@aussieljk/forkbook 0.0.0-stage → 0.0.1-2
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/LICENSE +22 -0
- package/README.md +77 -2
- package/assets/addon-vitest/templates/vitest.config.4.template.ts +36 -0
- package/assets/browser/favicon-wrapper.svg +46 -0
- package/assets/browser/favicon.svg +1 -0
- package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-bold.woff2 +0 -0
- package/assets/browser/nunito-sans-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-regular.woff2 +0 -0
- package/assets/builder-vite/iframe.html +99 -0
- package/assets/create/rendererAssets/.eslintrc.json +16 -0
- package/assets/create/rendererAssets/common/Configure.mdx +388 -0
- package/assets/create/rendererAssets/common/assets/accessibility.png +0 -0
- package/assets/create/rendererAssets/common/assets/accessibility.svg +1 -0
- package/assets/create/rendererAssets/common/assets/addon-library.png +0 -0
- package/assets/create/rendererAssets/common/assets/assets.png +0 -0
- package/assets/create/rendererAssets/common/assets/avif-test-image.avif +0 -0
- package/assets/create/rendererAssets/common/assets/context.png +0 -0
- package/assets/create/rendererAssets/common/assets/discord.svg +1 -0
- package/assets/create/rendererAssets/common/assets/docs.png +0 -0
- package/assets/create/rendererAssets/common/assets/figma-plugin.png +0 -0
- package/assets/create/rendererAssets/common/assets/github.svg +1 -0
- package/assets/create/rendererAssets/common/assets/share.png +0 -0
- package/assets/create/rendererAssets/common/assets/styling.png +0 -0
- package/assets/create/rendererAssets/common/assets/testing.png +0 -0
- package/assets/create/rendererAssets/common/assets/theming.png +0 -0
- package/assets/create/rendererAssets/common/assets/tutorials.svg +1 -0
- package/assets/create/rendererAssets/common/assets/youtube.svg +1 -0
- package/assets/create/rendererAssets/common/button.css +30 -0
- package/assets/create/rendererAssets/common/header.css +32 -0
- package/assets/create/rendererAssets/common/page.css +68 -0
- package/assets/create/templates/react-native/index.expo.js +20 -0
- package/assets/create/templates/react-native/index.js +25 -0
- package/assets/docs/addon-backgrounds.gif +0 -0
- package/assets/docs/addon-controls-args-annotated.png +0 -0
- package/assets/docs/addon-controls-args-background-color.png +0 -0
- package/assets/docs/addon-controls-args-background-string.png +0 -0
- package/assets/docs/addon-controls-args-docs.png +0 -0
- package/assets/docs/addon-controls-args-logging.png +0 -0
- package/assets/docs/addon-controls-args-no-annotation.png +0 -0
- package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
- package/assets/docs/addon-controls-args-reflow.png +0 -0
- package/assets/docs/addon-controls-args-template.png +0 -0
- package/assets/docs/addon-controls-expanded.png +0 -0
- package/assets/docs/addon-controls-hero.gif +0 -0
- package/assets/docs/addon-controls-install.png +0 -0
- package/assets/docs/hero.gif +0 -0
- package/assets/docs/highlight.png +0 -0
- package/assets/docs/message-reference.png +0 -0
- package/assets/docs/viewport.png +0 -0
- package/assets/react-native/metro-env.d.ts +69 -0
- package/assets/server/addon.tsconfig.json +6 -0
- package/assets/server/base-preview-body.html +116 -0
- package/assets/server/base-preview-head.html +494 -0
- package/assets/server/openBrowser.applescript +94 -0
- package/assets/server/template.ejs +87 -0
- package/dist/.build-stamp +0 -0
- package/dist/_browser-chunks/Color-PCLE2J36.js +1025 -0
- package/dist/_browser-chunks/DocsRenderer-JXND3PVQ.js +10 -0
- package/dist/_browser-chunks/WithTooltip-XSQFTBMB.js +1619 -0
- package/dist/_browser-chunks/chunk-2JDQ35OA.js +247 -0
- package/dist/_browser-chunks/chunk-2JT76G3E.js +104 -0
- package/dist/_browser-chunks/chunk-2MEPHP35.js +17 -0
- package/dist/_browser-chunks/chunk-2SCZVUKW.js +24 -0
- package/dist/_browser-chunks/chunk-46Z7NGAS.js +41 -0
- package/dist/_browser-chunks/chunk-4ATQOMJB.js +30 -0
- package/dist/_browser-chunks/chunk-52CW7FF7.js +49 -0
- package/dist/_browser-chunks/chunk-5I7E4GMO.js +62 -0
- package/dist/_browser-chunks/chunk-5P4QA6MY.js +20 -0
- package/dist/_browser-chunks/chunk-5WMXI5GW.js +816 -0
- package/dist/_browser-chunks/chunk-66OCZ54D.js +2604 -0
- package/dist/_browser-chunks/chunk-6SXYJQST.js +253 -0
- package/dist/_browser-chunks/chunk-AYRF6EJB.js +36 -0
- package/dist/_browser-chunks/chunk-B4AUNNU4.js +156 -0
- package/dist/_browser-chunks/chunk-BCP2FFXF.js +369 -0
- package/dist/_browser-chunks/chunk-C3D4HEFY.js +3396 -0
- package/dist/_browser-chunks/chunk-CFAOWGL7.js +43 -0
- package/dist/_browser-chunks/chunk-CFWWCCZV.js +223 -0
- package/dist/_browser-chunks/chunk-CNED6RYH.js +18 -0
- package/dist/_browser-chunks/chunk-DRQKCCAG.js +136 -0
- package/dist/_browser-chunks/chunk-ECQ75MKQ.js +0 -0
- package/dist/_browser-chunks/chunk-EIYAKDGP.js +302 -0
- package/dist/_browser-chunks/chunk-ENKK74N4.js +12 -0
- package/dist/_browser-chunks/chunk-FENFYI4X.js +698 -0
- package/dist/_browser-chunks/chunk-FJGWSWL5.js +155 -0
- package/dist/_browser-chunks/chunk-FVSEPWWX.js +2810 -0
- package/dist/_browser-chunks/chunk-GNZY6LOW.js +10116 -0
- package/dist/_browser-chunks/chunk-IE4ULIOQ.js +14 -0
- package/dist/_browser-chunks/chunk-IMSF75WX.js +42 -0
- package/dist/_browser-chunks/chunk-IWQGIXJS.js +14 -0
- package/dist/_browser-chunks/chunk-JMC7AIKT.js +108 -0
- package/dist/_browser-chunks/chunk-JPUOQJUI.js +8 -0
- package/dist/_browser-chunks/chunk-JSBKXXXF.js +218 -0
- package/dist/_browser-chunks/chunk-JWSKPMPC.js +73 -0
- package/dist/_browser-chunks/chunk-JYVGARBG.js +2943 -0
- package/dist/_browser-chunks/chunk-KBK7GKBN.js +35 -0
- package/dist/_browser-chunks/chunk-KQ7CRO2B.js +108 -0
- package/dist/_browser-chunks/chunk-LAWXTSXK.js +18 -0
- package/dist/_browser-chunks/chunk-LE2LTDW3.js +14 -0
- package/dist/_browser-chunks/chunk-LEVSOOLQ.js +48 -0
- package/dist/_browser-chunks/chunk-LV5PIKV4.js +93 -0
- package/dist/_browser-chunks/chunk-MDOL7KML.js +56 -0
- package/dist/_browser-chunks/chunk-MFMDGWP6.js +34 -0
- package/dist/_browser-chunks/chunk-MLBOOZL4.js +67 -0
- package/dist/_browser-chunks/chunk-NQUD4B7H.js +91 -0
- package/dist/_browser-chunks/chunk-NULBREPZ.js +43 -0
- package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
- package/dist/_browser-chunks/chunk-OD6IBQCC.js +117 -0
- package/dist/_browser-chunks/chunk-ODVJ3XZJ.js +157 -0
- package/dist/_browser-chunks/chunk-OQWFVDIN.js +386 -0
- package/dist/_browser-chunks/chunk-OVH3USFB.js +20 -0
- package/dist/_browser-chunks/chunk-OZZPSYQR.js +14 -0
- package/dist/_browser-chunks/chunk-P6PK47TQ.js +1970 -0
- package/dist/_browser-chunks/chunk-PFRNG3UC.js +22 -0
- package/dist/_browser-chunks/chunk-PJSMZ27A.js +13 -0
- package/dist/_browser-chunks/chunk-QC4HFS6K.js +41 -0
- package/dist/_browser-chunks/chunk-QDXFODK4.js +274 -0
- package/dist/_browser-chunks/chunk-RBCHTR7C.js +28 -0
- package/dist/_browser-chunks/chunk-RMYQ3QN3.js +294 -0
- package/dist/_browser-chunks/chunk-RNTIV5CE.js +411 -0
- package/dist/_browser-chunks/chunk-RSPAQWVJ.js +80 -0
- package/dist/_browser-chunks/chunk-S6TK43XQ.js +836 -0
- package/dist/_browser-chunks/chunk-SC67XZST.js +18 -0
- package/dist/_browser-chunks/chunk-SFVA4SBT.js +683 -0
- package/dist/_browser-chunks/chunk-SZYFOQMT.js +25 -0
- package/dist/_browser-chunks/chunk-TBJCJXK4.js +18 -0
- package/dist/_browser-chunks/chunk-UMDO3KB7.js +205 -0
- package/dist/_browser-chunks/chunk-V2G23FV7.js +11 -0
- package/dist/_browser-chunks/chunk-V5M7Q4HT.js +88 -0
- package/dist/_browser-chunks/chunk-W5M6NPS3.js +198 -0
- package/dist/_browser-chunks/chunk-W7NE2JXW.js +84 -0
- package/dist/_browser-chunks/chunk-WGVAAM43.js +1110 -0
- package/dist/_browser-chunks/chunk-WHQRNHXD.js +8 -0
- package/dist/_browser-chunks/chunk-WOSOWBCA.js +12 -0
- package/dist/_browser-chunks/chunk-WZ7KR7SH.js +85 -0
- package/dist/_browser-chunks/chunk-YEKO6BHJ.js +20 -0
- package/dist/_browser-chunks/chunk-YI2IBIQS.js +7 -0
- package/dist/_browser-chunks/chunk-YTIT5NA5.js +1966 -0
- package/dist/_browser-chunks/chunk-ZEHRUHTA.js +6 -0
- package/dist/_browser-chunks/chunk-ZTQ5MEJ5.js +203 -0
- package/dist/_browser-chunks/matchers-YLBYSYAF.js +1263 -0
- package/dist/_browser-chunks/react-dom-client-4OHE3QDV.js +9 -0
- package/dist/_node-chunks/attached-runtime-I2G4WLJI.js +282 -0
- package/dist/_node-chunks/builder-manager-VVHYQXCH.js +1661 -0
- package/dist/_node-chunks/chunk-2BUPBPFB.js +82 -0
- package/dist/_node-chunks/chunk-2DSIDINN.js +884 -0
- package/dist/_node-chunks/chunk-2RU7BKEW.js +23 -0
- package/dist/_node-chunks/chunk-34EO2PUT.js +26 -0
- package/dist/_node-chunks/chunk-3BKIBF5S.js +3008 -0
- package/dist/_node-chunks/chunk-3SDUYDXH.js +98 -0
- package/dist/_node-chunks/chunk-3T4ZSNPH.js +662 -0
- package/dist/_node-chunks/chunk-3W7F2B7P.js +79 -0
- package/dist/_node-chunks/chunk-3Y6AAY5H.js +80 -0
- package/dist/_node-chunks/chunk-42UWAGPW.js +1193 -0
- package/dist/_node-chunks/chunk-4FEANXWU.js +1986 -0
- package/dist/_node-chunks/chunk-5DQFEZEA.js +40 -0
- package/dist/_node-chunks/chunk-6KEHV53S.js +1218 -0
- package/dist/_node-chunks/chunk-6LMWA44H.js +3837 -0
- package/dist/_node-chunks/chunk-6YKBRP72.js +20 -0
- package/dist/_node-chunks/chunk-7GUDZVRQ.js +110 -0
- package/dist/_node-chunks/chunk-B5J7Q7J4.js +21 -0
- package/dist/_node-chunks/chunk-BS2WMZMR.js +90 -0
- package/dist/_node-chunks/chunk-BSKFCWQD.js +47 -0
- package/dist/_node-chunks/chunk-BXVYT7SB.js +36 -0
- package/dist/_node-chunks/chunk-CCOTJ4FC.js +688 -0
- package/dist/_node-chunks/chunk-CQKMLL5J.js +33 -0
- package/dist/_node-chunks/chunk-CXRU72ET.js +63 -0
- package/dist/_node-chunks/chunk-DC7DKR5K.js +20 -0
- package/dist/_node-chunks/chunk-DHJFTB4K.js +25 -0
- package/dist/_node-chunks/chunk-DUR55DJJ.js +1094 -0
- package/dist/_node-chunks/chunk-E6YESGLX.js +7032 -0
- package/dist/_node-chunks/chunk-EHUNOMDD.js +52345 -0
- package/dist/_node-chunks/chunk-ET7PWEO7.js +298 -0
- package/dist/_node-chunks/chunk-EWOX7HPJ.js +20 -0
- package/dist/_node-chunks/chunk-F3ZFKBHY.js +844 -0
- package/dist/_node-chunks/chunk-FK7KGTV7.js +26 -0
- package/dist/_node-chunks/chunk-FPZB5OI7.js +35 -0
- package/dist/_node-chunks/chunk-FW2HQUBQ.js +25 -0
- package/dist/_node-chunks/chunk-FY6UXW6G.js +11 -0
- package/dist/_node-chunks/chunk-GEFQN7K3.js +499 -0
- package/dist/_node-chunks/chunk-GRBLDJCR.js +989 -0
- package/dist/_node-chunks/chunk-H32DYT6P.js +87 -0
- package/dist/_node-chunks/chunk-H4PPVMP5.js +23 -0
- package/dist/_node-chunks/chunk-HMP2G23X.js +25 -0
- package/dist/_node-chunks/chunk-ICPBH3E7.js +59 -0
- package/dist/_node-chunks/chunk-IDEL2J23.js +23 -0
- package/dist/_node-chunks/chunk-IK4FGZLR.js +223 -0
- package/dist/_node-chunks/chunk-JDXXX6LB.js +68 -0
- package/dist/_node-chunks/chunk-JGGFYIG5.js +5468 -0
- package/dist/_node-chunks/chunk-JPAZLYJ3.js +29 -0
- package/dist/_node-chunks/chunk-JZOO7GGC.js +48 -0
- package/dist/_node-chunks/chunk-KISMCCP5.js +4744 -0
- package/dist/_node-chunks/chunk-LCK4ZQKG.js +115 -0
- package/dist/_node-chunks/chunk-LO56I6E2.js +132 -0
- package/dist/_node-chunks/chunk-LXBD4UL4.js +104 -0
- package/dist/_node-chunks/chunk-MA24JW6C.js +7162 -0
- package/dist/_node-chunks/chunk-MK2KYAI6.js +5414 -0
- package/dist/_node-chunks/chunk-NDWKJ4CL.js +2102 -0
- package/dist/_node-chunks/chunk-NIBT7XDZ.js +168 -0
- package/dist/_node-chunks/chunk-NPO45IMH.js +33 -0
- package/dist/_node-chunks/chunk-OISX4AGQ.js +414 -0
- package/dist/_node-chunks/chunk-OUW6R7C3.js +26 -0
- package/dist/_node-chunks/chunk-OWNFOGTA.js +194 -0
- package/dist/_node-chunks/chunk-Q7QNUM5H.js +49 -0
- package/dist/_node-chunks/chunk-QEQLR22M.js +1877 -0
- package/dist/_node-chunks/chunk-RRN2V55B.js +45 -0
- package/dist/_node-chunks/chunk-RWFIFGO5.js +144 -0
- package/dist/_node-chunks/chunk-RXNJDRGO.js +209 -0
- package/dist/_node-chunks/chunk-RZMQ7S3L.js +92 -0
- package/dist/_node-chunks/chunk-SIEXZVCR.js +51 -0
- package/dist/_node-chunks/chunk-SLWQNBGO.js +2034 -0
- package/dist/_node-chunks/chunk-SVTBJ7Q3.js +35 -0
- package/dist/_node-chunks/chunk-SWO5CDYU.js +32 -0
- package/dist/_node-chunks/chunk-TD5PLLQG.js +121 -0
- package/dist/_node-chunks/chunk-TEQGGSP7.js +33 -0
- package/dist/_node-chunks/chunk-TFCEV2XX.js +155 -0
- package/dist/_node-chunks/chunk-TFEWM4E3.js +1073 -0
- package/dist/_node-chunks/chunk-TINO74G5.js +21 -0
- package/dist/_node-chunks/chunk-TNJIXE37.js +40 -0
- package/dist/_node-chunks/chunk-TWI4GVH7.js +19 -0
- package/dist/_node-chunks/chunk-U5W53R2J.js +1011 -0
- package/dist/_node-chunks/chunk-UBOGWBEA.js +148 -0
- package/dist/_node-chunks/chunk-UMUBKI6E.js +3787 -0
- package/dist/_node-chunks/chunk-UVINFLGY.js +56 -0
- package/dist/_node-chunks/chunk-V2DY426G.js +1133 -0
- package/dist/_node-chunks/chunk-VLOXOXXE.js +45 -0
- package/dist/_node-chunks/chunk-W4OMYLSP.js +1297 -0
- package/dist/_node-chunks/chunk-WAXVSN3O.js +18 -0
- package/dist/_node-chunks/chunk-WCULS5TP.js +3767 -0
- package/dist/_node-chunks/chunk-WNZ2UMFM.js +153 -0
- package/dist/_node-chunks/chunk-WZJF2OUH.js +74 -0
- package/dist/_node-chunks/chunk-XGIUVY52.js +611 -0
- package/dist/_node-chunks/chunk-XHL2LVBM.js +415 -0
- package/dist/_node-chunks/chunk-XI6B6P47.js +59 -0
- package/dist/_node-chunks/chunk-XLP2ZKXV.js +60 -0
- package/dist/_node-chunks/chunk-YCMRA6RX.js +95 -0
- package/dist/_node-chunks/chunk-YZFWBA5L.js +2700 -0
- package/dist/_node-chunks/chunk-ZMAMXQKP.js +4731 -0
- package/dist/_node-chunks/chunk-ZWBCQ4MJ.js +110 -0
- package/dist/_node-chunks/dist-VTSTZKUB.js +16 -0
- package/dist/_node-chunks/globby-OEMHPBFY.js +2884 -0
- package/dist/_node-chunks/jiti-NFX6UU74.js +3848 -0
- package/dist/_node-chunks/lib-MDVARD7W.js +366 -0
- package/dist/_node-chunks/local-runtime-NTKIN2QT.js +78 -0
- package/dist/_node-chunks/mdx-plugin-MWISDWDQ.js +5680 -0
- package/dist/_node-chunks/monorepo-LIRFMQXE.js +121 -0
- package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-CPDW4XTW.js +121 -0
- package/dist/_node-chunks/optimized-tests-HDOLR3EY.js +22 -0
- package/dist/_node-chunks/pattern-copy-play-EKHIUAU2.js +807 -0
- package/dist/_node-chunks/postinstallAddon-GYGMWDL6.js +20 -0
- package/dist/_node-chunks/rehype-external-links-BUN3HUCO.js +121 -0
- package/dist/_node-chunks/rehype-slug-PLADX223.js +52 -0
- package/dist/_node-chunks/relaxed-limits-GBHW6KIQ.js +117 -0
- package/dist/_node-chunks/run-KDTIZNSY.js +103 -0
- package/dist/_node-chunks/run-NL66VTNR.js +4532 -0
- package/dist/_node-chunks/session-id-KIIVOQLR.js +23 -0
- package/dist/_node-chunks/setup-MGC7BQO6.js +278 -0
- package/dist/_node-chunks/vitest.config.4.template-JH2THZFG.js +54 -0
- package/dist/actions/decorator.d.ts +7 -0
- package/dist/actions/decorator.js +43 -0
- package/dist/actions/index.d.ts +67 -0
- package/dist/actions/index.js +28 -0
- package/dist/addon-a11y/index.d.ts +52 -0
- package/dist/addon-a11y/index.js +16 -0
- package/dist/addon-a11y/manager.js +1429 -0
- package/dist/addon-a11y/preset.js +18 -0
- package/dist/addon-a11y/preview.d.ts +17 -0
- package/dist/addon-a11y/preview.js +15 -0
- package/dist/addon-docs/blocks.d.ts +1061 -0
- package/dist/addon-docs/blocks.js +2461 -0
- package/dist/addon-docs/index.d.ts +236 -0
- package/dist/addon-docs/index.js +16 -0
- package/dist/addon-docs/manager.js +90 -0
- package/dist/addon-docs/mdx-react-shim.d.ts +1 -0
- package/dist/addon-docs/mdx-react-shim.js +2 -0
- package/dist/addon-docs/preset.js +378 -0
- package/dist/addon-docs/preview.d.ts +4 -0
- package/dist/addon-docs/preview.js +7 -0
- package/dist/addon-links/index.d.ts +22 -0
- package/dist/addon-links/index.js +20 -0
- package/dist/addon-links/manager.js +14 -0
- package/dist/addon-links/preview.d.ts +6 -0
- package/dist/addon-links/preview.js +9 -0
- package/dist/addon-links/react/index.d.ts +25 -0
- package/dist/addon-links/react/index.js +52 -0
- package/dist/addon-mcp/preset.js +1345 -0
- package/dist/addon-mcp/preview.js +29 -0
- package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +1153 -0
- package/dist/addon-ondevice-actions/index.d.ts +4 -0
- package/dist/addon-ondevice-actions/index.js +7 -0
- package/dist/addon-ondevice-actions/register.js +7 -0
- package/dist/addon-ondevice-controls/index.d.ts +6 -0
- package/dist/addon-ondevice-controls/index.js +14 -0
- package/dist/addon-ondevice-controls/register.js +10 -0
- package/dist/addon-pseudo-states/index.d.ts +35 -0
- package/dist/addon-pseudo-states/index.js +15 -0
- package/dist/addon-pseudo-states/manager.js +53 -0
- package/dist/addon-pseudo-states/preview.d.ts +9 -0
- package/dist/addon-pseudo-states/preview.js +10 -0
- package/dist/addon-themes/index.d.ts +80 -0
- package/dist/addon-themes/index.js +104 -0
- package/dist/addon-themes/manager.js +97 -0
- package/dist/addon-themes/postinstall.js +33 -0
- package/dist/addon-themes/preview.d.ts +6 -0
- package/dist/addon-themes/preview.js +8 -0
- package/dist/addon-vitest/constants.d.ts +132 -0
- package/dist/addon-vitest/constants.js +66 -0
- package/dist/addon-vitest/index.d.ts +4 -0
- package/dist/addon-vitest/index.js +8 -0
- package/dist/addon-vitest/manager.js +665 -0
- package/dist/addon-vitest/node/coverage-reporter.js +1284 -0
- package/dist/addon-vitest/node/vitest.js +674 -0
- package/dist/addon-vitest/postinstall.js +24 -0
- package/dist/addon-vitest/preset.js +943 -0
- package/dist/addon-vitest/vitest-plugin/global-setup.js +162 -0
- package/dist/addon-vitest/vitest-plugin/index.d.ts +56 -0
- package/dist/addon-vitest/vitest-plugin/index.js +463 -0
- package/dist/addon-vitest/vitest-plugin/setup-file-with-project-annotations.js +9 -0
- package/dist/addon-vitest/vitest-plugin/setup-file.browser.4.js +20 -0
- package/dist/addon-vitest/vitest-plugin/setup-file.js +50 -0
- package/dist/addon-vitest/vitest-plugin/test-utils.js +128 -0
- package/dist/babel/index.d.ts +2301 -0
- package/dist/babel/index.js +61 -0
- package/dist/backgrounds/index.d.ts +6 -0
- package/dist/backgrounds/index.js +15 -0
- package/dist/bin/core.js +1705 -0
- package/dist/bin/dispatcher.js +43 -0
- package/dist/bin/loader.js +115 -0
- package/dist/builder-vite/index.d.ts +50 -0
- package/dist/builder-vite/index.js +245 -0
- package/dist/builder-vite/preset.js +27 -0
- package/dist/channels/index.d.ts +2 -0
- package/dist/channels/index.js +352 -0
- package/dist/chunk-B2t1tGRh.d.ts +284 -0
- package/dist/chunk-BCoJQE-f.d.ts +602 -0
- package/dist/chunk-BGkgZp-H.d.ts +214 -0
- package/dist/chunk-BTVrWliM.d.ts +115 -0
- package/dist/chunk-BXLImeLy.d.ts +197 -0
- package/dist/chunk-BfBzpgct.d.ts +916 -0
- package/dist/chunk-Bpi2tz-6.d.ts +511 -0
- package/dist/chunk-BxWufQms.d.ts +142 -0
- package/dist/chunk-C-bavsOH.d.ts +34 -0
- package/dist/chunk-C2p5r3Vt.d.ts +13001 -0
- package/dist/chunk-C6PAgHLT.d.ts +12 -0
- package/dist/chunk-CMeX4WRe.d.ts +179 -0
- package/dist/chunk-Ct9xd6IM.d.ts +65 -0
- package/dist/chunk-CwQKNaYL.d.ts +15 -0
- package/dist/chunk-D7DwV41f.d.ts +3622 -0
- package/dist/chunk-DEVFdzxR.d.ts +253 -0
- package/dist/chunk-DaVb55-_.d.ts +124 -0
- package/dist/chunk-DgRNfmj_.d.ts +40 -0
- package/dist/chunk-DoIGKY33.d.ts +666 -0
- package/dist/chunk-Dr3R0DXk.d.ts +40 -0
- package/dist/chunk-DtHByo32.d.ts +55 -0
- package/dist/chunk-Dw1z1Pki.d.ts +933 -0
- package/dist/chunk-DzuY9DXg.d.ts +79 -0
- package/dist/chunk-FjDVzZTj.d.ts +62 -0
- package/dist/chunk-Kt1tW-D1.d.ts +59 -0
- package/dist/chunk-XP8oHzpE.d.ts +6 -0
- package/dist/chunk-gCX81nOr.d.ts +61 -0
- package/dist/chunk-pcFXCimE.d.ts +741 -0
- package/dist/cli/index.d.ts +1174 -0
- package/dist/cli/index.js +5613 -0
- package/dist/cli/skills/content/index.d.ts +72 -0
- package/dist/cli/skills/content/index.js +335 -0
- package/dist/cli/tools/sdk/child-host.d.ts +61 -0
- package/dist/cli/tools/sdk/child-host.js +131 -0
- package/dist/cli/tools/sdk/index.d.ts +137 -0
- package/dist/cli/tools/sdk/index.js +44 -0
- package/dist/cli-commands/bin/index.js +25 -0
- package/dist/client-logger/index.d.ts +31 -0
- package/dist/client-logger/index.js +63 -0
- package/dist/common/index.d.ts +1103 -0
- package/dist/common/index.js +364 -0
- package/dist/components/index.d.ts +1924 -0
- package/dist/components/index.js +13759 -0
- package/dist/core-events/index.d.ts +155 -0
- package/dist/core-events/index.js +136 -0
- package/dist/core-server/index.d.ts +2200 -0
- package/dist/core-server/index.js +4165 -0
- package/dist/core-server/presets/common-manager.css +170 -0
- package/dist/core-server/presets/common-manager.js +4168 -0
- package/dist/core-server/presets/common-override-preset.js +81 -0
- package/dist/core-server/presets/common-preset.js +2187 -0
- package/dist/create/bin/index.js +23 -0
- package/dist/create/index.js +25 -0
- package/dist/csf/csf-utils.d.ts +2 -0
- package/dist/csf/csf-utils.js +19 -0
- package/dist/csf/index.d.ts +7 -0
- package/dist/csf/index.js +2142 -0
- package/dist/csf-tools/index.d.ts +1157 -0
- package/dist/csf-tools/index.js +736 -0
- package/dist/docs-tools/index.d.ts +197 -0
- package/dist/docs-tools/index.js +61 -0
- package/dist/highlight/index.d.ts +10 -0
- package/dist/highlight/index.js +15 -0
- package/dist/instrumenter/index.d.ts +113 -0
- package/dist/instrumenter/index.js +2595 -0
- package/dist/manager/_manager-chunks/globals-runtime-8HkdnU2F.js +6144 -0
- package/dist/manager/_manager-chunks/globals-runtime-BIKBO23x.js +3389 -0
- package/dist/manager/_manager-chunks/globals-runtime-BdGkqNEt.js +45 -0
- package/dist/manager/_manager-chunks/globals-runtime-BmphMP6z.js +1190 -0
- package/dist/manager/_manager-chunks/globals-runtime-BvM-NY2g.js +13307 -0
- package/dist/manager/_manager-chunks/globals-runtime-C02fvgcd.js +9243 -0
- package/dist/manager/_manager-chunks/globals-runtime-DkAPXCvc.js +9766 -0
- package/dist/manager/_manager-chunks/globals-runtime-DpNYC-qi.js +5564 -0
- package/dist/manager/_manager-chunks/globals-runtime-DtcOnYHR.js +5357 -0
- package/dist/manager/_manager-chunks/globals-runtime-DwFqpqya.js +722 -0
- package/dist/manager/_manager-chunks/globals-runtime-FC201B7s.js +6837 -0
- package/dist/manager/_manager-chunks/globals-runtime-Rp_zjGnh.js +121 -0
- package/dist/manager/_manager-chunks/globals-runtime-ZHrQFa3-.js +10463 -0
- package/dist/manager/_manager-chunks/globals-runtime-eLPTIfX-.js +7759 -0
- package/dist/manager/_manager-chunks/globals-runtime-qKvCZHFY.js +4468 -0
- package/dist/manager/_manager-chunks/globals-runtime-sGpNlIJ1.js +5102 -0
- package/dist/manager/_manager-chunks/runtime-B1L9TH89.js +452 -0
- package/dist/manager/_manager-chunks/runtime-BK0zF7FN.js +22 -0
- package/dist/manager/_manager-chunks/runtime-BhkT2CXl.js +1408 -0
- package/dist/manager/_manager-chunks/runtime-Bly6WJLN.js +998 -0
- package/dist/manager/_manager-chunks/runtime-D0UOWx0U.js +979 -0
- package/dist/manager/_manager-chunks/runtime-D94Vq3oR.js +4014 -0
- package/dist/manager/_manager-chunks/runtime-DMig8mT7.js +77 -0
- package/dist/manager/_manager-chunks/runtime-EITvVbkG.js +46 -0
- package/dist/manager/_manager-chunks/runtime-cp5pazY2.js +8936 -0
- package/dist/manager/_manager-chunks/runtime-eDVAYF7N.js +6860 -0
- package/dist/manager/_manager-chunks/runtime-i-PDAHLR.js +2493 -0
- package/dist/manager/globals-runtime.js +2 -0
- package/dist/manager/globals.d.ts +23 -0
- package/dist/manager/globals.js +26 -0
- package/dist/manager/manager-stores.d.ts +2 -0
- package/dist/manager/manager-stores.js +19 -0
- package/dist/manager/runtime.js +2 -0
- package/dist/manager-api/index.d.ts +2 -0
- package/dist/manager-api/index.js +3257 -0
- package/dist/manager-errors.d.ts +89 -0
- package/dist/manager-errors.js +20 -0
- package/dist/mcp/index.d.ts +270 -0
- package/dist/mcp/index.js +305 -0
- package/dist/mocking-utils/index.d.ts +689 -0
- package/dist/mocking-utils/index.js +521 -0
- package/dist/mocking-utils/mocker-runtime.js +1254 -0
- package/dist/nextjs-vite/config/preview.js +3 -0
- package/dist/nextjs-vite/export-mocks/cache/index.d.ts +25 -0
- package/dist/nextjs-vite/export-mocks/cache/index.js +29 -0
- package/dist/nextjs-vite/export-mocks/headers/index.d.ts +37 -0
- package/dist/nextjs-vite/export-mocks/headers/index.js +54 -0
- package/dist/nextjs-vite/export-mocks/link/index.d.ts +9 -0
- package/dist/nextjs-vite/export-mocks/link/index.js +59 -0
- package/dist/nextjs-vite/export-mocks/navigation/index.d.ts +28 -0
- package/dist/nextjs-vite/export-mocks/navigation/index.js +58 -0
- package/dist/nextjs-vite/export-mocks/router/index.d.ts +34 -0
- package/dist/nextjs-vite/export-mocks/router/index.js +63 -0
- package/dist/nextjs-vite/index.d.ts +92 -0
- package/dist/nextjs-vite/index.js +58 -0
- package/dist/nextjs-vite/node/index.d.ts +6 -0
- package/dist/nextjs-vite/node/index.js +20 -0
- package/dist/nextjs-vite/preset.js +648 -0
- package/dist/nextjs-vite/preview.d.ts +20 -0
- package/dist/nextjs-vite/preview.js +11 -0
- package/dist/nextjs-vite/vite-plugin/index.d.ts +6 -0
- package/dist/nextjs-vite/vite-plugin/index.js +19 -0
- package/dist/nextjs-vite-plugin/index.d.ts +28 -0
- package/dist/nextjs-vite-plugin/index.js +923 -0
- package/dist/nextjs-vite-plugin/mocks/storybook.global.js +29 -0
- package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-context.js +8 -0
- package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-default-loader.js +23 -0
- package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-image.js +28 -0
- package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-legacy-image.js +17 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/cache/index.js +29 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/dynamic/index.js +40 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/headers/index.js +55 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/link/index.js +63 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/navigation/index.js +71 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/router/index.js +74 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/rsc/server-only.js +7 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/safe-stable-stringify/index.js +13 -0
- package/dist/nextjs-vite-plugin/plugins/next-mocks/compatibility/draft-mode.compat.js +7 -0
- package/dist/node-logger/index.d.ts +495 -0
- package/dist/node-logger/index.js +42 -0
- package/dist/oxc-parser/index.d.ts +99 -0
- package/dist/oxc-parser/index.js +275 -0
- package/dist/oxc-parser/worker.js +37 -0
- package/dist/preview/_chunks/runtime-BIzIdDbb.js +10263 -0
- package/dist/preview/_chunks/runtime-BTPtVY1p.js +1102 -0
- package/dist/preview/_chunks/runtime-BZSnICCg.js +8484 -0
- package/dist/preview/_chunks/runtime-BdGkqNEt.js +45 -0
- package/dist/preview/_chunks/runtime-BwSxqk3t.js +63 -0
- package/dist/preview/_chunks/runtime-CqHxptiK.js +6143 -0
- package/dist/preview/_chunks/runtime-CsV4HZPV.js +5064 -0
- package/dist/preview/_chunks/runtime-CxZK_Ln3.js +284 -0
- package/dist/preview/_chunks/runtime-DZToXfvO.js +9767 -0
- package/dist/preview/_chunks/runtime-DrTjJkPY.js +3872 -0
- package/dist/preview/_chunks/runtime-DuHdxMFA.js +387 -0
- package/dist/preview/_chunks/runtime-iXdo8CR8.js +3635 -0
- package/dist/preview/_chunks/runtime-q3wt0e_N.js +6838 -0
- package/dist/preview/globals.d.ts +16 -0
- package/dist/preview/globals.js +20 -0
- package/dist/preview/runtime.js +6 -0
- package/dist/preview-api/index.d.ts +4 -0
- package/dist/preview-api/index.js +147 -0
- package/dist/preview-errors.d.ts +186 -0
- package/dist/preview-errors.js +56 -0
- package/dist/react/docgen/docgen-worker.js +38 -0
- package/dist/react/entry-preview-argtypes.js +9 -0
- package/dist/react/entry-preview-docs.js +12 -0
- package/dist/react/entry-preview-rsc.js +11 -0
- package/dist/react/entry-preview.js +21 -0
- package/dist/react/index.d.ts +119 -0
- package/dist/react/index.js +26 -0
- package/dist/react/preset.js +301 -0
- package/dist/react/preview.d.ts +2 -0
- package/dist/react/preview.js +11 -0
- package/dist/react-native/bin/get-stories.js +34 -0
- package/dist/react-native/index.d.ts +160 -0
- package/dist/react-native/index.js +1547 -0
- package/dist/react-native/metro/node.d.ts +83 -0
- package/dist/react-native/metro/node.js +21 -0
- package/dist/react-native/metro/withStorybook.d.ts +2269 -0
- package/dist/react-native/metro/withStorybook.js +138 -0
- package/dist/react-native/preview.d.ts +6 -0
- package/dist/react-native/preview.js +20 -0
- package/dist/react-native/scripts/generate.d.ts +22 -0
- package/dist/react-native/scripts/generate.js +18 -0
- package/dist/react-native/stub.js +20 -0
- package/dist/react-native-theming/index.d.ts +175 -0
- package/dist/react-native-theming/index.js +2591 -0
- package/dist/react-native-ui/index.d.ts +130 -0
- package/dist/react-native-ui/index.js +1448 -0
- package/dist/react-native-ui-common/index.d.ts +230 -0
- package/dist/react-native-ui-common/index.js +514 -0
- package/dist/react-vite/index.d.ts +4 -0
- package/dist/react-vite/index.js +8 -0
- package/dist/react-vite/node/index.d.ts +6 -0
- package/dist/react-vite/node/index.js +20 -0
- package/dist/react-vite/preset.d.ts +6 -0
- package/dist/react-vite/preset.js +21 -0
- package/dist/router/index.d.ts +141 -0
- package/dist/router/index.js +1217 -0
- package/dist/server-errors.d.ts +2 -0
- package/dist/server-errors.js +149 -0
- package/dist/shared/open-service/index.d.ts +3 -0
- package/dist/shared/open-service/index.js +115 -0
- package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +75 -0
- package/dist/shared/open-service/toolsets/docs/public.d.ts +1296 -0
- package/dist/shared/open-service/toolsets/docs/public.js +991 -0
- package/dist/telemetry/index.d.ts +314 -0
- package/dist/telemetry/index.js +103 -0
- package/dist/test/index.d.ts +158 -0
- package/dist/test/index.js +19421 -0
- package/dist/theming/create.d.ts +15 -0
- package/dist/theming/create.js +11 -0
- package/dist/theming/index.d.ts +54 -0
- package/dist/theming/index.js +511 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +48 -0
- package/dist/viewport/index.d.ts +275 -0
- package/dist/viewport/index.js +21 -0
- package/package.json +1054 -4
- package/template/nextjs-vite/cli/.eslintrc.json +6 -0
- package/template/nextjs-vite/cli/js/Button.jsx +42 -0
- package/template/nextjs-vite/cli/js/Button.stories.js +49 -0
- package/template/nextjs-vite/cli/js/Configure.mdx +470 -0
- package/template/nextjs-vite/cli/js/Header.jsx +58 -0
- package/template/nextjs-vite/cli/js/Header.stories.js +30 -0
- package/template/nextjs-vite/cli/js/Page.jsx +68 -0
- package/template/nextjs-vite/cli/js/Page.stories.js +28 -0
- package/template/nextjs-vite/cli/ts/Button.stories.ts +54 -0
- package/template/nextjs-vite/cli/ts/Button.tsx +39 -0
- package/template/nextjs-vite/cli/ts/Configure.mdx +446 -0
- package/template/nextjs-vite/cli/ts/Header.stories.ts +34 -0
- package/template/nextjs-vite/cli/ts/Header.tsx +54 -0
- package/template/nextjs-vite/cli/ts/Page.stories.ts +33 -0
- package/template/nextjs-vite/cli/ts/Page.tsx +73 -0
- package/template/react/cli/.eslintrc.json +5 -0
- package/template/react/cli/js/Button.jsx +39 -0
- package/template/react/cli/js/Button.stories.js +49 -0
- package/template/react/cli/js/Header.jsx +56 -0
- package/template/react/cli/js/Header.stories.js +29 -0
- package/template/react/cli/js/Page.jsx +69 -0
- package/template/react/cli/js/Page.stories.js +28 -0
- package/template/react/cli/ts/Button.stories.ts +54 -0
- package/template/react/cli/ts/Button.tsx +37 -0
- package/template/react/cli/ts/Header.stories.ts +34 -0
- package/template/react/cli/ts/Header.tsx +56 -0
- package/template/react/cli/ts/Page.stories.ts +33 -0
- package/template/react/cli/ts/Page.tsx +73 -0
- package/template/react-vite/cli/.eslintrc.json +5 -0
- package/template/react-vite/cli/js/Button.jsx +39 -0
- package/template/react-vite/cli/js/Button.stories.js +49 -0
- package/template/react-vite/cli/js/Header.jsx +56 -0
- package/template/react-vite/cli/js/Header.stories.js +29 -0
- package/template/react-vite/cli/js/Page.jsx +69 -0
- package/template/react-vite/cli/js/Page.stories.js +28 -0
- package/template/react-vite/cli/ts/Button.stories.ts +54 -0
- package/template/react-vite/cli/ts/Button.tsx +37 -0
- package/template/react-vite/cli/ts/Header.stories.ts +34 -0
- package/template/react-vite/cli/ts/Header.tsx +56 -0
- package/template/react-vite/cli/ts/Page.stories.ts +33 -0
- package/template/react-vite/cli/ts/Page.tsx +73 -0
|
@@ -0,0 +1,4468 @@
|
|
|
1
|
+
import { a as __toESM, n as __esmMin, r as __exportAll } from "./globals-runtime-BdGkqNEt.js";
|
|
2
|
+
import { H as stringify, U as dedent, V as parse, W as init_esm, l as require_store2, u as require_semver, z as init_dist } from "./globals-runtime-eLPTIfX-.js";
|
|
3
|
+
import { A as create_exports, C as router_exports, D as init_routes, E as queryFromLocation, F as Tag, G as countStatusesByValue, I as USER_TAG_FILTER, J as statusValueShortName, K as createStatusStore, L as init_tags$1, M as init_test, N as test_exports, O as isReviewManagerRoute, P as BUILT_IN_FILTERS, S as init_router, W as UNIVERSAL_STATUS_STORE_OPTIONS, Y as toStatusValue, _ as init_test_provider_store, at as UniversalStore, b as init_use_universal_store_manager, c as getService, ct as init_storybook_error, f as useServiceQuery, g as createTestProviderStore, h as UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS, j as init_create, k as create, l as init_manager, m as useServiceCommand, n as theming_exports, ot as init_universal_store, q as init_status_store, st as StorybookError, t as init_theming, u as registerService, v as MockUniversalStore, w as buildArgsParam, x as useUniversalStore, y as init_mock } from "./globals-runtime-sGpNlIJ1.js";
|
|
4
|
+
import { $ as once, A as SET_WHATS_NEW_CACHE, B as STORY_PREPARED, C as SELECT_STORY, D as SET_GLOBALS, E as SET_FILTER, F as STORIES_EXPAND_ALL, G as UPDATE_GLOBALS, H as STORY_SPECIFIED, I as STORY_ARGS_UPDATED, J as core_events_exports, K as UPDATE_QUERY_PARAMS, L as STORY_CHANGED, M as SHARED_STATE_SET, N as SIDEBAR_FILTER_CHANGED, O as SET_INDEX, P as STORIES_COLLAPSE_ALL, Q as logger, R as STORY_INDEX_INVALIDATED, S as RESULT_WHATS_NEW_DATA, T as SET_CURRENT_STORY, U as TELEMETRY_ERROR, V as STORY_RENDER_PHASE_CHANGED, W as TOGGLE_WHATS_NEW_NOTIFICATIONS, X as client_logger_exports, Y as init_core_events, Z as init_client_logger, _ as OPEN_IN_EDITOR_RESPONSE, a as channels_exports, b as REQUEST_WHATS_NEW_DATA, c as init_channel_slot, d as CURRENT_STORY_WAS_SET, f as DOCS_PREPARED, g as OPEN_IN_EDITOR_REQUEST, h as NAVIGATE_URL, i as mockChannel, j as SHARED_STATE_CHANGED, k as SET_STORIES, l as setChannel, m as GLOBALS_UPDATED, n as init_components, o as init_channels, p as FORCE_REMOUNT, q as UPDATE_STORY_ARGS, r as init_mock_channel, s as getChannel, t as components_exports, u as CONFIG_ERROR, v as PRELOAD_ENTRIES, w as SET_CONFIG, x as RESET_STORY_ARGS, y as PREVIEW_KEYDOWN, z as STORY_MISSING } from "./globals-runtime-DpNYC-qi.js";
|
|
5
|
+
import { C as init_dist$1, S as init_dist$2, v as FailedIcon, w as scope, x as dist_exports } from "./globals-runtime-DtcOnYHR.js";
|
|
6
|
+
import { A as require_react_dom, O as require_jsx_runtime, S as init_main, j as require_react, k as require_client, w as stringify$1 } from "./globals-runtime-ZHrQFa3-.js";
|
|
7
|
+
import { F as init_dist$3, G as mapValues, H as init_mergeWith, I as init_toMerged, K as init_isEqual, L as toMerged, P as dequal, U as mergeWith, V as omit, X as require_memoizerific, a as throttle, c as partition, i as init_throttle, l as countBy, o as require_copy_to_clipboard, q as isEqual, t as require_browser_dtector_umd_min, z as pick } from "./globals-runtime-BvM-NY2g.js";
|
|
8
|
+
import { n as types_exports, r as Addon_TypesEnum, t as init_types } from "./globals-runtime-Rp_zjGnh.js";
|
|
9
|
+
import { h as processError, m as init_error } from "./globals-runtime-FC201B7s.js";
|
|
10
|
+
//#region src/manager-errors.ts
|
|
11
|
+
var manager_errors_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
Category: () => Category,
|
|
13
|
+
OpenServiceStaticSnapshotInvalidError: () => OpenServiceStaticSnapshotInvalidError,
|
|
14
|
+
OpenServiceStaticSnapshotLoadError: () => OpenServiceStaticSnapshotLoadError,
|
|
15
|
+
ProviderDoesNotExtendBaseProviderError: () => ProviderDoesNotExtendBaseProviderError,
|
|
16
|
+
StatusTypeIdMismatchError: () => StatusTypeIdMismatchError$1,
|
|
17
|
+
UncaughtManagerError: () => UncaughtManagerError,
|
|
18
|
+
UniversalStoreFollowerTimeoutError: () => UniversalStoreFollowerTimeoutError
|
|
19
|
+
});
|
|
20
|
+
var Category, ProviderDoesNotExtendBaseProviderError, UncaughtManagerError, StatusTypeIdMismatchError$1, UniversalStoreFollowerTimeoutError, OpenServiceStaticSnapshotLoadError, OpenServiceStaticSnapshotInvalidError;
|
|
21
|
+
function init_manager_errors() {
|
|
22
|
+
return (init_manager_errors = __esmMin((() => {
|
|
23
|
+
init_storybook_error();
|
|
24
|
+
Category = /* @__PURE__ */ function(Category) {
|
|
25
|
+
Category["MANAGER_UNCAUGHT"] = "MANAGER_UNCAUGHT";
|
|
26
|
+
Category["MANAGER_UI"] = "MANAGER_UI";
|
|
27
|
+
Category["MANAGER_API"] = "MANAGER_API";
|
|
28
|
+
Category["MANAGER_CLIENT_LOGGER"] = "MANAGER_CLIENT-LOGGER";
|
|
29
|
+
Category["MANAGER_CHANNELS"] = "MANAGER_CHANNELS";
|
|
30
|
+
Category["MANAGER_CORE_EVENTS"] = "MANAGER_CORE-EVENTS";
|
|
31
|
+
Category["MANAGER_ROUTER"] = "MANAGER_ROUTER";
|
|
32
|
+
Category["MANAGER_THEMING"] = "MANAGER_THEMING";
|
|
33
|
+
Category["MANAGER_UNIVERSAL_STORE"] = "MANAGER_UNIVERSAL-STORE";
|
|
34
|
+
Category["MANAGER_OPEN_SERVICE"] = "MANAGER_OPEN-SERVICE";
|
|
35
|
+
return Category;
|
|
36
|
+
}({});
|
|
37
|
+
ProviderDoesNotExtendBaseProviderError = class extends StorybookError {
|
|
38
|
+
constructor() {
|
|
39
|
+
super({
|
|
40
|
+
name: "ProviderDoesNotExtendBaseProviderError",
|
|
41
|
+
category: "MANAGER_UI",
|
|
42
|
+
code: 1,
|
|
43
|
+
message: `The Provider passed into Forkbook's UI is not extended from the base Provider. Please check your Provider implementation.`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
UncaughtManagerError = class extends StorybookError {
|
|
48
|
+
constructor(data) {
|
|
49
|
+
super({
|
|
50
|
+
name: "UncaughtManagerError",
|
|
51
|
+
category: "MANAGER_UNCAUGHT",
|
|
52
|
+
code: 1,
|
|
53
|
+
message: data.error.message
|
|
54
|
+
});
|
|
55
|
+
this.data = data;
|
|
56
|
+
this.stack = data.error.stack;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
StatusTypeIdMismatchError$1 = class extends StorybookError {
|
|
60
|
+
constructor(data) {
|
|
61
|
+
super({
|
|
62
|
+
name: "StatusTypeIdMismatchError",
|
|
63
|
+
category: "MANAGER_API",
|
|
64
|
+
code: 1,
|
|
65
|
+
message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(data.status, null, 2)}`
|
|
66
|
+
});
|
|
67
|
+
this.data = data;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
UniversalStoreFollowerTimeoutError = class extends StorybookError {
|
|
71
|
+
constructor(followerId) {
|
|
72
|
+
super({
|
|
73
|
+
name: "UniversalStoreFollowerTimeoutError",
|
|
74
|
+
category: "MANAGER_UNIVERSAL-STORE",
|
|
75
|
+
code: 1,
|
|
76
|
+
message: `Timed out waiting for leader state for UniversalStore follower with id: '${followerId}'. Ensure a leader with the same id exists and is reachable before creating a follower.`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
OpenServiceStaticSnapshotLoadError = class extends StorybookError {
|
|
81
|
+
constructor(data) {
|
|
82
|
+
super({
|
|
83
|
+
name: "OpenServiceStaticSnapshotLoadError",
|
|
84
|
+
category: "MANAGER_OPEN-SERVICE",
|
|
85
|
+
code: 1,
|
|
86
|
+
message: `Failed to load open-service static snapshot "${data.logicalPath}" from "${data.url}" for "${data.serviceId}.${data.queryName}".`,
|
|
87
|
+
cause: data.cause
|
|
88
|
+
});
|
|
89
|
+
this.data = data;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
OpenServiceStaticSnapshotInvalidError = class extends StorybookError {
|
|
93
|
+
constructor(data) {
|
|
94
|
+
super({
|
|
95
|
+
name: "OpenServiceStaticSnapshotInvalidError",
|
|
96
|
+
category: "MANAGER_OPEN-SERVICE",
|
|
97
|
+
code: 2,
|
|
98
|
+
message: `Open-service static snapshot "${data.logicalPath}" from "${data.url}" for "${data.serviceId}.${data.queryName}" must be a plain object.`
|
|
99
|
+
});
|
|
100
|
+
this.data = data;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
})))();
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/preview-errors.ts
|
|
107
|
+
var InvalidChannelPageError, StatusTypeIdMismatchError;
|
|
108
|
+
function init_preview_errors() {
|
|
109
|
+
return (init_preview_errors = __esmMin((() => {
|
|
110
|
+
init_storybook_error();
|
|
111
|
+
InvalidChannelPageError = class extends StorybookError {
|
|
112
|
+
constructor(data) {
|
|
113
|
+
super({
|
|
114
|
+
name: "InvalidChannelPageError",
|
|
115
|
+
category: "PREVIEW_CHANNELS",
|
|
116
|
+
code: 1,
|
|
117
|
+
message: `The postMessage channel transport needs "config.page" to be "manager" or "preview", but received "${data.page}".`
|
|
118
|
+
});
|
|
119
|
+
this.data = data;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
StatusTypeIdMismatchError = class extends StorybookError {
|
|
123
|
+
constructor(data) {
|
|
124
|
+
super({
|
|
125
|
+
name: "StatusTypeIdMismatchError",
|
|
126
|
+
category: "PREVIEW_API",
|
|
127
|
+
code: 16,
|
|
128
|
+
message: `Status has typeId "${data.status.typeId}" but was added to store with typeId "${data.typeId}". Full status: ${JSON.stringify(data.status, null, 2)}`
|
|
129
|
+
});
|
|
130
|
+
this.data = data;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
})))();
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/manager/globals/globals.ts
|
|
137
|
+
var globalsNameReferenceMap, globalPackages;
|
|
138
|
+
function init_globals() {
|
|
139
|
+
return (init_globals = __esmMin((() => {
|
|
140
|
+
globalsNameReferenceMap = {
|
|
141
|
+
react: "__REACT__",
|
|
142
|
+
"react/jsx-runtime": "__REACT_JSX_RUNTIME__",
|
|
143
|
+
"react/jsx-dev-runtime": "__REACT_JSX_DEV_RUNTIME__",
|
|
144
|
+
"react-dom": "__REACT_DOM__",
|
|
145
|
+
"react-dom/client": "__REACT_DOM_CLIENT__",
|
|
146
|
+
"@storybook/icons": "__STORYBOOK_ICONS__",
|
|
147
|
+
"@aussieljk/forkbook/manager-api": "__STORYBOOK_API__",
|
|
148
|
+
"@aussieljk/forkbook/theming": "__STORYBOOK_THEMING__",
|
|
149
|
+
"@aussieljk/forkbook/theming/create": "__STORYBOOK_THEMING_CREATE__",
|
|
150
|
+
"@aussieljk/forkbook/test": "__STORYBOOK_TEST__",
|
|
151
|
+
"@aussieljk/forkbook/internal/channels": "__STORYBOOK_CHANNELS__",
|
|
152
|
+
"@aussieljk/forkbook/internal/client-logger": "__STORYBOOK_CLIENT_LOGGER__",
|
|
153
|
+
"@aussieljk/forkbook/internal/components": "__STORYBOOK_COMPONENTS__",
|
|
154
|
+
"@aussieljk/forkbook/internal/core-events": "__STORYBOOK_CORE_EVENTS__",
|
|
155
|
+
"@aussieljk/forkbook/internal/manager-errors": "__STORYBOOK_CORE_EVENTS_MANAGER_ERRORS__",
|
|
156
|
+
"@aussieljk/forkbook/internal/router": "__STORYBOOK_ROUTER__",
|
|
157
|
+
"@aussieljk/forkbook/internal/types": "__STORYBOOK_TYPES__"
|
|
158
|
+
};
|
|
159
|
+
globalPackages = Object.keys(globalsNameReferenceMap);
|
|
160
|
+
})))();
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/manager-api/context.ts
|
|
164
|
+
var import_react$5, createContext;
|
|
165
|
+
function init_context() {
|
|
166
|
+
return (init_context = __esmMin((() => {
|
|
167
|
+
import_react$5 = require_react();
|
|
168
|
+
createContext = ({ api, state }) => (0, import_react$5.createContext)({
|
|
169
|
+
api,
|
|
170
|
+
state
|
|
171
|
+
});
|
|
172
|
+
})))();
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/manager-api/lib/merge.ts
|
|
176
|
+
var merge_default, noArrayMerge;
|
|
177
|
+
function init_merge() {
|
|
178
|
+
return (init_merge = __esmMin((() => {
|
|
179
|
+
init_client_logger();
|
|
180
|
+
init_mergeWith();
|
|
181
|
+
init_isEqual();
|
|
182
|
+
merge_default = (a, ...b) => {
|
|
183
|
+
let target = {};
|
|
184
|
+
target = mergeWith({}, a, (objValue, srcValue) => {
|
|
185
|
+
if (Array.isArray(srcValue) && Array.isArray(objValue)) {
|
|
186
|
+
srcValue.forEach((s) => {
|
|
187
|
+
if (!objValue.find((o) => o === s || isEqual(o, s))) objValue.push(s);
|
|
188
|
+
});
|
|
189
|
+
return objValue;
|
|
190
|
+
}
|
|
191
|
+
if (Array.isArray(objValue)) {
|
|
192
|
+
logger.log(["the types mismatch, picking", objValue]);
|
|
193
|
+
return objValue;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
for (const obj of b) target = mergeWith(target, obj, (objValue, srcValue) => {
|
|
197
|
+
if (Array.isArray(srcValue) && Array.isArray(objValue)) {
|
|
198
|
+
srcValue.forEach((s) => {
|
|
199
|
+
if (!objValue.find((o) => o === s || isEqual(o, s))) objValue.push(s);
|
|
200
|
+
});
|
|
201
|
+
return objValue;
|
|
202
|
+
}
|
|
203
|
+
if (Array.isArray(objValue)) {
|
|
204
|
+
logger.log(["the types mismatch, picking", objValue]);
|
|
205
|
+
return objValue;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return target;
|
|
209
|
+
};
|
|
210
|
+
noArrayMerge = (a, ...b) => {
|
|
211
|
+
let target = {};
|
|
212
|
+
target = mergeWith({}, a, (objValue, srcValue) => {
|
|
213
|
+
if (Array.isArray(srcValue)) return srcValue;
|
|
214
|
+
});
|
|
215
|
+
for (const obj of b) target = mergeWith(target, obj, (objValue, srcValue) => {
|
|
216
|
+
if (Array.isArray(srcValue)) return srcValue;
|
|
217
|
+
});
|
|
218
|
+
return target;
|
|
219
|
+
};
|
|
220
|
+
})))();
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/manager-api/initial-state.ts
|
|
224
|
+
var main;
|
|
225
|
+
function init_initial_state() {
|
|
226
|
+
return (init_initial_state = __esmMin((() => {
|
|
227
|
+
init_merge();
|
|
228
|
+
main = (...additions) => additions.reduce((acc, item) => merge_default(acc, item), {});
|
|
229
|
+
})))();
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/manager-api/lib/addons.ts
|
|
233
|
+
function getAddonsStore() {
|
|
234
|
+
if (!globalThis[KEY]) globalThis[KEY] = new AddonStore();
|
|
235
|
+
return globalThis[KEY];
|
|
236
|
+
}
|
|
237
|
+
var AddonStore, KEY, addons$1;
|
|
238
|
+
function init_addons() {
|
|
239
|
+
return (init_addons = __esmMin((() => {
|
|
240
|
+
init_client_logger();
|
|
241
|
+
init_core_events();
|
|
242
|
+
init_types();
|
|
243
|
+
init_channel_slot();
|
|
244
|
+
init_mock_channel();
|
|
245
|
+
AddonStore = class {
|
|
246
|
+
constructor() {
|
|
247
|
+
this.loaders = {};
|
|
248
|
+
this.elements = {};
|
|
249
|
+
this.config = {};
|
|
250
|
+
this.getChannel = () => {
|
|
251
|
+
if (this.channel) return this.channel;
|
|
252
|
+
const installed = getChannel();
|
|
253
|
+
if (installed) {
|
|
254
|
+
this.channel = installed;
|
|
255
|
+
this.resolve();
|
|
256
|
+
return this.channel;
|
|
257
|
+
}
|
|
258
|
+
return mockChannel();
|
|
259
|
+
};
|
|
260
|
+
this.ready = () => this.promise;
|
|
261
|
+
this.hasChannel = () => !!this.channel || !!getChannel();
|
|
262
|
+
this.setChannel = (channel) => {
|
|
263
|
+
this.channel = channel;
|
|
264
|
+
setChannel(channel);
|
|
265
|
+
this.resolve();
|
|
266
|
+
};
|
|
267
|
+
this.setConfig = (value) => {
|
|
268
|
+
Object.assign(this.config, value);
|
|
269
|
+
if (this.hasChannel()) this.getChannel().emit(SET_CONFIG, this.config);
|
|
270
|
+
else this.ready().then((channel) => {
|
|
271
|
+
channel.emit(SET_CONFIG, this.config);
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
this.getConfig = () => this.config;
|
|
275
|
+
this.register = (id, callback) => {
|
|
276
|
+
if (this.loaders[id]) logger.warn(`${id} was loaded twice, this could have bad side-effects`);
|
|
277
|
+
this.loaders[id] = callback;
|
|
278
|
+
};
|
|
279
|
+
this.loadAddons = (api) => {
|
|
280
|
+
Object.values(this.loaders).forEach((value) => value(api));
|
|
281
|
+
};
|
|
282
|
+
this.promise = new Promise((res) => {
|
|
283
|
+
this.resolve = () => res(this.getChannel());
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
getElements(type) {
|
|
287
|
+
if (!this.elements[type]) this.elements[type] = {};
|
|
288
|
+
return this.elements[type];
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Adds an addon to the addon store.
|
|
292
|
+
*
|
|
293
|
+
* @param {string} id - The id of the addon.
|
|
294
|
+
* @param {Addon_Type} addon - The addon to add.
|
|
295
|
+
* @returns {void}
|
|
296
|
+
*/
|
|
297
|
+
add(id, addon) {
|
|
298
|
+
const { type } = addon;
|
|
299
|
+
const collection = this.getElements(type);
|
|
300
|
+
collection[id] = {
|
|
301
|
+
...addon,
|
|
302
|
+
id
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
experimental_getRegisteredAddons(type) {
|
|
306
|
+
return type ? Object.keys(this.getElements(type)) : Object.keys(this.loaders);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
KEY = "__STORYBOOK_ADDONS_MANAGER";
|
|
310
|
+
addons$1 = getAddonsStore();
|
|
311
|
+
})))();
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/manager-api/modules/addons.ts
|
|
315
|
+
var addons_exports = /* @__PURE__ */ __exportAll({
|
|
316
|
+
ensurePanel: () => ensurePanel,
|
|
317
|
+
init: () => init$13
|
|
318
|
+
});
|
|
319
|
+
function ensurePanel(panels, selectedPanel, currentPanel) {
|
|
320
|
+
const keys = Object.keys(panels ?? {});
|
|
321
|
+
if (keys.indexOf(selectedPanel) >= 0) return selectedPanel;
|
|
322
|
+
if (keys.length) return keys[0];
|
|
323
|
+
return currentPanel;
|
|
324
|
+
}
|
|
325
|
+
var init$13;
|
|
326
|
+
function init_addons$1() {
|
|
327
|
+
return (init_addons$1 = __esmMin((() => {
|
|
328
|
+
init_client_logger();
|
|
329
|
+
init_types();
|
|
330
|
+
init$13 = ({ provider, store, fullAPI }) => {
|
|
331
|
+
const api = {
|
|
332
|
+
getElements: (type) => provider.getElements(type),
|
|
333
|
+
clearStatuses: () => {
|
|
334
|
+
const testProviders = api.getElements("test-provider");
|
|
335
|
+
Object.values(testProviders).forEach((testProvider) => {
|
|
336
|
+
try {
|
|
337
|
+
testProvider.clear?.();
|
|
338
|
+
} catch (e) {
|
|
339
|
+
try {
|
|
340
|
+
logger.warn(`Failed to clear test provider "${testProvider.id}":`, e);
|
|
341
|
+
} catch {}
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
getSelectedPanel: () => {
|
|
346
|
+
const { selectedPanel } = store.getState();
|
|
347
|
+
return ensurePanel(api.getElements("panel"), selectedPanel, selectedPanel);
|
|
348
|
+
},
|
|
349
|
+
setSelectedPanel: (panelName) => {
|
|
350
|
+
store.setState({ selectedPanel: panelName }, { persistence: "session" });
|
|
351
|
+
},
|
|
352
|
+
setAddonState(addonId, newStateOrMerger, options) {
|
|
353
|
+
const merger = typeof newStateOrMerger === "function" ? newStateOrMerger : () => newStateOrMerger;
|
|
354
|
+
return store.setState((s) => ({
|
|
355
|
+
...s,
|
|
356
|
+
addons: {
|
|
357
|
+
...s.addons,
|
|
358
|
+
[addonId]: merger(s.addons[addonId])
|
|
359
|
+
}
|
|
360
|
+
}), options).then(() => api.getAddonState(addonId));
|
|
361
|
+
},
|
|
362
|
+
getAddonState: (addonId) => {
|
|
363
|
+
return store.getState().addons[addonId] || globalThis?.FORKBOOK_ADDON_STATE[addonId];
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return {
|
|
367
|
+
api,
|
|
368
|
+
state: {
|
|
369
|
+
selectedPanel: ensurePanel(api.getElements("panel"), store.getState().selectedPanel),
|
|
370
|
+
addons: {}
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
})))();
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/manager-api/modules/channel.ts
|
|
378
|
+
var channel_exports = /* @__PURE__ */ __exportAll({ init: () => init$12 });
|
|
379
|
+
var init$12;
|
|
380
|
+
function init_channel() {
|
|
381
|
+
return (init_channel = __esmMin((() => {
|
|
382
|
+
init$12 = ({ provider }) => {
|
|
383
|
+
return {
|
|
384
|
+
api: {
|
|
385
|
+
getChannel: () => provider.channel,
|
|
386
|
+
on: (type, handler) => {
|
|
387
|
+
provider.channel?.on(type, handler);
|
|
388
|
+
return () => provider.channel?.off(type, handler);
|
|
389
|
+
},
|
|
390
|
+
off: (type, handler) => provider.channel?.off(type, handler),
|
|
391
|
+
once: (type, handler) => provider.channel?.once(type, handler),
|
|
392
|
+
emit: (type, data, ...args) => {
|
|
393
|
+
if (data?.options?.target && data.options.target !== "storybook-preview-iframe" && !data.options.target.startsWith("storybook-ref-")) data.options.target = data.options.target !== "storybook_internal" ? `storybook-ref-${data.options.target}` : "storybook-preview-iframe";
|
|
394
|
+
provider.channel?.emit(type, data, ...args);
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
state: {}
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
})))();
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/csf/csf-utils.ts
|
|
404
|
+
var sanitize, sanitizeSafe, toId;
|
|
405
|
+
function init_csf_utils() {
|
|
406
|
+
return (init_csf_utils = __esmMin((() => {
|
|
407
|
+
sanitize = (string) => {
|
|
408
|
+
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
409
|
+
};
|
|
410
|
+
sanitizeSafe = (string, part) => {
|
|
411
|
+
const sanitized = sanitize(string);
|
|
412
|
+
if (sanitized === "") throw new Error(`Invalid ${part} '${string}', must include alphanumeric characters`);
|
|
413
|
+
return sanitized;
|
|
414
|
+
};
|
|
415
|
+
toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
|
|
416
|
+
})))();
|
|
417
|
+
}
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/preview-api/modules/preview-web/render/animation-utils.ts
|
|
420
|
+
function isTestEnvironment() {
|
|
421
|
+
try {
|
|
422
|
+
return !!globalThis.__vitest_browser__ || !!globalThis.window?.navigator?.userAgent?.match(/StorybookTestRunner/);
|
|
423
|
+
} catch {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function init_animation_utils() {
|
|
428
|
+
return (init_animation_utils = __esmMin((() => {})))();
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/instrumenter/EVENTS.ts
|
|
432
|
+
var EVENTS;
|
|
433
|
+
function init_EVENTS() {
|
|
434
|
+
return (init_EVENTS = __esmMin((() => {
|
|
435
|
+
EVENTS = {
|
|
436
|
+
CALL: "@aussieljk/forkbook/instrumenter/call",
|
|
437
|
+
SYNC: "@aussieljk/forkbook/instrumenter/sync",
|
|
438
|
+
START: "@aussieljk/forkbook/instrumenter/start",
|
|
439
|
+
BACK: "@aussieljk/forkbook/instrumenter/back",
|
|
440
|
+
GOTO: "@aussieljk/forkbook/instrumenter/goto",
|
|
441
|
+
NEXT: "@aussieljk/forkbook/instrumenter/next",
|
|
442
|
+
END: "@aussieljk/forkbook/instrumenter/end"
|
|
443
|
+
};
|
|
444
|
+
})))();
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/instrumenter/preview-api.ts
|
|
448
|
+
var addons;
|
|
449
|
+
function init_preview_api() {
|
|
450
|
+
return (init_preview_api = __esmMin((() => {
|
|
451
|
+
addons = globalThis.__STORYBOOK_ADDONS_PREVIEW;
|
|
452
|
+
})))();
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/instrumenter/instrumenter.ts
|
|
456
|
+
/**
|
|
457
|
+
* Instruments an object or module by traversing its properties, patching any functions (methods) to
|
|
458
|
+
* enable debugging. Patched functions will emit a `call` event when invoked. When intercept = true,
|
|
459
|
+
* patched functions will return a Promise when the debugger stops before this function. As such,
|
|
460
|
+
* "interceptable" functions will have to be `await`-ed.
|
|
461
|
+
*/
|
|
462
|
+
function instrument(obj, options = {}) {
|
|
463
|
+
try {
|
|
464
|
+
let forceInstrument = false;
|
|
465
|
+
let skipInstrument = false;
|
|
466
|
+
if (scope.window?.location?.search?.includes("instrument=true")) forceInstrument = true;
|
|
467
|
+
else if (scope.window?.location?.search?.includes("instrument=false")) skipInstrument = true;
|
|
468
|
+
if (scope.window?.parent === scope.window && !forceInstrument || skipInstrument) return obj;
|
|
469
|
+
if (scope.window && !scope.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) scope.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__ = new Instrumenter();
|
|
470
|
+
return (scope.window?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__).instrument(obj, options);
|
|
471
|
+
} catch (e) {
|
|
472
|
+
once.warn(e);
|
|
473
|
+
return obj;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function getPropertyDescriptor(obj, propName) {
|
|
477
|
+
let target = obj;
|
|
478
|
+
while (target != null) {
|
|
479
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, propName);
|
|
480
|
+
if (descriptor) return descriptor;
|
|
481
|
+
target = Object.getPrototypeOf(target);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function isClass(obj) {
|
|
485
|
+
if (typeof obj !== "function") return false;
|
|
486
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, "prototype");
|
|
487
|
+
if (!descriptor) return false;
|
|
488
|
+
return !descriptor.writable;
|
|
489
|
+
}
|
|
490
|
+
var alreadyCompletedException, isObject, isModule, isInstrumentable, construct, getInitialState, getRetainedState, Instrumenter;
|
|
491
|
+
function init_instrumenter() {
|
|
492
|
+
return (init_instrumenter = __esmMin((() => {
|
|
493
|
+
init_client_logger();
|
|
494
|
+
init_core_events();
|
|
495
|
+
init_dist$1();
|
|
496
|
+
init_error();
|
|
497
|
+
init_EVENTS();
|
|
498
|
+
init_preview_api();
|
|
499
|
+
alreadyCompletedException = /* @__PURE__ */ new Error(`This function ran after the play function completed. Did you forget to \`await\` it?`);
|
|
500
|
+
isObject = (o) => Object.prototype.toString.call(o) === "[object Object]";
|
|
501
|
+
isModule = (o) => Object.prototype.toString.call(o) === "[object Module]";
|
|
502
|
+
isInstrumentable = (o) => {
|
|
503
|
+
if (!isObject(o) && !isModule(o)) return false;
|
|
504
|
+
if (o.constructor === void 0) return true;
|
|
505
|
+
const proto = o.constructor.prototype;
|
|
506
|
+
if (!isObject(proto)) return false;
|
|
507
|
+
return true;
|
|
508
|
+
};
|
|
509
|
+
construct = (obj) => {
|
|
510
|
+
try {
|
|
511
|
+
return new obj.constructor();
|
|
512
|
+
} catch {
|
|
513
|
+
return {};
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
getInitialState = () => ({
|
|
517
|
+
renderPhase: "preparing",
|
|
518
|
+
isDebugging: false,
|
|
519
|
+
isPlaying: false,
|
|
520
|
+
isLocked: false,
|
|
521
|
+
cursor: 0,
|
|
522
|
+
calls: [],
|
|
523
|
+
shadowCalls: [],
|
|
524
|
+
callRefsByResult: /* @__PURE__ */ new Map(),
|
|
525
|
+
chainedCallIds: /* @__PURE__ */ new Set(),
|
|
526
|
+
ancestors: [],
|
|
527
|
+
playUntil: void 0,
|
|
528
|
+
resolvers: {},
|
|
529
|
+
syncTimeout: void 0
|
|
530
|
+
});
|
|
531
|
+
getRetainedState = (state, isDebugging = false) => {
|
|
532
|
+
const calls = (isDebugging ? state.shadowCalls : state.calls).filter((call) => call.retain);
|
|
533
|
+
if (!calls.length) return;
|
|
534
|
+
const callRefsByResult = new Map(Array.from(state.callRefsByResult.entries()).filter(([, ref]) => ref.retain));
|
|
535
|
+
return {
|
|
536
|
+
cursor: calls.length,
|
|
537
|
+
calls,
|
|
538
|
+
callRefsByResult
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
Instrumenter = class {
|
|
542
|
+
constructor() {
|
|
543
|
+
this.detached = false;
|
|
544
|
+
this.initialized = false;
|
|
545
|
+
this.state = {};
|
|
546
|
+
this.loadParentWindowState = () => {
|
|
547
|
+
try {
|
|
548
|
+
this.state = scope.window?.parent?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ || {};
|
|
549
|
+
} catch {
|
|
550
|
+
this.detached = true;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
this.updateParentWindowState = () => {
|
|
554
|
+
try {
|
|
555
|
+
scope.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
|
|
556
|
+
} catch {
|
|
557
|
+
this.detached = true;
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
this.loadParentWindowState();
|
|
561
|
+
const resetState = ({ storyId, renderPhase, isPlaying = true, isDebugging = false }) => {
|
|
562
|
+
const state = this.getState(storyId);
|
|
563
|
+
this.setState(storyId, {
|
|
564
|
+
...getInitialState(),
|
|
565
|
+
...getRetainedState(state, isDebugging),
|
|
566
|
+
renderPhase: renderPhase || state.renderPhase,
|
|
567
|
+
shadowCalls: isDebugging ? state.shadowCalls : [],
|
|
568
|
+
chainedCallIds: isDebugging ? state.chainedCallIds : /* @__PURE__ */ new Set(),
|
|
569
|
+
playUntil: isDebugging ? state.playUntil : void 0,
|
|
570
|
+
isPlaying,
|
|
571
|
+
isDebugging
|
|
572
|
+
});
|
|
573
|
+
this.sync(storyId);
|
|
574
|
+
};
|
|
575
|
+
const start = (channel) => ({ storyId, playUntil }) => {
|
|
576
|
+
if (!this.getState(storyId).isDebugging) this.setState(storyId, ({ calls }) => ({
|
|
577
|
+
calls: [],
|
|
578
|
+
shadowCalls: calls.map((call) => ({
|
|
579
|
+
...call,
|
|
580
|
+
status: "waiting"
|
|
581
|
+
})),
|
|
582
|
+
isDebugging: true
|
|
583
|
+
}));
|
|
584
|
+
const log = this.getLog(storyId);
|
|
585
|
+
this.setState(storyId, ({ shadowCalls }) => {
|
|
586
|
+
if (playUntil || !log.length) return { playUntil };
|
|
587
|
+
const firstRowIndex = shadowCalls.findIndex((call) => call.id === log[0].callId);
|
|
588
|
+
return { playUntil: shadowCalls.slice(0, firstRowIndex).filter((call) => call.interceptable && !call.ancestors?.length).slice(-1)[0]?.id };
|
|
589
|
+
});
|
|
590
|
+
channel.emit(FORCE_REMOUNT, {
|
|
591
|
+
storyId,
|
|
592
|
+
isDebugging: true
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
const back = (channel) => ({ storyId }) => {
|
|
596
|
+
const log = this.getLog(storyId).filter((call) => !call.ancestors?.length);
|
|
597
|
+
const last = log.reduceRight((res, item, index) => {
|
|
598
|
+
if (res >= 0 || item.status === "waiting") return res;
|
|
599
|
+
return index;
|
|
600
|
+
}, -1);
|
|
601
|
+
start(channel)({
|
|
602
|
+
storyId,
|
|
603
|
+
playUntil: log[last - 1]?.callId
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
const goto = (channel) => ({ storyId, callId }) => {
|
|
607
|
+
const { calls, shadowCalls, resolvers } = this.getState(storyId);
|
|
608
|
+
const call = calls.find(({ id }) => id === callId);
|
|
609
|
+
const shadowCall = shadowCalls.find(({ id }) => id === callId);
|
|
610
|
+
if (!call && shadowCall && Object.values(resolvers).length > 0) {
|
|
611
|
+
const nextId = this.getLog(storyId).find((c) => c.status === "waiting")?.callId;
|
|
612
|
+
if (shadowCall.id !== nextId) this.setState(storyId, { playUntil: shadowCall.id });
|
|
613
|
+
Object.values(resolvers).forEach((resolve) => resolve());
|
|
614
|
+
} else start(channel)({
|
|
615
|
+
storyId,
|
|
616
|
+
playUntil: callId
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
const next = (channel) => ({ storyId }) => {
|
|
620
|
+
const { resolvers } = this.getState(storyId);
|
|
621
|
+
if (Object.values(resolvers).length > 0) Object.values(resolvers).forEach((resolve) => resolve());
|
|
622
|
+
else {
|
|
623
|
+
const nextId = this.getLog(storyId).find((c) => c.status === "waiting")?.callId;
|
|
624
|
+
if (nextId) start(channel)({
|
|
625
|
+
storyId,
|
|
626
|
+
playUntil: nextId
|
|
627
|
+
});
|
|
628
|
+
else end({ storyId });
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
const end = ({ storyId }) => {
|
|
632
|
+
this.setState(storyId, {
|
|
633
|
+
playUntil: void 0,
|
|
634
|
+
isDebugging: false
|
|
635
|
+
});
|
|
636
|
+
Object.values(this.getState(storyId).resolvers).forEach((resolve) => resolve());
|
|
637
|
+
};
|
|
638
|
+
const renderPhaseChanged = ({ storyId, newPhase }) => {
|
|
639
|
+
const { isDebugging } = this.getState(storyId);
|
|
640
|
+
if (newPhase === "preparing" && isDebugging) return resetState({
|
|
641
|
+
storyId,
|
|
642
|
+
renderPhase: newPhase,
|
|
643
|
+
isDebugging
|
|
644
|
+
});
|
|
645
|
+
else if (newPhase === "playing") return resetState({
|
|
646
|
+
storyId,
|
|
647
|
+
renderPhase: newPhase,
|
|
648
|
+
isDebugging
|
|
649
|
+
});
|
|
650
|
+
if (newPhase === "played") this.setState(storyId, {
|
|
651
|
+
renderPhase: newPhase,
|
|
652
|
+
isLocked: false,
|
|
653
|
+
isPlaying: false,
|
|
654
|
+
isDebugging: false
|
|
655
|
+
});
|
|
656
|
+
else if (newPhase === "errored") this.setState(storyId, {
|
|
657
|
+
renderPhase: newPhase,
|
|
658
|
+
isLocked: false,
|
|
659
|
+
isPlaying: false
|
|
660
|
+
});
|
|
661
|
+
else if (newPhase === "aborted") this.setState(storyId, {
|
|
662
|
+
renderPhase: newPhase,
|
|
663
|
+
isLocked: true,
|
|
664
|
+
isPlaying: false
|
|
665
|
+
});
|
|
666
|
+
else this.setState(storyId, { renderPhase: newPhase });
|
|
667
|
+
this.sync(storyId);
|
|
668
|
+
};
|
|
669
|
+
if (addons) addons.ready().then(() => {
|
|
670
|
+
this.channel = addons.getChannel();
|
|
671
|
+
this.channel.on(FORCE_REMOUNT, resetState);
|
|
672
|
+
this.channel.on(STORY_RENDER_PHASE_CHANGED, renderPhaseChanged);
|
|
673
|
+
this.channel.on(SET_CURRENT_STORY, () => {
|
|
674
|
+
if (this.initialized) this.cleanup();
|
|
675
|
+
else this.initialized = true;
|
|
676
|
+
});
|
|
677
|
+
this.channel.on(EVENTS.START, start(this.channel));
|
|
678
|
+
this.channel.on(EVENTS.BACK, back(this.channel));
|
|
679
|
+
this.channel.on(EVENTS.GOTO, goto(this.channel));
|
|
680
|
+
this.channel.on(EVENTS.NEXT, next(this.channel));
|
|
681
|
+
this.channel.on(EVENTS.END, end);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
getState(storyId) {
|
|
685
|
+
return this.state[storyId] || getInitialState();
|
|
686
|
+
}
|
|
687
|
+
setState(storyId, update) {
|
|
688
|
+
if (storyId) {
|
|
689
|
+
const state = this.getState(storyId);
|
|
690
|
+
const patch = typeof update === "function" ? update(state) : update;
|
|
691
|
+
this.state = {
|
|
692
|
+
...this.state,
|
|
693
|
+
[storyId]: {
|
|
694
|
+
...state,
|
|
695
|
+
...patch
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
this.updateParentWindowState();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
cleanup() {
|
|
702
|
+
this.state = Object.entries(this.state).reduce((acc, [storyId, state]) => {
|
|
703
|
+
const retainedState = getRetainedState(state);
|
|
704
|
+
if (!retainedState) return acc;
|
|
705
|
+
acc[storyId] = Object.assign(getInitialState(), retainedState);
|
|
706
|
+
return acc;
|
|
707
|
+
}, {});
|
|
708
|
+
const payload = {
|
|
709
|
+
controlStates: {
|
|
710
|
+
detached: this.detached,
|
|
711
|
+
start: false,
|
|
712
|
+
back: false,
|
|
713
|
+
goto: false,
|
|
714
|
+
next: false,
|
|
715
|
+
end: false
|
|
716
|
+
},
|
|
717
|
+
logItems: []
|
|
718
|
+
};
|
|
719
|
+
this.channel?.emit(EVENTS.SYNC, payload);
|
|
720
|
+
this.updateParentWindowState();
|
|
721
|
+
}
|
|
722
|
+
getLog(storyId) {
|
|
723
|
+
const { calls, shadowCalls } = this.getState(storyId);
|
|
724
|
+
const merged = [...shadowCalls];
|
|
725
|
+
calls.forEach((call, index) => {
|
|
726
|
+
merged[index] = call;
|
|
727
|
+
});
|
|
728
|
+
const seen = /* @__PURE__ */ new Set();
|
|
729
|
+
return merged.reduceRight((acc, call) => {
|
|
730
|
+
call.args.forEach((arg) => {
|
|
731
|
+
if (arg?.__callId__) seen.add(arg.__callId__);
|
|
732
|
+
});
|
|
733
|
+
call.path.forEach((node) => {
|
|
734
|
+
if (node.__callId__) seen.add(node.__callId__);
|
|
735
|
+
});
|
|
736
|
+
if ((call.interceptable || call.exception) && !seen.has(call.id)) {
|
|
737
|
+
acc.unshift({
|
|
738
|
+
callId: call.id,
|
|
739
|
+
status: call.status,
|
|
740
|
+
ancestors: call.ancestors
|
|
741
|
+
});
|
|
742
|
+
seen.add(call.id);
|
|
743
|
+
}
|
|
744
|
+
return acc;
|
|
745
|
+
}, []);
|
|
746
|
+
}
|
|
747
|
+
instrument(obj, options, depth = 0) {
|
|
748
|
+
if (!isInstrumentable(obj)) return obj;
|
|
749
|
+
const { mutate = false, path = [] } = options;
|
|
750
|
+
const keys = options.getKeys ? options.getKeys(obj, depth) : Object.keys(obj);
|
|
751
|
+
depth += 1;
|
|
752
|
+
return keys.reduce((acc, key) => {
|
|
753
|
+
const descriptor = getPropertyDescriptor(obj, key);
|
|
754
|
+
if (typeof descriptor?.get === "function") {
|
|
755
|
+
if (descriptor.configurable) {
|
|
756
|
+
const getter = () => descriptor?.get?.bind(obj)?.();
|
|
757
|
+
Object.defineProperty(acc, key, { get: () => {
|
|
758
|
+
return this.instrument(getter(), {
|
|
759
|
+
...options,
|
|
760
|
+
path: path.concat(key)
|
|
761
|
+
}, depth);
|
|
762
|
+
} });
|
|
763
|
+
}
|
|
764
|
+
return acc;
|
|
765
|
+
}
|
|
766
|
+
const value = obj[key];
|
|
767
|
+
if (typeof value !== "function") {
|
|
768
|
+
acc[key] = this.instrument(value, {
|
|
769
|
+
...options,
|
|
770
|
+
path: path.concat(key)
|
|
771
|
+
}, depth);
|
|
772
|
+
return acc;
|
|
773
|
+
}
|
|
774
|
+
if ("__originalFn__" in value && typeof value.__originalFn__ === "function") {
|
|
775
|
+
acc[key] = value;
|
|
776
|
+
return acc;
|
|
777
|
+
}
|
|
778
|
+
acc[key] = (...args) => this.track(key, value, obj, args, options);
|
|
779
|
+
acc[key].__originalFn__ = value;
|
|
780
|
+
Object.defineProperty(acc[key], "name", {
|
|
781
|
+
value: key,
|
|
782
|
+
writable: false
|
|
783
|
+
});
|
|
784
|
+
if (Object.keys(value).length > 0) Object.assign(acc[key], this.instrument({ ...value }, {
|
|
785
|
+
...options,
|
|
786
|
+
path: path.concat(key)
|
|
787
|
+
}, depth));
|
|
788
|
+
return acc;
|
|
789
|
+
}, mutate ? obj : construct(obj));
|
|
790
|
+
}
|
|
791
|
+
track(method, fn, object, args, options) {
|
|
792
|
+
const storyId = args?.[0]?.__storyId__ || scope.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId;
|
|
793
|
+
const { cursor, ancestors } = this.getState(storyId);
|
|
794
|
+
this.setState(storyId, { cursor: cursor + 1 });
|
|
795
|
+
const id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`;
|
|
796
|
+
const { path = [], intercept = false, retain = false } = options;
|
|
797
|
+
const interceptable = typeof intercept === "function" ? intercept(method, path) : intercept;
|
|
798
|
+
const call = {
|
|
799
|
+
id,
|
|
800
|
+
cursor,
|
|
801
|
+
storyId,
|
|
802
|
+
ancestors,
|
|
803
|
+
path,
|
|
804
|
+
method,
|
|
805
|
+
args,
|
|
806
|
+
interceptable,
|
|
807
|
+
retain
|
|
808
|
+
};
|
|
809
|
+
const result = (interceptable && !ancestors.length ? this.intercept : this.invoke).call(this, fn, object, call, options);
|
|
810
|
+
return this.instrument(result, {
|
|
811
|
+
...options,
|
|
812
|
+
mutate: true,
|
|
813
|
+
path: [{ __callId__: call.id }]
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
intercept(fn, object, call, options) {
|
|
817
|
+
const { chainedCallIds, isDebugging, playUntil } = this.getState(call.storyId);
|
|
818
|
+
const isChainedUpon = chainedCallIds.has(call.id);
|
|
819
|
+
if (!isDebugging || isChainedUpon || playUntil) {
|
|
820
|
+
if (playUntil === call.id) this.setState(call.storyId, { playUntil: void 0 });
|
|
821
|
+
return this.invoke(fn, object, call, options);
|
|
822
|
+
}
|
|
823
|
+
return new Promise((resolve) => {
|
|
824
|
+
this.setState(call.storyId, ({ resolvers }) => ({
|
|
825
|
+
isLocked: false,
|
|
826
|
+
resolvers: {
|
|
827
|
+
...resolvers,
|
|
828
|
+
[call.id]: resolve
|
|
829
|
+
}
|
|
830
|
+
}));
|
|
831
|
+
}).then(() => {
|
|
832
|
+
this.setState(call.storyId, (state) => {
|
|
833
|
+
const { [call.id]: _, ...resolvers } = state.resolvers;
|
|
834
|
+
return {
|
|
835
|
+
isLocked: true,
|
|
836
|
+
resolvers
|
|
837
|
+
};
|
|
838
|
+
});
|
|
839
|
+
return this.invoke(fn, object, call, options);
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
invoke(fn, object, call, options) {
|
|
843
|
+
const { callRefsByResult, renderPhase } = this.getState(call.storyId);
|
|
844
|
+
const maximumDepth = 25;
|
|
845
|
+
const serializeValues = (value, depth, seen) => {
|
|
846
|
+
if (seen.includes(value)) return "[Circular]";
|
|
847
|
+
seen = [...seen, value];
|
|
848
|
+
if (depth > maximumDepth) return "...";
|
|
849
|
+
if (callRefsByResult.has(value)) return callRefsByResult.get(value);
|
|
850
|
+
if (value instanceof Array) return value.map((it) => serializeValues(it, ++depth, seen));
|
|
851
|
+
if (value instanceof Date) return { __date__: { value: value.toISOString() } };
|
|
852
|
+
if (value instanceof Error) {
|
|
853
|
+
const { name, message, stack } = value;
|
|
854
|
+
return { __error__: {
|
|
855
|
+
name,
|
|
856
|
+
message,
|
|
857
|
+
stack
|
|
858
|
+
} };
|
|
859
|
+
}
|
|
860
|
+
if (value instanceof RegExp) {
|
|
861
|
+
const { flags, source } = value;
|
|
862
|
+
return { __regexp__: {
|
|
863
|
+
flags,
|
|
864
|
+
source
|
|
865
|
+
} };
|
|
866
|
+
}
|
|
867
|
+
if (value instanceof scope.window?.HTMLElement) {
|
|
868
|
+
const { prefix, localName, id, classList, innerText } = value;
|
|
869
|
+
return { __element__: {
|
|
870
|
+
prefix,
|
|
871
|
+
localName,
|
|
872
|
+
id,
|
|
873
|
+
classNames: Array.from(classList),
|
|
874
|
+
innerText
|
|
875
|
+
} };
|
|
876
|
+
}
|
|
877
|
+
if (typeof value === "function") return { __function__: { name: "getMockName" in value ? value.getMockName() : value.name } };
|
|
878
|
+
if (typeof value === "symbol") return { __symbol__: { description: value.description } };
|
|
879
|
+
if (typeof value === "object" && value?.constructor?.name && value?.constructor?.name !== "Object") return { __class__: { name: value.constructor.name } };
|
|
880
|
+
if (Object.prototype.toString.call(value) === "[object Object]") return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, serializeValues(val, ++depth, seen)]));
|
|
881
|
+
return value;
|
|
882
|
+
};
|
|
883
|
+
const info = {
|
|
884
|
+
...call,
|
|
885
|
+
args: call.args.map((arg) => serializeValues(arg, 0, []))
|
|
886
|
+
};
|
|
887
|
+
call.path.forEach((ref) => {
|
|
888
|
+
if (ref?.__callId__) this.setState(call.storyId, ({ chainedCallIds }) => ({ chainedCallIds: new Set(Array.from(chainedCallIds).concat(ref.__callId__)) }));
|
|
889
|
+
});
|
|
890
|
+
const handleException = (e) => {
|
|
891
|
+
if (e instanceof Error) {
|
|
892
|
+
const { name, message, stack, callId = call.id } = e;
|
|
893
|
+
const { showDiff = void 0, diff = void 0, actual = void 0, expected = void 0 } = e.name === "AssertionError" ? processError(e) : e;
|
|
894
|
+
const exception = {
|
|
895
|
+
name,
|
|
896
|
+
message,
|
|
897
|
+
stack,
|
|
898
|
+
callId,
|
|
899
|
+
showDiff,
|
|
900
|
+
diff,
|
|
901
|
+
actual,
|
|
902
|
+
expected
|
|
903
|
+
};
|
|
904
|
+
this.update({
|
|
905
|
+
...info,
|
|
906
|
+
status: "error",
|
|
907
|
+
exception
|
|
908
|
+
});
|
|
909
|
+
this.setState(call.storyId, (state) => ({ callRefsByResult: new Map([...Array.from(state.callRefsByResult.entries()), [e, {
|
|
910
|
+
__callId__: call.id,
|
|
911
|
+
retain: call.retain
|
|
912
|
+
}]]) }));
|
|
913
|
+
if (call.ancestors?.length) {
|
|
914
|
+
if (!Object.prototype.hasOwnProperty.call(e, "callId")) Object.defineProperty(e, "callId", { value: call.id });
|
|
915
|
+
throw e;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
throw e;
|
|
919
|
+
};
|
|
920
|
+
try {
|
|
921
|
+
if (renderPhase === "played" && !call.retain) throw alreadyCompletedException;
|
|
922
|
+
const finalArgs = (options.getArgs ? options.getArgs(call, this.getState(call.storyId)) : call.args).map((arg) => {
|
|
923
|
+
if (typeof arg !== "function" || isClass(arg) || Object.keys(arg).length) return arg;
|
|
924
|
+
return (...args) => {
|
|
925
|
+
const { cursor, ancestors } = this.getState(call.storyId);
|
|
926
|
+
this.setState(call.storyId, {
|
|
927
|
+
cursor: 0,
|
|
928
|
+
ancestors: [...ancestors, call.id]
|
|
929
|
+
});
|
|
930
|
+
const restore = () => this.setState(call.storyId, {
|
|
931
|
+
cursor,
|
|
932
|
+
ancestors
|
|
933
|
+
});
|
|
934
|
+
let willRestore = false;
|
|
935
|
+
try {
|
|
936
|
+
const res = arg(...args);
|
|
937
|
+
if (res instanceof Promise) {
|
|
938
|
+
willRestore = true;
|
|
939
|
+
return res.finally(restore);
|
|
940
|
+
}
|
|
941
|
+
return res;
|
|
942
|
+
} finally {
|
|
943
|
+
if (!willRestore) restore();
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
});
|
|
947
|
+
const result = fn.apply(object, finalArgs);
|
|
948
|
+
if (result && [
|
|
949
|
+
"object",
|
|
950
|
+
"function",
|
|
951
|
+
"symbol"
|
|
952
|
+
].includes(typeof result)) this.setState(call.storyId, (state) => ({ callRefsByResult: new Map([...Array.from(state.callRefsByResult.entries()), [result, {
|
|
953
|
+
__callId__: call.id,
|
|
954
|
+
retain: call.retain
|
|
955
|
+
}]]) }));
|
|
956
|
+
this.update({
|
|
957
|
+
...info,
|
|
958
|
+
status: result instanceof Promise ? "active" : "done"
|
|
959
|
+
});
|
|
960
|
+
if (result instanceof Promise) return result.then((value) => {
|
|
961
|
+
this.update({
|
|
962
|
+
...info,
|
|
963
|
+
status: "done"
|
|
964
|
+
});
|
|
965
|
+
return value;
|
|
966
|
+
}, handleException);
|
|
967
|
+
return result;
|
|
968
|
+
} catch (e) {
|
|
969
|
+
return handleException(e);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
update(call) {
|
|
973
|
+
this.channel?.emit(EVENTS.CALL, call);
|
|
974
|
+
this.setState(call.storyId, ({ calls }) => {
|
|
975
|
+
const callsById = calls.concat(call).reduce((a, c) => Object.assign(a, { [c.id]: c }), {});
|
|
976
|
+
return { calls: Object.values(callsById).sort((a, b) => a.id.localeCompare(b.id, void 0, { numeric: true })) };
|
|
977
|
+
});
|
|
978
|
+
this.sync(call.storyId);
|
|
979
|
+
}
|
|
980
|
+
sync(storyId) {
|
|
981
|
+
const synchronize = () => {
|
|
982
|
+
const { isLocked, isPlaying } = this.getState(storyId);
|
|
983
|
+
const logItems = this.getLog(storyId);
|
|
984
|
+
const pausedAt = logItems.filter(({ ancestors }) => !ancestors.length).find((item) => item.status === "waiting")?.callId;
|
|
985
|
+
const hasActive = logItems.some((item) => item.status === "active");
|
|
986
|
+
if (this.detached || isLocked || hasActive || logItems.length === 0) {
|
|
987
|
+
const payload = {
|
|
988
|
+
storyId,
|
|
989
|
+
controlStates: {
|
|
990
|
+
detached: this.detached,
|
|
991
|
+
start: false,
|
|
992
|
+
back: false,
|
|
993
|
+
goto: false,
|
|
994
|
+
next: false,
|
|
995
|
+
end: false
|
|
996
|
+
},
|
|
997
|
+
logItems
|
|
998
|
+
};
|
|
999
|
+
this.channel?.emit(EVENTS.SYNC, payload);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
const hasPrevious = logItems.some((item) => item.status === "done" || item.status === "error");
|
|
1003
|
+
const payload = {
|
|
1004
|
+
storyId,
|
|
1005
|
+
controlStates: {
|
|
1006
|
+
detached: this.detached,
|
|
1007
|
+
start: hasPrevious,
|
|
1008
|
+
back: hasPrevious,
|
|
1009
|
+
goto: true,
|
|
1010
|
+
next: isPlaying,
|
|
1011
|
+
end: isPlaying
|
|
1012
|
+
},
|
|
1013
|
+
logItems,
|
|
1014
|
+
pausedAt
|
|
1015
|
+
};
|
|
1016
|
+
this.channel?.emit(EVENTS.SYNC, payload);
|
|
1017
|
+
};
|
|
1018
|
+
this.setState(storyId, ({ syncTimeout }) => {
|
|
1019
|
+
clearTimeout(syncTimeout);
|
|
1020
|
+
return { syncTimeout: setTimeout(synchronize, 0) };
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
})))();
|
|
1025
|
+
}
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/manager-api/lib/intersect.ts
|
|
1028
|
+
var intersect_default;
|
|
1029
|
+
function init_intersect() {
|
|
1030
|
+
return (init_intersect = __esmMin((() => {
|
|
1031
|
+
intersect_default = (a, b) => {
|
|
1032
|
+
if (!Array.isArray(a) || !Array.isArray(b) || !a.length || !b.length) return [];
|
|
1033
|
+
return a.reduce((acc, aValue) => {
|
|
1034
|
+
if (b.includes(aValue)) acc.push(aValue);
|
|
1035
|
+
return acc;
|
|
1036
|
+
}, []);
|
|
1037
|
+
};
|
|
1038
|
+
})))();
|
|
1039
|
+
}
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/manager-api/lib/stories.ts
|
|
1042
|
+
var import_memoizerific$2, TITLE_PATH_SEPARATOR, denormalizeStoryParameters, transformSetStoriesStoryDataToPreparedStoryIndex, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, transformStoryIndexToStoriesHash, addPreparedStories, getComponentLookupList, getStoriesLookupList;
|
|
1043
|
+
function init_stories() {
|
|
1044
|
+
return (init_stories = __esmMin((() => {
|
|
1045
|
+
init_csf_utils();
|
|
1046
|
+
import_memoizerific$2 = /* @__PURE__ */ __toESM(require_memoizerific(), 1);
|
|
1047
|
+
init_esm();
|
|
1048
|
+
init_tags$1();
|
|
1049
|
+
init_root();
|
|
1050
|
+
init_intersect();
|
|
1051
|
+
init_merge();
|
|
1052
|
+
TITLE_PATH_SEPARATOR = /\s*\/\s*/;
|
|
1053
|
+
denormalizeStoryParameters = ({ globalParameters, kindParameters, stories }) => {
|
|
1054
|
+
return mapValues(stories, (storyData) => ({
|
|
1055
|
+
...storyData,
|
|
1056
|
+
parameters: combineParameters(globalParameters, kindParameters[storyData.kind], storyData.parameters)
|
|
1057
|
+
}));
|
|
1058
|
+
};
|
|
1059
|
+
transformSetStoriesStoryDataToPreparedStoryIndex = (stories) => {
|
|
1060
|
+
return {
|
|
1061
|
+
v: 5,
|
|
1062
|
+
entries: Object.entries(stories).reduce((acc, [id, story]) => {
|
|
1063
|
+
if (!story) return acc;
|
|
1064
|
+
const { docsOnly, fileName, ...parameters } = story.parameters;
|
|
1065
|
+
const base = {
|
|
1066
|
+
title: story.kind,
|
|
1067
|
+
id,
|
|
1068
|
+
name: story.name,
|
|
1069
|
+
importPath: fileName
|
|
1070
|
+
};
|
|
1071
|
+
if (docsOnly) acc[id] = {
|
|
1072
|
+
type: "docs",
|
|
1073
|
+
tags: ["stories-mdx"],
|
|
1074
|
+
storiesImports: [],
|
|
1075
|
+
...base
|
|
1076
|
+
};
|
|
1077
|
+
else {
|
|
1078
|
+
const { argTypes, args, initialArgs } = story;
|
|
1079
|
+
acc[id] = {
|
|
1080
|
+
type: "story",
|
|
1081
|
+
subtype: "story",
|
|
1082
|
+
...base,
|
|
1083
|
+
parameters,
|
|
1084
|
+
argTypes,
|
|
1085
|
+
args,
|
|
1086
|
+
initialArgs
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
return acc;
|
|
1090
|
+
}, {})
|
|
1091
|
+
};
|
|
1092
|
+
};
|
|
1093
|
+
transformStoryIndexV2toV3 = (index) => {
|
|
1094
|
+
return {
|
|
1095
|
+
v: 3,
|
|
1096
|
+
stories: Object.values(index.stories).reduce((acc, entry) => {
|
|
1097
|
+
acc[entry.id] = {
|
|
1098
|
+
...entry,
|
|
1099
|
+
title: entry.kind,
|
|
1100
|
+
name: entry.name || entry.story,
|
|
1101
|
+
importPath: entry.parameters.fileName || ""
|
|
1102
|
+
};
|
|
1103
|
+
return acc;
|
|
1104
|
+
}, {})
|
|
1105
|
+
};
|
|
1106
|
+
};
|
|
1107
|
+
transformStoryIndexV3toV4 = (index) => {
|
|
1108
|
+
const countByTitle = countBy(Object.values(index.stories), (item) => item.title);
|
|
1109
|
+
return {
|
|
1110
|
+
v: 4,
|
|
1111
|
+
entries: Object.values(index.stories).reduce((acc, entry) => {
|
|
1112
|
+
let type = "story";
|
|
1113
|
+
if (entry.parameters?.docsOnly || entry.name === "Page" && countByTitle[entry.title] === 1) type = "docs";
|
|
1114
|
+
acc[entry.id] = {
|
|
1115
|
+
type,
|
|
1116
|
+
...type === "docs" && {
|
|
1117
|
+
tags: ["stories-mdx"],
|
|
1118
|
+
storiesImports: []
|
|
1119
|
+
},
|
|
1120
|
+
...entry
|
|
1121
|
+
};
|
|
1122
|
+
delete acc[entry.id].story;
|
|
1123
|
+
delete acc[entry.id].kind;
|
|
1124
|
+
return acc;
|
|
1125
|
+
}, {})
|
|
1126
|
+
};
|
|
1127
|
+
};
|
|
1128
|
+
transformStoryIndexV4toV5 = (index) => {
|
|
1129
|
+
return {
|
|
1130
|
+
v: 5,
|
|
1131
|
+
entries: Object.values(index.entries).reduce((acc, entry) => {
|
|
1132
|
+
acc[entry.id] = {
|
|
1133
|
+
...entry,
|
|
1134
|
+
tags: entry.tags ? [
|
|
1135
|
+
Tag.DEV,
|
|
1136
|
+
Tag.TEST,
|
|
1137
|
+
...entry.tags
|
|
1138
|
+
] : [Tag.DEV]
|
|
1139
|
+
};
|
|
1140
|
+
return acc;
|
|
1141
|
+
}, {})
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1144
|
+
transformStoryIndexToStoriesHash = (input, { provider, docsOptions, filters, allStatuses, statusFilterKey }) => {
|
|
1145
|
+
if (!input.v) throw new Error("Composition: Missing stories.json version");
|
|
1146
|
+
let index = input;
|
|
1147
|
+
index = index.v === 2 ? transformStoryIndexV2toV3(index) : index;
|
|
1148
|
+
index = index.v === 3 ? transformStoryIndexV3toV4(index) : index;
|
|
1149
|
+
index = index.v === 4 ? transformStoryIndexV4toV5(index) : index;
|
|
1150
|
+
index = index;
|
|
1151
|
+
const indexEntries = Object.values(index.entries);
|
|
1152
|
+
const filterFunctions = Object.values(filters);
|
|
1153
|
+
const statusFilterFn = statusFilterKey ? filters[statusFilterKey] : void 0;
|
|
1154
|
+
const entryValues = indexEntries.filter((entry) => {
|
|
1155
|
+
const statuses = allStatuses[entry.id] ?? {};
|
|
1156
|
+
if (statusFilterFn && !statusFilterFn({
|
|
1157
|
+
...entry,
|
|
1158
|
+
statuses
|
|
1159
|
+
})) {
|
|
1160
|
+
if (!indexEntries.filter((item) => "parent" in item && item.parent === entry.id).some((child) => statusFilterFn({
|
|
1161
|
+
...child,
|
|
1162
|
+
statuses: allStatuses[child.id] ?? {}
|
|
1163
|
+
}))) return false;
|
|
1164
|
+
}
|
|
1165
|
+
if (Object.values(statuses).some(({ value }) => value === "status-value:error")) return true;
|
|
1166
|
+
if (filterFunctions.every((fn) => fn({
|
|
1167
|
+
...entry,
|
|
1168
|
+
statuses
|
|
1169
|
+
}))) return true;
|
|
1170
|
+
return indexEntries.filter((item) => "parent" in item && item.parent === entry.id).some((child) => filterFunctions.every((fn) => fn({
|
|
1171
|
+
...child,
|
|
1172
|
+
statuses
|
|
1173
|
+
})));
|
|
1174
|
+
});
|
|
1175
|
+
const { sidebar = {} } = provider.getConfig();
|
|
1176
|
+
const { showRoots, collapsedRoots = [], renderAriaLabel, renderLabel } = sidebar;
|
|
1177
|
+
const setShowRoots = typeof showRoots !== "undefined";
|
|
1178
|
+
const storiesHashOutOfOrder = entryValues.reduce((acc, item) => {
|
|
1179
|
+
if (docsOptions.docsMode && item.type !== "docs") return acc;
|
|
1180
|
+
const { title } = item;
|
|
1181
|
+
const groups = title.trim().split(TITLE_PATH_SEPARATOR);
|
|
1182
|
+
const root = (!setShowRoots || showRoots) && groups.length > 1 ? [groups.shift()] : [];
|
|
1183
|
+
const names = [...root, ...groups];
|
|
1184
|
+
const paths = names.reduce((list, name, idx) => {
|
|
1185
|
+
const parent = idx > 0 && list[idx - 1];
|
|
1186
|
+
const id = sanitize(parent ? `${parent}-${name}` : name);
|
|
1187
|
+
if (name.trim() === "") throw new Error(dedent`Invalid title ${title} ending in slash.`);
|
|
1188
|
+
if (parent === id) throw new Error(dedent`
|
|
1189
|
+
Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}'
|
|
1190
|
+
|
|
1191
|
+
Did you create a path that uses the separator char accidentally, such as 'Vue <docs/>' where '/' is a separator char? See https://github.com/storybookjs/storybook/issues/6128
|
|
1192
|
+
`);
|
|
1193
|
+
list.push(id);
|
|
1194
|
+
return list;
|
|
1195
|
+
}, []);
|
|
1196
|
+
paths.forEach((id, idx) => {
|
|
1197
|
+
const childId = paths[idx + 1] || item.id;
|
|
1198
|
+
if (root.length && idx === 0) acc[id] = merge_default(acc[id] || {}, {
|
|
1199
|
+
type: "root",
|
|
1200
|
+
id,
|
|
1201
|
+
name: names[idx],
|
|
1202
|
+
tags: [],
|
|
1203
|
+
depth: idx,
|
|
1204
|
+
renderAriaLabel,
|
|
1205
|
+
renderLabel,
|
|
1206
|
+
startCollapsed: collapsedRoots.includes(id),
|
|
1207
|
+
children: [childId]
|
|
1208
|
+
});
|
|
1209
|
+
else if ((!acc[id] || acc[id].type === "component") && idx === paths.length - 1) acc[id] = merge_default(acc[id] || {}, {
|
|
1210
|
+
type: "component",
|
|
1211
|
+
id,
|
|
1212
|
+
name: names[idx],
|
|
1213
|
+
tags: [],
|
|
1214
|
+
parent: paths[idx - 1],
|
|
1215
|
+
depth: idx,
|
|
1216
|
+
renderAriaLabel,
|
|
1217
|
+
renderLabel,
|
|
1218
|
+
...childId && { children: [childId] }
|
|
1219
|
+
});
|
|
1220
|
+
else acc[id] = merge_default(acc[id] || {}, {
|
|
1221
|
+
type: "group",
|
|
1222
|
+
id,
|
|
1223
|
+
name: names[idx],
|
|
1224
|
+
tags: [],
|
|
1225
|
+
parent: paths[idx - 1],
|
|
1226
|
+
depth: idx,
|
|
1227
|
+
renderAriaLabel,
|
|
1228
|
+
renderLabel,
|
|
1229
|
+
...childId && { children: [childId] }
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
1232
|
+
acc[item.id] = {
|
|
1233
|
+
tags: [],
|
|
1234
|
+
...item,
|
|
1235
|
+
depth: paths.length,
|
|
1236
|
+
parent: "parent" in item ? item.parent : paths[paths.length - 1],
|
|
1237
|
+
renderAriaLabel,
|
|
1238
|
+
renderLabel,
|
|
1239
|
+
prepared: !!item.parameters
|
|
1240
|
+
};
|
|
1241
|
+
return acc;
|
|
1242
|
+
}, {});
|
|
1243
|
+
function addItem(acc, item) {
|
|
1244
|
+
if (!acc[item.id]) {
|
|
1245
|
+
acc[item.id] = item;
|
|
1246
|
+
if ("children" in item && item.children) {
|
|
1247
|
+
item.children.forEach((childId) => addItem(acc, storiesHashOutOfOrder[childId]));
|
|
1248
|
+
item.tags = item.children.reduce((currentTags, childId) => {
|
|
1249
|
+
return currentTags === null ? acc[childId].tags : intersect_default(currentTags, acc[childId].tags);
|
|
1250
|
+
}, null) || [];
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (item.type === "component") {
|
|
1254
|
+
const firstChild = acc[item.children[0]];
|
|
1255
|
+
if (firstChild && "importPath" in firstChild) item.importPath = firstChild.importPath;
|
|
1256
|
+
}
|
|
1257
|
+
return acc;
|
|
1258
|
+
}
|
|
1259
|
+
let storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type !== "root" && !i.parent).reduce((acc, item) => addItem(acc, item), {});
|
|
1260
|
+
storiesHash = Object.values(storiesHashOutOfOrder).filter((i) => i.type === "root").reduce(addItem, storiesHash);
|
|
1261
|
+
storiesHash = Object.values(storiesHash).reduce((acc, item) => {
|
|
1262
|
+
if (item.type === "story" && item.subtype === "test") {
|
|
1263
|
+
const story = acc[item.parent];
|
|
1264
|
+
const component = acc[story.parent];
|
|
1265
|
+
acc[component.id] = {
|
|
1266
|
+
...component,
|
|
1267
|
+
children: component.children && component.children.filter((id) => id !== item.id)
|
|
1268
|
+
};
|
|
1269
|
+
acc[story.id] = {
|
|
1270
|
+
...story,
|
|
1271
|
+
children: (story.children || []).concat(item.id)
|
|
1272
|
+
};
|
|
1273
|
+
acc[item.id] = {
|
|
1274
|
+
...item,
|
|
1275
|
+
depth: item.depth + 1
|
|
1276
|
+
};
|
|
1277
|
+
} else acc[item.id] = item;
|
|
1278
|
+
return acc;
|
|
1279
|
+
}, {});
|
|
1280
|
+
return storiesHash;
|
|
1281
|
+
};
|
|
1282
|
+
addPreparedStories = (newHash, oldHash) => {
|
|
1283
|
+
if (!oldHash) return newHash;
|
|
1284
|
+
return Object.fromEntries(Object.entries(newHash).map(([id, newEntry]) => {
|
|
1285
|
+
const oldEntry = oldHash[id];
|
|
1286
|
+
if (newEntry.type === "story" && oldEntry?.type === "story" && oldEntry.prepared) {
|
|
1287
|
+
if ("children" in oldEntry) delete oldEntry.children;
|
|
1288
|
+
return [id, {
|
|
1289
|
+
...oldEntry,
|
|
1290
|
+
...newEntry,
|
|
1291
|
+
prepared: true
|
|
1292
|
+
}];
|
|
1293
|
+
}
|
|
1294
|
+
return [id, newEntry];
|
|
1295
|
+
}));
|
|
1296
|
+
};
|
|
1297
|
+
getComponentLookupList = (0, import_memoizerific$2.default)(1)((hash) => {
|
|
1298
|
+
return Object.entries(hash).reduce((acc, i) => {
|
|
1299
|
+
const value = i[1];
|
|
1300
|
+
if (value.type === "component") acc.push([...value.children]);
|
|
1301
|
+
return acc;
|
|
1302
|
+
}, []);
|
|
1303
|
+
});
|
|
1304
|
+
getStoriesLookupList = (0, import_memoizerific$2.default)(1)((hash) => {
|
|
1305
|
+
return Object.keys(hash).filter((k) => ["story", "docs"].includes(hash[k].type));
|
|
1306
|
+
});
|
|
1307
|
+
})))();
|
|
1308
|
+
}
|
|
1309
|
+
//#endregion
|
|
1310
|
+
//#region src/manager-api/modules/refs.ts
|
|
1311
|
+
var refs_exports = /* @__PURE__ */ __exportAll({
|
|
1312
|
+
defaultStoryMapper: () => defaultStoryMapper,
|
|
1313
|
+
getSourceType: () => getSourceType,
|
|
1314
|
+
init: () => init$11
|
|
1315
|
+
});
|
|
1316
|
+
async function handleRequest(request) {
|
|
1317
|
+
if (!request) return {};
|
|
1318
|
+
try {
|
|
1319
|
+
const response = await request;
|
|
1320
|
+
if (response === false || response === true) throw new Error("Unexpected boolean response");
|
|
1321
|
+
if (!response.ok) {
|
|
1322
|
+
if (response.status === 401) try {
|
|
1323
|
+
const json = await response.json();
|
|
1324
|
+
if (json.loginUrl) return { loginUrl: json.loginUrl };
|
|
1325
|
+
} catch {}
|
|
1326
|
+
throw new Error(`Unexpected response not OK: ${response.statusText}`);
|
|
1327
|
+
}
|
|
1328
|
+
const json = await response.json();
|
|
1329
|
+
if (json.entries || json.stories) return { storyIndex: json };
|
|
1330
|
+
return json;
|
|
1331
|
+
} catch (err) {
|
|
1332
|
+
return { indexError: err };
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
var location, fetch$1, getSourceType, defaultStoryMapper, addRefIds, applyRefStoryUpdates, parseUrl, getRedirectedRefUrl, map, init$11;
|
|
1336
|
+
function init_refs() {
|
|
1337
|
+
return (init_refs = __esmMin((() => {
|
|
1338
|
+
init_dist$1();
|
|
1339
|
+
init_esm();
|
|
1340
|
+
init_stories();
|
|
1341
|
+
({location, fetch: fetch$1} = scope);
|
|
1342
|
+
getSourceType = (source, refId) => {
|
|
1343
|
+
const { origin: localOrigin, pathname: localPathname } = location;
|
|
1344
|
+
const { origin: sourceOrigin, pathname: sourcePathname } = new URL(source);
|
|
1345
|
+
const localFull = `${localOrigin + localPathname}`.replace(/\/[^\/]*$/, "");
|
|
1346
|
+
const sourceFull = `${sourceOrigin + sourcePathname}`.replace(/\/[^\/]*$/, "");
|
|
1347
|
+
if (localFull === sourceFull) return ["local", sourceFull];
|
|
1348
|
+
if (refId || source) return ["external", sourceFull];
|
|
1349
|
+
return [null, null];
|
|
1350
|
+
};
|
|
1351
|
+
defaultStoryMapper = (b, a) => {
|
|
1352
|
+
return {
|
|
1353
|
+
...a,
|
|
1354
|
+
kind: a.kind.replace("|", "/")
|
|
1355
|
+
};
|
|
1356
|
+
};
|
|
1357
|
+
addRefIds = (input, ref) => {
|
|
1358
|
+
return Object.entries(input).reduce((acc, [id, item]) => {
|
|
1359
|
+
return {
|
|
1360
|
+
...acc,
|
|
1361
|
+
[id]: {
|
|
1362
|
+
...item,
|
|
1363
|
+
refId: ref.id
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
}, {});
|
|
1367
|
+
};
|
|
1368
|
+
applyRefStoryUpdates = (index, storyUpdates) => {
|
|
1369
|
+
if (!storyUpdates) return index;
|
|
1370
|
+
Object.entries(storyUpdates).forEach(([id, update]) => {
|
|
1371
|
+
const entry = index[id];
|
|
1372
|
+
if (entry && (entry.type === "story" || entry.type === "docs")) index[id] = {
|
|
1373
|
+
...entry,
|
|
1374
|
+
...update
|
|
1375
|
+
};
|
|
1376
|
+
});
|
|
1377
|
+
return index;
|
|
1378
|
+
};
|
|
1379
|
+
parseUrl = (url) => {
|
|
1380
|
+
const credentialsRegex = /https?:\/\/(.+:.+)@/;
|
|
1381
|
+
let cleanUrl = url;
|
|
1382
|
+
let authorization;
|
|
1383
|
+
const [, credentials] = url.match(credentialsRegex) || [];
|
|
1384
|
+
if (credentials) {
|
|
1385
|
+
cleanUrl = url.replace(`${credentials}@`, "");
|
|
1386
|
+
authorization = btoa(`${credentials}`);
|
|
1387
|
+
}
|
|
1388
|
+
return {
|
|
1389
|
+
url: cleanUrl,
|
|
1390
|
+
authorization
|
|
1391
|
+
};
|
|
1392
|
+
};
|
|
1393
|
+
getRedirectedRefUrl = (refUrl, indexResponseUrl) => {
|
|
1394
|
+
if (!indexResponseUrl) return refUrl;
|
|
1395
|
+
const served = new URL(indexResponseUrl);
|
|
1396
|
+
if (served.origin === new URL(refUrl, location.href).origin || !served.pathname.endsWith("/index.json")) return refUrl;
|
|
1397
|
+
return served.origin + served.pathname.slice(0, -11);
|
|
1398
|
+
};
|
|
1399
|
+
map = (input, ref, options) => {
|
|
1400
|
+
const { storyMapper } = options;
|
|
1401
|
+
if (storyMapper) return Object.entries(input).reduce((acc, [id, item]) => {
|
|
1402
|
+
return {
|
|
1403
|
+
...acc,
|
|
1404
|
+
[id]: storyMapper(ref, item)
|
|
1405
|
+
};
|
|
1406
|
+
}, {});
|
|
1407
|
+
return input;
|
|
1408
|
+
};
|
|
1409
|
+
init$11 = ({ store, provider, singleStory, docsOptions = {} }, { runCheck = true } = {}) => {
|
|
1410
|
+
const api = {
|
|
1411
|
+
findRef: (source) => {
|
|
1412
|
+
const refs = api.getRefs();
|
|
1413
|
+
return Object.values(refs).find(({ url }) => url.match(source));
|
|
1414
|
+
},
|
|
1415
|
+
changeRefVersion: async (id, url) => {
|
|
1416
|
+
const { versions, title } = api.getRefs()[id];
|
|
1417
|
+
const ref = {
|
|
1418
|
+
id,
|
|
1419
|
+
url,
|
|
1420
|
+
versions,
|
|
1421
|
+
title,
|
|
1422
|
+
index: {},
|
|
1423
|
+
filteredIndex: {},
|
|
1424
|
+
expanded: true
|
|
1425
|
+
};
|
|
1426
|
+
await api.setRef(id, {
|
|
1427
|
+
...ref,
|
|
1428
|
+
type: "unknown"
|
|
1429
|
+
}, false);
|
|
1430
|
+
await api.checkRef(ref);
|
|
1431
|
+
},
|
|
1432
|
+
changeRefState: (id, previewInitialized) => {
|
|
1433
|
+
const { [id]: ref, ...updated } = api.getRefs();
|
|
1434
|
+
updated[id] = {
|
|
1435
|
+
...ref,
|
|
1436
|
+
previewInitialized
|
|
1437
|
+
};
|
|
1438
|
+
store.setState({ refs: updated });
|
|
1439
|
+
},
|
|
1440
|
+
checkRef: async (ref) => {
|
|
1441
|
+
const { id, url, version, type } = ref;
|
|
1442
|
+
const isPublic = type === "server-checked";
|
|
1443
|
+
const loadedData = {};
|
|
1444
|
+
const query = version ? `?version=${version}` : "";
|
|
1445
|
+
const credentials = isPublic ? "omit" : "include";
|
|
1446
|
+
const urlParseResult = parseUrl(url);
|
|
1447
|
+
const headers = { Accept: "application/json" };
|
|
1448
|
+
if (urlParseResult.authorization) Object.assign(headers, { Authorization: `Basic ${urlParseResult.authorization}` });
|
|
1449
|
+
const [indexRequest, storiesRequest] = ["index.json", "stories.json"].map((file) => fetch$1(`${urlParseResult.url}/${file}${query}`, {
|
|
1450
|
+
headers,
|
|
1451
|
+
credentials
|
|
1452
|
+
}));
|
|
1453
|
+
const [indexResult, storiesResult] = await Promise.all([handleRequest(indexRequest), handleRequest(storiesRequest)]);
|
|
1454
|
+
const refUrl = scope.CONFIG_TYPE === "DEVELOPMENT" && indexResult.storyIndex ? getRedirectedRefUrl(urlParseResult.url, (await indexRequest).url) : urlParseResult.url;
|
|
1455
|
+
if (!indexResult.indexError || !storiesResult.indexError) {
|
|
1456
|
+
const metadata = await handleRequest(fetch$1(`${urlParseResult.url}/metadata.json${query}`, {
|
|
1457
|
+
headers,
|
|
1458
|
+
credentials,
|
|
1459
|
+
cache: "no-cache"
|
|
1460
|
+
}).catch(() => false));
|
|
1461
|
+
Object.assign(loadedData, {
|
|
1462
|
+
...indexResult.indexError ? storiesResult : indexResult,
|
|
1463
|
+
...!metadata.indexError && metadata
|
|
1464
|
+
});
|
|
1465
|
+
} else if (!isPublic) loadedData.indexError = { message: dedent`
|
|
1466
|
+
Error: Loading of ref failed
|
|
1467
|
+
at fetch (lib/api/src/modules/refs.ts)
|
|
1468
|
+
|
|
1469
|
+
URL: ${urlParseResult.url}
|
|
1470
|
+
|
|
1471
|
+
We weren't able to load the above URL,
|
|
1472
|
+
it's possible a CORS error happened.
|
|
1473
|
+
|
|
1474
|
+
Please check your dev-tools network tab.
|
|
1475
|
+
` };
|
|
1476
|
+
const versions = ref.versions && Object.keys(ref.versions).length ? ref.versions : loadedData.versions;
|
|
1477
|
+
await api.setRef(id, {
|
|
1478
|
+
id,
|
|
1479
|
+
url: refUrl,
|
|
1480
|
+
...loadedData,
|
|
1481
|
+
...versions ? { versions } : {},
|
|
1482
|
+
type: !loadedData.storyIndex ? "auto-inject" : "lazy"
|
|
1483
|
+
});
|
|
1484
|
+
},
|
|
1485
|
+
getRefs: () => {
|
|
1486
|
+
const { refs = {} } = store.getState();
|
|
1487
|
+
return refs;
|
|
1488
|
+
},
|
|
1489
|
+
setRef: async (id, { storyIndex, setStoriesData, ...rest }, ready = false) => {
|
|
1490
|
+
if (singleStory) return;
|
|
1491
|
+
let internal_index;
|
|
1492
|
+
let index;
|
|
1493
|
+
let filteredIndex;
|
|
1494
|
+
const { filters } = store.getState();
|
|
1495
|
+
const { storyMapper = defaultStoryMapper } = provider.getConfig();
|
|
1496
|
+
const ref = api.getRefs()[id];
|
|
1497
|
+
if (storyIndex || setStoriesData) {
|
|
1498
|
+
internal_index = setStoriesData ? transformSetStoriesStoryDataToPreparedStoryIndex(map(setStoriesData, ref, { storyMapper })) : storyIndex;
|
|
1499
|
+
filteredIndex = transformStoryIndexToStoriesHash(storyIndex, {
|
|
1500
|
+
provider,
|
|
1501
|
+
docsOptions,
|
|
1502
|
+
filters,
|
|
1503
|
+
allStatuses: {}
|
|
1504
|
+
});
|
|
1505
|
+
index = transformStoryIndexToStoriesHash(storyIndex, {
|
|
1506
|
+
provider,
|
|
1507
|
+
docsOptions,
|
|
1508
|
+
filters: {},
|
|
1509
|
+
allStatuses: {}
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
if (index) {
|
|
1513
|
+
index = addRefIds(index, ref);
|
|
1514
|
+
index = applyRefStoryUpdates(index, ref?.storyUpdates);
|
|
1515
|
+
}
|
|
1516
|
+
if (filteredIndex) {
|
|
1517
|
+
filteredIndex = addRefIds(filteredIndex, ref);
|
|
1518
|
+
filteredIndex = applyRefStoryUpdates(filteredIndex, ref?.storyUpdates);
|
|
1519
|
+
}
|
|
1520
|
+
await api.updateRef(id, {
|
|
1521
|
+
...ref,
|
|
1522
|
+
...rest,
|
|
1523
|
+
index,
|
|
1524
|
+
filteredIndex,
|
|
1525
|
+
internal_index
|
|
1526
|
+
});
|
|
1527
|
+
},
|
|
1528
|
+
updateRef: async (id, data) => {
|
|
1529
|
+
const { [id]: ref, ...updated } = api.getRefs();
|
|
1530
|
+
updated[id] = {
|
|
1531
|
+
...ref,
|
|
1532
|
+
...data
|
|
1533
|
+
};
|
|
1534
|
+
const ordered = Object.keys(initialState).reduce((obj, key) => {
|
|
1535
|
+
obj[key] = updated[key];
|
|
1536
|
+
return obj;
|
|
1537
|
+
}, {});
|
|
1538
|
+
await store.setState({ refs: ordered });
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
const refs = !singleStory && scope.REFS || {};
|
|
1542
|
+
const initialState = refs;
|
|
1543
|
+
if (runCheck) new Promise(async (resolve) => {
|
|
1544
|
+
for (const ref of Object.values(refs)) await api.checkRef({
|
|
1545
|
+
...ref,
|
|
1546
|
+
stories: {}
|
|
1547
|
+
});
|
|
1548
|
+
resolve(void 0);
|
|
1549
|
+
});
|
|
1550
|
+
return {
|
|
1551
|
+
api,
|
|
1552
|
+
state: { refs: initialState }
|
|
1553
|
+
};
|
|
1554
|
+
};
|
|
1555
|
+
})))();
|
|
1556
|
+
}
|
|
1557
|
+
//#endregion
|
|
1558
|
+
//#region src/manager-api/lib/events.ts
|
|
1559
|
+
var getEventMetadata;
|
|
1560
|
+
function init_events() {
|
|
1561
|
+
return (init_events = __esmMin((() => {
|
|
1562
|
+
init_client_logger();
|
|
1563
|
+
init_refs();
|
|
1564
|
+
getEventMetadata = (context, fullAPI) => {
|
|
1565
|
+
const { source, refId, type } = context;
|
|
1566
|
+
const [sourceType, sourceLocation] = getSourceType(source, refId);
|
|
1567
|
+
let ref;
|
|
1568
|
+
if (refId || sourceType === "external") ref = refId && fullAPI.getRefs()[refId] ? fullAPI.getRefs()[refId] : fullAPI.findRef(sourceLocation);
|
|
1569
|
+
const meta = {
|
|
1570
|
+
source,
|
|
1571
|
+
sourceType,
|
|
1572
|
+
sourceLocation,
|
|
1573
|
+
refId,
|
|
1574
|
+
ref,
|
|
1575
|
+
type
|
|
1576
|
+
};
|
|
1577
|
+
switch (true) {
|
|
1578
|
+
case typeof refId === "string":
|
|
1579
|
+
case sourceType === "local":
|
|
1580
|
+
case sourceType === "external": return meta;
|
|
1581
|
+
default:
|
|
1582
|
+
logger.warn(`Received a ${type} frame that was not configured as a ref`);
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
})))();
|
|
1587
|
+
}
|
|
1588
|
+
//#endregion
|
|
1589
|
+
//#region src/manager-api/modules/globals.ts
|
|
1590
|
+
var globals_exports = /* @__PURE__ */ __exportAll({ init: () => init$10 });
|
|
1591
|
+
var init$10;
|
|
1592
|
+
function init_globals$1() {
|
|
1593
|
+
return (init_globals$1 = __esmMin((() => {
|
|
1594
|
+
init_client_logger();
|
|
1595
|
+
init_core_events();
|
|
1596
|
+
init_dist$3();
|
|
1597
|
+
init_events();
|
|
1598
|
+
init$10 = ({ store, fullAPI, provider }) => {
|
|
1599
|
+
const api = {
|
|
1600
|
+
getGlobals() {
|
|
1601
|
+
return store.getState().globals;
|
|
1602
|
+
},
|
|
1603
|
+
getUserGlobals() {
|
|
1604
|
+
return store.getState().userGlobals;
|
|
1605
|
+
},
|
|
1606
|
+
getStoryGlobals() {
|
|
1607
|
+
return store.getState().storyGlobals;
|
|
1608
|
+
},
|
|
1609
|
+
getGlobalTypes() {
|
|
1610
|
+
return store.getState().globalTypes;
|
|
1611
|
+
},
|
|
1612
|
+
updateGlobals(newGlobals) {
|
|
1613
|
+
provider.channel?.emit(UPDATE_GLOBALS, {
|
|
1614
|
+
globals: newGlobals,
|
|
1615
|
+
options: { target: "storybook-preview-iframe" }
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
const state = {
|
|
1620
|
+
globals: {},
|
|
1621
|
+
userGlobals: {},
|
|
1622
|
+
storyGlobals: {},
|
|
1623
|
+
globalTypes: {}
|
|
1624
|
+
};
|
|
1625
|
+
const updateGlobals = ({ globals, storyGlobals, userGlobals }) => {
|
|
1626
|
+
const { globals: currentGlobals, userGlobals: currentUserGlobals, storyGlobals: currentStoryGlobals } = store.getState();
|
|
1627
|
+
if (!dequal(globals, currentGlobals)) store.setState({ globals });
|
|
1628
|
+
if (!dequal(userGlobals, currentUserGlobals)) store.setState({ userGlobals });
|
|
1629
|
+
if (!dequal(storyGlobals, currentStoryGlobals)) store.setState({ storyGlobals });
|
|
1630
|
+
};
|
|
1631
|
+
provider.channel?.on(GLOBALS_UPDATED, function handleGlobalsUpdated({ globals, storyGlobals, userGlobals }) {
|
|
1632
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
1633
|
+
if (!ref) updateGlobals({
|
|
1634
|
+
globals,
|
|
1635
|
+
storyGlobals,
|
|
1636
|
+
userGlobals
|
|
1637
|
+
});
|
|
1638
|
+
else logger.warn("received a GLOBALS_UPDATED from a non-local ref. This is not currently supported.");
|
|
1639
|
+
});
|
|
1640
|
+
provider.channel?.on(SET_GLOBALS, function handleSetGlobals({ globals, globalTypes }) {
|
|
1641
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
1642
|
+
const currentUserGlobals = store.getState()?.userGlobals;
|
|
1643
|
+
if (!ref) store.setState({
|
|
1644
|
+
globals,
|
|
1645
|
+
userGlobals: globals,
|
|
1646
|
+
globalTypes
|
|
1647
|
+
});
|
|
1648
|
+
else if (Object.keys(globals).length > 0) logger.warn("received globals from a non-local ref. This is not currently supported.");
|
|
1649
|
+
if (currentUserGlobals && Object.keys(currentUserGlobals).length !== 0 && !dequal(globals, currentUserGlobals)) api.updateGlobals(currentUserGlobals);
|
|
1650
|
+
});
|
|
1651
|
+
return {
|
|
1652
|
+
api,
|
|
1653
|
+
state
|
|
1654
|
+
};
|
|
1655
|
+
};
|
|
1656
|
+
})))();
|
|
1657
|
+
}
|
|
1658
|
+
//#endregion
|
|
1659
|
+
//#region src/manager-api/modules/layout.ts
|
|
1660
|
+
var layout_exports = /* @__PURE__ */ __exportAll({
|
|
1661
|
+
ActiveTabs: () => ActiveTabs$1,
|
|
1662
|
+
DEFAULT_BOTTOM_PANEL_HEIGHT: () => 300,
|
|
1663
|
+
DEFAULT_NAV_SIZE: () => 300,
|
|
1664
|
+
DEFAULT_RIGHT_PANEL_WIDTH: () => 400,
|
|
1665
|
+
focusableUIElements: () => focusableUIElements,
|
|
1666
|
+
getDefaultLayoutState: () => getDefaultLayoutState,
|
|
1667
|
+
init: () => init$9,
|
|
1668
|
+
isDesktopViewport: () => isDesktopViewport,
|
|
1669
|
+
isPagesViewMode: () => isPagesViewMode
|
|
1670
|
+
}), document$2, isFunction, ActiveTabs$1, isPagesViewMode, getDefaultLayoutState, focusableUIElements, getIsNavShown, getIsPanelShown, getIsFullscreen, getRecentVisibleSizes, applyLayoutOptions, applyUiOptions, isDesktopViewport, init$9;
|
|
1671
|
+
function init_layout() {
|
|
1672
|
+
return (init_layout = __esmMin((() => {
|
|
1673
|
+
init_core_events();
|
|
1674
|
+
init_dist$1();
|
|
1675
|
+
init_toMerged();
|
|
1676
|
+
init_isEqual();
|
|
1677
|
+
init_create();
|
|
1678
|
+
init_routes();
|
|
1679
|
+
init_merge();
|
|
1680
|
+
({document: document$2} = scope);
|
|
1681
|
+
isFunction = (val) => typeof val === "function";
|
|
1682
|
+
ActiveTabs$1 = {
|
|
1683
|
+
SIDEBAR: "sidebar",
|
|
1684
|
+
CANVAS: "canvas",
|
|
1685
|
+
ADDONS: "addons"
|
|
1686
|
+
};
|
|
1687
|
+
isPagesViewMode = (viewMode) => viewMode !== void 0 && viewMode !== "story" && viewMode !== "docs" && viewMode !== "review";
|
|
1688
|
+
getDefaultLayoutState = () => {
|
|
1689
|
+
return {
|
|
1690
|
+
ui: { enableShortcuts: true },
|
|
1691
|
+
layout: {
|
|
1692
|
+
initialActive: ActiveTabs$1.CANVAS,
|
|
1693
|
+
navSize: 300,
|
|
1694
|
+
bottomPanelHeight: 300,
|
|
1695
|
+
rightPanelWidth: 400,
|
|
1696
|
+
recentVisibleSizes: {
|
|
1697
|
+
navSize: 300,
|
|
1698
|
+
bottomPanelHeight: 300,
|
|
1699
|
+
rightPanelWidth: 400
|
|
1700
|
+
},
|
|
1701
|
+
panelPosition: "bottom",
|
|
1702
|
+
showNav: true,
|
|
1703
|
+
showPanel: true,
|
|
1704
|
+
showToolbar: true,
|
|
1705
|
+
showMobileNavigation: false
|
|
1706
|
+
},
|
|
1707
|
+
layoutCustomisations: {
|
|
1708
|
+
showPanel: void 0,
|
|
1709
|
+
showSidebar: void 0,
|
|
1710
|
+
showToolbar: void 0
|
|
1711
|
+
},
|
|
1712
|
+
selectedPanel: void 0,
|
|
1713
|
+
theme: create()
|
|
1714
|
+
};
|
|
1715
|
+
};
|
|
1716
|
+
focusableUIElements = {
|
|
1717
|
+
addonPanel: "storybook-panel-region",
|
|
1718
|
+
storySearchField: "storybook-explorer-searchfield",
|
|
1719
|
+
storyListMenu: "storybook-explorer-menu",
|
|
1720
|
+
storyPanelRoot: "storybook-panel-root",
|
|
1721
|
+
showAddonPanel: "storybook-show-addon-panel",
|
|
1722
|
+
sidebarRegion: "storybook-sidebar-region",
|
|
1723
|
+
showSidebar: "storybook-show-sidebar"
|
|
1724
|
+
};
|
|
1725
|
+
getIsNavShown = (state) => {
|
|
1726
|
+
return state.layout.navSize > 0;
|
|
1727
|
+
};
|
|
1728
|
+
getIsPanelShown = (state) => {
|
|
1729
|
+
const { bottomPanelHeight, rightPanelWidth, panelPosition } = state.layout;
|
|
1730
|
+
return panelPosition === "bottom" && bottomPanelHeight > 0 || panelPosition === "right" && rightPanelWidth > 0;
|
|
1731
|
+
};
|
|
1732
|
+
getIsFullscreen = (state) => {
|
|
1733
|
+
return !getIsNavShown(state) && !getIsPanelShown(state);
|
|
1734
|
+
};
|
|
1735
|
+
getRecentVisibleSizes = (layoutState) => {
|
|
1736
|
+
return {
|
|
1737
|
+
navSize: layoutState.navSize > 0 ? layoutState.navSize : layoutState.recentVisibleSizes.navSize,
|
|
1738
|
+
bottomPanelHeight: layoutState.bottomPanelHeight > 0 ? layoutState.bottomPanelHeight : layoutState.recentVisibleSizes.bottomPanelHeight,
|
|
1739
|
+
rightPanelWidth: layoutState.rightPanelWidth > 0 ? layoutState.rightPanelWidth : layoutState.recentVisibleSizes.rightPanelWidth
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1742
|
+
applyLayoutOptions = (layoutState, options, singleStory) => {
|
|
1743
|
+
const { showPanel, showNav } = options ?? {};
|
|
1744
|
+
const layoutKeys = Object.keys(layoutState);
|
|
1745
|
+
const nextLayoutState = toMerged(layoutState, pick(options ?? {}, layoutKeys));
|
|
1746
|
+
if (showNav === false || singleStory) {
|
|
1747
|
+
nextLayoutState.recentVisibleSizes = getRecentVisibleSizes(nextLayoutState);
|
|
1748
|
+
nextLayoutState.navSize = 0;
|
|
1749
|
+
} else if (showNav === true) nextLayoutState.navSize = nextLayoutState.recentVisibleSizes.navSize;
|
|
1750
|
+
if (showPanel === false) {
|
|
1751
|
+
nextLayoutState.recentVisibleSizes = getRecentVisibleSizes(nextLayoutState);
|
|
1752
|
+
nextLayoutState.bottomPanelHeight = 0;
|
|
1753
|
+
nextLayoutState.rightPanelWidth = 0;
|
|
1754
|
+
} else if (showPanel === true) {
|
|
1755
|
+
nextLayoutState.bottomPanelHeight = nextLayoutState.recentVisibleSizes.bottomPanelHeight;
|
|
1756
|
+
nextLayoutState.rightPanelWidth = nextLayoutState.recentVisibleSizes.rightPanelWidth;
|
|
1757
|
+
}
|
|
1758
|
+
return nextLayoutState;
|
|
1759
|
+
};
|
|
1760
|
+
applyUiOptions = (uiState, options) => {
|
|
1761
|
+
const uiKeys = Object.keys(uiState);
|
|
1762
|
+
return toMerged(uiState, pick(options ?? {}, uiKeys));
|
|
1763
|
+
};
|
|
1764
|
+
isDesktopViewport = () => scope.matchMedia?.("(min-width: 600px)")?.matches ?? true;
|
|
1765
|
+
init$9 = ({ store, provider, singleStory }) => {
|
|
1766
|
+
const api = {
|
|
1767
|
+
toggleFullscreen(nextState) {
|
|
1768
|
+
return store.setState((state) => {
|
|
1769
|
+
const isFullscreen = getIsFullscreen(state);
|
|
1770
|
+
const shouldFullscreen = typeof nextState === "boolean" ? nextState : !isFullscreen;
|
|
1771
|
+
if (shouldFullscreen === isFullscreen) return { layout: state.layout };
|
|
1772
|
+
return shouldFullscreen ? { layout: {
|
|
1773
|
+
...state.layout,
|
|
1774
|
+
navSize: 0,
|
|
1775
|
+
bottomPanelHeight: 0,
|
|
1776
|
+
rightPanelWidth: 0,
|
|
1777
|
+
recentVisibleSizes: getRecentVisibleSizes(state.layout)
|
|
1778
|
+
} } : { layout: {
|
|
1779
|
+
...state.layout,
|
|
1780
|
+
navSize: state.singleStory ? 0 : state.layout.recentVisibleSizes.navSize,
|
|
1781
|
+
bottomPanelHeight: state.layout.recentVisibleSizes.bottomPanelHeight,
|
|
1782
|
+
rightPanelWidth: state.layout.recentVisibleSizes.rightPanelWidth
|
|
1783
|
+
} };
|
|
1784
|
+
}, { persistence: "session" });
|
|
1785
|
+
},
|
|
1786
|
+
togglePanel(nextState) {
|
|
1787
|
+
return store.setState((state) => {
|
|
1788
|
+
const isPanelShown = getIsPanelShown(state);
|
|
1789
|
+
const shouldShowPanel = typeof nextState === "boolean" ? nextState : !isPanelShown;
|
|
1790
|
+
if (shouldShowPanel === isPanelShown) return { layout: state.layout };
|
|
1791
|
+
return shouldShowPanel ? { layout: {
|
|
1792
|
+
...state.layout,
|
|
1793
|
+
bottomPanelHeight: state.layout.recentVisibleSizes.bottomPanelHeight,
|
|
1794
|
+
rightPanelWidth: state.layout.recentVisibleSizes.rightPanelWidth
|
|
1795
|
+
} } : { layout: {
|
|
1796
|
+
...state.layout,
|
|
1797
|
+
bottomPanelHeight: 0,
|
|
1798
|
+
rightPanelWidth: 0,
|
|
1799
|
+
recentVisibleSizes: getRecentVisibleSizes(state.layout)
|
|
1800
|
+
} };
|
|
1801
|
+
}, { persistence: "session" });
|
|
1802
|
+
},
|
|
1803
|
+
togglePanelPosition(position) {
|
|
1804
|
+
return store.setState((state) => {
|
|
1805
|
+
const nextPosition = position || (state.layout.panelPosition === "right" ? "bottom" : "right");
|
|
1806
|
+
return { layout: {
|
|
1807
|
+
...state.layout,
|
|
1808
|
+
panelPosition: nextPosition,
|
|
1809
|
+
bottomPanelHeight: state.layout.recentVisibleSizes.bottomPanelHeight,
|
|
1810
|
+
rightPanelWidth: state.layout.recentVisibleSizes.rightPanelWidth
|
|
1811
|
+
} };
|
|
1812
|
+
}, { persistence: "permanent" });
|
|
1813
|
+
},
|
|
1814
|
+
toggleNav(nextState) {
|
|
1815
|
+
if (!isDesktopViewport()) return store.setState((state) => ({ layout: {
|
|
1816
|
+
...state.layout,
|
|
1817
|
+
showMobileNavigation: typeof nextState === "boolean" ? nextState : !state.layout.showMobileNavigation
|
|
1818
|
+
} }));
|
|
1819
|
+
return store.setState((state) => {
|
|
1820
|
+
if (state.singleStory) return { layout: state.layout };
|
|
1821
|
+
const isNavShown = getIsNavShown(state);
|
|
1822
|
+
const shouldShowNav = typeof nextState === "boolean" ? nextState : !isNavShown;
|
|
1823
|
+
if (shouldShowNav === isNavShown) return { layout: state.layout };
|
|
1824
|
+
return shouldShowNav ? { layout: {
|
|
1825
|
+
...state.layout,
|
|
1826
|
+
navSize: state.layout.recentVisibleSizes.navSize
|
|
1827
|
+
} } : { layout: {
|
|
1828
|
+
...state.layout,
|
|
1829
|
+
navSize: 0,
|
|
1830
|
+
recentVisibleSizes: getRecentVisibleSizes(state.layout)
|
|
1831
|
+
} };
|
|
1832
|
+
}, { persistence: "session" });
|
|
1833
|
+
},
|
|
1834
|
+
setMobileNavigation(show) {
|
|
1835
|
+
return store.setState((state) => ({ layout: {
|
|
1836
|
+
...state.layout,
|
|
1837
|
+
showMobileNavigation: show
|
|
1838
|
+
} }));
|
|
1839
|
+
},
|
|
1840
|
+
toggleToolbar(toggled) {
|
|
1841
|
+
return store.setState((state) => {
|
|
1842
|
+
const value = typeof toggled !== "undefined" ? toggled : !state.layout.showToolbar;
|
|
1843
|
+
return { layout: {
|
|
1844
|
+
...state.layout,
|
|
1845
|
+
showToolbar: value
|
|
1846
|
+
} };
|
|
1847
|
+
}, { persistence: "session" });
|
|
1848
|
+
},
|
|
1849
|
+
setSizes({ navSize, bottomPanelHeight, rightPanelWidth }) {
|
|
1850
|
+
return store.setState((state) => {
|
|
1851
|
+
const nextLayoutState = {
|
|
1852
|
+
...state.layout,
|
|
1853
|
+
navSize: navSize ?? state.layout.navSize,
|
|
1854
|
+
bottomPanelHeight: bottomPanelHeight ?? state.layout.bottomPanelHeight,
|
|
1855
|
+
rightPanelWidth: rightPanelWidth ?? state.layout.rightPanelWidth
|
|
1856
|
+
};
|
|
1857
|
+
return { layout: {
|
|
1858
|
+
...nextLayoutState,
|
|
1859
|
+
recentVisibleSizes: getRecentVisibleSizes(nextLayoutState)
|
|
1860
|
+
} };
|
|
1861
|
+
}, { persistence: "session" });
|
|
1862
|
+
},
|
|
1863
|
+
/**
|
|
1864
|
+
* Attempts to focus (and select) an element identified by its ID. It is the responsibility of
|
|
1865
|
+
* the callee to ensure that the element is present in the DOM and that no focus trap is
|
|
1866
|
+
* available. When polling is enabled, this API polls and attempts to perform the focus for a
|
|
1867
|
+
* set duration (max 500ms), so that race conditions can be avoided with the current API
|
|
1868
|
+
* design.
|
|
1869
|
+
*
|
|
1870
|
+
* @param elementId The id of the element to focus.
|
|
1871
|
+
* @param options When a boolean, treated as the `select` option for backwards compatibility.
|
|
1872
|
+
* When an object, may contain `select` and `poll` options.
|
|
1873
|
+
* @returns Whether the element was successfully focused. Returns a Promise when polling.
|
|
1874
|
+
*/
|
|
1875
|
+
focusOnUIElement(elementId, options) {
|
|
1876
|
+
const { forceFocus = false, select = false, poll = true } = typeof options === "boolean" ? { select: options } : options ?? {};
|
|
1877
|
+
if (!elementId) return false;
|
|
1878
|
+
const attemptFocus = () => {
|
|
1879
|
+
const element = document$2.getElementById(elementId);
|
|
1880
|
+
if (!element) return false;
|
|
1881
|
+
element.focus();
|
|
1882
|
+
if (element !== document$2.activeElement && forceFocus && element.getAttribute("tabindex") === null) {
|
|
1883
|
+
element.setAttribute("tabindex", "-1");
|
|
1884
|
+
element.focus();
|
|
1885
|
+
}
|
|
1886
|
+
if (element !== document$2.activeElement && element.id !== document$2.activeElement?.id) return false;
|
|
1887
|
+
if (select) element.select?.();
|
|
1888
|
+
return true;
|
|
1889
|
+
};
|
|
1890
|
+
if (attemptFocus()) return true;
|
|
1891
|
+
if (!poll) return false;
|
|
1892
|
+
return new Promise((resolve) => {
|
|
1893
|
+
const startTime = Date.now();
|
|
1894
|
+
const maxDuration = 500;
|
|
1895
|
+
const intervalId = setInterval(() => {
|
|
1896
|
+
const elapsed = Date.now() - startTime;
|
|
1897
|
+
if (attemptFocus()) {
|
|
1898
|
+
clearInterval(intervalId);
|
|
1899
|
+
resolve(true);
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if (elapsed >= maxDuration) {
|
|
1903
|
+
clearInterval(intervalId);
|
|
1904
|
+
resolve(false);
|
|
1905
|
+
}
|
|
1906
|
+
}, 50);
|
|
1907
|
+
});
|
|
1908
|
+
},
|
|
1909
|
+
getInitialOptions() {
|
|
1910
|
+
const userConfig = provider.getConfig();
|
|
1911
|
+
const defaultLayoutState = getDefaultLayoutState();
|
|
1912
|
+
const { theme, selectedPanel, layoutCustomisations } = userConfig;
|
|
1913
|
+
return {
|
|
1914
|
+
...defaultLayoutState,
|
|
1915
|
+
layout: applyLayoutOptions(defaultLayoutState.layout, userConfig.layout, !!singleStory),
|
|
1916
|
+
layoutCustomisations: {
|
|
1917
|
+
...defaultLayoutState.layoutCustomisations,
|
|
1918
|
+
...layoutCustomisations ?? {}
|
|
1919
|
+
},
|
|
1920
|
+
ui: applyUiOptions(defaultLayoutState.ui, userConfig.ui),
|
|
1921
|
+
selectedPanel: selectedPanel || defaultLayoutState.selectedPanel,
|
|
1922
|
+
theme: theme || defaultLayoutState.theme
|
|
1923
|
+
};
|
|
1924
|
+
},
|
|
1925
|
+
getIsFullscreen() {
|
|
1926
|
+
return getIsFullscreen(store.getState());
|
|
1927
|
+
},
|
|
1928
|
+
getIsPanelShown() {
|
|
1929
|
+
return getIsPanelShown(store.getState());
|
|
1930
|
+
},
|
|
1931
|
+
getIsNavShown() {
|
|
1932
|
+
return getIsNavShown(store.getState());
|
|
1933
|
+
},
|
|
1934
|
+
getNavAvailability() {
|
|
1935
|
+
const state = store.getState();
|
|
1936
|
+
if (isReviewManagerRoute(state.path, state.customQueryParams)) return "unavailable";
|
|
1937
|
+
return getIsNavShown(state) ? "shown" : "hidden";
|
|
1938
|
+
},
|
|
1939
|
+
getShowToolbarWithCustomisations(showToolbar) {
|
|
1940
|
+
const state = store.getState();
|
|
1941
|
+
if (isFunction(state.layoutCustomisations.showToolbar)) return state.layoutCustomisations.showToolbar(state, showToolbar) ?? showToolbar;
|
|
1942
|
+
return showToolbar;
|
|
1943
|
+
},
|
|
1944
|
+
getShowPanelWithCustomisations(showPanel) {
|
|
1945
|
+
const state = store.getState();
|
|
1946
|
+
if (isFunction(state.layoutCustomisations.showPanel)) return state.layoutCustomisations.showPanel(state, showPanel) ?? showPanel;
|
|
1947
|
+
return showPanel;
|
|
1948
|
+
},
|
|
1949
|
+
getNavSizeWithCustomisations(navSize) {
|
|
1950
|
+
const state = store.getState();
|
|
1951
|
+
if (isFunction(state.layoutCustomisations.showSidebar)) {
|
|
1952
|
+
const shouldShowNav = state.layoutCustomisations.showSidebar(state, navSize !== 0);
|
|
1953
|
+
if (navSize === 0 && shouldShowNav === true) return state.layout.recentVisibleSizes.navSize;
|
|
1954
|
+
else if (navSize !== 0 && shouldShowNav === false) return 0;
|
|
1955
|
+
}
|
|
1956
|
+
return navSize;
|
|
1957
|
+
},
|
|
1958
|
+
setOptions: (options) => {
|
|
1959
|
+
const { layout, ui, selectedPanel, theme } = store.getState();
|
|
1960
|
+
if (!options) return;
|
|
1961
|
+
const updatedLayout = applyLayoutOptions(layout, options.layout, !!singleStory);
|
|
1962
|
+
const updatedUi = applyUiOptions(ui, options.ui);
|
|
1963
|
+
const updatedTheme = {
|
|
1964
|
+
...theme,
|
|
1965
|
+
...options.theme
|
|
1966
|
+
};
|
|
1967
|
+
const modification = {};
|
|
1968
|
+
if (!isEqual(ui, updatedUi)) modification.ui = updatedUi;
|
|
1969
|
+
if (!isEqual(layout, updatedLayout)) modification.layout = updatedLayout;
|
|
1970
|
+
if (options.selectedPanel && !isEqual(selectedPanel, options.selectedPanel)) modification.selectedPanel = options.selectedPanel;
|
|
1971
|
+
if (Object.keys(modification).length) store.setState(modification, { persistence: "permanent" });
|
|
1972
|
+
if (!isEqual(theme, updatedTheme)) store.setState({ theme: updatedTheme });
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
const persisted = pick(store.getState(), ["layout", "selectedPanel"]);
|
|
1976
|
+
if (persisted.layout) persisted.layout = {
|
|
1977
|
+
...persisted.layout,
|
|
1978
|
+
showMobileNavigation: false
|
|
1979
|
+
};
|
|
1980
|
+
provider.channel?.on(SET_CONFIG, () => {
|
|
1981
|
+
api.setOptions(merge_default(api.getInitialOptions(), persisted));
|
|
1982
|
+
});
|
|
1983
|
+
return {
|
|
1984
|
+
api,
|
|
1985
|
+
state: merge_default(api.getInitialOptions(), persisted)
|
|
1986
|
+
};
|
|
1987
|
+
};
|
|
1988
|
+
})))();
|
|
1989
|
+
}
|
|
1990
|
+
//#endregion
|
|
1991
|
+
//#region src/manager-api/modules/notifications.ts
|
|
1992
|
+
var notifications_exports = /* @__PURE__ */ __exportAll({ init: () => init$8 });
|
|
1993
|
+
var init$8;
|
|
1994
|
+
function init_notifications() {
|
|
1995
|
+
return (init_notifications = __esmMin((() => {
|
|
1996
|
+
init$8 = ({ store }) => {
|
|
1997
|
+
return {
|
|
1998
|
+
api: {
|
|
1999
|
+
addNotification: (newNotification) => {
|
|
2000
|
+
store.setState(({ notifications }) => {
|
|
2001
|
+
const [existing, others] = partition(notifications, (n) => n.id === newNotification.id);
|
|
2002
|
+
existing.forEach((notification) => {
|
|
2003
|
+
if (notification.onClear) notification.onClear({
|
|
2004
|
+
dismissed: false,
|
|
2005
|
+
timeout: false
|
|
2006
|
+
});
|
|
2007
|
+
});
|
|
2008
|
+
return { notifications: [...others, newNotification] };
|
|
2009
|
+
});
|
|
2010
|
+
},
|
|
2011
|
+
clearNotification: (notificationId) => {
|
|
2012
|
+
store.setState(({ notifications }) => {
|
|
2013
|
+
const [matching, others] = partition(notifications, (n) => n.id === notificationId);
|
|
2014
|
+
matching.forEach((notification) => {
|
|
2015
|
+
if (notification.onClear) notification.onClear({
|
|
2016
|
+
dismissed: false,
|
|
2017
|
+
timeout: false
|
|
2018
|
+
});
|
|
2019
|
+
});
|
|
2020
|
+
return { notifications: others };
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
state: { notifications: [] }
|
|
2025
|
+
};
|
|
2026
|
+
};
|
|
2027
|
+
})))();
|
|
2028
|
+
}
|
|
2029
|
+
//#endregion
|
|
2030
|
+
//#region src/manager-api/modules/open-in-editor.tsx
|
|
2031
|
+
var open_in_editor_exports = /* @__PURE__ */ __exportAll({ init: () => init$7 });
|
|
2032
|
+
var import_react$4, init$7;
|
|
2033
|
+
function init_open_in_editor() {
|
|
2034
|
+
return (init_open_in_editor = __esmMin((() => {
|
|
2035
|
+
import_react$4 = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
2036
|
+
init_core_events();
|
|
2037
|
+
init_dist$2();
|
|
2038
|
+
init$7 = ({ provider, fullAPI }) => {
|
|
2039
|
+
return {
|
|
2040
|
+
api: { openInEditor(payload) {
|
|
2041
|
+
return new Promise((resolve) => {
|
|
2042
|
+
const { file, line, column } = payload;
|
|
2043
|
+
const handler = (res) => {
|
|
2044
|
+
if (res.file === file && res.line === line && res.column === column) {
|
|
2045
|
+
provider.channel?.off(OPEN_IN_EDITOR_RESPONSE, handler);
|
|
2046
|
+
resolve(res);
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, handler);
|
|
2050
|
+
provider.channel?.emit(OPEN_IN_EDITOR_REQUEST, payload);
|
|
2051
|
+
});
|
|
2052
|
+
} },
|
|
2053
|
+
state: { notifications: [] },
|
|
2054
|
+
init: async () => {
|
|
2055
|
+
const { color } = await import("./globals-runtime-sGpNlIJ1.js").then((n) => (n.t(), n.n));
|
|
2056
|
+
provider.channel?.on(OPEN_IN_EDITOR_RESPONSE, (payload) => {
|
|
2057
|
+
if (payload.error !== null) fullAPI.addNotification({
|
|
2058
|
+
id: "open-in-editor-error",
|
|
2059
|
+
content: {
|
|
2060
|
+
headline: "Failed to open in editor",
|
|
2061
|
+
subHeadline: payload.error || "Check the Forkbook process on the command line for more details."
|
|
2062
|
+
},
|
|
2063
|
+
icon: /* @__PURE__ */ import_react$4.default.createElement(FailedIcon, { color: color.negative }),
|
|
2064
|
+
duration: 8e3
|
|
2065
|
+
});
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
};
|
|
2069
|
+
};
|
|
2070
|
+
})))();
|
|
2071
|
+
}
|
|
2072
|
+
//#endregion
|
|
2073
|
+
//#region src/manager-api/modules/provider.ts
|
|
2074
|
+
var provider_exports = /* @__PURE__ */ __exportAll({ init: () => init$6 });
|
|
2075
|
+
var init$6;
|
|
2076
|
+
function init_provider() {
|
|
2077
|
+
return (init_provider = __esmMin((() => {
|
|
2078
|
+
init$6 = ({ provider }) => {
|
|
2079
|
+
return {
|
|
2080
|
+
api: provider.renderPreview ? { renderPreview: provider.renderPreview } : {},
|
|
2081
|
+
state: {}
|
|
2082
|
+
};
|
|
2083
|
+
};
|
|
2084
|
+
})))();
|
|
2085
|
+
}
|
|
2086
|
+
//#endregion
|
|
2087
|
+
//#region src/manager-api/modules/settings.ts
|
|
2088
|
+
var settings_exports = /* @__PURE__ */ __exportAll({ init: () => init$5 });
|
|
2089
|
+
var init$5;
|
|
2090
|
+
function init_settings() {
|
|
2091
|
+
return (init_settings = __esmMin((() => {
|
|
2092
|
+
init$5 = ({ store, navigate, fullAPI }) => {
|
|
2093
|
+
const isSettingsScreenActive = () => {
|
|
2094
|
+
const { path } = fullAPI.getUrlState();
|
|
2095
|
+
return !!(path || "").match(/^\/settings/);
|
|
2096
|
+
};
|
|
2097
|
+
return {
|
|
2098
|
+
state: { settings: { lastTrackedStoryId: null } },
|
|
2099
|
+
api: {
|
|
2100
|
+
closeSettings: () => {
|
|
2101
|
+
const { settings: { lastTrackedStoryId } } = store.getState();
|
|
2102
|
+
if (lastTrackedStoryId) fullAPI.selectStory(lastTrackedStoryId);
|
|
2103
|
+
else fullAPI.selectFirstStory();
|
|
2104
|
+
},
|
|
2105
|
+
changeSettingsTab: (path) => {
|
|
2106
|
+
navigate(`/settings/${path}`);
|
|
2107
|
+
},
|
|
2108
|
+
isSettingsScreenActive,
|
|
2109
|
+
retrieveSelection() {
|
|
2110
|
+
const { settings } = store.getState();
|
|
2111
|
+
return settings.lastTrackedStoryId;
|
|
2112
|
+
},
|
|
2113
|
+
storeSelection: async () => {
|
|
2114
|
+
const { storyId, settings } = store.getState();
|
|
2115
|
+
await store.setState({ settings: {
|
|
2116
|
+
...settings,
|
|
2117
|
+
lastTrackedStoryId: storyId
|
|
2118
|
+
} });
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
};
|
|
2123
|
+
})))();
|
|
2124
|
+
}
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/manager-api/lib/platform.ts
|
|
2127
|
+
var navigator$1, isMacLike$1;
|
|
2128
|
+
function init_platform() {
|
|
2129
|
+
return (init_platform = __esmMin((() => {
|
|
2130
|
+
init_dist$1();
|
|
2131
|
+
({navigator: navigator$1} = scope);
|
|
2132
|
+
isMacLike$1 = () => navigator$1 && navigator$1.platform ? !!navigator$1.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false;
|
|
2133
|
+
})))();
|
|
2134
|
+
}
|
|
2135
|
+
//#endregion
|
|
2136
|
+
//#region src/manager-api/lib/shortcut.ts
|
|
2137
|
+
var controlOrMetaSymbol, controlOrMetaKey$1, optionOrAltSymbol, isShortcutTaken, eventToShortcut, shortcutMatchesShortcut, eventMatchesShortcut, keyToSymbol, shortcutToHumanString, shortcutToAriaKeyshortcuts;
|
|
2138
|
+
function init_shortcut() {
|
|
2139
|
+
return (init_shortcut = __esmMin((() => {
|
|
2140
|
+
init_platform();
|
|
2141
|
+
controlOrMetaSymbol = () => isMacLike$1() ? "⌘" : "ctrl";
|
|
2142
|
+
controlOrMetaKey$1 = () => isMacLike$1() ? "meta" : "control";
|
|
2143
|
+
optionOrAltSymbol = () => isMacLike$1() ? "⌥" : "alt";
|
|
2144
|
+
isShortcutTaken = (arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2);
|
|
2145
|
+
eventToShortcut = (e) => {
|
|
2146
|
+
if ([
|
|
2147
|
+
"Meta",
|
|
2148
|
+
"Alt",
|
|
2149
|
+
"Control",
|
|
2150
|
+
"Shift",
|
|
2151
|
+
"Tab"
|
|
2152
|
+
].includes(e.key)) return null;
|
|
2153
|
+
const keys = [];
|
|
2154
|
+
if (e.altKey) keys.push("alt");
|
|
2155
|
+
if (e.ctrlKey) keys.push("control");
|
|
2156
|
+
if (e.metaKey) keys.push("meta");
|
|
2157
|
+
if (e.shiftKey) keys.push("shift");
|
|
2158
|
+
const codeUpper = e.code?.toUpperCase();
|
|
2159
|
+
const codeChar = codeUpper ? codeUpper.startsWith("KEY") && codeUpper.length === 4 ? codeUpper.replace("KEY", "") : codeUpper.startsWith("DIGIT") ? codeUpper.replace("DIGIT", "") : {
|
|
2160
|
+
MINUS: "-",
|
|
2161
|
+
EQUAL: "=",
|
|
2162
|
+
BRACKETLEFT: "[",
|
|
2163
|
+
BRACKETRIGHT: "]",
|
|
2164
|
+
BACKSLASH: "\\",
|
|
2165
|
+
SEMICOLON: ";",
|
|
2166
|
+
QUOTE: "'",
|
|
2167
|
+
BACKQUOTE: "`",
|
|
2168
|
+
COMMA: ",",
|
|
2169
|
+
PERIOD: ".",
|
|
2170
|
+
SLASH: "/"
|
|
2171
|
+
}[codeUpper] : void 0;
|
|
2172
|
+
if (e.key && e.key.length === 1 && e.key !== " ") {
|
|
2173
|
+
const key = e.key.toUpperCase();
|
|
2174
|
+
const code = codeChar;
|
|
2175
|
+
if (code && code.length === 1 && code !== key) keys.push([key, code]);
|
|
2176
|
+
else keys.push(key);
|
|
2177
|
+
} else if (e.key === "Dead" && codeChar) keys.push(codeChar);
|
|
2178
|
+
if (e.key === " ") keys.push("space");
|
|
2179
|
+
if (e.key === "Escape") keys.push("escape");
|
|
2180
|
+
if (e.key === "ArrowRight") keys.push("ArrowRight");
|
|
2181
|
+
if (e.key === "ArrowDown") keys.push("ArrowDown");
|
|
2182
|
+
if (e.key === "ArrowUp") keys.push("ArrowUp");
|
|
2183
|
+
if (e.key === "ArrowLeft") keys.push("ArrowLeft");
|
|
2184
|
+
return keys.length > 0 ? keys : null;
|
|
2185
|
+
};
|
|
2186
|
+
shortcutMatchesShortcut = (inputShortcut, shortcut) => {
|
|
2187
|
+
if (!inputShortcut || !shortcut) return false;
|
|
2188
|
+
if (inputShortcut.join("").startsWith("shift/")) inputShortcut.shift();
|
|
2189
|
+
if (inputShortcut.length !== shortcut.length) return false;
|
|
2190
|
+
return !inputShortcut.find((input, i) => Array.isArray(input) ? !input.includes(shortcut[i]) : input !== shortcut[i]);
|
|
2191
|
+
};
|
|
2192
|
+
eventMatchesShortcut = (e, shortcut) => {
|
|
2193
|
+
return shortcutMatchesShortcut(eventToShortcut(e), shortcut);
|
|
2194
|
+
};
|
|
2195
|
+
keyToSymbol = (key) => {
|
|
2196
|
+
if (key === "alt") return optionOrAltSymbol();
|
|
2197
|
+
if (key === "control") return "⌃";
|
|
2198
|
+
if (key === "meta") return "⌘";
|
|
2199
|
+
if (key === "shift") return "⇧";
|
|
2200
|
+
if (key === "Enter" || key === "Backspace" || key === "Esc") return "";
|
|
2201
|
+
if (key === " ") return "SPACE";
|
|
2202
|
+
if (key === "ArrowUp") return "↑";
|
|
2203
|
+
if (key === "ArrowDown") return "↓";
|
|
2204
|
+
if (key === "ArrowLeft") return "←";
|
|
2205
|
+
if (key === "ArrowRight") return "→";
|
|
2206
|
+
return key?.toUpperCase();
|
|
2207
|
+
};
|
|
2208
|
+
shortcutToHumanString = (shortcut) => {
|
|
2209
|
+
return shortcut.map(keyToSymbol).join(" ");
|
|
2210
|
+
};
|
|
2211
|
+
shortcutToAriaKeyshortcuts = (shortcut) => {
|
|
2212
|
+
return shortcut.map((shortcut) => {
|
|
2213
|
+
if (shortcut === "+") return "plus";
|
|
2214
|
+
if (shortcut === " ") return "space";
|
|
2215
|
+
return shortcut;
|
|
2216
|
+
}).join("+");
|
|
2217
|
+
};
|
|
2218
|
+
})))();
|
|
2219
|
+
}
|
|
2220
|
+
//#endregion
|
|
2221
|
+
//#region src/manager-api/modules/shortcuts.ts
|
|
2222
|
+
var shortcuts_exports = /* @__PURE__ */ __exportAll({
|
|
2223
|
+
controlOrMetaKey: () => controlOrMetaKey,
|
|
2224
|
+
defaultShortcuts: () => defaultShortcuts,
|
|
2225
|
+
init: () => init$4,
|
|
2226
|
+
isMacLike: () => isMacLike,
|
|
2227
|
+
keys: () => keys
|
|
2228
|
+
});
|
|
2229
|
+
function wasFocusInElement(element) {
|
|
2230
|
+
return document$1.activeElement && element?.contains(document$1.activeElement);
|
|
2231
|
+
}
|
|
2232
|
+
function keys(o) {
|
|
2233
|
+
return Object.keys(o);
|
|
2234
|
+
}
|
|
2235
|
+
function shouldSkipShortcut(event) {
|
|
2236
|
+
const target = event.target;
|
|
2237
|
+
if (/input|textarea/i.test(target.tagName) || target.getAttribute("contenteditable") !== null) return true;
|
|
2238
|
+
if (target.closest("dialog[open]")) return true;
|
|
2239
|
+
return false;
|
|
2240
|
+
}
|
|
2241
|
+
var import_copy_to_clipboard, navigator, document$1, isMacLike, controlOrMetaKey, defaultShortcuts, addonsShortcuts, init$4;
|
|
2242
|
+
function init_shortcuts() {
|
|
2243
|
+
return (init_shortcuts = __esmMin((() => {
|
|
2244
|
+
init_core_events();
|
|
2245
|
+
init_dist$1();
|
|
2246
|
+
import_copy_to_clipboard = /* @__PURE__ */ __toESM(require_copy_to_clipboard(), 1);
|
|
2247
|
+
init_client_logger();
|
|
2248
|
+
init_shortcut();
|
|
2249
|
+
init_layout();
|
|
2250
|
+
({navigator, document: document$1} = scope);
|
|
2251
|
+
isMacLike = () => navigator && navigator.platform ? !!navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i) : false;
|
|
2252
|
+
controlOrMetaKey = () => isMacLike() ? "meta" : "control";
|
|
2253
|
+
defaultShortcuts = Object.freeze({
|
|
2254
|
+
fullScreen: ["alt", "F"],
|
|
2255
|
+
togglePanel: ["alt", "A"],
|
|
2256
|
+
panelPosition: ["alt", "D"],
|
|
2257
|
+
toggleNav: ["alt", "S"],
|
|
2258
|
+
toolbar: ["alt", "T"],
|
|
2259
|
+
search: [controlOrMetaKey(), "K"],
|
|
2260
|
+
focusNav: ["1"],
|
|
2261
|
+
focusIframe: ["2"],
|
|
2262
|
+
focusPanel: ["3"],
|
|
2263
|
+
prevComponent: ["alt", "ArrowUp"],
|
|
2264
|
+
nextComponent: ["alt", "ArrowDown"],
|
|
2265
|
+
prevStory: ["alt", "ArrowLeft"],
|
|
2266
|
+
nextStory: ["alt", "ArrowRight"],
|
|
2267
|
+
shortcutsPage: [
|
|
2268
|
+
controlOrMetaKey(),
|
|
2269
|
+
"shift",
|
|
2270
|
+
","
|
|
2271
|
+
],
|
|
2272
|
+
aboutPage: [controlOrMetaKey(), ","],
|
|
2273
|
+
collapseAll: [
|
|
2274
|
+
controlOrMetaKey(),
|
|
2275
|
+
"shift",
|
|
2276
|
+
"ArrowUp"
|
|
2277
|
+
],
|
|
2278
|
+
expandAll: [
|
|
2279
|
+
controlOrMetaKey(),
|
|
2280
|
+
"shift",
|
|
2281
|
+
"ArrowDown"
|
|
2282
|
+
],
|
|
2283
|
+
remount: ["alt", "R"],
|
|
2284
|
+
openInEditor: [
|
|
2285
|
+
"alt",
|
|
2286
|
+
"shift",
|
|
2287
|
+
"E"
|
|
2288
|
+
],
|
|
2289
|
+
openInIsolation: [
|
|
2290
|
+
"alt",
|
|
2291
|
+
"shift",
|
|
2292
|
+
"I"
|
|
2293
|
+
],
|
|
2294
|
+
copyStoryLink: [
|
|
2295
|
+
"alt",
|
|
2296
|
+
"shift",
|
|
2297
|
+
"L"
|
|
2298
|
+
],
|
|
2299
|
+
goToPreviousLandmark: ["shift", "F6"],
|
|
2300
|
+
goToNextLandmark: ["F6"]
|
|
2301
|
+
});
|
|
2302
|
+
addonsShortcuts = {};
|
|
2303
|
+
init$4 = ({ store, fullAPI, provider }) => {
|
|
2304
|
+
const api = {
|
|
2305
|
+
getShortcutKeys() {
|
|
2306
|
+
return store.getState().shortcuts;
|
|
2307
|
+
},
|
|
2308
|
+
getDefaultShortcuts() {
|
|
2309
|
+
return {
|
|
2310
|
+
...defaultShortcuts,
|
|
2311
|
+
...api.getAddonsShortcutDefaults()
|
|
2312
|
+
};
|
|
2313
|
+
},
|
|
2314
|
+
getAddonsShortcuts() {
|
|
2315
|
+
return addonsShortcuts;
|
|
2316
|
+
},
|
|
2317
|
+
getAddonsShortcutLabels() {
|
|
2318
|
+
const labels = {};
|
|
2319
|
+
Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => {
|
|
2320
|
+
labels[actionName] = label;
|
|
2321
|
+
});
|
|
2322
|
+
return labels;
|
|
2323
|
+
},
|
|
2324
|
+
getAddonsShortcutDefaults() {
|
|
2325
|
+
const defaults = {};
|
|
2326
|
+
Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => {
|
|
2327
|
+
defaults[actionName] = defaultShortcut;
|
|
2328
|
+
});
|
|
2329
|
+
return defaults;
|
|
2330
|
+
},
|
|
2331
|
+
async setShortcuts(update) {
|
|
2332
|
+
const { shortcuts } = await store.setState((state) => ({ shortcuts: typeof update === "function" ? update(state.shortcuts) : update }), { persistence: "permanent" });
|
|
2333
|
+
return shortcuts;
|
|
2334
|
+
},
|
|
2335
|
+
async restoreAllDefaultShortcuts() {
|
|
2336
|
+
return api.setShortcuts(api.getDefaultShortcuts());
|
|
2337
|
+
},
|
|
2338
|
+
async setShortcut(action, value) {
|
|
2339
|
+
await api.setShortcuts((shortcuts) => ({
|
|
2340
|
+
...shortcuts,
|
|
2341
|
+
[action]: value
|
|
2342
|
+
}));
|
|
2343
|
+
return value;
|
|
2344
|
+
},
|
|
2345
|
+
async setAddonShortcut(addon, shortcut) {
|
|
2346
|
+
await api.setShortcuts((shortcuts) => ({
|
|
2347
|
+
...shortcuts,
|
|
2348
|
+
[`${addon}-${shortcut.actionName}`]: shortcut.defaultShortcut
|
|
2349
|
+
}));
|
|
2350
|
+
addonsShortcuts[`${addon}-${shortcut.actionName}`] = shortcut;
|
|
2351
|
+
return shortcut;
|
|
2352
|
+
},
|
|
2353
|
+
async restoreDefaultShortcut(action) {
|
|
2354
|
+
const defaultShortcut = api.getDefaultShortcuts()[action];
|
|
2355
|
+
return api.setShortcut(action, defaultShortcut);
|
|
2356
|
+
},
|
|
2357
|
+
handleKeydownEvent(event) {
|
|
2358
|
+
if (!store.getState().ui.enableShortcuts) return;
|
|
2359
|
+
const shortcut = eventToShortcut(event);
|
|
2360
|
+
const shortcuts = api.getShortcutKeys();
|
|
2361
|
+
const matchedFeature = keys(shortcuts).find((feature) => {
|
|
2362
|
+
if (!shortcutMatchesShortcut(shortcut, shortcuts[feature])) return false;
|
|
2363
|
+
if (fullAPI.getNavAvailability() === "unavailable" && [
|
|
2364
|
+
"focusNav",
|
|
2365
|
+
"search",
|
|
2366
|
+
"toggleNav"
|
|
2367
|
+
].includes(feature)) return false;
|
|
2368
|
+
if (!(feature in defaultShortcuts)) return feature in addonsShortcuts;
|
|
2369
|
+
return true;
|
|
2370
|
+
});
|
|
2371
|
+
if (matchedFeature) api.handleShortcutFeature(matchedFeature, event);
|
|
2372
|
+
return matchedFeature;
|
|
2373
|
+
},
|
|
2374
|
+
handleShortcutFeature(feature, event) {
|
|
2375
|
+
const { ui: { enableShortcuts }, storyId, refId, viewMode } = store.getState();
|
|
2376
|
+
if (!enableShortcuts) return;
|
|
2377
|
+
const isSidebarShortcutBlocked = fullAPI.getNavAvailability() === "unavailable";
|
|
2378
|
+
const isSidebarShortcutFeature = [
|
|
2379
|
+
"focusNav",
|
|
2380
|
+
"search",
|
|
2381
|
+
"toggleNav"
|
|
2382
|
+
].includes(feature);
|
|
2383
|
+
if (isSidebarShortcutBlocked && isSidebarShortcutFeature) return;
|
|
2384
|
+
if (event?.preventDefault) event.preventDefault();
|
|
2385
|
+
switch (feature) {
|
|
2386
|
+
case "goToNextLandmark":
|
|
2387
|
+
case "goToPreviousLandmark": break;
|
|
2388
|
+
case "focusNav":
|
|
2389
|
+
if (fullAPI.getIsFullscreen()) fullAPI.toggleFullscreen(false);
|
|
2390
|
+
if (!fullAPI.getIsNavShown()) fullAPI.toggleNav(true);
|
|
2391
|
+
fullAPI.focusOnUIElement(focusableUIElements.storyListMenu);
|
|
2392
|
+
break;
|
|
2393
|
+
case "search":
|
|
2394
|
+
if (fullAPI.getIsFullscreen()) fullAPI.toggleFullscreen(false);
|
|
2395
|
+
if (!fullAPI.getIsNavShown()) fullAPI.toggleNav(true);
|
|
2396
|
+
setTimeout(() => {
|
|
2397
|
+
fullAPI.focusOnUIElement(focusableUIElements.storySearchField, true);
|
|
2398
|
+
}, 0);
|
|
2399
|
+
break;
|
|
2400
|
+
case "focusIframe": {
|
|
2401
|
+
const element = document$1.getElementById("storybook-preview-iframe");
|
|
2402
|
+
if (element) try {
|
|
2403
|
+
element.contentWindow.focus();
|
|
2404
|
+
} catch (e) {}
|
|
2405
|
+
break;
|
|
2406
|
+
}
|
|
2407
|
+
case "focusPanel":
|
|
2408
|
+
if (fullAPI.getIsFullscreen()) fullAPI.toggleFullscreen(false);
|
|
2409
|
+
if (!fullAPI.getIsPanelShown()) fullAPI.togglePanel(true);
|
|
2410
|
+
fullAPI.focusOnUIElement(focusableUIElements.storyPanelRoot);
|
|
2411
|
+
break;
|
|
2412
|
+
case "nextStory":
|
|
2413
|
+
fullAPI.jumpToStory(1);
|
|
2414
|
+
break;
|
|
2415
|
+
case "prevStory":
|
|
2416
|
+
fullAPI.jumpToStory(-1);
|
|
2417
|
+
break;
|
|
2418
|
+
case "nextComponent":
|
|
2419
|
+
fullAPI.jumpToComponent(1);
|
|
2420
|
+
break;
|
|
2421
|
+
case "prevComponent":
|
|
2422
|
+
fullAPI.jumpToComponent(-1);
|
|
2423
|
+
break;
|
|
2424
|
+
case "fullScreen":
|
|
2425
|
+
fullAPI.toggleFullscreen();
|
|
2426
|
+
break;
|
|
2427
|
+
case "togglePanel": {
|
|
2428
|
+
const wasPanelShown = fullAPI.getIsPanelShown();
|
|
2429
|
+
const panelElement = document$1.getElementById(focusableUIElements.addonPanel);
|
|
2430
|
+
fullAPI.togglePanel();
|
|
2431
|
+
if (wasPanelShown && wasFocusInElement(panelElement)) fullAPI.focusOnUIElement(focusableUIElements.showAddonPanel, { poll: true }).then((success) => {
|
|
2432
|
+
if (success === false) document$1.body.focus();
|
|
2433
|
+
});
|
|
2434
|
+
if (!wasPanelShown) fullAPI.focusOnUIElement(focusableUIElements.addonPanel, {
|
|
2435
|
+
forceFocus: true,
|
|
2436
|
+
poll: true
|
|
2437
|
+
});
|
|
2438
|
+
break;
|
|
2439
|
+
}
|
|
2440
|
+
case "toggleNav": {
|
|
2441
|
+
const isDesktop = isDesktopViewport();
|
|
2442
|
+
const wasNavShown = fullAPI.getIsNavShown();
|
|
2443
|
+
const sidebarElement = document$1.getElementById(focusableUIElements.sidebarRegion);
|
|
2444
|
+
fullAPI.toggleNav();
|
|
2445
|
+
if (isDesktop) {
|
|
2446
|
+
if (wasNavShown && wasFocusInElement(sidebarElement)) fullAPI.focusOnUIElement(focusableUIElements.showSidebar, { poll: true }).then((success) => {
|
|
2447
|
+
if (success === false) document$1.body.focus();
|
|
2448
|
+
});
|
|
2449
|
+
if (!wasNavShown) fullAPI.focusOnUIElement(focusableUIElements.sidebarRegion, {
|
|
2450
|
+
forceFocus: true,
|
|
2451
|
+
poll: true
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
break;
|
|
2455
|
+
}
|
|
2456
|
+
case "toolbar":
|
|
2457
|
+
fullAPI.toggleToolbar();
|
|
2458
|
+
break;
|
|
2459
|
+
case "panelPosition":
|
|
2460
|
+
if (fullAPI.getIsFullscreen()) fullAPI.toggleFullscreen(false);
|
|
2461
|
+
if (!fullAPI.getIsPanelShown()) fullAPI.togglePanel(true);
|
|
2462
|
+
fullAPI.togglePanelPosition();
|
|
2463
|
+
break;
|
|
2464
|
+
case "aboutPage":
|
|
2465
|
+
fullAPI.navigate("/settings/about");
|
|
2466
|
+
break;
|
|
2467
|
+
case "shortcutsPage":
|
|
2468
|
+
fullAPI.navigate("/settings/shortcuts");
|
|
2469
|
+
break;
|
|
2470
|
+
case "collapseAll":
|
|
2471
|
+
fullAPI.emit(STORIES_COLLAPSE_ALL);
|
|
2472
|
+
break;
|
|
2473
|
+
case "expandAll":
|
|
2474
|
+
fullAPI.emit(STORIES_EXPAND_ALL);
|
|
2475
|
+
break;
|
|
2476
|
+
case "remount":
|
|
2477
|
+
fullAPI.emit(FORCE_REMOUNT, { storyId });
|
|
2478
|
+
break;
|
|
2479
|
+
case "openInEditor":
|
|
2480
|
+
if (scope.CONFIG_TYPE === "DEVELOPMENT") fullAPI.openInEditor({ file: fullAPI.getCurrentStoryData().importPath });
|
|
2481
|
+
break;
|
|
2482
|
+
case "openInIsolation":
|
|
2483
|
+
if (storyId && viewMode === "story") {
|
|
2484
|
+
const { previewHref } = fullAPI.getStoryHrefs(storyId, { refId });
|
|
2485
|
+
window.open(previewHref, "_blank", "noopener,noreferrer");
|
|
2486
|
+
}
|
|
2487
|
+
break;
|
|
2488
|
+
case "copyStoryLink":
|
|
2489
|
+
if (storyId) {
|
|
2490
|
+
const { managerHref } = fullAPI.getStoryHrefs(storyId, { refId });
|
|
2491
|
+
(0, import_copy_to_clipboard.default)(managerHref);
|
|
2492
|
+
}
|
|
2493
|
+
break;
|
|
2494
|
+
default: if (feature in addonsShortcuts) addonsShortcuts[feature].action();
|
|
2495
|
+
else logger.warn(`api.handleShortcutFeature called with unknown feature: ${feature}.`);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
const { shortcuts: persistedShortcuts = defaultShortcuts } = store.getState();
|
|
2500
|
+
const state = { shortcuts: keys(defaultShortcuts).reduce((acc, key) => ({
|
|
2501
|
+
...acc,
|
|
2502
|
+
[key]: persistedShortcuts[key] || defaultShortcuts[key]
|
|
2503
|
+
}), defaultShortcuts) };
|
|
2504
|
+
const initModule = () => {
|
|
2505
|
+
document$1.addEventListener("keydown", (event) => {
|
|
2506
|
+
if (!shouldSkipShortcut(event)) {
|
|
2507
|
+
const matched = api.handleKeydownEvent(event);
|
|
2508
|
+
if (matched && matched !== "goToNextLandmark" && matched !== "goToPreviousLandmark") event.stopPropagation();
|
|
2509
|
+
}
|
|
2510
|
+
}, { capture: true });
|
|
2511
|
+
window.addEventListener("keydown", (event) => {
|
|
2512
|
+
if (event.key === "Escape" && !event.defaultPrevented && !shouldSkipShortcut(event) && store.getState().ui.enableShortcuts && fullAPI.getIsFullscreen()) {
|
|
2513
|
+
event.preventDefault();
|
|
2514
|
+
fullAPI.toggleFullscreen(false);
|
|
2515
|
+
}
|
|
2516
|
+
});
|
|
2517
|
+
provider.channel?.on(PREVIEW_KEYDOWN, (data) => {
|
|
2518
|
+
api.handleKeydownEvent(data.event);
|
|
2519
|
+
if (data.event.key === "Escape" && store.getState().ui.enableShortcuts && fullAPI.getIsFullscreen()) fullAPI.toggleFullscreen(false);
|
|
2520
|
+
});
|
|
2521
|
+
};
|
|
2522
|
+
return {
|
|
2523
|
+
api,
|
|
2524
|
+
state,
|
|
2525
|
+
init: initModule
|
|
2526
|
+
};
|
|
2527
|
+
};
|
|
2528
|
+
})))();
|
|
2529
|
+
}
|
|
2530
|
+
//#endregion
|
|
2531
|
+
//#region src/manager-api/lib/url.ts
|
|
2532
|
+
var buildNavigationUrl;
|
|
2533
|
+
function init_url() {
|
|
2534
|
+
return (init_url = __esmMin((() => {
|
|
2535
|
+
buildNavigationUrl = (path, queryParams = {}) => {
|
|
2536
|
+
return [path, ...Object.entries(queryParams).filter(([k, v]) => k !== "path" && v !== null && v !== void 0).sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${k}=${v}`)].join("&");
|
|
2537
|
+
};
|
|
2538
|
+
})))();
|
|
2539
|
+
}
|
|
2540
|
+
//#endregion
|
|
2541
|
+
//#region src/manager-api/stores/status.ts
|
|
2542
|
+
var statusStore, fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore;
|
|
2543
|
+
function init_status() {
|
|
2544
|
+
return (init_status = __esmMin((() => {
|
|
2545
|
+
init_status_store();
|
|
2546
|
+
init_universal_store();
|
|
2547
|
+
init_use_universal_store_manager();
|
|
2548
|
+
statusStore = createStatusStore({
|
|
2549
|
+
universalStatusStore: UniversalStore.create({
|
|
2550
|
+
...UNIVERSAL_STATUS_STORE_OPTIONS,
|
|
2551
|
+
leader: globalThis.CONFIG_TYPE === "PRODUCTION"
|
|
2552
|
+
}),
|
|
2553
|
+
useUniversalStore,
|
|
2554
|
+
environment: "manager"
|
|
2555
|
+
});
|
|
2556
|
+
({fullStatusStore, getStatusStoreByTypeId, useStatusStore, universalStatusStore} = statusStore);
|
|
2557
|
+
})))();
|
|
2558
|
+
}
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region src/manager-api/lib/filter-param.ts
|
|
2561
|
+
var parseFilterParam;
|
|
2562
|
+
function init_filter_param() {
|
|
2563
|
+
return (init_filter_param = __esmMin((() => {
|
|
2564
|
+
parseFilterParam = (param, transform) => {
|
|
2565
|
+
if (!param) return {
|
|
2566
|
+
included: [],
|
|
2567
|
+
excluded: []
|
|
2568
|
+
};
|
|
2569
|
+
const included = [];
|
|
2570
|
+
const excluded = [];
|
|
2571
|
+
param.split(";").forEach((raw) => {
|
|
2572
|
+
if (!raw) return;
|
|
2573
|
+
const isExcluded = raw.startsWith("!");
|
|
2574
|
+
const value = transform(isExcluded ? raw.slice(1) : raw);
|
|
2575
|
+
if (value == null) return;
|
|
2576
|
+
if (isExcluded) excluded.push(value);
|
|
2577
|
+
else included.push(value);
|
|
2578
|
+
});
|
|
2579
|
+
return {
|
|
2580
|
+
included,
|
|
2581
|
+
excluded
|
|
2582
|
+
};
|
|
2583
|
+
};
|
|
2584
|
+
})))();
|
|
2585
|
+
}
|
|
2586
|
+
//#endregion
|
|
2587
|
+
//#region src/manager-api/modules/statuses.ts
|
|
2588
|
+
var parseStatusesParam, serializeStatusesParam, computeStatusFilterFn;
|
|
2589
|
+
function init_statuses() {
|
|
2590
|
+
return (init_statuses = __esmMin((() => {
|
|
2591
|
+
init_status_store();
|
|
2592
|
+
init_filter_param();
|
|
2593
|
+
init_status();
|
|
2594
|
+
parseStatusesParam = (statusesParam) => parseFilterParam(statusesParam, toStatusValue);
|
|
2595
|
+
serializeStatusesParam = (included, excluded) => {
|
|
2596
|
+
if (!included.length && !excluded.length) return;
|
|
2597
|
+
const serializedIncluded = included.map((v) => statusValueShortName(v)).sort();
|
|
2598
|
+
const serializedExcluded = excluded.map((v) => `!${statusValueShortName(v)}`).sort();
|
|
2599
|
+
return [...serializedIncluded, ...serializedExcluded].join(";");
|
|
2600
|
+
};
|
|
2601
|
+
computeStatusFilterFn = (includedStatusFilters, excludedStatusFilters) => {
|
|
2602
|
+
return (entry) => {
|
|
2603
|
+
if (!includedStatusFilters.length && !excludedStatusFilters.length) return true;
|
|
2604
|
+
const storyStatuses = (fullStatusStore.getAll() ?? {})[entry.id];
|
|
2605
|
+
const storyStatusValues = storyStatuses ? Object.values(storyStatuses).map((s) => s.value) : [];
|
|
2606
|
+
const passesInclude = !includedStatusFilters.length || includedStatusFilters.some((v) => storyStatusValues.includes(v));
|
|
2607
|
+
const passesExclude = !excludedStatusFilters.length || excludedStatusFilters.every((v) => !storyStatusValues.includes(v));
|
|
2608
|
+
return passesInclude && passesExclude;
|
|
2609
|
+
};
|
|
2610
|
+
};
|
|
2611
|
+
})))();
|
|
2612
|
+
}
|
|
2613
|
+
//#endregion
|
|
2614
|
+
//#region src/manager-api/modules/tags.ts
|
|
2615
|
+
var import_memoizerific$1, BUILT_IN_URL_TAG_MAP, parseTagsParam, serializeTagsParam, getDefaultTagsFromPreset, computeStaticFilterFn, computeTagsFilterFn;
|
|
2616
|
+
function init_tags() {
|
|
2617
|
+
return (init_tags = __esmMin((() => {
|
|
2618
|
+
import_memoizerific$1 = /* @__PURE__ */ __toESM(require_memoizerific(), 1);
|
|
2619
|
+
init_filter_param();
|
|
2620
|
+
init_tags$1();
|
|
2621
|
+
BUILT_IN_URL_TAG_MAP = {
|
|
2622
|
+
$docs: "_docs",
|
|
2623
|
+
$play: "_play",
|
|
2624
|
+
$test: "_test"
|
|
2625
|
+
};
|
|
2626
|
+
parseTagsParam = (tagsParam) => parseFilterParam(tagsParam, (raw) => BUILT_IN_URL_TAG_MAP[raw] ?? raw);
|
|
2627
|
+
serializeTagsParam = (included, excluded) => {
|
|
2628
|
+
if (!included.length && !excluded.length) return "";
|
|
2629
|
+
const reverseBuiltInUrlTagMap = Object.fromEntries(Object.entries(BUILT_IN_URL_TAG_MAP).map(([urlTag, internalTag]) => [internalTag, urlTag]));
|
|
2630
|
+
const serializedIncluded = included.map((tag) => reverseBuiltInUrlTagMap[tag] ?? tag).sort();
|
|
2631
|
+
const serializedExcluded = excluded.map((tag) => `!${reverseBuiltInUrlTagMap[tag] ?? tag}`).sort();
|
|
2632
|
+
return [...serializedIncluded, ...serializedExcluded].join(";");
|
|
2633
|
+
};
|
|
2634
|
+
getDefaultTagsFromPreset = (0, import_memoizerific$1.default)(1)((presets) => {
|
|
2635
|
+
const presetEntries = Object.entries(presets);
|
|
2636
|
+
return {
|
|
2637
|
+
included: presetEntries.filter(([, option]) => option.defaultFilterSelection === "include").map(([tag]) => tag),
|
|
2638
|
+
excluded: presetEntries.filter(([, option]) => option.defaultFilterSelection === "exclude").map(([tag]) => tag)
|
|
2639
|
+
};
|
|
2640
|
+
});
|
|
2641
|
+
computeStaticFilterFn = (tagPresets) => {
|
|
2642
|
+
const staticExcludeTags = Object.entries(tagPresets).reduce((acc, [tag, option]) => {
|
|
2643
|
+
if (option.hideFromSidebar) acc[tag] = true;
|
|
2644
|
+
return acc;
|
|
2645
|
+
}, {});
|
|
2646
|
+
return (item) => {
|
|
2647
|
+
const tags = item.tags ?? [];
|
|
2648
|
+
const isCsfAutodocsEntry = item.type === "docs" && !tags.includes(Tag.ATTACHED_MDX) && !tags.includes(Tag.UNATTACHED_MDX);
|
|
2649
|
+
return (tags.includes(Tag.DEV) || isCsfAutodocsEntry) && tags.filter((tag) => staticExcludeTags[tag]).length === 0;
|
|
2650
|
+
};
|
|
2651
|
+
};
|
|
2652
|
+
computeTagsFilterFn = (includedTagFilters, excludedTagFilters) => {
|
|
2653
|
+
const computeFilterFunctions = (set) => {
|
|
2654
|
+
return Object.values(set.reduce((acc, tag) => {
|
|
2655
|
+
if (Object.hasOwn(BUILT_IN_FILTERS, tag)) acc["built-in"].push(BUILT_IN_FILTERS[tag]);
|
|
2656
|
+
else acc.user.push(USER_TAG_FILTER(tag));
|
|
2657
|
+
return acc;
|
|
2658
|
+
}, {
|
|
2659
|
+
"built-in": [],
|
|
2660
|
+
user: []
|
|
2661
|
+
})).filter((group) => group.length > 0);
|
|
2662
|
+
};
|
|
2663
|
+
return (item) => {
|
|
2664
|
+
const included = computeFilterFunctions(includedTagFilters);
|
|
2665
|
+
const excluded = computeFilterFunctions(excludedTagFilters);
|
|
2666
|
+
return (!included.length || included.every((group) => group.some((filterFn) => filterFn(item, false)))) && (!excluded.length || excluded.every((group) => group.every((filterFn) => filterFn(item, true))));
|
|
2667
|
+
};
|
|
2668
|
+
};
|
|
2669
|
+
})))();
|
|
2670
|
+
}
|
|
2671
|
+
//#endregion
|
|
2672
|
+
//#region src/manager-api/modules/stories.ts
|
|
2673
|
+
var stories_exports = /* @__PURE__ */ __exportAll({ init: () => init$3 });
|
|
2674
|
+
function removeRemovedOptions(options) {
|
|
2675
|
+
if (!options || typeof options === "string") return options;
|
|
2676
|
+
const result = { ...options };
|
|
2677
|
+
removedOptions.forEach((option) => {
|
|
2678
|
+
if (option in result) delete result[option];
|
|
2679
|
+
});
|
|
2680
|
+
return result;
|
|
2681
|
+
}
|
|
2682
|
+
var fetch, STORY_INDEX_PATH, TAGS_FILTER, STATIC_FILTER, STATUS_FILTER, STATUS_CHANGE_REBUILD_THROTTLE, BUILT_IN_TAG_IDS, removedOptions, FILTER_KEYS, init$3;
|
|
2683
|
+
function init_stories$1() {
|
|
2684
|
+
return (init_stories$1 = __esmMin((() => {
|
|
2685
|
+
init_client_logger();
|
|
2686
|
+
init_core_events();
|
|
2687
|
+
init_csf_utils();
|
|
2688
|
+
init_router();
|
|
2689
|
+
init_routes();
|
|
2690
|
+
init_dist$1();
|
|
2691
|
+
init_throttle();
|
|
2692
|
+
init_tags$1();
|
|
2693
|
+
init_status_store();
|
|
2694
|
+
init_events();
|
|
2695
|
+
init_stories();
|
|
2696
|
+
init_url();
|
|
2697
|
+
init_status();
|
|
2698
|
+
init_statuses();
|
|
2699
|
+
init_tags();
|
|
2700
|
+
({fetch} = scope);
|
|
2701
|
+
STORY_INDEX_PATH = "./index.json";
|
|
2702
|
+
TAGS_FILTER = "tags-filter";
|
|
2703
|
+
STATIC_FILTER = "static-filter";
|
|
2704
|
+
STATUS_FILTER = "status-filter";
|
|
2705
|
+
STATUS_CHANGE_REBUILD_THROTTLE = 500;
|
|
2706
|
+
BUILT_IN_TAG_IDS = new Set(Object.keys(BUILT_IN_FILTERS));
|
|
2707
|
+
removedOptions = [
|
|
2708
|
+
"enableShortcuts",
|
|
2709
|
+
"theme",
|
|
2710
|
+
"showRoots"
|
|
2711
|
+
];
|
|
2712
|
+
FILTER_KEYS = {
|
|
2713
|
+
tag: {
|
|
2714
|
+
included: "includedTagFilters",
|
|
2715
|
+
excluded: "excludedTagFilters"
|
|
2716
|
+
},
|
|
2717
|
+
status: {
|
|
2718
|
+
included: "includedStatusFilters",
|
|
2719
|
+
excluded: "excludedStatusFilters"
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
init$3 = ({ fullAPI, store, navigate, provider, state: { location } = {}, storyId: initialStoryId, viewMode: initialViewMode, docsOptions = {} }) => {
|
|
2723
|
+
const navigateWithQueryParams = (path, options) => {
|
|
2724
|
+
const { customQueryParams } = store.getState();
|
|
2725
|
+
navigate(buildNavigationUrl(path, customQueryParams ?? {}), options);
|
|
2726
|
+
};
|
|
2727
|
+
const persistFilters = (inputPatch) => {
|
|
2728
|
+
return store.setState(inputPatch, {
|
|
2729
|
+
persistence: "url",
|
|
2730
|
+
serialize: (s) => {
|
|
2731
|
+
const tagsValue = serializeTagsParam(s.includedTagFilters, s.excludedTagFilters);
|
|
2732
|
+
const statusesValue = serializeStatusesParam(s.includedStatusFilters, s.excludedStatusFilters);
|
|
2733
|
+
return {
|
|
2734
|
+
tags: tagsValue ?? null,
|
|
2735
|
+
statuses: statusesValue ?? null
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
});
|
|
2739
|
+
};
|
|
2740
|
+
let urlFilterTelemetryEmitted = false;
|
|
2741
|
+
const addFilters = async (type, items, excluded) => {
|
|
2742
|
+
const { included, excluded: excludedKey } = FILTER_KEYS[type];
|
|
2743
|
+
const state = store.getState();
|
|
2744
|
+
const newIncluded = new Set(state[included]);
|
|
2745
|
+
const newExcluded = new Set(state[excludedKey]);
|
|
2746
|
+
for (const item of items) {
|
|
2747
|
+
const [target, other] = excluded ? [newExcluded, newIncluded] : [newIncluded, newExcluded];
|
|
2748
|
+
other.delete(item);
|
|
2749
|
+
target.add(item);
|
|
2750
|
+
}
|
|
2751
|
+
await persistFilters({
|
|
2752
|
+
[included]: Array.from(newIncluded),
|
|
2753
|
+
[excludedKey]: Array.from(newExcluded)
|
|
2754
|
+
});
|
|
2755
|
+
};
|
|
2756
|
+
const removeFilters = async (type, items) => {
|
|
2757
|
+
const { included, excluded } = FILTER_KEYS[type];
|
|
2758
|
+
const state = store.getState();
|
|
2759
|
+
const itemSet = new Set(items);
|
|
2760
|
+
await persistFilters({
|
|
2761
|
+
[included]: state[included].filter((v) => !itemSet.has(v)),
|
|
2762
|
+
[excluded]: state[excluded].filter((v) => !itemSet.has(v))
|
|
2763
|
+
});
|
|
2764
|
+
};
|
|
2765
|
+
const emitFilterTelemetry = (trigger, changed) => {
|
|
2766
|
+
const state = store.getState();
|
|
2767
|
+
const includedTags = (state.includedTagFilters ?? []).filter((id) => BUILT_IN_TAG_IDS.has(id));
|
|
2768
|
+
const excludedTags = (state.excludedTagFilters ?? []).filter((id) => BUILT_IN_TAG_IDS.has(id));
|
|
2769
|
+
const includedStatuses = state.includedStatusFilters ?? [];
|
|
2770
|
+
const excludedStatuses = state.excludedStatusFilters ?? [];
|
|
2771
|
+
const storyCounts = {};
|
|
2772
|
+
const entries = state.internal_index ? Object.values(state.internal_index.entries) : [];
|
|
2773
|
+
for (const tagId of /* @__PURE__ */ new Set([...includedTags, ...excludedTags])) {
|
|
2774
|
+
const filterDef = BUILT_IN_FILTERS[tagId];
|
|
2775
|
+
storyCounts[tagId] = entries.filter((entry) => filterDef(entry)).length;
|
|
2776
|
+
}
|
|
2777
|
+
if (includedStatuses.length > 0 || excludedStatuses.length > 0) {
|
|
2778
|
+
const statusCounts = countStatusesByValue(fullStatusStore.getAll());
|
|
2779
|
+
for (const statusValue of /* @__PURE__ */ new Set([...includedStatuses, ...excludedStatuses])) if (statusCounts[statusValue] !== void 0) storyCounts[statusValue] = statusCounts[statusValue];
|
|
2780
|
+
}
|
|
2781
|
+
provider.channel?.emit(SIDEBAR_FILTER_CHANGED, {
|
|
2782
|
+
trigger,
|
|
2783
|
+
changed,
|
|
2784
|
+
activeTagFilters: {
|
|
2785
|
+
included: includedTags,
|
|
2786
|
+
excluded: excludedTags
|
|
2787
|
+
},
|
|
2788
|
+
activeStatusFilters: {
|
|
2789
|
+
included: includedStatuses,
|
|
2790
|
+
excluded: excludedStatuses
|
|
2791
|
+
},
|
|
2792
|
+
storyCounts
|
|
2793
|
+
});
|
|
2794
|
+
};
|
|
2795
|
+
const api = {
|
|
2796
|
+
storyId: toId,
|
|
2797
|
+
getData: (storyId, refId) => {
|
|
2798
|
+
const result = api.resolveStory(storyId, refId);
|
|
2799
|
+
if (result?.type === "story" || result?.type === "docs") return result;
|
|
2800
|
+
},
|
|
2801
|
+
isPrepared: (storyId, refId) => {
|
|
2802
|
+
const data = api.getData(storyId, refId);
|
|
2803
|
+
if (!data) return false;
|
|
2804
|
+
return data.type === "story" ? data.prepared : true;
|
|
2805
|
+
},
|
|
2806
|
+
resolveStory: (storyId, refId) => {
|
|
2807
|
+
const { refs, index } = store.getState();
|
|
2808
|
+
if (refId && !refs[refId]) return;
|
|
2809
|
+
if (refId) return refs?.[refId]?.index?.[storyId] ?? void 0;
|
|
2810
|
+
return index ? index[storyId] : void 0;
|
|
2811
|
+
},
|
|
2812
|
+
getCurrentStoryData: () => {
|
|
2813
|
+
const { storyId, refId } = store.getState();
|
|
2814
|
+
return api.getData(storyId, refId);
|
|
2815
|
+
},
|
|
2816
|
+
getIndex: () => {
|
|
2817
|
+
const { internal_index } = store.getState();
|
|
2818
|
+
return internal_index;
|
|
2819
|
+
},
|
|
2820
|
+
getParameters: (storyIdOrCombo, parameterName) => {
|
|
2821
|
+
const { storyId, refId } = typeof storyIdOrCombo === "string" ? {
|
|
2822
|
+
storyId: storyIdOrCombo,
|
|
2823
|
+
refId: void 0
|
|
2824
|
+
} : storyIdOrCombo;
|
|
2825
|
+
const data = api.getData(storyId, refId);
|
|
2826
|
+
if (["story", "docs"].includes(data?.type)) {
|
|
2827
|
+
const { parameters } = data;
|
|
2828
|
+
if (parameters) return parameterName ? parameters[parameterName] : parameters;
|
|
2829
|
+
}
|
|
2830
|
+
return null;
|
|
2831
|
+
},
|
|
2832
|
+
getCurrentParameter: (parameterName) => {
|
|
2833
|
+
const { storyId, refId } = store.getState();
|
|
2834
|
+
return api.getParameters({
|
|
2835
|
+
storyId,
|
|
2836
|
+
refId
|
|
2837
|
+
}, parameterName) || void 0;
|
|
2838
|
+
},
|
|
2839
|
+
jumpToComponent: (direction) => {
|
|
2840
|
+
const { filteredIndex, storyId, refs, refId } = store.getState();
|
|
2841
|
+
if (!api.getData(storyId, refId)) return;
|
|
2842
|
+
const hash = refId ? refs[refId].filteredIndex || {} : filteredIndex;
|
|
2843
|
+
if (!hash) return;
|
|
2844
|
+
const result = api.findSiblingStoryId(storyId, hash, direction, true);
|
|
2845
|
+
if (result) api.selectStory(result, void 0, { ref: refId });
|
|
2846
|
+
},
|
|
2847
|
+
jumpToStory: (direction) => {
|
|
2848
|
+
const { filteredIndex, storyId, refs, refId } = store.getState();
|
|
2849
|
+
const story = api.getData(storyId, refId);
|
|
2850
|
+
if (!story) return;
|
|
2851
|
+
const hash = story.refId ? refs[story.refId].filteredIndex : filteredIndex;
|
|
2852
|
+
if (!hash) return;
|
|
2853
|
+
const result = api.findSiblingStoryId(storyId, hash, direction, false);
|
|
2854
|
+
if (result) api.selectStory(result, void 0, { ref: refId });
|
|
2855
|
+
},
|
|
2856
|
+
selectFirstStory: () => {
|
|
2857
|
+
const state = store.getState();
|
|
2858
|
+
const { filteredIndex } = state;
|
|
2859
|
+
if (filteredIndex) {
|
|
2860
|
+
const firstStory = Object.keys(filteredIndex).find((id) => filteredIndex[id].type === "story");
|
|
2861
|
+
if (firstStory) api.selectStory(firstStory);
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
const { index } = state;
|
|
2865
|
+
if (!index) return;
|
|
2866
|
+
const firstStory = Object.keys(index).find((id) => index[id].type === "story");
|
|
2867
|
+
if (firstStory) {
|
|
2868
|
+
api.selectStory(firstStory);
|
|
2869
|
+
return;
|
|
2870
|
+
}
|
|
2871
|
+
navigateWithQueryParams("/");
|
|
2872
|
+
},
|
|
2873
|
+
selectStory: (titleOrId = void 0, name = void 0, options = {}) => {
|
|
2874
|
+
const { ref, scrollTo } = options;
|
|
2875
|
+
const { storyId, index, filteredIndex, refs, settings } = store.getState();
|
|
2876
|
+
const gotoStory = (entry) => {
|
|
2877
|
+
if (entry?.type === "docs" || entry?.type === "story") {
|
|
2878
|
+
store.setState({ settings: {
|
|
2879
|
+
...settings,
|
|
2880
|
+
lastTrackedStoryId: entry.id
|
|
2881
|
+
} });
|
|
2882
|
+
navigateWithQueryParams(`/${entry.type}/${entry.refId ? `${entry.refId}_${entry.id}` : entry.id}${scrollTo ? `#${scrollTo}` : ""}`);
|
|
2883
|
+
return true;
|
|
2884
|
+
}
|
|
2885
|
+
return false;
|
|
2886
|
+
};
|
|
2887
|
+
const kindSlug = storyId?.split("--", 2)[0];
|
|
2888
|
+
const hash = ref ? refs[ref].index : index;
|
|
2889
|
+
const filteredHash = ref ? refs[ref].filteredIndex : filteredIndex;
|
|
2890
|
+
if (!hash || !filteredHash) return;
|
|
2891
|
+
if (!name) {
|
|
2892
|
+
const entry = titleOrId ? hash[titleOrId] || hash[sanitize(titleOrId)] : hash[kindSlug];
|
|
2893
|
+
if (!entry) throw new Error(`Unknown id or title: '${titleOrId}'`);
|
|
2894
|
+
if (!gotoStory(entry)) gotoStory(api.findLeafEntry(filteredHash, entry.id));
|
|
2895
|
+
} else if (!titleOrId) gotoStory(hash[toId(kindSlug, name)]);
|
|
2896
|
+
else {
|
|
2897
|
+
const id = ref ? `${ref}_${toId(titleOrId, name)}` : toId(titleOrId, name);
|
|
2898
|
+
if (hash[id]) gotoStory(hash[id]);
|
|
2899
|
+
else {
|
|
2900
|
+
const entry = hash[sanitize(titleOrId)];
|
|
2901
|
+
if (entry?.type === "component") {
|
|
2902
|
+
const foundId = entry.children.find((childId) => hash[childId].name === name);
|
|
2903
|
+
gotoStory(foundId ? hash[foundId] : void 0);
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
},
|
|
2908
|
+
findLeafEntry(index, storyId) {
|
|
2909
|
+
const entry = index[storyId];
|
|
2910
|
+
if (!entry) return;
|
|
2911
|
+
if (entry.type === "docs" || entry.type === "story") return entry;
|
|
2912
|
+
const childStoryId = entry.children.find((childId) => index[childId]);
|
|
2913
|
+
return childStoryId ? api.findLeafEntry(index, childStoryId) : void 0;
|
|
2914
|
+
},
|
|
2915
|
+
findLeafStoryId(index, storyId) {
|
|
2916
|
+
return api.findLeafEntry(index, storyId)?.id;
|
|
2917
|
+
},
|
|
2918
|
+
findAllLeafStoryIds(entryId) {
|
|
2919
|
+
const { index } = store.getState();
|
|
2920
|
+
if (!index) return [];
|
|
2921
|
+
const findChildEntriesRecursively = (currentEntryId, results = []) => {
|
|
2922
|
+
const node = index[currentEntryId];
|
|
2923
|
+
if (!node) return results;
|
|
2924
|
+
if (node.type === "story") results.push(node.id);
|
|
2925
|
+
if ("children" in node) node.children?.forEach((childId) => findChildEntriesRecursively(childId, results));
|
|
2926
|
+
return results;
|
|
2927
|
+
};
|
|
2928
|
+
return findChildEntriesRecursively(entryId, []);
|
|
2929
|
+
},
|
|
2930
|
+
findSiblingStoryId(storyId, index, direction, toSiblingGroup) {
|
|
2931
|
+
if (toSiblingGroup) {
|
|
2932
|
+
const lookupList = getComponentLookupList(index);
|
|
2933
|
+
const position = lookupList.findIndex((i) => i.includes(storyId));
|
|
2934
|
+
if (position === lookupList.length - 1 && direction > 0) return;
|
|
2935
|
+
if (position === 0 && direction < 0) return;
|
|
2936
|
+
if (lookupList[position + direction]) return lookupList[position + direction][0];
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
const lookupList = getStoriesLookupList(index);
|
|
2940
|
+
const position = lookupList.indexOf(storyId);
|
|
2941
|
+
if (position === lookupList.length - 1 && direction > 0) return;
|
|
2942
|
+
if (position === 0 && direction < 0) return;
|
|
2943
|
+
return lookupList[position + direction];
|
|
2944
|
+
},
|
|
2945
|
+
updateStoryArgs: (story, updatedArgs) => {
|
|
2946
|
+
const { id: storyId, refId } = story;
|
|
2947
|
+
provider.channel?.emit(UPDATE_STORY_ARGS, {
|
|
2948
|
+
storyId,
|
|
2949
|
+
updatedArgs,
|
|
2950
|
+
options: { target: refId }
|
|
2951
|
+
});
|
|
2952
|
+
},
|
|
2953
|
+
resetStoryArgs: (story, argNames) => {
|
|
2954
|
+
const { id: storyId, refId } = story;
|
|
2955
|
+
provider.channel?.emit(RESET_STORY_ARGS, {
|
|
2956
|
+
storyId,
|
|
2957
|
+
argNames,
|
|
2958
|
+
options: { target: refId }
|
|
2959
|
+
});
|
|
2960
|
+
},
|
|
2961
|
+
fetchIndex: async () => {
|
|
2962
|
+
try {
|
|
2963
|
+
const result = await fetch(STORY_INDEX_PATH);
|
|
2964
|
+
if (result.status !== 200) throw new Error(await result.text());
|
|
2965
|
+
const storyIndex = await result.json();
|
|
2966
|
+
if (storyIndex.v < 3) {
|
|
2967
|
+
logger.warn(`Skipping story index with version v${storyIndex.v}, awaiting SET_STORIES.`);
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
await api.setIndex(storyIndex);
|
|
2971
|
+
} catch (err) {
|
|
2972
|
+
await store.setState({ indexError: err });
|
|
2973
|
+
}
|
|
2974
|
+
},
|
|
2975
|
+
setIndex: async (input) => {
|
|
2976
|
+
const { filteredIndex: oldFilteredHash, index: oldHash, filters } = store.getState();
|
|
2977
|
+
const allStatuses = fullStatusStore.getAll();
|
|
2978
|
+
const newFilteredHash = transformStoryIndexToStoriesHash(input, {
|
|
2979
|
+
provider,
|
|
2980
|
+
docsOptions,
|
|
2981
|
+
filters,
|
|
2982
|
+
allStatuses,
|
|
2983
|
+
statusFilterKey: STATUS_FILTER
|
|
2984
|
+
});
|
|
2985
|
+
const newHash = transformStoryIndexToStoriesHash(input, {
|
|
2986
|
+
provider,
|
|
2987
|
+
docsOptions,
|
|
2988
|
+
filters: {},
|
|
2989
|
+
allStatuses
|
|
2990
|
+
});
|
|
2991
|
+
await store.setState({
|
|
2992
|
+
internal_index: input,
|
|
2993
|
+
filteredIndex: addPreparedStories(newFilteredHash, oldFilteredHash),
|
|
2994
|
+
index: addPreparedStories(newHash, oldHash),
|
|
2995
|
+
indexError: void 0
|
|
2996
|
+
});
|
|
2997
|
+
},
|
|
2998
|
+
updateStory: async (storyId, update, ref) => {
|
|
2999
|
+
if (!ref) {
|
|
3000
|
+
const { index, filteredIndex } = store.getState();
|
|
3001
|
+
if (index && index[storyId]) index[storyId] = {
|
|
3002
|
+
...index[storyId],
|
|
3003
|
+
...update
|
|
3004
|
+
};
|
|
3005
|
+
if (filteredIndex && filteredIndex[storyId]) filteredIndex[storyId] = {
|
|
3006
|
+
...filteredIndex[storyId],
|
|
3007
|
+
...update
|
|
3008
|
+
};
|
|
3009
|
+
if (index || filteredIndex) await store.setState({
|
|
3010
|
+
index,
|
|
3011
|
+
filteredIndex
|
|
3012
|
+
});
|
|
3013
|
+
} else {
|
|
3014
|
+
const { id: refId, index, filteredIndex } = ref;
|
|
3015
|
+
const storyUpdates = {
|
|
3016
|
+
...ref.storyUpdates,
|
|
3017
|
+
[storyId]: {
|
|
3018
|
+
...ref.storyUpdates?.[storyId],
|
|
3019
|
+
...update
|
|
3020
|
+
}
|
|
3021
|
+
};
|
|
3022
|
+
if (index && index[storyId]) index[storyId] = {
|
|
3023
|
+
...index[storyId],
|
|
3024
|
+
...update
|
|
3025
|
+
};
|
|
3026
|
+
if (filteredIndex && filteredIndex[storyId]) filteredIndex[storyId] = {
|
|
3027
|
+
...filteredIndex[storyId],
|
|
3028
|
+
...update
|
|
3029
|
+
};
|
|
3030
|
+
await fullAPI.updateRef(refId, {
|
|
3031
|
+
index,
|
|
3032
|
+
filteredIndex,
|
|
3033
|
+
storyUpdates
|
|
3034
|
+
});
|
|
3035
|
+
}
|
|
3036
|
+
},
|
|
3037
|
+
updateDocs: async (docsId, update, ref) => {
|
|
3038
|
+
if (!ref) {
|
|
3039
|
+
const { index, filteredIndex } = store.getState();
|
|
3040
|
+
if (index) index[docsId] = {
|
|
3041
|
+
...index[docsId],
|
|
3042
|
+
...update
|
|
3043
|
+
};
|
|
3044
|
+
if (filteredIndex) filteredIndex[docsId] = {
|
|
3045
|
+
...filteredIndex[docsId],
|
|
3046
|
+
...update
|
|
3047
|
+
};
|
|
3048
|
+
if (index || filteredIndex) await store.setState({
|
|
3049
|
+
index,
|
|
3050
|
+
filteredIndex
|
|
3051
|
+
});
|
|
3052
|
+
} else {
|
|
3053
|
+
const { id: refId, index, filteredIndex } = ref;
|
|
3054
|
+
const storyUpdates = {
|
|
3055
|
+
...ref.storyUpdates,
|
|
3056
|
+
[docsId]: {
|
|
3057
|
+
...ref.storyUpdates?.[docsId],
|
|
3058
|
+
...update
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
if (index && index[docsId]) index[docsId] = {
|
|
3062
|
+
...index[docsId],
|
|
3063
|
+
...update
|
|
3064
|
+
};
|
|
3065
|
+
if (filteredIndex && filteredIndex[docsId]) filteredIndex[docsId] = {
|
|
3066
|
+
...filteredIndex[docsId],
|
|
3067
|
+
...update
|
|
3068
|
+
};
|
|
3069
|
+
await fullAPI.updateRef(refId, {
|
|
3070
|
+
index,
|
|
3071
|
+
filteredIndex,
|
|
3072
|
+
storyUpdates
|
|
3073
|
+
});
|
|
3074
|
+
}
|
|
3075
|
+
},
|
|
3076
|
+
setPreviewInitialized: async (ref) => {
|
|
3077
|
+
if (!ref) store.setState({ previewInitialized: true });
|
|
3078
|
+
else fullAPI.updateRef(ref.id, { previewInitialized: true });
|
|
3079
|
+
},
|
|
3080
|
+
setFilter: async (id, filterFunction) => {
|
|
3081
|
+
await api.setFilters({ [id]: filterFunction });
|
|
3082
|
+
},
|
|
3083
|
+
setFilters: async (filters) => {
|
|
3084
|
+
await store.setState((state) => ({ filters: {
|
|
3085
|
+
...state.filters,
|
|
3086
|
+
...filters
|
|
3087
|
+
} }));
|
|
3088
|
+
if (!await applyCurrentFilters()) return;
|
|
3089
|
+
for (const id of Object.keys(filters)) provider.channel?.emit(SET_FILTER, { id });
|
|
3090
|
+
},
|
|
3091
|
+
resetTagFilters: async () => {
|
|
3092
|
+
await persistFilters((s) => ({
|
|
3093
|
+
includedTagFilters: s.defaultIncludedTagFilters,
|
|
3094
|
+
excludedTagFilters: s.defaultExcludedTagFilters
|
|
3095
|
+
}));
|
|
3096
|
+
await recomputeTagsFilter();
|
|
3097
|
+
},
|
|
3098
|
+
setAllTagFilters: async (included, excluded) => {
|
|
3099
|
+
await persistFilters({
|
|
3100
|
+
includedTagFilters: included,
|
|
3101
|
+
excludedTagFilters: excluded
|
|
3102
|
+
});
|
|
3103
|
+
await recomputeTagsFilter();
|
|
3104
|
+
},
|
|
3105
|
+
addTagFilters: async (tags, excluded) => {
|
|
3106
|
+
await addFilters("tag", tags, excluded);
|
|
3107
|
+
await recomputeTagsFilter();
|
|
3108
|
+
if (tags.length === 1 && BUILT_IN_TAG_IDS.has(tags[0])) emitFilterTelemetry("interaction", {
|
|
3109
|
+
filterType: "tag",
|
|
3110
|
+
filterId: tags[0],
|
|
3111
|
+
action: excluded ? "exclude" : "include"
|
|
3112
|
+
});
|
|
3113
|
+
},
|
|
3114
|
+
removeTagFilters: async (tags) => {
|
|
3115
|
+
await removeFilters("tag", tags);
|
|
3116
|
+
await recomputeTagsFilter();
|
|
3117
|
+
if (tags.length === 1 && BUILT_IN_TAG_IDS.has(tags[0])) emitFilterTelemetry("interaction", {
|
|
3118
|
+
filterType: "tag",
|
|
3119
|
+
filterId: tags[0],
|
|
3120
|
+
action: "remove"
|
|
3121
|
+
});
|
|
3122
|
+
},
|
|
3123
|
+
resetStatusFilters: async () => {
|
|
3124
|
+
await persistFilters({
|
|
3125
|
+
includedStatusFilters: [],
|
|
3126
|
+
excludedStatusFilters: []
|
|
3127
|
+
});
|
|
3128
|
+
await recomputeStatusFilter();
|
|
3129
|
+
},
|
|
3130
|
+
setAllStatusFilters: async (included, excluded) => {
|
|
3131
|
+
const prevState = store.getState();
|
|
3132
|
+
const prevIncluded = new Set(prevState.includedStatusFilters ?? []);
|
|
3133
|
+
const prevExcluded = new Set(prevState.excludedStatusFilters ?? []);
|
|
3134
|
+
const nextIncluded = new Set(included);
|
|
3135
|
+
const nextExcluded = new Set(excluded);
|
|
3136
|
+
await persistFilters({
|
|
3137
|
+
includedStatusFilters: included,
|
|
3138
|
+
excludedStatusFilters: excluded
|
|
3139
|
+
});
|
|
3140
|
+
await recomputeStatusFilter();
|
|
3141
|
+
const changedIds = /* @__PURE__ */ new Set([
|
|
3142
|
+
...prevIncluded,
|
|
3143
|
+
...prevExcluded,
|
|
3144
|
+
...nextIncluded,
|
|
3145
|
+
...nextExcluded
|
|
3146
|
+
]);
|
|
3147
|
+
for (const id of changedIds) {
|
|
3148
|
+
const wasIncluded = prevIncluded.has(id);
|
|
3149
|
+
const wasExcluded = prevExcluded.has(id);
|
|
3150
|
+
const isIncluded = nextIncluded.has(id);
|
|
3151
|
+
const isExcluded = nextExcluded.has(id);
|
|
3152
|
+
if (wasIncluded === isIncluded && wasExcluded === isExcluded) continue;
|
|
3153
|
+
let action;
|
|
3154
|
+
if (isIncluded) action = "include";
|
|
3155
|
+
else if (isExcluded) action = "exclude";
|
|
3156
|
+
else action = "remove";
|
|
3157
|
+
emitFilterTelemetry("interaction", {
|
|
3158
|
+
filterType: "status",
|
|
3159
|
+
filterId: id,
|
|
3160
|
+
action
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
},
|
|
3164
|
+
addStatusFilters: async (statuses, excluded) => {
|
|
3165
|
+
await addFilters("status", statuses, excluded);
|
|
3166
|
+
await recomputeStatusFilter();
|
|
3167
|
+
if (statuses.length === 1) emitFilterTelemetry("interaction", {
|
|
3168
|
+
filterType: "status",
|
|
3169
|
+
filterId: statuses[0],
|
|
3170
|
+
action: excluded ? "exclude" : "include"
|
|
3171
|
+
});
|
|
3172
|
+
},
|
|
3173
|
+
removeStatusFilters: async (statuses) => {
|
|
3174
|
+
await removeFilters("status", statuses);
|
|
3175
|
+
await recomputeStatusFilter();
|
|
3176
|
+
if (statuses.length === 1) emitFilterTelemetry("interaction", {
|
|
3177
|
+
filterType: "status",
|
|
3178
|
+
filterId: statuses[0],
|
|
3179
|
+
action: "remove"
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
};
|
|
3183
|
+
const applyCurrentFilters = async () => {
|
|
3184
|
+
const { internal_index: index } = store.getState();
|
|
3185
|
+
if (!index) return false;
|
|
3186
|
+
await api.setIndex(index);
|
|
3187
|
+
const refs = await fullAPI.getRefs();
|
|
3188
|
+
for (const [refId, { internal_index, ...ref }] of Object.entries(refs)) await fullAPI.setRef(refId, {
|
|
3189
|
+
...ref,
|
|
3190
|
+
storyIndex: internal_index
|
|
3191
|
+
}, true);
|
|
3192
|
+
return true;
|
|
3193
|
+
};
|
|
3194
|
+
let statusFilterRebuildQueued = false;
|
|
3195
|
+
let statusFilterRebuildInFlight = false;
|
|
3196
|
+
const flushStatusFilterRebuild = async () => {
|
|
3197
|
+
if (statusFilterRebuildInFlight) return;
|
|
3198
|
+
statusFilterRebuildInFlight = true;
|
|
3199
|
+
try {
|
|
3200
|
+
while (statusFilterRebuildQueued) {
|
|
3201
|
+
statusFilterRebuildQueued = false;
|
|
3202
|
+
try {
|
|
3203
|
+
await applyCurrentFilters();
|
|
3204
|
+
} catch (error) {
|
|
3205
|
+
logger.warn("Failed to rebuild story index after status change:", error);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
} finally {
|
|
3209
|
+
statusFilterRebuildInFlight = false;
|
|
3210
|
+
if (statusFilterRebuildQueued) flushStatusFilterRebuild();
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
const requestStatusFilterRebuild = () => {
|
|
3214
|
+
statusFilterRebuildQueued = true;
|
|
3215
|
+
flushStatusFilterRebuild();
|
|
3216
|
+
};
|
|
3217
|
+
const recomputeTagsFilter = () => {
|
|
3218
|
+
const { includedTagFilters, excludedTagFilters } = store.getState();
|
|
3219
|
+
return api.setFilters({ [TAGS_FILTER]: computeTagsFilterFn(includedTagFilters, excludedTagFilters) });
|
|
3220
|
+
};
|
|
3221
|
+
const recomputeStatusFilter = () => {
|
|
3222
|
+
const { includedStatusFilters, excludedStatusFilters } = store.getState();
|
|
3223
|
+
return api.setFilters({ [STATUS_FILTER]: computeStatusFilterFn(includedStatusFilters ?? [], excludedStatusFilters ?? []) });
|
|
3224
|
+
};
|
|
3225
|
+
provider.channel?.on(STORY_SPECIFIED, function handler({ storyId, viewMode }) {
|
|
3226
|
+
const { sourceType } = getEventMetadata(this, fullAPI);
|
|
3227
|
+
if (sourceType === "local") {
|
|
3228
|
+
const state = store.getState();
|
|
3229
|
+
const isCanvasRoute = !isReviewManagerRoute(state.path, state.customQueryParams) && (state.path === "/" || state.viewMode === "story" || state.viewMode === "docs");
|
|
3230
|
+
const stateHasSelection = state.viewMode && state.storyId;
|
|
3231
|
+
const stateSelectionDifferent = state.viewMode !== viewMode || state.storyId !== storyId;
|
|
3232
|
+
const { type } = state.index?.[state.storyId] || {};
|
|
3233
|
+
const isStory = !(type === "root" || type === "component" || type === "group");
|
|
3234
|
+
/**
|
|
3235
|
+
* When storybook starts, we want to navigate to the first story. But there are a few
|
|
3236
|
+
* exceptions:
|
|
3237
|
+
*
|
|
3238
|
+
* - If the current storyId and viewMode are already set/correct AND the url section is a
|
|
3239
|
+
* leaf-type.
|
|
3240
|
+
* - If the user has navigated away already.
|
|
3241
|
+
* - If the user started storybook with a specific page-URL like "/settings/about"
|
|
3242
|
+
*/
|
|
3243
|
+
if (isCanvasRoute) {
|
|
3244
|
+
const { filteredIndex } = state;
|
|
3245
|
+
if (filteredIndex && !stateHasSelection) {
|
|
3246
|
+
if (!(filteredIndex[storyId]?.type === "story")) {
|
|
3247
|
+
const firstFiltered = filteredIndex ? Object.keys(filteredIndex).find((id) => {
|
|
3248
|
+
const entry = filteredIndex[id];
|
|
3249
|
+
return entry.type === "story" || entry.type === "docs";
|
|
3250
|
+
}) : void 0;
|
|
3251
|
+
if (firstFiltered) navigateWithQueryParams(`/${viewMode}/${firstFiltered}`);
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
if (stateHasSelection && stateSelectionDifferent && isStory) provider.channel?.emit(SET_CURRENT_STORY, {
|
|
3256
|
+
storyId: state.storyId,
|
|
3257
|
+
viewMode: state.viewMode
|
|
3258
|
+
});
|
|
3259
|
+
else if (stateSelectionDifferent) navigateWithQueryParams(`/${viewMode}/${storyId}`);
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
});
|
|
3263
|
+
provider.channel?.on(CURRENT_STORY_WAS_SET, function handler() {
|
|
3264
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3265
|
+
api.setPreviewInitialized(ref);
|
|
3266
|
+
});
|
|
3267
|
+
provider.channel?.on(STORY_CHANGED, function handler() {
|
|
3268
|
+
const { sourceType } = getEventMetadata(this, fullAPI);
|
|
3269
|
+
if (sourceType === "local") {
|
|
3270
|
+
const options = api.getCurrentParameter("options");
|
|
3271
|
+
if (options) fullAPI.setOptions(removeRemovedOptions(options));
|
|
3272
|
+
}
|
|
3273
|
+
});
|
|
3274
|
+
provider.channel?.on(STORY_PREPARED, function handler({ id, ...update }) {
|
|
3275
|
+
const { ref, sourceType } = getEventMetadata(this, fullAPI);
|
|
3276
|
+
api.updateStory(id, {
|
|
3277
|
+
...update,
|
|
3278
|
+
prepared: true
|
|
3279
|
+
}, ref);
|
|
3280
|
+
if (!ref) {
|
|
3281
|
+
if (!store.getState().hasCalledSetOptions) {
|
|
3282
|
+
const { options } = update.parameters;
|
|
3283
|
+
fullAPI.setOptions(removeRemovedOptions(options));
|
|
3284
|
+
store.setState({ hasCalledSetOptions: true });
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
if (sourceType === "local") {
|
|
3288
|
+
const { storyId, index, refId } = store.getState();
|
|
3289
|
+
if (!index) return;
|
|
3290
|
+
const toBePreloaded = Array.from(/* @__PURE__ */ new Set([api.findSiblingStoryId(storyId, index, 1, true), api.findSiblingStoryId(storyId, index, -1, true)])).filter(Boolean);
|
|
3291
|
+
provider.channel?.emit(PRELOAD_ENTRIES, {
|
|
3292
|
+
ids: toBePreloaded,
|
|
3293
|
+
options: { target: refId }
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
});
|
|
3297
|
+
provider.channel?.on(DOCS_PREPARED, function handler({ id, ...update }) {
|
|
3298
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3299
|
+
api.updateStory(id, {
|
|
3300
|
+
...update,
|
|
3301
|
+
prepared: true
|
|
3302
|
+
}, ref);
|
|
3303
|
+
});
|
|
3304
|
+
provider.channel?.on(SET_INDEX, function handler(index) {
|
|
3305
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3306
|
+
if (!ref) {
|
|
3307
|
+
api.setIndex(index);
|
|
3308
|
+
const options = api.getCurrentParameter("options");
|
|
3309
|
+
fullAPI.setOptions(removeRemovedOptions(options));
|
|
3310
|
+
} else fullAPI.setRef(ref.id, {
|
|
3311
|
+
...ref,
|
|
3312
|
+
storyIndex: index
|
|
3313
|
+
}, true);
|
|
3314
|
+
});
|
|
3315
|
+
provider.channel?.on(SET_STORIES, function handler(data) {
|
|
3316
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3317
|
+
const setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories;
|
|
3318
|
+
if (!ref) throw new Error("Cannot call SET_STORIES for local frame");
|
|
3319
|
+
else fullAPI.setRef(ref.id, {
|
|
3320
|
+
...ref,
|
|
3321
|
+
setStoriesData
|
|
3322
|
+
}, true);
|
|
3323
|
+
});
|
|
3324
|
+
provider.channel?.on(SELECT_STORY, function handler({ kind, title = kind, story, name = story, storyId, ...rest }) {
|
|
3325
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3326
|
+
if (!ref) fullAPI.selectStory(storyId || title, name, rest);
|
|
3327
|
+
else fullAPI.selectStory(storyId || title, name, {
|
|
3328
|
+
...rest,
|
|
3329
|
+
ref: ref.id
|
|
3330
|
+
});
|
|
3331
|
+
});
|
|
3332
|
+
provider.channel?.on(STORY_ARGS_UPDATED, function handleStoryArgsUpdated({ storyId, args }) {
|
|
3333
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3334
|
+
api.updateStory(storyId, { args }, ref);
|
|
3335
|
+
});
|
|
3336
|
+
provider.channel?.on(CONFIG_ERROR, function handleConfigError(err) {
|
|
3337
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3338
|
+
api.setPreviewInitialized(ref);
|
|
3339
|
+
});
|
|
3340
|
+
provider.channel?.on(STORY_MISSING, function handleConfigError(err) {
|
|
3341
|
+
const { ref } = getEventMetadata(this, fullAPI);
|
|
3342
|
+
api.setPreviewInitialized(ref);
|
|
3343
|
+
});
|
|
3344
|
+
provider.channel?.on(SET_CONFIG, async () => {
|
|
3345
|
+
const { includedTagFilters, excludedTagFilters, includedStatusFilters, excludedStatusFilters, tagPresets } = store.getState();
|
|
3346
|
+
await api.setFilters({
|
|
3347
|
+
[STATIC_FILTER]: computeStaticFilterFn(tagPresets),
|
|
3348
|
+
[TAGS_FILTER]: computeTagsFilterFn(includedTagFilters, excludedTagFilters),
|
|
3349
|
+
[STATUS_FILTER]: computeStatusFilterFn(includedStatusFilters, excludedStatusFilters)
|
|
3350
|
+
});
|
|
3351
|
+
});
|
|
3352
|
+
fullStatusStore.onAllStatusChange(throttle(requestStatusFilterRebuild, STATUS_CHANGE_REBUILD_THROTTLE, { edges: ["leading", "trailing"] }));
|
|
3353
|
+
const tagPresets = scope.TAGS_OPTIONS || {};
|
|
3354
|
+
const defaultTags = getDefaultTagsFromPreset(tagPresets);
|
|
3355
|
+
const { tags, statuses } = queryFromLocation(location ?? { search: "" });
|
|
3356
|
+
const parsedTags = parseTagsParam(tags);
|
|
3357
|
+
const hasTagsParam = tags !== void 0;
|
|
3358
|
+
const initialIncluded = hasTagsParam ? parsedTags.included : defaultTags.included;
|
|
3359
|
+
const initialExcluded = hasTagsParam ? parsedTags.excluded : defaultTags.excluded;
|
|
3360
|
+
const parsedStatuses = parseStatusesParam(statuses);
|
|
3361
|
+
const initialIncludedStatuses = parsedStatuses.included;
|
|
3362
|
+
const initialExcludedStatuses = parsedStatuses.excluded;
|
|
3363
|
+
return {
|
|
3364
|
+
api,
|
|
3365
|
+
state: {
|
|
3366
|
+
storyId: initialStoryId,
|
|
3367
|
+
viewMode: initialViewMode,
|
|
3368
|
+
hasCalledSetOptions: false,
|
|
3369
|
+
previewInitialized: false,
|
|
3370
|
+
filters: {
|
|
3371
|
+
[STATIC_FILTER]: computeStaticFilterFn(tagPresets),
|
|
3372
|
+
[TAGS_FILTER]: computeTagsFilterFn(initialIncluded, initialExcluded),
|
|
3373
|
+
[STATUS_FILTER]: computeStatusFilterFn(initialIncludedStatuses, initialExcludedStatuses)
|
|
3374
|
+
},
|
|
3375
|
+
tagPresets,
|
|
3376
|
+
defaultIncludedTagFilters: defaultTags.included,
|
|
3377
|
+
defaultExcludedTagFilters: defaultTags.excluded,
|
|
3378
|
+
includedTagFilters: initialIncluded,
|
|
3379
|
+
excludedTagFilters: initialExcluded,
|
|
3380
|
+
includedStatusFilters: initialIncludedStatuses,
|
|
3381
|
+
excludedStatusFilters: initialExcludedStatuses
|
|
3382
|
+
},
|
|
3383
|
+
init: async () => {
|
|
3384
|
+
provider.channel?.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex());
|
|
3385
|
+
await api.fetchIndex();
|
|
3386
|
+
if (urlFilterTelemetryEmitted) return;
|
|
3387
|
+
urlFilterTelemetryEmitted = true;
|
|
3388
|
+
const hasBuiltInTagFilters = initialIncluded.some((id) => BUILT_IN_TAG_IDS.has(id)) || initialExcluded.some((id) => BUILT_IN_TAG_IDS.has(id));
|
|
3389
|
+
const hasStatusFilters = initialIncludedStatuses.length > 0 || initialExcludedStatuses.length > 0;
|
|
3390
|
+
if (hasBuiltInTagFilters || hasStatusFilters) emitFilterTelemetry("url");
|
|
3391
|
+
}
|
|
3392
|
+
};
|
|
3393
|
+
};
|
|
3394
|
+
})))();
|
|
3395
|
+
}
|
|
3396
|
+
//#endregion
|
|
3397
|
+
//#region src/manager-api/modules/url.ts
|
|
3398
|
+
var url_exports = /* @__PURE__ */ __exportAll({
|
|
3399
|
+
getCustomQueryParams: () => getCustomQueryParams,
|
|
3400
|
+
init: () => init$2
|
|
3401
|
+
});
|
|
3402
|
+
var parseBoolean, parseSerializedParam, mergeSerializedParams, resolveIframeUrl, LAYOUT_QUERY_PARAM_KEYS, getCustomQueryParams, prevParams, initialUrlSupport, init$2;
|
|
3403
|
+
function init_url$1() {
|
|
3404
|
+
return (init_url$1 = __esmMin((() => {
|
|
3405
|
+
init_core_events();
|
|
3406
|
+
init_router();
|
|
3407
|
+
init_dist$1();
|
|
3408
|
+
init_dist$3();
|
|
3409
|
+
init_main();
|
|
3410
|
+
init_merge();
|
|
3411
|
+
init_url();
|
|
3412
|
+
init_layout();
|
|
3413
|
+
parseBoolean = (value) => {
|
|
3414
|
+
if (value === "true" || value === "1") return true;
|
|
3415
|
+
if (value === "false" || value === "0") return false;
|
|
3416
|
+
};
|
|
3417
|
+
parseSerializedParam = (param) => Object.fromEntries(param.split(";").map((pair) => pair.split(":")).map(([key, value]) => [key, encodeURIComponent(value)]).filter(([key, value]) => key && value));
|
|
3418
|
+
mergeSerializedParams = (params, extraParams) => {
|
|
3419
|
+
const pairs = parseSerializedParam(params);
|
|
3420
|
+
const extra = parseSerializedParam(extraParams);
|
|
3421
|
+
return Object.entries({
|
|
3422
|
+
...pairs,
|
|
3423
|
+
...extra
|
|
3424
|
+
}).map(([key, value]) => `${key}:${value}`).join(";");
|
|
3425
|
+
};
|
|
3426
|
+
resolveIframeUrl = (baseUrl, { absolute }) => {
|
|
3427
|
+
const resolved = new URL("iframe.html", baseUrl);
|
|
3428
|
+
return absolute ? resolved.href : `${resolved.pathname}${resolved.search}${resolved.hash}`;
|
|
3429
|
+
};
|
|
3430
|
+
LAYOUT_QUERY_PARAM_KEYS = [
|
|
3431
|
+
"full",
|
|
3432
|
+
"panel",
|
|
3433
|
+
"nav",
|
|
3434
|
+
"shortcuts",
|
|
3435
|
+
"addonPanel",
|
|
3436
|
+
"tabs",
|
|
3437
|
+
"path"
|
|
3438
|
+
];
|
|
3439
|
+
getCustomQueryParams = (location) => omit(queryFromLocation(location), LAYOUT_QUERY_PARAM_KEYS);
|
|
3440
|
+
initialUrlSupport = ({ state: { location, path, viewMode, storyId: storyIdFromUrl }, singleStory }) => {
|
|
3441
|
+
const { full, panel, nav, shortcuts, addonPanel } = queryFromLocation(location);
|
|
3442
|
+
let navSize;
|
|
3443
|
+
let bottomPanelHeight;
|
|
3444
|
+
let rightPanelWidth;
|
|
3445
|
+
if (parseBoolean(full) === true) {
|
|
3446
|
+
navSize = 0;
|
|
3447
|
+
bottomPanelHeight = 0;
|
|
3448
|
+
rightPanelWidth = 0;
|
|
3449
|
+
} else if (parseBoolean(full) === false) {
|
|
3450
|
+
navSize = 300;
|
|
3451
|
+
bottomPanelHeight = 300;
|
|
3452
|
+
rightPanelWidth = 400;
|
|
3453
|
+
}
|
|
3454
|
+
if (!singleStory) {
|
|
3455
|
+
if (parseBoolean(nav) === true) navSize = 300;
|
|
3456
|
+
if (parseBoolean(nav) === false) navSize = 0;
|
|
3457
|
+
}
|
|
3458
|
+
if (parseBoolean(panel) === false) {
|
|
3459
|
+
bottomPanelHeight = 0;
|
|
3460
|
+
rightPanelWidth = 0;
|
|
3461
|
+
}
|
|
3462
|
+
const layout = {
|
|
3463
|
+
navSize,
|
|
3464
|
+
bottomPanelHeight,
|
|
3465
|
+
rightPanelWidth,
|
|
3466
|
+
panelPosition: ["right", "bottom"].includes(panel) ? panel : void 0
|
|
3467
|
+
};
|
|
3468
|
+
const ui = { enableShortcuts: parseBoolean(shortcuts) };
|
|
3469
|
+
const selectedPanel = addonPanel || void 0;
|
|
3470
|
+
const storyId = storyIdFromUrl;
|
|
3471
|
+
const otherParams = getCustomQueryParams(location);
|
|
3472
|
+
const customQueryParams = dequal(prevParams, otherParams) ? prevParams : otherParams;
|
|
3473
|
+
prevParams = customQueryParams;
|
|
3474
|
+
return {
|
|
3475
|
+
viewMode,
|
|
3476
|
+
layout,
|
|
3477
|
+
ui,
|
|
3478
|
+
selectedPanel,
|
|
3479
|
+
location,
|
|
3480
|
+
path,
|
|
3481
|
+
customQueryParams,
|
|
3482
|
+
storyId
|
|
3483
|
+
};
|
|
3484
|
+
};
|
|
3485
|
+
init$2 = (moduleArgs) => {
|
|
3486
|
+
const { store, navigate, provider, fullAPI } = moduleArgs;
|
|
3487
|
+
const navigateTo = (path, queryParams = {}, options = {}) => {
|
|
3488
|
+
return navigate(buildNavigationUrl(path, queryParams), options);
|
|
3489
|
+
};
|
|
3490
|
+
const api = {
|
|
3491
|
+
getStoryHrefs(storyId, options = {}) {
|
|
3492
|
+
const { id: currentStoryId, refId: currentRefId } = fullAPI.getCurrentStoryData() ?? {};
|
|
3493
|
+
const isCurrentStory = storyId === currentStoryId && options.refId === currentRefId;
|
|
3494
|
+
const { customQueryParams, location, refs } = store.getState();
|
|
3495
|
+
const { base, inheritArgs = isCurrentStory, inheritGlobals = true, queryParams = {}, refId, viewMode = "story", embed = false, freeze = false } = options;
|
|
3496
|
+
if (refId && !refs[refId]) throw new Error(`Invalid refId: ${refId}`);
|
|
3497
|
+
const pathname = location.pathname || "/";
|
|
3498
|
+
const originAddress = scope.window.location.origin + pathname;
|
|
3499
|
+
const networkAddress = scope.FORKBOOK_NETWORK_ADDRESS ?? originAddress;
|
|
3500
|
+
const managerBase = base === "origin" ? originAddress : base === "network" ? networkAddress : pathname;
|
|
3501
|
+
const previewBaseUrl = base ? managerBase : scope.document?.baseURI || originAddress;
|
|
3502
|
+
const previewBase = refId ? refs[refId].url + "/iframe.html" : resolveIframeUrl(previewBaseUrl, { absolute: Boolean(base) });
|
|
3503
|
+
const refParam = refId ? `&refId=${encodeURIComponent(refId)}` : "";
|
|
3504
|
+
const { args = "", globals = "", ...otherParams } = queryParams;
|
|
3505
|
+
let argsParam = inheritArgs ? mergeSerializedParams(customQueryParams?.args ?? "", args) : args;
|
|
3506
|
+
let globalsParam = inheritGlobals ? mergeSerializedParams(customQueryParams?.globals ?? "", globals) : globals;
|
|
3507
|
+
const managerQueryParams = omit(otherParams, ["embed", "freeze"]);
|
|
3508
|
+
const previewQueryParams = omit(otherParams, [
|
|
3509
|
+
"id",
|
|
3510
|
+
"viewMode",
|
|
3511
|
+
"embed",
|
|
3512
|
+
"freeze"
|
|
3513
|
+
]);
|
|
3514
|
+
let customManagerParams = stringify$1(managerQueryParams, {
|
|
3515
|
+
nesting: true,
|
|
3516
|
+
nestingSyntax: "js"
|
|
3517
|
+
});
|
|
3518
|
+
let customPreviewParams = stringify$1(previewQueryParams, {
|
|
3519
|
+
nesting: true,
|
|
3520
|
+
nestingSyntax: "js"
|
|
3521
|
+
});
|
|
3522
|
+
argsParam = argsParam && `&args=${argsParam}`;
|
|
3523
|
+
globalsParam = globalsParam && `&globals=${globalsParam}`;
|
|
3524
|
+
customManagerParams = customManagerParams && `&${customManagerParams}`;
|
|
3525
|
+
customPreviewParams = customPreviewParams && `&${customPreviewParams}`;
|
|
3526
|
+
const embedParam = embed ? "&embed=true" : "";
|
|
3527
|
+
const freezeParam = freeze ? "&freeze=finished" : "";
|
|
3528
|
+
return {
|
|
3529
|
+
managerHref: `${managerBase}?path=/${viewMode}/${refId ? `${refId}_` : ""}${storyId}${argsParam}${globalsParam}${customManagerParams}`,
|
|
3530
|
+
previewHref: `${previewBase}?id=${storyId}&viewMode=${viewMode}${refParam}${argsParam}${refId ? "" : globalsParam}${customPreviewParams}${embedParam}${freezeParam}`
|
|
3531
|
+
};
|
|
3532
|
+
},
|
|
3533
|
+
getQueryParam(key) {
|
|
3534
|
+
const { customQueryParams } = store.getState();
|
|
3535
|
+
return customQueryParams ? customQueryParams[key] : void 0;
|
|
3536
|
+
},
|
|
3537
|
+
getUrlState() {
|
|
3538
|
+
const { location, path, customQueryParams, storyId, url, viewMode } = store.getState();
|
|
3539
|
+
return {
|
|
3540
|
+
path,
|
|
3541
|
+
hash: location?.hash ?? "",
|
|
3542
|
+
queryParams: customQueryParams,
|
|
3543
|
+
storyId,
|
|
3544
|
+
url,
|
|
3545
|
+
viewMode
|
|
3546
|
+
};
|
|
3547
|
+
},
|
|
3548
|
+
setQueryParams(input) {
|
|
3549
|
+
const { customQueryParams } = store.getState();
|
|
3550
|
+
const update = { ...customQueryParams };
|
|
3551
|
+
for (const [key, value] of Object.entries(input)) if (value === null || value === void 0) delete update[key];
|
|
3552
|
+
else update[key] = value;
|
|
3553
|
+
if (!dequal(customQueryParams, update)) {
|
|
3554
|
+
store.setState({ customQueryParams: update });
|
|
3555
|
+
provider.channel?.emit(UPDATE_QUERY_PARAMS, update);
|
|
3556
|
+
}
|
|
3557
|
+
},
|
|
3558
|
+
applyQueryParams(input, options) {
|
|
3559
|
+
const { path, hash = "", queryParams } = api.getUrlState();
|
|
3560
|
+
navigateTo(`${path}${hash}`, {
|
|
3561
|
+
...queryParams,
|
|
3562
|
+
...input
|
|
3563
|
+
}, options);
|
|
3564
|
+
api.setQueryParams(input);
|
|
3565
|
+
},
|
|
3566
|
+
navigateUrl(url, options) {
|
|
3567
|
+
navigate(url, {
|
|
3568
|
+
plain: true,
|
|
3569
|
+
...options
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
};
|
|
3573
|
+
/**
|
|
3574
|
+
* Sets `args` parameter in URL, omitting any args that have their initial value or cannot be
|
|
3575
|
+
* unserialized safely.
|
|
3576
|
+
*/
|
|
3577
|
+
const updateArgsParam = () => {
|
|
3578
|
+
const { path, hash = "", queryParams, viewMode } = api.getUrlState();
|
|
3579
|
+
if (viewMode !== "story") return;
|
|
3580
|
+
const currentStory = fullAPI.getCurrentStoryData();
|
|
3581
|
+
if (currentStory?.type !== "story") return;
|
|
3582
|
+
const { args, initialArgs } = currentStory;
|
|
3583
|
+
const argsString = buildArgsParam(initialArgs, args);
|
|
3584
|
+
navigateTo(`${path}${hash}`, {
|
|
3585
|
+
...queryParams,
|
|
3586
|
+
args: argsString || null
|
|
3587
|
+
}, { replace: true });
|
|
3588
|
+
api.setQueryParams({ args: argsString || null });
|
|
3589
|
+
};
|
|
3590
|
+
provider.channel?.on(SET_CURRENT_STORY, () => updateArgsParam());
|
|
3591
|
+
let handleOrId;
|
|
3592
|
+
provider.channel?.on(STORY_ARGS_UPDATED, () => {
|
|
3593
|
+
if ("requestIdleCallback" in scope.window) {
|
|
3594
|
+
if (handleOrId) scope.window.cancelIdleCallback(handleOrId);
|
|
3595
|
+
handleOrId = scope.window.requestIdleCallback(updateArgsParam, { timeout: 1e3 });
|
|
3596
|
+
} else {
|
|
3597
|
+
if (handleOrId) clearTimeout(handleOrId);
|
|
3598
|
+
setTimeout(updateArgsParam, 100);
|
|
3599
|
+
}
|
|
3600
|
+
});
|
|
3601
|
+
provider.channel?.on(GLOBALS_UPDATED, ({ userGlobals, initialGlobals }) => {
|
|
3602
|
+
const { path, hash = "", queryParams } = api.getUrlState();
|
|
3603
|
+
const globalsString = buildArgsParam(initialGlobals, merge_default(initialGlobals, userGlobals));
|
|
3604
|
+
navigateTo(`${path}${hash}`, {
|
|
3605
|
+
...queryParams,
|
|
3606
|
+
globals: globalsString || null
|
|
3607
|
+
}, { replace: true });
|
|
3608
|
+
api.setQueryParams({ globals: globalsString || null });
|
|
3609
|
+
});
|
|
3610
|
+
provider.channel?.on(NAVIGATE_URL, (url, options) => {
|
|
3611
|
+
api.navigateUrl(url, options);
|
|
3612
|
+
});
|
|
3613
|
+
return {
|
|
3614
|
+
api,
|
|
3615
|
+
state: initialUrlSupport(moduleArgs),
|
|
3616
|
+
init: () => {
|
|
3617
|
+
store.registerPersistenceHandler("url", (_patch, serialize) => {
|
|
3618
|
+
if (serialize) {
|
|
3619
|
+
const params = serialize(store.getState());
|
|
3620
|
+
api.applyQueryParams(params, { replace: true });
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
};
|
|
3625
|
+
};
|
|
3626
|
+
})))();
|
|
3627
|
+
}
|
|
3628
|
+
//#endregion
|
|
3629
|
+
//#region src/manager-api/version.ts
|
|
3630
|
+
var version;
|
|
3631
|
+
function init_version() {
|
|
3632
|
+
return (init_version = __esmMin((() => {
|
|
3633
|
+
version = "11.0.0-alpha.6";
|
|
3634
|
+
})))();
|
|
3635
|
+
}
|
|
3636
|
+
//#endregion
|
|
3637
|
+
//#region src/manager-api/modules/versions.ts
|
|
3638
|
+
var versions_exports = /* @__PURE__ */ __exportAll({ init: () => init$1 });
|
|
3639
|
+
var import_memoizerific, import_semver, VERSIONCHECK, getVersionCheckData, normalizeRendererName, init$1;
|
|
3640
|
+
function init_versions() {
|
|
3641
|
+
return (init_versions = __esmMin((() => {
|
|
3642
|
+
init_dist$1();
|
|
3643
|
+
import_memoizerific = /* @__PURE__ */ __toESM(require_memoizerific(), 1);
|
|
3644
|
+
import_semver = /* @__PURE__ */ __toESM(require_semver(), 1);
|
|
3645
|
+
init_version();
|
|
3646
|
+
({VERSIONCHECK} = scope);
|
|
3647
|
+
getVersionCheckData = (0, import_memoizerific.default)(1)(() => {
|
|
3648
|
+
try {
|
|
3649
|
+
return { ...JSON.parse(VERSIONCHECK).data || {} };
|
|
3650
|
+
} catch (e) {
|
|
3651
|
+
return {};
|
|
3652
|
+
}
|
|
3653
|
+
});
|
|
3654
|
+
normalizeRendererName = (renderer) => {
|
|
3655
|
+
if (renderer.includes("vue")) return "vue";
|
|
3656
|
+
return renderer;
|
|
3657
|
+
};
|
|
3658
|
+
init$1 = ({ store }) => {
|
|
3659
|
+
const { dismissedVersionNotification } = store.getState();
|
|
3660
|
+
const state = {
|
|
3661
|
+
versions: {
|
|
3662
|
+
current: { version },
|
|
3663
|
+
...getVersionCheckData()
|
|
3664
|
+
},
|
|
3665
|
+
dismissedVersionNotification
|
|
3666
|
+
};
|
|
3667
|
+
const api = {
|
|
3668
|
+
getCurrentVersion: () => {
|
|
3669
|
+
const { versions: { current } } = store.getState();
|
|
3670
|
+
return current;
|
|
3671
|
+
},
|
|
3672
|
+
getLatestVersion: () => {
|
|
3673
|
+
const { versions: { latest, next, current } } = store.getState();
|
|
3674
|
+
if (current && import_semver.default.prerelease(current.version) && next) return latest && import_semver.default.gt(latest.version, next.version) ? latest : next;
|
|
3675
|
+
return latest;
|
|
3676
|
+
},
|
|
3677
|
+
getDocsUrl: ({ asset, subpath = asset, versioned, renderer, ref = "ui" }) => {
|
|
3678
|
+
const { versions } = store.getState();
|
|
3679
|
+
const latestVersion = versions.latest?.version;
|
|
3680
|
+
const currentVersion = versions.current?.version;
|
|
3681
|
+
const activeVersion = currentVersion?.startsWith("0.0.0") && latestVersion || currentVersion;
|
|
3682
|
+
let url = `https://storybook.js.org/${asset ? "docs-assets" : "docs"}/`;
|
|
3683
|
+
if (asset && activeVersion) url += `${import_semver.default.major(activeVersion)}.${import_semver.default.minor(activeVersion)}/`;
|
|
3684
|
+
else if (versioned && activeVersion && latestVersion) {
|
|
3685
|
+
const versionDiff = import_semver.default.diff(latestVersion, activeVersion);
|
|
3686
|
+
if (!(versionDiff === "patch" || versionDiff === null)) url += `${import_semver.default.major(activeVersion)}.${import_semver.default.minor(activeVersion)}/`;
|
|
3687
|
+
}
|
|
3688
|
+
const [cleanedSubpath, hash] = subpath?.split("#") || [];
|
|
3689
|
+
if (cleanedSubpath) url += asset ? cleanedSubpath : `${cleanedSubpath}/`;
|
|
3690
|
+
if (renderer && typeof scope.FORKBOOK_RENDERER !== "undefined") {
|
|
3691
|
+
const rendererName = scope.FORKBOOK_RENDERER;
|
|
3692
|
+
if (rendererName) url += `?renderer=${normalizeRendererName(rendererName)}`;
|
|
3693
|
+
}
|
|
3694
|
+
if (ref) url += `${url.includes("?") ? "&" : "?"}ref=${ref}`;
|
|
3695
|
+
if (hash) url += `#${hash}`;
|
|
3696
|
+
return url;
|
|
3697
|
+
},
|
|
3698
|
+
versionUpdateAvailable: () => {
|
|
3699
|
+
const latest = api.getLatestVersion();
|
|
3700
|
+
const current = api.getCurrentVersion();
|
|
3701
|
+
if (latest) {
|
|
3702
|
+
if (!latest.version) return true;
|
|
3703
|
+
if (!current.version) return true;
|
|
3704
|
+
const actualCurrent = !!import_semver.default.prerelease(current.version) ? `${import_semver.default.major(current.version)}.${import_semver.default.minor(current.version)}.${import_semver.default.patch(current.version)}` : current.version;
|
|
3705
|
+
const diff = import_semver.default.diff(actualCurrent, latest.version);
|
|
3706
|
+
return import_semver.default.gt(latest.version, actualCurrent) && diff !== "patch" && !diff.includes("pre");
|
|
3707
|
+
}
|
|
3708
|
+
return false;
|
|
3709
|
+
}
|
|
3710
|
+
};
|
|
3711
|
+
const initModule = async () => {
|
|
3712
|
+
const { versions = {} } = store.getState();
|
|
3713
|
+
const { latest, next } = getVersionCheckData();
|
|
3714
|
+
await store.setState({ versions: {
|
|
3715
|
+
...versions,
|
|
3716
|
+
latest,
|
|
3717
|
+
next
|
|
3718
|
+
} });
|
|
3719
|
+
};
|
|
3720
|
+
return {
|
|
3721
|
+
init: initModule,
|
|
3722
|
+
state,
|
|
3723
|
+
api
|
|
3724
|
+
};
|
|
3725
|
+
};
|
|
3726
|
+
})))();
|
|
3727
|
+
}
|
|
3728
|
+
//#endregion
|
|
3729
|
+
//#region src/manager-api/modules/whatsnew.tsx
|
|
3730
|
+
var whatsnew_exports = /* @__PURE__ */ __exportAll({ init: () => init });
|
|
3731
|
+
var import_react$3, WHATS_NEW_NOTIFICATION_ID, StorybookIcon, init;
|
|
3732
|
+
function init_whatsnew() {
|
|
3733
|
+
return (init_whatsnew = __esmMin((() => {
|
|
3734
|
+
import_react$3 = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
3735
|
+
init_core_events();
|
|
3736
|
+
init_dist$1();
|
|
3737
|
+
WHATS_NEW_NOTIFICATION_ID = "whats-new";
|
|
3738
|
+
StorybookIcon = ({ color = "currentColor", size = 14 }) => {
|
|
3739
|
+
return /* @__PURE__ */ import_react$3.default.createElement("svg", {
|
|
3740
|
+
width: size,
|
|
3741
|
+
height: size,
|
|
3742
|
+
viewBox: "0 0 14 14",
|
|
3743
|
+
fill: "none",
|
|
3744
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3745
|
+
}, /* @__PURE__ */ import_react$3.default.createElement("path", {
|
|
3746
|
+
fillRule: "evenodd",
|
|
3747
|
+
clipRule: "evenodd",
|
|
3748
|
+
d: "M2.042.616a.704.704 0 00-.66.729L1.816 12.9c.014.367.306.66.672.677l9.395.422h.032a.704.704 0 00.704-.703V.704c0-.015 0-.03-.002-.044a.704.704 0 00-.746-.659l-.773.049.057 1.615a.105.105 0 01-.17.086l-.52-.41-.617.468a.105.105 0 01-.168-.088L9.746.134 2.042.616zm8.003 4.747c-.247.192-2.092.324-2.092.05.04-1.045-.429-1.091-.689-1.091-.247 0-.662.075-.662.634 0 .57.607.893 1.32 1.27 1.014.538 2.24 1.188 2.24 2.823 0 1.568-1.273 2.433-2.898 2.433-1.676 0-3.141-.678-2.976-3.03.065-.275 2.197-.21 2.197 0-.026.971.195 1.256.753 1.256.43 0 .624-.236.624-.634 0-.602-.633-.958-1.361-1.367-.987-.554-2.148-1.205-2.148-2.7 0-1.494 1.027-2.489 2.86-2.489 1.832 0 2.832.98 2.832 2.845z",
|
|
3749
|
+
fill: color
|
|
3750
|
+
}));
|
|
3751
|
+
};
|
|
3752
|
+
init = ({ fullAPI, store, provider }) => {
|
|
3753
|
+
const state = { whatsNewData: void 0 };
|
|
3754
|
+
function setWhatsNewState(newState) {
|
|
3755
|
+
store.setState({ whatsNewData: newState });
|
|
3756
|
+
state.whatsNewData = newState;
|
|
3757
|
+
}
|
|
3758
|
+
const api = {
|
|
3759
|
+
isWhatsNewUnread() {
|
|
3760
|
+
return state.whatsNewData?.status === "SUCCESS" && !state.whatsNewData.postIsRead;
|
|
3761
|
+
},
|
|
3762
|
+
whatsNewHasBeenRead() {
|
|
3763
|
+
if (state.whatsNewData?.status === "SUCCESS") {
|
|
3764
|
+
setWhatsNewCache({ lastReadPost: state.whatsNewData.url });
|
|
3765
|
+
setWhatsNewState({
|
|
3766
|
+
...state.whatsNewData,
|
|
3767
|
+
postIsRead: true
|
|
3768
|
+
});
|
|
3769
|
+
fullAPI.clearNotification(WHATS_NEW_NOTIFICATION_ID);
|
|
3770
|
+
}
|
|
3771
|
+
},
|
|
3772
|
+
toggleWhatsNewNotifications() {
|
|
3773
|
+
if (state.whatsNewData?.status === "SUCCESS") {
|
|
3774
|
+
setWhatsNewState({
|
|
3775
|
+
...state.whatsNewData,
|
|
3776
|
+
disableWhatsNewNotifications: !state.whatsNewData.disableWhatsNewNotifications
|
|
3777
|
+
});
|
|
3778
|
+
provider.channel?.emit(TOGGLE_WHATS_NEW_NOTIFICATIONS, { disableWhatsNewNotifications: state.whatsNewData.disableWhatsNewNotifications });
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
};
|
|
3782
|
+
function getLatestWhatsNewPost() {
|
|
3783
|
+
provider.channel?.emit(REQUEST_WHATS_NEW_DATA);
|
|
3784
|
+
return new Promise((resolve) => provider.channel?.once(RESULT_WHATS_NEW_DATA, ({ data }) => resolve(data)));
|
|
3785
|
+
}
|
|
3786
|
+
function setWhatsNewCache(cache) {
|
|
3787
|
+
provider.channel?.emit(SET_WHATS_NEW_CACHE, cache);
|
|
3788
|
+
}
|
|
3789
|
+
const initModule = async () => {
|
|
3790
|
+
if (scope.CONFIG_TYPE !== "DEVELOPMENT") return;
|
|
3791
|
+
const whatsNewData = await getLatestWhatsNewPost();
|
|
3792
|
+
setWhatsNewState(whatsNewData);
|
|
3793
|
+
const urlState = fullAPI.getUrlState();
|
|
3794
|
+
if (!(urlState?.path === "/review/" || urlState?.path === "/review" || urlState?.path?.startsWith("/review/")) && whatsNewData.status === "SUCCESS" && !whatsNewData.disableWhatsNewNotifications && whatsNewData.showNotification) fullAPI.addNotification({
|
|
3795
|
+
id: WHATS_NEW_NOTIFICATION_ID,
|
|
3796
|
+
link: "/settings/whats-new",
|
|
3797
|
+
content: {
|
|
3798
|
+
headline: whatsNewData.title,
|
|
3799
|
+
subHeadline: "Learn what's new in Forkbook"
|
|
3800
|
+
},
|
|
3801
|
+
icon: /* @__PURE__ */ import_react$3.default.createElement(StorybookIcon, null),
|
|
3802
|
+
onClear({ dismissed }) {
|
|
3803
|
+
if (dismissed) setWhatsNewCache({ lastDismissedPost: whatsNewData.url });
|
|
3804
|
+
}
|
|
3805
|
+
});
|
|
3806
|
+
};
|
|
3807
|
+
return {
|
|
3808
|
+
init: initModule,
|
|
3809
|
+
state,
|
|
3810
|
+
api
|
|
3811
|
+
};
|
|
3812
|
+
};
|
|
3813
|
+
})))();
|
|
3814
|
+
}
|
|
3815
|
+
//#endregion
|
|
3816
|
+
//#region src/manager-api/lib/store-setup.ts
|
|
3817
|
+
var store_setup_default;
|
|
3818
|
+
function init_store_setup() {
|
|
3819
|
+
return (init_store_setup = __esmMin((() => {
|
|
3820
|
+
init_dist();
|
|
3821
|
+
store_setup_default = (_) => {
|
|
3822
|
+
_.fn("set", function(key, data) {
|
|
3823
|
+
return _.set(this._area, this._in(key), stringify(data, { maxDepth: 50 }));
|
|
3824
|
+
});
|
|
3825
|
+
_.fn("get", function(key, alt) {
|
|
3826
|
+
const value = _.get(this._area, this._in(key));
|
|
3827
|
+
return value !== null ? parse(value) : alt || value;
|
|
3828
|
+
});
|
|
3829
|
+
};
|
|
3830
|
+
})))();
|
|
3831
|
+
}
|
|
3832
|
+
//#endregion
|
|
3833
|
+
//#region src/manager-api/store.ts
|
|
3834
|
+
function get(storage) {
|
|
3835
|
+
return storage.get("@storybook/manager/store") || {};
|
|
3836
|
+
}
|
|
3837
|
+
function set(storage, value) {
|
|
3838
|
+
return storage.set(STORAGE_KEY, value);
|
|
3839
|
+
}
|
|
3840
|
+
function update(storage, patch) {
|
|
3841
|
+
return set(storage, {
|
|
3842
|
+
...get(storage),
|
|
3843
|
+
...patch
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3846
|
+
var import_store2, STORAGE_KEY, Store;
|
|
3847
|
+
function init_store() {
|
|
3848
|
+
return (init_store = __esmMin((() => {
|
|
3849
|
+
import_store2 = /* @__PURE__ */ __toESM(require_store2(), 1);
|
|
3850
|
+
init_store_setup();
|
|
3851
|
+
store_setup_default(import_store2.default._);
|
|
3852
|
+
STORAGE_KEY = "@storybook/manager/store";
|
|
3853
|
+
Store = class {
|
|
3854
|
+
constructor({ allowPersistence, setState, getState }) {
|
|
3855
|
+
this.persistenceHandlers = /* @__PURE__ */ new Map();
|
|
3856
|
+
this.upstreamPersistence = allowPersistence ?? true;
|
|
3857
|
+
this.upstreamSetState = setState;
|
|
3858
|
+
this.upstreamGetState = getState;
|
|
3859
|
+
}
|
|
3860
|
+
registerPersistenceHandler(key, handler) {
|
|
3861
|
+
this.persistenceHandlers.set(key, handler);
|
|
3862
|
+
}
|
|
3863
|
+
getInitialState(base) {
|
|
3864
|
+
const { includedTagFilters: _included, excludedTagFilters: _excluded, ...local } = get(import_store2.default.local);
|
|
3865
|
+
const session = get(import_store2.default.session);
|
|
3866
|
+
return {
|
|
3867
|
+
...base,
|
|
3868
|
+
...local,
|
|
3869
|
+
...session
|
|
3870
|
+
};
|
|
3871
|
+
}
|
|
3872
|
+
getState() {
|
|
3873
|
+
return this.upstreamGetState();
|
|
3874
|
+
}
|
|
3875
|
+
async setState(inputPatch, cbOrOptions, inputOptions) {
|
|
3876
|
+
let callback;
|
|
3877
|
+
let options;
|
|
3878
|
+
if (typeof cbOrOptions === "function") {
|
|
3879
|
+
callback = cbOrOptions;
|
|
3880
|
+
options = inputOptions;
|
|
3881
|
+
} else options = cbOrOptions;
|
|
3882
|
+
const { persistence = "none" } = options || {};
|
|
3883
|
+
let patch = {};
|
|
3884
|
+
let delta = {};
|
|
3885
|
+
if (typeof inputPatch === "function") patch = (state) => {
|
|
3886
|
+
delta = inputPatch(state);
|
|
3887
|
+
return delta;
|
|
3888
|
+
};
|
|
3889
|
+
else {
|
|
3890
|
+
patch = inputPatch;
|
|
3891
|
+
delta = patch;
|
|
3892
|
+
}
|
|
3893
|
+
const newState = await new Promise((resolve) => {
|
|
3894
|
+
this.upstreamSetState(patch, () => {
|
|
3895
|
+
resolve(this.getState());
|
|
3896
|
+
});
|
|
3897
|
+
});
|
|
3898
|
+
if (persistence !== "none" && this.upstreamPersistence) {
|
|
3899
|
+
if (persistence === "url") {
|
|
3900
|
+
const handler = this.persistenceHandlers.get("url");
|
|
3901
|
+
if (handler) await handler(delta, options?.serialize);
|
|
3902
|
+
} else await update(persistence === "session" ? import_store2.default.session : import_store2.default.local, delta);
|
|
3903
|
+
}
|
|
3904
|
+
if (callback) callback(newState);
|
|
3905
|
+
return newState;
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
})))();
|
|
3909
|
+
}
|
|
3910
|
+
//#endregion
|
|
3911
|
+
//#region src/manager-api/lib/request-response.ts
|
|
3912
|
+
var RequestResponseError, experimental_requestResponse;
|
|
3913
|
+
function init_request_response() {
|
|
3914
|
+
return (init_request_response = __esmMin((() => {
|
|
3915
|
+
RequestResponseError = class extends Error {
|
|
3916
|
+
constructor(message, payload) {
|
|
3917
|
+
super(message);
|
|
3918
|
+
this.payload = void 0;
|
|
3919
|
+
this.payload = payload;
|
|
3920
|
+
}
|
|
3921
|
+
};
|
|
3922
|
+
experimental_requestResponse = (channel, requestEvent, responseEvent, payload, timeout = 5e3) => {
|
|
3923
|
+
let timeoutId;
|
|
3924
|
+
return new Promise((resolve, reject) => {
|
|
3925
|
+
const request = {
|
|
3926
|
+
id: Math.random().toString(16).slice(2),
|
|
3927
|
+
payload
|
|
3928
|
+
};
|
|
3929
|
+
const responseHandler = (response) => {
|
|
3930
|
+
if (response.id !== request.id) return;
|
|
3931
|
+
clearTimeout(timeoutId);
|
|
3932
|
+
channel.off(responseEvent, responseHandler);
|
|
3933
|
+
if (response.success) resolve(response.payload);
|
|
3934
|
+
else reject(new RequestResponseError(response.error, response.payload));
|
|
3935
|
+
};
|
|
3936
|
+
channel.emit(requestEvent, request);
|
|
3937
|
+
channel.on(responseEvent, responseHandler);
|
|
3938
|
+
timeoutId = setTimeout(() => {
|
|
3939
|
+
channel.off(responseEvent, responseHandler);
|
|
3940
|
+
reject(new RequestResponseError("Timed out waiting for response"));
|
|
3941
|
+
}, timeout);
|
|
3942
|
+
});
|
|
3943
|
+
};
|
|
3944
|
+
})))();
|
|
3945
|
+
}
|
|
3946
|
+
//#endregion
|
|
3947
|
+
//#region src/manager-api/root.tsx
|
|
3948
|
+
function ManagerConsumer({ filter = defaultFilter, children }) {
|
|
3949
|
+
const managerContext = (0, import_react$2.useContext)(ManagerContext);
|
|
3950
|
+
const renderer = (0, import_react$2.useRef)(children);
|
|
3951
|
+
const filterer = (0, import_react$2.useRef)(filter);
|
|
3952
|
+
if (typeof renderer.current !== "function") return /* @__PURE__ */ import_react$2.default.createElement(import_react$2.Fragment, null, renderer.current);
|
|
3953
|
+
const comboData = filterer.current(managerContext);
|
|
3954
|
+
const comboDataArray = (0, import_react$2.useMemo)(() => {
|
|
3955
|
+
return [...Object.entries(comboData).reduce((acc, keyval) => acc.concat(keyval), [])];
|
|
3956
|
+
}, [managerContext.state]);
|
|
3957
|
+
return (0, import_react$2.useMemo)(() => {
|
|
3958
|
+
const Child = renderer.current;
|
|
3959
|
+
return /* @__PURE__ */ import_react$2.default.createElement(Child, comboData);
|
|
3960
|
+
}, comboDataArray);
|
|
3961
|
+
}
|
|
3962
|
+
function useStorybookState() {
|
|
3963
|
+
const { state } = (0, import_react$2.useContext)(ManagerContext);
|
|
3964
|
+
return state;
|
|
3965
|
+
}
|
|
3966
|
+
function useStorybookApi() {
|
|
3967
|
+
const { api } = (0, import_react$2.useContext)(ManagerContext);
|
|
3968
|
+
return api;
|
|
3969
|
+
}
|
|
3970
|
+
function orDefault(fromStore, defaultState) {
|
|
3971
|
+
if (typeof fromStore === "undefined") return defaultState;
|
|
3972
|
+
return fromStore;
|
|
3973
|
+
}
|
|
3974
|
+
function useStoryPrepared(storyId) {
|
|
3975
|
+
return useStorybookApi().isPrepared(storyId);
|
|
3976
|
+
}
|
|
3977
|
+
function useParameter(parameterKey, defaultValue) {
|
|
3978
|
+
const api = useStorybookApi();
|
|
3979
|
+
const [parameter, setParameter] = (0, import_react$2.useState)(api.getCurrentParameter(parameterKey));
|
|
3980
|
+
const handleParameterChange = (0, import_react$2.useCallback)(() => {
|
|
3981
|
+
const newParameter = api.getCurrentParameter(parameterKey);
|
|
3982
|
+
setParameter(newParameter);
|
|
3983
|
+
}, [api, parameterKey]);
|
|
3984
|
+
useChannel({
|
|
3985
|
+
[STORY_PREPARED]: handleParameterChange,
|
|
3986
|
+
[DOCS_PREPARED]: handleParameterChange
|
|
3987
|
+
}, [handleParameterChange]);
|
|
3988
|
+
return orDefault(parameter, defaultValue);
|
|
3989
|
+
}
|
|
3990
|
+
function useSharedState(stateId, defaultState) {
|
|
3991
|
+
const api = useStorybookApi();
|
|
3992
|
+
const state = orDefault(api.getAddonState(stateId) || FORKBOOK_ADDON_STATE[stateId], FORKBOOK_ADDON_STATE[stateId] ? FORKBOOK_ADDON_STATE[stateId] : defaultState);
|
|
3993
|
+
let quicksync = false;
|
|
3994
|
+
if (state === defaultState && defaultState !== void 0) {
|
|
3995
|
+
FORKBOOK_ADDON_STATE[stateId] = defaultState;
|
|
3996
|
+
quicksync = true;
|
|
3997
|
+
}
|
|
3998
|
+
(0, import_react$2.useEffect)(() => {
|
|
3999
|
+
if (quicksync) api.setAddonState(stateId, defaultState);
|
|
4000
|
+
}, [quicksync]);
|
|
4001
|
+
const setState = (0, import_react$2.useCallback)(async (s, options) => {
|
|
4002
|
+
await api.setAddonState(stateId, s, options);
|
|
4003
|
+
const result = api.getAddonState(stateId);
|
|
4004
|
+
FORKBOOK_ADDON_STATE[stateId] = result;
|
|
4005
|
+
return result;
|
|
4006
|
+
}, [api, stateId]);
|
|
4007
|
+
const allListeners = (0, import_react$2.useMemo)(() => {
|
|
4008
|
+
const stateChangeHandlers = {
|
|
4009
|
+
[`${SHARED_STATE_CHANGED}-client-${stateId}`]: setState,
|
|
4010
|
+
[`${SHARED_STATE_SET}-client-${stateId}`]: setState
|
|
4011
|
+
};
|
|
4012
|
+
const stateInitializationHandlers = {
|
|
4013
|
+
[SET_STORIES]: async () => {
|
|
4014
|
+
const currentState = api.getAddonState(stateId);
|
|
4015
|
+
if (currentState) {
|
|
4016
|
+
FORKBOOK_ADDON_STATE[stateId] = currentState;
|
|
4017
|
+
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
|
|
4018
|
+
} else if (FORKBOOK_ADDON_STATE[stateId]) {
|
|
4019
|
+
await setState(FORKBOOK_ADDON_STATE[stateId]);
|
|
4020
|
+
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, FORKBOOK_ADDON_STATE[stateId]);
|
|
4021
|
+
} else if (defaultState !== void 0) {
|
|
4022
|
+
await setState(defaultState);
|
|
4023
|
+
FORKBOOK_ADDON_STATE[stateId] = defaultState;
|
|
4024
|
+
api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, defaultState);
|
|
4025
|
+
}
|
|
4026
|
+
},
|
|
4027
|
+
[STORY_CHANGED]: () => {
|
|
4028
|
+
const currentState = api.getAddonState(stateId);
|
|
4029
|
+
if (currentState !== void 0) api.emit(`${SHARED_STATE_SET}-manager-${stateId}`, currentState);
|
|
4030
|
+
}
|
|
4031
|
+
};
|
|
4032
|
+
return {
|
|
4033
|
+
...stateChangeHandlers,
|
|
4034
|
+
...stateInitializationHandlers
|
|
4035
|
+
};
|
|
4036
|
+
}, [stateId]);
|
|
4037
|
+
const emit = useChannel(allListeners);
|
|
4038
|
+
return [state, (0, import_react$2.useCallback)(async (newStateOrMerger, options) => {
|
|
4039
|
+
await setState(newStateOrMerger, options);
|
|
4040
|
+
const result = api.getAddonState(stateId);
|
|
4041
|
+
emit(`${SHARED_STATE_CHANGED}-manager-${stateId}`, result);
|
|
4042
|
+
}, [
|
|
4043
|
+
api,
|
|
4044
|
+
emit,
|
|
4045
|
+
setState,
|
|
4046
|
+
stateId
|
|
4047
|
+
])];
|
|
4048
|
+
}
|
|
4049
|
+
function useAddonState(addonId, defaultState) {
|
|
4050
|
+
return useSharedState(addonId, defaultState);
|
|
4051
|
+
}
|
|
4052
|
+
function useArgs() {
|
|
4053
|
+
const { getCurrentStoryData, updateStoryArgs, resetStoryArgs } = useStorybookApi();
|
|
4054
|
+
const data = getCurrentStoryData();
|
|
4055
|
+
const args = data?.type === "story" ? data.args : {};
|
|
4056
|
+
const initialArgs = data?.type === "story" ? data.initialArgs : {};
|
|
4057
|
+
return [
|
|
4058
|
+
args,
|
|
4059
|
+
(0, import_react$2.useCallback)((newArgs) => updateStoryArgs(data, newArgs), [data, updateStoryArgs]),
|
|
4060
|
+
(0, import_react$2.useCallback)((argNames) => resetStoryArgs(data, argNames), [data, resetStoryArgs]),
|
|
4061
|
+
initialArgs
|
|
4062
|
+
];
|
|
4063
|
+
}
|
|
4064
|
+
function useGlobals() {
|
|
4065
|
+
const api = useStorybookApi();
|
|
4066
|
+
return [
|
|
4067
|
+
api.getGlobals(),
|
|
4068
|
+
api.updateGlobals,
|
|
4069
|
+
api.getStoryGlobals(),
|
|
4070
|
+
api.getUserGlobals()
|
|
4071
|
+
];
|
|
4072
|
+
}
|
|
4073
|
+
function useGlobalTypes() {
|
|
4074
|
+
return useStorybookApi().getGlobalTypes();
|
|
4075
|
+
}
|
|
4076
|
+
function useCurrentStory() {
|
|
4077
|
+
const { getCurrentStoryData } = useStorybookApi();
|
|
4078
|
+
return getCurrentStoryData();
|
|
4079
|
+
}
|
|
4080
|
+
function useArgTypes() {
|
|
4081
|
+
const current = useCurrentStory();
|
|
4082
|
+
return current?.type === "story" && current.argTypes || {};
|
|
4083
|
+
}
|
|
4084
|
+
var import_react$2, ActiveTabs, ManagerContext, combineParameters, ManagerProvider, EffectOnMount, defaultFilter, useChannel, FORKBOOK_ADDON_STATE, typesX;
|
|
4085
|
+
function init_root() {
|
|
4086
|
+
return (init_root = __esmMin((() => {
|
|
4087
|
+
import_react$2 = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
4088
|
+
init_core_events();
|
|
4089
|
+
init_isEqual();
|
|
4090
|
+
init_context();
|
|
4091
|
+
init_initial_state();
|
|
4092
|
+
init_addons();
|
|
4093
|
+
init_merge();
|
|
4094
|
+
init_addons$1();
|
|
4095
|
+
init_channel();
|
|
4096
|
+
init_globals$1();
|
|
4097
|
+
init_layout();
|
|
4098
|
+
init_notifications();
|
|
4099
|
+
init_open_in_editor();
|
|
4100
|
+
init_provider();
|
|
4101
|
+
init_refs();
|
|
4102
|
+
init_settings();
|
|
4103
|
+
init_shortcuts();
|
|
4104
|
+
init_stories$1();
|
|
4105
|
+
init_url$1();
|
|
4106
|
+
init_versions();
|
|
4107
|
+
init_whatsnew();
|
|
4108
|
+
init_store();
|
|
4109
|
+
init_request_response();
|
|
4110
|
+
init_platform();
|
|
4111
|
+
init_shortcut();
|
|
4112
|
+
({ActiveTabs} = layout_exports);
|
|
4113
|
+
ManagerContext = createContext({
|
|
4114
|
+
api: void 0,
|
|
4115
|
+
state: main({})
|
|
4116
|
+
});
|
|
4117
|
+
combineParameters = (...parameterSets) => noArrayMerge({}, ...parameterSets);
|
|
4118
|
+
ManagerProvider = class extends import_react$2.Component {
|
|
4119
|
+
static {
|
|
4120
|
+
this.displayName = "Manager";
|
|
4121
|
+
}
|
|
4122
|
+
constructor(props) {
|
|
4123
|
+
super(props);
|
|
4124
|
+
this.api = {};
|
|
4125
|
+
this.mounted = false;
|
|
4126
|
+
this.initModules = () => {
|
|
4127
|
+
this.modules.forEach((module) => {
|
|
4128
|
+
if ("init" in module) module.init();
|
|
4129
|
+
});
|
|
4130
|
+
};
|
|
4131
|
+
const { location, path, refId, viewMode = props.docsOptions.docsMode ? "docs" : props.viewMode, singleStory, storyId, docsOptions, navigate } = props;
|
|
4132
|
+
const store = new Store({
|
|
4133
|
+
getState: () => this.state,
|
|
4134
|
+
setState: (stateChange, callback) => {
|
|
4135
|
+
if (!this.mounted) {
|
|
4136
|
+
const patch = typeof stateChange === "function" ? stateChange(this.state) : stateChange;
|
|
4137
|
+
this.state = {
|
|
4138
|
+
...this.state,
|
|
4139
|
+
...patch
|
|
4140
|
+
};
|
|
4141
|
+
callback?.(this.state);
|
|
4142
|
+
return this.state;
|
|
4143
|
+
}
|
|
4144
|
+
this.setState(stateChange, () => callback(this.state));
|
|
4145
|
+
return this.state;
|
|
4146
|
+
}
|
|
4147
|
+
});
|
|
4148
|
+
const routeData = {
|
|
4149
|
+
location,
|
|
4150
|
+
path,
|
|
4151
|
+
viewMode,
|
|
4152
|
+
singleStory,
|
|
4153
|
+
storyId,
|
|
4154
|
+
refId
|
|
4155
|
+
};
|
|
4156
|
+
const optionsData = { docsOptions };
|
|
4157
|
+
this.state = store.getInitialState(main({
|
|
4158
|
+
...routeData,
|
|
4159
|
+
...optionsData
|
|
4160
|
+
}));
|
|
4161
|
+
const apiData = {
|
|
4162
|
+
navigate,
|
|
4163
|
+
store,
|
|
4164
|
+
provider: props.provider
|
|
4165
|
+
};
|
|
4166
|
+
this.modules = [
|
|
4167
|
+
provider_exports,
|
|
4168
|
+
channel_exports,
|
|
4169
|
+
addons_exports,
|
|
4170
|
+
layout_exports,
|
|
4171
|
+
notifications_exports,
|
|
4172
|
+
settings_exports,
|
|
4173
|
+
shortcuts_exports,
|
|
4174
|
+
stories_exports,
|
|
4175
|
+
refs_exports,
|
|
4176
|
+
globals_exports,
|
|
4177
|
+
url_exports,
|
|
4178
|
+
versions_exports,
|
|
4179
|
+
whatsnew_exports,
|
|
4180
|
+
open_in_editor_exports
|
|
4181
|
+
].map((m) => m.init({
|
|
4182
|
+
...routeData,
|
|
4183
|
+
...optionsData,
|
|
4184
|
+
...apiData,
|
|
4185
|
+
state: this.state,
|
|
4186
|
+
fullAPI: this.api
|
|
4187
|
+
}));
|
|
4188
|
+
const state = main(this.state, ...this.modules.map((m) => m.state));
|
|
4189
|
+
const api = Object.assign(this.api, { navigate }, ...this.modules.map((m) => m.api));
|
|
4190
|
+
this.state = state;
|
|
4191
|
+
this.api = api;
|
|
4192
|
+
props.provider.handleAPI(this.api);
|
|
4193
|
+
}
|
|
4194
|
+
componentDidMount() {
|
|
4195
|
+
this.mounted = true;
|
|
4196
|
+
}
|
|
4197
|
+
static getDerivedStateFromProps(props, state) {
|
|
4198
|
+
const locationSearchChanged = state.location?.search !== props.location?.search;
|
|
4199
|
+
const locationHashChanged = state.location?.hash !== props.location?.hash;
|
|
4200
|
+
if (state.path !== props.path || locationSearchChanged || locationHashChanged) return {
|
|
4201
|
+
...state,
|
|
4202
|
+
location: props.location,
|
|
4203
|
+
path: props.path,
|
|
4204
|
+
refId: props.refId,
|
|
4205
|
+
viewMode: props.viewMode,
|
|
4206
|
+
storyId: props.storyId,
|
|
4207
|
+
customQueryParams: getCustomQueryParams(props.location)
|
|
4208
|
+
};
|
|
4209
|
+
return null;
|
|
4210
|
+
}
|
|
4211
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
4212
|
+
const prevProps = this.props;
|
|
4213
|
+
const prevState = this.state;
|
|
4214
|
+
return prevProps.path !== nextProps.path || !isEqual(prevState, nextState);
|
|
4215
|
+
}
|
|
4216
|
+
render() {
|
|
4217
|
+
const { children } = this.props;
|
|
4218
|
+
const value = {
|
|
4219
|
+
state: this.state,
|
|
4220
|
+
api: this.api
|
|
4221
|
+
};
|
|
4222
|
+
return /* @__PURE__ */ import_react$2.default.createElement(EffectOnMount, { effect: this.initModules }, /* @__PURE__ */ import_react$2.default.createElement(ManagerContext.Provider, { value }, /* @__PURE__ */ import_react$2.default.createElement(ManagerConsumer, null, children)));
|
|
4223
|
+
}
|
|
4224
|
+
};
|
|
4225
|
+
EffectOnMount = ({ children, effect }) => {
|
|
4226
|
+
import_react$2.useEffect(effect, []);
|
|
4227
|
+
return children;
|
|
4228
|
+
};
|
|
4229
|
+
defaultFilter = (c) => c;
|
|
4230
|
+
useChannel = (eventMap, deps = []) => {
|
|
4231
|
+
const api = useStorybookApi();
|
|
4232
|
+
(0, import_react$2.useEffect)(() => {
|
|
4233
|
+
Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener));
|
|
4234
|
+
return () => {
|
|
4235
|
+
Object.entries(eventMap).forEach(([type, listener]) => api.off(type, listener));
|
|
4236
|
+
};
|
|
4237
|
+
}, deps);
|
|
4238
|
+
return api.emit;
|
|
4239
|
+
};
|
|
4240
|
+
globalThis.FORKBOOK_ADDON_STATE = {};
|
|
4241
|
+
({FORKBOOK_ADDON_STATE} = globalThis);
|
|
4242
|
+
typesX = Addon_TypesEnum;
|
|
4243
|
+
})))();
|
|
4244
|
+
}
|
|
4245
|
+
//#endregion
|
|
4246
|
+
//#region src/manager-api/stores/test-provider.ts
|
|
4247
|
+
var testProviderStore, fullTestProviderStore, getTestProviderStoreById, useTestProviderStore, universalTestProviderStore;
|
|
4248
|
+
function init_test_provider() {
|
|
4249
|
+
return (init_test_provider = __esmMin((() => {
|
|
4250
|
+
init_test_provider_store();
|
|
4251
|
+
init_universal_store();
|
|
4252
|
+
init_use_universal_store_manager();
|
|
4253
|
+
testProviderStore = createTestProviderStore({
|
|
4254
|
+
universalTestProviderStore: UniversalStore.create({
|
|
4255
|
+
...UNIVERSAL_TEST_PROVIDER_STORE_OPTIONS,
|
|
4256
|
+
leader: globalThis.CONFIG_TYPE === "PRODUCTION"
|
|
4257
|
+
}),
|
|
4258
|
+
useUniversalStore
|
|
4259
|
+
});
|
|
4260
|
+
({fullTestProviderStore, getTestProviderStoreById, useTestProviderStore, universalTestProviderStore} = testProviderStore);
|
|
4261
|
+
})))();
|
|
4262
|
+
}
|
|
4263
|
+
//#endregion
|
|
4264
|
+
//#region src/manager-api/index.ts
|
|
4265
|
+
var manager_api_exports = /* @__PURE__ */ __exportAll({
|
|
4266
|
+
ActiveTabs: () => ActiveTabs,
|
|
4267
|
+
Consumer: () => ManagerConsumer,
|
|
4268
|
+
ManagerContext: () => ManagerContext,
|
|
4269
|
+
Provider: () => ManagerProvider,
|
|
4270
|
+
RequestResponseError: () => RequestResponseError,
|
|
4271
|
+
Tag: () => Tag,
|
|
4272
|
+
addons: () => addons$1,
|
|
4273
|
+
combineParameters: () => combineParameters,
|
|
4274
|
+
controlOrMetaKey: () => controlOrMetaKey$1,
|
|
4275
|
+
controlOrMetaSymbol: () => controlOrMetaSymbol,
|
|
4276
|
+
eventMatchesShortcut: () => eventMatchesShortcut,
|
|
4277
|
+
eventToShortcut: () => eventToShortcut,
|
|
4278
|
+
experimental_MockUniversalStore: () => MockUniversalStore,
|
|
4279
|
+
experimental_getStatusStore: () => getStatusStoreByTypeId,
|
|
4280
|
+
experimental_getTestProviderStore: () => getTestProviderStoreById,
|
|
4281
|
+
experimental_requestResponse: () => experimental_requestResponse,
|
|
4282
|
+
experimental_useStatusStore: () => useStatusStore,
|
|
4283
|
+
experimental_useTestProviderStore: () => useTestProviderStore,
|
|
4284
|
+
getService: () => getService,
|
|
4285
|
+
internal_UniversalStore: () => UniversalStore,
|
|
4286
|
+
internal_fullStatusStore: () => fullStatusStore,
|
|
4287
|
+
internal_fullTestProviderStore: () => fullTestProviderStore,
|
|
4288
|
+
internal_universalStatusStore: () => universalStatusStore,
|
|
4289
|
+
internal_universalTestProviderStore: () => universalTestProviderStore,
|
|
4290
|
+
internal_useUniversalStore: () => useUniversalStore,
|
|
4291
|
+
isMacLike: () => isMacLike$1,
|
|
4292
|
+
isShortcutTaken: () => isShortcutTaken,
|
|
4293
|
+
keyToSymbol: () => keyToSymbol,
|
|
4294
|
+
merge: () => merge_default,
|
|
4295
|
+
optionOrAltSymbol: () => optionOrAltSymbol,
|
|
4296
|
+
registerService: () => registerService,
|
|
4297
|
+
shortcutMatchesShortcut: () => shortcutMatchesShortcut,
|
|
4298
|
+
shortcutToAriaKeyshortcuts: () => shortcutToAriaKeyshortcuts,
|
|
4299
|
+
shortcutToHumanString: () => shortcutToHumanString,
|
|
4300
|
+
types: () => typesX,
|
|
4301
|
+
useAddonState: () => useAddonState,
|
|
4302
|
+
useArgTypes: () => useArgTypes,
|
|
4303
|
+
useArgs: () => useArgs,
|
|
4304
|
+
useChannel: () => useChannel,
|
|
4305
|
+
useGlobalTypes: () => useGlobalTypes,
|
|
4306
|
+
useGlobals: () => useGlobals,
|
|
4307
|
+
useParameter: () => useParameter,
|
|
4308
|
+
useServiceCommand: () => useServiceCommand,
|
|
4309
|
+
useServiceQuery: () => useServiceQuery,
|
|
4310
|
+
useSharedState: () => useSharedState,
|
|
4311
|
+
useStoryPrepared: () => useStoryPrepared,
|
|
4312
|
+
useStorybookApi: () => useStorybookApi,
|
|
4313
|
+
useStorybookState: () => useStorybookState
|
|
4314
|
+
});
|
|
4315
|
+
function init_manager_api() {
|
|
4316
|
+
return (init_manager_api = __esmMin((() => {
|
|
4317
|
+
init_root();
|
|
4318
|
+
init_universal_store();
|
|
4319
|
+
init_use_universal_store_manager();
|
|
4320
|
+
init_mock();
|
|
4321
|
+
init_status();
|
|
4322
|
+
init_test_provider();
|
|
4323
|
+
init_tags$1();
|
|
4324
|
+
init_manager();
|
|
4325
|
+
})))();
|
|
4326
|
+
}
|
|
4327
|
+
//#endregion
|
|
4328
|
+
//#region src/manager/hooks/useMedia.tsx
|
|
4329
|
+
function useMediaQuery(query) {
|
|
4330
|
+
const getMatches = (queryMatch) => {
|
|
4331
|
+
if (typeof window !== "undefined") return window.matchMedia(queryMatch).matches;
|
|
4332
|
+
return false;
|
|
4333
|
+
};
|
|
4334
|
+
const [matches, setMatches] = (0, import_react$1.useState)(getMatches(query));
|
|
4335
|
+
function handleChange() {
|
|
4336
|
+
setMatches(getMatches(query));
|
|
4337
|
+
}
|
|
4338
|
+
(0, import_react$1.useEffect)(() => {
|
|
4339
|
+
const matchMedia = window.matchMedia(query);
|
|
4340
|
+
handleChange();
|
|
4341
|
+
matchMedia.addEventListener("change", handleChange);
|
|
4342
|
+
return () => {
|
|
4343
|
+
matchMedia.removeEventListener("change", handleChange);
|
|
4344
|
+
};
|
|
4345
|
+
}, [query]);
|
|
4346
|
+
return matches;
|
|
4347
|
+
}
|
|
4348
|
+
var import_react$1;
|
|
4349
|
+
function init_useMedia() {
|
|
4350
|
+
return (init_useMedia = __esmMin((() => {
|
|
4351
|
+
import_react$1 = require_react();
|
|
4352
|
+
})))();
|
|
4353
|
+
}
|
|
4354
|
+
//#endregion
|
|
4355
|
+
//#region src/manager/globals/runtime.ts
|
|
4356
|
+
var import_react, import_react_dom, import_client, import_jsx_runtime, globalsNameValueMap;
|
|
4357
|
+
function init_runtime() {
|
|
4358
|
+
return (init_runtime = __esmMin((() => {
|
|
4359
|
+
import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
4360
|
+
import_react_dom = /* @__PURE__ */ __toESM(require_react_dom(), 1);
|
|
4361
|
+
import_client = /* @__PURE__ */ __toESM(require_client(), 1);
|
|
4362
|
+
import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1);
|
|
4363
|
+
init_channels();
|
|
4364
|
+
init_client_logger();
|
|
4365
|
+
init_components();
|
|
4366
|
+
init_core_events();
|
|
4367
|
+
init_manager_errors();
|
|
4368
|
+
init_router();
|
|
4369
|
+
init_types();
|
|
4370
|
+
init_dist$2();
|
|
4371
|
+
init_manager_api();
|
|
4372
|
+
init_test();
|
|
4373
|
+
init_theming();
|
|
4374
|
+
init_create();
|
|
4375
|
+
globalsNameValueMap = {
|
|
4376
|
+
react: import_react,
|
|
4377
|
+
"react/jsx-runtime": import_jsx_runtime,
|
|
4378
|
+
"react/jsx-dev-runtime": {
|
|
4379
|
+
Fragment: import_jsx_runtime.Fragment,
|
|
4380
|
+
jsxDEV: import_jsx_runtime.jsx
|
|
4381
|
+
},
|
|
4382
|
+
"react-dom": import_react_dom,
|
|
4383
|
+
"react-dom/client": import_client,
|
|
4384
|
+
"@storybook/icons": dist_exports,
|
|
4385
|
+
"@aussieljk/forkbook/manager-api": manager_api_exports,
|
|
4386
|
+
"@aussieljk/forkbook/theming": theming_exports,
|
|
4387
|
+
"@aussieljk/forkbook/theming/create": create_exports,
|
|
4388
|
+
"@aussieljk/forkbook/test": test_exports,
|
|
4389
|
+
"@aussieljk/forkbook/internal/channels": channels_exports,
|
|
4390
|
+
"@aussieljk/forkbook/internal/client-logger": client_logger_exports,
|
|
4391
|
+
"@aussieljk/forkbook/internal/components": components_exports,
|
|
4392
|
+
"@aussieljk/forkbook/internal/core-events": core_events_exports,
|
|
4393
|
+
"@aussieljk/forkbook/internal/manager-errors": manager_errors_exports,
|
|
4394
|
+
"@aussieljk/forkbook/internal/router": router_exports,
|
|
4395
|
+
"@aussieljk/forkbook/internal/types": types_exports
|
|
4396
|
+
};
|
|
4397
|
+
})))();
|
|
4398
|
+
}
|
|
4399
|
+
//#endregion
|
|
4400
|
+
//#region src/manager/utils/prepareForTelemetry.ts
|
|
4401
|
+
function getBrowserInfo() {
|
|
4402
|
+
if (!browserInfo) browserInfo = new import_browser_dtector_umd_min.default(scope.navigator?.userAgent).getBrowserInfo();
|
|
4403
|
+
return browserInfo;
|
|
4404
|
+
}
|
|
4405
|
+
function prepareForTelemetry(originalError) {
|
|
4406
|
+
let error = originalError;
|
|
4407
|
+
if (originalError.target === scope || originalError.currentTarget === scope || originalError.srcElement === scope) {
|
|
4408
|
+
error = new Error(originalError.message);
|
|
4409
|
+
error.name = originalError.name || error.name;
|
|
4410
|
+
}
|
|
4411
|
+
if (!originalError.fromStorybook) error = new UncaughtManagerError({ error });
|
|
4412
|
+
error.browserInfo = getBrowserInfo();
|
|
4413
|
+
return error;
|
|
4414
|
+
}
|
|
4415
|
+
var import_browser_dtector_umd_min, browserInfo, errorMessages, shouldSkipError;
|
|
4416
|
+
function init_prepareForTelemetry() {
|
|
4417
|
+
return (init_prepareForTelemetry = __esmMin((() => {
|
|
4418
|
+
init_manager_errors();
|
|
4419
|
+
init_dist$1();
|
|
4420
|
+
import_browser_dtector_umd_min = /* @__PURE__ */ __toESM(require_browser_dtector_umd_min(), 1);
|
|
4421
|
+
errorMessages = [
|
|
4422
|
+
"ResizeObserver loop completed with undelivered notifications.",
|
|
4423
|
+
"ResizeObserver loop limit exceeded",
|
|
4424
|
+
"Script error.",
|
|
4425
|
+
"React is running in production mode"
|
|
4426
|
+
];
|
|
4427
|
+
shouldSkipError = (error) => errorMessages.includes(error?.message);
|
|
4428
|
+
})))();
|
|
4429
|
+
}
|
|
4430
|
+
//#endregion
|
|
4431
|
+
//#region src/manager/globals-runtime.ts
|
|
4432
|
+
var queuedErrors;
|
|
4433
|
+
function init_globals_runtime() {
|
|
4434
|
+
return (init_globals_runtime = __esmMin((() => {
|
|
4435
|
+
init_channels();
|
|
4436
|
+
init_core_events();
|
|
4437
|
+
init_globals();
|
|
4438
|
+
init_runtime();
|
|
4439
|
+
init_prepareForTelemetry();
|
|
4440
|
+
globalPackages.forEach((key) => {
|
|
4441
|
+
globalThis[globalsNameReferenceMap[key]] = globalsNameValueMap[key];
|
|
4442
|
+
});
|
|
4443
|
+
queuedErrors = [];
|
|
4444
|
+
globalThis.sendTelemetryError = (error) => {
|
|
4445
|
+
if (shouldSkipError(error)) return;
|
|
4446
|
+
const channel = getChannel();
|
|
4447
|
+
const preparedError = prepareForTelemetry(error);
|
|
4448
|
+
if (!channel) {
|
|
4449
|
+
queuedErrors.push(preparedError);
|
|
4450
|
+
return;
|
|
4451
|
+
}
|
|
4452
|
+
while (queuedErrors.length > 0) {
|
|
4453
|
+
const queuedError = queuedErrors.shift();
|
|
4454
|
+
channel.emit(TELEMETRY_ERROR, queuedError);
|
|
4455
|
+
}
|
|
4456
|
+
channel.emit(TELEMETRY_ERROR, preparedError);
|
|
4457
|
+
};
|
|
4458
|
+
globalThis.addEventListener("error", (args) => {
|
|
4459
|
+
const error = args.error || args;
|
|
4460
|
+
globalThis.sendTelemetryError(error);
|
|
4461
|
+
});
|
|
4462
|
+
globalThis.addEventListener("unhandledrejection", ({ reason }) => {
|
|
4463
|
+
globalThis.sendTelemetryError(reason);
|
|
4464
|
+
});
|
|
4465
|
+
})))();
|
|
4466
|
+
}
|
|
4467
|
+
//#endregion
|
|
4468
|
+
export { init_manager_errors as C, UniversalStoreFollowerTimeoutError as S, StatusTypeIdMismatchError as _, init_shortcut as a, OpenServiceStaticSnapshotLoadError as b, init_instrumenter as c, isTestEnvironment as d, init_csf_utils as f, InvalidChannelPageError as g, init_addons as h, init_manager_api as i, instrument as l, addons$1 as m, init_useMedia as n, shortcutToAriaKeyshortcuts as o, sanitize as p, useMediaQuery as r, shortcutToHumanString as s, init_globals_runtime as t, init_animation_utils as u, init_preview_errors as v, StatusTypeIdMismatchError$1 as x, OpenServiceStaticSnapshotInvalidError as y };
|