UNPKG

prepack

Version:

Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.

99 lines (83 loc) 3.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SerializerStatistics = exports.ReactStatistics = exports.TimingStatistics = exports.BodyReference = undefined; exports.AreSameResidualBinding = AreSameResidualBinding; var _environment = require("../environment.js"); var _index = require("../values/index.js"); var _abstract = require("../methods/abstract.js"); var _realm = require("../realm.js"); var _invariant = require("../invariant.js"); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // TODO: add type for additional functions. function AreSameResidualBinding(realm, x, y) { if (x.serializedValue === y.serializedValue) return true; if (x.value && x.value === y.value) return true; if (x.value instanceof _index.ConcreteValue && y.value instanceof _index.ConcreteValue) { return (0, _abstract.SameValue)(realm, x.value, y.value); } return false; } /** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ class BodyReference { constructor(body, index) { (0, _invariant2.default)(index >= 0); this.body = body; this.index = index; } isNotEarlierThan(other) { return this.body === other.body && this.index >= other.index; } } exports.BodyReference = BodyReference; class TimingStatistics { constructor() { this.totalTime = 0; this.globalCodeTime = 0; this.initializeMoreModulesTime = 0; this.deepTraversalTime = 0; this.referenceCountsTime = 0; this.serializePassTime = 0; } } exports.TimingStatistics = TimingStatistics; class ReactStatistics { constructor() { this.optimizedTrees = 0; this.inlinedComponents = 0; this.evaluatedRootNodes = []; this.componentsEvaluated = 0; } } exports.ReactStatistics = ReactStatistics; class SerializerStatistics { constructor() { this.objects = 0; this.objectProperties = 0; this.functions = 0; this.functionClones = 0; this.referentialized = 0; this.valueIds = 0; this.valuesInlined = 0; this.delayedValues = 0; this.acceleratedModules = 0; this.delayedModules = 0; } log() { console.log(`=== serialization statistics`); console.log(`${this.objects} objects with ${this.objectProperties} properties`); console.log(`${this.functions} functions plus ${this.functionClones} clones due to captured variables; ${this.referentialized} captured mutable variables`); console.log(`${this.valueIds} eager and ${this.delayedValues} delayed value ids generated, and ${this.valuesInlined} values inlined`); console.log(`${this.acceleratedModules} accelerated and ${this.delayedModules} delayed modules.`); } } exports.SerializerStatistics = SerializerStatistics; //# sourceMappingURL=types.js.map