@analogjs/platform 3.0.0-alpha.2 → 3.0.0-alpha.20
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 +13 -17
- package/src/index.d.ts +5 -2
- package/src/index.js +9 -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 -4
- 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.d.ts +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 +19 -28
- package/src/lib/content/shiki/index.js.map +1 -0
- package/src/lib/content/shiki/options.d.ts +7 -7
- package/src/lib/content/shiki/shiki-highlighter.d.ts +13 -13
- package/src/lib/content/shiki/shiki-highlighter.js +45 -44
- 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 +178 -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 +73 -82
- package/src/lib/deps-plugin.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/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/package.json +1 -5
- package/src/lib/nx-plugin/src/executors/vite/compat.d.ts +3 -2
- package/src/lib/nx-plugin/src/executors/vite/compat.js +6 -6
- 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 +3 -2
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +6 -6
- 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 +3 -2
- package/src/lib/nx-plugin/src/executors/vitest/compat.js +6 -6
- 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 -2
- package/src/lib/nx-plugin/src/generators/app/compat.js +17 -6
- 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 -0
- 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__ +0 -18
- 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__ +0 -18
- 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__ +0 -9
- package/src/lib/nx-plugin/src/generators/app/generator.d.ts +11 -11
- package/src/lib/nx-plugin/src/generators/app/generator.js +78 -88
- 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 -89
- 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 +15 -30
- 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 +3 -5
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +49 -147
- 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 -12
- 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 +4 -5
- 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 +0 -5
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +9 -16
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +7 -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 +9 -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 -2
- package/src/lib/nx-plugin/src/generators/init/compat.js +17 -6
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/init/generator.js +54 -55
- 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 -18
- 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 -57
- 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 -15
- 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 -12
- 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 -25
- 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 -45
- 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 -28
- 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 -17
- 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/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/generator.d.ts +3 -4
- package/src/lib/nx-plugin/src/generators/page/generator.js +33 -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 -3
- 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 -2
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +17 -6
- 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/generator.d.ts +3 -3
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +35 -32
- 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 -21
- 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 -19
- 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 -1
- package/src/lib/nx-plugin/src/utils/version-utils.d.ts +1 -1
- package/src/lib/nx-plugin/src/utils/version-utils.js +20 -18
- 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.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.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 +7 -7
- 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 +158 -80
- package/src/lib/platform-plugin.d.ts +2 -2
- package/src/lib/platform-plugin.js +67 -61
- 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 +34 -0
- package/src/lib/route-generation-plugin.js.map +1 -0
- package/src/lib/route-manifest.d.ts +118 -0
- package/src/lib/route-manifest.js +377 -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 +193 -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 +18 -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/tailwind-preprocessor.d.ts +23 -0
- package/src/lib/tailwind-preprocessor.js +33 -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 +204 -0
- package/src/lib/typed-routes-plugin.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/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/v2/postcss.config.cjs__template__ +0 -10
- package/src/lib/nx-plugin/src/generators/app/files/tailwind/v2/tailwind.config.cjs__template__ +0 -14
- package/src/lib/nx-plugin/src/generators/app/files/tailwind/v3/postcss.config.cjs__template__ +0 -10
- package/src/lib/nx-plugin/src/generators/app/files/tailwind/v3/tailwind.config.ts__template__ +0 -14
- 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 -107
- 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
package/src/lib/router-plugin.js
CHANGED
|
@@ -1,152 +1,195 @@
|
|
|
1
|
-
import { normalizePath } from
|
|
2
|
-
import { globSync } from
|
|
3
|
-
import { resolve } from
|
|
1
|
+
import { normalizePath } from "vite";
|
|
2
|
+
import { globSync } from "tinyglobby";
|
|
3
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
4
|
+
//#region packages/platform/src/lib/router-plugin.ts
|
|
4
5
|
/**
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
6
|
+
* Router plugin that handles route file discovery and hot module replacement.
|
|
7
|
+
*
|
|
8
|
+
* This plugin provides three main functionalities:
|
|
9
|
+
* 1. Route invalidation when files are added/deleted (HMR workaround)
|
|
10
|
+
* 2. Dynamic route file discovery and import generation
|
|
11
|
+
* 3. Content route file discovery for markdown and Analog content
|
|
12
|
+
*
|
|
13
|
+
* @param options Configuration options for the router plugin
|
|
14
|
+
* @returns Array of Vite plugins for route handling
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: This plugin uses tinyglobby for file discovery.
|
|
17
|
+
* Key behavior with { dot: true, absolute: true }:
|
|
18
|
+
* - Returns absolute paths for ALL discovered files
|
|
19
|
+
* - Path normalization is required to match expected output format
|
|
20
|
+
* - Files within project root must use relative paths in object keys
|
|
21
|
+
* - Files outside project root keep absolute paths in object keys
|
|
22
|
+
*/
|
|
23
|
+
function routerPlugin(options) {
|
|
24
|
+
const workspaceRoot = normalizePath(options?.workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd());
|
|
25
|
+
let config;
|
|
26
|
+
let root;
|
|
27
|
+
const normalizeWatchedDir = (dir) => {
|
|
28
|
+
const normalizedDir = normalizePath(dir.startsWith(`${workspaceRoot}/`) || dir === workspaceRoot ? dir : dir.startsWith("/") ? `${workspaceRoot}${dir}` : resolve(workspaceRoot, dir));
|
|
29
|
+
return normalizedDir.endsWith("/") ? normalizedDir.slice(0, -1) : normalizedDir;
|
|
30
|
+
};
|
|
31
|
+
const additionalPagesDirs = (options?.additionalPagesDirs || []).map((dir) => normalizeWatchedDir(dir));
|
|
32
|
+
const additionalContentDirs = (options?.additionalContentDirs || []).map((dir) => normalizeWatchedDir(dir));
|
|
33
|
+
const getRouteLikeDirs = () => [
|
|
34
|
+
...root ? [
|
|
35
|
+
normalizeWatchedDir(`${root}/app/routes`),
|
|
36
|
+
normalizeWatchedDir(`${root}/src/app/routes`),
|
|
37
|
+
normalizeWatchedDir(`${root}/src/app/pages`),
|
|
38
|
+
normalizeWatchedDir(`${root}/src/content`)
|
|
39
|
+
] : [],
|
|
40
|
+
"/app/routes",
|
|
41
|
+
"/src/app/routes",
|
|
42
|
+
"/src/app/pages",
|
|
43
|
+
"/src/content",
|
|
44
|
+
...additionalPagesDirs,
|
|
45
|
+
...additionalContentDirs
|
|
46
|
+
];
|
|
47
|
+
let routeFilesCache;
|
|
48
|
+
let contentRouteFilesCache;
|
|
49
|
+
let endpointFilesCache;
|
|
50
|
+
const isRouteLikeFile = (path) => {
|
|
51
|
+
const normalizedPath = normalizePath(path);
|
|
52
|
+
return getRouteLikeDirs().some((dir) => normalizedPath === dir || normalizedPath.startsWith(`${dir}/`));
|
|
53
|
+
};
|
|
54
|
+
const discoverRouteFiles = () => {
|
|
55
|
+
routeFilesCache ??= globSync([
|
|
56
|
+
`${root}/app/routes/**/*.ts`,
|
|
57
|
+
`${root}/src/app/routes/**/*.ts`,
|
|
58
|
+
`${root}/src/app/pages/**/*.page.ts`,
|
|
59
|
+
...additionalPagesDirs.map((dir) => `${dir}/**/*.page.ts`)
|
|
60
|
+
], {
|
|
61
|
+
dot: true,
|
|
62
|
+
absolute: true
|
|
63
|
+
});
|
|
64
|
+
return routeFilesCache;
|
|
65
|
+
};
|
|
66
|
+
const discoverContentRouteFiles = () => {
|
|
67
|
+
contentRouteFilesCache ??= globSync([
|
|
68
|
+
`${root}/src/app/routes/**/*.md`,
|
|
69
|
+
`${root}/src/app/pages/**/*.md`,
|
|
70
|
+
`${root}/src/content/**/*.md`,
|
|
71
|
+
...additionalContentDirs.map((dir) => `${dir}/**/*.md`)
|
|
72
|
+
], {
|
|
73
|
+
dot: true,
|
|
74
|
+
absolute: true
|
|
75
|
+
});
|
|
76
|
+
return contentRouteFilesCache;
|
|
77
|
+
};
|
|
78
|
+
const discoverEndpointFiles = () => {
|
|
79
|
+
endpointFilesCache ??= globSync([`${root}/src/app/pages/**/*.server.ts`, ...additionalPagesDirs.map((dir) => `${dir}/**/*.server.ts`)], {
|
|
80
|
+
dot: true,
|
|
81
|
+
absolute: true
|
|
82
|
+
});
|
|
83
|
+
return endpointFilesCache;
|
|
84
|
+
};
|
|
85
|
+
const invalidateDiscoveryCaches = () => {
|
|
86
|
+
routeFilesCache = void 0;
|
|
87
|
+
contentRouteFilesCache = void 0;
|
|
88
|
+
endpointFilesCache = void 0;
|
|
89
|
+
};
|
|
90
|
+
const getModuleKey = (module) => {
|
|
91
|
+
if (!root) return `/${normalizePath(relative(workspaceRoot, module))}`;
|
|
92
|
+
const relToRoot = normalizePath(relative(root, module));
|
|
93
|
+
if (!relToRoot.startsWith("..") && !isAbsolute(relToRoot)) return `/${relToRoot}`;
|
|
94
|
+
return `/${normalizePath(relative(workspaceRoot, module))}`;
|
|
95
|
+
};
|
|
96
|
+
const invalidateFileModules = (server, path) => {
|
|
97
|
+
const normalizedPath = normalizePath(path);
|
|
98
|
+
(server.moduleGraph.getModulesByFile?.(normalizedPath) ?? server.moduleGraph.fileToModulesMap.get(normalizedPath))?.forEach((mod) => {
|
|
99
|
+
server.moduleGraph.invalidateModule(mod);
|
|
100
|
+
mod.importers.forEach((imp) => {
|
|
101
|
+
server.moduleGraph.invalidateModule(imp);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
name: "analogjs-router-invalidate-routes",
|
|
108
|
+
configureServer(server) {
|
|
109
|
+
/**
|
|
110
|
+
* Invalidates route modules when files are added or deleted.
|
|
111
|
+
* This is a workaround for Vite's HMR limitations with dynamic imports.
|
|
112
|
+
*
|
|
113
|
+
* @param path The file path that was added or deleted
|
|
114
|
+
*/
|
|
115
|
+
function invalidateRoutes(path, event) {
|
|
116
|
+
if (!isRouteLikeFile(path)) return;
|
|
117
|
+
if (event !== "change") invalidateDiscoveryCaches();
|
|
118
|
+
invalidateFileModules(server, path);
|
|
119
|
+
if (event === "change") return;
|
|
120
|
+
server.moduleGraph.fileToModulesMap.forEach((mods) => {
|
|
121
|
+
mods.forEach((mod) => {
|
|
122
|
+
if (mod.id?.includes("analogjs") && mod.id?.includes("fesm")) {
|
|
123
|
+
server.moduleGraph.invalidateModule(mod);
|
|
124
|
+
mod.importers.forEach((imp) => {
|
|
125
|
+
server.moduleGraph.invalidateModule(imp);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
server.ws.send({ type: "full-reload" });
|
|
131
|
+
}
|
|
132
|
+
server.watcher.on("add", (path) => invalidateRoutes(path, "add"));
|
|
133
|
+
server.watcher.on("change", (path) => invalidateRoutes(path, "change"));
|
|
134
|
+
server.watcher.on("unlink", (path) => invalidateRoutes(path, "unlink"));
|
|
135
|
+
for (const dir of [...additionalPagesDirs, ...additionalContentDirs]) server.watcher.add(dir);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "analog-glob-routes",
|
|
140
|
+
enforce: "post",
|
|
141
|
+
config(_config) {
|
|
142
|
+
config = _config;
|
|
143
|
+
root = normalizePath(resolve(workspaceRoot, config.root || ".") || ".");
|
|
144
|
+
},
|
|
145
|
+
transform: {
|
|
146
|
+
filter: { code: "_ROUTE_FILES" },
|
|
147
|
+
handler(code) {
|
|
148
|
+
if (code.includes("ANALOG_ROUTE_FILES") || code.includes("ANALOG_CONTENT_ROUTE_FILES")) {
|
|
149
|
+
const routeFiles = discoverRouteFiles();
|
|
150
|
+
const contentRouteFiles = discoverContentRouteFiles();
|
|
151
|
+
let result = code.replace("ANALOG_ROUTE_FILES = {};", `
|
|
152
|
+
ANALOG_ROUTE_FILES = {${routeFiles.map((module) => {
|
|
153
|
+
return `"${getModuleKey(module)}": () => import('${module}')`;
|
|
154
|
+
})}};
|
|
155
|
+
`);
|
|
156
|
+
result = result.replace("ANALOG_CONTENT_ROUTE_FILES = {};", `
|
|
157
|
+
ANALOG_CONTENT_ROUTE_FILES = {${contentRouteFiles.map((module) => {
|
|
158
|
+
return `"${getModuleKey(module)}": () => import('${module}?analog-content-file=true').then(m => m.default)`;
|
|
159
|
+
})}};
|
|
160
|
+
`);
|
|
161
|
+
result = result.replace("ANALOG_CONTENT_FILE_COUNT = 0", `ANALOG_CONTENT_FILE_COUNT = ${contentRouteFiles.length}`);
|
|
162
|
+
return {
|
|
163
|
+
code: result,
|
|
164
|
+
map: { mappings: "" }
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "analog-glob-endpoints",
|
|
172
|
+
enforce: "post",
|
|
173
|
+
transform: {
|
|
174
|
+
filter: { code: "ANALOG_PAGE_ENDPOINTS" },
|
|
175
|
+
handler(code) {
|
|
176
|
+
if (code.includes("ANALOG_PAGE_ENDPOINTS")) {
|
|
177
|
+
const endpointFiles = discoverEndpointFiles();
|
|
178
|
+
return {
|
|
179
|
+
code: code.replace("ANALOG_PAGE_ENDPOINTS = {};", `
|
|
180
|
+
ANALOG_PAGE_ENDPOINTS = {${endpointFiles.map((module) => {
|
|
181
|
+
return `"${getModuleKey(module)}": () => import('${module}')`;
|
|
182
|
+
})}};
|
|
183
|
+
`),
|
|
184
|
+
map: { mappings: "" }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
];
|
|
151
191
|
}
|
|
152
|
-
//#
|
|
192
|
+
//#endregion
|
|
193
|
+
export { routerPlugin };
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=router-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-plugin.js","names":[],"sources":["../../../src/lib/router-plugin.ts"],"sourcesContent":["import { normalizePath, Plugin, UserConfig, ViteDevServer } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { isAbsolute, relative, resolve } from 'node:path';\n\nimport { Options } from './options.js';\n\n/**\n * Router plugin that handles route file discovery and hot module replacement.\n *\n * This plugin provides three main functionalities:\n * 1. Route invalidation when files are added/deleted (HMR workaround)\n * 2. Dynamic route file discovery and import generation\n * 3. Content route file discovery for markdown and Analog content\n *\n * @param options Configuration options for the router plugin\n * @returns Array of Vite plugins for route handling\n *\n * IMPORTANT: This plugin uses tinyglobby for file discovery.\n * Key behavior with { dot: true, absolute: true }:\n * - Returns absolute paths for ALL discovered files\n * - Path normalization is required to match expected output format\n * - Files within project root must use relative paths in object keys\n * - Files outside project root keep absolute paths in object keys\n */\nexport function routerPlugin(options?: Options): Plugin[] {\n const workspaceRoot = normalizePath(\n options?.workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd(),\n );\n let config: UserConfig;\n let root: string;\n // Option dirs are workspace-relative, often written with a leading `/`.\n // Normalize them once into absolute workspace paths so watcher events,\n // glob patterns, and key generation all compare against the same shape.\n const normalizeWatchedDir = (dir: string) => {\n const normalizedDir = normalizePath(\n dir.startsWith(`${workspaceRoot}/`) || dir === workspaceRoot\n ? dir\n : dir.startsWith('/')\n ? `${workspaceRoot}${dir}`\n : resolve(workspaceRoot, dir),\n );\n return normalizedDir.endsWith('/')\n ? normalizedDir.slice(0, -1)\n : normalizedDir;\n };\n // Computed eagerly — these depend only on `options` and `workspaceRoot`,\n // both of which are fixed at construction time.\n const additionalPagesDirs = (options?.additionalPagesDirs || []).map((dir) =>\n normalizeWatchedDir(dir),\n );\n const additionalContentDirs = (options?.additionalContentDirs || []).map(\n (dir) => normalizeWatchedDir(dir),\n );\n // Returns every directory that can contain route-like files. The root-\n // relative entries are only available after the Vite `config` hook sets\n // `root`. The short-form fallbacks (`/app/routes`, etc.) let watcher\n // events match before `config` runs — they cover the common convention\n // where paths start with these prefixes.\n const getRouteLikeDirs = () => [\n ...(root\n ? [\n normalizeWatchedDir(`${root}/app/routes`),\n normalizeWatchedDir(`${root}/src/app/routes`),\n normalizeWatchedDir(`${root}/src/app/pages`),\n normalizeWatchedDir(`${root}/src/content`),\n ]\n : []),\n '/app/routes',\n '/src/app/routes',\n '/src/app/pages',\n '/src/content',\n ...additionalPagesDirs,\n ...additionalContentDirs,\n ];\n // These lists are used repeatedly by transform hooks during serve. Keeping\n // them warm avoids a full glob on every route/content invalidation.\n let routeFilesCache: string[] | undefined;\n let contentRouteFilesCache: string[] | undefined;\n let endpointFilesCache: string[] | undefined;\n const isRouteLikeFile = (path: string) => {\n // Watcher paths from chokidar are already absolute — `normalizePath`\n // (forward-slash only) is sufficient; `resolve()` would be a no-op.\n const normalizedPath = normalizePath(path);\n\n return getRouteLikeDirs().some(\n (dir) => normalizedPath === dir || normalizedPath.startsWith(`${dir}/`),\n );\n };\n const discoverRouteFiles = () => {\n routeFilesCache ??= globSync(\n [\n `${root}/app/routes/**/*.ts`,\n `${root}/src/app/routes/**/*.ts`,\n `${root}/src/app/pages/**/*.page.ts`,\n ...additionalPagesDirs.map((dir) => `${dir}/**/*.page.ts`),\n ],\n { dot: true, absolute: true },\n );\n\n return routeFilesCache;\n };\n const discoverContentRouteFiles = () => {\n contentRouteFilesCache ??= globSync(\n [\n `${root}/src/app/routes/**/*.md`,\n `${root}/src/app/pages/**/*.md`,\n `${root}/src/content/**/*.md`,\n ...additionalContentDirs.map((dir) => `${dir}/**/*.md`),\n ],\n { dot: true, absolute: true },\n );\n\n return contentRouteFilesCache;\n };\n const discoverEndpointFiles = () => {\n endpointFilesCache ??= globSync(\n [\n `${root}/src/app/pages/**/*.server.ts`,\n ...additionalPagesDirs.map((dir) => `${dir}/**/*.server.ts`),\n ],\n { dot: true, absolute: true },\n );\n\n return endpointFilesCache;\n };\n const invalidateDiscoveryCaches = () => {\n routeFilesCache = undefined;\n contentRouteFilesCache = undefined;\n endpointFilesCache = undefined;\n };\n const getModuleKey = (module: string) => {\n // Before config sets `root`, fall back to workspace-relative keys.\n if (!root) {\n return `/${normalizePath(relative(workspaceRoot, module))}`;\n }\n\n const relToRoot = normalizePath(relative(root, module));\n // Use true path containment instead of a raw prefix check so siblings like\n // `/apps/my-app-tools/...` are not mistaken for files inside `/apps/my-app`.\n const isInRoot = !relToRoot.startsWith('..') && !isAbsolute(relToRoot);\n\n if (isInRoot) {\n return `/${relToRoot}`;\n }\n\n return `/${normalizePath(relative(workspaceRoot, module))}`;\n };\n const invalidateFileModules = (server: ViteDevServer, path: string) => {\n const normalizedPath = normalizePath(path);\n // A newly added page can be discovered before its final contents settle.\n // Invalidate the page module itself so later edits don't keep serving the\n // first incomplete transform from Vite's module graph.\n const fileModules =\n server.moduleGraph.getModulesByFile?.(normalizedPath) ??\n server.moduleGraph.fileToModulesMap.get(normalizedPath);\n\n fileModules?.forEach((mod) => {\n server.moduleGraph.invalidateModule(mod);\n\n mod.importers.forEach((imp) => {\n server.moduleGraph.invalidateModule(imp);\n });\n });\n };\n\n return [\n {\n name: 'analogjs-router-invalidate-routes',\n configureServer(server) {\n /**\n * Invalidates route modules when files are added or deleted.\n * This is a workaround for Vite's HMR limitations with dynamic imports.\n *\n * @param path The file path that was added or deleted\n */\n function invalidateRoutes(\n path: string,\n event: 'add' | 'change' | 'unlink',\n ) {\n if (!isRouteLikeFile(path)) {\n return;\n }\n\n // Add/remove changes the route graph shape, so the discovery caches\n // must be rebuilt. Plain edits can keep using the current file set.\n if (event !== 'change') {\n invalidateDiscoveryCaches();\n }\n\n invalidateFileModules(server, path);\n\n // For an in-place edit we only need module invalidation. Keeping the\n // app alive here lets Angular/Vite attempt the narrower HMR path.\n if (event === 'change') {\n return;\n }\n\n server.moduleGraph.fileToModulesMap.forEach((mods) => {\n mods.forEach((mod) => {\n if (mod.id?.includes('analogjs') && mod.id?.includes('fesm')) {\n server.moduleGraph.invalidateModule(mod);\n\n mod.importers.forEach((imp) => {\n server.moduleGraph.invalidateModule(imp);\n });\n }\n });\n });\n\n server.ws.send({\n type: 'full-reload',\n });\n }\n\n server.watcher.on('add', (path) => invalidateRoutes(path, 'add'));\n server.watcher.on('change', (path) => invalidateRoutes(path, 'change'));\n server.watcher.on('unlink', (path) => invalidateRoutes(path, 'unlink'));\n\n // Vite's watcher only covers the app root by default.\n // additionalPagesDirs / additionalContentDirs live outside the\n // root (e.g. libs/shared/feature in a monorepo), so file\n // add/rename/delete events are never fired for them. Explicitly\n // add these directories to chokidar so route invalidation works.\n for (const dir of [...additionalPagesDirs, ...additionalContentDirs]) {\n server.watcher.add(dir);\n }\n },\n },\n {\n name: 'analog-glob-routes',\n // enforce: 'post' ensures this transform runs AFTER the Angular compiler\n // plugin, which replaces module content with its own compiled output.\n // Without this, the Angular plugin would overwrite the route replacements.\n enforce: 'post',\n config(_config) {\n config = _config;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n },\n /**\n * Transforms code to replace ANALOG_ROUTE_FILES and ANALOG_CONTENT_ROUTE_FILES\n * placeholders with actual dynamic imports of discovered route and content files.\n *\n * @param code The source code to transform\n * @returns Transformed code with dynamic imports or undefined if no transformation needed\n */\n // Vite 8 / Rolldown filtered transform: the `filter.code` substring\n // pre-filter lets the bundler skip modules that don't contain the\n // marker. '_ROUTE_FILES' is a common substring of both\n // 'ANALOG_ROUTE_FILES' and 'ANALOG_CONTENT_ROUTE_FILES'.\n //\n // IMPORTANT: Do NOT change this to 'ANALOG_ROUTE_FILES' — that is NOT\n // a substring of 'ANALOG_CONTENT_ROUTE_FILES' (they diverge at\n // position 7: 'ANALOG_C...' vs 'ANALOG_R...'). When tsconfig path\n // aliases resolve @analogjs/router and @analogjs/router/content to\n // separate source files, each variable lives in its own module and\n // the filter must match both independently.\n transform: {\n filter: {\n code: '_ROUTE_FILES',\n },\n handler(code) {\n if (\n code.includes('ANALOG_ROUTE_FILES') ||\n code.includes('ANALOG_CONTENT_ROUTE_FILES')\n ) {\n // Discover route files using tinyglobby\n // NOTE: { absolute: true } returns absolute paths for ALL files\n const routeFiles = discoverRouteFiles();\n\n // Discover content files using tinyglobby\n const contentRouteFiles = discoverContentRouteFiles();\n\n let result = code.replace(\n 'ANALOG_ROUTE_FILES = {};',\n `\n ANALOG_ROUTE_FILES = {${routeFiles.map((module) => {\n // Keys are app-root-relative for in-app files,\n // workspace-relative for library files (additionalPagesDirs).\n // import() keeps absolute paths for Vite's module resolution.\n const key = getModuleKey(module);\n return `\"${key}\": () => import('${module}')`;\n })}};\n `,\n );\n\n result = result.replace(\n 'ANALOG_CONTENT_ROUTE_FILES = {};',\n `\n ANALOG_CONTENT_ROUTE_FILES = {${contentRouteFiles.map((module) => {\n const key = getModuleKey(module);\n return `\"${key}\": () => import('${module}?analog-content-file=true').then(m => m.default)`;\n })}};\n `,\n );\n\n result = result.replace(\n 'ANALOG_CONTENT_FILE_COUNT = 0',\n `ANALOG_CONTENT_FILE_COUNT = ${contentRouteFiles.length}`,\n );\n\n return {\n code: result,\n map: { mappings: '' },\n };\n }\n\n return;\n },\n },\n },\n {\n name: 'analog-glob-endpoints',\n // enforce: 'post' ensures this transform runs AFTER the Angular compiler\n // plugin, which replaces module content with its own compiled output.\n // Without this, the Angular plugin would overwrite the endpoint replacements.\n enforce: 'post',\n /**\n * Transforms code to replace ANALOG_PAGE_ENDPOINTS placeholder\n * with actual dynamic imports of discovered server endpoint files.\n *\n * @param code The source code to transform\n * @returns Transformed code with dynamic imports or undefined if no transformation needed\n */\n transform: {\n filter: {\n code: 'ANALOG_PAGE_ENDPOINTS',\n },\n handler(code) {\n if (code.includes('ANALOG_PAGE_ENDPOINTS')) {\n // Discover server endpoint files using tinyglobby\n const endpointFiles = discoverEndpointFiles();\n\n const result = code.replace(\n 'ANALOG_PAGE_ENDPOINTS = {};',\n `\n ANALOG_PAGE_ENDPOINTS = {${endpointFiles.map((module) => {\n const key = getModuleKey(module);\n return `\"${key}\": () => import('${module}')`;\n })}};\n `,\n );\n\n return {\n code: result,\n map: { mappings: '' },\n };\n }\n\n return;\n },\n },\n },\n ];\n}\n"],"mappings":"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"}
|
|
@@ -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,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* SSR build patches for Angular platform-server, Zone.js, and Domino.
|
|
4
|
+
*
|
|
5
|
+
* Returns an array of Vite plugins because under Vite 8+ (Rolldown) we
|
|
6
|
+
* append Rolldown's built-in `replacePlugin` for an AST-safe
|
|
7
|
+
* `global → globalThis` rewrite that avoids false positives inside string
|
|
8
|
+
* literals and comments.
|
|
9
|
+
*
|
|
10
|
+
* **Why each patch exists:**
|
|
11
|
+
* - zone-node: removes a `const global = globalThis` alias that shadows the
|
|
12
|
+
* real global in strict mode.
|
|
13
|
+
* - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and
|
|
14
|
+
* replaces bare `global` references with `globalThis`.
|
|
15
|
+
* - xhr2: strips Node-specific `os`/`process` references for SSR bundling.
|
|
16
|
+
* - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ssrBuildPlugin(): vite.Plugin[];
|
|
@@ -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"],"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,23 @@
|
|
|
1
|
+
import type { StylePreprocessor } from "@analogjs/vite-plugin-angular";
|
|
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;
|