@timber-js/app 0.2.0-alpha.222 → 0.2.0-alpha.224
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/agent-skill.md +21 -5
- package/dist/_chunks/{actions-vBHr2vqd.js → actions-7dTXYJfu.js} +53 -24
- package/dist/_chunks/actions-7dTXYJfu.js.map +1 -0
- package/dist/_chunks/{als-registry-BZqHCtq-.js → als-registry-DpygwCp0.js} +2 -3
- package/dist/_chunks/{als-registry-BZqHCtq-.js.map → als-registry-DpygwCp0.js.map} +1 -1
- package/dist/_chunks/{als-slots-BEEIPKYm.js → als-slots-kbQrHTzm.js} +2 -3
- package/dist/_chunks/{als-slots-BEEIPKYm.js.map → als-slots-kbQrHTzm.js.map} +1 -1
- package/dist/_chunks/{base-path-DaQrzbez.js → base-path-DDIx0FXe.js} +2 -3
- package/dist/_chunks/{base-path-DaQrzbez.js.map → base-path-DDIx0FXe.js.map} +1 -1
- package/dist/_chunks/{build-manifest-DWppEdLB.js → build-manifest-Y4jl7nwU.js} +2 -3
- package/dist/_chunks/{build-manifest-DWppEdLB.js.map → build-manifest-Y4jl7nwU.js.map} +1 -1
- package/dist/_chunks/{build-output-helper-RV_BRcF1.js → build-output-helper-B7wWGTfR.js} +14 -10
- package/dist/_chunks/build-output-helper-B7wWGTfR.js.map +1 -0
- package/dist/_chunks/{cache-api-DdcDLpBj.js → cache-api-TDZ4hlDc.js} +190 -38
- package/dist/_chunks/cache-api-TDZ4hlDc.js.map +1 -0
- package/dist/_chunks/{canonicalize-BAWkWiKK.js → canonicalize-CqK135BN.js} +29 -4
- package/dist/_chunks/{canonicalize-BAWkWiKK.js.map → canonicalize-CqK135BN.js.map} +1 -1
- package/dist/_chunks/chains-CwOr3Myj.js +1 -0
- package/dist/_chunks/{chains-BchW_AtW.js → chains-Dgm3PrMe.js} +3 -4
- package/dist/_chunks/{chains-BchW_AtW.js.map → chains-Dgm3PrMe.js.map} +1 -1
- package/dist/_chunks/{classify-IqzMpxMs.js → classify--_kINHQV.js} +4 -5
- package/dist/_chunks/{classify-IqzMpxMs.js.map → classify--_kINHQV.js.map} +1 -1
- package/dist/_chunks/{cli-check-DQne_YhU.js → cli-check-Dv3f8d2j.js} +5 -6
- package/dist/_chunks/{cli-check-DQne_YhU.js.map → cli-check-Dv3f8d2j.js.map} +1 -1
- package/dist/_chunks/{cli-context-_mPttGGY.js → cli-context-CbZp32SK.js} +3 -4
- package/dist/_chunks/{cli-context-_mPttGGY.js.map → cli-context-CbZp32SK.js.map} +1 -1
- package/dist/_chunks/cli-context-n5hmkdla.js +1 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js +138 -0
- package/dist/_chunks/cli-dev-status-prPMLU8G.js.map +1 -0
- package/dist/_chunks/cli-init-BoXOYYil.js +196 -0
- package/dist/_chunks/cli-init-BoXOYYil.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js → cli-schema-sync-DIPurq7X.js} +4 -5
- package/dist/_chunks/{cli-schema-sync-BS-RFGE2.js.map → cli-schema-sync-DIPurq7X.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-v872sHms.js → cli-schema-sync-uq72EZmD.js} +1 -1
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js → client-dep-entries-CP7AkMCM.js} +4 -5
- package/dist/_chunks/{client-dep-entries-BJyP9SIu.js.map → client-dep-entries-CP7AkMCM.js.map} +1 -1
- package/dist/_chunks/{cloudflare-Byxl8FWP.js → cloudflare-B75X6u4O.js} +10 -13
- package/dist/_chunks/{cloudflare-Byxl8FWP.js.map → cloudflare-B75X6u4O.js.map} +1 -1
- package/dist/_chunks/{codec-registry-oOUxugz3.js → codec-registry-CPc6bjVl.js} +2 -3
- package/dist/_chunks/{codec-registry-oOUxugz3.js.map → codec-registry-CPc6bjVl.js.map} +1 -1
- package/dist/_chunks/{codegen-Bps1sLKJ.js → codegen-B9oWkWGf.js} +5 -8
- package/dist/_chunks/{codegen-Bps1sLKJ.js.map → codegen-B9oWkWGf.js.map} +1 -1
- package/dist/_chunks/{convention-lint-VwzrtjIt.js → convention-lint-hZwz5wd4.js} +8 -11
- package/dist/_chunks/{convention-lint-VwzrtjIt.js.map → convention-lint-hZwz5wd4.js.map} +1 -1
- package/dist/_chunks/dev-discovery-YnabkCKD.js +238 -0
- package/dist/_chunks/dev-discovery-YnabkCKD.js.map +1 -0
- package/dist/_chunks/{dev-server-BNr5drEO.js → dev-server-B7o4As0l.js} +383 -55
- package/dist/_chunks/dev-server-B7o4As0l.js.map +1 -0
- package/dist/_chunks/dev-server-hZzmbMvK.js +1 -0
- package/dist/_chunks/{dev-store-BOa304m_.js → dev-store-BvdqtHvK.js} +82 -38
- package/dist/_chunks/dev-store-BvdqtHvK.js.map +1 -0
- package/dist/_chunks/{dist-DtrJyBbw.js → dist-C1Rjlo6s.js} +3 -5
- package/dist/_chunks/{dist-DtrJyBbw.js.map → dist-C1Rjlo6s.js.map} +1 -1
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js → error-boundary-DRQXGWCp.js} +20 -27
- package/dist/_chunks/{error-boundary-Bc8QPZuq.js.map → error-boundary-DRQXGWCp.js.map} +1 -1
- package/dist/_chunks/{fast-hash-C-tVYrLb.js → fast-hash-DddxkU5Y.js} +2 -3
- package/dist/_chunks/{fast-hash-C-tVYrLb.js.map → fast-hash-DddxkU5Y.js.map} +1 -1
- package/dist/_chunks/{flight-source-node-BdHUOUqg.js → flight-source-node-0Tp6evlz.js} +6 -8
- package/dist/_chunks/flight-source-node-0Tp6evlz.js.map +1 -0
- package/dist/_chunks/{format-BKclgVbk.js → format-DuPOoXUP.js} +2 -3
- package/dist/_chunks/{format-BKclgVbk.js.map → format-DuPOoXUP.js.map} +1 -1
- package/dist/_chunks/{fs-identity-BRKuL215.js → fs-identity-BmQ_Agg-.js} +3 -5
- package/dist/_chunks/{fs-identity-BRKuL215.js.map → fs-identity-BmQ_Agg-.js.map} +1 -1
- package/dist/_chunks/{global-context-B9PFncvb.js → global-context-DbxNWeBP.js} +2 -3
- package/dist/_chunks/{global-context-B9PFncvb.js.map → global-context-DbxNWeBP.js.map} +1 -1
- package/dist/_chunks/{graph-cache-CYiUS2aS.js → graph-cache-B1LAg4t7.js} +5 -89
- package/dist/_chunks/graph-cache-B1LAg4t7.js.map +1 -0
- package/dist/_chunks/{href-validation-BIrxavIy.js → href-validation-CEZy1V-k.js} +4 -7
- package/dist/_chunks/{href-validation-BIrxavIy.js.map → href-validation-CEZy1V-k.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js → json-lossy-check-DVkLUlfC.js} +3 -4
- package/dist/_chunks/{json-lossy-check-C3Sht92C.js.map → json-lossy-check-DVkLUlfC.js.map} +1 -1
- package/dist/_chunks/{live-graph-DEu_GWbc.js → live-graph-BcVjQ1Te.js} +6 -7
- package/dist/_chunks/{live-graph-DEu_GWbc.js.map → live-graph-BcVjQ1Te.js.map} +1 -1
- package/dist/_chunks/{logger-CI_hThfy.js → logger-CWk44DLp.js} +89 -47
- package/dist/_chunks/logger-CWk44DLp.js.map +1 -0
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js → metadata-routes-BL26HCDd.js} +2 -3
- package/dist/_chunks/{metadata-routes-B3XJNyIH.js.map → metadata-routes-BL26HCDd.js.map} +1 -1
- package/dist/_chunks/{navigation-root-BQfo1-kG.js → navigation-root-M3B2ZrdO.js} +6 -10
- package/dist/_chunks/{navigation-root-BQfo1-kG.js.map → navigation-root-M3B2ZrdO.js.map} +1 -1
- package/dist/_chunks/{node-response-bF0bKoig.js → node-response-B9aviPDa.js} +43 -9
- package/dist/_chunks/node-response-B9aviPDa.js.map +1 -0
- package/dist/_chunks/{param-value-C8TNYchQ.js → param-value-DqlGfF57.js} +2 -3
- package/dist/_chunks/{param-value-C8TNYchQ.js.map → param-value-DqlGfF57.js.map} +1 -1
- package/dist/_chunks/{plugin-context-uDHFqHHJ.js → plugin-context-BfSRKJfz.js} +1 -1
- package/dist/_chunks/{plugin-context-DxMMvjUt.js → plugin-context-FCkaNLUB.js} +4 -6
- package/dist/_chunks/plugin-context-FCkaNLUB.js.map +1 -0
- package/dist/_chunks/{poison-rules-DoEhbqaY.js → poison-rules-Bmz-lCPi.js} +2 -3
- package/dist/_chunks/{poison-rules-DoEhbqaY.js.map → poison-rules-Bmz-lCPi.js.map} +1 -1
- package/dist/_chunks/{poison-scan-DTWIfNgD.js → poison-scan-DJYxZc_7.js} +4 -5
- package/dist/_chunks/{poison-scan-DTWIfNgD.js.map → poison-scan-DJYxZc_7.js.map} +1 -1
- package/dist/_chunks/{purge-store-WZaxu-3m.js → purge-store-8BqLAYZ1.js} +2 -3
- package/dist/_chunks/{purge-store-WZaxu-3m.js.map → purge-store-8BqLAYZ1.js.map} +1 -1
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js → render-timeout-MrrqD1wd.js} +2 -3
- package/dist/_chunks/{render-timeout-Ln_u7fX-.js.map → render-timeout-MrrqD1wd.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-CkAInout.js → resolve-schema-B-aCuTu3.js} +3 -4
- package/dist/_chunks/{resolve-schema-CkAInout.js.map → resolve-schema-B-aCuTu3.js.map} +1 -1
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js → rsc-cache-key-D0cb0Gmc.js} +2 -3
- package/dist/_chunks/{rsc-cache-key-ClUiXQnK.js.map → rsc-cache-key-D0cb0Gmc.js.map} +1 -1
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js → rsc-media-type-m8jz9u6_.js} +2 -3
- package/dist/_chunks/{rsc-media-type-DDc7duTD.js.map → rsc-media-type-m8jz9u6_.js.map} +1 -1
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js → rsc-payload-path-EphpDB-J.js} +2 -3
- package/dist/_chunks/{rsc-payload-path-dffcs4jp.js.map → rsc-payload-path-EphpDB-J.js.map} +1 -1
- package/dist/_chunks/{scan-BoP17W3w.js → scan-CyizcBiX.js} +2 -3
- package/dist/_chunks/{scan-BoP17W3w.js.map → scan-CyizcBiX.js.map} +1 -1
- package/dist/_chunks/{scanner-C8fdKvKG.js → scanner-CJC-ScJU.js} +15 -23
- package/dist/_chunks/{scanner-C8fdKvKG.js.map → scanner-CJC-ScJU.js.map} +1 -1
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js → schema-bridge-DyRs3cqy.js} +2 -3
- package/dist/_chunks/{schema-bridge-DpOmvZlI.js.map → schema-bridge-DyRs3cqy.js.map} +1 -1
- package/dist/_chunks/{segment-classify-C539Pa2O.js → segment-classify-Ho8jXWeC.js} +3 -5
- package/dist/_chunks/{segment-classify-C539Pa2O.js.map → segment-classify-Ho8jXWeC.js.map} +1 -1
- package/dist/_chunks/{segment-context-D3DNxKFq.js → segment-context-CYiGTi3K.js} +4 -6
- package/dist/_chunks/{segment-context-D3DNxKFq.js.map → segment-context-CYiGTi3K.js.map} +1 -1
- package/dist/_chunks/{segment-keys-D5hu1hz4.js → segment-keys-Y60KNc8C.js} +2 -3
- package/dist/_chunks/{segment-keys-D5hu1hz4.js.map → segment-keys-Y60KNc8C.js.map} +1 -1
- package/dist/_chunks/{singleflight-BeVMMKi0.js → singleflight-BChPMjwH.js} +2 -3
- package/dist/_chunks/{singleflight-BeVMMKi0.js.map → singleflight-BChPMjwH.js.map} +1 -1
- package/dist/_chunks/{sizeof-CO3dk0V1.js → sizeof-DG4W40lv.js} +3 -4
- package/dist/_chunks/{sizeof-CO3dk0V1.js.map → sizeof-DG4W40lv.js.map} +1 -1
- package/dist/_chunks/{ssr-data-nA3I70_n.js → ssr-data-9hPtcNOr.js} +3 -4
- package/dist/_chunks/{ssr-data-nA3I70_n.js.map → ssr-data-9hPtcNOr.js.map} +1 -1
- package/dist/_chunks/{state-BhNGPsdi.js → state-B-EBjeER.js} +2 -3
- package/dist/_chunks/{state-BhNGPsdi.js.map → state-B-EBjeER.js.map} +1 -1
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js → status-page-marker-XIQXlTOb.js} +8 -13
- package/dist/_chunks/{status-page-marker-BRX9Ib-d.js.map → status-page-marker-XIQXlTOb.js.map} +1 -1
- package/dist/_chunks/{tree-match-6yihorhk.js → tree-match-Bqdr9szG.js} +2 -3
- package/dist/_chunks/{tree-match-6yihorhk.js.map → tree-match-Bqdr9szG.js.map} +1 -1
- package/dist/_chunks/{use-query-states-I3JMng6J.js → use-query-states-pkDV-jSg.js} +4 -7
- package/dist/_chunks/{use-query-states-I3JMng6J.js.map → use-query-states-pkDV-jSg.js.map} +1 -1
- package/dist/_chunks/{walkers-BqzxnwGC.js → walkers-DIE203ir.js} +6 -8
- package/dist/_chunks/{walkers-BqzxnwGC.js.map → walkers-DIE203ir.js.map} +1 -1
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js → write-file-atomic-DW8m_Atv.js} +2 -3
- package/dist/_chunks/{write-file-atomic-D1qWqHb4.js.map → write-file-atomic-DW8m_Atv.js.map} +1 -1
- package/dist/adapters/build-output-helper.d.ts +10 -1
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare-dev.js +2 -3
- package/dist/adapters/cloudflare-kv-cache.js +3 -4
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro-presets.d.ts +6 -0
- package/dist/adapters/nitro-presets.d.ts.map +1 -1
- package/dist/adapters/nitro-preview.d.ts.map +1 -1
- package/dist/adapters/nitro.d.ts.map +1 -1
- package/dist/adapters/nitro.js +94 -57
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/crawl-entry.js +7 -9
- package/dist/analyze/crawl-entry.js.map +1 -1
- package/dist/analyze/graph-command.d.ts.map +1 -1
- package/dist/analyze/graph-command.js +19 -105
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/key-discipline.d.ts +61 -0
- package/dist/cache/key-discipline.d.ts.map +1 -0
- package/dist/cache/stores/cloudflare-kv.js +1 -2
- package/dist/cache/stores/memory.js +2 -3
- package/dist/cache/stores/redis.js +1 -2
- package/dist/cache/stores/vercel.js +1 -2
- package/dist/cache/timber-cache.d.ts +5 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.js +1 -2
- package/dist/cdn/fastly-purge.js +1 -2
- package/dist/cdn/index.js +2 -3
- package/dist/cdn/workers-cache-purge.js +3 -5
- package/dist/cdn/workers-cache-purge.js.map +1 -1
- package/dist/cli-dev-status.d.ts +75 -0
- package/dist/cli-dev-status.d.ts.map +1 -0
- package/dist/cli-init.d.ts +72 -0
- package/dist/cli-init.d.ts.map +1 -0
- package/dist/cli.d.ts +4 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -54
- package/dist/cli.js.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +22 -34
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +13 -18
- package/dist/client/internal.js.map +1 -1
- package/dist/client/use-cookie.d.ts +18 -5
- package/dist/client/use-cookie.d.ts.map +1 -1
- package/dist/codec.js +2 -3
- package/dist/config-types.d.ts +40 -5
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +40 -67
- package/dist/cookies/index.js.map +1 -1
- package/dist/cookies/json-cookie.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +698 -237
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +3 -4
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/dev-discovery.d.ts +69 -5
- package/dist/plugins/dev-discovery.d.ts.map +1 -1
- package/dist/plugins/dev-hostname.d.ts +152 -0
- package/dist/plugins/dev-hostname.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +5 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/dev-store-clear.d.ts +59 -4
- package/dist/plugins/dev-store-clear.d.ts.map +1 -1
- package/dist/plugins/graph-endpoint.d.ts +4 -2
- package/dist/plugins/graph-endpoint.d.ts.map +1 -1
- package/dist/plugins/optimize-package-imports-defaults.d.ts +13 -0
- package/dist/plugins/optimize-package-imports-defaults.d.ts.map +1 -0
- package/dist/plugins/optimize-package-imports.d.ts +113 -0
- package/dist/plugins/optimize-package-imports.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts.map +1 -1
- package/dist/routing/index.js +4 -4
- package/dist/rsc-runtime/rsc.d.ts +2 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/server-references.d.ts +8 -0
- package/dist/rsc-runtime/server-references.d.ts.map +1 -0
- package/dist/search-params/index.js +5 -7
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/access-gate.d.ts +12 -0
- package/dist/server/access-gate.d.ts.map +1 -1
- package/dist/server/canonicalize.d.ts +21 -0
- package/dist/server/canonicalize.d.ts.map +1 -1
- package/dist/server/cookie-context.d.ts +8 -1
- package/dist/server/cookie-context.d.ts.map +1 -1
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/flight-source.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -13
- package/dist/server/index.js.map +1 -1
- package/dist/server/interception-gates.d.ts +49 -0
- package/dist/server/interception-gates.d.ts.map +1 -0
- package/dist/server/internal.js +1061 -943
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +17 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts +8 -0
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-interception.d.ts +34 -4
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline-metadata-route.d.ts +24 -0
- package/dist/server/pipeline-metadata-route.d.ts.map +1 -0
- package/dist/server/pipeline-metadata.d.ts +3 -2
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +9 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +68 -22
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -1
- package/dist/server/prebuilt/overlay.d.ts +8 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/primitives.d.ts +13 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-utils.d.ts +21 -0
- package/dist/server/render-utils.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +14 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-handler.d.ts +7 -0
- package/dist/server/route-handler.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +14 -3
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/signal-identity.d.ts +6 -0
- package/dist/server/signal-identity.d.ts.map +1 -1
- package/dist/server/traced-access.d.ts +18 -0
- package/dist/server/traced-access.d.ts.map +1 -0
- package/dist/server/tracing.d.ts.map +1 -1
- package/dist/server/types.d.ts +5 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shims/font-google.js +1 -2
- package/dist/shims/font-local.js +1 -2
- package/dist/shims/headers.d.ts +11 -4
- package/dist/shims/headers.d.ts.map +1 -1
- package/docs/api/30-api-server.mdx +3 -1
- package/docs/api/32-api-cache.mdx +1 -1
- package/docs/api/34-api-config.mdx +42 -0
- package/docs/api/36-cli.mdx +72 -6
- package/docs/learn/01-quick-start.mdx +1 -1
- package/docs/learn/06-typed-params.mdx +2 -2
- package/docs/learn/10-caching.mdx +26 -5
- package/llms.txt +1 -1
- package/package.json +12 -12
- package/src/adapters/build-output-helper.ts +26 -4
- package/src/adapters/cloudflare.ts +1 -0
- package/src/adapters/nitro-presets.ts +15 -0
- package/src/adapters/nitro-preview.ts +66 -34
- package/src/adapters/nitro.ts +14 -6
- package/src/analyze/graph-command.ts +25 -133
- package/src/cache/key-discipline.ts +218 -0
- package/src/cache/timber-cache.ts +42 -5
- package/src/cli-dev-status.ts +196 -0
- package/src/cli-init.ts +278 -0
- package/src/cli.ts +33 -79
- package/src/client/error-boundary.tsx +19 -2
- package/src/client/use-cookie.ts +33 -21
- package/src/config-types.ts +40 -5
- package/src/config-validation.ts +37 -0
- package/src/cookies/define-cookie.ts +10 -46
- package/src/cookies/json-cookie.ts +4 -4
- package/src/index.ts +2 -0
- package/src/plugin-context.ts +7 -0
- package/src/plugins/dev-discovery.ts +216 -6
- package/src/plugins/dev-hostname.ts +322 -0
- package/src/plugins/dev-server.ts +96 -37
- package/src/plugins/dev-store-clear.ts +105 -7
- package/src/plugins/graph-endpoint.ts +15 -3
- package/src/plugins/optimize-package-imports-defaults.ts +88 -0
- package/src/plugins/optimize-package-imports.ts +439 -0
- package/src/plugins/prebuilt.ts +9 -0
- package/src/rsc-runtime/rsc.ts +7 -3
- package/src/rsc-runtime/server-references.ts +73 -0
- package/src/rsc-runtime/vendor-types.d.ts +9 -0
- package/src/server/access-gate.tsx +32 -20
- package/src/server/action-handler.ts +40 -34
- package/src/server/canonicalize.ts +27 -0
- package/src/server/cookie-context.ts +11 -3
- package/src/server/flight-source-node.ts +5 -2
- package/src/server/flight-source.ts +4 -3
- package/src/server/index.ts +6 -1
- package/src/server/interception-gates.ts +94 -0
- package/src/server/logger.ts +23 -0
- package/src/server/param-coercion.ts +22 -0
- package/src/server/pipeline-interception.ts +64 -4
- package/src/server/pipeline-metadata-route.ts +242 -0
- package/src/server/pipeline-metadata.ts +7 -5
- package/src/server/pipeline-phases.ts +71 -131
- package/src/server/pipeline.ts +20 -2
- package/src/server/prebuilt/dev-store.ts +113 -34
- package/src/server/prebuilt/overlay.ts +18 -0
- package/src/server/prebuilt-runtime.ts +43 -44
- package/src/server/primitives.ts +14 -0
- package/src/server/render-utils.ts +25 -0
- package/src/server/request-context.ts +27 -3
- package/src/server/route-element-builder.ts +15 -2
- package/src/server/route-handler.ts +3 -2
- package/src/server/route-matcher.ts +48 -33
- package/src/server/rsc-entry/api-handler.ts +2 -33
- package/src/server/rsc-entry/index.ts +8 -3
- package/src/server/rsc-entry/rsc-stream.ts +7 -1
- package/src/server/signal-identity.ts +30 -12
- package/src/server/traced-access.ts +50 -0
- package/src/server/tracing.ts +18 -1
- package/src/server/types.ts +5 -4
- package/src/shims/headers.ts +12 -4
- package/dist/_chunks/actions-vBHr2vqd.js.map +0 -1
- package/dist/_chunks/build-output-helper-RV_BRcF1.js.map +0 -1
- package/dist/_chunks/cache-api-DdcDLpBj.js.map +0 -1
- package/dist/_chunks/chains-B8TCLved.js +0 -1
- package/dist/_chunks/cli-context-BJQB6rtF.js +0 -1
- package/dist/_chunks/dev-server-BNr5drEO.js.map +0 -1
- package/dist/_chunks/dev-server-CUg7Mqh_.js +0 -1
- package/dist/_chunks/dev-store-BOa304m_.js.map +0 -1
- package/dist/_chunks/flight-source-node-BdHUOUqg.js.map +0 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +0 -1
- package/dist/_chunks/logger-CI_hThfy.js.map +0 -1
- package/dist/_chunks/node-response-bF0bKoig.js.map +0 -1
- package/dist/_chunks/plugin-context-DxMMvjUt.js.map +0 -1
- package/dist/server/prebuilt/key-discipline.d.ts +0 -52
- package/dist/server/prebuilt/key-discipline.d.ts.map +0 -1
- package/src/server/prebuilt/key-discipline.ts +0 -122
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { a as formatMissingPeers, i as checkPeerDependencies, n as timberDevServer, o as reportConfigErrors, s as validateConfig } from "./_chunks/dev-server-
|
|
2
|
-
import { i as resolveRenderTimeoutMs } from "./_chunks/render-timeout-
|
|
3
|
-
import { t as writeFileAtomic } from "./_chunks/write-file-atomic-
|
|
4
|
-
import { d as collectInterceptionRewrites, l as getPrerenderExport, n as scanRoutes } from "./_chunks/scanner-
|
|
5
|
-
import {
|
|
6
|
-
import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-
|
|
7
|
-
import { a as contextAdapter, c as loadTimberConfigFile, d as resolveBuildDir, f as resolveClientJavascript, l as mergeFileConfig, m as createNoopTimer, o as createPluginContext, r as adapterConfig, u as resolveAppDir } from "./_chunks/plugin-context-
|
|
8
|
-
import { i as withBasePath, n as normalizeBasePath, t as isRelativeBase } from "./_chunks/base-path-
|
|
9
|
-
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-
|
|
10
|
-
import { i as poisonPillSource, r as markerFor, t as EXPLICIT_MARKERS } from "./_chunks/poison-rules-
|
|
11
|
-
import { n as rscPayloadPath, t as RSC_PAYLOAD_DIR } from "./_chunks/rsc-payload-path-
|
|
12
|
-
import { a as REDIRECTS_FILE, n as detectFsIdentity, o as RESERVED_OUTPUT_PATHS, r as fsKey, t as EXACT_FS_IDENTITY } from "./_chunks/fs-identity-
|
|
13
|
-
import { t as EMPTY_BUILD_MANIFEST } from "./_chunks/build-manifest-
|
|
14
|
-
import { t as fnv1aHash } from "./_chunks/fast-hash-
|
|
15
|
-
import { t as formatSize } from "./_chunks/format-
|
|
1
|
+
import { a as formatMissingPeers, i as checkPeerDependencies, n as timberDevServer, o as reportConfigErrors, s as validateConfig } from "./_chunks/dev-server-B7o4As0l.js";
|
|
2
|
+
import { i as resolveRenderTimeoutMs } from "./_chunks/render-timeout-MrrqD1wd.js";
|
|
3
|
+
import { t as writeFileAtomic } from "./_chunks/write-file-atomic-DW8m_Atv.js";
|
|
4
|
+
import { d as collectInterceptionRewrites, l as getPrerenderExport, n as scanRoutes } from "./_chunks/scanner-CJC-ScJU.js";
|
|
5
|
+
import { b as swallow } from "./_chunks/logger-CWk44DLp.js";
|
|
6
|
+
import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-hZwz5wd4.js";
|
|
7
|
+
import { a as contextAdapter, c as loadTimberConfigFile, d as resolveBuildDir, f as resolveClientJavascript, l as mergeFileConfig, m as createNoopTimer, o as createPluginContext, r as adapterConfig, u as resolveAppDir } from "./_chunks/plugin-context-FCkaNLUB.js";
|
|
8
|
+
import { i as withBasePath, n as normalizeBasePath, t as isRelativeBase } from "./_chunks/base-path-DDIx0FXe.js";
|
|
9
|
+
import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-DIE203ir.js";
|
|
10
|
+
import { i as poisonPillSource, r as markerFor, t as EXPLICIT_MARKERS } from "./_chunks/poison-rules-Bmz-lCPi.js";
|
|
11
|
+
import { n as rscPayloadPath, t as RSC_PAYLOAD_DIR } from "./_chunks/rsc-payload-path-EphpDB-J.js";
|
|
12
|
+
import { a as REDIRECTS_FILE, n as detectFsIdentity, o as RESERVED_OUTPUT_PATHS, r as fsKey, t as EXACT_FS_IDENTITY } from "./_chunks/fs-identity-BmQ_Agg-.js";
|
|
13
|
+
import { t as EMPTY_BUILD_MANIFEST } from "./_chunks/build-manifest-Y4jl7nwU.js";
|
|
14
|
+
import { t as fnv1aHash } from "./_chunks/fast-hash-DddxkU5Y.js";
|
|
15
|
+
import { t as formatSize } from "./_chunks/format-DuPOoXUP.js";
|
|
16
16
|
import { createLogger, esmExternalRequirePlugin, isRunnableDevEnvironment, parseAst } from "vite";
|
|
17
17
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, win32 } from "node:path";
|
|
18
18
|
import { builtinModules, createRequire } from "node:module";
|
|
@@ -23,7 +23,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
23
23
|
import { createHash, randomUUID } from "node:crypto";
|
|
24
24
|
import { copyFile, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
25
25
|
import { gzipSync } from "node:zlib";
|
|
26
|
-
|
|
26
|
+
// src/plugins/content.ts
|
|
27
27
|
var CONFIG_FILE_NAMES = [
|
|
28
28
|
"content-collections.ts",
|
|
29
29
|
"content-collections.js",
|
|
@@ -126,8 +126,7 @@ function timberContent(ctx) {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
//#region src/plugins/entries.ts
|
|
129
|
+
// src/plugins/entries.ts
|
|
131
130
|
var __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
132
131
|
var SRC_DIR = existsSync(resolve(__dirname$1, "..", "server", "rsc-entry", "index.ts")) ? resolve(__dirname$1, "..") : resolve(__dirname$1, "..", "src");
|
|
133
132
|
var VIRTUAL_IDS = {
|
|
@@ -394,8 +393,7 @@ function timberEntries(ctx) {
|
|
|
394
393
|
}
|
|
395
394
|
};
|
|
396
395
|
}
|
|
397
|
-
|
|
398
|
-
//#region src/plugins/mdx.ts
|
|
396
|
+
// src/plugins/mdx.ts
|
|
399
397
|
var MDX_EXTENSIONS_UNDOTTED = [.../* @__PURE__ */ new Set([".mdx", ".md"])].map((ext) => ext.slice(1));
|
|
400
398
|
/**
|
|
401
399
|
* Check if mdx-components.tsx (or .ts, .jsx, .js) exists at the project root
|
|
@@ -533,8 +531,7 @@ function timberMdx(ctx) {
|
|
|
533
531
|
}
|
|
534
532
|
};
|
|
535
533
|
}
|
|
536
|
-
|
|
537
|
-
//#region src/routing/manifest-codegen.ts
|
|
534
|
+
// src/routing/manifest-codegen.ts
|
|
538
535
|
/**
|
|
539
536
|
* Route manifest codegen — generates virtual module source for the route
|
|
540
537
|
* manifest and the global schema loader.
|
|
@@ -683,8 +680,7 @@ function generateSchemaModule(appDir) {
|
|
|
683
680
|
"export default globalCodecs;"
|
|
684
681
|
].join("\n");
|
|
685
682
|
}
|
|
686
|
-
|
|
687
|
-
//#region src/plugins/orphaned-modules.ts
|
|
683
|
+
// src/plugins/orphaned-modules.ts
|
|
688
684
|
/**
|
|
689
685
|
* The update's modules with each orphan replaced by the RSC entry (whose
|
|
690
686
|
* file is `entryFile`). `undefined` when there are no orphans, so Vite keeps
|
|
@@ -704,8 +700,7 @@ function redirectOrphanedModules(environment, modules, entryFile) {
|
|
|
704
700
|
if (entry && !rest.includes(entry)) rest.push(entry);
|
|
705
701
|
return rest;
|
|
706
702
|
}
|
|
707
|
-
|
|
708
|
-
//#region src/plugins/routing.ts
|
|
703
|
+
// src/plugins/routing.ts
|
|
709
704
|
/**
|
|
710
705
|
* timber-routing — Vite sub-plugin for route manifest generation.
|
|
711
706
|
*
|
|
@@ -996,8 +991,7 @@ function invalidateManifest(server) {
|
|
|
996
991
|
}
|
|
997
992
|
server.hot.send({ type: "full-reload" });
|
|
998
993
|
}
|
|
999
|
-
|
|
1000
|
-
//#region src/plugins/shims.ts
|
|
994
|
+
// src/plugins/shims.ts
|
|
1001
995
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
1002
996
|
var PKG_ROOT = __dirname.endsWith("plugins") ? resolve(__dirname, "..", "..") : resolve(__dirname, "..");
|
|
1003
997
|
var SHIMS_DIR = resolve(PKG_ROOT, "src", "shims");
|
|
@@ -1199,8 +1193,7 @@ ${SERVER_STUB_EXPORTS.map((name) => name === "RedirectType" ? `export const Redi
|
|
|
1199
1193
|
}
|
|
1200
1194
|
};
|
|
1201
1195
|
}
|
|
1202
|
-
|
|
1203
|
-
//#region src/fonts/paths.ts
|
|
1196
|
+
// src/fonts/paths.ts
|
|
1204
1197
|
/**
|
|
1205
1198
|
* Shared path/URL helpers for the timber-fonts pipeline.
|
|
1206
1199
|
*
|
|
@@ -1251,8 +1244,7 @@ function hashedFontBasename(srcPath, hash) {
|
|
|
1251
1244
|
const ext = win32.extname(basename);
|
|
1252
1245
|
return `${ext ? basename.slice(0, -ext.length) : basename}-${hash}${ext}`;
|
|
1253
1246
|
}
|
|
1254
|
-
|
|
1255
|
-
//#region src/fonts/google.ts
|
|
1247
|
+
// src/fonts/google.ts
|
|
1256
1248
|
/**
|
|
1257
1249
|
* Google Fonts download, caching, and dev CDN fallback.
|
|
1258
1250
|
*
|
|
@@ -1542,8 +1534,7 @@ function generateDevFontFaces(faces, display) {
|
|
|
1542
1534
|
async function resolveDevFontFaces(font) {
|
|
1543
1535
|
return generateDevFontFaces(filterBySubsets(await fetchGoogleFontsCss(buildGoogleFontsUrl(font)), font.subsets), font.display);
|
|
1544
1536
|
}
|
|
1545
|
-
|
|
1546
|
-
//#region src/fonts/css.ts
|
|
1537
|
+
// src/fonts/css.ts
|
|
1547
1538
|
/**
|
|
1548
1539
|
* Generate a single `@font-face` CSS rule from a descriptor.
|
|
1549
1540
|
*/
|
|
@@ -1595,8 +1586,7 @@ function generateVariableClass(className, variable, fontFamily) {
|
|
|
1595
1586
|
function generateFontFamilyClass(className, fontFamily) {
|
|
1596
1587
|
return `.${className} {\n font-family: ${fontFamily};\n}`;
|
|
1597
1588
|
}
|
|
1598
|
-
|
|
1599
|
-
//#region src/fonts/fallbacks.ts
|
|
1589
|
+
// src/fonts/fallbacks.ts
|
|
1600
1590
|
/**
|
|
1601
1591
|
* Lookup table for commonly used Google Fonts.
|
|
1602
1592
|
*
|
|
@@ -1775,8 +1765,7 @@ function buildFontStack(family) {
|
|
|
1775
1765
|
parts.push(generic);
|
|
1776
1766
|
return parts.join(", ");
|
|
1777
1767
|
}
|
|
1778
|
-
|
|
1779
|
-
//#region src/fonts/ast-walk.ts
|
|
1768
|
+
// src/fonts/ast-walk.ts
|
|
1780
1769
|
/** Convert a 0-based byte offset into a 1-based line and 0-based column. */
|
|
1781
1770
|
function offsetToLineColumn(source, offset) {
|
|
1782
1771
|
let line = 1;
|
|
@@ -1895,8 +1884,7 @@ function walkForUnconsumedReferences(node, bindingNames, consumedCallStarts, sou
|
|
|
1895
1884
|
}
|
|
1896
1885
|
walkChildNodes(node, (child) => walkForUnconsumedReferences(child, bindingNames, consumedCallStarts, source, out));
|
|
1897
1886
|
}
|
|
1898
|
-
|
|
1899
|
-
//#region src/fonts/ast.ts
|
|
1887
|
+
// src/fonts/ast.ts
|
|
1900
1888
|
/**
|
|
1901
1889
|
* AST utilities for extracting static font configs from source code.
|
|
1902
1890
|
* Uses OXC via Vite's `parseAst` — handles JS/JSX/TS/TSX natively.
|
|
@@ -2264,8 +2252,7 @@ function matchCallExpression(call, bindings, _source) {
|
|
|
2264
2252
|
configNode: args[0]
|
|
2265
2253
|
};
|
|
2266
2254
|
}
|
|
2267
|
-
|
|
2268
|
-
//#region src/fonts/local.ts
|
|
2255
|
+
// src/fonts/local.ts
|
|
2269
2256
|
/**
|
|
2270
2257
|
* Local font processing for the timber-fonts pipeline.
|
|
2271
2258
|
*
|
|
@@ -2518,8 +2505,7 @@ function generateLocalVirtualModule() {
|
|
|
2518
2505
|
"}"
|
|
2519
2506
|
].join("\n");
|
|
2520
2507
|
}
|
|
2521
|
-
|
|
2522
|
-
//#region src/fonts/pipeline.ts
|
|
2508
|
+
// src/fonts/pipeline.ts
|
|
2523
2509
|
/**
|
|
2524
2510
|
* FontPipeline — owns all per-font state for the timber-fonts plugin.
|
|
2525
2511
|
*
|
|
@@ -2782,8 +2768,7 @@ function renderEntryCss(entry, urlPrefix) {
|
|
|
2782
2768
|
else cssParts.push(generateFontFamilyClass(entry.className, entry.fontFamily));
|
|
2783
2769
|
return cssParts.join("\n\n");
|
|
2784
2770
|
}
|
|
2785
|
-
|
|
2786
|
-
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
2771
|
+
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
2787
2772
|
var comma = ",".charCodeAt(0);
|
|
2788
2773
|
var semicolon = ";".charCodeAt(0);
|
|
2789
2774
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -2877,8 +2862,7 @@ function encode(decoded) {
|
|
|
2877
2862
|
}
|
|
2878
2863
|
return writer.flush();
|
|
2879
2864
|
}
|
|
2880
|
-
|
|
2881
|
-
//#region ../../node_modules/.pnpm/magic-string@1.4.3/node_modules/magic-string/dist/index.mjs
|
|
2865
|
+
// ../../node_modules/.pnpm/magic-string@1.4.5/node_modules/magic-string/dist/index.mjs
|
|
2882
2866
|
var BitSet = class BitSet {
|
|
2883
2867
|
constructor(arg) {
|
|
2884
2868
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -2889,6 +2873,17 @@ var BitSet = class BitSet {
|
|
|
2889
2873
|
has(n) {
|
|
2890
2874
|
return !!(this.bits[n >> 5] & 1 << (n & 31));
|
|
2891
2875
|
}
|
|
2876
|
+
forEach(fn) {
|
|
2877
|
+
const bits = this.bits;
|
|
2878
|
+
for (let w = 0; w < bits.length; w++) {
|
|
2879
|
+
let word = bits[w];
|
|
2880
|
+
while (word) {
|
|
2881
|
+
const lowest = word & -word;
|
|
2882
|
+
fn((w << 5) + 31 - Math.clz32(lowest));
|
|
2883
|
+
word ^= lowest;
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2892
2887
|
};
|
|
2893
2888
|
var Chunk = class Chunk {
|
|
2894
2889
|
constructor(start, end, content) {
|
|
@@ -2900,6 +2895,8 @@ var Chunk = class Chunk {
|
|
|
2900
2895
|
this.content = content;
|
|
2901
2896
|
this.storeName = false;
|
|
2902
2897
|
this.edited = false;
|
|
2898
|
+
this.replacesUntil = -1;
|
|
2899
|
+
this.replacedFrom = -1;
|
|
2903
2900
|
this.previous = null;
|
|
2904
2901
|
this.next = null;
|
|
2905
2902
|
}
|
|
@@ -2916,6 +2913,8 @@ var Chunk = class Chunk {
|
|
|
2916
2913
|
chunk.content = this.content;
|
|
2917
2914
|
chunk.storeName = this.storeName;
|
|
2918
2915
|
chunk.edited = this.edited;
|
|
2916
|
+
chunk.replacesUntil = this.replacesUntil;
|
|
2917
|
+
chunk.replacedFrom = this.replacedFrom;
|
|
2919
2918
|
return chunk;
|
|
2920
2919
|
}
|
|
2921
2920
|
contains(index) {
|
|
@@ -2956,6 +2955,8 @@ var Chunk = class Chunk {
|
|
|
2956
2955
|
reset() {
|
|
2957
2956
|
this.intro = "";
|
|
2958
2957
|
this.outro = "";
|
|
2958
|
+
this.replacesUntil = -1;
|
|
2959
|
+
this.replacedFrom = -1;
|
|
2959
2960
|
if (this.edited) {
|
|
2960
2961
|
this.content = this.original;
|
|
2961
2962
|
this.storeName = false;
|
|
@@ -2973,7 +2974,7 @@ var Chunk = class Chunk {
|
|
|
2973
2974
|
this.end = index;
|
|
2974
2975
|
if (this.edited) {
|
|
2975
2976
|
newChunk.edit("", false, true);
|
|
2976
|
-
|
|
2977
|
+
newChunk.replacedFrom = this.replacedFrom;
|
|
2977
2978
|
} else this.content = originalBefore;
|
|
2978
2979
|
newChunk.next = this.next;
|
|
2979
2980
|
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
@@ -3223,8 +3224,8 @@ var Mappings = class {
|
|
|
3223
3224
|
this.generatedCodeColumn = 0;
|
|
3224
3225
|
this.raw = [];
|
|
3225
3226
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
3226
|
-
this.
|
|
3227
|
-
this.
|
|
3227
|
+
this.rawRangeMappingsIndices = [];
|
|
3228
|
+
this.rawRangeMappings = hires === "experimental-range" ? [this.rawRangeMappingsIndices] : void 0;
|
|
3228
3229
|
this.encoder = encoder;
|
|
3229
3230
|
}
|
|
3230
3231
|
nextLine() {
|
|
@@ -3237,7 +3238,28 @@ var Mappings = class {
|
|
|
3237
3238
|
this.generatedCodeLine += 1;
|
|
3238
3239
|
}
|
|
3239
3240
|
this.generatedCodeColumn = 0;
|
|
3240
|
-
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
3241
|
+
if (this.rawRangeMappings) this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Emits the mappings for one MagicString: its intro, every chunk (with the
|
|
3245
|
+
* chunk's own intro/outro) and its outro. `sourceIndex === -1` means the
|
|
3246
|
+
* string has no source of its own, so its content only advances the
|
|
3247
|
+
* generated position without mapping anything.
|
|
3248
|
+
*/
|
|
3249
|
+
addMagicString(magicString, sourceIndex, nameIndex) {
|
|
3250
|
+
const { original } = magicString;
|
|
3251
|
+
const locate = getLocator(original);
|
|
3252
|
+
if (magicString.intro) this.advance(magicString.intro);
|
|
3253
|
+
magicString.firstChunk.eachNext((chunk) => {
|
|
3254
|
+
if (chunk.intro.length) this.advance(chunk.intro);
|
|
3255
|
+
if (sourceIndex === -1) this.advance(chunk.content);
|
|
3256
|
+
else if (chunk.edited) {
|
|
3257
|
+
const name = chunk.storeName ? nameIndex.get(original.slice(chunk.start, chunk.replacesUntil)) : void 0;
|
|
3258
|
+
this.addEdit(sourceIndex, chunk.content, locate(chunk.start), name ?? -1);
|
|
3259
|
+
} else this.addUneditedChunk(sourceIndex, chunk, original, locate(chunk.start), magicString.sourcemapLocations);
|
|
3260
|
+
if (chunk.outro.length) this.advance(chunk.outro);
|
|
3261
|
+
});
|
|
3262
|
+
if (magicString.outro) this.advance(magicString.outro);
|
|
3241
3263
|
}
|
|
3242
3264
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
3243
3265
|
if (content.length) {
|
|
@@ -3450,6 +3472,9 @@ function expandReplacement(replacement, matched, position, str, captures, namedC
|
|
|
3450
3472
|
return result;
|
|
3451
3473
|
}
|
|
3452
3474
|
var MagicString = class MagicString {
|
|
3475
|
+
/**
|
|
3476
|
+
* Wraps `string` for editing; every index passed to the editing methods refers to this original string.
|
|
3477
|
+
*/
|
|
3453
3478
|
constructor(string, options = {}) {
|
|
3454
3479
|
const chunk = new Chunk(0, string.length, string);
|
|
3455
3480
|
Object.defineProperties(this, {
|
|
@@ -3499,7 +3524,7 @@ var MagicString = class MagicString {
|
|
|
3499
3524
|
},
|
|
3500
3525
|
storedNames: {
|
|
3501
3526
|
writable: true,
|
|
3502
|
-
value:
|
|
3527
|
+
value: /* @__PURE__ */ new Set()
|
|
3503
3528
|
},
|
|
3504
3529
|
indentStr: {
|
|
3505
3530
|
writable: true,
|
|
@@ -3539,7 +3564,8 @@ var MagicString = class MagicString {
|
|
|
3539
3564
|
* See also `s.prependLeft(...)`.
|
|
3540
3565
|
*/
|
|
3541
3566
|
appendLeft(index, content) {
|
|
3542
|
-
index =
|
|
3567
|
+
index = this._resolveIndex(index);
|
|
3568
|
+
if (index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
|
|
3543
3569
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
3544
3570
|
this._split(index);
|
|
3545
3571
|
const chunk = this.byEnd.get(index);
|
|
@@ -3553,7 +3579,8 @@ var MagicString = class MagicString {
|
|
|
3553
3579
|
* See also `s.prependRight(...)`.
|
|
3554
3580
|
*/
|
|
3555
3581
|
appendRight(index, content) {
|
|
3556
|
-
index =
|
|
3582
|
+
index = this._resolveIndex(index);
|
|
3583
|
+
if (index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
|
|
3557
3584
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
3558
3585
|
this._split(index);
|
|
3559
3586
|
const chunk = this.byStart.get(index);
|
|
@@ -3562,7 +3589,10 @@ var MagicString = class MagicString {
|
|
|
3562
3589
|
return this;
|
|
3563
3590
|
}
|
|
3564
3591
|
/**
|
|
3565
|
-
*
|
|
3592
|
+
* Returns an independent copy: the chunk list, string-level intro/outro,
|
|
3593
|
+
* sourcemap locations, stored names, indent exclusion ranges, `offset`,
|
|
3594
|
+
* `filename` and `ignoreList` are all copied; later edits to either string
|
|
3595
|
+
* do not affect the other.
|
|
3566
3596
|
*/
|
|
3567
3597
|
clone() {
|
|
3568
3598
|
const cloned = new MagicString(this.original, {
|
|
@@ -3587,7 +3617,7 @@ var MagicString = class MagicString {
|
|
|
3587
3617
|
cloned.lastChunk = clonedChunk;
|
|
3588
3618
|
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
3589
3619
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
3590
|
-
cloned.storedNames =
|
|
3620
|
+
cloned.storedNames = new Set(this.storedNames);
|
|
3591
3621
|
cloned.intro = this.intro;
|
|
3592
3622
|
cloned.outro = this.outro;
|
|
3593
3623
|
cloned.hasMovedChunks = this.hasMovedChunks;
|
|
@@ -3623,18 +3653,8 @@ var MagicString = class MagicString {
|
|
|
3623
3653
|
}
|
|
3624
3654
|
/** @internal */
|
|
3625
3655
|
_generateMappings(mappings) {
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3628
|
-
const locate = getLocator(this.original);
|
|
3629
|
-
if (this.intro) mappings.advance(this.intro);
|
|
3630
|
-
this.firstChunk.eachNext((chunk) => {
|
|
3631
|
-
const loc = locate(chunk.start);
|
|
3632
|
-
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
3633
|
-
if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
3634
|
-
else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
3635
|
-
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
3636
|
-
});
|
|
3637
|
-
if (this.outro) mappings.advance(this.outro);
|
|
3656
|
+
const names = [...this.storedNames];
|
|
3657
|
+
mappings.addMagicString(this, 0, new Map(names.map((name, i) => [name, i])));
|
|
3638
3658
|
return names;
|
|
3639
3659
|
}
|
|
3640
3660
|
/** @internal */
|
|
@@ -3656,9 +3676,13 @@ var MagicString = class MagicString {
|
|
|
3656
3676
|
this._ensureindentStr();
|
|
3657
3677
|
return this.indentStr;
|
|
3658
3678
|
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Returns the indentation string guessed from the original content, falling back to a single tab character.
|
|
3681
|
+
* This is the value `s.indent()` uses when no prefix is supplied.
|
|
3682
|
+
*/
|
|
3659
3683
|
getIndentString() {
|
|
3660
3684
|
this._ensureindentStr();
|
|
3661
|
-
return this.indentStr
|
|
3685
|
+
return this.indentStr ?? " ";
|
|
3662
3686
|
}
|
|
3663
3687
|
indent(indentStr, options) {
|
|
3664
3688
|
const pattern = /^[^\r\n]/gm;
|
|
@@ -3673,9 +3697,9 @@ var MagicString = class MagicString {
|
|
|
3673
3697
|
if (indentStr === "") return this;
|
|
3674
3698
|
const resolvedIndentStr = indentStr;
|
|
3675
3699
|
options = options || {};
|
|
3676
|
-
const isExcluded =
|
|
3700
|
+
const isExcluded = new BitSet();
|
|
3677
3701
|
if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
3678
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded
|
|
3702
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded.add(i);
|
|
3679
3703
|
});
|
|
3680
3704
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
3681
3705
|
const indentPiece = (str) => {
|
|
@@ -3698,13 +3722,14 @@ var MagicString = class MagicString {
|
|
|
3698
3722
|
};
|
|
3699
3723
|
while (chunk) {
|
|
3700
3724
|
const end = chunk.end;
|
|
3701
|
-
if (!isExcluded
|
|
3725
|
+
if (!isExcluded.has(chunk.start)) chunk.intro = indentPiece(chunk.intro);
|
|
3702
3726
|
if (chunk.edited) {
|
|
3703
|
-
if (!isExcluded
|
|
3727
|
+
if (!isExcluded.has(chunk.start)) chunk.content = indentPiece(chunk.content);
|
|
3728
|
+
else if (chunk.content) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
3704
3729
|
} else if (options.exclude) {
|
|
3705
3730
|
charIndex = chunk.start;
|
|
3706
3731
|
while (charIndex < end) {
|
|
3707
|
-
if (!isExcluded
|
|
3732
|
+
if (!isExcluded.has(charIndex)) {
|
|
3708
3733
|
const char = this.original.charCodeAt(charIndex);
|
|
3709
3734
|
if (char === NEWLINE_CHAR) shouldIndentNextCharacter = true;
|
|
3710
3735
|
else if (char !== CR_CHAR && shouldIndentNextCharacter) indentAt(charIndex);
|
|
@@ -3730,7 +3755,7 @@ var MagicString = class MagicString {
|
|
|
3730
3755
|
charIndex += 1;
|
|
3731
3756
|
}
|
|
3732
3757
|
}
|
|
3733
|
-
if (!isExcluded
|
|
3758
|
+
if (!isExcluded.has(chunk.end - 1)) chunk.outro = indentPiece(chunk.outro);
|
|
3734
3759
|
charIndex = chunk.end;
|
|
3735
3760
|
chunk = chunk.next;
|
|
3736
3761
|
}
|
|
@@ -3767,16 +3792,19 @@ var MagicString = class MagicString {
|
|
|
3767
3792
|
* mirroring the `appendLeft`/`appendRight` distinction.
|
|
3768
3793
|
*/
|
|
3769
3794
|
move(start, end, index, affinity = "right") {
|
|
3770
|
-
start =
|
|
3771
|
-
end =
|
|
3772
|
-
index =
|
|
3795
|
+
start = this._resolveIndex(start);
|
|
3796
|
+
end = this._resolveIndex(end);
|
|
3797
|
+
index = this._resolveIndex(index);
|
|
3773
3798
|
if (start === end) return this;
|
|
3799
|
+
if (start < 0 || end > this.original.length || index < 0 || index > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
3800
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
3774
3801
|
if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
|
|
3775
3802
|
this._split(start);
|
|
3776
3803
|
this._split(end);
|
|
3777
3804
|
this._split(index);
|
|
3778
3805
|
const first = this.byStart.get(start);
|
|
3779
3806
|
const last = this.byEnd.get(end);
|
|
3807
|
+
if (!first || !last) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
3780
3808
|
if (this.hasMovedChunks) {
|
|
3781
3809
|
let cursor = first;
|
|
3782
3810
|
while (cursor !== last) {
|
|
@@ -3811,9 +3839,9 @@ var MagicString = class MagicString {
|
|
|
3811
3839
|
if (oldRight) oldRight.previous = oldLeft;
|
|
3812
3840
|
if (newLeft) newLeft.next = first;
|
|
3813
3841
|
if (newRight) newRight.previous = last;
|
|
3814
|
-
if (!
|
|
3815
|
-
if (!
|
|
3816
|
-
this.lastChunk =
|
|
3842
|
+
if (!oldLeft) this.firstChunk = oldRight;
|
|
3843
|
+
if (!oldRight) {
|
|
3844
|
+
this.lastChunk = oldLeft;
|
|
3817
3845
|
this.lastChunk.next = null;
|
|
3818
3846
|
}
|
|
3819
3847
|
first.previous = newLeft;
|
|
@@ -3834,6 +3862,16 @@ var MagicString = class MagicString {
|
|
|
3834
3862
|
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
|
3835
3863
|
*/
|
|
3836
3864
|
overwrite(start, end, content, options) {
|
|
3865
|
+
if (options === true) {
|
|
3866
|
+
if (!warned.storeName) {
|
|
3867
|
+
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
3868
|
+
warned.storeName = true;
|
|
3869
|
+
}
|
|
3870
|
+
return this.update(start, end, content, {
|
|
3871
|
+
storeName: true,
|
|
3872
|
+
overwrite: true
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3837
3875
|
const optionObject = typeof options === "object" && options ? options : {};
|
|
3838
3876
|
return this.update(start, end, content, {
|
|
3839
3877
|
...optionObject,
|
|
@@ -3848,13 +3886,9 @@ var MagicString = class MagicString {
|
|
|
3848
3886
|
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
3849
3887
|
*/
|
|
3850
3888
|
update(start, end, content, options) {
|
|
3851
|
-
start =
|
|
3852
|
-
end =
|
|
3889
|
+
start = this._resolveIndex(start);
|
|
3890
|
+
end = this._resolveIndex(end);
|
|
3853
3891
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
3854
|
-
if (this.original.length !== 0) {
|
|
3855
|
-
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
3856
|
-
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
3857
|
-
}
|
|
3858
3892
|
if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
|
|
3859
3893
|
if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
|
|
3860
3894
|
if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
|
|
@@ -3871,30 +3905,21 @@ var MagicString = class MagicString {
|
|
|
3871
3905
|
const optionObject = typeof options === "object" && options ? options : {};
|
|
3872
3906
|
const storeName = optionObject.storeName || false;
|
|
3873
3907
|
const overwrite = optionObject.overwrite || false;
|
|
3874
|
-
if (storeName)
|
|
3875
|
-
const original = this.original.slice(start, end);
|
|
3876
|
-
Object.defineProperty(this.storedNames, original, {
|
|
3877
|
-
writable: true,
|
|
3878
|
-
value: true,
|
|
3879
|
-
enumerable: true
|
|
3880
|
-
});
|
|
3881
|
-
}
|
|
3908
|
+
if (storeName) this.storedNames.add(this.original.slice(start, end));
|
|
3882
3909
|
const first = this.byStart.get(start);
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
newChunk.previous = last;
|
|
3897
|
-
}
|
|
3910
|
+
for (let chunk = first; chunk.end < end;) {
|
|
3911
|
+
const next = chunk.next;
|
|
3912
|
+
if (next === null || next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
|
|
3913
|
+
chunk = next;
|
|
3914
|
+
}
|
|
3915
|
+
for (let chunk = first.next; chunk !== null && chunk.start < end; chunk = chunk.next) {
|
|
3916
|
+
chunk.edit("", false, !overwrite);
|
|
3917
|
+
chunk.replacesUntil = -1;
|
|
3918
|
+
chunk.replacedFrom = start;
|
|
3919
|
+
}
|
|
3920
|
+
first.edit(content, storeName, !overwrite);
|
|
3921
|
+
first.replacesUntil = end;
|
|
3922
|
+
first.replacedFrom = -1;
|
|
3898
3923
|
return this;
|
|
3899
3924
|
}
|
|
3900
3925
|
/**
|
|
@@ -3909,7 +3934,8 @@ var MagicString = class MagicString {
|
|
|
3909
3934
|
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
|
3910
3935
|
*/
|
|
3911
3936
|
prependLeft(index, content) {
|
|
3912
|
-
index =
|
|
3937
|
+
index = this._resolveIndex(index);
|
|
3938
|
+
if (index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
|
|
3913
3939
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
3914
3940
|
this._split(index);
|
|
3915
3941
|
const chunk = this.byEnd.get(index);
|
|
@@ -3921,7 +3947,8 @@ var MagicString = class MagicString {
|
|
|
3921
3947
|
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
|
3922
3948
|
*/
|
|
3923
3949
|
prependRight(index, content) {
|
|
3924
|
-
index =
|
|
3950
|
+
index = this._resolveIndex(index);
|
|
3951
|
+
if (index < 0 || index > this.original.length) throw new MagicStringError(`index ${index} is out of bounds`);
|
|
3925
3952
|
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
3926
3953
|
this._split(index);
|
|
3927
3954
|
const chunk = this.byStart.get(index);
|
|
@@ -3937,12 +3964,8 @@ var MagicString = class MagicString {
|
|
|
3937
3964
|
* Repeated removals and removals with partially overlapping ranges are allowed.
|
|
3938
3965
|
*/
|
|
3939
3966
|
remove(start, end) {
|
|
3940
|
-
start =
|
|
3941
|
-
end =
|
|
3942
|
-
if (this.original.length !== 0) {
|
|
3943
|
-
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
3944
|
-
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
3945
|
-
}
|
|
3967
|
+
start = this._resolveIndex(start);
|
|
3968
|
+
end = this._resolveIndex(end);
|
|
3946
3969
|
if (start === end) return this;
|
|
3947
3970
|
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
3948
3971
|
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
@@ -3953,7 +3976,9 @@ var MagicString = class MagicString {
|
|
|
3953
3976
|
if (chunk.start > start) chunk.intro = "";
|
|
3954
3977
|
if (chunk.end < end) chunk.outro = "";
|
|
3955
3978
|
chunk.edit("", false, true);
|
|
3956
|
-
chunk =
|
|
3979
|
+
chunk.replacesUntil = -1;
|
|
3980
|
+
chunk.replacedFrom = -1;
|
|
3981
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : void 0;
|
|
3957
3982
|
}
|
|
3958
3983
|
return this;
|
|
3959
3984
|
}
|
|
@@ -3961,12 +3986,8 @@ var MagicString = class MagicString {
|
|
|
3961
3986
|
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
|
|
3962
3987
|
*/
|
|
3963
3988
|
reset(start, end) {
|
|
3964
|
-
start =
|
|
3965
|
-
end =
|
|
3966
|
-
if (this.original.length !== 0) {
|
|
3967
|
-
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
3968
|
-
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
3969
|
-
}
|
|
3989
|
+
start = this._resolveIndex(start);
|
|
3990
|
+
end = this._resolveIndex(end);
|
|
3970
3991
|
if (start === end) return this;
|
|
3971
3992
|
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
3972
3993
|
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
@@ -3975,10 +3996,13 @@ var MagicString = class MagicString {
|
|
|
3975
3996
|
let chunk = this.byStart.get(start);
|
|
3976
3997
|
while (chunk) {
|
|
3977
3998
|
chunk.reset();
|
|
3978
|
-
chunk = end > chunk.end ? this.byStart.get(chunk.end) :
|
|
3999
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : void 0;
|
|
3979
4000
|
}
|
|
3980
4001
|
return this;
|
|
3981
4002
|
}
|
|
4003
|
+
/**
|
|
4004
|
+
* Returns the last character of the generated string, or `''` if it is empty.
|
|
4005
|
+
*/
|
|
3982
4006
|
lastChar() {
|
|
3983
4007
|
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
3984
4008
|
let chunk = this.lastChunk;
|
|
@@ -3991,49 +4015,57 @@ var MagicString = class MagicString {
|
|
|
3991
4015
|
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
3992
4016
|
return "";
|
|
3993
4017
|
}
|
|
4018
|
+
/**
|
|
4019
|
+
* Returns everything after the last newline in the generated string, or the whole string if there is no newline.
|
|
4020
|
+
*/
|
|
3994
4021
|
lastLine() {
|
|
3995
4022
|
let lineIndex = this.outro.lastIndexOf(n);
|
|
3996
|
-
if (lineIndex !== -1) return this.outro.
|
|
4023
|
+
if (lineIndex !== -1) return this.outro.slice(lineIndex + 1);
|
|
3997
4024
|
let lineStr = this.outro;
|
|
3998
4025
|
let chunk = this.lastChunk;
|
|
3999
4026
|
while (chunk) {
|
|
4000
4027
|
if (chunk.outro.length > 0) {
|
|
4001
4028
|
lineIndex = chunk.outro.lastIndexOf(n);
|
|
4002
|
-
if (lineIndex !== -1) return chunk.outro.
|
|
4029
|
+
if (lineIndex !== -1) return chunk.outro.slice(lineIndex + 1) + lineStr;
|
|
4003
4030
|
lineStr = chunk.outro + lineStr;
|
|
4004
4031
|
}
|
|
4005
4032
|
if (chunk.content.length > 0) {
|
|
4006
4033
|
lineIndex = chunk.content.lastIndexOf(n);
|
|
4007
|
-
if (lineIndex !== -1) return chunk.content.
|
|
4034
|
+
if (lineIndex !== -1) return chunk.content.slice(lineIndex + 1) + lineStr;
|
|
4008
4035
|
lineStr = chunk.content + lineStr;
|
|
4009
4036
|
}
|
|
4010
4037
|
if (chunk.intro.length > 0) {
|
|
4011
4038
|
lineIndex = chunk.intro.lastIndexOf(n);
|
|
4012
|
-
if (lineIndex !== -1) return chunk.intro.
|
|
4039
|
+
if (lineIndex !== -1) return chunk.intro.slice(lineIndex + 1) + lineStr;
|
|
4013
4040
|
lineStr = chunk.intro + lineStr;
|
|
4014
4041
|
}
|
|
4015
4042
|
chunk = chunk.previous;
|
|
4016
4043
|
}
|
|
4017
4044
|
lineIndex = this.intro.lastIndexOf(n);
|
|
4018
|
-
if (lineIndex !== -1) return this.intro.
|
|
4045
|
+
if (lineIndex !== -1) return this.intro.slice(lineIndex + 1) + lineStr;
|
|
4019
4046
|
return this.intro + lineStr;
|
|
4020
4047
|
}
|
|
4021
4048
|
/**
|
|
4022
|
-
* Returns the content of the generated string that corresponds to the slice
|
|
4023
|
-
*
|
|
4049
|
+
* Returns the content of the generated string that corresponds to the slice
|
|
4050
|
+
* between `start` and `end` of the original string, walking the generated
|
|
4051
|
+
* string from the chunk holding `start` to the chunk holding `end`. Throws
|
|
4052
|
+
* if either index falls inside replaced content. After `move()`, a range
|
|
4053
|
+
* whose end now comes before its start in the output yields `''`.
|
|
4024
4054
|
*/
|
|
4025
4055
|
slice(start = 0, end = this.original.length - this.offset) {
|
|
4026
|
-
start =
|
|
4027
|
-
end =
|
|
4028
|
-
if (this.original.length !== 0) {
|
|
4029
|
-
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
4030
|
-
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
4031
|
-
}
|
|
4056
|
+
start = this._resolveIndex(start);
|
|
4057
|
+
end = this._resolveIndex(end);
|
|
4032
4058
|
let result = "";
|
|
4033
|
-
let chunk
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
chunk
|
|
4059
|
+
let chunk;
|
|
4060
|
+
if (this.hasMovedChunks) {
|
|
4061
|
+
chunk = this.firstChunk;
|
|
4062
|
+
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
4063
|
+
if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0) return result;
|
|
4064
|
+
chunk = chunk.next;
|
|
4065
|
+
}
|
|
4066
|
+
} else {
|
|
4067
|
+
if (start >= end) return result;
|
|
4068
|
+
chunk = this._chunkAt(start);
|
|
4037
4069
|
}
|
|
4038
4070
|
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
4039
4071
|
const startChunk = chunk;
|
|
@@ -4056,10 +4088,39 @@ var MagicString = class MagicString {
|
|
|
4056
4088
|
*/
|
|
4057
4089
|
snip(start, end) {
|
|
4058
4090
|
const clone = this.clone();
|
|
4059
|
-
clone.remove(
|
|
4060
|
-
clone.remove(end, clone.original.length);
|
|
4091
|
+
clone.remove(-clone.offset, start);
|
|
4092
|
+
clone.remove(end, clone.original.length - clone.offset);
|
|
4061
4093
|
return clone;
|
|
4062
4094
|
}
|
|
4095
|
+
/**
|
|
4096
|
+
* Applies `offset`, resolves a negative index from the end of `original` as
|
|
4097
|
+
* `update`/`remove` always have, and rejects anything that is not an integer.
|
|
4098
|
+
* Bounds are checked by the caller, because the methods report them differently.
|
|
4099
|
+
*
|
|
4100
|
+
* @internal
|
|
4101
|
+
*/
|
|
4102
|
+
_resolveIndex(index) {
|
|
4103
|
+
const resolved = index + this.offset;
|
|
4104
|
+
if (!Number.isInteger(resolved)) throw new MagicStringError(`index must be an integer, got ${index}`);
|
|
4105
|
+
if (resolved < 0 && this.original.length !== 0) return Math.max(0, resolved + this.original.length);
|
|
4106
|
+
return resolved;
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* The chunk whose original range holds `index` (`chunk.start <= index < chunk.end`),
|
|
4110
|
+
* or `undefined` when `index` is at or past the end. Searches from the last
|
|
4111
|
+
* visited chunk so that scans over nearby indices stay cheap.
|
|
4112
|
+
*
|
|
4113
|
+
* @internal
|
|
4114
|
+
*/
|
|
4115
|
+
_chunkAt(index) {
|
|
4116
|
+
let chunk = this.byStart.get(index);
|
|
4117
|
+
if (chunk) return chunk;
|
|
4118
|
+
chunk = this.lastSearchedChunk;
|
|
4119
|
+
const searchForward = index >= chunk.end;
|
|
4120
|
+
while (chunk && !chunk.contains(index)) chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
|
|
4121
|
+
if (chunk) this.lastSearchedChunk = chunk;
|
|
4122
|
+
return chunk;
|
|
4123
|
+
}
|
|
4063
4124
|
/** @internal */
|
|
4064
4125
|
_split(index) {
|
|
4065
4126
|
if (this.byStart.get(index) || this.byEnd.get(index)) return;
|
|
@@ -4112,6 +4173,11 @@ var MagicString = class MagicString {
|
|
|
4112
4173
|
if (this.outro.length && this.outro.trim()) return false;
|
|
4113
4174
|
return true;
|
|
4114
4175
|
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Returns the length of the generated string, counting only content attached to the original characters.
|
|
4178
|
+
* Content outside the string body (`s.prepend()`/`s.append()`, and inserts before the first or after the last
|
|
4179
|
+
* character) is not counted, so this can differ from `s.toString().length`.
|
|
4180
|
+
*/
|
|
4115
4181
|
length() {
|
|
4116
4182
|
let chunk = this.firstChunk;
|
|
4117
4183
|
let length = 0;
|
|
@@ -4143,10 +4209,11 @@ var MagicString = class MagicString {
|
|
|
4143
4209
|
const end = chunk.end;
|
|
4144
4210
|
const aborted = chunk.trimEnd(rx);
|
|
4145
4211
|
if (chunk.end !== end) {
|
|
4146
|
-
|
|
4212
|
+
const next = chunk.next;
|
|
4213
|
+
if (this.lastChunk === chunk) this.lastChunk = next;
|
|
4147
4214
|
this.byEnd.set(chunk.end, chunk);
|
|
4148
|
-
this.byStart.set(
|
|
4149
|
-
this.byEnd.set(
|
|
4215
|
+
this.byStart.set(next.start, next);
|
|
4216
|
+
this.byEnd.set(next.end, next);
|
|
4150
4217
|
}
|
|
4151
4218
|
if (aborted) return true;
|
|
4152
4219
|
chunk = chunk.previous;
|
|
@@ -4171,10 +4238,11 @@ var MagicString = class MagicString {
|
|
|
4171
4238
|
const end = chunk.end;
|
|
4172
4239
|
const aborted = chunk.trimStart(rx);
|
|
4173
4240
|
if (chunk.end !== end) {
|
|
4174
|
-
|
|
4241
|
+
const next = chunk.next;
|
|
4242
|
+
if (chunk === this.lastChunk) this.lastChunk = next;
|
|
4175
4243
|
this.byEnd.set(chunk.end, chunk);
|
|
4176
|
-
this.byStart.set(
|
|
4177
|
-
this.byEnd.set(
|
|
4244
|
+
this.byStart.set(next.start, next);
|
|
4245
|
+
this.byEnd.set(next.end, next);
|
|
4178
4246
|
}
|
|
4179
4247
|
if (aborted) return true;
|
|
4180
4248
|
chunk = chunk.next;
|
|
@@ -4216,30 +4284,29 @@ var MagicString = class MagicString {
|
|
|
4216
4284
|
* @internal
|
|
4217
4285
|
*/
|
|
4218
4286
|
_hasRemovedContent(start, end) {
|
|
4219
|
-
|
|
4220
|
-
if (
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
while (chunk && !chunk.contains(start)) chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
|
|
4224
|
-
if (chunk) this.lastSearchedChunk = chunk;
|
|
4287
|
+
const atBoundary = this.byStart.get(start);
|
|
4288
|
+
if (atBoundary && start === end) {
|
|
4289
|
+
const previous = this.byEnd.get(start);
|
|
4290
|
+
return !!previous && previous.content === "" && atBoundary.content === "";
|
|
4225
4291
|
}
|
|
4292
|
+
let chunk = this._chunkAt(start);
|
|
4226
4293
|
while (chunk && chunk.start < end) {
|
|
4227
|
-
if (chunk.content === "") return true;
|
|
4294
|
+
if (chunk.content === "" && (chunk.replacedFrom < start || this.byStart.get(chunk.replacedFrom).replacesUntil < chunk.end)) return true;
|
|
4228
4295
|
chunk = this.byStart.get(chunk.end);
|
|
4229
4296
|
}
|
|
4230
4297
|
return false;
|
|
4231
4298
|
}
|
|
4232
4299
|
/** @internal */
|
|
4233
4300
|
_replaceRegexp(searchValue, replacement) {
|
|
4234
|
-
function getReplacement(match, str) {
|
|
4235
|
-
if (typeof replacement === "string") return expandReplacement(replacement, match[0],
|
|
4236
|
-
else return match.groups === void 0 ? replacement(match[0], ...match.slice(1),
|
|
4301
|
+
function getReplacement(match, index, str) {
|
|
4302
|
+
if (typeof replacement === "string") return expandReplacement(replacement, match[0], index, str, match.slice(1), match.groups);
|
|
4303
|
+
else return match.groups === void 0 ? replacement(match[0], ...match.slice(1), index, str) : replacement(match[0], ...match.slice(1), index, str, match.groups);
|
|
4237
4304
|
}
|
|
4238
4305
|
const replaceMatch = (match) => {
|
|
4239
4306
|
/* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
|
|
4240
4307
|
if (match.index == null) return false;
|
|
4241
4308
|
if (this._hasRemovedContent(match.index, match.index + match[0].length)) return false;
|
|
4242
|
-
const replacement = getReplacement(match, this.original);
|
|
4309
|
+
const replacement = getReplacement(match, match.index, this.original);
|
|
4243
4310
|
if (replacement === match[0]) return true;
|
|
4244
4311
|
if (match[0].length === 0) this.appendRight(match.index - this.offset, replacement);
|
|
4245
4312
|
else this.overwrite(match.index - this.offset, match.index + match[0].length - this.offset, replacement);
|
|
@@ -4312,8 +4379,7 @@ var MagicString = class MagicString {
|
|
|
4312
4379
|
return this._replaceRegexp(searchValue, replacement);
|
|
4313
4380
|
}
|
|
4314
4381
|
};
|
|
4315
|
-
|
|
4316
|
-
//#region src/fonts/transform.ts
|
|
4382
|
+
// src/fonts/transform.ts
|
|
4317
4383
|
/**
|
|
4318
4384
|
* Transform-hook logic for the timber-fonts plugin.
|
|
4319
4385
|
*
|
|
@@ -4459,8 +4525,7 @@ function runFontsTransform(code, id, pipeline, emitError) {
|
|
|
4459
4525
|
map: s.generateMap({ hires: true })
|
|
4460
4526
|
};
|
|
4461
4527
|
}
|
|
4462
|
-
|
|
4463
|
-
//#region src/fonts/dev-middleware.ts
|
|
4528
|
+
// src/fonts/dev-middleware.ts
|
|
4464
4529
|
var FONT_MIME_TYPES = {
|
|
4465
4530
|
woff2: "font/woff2",
|
|
4466
4531
|
woff: "font/woff",
|
|
@@ -4508,8 +4573,7 @@ function installFontDevMiddleware(server, pipeline, base = "/") {
|
|
|
4508
4573
|
next();
|
|
4509
4574
|
});
|
|
4510
4575
|
}
|
|
4511
|
-
|
|
4512
|
-
//#region src/fonts/bundle.ts
|
|
4576
|
+
// src/fonts/bundle.ts
|
|
4513
4577
|
/**
|
|
4514
4578
|
* Build-output emission for the timber-fonts plugin.
|
|
4515
4579
|
*
|
|
@@ -4597,8 +4661,7 @@ function writeFontManifest(pipeline, buildManifest, base = "/") {
|
|
|
4597
4661
|
}
|
|
4598
4662
|
for (const [importer, entries] of fontsByImporter) buildManifest.fonts[importer] = entries;
|
|
4599
4663
|
}
|
|
4600
|
-
|
|
4601
|
-
//#region src/plugins/fonts.ts
|
|
4664
|
+
// src/plugins/fonts.ts
|
|
4602
4665
|
/**
|
|
4603
4666
|
* timber-fonts — Vite sub-plugin shell for build-time font processing.
|
|
4604
4667
|
*
|
|
@@ -4827,8 +4890,7 @@ function timberFonts(ctx) {
|
|
|
4827
4890
|
}
|
|
4828
4891
|
};
|
|
4829
4892
|
}
|
|
4830
|
-
|
|
4831
|
-
//#region src/server/flight-scripts.ts
|
|
4893
|
+
// src/server/flight-scripts.ts
|
|
4832
4894
|
/**
|
|
4833
4895
|
* Escape a JSON string for safe embedding inside an HTML `<script>` tag.
|
|
4834
4896
|
*
|
|
@@ -4838,8 +4900,7 @@ function timberFonts(ctx) {
|
|
|
4838
4900
|
function htmlEscapeJsonString(str) {
|
|
4839
4901
|
return str.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
4840
4902
|
}
|
|
4841
|
-
|
|
4842
|
-
//#region src/plugins/static-build.ts
|
|
4903
|
+
// src/plugins/static-build.ts
|
|
4843
4904
|
/**
|
|
4844
4905
|
* Patterns that indicate dynamic per-request API usage.
|
|
4845
4906
|
* These are build errors in static mode because there is no request at build time.
|
|
@@ -5331,8 +5392,7 @@ function timberStaticBuild(ctx) {
|
|
|
5331
5392
|
}
|
|
5332
5393
|
};
|
|
5333
5394
|
}
|
|
5334
|
-
|
|
5335
|
-
//#region src/plugins/build-manifest.ts
|
|
5395
|
+
// src/plugins/build-manifest.ts
|
|
5336
5396
|
/**
|
|
5337
5397
|
* timber-build-manifest — Vite sub-plugin for build asset manifest generation.
|
|
5338
5398
|
*
|
|
@@ -5540,8 +5600,7 @@ function timberBuildManifest(ctx) {
|
|
|
5540
5600
|
}
|
|
5541
5601
|
};
|
|
5542
5602
|
}
|
|
5543
|
-
|
|
5544
|
-
//#region src/dev-tools/logs.ts
|
|
5603
|
+
// src/dev-tools/logs.ts
|
|
5545
5604
|
/**
|
|
5546
5605
|
* Snapshot of the original console methods, captured at module load time
|
|
5547
5606
|
* (before any patching). Used as Vite's `customLogger` console so that
|
|
@@ -5810,8 +5869,7 @@ function timberDevLogs(_ctx) {
|
|
|
5810
5869
|
}
|
|
5811
5870
|
};
|
|
5812
5871
|
}
|
|
5813
|
-
|
|
5814
|
-
//#region src/dev-tools/browser-logs.ts
|
|
5872
|
+
// src/dev-tools/browser-logs.ts
|
|
5815
5873
|
/**
|
|
5816
5874
|
* Map timber's devBrowserLogs threshold to Vite 8's server.forwardConsole.
|
|
5817
5875
|
*
|
|
@@ -5840,8 +5898,7 @@ function resolveForwardConsole(threshold) {
|
|
|
5840
5898
|
logLevels
|
|
5841
5899
|
};
|
|
5842
5900
|
}
|
|
5843
|
-
|
|
5844
|
-
//#region src/plugins/react-prod.ts
|
|
5901
|
+
// src/plugins/react-prod.ts
|
|
5845
5902
|
/**
|
|
5846
5903
|
* Redirect React's CJS development bundles to production bundles.
|
|
5847
5904
|
*
|
|
@@ -5885,8 +5942,7 @@ function timberReactProd() {
|
|
|
5885
5942
|
}
|
|
5886
5943
|
};
|
|
5887
5944
|
}
|
|
5888
|
-
|
|
5889
|
-
//#region src/plugins/react-resolve.ts
|
|
5945
|
+
// src/plugins/react-resolve.ts
|
|
5890
5946
|
/**
|
|
5891
5947
|
* timber-react-resolve — Deduplicate React across timber and user project.
|
|
5892
5948
|
*
|
|
@@ -5985,8 +6041,7 @@ function timberReactResolve() {
|
|
|
5985
6041
|
}
|
|
5986
6042
|
};
|
|
5987
6043
|
}
|
|
5988
|
-
|
|
5989
|
-
//#region src/plugins/chunks.ts
|
|
6044
|
+
// src/plugins/chunks.ts
|
|
5990
6045
|
/**
|
|
5991
6046
|
* Build a map from absolute module IDs in non-facade RSC chunks to the
|
|
5992
6047
|
* absolute facade module paths that transitively import them.
|
|
@@ -6052,8 +6107,7 @@ function timberChunks(ctx) {
|
|
|
6052
6107
|
}
|
|
6053
6108
|
};
|
|
6054
6109
|
}
|
|
6055
|
-
|
|
6056
|
-
//#region src/plugins/client-chunks.ts
|
|
6110
|
+
// src/plugins/client-chunks.ts
|
|
6057
6111
|
/**
|
|
6058
6112
|
* Client chunk grouping strategy for @vitejs/plugin-rsc.
|
|
6059
6113
|
*
|
|
@@ -6185,8 +6239,7 @@ function clientChunkGroup(meta, appDir, root, sharedModuleFacades) {
|
|
|
6185
6239
|
}
|
|
6186
6240
|
return "client-shared";
|
|
6187
6241
|
}
|
|
6188
|
-
|
|
6189
|
-
//#region src/plugins/server-bundle.ts
|
|
6242
|
+
// src/plugins/server-bundle.ts
|
|
6190
6243
|
/**
|
|
6191
6244
|
* timber-server-bundle — Bundle all dependencies for server environments.
|
|
6192
6245
|
*
|
|
@@ -6296,8 +6349,7 @@ function timberServerBundle() {
|
|
|
6296
6349
|
}
|
|
6297
6350
|
];
|
|
6298
6351
|
}
|
|
6299
|
-
|
|
6300
|
-
//#region src/plugins/encryption-runtime.ts
|
|
6352
|
+
// src/plugins/encryption-runtime.ts
|
|
6301
6353
|
/**
|
|
6302
6354
|
* timber-encryption-runtime — route plugin-rsc's server-action encryption
|
|
6303
6355
|
* runtime to timber's (`rsc-runtime/encryption-runtime.ts`), which serializes
|
|
@@ -6323,8 +6375,7 @@ function timberEncryptionRuntime() {
|
|
|
6323
6375
|
}
|
|
6324
6376
|
};
|
|
6325
6377
|
}
|
|
6326
|
-
|
|
6327
|
-
//#region src/plugins/callsite-ast.ts
|
|
6378
|
+
// src/plugins/callsite-ast.ts
|
|
6328
6379
|
/**
|
|
6329
6380
|
* Shared AST helpers for callsite-ID transforms.
|
|
6330
6381
|
*
|
|
@@ -6619,8 +6670,7 @@ function findCallSites(node, matches, results) {
|
|
|
6619
6670
|
function generateStableCallsiteId(relativeModulePath, kind, statementText, callSpanText, occurrence) {
|
|
6620
6671
|
return fnv1aHash(`${relativeModulePath}:${kind}:${fnv1aHash(statementText)}:${fnv1aHash(callSpanText)}:${occurrence}`);
|
|
6621
6672
|
}
|
|
6622
|
-
|
|
6623
|
-
//#region src/plugins/cache.ts
|
|
6673
|
+
// src/plugins/cache.ts
|
|
6624
6674
|
/**
|
|
6625
6675
|
* timber-cache-transform — Vite plugin that injects stable callsite IDs
|
|
6626
6676
|
* into `cache.data()` calls imported from `@timber-js/app/cache`.
|
|
@@ -6776,8 +6826,7 @@ function timberCacheTransform(ctx) {
|
|
|
6776
6826
|
}
|
|
6777
6827
|
};
|
|
6778
6828
|
}
|
|
6779
|
-
|
|
6780
|
-
//#region src/plugins/request-dep/analysis.ts
|
|
6829
|
+
// src/plugins/request-dep/analysis.ts
|
|
6781
6830
|
/** `export default` has no local name of its own; this stands in for one. */
|
|
6782
6831
|
var DEFAULT_EXPORT = "default";
|
|
6783
6832
|
function createModuleFacts() {
|
|
@@ -6844,7 +6893,7 @@ function addToMapSet(map, key, value) {
|
|
|
6844
6893
|
if (existing) existing.add(value);
|
|
6845
6894
|
else map.set(key, /* @__PURE__ */ new Set([value]));
|
|
6846
6895
|
}
|
|
6847
|
-
function nameOf(node) {
|
|
6896
|
+
function nameOf$1(node) {
|
|
6848
6897
|
if (!node) return null;
|
|
6849
6898
|
if (node.type === "Identifier") return node.name;
|
|
6850
6899
|
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
@@ -6862,7 +6911,7 @@ function collectImportDeclaration(stmt, facts) {
|
|
|
6862
6911
|
const source = stmt.source?.value;
|
|
6863
6912
|
if (typeof source !== "string") return;
|
|
6864
6913
|
for (const spec of stmt.specifiers ?? []) {
|
|
6865
|
-
const local = nameOf(spec.local);
|
|
6914
|
+
const local = nameOf$1(spec.local);
|
|
6866
6915
|
if (!local) continue;
|
|
6867
6916
|
if (spec.type === "ImportNamespaceSpecifier") facts.importedBindings.set(local, {
|
|
6868
6917
|
source,
|
|
@@ -6874,7 +6923,7 @@ function collectImportDeclaration(stmt, facts) {
|
|
|
6874
6923
|
});
|
|
6875
6924
|
else if (spec.type === "ImportSpecifier") facts.importedBindings.set(local, {
|
|
6876
6925
|
source,
|
|
6877
|
-
imported: nameOf(spec.imported) ?? local
|
|
6926
|
+
imported: nameOf$1(spec.imported) ?? local
|
|
6878
6927
|
});
|
|
6879
6928
|
}
|
|
6880
6929
|
}
|
|
@@ -6893,8 +6942,8 @@ function collectExportNamed(stmt, facts) {
|
|
|
6893
6942
|
const specifiers = stmt.specifiers ?? [];
|
|
6894
6943
|
if (typeof source === "string") {
|
|
6895
6944
|
for (const spec of specifiers) {
|
|
6896
|
-
const imported = nameOf(spec.imported) ?? nameOf(spec.local);
|
|
6897
|
-
const exported = nameOf(spec.exported);
|
|
6945
|
+
const imported = nameOf$1(spec.imported) ?? nameOf$1(spec.local);
|
|
6946
|
+
const exported = nameOf$1(spec.exported);
|
|
6898
6947
|
if (imported && exported) facts.reExports.set(exported, {
|
|
6899
6948
|
source,
|
|
6900
6949
|
imported
|
|
@@ -6903,8 +6952,8 @@ function collectExportNamed(stmt, facts) {
|
|
|
6903
6952
|
return;
|
|
6904
6953
|
}
|
|
6905
6954
|
for (const spec of specifiers) {
|
|
6906
|
-
const local = nameOf(spec.local);
|
|
6907
|
-
const exported = nameOf(spec.exported);
|
|
6955
|
+
const local = nameOf$1(spec.local);
|
|
6956
|
+
const exported = nameOf$1(spec.exported);
|
|
6908
6957
|
if (local && exported) facts.localExports.set(exported, local);
|
|
6909
6958
|
}
|
|
6910
6959
|
const declaration = stmt.declaration;
|
|
@@ -6917,7 +6966,7 @@ function collectExportNamed(stmt, facts) {
|
|
|
6917
6966
|
function collectExportAll(stmt, facts) {
|
|
6918
6967
|
const source = stmt.source?.value;
|
|
6919
6968
|
if (typeof source !== "string") return;
|
|
6920
|
-
const exported = nameOf(stmt.exported);
|
|
6969
|
+
const exported = nameOf$1(stmt.exported);
|
|
6921
6970
|
if (exported) facts.reExports.set(exported, {
|
|
6922
6971
|
source,
|
|
6923
6972
|
imported: "*"
|
|
@@ -7086,8 +7135,7 @@ function analyzeModule(program) {
|
|
|
7086
7135
|
walk(program, facts);
|
|
7087
7136
|
return facts;
|
|
7088
7137
|
}
|
|
7089
|
-
|
|
7090
|
-
//#region src/plugins/request-dep/origin.ts
|
|
7138
|
+
// src/plugins/request-dep/origin.ts
|
|
7091
7139
|
var ACCESSOR_SOURCES = /* @__PURE__ */ new Set([
|
|
7092
7140
|
"@timber-js/app/server",
|
|
7093
7141
|
"next/headers",
|
|
@@ -7294,8 +7342,7 @@ function createOriginResolver(factsMap) {
|
|
|
7294
7342
|
}
|
|
7295
7343
|
};
|
|
7296
7344
|
}
|
|
7297
|
-
|
|
7298
|
-
//#region src/plugins/request-dep/index.ts
|
|
7345
|
+
// src/plugins/request-dep/index.ts
|
|
7299
7346
|
function isFrameworkModule(id) {
|
|
7300
7347
|
return /[\\/]node_modules[\\/]@timber-js[\\/]app[\\/]/.test(id) || /[\\/]packages[\\/]timber-app[\\/]src[\\/]/.test(id);
|
|
7301
7348
|
}
|
|
@@ -7499,8 +7546,430 @@ function walkSegmentTree(node, fn) {
|
|
|
7499
7546
|
if (node.children) for (const child of node.children) walkSegmentTree(child, fn);
|
|
7500
7547
|
if (node.slots) for (const slot of Object.values(node.slots)) walkSegmentTree(slot, fn);
|
|
7501
7548
|
}
|
|
7502
|
-
|
|
7503
|
-
|
|
7549
|
+
// src/plugins/optimize-package-imports-defaults.ts
|
|
7550
|
+
/**
|
|
7551
|
+
* Import specifiers whose barrel imports timber rewrites by default.
|
|
7552
|
+
*
|
|
7553
|
+
* Copied from Next.js's built-in `optimizePackageImports` list
|
|
7554
|
+
* (packages/next/src/server/config.ts, vercel/next.js@50bf604f2), so an app
|
|
7555
|
+
* moving from Next gets the same set without configuring it. Entries are exact
|
|
7556
|
+
* import specifiers, not package names: a package with several icon entry
|
|
7557
|
+
* points (`react-icons/fa`, `@heroicons/react/24/solid`) lists each one.
|
|
7558
|
+
*
|
|
7559
|
+
* See design/21-dev-server.md §"Barrel Import Optimization".
|
|
7560
|
+
*/
|
|
7561
|
+
var DEFAULT_OPTIMIZE_PACKAGE_IMPORTS = [
|
|
7562
|
+
"lucide-react",
|
|
7563
|
+
"date-fns",
|
|
7564
|
+
"lodash-es",
|
|
7565
|
+
"ramda",
|
|
7566
|
+
"antd",
|
|
7567
|
+
"react-bootstrap",
|
|
7568
|
+
"ahooks",
|
|
7569
|
+
"@ant-design/icons",
|
|
7570
|
+
"@headlessui/react",
|
|
7571
|
+
"@headlessui-float/react",
|
|
7572
|
+
"@heroicons/react/20/solid",
|
|
7573
|
+
"@heroicons/react/24/solid",
|
|
7574
|
+
"@heroicons/react/24/outline",
|
|
7575
|
+
"@visx/visx",
|
|
7576
|
+
"@tremor/react",
|
|
7577
|
+
"rxjs",
|
|
7578
|
+
"@mui/material",
|
|
7579
|
+
"@mui/icons-material",
|
|
7580
|
+
"recharts",
|
|
7581
|
+
"react-use",
|
|
7582
|
+
"effect",
|
|
7583
|
+
"@effect/schema",
|
|
7584
|
+
"@effect/platform",
|
|
7585
|
+
"@effect/platform-node",
|
|
7586
|
+
"@effect/platform-browser",
|
|
7587
|
+
"@effect/platform-bun",
|
|
7588
|
+
"@effect/sql",
|
|
7589
|
+
"@effect/sql-mssql",
|
|
7590
|
+
"@effect/sql-mysql2",
|
|
7591
|
+
"@effect/sql-pg",
|
|
7592
|
+
"@effect/sql-sqlite-node",
|
|
7593
|
+
"@effect/sql-sqlite-bun",
|
|
7594
|
+
"@effect/sql-sqlite-wasm",
|
|
7595
|
+
"@effect/sql-sqlite-react-native",
|
|
7596
|
+
"@effect/rpc",
|
|
7597
|
+
"@effect/rpc-http",
|
|
7598
|
+
"@effect/typeclass",
|
|
7599
|
+
"@effect/experimental",
|
|
7600
|
+
"@effect/opentelemetry",
|
|
7601
|
+
"@material-ui/core",
|
|
7602
|
+
"@material-ui/icons",
|
|
7603
|
+
"@tabler/icons-react",
|
|
7604
|
+
"mui-core",
|
|
7605
|
+
"react-icons/ai",
|
|
7606
|
+
"react-icons/bi",
|
|
7607
|
+
"react-icons/bs",
|
|
7608
|
+
"react-icons/cg",
|
|
7609
|
+
"react-icons/ci",
|
|
7610
|
+
"react-icons/di",
|
|
7611
|
+
"react-icons/fa",
|
|
7612
|
+
"react-icons/fa6",
|
|
7613
|
+
"react-icons/fc",
|
|
7614
|
+
"react-icons/fi",
|
|
7615
|
+
"react-icons/gi",
|
|
7616
|
+
"react-icons/go",
|
|
7617
|
+
"react-icons/gr",
|
|
7618
|
+
"react-icons/hi",
|
|
7619
|
+
"react-icons/hi2",
|
|
7620
|
+
"react-icons/im",
|
|
7621
|
+
"react-icons/io",
|
|
7622
|
+
"react-icons/io5",
|
|
7623
|
+
"react-icons/lia",
|
|
7624
|
+
"react-icons/lib",
|
|
7625
|
+
"react-icons/lu",
|
|
7626
|
+
"react-icons/md",
|
|
7627
|
+
"react-icons/pi",
|
|
7628
|
+
"react-icons/ri",
|
|
7629
|
+
"react-icons/rx",
|
|
7630
|
+
"react-icons/si",
|
|
7631
|
+
"react-icons/sl",
|
|
7632
|
+
"react-icons/tb",
|
|
7633
|
+
"react-icons/tfi",
|
|
7634
|
+
"react-icons/ti",
|
|
7635
|
+
"react-icons/vsc",
|
|
7636
|
+
"react-icons/wi"
|
|
7637
|
+
];
|
|
7638
|
+
// src/plugins/optimize-package-imports.ts
|
|
7639
|
+
/**
|
|
7640
|
+
* timber-optimize-package-imports — rewrites named imports from a listed
|
|
7641
|
+
* barrel package into imports of only the modules that define those names.
|
|
7642
|
+
*
|
|
7643
|
+
* In dev, `@vitejs/plugin-rsc` keeps packages with a `react` peer dependency
|
|
7644
|
+
* in the rsc and ssr module graphs without pre-bundling them, so on the server
|
|
7645
|
+
* `import { Play } from 'lucide-react'` enters lucide's barrel and Vite
|
|
7646
|
+
* transforms all ~2,000 icon modules it re-exports, once per environment. A
|
|
7647
|
+
* build loads all of them too, before tree-shaking. The
|
|
7648
|
+
* rewrite turns that import into one of the icon's own file:
|
|
7649
|
+
*
|
|
7650
|
+
* import { Play } from 'lucide-react'
|
|
7651
|
+
* → import { default as Play } from "/…/lucide-react/dist/esm/icons/play.mjs";
|
|
7652
|
+
*
|
|
7653
|
+
* Next.js does the same for its `optimizePackageImports` list
|
|
7654
|
+
* (next-barrel-loader.ts, optimize_barrel.rs). It applies to every environment
|
|
7655
|
+
* in builds; in dev, to the server environments and only for packages Vite
|
|
7656
|
+
* compiles itself (the client environment pre-bundles them; the server
|
|
7657
|
+
* environments hand most other packages to Node). See design/21-dev-server.md
|
|
7658
|
+
* §"Barrel Import Optimization".
|
|
7659
|
+
*
|
|
7660
|
+
* Every rule here leans toward leaving the import alone. A missed rewrite costs
|
|
7661
|
+
* compile time; a wrong one breaks the app. An import is rewritten only when
|
|
7662
|
+
* the barrel is a pure barrel (nothing but imports and re-exports) and every
|
|
7663
|
+
* imported name is in its export map with a target that resolves to a file.
|
|
7664
|
+
*/
|
|
7665
|
+
/**
|
|
7666
|
+
* Merge the user's list with the defaults (Next's semantics: the user list
|
|
7667
|
+
* adds, never replaces). Config validation reports invalid entries without
|
|
7668
|
+
* stopping the dev server, so only the valid ones (non-empty strings) are used
|
|
7669
|
+
* here; a string list is not spread into characters, and an empty entry does
|
|
7670
|
+
* not match every quoted empty string.
|
|
7671
|
+
*/
|
|
7672
|
+
function resolveOptimizedPackages(user) {
|
|
7673
|
+
const extra = Array.isArray(user) ? user.filter((entry) => typeof entry === "string" && entry.trim() !== "") : [];
|
|
7674
|
+
return /* @__PURE__ */ new Set([...DEFAULT_OPTIMIZE_PACKAGE_IMPORTS, ...extra]);
|
|
7675
|
+
}
|
|
7676
|
+
function nameOf(node) {
|
|
7677
|
+
return node.type === "Literal" ? node.value : node.name;
|
|
7678
|
+
}
|
|
7679
|
+
/**
|
|
7680
|
+
* Read a barrel's export map, or null when the file is not a pure barrel.
|
|
7681
|
+
*
|
|
7682
|
+
* A pure barrel holds only imports, re-exports, and `export { local }` of an
|
|
7683
|
+
* imported binding (`import * as icons from './icons'; export { icons }`, which
|
|
7684
|
+
* lucide-react's barrel opens with). Anything that runs code of its own, a
|
|
7685
|
+
* declaration, an expression, a bare side-effect import, makes it not a barrel:
|
|
7686
|
+
* importing past it would skip that code. So does any directive except
|
|
7687
|
+
* `'use strict'`: a `'use client'` or `'use server'` barrel is a boundary
|
|
7688
|
+
* plugin-rsc draws around the barrel module itself, and importing past it would
|
|
7689
|
+
* load the re-exported files on the wrong side of it.
|
|
7690
|
+
*
|
|
7691
|
+
* `export default local` is not followed even when `local` is imported: it
|
|
7692
|
+
* exports the value `local` held when the barrel ran, not a live binding, so
|
|
7693
|
+
* importing `local` directly would see later reassignments the barrel's
|
|
7694
|
+
* default never does. `export { local as default }` is live and is followed.
|
|
7695
|
+
*
|
|
7696
|
+
* A source-phase or deferred import, or import attributes, change what the
|
|
7697
|
+
* barrel's binding is, so a barrel using them is not followed. An
|
|
7698
|
+
* `export {} from` with no names only runs the module, like a bare import.
|
|
7699
|
+
*
|
|
7700
|
+
* `export * from` adds no entries. A name it might supply is not in the map, so
|
|
7701
|
+
* an import of that name falls back; explicit exports shadow star exports, so
|
|
7702
|
+
* every name that is in the map is exact.
|
|
7703
|
+
*/
|
|
7704
|
+
function readBarrelExportMap(code, lang) {
|
|
7705
|
+
let program;
|
|
7706
|
+
try {
|
|
7707
|
+
program = parseAst(code, { lang });
|
|
7708
|
+
} catch {
|
|
7709
|
+
return null;
|
|
7710
|
+
}
|
|
7711
|
+
const imported = /* @__PURE__ */ new Map();
|
|
7712
|
+
for (const item of program.body) {
|
|
7713
|
+
if (item.type !== "ImportDeclaration" || item.importKind === "type") continue;
|
|
7714
|
+
const source = item.source.value;
|
|
7715
|
+
for (const spec of item.specifiers) if (spec.type === "ImportSpecifier") {
|
|
7716
|
+
if (spec.importKind === "type") continue;
|
|
7717
|
+
imported.set(spec.local.name, {
|
|
7718
|
+
source,
|
|
7719
|
+
imported: nameOf(spec.imported)
|
|
7720
|
+
});
|
|
7721
|
+
} else if (spec.type === "ImportDefaultSpecifier") imported.set(spec.local.name, {
|
|
7722
|
+
source,
|
|
7723
|
+
imported: "default"
|
|
7724
|
+
});
|
|
7725
|
+
else imported.set(spec.local.name, {
|
|
7726
|
+
source,
|
|
7727
|
+
imported: "*"
|
|
7728
|
+
});
|
|
7729
|
+
}
|
|
7730
|
+
const exports = /* @__PURE__ */ new Map();
|
|
7731
|
+
for (const item of program.body) switch (item.type) {
|
|
7732
|
+
case "ExpressionStatement":
|
|
7733
|
+
if ("directive" in item && item.directive === "use strict") continue;
|
|
7734
|
+
return null;
|
|
7735
|
+
case "ImportDeclaration":
|
|
7736
|
+
if (item.importKind === "type") continue;
|
|
7737
|
+
if (item.specifiers.length === 0 || item.phase !== null || item.attributes.length > 0) return null;
|
|
7738
|
+
continue;
|
|
7739
|
+
case "ExportAllDeclaration":
|
|
7740
|
+
if (item.exportKind === "type") continue;
|
|
7741
|
+
if (item.attributes.length > 0) return null;
|
|
7742
|
+
if (item.exported) exports.set(nameOf(item.exported), {
|
|
7743
|
+
source: item.source.value,
|
|
7744
|
+
imported: "*"
|
|
7745
|
+
});
|
|
7746
|
+
continue;
|
|
7747
|
+
case "ExportNamedDeclaration":
|
|
7748
|
+
if (item.exportKind === "type") continue;
|
|
7749
|
+
if (item.declaration || item.attributes.length > 0) return null;
|
|
7750
|
+
if (item.source && item.specifiers.length === 0) return null;
|
|
7751
|
+
for (const spec of item.specifiers) {
|
|
7752
|
+
if (spec.exportKind === "type") continue;
|
|
7753
|
+
const local = nameOf(spec.local);
|
|
7754
|
+
const origin = item.source ? {
|
|
7755
|
+
source: item.source.value,
|
|
7756
|
+
imported: local
|
|
7757
|
+
} : imported.get(local);
|
|
7758
|
+
if (!origin) return null;
|
|
7759
|
+
exports.set(nameOf(spec.exported), origin);
|
|
7760
|
+
}
|
|
7761
|
+
continue;
|
|
7762
|
+
case "TSInterfaceDeclaration":
|
|
7763
|
+
case "TSTypeAliasDeclaration": continue;
|
|
7764
|
+
default: return null;
|
|
7765
|
+
}
|
|
7766
|
+
return exports;
|
|
7767
|
+
}
|
|
7768
|
+
var IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
|
|
7769
|
+
/** An export name as it must be written in an import or export clause. */
|
|
7770
|
+
function clauseName(name) {
|
|
7771
|
+
return IDENTIFIER_RE.test(name) ? name : JSON.stringify(name);
|
|
7772
|
+
}
|
|
7773
|
+
/**
|
|
7774
|
+
* The bindings a statement takes from `source`, or null when the statement is
|
|
7775
|
+
* not a candidate: a namespace import, `import type`, an import attribute, a
|
|
7776
|
+
* source phase import, or a statement with no value bindings.
|
|
7777
|
+
*/
|
|
7778
|
+
function statementBindings(item) {
|
|
7779
|
+
if (item.attributes.length > 0) return null;
|
|
7780
|
+
const bindings = [];
|
|
7781
|
+
if (item.type === "ImportDeclaration") {
|
|
7782
|
+
if (item.importKind === "type" || item.phase !== null) return null;
|
|
7783
|
+
for (const spec of item.specifiers) {
|
|
7784
|
+
if (spec.type === "ImportNamespaceSpecifier") return null;
|
|
7785
|
+
if (spec.type === "ImportDefaultSpecifier") bindings.push({
|
|
7786
|
+
barrelName: "default",
|
|
7787
|
+
as: spec.local.name
|
|
7788
|
+
});
|
|
7789
|
+
else if (spec.importKind !== "type") bindings.push({
|
|
7790
|
+
barrelName: nameOf(spec.imported),
|
|
7791
|
+
as: spec.local.name
|
|
7792
|
+
});
|
|
7793
|
+
}
|
|
7794
|
+
} else {
|
|
7795
|
+
if (item.exportKind === "type" || item.declaration) return null;
|
|
7796
|
+
for (const spec of item.specifiers) {
|
|
7797
|
+
if (spec.exportKind === "type") continue;
|
|
7798
|
+
bindings.push({
|
|
7799
|
+
barrelName: nameOf(spec.local),
|
|
7800
|
+
as: nameOf(spec.exported)
|
|
7801
|
+
});
|
|
7802
|
+
}
|
|
7803
|
+
}
|
|
7804
|
+
return bindings.length > 0 ? bindings : null;
|
|
7805
|
+
}
|
|
7806
|
+
/** The replacement statements for one candidate, or null to leave it alone. */
|
|
7807
|
+
async function rewriteStatement(item, barrel) {
|
|
7808
|
+
const bindings = statementBindings(item);
|
|
7809
|
+
if (!bindings) return null;
|
|
7810
|
+
const out = [];
|
|
7811
|
+
for (const { barrelName, as } of bindings) {
|
|
7812
|
+
const origin = barrel.exports.get(barrelName);
|
|
7813
|
+
if (!origin) return null;
|
|
7814
|
+
const target = await barrel.resolveTarget(origin.source);
|
|
7815
|
+
if (!target) return null;
|
|
7816
|
+
const from = JSON.stringify(target);
|
|
7817
|
+
if (item.type === "ImportDeclaration") out.push(origin.imported === "*" ? `import * as ${as} from ${from};` : `import { ${clauseName(origin.imported)} as ${as} } from ${from};`);
|
|
7818
|
+
else out.push(origin.imported === "*" ? `export * as ${clauseName(as)} from ${from};` : `export { ${clauseName(origin.imported)} as ${clauseName(as)} } from ${from};`);
|
|
7819
|
+
}
|
|
7820
|
+
return out.join(" ");
|
|
7821
|
+
}
|
|
7822
|
+
/**
|
|
7823
|
+
* Rewrite every import and `export { … } from` of a listed specifier whose
|
|
7824
|
+
* names the barrel's export map covers. Returns null when nothing changed.
|
|
7825
|
+
*
|
|
7826
|
+
* Replacements stay on the statement's own lines, so positions after it keep
|
|
7827
|
+
* their line numbers even before the source map is applied.
|
|
7828
|
+
*/
|
|
7829
|
+
async function rewriteBarrelImports(code, packages, loadBarrel) {
|
|
7830
|
+
let program;
|
|
7831
|
+
try {
|
|
7832
|
+
program = parseAst(code, { lang: "js" });
|
|
7833
|
+
} catch {
|
|
7834
|
+
return null;
|
|
7835
|
+
}
|
|
7836
|
+
let s = null;
|
|
7837
|
+
const barrels = /* @__PURE__ */ new Map();
|
|
7838
|
+
for (const item of program.body) {
|
|
7839
|
+
if (item.type !== "ImportDeclaration" && item.type !== "ExportNamedDeclaration") continue;
|
|
7840
|
+
const specifier = item.source?.value;
|
|
7841
|
+
if (specifier === void 0 || !packages.has(specifier)) continue;
|
|
7842
|
+
let barrel = barrels.get(specifier);
|
|
7843
|
+
if (barrel === void 0) {
|
|
7844
|
+
barrel = await loadBarrel(specifier);
|
|
7845
|
+
barrels.set(specifier, barrel);
|
|
7846
|
+
}
|
|
7847
|
+
if (!barrel) continue;
|
|
7848
|
+
const replacement = await rewriteStatement(item, barrel);
|
|
7849
|
+
if (replacement === null) continue;
|
|
7850
|
+
s ??= new MagicString(code);
|
|
7851
|
+
const lineBreaks = code.slice(item.start, item.end).split("\n").length - 1;
|
|
7852
|
+
s.overwrite(item.start, item.end, replacement + "\n".repeat(lineBreaks));
|
|
7853
|
+
}
|
|
7854
|
+
return s;
|
|
7855
|
+
}
|
|
7856
|
+
/** The npm package a bare specifier names: `@scope/pkg/sub` → `@scope/pkg`. */
|
|
7857
|
+
function packageNameOf(specifier) {
|
|
7858
|
+
const parts = specifier.split("/");
|
|
7859
|
+
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
7860
|
+
}
|
|
7861
|
+
/**
|
|
7862
|
+
* Whether the environment loads `specifier` through Vite rather than handing
|
|
7863
|
+
* it to Node. Only those imports are rewritten.
|
|
7864
|
+
*
|
|
7865
|
+
* A server environment externalizes most of node_modules in dev: Node loads
|
|
7866
|
+
* the package natively, so its barrel costs nothing to compile. Rewriting such
|
|
7867
|
+
* an import to a file path would pull that file into Vite's module graph
|
|
7868
|
+
* while any other import of the package stayed external, two instances of one
|
|
7869
|
+
* module. In dev, plugin-rsc keeps packages with a `react` peer dependency
|
|
7870
|
+
* (lucide-react, the icon sets, the component libraries) out of
|
|
7871
|
+
* externalization, and timber's production build sets `noExternal: true`.
|
|
7872
|
+
*
|
|
7873
|
+
* Vite's own check is internal, so this is its conservative subset: the
|
|
7874
|
+
* package must match `resolve.noExternal` exactly (a string or a RegExp) and
|
|
7875
|
+
* `resolve.external` must not name it. A glob string in `noExternal` does
|
|
7876
|
+
* not match here, which only costs the optimization.
|
|
7877
|
+
*/
|
|
7878
|
+
function isLoadedThroughVite(specifier, config) {
|
|
7879
|
+
const pkg = packageNameOf(specifier);
|
|
7880
|
+
const { noExternal, external } = config;
|
|
7881
|
+
if (external === true || external.includes(specifier) || external.includes(pkg)) return false;
|
|
7882
|
+
if (noExternal === true) return true;
|
|
7883
|
+
return (Array.isArray(noExternal) ? noExternal : [noExternal]).some((p) => typeof p === "string" ? p === pkg : p.test(pkg));
|
|
7884
|
+
}
|
|
7885
|
+
function langForFile(file) {
|
|
7886
|
+
if (file.endsWith(".tsx")) return "tsx";
|
|
7887
|
+
if (/\.[mc]?ts$/.test(file)) return "ts";
|
|
7888
|
+
if (file.endsWith(".jsx")) return "jsx";
|
|
7889
|
+
return "js";
|
|
7890
|
+
}
|
|
7891
|
+
/**
|
|
7892
|
+
* A resolved id as a plain file import, or null when it is not one (virtual,
|
|
7893
|
+
* relative, or carrying a query that changes what the module is).
|
|
7894
|
+
*
|
|
7895
|
+
* Vite's dev resolver appends `?v=<hash>` to files under node_modules, in the
|
|
7896
|
+
* server environments too, and appends the same query again when it resolves
|
|
7897
|
+
* the absolute path this rewrite emits. So the query is dropped, never copied:
|
|
7898
|
+
* the emitted path resolves to the same id the barrel's own import would, which
|
|
7899
|
+
* keeps one module instance per file.
|
|
7900
|
+
*/
|
|
7901
|
+
function asFilePath(id) {
|
|
7902
|
+
const path = id.replace(/\?v=[\w.-]+$/, "");
|
|
7903
|
+
return isAbsolute(path) && !path.includes("?") && !path.includes("\0") ? path : null;
|
|
7904
|
+
}
|
|
7905
|
+
function escapeRegExp(text) {
|
|
7906
|
+
return text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
7907
|
+
}
|
|
7908
|
+
function timberOptimizePackageImports(ctx) {
|
|
7909
|
+
let packages = /* @__PURE__ */ new Set();
|
|
7910
|
+
let isDev = false;
|
|
7911
|
+
let mentionsListed = /(?!)/;
|
|
7912
|
+
const exportMaps = /* @__PURE__ */ new Map();
|
|
7913
|
+
const targets = /* @__PURE__ */ new Map();
|
|
7914
|
+
const isInstalled = (path) => path.includes("/node_modules/");
|
|
7915
|
+
function exportMapFor(barrelPath) {
|
|
7916
|
+
const cached = exportMaps.get(barrelPath);
|
|
7917
|
+
if (cached !== void 0) return cached;
|
|
7918
|
+
let code;
|
|
7919
|
+
try {
|
|
7920
|
+
code = readFileSync(barrelPath, "utf8");
|
|
7921
|
+
} catch {
|
|
7922
|
+
return null;
|
|
7923
|
+
}
|
|
7924
|
+
const map = readBarrelExportMap(code, langForFile(barrelPath));
|
|
7925
|
+
if (isInstalled(barrelPath)) exportMaps.set(barrelPath, map);
|
|
7926
|
+
return map;
|
|
7927
|
+
}
|
|
7928
|
+
return {
|
|
7929
|
+
name: "timber-optimize-package-imports",
|
|
7930
|
+
configResolved(config) {
|
|
7931
|
+
isDev = config.command === "serve";
|
|
7932
|
+
packages = resolveOptimizedPackages(ctx.config.optimizePackageImports);
|
|
7933
|
+
const alternatives = [...packages].map(escapeRegExp).join("|");
|
|
7934
|
+
mentionsListed = new RegExp(`(["'])(?:${alternatives})\\1`);
|
|
7935
|
+
},
|
|
7936
|
+
async transform(code, id) {
|
|
7937
|
+
if (isDev && this.environment.config.consumer !== "server") return null;
|
|
7938
|
+
if (id.startsWith("\0") || !mentionsListed.test(code)) return null;
|
|
7939
|
+
const envName = this.environment.name;
|
|
7940
|
+
const { consumer, resolve } = this.environment.config;
|
|
7941
|
+
const s = await rewriteBarrelImports(code, packages, async (specifier) => {
|
|
7942
|
+
if (consumer === "server" && !isLoadedThroughVite(specifier, resolve)) return null;
|
|
7943
|
+
const resolved = await this.resolve(specifier, id);
|
|
7944
|
+
const barrelPath = resolved && !resolved.external ? asFilePath(resolved.id) : null;
|
|
7945
|
+
if (!barrelPath) return null;
|
|
7946
|
+
const installed = isInstalled(barrelPath);
|
|
7947
|
+
if (!installed) this.addWatchFile(barrelPath);
|
|
7948
|
+
const exports = exportMapFor(barrelPath);
|
|
7949
|
+
if (!exports) return null;
|
|
7950
|
+
return {
|
|
7951
|
+
exports,
|
|
7952
|
+
resolveTarget: async (source) => {
|
|
7953
|
+
if (!source.startsWith("./") && !source.startsWith("../")) return null;
|
|
7954
|
+
const key = `${envName}\0${barrelPath}\0${source}`;
|
|
7955
|
+
const cached = targets.get(key);
|
|
7956
|
+
if (cached !== void 0) return cached;
|
|
7957
|
+
const target = await this.resolve(source, barrelPath);
|
|
7958
|
+
const path = target && !target.external ? asFilePath(target.id) : null;
|
|
7959
|
+
if (installed) targets.set(key, path);
|
|
7960
|
+
return path;
|
|
7961
|
+
}
|
|
7962
|
+
};
|
|
7963
|
+
});
|
|
7964
|
+
if (!s) return null;
|
|
7965
|
+
return {
|
|
7966
|
+
code: s.toString(),
|
|
7967
|
+
map: s.generateMap({ hires: "boundary" })
|
|
7968
|
+
};
|
|
7969
|
+
}
|
|
7970
|
+
};
|
|
7971
|
+
}
|
|
7972
|
+
// src/plugins/callsite-jsx.ts
|
|
7504
7973
|
/**
|
|
7505
7974
|
* Try to extract a static JSON-safe value from an AST expression node.
|
|
7506
7975
|
* Returns `undefined` (not null — null is a valid JSON value) when the
|
|
@@ -7647,8 +8116,7 @@ function recordCallSiteProps(ctx, componentId, props) {
|
|
|
7647
8116
|
ctx.prebuiltCallSiteProps.set(componentId, existing);
|
|
7648
8117
|
}
|
|
7649
8118
|
}
|
|
7650
|
-
|
|
7651
|
-
//#region src/plugins/prebuilt-options-analysis.ts
|
|
8119
|
+
// src/plugins/prebuilt-options-analysis.ts
|
|
7652
8120
|
var EXPRESSION_WRAPPER_TYPES = /* @__PURE__ */ new Set([
|
|
7653
8121
|
"TSAsExpression",
|
|
7654
8122
|
"TSSatisfiesExpression",
|
|
@@ -7763,8 +8231,7 @@ function mayPrerender(call) {
|
|
|
7763
8231
|
if (slotsActive === "yes" && (ttl === "yes" || tags === "yes")) return false;
|
|
7764
8232
|
return true;
|
|
7765
8233
|
}
|
|
7766
|
-
|
|
7767
|
-
//#region src/plugins/prebuilt-capture.ts
|
|
8234
|
+
// src/plugins/prebuilt-capture.ts
|
|
7768
8235
|
/**
|
|
7769
8236
|
* Post-build prebuilt capture — Node-side orchestration (TIM-1119).
|
|
7770
8237
|
*
|
|
@@ -7899,8 +8366,7 @@ async function runPrebuiltCapture(ctx, rscDir) {
|
|
|
7899
8366
|
artifact: { path: prebuiltDir }
|
|
7900
8367
|
} : { summary };
|
|
7901
8368
|
}
|
|
7902
|
-
|
|
7903
|
-
//#region src/plugins/prebuilt.ts
|
|
8369
|
+
// src/plugins/prebuilt.ts
|
|
7904
8370
|
/**
|
|
7905
8371
|
* timber-prebuilt — Vite plugin that detects `cache.component(...)` call
|
|
7906
8372
|
* sites and rewrites them to `__prebuilt(stableId, component, options)`.
|
|
@@ -8167,6 +8633,8 @@ function timberPrebuilt(ctx) {
|
|
|
8167
8633
|
moduleComponents.delete(id);
|
|
8168
8634
|
bindingNames.delete(id);
|
|
8169
8635
|
}
|
|
8636
|
+
const devIds = ctx.dev && this?.environment?.name === "rsc" ? ctx.devPrebuiltComponentIds ??= /* @__PURE__ */ new Map() : null;
|
|
8637
|
+
devIds?.delete(id);
|
|
8170
8638
|
if (!code.includes("@timber-js/app/cache") && !code.includes("timber/cache")) return;
|
|
8171
8639
|
if (id.includes("node_modules")) return;
|
|
8172
8640
|
if (this?.environment?.name === "client") return;
|
|
@@ -8193,6 +8661,7 @@ function timberPrebuilt(ctx) {
|
|
|
8193
8661
|
occurrences.set(dupKey, occurrence + 1);
|
|
8194
8662
|
const componentId = generatePrebuiltId(relPath, stmtText, spanText, occurrence, displayName);
|
|
8195
8663
|
if (!ctx.dev && mayPrerender(call)) componentIds.push(componentId);
|
|
8664
|
+
if (devIds) devIds.set(id, [...devIds.get(id) ?? [], componentId]);
|
|
8196
8665
|
s.overwrite(call.callee.start, call.callee.end, "__prebuilt");
|
|
8197
8666
|
s.appendLeft(call.arguments[0].start, `${JSON.stringify(componentId)}, `);
|
|
8198
8667
|
}
|
|
@@ -8301,8 +8770,7 @@ function timberPrebuilt(ctx) {
|
|
|
8301
8770
|
}
|
|
8302
8771
|
};
|
|
8303
8772
|
}
|
|
8304
|
-
|
|
8305
|
-
//#region src/plugins/prerender-sugar.ts
|
|
8773
|
+
// src/plugins/prerender-sugar.ts
|
|
8306
8774
|
/**
|
|
8307
8775
|
* timber-prerender-sugar — Vite plugin that desugars `export const prerender`
|
|
8308
8776
|
* on page and layout files into `cache.component(...)` wrappers.
|
|
@@ -8519,8 +8987,7 @@ function timberPrerenderSugar(ctx) {
|
|
|
8519
8987
|
}
|
|
8520
8988
|
};
|
|
8521
8989
|
}
|
|
8522
|
-
|
|
8523
|
-
//#region src/plugins/cloudflare-wasm.ts
|
|
8990
|
+
// src/plugins/cloudflare-wasm.ts
|
|
8524
8991
|
/**
|
|
8525
8992
|
* timber-cloudflare-wasm — Handle WASM modules for Cloudflare Workers builds.
|
|
8526
8993
|
*
|
|
@@ -8608,8 +9075,7 @@ function timberCloudflareWasm(ctx) {
|
|
|
8608
9075
|
}
|
|
8609
9076
|
}];
|
|
8610
9077
|
}
|
|
8611
|
-
|
|
8612
|
-
//#region src/plugins/rsc-assets-manifest.ts
|
|
9078
|
+
// src/plugins/rsc-assets-manifest.ts
|
|
8613
9079
|
/**
|
|
8614
9080
|
* The RSC plugin's assets manifest (`__vite_rsc_assets_manifest.js`) — read
|
|
8615
9081
|
* into the build manifest, and stripped of JavaScript when client JS is off.
|
|
@@ -8776,8 +9242,7 @@ async function stripJsFromRscAssetsManifests(serverDirs) {
|
|
|
8776
9242
|
await writeFile(path, `export default ${JSON.stringify(manifest, null, 2)};\n`);
|
|
8777
9243
|
}
|
|
8778
9244
|
}
|
|
8779
|
-
|
|
8780
|
-
//#region src/plugins/post-build.ts
|
|
9245
|
+
// src/plugins/post-build.ts
|
|
8781
9246
|
/** The Vite environments whose output adapters consume. */
|
|
8782
9247
|
var ARTIFACT_ENVIRONMENTS = [
|
|
8783
9248
|
"client",
|
|
@@ -8980,8 +9445,7 @@ function assembleBuildArtifacts(input) {
|
|
|
8980
9445
|
manifestInit: input.manifestInit
|
|
8981
9446
|
};
|
|
8982
9447
|
}
|
|
8983
|
-
|
|
8984
|
-
//#region src/plugins/build-report.ts
|
|
9448
|
+
// src/plugins/build-report.ts
|
|
8985
9449
|
/**
|
|
8986
9450
|
* timber-build-report — Post-build route summary table.
|
|
8987
9451
|
*
|
|
@@ -9351,8 +9815,7 @@ function timberBuildReport(ctx) {
|
|
|
9351
9815
|
}
|
|
9352
9816
|
};
|
|
9353
9817
|
}
|
|
9354
|
-
|
|
9355
|
-
//#region src/server/action-encryption.ts
|
|
9818
|
+
// src/server/action-encryption.ts
|
|
9356
9819
|
/**
|
|
9357
9820
|
* Regex for safe `defineEncryptionKey` expressions.
|
|
9358
9821
|
*
|
|
@@ -9410,8 +9873,7 @@ function validateKeyFormat(key) {
|
|
|
9410
9873
|
throw new Error("TIMBER_ACTIONS_ENCRYPTION_KEY is not valid base64. Generate a key with: node -e \"console.log(require('crypto').randomBytes(32).toString('base64'))\"");
|
|
9411
9874
|
}
|
|
9412
9875
|
}
|
|
9413
|
-
|
|
9414
|
-
//#region src/dev-tools/holding-server.ts
|
|
9876
|
+
// src/dev-tools/holding-server.ts
|
|
9415
9877
|
/**
|
|
9416
9878
|
* Dev holding server — serves a loading page while Vite initializes.
|
|
9417
9879
|
*
|
|
@@ -9574,8 +10036,7 @@ function resolveStartPort(input) {
|
|
|
9574
10036
|
}
|
|
9575
10037
|
return defaultPort;
|
|
9576
10038
|
}
|
|
9577
|
-
|
|
9578
|
-
//#region src/index.ts
|
|
10039
|
+
// src/index.ts
|
|
9579
10040
|
/**
|
|
9580
10041
|
* Type-safe helper for timber.config.ts files.
|
|
9581
10042
|
*
|
|
@@ -9737,7 +10198,7 @@ function timber(config) {
|
|
|
9737
10198
|
console: originalConsole
|
|
9738
10199
|
});
|
|
9739
10200
|
ctx.timer.start("client-deps-scan");
|
|
9740
|
-
const { clientOptimizeDepsEntries, skipUseServerScanPlugin } = await import("./_chunks/client-dep-entries-
|
|
10201
|
+
const { clientOptimizeDepsEntries, skipUseServerScanPlugin } = await import("./_chunks/client-dep-entries-CP7AkMCM.js");
|
|
9741
10202
|
const entries = await clientOptimizeDepsEntries(resolvedRoot, BROWSER_ENTRY_FILE, buildDir);
|
|
9742
10203
|
ctx.timer.end("client-deps-scan");
|
|
9743
10204
|
return {
|
|
@@ -9789,6 +10250,7 @@ function timber(config) {
|
|
|
9789
10250
|
timberBuildManifest(ctx),
|
|
9790
10251
|
fonts,
|
|
9791
10252
|
timberMdx(ctx),
|
|
10253
|
+
timberOptimizePackageImports(ctx),
|
|
9792
10254
|
timberRequestDep(ctx),
|
|
9793
10255
|
timberCacheTransform(ctx),
|
|
9794
10256
|
timberPrerenderSugar(ctx),
|
|
@@ -9808,7 +10270,6 @@ function timber(config) {
|
|
|
9808
10270
|
timberDevServer(ctx)
|
|
9809
10271
|
];
|
|
9810
10272
|
}
|
|
9811
|
-
//#endregion
|
|
9812
10273
|
export { timber as default, timber, defineConfig };
|
|
9813
10274
|
|
|
9814
10275
|
//# sourceMappingURL=index.js.map
|