Merge branch 'upgrade' of https://github.com/CendioOssman/noVNC
This commit is contained in:
commit
30ff15a35a
|
@ -4,7 +4,7 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
node_js:
|
node_js:
|
||||||
- 6
|
- lts/*
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- TEST_BROWSER_NAME=chrome TEST_BROWSER_OS='Windows 10'
|
- TEST_BROWSER_NAME=chrome TEST_BROWSER_OS='Windows 10'
|
||||||
|
|
54
package.json
54
package.json
|
@ -19,7 +19,7 @@
|
||||||
"vendor/pako"
|
"vendor/pako"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint app core po tests utils",
|
"lint": "eslint app core po/po2js po/xgettext-html tests utils",
|
||||||
"test": "karma start karma.conf.js",
|
"test": "karma start karma.conf.js",
|
||||||
"prepublish": "node ./utils/use_require.js --as commonjs --clean"
|
"prepublish": "node ./utils/use_require.js --as commonjs --clean"
|
||||||
},
|
},
|
||||||
|
@ -40,36 +40,36 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/novnc/noVNC",
|
"homepage": "https://github.com/novnc/noVNC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.22.1",
|
"babel-core": "*",
|
||||||
"babel-plugin-add-module-exports": "^0.2.1",
|
"babel-plugin-add-module-exports": "*",
|
||||||
"babel-plugin-import-redirect": "*",
|
"babel-plugin-import-redirect": "*",
|
||||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
"babel-plugin-syntax-dynamic-import": "*",
|
||||||
"babel-plugin-transform-es2015-modules-amd": "^6.22.0",
|
"babel-plugin-transform-es2015-modules-amd": "*",
|
||||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
|
"babel-plugin-transform-es2015-modules-commonjs": "*",
|
||||||
"babel-plugin-transform-es2015-modules-systemjs": "^6.22.0",
|
"babel-plugin-transform-es2015-modules-systemjs": "*",
|
||||||
"babel-plugin-transform-es2015-modules-umd": "^6.22.0",
|
"babel-plugin-transform-es2015-modules-umd": "*",
|
||||||
"babel-preset-es2015": "^6.24.1",
|
"babel-preset-es2015": "*",
|
||||||
"babelify": "^7.3.0",
|
"babelify": "*",
|
||||||
"browserify": "^13.1.0",
|
"browserify": "*",
|
||||||
"chai": "^3.5.0",
|
"chai": "*",
|
||||||
"commander": "^2.9.0",
|
"commander": "*",
|
||||||
"es-module-loader": "^2.1.0",
|
"es-module-loader": "*",
|
||||||
"eslint": "^4.16.0",
|
"eslint": "*",
|
||||||
"fs-extra": "^1.0.0",
|
"fs-extra": "*",
|
||||||
"jsdom": "*",
|
"jsdom": "*",
|
||||||
"karma": "^1.3.0",
|
"karma": "*",
|
||||||
"karma-mocha": "^1.3.0",
|
"karma-mocha": "*",
|
||||||
"karma-mocha-reporter": "^2.2.0",
|
"karma-mocha-reporter": "*",
|
||||||
"karma-sauce-launcher": "^1.0.0",
|
"karma-sauce-launcher": "*",
|
||||||
"karma-sinon-chai": "^2.0.0",
|
"karma-sinon-chai": "*",
|
||||||
"mocha": "^3.1.2",
|
"mocha": "*",
|
||||||
"node-getopt": "*",
|
"node-getopt": "*",
|
||||||
"po2json": "*",
|
"po2json": "*",
|
||||||
"requirejs": "^2.3.2",
|
"requirejs": "*",
|
||||||
"rollup": "^0.41.4",
|
"rollup": "*",
|
||||||
"rollup-plugin-node-resolve": "^2.0.0",
|
"rollup-plugin-node-resolve": "*",
|
||||||
"sinon": "^4.0.0",
|
"sinon": "*",
|
||||||
"sinon-chai": "^2.8.0"
|
"sinon-chai": "*"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
},
|
||||||
|
}
|
4
po/po2js
4
po/po2js
|
@ -22,7 +22,7 @@ const fs = require('fs');
|
||||||
const po2json = require("po2json");
|
const po2json = require("po2json");
|
||||||
|
|
||||||
const opt = getopt.create([
|
const opt = getopt.create([
|
||||||
['h' , 'help' , 'display this help'],
|
['h', 'help', 'display this help'],
|
||||||
]).bindHelp().parseSystem();
|
]).bindHelp().parseSystem();
|
||||||
|
|
||||||
if (opt.argv.length != 2) {
|
if (opt.argv.length != 2) {
|
||||||
|
@ -32,7 +32,7 @@ if (opt.argv.length != 2) {
|
||||||
|
|
||||||
const data = po2json.parseFileSync(opt.argv[0]);
|
const data = po2json.parseFileSync(opt.argv[0]);
|
||||||
|
|
||||||
const bodyPart = Object.keys(data).filter((msgid) => msgid !== "").map((msgid) => {
|
const bodyPart = Object.keys(data).filter(msgid => msgid !== "").map((msgid) => {
|
||||||
if (msgid === "") return;
|
if (msgid === "") return;
|
||||||
const msgstr = data[msgid][1];
|
const msgstr = data[msgid][1];
|
||||||
return " " + JSON.stringify(msgid) + ": " + JSON.stringify(msgstr);
|
return " " + JSON.stringify(msgid) + ": " + JSON.stringify(msgstr);
|
||||||
|
|
|
@ -10,8 +10,8 @@ const jsdom = require("jsdom");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
const opt = getopt.create([
|
const opt = getopt.create([
|
||||||
['o' , 'output=FILE' , 'write output to specified file'],
|
['o', 'output=FILE', 'write output to specified file'],
|
||||||
['h' , 'help' , 'display this help'],
|
['h', 'help', 'display this help'],
|
||||||
]).bindHelp().parseSystem();
|
]).bindHelp().parseSystem();
|
||||||
|
|
||||||
const strings = {};
|
const strings = {};
|
||||||
|
@ -22,7 +22,7 @@ function addString(str, location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings[str] === undefined) {
|
if (strings[str] === undefined) {
|
||||||
strings[str] = {}
|
strings[str] = {};
|
||||||
}
|
}
|
||||||
strings[str][location] = null;
|
strings[str][location] = null;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ function process(elem, locator, enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < elem.childNodes.length; i++) {
|
for (let i = 0; i < elem.childNodes.length; i++) {
|
||||||
node = elem.childNodes[i];
|
let node = elem.childNodes[i];
|
||||||
if (node.nodeType === node.ELEMENT_NODE) {
|
if (node.nodeType === node.ELEMENT_NODE) {
|
||||||
process(node, locator, enabled);
|
process(node, locator, enabled);
|
||||||
} else if (node.nodeType === node.TEXT_NODE && enabled) {
|
} else if (node.nodeType === node.TEXT_NODE && enabled) {
|
||||||
|
@ -89,18 +89,18 @@ for (let i = 0; i < opt.argv.length; i++) {
|
||||||
const dom = new jsdom.JSDOM(file, { includeNodeLocations: true });
|
const dom = new jsdom.JSDOM(file, { includeNodeLocations: true });
|
||||||
const body = dom.window.document.body;
|
const body = dom.window.document.body;
|
||||||
|
|
||||||
function locator(elem) {
|
let locator = (elem) => {
|
||||||
const offset = dom.nodeLocation(elem).startOffset;
|
const offset = dom.nodeLocation(elem).startOffset;
|
||||||
const line = file.slice(0, offset).split("\n").length;
|
const line = file.slice(0, offset).split("\n").length;
|
||||||
return fn + ":" + line;
|
return fn + ":" + line;
|
||||||
}
|
};
|
||||||
|
|
||||||
process(body, locator, true);
|
process(body, locator, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = "";
|
let output = "";
|
||||||
|
|
||||||
for (str in strings) {
|
for (let str in strings) {
|
||||||
output += "#:";
|
output += "#:";
|
||||||
for (location in strings[str]) {
|
for (location in strings[str]) {
|
||||||
output += " " + location;
|
output += " " + location;
|
||||||
|
|
|
@ -437,7 +437,7 @@ describe('Key Event Handling', function () {
|
||||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0x61, "KeyA", true);
|
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0x61, "KeyA", true);
|
||||||
|
|
||||||
// Check that the timer is properly dead
|
// Check that the timer is properly dead
|
||||||
kbd.onkeyevent.reset();
|
kbd.onkeyevent.resetHistory();
|
||||||
this.clock.tick(100);
|
this.clock.tick(100);
|
||||||
expect(kbd.onkeyevent).to.not.have.been.called;
|
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
|
@ -455,7 +455,7 @@ describe('Key Event Handling', function () {
|
||||||
expect(kbd.onkeyevent.thirdCall).to.have.been.calledWith(0x61, "KeyA", false);
|
expect(kbd.onkeyevent.thirdCall).to.have.been.calledWith(0x61, "KeyA", false);
|
||||||
|
|
||||||
// Check that the timer is properly dead
|
// Check that the timer is properly dead
|
||||||
kbd.onkeyevent.reset();
|
kbd.onkeyevent.resetHistory();
|
||||||
this.clock.tick(100);
|
this.clock.tick(100);
|
||||||
expect(kbd.onkeyevent).to.not.have.been.called;
|
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
|
@ -470,7 +470,7 @@ describe('Key Event Handling', function () {
|
||||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xfe03, 'AltRight', true);
|
expect(kbd.onkeyevent).to.have.been.calledWith(0xfe03, 'AltRight', true);
|
||||||
|
|
||||||
// Check that the timer is properly dead
|
// Check that the timer is properly dead
|
||||||
kbd.onkeyevent.reset();
|
kbd.onkeyevent.resetHistory();
|
||||||
this.clock.tick(100);
|
this.clock.tick(100);
|
||||||
expect(kbd.onkeyevent).to.not.have.been.called;
|
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
|
@ -486,7 +486,7 @@ describe('Key Event Handling', function () {
|
||||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffea, "AltRight", true);
|
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffea, "AltRight", true);
|
||||||
|
|
||||||
// Check that the timer is properly dead
|
// Check that the timer is properly dead
|
||||||
kbd.onkeyevent.reset();
|
kbd.onkeyevent.resetHistory();
|
||||||
this.clock.tick(100);
|
this.clock.tick(100);
|
||||||
expect(kbd.onkeyevent).to.not.have.been.called;
|
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
|
|
|
@ -271,7 +271,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
it('should move focus to canvas object', function () {
|
it('should move focus to canvas object', function () {
|
||||||
client._canvas.focus = sinon.spy();
|
client._canvas.focus = sinon.spy();
|
||||||
client.focus();
|
client.focus();
|
||||||
expect(client._canvas.focus).to.have.been.called.once;
|
expect(client._canvas.focus).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
it('should remove focus from canvas object', function () {
|
it('should remove focus from canvas object', function () {
|
||||||
client._canvas.blur = sinon.spy();
|
client._canvas.blur = sinon.spy();
|
||||||
client.blur();
|
client.blur();
|
||||||
expect(client._canvas.blur).to.have.been.called.once;
|
expect(client._canvas.blur).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
client.clipViewport = false;
|
client.clipViewport = false;
|
||||||
expect(spy.set).to.have.been.calledOnce;
|
expect(spy.set).to.have.been.calledOnce;
|
||||||
expect(spy.set).to.have.been.calledWith(false);
|
expect(spy.set).to.have.been.calledWith(false);
|
||||||
spy.set.reset();
|
spy.set.resetHistory();
|
||||||
|
|
||||||
client.clipViewport = true;
|
client.clipViewport = true;
|
||||||
expect(spy.set).to.have.been.calledOnce;
|
expect(spy.set).to.have.been.calledOnce;
|
||||||
|
@ -438,7 +438,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
client._handleMouseButton(13, 9, 0x000);
|
client._handleMouseButton(13, 9, 0x000);
|
||||||
expect(RFB.messages.pointerEvent).to.have.been.calledTwice;
|
expect(RFB.messages.pointerEvent).to.have.been.calledTwice;
|
||||||
|
|
||||||
RFB.messages.pointerEvent.reset();
|
RFB.messages.pointerEvent.resetHistory();
|
||||||
|
|
||||||
// Small movement
|
// Small movement
|
||||||
client._handleMouseButton(13, 9, 0x001);
|
client._handleMouseButton(13, 9, 0x001);
|
||||||
|
@ -472,7 +472,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
expect(client._display.viewportChangePos).to.have.been.calledOnce;
|
expect(client._display.viewportChangePos).to.have.been.calledOnce;
|
||||||
expect(client._display.viewportChangePos).to.have.been.calledWith(-30, 0);
|
expect(client._display.viewportChangePos).to.have.been.calledWith(-30, 0);
|
||||||
|
|
||||||
client._display.viewportChangePos.reset();
|
client._display.viewportChangePos.resetHistory();
|
||||||
|
|
||||||
// Now a small movement should move right away
|
// Now a small movement should move right away
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
expect(spy.set).to.have.been.calledOnce;
|
expect(spy.set).to.have.been.calledOnce;
|
||||||
expect(spy.set).to.have.been.calledWith(true);
|
expect(spy.set).to.have.been.calledWith(true);
|
||||||
|
|
||||||
spy.set.reset();
|
spy.set.resetHistory();
|
||||||
|
|
||||||
client.scaleViewport = true;
|
client.scaleViewport = true;
|
||||||
expect(spy.set).to.have.been.calledOnce;
|
expect(spy.set).to.have.been.calledOnce;
|
||||||
|
@ -633,7 +633,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
expect(RFB.messages.setDesktopSize).to.have.been.calledOnce;
|
expect(RFB.messages.setDesktopSize).to.have.been.calledOnce;
|
||||||
expect(RFB.messages.setDesktopSize).to.have.been.calledWith(sinon.match.object, 70, 80, 0, 0);
|
expect(RFB.messages.setDesktopSize).to.have.been.calledWith(sinon.match.object, 70, 80, 0, 0);
|
||||||
|
|
||||||
RFB.messages.setDesktopSize.reset();
|
RFB.messages.setDesktopSize.resetHistory();
|
||||||
|
|
||||||
// Second message should not trigger a resize
|
// Second message should not trigger a resize
|
||||||
|
|
||||||
|
@ -2056,7 +2056,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
client.showDotCursor = true;
|
client.showDotCursor = true;
|
||||||
// Was called when we enabled dot cursor
|
// Was called when we enabled dot cursor
|
||||||
client._cursor.change.reset();
|
client._cursor.change.resetHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show a standard cursor', function () {
|
it('should show a standard cursor', function () {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,74 +1,71 @@
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||||
typeof define === 'function' && define.amd ? define(factory) :
|
typeof define === 'function' && define.amd ? define(factory) :
|
||||||
(global.BrowserESModuleLoader = factory());
|
(global = global || self, global.BrowserESModuleLoader = factory());
|
||||||
}(this, (function () { 'use strict';
|
}(this, function () { 'use strict';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Environment
|
* Environment
|
||||||
*/
|
*/
|
||||||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||||
var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
||||||
var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);
|
var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);
|
||||||
|
|
||||||
var envGlobal = typeof self !== 'undefined' ? self : global;
|
var envGlobal = typeof self !== 'undefined' ? self : global;
|
||||||
/*
|
|
||||||
|
/*
|
||||||
* Simple Symbol() shim
|
* Simple Symbol() shim
|
||||||
*/
|
*/
|
||||||
var hasSymbol = typeof Symbol !== 'undefined';
|
var hasSymbol = typeof Symbol !== 'undefined';
|
||||||
function createSymbol (name) {
|
function createSymbol (name) {
|
||||||
return hasSymbol ? Symbol() : '@@' + name;
|
return hasSymbol ? Symbol() : '@@' + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
var toStringTag = hasSymbol && Symbol.toStringTag;
|
var toStringTag = hasSymbol && Symbol.toStringTag;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Environment baseURI
|
* Environment baseURI
|
||||||
*/
|
*/
|
||||||
var baseURI;
|
var baseURI;
|
||||||
|
|
||||||
// environent baseURI detection
|
// environent baseURI detection
|
||||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
baseURI = document.baseURI;
|
baseURI = document.baseURI;
|
||||||
|
|
||||||
if (!baseURI) {
|
if (!baseURI) {
|
||||||
var bases = document.getElementsByTagName('base');
|
var bases = document.getElementsByTagName('base');
|
||||||
baseURI = bases[0] && bases[0].href || window.location.href;
|
baseURI = bases[0] && bases[0].href || window.location.href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof location != 'undefined') {
|
else if (typeof location != 'undefined') {
|
||||||
baseURI = location.href;
|
baseURI = location.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanitize out the hash and querystring
|
// sanitize out the hash and querystring
|
||||||
if (baseURI) {
|
if (baseURI) {
|
||||||
baseURI = baseURI.split('#')[0].split('?')[0];
|
baseURI = baseURI.split('#')[0].split('?')[0];
|
||||||
var slashIndex = baseURI.lastIndexOf('/');
|
var slashIndex = baseURI.lastIndexOf('/');
|
||||||
if (slashIndex !== -1)
|
if (slashIndex !== -1)
|
||||||
baseURI = baseURI.substr(0, slashIndex + 1);
|
baseURI = baseURI.substr(0, slashIndex + 1);
|
||||||
}
|
}
|
||||||
else if (typeof process !== 'undefined' && process.cwd) {
|
else if (typeof process !== 'undefined' && process.cwd) {
|
||||||
baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd();
|
baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd();
|
||||||
if (isWindows)
|
if (isWindows)
|
||||||
baseURI = baseURI.replace(/\\/g, '/');
|
baseURI = baseURI.replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new TypeError('No environment baseURI');
|
throw new TypeError('No environment baseURI');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure baseURI has trailing "/"
|
// ensure baseURI has trailing "/"
|
||||||
if (baseURI[baseURI.length - 1] !== '/')
|
if (baseURI[baseURI.length - 1] !== '/')
|
||||||
baseURI += '/';
|
baseURI += '/';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LoaderError with chaining for loader stacks
|
* LoaderError with chaining for loader stacks
|
||||||
*/
|
*/
|
||||||
var errArgs = new Error(0, '_').fileName == '_';
|
var errArgs = new Error(0, '_').fileName == '_';
|
||||||
function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {
|
function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {
|
||||||
// Convert file:/// URLs to paths in Node
|
// Convert file:/// URLs to paths in Node
|
||||||
if (!isBrowser)
|
if (!isBrowser)
|
||||||
newMessage = newMessage.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
|
newMessage = newMessage.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
|
||||||
|
@ -93,14 +90,14 @@ function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage
|
||||||
err.originalErr = childErr.originalErr || childErr;
|
err.originalErr = childErr.originalErr || childErr;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
var resolvedPromise$1 = Promise.resolve();
|
var resolvedPromise = Promise.resolve();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple Array values shim
|
* Simple Array values shim
|
||||||
*/
|
*/
|
||||||
function arrayValues (arr) {
|
function arrayValues (arr) {
|
||||||
if (arr.values)
|
if (arr.values)
|
||||||
return arr.values();
|
return arr.values();
|
||||||
|
|
||||||
|
@ -127,35 +124,35 @@ function arrayValues (arr) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return iterable;
|
return iterable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 3. Reflect.Loader
|
* 3. Reflect.Loader
|
||||||
*
|
*
|
||||||
* We skip the entire native internal pipeline, just providing the bare API
|
* We skip the entire native internal pipeline, just providing the bare API
|
||||||
*/
|
*/
|
||||||
// 3.1.1
|
// 3.1.1
|
||||||
function Loader () {
|
function Loader () {
|
||||||
this.registry = new Registry();
|
this.registry = new Registry();
|
||||||
}
|
}
|
||||||
// 3.3.1
|
// 3.3.1
|
||||||
Loader.prototype.constructor = Loader;
|
Loader.prototype.constructor = Loader;
|
||||||
|
|
||||||
function ensureInstantiated (module) {
|
function ensureInstantiated (module) {
|
||||||
if (module === undefined)
|
if (module === undefined)
|
||||||
return;
|
return;
|
||||||
if (module instanceof ModuleNamespace === false && module[toStringTag] !== 'module')
|
if (module instanceof ModuleNamespace === false && module[toStringTag] !== 'module')
|
||||||
throw new TypeError('Module instantiation did not return a valid namespace object.');
|
throw new TypeError('Module instantiation did not return a valid namespace object.');
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.3.2
|
// 3.3.2
|
||||||
Loader.prototype.import = function (key, parent) {
|
Loader.prototype.import = function (key, parent) {
|
||||||
if (typeof key !== 'string')
|
if (typeof key !== 'string')
|
||||||
throw new TypeError('Loader import method must be passed a module key string');
|
throw new TypeError('Loader import method must be passed a module key string');
|
||||||
// custom resolveInstantiate combined hook for better perf
|
// custom resolveInstantiate combined hook for better perf
|
||||||
var loader = this;
|
var loader = this;
|
||||||
return resolvedPromise$1
|
return resolvedPromise
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return loader[RESOLVE_INSTANTIATE](key, parent);
|
return loader[RESOLVE_INSTANTIATE](key, parent);
|
||||||
})
|
})
|
||||||
|
@ -164,11 +161,11 @@ Loader.prototype.import = function (key, parent) {
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
throw LoaderError__Check_error_message_for_loader_stack(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
throw LoaderError__Check_error_message_for_loader_stack(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 3.3.3
|
// 3.3.3
|
||||||
var RESOLVE = Loader.resolve = createSymbol('resolve');
|
var RESOLVE = Loader.resolve = createSymbol('resolve');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combined resolve / instantiate hook
|
* Combined resolve / instantiate hook
|
||||||
*
|
*
|
||||||
* Not in current reduced spec, but necessary to separate RESOLVE from RESOLVE + INSTANTIATE as described
|
* Not in current reduced spec, but necessary to separate RESOLVE from RESOLVE + INSTANTIATE as described
|
||||||
|
@ -177,27 +174,27 @@ var RESOLVE = Loader.resolve = createSymbol('resolve');
|
||||||
* We implement RESOLVE_INSTANTIATE as a single hook instead of a separate INSTANTIATE in order to avoid
|
* We implement RESOLVE_INSTANTIATE as a single hook instead of a separate INSTANTIATE in order to avoid
|
||||||
* the need for double registry lookups as a performance optimization.
|
* the need for double registry lookups as a performance optimization.
|
||||||
*/
|
*/
|
||||||
var RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');
|
var RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');
|
||||||
|
|
||||||
// default resolveInstantiate is just to call resolve and then get from the registry
|
// default resolveInstantiate is just to call resolve and then get from the registry
|
||||||
// this provides compatibility for the resolveInstantiate optimization
|
// this provides compatibility for the resolveInstantiate optimization
|
||||||
Loader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {
|
Loader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {
|
||||||
var loader = this;
|
var loader = this;
|
||||||
return loader.resolve(key, parent)
|
return loader.resolve(key, parent)
|
||||||
.then(function (resolved) {
|
.then(function (resolved) {
|
||||||
return loader.registry.get(resolved);
|
return loader.registry.get(resolved);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function ensureResolution (resolvedKey) {
|
function ensureResolution (resolvedKey) {
|
||||||
if (resolvedKey === undefined)
|
if (resolvedKey === undefined)
|
||||||
throw new RangeError('No resolution found.');
|
throw new RangeError('No resolution found.');
|
||||||
return resolvedKey;
|
return resolvedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader.prototype.resolve = function (key, parent) {
|
Loader.prototype.resolve = function (key, parent) {
|
||||||
var loader = this;
|
var loader = this;
|
||||||
return resolvedPromise$1
|
return resolvedPromise
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return loader[RESOLVE](key, parent);
|
return loader[RESOLVE](key, parent);
|
||||||
})
|
})
|
||||||
|
@ -205,20 +202,20 @@ Loader.prototype.resolve = function (key, parent) {
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
throw LoaderError__Check_error_message_for_loader_stack(err, 'Resolving ' + key + (parent ? ' to ' + parent : ''));
|
throw LoaderError__Check_error_message_for_loader_stack(err, 'Resolving ' + key + (parent ? ' to ' + parent : ''));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 3.3.4 (import without evaluate)
|
// 3.3.4 (import without evaluate)
|
||||||
// this is not documented because the use of deferred evaluation as in Module.evaluate is not
|
// this is not documented because the use of deferred evaluation as in Module.evaluate is not
|
||||||
// documented, as it is not considered a stable feature to be encouraged
|
// documented, as it is not considered a stable feature to be encouraged
|
||||||
// Loader.prototype.load may well be deprecated if this stays disabled
|
// Loader.prototype.load may well be deprecated if this stays disabled
|
||||||
/* Loader.prototype.load = function (key, parent) {
|
/* Loader.prototype.load = function (key, parent) {
|
||||||
return Promise.resolve(this[RESOLVE_INSTANTIATE](key, parent || this.key))
|
return Promise.resolve(this[RESOLVE_INSTANTIATE](key, parent || this.key))
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
||||||
});
|
});
|
||||||
}; */
|
}; */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4. Registry
|
* 4. Registry
|
||||||
*
|
*
|
||||||
* Instead of structuring through a Map, just use a dictionary object
|
* Instead of structuring through a Map, just use a dictionary object
|
||||||
|
@ -227,13 +224,13 @@ Loader.prototype.resolve = function (key, parent) {
|
||||||
* Registry has been adjusted to use Namespace objects over ModuleStatus objects
|
* Registry has been adjusted to use Namespace objects over ModuleStatus objects
|
||||||
* as part of simplifying loader API implementation
|
* as part of simplifying loader API implementation
|
||||||
*/
|
*/
|
||||||
var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
|
var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
|
||||||
var REGISTRY = createSymbol('registry');
|
var REGISTRY = createSymbol('registry');
|
||||||
function Registry() {
|
function Registry() {
|
||||||
this[REGISTRY] = {};
|
this[REGISTRY] = {};
|
||||||
}
|
}
|
||||||
// 4.4.1
|
// 4.4.1
|
||||||
if (iteratorSupport) {
|
if (iteratorSupport) {
|
||||||
// 4.4.2
|
// 4.4.2
|
||||||
Registry.prototype[Symbol.iterator] = function () {
|
Registry.prototype[Symbol.iterator] = function () {
|
||||||
return this.entries()[Symbol.iterator]();
|
return this.entries()[Symbol.iterator]();
|
||||||
|
@ -246,52 +243,52 @@ if (iteratorSupport) {
|
||||||
return [key, registry[key]];
|
return [key, registry[key]];
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.4.4
|
// 4.4.4
|
||||||
Registry.prototype.keys = function () {
|
Registry.prototype.keys = function () {
|
||||||
return arrayValues(Object.keys(this[REGISTRY]));
|
return arrayValues(Object.keys(this[REGISTRY]));
|
||||||
};
|
};
|
||||||
// 4.4.5
|
// 4.4.5
|
||||||
Registry.prototype.values = function () {
|
Registry.prototype.values = function () {
|
||||||
var registry = this[REGISTRY];
|
var registry = this[REGISTRY];
|
||||||
return arrayValues(Object.keys(registry).map(function (key) {
|
return arrayValues(Object.keys(registry).map(function (key) {
|
||||||
return registry[key];
|
return registry[key];
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
// 4.4.6
|
// 4.4.6
|
||||||
Registry.prototype.get = function (key) {
|
Registry.prototype.get = function (key) {
|
||||||
return this[REGISTRY][key];
|
return this[REGISTRY][key];
|
||||||
};
|
};
|
||||||
// 4.4.7
|
// 4.4.7
|
||||||
Registry.prototype.set = function (key, namespace) {
|
Registry.prototype.set = function (key, namespace) {
|
||||||
if (!(namespace instanceof ModuleNamespace || namespace[toStringTag] === 'module'))
|
if (!(namespace instanceof ModuleNamespace || namespace[toStringTag] === 'module'))
|
||||||
throw new Error('Registry must be set with an instance of Module Namespace');
|
throw new Error('Registry must be set with an instance of Module Namespace');
|
||||||
this[REGISTRY][key] = namespace;
|
this[REGISTRY][key] = namespace;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
// 4.4.8
|
// 4.4.8
|
||||||
Registry.prototype.has = function (key) {
|
Registry.prototype.has = function (key) {
|
||||||
return Object.hasOwnProperty.call(this[REGISTRY], key);
|
return Object.hasOwnProperty.call(this[REGISTRY], key);
|
||||||
};
|
};
|
||||||
// 4.4.9
|
// 4.4.9
|
||||||
Registry.prototype.delete = function (key) {
|
Registry.prototype.delete = function (key) {
|
||||||
if (Object.hasOwnProperty.call(this[REGISTRY], key)) {
|
if (Object.hasOwnProperty.call(this[REGISTRY], key)) {
|
||||||
delete this[REGISTRY][key];
|
delete this[REGISTRY][key];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple ModuleNamespace Exotic object based on a baseObject
|
* Simple ModuleNamespace Exotic object based on a baseObject
|
||||||
* We export this for allowing a fast-path for module namespace creation over Module descriptors
|
* We export this for allowing a fast-path for module namespace creation over Module descriptors
|
||||||
*/
|
*/
|
||||||
// var EVALUATE = createSymbol('evaluate');
|
// var EVALUATE = createSymbol('evaluate');
|
||||||
var BASE_OBJECT = createSymbol('baseObject');
|
var BASE_OBJECT = createSymbol('baseObject');
|
||||||
|
|
||||||
// 8.3.1 Reflect.Module
|
// 8.3.1 Reflect.Module
|
||||||
/*
|
/*
|
||||||
* Best-effort simplified non-spec implementation based on
|
* Best-effort simplified non-spec implementation based on
|
||||||
* a baseObject referenced via getters.
|
* a baseObject referenced via getters.
|
||||||
*
|
*
|
||||||
|
@ -302,7 +299,7 @@ var BASE_OBJECT = createSymbol('baseObject');
|
||||||
* Optional evaluation function provides experimental Module.evaluate
|
* Optional evaluation function provides experimental Module.evaluate
|
||||||
* support for non-executed modules in registry.
|
* support for non-executed modules in registry.
|
||||||
*/
|
*/
|
||||||
function ModuleNamespace (baseObject/*, evaluate*/) {
|
function ModuleNamespace (baseObject/*, evaluate*/) {
|
||||||
Object.defineProperty(this, BASE_OBJECT, {
|
Object.defineProperty(this, BASE_OBJECT, {
|
||||||
value: baseObject
|
value: baseObject
|
||||||
});
|
});
|
||||||
|
@ -318,35 +315,34 @@ function ModuleNamespace (baseObject/*, evaluate*/) {
|
||||||
else { */
|
else { */
|
||||||
Object.keys(baseObject).forEach(extendNamespace, this);
|
Object.keys(baseObject).forEach(extendNamespace, this);
|
||||||
//}
|
//}
|
||||||
}
|
}// 8.4.2
|
||||||
// 8.4.2
|
ModuleNamespace.prototype = Object.create(null);
|
||||||
ModuleNamespace.prototype = Object.create(null);
|
|
||||||
|
|
||||||
if (toStringTag)
|
if (toStringTag)
|
||||||
Object.defineProperty(ModuleNamespace.prototype, toStringTag, {
|
Object.defineProperty(ModuleNamespace.prototype, toStringTag, {
|
||||||
value: 'Module'
|
value: 'Module'
|
||||||
});
|
});
|
||||||
|
|
||||||
function extendNamespace (key) {
|
function extendNamespace (key) {
|
||||||
Object.defineProperty(this, key, {
|
Object.defineProperty(this, key, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function () {
|
get: function () {
|
||||||
return this[BASE_OBJECT][key];
|
return this[BASE_OBJECT][key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function doEvaluate (evaluate, context) {
|
/* function doEvaluate (evaluate, context) {
|
||||||
try {
|
try {
|
||||||
evaluate.call(context);
|
evaluate.call(context);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8.4.1 Module.evaluate... not documented or used because this is potentially unstable
|
// 8.4.1 Module.evaluate... not documented or used because this is potentially unstable
|
||||||
Module.evaluate = function (ns) {
|
Module.evaluate = function (ns) {
|
||||||
var evaluate = ns[EVALUATE];
|
var evaluate = ns[EVALUATE];
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
ns[EVALUATE] = undefined;
|
ns[EVALUATE] = undefined;
|
||||||
|
@ -362,16 +358,16 @@ Module.evaluate = function (ns) {
|
||||||
}
|
}
|
||||||
// make chainable
|
// make chainable
|
||||||
return ns;
|
return ns;
|
||||||
}; */
|
}; */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optimized URL normalization assuming a syntax-valid URL parent
|
* Optimized URL normalization assuming a syntax-valid URL parent
|
||||||
*/
|
*/
|
||||||
function throwResolveError (relUrl, parentUrl) {
|
function throwResolveError (relUrl, parentUrl) {
|
||||||
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
|
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
|
||||||
}
|
}
|
||||||
var backslashRegEx = /\\/g;
|
var backslashRegEx = /\\/g;
|
||||||
function resolveIfNotPlain (relUrl, parentUrl) {
|
function resolveIfNotPlain (relUrl, parentUrl) {
|
||||||
if (relUrl[0] === ' ' || relUrl[relUrl.length - 1] === ' ')
|
if (relUrl[0] === ' ' || relUrl[relUrl.length - 1] === ' ')
|
||||||
relUrl = relUrl.trim();
|
relUrl = relUrl.trim();
|
||||||
var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);
|
var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);
|
||||||
|
@ -489,10 +485,11 @@ function resolveIfNotPlain (relUrl, parentUrl) {
|
||||||
}
|
}
|
||||||
return relUrl;
|
return relUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var resolvedPromise = Promise.resolve();
|
var resolvedPromise$1 = Promise.resolve();
|
||||||
/*
|
|
||||||
|
/*
|
||||||
* Register Loader
|
* Register Loader
|
||||||
*
|
*
|
||||||
* Builds directly on top of loader polyfill to provide:
|
* Builds directly on top of loader polyfill to provide:
|
||||||
|
@ -503,9 +500,9 @@ var resolvedPromise = Promise.resolve();
|
||||||
* - build tracing support by providing a .trace=true and .loads object format
|
* - build tracing support by providing a .trace=true and .loads object format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var REGISTER_INTERNAL = createSymbol('register-internal');
|
var REGISTER_INTERNAL = createSymbol('register-internal');
|
||||||
|
|
||||||
function RegisterLoader$1 () {
|
function RegisterLoader () {
|
||||||
Loader.call(this);
|
Loader.call(this);
|
||||||
|
|
||||||
var registryDelete = this.registry.delete;
|
var registryDelete = this.registry.delete;
|
||||||
|
@ -532,24 +529,24 @@ function RegisterLoader$1 () {
|
||||||
|
|
||||||
// tracing
|
// tracing
|
||||||
this.trace = false;
|
this.trace = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterLoader$1.prototype = Object.create(Loader.prototype);
|
RegisterLoader.prototype = Object.create(Loader.prototype);
|
||||||
RegisterLoader$1.prototype.constructor = RegisterLoader$1;
|
RegisterLoader.prototype.constructor = RegisterLoader;
|
||||||
|
|
||||||
var INSTANTIATE = RegisterLoader$1.instantiate = createSymbol('instantiate');
|
var INSTANTIATE = RegisterLoader.instantiate = createSymbol('instantiate');
|
||||||
|
|
||||||
// default normalize is the WhatWG style normalizer
|
// default normalize is the WhatWG style normalizer
|
||||||
RegisterLoader$1.prototype[RegisterLoader$1.resolve = Loader.resolve] = function (key, parentKey) {
|
RegisterLoader.prototype[RegisterLoader.resolve = Loader.resolve] = function (key, parentKey) {
|
||||||
return resolveIfNotPlain(key, parentKey || baseURI);
|
return resolveIfNotPlain(key, parentKey || baseURI);
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterLoader$1.prototype[INSTANTIATE] = function (key, processAnonRegister) {};
|
RegisterLoader.prototype[INSTANTIATE] = function (key, processAnonRegister) {};
|
||||||
|
|
||||||
// once evaluated, the linkRecord is set to undefined leaving just the other load record properties
|
// once evaluated, the linkRecord is set to undefined leaving just the other load record properties
|
||||||
// this allows tracking new binding listeners for es modules through importerSetters
|
// this allows tracking new binding listeners for es modules through importerSetters
|
||||||
// for dynamic modules, the load record is removed entirely.
|
// for dynamic modules, the load record is removed entirely.
|
||||||
function createLoadRecord (state, key, registration) {
|
function createLoadRecord (state, key, registration) {
|
||||||
return state.records[key] = {
|
return state.records[key] = {
|
||||||
key: key,
|
key: key,
|
||||||
|
|
||||||
|
@ -597,9 +594,9 @@ function createLoadRecord (state, key, registration) {
|
||||||
// hoisted: undefined
|
// hoisted: undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterLoader$1.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
|
RegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
|
||||||
var loader = this;
|
var loader = this;
|
||||||
var state = this[REGISTER_INTERNAL];
|
var state = this[REGISTER_INTERNAL];
|
||||||
var registry = this.registry[REGISTRY];
|
var registry = this.registry[REGISTRY];
|
||||||
|
@ -624,9 +621,9 @@ RegisterLoader$1.prototype[Loader.resolveInstantiate] = function (key, parentKey
|
||||||
return ensureEvaluate(loader, instantiated, link, registry, state);
|
return ensureEvaluate(loader, instantiated, link, registry, state);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveInstantiate (loader, key, parentKey, registry, state) {
|
function resolveInstantiate (loader, key, parentKey, registry, state) {
|
||||||
// normalization shortpath for already-normalized key
|
// normalization shortpath for already-normalized key
|
||||||
// could add a plain name filter, but doesn't yet seem necessary for perf
|
// could add a plain name filter, but doesn't yet seem necessary for perf
|
||||||
var module = registry[key];
|
var module = registry[key];
|
||||||
|
@ -667,9 +664,9 @@ function resolveInstantiate (loader, key, parentKey, registry, state) {
|
||||||
|
|
||||||
return instantiate(loader, load, link, registry, state);
|
return instantiate(loader, load, link, registry, state);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createProcessAnonRegister (loader, load, state) {
|
function createProcessAnonRegister (loader, load, state) {
|
||||||
return function () {
|
return function () {
|
||||||
var lastRegister = state.lastRegister;
|
var lastRegister = state.lastRegister;
|
||||||
|
|
||||||
|
@ -681,12 +678,12 @@ function createProcessAnonRegister (loader, load, state) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiate (loader, load, link, registry, state) {
|
function instantiate (loader, load, link, registry, state) {
|
||||||
return link.instantiatePromise || (link.instantiatePromise =
|
return link.instantiatePromise || (link.instantiatePromise =
|
||||||
// if there is already an existing registration, skip running instantiate
|
// if there is already an existing registration, skip running instantiate
|
||||||
(load.registration ? resolvedPromise : resolvedPromise.then(function () {
|
(load.registration ? resolvedPromise$1 : resolvedPromise$1.then(function () {
|
||||||
state.lastRegister = undefined;
|
state.lastRegister = undefined;
|
||||||
return loader[INSTANTIATE](load.key, loader[INSTANTIATE].length > 1 && createProcessAnonRegister(loader, load, state));
|
return loader[INSTANTIATE](load.key, loader[INSTANTIATE].length > 1 && createProcessAnonRegister(loader, load, state));
|
||||||
}))
|
}))
|
||||||
|
@ -733,10 +730,10 @@ function instantiate (loader, load, link, registry, state) {
|
||||||
load.linkRecord = undefined;
|
load.linkRecord = undefined;
|
||||||
throw load.loadError = load.loadError || LoaderError__Check_error_message_for_loader_stack(err, 'Instantiating ' + load.key);
|
throw load.loadError = load.loadError || LoaderError__Check_error_message_for_loader_stack(err, 'Instantiating ' + load.key);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// like resolveInstantiate, but returning load records for linking
|
// like resolveInstantiate, but returning load records for linking
|
||||||
function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {
|
function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {
|
||||||
// normalization shortpaths for already-normalized key
|
// normalization shortpaths for already-normalized key
|
||||||
// DISABLED to prioritise consistent resolver calls
|
// DISABLED to prioritise consistent resolver calls
|
||||||
// could add a plain name filter, but doesn't yet seem necessary for perf
|
// could add a plain name filter, but doesn't yet seem necessary for perf
|
||||||
|
@ -789,9 +786,9 @@ function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDe
|
||||||
|
|
||||||
return instantiate(loader, load, link, registry, state);
|
return instantiate(loader, load, link, registry, state);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function traceLoad (loader, load, link) {
|
function traceLoad (loader, load, link) {
|
||||||
loader.loads = loader.loads || {};
|
loader.loads = loader.loads || {};
|
||||||
loader.loads[load.key] = {
|
loader.loads[load.key] = {
|
||||||
key: load.key,
|
key: load.key,
|
||||||
|
@ -799,16 +796,16 @@ function traceLoad (loader, load, link) {
|
||||||
dynamicDeps: [],
|
dynamicDeps: [],
|
||||||
depMap: link.depMap || {}
|
depMap: link.depMap || {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a CJS module.exports into a valid object for new Module:
|
* Convert a CJS module.exports into a valid object for new Module:
|
||||||
*
|
*
|
||||||
* new Module(getEsModule(module.exports))
|
* new Module(getEsModule(module.exports))
|
||||||
*
|
*
|
||||||
* Sets the default value to the module, while also reading off named exports carefully.
|
* Sets the default value to the module, while also reading off named exports carefully.
|
||||||
*/
|
*/
|
||||||
function registerDeclarative (loader, load, link, declare) {
|
function registerDeclarative (loader, load, link, declare) {
|
||||||
var moduleObj = link.moduleObj;
|
var moduleObj = link.moduleObj;
|
||||||
var importerSetters = load.importerSetters;
|
var importerSetters = load.importerSetters;
|
||||||
|
|
||||||
|
@ -846,9 +843,9 @@ function registerDeclarative (loader, load, link, declare) {
|
||||||
link.moduleObj = moduleObj = declared.exports;
|
link.moduleObj = moduleObj = declared.exports;
|
||||||
definedExports = true;
|
definedExports = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiateDeps (loader, load, link, registry, state) {
|
function instantiateDeps (loader, load, link, registry, state) {
|
||||||
if (link.depsInstantiatePromise)
|
if (link.depsInstantiatePromise)
|
||||||
return link.depsInstantiatePromise;
|
return link.depsInstantiatePromise;
|
||||||
|
|
||||||
|
@ -901,15 +898,15 @@ function instantiateDeps (loader, load, link, registry, state) {
|
||||||
depsInstantiatePromise.catch(function () {});
|
depsInstantiatePromise.catch(function () {});
|
||||||
|
|
||||||
return link.depsInstantiatePromise = depsInstantiatePromise;
|
return link.depsInstantiatePromise = depsInstantiatePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deepInstantiateDeps (loader, load, link, registry, state) {
|
function deepInstantiateDeps (loader, load, link, registry, state) {
|
||||||
var seen = [];
|
var seen = [];
|
||||||
function addDeps (load, link) {
|
function addDeps (load, link) {
|
||||||
if (!link)
|
if (!link)
|
||||||
return resolvedPromise;
|
return resolvedPromise$1;
|
||||||
if (seen.indexOf(load) !== -1)
|
if (seen.indexOf(load) !== -1)
|
||||||
return resolvedPromise;
|
return resolvedPromise$1;
|
||||||
seen.push(load);
|
seen.push(load);
|
||||||
|
|
||||||
return instantiateDeps(loader, load, link, registry, state)
|
return instantiateDeps(loader, load, link, registry, state)
|
||||||
|
@ -926,14 +923,13 @@ function deepInstantiateDeps (loader, load, link, registry, state) {
|
||||||
return Promise.all(depPromises);
|
return Promise.all(depPromises);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return addDeps(load, link);
|
return addDeps(load, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System.register
|
* System.register
|
||||||
*/
|
*/
|
||||||
RegisterLoader$1.prototype.register = function (key, deps, declare) {
|
RegisterLoader.prototype.register = function (key, deps, declare) {
|
||||||
var state = this[REGISTER_INTERNAL];
|
var state = this[REGISTER_INTERNAL];
|
||||||
|
|
||||||
// anonymous modules get stored as lastAnon
|
// anonymous modules get stored as lastAnon
|
||||||
|
@ -946,12 +942,12 @@ RegisterLoader$1.prototype.register = function (key, deps, declare) {
|
||||||
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
||||||
load.registration = [deps, declare, undefined];
|
load.registration = [deps, declare, undefined];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System.registerDyanmic
|
* System.registerDyanmic
|
||||||
*/
|
*/
|
||||||
RegisterLoader$1.prototype.registerDynamic = function (key, deps, executingRequire, execute) {
|
RegisterLoader.prototype.registerDynamic = function (key, deps, executingRequire, execute) {
|
||||||
var state = this[REGISTER_INTERNAL];
|
var state = this[REGISTER_INTERNAL];
|
||||||
|
|
||||||
// anonymous modules get stored as lastAnon
|
// anonymous modules get stored as lastAnon
|
||||||
|
@ -964,31 +960,31 @@ RegisterLoader$1.prototype.registerDynamic = function (key, deps, executingRequi
|
||||||
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
||||||
load.registration = [deps, executingRequire, execute];
|
load.registration = [deps, executingRequire, execute];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ContextualLoader class
|
// ContextualLoader class
|
||||||
// backwards-compatible with previous System.register context argument by exposing .id, .key
|
// backwards-compatible with previous System.register context argument by exposing .id, .key
|
||||||
function ContextualLoader (loader, key) {
|
function ContextualLoader (loader, key) {
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
this.key = this.id = key;
|
this.key = this.id = key;
|
||||||
this.meta = {
|
this.meta = {
|
||||||
url: key
|
url: key
|
||||||
// scriptElement: null
|
// scriptElement: null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/*ContextualLoader.prototype.constructor = function () {
|
/*ContextualLoader.prototype.constructor = function () {
|
||||||
throw new TypeError('Cannot subclass the contextual loader only Reflect.Loader.');
|
throw new TypeError('Cannot subclass the contextual loader only Reflect.Loader.');
|
||||||
};*/
|
};*/
|
||||||
ContextualLoader.prototype.import = function (key) {
|
ContextualLoader.prototype.import = function (key) {
|
||||||
if (this.loader.trace)
|
if (this.loader.trace)
|
||||||
this.loader.loads[this.key].dynamicDeps.push(key);
|
this.loader.loads[this.key].dynamicDeps.push(key);
|
||||||
return this.loader.import(key, this.key);
|
return this.loader.import(key, this.key);
|
||||||
};
|
};
|
||||||
/*ContextualLoader.prototype.resolve = function (key) {
|
/*ContextualLoader.prototype.resolve = function (key) {
|
||||||
return this.loader.resolve(key, this.key);
|
return this.loader.resolve(key, this.key);
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
function ensureEvaluate (loader, load, link, registry, state) {
|
function ensureEvaluate (loader, load, link, registry, state) {
|
||||||
if (load.module)
|
if (load.module)
|
||||||
return load.module;
|
return load.module;
|
||||||
if (load.evalError)
|
if (load.evalError)
|
||||||
|
@ -1005,9 +1001,9 @@ function ensureEvaluate (loader, load, link, registry, state) {
|
||||||
doEvaluateDynamic(loader, load, link, registry, state, [load]);
|
doEvaluateDynamic(loader, load, link, registry, state, [load]);
|
||||||
}
|
}
|
||||||
return load.module;
|
return load.module;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {
|
function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {
|
||||||
// we can only require from already-known dependencies
|
// we can only require from already-known dependencies
|
||||||
return function (name) {
|
return function (name) {
|
||||||
for (var i = 0; i < dependencies.length; i++) {
|
for (var i = 0; i < dependencies.length; i++) {
|
||||||
|
@ -1038,19 +1034,19 @@ function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations
|
||||||
}
|
}
|
||||||
throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);
|
throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function evalError (load, err) {
|
function evalError (load, err) {
|
||||||
load.linkRecord = undefined;
|
load.linkRecord = undefined;
|
||||||
var evalError = LoaderError__Check_error_message_for_loader_stack(err, 'Evaluating ' + load.key);
|
var evalError = LoaderError__Check_error_message_for_loader_stack(err, 'Evaluating ' + load.key);
|
||||||
if (load.evalError === undefined)
|
if (load.evalError === undefined)
|
||||||
load.evalError = evalError;
|
load.evalError = evalError;
|
||||||
throw evalError;
|
throw evalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// es modules evaluate dependencies first
|
// es modules evaluate dependencies first
|
||||||
// returns the error if any
|
// returns the error if any
|
||||||
function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
||||||
var depLoad, depLink;
|
var depLoad, depLink;
|
||||||
var depLoadPromises;
|
var depLoadPromises;
|
||||||
for (var i = 0; i < link.dependencies.length; i++) {
|
for (var i = 0; i < link.dependencies.length; i++) {
|
||||||
|
@ -1141,10 +1137,10 @@ function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
||||||
// dispose link record
|
// dispose link record
|
||||||
load.linkRecord = undefined;
|
load.linkRecord = undefined;
|
||||||
registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
|
registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// non es modules explicitly call moduleEvaluate through require
|
// non es modules explicitly call moduleEvaluate through require
|
||||||
function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
||||||
// System.registerDynamic execute
|
// System.registerDynamic execute
|
||||||
// "this" is "exports" in CJS
|
// "this" is "exports" in CJS
|
||||||
var module = { id: load.key };
|
var module = { id: load.key };
|
||||||
|
@ -1200,18 +1196,18 @@ function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
||||||
for (var i = 0; i < load.importerSetters.length; i++)
|
for (var i = 0; i < load.importerSetters.length; i++)
|
||||||
load.importerSetters[i](load.module);
|
load.importerSetters[i](load.module);
|
||||||
load.importerSetters = undefined;
|
load.importerSetters = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the closest we can get to call(undefined)
|
// the closest we can get to call(undefined)
|
||||||
var nullContext = Object.create(null);
|
var nullContext = Object.create(null);
|
||||||
if (Object.freeze)
|
if (Object.freeze)
|
||||||
Object.freeze(nullContext);
|
Object.freeze(nullContext);
|
||||||
|
|
||||||
var loader;
|
var loader;
|
||||||
|
|
||||||
// <script type="module"> support
|
// <script type="module"> support
|
||||||
var anonSources = {};
|
var anonSources = {};
|
||||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
var handleError = function(err) {
|
var handleError = function(err) {
|
||||||
// dispatch an error event so that we can display in errors in browsers
|
// dispatch an error event so that we can display in errors in browsers
|
||||||
// that don't yet support unhandledrejection
|
// that don't yet support unhandledrejection
|
||||||
|
@ -1273,13 +1269,13 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
setTimeout(ready);
|
setTimeout(ready);
|
||||||
else
|
else
|
||||||
document.addEventListener('DOMContentLoaded', ready, false);
|
document.addEventListener('DOMContentLoaded', ready, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BrowserESModuleLoader(baseKey) {
|
function BrowserESModuleLoader(baseKey) {
|
||||||
if (baseKey)
|
if (baseKey)
|
||||||
this.baseKey = resolveIfNotPlain(baseKey, baseURI) || resolveIfNotPlain('./' + baseKey, baseURI);
|
this.baseKey = resolveIfNotPlain(baseKey, baseURI) || resolveIfNotPlain('./' + baseKey, baseURI);
|
||||||
|
|
||||||
RegisterLoader$1.call(this);
|
RegisterLoader.call(this);
|
||||||
|
|
||||||
var loader = this;
|
var loader = this;
|
||||||
|
|
||||||
|
@ -1292,19 +1288,19 @@ function BrowserESModuleLoader(baseKey) {
|
||||||
if (prevRegister)
|
if (prevRegister)
|
||||||
prevRegister.apply(this, arguments);
|
prevRegister.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
BrowserESModuleLoader.prototype = Object.create(RegisterLoader$1.prototype);
|
BrowserESModuleLoader.prototype = Object.create(RegisterLoader.prototype);
|
||||||
|
|
||||||
// normalize is never given a relative name like "./x", that part is already handled
|
// normalize is never given a relative name like "./x", that part is already handled
|
||||||
BrowserESModuleLoader.prototype[RegisterLoader$1.resolve] = function(key, parent) {
|
BrowserESModuleLoader.prototype[RegisterLoader.resolve] = function(key, parent) {
|
||||||
var resolved = RegisterLoader$1.prototype[RegisterLoader$1.resolve].call(this, key, parent || this.baseKey) || key;
|
var resolved = RegisterLoader.prototype[RegisterLoader.resolve].call(this, key, parent || this.baseKey) || key;
|
||||||
if (!resolved)
|
if (!resolved)
|
||||||
throw new RangeError('ES module loader does not resolve plain module names, resolving "' + key + '" to ' + parent);
|
throw new RangeError('ES module loader does not resolve plain module names, resolving "' + key + '" to ' + parent);
|
||||||
|
|
||||||
return resolved;
|
return resolved;
|
||||||
};
|
};
|
||||||
|
|
||||||
function xhrFetch(url, resolve, reject) {
|
function xhrFetch(url, resolve, reject) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
var load = function(source) {
|
var load = function(source) {
|
||||||
resolve(xhr.responseText);
|
resolve(xhr.responseText);
|
||||||
|
@ -1337,9 +1333,9 @@ function xhrFetch(url, resolve, reject) {
|
||||||
};
|
};
|
||||||
xhr.open("GET", url, true);
|
xhr.open("GET", url, true);
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var WorkerPool = function (script, size) {
|
var WorkerPool = function (script, size) {
|
||||||
var current = document.currentScript;
|
var current = document.currentScript;
|
||||||
// IE doesn't support currentScript
|
// IE doesn't support currentScript
|
||||||
if (!current) {
|
if (!current) {
|
||||||
|
@ -1371,8 +1367,8 @@ var WorkerPool = function (script, size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._checkJobs();
|
this._checkJobs();
|
||||||
};
|
};
|
||||||
WorkerPool.prototype = {
|
WorkerPool.prototype = {
|
||||||
postMessage: function (msg) {
|
postMessage: function (msg) {
|
||||||
if (this._stopTimeout !== undefined) {
|
if (this._stopTimeout !== undefined) {
|
||||||
clearTimeout(this._stopTimeout);
|
clearTimeout(this._stopTimeout);
|
||||||
|
@ -1419,20 +1415,19 @@ WorkerPool.prototype = {
|
||||||
wrkr.terminate();
|
wrkr.terminate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var promiseMap = new Map();
|
var promiseMap = new Map();
|
||||||
var babelWorker = new WorkerPool('babel-worker.js', 3);
|
var babelWorker = new WorkerPool('babel-worker.js', 3);
|
||||||
babelWorker.onmessage = function (evt) {
|
babelWorker.onmessage = function (evt) {
|
||||||
var promFuncs = promiseMap.get(evt.data.key);
|
var promFuncs = promiseMap.get(evt.data.key);
|
||||||
promFuncs.resolve(evt.data);
|
promFuncs.resolve(evt.data);
|
||||||
promiseMap.delete(evt.data.key);
|
promiseMap.delete(evt.data.key);
|
||||||
};
|
};
|
||||||
|
|
||||||
// instantiate just needs to run System.register
|
// instantiate just needs to run System.register
|
||||||
// so we fetch the source, convert into the Babel System module format, then evaluate it
|
// so we fetch the source, convert into the Babel System module format, then evaluate it
|
||||||
BrowserESModuleLoader.prototype[RegisterLoader$1.instantiate] = function(key, processAnonRegister) {
|
BrowserESModuleLoader.prototype[RegisterLoader.instantiate] = function(key, processAnonRegister) {
|
||||||
var loader = this;
|
|
||||||
|
|
||||||
// load as ES with Babel converting into System.register
|
// load as ES with Babel converting into System.register
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
|
@ -1474,13 +1469,13 @@ BrowserESModuleLoader.prototype[RegisterLoader$1.instantiate] = function(key, pr
|
||||||
(0, eval)(data.code + '\n//# sourceURL=' + data.key + '!transpiled');
|
(0, eval)(data.code + '\n//# sourceURL=' + data.key + '!transpiled');
|
||||||
processAnonRegister();
|
processAnonRegister();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// create a default loader instance in the browser
|
// create a default loader instance in the browser
|
||||||
if (isBrowser)
|
if (isBrowser)
|
||||||
loader = new BrowserESModuleLoader();
|
loader = new BrowserESModuleLoader();
|
||||||
|
|
||||||
return BrowserESModuleLoader;
|
return BrowserESModuleLoader;
|
||||||
|
|
||||||
})));
|
}));
|
||||||
//# sourceMappingURL=browser-es-module-loader.js.map
|
//# sourceMappingURL=browser-es-module-loader.js.map
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,16 +1,15 @@
|
||||||
import nodeResolve from 'rollup-plugin-node-resolve';
|
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
entry: 'src/browser-es-module-loader.js',
|
input: 'src/browser-es-module-loader.js',
|
||||||
dest: 'dist/browser-es-module-loader.js',
|
output: {
|
||||||
|
file: 'dist/browser-es-module-loader.js',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
moduleName: 'BrowserESModuleLoader',
|
name: 'BrowserESModuleLoader',
|
||||||
sourceMap: true,
|
sourcemap: true,
|
||||||
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
nodeResolve(),
|
nodeResolve(),
|
||||||
],
|
],
|
||||||
|
|
||||||
// skip rollup warnings (specifically the eval warning)
|
|
||||||
onwarn: function() {}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import RegisterLoader from 'es-module-loader/core/register-loader.js';
|
import RegisterLoader from 'es-module-loader/core/register-loader.js';
|
||||||
import { InternalModuleNamespace as ModuleNamespace } from 'es-module-loader/core/loader-polyfill.js';
|
|
||||||
|
|
||||||
import { baseURI, global, isBrowser } from 'es-module-loader/core/common.js';
|
import { baseURI, global, isBrowser } from 'es-module-loader/core/common.js';
|
||||||
import { resolveIfNotPlain } from 'es-module-loader/core/resolve.js';
|
import { resolveIfNotPlain } from 'es-module-loader/core/resolve.js';
|
||||||
|
|
Loading…
Reference in New Issue