UNPKG

@huluvu424242/honey-slideshow

Version:

Text to Speech component wich is reading texts from DOM elements.

158 lines (153 loc) 7 kB
import { C as CSS, p as plt, w as win, a as promiseResolve, d as doc, N as NAMESPACE, s as setMode } from './index-a2883912.js'; import { s as setupPlatforms, i as isPlatform } from './platform-d0e0bd54.js'; import { c as configFromSession, a as configFromURL, b as config, s as saveConfig } from './config-804a0dce.js'; /* Stencil Client Patch v1.16.0-4 | MIT Licensed | https://stenciljs.com */ const noop = () => { /* noop*/ }; const IS_DENO_ENV = typeof Deno !== 'undefined'; const IS_NODE_ENV = !IS_DENO_ENV && typeof global !== 'undefined' && typeof require === 'function' && !!global.process && typeof __filename === 'string' && (!global.origin || typeof global.origin !== 'string'); const IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows'; const getCurrentDirectory = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : () => '/'; const exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop; const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`; const patchEsm = () => { // NOTE!! This fn cannot use async/await! // @ts-ignore if ( !(CSS && CSS.supports && CSS.supports('color', 'var(--c)'))) { // @ts-ignore return import(/* webpackChunkName: "polyfills-css-shim" */ './css-shim-201d79b4.js').then(() => { if ((plt.$cssShim$ = win.__cssshim)) { return plt.$cssShim$.i(); } else { // for better minification return 0; } }); } return promiseResolve(); }; const patchBrowser = () => { { // shim css vars plt.$cssShim$ = win.__cssshim; } // @ts-ignore const scriptElm = Array.from(doc.querySelectorAll('script')).find(s => new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) || s.getAttribute('data-stencil-namespace') === NAMESPACE) ; const opts = scriptElm['data-opts'] || {} ; if ( 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) { // Safari < v11 support: This IF is true if it's Safari below v11. // This fn cannot use async/await since Safari didn't support it until v11, // however, Safari 10 did support modules. Safari 10 also didn't support "nomodule", // so both the ESM file and nomodule file would get downloaded. Only Safari // has 'onbeforeload' in the script, and "history.scrollRestoration" was added // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue. // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds. return { then() { /* promise noop */ }, }; } { opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href; { patchDynamicImport(opts.resourcesUrl, scriptElm); } if ( !win.customElements) { // module support, but no custom elements support (Old Edge) // @ts-ignore return import(/* webpackChunkName: "polyfills-dom" */ './dom-c0be991d.js').then(() => opts); } } return promiseResolve(opts); }; const patchDynamicImport = (base, orgScriptElm) => { const importFunctionName = getDynamicImportFunction(NAMESPACE); try { // test if this browser supports dynamic imports // There is a caching issue in V8, that breaks using import() in Function // By generating a random string, we can workaround it // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`); } catch (e) { // this shim is specifically for browsers that do support "esm" imports // however, they do NOT support "dynamic" imports // basically this code is for old Edge, v18 and below const moduleMap = new Map(); win[importFunctionName] = (src) => { const url = new URL(src, base).href; let mod = moduleMap.get(url); if (!mod) { const script = doc.createElement('script'); script.type = 'module'; script.crossOrigin = orgScriptElm.crossOrigin; script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], { type: 'application/javascript' })); mod = new Promise(resolve => { script.onload = () => { resolve(win[importFunctionName].m); script.remove(); }; }); moduleMap.set(url, mod); doc.head.appendChild(script); } return mod; }; } }; let defaultMode; const appGlobalScript = () => { const doc = document; const win = window; const Ionic = win.Ionic = win.Ionic || {}; // Setup platforms setupPlatforms(win); // create the Ionic.config from raw config object (if it exists) // and convert Ionic.config into a ConfigApi that has a get() fn const configObj = Object.assign(Object.assign(Object.assign(Object.assign({}, configFromSession(win)), { persistConfig: false }), Ionic.config), configFromURL(win)); config.reset(configObj); if (config.getBoolean('persistConfig')) { saveConfig(win, configObj); } // first see if the mode was set as an attribute on <html> // which could have been set by the user, or by pre-rendering // otherwise get the mode via config settings, and fallback to md Ionic.config = config; Ionic.mode = defaultMode = config.get('mode', (doc.documentElement.getAttribute('mode')) || (isPlatform(win, 'ios') ? 'ios' : 'md')); config.set('mode', defaultMode); doc.documentElement.setAttribute('mode', defaultMode); doc.documentElement.classList.add(defaultMode); if (config.getBoolean('_testing')) { config.set('animated', false); } const isIonicElement = (elm) => elm.tagName && elm.tagName.startsWith('ION-'); const isAllowedIonicModeValue = (elmMode) => ['ios', 'md'].includes(elmMode); setMode((elm) => { while (elm) { const elmMode = elm.mode || elm.getAttribute('mode'); if (elmMode) { if (isAllowedIonicModeValue(elmMode)) { return elmMode; } else if (isIonicElement(elm)) { console.warn('Invalid ionic mode: "' + elmMode + '", expected: "ios" or "md"'); } } elm = elm.parentElement; } return defaultMode; }); }; const globalScripts = appGlobalScript; export { patchEsm as a, globalScripts as g, patchBrowser as p };