deltafold 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +274 -4
  2. package/dist/changelog.d.ts +116 -0
  3. package/dist/changelog.d.ts.map +1 -0
  4. package/dist/changelog.js +304 -0
  5. package/dist/changelog.js.map +1 -0
  6. package/dist/document-BZcZo9nr.js +171 -0
  7. package/dist/document-BZcZo9nr.js.map +1 -0
  8. package/dist/document-DWHsgywm.d.ts +257 -0
  9. package/dist/document-DWHsgywm.d.ts.map +1 -0
  10. package/dist/html.d.ts +8 -0
  11. package/dist/html.d.ts.map +1 -0
  12. package/dist/html.js +13 -0
  13. package/dist/html.js.map +1 -0
  14. package/dist/index.d.ts +378 -1
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +2058 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/markdown.d.ts +8 -0
  19. package/dist/markdown.d.ts.map +1 -0
  20. package/dist/markdown.js +16 -0
  21. package/dist/markdown.js.map +1 -0
  22. package/dist/mdast-DiRsYwPU.js +108 -0
  23. package/dist/mdast-DiRsYwPU.js.map +1 -0
  24. package/dist/package-BfBYnaCz.d.ts +1125 -0
  25. package/dist/package-BfBYnaCz.d.ts.map +1 -0
  26. package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
  27. package/package.json +13 -1
  28. package/src/features/documents/changelog.ts +450 -0
  29. package/src/features/documents/document.ts +357 -0
  30. package/src/features/documents/index.ts +4 -0
  31. package/src/features/documents/public-document.ts +31 -0
  32. package/src/features/documents/sections.ts +44 -0
  33. package/src/features/execution/executor.ts +826 -0
  34. package/src/features/execution/handler.ts +257 -0
  35. package/src/features/execution/settlement.ts +49 -0
  36. package/src/features/package.ts +32 -0
  37. package/src/features/planning/guide.ts +56 -0
  38. package/src/features/planning/history.ts +174 -0
  39. package/src/features/planning/identifiers.ts +43 -0
  40. package/src/features/planning/resolve-error.ts +201 -0
  41. package/src/features/planning/resolve.ts +724 -0
  42. package/src/features/planning/rewrite.ts +331 -0
  43. package/src/features/planning/validate.ts +388 -0
  44. package/src/foundation/action.ts +188 -0
  45. package/src/foundation/change.ts +147 -0
  46. package/src/foundation/instruction.ts +110 -0
  47. package/src/foundation/migration.ts +236 -0
  48. package/src/foundation/plan.ts +245 -0
  49. package/src/foundation/rule.ts +74 -0
  50. package/src/foundation/shortcut.ts +79 -0
  51. package/src/foundation/template.ts +28 -0
  52. package/src/foundation/version.ts +78 -0
  53. package/src/index.ts +22 -11
  54. package/src/renderers/html.ts +12 -0
  55. package/src/renderers/markdown.ts +12 -0
  56. package/src/renderers/mdast.ts +120 -0
  57. package/src/types.ts +2 -0
