@aussieljk/forkbook 0.0.1-11 → 0.0.1-13
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/README.md +1 -1
- package/assets/create/rendererAssets/common/button.css +6 -6
- package/assets/create/rendererAssets/common/header.css +5 -5
- package/assets/create/rendererAssets/common/page.css +10 -10
- package/dist/_browser-chunks/{Color-QLZNXLSV.js → Color-2EUQ6NXV.js} +2 -2
- package/dist/_browser-chunks/{DocsRenderer-JXND3PVQ.js → DocsRenderer-DKXSW2OY.js} +2 -2
- package/dist/_browser-chunks/{WithTooltip-GNLRTZDF.js → WithTooltip-QCFTNB6P.js} +5 -4
- package/dist/_browser-chunks/{chunk-RBCHTR7C.js → chunk-2ELGJRFZ.js} +1 -1
- package/dist/_browser-chunks/{chunk-6ELMKWKX.js → chunk-2WZWS7GJ.js} +1 -1
- package/dist/_browser-chunks/{chunk-FRAOQJDI.js → chunk-3QPZOXB7.js} +1 -5
- package/dist/_browser-chunks/{chunk-GRO2ZYEJ.js → chunk-4BOJAE7P.js} +12 -8
- package/dist/_browser-chunks/{chunk-ZHKZKFY4.js → chunk-6SL45YM3.js} +9 -13
- package/dist/_browser-chunks/{chunk-DS2WQZGO.js → chunk-BLCZ3C5M.js} +41 -62
- package/dist/_browser-chunks/{chunk-7DQREF4S.js → chunk-DHTLVXAL.js} +37 -44
- package/dist/_browser-chunks/{chunk-GNZY6LOW.js → chunk-DISGPOF4.js} +54 -51
- package/dist/_browser-chunks/{chunk-76222HQR.js → chunk-E6QKKKLO.js} +20 -5
- package/dist/_browser-chunks/{chunk-DYNTDJ3O.js → chunk-EBSOKHFG.js} +8 -2
- package/dist/_browser-chunks/{chunk-3M5T7BW4.js → chunk-ECMVTOVD.js} +1 -1
- package/dist/_browser-chunks/{chunk-EQKMUQF3.js → chunk-ENHFQXYS.js} +5 -4
- package/dist/_browser-chunks/{chunk-KYSD26D6.js → chunk-EW2M3URL.js} +90 -83
- package/dist/_browser-chunks/{chunk-I4ATZPNZ.js → chunk-FCULT3AE.js} +3 -3
- package/dist/_browser-chunks/{chunk-46Z7NGAS.js → chunk-HX443LKV.js} +1 -1
- package/dist/_browser-chunks/{chunk-NGMQJMCY.js → chunk-HZFHNYRC.js} +1 -1
- package/dist/_browser-chunks/{chunk-5H4KFI44.js → chunk-KQJ4T6JL.js} +30 -24
- package/dist/_browser-chunks/{chunk-RMYQ3QN3.js → chunk-NK5SGJNG.js} +22 -17
- package/dist/_browser-chunks/{chunk-N3NRW5XX.js → chunk-PQRPDA4U.js} +3 -3
- package/dist/_browser-chunks/{chunk-2JDQ35OA.js → chunk-PU7D2WDP.js} +0 -11
- package/dist/_browser-chunks/{chunk-5WMXI5GW.js → chunk-QFO2B4X2.js} +31 -28
- package/dist/_browser-chunks/{chunk-TTBPZQ24.js → chunk-S7N7Z5TY.js} +47 -43
- package/dist/_browser-chunks/{chunk-2JT76G3E.js → chunk-SBOQ4QPY.js} +15 -15
- package/dist/_browser-chunks/{chunk-WBLVFDJT.js → chunk-UH3XTEOQ.js} +716 -658
- package/dist/_browser-chunks/{chunk-5I7E4GMO.js → chunk-WY2LUGOH.js} +1 -1
- package/dist/_browser-chunks/{chunk-O24AZJZ7.js → chunk-YJO5BK52.js} +7 -3
- package/dist/_browser-chunks/{chunk-3HM3VWJS.js → chunk-ZF37BMDS.js} +6 -2
- package/dist/_browser-chunks/{chunk-QU4RB2WU.js → chunk-ZF5SPY56.js} +4 -4
- package/dist/_browser-chunks/{matchers-YLBYSYAF.js → matchers-2HVLNCVO.js} +4 -4
- package/dist/_browser-chunks/{react-dom-client-4OHE3QDV.js → react-dom-client-SLBUX3U3.js} +1 -1
- package/dist/_node-chunks/{attached-runtime-J2AKT5WI.js → attached-runtime-7IRDQUTZ.js} +28 -29
- package/dist/_node-chunks/{builder-manager-Z4RWF4ZH.js → builder-manager-YTALSWKQ.js} +39 -28
- package/dist/_node-chunks/{chunk-2WVLC5M2.js → chunk-26ERGIQH.js} +6 -6
- package/dist/_node-chunks/{chunk-VZG3OKFO.js → chunk-33T4HNF2.js} +6 -6
- package/dist/_node-chunks/{chunk-ZEYODVQT.js → chunk-3F3673RQ.js} +7 -7
- package/dist/_node-chunks/{chunk-Y4W4B3E7.js → chunk-3FLRYZLJ.js} +6 -6
- package/dist/_node-chunks/{chunk-AVL7GUOZ.js → chunk-3L2QRDKH.js} +522 -1045
- package/dist/_node-chunks/{chunk-XO54HM4P.js → chunk-3NH7IHUS.js} +6 -6
- package/dist/_node-chunks/{chunk-GMKLTDKN.js → chunk-3ZAENV5A.js} +6 -6
- package/dist/_node-chunks/{chunk-3IIQSDCO.js → chunk-4B52HLKK.js} +53 -55
- package/dist/_node-chunks/chunk-4CZJ4SFH.js +281 -0
- package/dist/_node-chunks/{chunk-BBU2FUPC.js → chunk-4IIWFG7O.js} +13 -11
- package/dist/_node-chunks/{chunk-2U5J7YTA.js → chunk-4YWZLOAF.js} +6 -6
- package/dist/_node-chunks/{chunk-XVOIYGTJ.js → chunk-5A5XOSRM.js} +6 -6
- package/dist/_node-chunks/chunk-5T6Q7HT3.js +11 -0
- package/dist/_node-chunks/{chunk-MI7WBXWX.js → chunk-6DRDJF2Q.js} +6 -6
- package/dist/_node-chunks/{chunk-WBCKO5LP.js → chunk-6JSZY5TJ.js} +6 -6
- package/dist/_node-chunks/{chunk-3EBGFRAH.js → chunk-7SPDKMDQ.js} +32 -40
- package/dist/_node-chunks/{chunk-IRPQQARO.js → chunk-7YLKDHLZ.js} +7 -7
- package/dist/_node-chunks/{chunk-BSQB5B57.js → chunk-7YQIVUEK.js} +6 -6
- package/dist/_node-chunks/{chunk-PYVGF5F2.js → chunk-ADCQYK3Z.js} +6 -6
- package/dist/_node-chunks/{chunk-7YQTID2W.js → chunk-ALHQVE5R.js} +6 -6
- package/dist/_node-chunks/{chunk-MW4OAPPD.js → chunk-B4XAZ2OC.js} +8 -8
- package/dist/_node-chunks/{chunk-GGCOG7OV.js → chunk-BFQJF3ID.js} +283 -306
- package/dist/_node-chunks/{chunk-5GOXN5M4.js → chunk-BSXI35KM.js} +7 -7
- package/dist/_node-chunks/{chunk-TAMTPVYZ.js → chunk-BZQF5KUE.js} +7 -7
- package/dist/_node-chunks/{chunk-5JLVSH44.js → chunk-CEIESR4U.js} +8 -8
- package/dist/_node-chunks/{chunk-OJWUUSA4.js → chunk-CESXIP3N.js} +6 -6
- package/dist/_node-chunks/{chunk-CEYSYQLV.js → chunk-DAEUTT3I.js} +6 -6
- package/dist/_node-chunks/{chunk-FB2BOL6I.js → chunk-DIC4T2UO.js} +6 -6
- package/dist/_node-chunks/{chunk-LKITAODU.js → chunk-DPOWAA4P.js} +37 -31
- package/dist/_node-chunks/{chunk-W3KFVTWV.js → chunk-DTNEHO4J.js} +10 -10
- package/dist/_node-chunks/{chunk-C5OFHB3N.js → chunk-DY7F7B6V.js} +7 -7
- package/dist/_node-chunks/{chunk-FUG5LYKS.js → chunk-E56UKDJR.js} +8 -8
- package/dist/_node-chunks/{chunk-A7GEBS3Q.js → chunk-EFX2VA4Q.js} +6 -6
- package/dist/_node-chunks/{chunk-PQTEFQIJ.js → chunk-EM6AYELK.js} +10 -12
- package/dist/_node-chunks/{chunk-32FLWHUC.js → chunk-F2AFT3P7.js} +497 -475
- package/dist/_node-chunks/{chunk-OXT6T4AS.js → chunk-GC7NA2Y7.js} +7 -7
- package/dist/_node-chunks/{chunk-55S3GGGC.js → chunk-GIKCT5KG.js} +7 -7
- package/dist/_node-chunks/{chunk-PXOD36TR.js → chunk-GLNHSUKT.js} +20 -20
- package/dist/_node-chunks/{chunk-BKND5XP2.js → chunk-GQZZQB4K.js} +7 -7
- package/dist/_node-chunks/{chunk-GTXZNA2L.js → chunk-GRN6WQC3.js} +10 -10
- package/dist/_node-chunks/{chunk-6UASHVMR.js → chunk-HCMHVV7N.js} +8 -8
- package/dist/_node-chunks/{chunk-IVAOJWPF.js → chunk-HJVZQS65.js} +7 -7
- package/dist/_node-chunks/{chunk-ER3X3AQ7.js → chunk-I26RGEVQ.js} +7 -7
- package/dist/_node-chunks/{chunk-LAIED5XU.js → chunk-I36FPWMO.js} +6 -6
- package/dist/_node-chunks/{chunk-W7HY3ELZ.js → chunk-IDPQ3CVN.js} +474 -479
- package/dist/_node-chunks/{chunk-36LPBTLF.js → chunk-JUVUVVHI.js} +6 -6
- package/dist/_node-chunks/{chunk-DGWKJQ6G.js → chunk-K6TEIAKH.js} +62 -7
- package/dist/_node-chunks/{chunk-7IOSIYW2.js → chunk-KEXQ3BON.js} +7 -7
- package/dist/_node-chunks/{chunk-NLNAIU4I.js → chunk-KUZSE7ZD.js} +9 -9
- package/dist/_node-chunks/chunk-LJ5JRR5Q.js +18 -0
- package/dist/_node-chunks/{chunk-YBG7HVP7.js → chunk-LMGI47HP.js} +8 -8
- package/dist/_node-chunks/{chunk-6E34W4UX.js → chunk-LPIPPSMS.js} +6 -6
- package/dist/_node-chunks/{chunk-XICRXTTE.js → chunk-LR4W5G37.js} +6 -6
- package/dist/_node-chunks/{chunk-VKRGTLQJ.js → chunk-M4MRBEJI.js} +27 -23
- package/dist/_node-chunks/{chunk-REIDJUVJ.js → chunk-M7BVABR2.js} +20 -16
- package/dist/_node-chunks/{chunk-XCJ2ZIQ4.js → chunk-MK2RPLWT.js} +7 -7
- package/dist/_node-chunks/{chunk-LHNHFYK3.js → chunk-MKSEM5C2.js} +6 -6
- package/dist/_node-chunks/{chunk-RNRGXAFV.js → chunk-MWQIBOUB.js} +6 -6
- package/dist/_node-chunks/{chunk-NFDQT7UW.js → chunk-NAXIA2JI.js} +320 -316
- package/dist/_node-chunks/{chunk-GYFR2JLS.js → chunk-NDVIMCIX.js} +7 -7
- package/dist/_node-chunks/{chunk-D5ADPGA4.js → chunk-NIOVXWQZ.js} +6 -6
- package/dist/_node-chunks/{chunk-54EHKXV7.js → chunk-NRP4FGRT.js} +15 -9
- package/dist/_node-chunks/{chunk-NIQSBBT2.js → chunk-NSNBFXVB.js} +7 -7
- package/dist/_node-chunks/{chunk-Z2ZTDQDY.js → chunk-NTUTJAD4.js} +8 -8
- package/dist/_node-chunks/{chunk-XH5CXH53.js → chunk-O46DZ2KC.js} +8 -8
- package/dist/_node-chunks/{chunk-S3NDLFYL.js → chunk-OH5M2YER.js} +7 -7
- package/dist/_node-chunks/{chunk-FTYDKQCO.js → chunk-OSIENBU6.js} +6 -6
- package/dist/_node-chunks/{chunk-76KKKLEE.js → chunk-OVJZBW54.js} +7 -7
- package/dist/_node-chunks/{chunk-WO4UEQI6.js → chunk-PGIDRLZ5.js} +22 -22
- package/dist/_node-chunks/{chunk-J3SM62J3.js → chunk-PJCSZR4T.js} +8 -8
- package/dist/_node-chunks/{chunk-OPT5A55S.js → chunk-PQXP5FZ2.js} +8 -8
- package/dist/_node-chunks/{chunk-5P4N734V.js → chunk-PU33WSBW.js} +34 -52
- package/dist/_node-chunks/{chunk-APPFF22V.js → chunk-PUBZLLNL.js} +7 -7
- package/dist/_node-chunks/{chunk-ALGQMFMN.js → chunk-QWZZX2HN.js} +6 -6
- package/dist/_node-chunks/{chunk-NLLM4MDK.js → chunk-RMUBUNBY.js} +6 -6
- package/dist/_node-chunks/{chunk-SJXLINHV.js → chunk-S33FEPQ3.js} +6 -6
- package/dist/_node-chunks/{chunk-FEC5PGJO.js → chunk-SHP6447T.js} +7 -7
- package/dist/_node-chunks/{chunk-MBIVTOJK.js → chunk-ST3KB36E.js} +6 -6
- package/dist/_node-chunks/{chunk-AKMPPLT5.js → chunk-SXX75O2D.js} +7 -7
- package/dist/_node-chunks/{chunk-6UAJLEIO.js → chunk-TQ5YAQ4Y.js} +6 -6
- package/dist/_node-chunks/{chunk-R7VDUSKY.js → chunk-TSJ3JCNN.js} +16 -10
- package/dist/_node-chunks/{chunk-TKMXEHM4.js → chunk-UYEX6LW6.js} +7 -7
- package/dist/_node-chunks/{chunk-46Y5H6X5.js → chunk-VJLLEKWR.js} +138 -116
- package/dist/_node-chunks/{chunk-IFAV3CER.js → chunk-WWJKLYU5.js} +10 -10
- package/dist/_node-chunks/{chunk-MXLHIEXC.js → chunk-XC7K4QEX.js} +6 -6
- package/dist/_node-chunks/{chunk-GO3YSBPE.js → chunk-Y64FM6U7.js} +8 -8
- package/dist/_node-chunks/{chunk-T6P2EJD2.js → chunk-YDM7NH4T.js} +6 -6
- package/dist/_node-chunks/{chunk-XSVOMORJ.js → chunk-ZHVOUP6D.js} +6 -6
- package/dist/_node-chunks/dist-CFCU4PZG.js +27 -0
- package/dist/_node-chunks/dist-PFMT5YJK.js +16 -0
- package/dist/_node-chunks/{local-runtime-YDAW5RJV.js → local-runtime-BKID5MBG.js} +19 -20
- package/dist/_node-chunks/{mdx-plugin-XLDET5LV.js → mdx-plugin-7BOUDCZB.js} +13 -13
- package/dist/_node-chunks/{monorepo-NWMAHGOM.js → monorepo-FRHSAJB7.js} +11 -11
- package/dist/_node-chunks/{monorepo-optimized-tests-relaxed-limits-no-story-deletion-4B6IZ7JD.js → monorepo-optimized-tests-relaxed-limits-no-story-deletion-7BHSAJP4.js} +11 -11
- package/dist/_node-chunks/optimized-tests-F5LCOTXH.js +22 -0
- package/dist/_node-chunks/{pattern-copy-play-PJC4PO6A.js → pattern-copy-play-6TGV6WS4.js} +9 -9
- package/dist/_node-chunks/postinstallAddon-4RININ5C.js +20 -0
- package/dist/_node-chunks/{rehype-external-links-4CWXZ35U.js → rehype-external-links-EE2HT4QP.js} +9 -9
- package/dist/_node-chunks/{rehype-slug-QZ2PWSJH.js → rehype-slug-ZKRW2V6Z.js} +9 -9
- package/dist/_node-chunks/{relaxed-limits-ZQR4ER7L.js → relaxed-limits-6Q7VRQC5.js} +11 -11
- package/dist/_node-chunks/{run-U63AXEKZ.js → run-6Y3ZTASZ.js} +23 -21
- package/dist/_node-chunks/{run-BMXB2BW2.js → run-EBHIAT35.js} +18 -18
- package/dist/_node-chunks/{setup-NCUTUBNN.js → setup-6XIF77JT.js} +8 -8
- package/dist/_node-chunks/{vitest.config.4.template-4XHF7XPS.js → vitest.config.4.template-GMQNQ4UW.js} +7 -7
- package/dist/actions/decorator.js +16 -21
- package/dist/actions/index.d.ts +3 -3
- package/dist/actions/index.js +1 -1
- package/dist/addon-a11y/index.js +2 -2
- package/dist/addon-a11y/manager.js +11 -11
- package/dist/addon-a11y/preset.js +7 -7
- package/dist/addon-a11y/preview.d.ts +8 -2
- package/dist/addon-a11y/preview.js +2 -2
- package/dist/addon-docs/blocks.d.ts +104 -85
- package/dist/addon-docs/blocks.js +30 -32
- package/dist/addon-docs/index.d.ts +2 -2
- package/dist/addon-docs/index.js +3 -3
- package/dist/addon-docs/manager.js +4 -4
- package/dist/addon-docs/preset.js +12 -12
- package/dist/addon-docs/preview.d.ts +3 -1
- package/dist/addon-docs/preview.js +1 -1
- package/dist/addon-links/index.d.ts +2 -1
- package/dist/addon-links/preview.d.ts +1 -1
- package/dist/addon-mcp/preset.js +11 -11
- package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +16 -16
- package/dist/addon-ondevice-controls/index.js +1 -1
- package/dist/addon-ondevice-controls/register.js +1 -1
- package/dist/addon-pseudo-states/index.js +1 -1
- package/dist/addon-pseudo-states/preview.d.ts +1 -1
- package/dist/addon-pseudo-states/preview.js +1 -1
- package/dist/addon-themes/index.d.ts +6 -5
- package/dist/addon-themes/postinstall.js +7 -7
- package/dist/addon-vitest/constants.js +8 -8
- package/dist/addon-vitest/manager.js +18 -9
- package/dist/addon-vitest/node/coverage-reporter.js +11 -11
- package/dist/addon-vitest/node/vitest.js +34 -34
- package/dist/addon-vitest/postinstall.js +10 -10
- package/dist/addon-vitest/preset.js +21 -20
- package/dist/addon-vitest/vitest-plugin/global-setup.js +22 -22
- package/dist/addon-vitest/vitest-plugin/index.js +69 -59
- package/dist/babel/index.d.ts +209 -212
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +110 -89
- package/dist/bin/dispatcher.js +10 -10
- package/dist/bin/loader.js +8 -8
- package/dist/builder-vite/index.d.ts +1 -1
- package/dist/builder-vite/index.js +18 -18
- package/dist/builder-vite/preset.js +13 -13
- package/dist/channels/index.d.ts +1 -1
- package/dist/channels/index.js +2 -2
- package/dist/{chunk-Dr3R0DXk.d.ts → chunk-B-NVyPqN.d.ts} +2 -2
- package/dist/{chunk-Fg1Fm__9.d.ts → chunk-BCG2ui5q.d.ts} +671 -674
- package/dist/{chunk-DoIGKY33.d.ts → chunk-BLZXEm1K.d.ts} +6 -8
- package/dist/{chunk-CYuvV2sR.d.ts → chunk-BNRZY6Jq.d.ts} +3 -3
- package/dist/{chunk-CNqjcOmK.d.ts → chunk-BV_hETtB.d.ts} +2 -2
- package/dist/chunk-BcYKnZln.d.ts +10 -0
- package/dist/{chunk-BCoJQE-f.d.ts → chunk-BtKww7r1.d.ts} +6 -4
- package/dist/{chunk-Bpi2tz-6.d.ts → chunk-Bubi-WAs.d.ts} +20 -17
- package/dist/{chunk-pcFXCimE.d.ts → chunk-CmV7WZzR.d.ts} +124 -2
- package/dist/{chunk-BGkgZp-H.d.ts → chunk-D3uSIa6H.d.ts} +9 -1
- package/dist/{chunk-DROZ9oel.d.ts → chunk-DNCU78oW.d.ts} +110 -9
- package/dist/{chunk-D0NUmzXp.d.ts → chunk-LWwxlbee.d.ts} +4 -4
- package/dist/{chunk-BXLImeLy.d.ts → chunk-u_gGuTrz.d.ts} +23 -8
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +25 -30
- package/dist/cli/skills/content/index.d.ts +1 -1
- package/dist/cli/tools/sdk/child-host.d.ts +1 -1
- package/dist/cli/tools/sdk/child-host.js +17 -17
- package/dist/cli/tools/sdk/index.d.ts +3 -3
- package/dist/cli/tools/sdk/index.js +18 -18
- package/dist/cli-commands/bin/index.js +7 -7
- package/dist/client-logger/index.d.ts +20 -21
- package/dist/client-logger/index.js +2 -1
- package/dist/common/index.d.ts +13 -13
- package/dist/common/index.js +34 -35
- package/dist/components/index.d.ts +46 -35
- package/dist/components/index.js +194 -205
- package/dist/core-events/index.d.ts +2 -2
- package/dist/core-server/index.d.ts +15 -10
- package/dist/core-server/index.js +706 -165
- package/dist/core-server/presets/common-manager.js +254 -336
- package/dist/core-server/presets/common-override-preset.js +10 -10
- package/dist/core-server/presets/common-preset.js +83 -275
- package/dist/create/bin/index.js +7 -7
- package/dist/create/index.js +15 -15
- package/dist/csf/csf-utils.d.ts +1 -1
- package/dist/csf/index.d.ts +3 -3
- package/dist/csf/index.js +40 -43
- package/dist/csf-tools/index.d.ts +52 -44
- package/dist/csf-tools/index.js +13 -13
- package/dist/docs-tools/index.d.ts +332 -16
- package/dist/docs-tools/index.js +3 -3
- package/dist/instrumenter/index.d.ts +5 -5
- package/dist/instrumenter/index.js +25 -15
- package/dist/manager/_manager-chunks/{globals-runtime-DvV_TF3-.js → globals-runtime-B4NRbNSS.js} +2 -2
- package/dist/manager/_manager-chunks/{globals-runtime-wjkxyMn0.js → globals-runtime-BC43T1rL.js} +4150 -50
- package/dist/manager/_manager-chunks/{globals-runtime-BSj0mCjE.js → globals-runtime-BgWmCsA7.js} +114 -110
- package/dist/manager/_manager-chunks/{globals-runtime-CA8AuIRT.js → globals-runtime-BnQ7i5wq.js} +232 -228
- package/dist/manager/_manager-chunks/globals-runtime-BtduS2C2.js +10601 -0
- package/dist/manager/_manager-chunks/globals-runtime-BzuYs3dZ.js +1971 -0
- package/dist/manager/_manager-chunks/{globals-runtime-C5gK7HhH.js → globals-runtime-C59T0h-j.js} +2 -2
- package/dist/manager/_manager-chunks/{globals-runtime-CCTA-XPa.js → globals-runtime-CCZrdft6.js} +5 -4
- package/dist/manager/_manager-chunks/{globals-runtime-BY3epqww.js → globals-runtime-CS41oTca.js} +2 -1
- package/dist/manager/_manager-chunks/{globals-runtime-Bu9eGDTe.js → globals-runtime-Cccwtspx.js} +288 -420
- package/dist/manager/_manager-chunks/globals-runtime-CoTrrHG3.js +1163 -0
- package/dist/manager/_manager-chunks/{globals-runtime-BweHuXkK.js → globals-runtime-DCmvKMN5.js} +2 -2
- package/dist/manager/_manager-chunks/{globals-runtime-C92M_Vnq.js → globals-runtime-Ddp2jFET.js} +5 -5
- package/dist/manager/_manager-chunks/globals-runtime-DgO0hT2p.js +32 -0
- package/dist/manager/_manager-chunks/globals-runtime-Me9Bl-sx.js +156 -0
- package/dist/manager/_manager-chunks/{globals-runtime-CHjExYMv.js → globals-runtime-UFDJQlo-.js} +741 -540
- package/dist/manager/_manager-chunks/globals-runtime-nQMRiA0J.js +19 -0
- package/dist/manager/_manager-chunks/{globals-runtime-Bj5KDUJi.js → globals-runtime-oRjPg2jY.js} +1 -1
- package/dist/manager/_manager-chunks/runtime-4wMiTjjZ.js +552 -0
- package/dist/manager/_manager-chunks/{runtime--hR2NZFd.js → runtime-AvqHE9rM.js} +112 -109
- package/dist/manager/_manager-chunks/{runtime-EPerAEAs.js → runtime-CZtDJIYj.js} +3 -3
- package/dist/manager/_manager-chunks/{runtime-B6NL14pz.js → runtime-D8QxTQiI.js} +6 -6
- package/dist/manager/_manager-chunks/{runtime-BAsOe1C_.js → runtime-DC3oEVlM.js} +49 -49
- package/dist/manager/_manager-chunks/{runtime-CJQZFUUj.js → runtime-DCOIOn4T.js} +46 -56
- package/dist/manager/_manager-chunks/{runtime-DvB1axgp.js → runtime-D_FDSHFG.js} +13 -13
- package/dist/manager/_manager-chunks/{runtime-Dtbhxq5m.js → runtime-Db8fJ2MP.js} +67 -500
- package/dist/manager/_manager-chunks/{runtime-CgRqs_SK.js → runtime-lPbyY_f5.js} +882 -869
- package/dist/manager/_manager-chunks/{runtime-Dem2xJbS.js → runtime-td6oYfU6.js} +739 -554
- package/dist/manager/globals-runtime.js +1 -1
- package/dist/manager/runtime.js +1 -1
- package/dist/manager-api/index.d.ts +1 -1
- package/dist/manager-api/index.js +479 -464
- package/dist/manager-errors.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +9 -9
- package/dist/mocking-utils/index.d.ts +5 -3
- package/dist/mocking-utils/index.js +21 -26
- package/dist/nextjs-vite/export-mocks/headers/index.js +3 -1
- package/dist/nextjs-vite/export-mocks/link/index.d.ts +4 -1
- package/dist/nextjs-vite/export-mocks/navigation/index.d.ts +9 -1
- package/dist/nextjs-vite/export-mocks/router/index.js +13 -7
- package/dist/nextjs-vite/index.d.ts +2 -2
- package/dist/nextjs-vite/index.js +9 -5
- package/dist/nextjs-vite/node/index.js +7 -7
- package/dist/nextjs-vite/preset.js +12 -12
- package/dist/nextjs-vite/preview.d.ts +2 -1
- package/dist/nextjs-vite/preview.js +1 -1
- package/dist/nextjs-vite/vite-plugin/index.d.ts +2 -2
- package/dist/nextjs-vite/vite-plugin/index.js +9 -9
- package/dist/nextjs-vite-plugin/index.js +17 -27
- package/dist/nextjs-vite-plugin/mocks/storybook.global.js +8 -8
- package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/router/index.js +10 -6
- package/dist/node-logger/index.d.ts +18 -18
- package/dist/node-logger/index.js +9 -9
- package/dist/oxc-parser/index.js +14 -11
- package/dist/oxc-parser/worker.js +10 -10
- package/dist/preview/_chunks/{runtime-Bcv1hJky.js → runtime-BYRCSYBN.js} +4148 -48
- package/dist/preview/_chunks/{runtime-WapFVPAh.js → runtime-Bvh_rfnQ.js} +2 -37
- package/dist/preview/_chunks/{runtime-BZ4pNS3g.js → runtime-CdZ1yk7m.js} +3 -3
- package/dist/preview/_chunks/{runtime-BhSZ1Mwt.js → runtime-CsO4apr9.js} +38 -42
- package/dist/preview/_chunks/{runtime-BUnOhg9h.js → runtime-D2MPrqbU.js} +2 -2
- package/dist/preview/_chunks/{runtime-BPwAnlRx.js → runtime-DS0s7U3c.js} +1 -1
- package/dist/preview/_chunks/{runtime-BgPhfM5P.js → runtime-U1Ycy25F.js} +736 -428
- package/dist/preview/_chunks/{runtime-BJwGQok8.js → runtime-tyJLgv6h.js} +221 -60
- package/dist/preview/runtime.js +1 -1
- package/dist/preview-api/index.d.ts +3 -3
- package/dist/preview-api/index.js +8 -8
- package/dist/preview-errors.d.ts +1 -1
- package/dist/react/docgen/docgen-worker.js +11 -11
- package/dist/react/entry-preview-argtypes.js +1 -1
- package/dist/react/entry-preview-docs.js +1 -1
- package/dist/react/entry-preview.js +1 -1
- package/dist/react/index.d.ts +5 -7
- package/dist/react/index.js +5 -5
- package/dist/react/preset.js +13 -13
- package/dist/react/preview.js +4 -4
- package/dist/react-native/bin/get-stories.js +8 -8
- package/dist/react-native/index.d.ts +37 -36
- package/dist/react-native/index.js +38 -38
- package/dist/react-native/metro/node.d.ts +1 -1
- package/dist/react-native/metro/node.js +10 -10
- package/dist/react-native/metro/withForkbook.d.ts +7 -7
- package/dist/react-native/metro/withForkbook.js +16 -16
- package/dist/react-native/preview.js +4 -1
- package/dist/react-native/scripts/generate.js +8 -8
- package/dist/react-native/stub.js +1 -1
- package/dist/react-native-ui/index.d.ts +8 -7
- package/dist/react-native-ui/index.js +1 -8
- package/dist/react-native-ui-common/index.d.ts +30 -9
- package/dist/react-native-ui-common/index.js +26 -31
- package/dist/react-vite/node/index.js +7 -7
- package/dist/react-vite/preset.js +7 -7
- package/dist/router/index.d.ts +2 -2
- package/dist/router/index.js +4 -2
- package/dist/server-errors.d.ts +1 -1
- package/dist/server-errors.js +9 -9
- package/dist/shared/open-service/index.d.ts +3 -3
- package/dist/shared/open-service/index.js +1 -1
- package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +9 -9
- package/dist/shared/open-service/toolsets/docs/public.d.ts +7 -7
- package/dist/telemetry/index.d.ts +38 -274
- package/dist/telemetry/index.js +11 -66
- package/dist/test/index.d.ts +2 -2
- package/dist/test/index.js +139 -120
- package/dist/theming/create.d.ts +1 -1
- package/dist/theming/index.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/package.json +16 -16
- package/template/nextjs-vite/cli/js/Button.jsx +2 -2
- package/template/nextjs-vite/cli/js/Header.jsx +1 -1
- package/template/nextjs-vite/cli/js/Page.jsx +1 -1
- package/template/nextjs-vite/cli/ts/Button.tsx +2 -2
- package/template/nextjs-vite/cli/ts/Header.tsx +1 -1
- package/template/nextjs-vite/cli/ts/Page.tsx +1 -1
- package/template/react/cli/js/Button.jsx +2 -2
- package/template/react/cli/js/Header.jsx +1 -1
- package/template/react/cli/js/Page.jsx +1 -1
- package/template/react/cli/ts/Button.tsx +2 -2
- package/template/react/cli/ts/Header.tsx +1 -1
- package/template/react/cli/ts/Page.tsx +1 -1
- package/template/react-vite/cli/js/Button.jsx +2 -2
- package/template/react-vite/cli/js/Header.jsx +1 -1
- package/template/react-vite/cli/js/Page.jsx +1 -1
- package/template/react-vite/cli/ts/Button.tsx +2 -2
- package/template/react-vite/cli/ts/Header.tsx +1 -1
- package/template/react-vite/cli/ts/Page.tsx +1 -1
- package/dist/_node-chunks/chunk-2YNXKY72.js +0 -40
- package/dist/_node-chunks/chunk-3NST2GUZ.js +0 -33
- package/dist/_node-chunks/chunk-4D325SMT.js +0 -1359
- package/dist/_node-chunks/chunk-APXRPW7A.js +0 -11
- package/dist/_node-chunks/chunk-QHBQRPDP.js +0 -155
- package/dist/_node-chunks/chunk-SMBAR4G6.js +0 -18
- package/dist/_node-chunks/chunk-SRDKK3SG.js +0 -33
- package/dist/_node-chunks/chunk-V5IMPC3J.js +0 -33
- package/dist/_node-chunks/chunk-YIAUHGY2.js +0 -69
- package/dist/_node-chunks/dist-C5QIQD3G.js +0 -27
- package/dist/_node-chunks/dist-NBRPZCHX.js +0 -16
- package/dist/_node-chunks/optimized-tests-EIPJR7HA.js +0 -22
- package/dist/_node-chunks/postinstallAddon-EOAAURMG.js +0 -20
- package/dist/_node-chunks/session-id-HEW5JUNB.js +0 -23
- package/dist/chunk-BGhyFTJO.d.ts +0 -115
- package/dist/chunk-DaVb55-_.d.ts +0 -124
- package/dist/manager/_manager-chunks/globals-runtime-Bs75QQ_I.js +0 -9987
- package/dist/manager/_manager-chunks/globals-runtime-WZKaeKm9.js +0 -4091
- package/dist/manager/_manager-chunks/runtime-5o_11Jae.js +0 -78
- package/dist/preview/_chunks/runtime-BsMjBzuq.js +0 -53
- package/dist/preview/_chunks/runtime-C1jgT6tJ.js +0 -4091
- package/dist/preview/_chunks/runtime-CkOhMcXf.js +0 -387
|
@@ -1,22 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_sfnpbdazcnb from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_sfnpbdazcnb from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_sfnpbdazcnb from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_sfnpbdazcnb.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_sfnpbdazcnb.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_sfnpbdazcnb.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Forkbook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
createCsfObject,
|
|
14
|
+
findVarDeclarator,
|
|
15
|
+
findVarInitialization,
|
|
14
16
|
pathForNode,
|
|
15
17
|
unwrapExpression
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NAXIA2JI.js";
|
|
17
19
|
import {
|
|
18
20
|
invariant
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-I36FPWMO.js";
|
|
22
|
+
|
|
23
|
+
// src/csf-tools/configFileImports.ts
|
|
24
|
+
import { types as t } from "@aussieljk/forkbook/internal/babel";
|
|
25
|
+
var NEXT_LINE_DIRECTIVE = /^\s*(@ts-(expect-error|ignore)|[a-z]+-disable-next-line|prettier-ignore|biome-ignore)\b/, getHeaderComments = (statement) => {
|
|
26
|
+
let leading = (statement?.comments ?? []).filter((comment) => comment.leading), directive = leading.findIndex(({ value }) => NEXT_LINE_DIRECTIVE.test(value));
|
|
27
|
+
return directive === -1 ? leading : leading.slice(0, directive);
|
|
28
|
+
}, prependStatement = (program, statement) => {
|
|
29
|
+
let first = program.body[0], header = getHeaderComments(first);
|
|
30
|
+
if (!first || !header.length) {
|
|
31
|
+
program.body.unshift(statement);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let firstNonImport = program.body.findIndex((node) => !t.isImportDeclaration(node)), index = firstNonImport === -1 ? program.body.length : firstNonImport;
|
|
35
|
+
if (index === 0) {
|
|
36
|
+
let notHeader = (comment) => !header.includes(comment);
|
|
37
|
+
first.comments = first.comments?.filter(notHeader), first.leadingComments = first.leadingComments?.filter(notHeader), Object.assign(statement, { comments: header, leadingComments: header });
|
|
38
|
+
}
|
|
39
|
+
program.body.splice(index, 0, statement);
|
|
40
|
+
}, isSameModule = (source, fromImport) => source === fromImport || source === fromImport.split("node:")[1], getRequireSource = (node) => {
|
|
41
|
+
if (!t.isVariableDeclaration(node) || node.declarations.length !== 1)
|
|
42
|
+
return;
|
|
43
|
+
let { init } = node.declarations[0];
|
|
44
|
+
if (t.isCallExpression(init) && t.isIdentifier(init.callee, { name: "require" }) && t.isStringLiteral(init.arguments[0]))
|
|
45
|
+
return init.arguments[0].value;
|
|
46
|
+
}, findRequireIndex = (program, fromImport) => program.body.findIndex((node) => {
|
|
47
|
+
let source = getRequireSource(node);
|
|
48
|
+
return source !== void 0 && isSameModule(source, fromImport);
|
|
49
|
+
}), findImportIndex = (program, fromImport) => program.body.findIndex(
|
|
50
|
+
(node) => t.isImportDeclaration(node) && isSameModule(node.source.value, fromImport)
|
|
51
|
+
), requireCall = (fromImport) => t.callExpression(t.identifier("require"), [t.stringLiteral(fromImport)]), shorthandProperty = (name) => t.objectProperty(t.identifier(name), t.identifier(name), void 0, !0), setRequireImport = (program, importSpecifier, fromImport) => {
|
|
52
|
+
let index = findRequireIndex(program, fromImport), requireDeclaration = index === -1 ? void 0 : program.body[index], source = requireDeclaration ? getRequireSource(requireDeclaration) : fromImport, declarator = requireDeclaration?.declarations[0];
|
|
53
|
+
if (typeof importSpecifier == "string") {
|
|
54
|
+
t.isIdentifier(declarator?.id, { name: importSpecifier }) || prependStatement(
|
|
55
|
+
program,
|
|
56
|
+
t.variableDeclaration("const", [
|
|
57
|
+
t.variableDeclarator(t.identifier(importSpecifier), requireCall(source))
|
|
58
|
+
])
|
|
59
|
+
);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (declarator) {
|
|
63
|
+
let pattern = declarator.id;
|
|
64
|
+
importSpecifier.forEach((specifier) => {
|
|
65
|
+
t.isObjectPattern(pattern) && pattern.properties.some(
|
|
66
|
+
(property) => t.isObjectProperty(property) && t.isIdentifier(property.key, { name: specifier })
|
|
67
|
+
) || pattern.properties.push(shorthandProperty(specifier));
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
prependStatement(
|
|
72
|
+
program,
|
|
73
|
+
t.variableDeclaration("const", [
|
|
74
|
+
t.variableDeclarator(
|
|
75
|
+
t.objectPattern(importSpecifier.map(shorthandProperty)),
|
|
76
|
+
requireCall(source)
|
|
77
|
+
)
|
|
78
|
+
])
|
|
79
|
+
);
|
|
80
|
+
}, matchesSpecifier = (current, importSpecifier) => importSpecifier === null ? !1 : typeof importSpecifier == "string" ? t.isImportDefaultSpecifier(current) && current.local.name === importSpecifier : Array.isArray(importSpecifier) ? t.isImportSpecifier(current) && t.isIdentifier(current.imported) && importSpecifier.includes(current.imported.name) : t.isImportNamespaceSpecifier(current) && current.local.name === importSpecifier.namespace, hasSpecifier = (declaration, importSpecifier) => declaration.specifiers.some((current) => matchesSpecifier(current, importSpecifier)), namedSpecifier = (name) => t.importSpecifier(t.identifier(name), t.identifier(name)), setImport = (program, importSpecifier, fromImport) => {
|
|
81
|
+
let index = findImportIndex(program, fromImport), importDeclaration = index === -1 ? void 0 : program.body[index];
|
|
82
|
+
if (importSpecifier === null) {
|
|
83
|
+
importDeclaration || prependStatement(program, t.importDeclaration([], t.stringLiteral(fromImport)));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(importSpecifier)) {
|
|
87
|
+
importDeclaration ? importSpecifier.filter((name) => !hasSpecifier(importDeclaration, [name])).forEach((name) => importDeclaration.specifiers.push(namedSpecifier(name))) : prependStatement(
|
|
88
|
+
program,
|
|
89
|
+
t.importDeclaration(importSpecifier.map(namedSpecifier), t.stringLiteral(fromImport))
|
|
90
|
+
);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let specifier = typeof importSpecifier == "string" ? t.importDefaultSpecifier(t.identifier(importSpecifier)) : t.importNamespaceSpecifier(t.identifier(importSpecifier.namespace));
|
|
94
|
+
importDeclaration ? hasSpecifier(importDeclaration, importSpecifier) || importDeclaration.specifiers.push(specifier) : prependStatement(program, t.importDeclaration([specifier], t.stringLiteral(fromImport)));
|
|
95
|
+
}, removeRequireImport = (program, importSpecifier, fromImport) => {
|
|
96
|
+
let index = findRequireIndex(program, fromImport);
|
|
97
|
+
if (index === -1 || importSpecifier === null)
|
|
98
|
+
return;
|
|
99
|
+
let declarator = program.body[index].declarations[0];
|
|
100
|
+
if (typeof importSpecifier == "string") {
|
|
101
|
+
t.isIdentifier(declarator.id, { name: importSpecifier }) && program.body.splice(index, 1);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (Array.isArray(importSpecifier) && t.isObjectPattern(declarator.id)) {
|
|
105
|
+
let pattern = declarator.id;
|
|
106
|
+
pattern.properties = pattern.properties.filter(
|
|
107
|
+
(property) => !(t.isObjectProperty(property) && t.isIdentifier(property.key) && importSpecifier.includes(property.key.name))
|
|
108
|
+
), pattern.properties.length === 0 && program.body.splice(index, 1);
|
|
109
|
+
}
|
|
110
|
+
}, removeEsmImport = (program, importSpecifier, fromImport) => {
|
|
111
|
+
let index = findImportIndex(program, fromImport);
|
|
112
|
+
if (index === -1)
|
|
113
|
+
return;
|
|
114
|
+
let importDeclaration = program.body[index];
|
|
115
|
+
importSpecifier !== null && (importDeclaration.specifiers = importDeclaration.specifiers.filter(
|
|
116
|
+
(current) => !matchesSpecifier(current, importSpecifier)
|
|
117
|
+
)), importDeclaration.specifiers.length === 0 && program.body.splice(index, 1);
|
|
118
|
+
}, removeImport = (program, importSpecifier, fromImport) => {
|
|
119
|
+
removeRequireImport(program, importSpecifier, fromImport), removeEsmImport(program, importSpecifier, fromImport);
|
|
120
|
+
};
|
|
20
121
|
|
|
21
122
|
// src/csf-tools/ConfigFile.ts
|
|
22
123
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -24,22 +125,22 @@ import {
|
|
|
24
125
|
babelParse,
|
|
25
126
|
generate,
|
|
26
127
|
recast,
|
|
27
|
-
types as
|
|
28
|
-
traverse as
|
|
128
|
+
types as t5,
|
|
129
|
+
traverse as traverse3
|
|
29
130
|
} from "@aussieljk/forkbook/internal/babel";
|
|
30
131
|
import { logger } from "@aussieljk/forkbook/internal/node-logger";
|
|
31
132
|
import { dedent } from "ts-dedent";
|
|
32
133
|
|
|
33
134
|
// src/csf-tools/ConfigObject.ts
|
|
34
|
-
import { traverse, types as
|
|
135
|
+
import { traverse, types as t2 } from "@aussieljk/forkbook/internal/babel";
|
|
35
136
|
var isConfigFactory = (callee) => {
|
|
36
137
|
if (!callee.isIdentifier())
|
|
37
138
|
return !1;
|
|
38
139
|
let binding = callee.scope.getBinding(callee.node.name), name = binding?.path.isImportSpecifier() ? binding.path.node.imported : binding ? void 0 : callee.node;
|
|
39
|
-
return
|
|
140
|
+
return t2.isIdentifier(name) && ["defineMain", "definePreview", "defineConfig"].includes(name.name);
|
|
40
141
|
}, isExportReference = (reference) => {
|
|
41
142
|
let parent = reference.parentPath;
|
|
42
|
-
return parent ? parent.isTSAsExpression() || parent.isTSSatisfiesExpression() || parent.isTSNonNullExpression() ? isExportReference(parent) : reference.isExportNamedDeclaration() || parent.isExportDefaultDeclaration() || parent.isExportSpecifier() || parent.isAssignmentExpression() &&
|
|
143
|
+
return parent ? parent.isTSAsExpression() || parent.isTSSatisfiesExpression() || parent.isTSNonNullExpression() ? isExportReference(parent) : reference.isExportNamedDeclaration() || parent.isExportDefaultDeclaration() || parent.isExportSpecifier() || parent.isAssignmentExpression() && t2.isMemberExpression(parent.node.left) && t2.isIdentifier(parent.node.left.object, { name: "module" }) && t2.isIdentifier(parent.node.left.property, { name: "exports" }) : !1;
|
|
43
144
|
};
|
|
44
145
|
function createConfigObject(config, mode, report, markChanged) {
|
|
45
146
|
let result = {
|
|
@@ -69,7 +170,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
69
170
|
program.traverse({
|
|
70
171
|
AssignmentExpression(path) {
|
|
71
172
|
let { left } = path.node;
|
|
72
|
-
|
|
173
|
+
t2.isMemberExpression(left) && (t2.isIdentifier(left.object, { name: "module" }) && (t2.isIdentifier(left.property, { name: "exports" }) || t2.isStringLiteral(left.property, { value: "exports" })) || t2.isIdentifier(left.object, { name: "exports" })) && assignments.push(path);
|
|
73
174
|
}
|
|
74
175
|
});
|
|
75
176
|
let root = pathForNode(program, config._exportsObject);
|
|
@@ -87,7 +188,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
87
188
|
if (!parent.isCallExpression())
|
|
88
189
|
continue;
|
|
89
190
|
let callee = parent.get("callee");
|
|
90
|
-
if (!(callee.isMemberExpression() && !callee.node.computed &&
|
|
191
|
+
if (!(callee.isMemberExpression() && !callee.node.computed && t2.isIdentifier(callee.node.property, { name: "type" }) && parent.node.arguments.length === 0) && !(isConfigFactory(callee) && parent.node.arguments.length === 1)) {
|
|
91
192
|
reject(
|
|
92
193
|
parent.node,
|
|
93
194
|
"unsupported-initializer",
|
|
@@ -97,7 +198,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
97
198
|
}
|
|
98
199
|
}
|
|
99
200
|
let statement = root.getStatementParent();
|
|
100
|
-
if (statement?.isExpressionStatement() && (!
|
|
201
|
+
if (statement?.isExpressionStatement() && (!t2.isAssignmentExpression(statement.node.expression) || !t2.isMemberExpression(statement.node.expression.left) || !t2.isIdentifier(statement.node.expression.left.object, { name: "module" }) || !t2.isIdentifier(statement.node.expression.left.property, { name: "exports" }))) {
|
|
101
202
|
reject(
|
|
102
203
|
root.node,
|
|
103
204
|
"ambiguous-binding",
|
|
@@ -113,7 +214,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
113
214
|
);
|
|
114
215
|
return;
|
|
115
216
|
}
|
|
116
|
-
if (declaration?.isVariableDeclarator() &&
|
|
217
|
+
if (declaration?.isVariableDeclarator() && t2.isIdentifier(declaration.node.id)) {
|
|
117
218
|
let binding = declaration.scope.getBinding(declaration.node.id.name);
|
|
118
219
|
if (!binding?.constant || binding.referencePaths.length !== 1 || !binding.referencePaths.every(isExportReference)) {
|
|
119
220
|
reject(
|
|
@@ -125,7 +226,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
125
226
|
}
|
|
126
227
|
}
|
|
127
228
|
if (assignments.length > 1 || assignments.some(
|
|
128
|
-
(assignment) => assignment.scope.hasBinding("module") ||
|
|
229
|
+
(assignment) => assignment.scope.hasBinding("module") || t2.isMemberExpression(assignment.node.left) && assignment.node.left.computed || !assignment.parentPath.parentPath?.isProgram()
|
|
129
230
|
)) {
|
|
130
231
|
reject(
|
|
131
232
|
root.node,
|
|
@@ -148,7 +249,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
148
249
|
);
|
|
149
250
|
return;
|
|
150
251
|
}
|
|
151
|
-
let named = /* @__PURE__ */ new Map(), virtualRoot =
|
|
252
|
+
let named = /* @__PURE__ */ new Map(), virtualRoot = t2.objectExpression([]), seen = /* @__PURE__ */ new Set();
|
|
152
253
|
for (let statement of program.get("body"))
|
|
153
254
|
if (!(statement.isExportNamedDeclaration() && statement.node.exportKind === "type")) {
|
|
154
255
|
if (statement.isExportAllDeclaration() || statement.isExportNamedDeclaration() && statement.node.source) {
|
|
@@ -163,7 +264,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
163
264
|
for (let specifier of statement.get("specifiers")) {
|
|
164
265
|
if (!specifier.isExportSpecifier() || specifier.node.exportKind === "type")
|
|
165
266
|
continue;
|
|
166
|
-
let name =
|
|
267
|
+
let name = t2.isIdentifier(specifier.node.exported) ? specifier.node.exported.name : specifier.node.exported.value;
|
|
167
268
|
if (!Object.hasOwn(config._exportDecls, name)) {
|
|
168
269
|
reject(
|
|
169
270
|
specifier.node,
|
|
@@ -176,7 +277,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
176
277
|
}
|
|
177
278
|
for (let [name, node] of Object.entries(config._exportDecls)) {
|
|
178
279
|
let declaration = pathForNode(program, node);
|
|
179
|
-
if (!(declaration?.isVariableDeclarator() || declaration?.isFunctionDeclaration()) || !
|
|
280
|
+
if (!(declaration?.isVariableDeclarator() || declaration?.isFunctionDeclaration()) || !t2.isIdentifier(declaration.node.id)) {
|
|
180
281
|
reject(
|
|
181
282
|
node,
|
|
182
283
|
"unsupported-initializer",
|
|
@@ -196,8 +297,8 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
196
297
|
seen.add(node);
|
|
197
298
|
let specifier = binding.referencePaths.find(
|
|
198
299
|
(path) => path.parentPath?.isExportSpecifier()
|
|
199
|
-
)?.parentPath, value = declaration.isFunctionDeclaration() ?
|
|
200
|
-
if (!
|
|
300
|
+
)?.parentPath, value = declaration.isFunctionDeclaration() ? t2.toExpression(t2.cloneNode(declaration.node)) : declaration.node.init;
|
|
301
|
+
if (!t2.isExpression(value)) {
|
|
201
302
|
reject(
|
|
202
303
|
node,
|
|
203
304
|
"unsupported-initializer",
|
|
@@ -205,7 +306,7 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
205
306
|
);
|
|
206
307
|
return;
|
|
207
308
|
}
|
|
208
|
-
let property =
|
|
309
|
+
let property = t2.objectProperty(t2.stringLiteral(name), value);
|
|
209
310
|
virtualRoot.properties.push(property), named.set(property, {
|
|
210
311
|
declaration,
|
|
211
312
|
...specifier?.isExportSpecifier() ? { specifier } : {}
|
|
@@ -215,15 +316,15 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
215
316
|
for (let [property, entry] of named)
|
|
216
317
|
virtualRoot.properties.includes(property) || (entry.specifier ? entry.specifier.remove() : entry.declaration.remove(), named.delete(property));
|
|
217
318
|
for (let property of virtualRoot.properties) {
|
|
218
|
-
if (!
|
|
319
|
+
if (!t2.isObjectProperty(property) || !t2.isExpression(property.value))
|
|
219
320
|
continue;
|
|
220
|
-
let name =
|
|
321
|
+
let name = t2.isIdentifier(property.key) ? property.key.name : t2.isStringLiteral(property.key) ? property.key.value : void 0;
|
|
221
322
|
if (name === void 0)
|
|
222
323
|
continue;
|
|
223
324
|
let entry = named.get(property);
|
|
224
325
|
if (entry) {
|
|
225
326
|
if (entry.declaration.isFunctionDeclaration())
|
|
226
|
-
if (
|
|
327
|
+
if (t2.isFunctionExpression(property.value) && (!property.value.id || property.value.id.name === entry.declaration.node.id?.name)) {
|
|
227
328
|
let { params, body, async, generator, returnType, typeParameters } = property.value;
|
|
228
329
|
Object.assign(entry.declaration.node, {
|
|
229
330
|
params,
|
|
@@ -237,31 +338,31 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
237
338
|
let id2 = entry.declaration.node.id;
|
|
238
339
|
if (!id2)
|
|
239
340
|
continue;
|
|
240
|
-
let variable2 =
|
|
241
|
-
entry.declaration.replaceWith(
|
|
341
|
+
let variable2 = t2.variableDeclarator(id2, property.value);
|
|
342
|
+
entry.declaration.replaceWith(t2.variableDeclaration("const", [variable2]));
|
|
242
343
|
let path = pathForNode(program, variable2);
|
|
243
344
|
path && (entry.declaration = path);
|
|
244
345
|
}
|
|
245
346
|
else entry.declaration.isVariableDeclarator() && (entry.declaration.node.init = property.value);
|
|
246
347
|
if (entry.specifier) {
|
|
247
|
-
entry.specifier.node.exported =
|
|
348
|
+
entry.specifier.node.exported = t2.isValidIdentifier(name) ? t2.identifier(name) : t2.stringLiteral(name);
|
|
248
349
|
continue;
|
|
249
350
|
}
|
|
250
|
-
if (
|
|
251
|
-
entry.declaration.node.id =
|
|
351
|
+
if (t2.isValidIdentifier(name) && (t2.isIdentifier(entry.declaration.node.id, { name }) || !program.scope.hasBinding(name))) {
|
|
352
|
+
entry.declaration.node.id = t2.identifier(name);
|
|
252
353
|
continue;
|
|
253
354
|
}
|
|
254
355
|
entry.declaration.remove();
|
|
255
356
|
}
|
|
256
|
-
let id =
|
|
357
|
+
let id = t2.isValidIdentifier(name) && !program.scope.hasBinding(name) ? t2.identifier(name) : program.scope.generateUidIdentifier(name), declaration = t2.variableDeclarator(id, property.value), variable = t2.variableDeclaration("const", [declaration]);
|
|
257
358
|
if (id.name === name)
|
|
258
|
-
program.pushContainer("body",
|
|
359
|
+
program.pushContainer("body", t2.exportNamedDeclaration(variable));
|
|
259
360
|
else {
|
|
260
|
-
let specifier =
|
|
361
|
+
let specifier = t2.exportSpecifier(
|
|
261
362
|
id,
|
|
262
|
-
|
|
363
|
+
t2.isValidIdentifier(name) ? t2.identifier(name) : t2.stringLiteral(name)
|
|
263
364
|
);
|
|
264
|
-
program.pushContainer("body", [variable,
|
|
365
|
+
program.pushContainer("body", [variable, t2.exportNamedDeclaration(null, [specifier])]);
|
|
265
366
|
}
|
|
266
367
|
let declarationPath = pathForNode(program, declaration);
|
|
267
368
|
if (declarationPath) {
|
|
@@ -295,52 +396,103 @@ function createConfigObject(config, mode, report, markChanged) {
|
|
|
295
396
|
}), result;
|
|
296
397
|
}
|
|
297
398
|
|
|
298
|
-
// src/csf-tools/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
399
|
+
// src/csf-tools/configFileCallArguments.ts
|
|
400
|
+
import { types as t3, traverse as traverse2 } from "@aussieljk/forkbook/internal/babel";
|
|
401
|
+
var findCallArguments = (ast, { importedName, methodName, moduleNames }, report, markChanged) => {
|
|
402
|
+
let modules = new Set(moduleNames), imports = /* @__PURE__ */ new Map();
|
|
403
|
+
traverse2(ast, {
|
|
404
|
+
ImportDeclaration(path) {
|
|
405
|
+
if (!(!modules.has(path.node.source.value) || path.node.importKind === "type")) {
|
|
406
|
+
for (let specifier of path.node.specifiers)
|
|
407
|
+
if (t3.isImportSpecifier(specifier) && specifier.importKind !== "type" && t3.isIdentifier(specifier.imported, { name: importedName })) {
|
|
408
|
+
let bindingNodes = imports.get(specifier.local.name) ?? /* @__PURE__ */ new Set();
|
|
409
|
+
bindingNodes.add(specifier), imports.set(specifier.local.name, bindingNodes);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
VariableDeclarator(path) {
|
|
414
|
+
let { id, init } = path.node;
|
|
415
|
+
if (!(!t3.isObjectPattern(id) || !t3.isCallExpression(init) || !t3.isIdentifier(init.callee, { name: "require" }) || path.scope.getBinding("require") !== void 0 || init.arguments.length !== 1 || !t3.isStringLiteral(init.arguments[0]) || !modules.has(init.arguments[0].value))) {
|
|
416
|
+
for (let property of id.properties)
|
|
417
|
+
if (t3.isObjectProperty(property) && !property.computed && (t3.isIdentifier(property.key) && property.key.name === importedName || t3.isStringLiteral(property.key) && property.key.value === importedName) && t3.isIdentifier(property.value)) {
|
|
418
|
+
let bindingNodes = imports.get(property.value.name) ?? /* @__PURE__ */ new Set();
|
|
419
|
+
bindingNodes.add(path.node), imports.set(property.value.name, bindingNodes);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
let objects = [];
|
|
425
|
+
return traverse2(ast, {
|
|
426
|
+
CallExpression(path) {
|
|
427
|
+
let { callee } = path.node;
|
|
428
|
+
if (!t3.isMemberExpression(callee) || !t3.isIdentifier(callee.object) || !(t3.isIdentifier(callee.property) && !callee.computed && callee.property.name === methodName || t3.isStringLiteral(callee.property) && callee.property.value === methodName))
|
|
429
|
+
return;
|
|
430
|
+
let bindingNode = path.scope.getBinding(callee.object.name)?.path.node;
|
|
431
|
+
if (bindingNode && imports.get(callee.object.name)?.has(bindingNode)) {
|
|
432
|
+
let argument = path.node.arguments[0];
|
|
433
|
+
if (!argument)
|
|
434
|
+
return;
|
|
435
|
+
let value = unwrapExpression(argument), target = { kind: "call-argument", importedName, methodName }, binding = path.scope.getBinding(callee.object.name);
|
|
436
|
+
if (!binding?.constant || !t3.isObjectExpression(value)) {
|
|
437
|
+
report({
|
|
438
|
+
code: binding?.constant ? "unsupported-initializer" : "ambiguous-binding",
|
|
439
|
+
target,
|
|
440
|
+
path: [],
|
|
441
|
+
message: binding?.constant ? "the call argument is not an object literal" : "the imported binding is reassigned",
|
|
442
|
+
...argument.loc ? { loc: argument.loc } : {}
|
|
443
|
+
});
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
objects.push(
|
|
447
|
+
createCsfObject(
|
|
448
|
+
target,
|
|
449
|
+
{
|
|
450
|
+
node: value,
|
|
451
|
+
scope: path.scope,
|
|
452
|
+
buildCodeFrameError: path.buildCodeFrameError.bind(path)
|
|
453
|
+
},
|
|
454
|
+
[],
|
|
455
|
+
report,
|
|
456
|
+
markChanged
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}), objects;
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// src/csf-tools/configFilePaths.ts
|
|
465
|
+
import { types as t4 } from "@aussieljk/forkbook/internal/babel";
|
|
466
|
+
var propKey = (p) => t4.isIdentifier(p.key) ? p.key.name : t4.isStringLiteral(p.key) ? p.key.value : null, getPath = (path, node) => {
|
|
307
467
|
if (path.length === 0)
|
|
308
468
|
return node;
|
|
309
|
-
if (
|
|
469
|
+
if (t4.isObjectExpression(node)) {
|
|
310
470
|
let [first, ...rest] = path, field = node.properties.find((p) => propKey(p) === first);
|
|
311
471
|
if (field)
|
|
312
|
-
return
|
|
472
|
+
return getPath(rest, field.value);
|
|
313
473
|
}
|
|
314
|
-
},
|
|
474
|
+
}, getPathProperties = (path, node) => {
|
|
315
475
|
if (path.length === 0) {
|
|
316
|
-
if (
|
|
476
|
+
if (t4.isObjectExpression(node))
|
|
317
477
|
return node.properties;
|
|
318
478
|
throw new Error("Expected object expression");
|
|
319
479
|
}
|
|
320
|
-
if (
|
|
480
|
+
if (t4.isObjectExpression(node)) {
|
|
321
481
|
let [first, ...rest] = path, field = node.properties.find((p) => propKey(p) === first);
|
|
322
482
|
if (field)
|
|
323
|
-
return rest.length === 0 ? node.properties :
|
|
483
|
+
return rest.length === 0 ? node.properties : getPathProperties(rest, field.value);
|
|
324
484
|
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
let firstNonImport = program.body.findIndex((node) => !t2.isImportDeclaration(node)), index = firstNonImport === -1 ? program.body.length : firstNonImport;
|
|
338
|
-
if (index === 0) {
|
|
339
|
-
let notHeader = (comment) => !header.includes(comment);
|
|
340
|
-
first.comments = first.comments?.filter(notHeader), first.leadingComments = first.leadingComments?.filter(notHeader), Object.assign(statement, { comments: header, leadingComments: header });
|
|
341
|
-
}
|
|
342
|
-
program.body.splice(index, 0, statement);
|
|
343
|
-
}, ConfigFile = class {
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/csf-tools/ConfigFile.ts
|
|
488
|
+
var getCsfParsingErrorMessage = ({
|
|
489
|
+
fileName,
|
|
490
|
+
expectedType,
|
|
491
|
+
foundType,
|
|
492
|
+
node
|
|
493
|
+
}) => dedent`
|
|
494
|
+
CSF Parsing error in ${fileName ?? "a config file"}: Expected '${expectedType}' but found '${foundType}' instead in '${node?.type}'.
|
|
495
|
+
`, ConfigFile = class {
|
|
344
496
|
constructor(ast, code, fileName) {
|
|
345
497
|
/**
|
|
346
498
|
* Identify the config, meta, story, annotation, or call argument this editor represents.
|
|
@@ -363,15 +515,18 @@ var getCsfParsingErrorMessage = ({
|
|
|
363
515
|
this._exportDecls = {};
|
|
364
516
|
this.hasDefaultExport = !1;
|
|
365
517
|
/** Unwraps TS assertions/satisfies from a node, to get the underlying node. */
|
|
366
|
-
this._unwrap = (node) =>
|
|
518
|
+
this._unwrap = (node) => t5.isTSAsExpression(node) || t5.isTSSatisfiesExpression(node) ? this._unwrap(node.expression) : node;
|
|
367
519
|
/**
|
|
368
520
|
* Resolve a declaration node by unwrapping TS assertions/satisfies and following identifiers to
|
|
369
521
|
* resolve the correct node in case it's an identifier.
|
|
522
|
+
*
|
|
523
|
+
* The result is typed as an expression, because callers keep it as an export value. A default
|
|
524
|
+
* export can also be a function or class declaration, which callers check for.
|
|
370
525
|
*/
|
|
371
526
|
this._resolveDeclaration = (node, parent = this._ast.program) => {
|
|
372
527
|
let decl = this._unwrap(node);
|
|
373
|
-
if (
|
|
374
|
-
let initialization =
|
|
528
|
+
if (t5.isIdentifier(decl) && t5.isProgram(parent)) {
|
|
529
|
+
let initialization = findVarInitialization(decl.name, parent);
|
|
375
530
|
return initialization ? this._unwrap(initialization) : decl;
|
|
376
531
|
}
|
|
377
532
|
return decl;
|
|
@@ -555,20 +710,20 @@ var getCsfParsingErrorMessage = ({
|
|
|
555
710
|
parse() {
|
|
556
711
|
this._inferQuotes();
|
|
557
712
|
let self = this;
|
|
558
|
-
return
|
|
713
|
+
return traverse3(this._ast, {
|
|
559
714
|
ExportDefaultDeclaration: {
|
|
560
715
|
enter({ node, parent }) {
|
|
561
716
|
self.hasDefaultExport = !0;
|
|
562
717
|
let decl = self._resolveDeclaration(node.declaration, parent);
|
|
563
|
-
for (;
|
|
564
|
-
if (
|
|
718
|
+
for (; t5.isCallExpression(decl); )
|
|
719
|
+
if (t5.isObjectExpression(decl.arguments[0])) {
|
|
565
720
|
decl = decl.arguments[0];
|
|
566
721
|
break;
|
|
567
|
-
} else if (
|
|
722
|
+
} else if (t5.isMemberExpression(decl.callee) && t5.isCallExpression(decl.callee.object))
|
|
568
723
|
decl = decl.callee.object;
|
|
569
724
|
else
|
|
570
725
|
break;
|
|
571
|
-
|
|
726
|
+
t5.isObjectExpression(decl) ? self._parseExportsObject(decl) : logger.debug(
|
|
572
727
|
getCsfParsingErrorMessage({
|
|
573
728
|
fileName: self.fileName,
|
|
574
729
|
expectedType: "ObjectExpression",
|
|
@@ -580,27 +735,27 @@ var getCsfParsingErrorMessage = ({
|
|
|
580
735
|
},
|
|
581
736
|
ExportNamedDeclaration: {
|
|
582
737
|
enter({ node, parent }) {
|
|
583
|
-
if (
|
|
738
|
+
if (t5.isVariableDeclaration(node.declaration))
|
|
584
739
|
node.declaration.declarations.forEach((decl) => {
|
|
585
|
-
if (
|
|
740
|
+
if (t5.isVariableDeclarator(decl) && t5.isIdentifier(decl.id)) {
|
|
586
741
|
let { name: exportName } = decl.id, exportVal = self._resolveDeclaration(decl.init, parent);
|
|
587
742
|
self._exports[exportName] = exportVal, self._exportDecls[exportName] = decl;
|
|
588
743
|
}
|
|
589
744
|
});
|
|
590
|
-
else if (
|
|
745
|
+
else if (t5.isFunctionDeclaration(node.declaration)) {
|
|
591
746
|
let decl = node.declaration;
|
|
592
|
-
if (
|
|
747
|
+
if (t5.isIdentifier(decl.id)) {
|
|
593
748
|
let { name: exportName } = decl.id;
|
|
594
|
-
self._exportDecls[exportName] = decl, self._exports[exportName] =
|
|
749
|
+
self._exportDecls[exportName] = decl, self._exports[exportName] = t5.toExpression(t5.cloneNode(decl));
|
|
595
750
|
}
|
|
596
751
|
} else node.specifiers ? node.specifiers.forEach((spec) => {
|
|
597
|
-
if (
|
|
598
|
-
let { name: localName } = spec.local, exportName =
|
|
599
|
-
(statement) =>
|
|
752
|
+
if (t5.isExportSpecifier(spec) && t5.isIdentifier(spec.local) && (t5.isIdentifier(spec.exported) || t5.isStringLiteral(spec.exported))) {
|
|
753
|
+
let { name: localName } = spec.local, exportName = t5.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value, decl = findVarDeclarator(localName, self._ast.program) ?? self._ast.program.body.find(
|
|
754
|
+
(statement) => t5.isFunctionDeclaration(statement) && statement.id?.name === localName
|
|
600
755
|
);
|
|
601
756
|
if (decl) {
|
|
602
|
-
let value =
|
|
603
|
-
if (exportName === "default" &&
|
|
757
|
+
let value = t5.isFunctionDeclaration(decl) ? t5.toExpression(t5.cloneNode(decl)) : decl.init ? self._resolveDeclaration(decl.init, parent) : void 0;
|
|
758
|
+
if (exportName === "default" && t5.isObjectExpression(value)) {
|
|
604
759
|
self.hasDefaultExport = !0, self._parseExportsObject(value);
|
|
605
760
|
return;
|
|
606
761
|
}
|
|
@@ -619,11 +774,11 @@ var getCsfParsingErrorMessage = ({
|
|
|
619
774
|
},
|
|
620
775
|
ExpressionStatement: {
|
|
621
776
|
enter({ node, parent }) {
|
|
622
|
-
if (
|
|
777
|
+
if (t5.isAssignmentExpression(node.expression) && node.expression.operator === "=") {
|
|
623
778
|
let { left, right } = node.expression;
|
|
624
|
-
if (
|
|
779
|
+
if (t5.isMemberExpression(left) && t5.isIdentifier(left.object) && left.object.name === "module" && t5.isIdentifier(left.property) && left.property.name === "exports") {
|
|
625
780
|
let exportObject = right;
|
|
626
|
-
exportObject = self._resolveDeclaration(exportObject, parent),
|
|
781
|
+
exportObject = self._resolveDeclaration(exportObject, parent), t5.isObjectExpression(exportObject) ? (self._exportsObject = exportObject, exportObject.properties.forEach((p) => {
|
|
627
782
|
let exportName = propKey(p);
|
|
628
783
|
if (exportName) {
|
|
629
784
|
let exportVal = self._resolveDeclaration(p.value, parent);
|
|
@@ -643,7 +798,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
643
798
|
},
|
|
644
799
|
CallExpression: {
|
|
645
800
|
enter: ({ node }) => {
|
|
646
|
-
|
|
801
|
+
t5.isIdentifier(node.callee) && node.callee.name === "definePreview" && node.arguments.length === 1 && t5.isObjectExpression(node.arguments[0]) && self._parseExportsObject(node.arguments[0]);
|
|
647
802
|
}
|
|
648
803
|
}
|
|
649
804
|
}), self;
|
|
@@ -651,12 +806,12 @@ var getCsfParsingErrorMessage = ({
|
|
|
651
806
|
getFieldNode(path) {
|
|
652
807
|
let [root, ...rest] = path, exported = this._exports[root];
|
|
653
808
|
if (exported)
|
|
654
|
-
return
|
|
809
|
+
return getPath(rest, exported);
|
|
655
810
|
}
|
|
656
811
|
getFieldProperties(path) {
|
|
657
812
|
let [root, ...rest] = path, exported = this._exports[root];
|
|
658
813
|
if (exported)
|
|
659
|
-
return
|
|
814
|
+
return getPathProperties(rest, exported);
|
|
660
815
|
}
|
|
661
816
|
/**
|
|
662
817
|
* @example
|
|
@@ -692,14 +847,14 @@ var getCsfParsingErrorMessage = ({
|
|
|
692
847
|
if (!node)
|
|
693
848
|
return;
|
|
694
849
|
let pathNames = [];
|
|
695
|
-
return
|
|
850
|
+
return t5.isArrayExpression(node) && node.elements.forEach((element) => {
|
|
696
851
|
pathNames.push(this._getPresetValue(element, "name"));
|
|
697
852
|
}), pathNames;
|
|
698
853
|
}
|
|
699
854
|
_getWrappedValue(node) {
|
|
700
|
-
if (
|
|
855
|
+
if (t5.isCallExpression(node)) {
|
|
701
856
|
let arg = node.arguments[0];
|
|
702
|
-
if (
|
|
857
|
+
if (t5.isStringLiteral(arg))
|
|
703
858
|
return arg.value;
|
|
704
859
|
}
|
|
705
860
|
}
|
|
@@ -711,9 +866,9 @@ var getCsfParsingErrorMessage = ({
|
|
|
711
866
|
*/
|
|
712
867
|
_getPresetValue(node, fallbackProperty) {
|
|
713
868
|
let value;
|
|
714
|
-
if (
|
|
715
|
-
|
|
716
|
-
}) :
|
|
869
|
+
if (t5.isStringLiteral(node) ? value = node.value : t5.isObjectExpression(node) ? node.properties.forEach((prop) => {
|
|
870
|
+
t5.isObjectProperty(prop) && t5.isIdentifier(prop.key) && prop.key.name === fallbackProperty && (t5.isStringLiteral(prop.value) ? value = prop.value.value : value = this._getWrappedValue(prop.value)), t5.isObjectProperty(prop) && t5.isStringLiteral(prop.key) && prop.key.value === "name" && t5.isStringLiteral(prop.value) && (value = prop.value.value);
|
|
871
|
+
}) : t5.isCallExpression(node) && (value = this._getWrappedValue(node)), !value)
|
|
717
872
|
throw new Error(
|
|
718
873
|
`The given node must be a string literal or an object expression with a "${fallbackProperty}" property that is a string literal.`
|
|
719
874
|
);
|
|
@@ -722,25 +877,25 @@ var getCsfParsingErrorMessage = ({
|
|
|
722
877
|
removeField(path) {
|
|
723
878
|
let removeProperty = (properties2, prop) => {
|
|
724
879
|
let index = properties2.findIndex(
|
|
725
|
-
(p) =>
|
|
880
|
+
(p) => t5.isIdentifier(p.key) && p.key.name === prop || t5.isStringLiteral(p.key) && p.key.value === prop
|
|
726
881
|
);
|
|
727
882
|
index >= 0 && properties2.splice(index, 1);
|
|
728
883
|
};
|
|
729
884
|
if (path.length === 1) {
|
|
730
885
|
let removedRootProperty = !1;
|
|
731
886
|
if (this._ast.program.body.forEach((node) => {
|
|
732
|
-
if (
|
|
887
|
+
if (t5.isExportNamedDeclaration(node) && t5.isVariableDeclaration(node.declaration)) {
|
|
733
888
|
let decl = node.declaration.declarations[0];
|
|
734
|
-
|
|
889
|
+
t5.isIdentifier(decl.id) && decl.id.name === path[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(node), 1), removedRootProperty = !0);
|
|
735
890
|
}
|
|
736
|
-
if (
|
|
891
|
+
if (t5.isExportDefaultDeclaration(node)) {
|
|
737
892
|
let resolved = this._resolveDeclaration(node.declaration);
|
|
738
|
-
if (
|
|
893
|
+
if (t5.isObjectExpression(resolved)) {
|
|
739
894
|
let properties2 = resolved.properties;
|
|
740
895
|
removeProperty(properties2, path[0]), removedRootProperty = !0;
|
|
741
896
|
}
|
|
742
897
|
}
|
|
743
|
-
if (
|
|
898
|
+
if (t5.isExpressionStatement(node) && t5.isAssignmentExpression(node.expression) && t5.isMemberExpression(node.expression.left) && t5.isIdentifier(node.expression.left.object) && node.expression.left.object.name === "module" && t5.isIdentifier(node.expression.left.property) && node.expression.left.property.name === "exports" && t5.isObjectExpression(node.expression.right)) {
|
|
744
899
|
let properties2 = node.expression.right.properties;
|
|
745
900
|
removeProperty(properties2, path[0]), removedRootProperty = !0;
|
|
746
901
|
}
|
|
@@ -760,8 +915,8 @@ var getCsfParsingErrorMessage = ({
|
|
|
760
915
|
appendNodeToArray(path, node) {
|
|
761
916
|
let current = this.getFieldNode(path);
|
|
762
917
|
if (!current)
|
|
763
|
-
this.set(path,
|
|
764
|
-
else if (
|
|
918
|
+
this.set(path, t5.arrayExpression([node]));
|
|
919
|
+
else if (t5.isArrayExpression(current))
|
|
765
920
|
current.elements.push(node);
|
|
766
921
|
else
|
|
767
922
|
throw new Error(`Expected array at '${path.join(".")}', got '${current.type}'`);
|
|
@@ -773,8 +928,8 @@ var getCsfParsingErrorMessage = ({
|
|
|
773
928
|
removeEntryFromArray(path, value) {
|
|
774
929
|
let current = this.getFieldNode(path);
|
|
775
930
|
if (current)
|
|
776
|
-
if (
|
|
777
|
-
let index = current.elements.findIndex((element) =>
|
|
931
|
+
if (t5.isArrayExpression(current)) {
|
|
932
|
+
let index = current.elements.findIndex((element) => t5.isStringLiteral(element) ? element.value === value : t5.isObjectExpression(element) ? this._getPresetValue(element, "name") === value : this._getWrappedValue(element) === value);
|
|
778
933
|
if (index >= 0)
|
|
779
934
|
current.elements.splice(index, 1);
|
|
780
935
|
else
|
|
@@ -788,7 +943,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
788
943
|
let raw = node.extra?.raw;
|
|
789
944
|
typeof raw == "string" && (raw[0] === "'" || raw[0] === '"') && (occurrences[raw[0]] += 1);
|
|
790
945
|
};
|
|
791
|
-
|
|
946
|
+
traverse3(this._ast, {
|
|
792
947
|
StringLiteral: { enter: countQuotes },
|
|
793
948
|
DirectiveLiteral: { enter: countQuotes }
|
|
794
949
|
}), this._quotes = occurrences["'"] > occurrences['"'] ? "single" : "double";
|
|
@@ -798,16 +953,16 @@ var getCsfParsingErrorMessage = ({
|
|
|
798
953
|
valueToNode(value) {
|
|
799
954
|
let quotes = this._inferQuotes(), valueNode;
|
|
800
955
|
if (quotes === "single") {
|
|
801
|
-
let { code } = generate(
|
|
802
|
-
|
|
956
|
+
let { code } = generate(t5.valueToNode(value), { jsescOption: { quotes } }), program = babelParse(`const __x = ${code}`);
|
|
957
|
+
traverse3(program, {
|
|
803
958
|
VariableDeclaration: {
|
|
804
959
|
enter({ node }) {
|
|
805
|
-
node.declarations.length === 1 &&
|
|
960
|
+
node.declarations.length === 1 && t5.isVariableDeclarator(node.declarations[0]) && t5.isIdentifier(node.declarations[0].id) && node.declarations[0].id.name === "__x" && (valueNode = node.declarations[0].init);
|
|
806
961
|
}
|
|
807
962
|
}
|
|
808
963
|
});
|
|
809
964
|
} else
|
|
810
|
-
valueNode =
|
|
965
|
+
valueNode = t5.valueToNode(value);
|
|
811
966
|
return valueNode;
|
|
812
967
|
}
|
|
813
968
|
getBodyDeclarations() {
|
|
@@ -833,73 +988,15 @@ var getCsfParsingErrorMessage = ({
|
|
|
833
988
|
* manager.changed; // true
|
|
834
989
|
* ```
|
|
835
990
|
*/
|
|
836
|
-
callArguments({
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
ImportDeclaration(path) {
|
|
844
|
-
if (!(!modules.has(path.node.source.value) || path.node.importKind === "type")) {
|
|
845
|
-
for (let specifier of path.node.specifiers)
|
|
846
|
-
if (t2.isImportSpecifier(specifier) && specifier.importKind !== "type" && t2.isIdentifier(specifier.imported, { name: importedName })) {
|
|
847
|
-
let bindingNodes = imports.get(specifier.local.name) ?? /* @__PURE__ */ new Set();
|
|
848
|
-
bindingNodes.add(specifier), imports.set(specifier.local.name, bindingNodes);
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
},
|
|
852
|
-
VariableDeclarator(path) {
|
|
853
|
-
let { id, init } = path.node;
|
|
854
|
-
if (!(!t2.isObjectPattern(id) || !t2.isCallExpression(init) || !t2.isIdentifier(init.callee, { name: "require" }) || path.scope.getBinding("require") !== void 0 || init.arguments.length !== 1 || !t2.isStringLiteral(init.arguments[0]) || !modules.has(init.arguments[0].value))) {
|
|
855
|
-
for (let property of id.properties)
|
|
856
|
-
if (t2.isObjectProperty(property) && !property.computed && (t2.isIdentifier(property.key) && property.key.name === importedName || t2.isStringLiteral(property.key) && property.key.value === importedName) && t2.isIdentifier(property.value)) {
|
|
857
|
-
let bindingNodes = imports.get(property.value.name) ?? /* @__PURE__ */ new Set();
|
|
858
|
-
bindingNodes.add(path.node), imports.set(property.value.name, bindingNodes);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
let objects = [], report = (diagnostic) => this._mutationDiagnostics.push(diagnostic), markChanged = () => {
|
|
864
|
-
this._changed = !0;
|
|
865
|
-
};
|
|
866
|
-
return traverse2(this._ast, {
|
|
867
|
-
CallExpression(path) {
|
|
868
|
-
let { callee } = path.node;
|
|
869
|
-
if (!t2.isMemberExpression(callee) || !t2.isIdentifier(callee.object) || !(t2.isIdentifier(callee.property) && !callee.computed && callee.property.name === methodName || t2.isStringLiteral(callee.property) && callee.property.value === methodName))
|
|
870
|
-
return;
|
|
871
|
-
let bindingNode = path.scope.getBinding(callee.object.name)?.path.node;
|
|
872
|
-
if (bindingNode && imports.get(callee.object.name)?.has(bindingNode)) {
|
|
873
|
-
let argument = path.node.arguments[0];
|
|
874
|
-
if (!argument)
|
|
875
|
-
return;
|
|
876
|
-
let value = unwrapExpression(argument), target = { kind: "call-argument", importedName, methodName }, binding = path.scope.getBinding(callee.object.name);
|
|
877
|
-
if (!binding?.constant || !t2.isObjectExpression(value)) {
|
|
878
|
-
report({
|
|
879
|
-
code: binding?.constant ? "unsupported-initializer" : "ambiguous-binding",
|
|
880
|
-
target,
|
|
881
|
-
path: [],
|
|
882
|
-
message: binding?.constant ? "the call argument is not an object literal" : "the imported binding is reassigned",
|
|
883
|
-
...argument.loc ? { loc: argument.loc } : {}
|
|
884
|
-
});
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
objects.push(
|
|
888
|
-
createCsfObject(
|
|
889
|
-
target,
|
|
890
|
-
{
|
|
891
|
-
node: value,
|
|
892
|
-
scope: path.scope,
|
|
893
|
-
buildCodeFrameError: path.buildCodeFrameError.bind(path)
|
|
894
|
-
},
|
|
895
|
-
[],
|
|
896
|
-
report,
|
|
897
|
-
markChanged
|
|
898
|
-
)
|
|
899
|
-
);
|
|
900
|
-
}
|
|
991
|
+
callArguments(options) {
|
|
992
|
+
return findCallArguments(
|
|
993
|
+
this._ast,
|
|
994
|
+
options,
|
|
995
|
+
(diagnostic) => this._mutationDiagnostics.push(diagnostic),
|
|
996
|
+
() => {
|
|
997
|
+
this._changed = !0;
|
|
901
998
|
}
|
|
902
|
-
|
|
999
|
+
);
|
|
903
1000
|
}
|
|
904
1001
|
setBodyDeclaration(declaration) {
|
|
905
1002
|
this._ast.program.body.push(declaration);
|
|
@@ -922,42 +1019,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
922
1019
|
* @param fromImport - The module to import from
|
|
923
1020
|
*/
|
|
924
1021
|
setRequireImport(importSpecifier, fromImport) {
|
|
925
|
-
|
|
926
|
-
let hasDeclaration = t2.isVariableDeclaration(node) && node.declarations.length === 1 && t2.isVariableDeclarator(node.declarations[0]) && t2.isCallExpression(node.declarations[0].init) && t2.isIdentifier(node.declarations[0].init.callee) && node.declarations[0].init.callee.name === "require" && t2.isStringLiteral(node.declarations[0].init.arguments[0]) && (node.declarations[0].init.arguments[0].value === fromImport || node.declarations[0].init.arguments[0].value === fromImport.split("node:")[1]);
|
|
927
|
-
return hasDeclaration && (fromImport = node.declarations[0].init.arguments[0].value), hasDeclaration;
|
|
928
|
-
}), hasRequireSpecifier = (name) => t2.isObjectPattern(requireDeclaration?.declarations[0].id) && requireDeclaration?.declarations[0].id.properties.find(
|
|
929
|
-
(specifier) => t2.isObjectProperty(specifier) && t2.isIdentifier(specifier.key) && specifier.key.name === name
|
|
930
|
-
), hasDefaultRequireSpecifier = (declaration, name) => declaration.declarations.length === 1 && t2.isVariableDeclarator(declaration.declarations[0]) && t2.isIdentifier(declaration.declarations[0].id) && declaration.declarations[0].id.name === name;
|
|
931
|
-
if (typeof importSpecifier == "string") {
|
|
932
|
-
let addDefaultRequireSpecifier = () => {
|
|
933
|
-
prependStatement(
|
|
934
|
-
this._ast.program,
|
|
935
|
-
t2.variableDeclaration("const", [
|
|
936
|
-
t2.variableDeclarator(
|
|
937
|
-
t2.identifier(importSpecifier),
|
|
938
|
-
t2.callExpression(t2.identifier("require"), [t2.stringLiteral(fromImport)])
|
|
939
|
-
)
|
|
940
|
-
])
|
|
941
|
-
);
|
|
942
|
-
};
|
|
943
|
-
requireDeclaration && hasDefaultRequireSpecifier(requireDeclaration, importSpecifier) || addDefaultRequireSpecifier();
|
|
944
|
-
} else requireDeclaration ? importSpecifier.forEach((specifier) => {
|
|
945
|
-
hasRequireSpecifier(specifier) || requireDeclaration.declarations[0].id.properties.push(
|
|
946
|
-
t2.objectProperty(t2.identifier(specifier), t2.identifier(specifier), void 0, !0)
|
|
947
|
-
);
|
|
948
|
-
}) : prependStatement(
|
|
949
|
-
this._ast.program,
|
|
950
|
-
t2.variableDeclaration("const", [
|
|
951
|
-
t2.variableDeclarator(
|
|
952
|
-
t2.objectPattern(
|
|
953
|
-
importSpecifier.map(
|
|
954
|
-
(specifier) => t2.objectProperty(t2.identifier(specifier), t2.identifier(specifier), void 0, !0)
|
|
955
|
-
)
|
|
956
|
-
),
|
|
957
|
-
t2.callExpression(t2.identifier("require"), [t2.stringLiteral(fromImport)])
|
|
958
|
-
)
|
|
959
|
-
])
|
|
960
|
-
);
|
|
1022
|
+
setRequireImport(this._ast.program, importSpecifier, fromImport);
|
|
961
1023
|
}
|
|
962
1024
|
/**
|
|
963
1025
|
* Set import specifiers for a given import statement.
|
|
@@ -985,92 +1047,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
985
1047
|
* @param fromImport - The module to import from
|
|
986
1048
|
*/
|
|
987
1049
|
setImport(importSpecifier, fromImport) {
|
|
988
|
-
|
|
989
|
-
let hasDeclaration = t2.isImportDeclaration(node) && (node.source.value === fromImport || node.source.value === fromImport.split("node:")[1]);
|
|
990
|
-
return hasDeclaration && (fromImport = node.source.value), hasDeclaration;
|
|
991
|
-
}), getNewImportSpecifier = (specifier) => t2.importSpecifier(t2.identifier(specifier), t2.identifier(specifier)), hasImportSpecifier = (declaration, name) => declaration.specifiers.find(
|
|
992
|
-
(specifier) => t2.isImportSpecifier(specifier) && t2.isIdentifier(specifier.imported) && specifier.imported.name === name
|
|
993
|
-
), hasNamespaceImportSpecifier = (declaration, name) => declaration.specifiers.find(
|
|
994
|
-
(specifier) => t2.isImportNamespaceSpecifier(specifier) && t2.isIdentifier(specifier.local) && specifier.local.name === name
|
|
995
|
-
);
|
|
996
|
-
importSpecifier === null ? importDeclaration || prependStatement(this._ast.program, t2.importDeclaration([], t2.stringLiteral(fromImport))) : typeof importSpecifier == "string" ? importDeclaration ? ((declaration, name) => declaration.specifiers.find(
|
|
997
|
-
(specifier) => t2.isImportDefaultSpecifier(specifier) && t2.isIdentifier(specifier.local) && specifier.local.name === name
|
|
998
|
-
))(importDeclaration, importSpecifier) || importDeclaration.specifiers.push(
|
|
999
|
-
t2.importDefaultSpecifier(t2.identifier(importSpecifier))
|
|
1000
|
-
) : prependStatement(
|
|
1001
|
-
this._ast.program,
|
|
1002
|
-
t2.importDeclaration(
|
|
1003
|
-
[t2.importDefaultSpecifier(t2.identifier(importSpecifier))],
|
|
1004
|
-
t2.stringLiteral(fromImport)
|
|
1005
|
-
)
|
|
1006
|
-
) : Array.isArray(importSpecifier) ? importDeclaration ? importSpecifier.forEach((specifier) => {
|
|
1007
|
-
hasImportSpecifier(importDeclaration, specifier) || importDeclaration.specifiers.push(getNewImportSpecifier(specifier));
|
|
1008
|
-
}) : prependStatement(
|
|
1009
|
-
this._ast.program,
|
|
1010
|
-
t2.importDeclaration(
|
|
1011
|
-
importSpecifier.map(getNewImportSpecifier),
|
|
1012
|
-
t2.stringLiteral(fromImport)
|
|
1013
|
-
)
|
|
1014
|
-
) : importSpecifier.namespace && (importDeclaration ? hasNamespaceImportSpecifier(importDeclaration, importSpecifier.namespace) || importDeclaration.specifiers.push(
|
|
1015
|
-
t2.importNamespaceSpecifier(t2.identifier(importSpecifier.namespace))
|
|
1016
|
-
) : prependStatement(
|
|
1017
|
-
this._ast.program,
|
|
1018
|
-
t2.importDeclaration(
|
|
1019
|
-
[t2.importNamespaceSpecifier(t2.identifier(importSpecifier.namespace))],
|
|
1020
|
-
t2.stringLiteral(fromImport)
|
|
1021
|
-
)
|
|
1022
|
-
));
|
|
1023
|
-
}
|
|
1024
|
-
_removeRequireImport(importSpecifier, fromImport) {
|
|
1025
|
-
let requireDeclarationIndex = this._ast.program.body.findIndex((node) => t2.isVariableDeclaration(node) && node.declarations.length === 1 && t2.isVariableDeclarator(node.declarations[0]) && t2.isCallExpression(node.declarations[0].init) && t2.isIdentifier(node.declarations[0].init.callee) && node.declarations[0].init.callee.name === "require" && t2.isStringLiteral(node.declarations[0].init.arguments[0]) && (node.declarations[0].init.arguments[0].value === fromImport || node.declarations[0].init.arguments[0].value === fromImport.split("node:")[1]));
|
|
1026
|
-
if (requireDeclarationIndex === -1)
|
|
1027
|
-
return;
|
|
1028
|
-
let declarator = this._ast.program.body[requireDeclarationIndex].declarations[0];
|
|
1029
|
-
if (importSpecifier !== null) {
|
|
1030
|
-
if (typeof importSpecifier == "string") {
|
|
1031
|
-
t2.isIdentifier(declarator.id) && declarator.id.name === importSpecifier && this._ast.program.body.splice(requireDeclarationIndex, 1);
|
|
1032
|
-
return;
|
|
1033
|
-
}
|
|
1034
|
-
if (!(typeof importSpecifier == "object" && "namespace" in importSpecifier) && Array.isArray(importSpecifier) && t2.isObjectPattern(declarator.id)) {
|
|
1035
|
-
let objectPattern = declarator.id;
|
|
1036
|
-
importSpecifier.forEach((specifier) => {
|
|
1037
|
-
let index = objectPattern.properties.findIndex(
|
|
1038
|
-
(prop) => t2.isObjectProperty(prop) && t2.isIdentifier(prop.key) && prop.key.name === specifier
|
|
1039
|
-
);
|
|
1040
|
-
index !== -1 && objectPattern.properties.splice(index, 1);
|
|
1041
|
-
}), objectPattern.properties.length === 0 && this._ast.program.body.splice(requireDeclarationIndex, 1);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
_removeImport(importSpecifier, fromImport) {
|
|
1046
|
-
let importDeclarationIndex = this._ast.program.body.findIndex(
|
|
1047
|
-
(node) => t2.isImportDeclaration(node) && (node.source.value === fromImport || node.source.value === fromImport.split("node:")[1])
|
|
1048
|
-
);
|
|
1049
|
-
if (importDeclarationIndex === -1)
|
|
1050
|
-
return;
|
|
1051
|
-
let importDeclaration = this._ast.program.body[importDeclarationIndex];
|
|
1052
|
-
if (importSpecifier === null) {
|
|
1053
|
-
importDeclaration.specifiers.length === 0 && this._ast.program.body.splice(importDeclarationIndex, 1);
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
if (typeof importSpecifier == "object" && "namespace" in importSpecifier) {
|
|
1057
|
-
let index = importDeclaration.specifiers.findIndex(
|
|
1058
|
-
(specifier) => t2.isImportNamespaceSpecifier(specifier) && t2.isIdentifier(specifier.local) && specifier.local.name === importSpecifier.namespace
|
|
1059
|
-
);
|
|
1060
|
-
index !== -1 && importDeclaration.specifiers.splice(index, 1);
|
|
1061
|
-
}
|
|
1062
|
-
if (typeof importSpecifier == "string") {
|
|
1063
|
-
let index = importDeclaration.specifiers.findIndex(
|
|
1064
|
-
(specifier) => t2.isImportDefaultSpecifier(specifier) && t2.isIdentifier(specifier.local) && specifier.local.name === importSpecifier
|
|
1065
|
-
);
|
|
1066
|
-
index !== -1 && importDeclaration.specifiers.splice(index, 1);
|
|
1067
|
-
}
|
|
1068
|
-
Array.isArray(importSpecifier) && importSpecifier.forEach((specifier) => {
|
|
1069
|
-
let index = importDeclaration.specifiers.findIndex(
|
|
1070
|
-
(current) => t2.isImportSpecifier(current) && t2.isIdentifier(current.imported) && current.imported.name === specifier
|
|
1071
|
-
);
|
|
1072
|
-
index !== -1 && importDeclaration.specifiers.splice(index, 1);
|
|
1073
|
-
}), importDeclaration.specifiers.length === 0 && this._ast.program.body.splice(importDeclarationIndex, 1);
|
|
1050
|
+
setImport(this._ast.program, importSpecifier, fromImport);
|
|
1074
1051
|
}
|
|
1075
1052
|
/**
|
|
1076
1053
|
* Remove import specifiers for a given import statement.
|
|
@@ -1098,7 +1075,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
1098
1075
|
* @param fromImport - The module to import from
|
|
1099
1076
|
*/
|
|
1100
1077
|
removeImport(importSpecifier, fromImport) {
|
|
1101
|
-
this.
|
|
1078
|
+
removeImport(this._ast.program, importSpecifier, fromImport);
|
|
1102
1079
|
}
|
|
1103
1080
|
}, loadConfig = (code, fileName) => {
|
|
1104
1081
|
let ast = babelParse(code);
|
|
@@ -1119,7 +1096,7 @@ var getCsfParsingErrorMessage = ({
|
|
|
1119
1096
|
if (!fname)
|
|
1120
1097
|
throw new Error("Please specify a fileName for writeConfig");
|
|
1121
1098
|
await writeFile(fname, formatConfig(config));
|
|
1122
|
-
}, isCsfFactoryPreview = (previewConfig) => !!previewConfig._ast.program.body.find((node) =>
|
|
1099
|
+
}, isCsfFactoryPreview = (previewConfig) => !!previewConfig._ast.program.body.find((node) => t5.isImportDeclaration(node) && (node.source.value.includes("storybook") || node.source.value.includes("forkbook")) && node.specifiers.some((specifier) => t5.isImportSpecifier(specifier) && t5.isIdentifier(specifier.imported) && specifier.imported.name === "definePreview"));
|
|
1123
1100
|
|
|
1124
1101
|
export {
|
|
1125
1102
|
getHeaderComments,
|