mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
refactor: add __snapshot in d.ts and fix checks
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
// Require globals first so that snapshot takes __extends function.
|
// Require globals first so that snapshot takes __extends function.
|
||||||
require("../globals");
|
import "../globals";
|
||||||
|
|
||||||
import { Observable, EventData } from "../data/observable";
|
import { Observable, EventData } from "../data/observable";
|
||||||
import { View } from "../ui/core/view";
|
import { View } from "../ui/core/view";
|
||||||
import {
|
import {
|
||||||
|
@ -17,7 +17,7 @@ function registerOnGlobalContext(moduleName: string, exportName: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function installPolyfills(moduleName: string, exportNames: string[]) {
|
export function installPolyfills(moduleName: string, exportNames: string[]) {
|
||||||
if ((<any>global).__snapshot || (<any>global).__snapshotEnabled) {
|
if (global.__snapshot) {
|
||||||
const loadedModule = global.loadModule(moduleName);
|
const loadedModule = global.loadModule(moduleName);
|
||||||
exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]);
|
exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]);
|
||||||
} else {
|
} else {
|
||||||
|
1
tns-core-modules/module.d.ts
vendored
1
tns-core-modules/module.d.ts
vendored
@ -82,6 +82,7 @@ declare namespace NodeJS {
|
|||||||
__onUncaughtError: (error: NativeScriptError) => void;
|
__onUncaughtError: (error: NativeScriptError) => void;
|
||||||
__onDiscardedError: (error: NativeScriptError) => void;
|
__onDiscardedError: (error: NativeScriptError) => void;
|
||||||
TNS_WEBPACK?: boolean;
|
TNS_WEBPACK?: boolean;
|
||||||
|
__snapshot?: boolean;
|
||||||
__requireOverride?: (name: string, dir: string) => any;
|
__requireOverride?: (name: string, dir: string) => any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { setActivityCallbacks, AndroidActivityCallbacks } from "./frame";
|
|||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
import * as appModule from "../../application";
|
import * as appModule from "../../application";
|
||||||
|
|
||||||
if ((<any>global).__snapshot || (<any>global).__snapshotEnabled) {
|
if (global.__snapshot) {
|
||||||
globals.install();
|
globals.install();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,14 +106,14 @@ function _HandleAmpEntities(found, decimalValue, hexValue, wordValue) {
|
|||||||
}
|
}
|
||||||
var res = _ampCodes.get(wordValue);
|
var res = _ampCodes.get(wordValue);
|
||||||
if (res) {
|
if (res) {
|
||||||
return String.fromCharCode(res);
|
return String.fromCodePoint(res);
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
if (decimalValue) {
|
if (decimalValue) {
|
||||||
return String.fromCharCode(parseInt(decimalValue, 10));
|
return String.fromCodePoint(parseInt(decimalValue, 10));
|
||||||
}
|
}
|
||||||
return String.fromCharCode(parseInt(hexValue, 16));
|
return String.fromCodePoint(parseInt(hexValue, 16));
|
||||||
}
|
}
|
||||||
var XmlParser = (function () {
|
var XmlParser = (function () {
|
||||||
function XmlParser(onEvent, onError, processNamespaces) {
|
function XmlParser(onEvent, onError, processNamespaces) {
|
||||||
|
@ -88,7 +88,7 @@ function _generateAmpMap(): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// android-specific implementation, which pre-populates the map to get it saved into the heap blob
|
// android-specific implementation, which pre-populates the map to get it saved into the heap blob
|
||||||
if ((<any>global).__snapshot) {
|
if (global.__snapshot) {
|
||||||
_ampCodes = _generateAmpMap();
|
_ampCodes = _generateAmpMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user