mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Some snapshot-specific fixes/improvements.
This commit is contained in:
@ -286,6 +286,11 @@ export class Console implements definition.Console {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private logMessage(message: string, messageType: number): void {
|
private logMessage(message: string, messageType: number): void {
|
||||||
|
if (!global.android) {
|
||||||
|
// This case may be entered during heap snapshot where the global.android is not present
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var arrayToLog = [];
|
var arrayToLog = [];
|
||||||
if (message.length > 4000) {
|
if (message.length > 4000) {
|
||||||
var i;
|
var i;
|
||||||
|
@ -6,6 +6,9 @@ global.moduleMerge = function (sourceExports: any, destExports: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import * as timerModule from "timer";
|
||||||
|
import * as dialogsModule from "ui/dialogs";
|
||||||
|
|
||||||
type ModuleLoader = () => any;
|
type ModuleLoader = () => any;
|
||||||
const modules: Map<string, ModuleLoader> = new Map<string, ModuleLoader>();
|
const modules: Map<string, ModuleLoader> = new Map<string, ModuleLoader>();
|
||||||
|
|
||||||
@ -54,16 +57,37 @@ function registerOnGlobalContext(name: string, module: string): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOnGlobalContext("setTimeout", "timer");
|
if (global.__snapshot) {
|
||||||
registerOnGlobalContext("clearTimeout", "timer");
|
// when we have a snapshot, it is better to pre-populate these on the global context to get them saved within the blob
|
||||||
registerOnGlobalContext("setInterval", "timer");
|
var timer: typeof timerModule = require("timer");
|
||||||
registerOnGlobalContext("clearInterval", "timer");
|
global.setTimeout = timer.setTimeout;
|
||||||
registerOnGlobalContext("alert", "ui/dialogs");
|
global.clearTimeout = timer.clearTimeout;
|
||||||
registerOnGlobalContext("confirm", "ui/dialogs");
|
global.setInterval = timer.setInterval;
|
||||||
registerOnGlobalContext("prompt", "ui/dialogs");
|
global.clearInterval = timer.clearInterval;
|
||||||
registerOnGlobalContext("XMLHttpRequest", "xhr");
|
|
||||||
registerOnGlobalContext("FormData", "xhr");
|
var dialogs: typeof dialogsModule = require("ui/dialogs");
|
||||||
registerOnGlobalContext("fetch", "fetch");
|
global.alert = dialogs.alert;
|
||||||
|
global.confirm = dialogs.confirm;
|
||||||
|
global.prompt = dialogs.prompt;
|
||||||
|
|
||||||
|
var xhr = require("xhr");
|
||||||
|
global.XMLHttpRequest = xhr.XMLHttpRequest;
|
||||||
|
global.FormData = xhr.FormData;
|
||||||
|
|
||||||
|
var fetch = require("fetch");
|
||||||
|
global.fetch = fetch.fetch;
|
||||||
|
} else {
|
||||||
|
registerOnGlobalContext("setTimeout", "timer");
|
||||||
|
registerOnGlobalContext("clearTimeout", "timer");
|
||||||
|
registerOnGlobalContext("setInterval", "timer");
|
||||||
|
registerOnGlobalContext("clearInterval", "timer");
|
||||||
|
registerOnGlobalContext("alert", "ui/dialogs");
|
||||||
|
registerOnGlobalContext("confirm", "ui/dialogs");
|
||||||
|
registerOnGlobalContext("prompt", "ui/dialogs");
|
||||||
|
registerOnGlobalContext("XMLHttpRequest", "xhr");
|
||||||
|
registerOnGlobalContext("FormData", "xhr");
|
||||||
|
registerOnGlobalContext("fetch", "fetch");
|
||||||
|
}
|
||||||
|
|
||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
import consoleModule = require("console");
|
import consoleModule = require("console");
|
||||||
@ -107,7 +131,6 @@ export function Deprecated(target: Object, key?: string | symbol, descriptor?: a
|
|||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
console.log(`${(target && (<any>target).name || target)} is deprecated`);
|
console.log(`${(target && (<any>target).name || target)} is deprecated`);
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,11 @@ function _generateAmpMap(): any {
|
|||||||
return ampCodes;
|
return ampCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// android-specific implementation, which pre-populates the map to get it saved into the heap blob
|
||||||
|
if (global.__snapshot) {
|
||||||
|
_ampCodes = _generateAmpMap();
|
||||||
|
}
|
||||||
|
|
||||||
function _HandleAmpEntities(found: string, decimalValue: string, hexValue: string, wordValue: string): string {
|
function _HandleAmpEntities(found: string, decimalValue: string, hexValue: string, wordValue: string): string {
|
||||||
|
|
||||||
if (wordValue) {
|
if (wordValue) {
|
||||||
|
Reference in New Issue
Block a user