@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,1218 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ro17f80mg6k from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ro17f80mg6k from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ro17f80mg6k from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ro17f80mg6k.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ro17f80mg6k.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ro17f80mg6k.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Forkbook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
formatAttachFallback
|
|
14
|
+
} from "./chunk-LXBD4UL4.js";
|
|
15
|
+
import {
|
|
16
|
+
AttachUnavailableError,
|
|
17
|
+
EnvironmentMismatchError,
|
|
18
|
+
SpawnFailedError,
|
|
19
|
+
ToolsRuntimeError,
|
|
20
|
+
attachGateReasonFromError,
|
|
21
|
+
isAttachGateError,
|
|
22
|
+
projectPathsEqual
|
|
23
|
+
} from "./chunk-3SDUYDXH.js";
|
|
24
|
+
import {
|
|
25
|
+
invokeToolsetMethod,
|
|
26
|
+
resolveToolsetDescription
|
|
27
|
+
} from "./chunk-BSKFCWQD.js";
|
|
28
|
+
import {
|
|
29
|
+
parseToolsetMethodId,
|
|
30
|
+
toCliMethodName
|
|
31
|
+
} from "./chunk-ICPBH3E7.js";
|
|
32
|
+
import {
|
|
33
|
+
deserializeError
|
|
34
|
+
} from "./chunk-3W7F2B7P.js";
|
|
35
|
+
import {
|
|
36
|
+
StorybookDevServerDisconnectedError,
|
|
37
|
+
formatIssues
|
|
38
|
+
} from "./chunk-U5W53R2J.js";
|
|
39
|
+
|
|
40
|
+
// src/cli/tools/sdk/child-protocol.ts
|
|
41
|
+
function isChildMessage(value) {
|
|
42
|
+
return typeof value == "object" && value !== null && "type" in value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/cli/tools/sdk/create-tools.ts
|
|
46
|
+
import { resolve } from "node:path";
|
|
47
|
+
import { versions } from "@aussieljk/forkbook/internal/common";
|
|
48
|
+
|
|
49
|
+
// ../../node_modules/@valibot/to-json-schema/dist/index.mjs
|
|
50
|
+
function addError(errors, message) {
|
|
51
|
+
return errors ? (errors.push(message), errors) : [message];
|
|
52
|
+
}
|
|
53
|
+
var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
|
|
54
|
+
function escapeRegExp(string) {
|
|
55
|
+
return string.replace(ESCAPE_REGEX, "\\$&");
|
|
56
|
+
}
|
|
57
|
+
function handleError(message, config) {
|
|
58
|
+
switch (config?.errorMode) {
|
|
59
|
+
case "ignore":
|
|
60
|
+
break;
|
|
61
|
+
case "warn":
|
|
62
|
+
console.warn(message);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function isJsonConstValue(value) {
|
|
69
|
+
return typeof value == "boolean" || typeof value == "number" && Number.isFinite(value) || typeof value == "string";
|
|
70
|
+
}
|
|
71
|
+
function isJsonEnumValues(values) {
|
|
72
|
+
return values.every(isJsonConstValue);
|
|
73
|
+
}
|
|
74
|
+
var ReferenceMap = class extends Map {
|
|
75
|
+
/**
|
|
76
|
+
* Creates an empty schema reference map.
|
|
77
|
+
*/
|
|
78
|
+
constructor() {
|
|
79
|
+
super(), this.count = 0, this.usedIds = /* @__PURE__ */ new Set();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Adds a schema reference and reserves its ID.
|
|
83
|
+
*
|
|
84
|
+
* @param schema The Valibot schema.
|
|
85
|
+
* @param referenceId The reference ID.
|
|
86
|
+
*
|
|
87
|
+
* @returns The reference map.
|
|
88
|
+
*/
|
|
89
|
+
set(schema, referenceId) {
|
|
90
|
+
return this.usedIds.add(referenceId), super.set(schema, referenceId);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Creates a reference ID that is not yet used.
|
|
94
|
+
*
|
|
95
|
+
* @param definitions The JSON Schema definitions.
|
|
96
|
+
*
|
|
97
|
+
* @returns The unused reference ID.
|
|
98
|
+
*/
|
|
99
|
+
createId(definitions) {
|
|
100
|
+
for (; this.usedIds.has(`${this.count}`) || `${this.count}` in definitions; ) this.count++;
|
|
101
|
+
return `${this.count++}`;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function getLowerBound(current, value) {
|
|
105
|
+
return typeof current != "number" || !Number.isFinite(current) || value > current ? value : current;
|
|
106
|
+
}
|
|
107
|
+
function getUpperBound(current, value) {
|
|
108
|
+
return typeof current != "number" || !Number.isFinite(current) || value < current ? value : current;
|
|
109
|
+
}
|
|
110
|
+
function getNotRestriction(current, value) {
|
|
111
|
+
return current !== void 0 ? { anyOf: [current, value] } : value;
|
|
112
|
+
}
|
|
113
|
+
function intersectEnum(jsonSchema, values) {
|
|
114
|
+
let enumValues = jsonSchema.enum ?? values;
|
|
115
|
+
if (jsonSchema.enum) {
|
|
116
|
+
let valueSet = new Set(values);
|
|
117
|
+
enumValues = enumValues.filter((value) => valueSet.has(value));
|
|
118
|
+
}
|
|
119
|
+
enumValues.length ? jsonSchema.enum = [...new Set(enumValues)] : (delete jsonSchema.enum, jsonSchema.not = getNotRestriction(jsonSchema.not, {}));
|
|
120
|
+
}
|
|
121
|
+
function convertAction(jsonSchema, valibotAction, config) {
|
|
122
|
+
if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
|
|
123
|
+
let errors;
|
|
124
|
+
switch (valibotAction.type) {
|
|
125
|
+
case "base64":
|
|
126
|
+
jsonSchema.contentEncoding = "base64";
|
|
127
|
+
break;
|
|
128
|
+
case "bic":
|
|
129
|
+
case "cuid2":
|
|
130
|
+
case "decimal":
|
|
131
|
+
case "digits":
|
|
132
|
+
case "domain":
|
|
133
|
+
case "emoji":
|
|
134
|
+
case "hash":
|
|
135
|
+
case "hexadecimal":
|
|
136
|
+
case "hex_color":
|
|
137
|
+
case "isrc":
|
|
138
|
+
case "iso_time_second":
|
|
139
|
+
case "iso_week":
|
|
140
|
+
case "ksuid":
|
|
141
|
+
case "mac":
|
|
142
|
+
case "mac48":
|
|
143
|
+
case "mac64":
|
|
144
|
+
case "nanoid":
|
|
145
|
+
case "octal":
|
|
146
|
+
case "slug":
|
|
147
|
+
case "ulid":
|
|
148
|
+
jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = valibotAction.requirement.source;
|
|
149
|
+
break;
|
|
150
|
+
case "description":
|
|
151
|
+
jsonSchema.description = valibotAction.description;
|
|
152
|
+
break;
|
|
153
|
+
case "email":
|
|
154
|
+
case "rfc_email":
|
|
155
|
+
jsonSchema.format = "email";
|
|
156
|
+
break;
|
|
157
|
+
case "ends_with":
|
|
158
|
+
jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
|
|
159
|
+
break;
|
|
160
|
+
case "empty":
|
|
161
|
+
jsonSchema.type === "array" ? jsonSchema.maxItems = 0 : (jsonSchema.type !== "string" && (errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`)), jsonSchema.maxLength = 0);
|
|
162
|
+
break;
|
|
163
|
+
case "entries":
|
|
164
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
165
|
+
errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement), jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
|
|
169
|
+
break;
|
|
170
|
+
case "examples":
|
|
171
|
+
Array.isArray(jsonSchema.examples) ? jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples] : jsonSchema.examples = valibotAction.examples;
|
|
172
|
+
break;
|
|
173
|
+
case "gt_value":
|
|
174
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
|
|
175
|
+
errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (!Number.isFinite(valibotAction.requirement)) {
|
|
179
|
+
errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (config?.target === "openapi-3.0") {
|
|
183
|
+
errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
|
|
187
|
+
break;
|
|
188
|
+
case "includes":
|
|
189
|
+
jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
|
|
190
|
+
break;
|
|
191
|
+
case "integer":
|
|
192
|
+
jsonSchema.type = "integer";
|
|
193
|
+
break;
|
|
194
|
+
case "ipv4":
|
|
195
|
+
jsonSchema.format = "ipv4";
|
|
196
|
+
break;
|
|
197
|
+
case "ipv6":
|
|
198
|
+
jsonSchema.format = "ipv6";
|
|
199
|
+
break;
|
|
200
|
+
case "iso_date":
|
|
201
|
+
jsonSchema.format = "date";
|
|
202
|
+
break;
|
|
203
|
+
case "iso_date_time":
|
|
204
|
+
case "iso_timestamp":
|
|
205
|
+
jsonSchema.format = "date-time";
|
|
206
|
+
break;
|
|
207
|
+
case "iso_time":
|
|
208
|
+
jsonSchema.format = "time";
|
|
209
|
+
break;
|
|
210
|
+
case "jws_compact":
|
|
211
|
+
jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = valibotAction.requirement.source;
|
|
212
|
+
break;
|
|
213
|
+
case "length":
|
|
214
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
215
|
+
errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
jsonSchema.type === "array" ? (jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement), jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement)) : (jsonSchema.type !== "string" && (errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`)), jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement), jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement));
|
|
219
|
+
break;
|
|
220
|
+
case "lt_value":
|
|
221
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
|
|
222
|
+
errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (!Number.isFinite(valibotAction.requirement)) {
|
|
226
|
+
errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (config?.target === "openapi-3.0") {
|
|
230
|
+
errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
|
|
234
|
+
break;
|
|
235
|
+
case "max_entries":
|
|
236
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
237
|
+
errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
|
|
241
|
+
break;
|
|
242
|
+
case "max_length":
|
|
243
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
244
|
+
errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
jsonSchema.type === "array" ? jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement) : (jsonSchema.type !== "string" && (errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`)), jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement));
|
|
248
|
+
break;
|
|
249
|
+
case "max_value":
|
|
250
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
|
|
251
|
+
errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
if (!Number.isFinite(valibotAction.requirement)) {
|
|
255
|
+
errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
|
|
259
|
+
break;
|
|
260
|
+
case "metadata":
|
|
261
|
+
typeof valibotAction.metadata.title == "string" && (jsonSchema.title = valibotAction.metadata.title), typeof valibotAction.metadata.description == "string" && (jsonSchema.description = valibotAction.metadata.description), Array.isArray(valibotAction.metadata.examples) && (Array.isArray(jsonSchema.examples) ? jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples] : jsonSchema.examples = valibotAction.metadata.examples);
|
|
262
|
+
for (let key of Object.keys(valibotAction.metadata)) key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__" && (jsonSchema[key] = valibotAction.metadata[key]);
|
|
263
|
+
break;
|
|
264
|
+
case "min_entries":
|
|
265
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
266
|
+
errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
|
|
270
|
+
break;
|
|
271
|
+
case "min_length":
|
|
272
|
+
if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
|
|
273
|
+
errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
jsonSchema.type === "array" ? jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement) : (jsonSchema.type !== "string" && (errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`)), jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement));
|
|
277
|
+
break;
|
|
278
|
+
case "min_value":
|
|
279
|
+
if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
|
|
280
|
+
errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
if (!Number.isFinite(valibotAction.requirement)) {
|
|
284
|
+
errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
|
|
288
|
+
break;
|
|
289
|
+
case "multiple_of":
|
|
290
|
+
jsonSchema.multipleOf = valibotAction.requirement;
|
|
291
|
+
break;
|
|
292
|
+
case "non_empty":
|
|
293
|
+
jsonSchema.type === "array" ? jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1) : (jsonSchema.type !== "string" && (errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`)), jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1));
|
|
294
|
+
break;
|
|
295
|
+
case "not_value":
|
|
296
|
+
if (!isJsonConstValue(valibotAction.requirement)) {
|
|
297
|
+
errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
jsonSchema.not = getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
|
|
301
|
+
break;
|
|
302
|
+
case "not_values":
|
|
303
|
+
if (!isJsonEnumValues(valibotAction.requirement)) {
|
|
304
|
+
errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
valibotAction.requirement.length && (jsonSchema.not = getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] }));
|
|
308
|
+
break;
|
|
309
|
+
case "regex":
|
|
310
|
+
valibotAction.requirement.flags && (errors = addError(errors, "RegExp flags are not supported by JSON Schema.")), jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = valibotAction.requirement.source;
|
|
311
|
+
break;
|
|
312
|
+
case "safe_integer":
|
|
313
|
+
jsonSchema.type = "integer", jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER), jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
|
|
314
|
+
break;
|
|
315
|
+
case "starts_with":
|
|
316
|
+
jsonSchema.pattern ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`) : jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
|
|
317
|
+
break;
|
|
318
|
+
case "title":
|
|
319
|
+
jsonSchema.title = valibotAction.title;
|
|
320
|
+
break;
|
|
321
|
+
case "url":
|
|
322
|
+
jsonSchema.format = "uri";
|
|
323
|
+
break;
|
|
324
|
+
case "uuid":
|
|
325
|
+
jsonSchema.format = "uuid";
|
|
326
|
+
break;
|
|
327
|
+
case "value":
|
|
328
|
+
if (!isJsonConstValue(valibotAction.requirement)) {
|
|
329
|
+
errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
config?.target === "openapi-3.0" ? intersectEnum(jsonSchema, [valibotAction.requirement]) : "const" in jsonSchema && jsonSchema.const !== valibotAction.requirement ? errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`) : jsonSchema.const = valibotAction.requirement;
|
|
333
|
+
break;
|
|
334
|
+
case "values":
|
|
335
|
+
if (!isJsonEnumValues(valibotAction.requirement)) {
|
|
336
|
+
errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
intersectEnum(jsonSchema, valibotAction.requirement);
|
|
340
|
+
break;
|
|
341
|
+
default:
|
|
342
|
+
errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
|
|
343
|
+
}
|
|
344
|
+
if (config?.overrideAction) {
|
|
345
|
+
let actionOverride = config.overrideAction({
|
|
346
|
+
valibotAction,
|
|
347
|
+
jsonSchema,
|
|
348
|
+
errors
|
|
349
|
+
});
|
|
350
|
+
if (actionOverride) return { ...actionOverride };
|
|
351
|
+
}
|
|
352
|
+
if (errors) for (let message of errors) handleError(message, config);
|
|
353
|
+
return jsonSchema;
|
|
354
|
+
}
|
|
355
|
+
function flattenPipe(pipe) {
|
|
356
|
+
return pipe.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
|
|
357
|
+
}
|
|
358
|
+
function getDefinitionRef(referenceId) {
|
|
359
|
+
return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
|
|
360
|
+
}
|
|
361
|
+
function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = !1) {
|
|
362
|
+
if (!skipRef) {
|
|
363
|
+
let referenceId = context.referenceMap.get(valibotSchema);
|
|
364
|
+
if (referenceId) {
|
|
365
|
+
if (jsonSchema.$ref = getDefinitionRef(referenceId), config?.overrideRef) {
|
|
366
|
+
let refOverride = config.overrideRef({
|
|
367
|
+
...context,
|
|
368
|
+
referenceId,
|
|
369
|
+
valibotSchema,
|
|
370
|
+
jsonSchema
|
|
371
|
+
});
|
|
372
|
+
refOverride && (jsonSchema.$ref = refOverride);
|
|
373
|
+
}
|
|
374
|
+
return jsonSchema;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if ("pipe" in valibotSchema) {
|
|
378
|
+
let flatPipe = flattenPipe(valibotSchema.pipe), startIndex = 0, stopIndex = flatPipe.length - 1;
|
|
379
|
+
if (config?.typeMode === "input") {
|
|
380
|
+
let inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
|
|
381
|
+
inputStopIndex !== -1 && (stopIndex = inputStopIndex);
|
|
382
|
+
} else if (config?.typeMode === "output") {
|
|
383
|
+
let outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
|
|
384
|
+
outputStartIndex !== -1 && (startIndex = outputStartIndex);
|
|
385
|
+
}
|
|
386
|
+
for (let index = startIndex; index <= stopIndex; index++) {
|
|
387
|
+
let valibotPipeItem = flatPipe[index];
|
|
388
|
+
valibotPipeItem.kind === "schema" ? (index > startIndex && handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config), jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, !0)) : jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
|
|
389
|
+
}
|
|
390
|
+
return jsonSchema;
|
|
391
|
+
}
|
|
392
|
+
let errors;
|
|
393
|
+
switch (valibotSchema.type) {
|
|
394
|
+
case "boolean":
|
|
395
|
+
jsonSchema.type = "boolean";
|
|
396
|
+
break;
|
|
397
|
+
case "null":
|
|
398
|
+
config?.target === "openapi-3.0" ? jsonSchema.enum = [null] : jsonSchema.type = "null";
|
|
399
|
+
break;
|
|
400
|
+
case "number":
|
|
401
|
+
jsonSchema.type = "number";
|
|
402
|
+
break;
|
|
403
|
+
case "string":
|
|
404
|
+
jsonSchema.type = "string";
|
|
405
|
+
break;
|
|
406
|
+
case "array":
|
|
407
|
+
jsonSchema.type = "array", jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
|
|
408
|
+
break;
|
|
409
|
+
case "tuple":
|
|
410
|
+
case "tuple_with_rest":
|
|
411
|
+
case "loose_tuple":
|
|
412
|
+
case "strict_tuple":
|
|
413
|
+
if (jsonSchema.type = "array", config?.target === "openapi-3.0") {
|
|
414
|
+
jsonSchema.items = { anyOf: [] }, jsonSchema.minItems = valibotSchema.items.length;
|
|
415
|
+
for (let item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
|
|
416
|
+
valibotSchema.type === "tuple_with_rest" ? jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context)) : (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") && (jsonSchema.maxItems = valibotSchema.items.length);
|
|
417
|
+
} else if (config?.target === "draft-2020-12") {
|
|
418
|
+
jsonSchema.prefixItems = [], jsonSchema.minItems = valibotSchema.items.length;
|
|
419
|
+
for (let item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
|
|
420
|
+
valibotSchema.type === "tuple_with_rest" ? jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context) : valibotSchema.type === "strict_tuple" && (jsonSchema.items = !1);
|
|
421
|
+
} else {
|
|
422
|
+
jsonSchema.items = [], jsonSchema.minItems = valibotSchema.items.length;
|
|
423
|
+
for (let item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
|
|
424
|
+
valibotSchema.type === "tuple_with_rest" ? jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context) : valibotSchema.type === "strict_tuple" && (jsonSchema.additionalItems = !1);
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
case "object":
|
|
428
|
+
case "object_with_rest":
|
|
429
|
+
case "loose_object":
|
|
430
|
+
case "strict_object":
|
|
431
|
+
jsonSchema.type = "object", jsonSchema.properties = {}, jsonSchema.required = [];
|
|
432
|
+
for (let key in valibotSchema.entries) {
|
|
433
|
+
let entry = valibotSchema.entries[key];
|
|
434
|
+
jsonSchema.properties[key] = convertSchema({}, entry, config, context), entry.type !== "exact_optional" && entry.type !== "nullish" && entry.type !== "optional" && jsonSchema.required.push(key);
|
|
435
|
+
}
|
|
436
|
+
valibotSchema.type === "object_with_rest" ? jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context) : valibotSchema.type === "strict_object" && (jsonSchema.additionalProperties = !1);
|
|
437
|
+
break;
|
|
438
|
+
case "record":
|
|
439
|
+
config?.target === "openapi-3.0" && "pipe" in valibotSchema.key && (errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.')), valibotSchema.key.type !== "string" && (errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`)), jsonSchema.type = "object", config?.target !== "openapi-3.0" && (jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context)), jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
|
|
440
|
+
break;
|
|
441
|
+
case "any":
|
|
442
|
+
case "unknown":
|
|
443
|
+
break;
|
|
444
|
+
case "never":
|
|
445
|
+
jsonSchema.not = {};
|
|
446
|
+
break;
|
|
447
|
+
case "nullable":
|
|
448
|
+
case "nullish":
|
|
449
|
+
if (config?.target === "openapi-3.0") {
|
|
450
|
+
let innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
|
|
451
|
+
Object.assign(jsonSchema, innerSchema), jsonSchema.nullable = !0;
|
|
452
|
+
} else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
|
|
453
|
+
valibotSchema.default !== void 0 && (jsonSchema.default = typeof valibotSchema.default == "function" ? valibotSchema.default() : valibotSchema.default);
|
|
454
|
+
break;
|
|
455
|
+
case "exact_optional":
|
|
456
|
+
case "optional":
|
|
457
|
+
case "undefinedable":
|
|
458
|
+
jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context), valibotSchema.default !== void 0 && (jsonSchema.default = typeof valibotSchema.default == "function" ? valibotSchema.default() : valibotSchema.default);
|
|
459
|
+
break;
|
|
460
|
+
case "literal":
|
|
461
|
+
if (!isJsonConstValue(valibotSchema.literal)) {
|
|
462
|
+
errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
config?.target === "openapi-3.0" ? jsonSchema.enum = [valibotSchema.literal] : jsonSchema.const = valibotSchema.literal;
|
|
466
|
+
break;
|
|
467
|
+
case "enum":
|
|
468
|
+
case "picklist": {
|
|
469
|
+
let options = valibotSchema.options;
|
|
470
|
+
if (!options.every((option) => typeof option == "string" || typeof option == "number" && Number.isFinite(option))) {
|
|
471
|
+
errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
jsonSchema.enum = options, options.every((option) => typeof option == "string") ? jsonSchema.type = "string" : options.every((option) => typeof option == "number") ? jsonSchema.type = "number" : config?.target !== "openapi-3.0" && (jsonSchema.type = ["string", "number"]);
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
case "union":
|
|
478
|
+
jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
479
|
+
break;
|
|
480
|
+
case "variant":
|
|
481
|
+
jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
482
|
+
break;
|
|
483
|
+
case "intersect":
|
|
484
|
+
jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
485
|
+
break;
|
|
486
|
+
case "lazy": {
|
|
487
|
+
let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
|
|
488
|
+
wrappedValibotSchema || (wrappedValibotSchema = valibotSchema.getter(void 0), context.getterMap.set(valibotSchema.getter, wrappedValibotSchema));
|
|
489
|
+
let referenceId = context.referenceMap.get(wrappedValibotSchema);
|
|
490
|
+
if (referenceId || (referenceId = context.referenceMap.createId(context.definitions), context.referenceMap.set(wrappedValibotSchema, referenceId), context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, !0)), jsonSchema.$ref = getDefinitionRef(referenceId), config?.overrideRef) {
|
|
491
|
+
let refOverride = config.overrideRef({
|
|
492
|
+
...context,
|
|
493
|
+
referenceId,
|
|
494
|
+
valibotSchema: wrappedValibotSchema,
|
|
495
|
+
jsonSchema
|
|
496
|
+
});
|
|
497
|
+
refOverride && (jsonSchema.$ref = refOverride);
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
default:
|
|
502
|
+
errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
|
|
503
|
+
}
|
|
504
|
+
if (config?.overrideSchema) {
|
|
505
|
+
let schemaOverride = config.overrideSchema({
|
|
506
|
+
...context,
|
|
507
|
+
referenceId: context.referenceMap.get(valibotSchema),
|
|
508
|
+
valibotSchema,
|
|
509
|
+
jsonSchema,
|
|
510
|
+
errors
|
|
511
|
+
});
|
|
512
|
+
if (schemaOverride) return { ...schemaOverride };
|
|
513
|
+
}
|
|
514
|
+
if (errors) for (let message of errors) handleError(message, config);
|
|
515
|
+
return jsonSchema;
|
|
516
|
+
}
|
|
517
|
+
var store;
|
|
518
|
+
function getGlobalDefs() {
|
|
519
|
+
return store;
|
|
520
|
+
}
|
|
521
|
+
function toJsonSchema(schema, config) {
|
|
522
|
+
let context = {
|
|
523
|
+
definitions: {},
|
|
524
|
+
referenceMap: new ReferenceMap(),
|
|
525
|
+
getterMap: /* @__PURE__ */ new Map()
|
|
526
|
+
}, definitions = config?.definitions ?? getGlobalDefs();
|
|
527
|
+
if (definitions) {
|
|
528
|
+
for (let key in definitions) context.referenceMap.set(definitions[key], key);
|
|
529
|
+
for (let key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, !0);
|
|
530
|
+
}
|
|
531
|
+
let jsonSchema = convertSchema({}, schema, config, context), target = config?.target ?? "draft-07";
|
|
532
|
+
return target === "draft-2020-12" ? jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema" : target === "draft-07" && (jsonSchema.$schema = "http://json-schema.org/draft-07/schema#"), context.referenceMap.size && (jsonSchema.$defs = context.definitions), jsonSchema;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// src/cli/tools/sdk/json-schema.ts
|
|
536
|
+
function toToolsetJsonSchema(schema) {
|
|
537
|
+
if (schema["~standard"].vendor === "valibot")
|
|
538
|
+
try {
|
|
539
|
+
return toJsonSchema(schema, { errorMode: "ignore" });
|
|
540
|
+
} catch {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/cli/tools/sdk/catalog.ts
|
|
546
|
+
function toCatalogEntry(toolset, ctx) {
|
|
547
|
+
return {
|
|
548
|
+
id: toolset.id,
|
|
549
|
+
description: toolset.description,
|
|
550
|
+
methods: Object.entries(toolset.methods).map(([methodName, method]) => ({
|
|
551
|
+
ref: `${toolset.id}.${methodName}`,
|
|
552
|
+
title: method.title,
|
|
553
|
+
description: resolveToolsetDescription(method.description, ctx).trim(),
|
|
554
|
+
requiresDevServer: method.requiresDevServer === !0,
|
|
555
|
+
input: toToolsetJsonSchema(method.input),
|
|
556
|
+
...method.output ? { output: toToolsetJsonSchema(method.output) } : {}
|
|
557
|
+
}))
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// src/cli/tools/sdk/child-client.ts
|
|
562
|
+
import { fork } from "node:child_process";
|
|
563
|
+
import { logger } from "@aussieljk/forkbook/internal/node-logger";
|
|
564
|
+
|
|
565
|
+
// src/cli/tools/sdk/command-telemetry.ts
|
|
566
|
+
import { telemetry } from "@aussieljk/forkbook/internal/telemetry";
|
|
567
|
+
function sanitizeNamePart(part) {
|
|
568
|
+
return /^[\w-]{1,64}$/.test(part) ? part : "(invalid)";
|
|
569
|
+
}
|
|
570
|
+
function toolsCommandDimensions(args) {
|
|
571
|
+
return {
|
|
572
|
+
client: args.clientInfo.kind,
|
|
573
|
+
requestedMode: args.requestedMode,
|
|
574
|
+
attachMode: args.resolvedMode ?? args.requestedMode,
|
|
575
|
+
...args.resolvedMode ? { resolvedMode: args.resolvedMode } : {},
|
|
576
|
+
...args.host ? { host: args.host } : {},
|
|
577
|
+
...args.fallbackReason ? { attachGate: args.fallbackReason } : {}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function commandPartsFromRef(ref) {
|
|
581
|
+
try {
|
|
582
|
+
let { toolsetId, methodName } = parseToolsetMethodId(ref);
|
|
583
|
+
return {
|
|
584
|
+
toolset: sanitizeNamePart(toolsetId),
|
|
585
|
+
tool: sanitizeNamePart(toCliMethodName(methodName))
|
|
586
|
+
};
|
|
587
|
+
} catch {
|
|
588
|
+
return { toolset: "(invalid)", tool: "(invalid)" };
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
async function reportToolsCommandEvent(record, options = {}) {
|
|
592
|
+
let { report, configDir } = options, payload = report ? {
|
|
593
|
+
...report.payload,
|
|
594
|
+
...record,
|
|
595
|
+
event: report.event,
|
|
596
|
+
toolset: report.toolset,
|
|
597
|
+
tool: report.tool
|
|
598
|
+
} : record;
|
|
599
|
+
try {
|
|
600
|
+
await telemetry("tools-command", payload, { configDir });
|
|
601
|
+
} catch {
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
function shouldReportSdkInvocation(kind) {
|
|
605
|
+
return kind === "sdk" && process.env.FORKBOOK_TOOLS_CHILD_HOST !== "true";
|
|
606
|
+
}
|
|
607
|
+
async function reportSdkAttachGate(args) {
|
|
608
|
+
if (!shouldReportSdkInvocation(args.clientInfo.kind))
|
|
609
|
+
return;
|
|
610
|
+
let attachGate = attachGateReasonFromError(args.error);
|
|
611
|
+
await reportToolsCommandEvent(
|
|
612
|
+
{
|
|
613
|
+
success: !1,
|
|
614
|
+
outcome: "attach-gate",
|
|
615
|
+
...toolsCommandDimensions({
|
|
616
|
+
clientInfo: args.clientInfo,
|
|
617
|
+
requestedMode: args.requestedMode,
|
|
618
|
+
fallbackReason: attachGate
|
|
619
|
+
})
|
|
620
|
+
},
|
|
621
|
+
{ configDir: args.configDir }
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
async function reportSdkInvocation(args) {
|
|
625
|
+
if (!shouldReportSdkInvocation(args.clientInfo.kind))
|
|
626
|
+
return;
|
|
627
|
+
let dimensions = toolsCommandDimensions(args), invoked = commandPartsFromRef(args.ref), options = { report: args.report, configDir: args.configDir };
|
|
628
|
+
if (!("ok" in args.result)) {
|
|
629
|
+
let attachGate = attachGateReasonFromError(args.result.error);
|
|
630
|
+
await reportToolsCommandEvent(
|
|
631
|
+
{
|
|
632
|
+
...invoked,
|
|
633
|
+
success: !1,
|
|
634
|
+
outcome: attachGate ? "attach-gate" : "error",
|
|
635
|
+
duration: args.duration,
|
|
636
|
+
...dimensions,
|
|
637
|
+
...attachGate ? { attachGate } : {}
|
|
638
|
+
},
|
|
639
|
+
options
|
|
640
|
+
);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
let success = args.result.ok;
|
|
644
|
+
await reportToolsCommandEvent(
|
|
645
|
+
{
|
|
646
|
+
...invoked,
|
|
647
|
+
success,
|
|
648
|
+
outcome: success ? "success" : "failure",
|
|
649
|
+
duration: args.duration,
|
|
650
|
+
...dimensions
|
|
651
|
+
},
|
|
652
|
+
options
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// src/cli/tools/sdk/resolve-project-storybook.ts
|
|
657
|
+
import { createRequire } from "node:module";
|
|
658
|
+
import { join } from "node:path";
|
|
659
|
+
var CHILD_HOST_ENTRY = "@aussieljk/forkbook/internal/tools/child-host";
|
|
660
|
+
function resolveChildHostScript(resolutionRoot) {
|
|
661
|
+
return createRequire(join(resolutionRoot, "package.json")).resolve(CHILD_HOST_ENTRY, { paths: [resolutionRoot] });
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/cli/tools/sdk/child-client.ts
|
|
665
|
+
async function spawnChildHost(args, deps = {}) {
|
|
666
|
+
let log = deps.logger ?? logger, forkChild = deps.fork ?? fork, cwd = args.cwd, resolvedMode = args.options.mode === "local" ? "local" : "attached", resolutionRoot = args.installationPath ?? cwd, scriptPath;
|
|
667
|
+
try {
|
|
668
|
+
scriptPath = (deps.resolveScript ?? resolveChildHostScript)(resolutionRoot);
|
|
669
|
+
} catch (cause) {
|
|
670
|
+
throw new SpawnFailedError({
|
|
671
|
+
reason: args.installationPath ? `The running Forkbook's installation at ${resolutionRoot} can no longer resolve \`@aussieljk/forkbook/internal/tools/child-host\`. From your project directory, restart Forkbook (for example \`npx forkbook dev\`) and re-run this command from there.` : `Could not resolve \`@aussieljk/forkbook/internal/tools/child-host\` from ${resolutionRoot}. Install Forkbook in that project, then retry.`,
|
|
672
|
+
cause
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
let env = {
|
|
676
|
+
...process.env,
|
|
677
|
+
FORKBOOK_TOOLS_CHILD_HOST: "true"
|
|
678
|
+
};
|
|
679
|
+
resolvedMode === "attached" ? env.FORKBOOK_ATTACHED_TOOLS = "true" : delete env.FORKBOOK_ATTACHED_TOOLS;
|
|
680
|
+
let child;
|
|
681
|
+
try {
|
|
682
|
+
child = forkChild(scriptPath, [], {
|
|
683
|
+
cwd,
|
|
684
|
+
stdio: ["ignore", "pipe", "pipe", "ipc"],
|
|
685
|
+
env
|
|
686
|
+
});
|
|
687
|
+
} catch (cause) {
|
|
688
|
+
throw new SpawnFailedError({
|
|
689
|
+
reason: `Could not start a tools child host for ${cwd}.`,
|
|
690
|
+
cause
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
child.stdout?.on("data", (chunk) => {
|
|
694
|
+
log.log(String(chunk));
|
|
695
|
+
}), child.stderr?.on("data", (chunk) => {
|
|
696
|
+
log.warn(String(chunk));
|
|
697
|
+
});
|
|
698
|
+
let pending = /* @__PURE__ */ new Map(), closed = !1, nextId = 0, failPending = (error) => {
|
|
699
|
+
for (let [, waiter] of pending)
|
|
700
|
+
waiter.reject(error);
|
|
701
|
+
pending.clear();
|
|
702
|
+
}, disconnected = new Promise((_, reject) => {
|
|
703
|
+
child.once("exit", (code, signal) => {
|
|
704
|
+
if (closed)
|
|
705
|
+
return;
|
|
706
|
+
let error = new ToolsRuntimeError({
|
|
707
|
+
reason: "connection-lost",
|
|
708
|
+
message: `The tools child host for ${cwd} exited${signal ? ` (${signal})` : code != null ? ` (code ${code})` : ""}.`
|
|
709
|
+
});
|
|
710
|
+
failPending(error), reject(error);
|
|
711
|
+
}), child.once("error", (cause) => {
|
|
712
|
+
if (closed)
|
|
713
|
+
return;
|
|
714
|
+
let error = new SpawnFailedError({
|
|
715
|
+
reason: `The tools child host for ${cwd} failed.`,
|
|
716
|
+
cause
|
|
717
|
+
});
|
|
718
|
+
failPending(error), reject(error);
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
disconnected.catch(() => {
|
|
722
|
+
}), child.on("message", (raw) => {
|
|
723
|
+
if (!isChildMessage(raw) || raw.type !== "result" && raw.type !== "error")
|
|
724
|
+
return;
|
|
725
|
+
let waiter = pending.get(raw.id);
|
|
726
|
+
if (waiter) {
|
|
727
|
+
if (pending.delete(raw.id), raw.type === "result") {
|
|
728
|
+
waiter.resolve(raw.value);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
waiter.reject(rehydrateSerializedToolsError(raw.error));
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
let send = (message) => {
|
|
735
|
+
if (!child.send)
|
|
736
|
+
throw new SpawnFailedError({
|
|
737
|
+
reason: `The tools child host for ${cwd} has no IPC channel.`
|
|
738
|
+
});
|
|
739
|
+
child.send(message);
|
|
740
|
+
}, request = (message) => closed ? Promise.reject(
|
|
741
|
+
new ToolsRuntimeError({
|
|
742
|
+
reason: "closed",
|
|
743
|
+
message: "This tools host is closed. Create a new one with `createTools`."
|
|
744
|
+
})
|
|
745
|
+
) : Promise.race([
|
|
746
|
+
new Promise((resolve2, reject) => {
|
|
747
|
+
pending.set(message.id, { resolve: resolve2, reject }), send(message);
|
|
748
|
+
}),
|
|
749
|
+
disconnected
|
|
750
|
+
]), hello;
|
|
751
|
+
try {
|
|
752
|
+
hello = await waitForHello(child, send, {
|
|
753
|
+
cwd,
|
|
754
|
+
options: args.options,
|
|
755
|
+
clientInfo: args.clientInfo,
|
|
756
|
+
resolvedMode
|
|
757
|
+
});
|
|
758
|
+
} catch (error) {
|
|
759
|
+
throw closed = !0, child.kill(), error;
|
|
760
|
+
}
|
|
761
|
+
if (hello.version !== 1)
|
|
762
|
+
throw closed = !0, child.kill(), new SpawnFailedError({
|
|
763
|
+
reason: `The tools child host at ${cwd} speaks protocol ${hello.version}, but this process expects ${1}. Restart your Forkbook so both sides match.`
|
|
764
|
+
});
|
|
765
|
+
let runtime = {
|
|
766
|
+
configDir: hello.storybook.configDir,
|
|
767
|
+
toolsets: [],
|
|
768
|
+
getService: () => {
|
|
769
|
+
throw new ToolsRuntimeError({
|
|
770
|
+
reason: "command-unhandled",
|
|
771
|
+
message: "Toolset services are served by the project-local child host."
|
|
772
|
+
});
|
|
773
|
+
},
|
|
774
|
+
close: async () => {
|
|
775
|
+
}
|
|
776
|
+
}, assertOpen = () => {
|
|
777
|
+
if (closed)
|
|
778
|
+
throw new ToolsRuntimeError({
|
|
779
|
+
reason: "closed",
|
|
780
|
+
message: "This tools host is closed. Create a new one with `createTools`."
|
|
781
|
+
});
|
|
782
|
+
};
|
|
783
|
+
return {
|
|
784
|
+
mode: resolvedMode,
|
|
785
|
+
host: "child",
|
|
786
|
+
requestedMode: args.requestedMode,
|
|
787
|
+
clientInfo: hello.clientInfo,
|
|
788
|
+
storybook: hello.storybook,
|
|
789
|
+
runtime,
|
|
790
|
+
async describe(options = {}) {
|
|
791
|
+
return assertOpen(), await request({ type: "describe", id: String(++nextId), options });
|
|
792
|
+
},
|
|
793
|
+
async call(ref, input = {}, options = {}) {
|
|
794
|
+
assertOpen(), options.signal?.throwIfAborted();
|
|
795
|
+
let id = String(++nextId), onAbort, aborted = options.signal ? new Promise((_, reject) => {
|
|
796
|
+
onAbort = () => {
|
|
797
|
+
try {
|
|
798
|
+
send({ type: "cancel", id });
|
|
799
|
+
} catch {
|
|
800
|
+
}
|
|
801
|
+
reject(options.signal.reason);
|
|
802
|
+
}, options.signal.addEventListener("abort", onAbort, { once: !0 });
|
|
803
|
+
}) : void 0, start = Date.now();
|
|
804
|
+
try {
|
|
805
|
+
let work = request({ type: "call", id, ref, input }), outcome = await (aborted ? Promise.race([work, aborted]) : work);
|
|
806
|
+
return await reportSdkInvocation({
|
|
807
|
+
ref,
|
|
808
|
+
clientInfo: args.clientInfo,
|
|
809
|
+
requestedMode: args.requestedMode,
|
|
810
|
+
resolvedMode,
|
|
811
|
+
host: "child",
|
|
812
|
+
result: outcome,
|
|
813
|
+
report: outcome.telemetry,
|
|
814
|
+
duration: Date.now() - start,
|
|
815
|
+
configDir: hello.storybook.configDir
|
|
816
|
+
}), outcome;
|
|
817
|
+
} catch (error) {
|
|
818
|
+
throw await reportSdkInvocation({
|
|
819
|
+
ref,
|
|
820
|
+
clientInfo: args.clientInfo,
|
|
821
|
+
requestedMode: args.requestedMode,
|
|
822
|
+
resolvedMode,
|
|
823
|
+
host: "child",
|
|
824
|
+
result: { error },
|
|
825
|
+
duration: Date.now() - start,
|
|
826
|
+
configDir: hello.storybook.configDir
|
|
827
|
+
}), error;
|
|
828
|
+
} finally {
|
|
829
|
+
onAbort && options.signal?.removeEventListener("abort", onAbort);
|
|
830
|
+
}
|
|
831
|
+
},
|
|
832
|
+
async close() {
|
|
833
|
+
if (!closed) {
|
|
834
|
+
closed = !0, failPending(
|
|
835
|
+
new ToolsRuntimeError({
|
|
836
|
+
reason: "closed",
|
|
837
|
+
message: "This tools host is closed. Create a new one with `createTools`."
|
|
838
|
+
})
|
|
839
|
+
);
|
|
840
|
+
try {
|
|
841
|
+
send({ type: "close" });
|
|
842
|
+
} catch {
|
|
843
|
+
}
|
|
844
|
+
child.kill();
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
var HELLO_TIMEOUT_MS = 1e4;
|
|
850
|
+
async function waitForHello(child, send, args) {
|
|
851
|
+
let { cwd, options, clientInfo, resolvedMode } = args;
|
|
852
|
+
return new Promise((resolve2, reject) => {
|
|
853
|
+
let onMessage = (raw) => {
|
|
854
|
+
if (isChildMessage(raw) && raw.type === "hello") {
|
|
855
|
+
cleanup(), resolve2(raw);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
isChildMessage(raw) && raw.type === "error" && raw.id === "init" && (cleanup(), reject(rehydrateSerializedToolsError(raw.error)));
|
|
859
|
+
}, onExit = (code, signal) => {
|
|
860
|
+
cleanup(), reject(
|
|
861
|
+
new SpawnFailedError({
|
|
862
|
+
reason: `The tools child host for ${cwd} exited before it was ready${signal ? ` (${signal})` : code != null ? ` (code ${code})` : ""}.`
|
|
863
|
+
})
|
|
864
|
+
);
|
|
865
|
+
}, onError = (cause) => {
|
|
866
|
+
cleanup(), reject(
|
|
867
|
+
new SpawnFailedError({
|
|
868
|
+
reason: `The tools child host for ${cwd} failed to start.`,
|
|
869
|
+
cause
|
|
870
|
+
})
|
|
871
|
+
);
|
|
872
|
+
}, cleanup = () => {
|
|
873
|
+
clearTimeout(timer), child.off("message", onMessage), child.off("exit", onExit), child.off("error", onError);
|
|
874
|
+
}, timer = setTimeout(() => {
|
|
875
|
+
cleanup(), reject(
|
|
876
|
+
new SpawnFailedError({
|
|
877
|
+
reason: `The tools child host for ${cwd} did not become ready in time.`
|
|
878
|
+
})
|
|
879
|
+
);
|
|
880
|
+
}, HELLO_TIMEOUT_MS);
|
|
881
|
+
child.on("message", onMessage), child.once("exit", onExit), child.once("error", onError);
|
|
882
|
+
try {
|
|
883
|
+
send({
|
|
884
|
+
type: "init",
|
|
885
|
+
options: {
|
|
886
|
+
...options,
|
|
887
|
+
cwd,
|
|
888
|
+
mode: resolvedMode,
|
|
889
|
+
autoSpawn: !1,
|
|
890
|
+
clientInfo
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
} catch (cause) {
|
|
894
|
+
cleanup(), reject(
|
|
895
|
+
new SpawnFailedError({
|
|
896
|
+
reason: `Could not initialize a tools child host for ${cwd}.`,
|
|
897
|
+
cause
|
|
898
|
+
})
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
function rehydrateSerializedToolsError(serialized) {
|
|
904
|
+
let plain = deserializeError(serialized), data = plain.data;
|
|
905
|
+
if (data == null || typeof data != "object")
|
|
906
|
+
return plain;
|
|
907
|
+
switch (toolsErrorKind(serialized)) {
|
|
908
|
+
case "AttachUnavailableError":
|
|
909
|
+
return new AttachUnavailableError(data);
|
|
910
|
+
case "EnvironmentMismatchError":
|
|
911
|
+
return new EnvironmentMismatchError(data);
|
|
912
|
+
case "SpawnFailedError":
|
|
913
|
+
return new SpawnFailedError(data);
|
|
914
|
+
case "ToolsRuntimeError":
|
|
915
|
+
return new ToolsRuntimeError(data);
|
|
916
|
+
default:
|
|
917
|
+
return plain;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function toolsErrorKind(serialized) {
|
|
921
|
+
let fromProps = serialized.properties?._name;
|
|
922
|
+
return typeof fromProps == "string" ? fromProps : serialized.name.match(/\(([^)]+)\)$/)?.[1] ?? serialized.name;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// src/cli/tools/sdk/create-tools.ts
|
|
926
|
+
async function createTools(options = {}, deps = {}) {
|
|
927
|
+
let mode = options.mode ?? "auto", clientInfo = {
|
|
928
|
+
name: options.clientInfo?.name ?? "storybook-tools-sdk",
|
|
929
|
+
version: options.clientInfo?.version ?? versions["@aussieljk/forkbook"],
|
|
930
|
+
kind: options.clientInfo?.kind ?? "sdk"
|
|
931
|
+
};
|
|
932
|
+
switch (mode) {
|
|
933
|
+
case "attached":
|
|
934
|
+
try {
|
|
935
|
+
return await createAttachedTools(options, deps, clientInfo, mode);
|
|
936
|
+
} catch (error) {
|
|
937
|
+
throw isAttachGateError(error) && await reportSdkAttachGate({
|
|
938
|
+
error,
|
|
939
|
+
clientInfo,
|
|
940
|
+
requestedMode: mode,
|
|
941
|
+
configDir: options.configDir
|
|
942
|
+
}), error;
|
|
943
|
+
}
|
|
944
|
+
case "auto":
|
|
945
|
+
try {
|
|
946
|
+
return await createAttachedTools(options, deps, clientInfo, mode);
|
|
947
|
+
} catch (error) {
|
|
948
|
+
if (!isAttachGateError(error))
|
|
949
|
+
throw error;
|
|
950
|
+
let fallbackReason = attachGateReasonFromError(error), notice = fallbackReason === "no-instance" ? void 0 : formatAttachFallback(error.message);
|
|
951
|
+
try {
|
|
952
|
+
return await createLocalTools(options, deps, clientInfo, mode, {
|
|
953
|
+
...notice ? { fallbackNotice: notice } : {},
|
|
954
|
+
fallbackReason
|
|
955
|
+
});
|
|
956
|
+
} catch (localError) {
|
|
957
|
+
throw shouldWrapAutoLocalFailure(localError) ? wrapAutoLocalFailure(notice ?? formatAttachFallback(error.message), localError) : localError;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
case "local":
|
|
961
|
+
return createLocalTools(options, deps, clientInfo, mode);
|
|
962
|
+
default:
|
|
963
|
+
throw mode;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
async function createAttachedTools(options, deps, clientInfo, requestedMode) {
|
|
967
|
+
process.env.FORKBOOK_ATTACHED_TOOLS = "true";
|
|
968
|
+
let { bootstrapAttachedRuntime } = await import("./attached-runtime-I2G4WLJI.js"), autoSpawn = process.env.FORKBOOK_TOOLS_CHILD_HOST === "true" ? !1 : options.autoSpawn ?? !0, attached = await (deps.attach ?? ((target) => bootstrapAttachedRuntime({ ...target, autoSpawn })))({
|
|
969
|
+
cwd: options.cwd,
|
|
970
|
+
configDir: options.configDir,
|
|
971
|
+
port: options.port
|
|
972
|
+
});
|
|
973
|
+
if ("kind" in attached && attached.kind === "spawn")
|
|
974
|
+
return (deps.spawnChild ?? spawnChildHost)({
|
|
975
|
+
cwd: attached.record.cwd,
|
|
976
|
+
installationPath: attached.storybookPath,
|
|
977
|
+
options: {
|
|
978
|
+
...options,
|
|
979
|
+
mode: "attached",
|
|
980
|
+
autoSpawn: !1,
|
|
981
|
+
cwd: attached.record.cwd,
|
|
982
|
+
port: attached.record.port
|
|
983
|
+
},
|
|
984
|
+
clientInfo,
|
|
985
|
+
requestedMode
|
|
986
|
+
});
|
|
987
|
+
let inProcess = attached, siblings = inProcess.siblings?.length ? inProcess.siblings.map(toSiblingInstance) : void 0;
|
|
988
|
+
return createToolsHost({
|
|
989
|
+
mode: "attached",
|
|
990
|
+
host: "in-process",
|
|
991
|
+
requestedMode,
|
|
992
|
+
runtime: inProcess.runtime,
|
|
993
|
+
clientInfo,
|
|
994
|
+
storybook: {
|
|
995
|
+
version: versions["@aussieljk/forkbook"],
|
|
996
|
+
configDir: inProcess.runtime.configDir,
|
|
997
|
+
url: inProcess.record.url,
|
|
998
|
+
pid: inProcess.record.pid,
|
|
999
|
+
...inProcess.record.port != null ? { port: inProcess.record.port } : {},
|
|
1000
|
+
...inProcess.record.cwd ? { cwd: inProcess.record.cwd } : {},
|
|
1001
|
+
...siblings ? { siblings } : {}
|
|
1002
|
+
},
|
|
1003
|
+
close: () => inProcess.connection.close(),
|
|
1004
|
+
disconnected: inProcess.connection.disconnected
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
function toSiblingInstance(record) {
|
|
1008
|
+
return {
|
|
1009
|
+
url: record.url,
|
|
1010
|
+
port: record.port,
|
|
1011
|
+
pid: record.pid,
|
|
1012
|
+
cwd: record.cwd,
|
|
1013
|
+
...record.configDir ? { configDir: record.configDir } : {}
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
async function createLocalTools(options, deps, clientInfo, requestedMode, fallback) {
|
|
1017
|
+
delete process.env.FORKBOOK_ATTACHED_TOOLS;
|
|
1018
|
+
let cwd = resolve(options.cwd ?? process.cwd()), autoSpawn = process.env.FORKBOOK_TOOLS_CHILD_HOST === "true" ? !1 : options.autoSpawn ?? !0;
|
|
1019
|
+
if (!projectPathsEqual(cwd, process.cwd())) {
|
|
1020
|
+
if (!autoSpawn)
|
|
1021
|
+
throw new ToolsRuntimeError({
|
|
1022
|
+
reason: "mode-unavailable",
|
|
1023
|
+
message: `This process is running from ${process.cwd()}, but the target Forkbook is at ${cwd}. Re-run from that directory, or omit \`autoSpawn: false\` so a child host can load the project.`
|
|
1024
|
+
});
|
|
1025
|
+
let child = await (deps.spawnChild ?? spawnChildHost)({
|
|
1026
|
+
cwd,
|
|
1027
|
+
options: { ...options, mode: "local", autoSpawn: !1, cwd },
|
|
1028
|
+
clientInfo,
|
|
1029
|
+
requestedMode
|
|
1030
|
+
});
|
|
1031
|
+
return fallback ? { ...child, ...fallback } : child;
|
|
1032
|
+
}
|
|
1033
|
+
let { bootstrapToolsRuntime } = await import("./local-runtime-NTKIN2QT.js"), runtime;
|
|
1034
|
+
try {
|
|
1035
|
+
runtime = await (deps.bootstrap ?? bootstrapToolsRuntime)({
|
|
1036
|
+
cwd,
|
|
1037
|
+
configDir: options.configDir
|
|
1038
|
+
});
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
throw new ToolsRuntimeError({
|
|
1041
|
+
reason: "config-load-failed",
|
|
1042
|
+
message: `Could not load the Forkbook configuration for this project: ${error instanceof Error ? error.message : String(error)}`,
|
|
1043
|
+
cause: error
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
return createToolsHost({
|
|
1047
|
+
mode: "local",
|
|
1048
|
+
host: "in-process",
|
|
1049
|
+
requestedMode,
|
|
1050
|
+
...fallback,
|
|
1051
|
+
runtime,
|
|
1052
|
+
clientInfo,
|
|
1053
|
+
storybook: { version: versions["@aussieljk/forkbook"], configDir: runtime.configDir }
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
function shouldWrapAutoLocalFailure(error) {
|
|
1057
|
+
return error instanceof SpawnFailedError ? !0 : error instanceof ToolsRuntimeError && (error.data.reason === "config-load-failed" || error.data.reason === "mode-unavailable");
|
|
1058
|
+
}
|
|
1059
|
+
function wrapAutoLocalFailure(notice, localError) {
|
|
1060
|
+
let message = `${notice}
|
|
1061
|
+
|
|
1062
|
+
${localError.message}`;
|
|
1063
|
+
if (localError instanceof SpawnFailedError)
|
|
1064
|
+
return new SpawnFailedError({
|
|
1065
|
+
reason: message,
|
|
1066
|
+
cause: localError.data.cause ?? localError
|
|
1067
|
+
});
|
|
1068
|
+
if (localError instanceof ToolsRuntimeError)
|
|
1069
|
+
return new ToolsRuntimeError({
|
|
1070
|
+
reason: localError.data.reason,
|
|
1071
|
+
message,
|
|
1072
|
+
cause: localError.data.cause
|
|
1073
|
+
});
|
|
1074
|
+
throw localError;
|
|
1075
|
+
}
|
|
1076
|
+
function transportFor(kind) {
|
|
1077
|
+
return kind === "cli" ? "cli" : "sdk";
|
|
1078
|
+
}
|
|
1079
|
+
function createToolsHost(args) {
|
|
1080
|
+
let { mode, host, requestedMode, runtime, clientInfo, storybook } = args, baseCtx = {
|
|
1081
|
+
transport: transportFor(clientInfo.kind),
|
|
1082
|
+
getService: runtime.getService,
|
|
1083
|
+
...storybook.url ? { origin: storybook.url } : {}
|
|
1084
|
+
}, closed = !1, assertOpen = () => {
|
|
1085
|
+
if (closed)
|
|
1086
|
+
throw new ToolsRuntimeError({
|
|
1087
|
+
reason: "closed",
|
|
1088
|
+
message: "This tools host is closed. Create a new one with `createTools`."
|
|
1089
|
+
});
|
|
1090
|
+
}, invoke = async (ref, input, options) => {
|
|
1091
|
+
options.signal?.throwIfAborted();
|
|
1092
|
+
let { toolsetId, methodName } = splitRef(ref), toolset = findToolset(runtime, toolsetId), method = findMethod(toolset, methodName);
|
|
1093
|
+
if (mode === "local" && method.requiresDevServer)
|
|
1094
|
+
throw new AttachUnavailableError({
|
|
1095
|
+
reason: "no-instance",
|
|
1096
|
+
instances: [],
|
|
1097
|
+
remediation: `\`${ref}\` needs a running Forkbook dev server, and this tools host loaded the project's configuration on its own. Start Forkbook (for example \`npm run storybook\`), then retry.`
|
|
1098
|
+
});
|
|
1099
|
+
let validation = await method.input["~standard"].validate(input);
|
|
1100
|
+
if (validation.issues)
|
|
1101
|
+
throw new ToolsRuntimeError({
|
|
1102
|
+
reason: "invalid-input",
|
|
1103
|
+
message: `Invalid input for \`${ref}\`:
|
|
1104
|
+
${formatIssues(validation.issues)}`,
|
|
1105
|
+
issues: validation.issues
|
|
1106
|
+
});
|
|
1107
|
+
return raceAbort(
|
|
1108
|
+
options.signal,
|
|
1109
|
+
invokeToolsetMethod(toolset, methodName, validation.value, {
|
|
1110
|
+
...baseCtx,
|
|
1111
|
+
...options.origin !== void 0 ? { origin: options.origin } : {}
|
|
1112
|
+
})
|
|
1113
|
+
);
|
|
1114
|
+
};
|
|
1115
|
+
return {
|
|
1116
|
+
mode,
|
|
1117
|
+
host,
|
|
1118
|
+
requestedMode,
|
|
1119
|
+
clientInfo,
|
|
1120
|
+
runtime,
|
|
1121
|
+
storybook,
|
|
1122
|
+
...args.fallbackNotice ? { fallbackNotice: args.fallbackNotice } : {},
|
|
1123
|
+
...args.fallbackReason ? { fallbackReason: args.fallbackReason } : {},
|
|
1124
|
+
async describe(options = {}) {
|
|
1125
|
+
assertOpen();
|
|
1126
|
+
let toolsets = options.toolset === void 0 ? runtime.toolsets : [findToolset(runtime, options.toolset)];
|
|
1127
|
+
return {
|
|
1128
|
+
configDir: runtime.configDir,
|
|
1129
|
+
toolsets: toolsets.map((toolset) => toCatalogEntry(toolset, baseCtx))
|
|
1130
|
+
};
|
|
1131
|
+
},
|
|
1132
|
+
async call(ref, input = {}, options = {}) {
|
|
1133
|
+
assertOpen();
|
|
1134
|
+
let start = Date.now();
|
|
1135
|
+
try {
|
|
1136
|
+
let outcome = args.disconnected ? await Promise.race([invoke(ref, input, options), args.disconnected]) : await invoke(ref, input, options);
|
|
1137
|
+
return await reportSdkInvocation({
|
|
1138
|
+
ref,
|
|
1139
|
+
clientInfo,
|
|
1140
|
+
requestedMode,
|
|
1141
|
+
resolvedMode: mode,
|
|
1142
|
+
host,
|
|
1143
|
+
fallbackReason: args.fallbackReason,
|
|
1144
|
+
result: outcome,
|
|
1145
|
+
report: outcome.telemetry,
|
|
1146
|
+
duration: Date.now() - start,
|
|
1147
|
+
configDir: runtime.configDir
|
|
1148
|
+
}), outcome;
|
|
1149
|
+
} catch (error) {
|
|
1150
|
+
let mapped = error instanceof StorybookDevServerDisconnectedError ? new ToolsRuntimeError({
|
|
1151
|
+
reason: "connection-lost",
|
|
1152
|
+
message: error.message,
|
|
1153
|
+
cause: error
|
|
1154
|
+
}) : error;
|
|
1155
|
+
throw await reportSdkInvocation({
|
|
1156
|
+
ref,
|
|
1157
|
+
clientInfo,
|
|
1158
|
+
requestedMode,
|
|
1159
|
+
resolvedMode: mode,
|
|
1160
|
+
host,
|
|
1161
|
+
fallbackReason: args.fallbackReason,
|
|
1162
|
+
result: { error: mapped },
|
|
1163
|
+
duration: Date.now() - start,
|
|
1164
|
+
configDir: runtime.configDir
|
|
1165
|
+
}), mapped;
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
async close() {
|
|
1169
|
+
closed || (closed = !0, args.close?.(), await runtime.close());
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function raceAbort(signal, work) {
|
|
1174
|
+
let pending = Promise.resolve(work);
|
|
1175
|
+
if (!signal)
|
|
1176
|
+
return pending;
|
|
1177
|
+
signal.throwIfAborted();
|
|
1178
|
+
let onAbort, aborted = new Promise((_, reject) => {
|
|
1179
|
+
onAbort = () => reject(signal.reason), signal.addEventListener("abort", onAbort, { once: !0 });
|
|
1180
|
+
});
|
|
1181
|
+
return Promise.race([pending, aborted]).finally(() => {
|
|
1182
|
+
signal.removeEventListener("abort", onAbort);
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
function splitRef(ref) {
|
|
1186
|
+
try {
|
|
1187
|
+
return parseToolsetMethodId(ref);
|
|
1188
|
+
} catch {
|
|
1189
|
+
throw new ToolsRuntimeError({
|
|
1190
|
+
reason: "unknown-method",
|
|
1191
|
+
message: `Invalid tool reference \`${ref}\`. Expected \`toolsetId.methodName\`.`
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
function findToolset(runtime, toolsetId) {
|
|
1196
|
+
let toolset = runtime.toolsets.find((candidate) => candidate.id === toolsetId);
|
|
1197
|
+
if (!toolset)
|
|
1198
|
+
throw new ToolsRuntimeError({
|
|
1199
|
+
reason: "unknown-toolset",
|
|
1200
|
+
message: `Unknown toolset \`${toolsetId}\`. The Forkbook configuration at ${runtime.configDir} provides: ${runtime.toolsets.map((candidate) => candidate.id).join(", ")}.`
|
|
1201
|
+
});
|
|
1202
|
+
return toolset;
|
|
1203
|
+
}
|
|
1204
|
+
function findMethod(toolset, methodName) {
|
|
1205
|
+
if (!Object.hasOwn(toolset.methods, methodName))
|
|
1206
|
+
throw new ToolsRuntimeError({
|
|
1207
|
+
reason: "unknown-method",
|
|
1208
|
+
message: `Unknown tool \`${toolset.id}.${methodName}\`. The \`${toolset.id}\` toolset provides: ${Object.keys(toolset.methods).join(", ")}.`
|
|
1209
|
+
});
|
|
1210
|
+
return toolset.methods[methodName];
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export {
|
|
1214
|
+
toCatalogEntry,
|
|
1215
|
+
sanitizeNamePart,
|
|
1216
|
+
reportToolsCommandEvent,
|
|
1217
|
+
createTools
|
|
1218
|
+
};
|