@merkur/integration 0.31.1 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/index.cjs +5 -7
- package/lib/index.es9.cjs +1 -4
- package/lib/index.es9.mjs +1 -1
- package/lib/index.js +5 -7
- package/lib/index.mjs +5 -5
- package/lib/index.umd.js +1 -1
- package/package.json +8 -9
- package/rollup.config.mjs +11 -0
- package/server/__tests__/__snapshots__/indexSpec.js.snap +4 -5
- package/server/__tests__/indexSpec.js +6 -8
- package/server/index.js +6 -6
- package/lib/index.es5.js +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|

|
|
12
12
|
[](https://github.com/prettier/prettier)
|
|
13
13
|
|
|
14
|
-
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of six predefined template's library [
|
|
14
|
+
The [Merkur](https://merkur.js.org/) is tiny extensible javascript library for front-end microservices(micro frontends). It allows by default server side rendering for loading performance boost. You can connect it with other frameworks or languages because merkur defines easy API. You can use one of six predefined template's library [Preact](https://preactjs.com/), [µhtml](https://github.com/WebReflection/uhtml#readme), [Svelte](https://svelte.dev/) and [vanilla](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) but you can easily extend for others.
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
- Flexible templating engine
|
package/lib/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
let _isES9Supported;
|
|
6
4
|
let _isES11Supported;
|
|
7
5
|
|
|
@@ -9,7 +7,7 @@ function isES9Supported() {
|
|
|
9
7
|
if (_isES9Supported === undefined) {
|
|
10
8
|
_isES9Supported =
|
|
11
9
|
exported.test(
|
|
12
|
-
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()'
|
|
10
|
+
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()',
|
|
13
11
|
) && !!Object.values;
|
|
14
12
|
}
|
|
15
13
|
|
|
@@ -20,7 +18,7 @@ function isES11Supported() {
|
|
|
20
18
|
if (_isES11Supported === undefined) {
|
|
21
19
|
_isES11Supported =
|
|
22
20
|
exported.test(
|
|
23
|
-
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()'
|
|
21
|
+
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()',
|
|
24
22
|
) &&
|
|
25
23
|
exported.test('return typeof Promise.allSettled === "function"') &&
|
|
26
24
|
exported.test('return typeof globalThis !== "undefined"') &&
|
|
@@ -59,7 +57,7 @@ function _loadScript(asset, root) {
|
|
|
59
57
|
scriptElement.addEventListener('load', resolve);
|
|
60
58
|
scriptElement.addEventListener(
|
|
61
59
|
'error',
|
|
62
|
-
asset.optional ? resolve : reject
|
|
60
|
+
asset.optional ? resolve : reject,
|
|
63
61
|
);
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
@@ -135,7 +133,7 @@ function loadStyleAssets(assets, root = document.head) {
|
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
return acc;
|
|
138
|
-
}, true)))
|
|
136
|
+
}, true))),
|
|
139
137
|
);
|
|
140
138
|
|
|
141
139
|
return Promise.all(stylesToRender.map((asset) => _loadStyle(asset, root)));
|
|
@@ -157,7 +155,7 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
157
155
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
158
156
|
_asset.source = source.es9;
|
|
159
157
|
} else {
|
|
160
|
-
_asset.source =
|
|
158
|
+
_asset.source = null;
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
if (!_asset.source) {
|
package/lib/index.es9.cjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
3
|
let _isES9Supported;
|
|
7
4
|
let _isES11Supported;
|
|
8
5
|
function isES9Supported() {
|
|
@@ -118,7 +115,7 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
118
115
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
119
116
|
_asset.source = source.es9;
|
|
120
117
|
} else {
|
|
121
|
-
_asset.source =
|
|
118
|
+
_asset.source = null;
|
|
122
119
|
}
|
|
123
120
|
if (!_asset.source) {
|
|
124
121
|
const message = `Asset '${_asset.name}' is missing ES variant and could not be loaded.`;
|
package/lib/index.es9.mjs
CHANGED
|
@@ -113,7 +113,7 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
113
113
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
114
114
|
_asset.source = source.es9;
|
|
115
115
|
} else {
|
|
116
|
-
_asset.source =
|
|
116
|
+
_asset.source = null;
|
|
117
117
|
}
|
|
118
118
|
if (!_asset.source) {
|
|
119
119
|
const message = `Asset '${_asset.name}' is missing ES variant and could not be loaded.`;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
let _isES9Supported;
|
|
6
4
|
let _isES11Supported;
|
|
7
5
|
|
|
@@ -9,7 +7,7 @@ function isES9Supported() {
|
|
|
9
7
|
if (_isES9Supported === undefined) {
|
|
10
8
|
_isES9Supported =
|
|
11
9
|
exported.test(
|
|
12
|
-
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()'
|
|
10
|
+
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()',
|
|
13
11
|
) && !!Object.values;
|
|
14
12
|
}
|
|
15
13
|
|
|
@@ -20,7 +18,7 @@ function isES11Supported() {
|
|
|
20
18
|
if (_isES11Supported === undefined) {
|
|
21
19
|
_isES11Supported =
|
|
22
20
|
exported.test(
|
|
23
|
-
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()'
|
|
21
|
+
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()',
|
|
24
22
|
) &&
|
|
25
23
|
exported.test('return typeof Promise.allSettled === "function"') &&
|
|
26
24
|
exported.test('return typeof globalThis !== "undefined"') &&
|
|
@@ -59,7 +57,7 @@ function _loadScript(asset, root) {
|
|
|
59
57
|
scriptElement.addEventListener('load', resolve);
|
|
60
58
|
scriptElement.addEventListener(
|
|
61
59
|
'error',
|
|
62
|
-
asset.optional ? resolve : reject
|
|
60
|
+
asset.optional ? resolve : reject,
|
|
63
61
|
);
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
@@ -135,7 +133,7 @@ function loadStyleAssets(assets, root = document.head) {
|
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
return acc;
|
|
138
|
-
}, true)))
|
|
136
|
+
}, true))),
|
|
139
137
|
);
|
|
140
138
|
|
|
141
139
|
return Promise.all(stylesToRender.map((asset) => _loadStyle(asset, root)));
|
|
@@ -157,7 +155,7 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
157
155
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
158
156
|
_asset.source = source.es9;
|
|
159
157
|
} else {
|
|
160
|
-
_asset.source =
|
|
158
|
+
_asset.source = null;
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
if (!_asset.source) {
|
package/lib/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ function isES9Supported() {
|
|
|
5
5
|
if (_isES9Supported === undefined) {
|
|
6
6
|
_isES9Supported =
|
|
7
7
|
exported.test(
|
|
8
|
-
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()'
|
|
8
|
+
'return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()',
|
|
9
9
|
) && !!Object.values;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ function isES11Supported() {
|
|
|
16
16
|
if (_isES11Supported === undefined) {
|
|
17
17
|
_isES11Supported =
|
|
18
18
|
exported.test(
|
|
19
|
-
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()'
|
|
19
|
+
'return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()',
|
|
20
20
|
) &&
|
|
21
21
|
exported.test('return typeof Promise.allSettled === "function"') &&
|
|
22
22
|
exported.test('return typeof globalThis !== "undefined"') &&
|
|
@@ -55,7 +55,7 @@ function _loadScript(asset, root) {
|
|
|
55
55
|
scriptElement.addEventListener('load', resolve);
|
|
56
56
|
scriptElement.addEventListener(
|
|
57
57
|
'error',
|
|
58
|
-
asset.optional ? resolve : reject
|
|
58
|
+
asset.optional ? resolve : reject,
|
|
59
59
|
);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
@@ -131,7 +131,7 @@ function loadStyleAssets(assets, root = document.head) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
return acc;
|
|
134
|
-
}, true)))
|
|
134
|
+
}, true))),
|
|
135
135
|
);
|
|
136
136
|
|
|
137
137
|
return Promise.all(stylesToRender.map((asset) => _loadStyle(asset, root)));
|
|
@@ -153,7 +153,7 @@ async function loadScriptAssets(assets, root = document.head) {
|
|
|
153
153
|
} else if (source.es9 && exported.isES9Supported()) {
|
|
154
154
|
_asset.source = source.es9;
|
|
155
155
|
} else {
|
|
156
|
-
_asset.source =
|
|
156
|
+
_asset.source = null;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
if (!_asset.source) {
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.Merkur=e.Merkur||{},e.Merkur.Integration=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function t(e,t,r,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}
|
|
1
|
+
!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var r={exports:{}};t(r.exports),e.Merkur=e.Merkur||{},e.Merkur.Integration=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e){function t(e,t,r,n,o,i,s){try{var u=e[i](s),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}var r,n;Object.defineProperty(e,"__esModule",{value:!0}),e.loadAssets=function(e,t){return Promise.all([s(e,t),i(e,t)])},e.loadScriptAssets=s,e.loadStyleAssets=i,e.testScript=void 0;var o={isES9Supported:function(){return void 0===r&&(r=o.test("return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()")&&!!Object.values),r},isES11Supported:function(){return void 0===n&&(n=o.test("return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()")&&o.test('return typeof Promise.allSettled === "function"')&&o.test('return typeof globalThis !== "undefined"')&&o.test('return typeof 9007199254740991n === "bigint"')),n},test:function(e){try{return!!new Function(e)()}catch(e){return!1}}};function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.head,r=t.querySelectorAll("style"),n=e.filter((function(e){return e.source&&("stylesheet"===e.type&&!t.querySelector("link[href='".concat(e.source,"']"))||"inlineStyle"===e.type&&Array.from(r).reduce((function(t,r){return r.innerHTML!==e.source&&t}),!0))}));return Promise.all(n.map((function(e){return function(e,t){return new Promise((function(r,n){if("stylesheet"===e.type){var o=document.createElement("link");o.onload=r,o.onerror=n,o.rel="stylesheet",o.href=e.source,t.appendChild(o)}else{var i=document.createElement("style");i.innerHTML=e.source,t.appendChild(i),r()}}))}(e,t)})))}function s(e){return u.apply(this,arguments)}function u(){var e;return e=function*(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.head,r=t.querySelectorAll("script"),n=e.reduce((function(e,t){var n=t.source,i=Object.assign({},t);if("script"!==i.type&&"inlineScript"!==i.type)return e;if(n===Object(n)&&(n.es11&&o.isES11Supported()?i.source=n.es11:n.es9&&o.isES9Supported()?i.source=n.es9:i.source=null,!i.source)){var s="Asset '".concat(i.name,"' is missing ES variant and could not be loaded.");if(!i.optional){var u=new Error(s);throw u.asset=i,u}return console.warn(s),e}return Array.from(r).reduce((function(e,t){return t.text===i.source||e}),!1)||i.test&&o.test(i.test)||e.push(i),e}),[]);return Promise.all(n.map((function(e){return function(e,t){return new Promise((function(r,n){var i=t.querySelector("script[src='".concat(e.source,"']"));if(i)return e.test&&!o.test(e.test)||r(),i.addEventListener("load",r),void i.addEventListener("error",e.optional?r:n);var s=document.createElement("script");if("script"===e.type){s.defer=!0,s.onload=r,s.onerror=function(t){s.remove(),e.optional?r(t):n(t)},s.src=e.source;var u=e.attr;if(u&&Object.keys(u).length)for(var c in u){var a=u[c];"boolean"==typeof a?a?s.setAttribute(c,""):s.removeAttribute(c):s.setAttribute(c,a)}}else s.text=e.source,r();t.appendChild(s)}))}(e,t)})))},u=function(){var r=this,n=arguments;return new Promise((function(o,i){var s=e.apply(r,n);function u(e){t(s,o,i,u,c,"next",e)}function c(e){t(s,o,i,u,c,"throw",e)}u(void 0)}))},u.apply(this,arguments)}e.testScript=o}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/integration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Merkur module for easy integration with other apps.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"./server/index.js": "./server/index.js"
|
|
19
19
|
},
|
|
20
20
|
"browser": {
|
|
21
|
-
"./lib/index.js": "./lib/index.
|
|
22
|
-
"./lib/index.cjs": "./lib/index.
|
|
21
|
+
"./lib/index.js": "./lib/index.js",
|
|
22
|
+
"./lib/index.cjs": "./lib/index.cjs",
|
|
23
23
|
"./lib/index.mjs": "./lib/index.mjs",
|
|
24
24
|
"./lib/index.es9.mjs": "./lib/index.es9.mjs"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"preversion": "npm test",
|
|
28
|
-
"test": "
|
|
29
|
-
"test:es:version": "
|
|
30
|
-
"build": "
|
|
28
|
+
"test": "jest --no-watchman -c ./jest.config.js",
|
|
29
|
+
"test:es:version": "es-check es11 ./lib/index.mjs --module && es-check es9 ./lib/index.es9.mjs --module && es-check es9 ./lib/index.es9.cjs --module",
|
|
30
|
+
"build": "rollup -c rollup.config.mjs",
|
|
31
31
|
"prepare": "npm run build"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
@@ -49,11 +49,10 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://merkur.js.org/",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@merkur/core": "^0.
|
|
53
|
-
"rollup": "^2.70.2"
|
|
52
|
+
"@merkur/core": "^0.33.0"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
55
|
"@merkur/core": "*"
|
|
57
56
|
},
|
|
58
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3e88b57abfad267ac3f3b20b2ae6bf50f93f5375"
|
|
59
58
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRollupESConfig,
|
|
3
|
+
createRollupES9Config,
|
|
4
|
+
createRollupUMDConfig,
|
|
5
|
+
} from '../../createRollupConfig.mjs';
|
|
6
|
+
|
|
7
|
+
let esConfig = createRollupESConfig();
|
|
8
|
+
let es9Config = createRollupES9Config();
|
|
9
|
+
let umdConfig = createRollupUMDConfig();
|
|
10
|
+
|
|
11
|
+
export default [esConfig, es9Config, umdConfig];
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`createAssets method should read manifests and add source to assets 1`] = `
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
6
|
"name": "widget.js",
|
|
7
|
-
"source":
|
|
7
|
+
"source": {
|
|
8
8
|
"es11": "https://seznam.cz/static/es11/widget.53fbc48b6fb616ecfd1b.js",
|
|
9
|
-
"es5": "https://seznam.cz/static/es5/widget.e5e3d41ecc1f5964c3e3.js",
|
|
10
9
|
"es9": "https://seznam.cz/static/es9/widget.fdf95165e917b666fc62.js",
|
|
11
10
|
},
|
|
12
11
|
"type": "script",
|
|
13
12
|
},
|
|
14
|
-
|
|
13
|
+
{
|
|
15
14
|
"name": "style.css",
|
|
16
15
|
"source": "https://seznam.cz/static/css/style.c3e64bd85803ef0e5583.css",
|
|
17
16
|
"type": "stylesheet",
|
|
@@ -3,13 +3,11 @@ const fs = require('fs');
|
|
|
3
3
|
|
|
4
4
|
const staticFolder = 'build/static';
|
|
5
5
|
const staticBaseUrl = 'https://seznam.cz/static';
|
|
6
|
-
const folders = ['es11', 'es9', '
|
|
6
|
+
const folders = ['es11', 'es9', 'css'];
|
|
7
7
|
|
|
8
8
|
const manifests = {
|
|
9
9
|
'build/static/css/manifest.json':
|
|
10
10
|
'{"style.css":"style.c3e64bd85803ef0e5583.css"}',
|
|
11
|
-
'build/static/es5/manifest.json':
|
|
12
|
-
'{"widget.css": "widget.96a1e61f8f77442b9837.css", "widget.js": "widget.e5e3d41ecc1f5964c3e3.js"}',
|
|
13
11
|
'build/static/es9/manifest.json':
|
|
14
12
|
'{"widget.css": "widget.96a1e61f8f77442b9837.css", "widget.js": "widget.fdf95165e917b666fc62.js"}',
|
|
15
13
|
'build/static/es11/manifest.json':
|
|
@@ -65,7 +63,7 @@ describe('createAssets method', () => {
|
|
|
65
63
|
});
|
|
66
64
|
|
|
67
65
|
expect(console.warn).toHaveBeenCalledWith(
|
|
68
|
-
expect.stringContaining('polyfill.js')
|
|
66
|
+
expect.stringContaining('polyfill.js'),
|
|
69
67
|
);
|
|
70
68
|
});
|
|
71
69
|
|
|
@@ -78,16 +76,16 @@ describe('createAssets method', () => {
|
|
|
78
76
|
});
|
|
79
77
|
|
|
80
78
|
expect(assets).toMatchInlineSnapshot(`
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
[
|
|
80
|
+
{
|
|
83
81
|
"name": "polyfill.js",
|
|
84
82
|
"type": "script",
|
|
85
83
|
},
|
|
86
|
-
|
|
84
|
+
{
|
|
87
85
|
"name": "widget.js",
|
|
88
86
|
"type": "script",
|
|
89
87
|
},
|
|
90
|
-
|
|
88
|
+
{
|
|
91
89
|
"name": "style.css",
|
|
92
90
|
"type": "stylesheet",
|
|
93
91
|
},
|
package/server/index.js
CHANGED
|
@@ -30,7 +30,7 @@ async function processAssetInFolder({
|
|
|
30
30
|
if (asset.type.includes('inline')) {
|
|
31
31
|
asset.source = await fsp.readFile(
|
|
32
32
|
path.join(staticFolder, folder, fileName),
|
|
33
|
-
{ encoding: 'utf-8' }
|
|
33
|
+
{ encoding: 'utf-8' },
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
return asset;
|
|
@@ -60,7 +60,7 @@ async function createAssets({ assets, staticFolder, folders, staticBaseUrl }) {
|
|
|
60
60
|
|
|
61
61
|
const manifestFile = await fsp.readFile(
|
|
62
62
|
path.join(folderPath, 'manifest.json'),
|
|
63
|
-
{ encoding: 'utf-8' }
|
|
63
|
+
{ encoding: 'utf-8' },
|
|
64
64
|
);
|
|
65
65
|
const manifest = JSON.parse(manifestFile);
|
|
66
66
|
|
|
@@ -72,17 +72,17 @@ async function createAssets({ assets, staticFolder, folders, staticBaseUrl }) {
|
|
|
72
72
|
fileName: manifest[asset.name],
|
|
73
73
|
staticBaseUrl,
|
|
74
74
|
staticFolder,
|
|
75
|
-
})
|
|
76
|
-
)
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
77
|
);
|
|
78
78
|
},
|
|
79
|
-
[...assets]
|
|
79
|
+
[...assets],
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
return processedAssets.filter((asset) => {
|
|
83
83
|
if (!asset.source) {
|
|
84
84
|
console.warn(
|
|
85
|
-
`Asset '${asset.name}' has been excluded because it doesn't have valid source
|
|
85
|
+
`Asset '${asset.name}' has been excluded because it doesn't have valid source.`,
|
|
86
86
|
);
|
|
87
87
|
return false;
|
|
88
88
|
}
|
package/lib/index.es5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t=function(){return r};var r={},o=Object.prototype,n=o.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",a=s.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,o){var n=t&&t.prototype instanceof d?t:d,s=Object.create(n.prototype),u=new O(o||[]);return i(s,"_invoke",{value:q(e,r,u)}),s}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=f;var p={};function d(){}function y(){}function m(){}var v={};l(v,u,(function(){return this}));var j=Object.getPrototypeOf,g=j&&j(j(_([])));g&&g!==o&&n.call(g,u)&&(v=g);var b=m.prototype=d.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function x(t,r){function o(i,s,u,c){var a=h(t[i],t,s);if("throw"!==a.type){var l=a.arg,f=l.value;return f&&"object"==e(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(e){o("next",e,u,c)}),(function(e){o("throw",e,u,c)})):r.resolve(f).then((function(e){l.value=e,u(l)}),(function(e){return o("throw",e,u,c)}))}c(a.arg)}var s;i(this,"_invoke",{value:function(e,t){function n(){return new r((function(r,n){o(e,t,r,n)}))}return s=s?s.then(n,n):n()}})}function q(e,t,r){var o="suspendedStart";return function(n,i){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===n)throw i;return P()}for(r.method=n,r.arg=i;;){var s=r.delegate;if(s){var u=E(s,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===o)throw o="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o="executing";var c=h(e,t,r);if("normal"===c.type){if(o=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(o="completed",r.method="throw",r.arg=c.arg)}}}function E(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var o=h(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,p;var n=o.arg;return n?n.done?(t[e.resultName]=n.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):n:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function _(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=m,i(b,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:y,configurable:!0}),y.displayName=l(m,a,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,a,"GeneratorFunction")),e.prototype=Object.create(b),e},r.awrap=function(e){return{__await:e}},w(x.prototype),l(x.prototype,c,(function(){return this})),r.AsyncIterator=x,r.async=function(e,t,o,n,i){void 0===i&&(i=Promise);var s=new x(f(e,t,o,n),i);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(b),l(b,a,"Generator"),l(b,u,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var o in t)r.push(o);return r.reverse(),function e(){for(;r.length;){var o=r.pop();if(o in t)return e.value=o,e.done=!1,e}return e.done=!0,e}},r.values=_,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,o){return s.type="throw",s.arg=e,t.next=r,o&&(t.method="next",t.arg=void 0),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var o=r.completion;if("throw"===o.type){var n=o.arg;S(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:_(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},r}function r(e,t,r,o,n,i,s){try{var u=e[i](s),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(o,n)}function o(e){return function(){var t=this,o=arguments;return new Promise((function(n,i){var s=e.apply(t,o);function u(e){r(s,n,i,u,c,"next",e)}function c(e){r(s,n,i,u,c,"throw",e)}u(void 0)}))}}var n,i;require("core-js/modules/es.object.define-property.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.object.values.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.array.reduce.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.object.create.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.array.for-each.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.array.reverse.js"),require("core-js/modules/es.array.slice.js"),Object.defineProperty(exports,"__esModule",{value:!0});var s={isES9Supported:function(){return void 0===n&&(n=s.test("return (() => { const o = { t: 1 }; return { ...o }; })() && (async () => ({}))()")&&!!Object.values),n},isES11Supported:function(){return void 0===i&&(i=s.test("return (() => { const o = { t: { q: true } }; return o?.t?.q && (o?.a?.q ?? true); })()")&&s.test('return typeof Promise.allSettled === "function"')&&s.test('return typeof globalThis !== "undefined"')&&s.test('return typeof 9007199254740991n === "bigint"')),i},test:function(e){try{return!!new Function(e)()}catch(e){return!1}}};function u(e,t){return new Promise((function(r,o){var n=t.querySelector("script[src='".concat(e.source,"']"));if(n)return e.test&&!s.test(e.test)||r(),n.addEventListener("load",r),void n.addEventListener("error",e.optional?r:o);var i=document.createElement("script");if("script"===e.type){i.defer=!0,i.onload=r,i.onerror=function(t){i.remove(),e.optional?r(t):o(t)},i.src=e.source;var u=e.attr;if(u&&Object.keys(u).length)for(var c in u){var a=u[c];"boolean"==typeof a?a?i.setAttribute(c,""):i.removeAttribute(c):i.setAttribute(c,a)}}else i.text=e.source,r();t.appendChild(i)}))}function c(e,t){return new Promise((function(r,o){if("stylesheet"===e.type){var n=document.createElement("link");n.onload=r,n.onerror=o,n.rel="stylesheet",n.href=e.source,t.appendChild(n)}else{var i=document.createElement("style");i.innerHTML=e.source,t.appendChild(i),r()}}))}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.head,r=t.querySelectorAll("style"),o=e.filter((function(e){return e.source&&("stylesheet"===e.type&&!t.querySelector("link[href='".concat(e.source,"']"))||"inlineStyle"===e.type&&Array.from(r).reduce((function(t,r){return r.innerHTML!==e.source&&t}),!0))}));return Promise.all(o.map((function(e){return c(e,t)})))}function l(e){return f.apply(this,arguments)}function f(){return f=o(t().mark((function e(r){var o,n,i,c=arguments;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=c.length>1&&void 0!==c[1]?c[1]:document.head,n=o.querySelectorAll("script"),i=r.reduce((function(e,t){var r=t.source,o=Object.assign({},t);if("script"!==o.type&&"inlineScript"!==o.type)return e;if(r===Object(r)&&(r.es11&&s.isES11Supported()?o.source=r.es11:r.es9&&s.isES9Supported()?o.source=r.es9:o.source=r.es5,!o.source)){var i="Asset '".concat(o.name,"' is missing ES variant and could not be loaded.");if(!o.optional){var u=new Error(i);throw u.asset=o,u}return console.warn(i),e}return Array.from(n).reduce((function(e,t){return t.text===o.source||e}),!1)||o.test&&s.test(o.test)||e.push(o),e}),[]),e.abrupt("return",Promise.all(i.map((function(e){return u(e,o)}))));case 4:case"end":return e.stop()}}),e)}))),f.apply(this,arguments)}exports.loadAssets=function(e,t){return Promise.all([l(e,t),a(e,t)])},exports.loadScriptAssets=l,exports.loadStyleAssets=a,exports.testScript=s;
|