deltafold 0.2.0 → 0.2.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 (48) hide show
  1. package/README.md +33 -1
  2. package/dist/changelog.d.ts +10 -10
  3. package/dist/changelog.js +4 -4
  4. package/dist/changelog.js.map +1 -1
  5. package/dist/{document-BZcZo9nr.js → document-HfPyYxEd.js} +20 -20
  6. package/dist/{document-BZcZo9nr.js.map → document-HfPyYxEd.js.map} +1 -1
  7. package/dist/{document-DWHsgywm.d.ts → document-gtXeGFJR.d.ts} +41 -41
  8. package/dist/{document-DWHsgywm.d.ts.map → document-gtXeGFJR.d.ts.map} +1 -1
  9. package/dist/html.d.ts +2 -2
  10. package/dist/html.js +2 -2
  11. package/dist/html.js.map +1 -1
  12. package/dist/index.d.ts +437 -105
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +750 -273
  15. package/dist/index.js.map +1 -1
  16. package/dist/markdown.d.ts +2 -2
  17. package/dist/markdown.js +2 -2
  18. package/dist/markdown.js.map +1 -1
  19. package/dist/{mdast-DiRsYwPU.js → mdast-Oqkh0Gs1.js} +2 -2
  20. package/dist/{mdast-DiRsYwPU.js.map → mdast-Oqkh0Gs1.js.map} +1 -1
  21. package/dist/{package-BfBYnaCz.d.ts → package-CA5R57IC.d.ts} +117 -112
  22. package/dist/{package-BfBYnaCz.d.ts.map → package-CA5R57IC.d.ts.map} +1 -1
  23. package/package.json +3 -3
  24. package/src/features/documents/changelog.ts +8 -8
  25. package/src/features/documents/document.ts +39 -39
  26. package/src/features/documents/index.ts +2 -2
  27. package/src/features/execution/executor.ts +485 -313
  28. package/src/features/execution/handler.ts +30 -30
  29. package/src/features/execution/interaction.ts +11 -11
  30. package/src/features/execution/observation.ts +489 -0
  31. package/src/features/execution/observer.ts +395 -0
  32. package/src/features/package.ts +3 -3
  33. package/src/features/planning/history.ts +10 -10
  34. package/src/features/planning/identifiers.ts +7 -4
  35. package/src/features/planning/resolve-error.ts +13 -13
  36. package/src/features/planning/resolve.ts +11 -4
  37. package/src/features/planning/validate.ts +1 -1
  38. package/src/foundation/action.ts +17 -17
  39. package/src/foundation/change.ts +10 -10
  40. package/src/foundation/instruction.ts +5 -5
  41. package/src/foundation/migration.ts +12 -12
  42. package/src/foundation/plan.ts +23 -18
  43. package/src/foundation/rule.ts +6 -6
  44. package/src/foundation/shortcut.ts +6 -6
  45. package/src/foundation/version.ts +6 -6
  46. package/src/index.ts +14 -12
  47. package/src/renderers/html.ts +1 -1
  48. package/src/renderers/markdown.ts +1 -1
package/README.md CHANGED
@@ -31,10 +31,15 @@ deltafold requires `effect` 4 as a peer dependency and a runtime with a global
31
31
  `AbortSignal`, such as Node.js 22.18 or later, Deno, Bun, or a browser. Type
32
32
  checking needs DOM or Node.js types for `AbortSignal`.
33
33
 
34
- - `deltafold`: declarations, planning, handlers, interactions, and executors.
34
+ - `deltafold`: declarations, planning, handlers, interactions, observers, and executors.
35
35
  - `deltafold/changelog`: changelog and document builders.
36
36
  - `deltafold/markdown` and `deltafold/html`: renderers for those documents.
37
37
 
38
+ Get plans and execution reports through deltafold's APIs. Patch-version
39
+ compatibility guarantees don't cover these structures when you construct them
40
+ by hand, such as a `Plan.Step` or an `Executor.Report`. If you create them
41
+ yourself, their required fields may change between patch releases.
42
+
38
43
  ## Declare a history
39
44
 
40
45
  An action kind describes an operation and its payload. An action instance is
