@analogjs/platform 3.0.0-alpha.2 → 3.0.0-alpha.21
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 +16 -18
- 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 +120 -0
- package/src/lib/route-manifest.js +411 -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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
//#region packages/platform/src/lib/tailwind-preprocessor.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`
|
|
6
|
+
* directives into Angular component styles when needed. The Tailwind prefix is
|
|
7
|
+
* detected from the configured root CSS file.
|
|
8
|
+
*/
|
|
9
|
+
function tailwindPreprocessor(options) {
|
|
10
|
+
const { tailwindRootCss, mode: modeOption = "auto", shouldInject } = options;
|
|
11
|
+
let rootPrefix;
|
|
12
|
+
return (code, filename) => {
|
|
13
|
+
if (code.includes("@reference")) return code;
|
|
14
|
+
const resolvedMode = typeof modeOption === "function" ? modeOption(filename) : modeOption;
|
|
15
|
+
if (resolvedMode === "disabled") return code;
|
|
16
|
+
const resolvedPrefix = typeof resolvedMode === "object" ? resolvedMode.prefix : getRootPrefix();
|
|
17
|
+
const isRootFile = path.resolve(filename) === path.resolve(tailwindRootCss) || /@import\s+["']tailwindcss["']/.test(code);
|
|
18
|
+
const hasTailwindUsage = resolvedPrefix ? code.includes(`${resolvedPrefix}:`) : false;
|
|
19
|
+
if (!(shouldInject ? shouldInject(code, filename, resolvedPrefix) : hasTailwindUsage && !isRootFile) || !resolvedPrefix) return code;
|
|
20
|
+
return `@reference "${path.relative(path.dirname(filename), tailwindRootCss).replace(/\\/g, "/")}";\n${code}`;
|
|
21
|
+
};
|
|
22
|
+
function getRootPrefix() {
|
|
23
|
+
if (rootPrefix === void 0) rootPrefix = extractTailwindPrefix(readFileSync(tailwindRootCss, "utf-8"));
|
|
24
|
+
return rootPrefix;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function extractTailwindPrefix(code) {
|
|
28
|
+
return code.match(/@import\s+["']tailwindcss["']\s+prefix\(\s*([^)\s;]+)\s*\)/i)?.[1]?.trim() ?? null;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { tailwindPreprocessor };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=tailwind-preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind-preprocessor.js","names":[],"sources":["../../../src/lib/tailwind-preprocessor.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { StylePreprocessor } from '@analogjs/vite-plugin-angular';\n\nexport type TailwindPreprocessorMode = 'auto' | 'disabled' | { prefix: string };\n\nexport interface TailwindPreprocessorOptions {\n /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */\n tailwindRootCss: string;\n\n /**\n * Controls whether the preprocessor auto-detects, disables, or manually\n * overrides the Tailwind prefix for a given file.\n */\n mode?:\n | TailwindPreprocessorMode\n | ((filename: string) => TailwindPreprocessorMode);\n\n /**\n * Optional predicate to override the default `@reference` injection behavior.\n */\n shouldInject?: (\n code: string,\n filename: string,\n resolvedPrefix: string | null,\n ) => boolean;\n}\n\n/**\n * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`\n * directives into Angular component styles when needed. The Tailwind prefix is\n * detected from the configured root CSS file.\n */\nexport function tailwindPreprocessor(\n options: TailwindPreprocessorOptions,\n): StylePreprocessor {\n const { tailwindRootCss, mode: modeOption = 'auto', shouldInject } = options;\n let rootPrefix: string | undefined;\n\n return (code: string, filename: string): string => {\n if (code.includes('@reference')) {\n return code;\n }\n\n const resolvedMode =\n typeof modeOption === 'function' ? modeOption(filename) : modeOption;\n\n if (resolvedMode === 'disabled') {\n return code;\n }\n\n const resolvedPrefix =\n typeof resolvedMode === 'object' ? resolvedMode.prefix : getRootPrefix();\n const isRootFile =\n path.resolve(filename) === path.resolve(tailwindRootCss) ||\n /@import\\s+[\"']tailwindcss[\"']/.test(code);\n const hasTailwindUsage = resolvedPrefix\n ? code.includes(`${resolvedPrefix}:`)\n : false;\n const shouldAddReference = shouldInject\n ? shouldInject(code, filename, resolvedPrefix)\n : hasTailwindUsage && !isRootFile;\n\n if (!shouldAddReference || !resolvedPrefix) {\n return code;\n }\n\n const refPath = path\n .relative(path.dirname(filename), tailwindRootCss)\n .replace(/\\\\/g, '/');\n\n return `@reference \"${refPath}\";\\n${code}`;\n };\n\n function getRootPrefix(): string | null {\n if (rootPrefix === undefined) {\n rootPrefix = extractTailwindPrefix(\n readFileSync(tailwindRootCss, 'utf-8'),\n );\n }\n\n return rootPrefix;\n }\n}\n\nfunction extractTailwindPrefix(code: string): string | null {\n const prefixMatch = code.match(\n /@import\\s+[\"']tailwindcss[\"']\\s+prefix\\(\\s*([^)\\s;]+)\\s*\\)/i,\n );\n\n return prefixMatch?.[1]?.trim() ?? null;\n}\n"],"mappings":";;;;;;;;AAkCA,SAAgB,qBACd,SACmB;CACnB,MAAM,EAAE,iBAAiB,MAAM,aAAa,QAAQ,iBAAiB;CACrE,IAAI;AAEJ,SAAQ,MAAc,aAA6B;AACjD,MAAI,KAAK,SAAS,aAAa,CAC7B,QAAO;EAGT,MAAM,eACJ,OAAO,eAAe,aAAa,WAAW,SAAS,GAAG;AAE5D,MAAI,iBAAiB,WACnB,QAAO;EAGT,MAAM,iBACJ,OAAO,iBAAiB,WAAW,aAAa,SAAS,eAAe;EAC1E,MAAM,aACJ,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,gBAAgB,IACxD,gCAAgC,KAAK,KAAK;EAC5C,MAAM,mBAAmB,iBACrB,KAAK,SAAS,GAAG,eAAe,GAAG,GACnC;AAKJ,MAAI,EAJuB,eACvB,aAAa,MAAM,UAAU,eAAe,GAC5C,oBAAoB,CAAC,eAEE,CAAC,eAC1B,QAAO;AAOT,SAAO,eAJS,KACb,SAAS,KAAK,QAAQ,SAAS,EAAE,gBAAgB,CACjD,QAAQ,OAAO,IAAI,CAEQ,MAAM;;CAGtC,SAAS,gBAA+B;AACtC,MAAI,eAAe,KAAA,EACjB,cAAa,sBACX,aAAa,iBAAiB,QAAQ,CACvC;AAGH,SAAO;;;AAIX,SAAS,sBAAsB,MAA6B;AAK1D,QAJoB,KAAK,MACvB,8DACD,GAEoB,IAAI,MAAM,IAAI"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Plugin } from "vite";
|
|
2
|
+
export interface TypedRoutesPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Output path for the single generated route module,
|
|
5
|
+
* relative to the app root.
|
|
6
|
+
*
|
|
7
|
+
* @default 'src/routeTree.gen.ts'
|
|
8
|
+
*/
|
|
9
|
+
outFile?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Workspace root used to resolve additional route/content directories.
|
|
12
|
+
*
|
|
13
|
+
* @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()
|
|
14
|
+
*/
|
|
15
|
+
workspaceRoot?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Additional page directories to scan for `.page.ts` files.
|
|
18
|
+
*/
|
|
19
|
+
additionalPagesDirs?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Additional content directories to scan for `.md` files.
|
|
22
|
+
*/
|
|
23
|
+
additionalContentDirs?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Include generated `routeJsonLdManifest` exports in the generated route file.
|
|
26
|
+
*
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
jsonLdManifest?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When true, compare generated output against the existing file and
|
|
32
|
+
* throw an error if they differ instead of writing. Useful for CI to
|
|
33
|
+
* detect stale checked-in route files.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
verify?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* When true, production builds fail after regenerating a stale checked-in
|
|
40
|
+
* route file. This preserves self-healing writes in development while making
|
|
41
|
+
* build-time freshness issues visible by default.
|
|
42
|
+
*
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
verifyOnBuild?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Vite plugin that generates a single typed route module for Analog file routes.
|
|
49
|
+
*/
|
|
50
|
+
export declare function typedRoutes(options?: TypedRoutesPluginOptions): Plugin;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { detectSchemaExports, filenameToRoutePath, formatManifestSummary, generateRouteManifest, generateRouteTableDeclaration, generateRouteTreeDeclaration } from "./route-manifest.js";
|
|
2
|
+
import { detectJsonLdModuleExports, extractMarkdownJsonLd, generateJsonLdManifestSource } from "./json-ld-manifest-plugin.js";
|
|
3
|
+
import { createRouteFileDiscovery } from "./route-file-discovery.js";
|
|
4
|
+
import { normalizePath } from "vite";
|
|
5
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
//#region packages/platform/src/lib/typed-routes-plugin.ts
|
|
8
|
+
var DEFAULT_OUT_FILE = "src/routeTree.gen.ts";
|
|
9
|
+
function resolvePluginOptions(options = {}) {
|
|
10
|
+
return {
|
|
11
|
+
outFile: options.outFile ?? DEFAULT_OUT_FILE,
|
|
12
|
+
workspaceRoot: options.workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd(),
|
|
13
|
+
additionalPagesDirs: options.additionalPagesDirs ?? [],
|
|
14
|
+
additionalContentDirs: options.additionalContentDirs ?? [],
|
|
15
|
+
jsonLdManifest: options.jsonLdManifest ?? true,
|
|
16
|
+
verify: options.verify ?? false,
|
|
17
|
+
verifyOnBuild: options.verifyOnBuild ?? true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Vite plugin that generates a single typed route module for Analog file routes.
|
|
22
|
+
*/
|
|
23
|
+
function typedRoutes(options = {}) {
|
|
24
|
+
const resolvedOptions = resolvePluginOptions(options);
|
|
25
|
+
const workspaceRoot = normalizePath(resolvedOptions.workspaceRoot);
|
|
26
|
+
let root = "";
|
|
27
|
+
let command = "serve";
|
|
28
|
+
let discovery;
|
|
29
|
+
function isFreshnessCheck() {
|
|
30
|
+
return resolvedOptions.verify || command === "build" && resolvedOptions.verifyOnBuild;
|
|
31
|
+
}
|
|
32
|
+
function resolveDiscoveredFile(filename) {
|
|
33
|
+
const fromRoot = join(root, filename);
|
|
34
|
+
if (existsSync(fromRoot)) return fromRoot;
|
|
35
|
+
return join(workspaceRoot, filename);
|
|
36
|
+
}
|
|
37
|
+
function detectSchemas(relativeFilename) {
|
|
38
|
+
if (!relativeFilename.endsWith(".ts")) return {
|
|
39
|
+
hasParamsSchema: false,
|
|
40
|
+
hasQuerySchema: false
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
return detectSchemaExports(readFileSync(resolveDiscoveredFile(relativeFilename), "utf-8"));
|
|
44
|
+
} catch {
|
|
45
|
+
return {
|
|
46
|
+
hasParamsSchema: false,
|
|
47
|
+
hasQuerySchema: false
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Ensures the generated route file is imported from an app entry file
|
|
53
|
+
* so the module augmentation is always part of the TypeScript program.
|
|
54
|
+
*/
|
|
55
|
+
function ensureEntryImport() {
|
|
56
|
+
const entryFiles = ["src/main.ts", "src/main.server.ts"];
|
|
57
|
+
function importSpecifierFor(entryFile) {
|
|
58
|
+
const rel = relative(dirname(entryFile), resolvedOptions.outFile).replace(/\.ts$/, "").replace(/\\/g, "/");
|
|
59
|
+
return rel.startsWith(".") ? rel : "./" + rel;
|
|
60
|
+
}
|
|
61
|
+
for (const entryFile of entryFiles) {
|
|
62
|
+
const entryPath = join(root, entryFile);
|
|
63
|
+
if (!existsSync(entryPath)) continue;
|
|
64
|
+
const content = readFileSync(entryPath, "utf-8");
|
|
65
|
+
const specifier = importSpecifierFor(entryFile);
|
|
66
|
+
const escaped = specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
67
|
+
if (new RegExp(`import\\s+['"]${escaped}(\\.ts|\\.js)?['"]`).test(content)) return;
|
|
68
|
+
if (isFreshnessCheck()) return;
|
|
69
|
+
const importLine = `import '${specifier}';`;
|
|
70
|
+
const lines = content.split("\n");
|
|
71
|
+
let lastImportLine = -1;
|
|
72
|
+
for (let i = 0; i < lines.length; i++) if (/^import\s/.test(lines[i])) lastImportLine = i;
|
|
73
|
+
if (lastImportLine >= 0) lines.splice(lastImportLine + 1, 0, importLine);
|
|
74
|
+
else lines.unshift(importLine);
|
|
75
|
+
writeFileSync(entryPath, lines.join("\n"), "utf-8");
|
|
76
|
+
console.log(`[analog] Added route tree import to ${entryFile}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const specifier = importSpecifierFor("src/main.ts");
|
|
80
|
+
if (isFreshnessCheck()) return;
|
|
81
|
+
console.warn(`[analog] Could not find an entry file (src/main.ts or src/main.server.ts) to add the route tree import. Add \`import '${specifier}';\` to your app entry file to ensure typed routing is active.`);
|
|
82
|
+
}
|
|
83
|
+
function generate() {
|
|
84
|
+
const routeFiles = discovery.getRouteFiles();
|
|
85
|
+
const contentFiles = discovery.getContentFiles();
|
|
86
|
+
const manifest = generateRouteManifest([...routeFiles, ...contentFiles], detectSchemas, (filename) => discovery.isAppLocal(filename) ? 0 : 1);
|
|
87
|
+
const declaration = generateRouteTableDeclaration(manifest);
|
|
88
|
+
const canonicalFiles = new Set(manifest.routes.map((route) => route.filename));
|
|
89
|
+
const jsonLdEntries = buildJsonLdEntries(resolveDiscoveredFile, routeFiles.filter((filename) => canonicalFiles.has(filename)), contentFiles.filter((filename) => canonicalFiles.has(filename)));
|
|
90
|
+
const output = combineGeneratedModules(declaration, generateRouteTreeDeclaration(manifest, { jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile) }), resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0 ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile) : "");
|
|
91
|
+
if (manifest.routes.length > 0) console.log(formatManifestSummary(manifest));
|
|
92
|
+
const outPath = join(root, resolvedOptions.outFile);
|
|
93
|
+
const outDir = dirname(outPath);
|
|
94
|
+
const hadExistingOutput = existsSync(outPath);
|
|
95
|
+
if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
|
|
96
|
+
let existing = "";
|
|
97
|
+
try {
|
|
98
|
+
existing = readFileSync(outPath, "utf-8");
|
|
99
|
+
} catch {}
|
|
100
|
+
if (output.includes(root)) console.warn(`[analog] Generated route output contains an absolute path prefix (${root}). Route keys and sourceFile values should be workspace-relative.`);
|
|
101
|
+
const normalizeEndings = (s) => s.replace(/\r\n/g, "\n");
|
|
102
|
+
if (normalizeEndings(existing) !== normalizeEndings(output)) {
|
|
103
|
+
if (resolvedOptions.verify) throw new Error(`[analog] Stale route file detected: ${resolvedOptions.outFile}\nThe checked-in generated route file does not match the current route sources.\nRegenerate route files and commit the updated output.`);
|
|
104
|
+
writeFileSync(outPath, output, "utf-8");
|
|
105
|
+
if (command === "build" && resolvedOptions.verifyOnBuild && hadExistingOutput) throw new Error(`[analog] Stale route file detected during build: ${resolvedOptions.outFile}\nThe generated route file was updated to match the current route sources.\nReview the updated output, commit it if it is checked in, and rerun the build.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
name: "analog-typed-routes",
|
|
110
|
+
config(config, env) {
|
|
111
|
+
command = env.command;
|
|
112
|
+
root = normalizePath(resolve(workspaceRoot, config.root || ".") || ".");
|
|
113
|
+
discovery = createRouteFileDiscovery({
|
|
114
|
+
root,
|
|
115
|
+
workspaceRoot,
|
|
116
|
+
additionalPagesDirs: resolvedOptions.additionalPagesDirs,
|
|
117
|
+
additionalContentDirs: resolvedOptions.additionalContentDirs
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
buildStart() {
|
|
121
|
+
generate();
|
|
122
|
+
if (!isFreshnessCheck()) ensureEntryImport();
|
|
123
|
+
},
|
|
124
|
+
configureServer(server) {
|
|
125
|
+
const regenerate = (path, event) => {
|
|
126
|
+
if (!discovery.getDiscoveredFileKind(path)) return;
|
|
127
|
+
discovery.updateDiscoveredFile(path, event);
|
|
128
|
+
generate();
|
|
129
|
+
};
|
|
130
|
+
server.watcher.on("add", (path) => regenerate(path, "add"));
|
|
131
|
+
server.watcher.on("change", (path) => regenerate(path, "change"));
|
|
132
|
+
server.watcher.on("unlink", (path) => regenerate(path, "unlink"));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function buildJsonLdEntries(resolveFile, routeFiles, contentFiles) {
|
|
137
|
+
const entries = [];
|
|
138
|
+
let importIndex = 0;
|
|
139
|
+
routeFiles.forEach((filename) => {
|
|
140
|
+
try {
|
|
141
|
+
if (!detectJsonLdModuleExports(readFileSync(resolveFile(filename), "utf-8"))) return;
|
|
142
|
+
entries.push({
|
|
143
|
+
kind: "module",
|
|
144
|
+
routePath: filenameToRoutePath(filename),
|
|
145
|
+
sourceFile: filename,
|
|
146
|
+
importAlias: `routeModule${importIndex++}`
|
|
147
|
+
});
|
|
148
|
+
} catch {}
|
|
149
|
+
});
|
|
150
|
+
contentFiles.forEach((filename) => {
|
|
151
|
+
try {
|
|
152
|
+
const jsonLd = extractMarkdownJsonLd(readFileSync(resolveFile(filename), "utf-8"));
|
|
153
|
+
if (jsonLd.length === 0) return;
|
|
154
|
+
entries.push({
|
|
155
|
+
kind: "content",
|
|
156
|
+
routePath: filenameToRoutePath(filename),
|
|
157
|
+
sourceFile: filename,
|
|
158
|
+
jsonLd
|
|
159
|
+
});
|
|
160
|
+
} catch {}
|
|
161
|
+
});
|
|
162
|
+
return entries.sort((a, b) => a.routePath.localeCompare(b.routePath));
|
|
163
|
+
}
|
|
164
|
+
function combineGeneratedModules(...sources) {
|
|
165
|
+
const imports = [];
|
|
166
|
+
const seenImports = /* @__PURE__ */ new Set();
|
|
167
|
+
const bodies = [];
|
|
168
|
+
for (const source of sources) {
|
|
169
|
+
const { body, importLines } = splitGeneratedModule(source);
|
|
170
|
+
for (const importLine of importLines) if (!seenImports.has(importLine)) {
|
|
171
|
+
seenImports.add(importLine);
|
|
172
|
+
imports.push(importLine);
|
|
173
|
+
}
|
|
174
|
+
if (body.trim()) bodies.push(body.trim());
|
|
175
|
+
}
|
|
176
|
+
return [
|
|
177
|
+
"// This file is auto-generated by @analogjs/platform",
|
|
178
|
+
"// Do not edit manually",
|
|
179
|
+
"",
|
|
180
|
+
...imports.length > 0 ? [...imports, ""] : [],
|
|
181
|
+
bodies.join("\n\n"),
|
|
182
|
+
""
|
|
183
|
+
].join("\n");
|
|
184
|
+
}
|
|
185
|
+
function splitGeneratedModule(source) {
|
|
186
|
+
const lines = source.split("\n");
|
|
187
|
+
let index = 0;
|
|
188
|
+
while (index < lines.length && lines[index].startsWith("//")) index++;
|
|
189
|
+
while (index < lines.length && lines[index] === "") index++;
|
|
190
|
+
const importLines = [];
|
|
191
|
+
while (index < lines.length && lines[index].startsWith("import ")) {
|
|
192
|
+
importLines.push(lines[index]);
|
|
193
|
+
index++;
|
|
194
|
+
}
|
|
195
|
+
while (index < lines.length && lines[index] === "") index++;
|
|
196
|
+
return {
|
|
197
|
+
importLines,
|
|
198
|
+
body: lines.slice(index).join("\n")
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
export { typedRoutes };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=typed-routes-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-routes-plugin.js","names":[],"sources":["../../../src/lib/typed-routes-plugin.ts"],"sourcesContent":["import { normalizePath, type Plugin } from 'vite';\nimport { resolve, join, dirname, relative } from 'node:path';\nimport { writeFileSync, mkdirSync, existsSync, readFileSync } from 'node:fs';\n\nimport {\n generateRouteManifest,\n generateRouteTableDeclaration,\n generateRouteTreeDeclaration,\n detectSchemaExports,\n formatManifestSummary,\n filenameToRoutePath,\n} from './route-manifest.js';\nimport type { RouteSchemaInfo } from './route-manifest.js';\nimport {\n detectJsonLdModuleExports,\n extractMarkdownJsonLd,\n generateJsonLdManifestSource,\n type JsonLdManifestEntry,\n} from './json-ld-manifest-plugin.js';\nimport {\n createRouteFileDiscovery,\n type RouteFileDiscovery,\n} from './route-file-discovery.js';\n\nconst DEFAULT_OUT_FILE = 'src/routeTree.gen.ts';\n\nexport interface TypedRoutesPluginOptions {\n /**\n * Output path for the single generated route module,\n * relative to the app root.\n *\n * @default 'src/routeTree.gen.ts'\n */\n outFile?: string;\n /**\n * Workspace root used to resolve additional route/content directories.\n *\n * @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()\n */\n workspaceRoot?: string;\n /**\n * Additional page directories to scan for `.page.ts` files.\n */\n additionalPagesDirs?: string[];\n /**\n * Additional content directories to scan for `.md` files.\n */\n additionalContentDirs?: string[];\n /**\n * Include generated `routeJsonLdManifest` exports in the generated route file.\n *\n * @default true\n */\n jsonLdManifest?: boolean;\n /**\n * When true, compare generated output against the existing file and\n * throw an error if they differ instead of writing. Useful for CI to\n * detect stale checked-in route files.\n *\n * @default false\n */\n verify?: boolean;\n /**\n * When true, production builds fail after regenerating a stale checked-in\n * route file. This preserves self-healing writes in development while making\n * build-time freshness issues visible by default.\n *\n * @default true\n */\n verifyOnBuild?: boolean;\n}\n\nfunction resolvePluginOptions(\n options: TypedRoutesPluginOptions = {},\n): Required<TypedRoutesPluginOptions> {\n return {\n outFile: options.outFile ?? DEFAULT_OUT_FILE,\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n additionalPagesDirs: options.additionalPagesDirs ?? [],\n additionalContentDirs: options.additionalContentDirs ?? [],\n jsonLdManifest: options.jsonLdManifest ?? true,\n verify: options.verify ?? false,\n verifyOnBuild: options.verifyOnBuild ?? true,\n };\n}\n\n/**\n * Vite plugin that generates a single typed route module for Analog file routes.\n */\nexport function typedRoutes(options: TypedRoutesPluginOptions = {}): Plugin {\n const resolvedOptions = resolvePluginOptions(options);\n const workspaceRoot = normalizePath(resolvedOptions.workspaceRoot);\n let root = '';\n let command: 'build' | 'serve' = 'serve';\n let discovery: RouteFileDiscovery;\n\n function isFreshnessCheck(): boolean {\n return (\n resolvedOptions.verify ||\n (command === 'build' && resolvedOptions.verifyOnBuild)\n );\n }\n\n function resolveDiscoveredFile(filename: string): string {\n const fromRoot = join(root, filename);\n if (existsSync(fromRoot)) return fromRoot;\n return join(workspaceRoot, filename);\n }\n\n function detectSchemas(relativeFilename: string): RouteSchemaInfo {\n if (!relativeFilename.endsWith('.ts')) {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n\n try {\n const absPath = resolveDiscoveredFile(relativeFilename);\n const content = readFileSync(absPath, 'utf-8');\n return detectSchemaExports(content);\n } catch {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n }\n\n /**\n * Ensures the generated route file is imported from an app entry file\n * so the module augmentation is always part of the TypeScript program.\n */\n function ensureEntryImport(): void {\n const entryFiles = ['src/main.ts', 'src/main.server.ts'];\n\n // Compute the import specifier relative to the entry file\n function importSpecifierFor(entryFile: string): string {\n const rel = relative(dirname(entryFile), resolvedOptions.outFile)\n .replace(/\\.ts$/, '')\n .replace(/\\\\/g, '/');\n return rel.startsWith('.') ? rel : './' + rel;\n }\n\n for (const entryFile of entryFiles) {\n const entryPath = join(root, entryFile);\n if (!existsSync(entryPath)) continue;\n\n const content = readFileSync(entryPath, 'utf-8');\n const specifier = importSpecifierFor(entryFile);\n\n // Check if any variation of the import already exists\n const escaped = specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pattern = new RegExp(`import\\\\s+['\"]${escaped}(\\\\.ts|\\\\.js)?['\"]`);\n if (pattern.test(content)) {\n return;\n }\n\n if (isFreshnessCheck()) {\n return;\n }\n\n // Insert the import after the last existing import line\n const importLine = `import '${specifier}';`;\n const lines = content.split('\\n');\n let lastImportLine = -1;\n\n for (let i = 0; i < lines.length; i++) {\n if (/^import\\s/.test(lines[i])) {\n lastImportLine = i;\n }\n }\n\n if (lastImportLine >= 0) {\n lines.splice(lastImportLine + 1, 0, importLine);\n } else {\n lines.unshift(importLine);\n }\n\n writeFileSync(entryPath, lines.join('\\n'), 'utf-8');\n console.log(`[analog] Added route tree import to ${entryFile}`);\n return;\n }\n\n // No suitable entry file found\n const specifier = importSpecifierFor('src/main.ts');\n if (isFreshnessCheck()) {\n return;\n }\n console.warn(\n `[analog] Could not find an entry file (src/main.ts or src/main.server.ts) ` +\n `to add the route tree import. Add \\`import '${specifier}';\\` ` +\n `to your app entry file to ensure typed routing is active.`,\n );\n }\n\n function generate(): void {\n const routeFiles = discovery.getRouteFiles();\n const contentFiles = discovery.getContentFiles();\n const allFiles = [...routeFiles, ...contentFiles];\n const manifest = generateRouteManifest(\n allFiles,\n detectSchemas,\n (filename) => (discovery.isAppLocal(filename) ? 0 : 1),\n );\n const declaration = generateRouteTableDeclaration(manifest);\n const canonicalFiles = new Set(\n manifest.routes.map((route) => route.filename),\n );\n const jsonLdEntries = buildJsonLdEntries(\n resolveDiscoveredFile,\n routeFiles.filter((filename) => canonicalFiles.has(filename)),\n contentFiles.filter((filename) => canonicalFiles.has(filename)),\n );\n const routeTree = generateRouteTreeDeclaration(manifest, {\n jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile),\n });\n const output = combineGeneratedModules(\n declaration,\n routeTree,\n resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0\n ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile)\n : '',\n );\n\n if (manifest.routes.length > 0) {\n console.log(formatManifestSummary(manifest));\n }\n\n const outPath = join(root, resolvedOptions.outFile);\n const outDir = dirname(outPath);\n const hadExistingOutput = existsSync(outPath);\n\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n\n let existing = '';\n\n try {\n existing = readFileSync(outPath, 'utf-8');\n } catch {\n // file does not exist yet\n }\n\n // Build-time guard: detect absolute path leaks in generated output.\n // Machine-specific prefixes must never appear in route keys or sourceFile values.\n if (output.includes(root)) {\n console.warn(\n `[analog] Generated route output contains an absolute path prefix (${root}). ` +\n `Route keys and sourceFile values should be workspace-relative.`,\n );\n }\n\n // Normalize line endings before comparison so that files checked in\n // with LF don't appear stale on Windows where readFileSync may return CRLF.\n const normalizeEndings = (s: string) => s.replace(/\\r\\n/g, '\\n');\n if (normalizeEndings(existing) !== normalizeEndings(output)) {\n if (resolvedOptions.verify) {\n throw new Error(\n `[analog] Stale route file detected: ${resolvedOptions.outFile}\\n` +\n `The checked-in generated route file does not match the current route sources.\\n` +\n `Regenerate route files and commit the updated output.`,\n );\n }\n\n writeFileSync(outPath, output, 'utf-8');\n\n if (\n command === 'build' &&\n resolvedOptions.verifyOnBuild &&\n hadExistingOutput\n ) {\n throw new Error(\n `[analog] Stale route file detected during build: ${resolvedOptions.outFile}\\n` +\n `The generated route file was updated to match the current route sources.\\n` +\n `Review the updated output, commit it if it is checked in, and rerun the build.`,\n );\n }\n }\n }\n\n return {\n name: 'analog-typed-routes',\n config(config, env) {\n command = env.command;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n discovery = createRouteFileDiscovery({\n root,\n workspaceRoot,\n additionalPagesDirs: resolvedOptions.additionalPagesDirs,\n additionalContentDirs: resolvedOptions.additionalContentDirs,\n });\n },\n buildStart() {\n generate();\n if (!isFreshnessCheck()) {\n ensureEntryImport();\n }\n },\n configureServer(server) {\n const regenerate = (path: string, event: 'add' | 'change' | 'unlink') => {\n // Reuse the discovery matcher so watch-time updates stay in sync with\n // the initial scan and don't pull Nitro server routes into routeTree.gen.ts.\n if (!discovery.getDiscoveredFileKind(path)) {\n return;\n }\n\n discovery.updateDiscoveredFile(path, event);\n generate();\n };\n\n server.watcher.on('add', (path) => regenerate(path, 'add'));\n server.watcher.on('change', (path) => regenerate(path, 'change'));\n server.watcher.on('unlink', (path) => regenerate(path, 'unlink'));\n },\n };\n}\n\nfunction buildJsonLdEntries(\n resolveFile: (filename: string) => string,\n routeFiles: string[],\n contentFiles: string[],\n): JsonLdManifestEntry[] {\n const entries: JsonLdManifestEntry[] = [];\n let importIndex = 0;\n\n routeFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n if (!detectJsonLdModuleExports(source)) {\n return;\n }\n\n entries.push({\n kind: 'module',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n importAlias: `routeModule${importIndex++}`,\n });\n } catch {\n // ignore unreadable route file\n }\n });\n\n contentFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n const jsonLd = extractMarkdownJsonLd(source);\n\n if (jsonLd.length === 0) {\n return;\n }\n\n entries.push({\n kind: 'content',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n jsonLd,\n });\n } catch {\n // ignore unreadable content file\n }\n });\n\n return entries.sort((a, b) => a.routePath.localeCompare(b.routePath));\n}\n\nfunction combineGeneratedModules(...sources: string[]): string {\n const imports: string[] = [];\n const seenImports = new Set<string>();\n const bodies: string[] = [];\n\n for (const source of sources) {\n const { body, importLines } = splitGeneratedModule(source);\n for (const importLine of importLines) {\n if (!seenImports.has(importLine)) {\n seenImports.add(importLine);\n imports.push(importLine);\n }\n }\n if (body.trim()) {\n bodies.push(body.trim());\n }\n }\n\n return [\n '// This file is auto-generated by @analogjs/platform',\n '// Do not edit manually',\n '',\n ...(imports.length > 0 ? [...imports, ''] : []),\n bodies.join('\\n\\n'),\n '',\n ].join('\\n');\n}\n\nfunction splitGeneratedModule(source: string): {\n importLines: string[];\n body: string;\n} {\n const lines = source.split('\\n');\n let index = 0;\n\n while (index < lines.length && lines[index].startsWith('//')) {\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n const importLines: string[] = [];\n while (index < lines.length && lines[index].startsWith('import ')) {\n importLines.push(lines[index]);\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n return {\n importLines,\n body: lines.slice(index).join('\\n'),\n };\n}\n"],"mappings":";;;;;;;AAwBA,IAAM,mBAAmB;AAgDzB,SAAS,qBACP,UAAoC,EAAE,EACF;AACpC,QAAO;EACL,SAAS,QAAQ,WAAW;EAC5B,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,qBAAqB,QAAQ,uBAAuB,EAAE;EACtD,uBAAuB,QAAQ,yBAAyB,EAAE;EAC1D,gBAAgB,QAAQ,kBAAkB;EAC1C,QAAQ,QAAQ,UAAU;EAC1B,eAAe,QAAQ,iBAAiB;EACzC;;;;;AAMH,SAAgB,YAAY,UAAoC,EAAE,EAAU;CAC1E,MAAM,kBAAkB,qBAAqB,QAAQ;CACrD,MAAM,gBAAgB,cAAc,gBAAgB,cAAc;CAClE,IAAI,OAAO;CACX,IAAI,UAA6B;CACjC,IAAI;CA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C9C;AAGF,QAAO;EACL;EACA,MAAM,MAAM,MAAM,MAAM,CAAC,KAAK,KAAK;EACpC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
//#region packages/platform/src/lib/utils/rolldown.ts
|
|
3
|
+
function isRolldown() {
|
|
4
|
+
return !!vite.rolldownVersion;
|
|
5
|
+
}
|
|
6
|
+
function getJsTransformConfigKey() {
|
|
7
|
+
return isRolldown() ? "oxc" : "esbuild";
|
|
8
|
+
}
|
|
9
|
+
function getBundleOptionsKey() {
|
|
10
|
+
return isRolldown() ? "rolldownOptions" : "rollupOptions";
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getBundleOptionsKey, getJsTransformConfigKey };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=rolldown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolldown.js","names":[],"sources":["../../../../src/lib/utils/rolldown.ts"],"sourcesContent":["import * as vite from 'vite';\n\nexport function isRolldown(): boolean {\n return !!vite.rolldownVersion;\n}\n\nexport function getJsTransformConfigKey(): 'oxc' | 'esbuild' {\n return isRolldown() ? 'oxc' : 'esbuild';\n}\n\nexport function getBundleOptionsKey(): 'rolldownOptions' | 'rollupOptions' {\n return isRolldown() ? 'rolldownOptions' : 'rollupOptions';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;AACpC,QAAO,CAAC,CAAC,KAAK;;AAGhB,SAAgB,0BAA6C;AAC3D,QAAO,YAAY,GAAG,QAAQ;;AAGhC,SAAgB,sBAA2D;AACzE,QAAO,YAAY,GAAG,oBAAoB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function serverModePlugin(): Plugin;
|
|
3
|
+
* This plugin ensures the ngServerMode flag is set
|
|
4
|
+
* during SSR. This should be revisited when Vite 6 lands
|
|
5
|
+
* with the new Environment API.
|
|
6
|
+
*/
|
|
7
|
+
export declare function serverModePlugin(): Plugin[];
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
//#region packages/platform/src/server-mode-plugin.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
code: code.replaceAll('ngServerMode', 'true'),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
17
|
-
},
|
|
18
|
-
};
|
|
3
|
+
* This plugin ensures the ngServerMode flag is set
|
|
4
|
+
* during SSR. This should be revisited when Vite 6 lands
|
|
5
|
+
* with the new Environment API.
|
|
6
|
+
*/
|
|
7
|
+
function serverModePlugin() {
|
|
8
|
+
return [{
|
|
9
|
+
name: "analogjs-server-mode-plugin",
|
|
10
|
+
transform(code, id, options) {
|
|
11
|
+
if (options?.ssr && (id.endsWith("platform-server.mjs") || id.endsWith("core.mjs"))) return { code: code.replaceAll("ngServerMode", "true") };
|
|
12
|
+
}
|
|
13
|
+
}];
|
|
19
14
|
}
|
|
20
|
-
//#
|
|
15
|
+
//#endregion
|
|
16
|
+
export { serverModePlugin };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=server-mode-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-mode-plugin.js","names":[],"sources":["../../src/server-mode-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\n\n/**\n * This plugin ensures the ngServerMode flag is set\n * during SSR. This should be revisited when Vite 6 lands\n * with the new Environment API.\n */\nexport function serverModePlugin(): Plugin[] {\n return [\n {\n name: 'analogjs-server-mode-plugin',\n transform(code, id, options) {\n if (\n options?.ssr &&\n (id.endsWith('platform-server.mjs') || id.endsWith('core.mjs'))\n ) {\n return {\n code: code.replaceAll('ngServerMode', 'true'),\n };\n }\n\n return;\n },\n },\n ];\n}\n"],"mappings":";;;;;;AAOA,SAAgB,mBAA6B;AAC3C,QAAO,CACL;EACE,MAAM;EACN,UAAU,MAAM,IAAI,SAAS;AAC3B,OACE,SAAS,QACR,GAAG,SAAS,sBAAsB,IAAI,GAAG,SAAS,WAAW,EAE9D,QAAO,EACL,MAAM,KAAK,WAAW,gBAAgB,OAAO,EAC9C;;EAKN,CACF"}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3BsYXRmb3JtL3NyYy9saWIvY29udGVudC9wcmlzbS9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3BsYXRmb3JtL3NyYy9saWIvY29udGVudC9zaGlraS9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# @analogjs/platform
|
|
2
|
-
|
|
3
|
-
Official plugin to add Analog to your Nx monorepo.
|
|
4
|
-
|
|
5
|
-
## Supported Generators
|
|
6
|
-
|
|
7
|
-
### app
|
|
8
|
-
|
|
9
|
-
Creates a preconfigured Analog application.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
nx g @analogjs/platform:application analog-app
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Development
|
|
16
|
-
|
|
17
|
-
### Building
|
|
18
|
-
|
|
19
|
-
Run `nx build nx-plugin` to build the library.
|
|
20
|
-
|
|
21
|
-
### Running unit tests
|
|
22
|
-
|
|
23
|
-
Run `nx test nx-plugin` to execute the unit tests via [Vitest](https://vitest.dev).
|
package/src/lib/nx-plugin/src/generators/app/files/tailwind/v2/tailwind.config.cjs__template__
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind');
|
|
2
|
-
const { join } = require('node:path');
|
|
3
|
-
|
|
4
|
-
/** @type {import('tailwindcss').Config} */
|
|
5
|
-
module.exports = {
|
|
6
|
-
content: [
|
|
7
|
-
join(__dirname, '<%= relativeSourceRoot %>/**/!(*.stories|*.spec).{ts,html}'),
|
|
8
|
-
...createGlobPatternsForDependencies(__dirname),
|
|
9
|
-
],
|
|
10
|
-
theme: {
|
|
11
|
-
extend: {},
|
|
12
|
-
},
|
|
13
|
-
plugins: [],
|
|
14
|
-
};
|
package/src/lib/nx-plugin/src/generators/app/files/tailwind/v3/tailwind.config.ts__template__
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss';
|
|
2
|
-
import { createGlobPatternsForDependencies } from '@nx/angular/tailwind';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
content: [
|
|
7
|
-
join(__dirname, '<%= relativeSourceRoot %>/**/!(*.stories|*.spec).{ts,html,md,analog,ag}'),
|
|
8
|
-
...createGlobPatternsForDependencies(__dirname),
|
|
9
|
-
],
|
|
10
|
-
theme: {
|
|
11
|
-
extend: {},
|
|
12
|
-
},
|
|
13
|
-
plugins: [],
|
|
14
|
-
} satisfies Config;
|
package/src/lib/nx-plugin/src/generators/app/files/tailwind/v4/tailwind.config.ts__template__
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss';
|
|
2
|
-
import { createGlobPatternsForDependencies } from '@nx/angular/tailwind';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
content: [
|
|
7
|
-
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,html,md,analog,ag}'),
|
|
8
|
-
...createGlobPatternsForDependencies(__dirname),
|
|
9
|
-
],
|
|
10
|
-
theme: {
|
|
11
|
-
extend: {},
|
|
12
|
-
},
|
|
13
|
-
plugins: [],
|
|
14
|
-
} satisfies Config;
|
package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/index.html__template__
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>MyApp</title>
|
|
6
|
-
<base href="/">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
-
<link rel="icon" type="image/x-icon" href="/src/favicon.ico">
|
|
9
|
-
<link rel="stylesheet" href="/src/styles.css" />
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<<%= fileName %>-root></<%= fileName %>-root>
|
|
13
|
-
<script type="module" src="/src/main.ts"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { RouterTestingModule } from '@angular/router/testing';
|
|
3
|
-
import { AppComponent } from './app.component';
|
|
4
|
-
|
|
5
|
-
describe('AppComponent', () => {
|
|
6
|
-
beforeEach(async () => {
|
|
7
|
-
await TestBed.configureTestingModule({
|
|
8
|
-
imports: [RouterTestingModule, AppComponent],
|
|
9
|
-
}).compileComponents();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should create the app', () => {
|
|
13
|
-
const fixture = TestBed.createComponent(AppComponent);
|
|
14
|
-
const app = fixture.componentInstance;
|
|
15
|
-
expect(app).toBeTruthy();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
2
|
-
import { RouterOutlet } from '@angular/router';
|
|
3
|
-
|
|
4
|
-
@Component({
|
|
5
|
-
selector: '<%= fileName %>-root',
|
|
6
|
-
standalone: true,
|
|
7
|
-
imports: [RouterOutlet],
|
|
8
|
-
template: ` <router-outlet></router-outlet> `,
|
|
9
|
-
})
|
|
10
|
-
export class AppComponent {}
|
package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/favicon.ico__template__
DELETED
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import 'zone.js/node';
|
|
2
|
-
import { enableProdMode } from '@angular/core';
|
|
3
|
-
import { renderApplication } from '@angular/platform-server';
|
|
4
|
-
import { provideFileRouter } from '@analogjs/router';
|
|
5
|
-
import { withEnabledBlockingInitialNavigation } from '@angular/router';
|
|
6
|
-
|
|
7
|
-
import { AppComponent } from './app/app.component';
|
|
8
|
-
import { mainProviders } from './main.providers';
|
|
9
|
-
|
|
10
|
-
if (import.meta.env.PROD) {
|
|
11
|
-
enableProdMode();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default async function render(url: string, document: string) {
|
|
15
|
-
const html = await renderApplication(AppComponent, {
|
|
16
|
-
appId: '<%= fileName %>',
|
|
17
|
-
document,
|
|
18
|
-
url,
|
|
19
|
-
providers: [provideFileRouter(withEnabledBlockingInitialNavigation()), ...mainProviders],
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return html;
|
|
23
|
-
}
|
package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import 'zone.js';
|
|
2
|
-
import { bootstrapApplication } from '@angular/platform-browser';
|
|
3
|
-
import { provideFileRouter } from '@analogjs/router';
|
|
4
|
-
import { AppComponent } from './app/app.component';
|
|
5
|
-
import { mainProviders } from './main.providers';
|
|
6
|
-
<% if (addTRPC) { %>
|
|
7
|
-
import { provideTrpcClient } from './trpc-client';
|
|
8
|
-
<% } %>
|
|
9
|
-
|
|
10
|
-
bootstrapApplication(AppComponent, {
|
|
11
|
-
providers: [
|
|
12
|
-
provideFileRouter(),
|
|
13
|
-
<% if (addTRPC) { %>
|
|
14
|
-
provideTrpcClient(),
|
|
15
|
-
<% } %>
|
|
16
|
-
...mainProviders],
|
|
17
|
-
});
|
|
File without changes
|