1 | 'use strict';
|
2 |
|
3 | const index = require('./index-46f37d00.js');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
|
9 | const patchEsm = () => {
|
10 |
|
11 |
|
12 | if ( !(index.CSS && index.CSS.supports && index.CSS.supports('color', 'var(--c)'))) {
|
13 |
|
14 | return Promise.resolve().then(function () { return require( './css-shim-564371aa.js'); }).then(() => {
|
15 | if ((index.plt.$cssShim$ = index.win.__cssshim)) {
|
16 | return index.plt.$cssShim$.i();
|
17 | }
|
18 | else {
|
19 |
|
20 | return 0;
|
21 | }
|
22 | });
|
23 | }
|
24 | return index.promiseResolve();
|
25 | };
|
26 | const patchBrowser = () => {
|
27 | {
|
28 |
|
29 | index.plt.$cssShim$ = index.win.__cssshim;
|
30 | }
|
31 |
|
32 | const scriptElm = Array.from(index.doc.querySelectorAll('script')).find(s => new RegExp(`\/${index.NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) || s.getAttribute('data-stencil-namespace') === index.NAMESPACE)
|
33 | ;
|
34 | const opts = scriptElm['data-opts'] || {} ;
|
35 | if ( 'onbeforeload' in scriptElm && !history.scrollRestoration ) {
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | return {
|
44 | then() {
|
45 |
|
46 | },
|
47 | };
|
48 | }
|
49 | {
|
50 | opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, index.win.location.href)).href;
|
51 | {
|
52 | patchDynamicImport(opts.resourcesUrl, scriptElm);
|
53 | }
|
54 | if ( !index.win.customElements) {
|
55 |
|
56 |
|
57 | return Promise.resolve().then(function () { return require( './dom-6b1463fe.js'); }).then(() => opts);
|
58 | }
|
59 | }
|
60 | return index.promiseResolve(opts);
|
61 | };
|
62 | const patchDynamicImport = (base, orgScriptElm) => {
|
63 | const importFunctionName = getDynamicImportFunction(index.NAMESPACE);
|
64 | try {
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | index.win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);
|
70 | }
|
71 | catch (e) {
|
72 |
|
73 |
|
74 |
|
75 | const moduleMap = new Map();
|
76 | index.win[importFunctionName] = (src) => {
|
77 | const url = new URL(src, base).href;
|
78 | let mod = moduleMap.get(url);
|
79 | if (!mod) {
|
80 | const script = index.doc.createElement('script');
|
81 | script.type = 'module';
|
82 | script.crossOrigin = orgScriptElm.crossOrigin;
|
83 | script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], { type: 'application/javascript' }));
|
84 | mod = new Promise(resolve => {
|
85 | script.onload = () => {
|
86 | resolve(index.win[importFunctionName].m);
|
87 | script.remove();
|
88 | };
|
89 | });
|
90 | moduleMap.set(url, mod);
|
91 | index.doc.head.appendChild(script);
|
92 | }
|
93 | return mod;
|
94 | };
|
95 | }
|
96 | };
|
97 |
|
98 | exports.patchBrowser = patchBrowser;
|
99 | exports.patchEsm = patchEsm;
|