@loozo/angular-router 0.0.2 → 0.0.4
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/README.md +565 -80
- package/builders.json +2 -2
- package/fesm2022/loozo-angular-router-_core.mjs +332 -595
- package/fesm2022/loozo-angular-router-_core.mjs.map +1 -1
- package/fesm2022/loozo-angular-router-_generated.mjs +335 -627
- package/fesm2022/loozo-angular-router-_generated.mjs.map +1 -1
- package/fesm2022/loozo-angular-router.mjs +2 -19
- package/node/_core/src/path.d.ts +17 -0
- package/node/src/builders/application.js +19 -7
- package/node/src/builders/options.js +47 -61
- package/node/src/builders/serve.js +66 -16
- package/node/src/generation/anchor.d.ts +13 -0
- package/node/src/generation/anchor.js +92 -0
- package/node/src/generation/compiler.d.ts +6 -0
- package/node/src/generation/compiler.js +68 -0
- package/node/src/generation/emit.d.ts +3 -0
- package/node/src/generation/emit.js +26 -8
- package/node/src/generation/files.d.ts +26 -0
- package/node/src/generation/files.js +14 -3
- package/node/src/generation/filesystem.d.ts +7 -0
- package/node/src/generation/filesystem.js +261 -69
- package/node/src/generation/generate.d.ts +16 -0
- package/node/src/generation/generate.js +10 -4
- package/node/src/generation/index.d.ts +16 -0
- package/node/src/generation/index.js +15 -0
- package/node/src/generation/overlay.d.ts +3 -0
- package/node/src/generation/selectors.d.ts +2 -0
- package/node/src/generation/sources.d.ts +50 -0
- package/node/src/generation/sources.js +57 -12
- package/node/src/generation/validate.d.ts +12 -0
- package/node/src/generation/validate.js +53 -57
- package/package.json +7 -2
- package/schemas/application.json +764 -20
- package/schemas/serve.json +144 -30
- package/snippets/angular.json +29 -0
- package/snippets/generated/destinations.generated.ts +126 -0
- package/snippets/generated/routes.generated.ts +35 -0
- package/snippets/src/catalog.ts +20 -0
- package/snippets/src/docs-url.ts +8 -0
- package/snippets/src/index.html +11 -0
- package/snippets/src/main.ts +6 -0
- package/snippets/src/product-url.ts +8 -0
- package/snippets/src/routes/products/$productId/page.ts +20 -0
- package/snippets/src/routes/products/$productId/route.generated.ts +24 -0
- package/snippets/src/routes/products/$productId/route.ts +7 -0
- package/snippets/src/routes/reports/$reportId/page.ts +9 -0
- package/snippets/src/routes/reports/$reportId/route.generated.ts +24 -0
- package/snippets/src/routes/reports/$reportId/route.ts +6 -0
- package/snippets/src/routes/teams/$teamId/items/$id/inputs.ts +15 -0
- package/snippets/src/routes/teams/$teamId/items/$id/links.ts +13 -0
- package/snippets/src/routes/teams/$teamId/items/$id/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.ts +18 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.ts +7 -0
- package/snippets/src/routes/teams/$teamId/old-items/$id/route.ts +13 -0
- package/snippets/src/routes/teams/$teamId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/route.ts +6 -0
- package/snippets/src/shell.ts +9 -0
- package/snippets/src/slug.ts +14 -0
- package/snippets/tsconfig.app.json +14 -0
- package/snippets/tsconfig.routes.json +5 -0
- package/types/loozo-angular-router-_core.d.ts +262 -242
- package/types/loozo-angular-router-_generated.d.ts +155 -116
- package/types/loozo-angular-router.d.ts +2 -1
- package/.npmignore +0 -3
- package/fesm2022/loozo-angular-router.mjs.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { inject } from "@angular/core";
|
|
2
|
+
import { defineRoute, numberParam } from "@loozo/angular-router";
|
|
3
|
+
import team from "../../route.js";
|
|
4
|
+
import { ItemCatalog } from "../../../../../catalog.js";
|
|
5
|
+
|
|
6
|
+
export default defineRoute("items/$id", {
|
|
7
|
+
parent: team,
|
|
8
|
+
params: { id: numberParam },
|
|
9
|
+
runGuardsAndResolvers: "paramsOrQueryParamsChange",
|
|
10
|
+
title: ({ params }) => `Item ${params.id}`,
|
|
11
|
+
resolve: {
|
|
12
|
+
item: ({ params, search }) => {
|
|
13
|
+
const catalog = inject(ItemCatalog);
|
|
14
|
+
|
|
15
|
+
return catalog({ teamId: params.teamId, id: params.id, score: search.score });
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Component } from "@angular/core";
|
|
2
|
+
import { injectRoute } from "./route.generated.js";
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
template: `<h1>Member {{ route.params().memberId }} of team {{ route.params().teamId }}</h1>`,
|
|
6
|
+
})
|
|
7
|
+
export default class Member {
|
|
8
|
+
readonly route = injectRoute();
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @loozo/angular-router routegen: owned route.generated.ts
|
|
2
|
+
import { createDestination, injectGeneratedRoute } from '@loozo/angular-router/_generated';
|
|
3
|
+
import { getRouteSet, type Destination, type Handle } from "../../../../../../generated/destinations.generated.js";
|
|
4
|
+
export { defineRoute } from '@loozo/angular-router';
|
|
5
|
+
/**
|
|
6
|
+
* Inert reference to this exact declaration for same-set handle link/navigate calls.
|
|
7
|
+
* No injection context is required; copies and foreign-set references are invalid.
|
|
8
|
+
* This is not an authored route and cannot be passed to the root createUrl function.
|
|
9
|
+
*/
|
|
10
|
+
export const destination: Destination<"src/routes/teams/$teamId/members/$memberId/route.ts"> = createDestination(() => getRouteSet(), "src/routes/teams/$teamId/members/$memberId/route.ts");
|
|
11
|
+
/**
|
|
12
|
+
* Injects a typed handle bound to this exact generated activated route record.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Call in an Angular injection context. The handle exposes readonly native
|
|
16
|
+
* params/search/data Signals and destination-typed link/navigate methods.
|
|
17
|
+
* Data includes local resolver results only, not static or inherited data.
|
|
18
|
+
* All navigation values are explicit; current inputs are never reused implicitly.
|
|
19
|
+
*
|
|
20
|
+
* @returns A noncallable handle for this declaration.
|
|
21
|
+
* @throws A synchronous wiring error outside an injection context or when the
|
|
22
|
+
* activated record does not carry this declaration's own generated identity.
|
|
23
|
+
*/
|
|
24
|
+
export function injectRoute(): Handle<"src/routes/teams/$teamId/members/$memberId/route.ts"> { return injectGeneratedRoute(getRouteSet(), "src/routes/teams/$teamId/members/$memberId/route.ts"); }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineRoute, numberParam } from "@loozo/angular-router";
|
|
2
|
+
import team from "../../route.js";
|
|
3
|
+
import item from "../../items/$id/route.js";
|
|
4
|
+
|
|
5
|
+
export default defineRoute("old-items/$id", {
|
|
6
|
+
parent: team,
|
|
7
|
+
params: { id: numberParam },
|
|
8
|
+
redirect: {
|
|
9
|
+
to: item,
|
|
10
|
+
search: { mode: "drop" }, // or "preserve", or { mode: "replace", values }
|
|
11
|
+
fragment: { mode: "drop" }, // or "preserve", or { mode: "replace", value }
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @loozo/angular-router routegen: owned route.generated.ts
|
|
2
|
+
import { createDestination, injectGeneratedRoute } from '@loozo/angular-router/_generated';
|
|
3
|
+
import { getRouteSet, type Destination, type Handle } from "../../../../generated/destinations.generated.js";
|
|
4
|
+
export { defineRoute } from '@loozo/angular-router';
|
|
5
|
+
/**
|
|
6
|
+
* Inert reference to this exact declaration for same-set handle link/navigate calls.
|
|
7
|
+
* No injection context is required; copies and foreign-set references are invalid.
|
|
8
|
+
* This is not an authored route and cannot be passed to the root createUrl function.
|
|
9
|
+
*/
|
|
10
|
+
export const destination: Destination<"src/routes/teams/$teamId/route.ts"> = createDestination(() => getRouteSet(), "src/routes/teams/$teamId/route.ts");
|
|
11
|
+
/**
|
|
12
|
+
* Injects a typed handle bound to this exact generated activated route record.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Call in an Angular injection context. The handle exposes readonly native
|
|
16
|
+
* params/search/data Signals and destination-typed link/navigate methods.
|
|
17
|
+
* Data includes local resolver results only, not static or inherited data.
|
|
18
|
+
* All navigation values are explicit; current inputs are never reused implicitly.
|
|
19
|
+
*
|
|
20
|
+
* @returns A noncallable handle for this declaration.
|
|
21
|
+
* @throws A synchronous wiring error outside an injection context or when the
|
|
22
|
+
* activated record does not carry this declaration's own generated identity.
|
|
23
|
+
*/
|
|
24
|
+
export function injectRoute(): Handle<"src/routes/teams/$teamId/route.ts"> { return injectGeneratedRoute(getRouteSet(), "src/routes/teams/$teamId/route.ts"); }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ParamCodec } from "@loozo/angular-router";
|
|
2
|
+
|
|
3
|
+
export const slug: ParamCodec<string> = {
|
|
4
|
+
parse(raw) {
|
|
5
|
+
if (!/^[a-z0-9-]+$/.test(raw)) {
|
|
6
|
+
throw new Error("invalid slug");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return raw;
|
|
10
|
+
},
|
|
11
|
+
stringify(value) {
|
|
12
|
+
return value;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"lib": ["ES2022", "DOM"],
|
|
9
|
+
"types": []
|
|
10
|
+
},
|
|
11
|
+
"angularCompilerOptions": { "strictTemplates": true },
|
|
12
|
+
"files": ["src/main.ts"],
|
|
13
|
+
"include": ["src/**/*.ts", "generated/**/*.ts"]
|
|
14
|
+
}
|