@nifrajs/cli 5.12.1 → 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 +72 -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.d.ts +9 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +139 -351
- 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.d.ts +29 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +100 -23
- 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.d.ts +12 -0
- package/dist/deployment-adapters.d.ts.map +1 -0
- package/dist/deployment-adapters.js +86 -0
- package/dist/deployment-adapters.js.map +1 -0
- package/dist/dev-bun-config.d.ts +4 -3
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +9 -101
- 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.d.ts +5 -0
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +2 -134
- 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.d.ts +12 -3
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +19 -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.d.ts.map +1 -1
- package/dist/mcp-root.js +18 -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.d.ts +6 -3
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +16 -92
- 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.d.ts +9 -0
- package/dist/recipes/5.13.0.d.ts.map +1 -0
- package/dist/recipes/5.13.0.js +34 -0
- package/dist/recipes/5.13.0.js.map +1 -0
- 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 +4 -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.d.ts +44 -0
- package/dist/shell-files.d.ts.map +1 -0
- package/dist/shell-files.js +186 -0
- package/dist/shell-files.js.map +1 -0
- package/dist/shell-init.d.ts +33 -0
- package/dist/shell-init.d.ts.map +1 -0
- package/dist/shell-init.js +84 -0
- package/dist/shell-init.js.map +1 -0
- 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/examples.json +97 -1
- package/docs/llms-full.txt +1347 -59
- package/docs/types.json +756 -37
- package/package.json +12 -11
- package/src/assure-hydration.ts +3 -3
- package/src/cli.ts +189 -39
- package/src/command-catalog.ts +144 -7
- package/src/deployment-adapters.ts +107 -0
- package/src/dev-bun-config.ts +21 -2
- package/src/init-agents.ts +1 -1
- 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/load.ts +36 -3
- 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-root.ts +21 -3
- package/src/mcp-tool-meta.ts +3 -3
- package/src/port.ts +25 -8
- package/src/recipes/5.13.0.ts +41 -0
- package/src/recipes/5.14.0.ts +34 -0
- package/src/recipes/index.ts +4 -0
- package/src/rules/routes.ts +2 -2
- package/src/shell-files.ts +225 -0
- package/src/shell-init.ts +139 -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
|
|
|
@@ -165,7 +165,7 @@ from one core, with loaders, actions, streaming, and a typed data layer - and a
|
|
|
165
165
|
### Nifra's lane
|
|
166
166
|
|
|
167
167
|
Every other full-stack framework here is **built around one UI library** (TanStack Start
|
|
168
|
-
supports
|
|
168
|
+
supports three), and most reach other hosts through adapters. Nifra bets on the other axis: one
|
|
169
169
|
core, five front-ends, many runtimes, with a contract-first typed backend in the same project.
|
|
170
170
|
|
|
171
171
|
Framework
|
|
@@ -188,12 +188,12 @@ SvelteKit
|
|
|
188
188
|
Svelte
|
|
189
189
|
adapters
|
|
190
190
|
|
|
191
|
-
React Router
|
|
191
|
+
React Router 8 (Remix)
|
|
192
192
|
React
|
|
193
193
|
adapters
|
|
194
194
|
|
|
195
195
|
TanStack Start
|
|
196
|
-
React · Solid
|
|
196
|
+
React · Solid · Vue
|
|
197
197
|
Nitro · host plugins
|
|
198
198
|
|
|
199
199
|
### Full-stack parity
|
|
@@ -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
|
|
|
@@ -295,13 +300,13 @@ to full-stack later without a rewrite.
|
|
|
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
302
|
100% of Elysia on `GET /users/:id` and
|
|
298
|
-
|
|
299
|
-
**level with Fastify on Node** (
|
|
300
|
-
|
|
301
|
-
and Express behind. On **Deno** it runs at
|
|
302
|
-
GET 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
|
-
|
|
@@ -1409,7 +1414,7 @@ export const app = server()
|
|
|
1409
1414
|
For a route whose response is always empty, use `staticResponse()` instead of
|
|
1410
1415
|
creating a `Response` in a handler on every request. Pass fixed status and headers
|
|
1411
1416
|
to the helper; caller-supplied `Content-Length` and `Transfer-Encoding`
|
|
1412
|
-
are rejected. On Bun, a plain literal-path GET or
|
|
1417
|
+
are rejected. On Bun, a plain literal-path GET, HEAD, or bodyless POST route can use Bun's static response
|
|
1413
1418
|
table when no request policy, validation, response middleware, or app-wide
|
|
1414
1419
|
`.responseHeaders(...)` defaults need to run. Null-body status codes use the
|
|
1415
1420
|
regular handler path to preserve framing on Bun 1.3. Otherwise Nifra keeps the regular route
|
|
@@ -1418,7 +1423,9 @@ pipeline. `app.fetch` and other runtimes also produce a fresh response per call.
|
|
|
1418
1423
|
```ts
|
|
1419
1424
|
import { server, staticResponse } from "@nifrajs/core/server"
|
|
1420
1425
|
|
|
1421
|
-
export const app = server()
|
|
1426
|
+
export const app = server()
|
|
1427
|
+
.get("/health", staticResponse())
|
|
1428
|
+
.post("/flush", staticResponse())
|
|
1422
1429
|
app.listen(3000)
|
|
1423
1430
|
```
|
|
1424
1431
|
|
|
@@ -1723,11 +1730,12 @@ whole path: `RequestPath<"/files/:name.json">` is
|
|
|
1723
1730
|
_before_ path segments: the seven HTTP verbs
|
|
1724
1731
|
(`get`/`post`/`put`/`patch`/`delete`/
|
|
1725
1732
|
`head`/`options`, any casing) call the route, and
|
|
1726
|
-
`subscribe`, `ws`, `index`,
|
|
1727
|
-
match) are the SSE, WebSocket, root-path,
|
|
1733
|
+
`subscribe`, `ws`, `index`, `then`, and
|
|
1734
|
+
`$query` (exact match) are the SSE, WebSocket, root-path, thenable-guard, and QUERY
|
|
1735
|
+
keys. A route whose path
|
|
1728
1736
|
contains a static segment spelling one of these - `.post("/api/delete", …)` -
|
|
1729
|
-
cannot be reached by **dot access**: `api.delete
|
|
1730
|
-
`delete` verb,
|
|
1737
|
+
cannot be reached by **dot access**: `api.delete()` invokes the
|
|
1738
|
+
`delete` verb, while `api.delete.post` is undefined. The typed spelling is a **call on the parent
|
|
1731
1739
|
node** - `api.api("delete").post()` sends `POST /api/delete` - the
|
|
1732
1740
|
same call params use, accepting exactly the colliding segment names. The client type rejects
|
|
1733
1741
|
the dot access at compile time with that guidance, and `nifra check` reports the
|
|
@@ -1769,6 +1777,11 @@ client sends nothing rather than reach a route the call does not name.
|
|
|
1769
1777
|
`.subscribe()` reports it through `onError` and closes;
|
|
1770
1778
|
`.ws()` throws.
|
|
1771
1779
|
|
|
1780
|
+
A `.subscribe()` handle and a `.ws()` handle also close at the end of a
|
|
1781
|
+
scope when held with `using`, the same as calling `close()`. A
|
|
1782
|
+
browser without `Symbol.dispose` needs a polyfill first; `close()`
|
|
1783
|
+
works without one.
|
|
1784
|
+
|
|
1772
1785
|
The same client runs in the browser and on the server. During SSR, a route's
|
|
1773
1786
|
loader calls it **in-process** (no network hop) via
|
|
1774
1787
|
`ctx.api`. Next: file routing,
|
|
@@ -2186,7 +2199,228 @@ public registration API rather than as a bespoke dispatcher.
|
|
|
2186
2199
|
|
|
2187
2200
|
## Nifra - Server components
|
|
2188
2201
|
|
|
2189
|
-
> 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.
|
|
2190
2424
|
|
|
2191
2425
|
## Nifra - Optimistic UI & fetchers
|
|
2192
2426
|
|
|
@@ -3328,6 +3562,12 @@ third argument's option), a background refetch, and bounded GC. The query cache
|
|
|
3328
3562
|
mutation and infinite-query bindings across the adapters, using each framework's reactive
|
|
3329
3563
|
model.
|
|
3330
3564
|
|
|
3565
|
+
Query keys are serialized structurally. Keep key arrays and objects stable when practical, and
|
|
3566
|
+
treat objects as immutable after the first query uses them: Nifra caches object hashes by
|
|
3567
|
+
identity, so mutating a reused object can leave it under its old hash, while creating a fresh
|
|
3568
|
+
equivalent key repeats serialization work. For example, derive one key from the current
|
|
3569
|
+
identity and reuse it for the render rather than mutating it after the query starts.
|
|
3570
|
+
|
|
3331
3571
|
```ts
|
|
3332
3572
|
import { useQuery, useQueryClient } from "@nifrajs/web-react/query"
|
|
3333
3573
|
|
|
@@ -4771,11 +5011,20 @@ the part names none. Only a type that `accept` matched is one the bytes proved.
|
|
|
4771
5011
|
-
|
|
4772
5012
|
**A form post is a simple cross-origin request.** A browser sends
|
|
4773
5013
|
`multipart/form-data`, urlencoded and `text/plain` with cookies and no
|
|
4774
|
-
preflight.
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
5014
|
+
preflight. Core refuses one whose `Origin` is another site's with
|
|
5015
|
+
`403` on a body-schema route before reading it, and on any other
|
|
5016
|
+
`POST`, `PUT`, `PATCH` or `DELETE` route before
|
|
5017
|
+
the handler runs. A route without a body schema refuses a request with no content type from
|
|
5018
|
+
such a site too, unless it carries an `Authorization` header a script set (a
|
|
5019
|
+
browser re-sends `Basic`, `Digest`, `Negotiate` and
|
|
5020
|
+
`NTLM` credentials from its own cache, so those do not count). List a site that
|
|
5021
|
+
must post to the app in the server's `formOrigins`; the origins
|
|
5022
|
+
`cors()` and `csrf({ origins })` name are trusted without a second
|
|
5023
|
+
list, for that server's own routes only: a mounted server keeps its own policy, a
|
|
5024
|
+
parent must list the same sites itself, and a web page action checks the backend's
|
|
5025
|
+
`allowedOrigins` instead. Audit those origins: one named there may post a form
|
|
5026
|
+
whatever methods or credentials the CORS policy allows. A request without an `Origin` passes, so a cookie-authenticated upload
|
|
5027
|
+
route still needs `csrf()` like any other state change.
|
|
4779
5028
|
|
|
4780
5029
|
-
|
|
4781
5030
|
**The form is held in memory.** Budget roughly twice `bodyLimit` per request in
|
|
@@ -7038,6 +7287,29 @@ export default { fetch: (req: Request, env: Env, ctx: ExecutionContext) =>
|
|
|
7038
7287
|
app.fetch(req, { env, waitUntil: ctx.waitUntil.bind(ctx) }) }
|
|
7039
7288
|
```
|
|
7040
7289
|
|
|
7290
|
+
For environment variables represented as strings, `@nifrajs/env` can validate the
|
|
7291
|
+
Workers binding object with `defineEnv(shape, { source: bindings })`. If the
|
|
7292
|
+
platform env also contains KV, D1, or Durable Object bindings, select only the string keys
|
|
7293
|
+
into the source object; keep the full binding type on `server<Env>()` for
|
|
7294
|
+
`c.env`.
|
|
7295
|
+
|
|
7296
|
+
```ts
|
|
7297
|
+
import { defineEnv, env as schemaEnv } from "@nifrajs/env"
|
|
7298
|
+
|
|
7299
|
+
// Select string bindings when the Workers env also contains KV/D1 objects.
|
|
7300
|
+
type StringBindings = Record<string, string | undefined>
|
|
7301
|
+
|
|
7302
|
+
export default {
|
|
7303
|
+
fetch(_request: Request, bindings: StringBindings) {
|
|
7304
|
+
const config = defineEnv(
|
|
7305
|
+
{ API_URL: schemaEnv.url(), API_TOKEN: schemaEnv.string() },
|
|
7306
|
+
{ source: bindings },
|
|
7307
|
+
)
|
|
7308
|
+
return new Response(config.API_URL)
|
|
7309
|
+
},
|
|
7310
|
+
}
|
|
7311
|
+
```
|
|
7312
|
+
|
|
7041
7313
|
Export through `toFetchHandler` rather than handing the app out directly. Besides
|
|
7042
7314
|
`env` and `ctx.waitUntil`, it tells nifra the request came from the
|
|
7043
7315
|
platform's own HTTP parser, which lets the
|
|
@@ -7614,6 +7886,64 @@ none (Build Output API v3)
|
|
|
7614
7886
|
pages, the client bundle and `public/`, for any static host. See
|
|
7615
7887
|
SSG & ISR.
|
|
7616
7888
|
|
|
7889
|
+
### Public build-target adapters
|
|
7890
|
+
|
|
7891
|
+
A deployment adapter adds host packaging around an existing Nifra build target. It does not
|
|
7892
|
+
replace the runtime, generated server entry, or Nifra's build checks. The versioned contract
|
|
7893
|
+
in `@nifrajs/web/build` lets an adapter declare its base target, validate options,
|
|
7894
|
+
and return extra files plus deploy guidance. Nifra checks paths and collisions, scans text
|
|
7895
|
+
artifacts for credentials, and only swaps the output directory after the full build passes.
|
|
7896
|
+
|
|
7897
|
+
Install the Fly adapter with its required Node runtime and create the named Fly app before
|
|
7898
|
+
its first deploy:
|
|
7899
|
+
|
|
7900
|
+
```sh
|
|
7901
|
+
bun add @nifrajs/deploy-fly @nifrajs/node
|
|
7902
|
+
fly apps create my-nifra-app # once, before the first deploy
|
|
7903
|
+
```
|
|
7904
|
+
|
|
7905
|
+
```ts
|
|
7906
|
+
// nifra.config.ts - keep your existing adapter and clientModule exports, and add:
|
|
7907
|
+
import { flyAdapter } from "@nifrajs/deploy-fly"
|
|
7908
|
+
|
|
7909
|
+
export const target = "fly"
|
|
7910
|
+
export const deploymentAdapter = {
|
|
7911
|
+
adapter: flyAdapter,
|
|
7912
|
+
options: { app: "my-nifra-app", primaryRegion: "iad" },
|
|
7913
|
+
}
|
|
7914
|
+
|
|
7915
|
+
// Build locally; then deploy the output directory yourself.
|
|
7916
|
+
// nifra build
|
|
7917
|
+
// cd dist && fly deploy
|
|
7918
|
+
```
|
|
7919
|
+
|
|
7920
|
+
The Fly reference package wraps the ordinary `node` target and emits a Dockerfile
|
|
7921
|
+
plus `fly.toml`. The `deploymentAdapter` configuration above registers
|
|
7922
|
+
the custom `fly` target. Run `fly deploy` from the emitted output
|
|
7923
|
+
directory; Nifra never logs in or deploys for you. Adapter code is trusted build-time code
|
|
7924
|
+
running in the CLI process. Each adapter must explicitly declare whether it supports the
|
|
7925
|
+
coordinated component pipeline; unsupported combinations fail before the previous output is
|
|
7926
|
+
replaced. Set Fly's optional `healthCheckPath` only when that route returns 2xx
|
|
7927
|
+
while the app is ready.
|
|
7928
|
+
|
|
7929
|
+
The emitted Dockerfile sets `NODE_ENV=production`, and production refuses
|
|
7930
|
+
in-memory stores. An app that uses one, such as the site scaffold's rate limiter, must
|
|
7931
|
+
configure a shared store, or for a single machine allow it explicitly (the scaffold reads
|
|
7932
|
+
`NIFRA_ALLOW_MEMORY_RATE_LIMIT=true`, set with `fly secrets set`). An
|
|
7933
|
+
in-memory limiter keeps one quota per machine, and `fly deploy` adds a spare
|
|
7934
|
+
machine by default. Deploy a new app with `fly deploy --ha=false`; for an app
|
|
7935
|
+
that already has several machines, run `fly scale count 1`. Confirm with
|
|
7936
|
+
`fly status`, or use a shared store.
|
|
7937
|
+
|
|
7938
|
+
The generated Node server derives `c.clientIp` from the socket peer only, which
|
|
7939
|
+
behind Fly's proxy is the proxy. Visitors then share one rate-limit bucket and get 429
|
|
7940
|
+
once it is spent, and a shared store does not change the keying. Passing
|
|
7941
|
+
`header: "fly-client-ip"` to `rateLimit()` keys requests that arrive
|
|
7942
|
+
over HTTP per visitor, but only while Fly's proxy is the sole path to the app; behind a CDN
|
|
7943
|
+
or another proxy the header holds that proxy's address. The server's own page-loader calls
|
|
7944
|
+
to the backend carry no such header, so they stay keyed by the proxy peer. Raise
|
|
7945
|
+
`max` for an app that serves its pages from the same server.
|
|
7946
|
+
|
|
7617
7947
|
The Bun, Node and Deno entries serve the client bundle from disk next to themselves; on
|
|
7618
7948
|
Cloudflare and Vercel the platform serves it.
|
|
7619
7949
|
|
|
@@ -7892,7 +8222,7 @@ nifra dev # true-HMR dev server (Bun native HMR + Nifra SSR) - http://local
|
|
|
7892
8222
|
nifra dev --vite # the Vite middleware pipeline instead (automatic when vitePlugins are your ONLY transforms)
|
|
7893
8223
|
nifra build # full Bun deploy → dist/server.js + content-hashed dist/assets/ (default target: bun)
|
|
7894
8224
|
nifra start # run dist/server.js on Bun
|
|
7895
|
-
nifra build --target cloudflare # also: node | deno | vercel | static;
|
|
8225
|
+
nifra build --target cloudflare # also: node | deno | vercel | static; configure custom adapters in nifra.config.ts first
|
|
7896
8226
|
|
|
7897
8227
|
# dev + start share the default port 4321. Override per run: --port <n> (alias -p) or the PORT env var.
|
|
7898
8228
|
# flags: --port <n> (dev/start) · --out <dir> (build/start) · --target <t> (build) · --poll (dev)
|
|
@@ -8003,9 +8333,9 @@ What it does
|
|
|
8003
8333
|
|
|
8004
8334
|
The dev server with true HMR, on port 4321. Bun runs it unless `vitePlugins` are the app's only transforms. `--no-indicator` hides the in-page issues badge.
|
|
8005
8335
|
|
|
8006
|
-
`nifra build [--target <t>] [--out <dir>] [--report]`
|
|
8336
|
+
`nifra build [--target <t>] [--out <dir>] [--transport <module>] [--prerender <paths>] [--report]`
|
|
8007
8337
|
|
|
8008
|
-
A complete deploy directory for `bun`, `node`, `deno`, `cloudflare`, `vercel` or `static`. The server entry is generated from `backend/framework.ts`, `backend/app.ts` and `routes/`. `--report` prints each chunk's size.
|
|
8338
|
+
A complete deploy directory for `bun`, `node`, `deno`, `cloudflare`, `vercel` or `static`. The server entry is generated from `backend/framework.ts`, `backend/app.ts` and `routes/`. `--report` prints each chunk's size. `--transport` builds the client to reach its server through that module's `fetch`, for a native shell. `--prerender` (static target) also prerenders the named pages, comma-separated, whether or not their route exports `prerender`.
|
|
8009
8339
|
|
|
8010
8340
|
`nifra start [--port <n>] [--out <dir>]`
|
|
8011
8341
|
|
|
@@ -8163,6 +8493,10 @@ Print the project's route index and conventions for an agent's prompt.
|
|
|
8163
8493
|
|
|
8164
8494
|
Print the guided build-an-app path, or one step's goal, actions and check.
|
|
8165
8495
|
|
|
8496
|
+
`nifra shell tauri [--origin <url>] [--name <n>] [--id <bundle>] [--mobile android|ios|all] [--force]`
|
|
8497
|
+
|
|
8498
|
+
Add a Tauri 2 shell to an existing app: `frontend/shell-transport.ts` and a `src-tauri/` project that wraps a static build made with `--transport`. Writes files only and keeps any that exist unless `--force`; `--mobile` then runs `tauri android init` and `tauri ios init`. See native shells.
|
|
8499
|
+
|
|
8166
8500
|
`nifra init-agents [--force] [--sync-mcp]`
|
|
8167
8501
|
|
|
8168
8502
|
Add the agent files a new app ships (`.mcp.json`, the `AGENTS.md` sections, each agent's pointer) to an existing app. `--sync-mcp` re-pins the MCP launch to the installed nifra.
|
|
@@ -8268,8 +8602,8 @@ starts from unless nothing else, installed or declared, names one.
|
|
|
8268
8602
|
|
|
8269
8603
|
```bash
|
|
8270
8604
|
nifra upgrade --list # the release targets this CLI knows
|
|
8271
|
-
nifra upgrade 5.
|
|
8272
|
-
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
|
|
8273
8607
|
# if pins were already bumped by hand, add --from <installed-version>
|
|
8274
8608
|
bun install # install the new pins
|
|
8275
8609
|
nifra check # verify against them
|
|
@@ -11244,8 +11578,11 @@ file that reaches it.
|
|
|
11244
11578
|
The optional server-components pipeline supports
|
|
11245
11579
|
React, Preact, Vue, Svelte and Solid. Declare closed input/public-props schemas and authorization
|
|
11246
11580
|
in `*.component.server.ts(x)`, register owner instances and export a named
|
|
11247
|
-
`componentPipeline` configuration. React uses native RSC/Flight;
|
|
11248
|
-
|
|
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;
|
|
11249
11586
|
HTML/data/refresh are private/no-store. Writes use server functions or actions. Bind the
|
|
11250
11587
|
router and await auth-scope invalidation on identity, tenant or permission changes.
|
|
11251
11588
|
|
|
@@ -11869,6 +12206,40 @@ delay is the time a load balancer gets to see that and route elsewhere. Register
|
|
|
11869
12206
|
`app.onStop(fn)` still runs after the drain, on Bun, Node and Deno alike.
|
|
11870
12207
|
`delayMs + drainMs` has to fit in the kill grace period.
|
|
11871
12208
|
|
|
12209
|
+
To stop at the end of a scope instead of on a signal, hold the handle with
|
|
12210
|
+
`await using`. The handle `listen()` returns, the one
|
|
12211
|
+
`serve()` returns on Node and Deno, and the worker `@nifrajs/jobs`
|
|
12212
|
+
starts all stop when the scope ends, on a throw or an early return too. On Bun, disposal runs
|
|
12213
|
+
the app's graceful `app.stop()` with its default options, not Bun's raw stop. On
|
|
12214
|
+
Node and Deno it calls the `stop()` of the `serve()` handle, also with
|
|
12215
|
+
default options, which runs the same `onStopping` and `onStop` hooks and
|
|
12216
|
+
drains the same way; it does not call `app.stop()`, which would leave that listener
|
|
12217
|
+
open. If a shutdown is already under way, disposal waits for that one rather than starting
|
|
12218
|
+
another. A `@nifrajs/cron` scheduler is synchronous, so it takes
|
|
12219
|
+
`using`.
|
|
12220
|
+
|
|
12221
|
+
```ts
|
|
12222
|
+
import { server } from "@nifrajs/core"
|
|
12223
|
+
import { createScheduler } from "@nifrajs/cron"
|
|
12224
|
+
import { createQueue } from "@nifrajs/jobs"
|
|
12225
|
+
|
|
12226
|
+
const app = server().get("/", () => "ok")
|
|
12227
|
+
const queue = createQueue()
|
|
12228
|
+
|
|
12229
|
+
export async function runUntilDone(done: Promise<void>): Promise<void> {
|
|
12230
|
+
await using running = app.listen(3000) // graceful stop() when the scope ends
|
|
12231
|
+
await using worker = queue.start() // stops polling, waits for jobs in flight
|
|
12232
|
+
using scheduler = createScheduler() // stop() when the scope ends
|
|
12233
|
+
scheduler.start()
|
|
12234
|
+
await done
|
|
12235
|
+
console.log(running.port, worker.running)
|
|
12236
|
+
}
|
|
12237
|
+
```
|
|
12238
|
+
|
|
12239
|
+
This needs a runtime and a TypeScript `lib` that know explicit resource management
|
|
12240
|
+
(`esnext.disposable`). Nifra's own declaration files reference that lib, so
|
|
12241
|
+
importing them is enough for the types.
|
|
12242
|
+
|
|
11872
12243
|
### Letting check and assure read the app
|
|
11873
12244
|
|
|
11874
12245
|
`nifra check`, `assure`, `routes` and the other commands that
|
|
@@ -12214,6 +12585,294 @@ Complete runnable references - a typed CRUD API you can diff your own against:
|
|
|
12214
12585
|
`examples/db-sqlite` (the same API on raw `bun:sqlite`, parameterized
|
|
12215
12586
|
queries, boundary validation).
|
|
12216
12587
|
|
|
12588
|
+
## Nifra - Browser end-to-end tests
|
|
12589
|
+
|
|
12590
|
+
> Browser tests for a Nifra app with typed paths, locators, retrying assertions, goal-driven agent steps and a replay cache that makes the second run model-free, with @nifrajs/e2e.
|
|
12591
|
+
|
|
12592
|
+
`@nifrajs/e2e` serves your app on an ephemeral port, drives it through a browser,
|
|
12593
|
+
and gives you typed paths, locators and retrying assertions. On top it adds goal-driven agent
|
|
12594
|
+
steps and a replay cache, so a test can say what it wants in words and still run model-free
|
|
12595
|
+
after the first pass. It is a library: use `bun:test`, Vitest or anything that
|
|
12596
|
+
runs `async` functions.
|
|
12597
|
+
|
|
12598
|
+
### A first test
|
|
12599
|
+
|
|
12600
|
+
```ts
|
|
12601
|
+
import { test } from "bun:test"
|
|
12602
|
+
import { server } from "@nifrajs/core/server"
|
|
12603
|
+
import { e2e, expect } from "@nifrajs/e2e"
|
|
12604
|
+
|
|
12605
|
+
const html = (body: string) => new Response(body, { headers: { "content-type": "text/html" } })
|
|
12606
|
+
|
|
12607
|
+
const app = server().get("/users/:id", (c) =>
|
|
12608
|
+
html(`<input aria-label="Nickname" value="ada"><h1>User ${c.params.id}`),
|
|
12609
|
+
)
|
|
12610
|
+
|
|
12611
|
+
test("a user page renders", async () => {
|
|
12612
|
+
await using t = await e2e(app)
|
|
12613
|
+
await t.open("/users/:id", { params: { id: 42 } }) // a path or param the app lacks fails typecheck
|
|
12614
|
+
await expect(t.screen.getByRole("heading")).toHaveText("User 42")
|
|
12615
|
+
await t.screen.getByLabel("Nickname").fill("grace")
|
|
12616
|
+
await expect(t).toHaveURL("/users/42")
|
|
12617
|
+
})
|
|
12618
|
+
```
|
|
12619
|
+
|
|
12620
|
+
`open()` takes only paths the app declares and requires their
|
|
12621
|
+
`:params`. `await using` closes the browser and the server at scope exit.
|
|
12622
|
+
Names and text match as a case-insensitive substring; pass `{ exact: true }` for
|
|
12623
|
+
a full match. A locator that matches several elements is an error for `tap`,
|
|
12624
|
+
`fill`, `press` and the one-element assertions, never a guess at the
|
|
12625
|
+
first. Assertions retry until `assertionTimeout` (5000 ms by default).
|
|
12626
|
+
|
|
12627
|
+
On a page that loads a module script, actions wait for `data-nifra-hydrated` on
|
|
12628
|
+
`<html>`, so a tap never lands before its handler exists. Pass
|
|
12629
|
+
`hydration: "off"` for a page that is not a hydrated Nifra page.
|
|
12630
|
+
|
|
12631
|
+
### Signed-in sessions
|
|
12632
|
+
|
|
12633
|
+
```ts
|
|
12634
|
+
import { server } from "@nifrajs/core/server"
|
|
12635
|
+
import { testSession } from "@nifrajs/testing"
|
|
12636
|
+
import { e2e, expect } from "@nifrajs/e2e"
|
|
12637
|
+
|
|
12638
|
+
const app = server().get("/me", (c) =>
|
|
12639
|
+
new Response(`<p>session ${c.cookies.sid ?? "none"}`, { headers: { "content-type": "text/html" } }),
|
|
12640
|
+
)
|
|
12641
|
+
|
|
12642
|
+
// Log in through the API, in process, then hand the cookie jar to the browser.
|
|
12643
|
+
const { cookies } = testSession<typeof app>(app)
|
|
12644
|
+
cookies.set("sid", "abc123")
|
|
12645
|
+
|
|
12646
|
+
await using t = await e2e(app, { cookies })
|
|
12647
|
+
await t.open("/me")
|
|
12648
|
+
await expect(t.screen.getByText("session abc123")).toBeVisible()
|
|
12649
|
+
```
|
|
12650
|
+
|
|
12651
|
+
### Agent steps
|
|
12652
|
+
|
|
12653
|
+
`t.agent.act` takes one goal; `assert` and `waitFor` take a
|
|
12654
|
+
statement; `extract` returns data your schema accepts. The model is a port you
|
|
12655
|
+
supply: `{ decide(request) }`. The request carries a pruned outline of the page
|
|
12656
|
+
(at most `snapshotChars`, 12000 by default) and what was already tried; the answer is
|
|
12657
|
+
a small JSON decision.
|
|
12658
|
+
|
|
12659
|
+
```ts
|
|
12660
|
+
import { server } from "@nifrajs/core/server"
|
|
12661
|
+
import { e2e, expect, Secret, type E2EModel } from "@nifrajs/e2e"
|
|
12662
|
+
|
|
12663
|
+
const html = (body: string) => new Response(body, { headers: { "content-type": "text/html" } })
|
|
12664
|
+
|
|
12665
|
+
// A sign-in form that lands on a dashboard, so a model has controls to find and a place to end.
|
|
12666
|
+
const app = server()
|
|
12667
|
+
.get("/login", () =>
|
|
12668
|
+
html(`<input aria-label="Email"><input aria-label="Password" type="password"><button onclick="location.href='/dashboard'">Sign in`),
|
|
12669
|
+
)
|
|
12670
|
+
.get("/dashboard", () => html("<h1>Welcome, Ada"))
|
|
12671
|
+
|
|
12672
|
+
// The seam to a model. Nothing here names a vendor: you call your provider inside decide().
|
|
12673
|
+
// doc-check: skip - the provider call is yours; a real adapter would await a model API here.
|
|
12674
|
+
declare const askMyModel: (request: unknown) => Promise<unknown>
|
|
12675
|
+
const model: E2EModel = { decide: (request) => askMyModel(request) }
|
|
12676
|
+
|
|
12677
|
+
await using t = await e2e(app, { model, agentContext: "Acme calls a plan a seat" })
|
|
12678
|
+
await t.open("/login")
|
|
12679
|
+
|
|
12680
|
+
await t.agent.act("sign in as {email} with {password}", {
|
|
12681
|
+
params: { email: "ada@example.test", password: new Secret("password", process.env.PASSWORD ?? "") },
|
|
12682
|
+
})
|
|
12683
|
+
await t.agent.assert("the dashboard greets Ada")
|
|
12684
|
+
await expect(t.screen.getByRole("heading")).toHaveText("Welcome, Ada") // locators and agent steps mix in one test
|
|
12685
|
+
```
|
|
12686
|
+
|
|
12687
|
+
```ts
|
|
12688
|
+
// What decide() receives and returns, by request kind.
|
|
12689
|
+
//
|
|
12690
|
+
// act { goal, snapshot, history, secrets, handoff, ... }
|
|
12691
|
+
// -> { kind: "tap" | "fill" | "press", target, value?, key? }
|
|
12692
|
+
// | { kind: "goto", path } | { kind: "done", summary? } | { kind: "fail", reason }
|
|
12693
|
+
// assert { statement, snapshot } -> { pass: true | false | "inconclusive", reason }
|
|
12694
|
+
// waitFor { statement, snapshot } -> { pass, reason }
|
|
12695
|
+
// extract { prompt, snapshot } -> { value } (validated with your Standard Schema)
|
|
12696
|
+
//
|
|
12697
|
+
// target is one of { role, name? } | { label } | { text } | { testId }, plus exact? and nth?.
|
|
12698
|
+
// doc-check: skip - protocol sketch, not code.
|
|
12699
|
+
```
|
|
12700
|
+
|
|
12701
|
+
-
|
|
12702
|
+
**Budgets.** `act` stops at `maxModelCalls` (12),
|
|
12703
|
+
`maxActions` (25) or `timeout` (120000 ms), each its own error. A tap
|
|
12704
|
+
that finds nothing, or several, goes back to the model, which can retry with
|
|
12705
|
+
`nth`. The time limit is checked between decisions: it does not interrupt a
|
|
12706
|
+
`decide()` call that never resolves, so enforce your own deadline inside
|
|
12707
|
+
`decide` (the request carries a `signal`).
|
|
12708
|
+
|
|
12709
|
+
-
|
|
12710
|
+
**Secrets.** A `Secret` is typed into the page by name. The model sees
|
|
12711
|
+
`{password}`, never the value, and every outline a session sends has any secret
|
|
12712
|
+
it was given replaced by its placeholder.
|
|
12713
|
+
|
|
12714
|
+
-
|
|
12715
|
+
**Same origin.** `goto` takes an app path only; anything else is refused and
|
|
12716
|
+
reported back to the model.
|
|
12717
|
+
|
|
12718
|
+
-
|
|
12719
|
+
**No model.** Agent steps reject with `MODEL_MISSING`; locator tests need
|
|
12720
|
+
none.
|
|
12721
|
+
|
|
12722
|
+
```ts
|
|
12723
|
+
import { server } from "@nifrajs/core/server"
|
|
12724
|
+
import { t as s } from "@nifrajs/schema"
|
|
12725
|
+
import { e2e } from "@nifrajs/e2e"
|
|
12726
|
+
|
|
12727
|
+
const app = server().get("/plan", () => new Response("<p>Pro, 5 seats", {
|
|
12728
|
+
headers: { "content-type": "text/html" },
|
|
12729
|
+
}))
|
|
12730
|
+
|
|
12731
|
+
const model = {
|
|
12732
|
+
decide: () => ({ value: { plan: "Pro", seats: 5 } }), // a real model reads the outline in the request
|
|
12733
|
+
}
|
|
12734
|
+
|
|
12735
|
+
await using t = await e2e(app, { model })
|
|
12736
|
+
await t.open("/plan")
|
|
12737
|
+
const plan = await t.agent.extract("the current plan and seat count", {
|
|
12738
|
+
schema: s.object({ plan: s.string(), seats: s.number() }),
|
|
12739
|
+
})
|
|
12740
|
+
plan.seats // number
|
|
12741
|
+
```
|
|
12742
|
+
|
|
12743
|
+
### The replay cache
|
|
12744
|
+
|
|
12745
|
+
The first run of an `act` asks the model. The next runs replay what it did, with no
|
|
12746
|
+
model call. A recording is written only after a **later** locator assertion,
|
|
12747
|
+
`agent.assert` or `agent.waitFor` passes, and a failing one deletes it, so
|
|
12748
|
+
a test should end with a check.
|
|
12749
|
+
|
|
12750
|
+
```ts
|
|
12751
|
+
import { server } from "@nifrajs/core/server"
|
|
12752
|
+
import { e2e, expect, formatReport, unique, type E2EModel } from "@nifrajs/e2e"
|
|
12753
|
+
|
|
12754
|
+
const app = server().get("/signup", () => new Response("<h1>Sign up", {
|
|
12755
|
+
headers: { "content-type": "text/html" },
|
|
12756
|
+
}))
|
|
12757
|
+
const model: E2EModel = { decide: () => ({ kind: "done" }) }
|
|
12758
|
+
|
|
12759
|
+
await using t = await e2e(app, {
|
|
12760
|
+
model,
|
|
12761
|
+
cache: { testId: "a visitor signs up", mode: "read-write" },
|
|
12762
|
+
})
|
|
12763
|
+
await t.open("/signup")
|
|
12764
|
+
|
|
12765
|
+
// unique() keeps a run-varying value from missing the cache; it is typed again on replay.
|
|
12766
|
+
await t.agent.act("sign up as {email}", { params: { email: unique(`ada-${Date.now()}@example.test`) } })
|
|
12767
|
+
|
|
12768
|
+
// The recording is written only when a LATER check passes.
|
|
12769
|
+
await expect(t.screen.getByRole("heading")).toBeVisible()
|
|
12770
|
+
console.log(formatReport(t.agent.report())) // Cache: 1 replayed - 0 handed off - 0 missed (0 model calls)
|
|
12771
|
+
```
|
|
12772
|
+
|
|
12773
|
+
-
|
|
12774
|
+
**Replay** needs the same start route, finds each control by the role, name, label, text
|
|
12775
|
+
or test id it had and requires the same number of matches, then checks the end route and the
|
|
12776
|
+
controls and headings that appeared or went away. It never taps a near miss.
|
|
12777
|
+
|
|
12778
|
+
-
|
|
12779
|
+
**Hand-off.** When a replay stops (`target-not-found`, `ambiguous`,
|
|
12780
|
+
`end-mismatch`, `action-uncertain`, `route-mismatch`) the
|
|
12781
|
+
actions already done stay done, and the model finishes the goal from the current page.
|
|
12782
|
+
`request.handoff` carries the reason. A passing check re-records the repaired steps;
|
|
12783
|
+
if the goal then fails, the recording is deleted.
|
|
12784
|
+
|
|
12785
|
+
-
|
|
12786
|
+
**The key** is `cache.testId` (set it: two tests that say the same thing
|
|
12787
|
+
otherwise share a recording), the goal text, the params, `agentContext` and
|
|
12788
|
+
`cache.appIdentity`. A `unique()` value and a `Secret` do not
|
|
12789
|
+
change it, and a secret is stored by name only.
|
|
12790
|
+
|
|
12791
|
+
-
|
|
12792
|
+
**Where.** `.nifra/e2e-cache/<hash>.json` under the working directory,
|
|
12793
|
+
small and meant to be committed. `cache.store` swaps in your own;
|
|
12794
|
+
`cache: false` turns the cache off.
|
|
12795
|
+
|
|
12796
|
+
#### Modes
|
|
12797
|
+
|
|
12798
|
+
Mode
|
|
12799
|
+
Replays
|
|
12800
|
+
Writes and deletes
|
|
12801
|
+
Stale or missing recording
|
|
12802
|
+
|
|
12803
|
+
`read-write`
|
|
12804
|
+
|
|
12805
|
+
yes
|
|
12806
|
+
yes
|
|
12807
|
+
hand-off to the model
|
|
12808
|
+
|
|
12809
|
+
`read-only` (default when `CI` is set)
|
|
12810
|
+
|
|
12811
|
+
yes
|
|
12812
|
+
no
|
|
12813
|
+
hand-off to the model
|
|
12814
|
+
|
|
12815
|
+
`strict`
|
|
12816
|
+
|
|
12817
|
+
yes
|
|
12818
|
+
no
|
|
12819
|
+
|
|
12820
|
+
`REPLAY_STALE` / `REPLAY_MISSING`, no model call
|
|
12821
|
+
|
|
12822
|
+
`off`
|
|
12823
|
+
|
|
12824
|
+
no
|
|
12825
|
+
no
|
|
12826
|
+
the model runs every time
|
|
12827
|
+
|
|
12828
|
+
```ts
|
|
12829
|
+
import { server } from "@nifrajs/core/server"
|
|
12830
|
+
import { e2e, expect } from "@nifrajs/e2e"
|
|
12831
|
+
|
|
12832
|
+
const html = (body: string) => new Response(body, { headers: { "content-type": "text/html" } })
|
|
12833
|
+
|
|
12834
|
+
const app = server()
|
|
12835
|
+
.get("/", () => html('<a href="/dashboard">Dashboard'))
|
|
12836
|
+
.get("/dashboard", () => html("<h1>Dashboard"))
|
|
12837
|
+
|
|
12838
|
+
// CI replays committed recordings and never writes or deletes them. With no model, a recording that
|
|
12839
|
+
// no longer matches fails with MODEL_MISSING; mode: "strict" fails with REPLAY_STALE (or
|
|
12840
|
+
// REPLAY_MISSING when nothing was recorded) instead of ever calling a model.
|
|
12841
|
+
await using t = await e2e(app, { cache: { testId: "home to dashboard", mode: "strict" } })
|
|
12842
|
+
await t.open("/")
|
|
12843
|
+
await t.agent.act("open the dashboard") // reads the committed recording; strict mode checks it here
|
|
12844
|
+
await expect(t.screen.getByRole("heading")).toHaveText("Dashboard")
|
|
12845
|
+
```
|
|
12846
|
+
|
|
12847
|
+
`t.agent.report()` returns `{ replayed, handedOff, missed, modelCalls }`
|
|
12848
|
+
and `formatReport` prints it. Token counts are not reported: the model port returns
|
|
12849
|
+
decisions, not usage. A cache store that refuses a write is counted, never thrown.
|
|
12850
|
+
|
|
12851
|
+
### Engines
|
|
12852
|
+
|
|
12853
|
+
`e2e()` uses Playwright by default. Install it yourself (`playwright` is
|
|
12854
|
+
an optional peer dependency) and a browser with `bunx playwright install chromium`.
|
|
12855
|
+
The engine is a six-method interface, so anything else plugs in with
|
|
12856
|
+
`e2e(app, { engine })`; `@nifrajs/e2e/fake` is an in-memory engine with
|
|
12857
|
+
the same locator rules, for testing code built on this package.
|
|
12858
|
+
|
|
12859
|
+
```ts
|
|
12860
|
+
import { server } from "@nifrajs/core/server"
|
|
12861
|
+
import { e2e } from "@nifrajs/e2e"
|
|
12862
|
+
import { fakeEngine } from "@nifrajs/e2e/fake"
|
|
12863
|
+
|
|
12864
|
+
const app = server().get("/", () => new Response("ok"))
|
|
12865
|
+
|
|
12866
|
+
// An in-memory engine with the same locator rules, for testing code built on this package.
|
|
12867
|
+
const { factory } = fakeEngine({ pages: { "/": [{ role: "heading", name: "Home", text: "Home" }] } })
|
|
12868
|
+
await using t = await e2e(app, { engine: factory, cache: false })
|
|
12869
|
+
await t.open("/")
|
|
12870
|
+
await t.screen.getByRole("heading").count()
|
|
12871
|
+
```
|
|
12872
|
+
|
|
12873
|
+
An agent step is only as safe as the app state behind it. Point it at a test database and an
|
|
12874
|
+
isolated fixture, never at production, and keep credentials in `Secret` params.
|
|
12875
|
+
|
|
12217
12876
|
## Nifra - Error codes
|
|
12218
12877
|
|
|
12219
12878
|
> Every error code Nifra recognises: what each one means and how to fix it. The dev overlay, nifra_explain and nifra_errors name these codes and link here.
|
|
@@ -12790,7 +13449,9 @@ app.use(idempotency({ store: new MemoryIdempotencyStore() }))
|
|
|
12790
13449
|
|
|
12791
13450
|
Stripe redelivers; users double-click. The `idempotency` middleware replays the
|
|
12792
13451
|
first response for a retried key instead of re-running the charge, and rejects a concurrent
|
|
12793
|
-
duplicate while the first is in flight.
|
|
13452
|
+
duplicate while the first is in flight. Cached response bodies are bounded to 1 MiB by
|
|
13453
|
+
default; set `maxBytes` explicitly for a different cap, and use a separate
|
|
13454
|
+
streaming endpoint for responses that should not be replayed.
|
|
12794
13455
|
|
|
12795
13456
|
### When to write a plugin
|
|
12796
13457
|
|
|
@@ -12808,6 +13469,47 @@ executor, with your typed nifra context passed to the resolvers. Subscriptions r
|
|
|
12808
13469
|
nifra's WebSocket lane with `graphql-ws`. The request body goes through the same
|
|
12809
13470
|
bounded parser as every other route, and the query text is never logged.
|
|
12810
13471
|
|
|
13472
|
+
### Supporting packages
|
|
13473
|
+
|
|
13474
|
+
The smaller integrations stay separate so a backend only pays for the surfaces it uses. They
|
|
13475
|
+
are all listed in the generated API reference and are
|
|
13476
|
+
discoverable from this guide:
|
|
13477
|
+
|
|
13478
|
+
-
|
|
13479
|
+
`@nifrajs/env` validates and coerces environment variables once at startup. It
|
|
13480
|
+
is edge-safe when you pass Workers bindings as `source`.
|
|
13481
|
+
|
|
13482
|
+
-
|
|
13483
|
+
`@nifrajs/proxy` forwards to one fixed upstream with SSRF-safe URL construction
|
|
13484
|
+
and hop-by-hop header hygiene.
|
|
13485
|
+
|
|
13486
|
+
-
|
|
13487
|
+
`@nifrajs/island-trigger` is the framework-neutral scheduling primitive behind
|
|
13488
|
+
web islands; most apps can use the higher-level `@nifrajs/web/islands` API.
|
|
13489
|
+
|
|
13490
|
+
-
|
|
13491
|
+
`@nifrajs/mcp-db` exposes an explicit SQLite table allowlist as fail-closed MCP
|
|
13492
|
+
schema tools, with read-only queries opt-in and bounded.
|
|
13493
|
+
|
|
13494
|
+
-
|
|
13495
|
+
`@nifrajs/agent-review` parses and composes bounded, content-free review reports
|
|
13496
|
+
for agent and CI tooling.
|
|
13497
|
+
|
|
13498
|
+
```ts
|
|
13499
|
+
import { defineEnv, env } from "@nifrajs/env"
|
|
13500
|
+
|
|
13501
|
+
export const config = defineEnv({
|
|
13502
|
+
DATABASE_URL: env.url(),
|
|
13503
|
+
PORT: env.port({ default: 3000 }),
|
|
13504
|
+
NODE_ENV: env.enum(["development", "production", "test"], { default: "development" }),
|
|
13505
|
+
})
|
|
13506
|
+
```
|
|
13507
|
+
|
|
13508
|
+
Keep the returned config frozen and server-only; never copy secret values into a
|
|
13509
|
+
`PUBLIC_*` client module. See
|
|
13510
|
+
Edge & bindings for the Workers binding form
|
|
13511
|
+
and Security for boundary rules.
|
|
13512
|
+
|
|
12811
13513
|
## Nifra - Keep-alive
|
|
12812
13514
|
|
|
12813
13515
|
> Pages that stay mounted after the visitor leaves them: back and forward bring back the same page, with its scroll, form input and component state, and a sign-out drops them in every tab.
|
|
@@ -13907,7 +14609,7 @@ the command below, which runs every recipe since its installed version. The 5.6
|
|
|
13907
14609
|
its imports and dependencies; the follow-up changes below need a hand.
|
|
13908
14610
|
|
|
13909
14611
|
```sh
|
|
13910
|
-
nifra upgrade 5.
|
|
14612
|
+
nifra upgrade 5.14.0
|
|
13911
14613
|
```
|
|
13912
14614
|
|
|
13913
14615
|
-
|
|
@@ -13926,7 +14628,7 @@ Islands.
|
|
|
13926
14628
|
throws at startup without one. Pages stored before the upgrade render once more.
|
|
13927
14629
|
|
|
13928
14630
|
-
|
|
13929
|
-
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
|
|
13930
14632
|
that version.
|
|
13931
14633
|
|
|
13932
14634
|
-
|
|
@@ -14338,9 +15040,9 @@ Migrate a backend. For the full
|
|
|
14338
15040
|
rendering and route model, see Loaders & actions
|
|
14339
15041
|
and Routing.
|
|
14340
15042
|
|
|
14341
|
-
The current dynamic SSR snapshot reports Nifra at
|
|
14342
|
-
of Next.js, 7
|
|
14343
|
-
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
|
|
14344
15046
|
benchmark methodology and full results.
|
|
14345
15047
|
|
|
14346
15048
|
## Nifra - Migrate route by route
|
|
@@ -14418,6 +15120,270 @@ handler. Pass its fetch-compatible function directly. For a Workers-style handle
|
|
|
14418
15120
|
platform argument carries bindings and `waitUntil`; mounted code remains responsible
|
|
14419
15121
|
for its own framework-specific request and response conventions.
|
|
14420
15122
|
|
|
15123
|
+
## Nifra - Native shells
|
|
15124
|
+
|
|
15125
|
+
> Ship an app's pages inside Tauri, Capacitor or Electron while its server stays on the web: one transport for route data, actions, server functions and the live socket.
|
|
15126
|
+
|
|
15127
|
+
A shell wraps an app's pages in a native window or a phone app: Tauri, Capacitor and
|
|
15128
|
+
Electron all load the built client from disk. The pages then live on one origin, such as
|
|
15129
|
+
`tauri://localhost`, and the server on another. A `transport` tells
|
|
15130
|
+
the client where the server is. The router's requests, server functions, the live socket and
|
|
15131
|
+
the calls you make with `appFetch` go through it; a plain
|
|
15132
|
+
`fetch("/api/todos")` does not, and goes to the shell's own origin.
|
|
15133
|
+
|
|
15134
|
+
### Build the pages
|
|
15135
|
+
|
|
15136
|
+
Write the transport in a frontend file with `serverFetch` from
|
|
15137
|
+
`@nifrajs/web/shell`. A path-absolute URL, such as `/todos`, goes to
|
|
15138
|
+
`origin`. The headers are added to each request to that origin, and may be a
|
|
15139
|
+
function that returns them; a request to any other host goes out as written, without the
|
|
15140
|
+
headers or credentials, so a call to a third party never carries your token.
|
|
15141
|
+
|
|
15142
|
+
```ts
|
|
15143
|
+
// frontend/transport.ts
|
|
15144
|
+
import { serverFetch } from "@nifrajs/web/shell"
|
|
15145
|
+
|
|
15146
|
+
export default serverFetch({ origin: "https://api.example.com" })
|
|
15147
|
+
```
|
|
15148
|
+
|
|
15149
|
+
With a token that refreshes:
|
|
15150
|
+
|
|
15151
|
+
```ts
|
|
15152
|
+
// frontend/transport.ts
|
|
15153
|
+
import { serverFetch } from "@nifrajs/web/shell"
|
|
15154
|
+
|
|
15155
|
+
export default serverFetch({
|
|
15156
|
+
origin: "https://api.example.com",
|
|
15157
|
+
// A bearer token that refreshes: the function runs before each request.
|
|
15158
|
+
headers: async () => ({ authorization: `Bearer ${await currentToken()}` }),
|
|
15159
|
+
})
|
|
15160
|
+
|
|
15161
|
+
// The app's own: where it keeps and refreshes its token.
|
|
15162
|
+
declare function currentToken(): Promise<string>
|
|
15163
|
+
```
|
|
15164
|
+
|
|
15165
|
+
An app that signs in with a cookie sets `credentials: "include"`. The
|
|
15166
|
+
server then needs `credentials: true` in its CORS options and a cookie a
|
|
15167
|
+
cross-site request may carry (`SameSite=None; Secure`), and a web view may
|
|
15168
|
+
restrict cookies further, so a bearer token is the safer choice in a shell.
|
|
15169
|
+
|
|
15170
|
+
```ts
|
|
15171
|
+
// doc-check: skip - a fragment of frontend/transport.ts.
|
|
15172
|
+
export default serverFetch({ origin: "https://api.example.com", credentials: "include" })
|
|
15173
|
+
```
|
|
15174
|
+
|
|
15175
|
+
Pass the module to the shell build with `--transport`, and name the pages the
|
|
15176
|
+
shell opens on with
|
|
15177
|
+
`--prerender` (comma-separated paths such as `/,/about`). Only this
|
|
15178
|
+
build prerenders them, so a web build of the same app keeps rendering them per request; a
|
|
15179
|
+
route that exports `prerender = true` is included too. A path that is not a
|
|
15180
|
+
static page route fails the build.
|
|
15181
|
+
|
|
15182
|
+
```bash
|
|
15183
|
+
nifra build --target static --out dist --prerender /
|
|
15184
|
+
```
|
|
15185
|
+
|
|
15186
|
+
`transport` in the framework config does the same for an app that ships nothing
|
|
15187
|
+
but the shell. It applies to every build, and `--transport` replaces it but
|
|
15188
|
+
cannot turn it off, so leave it out of an app that also ships a web build.
|
|
15189
|
+
|
|
15190
|
+
```ts
|
|
15191
|
+
// doc-check: skip - nifra.config.ts for the CLI; the adapter is the app's own.
|
|
15192
|
+
// Only for an app that ships nothing but the shell: it applies to every build.
|
|
15193
|
+
export { adapter } from "./backend/framework"
|
|
15194
|
+
export const clientModule = "@nifrajs/web-react/client"
|
|
15195
|
+
export const transport = "./frontend/transport.ts"
|
|
15196
|
+
```
|
|
15197
|
+
|
|
15198
|
+
The output has an `index.html` for each prerendered route and the assets they
|
|
15199
|
+
load, which is what a shell's `frontendDist` points at. The same option reaches
|
|
15200
|
+
the Bun and Vite builds and both dev servers, and `buildClient` takes it as
|
|
15201
|
+
`transport`.
|
|
15202
|
+
|
|
15203
|
+
A path the shell has no page for, such as a reload at `/todos`, hydrates the
|
|
15204
|
+
document the shell ships and then navigates to that URL. A prerendered page's route data
|
|
15205
|
+
loads from the bundle, except a navigation with a query string and, in an app with
|
|
15206
|
+
`live`, the loads the live endpoint makes: those go to the server.
|
|
15207
|
+
|
|
15208
|
+
`--transport` names the module for one run and wins over the config, so an app
|
|
15209
|
+
can ship a web build and a shell build from one tree. `--prerender` only
|
|
15210
|
+
applies to `--target static`:
|
|
15211
|
+
|
|
15212
|
+
```bash
|
|
15213
|
+
nifra build --target static --out dist-shell --transport ./frontend/shell-transport.ts --prerender /
|
|
15214
|
+
```
|
|
15215
|
+
|
|
15216
|
+
### What goes through the transport
|
|
15217
|
+
|
|
15218
|
+
- Route data, prefetches and action posts of the router.
|
|
15219
|
+
|
|
15220
|
+
-
|
|
15221
|
+
Server functions: the stub that stands in for a
|
|
15222
|
+
`*.fn.ts` module calls through it.
|
|
15223
|
+
|
|
15224
|
+
-
|
|
15225
|
+
The live socket and its load endpoint. The
|
|
15226
|
+
socket connects to the transport's origin.
|
|
15227
|
+
|
|
15228
|
+
-
|
|
15229
|
+
Keep-alive pages, layered over the
|
|
15230
|
+
transport.
|
|
15231
|
+
|
|
15232
|
+
-
|
|
15233
|
+
Your own calls, with `appFetch`. Hand it to a `useQuery` fetcher or
|
|
15234
|
+
to the typed client: `client(url, { fetch: appFetch })`.
|
|
15235
|
+
|
|
15236
|
+
```ts
|
|
15237
|
+
import { appFetch } from "@nifrajs/web/shell"
|
|
15238
|
+
|
|
15239
|
+
// The transport in a shell build, the global fetch anywhere else.
|
|
15240
|
+
export const todos = (): Promise<unknown> => appFetch("/api/todos").then((res) => res.json())
|
|
15241
|
+
```
|
|
15242
|
+
|
|
15243
|
+
### Let the server accept the shell
|
|
15244
|
+
|
|
15245
|
+
A shell's requests carry its own scheme as their `Origin`, so the server refuses
|
|
15246
|
+
them until it lists that origin. Tauri uses `tauri://localhost` on macOS, iOS
|
|
15247
|
+
and Linux and `http://tauri.localhost` on Windows and Android; Capacitor uses
|
|
15248
|
+
`capacitor://localhost` on iOS.
|
|
15249
|
+
|
|
15250
|
+
-
|
|
15251
|
+
CORS on the web app, as the `use` hook of `backend/framework.ts`:
|
|
15252
|
+
page data and form posts are its routes, not the backend's. List the headers the router
|
|
15253
|
+
reads in `exposedHeaders`; `"*"` is read literally by a credentialed
|
|
15254
|
+
request.
|
|
15255
|
+
|
|
15256
|
+
-
|
|
15257
|
+
A page action checks the route's own `allowedOrigins`, which replaces the
|
|
15258
|
+
same-origin default. Its second argument says whether that default would admit the
|
|
15259
|
+
request, so a route can keep its own site and add the shell.
|
|
15260
|
+
|
|
15261
|
+
-
|
|
15262
|
+
`serverFunctions` takes `origins`.
|
|
15263
|
+
|
|
15264
|
+
-
|
|
15265
|
+
`live` takes `trustedOrigins`, for the load endpoint and the
|
|
15266
|
+
socket.
|
|
15267
|
+
|
|
15268
|
+
```ts
|
|
15269
|
+
// backend/framework.ts: the web app answers page data and form posts, so the CORS goes on it.
|
|
15270
|
+
import { cors } from "@nifrajs/middleware"
|
|
15271
|
+
|
|
15272
|
+
const SHELLS = ["tauri://localhost", "http://tauri.localhost", "capacitor://localhost"]
|
|
15273
|
+
|
|
15274
|
+
export const use = (app: { use: (plugin: ReturnType<typeof cors>) => unknown }): void => {
|
|
15275
|
+
app.use(
|
|
15276
|
+
cors({
|
|
15277
|
+
origin: SHELLS,
|
|
15278
|
+
// Named, not "*": a credentialed request reads "*" as a header called "*".
|
|
15279
|
+
exposedHeaders: ["x-nifra-redirect", "x-nifra-status", "x-nifra-revalidate"],
|
|
15280
|
+
}),
|
|
15281
|
+
)
|
|
15282
|
+
}
|
|
15283
|
+
```
|
|
15284
|
+
|
|
15285
|
+
```ts
|
|
15286
|
+
// doc-check: skip - a route's backend half; the action is the app's own.
|
|
15287
|
+
// routes/todos.backend.ts
|
|
15288
|
+
// allowedOrigins replaces the same-origin default, so the site's own posts come in as sameOrigin.
|
|
15289
|
+
const SHELLS = ["tauri://localhost", "http://tauri.localhost", "capacitor://localhost"]
|
|
15290
|
+
|
|
15291
|
+
export const allowedOrigins = (origin: string | null, sameOrigin: boolean): boolean =>
|
|
15292
|
+
sameOrigin || (origin !== null && SHELLS.includes(origin))
|
|
15293
|
+
```
|
|
15294
|
+
|
|
15295
|
+
```ts
|
|
15296
|
+
import { serverFunctions } from "@nifrajs/web/fn"
|
|
15297
|
+
import * as todos from "./todos.fn.ts"
|
|
15298
|
+
|
|
15299
|
+
export const fns = serverFunctions("todos", todos, {
|
|
15300
|
+
origins: ["tauri://localhost", "http://tauri.localhost", "capacitor://localhost"],
|
|
15301
|
+
})
|
|
15302
|
+
```
|
|
15303
|
+
|
|
15304
|
+
```ts
|
|
15305
|
+
import { live } from "@nifrajs/web/live"
|
|
15306
|
+
|
|
15307
|
+
export const runtime = live({
|
|
15308
|
+
// Required in production, at least 32 bytes: set LIVE_SECRET (openssl rand -base64 32).
|
|
15309
|
+
secret: process.env.LIVE_SECRET ?? "",
|
|
15310
|
+
// Anonymous viewers. An app with accounts returns the session's user id, so a change of account
|
|
15311
|
+
// clears the client's cache and revoke(userId) reaches this viewer's grants.
|
|
15312
|
+
subject: () => null,
|
|
15313
|
+
trustedOrigins: ["tauri://localhost", "http://tauri.localhost", "capacitor://localhost"],
|
|
15314
|
+
})
|
|
15315
|
+
```
|
|
15316
|
+
|
|
15317
|
+
### Tauri 2
|
|
15318
|
+
|
|
15319
|
+
`nifra shell tauri` adds the transport and a `src-tauri/` project to
|
|
15320
|
+
an existing app. It writes files only, skips any that exist unless `--force`,
|
|
15321
|
+
and leaves `package.json` and the config alone. The project builds the static
|
|
15322
|
+
target with `--transport` into `dist-shell/`, and its content
|
|
15323
|
+
security policy allows the server's origin and socket. The window opens hidden and shows
|
|
15324
|
+
on the page's first paint, with a three second timer as the fallback, so there is no blank
|
|
15325
|
+
window while the web view starts.
|
|
15326
|
+
|
|
15327
|
+
```bash
|
|
15328
|
+
nifra shell tauri --origin https://api.example.com
|
|
15329
|
+
```
|
|
15330
|
+
|
|
15331
|
+
```bash
|
|
15332
|
+
bun add -d @tauri-apps/cli
|
|
15333
|
+
bunx tauri icon path/to/icon.png # a square PNG, 1024x1024 recommended
|
|
15334
|
+
bunx tauri dev
|
|
15335
|
+
```
|
|
15336
|
+
|
|
15337
|
+
A new site can start with a shell: `--shell tauri` adds the same project, lets
|
|
15338
|
+
the server's CORS accept the shell origins in `backend/shell-origins.ts`, and
|
|
15339
|
+
adds `shell:dev` and `shell:build` scripts.
|
|
15340
|
+
|
|
15341
|
+
```bash
|
|
15342
|
+
bun create nifra my-app --shell tauri
|
|
15343
|
+
cd my-app && bun install
|
|
15344
|
+
bunx tauri icon path/to/icon.png # a square PNG, 1024x1024 recommended
|
|
15345
|
+
bun run shell:dev
|
|
15346
|
+
```
|
|
15347
|
+
|
|
15348
|
+
`--mobile` also runs `tauri android init` or
|
|
15349
|
+
`tauri ios init` with the project's Tauri CLI, which needs the platform
|
|
15350
|
+
toolchain: the Android SDK and NDK, or Xcode. A platform that fails is reported and the
|
|
15351
|
+
files already written stay.
|
|
15352
|
+
|
|
15353
|
+
```bash
|
|
15354
|
+
nifra shell tauri --mobile android # or ios, or all
|
|
15355
|
+
```
|
|
15356
|
+
|
|
15357
|
+
By hand, point `frontendDist` at the build and allow the server in the content
|
|
15358
|
+
security policy. On iOS, a development server on a local address needs
|
|
15359
|
+
`NSAllowsLocalNetworking` in the app's `Info.plist`.
|
|
15360
|
+
|
|
15361
|
+
```json
|
|
15362
|
+
// doc-check: skip - src-tauri/tauri.conf.json
|
|
15363
|
+
{
|
|
15364
|
+
"build": { "frontendDist": "../dist-shell" },
|
|
15365
|
+
"app": { "security": { "csp": "default-src 'self'; connect-src 'self' https://api.example.com wss://api.example.com" } }
|
|
15366
|
+
}
|
|
15367
|
+
```
|
|
15368
|
+
|
|
15369
|
+
### Limits
|
|
15370
|
+
|
|
15371
|
+
-
|
|
15372
|
+
The transport module must sit in a zone: `frontend/`, or a package that
|
|
15373
|
+
declares `"nifra": { "environment": "frontend" }`.
|
|
15374
|
+
|
|
15375
|
+
-
|
|
15376
|
+
Tauri on macOS, the iOS Simulator and an Android emulator are what this was run on.
|
|
15377
|
+
Windows and Linux use the same transport but have not been run.
|
|
15378
|
+
|
|
15379
|
+
-
|
|
15380
|
+
On Android the web view draws under the status bar, so a page that starts at the top
|
|
15381
|
+
needs its own top padding.
|
|
15382
|
+
|
|
15383
|
+
-
|
|
15384
|
+
A page in a shell starts in the system web view, so its first paint comes after the
|
|
15385
|
+
view does.
|
|
15386
|
+
|
|
14421
15387
|
## Nifra - Tracing & observability
|
|
14422
15388
|
|
|
14423
15389
|
> One trace from the request through the cache, the job queue and the worker, plus the OpenTelemetry SDK's own database and HTTP spans, without bundling the SDK.
|
|
@@ -15391,7 +16357,7 @@ Nifra side: an implementation-level read of every security-relevant module acros
|
|
|
15391
16357
|
`core`, `middleware`, `auth`, `node`,
|
|
15392
16358
|
`web`, `uploads`, and `cli` - defaults and failure modes, not
|
|
15393
16359
|
marketing claims. Competitor side: current official documentation for defaults, verified as of
|
|
15394
|
-
|
|
16360
|
+
November 2026 against the published packages of Hono 4.13.17, Fastify 5.12.8, Express 5.3.0 / 4.22.3, and Elysia 1.4.31 (the Elysia 2.0 release candidate is not covered). The
|
|
15395
16361
|
comparison unit is what a developer gets **by default** and what the framework makes
|
|
15396
16362
|
**impossible to get wrong**, not what a maximally careful expert could configure - because
|
|
15397
16363
|
most real-world security incidents are misconfiguration-by-default.
|
|
@@ -15491,8 +16457,8 @@ O
|
|
|
15491
16457
|
ahead
|
|
15492
16458
|
|
|
15493
16459
|
CSRF
|
|
15494
|
-
B
|
|
15495
|
-
b (
|
|
16460
|
+
B core refuses cross-site form posts on every unsafe route; `csrf()` adds a signed double-submit
|
|
16461
|
+
b (Origin / Sec-Fetch-Site on form content types)
|
|
15496
16462
|
O token-based
|
|
15497
16463
|
3 (csurf deprecated)
|
|
15498
16464
|
-
|
|
@@ -15622,9 +16588,9 @@ ahead (unique)
|
|
|
15622
16588
|
Supply chain (runtime deps in core)
|
|
15623
16589
|
0
|
|
15624
16590
|
0
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
16591
|
+
15
|
|
16592
|
+
28
|
|
16593
|
+
4
|
|
15628
16594
|
par with Hono
|
|
15629
16595
|
|
|
15630
16596
|
Machine-checkable route security evidence
|
|
@@ -15638,7 +16604,7 @@ B (`nifra assure`)
|
|
|
15638
16604
|
unique
|
|
15639
16605
|
|
|
15640
16606
|
Security lint (fail-open, non-constant-time, PII logs)
|
|
15641
|
-
B (NF-S001..
|
|
16607
|
+
B (NF-S001..009)
|
|
15642
16608
|
-
|
|
15643
16609
|
-
|
|
15644
16610
|
-
|
|
@@ -15689,9 +16655,10 @@ Nifra's `cors()` throws at construction when `credentials: true`
|
|
|
15689
16655
|
meets `origin: "*"`, never reflects an origin by default with credentials,
|
|
15690
16656
|
and lands headers on error responses too - it is **the only one of the five where the
|
|
15691
16657
|
dangerous configuration is a construction-time error**. The other four leave
|
|
15692
|
-
reflect-with-credentials configurable.
|
|
15693
|
-
|
|
15694
|
-
|
|
16658
|
+
reflect-with-credentials configurable. Core refuses a cross-site HTML form post to every
|
|
16659
|
+
unsafe route before the handler runs, and `csrf()` adds an Origin/Referer check
|
|
16660
|
+
plus a signed double-submit token, timing-safe; Hono's CSRF is an Origin /
|
|
16661
|
+
Sec-Fetch-Site check on form content types, Fastify's official token package is comparable, Express's
|
|
15695
16662
|
csurf is deprecated, and Elysia ships none in-tree. Uncaught errors become a flat 500
|
|
15696
16663
|
unconditionally - not env-gated - so no configuration leaks a stack to the wire; Express's
|
|
15697
16664
|
dev handler printing stacks when `NODE_ENV` is unset is the perennial
|
|
@@ -15742,7 +16709,7 @@ shedding; nothing else in the field defaults to an unspoofable key or fails clos
|
|
|
15742
16709
|
**Route assurance evidence.** Middleware publishes machine-checkable per-route claims
|
|
15743
16710
|
(`AUTHENTICATED`, `BODY_BOUNDED`, `CSRF`,
|
|
15744
16711
|
`RATE_LIMITED`, `IP_RESTRICTED`, `SECURITY_HEADERS`,
|
|
15745
|
-
`IDEMPOTENCY_KEY`), and `nifra assure` fails CI when a policy is unmet.
|
|
16712
|
+
`IDEMPOTENCY_KEY`, `DURABLE_COMMAND`, `RESPONSE_CONTRACT`), and `nifra assure` fails CI when a policy is unmet.
|
|
15746
16713
|
Evidence is honest: an escape hatch suppresses its own claim.
|
|
15747
16714
|
|
|
15748
16715
|
-
|
|
@@ -16351,6 +17318,8 @@ browser: `serveTestApp` binds the app to an ephemeral port,
|
|
|
16351
17318
|
`e2eUrl` typechecks the visited path against the route registry, and the
|
|
16352
17319
|
session jar crosses into the browser as a `Cookie` header. Bring Playwright
|
|
16353
17320
|
(or Vitest Browser) for the browser itself - nifra supplies the glue, not another runner.
|
|
17321
|
+
@nifrajs/e2e wraps that glue into locators, assertions, agent steps
|
|
17322
|
+
and a replay cache.
|
|
16354
17323
|
|
|
16355
17324
|
```ts
|
|
16356
17325
|
import { chromium } from "@playwright/test"
|
|
@@ -18039,7 +19008,9 @@ The server answers for the nifra the project installs. When the project has its
|
|
|
18039
19008
|
a different version than the `nifra` the client spawned (a global install, say), the session is handed
|
|
18040
19009
|
to `./node_modules/.bin/nifra mcp`. When that is impossible, `nifra_check`, `nifra_types`,
|
|
18041
19010
|
`nifra_docs`, `nifra_example`, `nifra_assure` and `nifra_contracts` refuse with the fix instead of
|
|
18042
|
-
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.
|
|
18043
19014
|
|
|
18044
19015
|
The server runs none of the project's code and keeps none of its `.env`. Every tool, resource and
|
|
18045
19016
|
prompt that loads the app, including the ones the app declares with `.tool()`, runs in a fresh process
|
|
@@ -18645,6 +19616,78 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
18645
19616
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
18646
19617
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
18647
19618
|
|
|
19619
|
+
## @nifrajs/deploy-fly
|
|
19620
|
+
|
|
19621
|
+
Build-time Fly.io packaging for a Nifra app using the existing Node deployment target. It emits a
|
|
19622
|
+
Dockerfile and `fly.toml`; it does not deploy, contact Fly.io, or manage credentials.
|
|
19623
|
+
|
|
19624
|
+
```sh
|
|
19625
|
+
bun add @nifrajs/deploy-fly @nifrajs/node
|
|
19626
|
+
```
|
|
19627
|
+
|
|
19628
|
+
```ts
|
|
19629
|
+
// backend/framework.ts: runtime-only exports imported by the generated server.
|
|
19630
|
+
import { reactAdapter } from "@nifrajs/web-react"
|
|
19631
|
+
export const adapter = reactAdapter
|
|
19632
|
+
export const clientModule = "@nifrajs/web-react/client"
|
|
19633
|
+
```
|
|
19634
|
+
|
|
19635
|
+
```ts
|
|
19636
|
+
// nifra.config.ts: CLI-only deployment configuration.
|
|
19637
|
+
import { flyAdapter } from "@nifrajs/deploy-fly"
|
|
19638
|
+
export { adapter, clientModule } from "./backend/framework.ts"
|
|
19639
|
+
|
|
19640
|
+
export const target = "fly"
|
|
19641
|
+
export const deploymentAdapter = {
|
|
19642
|
+
adapter: flyAdapter,
|
|
19643
|
+
options: { app: "my-nifra-app", primaryRegion: "iad" },
|
|
19644
|
+
}
|
|
19645
|
+
```
|
|
19646
|
+
|
|
19647
|
+
Create the Fly app once before its first deploy if it does not already exist, then build and deploy
|
|
19648
|
+
the emitted directory:
|
|
19649
|
+
|
|
19650
|
+
```sh
|
|
19651
|
+
fly apps create my-nifra-app
|
|
19652
|
+
nifra build
|
|
19653
|
+
cd dist
|
|
19654
|
+
fly deploy
|
|
19655
|
+
```
|
|
19656
|
+
|
|
19657
|
+
`app` is required. `primaryRegion`, `internalPort` (default `3000`), `forceHttps` (default `true`),
|
|
19658
|
+
`healthCheckPath`, and `image` (default `node:22-slim`) are optional. Pin `image` to an exact tag or
|
|
19659
|
+
a `node@sha256:<digest>` reference for reproducible images. Set `healthCheckPath` only when the app has a route that
|
|
19660
|
+
returns 2xx while ready. The adapter emits Fly service-level checks for that path; without it, no
|
|
19661
|
+
health endpoint is assumed. Put secrets in Fly secrets with `fly secrets set`; do not put them in
|
|
19662
|
+
adapter options. Nifra scans emitted adapter files for credentials before publishing the output.
|
|
19663
|
+
|
|
19664
|
+
The adapter uses Nifra's Node target, so the built server and its static assets stay under Nifra's
|
|
19665
|
+
normal build and portability checks. The adapter only adds deployment metadata. It supports ordinary
|
|
19666
|
+
SSR; it currently declares no support for the coordinated component pipeline.
|
|
19667
|
+
|
|
19668
|
+
The emitted Dockerfile sets `NODE_ENV=production`, and production refuses in-memory stores. An app
|
|
19669
|
+
that uses one (the site scaffold's rate limiter, for example) must configure a shared store or, for
|
|
19670
|
+
a single machine, allow it explicitly: the scaffold reads `NIFRA_ALLOW_MEMORY_RATE_LIMIT=true`, set
|
|
19671
|
+
with `fly secrets set`. An in-memory limiter keeps one quota per machine and
|
|
19672
|
+
`fly deploy` adds a spare machine by default. Deploy a new app with `fly deploy --ha=false`; for an
|
|
19673
|
+
app that already has several machines, run `fly scale count 1`. Confirm with `fly status`, or use a
|
|
19674
|
+
shared store.
|
|
19675
|
+
|
|
19676
|
+
The generated Node server derives `c.clientIp` from the socket peer only, which behind Fly's proxy
|
|
19677
|
+
is the proxy. Visitors then share one rate-limit bucket and get 429 once it is spent, and a shared
|
|
19678
|
+
store does not change the keying. Passing `header: "fly-client-ip"` to `rateLimit()` keys requests
|
|
19679
|
+
that arrive over HTTP per visitor, but only while Fly's proxy is the sole path to the app; behind a
|
|
19680
|
+
CDN or another proxy the header holds that proxy's address. The server's own page-loader calls to
|
|
19681
|
+
the backend carry no such header, so they stay keyed by the proxy peer. Raise `max` for an app that
|
|
19682
|
+
serves its pages from the same server.
|
|
19683
|
+
|
|
19684
|
+
Adapters execute as trusted build-time code in the Nifra CLI process. Their API is versioned, their
|
|
19685
|
+
output is declarative, and Nifra rejects unsafe paths, collisions, credential findings, and failed
|
|
19686
|
+
builds before replacing the last successful deploy directory.
|
|
19687
|
+
|
|
19688
|
+
For agent-oriented package guidance, see [`LLM.md`](./LLM.md) and the full
|
|
19689
|
+
[`llms-full.txt`](../../llms-full.txt) corpus.
|
|
19690
|
+
|
|
18648
19691
|
## @nifrajs/devtools
|
|
18649
19692
|
|
|
18650
19693
|
Interactive request-trace DevTools for `nifra dev`, with a secured SSE stream and browser overlay.
|
|
@@ -18682,6 +19725,135 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
18682
19725
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
18683
19726
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
18684
19727
|
|
|
19728
|
+
## @nifrajs/e2e
|
|
19729
|
+
|
|
19730
|
+
Browser end-to-end tests for Nifra apps. It serves your app on an ephemeral port, drives it through
|
|
19731
|
+
a browser engine, and gives you locators and retrying assertions. The route table types `open()`.
|
|
19732
|
+
|
|
19733
|
+
```ts
|
|
19734
|
+
import { test } from "bun:test"
|
|
19735
|
+
import { e2e, expect } from "@nifrajs/e2e"
|
|
19736
|
+
import { app } from "../src/app"
|
|
19737
|
+
|
|
19738
|
+
test("a user page renders", async () => {
|
|
19739
|
+
await using t = await e2e(app)
|
|
19740
|
+
await t.open("/users/:id", { params: { id: 42 } }) // a path or param the app lacks fails typecheck
|
|
19741
|
+
await expect(t.screen.getByRole("heading")).toHaveText("User 42")
|
|
19742
|
+
await t.screen.getByLabel("Nickname").fill("grace")
|
|
19743
|
+
await expect(t).toHaveURL("/users/42")
|
|
19744
|
+
})
|
|
19745
|
+
```
|
|
19746
|
+
|
|
19747
|
+
`await using` closes the browser and the server at scope exit; `t.close()` does the same by hand.
|
|
19748
|
+
|
|
19749
|
+
## Locators and assertions
|
|
19750
|
+
|
|
19751
|
+
`getByRole(role, name)`, `getByLabel`, `getByText`, `getByTestId`, `.filter({ hasText })`, and chaining
|
|
19752
|
+
to scope into a row. Names and text match as a case-insensitive substring; pass `{ exact: true }` for
|
|
19753
|
+
a full match. Actions: `tap`, `fill`, `press`. Assertions retry until they pass or `assertionTimeout`
|
|
19754
|
+
(default 5000 ms) runs out: `toBeVisible`, `toBeHidden`, `toHaveText`, `toContainText`, `toHaveCount`,
|
|
19755
|
+
`toHaveValue`, `toHaveURL`, each with `.not`.
|
|
19756
|
+
|
|
19757
|
+
A locator that matches several elements is an error for `tap`, `fill`, `press` and the one-element
|
|
19758
|
+
assertions (`LOCATOR_AMBIGUOUS`, or a failed assertion naming the count).
|
|
19759
|
+
|
|
19760
|
+
## Hydration
|
|
19761
|
+
|
|
19762
|
+
On a page that loads a module script, the Playwright engine waits for `data-nifra-hydrated` on `<html>`
|
|
19763
|
+
after each navigation and before each action, so a tap does not land before its handler exists. Pass
|
|
19764
|
+
`hydration: "off"` for a page that is not a hydrated Nifra page.
|
|
19765
|
+
|
|
19766
|
+
## Signed-in sessions
|
|
19767
|
+
|
|
19768
|
+
```ts
|
|
19769
|
+
const { client, cookies } = testSession<typeof app>(app)
|
|
19770
|
+
await client.auth.login.post(credentials)
|
|
19771
|
+
await using t = await e2e(app, { cookies })
|
|
19772
|
+
```
|
|
19773
|
+
|
|
19774
|
+
## Agent steps
|
|
19775
|
+
|
|
19776
|
+
Say what you want in words; a model you supply drives the page. Locators and agent steps mix in one test.
|
|
19777
|
+
|
|
19778
|
+
```ts
|
|
19779
|
+
await using t = await e2e(app, { model, agentContext: "Acme calls a plan a seat" })
|
|
19780
|
+
await t.open("/login")
|
|
19781
|
+
await t.agent.act("sign in as {email} with {password}", {
|
|
19782
|
+
params: { email: "ada@example.test", password: new Secret("password", process.env.PASSWORD ?? "") },
|
|
19783
|
+
})
|
|
19784
|
+
await t.agent.assert("the dashboard greets Ada")
|
|
19785
|
+
await t.agent.waitFor("the export is finished", { timeout: 60_000 })
|
|
19786
|
+
const plan = await t.agent.extract("the current plan", { schema: PlanSchema })
|
|
19787
|
+
```
|
|
19788
|
+
|
|
19789
|
+
`model` is `{ decide(request) }`: the request carries the goal, a pruned outline of the page and what was
|
|
19790
|
+
already tried, and the answer is `{ kind: "tap" | "fill" | "press" | "goto" | "done" | "fail", ... }` for
|
|
19791
|
+
`act`, `{ pass, reason }` for `assert` and `waitFor`, and `{ value }` for `extract`. Nothing here names a
|
|
19792
|
+
vendor; you own the credentials, the retries and the cost. Without `model`, agent steps reject with
|
|
19793
|
+
`MODEL_MISSING` and locator tests are unaffected.
|
|
19794
|
+
|
|
19795
|
+
- **Budgets.** `act` stops at `maxModelCalls` (12), `maxActions` (25) or `timeout` (120000 ms), each a
|
|
19796
|
+
distinct error. The time limit is checked between decisions; it does not interrupt a `decide()` call
|
|
19797
|
+
that never resolves, so enforce a deadline inside `decide` (the request carries a `signal`). A tap that finds no element or several goes back to the model, which can retry with `nth`.
|
|
19798
|
+
- **Secrets.** A `Secret` is typed into the page by name. The model sees `{password}`, never the value,
|
|
19799
|
+
and every snapshot a session sends has any secret it was given replaced by its placeholder.
|
|
19800
|
+
- **Same origin.** `goto` takes an app path only; anything else is refused and reported to the model.
|
|
19801
|
+
- **`extract`** validates the answer with your Standard Schema (`EXTRACT_INVALID` on a mismatch).
|
|
19802
|
+
- **`waitFor`** asks the model again only when the page outline changed.
|
|
19803
|
+
|
|
19804
|
+
## Replay cache
|
|
19805
|
+
|
|
19806
|
+
The first run of an `act` asks the model; the next runs replay what it did, with no model call.
|
|
19807
|
+
|
|
19808
|
+
```ts
|
|
19809
|
+
await using t = await e2e(app, { model, cache: { testId: "member upgrades to Pro" } })
|
|
19810
|
+
await t.open("/settings/billing")
|
|
19811
|
+
await t.agent.act("upgrade the workspace to the {plan} plan", { params: { plan: "Pro" } })
|
|
19812
|
+
await expect(t.screen.getByRole("status")).toHaveText("Pro") // a later check that passes saves the recording
|
|
19813
|
+
console.log(formatReport(t.agent.report())) // Cache: 1 replayed - 0 handed off - 0 missed (0 model calls)
|
|
19814
|
+
```
|
|
19815
|
+
|
|
19816
|
+
- **Written only after a later check passes.** A locator `expect` or `agent.assert`/`waitFor` that passes
|
|
19817
|
+
saves what the `act`s before it recorded. One that fails deletes them. A test that ends with no check
|
|
19818
|
+
records nothing.
|
|
19819
|
+
- **Replay** needs the same start route, finds each control by the role, name, label, text or test id
|
|
19820
|
+
it had, and requires it to match exactly as often as it did. It never taps a near miss. It then checks
|
|
19821
|
+
the end route and the controls and headings that appeared or went away.
|
|
19822
|
+
- **Hand-off.** When a replay stops (`target-not-found`, `ambiguous`, `end-mismatch`, `action-uncertain`,
|
|
19823
|
+
`route-mismatch`) the actions it already did stay done, and the model finishes the goal from the current
|
|
19824
|
+
page. `ActRequest.handoff` carries the reason and how many actions to leave alone. A passing check
|
|
19825
|
+
re-records the repaired steps. If the goal then fails, the recording is deleted.
|
|
19826
|
+
- **Modes** (`cache.mode`): `read-write` (default; `read-only` when `CI` is set), `read-only` (replays and
|
|
19827
|
+
hands off, never writes or deletes), `strict` (replay only: a stale recording is `REPLAY_STALE`, a
|
|
19828
|
+
missing one `REPLAY_MISSING`), `off`.
|
|
19829
|
+
- **The key** is the test (`cache.testId`: pass it), the goal text, the params, `agentContext`, and
|
|
19830
|
+
`cache.appIdentity`. Wrap run-varying data in `unique(value)` so a new value does not miss; it is
|
|
19831
|
+
typed again on replay. A `Secret` is stored by name only, never by value.
|
|
19832
|
+
- **Where.** `.nifra/e2e-cache/<hash>.json` under the working directory (`cache.dir`), small and meant to
|
|
19833
|
+
be committed. `cache.store` swaps in your own store; `memoryCacheStore()` is one for tests. A store
|
|
19834
|
+
that refuses a write is counted in the cache, not thrown. `cache: false` turns the whole thing off.
|
|
19835
|
+
- Replay needs no model: in CI `model` can be left out and a stale recording then fails with
|
|
19836
|
+
`MODEL_MISSING`. `assert`, `waitFor` and `extract` always ask the model.
|
|
19837
|
+
|
|
19838
|
+
## Engines
|
|
19839
|
+
|
|
19840
|
+
`e2e()` uses the Playwright engine by default; install `playwright` yourself (optional peer). The engine
|
|
19841
|
+
is a six-method interface (`goto`, `url`, `resolve`, `act`, `snapshot`, `close`), so anything else can plug in with
|
|
19842
|
+
`e2e(app, { engine })`. `@nifrajs/e2e/fake` is an in-memory engine with the same locator semantics, for
|
|
19843
|
+
testing code built on this package without a browser.
|
|
19844
|
+
|
|
19845
|
+
## Not included yet
|
|
19846
|
+
|
|
19847
|
+
Token counts (the model port returns decisions, not usage) and a test runner. Use `bun:test` or Vitest.
|
|
19848
|
+
|
|
19849
|
+
## For AI agents
|
|
19850
|
+
|
|
19851
|
+
Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
|
|
19852
|
+
one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
19853
|
+
[`AGENTS.md`](../../AGENTS.md) is the copy-paste quick reference, and
|
|
19854
|
+
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
19855
|
+
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
19856
|
+
|
|
18685
19857
|
## @nifrajs/edge
|
|
18686
19858
|
|
|
18687
19859
|
Compact fetch-handler server for edge and serverless runtimes - Cloudflare Workers, Vercel Edge, Deno Deploy, Bun. Keeps the `server().get().post()` DX and the full request trust boundary (bounded body read, Content-Length pre-reject, prototype-pollution guard, JSON / urlencoded framing) in a fraction of the bundle. Zero runtime dependencies beyond `@nifrajs/core`.
|
|
@@ -19930,6 +21102,95 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
19930
21102
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
19931
21103
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
19932
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
|
+
|
|
19933
21194
|
## @nifrajs/otel
|
|
19934
21195
|
|
|
19935
21196
|
Distributed tracing for nifra. The `tracing()` plugin continues (or starts) a **W3C trace** per
|
|
@@ -20923,6 +22184,16 @@ one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
|
20923
22184
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
|
20924
22185
|
done-gate, or `nifra mcp` to give the agent live project tools.
|
|
20925
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
|
+
|
|
20926
22197
|
## @nifrajs/web
|
|
20927
22198
|
|
|
20928
22199
|
Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.
|
|
@@ -20943,12 +22214,13 @@ One package, the same on React, Preact, Vue, Solid and Svelte (pick the renderer
|
|
|
20943
22214
|
- [Keep-alive](https://nifra.dev/docs/keep-alive) pages, a query cache, optimistic fetchers, and
|
|
20944
22215
|
[islands](https://nifra.dev/docs/islands) (`@nifrajs/web/islands`) for pages with no framework runtime.
|
|
20945
22216
|
- Optional [server components](https://nifra.dev/docs/server-components) on all five adapters:
|
|
20946
|
-
React uses native RSC/Flight,
|
|
20947
|
-
|
|
20948
|
-
|
|
20949
|
-
|
|
20950
|
-
|
|
20951
|
-
|
|
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.
|
|
20952
22224
|
|
|
20953
22225
|
## Guarding pages
|
|
20954
22226
|
|
|
@@ -21107,7 +22379,7 @@ To refresh one region from a link or GET form without a full reload, render it w
|
|
|
21107
22379
|
|
|
21108
22380
|
- In text and in a quoted attribute value, it is HTML-escaped.
|
|
21109
22381
|
- An unquoted attribute value (`class=${name}`) is quoted for you, so a space in the value cannot start another attribute.
|
|
21110
|
-
- 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.
|
|
21111
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.
|
|
21112
22384
|
|
|
21113
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.
|
|
@@ -21492,10 +22764,18 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
21492
22764
|
|
|
21493
22765
|
`DenoServer`, `DenoStopOptions`, `FetchHandler`, `HashedFiles`, `ServeOptions`, `ServeStaticOptions`, `serve`, `serveStatic`
|
|
21494
22766
|
|
|
22767
|
+
## @nifrajs/deploy-fly
|
|
22768
|
+
|
|
22769
|
+
`FlyOptions`, `flyAdapter`
|
|
22770
|
+
|
|
21495
22771
|
## @nifrajs/devtools
|
|
21496
22772
|
|
|
21497
22773
|
`DevToolsClientOptions`, `DevToolsEvent`, `DevToolsOptions`, `DevToolsQuery`, `devtools`, `devtoolsClientScript`, `filterDevToolsEvents`
|
|
21498
22774
|
|
|
22775
|
+
## @nifrajs/e2e
|
|
22776
|
+
|
|
22777
|
+
`ActDecision`, `ActOptions`, `ActRequest`, `ActResult`, `ActionRecord`, `Agent`, `AgentReport`, `CacheEntry`, `CacheMode`, `CacheOptions`, `CacheStore`, `Clock`, `E2EError`, `E2EErrorCode`, `E2EModel`, `E2EOptions`, `E2ESession`, `ElementAction`, `ElementState`, `Engine`, `EngineFactory`, `EngineInit`, `ExtractOptions`, `ExtractRequest`, `HandOff`, `HydrationMode`, `JudgeRequest`, `Locator`, `LocatorContext`, `LocatorMatchers`, `MatcherOptions`, `ModelRequest`, `OpenArgs`, `OpenOptions`, `Param`, `Params`, `PathParams`, `PerformedDecision`, `RecordedAction`, `RoleOptions`, `Screen`, `Secret`, `Selector`, `Step`, `StepOptions`, `StopReason`, `Target`, `TextOptions`, `Unique`, `UrlMatchers`, `UrlSource`, `Verdict`, `WaitForOptions`, `e2e`, `expect`, `fileCacheStore`, `formatReport`, `memoryCacheStore`, `unique`
|
|
22778
|
+
|
|
21499
22779
|
## @nifrajs/edge
|
|
21500
22780
|
|
|
21501
22781
|
`EdgeContext`, `EdgeHandler`, `EdgeNotFound`, `EdgeOptions`, `EdgeServer`, `Method`, `NotFoundHandler`, `NotFoundInput`, `Params`, `QueryValue`, `StandardSchemaV1`, `notFound`, `server`, `toFetchHandler`
|
|
@@ -21548,6 +22828,10 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
21548
22828
|
|
|
21549
22829
|
`FetchHandler`, `HashedFiles`, `NodeServer`, `NodeStopOptions`, `RequestProtocol`, `RequestProtocolOption`, `ServeOptions`, `ServeStaticOptions`, `serve`, `serveStatic`
|
|
21550
22830
|
|
|
22831
|
+
## @nifrajs/node-uws
|
|
22832
|
+
|
|
22833
|
+
`FetchHandler`, `NodeStopOptions`, `ServeOptions`, `UwsServer`, `UwsTlsOptions`, `serve`
|
|
22834
|
+
|
|
21551
22835
|
## @nifrajs/otel
|
|
21552
22836
|
|
|
21553
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`
|
|
@@ -21588,6 +22872,10 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
21588
22872
|
|
|
21589
22873
|
`ImagePixelLimitError`, `ImageReencoder`, `SignDownloadUrlOptions`, `StripImageMetadataOptions`, `UploadResult`, `ValidateUploadOptions`, `signDownloadUrl`, `stripImageMetadata`, `validateUpload`, `verifyDownloadUrl`
|
|
21590
22874
|
|
|
22875
|
+
## @nifrajs/utils
|
|
22876
|
+
|
|
22877
|
+
`bytesToHex`, `concatBytes`, `escapeRegExp`, `isRecord`, `sha256Hex`
|
|
22878
|
+
|
|
21591
22879
|
## @nifrajs/web
|
|
21592
22880
|
|
|
21593
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`
|