@stories-js/core
Version:
Stories web components to build stories
117 lines (113 loc) • 8.68 kB
JavaScript
/*!
* (C) StoriesJS https://storiesjs.org - GPL-2.0 License
*/
;
const index = require('./index-c25eada5.js');
const appGlobals = require('./app-globals-a2bf6401.js');
require('./stories-global-be675187.js');
/*
Stencil Client Patch Browser v2.14.2 | MIT Licensed | https://stenciljs.com
*/
const getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
const patchBrowser = () => {
{
// shim css vars
index.plt.$cssShim$ = index.win.__cssshim;
}
{
// opted-in to polyfill cloneNode() for slot polyfilled components
patchCloneNodeFix(index.H.prototype);
}
// @ts-ignore
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)
;
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, index.win.location.href)).href;
{
patchDynamicImport(opts.resourcesUrl, scriptElm);
}
if (!index.win.customElements) {
// module support, but no custom elements support (Old Edge)
// @ts-ignore
return Promise.resolve().then(function () { return require(/* webpackChunkName: "polyfills-dom" */ './dom-e192025d.js'); }).then(() => opts);
}
}
return index.promiseResolve(opts);
};
const patchDynamicImport = (base, orgScriptElm) => {
const importFunctionName = getDynamicImportFunction(index.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
index.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();
index.win[importFunctionName] = (src) => {
const url = new URL(src, base).href;
let mod = moduleMap.get(url);
if (!mod) {
const script = index.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(index.win[importFunctionName].m);
script.remove();
};
});
moduleMap.set(url, mod);
index.doc.head.appendChild(script);
}
return mod;
};
}
};
const patchCloneNodeFix = (HTMLElementPrototype) => {
const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
HTMLElementPrototype.cloneNode = function (deep) {
if (this.nodeName === 'TEMPLATE') {
return nativeCloneNodeFn.call(this, deep);
}
const clonedNode = nativeCloneNodeFn.call(this, false);
const srcChildNodes = this.childNodes;
if (deep) {
for (let i = 0; i < srcChildNodes.length; i++) {
// Node.ATTRIBUTE_NODE === 2, and checking because IE11
if (srcChildNodes[i].nodeType !== 2) {
clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
}
}
}
return clonedNode;
};
};
patchBrowser().then(options => {
appGlobals.globalScripts();
return index.bootstrapLazy([["stories-tool-zoom.cjs",[[1,"stories-tool-zoom"]]],["stories-preview.cjs",[[1,"stories-preview"]]],["stories-searchbar.cjs",[[1,"stories-searchbar",{"color":[513],"cancelButtonIcon":[1,"cancel-button-icon"],"clearIcon":[1,"clear-icon"],"debounce":[2],"disabled":[4],"inputmode":[1],"placeholder":[1],"searchIcon":[1,"search-icon"],"showCancelButton":[1,"show-cancel-button"],"showClearButton":[1,"show-clear-button"],"type":[1],"value":[1025],"focused":[32],"setFocus":[64],"getInputElement":[64]}]]],["stories-addon-actions.cjs",[[1,"stories-addon-actions",{"actions":[32],"storyContextChanged":[64]}]]],["stories-addon-controls.cjs",[[1,"stories-addon-controls",{"controls":[32],"storyContextChanged":[64]}]]],["stories-addons.cjs",[[1,"stories-addons",{"registerAddon":[64],"unregisterAddon":[64],"findAddon":[64],"storyContextChanged":[64]}]]],["stories-app.cjs",[[1,"stories-app",{"modules":[16],"store":[1040]},[[8,"hashchange","onHash"]]]]],["stories-badge.cjs",[[1,"stories-badge",{"color":[513]}]]],["stories-button.cjs",[[1,"stories-button",{"color":[513],"buttonType":[1025,"button-type"],"disabled":[516],"expand":[513],"fill":[1537],"routerDirection":[1,"router-direction"],"href":[1],"shape":[513],"type":[1],"size":[513],"strong":[4],"target":[1]}]]],["stories-buttons.cjs",[[1,"stories-buttons",{"collapse":[4]}]]],["stories-checkbox.cjs",[[1,"stories-checkbox",{"color":[513],"name":[1],"checked":[1028],"indeterminate":[1028],"disabled":[4],"value":[8]}]]],["stories-col.cjs",[[1,"stories-col",{"offset":[1],"offsetXs":[1,"offset-xs"],"offsetSm":[1,"offset-sm"],"offsetMd":[1,"offset-md"],"offsetLg":[1,"offset-lg"],"offsetXl":[1,"offset-xl"],"pull":[1],"pullXs":[1,"pull-xs"],"pullSm":[1,"pull-sm"],"pullMd":[1,"pull-md"],"pullLg":[1,"pull-lg"],"pullXl":[1,"pull-xl"],"push":[1],"pushXs":[1,"push-xs"],"pushSm":[1,"push-sm"],"pushMd":[1,"push-md"],"pushLg":[1,"push-lg"],"pushXl":[1,"push-xl"],"size":[1],"sizeXs":[1,"size-xs"],"sizeSm":[1,"size-sm"],"sizeMd":[1,"size-md"],"sizeLg":[1,"size-lg"],"sizeXl":[1,"size-xl"]},[[9,"resize","onResize"]]]]],["stories-footer.cjs",[[1,"stories-footer"]]],["stories-grid.cjs",[[1,"stories-grid",{"fixed":[4]}]]],["stories-input.cjs",[[1,"stories-input",{"fireFocusEvents":[4,"fire-focus-events"],"color":[513],"autofocus":[4],"clearInput":[4,"clear-input"],"debounce":[2],"disabled":[4],"inputmode":[1],"max":[1],"maxlength":[2],"min":[1],"minlength":[2],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[4],"required":[4],"step":[1],"size":[2],"type":[1],"value":[1032],"hasFocus":[32],"setFocus":[64],"setBlur":[64],"getInputElement":[64]}]]],["stories-label.cjs",[[1,"stories-label",{"color":[513],"position":[1]}]]],["stories-router.cjs",[[1,"stories-router"]]],["stories-row.cjs",[[1,"stories-row"]]],["stories-sidebar.cjs",[[1,"stories-sidebar"]]],["stories-split-pane.cjs",[[1,"stories-split-pane",{"split":[1],"minSize":[2,"min-size"],"defaultSize":[2,"default-size"],"isResizing":[1540,"resizing"]}]]],["stories-tab.cjs",[[1,"stories-tab",{"active":[1028],"tab":[1]}]]],["stories-tab-bar.cjs",[[1,"stories-tab-bar",{"color":[513],"selectedTab":[1,"selected-tab"]}]]],["stories-tab-button.cjs",[[1,"stories-tab-button",{"disabled":[4],"layout":[1025],"selected":[1028],"tab":[1]},[[8,"storiesTabBarChanged","onTabBarChanged"]]]]],["stories-tabs.cjs",[[1,"stories-tabs",{"selectedTab":[32],"select":[64],"getTab":[64],"getSelected":[64]}]]],["stories-tool-bar.cjs",[[1,"stories-tool-bar"]]],["stories-tool-button.cjs",[[1,"stories-tool-button",{"disabled":[4],"icon":[1],"command":[1]}]]],["stories-zoom.cjs",[[1,"stories-zoom",{"zoom":[2],"div":[32],"height":[32]}]]],["stories-icon.cjs",[[1,"stories-icon",{"name":[1]}]]]], options);
});
//# sourceMappingURL=core.cjs.js.map