refactor: add __snapshot in d.ts and fix checks

This commit is contained in:
vakrilov
2019-08-02 11:34:24 +03:00
parent 52b8152362
commit fed360d763
6 changed files with 8 additions and 8 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
} }
} }

View File

@ -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();
} }

View File

@ -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) {

View File

@ -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();
} }