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