@storybook/preview 7.1.0-alpha.37 → 7.1.0-alpha.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime.js +1 -1
- package/package.json +5 -5
package/dist/runtime.js
CHANGED
|
@@ -97,7 +97,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
97
97
|
Omitted potentially unsafe URL args.
|
|
98
98
|
|
|
99
99
|
More info: https://storybook.js.org/docs/react/writing-stories/args#setting-args-through-the-url
|
|
100
|
-
`),acc),{})},{history,document:document3}=scope;function pathToId(path){let match=(path||"").match(/^\/story\/(.+)/);if(!match)throw new Error(`Invalid path '${path}', must start with '/story/'`);return match[1]}var getQueryString=({selection,extraParams})=>{let{search=""}=document3.location,{path,selectedKind,selectedStory,...rest}=import_qs3.default.parse(search,{ignoreQueryPrefix:!0});return import_qs3.default.stringify({...rest,...extraParams,...selection&&{id:selection.storyId,viewMode:selection.viewMode}},{encode:!1,addQueryPrefix:!0})},setPath=selection=>{if(!selection)return;let query=getQueryString({selection}),{hash=""}=document3.location;document3.title=selection.storyId,history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)},isObject4=val=>val!=null&&typeof val=="object"&&Array.isArray(val)===!1,getFirstString=v2=>{if(v2!==void 0){if(typeof v2=="string")return v2;if(Array.isArray(v2))return getFirstString(v2[0]);if(isObject4(v2))return getFirstString(Object.values(v2).filter(Boolean))}},getSelectionSpecifierFromPath=()=>{let query=import_qs3.default.parse(document3.location.search,{ignoreQueryPrefix:!0}),args2=typeof query.args=="string"?parseArgsParam(query.args):void 0,globals2=typeof query.globals=="string"?parseArgsParam(query.globals):void 0,viewMode=getFirstString(query.viewMode);(typeof viewMode!="string"||!viewMode.match(/docs|story/))&&(viewMode="story");let path=getFirstString(query.path),storyId=path?pathToId(path):getFirstString(query.id);return storyId?{storySpecifier:storyId,args:args2,globals:globals2,viewMode}:null},UrlStore=class{constructor(){this.selectionSpecifier=getSelectionSpecifierFromPath()}setSelection(selection){this.selection=selection,setPath(this.selection)}setQueryParams(queryParams){let query=getQueryString({extraParams:queryParams}),{hash=""}=document3.location;history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)}},import_ansi_to_html=__toESM3(require_ansi_to_html()),{document:document22}=scope,PREPARING_DELAY=100,Mode=(Mode2=>(Mode2.MAIN="MAIN",Mode2.NOPREVIEW="NOPREVIEW",Mode2.PREPARING_STORY="PREPARING_STORY",Mode2.PREPARING_DOCS="PREPARING_DOCS",Mode2.ERROR="ERROR",Mode2))(Mode||{}),classes={PREPARING_STORY:"sb-show-preparing-story",PREPARING_DOCS:"sb-show-preparing-docs",MAIN:"sb-show-main",NOPREVIEW:"sb-show-nopreview",ERROR:"sb-show-errordisplay"},layoutClassMap={centered:"sb-main-centered",fullscreen:"sb-main-fullscreen",padded:"sb-main-padded"},ansiConverter=new import_ansi_to_html.default({escapeXML:!0}),WebView=class{constructor(){this.testing=!1;let{__SPECIAL_TEST_PARAMETER__}=import_qs3.default.parse(document22.location.search,{ignoreQueryPrefix:!0});switch(__SPECIAL_TEST_PARAMETER__){case"preparing-story":{this.showPreparingStory(),this.testing=!0;break}case"preparing-docs":{this.showPreparingDocs(),this.testing=!0;break}}}prepareForStory(story){return this.showStory(),this.applyLayout(story.parameters.layout),document22.documentElement.scrollTop=0,document22.documentElement.scrollLeft=0,this.storyRoot()}storyRoot(){return document22.getElementById("storybook-root")}prepareForDocs(){return this.showMain(),this.showDocs(),this.applyLayout("fullscreen"),this.docsRoot()}docsRoot(){return document22.getElementById("storybook-docs")}applyLayout(layout="padded"){if(layout==="none"){document22.body.classList.remove(this.currentLayoutClass),this.currentLayoutClass=null;return}this.checkIfLayoutExists(layout);let layoutClass=layoutClassMap[layout];document22.body.classList.remove(this.currentLayoutClass),document22.body.classList.add(layoutClass),this.currentLayoutClass=layoutClass}checkIfLayoutExists(layout){layoutClassMap[layout]||logger.warn(dedent`The desired layout: ${layout} is not a valid option.
|
|
100
|
+
`),acc),{})},{history,document:document3}=scope;function pathToId(path){let match=(path||"").match(/^\/story\/(.+)/);if(!match)throw new Error(`Invalid path '${path}', must start with '/story/'`);return match[1]}var getQueryString=({selection,extraParams})=>{let{search=""}=document3.location,{path,selectedKind,selectedStory,...rest}=import_qs3.default.parse(search,{ignoreQueryPrefix:!0});return import_qs3.default.stringify({...rest,...extraParams,...selection&&{id:selection.storyId,viewMode:selection.viewMode}},{encode:!1,addQueryPrefix:!0})},setPath=selection=>{if(!selection)return;let query=getQueryString({selection}),{hash=""}=document3.location;document3.title=selection.storyId,history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)},isObject4=val=>val!=null&&typeof val=="object"&&Array.isArray(val)===!1,getFirstString=v2=>{if(v2!==void 0){if(typeof v2=="string")return v2;if(Array.isArray(v2))return getFirstString(v2[0]);if(isObject4(v2))return getFirstString(Object.values(v2).filter(Boolean))}},getSelectionSpecifierFromPath=()=>{let query=import_qs3.default.parse(document3.location.search,{ignoreQueryPrefix:!0}),args2=typeof query.args=="string"?parseArgsParam(query.args):void 0,globals2=typeof query.globals=="string"?parseArgsParam(query.globals):void 0,viewMode=getFirstString(query.viewMode);(typeof viewMode!="string"||!viewMode.match(/docs|story/))&&(viewMode="story");let path=getFirstString(query.path),storyId=path?pathToId(path):getFirstString(query.id);return storyId?{storySpecifier:storyId,args:args2,globals:globals2,viewMode}:null},UrlStore=class{constructor(){this.selectionSpecifier=getSelectionSpecifierFromPath()}setSelection(selection){this.selection=selection,setPath(this.selection)}setQueryParams(queryParams){let query=getQueryString({extraParams:queryParams}),{hash=""}=document3.location;history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)}},import_ansi_to_html=__toESM3(require_ansi_to_html()),{document:document22}=scope,PREPARING_DELAY=100,Mode=(Mode2=>(Mode2.MAIN="MAIN",Mode2.NOPREVIEW="NOPREVIEW",Mode2.PREPARING_STORY="PREPARING_STORY",Mode2.PREPARING_DOCS="PREPARING_DOCS",Mode2.ERROR="ERROR",Mode2))(Mode||{}),classes={PREPARING_STORY:"sb-show-preparing-story",PREPARING_DOCS:"sb-show-preparing-docs",MAIN:"sb-show-main",NOPREVIEW:"sb-show-nopreview",ERROR:"sb-show-errordisplay"},layoutClassMap={centered:"sb-main-centered",fullscreen:"sb-main-fullscreen",padded:"sb-main-padded"},ansiConverter=new import_ansi_to_html.default({escapeXML:!0}),WebView=class{constructor(){this.testing=!1;let{__SPECIAL_TEST_PARAMETER__}=import_qs3.default.parse(document22.location.search,{ignoreQueryPrefix:!0});switch(__SPECIAL_TEST_PARAMETER__){case"preparing-story":{this.showPreparingStory(),this.testing=!0;break}case"preparing-docs":{this.showPreparingDocs(),this.testing=!0;break}}}prepareForStory(story){return this.showStory(),this.applyLayout(story.parameters.layout),document22.documentElement.scrollTop=0,document22.documentElement.scrollLeft=0,this.storyRoot()}storyRoot(){return document22.getElementById("storybook-root")}prepareForDocs(){return this.showMain(),this.showDocs(),this.applyLayout("fullscreen"),document22.documentElement.scrollTop=0,document22.documentElement.scrollLeft=0,this.docsRoot()}docsRoot(){return document22.getElementById("storybook-docs")}applyLayout(layout="padded"){if(layout==="none"){document22.body.classList.remove(this.currentLayoutClass),this.currentLayoutClass=null;return}this.checkIfLayoutExists(layout);let layoutClass=layoutClassMap[layout];document22.body.classList.remove(this.currentLayoutClass),document22.body.classList.add(layoutClass),this.currentLayoutClass=layoutClass}checkIfLayoutExists(layout){layoutClassMap[layout]||logger.warn(dedent`The desired layout: ${layout} is not a valid option.
|
|
101
101
|
The possible options are: ${Object.keys(layoutClassMap).join(", ")}, none.`)}showMode(mode){clearTimeout(this.preparingTimeout),Object.keys(Mode).forEach(otherMode=>{otherMode===mode?document22.body.classList.add(classes[otherMode]):document22.body.classList.remove(classes[otherMode])})}showErrorDisplay({message="",stack=""}){let header=message,detail=stack,parts=message.split(`
|
|
102
102
|
`);parts.length>1&&([header]=parts,detail=parts.slice(1).join(`
|
|
103
103
|
`)),document22.getElementById("error-message").innerHTML=ansiConverter.toHtml(header),document22.getElementById("error-stack").innerHTML=ansiConverter.toHtml(detail),this.showMode("ERROR")}showNoPreview(){this.testing||(this.showMode("NOPREVIEW"),this.storyRoot()?.setAttribute("hidden","true"),this.docsRoot()?.setAttribute("hidden","true"))}showPreparingStory({immediate=!1}={}){clearTimeout(this.preparingTimeout),immediate?this.showMode("PREPARING_STORY"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_STORY"),PREPARING_DELAY)}showPreparingDocs({immediate=!1}={}){clearTimeout(this.preparingTimeout),immediate?this.showMode("PREPARING_DOCS"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_DOCS"),PREPARING_DELAY)}showMain(){this.showMode("MAIN")}showDocs(){this.storyRoot().setAttribute("hidden","true"),this.docsRoot().removeAttribute("hidden")}showStory(){this.docsRoot().setAttribute("hidden","true"),this.storyRoot().removeAttribute("hidden")}showStoryDuringRender(){document22.body.classList.add(classes.MAIN)}},PreviewWeb=class extends PreviewWithSelection{constructor(){super(new UrlStore,new WebView),scope.__STORYBOOK_PREVIEW__=this}},{document:document32}=scope,runScriptTypes=["application/javascript","application/ecmascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript","module"],SCRIPT="script",SCRIPTS_ROOT_ID="scripts-root";function simulateDOMContentLoaded(){let DOMContentLoadedEvent=document32.createEvent("Event");DOMContentLoadedEvent.initEvent("DOMContentLoaded",!0,!0),document32.dispatchEvent(DOMContentLoadedEvent)}function insertScript($script,callback,$scriptRoot){let scriptEl=document32.createElement("script");scriptEl.type=$script.type==="module"?"module":"text/javascript",$script.src?(scriptEl.onload=callback,scriptEl.onerror=callback,scriptEl.src=$script.src):scriptEl.textContent=$script.innerText,$scriptRoot?$scriptRoot.appendChild(scriptEl):document32.head.appendChild(scriptEl),$script.parentNode.removeChild($script),$script.src||callback()}function insertScriptsSequentially(scriptsToExecute,callback,index=0){scriptsToExecute[index](()=>{index++,index===scriptsToExecute.length?callback():insertScriptsSequentially(scriptsToExecute,callback,index)})}function simulatePageLoad($container){let $scriptsRoot=document32.getElementById(SCRIPTS_ROOT_ID);$scriptsRoot?$scriptsRoot.innerHTML="":($scriptsRoot=document32.createElement("div"),$scriptsRoot.id=SCRIPTS_ROOT_ID,document32.body.appendChild($scriptsRoot));let $scripts=Array.from($container.querySelectorAll(SCRIPT));if($scripts.length){let scriptsToExecute=[];$scripts.forEach($script=>{let typeAttr=$script.getAttribute("type");(!typeAttr||runScriptTypes.includes(typeAttr))&&scriptsToExecute.push(callback=>insertScript($script,callback,$scriptsRoot))}),scriptsToExecute.length&&insertScriptsSequentially(scriptsToExecute,simulateDOMContentLoaded,void 0)}else simulateDOMContentLoaded()}function executeLoadable(loadable){let reqs=null;Array.isArray(loadable)?reqs=loadable:loadable.keys&&(reqs=[loadable]);let exportsMap=new Map;if(reqs)reqs.forEach(req=>{req.keys().forEach(filename=>{try{let fileExports=req(filename);exportsMap.set(typeof req.resolve=="function"?req.resolve(filename):filename,fileExports)}catch(error){let errorString=error.message&&error.stack?`${error.message}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preview",
|
|
3
|
-
"version": "7.1.0-alpha.
|
|
3
|
+
"version": "7.1.0-alpha.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"prep": "../../../scripts/prepare/esm-bundle.ts"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@storybook/channels": "7.1.0-alpha.
|
|
59
|
-
"@storybook/client-logger": "7.1.0-alpha.
|
|
60
|
-
"@storybook/core-events": "7.1.0-alpha.
|
|
61
|
-
"@storybook/preview-api": "7.1.0-alpha.
|
|
58
|
+
"@storybook/channels": "7.1.0-alpha.38",
|
|
59
|
+
"@storybook/client-logger": "7.1.0-alpha.38",
|
|
60
|
+
"@storybook/core-events": "7.1.0-alpha.38",
|
|
61
|
+
"@storybook/preview-api": "7.1.0-alpha.38",
|
|
62
62
|
"typescript": "~4.9.3"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|