mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +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 {
|
||||
if (!global.android) {
|
||||
// This case may be entered during heap snapshot where the global.android is not present
|
||||
return;
|
||||
}
|
||||
|
||||
var arrayToLog = [];
|
||||
if (message.length > 4000) {
|
||||
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;
|
||||
const modules: Map<string, ModuleLoader> = new Map<string, ModuleLoader>();
|
||||
|
||||
@ -54,16 +57,37 @@ function registerOnGlobalContext(name: string, module: string): void {
|
||||
});
|
||||
}
|
||||
|
||||
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");
|
||||
if (global.__snapshot) {
|
||||
// when we have a snapshot, it is better to pre-populate these on the global context to get them saved within the blob
|
||||
var timer: typeof timerModule = require("timer");
|
||||
global.setTimeout = timer.setTimeout;
|
||||
global.clearTimeout = timer.clearTimeout;
|
||||
global.setInterval = timer.setInterval;
|
||||
global.clearInterval = timer.clearInterval;
|
||||
|
||||
var dialogs: typeof dialogsModule = require("ui/dialogs");
|
||||
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 consoleModule = require("console");
|
||||
@ -107,7 +131,6 @@ export function Deprecated(target: Object, key?: string | symbol, descriptor?: a
|
||||
|
||||
return descriptor;
|
||||
} else {
|
||||
|
||||
console.log(`${(target && (<any>target).name || target)} is deprecated`);
|
||||
return target;
|
||||
}
|
||||
|
@ -83,6 +83,11 @@ function _generateAmpMap(): any {
|
||||
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 {
|
||||
|
||||
if (wordValue) {
|
||||
|
Reference in New Issue
Block a user