82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
exports.default = function (realm) {
|
|
var global = realm.$GlobalObject;
|
|
|
|
global.$DefineOwnProperty("global", {
|
|
value: global,
|
|
writable: true,
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
|
|
var _arr = ["undefined", "NaN", "Infinity"];
|
|
for (var _i = 0; _i < _arr.length; _i++) {
|
|
var name = _arr[_i];
|
|
global.$DefineOwnProperty(name, {
|
|
value: realm.intrinsics[name],
|
|
writable: false,
|
|
enumerable: false,
|
|
configurable: false
|
|
});
|
|
}
|
|
var typeNames = ["String", "Object", "Function", "Array", "Number", "RegExp", "Date", "Math", "Error", "Function", "TypeError", "RangeError", "ReferenceError", "SyntaxError", "URIError", "EvalError", "Boolean", "DataView", "Float32Array", "Float64Array", "Int8Array", "Int16Array", "Int32Array", "Map", "Set", "WeakMap", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "ArrayBuffer", "JSON"];
|
|
if (!realm.isCompatibleWith(realm.MOBILE_JSC_VERSION)) typeNames = typeNames.concat("Symbol", "Promise", "WeakSet", "Proxy", "Reflect");
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = typeNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var _name = _step.value;
|
|
|
|
// need to check if the property exists (it may not due to --compatibility)
|
|
if (realm.intrinsics[_name]) {
|
|
global.$DefineOwnProperty(_name, {
|
|
value: realm.intrinsics[_name],
|
|
writable: true,
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
} else {
|
|
(0, _invariant2.default)(_name === "Symbol" || _name === "Promise" || _name === "WeakSet" || _name === "Proxy" || _name === "Reflect");
|
|
(0, _invariant2.default)(realm.isCompatibleWith(realm.MOBILE_JSC_VERSION));
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
_iterator.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
|
|
var _arr2 = ["parseFloat", "parseInt", "console", "isNaN", "eval", "isFinite", "encodeURI", "decodeURI", "encodeURIComponent", "decodeURIComponent"];
|
|
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
|
var _name2 = _arr2[_i2];
|
|
global.$DefineOwnProperty(_name2, {
|
|
value: realm.intrinsics[_name2],
|
|
writable: true,
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
}
|
|
};
|
|
|
|
var _invariant = require("../../invariant.js");
|
|
|
|
var _invariant2 = _interopRequireDefault(_invariant);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
//# sourceMappingURL=global.js.map
|