@aurelia/platform
Advanced tools
Comparing version 0.8.0-dev.202010260913 to 0.8.0-dev.202010270226
@@ -0,3 +1,9 @@ | ||
function notImplemented(name) { | ||
return function notImplemented() { | ||
throw new Error(`The PLATFORM did not receive a valid reference to the global function '${name}'.`); // TODO: link to docs describing how to fix this issue | ||
}; | ||
} | ||
export class Platform { | ||
constructor(g, overrides = {}) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
this.macroTaskRequested = false; | ||
@@ -13,10 +19,10 @@ this.macroTaskHandle = -1; | ||
this.Reflect = 'Reflect' in overrides ? overrides.Reflect : g.Reflect; | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval : g.clearInterval.bind(g); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout : g.clearTimeout.bind(g); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch : g.fetch.bind(g); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask : g.queueMicrotask.bind(g); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval : g.setInterval.bind(g); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout : g.setTimeout.bind(g); | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval : (_b = (_a = g.clearInterval) === null || _a === void 0 ? void 0 : _a.bind(g)) !== null && _b !== void 0 ? _b : notImplemented('clearInterval'); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout : (_d = (_c = g.clearTimeout) === null || _c === void 0 ? void 0 : _c.bind(g)) !== null && _d !== void 0 ? _d : notImplemented('clearTimeout'); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch : (_f = (_e = g.fetch) === null || _e === void 0 ? void 0 : _e.bind(g)) !== null && _f !== void 0 ? _f : notImplemented('fetch'); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask : (_h = (_g = g.queueMicrotask) === null || _g === void 0 ? void 0 : _g.bind(g)) !== null && _h !== void 0 ? _h : notImplemented('queueMicrotask'); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval : (_k = (_j = g.setInterval) === null || _j === void 0 ? void 0 : _j.bind(g)) !== null && _k !== void 0 ? _k : notImplemented('setInterval'); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout : (_m = (_l = g.setTimeout) === null || _l === void 0 ? void 0 : _l.bind(g)) !== null && _m !== void 0 ? _m : notImplemented('setTimeout'); | ||
this.console = 'console' in overrides ? overrides.console : g.console; | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow : g.performance.now.bind(g.performance); | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow : (_q = (_p = (_o = g.performance) === null || _o === void 0 ? void 0 : _o.now) === null || _p === void 0 ? void 0 : _p.bind(g.performance)) !== null && _q !== void 0 ? _q : notImplemented('performance.now'); | ||
this.flushMacroTask = this.flushMacroTask.bind(this); | ||
@@ -23,0 +29,0 @@ this.macroTaskQueue = new TaskQueue(this, this.requestMacroTask.bind(this), this.cancelMacroTask.bind(this)); |
@@ -13,4 +13,10 @@ (function (factory) { | ||
exports.TaskQueuePriority = exports.Task = exports.TaskStatus = exports.TaskAbortError = exports.TaskQueue = exports.Platform = void 0; | ||
function notImplemented(name) { | ||
return function notImplemented() { | ||
throw new Error(`The PLATFORM did not receive a valid reference to the global function '${name}'.`); // TODO: link to docs describing how to fix this issue | ||
}; | ||
} | ||
class Platform { | ||
constructor(g, overrides = {}) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; | ||
this.macroTaskRequested = false; | ||
@@ -26,10 +32,10 @@ this.macroTaskHandle = -1; | ||
this.Reflect = 'Reflect' in overrides ? overrides.Reflect : g.Reflect; | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval : g.clearInterval.bind(g); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout : g.clearTimeout.bind(g); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch : g.fetch.bind(g); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask : g.queueMicrotask.bind(g); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval : g.setInterval.bind(g); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout : g.setTimeout.bind(g); | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval : (_b = (_a = g.clearInterval) === null || _a === void 0 ? void 0 : _a.bind(g)) !== null && _b !== void 0 ? _b : notImplemented('clearInterval'); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout : (_d = (_c = g.clearTimeout) === null || _c === void 0 ? void 0 : _c.bind(g)) !== null && _d !== void 0 ? _d : notImplemented('clearTimeout'); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch : (_f = (_e = g.fetch) === null || _e === void 0 ? void 0 : _e.bind(g)) !== null && _f !== void 0 ? _f : notImplemented('fetch'); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask : (_h = (_g = g.queueMicrotask) === null || _g === void 0 ? void 0 : _g.bind(g)) !== null && _h !== void 0 ? _h : notImplemented('queueMicrotask'); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval : (_k = (_j = g.setInterval) === null || _j === void 0 ? void 0 : _j.bind(g)) !== null && _k !== void 0 ? _k : notImplemented('setInterval'); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout : (_m = (_l = g.setTimeout) === null || _l === void 0 ? void 0 : _l.bind(g)) !== null && _m !== void 0 ? _m : notImplemented('setTimeout'); | ||
this.console = 'console' in overrides ? overrides.console : g.console; | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow : g.performance.now.bind(g.performance); | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow : (_q = (_p = (_o = g.performance) === null || _o === void 0 ? void 0 : _o.now) === null || _p === void 0 ? void 0 : _p.bind(g.performance)) !== null && _q !== void 0 ? _q : notImplemented('performance.now'); | ||
this.flushMacroTask = this.flushMacroTask.bind(this); | ||
@@ -36,0 +42,0 @@ this.macroTaskQueue = new TaskQueue(this, this.requestMacroTask.bind(this), this.cancelMacroTask.bind(this)); |
{ | ||
"name": "@aurelia/platform", | ||
"version": "0.8.0-dev.202010260913", | ||
"version": "0.8.0-dev.202010270226", | ||
"main": "dist/umd/index.js", | ||
@@ -39,3 +39,3 @@ "module": "dist/esnext/index.js", | ||
}, | ||
"gitHead": "3b448c94f9fb0e36e5a4804261cc8f5d99a0483a" | ||
"gitHead": "4ae32258c74dbe7e711bb83d7174ee1510260559" | ||
} |
@@ -16,2 +16,8 @@ // Limit the accessible properties to that of the native ES globalThis and WindowOrWorkerGlobalScope by default. | ||
function notImplemented(name: string): (...args: any[]) => any { | ||
return function notImplemented() { | ||
throw new Error(`The PLATFORM did not receive a valid reference to the global function '${name}'.`); // TODO: link to docs describing how to fix this issue | ||
}; | ||
} | ||
export class Platform<TGlobal extends GlobalThisOrWindowOrWorkerGlobalScope = GlobalThisOrWindowOrWorkerGlobalScope> { | ||
@@ -61,11 +67,11 @@ // http://www.ecma-international.org/ecma-262/#sec-value-properties-of-the-global-object | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval! : g.clearInterval.bind(g); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout! : g.clearTimeout.bind(g); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch! : g.fetch.bind(g); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask! : g.queueMicrotask.bind(g); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval! : g.setInterval.bind(g); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout! : g.setTimeout.bind(g); | ||
this.clearInterval = 'clearInterval' in overrides ? overrides.clearInterval! : g.clearInterval?.bind(g) ?? notImplemented('clearInterval'); | ||
this.clearTimeout = 'clearTimeout' in overrides ? overrides.clearTimeout! : g.clearTimeout?.bind(g) ?? notImplemented('clearTimeout'); | ||
this.fetch = 'fetch' in overrides ? overrides.fetch! : g.fetch?.bind(g) ?? notImplemented('fetch'); | ||
this.queueMicrotask = 'queueMicrotask' in overrides ? overrides.queueMicrotask! : g.queueMicrotask?.bind(g) ?? notImplemented('queueMicrotask'); | ||
this.setInterval = 'setInterval' in overrides ? overrides.setInterval! : g.setInterval?.bind(g) ?? notImplemented('setInterval'); | ||
this.setTimeout = 'setTimeout' in overrides ? overrides.setTimeout! : g.setTimeout?.bind(g) ?? notImplemented('setTimeout'); | ||
this.console = 'console' in overrides ? overrides.console! : g.console; | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow! : g.performance.now.bind(g.performance); | ||
this.performanceNow = 'performanceNow' in overrides ? overrides.performanceNow! : g.performance?.now?.bind(g.performance) ?? notImplemented('performance.now'); | ||
@@ -72,0 +78,0 @@ this.flushMacroTask = this.flushMacroTask.bind(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
140797
2202