@analogjs/platform 3.0.0-alpha.5 → 3.0.0-alpha.50
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/package.json +29 -19
- package/src/index.d.ts +9 -2
- package/src/index.js +11 -3
- package/src/index.js.map +1 -0
- package/src/lib/clear-client-page-endpoint.d.ts +2 -2
- package/src/lib/clear-client-page-endpoint.js +22 -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 +80 -82
- package/src/lib/deps-plugin.js.map +1 -0
- package/src/lib/discover-library-routes.d.ts +13 -0
- package/src/lib/discover-library-routes.js +64 -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/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/nx-plugin/builders.json +7 -0
- package/src/lib/nx-plugin/executors.json +5 -0
- 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/executors/vite/compat.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite/compat.js +6 -7
- package/src/lib/nx-plugin/src/executors/vite/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +5 -4
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +1 -1
- 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 +6 -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 +5 -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 +6 -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 +5 -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 +17 -7
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- 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 +78 -92
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- 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 +72 -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 +24 -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 +15 -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 +14 -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 +18 -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 +60 -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 +14 -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/versions/minimum-supported-versions.d.ts +2 -3
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +6 -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 +17 -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 +54 -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 +19 -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 +20 -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 +56 -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 +17 -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 +12 -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 +19 -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 +43 -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 +27 -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 +19 -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 +18 -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 +34 -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 +5 -4
- package/src/lib/nx-plugin/src/generators/preset/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/preset/generator.js +17 -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 +17 -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 +32 -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 +7 -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 +20 -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 +19 -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 +20 -27
- package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js +42 -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 +49 -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 +8 -8
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +37 -23
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
- package/src/lib/options.d.ts +306 -80
- package/src/lib/platform-plugin.d.ts +2 -2
- package/src/lib/platform-plugin.js +91 -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 -150
- package/src/lib/router-plugin.js.map +1 -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 +31 -2
- package/src/lib/ssr/ssr-build-plugin.js +54 -30
- package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
- package/src/lib/style-pipeline.d.ts +34 -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/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
|
@@ -1,31 +1,55 @@
|
|
|
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
|
+
import { createRequire } from "node:module";
|
|
3
|
+
//#region packages/platform/src/lib/ssr/ssr-build-plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* SSR build patches for Angular platform-server, Zone.js, and Domino.
|
|
6
|
+
*
|
|
7
|
+
* Returns an array of Vite plugins because under Vite 8+ (Rolldown) we
|
|
8
|
+
* append Rolldown's built-in `replacePlugin` for an AST-safe
|
|
9
|
+
* `global → globalThis` rewrite that avoids false positives inside string
|
|
10
|
+
* literals and comments.
|
|
11
|
+
*
|
|
12
|
+
* **Why each patch exists:**
|
|
13
|
+
* - zone-node: removes a `const global = globalThis` alias that shadows the
|
|
14
|
+
* real global in strict mode.
|
|
15
|
+
* - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and
|
|
16
|
+
* replaces bare `global` references with `globalThis`.
|
|
17
|
+
* - xhr2: strips Node-specific `os`/`process` references for SSR bundling.
|
|
18
|
+
* - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.
|
|
19
|
+
*/
|
|
20
|
+
function ssrBuildPlugin() {
|
|
21
|
+
const plugins = [{
|
|
22
|
+
name: "analogjs-ssr-build-plugin",
|
|
23
|
+
apply: "build",
|
|
24
|
+
config() {
|
|
25
|
+
return { ssr: { noExternal: ["xhr2"] } };
|
|
26
|
+
},
|
|
27
|
+
transform: {
|
|
28
|
+
filter: { id: /zone-node|platform-server|xhr2\.js|domino\/lib\/sloppy\.js/ },
|
|
29
|
+
handler(code, id) {
|
|
30
|
+
if (id.includes("zone-node") && code.includes("const global = globalThis;")) return { code: code.replace("const global = globalThis;", "") };
|
|
31
|
+
if (id.includes("platform-server")) {
|
|
32
|
+
let result = code.replace("new xhr2.XMLHttpRequest", "new (xhr2.default.XMLHttpRequest || xhr2.default)");
|
|
33
|
+
if (!vite.rolldownVersion) result = result.replaceAll("global.", "globalThis.").replaceAll("global,", "globalThis,").replaceAll(" global[", " globalThis[");
|
|
34
|
+
return { code: result };
|
|
35
|
+
}
|
|
36
|
+
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'`) };
|
|
37
|
+
if (id.includes(vite.normalizePath("domino/lib/sloppy.js"))) return { code: code.replace(/with\(/gi, "if(") };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
if (vite.rolldownVersion) {
|
|
42
|
+
const require = createRequire(import.meta.url);
|
|
43
|
+
const { replacePlugin } = require("rolldown/plugins");
|
|
44
|
+
const { withFilter } = require("rolldown/filter");
|
|
45
|
+
plugins.push(withFilter(replacePlugin({ global: "globalThis" }, {
|
|
46
|
+
preventAssignment: true,
|
|
47
|
+
objectGuards: true
|
|
48
|
+
}), { transform: { id: /platform-server/ } }));
|
|
49
|
+
}
|
|
50
|
+
return plugins;
|
|
30
51
|
}
|
|
31
|
-
//#
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ssrBuildPlugin };
|
|
54
|
+
|
|
55
|
+
//# 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 { createRequire } from 'node:module';\nimport * as vite from 'vite';\n\n/**\n * SSR build patches for Angular platform-server, Zone.js, and Domino.\n *\n * Returns an array of Vite plugins because under Vite 8+ (Rolldown) we\n * append Rolldown's built-in `replacePlugin` for an AST-safe\n * `global → globalThis` rewrite that avoids false positives inside string\n * literals and comments.\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 // Under Vite 8+ the appended `replacePlugin` handles\n // global → globalThis via AST-aware replacement (scoped to\n // platform-server by `withFilter`). For Vite ≤7 we fall back\n // to text-based replaceAll — imprecise but sufficient for the\n // known occurrences in @angular/platform-server bundles.\n if (!vite.rolldownVersion) {\n result = result\n .replaceAll('global.', 'globalThis.')\n .replaceAll('global,', 'globalThis,')\n .replaceAll(' global[', ' globalThis[');\n }\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 // Under Vite 8+ (Rolldown), append Rolldown's built-in `replacePlugin`\n // for AST-aware `global → globalThis` rewriting scoped to platform-server.\n //\n // `createRequire` is used instead of dynamic `import()` because this code\n // runs synchronously during plugin construction (not inside an async hook).\n // Rolldown is guaranteed to be installed when `vite.rolldownVersion` is truthy.\n if (vite.rolldownVersion) {\n const require = createRequire(import.meta.url);\n const { replacePlugin } =\n require('rolldown/plugins') as typeof import('rolldown/plugins');\n const { withFilter } =\n require('rolldown/filter') as typeof import('rolldown/filter');\n\n plugins.push(\n withFilter(\n replacePlugin(\n { global: 'globalThis' },\n { preventAssignment: true, objectGuards: true },\n ),\n { transform: { id: /platform-server/ } },\n ) as unknown as vite.Plugin,\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":";;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAgC;CAC9C,MAAM,UAAyB,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,SAAI,CAAC,KAAK,gBACR,UAAS,OACN,WAAW,WAAW,cAAc,CACpC,WAAW,WAAW,cAAc,CACpC,WAAW,YAAY,eAAe;AAG3C,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;AAQD,KAAI,KAAK,iBAAiB;EACxB,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;EAC9C,MAAM,EAAE,kBACN,QAAQ,mBAAmB;EAC7B,MAAM,EAAE,eACN,QAAQ,kBAAkB;AAE5B,UAAQ,KACN,WACE,cACE,EAAE,QAAQ,cAAc,EACxB;GAAE,mBAAmB;GAAM,cAAc;GAAM,CAChD,EACD,EAAE,WAAW,EAAE,IAAI,mBAAmB,EAAE,CACzC,CACF;;AAGH,QAAO"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
angularPlugins?: AngularStylePipelinePlugin[];
|
|
31
|
+
}
|
|
32
|
+
export declare function defineStylePipeline<const T extends StylePipelineOptions>(options: T): T;
|
|
33
|
+
export declare function defineStylePipelinePlugins<const T extends StylePipelinePluginEntry[]>(plugins: T): T;
|
|
34
|
+
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 angularPlugins?: AngularStylePipelinePlugin[];\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;;AAwBT,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;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { debugTailwind } from "./utils/debug.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
//#region packages/platform/src/lib/tailwind-preprocessor.ts
|
|
5
|
+
var PLATFORM_TAILWIND_PREFIX = "[@analogjs/platform]";
|
|
6
|
+
var CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\n\r])\s*@reference\b/m;
|
|
7
|
+
var CSS_TAILWIND_IMPORT_REGEX = /(^|[;}\n\r])\s*@import\s+["']tailwindcss["']/m;
|
|
8
|
+
function stripCssBlockComments(code) {
|
|
9
|
+
let result = "";
|
|
10
|
+
let quote = null;
|
|
11
|
+
for (let index = 0; index < code.length; index++) {
|
|
12
|
+
const character = code[index];
|
|
13
|
+
const nextCharacter = code[index + 1];
|
|
14
|
+
if (quote) {
|
|
15
|
+
if (character === "\\" && nextCharacter) {
|
|
16
|
+
result += character;
|
|
17
|
+
result += nextCharacter;
|
|
18
|
+
index++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (character === quote) quote = null;
|
|
22
|
+
result += character;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (character === "\"" || character === "'" || character === "`") {
|
|
26
|
+
quote = character;
|
|
27
|
+
result += character;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (character === "/" && nextCharacter === "*") {
|
|
31
|
+
result += " ";
|
|
32
|
+
index += 2;
|
|
33
|
+
while (index < code.length) {
|
|
34
|
+
const commentCharacter = code[index];
|
|
35
|
+
const commentNextCharacter = code[index + 1];
|
|
36
|
+
if (commentCharacter === "*" && commentNextCharacter === "/") {
|
|
37
|
+
result += " ";
|
|
38
|
+
index++;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
result += commentCharacter === "\n" || commentCharacter === "\r" ? commentCharacter : " ";
|
|
42
|
+
index++;
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
result += character;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function hasReferenceTextInComments(code) {
|
|
51
|
+
let quote = null;
|
|
52
|
+
for (let index = 0; index < code.length; index++) {
|
|
53
|
+
const character = code[index];
|
|
54
|
+
const nextCharacter = code[index + 1];
|
|
55
|
+
if (quote) {
|
|
56
|
+
if (character === "\\" && nextCharacter) {
|
|
57
|
+
index++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (character === quote) quote = null;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (character === "\"" || character === "'" || character === "`") {
|
|
64
|
+
quote = character;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (character === "/" && nextCharacter === "*") {
|
|
68
|
+
const commentStart = index + 2;
|
|
69
|
+
index += 2;
|
|
70
|
+
while (index < code.length) {
|
|
71
|
+
const commentCharacter = code[index];
|
|
72
|
+
const commentNextCharacter = code[index + 1];
|
|
73
|
+
if (commentCharacter === "*" && commentNextCharacter === "/") break;
|
|
74
|
+
index++;
|
|
75
|
+
}
|
|
76
|
+
if (code.slice(commentStart, index).includes("@reference")) return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
function inspectCssTailwindDirectives(code) {
|
|
82
|
+
const commentlessCode = stripCssBlockComments(code);
|
|
83
|
+
return {
|
|
84
|
+
commentlessCode,
|
|
85
|
+
hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),
|
|
86
|
+
hasReferenceText: hasReferenceTextInComments(code),
|
|
87
|
+
hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function toReferenceSpecifier(filename, tailwindRootCss) {
|
|
91
|
+
const fromDir = path.posix.dirname(filename.replace(/\\/g, "/"));
|
|
92
|
+
const toFile = tailwindRootCss.replace(/\\/g, "/");
|
|
93
|
+
const relativePath = path.posix.relative(fromDir, toFile);
|
|
94
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
95
|
+
}
|
|
96
|
+
function throwTailwindReferenceTextError(filename, referenceSpecifier) {
|
|
97
|
+
throw new Error(`${PLATFORM_TAILWIND_PREFIX} Tailwind @reference auto-injection was blocked for "${filename}" because the stylesheet contains the text "@reference" but does not contain a real @reference directive.\n\nThis is usually caused by a CSS comment such as "/* ... @reference ... */".\n\nFix one of:\n - Reword the comment so it does not contain "@reference"\n - Add a real @reference "${referenceSpecifier}"; directive\n`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`
|
|
101
|
+
* directives into Angular component styles when needed. The Tailwind prefix is
|
|
102
|
+
* detected from the configured root CSS file.
|
|
103
|
+
*/
|
|
104
|
+
function tailwindPreprocessor(options) {
|
|
105
|
+
const { tailwindRootCss, mode: modeOption = "auto", shouldInject } = options;
|
|
106
|
+
let rootPrefix;
|
|
107
|
+
debugTailwind("configured", {
|
|
108
|
+
tailwindRootCss,
|
|
109
|
+
mode: modeOption
|
|
110
|
+
});
|
|
111
|
+
return (code, filename) => {
|
|
112
|
+
const directiveState = inspectCssTailwindDirectives(code);
|
|
113
|
+
if (directiveState.hasReferenceDirective) {
|
|
114
|
+
debugTailwind("skip (already has @reference)", { filename });
|
|
115
|
+
return code;
|
|
116
|
+
}
|
|
117
|
+
const resolvedMode = typeof modeOption === "function" ? modeOption(filename) : modeOption;
|
|
118
|
+
if (resolvedMode === "disabled") {
|
|
119
|
+
debugTailwind("skip (mode disabled)", { filename });
|
|
120
|
+
return code;
|
|
121
|
+
}
|
|
122
|
+
const resolvedPrefix = typeof resolvedMode === "object" ? resolvedMode.prefix : getRootPrefix();
|
|
123
|
+
const isRootFile = path.resolve(filename) === path.resolve(tailwindRootCss) || directiveState.hasTailwindImportDirective;
|
|
124
|
+
const hasTailwindUsage = resolvedPrefix ? directiveState.commentlessCode.includes(`${resolvedPrefix}:`) : false;
|
|
125
|
+
if (!(shouldInject ? shouldInject(code, filename, resolvedPrefix) : hasTailwindUsage && !isRootFile) || !resolvedPrefix) {
|
|
126
|
+
debugTailwind("skip (no injection needed)", {
|
|
127
|
+
filename,
|
|
128
|
+
resolvedPrefix,
|
|
129
|
+
isRootFile,
|
|
130
|
+
hasTailwindUsage
|
|
131
|
+
});
|
|
132
|
+
return code;
|
|
133
|
+
}
|
|
134
|
+
const refPath = toReferenceSpecifier(filename, tailwindRootCss);
|
|
135
|
+
if (directiveState.hasReferenceText) throwTailwindReferenceTextError(filename, refPath);
|
|
136
|
+
debugTailwind("injected @reference", {
|
|
137
|
+
filename,
|
|
138
|
+
refPath
|
|
139
|
+
});
|
|
140
|
+
return `@reference "${refPath}";\n${code}`;
|
|
141
|
+
};
|
|
142
|
+
function getRootPrefix() {
|
|
143
|
+
if (rootPrefix === void 0) rootPrefix = extractTailwindPrefix(readFileSync(tailwindRootCss, "utf-8"));
|
|
144
|
+
return rootPrefix;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function extractTailwindPrefix(code) {
|
|
148
|
+
return code.match(/@import\s+["']tailwindcss["']\s+prefix\(\s*([^)\s;]+)\s*\)/i)?.[1]?.trim() ?? null;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { tailwindPreprocessor };
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=tailwind-preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind-preprocessor.js","names":[],"sources":["../../../src/lib/tailwind-preprocessor.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { debugTailwind } from './utils/debug.js';\n\nexport type TailwindPreprocessorMode = 'auto' | 'disabled' | { prefix: string };\nconst PLATFORM_TAILWIND_PREFIX = '[@analogjs/platform]';\nconst CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\\n\\r])\\s*@reference\\b/m;\nconst CSS_TAILWIND_IMPORT_REGEX =\n /(^|[;}\\n\\r])\\s*@import\\s+[\"']tailwindcss[\"']/m;\n\ninterface CssTailwindDirectiveState {\n commentlessCode: string;\n hasReferenceDirective: boolean;\n hasReferenceText: boolean;\n hasTailwindImportDirective: boolean;\n}\n\n// Mask real block comments while preserving quoted CSS content. This keeps\n// prose like `/* add @reference here */` from disabling injection without\n// mistaking `/* ... */` sequences inside strings for real comments.\nfunction stripCssBlockComments(code: string): string {\n let result = '';\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n result += character;\n result += nextCharacter;\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n result += character;\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n result += character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n result += ' ';\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n result += ' ';\n index++;\n break;\n }\n\n result +=\n commentCharacter === '\\n' || commentCharacter === '\\r'\n ? commentCharacter\n : ' ';\n index++;\n }\n continue;\n }\n\n result += character;\n }\n\n return result;\n}\n\nfunction hasReferenceTextInComments(code: string): boolean {\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n const commentStart = index + 2;\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n break;\n }\n index++;\n }\n\n if (code.slice(commentStart, index).includes('@reference')) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction inspectCssTailwindDirectives(code: string): CssTailwindDirectiveState {\n const commentlessCode = stripCssBlockComments(code);\n\n return {\n commentlessCode,\n hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),\n hasReferenceText: hasReferenceTextInComments(code),\n hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode),\n };\n}\n\nfunction toReferenceSpecifier(\n filename: string,\n tailwindRootCss: string,\n): string {\n const fromDir = path.posix.dirname(filename.replace(/\\\\/g, '/'));\n const toFile = tailwindRootCss.replace(/\\\\/g, '/');\n const relativePath = path.posix.relative(fromDir, toFile);\n\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;\n}\n\nfunction throwTailwindReferenceTextError(\n filename: string,\n referenceSpecifier: string,\n): never {\n throw new Error(\n `${PLATFORM_TAILWIND_PREFIX} Tailwind @reference auto-injection was ` +\n `blocked for \"${filename}\" because the stylesheet contains the ` +\n `text \"@reference\" but does not contain a real @reference ` +\n `directive.\\n\\n` +\n `This is usually caused by a CSS comment such as ` +\n `\"/* ... @reference ... */\".\\n\\n` +\n `Fix one of:\\n` +\n ` - Reword the comment so it does not contain \"@reference\"\\n` +\n ` - Add a real @reference \"${referenceSpecifier}\"; directive\\n`,\n );\n}\n\nexport interface TailwindPreprocessorOptions {\n /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */\n tailwindRootCss: string;\n\n /**\n * Controls whether the preprocessor auto-detects, disables, or manually\n * overrides the Tailwind prefix for a given file.\n */\n mode?:\n | TailwindPreprocessorMode\n | ((filename: string) => TailwindPreprocessorMode);\n\n /**\n * Optional predicate to override the default `@reference` injection behavior.\n */\n shouldInject?: (\n code: string,\n filename: string,\n resolvedPrefix: string | null,\n ) => boolean;\n}\n\n/**\n * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`\n * directives into Angular component styles when needed. The Tailwind prefix is\n * detected from the configured root CSS file.\n */\nexport function tailwindPreprocessor(\n options: TailwindPreprocessorOptions,\n): StylePreprocessor {\n const { tailwindRootCss, mode: modeOption = 'auto', shouldInject } = options;\n let rootPrefix: string | undefined;\n\n debugTailwind('configured', { tailwindRootCss, mode: modeOption });\n\n return (code: string, filename: string): string => {\n const directiveState = inspectCssTailwindDirectives(code);\n\n if (directiveState.hasReferenceDirective) {\n debugTailwind('skip (already has @reference)', { filename });\n return code;\n }\n\n const resolvedMode =\n typeof modeOption === 'function' ? modeOption(filename) : modeOption;\n\n if (resolvedMode === 'disabled') {\n debugTailwind('skip (mode disabled)', { filename });\n return code;\n }\n\n const resolvedPrefix =\n typeof resolvedMode === 'object' ? resolvedMode.prefix : getRootPrefix();\n const isRootFile =\n path.resolve(filename) === path.resolve(tailwindRootCss) ||\n directiveState.hasTailwindImportDirective;\n const hasTailwindUsage = resolvedPrefix\n ? directiveState.commentlessCode.includes(`${resolvedPrefix}:`)\n : false;\n const shouldAddReference = shouldInject\n ? shouldInject(code, filename, resolvedPrefix)\n : hasTailwindUsage && !isRootFile;\n\n if (!shouldAddReference || !resolvedPrefix) {\n debugTailwind('skip (no injection needed)', {\n filename,\n resolvedPrefix,\n isRootFile,\n hasTailwindUsage,\n });\n return code;\n }\n\n const refPath = toReferenceSpecifier(filename, tailwindRootCss);\n if (directiveState.hasReferenceText) {\n throwTailwindReferenceTextError(filename, refPath);\n }\n\n debugTailwind('injected @reference', { filename, refPath });\n\n return `@reference \"${refPath}\";\\n${code}`;\n };\n\n function getRootPrefix(): string | null {\n if (rootPrefix === undefined) {\n rootPrefix = extractTailwindPrefix(\n readFileSync(tailwindRootCss, 'utf-8'),\n );\n }\n\n return rootPrefix;\n }\n}\n\nfunction extractTailwindPrefix(code: string): string | null {\n const prefixMatch = code.match(\n /@import\\s+[\"']tailwindcss[\"']\\s+prefix\\(\\s*([^)\\s;]+)\\s*\\)/i,\n );\n\n return prefixMatch?.[1]?.trim() ?? null;\n}\n"],"mappings":";;;;AAOA,IAAM,2BAA2B;AACjC,IAAM,gCAAgC;AACtC,IAAM,4BACJ;AAYF,SAAS,sBAAsB,MAAsB;CACnD,IAAI,SAAS;CACb,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC,cAAU;AACV,cAAU;AACV;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV,aAAU;AACV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR,aAAU;AACV;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;AAC9C,aAAU;AACV,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,KAAK;AAC5D,eAAU;AACV;AACA;;AAGF,cACE,qBAAqB,QAAQ,qBAAqB,OAC9C,mBACA;AACN;;AAEF;;AAGF,YAAU;;AAGZ,QAAO;;AAGT,SAAS,2BAA2B,MAAuB;CACzD,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;GAC9C,MAAM,eAAe,QAAQ;AAC7B,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,IACvD;AAEF;;AAGF,OAAI,KAAK,MAAM,cAAc,MAAM,CAAC,SAAS,aAAa,CACxD,QAAO;;;AAKb,QAAO;;AAGT,SAAS,6BAA6B,MAAyC;CAC7E,MAAM,kBAAkB,sBAAsB,KAAK;AAEnD,QAAO;EACL;EACA,uBAAuB,8BAA8B,KAAK,gBAAgB;EAC1E,kBAAkB,2BAA2B,KAAK;EAClD,4BAA4B,0BAA0B,KAAK,gBAAgB;EAC5E;;AAGH,SAAS,qBACP,UACA,iBACQ;CACR,MAAM,UAAU,KAAK,MAAM,QAAQ,SAAS,QAAQ,OAAO,IAAI,CAAC;CAChE,MAAM,SAAS,gBAAgB,QAAQ,OAAO,IAAI;CAClD,MAAM,eAAe,KAAK,MAAM,SAAS,SAAS,OAAO;AAEzD,QAAO,aAAa,WAAW,IAAI,GAAG,eAAe,KAAK;;AAG5D,SAAS,gCACP,UACA,oBACO;AACP,OAAM,IAAI,MACR,GAAG,yBAAyB,uDACV,SAAS,kSAOK,mBAAmB,gBACpD;;;;;;;AA8BH,SAAgB,qBACd,SACmB;CACnB,MAAM,EAAE,iBAAiB,MAAM,aAAa,QAAQ,iBAAiB;CACrE,IAAI;AAEJ,eAAc,cAAc;EAAE;EAAiB,MAAM;EAAY,CAAC;AAElE,SAAQ,MAAc,aAA6B;EACjD,MAAM,iBAAiB,6BAA6B,KAAK;AAEzD,MAAI,eAAe,uBAAuB;AACxC,iBAAc,iCAAiC,EAAE,UAAU,CAAC;AAC5D,UAAO;;EAGT,MAAM,eACJ,OAAO,eAAe,aAAa,WAAW,SAAS,GAAG;AAE5D,MAAI,iBAAiB,YAAY;AAC/B,iBAAc,wBAAwB,EAAE,UAAU,CAAC;AACnD,UAAO;;EAGT,MAAM,iBACJ,OAAO,iBAAiB,WAAW,aAAa,SAAS,eAAe;EAC1E,MAAM,aACJ,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,gBAAgB,IACxD,eAAe;EACjB,MAAM,mBAAmB,iBACrB,eAAe,gBAAgB,SAAS,GAAG,eAAe,GAAG,GAC7D;AAKJ,MAAI,EAJuB,eACvB,aAAa,MAAM,UAAU,eAAe,GAC5C,oBAAoB,CAAC,eAEE,CAAC,gBAAgB;AAC1C,iBAAc,8BAA8B;IAC1C;IACA;IACA;IACA;IACD,CAAC;AACF,UAAO;;EAGT,MAAM,UAAU,qBAAqB,UAAU,gBAAgB;AAC/D,MAAI,eAAe,iBACjB,iCAAgC,UAAU,QAAQ;AAGpD,gBAAc,uBAAuB;GAAE;GAAU;GAAS,CAAC;AAE3D,SAAO,eAAe,QAAQ,MAAM;;CAGtC,SAAS,gBAA+B;AACtC,MAAI,eAAe,KAAA,EACjB,cAAa,sBACX,aAAa,iBAAiB,QAAQ,CACvC;AAGH,SAAO;;;AAIX,SAAS,sBAAsB,MAA6B;AAK1D,QAJoB,KAAK,MACvB,8DACD,GAEoB,IAAI,MAAM,IAAI"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Plugin } from "vite";
|
|
2
|
+
export interface TypedRoutesPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Output path for the single generated route module,
|
|
5
|
+
* relative to the app root.
|
|
6
|
+
*
|
|
7
|
+
* @default 'src/routeTree.gen.ts'
|
|
8
|
+
*/
|
|
9
|
+
outFile?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Workspace root used to resolve additional route/content directories.
|
|
12
|
+
*
|
|
13
|
+
* @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()
|
|
14
|
+
*/
|
|
15
|
+
workspaceRoot?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Additional page directories to scan for `.page.ts` files.
|
|
18
|
+
*/
|
|
19
|
+
additionalPagesDirs?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Additional content directories to scan for `.md` files.
|
|
22
|
+
*/
|
|
23
|
+
additionalContentDirs?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Include generated `routeJsonLdManifest` exports in the generated route file.
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
jsonLdManifest?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When true, compare generated output against the existing file and
|
|
32
|
+
* throw an error if they differ instead of writing. Useful for CI to
|
|
33
|
+
* detect stale checked-in route files.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
verify?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* When true, production builds fail after regenerating a stale checked-in
|
|
40
|
+
* route file. This preserves self-healing writes in development while making
|
|
41
|
+
* build-time freshness issues visible by default.
|
|
42
|
+
*
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
verifyOnBuild?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Vite plugin that generates a single typed route module for Analog file routes.
|
|
49
|
+
*/
|
|
50
|
+
export declare function typedRoutes(options?: TypedRoutesPluginOptions): Plugin;
|