@shoklan/pustaka-contracts 0.0.0-stage → 0.1.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/README.md +6 -2
- package/dist/contracts.d.ts +269 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +169 -0
- package/dist/contracts.js.map +1 -0
- package/dist/corpus.d.ts +48 -0
- package/dist/corpus.d.ts.map +1 -0
- package/dist/corpus.js +26 -0
- package/dist/corpus.js.map +1 -0
- package/dist/crypto.d.ts +148 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +470 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/renderer.d.ts +54 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +101 -0
- package/dist/renderer.js.map +1 -0
- package/dist/tree.d.ts +77 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +208 -0
- package/dist/tree.js.map +1 -0
- package/package.json +65 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical renderer domains owned by the consumer web application.
|
|
4
|
+
* Every renderer manifest binds the complete canonical domain set.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RendererDomainSchema: z.ZodEnum<{
|
|
7
|
+
materials: "materials";
|
|
8
|
+
exercises: "exercises";
|
|
9
|
+
}>;
|
|
10
|
+
export type RendererDomain = z.infer<typeof RendererDomainSchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Whitelist of approved design-system components permitted in authored MDX.
|
|
13
|
+
* Reference: Nakafa ADR 0018 (Canonical component names, single current set, no versions).
|
|
14
|
+
*/
|
|
15
|
+
export declare const ALLOWED_COMPONENTS: readonly ["Anchor", "BlockMath", "Callout", "Heading", "InlineMath", "MathContainer", "Mermaid", "MermaidMdx", "Paragraph", "PaywallCallout", "ReactFlowDiagram", "Table", "TableBody", "TableCell", "TableHead", "TableHeader", "TableRow", "Youtube"];
|
|
16
|
+
export type AllowedComponent = (typeof ALLOWED_COMPONENTS)[number];
|
|
17
|
+
/** Checks whether a component name is within the approved renderer manifest. */
|
|
18
|
+
export declare function isComponentAllowed(name: string): name is AllowedComponent;
|
|
19
|
+
/**
|
|
20
|
+
* Computes a deterministic SHA-256 hash of the allowed renderer components.
|
|
21
|
+
* Sorts components in Unicode code-unit order so output is invariant to insertion order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeRendererManifestHash(components: readonly string[]): string;
|
|
24
|
+
/**
|
|
25
|
+
* Canonical renderer manifest envelope (ADR 0018: no version field).
|
|
26
|
+
*/
|
|
27
|
+
export declare const RendererManifestSchema: z.ZodObject<{
|
|
28
|
+
components: z.ZodArray<z.ZodString>;
|
|
29
|
+
domains: z.ZodArray<z.ZodEnum<{
|
|
30
|
+
materials: "materials";
|
|
31
|
+
exercises: "exercises";
|
|
32
|
+
}>>;
|
|
33
|
+
manifestHash: z.ZodString;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export type RendererManifest = z.infer<typeof RendererManifestSchema>;
|
|
36
|
+
/** Builds the canonical renderer manifest for a component list. */
|
|
37
|
+
export declare function createRendererManifest(components?: readonly string[], domains?: readonly RendererDomain[]): RendererManifest;
|
|
38
|
+
/** Error raised when an artifact requires a component absent from the live renderer manifest. */
|
|
39
|
+
export declare class RendererCompatibilityError extends Error {
|
|
40
|
+
readonly missingComponents: string[];
|
|
41
|
+
readonly contentKey?: string | undefined;
|
|
42
|
+
constructor(missingComponents: string[], contentKey?: string | undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Verifies that every component required by an artifact is supported by the
|
|
46
|
+
* given renderer component whitelist (defaults to canonical ALLOWED_COMPONENTS).
|
|
47
|
+
*/
|
|
48
|
+
export declare function assertRendererCompatibility(requiredComponents: readonly string[], contentKey?: string, supportedComponents?: readonly string[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Proves directional compatibility (ADR 0002): the live renderer must support
|
|
51
|
+
* every domain and every component declared by a frozen manifest.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isRendererSuperset(live: RendererManifest, frozen: RendererManifest): boolean;
|
|
54
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;EAAqC,CAAC;AACvE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,yPAmBrB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAInE,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAEzE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,CAGR;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;kBAMxB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,mEAAmE;AACnE,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,SAAS,MAAM,EAAuB,EAClD,OAAO,GAAE,SAAS,cAAc,EAA+B,GAC9D,gBAAgB,CAQlB;AAED,iGAAiG;AACjG,qBAAa,0BAA2B,SAAQ,KAAK;aAEjC,iBAAiB,EAAE,MAAM,EAAE;aAC3B,UAAU,CAAC,EAAE,MAAM;gBADnB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,UAAU,CAAC,EAAE,MAAM,YAAA;CAStC;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,UAAU,CAAC,EAAE,MAAM,EACnB,mBAAmB,GAAE,SAAS,MAAM,EAAuB,GAC1D,IAAI,CAUN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAOT"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Canonical renderer domains owned by the consumer web application.
|
|
5
|
+
* Every renderer manifest binds the complete canonical domain set.
|
|
6
|
+
*/
|
|
7
|
+
export const RendererDomainSchema = z.enum(["materials", "exercises"]);
|
|
8
|
+
/**
|
|
9
|
+
* Whitelist of approved design-system components permitted in authored MDX.
|
|
10
|
+
* Reference: Nakafa ADR 0018 (Canonical component names, single current set, no versions).
|
|
11
|
+
*/
|
|
12
|
+
export const ALLOWED_COMPONENTS = [
|
|
13
|
+
"Anchor",
|
|
14
|
+
"BlockMath",
|
|
15
|
+
"Callout",
|
|
16
|
+
"Heading",
|
|
17
|
+
"InlineMath",
|
|
18
|
+
"MathContainer",
|
|
19
|
+
"Mermaid",
|
|
20
|
+
"MermaidMdx",
|
|
21
|
+
"Paragraph",
|
|
22
|
+
"PaywallCallout",
|
|
23
|
+
"ReactFlowDiagram",
|
|
24
|
+
"Table",
|
|
25
|
+
"TableBody",
|
|
26
|
+
"TableCell",
|
|
27
|
+
"TableHead",
|
|
28
|
+
"TableHeader",
|
|
29
|
+
"TableRow",
|
|
30
|
+
"Youtube",
|
|
31
|
+
];
|
|
32
|
+
const ALLOWED_COMPONENTS_SET = new Set(ALLOWED_COMPONENTS);
|
|
33
|
+
/** Checks whether a component name is within the approved renderer manifest. */
|
|
34
|
+
export function isComponentAllowed(name) {
|
|
35
|
+
return ALLOWED_COMPONENTS_SET.has(name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Computes a deterministic SHA-256 hash of the allowed renderer components.
|
|
39
|
+
* Sorts components in Unicode code-unit order so output is invariant to insertion order.
|
|
40
|
+
*/
|
|
41
|
+
export function computeRendererManifestHash(components) {
|
|
42
|
+
const sorted = [...new Set(components)].sort();
|
|
43
|
+
return createHash("sha256").update(JSON.stringify(sorted), "utf8").digest("hex");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Canonical renderer manifest envelope (ADR 0018: no version field).
|
|
47
|
+
*/
|
|
48
|
+
export const RendererManifestSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
components: z.array(z.string().min(1)).min(1),
|
|
51
|
+
domains: z.array(RendererDomainSchema).min(1),
|
|
52
|
+
manifestHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
/** Builds the canonical renderer manifest for a component list. */
|
|
56
|
+
export function createRendererManifest(components = ALLOWED_COMPONENTS, domains = ["materials", "exercises"]) {
|
|
57
|
+
const sortedComponents = [...new Set(components)].sort();
|
|
58
|
+
const sortedDomains = [...new Set(domains)].sort();
|
|
59
|
+
return {
|
|
60
|
+
components: sortedComponents,
|
|
61
|
+
domains: sortedDomains,
|
|
62
|
+
manifestHash: computeRendererManifestHash(sortedComponents),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Error raised when an artifact requires a component absent from the live renderer manifest. */
|
|
66
|
+
export class RendererCompatibilityError extends Error {
|
|
67
|
+
missingComponents;
|
|
68
|
+
contentKey;
|
|
69
|
+
constructor(missingComponents, contentKey) {
|
|
70
|
+
super(`Renderer compatibility mismatch${contentKey ? ` for '${contentKey}'` : ""}: ` +
|
|
71
|
+
`Artifact requires unsupported components: [${missingComponents.join(", ")}]. ` +
|
|
72
|
+
`Web renderer manifest does not support these components.`);
|
|
73
|
+
this.missingComponents = missingComponents;
|
|
74
|
+
this.contentKey = contentKey;
|
|
75
|
+
this.name = "RendererCompatibilityError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Verifies that every component required by an artifact is supported by the
|
|
80
|
+
* given renderer component whitelist (defaults to canonical ALLOWED_COMPONENTS).
|
|
81
|
+
*/
|
|
82
|
+
export function assertRendererCompatibility(requiredComponents, contentKey, supportedComponents = ALLOWED_COMPONENTS) {
|
|
83
|
+
const supported = supportedComponents === ALLOWED_COMPONENTS
|
|
84
|
+
? ALLOWED_COMPONENTS_SET
|
|
85
|
+
: new Set(supportedComponents);
|
|
86
|
+
const unsupported = requiredComponents.filter((name) => !supported.has(name));
|
|
87
|
+
if (unsupported.length > 0) {
|
|
88
|
+
throw new RendererCompatibilityError(unsupported, contentKey);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Proves directional compatibility (ADR 0002): the live renderer must support
|
|
93
|
+
* every domain and every component declared by a frozen manifest.
|
|
94
|
+
*/
|
|
95
|
+
export function isRendererSuperset(live, frozen) {
|
|
96
|
+
const liveDomains = new Set(live.domains);
|
|
97
|
+
const liveComponents = new Set(live.components);
|
|
98
|
+
return (frozen.domains.every((domain) => liveDomains.has(domain)) &&
|
|
99
|
+
frozen.components.every((component) => liveComponents.has(component)));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sour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,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEnC,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,0BAA0B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAsB,EACtB,MAAwB;IAExB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS,IAAI,CAAC,UAAU,CAAC,CAAC;IACxD,OAAO,CACL,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CACtE,CAAC;AACJ,CAAC"}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** Key that only an element may carry, so a plain JSON object can never imitate one. */
|
|
4
|
+
export declare const ELEMENT_KEY: "$node";
|
|
5
|
+
/** Name of the element that renders its children without an element of its own. */
|
|
6
|
+
export declare const FRAGMENT_NAME: "fragment";
|
|
7
|
+
/** Renderer components are capitalized JSX names, never intrinsic tags. */
|
|
8
|
+
export declare const COMPONENT_NAME_PATTERN: RegExp;
|
|
9
|
+
/** Intrinsic HTML tags that the Markdown and MDX pipeline may emit, in code-unit order. */
|
|
10
|
+
export declare const CONTENT_TREE_INTRINSIC_TAGS: readonly ["a", "blockquote", "br", "caption", "code", "col", "colgroup", "dd", "del", "details", "div", "dl", "dt", "em", "figcaption", "figure", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "img", "input", "kbd", "li", "mark", "ol", "p", "pre", "s", "section", "small", "span", "strong", "sub", "summary", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "u", "ul"];
|
|
11
|
+
export type ContentTreeIntrinsicTag = (typeof CONTENT_TREE_INTRINSIC_TAGS)[number];
|
|
12
|
+
export declare function isContentTreeIntrinsicTag(name: string): name is ContentTreeIntrinsicTag;
|
|
13
|
+
/** The element name of one tree node: the fragment, an intrinsic tag, or a renderer component. */
|
|
14
|
+
export type ContentTreeElementName = typeof FRAGMENT_NAME | ContentTreeIntrinsicTag | string;
|
|
15
|
+
/**
|
|
16
|
+
* A value a prop or a list may hold: JSON data, an element of the tree, or a
|
|
17
|
+
* plain JSON object whose values are tree values.
|
|
18
|
+
*/
|
|
19
|
+
export type ContentTreeValue = null | boolean | number | string | readonly ContentTreeValue[] | {
|
|
20
|
+
readonly $node: "element";
|
|
21
|
+
readonly children: readonly ContentTreeChild[];
|
|
22
|
+
readonly name: ContentTreeElementName;
|
|
23
|
+
readonly props: {
|
|
24
|
+
readonly [key: string]: ContentTreeValue;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
readonly [key: string]: ContentTreeValue;
|
|
28
|
+
};
|
|
29
|
+
/** One rendered node: its name, its props, and its ordered children. */
|
|
30
|
+
export type ContentTreeElement = Extract<ContentTreeValue, {
|
|
31
|
+
readonly $node: "element";
|
|
32
|
+
}>;
|
|
33
|
+
/** Named props of one element, each a JSON value or an element of the tree. */
|
|
34
|
+
export type ContentTreeProps = ContentTreeElement["props"];
|
|
35
|
+
/** Text, or one element in the order React would render it. */
|
|
36
|
+
export type ContentTreeChild = string | ContentTreeElement;
|
|
37
|
+
/** Checks whether a string is a valid element name in a content tree. */
|
|
38
|
+
export declare function isValidContentTreeElementName(name: string): boolean;
|
|
39
|
+
/** Zod schema for ContentTreeElementName */
|
|
40
|
+
export declare const ContentTreeElementNameZodSchema: z.ZodString;
|
|
41
|
+
/** Recursive Zod schema for ContentTreeValue */
|
|
42
|
+
export declare const ContentTreeValueZodSchema: z.ZodType<ContentTreeValue>;
|
|
43
|
+
/** Recursive Zod schema for ContentTreeProps */
|
|
44
|
+
export declare const ContentTreePropsZodSchema: z.ZodType<ContentTreeProps>;
|
|
45
|
+
/** Recursive Zod schema for ContentTreeChild */
|
|
46
|
+
export declare const ContentTreeChildZodSchema: z.ZodType<ContentTreeChild>;
|
|
47
|
+
/** Zod schema for any ContentTreeElement */
|
|
48
|
+
export declare const ContentTreeElementZodSchema: z.ZodType<ContentTreeElement>;
|
|
49
|
+
/** Zod schema for root ContentTree (must be a fragment) */
|
|
50
|
+
export declare const ContentTreeZodSchema: z.ZodType<ContentTreeElement>;
|
|
51
|
+
/** Effect Schema for ContentTreeElement */
|
|
52
|
+
export declare const ContentTreeElementSchema: Schema.Schema<ContentTreeElement>;
|
|
53
|
+
/** The signed content tree: the fragment that the web renderer draws with its component map. */
|
|
54
|
+
export declare const ContentTreeSchema: Schema.filter<Schema.Schema<{
|
|
55
|
+
readonly $node: "element";
|
|
56
|
+
readonly children: readonly ContentTreeChild[];
|
|
57
|
+
readonly name: ContentTreeElementName;
|
|
58
|
+
readonly props: {
|
|
59
|
+
readonly [key: string]: ContentTreeValue;
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
readonly $node: "element";
|
|
63
|
+
readonly children: readonly ContentTreeChild[];
|
|
64
|
+
readonly name: ContentTreeElementName;
|
|
65
|
+
readonly props: {
|
|
66
|
+
readonly [key: string]: ContentTreeValue;
|
|
67
|
+
};
|
|
68
|
+
}, never>>;
|
|
69
|
+
/** Checks whether a tree value is an element rather than JSON data. */
|
|
70
|
+
export declare function isContentTreeElement(value: ContentTreeValue): value is ContentTreeElement;
|
|
71
|
+
/** Serializes the tree as the exact JSON text that hashes and signatures cover. */
|
|
72
|
+
export declare function canonicalizeContentTree(tree: ContentTreeElement): string;
|
|
73
|
+
/** Checks whether an element name is a renderer component, not the fragment or an intrinsic tag. */
|
|
74
|
+
export declare function isComponentElementName(name: ContentTreeElementName): boolean;
|
|
75
|
+
/** Lists the renderer components that one tree uses, once each, in first-use order. */
|
|
76
|
+
export declare function contentTreeComponentNames(tree: ContentTreeElement): readonly string[];
|
|
77
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wFAAwF;AACxF,eAAO,MAAM,WAAW,EAAG,OAAgB,CAAC;AAE5C,mFAAmF;AACnF,eAAO,MAAM,aAAa,EAAG,UAAmB,CAAC;AAEjD,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAE9D,2FAA2F;AAC3F,eAAO,MAAM,2BAA2B,yXAiD9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAInF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,uBAAuB,CAEvF;AAED,kGAAkG;AAClG,MAAM,MAAM,sBAAsB,GAC9B,OAAO,aAAa,GACpB,uBAAuB,GACvB,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,gBAAgB,EAAE,GAC3B;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE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BA7GR,SAAS;uBACN,SAAS,gBAAgB,EAAE;mBAC/B,sBAAsB;oBACrB;QAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;KAAE;;oBAH5C,SAAS;uBACN,SAAS,gBAAgB,EAAE;mBAC/B,sBAAsB;oBACrB;QAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;KAAE;UA8GjE,CAAC;AAUF,uEAAuE;AACvE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,GACtB,KAAK,IAAI,kBAAkB,CAO7B;AAwDD,mFAAmF;AACnF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAExE;AAED,oGAAoG;AACpG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAE5E;AA8BD,uFAAuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,kBAAkB,GACvB,SAAS,MAAM,EAAE,CAEnB"}
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Array as Arr, Order, Predicate, Record as Rec, Schema } from "effect";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** Key that only an element may carry, so a plain JSON object can never imitate one. */
|
|
4
|
+
export const ELEMENT_KEY = "$node";
|
|
5
|
+
/** Name of the element that renders its children without an element of its own. */
|
|
6
|
+
export const FRAGMENT_NAME = "fragment";
|
|
7
|
+
/** Renderer components are capitalized JSX names, never intrinsic tags. */
|
|
8
|
+
export const COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9_]*$/u;
|
|
9
|
+
/** Intrinsic HTML tags that the Markdown and MDX pipeline may emit, in code-unit order. */
|
|
10
|
+
export const CONTENT_TREE_INTRINSIC_TAGS = [
|
|
11
|
+
"a",
|
|
12
|
+
"blockquote",
|
|
13
|
+
"br",
|
|
14
|
+
"caption",
|
|
15
|
+
"code",
|
|
16
|
+
"col",
|
|
17
|
+
"colgroup",
|
|
18
|
+
"dd",
|
|
19
|
+
"del",
|
|
20
|
+
"details",
|
|
21
|
+
"div",
|
|
22
|
+
"dl",
|
|
23
|
+
"dt",
|
|
24
|
+
"em",
|
|
25
|
+
"figcaption",
|
|
26
|
+
"figure",
|
|
27
|
+
"h1",
|
|
28
|
+
"h2",
|
|
29
|
+
"h3",
|
|
30
|
+
"h4",
|
|
31
|
+
"h5",
|
|
32
|
+
"h6",
|
|
33
|
+
"hr",
|
|
34
|
+
"img",
|
|
35
|
+
"input",
|
|
36
|
+
"kbd",
|
|
37
|
+
"li",
|
|
38
|
+
"mark",
|
|
39
|
+
"ol",
|
|
40
|
+
"p",
|
|
41
|
+
"pre",
|
|
42
|
+
"s",
|
|
43
|
+
"section",
|
|
44
|
+
"small",
|
|
45
|
+
"span",
|
|
46
|
+
"strong",
|
|
47
|
+
"sub",
|
|
48
|
+
"summary",
|
|
49
|
+
"sup",
|
|
50
|
+
"table",
|
|
51
|
+
"tbody",
|
|
52
|
+
"td",
|
|
53
|
+
"tfoot",
|
|
54
|
+
"th",
|
|
55
|
+
"thead",
|
|
56
|
+
"tr",
|
|
57
|
+
"u",
|
|
58
|
+
"ul",
|
|
59
|
+
];
|
|
60
|
+
const INTRINSIC_TAG_SET = new Set(CONTENT_TREE_INTRINSIC_TAGS);
|
|
61
|
+
export function isContentTreeIntrinsicTag(name) {
|
|
62
|
+
return INTRINSIC_TAG_SET.has(name);
|
|
63
|
+
}
|
|
64
|
+
/** Checks whether a string is a valid element name in a content tree. */
|
|
65
|
+
export function isValidContentTreeElementName(name) {
|
|
66
|
+
return (name === FRAGMENT_NAME ||
|
|
67
|
+
isContentTreeIntrinsicTag(name) ||
|
|
68
|
+
COMPONENT_NAME_PATTERN.test(name));
|
|
69
|
+
}
|
|
70
|
+
/** Zod schema for ContentTreeElementName */
|
|
71
|
+
export const ContentTreeElementNameZodSchema = z
|
|
72
|
+
.string()
|
|
73
|
+
.refine(isValidContentTreeElementName, {
|
|
74
|
+
message: "Expected 'fragment', an allowed intrinsic HTML tag, or a capitalized renderer component name.",
|
|
75
|
+
});
|
|
76
|
+
/** Recursive Zod schema for ContentTreeValue */
|
|
77
|
+
export const ContentTreeValueZodSchema = z.lazy(() => z.union([
|
|
78
|
+
z.null(),
|
|
79
|
+
z.boolean(),
|
|
80
|
+
z.number().refine(Number.isFinite, { message: "Expected finite number" }),
|
|
81
|
+
z.string(),
|
|
82
|
+
z.array(ContentTreeValueZodSchema),
|
|
83
|
+
ContentTreeElementZodSchema,
|
|
84
|
+
ContentTreePropsZodSchema,
|
|
85
|
+
]));
|
|
86
|
+
/** Recursive Zod schema for ContentTreeProps */
|
|
87
|
+
export const ContentTreePropsZodSchema = z.lazy(() => z
|
|
88
|
+
.record(z.string(), ContentTreeValueZodSchema)
|
|
89
|
+
.refine((props) => !Object.prototype.hasOwnProperty.call(props, ELEMENT_KEY), {
|
|
90
|
+
message: "Expected props without the reserved element key '$node'.",
|
|
91
|
+
}));
|
|
92
|
+
/** Recursive Zod schema for ContentTreeChild */
|
|
93
|
+
export const ContentTreeChildZodSchema = z.lazy(() => z.union([z.string(), ContentTreeElementZodSchema]));
|
|
94
|
+
/** Zod schema for any ContentTreeElement */
|
|
95
|
+
export const ContentTreeElementZodSchema = z.lazy(() => z.object({
|
|
96
|
+
$node: z.literal("element"),
|
|
97
|
+
name: ContentTreeElementNameZodSchema,
|
|
98
|
+
props: ContentTreePropsZodSchema,
|
|
99
|
+
children: z.array(ContentTreeChildZodSchema),
|
|
100
|
+
}));
|
|
101
|
+
/** Zod schema for root ContentTree (must be a fragment) */
|
|
102
|
+
export const ContentTreeZodSchema = ContentTreeElementZodSchema.refine((tree) => tree.name === FRAGMENT_NAME, {
|
|
103
|
+
message: "Expected the fragment as the content tree root.",
|
|
104
|
+
});
|
|
105
|
+
/** Effect Schema for ContentTreeElement */
|
|
106
|
+
export const ContentTreeElementSchema = Schema.suspend(() => Schema.Struct({
|
|
107
|
+
$node: Schema.Literal("element"),
|
|
108
|
+
children: Schema.Array(Schema.Union(Schema.String, ContentTreeElementSchema)),
|
|
109
|
+
name: Schema.String.pipe(Schema.filter(isValidContentTreeElementName, {
|
|
110
|
+
message: () => "Expected 'fragment', an allowed intrinsic HTML tag, or a capitalized renderer component name.",
|
|
111
|
+
})),
|
|
112
|
+
props: Schema.Record({
|
|
113
|
+
key: Schema.String,
|
|
114
|
+
value: Schema.Unknown,
|
|
115
|
+
}).pipe(Schema.filter((props) => !Predicate.hasProperty(props, ELEMENT_KEY), {
|
|
116
|
+
message: () => "Expected props without the reserved element key.",
|
|
117
|
+
})),
|
|
118
|
+
}));
|
|
119
|
+
/** The signed content tree: the fragment that the web renderer draws with its component map. */
|
|
120
|
+
export const ContentTreeSchema = ContentTreeElementSchema.pipe(Schema.filter((tree) => tree.name === FRAGMENT_NAME, {
|
|
121
|
+
message: () => "Expected the fragment as the content tree root.",
|
|
122
|
+
}));
|
|
123
|
+
/** Encodes a primitive or string value as standard JSON text, normalizing -0 to 0. */
|
|
124
|
+
function encodeJsonText(value) {
|
|
125
|
+
if (typeof value === "number" && Object.is(value, -0)) {
|
|
126
|
+
return "0";
|
|
127
|
+
}
|
|
128
|
+
return JSON.stringify(value);
|
|
129
|
+
}
|
|
130
|
+
/** Checks whether a tree value is an element rather than JSON data. */
|
|
131
|
+
export function isContentTreeElement(value) {
|
|
132
|
+
return (Predicate.isObject(value) &&
|
|
133
|
+
!Arr.isArray(value) &&
|
|
134
|
+
Predicate.hasProperty(value, ELEMENT_KEY) &&
|
|
135
|
+
value.$node === "element");
|
|
136
|
+
}
|
|
137
|
+
/** Checks whether a tree value is a list of tree values. */
|
|
138
|
+
function isList(value) {
|
|
139
|
+
return Arr.isArray(value);
|
|
140
|
+
}
|
|
141
|
+
/** Checks whether a tree value is a plain props object. */
|
|
142
|
+
function isProps(value) {
|
|
143
|
+
return Predicate.isObject(value) && !Arr.isArray(value);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Writes one props object as JSON text with its keys in code-unit order. The
|
|
147
|
+
* text is assembled by hand, so no formatter or key sort can change its bytes.
|
|
148
|
+
*/
|
|
149
|
+
function canonicalPropsText(props) {
|
|
150
|
+
const entries = Arr.sortWith(Rec.toEntries(props), ([key]) => key, Order.string);
|
|
151
|
+
const texts = Arr.map(entries, ([key, value]) => `${encodeJsonText(key)}:${canonicalValueText(value)}`);
|
|
152
|
+
return `{${Arr.join(texts, ",")}}`;
|
|
153
|
+
}
|
|
154
|
+
/** Writes one tree value as JSON text in the one canonical form. */
|
|
155
|
+
function canonicalValueText(value) {
|
|
156
|
+
if (isContentTreeElement(value)) {
|
|
157
|
+
return canonicalElementText(value);
|
|
158
|
+
}
|
|
159
|
+
if (isList(value)) {
|
|
160
|
+
return `[${Arr.join(Arr.map(value, canonicalValueText), ",")}]`;
|
|
161
|
+
}
|
|
162
|
+
if (isProps(value)) {
|
|
163
|
+
return canonicalPropsText(value);
|
|
164
|
+
}
|
|
165
|
+
return encodeJsonText(value);
|
|
166
|
+
}
|
|
167
|
+
/** Writes one element as JSON text with its fields in the declared order. */
|
|
168
|
+
function canonicalElementText(element) {
|
|
169
|
+
const children = Arr.join(Arr.map(element.children, (child) => typeof child === "string"
|
|
170
|
+
? encodeJsonText(child)
|
|
171
|
+
: canonicalElementText(child)), ",");
|
|
172
|
+
return `{"$node":"element","name":${encodeJsonText(element.name)},"props":${canonicalPropsText(element.props)},"children":[${children}]}`;
|
|
173
|
+
}
|
|
174
|
+
/** Serializes the tree as the exact JSON text that hashes and signatures cover. */
|
|
175
|
+
export function canonicalizeContentTree(tree) {
|
|
176
|
+
return canonicalElementText(tree);
|
|
177
|
+
}
|
|
178
|
+
/** Checks whether an element name is a renderer component, not the fragment or an intrinsic tag. */
|
|
179
|
+
export function isComponentElementName(name) {
|
|
180
|
+
return name !== FRAGMENT_NAME && !isContentTreeIntrinsicTag(name);
|
|
181
|
+
}
|
|
182
|
+
/** Collects the component names of one element and of every element nested beneath it. */
|
|
183
|
+
function componentNamesOfElement(element) {
|
|
184
|
+
const own = isComponentElementName(element.name) ? [element.name] : [];
|
|
185
|
+
return [
|
|
186
|
+
...own,
|
|
187
|
+
...Arr.flatMap(element.children, (child) => typeof child === "string" ? [] : componentNamesOfElement(child)),
|
|
188
|
+
...Arr.flatMap(Object.values(element.props), componentNamesOfValue),
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
/** Collects the component names of one prop value, which may hold lists, objects, and elements. */
|
|
192
|
+
function componentNamesOfValue(value) {
|
|
193
|
+
if (isContentTreeElement(value)) {
|
|
194
|
+
return componentNamesOfElement(value);
|
|
195
|
+
}
|
|
196
|
+
if (isList(value)) {
|
|
197
|
+
return Arr.flatMap(value, componentNamesOfValue);
|
|
198
|
+
}
|
|
199
|
+
if (isProps(value)) {
|
|
200
|
+
return Arr.flatMap(Object.values(value), componentNamesOfValue);
|
|
201
|
+
}
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
/** Lists the renderer components that one tree uses, once each, in first-use order. */
|
|
205
|
+
export function contentTreeComponentNames(tree) {
|
|
206
|
+
return Arr.dedupe(componentNamesOfElement(tree));
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=tree.js.map
|
package/dist/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,OAAgB,CAAC;AAE5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,UAAmB,CAAC;AAEjD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB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
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Signed content-tree, renderer manifest, and release wire contracts shared between Pustaka and SME Clone.",
|
|
7
|
+
"homepage": "https://github.com/shoklan14/pustaka#readme",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"provenance": true
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/shoklan14/pustaka.git",
|
|
15
|
+
"directory": "packages/contracts"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.0.0"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"pustaka-source": "./src/index.ts",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./contracts": {
|
|
29
|
+
"pustaka-source": "./src/contracts.ts",
|
|
30
|
+
"types": "./dist/contracts.d.ts",
|
|
31
|
+
"import": "./dist/contracts.js"
|
|
32
|
+
},
|
|
33
|
+
"./corpus": {
|
|
34
|
+
"pustaka-source": "./src/corpus.ts",
|
|
35
|
+
"types": "./dist/corpus.d.ts",
|
|
36
|
+
"import": "./dist/corpus.js"
|
|
37
|
+
},
|
|
38
|
+
"./crypto": {
|
|
39
|
+
"pustaka-source": "./src/crypto.ts",
|
|
40
|
+
"types": "./dist/crypto.d.ts",
|
|
41
|
+
"import": "./dist/crypto.js"
|
|
42
|
+
},
|
|
43
|
+
"./renderer": {
|
|
44
|
+
"pustaka-source": "./src/renderer.ts",
|
|
45
|
+
"types": "./dist/renderer.d.ts",
|
|
46
|
+
"import": "./dist/renderer.js"
|
|
47
|
+
},
|
|
48
|
+
"./tree": {
|
|
49
|
+
"pustaka-source": "./src/tree.ts",
|
|
50
|
+
"types": "./dist/tree.d.ts",
|
|
51
|
+
"import": "./dist/tree.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
60
|
+
"prepack": "bun run build",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"effect": "^3.19.14",
|
|
65
|
+
"zod": "^4.3.5"
|
|
66
|
+
}
|
|
67
|
+
}
|