@analogjs/content 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
Files changed (65) hide show
  1. package/devtools/package.json +4 -0
  2. package/fesm2022/analogjs-content-devtools.mjs +162 -0
  3. package/fesm2022/analogjs-content-devtools.mjs.map +1 -0
  4. package/fesm2022/analogjs-content-md4x.mjs +291 -0
  5. package/fesm2022/analogjs-content-md4x.mjs.map +1 -0
  6. package/fesm2022/analogjs-content-mdc.mjs +170 -0
  7. package/fesm2022/analogjs-content-mdc.mjs.map +1 -0
  8. package/fesm2022/analogjs-content-og.mjs.map +1 -0
  9. package/fesm2022/analogjs-content-prism-highlighter.mjs +5 -4
  10. package/fesm2022/analogjs-content-prism-highlighter.mjs.map +1 -0
  11. package/fesm2022/analogjs-content-resources.mjs +30 -24
  12. package/fesm2022/analogjs-content-resources.mjs.map +1 -0
  13. package/fesm2022/analogjs-content-shiki-highlighter.mjs +1 -1
  14. package/fesm2022/analogjs-content-shiki-highlighter.mjs.map +1 -0
  15. package/fesm2022/analogjs-content.mjs +25 -350
  16. package/fesm2022/analogjs-content.mjs.map +1 -0
  17. package/fesm2022/content-list-loader.mjs +161 -0
  18. package/fesm2022/content-list-loader.mjs.map +1 -0
  19. package/fesm2022/content-renderer.mjs +128 -0
  20. package/fesm2022/content-renderer.mjs.map +1 -0
  21. package/fesm2022/marked-content-highlighter.mjs +40 -0
  22. package/fesm2022/marked-content-highlighter.mjs.map +1 -0
  23. package/fesm2022/parse-raw-content-file.mjs +45 -0
  24. package/fesm2022/parse-raw-content-file.mjs.map +1 -0
  25. package/md4x/package.json +4 -0
  26. package/mdc/package.json +4 -0
  27. package/package.json +71 -36
  28. package/plugin/migrations.json +1 -1
  29. package/plugin/package.json +2 -22
  30. package/plugin/src/index.d.ts +3 -1
  31. package/plugin/src/index.d.ts.map +1 -0
  32. package/plugin/src/index.js +5 -4
  33. package/plugin/src/index.js.map +1 -0
  34. package/plugin/src/migrations/update-markdown-version/compat.d.ts +5 -2
  35. package/plugin/src/migrations/update-markdown-version/compat.d.ts.map +1 -0
  36. package/plugin/src/migrations/update-markdown-version/compat.js +8 -7
  37. package/plugin/src/migrations/update-markdown-version/compat.js.map +1 -0
  38. package/plugin/src/migrations/update-markdown-version/update-markdown-version.d.ts +6 -2
  39. package/plugin/src/migrations/update-markdown-version/update-markdown-version.d.ts.map +1 -0
  40. package/plugin/src/migrations/update-markdown-version/update-markdown-version.js +18 -20
  41. package/plugin/src/migrations/update-markdown-version/update-markdown-version.js.map +1 -0
  42. package/src/lib/devtools/content-devtools-client.ts +215 -0
  43. package/src/lib/devtools/content-devtools.styles.css +194 -0
  44. package/types/devtools/src/index.d.ts +1 -0
  45. package/types/md4x/src/index.d.ts +5 -0
  46. package/types/md4x/src/lib/md4x-content-renderer.service.d.ts +33 -0
  47. package/types/md4x/src/lib/md4x-wasm-content-renderer.service.d.ts +16 -0
  48. package/types/md4x/src/lib/provide-md4x.d.ts +26 -0
  49. package/types/md4x/src/lib/streaming-markdown-renderer.d.ts +21 -0
  50. package/types/mdc/src/index.d.ts +2 -0
  51. package/types/mdc/src/lib/mdc-component-registry.d.ts +25 -0
  52. package/types/mdc/src/lib/mdc-renderer.directive.d.ts +33 -0
  53. package/types/prism-highlighter/src/lib/prism-highlighter.d.ts +1 -1
  54. package/types/resources/src/content-file-resource.d.ts +32 -7
  55. package/types/resources/src/content-files-resource.d.ts +2 -1
  56. package/types/src/index.d.ts +5 -3
  57. package/types/src/lib/devtools/content-devtools-plugin.d.ts +23 -0
  58. package/types/src/lib/devtools/content-devtools-renderer.d.ts +23 -0
  59. package/types/src/lib/devtools/index.d.ts +23 -0
  60. package/types/src/lib/parse-raw-content-file.d.ts +15 -1
  61. package/plugin/README.md +0 -11
  62. package/plugin/src/migrations/update-markdown-renderer-feature/compat.d.ts +0 -3
  63. package/plugin/src/migrations/update-markdown-renderer-feature/compat.js +0 -8
  64. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.d.ts +0 -2
  65. package/plugin/src/migrations/update-markdown-renderer-feature/update-markdown-renderer-feature.js +0 -48
