@nifrajs/cli 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/dist/app-files.d.ts +11 -0
- package/dist/app-files.d.ts.map +1 -0
- package/dist/app-files.js +34 -0
- package/dist/app-files.js.map +1 -0
- package/dist/assure-hydration.d.ts +7 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +128 -43
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +16 -2
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts +5 -1
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +32 -10
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/cdn-check.d.ts +41 -0
- package/dist/cdn-check.d.ts.map +1 -0
- package/dist/cdn-check.js +207 -0
- package/dist/cdn-check.js.map +1 -0
- package/dist/check-diagnostics.d.ts +7 -15
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +162 -713
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +58 -7
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +323 -62
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +1 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +145 -54
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +42 -16
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +306 -87
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +60 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +298 -33
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.d.ts +8 -0
- package/dist/config-target.d.ts.map +1 -0
- package/dist/config-target.js +45 -0
- package/dist/config-target.js.map +1 -0
- package/dist/contracts.d.ts +3 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +56 -16
- package/dist/contracts.js.map +1 -1
- package/dist/db-audit.d.ts +37 -0
- package/dist/db-audit.d.ts.map +1 -0
- package/dist/db-audit.js +99 -0
- package/dist/db-audit.js.map +1 -0
- package/dist/db-child.d.ts +64 -0
- package/dist/db-child.d.ts.map +1 -0
- package/dist/db-child.js +213 -0
- package/dist/db-child.js.map +1 -0
- package/dist/db-config.d.ts +60 -0
- package/dist/db-config.d.ts.map +1 -0
- package/dist/db-config.js +176 -0
- package/dist/db-config.js.map +1 -0
- package/dist/db-tool.d.ts +84 -0
- package/dist/db-tool.d.ts.map +1 -0
- package/dist/db-tool.js +537 -0
- package/dist/db-tool.js.map +1 -0
- package/dist/dev-bun-config.d.ts +20 -13
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +98 -41
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.d.ts +106 -0
- package/dist/dev-feed-tool.d.ts.map +1 -0
- package/dist/dev-feed-tool.js +713 -0
- package/dist/dev-feed-tool.js.map +1 -0
- package/dist/dev-server-client.d.ts +67 -0
- package/dist/dev-server-client.d.ts.map +1 -0
- package/dist/dev-server-client.js +195 -0
- package/dist/dev-server-client.js.map +1 -0
- package/dist/diagnostics.d.ts +86 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +85 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/diff-tool.d.ts +3 -3
- package/dist/diff-tool.d.ts.map +1 -1
- package/dist/diff-tool.js +6 -5
- package/dist/diff-tool.js.map +1 -1
- package/dist/docs-search.d.ts.map +1 -1
- package/dist/docs-search.js +12 -4
- package/dist/docs-search.js.map +1 -1
- package/dist/doctor.d.ts +17 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +76 -15
- package/dist/doctor.js.map +1 -1
- package/dist/env-file.d.ts +15 -0
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +73 -1
- package/dist/env-file.js.map +1 -1
- package/dist/fix-recipes.d.ts.map +1 -1
- package/dist/fix-recipes.js +41 -21
- package/dist/fix-recipes.js.map +1 -1
- package/dist/frontend-guidance.js +5 -5
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/i18n-check.d.ts +16 -0
- package/dist/i18n-check.d.ts.map +1 -0
- package/dist/i18n-check.js +154 -0
- package/dist/i18n-check.js.map +1 -0
- package/dist/init-agents.d.ts +49 -13
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +239 -34
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/code-unit-order.d.ts +4 -0
- package/dist/internal/code-unit-order.d.ts.map +1 -0
- package/dist/internal/code-unit-order.js +6 -0
- package/dist/internal/code-unit-order.js.map +1 -0
- package/dist/internal/script-kind.d.ts +7 -0
- package/dist/internal/script-kind.d.ts.map +1 -0
- package/dist/internal/script-kind.js +12 -0
- package/dist/internal/script-kind.js.map +1 -0
- package/dist/internal/source-facts.d.ts +5 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +61 -5
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.d.ts +49 -24
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +507 -67
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/introspect.d.ts +6 -4
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +93 -74
- package/dist/introspect.js.map +1 -1
- package/dist/learn.js +3 -3
- package/dist/learn.js.map +1 -1
- package/dist/levels-tool.d.ts +10 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +33 -3
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +71 -16
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +78 -18
- package/dist/load.js.map +1 -1
- package/dist/manifest-tool.d.ts.map +1 -1
- package/dist/manifest-tool.js +3 -2
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-app-tool.d.ts.map +1 -1
- package/dist/mcp-app-tool.js +2 -0
- package/dist/mcp-app-tool.js.map +1 -1
- package/dist/mcp-context.d.ts.map +1 -1
- package/dist/mcp-context.js +5 -6
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.d.ts +57 -0
- package/dist/mcp-delegate.d.ts.map +1 -0
- package/dist/mcp-delegate.js +130 -0
- package/dist/mcp-delegate.js.map +1 -0
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +23 -5
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-exec.d.ts +3 -0
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +263 -131
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +20 -5
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-io.d.ts +26 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +113 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts +48 -0
- package/dist/mcp-isolate.d.ts.map +1 -0
- package/dist/mcp-isolate.js +222 -0
- package/dist/mcp-isolate.js.map +1 -0
- package/dist/mcp-path.d.ts +10 -0
- package/dist/mcp-path.d.ts.map +1 -0
- package/dist/mcp-path.js +51 -0
- package/dist/mcp-path.js.map +1 -0
- package/dist/mcp-project-child.d.ts +74 -0
- package/dist/mcp-project-child.d.ts.map +1 -0
- package/dist/mcp-project-child.js +130 -0
- package/dist/mcp-project-child.js.map +1 -0
- package/dist/mcp-reflect.d.ts.map +1 -1
- package/dist/mcp-reflect.js +2 -2
- package/dist/mcp-reflect.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +64 -45
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.d.ts +37 -9
- package/dist/mcp-root.d.ts.map +1 -1
- package/dist/mcp-root.js +124 -25
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts +18 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +159 -55
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-ws.js +4 -1
- package/dist/mcp-ws.js.map +1 -1
- package/dist/mcp.d.ts +18 -5
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +165 -82
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.d.ts +44 -0
- package/dist/migrate-layout.d.ts.map +1 -0
- package/dist/migrate-layout.js +982 -0
- package/dist/migrate-layout.js.map +1 -0
- package/dist/openapi-tool.d.ts +2 -2
- package/dist/openapi-tool.d.ts.map +1 -1
- package/dist/openapi-tool.js.map +1 -1
- package/dist/openapi-types.d.ts +2 -1
- package/dist/openapi-types.d.ts.map +1 -1
- package/dist/openapi-types.js +240 -12
- package/dist/openapi-types.js.map +1 -1
- package/dist/pipeline-report.d.ts +3 -2
- package/dist/pipeline-report.d.ts.map +1 -1
- package/dist/pipeline-report.js +19 -16
- package/dist/pipeline-report.js.map +1 -1
- package/dist/port.d.ts +5 -4
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +46 -29
- package/dist/port.js.map +1 -1
- package/dist/project-facts.d.ts +28 -4
- package/dist/project-facts.d.ts.map +1 -1
- package/dist/project-facts.js +12 -2
- package/dist/project-facts.js.map +1 -1
- package/dist/recipes/4.0.0.d.ts +9 -0
- package/dist/recipes/4.0.0.d.ts.map +1 -0
- package/dist/recipes/4.0.0.js +34 -0
- package/dist/recipes/4.0.0.js.map +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.d.ts +11 -1
- package/dist/release-verification.d.ts.map +1 -1
- package/dist/release-verification.js +47 -4
- package/dist/release-verification.js.map +1 -1
- package/dist/review.d.ts +21 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +823 -0
- package/dist/review.js.map +1 -0
- package/dist/route-types.d.ts +28 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +106 -0
- package/dist/route-types.js.map +1 -0
- package/dist/rules/codes.d.ts +9 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +9 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/data-guard.d.ts +12 -0
- package/dist/rules/data-guard.d.ts.map +1 -0
- package/dist/rules/data-guard.js +213 -0
- package/dist/rules/data-guard.js.map +1 -0
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +17 -5
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/islands.d.ts.map +1 -1
- package/dist/rules/islands.js +7 -4
- package/dist/rules/islands.js.map +1 -1
- package/dist/rules/legacy.d.ts +3 -1
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +829 -34
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/nano.d.ts.map +1 -1
- package/dist/rules/nano.js +15 -6
- package/dist/rules/nano.js.map +1 -1
- package/dist/rules/pages.d.ts +15 -0
- package/dist/rules/pages.d.ts.map +1 -0
- package/dist/rules/pages.js +88 -0
- package/dist/rules/pages.js.map +1 -0
- package/dist/rules/routes.d.ts +11 -0
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +180 -2
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/secrets.d.ts +10 -0
- package/dist/rules/secrets.d.ts.map +1 -0
- package/dist/rules/secrets.js +169 -0
- package/dist/rules/secrets.js.map +1 -0
- package/dist/rules/security.d.ts +7 -0
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +171 -65
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/typescript.d.ts +16 -0
- package/dist/rules/typescript.d.ts.map +1 -0
- package/dist/rules/typescript.js +59 -0
- package/dist/rules/typescript.js.map +1 -0
- package/dist/rules/zones.d.ts +17 -0
- package/dist/rules/zones.d.ts.map +1 -0
- package/dist/rules/zones.js +174 -0
- package/dist/rules/zones.js.map +1 -0
- package/dist/scaffold.d.ts +25 -12
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +154 -90
- package/dist/scaffold.js.map +1 -1
- package/dist/sdk.d.ts +17 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +941 -153
- package/dist/sdk.js.map +1 -1
- package/dist/search-terms.d.ts +2 -0
- package/dist/search-terms.d.ts.map +1 -1
- package/dist/search-terms.js +23 -8
- package/dist/search-terms.js.map +1 -1
- package/dist/smoke.d.ts +79 -0
- package/dist/smoke.d.ts.map +1 -0
- package/dist/smoke.js +494 -0
- package/dist/smoke.js.map +1 -0
- package/dist/sync-manifest.d.ts.map +1 -1
- package/dist/sync-manifest.js +2 -1
- package/dist/sync-manifest.js.map +1 -1
- package/dist/sync-routes.d.ts +4 -3
- package/dist/sync-routes.d.ts.map +1 -1
- package/dist/sync-routes.js +4 -3
- package/dist/sync-routes.js.map +1 -1
- package/dist/test-tool.d.ts.map +1 -1
- package/dist/test-tool.js +30 -11
- package/dist/test-tool.js.map +1 -1
- package/dist/types-search.d.ts.map +1 -1
- package/dist/types-search.js +11 -5
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.d.ts +36 -6
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +167 -29
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +8 -0
- package/dist/verification-plan.js.map +1 -1
- package/dist/verification.d.ts.map +1 -1
- package/dist/verification.js +45 -12
- package/dist/verification.js.map +1 -1
- package/dist/web-app-options.d.ts +19 -0
- package/dist/web-app-options.d.ts.map +1 -0
- package/dist/web-app-options.js +49 -0
- package/dist/web-app-options.js.map +1 -0
- package/dist/work-graph.d.ts +3 -0
- package/dist/work-graph.d.ts.map +1 -1
- package/dist/work-graph.js +33 -16
- package/dist/work-graph.js.map +1 -1
- package/docs/examples.json +185 -29
- package/docs/llms-full.txt +4123 -548
- package/docs/types.json +14391 -10060
- package/package.json +19 -11
- package/src/app-files.ts +40 -0
- package/src/assure-hydration.ts +139 -46
- package/src/assure.ts +17 -2
- package/src/capabilities-tool.ts +35 -9
- package/src/cdn-check.ts +268 -0
- package/src/check-diagnostics.ts +199 -797
- package/src/check-scan.ts +394 -63
- package/src/check.ts +146 -58
- package/src/cli.ts +347 -92
- package/src/command-catalog.ts +407 -45
- package/src/config-target.ts +47 -0
- package/src/contracts.ts +66 -15
- package/src/db-audit.ts +128 -0
- package/src/db-child.ts +285 -0
- package/src/db-config.ts +224 -0
- package/src/db-tool.ts +690 -0
- package/src/dev-bun-config.ts +116 -40
- package/src/dev-feed-tool.ts +912 -0
- package/src/dev-server-client.ts +267 -0
- package/src/diagnostics.ts +179 -0
- package/src/diff-tool.ts +6 -5
- package/src/docs-search.ts +10 -3
- package/src/doctor.ts +98 -15
- package/src/env-file.ts +78 -1
- package/src/fix-recipes.ts +44 -31
- package/src/frontend-guidance.ts +5 -5
- package/src/i18n-check.ts +179 -0
- package/src/init-agents.ts +301 -38
- package/src/internal/code-unit-order.ts +5 -0
- package/src/internal/script-kind.ts +11 -0
- package/src/internal/source-facts.ts +96 -22
- package/src/internal/typescript-import.ts +663 -68
- package/src/introspect.ts +93 -82
- package/src/learn.ts +3 -3
- package/src/levels-tool.ts +47 -2
- package/src/load.ts +144 -32
- package/src/manifest-tool.ts +3 -2
- package/src/mcp-app-tool.ts +2 -0
- package/src/mcp-context.ts +5 -7
- package/src/mcp-delegate.ts +162 -0
- package/src/mcp-docs-tools.ts +23 -5
- package/src/mcp-exec.ts +301 -161
- package/src/mcp-http.ts +22 -5
- package/src/mcp-io.ts +130 -0
- package/src/mcp-isolate.ts +287 -0
- package/src/mcp-path.ts +50 -0
- package/src/mcp-project-child.ts +182 -0
- package/src/mcp-reflect.ts +3 -2
- package/src/mcp-render.ts +72 -42
- package/src/mcp-root.ts +130 -24
- package/src/mcp-run.ts +190 -56
- package/src/mcp-ws.ts +4 -1
- package/src/mcp.ts +193 -91
- package/src/migrate-layout.ts +1121 -0
- package/src/openapi-tool.ts +7 -3
- package/src/openapi-types.ts +315 -13
- package/src/pipeline-report.ts +22 -18
- package/src/port.ts +53 -30
- package/src/project-facts.ts +42 -8
- package/src/recipes/4.0.0.ts +35 -0
- package/src/recipes/index.ts +2 -0
- package/src/release-verification.ts +74 -5
- package/src/review.ts +988 -0
- package/src/route-types.ts +133 -0
- package/src/rules/codes.ts +9 -0
- package/src/rules/data-guard.ts +230 -0
- package/src/rules/index.ts +18 -5
- package/src/rules/islands.ts +12 -4
- package/src/rules/legacy.ts +947 -35
- package/src/rules/nano.ts +18 -6
- package/src/rules/pages.ts +99 -0
- package/src/rules/routes.ts +181 -2
- package/src/rules/secrets.ts +174 -0
- package/src/rules/security.ts +198 -70
- package/src/rules/typescript.ts +77 -0
- package/src/rules/zones.ts +195 -0
- package/src/scaffold.ts +175 -98
- package/src/sdk.ts +1215 -158
- package/src/search-terms.ts +24 -7
- package/src/smoke.ts +607 -0
- package/src/sync-manifest.ts +2 -1
- package/src/sync-routes.ts +4 -3
- package/src/test-tool.ts +32 -11
- package/src/types-search.ts +11 -4
- package/src/upgrade.ts +205 -25
- package/src/verification-plan.ts +27 -0
- package/src/verification.ts +50 -12
- package/src/web-app-options.ts +57 -0
- package/src/work-graph.ts +40 -16
package/dist/scaffold.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `nifra_scaffold` - turn a URL path into the correct `routes/`
|
|
3
|
-
* gets wrong) + a minimal, contract-correct
|
|
4
|
-
*
|
|
5
|
-
* `/` → `
|
|
2
|
+
* `nifra_scaffold` - turn a URL path into the correct `routes/` files (the convention an agent most often
|
|
3
|
+
* gets wrong) + a minimal, contract-correct route pair: the page, and its `.backend.ts` half holding the
|
|
4
|
+
* loader and its output schema. The mapping is the inverse of @nifrajs/web's `filePathToPatterns`:
|
|
5
|
+
* `:id`/`[id]` → `[id]`, `*rest`/`[...rest]` → `[...rest]`, `[[lang]]` optional, `/` → `index`. The
|
|
6
|
+
* framework (→ file extension) comes from the project's `clientModule`.
|
|
6
7
|
*
|
|
7
8
|
* Page stubs are emitted for the JSX family (react/preact/solid - one shared, verified shape) and
|
|
8
9
|
* for vanilla (a zero-runtime `html` page carrying the golden island pattern); for vue/svelte we
|
|
9
|
-
* return the correct
|
|
10
|
-
* rather than hand-writing an SFC we can't typecheck here.
|
|
10
|
+
* return the correct PATHS, the backend half and the route contract, and point at `nifra_example` for
|
|
11
|
+
* the page body, rather than hand-writing an SFC we can't typecheck here.
|
|
11
12
|
*/
|
|
12
13
|
import { lstat, mkdir, realpath, writeFile } from "node:fs/promises";
|
|
13
|
-
import { dirname, resolve, sep } from "node:path";
|
|
14
|
+
import { basename, dirname, resolve, sep } from "node:path";
|
|
15
|
+
import { paramConstraint } from "@nifrajs/core/pattern";
|
|
14
16
|
const EXT = {
|
|
15
17
|
react: "tsx",
|
|
16
18
|
preact: "tsx",
|
|
@@ -35,12 +37,34 @@ function segmentToFile(seg) {
|
|
|
35
37
|
return `[${seg.slice(1)}]`; // :id → [id]
|
|
36
38
|
return seg;
|
|
37
39
|
}
|
|
40
|
+
/** Reject syntax that could be interpreted by the host filesystem rather than the route mapper. */
|
|
41
|
+
function assertSafeRouteSegment(segment, urlPath) {
|
|
42
|
+
if (segment === "." || segment === ".." || segment.includes("\0") || segment.includes("\\")) {
|
|
43
|
+
throw new Error(`invalid route segment in ${JSON.stringify(urlPath)}: ${JSON.stringify(segment)}`);
|
|
44
|
+
}
|
|
45
|
+
const brace = segment.indexOf("{");
|
|
46
|
+
if (segment.startsWith(":") && brace > 0 && paramConstraint(segment.slice(brace)) !== undefined) {
|
|
47
|
+
throw new Error(`a param constraint cannot be written in a route file name: ${JSON.stringify(segment)} in ${JSON.stringify(urlPath)}. Scaffold the page without it and check the value in the route's loader.`);
|
|
48
|
+
}
|
|
49
|
+
const fileSegment = segmentToFile(segment);
|
|
50
|
+
if (fileSegment === "." ||
|
|
51
|
+
fileSegment === ".." ||
|
|
52
|
+
fileSegment.includes("\0") ||
|
|
53
|
+
fileSegment.includes("/") ||
|
|
54
|
+
fileSegment.includes("\\") ||
|
|
55
|
+
fileSegment.includes(":") ||
|
|
56
|
+
/^[A-Za-z]:/.test(fileSegment)) {
|
|
57
|
+
throw new Error(`invalid route segment in ${JSON.stringify(urlPath)}: ${JSON.stringify(segment)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
38
60
|
/** Map a URL path to its `routes/` file path (relative to `routes/`, without extension prefix dir).
|
|
39
61
|
* `/` → `index`; `/users/:id` → `users/[id]`; `/blog/*slug` → `blog/[...slug]`. */
|
|
40
62
|
export function routePathToFile(urlPath, ext) {
|
|
41
63
|
const segments = urlPath.split("/").filter((s) => s.length > 0);
|
|
42
64
|
if (segments.length === 0)
|
|
43
65
|
return `routes/index.${ext}`;
|
|
66
|
+
for (const segment of segments)
|
|
67
|
+
assertSafeRouteSegment(segment, urlPath);
|
|
44
68
|
const last = segments.length - 1;
|
|
45
69
|
// Catch-all must be the final segment (mirrors @nifrajs/web); flag it rather than emit an invalid file.
|
|
46
70
|
for (let i = 0; i < last; i++) {
|
|
@@ -49,22 +73,58 @@ export function routePathToFile(urlPath, ext) {
|
|
|
49
73
|
}
|
|
50
74
|
return `routes/${segments.map(segmentToFile).join("/")}.${ext}`;
|
|
51
75
|
}
|
|
52
|
-
const ROUTE_CONTRACT = `A route
|
|
53
|
-
- \`export default function Page(
|
|
54
|
-
- \`export async function loader({ params,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export
|
|
67
|
-
|
|
76
|
+
const ROUTE_CONTRACT = `A route is two files:
|
|
77
|
+
- The page, \`routes/x.<ext>\` - ships to the browser: \`export default function Page({ data }: Route.ComponentProps)\` and \`export const meta = { title, meta: […] }\`. It never imports backend code.
|
|
78
|
+
- Its backend half, \`routes/x.backend.ts\` - never reaches the browser: \`export const loaderOutput = t.object({…})\` with \`export async function loader({ params, api }: Route.LoaderArgs)\` (data for SSR - only what the schema declares is sent), \`actionOutput\` with \`action\` (the form POST), and \`hydrate\`, \`islandScripts\`, \`revalidate\`, \`middleware\`. Reach the backend through the typed \`api\`.
|
|
79
|
+
Both import \`type { Route } from "./+types/<name>"\`, which \`nifra dev\`, \`nifra build\`, \`nifra check\` and \`nifra types\` generate. Path params are typed on \`params\`.`;
|
|
80
|
+
/** Param names a route file declares, for the stubs. */
|
|
81
|
+
function paramsOf(file) {
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const m of file.matchAll(/(\[)?\[(?:\.\.\.)?([A-Za-z_][A-Za-z0-9_]*)\]/g))
|
|
84
|
+
out.push({ name: m[2], optional: m[1] !== undefined });
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/** `./+types/<name>` for a route file: the generated module both halves import `Route` from. */
|
|
88
|
+
const typesOf = (file) => `./+types/${basename(file).replace(/\.[^.]+$/, "")}`;
|
|
89
|
+
/** `routes/users/[id].tsx` → `routes/users/[id].backend.ts`. */
|
|
90
|
+
export const backendFileOf = (file) => file.replace(/\.[^./]+$/, ".backend.ts");
|
|
91
|
+
/** The page's backend half: its loader, and the schema that bounds what the loader sends. */
|
|
92
|
+
function backendStub(file, params, vanilla) {
|
|
93
|
+
const last = params.at(-1);
|
|
94
|
+
const loader = last === undefined
|
|
95
|
+
? `export async function loader(_args: Route.LoaderArgs) {
|
|
96
|
+
// Load through the typed backend client, \`api\` in these args; see nifra_example("loader").
|
|
97
|
+
return { title: "TODO" }
|
|
98
|
+
}`
|
|
99
|
+
: `export async function loader({ params }: Route.LoaderArgs) {
|
|
100
|
+
// Load by params.${last.name} through the typed backend client, \`api\` in these args; see nifra_example("loader").
|
|
101
|
+
return { title: \`TODO: \${params.${last.name}${last.optional ? ' ?? ""' : ""}}\` }
|
|
102
|
+
}`;
|
|
103
|
+
const vanillaExports = vanilla
|
|
104
|
+
? `
|
|
105
|
+
|
|
106
|
+
// No client framework to hydrate with - vanilla routes are documents, not hydrated apps.
|
|
107
|
+
export const hydrate = false
|
|
108
|
+
|
|
109
|
+
// The built URL of each island enhancer this page renders a marker for (./<name>.client.ts).
|
|
110
|
+
// export const islandScripts = []`
|
|
111
|
+
: "";
|
|
112
|
+
return `// ${backendFileOf(file)} - the server half of ${file}; it never reaches the browser.
|
|
113
|
+
import { t } from "@nifrajs/schema"
|
|
114
|
+
import type { Route } from "${typesOf(file)}"
|
|
115
|
+
|
|
116
|
+
// Only what this schema declares is sent to the page.
|
|
117
|
+
export const loaderOutput = t.object({ title: t.string() })
|
|
118
|
+
|
|
119
|
+
${loader}${vanillaExports}
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
function jsxStub(file) {
|
|
123
|
+
return `// ${file} - the page; it ships to the browser. Its data comes from ${basename(backendFileOf(file))}.
|
|
124
|
+
import type { Route } from "${typesOf(file)}"
|
|
125
|
+
|
|
126
|
+
export default function Page({ data }: Route.ComponentProps) {
|
|
127
|
+
return <main>{data.title}</main>
|
|
68
128
|
}
|
|
69
129
|
`;
|
|
70
130
|
}
|
|
@@ -75,27 +135,20 @@ export default function Page() {
|
|
|
75
135
|
* returns its cleanup (the one thing NF-C020 checks), wired through `mountIslands`. Interactivity is
|
|
76
136
|
* added by uncommenting and writing the companion `<name>.client.ts`, never by turning on hydration.
|
|
77
137
|
*/
|
|
78
|
-
function vanillaStub(file
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
? `// export async function loader({ params, api }: LoaderArgs<typeof backend>) { return { /* fetch by ${params[0]} */ } }`
|
|
82
|
-
: `// export async function loader({ api }: LoaderArgs<typeof backend>) { return {} }`;
|
|
83
|
-
return `// ${file} - @nifrajs/web-vanilla route. Server-rendered HTML, ZERO framework runtime.
|
|
84
|
-
// Available here: ${paramsNote}. Fetch data in a loader via the typed \`api\`; see nifra_example("loader").
|
|
138
|
+
function vanillaStub(file) {
|
|
139
|
+
return `// ${file} - @nifrajs/web-vanilla page. Server-rendered HTML, ZERO framework runtime; its data,
|
|
140
|
+
// and \`hydrate = false\`, live in ${basename(backendFileOf(file))}.
|
|
85
141
|
import { html } from "@nifrajs/web-vanilla"
|
|
142
|
+
import type { Route } from "${typesOf(file)}"
|
|
86
143
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
${loaderLine}
|
|
91
|
-
|
|
92
|
-
export default function Page() {
|
|
93
|
-
return html\`<main><h1>TODO: ${file}</h1></main>\`
|
|
144
|
+
export default function Page({ data }: Route.ComponentProps) {
|
|
145
|
+
return html\`<main><h1>\${data.title}</h1></main>\`
|
|
94
146
|
}
|
|
95
147
|
|
|
96
148
|
// --- Add interactivity the AI-safe way (islands), NOT hydration ---------------------------------
|
|
97
149
|
// 1. Render a marker in the page above: html\`<nifra-island data-id="counter" data-props=\${JSON.stringify({ start: 0 })}></nifra-island>\`
|
|
98
|
-
// 2. Wire the route to its enhancer bundle
|
|
150
|
+
// 2. Wire the route to its enhancer bundle, in ${basename(backendFileOf(file))}:
|
|
151
|
+
// export const islandScripts = [/* built URL of ./counter.client.ts */]
|
|
99
152
|
// 3. Write ./counter.client.ts as an imperative enhancer that ALWAYS returns its cleanup:
|
|
100
153
|
//
|
|
101
154
|
// import { defineIsland, mountIslands } from "@nifrajs/web/islands"
|
|
@@ -123,31 +176,21 @@ export default function Page() {
|
|
|
123
176
|
* The page body is a valid, typecheckable static document; interactivity is added by writing the
|
|
124
177
|
* companion client shown, never by turning on hydration.
|
|
125
178
|
*/
|
|
126
|
-
function nanoStub(file
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
: `// export async function loader({ api }: LoaderArgs<typeof backend>) { return {} }`;
|
|
131
|
-
return `// ${file} - @nifrajs/web-vanilla route + a nano island (explicit reactivity, zero VDOM).
|
|
132
|
-
// Available here: ${paramsNote}. Seed data in a loader via the typed \`api\`; see nifra_example("loader").
|
|
179
|
+
function nanoStub(file) {
|
|
180
|
+
return `// ${file} - @nifrajs/web-vanilla page + a nano island (explicit reactivity, zero VDOM). The
|
|
181
|
+
// document is static and the nano client below owns all interactivity; \`hydrate = false\` and the
|
|
182
|
+
// island's \`islandScripts\` URL live in ${basename(backendFileOf(file))}.
|
|
133
183
|
import { html } from "@nifrajs/web-vanilla"
|
|
184
|
+
import type { Route } from "${typesOf(file)}"
|
|
134
185
|
|
|
135
|
-
|
|
136
|
-
export const hydrate = false
|
|
137
|
-
|
|
138
|
-
${loaderLine}
|
|
139
|
-
|
|
140
|
-
export default function Page() {
|
|
186
|
+
export default function Page({ data }: Route.ComponentProps) {
|
|
141
187
|
// The island marker: data-props is the initial state the client reads on mount.
|
|
142
188
|
return html\`<main>
|
|
143
|
-
<h1
|
|
189
|
+
<h1>\${data.title}</h1>
|
|
144
190
|
<nifra-island data-id="todos" data-props=\${JSON.stringify({ items: [] })}></nifra-island>
|
|
145
191
|
</main>\`
|
|
146
192
|
}
|
|
147
193
|
|
|
148
|
-
// Wire the route to the built URL of ./todos.client.ts (the nano enhancer below).
|
|
149
|
-
// export const islandScripts = [/* built URL of ./todos.client.ts */]
|
|
150
|
-
|
|
151
194
|
// --- ./todos.client.ts - the golden nano pattern (write this as a companion file) -----------------
|
|
152
195
|
//
|
|
153
196
|
// import { defineIsland, mountIslands } from "@nifrajs/web/islands"
|
|
@@ -190,52 +233,55 @@ export default function Page() {
|
|
|
190
233
|
// has the full cookbook; \`nifra check\` runs NF-C021/C022/C023 over the client you write.
|
|
191
234
|
`;
|
|
192
235
|
}
|
|
193
|
-
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
for (const m of file.matchAll(/\[(?:\.\.\.)?([A-Za-z_][A-Za-z0-9_]*)\]/g))
|
|
197
|
-
out.push(m[1]);
|
|
198
|
-
return out;
|
|
199
|
-
}
|
|
200
|
-
/** Scaffold a page route for `urlPath` under the project's `framework`. Returns the correct file path
|
|
201
|
-
* always; a ready-to-write stub for the JSX family, contract guidance otherwise. */
|
|
236
|
+
/** Scaffold a page route for `urlPath` under the project's `framework`. Returns the correct file paths
|
|
237
|
+
* and the backend half always; a ready-to-write page stub for the JSX family and vanilla, contract
|
|
238
|
+
* guidance otherwise. */
|
|
202
239
|
export function scaffoldRoute(urlPath, framework, variant = "default") {
|
|
203
240
|
const ext = EXT[framework];
|
|
204
241
|
const file = routePathToFile(urlPath, ext);
|
|
205
242
|
const params = paramsOf(file);
|
|
243
|
+
const backend = {
|
|
244
|
+
file: backendFileOf(file),
|
|
245
|
+
content: backendStub(file, params, framework === "vanilla"),
|
|
246
|
+
};
|
|
206
247
|
// `stateful` is vanilla-only: it swaps the static island stub for the nano golden pattern. Asking
|
|
207
248
|
// for it on a JSX/SFC framework is a no-op on the flavour (those lanes have their own reactivity).
|
|
208
249
|
if (framework === "vanilla" && variant === "stateful") {
|
|
209
250
|
return {
|
|
210
251
|
file,
|
|
211
|
-
content: nanoStub(file
|
|
212
|
-
|
|
252
|
+
content: nanoStub(file),
|
|
253
|
+
backend,
|
|
254
|
+
note: `Create ${file} and ${backend.file} as a zero-runtime @nifrajs/web-vanilla route with a nano island. ${ROUTE_CONTRACT}\nThe stub embeds the golden nano client (signal + computed(fn,[deps]) + keyed bindList + collected cleanups); write it as the companion .client.ts. \`nifra check\` runs NF-C021/C022/C023 over it; nifra_docs("nano") is the full cookbook.`,
|
|
213
255
|
};
|
|
214
256
|
}
|
|
215
257
|
if (framework === "react" || framework === "preact" || framework === "solid") {
|
|
216
258
|
return {
|
|
217
259
|
file,
|
|
218
|
-
content: jsxStub(file
|
|
219
|
-
|
|
260
|
+
content: jsxStub(file),
|
|
261
|
+
backend,
|
|
262
|
+
note: `Create ${file} and ${backend.file}. ${ROUTE_CONTRACT}\nIf the rendered page misbehaves (hydration warning, a value that stops updating), call nifra_frontend { adapter: "${framework}" } for the cause + fix.`,
|
|
220
263
|
};
|
|
221
264
|
}
|
|
222
265
|
if (framework === "vanilla") {
|
|
223
266
|
return {
|
|
224
267
|
file,
|
|
225
|
-
content: vanillaStub(file
|
|
226
|
-
|
|
268
|
+
content: vanillaStub(file),
|
|
269
|
+
backend,
|
|
270
|
+
note: `Create ${file} and ${backend.file} as a zero-runtime @nifrajs/web-vanilla route. ${ROUTE_CONTRACT}\nInteractivity comes from islands (imperative enhancers), never hydration - the stub embeds the golden pattern; nifra_example("islands") has the full cookbook. For explicit local state (a list a human edits), scaffold with variant "stateful" to get the nano pattern instead.`,
|
|
227
271
|
};
|
|
228
272
|
}
|
|
229
273
|
return {
|
|
230
274
|
file,
|
|
231
|
-
|
|
275
|
+
backend,
|
|
276
|
+
note: `Create ${file} as a ${framework} route module, and ${backend.file} from the stub below. ${ROUTE_CONTRACT}\nFor the ${framework} page body, call nifra_example (it ships verified ${framework} snippets) rather than guessing the SFC shape. If a value stops updating the template, call nifra_frontend { adapter: "${framework}" } for the ${framework} reactivity-loss fix.`,
|
|
232
277
|
};
|
|
233
278
|
}
|
|
234
|
-
function
|
|
279
|
+
function resolveInsideRoutes(cwd, relativeFile) {
|
|
235
280
|
const root = resolve(cwd);
|
|
281
|
+
const routesRoot = resolve(root, "routes");
|
|
236
282
|
const target = resolve(root, relativeFile);
|
|
237
|
-
if (target
|
|
238
|
-
throw new Error(`refusing to write outside
|
|
283
|
+
if (target === routesRoot || !target.startsWith(`${routesRoot}${sep}`)) {
|
|
284
|
+
throw new Error(`refusing to write outside routes directory: ${relativeFile}`);
|
|
239
285
|
}
|
|
240
286
|
return target;
|
|
241
287
|
}
|
|
@@ -270,9 +316,11 @@ async function assertNoSymlinkedAncestors(root, target) {
|
|
|
270
316
|
current = dirname(current);
|
|
271
317
|
}
|
|
272
318
|
}
|
|
273
|
-
/** Write a scaffolded route
|
|
274
|
-
* intentionally conservative: it refuses
|
|
275
|
-
* uses `wx`, so an agent
|
|
319
|
+
/** Write a scaffolded route pair when the framework has a verified ready-to-write page body. The write
|
|
320
|
+
* is intentionally conservative: it refuses frameworks where we only return contract guidance (a
|
|
321
|
+
* backend half alone is a build error), refuses when either file exists, and uses `wx`, so an agent
|
|
322
|
+
* cannot overwrite user work by accident. It then generates the route's `./+types` module, so both
|
|
323
|
+
* halves typecheck at once. */
|
|
276
324
|
export async function writeScaffoldRoute(cwd, urlPath, framework, variant = "default") {
|
|
277
325
|
const result = scaffoldRoute(urlPath, framework, variant);
|
|
278
326
|
if (result.content === undefined) {
|
|
@@ -282,22 +330,37 @@ export async function writeScaffoldRoute(cwd, urlPath, framework, variant = "def
|
|
|
282
330
|
reason: "no verified ready-to-write stub for this framework; use nifra_example for the body",
|
|
283
331
|
};
|
|
284
332
|
}
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
333
|
+
const files = [
|
|
334
|
+
{ file: result.file, content: result.content },
|
|
335
|
+
{ file: result.backend.file, content: result.backend.content },
|
|
336
|
+
];
|
|
337
|
+
const targets = files.map(({ file }) => resolveInsideRoutes(cwd, file));
|
|
338
|
+
for (const target of targets)
|
|
339
|
+
await assertNoSymlinkedAncestors(cwd, target);
|
|
340
|
+
for (const [i, target] of targets.entries()) {
|
|
341
|
+
if ((await lstat(target).catch(() => undefined)) !== undefined) {
|
|
342
|
+
return { ...result, written: false, reason: `file already exists: ${files[i]?.file}` };
|
|
343
|
+
}
|
|
291
344
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
345
|
+
await mkdir(dirname(targets[0]), { recursive: true });
|
|
346
|
+
for (const target of targets)
|
|
347
|
+
await assertNoSymlinkedAncestors(cwd, target);
|
|
348
|
+
for (const [i, target] of targets.entries()) {
|
|
349
|
+
try {
|
|
350
|
+
await writeFile(target, files[i]?.content ?? "", { flag: "wx" });
|
|
351
|
+
}
|
|
352
|
+
catch (err) {
|
|
353
|
+
if (err && typeof err === "object" && err.code === "EEXIST") {
|
|
354
|
+
return { ...result, written: false, reason: `file already exists: ${files[i]?.file}` };
|
|
355
|
+
}
|
|
356
|
+
throw err;
|
|
295
357
|
}
|
|
296
|
-
throw err;
|
|
297
358
|
}
|
|
359
|
+
const { refreshRouteTypes } = await import("./route-types.js");
|
|
360
|
+
refreshRouteTypes(cwd, () => { });
|
|
298
361
|
return { ...result, written: true };
|
|
299
362
|
}
|
|
300
|
-
/** Render the tool result as markdown - the file
|
|
363
|
+
/** Render the tool result as markdown - the file paths, the stubs (if any), and the contract note. */
|
|
301
364
|
export function renderScaffold(urlPath, framework, variant = "default") {
|
|
302
365
|
let r;
|
|
303
366
|
try {
|
|
@@ -306,7 +369,8 @@ export function renderScaffold(urlPath, framework, variant = "default") {
|
|
|
306
369
|
catch (err) {
|
|
307
370
|
return `Cannot scaffold ${JSON.stringify(urlPath)}: ${err instanceof Error ? err.message : String(err)}`;
|
|
308
371
|
}
|
|
309
|
-
const
|
|
310
|
-
|
|
372
|
+
const page = r.content ? `\n\n\`${r.file}\`:\n\n\`\`\`${EXT[framework]}\n${r.content}\`\`\`` : "";
|
|
373
|
+
const backend = `\n\n\`${r.backend.file}\`:\n\n\`\`\`ts\n${r.backend.content}\`\`\``;
|
|
374
|
+
return `# Scaffold route \`${urlPath}\` (${framework})\n\n**Files:** \`${r.file}\` + \`${r.backend.file}\`\n\n${r.note}${page}${backend}`;
|
|
311
375
|
}
|
|
312
376
|
//# sourceMappingURL=scaffold.js.map
|
package/dist/scaffold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE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sdk.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { type OpenAPIDocument } from "@nifrajs/schema/openapi";
|
|
2
2
|
export type SdkLanguage = "python" | "go";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export interface SdkRenderOptions {
|
|
4
|
+
/** Refuse operations whose request/response schema is opaque or unsupported. */
|
|
5
|
+
readonly strict?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SdkOpaqueIssue {
|
|
8
|
+
readonly operation: string;
|
|
9
|
+
readonly location: string;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class SdkGenerationError extends Error {
|
|
13
|
+
readonly issues: readonly SdkOpaqueIssue[];
|
|
14
|
+
constructor(issues: readonly SdkOpaqueIssue[]);
|
|
15
|
+
}
|
|
16
|
+
/** Render a generated SDK. Strict mode refuses opaque request/response portions. */
|
|
17
|
+
export declare function renderSdk(document: OpenAPIDocument, language: SdkLanguage, options?: SdkRenderOptions): string;
|
|
18
|
+
/** Load backend/app.ts, generate an SDK, and write it to the project. */
|
|
6
19
|
export declare function runSdk(cwd: string, options: {
|
|
7
20
|
readonly language: SdkLanguage;
|
|
8
21
|
readonly out?: string;
|
|
22
|
+
readonly strict?: boolean;
|
|
9
23
|
}): Promise<void>;
|
|
10
24
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAa,MAAM,yBAAyB,CAAA;AAIzE,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,IAAI,CAAA;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;gBAE9B,MAAM,EAAE,SAAS,cAAc,EAAE;CAY9C;AA4rCD,oFAAoF;AACpF,wBAAgB,SAAS,CACvB,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAER;AAwBD,yEAAyE;AACzE,wBAAsB,MAAM,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5F,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|