@analogjs/router 3.0.0-beta.8 → 3.0.0-beta.9

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.
@@ -1,12 +1,12 @@
1
1
  import { r as createRoutes, t as ANALOG_EXTRA_ROUTE_FILE_SOURCES } from "./route-files.mjs";
2
2
  import { InjectionToken, inject } from "@angular/core";
3
- import { ContentRenderer, MarkdownRouteComponent, parseRawContentFile } from "@analogjs/content";
3
+ import { ContentRenderer, MarkdownRouteComponent, parseContentFile } from "@analogjs/content";
4
4
  //#region packages/router/content/src/lib/markdown-helpers.ts
5
5
  var isNgZoneEnabled = typeof Zone !== "undefined" && !!Zone.root;
6
6
  function toMarkdownModule(markdownFileFactory) {
7
7
  return async () => {
8
8
  const markdownFile = await (isNgZoneEnabled ? Zone.root.run(markdownFileFactory) : markdownFileFactory());
9
- const { content, attributes } = parseRawContentFile(markdownFile);
9
+ const { content, attributes } = await parseContentFile(markdownFile);
10
10
  const { title, meta, jsonLd } = attributes;
11
11
  return {
12
12
  default: MarkdownRouteComponent,
@@ -1 +1 @@
1
- {"version":3,"file":"analogjs-router-content.mjs","names":[],"sources":["../../content/src/lib/markdown-helpers.ts","../../content/src/lib/routes.ts","../../content/src/lib/with-content-routes.ts","../../content/src/lib/debug/routes.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport {\n ContentRenderer,\n MarkdownRouteComponent,\n parseRawContentFile,\n} from '@analogjs/content';\n\nimport type { RouteExport } from '../../../src/lib/models';\n\ndeclare const Zone: any;\n\ntype RenderResult = string | { content: string };\ntype ContentRendererLike = {\n render: (content: string) => Promise<RenderResult>;\n};\n\nconst isNgZoneEnabled = typeof Zone !== 'undefined' && !!Zone.root;\n\nexport function toMarkdownModule(\n markdownFileFactory: () => Promise<string>,\n): () => Promise<RouteExport> {\n return async () => {\n const markdownFile = await (isNgZoneEnabled\n ? Zone.root.run(markdownFileFactory)\n : markdownFileFactory());\n\n const { content, attributes } = parseRawContentFile(markdownFile);\n const { title, meta, jsonLd } = attributes;\n\n return {\n default: MarkdownRouteComponent,\n routeMeta: {\n data: { _analogContent: content },\n title,\n meta,\n jsonLd,\n resolve: {\n renderedAnalogContent: async () => {\n const contentRenderer = inject<any>(\n ContentRenderer as any,\n ) as ContentRendererLike;\n const rendered = await contentRenderer.render(content);\n return typeof rendered === 'string' ? rendered : rendered.content;\n },\n },\n },\n };\n };\n}\n","import type { Route } from '@angular/router';\n\nimport type { RouteExport } from '../../../src/lib/models';\nimport { createRoutes as createBaseRoutes } from '../../../src/lib/route-builder';\nimport { toMarkdownModule } from './markdown-helpers';\n\n/**\n * This variable reference is replaced with a glob of all content routes.\n */\nexport const ANALOG_CONTENT_ROUTE_FILES = {};\n\nexport type Files = Record<string, () => Promise<RouteExport | string>>;\n\nexport function createContentRoutes(files: Files, debug = false): Route[] {\n return createBaseRoutes(\n files,\n (filename, fileLoader) =>\n filename.endsWith('.md')\n ? toMarkdownModule(fileLoader as () => Promise<string>)\n : (fileLoader as () => Promise<RouteExport>),\n debug,\n );\n}\n","import { type RouterFeatures } from '@angular/router';\n\nimport { ANALOG_CONTENT_ROUTE_FILES } from './routes';\nimport { toMarkdownModule } from './markdown-helpers';\nimport type { RouteExport } from '../../../src/lib/models';\nimport {\n ANALOG_EXTRA_ROUTE_FILE_SOURCES,\n type ExtraRouteFileSource,\n} from '../../../src/lib/route-files';\n\nexport function withContentRoutes(): RouterFeatures {\n return {\n ɵkind: 101 as number,\n ɵproviders: [\n {\n provide: ANALOG_EXTRA_ROUTE_FILE_SOURCES,\n multi: true,\n useValue: {\n files: ANALOG_CONTENT_ROUTE_FILES,\n resolveModule: (\n filename: string,\n fileLoader: () => Promise<unknown>,\n ) =>\n filename.endsWith('.md')\n ? toMarkdownModule(fileLoader as () => Promise<string>)\n : (fileLoader as () => Promise<RouteExport>),\n } satisfies ExtraRouteFileSource,\n },\n ],\n };\n}\n","import { inject, InjectionToken } from '@angular/core';\nimport { Route } from '@angular/router';\n\nimport { ANALOG_CONTENT_ROUTE_FILES, createContentRoutes } from '../routes';\n\nexport const DEBUG_CONTENT_ROUTES: InjectionToken<(Route & DebugRoute)[]> =\n new InjectionToken<(Route & DebugRoute)[]>(\n '@analogjs/router/content debug routes',\n {\n providedIn: 'root',\n factory() {\n const debugRoutes = createContentRoutes(\n ANALOG_CONTENT_ROUTE_FILES as Record<string, () => Promise<string>>,\n true,\n );\n\n return debugRoutes as (Route & DebugRoute)[];\n },\n },\n );\n\nexport type DebugRoute = {\n path: string;\n filename: string;\n isLayout: boolean;\n children?: DebugRoute[];\n};\n\nexport function injectDebugContentRoutes(): (Route & DebugRoute)[] {\n return inject(DEBUG_CONTENT_ROUTES);\n}\n"],"mappings":";;;;AAgBA,IAAM,kBAAkB,OAAO,SAAS,eAAe,CAAC,CAAC,KAAK;AAE9D,SAAgB,iBACd,qBAA0C;CAE1C,OAAO,YAAW;EAChB,MAAM,eAAe,OAAO,kBACxB,KAAK,KAAK,IAAI,mBAAmB,IACjC,oBAAmB;EAEvB,MAAM,EAAE,SAAS,eAAe,oBAAoB,YAAY;EAChE,MAAM,EAAE,OAAO,MAAM,WAAW;EAEhC,OAAO;GACL,SAAS;GACT,WAAW;IACT,MAAM,EAAE,gBAAgB,QAAO;IAC/B;IACA;IACA;IACA,SAAS,EACP,uBAAuB,YAAW;KAIhC,MAAM,WAAW,MAHO,OACtB,eAEqB,CAAe,CAAC,OAAO,OAAO;KACrD,OAAO,OAAO,aAAa,WAAW,WAAW,SAAS;IAC5D,EACD;GACF;EACF;CACH;AACF;;;;;;ACvCA,IAAa,6BAA6B,CAAA;AAI1C,SAAgB,oBAAoB,OAAc,QAAQ,OAAK;CAC7D,OAAO,aACL,QACC,UAAU,eACT,SAAS,SAAS,KAAK,IACnB,iBAAiB,UAAmC,IACnD,YACP,KAAK;AAET;;;ACZA,SAAgB,oBAAiB;CAC/B,OAAO;EACL,OAAO;EACP,YAAY,CACV;GACE,SAAS;GACT,OAAO;GACP,UAAU;IACR,OAAO;IACP,gBACE,UACA,eAEA,SAAS,SAAS,KAAK,IACnB,iBAAiB,UAAmC,IACnD;GACuB;EACjC,CACF;CACF;AACH;;;ACzBA,IAAa,uBACX,IAAI,eACF,yCACA;CACE,YAAY;CACZ,UAAO;EAML,OALoB,oBAClB,4BACA,IAGK;CACT;AACD,CAAA;AAUL,SAAgB,2BAAwB;CACtC,OAAO,OAAO,oBAAoB;AACpC"}
1
+ {"version":3,"file":"analogjs-router-content.mjs","names":[],"sources":["../../content/src/lib/markdown-helpers.ts","../../content/src/lib/routes.ts","../../content/src/lib/with-content-routes.ts","../../content/src/lib/debug/routes.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport {\n type ContentFileLoader,\n ContentRenderer,\n MarkdownRouteComponent,\n parseContentFile,\n} from '@analogjs/content';\n\nimport type { RouteExport } from '../../../src/lib/models';\n\ndeclare const Zone: any;\n\ntype RenderResult = string | { content: string };\ntype ContentRendererLike = {\n render: (content: string) => Promise<RenderResult>;\n};\n\nconst isNgZoneEnabled = typeof Zone !== 'undefined' && !!Zone.root;\n\nexport function toMarkdownModule(\n markdownFileFactory: ContentFileLoader,\n): () => Promise<RouteExport> {\n return async () => {\n const markdownFile = await (isNgZoneEnabled\n ? Zone.root.run(markdownFileFactory)\n : markdownFileFactory());\n\n const { content, attributes } = await parseContentFile(markdownFile);\n const { title, meta, jsonLd } = attributes;\n\n return {\n default: MarkdownRouteComponent,\n routeMeta: {\n data: { _analogContent: content },\n title,\n meta,\n jsonLd,\n resolve: {\n renderedAnalogContent: async () => {\n const contentRenderer = inject<any>(\n ContentRenderer as any,\n ) as ContentRendererLike;\n const rendered = await contentRenderer.render(content);\n return typeof rendered === 'string' ? rendered : rendered.content;\n },\n },\n },\n };\n };\n}\n","import type { Route } from '@angular/router';\nimport type { ContentFileLoader, ContentFileModule } from '@analogjs/content';\n\nimport type { RouteExport } from '../../../src/lib/models';\nimport { createRoutes as createBaseRoutes } from '../../../src/lib/route-builder';\nimport { toMarkdownModule } from './markdown-helpers';\n\n/**\n * This variable reference is replaced with a glob of all content routes.\n */\nexport const ANALOG_CONTENT_ROUTE_FILES = {};\n\nexport type Files = Record<\n string,\n () => Promise<RouteExport | string | ContentFileModule>\n>;\n\nexport function createContentRoutes(files: Files, debug = false): Route[] {\n return createBaseRoutes(\n files,\n (filename, fileLoader) =>\n filename.endsWith('.md')\n ? toMarkdownModule(fileLoader as ContentFileLoader)\n : (fileLoader as () => Promise<RouteExport>),\n debug,\n );\n}\n","import { type RouterFeatures } from '@angular/router';\nimport type { ContentFileLoader } from '@analogjs/content';\n\nimport { ANALOG_CONTENT_ROUTE_FILES } from './routes';\nimport { toMarkdownModule } from './markdown-helpers';\nimport type { RouteExport } from '../../../src/lib/models';\nimport {\n ANALOG_EXTRA_ROUTE_FILE_SOURCES,\n type ExtraRouteFileSource,\n} from '../../../src/lib/route-files';\n\nexport function withContentRoutes(): RouterFeatures {\n return {\n ɵkind: 101 as number,\n ɵproviders: [\n {\n provide: ANALOG_EXTRA_ROUTE_FILE_SOURCES,\n multi: true,\n useValue: {\n files: ANALOG_CONTENT_ROUTE_FILES,\n resolveModule: (\n filename: string,\n fileLoader: () => Promise<unknown>,\n ) =>\n filename.endsWith('.md')\n ? toMarkdownModule(fileLoader as ContentFileLoader)\n : (fileLoader as () => Promise<RouteExport>),\n } satisfies ExtraRouteFileSource,\n },\n ],\n };\n}\n","import { inject, InjectionToken } from '@angular/core';\nimport { Route } from '@angular/router';\nimport type { ContentFileLoader } from '@analogjs/content';\n\nimport { ANALOG_CONTENT_ROUTE_FILES, createContentRoutes } from '../routes';\n\nexport const DEBUG_CONTENT_ROUTES: InjectionToken<(Route & DebugRoute)[]> =\n new InjectionToken<(Route & DebugRoute)[]>(\n '@analogjs/router/content debug routes',\n {\n providedIn: 'root',\n factory() {\n const debugRoutes = createContentRoutes(\n ANALOG_CONTENT_ROUTE_FILES as Record<string, ContentFileLoader>,\n true,\n );\n\n return debugRoutes as (Route & DebugRoute)[];\n },\n },\n );\n\nexport type DebugRoute = {\n path: string;\n filename: string;\n isLayout: boolean;\n children?: DebugRoute[];\n};\n\nexport function injectDebugContentRoutes(): (Route & DebugRoute)[] {\n return inject(DEBUG_CONTENT_ROUTES);\n}\n"],"mappings":";;;;AAiBA,IAAM,kBAAkB,OAAO,SAAS,eAAe,CAAC,CAAC,KAAK;AAE9D,SAAgB,iBACd,qBAAsC;CAEtC,OAAO,YAAW;EAChB,MAAM,eAAe,OAAO,kBACxB,KAAK,KAAK,IAAI,mBAAmB,IACjC,oBAAmB;EAEvB,MAAM,EAAE,SAAS,eAAe,MAAM,iBAAiB,YAAY;EACnE,MAAM,EAAE,OAAO,MAAM,WAAW;EAEhC,OAAO;GACL,SAAS;GACT,WAAW;IACT,MAAM,EAAE,gBAAgB,QAAO;IAC/B;IACA;IACA;IACA,SAAS,EACP,uBAAuB,YAAW;KAIhC,MAAM,WAAW,MAHO,OACtB,eAEqB,CAAe,CAAC,OAAO,OAAO;KACrD,OAAO,OAAO,aAAa,WAAW,WAAW,SAAS;IAC5D,EACD;GACF;EACF;CACH;AACF;;;;;;ACvCA,IAAa,6BAA6B,CAAA;AAO1C,SAAgB,oBAAoB,OAAc,QAAQ,OAAK;CAC7D,OAAO,aACL,QACC,UAAU,eACT,SAAS,SAAS,KAAK,IACnB,iBAAiB,UAA+B,IAC/C,YACP,KAAK;AAET;;;ACfA,SAAgB,oBAAiB;CAC/B,OAAO;EACL,OAAO;EACP,YAAY,CACV;GACE,SAAS;GACT,OAAO;GACP,UAAU;IACR,OAAO;IACP,gBACE,UACA,eAEA,SAAS,SAAS,KAAK,IACnB,iBAAiB,UAA+B,IAC/C;GACuB;EACjC,CACF;CACF;AACH;;;ACzBA,IAAa,uBACX,IAAI,eACF,yCACA;CACE,YAAY;CACZ,UAAO;EAML,OALoB,oBAClB,4BACA,IAGK;CACT;AACD,CAAA;AAUL,SAAgB,2BAAwB;CACtC,OAAO,OAAO,oBAAoB;AACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/router",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-beta.9",
4
4
  "description": "Filesystem-based routing for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -69,7 +69,7 @@
69
69
  "url": "https://github.com/sponsors/brandonroberts"
70
70
  },
71
71
  "peerDependencies": {
72
- "@analogjs/content": "3.0.0-beta.8",
72
+ "@analogjs/content": "3.0.0-beta.9",
73
73
  "@angular/core": "^20.0.0 || ^21.0.0 || ^22.0.0",
74
74
  "@angular/platform-server": "^20.0.0 || ^21.0.0 || ^22.0.0",
75
75
  "@angular/router": "^20.0.0 || ^21.0.0 || ^22.0.0",
@@ -105,8 +105,8 @@
105
105
  "tslib": "^2.3.0"
106
106
  },
107
107
  "devDependencies": {
108
- "@analogjs/vite-plugin-angular": "3.0.0-beta.8",
109
- "@analogjs/vitest-angular": "3.0.0-beta.8"
108
+ "@analogjs/vite-plugin-angular": "3.0.0-beta.9",
109
+ "@analogjs/vitest-angular": "3.0.0-beta.9"
110
110
  },
111
111
  "ng-update": {
112
112
  "packageGroup": [
@@ -1,2 +1,3 @@
1
+ import { type ContentFileLoader } from '@analogjs/content';
1
2
  import type { RouteExport } from '../../../src/lib/models';
2
- export declare function toMarkdownModule(markdownFileFactory: () => Promise<string>): () => Promise<RouteExport>;
3
+ export declare function toMarkdownModule(markdownFileFactory: ContentFileLoader): () => Promise<RouteExport>;
@@ -1,8 +1,9 @@
1
1
  import type { Route } from '@angular/router';
2
+ import type { ContentFileModule } from '@analogjs/content';
2
3
  import type { RouteExport } from '../../../src/lib/models';
3
4
  /**
4
5
  * This variable reference is replaced with a glob of all content routes.
5
6
  */
6
7
  export declare const ANALOG_CONTENT_ROUTE_FILES: {};
7
- export type Files = Record<string, () => Promise<RouteExport | string>>;
8
+ export type Files = Record<string, () => Promise<RouteExport | string | ContentFileModule>>;
8
9
  export declare function createContentRoutes(files: Files, debug?: boolean): Route[];