@nifrajs/cli 5.13.0 → 5.14.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/CHANGELOG.md +27 -0
- package/README.md +3 -1
- package/dist/agent-files.js +0 -74
- package/dist/agent-files.js.map +1 -1
- package/dist/app-files.js +0 -19
- package/dist/app-files.js.map +1 -1
- package/dist/assure-hydration.js +0 -23
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.js +0 -14
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.js +0 -51
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/cdn-check.js +0 -2
- package/dist/cdn-check.js.map +1 -1
- package/dist/check-diagnostics.js +0 -29
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.js +10 -621
- package/dist/check-scan.js.map +1 -1
- package/dist/check.js +0 -86
- package/dist/check.js.map +1 -1
- package/dist/cli.js +3 -336
- package/dist/cli.js.map +1 -1
- package/dist/client-module.js +0 -13
- package/dist/client-module.js.map +1 -1
- package/dist/command-catalog.js +0 -21
- package/dist/command-catalog.js.map +1 -1
- package/dist/component-check.js +1 -7
- package/dist/component-check.js.map +1 -1
- package/dist/config-target.js +0 -13
- package/dist/config-target.js.map +1 -1
- package/dist/contract-proof.js +0 -1
- package/dist/contract-proof.js.map +1 -1
- package/dist/contracts.js +0 -36
- package/dist/contracts.js.map +1 -1
- package/dist/db-audit.js +0 -15
- package/dist/db-audit.js.map +1 -1
- package/dist/db-child.js +0 -20
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.js +0 -23
- package/dist/db-config.js.map +1 -1
- package/dist/db-tool.js +0 -24
- package/dist/db-tool.js.map +1 -1
- package/dist/deployment-adapters.js +1 -7
- package/dist/deployment-adapters.js.map +1 -1
- package/dist/dev-bun-config.js +0 -102
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.js +0 -32
- package/dist/dev-feed-tool.js.map +1 -1
- package/dist/dev-server-client.js +0 -16
- package/dist/dev-server-client.js.map +1 -1
- package/dist/diagnostics.js +0 -10
- package/dist/diagnostics.js.map +1 -1
- package/dist/diff-tool.js +0 -23
- package/dist/diff-tool.js.map +1 -1
- package/dist/docs-search.js +0 -35
- package/dist/docs-search.js.map +1 -1
- package/dist/doctor.js +3 -161
- package/dist/doctor.js.map +1 -1
- package/dist/env-file.js +0 -66
- package/dist/env-file.js.map +1 -1
- package/dist/examples.js +0 -16
- package/dist/examples.js.map +1 -1
- package/dist/fix-recipes.js +0 -20
- package/dist/fix-recipes.js.map +1 -1
- package/dist/frontend-guidance.js +0 -36
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.js +0 -17
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/hooks-report.js +0 -4
- package/dist/hooks-report.js.map +1 -1
- package/dist/i18n-check.js +0 -30
- package/dist/i18n-check.js.map +1 -1
- package/dist/init-agents.js +1 -133
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/code-unit-order.js +0 -2
- package/dist/internal/code-unit-order.js.map +1 -1
- package/dist/internal/config-paths.js +0 -12
- package/dist/internal/config-paths.js.map +1 -1
- package/dist/internal/control-character.js +0 -1
- package/dist/internal/control-character.js.map +1 -1
- package/dist/internal/escape-regexp.d.ts +1 -2
- package/dist/internal/escape-regexp.d.ts.map +1 -1
- package/dist/internal/escape-regexp.js +1 -4
- package/dist/internal/escape-regexp.js.map +1 -1
- package/dist/internal/git-ignored.js +0 -11
- package/dist/internal/git-ignored.js.map +1 -1
- package/dist/internal/installed-package.js +0 -2
- package/dist/internal/installed-package.js.map +1 -1
- package/dist/internal/line-at.js +0 -1
- package/dist/internal/line-at.js.map +1 -1
- package/dist/internal/nifra-project.js +0 -31
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.js +0 -1
- package/dist/internal/posix-path.js.map +1 -1
- package/dist/internal/project-specifiers.js +0 -34
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.js +0 -1
- package/dist/internal/realpath-or-self.js.map +1 -1
- package/dist/internal/record.d.ts +1 -1
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +1 -4
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/reserved-segment-codemod.js +0 -44
- package/dist/internal/reserved-segment-codemod.js.map +1 -1
- package/dist/internal/script-kind.js +0 -5
- package/dist/internal/script-kind.js.map +1 -1
- package/dist/internal/source-facts.js +3 -37
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.js +0 -49
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/internal/workspace-packages.js +0 -24
- package/dist/internal/workspace-packages.js.map +1 -1
- package/dist/introspect.js +1 -89
- package/dist/introspect.js.map +1 -1
- package/dist/learn.js +0 -16
- package/dist/learn.js.map +1 -1
- package/dist/levels-tool.js +0 -34
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.js +0 -75
- package/dist/load.js.map +1 -1
- package/dist/local-cli.js +0 -23
- package/dist/local-cli.js.map +1 -1
- package/dist/lock-links.js +0 -20
- package/dist/lock-links.js.map +1 -1
- package/dist/manifest-tool.js +0 -5
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-app-tool.js +0 -9
- package/dist/mcp-app-tool.js.map +1 -1
- package/dist/mcp-context.js +0 -30
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.js +0 -45
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-docs-tools.js +0 -13
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-exec.js +0 -71
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -38
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-io.d.ts +5 -1
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +3 -68
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.js +0 -28
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-path.js +0 -8
- package/dist/mcp-path.js.map +1 -1
- package/dist/mcp-project-child.js +0 -19
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-protocol.js +0 -5
- package/dist/mcp-protocol.js.map +1 -1
- package/dist/mcp-reflect.js +0 -11
- package/dist/mcp-reflect.js.map +1 -1
- package/dist/mcp-relay.d.ts +4 -0
- package/dist/mcp-relay.d.ts.map +1 -1
- package/dist/mcp-relay.js +9 -20
- package/dist/mcp-relay.js.map +1 -1
- package/dist/mcp-render.js +1 -42
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.js +0 -90
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.js +1 -38
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-tool-meta.js +3 -8
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/mcp-ws.js +0 -16
- package/dist/mcp-ws.js.map +1 -1
- package/dist/mcp.js +0 -86
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.js +0 -313
- package/dist/migrate-layout.js.map +1 -1
- package/dist/openapi-tool.js +0 -18
- package/dist/openapi-tool.js.map +1 -1
- package/dist/openapi-types.js +0 -22
- package/dist/openapi-types.js.map +1 -1
- package/dist/output-schemas.js +0 -67
- package/dist/output-schemas.js.map +1 -1
- package/dist/pipeline-guard.js +0 -58
- package/dist/pipeline-guard.js.map +1 -1
- package/dist/pipeline-report.js +0 -71
- package/dist/pipeline-report.js.map +1 -1
- package/dist/port.js +1 -89
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +0 -29
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/project-facts.js +0 -5
- package/dist/project-facts.js.map +1 -1
- package/dist/project-path.js +0 -7
- package/dist/project-path.js.map +1 -1
- package/dist/project-site.js +0 -2
- package/dist/project-site.js.map +1 -1
- package/dist/recipes/1.8.0.js +0 -9
- package/dist/recipes/1.8.0.js.map +1 -1
- package/dist/recipes/2.0.0.js +0 -6
- package/dist/recipes/2.0.0.js.map +1 -1
- package/dist/recipes/3.0.0.js +0 -7
- package/dist/recipes/3.0.0.js.map +1 -1
- package/dist/recipes/4.0.0.js +0 -6
- package/dist/recipes/4.0.0.js.map +1 -1
- package/dist/recipes/5.0.0.js +0 -8
- package/dist/recipes/5.0.0.js.map +1 -1
- package/dist/recipes/5.1.0.js +0 -6
- package/dist/recipes/5.1.0.js.map +1 -1
- package/dist/recipes/5.10.0.js +0 -10
- package/dist/recipes/5.10.0.js.map +1 -1
- package/dist/recipes/5.11.0.js +0 -7
- package/dist/recipes/5.11.0.js.map +1 -1
- package/dist/recipes/5.12.0.js +0 -6
- package/dist/recipes/5.12.0.js.map +1 -1
- package/dist/recipes/5.13.0.js +0 -6
- package/dist/recipes/5.13.0.js.map +1 -1
- package/dist/recipes/5.14.0.d.ts +10 -0
- package/dist/recipes/5.14.0.d.ts.map +1 -0
- package/dist/recipes/5.14.0.js +26 -0
- package/dist/recipes/5.14.0.js.map +1 -0
- package/dist/recipes/5.2.0.js +0 -7
- package/dist/recipes/5.2.0.js.map +1 -1
- package/dist/recipes/5.3.0.js +0 -8
- package/dist/recipes/5.3.0.js.map +1 -1
- package/dist/recipes/5.4.0.js +0 -8
- package/dist/recipes/5.4.0.js.map +1 -1
- package/dist/recipes/5.5.0.js +0 -6
- package/dist/recipes/5.5.0.js.map +1 -1
- package/dist/recipes/5.6.0.js +0 -7
- package/dist/recipes/5.6.0.js.map +1 -1
- package/dist/recipes/5.7.0.js +0 -9
- package/dist/recipes/5.7.0.js.map +1 -1
- package/dist/recipes/5.8.0.js +0 -6
- package/dist/recipes/5.8.0.js.map +1 -1
- package/dist/recipes/5.9.0.js +0 -9
- package/dist/recipes/5.9.0.js.map +1 -1
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -9
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.js +0 -14
- package/dist/release-verification.js.map +1 -1
- package/dist/replay.js +0 -3
- package/dist/replay.js.map +1 -1
- package/dist/review.js +0 -21
- package/dist/review.js.map +1 -1
- package/dist/route-types.js +0 -17
- package/dist/route-types.js.map +1 -1
- package/dist/rule-explain.js +0 -5
- package/dist/rule-explain.js.map +1 -1
- package/dist/rules/codes.js +0 -2
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/comment-markers.js +0 -25
- package/dist/rules/comment-markers.js.map +1 -1
- package/dist/rules/contract-visibility.js +0 -27
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.js +1 -52
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/internal-links.js +0 -36
- package/dist/rules/internal-links.js.map +1 -1
- package/dist/rules/islands.js +2 -65
- package/dist/rules/islands.js.map +1 -1
- package/dist/rules/layout.js +0 -1
- package/dist/rules/layout.js.map +1 -1
- package/dist/rules/legacy.js +0 -31
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/merge-auth.js +0 -9
- package/dist/rules/merge-auth.js.map +1 -1
- package/dist/rules/pages.js +0 -95
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/ppr.js +0 -8
- package/dist/rules/ppr.js.map +1 -1
- package/dist/rules/route-statement.js +0 -13
- package/dist/rules/route-statement.js.map +1 -1
- package/dist/rules/routes.js +1 -67
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/secrets.js +0 -15
- package/dist/rules/secrets.js.map +1 -1
- package/dist/rules/security.js +0 -113
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/server-fn-namespace.js +0 -5
- package/dist/rules/server-fn-namespace.js.map +1 -1
- package/dist/rules/source-scan.js +0 -5
- package/dist/rules/source-scan.js.map +1 -1
- package/dist/rules/swap.js +0 -21
- package/dist/rules/swap.js.map +1 -1
- package/dist/rules/text-slot-boolean.js +0 -5
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/rules/typescript.js +0 -5
- package/dist/rules/typescript.js.map +1 -1
- package/dist/rules/undeclared-response.js +0 -8
- package/dist/rules/undeclared-response.js.map +1 -1
- package/dist/rules/zones.js +0 -45
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.js +0 -20
- package/dist/runtime-differences.js.map +1 -1
- package/dist/scaffold-hole.js +1 -45
- package/dist/scaffold-hole.js.map +1 -1
- package/dist/scaffold.js +3 -60
- package/dist/scaffold.js.map +1 -1
- package/dist/sdk.js +1 -13
- package/dist/sdk.js.map +1 -1
- package/dist/search-terms.js +0 -12
- package/dist/search-terms.js.map +1 -1
- package/dist/shell-files.js +0 -15
- package/dist/shell-files.js.map +1 -1
- package/dist/shell-init.js +0 -15
- package/dist/shell-init.js.map +1 -1
- package/dist/smoke.js +0 -4
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.js +0 -43
- package/dist/source-rewrites.js.map +1 -1
- package/dist/stylex-migrate.js +0 -29
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.js +0 -3
- package/dist/symptom-search.js.map +1 -1
- package/dist/sync-manifest.js +3 -33
- package/dist/sync-manifest.js.map +1 -1
- package/dist/test-tool.js +0 -10
- package/dist/test-tool.js.map +1 -1
- package/dist/typecheck-coverage.js +0 -36
- package/dist/typecheck-coverage.js.map +1 -1
- package/dist/types-search.js +0 -35
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.js +0 -214
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.js +0 -19
- package/dist/verification-plan.js.map +1 -1
- package/dist/verification.js +0 -23
- package/dist/verification.js.map +1 -1
- package/dist/version-drift.js +0 -8
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.js +0 -16
- package/dist/web-app-options.js.map +1 -1
- package/dist/work-graph.js +0 -21
- package/dist/work-graph.js.map +1 -1
- package/dist/workspace-link.js +0 -31
- package/dist/workspace-link.js.map +1 -1
- package/docs/llms-full.txt +370 -31
- package/docs/types.json +152 -3
- package/package.json +12 -11
- package/src/assure-hydration.ts +3 -3
- package/src/cli.ts +5 -5
- package/src/internal/escape-regexp.ts +1 -4
- package/src/internal/record.ts +1 -3
- package/src/internal/typescript-import.ts +1 -1
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +8 -5
- package/src/mcp-relay.ts +19 -7
- package/src/mcp-render.ts +1 -1
- package/src/mcp-tool-meta.ts +3 -3
- package/src/recipes/5.14.0.ts +34 -0
- package/src/recipes/index.ts +2 -0
package/docs/llms-full.txt
CHANGED
|
@@ -12,7 +12,7 @@ nifra is a Bun-native, contract-first, framework-agnostic full-stack TypeScript
|
|
|
12
12
|
- **Secure by default.** Body-size cap, `requestTimeoutMs` + `c.signal`, graceful shutdown, redacting logger, same-origin `redirect()`, constant-time secret comparison, fail-closed middleware.
|
|
13
13
|
- **Money** in integer minor units; **time** parsed to absolute UTC at the boundary.
|
|
14
14
|
- Throwing a `Response` anywhere in the lifecycle is control flow (returned as-is), not an error.
|
|
15
|
-
Optional server components (all five adapters): React, Preact, Vue, Svelte and Solid share owner-GET admission, closed input/public-props schemas and private/no-store output. React uses native RSC/Flight. Use *.component.server.ts(x), defineServerComponent, an explicit componentPipeline named config export, native outlets and bindComponentRouter. Await invalidateComponentScope on identity/tenant/permission changes. Component GETs cannot acquire domain write privileges; use validated serverFn/actions for mutations. Native use-server actions are unsupported. Pin the certified compiler tuple documented in /docs/server-components.
|
|
15
|
+
Optional server components (all five adapters): React, Preact, Vue, Svelte and Solid share owner-GET admission, closed input/public-props schemas and private/no-store output. React uses native RSC/Flight; Vue, Svelte, Preact and the current Solid 1.x adapter use explicitly registered islands in validated server-rendered ranges. Solid 2's experimental frames protocol is not currently targeted. Use *.component.server.ts(x), defineServerComponent, an explicit componentPipeline named config export, native outlets and bindComponentRouter. Await invalidateComponentScope on identity/tenant/permission changes. Component GETs cannot acquire domain write privileges; use validated serverFn/actions for mutations. Native use-server actions are unsupported. Pin the certified compiler tuple documented in /docs/server-components.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -239,11 +239,16 @@ implementation, secrets and database handles off the browser and use the same va
|
|
|
239
239
|
mutation API across the supported UI libraries.
|
|
240
240
|
|
|
241
241
|
The optional server-components pipeline adds
|
|
242
|
-
server-only views and state-preserving refresh
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
server-only views and state-preserving refresh, but the render protocol depends on the UI
|
|
243
|
+
library. React uses native RSC/Flight. In Nifra's current certified adapters, Vue, Svelte,
|
|
244
|
+
Solid 1.x and Preact use an owned server-rendered range with schema-checked JSON props and
|
|
245
|
+
explicitly registered client islands as separate native roots; they do not emulate Flight.
|
|
246
|
+
Nested ranges, slots and data crossing those roots are explicit. Solid 2 has its own
|
|
247
|
+
experimental server-component frames protocol, but Nifra's current Solid tuple does not
|
|
248
|
+
target it. The shared certification covers admission, ownership, prop validation, limits and
|
|
249
|
+
safe hydration - it does not mean identical React component semantics.
|
|
250
|
+
A partially prerendered page can show a server component in a hole. Server functions remain
|
|
251
|
+
the mutation API; native React `"use server"` actions are unsupported.
|
|
247
252
|
|
|
248
253
|
### Caching and fresh data
|
|
249
254
|
|
|
@@ -294,14 +299,14 @@ to full-stack later without a rewrite.
|
|
|
294
299
|
**Throughput - the realistic case.** Router micro-benchmarks flatter Hono (a single compiled
|
|
295
300
|
regex), but a real request also pays for middleware and validation,
|
|
296
301
|
context, and serialization. In the current matrix Nifra runs **level with Elysia on Bun** -
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
**level with Fastify on Node** (
|
|
300
|
-
|
|
301
|
-
and Express behind. On **Deno** it runs at
|
|
302
|
-
GET and
|
|
302
|
+
100% of Elysia on `GET /users/:id` and
|
|
303
|
+
100% on the validated `POST` - and
|
|
304
|
+
**level with Fastify on Node** (104% of Fastify on GET,
|
|
305
|
+
104% on the validated `POST`), with Elysia, Hono,
|
|
306
|
+
and Express behind. On **Deno** it runs at 106% of Elysia on
|
|
307
|
+
GET and 130% on the validated `POST`. In the realistic shape (security headers + CORS +
|
|
303
308
|
bearer auth + cookies + validated query/body + a ~2.4 KB JSON response, measured on
|
|
304
|
-
**Bun** with `oha`) Nifra runs at **
|
|
309
|
+
**Bun** with `oha`) Nifra runs at **111% of Elysia on GET and 113% on POST**. Treat benchmark
|
|
305
310
|
rows as same-run evidence, not a permanent law of nature.
|
|
306
311
|
|
|
307
312
|
-
|
|
@@ -2194,7 +2199,228 @@ public registration API rather than as a bespoke dispatcher.
|
|
|
2194
2199
|
|
|
2195
2200
|
## Nifra - Server components
|
|
2196
2201
|
|
|
2197
|
-
> Server-only views with
|
|
2202
|
+
> Server-only views with closed schemas and owner-route authorization: native React RSC/Flight, or explicit server-rendered ranges and client islands for Vue, Svelte, Solid 1.x and Preact.
|
|
2203
|
+
|
|
2204
|
+
Compose server-only views and refresh their content while keeping native client state. React uses native RSC and Flight. Nifra's current certified Vue, Svelte, Solid 1.x and Preact adapters use schema-guarded server-rendered ranges with explicitly registered client islands, not a Flight-equivalent protocol.
|
|
2205
|
+
|
|
2206
|
+
This additive feature shipped in 5.0.0. All five adapters pass the same admission, ownership, limits and hydration-safety certification; that shared certification does not make their component semantics identical. Ordinary SSR, loaders, islands and server functions keep their existing APIs.
|
|
2207
|
+
|
|
2208
|
+
### Execution and public props
|
|
2209
|
+
|
|
2210
|
+
A `*.component.server.ts` or `*.component.server.tsx` module declares a closed input schema, closed public-props schema, authorization, a read operation and a view. The compiler replaces browser imports with an opaque typed handle. The server implementation and its imports stay in the server build.
|
|
2211
|
+
|
|
2212
|
+
```ts
|
|
2213
|
+
// Product.component.server.ts - native Vue/Svelte/Solid view.
|
|
2214
|
+
import { t } from "@nifrajs/schema"
|
|
2215
|
+
import { defineServerComponent, type ServerComponentContext } from "@nifrajs/web/server-components"
|
|
2216
|
+
import { nativeServerView } from "@nifrajs/web/server-components/islands"
|
|
2217
|
+
|
|
2218
|
+
// Replace these declarations with your native view and scoped read service.
|
|
2219
|
+
declare const ProductView: unknown
|
|
2220
|
+
declare function readProduct(ctx: ServerComponentContext, id: string): Promise<{ title: string; internal: string }>
|
|
2221
|
+
|
|
2222
|
+
export const Product = defineServerComponent({
|
|
2223
|
+
input: t.object({ id: t.string({ minLength: 1 }) }),
|
|
2224
|
+
props: t.object({ title: t.string() }),
|
|
2225
|
+
authorize(ctx, input) {
|
|
2226
|
+
if (ctx.params.id !== input.id) throw new Response(null, { status: 403 })
|
|
2227
|
+
},
|
|
2228
|
+
load: (ctx, input) => readProduct(ctx, input.id),
|
|
2229
|
+
view: () => nativeServerView(ProductView),
|
|
2230
|
+
})
|
|
2231
|
+
```
|
|
2232
|
+
|
|
2233
|
+
The input is validated before component authorization and loading. The load result is projected through the props schema, so undeclared fields such as `internal` never reach the view or browser. The view receives `{ props, children }`. Public values are bounded JSON: finite numbers, strings, booleans, null, arrays and plain objects. Functions, framework contexts, requests, bindings, class instances and executable closures cannot cross this seam.
|
|
2234
|
+
|
|
2235
|
+
Keep ownership checks in the scoped read service too. Every definition requires an authorization callback. Use `inheritOwnerAuthorization` only when the owning route already enforces the full resource authorization; it records an intentional choice to reuse that admission.
|
|
2236
|
+
|
|
2237
|
+
### Why non-React adapters use ranges
|
|
2238
|
+
|
|
2239
|
+
RSC is a React wire-format and runtime contract, not a generic SSR feature that every UI library can share. For the current Vue, Svelte, Solid 1.x and Preact adapters, the portable unit is an owned server-rendered HTML range: Nifra calls that framework's own SSR renderer for the range, places registered client islands behind owned markers, and sends bounded JSON props plus validated slot and nested-range HTML. The browser's matching native adapter then creates independent roots for those islands and updates their props or remounts them according to their stable reference and key. The server-rendered range itself is not interactive.
|
|
2240
|
+
|
|
2241
|
+
This is intentionally narrower than React RSC/Flight: non-React adapters do not have a Flight payload, server references, serialized closures, or automatic React-style server/client tree composition. Named slots and nested server ranges must be registered explicitly, and a separate native root does not inherit outer page context; pass the needed public data explicitly. Domain writes still go through a validated server function or route action, followed by a component refresh. Native `"use server"` actions are not part of Nifra's component contract.
|
|
2242
|
+
|
|
2243
|
+
Solid has a separate path here. Solid 2.0 RC exposes experimental reactive server components behind `serverFunctions: { components: true }`; its server functions return streamed Solid HTML that the Solid client applies in place through Solid's frames runtime. Nifra does not currently target that Solid 2 frames protocol: the certified tuple below is Solid 1.x with `vite-plugin-solid`, so the Nifra Solid adapter intentionally uses ordinary Solid SSR and hydration inside the shared range/island contract. Adding Solid 2 frames would require a separate renderer, the `installServerComponents()` client setup and a new version tuple; it would not turn the result into React Flight.
|
|
2244
|
+
|
|
2245
|
+
### Register the owning page
|
|
2246
|
+
|
|
2247
|
+
```ts
|
|
2248
|
+
// doc-check: skip - complete application entries are in examples/server-components.
|
|
2249
|
+
import { createWebApp } from "@nifrajs/web"
|
|
2250
|
+
import { componentBuild } from "@nifrajs/web/server-components/build-info"
|
|
2251
|
+
import { createServerComponents, serverComponentInstance } from "@nifrajs/web/server-components"
|
|
2252
|
+
import { vueServerComponents } from "@nifrajs/web-vue/server-components"
|
|
2253
|
+
import { Product } from "./Product.component.server"
|
|
2254
|
+
declare const deploymentId: string // stable and unique for this deployed environment
|
|
2255
|
+
|
|
2256
|
+
const components = createServerComponents({
|
|
2257
|
+
build: componentBuild,
|
|
2258
|
+
deployment: deploymentId,
|
|
2259
|
+
adapter: vueServerComponents(),
|
|
2260
|
+
owners: {
|
|
2261
|
+
"product/[id]": { // exact manifest route id, not a URL pattern
|
|
2262
|
+
components: [Product],
|
|
2263
|
+
scope: "anonymous", // personalized pages supply a public auth-scope token
|
|
2264
|
+
cache: {
|
|
2265
|
+
scope: "public",
|
|
2266
|
+
requestIndependent: true,
|
|
2267
|
+
revalidate: 300,
|
|
2268
|
+
tags: ["catalog"],
|
|
2269
|
+
},
|
|
2270
|
+
instances: (ctx) => [serverComponentInstance(Product, "product", { id: ctx.params.id })],
|
|
2271
|
+
},
|
|
2272
|
+
},
|
|
2273
|
+
})
|
|
2274
|
+
|
|
2275
|
+
export function createApp(clientEntry: string, assets: { styles?: readonly string[] }) {
|
|
2276
|
+
return createWebApp({ adapter, manifest, clientEntry, styles: assets.styles, serverComponents: components })
|
|
2277
|
+
}
|
|
2278
|
+
```
|
|
2279
|
+
|
|
2280
|
+
The owner lists the components and instances that may execute. A browser cannot invent a new instance or change its input. Initial HTML and hydration state reuse one execution. A refresh sends a bounded `x-nifra-component` selection to the actual owning page URL using same-origin GET.
|
|
2281
|
+
|
|
2282
|
+
Hooks, filesystem middleware, gate layouts, ordinary layouts and the page loader run before component work on both initial requests and refreshes. Ordinary layout and page loaders retain their parallel execution; use `gate: true` when a layout must block the page loader. Component execution preserves the admitted request's environment, API, response controls, cancellation, budgets and effect accounting.
|
|
2283
|
+
|
|
2284
|
+
Owners declare allowed capabilities and definitions may narrow that set. Domain writes are rejected in this GET path. Mutate through a validated server function or route action, then refresh after success. Native React `"use server"` actions and serialized closures are unsupported.
|
|
2285
|
+
|
|
2286
|
+
A partially prerendered page can instead show a component in a hole, rendered for each visitor after the shared shell; its route lists the component under `holes` rather than `owners`. See partial prerendering.
|
|
2287
|
+
|
|
2288
|
+
### Native views and client islands
|
|
2289
|
+
|
|
2290
|
+
React definitions return JSX in a compiler-generated RSC entry. `createReactComponentRenderer` resolves an allowlisted definition, guards its public props, and renders it with the plugin's React server renderer into a sanitized Flight stream. `reactServerComponents` consumes that stream, produces the initial HTML with React's server renderer, and carries the bounded Flight payload for hydration. The browser decodes the payload with React Flight and hydrates or creates a real React root; refreshes publish the next React tree into that root, preserving React state. One selected React component can additionally negotiate progressive Flight during an owner refresh; other cases use the bounded buffered response. Imported `"use client"` exports require a companion `*.props.ts` with a matching closed schema for every export. The compiler guards element creation and cloning before a client prop handoff.
|
|
2291
|
+
|
|
2292
|
+
Nifra's React path is still an opt-in owner/component pipeline, not a claim that every Nifra route becomes a Next.js App Router tree. Component inputs and public props are closed, bounded JSON; server references, serialized closures, arbitrary framework context and native React `"use server"` actions do not cross this public seam. Mutations use Nifra server functions or route actions, and progressive Flight is limited to one selected component with no mounted Nifra descendants. Multiple records, descendants, unsupported negotiation and all non-React adapters use the bounded buffered component response.
|
|
2293
|
+
|
|
2294
|
+
Vue, Svelte, Solid 1.x and Preact definitions return `nativeServerView(View, islands, ranges)`. Their native view receives public `props` plus named island and nested-range markup. Use `vueServerComponents()`, `svelteServerComponents()` or `solidServerComponents()` or `preactServerComponents()` with the matching client adapter.
|
|
2295
|
+
|
|
2296
|
+
Preact uses `preactServerComponents()` from `@nifrajs/web-preact/server-components`, `preactComponentClient({ islands })` from its `/client` subpath, and a typed `ServerComponent` from its `/outlet` subpath. Pass the controller or client adapter to the outlet and hydrate with Preact. Use `@preact/preset-vite` for JSX and development updates. Preact uses native Preact roots; `preact/compat` does not supply React Flight.
|
|
2297
|
+
|
|
2298
|
+
```ts
|
|
2299
|
+
// Counter.island.ts - compiler assigns an opaque reference.
|
|
2300
|
+
import { t } from "@nifrajs/schema"
|
|
2301
|
+
import { defineClientIsland, clientIsland } from "@nifrajs/web/server-components/islands"
|
|
2302
|
+
declare function Counter(props: { title: string }): null
|
|
2303
|
+
|
|
2304
|
+
export const counter = defineClientIsland({
|
|
2305
|
+
props: t.object({ title: t.string() }), component: Counter, slots: ["summary"],
|
|
2306
|
+
})
|
|
2307
|
+
// Inside a server view, pass this named island to nativeServerView(...).
|
|
2308
|
+
export const instance = clientIsland(counter, "counter", { title: "Public title" }, {
|
|
2309
|
+
summary: "<p>Server-owned summary</p>",
|
|
2310
|
+
})
|
|
2311
|
+
```
|
|
2312
|
+
|
|
2313
|
+
A stable island reference, key and parent keep the native root, state, DOM node, focus and text selection. Changed keys remount. Removal awaits disposal; reappearance mounts a fresh root. Named slots contain validated server-owned HTML. Nested ranges must refer to registered children of that parent. Use `serverComponentIdentity` when registering a child's parent and `serverComponentChild` when selecting a child's render.
|
|
2314
|
+
|
|
2315
|
+
Each component range has its own native root. Native context belongs to that root and its descendants; outer page context is not implicitly shared across independent roots. Pass explicit public data when a separate root needs it. Managed portals must use `componentPortalTarget` from `@nifrajs/web/server-components/portal`; targets outside the owned range are rejected and cleanup is awaited.
|
|
2316
|
+
|
|
2317
|
+
Outlets are available from each adapter's `/server-components/outlet` export. React, Solid and Preact export `ServerComponent`; Svelte exports a native generic component as default. Vue also offers a specialized outlet for render functions and templates:
|
|
2318
|
+
|
|
2319
|
+
```ts
|
|
2320
|
+
// doc-check: skip - component fragment; Product is a compiler-generated client handle.
|
|
2321
|
+
import { h } from "vue"
|
|
2322
|
+
import { createServerComponentOutlet } from "@nifrajs/web-vue/server-components/outlet"
|
|
2323
|
+
import { Product } from "./Product.component.server"
|
|
2324
|
+
const ProductOutlet = createServerComponentOutlet(Product)
|
|
2325
|
+
// Specialization keeps h() and SFC template inputs tied to Product's schema.
|
|
2326
|
+
h(ProductOutlet, { state, instanceKey: "product", input: { id }, controller, clientAdapter })
|
|
2327
|
+
```
|
|
2328
|
+
|
|
2329
|
+
### Client entry, navigation and mutations
|
|
2330
|
+
|
|
2331
|
+
```ts
|
|
2332
|
+
// doc-check: skip - integrate with the native client entry, not a second page root.
|
|
2333
|
+
import { ComponentController, bindComponentRouter, invalidateComponentScope,
|
|
2334
|
+
parseComponentState, refreshAfterComponentMutation } from "@nifrajs/web/server-components/client"
|
|
2335
|
+
import { vueComponentClient } from "@nifrajs/web-vue/server-components/client"
|
|
2336
|
+
import { counter } from "./Counter.island"
|
|
2337
|
+
|
|
2338
|
+
const state = parseComponentState(hydrationState)
|
|
2339
|
+
const clientAdapter = vueComponentClient({ islands: [counter] })
|
|
2340
|
+
const controller = new ComponentController({ state, adapter: clientAdapter })
|
|
2341
|
+
// Pass state, controller and clientAdapter to the page's native outlet.
|
|
2342
|
+
const stop = bindComponentRouter(router)
|
|
2343
|
+
await refreshAfterComponentMutation(save({ text }), controller, [state.records[0].instance])
|
|
2344
|
+
await invalidateComponentScope() // await this on logout or permission/tenant changes
|
|
2345
|
+
// On application disposal: stop(); await controller.dispose()
|
|
2346
|
+
```
|
|
2347
|
+
|
|
2348
|
+
Use `props.serverComponents` from the server render to initialize the outlet and controller. Hydrate with the adapter's native API. Install `bindComponentRouter` for navigation, retained layouts, history and action revalidation, and dispose its subscription with the application. Mutation helpers refresh only an `ok: true` result; failures keep the current content.
|
|
2349
|
+
|
|
2350
|
+
Auth-scope tokens are public identifiers, never cookies or credentials. Personalized owners must change their scope when identity, tenant or permissions change. Await `invalidateComponentScope()` before displaying another subject's content. Invalidation clears private records and native roots; subsequent authorized navigation can restore structural outlets. Denied refreshes also clear the scope.
|
|
2351
|
+
|
|
2352
|
+
Route epochs, auth epochs, generations and build IDs prevent obsolete fetches, imports or native preparation from committing. A failed update disposes the affected range and reports a typed error. There is no automatic 4xx retry. Version mismatch permits at most one controlled document reload for that build.
|
|
2353
|
+
|
|
2354
|
+
### Build and development
|
|
2355
|
+
|
|
2356
|
+
```ts
|
|
2357
|
+
// doc-check: skip - Vue compiler is an app dependency; the isolated tarball consumer compiles this config with the pinned plugin.
|
|
2358
|
+
// nifra.config.ts - named exports; no default config object.
|
|
2359
|
+
import vue from "@vitejs/plugin-vue"
|
|
2360
|
+
import { vueAdapter } from "@nifrajs/web-vue"
|
|
2361
|
+
export const adapter = vueAdapter
|
|
2362
|
+
export const clientModule = "@nifrajs/web-vue/client"
|
|
2363
|
+
export const vitePlugins = [vue()]
|
|
2364
|
+
export const componentPipeline = {
|
|
2365
|
+
adapter: "vue" as const,
|
|
2366
|
+
entries: { client: "entry.client.ts", ssr: "entry.backend.ts" },
|
|
2367
|
+
}
|
|
2368
|
+
// entry.backend.ts exports createApp(clientEntry, assets).
|
|
2369
|
+
// React also requires entries.rsc and an RSC renderer registry.
|
|
2370
|
+
```
|
|
2371
|
+
|
|
2372
|
+
`nifra dev` and `nifra build --target node` select the coordinated Vite pipeline when `componentPipeline` is exported. Other targets are `bun`, `deno`, `cloudflare` and `vercel`. Bun remains a supported runtime. The programmatic APIs are `buildServerComponents` and `devServerComponents` from `@nifrajs/web/server-components/build`.
|
|
2373
|
+
|
|
2374
|
+
The pipeline has complete application client/SSR entries; React adds an RSC entry. It generates target serving code, an integrity manifest and one generation across server and client assets. It rejects an ordinary backend import into client code, unregistered client props, unsupported target builtins, foreign references and mixed build generations. Source edits restart all development environments together. `nifra check --json` validates source receipts without executing configuration.
|
|
2375
|
+
|
|
2376
|
+
Keep the certified compiler tuple pinned in the application lockfile. React's framework-facing RSC APIs require exact alignment even when ordinary React SSR allows a broader peer range. The pipeline reads component modules with the TypeScript compiler API, which TypeScript 7 does not ship: on TypeScript 7 the build stops with `NIFRA_TS_UNSUPPORTED`, and `nifra check` reports the same code and checks each component module as an ordinary backend import.
|
|
2377
|
+
|
|
2378
|
+
| Dependency | Certified tuple |
|
|
2379
|
+
| --- | --- |
|
|
2380
|
+
| React / React DOM / Flight | 19.3.1 / 19.3.1 / 19.3.1 |
|
|
2381
|
+
| Vue / plugin-vue | 3.5.45 / 6.0.11 |
|
|
2382
|
+
| Svelte / plugin-svelte | 5.57.3 / 7.3.1 |
|
|
2383
|
+
| Solid / vite-plugin-solid | 1.9.19 / 2.11.16 |
|
|
2384
|
+
| Preact / render-to-string / preset-vite | 10.29.8 / 6.8.3 / 2.10.6 |
|
|
2385
|
+
| Vite / plugin-rsc | 8.3.8 / 0.5.39 |
|
|
2386
|
+
| TypeScript | 6.0.3 |
|
|
2387
|
+
|
|
2388
|
+
The runtime matrix covers Bun 1.3.14 and 1.4.4, Node 22.23.3 and 26.12.0, Deno 2.0.0 and 2.9.7, Cloudflare Workers and Pages under workerd compatibility date 2026-09-18, and Vercel's Node 22 entry. Browser certification uses Playwright 1.63.0 with Chromium 153.0.8010.12, Firefox 155.0 and WebKit 26.6. Vanilla retains ordinary SSR; its server-component opt-in is rejected.
|
|
2389
|
+
|
|
2390
|
+
### Streaming, caching and CSP
|
|
2391
|
+
|
|
2392
|
+
Progressive Flight currently applies to React owner refreshes for one selected component with no mounted Nifra descendants. Multiple components, descendants, other adapters, or refreshes without Flight negotiation use the bounded buffered response. This does not stream the initial owner HTML.
|
|
2393
|
+
|
|
2394
|
+
Enabling server components does not make every route private. Owner and hole-hosting routes and component transport responses remain `private, no-store` by default; non-owner routes keep their ordinary SSR and ISR behavior.
|
|
2395
|
+
|
|
2396
|
+
For a cacheable owner route, any request-header method called through `ctx.request.headers` or `ctx.req.headers` by route middleware, a layout or page loader, component authorization/loading, or app hooks registered through `createWebApp({ use })` disables shared storage for that response. A request replacement Nifra cannot inspect also disables storage. Nifra has no request-header variation key. `requestIndependent` remains the application's assertion for dependencies Nifra cannot observe, including database, environment, global, external-service, and hooks attached after app creation.
|
|
2397
|
+
|
|
2398
|
+
Initial owner-route HTML still waits for its complete state. Owner refreshes negotiate `application/vnd.nifra.component-flight-v1` only for one selected React record with no currently mounted Nifra descendants. The server sends a bounded metadata frame followed by sanitized Flight rows as they become ready. The client checks the closed metadata shape, route owner, build, identity scope and navigation epochs before handing the stream to React; each frame is checked for size, order, count and completion before its bytes reach Flight. React commits the record root and ready Suspense fallbacks while later Flight segments remain in flight, then reveals each boundary as its segment resolves. Refreshes with multiple Nifra records or currently mounted Nifra descendants, unsupported adapters or no Flight negotiation use the bounded buffered response. This refresh protocol stays separate from PPR and does not make refresh output cacheable.
|
|
2399
|
+
|
|
2400
|
+
An owner route is eligible for shared ISR only when its owner declares `cache: { scope: "public", requestIndependent: true, revalidate, tags }`. That contract covers the complete route, layouts and loaders, owner callbacks, component authorization and loading, and rendered output. Runtime also requires a static anonymous owner scope, a deployment identity, and no owner capabilities. Never opt in output derived from a user, credential, authorization decision or secret. Cache identity includes the canonical URL, deployment, build, adapter and route. Requests with credentials or accepted authentication state, data or swap mode, component refreshes, non-GET methods, errors, `Set-Cookie` or unsupported `Vary` bypass storage. Responses leaving Nifra remain `private, no-store`; only the configured Nifra ISR store keeps an approved document. To purge an owner route by path, pass the same app instance to `revalidateEndpoint({ app, store, secret })` so the purge uses the same deployment/build/route partition. Tag purges affect entries carrying the declared tag. Without the ISR wrapper, owner caching is disabled.
|
|
2401
|
+
|
|
2402
|
+
PPR holes keep their separate caching lifecycle. A nonce must be fresh per response; pass it through `createWebApp`. Strict CSP and Chromium Trusted Types are covered by the browser suite. If your policy requires Trusted Types, install `installComponentTrustedTypesPolicy()` from `@nifrajs/web/server-components/trusted-html` before hydration and allow the native framework's policy where required.
|
|
2403
|
+
|
|
2404
|
+
HTML, URLs, styles, slots and portal targets are validated before insertion. React-owned bootstrap scripts require the expected nonce; raw executable HTML and foreign script/assets are rejected. Per-input, per-stream, per-document, depth, concurrency, queue and deadline limits fail closed. Cancellation propagates to reads and native work; an uncooperative promise retains its admission slot until it settles.
|
|
2405
|
+
|
|
2406
|
+
Forms work without JavaScript. Successful actions reauthorize the owner GET exactly once. Parent-domain cookie changes, and Secure cookies on a request the app sees as `http:` (a TLS terminator in front), return 303 to the same path so the browser applies its cookie policy before the GET, preserving the action headers and cookies.
|
|
2407
|
+
|
|
2408
|
+
### Examples, verification and rollback
|
|
2409
|
+
|
|
2410
|
+
The repository contains runnable React, Vue, Svelte, Solid and Preact examples under `examples/server-components/`. They exercise native islands, nested ranges, slots, portals, actions and navigation. Their data, scope tokens and fixed nonce are certification fixtures; replace them with scoped application services, auth integration and fresh nonces before deployment.
|
|
2411
|
+
|
|
2412
|
+
```bash
|
|
2413
|
+
bun examples/server-components/react/run.ts
|
|
2414
|
+
bun examples/server-components/vue/run.ts
|
|
2415
|
+
bun examples/server-components/svelte/run.ts
|
|
2416
|
+
bun examples/server-components/solid/run.ts
|
|
2417
|
+
# Add build to emit a Bun production application.
|
|
2418
|
+
bun run check:server-components
|
|
2419
|
+
bun run check:server-components:consumers
|
|
2420
|
+
bun run check:server-components:performance
|
|
2421
|
+
```
|
|
2422
|
+
|
|
2423
|
+
Deploy the complete server build, integrity manifest and immutable assets together. Keep old hashed assets for the deployment overlap window. Roll back by redeploying the previous complete build. Disabling components requires rebuilding the application with an ordinary SSR fallback; component source cannot be dropped unchanged into an older runtime.
|
|
2198
2424
|
|
|
2199
2425
|
## Nifra - Optimistic UI & fetchers
|
|
2200
2426
|
|
|
@@ -8376,8 +8602,8 @@ starts from unless nothing else, installed or declared, names one.
|
|
|
8376
8602
|
|
|
8377
8603
|
```bash
|
|
8378
8604
|
nifra upgrade --list # the release targets this CLI knows
|
|
8379
|
-
nifra upgrade 5.
|
|
8380
|
-
nifra upgrade 5.
|
|
8605
|
+
nifra upgrade 5.14.0 # dry-run: every planned edit, nothing written
|
|
8606
|
+
nifra upgrade 5.14.0 --write # apply; it verifies with nifra check once the target is installed
|
|
8381
8607
|
# if pins were already bumped by hand, add --from <installed-version>
|
|
8382
8608
|
bun install # install the new pins
|
|
8383
8609
|
nifra check # verify against them
|
|
@@ -11352,8 +11578,11 @@ file that reaches it.
|
|
|
11352
11578
|
The optional server-components pipeline supports
|
|
11353
11579
|
React, Preact, Vue, Svelte and Solid. Declare closed input/public-props schemas and authorization
|
|
11354
11580
|
in `*.component.server.ts(x)`, register owner instances and export a named
|
|
11355
|
-
`componentPipeline` configuration. React uses native RSC/Flight;
|
|
11356
|
-
|
|
11581
|
+
`componentPipeline` configuration. React uses native RSC/Flight; Vue, Svelte,
|
|
11582
|
+
Preact and Nifra's current Solid 1.x adapter use schema-checked server-rendered ranges and
|
|
11583
|
+
explicitly registered native islands, not a Flight-equivalent protocol. Solid 2 has a
|
|
11584
|
+
separate experimental server-component frames protocol that Nifra does not currently target.
|
|
11585
|
+
Refresh repeats owner GET admission;
|
|
11357
11586
|
HTML/data/refresh are private/no-store. Writes use server functions or actions. Bind the
|
|
11358
11587
|
router and await auth-scope invalidation on identity, tenant or permission changes.
|
|
11359
11588
|
|
|
@@ -14380,7 +14609,7 @@ the command below, which runs every recipe since its installed version. The 5.6
|
|
|
14380
14609
|
its imports and dependencies; the follow-up changes below need a hand.
|
|
14381
14610
|
|
|
14382
14611
|
```sh
|
|
14383
|
-
nifra upgrade 5.
|
|
14612
|
+
nifra upgrade 5.14.0
|
|
14384
14613
|
```
|
|
14385
14614
|
|
|
14386
14615
|
-
|
|
@@ -14399,7 +14628,7 @@ Islands.
|
|
|
14399
14628
|
throws at startup without one. Pages stored before the upgrade render once more.
|
|
14400
14629
|
|
|
14401
14630
|
-
|
|
14402
|
-
The server-component pipeline is certified on Vite 8.3.
|
|
14631
|
+
The server-component pipeline is certified on Vite 8.3.8: pin `vite` to exactly
|
|
14403
14632
|
that version.
|
|
14404
14633
|
|
|
14405
14634
|
-
|
|
@@ -14811,9 +15040,9 @@ Migrate a backend. For the full
|
|
|
14811
15040
|
rendering and route model, see Loaders & actions
|
|
14812
15041
|
and Routing.
|
|
14813
15042
|
|
|
14814
|
-
The current dynamic SSR snapshot reports Nifra at
|
|
14815
|
-
of Next.js,
|
|
14816
|
-
2.
|
|
15043
|
+
The current dynamic SSR snapshot reports Nifra at 15× the throughput
|
|
15044
|
+
of Next.js, 7× Nuxt, 3.9× SvelteKit, and
|
|
15045
|
+
2.4× SolidStart on the measured pages. See the
|
|
14817
15046
|
benchmark methodology and full results.
|
|
14818
15047
|
|
|
14819
15048
|
## Nifra - Migrate route by route
|
|
@@ -18779,7 +19008,9 @@ The server answers for the nifra the project installs. When the project has its
|
|
|
18779
19008
|
a different version than the `nifra` the client spawned (a global install, say), the session is handed
|
|
18780
19009
|
to `./node_modules/.bin/nifra mcp`. When that is impossible, `nifra_check`, `nifra_types`,
|
|
18781
19010
|
`nifra_docs`, `nifra_example`, `nifra_assure` and `nifra_contracts` refuse with the fix instead of
|
|
18782
|
-
describing a different release.
|
|
19011
|
+
describing a different release. A project CLI that installs mid-session takes the session over the same
|
|
19012
|
+
way; a single message from it larger than 16 MiB ends that CLI, and the request waiting on it gets a
|
|
19013
|
+
`-32603` error.
|
|
18783
19014
|
|
|
18784
19015
|
The server runs none of the project's code and keeps none of its `.env`. Every tool, resource and
|
|
18785
19016
|
prompt that loads the app, including the ones the app declares with `.tool()`, runs in a fresh process
|
|
@@ -20871,6 +21102,95 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
20871
21102
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
20872
21103
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
20873
21104
|
|
|
21105
|
+
## @nifrajs/node-uws
|
|
21106
|
+
|
|
21107
|
+
Serve a [nifra](../../README.md) app on [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js)
|
|
21108
|
+
from Node. It is `@nifrajs/node` with uWS's native HTTP server in place of `node:http`: requests reach
|
|
21109
|
+
the app through the same node-direct lane, and answers are written with uWS's corked, copy-once API.
|
|
21110
|
+
|
|
21111
|
+
```ts
|
|
21112
|
+
import { server } from "@nifrajs/core/server"
|
|
21113
|
+
import { serve } from "@nifrajs/node-uws"
|
|
21114
|
+
|
|
21115
|
+
const app = server().get("/users/:id", (c) => ({ id: c.params.id }))
|
|
21116
|
+
|
|
21117
|
+
const handle = await serve(app, { port: 3000 })
|
|
21118
|
+
// handle.port the bound port (useful with `port: 0`)
|
|
21119
|
+
// await handle.stop() stop accepting, drain in-flight requests, close the rest
|
|
21120
|
+
```
|
|
21121
|
+
|
|
21122
|
+
## Install
|
|
21123
|
+
|
|
21124
|
+
Install this package with its core and Node adapter dependencies:
|
|
21125
|
+
|
|
21126
|
+
```sh
|
|
21127
|
+
npm install @nifrajs/node-uws @nifrajs/node @nifrajs/core
|
|
21128
|
+
```
|
|
21129
|
+
|
|
21130
|
+
uWebSockets.js is not published to npm. Install it from GitHub, next to this package:
|
|
21131
|
+
|
|
21132
|
+
```sh
|
|
21133
|
+
npm install uNetworking/uWebSockets.js#v20.71.0
|
|
21134
|
+
```
|
|
21135
|
+
|
|
21136
|
+
Its releases ship prebuilt binaries for Node 22, 24 and 26 on macOS and Linux (x64, arm64) and Windows
|
|
21137
|
+
(x64). There is none for Alpine (musl) or Windows on arm64, and a new Node major has none until upstream
|
|
21138
|
+
publishes one. The Node 24 binary for Linux arm64 needs glibc 2.38 or newer, so Debian 12 and Ubuntu 22.04
|
|
21139
|
+
cannot load it. Importing this package succeeds either way; `serve()` loads the addon and throws an error
|
|
21140
|
+
that says so when it cannot load. Use `@nifrajs/node` where that matters.
|
|
21141
|
+
|
|
21142
|
+
## Options
|
|
21143
|
+
|
|
21144
|
+
| Option | |
|
|
21145
|
+
|---|---|
|
|
21146
|
+
| `port`, `hostname` | As in `@nifrajs/node`. |
|
|
21147
|
+
| `protocol` | `"http"` or `"https"`: the scheme `Request.url` carries. `"https"` by default when `tls` is set. |
|
|
21148
|
+
| `tls` | `{ keyFileName, certFileName, passphrase?, caFileName?, dhParamsFileName?, sslCiphers?, sslPreferLowMemoryUsage? }`. uWS reads the files itself, so these are paths, not PEM text. |
|
|
21149
|
+
| `allowedHosts`, `canonicalHost`, `normalizeTarget` | Same rules and defaults as `@nifrajs/node`. |
|
|
21150
|
+
| `gracefulSignals` | Call `stop()` on SIGTERM/SIGINT. Off by default. |
|
|
21151
|
+
|
|
21152
|
+
`static` and `fastResponse` are refused with a `TypeError`: serve files from a route or a static host in
|
|
21153
|
+
front.
|
|
21154
|
+
|
|
21155
|
+
`stop({ drainMs, delayMs })`, `await using`, and the app's `onStopping` / `onStop` hooks behave as they
|
|
21156
|
+
do on `@nifrajs/node`.
|
|
21157
|
+
|
|
21158
|
+
## How it differs from `@nifrajs/node`
|
|
21159
|
+
|
|
21160
|
+
- **No WebSockets.** A handshake is refused with `501`. Use `@nifrajs/node` for apps with `ws` routes.
|
|
21161
|
+
- **Streaming responses** (SSE, streamed SSR) are written chunked with back-pressure; a body whose
|
|
21162
|
+
`Content-Length` is declared is sent with that length and cut off, not finished, if the stream ends
|
|
21163
|
+
short or runs long.
|
|
21164
|
+
- **Headers uWS frames itself** - `Content-Length`, `Transfer-Encoding` and `Date` - are dropped from the
|
|
21165
|
+
app's response, and uWS adds a `uWebSockets: 20` header it cannot be told to omit.
|
|
21166
|
+
- **Header values are checked** for CR, LF and other control characters before anything is written, and
|
|
21167
|
+
a status outside 100-999 is refused: either is a `500`, reported through the app's logger.
|
|
21168
|
+
- **uWS's parser, not Node's.** It rejects a repeated `Host`, a request carrying both `Content-Length`
|
|
21169
|
+
and `Transfer-Encoding`, and an absolute-form target with `400`, before the app sees them. Its idle
|
|
21170
|
+
timeout is fixed at 10 seconds, and there is no equivalent of Node's `requestTimeout`.
|
|
21171
|
+
- **Request bodies are pushed by uWS**, not pulled. The socket is throttled once 1 MiB is buffered
|
|
21172
|
+
unread; a body larger than the route's cap is refused with `413` as on `@nifrajs/node`. A handler
|
|
21173
|
+
that answers without reading the body releases the throttle first and the rest of the upload is
|
|
21174
|
+
dropped, so the next request on that connection is read; reading the body afterwards rejects.
|
|
21175
|
+
- **An empty header value reads as absent** through `c.header()`.
|
|
21176
|
+
|
|
21177
|
+
## Notes for contributors
|
|
21178
|
+
|
|
21179
|
+
The shared pieces - the outcome runtime, Host and target policy, lifecycle and error hooks - come from
|
|
21180
|
+
`@nifrajs/node/transport`. uWS objects are valid only while their callback runs, so the request copies
|
|
21181
|
+
its headers out the moment an app goes asynchronous, and a response is never touched after it ended or
|
|
21182
|
+
aborted: uWS throws on that, and an uncaught throw there ends the process.
|
|
21183
|
+
|
|
21184
|
+
Tests run on Node (`bun run test:node`), because uWS does not load under Bun.
|
|
21185
|
+
|
|
21186
|
+
## For AI agents
|
|
21187
|
+
|
|
21188
|
+
Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
|
|
21189
|
+
one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
21190
|
+
[`AGENTS.md`](../../AGENTS.md) is the copy-paste quick reference, and
|
|
21191
|
+
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
21192
|
+
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
21193
|
+
|
|
20874
21194
|
## @nifrajs/otel
|
|
20875
21195
|
|
|
20876
21196
|
Distributed tracing for nifra. The `tracing()` plugin continues (or starts) a **W3C trace** per
|
|
@@ -21864,6 +22184,16 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
21864
22184
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
21865
22185
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
21866
22186
|
|
|
22187
|
+
## @nifrajs/utils
|
|
22188
|
+
|
|
22189
|
+
Runtime-neutral utility functions shared by Nifra packages. The package has no runtime dependencies.
|
|
22190
|
+
|
|
22191
|
+
```ts
|
|
22192
|
+
import { isRecord, sha256Hex } from "@nifrajs/utils"
|
|
22193
|
+
```
|
|
22194
|
+
|
|
22195
|
+
See the [package LLM guide](./LLM.md) and the [full repository LLM context](../../llms-full.txt).
|
|
22196
|
+
|
|
21867
22197
|
## @nifrajs/web
|
|
21868
22198
|
|
|
21869
22199
|
Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.
|
|
@@ -21884,12 +22214,13 @@ One package, the same on React, Preact, Vue, Solid and Svelte (pick the renderer
|
|
|
21884
22214
|
- [Keep-alive](https://nifra.dev/docs/keep-alive) pages, a query cache, optimistic fetchers, and
|
|
21885
22215
|
[islands](https://nifra.dev/docs/islands) (`@nifrajs/web/islands`) for pages with no framework runtime.
|
|
21886
22216
|
- Optional [server components](https://nifra.dev/docs/server-components) on all five adapters:
|
|
21887
|
-
React uses native RSC/Flight,
|
|
21888
|
-
|
|
21889
|
-
|
|
21890
|
-
|
|
21891
|
-
|
|
21892
|
-
|
|
22217
|
+
React uses native RSC/Flight. Vue, Svelte, Preact and the current Solid 1.x adapter use
|
|
22218
|
+
explicitly registered islands in validated server-rendered ranges; Solid 2's experimental
|
|
22219
|
+
frames protocol is not currently targeted. Definitions take closed input and public-props
|
|
22220
|
+
schemas and authorization; a refresh runs the owner page's GET with its admission, capabilities,
|
|
22221
|
+
budgets and cancellation. Use the `/server-components`, `/server-components/client`,
|
|
22222
|
+
`/server-components/islands` and `/server-components/build` exports with a `componentPipeline`
|
|
22223
|
+
config export; the repository has a runnable example per adapter.
|
|
21893
22224
|
|
|
21894
22225
|
## Guarding pages
|
|
21895
22226
|
|
|
@@ -22048,7 +22379,7 @@ To refresh one region from a link or GET form without a full reload, render it w
|
|
|
22048
22379
|
|
|
22049
22380
|
- In text and in a quoted attribute value, it is HTML-escaped.
|
|
22050
22381
|
- An unquoted attribute value (`class=${name}`) is quoted for you, so a space in the value cannot start another attribute.
|
|
22051
|
-
- A `javascript:` or `vbscript:` URL that begins an `href`, `src`, `action` or other URL attribute is written as `about:invalid`.
|
|
22382
|
+
- A `javascript:` or `vbscript:` URL that begins an `href`, `src`, `action` or other URL attribute is written as `about:invalid`. So is a `data:` URL that begins the `src` (or `href`) of a `<script>`, which runs; a `data:` image, download, frame or object URL is kept.
|
|
22052
22383
|
- No escaping makes a string safe as a tag name, inside `<script>` or `<style>`, or in an `on*` handler or `srcdoc` value, so a string or nested template throws there. An attribute name takes only a plain name with no value (`<input ${checked ? "checked" : ""}>`), or a suffix after `data-` or `aria-`. Numbers and booleans fill any of these, and `raw()` is the explicit opt-out for trusted text.
|
|
22053
22384
|
|
|
22054
22385
|
Need a stateful app UI with reactive components? That is what the five framework adapters are for - reach for `@nifrajs/web-preact` or `@nifrajs/web-solid` when you want a small reactive runtime.
|
|
@@ -22497,6 +22828,10 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
22497
22828
|
|
|
22498
22829
|
`FetchHandler`, `HashedFiles`, `NodeServer`, `NodeStopOptions`, `RequestProtocol`, `RequestProtocolOption`, `ServeOptions`, `ServeStaticOptions`, `serve`, `serveStatic`
|
|
22499
22830
|
|
|
22831
|
+
## @nifrajs/node-uws
|
|
22832
|
+
|
|
22833
|
+
`FetchHandler`, `NodeStopOptions`, `ServeOptions`, `UwsServer`, `UwsTlsOptions`, `serve`
|
|
22834
|
+
|
|
22500
22835
|
## @nifrajs/otel
|
|
22501
22836
|
|
|
22502
22837
|
`ActiveObservation`, `AttributeValue`, `EffectTracingOptions`, `EffectTracingPlugin`, `EndObservation`, `NifraSpan`, `ObservationAdapter`, `ObservationClock`, `ObservationContext`, `ObservationLifecycle`, `ObservationLifecycleOptions`, `ObservationLink`, `ObservationParent`, `ObservationScope`, `OtlpExporter`, `OtlpExporterOptions`, `ParsedTraceparent`, `RecordingObservationLifecycle`, `SpanKind`, `SpanStatus`, `StartObservation`, `TraceContext`, `TracingOptions`, `causalitySpanLink`, `combineObservationAdapters`, `consoleSpanExporter`, `createObservationLifecycle`, `effectTracing`, `formatTraceparent`, `generateSpanId`, `generateTraceId`, `otlpExporter`, `parseTraceparent`, `traceHeaders`, `tracing`
|
|
@@ -22537,6 +22872,10 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
22537
22872
|
|
|
22538
22873
|
`ImagePixelLimitError`, `ImageReencoder`, `SignDownloadUrlOptions`, `StripImageMetadataOptions`, `UploadResult`, `ValidateUploadOptions`, `signDownloadUrl`, `stripImageMetadata`, `validateUpload`, `verifyDownloadUrl`
|
|
22539
22874
|
|
|
22875
|
+
## @nifrajs/utils
|
|
22876
|
+
|
|
22877
|
+
`bytesToHex`, `concatBytes`, `escapeRegExp`, `isRecord`, `sha256Hex`
|
|
22878
|
+
|
|
22540
22879
|
## @nifrajs/web
|
|
22541
22880
|
|
|
22542
22881
|
`ACTION_GLOBAL`, `Action`, `BOUNDARY_GLOBAL`, `BackendOnly`, `Blocker`, `BlockerController`, `BlockerFunction`, `BlockerLocation`, `BlockerState`, `Boundary`, `BoundaryDescriptor`, `BoundaryError`, `BoundaryLoaderEntry`, `BoundaryLoadersOf`, `BoundaryMode`, `BoundaryRegistration`, `BoundaryRequestCtx`, `BoundaryState`, `BoundaryStates`, `BoundaryStatus`, `BrowserNavigate`, `BuildAssetSet`, `CacheStore`, `CachedResponse`, `CdnPurgeOutcome`, `CdnPurgeTarget`, `ClientAction`, `ClientActionArgs`, `ClientActionResult`, `ClientLoader`, `ClientLoaderArgs`, `ClientRequestBody`, `ClientRouteHooks`, `ClientRouter`, `ClientRouterOptions`, `CreateCspPolicyOptions`, `CreateNonceResolverOptions`, `CreateWebAppOptions`, `CspHeaderContext`, `CspPolicy`, `CssLoadingMode`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_CSS_LOADING`, `DEFAULT_DEV_PORT`, `DRAFT_COOKIE`, `DataText`, `Deferred`, `DehydrateOptions`, `DehydratedQueryInfo`, `DehydratedState`, `DocumentParts`, `DraftCookieControls`, `DynamicBoundary`, `DynamicBoundaryBatch`, `EnableDraftOptions`, `FetchRouteData`, `Fetcher`, `FetcherState`, `FontDisplay`, `FontFace`, `FontPreloadInput`, `FontSource`, `GenerateClientEntryOptions`, `GenerateServerManifestOptions`, `GetStaticPaths`, `HANDOVER_ID`, `HostPolicy`, `HostPolicyOptions`, `HostPolicyRule`, `Href`, `HrefOptions`, `HtmlSanitizer`, `IDLE_BLOCKER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `ISRQuery`, `ISRStoreOp`, `ISR_REVALIDATE_HEADER`, `ISR_REVALIDATE_TAGS_HEADER`, `ISR_STATUS_HEADER`, `IdentityEpochContext`, `InertScriptType`, `InfiniteData`, `InfiniteQueryHandle`, `InfiniteQueryOptions`, `InterceptBoundary`, `Intercepted`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `KeepAliveOptions`, `KeepAliveServerOptions`, `KeptPage`, `LAYOUT_DATA_GLOBAL`, `LOCALES_GLOBAL`, `LayoutEntry`, `LinkDescriptor`, `LiveClientEntry`, `Loader`, `LoaderContext`, `LoaderResponseControls`, `LoadingEntry`, `Manifest`, `MatchChain`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `MemoryStaticBoundaryCache`, `Meta`, `MetaArgs`, `MetaDescriptor`, `MetaInput`, `MiddlewareOutcome`, `MountRouterOptions`, `MutationCallbacks`, `MutationCancelledError`, `MutationContext`, `MutationHandle`, `MutationState`, `MutationStatus`, `NAV_FROM_HEADER`, `NavigateFunction`, `NavigateOptions`, `NonceContext`, `NonceGenerator`, `NonceHeader`, `NonceHeaderContext`, `NonceResolver`, `NotFoundEntry`, `NotFoundScope`, `OpenGraphInput`, `PREFETCH_HEADER`, `PRE_HYDRATION_GUARD`, `PageLocale`, `PageLocales`, `PendingBoundary`, `PrefetchMode`, `PrerenderedPageReaderOptions`, `PrerenderedPages`, `PreviewEndpointOptions`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryOptions`, `QueryState`, `QueryStatus`, `REDIRECT_HEADER`, `RETAIN_HEADER`, `REVALIDATE_HEADER`, `ROOT_ATTRIBUTE`, `ROUTE_GLOBAL`, `RedirectOptions`, `RenderAdapter`, `RenderAdapterConformanceError`, `RenderAdapterConformanceFixture`, `RenderAssemblyCache`, `RenderPageInput`, `RenderPageOptions`, `RenderProps`, `RenderStreamOptions`, `RenderedPage`, `RevalidateEndpointOptions`, `RevalidateOptions`, `RevalidateResult`, `RevalidateTags`, `RevalidateTagsInput`, `RouteEntry`, `RouteMatch`, `RouteMiddleware`, `RouteModule`, `RoutePattern`, `RouteSlotName`, `RouteSlotPatternsOf`, `RouteSlotRegistry`, `RouteSlotTarget`, `RouteTable`, `RouterState`, `SERVER_FN_MODULE`, `STATUS_HEADER`, `SanitizedHtml`, `ScriptDescriptor`, `SearchOf`, `SharedBoundary`, `SharedHoleCtx`, `ShellCtx`, `ShouldRevalidate`, `ShouldRevalidateArgs`, `SsrModuleLoader`, `StaticBoundary`, `StaticBoundaryCache`, `StaticBoundaryImportEdge`, `StaticBoundaryRoot`, `StaticCtx`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `StatusPageOptions`, `Submission`, `SubmitOptions`, `TrustedHtml`, `UIMatch`, `UnsafeScriptDescriptor`, `WebAppI18n`, `assertCssLoadingCompatible`, `assertRenderAdapterConformance`, `assertStaticBoundaryImports`, `boundaryDescriptors`, `boundaryModeKey`, `buildManifest`, `canonical`, `closeBoundary`, `createClientRouter`, `createCspPolicy`, `createHostPolicy`, `createMatcher`, `createMutation`, `createNonceResolver`, `createQueryClient`, `createWebApp`, `defer`, `disableDraft`, `enableDraft`, `enumerateStaticRoutes`, `filePathToPattern`, `filePathToPatterns`, `fontFace`, `fontPreload`, `generateClientEntry`, `generateServerManifest`, `getBrowserNavigate`, `gone`, `hashQueryKey`, `href`, `isCacheablePage`, `isDraftEnabled`, `isHostPolicy`, `jsonLd`, `localeOfProps`, `mergeHeads`, `nifraScriptHashes`, `normalizeCssLoading`, `notFound`, `openGraph`, `pageLocaleIn`, `prerenderedPageReader`, `previewEndpoint`, `rawHref`, `redirect`, `registerBlocker`, `renderPage`, `renderPageResult`, `resolveChainMeta`, `resolveDynamicBoundaries`, `resolveMeta`, `resolvePublicPath`, `resolveStaticBoundaries`, `revalidate`, `revalidateEndpoint`, `rotateIdentityEpoch`, `sanitizeHtml`, `sanitizedHtml`, `searchOf`, `searchOfChain`, `serializeData`, `serializeSearch`, `setBlockerController`, `setBrowserNavigate`, `setSsrModuleLoader`, `ssrModuleLoader`, `startDynamicBoundaries`, `statusPage`, `trustHtml`, `unsafeInlineScript`, `webProjectEvidence`, `withISR`
|