@docs-sdk-dev/reader 0.0.0-stage → 0.4.0-next.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/LICENSE +21 -0
- package/README.md +97 -2
- package/dist/annotation-projection.d.ts +35 -0
- package/dist/annotation-projection.js +78 -0
- package/dist/annotation-projection.js.map +1 -0
- package/dist/artifacts.d.ts +19 -0
- package/dist/artifacts.js +33 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/ask.d.ts +41 -0
- package/dist/ask.js +89 -0
- package/dist/ask.js.map +1 -0
- package/dist/collection-view.d.ts +190 -0
- package/dist/collection-view.js +170 -0
- package/dist/collection-view.js.map +1 -0
- package/dist/composition.d.ts +199 -0
- package/dist/composition.js +473 -0
- package/dist/composition.js.map +1 -0
- package/dist/condition.d.ts +17 -0
- package/dist/condition.js +61 -0
- package/dist/condition.js.map +1 -0
- package/dist/content-schema.d.ts +182 -0
- package/dist/content-schema.js +288 -0
- package/dist/content-schema.js.map +1 -0
- package/dist/context-search.d.ts +168 -0
- package/dist/context-search.js +73 -0
- package/dist/context-search.js.map +1 -0
- package/dist/context-store.d.ts +93 -0
- package/dist/context-store.js +438 -0
- package/dist/context-store.js.map +1 -0
- package/dist/dimension-runtime.d.ts +203 -0
- package/dist/dimension-runtime.js +737 -0
- package/dist/dimension-runtime.js.map +1 -0
- package/dist/dimensions.d.ts +84 -0
- package/dist/dimensions.js +136 -0
- package/dist/dimensions.js.map +1 -0
- package/dist/directory-navigation.d.ts +60 -0
- package/dist/directory-navigation.js +41 -0
- package/dist/directory-navigation.js.map +1 -0
- package/dist/directory-sections.d.ts +9 -0
- package/dist/directory-sections.js +76 -0
- package/dist/directory-sections.js.map +1 -0
- package/dist/document-reader.d.ts +1017 -0
- package/dist/document-reader.js +396 -0
- package/dist/document-reader.js.map +1 -0
- package/dist/document-selection.d.ts +412 -0
- package/dist/document-selection.js +45 -0
- package/dist/document-selection.js.map +1 -0
- package/dist/evidence.d.ts +102 -0
- package/dist/evidence.js +104 -0
- package/dist/evidence.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +23 -0
- package/dist/model.d.ts +89 -0
- package/dist/model.js +31 -0
- package/dist/model.js.map +1 -0
- package/dist/module.d.ts +657 -0
- package/dist/module.js +199 -0
- package/dist/module.js.map +1 -0
- package/dist/navigation-view.d.ts +33 -0
- package/dist/navigation-view.js +68 -0
- package/dist/navigation-view.js.map +1 -0
- package/dist/node.d.ts +2004 -0
- package/dist/node.js +210 -0
- package/dist/node.js.map +1 -0
- package/dist/open-docs.d.ts +1396 -0
- package/dist/open-docs.js +198 -0
- package/dist/open-docs.js.map +1 -0
- package/dist/outline.d.ts +97 -0
- package/dist/outline.js +171 -0
- package/dist/outline.js.map +1 -0
- package/dist/persistence.d.ts +82 -0
- package/dist/persistence.js +377 -0
- package/dist/persistence.js.map +1 -0
- package/dist/projection-catalog.d.ts +23 -0
- package/dist/projection-catalog.js +45 -0
- package/dist/projection-catalog.js.map +1 -0
- package/dist/publication.d.ts +59 -0
- package/dist/publication.js +11 -0
- package/dist/publication.js.map +1 -0
- package/dist/reader.d.ts +236 -0
- package/dist/reader.js +400 -0
- package/dist/reader.js.map +1 -0
- package/dist/references.d.ts +54 -0
- package/dist/references.js +70 -0
- package/dist/references.js.map +1 -0
- package/dist/retrieval.d.ts +82 -0
- package/dist/retrieval.js +135 -0
- package/dist/retrieval.js.map +1 -0
- package/dist/search-view.d.ts +11 -0
- package/dist/search-view.js +30 -0
- package/dist/search-view.js.map +1 -0
- package/dist/search.d.ts +95 -0
- package/dist/search.js +234 -0
- package/dist/search.js.map +1 -0
- package/dist/semantic.d.ts +177 -0
- package/dist/semantic.js +104 -0
- package/dist/semantic.js.map +1 -0
- package/dist/skills.d.ts +21 -0
- package/dist/skills.js +42 -0
- package/dist/skills.js.map +1 -0
- package/docs/index.md +10 -0
- package/docs/sdk/composition.md +72 -0
- package/docs/sdk/reader-storage.md +70 -0
- package/docs/sdk/reader.md +99 -0
- package/docs/zh-CN/sdk/composition.md +72 -0
- package/docs/zh-CN/sdk/reader-storage.md +70 -0
- package/docs/zh-CN/sdk/reader.md +99 -0
- package/package.json +69 -4
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { type ProjectionLoss } from "./model.js";
|
|
2
|
+
export interface InlineAnnotation {
|
|
3
|
+
type: "annotation";
|
|
4
|
+
name: string;
|
|
5
|
+
attrs: JsonValue;
|
|
6
|
+
version?: number;
|
|
7
|
+
children: Inline[];
|
|
8
|
+
}
|
|
9
|
+
export type Inline = InlineAnnotation | {
|
|
10
|
+
type: "text" | "code";
|
|
11
|
+
value: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "strong" | "emphasis" | "strikethrough";
|
|
14
|
+
children: Inline[];
|
|
15
|
+
} | {
|
|
16
|
+
type: "hardBreak";
|
|
17
|
+
} | {
|
|
18
|
+
type: "link";
|
|
19
|
+
url: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
children: Inline[];
|
|
22
|
+
} | {
|
|
23
|
+
type: "image";
|
|
24
|
+
url: string;
|
|
25
|
+
alt: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
};
|
|
28
|
+
export type TableAlignment = "left" | "center" | "right" | null;
|
|
29
|
+
export interface ParagraphBlock {
|
|
30
|
+
type: "paragraph";
|
|
31
|
+
children: Inline[];
|
|
32
|
+
}
|
|
33
|
+
export interface ListBlock {
|
|
34
|
+
type: "list";
|
|
35
|
+
ordered: boolean;
|
|
36
|
+
start?: number;
|
|
37
|
+
spread?: boolean;
|
|
38
|
+
items: {
|
|
39
|
+
checked?: boolean;
|
|
40
|
+
spread?: boolean;
|
|
41
|
+
blocks: StructuredBlock[];
|
|
42
|
+
}[];
|
|
43
|
+
}
|
|
44
|
+
export interface MediaBlock {
|
|
45
|
+
type: "media";
|
|
46
|
+
kind: "audio" | "video";
|
|
47
|
+
url: string;
|
|
48
|
+
title: string;
|
|
49
|
+
transcript?: {
|
|
50
|
+
url: string;
|
|
51
|
+
title: string;
|
|
52
|
+
};
|
|
53
|
+
losses?: ProjectionLoss[];
|
|
54
|
+
}
|
|
55
|
+
/** Media can be owned by the host site or served by an absolute HTTP(S) URL. */
|
|
56
|
+
export declare function mediaUrl(value: string): string | undefined;
|
|
57
|
+
export declare function isMediaBlock(value: unknown): value is MediaBlock;
|
|
58
|
+
export type LiteralBlock = (MediaBlock | {
|
|
59
|
+
type: "markdown";
|
|
60
|
+
value: string;
|
|
61
|
+
losses?: ProjectionLoss[];
|
|
62
|
+
} | StructuredBlock) & {
|
|
63
|
+
outline?: import("./outline.js").ProjectedOutline;
|
|
64
|
+
};
|
|
65
|
+
type StructuredBlock = (ParagraphBlock | ListBlock | {
|
|
66
|
+
type: "heading";
|
|
67
|
+
depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
68
|
+
children: Inline[];
|
|
69
|
+
} | {
|
|
70
|
+
type: "codeBlock";
|
|
71
|
+
value: string;
|
|
72
|
+
language?: string;
|
|
73
|
+
meta?: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "blockquote";
|
|
76
|
+
blocks: StructuredBlock[];
|
|
77
|
+
} | {
|
|
78
|
+
type: "table";
|
|
79
|
+
align: TableAlignment[];
|
|
80
|
+
rows: Inline[][][];
|
|
81
|
+
/** Corresponds to rows, including the header at index zero. */
|
|
82
|
+
rowOutlines?: readonly (import("./outline.js").ProjectedOutline | null)[];
|
|
83
|
+
}) & {
|
|
84
|
+
losses?: ProjectionLoss[];
|
|
85
|
+
};
|
|
86
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
87
|
+
[key: string]: JsonValue;
|
|
88
|
+
};
|
|
89
|
+
export interface ValueReference {
|
|
90
|
+
kind: "context" | "data" | "param" | "entity" | "resource" | "provider" | "compute";
|
|
91
|
+
key: string;
|
|
92
|
+
select?: string;
|
|
93
|
+
args?: JsonValue;
|
|
94
|
+
}
|
|
95
|
+
export declare function isValueReference(value: unknown): value is ValueReference;
|
|
96
|
+
/** Computation arguments cross a JSON boundary. Limit work before serializing a programmatically supplied graph. */
|
|
97
|
+
export declare function isComputeArguments(value: unknown): value is JsonValue;
|
|
98
|
+
export interface ValueBlock {
|
|
99
|
+
type: "value";
|
|
100
|
+
ref: ValueReference;
|
|
101
|
+
}
|
|
102
|
+
export type ParameterValue = string | number | boolean | null;
|
|
103
|
+
export interface FragmentParameter {
|
|
104
|
+
type: "string" | "number" | "boolean";
|
|
105
|
+
nullable?: boolean;
|
|
106
|
+
default?: ParameterValue;
|
|
107
|
+
}
|
|
108
|
+
export type Arguments = Readonly<Record<string, ParameterValue>>;
|
|
109
|
+
export interface FragmentInclude {
|
|
110
|
+
type: "include";
|
|
111
|
+
target: string;
|
|
112
|
+
factRevision?: string;
|
|
113
|
+
arguments?: Arguments;
|
|
114
|
+
overrides?: Record<string, InstanceBlock[]>;
|
|
115
|
+
}
|
|
116
|
+
export type ContentReference = {
|
|
117
|
+
type: "reference";
|
|
118
|
+
target: string;
|
|
119
|
+
factRevision?: string;
|
|
120
|
+
} & ({
|
|
121
|
+
label: string;
|
|
122
|
+
select?: never;
|
|
123
|
+
} | {
|
|
124
|
+
select: string;
|
|
125
|
+
label?: never;
|
|
126
|
+
});
|
|
127
|
+
export interface CustomBlock {
|
|
128
|
+
type: "custom";
|
|
129
|
+
name: string;
|
|
130
|
+
attrs: JsonValue;
|
|
131
|
+
version?: number;
|
|
132
|
+
fallbackText?: string;
|
|
133
|
+
children?: InstanceBlock[];
|
|
134
|
+
}
|
|
135
|
+
export type InstanceBlock = ValueBlock | LiteralBlock | FragmentInclude | ContentReference | CustomBlock;
|
|
136
|
+
export type ContentBlock = (InstanceBlock | {
|
|
137
|
+
type: "slot";
|
|
138
|
+
name: string;
|
|
139
|
+
fallback: InstanceBlock[];
|
|
140
|
+
}) & {
|
|
141
|
+
blockId?: string;
|
|
142
|
+
};
|
|
143
|
+
export interface ContentTree {
|
|
144
|
+
schemaVersion: 1;
|
|
145
|
+
blocks: ContentBlock[];
|
|
146
|
+
parameters?: Record<string, FragmentParameter>;
|
|
147
|
+
}
|
|
148
|
+
export interface CustomBlockSchema {
|
|
149
|
+
version: number;
|
|
150
|
+
validate(attrs: JsonValue): boolean;
|
|
151
|
+
normalize?(attrs: JsonValue): JsonValue;
|
|
152
|
+
/** The migration at version n produces the attributes for version n + 1. */
|
|
153
|
+
migrations?: ReadonlyMap<number, (attrs: JsonValue) => JsonValue>;
|
|
154
|
+
}
|
|
155
|
+
export type AttributeSchema = CustomBlockSchema;
|
|
156
|
+
export declare function record(value: unknown): value is Record<string, unknown>;
|
|
157
|
+
export declare function isJsonValue(value: unknown): value is JsonValue;
|
|
158
|
+
/** Upgrade a copy. An authoring host can explicitly commit the result using a revision-checked block replacement. */
|
|
159
|
+
export declare function upgradeCustomBlock(block: CustomBlock & {
|
|
160
|
+
blockId?: string;
|
|
161
|
+
}, schema: CustomBlockSchema): {
|
|
162
|
+
type: "custom";
|
|
163
|
+
name: string;
|
|
164
|
+
fallbackText?: string;
|
|
165
|
+
children?: InstanceBlock[];
|
|
166
|
+
blockId?: string;
|
|
167
|
+
version: number;
|
|
168
|
+
attrs: JsonValue;
|
|
169
|
+
};
|
|
170
|
+
export declare function extensionAttributes(block: Pick<CustomBlock, "name" | "attrs" | "version">, schema: AttributeSchema, source?: string): JsonValue;
|
|
171
|
+
export type ContentExtensionSchemas = ReadonlyMap<string, CustomBlockSchema> | {
|
|
172
|
+
blocks?: ReadonlyMap<string, AttributeSchema>;
|
|
173
|
+
annotations?: ReadonlyMap<string, AttributeSchema>;
|
|
174
|
+
};
|
|
175
|
+
/** Visit only locally authored schema nodes. Paths are relative to the root blocks array. */
|
|
176
|
+
export declare function visitContentExtensions(content: ContentTree, schemas: ContentExtensionSchemas, visit: (node: CustomBlock | InlineAnnotation, schema: AttributeSchema, path: (string | number)[]) => void): void;
|
|
177
|
+
/** Upgrade registered blocks and inline annotations on a copy of their owning tree. */
|
|
178
|
+
export declare function upgradeContentBlocks(content: ContentTree, schemas: ContentExtensionSchemas): ContentTree;
|
|
179
|
+
export declare function bindArguments(id: string, specs?: Record<string, FragmentParameter>, args?: Arguments): Arguments;
|
|
180
|
+
/** Validate data decoded from JSON before using it as document or fragment content. */
|
|
181
|
+
export declare function isContentTree(value: unknown): value is ContentTree;
|
|
182
|
+
export {};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { DocsError } from "./model.js";
|
|
2
|
+
import { isEntityId } from "./semantic.js";
|
|
3
|
+
|
|
4
|
+
// src/content-schema.ts
|
|
5
|
+
/** Media can be owned by the host site or served by an absolute HTTP(S) URL. */
|
|
6
|
+
function mediaUrl(value) {
|
|
7
|
+
if (value.startsWith("/")) {
|
|
8
|
+
if (value.startsWith("//") || /[\\\x00-\x20\x7f]/.test(value)) return;
|
|
9
|
+
const url = new URL(value, "https://docs.invalid");
|
|
10
|
+
if (!url.pathname.startsWith("//") && !/%(?:2f|5c)/i.test(url.pathname)) return url.pathname + url.search + url.hash;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const url = URL.parse(value);
|
|
14
|
+
if (url?.protocol === "http:" || url?.protocol === "https:") return url.href;
|
|
15
|
+
}
|
|
16
|
+
function validMediaLink(value) {
|
|
17
|
+
return typeof value.title === "string" && !!value.title.trim() && typeof value.url === "string" && mediaUrl(value.url) !== void 0;
|
|
18
|
+
}
|
|
19
|
+
function isMediaBlock(value) {
|
|
20
|
+
return record(value) && value.type === "media" && (value.kind === "audio" || value.kind === "video") && validMediaLink(value) && (value.transcript === void 0 || record(value.transcript) && validMediaLink(value.transcript));
|
|
21
|
+
}
|
|
22
|
+
function isValueReference(value) {
|
|
23
|
+
return record(value) && typeof value.kind === "string" && [
|
|
24
|
+
"context",
|
|
25
|
+
"data",
|
|
26
|
+
"param",
|
|
27
|
+
"entity",
|
|
28
|
+
"resource",
|
|
29
|
+
"provider",
|
|
30
|
+
"compute"
|
|
31
|
+
].includes(value.kind) && typeof value.key === "string" && !!value.key && (value.select === void 0 || typeof value.select === "string" && !!value.select) && (value.args === void 0 || value.kind === "compute" && isComputeArguments(value.args));
|
|
32
|
+
}
|
|
33
|
+
/** Computation arguments cross a JSON boundary. Limit work before serializing a programmatically supplied graph. */
|
|
34
|
+
function isComputeArguments(value) {
|
|
35
|
+
let remaining = 1e4;
|
|
36
|
+
function visit(item, depth) {
|
|
37
|
+
if (--remaining < 0 || depth > 64) return false;
|
|
38
|
+
if (item === null || typeof item === "string" || typeof item === "boolean") return true;
|
|
39
|
+
if (typeof item === "number") return Number.isFinite(item);
|
|
40
|
+
if (Array.isArray(item)) {
|
|
41
|
+
if (item.length > remaining || Reflect.ownKeys(item).length !== item.length + 1) return false;
|
|
42
|
+
for (let index = 0; index < item.length; index++) {
|
|
43
|
+
const property = Object.getOwnPropertyDescriptor(item, index);
|
|
44
|
+
if (!property?.enumerable || !("value" in property) || !visit(property.value, depth + 1)) return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (!record(item) || ![Object.prototype, null].includes(Object.getPrototypeOf(item))) return false;
|
|
49
|
+
return Reflect.ownKeys(item).every((key) => {
|
|
50
|
+
const property = Object.getOwnPropertyDescriptor(item, key);
|
|
51
|
+
return typeof key === "string" && property.enumerable && "value" in property && visit(property.value, depth + 1);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return visit(value, 0);
|
|
55
|
+
}
|
|
56
|
+
function record(value) {
|
|
57
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
58
|
+
}
|
|
59
|
+
function validInline(value, insideLink) {
|
|
60
|
+
if (!record(value)) return false;
|
|
61
|
+
if (value.type === "hardBreak") return true;
|
|
62
|
+
if (value.type === "text" || value.type === "code") return typeof value.value === "string";
|
|
63
|
+
if (value.type === "annotation") return typeof value.name === "string" && value.name.trim().length > 0 && isJsonValue(value.attrs) && (value.version === void 0 || validVersion(value.version)) && Array.isArray(value.children) && value.children.every((child) => validInline(child, insideLink));
|
|
64
|
+
if (value.type === "image" || value.type === "link") {
|
|
65
|
+
if (typeof value.url !== "string" || value.title !== void 0 && typeof value.title !== "string") return false;
|
|
66
|
+
if (value.type === "image") return typeof value.alt === "string";
|
|
67
|
+
return !insideLink && Array.isArray(value.children) && value.children.every((child) => validInline(child, true));
|
|
68
|
+
}
|
|
69
|
+
return (value.type === "strong" || value.type === "emphasis" || value.type === "strikethrough") && Array.isArray(value.children) && value.children.every((child) => validInline(child, insideLink));
|
|
70
|
+
}
|
|
71
|
+
function inline(value) {
|
|
72
|
+
return validInline(value, false);
|
|
73
|
+
}
|
|
74
|
+
function isJsonValue(value) {
|
|
75
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
76
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
77
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
78
|
+
return record(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) && Object.values(value).every(isJsonValue);
|
|
79
|
+
}
|
|
80
|
+
const validVersion = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
81
|
+
/** Upgrade a copy. An authoring host can explicitly commit the result using a revision-checked block replacement. */
|
|
82
|
+
function upgradeCustomBlock(block, schema) {
|
|
83
|
+
return {
|
|
84
|
+
...block,
|
|
85
|
+
version: schema.version,
|
|
86
|
+
attrs: extensionAttributes(block, schema)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function extensionAttributes(block, schema, source) {
|
|
90
|
+
const location = source === void 0 ? {} : { source };
|
|
91
|
+
const current = block.version ?? 1;
|
|
92
|
+
if (!validVersion(current) || !validVersion(schema.version) || current > schema.version) throw new DocsError("DOCS_BLOCK_SCHEMA", `Unsupported ${block.name} schema version ${current} for version ${schema.version}.`, location);
|
|
93
|
+
let attrs = structuredClone(block.attrs);
|
|
94
|
+
for (let version = current; version < schema.version; version++) {
|
|
95
|
+
const migrate = schema.migrations?.get(version);
|
|
96
|
+
if (!migrate) throw new DocsError("DOCS_BLOCK_SCHEMA", `Missing ${block.name} migration from version ${version}.`, location);
|
|
97
|
+
attrs = migrate(attrs);
|
|
98
|
+
if (!isJsonValue(attrs)) throw new DocsError("DOCS_BLOCK_SCHEMA", `Invalid JSON from ${block.name} migration at version ${version}.`, location);
|
|
99
|
+
}
|
|
100
|
+
if (!schema.validate(attrs)) throw new DocsError("DOCS_BLOCK_SCHEMA", `Invalid ${block.name} attributes for version ${schema.version}.`, location);
|
|
101
|
+
if (!schema.normalize) return attrs;
|
|
102
|
+
const normalized = schema.normalize(attrs);
|
|
103
|
+
if (!isJsonValue(normalized)) throw new DocsError("DOCS_BLOCK_SCHEMA", `Invalid JSON after normalizing ${block.name}.`, location);
|
|
104
|
+
return normalized;
|
|
105
|
+
}
|
|
106
|
+
/** Visit only locally authored schema nodes. Paths are relative to the root blocks array. */
|
|
107
|
+
function visitContentExtensions(content, schemas, visit) {
|
|
108
|
+
const registry = "get" in schemas ? { blocks: schemas } : schemas;
|
|
109
|
+
function inline(node, path) {
|
|
110
|
+
if (node.type === "annotation") {
|
|
111
|
+
const schema = registry.annotations?.get(node.name);
|
|
112
|
+
if (schema) visit(node, schema, path);
|
|
113
|
+
}
|
|
114
|
+
if ("children" in node) node.children.forEach((child, i) => inline(child, [
|
|
115
|
+
...path,
|
|
116
|
+
"children",
|
|
117
|
+
i
|
|
118
|
+
]));
|
|
119
|
+
}
|
|
120
|
+
function block(node, path) {
|
|
121
|
+
if (!registry.annotations?.size && node.type !== "custom" && node.type !== "slot" && node.type !== "include") return;
|
|
122
|
+
switch (node.type) {
|
|
123
|
+
case "custom": {
|
|
124
|
+
const schema = registry.blocks?.get(node.name);
|
|
125
|
+
if (schema) visit(node, schema, path);
|
|
126
|
+
node.children?.forEach((child, i) => block(child, [
|
|
127
|
+
...path,
|
|
128
|
+
"children",
|
|
129
|
+
i
|
|
130
|
+
]));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case "paragraph":
|
|
134
|
+
case "heading":
|
|
135
|
+
node.children.forEach((child, i) => inline(child, [
|
|
136
|
+
...path,
|
|
137
|
+
"children",
|
|
138
|
+
i
|
|
139
|
+
]));
|
|
140
|
+
break;
|
|
141
|
+
case "table":
|
|
142
|
+
node.rows.forEach((row, r) => row.forEach((cell, c) => cell.forEach((child, i) => inline(child, [
|
|
143
|
+
...path,
|
|
144
|
+
"rows",
|
|
145
|
+
r,
|
|
146
|
+
c,
|
|
147
|
+
i
|
|
148
|
+
]))));
|
|
149
|
+
break;
|
|
150
|
+
case "blockquote":
|
|
151
|
+
node.blocks.forEach((child, i) => block(child, [
|
|
152
|
+
...path,
|
|
153
|
+
"blocks",
|
|
154
|
+
i
|
|
155
|
+
]));
|
|
156
|
+
break;
|
|
157
|
+
case "list":
|
|
158
|
+
node.items.forEach((item, j) => item.blocks.forEach((child, i) => block(child, [
|
|
159
|
+
...path,
|
|
160
|
+
"items",
|
|
161
|
+
j,
|
|
162
|
+
"blocks",
|
|
163
|
+
i
|
|
164
|
+
])));
|
|
165
|
+
break;
|
|
166
|
+
case "slot":
|
|
167
|
+
node.fallback.forEach((child, i) => block(child, [
|
|
168
|
+
...path,
|
|
169
|
+
"fallback",
|
|
170
|
+
i
|
|
171
|
+
]));
|
|
172
|
+
break;
|
|
173
|
+
case "include": for (const [slot, children] of Object.entries(node.overrides ?? {})) children.forEach((child, i) => block(child, [
|
|
174
|
+
...path,
|
|
175
|
+
"overrides",
|
|
176
|
+
slot,
|
|
177
|
+
i
|
|
178
|
+
]));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
content.blocks.forEach((node, i) => block(node, [i]));
|
|
182
|
+
}
|
|
183
|
+
/** Upgrade registered blocks and inline annotations on a copy of their owning tree. */
|
|
184
|
+
function upgradeContentBlocks(content, schemas) {
|
|
185
|
+
const candidate = structuredClone(content);
|
|
186
|
+
visitContentExtensions(candidate, schemas, (node, schema) => {
|
|
187
|
+
node.attrs = extensionAttributes(node, schema);
|
|
188
|
+
node.version = schema.version;
|
|
189
|
+
});
|
|
190
|
+
return candidate;
|
|
191
|
+
}
|
|
192
|
+
function matchesParameter(type, nullable, value) {
|
|
193
|
+
return value === null ? nullable : typeof value === type && (type !== "number" || Number.isFinite(value));
|
|
194
|
+
}
|
|
195
|
+
function parameterSpec(value) {
|
|
196
|
+
return record(value) && (value.type === "string" || value.type === "number" || value.type === "boolean") && (value.nullable === void 0 || typeof value.nullable === "boolean") && (!Object.hasOwn(value, "default") || matchesParameter(value.type, value.nullable === true, value.default));
|
|
197
|
+
}
|
|
198
|
+
function bindArguments(id, specs = {}, args = {}) {
|
|
199
|
+
const result = Object.create(null);
|
|
200
|
+
for (const name of Object.keys(args)) if (!Object.hasOwn(specs, name)) throw new DocsError("DOCS_CONTENT_ARGUMENT", `Unknown parameter ${name} in ${id}.`);
|
|
201
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
202
|
+
const value = Object.hasOwn(args, name) ? args[name] : spec.default;
|
|
203
|
+
if (value === void 0 || !matchesParameter(spec.type, spec.nullable === true, value)) throw new DocsError("DOCS_CONTENT_ARGUMENT", `Expected ${spec.type} for parameter ${name} in ${id}.`);
|
|
204
|
+
result[name] = value;
|
|
205
|
+
}
|
|
206
|
+
return Object.freeze(result);
|
|
207
|
+
}
|
|
208
|
+
/** Validate data decoded from JSON before using it as document or fragment content. */
|
|
209
|
+
function isContentTree(value) {
|
|
210
|
+
if (!record(value) || value.schemaVersion !== 1 || !Array.isArray(value.blocks)) return false;
|
|
211
|
+
if (value.parameters !== void 0 && (!record(value.parameters) || !Object.values(value.parameters).every(parameterSpec))) return false;
|
|
212
|
+
const ids = /* @__PURE__ */ new Set();
|
|
213
|
+
return validBlocks(value.blocks, true) && value.blocks.every((block) => {
|
|
214
|
+
if (block.blockId === void 0) return true;
|
|
215
|
+
if (typeof block.blockId !== "string" || !block.blockId.trim() || ids.has(block.blockId)) return false;
|
|
216
|
+
ids.add(block.blockId);
|
|
217
|
+
return true;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function validList(block) {
|
|
221
|
+
return typeof block.ordered === "boolean" && (block.spread === void 0 || typeof block.spread === "boolean") && (block.start === void 0 || block.ordered && typeof block.start === "number" && Number.isInteger(block.start) && block.start >= 0 && block.start <= 999999999) && Array.isArray(block.items) && block.items.length > 0 && block.items.every((item) => record(item) && (item.checked === void 0 || typeof item.checked === "boolean") && (item.spread === void 0 || typeof item.spread === "boolean") && validStructuredBlocks(item.blocks));
|
|
222
|
+
}
|
|
223
|
+
function validStructuredBlocks(blocks) {
|
|
224
|
+
return Array.isArray(blocks) && blocks.every((child) => record(child) && typeof child.type === "string" && [
|
|
225
|
+
"paragraph",
|
|
226
|
+
"heading",
|
|
227
|
+
"codeBlock",
|
|
228
|
+
"list",
|
|
229
|
+
"table",
|
|
230
|
+
"blockquote"
|
|
231
|
+
].includes(child.type)) && validBlocks(blocks, false);
|
|
232
|
+
}
|
|
233
|
+
function projectionLoss(value) {
|
|
234
|
+
return record(value) && (value.target === "web" || value.target === "markdown") && (value.severity === "warning" || value.severity === "info") && [
|
|
235
|
+
"raw-html",
|
|
236
|
+
"interactive-example",
|
|
237
|
+
"mdx-component",
|
|
238
|
+
"custom-block",
|
|
239
|
+
"custom-mark",
|
|
240
|
+
"media-player",
|
|
241
|
+
"native-view"
|
|
242
|
+
].some((kind) => kind === value.kind) && typeof value.source === "string" && typeof value.message === "string" && (value.line === void 0 || typeof value.line === "number" && Number.isSafeInteger(value.line) && value.line >= 1);
|
|
243
|
+
}
|
|
244
|
+
function validBlocks(value, allowSlots) {
|
|
245
|
+
return Array.isArray(value) && value.every((block) => {
|
|
246
|
+
if (!record(block) || !allowSlots && block.blockId !== void 0) return false;
|
|
247
|
+
if (block.losses !== void 0 && ([
|
|
248
|
+
"slot",
|
|
249
|
+
"reference",
|
|
250
|
+
"include",
|
|
251
|
+
"custom"
|
|
252
|
+
].some((type) => type === block.type) || !Array.isArray(block.losses) || !block.losses.every(projectionLoss))) return false;
|
|
253
|
+
switch (block.type) {
|
|
254
|
+
case "value": return isValueReference(block.ref);
|
|
255
|
+
case "reference": return typeof block.target === "string" && isEntityId(block.target) && (block.select === void 0 ? typeof block.label === "string" && !!block.label.trim() : block.label === void 0 && typeof block.select === "string" && /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(block.select)) && (block.factRevision === void 0 || typeof block.factRevision === "string");
|
|
256
|
+
case "include": return typeof block.target === "string" && block.target.startsWith("fragment:") && (block.factRevision === void 0 || typeof block.factRevision === "string") && (block.arguments === void 0 || record(block.arguments) && Object.values(block.arguments).every((value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))) && (block.overrides === void 0 || record(block.overrides) && Object.values(block.overrides).every((children) => validBlocks(children, false)));
|
|
257
|
+
case "slot": return allowSlots && typeof block.name === "string" && !!block.name && validBlocks(block.fallback, false);
|
|
258
|
+
case "custom": return typeof block.name === "string" && isJsonValue(block.attrs) && (block.children === void 0 || validBlocks(block.children, false)) && (block.fallbackText === void 0 || typeof block.fallbackText === "string" && !!block.fallbackText.trim()) && (block.version === void 0 || validVersion(block.version));
|
|
259
|
+
case "blockquote": return validStructuredBlocks(block.blocks);
|
|
260
|
+
case "list": return validList(block);
|
|
261
|
+
case "table": {
|
|
262
|
+
const { align, rows, rowOutlines } = block;
|
|
263
|
+
return Array.isArray(align) && align.length > 0 && align.every((value) => [
|
|
264
|
+
null,
|
|
265
|
+
"left",
|
|
266
|
+
"center",
|
|
267
|
+
"right"
|
|
268
|
+
].includes(value)) && Array.isArray(rows) && rows.length > 0 && (rowOutlines === void 0 || Array.isArray(rowOutlines) && rowOutlines.length === rows.length && rowOutlines.every((item) => item === null || record(item))) && rows.every((row) => Array.isArray(row) && row.length === align.length && row.every((cell) => Array.isArray(cell) && cell.every(inline)));
|
|
269
|
+
}
|
|
270
|
+
case "codeBlock": return typeof block.value === "string" && (block.language === void 0 || typeof block.language === "string" && /^\S+$/u.test(block.language)) && (block.meta === void 0 || !!block.language && typeof block.meta === "string" && !!block.meta.trim() && !/[\r\n]/.test(block.meta));
|
|
271
|
+
case "media": return isMediaBlock(block);
|
|
272
|
+
case "markdown": return typeof block.value === "string";
|
|
273
|
+
case "heading": if (block.outline !== void 0 && (!record(block.outline) || typeof block.outline.kind !== "string" || !block.outline.kind.trim() || block.outline.parent !== void 0 && (typeof block.outline.parent !== "string" || !block.outline.parent) || block.outline.text !== void 0 && typeof block.outline.text !== "string" || block.outline.reference !== void 0 && typeof block.outline.reference !== "string")) return false;
|
|
274
|
+
case "paragraph": return (block.type === "paragraph" || typeof block.depth === "number" && [
|
|
275
|
+
1,
|
|
276
|
+
2,
|
|
277
|
+
3,
|
|
278
|
+
4,
|
|
279
|
+
5,
|
|
280
|
+
6
|
|
281
|
+
].includes(block.depth)) && Array.isArray(block.children) && block.children.every(inline);
|
|
282
|
+
default: return false;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { bindArguments, extensionAttributes, isComputeArguments, isContentTree, isJsonValue, isMediaBlock, isValueReference, mediaUrl, record, upgradeContentBlocks, upgradeCustomBlock, visitContentExtensions };
|
|
288
|
+
//# sourceMappingURL=content-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-schema.js","names":[],"sources":["../src/content-schema.ts"],"sourcesContent":["import { DocsError, type ProjectionLoss } from \"./model.js\"\nimport { isEntityId } from \"./semantic.js\"\n\nexport interface InlineAnnotation {\n type: \"annotation\"\n name: string\n attrs: JsonValue\n version?: number\n children: Inline[]\n}\nexport type Inline =\n | InlineAnnotation\n | { type: \"text\" | \"code\"; value: string }\n | { type: \"strong\" | \"emphasis\" | \"strikethrough\"; children: Inline[] }\n | { type: \"hardBreak\" }\n | { type: \"link\"; url: string; title?: string; children: Inline[] }\n | { type: \"image\"; url: string; alt: string; title?: string }\nexport type TableAlignment = \"left\" | \"center\" | \"right\" | null\nexport interface ParagraphBlock {\n type: \"paragraph\"\n children: Inline[]\n}\nexport interface ListBlock {\n type: \"list\"\n ordered: boolean\n start?: number\n spread?: boolean\n items: { checked?: boolean; spread?: boolean; blocks: StructuredBlock[] }[]\n}\nexport interface MediaBlock {\n type: \"media\"\n kind: \"audio\" | \"video\"\n url: string\n title: string\n transcript?: { url: string; title: string }\n losses?: ProjectionLoss[]\n}\n\n/** Media can be owned by the host site or served by an absolute HTTP(S) URL. */\nexport function mediaUrl(value: string) {\n if (value.startsWith(\"/\")) {\n if (value.startsWith(\"//\") || /[\\\\\\x00-\\x20\\x7f]/.test(value)) return\n const url = new URL(value, \"https://docs.invalid\")\n if (!url.pathname.startsWith(\"//\") && !/%(?:2f|5c)/i.test(url.pathname))\n return url.pathname + url.search + url.hash\n return\n }\n const url = URL.parse(value)\n if (url?.protocol === \"http:\" || url?.protocol === \"https:\") return url.href\n}\n\nfunction validMediaLink(value: Record<string, unknown>) {\n return (\n typeof value.title === \"string\" &&\n !!value.title.trim() &&\n typeof value.url === \"string\" &&\n mediaUrl(value.url) !== undefined\n )\n}\n\nexport function isMediaBlock(value: unknown): value is MediaBlock {\n return (\n record(value) &&\n value.type === \"media\" &&\n (value.kind === \"audio\" || value.kind === \"video\") &&\n validMediaLink(value) &&\n (value.transcript === undefined ||\n (record(value.transcript) && validMediaLink(value.transcript)))\n )\n}\n\nexport type LiteralBlock = (\n MediaBlock | { type: \"markdown\"; value: string; losses?: ProjectionLoss[] } | StructuredBlock\n) & { outline?: import(\"./outline.js\").ProjectedOutline }\ntype StructuredBlock = (\n | ParagraphBlock\n | ListBlock\n | { type: \"heading\"; depth: 1 | 2 | 3 | 4 | 5 | 6; children: Inline[] }\n | { type: \"codeBlock\"; value: string; language?: string; meta?: string }\n | { type: \"blockquote\"; blocks: StructuredBlock[] }\n | {\n type: \"table\"\n align: TableAlignment[]\n rows: Inline[][][]\n /** Corresponds to rows, including the header at index zero. */\n rowOutlines?: readonly (import(\"./outline.js\").ProjectedOutline | null)[]\n }\n) & { losses?: ProjectionLoss[] }\nexport type JsonValue =\n null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }\nexport interface ValueReference {\n kind: \"context\" | \"data\" | \"param\" | \"entity\" | \"resource\" | \"provider\" | \"compute\"\n key: string\n select?: string\n args?: JsonValue\n}\nexport function isValueReference(value: unknown): value is ValueReference {\n return (\n record(value) &&\n typeof value.kind === \"string\" &&\n [\"context\", \"data\", \"param\", \"entity\", \"resource\", \"provider\", \"compute\"].includes(\n value.kind,\n ) &&\n typeof value.key === \"string\" &&\n !!value.key &&\n (value.select === undefined || (typeof value.select === \"string\" && !!value.select)) &&\n (value.args === undefined || (value.kind === \"compute\" && isComputeArguments(value.args)))\n )\n}\n/** Computation arguments cross a JSON boundary. Limit work before serializing a programmatically supplied graph. */\nexport function isComputeArguments(value: unknown): value is JsonValue {\n let remaining = 10000\n function visit(item: unknown, depth: number): boolean {\n if (--remaining < 0 || depth > 64) return false\n if (item === null || typeof item === \"string\" || typeof item === \"boolean\") return true\n if (typeof item === \"number\") return Number.isFinite(item)\n if (Array.isArray(item)) {\n if (item.length > remaining || Reflect.ownKeys(item).length !== item.length + 1) return false\n for (let index = 0; index < item.length; index++) {\n const property = Object.getOwnPropertyDescriptor(item, index)\n if (!property?.enumerable || !(\"value\" in property) || !visit(property.value, depth + 1))\n return false\n }\n return true\n }\n if (!record(item) || ![Object.prototype, null].includes(Object.getPrototypeOf(item)))\n return false\n return Reflect.ownKeys(item).every((key) => {\n const property = Object.getOwnPropertyDescriptor(item, key)!\n return (\n typeof key === \"string\" &&\n property.enumerable &&\n \"value\" in property &&\n visit(property.value, depth + 1)\n )\n })\n }\n return visit(value, 0)\n}\nexport interface ValueBlock {\n type: \"value\"\n ref: ValueReference\n}\nexport type ParameterValue = string | number | boolean | null\nexport interface FragmentParameter {\n type: \"string\" | \"number\" | \"boolean\"\n nullable?: boolean\n default?: ParameterValue\n}\nexport type Arguments = Readonly<Record<string, ParameterValue>>\nexport interface FragmentInclude {\n type: \"include\"\n target: string\n factRevision?: string\n arguments?: Arguments\n overrides?: Record<string, InstanceBlock[]>\n}\nexport type ContentReference = { type: \"reference\"; target: string; factRevision?: string } & (\n { label: string; select?: never } | { select: string; label?: never }\n)\nexport interface CustomBlock {\n type: \"custom\"\n name: string\n attrs: JsonValue\n version?: number\n fallbackText?: string\n children?: InstanceBlock[]\n}\nexport type InstanceBlock =\n ValueBlock | LiteralBlock | FragmentInclude | ContentReference | CustomBlock\nexport type ContentBlock = (\n InstanceBlock | { type: \"slot\"; name: string; fallback: InstanceBlock[] }\n) & { blockId?: string }\nexport interface ContentTree {\n schemaVersion: 1\n blocks: ContentBlock[]\n parameters?: Record<string, FragmentParameter>\n}\nexport interface CustomBlockSchema {\n version: number\n validate(attrs: JsonValue): boolean\n normalize?(attrs: JsonValue): JsonValue\n /** The migration at version n produces the attributes for version n + 1. */\n migrations?: ReadonlyMap<number, (attrs: JsonValue) => JsonValue>\n}\n\nexport type AttributeSchema = CustomBlockSchema\n\nexport function record(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value)\n}\nfunction validInline(value: unknown, insideLink: boolean): boolean {\n if (!record(value)) return false\n if (value.type === \"hardBreak\") return true\n if (value.type === \"text\" || value.type === \"code\") return typeof value.value === \"string\"\n if (value.type === \"annotation\")\n return (\n typeof value.name === \"string\" &&\n value.name.trim().length > 0 &&\n isJsonValue(value.attrs) &&\n (value.version === undefined || validVersion(value.version)) &&\n Array.isArray(value.children) &&\n value.children.every((child) => validInline(child, insideLink))\n )\n if (value.type === \"image\" || value.type === \"link\") {\n if (\n typeof value.url !== \"string\" ||\n (value.title !== undefined && typeof value.title !== \"string\")\n )\n return false\n if (value.type === \"image\") return typeof value.alt === \"string\"\n return (\n !insideLink &&\n Array.isArray(value.children) &&\n value.children.every((child) => validInline(child, true))\n )\n }\n return (\n (value.type === \"strong\" || value.type === \"emphasis\" || value.type === \"strikethrough\") &&\n Array.isArray(value.children) &&\n value.children.every((child) => validInline(child, insideLink))\n )\n}\nfunction inline(value: unknown): boolean {\n return validInline(value, false)\n}\nexport function isJsonValue(value: unknown): value is JsonValue {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true\n if (typeof value === \"number\") return Number.isFinite(value)\n if (Array.isArray(value)) return value.every(isJsonValue)\n return (\n record(value) &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) &&\n Object.values(value).every(isJsonValue)\n )\n}\n\nconst validVersion = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value > 0\n\n/** Upgrade a copy. An authoring host can explicitly commit the result using a revision-checked block replacement. */\nexport function upgradeCustomBlock(\n block: CustomBlock & { blockId?: string },\n schema: CustomBlockSchema,\n) {\n return { ...block, version: schema.version, attrs: extensionAttributes(block, schema) }\n}\n\nexport function extensionAttributes(\n block: Pick<CustomBlock, \"name\" | \"attrs\" | \"version\">,\n schema: AttributeSchema,\n source?: string,\n) {\n const location = source === undefined ? {} : { source }\n const current = block.version ?? 1\n if (!validVersion(current) || !validVersion(schema.version) || current > schema.version)\n throw new DocsError(\n \"DOCS_BLOCK_SCHEMA\",\n `Unsupported ${block.name} schema version ${current} for version ${schema.version}.`,\n location,\n )\n let attrs = structuredClone(block.attrs)\n for (let version = current; version < schema.version; version++) {\n const migrate = schema.migrations?.get(version)\n if (!migrate)\n throw new DocsError(\n \"DOCS_BLOCK_SCHEMA\",\n `Missing ${block.name} migration from version ${version}.`,\n location,\n )\n attrs = migrate(attrs)\n if (!isJsonValue(attrs))\n throw new DocsError(\n \"DOCS_BLOCK_SCHEMA\",\n `Invalid JSON from ${block.name} migration at version ${version}.`,\n location,\n )\n }\n if (!schema.validate(attrs))\n throw new DocsError(\n \"DOCS_BLOCK_SCHEMA\",\n `Invalid ${block.name} attributes for version ${schema.version}.`,\n location,\n )\n if (!schema.normalize) return attrs\n const normalized = schema.normalize(attrs)\n if (!isJsonValue(normalized))\n throw new DocsError(\n \"DOCS_BLOCK_SCHEMA\",\n `Invalid JSON after normalizing ${block.name}.`,\n location,\n )\n return normalized\n}\n\nexport type ContentExtensionSchemas =\n | ReadonlyMap<string, CustomBlockSchema>\n | {\n blocks?: ReadonlyMap<string, AttributeSchema>\n annotations?: ReadonlyMap<string, AttributeSchema>\n }\n\n/** Visit only locally authored schema nodes. Paths are relative to the root blocks array. */\nexport function visitContentExtensions(\n content: ContentTree,\n schemas: ContentExtensionSchemas,\n visit: (\n node: CustomBlock | InlineAnnotation,\n schema: AttributeSchema,\n path: (string | number)[],\n ) => void,\n) {\n const registry = \"get\" in schemas ? { blocks: schemas } : schemas\n type Path = (string | number)[]\n function inline(node: Inline, path: Path) {\n if (node.type === \"annotation\") {\n const schema = registry.annotations?.get(node.name)\n if (schema) visit(node, schema, path)\n }\n if (\"children\" in node)\n node.children.forEach((child, i) => inline(child, [...path, \"children\", i]))\n }\n function block(node: ContentBlock, path: Path) {\n if (\n !registry.annotations?.size &&\n node.type !== \"custom\" &&\n node.type !== \"slot\" &&\n node.type !== \"include\"\n )\n return\n switch (node.type) {\n case \"custom\": {\n const schema = registry.blocks?.get(node.name)\n if (schema) visit(node, schema, path)\n node.children?.forEach((child, i) => block(child, [...path, \"children\", i]))\n break\n }\n case \"paragraph\":\n case \"heading\":\n node.children.forEach((child, i) => inline(child, [...path, \"children\", i]))\n break\n case \"table\":\n node.rows.forEach((row, r) =>\n row.forEach((cell, c) =>\n cell.forEach((child, i) => inline(child, [...path, \"rows\", r, c, i])),\n ),\n )\n break\n case \"blockquote\":\n node.blocks.forEach((child, i) => block(child, [...path, \"blocks\", i]))\n break\n case \"list\":\n node.items.forEach((item, j) =>\n item.blocks.forEach((child, i) => block(child, [...path, \"items\", j, \"blocks\", i])),\n )\n break\n case \"slot\":\n node.fallback.forEach((child, i) => block(child, [...path, \"fallback\", i]))\n break\n case \"include\":\n for (const [slot, children] of Object.entries(node.overrides ?? {}))\n children.forEach((child, i) => block(child, [...path, \"overrides\", slot, i]))\n }\n }\n content.blocks.forEach((node, i) => block(node, [i]))\n}\n\n/** Upgrade registered blocks and inline annotations on a copy of their owning tree. */\nexport function upgradeContentBlocks(\n content: ContentTree,\n schemas: ContentExtensionSchemas,\n): ContentTree {\n const candidate = structuredClone(content)\n visitContentExtensions(candidate, schemas, (node, schema) => {\n node.attrs = extensionAttributes(node, schema)\n node.version = schema.version\n })\n return candidate\n}\n\nfunction matchesParameter(type: FragmentParameter[\"type\"], nullable: boolean, value: unknown) {\n return value === null\n ? nullable\n : typeof value === type && (type !== \"number\" || Number.isFinite(value))\n}\nfunction parameterSpec(value: unknown): value is FragmentParameter {\n return (\n record(value) &&\n (value.type === \"string\" || value.type === \"number\" || value.type === \"boolean\") &&\n (value.nullable === undefined || typeof value.nullable === \"boolean\") &&\n (!Object.hasOwn(value, \"default\") ||\n matchesParameter(value.type, value.nullable === true, value.default))\n )\n}\nexport function bindArguments(\n id: string,\n specs: Record<string, FragmentParameter> = {},\n args: Arguments = {},\n): Arguments {\n const result: Record<string, ParameterValue> = Object.create(null)\n for (const name of Object.keys(args))\n if (!Object.hasOwn(specs, name))\n throw new DocsError(\"DOCS_CONTENT_ARGUMENT\", `Unknown parameter ${name} in ${id}.`)\n for (const [name, spec] of Object.entries(specs)) {\n const value = Object.hasOwn(args, name) ? args[name] : spec.default\n if (value === undefined || !matchesParameter(spec.type, spec.nullable === true, value))\n throw new DocsError(\n \"DOCS_CONTENT_ARGUMENT\",\n `Expected ${spec.type} for parameter ${name} in ${id}.`,\n )\n result[name] = value\n }\n return Object.freeze(result)\n}\n\n/** Validate data decoded from JSON before using it as document or fragment content. */\nexport function isContentTree(value: unknown): value is ContentTree {\n if (!record(value) || value.schemaVersion !== 1 || !Array.isArray(value.blocks)) return false\n if (\n value.parameters !== undefined &&\n (!record(value.parameters) || !Object.values(value.parameters).every(parameterSpec))\n )\n return false\n const ids = new Set<string>()\n return (\n validBlocks(value.blocks, true) &&\n value.blocks.every((block) => {\n if (block.blockId === undefined) return true\n if (typeof block.blockId !== \"string\" || !block.blockId.trim() || ids.has(block.blockId))\n return false\n ids.add(block.blockId)\n return true\n })\n )\n}\n\nfunction validList(block: Record<string, unknown>): boolean {\n return (\n typeof block.ordered === \"boolean\" &&\n (block.spread === undefined || typeof block.spread === \"boolean\") &&\n (block.start === undefined ||\n (block.ordered &&\n typeof block.start === \"number\" &&\n Number.isInteger(block.start) &&\n block.start >= 0 &&\n block.start <= 999999999)) &&\n Array.isArray(block.items) &&\n block.items.length > 0 &&\n block.items.every(\n (item) =>\n record(item) &&\n (item.checked === undefined || typeof item.checked === \"boolean\") &&\n (item.spread === undefined || typeof item.spread === \"boolean\") &&\n validStructuredBlocks(item.blocks),\n )\n )\n}\n\nfunction validStructuredBlocks(blocks: unknown): boolean {\n return (\n Array.isArray(blocks) &&\n blocks.every(\n (child) =>\n record(child) &&\n typeof child.type === \"string\" &&\n [\"paragraph\", \"heading\", \"codeBlock\", \"list\", \"table\", \"blockquote\"].includes(child.type),\n ) &&\n validBlocks(blocks, false)\n )\n}\n\nfunction projectionLoss(value: unknown): value is ProjectionLoss {\n return (\n record(value) &&\n (value.target === \"web\" || value.target === \"markdown\") &&\n (value.severity === \"warning\" || value.severity === \"info\") &&\n [\n \"raw-html\",\n \"interactive-example\",\n \"mdx-component\",\n \"custom-block\",\n \"custom-mark\",\n \"media-player\",\n \"native-view\",\n ].some((kind) => kind === value.kind) &&\n typeof value.source === \"string\" &&\n typeof value.message === \"string\" &&\n (value.line === undefined ||\n (typeof value.line === \"number\" && Number.isSafeInteger(value.line) && value.line >= 1))\n )\n}\n\nfunction validBlocks(value: unknown, allowSlots: boolean): boolean {\n return (\n Array.isArray(value) &&\n value.every((block: unknown) => {\n if (!record(block) || (!allowSlots && block.blockId !== undefined)) return false\n if (\n block.losses !== undefined &&\n ([\"slot\", \"reference\", \"include\", \"custom\"].some((type) => type === block.type) ||\n !Array.isArray(block.losses) ||\n !block.losses.every(projectionLoss))\n )\n return false\n switch (block.type) {\n case \"value\":\n return isValueReference(block.ref)\n case \"reference\":\n return (\n typeof block.target === \"string\" &&\n isEntityId(block.target) &&\n (block.select === undefined\n ? typeof block.label === \"string\" && !!block.label.trim()\n : block.label === undefined &&\n typeof block.select === \"string\" &&\n /^[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*$/.test(block.select)) &&\n (block.factRevision === undefined || typeof block.factRevision === \"string\")\n )\n case \"include\":\n return (\n typeof block.target === \"string\" &&\n block.target.startsWith(\"fragment:\") &&\n (block.factRevision === undefined || typeof block.factRevision === \"string\") &&\n (block.arguments === undefined ||\n (record(block.arguments) &&\n Object.values(block.arguments).every(\n (value) =>\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\" ||\n (typeof value === \"number\" && Number.isFinite(value)),\n ))) &&\n (block.overrides === undefined ||\n (record(block.overrides) &&\n Object.values(block.overrides).every((children) => validBlocks(children, false))))\n )\n case \"slot\":\n return (\n allowSlots &&\n typeof block.name === \"string\" &&\n !!block.name &&\n validBlocks(block.fallback, false)\n )\n case \"custom\":\n return (\n typeof block.name === \"string\" &&\n isJsonValue(block.attrs) &&\n (block.children === undefined || validBlocks(block.children, false)) &&\n (block.fallbackText === undefined ||\n (typeof block.fallbackText === \"string\" && !!block.fallbackText.trim())) &&\n (block.version === undefined || validVersion(block.version))\n )\n case \"blockquote\":\n return validStructuredBlocks(block.blocks)\n case \"list\":\n return validList(block)\n case \"table\": {\n const { align, rows, rowOutlines } = block\n return (\n Array.isArray(align) &&\n align.length > 0 &&\n align.every((value) => [null, \"left\", \"center\", \"right\"].includes(value)) &&\n Array.isArray(rows) &&\n rows.length > 0 &&\n (rowOutlines === undefined ||\n (Array.isArray(rowOutlines) &&\n rowOutlines.length === rows.length &&\n rowOutlines.every((item) => item === null || record(item)))) &&\n rows.every(\n (row) =>\n Array.isArray(row) &&\n row.length === align.length &&\n row.every((cell) => Array.isArray(cell) && cell.every(inline)),\n )\n )\n }\n case \"codeBlock\":\n return (\n typeof block.value === \"string\" &&\n (block.language === undefined ||\n (typeof block.language === \"string\" && /^\\S+$/u.test(block.language))) &&\n (block.meta === undefined ||\n (!!block.language &&\n typeof block.meta === \"string\" &&\n !!block.meta.trim() &&\n !/[\\r\\n]/.test(block.meta)))\n )\n case \"media\":\n return isMediaBlock(block)\n case \"markdown\":\n return typeof block.value === \"string\"\n case \"heading\":\n if (\n block.outline !== undefined &&\n (!record(block.outline) ||\n typeof block.outline.kind !== \"string\" ||\n !block.outline.kind.trim() ||\n (block.outline.parent !== undefined &&\n (typeof block.outline.parent !== \"string\" || !block.outline.parent)) ||\n (block.outline.text !== undefined && typeof block.outline.text !== \"string\") ||\n (block.outline.reference !== undefined &&\n typeof block.outline.reference !== \"string\"))\n )\n return false\n case \"paragraph\":\n return (\n (block.type === \"paragraph\" ||\n (typeof block.depth === \"number\" && [1, 2, 3, 4, 5, 6].includes(block.depth))) &&\n Array.isArray(block.children) &&\n block.children.every(inline)\n )\n default:\n return false\n }\n })\n )\n}\n"],"mappings":";;;;;AAuCA,SAAgB,SAAS,OAAe;CACtC,IAAI,MAAM,WAAW,GAAG,GAAG;EACzB,IAAI,MAAM,WAAW,IAAI,KAAK,oBAAoB,KAAK,KAAK,GAAG;EAC/D,MAAM,MAAM,IAAI,IAAI,OAAO,sBAAsB;EACjD,IAAI,CAAC,IAAI,SAAS,WAAW,IAAI,KAAK,CAAC,cAAc,KAAK,IAAI,QAAQ,GACpE,OAAO,IAAI,WAAW,IAAI,SAAS,IAAI;EACzC;CACF;CACA,MAAM,MAAM,IAAI,MAAM,KAAK;CAC3B,IAAI,KAAK,aAAa,WAAW,KAAK,aAAa,UAAU,OAAO,IAAI;AAC1E;AAEA,SAAS,eAAe,OAAgC;CACtD,OACE,OAAO,MAAM,UAAU,YACvB,CAAC,CAAC,MAAM,MAAM,KAAK,KACnB,OAAO,MAAM,QAAQ,YACrB,SAAS,MAAM,GAAG,MAAM;AAE5B;AAEA,SAAgB,aAAa,OAAqC;CAChE,OACE,OAAO,KAAK,KACZ,MAAM,SAAS,YACd,MAAM,SAAS,WAAW,MAAM,SAA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