@analogjs/platform 3.0.0-beta.3 → 3.0.0-beta.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 +12 -8
- package/src/lib/content-plugin.js +12 -3
- package/src/lib/content-plugin.js.map +1 -1
- package/src/lib/deps-plugin.d.ts +1 -1
- package/src/lib/deps-plugin.js +10 -6
- package/src/lib/deps-plugin.js.map +1 -1
- package/src/lib/get-page-endpoints.d.ts +25 -0
- package/src/lib/get-page-endpoints.js +29 -0
- package/src/lib/get-page-endpoints.js.map +1 -0
- package/src/lib/nitro/analog-nitro-plugin.js +10 -12
- package/src/lib/nitro/analog-nitro-plugin.js.map +1 -1
- package/src/lib/nitro/get-page-handlers.d.ts +4 -19
- package/src/lib/nitro/get-page-handlers.js +9 -26
- package/src/lib/nitro/get-page-handlers.js.map +1 -1
- package/src/lib/nx-plugin/executors.json +0 -7
- package/src/lib/nx-plugin/src/generators/app/compat.d.ts +2 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js +4 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/generator.js +7 -2
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +2 -2
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +3 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +5 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/compat.d.ts +2 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js +4 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/page/compat.d.ts +2 -1
- package/src/lib/nx-plugin/src/generators/page/compat.js +4 -1
- package/src/lib/nx-plugin/src/generators/page/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/preset/__snapshots__/generator.spec.ts.snap +4 -0
- package/src/lib/nx-plugin/src/generators/preset/generator.js +5 -2
- package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.d.ts +2 -2
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +7 -3
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/versions.d.ts +9 -6
- package/src/lib/nx-plugin/src/utils/versions/versions.js +13 -7
- package/src/lib/nx-plugin/src/utils/versions/versions.js.map +1 -1
- package/src/lib/options.d.ts +16 -0
- package/src/lib/platform-plugin.js +2 -0
- package/src/lib/platform-plugin.js.map +1 -1
- package/src/lib/route-idiom-diagnostics.js +23 -8
- package/src/lib/route-idiom-diagnostics.js.map +1 -1
- package/src/lib/router-plugin.js +1 -1
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/server-plugin.d.ts +9 -0
- package/src/lib/server-plugin.js +170 -0
- package/src/lib/server-plugin.js.map +1 -0
- package/src/lib/typed-routes-plugin.js +1 -1
- package/src/lib/typed-routes-plugin.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.d.ts +0 -3
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +0 -7
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +0 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +0 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.json +0 -101
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.d.ts +0 -2
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +0 -6
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimum-supported-versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/generators/app/versions/minimum-supported-versions.ts"],"sourcesContent":["import { lt, coerce } from 'semver';\n\nexport const MINIMUM_SUPPORTED_NX_VERSION = '23.2.0';\nexport const MINIMUM_SUPPORTED_ANGULAR_VERSION = '20.0.0';\n\nexport const belowMinimumSupportedNxVersion = (nxVersion: string): boolean =>\n lt(coerce(nxVersion)!, MINIMUM_SUPPORTED_NX_VERSION);\n"],"mappings":";;AAEA,IAAa,+BAA+B;
|
|
1
|
+
{"version":3,"file":"minimum-supported-versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/generators/app/versions/minimum-supported-versions.ts"],"sourcesContent":["import { lt, coerce } from 'semver';\n\nexport const MINIMUM_SUPPORTED_NX_VERSION = '21.2.0';\nexport const MINIMUM_SUPPORTED_OXLINT_NX_VERSION = '23.2.0';\nexport const MINIMUM_SUPPORTED_ANGULAR_VERSION = '20.0.0';\n\nexport const belowMinimumSupportedNxVersion = (nxVersion: string): boolean =>\n lt(coerce(nxVersion)!, MINIMUM_SUPPORTED_NX_VERSION);\n\nexport const belowMinimumSupportedOxlintNxVersion = (\n nxVersion: string,\n): boolean => lt(coerce(nxVersion)!, MINIMUM_SUPPORTED_OXLINT_NX_VERSION);\n"],"mappings":";;AAEA,IAAa,+BAA+B;AAC5C,IAAa,sCAAsC;AAGnD,IAAa,kCAAkC,eAAA,GAC7C,OAAA,GAAA,EAAA,GAAG,OAAA,OAAA,CAAO,SAAS,GAAI,4BAA4B;AAErD,IAAa,wCACX,eAAA,GACY,OAAA,GAAA,EAAA,GAAG,OAAA,OAAA,CAAO,SAAS,GAAI,mCAAmC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { convertNxGenerator } from "@nx/devkit";
|
|
2
|
+
import setupAnalogGenerator from "./generator";
|
|
2
3
|
/**
|
|
3
4
|
* Angular CLI schematic wrapper for the Analog init/migrate generator.
|
|
4
5
|
* Referenced by `generators.json#schematics.init.factory` so that
|
|
5
6
|
* `ng generate @analogjs/platform:migrate` resolves through the
|
|
6
7
|
* Angular schematics engine.
|
|
7
8
|
*/
|
|
8
|
-
export declare
|
|
9
|
+
export declare function initSchematic(options: Parameters<typeof setupAnalogGenerator>[1]): ReturnType<ReturnType<typeof convertNxGenerator>>;
|
|
9
10
|
export default initSchematic;
|
|
@@ -3,6 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_src_generators_init_generator = require("./generator.js");
|
|
6
|
+
let _nx_devkit = require("@nx/devkit");
|
|
6
7
|
//#region packages/nx-plugin/src/generators/init/compat.ts
|
|
7
8
|
/**
|
|
8
9
|
* Angular CLI schematic wrapper for the Analog init/migrate generator.
|
|
@@ -10,7 +11,9 @@ const require_src_generators_init_generator = require("./generator.js");
|
|
|
10
11
|
* `ng generate @analogjs/platform:migrate` resolves through the
|
|
11
12
|
* Angular schematics engine.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
function initSchematic(options) {
|
|
15
|
+
return (0, _nx_devkit.convertNxGenerator)(require_src_generators_init_generator)(options);
|
|
16
|
+
}
|
|
14
17
|
//#endregion
|
|
15
18
|
exports.default = initSchematic;
|
|
16
19
|
exports.initSchematic = initSchematic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/init/compat.ts"],"sourcesContent":["import { convertNxGenerator } from '@nx/devkit';\n\nimport setupAnalogGenerator from './generator';\n\n/**\n * Angular CLI schematic wrapper for the Analog init/migrate generator.\n * Referenced by `generators.json#schematics.init.factory` so that\n * `ng generate @analogjs/platform:migrate` resolves through the\n * Angular schematics engine.\n */\nexport
|
|
1
|
+
{"version":3,"file":"compat.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/init/compat.ts"],"sourcesContent":["import { convertNxGenerator } from '@nx/devkit';\n\nimport setupAnalogGenerator from './generator';\n\n/**\n * Angular CLI schematic wrapper for the Analog init/migrate generator.\n * Referenced by `generators.json#schematics.init.factory` so that\n * `ng generate @analogjs/platform:migrate` resolves through the\n * Angular schematics engine.\n */\nexport function initSchematic(\n options: Parameters<typeof setupAnalogGenerator>[1],\n): ReturnType<ReturnType<typeof convertNxGenerator>> {\n return convertNxGenerator(setupAnalogGenerator)(options);\n}\nexport default initSchematic;\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAgB,cACd,SACmD;CACnD,QAAA,GAAO,WAAA,mBAAA,CAAmB,qCAAoB,CAAC,CAAC,OAAO;AACzD"}
|
|
@@ -3,9 +3,9 @@ const require_dependencies = require("../../../utils/versions/dependencies.js");
|
|
|
3
3
|
let _nx_devkit = require("@nx/devkit");
|
|
4
4
|
//#region packages/nx-plugin/src/generators/init/lib/add-analog-dependencies.ts
|
|
5
5
|
function addAnalogDependencies(tree, angularVersion, vitest, nxVersion) {
|
|
6
|
-
const devDependencies = require_dev_dependencies.getAnalogDevDependencies(angularVersion);
|
|
6
|
+
const devDependencies = require_dev_dependencies.getAnalogDevDependencies(angularVersion, nxVersion);
|
|
7
7
|
const dependencies = require_dependencies.getAnalogDependencies(angularVersion);
|
|
8
|
-
if (
|
|
8
|
+
if (nxVersion) devDependencies["@nx/vite"] = `^${nxVersion}`;
|
|
9
9
|
if (!vitest) {
|
|
10
10
|
delete devDependencies["vitest"];
|
|
11
11
|
delete devDependencies["@vitest/coverage-v8"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-analog-dependencies.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/generators/init/lib/add-analog-dependencies.ts"],"sourcesContent":["import { addDependenciesToPackageJson, Tree } from '@nx/devkit';\n\nimport { getAnalogDevDependencies } from '../../../utils/versions/dev-dependencies';\nimport { getAnalogDependencies } from '../../../utils/versions/dependencies';\n\nexport function addAnalogDependencies(\n tree: Tree,\n angularVersion: string,\n vitest: boolean,\n nxVersion?: string,\n): void {\n const devDependencies: Record<string, string>
|
|
1
|
+
{"version":3,"file":"add-analog-dependencies.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/generators/init/lib/add-analog-dependencies.ts"],"sourcesContent":["import { addDependenciesToPackageJson, Tree } from '@nx/devkit';\n\nimport { getAnalogDevDependencies } from '../../../utils/versions/dev-dependencies';\nimport { getAnalogDependencies } from '../../../utils/versions/dependencies';\n\nexport function addAnalogDependencies(\n tree: Tree,\n angularVersion: string,\n vitest: boolean,\n nxVersion?: string,\n): void {\n const devDependencies: Record<string, string> = getAnalogDevDependencies(\n angularVersion,\n nxVersion,\n );\n const dependencies = getAnalogDependencies(angularVersion);\n\n if (nxVersion) {\n devDependencies['@nx/vite'] = `^${nxVersion}`;\n }\n\n if (!vitest) {\n delete devDependencies['vitest'];\n delete devDependencies['@vitest/coverage-v8'];\n delete devDependencies['@vitest/ui'];\n }\n\n addDependenciesToPackageJson(\n tree,\n {\n ...dependencies,\n '@angular/platform-server': `^${angularVersion}`,\n },\n devDependencies,\n );\n}\n"],"mappings":";;;;AAKA,SAAgB,sBACd,MACA,gBACA,QACA,WACM;CACN,MAAM,kBAA0C,yBAAA,yBAC9C,gBACA,SACF;CACA,MAAM,eAAe,qBAAA,sBAAsB,cAAc;CAEzD,IAAI,WACF,gBAAgB,cAAc,IAAI;CAGpC,IAAI,CAAC,QAAQ;EACX,OAAO,gBAAgB;EACvB,OAAO,gBAAgB;EACvB,OAAO,gBAAgB;CACzB;CAEA,CAAA,GAAA,WAAA,6BAAA,CACE,MACA;EACE,GAAG;EACH,4BAA4B,IAAI;CAClC,GACA,eACF;AACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { convertNxGenerator } from "@nx/devkit";
|
|
2
|
+
import analogPageGenerator from "./generator";
|
|
2
3
|
/**
|
|
3
4
|
* Angular CLI schematic wrapper for the Analog page generator.
|
|
4
5
|
* Referenced by `generators.json#schematics.page.factory` so that
|
|
5
6
|
* `ng generate @analogjs/platform:page` resolves through the
|
|
6
7
|
* Angular schematics engine.
|
|
7
8
|
*/
|
|
8
|
-
export declare
|
|
9
|
+
export declare function pageSchematic(options: Parameters<typeof analogPageGenerator>[1]): ReturnType<ReturnType<typeof convertNxGenerator>>;
|
|
9
10
|
export default pageSchematic;
|
|
@@ -3,6 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_src_generators_page_generator = require("./generator.js");
|
|
6
|
+
let _nx_devkit = require("@nx/devkit");
|
|
6
7
|
//#region packages/nx-plugin/src/generators/page/compat.ts
|
|
7
8
|
/**
|
|
8
9
|
* Angular CLI schematic wrapper for the Analog page generator.
|
|
@@ -10,7 +11,9 @@ const require_src_generators_page_generator = require("./generator.js");
|
|
|
10
11
|
* `ng generate @analogjs/platform:page` resolves through the
|
|
11
12
|
* Angular schematics engine.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
function pageSchematic(options) {
|
|
15
|
+
return (0, _nx_devkit.convertNxGenerator)(require_src_generators_page_generator)(options);
|
|
16
|
+
}
|
|
14
17
|
//#endregion
|
|
15
18
|
exports.default = pageSchematic;
|
|
16
19
|
exports.pageSchematic = pageSchematic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/page/compat.ts"],"sourcesContent":["import { convertNxGenerator } from '@nx/devkit';\n\nimport analogPageGenerator from './generator';\n\n/**\n * Angular CLI schematic wrapper for the Analog page generator.\n * Referenced by `generators.json#schematics.page.factory` so that\n * `ng generate @analogjs/platform:page` resolves through the\n * Angular schematics engine.\n */\nexport
|
|
1
|
+
{"version":3,"file":"compat.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/page/compat.ts"],"sourcesContent":["import { convertNxGenerator } from '@nx/devkit';\n\nimport analogPageGenerator from './generator';\n\n/**\n * Angular CLI schematic wrapper for the Analog page generator.\n * Referenced by `generators.json#schematics.page.factory` so that\n * `ng generate @analogjs/platform:page` resolves through the\n * Angular schematics engine.\n */\nexport function pageSchematic(\n options: Parameters<typeof analogPageGenerator>[1],\n): ReturnType<ReturnType<typeof convertNxGenerator>> {\n return convertNxGenerator(analogPageGenerator)(options);\n}\nexport default pageSchematic;\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAgB,cACd,SACmD;CACnD,QAAA,GAAO,WAAA,mBAAA,CAAmB,qCAAmB,CAAC,CAAC,OAAO;AACxD"}
|
|
@@ -68,6 +68,10 @@ exports[`preset generator > should match project.json 1`] = `
|
|
|
68
68
|
},
|
|
69
69
|
"serve-static": {
|
|
70
70
|
"continuous": true,
|
|
71
|
+
"readyWhen": {
|
|
72
|
+
"signal": true
|
|
73
|
+
},
|
|
74
|
+
"dependsOn": ["build"],
|
|
71
75
|
"executor": "@nx/web:file-server",
|
|
72
76
|
"options": {
|
|
73
77
|
"buildTarget": "my-app:build",
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
const require_minimum_supported_versions = require("../app/versions/minimum-supported-versions.js");
|
|
1
2
|
let _nx_devkit = require("@nx/devkit");
|
|
2
3
|
let node_path = require("node:path");
|
|
3
4
|
//#region packages/nx-plugin/src/generators/preset/generator.ts
|
|
4
5
|
async function generator_default(tree, options) {
|
|
5
6
|
(0, _nx_devkit.ensurePackage)("@nx/angular", _nx_devkit.NX_VERSION);
|
|
6
7
|
(0, _nx_devkit.ensurePackage)("@nx/vite", _nx_devkit.NX_VERSION);
|
|
7
|
-
if (options.linter === "oxlint")
|
|
8
|
-
|
|
8
|
+
if (options.linter === "oxlint") {
|
|
9
|
+
if (require_minimum_supported_versions.belowMinimumSupportedOxlintNxVersion(_nx_devkit.NX_VERSION)) throw new Error(`Nx v${require_minimum_supported_versions.MINIMUM_SUPPORTED_OXLINT_NX_VERSION} or newer is required to use the oxlint linter`);
|
|
10
|
+
(0, _nx_devkit.ensurePackage)("@nx/oxlint", _nx_devkit.NX_VERSION);
|
|
11
|
+
} else if (options.linter !== "none") (0, _nx_devkit.ensurePackage)("@nx/eslint", _nx_devkit.NX_VERSION);
|
|
9
12
|
(0, _nx_devkit.ensurePackage)("@angular-devkit/core", "latest");
|
|
10
13
|
(0, _nx_devkit.ensurePackage)("rxjs", "latest");
|
|
11
14
|
const generatorModule = await Promise.resolve().then(() => require("../app/generator.js"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/preset/generator.ts"],"sourcesContent":["import {\n ensurePackage,\n generateFiles,\n NX_VERSION,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport { join } from 'node:path';\nimport { PresetGeneratorSchema } from './schema';\n\nexport default async function (\n tree: Tree,\n options: PresetGeneratorSchema,\n): Promise<() => void> {\n ensurePackage('@nx/angular', NX_VERSION);\n ensurePackage('@nx/vite', NX_VERSION);\n if (options.linter === 'oxlint') {\n ensurePackage('@nx/oxlint', NX_VERSION);\n } else if (options.linter !== 'none') {\n ensurePackage('@nx/eslint', NX_VERSION);\n }\n ensurePackage('@angular-devkit/core', 'latest');\n ensurePackage('rxjs', 'latest');\n\n const generatorModule = await import('../app/generator');\n const appGenerator =\n 'default' in generatorModule ? generatorModule.default : generatorModule;\n\n const installTask = await appGenerator(tree, {\n ...options,\n skipAgentContext: true,\n });\n\n // Seed agent context at the workspace root so AI coding assistants pick up\n // Analog conventions (see node_modules/@analogjs/platform/AGENTS.md).\n generateFiles(\n tree,\n join(__dirname, '..', 'app', 'files', 'agents'),\n '.',\n options,\n );\n\n if (tree.exists('/tsconfig.base.json')) {\n updateJson<{\n compilerOptions?: {\n baseUrl?: string;\n };\n }>(tree, '/tsconfig.base.json', (json) => {\n delete json.compilerOptions?.baseUrl;\n return json;\n });\n }\n\n return installTask;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.js","names":[],"sources":["../../../../../../../../nx-plugin/src/generators/preset/generator.ts"],"sourcesContent":["import {\n ensurePackage,\n generateFiles,\n NX_VERSION,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport { join } from 'node:path';\nimport {\n belowMinimumSupportedOxlintNxVersion,\n MINIMUM_SUPPORTED_OXLINT_NX_VERSION,\n} from '../app/versions/minimum-supported-versions';\nimport { PresetGeneratorSchema } from './schema';\n\nexport default async function (\n tree: Tree,\n options: PresetGeneratorSchema,\n): Promise<() => void> {\n ensurePackage('@nx/angular', NX_VERSION);\n ensurePackage('@nx/vite', NX_VERSION);\n if (options.linter === 'oxlint') {\n if (belowMinimumSupportedOxlintNxVersion(NX_VERSION)) {\n throw new Error(\n `Nx v${MINIMUM_SUPPORTED_OXLINT_NX_VERSION} or newer is required to use the oxlint linter`,\n );\n }\n ensurePackage('@nx/oxlint', NX_VERSION);\n } else if (options.linter !== 'none') {\n ensurePackage('@nx/eslint', NX_VERSION);\n }\n ensurePackage('@angular-devkit/core', 'latest');\n ensurePackage('rxjs', 'latest');\n\n const generatorModule = await import('../app/generator');\n const appGenerator =\n 'default' in generatorModule ? generatorModule.default : generatorModule;\n\n const installTask = await appGenerator(tree, {\n ...options,\n skipAgentContext: true,\n });\n\n // Seed agent context at the workspace root so AI coding assistants pick up\n // Analog conventions (see node_modules/@analogjs/platform/AGENTS.md).\n generateFiles(\n tree,\n join(__dirname, '..', 'app', 'files', 'agents'),\n '.',\n options,\n );\n\n if (tree.exists('/tsconfig.base.json')) {\n updateJson<{\n compilerOptions?: {\n baseUrl?: string;\n };\n }>(tree, '/tsconfig.base.json', (json) => {\n delete json.compilerOptions?.baseUrl;\n return json;\n });\n }\n\n return installTask;\n}\n"],"mappings":";;;;AAcA,eAAA,kBACE,MACA,SACqB;CACrB,CAAA,GAAA,WAAA,cAAA,CAAc,eAAe,WAAA,UAAU;CACvC,CAAA,GAAA,WAAA,cAAA,CAAc,YAAY,WAAA,UAAU;CACpC,IAAI,QAAQ,WAAW,UAAU;EAC/B,IAAI,mCAAA,qCAAqC,WAAA,UAAU,GACjD,MAAM,IAAI,MACR,OAAO,mCAAA,oCAAoC,+CAC7C;EAEF,CAAA,GAAA,WAAA,cAAA,CAAc,cAAc,WAAA,UAAU;CACxC,OAAO,IAAI,QAAQ,WAAW,QAC5B,CAAA,GAAA,WAAA,cAAA,CAAc,cAAc,WAAA,UAAU;CAExC,CAAA,GAAA,WAAA,cAAA,CAAc,wBAAwB,QAAQ;CAC9C,CAAA,GAAA,WAAA,cAAA,CAAc,QAAQ,QAAQ;CAE9B,MAAM,kBAAkB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;CAI9B,MAAM,cAAc,OAFlB,aAAa,kBAAkB,gBAAgB,UAAU,gBAAA,CAEpB,MAAM;EAC3C,GAAG;EACH,kBAAkB;CACpB,CAAC;CAID,CAAA,GAAA,WAAA,cAAA,CACE,OAAA,GACA,UAAA,KAAA,CAAK,WAAW,MAAM,OAAO,SAAS,QAAQ,GAC9C,KACA,OACF;CAEA,IAAI,KAAK,OAAO,qBAAqB,GACnC,CAAA,GAAA,WAAA,WAAA,CAIG,MAAM,wBAAwB,SAAS;EACxC,OAAO,KAAK,iBAAiB;EAC7B,OAAO;CACT,CAAC;CAGH,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const devDependencyKeys: readonly ["@analogjs/platform", "@analogjs/vite-plugin-angular", "@analogjs/vitest-angular", "
|
|
1
|
+
declare const devDependencyKeys: readonly ["@analogjs/platform", "@analogjs/vite-plugin-angular", "@analogjs/vitest-angular", "jsdom", "vite-tsconfig-paths", "vitest", "vite", "@vitest/coverage-v8", "@vitest/ui"];
|
|
2
2
|
export type AnalogDevDependency = (typeof devDependencyKeys)[number];
|
|
3
|
-
export declare const getAnalogDevDependencies: (ngVersion: string) => Record<AnalogDevDependency, string>;
|
|
3
|
+
export declare const getAnalogDevDependencies: (ngVersion: string, nxVersion?: string) => Record<AnalogDevDependency, string>;
|
|
4
4
|
export {};
|
|
@@ -2,22 +2,26 @@ const require_versions = require("./versions.js");
|
|
|
2
2
|
let _nx_devkit = require("@nx/devkit");
|
|
3
3
|
let semver = require("semver");
|
|
4
4
|
//#region packages/nx-plugin/src/utils/versions/dev-dependencies.ts
|
|
5
|
-
var getAnalogDevDependencies = (ngVersion) => {
|
|
5
|
+
var getAnalogDevDependencies = (ngVersion, nxVersion) => {
|
|
6
6
|
const escapedNgVersion = ngVersion.replace(/[~^]/, "");
|
|
7
7
|
if ((0, semver.lt)(escapedNgVersion, "20.0.0")) throw new Error(_nx_devkit.stripIndents`Angular v20.0.0 or newer is required.`);
|
|
8
8
|
return {
|
|
9
9
|
"@analogjs/platform": require_versions.ANALOG_JS_PLATFORM,
|
|
10
10
|
"@analogjs/vite-plugin-angular": require_versions.ANALOG_JS_VITE_PLUGIN_ANGULAR,
|
|
11
11
|
"@analogjs/vitest-angular": require_versions.ANALOG_JS_VITEST_ANGULAR,
|
|
12
|
-
"@nx/vite": require_versions.NX,
|
|
13
12
|
jsdom: require_versions.JSDOM,
|
|
14
13
|
"vite-tsconfig-paths": require_versions.VITE_TSCONFIG_PATHS,
|
|
15
|
-
vite:
|
|
14
|
+
vite: getViteVersion(nxVersion),
|
|
16
15
|
vitest: require_versions.VITEST,
|
|
17
16
|
"@vitest/coverage-v8": require_versions.VITEST,
|
|
18
17
|
"@vitest/ui": require_versions.VITEST
|
|
19
18
|
};
|
|
20
19
|
};
|
|
20
|
+
var getViteVersion = (nxVersion) => {
|
|
21
|
+
if (nxVersion && (0, semver.lt)(nxVersion, "21.5.1")) return require_versions.VITE_6;
|
|
22
|
+
if (nxVersion && (0, semver.lt)(nxVersion, "22.6.2")) return require_versions.VITE_7;
|
|
23
|
+
return require_versions.VITE;
|
|
24
|
+
};
|
|
21
25
|
//#endregion
|
|
22
26
|
exports.getAnalogDevDependencies = getAnalogDevDependencies;
|
|
23
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-dependencies.js","names":[],"sources":["../../../../../../../../nx-plugin/src/utils/versions/dev-dependencies.ts"],"sourcesContent":["import { lt } from 'semver';\nimport { stripIndents } from '@nx/devkit';\nimport {\n ANALOG_JS_PLATFORM,\n ANALOG_JS_VITE_PLUGIN_ANGULAR,\n ANALOG_JS_VITEST_ANGULAR,\n JSDOM,\n VITE_TSCONFIG_PATHS,\n VITE,\n
|
|
1
|
+
{"version":3,"file":"dev-dependencies.js","names":[],"sources":["../../../../../../../../nx-plugin/src/utils/versions/dev-dependencies.ts"],"sourcesContent":["import { lt } from 'semver';\nimport { stripIndents } from '@nx/devkit';\nimport {\n ANALOG_JS_PLATFORM,\n ANALOG_JS_VITE_PLUGIN_ANGULAR,\n ANALOG_JS_VITEST_ANGULAR,\n JSDOM,\n VITE_TSCONFIG_PATHS,\n VITE,\n VITE_6,\n VITE_7,\n VITEST,\n} from './versions';\n\nconst devDependencyKeys = [\n '@analogjs/platform',\n '@analogjs/vite-plugin-angular',\n '@analogjs/vitest-angular',\n 'jsdom',\n 'vite-tsconfig-paths',\n 'vitest',\n 'vite',\n '@vitest/coverage-v8',\n '@vitest/ui',\n] as const;\nexport type AnalogDevDependency = (typeof devDependencyKeys)[number];\n\nexport const getAnalogDevDependencies = (\n ngVersion: string,\n nxVersion?: string,\n): Record<AnalogDevDependency, string> => {\n const escapedNgVersion = ngVersion.replace(/[~^]/, '');\n\n // fail out for versions <20.0.0\n if (lt(escapedNgVersion, '20.0.0')) {\n throw new Error(stripIndents`Angular v20.0.0 or newer is required.`);\n }\n\n return {\n '@analogjs/platform': ANALOG_JS_PLATFORM,\n '@analogjs/vite-plugin-angular': ANALOG_JS_VITE_PLUGIN_ANGULAR,\n '@analogjs/vitest-angular': ANALOG_JS_VITEST_ANGULAR,\n jsdom: JSDOM,\n 'vite-tsconfig-paths': VITE_TSCONFIG_PATHS,\n vite: getViteVersion(nxVersion),\n vitest: VITEST,\n '@vitest/coverage-v8': VITEST,\n '@vitest/ui': VITEST,\n };\n};\n\n// Match the Vite major accepted by the installed @nx/vite peer range.\nconst getViteVersion = (nxVersion?: string): string => {\n if (nxVersion && lt(nxVersion, '21.5.1')) {\n return VITE_6;\n }\n if (nxVersion && lt(nxVersion, '22.6.2')) {\n return VITE_7;\n }\n return VITE;\n};\n"],"mappings":";;;;AA2BA,IAAa,4BACX,WACA,cACwC;CACxC,MAAM,mBAAmB,UAAU,QAAQ,QAAQ,EAAE;CAGrD,KAAA,GAAI,OAAA,GAAA,CAAG,kBAAkB,QAAQ,GAC/B,MAAM,IAAI,MAAM,WAAA,YAAY,uCAAuC;CAGrE,OAAO;EACL,sBAAsB,iBAAA;EACtB,iCAAiC,iBAAA;EACjC,4BAA4B,iBAAA;EAC5B,OAAO,iBAAA;EACP,uBAAuB,iBAAA;EACvB,MAAM,eAAe,SAAS;EAC9B,QAAQ,iBAAA;EACR,uBAAuB,iBAAA;EACvB,cAAc,iBAAA;CAChB;AACF;AAGA,IAAM,kBAAkB,cAA+B;CACrD,IAAI,cAAA,GAAa,OAAA,GAAA,CAAG,WAAW,QAAQ,GACrC,OAAO,iBAAA;CAET,IAAI,cAAA,GAAa,OAAA,GAAA,CAAG,WAAW,QAAQ,GACrC,OAAO,iBAAA;CAET,OAAO,iBAAA;AACT"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
export declare const ANALOG_JS_ROUTER = "^3.0.0-beta.
|
|
2
|
-
export declare const ANALOG_JS_CONTENT = "^3.0.0-beta.
|
|
1
|
+
export declare const ANALOG_JS_ROUTER = "^3.0.0-beta.31";
|
|
2
|
+
export declare const ANALOG_JS_CONTENT = "^3.0.0-beta.31";
|
|
3
3
|
export declare const MARKED = "^18.0.0";
|
|
4
4
|
export declare const MARKED_GFM_HEADING_ID = "^4.1.1";
|
|
5
5
|
export declare const MARKED_HIGHLIGHT = "^2.2.1";
|
|
6
6
|
export declare const MARKED_MANGLE = "^1.1.10";
|
|
7
7
|
export declare const PRISMJS = "^1.29.0";
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
8
|
+
export declare const H3 = "^1.15.11";
|
|
9
|
+
export declare const ANALOG_JS_PLATFORM = "^3.0.0-beta.31";
|
|
10
|
+
export declare const ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-beta.31";
|
|
11
|
+
export declare const ANALOG_JS_VITEST_ANGULAR = "^3.0.0-beta.31";
|
|
12
|
+
export declare const ANALOG_JS_VITE_PLUGIN_NITRO = "^3.0.0-beta.31";
|
|
11
13
|
export declare const JSDOM = "^22.0.0";
|
|
12
14
|
export declare const VITE_TSCONFIG_PATHS = "^4.2.0";
|
|
13
15
|
export declare const VITE = "^8.0.0";
|
|
16
|
+
export declare const VITE_7 = "^7.0.0";
|
|
17
|
+
export declare const VITE_6 = "^6.4.0";
|
|
14
18
|
export declare const VITEST = "^5.0.0";
|
|
15
|
-
export declare const NX = "^23.2.0";
|
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
//#region packages/nx-plugin/src/utils/versions/versions.ts
|
|
2
|
-
var ANALOG_JS_ROUTER = "^3.0.0-beta.
|
|
3
|
-
var ANALOG_JS_CONTENT = "^3.0.0-beta.
|
|
2
|
+
var ANALOG_JS_ROUTER = "^3.0.0-beta.31";
|
|
3
|
+
var ANALOG_JS_CONTENT = "^3.0.0-beta.31";
|
|
4
4
|
var MARKED = "^18.0.0";
|
|
5
5
|
var MARKED_GFM_HEADING_ID = "^4.1.1";
|
|
6
6
|
var MARKED_HIGHLIGHT = "^2.2.1";
|
|
7
7
|
var MARKED_MANGLE = "^1.1.10";
|
|
8
8
|
var PRISMJS = "^1.29.0";
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
9
|
+
var H3 = "^1.15.11";
|
|
10
|
+
var ANALOG_JS_PLATFORM = "^3.0.0-beta.31";
|
|
11
|
+
var ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-beta.31";
|
|
12
|
+
var ANALOG_JS_VITEST_ANGULAR = "^3.0.0-beta.31";
|
|
13
|
+
var ANALOG_JS_VITE_PLUGIN_NITRO = "^3.0.0-beta.31";
|
|
12
14
|
var JSDOM = "^22.0.0";
|
|
13
15
|
var VITE_TSCONFIG_PATHS = "^4.2.0";
|
|
14
16
|
var VITE = "^8.0.0";
|
|
17
|
+
var VITE_7 = "^7.0.0";
|
|
18
|
+
var VITE_6 = "^6.4.0";
|
|
15
19
|
var VITEST = "^5.0.0";
|
|
16
|
-
var NX = "^23.2.0";
|
|
17
20
|
//#endregion
|
|
18
21
|
exports.ANALOG_JS_CONTENT = ANALOG_JS_CONTENT;
|
|
19
22
|
exports.ANALOG_JS_PLATFORM = ANALOG_JS_PLATFORM;
|
|
20
23
|
exports.ANALOG_JS_ROUTER = ANALOG_JS_ROUTER;
|
|
21
24
|
exports.ANALOG_JS_VITEST_ANGULAR = ANALOG_JS_VITEST_ANGULAR;
|
|
22
25
|
exports.ANALOG_JS_VITE_PLUGIN_ANGULAR = ANALOG_JS_VITE_PLUGIN_ANGULAR;
|
|
26
|
+
exports.ANALOG_JS_VITE_PLUGIN_NITRO = ANALOG_JS_VITE_PLUGIN_NITRO;
|
|
27
|
+
exports.H3 = H3;
|
|
23
28
|
exports.JSDOM = JSDOM;
|
|
24
29
|
exports.MARKED = MARKED;
|
|
25
30
|
exports.MARKED_GFM_HEADING_ID = MARKED_GFM_HEADING_ID;
|
|
26
31
|
exports.MARKED_HIGHLIGHT = MARKED_HIGHLIGHT;
|
|
27
32
|
exports.MARKED_MANGLE = MARKED_MANGLE;
|
|
28
|
-
exports.NX = NX;
|
|
29
33
|
exports.PRISMJS = PRISMJS;
|
|
30
34
|
exports.VITE = VITE;
|
|
31
35
|
exports.VITEST = VITEST;
|
|
36
|
+
exports.VITE_6 = VITE_6;
|
|
37
|
+
exports.VITE_7 = VITE_7;
|
|
32
38
|
exports.VITE_TSCONFIG_PATHS = VITE_TSCONFIG_PATHS;
|
|
33
39
|
|
|
34
40
|
//# sourceMappingURL=versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../nx-plugin/src/utils/versions/versions.ts"],"sourcesContent":["// dependencies\nexport const ANALOG_JS_ROUTER = '^3.0.0-beta.
|
|
1
|
+
{"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../nx-plugin/src/utils/versions/versions.ts"],"sourcesContent":["// dependencies\nexport const ANALOG_JS_ROUTER = '^3.0.0-beta.31';\nexport const ANALOG_JS_CONTENT = '^3.0.0-beta.31';\nexport const MARKED = '^18.0.0';\nexport const MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const MARKED_HIGHLIGHT = '^2.2.1';\nexport const MARKED_MANGLE = '^1.1.10';\nexport const PRISMJS = '^1.29.0';\nexport const H3 = '^1.15.11';\n\n// devDependencies\nexport const ANALOG_JS_PLATFORM = '^3.0.0-beta.31';\nexport const ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-beta.31';\nexport const ANALOG_JS_VITEST_ANGULAR = '^3.0.0-beta.31';\nexport const ANALOG_JS_VITE_PLUGIN_NITRO = '^3.0.0-beta.31';\nexport const JSDOM = '^22.0.0';\nexport const VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const VITE = '^8.0.0';\nexport const VITE_7 = '^7.0.0';\nexport const VITE_6 = '^6.4.0';\nexport const VITEST = '^5.0.0';\n"],"mappings":";AACA,IAAa,mBAAmB;AAChC,IAAa,oBAAoB;AACjC,IAAa,SAAS;AACtB,IAAa,wBAAwB;AACrC,IAAa,mBAAmB;AAChC,IAAa,gBAAgB;AAC7B,IAAa,UAAU;AACvB,IAAa,KAAK;AAGlB,IAAa,qBAAqB;AAClC,IAAa,gCAAgC;AAC7C,IAAa,2BAA2B;AACxC,IAAa,8BAA8B;AAC3C,IAAa,QAAQ;AACrB,IAAa,sBAAsB;AACnC,IAAa,OAAO;AACpB,IAAa,SAAS;AACtB,IAAa,SAAS;AACtB,IAAa,SAAS"}
|
package/src/lib/options.d.ts
CHANGED
|
@@ -63,9 +63,25 @@ export interface I18nOptions {
|
|
|
63
63
|
outFile?: string;
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
+
export interface ServerOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The server entry, relative to the project root: a Fetchable module whose
|
|
69
|
+
* default export has `fetch(request)`, and optionally `close()`, which the
|
|
70
|
+
* dev server calls before reloading the entry. TypeScript in the entry's
|
|
71
|
+
* directory is compiled by Vite.
|
|
72
|
+
*/
|
|
73
|
+
entry: string;
|
|
74
|
+
}
|
|
66
75
|
export interface Options {
|
|
67
76
|
ssr?: boolean;
|
|
68
77
|
/**
|
|
78
|
+
* Serve the app from your own Fetchable server entry (plain, Hono, Express,
|
|
79
|
+
* NestJS, …) instead of Nitro, using `createAnalogRequestHandler()` or
|
|
80
|
+
* `createAnalogHandler()` from `@analogjs/router/server`. Don't add `nitro()`
|
|
81
|
+
* alongside it.
|
|
82
|
+
*/
|
|
83
|
+
server?: ServerOptions;
|
|
84
|
+
/**
|
|
69
85
|
* Prerender the static pages without producing the server output.
|
|
70
86
|
*/
|
|
71
87
|
static?: boolean;
|
|
@@ -10,6 +10,7 @@ import { deferStreamingPlugin, streamingSupportedOnAngular } from "./ssr/defer-s
|
|
|
10
10
|
import { serverModePlugin } from "../server-mode-plugin.js";
|
|
11
11
|
import { typedRoutes } from "./typed-routes-plugin.js";
|
|
12
12
|
import { analogNitroPlugin } from "./nitro/analog-nitro-plugin.js";
|
|
13
|
+
import { serverPlugin } from "./server-plugin.js";
|
|
13
14
|
import { createRequire } from "node:module";
|
|
14
15
|
import { join } from "node:path";
|
|
15
16
|
//#region packages/platform/src/lib/platform-plugin.ts
|
|
@@ -64,6 +65,7 @@ function platformPlugin(opts = {}) {
|
|
|
64
65
|
api: { analogOptions: platformOptions }
|
|
65
66
|
},
|
|
66
67
|
...!isTest ? [analogNitroPlugin(platformOptions)] : [],
|
|
68
|
+
...platformOptions.server && !isTest ? [serverPlugin(platformOptions.server, platformOptions)] : [],
|
|
67
69
|
...platformOptions.ssr ? [...ssrBuildPlugin(), ...injectHTMLPlugin()] : [],
|
|
68
70
|
...platformOptions.ssr && platformOptions.experimental?.streaming ? [deferStreamingPlugin()] : [],
|
|
69
71
|
...!isTest ? depsPlugin(platformOptions) : [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { Plugin } from 'vite';\n\nimport { Options } from './options.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugPlatform,\n} from './utils/debug.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { analogIntegrationPlugin } from './analog-integration-plugin.js';\nimport {\n i18nDefRegistryPlugin,\n ssrBuildPlugin,\n} from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport {\n deferStreamingPlugin,\n MIN_STREAMING_ANGULAR_MAJOR,\n streamingSupportedOnAngular,\n} from './ssr/defer-streaming-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { typedRoutes } from './typed-routes-plugin.js';\nimport { analogNitroPlugin } from './nitro/analog-nitro-plugin.js';\n\n/**\n * The installed `@angular/core` major version, resolved from the workspace root\n * (where the app's Angular is installed). Returns `null` when it cannot be\n * detected, in which case streaming is not blocked and the build-time\n * anchor-drift detection is relied on instead.\n */\nfunction getAngularCoreMajor(workspaceRoot: string): number | null {\n try {\n const req = createRequire(join(workspaceRoot, 'noop.js'));\n const { version } = req('@angular/core/package.json') as {\n version: string;\n };\n const major = Number.parseInt(version.split('.')[0], 10);\n return Number.isNaN(major) ? null : major;\n } catch {\n return null;\n }\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n applyDebugOption(opts.debug, opts.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n\n // Streaming patches the compiled @angular/core, which needs a supported\n // Angular version. Turn it off otherwise so the renderer stays buffered.\n if (platformOptions.ssr && platformOptions.experimental?.streaming) {\n const major = getAngularCoreMajor(\n platformOptions.workspaceRoot ?? process.cwd(),\n );\n if (!streamingSupportedOnAngular(major)) {\n console.warn(\n `[@analogjs/platform] experimental.streaming requires Angular ` +\n `${MIN_STREAMING_ANGULAR_MAJOR}+ (detected v${major}); streaming is ` +\n `disabled and rendering falls back to buffered SSR.`,\n );\n platformOptions.experimental = {\n ...platformOptions.experimental,\n streaming: false,\n };\n }\n }\n\n debugPlatform('experimental options resolved', {\n typedRouting: platformOptions.experimental?.typedRouting,\n });\n\n return [\n ...(platformOptions.experimental?.typedRouting\n ? [\n typedRoutes({\n ...(typeof platformOptions.experimental.typedRouting === 'object'\n ? platformOptions.experimental.typedRouting\n : {}),\n workspaceRoot: platformOptions.workspaceRoot,\n additionalPagesDirs: platformOptions.additionalPagesDirs,\n additionalContentDirs: platformOptions.additionalContentDirs,\n }),\n ]\n : []),\n {\n name: 'analogjs-debug-activate',\n config(_, { command }) {\n activateDeferredDebug(command);\n },\n },\n // `nitro()` from `@analogjs/vite-plugin-nitro` reads these as its defaults.\n {\n name: '@analogjs/platform-options',\n api: { analogOptions: platformOptions },\n },\n ...(!isTest ? [analogNitroPlugin(platformOptions)] : []),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(platformOptions.ssr && platformOptions.experimental?.streaming\n ? [deferStreamingPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n analogIntegrationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(platformOptions.i18n ? [i18nDefRegistryPlugin()] : []),\n ...serverModePlugin(platformOptions.entryServer),\n clearClientPageEndpointsPlugin(),\n ];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { Plugin } from 'vite';\n\nimport { Options } from './options.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugPlatform,\n} from './utils/debug.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { analogIntegrationPlugin } from './analog-integration-plugin.js';\nimport {\n i18nDefRegistryPlugin,\n ssrBuildPlugin,\n} from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport {\n deferStreamingPlugin,\n MIN_STREAMING_ANGULAR_MAJOR,\n streamingSupportedOnAngular,\n} from './ssr/defer-streaming-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { typedRoutes } from './typed-routes-plugin.js';\nimport { analogNitroPlugin } from './nitro/analog-nitro-plugin.js';\nimport { serverPlugin } from './server-plugin.js';\n\n/**\n * The installed `@angular/core` major version, resolved from the workspace root\n * (where the app's Angular is installed). Returns `null` when it cannot be\n * detected, in which case streaming is not blocked and the build-time\n * anchor-drift detection is relied on instead.\n */\nfunction getAngularCoreMajor(workspaceRoot: string): number | null {\n try {\n const req = createRequire(join(workspaceRoot, 'noop.js'));\n const { version } = req('@angular/core/package.json') as {\n version: string;\n };\n const major = Number.parseInt(version.split('.')[0], 10);\n return Number.isNaN(major) ? null : major;\n } catch {\n return null;\n }\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n applyDebugOption(opts.debug, opts.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n\n // Streaming patches the compiled @angular/core, which needs a supported\n // Angular version. Turn it off otherwise so the renderer stays buffered.\n if (platformOptions.ssr && platformOptions.experimental?.streaming) {\n const major = getAngularCoreMajor(\n platformOptions.workspaceRoot ?? process.cwd(),\n );\n if (!streamingSupportedOnAngular(major)) {\n console.warn(\n `[@analogjs/platform] experimental.streaming requires Angular ` +\n `${MIN_STREAMING_ANGULAR_MAJOR}+ (detected v${major}); streaming is ` +\n `disabled and rendering falls back to buffered SSR.`,\n );\n platformOptions.experimental = {\n ...platformOptions.experimental,\n streaming: false,\n };\n }\n }\n\n debugPlatform('experimental options resolved', {\n typedRouting: platformOptions.experimental?.typedRouting,\n });\n\n return [\n ...(platformOptions.experimental?.typedRouting\n ? [\n typedRoutes({\n ...(typeof platformOptions.experimental.typedRouting === 'object'\n ? platformOptions.experimental.typedRouting\n : {}),\n workspaceRoot: platformOptions.workspaceRoot,\n additionalPagesDirs: platformOptions.additionalPagesDirs,\n additionalContentDirs: platformOptions.additionalContentDirs,\n }),\n ]\n : []),\n {\n name: 'analogjs-debug-activate',\n config(_, { command }) {\n activateDeferredDebug(command);\n },\n },\n // `nitro()` from `@analogjs/vite-plugin-nitro` reads these as its defaults.\n {\n name: '@analogjs/platform-options',\n api: { analogOptions: platformOptions },\n },\n ...(!isTest ? [analogNitroPlugin(platformOptions)] : []),\n ...(platformOptions.server && !isTest\n ? [serverPlugin(platformOptions.server, platformOptions)]\n : []),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(platformOptions.ssr && platformOptions.experimental?.streaming\n ? [deferStreamingPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n analogIntegrationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(platformOptions.i18n ? [i18nDefRegistryPlugin()] : []),\n ...serverModePlugin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AAI,CAAC,SAAS,CAAC,kBAAkB,eAAe,CAAC,IAAI,CAAC;EACtD,GAAI,gBAAgB,UAAU,CAAC,SAC3B,CAAC,aAAa,gBAAgB,QAAQ,eAAe,CAAC,IACtD,CAAC;EACL,GAAI,gBAAgB,MAChB,CAAC,GAAG,eAAe,GAAG,GAAG,iBAAiB,CAAC,IAC3C,CAAC;EACL,GAAI,gBAAgB,OAAO,gBAAgB,cAAc,YACrD,CAAC,qBAAqB,CAAC,IACvB,CAAC;EACL,GAAI,CAAC,SAAS,WAAW,eAAe,IAAI,CAAC;EAC7C,GAAG,aAAa,eAAe;EAC/B,wBAAwB,eAAe;EACvC,GAAG,cAAc,iBAAiB,SAAS,eAAe;EAC1D,GAAI,gBAAgB,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC;EACxD,GAAG,iBAAiB,gBAAgB,WAAW;EAC/C,+BAA+B;CACjC;AACF"}
|
|
@@ -4,6 +4,12 @@ import { parseSync } from "oxc-parser";
|
|
|
4
4
|
//#region packages/platform/src/lib/route-idiom-diagnostics.ts
|
|
5
5
|
var PAGE_FILE_RE = /\.page\.ts$/;
|
|
6
6
|
var ROUTER_OUTLET_RE = /\bRouterOutlet\b|<router-outlet(?:\s|>)/;
|
|
7
|
+
var WRAPPER_EXPRESSIONS = /* @__PURE__ */ new Set([
|
|
8
|
+
"ParenthesizedExpression",
|
|
9
|
+
"TSAsExpression",
|
|
10
|
+
"TSSatisfiesExpression",
|
|
11
|
+
"TSTypeAssertion"
|
|
12
|
+
]);
|
|
7
13
|
function analyzeAnalogRouteFile(options) {
|
|
8
14
|
const { filename, code, routeFiles = [] } = options;
|
|
9
15
|
const parseResult = parseSync(filename, code, {
|
|
@@ -31,7 +37,7 @@ function analyzeAnalogRouteFile(options) {
|
|
|
31
37
|
message: "Redirect routes should not also export a page component.",
|
|
32
38
|
details: "Analog ignores the default export when `routeMeta.redirectTo` is present. Remove the component export or remove the redirect."
|
|
33
39
|
});
|
|
34
|
-
if (routeMetaInfo?.
|
|
40
|
+
if (routeMetaInfo?.redirectTarget && !routeMetaInfo.redirectTarget.startsWith("/")) diagnostics.push({
|
|
35
41
|
code: "relative-redirect",
|
|
36
42
|
severity: "warning",
|
|
37
43
|
message: "`routeMeta.redirectTo` should use an absolute path.",
|
|
@@ -73,17 +79,19 @@ function isLikelyLayoutRoute(filename, routeFiles) {
|
|
|
73
79
|
return routeFiles.some((routeFile) => routeFile !== filename && routeFile.startsWith(`${routeStem}/`));
|
|
74
80
|
}
|
|
75
81
|
function getRouteMetaInfo(program, bindingName) {
|
|
76
|
-
const routeMetaNode = getExportedBindingInitializer(program, bindingName);
|
|
82
|
+
const routeMetaNode = unwrapExpression(getExportedBindingInitializer(program, bindingName));
|
|
77
83
|
if (routeMetaNode?.type !== "ObjectExpression") return null;
|
|
78
84
|
let redirectTo;
|
|
79
85
|
for (const property of routeMetaNode.properties ?? []) {
|
|
80
86
|
if (property?.type !== "Property") continue;
|
|
81
87
|
if (getPropertyName(property.key) !== "redirectTo") continue;
|
|
82
|
-
redirectTo =
|
|
88
|
+
redirectTo = property.value;
|
|
83
89
|
}
|
|
90
|
+
const value = unwrapExpression(redirectTo);
|
|
91
|
+
if (!value || isNullish(value)) return { hasRedirect: false };
|
|
84
92
|
return {
|
|
85
|
-
hasRedirect:
|
|
86
|
-
|
|
93
|
+
hasRedirect: true,
|
|
94
|
+
redirectTarget: getStaticRedirectTarget(value)
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
97
|
function getExportedBindingInitializer(program, bindingName) {
|
|
@@ -131,9 +139,16 @@ function getPropertyName(node) {
|
|
|
131
139
|
if (node?.type === "Identifier") return node.name;
|
|
132
140
|
if ((node?.type === "Literal" || node?.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
133
141
|
}
|
|
134
|
-
function
|
|
135
|
-
if ((node
|
|
136
|
-
if (node
|
|
142
|
+
function getStaticRedirectTarget(node) {
|
|
143
|
+
if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
144
|
+
if (node.type === "TemplateLiteral") return (node.quasis?.[0]?.value.cooked ?? node.quasis?.[0]?.value.raw) || void 0;
|
|
145
|
+
}
|
|
146
|
+
function isNullish(node) {
|
|
147
|
+
return node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined" || node.type === "UnaryExpression" && node.operator === "void";
|
|
148
|
+
}
|
|
149
|
+
function unwrapExpression(node) {
|
|
150
|
+
while (node && WRAPPER_EXPRESSIONS.has(node.type)) node = node.expression;
|
|
151
|
+
return node;
|
|
137
152
|
}
|
|
138
153
|
//#endregion
|
|
139
154
|
export { analyzeAnalogRouteFile, formatAnalogRouteIdiomDiagnostic };
|
|
@@ -1 +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 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 (\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 routeMetaNode = getExportedBindingInitializer(program, bindingName);\n\n if (routeMetaNode?.type !== 'ObjectExpression') {\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 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} {\n let hasDefaultExport = false;\n let routeMeta: 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 }\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 }\n\n return {\n hasDefaultExport,\n routeMeta,\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,CAAC,MAAM;CAC5C,MAAM,cAAc,UAAU,UAAU,MAAM;EAC5C,MAAM;EACN,YAAY;EACZ,OAAO;EACP,oBAAoB;CACtB,CAAC;CAED,MAAM,mBAAmB,YAAY,OAAO,KAAK,UAC/C,kBAAkB,KAAK,CACzB;CAEA,IAAI,iBAAiB,MAAM,eAAe,WAAW,aAAa,OAAO,GACvE,OAAO;CAIT,MAAM,UAAe,YAAY;CACjC,MAAM,mBAAmB,wBAAwB,OAAO;CACxD,MAAM,uBAAuB,iBAAiB;CAC9C,MAAM,cAAc,CAAC,GAAG,gBAAgB;CAExC,MAAM,gBAAgB,uBAClB,iBAAiB,SAAS,oBAAoB,IAC9C;CAEJ,IAAI,CAAC,iBAAiB,oBAAoB,CAAC,eAAe,aACxD,YAAY,KAAK;EACf,MAAM;EACN,UAAU;EACV,SACE;EACF,SACE;CACJ,CAAC;CAGH,IAAI,iBAAiB,oBAAoB,eAAe,aACtD,YAAY,KAAK;EACf,MAAM;EACN,UAAU;EACV,SAAS;EACT,SACE;CACJ,CAAC;CAGH,IACE,eAAe,eACf,cAAc,cACd,CAAC,cAAc,WAAW,WAAW,GAAG,GAExC,YAAY,KAAK;EACf,MAAM;EACN,UAAU;EACV,SAAS;EACT,SACE;CACJ,CAAC;CAGH,IACE,oBAAoB,UAAU,UAAU,KACx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F;AACF;AAEA,SAAS,gBAEP,MACoB;CACpB,IAAI,MAAM,SAAS,cACjB,OAAO,KAAK;CAGd,KACG,MAAM,SAAS,aAAa,MAAM,SAAS,oBAC5C,OAAO,KAAK,UAAU,UAEtB,OAAO,KAAK;AAIhB;AAEA,SAAS,eAEP,MACoB;CACpB,KACG,MAAM,SAAS,aAAa,MAAM,SAAS,oBAC5C,OAAO,KAAK,UAAU,UAEtB,OAAO,KAAK;CAGd,IACE,MAAM,SAAS,qBACf,KAAK,aAAa,WAAW,KAC7B,KAAK,QAAQ,WAAW,GAExB,OAAO,KAAK,OAAO,EAAE,CAAC,MAAM,UAAU,KAAK,OAAO,EAAE,CAAC,MAAM;AAI/D"}
|
|
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\n// Valid AST node types: grouping parentheses, as, satisfies, angle-bracket type assertion\nconst WRAPPER_EXPRESSIONS = new Set([\n 'ParenthesizedExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSTypeAssertion',\n]);\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 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?.redirectTarget &&\n !routeMetaInfo.redirectTarget.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 (\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 redirectTarget?: string;\n} | null {\n const routeMetaNode = unwrapExpression(\n getExportedBindingInitializer(program, bindingName),\n );\n\n if (routeMetaNode?.type !== 'ObjectExpression') {\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let redirectTo: any;\n\n for (const property of routeMetaNode.properties ?? []) {\n if (property?.type !== 'Property') {\n continue;\n }\n\n const keyName = getPropertyName(property.key);\n\n if (keyName !== 'redirectTo') {\n continue;\n }\n\n redirectTo = property.value;\n }\n\n const value = unwrapExpression(redirectTo);\n\n if (!value || isNullish(value)) {\n return { hasRedirect: false };\n }\n\n return {\n hasRedirect: true,\n redirectTarget: getStaticRedirectTarget(value),\n };\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} {\n let hasDefaultExport = false;\n let routeMeta: 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 }\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 }\n\n return {\n hasDefaultExport,\n routeMeta,\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 getStaticRedirectTarget(\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 (node.type === 'TemplateLiteral') {\n const lead = node.quasis?.[0]?.value.cooked ?? node.quasis?.[0]?.value.raw;\n return lead || undefined;\n }\n\n return undefined;\n}\n\nfunction isNullish(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node: any,\n): boolean {\n return (\n (node.type === 'Literal' && node.value === null) ||\n (node.type === 'Identifier' && node.name === 'undefined') ||\n (node.type === 'UnaryExpression' && node.operator === 'void')\n );\n}\n\nfunction unwrapExpression(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any | undefined {\n while (node && WRAPPER_EXPRESSIONS.has(node.type)) {\n node = node.expression;\n }\n\n return node;\n}\n"],"mappings":";;;;AAiBA,IAAM,eAAe;AACrB,IAAM,mBAAmB;AAGzB,IAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,uBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,MAAM,aAAa,CAAC,MAAM;CAC5C,MAAM,cAAc,UAAU,UAAU,MAAM;EAC5C,MAAM;EACN,YAAY;EACZ,OAAO;EACP,oBAAoB;CACtB,CAAC;CAED,MAAM,mBAAmB,YAAY,OAAO,KAAK,UAC/C,kBAAkB,KAAK,CACzB;CAEA,IAAI,iBAAiB,MAAM,eAAe,WAAW,a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aAAa;AAE1D;AAEA,SAAS,iBAEP,MAEiB;CACjB,OAAO,QAAQ,oBAAoB,IAAI,KAAK,IAAI,GAC9C,OAAO,KAAK;CAGd,OAAO;AACT"}
|
package/src/lib/router-plugin.js
CHANGED
|
@@ -192,7 +192,7 @@ function routerPlugin(options) {
|
|
|
192
192
|
`);
|
|
193
193
|
result = result.replace("ANALOG_CONTENT_ROUTE_FILES = {};", `
|
|
194
194
|
ANALOG_CONTENT_ROUTE_FILES = {${contentRouteFiles.map((module) => {
|
|
195
|
-
return `"${getModuleKey(module)}": () => import('${module}?analog-content-file=true')
|
|
195
|
+
return `"${getModuleKey(module)}": () => import('${module}?analog-content-file=true')`;
|
|
196
196
|
})}};
|
|
197
197
|
`);
|
|
198
198
|
result = result.replace("ANALOG_CONTENT_FILE_COUNT = 0", `ANALOG_CONTENT_FILE_COUNT = ${contentRouteFiles.length}`);
|