@@ -0,0 +1,33 @@
1
+ import { InputSignal } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ type ComarkNode = string | [string | null, Record<string, unknown>, ...ComarkNode[]];
4
+ /**
5
+ * Directive that renders MDC (Markdown Components) AST nodes as Angular components.
6
+ *
7
+ * Walks the ComarkTree AST from md4x's `parseAST()`, matches component nodes
8
+ * to the registered MDC_COMPONENTS map, and instantiates them via
9
+ * `ViewContainerRef.createComponent()` with MDC attributes bound as inputs.
10
+ *
11
+ * @experimental MDC component support is experimental and may change in future releases.
12
+ *
13
+ * @example
14
+ * ```html
15
+ * <div [mdcAst]="parsedAst"></div>
16
+ * ```
17
+ */
18
+ export declare class MdcRendererDirective {
19
+ readonly ast: InputSignal<{
20
+ nodes: ComarkNode[];
21
+ } | null>;
22
+ private readonly viewContainer;
23
+ private readonly renderer;
24
+ private readonly el;
25
+ private readonly components;
26
+ private renderId;
27
+ constructor();
28
+ private renderNodes;
29
+ private renderNode;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<MdcRendererDirective, never>;
31
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MdcRendererDirective, "[mdcAst]", never, { "ast": { "alias": "mdcAst"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
32
+ }
33
+ export {};
@@ -1,4 +1,4 @@
1
- import { MarkedContentHighlighter } from '@analogjs/content';
1
+ import { MarkedContentHighlighter } from '../../../src/lib/marked-content-highlighter';
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class PrismHighlighter extends MarkedContentHighlighter {
4
4
  augmentCodeBlock(code: string, lang: string): string;
@@ -1,14 +1,39 @@
1
- import { ResourceRef, Signal } from '@angular/core';
2
- import { ContentFile } from '@analogjs/content';
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import { Signal, type ResourceRef } from '@angular/core';
3
+ import type { ContentFile } from '../../src/lib/content-file';
4
+ export interface ContentFileResourceResult<Attributes extends Record<string, any> = Record<string, any>> extends ContentFile<Attributes | Record<string, never>> {
5
+ toc: Array<{
6
+ id: string;
7
+ level: number;
8
+ text: string;
9
+ }>;
10
+ }
3
11
  type ContentFileParams = Signal<string | {
4
12
  customFilename: string;
13
+ }> | Signal<string> | Signal<{
14
+ customFilename: string;
5
15
  }>;
6
16
  /**
7
- * Resource for requesting an individual content file
17
+ * Resource for requesting an individual content file.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Without schema (existing behavior)
22
+ * const post = contentFileResource<BlogAttributes>();
8
23
  *
9
- * @param params
10
- * @param fallback
11
- * @returns
24
+ * // With schema validation
25
+ * import * as v from 'valibot';
26
+ * const BlogSchema = v.object({
27
+ * title: v.string(),
28
+ * date: v.pipe(v.string(), v.isoDate()),
29
+ * });
30
+ * const post = contentFileResource({ schema: BlogSchema });
31
+ * ```
12
32
  */
13
- export declare function contentFileResource<Attributes extends Record<string, any> = Record<string, any>>(params?: ContentFileParams, fallback?: string): ResourceRef<ContentFile<Attributes | Record<string, never>> | undefined>;
33
+ export declare function contentFileResource<Attributes extends Record<string, any> = Record<string, any>>(params?: ContentFileParams, fallback?: string): ResourceRef<ContentFileResourceResult<Attributes> | undefined>;
34
+ export declare function contentFileResource<TSchema extends StandardSchemaV1>(options: {
35
+ params?: ContentFileParams;
36
+ fallback?: string;
37
+ schema: TSchema;
38
+ }): ResourceRef<ContentFileResourceResult<StandardSchemaV1.InferOutput<TSchema> & Record<string, any>> | undefined>;
14
39
  export {};
@@ -1,3 +1,4 @@
1
1
  import { ResourceRef } from '@angular/core';
2
- import { ContentFile, InjectContentFilesFilterFunction } from '@analogjs/content';
2
+ import type { ContentFile } from '../../src/lib/content-file';
3
+ import type { InjectContentFilesFilterFunction } from '../../src/lib/inject-content-files';
3
4
  export declare function contentFilesResource<Attributes extends Record<string, any>>(filterFn?: InjectContentFilesFilterFunction<Attributes> | undefined): ResourceRef<ContentFile<Attributes>[] | undefined>;
@@ -1,13 +1,15 @@
1
1
  export { AnchorNavigationDirective } from './lib/anchor-navigation.directive';
2
2
  export { injectContent } from './lib/content';
3
- export { ContentFile } from './lib/content-file';
3
+ export type { ContentFile } from './lib/content-file';
4
4
  export { ContentRenderer, NoopContentRenderer } from './lib/content-renderer';
5
- export { injectContentFiles, InjectContentFilesFilterFunction, } from './lib/inject-content-files';
5
+ export type { RenderedContent, TableOfContentItem, } from './lib/content-renderer';
6
+ export { injectContentFiles } from './lib/inject-content-files';
7
+ export type { InjectContentFilesFilterFunction } from './lib/inject-content-files';
6
8
  export { MarkdownContentRendererService } from './lib/markdown-content-renderer.service';
7
9
  export { provideContent, withMarkdownRenderer, MERMAID_IMPORT_TOKEN, } from './lib/provide-content';
8
10
  export { default as MarkdownRouteComponent } from './lib/markdown-route.component';
9
11
  export { default as MarkdownComponent } from './lib/markdown.component';
10
- export { parseRawContentFile } from './lib/parse-raw-content-file';
12
+ export { parseRawContentFile, parseRawContentFileAsync, FrontmatterValidationError, } from './lib/parse-raw-content-file';
11
13
  export { MarkedSetupService } from './lib/marked-setup.service';
12
14
  export { MarkedContentHighlighter, withHighlighter, } from './lib/marked-content-highlighter';
13
15
  export { injectContentFilesMap } from './lib/inject-content-files';
@@ -0,0 +1,23 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Vite plugin that injects the Analog Content DevTools panel in dev mode.
4
+ *
5
+ * Shows render time, frontmatter data, TOC, and content stats in a floating
6
+ * panel. Dev-only — completely stripped from production builds.
7
+ *
8
+ * @experimental Content DevTools is experimental and may change in future releases.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // vite.config.ts
13
+ * import { contentDevToolsPlugin } from '@analogjs/content/devtools';
14
+ *
15
+ * export default defineConfig({
16
+ * plugins: [
17
+ * analog({ ... }),
18
+ * contentDevToolsPlugin(),
19
+ * ],
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function contentDevToolsPlugin(): Plugin;
@@ -0,0 +1,23 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ContentRenderer, RenderedContent, TableOfContentItem } from '../content-renderer';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Token for the wrapped renderer that DevTools delegates to.
6
+ * @internal
7
+ */
8
+ export declare const DEVTOOLS_INNER_RENDERER: InjectionToken<ContentRenderer>;
9
+ /**
10
+ * Wraps an existing ContentRenderer to collect timing and metadata for the
11
+ * Content DevTools panel. Dispatches a custom event on the window after
12
+ * each render so the devtools client can update.
13
+ *
14
+ * @experimental Content DevTools is experimental and may change in future releases.
15
+ */
16
+ export declare class DevToolsContentRenderer extends ContentRenderer {
17
+ private readonly inner;
18
+ render(content: string): Promise<RenderedContent>;
19
+ getContentHeadings(content: string): TableOfContentItem[];
20
+ enhance(): void;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<DevToolsContentRenderer, never>;
22
+ static ɵprov: i0.ɵɵInjectableDeclaration<DevToolsContentRenderer>;
23
+ }
@@ -0,0 +1,23 @@
1
+ import { Provider, Type } from '@angular/core';
2
+ import { ContentRenderer } from '../content-renderer';
3
+ export { contentDevToolsPlugin } from './content-devtools-plugin';
4
+ export { DevToolsContentRenderer, DEVTOOLS_INNER_RENDERER, } from './content-devtools-renderer';
5
+ /**
6
+ * Wraps the given ContentRenderer with DevTools instrumentation.
7
+ *
8
+ * The supplied renderer class is provided under DEVTOOLS_INNER_RENDERER and
9
+ * DevToolsContentRenderer becomes the new ContentRenderer, delegating
10
+ * all calls and collecting timing data.
11
+ *
12
+ * @param innerRenderer The renderer class to wrap with devtools instrumentation.
13
+ *
14
+ * @experimental Content DevTools is experimental and may change in future releases.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * provideContent(
19
+ * withContentDevTools(NoopContentRenderer),
20
+ * );
21
+ * ```
22
+ */
23
+ export declare function withContentDevTools(innerRenderer: Type<ContentRenderer>): Provider;
@@ -1,4 +1,18 @@
1
- export declare function parseRawContentFile<Attributes extends Record<string, any>>(rawContentFile: string): {
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ export declare class FrontmatterValidationError extends Error {
3
+ readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
4
+ readonly filename?: string | undefined;
5
+ constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>, filename?: string | undefined);
6
+ }
7
+ export declare function parseRawContentFile<Attributes extends Record<string, any> = Record<string, any>>(rawContentFile: string): {
2
8
  content: string;
3
9
  attributes: Attributes;
4
10
  };
11
+ export declare function parseRawContentFile<TSchema extends StandardSchemaV1>(rawContentFile: string, schema: TSchema, filename?: string): {
12
+ content: string;
13
+ attributes: StandardSchemaV1.InferOutput<TSchema>;
14
+ };
15
+ export declare function parseRawContentFileAsync<TSchema extends StandardSchemaV1>(rawContentFile: string, schema: TSchema, filename?: string): Promise<{
16
+ content: string;
17
+ attributes: StandardSchemaV1.InferOutput<TSchema>;
18
+ }>;
package/plugin/README.md DELETED
@@ -1,11 +0,0 @@
1
- # content-plugin
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build content-plugin` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test content-plugin` to execute the unit tests via [Vitest](https://vitest.dev).
@@ -1,3 +0,0 @@
1
- import { convertNxGenerator } from '@nx/devkit';
2
- declare const _default: ReturnType<typeof convertNxGenerator>;
3
- export default _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const devkit_1 = require("@nx/devkit");
5
- const update_markdown_renderer_feature_1 = tslib_1.__importDefault(require("./update-markdown-renderer-feature"));
6
- const _default = (0, devkit_1.convertNxGenerator)(update_markdown_renderer_feature_1.default);
7
- exports.default = _default;
8
- //# sourceMappingURL=compat.js.map
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function update(host: Tree): Promise<(() => void) | undefined>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- const ts_morph_1 = require("ts-morph");
6
- async function update(host) {
7
- let project;
8
- (0, devkit_1.visitNotIgnoredFiles)(host, '/', (file) => {
9
- if (file.endsWith('.ts')) {
10
- const content = host.read(file, 'utf-8');
11
- if (content &&
12
- content.includes('withMarkdownRenderer') &&
13
- !content.includes('withPrismHighlighter') &&
14
- !content.includes('withShikiHighlighter')) {
15
- if (!project) {
16
- project = new ts_morph_1.Project({
17
- useInMemoryFileSystem: true,
18
- skipAddingFilesFromTsConfig: true,
19
- });
20
- }
21
- const sourceFile = project.createSourceFile(file, content);
22
- const provideContentNode = sourceFile.getFirstDescendant((node) => ts_morph_1.Node.isCallExpression(node) &&
23
- node.getText().includes('provideContent') &&
24
- node.getText().includes('withMarkdownRenderer'));
25
- if (provideContentNode) {
26
- sourceFile.addImportDeclaration({
27
- moduleSpecifier: '@analogjs/content/prism-highlighter',
28
- namedImports: ['withPrismHighlighter'],
29
- });
30
- provideContentNode.addArgument('withPrismHighlighter()');
31
- }
32
- host.write(file, sourceFile.getFullText());
33
- }
34
- }
35
- });
36
- // NOTE: we only add the dependency if the project is an Angular project
37
- // Nx projects can add the dependency from migrations.json
38
- let dependencyAdded = false;
39
- if (host.exists('/angular.json')) {
40
- (0, devkit_1.addDependenciesToPackageJson)(host, { 'marked-mangle': '^1.1.7' }, {});
41
- dependencyAdded = true;
42
- }
43
- await (0, devkit_1.formatFiles)(host);
44
- if (dependencyAdded) {
45
- return () => (0, devkit_1.installPackagesTask)(host);
46
- }
47
- }
48
- //# sourceMappingURL=update-markdown-renderer-feature.js.map