mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor(core): zero circulars + esm ready (#10770)
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
import { Trace } from '../trace';
|
||||
import { ios as iOSUtils } from './native-helper';
|
||||
import { ios as iOSUtils, isRealDevice } from './native-helper';
|
||||
import { debounce, throttle } from './shared';
|
||||
|
||||
export { clearInterval, clearTimeout, setInterval, setTimeout } from '../timer';
|
||||
export * from './animation-helpers';
|
||||
export * from './common';
|
||||
export * from './constants';
|
||||
export * from './debug';
|
||||
@ -9,12 +11,14 @@ export * from './layout-helper';
|
||||
export * from './macrotask-scheduler';
|
||||
export * from './mainthread-helper';
|
||||
export * from './native-helper';
|
||||
export * from './shared';
|
||||
export * from './types';
|
||||
export * from './native-helper';
|
||||
|
||||
export function openFile(filePath: string): boolean {
|
||||
try {
|
||||
const appPath = iOSUtils.getCurrentAppPath();
|
||||
const path = iOSUtils.isRealDevice() ? filePath.replace('~', appPath) : filePath;
|
||||
const path = isRealDevice() ? filePath.replace('~', appPath) : filePath;
|
||||
|
||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||
controller.delegate = iOSUtils.createUIDocumentInteractionControllerDelegate();
|
||||
@ -31,6 +35,39 @@ export function GC() {
|
||||
__collect();
|
||||
}
|
||||
|
||||
let throttledGC: Map<number, () => void>;
|
||||
let debouncedGC: Map<number, () => void>;
|
||||
|
||||
export function queueGC(delay = 900, useThrottle?: boolean) {
|
||||
/**
|
||||
* developers can use different queueGC settings to optimize their own apps
|
||||
* each setting is stored in a Map to reuse each time app calls it
|
||||
*/
|
||||
if (useThrottle) {
|
||||
if (!throttledGC) {
|
||||
throttledGC = new Map();
|
||||
}
|
||||
if (!throttledGC.get(delay)) {
|
||||
throttledGC.set(
|
||||
delay,
|
||||
throttle(() => GC(), delay),
|
||||
);
|
||||
}
|
||||
throttledGC.get(delay)();
|
||||
} else {
|
||||
if (!debouncedGC) {
|
||||
debouncedGC = new Map();
|
||||
}
|
||||
if (!debouncedGC.get(delay)) {
|
||||
debouncedGC.set(
|
||||
delay,
|
||||
debounce(() => GC(), delay),
|
||||
);
|
||||
}
|
||||
debouncedGC.get(delay)();
|
||||
}
|
||||
}
|
||||
|
||||
export function releaseNativeObject(object: NSObject) {
|
||||
__releaseNativeCounterpart(object);
|
||||
}
|
||||
@ -69,10 +106,6 @@ export function openUrlAsync(location: string): Promise<boolean> {
|
||||
});
|
||||
}
|
||||
|
||||
export function isRealDevice(): boolean {
|
||||
return iOSUtils.isRealDevice();
|
||||
}
|
||||
|
||||
export const ad = 0;
|
||||
|
||||
export function dismissSoftInput(nativeView?: UIView): void {
|
||||
|
||||
Reference in New Issue
Block a user