@nifrajs/web 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend-only.d.ts +15 -0
- package/dist/backend-only.d.ts.map +1 -0
- package/dist/backend-only.js +16 -0
- package/dist/backend-only.js.map +1 -0
- package/dist/boundary.d.ts +5 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +11 -2
- package/dist/boundary.js.map +1 -1
- package/dist/build-plan.d.ts +35 -6
- package/dist/build-plan.d.ts.map +1 -1
- package/dist/build-plan.js +89 -35
- package/dist/build-plan.js.map +1 -1
- package/dist/build-vite.d.ts +18 -0
- package/dist/build-vite.d.ts.map +1 -1
- package/dist/build-vite.js +97 -17
- package/dist/build-vite.js.map +1 -1
- package/dist/build.d.ts +72 -23
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +411 -98
- package/dist/build.js.map +1 -1
- package/dist/bun-dev-entry.d.ts +1 -1
- package/dist/bun-dev-entry.js +1 -1
- package/dist/cdn.d.ts +74 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/cdn.js +132 -0
- package/dist/cdn.js.map +1 -0
- package/dist/client.d.ts +21 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +226 -15
- package/dist/client.js.map +1 -1
- package/dist/conformance.d.ts +4 -3
- package/dist/conformance.d.ts.map +1 -1
- package/dist/conformance.js +12 -3
- package/dist/conformance.js.map +1 -1
- package/dist/csp.d.ts +93 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +122 -0
- package/dist/csp.js.map +1 -0
- package/dist/css-contract.d.ts +21 -0
- package/dist/css-contract.d.ts.map +1 -0
- package/dist/css-contract.js +28 -0
- package/dist/css-contract.js.map +1 -0
- package/dist/dev-client.d.ts +76 -0
- package/dist/dev-client.d.ts.map +1 -0
- package/dist/dev-client.js +280 -0
- package/dist/dev-client.js.map +1 -0
- package/dist/dev-diagnostics.d.ts +26 -2
- package/dist/dev-diagnostics.d.ts.map +1 -1
- package/dist/dev-diagnostics.js +38 -7
- package/dist/dev-diagnostics.js.map +1 -1
- package/dist/dev-error.d.ts +4 -13
- package/dist/dev-error.d.ts.map +1 -1
- package/dist/dev-error.js +46 -4
- package/dist/dev-error.js.map +1 -1
- package/dist/dev-feed.d.ts +298 -0
- package/dist/dev-feed.d.ts.map +1 -0
- package/dist/dev-feed.js +797 -0
- package/dist/dev-feed.js.map +1 -0
- package/dist/dev-indicator.d.ts +38 -0
- package/dist/dev-indicator.d.ts.map +1 -0
- package/dist/dev-indicator.js +93 -0
- package/dist/dev-indicator.js.map +1 -0
- package/dist/dev-session.d.ts +77 -0
- package/dist/dev-session.d.ts.map +1 -0
- package/dist/dev-session.js +580 -0
- package/dist/dev-session.js.map +1 -0
- package/dist/dev-sourcemap.d.ts +27 -0
- package/dist/dev-sourcemap.d.ts.map +1 -0
- package/dist/dev-sourcemap.js +235 -0
- package/dist/dev-sourcemap.js.map +1 -0
- package/dist/dev-ssr-graph.d.ts.map +1 -1
- package/dist/dev-ssr-graph.js +13 -5
- package/dist/dev-ssr-graph.js.map +1 -1
- package/dist/dev.d.ts +15 -2
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +69 -44
- package/dist/dev.js.map +1 -1
- package/dist/diagnostic-catalog.d.ts +35 -0
- package/dist/diagnostic-catalog.d.ts.map +1 -0
- package/dist/diagnostic-catalog.js +203 -0
- package/dist/diagnostic-catalog.js.map +1 -0
- package/dist/diagnostic-prompt.d.ts +49 -0
- package/dist/diagnostic-prompt.d.ts.map +1 -0
- package/dist/diagnostic-prompt.js +303 -0
- package/dist/diagnostic-prompt.js.map +1 -0
- package/dist/diagnostic.d.ts +17 -23
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +31 -39
- package/dist/diagnostic.js.map +1 -1
- package/dist/draft.d.ts.map +1 -1
- package/dist/draft.js +4 -1
- package/dist/draft.js.map +1 -1
- package/dist/fn.d.ts +5 -0
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +13 -3
- package/dist/fn.js.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +4 -2
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/cdn/cloudflare.d.ts +48 -0
- package/dist/internal/cdn/cloudflare.d.ts.map +1 -0
- package/dist/internal/cdn/cloudflare.js +94 -0
- package/dist/internal/cdn/cloudflare.js.map +1 -0
- package/dist/internal/cdn/core.d.ts +91 -0
- package/dist/internal/cdn/core.d.ts.map +1 -0
- package/dist/internal/cdn/core.js +220 -0
- package/dist/internal/cdn/core.js.map +1 -0
- package/dist/internal/cdn/fastly.d.ts +17 -0
- package/dist/internal/cdn/fastly.d.ts.map +1 -0
- package/dist/internal/cdn/fastly.js +43 -0
- package/dist/internal/cdn/fastly.js.map +1 -0
- package/dist/internal/cdn/vercel.d.ts +31 -0
- package/dist/internal/cdn/vercel.d.ts.map +1 -0
- package/dist/internal/cdn/vercel.js +56 -0
- package/dist/internal/cdn/vercel.js.map +1 -0
- package/dist/internal/code-unit-order.d.ts +4 -0
- package/dist/internal/code-unit-order.d.ts.map +1 -0
- package/dist/internal/code-unit-order.js +6 -0
- package/dist/internal/code-unit-order.js.map +1 -0
- package/dist/internal/codegen.d.ts +3 -0
- package/dist/internal/codegen.d.ts.map +1 -1
- package/dist/internal/codegen.js +151 -30
- package/dist/internal/codegen.js.map +1 -1
- package/dist/internal/dev-csp.d.ts +24 -0
- package/dist/internal/dev-csp.d.ts.map +1 -0
- package/dist/internal/dev-csp.js +160 -0
- package/dist/internal/dev-csp.js.map +1 -0
- package/dist/internal/dev-reserved.d.ts +25 -0
- package/dist/internal/dev-reserved.d.ts.map +1 -0
- package/dist/internal/dev-reserved.js +39 -0
- package/dist/internal/dev-reserved.js.map +1 -0
- package/dist/internal/html-spans.d.ts +10 -0
- package/dist/internal/html-spans.d.ts.map +1 -0
- package/dist/internal/html-spans.js +46 -0
- package/dist/internal/html-spans.js.map +1 -0
- package/dist/internal/loading-runtime.d.ts +44 -0
- package/dist/internal/loading-runtime.d.ts.map +1 -0
- package/dist/internal/loading-runtime.js +206 -0
- package/dist/internal/loading-runtime.js.map +1 -0
- package/dist/internal/matches-runtime.d.ts +8 -0
- package/dist/internal/matches-runtime.d.ts.map +1 -0
- package/dist/internal/matches-runtime.js +61 -0
- package/dist/internal/matches-runtime.js.map +1 -0
- package/dist/internal/mount-shadow.d.ts +36 -0
- package/dist/internal/mount-shadow.d.ts.map +1 -0
- package/dist/internal/mount-shadow.js +65 -0
- package/dist/internal/mount-shadow.js.map +1 -0
- package/dist/internal/node-builtins.d.ts +3 -0
- package/dist/internal/node-builtins.d.ts.map +1 -0
- package/dist/internal/node-builtins.js +79 -0
- package/dist/internal/node-builtins.js.map +1 -0
- package/dist/internal/output-guard.d.ts +65 -0
- package/dist/internal/output-guard.d.ts.map +1 -0
- package/dist/internal/output-guard.js +630 -0
- package/dist/internal/output-guard.js.map +1 -0
- package/dist/internal/page-execution.d.ts +69 -0
- package/dist/internal/page-execution.d.ts.map +1 -0
- package/dist/internal/page-execution.js +1021 -0
- package/dist/internal/page-execution.js.map +1 -0
- package/dist/internal/parity.d.ts +21 -0
- package/dist/internal/parity.d.ts.map +1 -1
- package/dist/internal/parity.js +104 -22
- package/dist/internal/parity.js.map +1 -1
- package/dist/internal/private-env.d.ts +12 -0
- package/dist/internal/private-env.d.ts.map +1 -0
- package/dist/internal/private-env.js +335 -0
- package/dist/internal/private-env.js.map +1 -0
- package/dist/internal/public-url.d.ts +3 -0
- package/dist/internal/public-url.d.ts.map +1 -0
- package/dist/internal/public-url.js +18 -0
- package/dist/internal/public-url.js.map +1 -0
- package/dist/internal/render-document.d.ts +37 -21
- package/dist/internal/render-document.d.ts.map +1 -1
- package/dist/internal/render-document.js +104 -65
- package/dist/internal/render-document.js.map +1 -1
- package/dist/internal/request-url.d.ts +3 -0
- package/dist/internal/request-url.d.ts.map +1 -0
- package/dist/internal/request-url.js +14 -0
- package/dist/internal/request-url.js.map +1 -0
- package/dist/internal/response-controls.d.ts +75 -0
- package/dist/internal/response-controls.d.ts.map +1 -0
- package/dist/internal/response-controls.js +256 -0
- package/dist/internal/response-controls.js.map +1 -0
- package/dist/internal/runtime-contract.d.ts +11 -16
- package/dist/internal/runtime-contract.d.ts.map +1 -1
- package/dist/internal/runtime-contract.js.map +1 -1
- package/dist/internal/secret-scan.d.ts +104 -0
- package/dist/internal/secret-scan.d.ts.map +1 -0
- package/dist/internal/secret-scan.js +485 -0
- package/dist/internal/secret-scan.js.map +1 -0
- package/dist/internal/server-boundary.d.ts +6 -29
- package/dist/internal/server-boundary.d.ts.map +1 -1
- package/dist/internal/server-boundary.js +6 -66
- package/dist/internal/server-boundary.js.map +1 -1
- package/dist/internal/source-map.d.ts +47 -0
- package/dist/internal/source-map.d.ts.map +1 -0
- package/dist/internal/source-map.js +225 -0
- package/dist/internal/source-map.js.map +1 -0
- package/dist/internal/target-compat.d.ts +27 -0
- package/dist/internal/target-compat.d.ts.map +1 -0
- package/dist/internal/target-compat.js +77 -0
- package/dist/internal/target-compat.js.map +1 -0
- package/dist/internal/timing-safe-equal.d.ts +6 -0
- package/dist/internal/timing-safe-equal.d.ts.map +1 -1
- package/dist/internal/timing-safe-equal.js +10 -0
- package/dist/internal/timing-safe-equal.js.map +1 -1
- package/dist/internal/vitals-runtime.d.ts +18 -0
- package/dist/internal/vitals-runtime.d.ts.map +1 -0
- package/dist/internal/vitals-runtime.js +38 -0
- package/dist/internal/vitals-runtime.js.map +1 -0
- package/dist/internal/web-app.d.ts +56 -8
- package/dist/internal/web-app.d.ts.map +1 -1
- package/dist/internal/web-app.js +215 -772
- package/dist/internal/web-app.js.map +1 -1
- package/dist/internal/zone-graph.d.ts +89 -0
- package/dist/internal/zone-graph.d.ts.map +1 -0
- package/dist/internal/zone-graph.js +492 -0
- package/dist/internal/zone-graph.js.map +1 -0
- package/dist/isr.d.ts +83 -6
- package/dist/isr.d.ts.map +1 -1
- package/dist/isr.js +301 -39
- package/dist/isr.js.map +1 -1
- package/dist/llms-txt.d.ts +3 -0
- package/dist/llms-txt.d.ts.map +1 -1
- package/dist/llms-txt.js +37 -9
- package/dist/llms-txt.js.map +1 -1
- package/dist/manifest.d.ts +221 -14
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +386 -9
- package/dist/manifest.js.map +1 -1
- package/dist/module-graph.d.ts +26 -5
- package/dist/module-graph.d.ts.map +1 -1
- package/dist/module-graph.js +17 -7
- package/dist/module-graph.js.map +1 -1
- package/dist/navigation.d.ts +17 -3
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +11 -5
- package/dist/navigation.js.map +1 -1
- package/dist/nonce.d.ts +47 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/nonce.js +63 -0
- package/dist/nonce.js.map +1 -0
- package/dist/plugins/css-modules.d.ts.map +1 -1
- package/dist/plugins/css-modules.js +4 -3
- package/dist/plugins/css-modules.js.map +1 -1
- package/dist/plugins/kit.d.ts +9 -0
- package/dist/plugins/kit.d.ts.map +1 -1
- package/dist/plugins/kit.js +18 -0
- package/dist/plugins/kit.js.map +1 -1
- package/dist/plugins/svg.d.ts +22 -3
- package/dist/plugins/svg.d.ts.map +1 -1
- package/dist/plugins/svg.js +112 -1
- package/dist/plugins/svg.js.map +1 -1
- package/dist/plugins/vite-leak-guard.d.ts +107 -3
- package/dist/plugins/vite-leak-guard.d.ts.map +1 -1
- package/dist/plugins/vite-leak-guard.js +378 -17
- package/dist/plugins/vite-leak-guard.js.map +1 -1
- package/dist/plugins/vite-zone-guard.d.ts +61 -0
- package/dist/plugins/vite-zone-guard.d.ts.map +1 -0
- package/dist/plugins/vite-zone-guard.js +208 -0
- package/dist/plugins/vite-zone-guard.js.map +1 -0
- package/dist/plugins/zone-guard.d.ts +27 -0
- package/dist/plugins/zone-guard.d.ts.map +1 -0
- package/dist/plugins/zone-guard.js +72 -0
- package/dist/plugins/zone-guard.js.map +1 -0
- package/dist/prerender.d.ts +10 -0
- package/dist/prerender.d.ts.map +1 -1
- package/dist/prerender.js +35 -3
- package/dist/prerender.js.map +1 -1
- package/dist/public-dir.d.ts +9 -0
- package/dist/public-dir.d.ts.map +1 -1
- package/dist/public-dir.js +131 -48
- package/dist/public-dir.js.map +1 -1
- package/dist/pwa-manifest.d.ts +68 -0
- package/dist/pwa-manifest.d.ts.map +1 -0
- package/dist/pwa-manifest.js +178 -0
- package/dist/pwa-manifest.js.map +1 -0
- package/dist/query.js +4 -4
- package/dist/query.js.map +1 -1
- package/dist/render-seam.d.ts +42 -2
- package/dist/render-seam.d.ts.map +1 -1
- package/dist/render-seam.js +6 -0
- package/dist/render-seam.js.map +1 -1
- package/dist/route-manifest.d.ts +3 -0
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +26 -3
- package/dist/route-manifest.js.map +1 -1
- package/dist/route-types.d.ts +24 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +195 -0
- package/dist/route-types.js.map +1 -0
- package/dist/router.d.ts +28 -6
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +129 -40
- package/dist/router.js.map +1 -1
- package/dist/trusted-html.d.ts +34 -0
- package/dist/trusted-html.d.ts.map +1 -0
- package/dist/trusted-html.js +35 -0
- package/dist/trusted-html.js.map +1 -0
- package/dist/vitals.d.ts +33 -0
- package/dist/vitals.d.ts.map +1 -0
- package/dist/vitals.js +16 -0
- package/dist/vitals.js.map +1 -0
- package/dist/vite.d.ts +16 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +187 -36
- package/dist/vite.js.map +1 -1
- package/dist/zones.d.ts +70 -0
- package/dist/zones.d.ts.map +1 -0
- package/dist/zones.js +365 -0
- package/dist/zones.js.map +1 -0
- package/package.json +67 -14
- package/src/backend-only.ts +16 -0
- package/src/boundary.ts +18 -5
- package/src/build-plan.ts +113 -36
- package/src/build-vite.ts +124 -15
- package/src/build.ts +535 -102
- package/src/bun-dev-entry.ts +1 -1
- package/src/cdn.ts +216 -0
- package/src/client.ts +251 -18
- package/src/conformance.ts +16 -3
- package/src/csp.ts +194 -0
- package/src/css-contract.ts +44 -0
- package/src/dev-client.ts +349 -0
- package/src/dev-diagnostics.ts +60 -7
- package/src/dev-error.ts +49 -5
- package/src/dev-feed.ts +1140 -0
- package/src/dev-indicator.ts +113 -0
- package/src/dev-session.ts +729 -0
- package/src/dev-sourcemap.ts +281 -0
- package/src/dev-ssr-graph.ts +16 -5
- package/src/dev.ts +86 -43
- package/src/diagnostic-catalog.ts +243 -0
- package/src/diagnostic-prompt.ts +355 -0
- package/src/diagnostic.ts +63 -66
- package/src/draft.ts +4 -1
- package/src/fn.ts +19 -3
- package/src/fs.ts +13 -2
- package/src/index.ts +57 -10
- package/src/internal/cdn/cloudflare.ts +146 -0
- package/src/internal/cdn/core.ts +316 -0
- package/src/internal/cdn/fastly.ts +62 -0
- package/src/internal/cdn/vercel.ts +95 -0
- package/src/internal/code-unit-order.ts +5 -0
- package/src/internal/codegen.ts +180 -29
- package/src/internal/dev-csp.ts +176 -0
- package/src/internal/dev-reserved.ts +52 -0
- package/src/internal/html-spans.ts +50 -0
- package/src/internal/loading-runtime.ts +244 -0
- package/src/internal/matches-runtime.ts +62 -0
- package/src/internal/mount-shadow.ts +88 -0
- package/src/internal/node-builtins.ts +79 -0
- package/src/internal/output-guard.ts +701 -0
- package/src/internal/page-execution.ts +1371 -0
- package/src/internal/parity.ts +150 -36
- package/src/internal/private-env.ts +334 -0
- package/src/internal/public-url.ts +22 -0
- package/src/internal/render-document.ts +153 -73
- package/src/internal/request-url.ts +14 -0
- package/src/internal/response-controls.ts +284 -0
- package/src/internal/runtime-contract.ts +10 -15
- package/src/internal/secret-scan.ts +623 -0
- package/src/internal/server-boundary.ts +6 -69
- package/src/internal/source-map.ts +256 -0
- package/src/internal/target-compat.ts +92 -0
- package/src/internal/timing-safe-equal.ts +13 -0
- package/src/internal/vitals-runtime.ts +53 -0
- package/src/internal/web-app.ts +290 -879
- package/src/internal/zone-graph.ts +593 -0
- package/src/isr.ts +366 -39
- package/src/llms-txt.ts +44 -8
- package/src/manifest.ts +671 -17
- package/src/module-graph.ts +53 -9
- package/src/navigation.ts +29 -6
- package/src/nonce.ts +104 -0
- package/src/plugins/css-modules.ts +5 -3
- package/src/plugins/kit.ts +24 -0
- package/src/plugins/svg.ts +135 -4
- package/src/plugins/vite-leak-guard.ts +529 -16
- package/src/plugins/vite-zone-guard.ts +263 -0
- package/src/plugins/zone-guard.ts +110 -0
- package/src/prerender.ts +49 -3
- package/src/public-dir.ts +135 -49
- package/src/pwa-manifest.ts +226 -0
- package/src/query.ts +4 -4
- package/src/render-seam.ts +46 -1
- package/src/route-manifest.ts +15 -3
- package/src/route-types.ts +264 -0
- package/src/router.ts +163 -63
- package/src/trusted-html.ts +44 -0
- package/src/vitals.ts +44 -0
- package/src/vite.ts +207 -36
- package/src/zones.ts +430 -0
- package/dist/plugins/vite-server-only.d.ts +0 -49
- package/dist/plugins/vite-server-only.d.ts.map +0 -1
- package/dist/plugins/vite-server-only.js +0 -57
- package/dist/plugins/vite-server-only.js.map +0 -1
- package/dist/server-only.d.ts +0 -21
- package/dist/server-only.d.ts.map +0 -1
- package/dist/server-only.js +0 -25
- package/dist/server-only.js.map +0 -1
- package/src/plugins/vite-server-only.ts +0 -75
- package/src/server-only.ts +0 -25
|
@@ -1,77 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The client-build transforms that every pipeline must apply identically - the Bun client build, the
|
|
3
|
+
* Vite dev server, the Vite production build, and `nifra dev --bun`:
|
|
3
4
|
*
|
|
4
|
-
* The client build must never ship server-only code, or server-only config, to a browser. Three
|
|
5
|
-
* conventions enforce that, and each has to mean the SAME thing in every pipeline that builds the client
|
|
6
|
-
* - the Bun client build, the Vite dev server, the Vite production build, and `nifra dev --bun`:
|
|
7
|
-
*
|
|
8
|
-
* - `*.server` modules - emptied, so a secret / `node:` / native import subtree never reaches the client.
|
|
9
5
|
* - `*.fn` modules - replaced with HTTP stubs, so the function bodies (and their imports) stay server-side.
|
|
10
6
|
* - public-env prefix - which environment variables the client bundle is allowed to inline.
|
|
11
7
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* the replacement bodies, and the env mapping get exactly one definition here; every pipeline imports it,
|
|
16
|
-
* and parity tests assert the Bun and Vite halves emit identical bytes. A matcher that decides whether a
|
|
17
|
-
* secret can reach a browser gets one owner, not four.
|
|
8
|
+
* Which files may reach a browser at all is the zone classifier's job (`zones.ts`). These two get one
|
|
9
|
+
* definition here so the Bun and Vite halves emit identical bytes; a copied-then-edited second version
|
|
10
|
+
* is how a client that works in dev and 404s in production happens.
|
|
18
11
|
*/
|
|
19
|
-
|
|
20
|
-
// `.ts`, `.tsx`, `.mts`, `.cts`, `.mjs`, `.cjs`, `.js`, `.jsx`, or none (the extensionless `db.server` /
|
|
21
|
-
// `todos.fn`). Kept adjacent so the shared shape is visible, and a parity test pins that the two never
|
|
22
|
-
// diverge on which extensions count - a copied-then-edited second tail is exactly how the old glob drifted.
|
|
23
|
-
/** Matches `db.server.ts`, `auth.server.tsx`, `x.server.mjs`, and the extensionless `foo.server`. */
|
|
24
|
-
export const SERVER_ONLY_MODULE = /\.server(\.[cm]?[jt]sx?)?$/;
|
|
25
|
-
/** Modules whose exports become client stubs. Mirrors the `.server` convention's shape. */
|
|
12
|
+
/** Modules whose exports become client stubs: `todos.fn.ts`, `x.fn.mjs`, or the extensionless `foo.fn`. */
|
|
26
13
|
export const SERVER_FN_MODULE = /\.fn(\.[cm]?[jt]sx?)?$/;
|
|
27
|
-
// ---------------------------------------------------------------------------------------------------
|
|
28
|
-
// `.server` - empty a server-only module in the client build.
|
|
29
|
-
// ---------------------------------------------------------------------------------------------------
|
|
30
|
-
/**
|
|
31
|
-
* The replacement body for an emptied module. A Proxy rather than `export {}` so any named OR default
|
|
32
|
-
* import resolves to `undefined` instead of failing the bundle with a missing-export error - the client
|
|
33
|
-
* degrades at the call site it wrote, not at link time in a file it never named.
|
|
34
|
-
*
|
|
35
|
-
* Shared so the Bun and Vite pipelines emit the same bytes; a parity test asserts it.
|
|
36
|
-
*/
|
|
37
|
-
export const SERVER_ONLY_REPLACEMENT = "module.exports = new Proxy({}, { get: () => undefined })";
|
|
38
14
|
import { jsStringLiteral } from "./js-string.js";
|
|
39
|
-
const EXPORTED_DECLARATION = /\bexport\s+(?:declare\s+)?(?:async\s+)?(?:const|let|var|function|class|enum)\s+([A-Za-z_$][\w$]*)/g;
|
|
40
|
-
const EXPORTED_LIST = /\bexport\s*\{([^}]*)\}(?:\s*from\s*["'][^"']+["'])?/g;
|
|
41
|
-
/**
|
|
42
|
-
* Vite dev serves native ESM, so the Bun/CommonJS proxy above is invalid there. Emit inert ESM
|
|
43
|
-
* bindings derived from the source's public names while discarding the implementation and imports.
|
|
44
|
-
* An unsupported exotic export fails closed at ESM link time; server code is never served as fallback.
|
|
45
|
-
*/
|
|
46
|
-
export function viteServerOnlyReplacement(source) {
|
|
47
|
-
const names = new Set();
|
|
48
|
-
let hasDefault = /\bexport\s+default\b/.test(source);
|
|
49
|
-
for (const match of source.matchAll(EXPORTED_DECLARATION))
|
|
50
|
-
names.add(match[1]);
|
|
51
|
-
for (const match of source.matchAll(EXPORTED_LIST)) {
|
|
52
|
-
for (const raw of (match[1] ?? "").split(",")) {
|
|
53
|
-
// Collapse runs of whitespace first (linear), so the ` as ` split below needs no `\s+as\s+`
|
|
54
|
-
// regex - adjacent unbounded quantifiers around a literal backtrack quadratically on crafted
|
|
55
|
-
// all-whitespace input.
|
|
56
|
-
const item = raw
|
|
57
|
-
.trim()
|
|
58
|
-
.replace(/\s+/g, " ")
|
|
59
|
-
.replace(/^type /, "");
|
|
60
|
-
if (item === "")
|
|
61
|
-
continue;
|
|
62
|
-
const parts = item.split(" as ");
|
|
63
|
-
const exported = (parts[1] ?? parts[0] ?? "").trim();
|
|
64
|
-
if (exported === "default")
|
|
65
|
-
hasDefault = true;
|
|
66
|
-
else if (/^[A-Za-z_$][\w$]*$/.test(exported))
|
|
67
|
-
names.add(exported);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const bindings = [...names].sort().map((name) => `export const ${name} = undefined`);
|
|
71
|
-
if (hasDefault)
|
|
72
|
-
bindings.push("export default undefined");
|
|
73
|
-
return `// Generated by @nifrajs/web: server-only implementation removed from the browser.\n${bindings.join("\n")}\n`;
|
|
74
|
-
}
|
|
75
15
|
// ---------------------------------------------------------------------------------------------------
|
|
76
16
|
// `.fn` - turn a server-function module into the client stubs that call it.
|
|
77
17
|
// ---------------------------------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-boundary.js","sourceRoot":"","sources":["../../src/internal/server-boundary.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server-boundary.js","sourceRoot":"","sources":["../../src/internal/server-boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,sGAAsG;AACtG,4EAA4E;AAC5E,sGAAsG;AAEtG;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;2FAI2F;AAC3F,MAAM,WAAW,GACf,kFAAkF,CAAA;AACpF;;0FAE0F;AAC1F,MAAM,QAAQ,GAAG,oBAAoB,CAAA;AACrC;;;;8DAI8D;AAC9D,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,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I,SAAS,CAAA;IACtC,gGAAgG;IAChG,0FAA0F;IAC1F,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,UAAU,CAAA;AACvE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source map v3 decoding, encoding and lookup, shared by the browser-frame mapper, the dev server's
|
|
3
|
+
* SSR frame remap and the SFC plugins that join several compiler outputs into one module. Node-free.
|
|
4
|
+
*/
|
|
5
|
+
/** A source map as its v3 JSON object. */
|
|
6
|
+
export interface RawSourceMap {
|
|
7
|
+
/** `3`; some compilers type it as the string. */
|
|
8
|
+
readonly version: number | string;
|
|
9
|
+
readonly sources: readonly string[];
|
|
10
|
+
readonly sourcesContent?: readonly (string | null)[] | undefined;
|
|
11
|
+
readonly names?: readonly string[] | undefined;
|
|
12
|
+
readonly mappings: string;
|
|
13
|
+
readonly file?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** One generated line's segments, flattened: [column, source, line, column] per segment, all absolute. */
|
|
16
|
+
export type MappingLine = Int32Array;
|
|
17
|
+
/** Decode a source map v3 `mappings` string. Segments without a source are dropped. */
|
|
18
|
+
export declare function decodeMappings(mappings: string): MappingLine[];
|
|
19
|
+
/** Encode decoded lines back into a `mappings` string. */
|
|
20
|
+
export declare function encodeMappings(lines: readonly MappingLine[]): string;
|
|
21
|
+
/** The source position for a 0-based generated line/column: the last segment at or before it. */
|
|
22
|
+
export declare function lookupPosition(lines: readonly (MappingLine | undefined)[], line: number, column: number): {
|
|
23
|
+
readonly source: number;
|
|
24
|
+
readonly line: number;
|
|
25
|
+
readonly column: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** Where a 1-based generated line/column came from in `map`'s first-listed sources, 1-based. */
|
|
28
|
+
export declare function originalPosition(map: RawSourceMap, line: number, column: number): {
|
|
29
|
+
readonly line: number;
|
|
30
|
+
readonly column: number;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** The map a module carries as a trailing base64 `sourceMappingURL` comment, when it does. */
|
|
33
|
+
export declare function inlineSourceMap(code: string): RawSourceMap | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* One map over parts joined with no separator, each part either mapped by its own map or unmapped
|
|
36
|
+
* (generated glue). Sources are merged by name.
|
|
37
|
+
*/
|
|
38
|
+
export declare function concatSourceMaps(parts: readonly {
|
|
39
|
+
readonly code: string;
|
|
40
|
+
readonly map?: RawSourceMap | undefined;
|
|
41
|
+
}[]): RawSourceMap;
|
|
42
|
+
/**
|
|
43
|
+
* The maps of modules a dev plugin compiled for SSR, by file path. Bun's runtime ignores a plugin's
|
|
44
|
+
* inline map, so a server stack names the compiled line; the dev server remaps through this.
|
|
45
|
+
*/
|
|
46
|
+
export declare function ssrSourceMaps(): Map<string, RawSourceMap>;
|
|
47
|
+
//# sourceMappingURL=source-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-map.d.ts","sourceRoot":"","sources":["../../src/internal/source-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,CAAA;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC;AAED,0GAA0G;AAC1G,MAAM,MAAM,WAAW,GAAG,UAAU,CAAA;AAMpC,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAgD9D;AAcD,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CA2BpE;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,EAC3C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAmBzF;AAID,gGAAgG;AAChG,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQhE;AAID,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAkBtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CAAE,EAAE,GACnF,YAAY,CAwCd;AAiBD;;;GAGG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAMzD"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source map v3 decoding, encoding and lookup, shared by the browser-frame mapper, the dev server's
|
|
3
|
+
* SSR frame remap and the SFC plugins that join several compiler outputs into one module. Node-free.
|
|
4
|
+
*/
|
|
5
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6
|
+
const BASE64_VALUE = new Int8Array(128).fill(-1);
|
|
7
|
+
for (let i = 0; i < BASE64.length; i++)
|
|
8
|
+
BASE64_VALUE[BASE64.charCodeAt(i)] = i;
|
|
9
|
+
/** Decode a source map v3 `mappings` string. Segments without a source are dropped. */
|
|
10
|
+
export function decodeMappings(mappings) {
|
|
11
|
+
const lines = [];
|
|
12
|
+
let segment = [];
|
|
13
|
+
let current = [];
|
|
14
|
+
let generatedColumn = 0;
|
|
15
|
+
let source = 0;
|
|
16
|
+
let sourceLine = 0;
|
|
17
|
+
let sourceColumn = 0;
|
|
18
|
+
let value = 0;
|
|
19
|
+
let shift = 0;
|
|
20
|
+
const endSegment = () => {
|
|
21
|
+
if (segment.length === 0)
|
|
22
|
+
return;
|
|
23
|
+
generatedColumn += segment[0] ?? 0;
|
|
24
|
+
if (segment.length >= 4) {
|
|
25
|
+
source += segment[1] ?? 0;
|
|
26
|
+
sourceLine += segment[2] ?? 0;
|
|
27
|
+
sourceColumn += segment[3] ?? 0;
|
|
28
|
+
current.push(generatedColumn, source, sourceLine, sourceColumn);
|
|
29
|
+
}
|
|
30
|
+
segment = [];
|
|
31
|
+
};
|
|
32
|
+
for (let i = 0; i < mappings.length; i++) {
|
|
33
|
+
const code = mappings.charCodeAt(i);
|
|
34
|
+
if (code === 44 /* , */) {
|
|
35
|
+
endSegment();
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (code === 59 /* ; */) {
|
|
39
|
+
endSegment();
|
|
40
|
+
lines.push(Int32Array.from(current));
|
|
41
|
+
current = [];
|
|
42
|
+
generatedColumn = 0;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const digit = code < 128 ? (BASE64_VALUE[code] ?? -1) : -1;
|
|
46
|
+
if (digit === -1)
|
|
47
|
+
throw new Error(`invalid VLQ character at ${i}`);
|
|
48
|
+
value += (digit & 31) << shift;
|
|
49
|
+
if (digit & 32) {
|
|
50
|
+
shift += 5;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
segment.push(value & 1 ? -(value >>> 1) : value >>> 1);
|
|
54
|
+
value = 0;
|
|
55
|
+
shift = 0;
|
|
56
|
+
}
|
|
57
|
+
endSegment();
|
|
58
|
+
lines.push(Int32Array.from(current));
|
|
59
|
+
return lines;
|
|
60
|
+
}
|
|
61
|
+
function vlq(value) {
|
|
62
|
+
let rest = value < 0 ? (-value << 1) | 1 : value << 1;
|
|
63
|
+
let out = "";
|
|
64
|
+
do {
|
|
65
|
+
let digit = rest & 31;
|
|
66
|
+
rest >>>= 5;
|
|
67
|
+
if (rest > 0)
|
|
68
|
+
digit |= 32;
|
|
69
|
+
out += BASE64[digit];
|
|
70
|
+
} while (rest > 0);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
/** Encode decoded lines back into a `mappings` string. */
|
|
74
|
+
export function encodeMappings(lines) {
|
|
75
|
+
let source = 0;
|
|
76
|
+
let sourceLine = 0;
|
|
77
|
+
let sourceColumn = 0;
|
|
78
|
+
return lines
|
|
79
|
+
.map((segments) => {
|
|
80
|
+
let generatedColumn = 0;
|
|
81
|
+
const parts = [];
|
|
82
|
+
for (let i = 0; i + 3 < segments.length; i += 4) {
|
|
83
|
+
const column = segments[i] ?? 0;
|
|
84
|
+
const s = segments[i + 1] ?? 0;
|
|
85
|
+
const l = segments[i + 2] ?? 0;
|
|
86
|
+
const c = segments[i + 3] ?? 0;
|
|
87
|
+
parts.push(vlq(column - generatedColumn) +
|
|
88
|
+
vlq(s - source) +
|
|
89
|
+
vlq(l - sourceLine) +
|
|
90
|
+
vlq(c - sourceColumn));
|
|
91
|
+
generatedColumn = column;
|
|
92
|
+
source = s;
|
|
93
|
+
sourceLine = l;
|
|
94
|
+
sourceColumn = c;
|
|
95
|
+
}
|
|
96
|
+
return parts.join(",");
|
|
97
|
+
})
|
|
98
|
+
.join(";");
|
|
99
|
+
}
|
|
100
|
+
/** The source position for a 0-based generated line/column: the last segment at or before it. */
|
|
101
|
+
export function lookupPosition(lines, line, column) {
|
|
102
|
+
const segments = lines[line];
|
|
103
|
+
if (segments === undefined || segments.length === 0)
|
|
104
|
+
return undefined;
|
|
105
|
+
let low = 0;
|
|
106
|
+
let high = segments.length / 4 - 1;
|
|
107
|
+
let found = -1;
|
|
108
|
+
while (low <= high) {
|
|
109
|
+
const mid = (low + high) >>> 1;
|
|
110
|
+
if ((segments[mid * 4] ?? 0) <= column) {
|
|
111
|
+
found = mid;
|
|
112
|
+
low = mid + 1;
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
high = mid - 1;
|
|
116
|
+
}
|
|
117
|
+
if (found === -1)
|
|
118
|
+
found = 0;
|
|
119
|
+
return {
|
|
120
|
+
source: segments[found * 4 + 1] ?? 0,
|
|
121
|
+
line: (segments[found * 4 + 2] ?? 0) + 1,
|
|
122
|
+
column: (segments[found * 4 + 3] ?? 0) + 1,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const decoded = new WeakMap();
|
|
126
|
+
/** Where a 1-based generated line/column came from in `map`'s first-listed sources, 1-based. */
|
|
127
|
+
export function originalPosition(map, line, column) {
|
|
128
|
+
let lines = decoded.get(map);
|
|
129
|
+
if (lines === undefined) {
|
|
130
|
+
lines = decodeMappings(map.mappings);
|
|
131
|
+
decoded.set(map, lines);
|
|
132
|
+
}
|
|
133
|
+
const found = lookupPosition(lines, line - 1, column - 1);
|
|
134
|
+
return found === undefined ? undefined : { line: found.line, column: found.column };
|
|
135
|
+
}
|
|
136
|
+
const INLINE_MAP = /\/\/[#@] sourceMappingURL=data:application\/json;base64,([A-Za-z0-9+/=]+)\s*$/;
|
|
137
|
+
/** The map a module carries as a trailing base64 `sourceMappingURL` comment, when it does. */
|
|
138
|
+
export function inlineSourceMap(code) {
|
|
139
|
+
const found = INLINE_MAP.exec(code.slice(-4 * 1024 * 1024));
|
|
140
|
+
if (found === null)
|
|
141
|
+
return undefined;
|
|
142
|
+
let parsed;
|
|
143
|
+
try {
|
|
144
|
+
parsed = JSON.parse(atob(found[1] ?? ""));
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
150
|
+
return undefined;
|
|
151
|
+
const mappings = Reflect.get(parsed, "mappings");
|
|
152
|
+
const sources = Reflect.get(parsed, "sources");
|
|
153
|
+
if (typeof mappings !== "string" || !Array.isArray(sources))
|
|
154
|
+
return undefined;
|
|
155
|
+
return {
|
|
156
|
+
version: 3,
|
|
157
|
+
sources: sources.map((source) => (typeof source === "string" ? source : "")),
|
|
158
|
+
mappings,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* One map over parts joined with no separator, each part either mapped by its own map or unmapped
|
|
163
|
+
* (generated glue). Sources are merged by name.
|
|
164
|
+
*/
|
|
165
|
+
export function concatSourceMaps(parts) {
|
|
166
|
+
const sources = [];
|
|
167
|
+
const sourcesContent = [];
|
|
168
|
+
const out = [[]];
|
|
169
|
+
for (const part of parts) {
|
|
170
|
+
const lineOffset = out.length - 1;
|
|
171
|
+
// A part that starts mid-line shifts its first line's columns by what is already on that line.
|
|
172
|
+
const columnOffset = lastLineLength(parts, part);
|
|
173
|
+
if (part.map !== undefined) {
|
|
174
|
+
const index = part.map.sources.map((source, i) => {
|
|
175
|
+
let at = sources.indexOf(source);
|
|
176
|
+
if (at === -1) {
|
|
177
|
+
at = sources.push(source) - 1;
|
|
178
|
+
sourcesContent.push(part.map?.sourcesContent?.[i] ?? null);
|
|
179
|
+
}
|
|
180
|
+
return at;
|
|
181
|
+
});
|
|
182
|
+
decodeMappings(part.map.mappings).forEach((segments, line) => {
|
|
183
|
+
const target = out[lineOffset + line] ?? [];
|
|
184
|
+
out[lineOffset + line] = target;
|
|
185
|
+
for (let i = 0; i + 3 < segments.length; i += 4) {
|
|
186
|
+
target.push((segments[i] ?? 0) + (line === 0 ? columnOffset : 0), index[segments[i + 1] ?? 0] ?? 0, segments[i + 2] ?? 0, segments[i + 3] ?? 0);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const newlines = part.code.split("\n").length - 1;
|
|
191
|
+
for (let i = 0; i < newlines; i++)
|
|
192
|
+
out[lineOffset + 1 + i] ??= [];
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
version: 3,
|
|
196
|
+
sources,
|
|
197
|
+
sourcesContent,
|
|
198
|
+
names: [],
|
|
199
|
+
mappings: encodeMappings(out.map((line) => Int32Array.from(line))),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function lastLineLength(parts, until) {
|
|
203
|
+
let length = 0;
|
|
204
|
+
for (const part of parts) {
|
|
205
|
+
if (part === until)
|
|
206
|
+
return length;
|
|
207
|
+
const newline = part.code.lastIndexOf("\n");
|
|
208
|
+
length = newline === -1 ? length + part.code.length : part.code.length - newline - 1;
|
|
209
|
+
}
|
|
210
|
+
return length;
|
|
211
|
+
}
|
|
212
|
+
const REGISTRY = Symbol.for("nifra.dev.ssrSourceMaps");
|
|
213
|
+
/**
|
|
214
|
+
* The maps of modules a dev plugin compiled for SSR, by file path. Bun's runtime ignores a plugin's
|
|
215
|
+
* inline map, so a server stack names the compiled line; the dev server remaps through this.
|
|
216
|
+
*/
|
|
217
|
+
export function ssrSourceMaps() {
|
|
218
|
+
const existing = Reflect.get(globalThis, REGISTRY);
|
|
219
|
+
if (existing instanceof Map)
|
|
220
|
+
return existing;
|
|
221
|
+
const created = new Map();
|
|
222
|
+
Reflect.set(globalThis, REGISTRY, created);
|
|
223
|
+
return created;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=source-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-map.js","sourceRoot":"","sources":["../../src/internal/source-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,MAAM,G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AAQ,YAAY,GAAG;QAAE,OAAO,QAAQ,CAAA;IAC5C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC/C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC1C,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which runtime built-ins a server bundle can load on its target. Separate from the zone rules: a
|
|
3
|
+
* backend module may import `node:fs`, but an edge worker cannot run it, and a Node server has no
|
|
4
|
+
* `bun:` modules. Same refusal and wording as the Vite edge build's guard.
|
|
5
|
+
*/
|
|
6
|
+
import type { ClientModuleGraph } from "../module-graph.js";
|
|
7
|
+
export type ServerBundleTarget = "browser" | "node" | "bun";
|
|
8
|
+
/**
|
|
9
|
+
* The `node:` built-ins every edge runtime nifra deploys to provides: Cloudflare Workers with
|
|
10
|
+
* `nodejs_compat` (the scaffold's wrangler.toml sets it), Vercel Edge and Deno. Svelte's server renderer
|
|
11
|
+
* imports `node:async_hooks` for AsyncLocalStorage.
|
|
12
|
+
*/
|
|
13
|
+
export declare const EDGE_NODE_BUILTINS: ReadonlySet<string>;
|
|
14
|
+
/** Whether a server bundle for `target` cannot load the built-in `specifier`. */
|
|
15
|
+
export declare function unsupportedBuiltin(specifier: string, target: ServerBundleTarget): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The built-ins a server bundle still loads that its target cannot, each with the modules that import
|
|
18
|
+
* them. A tree-shaken library module that imports `node:fs` is not one: only what the output keeps can
|
|
19
|
+
* fail. Two kinds are kept: an import the emitted code still makes (a dynamic `import()` that survived),
|
|
20
|
+
* and a static import of a built-in the bundler left external in a module that ships, which Bun's
|
|
21
|
+
* browser target replaces with an empty object that throws on first use. A chunk without `imports`
|
|
22
|
+
* evidence falls back to every module import, so missing evidence refuses.
|
|
23
|
+
*/
|
|
24
|
+
export declare function unsupportedBuiltins(graph: ClientModuleGraph, target: ServerBundleTarget, labelOf: (id: string) => string): ReadonlyMap<string, readonly string[]>;
|
|
25
|
+
/** The build-failing message for {@link unsupportedBuiltins}, or `undefined` when there are none. */
|
|
26
|
+
export declare function formatUnsupportedBuiltins(found: ReadonlyMap<string, readonly string[]>, target: ServerBundleTarget): string | undefined;
|
|
27
|
+
//# sourceMappingURL=target-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target-compat.d.ts","sourceRoot":"","sources":["../../src/internal/target-compat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,oBAAoB,CAAA;AAExE,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAA;AAS3D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAMjD,CAAA;AAEF,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAGzF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAC9B,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAuBxC;AAED,qGAAqG;AACrG,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAC7C,MAAM,EAAE,kBAAkB,GACzB,MAAM,GAAG,SAAS,CAepB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** Built-in prefixes each target cannot load. The `browser` target is the edge (workerd, edge-light). */
|
|
2
|
+
const UNSUPPORTED = {
|
|
3
|
+
browser: ["node:", "bun:"],
|
|
4
|
+
node: ["bun:"],
|
|
5
|
+
bun: [],
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The `node:` built-ins every edge runtime nifra deploys to provides: Cloudflare Workers with
|
|
9
|
+
* `nodejs_compat` (the scaffold's wrangler.toml sets it), Vercel Edge and Deno. Svelte's server renderer
|
|
10
|
+
* imports `node:async_hooks` for AsyncLocalStorage.
|
|
11
|
+
*/
|
|
12
|
+
export const EDGE_NODE_BUILTINS = new Set([
|
|
13
|
+
"node:assert",
|
|
14
|
+
"node:async_hooks",
|
|
15
|
+
"node:buffer",
|
|
16
|
+
"node:events",
|
|
17
|
+
"node:util",
|
|
18
|
+
]);
|
|
19
|
+
/** Whether a server bundle for `target` cannot load the built-in `specifier`. */
|
|
20
|
+
export function unsupportedBuiltin(specifier, target) {
|
|
21
|
+
if (target === "browser" && EDGE_NODE_BUILTINS.has(specifier))
|
|
22
|
+
return false;
|
|
23
|
+
return UNSUPPORTED[target].some((prefix) => specifier.startsWith(prefix));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The built-ins a server bundle still loads that its target cannot, each with the modules that import
|
|
27
|
+
* them. A tree-shaken library module that imports `node:fs` is not one: only what the output keeps can
|
|
28
|
+
* fail. Two kinds are kept: an import the emitted code still makes (a dynamic `import()` that survived),
|
|
29
|
+
* and a static import of a built-in the bundler left external in a module that ships, which Bun's
|
|
30
|
+
* browser target replaces with an empty object that throws on first use. A chunk without `imports`
|
|
31
|
+
* evidence falls back to every module import, so missing evidence refuses.
|
|
32
|
+
*/
|
|
33
|
+
export function unsupportedBuiltins(graph, target, labelOf) {
|
|
34
|
+
if (UNSUPPORTED[target].length === 0)
|
|
35
|
+
return new Map();
|
|
36
|
+
const unsupported = (spec) => unsupportedBuiltin(spec, target);
|
|
37
|
+
const specOf = (im) => im.original ?? im.path ?? "";
|
|
38
|
+
const chunks = Object.values(graph.chunks);
|
|
39
|
+
const evidence = chunks.every((chunk) => chunk.imports !== undefined);
|
|
40
|
+
const shipped = evidence
|
|
41
|
+
? new Set(chunks.flatMap((chunk) => chunk.modules))
|
|
42
|
+
: new Set(Object.keys(graph.modules));
|
|
43
|
+
const found = new Map();
|
|
44
|
+
const keep = (builtin) => {
|
|
45
|
+
if (unsupported(builtin) && !found.has(builtin))
|
|
46
|
+
found.set(builtin, new Set());
|
|
47
|
+
};
|
|
48
|
+
for (const chunk of chunks)
|
|
49
|
+
for (const spec of chunk.imports ?? [])
|
|
50
|
+
keep(spec);
|
|
51
|
+
for (const id of shipped) {
|
|
52
|
+
for (const im of graph.modules[id]?.imports ?? []) {
|
|
53
|
+
if (!evidence || (im.external === true && im.dynamic !== true))
|
|
54
|
+
keep(specOf(im));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const id of shipped) {
|
|
58
|
+
for (const im of graph.modules[id]?.imports ?? [])
|
|
59
|
+
found.get(specOf(im))?.add(labelOf(id));
|
|
60
|
+
}
|
|
61
|
+
return new Map([...found].map(([builtin, importers]) => [builtin, [...importers].sort()]));
|
|
62
|
+
}
|
|
63
|
+
/** The build-failing message for {@link unsupportedBuiltins}, or `undefined` when there are none. */
|
|
64
|
+
export function formatUnsupportedBuiltins(found, target) {
|
|
65
|
+
if (found.size === 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
const builtins = [...found.keys()].sort();
|
|
68
|
+
const importers = [...new Set([...found.values()].flat())].sort().join(", ") || "unknown module";
|
|
69
|
+
if (target === "browser") {
|
|
70
|
+
return (`[nifra/web] Node built-in(s) reached an edge server bundle: ${builtins.join(", ")}. ` +
|
|
71
|
+
`Imported by: ${importers}. ` +
|
|
72
|
+
"Move the import behind a Node/Bun target or replace it with an edge-compatible API.");
|
|
73
|
+
}
|
|
74
|
+
return (`[nifra/web] Bun built-in(s) reached a Node server bundle: ${builtins.join(", ")}. ` +
|
|
75
|
+
`Imported by: ${importers}. Build for the Bun target or replace it with a Node API.`);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=target-compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AAC,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC5F,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,yBAAyB,CACvC,KAA6C,EAC7C,MAA0B;IAE1B,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACtC,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACzC,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAA;IAChG,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,CACL,+DAA+D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACtF,gBAAgB,SAAS,IAAI;YAC7B,qFAAqF,CACtF,CAAA;IACH,CAAC;IACD,OAAO,CACL,6DAA6D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QACpF,gBAAgB,SAAS,2DAA2D,CACrF,CAAA;AACH,CAAC"}
|
|
@@ -13,4 +13,10 @@
|
|
|
13
13
|
* UTF-16 code unit.
|
|
14
14
|
*/
|
|
15
15
|
export declare function timingSafeEqual(a: string, b: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Boot-time guard for a shared bearer token checked with {@link timingSafeEqual}. A missing header or
|
|
18
|
+
* query parameter is compared as `""`, so an empty (or unset, then defaulted) secret would authorize
|
|
19
|
+
* every request that simply omits the token. Throws rather than letting that endpoint exist.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertTokenSecret(secret: unknown, label: string): asserts secret is string;
|
|
16
22
|
//# sourceMappingURL=timing-safe-equal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing-safe-equal.d.ts","sourceRoot":"","sources":["../../src/internal/timing-safe-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAQ7D"}
|
|
1
|
+
{"version":3,"file":"timing-safe-equal.d.ts","sourceRoot":"","sources":["../../src/internal/timing-safe-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAM1F"}
|
|
@@ -23,4 +23,14 @@ export function timingSafeEqual(a, b) {
|
|
|
23
23
|
diff |= ba[i] ^ bb[i];
|
|
24
24
|
return diff === 0;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Boot-time guard for a shared bearer token checked with {@link timingSafeEqual}. A missing header or
|
|
28
|
+
* query parameter is compared as `""`, so an empty (or unset, then defaulted) secret would authorize
|
|
29
|
+
* every request that simply omits the token. Throws rather than letting that endpoint exist.
|
|
30
|
+
*/
|
|
31
|
+
export function assertTokenSecret(secret, label) {
|
|
32
|
+
if (typeof secret !== "string" || secret.trim() === "") {
|
|
33
|
+
throw new TypeError(`[nifra] ${label} requires a non-empty secret; an empty one would accept requests that omit the token`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
//# sourceMappingURL=timing-safe-equal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing-safe-equal.js","sourceRoot":"","sources":["../../src/internal/timing-safe-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACxB,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACzC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAK,EAAE,CAAC,CAAC,CAAY,GAAI,EAAE,CAAC,CAAC,CAAY,CAAA;IACjF,OAAO,IAAI,KAAK,CAAC,CAAA;AACnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"timing-safe-equal.js","sourceRoot":"","sources":["../../src/internal/timing-safe-equal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IACxB,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACzC,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAK,EAAE,CAAC,CAAC,CAAY,GAAI,EAAE,CAAC,CAAC,CAAY,CAAA;IACjF,OAAO,IAAI,KAAK,CAAC,CAAA;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe,EAAE,KAAa;IAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACvD,MAAM,IAAI,SAAS,CACjB,WAAW,KAAK,sFAAsF,CACvG,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** `@nifrajs/web/vitals` with the metric library passed in, so tests can use a fake. */
|
|
2
|
+
import type { MetricType, ReportOpts } from "web-vitals";
|
|
3
|
+
import type { ReportWebVitalsOptions, WebVitalsMetric } from "../vitals.js";
|
|
4
|
+
type OnMetric = (report: (metric: MetricType) => void, options?: ReportOpts) => void;
|
|
5
|
+
/** The `web-vitals` functions the reporter registers with. */
|
|
6
|
+
export interface VitalsLibrary {
|
|
7
|
+
readonly onCLS: OnMetric;
|
|
8
|
+
readonly onFCP: OnMetric;
|
|
9
|
+
readonly onINP: OnMetric;
|
|
10
|
+
readonly onLCP: OnMetric;
|
|
11
|
+
readonly onTTFB: OnMetric;
|
|
12
|
+
}
|
|
13
|
+
/** Register `report` with every metric `library` measures. Each report is a fresh object, so a metric
|
|
14
|
+
* kept by the caller does not change when the library updates its own copy. On the server there is
|
|
15
|
+
* nothing to measure, and the returned stop function is a no-op. */
|
|
16
|
+
export declare function reportWith(library: VitalsLibrary, report: (metric: WebVitalsMetric) => void, options: ReportWebVitalsOptions): () => void;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=vitals-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitals-runtime.d.ts","sourceRoot":"","sources":["../../src/internal/vitals-runtime.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE3E,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;AAEpF,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;CAC1B;AAaD;;oEAEoE;AACpE,wBAAgB,UAAU,CACxB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,EACzC,OAAO,EAAE,sBAAsB,GAC9B,MAAM,IAAI,CAkBZ"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getBrowserRouter } from "../navigation.js";
|
|
2
|
+
/** The route id a measured URL matches, through the router `installHistory` registered. A metric of a
|
|
3
|
+
* client navigation names that navigation's URL; any other names the document's, and a library that
|
|
4
|
+
* names none falls back to the current one. */
|
|
5
|
+
function routeOf(url) {
|
|
6
|
+
const router = getBrowserRouter();
|
|
7
|
+
if (router === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
const target = new URL(url ?? location.href, location.href);
|
|
10
|
+
if (target.origin !== location.origin)
|
|
11
|
+
return undefined;
|
|
12
|
+
return router.match(target.pathname + target.search)?.routeId;
|
|
13
|
+
}
|
|
14
|
+
/** Register `report` with every metric `library` measures. Each report is a fresh object, so a metric
|
|
15
|
+
* kept by the caller does not change when the library updates its own copy. On the server there is
|
|
16
|
+
* nothing to measure, and the returned stop function is a no-op. */
|
|
17
|
+
export function reportWith(library, report, options) {
|
|
18
|
+
if (typeof document === "undefined")
|
|
19
|
+
return () => { };
|
|
20
|
+
let active = true;
|
|
21
|
+
const opts = {
|
|
22
|
+
reportAllChanges: options.reportAllChanges === true,
|
|
23
|
+
reportSoftNavs: options.softNavigations === true,
|
|
24
|
+
};
|
|
25
|
+
const forward = (metric) => {
|
|
26
|
+
if (active)
|
|
27
|
+
report({ ...metric, route: routeOf(metric.navigationURL) });
|
|
28
|
+
};
|
|
29
|
+
library.onCLS(forward, opts);
|
|
30
|
+
library.onFCP(forward, opts);
|
|
31
|
+
library.onINP(forward, opts);
|
|
32
|
+
library.onLCP(forward, opts);
|
|
33
|
+
library.onTTFB(forward, opts);
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=vitals-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitals-runtime.js","sourceRoot":"","sources":["../../src/internal/vitals-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAcnD;;+CAE+C;AAC/C,SAAS,OAAO,CAAC,GAAuB;IACtC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;IACjC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3D,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;QAAE,OAAO,SAAS,CAAA;IACvD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ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