1 | import { B as BUILD, C as CSS, p as plt, w as win, a as promiseResolve, c as consoleDevInfo, H, d as doc, N as NAMESPACE } from './index-d4feb066.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 (BUILD.cssVarShim && !(CSS && CSS.supports && CSS.supports('color', 'var(--c)'))) {
|
24 |
|
25 | return import( './css-shim-a659079f.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 | if (BUILD.isDev && !BUILD.isTesting) {
|
40 | consoleDevInfo('Running in development mode.');
|
41 | }
|
42 | if (BUILD.cssVarShim) {
|
43 |
|
44 | plt.$cssShim$ = win.__cssshim;
|
45 | }
|
46 | if (BUILD.cloneNodeFix) {
|
47 |
|
48 | patchCloneNodeFix(H.prototype);
|
49 | }
|
50 | if (BUILD.profile && !performance.mark) {
|
51 |
|
52 | performance.mark = performance.measure = () => {
|
53 |
|
54 | };
|
55 | performance.getEntriesByName = () => [];
|
56 | }
|
57 |
|
58 | const scriptElm = BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim
|
59 | ? Array.from(doc.querySelectorAll('script')).find(s => new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) || s.getAttribute('data-stencil-namespace') === NAMESPACE)
|
60 | : null;
|
61 | const importMeta = "";
|
62 | const opts = BUILD.scriptDataOpts ? scriptElm['data-opts'] || {} : {};
|
63 | if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration ) {
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | return {
|
72 | then() {
|
73 |
|
74 | },
|
75 | };
|
76 | }
|
77 | if (!BUILD.safari10 && importMeta !== '') {
|
78 | opts.resourcesUrl = new URL('.', importMeta).href;
|
79 | }
|
80 | else if (BUILD.dynamicImportShim || BUILD.safari10) {
|
81 | opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;
|
82 | if (BUILD.dynamicImportShim) {
|
83 | patchDynamicImport(opts.resourcesUrl, scriptElm);
|
84 | }
|
85 | if (BUILD.dynamicImportShim && !win.customElements) {
|
86 |
|
87 |
|
88 | return import( './dom-4061ceba.js').then(() => opts);
|
89 | }
|
90 | }
|
91 | return promiseResolve(opts);
|
92 | };
|
93 | const patchDynamicImport = (base, orgScriptElm) => {
|
94 | const importFunctionName = getDynamicImportFunction(NAMESPACE);
|
95 | try {
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);
|
101 | }
|
102 | catch (e) {
|
103 |
|
104 |
|
105 |
|
106 | const moduleMap = new Map();
|
107 | win[importFunctionName] = (src) => {
|
108 | const url = new URL(src, base).href;
|
109 | let mod = moduleMap.get(url);
|
110 | if (!mod) {
|
111 | const script = doc.createElement('script');
|
112 | script.type = 'module';
|
113 | script.crossOrigin = orgScriptElm.crossOrigin;
|
114 | script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], { type: 'application/javascript' }));
|
115 | mod = new Promise(resolve => {
|
116 | script.onload = () => {
|
117 | resolve(win[importFunctionName].m);
|
118 | script.remove();
|
119 | };
|
120 | });
|
121 | moduleMap.set(url, mod);
|
122 | doc.head.appendChild(script);
|
123 | }
|
124 | return mod;
|
125 | };
|
126 | }
|
127 | };
|
128 | const patchCloneNodeFix = (HTMLElementPrototype) => {
|
129 | const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
|
130 | HTMLElementPrototype.cloneNode = function (deep) {
|
131 | if (this.nodeName === 'TEMPLATE') {
|
132 | return nativeCloneNodeFn.call(this, deep);
|
133 | }
|
134 | const clonedNode = nativeCloneNodeFn.call(this, false);
|
135 | const srcChildNodes = this.childNodes;
|
136 | if (deep) {
|
137 | for (let i = 0; i < srcChildNodes.length; i++) {
|
138 |
|
139 | if (srcChildNodes[i].nodeType !== 2) {
|
140 | clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
|
141 | }
|
142 | }
|
143 | }
|
144 | return clonedNode;
|
145 | };
|
146 | };
|
147 |
|
148 | const globalScripts = () => {};
|
149 |
|
150 | export { patchEsm as a, globalScripts as g, patchBrowser as p };
|