@@ -280,6 +285,33 @@ whatever terminal or interface the caller has, and answers `"confirmed"` or
280
285
  `Handler.manualEffect` and `Interaction.effect` take an Effect check and an
281
286
  Effect interaction, and keep their errors and services.
282
287
 
288
+ ## Observe execution
289
+
290
+ Observers receive a run's events as they happen, for example to write logs or
291
+ show progress. Like handlers, they are an input of the run: pass them to the
292
+ executor's `observers` option.
293
+
294
+ ```ts
295
+ import { Observer } from "deltafold";
296
+
297
+ const logging = Observer.effect((event) => Effect.logDebug(event._tag));
298
+
299
+ // Progress goes to stderr, so it stays out of the program's own output.
300
+ const progress = Observer.sync((event) => {
301
+ if (event._tag !== "ActionSettled") return;
302
+ const { finished, total } = event.progress.actions;
303
+ console.error(`[${finished}/${total}] ${event.action.description}: ${event.outcome._tag}`);
304
+ });
305
+
306
+ await Executor.runPromise(plan, { handlers, observers: [logging, progress] });
307
+ ```
308
+
309
+ `Observer.sync`, `Observer.promise`, and `Observer.effect` take a callback for
310
+ each event. An Effect observer's services become requirements of the execution.
311
+ The executor waits for each observer before it continues, so a slow observer
312
+ slows the run. A failing observer never changes the outcome; the report lists it
313
+ under `observation`.
314
+
283
315
  ## Simplify routes with rules and shortcuts
284
316
 
285
317
  Rules replace consecutive actions when you assert that they are equivalent.
@@ -1,5 +1,5 @@
1
- import { _ as Any$1, d as Release, f as Version, h as Change, i as Coverage, m as Any, o as Plan, t as Package } from "./package-BfBYnaCz.js";
2
- import { C as Text, D as withTitle, E as withLevel, S as Strong, T as append, _ as PluginOptions, a as CodeBlock, b as ReleaseContext, c as Emphasis, d as Inline, f as InlineInput, g as Plugin, h as Paragraph, i as Code, l as History, m as List, n as Block, o as Document, p as Link, r as Body, s as DocumentError, t as Anchor, u as HistoryContext, v as PluginOutput, w as Title, x as Section, y as Release$1 } from "./document-DWHsgywm.js";
1
+ import { f as Release, g as Change, h as Any, i as Coverage, p as Version, s as Plan, t as Package, v as Any$1 } from "./package-CA5R57IC.js";
2
+ import { C as Text, D as withTitle, E as withLevel, S as Strong, T as append, _ as PluginOptions, a as CodeBlock, b as ReleaseContext, c as Emphasis, d as Inline, f as InlineInput, g as Plugin, h as Paragraph, i as Code, l as History, m as List, n as Block, o as Document, p as Link, r as Body, s as DocumentError, t as Anchor, u as HistoryContext, v as PluginOutput, w as Title, x as Section, y as Release$1 } from "./document-gtXeGFJR.js";
3
3
  declare namespace changelog_d_exports {
4
4
  export { Changelog, GuideOptions, HistoryOptions, Options, ReleaseMetadataError, SectionDefinition, make, section };
5
5
  }
