@analogjs/platform 3.0.0-alpha.7 → 3.0.0-alpha.70
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/migrations/migration.json +7 -1
- package/package.json +37 -23
- package/src/index.d.ts +11 -2
- package/src/index.js +12 -3
- package/src/index.js.map +1 -0
- package/src/lib/clear-client-page-endpoint.d.ts +1 -1
- package/src/lib/clear-client-page-endpoint.js +44 -32
- package/src/lib/clear-client-page-endpoint.js.map +1 -0
- package/src/lib/content/marked/index.d.ts +5 -5
- package/src/lib/content/marked/index.js +10 -6
- package/src/lib/content/marked/index.js.map +1 -0
- package/src/lib/content/marked/marked-content-highlighter.d.ts +2 -2
- package/src/lib/content/marked/marked-content-highlighter.js +6 -3
- package/src/lib/content/marked/marked-content-highlighter.js.map +1 -0
- package/src/lib/content/marked/marked-setup.service.d.ts +8 -8
- package/src/lib/content/marked/marked-setup.service.js +44 -54
- package/src/lib/content/marked/marked-setup.service.js.map +1 -0
- package/src/lib/content/prism/angular.js +18 -19
- package/src/lib/content/prism/angular.js.map +1 -0
- package/src/lib/content/prism/index.d.ts +1 -1
- package/src/lib/content/prism/index.js +10 -7
- package/src/lib/content/prism/index.js.map +1 -0
- package/src/lib/content/prism/options.d.ts +1 -1
- package/src/lib/content/prism/prism-highlighter.d.ts +5 -5
- package/src/lib/content/prism/prism-highlighter.js +33 -33
- package/src/lib/content/prism/prism-highlighter.js.map +1 -0
- package/src/lib/content/shiki/index.d.ts +3 -3
- package/src/lib/content/shiki/index.js +22 -28
- package/src/lib/content/shiki/index.js.map +1 -0
- package/src/lib/content/shiki/options.d.ts +8 -7
- package/src/lib/content/shiki/shiki-highlighter.d.ts +14 -13
- package/src/lib/content/shiki/shiki-highlighter.js +49 -43
- package/src/lib/content/shiki/shiki-highlighter.js.map +1 -0
- package/src/lib/content-plugin.d.ts +19 -19
- package/src/lib/content-plugin.js +181 -196
- package/src/lib/content-plugin.js.map +1 -0
- package/src/lib/deps-plugin.d.ts +2 -2
- package/src/lib/deps-plugin.js +84 -82
- package/src/lib/deps-plugin.js.map +1 -0
- package/src/lib/discover-library-routes.d.ts +22 -0
- package/src/lib/discover-library-routes.js +75 -0
- package/src/lib/discover-library-routes.js.map +1 -0
- package/src/lib/i18n-component-registry-plugin.d.ts +17 -0
- package/src/lib/i18n-component-registry-plugin.js +100 -0
- package/src/lib/i18n-component-registry-plugin.js.map +1 -0
- package/src/lib/i18n-extract-plugin.d.ts +33 -0
- package/src/lib/inject-server-fn-ids.d.ts +17 -0
- package/src/lib/inject-server-fn-ids.js +94 -0
- package/src/lib/inject-server-fn-ids.js.map +1 -0
- package/src/lib/json-ld-manifest-plugin.d.ts +41 -0
- package/src/lib/json-ld-manifest-plugin.js +84 -0
- package/src/lib/json-ld-manifest-plugin.js.map +1 -0
- package/src/lib/nitro/analog-nitro-plugin.d.ts +18 -0
- package/src/lib/nitro/analog-nitro-plugin.js +555 -0
- package/src/lib/nitro/analog-nitro-plugin.js.map +1 -0
- package/src/lib/nitro/angular-linker-plugin.d.ts +17 -0
- package/src/lib/nitro/angular-linker-plugin.js +51 -0
- package/src/lib/nitro/angular-linker-plugin.js.map +1 -0
- package/src/lib/nitro/build-sitemap.d.ts +23 -0
- package/src/lib/nitro/build-sitemap.js +137 -0
- package/src/lib/nitro/build-sitemap.js.map +1 -0
- package/src/lib/nitro/debug.d.ts +5 -0
- package/src/lib/nitro/debug.js +11 -0
- package/src/lib/nitro/debug.js.map +1 -0
- package/src/lib/nitro/get-content-files.d.ts +13 -0
- package/src/lib/nitro/get-content-files.js +52 -0
- package/src/lib/nitro/get-content-files.js.map +1 -0
- package/src/lib/nitro/get-page-handlers.d.ts +22 -0
- package/src/lib/nitro/get-page-handlers.js +33 -0
- package/src/lib/nitro/get-page-handlers.js.map +1 -0
- package/src/lib/nitro/i18n-prerender.d.ts +29 -0
- package/src/lib/nitro/i18n-prerender.js +61 -0
- package/src/lib/nitro/i18n-prerender.js.map +1 -0
- package/src/lib/nitro/page-endpoints-plugin.d.ts +7 -0
- package/src/lib/nitro/page-endpoints-plugin.js +72 -0
- package/src/lib/nitro/page-endpoints-plugin.js.map +1 -0
- package/src/lib/nitro/post-rendering-hook.d.ts +2 -0
- package/src/lib/nitro/post-rendering-hook.js +10 -0
- package/src/lib/nitro/post-rendering-hook.js.map +1 -0
- package/src/lib/nitro/renderers.d.ts +33 -0
- package/src/lib/nitro/renderers.js +22 -0
- package/src/lib/nitro/renderers.js.map +1 -0
- package/src/lib/nitro/types.d.ts +122 -0
- package/src/lib/nx-plugin/_virtual/_rolldown/runtime.js +23 -0
- package/src/lib/nx-plugin/builders.json +15 -0
- package/src/lib/nx-plugin/executors.json +13 -5
- package/src/lib/nx-plugin/generators.json +25 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js +13 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js.map +1 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js +8 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js.map +1 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js +9 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js.map +1 -0
- package/src/lib/nx-plugin/package.json +1 -5
- package/src/lib/nx-plugin/src/builders/vite/schema.json +39 -0
- package/src/lib/nx-plugin/src/builders/vite/vite-build.d.ts +11 -0
- package/src/lib/nx-plugin/src/builders/vite/vite-build.js +18 -0
- package/src/lib/nx-plugin/src/builders/vite/vite-build.js.map +1 -0
- package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.d.ts +7 -0
- package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.js +14 -0
- package/src/lib/nx-plugin/src/builders/vite-dev-server/dev-server.js.map +1 -0
- package/src/lib/nx-plugin/src/builders/vite-dev-server/schema.json +27 -0
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/compat.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/compat.d.ts +9 -3
- package/src/lib/nx-plugin/src/generators/app/compat.js +18 -7
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/files/agents/AGENTS.md +11 -0
- package/src/lib/nx-plugin/src/generators/app/files/agents/CLAUDE.md +1 -0
- package/src/lib/nx-plugin/src/generators/app/files/root/tsconfig.base.json +3 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular/src/test-setup.ts__template__ +1 -0
- package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.app.json__template__ +1 -3
- package/src/lib/nx-plugin/src/generators/app/files/template-angular/tsconfig.json__template__ +2 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular/vite.config.ts__template__ +6 -2
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/tsconfig.json__template__ +4 -2
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/vite.config.ts__template__ +1 -21
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/tsconfig.json__template__ +4 -2
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/vite.config.ts__template__ +2 -22
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.app.json__template__ +1 -3
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/tsconfig.json__template__ +4 -2
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/vite.config.ts__template__ +1 -12
- package/src/lib/nx-plugin/src/generators/app/generator.d.ts +11 -11
- package/src/lib/nx-plugin/src/generators/app/generator.js +81 -92
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.d.ts +2 -0
- package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js +16 -0
- package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js.map +1 -0
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +73 -81
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +25 -58
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +16 -16
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +15 -13
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.d.ts +7 -7
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +19 -29
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.d.ts +4 -5
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +61 -103
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js +17 -20
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +15 -18
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/schema.d.ts +2 -0
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +2 -3
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +7 -10
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.d.ts +0 -3
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.d.ts +1 -6
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +12 -17
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +11 -37
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js +11 -15
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions.d.ts +0 -28
- package/src/lib/nx-plugin/src/generators/init/compat.d.ts +9 -3
- package/src/lib/nx-plugin/src/generators/init/compat.js +18 -7
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/files/vite.config.ts__template__ +2 -6
- package/src/lib/nx-plugin/src/generators/init/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/init/generator.js +55 -65
- package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +20 -20
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +21 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +57 -66
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js +12 -11
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +18 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +13 -15
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +20 -31
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +44 -51
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +28 -34
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +20 -20
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/test-files/src/test-setup.ts__template__ +1 -0
- package/src/lib/nx-plugin/src/generators/page/__snapshots__/generator.spec.ts.snap +0 -7
- package/src/lib/nx-plugin/src/generators/page/compat.d.ts +9 -0
- package/src/lib/nx-plugin/src/generators/page/compat.js +19 -0
- package/src/lib/nx-plugin/src/generators/page/compat.js.map +1 -0
- package/src/lib/nx-plugin/src/generators/page/files/__fileName__.page.ts__template__ +0 -1
- package/src/lib/nx-plugin/src/generators/page/generator.d.ts +3 -4
- package/src/lib/nx-plugin/src/generators/page/generator.js +35 -44
- package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +8 -7
- package/src/lib/nx-plugin/src/generators/preset/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/preset/generator.js +24 -43
- package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.d.ts +9 -3
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +18 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/files/src/test-setup.ts__template__ +1 -0
- package/src/lib/nx-plugin/src/generators/setup-vitest/files/vite.config.mts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +33 -42
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.d.ts +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js +8 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js +21 -27
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.d.ts +2 -2
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js +20 -22
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/index.js +0 -2
- package/src/lib/nx-plugin/src/utils/version-utils.d.ts +1 -1
- package/src/lib/nx-plugin/src/utils/version-utils.js +21 -27
- package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js +43 -62
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +50 -83
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.d.ts +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js +33 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.d.ts +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js +33 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +9 -8
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +39 -23
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
- package/src/lib/options.d.ts +175 -80
- package/src/lib/platform-plugin.d.ts +2 -2
- package/src/lib/platform-plugin.js +48 -62
- package/src/lib/platform-plugin.js.map +1 -0
- package/src/lib/route-file-discovery.d.ts +23 -0
- package/src/lib/route-file-discovery.js +114 -0
- package/src/lib/route-file-discovery.js.map +1 -0
- package/src/lib/route-generation-plugin.d.ts +3 -0
- package/src/lib/route-generation-plugin.js +45 -0
- package/src/lib/route-generation-plugin.js.map +1 -0
- package/src/lib/route-idiom-diagnostics.d.ts +13 -0
- package/src/lib/route-idiom-diagnostics.js +160 -0
- package/src/lib/route-idiom-diagnostics.js.map +1 -0
- package/src/lib/route-manifest.d.ts +122 -0
- package/src/lib/route-manifest.js +431 -0
- package/src/lib/route-manifest.js.map +1 -0
- package/src/lib/router-plugin.d.ts +19 -19
- package/src/lib/router-plugin.js +234 -176
- package/src/lib/router-plugin.js.map +1 -0
- package/src/lib/server-fn-client-transform.d.ts +26 -0
- package/src/lib/server-fn-client-transform.js +97 -0
- package/src/lib/server-fn-client-transform.js.map +1 -0
- package/src/lib/server-fn-id.d.ts +25 -0
- package/src/lib/server-fn-id.js +37 -0
- package/src/lib/server-fn-id.js.map +1 -0
- package/src/lib/ssr/defer-streaming-plugin.d.ts +65 -0
- package/src/lib/ssr/inject-html-plugin.d.ts +1 -1
- package/src/lib/ssr/inject-html-plugin.js +25 -25
- package/src/lib/ssr/inject-html-plugin.js.map +1 -0
- package/src/lib/ssr/ssr-build-plugin.d.ts +26 -2
- package/src/lib/ssr/ssr-build-plugin.js +38 -30
- package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
- package/src/lib/style-pipeline.d.ts +33 -0
- package/src/lib/style-pipeline.js +32 -0
- package/src/lib/style-pipeline.js.map +1 -0
- package/src/lib/style-preprocessor.d.ts +28 -0
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/tailwind-preprocessor.d.ts +23 -0
- package/src/lib/tailwind-preprocessor.js +153 -0
- package/src/lib/tailwind-preprocessor.js.map +1 -0
- package/src/lib/typed-routes-plugin.d.ts +50 -0
- package/src/lib/typed-routes-plugin.js +234 -0
- package/src/lib/typed-routes-plugin.js.map +1 -0
- package/src/lib/utils/debug-harness.d.ts +23 -0
- package/src/lib/utils/debug-harness.js +88 -0
- package/src/lib/utils/debug-harness.js.map +1 -0
- package/src/lib/utils/debug-log-file.d.ts +5 -0
- package/src/lib/utils/debug-log-file.js +56 -0
- package/src/lib/utils/debug-log-file.js.map +1 -0
- package/src/lib/utils/debug.d.ts +22 -0
- package/src/lib/utils/debug.js +27 -0
- package/src/lib/utils/debug.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +3 -0
- package/src/lib/utils/rolldown.js +15 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/server-mode-plugin.d.ts +6 -6
- package/src/server-mode-plugin.js +16 -18
- package/src/server-mode-plugin.js.map +1 -0
- package/src/style-pipeline.d.ts +1 -0
- package/src/style-pipeline.js +2 -0
- package/src/style-preprocessor.d.ts +1 -0
- package/src/style-preprocessor.js +2 -0
- package/README.md +0 -5
- package/src/lib/content/prism/options.js +0 -1
- package/src/lib/content/shiki/options.js +0 -1
- package/src/lib/nx-plugin/README.md +0 -23
- package/src/lib/nx-plugin/src/executors/vite/compat.d.ts +0 -3
- package/src/lib/nx-plugin/src/executors/vite/compat.js +0 -8
- package/src/lib/nx-plugin/src/executors/vite/compat.js.map +0 -1
- package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +0 -2
- package/src/lib/nx-plugin/src/executors/vite/schema.json +0 -147
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.d.ts +0 -2
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +0 -5
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/.postcssrc.json +0 -5
- package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/tailwind.config.ts__template__ +0 -14
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/index.html__template__ +0 -15
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.spec.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/app/app.component.ts__template__ +0 -10
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/favicon.ico__template__ +0 -0
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.providers.ts__template__ +0 -5
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.server.ts__template__ +0 -23
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/.gitkeep__template__ +0 -0
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/analog.svg__template__ +0 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/public/assets/vite.svg__template__ +0 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/server/routes/v1/hello.ts__template__ +0 -3
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/styles.css__template__ +0 -4
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/test-setup.ts__template__ +0 -12
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/vite-env.d.ts__template__ +0 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.app.json__template__ +0 -16
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.editor.json__template__ +0 -7
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.json__template__ +0 -32
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/tsconfig.spec.json__template__ +0 -14
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/vite.config.ts__template__ +0 -69
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js +0 -15
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js +0 -58
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js +0 -47
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js +0 -110
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +0 -56
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +0 -72
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +0 -46
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +0 -37
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions.js +0 -43
- package/src/lib/nx-plugin/src/generators/app/versions.js.map +0 -1
- package/src/lib/nx-plugin/src/index.d.ts +0 -0
- package/src/lib/nx-plugin/src/index.js.map +0 -1
- package/src/lib/options.js +0 -1
- package/src/lib/ssr/ssr-xhr-plugin.d.ts +0 -2
- package/src/lib/ssr/ssr-xhr-plugin.js +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-fn-client-transform.js","names":[],"sources":["../../../src/lib/server-fn-client-transform.ts"],"sourcesContent":["import { parseSync } from 'oxc-parser';\n// Light subpath (no vite/nitro barrel): the built scrub is loaded outside a\n// build too, so it must not pull the plugin graph in.\nimport { deriveServerFnId } from './server-fn-id.js';\n\n/**\n * Client-build scrub + proxy generation for server functions.\n *\n * On the client build a `*.server.ts` module must not carry server handler\n * bodies (which `inject()` server services, read the request, hit the database).\n * But the client still imports the named `serverFn` exports to dispatch them.\n * This transform regenerates the module so each `export const NAME = serverFn(\n * config, handler)` becomes a call to the client-safe `createServerFnRef`\n * factory — keeping the `{ id, url, method }` metadata `injectServerFn` needs,\n * dropping the handler and every server-only import. Because the regenerated\n * module references nothing else, the server code tree-shakes away entirely.\n *\n * Returns the new module source, or `null` when the module defines no server\n * function (the caller falls back to the page-endpoint scrub for those).\n */\nexport interface ServerFnProxy {\n name: string;\n id: string;\n method: 'GET' | 'POST';\n}\n\nexport interface ScrubResult {\n code: string;\n proxies: ServerFnProxy[];\n hadDefaultExport: boolean;\n}\n\nconst SERVER_FN_SOURCE = '@analogjs/router/server';\n\nexport function scrubServerFnModule(\n code: string,\n fileId = 'file.ts',\n): ScrubResult | null {\n // Cheap bail-out before parsing: no `serverFn` token, nothing to do.\n if (!code.includes('serverFn')) {\n return null;\n }\n\n const { program } = parseSync(fileId, code);\n const body = (program as { body: any[] }).body;\n\n const serverFnLocalNames = collectServerFnLocalNames(body);\n const hadDefaultExport = body.some(\n (node) => node.type === 'ExportDefaultDeclaration',\n );\n\n const proxies: ServerFnProxy[] = [];\n for (const node of body) {\n if (\n node.type !== 'ExportNamedDeclaration' ||\n node.declaration?.type !== 'VariableDeclaration'\n ) {\n continue;\n }\n for (const declarator of node.declaration.declarations) {\n if (\n declarator.id?.type !== 'Identifier' ||\n declarator.init?.type !== 'CallExpression' ||\n declarator.init.callee?.type !== 'Identifier' ||\n !serverFnLocalNames.has(declarator.init.callee.name)\n ) {\n continue;\n }\n proxies.push(\n toProxy(declarator.id.name, declarator.init.arguments ?? [], fileId),\n );\n }\n }\n\n // Every `serverFn(...)` call in the module must have become a proxy. If one\n // did not, the module uses a shape this transform cannot rewrite (e.g.\n // `const fn = serverFn(...); export { fn };`) and returning `null` would leave\n // it untouched — shipping the handler and its server imports to the browser.\n // Fail the build instead: a scrub that silently opts out is a code leak.\n const callCount = countServerFnCalls(program, serverFnLocalNames);\n if (callCount > proxies.length) {\n throw new Error(\n `[analog] ${fileId}: found ${callCount} serverFn call(s) but could only rewrite ${proxies.length} for the client build. ` +\n `Server functions must be declared as a directly exported const — \\`export const name = serverFn(…)\\` — so the handler can be stripped from the browser bundle.`,\n );\n }\n\n if (proxies.length === 0) {\n return null;\n }\n\n const lines = [\n `import { createServerFnRef } from '@analogjs/router';`,\n '',\n ...proxies.map(\n (p) =>\n `export const ${p.name} = createServerFnRef({ id: ${JSON.stringify(\n p.id,\n )}, method: ${JSON.stringify(p.method)} });`,\n ),\n ];\n // A file that is also a page endpoint keeps the load-shim the router expects.\n if (hadDefaultExport) {\n lines.push('', 'export default undefined;');\n }\n\n return { code: lines.join('\\n') + '\\n', proxies, hadDefaultExport };\n}\n\n/** Local identifier(s) `serverFn` is imported under from `@analogjs/router/server`. */\nfunction collectServerFnLocalNames(body: any[]): Set<string> {\n const names = new Set<string>();\n for (const node of body) {\n if (\n node.type !== 'ImportDeclaration' ||\n node.source?.value !== SERVER_FN_SOURCE\n ) {\n continue;\n }\n for (const spec of node.specifiers ?? []) {\n if (\n spec.type === 'ImportSpecifier' &&\n spec.imported?.name === 'serverFn'\n ) {\n names.add(spec.local.name);\n }\n }\n }\n // Fallback: if the module never imported it (unusual), still match the\n // conventional name so a mis-resolved import doesn't leak server code.\n if (names.size === 0) {\n names.add('serverFn');\n }\n return names;\n}\n\nfunction toProxy(name: string, args: any[], fileId: string): ServerFnProxy {\n const method = methodForCall(name, args, fileId);\n // The id is derived, never read from source — same algorithm the server\n // registration uses, so client proxy and server route always match.\n return { name, id: deriveServerFnId(fileId, name), method };\n}\n\n/**\n * Resolve the HTTP method from the call shape, matching the runtime overloads:\n * `serverFn(handler)` ⇒ GET, `serverFn(schema, handler)` ⇒ POST,\n * `serverFn(config, handler)` ⇒ config-driven.\n */\nfunction methodForCall(\n name: string,\n args: any[],\n fileId: string,\n): 'GET' | 'POST' {\n const arg0 = args[0];\n\n // serverFn(handler) — input-less GET.\n if (isFunctionNode(arg0)) return 'GET';\n\n // serverFn(config, handler) — read method/input off the object.\n if (arg0?.type === 'ObjectExpression') {\n let method: 'GET' | 'POST' | undefined;\n let hasInput = false;\n for (const prop of arg0.properties ?? []) {\n if (prop.type !== 'Property') continue;\n const key =\n prop.key?.type === 'Identifier' ? prop.key.name : prop.key?.value;\n if (key === 'method' && isStringLiteral(prop.value)) {\n method = prop.value.value as 'GET' | 'POST';\n } else if (key === 'input') {\n hasInput = true;\n }\n }\n if (method === 'GET' && hasInput) {\n throw new Error(\n `[analog] serverFn \"${name}\" in ${fileId} declares method: 'GET' with an input schema; GET carries no body. Use POST or drop the input.`,\n );\n }\n return method ?? (hasInput ? 'POST' : 'GET');\n }\n\n // serverFn(schema, handler) — a schema ⇒ POST + input.\n if (arg0 && args.length >= 2) return 'POST';\n\n throw new Error(\n `[analog] serverFn \"${name}\" in ${fileId} must be called as serverFn(handler), serverFn(schema, handler), or serverFn(config, handler).`,\n );\n}\n\nfunction isFunctionNode(node: any): boolean {\n return (\n node?.type === 'ArrowFunctionExpression' ||\n node?.type === 'FunctionExpression'\n );\n}\n\nfunction isStringLiteral(\n node: any,\n): node is { type: 'Literal'; value: string } {\n return node?.type === 'Literal' && typeof node.value === 'string';\n}\n\n/** Every `serverFn(...)` call anywhere in the module, not just exported ones. */\nfunction countServerFnCalls(node: unknown, names: Set<string>): number {\n if (!node || typeof node !== 'object') {\n return 0;\n }\n if (Array.isArray(node)) {\n return node.reduce(\n (total, child) => total + countServerFnCalls(child, names),\n 0,\n );\n }\n\n const record = node as Record<string, unknown> & { type?: string };\n let count = 0;\n if (record.type === 'CallExpression') {\n const callee = record['callee'] as { type?: string; name?: string };\n if (\n callee?.type === 'Identifier' &&\n callee.name &&\n names.has(callee.name)\n ) {\n count += 1;\n }\n }\n for (const key of Object.keys(record)) {\n count += countServerFnCalls(record[key], names);\n }\n return count;\n}\n"],"mappings":";;;AAgCA,IAAM,mBAAmB;AAEzB,SAAgB,oBACd,MACA,SAAS,WACW;AAEpB,KAAI,CAAC,KAAK,SAAS,WAAW,CAC5B,QAAO;CAGT,MAAM,EAAE,YAAY,UAAU,QAAQ,KAAK;CAC3C,MAAM,OAAQ,QAA4B;CAE1C,MAAM,qBAAqB,0BAA0B,KAAK;CAC1D,MAAM,mBAAmB,KAAK,MAC3B,SAAS,KAAK,SAAS,2BACzB;CAED,MAAM,UAA2B,EAAE;AACnC,MAAK,MAAM,QAAQ,MAAM;AACvB,MACE,KAAK,SAAS,4BACd,KAAK,aAAa,SAAS,sBAE3B;AAEF,OAAK,MAAM,cAAc,KAAK,YAAY,cAAc;AACtD,OACE,WAAW,IAAI,SAAS,gBACxB,WAAW,MAAM,SAAS,oBAC1B,WAAW,KAAK,QAAQ,SAAS,gBACjC,CAAC,mBAAmB,IAAI,WAAW,KAAK,OAAO,KAAK,CAEpD;AAEF,WAAQ,KACN,QAAQ,WAAW,GAAG,MAAM,WAAW,KAAK,aAAa,EAAE,EAAE,OAAO,CACrE;;;CASL,MAAM,YAAY,mBAAmB,SAAS,mBAAmB;AACjE,KAAI,YAAY,QAAQ,OACtB,OAAM,IAAI,MACR,YAAY,OAAO,UAAU,UAAU,2CAA2C,QAAQ,OAAO,uLAElG;AAGH,KAAI,QAAQ,WAAW,EACrB,QAAO;CAGT,MAAM,QAAQ;EACZ;EACA;EACA,GAAG,QAAQ,KACR,MACC,gBAAgB,EAAE,KAAK,6BAA6B,KAAK,UACvD,EAAE,GACH,CAAC,YAAY,KAAK,UAAU,EAAE,OAAO,CAAC,MAC1C;EACF;AAED,KAAI,iBACF,OAAM,KAAK,IAAI,4BAA4B;AAG7C,QAAO;EAAE,MAAM,MAAM,KAAK,KAAK,GAAG;EAAM;EAAS;EAAkB;;;AAIrE,SAAS,0BAA0B,MAA0B;CAC3D,MAAM,wBAAQ,IAAI,KAAa;AAC/B,MAAK,MAAM,QAAQ,MAAM;AACvB,MACE,KAAK,SAAS,uBACd,KAAK,QAAQ,UAAU,iBAEvB;AAEF,OAAK,MAAM,QAAQ,KAAK,cAAc,EAAE,CACtC,KACE,KAAK,SAAS,qBACd,KAAK,UAAU,SAAS,WAExB,OAAM,IAAI,KAAK,MAAM,KAAK;;AAMhC,KAAI,MAAM,SAAS,EACjB,OAAM,IAAI,WAAW;AAEvB,QAAO;;AAGT,SAAS,QAAQ,MAAc,MAAa,QAA+B;CACzE,MAAM,SAAS,cAAc,MAAM,MAAM,OAAO;AAGhD,QAAO;EAAE;EAAM,IAAI,iBAAiB,QAAQ,KAAK;EAAE;EAAQ;;;;;;;AAQ7D,SAAS,cACP,MACA,MACA,QACgB;CAChB,MAAM,OAAO,KAAK;AAGlB,KAAI,eAAe,KAAK,CAAE,QAAO;AAGjC,KAAI,MAAM,SAAS,oBAAoB;EACrC,IAAI;EACJ,IAAI,WAAW;AACf,OAAK,MAAM,QAAQ,KAAK,cAAc,EAAE,EAAE;AACxC,OAAI,KAAK,SAAS,WAAY;GAC9B,MAAM,MACJ,KAAK,KAAK,SAAS,eAAe,KAAK,IAAI,OAAO,KAAK,KAAK;AAC9D,OAAI,QAAQ,YAAY,gBAAgB,KAAK,MAAM,CACjD,UAAS,KAAK,MAAM;YACX,QAAQ,QACjB,YAAW;;AAGf,MAAI,WAAW,SAAS,SACtB,OAAM,IAAI,MACR,sBAAsB,KAAK,OAAO,OAAO,gGAC1C;AAEH,SAAO,WAAW,WAAW,SAAS;;AAIxC,KAAI,QAAQ,KAAK,UAAU,EAAG,QAAO;AAErC,OAAM,IAAI,MACR,sBAAsB,KAAK,OAAO,OAAO,gGAC1C;;AAGH,SAAS,eAAe,MAAoB;AAC1C,QACE,MAAM,SAAS,6BACf,MAAM,SAAS;;AAInB,SAAS,gBACP,MAC4C;AAC5C,QAAO,MAAM,SAAS,aAAa,OAAO,KAAK,UAAU;;;AAI3D,SAAS,mBAAmB,MAAe,OAA4B;AACrE,KAAI,CAAC,QAAQ,OAAO,SAAS,SAC3B,QAAO;AAET,KAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,KAAK,QACT,OAAO,UAAU,QAAQ,mBAAmB,OAAO,MAAM,EAC1D,EACD;CAGH,MAAM,SAAS;CACf,IAAI,QAAQ;AACZ,KAAI,OAAO,SAAS,kBAAkB;EACpC,MAAM,SAAS,OAAO;AACtB,MACE,QAAQ,SAAS,gBACjB,OAAO,QACP,MAAM,IAAI,OAAO,KAAK,CAEtB,UAAS;;AAGb,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,UAAS,mBAAmB,OAAO,MAAM,MAAM;AAEjD,QAAO"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-function ids are derived, never author-chosen, for security:
|
|
3
|
+
*
|
|
4
|
+
* - **Collision-free.** `hash(fileId + exportName)` is unique per file+export, so
|
|
5
|
+
* two functions can never share a route and hijack each other's dispatch — a
|
|
6
|
+
* real risk with hand-picked ids where two authors independently pick `getUser`.
|
|
7
|
+
* - **Non-enumerable.** The public route is an opaque digest, not a guessable
|
|
8
|
+
* verb like `/_analog/fn/deleteAccount`, shrinking the discoverable surface.
|
|
9
|
+
* - **Not author-controlled.** Authors cannot expose a meaningful or duplicate
|
|
10
|
+
* route by accident; the id is a pure function of location.
|
|
11
|
+
*
|
|
12
|
+
* Both build transforms (server registration + client proxy) MUST derive the
|
|
13
|
+
* same id, so this is the single source of truth for the algorithm and the
|
|
14
|
+
* `fileId` must be the **project-root-relative** POSIX path — identical across
|
|
15
|
+
* the client, SSR, and Nitro builds regardless of absolute checkout location.
|
|
16
|
+
*/
|
|
17
|
+
/** Project-root-relative POSIX module path used as the stable hash input. */
|
|
18
|
+
export declare function serverFnFileId(absPath: string, projectRoot: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Derives the opaque, collision-free id for a server function from its
|
|
21
|
+
* project-root-relative file id and export name. 16 hex chars (64 bits) is far
|
|
22
|
+
* beyond birthday-collision range for any realistic function count while keeping
|
|
23
|
+
* the route short.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deriveServerFnId(fileId: string, exportName: string): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
//#region packages/platform/src/lib/server-fn-id.ts
|
|
4
|
+
var toPosix = (p) => p.replace(/\\/g, "/");
|
|
5
|
+
/**
|
|
6
|
+
* Server-function ids are derived, never author-chosen, for security:
|
|
7
|
+
*
|
|
8
|
+
* - **Collision-free.** `hash(fileId + exportName)` is unique per file+export, so
|
|
9
|
+
* two functions can never share a route and hijack each other's dispatch — a
|
|
10
|
+
* real risk with hand-picked ids where two authors independently pick `getUser`.
|
|
11
|
+
* - **Non-enumerable.** The public route is an opaque digest, not a guessable
|
|
12
|
+
* verb like `/_analog/fn/deleteAccount`, shrinking the discoverable surface.
|
|
13
|
+
* - **Not author-controlled.** Authors cannot expose a meaningful or duplicate
|
|
14
|
+
* route by accident; the id is a pure function of location.
|
|
15
|
+
*
|
|
16
|
+
* Both build transforms (server registration + client proxy) MUST derive the
|
|
17
|
+
* same id, so this is the single source of truth for the algorithm and the
|
|
18
|
+
* `fileId` must be the **project-root-relative** POSIX path — identical across
|
|
19
|
+
* the client, SSR, and Nitro builds regardless of absolute checkout location.
|
|
20
|
+
*/
|
|
21
|
+
/** Project-root-relative POSIX module path used as the stable hash input. */
|
|
22
|
+
function serverFnFileId(absPath, projectRoot) {
|
|
23
|
+
return toPosix(relative(projectRoot, absPath));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Derives the opaque, collision-free id for a server function from its
|
|
27
|
+
* project-root-relative file id and export name. 16 hex chars (64 bits) is far
|
|
28
|
+
* beyond birthday-collision range for any realistic function count while keeping
|
|
29
|
+
* the route short.
|
|
30
|
+
*/
|
|
31
|
+
function deriveServerFnId(fileId, exportName) {
|
|
32
|
+
return createHash("sha256").update(`${fileId}#${exportName}`).digest("hex").slice(0, 16);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { deriveServerFnId, serverFnFileId };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=server-fn-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-fn-id.js","names":[],"sources":["../../../src/lib/server-fn-id.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { relative } from 'node:path';\n\n// Intentionally dependency-light (node built-ins only): this module is loaded by\n// the client scrub, so it must not drag in vite/nitro. POSIX-normalize inline.\nconst toPosix = (p: string): string => p.replace(/\\\\/g, '/');\n\n/**\n * Server-function ids are derived, never author-chosen, for security:\n *\n * - **Collision-free.** `hash(fileId + exportName)` is unique per file+export, so\n * two functions can never share a route and hijack each other's dispatch — a\n * real risk with hand-picked ids where two authors independently pick `getUser`.\n * - **Non-enumerable.** The public route is an opaque digest, not a guessable\n * verb like `/_analog/fn/deleteAccount`, shrinking the discoverable surface.\n * - **Not author-controlled.** Authors cannot expose a meaningful or duplicate\n * route by accident; the id is a pure function of location.\n *\n * Both build transforms (server registration + client proxy) MUST derive the\n * same id, so this is the single source of truth for the algorithm and the\n * `fileId` must be the **project-root-relative** POSIX path — identical across\n * the client, SSR, and Nitro builds regardless of absolute checkout location.\n */\n\n/** Project-root-relative POSIX module path used as the stable hash input. */\nexport function serverFnFileId(absPath: string, projectRoot: string): string {\n return toPosix(relative(projectRoot, absPath));\n}\n\n/**\n * Derives the opaque, collision-free id for a server function from its\n * project-root-relative file id and export name. 16 hex chars (64 bits) is far\n * beyond birthday-collision range for any realistic function count while keeping\n * the route short.\n */\nexport function deriveServerFnId(fileId: string, exportName: string): string {\n return createHash('sha256')\n .update(`${fileId}#${exportName}`)\n .digest('hex')\n .slice(0, 16);\n}\n"],"mappings":";;;AAKA,IAAM,WAAW,MAAsB,EAAE,QAAQ,OAAO,IAAI;;;;;;;;;;;;;;;;;;AAoB5D,SAAgB,eAAe,SAAiB,aAA6B;AAC3E,QAAO,QAAQ,SAAS,aAAa,QAAQ,CAAC;;;;;;;;AAShD,SAAgB,iBAAiB,QAAgB,YAA4B;AAC3E,QAAO,WAAW,SAAS,CACxB,OAAO,GAAG,OAAO,GAAG,aAAa,CACjC,OAAO,MAAM,CACb,MAAM,GAAG,GAAG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Minimum Angular major whose compiled `@angular/core` FESM matches the
|
|
4
|
+
* streaming patch anchors. Incremental hydration is a stable public API from
|
|
5
|
+
* v20 (`withIncrementalHydration`, `@publicApi 20.0`), but v20's FESM inlines
|
|
6
|
+
* the injection anchor's `DeferBlockStateEnd` profiler event to its numeric
|
|
7
|
+
* ordinal, whereas v21+ keeps the symbolic `ProfilerEvent.DeferBlockStateEnd`
|
|
8
|
+
* form the anchor matches on. Keying on the literal ordinal would be fragile
|
|
9
|
+
* (enum values shift between versions), so v21 is the floor.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MIN_STREAMING_ANGULAR_MAJOR = 21;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the streaming SSR patch can be applied to the installed Angular.
|
|
14
|
+
* A `null` major (version undetectable) returns `true`: don't block on a failed
|
|
15
|
+
* detection — the plugin's anchor-drift detection catches a real mismatch at
|
|
16
|
+
* build time and falls back to buffered rendering.
|
|
17
|
+
*/
|
|
18
|
+
export declare function streamingSupportedOnAngular(major: number | null): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Pure transform that injects the streaming-SSR per-block resolution hook into
|
|
21
|
+
* `@angular/core`'s compiled output. It is the same class of transform as
|
|
22
|
+
* `i18nDefRegistryPlugin` in ./ssr-build-plugin — a string patch of Angular's
|
|
23
|
+
* bundle applied only to SSR builds. Exported separately so it can be unit
|
|
24
|
+
* tested against a bundle string.
|
|
25
|
+
*
|
|
26
|
+
* Two edits, both keyed on single-occurrence anchors in the module that holds
|
|
27
|
+
* the defer runtime:
|
|
28
|
+
* 1. Inside `applyDeferBlockState`, fire `globalThis.__analogSsrDeferCapture`
|
|
29
|
+
* when a `@defer` block reaches `Complete` on the server, passing the
|
|
30
|
+
* block's live `lContainer` — this is the per-block resolution signal a
|
|
31
|
+
* streaming renderer consumes.
|
|
32
|
+
* 2. Expose `collectNativeNodesInLContainer` via `globalThis.__analogSsrInternals`
|
|
33
|
+
* so the renderer can serialize a block's subtree.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when the module is not the one carrying the defer runtime, so
|
|
36
|
+
* it is a no-op on every other Angular module.
|
|
37
|
+
*/
|
|
38
|
+
export declare function injectDeferStreamingHook(code: string): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Classify an `@angular/core` module for the streaming patch. The patch anchors
|
|
41
|
+
* on internal symbol names, so when Angular changes those the transform would
|
|
42
|
+
* otherwise become a silent no-op and streaming would degrade to buffered with
|
|
43
|
+
* no signal. This distinguishes "not the target module" (skip quietly) from
|
|
44
|
+
* "this IS the `@defer` runtime module but the anchors drifted" (worth warning).
|
|
45
|
+
*/
|
|
46
|
+
export declare function inspectAngularCoreModule(code: string): {
|
|
47
|
+
kind: "not-target";
|
|
48
|
+
} | {
|
|
49
|
+
kind: "patchable";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "drifted";
|
|
52
|
+
reason: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Vite plugin that applies {@link injectDeferStreamingHook} to `@angular/core`
|
|
56
|
+
* during SSR builds, so `@analogjs/router`'s `renderStream` can flush `@defer`
|
|
57
|
+
* blocks as they resolve on the server — without hand-patching node_modules.
|
|
58
|
+
*
|
|
59
|
+
* Only active for SSR. Mirrors the enforce/filter/ssr-gate shape of
|
|
60
|
+
* `i18nDefRegistryPlugin`. If the `@defer` runtime module is found but its
|
|
61
|
+
* anchors have drifted (Angular changed internals), or if it is never
|
|
62
|
+
* encountered at all, the plugin warns rather than silently producing a build
|
|
63
|
+
* that falls back to buffered rendering.
|
|
64
|
+
*/
|
|
65
|
+
export declare function deferStreamingPlugin(): Plugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
2
|
export declare function injectHTMLPlugin(): Plugin[];
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { VERSION } from "@angular/compiler-cli";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
//#region packages/platform/src/lib/ssr/inject-html-plugin.ts
|
|
5
|
+
var require = createRequire(import.meta.url);
|
|
5
6
|
function eventReplayPlugin() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
];
|
|
21
|
-
},
|
|
22
|
-
};
|
|
7
|
+
return {
|
|
8
|
+
name: "analogjs-event-replay-plugin",
|
|
9
|
+
async transformIndexHtml() {
|
|
10
|
+
return [{
|
|
11
|
+
tag: "script",
|
|
12
|
+
attrs: {
|
|
13
|
+
type: "text/javascript",
|
|
14
|
+
id: "ng-event-dispatch-contract"
|
|
15
|
+
},
|
|
16
|
+
children: await readFile(require.resolve("@angular/core/event-dispatch-contract.min.js"), "utf-8"),
|
|
17
|
+
injectTo: "body"
|
|
18
|
+
}];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return hasEventReplay ? [eventReplayPlugin()] : [];
|
|
22
|
+
function injectHTMLPlugin() {
|
|
23
|
+
return Number(VERSION.major) >= 18 ? [eventReplayPlugin()] : [];
|
|
27
24
|
}
|
|
28
|
-
//#
|
|
25
|
+
//#endregion
|
|
26
|
+
export { injectHTMLPlugin };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=inject-html-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-html-plugin.js","names":[],"sources":["../../../../src/lib/ssr/inject-html-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { Plugin } from 'vite';\nimport { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\n\nconst require = createRequire(import.meta.url);\n\nfunction eventReplayPlugin(): Plugin {\n return {\n name: 'analogjs-event-replay-plugin',\n async transformIndexHtml() {\n const eventReplayScript = await readFile(\n require.resolve('@angular/core/event-dispatch-contract.min.js'),\n 'utf-8',\n );\n\n return [\n {\n tag: 'script',\n attrs: {\n type: 'text/javascript',\n id: 'ng-event-dispatch-contract',\n },\n children: eventReplayScript,\n injectTo: 'body',\n },\n ];\n },\n };\n}\n\nexport function injectHTMLPlugin(): Plugin[] {\n const hasEventReplay = Number(VERSION.major) >= 18;\n\n return hasEventReplay ? [eventReplayPlugin()] : [];\n}\n"],"mappings":";;;;AAKA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,SAAS,oBAA4B;AACnC,QAAO;EACL,MAAM;EACN,MAAM,qBAAqB;AAMzB,UAAO,CACL;IACE,KAAK;IACL,OAAO;KACL,MAAM;KACN,IAAI;KACL;IACD,UAZsB,MAAM,SAC9B,QAAQ,QAAQ,+CAA+C,EAC/D,QACD;IAUG,UAAU;IACX,CACF;;EAEJ;;AAGH,SAAgB,mBAA6B;AAG3C,QAFuB,OAAO,QAAQ,MAAM,IAAI,KAExB,CAAC,mBAAmB,CAAC,GAAG,EAAE"}
|
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* SSR build patches for Angular platform-server, Zone.js, and Domino.
|
|
4
|
+
*
|
|
5
|
+
* **Why each patch exists:**
|
|
6
|
+
* - zone-node: removes a `const global = globalThis` alias that shadows the
|
|
7
|
+
* real global in strict mode.
|
|
8
|
+
* - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and
|
|
9
|
+
* replaces bare `global` references with `globalThis`.
|
|
10
|
+
* - xhr2: strips Node-specific `os`/`process` references for SSR bundling.
|
|
11
|
+
* - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ssrBuildPlugin(): vite.Plugin[];
|
|
14
|
+
/**
|
|
15
|
+
* Vite plugin that patches `@angular/core`'s `getComponentId()` to
|
|
16
|
+
* mirror every compiled component definition to a global Set, bypassing
|
|
17
|
+
* the `ngServerMode` guard that normally prevents registration on the
|
|
18
|
+
* server. The set lives at `globalThis.__ngComponentDefs` and is read by
|
|
19
|
+
* `@analogjs/router`'s SSR render function to null cached `tView`
|
|
20
|
+
* objects between requests so that `$localize` tagged templates in
|
|
21
|
+
* `consts()` re-evaluate with the freshly loaded translations.
|
|
22
|
+
*
|
|
23
|
+
* Only active when the platform's `i18n` option is configured.
|
|
24
|
+
* Only transforms `@angular/core` modules in SSR builds.
|
|
25
|
+
*/
|
|
26
|
+
export declare function i18nDefRegistryPlugin(): Plugin;
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
//#region packages/platform/src/lib/ssr/ssr-build-plugin.ts
|
|
3
|
+
/**
|
|
4
|
+
* SSR build patches for Angular platform-server, Zone.js, and Domino.
|
|
5
|
+
*
|
|
6
|
+
* **Why each patch exists:**
|
|
7
|
+
* - zone-node: removes a `const global = globalThis` alias that shadows the
|
|
8
|
+
* real global in strict mode.
|
|
9
|
+
* - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and
|
|
10
|
+
* replaces bare `global` references with `globalThis`.
|
|
11
|
+
* - xhr2: strips Node-specific `os`/`process` references for SSR bundling.
|
|
12
|
+
* - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.
|
|
13
|
+
*/
|
|
14
|
+
function ssrBuildPlugin() {
|
|
15
|
+
return [{
|
|
16
|
+
name: "analogjs-ssr-build-plugin",
|
|
17
|
+
apply: "build",
|
|
18
|
+
config() {
|
|
19
|
+
return { ssr: { noExternal: ["xhr2"] } };
|
|
20
|
+
},
|
|
21
|
+
transform: {
|
|
22
|
+
filter: { id: /zone-node|platform-server|xhr2\.js|domino\/lib\/sloppy\.js/ },
|
|
23
|
+
handler(code, id) {
|
|
24
|
+
if (id.includes("zone-node") && code.includes("const global = globalThis;")) return { code: code.replace("const global = globalThis;", "") };
|
|
25
|
+
if (id.includes("platform-server")) {
|
|
26
|
+
let result = code.replace("new xhr2.XMLHttpRequest", "new (xhr2.default.XMLHttpRequest || xhr2.default)");
|
|
27
|
+
result = result.replaceAll("global.", "globalThis.").replaceAll("global,", "globalThis,").replaceAll(" global[", " globalThis[");
|
|
28
|
+
return { code: result };
|
|
29
|
+
}
|
|
30
|
+
if (id.includes(vite.normalizePath("xhr2.js"))) return { code: code.replace("os.type()", `''`).replace("os.arch()", `''`).replace("process.versions.node", `'node'`).replace("process.versions.v8", `'v8'`) };
|
|
31
|
+
if (id.includes(vite.normalizePath("domino/lib/sloppy.js"))) return { code: code.replace(/with\(/gi, "if(") };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}];
|
|
30
35
|
}
|
|
31
|
-
//#
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ssrBuildPlugin };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=ssr-build-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-build-plugin.js","names":[],"sources":["../../../../src/lib/ssr/ssr-build-plugin.ts"],"sourcesContent":["import * as vite from 'vite';\n\n/**\n * SSR build patches for Angular platform-server, Zone.js, and Domino.\n *\n * **Why each patch exists:**\n * - zone-node: removes a `const global = globalThis` alias that shadows the\n * real global in strict mode.\n * - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and\n * replaces bare `global` references with `globalThis`.\n * - xhr2: strips Node-specific `os`/`process` references for SSR bundling.\n * - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.\n */\nexport function ssrBuildPlugin(): vite.Plugin[] {\n const plugins: vite.Plugin[] = [\n {\n name: 'analogjs-ssr-build-plugin',\n apply: 'build',\n config() {\n return {\n ssr: {\n noExternal: ['xhr2'],\n },\n };\n },\n transform: {\n filter: {\n id: /zone-node|platform-server|xhr2\\.js|domino\\/lib\\/sloppy\\.js/,\n },\n handler(code, id) {\n if (\n id.includes('zone-node') &&\n code.includes('const global = globalThis;')\n ) {\n return {\n code: code.replace('const global = globalThis;', ''),\n };\n }\n\n if (id.includes('platform-server')) {\n let result = code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)',\n );\n\n // Narrowly scoped text replacement of the bare `global`\n // identifier. Matching `global.`, `global,` and ` global[`\n // targets the known occurrences in the @angular/platform-server\n // bundle while leaving strings, comments and asset paths that\n // merely contain the word `global` untouched (see #2426).\n result = result\n .replaceAll('global.', 'globalThis.')\n .replaceAll('global,', 'globalThis,')\n .replaceAll(' global[', ' globalThis[');\n\n return { code: result };\n }\n\n if (id.includes(vite.normalizePath('xhr2.js'))) {\n return {\n code: code\n .replace('os.type()', `''`)\n .replace('os.arch()', `''`)\n .replace('process.versions.node', `'node'`)\n .replace('process.versions.v8', `'v8'`),\n };\n }\n\n if (id.includes(vite.normalizePath('domino/lib/sloppy.js'))) {\n return {\n code: code.replace(/with\\(/gi, 'if('),\n };\n }\n\n return;\n },\n },\n },\n ];\n\n return plugins;\n}\n\n/**\n * Vite plugin that patches `@angular/core`'s `getComponentId()` to\n * mirror every compiled component definition to a global Set, bypassing\n * the `ngServerMode` guard that normally prevents registration on the\n * server. The set lives at `globalThis.__ngComponentDefs` and is read by\n * `@analogjs/router`'s SSR render function to null cached `tView`\n * objects between requests so that `$localize` tagged templates in\n * `consts()` re-evaluate with the freshly loaded translations.\n *\n * Only active when the platform's `i18n` option is configured.\n * Only transforms `@angular/core` modules in SSR builds.\n */\nexport function i18nDefRegistryPlugin(): Plugin {\n const DETECT_MARKER = 'GENERATED_COMP_IDS.set(compId, componentDef.type);';\n const RETURN_STMT = 'return compId;\\n}';\n\n return {\n name: 'analogjs-i18n-def-registry',\n enforce: 'post',\n\n transform: {\n filter: {\n id: /\\/@angular\\/core\\//,\n },\n handler(code, id, options) {\n if (!options?.ssr) return;\n if (!code.includes(DETECT_MARKER)) return;\n\n return {\n code: code.replace(\n RETURN_STMT,\n '(globalThis.__ngComponentDefs ??= new Set()).add(componentDef);\\n' +\n RETURN_STMT,\n ),\n };\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,iBAAgC;AAmE9C,QAlE+B,CAC7B;EACE,MAAM;EACN,OAAO;EACP,SAAS;AACP,UAAO,EACL,KAAK,EACH,YAAY,CAAC,OAAO,EACrB,EACF;;EAEH,WAAW;GACT,QAAQ,EACN,IAAI,8DACL;GACD,QAAQ,MAAM,IAAI;AAChB,QACE,GAAG,SAAS,YAAY,IACxB,KAAK,SAAS,6BAA6B,CAE3C,QAAO,EACL,MAAM,KAAK,QAAQ,8BAA8B,GAAG,EACrD;AAGH,QAAI,GAAG,SAAS,kBAAkB,EAAE;KAClC,IAAI,SAAS,KAAK,QAChB,2BACA,oDACD;AAOD,cAAS,OACN,WAAW,WAAW,cAAc,CACpC,WAAW,WAAW,cAAc,CACpC,WAAW,YAAY,eAAe;AAEzC,YAAO,EAAE,MAAM,QAAQ;;AAGzB,QAAI,GAAG,SAAS,KAAK,cAAc,UAAU,CAAC,CAC5C,QAAO,EACL,MAAM,KACH,QAAQ,aAAa,KAAK,CAC1B,QAAQ,aAAa,KAAK,CAC1B,QAAQ,yBAAyB,SAAS,CAC1C,QAAQ,uBAAuB,OAAO,EAC1C;AAGH,QAAI,GAAG,SAAS,KAAK,cAAc,uBAAuB,CAAC,CACzD,QAAO,EACL,MAAM,KAAK,QAAQ,YAAY,MAAM,EACtC;;GAKN;EACF,CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { StylesheetDependency, StylesheetDiagnostic, StylesheetTransformContext, StylesheetTransformResult } from "./style-preprocessor.js";
|
|
3
|
+
export interface StylePipelineStylesheetRegistry {
|
|
4
|
+
getPublicIdsForSource(sourcePath: string): string[];
|
|
5
|
+
getRequestIdsForSource(sourcePath: string): string[];
|
|
6
|
+
getDependenciesForSource(sourcePath: string): StylesheetDependency[];
|
|
7
|
+
getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];
|
|
8
|
+
getTagsForSource(sourcePath: string): string[];
|
|
9
|
+
}
|
|
10
|
+
export interface AngularStylePipelineContext {
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AngularStylePipelinePlugin {
|
|
14
|
+
name: string;
|
|
15
|
+
preprocessStylesheet?: (code: string, context: StylesheetTransformContext) => string | StylesheetTransformResult | undefined;
|
|
16
|
+
configureStylesheetRegistry?: (registry: StylePipelineStylesheetRegistry, context: AngularStylePipelineContext) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface AngularStylePipelineOptions {
|
|
19
|
+
plugins: AngularStylePipelinePlugin[];
|
|
20
|
+
}
|
|
21
|
+
export declare function defineAngularStylePipeline<const T extends AngularStylePipelineOptions>(options: T): T;
|
|
22
|
+
export declare function defineAngularStylePipelinePlugins<const T extends AngularStylePipelinePlugin[]>(plugins: T): T;
|
|
23
|
+
export interface StylePipelineContext {
|
|
24
|
+
workspaceRoot: string;
|
|
25
|
+
}
|
|
26
|
+
export type StylePipelinePluginFactory = (context: StylePipelineContext) => Plugin | Plugin[] | false | null | undefined;
|
|
27
|
+
export type StylePipelinePluginEntry = Plugin | Plugin[] | StylePipelinePluginFactory | false | null | undefined;
|
|
28
|
+
export interface StylePipelineOptions {
|
|
29
|
+
plugins?: StylePipelinePluginEntry[];
|
|
30
|
+
}
|
|
31
|
+
export declare function defineStylePipeline<const T extends StylePipelineOptions>(options: T): T;
|
|
32
|
+
export declare function defineStylePipelinePlugins<const T extends StylePipelinePluginEntry[]>(plugins: T): T;
|
|
33
|
+
export declare function resolveStylePipelinePlugins(options: StylePipelineOptions | false | undefined, workspaceRoot?: string): Plugin[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region packages/platform/src/lib/style-pipeline.ts
|
|
2
|
+
function defineAngularStylePipeline(options) {
|
|
3
|
+
return options;
|
|
4
|
+
}
|
|
5
|
+
function defineAngularStylePipelinePlugins(plugins) {
|
|
6
|
+
return plugins;
|
|
7
|
+
}
|
|
8
|
+
function defineStylePipeline(options) {
|
|
9
|
+
return options;
|
|
10
|
+
}
|
|
11
|
+
function defineStylePipelinePlugins(plugins) {
|
|
12
|
+
return plugins;
|
|
13
|
+
}
|
|
14
|
+
function resolveStylePipelinePlugins(options, workspaceRoot) {
|
|
15
|
+
if (!options?.plugins?.length) return [];
|
|
16
|
+
const context = { workspaceRoot: workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd() };
|
|
17
|
+
const resolved = [];
|
|
18
|
+
for (const entry of options.plugins) {
|
|
19
|
+
const plugins = typeof entry === "function" ? entry(context) : entry;
|
|
20
|
+
if (!plugins) continue;
|
|
21
|
+
if (Array.isArray(plugins)) {
|
|
22
|
+
resolved.push(...plugins);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
resolved.push(plugins);
|
|
26
|
+
}
|
|
27
|
+
return resolved;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { defineAngularStylePipeline, defineAngularStylePipelinePlugins, defineStylePipeline, defineStylePipelinePlugins, resolveStylePipelinePlugins };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=style-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-pipeline.js","names":[],"sources":["../../../src/lib/style-pipeline.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type {\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './style-preprocessor.js';\n\nexport interface StylePipelineStylesheetRegistry {\n getPublicIdsForSource(sourcePath: string): string[];\n getRequestIdsForSource(sourcePath: string): string[];\n getDependenciesForSource(sourcePath: string): StylesheetDependency[];\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];\n getTagsForSource(sourcePath: string): string[];\n}\n\nexport interface AngularStylePipelineContext {\n workspaceRoot: string;\n}\n\nexport interface AngularStylePipelinePlugin {\n name: string;\n preprocessStylesheet?: (\n code: string,\n context: StylesheetTransformContext,\n ) => string | StylesheetTransformResult | undefined;\n configureStylesheetRegistry?: (\n registry: StylePipelineStylesheetRegistry,\n context: AngularStylePipelineContext,\n ) => void;\n}\n\nexport interface AngularStylePipelineOptions {\n plugins: AngularStylePipelinePlugin[];\n}\n\nexport function defineAngularStylePipeline<\n const T extends AngularStylePipelineOptions,\n>(options: T): T {\n return options;\n}\n\nexport function defineAngularStylePipelinePlugins<\n const T extends AngularStylePipelinePlugin[],\n>(plugins: T): T {\n return plugins;\n}\n\nexport interface StylePipelineContext {\n workspaceRoot: string;\n}\n\nexport type StylePipelinePluginFactory = (\n context: StylePipelineContext,\n) => Plugin | Plugin[] | false | null | undefined;\n\nexport type StylePipelinePluginEntry =\n | Plugin\n | Plugin[]\n | StylePipelinePluginFactory\n | false\n | null\n | undefined;\n\nexport interface StylePipelineOptions {\n plugins?: StylePipelinePluginEntry[];\n}\n\nexport function defineStylePipeline<const T extends StylePipelineOptions>(\n options: T,\n): T {\n return options;\n}\n\nexport function defineStylePipelinePlugins<\n const T extends StylePipelinePluginEntry[],\n>(plugins: T): T {\n return plugins;\n}\n\nexport function resolveStylePipelinePlugins(\n options: StylePipelineOptions | false | undefined,\n workspaceRoot?: string,\n): Plugin[] {\n if (!options?.plugins?.length) {\n return [];\n }\n\n const context: StylePipelineContext = {\n workspaceRoot:\n workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd(),\n };\n\n const resolved: Plugin[] = [];\n\n for (const entry of options.plugins) {\n const plugins = typeof entry === 'function' ? entry(context) : entry;\n\n if (!plugins) {\n continue;\n }\n\n if (Array.isArray(plugins)) {\n resolved.push(...plugins);\n continue;\n }\n\n resolved.push(plugins);\n }\n\n return resolved;\n}\n"],"mappings":";AAoCA,SAAgB,2BAEd,SAAe;AACf,QAAO;;AAGT,SAAgB,kCAEd,SAAe;AACf,QAAO;;AAuBT,SAAgB,oBACd,SACG;AACH,QAAO;;AAGT,SAAgB,2BAEd,SAAe;AACf,QAAO;;AAGT,SAAgB,4BACd,SACA,eACU;AACV,KAAI,CAAC,SAAS,SAAS,OACrB,QAAO,EAAE;CAGX,MAAM,UAAgC,EACpC,eACE,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK,EACrE;CAED,MAAM,WAAqB,EAAE;AAE7B,MAAK,MAAM,SAAS,QAAQ,SAAS;EACnC,MAAM,UAAU,OAAO,UAAU,aAAa,MAAM,QAAQ,GAAG;AAE/D,MAAI,CAAC,QACH;AAGF,MAAI,MAAM,QAAQ,QAAQ,EAAE;AAC1B,YAAS,KAAK,GAAG,QAAQ;AACzB;;AAGF,WAAS,KAAK,QAAQ;;AAGxB,QAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface StylesheetTransformContext {
|
|
2
|
+
filename: string;
|
|
3
|
+
containingFile?: string;
|
|
4
|
+
resourceFile?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
order?: number;
|
|
7
|
+
inline: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface StylesheetDependency {
|
|
10
|
+
id: string;
|
|
11
|
+
kind?: "file" | "virtual" | "token" | "bridge" | "manifest" | "runtime";
|
|
12
|
+
owner?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface StylesheetDiagnostic {
|
|
15
|
+
severity: "warning" | "error";
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface StylesheetTransformResult {
|
|
20
|
+
code: string;
|
|
21
|
+
dependencies?: Array<string | StylesheetDependency>;
|
|
22
|
+
diagnostics?: StylesheetDiagnostic[];
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}
|
|
25
|
+
export type StylePreprocessor = (code: string, filename: string, context?: StylesheetTransformContext) => string | StylesheetTransformResult;
|
|
26
|
+
export declare function normalizeStylesheetTransformResult(value: string | StylesheetTransformResult | undefined, fallbackCode: string): StylesheetTransformResult;
|
|
27
|
+
export declare function normalizeStylesheetDependencies(dependencies: Array<string | StylesheetDependency> | undefined): StylesheetDependency[];
|
|
28
|
+
export declare function composeStylePreprocessors(preprocessors: Array<StylePreprocessor | false | null | undefined>): StylePreprocessor | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region packages/platform/src/lib/style-preprocessor.ts
|
|
2
|
+
function normalizeStylesheetTransformResult(value, fallbackCode) {
|
|
3
|
+
if (value == null) return { code: fallbackCode };
|
|
4
|
+
if (typeof value === "string") return { code: value };
|
|
5
|
+
return {
|
|
6
|
+
code: value.code ?? fallbackCode,
|
|
7
|
+
dependencies: normalizeStylesheetDependencies(value.dependencies),
|
|
8
|
+
diagnostics: value.diagnostics ?? [],
|
|
9
|
+
tags: value.tags ?? []
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function normalizeStylesheetDependencies(dependencies) {
|
|
13
|
+
return (dependencies ?? []).map((dependency) => typeof dependency === "string" ? { id: dependency } : dependency);
|
|
14
|
+
}
|
|
15
|
+
function composeStylePreprocessors(preprocessors) {
|
|
16
|
+
const active = preprocessors.filter((preprocessor) => !!preprocessor);
|
|
17
|
+
if (!active.length) return;
|
|
18
|
+
return (code, filename, context) => {
|
|
19
|
+
let current = normalizeStylesheetTransformResult(void 0, code);
|
|
20
|
+
for (const preprocessor of active) {
|
|
21
|
+
const next = normalizeStylesheetTransformResult(preprocessor(current.code, filename, context), current.code);
|
|
22
|
+
current = {
|
|
23
|
+
code: next.code,
|
|
24
|
+
dependencies: [...current.dependencies ?? [], ...next.dependencies ?? []],
|
|
25
|
+
diagnostics: [...current.diagnostics ?? [], ...next.diagnostics ?? []],
|
|
26
|
+
tags: [...current.tags ?? [], ...next.tags ?? []]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return current;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { composeStylePreprocessors, normalizeStylesheetDependencies, normalizeStylesheetTransformResult };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=style-preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-preprocessor.js","names":[],"sources":["../../../src/lib/style-preprocessor.ts"],"sourcesContent":["export interface StylesheetTransformContext {\n filename: string;\n containingFile?: string;\n resourceFile?: string;\n className?: string;\n order?: number;\n inline: boolean;\n}\n\nexport interface StylesheetDependency {\n id: string;\n kind?: 'file' | 'virtual' | 'token' | 'bridge' | 'manifest' | 'runtime';\n owner?: string;\n}\n\nexport interface StylesheetDiagnostic {\n severity: 'warning' | 'error';\n code: string;\n message: string;\n}\n\nexport interface StylesheetTransformResult {\n code: string;\n dependencies?: Array<string | StylesheetDependency>;\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport type StylePreprocessor = (\n code: string,\n filename: string,\n context?: StylesheetTransformContext,\n) => string | StylesheetTransformResult;\n\nexport function normalizeStylesheetTransformResult(\n value: string | StylesheetTransformResult | undefined,\n fallbackCode: string,\n): StylesheetTransformResult {\n if (value == null) {\n return { code: fallbackCode };\n }\n\n if (typeof value === 'string') {\n return { code: value };\n }\n\n return {\n code: value.code ?? fallbackCode,\n dependencies: normalizeStylesheetDependencies(value.dependencies),\n diagnostics: value.diagnostics ?? [],\n tags: value.tags ?? [],\n };\n}\n\nexport function normalizeStylesheetDependencies(\n dependencies: Array<string | StylesheetDependency> | undefined,\n): StylesheetDependency[] {\n return (dependencies ?? []).map((dependency) =>\n typeof dependency === 'string' ? { id: dependency } : dependency,\n );\n}\n\nexport function composeStylePreprocessors(\n preprocessors: Array<StylePreprocessor | false | null | undefined>,\n): StylePreprocessor | undefined {\n const active = preprocessors.filter(\n (preprocessor): preprocessor is StylePreprocessor => !!preprocessor,\n );\n\n if (!active.length) {\n return undefined;\n }\n\n return (code, filename, context) => {\n let current = normalizeStylesheetTransformResult(undefined, code);\n\n for (const preprocessor of active) {\n const next = normalizeStylesheetTransformResult(\n preprocessor(current.code, filename, context),\n current.code,\n );\n current = {\n code: next.code,\n dependencies: [\n ...(current.dependencies ?? []),\n ...(next.dependencies ?? []),\n ],\n diagnostics: [\n ...(current.diagnostics ?? []),\n ...(next.diagnostics ?? []),\n ],\n tags: [...(current.tags ?? []), ...(next.tags ?? [])],\n };\n }\n\n return current;\n };\n}\n"],"mappings":";AAkCA,SAAgB,mCACd,OACA,cAC2B;AAC3B,KAAI,SAAS,KACX,QAAO,EAAE,MAAM,cAAc;AAG/B,KAAI,OAAO,UAAU,SACnB,QAAO,EAAE,MAAM,OAAO;AAGxB,QAAO;EACL,MAAM,MAAM,QAAQ;EACpB,cAAc,gCAAgC,MAAM,aAAa;EACjE,aAAa,MAAM,eAAe,EAAE;EACpC,MAAM,MAAM,QAAQ,EAAE;EACvB;;AAGH,SAAgB,gCACd,cACwB;AACxB,SAAQ,gBAAgB,EAAE,EAAE,KAAK,eAC/B,OAAO,eAAe,WAAW,EAAE,IAAI,YAAY,GAAG,WACvD;;AAGH,SAAgB,0BACd,eAC+B;CAC/B,MAAM,SAAS,cAAc,QAC1B,iBAAoD,CAAC,CAAC,aACxD;AAED,KAAI,CAAC,OAAO,OACV;AAGF,SAAQ,MAAM,UAAU,YAAY;EAClC,IAAI,UAAU,mCAAmC,KAAA,GAAW,KAAK;AAEjE,OAAK,MAAM,gBAAgB,QAAQ;GACjC,MAAM,OAAO,mCACX,aAAa,QAAQ,MAAM,UAAU,QAAQ,EAC7C,QAAQ,KACT;AACD,aAAU;IACR,MAAM,KAAK;IACX,cAAc,CACZ,GAAI,QAAQ,gBAAgB,EAAE,EAC9B,GAAI,KAAK,gBAAgB,EAAE,CAC5B;IACD,aAAa,CACX,GAAI,QAAQ,eAAe,EAAE,EAC7B,GAAI,KAAK,eAAe,EAAE,CAC3B;IACD,MAAM,CAAC,GAAI,QAAQ,QAAQ,EAAE,EAAG,GAAI,KAAK,QAAQ,EAAE,CAAE;IACtD;;AAGH,SAAO"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
2
|
+
export type TailwindPreprocessorMode = "auto" | "disabled" | {
|
|
3
|
+
prefix: string;
|
|
4
|
+
};
|
|
5
|
+
export interface TailwindPreprocessorOptions {
|
|
6
|
+
/** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */
|
|
7
|
+
tailwindRootCss: string;
|
|
8
|
+
/**
|
|
9
|
+
* Controls whether the preprocessor auto-detects, disables, or manually
|
|
10
|
+
* overrides the Tailwind prefix for a given file.
|
|
11
|
+
*/
|
|
12
|
+
mode?: TailwindPreprocessorMode | ((filename: string) => TailwindPreprocessorMode);
|
|
13
|
+
/**
|
|
14
|
+
* Optional predicate to override the default `@reference` injection behavior.
|
|
15
|
+
*/
|
|
16
|
+
shouldInject?: (code: string, filename: string, resolvedPrefix: string | null) => boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`
|
|
20
|
+
* directives into Angular component styles when needed. The Tailwind prefix is
|
|
21
|
+
* detected from the configured root CSS file.
|
|
22
|
+
*/
|
|
23
|
+
export declare function tailwindPreprocessor(options: TailwindPreprocessorOptions): StylePreprocessor;
|