mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
timer and dialogs modules will be loaded lazy
This commit is contained in:
@ -6,16 +6,47 @@ global.moduleMerge = function (sourceExports: any, destExports: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
import types = require("utils/types");
|
|
||||||
import timer = require("timer");
|
|
||||||
import consoleModule = require("console");
|
import consoleModule = require("console");
|
||||||
import xhr = require("../xhr/xhr");
|
|
||||||
import dialogs = require("ui/dialogs");
|
|
||||||
|
|
||||||
global.setTimeout = timer.setTimeout;
|
var c = new consoleModule.Console();
|
||||||
global.clearTimeout = timer.clearTimeout;
|
|
||||||
global.setInterval = timer.setInterval;
|
if (platform.device.os === platform.platformNames.android) {
|
||||||
global.clearInterval = timer.clearInterval;
|
global.console = c;
|
||||||
|
} else if (platform.device.os === platform.platformNames.ios) {
|
||||||
|
global.console.dump = function (args) { c.dump(args); };
|
||||||
|
}
|
||||||
|
|
||||||
|
global.setTimeout = function (callback, milliseconds) {
|
||||||
|
let tm = require("timer");
|
||||||
|
return tm.setTimeout(callback, milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.clearTimeout = function (id) {
|
||||||
|
let tm = require("timer");
|
||||||
|
tm.clearTimeout(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.setInterval = function (callback, milliseconds) {
|
||||||
|
let tm = require("timer");
|
||||||
|
return tm.setInterval(callback, milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.clearInterval = function (id) {
|
||||||
|
let tm = require("timer");
|
||||||
|
tm.clearInterval(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.alert = function (args) {
|
||||||
|
let dm = require("ui/dialogs");
|
||||||
|
return dm.alert(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
var xhr = require("../xhr/xhr");
|
||||||
|
global.moduleMerge(xhr, global);
|
||||||
|
|
||||||
|
// Fetch module should be after XMLHttpRequest/FormData!
|
||||||
|
var fetchModule = require("fetch");
|
||||||
|
global.moduleMerge(fetchModule, global);
|
||||||
|
|
||||||
if (typeof global.__decorate !== "function") {
|
if (typeof global.__decorate !== "function") {
|
||||||
global.__decorate = function (decorators, target, key, desc) {
|
global.__decorate = function (decorators, target, key, desc) {
|
||||||
@ -28,24 +59,8 @@ if (typeof global.__decorate !== "function") {
|
|||||||
case 4: return decorators.reduceRight(function (o, d) { return (d && d(target, key, o)) || o; }, desc);
|
case 4: return decorators.reduceRight(function (o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var c = new consoleModule.Console();
|
|
||||||
|
|
||||||
if (platform.device.os === platform.platformNames.android) {
|
|
||||||
global.console = c;
|
|
||||||
} else if (platform.device.os === platform.platformNames.ios) {
|
|
||||||
global.console.dump = function (args) { c.dump(args); };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.XMLHttpRequest = xhr.XMLHttpRequest;
|
|
||||||
global.FormData = xhr.FormData;
|
|
||||||
global.alert = dialogs.alert;
|
|
||||||
|
|
||||||
// Fetch module should be after XMLHttpRequest/FormData!
|
|
||||||
var fetchModule = require("fetch");
|
|
||||||
global.moduleMerge(fetchModule, global);
|
|
||||||
|
|
||||||
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
|
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
var originalMethod = descriptor.value;
|
var originalMethod = descriptor.value;
|
||||||
|
Reference in New Issue
Block a user