deltafold 0.0.0 → 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 +278 -4
- package/dist/changelog.d.ts +116 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/changelog.js +304 -0
- package/dist/changelog.js.map +1 -0
- package/dist/document-BZcZo9nr.js +171 -0
- package/dist/document-BZcZo9nr.js.map +1 -0
- package/dist/document-DWHsgywm.d.ts +257 -0
- package/dist/document-DWHsgywm.d.ts.map +1 -0
- package/dist/html.d.ts +8 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +13 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +517 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2126 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +8 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +16 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mdast-DiRsYwPU.js +108 -0
- package/dist/mdast-DiRsYwPU.js.map +1 -0
- package/dist/package-BfBYnaCz.d.ts +1125 -0
- package/dist/package-BfBYnaCz.d.ts.map +1 -0
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/package.json +13 -1
- package/src/features/documents/changelog.ts +450 -0
- package/src/features/documents/document.ts +357 -0
- package/src/features/documents/index.ts +4 -0
- package/src/features/documents/public-document.ts +31 -0
- package/src/features/documents/sections.ts +44 -0
- package/src/features/execution/executor.ts +968 -0
- package/src/features/execution/handler.ts +485 -0
- package/src/features/execution/settlement.ts +52 -0
- package/src/features/package.ts +32 -0
- package/src/features/planning/guide.ts +56 -0
- package/src/features/planning/history.ts +174 -0
- package/src/features/planning/identifiers.ts +43 -0
- package/src/features/planning/resolve-error.ts +201 -0
- package/src/features/planning/resolve.ts +724 -0
- package/src/features/planning/rewrite.ts +331 -0
- package/src/features/planning/validate.ts +388 -0
- package/src/foundation/action.ts +188 -0
- package/src/foundation/change.ts +147 -0
- package/src/foundation/instruction.ts +110 -0
- package/src/foundation/migration.ts +236 -0
- package/src/foundation/plan.ts +245 -0
- package/src/foundation/rule.ts +74 -0
- package/src/foundation/shortcut.ts +79 -0
- package/src/foundation/template.ts +28 -0
- package/src/foundation/version.ts +78 -0
- package/src/index.ts +22 -11
- package/src/renderers/html.ts +12 -0
- package/src/renderers/markdown.ts +12 -0
- package/src/renderers/mdast.ts +120 -0
- package/src/types.ts +2 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { i as DocumentError } from "./document-BZcZo9nr.js";
|
|
2
|
+
import { normalizeUri, sanitizeUri } from "micromark-util-sanitize-uri";
|
|
3
|
+
// src/renderers/mdast.ts
|
|
4
|
+
/** Link schemes kept in rendered output. Relative URLs are always kept. */
|
|
5
|
+
const safeSchemes = /^(https?|mailto)$/i;
|
|
6
|
+
/**
|
|
7
|
+
* Keeps a URL whose scheme is allowed, and replaces any other URL with an empty one.
|
|
8
|
+
* `sanitizeUri` also HTML-escapes its result, which the serializers would escape again,
|
|
9
|
+
* so only its scheme check is used here.
|
|
10
|
+
*/
|
|
11
|
+
const safeUrl = (url) => sanitizeUri(url, safeSchemes) === "" ? "" : normalizeUri(url);
|
|
12
|
+
const maximumLevel = 6;
|
|
13
|
+
const isDepth = (level) => Number.isInteger(level) && level >= 1 && level <= maximumLevel;
|
|
14
|
+
const lowerInline = (value) => {
|
|
15
|
+
switch (value._tag) {
|
|
16
|
+
case "Text": return {
|
|
17
|
+
type: "text",
|
|
18
|
+
value: value.value
|
|
19
|
+
};
|
|
20
|
+
case "Code": return {
|
|
21
|
+
type: "inlineCode",
|
|
22
|
+
value: value.value
|
|
23
|
+
};
|
|
24
|
+
case "Link": return {
|
|
25
|
+
type: "link",
|
|
26
|
+
url: safeUrl(value.url),
|
|
27
|
+
children: value.children.map(lowerInline)
|
|
28
|
+
};
|
|
29
|
+
case "Strong": return {
|
|
30
|
+
type: "strong",
|
|
31
|
+
children: value.children.map(lowerInline)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
type: "emphasis",
|
|
36
|
+
children: value.children.map(lowerInline)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const lowerBlocks = (blocks, depth, scope) => blocks.flatMap((block) => {
|
|
40
|
+
switch (block._tag) {
|
|
41
|
+
case "Paragraph": return [{
|
|
42
|
+
type: "paragraph",
|
|
43
|
+
children: block.children.map(lowerInline)
|
|
44
|
+
}];
|
|
45
|
+
case "CodeBlock": return [{
|
|
46
|
+
type: "code",
|
|
47
|
+
value: block.value,
|
|
48
|
+
lang: block.lang ?? null
|
|
49
|
+
}];
|
|
50
|
+
case "List": return [{
|
|
51
|
+
type: "list",
|
|
52
|
+
ordered: block.ordered,
|
|
53
|
+
spread: false,
|
|
54
|
+
children: block.items.map((item) => ({
|
|
55
|
+
type: "listItem",
|
|
56
|
+
spread: false,
|
|
57
|
+
children: lowerBlocks(item, depth, scope)
|
|
58
|
+
}))
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
if (scope.ids.has(block.id)) throw new DocumentError({
|
|
62
|
+
reason: "duplicate-section",
|
|
63
|
+
message: `Section "${block.id}" appears more than once in ${scope.label}.`
|
|
64
|
+
});
|
|
65
|
+
scope.ids.add(block.id);
|
|
66
|
+
const inner = block.release === void 0 ? scope : {
|
|
67
|
+
ids: /* @__PURE__ */ new Set(),
|
|
68
|
+
label: `release "${block.release.id}"`
|
|
69
|
+
};
|
|
70
|
+
if (block.title === void 0) return [
|
|
71
|
+
...lowerBlocks(block.before, depth, inner),
|
|
72
|
+
...lowerBlocks(block.after, depth, inner),
|
|
73
|
+
...lowerBlocks(block.children, depth, inner)
|
|
74
|
+
];
|
|
75
|
+
const level = block.title.level ?? depth;
|
|
76
|
+
if (!isDepth(level)) throw new DocumentError({
|
|
77
|
+
reason: "heading-level",
|
|
78
|
+
message: `Section "${block.id}" needs heading level ${level}, but levels range from 1 to ${maximumLevel}.`
|
|
79
|
+
});
|
|
80
|
+
return [
|
|
81
|
+
...lowerBlocks(block.before, level + 1, inner),
|
|
82
|
+
{
|
|
83
|
+
type: "heading",
|
|
84
|
+
depth: level,
|
|
85
|
+
children: block.title.children.map(lowerInline)
|
|
86
|
+
},
|
|
87
|
+
...lowerBlocks(block.after, level + 1, inner),
|
|
88
|
+
...lowerBlocks(block.children, level + 1, inner)
|
|
89
|
+
];
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Lowers a document to an mdast root. Untitled sections contribute only their content,
|
|
93
|
+
* and titled sections get the next heading level unless their title sets one. Link URLs
|
|
94
|
+
* with a scheme other than http, https, or mailto become empty.
|
|
95
|
+
*
|
|
96
|
+
* Throws `DocumentError` when a section identifier repeats within the document or within
|
|
97
|
+
* one release, or when a heading level falls outside 1 to 6.
|
|
98
|
+
*/
|
|
99
|
+
const toMdast = (document) => ({
|
|
100
|
+
type: "root",
|
|
101
|
+
children: lowerBlocks(document.children, 1, {
|
|
102
|
+
ids: /* @__PURE__ */ new Set(),
|
|
103
|
+
label: "the document"
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
export { toMdast as t };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=mdast-DiRsYwPU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdast-DiRsYwPU.js","names":[],"sources":["../src/renderers/mdast.ts"],"sourcesContent":["import type * as Mdast from \"mdast\";\nimport { normalizeUri, sanitizeUri } from \"micromark-util-sanitize-uri\";\n\nimport {\n\tDocumentError,\n\ttype Block,\n\ttype Document,\n\ttype Inline,\n} from \"../features/documents/document.ts\";\n\n/** Link schemes kept in rendered output. Relative URLs are always kept. */\nconst safeSchemes = /^(https?|mailto)$/i;\n\n/**\n * Keeps a URL whose scheme is allowed, and replaces any other URL with an empty one.\n * `sanitizeUri` also HTML-escapes its result, which the serializers would escape again,\n * so only its scheme check is used here.\n */\nconst safeUrl = (url: string) => (sanitizeUri(url, safeSchemes) === \"\" ? \"\" : normalizeUri(url));\n\nconst maximumLevel = 6;\n\nconst isDepth = (level: number): level is Mdast.Heading[\"depth\"] =>\n\tNumber.isInteger(level) && level >= 1 && level <= maximumLevel;\n\nconst lowerInline = (value: Inline): Mdast.PhrasingContent => {\n\tswitch (value._tag) {\n\t\tcase \"Text\":\n\t\t\treturn { type: \"text\", value: value.value };\n\t\tcase \"Code\":\n\t\t\treturn { type: \"inlineCode\", value: value.value };\n\t\tcase \"Link\":\n\t\t\treturn {\n\t\t\t\ttype: \"link\",\n\t\t\t\turl: safeUrl(value.url),\n\t\t\t\tchildren: value.children.map(lowerInline),\n\t\t\t};\n\t\tcase \"Strong\":\n\t\t\treturn { type: \"strong\", children: value.children.map(lowerInline) };\n\t}\n\n\treturn { type: \"emphasis\", children: value.children.map(lowerInline) };\n};\n\ntype Scope = { readonly ids: Set<string>; readonly label: string };\n\nconst lowerBlocks = (\n\tblocks: ReadonlyArray<Block>,\n\tdepth: number,\n\tscope: Scope,\n): Array<Mdast.BlockContent> =>\n\tblocks.flatMap((block): Array<Mdast.BlockContent> => {\n\t\tswitch (block._tag) {\n\t\t\tcase \"Paragraph\":\n\t\t\t\treturn [{ type: \"paragraph\", children: block.children.map(lowerInline) }];\n\t\t\tcase \"CodeBlock\":\n\t\t\t\treturn [{ type: \"code\", value: block.value, lang: block.lang ?? null }];\n\t\t\tcase \"List\":\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"list\",\n\t\t\t\t\t\tordered: block.ordered,\n\t\t\t\t\t\tspread: false,\n\t\t\t\t\t\tchildren: block.items.map((item) => ({\n\t\t\t\t\t\t\ttype: \"listItem\",\n\t\t\t\t\t\t\tspread: false,\n\t\t\t\t\t\t\tchildren: lowerBlocks(item, depth, scope),\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t}\n\n\t\tif (scope.ids.has(block.id)) {\n\t\t\tthrow new DocumentError({\n\t\t\t\treason: \"duplicate-section\",\n\t\t\t\tmessage: `Section \"${block.id}\" appears more than once in ${scope.label}.`,\n\t\t\t});\n\t\t}\n\t\tscope.ids.add(block.id);\n\t\tconst inner =\n\t\t\tblock.release === undefined\n\t\t\t\t? scope\n\t\t\t\t: { ids: new Set<string>(), label: `release \"${block.release.id}\"` };\n\n\t\tif (block.title === undefined) {\n\t\t\treturn [\n\t\t\t\t...lowerBlocks(block.before, depth, inner),\n\t\t\t\t...lowerBlocks(block.after, depth, inner),\n\t\t\t\t...lowerBlocks(block.children, depth, inner),\n\t\t\t];\n\t\t}\n\n\t\tconst level = block.title.level ?? depth;\n\t\tif (!isDepth(level)) {\n\t\t\tthrow new DocumentError({\n\t\t\t\treason: \"heading-level\",\n\t\t\t\tmessage: `Section \"${block.id}\" needs heading level ${level}, but levels range from 1 to ${maximumLevel}.`,\n\t\t\t});\n\t\t}\n\n\t\treturn [\n\t\t\t...lowerBlocks(block.before, level + 1, inner),\n\t\t\t{ type: \"heading\", depth: level, children: block.title.children.map(lowerInline) },\n\t\t\t...lowerBlocks(block.after, level + 1, inner),\n\t\t\t...lowerBlocks(block.children, level + 1, inner),\n\t\t];\n\t});\n\n/**\n * Lowers a document to an mdast root. Untitled sections contribute only their content,\n * and titled sections get the next heading level unless their title sets one. Link URLs\n * with a scheme other than http, https, or mailto become empty.\n *\n * Throws `DocumentError` when a section identifier repeats within the document or within\n * one release, or when a heading level falls outside 1 to 6.\n */\nexport const toMdast = (document: Document): Mdast.Root => ({\n\ttype: \"root\",\n\tchildren: lowerBlocks(document.children, 1, { ids: new Set(), label: \"the document\" }),\n});\n"],"mappings":";;;;AAWA,MAAM,cAAc;;;;;;AAOpB,MAAM,WAAW,QAAiB,YAAY,KAAK,WAAW,MAAM,KAAK,KAAK,aAAa,GAAG;AAE9F,MAAM,eAAe;AAErB,MAAM,WAAW,UAChB,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS;AAEnD,MAAM,eAAe,UAAyC;CAC7D,QAAQ,MAAM,MAA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