@nifrajs/web 3.1.0 → 3.3.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/build-plan.d.ts +228 -0
- package/dist/build-plan.d.ts.map +1 -0
- package/dist/build-plan.js +514 -0
- package/dist/build-plan.js.map +1 -0
- package/dist/build-vite.d.ts +2 -1
- package/dist/build-vite.d.ts.map +1 -1
- package/dist/build-vite.js.map +1 -1
- package/dist/build.d.ts +2 -197
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +61 -502
- package/dist/build.js.map +1 -1
- package/dist/chunk-names.d.ts.map +1 -1
- package/dist/chunk-names.js +3 -2
- package/dist/chunk-names.js.map +1 -1
- package/dist/dev-ssr-graph.d.ts.map +1 -1
- package/dist/dev-ssr-graph.js +63 -28
- package/dist/dev-ssr-graph.js.map +1 -1
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +9 -2
- package/dist/diagnostic.js.map +1 -1
- package/dist/fonts-google.d.ts.map +1 -1
- package/dist/fonts-google.js +3 -1
- package/dist/fonts-google.js.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +2 -1
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +15 -609
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -1935
- package/dist/index.js.map +1 -1
- package/dist/internal/codegen.d.ts +68 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +317 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/head-merge.d.ts +2 -0
- package/dist/internal/head-merge.d.ts.map +1 -1
- package/dist/internal/head-merge.js +17 -1
- package/dist/internal/head-merge.js.map +1 -1
- package/dist/internal/parity.d.ts +7 -0
- package/dist/internal/parity.d.ts.map +1 -1
- package/dist/internal/parity.js +212 -30
- package/dist/internal/parity.js.map +1 -1
- package/dist/internal/render-document.d.ts +372 -0
- package/dist/internal/render-document.d.ts.map +1 -0
- package/dist/internal/render-document.js +744 -0
- package/dist/internal/render-document.js.map +1 -0
- package/dist/internal/runtime-contract.d.ts +48 -0
- package/dist/internal/runtime-contract.d.ts.map +1 -0
- package/dist/internal/runtime-contract.js +27 -0
- package/dist/internal/runtime-contract.js.map +1 -0
- package/dist/internal/web-app.d.ts +171 -0
- package/dist/internal/web-app.d.ts.map +1 -0
- package/dist/internal/web-app.js +844 -0
- package/dist/internal/web-app.js.map +1 -0
- package/dist/islands.d.ts +48 -0
- package/dist/islands.d.ts.map +1 -1
- package/dist/islands.js +79 -0
- package/dist/islands.js.map +1 -1
- package/dist/module-graph.d.ts.map +1 -1
- package/dist/module-graph.js +22 -9
- package/dist/module-graph.js.map +1 -1
- package/dist/nano.d.ts +125 -0
- package/dist/nano.d.ts.map +1 -0
- package/dist/nano.js +190 -0
- package/dist/nano.js.map +1 -0
- package/dist/plugins/css-modules.js +2 -2
- package/dist/plugins/css-modules.js.map +1 -1
- package/dist/plugins/kit.d.ts +12 -0
- package/dist/plugins/kit.d.ts.map +1 -1
- package/dist/plugins/kit.js +62 -12
- package/dist/plugins/kit.js.map +1 -1
- package/dist/plugins/postcss.js +2 -2
- package/dist/plugins/postcss.js.map +1 -1
- package/dist/plugins/scss.js +2 -2
- package/dist/plugins/scss.js.map +1 -1
- package/dist/plugins/stylex.d.ts +70 -0
- package/dist/plugins/stylex.d.ts.map +1 -0
- package/dist/plugins/stylex.js +166 -0
- package/dist/plugins/stylex.js.map +1 -0
- package/dist/plugins/svg.js +2 -2
- package/dist/plugins/svg.js.map +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/router.js +23 -23
- package/dist/router.js.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +26 -10
- package/dist/vite.js.map +1 -1
- package/package.json +39 -3
- package/src/build-plan.ts +741 -0
- package/src/build-vite.ts +1 -4
- package/src/build.ts +84 -716
- package/src/chunk-names.ts +3 -2
- package/src/dev-ssr-graph.ts +63 -28
- package/src/diagnostic.ts +14 -2
- package/src/fonts-google.ts +3 -1
- package/src/fs.ts +2 -1
- package/src/index.ts +73 -2705
- package/src/internal/codegen.ts +400 -0
- package/src/internal/head-merge.ts +19 -1
- package/src/internal/parity.ts +215 -35
- package/src/internal/render-document.ts +1116 -0
- package/src/internal/runtime-contract.ts +54 -0
- package/src/internal/web-app.ts +1114 -0
- package/src/islands.ts +85 -0
- package/src/module-graph.ts +23 -9
- package/src/nano.ts +246 -0
- package/src/plugins/css-modules.ts +2 -2
- package/src/plugins/kit.ts +65 -12
- package/src/plugins/postcss.ts +2 -2
- package/src/plugins/scss.ts +2 -2
- package/src/plugins/stylex.ts +298 -0
- package/src/plugins/svg.ts +2 -2
- package/src/router.ts +24 -24
- package/src/vite.ts +33 -9
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Phantom brand key for {@link ServerOnly}. */
|
|
2
|
+
declare const SERVER_ONLY_BRAND: unique symbol
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type-level intent marker for a value that must only exist on the server - a secret, a DB handle, a
|
|
6
|
+
* server-only client. `ServerOnly<T>` is structurally `T` (the brand is an optional phantom field, so
|
|
7
|
+
* existing code keeps type-checking), but it advertises to readers + the compiler that the value is
|
|
8
|
+
* not meant to cross to the browser. It is **purely type-level** and erases at build - it does NOT,
|
|
9
|
+
* by itself, keep the value out of the client bundle.
|
|
10
|
+
*
|
|
11
|
+
* The enforcement is two runtime conventions:
|
|
12
|
+
* - add the side-effect import `import "@nifrajs/web/server-only"` at the top of the module - the
|
|
13
|
+
* client build ({@link buildClient}) fails loud, with the import chain, if it reaches a browser
|
|
14
|
+
* chunk (the poison-import marker);
|
|
15
|
+
* - or name the file `*.server.ts` - the `.server` convention empties it in the client build.
|
|
16
|
+
*
|
|
17
|
+
* Use this brand to express the intent in the types; pair it with one of those runtime markers so a
|
|
18
|
+
* leak is caught at build time rather than shipping a secret to the client.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import "@nifrajs/web/server-only"
|
|
22
|
+
* import type { ServerOnly } from "@nifrajs/web"
|
|
23
|
+
* export const apiKey: ServerOnly<string> = process.env.SECRET_API_KEY!
|
|
24
|
+
*/
|
|
25
|
+
export type ServerOnly<T> = T & { readonly [SERVER_ONLY_BRAND]?: never }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Pre-hydration form guard - a tiny inline script flushed in `<head>` (it runs in the window between
|
|
29
|
+
* first paint and the island bundle taking over). It neutralizes the one real hydration footgun: a
|
|
30
|
+
* JS-only form (a hand-wired `onSubmit` with no native fallback) submitting *natively* before its
|
|
31
|
+
* handler is attached, which navigates the browser to a broken `?field=…` GET of the current page.
|
|
32
|
+
*
|
|
33
|
+
* It blocks ONLY that shape - an effective-GET form whose action targets the current document - and
|
|
34
|
+
* only until hydration commits (`data-nifra-hydrated`, set by the client entry). Method-`post` forms
|
|
35
|
+
* (progressive enhancement: the native POST hits the route `action`) and GET forms with a real action
|
|
36
|
+
* (a search box → `/search`) pass through untouched. Opt out per-form with `data-native`. Static text
|
|
37
|
+
* (no interpolation), so it can't carry injected markup. See the Hydration guide.
|
|
38
|
+
*/
|
|
39
|
+
export const PRE_HYDRATION_GUARD =
|
|
40
|
+
"(function(){addEventListener('submit',function(e){var f=e.target;" +
|
|
41
|
+
"if(!f||f.tagName!=='FORM'||f.hasAttribute('data-native'))return;" +
|
|
42
|
+
"if(document.documentElement.hasAttribute('data-nifra-hydrated'))return;" +
|
|
43
|
+
"var m=(f.getAttribute('method')||'get').toLowerCase();if(m==='post')return;" +
|
|
44
|
+
"var a=f.getAttribute('action');" +
|
|
45
|
+
"if(!a||a===''||a==='#'||a===location.pathname||a===location.href)e.preventDefault()" +
|
|
46
|
+
"},true)})()"
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The single default port for the dev server (`@nifrajs/web/dev`, `@nifrajs/web/vite`) **and**
|
|
50
|
+
* `nifra start`. Deliberately uncommon: `3000`/`5173`/`8080` collide with whatever else is running
|
|
51
|
+
* (Next, Vite, a stray Node API). `4321` rarely is - and being the *same* constant across `nifra dev`
|
|
52
|
+
* and `nifra start` means a project's URL doesn't change between commands. Override per-run with
|
|
53
|
+
* `--port <n>` or the `PORT` env var. */
|
|
54
|
+
export const DEFAULT_DEV_PORT = 4321
|