@analogjs/platform 3.0.0-alpha.3 → 3.0.0-alpha.31
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 +30 -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 +183 -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-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__ +0 -20
- 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 -20
- 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 -11
- 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 -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 +4 -5
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +61 -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 -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 +224 -80
- package/src/lib/platform-plugin.d.ts +2 -2
- package/src/lib/platform-plugin.js +88 -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 +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/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 +57 -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/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 -110
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +0 -56
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +0 -72
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +0 -46
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +0 -37
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions.js +0 -43
- package/src/lib/nx-plugin/src/generators/app/versions.js.map +0 -1
- package/src/lib/nx-plugin/src/index.d.ts +0 -0
- package/src/lib/nx-plugin/src/index.js.map +0 -1
- package/src/lib/options.js +0 -1
- package/src/lib/ssr/ssr-xhr-plugin.d.ts +0 -2
- package/src/lib/ssr/ssr-xhr-plugin.js +0 -28
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { normalizePath } from "vite";
|
|
3
|
+
import { globSync } from "tinyglobby";
|
|
4
|
+
//#region packages/platform/src/lib/route-file-discovery.ts
|
|
5
|
+
function createRouteFileDiscovery(options) {
|
|
6
|
+
const { root, workspaceRoot, additionalPagesDirs, additionalContentDirs } = options;
|
|
7
|
+
let routeFilesCache = /* @__PURE__ */ new Set();
|
|
8
|
+
let contentFilesCache = /* @__PURE__ */ new Set();
|
|
9
|
+
let appLocalFilesCache = /* @__PURE__ */ new Set();
|
|
10
|
+
let initialized = false;
|
|
11
|
+
const joinDir = (dir) => dir.startsWith(workspaceRoot) ? normalizePath(dir) : dir.startsWith("/") ? normalizePath(`${workspaceRoot}${dir}`) : normalizePath(resolve(workspaceRoot, dir));
|
|
12
|
+
const additionalPagesRoots = additionalPagesDirs.map(joinDir);
|
|
13
|
+
const additionalContentRoots = additionalContentDirs.map(joinDir);
|
|
14
|
+
function normalizePath_(absolutePath) {
|
|
15
|
+
const normalized = normalizePath(absolutePath);
|
|
16
|
+
if (normalized.startsWith(root)) return normalized.slice(root.length);
|
|
17
|
+
if (normalized.startsWith(workspaceRoot)) return normalized.slice(workspaceRoot.length);
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
function isWithinDir(path, dir) {
|
|
21
|
+
return path === dir || path.startsWith(`${dir}/`);
|
|
22
|
+
}
|
|
23
|
+
function getDiscoveredFileKind(path) {
|
|
24
|
+
const normalized = normalizePath(path);
|
|
25
|
+
if (normalized.endsWith(".md") && (normalized.includes("/src/app/routes/") || normalized.includes("/src/app/pages/") || normalized.includes("/src/content/") || additionalContentRoots.some((dir) => isWithinDir(normalized, dir)))) return "content";
|
|
26
|
+
if ((normalized.includes("/app/routes/") || normalized.includes("/src/app/routes/")) && normalized.endsWith(".ts")) return "route";
|
|
27
|
+
if (normalized.endsWith(".page.ts") && (normalized.includes("/src/app/pages/") || additionalPagesRoots.some((dir) => isWithinDir(normalized, dir)))) return "route";
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function scanRouteFiles() {
|
|
31
|
+
const appLocalGlobs = [
|
|
32
|
+
`${root}/app/routes/**/*.ts`,
|
|
33
|
+
`${root}/src/app/routes/**/*.ts`,
|
|
34
|
+
`${root}/src/app/pages/**/*.page.ts`
|
|
35
|
+
];
|
|
36
|
+
const additionalGlobs = additionalPagesDirs.map((dir) => `${joinDir(dir)}/**/*.page.ts`);
|
|
37
|
+
const appLocal = globSync(appLocalGlobs, {
|
|
38
|
+
dot: true,
|
|
39
|
+
absolute: true
|
|
40
|
+
}).map(normalizePath_);
|
|
41
|
+
const additional = globSync(additionalGlobs, {
|
|
42
|
+
dot: true,
|
|
43
|
+
absolute: true
|
|
44
|
+
}).map(normalizePath_);
|
|
45
|
+
for (const f of appLocal) appLocalFilesCache.add(f);
|
|
46
|
+
return [...appLocal, ...additional];
|
|
47
|
+
}
|
|
48
|
+
function scanContentFiles() {
|
|
49
|
+
const appLocalGlobs = [
|
|
50
|
+
`${root}/src/app/routes/**/*.md`,
|
|
51
|
+
`${root}/src/app/pages/**/*.md`,
|
|
52
|
+
`${root}/src/content/**/*.md`
|
|
53
|
+
];
|
|
54
|
+
const additionalGlobs = additionalContentDirs.map((dir) => `${joinDir(dir)}/**/*.md`);
|
|
55
|
+
const appLocal = globSync(appLocalGlobs, {
|
|
56
|
+
dot: true,
|
|
57
|
+
absolute: true
|
|
58
|
+
}).map(normalizePath_);
|
|
59
|
+
const additional = globSync(additionalGlobs, {
|
|
60
|
+
dot: true,
|
|
61
|
+
absolute: true
|
|
62
|
+
}).map(normalizePath_);
|
|
63
|
+
for (const f of appLocal) appLocalFilesCache.add(f);
|
|
64
|
+
return [...appLocal, ...additional];
|
|
65
|
+
}
|
|
66
|
+
function isAppLocalByPath(absolutePath) {
|
|
67
|
+
return normalizePath(absolutePath).startsWith(root);
|
|
68
|
+
}
|
|
69
|
+
function ensureInitialized() {
|
|
70
|
+
if (initialized) return;
|
|
71
|
+
routeFilesCache = new Set(scanRouteFiles());
|
|
72
|
+
contentFilesCache = new Set(scanContentFiles());
|
|
73
|
+
initialized = true;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
getRouteFiles() {
|
|
77
|
+
ensureInitialized();
|
|
78
|
+
return [...routeFilesCache].sort();
|
|
79
|
+
},
|
|
80
|
+
getContentFiles() {
|
|
81
|
+
ensureInitialized();
|
|
82
|
+
return [...contentFilesCache].sort();
|
|
83
|
+
},
|
|
84
|
+
getDiscoveredFileKind(path) {
|
|
85
|
+
return getDiscoveredFileKind(path);
|
|
86
|
+
},
|
|
87
|
+
updateDiscoveredFile(path, event) {
|
|
88
|
+
ensureInitialized();
|
|
89
|
+
const kind = getDiscoveredFileKind(path);
|
|
90
|
+
if (!kind) return;
|
|
91
|
+
const normalizedPath = normalizePath_(path);
|
|
92
|
+
const targetCache = kind === "content" ? contentFilesCache : routeFilesCache;
|
|
93
|
+
if (event === "unlink") {
|
|
94
|
+
targetCache.delete(normalizedPath);
|
|
95
|
+
appLocalFilesCache.delete(normalizedPath);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
targetCache.add(normalizedPath);
|
|
99
|
+
if (isAppLocalByPath(path)) appLocalFilesCache.add(normalizedPath);
|
|
100
|
+
},
|
|
101
|
+
isAppLocal(normalizedFilename) {
|
|
102
|
+
ensureInitialized();
|
|
103
|
+
return appLocalFilesCache.has(normalizedFilename);
|
|
104
|
+
},
|
|
105
|
+
reset() {
|
|
106
|
+
initialized = false;
|
|
107
|
+
appLocalFilesCache = /* @__PURE__ */ new Set();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { createRouteFileDiscovery };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=route-file-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-file-discovery.js","names":[],"sources":["../../../src/lib/route-file-discovery.ts"],"sourcesContent":["import { normalizePath } from 'vite';\nimport { resolve } from 'node:path';\nimport { globSync } from 'tinyglobby';\n\nexport interface RouteFileDiscoveryOptions {\n root: string;\n workspaceRoot: string;\n additionalPagesDirs: string[];\n additionalContentDirs: string[];\n}\n\nexport interface RouteFileDiscovery {\n getRouteFiles(): string[];\n getContentFiles(): string[];\n getDiscoveredFileKind(path: string): 'route' | 'content' | null;\n updateDiscoveredFile(path: string, event: 'add' | 'change' | 'unlink'): void;\n /**\n * Returns true if the normalized filename was discovered from an app-local\n * glob (under the configured root) rather than from an additional directory.\n *\n * Used by collision priority to prefer app-local routes over shared/external\n * routes based on actual configured roots instead of hard-coded path\n * substrings.\n */\n isAppLocal(normalizedFilename: string): boolean;\n reset(): void;\n}\n\nexport function createRouteFileDiscovery(\n options: RouteFileDiscoveryOptions,\n): RouteFileDiscovery {\n const { root, workspaceRoot, additionalPagesDirs, additionalContentDirs } =\n options;\n\n let routeFilesCache = new Set<string>();\n let contentFilesCache = new Set<string>();\n let appLocalFilesCache = new Set<string>();\n let initialized = false;\n const joinDir = (dir: string) =>\n dir.startsWith(workspaceRoot)\n ? normalizePath(dir)\n : dir.startsWith('/')\n ? normalizePath(`${workspaceRoot}${dir}`)\n : normalizePath(resolve(workspaceRoot, dir));\n const additionalPagesRoots = additionalPagesDirs.map(joinDir);\n const additionalContentRoots = additionalContentDirs.map(joinDir);\n\n function normalizePath_(absolutePath: string): string {\n const normalized = normalizePath(absolutePath);\n if (normalized.startsWith(root)) {\n return normalized.slice(root.length);\n }\n if (normalized.startsWith(workspaceRoot)) {\n return normalized.slice(workspaceRoot.length);\n }\n return normalized;\n }\n\n function isWithinDir(path: string, dir: string): boolean {\n return path === dir || path.startsWith(`${dir}/`);\n }\n\n function getDiscoveredFileKind(path: string): 'route' | 'content' | null {\n const normalized = normalizePath(path);\n\n if (\n normalized.endsWith('.md') &&\n (normalized.includes('/src/app/routes/') ||\n normalized.includes('/src/app/pages/') ||\n normalized.includes('/src/content/') ||\n additionalContentRoots.some((dir) => isWithinDir(normalized, dir)))\n ) {\n return 'content';\n }\n\n if (\n (normalized.includes('/app/routes/') ||\n normalized.includes('/src/app/routes/')) &&\n normalized.endsWith('.ts')\n ) {\n return 'route';\n }\n\n // Keep the dev watcher aligned with the build-time route scan. In\n // particular, `src/server/routes/**` must stay out of typed route codegen\n // because Nitro API handlers are not client-navigable pages.\n if (\n normalized.endsWith('.page.ts') &&\n (normalized.includes('/src/app/pages/') ||\n additionalPagesRoots.some((dir) => isWithinDir(normalized, dir)))\n ) {\n return 'route';\n }\n\n return null;\n }\n\n function scanRouteFiles(): string[] {\n const appLocalGlobs = [\n `${root}/app/routes/**/*.ts`,\n `${root}/src/app/routes/**/*.ts`,\n `${root}/src/app/pages/**/*.page.ts`,\n ];\n const additionalGlobs = additionalPagesDirs.map(\n (dir) => `${joinDir(dir)}/**/*.page.ts`,\n );\n\n const appLocal = globSync(appLocalGlobs, {\n dot: true,\n absolute: true,\n }).map(normalizePath_);\n\n const additional = globSync(additionalGlobs, {\n dot: true,\n absolute: true,\n }).map(normalizePath_);\n\n for (const f of appLocal) {\n appLocalFilesCache.add(f);\n }\n\n return [...appLocal, ...additional];\n }\n\n function scanContentFiles(): string[] {\n const appLocalGlobs = [\n `${root}/src/app/routes/**/*.md`,\n `${root}/src/app/pages/**/*.md`,\n `${root}/src/content/**/*.md`,\n ];\n const additionalGlobs = additionalContentDirs.map(\n (dir) => `${joinDir(dir)}/**/*.md`,\n );\n\n const appLocal = globSync(appLocalGlobs, {\n dot: true,\n absolute: true,\n }).map(normalizePath_);\n\n const additional = globSync(additionalGlobs, {\n dot: true,\n absolute: true,\n }).map(normalizePath_);\n\n for (const f of appLocal) {\n appLocalFilesCache.add(f);\n }\n\n return [...appLocal, ...additional];\n }\n\n function isAppLocalByPath(absolutePath: string): boolean {\n const normalized = normalizePath(absolutePath);\n return normalized.startsWith(root);\n }\n\n function ensureInitialized(): void {\n if (initialized) {\n return;\n }\n\n routeFilesCache = new Set(scanRouteFiles());\n contentFilesCache = new Set(scanContentFiles());\n initialized = true;\n }\n\n return {\n getRouteFiles(): string[] {\n ensureInitialized();\n return [...routeFilesCache].sort();\n },\n\n getContentFiles(): string[] {\n ensureInitialized();\n return [...contentFilesCache].sort();\n },\n\n getDiscoveredFileKind(path: string): 'route' | 'content' | null {\n return getDiscoveredFileKind(path);\n },\n\n updateDiscoveredFile(\n path: string,\n event: 'add' | 'change' | 'unlink',\n ): void {\n ensureInitialized();\n const kind = getDiscoveredFileKind(path);\n if (!kind) {\n return;\n }\n\n const normalizedPath = normalizePath_(path);\n const targetCache =\n kind === 'content' ? contentFilesCache : routeFilesCache;\n\n if (event === 'unlink') {\n targetCache.delete(normalizedPath);\n appLocalFilesCache.delete(normalizedPath);\n return;\n }\n\n targetCache.add(normalizedPath);\n if (isAppLocalByPath(path)) {\n appLocalFilesCache.add(normalizedPath);\n }\n },\n\n isAppLocal(normalizedFilename: string): boolean {\n ensureInitialized();\n return appLocalFilesCache.has(normalizedFilename);\n },\n\n reset(): void {\n initialized = false;\n appLocalFilesCache = new Set<string>();\n },\n };\n}\n"],"mappings":";;;;AA4BA,SAAgB,yBACd,SACoB;CACpB,MAAM,EAAE,MAAM,eAAe,qBAAqB,0BAChD;CAEF,IAAI,kCAAkB,IAAI,KAAa;CACvC,IAAI,oCAAoB,IAAI,KAAa;CACzC,IAAI,qCAAqB,IAAI,KAAa;CAC1C,IAAI,cAAc;CAClB,MAAM,WAAW,QACf,IAAI,WAAW,cAAc,GACzB,cAAc,IAAI,GAClB,IAAI,WAAW,IAAI,GACjB,cAAc,GAAG,gBAAgB,MAAM,GACvC,cAAc,QAAQ,eAAe,IAAI,CAAC;CAClD,MAAM,uBAAuB,oBAAoB,IAAI,QAAQ;CAC7D,MAAM,yBAAyB,sBAAsB,IAAI,QAAQ;CAEjE,SAAS,eAAe,cAA8B;EACpD,MAAM,aAAa,cAAc,aAAa;AAC9C,MAAI,WAAW,WAAW,KAAK,CAC7B,QAAO,WAAW,MAAM,KAAK,OAAO;AAEtC,MAAI,WAAW,WAAW,cAAc,CACtC,QAAO,WAAW,MAAM,cAAc,OAAO;AAE/C,SAA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AAe;EAEtB,MAAM,aAAa,SAAS,iBAAiB;GAC3C,KAAK;GACL,UAAU;GACX,CAAC,CAAC,IAAI,eAAe;AAEtB,OAAK,MAAM,KAAK,SACd,oBAAmB,IAAI,EAAE;AAG3B,SAAO,CAAC,GAAG,UAAU,GAAG,WAAW;;CAGrC,SAAS,iBAAiB,cAA+B;AAEvD,SADmB,cAAc,aAAa,CAC5B,WAAW,KAAK;;CAGpC,SAAS,oBAA0B;AACjC,MAAI,YACF;AAGF,oBAAkB,IAAI,IAAI,gBAAgB,CAAC;AAC3C,sBAAoB,IAAI,IAAI,kBAAkB,CAAC;AAC/C,gBAAc;;AAGhB,QAAO;EACL,gBAA0B;AACxB,sBAAmB;AACnB,UAAO,CAAC,GAAG,gBAAgB,CAAC,MAAM;;EAGpC,kBAA4B;AAC1B,sBAAmB;AACnB,UAAO,CAAC,GAAG,kBAAkB,CAAC,MAAM;;EAGtC,sBAAsB,MAA0C;AAC9D,UAAO,sBAAsB,KAAK;;EAGpC,qBACE,MACA,OACM;AACN,sBAAmB;GACnB,MAAM,OAAO,sBAAsB,KAAK;AACxC,OAAI,CAAC,KACH;GAGF,MAAM,iBAAiB,eAAe,KAAK;GAC3C,MAAM,cACJ,SAAS,YAAY,oBAAoB;AAE3C,OAAI,UAAU,UAAU;AACtB,gBAAY,OAAO,eAAe;AAClC,uBAAmB,OAAO,eAAe;AACzC;;AAGF,eAAY,IAAI,eAAe;AAC/B,OAAI,iBAAiB,KAAK,CACxB,oBAAmB,IAAI,eAAe;;EAI1C,WAAW,oBAAqC;AAC9C,sBAAmB;AACnB,UAAO,mBAAmB,IAAI,mBAAmB;;EAGnD,QAAc;AACZ,iBAAc;AACd,wCAAqB,IAAI,KAAa;;EAEzC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { debugTypedRouter } from "./utils/debug.js";
|
|
2
|
+
import { typedRoutes } from "./typed-routes-plugin.js";
|
|
3
|
+
//#region packages/platform/src/lib/route-generation-plugin.ts
|
|
4
|
+
function resolveTypedRouterOptions(experimental) {
|
|
5
|
+
const typedRouter = experimental?.typedRouter;
|
|
6
|
+
if (typedRouter === false) return {
|
|
7
|
+
enabled: false,
|
|
8
|
+
options: {}
|
|
9
|
+
};
|
|
10
|
+
if (!typedRouter || typedRouter === true) return {
|
|
11
|
+
enabled: true,
|
|
12
|
+
options: { jsonLdManifest: true }
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
enabled: true,
|
|
16
|
+
options: {
|
|
17
|
+
...typedRouter,
|
|
18
|
+
jsonLdManifest: typedRouter.jsonLdManifest ?? true
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function routeGenerationPlugin(options) {
|
|
23
|
+
const { enabled, options: typedRouterOptions } = resolveTypedRouterOptions(options?.experimental);
|
|
24
|
+
if (!enabled) {
|
|
25
|
+
debugTypedRouter("disabled by experimental.typedRouter === false");
|
|
26
|
+
return { name: "analog-route-generation-disabled" };
|
|
27
|
+
}
|
|
28
|
+
const pluginOptions = {
|
|
29
|
+
...typedRouterOptions,
|
|
30
|
+
workspaceRoot: options?.workspaceRoot,
|
|
31
|
+
additionalPagesDirs: options?.additionalPagesDirs,
|
|
32
|
+
additionalContentDirs: options?.additionalContentDirs
|
|
33
|
+
};
|
|
34
|
+
debugTypedRouter("enabled", {
|
|
35
|
+
outFile: pluginOptions.outFile,
|
|
36
|
+
jsonLdManifest: pluginOptions.jsonLdManifest,
|
|
37
|
+
additionalPagesDirs: pluginOptions.additionalPagesDirs,
|
|
38
|
+
additionalContentDirs: pluginOptions.additionalContentDirs
|
|
39
|
+
});
|
|
40
|
+
return typedRoutes(pluginOptions);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { routeGenerationPlugin };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=route-generation-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-generation-plugin.js","names":[],"sources":["../../../src/lib/route-generation-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport type { Options, TypedRouterOptions } from './options.js';\nimport {\n typedRoutes,\n type TypedRoutesPluginOptions,\n} from './typed-routes-plugin.js';\nimport { debugTypedRouter } from './utils/debug.js';\n\nfunction resolveTypedRouterOptions(experimental: Options['experimental']): {\n enabled: boolean;\n options: TypedRouterOptions;\n} {\n const typedRouter = experimental?.typedRouter;\n if (typedRouter === false) {\n return { enabled: false, options: {} };\n }\n if (!typedRouter || typedRouter === true) {\n return { enabled: true, options: { jsonLdManifest: true } };\n }\n return {\n enabled: true,\n options: {\n ...typedRouter,\n jsonLdManifest: typedRouter.jsonLdManifest ?? true,\n },\n };\n}\n\nexport function routeGenerationPlugin(options?: Options): Plugin {\n const { enabled, options: typedRouterOptions } = resolveTypedRouterOptions(\n options?.experimental,\n );\n\n if (!enabled) {\n debugTypedRouter('disabled by experimental.typedRouter === false');\n return {\n name: 'analog-route-generation-disabled',\n };\n }\n\n const pluginOptions: TypedRoutesPluginOptions = {\n ...typedRouterOptions,\n workspaceRoot: options?.workspaceRoot,\n additionalPagesDirs: options?.additionalPagesDirs,\n additionalContentDirs: options?.additionalContentDirs,\n };\n debugTypedRouter('enabled', {\n outFile: pluginOptions.outFile,\n jsonLdManifest: pluginOptions.jsonLdManifest,\n additionalPagesDirs: pluginOptions.additionalPagesDirs,\n additionalContentDirs: pluginOptions.additionalContentDirs,\n });\n\n return typedRoutes(pluginOptions);\n}\n"],"mappings":";;;AASA,SAAS,0BAA0B,cAGjC;CACA,MAAM,cAAc,cAAc;AAClC,KAAI,gBAAgB,MAClB,QAAO;EAAE,SAAS;EAAO,SAAS,EAAE;EAAE;AAExC,KAAI,CAAC,eAAe,gBAAgB,KAClC,QAAO;EAAE,SAAS;EAAM,SAAS,EAAE,gBAAgB,MAAM;EAAE;AAE7D,QAAO;EACL,SAAS;EACT,SAAS;GACP,GAAG;GACH,gBAAgB,YAAY,kBAAkB;GAC/C;EACF;;AAGH,SAAgB,sBAAsB,SAA2B;CAC/D,MAAM,EAAE,SAAS,SAAS,uBAAuB,0BAC/C,SAAS,aACV;AAED,KAAI,CAAC,SAAS;AACZ,mBAAiB,iDAAiD;AAClE,SAAO,EACL,MAAM,oCACP;;CAGH,MAAM,gBAA0C;EAC9C,GAAG;EACH,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC9B,uBAAuB,SAAS;EACjC;AACD,kBAAiB,WAAW;EAC1B,SAAS,cAAc;EACvB,gBAAgB,cAAc;EAC9B,qBAAqB,cAAc;EACnC,uBAAuB,cAAc;EACtC,CAAC;AAEF,QAAO,YAAY,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface AnalogRouteIdiomDiagnostic {
|
|
2
|
+
code: string;
|
|
3
|
+
severity: "error" | "warning";
|
|
4
|
+
message: string;
|
|
5
|
+
details?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AnalyzeAnalogRouteFileOptions {
|
|
8
|
+
filename: string;
|
|
9
|
+
code: string;
|
|
10
|
+
routeFiles?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function analyzeAnalogRouteFile(options: AnalyzeAnalogRouteFileOptions): AnalogRouteIdiomDiagnostic[];
|
|
13
|
+
export declare function formatAnalogRouteIdiomDiagnostic(diagnostic: AnalogRouteIdiomDiagnostic, filename: string, workspaceRoot: string): string;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { normalizePath } from "vite";
|
|
3
|
+
import { parseSync } from "oxc-parser";
|
|
4
|
+
//#region packages/platform/src/lib/route-idiom-diagnostics.ts
|
|
5
|
+
var PAGE_FILE_RE = /\.page\.ts$/;
|
|
6
|
+
var ROUTER_OUTLET_RE = /\bRouterOutlet\b|<router-outlet(?:\s|>)/;
|
|
7
|
+
function analyzeAnalogRouteFile(options) {
|
|
8
|
+
const { filename, code, routeFiles = [] } = options;
|
|
9
|
+
const parseResult = parseSync(filename, code, {
|
|
10
|
+
lang: "ts",
|
|
11
|
+
sourceType: "module",
|
|
12
|
+
range: true,
|
|
13
|
+
showSemanticErrors: true
|
|
14
|
+
});
|
|
15
|
+
const parseDiagnostics = parseResult.errors.map((error) => toParseDiagnostic(error));
|
|
16
|
+
if (parseDiagnostics.some((diagnostic) => diagnostic.severity === "error")) return parseDiagnostics;
|
|
17
|
+
const program = parseResult.program;
|
|
18
|
+
const exportedBindings = collectExportedBindings(program);
|
|
19
|
+
const routeMetaBindingName = exportedBindings.routeMeta;
|
|
20
|
+
const routeJsonLdBindingName = exportedBindings.routeJsonLd;
|
|
21
|
+
const diagnostics = [...parseDiagnostics];
|
|
22
|
+
const routeMetaInfo = routeMetaBindingName ? getRouteMetaInfo(program, routeMetaBindingName) : null;
|
|
23
|
+
if (!exportedBindings.hasDefaultExport && !routeMetaInfo?.hasRedirect) diagnostics.push({
|
|
24
|
+
code: "missing-default-export",
|
|
25
|
+
severity: "warning",
|
|
26
|
+
message: "Route files should default-export the page component, unless they are redirect-only routes.",
|
|
27
|
+
details: "Add `export default class ...` or define `routeMeta.redirectTo` for a redirect route."
|
|
28
|
+
});
|
|
29
|
+
if (exportedBindings.hasDefaultExport && routeMetaInfo?.hasRedirect) diagnostics.push({
|
|
30
|
+
code: "redirect-with-component",
|
|
31
|
+
severity: "warning",
|
|
32
|
+
message: "Redirect routes should not also export a page component.",
|
|
33
|
+
details: "Analog ignores the default export when `routeMeta.redirectTo` is present. Remove the component export or remove the redirect."
|
|
34
|
+
});
|
|
35
|
+
if (routeMetaInfo?.hasRedirect && routeMetaInfo.redirectTo && !routeMetaInfo.redirectTo.startsWith("/")) diagnostics.push({
|
|
36
|
+
code: "relative-redirect",
|
|
37
|
+
severity: "warning",
|
|
38
|
+
message: "`routeMeta.redirectTo` should use an absolute path.",
|
|
39
|
+
details: "Nested redirects are documented to use absolute targets such as `/cities/new-york`."
|
|
40
|
+
});
|
|
41
|
+
if (routeJsonLdBindingName) diagnostics.push({
|
|
42
|
+
code: "legacy-route-jsonld-export",
|
|
43
|
+
severity: "warning",
|
|
44
|
+
message: "Prefer `routeMeta.jsonLd` over the legacy top-level `routeJsonLd` export.",
|
|
45
|
+
details: "Keeping JSON-LD inside `routeMeta` makes the route module easier to read and matches the current docs."
|
|
46
|
+
});
|
|
47
|
+
if (isLikelyLayoutRoute(filename, routeFiles) && !ROUTER_OUTLET_RE.test(code)) diagnostics.push({
|
|
48
|
+
code: "layout-without-router-outlet",
|
|
49
|
+
severity: "warning",
|
|
50
|
+
message: "This route file looks like a layout shell, but it does not reference `RouterOutlet` or `<router-outlet>`.",
|
|
51
|
+
details: "Parent layout pages usually import `RouterOutlet` and render an outlet so child routes have somewhere to mount."
|
|
52
|
+
});
|
|
53
|
+
return diagnostics;
|
|
54
|
+
}
|
|
55
|
+
function formatAnalogRouteIdiomDiagnostic(diagnostic, filename, workspaceRoot) {
|
|
56
|
+
const header = `[Analog] ${toDisplayPath(filename, workspaceRoot)} (${diagnostic.code})`;
|
|
57
|
+
const severity = diagnostic.severity.toUpperCase();
|
|
58
|
+
if (diagnostic.details) return `${header}\n${severity}: ${diagnostic.message}\n${diagnostic.details}`;
|
|
59
|
+
return `${header}\n${severity}: ${diagnostic.message}`;
|
|
60
|
+
}
|
|
61
|
+
function toDisplayPath(filename, workspaceRoot) {
|
|
62
|
+
const normalizedFilename = normalizePath(filename);
|
|
63
|
+
const relativePath = normalizePath(relative(normalizePath(workspaceRoot), normalizedFilename));
|
|
64
|
+
if (relativePath && !relativePath.startsWith("..")) return `/${relativePath}`;
|
|
65
|
+
return normalizedFilename;
|
|
66
|
+
}
|
|
67
|
+
function toParseDiagnostic(error) {
|
|
68
|
+
return {
|
|
69
|
+
code: "oxc-parse",
|
|
70
|
+
severity: error.severity === severityError ? "error" : "warning",
|
|
71
|
+
message: error.message,
|
|
72
|
+
details: error.codeframe ?? error.helpMessage ?? void 0
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var severityError = "Error";
|
|
76
|
+
function isLikelyLayoutRoute(filename, routeFiles) {
|
|
77
|
+
if (!PAGE_FILE_RE.test(filename)) return false;
|
|
78
|
+
const routeStem = filename.replace(PAGE_FILE_RE, "");
|
|
79
|
+
return routeFiles.some((routeFile) => routeFile !== filename && routeFile.startsWith(`${routeStem}/`));
|
|
80
|
+
}
|
|
81
|
+
function getRouteMetaInfo(program, bindingName) {
|
|
82
|
+
const routeMetaNode = unwrapRouteMetaObject(getExportedBindingInitializer(program, bindingName));
|
|
83
|
+
if (!routeMetaNode) return null;
|
|
84
|
+
let redirectTo;
|
|
85
|
+
for (const property of routeMetaNode.properties ?? []) {
|
|
86
|
+
if (property?.type !== "Property") continue;
|
|
87
|
+
if (getPropertyName(property.key) !== "redirectTo") continue;
|
|
88
|
+
redirectTo = getStringValue(property.value);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
hasRedirect: typeof redirectTo === "string" && redirectTo.length > 0,
|
|
92
|
+
redirectTo
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function unwrapRouteMetaObject(initializer) {
|
|
96
|
+
if (!initializer) return null;
|
|
97
|
+
if (initializer.type === "ObjectExpression") return initializer;
|
|
98
|
+
if (initializer.type === "CallExpression" && initializer.callee?.type === "Identifier" && initializer.callee.name === "defineRouteMeta") {
|
|
99
|
+
const firstArgument = initializer.arguments?.[0];
|
|
100
|
+
return firstArgument?.type === "ObjectExpression" ? firstArgument : null;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
function getExportedBindingInitializer(program, bindingName) {
|
|
105
|
+
for (const statement of program.body ?? []) {
|
|
106
|
+
if (statement?.type === "VariableDeclaration") {
|
|
107
|
+
const initializer = getVariableInitializer(statement, bindingName);
|
|
108
|
+
if (initializer) return initializer;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (statement?.type === "ExportNamedDeclaration" && statement.declaration?.type === "VariableDeclaration") {
|
|
112
|
+
const initializer = getVariableInitializer(statement.declaration, bindingName);
|
|
113
|
+
if (initializer) return initializer;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function getVariableInitializer(declaration, bindingName) {
|
|
118
|
+
for (const declarator of declaration.declarations ?? []) if (declarator.id?.type === "Identifier" && declarator.id.name === bindingName) return declarator.init;
|
|
119
|
+
}
|
|
120
|
+
function collectExportedBindings(program) {
|
|
121
|
+
let hasDefaultExport = false;
|
|
122
|
+
let routeMeta;
|
|
123
|
+
let routeJsonLd;
|
|
124
|
+
for (const statement of program.body ?? []) {
|
|
125
|
+
if (statement?.type === "ExportDefaultDeclaration") {
|
|
126
|
+
hasDefaultExport = true;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (statement?.type !== "ExportNamedDeclaration") continue;
|
|
130
|
+
const declaration = statement.declaration;
|
|
131
|
+
if (declaration?.type === "VariableDeclaration") for (const declarator of declaration.declarations ?? []) {
|
|
132
|
+
if (declarator.id?.type !== "Identifier") continue;
|
|
133
|
+
if (declarator.id.name === "routeMeta") routeMeta = "routeMeta";
|
|
134
|
+
if (declarator.id.name === "routeJsonLd") routeJsonLd = "routeJsonLd";
|
|
135
|
+
}
|
|
136
|
+
for (const specifier of statement.specifiers ?? []) {
|
|
137
|
+
if (specifier?.type !== "ExportSpecifier" || specifier.local?.type !== "Identifier") continue;
|
|
138
|
+
if (specifier.exported?.type !== "Identifier") continue;
|
|
139
|
+
if (specifier.exported.name === "routeMeta") routeMeta = specifier.local.name;
|
|
140
|
+
if (specifier.exported.name === "routeJsonLd") routeJsonLd = specifier.local.name;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
hasDefaultExport,
|
|
145
|
+
routeMeta,
|
|
146
|
+
routeJsonLd
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function getPropertyName(node) {
|
|
150
|
+
if (node?.type === "Identifier") return node.name;
|
|
151
|
+
if ((node?.type === "Literal" || node?.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
152
|
+
}
|
|
153
|
+
function getStringValue(node) {
|
|
154
|
+
if ((node?.type === "Literal" || node?.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
155
|
+
if (node?.type === "TemplateLiteral" && node.expressions?.length === 0 && node.quasis?.length === 1) return node.quasis[0].value.cooked ?? node.quasis[0].value.raw;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { analyzeAnalogRouteFile, formatAnalogRouteIdiomDiagnostic };
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=route-idiom-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-idiom-diagnostics.js","names":[],"sources":["../../../src/lib/route-idiom-diagnostics.ts"],"sourcesContent":["import { parseSync, type OxcError, type Severity } from 'oxc-parser';\nimport { relative } from 'node:path';\nimport { normalizePath } from 'vite';\n\nexport interface AnalogRouteIdiomDiagnostic {\n code: string;\n severity: 'error' | 'warning';\n message: string;\n details?: string;\n}\n\nexport interface AnalyzeAnalogRouteFileOptions {\n filename: string;\n code: string;\n routeFiles?: string[];\n}\n\nconst PAGE_FILE_RE = /\\.page\\.ts$/;\nconst ROUTER_OUTLET_RE = /\\bRouterOutlet\\b|<router-outlet(?:\\s|>)/;\n\nexport function analyzeAnalogRouteFile(\n options: AnalyzeAnalogRouteFileOptions,\n): AnalogRouteIdiomDiagnostic[] {\n const { filename, code, routeFiles = [] } = options;\n const parseResult = parseSync(filename, code, {\n lang: 'ts',\n sourceType: 'module',\n range: true,\n showSemanticErrors: true,\n });\n\n const parseDiagnostics = parseResult.errors.map((error) =>\n toParseDiagnostic(error),\n );\n\n if (parseDiagnostics.some((diagnostic) => diagnostic.severity === 'error')) {\n return parseDiagnostics;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const program: any = parseResult.program;\n const exportedBindings = collectExportedBindings(program);\n const routeMetaBindingName = exportedBindings.routeMeta;\n const routeJsonLdBindingName = exportedBindings.routeJsonLd;\n const diagnostics = [...parseDiagnostics];\n\n const routeMetaInfo = routeMetaBindingName\n ? getRouteMetaInfo(program, routeMetaBindingName)\n : null;\n\n if (!exportedBindings.hasDefaultExport && !routeMetaInfo?.hasRedirect) {\n diagnostics.push({\n code: 'missing-default-export',\n severity: 'warning',\n message:\n 'Route files should default-export the page component, unless they are redirect-only routes.',\n details:\n 'Add `export default class ...` or define `routeMeta.redirectTo` for a redirect route.',\n });\n }\n\n if (exportedBindings.hasDefaultExport && routeMetaInfo?.hasRedirect) {\n diagnostics.push({\n code: 'redirect-with-component',\n severity: 'warning',\n message: 'Redirect routes should not also export a page component.',\n details:\n 'Analog ignores the default export when `routeMeta.redirectTo` is present. Remove the component export or remove the redirect.',\n });\n }\n\n if (\n routeMetaInfo?.hasRedirect &&\n routeMetaInfo.redirectTo &&\n !routeMetaInfo.redirectTo.startsWith('/')\n ) {\n diagnostics.push({\n code: 'relative-redirect',\n severity: 'warning',\n message: '`routeMeta.redirectTo` should use an absolute path.',\n details:\n 'Nested redirects are documented to use absolute targets such as `/cities/new-york`.',\n });\n }\n\n if (routeJsonLdBindingName) {\n diagnostics.push({\n code: 'legacy-route-jsonld-export',\n severity: 'warning',\n message:\n 'Prefer `routeMeta.jsonLd` over the legacy top-level `routeJsonLd` export.',\n details:\n 'Keeping JSON-LD inside `routeMeta` makes the route module easier to read and matches the current docs.',\n });\n }\n\n if (\n isLikelyLayoutRoute(filename, routeFiles) &&\n !ROUTER_OUTLET_RE.test(code)\n ) {\n diagnostics.push({\n code: 'layout-without-router-outlet',\n severity: 'warning',\n message:\n 'This route file looks like a layout shell, but it does not reference `RouterOutlet` or `<router-outlet>`.',\n details:\n 'Parent layout pages usually import `RouterOutlet` and render an outlet so child routes have somewhere to mount.',\n });\n }\n\n return diagnostics;\n}\n\nexport function formatAnalogRouteIdiomDiagnostic(\n diagnostic: AnalogRouteIdiomDiagnostic,\n filename: string,\n workspaceRoot: string,\n): string {\n const displayName = toDisplayPath(filename, workspaceRoot);\n const header = `[Analog] ${displayName} (${diagnostic.code})`;\n const severity = diagnostic.severity.toUpperCase();\n\n if (diagnostic.details) {\n return `${header}\\n${severity}: ${diagnostic.message}\\n${diagnostic.details}`;\n }\n\n return `${header}\\n${severity}: ${diagnostic.message}`;\n}\n\nfunction toDisplayPath(filename: string, workspaceRoot: string): string {\n const normalizedFilename = normalizePath(filename);\n const normalizedRoot = normalizePath(workspaceRoot);\n const relativePath = normalizePath(\n relative(normalizedRoot, normalizedFilename),\n );\n\n if (relativePath && !relativePath.startsWith('..')) {\n return `/${relativePath}`;\n }\n\n return normalizedFilename;\n}\n\nfunction toParseDiagnostic(error: OxcError): AnalogRouteIdiomDiagnostic {\n return {\n code: 'oxc-parse',\n severity: error.severity === severityError ? 'error' : 'warning',\n message: error.message,\n details: error.codeframe ?? error.helpMessage ?? undefined,\n };\n}\n\nconst severityError: Severity = 'Error';\n\nfunction isLikelyLayoutRoute(filename: string, routeFiles: string[]): boolean {\n if (!PAGE_FILE_RE.test(filename)) {\n return false;\n }\n\n const routeStem = filename.replace(PAGE_FILE_RE, '');\n return routeFiles.some(\n (routeFile) =>\n routeFile !== filename && routeFile.startsWith(`${routeStem}/`),\n );\n}\n\nfunction getRouteMetaInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n program: any,\n bindingName: string,\n): {\n hasRedirect: boolean;\n redirectTo?: string;\n} | null {\n const initializer = getExportedBindingInitializer(program, bindingName);\n const routeMetaNode = unwrapRouteMetaObject(initializer);\n\n if (!routeMetaNode) {\n return null;\n }\n\n let redirectTo: string | undefined;\n\n for (const property of routeMetaNode.properties ?? []) {\n if (property?.type !== 'Property') {\n continue;\n }\n\n const keyName = getPropertyName(property.key);\n if (keyName !== 'redirectTo') {\n continue;\n }\n\n redirectTo = getStringValue(property.value);\n }\n\n return {\n hasRedirect: typeof redirectTo === 'string' && redirectTo.length > 0,\n redirectTo,\n };\n}\n\nfunction unwrapRouteMetaObject(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n initializer: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any | null {\n if (!initializer) {\n return null;\n }\n\n if (initializer.type === 'ObjectExpression') {\n return initializer;\n }\n\n if (\n initializer.type === 'CallExpression' &&\n initializer.callee?.type === 'Identifier' &&\n initializer.callee.name === 'defineRouteMeta'\n ) {\n const firstArgument = initializer.arguments?.[0];\n return firstArgument?.type === 'ObjectExpression' ? firstArgument : null;\n }\n\n return null;\n}\n\nfunction getExportedBindingInitializer(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n program: any,\n bindingName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any | undefined {\n for (const statement of program.body ?? []) {\n if (statement?.type === 'VariableDeclaration') {\n const initializer = getVariableInitializer(statement, bindingName);\n if (initializer) {\n return initializer;\n }\n continue;\n }\n\n if (\n statement?.type === 'ExportNamedDeclaration' &&\n statement.declaration?.type === 'VariableDeclaration'\n ) {\n const initializer = getVariableInitializer(\n statement.declaration,\n bindingName,\n );\n if (initializer) {\n return initializer;\n }\n }\n }\n\n return undefined;\n}\n\nfunction getVariableInitializer(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n declaration: any,\n bindingName: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any | undefined {\n for (const declarator of declaration.declarations ?? []) {\n if (\n declarator.id?.type === 'Identifier' &&\n declarator.id.name === bindingName\n ) {\n return declarator.init;\n }\n }\n\n return undefined;\n}\n\nfunction collectExportedBindings(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n program: any,\n): {\n hasDefaultExport: boolean;\n routeMeta?: string;\n routeJsonLd?: string;\n} {\n let hasDefaultExport = false;\n let routeMeta: string | undefined;\n let routeJsonLd: string | undefined;\n\n for (const statement of program.body ?? []) {\n if (statement?.type === 'ExportDefaultDeclaration') {\n hasDefaultExport = true;\n continue;\n }\n\n if (statement?.type !== 'ExportNamedDeclaration') {\n continue;\n }\n\n const declaration = statement.declaration;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations ?? []) {\n if (declarator.id?.type !== 'Identifier') {\n continue;\n }\n\n if (declarator.id.name === 'routeMeta') {\n routeMeta = 'routeMeta';\n }\n\n if (declarator.id.name === 'routeJsonLd') {\n routeJsonLd = 'routeJsonLd';\n }\n }\n }\n\n for (const specifier of statement.specifiers ?? []) {\n if (\n specifier?.type !== 'ExportSpecifier' ||\n specifier.local?.type !== 'Identifier'\n ) {\n continue;\n }\n\n if (specifier.exported?.type !== 'Identifier') {\n continue;\n }\n\n if (specifier.exported.name === 'routeMeta') {\n routeMeta = specifier.local.name;\n }\n\n if (specifier.exported.name === 'routeJsonLd') {\n routeJsonLd = specifier.local.name;\n }\n }\n }\n\n return {\n hasDefaultExport,\n routeMeta,\n routeJsonLd,\n };\n}\n\nfunction getPropertyName(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node: any,\n): string | undefined {\n if (node?.type === 'Identifier') {\n return node.name;\n }\n\n if (\n (node?.type === 'Literal' || node?.type === 'StringLiteral') &&\n typeof node.value === 'string'\n ) {\n return node.value;\n }\n\n return undefined;\n}\n\nfunction getStringValue(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node: any,\n): string | undefined {\n if (\n (node?.type === 'Literal' || node?.type === 'StringLiteral') &&\n typeof node.value === 'string'\n ) {\n return node.value;\n }\n\n if (\n node?.type === 'TemplateLiteral' &&\n node.expressions?.length === 0 &&\n node.quasis?.length === 1\n ) {\n return node.quasis[0].value.cooked ?? node.quasis[0].value.raw;\n }\n\n return undefined;\n}\n"],"mappings":";;;;AAiBA,IAAM,eAAe;AACrB,IAAM,mBAAmB;AAEzB,SAAgB,uBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,MAAM,aAAa,EAAE,KAAK;CAC5C,MAAM,cAAc,UAAU,UAAU,MAAM;EAC5C,MAAM;EACN,YAAY;EACZ,OAAO;EACP,oBAAoB;EACrB,CAAC;CAEF,MAAM,mBAAmB,YAAY,OAAO,KAAK,U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;;AAMhB,SAAS,eAEP,MACoB;AACpB,MACG,MAAM,SAAS,aAAa,MAAM,SAAS,oBAC5C,OAAO,KAAK,UAAU,SAEtB,QAAO,KAAK;AAGd,KACE,MAAM,SAAS,qBACf,KAAK,aAAa,WAAW,KAC7B,KAAK,QAAQ,WAAW,EAExB,QAAO,KAAK,OAAO,GAAG,MAAM,UAAU,KAAK,OAAO,GAAG,MAAM"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export interface RouteParamInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
type: "dynamic" | "catchAll" | "optionalCatchAll";
|
|
4
|
+
}
|
|
5
|
+
export interface RouteSchemaInfo {
|
|
6
|
+
hasParamsSchema: boolean;
|
|
7
|
+
hasQuerySchema: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface GenerateRouteTreeDeclarationOptions {
|
|
10
|
+
jsonLdFiles?: Iterable<string>;
|
|
11
|
+
}
|
|
12
|
+
export interface RouteEntry {
|
|
13
|
+
/** Stable structural route id derived from the source filename */
|
|
14
|
+
id: string;
|
|
15
|
+
/** The route path segment relative to the nearest existing parent route */
|
|
16
|
+
path: string;
|
|
17
|
+
/** The fully resolved navigation path pattern (e.g., '/users/[id]') */
|
|
18
|
+
fullPath: string;
|
|
19
|
+
/** Extracted parameter information */
|
|
20
|
+
params: RouteParamInfo[];
|
|
21
|
+
/** Original filename that produced this route */
|
|
22
|
+
filename: string;
|
|
23
|
+
/** Schema export info (detected from file content) */
|
|
24
|
+
schemas: RouteSchemaInfo;
|
|
25
|
+
/** Type of source that produced this route */
|
|
26
|
+
kind: "page" | "content";
|
|
27
|
+
/** Parent route id, or null for top-level routes */
|
|
28
|
+
parentId: string | null;
|
|
29
|
+
/** Child route ids */
|
|
30
|
+
children: string[];
|
|
31
|
+
/** Whether the source filename represents an index route */
|
|
32
|
+
isIndex: boolean;
|
|
33
|
+
/** Whether the source filename includes route-group/pathless segments */
|
|
34
|
+
isGroup: boolean;
|
|
35
|
+
/** Whether the route contains a required catch-all parameter */
|
|
36
|
+
isCatchAll: boolean;
|
|
37
|
+
/** Whether the route contains an optional catch-all parameter */
|
|
38
|
+
isOptionalCatchAll: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface RouteCollision {
|
|
41
|
+
fullPath: string;
|
|
42
|
+
keptFile: string;
|
|
43
|
+
droppedFile: string;
|
|
44
|
+
/** True when both files have the same collision priority (hard error). */
|
|
45
|
+
samePriority: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface RouteManifest {
|
|
48
|
+
routes: RouteEntry[];
|
|
49
|
+
collisions: RouteCollision[];
|
|
50
|
+
/** Canonical route per fullPath — precomputed once to avoid redundant work. */
|
|
51
|
+
canonicalByFullPath: Map<string, RouteEntry>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Converts a discovered filename to a route path pattern.
|
|
55
|
+
*
|
|
56
|
+
* Uses the same stripping rules as the existing route system
|
|
57
|
+
* but preserves bracket param syntax instead of converting to
|
|
58
|
+
* Angular's `:param` syntax.
|
|
59
|
+
*
|
|
60
|
+
* The regex applies four alternations (left to right, all replaced with ''):
|
|
61
|
+
* 1. `^(.*?)[\\/](?:routes|pages|content)[\\/]` — anchored, strips everything
|
|
62
|
+
* up to and including the first /routes/, /pages/, or /content/ segment.
|
|
63
|
+
* Handles app-local paths (`/src/app/pages/`) AND additional dirs
|
|
64
|
+
* (`/libs/shared/feature/src/content/`) uniformly.
|
|
65
|
+
* 2. `[\\/](?:app[\\/](?:routes|pages)|src[\\/]content)[\\/]` — non-anchored
|
|
66
|
+
* fallback for legacy paths where the directory marker appears mid-string.
|
|
67
|
+
* 3. `\.page\.(js|ts|analog|ag)$` — strips page file extensions.
|
|
68
|
+
* 4. `\.(ts|md|analog|ag)$` — strips remaining file extensions.
|
|
69
|
+
*
|
|
70
|
+
* Examples:
|
|
71
|
+
* - '/app/routes/index.ts' -> '/'
|
|
72
|
+
* - '/app/routes/about.ts' -> '/about'
|
|
73
|
+
* - '/src/app/pages/users/[id].page.ts' -> '/users/[id]'
|
|
74
|
+
* - '/app/routes/blog.[slug].ts' -> '/blog/[slug]'
|
|
75
|
+
* - '/src/app/pages/(auth)/login.page.ts' -> '/login'
|
|
76
|
+
* - '/src/app/pages/docs/[...slug].page.ts' -> '/docs/[...slug]'
|
|
77
|
+
* - '/src/app/pages/shop/[[...category]].page.ts' -> '/shop/[[...category]]'
|
|
78
|
+
* - '/libs/shared/feature/src/content/test.md' -> '/test'
|
|
79
|
+
*/
|
|
80
|
+
export declare function filenameToRoutePath(filename: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Converts a discovered filename to a stable structural route id.
|
|
83
|
+
*
|
|
84
|
+
* Unlike `filenameToRoutePath`, this preserves route groups and `index`
|
|
85
|
+
* segments so that multiple files resolving to the same URL shape can still
|
|
86
|
+
* have distinct structural identities in the generated route tree metadata.
|
|
87
|
+
*
|
|
88
|
+
* Uses the same directory-stripping regex as `filenameToRoutePath` —
|
|
89
|
+
* changes to the regex must be kept in sync between both functions.
|
|
90
|
+
*/
|
|
91
|
+
export declare function filenameToRouteId(filename: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Extracts parameter information from a route path pattern.
|
|
94
|
+
*/
|
|
95
|
+
export declare function extractRouteParams(routePath: string): RouteParamInfo[];
|
|
96
|
+
/**
|
|
97
|
+
* Detects whether a route file exports schema constants.
|
|
98
|
+
*/
|
|
99
|
+
export declare function detectSchemaExports(fileContent: string): RouteSchemaInfo;
|
|
100
|
+
/**
|
|
101
|
+
* Generates a route manifest from a list of discovered filenames.
|
|
102
|
+
*
|
|
103
|
+
* @param collisionPriority - Optional callback that returns a numeric priority
|
|
104
|
+
* for each filename (lower wins). When provided, this replaces the default
|
|
105
|
+
* hard-coded path-substring heuristic with config-derived precedence.
|
|
106
|
+
*/
|
|
107
|
+
export declare function generateRouteManifest(filenames: string[], schemaDetector?: (filename: string) => RouteSchemaInfo, collisionPriority?: (filename: string) => number): RouteManifest;
|
|
108
|
+
/**
|
|
109
|
+
* Produces a human-readable summary of the generated route manifest.
|
|
110
|
+
*/
|
|
111
|
+
export declare function formatManifestSummary(manifest: RouteManifest): string;
|
|
112
|
+
/**
|
|
113
|
+
* Generates the route-table section for the combined generated route module.
|
|
114
|
+
*/
|
|
115
|
+
export declare function generateRouteTableDeclaration(manifest: RouteManifest): string;
|
|
116
|
+
/**
|
|
117
|
+
* Generates the route-tree section for the combined generated route module.
|
|
118
|
+
*/
|
|
119
|
+
export declare function generateRouteTreeDeclaration(manifest: RouteManifest, options?: GenerateRouteTreeDeclarationOptions): string;
|
|
120
|
+
export type JsonLdObject = Record<string, unknown>;
|
|
121
|
+
export declare function isJsonLdObject(value: unknown): value is JsonLdObject;
|
|
122
|
+
export declare function normalizeJsonLd(value: unknown): JsonLdObject[];
|