@@ -7,7 +7,7 @@ declare namespace changelog_d_exports {
7
7
  * A change section of a release. The first section whose `select` matches wins. Selectors
8
8
  * read the metadata that the consumer declared on each change.
9
9
  *
10
- * @since @next
10
+ * @since 0.0.1
11
11
  */
12
12
  type SectionDefinition = {
13
13
  readonly _tag: "ChangelogSection";
@@ -15,7 +15,7 @@ type SectionDefinition = {
15
15
  readonly title: string;
16
16
  readonly select: (change: Change) => boolean;
17
17
  };
18
- /** @since @next */
18
+ /** @since 0.0.1 */
19
19
  declare const section: (id: string, options: {
20
20
  readonly title: string;
21
21
  readonly select: (change: Change) => boolean;
@@ -26,14 +26,14 @@ declare const ReleaseMetadataError_base: new <A extends Record<string, any> = {}
26
26
  /**
27
27
  * Release metadata does not match the package history.
28
28
  *
29
- * @since @next
29
+ * @since 0.0.1
30
30
  */
31
31
  declare class ReleaseMetadataError extends ReleaseMetadataError_base<{
32
32
  readonly reason: "duplicate" | "unrelated" | "missing";
33
33
  readonly versions: ReadonlyArray<string>;
34
34
  readonly message: string;
35
35
  }> {}
36
- /** @since @next */
36
+ /** @since 0.0.1 */
37
37
  type HistoryOptions<M> = {
38
38
  /**
39
39
  * Release metadata annotations, one per included version, in any order. Missing,
@@ -43,14 +43,14 @@ type HistoryOptions<M> = {
43
43
  /** The versions to include. Defaults to every version in the package history. */
44
44
  readonly versions?: ReadonlyArray<Version>;
45
45
  };
46
- /** @since @next */
46
+ /** @since 0.0.1 */
47
47
  type GuideOptions = {
48
48
  /** The modeled package, for the guide title. */
49
49
  readonly package?: Package;
50
50
  /** Adds a section that lists omitted instructions and the rules responsible. */
51
51
  readonly explain?: boolean;
52
52
  };
53
- /** @since @next */
53
+ /** @since 0.0.1 */
54
54
  type Changelog<M> = {
55
55
  readonly sections: ReadonlyArray<SectionDefinition>;
56
56
  readonly plugins: ReadonlyArray<Plugin<M>>;
@@ -72,7 +72,7 @@ type Changelog<M> = {
72
72
  */
73
73
  readonly upgrade: (plan: Plan<Any$1, Coverage>, options?: GuideOptions) => Document;
74
74
  };
75
- /** @since @next */
75
+ /** @since 0.0.1 */
76
76
  type Options<M> = {
77
77
  readonly sections?: ReadonlyArray<SectionDefinition>;
78
78
  readonly plugins?: ReadonlyArray<Plugin<M>>;
@@ -106,7 +106,7 @@ type Options<M> = {
106
106
  * Markdown.render(changelog.history(widgets, { releases: [release100, release200] }));
107
107
  * ```
108
108
  *
109
- * @since @next
109
+ * @since 0.0.1
110
110
  */
111
111
  declare const make: <M = unknown>(options?: Options<M>) => Changelog<M>;
112
112
  declare namespace public_document_d_exports {
package/dist/changelog.js CHANGED
@@ -1,5 +1,5 @@
1
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";
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-HfPyYxEd.js";
3
3
  import { Array, Data, Order, Result, SemVer } from "effect";
4
4
  // src/features/documents/sections.ts
5
5
  /** Marks a section as the section of one release. */
@@ -32,7 +32,7 @@ var changelog_exports = /* @__PURE__ */ __exportAll({
32
32
  make: () => make,
33
33
  section: () => section
34
34
  });
35
- /** @since @next */
35
+ /** @since 0.0.1 */
36
36
  const section = (id, options) => ({
37
37
  _tag: "ChangelogSection",
38
38
  id,
@@ -41,7 +41,7 @@ const section = (id, options) => ({
41
41
  /**
42
42
  * Release metadata does not match the package history.
43
43
  *
44
- * @since @next
44
+ * @since 0.0.1
45
45
  */
46
46
  var ReleaseMetadataError = class extends Data.TaggedError("ReleaseMetadataError") {};
47
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));
@@ -127,7 +127,7 @@ const stepId = (step) => `deltafold/${step.direction === "forward" ? "step" : "r
127
127
  * Markdown.render(changelog.history(widgets, { releases: [release100, release200] }));
128
128
  * ```
129
129
  *
130
- * @since @next
130
+ * @since 0.0.1
131
131
  */
132
132
  const make = (options = {}) => {
133
133
  const sections = options.sections ?? [];
@@ -1 +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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AAK,IAAI,EAAE,KAC/D,SAAS,YAAY,KAAK,GAAG,aAAa,QAAQ,KAAK,IAAI,EAAE,QAAQ,SAAS,KAAK,IAAI,EAAE;IAC7F,CAAC,CACF,CACD;GACD,CAAC,CACF;GAGD,OAAO;IACN,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"}
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 0.0.1\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 0.0.1 */\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 0.0.1\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 0.0.1 */\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 0.0.1 */\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 0.0.1 */\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 0.0.1 */\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 0.0.1\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,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,QAAQ,KAClC,eAAe,WAAW,OAAO,WACnC;KACA,MAAM,WAAW,YAAY,SAAS,KACpC,eAAe,WAAW,OAAO,WACnC;KAEA,OAAO,SAAS,WAAW,IACxB,SAAS,YAAY,KAAK,GAAG,eAAe,QAAQ,KAAK,IAAI,EAAE,KAC/D,SAAS,YAAY,KAAK,GAAG,aAAa,QAAQ,KAAK,IAAI,EAAE,QAAQ,SAAS,KAAK,IAAI,EAAE;IAC7F,CAAC,CACF,CACD;GACD,CAAC,CACF;GAGD,OAAO;IACN,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"}
@@ -7,38 +7,38 @@ const inlines = (value) => {
7
7
  if (isInline(value)) return [value];
8
8
  return value.map((item) => typeof item === "string" ? Text(item) : item);
9
9
  };
10
- /** @since @next */
10
+ /** @since 0.0.1 */
11
11
  const Text = (value) => ({
12
12
  _tag: "Text",
13
13
  value
14
14
  });
15
- /** @since @next */
15
+ /** @since 0.0.1 */
16
16
  const Code = (value) => ({
17
17
  _tag: "Code",
18
18
  value
19
19
  });
20
- /** @since @next */
20
+ /** @since 0.0.1 */
21
21
  const Link = (text, url) => ({
22
22
  _tag: "Link",
23
23
  url,
24
24
  children: inlines(text)
25
25
  });
26
- /** @since @next */
26
+ /** @since 0.0.1 */
27
27
  const Strong = (children) => ({
28
28
  _tag: "Strong",
29
29
  children: inlines(children)
30
30
  });
31
- /** @since @next */
31
+ /** @since 0.0.1 */
32
32
  const Emphasis = (children) => ({
33
33
  _tag: "Emphasis",
34
34
  children: inlines(children)
35
35
  });
36
- /** @since @next */
36
+ /** @since 0.0.1 */
37
37
  const Paragraph = (children) => ({
38
38
  _tag: "Paragraph",
39
39
  children: inlines(children)
40
40
  });
41
- /** @since @next */
41
+ /** @since 0.0.1 */
42
42
  const CodeBlock = (value, options = {}) => ({
43
43
  _tag: "CodeBlock",
44
44
  value,
@@ -47,7 +47,7 @@ const CodeBlock = (value, options = {}) => ({
47
47
  /**
48
48
  * Builds a list. Each item is text, an inline node, a block, or several blocks.
49
49
  *
50
- * @since @next
50
+ * @since 0.0.1
51
51
  */
52
52
  const List = (items, options = {}) => ({
53
53
  _tag: "List",
@@ -74,7 +74,7 @@ const makeTitle = (text, options = {}) => new TitleValue({
74
74
  * Builds a title. `Document.Title.pre` and `Document.Title.post` are the insertion points
75
75
  * around a scoped section's title.
76
76
  *
77
- * @since @next
77
+ * @since 0.0.1
78
78
  */
79
79
  const Title = Object.assign(makeTitle, {
80
80
  pre: anchor("title", "pre"),
@@ -83,14 +83,14 @@ const Title = Object.assign(makeTitle, {
83
83
  /**
84
84
  * The insertion points around a scoped section's body.
85
85
  *
86
- * @since @next
86
+ * @since 0.0.1
87
87
  */
88
88
  const Body = {
89
89
  pre: anchor("body", "pre"),
90
90
  post: anchor("body", "post")
91
91
  };
92
92
  const titleOf = (title) => typeof title === "string" ? makeTitle(title) : title;
93
- /** @since @next */
93
+ /** @since 0.0.1 */
94
94
  const Section = (id, options = {}) => {
95
95
  if (id.startsWith(reservedPrefix)) throw new DocumentError({
96
96
  reason: "reserved-id",
@@ -112,7 +112,7 @@ const generatedSection = (id, options = {}) => new SectionValue({
112
112
  /**
113
113
  * Sets an absolute heading level on a title. Levels outside 1 to 6 fail at render time.
114
114
  *
115
- * @since @next
115
+ * @since 0.0.1
116
116
  */
117
117
  const withLevel = (level) => (title) => new TitleValue({
118
118
  ...title,
@@ -121,7 +121,7 @@ const withLevel = (level) => (title) => new TitleValue({
121
121
  /**
122
122
  * Sets the title of a section.
123
123
  *
124
- * @since @next
124
+ * @since 0.0.1
125
125
  */
126
126
  const withTitle = (title) => (section) => new SectionValue({
127
127
  ...section,
@@ -130,7 +130,7 @@ const withTitle = (title) => (section) => new SectionValue({
130
130
  /**
131
131
  * Appends blocks to a section's body.
132
132
  *
133
- * @since @next
133
+ * @since 0.0.1
134
134
  */
135
135
  const append = (...blocks) => (section) => new SectionValue({
136
136
  ...section,
@@ -139,22 +139,22 @@ const append = (...blocks) => (section) => new SectionValue({
139
139
  /**
140
140
  * A document structure that cannot be rendered.
141
141
  *
142
- * @since @next
142
+ * @since 0.0.1
143
143
  */
144
144
  var DocumentError = class extends Data.TaggedError("DocumentError") {};
145
145
  /**
146
146
  * Release-scoped plugins run once per included release.
147
147
  *
148
- * @since @next
148
+ * @since 0.0.1
149
149
  */
150
150
  const Release = "release";
151
151
  /**
152
152
  * History-scoped plugins run once per history document.
153
153
  *
154
- * @since @next
154
+ * @since 0.0.1
155
155
  */
156
156
  const History = "history";
157
- /** @since @next */
157
+ /** @since 0.0.1 */
158
158
  const makePlugin = (id, options) => ({
159
159
  _tag: "Plugin",
160
160
  id,
@@ -163,9 +163,9 @@ const makePlugin = (id, options) => ({
163
163
  /**
164
164
  * `Document.Plugin.make`
165
165
  *
166
- * @since @next
166
+ * @since 0.0.1
167
167
  */
168
168
  const Plugin = { make: makePlugin };
169
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
170
 
171
- //# sourceMappingURL=document-BZcZo9nr.js.map
171
+ //# sourceMappingURL=document-HfPyYxEd.js.map
@@ -1 +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,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Q,MAAM;AAAE;AAE/E,MAAM,WAAW,UAChB,OAAO,UAAU,WAAW,UAAU,KAAK,IAAI;;AAGhD,MAAa,WAAW,IAAY,UAA0B,CAAC,MAAe;CAC7E,IAAI,GAAG,WAAW,cAAc,GAC/B,MAAM,IAAI,cAAc;EACvB,QAAQ;EACR,SAAS,uBAAuB,GAAG,uBAAuB,eAAe;CAC1E,CAAC;CAGF,OAAO,iBAAiB,IAAI,OAAO;AACpC;;AAQA,MAAM,iBAAiB;;AAGvB,MAAa,oBAAoB,IAAY,UAA0B,CAAC,MACvE,IAAI,aAAa;CAChB;CACA,OAAO,QAAQ,QAAQ,KAAK;CAC5B,QAAQ,CAAC;CACT,OAAO,CAAC;CACR,UAAU,QAAQ,YAAY,CAAC;CAC/B,SAAS,KAAA;AACV,CAAC;;;;;;AAOF,MAAa,aACX,WACA,UACA,IAAI,WAAW;CAAE,GAAG;CAAO;AAAM,CAAC;;;;;;AAOpC,MAAa,aACX,WACA,YACA,IAAI,aAAa;CAAE,GAAG;CAAS,OAAO,QAAQ,KAAK;AAAE,CAAC;;;;;;AAOxD,MAAa,UACX,GAAG,YACH,YACA,IAAI,aAAa;CAAE,GAAG;CAAS,UAAU,CAAC,GAAG,QAAQ,UAAU,GAAG,MAAM;AAAE,CAAC;;;;;;AAO7E,IAAa,gBAAb,cAAmC,KAAK,YAAY,eAAe,CAAC,CAGjE,CAAC;;;;;;AASJ,MAAa,UAAU;;;;;;AAMvB,MAAa,UAAU;;AAqDvB,MAAa,cAAiB,IAAY,aAA0C;CACnF,MAAM;CACN;CACA,GAAG;AACJ;;;;;;AAOA,MAAa,SAAS,EAAE,MAAM,WAAW"}
1
+ {"version":3,"file":"document-HfPyYxEd.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 0.0.1 */\nexport type Text = { readonly _tag: \"Text\"; readonly value: string };\n/** @since 0.0.1 */\nexport type Code = { readonly _tag: \"Code\"; readonly value: string };\n/** @since 0.0.1 */\nexport type Link = {\n\treadonly _tag: \"Link\";\n\treadonly url: string;\n\treadonly children: ReadonlyArray<Inline>;\n};\n/** @since 0.0.1 */\nexport type Strong = { readonly _tag: \"Strong\"; readonly children: ReadonlyArray<Inline> };\n/** @since 0.0.1 */\nexport type Emphasis = { readonly _tag: \"Emphasis\"; readonly children: ReadonlyArray<Inline> };\n\n/**\n * Phrasing content.\n *\n * @since 0.0.1\n */\nexport type Inline = Text | Code | Link | Strong | Emphasis;\n\n/** @since 0.0.1 */\nexport type Paragraph = { readonly _tag: \"Paragraph\"; readonly children: ReadonlyArray<Inline> };\n/** @since 0.0.1 */\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 0.0.1 */\nexport type CodeBlock = {\n\treadonly _tag: \"CodeBlock\";\n\treadonly value: string;\n\treadonly lang: string | undefined;\n};\n\n/** @since 0.0.1 */\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 0.0.1\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 0.0.1 */\nexport type Block = Paragraph | List | CodeBlock | Section;\n\n/**\n * A complete document returned by changelog builders.\n *\n * @since 0.0.1\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 0.0.1\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 0.0.1 */\nexport const Text = (value: string): Text => ({ _tag: \"Text\", value });\n/** @since 0.0.1 */\nexport const Code = (value: string): Code => ({ _tag: \"Code\", value });\n/** @since 0.0.1 */\nexport const Link = (text: InlineInput, url: string): Link => ({\n\t_tag: \"Link\",\n\turl,\n\tchildren: inlines(text),\n});\n/** @since 0.0.1 */\nexport const Strong = (children: InlineInput): Strong => ({\n\t_tag: \"Strong\",\n\tchildren: inlines(children),\n});\n/** @since 0.0.1 */\nexport const Emphasis = (children: InlineInput): Emphasis => ({\n\t_tag: \"Emphasis\",\n\tchildren: inlines(children),\n});\n/** @since 0.0.1 */\nexport const Paragraph = (children: InlineInput): Paragraph => ({\n\t_tag: \"Paragraph\",\n\tchildren: inlines(children),\n});\n/** @since 0.0.1 */\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 0.0.1\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 0.0.1\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 0.0.1\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 0.0.1\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 0.0.1 */\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 0.0.1\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 0.0.1\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 0.0.1\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 0.0.1\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 0.0.1\n */\nexport const Release = \"release\";\n/**\n * History-scoped plugins run once per history document.\n *\n * @since 0.0.1\n */\nexport const History = \"history\";\n\n/** @since 0.0.1 */\nexport type ReleaseContext<M> = {\n\treadonly package: Package;\n\treadonly version: Version;\n\treadonly metadata: M;\n};\n\n/** @since 0.0.1 */\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 0.0.1\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 0.0.1\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 0.0.1\n */\nexport type Plugin<M> = { readonly _tag: \"Plugin\"; readonly id: string } & PluginOptions<M>;\n\n/** @since 0.0.1 */\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 0.0.1\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,UA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