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