@farm.js/core 0.1.49 → 0.1.51-beta.0
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 +163 -3
- package/dist/{agent-mcp-Bb8hnnqd.d.ts → agent-mcp-BBMfNpsC.d.ts} +1 -1
- package/dist/{agent-mcp-ir3v4fHf.d.mts → agent-mcp-D44ip11f.d.mts} +1 -1
- package/dist/agent-runtime.cjs +3 -3
- package/dist/agent-runtime.d.mts +6 -6
- package/dist/agent-runtime.d.ts +6 -6
- package/dist/agent-runtime.mjs +2 -2
- package/dist/analyzer-HOUCQR3K.mjs +1066 -0
- package/dist/analyzer-VKUDHNDF.cjs +1066 -0
- package/dist/api/client.d.mts +0 -1
- package/dist/api/client.d.ts +0 -1
- package/dist/api/route-manager.cjs +8 -8
- package/dist/api/route-manager.d.mts +10 -10
- package/dist/api/route-manager.d.ts +10 -10
- package/dist/api/route-manager.mjs +7 -7
- package/dist/api/runtime.cjs +3 -3
- package/dist/api/runtime.d.mts +7 -7
- package/dist/api/runtime.d.ts +7 -7
- package/dist/api/runtime.mjs +2 -2
- package/dist/api.cjs +9 -9
- package/dist/api.d.mts +10 -10
- package/dist/api.d.ts +10 -10
- package/dist/api.mjs +8 -8
- package/dist/{app-y649szYm.d.ts → app-CourU3rQ.d.ts} +7 -7
- package/dist/{app-DLzz02du.d.mts → app-aeD4s_mg.d.mts} +7 -7
- package/dist/{app-manifest-Crn8Qd3U.d.mts → app-manifest-BC6mFn5A.d.mts} +1 -1
- package/dist/{app-manifest-DNeTKMRL.d.ts → app-manifest-LzjoNPeq.d.ts} +1 -1
- package/dist/app-markdown.d.mts +7 -7
- package/dist/app-markdown.d.ts +7 -7
- package/dist/base-path-BOUV5ozD.d.mts +10 -0
- package/dist/base-path-BOUV5ozD.d.ts +10 -0
- package/dist/cache.d.mts +4 -3
- package/dist/cache.d.ts +4 -3
- package/dist/{chunk-YQGZLCT4.cjs → chunk-2IAPKPEB.cjs} +6 -6
- package/dist/chunk-2KVDHNQS.mjs +224 -0
- package/dist/{chunk-QFQDRJKJ.mjs → chunk-3HA7PP72.mjs} +2 -2
- package/dist/{chunk-6LH33DLL.cjs → chunk-3OWVWZ6R.cjs} +28 -2
- package/dist/{chunk-GXSMF7UR.mjs → chunk-4GJJ65RB.mjs} +10 -2
- package/dist/{chunk-GERUXONA.cjs → chunk-5A77OEIG.cjs} +4 -1
- package/dist/{chunk-4HBKBHVP.mjs → chunk-5ENW27SL.mjs} +1 -1
- package/dist/{chunk-MTB57GOK.mjs → chunk-724WT3NI.mjs} +4 -2
- package/dist/{chunk-XLYXG73A.mjs → chunk-75WWOZ5C.mjs} +22 -0
- package/dist/{chunk-VCKGOXFI.cjs → chunk-76GHW3WI.cjs} +7 -1
- package/dist/{chunk-ZIBIE7AH.mjs → chunk-7UPCJDB5.mjs} +7 -1
- package/dist/{chunk-4IICUBQX.cjs → chunk-A5BJKSZE.cjs} +2 -2
- package/dist/{chunk-UYQOIPXE.mjs → chunk-AER5I65K.mjs} +1 -1
- package/dist/{chunk-WB6XES4V.mjs → chunk-ALEUMLJN.mjs} +34 -5
- package/dist/{chunk-Z4LTSH7D.mjs → chunk-AMRK3P6W.mjs} +175 -71
- package/dist/{chunk-TTYXOAB7.mjs → chunk-ANHZ6SUL.mjs} +1 -1
- package/dist/{chunk-ZBS3GOQZ.cjs → chunk-AQLHD6HZ.cjs} +35 -61
- package/dist/{chunk-L6QDME5Z.cjs → chunk-B3GZAQSC.cjs} +3 -3
- package/dist/chunk-CKPTIEDX.cjs +12 -0
- package/dist/{chunk-JPAVNDZH.cjs → chunk-CY7H5KS4.cjs} +25 -25
- package/dist/{chunk-4S7M63WX.cjs → chunk-DGOLAZLV.cjs} +22 -1
- package/dist/{chunk-4HM5B5RR.cjs → chunk-DWW3AMJX.cjs} +343 -308
- package/dist/{chunk-EQMTJBB7.cjs → chunk-DZZHTMWM.cjs} +35 -6
- package/dist/chunk-E36C43IX.cjs +224 -0
- package/dist/{chunk-J2ZEVDEK.cjs → chunk-EHB77D5U.cjs} +3 -3
- package/dist/{chunk-WQGRD5BJ.cjs → chunk-EX6ZSN5P.cjs} +1 -16
- package/dist/{chunk-C5S457CK.cjs → chunk-F42U3R4F.cjs} +214 -193
- package/dist/{chunk-FGJQS4EC.cjs → chunk-FK25QSVC.cjs} +4 -3
- package/dist/{chunk-JOHXK4BB.mjs → chunk-FSQMN2MQ.mjs} +2 -1
- package/dist/{chunk-2H3FJYY6.mjs → chunk-FSXSQQTV.mjs} +3 -2
- package/dist/chunk-G2KTRMWA.mjs +40 -0
- package/dist/{chunk-C6U66WWF.mjs → chunk-GFT5AHAT.mjs} +13 -0
- package/dist/chunk-GNZIAJGB.mjs +358 -0
- package/dist/{chunk-TXK4D46O.mjs → chunk-H3ASZDT7.mjs} +21 -1
- package/dist/{chunk-AXRNEVCS.cjs → chunk-HASX6DC7.cjs} +8 -8
- package/dist/{chunk-NW2BKDVT.mjs → chunk-HHFMECFO.mjs} +1 -1
- package/dist/{chunk-HELQXYVI.cjs → chunk-I2DQGS56.cjs} +11 -9
- package/dist/{chunk-IVHPRF4W.mjs → chunk-I2ZA5SXS.mjs} +81 -46
- package/dist/{chunk-EVCQX243.cjs → chunk-IOUOGRDX.cjs} +13 -5
- package/dist/{chunk-CBJKDB6F.mjs → chunk-IRSS4HS4.mjs} +1 -1
- package/dist/{chunk-NPPT4RWF.cjs → chunk-J22JD5YJ.cjs} +7 -7
- package/dist/{chunk-VJXLUTBM.mjs → chunk-JF5CNHHF.mjs} +9 -9
- package/dist/{chunk-VR4SEDEM.mjs → chunk-JWI5PUO2.mjs} +6 -2
- package/dist/{chunk-6XFGJBYX.cjs → chunk-JYNNIGQO.cjs} +16 -7
- package/dist/{chunk-EXHEPWFJ.cjs → chunk-KHXAJ2KA.cjs} +16 -16
- package/dist/{chunk-ALD2WMLA.mjs → chunk-KY32FWK7.mjs} +4 -4
- package/dist/{chunk-BR5FSKZ5.cjs → chunk-LEIXUFJN.cjs} +6 -2
- package/dist/{chunk-5566GNEG.cjs → chunk-LIFUPCXW.cjs} +13 -0
- package/dist/{chunk-I2SWKWO7.mjs → chunk-LJDIFIJ2.mjs} +1 -1
- package/dist/chunk-LMFJCXDD.mjs +55 -0
- package/dist/{chunk-IXSMFKZ2.cjs → chunk-LNM57D3H.cjs} +4 -4
- package/dist/{chunk-ATHPRVP2.mjs → chunk-LZ4SB57H.mjs} +3 -3
- package/dist/{chunk-73XBJRZW.cjs → chunk-MMEEXMUQ.cjs} +2 -2
- package/dist/chunk-N4AQNEXR.cjs +17 -0
- package/dist/{chunk-JZMZKABS.cjs → chunk-NWUHS6GV.cjs} +3 -2
- package/dist/{chunk-KZT2VHRQ.cjs → chunk-O3MMJPC2.cjs} +19 -19
- package/dist/{chunk-JWP56HCP.mjs → chunk-OD6WM3I7.mjs} +2 -2
- package/dist/{chunk-R2SEZEBC.cjs → chunk-OYNNA4DD.cjs} +4 -4
- package/dist/{chunk-GBPDSUFE.mjs → chunk-OZK2DS44.mjs} +1 -1
- package/dist/{chunk-A7DK663W.cjs → chunk-PDJSL7PL.cjs} +50 -39
- package/dist/{chunk-XLLVWLWO.mjs → chunk-PIHKO25G.mjs} +1 -1
- package/dist/chunk-PIUTGRDI.cjs +358 -0
- package/dist/{chunk-XO6WL6NL.mjs → chunk-PPDHCRTC.mjs} +1 -1
- package/dist/{chunk-LZBM35DH.mjs → chunk-QI5AQMEE.mjs} +20 -9
- package/dist/{chunk-FR4HJDI6.cjs → chunk-QK3HBOTG.cjs} +27 -30
- package/dist/{chunk-Q3UU2KXC.mjs → chunk-QMDU6QHN.mjs} +4 -1
- package/dist/chunk-QXJADAQB.cjs +40 -0
- package/dist/{chunk-DGVVVYKD.mjs → chunk-R5P4KFPM.mjs} +2 -2
- package/dist/{chunk-3HBFI373.cjs → chunk-S5AQ7CAC.cjs} +14 -14
- package/dist/{chunk-Z3BXMMFF.mjs → chunk-S5ZA2T2W.mjs} +63 -42
- package/dist/{chunk-PXEXOQ5R.mjs → chunk-SHS6KXOZ.mjs} +1 -1
- package/dist/{chunk-ETF5C6HR.cjs → chunk-SJ23LJ3N.cjs} +3 -3
- package/dist/{chunk-LL7TDMOM.mjs → chunk-SMUW7UST.mjs} +33 -59
- package/dist/{chunk-VCFBQFOV.mjs → chunk-SN5VSO3Q.mjs} +9 -7
- package/dist/{chunk-AIHD6VME.cjs → chunk-SO3T6T4I.cjs} +482 -378
- package/dist/{chunk-JHXJBNLY.cjs → chunk-SUCDVKUB.cjs} +21 -1
- package/dist/{chunk-DM3TFCC2.cjs → chunk-SUV6YO4Q.cjs} +5 -5
- package/dist/{chunk-NG44F7AH.mjs → chunk-T4EW7AAD.mjs} +2 -2
- package/dist/{chunk-JUMPFVMK.mjs → chunk-TUOO6IK3.mjs} +9 -0
- package/dist/chunk-UB7RVEMX.mjs +73 -0
- package/dist/{chunk-CDTIXBKN.mjs → chunk-UN6N623E.mjs} +2 -2
- package/dist/{chunk-BEXYFR2R.cjs → chunk-USL2ANCB.cjs} +10 -10
- package/dist/{chunk-HAH4FBTA.mjs → chunk-VAHBCI6X.mjs} +1 -1
- package/dist/{chunk-QNQEK3OF.cjs → chunk-VIFPE5RG.cjs} +14 -14
- package/dist/{chunk-HTLCLOXQ.cjs → chunk-VO6NLTV4.cjs} +3 -3
- package/dist/{chunk-XN2MB4QZ.cjs → chunk-VQJYGZNX.cjs} +4 -4
- package/dist/{chunk-N25RPPO5.cjs → chunk-WAPQWAE6.cjs} +10 -10
- package/dist/{chunk-5PKDHKQP.cjs → chunk-WFVSAT7Y.cjs} +6 -4
- package/dist/{chunk-EA5PMJDU.mjs → chunk-WSY2JD7O.mjs} +7 -7
- package/dist/{chunk-HNAUK3SC.mjs → chunk-WVX3BUNJ.mjs} +40 -199
- package/dist/chunk-X3EFRVXY.mjs +12 -0
- package/dist/{chunk-UCQ52TJY.mjs → chunk-X3JNB2TB.mjs} +1 -1
- package/dist/{chunk-J5VCA45K.cjs → chunk-X5BCMLGP.cjs} +1 -1
- package/dist/{chunk-SSNN55Q6.cjs → chunk-XB24LZWI.cjs} +10 -10
- package/dist/{chunk-XXB37YET.cjs → chunk-XLRLSTJ6.cjs} +7 -7
- package/dist/{chunk-BNMHXVLL.mjs → chunk-XMHERKSE.mjs} +0 -15
- package/dist/chunk-XPMC4E2G.cjs +55 -0
- package/dist/{chunk-J27BZO67.mjs → chunk-XWC5NAHV.mjs} +23 -26
- package/dist/{chunk-DRFADSKY.mjs → chunk-XXXRRVY6.mjs} +4 -4
- package/dist/{chunk-C7425KDG.cjs → chunk-XYL4HSVC.cjs} +2 -2
- package/dist/{chunk-2SVJGOAX.mjs → chunk-Y3N5BFRJ.mjs} +3 -3
- package/dist/{chunk-ZSIGEHSE.cjs → chunk-Y7TLL65B.cjs} +21 -180
- package/dist/{chunk-PEHL3IZL.cjs → chunk-YB44NKC2.cjs} +2 -2
- package/dist/chunk-YKHRCY4T.cjs +73 -0
- package/dist/{chunk-RYDDUCNJ.mjs → chunk-YLNBWUVS.mjs} +1 -1
- package/dist/chunk-Z5A6CNV2.mjs +60 -0
- package/dist/chunk-Z64V4WZI.mjs +17 -0
- package/dist/{chunk-ACI52TCN.mjs → chunk-ZF3GX4O7.mjs} +1 -1
- package/dist/client/lifecycle.d.mts +1 -1
- package/dist/client/lifecycle.d.ts +1 -1
- package/dist/{client-plugins-DFDQUI9Q.d.ts → client-plugins-CFBEfVPO.d.ts} +34 -10
- package/dist/{client-plugins-BNBeyLMi.d.mts → client-plugins-cqy_dQd0.d.mts} +34 -10
- package/dist/client-plugins.d.mts +6 -6
- package/dist/client-plugins.d.ts +6 -6
- package/dist/client.cjs +13 -9
- package/dist/client.d.mts +11 -10
- package/dist/client.d.ts +11 -10
- package/dist/client.mjs +15 -11
- package/dist/client.react-server.mjs +1 -1
- package/dist/config-CnhyvvmT.d.mts +188 -0
- package/dist/config-CnhyvvmT.d.ts +188 -0
- package/dist/config.d.mts +6 -6
- package/dist/config.d.ts +6 -6
- package/dist/cron.cjs +4 -4
- package/dist/cron.mjs +3 -3
- package/dist/desktop.d.mts +7 -7
- package/dist/desktop.d.ts +7 -7
- package/dist/{dev-guard-YO6KPIOQ.mjs → dev-guard-4PFQNXQX.mjs} +2 -1
- package/dist/{dev-guard-PLHL6OTJ.cjs → dev-guard-YLO5DE3H.cjs} +4 -3
- package/dist/{devtools-BLKHPY3C.mjs → devtools-4MLL3RAL.mjs} +10 -10
- package/dist/{devtools-A37WWJZL.cjs → devtools-4ZLMD454.cjs} +12 -12
- package/dist/docs.cjs +14 -14
- package/dist/docs.d.mts +7 -7
- package/dist/docs.d.ts +7 -7
- package/dist/docs.mjs +13 -13
- package/dist/environment/vite.d.mts +1 -1
- package/dist/environment/vite.d.ts +1 -1
- package/dist/generate-route-types-DQP0cUzk.d.ts +33 -0
- package/dist/generate-route-types-TF5Wwtvz.d.mts +33 -0
- package/dist/i18n/client.d.mts +2 -2
- package/dist/i18n/client.d.ts +2 -2
- package/dist/i18n/index.d.mts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/server.d.mts +5 -5
- package/dist/i18n/server.d.ts +5 -5
- package/dist/image/server.cjs +3 -3
- package/dist/image/server.mjs +2 -2
- package/dist/image/sharp.cjs +10 -10
- package/dist/image/sharp.mjs +2 -2
- package/dist/{index-DBdiTkNc.d.ts → index-BYkNbeQV.d.mts} +2 -2
- package/dist/{index-CeJ9_s9p.d.mts → index-BxjN_UDZ.d.ts} +2 -2
- package/dist/{index-MocnSP3a.d.ts → index-D3l4tREW.d.ts} +2 -2
- package/dist/{index-Cl3akY5U.d.mts → index-DPUAPho_.d.mts} +2 -2
- package/dist/index.cjs +88 -79
- package/dist/index.d.mts +29 -45
- package/dist/index.d.ts +29 -45
- package/dist/index.mjs +92 -83
- package/dist/integrations.cjs +3 -3
- package/dist/integrations.d.mts +6 -6
- package/dist/integrations.d.ts +6 -6
- package/dist/integrations.mjs +2 -2
- package/dist/internal/app-markdown-runtime.d.mts +7 -7
- package/dist/internal/app-markdown-runtime.d.ts +7 -7
- package/dist/internal/build-runtime.cjs +47 -43
- package/dist/internal/build-runtime.d.mts +9 -9
- package/dist/internal/build-runtime.d.ts +9 -9
- package/dist/internal/build-runtime.mjs +46 -42
- package/dist/internal/cli-runtime.cjs +24 -23
- package/dist/internal/cli-runtime.mjs +24 -23
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/client-runtime.cjs +22 -3
- package/dist/internal/client-runtime.d.mts +46 -4
- package/dist/internal/client-runtime.d.ts +46 -4
- package/dist/internal/client-runtime.mjs +22 -3
- package/dist/internal/compression-runtime.d.mts +6 -6
- package/dist/internal/compression-runtime.d.ts +6 -6
- package/dist/internal/config-runtime.cjs +20 -13
- package/dist/internal/config-runtime.d.mts +259 -18
- package/dist/internal/config-runtime.d.ts +259 -18
- package/dist/internal/config-runtime.mjs +18 -11
- package/dist/internal/form-actions.cjs +5 -4
- package/dist/internal/form-actions.mjs +4 -3
- package/dist/internal/infra-analytics-runtime.cjs +6 -6
- package/dist/internal/infra-analytics-runtime.mjs +4 -4
- package/dist/internal/islands-runtime.cjs +56 -0
- package/dist/internal/islands-runtime.mjs +57 -1
- package/dist/internal/metadata-image-runtime.cjs +3 -3
- package/dist/internal/metadata-image-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +18 -15
- package/dist/internal/production-runtime.d.mts +33 -20
- package/dist/internal/production-runtime.d.ts +33 -20
- package/dist/internal/production-runtime.mjs +20 -17
- package/dist/internal/server-fn-transform.cjs +13 -0
- package/dist/internal/server-fn-transform.d.mts +24 -0
- package/dist/internal/server-fn-transform.d.ts +24 -0
- package/dist/internal/server-fn-transform.mjs +13 -0
- package/dist/{layers-D9fbe-rz.d.ts → layers-CcS42OGR.d.mts} +1 -1
- package/dist/{layers-D9fbe-rz.d.mts → layers-CcS42OGR.d.ts} +1 -1
- package/dist/{lifecycle-DK06VuKP.d.ts → lifecycle-C2aLBOwu.d.mts} +1 -1
- package/dist/{lifecycle-DK06VuKP.d.mts → lifecycle-C2aLBOwu.d.ts} +1 -1
- package/dist/markdown.d.mts +6 -6
- package/dist/markdown.d.ts +6 -6
- package/dist/middleware.cjs +11 -11
- package/dist/middleware.d.mts +8 -8
- package/dist/middleware.d.ts +8 -8
- package/dist/middleware.mjs +10 -10
- package/dist/mobile.cjs +9 -0
- package/dist/mobile.d.mts +94 -0
- package/dist/mobile.d.ts +94 -0
- package/dist/mobile.mjs +9 -0
- package/dist/navigation-delegate-BU4xqdnw.d.ts +29 -0
- package/dist/navigation-delegate-DLhbfEN4.d.mts +29 -0
- package/dist/navigation.cjs +5 -5
- package/dist/navigation.d.mts +9 -9
- package/dist/navigation.d.ts +9 -9
- package/dist/navigation.mjs +4 -4
- package/dist/{nitro-BIXIKJZS.cjs → nitro-CK7M4RMY.cjs} +12 -12
- package/dist/{nitro-UT2J5A5D.mjs → nitro-R444AF3O.mjs} +8 -8
- package/dist/platform.cjs +2 -1
- package/dist/platform.d.mts +4 -3
- package/dist/platform.d.ts +4 -3
- package/dist/platform.mjs +2 -1
- package/dist/{plugin-4KYXV7BB.mjs → plugin-53SY5YBS.mjs} +1 -1
- package/dist/{plugin-WBANOZQM.cjs → plugin-HZIBL3DW.cjs} +2 -2
- package/dist/plugin.cjs +40 -36
- package/dist/plugin.d.mts +13 -8
- package/dist/plugin.d.ts +13 -8
- package/dist/plugin.mjs +39 -35
- package/dist/{production-runtime-B3qFFtKF.d.ts → production-runtime-C78A8YgK.d.ts} +3 -3
- package/dist/{production-runtime-DcD-GRAv.d.mts → production-runtime-DLA4J5WG.d.mts} +3 -3
- package/dist/production-vite-BQFAlG7n.d.mts +13 -0
- package/dist/production-vite-BQFAlG7n.d.ts +13 -0
- package/dist/{programmatic-routes-client-fD9f4XqU.d.ts → programmatic-routes-client-CBqkNhBy.d.ts} +2 -2
- package/dist/{programmatic-routes-client-DzbYGiZQ.d.mts → programmatic-routes-client-NpqGBn-i.d.mts} +2 -2
- package/dist/query/client.cjs +6 -6
- package/dist/query/client.mjs +2 -2
- package/dist/{render-plan-DqJ51ufr.d.mts → render-plan-C9sWvDTv.d.mts} +1 -1
- package/dist/{render-plan-B6cfssrr.d.ts → render-plan-CrqcBbnV.d.ts} +1 -1
- package/dist/renderer-client.cjs +17 -12
- package/dist/renderer-client.d.mts +9 -8
- package/dist/renderer-client.d.ts +9 -8
- package/dist/renderer-client.mjs +10 -5
- package/dist/{request-jhvUMXRx.d.ts → request-BizeuqD7.d.ts} +1 -1
- package/dist/{request-UuAxHn8h.d.mts → request-WwB1-Uim.d.mts} +1 -1
- package/dist/request.d.mts +7 -7
- package/dist/request.d.ts +7 -7
- package/dist/{resolver-DC57A4vz.d.ts → resolver-CJ-D9nP-.d.ts} +1 -1
- package/dist/{resolver-C2G-3Tm6.d.mts → resolver-TDyZKgKI.d.mts} +1 -1
- package/dist/{route-rendering-Sn50cYZf.d.ts → route-rendering-BGhJN64l.d.ts} +1 -1
- package/dist/{route-rendering-Cou00t1X.d.mts → route-rendering-S6NFjnx4.d.mts} +1 -1
- package/dist/{router-0X9DCTcm.d.mts → router-BIheIy9G.d.mts} +1 -1
- package/dist/{router-xwLvi48p.d.ts → router-BUD_j2EL.d.ts} +1 -1
- package/dist/routes-8PT9cl60.d.ts +121 -0
- package/dist/routes-kEUsXHx3.d.mts +121 -0
- package/dist/routes.cjs +3 -2
- package/dist/routes.d.mts +7 -7
- package/dist/routes.d.ts +7 -7
- package/dist/routes.mjs +2 -1
- package/dist/{rsc-pipeline-VKHMABDJ.cjs → rsc-pipeline-JRGUZBYM.cjs} +18 -16
- package/dist/{rsc-pipeline-F6ZPH5MU.mjs → rsc-pipeline-OLAVIKI3.mjs} +17 -15
- package/dist/{runtime-B9HmxiZc.d.ts → runtime-C4CmlOOh.d.ts} +2 -2
- package/dist/{runtime-tkSXZiqO.d.ts → runtime-CWP-21hP.d.ts} +1 -1
- package/dist/{runtime-CMrsyChI.d.mts → runtime-CgJwe6H_.d.mts} +1 -1
- package/dist/{runtime-CCxTmGuf.d.mts → runtime-CihDZ2Rn.d.mts} +2 -2
- package/dist/runtime-G23RSLEK.cjs +1005 -0
- package/dist/runtime-OGCHDACZ.mjs +1005 -0
- package/dist/{schema-dev-notice-O3I5HLXK.mjs → schema-dev-notice-F6QYSOAI.mjs} +4 -4
- package/dist/{schema-dev-notice-Z73J3NJ6.cjs → schema-dev-notice-UU7DMZEU.cjs} +7 -7
- package/dist/{search-client-BTXL5XWD.mjs → search-client-OXH6GBNO.mjs} +5 -3
- package/dist/search-client-ZZLKVO5R.cjs +15 -0
- package/dist/server-action-security.cjs +3 -3
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn-client.d.mts +0 -1
- package/dist/server-fn-client.d.ts +0 -1
- package/dist/server-fn.cjs +4 -4
- package/dist/server-fn.d.mts +0 -1
- package/dist/server-fn.d.ts +0 -1
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.cjs +1 -1
- package/dist/server-plugins.d.mts +7 -7
- package/dist/server-plugins.d.ts +7 -7
- package/dist/server-plugins.mjs +1 -1
- package/dist/server-query-client.cjs +4 -3
- package/dist/server-query-client.d.mts +0 -1
- package/dist/server-query-client.d.ts +0 -1
- package/dist/server-query-client.mjs +3 -2
- package/dist/server-query.cjs +5 -5
- package/dist/server-query.d.mts +0 -1
- package/dist/server-query.d.ts +0 -1
- package/dist/server-query.mjs +4 -4
- package/dist/server.cjs +104 -79
- package/dist/server.d.mts +22 -17
- package/dist/server.d.ts +22 -17
- package/dist/server.mjs +73 -48
- package/dist/{spa-router-B48EjsS1.d.mts → spa-router-CVOL0Vrq.d.mts} +4 -4
- package/dist/{spa-router-B06APnGK.d.ts → spa-router-Kytv4jSB.d.ts} +4 -4
- package/dist/testing.cjs +16 -15
- package/dist/testing.d.mts +6 -6
- package/dist/testing.d.ts +6 -6
- package/dist/testing.mjs +12 -11
- package/dist/{types--Wh02r5_.d.mts → types-C41ePjvP.d.mts} +1 -1
- package/dist/{types--Wh02r5_.d.ts → types-C41ePjvP.d.ts} +1 -1
- package/dist/{utils-C5fyK2tE.d.ts → utils-DbyXlzaj.d.ts} +1 -1
- package/dist/{utils-hyAwmcN6.d.mts → utils-Dsa1HZ7X.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +40 -36
- package/dist/vite.d.mts +9 -9
- package/dist/vite.d.ts +9 -9
- package/dist/vite.mjs +39 -35
- package/dist/{workflows-Df1C_7OG.d.mts → workflows-CRMzQZ3k.d.mts} +2 -1
- package/dist/{workflows-Df1C_7OG.d.ts → workflows-CRMzQZ3k.d.ts} +2 -1
- package/dist/workflows.cjs +5 -5
- package/dist/workflows.d.mts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.mjs +4 -4
- package/package.json +16 -3
- package/dist/base-path-leyrqXbX.d.mts +0 -19
- package/dist/base-path-leyrqXbX.d.ts +0 -19
- package/dist/cache-invalidation-BD0z_lfu.d.mts +0 -4
- package/dist/cache-invalidation-BD0z_lfu.d.ts +0 -4
- package/dist/chunk-45EUIICW.mjs +0 -15
- package/dist/chunk-MJ6IC4K2.mjs +0 -34
- package/dist/chunk-V7KTQR4C.cjs +0 -15
- package/dist/search-client-QCYAL6AY.cjs +0 -13
- package/dist/{chunk-5OJVKXFV.cjs → chunk-N7JQXQAV.cjs} +2 -2
- package/dist/{chunk-72KABRWN.mjs → chunk-WSDKXV4E.mjs} +4 -4
|
@@ -0,0 +1,1066 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkX5BCMLGPcjs = require('./chunk-X5BCMLGP.cjs');
|
|
4
|
+
require('./chunk-BTZ5O6VM.cjs');
|
|
5
|
+
|
|
6
|
+
// src/mobile/analyzer.ts
|
|
7
|
+
var _crypto = require('crypto');
|
|
8
|
+
var _fs = require('fs');
|
|
9
|
+
var _promises = require('fs/promises');
|
|
10
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
11
|
+
var ANALYZER_VERSION = `1:${_chunkX5BCMLGPcjs.FARM_VERSION}`;
|
|
12
|
+
var INTRINSIC_KINDS = {};
|
|
13
|
+
for (const tag of "div section main article header footer nav aside figure hr li".split(" ")) {
|
|
14
|
+
INTRINSIC_KINDS[tag] = "View";
|
|
15
|
+
}
|
|
16
|
+
for (const tag of "p span h1 h2 h3 h4 h5 h6 strong em b i small label code br".split(" ")) {
|
|
17
|
+
INTRINSIC_KINDS[tag] = "Text";
|
|
18
|
+
}
|
|
19
|
+
Object.assign(INTRINSIC_KINDS, {
|
|
20
|
+
img: "Image",
|
|
21
|
+
button: "Pressable",
|
|
22
|
+
a: "Pressable",
|
|
23
|
+
input: "TextInput",
|
|
24
|
+
textarea: "TextInput",
|
|
25
|
+
ul: "List",
|
|
26
|
+
ol: "List"
|
|
27
|
+
});
|
|
28
|
+
var INPUT_TYPES = /* @__PURE__ */ new Set(["text", "email", "password", "number", "search", "tel", "url"]);
|
|
29
|
+
var MAPPED_EVENTS = {
|
|
30
|
+
View: /* @__PURE__ */ new Set(["onClick"]),
|
|
31
|
+
Text: /* @__PURE__ */ new Set(["onClick"]),
|
|
32
|
+
Image: /* @__PURE__ */ new Set(["onClick", "onLoad", "onError"]),
|
|
33
|
+
Pressable: /* @__PURE__ */ new Set(["onClick"]),
|
|
34
|
+
TextInput: /* @__PURE__ */ new Set(["onChange", "onInput", "onFocus", "onBlur"]),
|
|
35
|
+
List: /* @__PURE__ */ new Set()
|
|
36
|
+
};
|
|
37
|
+
var BROWSER_GLOBALS = new Set(
|
|
38
|
+
"window document localStorage sessionStorage navigator matchMedia ResizeObserver IntersectionObserver MutationObserver getComputedStyle requestAnimationFrame cancelAnimationFrame location history indexedDB customElements HTMLElement Element DOMParser screen visualViewport".split(" ")
|
|
39
|
+
);
|
|
40
|
+
var DOM_PACKAGES = [
|
|
41
|
+
"react-dom",
|
|
42
|
+
"leaflet",
|
|
43
|
+
"react-leaflet",
|
|
44
|
+
"mapbox-gl",
|
|
45
|
+
"chart.js",
|
|
46
|
+
"react-chartjs-2",
|
|
47
|
+
"recharts",
|
|
48
|
+
"d3",
|
|
49
|
+
"three",
|
|
50
|
+
"@react-three/",
|
|
51
|
+
"framer-motion",
|
|
52
|
+
"motion",
|
|
53
|
+
"@radix-ui/",
|
|
54
|
+
"@headlessui/",
|
|
55
|
+
"react-markdown",
|
|
56
|
+
"@tiptap/",
|
|
57
|
+
"prosemirror-",
|
|
58
|
+
"@monaco-editor/",
|
|
59
|
+
"monaco-editor",
|
|
60
|
+
"codemirror",
|
|
61
|
+
"@codemirror/",
|
|
62
|
+
"swiper",
|
|
63
|
+
"embla-carousel",
|
|
64
|
+
"lucide-react",
|
|
65
|
+
"react-icons",
|
|
66
|
+
"@heroicons/",
|
|
67
|
+
"shiki",
|
|
68
|
+
"highlight.js",
|
|
69
|
+
"prismjs",
|
|
70
|
+
"styled-components",
|
|
71
|
+
"@emotion/",
|
|
72
|
+
"@stylexjs/"
|
|
73
|
+
];
|
|
74
|
+
var PORTABLE_PACKAGES = /* @__PURE__ */ new Set([
|
|
75
|
+
"react",
|
|
76
|
+
"@farm.js/ui",
|
|
77
|
+
"@farm.js/native",
|
|
78
|
+
"zod",
|
|
79
|
+
"valibot",
|
|
80
|
+
"date-fns",
|
|
81
|
+
"dayjs",
|
|
82
|
+
"lodash",
|
|
83
|
+
"lodash-es",
|
|
84
|
+
"nanoid",
|
|
85
|
+
"uuid",
|
|
86
|
+
"clsx",
|
|
87
|
+
"classnames",
|
|
88
|
+
"tailwind-merge",
|
|
89
|
+
"@tanstack/react-query",
|
|
90
|
+
"zustand",
|
|
91
|
+
"jotai",
|
|
92
|
+
"immer"
|
|
93
|
+
]);
|
|
94
|
+
var CORE_PORTABLE = {
|
|
95
|
+
"@farm.js/core": /* @__PURE__ */ new Set([
|
|
96
|
+
"Link",
|
|
97
|
+
"createRoute",
|
|
98
|
+
"useRouter",
|
|
99
|
+
"useSearchParams",
|
|
100
|
+
"usePathname",
|
|
101
|
+
"navigateTo",
|
|
102
|
+
"notFound",
|
|
103
|
+
"redirect",
|
|
104
|
+
"createServerFn",
|
|
105
|
+
"createServerQuery"
|
|
106
|
+
]),
|
|
107
|
+
"@farm.js/core/client": /* @__PURE__ */ new Set([
|
|
108
|
+
"Link",
|
|
109
|
+
"useRouter",
|
|
110
|
+
"navigateTo",
|
|
111
|
+
"createApiClients",
|
|
112
|
+
"useServerQuery"
|
|
113
|
+
]),
|
|
114
|
+
"@farm.js/core/navigation": /* @__PURE__ */ new Set([
|
|
115
|
+
"useRouter",
|
|
116
|
+
"useSearchParams",
|
|
117
|
+
"usePathname",
|
|
118
|
+
"notFound",
|
|
119
|
+
"redirect"
|
|
120
|
+
]),
|
|
121
|
+
"@farm.js/core/server-fn": /* @__PURE__ */ new Set(["createServerFn"]),
|
|
122
|
+
"@farm.js/core/server-query": /* @__PURE__ */ new Set(["createServerQuery"]),
|
|
123
|
+
"@farm.js/core/server-fn/client": /* @__PURE__ */ new Set(["useServerFn"]),
|
|
124
|
+
"@farm.js/core/server-query/client": /* @__PURE__ */ new Set(["useServerQuery", "prefetchServerQuery"]),
|
|
125
|
+
"@farm.js/core/api/client": /* @__PURE__ */ new Set(["createApiClients"]),
|
|
126
|
+
"@farm.js/core/image": /* @__PURE__ */ new Set(["Image"]),
|
|
127
|
+
"@farm.js/core/i18n/client": /* @__PURE__ */ new Set(["useLocale", "useTranslations"]),
|
|
128
|
+
"@farm.js/core/version": /* @__PURE__ */ new Set(["FARM_VERSION"]),
|
|
129
|
+
"@farm.js/core/platform": /* @__PURE__ */ new Set(["platform"])
|
|
130
|
+
};
|
|
131
|
+
var MAPPED_COMPONENTS = {
|
|
132
|
+
"@farm.js/core": { Link: "Pressable" },
|
|
133
|
+
"@farm.js/core/client": { Link: "Pressable" },
|
|
134
|
+
"@farm.js/core/image": { Image: "Image" },
|
|
135
|
+
"@farm.js/ui": {
|
|
136
|
+
View: "View",
|
|
137
|
+
Text: "Text",
|
|
138
|
+
Image: "Image",
|
|
139
|
+
Pressable: "Pressable",
|
|
140
|
+
TextInput: "TextInput",
|
|
141
|
+
List: "List"
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var SERVER_FN_FACTORIES = /* @__PURE__ */ new Set(["createServerFn", "createServerQuery"]);
|
|
145
|
+
var SCRIPT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
146
|
+
var STYLE_FILE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)(?:\?.*)?$/i;
|
|
147
|
+
var ASSET_FILE = /\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|json|woff2?|ttf|otf|mp3|wav|txt)(?:\?.*)?$/i;
|
|
148
|
+
var STYLE_PROPERTIES = new Set(
|
|
149
|
+
"display flexDirection flex flexGrow flexShrink flexBasis flexWrap alignItems alignSelf alignContent justifyContent gap rowGap columnGap padding paddingTop paddingRight paddingBottom paddingLeft paddingInline paddingBlock paddingHorizontal paddingVertical margin marginTop marginRight marginBottom marginLeft marginInline marginBlock width height minWidth minHeight maxWidth maxHeight color backgroundColor borderColor borderWidth borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth borderRadius borderStyle opacity fontSize fontWeight fontStyle fontFamily lineHeight letterSpacing textAlign textDecorationLine textTransform position top right bottom left zIndex overflow aspectRatio".split(" ")
|
|
150
|
+
);
|
|
151
|
+
var STYLE_ENUMS = {
|
|
152
|
+
display: /* @__PURE__ */ new Set(["flex", "none"]),
|
|
153
|
+
position: /* @__PURE__ */ new Set(["relative", "absolute"]),
|
|
154
|
+
overflow: /* @__PURE__ */ new Set(["hidden", "visible"])
|
|
155
|
+
};
|
|
156
|
+
var STYLE_VALUE_BLOCK = /\b(?:calc|var|env|min|max|clamp)\(|\d(?:vh|vw|dvh|svh|lvh|vmin|vmax|em|ch)\b/;
|
|
157
|
+
var COLOR = "(?:inherit|current|transparent|black|white|(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|[1-9]00|950))(?:/\\d{1,3})?";
|
|
158
|
+
var SPACE = "(?:\\d+(?:\\.5)?|px|auto)";
|
|
159
|
+
var SIZE = "(?:\\d+(?:\\.5)?|px|auto|full|\\d+/\\d+|min|max|fit)";
|
|
160
|
+
var PORTABLE_CLASSES = [
|
|
161
|
+
/^(?:flex|flex-row|flex-col|flex-row-reverse|flex-col-reverse|flex-wrap|flex-nowrap|flex-wrap-reverse|flex-1|flex-auto|flex-initial|flex-none|grow|grow-0|shrink|shrink-0|hidden|relative|absolute|overflow-hidden|overflow-visible|italic|not-italic|underline|line-through|no-underline|uppercase|lowercase|capitalize|normal-case|text-left|text-center|text-right|text-justify)$/,
|
|
162
|
+
/^(?:items|justify|self|content)-(?:start|end|center|between|around|evenly|stretch|baseline|auto)$/,
|
|
163
|
+
new RegExp(
|
|
164
|
+
`^-?(?:gap|gap-x|gap-y|p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me)-${SPACE}$`
|
|
165
|
+
),
|
|
166
|
+
new RegExp(`^(?:w|h|size|min-w|min-h|max-h)-${SIZE}$`),
|
|
167
|
+
/^max-w-(?:none|xs|sm|md|lg|xl|[2-7]xl|full|min|max|fit)$/,
|
|
168
|
+
new RegExp(`^-?(?:top|right|bottom|left|inset|inset-x|inset-y)-${SIZE}$`),
|
|
169
|
+
/^z-(?:\d+|auto)$/,
|
|
170
|
+
/^text-(?:xs|sm|base|lg|xl|[2-9]xl)$/,
|
|
171
|
+
/^font-(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|sans|serif|mono)$/,
|
|
172
|
+
/^leading-(?:none|tight|snug|normal|relaxed|loose|\d+)$/,
|
|
173
|
+
/^tracking-(?:tighter|tight|normal|wide|wider|widest)$/,
|
|
174
|
+
new RegExp(`^(?:text|bg|border|border-[trblxy])-${COLOR}$`),
|
|
175
|
+
/^rounded(?:-[trbl]{1,2})?(?:-(?:none|sm|md|lg|xl|2xl|3xl|full))?$/,
|
|
176
|
+
/^border(?:-[trblxy])?(?:-(?:0|2|4|8))?$/,
|
|
177
|
+
/^border-(?:solid|dashed|dotted|none)$/,
|
|
178
|
+
/^opacity-\d{1,3}$/,
|
|
179
|
+
/^aspect-(?:square|video|auto)$/,
|
|
180
|
+
// No effect on a touch screen; dropped on native.
|
|
181
|
+
/^(?:cursor|select|outline|pointer-events)-[a-z-]+$/
|
|
182
|
+
];
|
|
183
|
+
var BLOCKING_CLASSES = [
|
|
184
|
+
[/^(?:grid|inline-grid|grid-.+|col-.+|row-.+|auto-cols-.+|auto-rows-.+)$/, "uses grid layout"],
|
|
185
|
+
[/^(?:fixed|sticky)$/, "uses fixed or sticky positioning"],
|
|
186
|
+
[
|
|
187
|
+
/^(?:transition.*|duration-.+|ease-.+|delay-.+|animate-.+)$/,
|
|
188
|
+
"uses CSS transitions or keyframes"
|
|
189
|
+
],
|
|
190
|
+
[/^(?:space-[xy]-.+|divide-.+)$/, "needs child selectors"],
|
|
191
|
+
[
|
|
192
|
+
/^(?:block|inline|inline-block|inline-flex|table.*|contents|flow-root|list-item)$/,
|
|
193
|
+
"sets a display mode other than flex"
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
/^(?:shadow.*|ring.*|blur.*|backdrop-.+|drop-shadow.*|bg-gradient-.+|from-.+|via-.+|to-.+|bg-clip-.+|mix-blend-.+|filter|invert|grayscale.*|sepia.*)$/,
|
|
197
|
+
"is a visual effect with no native mapping"
|
|
198
|
+
],
|
|
199
|
+
[/^(?:container|prose.*|sr-only|not-sr-only)$/, "needs stylesheet rules"],
|
|
200
|
+
[
|
|
201
|
+
/^(?:truncate|line-clamp-.+|whitespace-.+|break-.+|text-ellipsis|text-clip)$/,
|
|
202
|
+
"needs CSS text wrapping"
|
|
203
|
+
]
|
|
204
|
+
];
|
|
205
|
+
function classifyClass(token) {
|
|
206
|
+
const parts = token.split(":");
|
|
207
|
+
const utility = parts.pop().replace(/^!/, "");
|
|
208
|
+
const variant = parts.find((part) => part !== "dark");
|
|
209
|
+
if (variant) {
|
|
210
|
+
return /^(?:sm|md|lg|xl|2xl|min-.+|max-.+|portrait|landscape|print)$/.test(variant) ? `"${token}" is a media query` : `"${token}" needs the CSS ${variant}: selector`;
|
|
211
|
+
}
|
|
212
|
+
if (utility.includes("[")) return `"${token}" is an arbitrary value`;
|
|
213
|
+
if (PORTABLE_CLASSES.some((pattern) => pattern.test(utility))) return void 0;
|
|
214
|
+
for (const [pattern, why] of BLOCKING_CLASSES) {
|
|
215
|
+
if (pattern.test(utility)) return `"${token}" ${why}`;
|
|
216
|
+
}
|
|
217
|
+
return `class "${token}" is not in the native Tailwind subset`;
|
|
218
|
+
}
|
|
219
|
+
function scriptLang(file) {
|
|
220
|
+
return file.endsWith(".tsx") ? "tsx" : file.endsWith(".ts") ? "ts" : "jsx";
|
|
221
|
+
}
|
|
222
|
+
function lineStarts(source) {
|
|
223
|
+
const starts = [0];
|
|
224
|
+
for (let index = source.indexOf("\n"); index !== -1; index = source.indexOf("\n", index + 1)) {
|
|
225
|
+
starts.push(index + 1);
|
|
226
|
+
}
|
|
227
|
+
return starts;
|
|
228
|
+
}
|
|
229
|
+
function locate(starts, offset) {
|
|
230
|
+
let low = 0;
|
|
231
|
+
let high = starts.length - 1;
|
|
232
|
+
while (low < high) {
|
|
233
|
+
const mid = low + high + 1 >> 1;
|
|
234
|
+
if (starts[mid] <= offset) low = mid;
|
|
235
|
+
else high = mid - 1;
|
|
236
|
+
}
|
|
237
|
+
return { line: low + 1, column: offset - starts[low] + 1 };
|
|
238
|
+
}
|
|
239
|
+
function collectPatternNames(pattern, names) {
|
|
240
|
+
if (!pattern) return;
|
|
241
|
+
switch (pattern.type) {
|
|
242
|
+
case "Identifier":
|
|
243
|
+
names.add(pattern.name);
|
|
244
|
+
return;
|
|
245
|
+
case "ObjectPattern":
|
|
246
|
+
for (const property of pattern.properties) {
|
|
247
|
+
collectPatternNames(
|
|
248
|
+
property.type === "RestElement" ? property.argument : property.value,
|
|
249
|
+
names
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
case "ArrayPattern":
|
|
254
|
+
for (const element of pattern.elements) collectPatternNames(element, names);
|
|
255
|
+
return;
|
|
256
|
+
case "RestElement":
|
|
257
|
+
collectPatternNames(pattern.argument, names);
|
|
258
|
+
return;
|
|
259
|
+
case "AssignmentPattern":
|
|
260
|
+
collectPatternNames(pattern.left, names);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function jsxName(name) {
|
|
265
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
266
|
+
if (name.type === "JSXMemberExpression") return `${jsxName(name.object)}.${name.property.name}`;
|
|
267
|
+
if (name.type === "JSXNamespacedName") return `${name.namespace.name}:${name.name.name}`;
|
|
268
|
+
return "?";
|
|
269
|
+
}
|
|
270
|
+
function attributeName(attribute) {
|
|
271
|
+
return attribute.name.type === "JSXNamespacedName" ? `${attribute.name.namespace.name}:${attribute.name.name.name}` : attribute.name.name;
|
|
272
|
+
}
|
|
273
|
+
function staticString(value) {
|
|
274
|
+
if (!value) return void 0;
|
|
275
|
+
if (value.type === "Literal" && typeof value.value === "string") return value.value;
|
|
276
|
+
if (value.type === "JSXExpressionContainer") return staticString(value.expression);
|
|
277
|
+
if (value.type === "TemplateLiteral" && value.expressions.length === 0) {
|
|
278
|
+
return value.quasis.map((quasi) => _nullishCoalesce(quasi.value.cooked, () => ( quasi.value.raw))).join("");
|
|
279
|
+
}
|
|
280
|
+
return void 0;
|
|
281
|
+
}
|
|
282
|
+
var SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
283
|
+
"type",
|
|
284
|
+
"start",
|
|
285
|
+
"end",
|
|
286
|
+
"range",
|
|
287
|
+
"loc",
|
|
288
|
+
"typeAnnotation",
|
|
289
|
+
"returnType",
|
|
290
|
+
"typeParameters",
|
|
291
|
+
"typeArguments",
|
|
292
|
+
"decorators"
|
|
293
|
+
]);
|
|
294
|
+
function analyzeSource(file, source, parseSync) {
|
|
295
|
+
const facts = {
|
|
296
|
+
imports: [],
|
|
297
|
+
blockers: [],
|
|
298
|
+
elements: { total: 0, mapped: 0, byKind: {} },
|
|
299
|
+
wins: [],
|
|
300
|
+
useClient: false,
|
|
301
|
+
serverBoundary: false,
|
|
302
|
+
asyncDefault: false,
|
|
303
|
+
components: {}
|
|
304
|
+
};
|
|
305
|
+
const starts = lineStarts(source);
|
|
306
|
+
const block = (node, rule, message) => {
|
|
307
|
+
facts.blockers.push({ ...locate(starts, node.start), rule, message });
|
|
308
|
+
};
|
|
309
|
+
const result = parseSync(file, source, { lang: scriptLang(file) });
|
|
310
|
+
if (result.errors.length > 0) {
|
|
311
|
+
const error = result.errors[0];
|
|
312
|
+
const offset = _nullishCoalesce(_optionalChain([error, 'access', _ => _.labels, 'optionalAccess', _2 => _2[0], 'optionalAccess', _3 => _3.start]), () => ( 0));
|
|
313
|
+
facts.blockers.push({ ...locate(starts, offset), rule: "parse-error", message: error.message });
|
|
314
|
+
return facts;
|
|
315
|
+
}
|
|
316
|
+
const program = result.program;
|
|
317
|
+
const wins = /* @__PURE__ */ new Set();
|
|
318
|
+
const imported = /* @__PURE__ */ new Map();
|
|
319
|
+
const topLevel = /* @__PURE__ */ new Set();
|
|
320
|
+
const declared = /* @__PURE__ */ new Set();
|
|
321
|
+
let callsServerFactory = false;
|
|
322
|
+
const asyncFunctions = /* @__PURE__ */ new Set();
|
|
323
|
+
let defaultName;
|
|
324
|
+
for (const statement of program.body) {
|
|
325
|
+
if (statement.type === "ExpressionStatement" && statement.directive) {
|
|
326
|
+
if (statement.directive === "use client") facts.useClient = true;
|
|
327
|
+
if (statement.directive === "use server") facts.serverBoundary = true;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (statement.type === "ImportDeclaration") {
|
|
331
|
+
const where = locate(starts, statement.start);
|
|
332
|
+
if (statement.importKind === "type") continue;
|
|
333
|
+
const names = [];
|
|
334
|
+
for (const specifier of statement.specifiers) {
|
|
335
|
+
if (specifier.importKind === "type") continue;
|
|
336
|
+
const name = specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.type === "ImportNamespaceSpecifier" ? "*" : _nullishCoalesce(specifier.imported.name, () => ( specifier.imported.value));
|
|
337
|
+
names.push(name);
|
|
338
|
+
imported.set(specifier.local.name, { source: statement.source.value, name });
|
|
339
|
+
declared.add(specifier.local.name);
|
|
340
|
+
}
|
|
341
|
+
if (statement.specifiers.length > 0 && names.length === 0) continue;
|
|
342
|
+
facts.imports.push({ source: statement.source.value, ...where, names });
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if ((statement.type === "ExportNamedDeclaration" || statement.type === "ExportAllDeclaration") && statement.source && statement.exportKind !== "type") {
|
|
346
|
+
facts.imports.push({
|
|
347
|
+
source: statement.source.value,
|
|
348
|
+
...locate(starts, statement.start),
|
|
349
|
+
names: statement.type === "ExportAllDeclaration" ? ["*"] : statement.specifiers.filter((specifier) => specifier.exportKind !== "type").map((specifier) => _nullishCoalesce(specifier.local.name, () => ( specifier.local.value)))
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
const declaration = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? statement.declaration : statement;
|
|
353
|
+
if (!declaration) continue;
|
|
354
|
+
if (_optionalChain([declaration, 'access', _4 => _4.id, 'optionalAccess', _5 => _5.name]) && /Function|Class/.test(declaration.type)) {
|
|
355
|
+
topLevel.add(declaration.id.name);
|
|
356
|
+
}
|
|
357
|
+
if (_optionalChain([declaration, 'access', _6 => _6.id, 'optionalAccess', _7 => _7.name]) && declaration.async) asyncFunctions.add(declaration.id.name);
|
|
358
|
+
if (statement.type === "ExportDefaultDeclaration" && declaration.type === "Identifier") {
|
|
359
|
+
defaultName = declaration.name;
|
|
360
|
+
}
|
|
361
|
+
if (declaration.type === "VariableDeclaration") {
|
|
362
|
+
for (const declarator of declaration.declarations) {
|
|
363
|
+
if (declarator.id.type !== "Identifier") continue;
|
|
364
|
+
const init = declarator.init;
|
|
365
|
+
if (_optionalChain([init, 'optionalAccess', _8 => _8.async])) asyncFunctions.add(declarator.id.name);
|
|
366
|
+
const callee = _optionalChain([init, 'optionalAccess', _9 => _9.type]) === "CallExpression" ? init.callee : void 0;
|
|
367
|
+
const calleeName = _optionalChain([callee, 'optionalAccess', _10 => _10.type]) === "MemberExpression" ? callee.property.name : _optionalChain([callee, 'optionalAccess', _11 => _11.name]);
|
|
368
|
+
if (/Function/.test(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _12 => _12.type]), () => ( ""))) || calleeName && /^(?:memo|forwardRef|lazy)$/.test(calleeName)) {
|
|
369
|
+
topLevel.add(declarator.id.name);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (statement.type === "ExportDefaultDeclaration" && declaration.async)
|
|
374
|
+
facts.asyncDefault = true;
|
|
375
|
+
}
|
|
376
|
+
const globalCandidates = [];
|
|
377
|
+
const blockGlobalsLater = () => {
|
|
378
|
+
for (const node of globalCandidates) {
|
|
379
|
+
if (!declared.has(node.name)) {
|
|
380
|
+
block(node, "browser-global", `${node.name} is a browser API`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const classifyElement = (element) => {
|
|
385
|
+
const opening = element.openingElement;
|
|
386
|
+
const tag = jsxName(opening.name);
|
|
387
|
+
let kind;
|
|
388
|
+
let counted = true;
|
|
389
|
+
const isIntrinsic = opening.name.type === "JSXIdentifier" && /^[a-z]/.test(tag);
|
|
390
|
+
if (isIntrinsic) {
|
|
391
|
+
kind = INTRINSIC_KINDS[tag];
|
|
392
|
+
if (!kind) block(opening, "unmapped-element", `<${tag}> has no native mapping`);
|
|
393
|
+
} else if (opening.name.type === "JSXNamespacedName") {
|
|
394
|
+
block(opening, "unmapped-element", `<${tag}> has no native mapping`);
|
|
395
|
+
} else {
|
|
396
|
+
const root = tag.split(".")[0];
|
|
397
|
+
const binding = imported.get(root);
|
|
398
|
+
if (binding) {
|
|
399
|
+
const member = tag.includes(".") ? binding.name === "*" ? tag.split(".")[1] : "" : binding.name;
|
|
400
|
+
kind = _optionalChain([MAPPED_COMPONENTS, 'access', _13 => _13[binding.source], 'optionalAccess', _14 => _14[member]]);
|
|
401
|
+
if (!kind) {
|
|
402
|
+
const fromApp = /^(?:\.|\/|@\/|~|#)/.test(binding.source);
|
|
403
|
+
counted = !fromApp;
|
|
404
|
+
kind = fromApp || PORTABLE_PACKAGES.has(packageName(binding.source)) ? "Component" : void 0;
|
|
405
|
+
}
|
|
406
|
+
} else if (topLevel.has(root)) {
|
|
407
|
+
kind = "Component";
|
|
408
|
+
counted = false;
|
|
409
|
+
} else {
|
|
410
|
+
block(
|
|
411
|
+
opening,
|
|
412
|
+
"dynamic-component",
|
|
413
|
+
`<${tag}> is a value the analyzer cannot resolve to a component`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (counted) {
|
|
418
|
+
facts.elements.total += 1;
|
|
419
|
+
if (kind) facts.elements.mapped += 1;
|
|
420
|
+
if (kind && kind !== "Component" && kind !== "Fragment") {
|
|
421
|
+
facts.elements.byKind[kind] = (_nullishCoalesce(facts.elements.byKind[kind], () => ( 0))) + 1;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const node = { kind: _nullishCoalesce(kind, () => ( "View")), tag };
|
|
425
|
+
const props = {};
|
|
426
|
+
const style = [];
|
|
427
|
+
const events = [];
|
|
428
|
+
for (const attribute of opening.attributes) {
|
|
429
|
+
if (attribute.type === "JSXSpreadAttribute") {
|
|
430
|
+
if (isIntrinsic)
|
|
431
|
+
block(attribute, "spread-props", `spread props on <${tag}> cannot be checked`);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const name = attributeName(attribute);
|
|
435
|
+
const value = attribute.value;
|
|
436
|
+
if (name === "key") continue;
|
|
437
|
+
if (name === "dangerouslySetInnerHTML") {
|
|
438
|
+
block(attribute, "dangerously-set-inner-html", "dangerouslySetInnerHTML");
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (name === "contentEditable") {
|
|
442
|
+
block(attribute, "content-editable", "contentEditable");
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (name === "ref" && isIntrinsic) {
|
|
446
|
+
block(attribute, "dom-ref", `a ref on <${tag}> reaches the DOM`);
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if ((name === "action" || name === "formAction") && isIntrinsic) {
|
|
450
|
+
block(attribute, "form-action", `${name} on <${tag}>`);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (/^on[A-Z]/.test(name)) {
|
|
454
|
+
if (isIntrinsic && kind && !_optionalChain([MAPPED_EVENTS, 'access', _15 => _15[kind], 'optionalAccess', _16 => _16.has, 'call', _17 => _17(name)])) {
|
|
455
|
+
block(attribute, "dom-event", `${name} on <${tag}> has no native event`);
|
|
456
|
+
}
|
|
457
|
+
events.push(name);
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (name === "className" || name === "class") {
|
|
461
|
+
const classes = staticString(value);
|
|
462
|
+
if (classes === void 0) {
|
|
463
|
+
block(attribute, "runtime-class-name", `<${tag}> builds its class names at runtime`);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
for (const token of classes.split(/\s+/).filter(Boolean)) {
|
|
467
|
+
const problem = classifyClass(token);
|
|
468
|
+
if (problem) block(attribute, "class-name", problem);
|
|
469
|
+
else style.push(token);
|
|
470
|
+
}
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (name === "style") {
|
|
474
|
+
const expression = _optionalChain([value, 'optionalAccess', _18 => _18.type]) === "JSXExpressionContainer" ? value.expression : null;
|
|
475
|
+
if (!expression || expression.type !== "ObjectExpression") {
|
|
476
|
+
block(attribute, "runtime-style", `<${tag}> style is not an object literal`);
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
for (const property of expression.properties) {
|
|
480
|
+
if (property.type !== "Property" || property.computed) {
|
|
481
|
+
block(property, "runtime-style", `<${tag}> style has a spread or computed key`);
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
const key = _nullishCoalesce(property.key.name, () => ( property.key.value));
|
|
485
|
+
if (!STYLE_PROPERTIES.has(key)) {
|
|
486
|
+
block(property, "style", `style.${key} has no native mapping`);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
const literal2 = staticString(property.value);
|
|
490
|
+
if (literal2 !== void 0) {
|
|
491
|
+
if (STYLE_ENUMS[key] && !STYLE_ENUMS[key].has(literal2)) {
|
|
492
|
+
block(property, "style", `style.${key} "${literal2}" has no native mapping`);
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (STYLE_VALUE_BLOCK.test(literal2)) {
|
|
496
|
+
block(
|
|
497
|
+
property,
|
|
498
|
+
"style",
|
|
499
|
+
`style.${key} "${literal2}" uses a CSS-only unit or function`
|
|
500
|
+
);
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
} else if (STYLE_ENUMS[key] && property.value.type !== "Literal") {
|
|
504
|
+
block(property, "style", `style.${key} is computed at runtime`);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
style.push(`style.${key}`);
|
|
508
|
+
}
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (tag === "input" && name === "type") {
|
|
512
|
+
const type = staticString(value);
|
|
513
|
+
if (type === void 0 || !INPUT_TYPES.has(type)) {
|
|
514
|
+
block(
|
|
515
|
+
attribute,
|
|
516
|
+
"unmapped-element",
|
|
517
|
+
`<input type="${_nullishCoalesce(type, () => ( "{expr}"))}"> has no native mapping`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const literal = value === null ? true : staticString(value);
|
|
522
|
+
if (literal !== void 0) props[name] = literal;
|
|
523
|
+
else if (_optionalChain([value, 'optionalAccess', _19 => _19.type]) === "JSXExpressionContainer" && value.expression.type === "Literal" && (typeof value.expression.value === "number" || typeof value.expression.value === "boolean")) {
|
|
524
|
+
props[name] = value.expression.value;
|
|
525
|
+
} else props[name] = "{expr}";
|
|
526
|
+
}
|
|
527
|
+
if (kind === "TextInput" && events.some((event) => event === "onChange" || event === "onInput")) {
|
|
528
|
+
wins.add("input");
|
|
529
|
+
}
|
|
530
|
+
if (Object.keys(props).length > 0) node.props = props;
|
|
531
|
+
if (style.length > 0) node.style = style;
|
|
532
|
+
if (events.length > 0) node.events = events;
|
|
533
|
+
return node;
|
|
534
|
+
};
|
|
535
|
+
const append = (parent, child) => {
|
|
536
|
+
if (!parent) return;
|
|
537
|
+
(_nullishCoalesce(parent.children, () => ( (parent.children = [])))).push(child);
|
|
538
|
+
};
|
|
539
|
+
const visit = (node, parent) => {
|
|
540
|
+
if (!node || typeof node !== "object") return void 0;
|
|
541
|
+
switch (node.type) {
|
|
542
|
+
case "ImportDeclaration":
|
|
543
|
+
return void 0;
|
|
544
|
+
case "JSXElement": {
|
|
545
|
+
const ui = classifyElement(node);
|
|
546
|
+
for (const attribute of node.openingElement.attributes) {
|
|
547
|
+
visit(attribute.type === "JSXSpreadAttribute" ? attribute.argument : attribute.value);
|
|
548
|
+
}
|
|
549
|
+
visitChildren(node.children, ui);
|
|
550
|
+
append(parent, ui);
|
|
551
|
+
return ui;
|
|
552
|
+
}
|
|
553
|
+
case "JSXFragment": {
|
|
554
|
+
const ui = { kind: "Fragment", tag: "" };
|
|
555
|
+
visitChildren(node.children, ui);
|
|
556
|
+
append(parent, ui);
|
|
557
|
+
return ui;
|
|
558
|
+
}
|
|
559
|
+
case "JSXText": {
|
|
560
|
+
const text = node.value.replace(/\s+/g, " ").trim();
|
|
561
|
+
if (text && parent) parent.text = parent.text ? `${parent.text} ${text}` : text;
|
|
562
|
+
return void 0;
|
|
563
|
+
}
|
|
564
|
+
case "JSXExpressionContainer":
|
|
565
|
+
visit(node.expression, parent);
|
|
566
|
+
return void 0;
|
|
567
|
+
case "Identifier":
|
|
568
|
+
if (BROWSER_GLOBALS.has(node.name)) globalCandidates.push(node);
|
|
569
|
+
return void 0;
|
|
570
|
+
case "MemberExpression":
|
|
571
|
+
visit(node.object, parent);
|
|
572
|
+
if (node.computed) visit(node.property, parent);
|
|
573
|
+
return void 0;
|
|
574
|
+
case "Property":
|
|
575
|
+
case "PropertyDefinition":
|
|
576
|
+
case "MethodDefinition":
|
|
577
|
+
if (node.computed) visit(node.key, parent);
|
|
578
|
+
visit(node.value, parent);
|
|
579
|
+
return void 0;
|
|
580
|
+
case "LabeledStatement":
|
|
581
|
+
visit(node.body, parent);
|
|
582
|
+
return void 0;
|
|
583
|
+
case "BreakStatement":
|
|
584
|
+
case "ContinueStatement":
|
|
585
|
+
return void 0;
|
|
586
|
+
case "VariableDeclarator":
|
|
587
|
+
collectPatternNames(node.id, declared);
|
|
588
|
+
visit(node.init, parent);
|
|
589
|
+
visitPatternDefaults(node.id, parent);
|
|
590
|
+
return void 0;
|
|
591
|
+
case "FunctionDeclaration":
|
|
592
|
+
case "FunctionExpression":
|
|
593
|
+
case "ArrowFunctionExpression":
|
|
594
|
+
if (node.id) declared.add(node.id.name);
|
|
595
|
+
for (const param of node.params) {
|
|
596
|
+
collectPatternNames(param, declared);
|
|
597
|
+
visitPatternDefaults(param, parent);
|
|
598
|
+
}
|
|
599
|
+
visit(node.body, parent);
|
|
600
|
+
return void 0;
|
|
601
|
+
case "ClassDeclaration":
|
|
602
|
+
case "ClassExpression":
|
|
603
|
+
if (node.id) declared.add(node.id.name);
|
|
604
|
+
visit(node.superClass, parent);
|
|
605
|
+
visit(node.body, parent);
|
|
606
|
+
return void 0;
|
|
607
|
+
case "CatchClause":
|
|
608
|
+
collectPatternNames(node.param, declared);
|
|
609
|
+
visit(node.body, parent);
|
|
610
|
+
return void 0;
|
|
611
|
+
case "CallExpression": {
|
|
612
|
+
const callee = node.callee;
|
|
613
|
+
const calleeName = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && !callee.computed ? callee.property.name : void 0;
|
|
614
|
+
if (calleeName === "useLayoutEffect" || calleeName === "useInsertionEffect") {
|
|
615
|
+
block(node, "layout-effect", `${calleeName} reads layout from the DOM`);
|
|
616
|
+
}
|
|
617
|
+
if (calleeName === "createElement" || calleeName === "cloneElement") {
|
|
618
|
+
block(
|
|
619
|
+
node,
|
|
620
|
+
"create-element",
|
|
621
|
+
`${calleeName}() builds elements the analyzer cannot check`
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
if (calleeName === "setInterval") wins.add("timer");
|
|
625
|
+
if (callee.type === "Identifier" && SERVER_FN_FACTORIES.has(callee.name)) {
|
|
626
|
+
const binding = imported.get(callee.name);
|
|
627
|
+
if (_optionalChain([binding, 'optionalAccess', _20 => _20.source, 'access', _21 => _21.startsWith, 'call', _22 => _22("@farm.js/core")])) callsServerFactory = true;
|
|
628
|
+
}
|
|
629
|
+
if (calleeName === "map" && callee.type === "MemberExpression" && parent) {
|
|
630
|
+
const before = facts.elements.total;
|
|
631
|
+
visit(callee.object, parent);
|
|
632
|
+
for (const argument of node.arguments) visit(argument, parent);
|
|
633
|
+
if (facts.elements.total > before) wins.add("list");
|
|
634
|
+
return void 0;
|
|
635
|
+
}
|
|
636
|
+
visit(callee, parent);
|
|
637
|
+
for (const argument of node.arguments) visit(argument, parent);
|
|
638
|
+
return void 0;
|
|
639
|
+
}
|
|
640
|
+
case "ImportExpression": {
|
|
641
|
+
const specifier = staticString(node.source);
|
|
642
|
+
facts.imports.push({
|
|
643
|
+
source: _nullishCoalesce(specifier, () => ( "")),
|
|
644
|
+
...locate(starts, node.start),
|
|
645
|
+
names: ["*"],
|
|
646
|
+
dynamic: true,
|
|
647
|
+
...specifier === void 0 ? { computed: true } : {}
|
|
648
|
+
});
|
|
649
|
+
if (specifier === void 0) visit(node.source, parent);
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if (node.type.startsWith("TS")) {
|
|
654
|
+
if (node.expression) visit(node.expression, parent);
|
|
655
|
+
return void 0;
|
|
656
|
+
}
|
|
657
|
+
for (const key in node) {
|
|
658
|
+
if (SKIP_KEYS.has(key)) continue;
|
|
659
|
+
const value = node[key];
|
|
660
|
+
if (Array.isArray(value)) {
|
|
661
|
+
for (const item of value) if (item && typeof item.type === "string") visit(item, parent);
|
|
662
|
+
} else if (value && typeof value.type === "string") {
|
|
663
|
+
visit(value, parent);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return void 0;
|
|
667
|
+
};
|
|
668
|
+
const visitChildren = (children, parent) => {
|
|
669
|
+
_nullishCoalesce(parent.children, () => ( (parent.children = [])));
|
|
670
|
+
for (const child of children) visit(child, parent);
|
|
671
|
+
if (parent.children.length === 0) delete parent.children;
|
|
672
|
+
};
|
|
673
|
+
const visitPatternDefaults = (pattern, parent) => {
|
|
674
|
+
if (!pattern) return;
|
|
675
|
+
if (pattern.type === "AssignmentPattern") visit(pattern.right, parent);
|
|
676
|
+
else if (pattern.type === "ObjectPattern") {
|
|
677
|
+
for (const property of pattern.properties) {
|
|
678
|
+
visitPatternDefaults(
|
|
679
|
+
property.type === "RestElement" ? property.argument : property.value,
|
|
680
|
+
parent
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
} else if (pattern.type === "ArrayPattern") {
|
|
684
|
+
for (const element of pattern.elements) visitPatternDefaults(element, parent);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
for (const statement of program.body) {
|
|
688
|
+
if (statement.type === "ImportDeclaration") continue;
|
|
689
|
+
const isDefault = statement.type === "ExportDefaultDeclaration";
|
|
690
|
+
const declaration = statement.type === "ExportNamedDeclaration" || isDefault ? statement.declaration : statement;
|
|
691
|
+
const roots = [];
|
|
692
|
+
if (_optionalChain([declaration, 'optionalAccess', _23 => _23.type]) === "FunctionDeclaration" || isDefault && /Function/.test(_nullishCoalesce(_optionalChain([declaration, 'optionalAccess', _24 => _24.type]), () => ( "")))) {
|
|
693
|
+
roots.push([isDefault ? "default" : declaration.id.name, declaration]);
|
|
694
|
+
} else if (_optionalChain([declaration, 'optionalAccess', _25 => _25.type]) === "VariableDeclaration") {
|
|
695
|
+
for (const declarator of declaration.declarations) {
|
|
696
|
+
if (declarator.id.type === "Identifier" && /Function/.test(_nullishCoalesce(_optionalChain([declarator, 'access', _26 => _26.init, 'optionalAccess', _27 => _27.type]), () => ( "")))) {
|
|
697
|
+
roots.push([declarator.id.name, declarator]);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (roots.length === 0) {
|
|
702
|
+
visit(statement);
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
for (const [name, root] of roots) {
|
|
706
|
+
const holder = { kind: "Fragment", tag: name, children: [] };
|
|
707
|
+
visit(root, holder);
|
|
708
|
+
if (holder.children.length > 0) {
|
|
709
|
+
facts.components[name] = holder.children.length === 1 ? holder.children[0] : holder;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (isDefault && _optionalChain([declaration, 'optionalAccess', _28 => _28.type]) === "Identifier") {
|
|
713
|
+
facts.components.default = { kind: "Component", tag: declaration.name };
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
blockGlobalsLater();
|
|
717
|
+
if (defaultName && asyncFunctions.has(defaultName)) facts.asyncDefault = true;
|
|
718
|
+
if (callsServerFactory) facts.serverBoundary = true;
|
|
719
|
+
facts.wins = [...wins].sort();
|
|
720
|
+
facts.blockers.sort((left, right) => left.line - right.line || left.column - right.column);
|
|
721
|
+
return facts;
|
|
722
|
+
}
|
|
723
|
+
function readAliases(root, srcDir) {
|
|
724
|
+
const aliases = [{ prefix: "@/", targets: [path.join(root, srcDir) + path.sep] }];
|
|
725
|
+
try {
|
|
726
|
+
const raw = _fs.readFileSync.call(void 0, path.join(root, "tsconfig.json"), "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:"'])\/\/.*$/gm, "$1").replace(/,(\s*[}\]])/g, "$1");
|
|
727
|
+
const options = _nullishCoalesce(JSON.parse(raw).compilerOptions, () => ( {}));
|
|
728
|
+
const base = path.resolve(root, _nullishCoalesce(options.baseUrl, () => ( ".")));
|
|
729
|
+
for (const [key, values] of Object.entries(_nullishCoalesce(options.paths, () => ( {})))) {
|
|
730
|
+
const prefix = key.replace(/\*$/, "");
|
|
731
|
+
aliases.push({
|
|
732
|
+
prefix,
|
|
733
|
+
targets: values.map((value) => path.join(base, value.replace(/\*$/, "")))
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
} catch (e) {
|
|
737
|
+
}
|
|
738
|
+
return aliases.sort((left, right) => right.prefix.length - left.prefix.length);
|
|
739
|
+
}
|
|
740
|
+
function isFile(file) {
|
|
741
|
+
try {
|
|
742
|
+
return _fs.statSync.call(void 0, file).isFile();
|
|
743
|
+
} catch (e2) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function resolveFile(base) {
|
|
748
|
+
if (isFile(base)) return base;
|
|
749
|
+
for (const extension of SCRIPT_EXTENSIONS) if (isFile(base + extension)) return base + extension;
|
|
750
|
+
const withoutJs = base.replace(/\.(?:js|jsx|mjs)$/, "");
|
|
751
|
+
if (withoutJs !== base) {
|
|
752
|
+
for (const extension of [".ts", ".tsx"])
|
|
753
|
+
if (isFile(withoutJs + extension)) return withoutJs + extension;
|
|
754
|
+
}
|
|
755
|
+
for (const extension of SCRIPT_EXTENSIONS) {
|
|
756
|
+
const index = path.join(base, `index${extension}`);
|
|
757
|
+
if (isFile(index)) return index;
|
|
758
|
+
}
|
|
759
|
+
return void 0;
|
|
760
|
+
}
|
|
761
|
+
function packageName(specifier) {
|
|
762
|
+
const parts = specifier.split("/");
|
|
763
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
764
|
+
}
|
|
765
|
+
function classifyPackage(fact, serverBoundary) {
|
|
766
|
+
const at = { line: fact.line, column: fact.column };
|
|
767
|
+
const specifier = fact.source;
|
|
768
|
+
if (specifier.startsWith("node:") || NODE_BUILTINS.has(packageName(specifier))) {
|
|
769
|
+
return serverBoundary ? void 0 : { ...at, rule: "node-builtin", message: `import "${specifier}" is a Node.js API` };
|
|
770
|
+
}
|
|
771
|
+
if (specifier.startsWith("@farm.js/core")) {
|
|
772
|
+
const portable = CORE_PORTABLE[specifier];
|
|
773
|
+
const unmapped = fact.names.filter((name2) => !_optionalChain([portable, 'optionalAccess', _29 => _29.has, 'call', _30 => _30(name2)]));
|
|
774
|
+
if (unmapped.length > 0 || !portable) {
|
|
775
|
+
return {
|
|
776
|
+
...at,
|
|
777
|
+
rule: "unmapped-import",
|
|
778
|
+
message: `${unmapped.join(", ") || "import"} from "${specifier}" has no native mapping`
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
return void 0;
|
|
782
|
+
}
|
|
783
|
+
const name = packageName(specifier);
|
|
784
|
+
if (name === "react") {
|
|
785
|
+
return specifier === "react" || specifier === "react/jsx-runtime" || specifier === "react/jsx-dev-runtime" ? void 0 : { ...at, rule: "unknown-package", message: `import "${specifier}" has no native mapping` };
|
|
786
|
+
}
|
|
787
|
+
if (PORTABLE_PACKAGES.has(name)) return void 0;
|
|
788
|
+
if (DOM_PACKAGES.some(
|
|
789
|
+
(entry) => entry.endsWith("/") || entry.endsWith("-") ? specifier.startsWith(entry) : name === entry
|
|
790
|
+
)) {
|
|
791
|
+
return { ...at, rule: "dom-package", message: `import "${specifier}" renders to the DOM` };
|
|
792
|
+
}
|
|
793
|
+
return {
|
|
794
|
+
...at,
|
|
795
|
+
rule: "unknown-package",
|
|
796
|
+
message: `import "${specifier}" has no native mapping`
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
var NODE_BUILTINS = new Set(
|
|
800
|
+
"assert buffer child_process cluster crypto dgram dns events fs http http2 https module net os path perf_hooks process querystring readline stream string_decoder timers tls tty url util v8 vm worker_threads zlib".split(" ")
|
|
801
|
+
);
|
|
802
|
+
function relative2(root, file) {
|
|
803
|
+
return path.relative(root, file).split(path.sep).join("/");
|
|
804
|
+
}
|
|
805
|
+
var LAYOUT_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
806
|
+
function layoutChain(appDir, pageFile, layoutByDir) {
|
|
807
|
+
const layouts = [];
|
|
808
|
+
let dir = path.dirname(pageFile);
|
|
809
|
+
for (; ; ) {
|
|
810
|
+
let layout = layoutByDir.get(dir);
|
|
811
|
+
if (layout === void 0) {
|
|
812
|
+
const replaced = LAYOUT_EXTENSIONS.some(
|
|
813
|
+
(extension) => _fs.existsSync.call(void 0, path.join(dir, `layout.native${extension}`))
|
|
814
|
+
);
|
|
815
|
+
layout = replaced ? null : _nullishCoalesce(LAYOUT_EXTENSIONS.map((extension) => path.join(dir, `layout${extension}`)).find(
|
|
816
|
+
(file) => _fs.existsSync.call(void 0, file)
|
|
817
|
+
), () => ( null));
|
|
818
|
+
layoutByDir.set(dir, layout);
|
|
819
|
+
}
|
|
820
|
+
if (layout) layouts.unshift(layout);
|
|
821
|
+
if (path.resolve(dir) === path.resolve(appDir) || path.dirname(dir) === dir) break;
|
|
822
|
+
dir = path.dirname(dir);
|
|
823
|
+
}
|
|
824
|
+
return layouts;
|
|
825
|
+
}
|
|
826
|
+
async function analyzeFarmMobileRoutes(options) {
|
|
827
|
+
const started = performance.now();
|
|
828
|
+
const root = path.resolve(options.root);
|
|
829
|
+
const srcDir = options.srcDir || "src";
|
|
830
|
+
const aliases = readAliases(root, srcDir);
|
|
831
|
+
const { parseSync } = await import("rolldown/utils");
|
|
832
|
+
let cache = { version: ANALYZER_VERSION, modules: {} };
|
|
833
|
+
if (options.cacheFile) {
|
|
834
|
+
try {
|
|
835
|
+
const stored = JSON.parse(await _promises.readFile.call(void 0, options.cacheFile, "utf8"));
|
|
836
|
+
if (stored.version === ANALYZER_VERSION && stored.modules) cache = stored;
|
|
837
|
+
} catch (e3) {
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const used = {};
|
|
841
|
+
let parsed = 0;
|
|
842
|
+
let cached = 0;
|
|
843
|
+
const facts = /* @__PURE__ */ new Map();
|
|
844
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
845
|
+
const loadFacts = (file) => {
|
|
846
|
+
let pending = facts.get(file);
|
|
847
|
+
if (!pending) {
|
|
848
|
+
pending = _promises.readFile.call(void 0, file, "utf8").then((source) => {
|
|
849
|
+
const hash = _crypto.createHash.call(void 0, "sha1").update(file.endsWith(".tsx") ? "tsx\0" : file.endsWith(".ts") ? "ts\0" : "jsx\0").update(source).digest("hex");
|
|
850
|
+
let result = cache.modules[hash];
|
|
851
|
+
if (result) cached += 1;
|
|
852
|
+
else {
|
|
853
|
+
result = analyzeSource(file, source, parseSync);
|
|
854
|
+
parsed += 1;
|
|
855
|
+
}
|
|
856
|
+
used[hash] = result;
|
|
857
|
+
return result;
|
|
858
|
+
});
|
|
859
|
+
facts.set(file, pending);
|
|
860
|
+
}
|
|
861
|
+
return pending;
|
|
862
|
+
};
|
|
863
|
+
const resolveImport = (from, fact, moduleFacts) => {
|
|
864
|
+
const at = { line: fact.line, column: fact.column };
|
|
865
|
+
if (fact.computed) {
|
|
866
|
+
return {
|
|
867
|
+
fact,
|
|
868
|
+
blocker: {
|
|
869
|
+
...at,
|
|
870
|
+
rule: "dynamic-import",
|
|
871
|
+
message: "import() of a computed specifier cannot be followed"
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
const specifier = fact.source;
|
|
876
|
+
let candidates;
|
|
877
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
878
|
+
candidates = [
|
|
879
|
+
specifier.startsWith("/") ? path.join(root, specifier) : path.resolve(path.dirname(from), specifier)
|
|
880
|
+
];
|
|
881
|
+
} else {
|
|
882
|
+
const alias = aliases.find(
|
|
883
|
+
(entry) => specifier.startsWith(entry.prefix) || specifier === entry.prefix.replace(/\/$/, "")
|
|
884
|
+
);
|
|
885
|
+
if (alias) {
|
|
886
|
+
candidates = alias.targets.map(
|
|
887
|
+
(target) => path.join(target, specifier.slice(alias.prefix.length))
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (!candidates) {
|
|
892
|
+
if (STYLE_FILE.test(specifier)) {
|
|
893
|
+
return {
|
|
894
|
+
fact,
|
|
895
|
+
blocker: { ...at, rule: "css-import", message: `import "${specifier}" is a stylesheet` }
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
const blocker = classifyPackage(fact, moduleFacts.serverBoundary);
|
|
899
|
+
return blocker ? { fact, blocker } : { fact };
|
|
900
|
+
}
|
|
901
|
+
if (STYLE_FILE.test(specifier)) {
|
|
902
|
+
return {
|
|
903
|
+
fact,
|
|
904
|
+
blocker: { ...at, rule: "css-import", message: `import "${specifier}" is a stylesheet` }
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
if (ASSET_FILE.test(specifier)) return { fact };
|
|
908
|
+
for (const candidate of candidates) {
|
|
909
|
+
const file = resolveFile(candidate);
|
|
910
|
+
if (file) {
|
|
911
|
+
if (ASSET_FILE.test(file)) return { fact };
|
|
912
|
+
if (STYLE_FILE.test(file)) {
|
|
913
|
+
return {
|
|
914
|
+
fact,
|
|
915
|
+
blocker: {
|
|
916
|
+
...at,
|
|
917
|
+
rule: "css-import",
|
|
918
|
+
message: `import "${specifier}" is a stylesheet`
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
if (!SCRIPT_EXTENSIONS.some((extension) => file.endsWith(extension))) {
|
|
923
|
+
return {
|
|
924
|
+
fact,
|
|
925
|
+
blocker: {
|
|
926
|
+
...at,
|
|
927
|
+
rule: "unresolved-import",
|
|
928
|
+
message: `import "${specifier}" is not a script module`
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
return { fact, file };
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return {
|
|
936
|
+
fact,
|
|
937
|
+
blocker: { ...at, rule: "unresolved-import", message: `import "${specifier}" was not found` }
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
const visitModule = async (file) => {
|
|
941
|
+
if (resolved.has(file)) return;
|
|
942
|
+
resolved.set(file, []);
|
|
943
|
+
const moduleFacts = await loadFacts(file);
|
|
944
|
+
const imports = moduleFacts.imports.map((fact) => resolveImport(file, fact, moduleFacts));
|
|
945
|
+
resolved.set(file, imports);
|
|
946
|
+
if (moduleFacts.serverBoundary) return;
|
|
947
|
+
await Promise.all(imports.map((entry) => entry.file ? visitModule(entry.file) : void 0));
|
|
948
|
+
};
|
|
949
|
+
const appDir = path.join(root, srcDir, "app");
|
|
950
|
+
const entries = /* @__PURE__ */ new Map();
|
|
951
|
+
const layoutByDir = /* @__PURE__ */ new Map();
|
|
952
|
+
for (const route of options.routes) {
|
|
953
|
+
const page = options.pageFiles.get(route);
|
|
954
|
+
entries.set(route, { page, layouts: page ? layoutChain(appDir, page, layoutByDir) : [] });
|
|
955
|
+
}
|
|
956
|
+
const scripts = /* @__PURE__ */ new Set();
|
|
957
|
+
for (const { page, layouts } of entries.values()) {
|
|
958
|
+
for (const file of [page, ...layouts]) {
|
|
959
|
+
if (file && SCRIPT_EXTENSIONS.some((extension) => file.endsWith(extension)))
|
|
960
|
+
scripts.add(file);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
await Promise.all([...scripts].map(visitModule));
|
|
964
|
+
const settled = /* @__PURE__ */ new Map();
|
|
965
|
+
for (const [file, pending] of facts) settled.set(file, await pending);
|
|
966
|
+
const routes = {};
|
|
967
|
+
for (const [route, { page, layouts }] of entries) {
|
|
968
|
+
const blockers = [];
|
|
969
|
+
const wins = /* @__PURE__ */ new Set();
|
|
970
|
+
const elements = { total: 0, mapped: 0, byKind: {} };
|
|
971
|
+
const seen = /* @__PURE__ */ new Set();
|
|
972
|
+
const ir = { root: "", components: {} };
|
|
973
|
+
const walk = (file, entry) => {
|
|
974
|
+
if (seen.has(file)) return;
|
|
975
|
+
seen.add(file);
|
|
976
|
+
const moduleFacts = settled.get(file);
|
|
977
|
+
const label = relative2(root, file);
|
|
978
|
+
if (entry && options.serverComponents && !moduleFacts.useClient) {
|
|
979
|
+
blockers.push({
|
|
980
|
+
file: label,
|
|
981
|
+
line: 1,
|
|
982
|
+
column: 1,
|
|
983
|
+
rule: "server-component",
|
|
984
|
+
message: 'a server component (no "use client") renders on the server'
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
if (entry && moduleFacts.asyncDefault) {
|
|
988
|
+
blockers.push({
|
|
989
|
+
file: label,
|
|
990
|
+
line: 1,
|
|
991
|
+
column: 1,
|
|
992
|
+
rule: "async-component",
|
|
993
|
+
message: "an async component renders on the server"
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
if (moduleFacts.serverBoundary && !entry) return;
|
|
997
|
+
for (const blocker of moduleFacts.blockers) blockers.push({ file: label, ...blocker });
|
|
998
|
+
for (const win of moduleFacts.wins) wins.add(win);
|
|
999
|
+
elements.total += moduleFacts.elements.total;
|
|
1000
|
+
elements.mapped += moduleFacts.elements.mapped;
|
|
1001
|
+
for (const [kind, count] of Object.entries(moduleFacts.elements.byKind)) {
|
|
1002
|
+
elements.byKind[kind] = (_nullishCoalesce(elements.byKind[kind], () => ( 0))) + count;
|
|
1003
|
+
}
|
|
1004
|
+
for (const [name, node] of Object.entries(moduleFacts.components)) {
|
|
1005
|
+
ir.components[`${label}#${name}`] = node;
|
|
1006
|
+
}
|
|
1007
|
+
for (const entryImport of _nullishCoalesce(resolved.get(file), () => ( []))) {
|
|
1008
|
+
if (entryImport.blocker) blockers.push({ file: label, ...entryImport.blocker });
|
|
1009
|
+
if (entryImport.file) walk(entryImport.file, false);
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
if (!page) {
|
|
1013
|
+
blockers.push({
|
|
1014
|
+
file: "",
|
|
1015
|
+
line: 0,
|
|
1016
|
+
column: 0,
|
|
1017
|
+
rule: "programmatic-route",
|
|
1018
|
+
message: "a programmatic route has no page file to analyze"
|
|
1019
|
+
});
|
|
1020
|
+
} else if (/\.(?:md|mdx)$/.test(page)) {
|
|
1021
|
+
blockers.push({
|
|
1022
|
+
file: relative2(root, page),
|
|
1023
|
+
line: 1,
|
|
1024
|
+
column: 1,
|
|
1025
|
+
rule: "markdown-page",
|
|
1026
|
+
message: "a Markdown page renders HTML from Markdown"
|
|
1027
|
+
});
|
|
1028
|
+
} else {
|
|
1029
|
+
walk(page, true);
|
|
1030
|
+
ir.root = `${relative2(root, page)}#default`;
|
|
1031
|
+
}
|
|
1032
|
+
for (const layout of layouts) walk(layout, true);
|
|
1033
|
+
const portable = blockers.length === 0;
|
|
1034
|
+
const sortedWins = [...wins].sort();
|
|
1035
|
+
const analysis = {
|
|
1036
|
+
route,
|
|
1037
|
+
decision: portable && sortedWins.length > 0 ? "port" : "web",
|
|
1038
|
+
portable,
|
|
1039
|
+
blockers,
|
|
1040
|
+
wins: sortedWins,
|
|
1041
|
+
elements,
|
|
1042
|
+
portablePercent: elements.total === 0 ? portable ? 100 : 0 : Math.round(elements.mapped / elements.total * 100),
|
|
1043
|
+
modules: seen.size
|
|
1044
|
+
};
|
|
1045
|
+
if (portable) {
|
|
1046
|
+
analysis.ir = ir;
|
|
1047
|
+
analysis.irBytes = Buffer.byteLength(JSON.stringify(ir));
|
|
1048
|
+
}
|
|
1049
|
+
routes[route] = analysis;
|
|
1050
|
+
}
|
|
1051
|
+
if (options.cacheFile) {
|
|
1052
|
+
await _promises.mkdir.call(void 0, path.dirname(options.cacheFile), { recursive: true });
|
|
1053
|
+
await _promises.writeFile.call(void 0,
|
|
1054
|
+
options.cacheFile,
|
|
1055
|
+
JSON.stringify({ version: ANALYZER_VERSION, modules: used })
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
return {
|
|
1059
|
+
routes,
|
|
1060
|
+
stats: { modules: facts.size, parsed, cached, ms: Math.round(performance.now() - started) }
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
exports.CORE_PORTABLE = CORE_PORTABLE; exports.analyzeFarmMobileRoutes = analyzeFarmMobileRoutes;
|