@@ -0,0 +1,304 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
+ import { _ as append, a as Emphasis, b as withLevel, c as List, d as Release, f as Section, g as Title, h as Text, i as DocumentError, l as Paragraph, m as Strong, n as Code, o as History, p as SectionValue, r as CodeBlock, s as Link, t as Body, u as Plugin, v as generatedSection, x as withTitle, y as isBlock } from "./document-BZcZo9nr.js";
3
+ import { Array, Data, Order, Result, SemVer } from "effect";
4
+ // src/features/documents/sections.ts
5
+ /** Marks a section as the section of one release. */
6
+ const asRelease = (section, version) => new SectionValue({
7
+ ...section,
8
+ release: version
9
+ });
10
+ /** Inserts contributions in configuration order. Each anchor receives its blocks at once. */
11
+ const insertAll = (section, contributions) => {
12
+ const at = (part, position) => contributions.filter((contribution) => contribution.at.part === part && contribution.at.position === position).flatMap((contribution) => contribution.blocks);
13
+ return new SectionValue({
14
+ ...section,
15
+ before: [...section.before, ...at("title", "pre")],
16
+ after: [...section.after, ...at("title", "post")],
17
+ children: [
18
+ ...at("body", "pre"),
19
+ ...section.children,
20
+ ...at("body", "post")
21
+ ]
22
+ });
23
+ };
24
+ const blocksOf = (output) => {
25
+ if (output === null) return [];
26
+ if (isBlock(output)) return [output];
27
+ return output;
28
+ };
29
+ // src/features/documents/changelog.ts
30
+ var changelog_exports = /* @__PURE__ */ __exportAll({
31
+ ReleaseMetadataError: () => ReleaseMetadataError,
32
+ make: () => make,
33
+ section: () => section
34
+ });
35
+ /** @since @next */
36
+ const section = (id, options) => ({
37
+ _tag: "ChangelogSection",
38
+ id,
39
+ ...options
40
+ });
41
+ /**
42
+ * Release metadata does not match the package history.
43
+ *
44
+ * @since @next
45
+ */
46
+ var ReleaseMetadataError = class extends Data.TaggedError("ReleaseMetadataError") {};
47
+ const paragraphsOf = (text) => text.split(/\n\s*\n/).map((part) => part.replace(/\s*\n\s*/g, " ").trim()).filter((part) => part !== "").map((part) => Paragraph(part));
48
+ /**
49
+ * Selectors read metadata fields by name. Reading any field of an object yields a value
50
+ * or `undefined`, so viewing the metadata as fields of type `unknown` is sound.
51
+ */
52
+ const selectable = (change) => change;
53
+ const changeList = (changes) => List(changes.map((change) => paragraphsOf(change.description)));
54
+ const knows = (pkg, version) => pkg.history.versions.some((known) => known.id === version.id);
55
+ const releaseOrder = (versions) => {
56
+ if (!versions.map((version) => SemVer.parse(version.id)).every(Result.isSuccess)) return Array.reverse(versions);
57
+ return Array.sort(versions, Order.flip(Order.mapInput(SemVer.Order, (version) => SemVer.parseUnsafe(version.id))));
58
+ };
59
+ const occurrenceBlocks = (action, prose) => prose === void 0 ? [Paragraph(action.description)] : guideBlocks(prose);
60
+ /** Builds guide blocks: prose becomes paragraphs; groups become lists. */
61
+ const guideBlocks = (items) => {
62
+ const blocks = [];
63
+ let current = [];
64
+ const flush = () => {
65
+ const trimmed = trimInlines(current);
66
+ if (trimmed.length > 0) blocks.push(Paragraph(trimmed));
67
+ current = [];
68
+ };
69
+ for (const item of items) switch (item._tag) {
70
+ case "Text": {
71
+ const [first = "", ...rest] = item.text.split(/\n\s*\n/);
72
+ current.push(Text(first.replace(/\s*\n\s*/g, " ")));
73
+ for (const part of rest) {
74
+ flush();
75
+ current.push(Text(part.replace(/\s*\n\s*/g, " ")));
76
+ }
77
+ break;
78
+ }
79
+ case "ActionRef":
80
+ current.push(Text(item.action.description));
81
+ break;
82
+ case "Occurrence": {
83
+ const { action, instruction } = item.occurrence;
84
+ if (instruction === void 0 && trimInlines(current).length > 0) {
85
+ current.push(Text(action.description));
86
+ break;
87
+ }
88
+ flush();
89
+ blocks.push(...occurrenceBlocks(action, instruction?.content));
90
+ break;
91
+ }
92
+ case "Group":
93
+ flush();
94
+ blocks.push(List(item.children.map((child) => guideBlocks(child))));
95
+ }
96
+ flush();
97
+ return blocks;
98
+ };
99
+ const trimInlines = (values) => {
100
+ const result = values.flatMap((value) => value._tag === "Text" && value.value === "" ? [] : [value]);
101
+ const first = result[0];
102
+ const last = result.at(-1);
103
+ if (first?._tag === "Text") result[0] = Text(first.value.trimStart());
104
+ if (last?._tag === "Text") result[result.length - 1] = Text(last.value.trimEnd());
105
+ return result.flatMap((value) => value._tag === "Text" && value.value === "" ? [] : [value]);
106
+ };
107
+ const stepId = (step) => `deltafold/${step.direction === "forward" ? "step" : "revert"}/${step.migration.id}`;
108
+ /**
109
+ * Configures sections and plugins for changelog documents. Without `sections`, a release
110
+ * lists all of its changes in one "Changes" section.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const changelog = Changelog.make<ReleaseMetadata>({
115
+ * sections: [
116
+ * Changelog.section("breaking", {
117
+ * title: "Breaking changes",
118
+ * select: (change) => change.metadata.breaking === true,
119
+ * }),
120
+ * Changelog.section("fixes", {
121
+ * title: "Fixes",
122
+ * select: (change) => change.metadata.kind === "fixed",
123
+ * }),
124
+ * ],
125
+ * plugins: [contributorsPlugin],
126
+ * });
127
+ * Markdown.render(changelog.history(widgets, { releases: [release100, release200] }));
128
+ * ```
129
+ *
130
+ * @since @next
131
+ */
132
+ const make = (options = {}) => {
133
+ const sections = options.sections ?? [];
134
+ const plugins = options.plugins ?? [];
135
+ const other = options.other ?? { title: sections.length === 0 ? "Changes" : "Other changes" };
136
+ const changeSections = (changes) => {
137
+ const grouped = /* @__PURE__ */ new Map();
138
+ const unmatched = [];
139
+ for (const change of changes) {
140
+ const match = sections.find((definition) => definition.select(selectable(change)));
141
+ if (match === void 0) {
142
+ unmatched.push(change);
143
+ continue;
144
+ }
145
+ const list = grouped.get(match.id) ?? [];
146
+ list.push(change);
147
+ grouped.set(match.id, list);
148
+ }
149
+ const result = sections.flatMap((definition) => {
150
+ const matched = grouped.get(definition.id);
151
+ if (matched === void 0) return [];
152
+ return [Section(definition.id, {
153
+ title: definition.title,
154
+ children: [changeList(matched)]
155
+ })];
156
+ });
157
+ if (other !== false && unmatched.length > 0) result.push(generatedSection("deltafold/other", {
158
+ title: other.title,
159
+ children: [changeList(unmatched)]
160
+ }));
161
+ return result;
162
+ };
163
+ const releaseSection = (context) => {
164
+ const base = asRelease(generatedSection(`deltafold/release/${context.version.id}`, {
165
+ title: context.version.id,
166
+ children: changeSections(context.version.changes)
167
+ }), context.version);
168
+ return insertAll(base, plugins.flatMap((plugin) => plugin.scope === "release" ? [{
169
+ at: plugin.at,
170
+ blocks: blocksOf(plugin.resolve(context))
171
+ }] : []));
172
+ };
173
+ const requireKnown = (pkg, releases) => {
174
+ const unrelated = releases.flatMap((release) => knows(pkg, release.version) ? [] : [release.version.id]);
175
+ if (unrelated.length > 0) throw new ReleaseMetadataError({
176
+ reason: "unrelated",
177
+ versions: unrelated,
178
+ message: `Release metadata for ${unrelated.map((id) => `"${id}"`).join(", ")} does not belong to the history of "${pkg.name}".`
179
+ });
180
+ };
181
+ return {
182
+ sections,
183
+ plugins,
184
+ change: (input, changeOptions = {}) => {
185
+ const changes = Array.ensure(input);
186
+ return {
187
+ _tag: "Document",
188
+ kind: "change",
189
+ children: [generatedSection("deltafold/unreleased", {
190
+ title: changeOptions.title ?? "Unreleased",
191
+ children: changeSections(changes)
192
+ })]
193
+ };
194
+ },
195
+ release: (pkg, release) => {
196
+ requireKnown(pkg, [release]);
197
+ return {
198
+ _tag: "Document",
199
+ kind: "release",
200
+ children: [releaseSection({
201
+ package: pkg,
202
+ version: release.version,
203
+ metadata: release.metadata
204
+ })]
205
+ };
206
+ },
207
+ history: (pkg, historyOptions) => {
208
+ const { releases } = historyOptions;
209
+ requireKnown(pkg, releases);
210
+ const byVersion = /* @__PURE__ */ new Map();
211
+ const duplicates = /* @__PURE__ */ new Set();
212
+ for (const release of releases) {
213
+ if (byVersion.has(release.version.id)) duplicates.add(release.version.id);
214
+ byVersion.set(release.version.id, release);
215
+ }
216
+ if (duplicates.size > 0) throw new ReleaseMetadataError({
217
+ reason: "duplicate",
218
+ versions: [...duplicates],
219
+ message: `Release metadata is supplied more than once for ${[...duplicates].map((id) => `"${id}"`).join(", ")}.`
220
+ });
221
+ const included = historyOptions.versions ?? pkg.history.versions;
222
+ const missing = included.flatMap((version) => byVersion.has(version.id) ? [] : [version.id]);
223
+ if (missing.length > 0) throw new ReleaseMetadataError({
224
+ reason: "missing",
225
+ versions: missing,
226
+ message: `Release metadata is missing for ${missing.map((id) => `"${id}"`).join(", ")}. Supply an annotation for each, or limit the document with the \`versions\` option.`
227
+ });
228
+ const contexts = releaseOrder(included).flatMap((version) => {
229
+ const release = byVersion.get(version.id);
230
+ return release === void 0 ? [] : [{
231
+ package: pkg,
232
+ version,
233
+ metadata: release.metadata
234
+ }];
235
+ });
236
+ return {
237
+ _tag: "Document",
238
+ kind: "history",
239
+ children: [insertAll(generatedSection("deltafold/package", {
240
+ title: pkg.name,
241
+ children: contexts.map(releaseSection)
242
+ }), plugins.flatMap((plugin) => plugin.scope === "history" ? [{
243
+ at: plugin.at,
244
+ blocks: blocksOf(plugin.resolve({
245
+ package: pkg,
246
+ releases: contexts
247
+ }))
248
+ }] : []))]
249
+ };
250
+ },
251
+ upgrade: (plan, guideOptions = {}) => {
252
+ const verb = plan.direction === "downgrade" ? "Downgrade" : plan.direction === "upgrade" ? "Upgrade" : "Migrate";
253
+ const subject = guideOptions.package === void 0 ? "" : ` ${guideOptions.package.name}`;
254
+ const shown = plan.steps.filter((step) => !step.omitted);
255
+ const sharedEndpoints = (step) => shown.filter((candidate) => candidate.from.id === step.from.id && candidate.to.id === step.to.id).length > 1;
256
+ const stepSections = shown.map((step) => generatedSection(stepId(step), {
257
+ title: `${step.from.id} to ${step.to.id}${sharedEndpoints(step) ? ` (${step.migration.id})` : ""}`,
258
+ children: guideBlocks(step.guide)
259
+ }));
260
+ const children = stepSections.length === 0 ? [Paragraph("No migration work is needed.")] : stepSections;
261
+ if (guideOptions.explain === true && plan.explanations.length > 0) children.push(generatedSection("deltafold/explanations", {
262
+ title: "Omitted instructions",
263
+ children: [List(plan.explanations.map((explanation) => {
264
+ if (explanation._tag === "OmittedStep") return explanation.reason === "noop" ? `Migration "${explanation.migration.id}" needs no work.` : `Rules removed every action of migration "${explanation.migration.id}".`;
265
+ const removed = explanation.removed.map((occurrence) => occurrence.action.description);
266
+ const produced = explanation.produced.map((occurrence) => occurrence.action.description);
267
+ return produced.length === 0 ? `Rule "${explanation.rule.id}" cancelled: ${removed.join("; ")}.` : `Rule "${explanation.rule.id}" replaced ${removed.join("; ")} with ${produced.join("; ")}.`;
268
+ }))]
269
+ }));
270
+ return {
271
+ _tag: "Document",
272
+ kind: plan.direction === "downgrade" ? "downgrade" : "upgrade",
273
+ children: [generatedSection("deltafold/guide", {
274
+ title: `${verb}${subject} from ${plan.from.id} to ${plan.to.id}`,
275
+ children
276
+ })]
277
+ };
278
+ }
279
+ };
280
+ };
281
+ // src/features/documents/public-document.ts
282
+ var public_document_exports = /* @__PURE__ */ __exportAll({
283
+ Body: () => Body,
284
+ Code: () => Code,
285
+ CodeBlock: () => CodeBlock,
286
+ DocumentError: () => DocumentError,
287
+ Emphasis: () => Emphasis,
288
+ History: () => History,
289
+ Link: () => Link,
290
+ List: () => List,
291
+ Paragraph: () => Paragraph,
292
+ Plugin: () => Plugin,
293
+ Release: () => Release,
294
+ Section: () => Section,
295
+ Strong: () => Strong,
296
+ Text: () => Text,
297
+ Title: () => Title,
298
+ append: () => append,
299
+ withLevel: () => withLevel,
300
+ withTitle: () => withTitle
301
+ });
302
+ export { changelog_exports as Changelog, public_document_exports as Document };
303
+
304
+ //# sourceMappingURL=changelog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changelog.js","names":["Document.Paragraph","Document.List","Arr","Document.Text","Document.Section","Document.generatedSection"],"sources":["../src/features/documents/sections.ts","../src/features/documents/changelog.ts","../src/features/documents/public-document.ts"],"sourcesContent":["import type { Version } from \"../../foundation/version.ts\";\nimport {\n\tisBlock,\n\tSectionValue,\n\ttype Anchor,\n\ttype Block,\n\ttype PluginOutput,\n\ttype Section,\n} from \"./document.ts\";\n\n/** Marks a section as the section of one release. */\nexport const asRelease = (section: Section, version: Version): Section =>\n\tnew SectionValue({ ...section, release: version });\n\n/** Content that one plugin contributes at an anchor. */\nexport type Contribution = { readonly at: Anchor; readonly blocks: ReadonlyArray<Block> };\n\n/** Inserts contributions in configuration order. Each anchor receives its blocks at once. */\nexport const insertAll = (\n\tsection: Section,\n\tcontributions: ReadonlyArray<Contribution>,\n): Section => {\n\tconst at = (part: Anchor[\"part\"], position: Anchor[\"position\"]) =>\n\t\tcontributions\n\t\t\t.filter(\n\t\t\t\t(contribution) =>\n\t\t\t\t\tcontribution.at.part === part && contribution.at.position === position,\n\t\t\t)\n\t\t\t.flatMap((contribution) => contribution.blocks);\n\n\treturn new SectionValue({\n\t\t...section,\n\t\tbefore: [...section.before, ...at(\"title\", \"pre\")],\n\t\tafter: [...section.after, ...at(\"title\", \"post\")],\n\t\tchildren: [...at(\"body\", \"pre\"), ...section.children, ...at(\"body\", \"post\")],\n\t});\n};\n\nexport const blocksOf = (output: PluginOutput): ReadonlyArray<Block> => {\n\tif (output === null) return [];\n\tif (isBlock(output)) return [output];\n\n\treturn output;\n};\n","import { Array as Arr, Data, Order, Result, SemVer } from \"effect\";\n\nimport type * as Action from \"../../foundation/action.ts\";\nimport * as Change from \"../../foundation/change.ts\";\nimport type { Prose } from \"../../foundation/instruction.ts\";\nimport type { Coverage, GuideItem, Plan, Step } from \"../../foundation/plan.ts\";\nimport type { Release, Version } from \"../../foundation/version.ts\";\nimport type { Package } from \"../package.ts\";\nimport * as Document from \"./document.ts\";\nimport { asRelease, blocksOf, insertAll } from \"./sections.ts\";\n\n/**\n * A change section of a release. The first section whose `select` matches wins. Selectors\n * read the metadata that the consumer declared on each change.\n *\n * @since @next\n */\nexport type SectionDefinition = {\n\treadonly _tag: \"ChangelogSection\";\n\treadonly id: string;\n\treadonly title: string;\n\treadonly select: (change: Change.Change) => boolean;\n};\n\n/** @since @next */\nexport const section = (\n\tid: string,\n\toptions: { readonly title: string; readonly select: (change: Change.Change) => boolean },\n): SectionDefinition => ({ _tag: \"ChangelogSection\", id, ...options });\n\n/**\n * Release metadata does not match the package history.\n *\n * @since @next\n */\nexport class ReleaseMetadataError extends Data.TaggedError(\"ReleaseMetadataError\")<{\n\treadonly reason: \"duplicate\" | \"unrelated\" | \"missing\";\n\treadonly versions: ReadonlyArray<string>;\n\treadonly message: string;\n}> {}\n\n/** @since @next */\nexport type HistoryOptions<M> = {\n\t/**\n\t * Release metadata annotations, one per included version, in any order. Missing,\n\t * duplicate, or unrelated annotations throw `ReleaseMetadataError`.\n\t */\n\treadonly releases: ReadonlyArray<Release<M>>;\n\t/** The versions to include. Defaults to every version in the package history. */\n\treadonly versions?: ReadonlyArray<Version>;\n};\n\n/** @since @next */\nexport type GuideOptions = {\n\t/** The modeled package, for the guide title. */\n\treadonly package?: Package;\n\t/** Adds a section that lists omitted instructions and the rules responsible. */\n\treadonly explain?: boolean;\n};\n\n/** @since @next */\nexport type Changelog<M> = {\n\treadonly sections: ReadonlyArray<SectionDefinition>;\n\treadonly plugins: ReadonlyArray<Document.Plugin<M>>;\n\t/** A document for changes that are not assigned to a release yet. */\n\treadonly change: (\n\t\tchange: Change.Any | ReadonlyArray<Change.Any>,\n\t\toptions?: { readonly title?: string },\n\t) => Document.Document;\n\t/** The section for one release. */\n\treadonly release: (pkg: Package, release: Release<M>) => Document.Document;\n\t/**\n\t * Release history, titled with the package name. Historical changes stay, including\n\t * reverted ones. Releases are listed newest first by semver when every identifier\n\t * parses, and in reverse registration order otherwise.\n\t */\n\treadonly history: (pkg: Package, options: HistoryOptions<M>) => Document.Document;\n\t/**\n\t * The resolved instructions of a plan. Cancelled instructions are omitted. Downgrade\n\t * plans are titled as downgrades.\n\t */\n\treadonly upgrade: (\n\t\tplan: Plan<Action.Any, Coverage>,\n\t\toptions?: GuideOptions,\n\t) => Document.Document;\n};\n\n/** @since @next */\nexport type Options<M> = {\n\treadonly sections?: ReadonlyArray<SectionDefinition>;\n\treadonly plugins?: ReadonlyArray<Document.Plugin<M>>;\n\t/**\n\t * The section for changes that no section selects, or `false` to leave them out. Its\n\t * title defaults to \"Changes\" without `sections` and to \"Other changes\" with them.\n\t */\n\treadonly other?: { readonly title: string } | false;\n};\n\nconst paragraphsOf = (text: string): ReadonlyArray<Document.Paragraph> =>\n\ttext\n\t\t.split(/\\n\\s*\\n/)\n\t\t.map((part) => part.replace(/\\s*\\n\\s*/g, \" \").trim())\n\t\t.filter((part) => part !== \"\")\n\t\t.map((part) => Document.Paragraph(part));\n\n/**\n * Selectors read metadata fields by name. Reading any field of an object yields a value\n * or `undefined`, so viewing the metadata as fields of type `unknown` is sound.\n */\n// oxlint-disable-next-line typescript/no-unsafe-type-assertion\nconst selectable = (change: Change.Any) => change as Change.Change;\n\nconst changeList = (changes: ReadonlyArray<Change.Any>) =>\n\tDocument.List(changes.map((change) => paragraphsOf(change.description)));\n\nconst knows = (pkg: Package, version: Version) =>\n\tpkg.history.versions.some((known) => known.id === version.id);\n\nconst releaseOrder = (versions: ReadonlyArray<Version>): ReadonlyArray<Version> => {\n\tconst parsed = versions.map((version) => SemVer.parse(version.id));\n\tif (!parsed.every(Result.isSuccess)) return Arr.reverse(versions);\n\n\treturn Arr.sort(\n\t\tversions,\n\t\tOrder.flip(\n\t\t\tOrder.mapInput(SemVer.Order, (version: Version) => SemVer.parseUnsafe(version.id)),\n\t\t),\n\t);\n};\n\nconst occurrenceBlocks = (action: Action.Any, prose: Prose | undefined) =>\n\tprose === undefined ? [Document.Paragraph(action.description)] : guideBlocks(prose);\n\n/** Builds guide blocks: prose becomes paragraphs; groups become lists. */\nconst guideBlocks = (\n\titems: ReadonlyArray<GuideItem | Prose[number]>,\n): ReadonlyArray<Document.Block> => {\n\tconst blocks: Array<Document.Block> = [];\n\tlet current: Array<Document.Inline> = [];\n\tconst flush = () => {\n\t\tconst trimmed = trimInlines(current);\n\t\tif (trimmed.length > 0) blocks.push(Document.Paragraph(trimmed));\n\t\tcurrent = [];\n\t};\n\tfor (const item of items) {\n\t\tswitch (item._tag) {\n\t\t\tcase \"Text\": {\n\t\t\t\tconst [first = \"\", ...rest] = item.text.split(/\\n\\s*\\n/);\n\t\t\t\tcurrent.push(Document.Text(first.replace(/\\s*\\n\\s*/g, \" \")));\n\t\t\t\tfor (const part of rest) {\n\t\t\t\t\tflush();\n\t\t\t\t\tcurrent.push(Document.Text(part.replace(/\\s*\\n\\s*/g, \" \")));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ActionRef\":\n\t\t\t\tcurrent.push(Document.Text(item.action.description));\n\t\t\t\tbreak;\n\t\t\tcase \"Occurrence\": {\n\t\t\t\tconst { action, instruction } = item.occurrence;\n\t\t\t\tif (instruction === undefined && trimInlines(current).length > 0) {\n\t\t\t\t\tcurrent.push(Document.Text(action.description));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tflush();\n\t\t\t\tblocks.push(...occurrenceBlocks(action, instruction?.content));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Group\":\n\t\t\t\tflush();\n\t\t\t\tblocks.push(Document.List(item.children.map((child) => guideBlocks(child))));\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tflush();\n\n\treturn blocks;\n};\n\nconst trimInlines = (values: ReadonlyArray<Document.Inline>): ReadonlyArray<Document.Inline> => {\n\tconst result = values.flatMap((value) =>\n\t\tvalue._tag === \"Text\" && value.value === \"\" ? [] : [value],\n\t);\n\tconst first = result[0];\n\tconst last = result.at(-1);\n\tif (first?._tag === \"Text\") result[0] = Document.Text(first.value.trimStart());\n\tif (last?._tag === \"Text\") result[result.length - 1] = Document.Text(last.value.trimEnd());\n\n\treturn result.flatMap((value) => (value._tag === \"Text\" && value.value === \"\" ? [] : [value]));\n};\n\n// Generated sections take their identity from model identifiers under a kind that has no\n// `/`, so any version or migration identifier renders without colliding with others.\nconst stepId = (step: Step) =>\n\t`deltafold/${step.direction === \"forward\" ? \"step\" : \"revert\"}/${step.migration.id}`;\n\n/**\n * Configures sections and plugins for changelog documents. Without `sections`, a release\n * lists all of its changes in one \"Changes\" section.\n *\n * @example\n * ```ts\n * const changelog = Changelog.make<ReleaseMetadata>({\n * \tsections: [\n * \t\tChangelog.section(\"breaking\", {\n * \t\t\ttitle: \"Breaking changes\",\n * \t\t\tselect: (change) => change.metadata.breaking === true,\n * \t\t}),\n * \t\tChangelog.section(\"fixes\", {\n * \t\t\ttitle: \"Fixes\",\n * \t\t\tselect: (change) => change.metadata.kind === \"fixed\",\n * \t\t}),\n * \t],\n * \tplugins: [contributorsPlugin],\n * });\n * Markdown.render(changelog.history(widgets, { releases: [release100, release200] }));\n * ```\n *\n * @since @next\n */\nexport const make = <M = unknown>(options: Options<M> = {}): Changelog<M> => {\n\tconst sections = options.sections ?? [];\n\tconst plugins = options.plugins ?? [];\n\tconst other = options.other ?? { title: sections.length === 0 ? \"Changes\" : \"Other changes\" };\n\n\tconst changeSections = (\n\t\tchanges: ReadonlyArray<Change.Any>,\n\t): ReadonlyArray<Document.Section> => {\n\t\tconst grouped = new Map<string, Array<Change.Any>>();\n\t\tconst unmatched: Array<Change.Any> = [];\n\t\tfor (const change of changes) {\n\t\t\tconst match = sections.find((definition) => definition.select(selectable(change)));\n\t\t\tif (match === undefined) {\n\t\t\t\tunmatched.push(change);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst list = grouped.get(match.id) ?? [];\n\t\t\tlist.push(change);\n\t\t\tgrouped.set(match.id, list);\n\t\t}\n\t\tconst result = sections.flatMap((definition) => {\n\t\t\tconst matched = grouped.get(definition.id);\n\t\t\tif (matched === undefined) return [];\n\n\t\t\treturn [\n\t\t\t\tDocument.Section(definition.id, {\n\t\t\t\t\ttitle: definition.title,\n\t\t\t\t\tchildren: [changeList(matched)],\n\t\t\t\t}),\n\t\t\t];\n\t\t});\n\t\tif (other !== false && unmatched.length > 0) {\n\t\t\tresult.push(\n\t\t\t\tDocument.generatedSection(\"deltafold/other\", {\n\t\t\t\t\ttitle: other.title,\n\t\t\t\t\tchildren: [changeList(unmatched)],\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst releaseSection = (context: Document.ReleaseContext<M>): Document.Section => {\n\t\tconst base = asRelease(\n\t\t\tDocument.generatedSection(`deltafold/release/${context.version.id}`, {\n\t\t\t\ttitle: context.version.id,\n\t\t\t\tchildren: changeSections(context.version.changes),\n\t\t\t}),\n\t\t\tcontext.version,\n\t\t);\n\n\t\treturn insertAll(\n\t\t\tbase,\n\t\t\tplugins.flatMap((plugin) =>\n\t\t\t\tplugin.scope === Document.Release\n\t\t\t\t\t? [{ at: plugin.at, blocks: blocksOf(plugin.resolve(context)) }]\n\t\t\t\t\t: [],\n\t\t\t),\n\t\t);\n\t};\n\n\tconst requireKnown = (pkg: Package, releases: ReadonlyArray<Release<M>>) => {\n\t\tconst unrelated = releases.flatMap((release) =>\n\t\t\tknows(pkg, release.version) ? [] : [release.version.id],\n\t\t);\n\t\tif (unrelated.length > 0) {\n\t\t\tthrow new ReleaseMetadataError({\n\t\t\t\treason: \"unrelated\",\n\t\t\t\tversions: unrelated,\n\t\t\t\tmessage: `Release metadata for ${unrelated.map((id) => `\"${id}\"`).join(\", \")} does not belong to the history of \"${pkg.name}\".`,\n\t\t\t});\n\t\t}\n\t};\n\n\treturn {\n\t\tsections,\n\t\tplugins,\n\t\tchange: (input, changeOptions = {}) => {\n\t\t\tconst changes = Arr.ensure(input);\n\n\t\t\treturn {\n\t\t\t\t_tag: \"Document\",\n\t\t\t\tkind: \"change\",\n\t\t\t\tchildren: [\n\t\t\t\t\tDocument.generatedSection(\"deltafold/unreleased\", {\n\t\t\t\t\t\ttitle: changeOptions.title ?? \"Unreleased\",\n\t\t\t\t\t\tchildren: changeSections(changes),\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t\trelease: (pkg, release) => {\n\t\t\trequireKnown(pkg, [release]);\n\n\t\t\treturn {\n\t\t\t\t_tag: \"Document\",\n\t\t\t\tkind: \"release\",\n\t\t\t\tchildren: [\n\t\t\t\t\treleaseSection({\n\t\t\t\t\t\tpackage: pkg,\n\t\t\t\t\t\tversion: release.version,\n\t\t\t\t\t\tmetadata: release.metadata,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t\thistory: (pkg, historyOptions) => {\n\t\t\tconst { releases } = historyOptions;\n\t\t\trequireKnown(pkg, releases);\n\t\t\tconst byVersion = new Map<string, Release<M>>();\n\t\t\tconst duplicates = new Set<string>();\n\t\t\tfor (const release of releases) {\n\t\t\t\tif (byVersion.has(release.version.id)) duplicates.add(release.version.id);\n\t\t\t\tbyVersion.set(release.version.id, release);\n\t\t\t}\n\t\t\tif (duplicates.size > 0) {\n\t\t\t\tthrow new ReleaseMetadataError({\n\t\t\t\t\treason: \"duplicate\",\n\t\t\t\t\tversions: [...duplicates],\n\t\t\t\t\tmessage: `Release metadata is supplied more than once for ${[...duplicates].map((id) => `\"${id}\"`).join(\", \")}.`,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst included = historyOptions.versions ?? pkg.history.versions;\n\t\t\tconst missing = included.flatMap((version) =>\n\t\t\t\tbyVersion.has(version.id) ? [] : [version.id],\n\t\t\t);\n\t\t\tif (missing.length > 0) {\n\t\t\t\tthrow new ReleaseMetadataError({\n\t\t\t\t\treason: \"missing\",\n\t\t\t\t\tversions: missing,\n\t\t\t\t\tmessage: `Release metadata is missing for ${missing.map((id) => `\"${id}\"`).join(\", \")}. Supply an annotation for each, or limit the document with the \\`versions\\` option.`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst contexts = releaseOrder(included).flatMap((version) => {\n\t\t\t\tconst release = byVersion.get(version.id);\n\n\t\t\t\treturn release === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [{ package: pkg, version, metadata: release.metadata }];\n\t\t\t});\n\t\t\tconst root = insertAll(\n\t\t\t\tDocument.generatedSection(\"deltafold/package\", {\n\t\t\t\t\ttitle: pkg.name,\n\t\t\t\t\tchildren: contexts.map(releaseSection),\n\t\t\t\t}),\n\t\t\t\tplugins.flatMap((plugin) =>\n\t\t\t\t\tplugin.scope === Document.History\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tat: plugin.at,\n\t\t\t\t\t\t\t\t\tblocks: blocksOf(\n\t\t\t\t\t\t\t\t\t\tplugin.resolve({ package: pkg, releases: contexts }),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: [],\n\t\t\t\t),\n\t\t\t);\n\n\t\t\treturn { _tag: \"Document\", kind: \"history\", children: [root] };\n\t\t},\n\t\tupgrade: (plan, guideOptions = {}) => {\n\t\t\tconst verb =\n\t\t\t\tplan.direction === \"downgrade\"\n\t\t\t\t\t? \"Downgrade\"\n\t\t\t\t\t: plan.direction === \"upgrade\"\n\t\t\t\t\t\t? \"Upgrade\"\n\t\t\t\t\t\t: \"Migrate\";\n\t\t\tconst subject =\n\t\t\t\tguideOptions.package === undefined ? \"\" : ` ${guideOptions.package.name}`;\n\t\t\tconst shown = plan.steps.filter((step) => !step.omitted);\n\t\t\tconst sharedEndpoints = (step: Step) =>\n\t\t\t\tshown.filter(\n\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\tcandidate.from.id === step.from.id && candidate.to.id === step.to.id,\n\t\t\t\t).length > 1;\n\t\t\tconst stepSections = shown.map((step) =>\n\t\t\t\tDocument.generatedSection(stepId(step), {\n\t\t\t\t\ttitle: `${step.from.id} to ${step.to.id}${sharedEndpoints(step) ? ` (${step.migration.id})` : \"\"}`,\n\t\t\t\t\tchildren: guideBlocks(step.guide),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst children: Array<Document.Block> =\n\t\t\t\tstepSections.length === 0\n\t\t\t\t\t? [Document.Paragraph(\"No migration work is needed.\")]\n\t\t\t\t\t: stepSections;\n\t\t\tif (guideOptions.explain === true && plan.explanations.length > 0) {\n\t\t\t\tchildren.push(\n\t\t\t\t\tDocument.generatedSection(\"deltafold/explanations\", {\n\t\t\t\t\t\ttitle: \"Omitted instructions\",\n\t\t\t\t\t\tchildren: [\n\t\t\t\t\t\t\tDocument.List(\n\t\t\t\t\t\t\t\tplan.explanations.map((explanation) => {\n\t\t\t\t\t\t\t\t\tif (explanation._tag === \"OmittedStep\") {\n\t\t\t\t\t\t\t\t\t\treturn explanation.reason === \"noop\"\n\t\t\t\t\t\t\t\t\t\t\t? `Migration \"${explanation.migration.id}\" needs no work.`\n\t\t\t\t\t\t\t\t\t\t\t: `Rules removed every action of migration \"${explanation.migration.id}\".`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst removed = explanation.removed.map(\n\t\t\t\t\t\t\t\t\t\t(occurrence) => occurrence.action.description,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst produced = explanation.produced.map(\n\t\t\t\t\t\t\t\t\t\t(occurrence) => occurrence.action.description,\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\treturn produced.length === 0\n\t\t\t\t\t\t\t\t\t\t? `Rule \"${explanation.rule.id}\" cancelled: ${removed.join(\"; \")}.`\n\t\t\t\t\t\t\t\t\t\t: `Rule \"${explanation.rule.id}\" replaced ${removed.join(\"; \")} with ${produced.join(\"; \")}.`;\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t_tag: \"Document\",\n\t\t\t\tkind: plan.direction === \"downgrade\" ? \"downgrade\" : \"upgrade\",\n\t\t\t\tchildren: [\n\t\t\t\t\tDocument.generatedSection(\"deltafold/guide\", {\n\t\t\t\t\t\ttitle: `${verb}${subject} from ${plan.from.id} to ${plan.to.id}`,\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n};\n","export {\n\tBody,\n\tCode,\n\tCodeBlock,\n\tDocumentError,\n\tEmphasis,\n\tHistory,\n\tLink,\n\tList,\n\tParagraph,\n\tPlugin,\n\tRelease,\n\tSection,\n\tStrong,\n\tText,\n\tTitle,\n\tappend,\n\twithLevel,\n\twithTitle,\n} from \"./document.ts\";\nexport type {\n\tAnchor,\n\tBlock,\n\tDocument,\n\tHistoryContext,\n\tInline,\n\tInlineInput,\n\tPluginOptions,\n\tPluginOutput,\n\tReleaseContext,\n} from \"./document.ts\";\n"],"mappings":";;;;;AAWA,MAAa,aAAa,SAAkB,YAC3C,IAAI,aAAa;CAAE,GAAG;CAAS,SAAS;AAAQ,CAAC;;AAMlD,MAAa,aACZ,SACA,kBACa;CACb,MAAM,MAAM,MAAsB,aACjC,cACE,QACC,iBACA,aAAa,GAAG,SAAS,QAAQ,aAAa,GAAG,aAAa,QAChE,CAAC,CACA,SAAS,iBAAiB,aAAa,MAAM;CAEhD,OAAO,IAAI,aAAa;EACvB,GAAG;EACH,QAAQ,CAAC,GAAG,QAAQ,QAAQ,GAAG,GAAG,SAAS,KAAK,CAAC;EACjD,OAAO,CAAC,GAAG,QAAQ,OAAO,GAAG,GAAG,SAAS,MAAM,CAAC;EAChD,UAAU;GAAC,GAAG,GAAG,QAAQ,KAAK;GAAG,GAAG,QAAQ;GAAU,GAAG,GAAG,QAAQ,MAAM;EAAC;CA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,MAAM;IACN,MAAM,KAAK,cAAc,cAAc,cAAc;IACrD,UAAU,CACTI,iBAA0B,mBAAmB;KAC5C,OAAO,GAAG,OAAO,QAAQ,QAAQ,KAAK,KAAK,GAAG,MAAM,KAAK,GAAG;KAC5D;IACD,CAAC,CACF;GACD;EACD;CACD;AACD"}
@@ -0,0 +1,171 @@
1
+ import { Data, Predicate } from "effect";
2
+ // src/features/documents/document.ts
3
+ const isInline = (value) => Predicate.isTagged(value, "Text") || Predicate.isTagged(value, "Code") || Predicate.isTagged(value, "Link") || Predicate.isTagged(value, "Strong") || Predicate.isTagged(value, "Emphasis");
4
+ const isBlock = (value) => Predicate.isTagged(value, "Paragraph") || Predicate.isTagged(value, "List") || Predicate.isTagged(value, "CodeBlock") || Predicate.isTagged(value, "Section");
5
+ const inlines = (value) => {
6
+ if (typeof value === "string") return [Text(value)];
7
+ if (isInline(value)) return [value];
8
+ return value.map((item) => typeof item === "string" ? Text(item) : item);
9
+ };
10
+ /** @since @next */
11
+ const Text = (value) => ({
12
+ _tag: "Text",
13
+ value
14
+ });
15
+ /** @since @next */
16
+ const Code = (value) => ({
17
+ _tag: "Code",
18
+ value
19
+ });
20
+ /** @since @next */
21
+ const Link = (text, url) => ({
22
+ _tag: "Link",
23
+ url,
24
+ children: inlines(text)
25
+ });
26
+ /** @since @next */
27
+ const Strong = (children) => ({
28
+ _tag: "Strong",
29
+ children: inlines(children)
30
+ });
31
+ /** @since @next */
32
+ const Emphasis = (children) => ({
33
+ _tag: "Emphasis",
34
+ children: inlines(children)
35
+ });
36
+ /** @since @next */
37
+ const Paragraph = (children) => ({
38
+ _tag: "Paragraph",
39
+ children: inlines(children)
40
+ });
41
+ /** @since @next */
42
+ const CodeBlock = (value, options = {}) => ({
43
+ _tag: "CodeBlock",
44
+ value,
45
+ lang: options.lang
46
+ });
47
+ /**
48
+ * Builds a list. Each item is text, an inline node, a block, or several blocks.
49
+ *
50
+ * @since @next
51
+ */
52
+ const List = (items, options = {}) => ({
53
+ _tag: "List",
54
+ ordered: options.ordered ?? false,
55
+ items: items.map((item) => {
56
+ if (typeof item === "string" || isInline(item)) return [Paragraph(item)];
57
+ if (isBlock(item)) return [item];
58
+ return item;
59
+ })
60
+ });
61
+ const anchor = (part, position) => ({
62
+ _tag: "Anchor",
63
+ part,
64
+ position
65
+ });
66
+ var TitleValue = class extends Data.TaggedClass("Title") {};
67
+ /** Builds section values. Like titles, they are immutable and have Effect's `pipe`. */
68
+ var SectionValue = class extends Data.TaggedClass("Section") {};
69
+ const makeTitle = (text, options = {}) => new TitleValue({
70
+ children: inlines(text),
71
+ level: options.level
72
+ });
73
+ /**
74
+ * Builds a title. `Document.Title.pre` and `Document.Title.post` are the insertion points
75
+ * around a scoped section's title.
76
+ *
77
+ * @since @next
78
+ */
79
+ const Title = Object.assign(makeTitle, {
80
+ pre: anchor("title", "pre"),
81
+ post: anchor("title", "post")
82
+ });
83
+ /**
84
+ * The insertion points around a scoped section's body.
85
+ *
86
+ * @since @next
87
+ */
88
+ const Body = {
89
+ pre: anchor("body", "pre"),
90
+ post: anchor("body", "post")
91
+ };
92
+ const titleOf = (title) => typeof title === "string" ? makeTitle(title) : title;
93
+ /** @since @next */
94
+ const Section = (id, options = {}) => {
95
+ if (id.startsWith(reservedPrefix)) throw new DocumentError({
96
+ reason: "reserved-id",
97
+ message: `Section identifier "${id}" uses the reserved "${reservedPrefix}" prefix.`
98
+ });
99
+ return generatedSection(id, options);
100
+ };
101
+ /** Section identifiers that deltafold generates start with this prefix. */
102
+ const reservedPrefix = "deltafold/";
103
+ /** Builds a section without the reserved-prefix check, for sections deltafold generates. */
104
+ const generatedSection = (id, options = {}) => new SectionValue({
105
+ id,
106
+ title: titleOf(options.title),
107
+ before: [],
108
+ after: [],
109
+ children: options.children ?? [],
110
+ release: void 0
111
+ });
112
+ /**
113
+ * Sets an absolute heading level on a title. Levels outside 1 to 6 fail at render time.
114
+ *
115
+ * @since @next
116
+ */
117
+ const withLevel = (level) => (title) => new TitleValue({
118
+ ...title,
119
+ level
120
+ });
121
+ /**
122
+ * Sets the title of a section.
123
+ *
124
+ * @since @next
125
+ */
126
+ const withTitle = (title) => (section) => new SectionValue({
127
+ ...section,
128
+ title: titleOf(title)
129
+ });
130
+ /**
131
+ * Appends blocks to a section's body.
132
+ *
133
+ * @since @next
134
+ */
135
+ const append = (...blocks) => (section) => new SectionValue({
136
+ ...section,
137
+ children: [...section.children, ...blocks]
138
+ });
139
+ /**
140
+ * A document structure that cannot be rendered.
141
+ *
142
+ * @since @next
143
+ */
144
+ var DocumentError = class extends Data.TaggedError("DocumentError") {};
145
+ /**
146
+ * Release-scoped plugins run once per included release.
147
+ *
148
+ * @since @next
149
+ */
150
+ const Release = "release";
151
+ /**
152
+ * History-scoped plugins run once per history document.
153
+ *
154
+ * @since @next
155
+ */
156
+ const History = "history";
157
+ /** @since @next */
158
+ const makePlugin = (id, options) => ({
159
+ _tag: "Plugin",
160
+ id,
161
+ ...options
162
+ });
163
+ /**
164
+ * `Document.Plugin.make`
165
+ *
166
+ * @since @next
167
+ */
168
+ const Plugin = { make: makePlugin };
169
+ export { append as _, Emphasis as a, withLevel as b, List as c, Release as d, Section as f, Title as g, Text as h, DocumentError as i, Paragraph as l, Strong as m, Code as n, History as o, SectionValue as p, CodeBlock as r, Link as s, Body as t, Plugin as u, generatedSection as v, withTitle as x, isBlock as y };
170
+
171
+ //# sourceMappingURL=document-BZcZo9nr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-BZcZo9nr.js","names":[],"sources":["../src/features/documents/document.ts"],"sourcesContent":["import { Data, Predicate, type Pipeable } from \"effect\";\n\nimport type { Version } from \"../../foundation/version.ts\";\nimport type { Package } from \"../package.ts\";\n\n/** @since @next */\nexport type Text = { readonly _tag: \"Text\"; readonly value: string };\n/** @since @next */\nexport type Code = { readonly _tag: \"Code\"; readonly value: string };\n/** @since @next */\nexport type Link = {\n\treadonly _tag: \"Link\";\n\treadonly url: string;\n\treadonly children: ReadonlyArray<Inline>;\n};\n/** @since @next */\nexport type Strong = { readonly _tag: \"Strong\"; readonly children: ReadonlyArray<Inline> };\n/** @since @next */\nexport type Emphasis = { readonly _tag: \"Emphasis\"; readonly children: ReadonlyArray<Inline> };\n\n/**\n * Phrasing content.\n *\n * @since @next\n */\nexport type Inline = Text | Code | Link | Strong | Emphasis;\n\n/** @since @next */\nexport type Paragraph = { readonly _tag: \"Paragraph\"; readonly children: ReadonlyArray<Inline> };\n/** @since @next */\nexport type List = {\n\treadonly _tag: \"List\";\n\treadonly ordered: boolean;\n\t/** One entry per item. */\n\treadonly items: ReadonlyArray<ReadonlyArray<Block>>;\n};\n/** @since @next */\nexport type CodeBlock = {\n\treadonly _tag: \"CodeBlock\";\n\treadonly value: string;\n\treadonly lang: string | undefined;\n};\n\n/** @since @next */\nexport type Title = Pipeable.Pipeable & {\n\treadonly _tag: \"Title\";\n\treadonly children: ReadonlyArray<Inline>;\n\t/** An absolute heading level. Absent means the level follows section nesting. */\n\treadonly level: number | undefined;\n};\n\n/**\n * A titled part of a document. Its `id` must be unique within the containing release,\n * or within the document outside releases.\n *\n * @since @next\n */\nexport type Section = Pipeable.Pipeable & {\n\treadonly _tag: \"Section\";\n\treadonly id: string;\n\treadonly title: Title | undefined;\n\t/** Content inserted before the title. */\n\treadonly before: ReadonlyArray<Block>;\n\t/** Content inserted after the title, before the body. */\n\treadonly after: ReadonlyArray<Block>;\n\treadonly children: ReadonlyArray<Block>;\n\t/** Set on a release section, which scopes the identifiers of its sections. */\n\treadonly release: Version | undefined;\n};\n\n/** @since @next */\nexport type Block = Paragraph | List | CodeBlock | Section;\n\n/**\n * A complete document returned by changelog builders.\n *\n * @since @next\n */\nexport type Document = {\n\treadonly _tag: \"Document\";\n\treadonly kind: \"change\" | \"release\" | \"history\" | \"upgrade\" | \"downgrade\";\n\treadonly children: ReadonlyArray<Block>;\n};\n\n/**\n * Text, or inline nodes.\n *\n * @since @next\n */\nexport type InlineInput = string | Inline | ReadonlyArray<string | Inline>;\n\nconst isInline = (value: unknown): value is Inline =>\n\tPredicate.isTagged(value, \"Text\") ||\n\tPredicate.isTagged(value, \"Code\") ||\n\tPredicate.isTagged(value, \"Link\") ||\n\tPredicate.isTagged(value, \"Strong\") ||\n\tPredicate.isTagged(value, \"Emphasis\");\n\nexport const isBlock = (value: unknown): value is Block =>\n\tPredicate.isTagged(value, \"Paragraph\") ||\n\tPredicate.isTagged(value, \"List\") ||\n\tPredicate.isTagged(value, \"CodeBlock\") ||\n\tPredicate.isTagged(value, \"Section\");\n\nconst inlines = (value: InlineInput): ReadonlyArray<Inline> => {\n\tif (typeof value === \"string\") return [Text(value)];\n\tif (isInline(value)) return [value];\n\n\treturn value.map((item) => (typeof item === \"string\" ? Text(item) : item));\n};\n\n/** @since @next */\nexport const Text = (value: string): Text => ({ _tag: \"Text\", value });\n/** @since @next */\nexport const Code = (value: string): Code => ({ _tag: \"Code\", value });\n/** @since @next */\nexport const Link = (text: InlineInput, url: string): Link => ({\n\t_tag: \"Link\",\n\turl,\n\tchildren: inlines(text),\n});\n/** @since @next */\nexport const Strong = (children: InlineInput): Strong => ({\n\t_tag: \"Strong\",\n\tchildren: inlines(children),\n});\n/** @since @next */\nexport const Emphasis = (children: InlineInput): Emphasis => ({\n\t_tag: \"Emphasis\",\n\tchildren: inlines(children),\n});\n/** @since @next */\nexport const Paragraph = (children: InlineInput): Paragraph => ({\n\t_tag: \"Paragraph\",\n\tchildren: inlines(children),\n});\n/** @since @next */\nexport const CodeBlock = (value: string, options: { readonly lang?: string } = {}): CodeBlock => ({\n\t_tag: \"CodeBlock\",\n\tvalue,\n\tlang: options.lang,\n});\n\n/**\n * Builds a list. Each item is text, an inline node, a block, or several blocks.\n *\n * @since @next\n */\nexport const List = (\n\titems: ReadonlyArray<string | Inline | Block | ReadonlyArray<Block>>,\n\toptions: { readonly ordered?: boolean } = {},\n): List => ({\n\t_tag: \"List\",\n\tordered: options.ordered ?? false,\n\titems: items.map((item): ReadonlyArray<Block> => {\n\t\tif (typeof item === \"string\" || isInline(item)) return [Paragraph(item)];\n\t\tif (isBlock(item)) return [item];\n\n\t\treturn item;\n\t}),\n});\n\n/**\n * An insertion point inside a plugin's scope.\n *\n * @since @next\n */\nexport type Anchor = {\n\treadonly _tag: \"Anchor\";\n\treadonly part: \"title\" | \"body\";\n\treadonly position: \"pre\" | \"post\";\n};\n\nconst anchor = (part: Anchor[\"part\"], position: Anchor[\"position\"]): Anchor => ({\n\t_tag: \"Anchor\",\n\tpart,\n\tposition,\n});\n\nclass TitleValue extends Data.TaggedClass(\"Title\")<Omit<Title, \"_tag\" | \"pipe\">> {}\n\n/** Builds section values. Like titles, they are immutable and have Effect's `pipe`. */\nexport class SectionValue extends Data.TaggedClass(\"Section\")<Omit<Section, \"_tag\" | \"pipe\">> {}\n\nconst makeTitle = (text: InlineInput, options: { readonly level?: number } = {}): Title =>\n\tnew TitleValue({ children: inlines(text), level: options.level });\n\n/**\n * Builds a title. `Document.Title.pre` and `Document.Title.post` are the insertion points\n * around a scoped section's title.\n *\n * @since @next\n */\nexport const Title = Object.assign(makeTitle, {\n\tpre: anchor(\"title\", \"pre\"),\n\tpost: anchor(\"title\", \"post\"),\n});\n\n/**\n * The insertion points around a scoped section's body.\n *\n * @since @next\n */\nexport const Body = { pre: anchor(\"body\", \"pre\"), post: anchor(\"body\", \"post\") } as const;\n\nconst titleOf = (title: Title | string | undefined) =>\n\ttypeof title === \"string\" ? makeTitle(title) : title;\n\n/** @since @next */\nexport const Section = (id: string, options: SectionOptions = {}): Section => {\n\tif (id.startsWith(reservedPrefix)) {\n\t\tthrow new DocumentError({\n\t\t\treason: \"reserved-id\",\n\t\t\tmessage: `Section identifier \"${id}\" uses the reserved \"${reservedPrefix}\" prefix.`,\n\t\t});\n\t}\n\n\treturn generatedSection(id, options);\n};\n\ntype SectionOptions = {\n\treadonly title?: Title | string;\n\treadonly children?: ReadonlyArray<Block>;\n};\n\n/** Section identifiers that deltafold generates start with this prefix. */\nconst reservedPrefix = \"deltafold/\";\n\n/** Builds a section without the reserved-prefix check, for sections deltafold generates. */\nexport const generatedSection = (id: string, options: SectionOptions = {}): Section =>\n\tnew SectionValue({\n\t\tid,\n\t\ttitle: titleOf(options.title),\n\t\tbefore: [],\n\t\tafter: [],\n\t\tchildren: options.children ?? [],\n\t\trelease: undefined,\n\t});\n\n/**\n * Sets an absolute heading level on a title. Levels outside 1 to 6 fail at render time.\n *\n * @since @next\n */\nexport const withLevel =\n\t(level: number) =>\n\t(title: Title): Title =>\n\t\tnew TitleValue({ ...title, level });\n\n/**\n * Sets the title of a section.\n *\n * @since @next\n */\nexport const withTitle =\n\t(title: Title | string) =>\n\t(section: Section): Section =>\n\t\tnew SectionValue({ ...section, title: titleOf(title) });\n\n/**\n * Appends blocks to a section's body.\n *\n * @since @next\n */\nexport const append =\n\t(...blocks: ReadonlyArray<Block>) =>\n\t(section: Section): Section =>\n\t\tnew SectionValue({ ...section, children: [...section.children, ...blocks] });\n\n/**\n * A document structure that cannot be rendered.\n *\n * @since @next\n */\nexport class DocumentError extends Data.TaggedError(\"DocumentError\")<{\n\treadonly reason: \"duplicate-section\" | \"heading-level\" | \"reserved-id\";\n\treadonly message: string;\n}> {}\n\n// Plugins.\n\n/**\n * Release-scoped plugins run once per included release.\n *\n * @since @next\n */\nexport const Release = \"release\";\n/**\n * History-scoped plugins run once per history document.\n *\n * @since @next\n */\nexport const History = \"history\";\n\n/** @since @next */\nexport type ReleaseContext<M> = {\n\treadonly package: Package;\n\treadonly version: Version;\n\treadonly metadata: M;\n};\n\n/** @since @next */\nexport type HistoryContext<M> = {\n\treadonly package: Package;\n\treadonly releases: ReadonlyArray<ReleaseContext<M>>;\n};\n\n/**\n * Plugin output: blocks to insert, or `null` for nothing.\n *\n * @since @next\n */\nexport type PluginOutput = Block | ReadonlyArray<Block> | null;\n\n/**\n * Where a plugin's content goes. `scope` is `Document.Release`, once per included\n * release, or `Document.History`, once per history document. `at` is\n * `Document.Title.pre`, `Document.Title.post`, `Document.Body.pre`, or\n * `Document.Body.post` of that scope's section. Each insertion point receives every\n * plugin's content in configuration order.\n *\n * @since @next\n */\nexport type PluginOptions<M> =\n\t| {\n\t\t\treadonly scope: typeof Release;\n\t\t\treadonly at: Anchor;\n\t\t\treadonly resolve: (context: ReleaseContext<M>) => PluginOutput;\n\t }\n\t| {\n\t\t\treadonly scope: typeof History;\n\t\t\treadonly at: Anchor;\n\t\t\treadonly resolve: (context: HistoryContext<M>) => PluginOutput;\n\t };\n\n/**\n * Contributes content at an insertion point. Plugins work on format-neutral content:\n * they must not fetch metadata or execute migrations. Output is inserted once and is not\n * processed by other plugins.\n *\n * @since @next\n */\nexport type Plugin<M> = { readonly _tag: \"Plugin\"; readonly id: string } & PluginOptions<M>;\n\n/** @since @next */\nexport const makePlugin = <M>(id: string, options: PluginOptions<M>): Plugin<M> => ({\n\t_tag: \"Plugin\",\n\tid,\n\t...options,\n});\n\n/**\n * `Document.Plugin.make`\n *\n * @since @next\n */\nexport const Plugin = { make: makePlugin } as const;\n"],"mappings":";;AA2FA,MAAM,YAAY,UACjB,UAAU,SAAS,OAAO,MAAM,KAChC,UAAU,SAAS,OAAO,MAAM,KAChC,UAAU,SAAS,OAAO,MAAM,KAChC,UAAU,SAAS,OAAO,QAAQ,KAClC,UAAU,SAAS,OAAO,UAAU;AAErC,MAAa,WAAW,UACvB,UAAU,SAAS,OAAO,WAAW,KACrC,UAAU,SAAS,OAAO,MAAM,KAChC,UAAU,SAAS,OAAO,WAAW,KACrC,UAAU,SAAS,OAAO,SAAS;AAEpC,MAAM,WAAW,UAA8C;CAC9D,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC,KAAK,KAAK,CAAC;CAClD,IAAI,SAAS,KAAK,GAAG,OAAO,CAAC,KAAK;CAElC,OAAO,MAAM,KAAK,SAAU,OAAO,SAAS,WAAW,KAAK,IAAI,IAAI,IAAK;AAC1E;;AAGA,MAAa,QAAQ,WAAyB;CAAE,MAAM;CAAQ;AAAM;;AAEpE,MAAa,QAAQ,W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