@refrakt-md/runes 0.38.0 → 0.40.0
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/dist/attribute-presets.d.ts +3 -2
- package/dist/attribute-presets.d.ts.map +1 -1
- package/dist/attribute-presets.js +2 -1
- package/dist/attribute-presets.js.map +1 -1
- package/dist/collection-helpers.d.ts +21 -2
- package/dist/collection-helpers.d.ts.map +1 -1
- package/dist/collection-helpers.js +72 -15
- package/dist/collection-helpers.js.map +1 -1
- package/dist/composed-rune.d.ts +59 -0
- package/dist/composed-rune.d.ts.map +1 -0
- package/dist/composed-rune.js +129 -0
- package/dist/composed-rune.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +73 -40
- package/dist/config.js.map +1 -1
- package/dist/data-pipeline.d.ts +24 -10
- package/dist/data-pipeline.d.ts.map +1 -1
- package/dist/data-pipeline.js +34 -56
- package/dist/data-pipeline.js.map +1 -1
- package/dist/file-ref-resolve.js +9 -13
- package/dist/file-ref-resolve.js.map +1 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/composition.d.ts +152 -0
- package/dist/lib/composition.d.ts.map +1 -0
- package/dist/lib/composition.js +1120 -0
- package/dist/lib/composition.js.map +1 -0
- package/dist/lib/index.d.ts +63 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +137 -8
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/preprocess.d.ts +64 -0
- package/dist/lib/preprocess.d.ts.map +1 -0
- package/dist/lib/preprocess.js +72 -0
- package/dist/lib/preprocess.js.map +1 -0
- package/dist/lib/registers.d.ts +132 -0
- package/dist/lib/registers.d.ts.map +1 -0
- package/dist/lib/registers.js +329 -0
- package/dist/lib/registers.js.map +1 -0
- package/dist/lib/resolver.d.ts +21 -1
- package/dist/lib/resolver.d.ts.map +1 -1
- package/dist/lib/resolver.js +41 -18
- package/dist/lib/resolver.js.map +1 -1
- package/dist/lib/schema-side-table.d.ts +26 -0
- package/dist/lib/schema-side-table.d.ts.map +1 -0
- package/dist/lib/schema-side-table.js +34 -0
- package/dist/lib/schema-side-table.js.map +1 -0
- package/dist/lib/schema-table.d.ts +59 -9
- package/dist/lib/schema-table.d.ts.map +1 -1
- package/dist/lib/schema-table.js +158 -22
- package/dist/lib/schema-table.js.map +1 -1
- package/dist/lib/slot-markers.d.ts +38 -0
- package/dist/lib/slot-markers.d.ts.map +1 -0
- package/dist/lib/slot-markers.js +105 -0
- package/dist/lib/slot-markers.js.map +1 -0
- package/dist/lib/slots.d.ts +99 -0
- package/dist/lib/slots.d.ts.map +1 -0
- package/dist/lib/slots.js +448 -0
- package/dist/lib/slots.js.map +1 -0
- package/dist/plugins.d.ts +3 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +53 -4
- package/dist/plugins.js.map +1 -1
- package/dist/reference.d.ts +18 -0
- package/dist/reference.d.ts.map +1 -1
- package/dist/reference.js +34 -1
- package/dist/reference.js.map +1 -1
- package/dist/registers-pipeline.d.ts +51 -0
- package/dist/registers-pipeline.d.ts.map +1 -0
- package/dist/registers-pipeline.js +224 -0
- package/dist/registers-pipeline.js.map +1 -0
- package/dist/schema-row.d.ts +5 -0
- package/dist/schema-row.d.ts.map +1 -1
- package/dist/schema-row.js +1 -0
- package/dist/schema-row.js.map +1 -1
- package/dist/tags/data.d.ts +2 -2
- package/dist/tags/data.d.ts.map +1 -1
- package/dist/tags/data.js +6 -4
- package/dist/tags/data.js.map +1 -1
- package/dist/tags/figure.d.ts +10 -4
- package/dist/tags/figure.d.ts.map +1 -1
- package/dist/tags/figure.js +65 -20
- package/dist/tags/figure.js.map +1 -1
- package/dist/tags/include.d.ts +51 -7
- package/dist/tags/include.d.ts.map +1 -1
- package/dist/tags/include.js +216 -7
- package/dist/tags/include.js.map +1 -1
- package/dist/tags/sandbox.d.ts.map +1 -1
- package/dist/tags/sandbox.js +13 -3
- package/dist/tags/sandbox.js.map +1 -1
- package/dist/tags/snippet.d.ts +9 -10
- package/dist/tags/snippet.d.ts.map +1 -1
- package/dist/tags/snippet.js +213 -10
- package/dist/tags/snippet.js.map +1 -1
- package/dist/universal-attributes.d.ts +1 -1
- package/package.json +3 -3
- package/dist/include-pipeline.d.ts +0 -52
- package/dist/include-pipeline.d.ts.map +0 -1
- package/dist/include-pipeline.js +0 -206
- package/dist/include-pipeline.js.map +0 -1
- package/dist/snippet-pipeline.d.ts +0 -44
- package/dist/snippet-pipeline.d.ts.map +0 -1
- package/dist/snippet-pipeline.js +0 -307
- package/dist/snippet-pipeline.js.map +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Config, Node, RenderableTreeNodes, Schema, SchemaAttribute } from '@markdoc/markdoc';
|
|
2
|
+
import type { ContentModel, ResolvedContent } from '@refrakt-md/types';
|
|
3
|
+
import type { RuneConfig } from '@refrakt-md/transform';
|
|
4
|
+
import type { SchemaTable } from './schema-table.js';
|
|
5
|
+
import { SchemaSideTable } from './schema-side-table.js';
|
|
6
|
+
import type { RegistersDeclaration } from './registers.js';
|
|
7
|
+
/**
|
|
8
|
+
* A composition template, as `createContentModelSchema` receives it — the third
|
|
9
|
+
* of D5's three mutually exclusive emit paths, beside `transform` and `emits`.
|
|
10
|
+
*/
|
|
11
|
+
export interface CompositionTemplate {
|
|
12
|
+
/** The composed rune's kebab-case name — its `data-rune`. */
|
|
13
|
+
rune: string;
|
|
14
|
+
/** The root element. */
|
|
15
|
+
tag: string;
|
|
16
|
+
/** Other names the rune answers to. A template placing one of them places itself. */
|
|
17
|
+
aliases?: readonly string[];
|
|
18
|
+
/** The Markdoc template body. */
|
|
19
|
+
body: string;
|
|
20
|
+
/** The `blocks` the rune declares — what `{% metablock %}` may name (D7). */
|
|
21
|
+
blocks?: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** One node of a composition's expansion, as the contract records it (D6). */
|
|
24
|
+
export interface CompositionOutlineNode {
|
|
25
|
+
/** A rune the template places. */
|
|
26
|
+
rune?: string;
|
|
27
|
+
/** A slot, by name; `''` for a bare `{% slot /%}` inside an `each`. */
|
|
28
|
+
slot?: string;
|
|
29
|
+
/** The slot iterates its field. */
|
|
30
|
+
each?: true;
|
|
31
|
+
/** The slot carries fallback content. */
|
|
32
|
+
fallback?: true;
|
|
33
|
+
/** A Markdoc node the template writes itself (`heading`, `paragraph`, …). */
|
|
34
|
+
node?: string;
|
|
35
|
+
/** `if` — a branch the template takes on an attribute. */
|
|
36
|
+
conditional?: true;
|
|
37
|
+
/** A declared meta block placed with `{% metablock %}` (D7). */
|
|
38
|
+
metablock?: string;
|
|
39
|
+
children?: CompositionOutlineNode[];
|
|
40
|
+
}
|
|
41
|
+
/** What construction learned about a composition — recorded per schema. */
|
|
42
|
+
export interface CompositionInfo {
|
|
43
|
+
rune: string;
|
|
44
|
+
/** Slot names in template order — the composed rune's published part names (D10c). */
|
|
45
|
+
slots: string[];
|
|
46
|
+
/** Every rune the template places, each with the nearest placed rune around it. */
|
|
47
|
+
placements: Array<{
|
|
48
|
+
rune: string;
|
|
49
|
+
parent?: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** The template's structure, for `contracts` (D6). */
|
|
52
|
+
outline: CompositionOutlineNode[];
|
|
53
|
+
/** The schema type the composed rune declares, if any. */
|
|
54
|
+
schemaType?: string;
|
|
55
|
+
/** The generated block-less config (D2a), when built from a definition. */
|
|
56
|
+
config?: RuneConfig;
|
|
57
|
+
/** The config key the engine finds it under. */
|
|
58
|
+
typeName?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Compositions by schema — the same pattern as `schemaTables`: tooling has only
|
|
61
|
+
* the schema to read from. */
|
|
62
|
+
export declare const schemaCompositions: SchemaSideTable<CompositionInfo>;
|
|
63
|
+
/** The composition a schema renders, if it is one. */
|
|
64
|
+
export declare function compositionFor(schema: unknown): CompositionInfo | undefined;
|
|
65
|
+
/** Schema types a placed rune may emit under a composed type: a media object
|
|
66
|
+
* that becomes a property of the outer entity, not a peer of it (D9). */
|
|
67
|
+
export declare const SUBORDINATE_SCHEMA_TYPES: ReadonlySet<string>;
|
|
68
|
+
export interface CompiledComposition {
|
|
69
|
+
/** The transform `createContentModelSchema` calls where it would call `transform`. */
|
|
70
|
+
transform: (resolved: ResolvedContent, attrs: Record<string, any>, config: Config, node: Node) => RenderableTreeNodes;
|
|
71
|
+
info: CompositionInfo;
|
|
72
|
+
}
|
|
73
|
+
export interface CompileCompositionOptions {
|
|
74
|
+
contentModel: ContentModel | ((attrs: Record<string, any>) => ContentModel);
|
|
75
|
+
/** The attributes the rune declares — what `$attrs` may name. */
|
|
76
|
+
attributes: readonly string[];
|
|
77
|
+
/** The rune's schema table, for its declared type (D9). */
|
|
78
|
+
schema?: SchemaTable;
|
|
79
|
+
/** The rune's registration, for D10b's copy into the field bag. */
|
|
80
|
+
registers?: RegistersDeclaration;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check a template against the rune's content model and attributes, and build
|
|
84
|
+
* the transform that renders it. Called once, at schema construction. Throws,
|
|
85
|
+
* naming the rune and the offending tag, slot, field or name, rather than
|
|
86
|
+
* building anything it cannot honour.
|
|
87
|
+
*/
|
|
88
|
+
export declare function compileComposition(template: CompositionTemplate, options: CompileCompositionOptions): CompiledComposition;
|
|
89
|
+
/**
|
|
90
|
+
* A composed rune's definition, parsed. The template is still source; it is
|
|
91
|
+
* checked and compiled by `createContentModelSchema`.
|
|
92
|
+
*/
|
|
93
|
+
export interface CompositionDefinition {
|
|
94
|
+
rune: string;
|
|
95
|
+
tag: string;
|
|
96
|
+
aliases?: string[];
|
|
97
|
+
description?: string;
|
|
98
|
+
attributes: Record<string, SchemaAttribute>;
|
|
99
|
+
contentModel: ContentModel;
|
|
100
|
+
schema?: SchemaTable;
|
|
101
|
+
registers?: RegistersDeclaration;
|
|
102
|
+
metaFields?: Record<string, unknown>;
|
|
103
|
+
blocks?: Record<string, unknown>;
|
|
104
|
+
provides?: string[];
|
|
105
|
+
template: string;
|
|
106
|
+
}
|
|
107
|
+
/** kebab-case → PascalCase: the config key the engine finds a rune under. */
|
|
108
|
+
export declare function composedTypeName(rune: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Split and parse a definition. The rune's name is the file's name (SPEC-153
|
|
111
|
+
* D9), passed in; a frontmatter key restating it is rejected rather than
|
|
112
|
+
* silently preferred.
|
|
113
|
+
*/
|
|
114
|
+
export declare function parseCompositionDefinition(rune: string, source: string): CompositionDefinition;
|
|
115
|
+
/**
|
|
116
|
+
* The generated, block-less engine config of a composed rune (D2a). Not
|
|
117
|
+
* hand-written beside the definition: modifiers come from its enum attributes
|
|
118
|
+
* and from every attribute a `metaFields` entry reads, and `metaFields` /
|
|
119
|
+
* `blocks` are carried as declared.
|
|
120
|
+
*
|
|
121
|
+
* The second source is what lets a placed meta block render (D7): the engine
|
|
122
|
+
* resolves a field against the rune's modifier values, exactly as it does for a
|
|
123
|
+
* tree-owning rune — which must declare the same attributes as modifiers for
|
|
124
|
+
* its own blocks to fill.
|
|
125
|
+
*/
|
|
126
|
+
export declare function composedRuneConfig(def: CompositionDefinition): RuneConfig;
|
|
127
|
+
/** One rune as the catalog-wide checks see it. */
|
|
128
|
+
export interface CompositionCatalogEntry {
|
|
129
|
+
schema?: Schema;
|
|
130
|
+
/** The rune's `data-rune`, when it differs from its tag name (`tabs` renders
|
|
131
|
+
* as `tab-group`). What `requiresParent` names. */
|
|
132
|
+
dataRune?: string;
|
|
133
|
+
seoType?: string;
|
|
134
|
+
/** Other names the rune answers to. */
|
|
135
|
+
aliases?: readonly string[];
|
|
136
|
+
/** From the rune's engine config (SPEC-084). */
|
|
137
|
+
requiresParent?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The checks that need every rune in hand: a composition cycle (A places B
|
|
141
|
+
* places A), a composed type placed over a peer type (D9), and a placed rune
|
|
142
|
+
* that requires a parent the template does not give it (D12). Run once the
|
|
143
|
+
* catalog is assembled — by `mergePlugins`, before any page renders — and
|
|
144
|
+
* throws on the first problem, naming the runes involved.
|
|
145
|
+
*
|
|
146
|
+
* D9 is relational: a composition that declares no type of its own may place
|
|
147
|
+
* an entity rune, because then exactly one type exists in the subtree. The
|
|
148
|
+
* check fires only when the composed rune declares a type and a placed rune
|
|
149
|
+
* declares a non-subordinate one.
|
|
150
|
+
*/
|
|
151
|
+
export declare function checkCompositions(catalog: Record<string, CompositionCatalogEntry>, tableOf: (schema: Schema) => SchemaTable | undefined): void;
|
|
152
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/lib/composition.ts"],"names":[],"mappings":"AA4DA,OAAO,KAAK,EACX,MAAM,EACN,IAAI,EAEJ,mBAAmB,EACnB,MAAM,EACN,eAAe,EAEf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAEX,YAAY,EAEZ,eAAe,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAQ3D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,qFAAqF;IACrF,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,sBAAsB;IACtC,kCAAkC;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