@storybook/preview 8.1.0-alpha.4 → 8.1.0-alpha.6
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 +4 -2
- package/package.json +5 -5
package/dist/runtime.js
CHANGED
|
@@ -133,7 +133,9 @@ See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-
|
|
|
133
133
|
Omitted potentially unsafe URL args.
|
|
134
134
|
|
|
135
135
|
More info: https://storybook.js.org/docs/react/writing-stories/args#setting-args-through-the-url
|
|
136
|
-
`),acc),{})},{history,document:document22}=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
|
|
137
|
-
|
|
136
|
+
`),acc),{})},{history,document:document22}=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=typeof document22<"u"?document22.location.search:"",{path,selectedKind,selectedStory,...rest}=import_qs.default.parse(search,{ignoreQueryPrefix:!0});return import_qs.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=""}=document22.location;document22.title=selection.storyId,history.replaceState({},"",`${document22.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=()=>{if(typeof document22<"u"){let query=import_qs.default.parse(document22.location.search,{ignoreQueryPrefix:!0}),args2=typeof query.args=="string"?parseArgsParam(query.args):void 0,globals=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);if(storyId)return{storySpecifier:storyId,args:args2,globals,viewMode}}return null},UrlStore=class{constructor(){this.selectionSpecifier=getSelectionSpecifierFromPath()}setSelection(selection){this.selection=selection,setPath(this.selection)}setQueryParams(queryParams){let query=getQueryString({extraParams:queryParams}),{hash=""}=document22.location;history.replaceState({},"",`${document22.location.pathname}${query}${hash}`)}},import_ansi_to_html=__toESM3(require_ansi_to_html()),{document:document3}=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(){if(this.testing=!1,typeof document3<"u"){let{__SPECIAL_TEST_PARAMETER__}=import_qs.default.parse(document3.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),document3.documentElement.scrollTop=0,document3.documentElement.scrollLeft=0,this.storyRoot()}storyRoot(){return document3.getElementById("storybook-root")}prepareForDocs(){return this.showMain(),this.showDocs(),this.applyLayout("fullscreen"),document3.documentElement.scrollTop=0,document3.documentElement.scrollLeft=0,this.docsRoot()}docsRoot(){return document3.getElementById("storybook-docs")}applyLayout(layout="padded"){if(layout==="none"){document3.body.classList.remove(this.currentLayoutClass),this.currentLayoutClass=null;return}this.checkIfLayoutExists(layout);let layoutClass=layoutClassMap[layout];document3.body.classList.remove(this.currentLayoutClass),document3.body.classList.add(layoutClass),this.currentLayoutClass=layoutClass}checkIfLayoutExists(layout){layoutClassMap[layout]||logger.warn(dedent`
|
|
137
|
+
The desired layout: ${layout} is not a valid option.
|
|
138
|
+
The possible options are: ${Object.keys(layoutClassMap).join(", ")}, none.
|
|
139
|
+
`)}showMode(mode){clearTimeout(this.preparingTimeout),Object.keys(Mode).forEach(otherMode=>{otherMode===mode?document3.body.classList.add(classes[otherMode]):document3.body.classList.remove(classes[otherMode])})}showErrorDisplay({message="",stack=""}){let header=message,detail=stack,parts=message.split(`
|
|
138
140
|
`);parts.length>1&&([header]=parts,detail=parts.slice(1).join(`
|
|
139
141
|
`).replace(/^\n/,"")),document3.getElementById("error-message").innerHTML=ansiConverter.toHtml(header),document3.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(){document3.body.classList.add(classes.MAIN)}},PreviewWeb=class extends PreviewWithSelection{constructor(importFn,getProjectAnnotations){super(importFn,getProjectAnnotations,new UrlStore,new WebView),this.importFn=importFn,this.getProjectAnnotations=getProjectAnnotations,scope.__STORYBOOK_PREVIEW__=this}},{document:document4}=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=document4.createEvent("Event");DOMContentLoadedEvent.initEvent("DOMContentLoaded",!0,!0),document4.dispatchEvent(DOMContentLoadedEvent)}function insertScript($script,callback,$scriptRoot){let scriptEl=document4.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):document4.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=document4.getElementById(SCRIPTS_ROOT_ID);$scriptsRoot?$scriptsRoot.innerHTML="":($scriptsRoot=document4.createElement("div"),$scriptsRoot.id=SCRIPTS_ROOT_ID,document4.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()}var dist_exports6={};__export(dist_exports6,{Addon_TypesEnum:()=>Addon_TypesEnum});var Addon_TypesEnum=(Addon_TypesEnum2=>(Addon_TypesEnum2.TAB="tab",Addon_TypesEnum2.PANEL="panel",Addon_TypesEnum2.TOOL="tool",Addon_TypesEnum2.TOOLEXTRA="toolextra",Addon_TypesEnum2.PREVIEW="preview",Addon_TypesEnum2.experimental_PAGE="page",Addon_TypesEnum2.experimental_SIDEBAR_BOTTOM="sidebar-bottom",Addon_TypesEnum2.experimental_SIDEBAR_TOP="sidebar-top",Addon_TypesEnum2))(Addon_TypesEnum||{});var globalsNameValueMap={"@storybook/channels":dist_exports4,"@storybook/client-logger":dist_exports3,"@storybook/core-events":dist_exports,"@storybook/core-events/preview-errors":preview_errors_exports,"@storybook/preview-api":dist_exports5,"@storybook/global":dist_exports2,"@storybook/types":dist_exports6};var import_browser_dtector=__toESM(require_browser_dtector_umd_min()),browserInfo;function getBrowserInfo(){return browserInfo||(browserInfo=new import_browser_dtector.default(scope.navigator?.userAgent).getBrowserInfo()),browserInfo}function prepareForTelemetry(error){return error.browserInfo=getBrowserInfo(),error}globalPackages.forEach(key2=>{scope[globalsNameReferenceMap[key2]]=globalsNameValueMap[key2]});scope.sendTelemetryError=error=>{scope.__STORYBOOK_ADDONS_CHANNEL__.emit(TELEMETRY_ERROR,prepareForTelemetry(error))};scope.addEventListener("error",args2=>{let error=args2.error||args2;error.fromStorybook&&scope.sendTelemetryError(error)});scope.addEventListener("unhandledrejection",({reason})=>{reason.fromStorybook&&scope.sendTelemetryError(reason)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preview",
|
|
3
|
-
"version": "8.1.0-alpha.
|
|
3
|
+
"version": "8.1.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/esm-bundle.ts"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@storybook/channels": "8.1.0-alpha.
|
|
61
|
-
"@storybook/client-logger": "8.1.0-alpha.
|
|
62
|
-
"@storybook/core-events": "8.1.0-alpha.
|
|
60
|
+
"@storybook/channels": "8.1.0-alpha.6",
|
|
61
|
+
"@storybook/client-logger": "8.1.0-alpha.6",
|
|
62
|
+
"@storybook/core-events": "8.1.0-alpha.6",
|
|
63
63
|
"@storybook/global": "^5.0.0",
|
|
64
|
-
"@storybook/preview-api": "8.1.0-alpha.
|
|
64
|
+
"@storybook/preview-api": "8.1.0-alpha.6",
|
|
65
65
|
"browser-dtector": "^3.4.0",
|
|
66
66
|
"typescript": "^5.3.2"
|
|
67
67
|
},
|