@driftsys/markspec 0.8.0 → 0.10.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.
- package/esm/compiler/mod.d.ts +7 -0
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +17 -3
- package/esm/compiler/schema.d.ts +8 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +8 -1
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +25 -0
- package/esm/discovery/gitignore.d.ts +40 -0
- package/esm/discovery/gitignore.d.ts.map +1 -0
- package/esm/discovery/gitignore.js +145 -0
- package/esm/discovery/mod.d.ts +54 -0
- package/esm/discovery/mod.d.ts.map +1 -0
- package/esm/discovery/mod.js +122 -0
- package/esm/formatter/dprint.d.ts +62 -0
- package/esm/formatter/dprint.d.ts.map +1 -0
- package/esm/formatter/dprint.js +83 -0
- package/esm/formatter/md_equiv.d.ts +24 -0
- package/esm/formatter/md_equiv.d.ts.map +1 -0
- package/esm/formatter/md_equiv.js +81 -0
- package/esm/formatter/mod.d.ts +25 -0
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +106 -6
- package/esm/formatter/prose.d.ts +48 -0
- package/esm/formatter/prose.d.ts.map +1 -0
- package/esm/formatter/prose.js +85 -0
- package/esm/mod.d.ts +10 -4
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +7 -2
- package/esm/model/mod.d.ts +25 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -0
- package/esm/model/profile.d.ts +34 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +28 -15
- package/esm/profile/chain.js +1 -0
- package/esm/profile/delivered.d.ts +27 -0
- package/esm/profile/delivered.d.ts.map +1 -0
- package/esm/profile/delivered.js +60 -0
- package/esm/profile/manifest.d.ts +1 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +107 -0
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +21 -0
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +22 -0
- package/esm/reporter/mod.js +17 -4
- package/esm/self_upgrade/target.d.ts +3 -3
- package/esm/self_upgrade/target.d.ts.map +1 -1
- package/esm/self_upgrade/target.js +4 -2
- package/esm/validator/corpus.d.ts +25 -0
- package/esm/validator/corpus.d.ts.map +1 -0
- package/esm/validator/corpus.js +138 -0
- package/esm/validator/listing.d.ts.map +1 -1
- package/esm/validator/listing.js +4 -1
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +1 -0
- package/package.json +3 -1
- package/script/compiler/mod.d.ts +7 -0
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +16 -2
- package/script/compiler/schema.d.ts +8 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +8 -1
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +25 -0
- package/script/discovery/gitignore.d.ts +40 -0
- package/script/discovery/gitignore.d.ts.map +1 -0
- package/script/discovery/gitignore.js +149 -0
- package/script/discovery/mod.d.ts +54 -0
- package/script/discovery/mod.d.ts.map +1 -0
- package/script/discovery/mod.js +128 -0
- package/script/formatter/dprint.d.ts +62 -0
- package/script/formatter/dprint.d.ts.map +1 -0
- package/script/formatter/dprint.js +120 -0
- package/script/formatter/md_equiv.d.ts +24 -0
- package/script/formatter/md_equiv.d.ts.map +1 -0
- package/script/formatter/md_equiv.js +87 -0
- package/script/formatter/mod.d.ts +25 -0
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +106 -5
- package/script/formatter/prose.d.ts +48 -0
- package/script/formatter/prose.d.ts.map +1 -0
- package/script/formatter/prose.js +88 -0
- package/script/mod.d.ts +10 -4
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +22 -3
- package/script/model/mod.d.ts +25 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +1 -0
- package/script/model/profile.d.ts +34 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +27 -14
- package/script/profile/chain.js +1 -0
- package/script/profile/delivered.d.ts +27 -0
- package/script/profile/delivered.d.ts.map +1 -0
- package/script/profile/delivered.js +65 -0
- package/script/profile/manifest.d.ts +1 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +108 -1
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +21 -0
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +22 -0
- package/script/reporter/mod.js +17 -4
- package/script/self_upgrade/target.d.ts +3 -3
- package/script/self_upgrade/target.d.ts.map +1 -1
- package/script/self_upgrade/target.js +4 -2
- package/script/validator/corpus.d.ts +25 -0
- package/script/validator/corpus.d.ts.map +1 -0
- package/script/validator/corpus.js +142 -0
- package/script/validator/listing.d.ts.map +1 -1
- package/script/validator/listing.js +4 -1
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +4 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/dprint
|
|
3
|
+
*
|
|
4
|
+
* Loader for the embedded dprint-markdown WASM plugin (ADR-029).
|
|
5
|
+
* `markspec fmt` formats whole Markdown documents with one canonical,
|
|
6
|
+
* zero-config style; this module owns that style and the (cached)
|
|
7
|
+
* WASM instantiation. Dynamic imports keep the plugin off every code
|
|
8
|
+
* path except formatting (`fmt`, the `check` MSL-F010 drift gate, LSP
|
|
9
|
+
* documentFormatting).
|
|
10
|
+
*
|
|
11
|
+
* Node-compatible: `node:fs/promises` + WebAssembly only, no `Deno.*`.
|
|
12
|
+
*
|
|
13
|
+
* Packaging note: `@dprint/formatter` and `@dprint/markdown` are dynamically
|
|
14
|
+
* imported bare npm specifiers, and their `plugin.wasm` ships inside the npm
|
|
15
|
+
* package — no vendored copy in this repo. `deno compile` only embeds the
|
|
16
|
+
* resolved npm tree (and thus the wasm) when the compile entry point itself
|
|
17
|
+
* lives inside this workspace member (`packages/markspec/`); an entry point
|
|
18
|
+
* outside that tree can't resolve the import map at runtime. The project's
|
|
19
|
+
* one real compile target (`packages/markspec/main.ts`) already satisfies
|
|
20
|
+
* this, so it's a non-issue in production — it only bites a from-scratch
|
|
21
|
+
* smoke test placed elsewhere.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The fixed MarkSpec Markdown style (ADR-029). Zero configuration by
|
|
25
|
+
* design — one canonical form across every project. `newLineKind` is
|
|
26
|
+
* "lf" because `format()` operates on a pure-LF buffer and re-applies
|
|
27
|
+
* the file's detected line ending on output.
|
|
28
|
+
*/
|
|
29
|
+
export const MARKSPEC_MARKDOWN_GLOBAL_CONFIG = Object.freeze({
|
|
30
|
+
lineWidth: 80,
|
|
31
|
+
newLineKind: "lf",
|
|
32
|
+
});
|
|
33
|
+
/** Plugin-level style knobs. See ADR-029 for the rationale per value.
|
|
34
|
+
*
|
|
35
|
+
* Frozen: this is the single canonical MarkSpec style, exported through the
|
|
36
|
+
* public barrel. Freezing stops a consumer from mutating the shared object
|
|
37
|
+
* after the formatter has already baked these values in at `instantiate()`
|
|
38
|
+
* (which would drift the entry-body width budget from the whole-document
|
|
39
|
+
* formatter — see `emitBodyViaAst`). */
|
|
40
|
+
export const MARKSPEC_MARKDOWN_PLUGIN_CONFIG = Object.freeze({
|
|
41
|
+
textWrap: "always",
|
|
42
|
+
emphasisKind: "underscores",
|
|
43
|
+
strongKind: "asterisks",
|
|
44
|
+
unorderedListKind: "dashes",
|
|
45
|
+
});
|
|
46
|
+
let cached;
|
|
47
|
+
/**
|
|
48
|
+
* Load the dprint-markdown WASM plugin (once — subsequent calls return
|
|
49
|
+
* the cached instance) and return a synchronous prose formatter.
|
|
50
|
+
*
|
|
51
|
+
* A failed instantiation is NOT cached: the rejected promise is cleared
|
|
52
|
+
* before it propagates, so the next call retries from scratch instead of
|
|
53
|
+
* replaying the same failure forever. This matters for the long-lived LSP
|
|
54
|
+
* session, where a transient WASM-load failure must not permanently
|
|
55
|
+
* disable formatting for the rest of the process.
|
|
56
|
+
*/
|
|
57
|
+
export function loadMarkdownFormatter() {
|
|
58
|
+
cached ??= instantiate().catch((err) => {
|
|
59
|
+
cached = undefined;
|
|
60
|
+
throw err;
|
|
61
|
+
});
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
async function instantiate() {
|
|
65
|
+
const { createFromBuffer } = await import("@dprint/formatter");
|
|
66
|
+
const { getPath } = await import("@dprint/markdown");
|
|
67
|
+
const { readFile } = await import("node:fs/promises");
|
|
68
|
+
const wasm = await readFile(getPath());
|
|
69
|
+
// `readFile` returns a Node `Buffer`, whose `buffer` property is typed
|
|
70
|
+
// `ArrayBufferLike` (may be a `SharedArrayBuffer`) — not assignable to
|
|
71
|
+
// `BufferSource`'s `ArrayBuffer`-backed view. Copy into a plain
|
|
72
|
+
// `Uint8Array` so the type is unambiguous; this runs once per process
|
|
73
|
+
// (the result is cached by `loadMarkdownFormatter`).
|
|
74
|
+
const formatter = createFromBuffer(Uint8Array.from(wasm));
|
|
75
|
+
formatter.setConfig(MARKSPEC_MARKDOWN_GLOBAL_CONFIG, MARKSPEC_MARKDOWN_PLUGIN_CONFIG);
|
|
76
|
+
return (markdown, options) => formatter.formatText({
|
|
77
|
+
filePath: "fragment.md",
|
|
78
|
+
fileText: markdown,
|
|
79
|
+
overrideConfig: options?.lineWidth !== undefined
|
|
80
|
+
? { lineWidth: options.lineWidth }
|
|
81
|
+
: undefined,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/md_equiv
|
|
3
|
+
*
|
|
4
|
+
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
5
|
+
* dprint pass. Two fragments are equivalent when they parse to the
|
|
6
|
+
* same mdast structure after eliding source `position`s and collapsing
|
|
7
|
+
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
8
|
+
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
9
|
+
* content, not wrap artifacts, and must not compare equal to a plain
|
|
10
|
+
* space. Soft-wrap positions,
|
|
11
|
+
* emphasis delimiter style (`*x*` vs `_x_`), table cell padding, and
|
|
12
|
+
* list marker style are presentation, not content — they compare
|
|
13
|
+
* equal. Hard breaks are `break` nodes in mdast, so wrap-collapsing
|
|
14
|
+
* cannot erase or fabricate one. Code (`code`, `inlineCode`), `html`,
|
|
15
|
+
* and definition `url`s stay byte-exact.
|
|
16
|
+
*
|
|
17
|
+
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
18
|
+
* inline markup). Used ONLY to accept/reject dprint output; the
|
|
19
|
+
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
20
|
+
* not be modified.
|
|
21
|
+
*/
|
|
22
|
+
/** True when `a` and `b` are the same Markdown, modulo presentation. */
|
|
23
|
+
export declare function markdownSemanticallyEquivalent(a: string, b: string): boolean;
|
|
24
|
+
//# sourceMappingURL=md_equiv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md_equiv.d.ts","sourceRoot":"","sources":["../../src/formatter/md_equiv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,wEAAwE;AACxE,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAMT"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/md_equiv
|
|
3
|
+
*
|
|
4
|
+
* CommonMark-semantic Markdown equivalence — the gate for the ADR-029
|
|
5
|
+
* dprint pass. Two fragments are equivalent when they parse to the
|
|
6
|
+
* same mdast structure after eliding source `position`s and collapsing
|
|
7
|
+
* ASCII whitespace runs inside `text` node values. Only ASCII
|
|
8
|
+
* whitespace is collapsed — NBSP (U+00A0) and Unicode spaces are
|
|
9
|
+
* content, not wrap artifacts, and must not compare equal to a plain
|
|
10
|
+
* space. Soft-wrap positions,
|
|
11
|
+
* emphasis delimiter style (`*x*` vs `_x_`), table cell padding, and
|
|
12
|
+
* list marker style are presentation, not content — they compare
|
|
13
|
+
* equal. Hard breaks are `break` nodes in mdast, so wrap-collapsing
|
|
14
|
+
* cannot erase or fabricate one. Code (`code`, `inlineCode`), `html`,
|
|
15
|
+
* and definition `url`s stay byte-exact.
|
|
16
|
+
*
|
|
17
|
+
* DELIBERATELY weaker than ADR-015's `astEquivalent` (byte-verbatim on
|
|
18
|
+
* inline markup). Used ONLY to accept/reject dprint output; the
|
|
19
|
+
* ADR-015 relation still guards §5.2 body emission (MSL-F900) and must
|
|
20
|
+
* not be modified.
|
|
21
|
+
*/
|
|
22
|
+
import { unified } from "unified";
|
|
23
|
+
import remarkParse from "remark-parse";
|
|
24
|
+
import remarkGfm from "remark-gfm";
|
|
25
|
+
const parser = unified().use(remarkParse).use(remarkGfm);
|
|
26
|
+
/** True when `a` and `b` are the same Markdown, modulo presentation. */
|
|
27
|
+
export function markdownSemanticallyEquivalent(a, b) {
|
|
28
|
+
if (a === b)
|
|
29
|
+
return true;
|
|
30
|
+
return deepEqual(normalize(parser.parse(a)), normalize(parser.parse(b)));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Recursively strip `position` keys and collapse ASCII whitespace runs
|
|
34
|
+
* in `text` node values (reflow can only introduce ASCII spaces and
|
|
35
|
+
* newlines; `\s` would also match NBSP and Unicode Zs spaces, letting
|
|
36
|
+
* a content change pass as a wrap change). Returns a plain JSON-ish
|
|
37
|
+
* structure for comparison; never mutates the input tree.
|
|
38
|
+
*/
|
|
39
|
+
function normalize(node) {
|
|
40
|
+
if (Array.isArray(node))
|
|
41
|
+
return node.map(normalize);
|
|
42
|
+
if (node === null || typeof node !== "object")
|
|
43
|
+
return node;
|
|
44
|
+
const src = node;
|
|
45
|
+
const out = {};
|
|
46
|
+
for (const key of Object.keys(src).sort()) {
|
|
47
|
+
if (key === "position")
|
|
48
|
+
continue;
|
|
49
|
+
if (key === "value" && src.type === "text" &&
|
|
50
|
+
typeof src.value === "string") {
|
|
51
|
+
out.value = src.value.replace(/[ \t\r\n\f\v]+/g, " ");
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
out[key] = normalize(src[key]);
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/** Structural deep-equality over the normalized trees. */
|
|
59
|
+
function deepEqual(a, b) {
|
|
60
|
+
if (a === b)
|
|
61
|
+
return true;
|
|
62
|
+
if (typeof a !== typeof b)
|
|
63
|
+
return false;
|
|
64
|
+
if (a === null || b === null)
|
|
65
|
+
return a === b;
|
|
66
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
67
|
+
if (!Array.isArray(a) || !Array.isArray(b))
|
|
68
|
+
return false;
|
|
69
|
+
if (a.length !== b.length)
|
|
70
|
+
return false;
|
|
71
|
+
return a.every((v, i) => deepEqual(v, b[i]));
|
|
72
|
+
}
|
|
73
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
74
|
+
const ak = Object.keys(a);
|
|
75
|
+
const bk = Object.keys(b);
|
|
76
|
+
if (ak.length !== bk.length)
|
|
77
|
+
return false;
|
|
78
|
+
return ak.every((k) => deepEqual(a[k], b[k]));
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
package/esm/formatter/mod.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* and requirement block insertion.
|
|
7
7
|
*/
|
|
8
8
|
import type { Attribute, Diagnostic } from "../model/mod.js";
|
|
9
|
+
import { type ProseFormatter } from "./dprint.js";
|
|
9
10
|
/**
|
|
10
11
|
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
11
12
|
* start (return value true). Delegates to the shared implementation in
|
|
@@ -49,6 +50,23 @@ export interface FormatOptions {
|
|
|
49
50
|
* Injectable for deterministic tests.
|
|
50
51
|
*/
|
|
51
52
|
readonly today?: () => string;
|
|
53
|
+
/**
|
|
54
|
+
* Whole-document Markdown formatter (ADR-029). When supplied, prose
|
|
55
|
+
* segments outside entry blocks and each entry body are routed
|
|
56
|
+
* through it (dprint-markdown), gated by CommonMark-semantic
|
|
57
|
+
* equivalence. When absent, format() is entry-only — the exact
|
|
58
|
+
* pre-ADR-029 behaviour. The entry-body polish passes a per-call
|
|
59
|
+
* `lineWidth` reduced by the body indent (see `emitBodyViaAst`);
|
|
60
|
+
* one-arg formatter callbacks simply ignore it.
|
|
61
|
+
*
|
|
62
|
+
* The pass is Markdown-only: it runs only when {@linkcode file} has a
|
|
63
|
+
* Markdown extension (`.md`). A source-file (or absent) `file` disables
|
|
64
|
+
* it even when this callback is set — a source file's doc comment must
|
|
65
|
+
* never be reflowed as Markdown, and the semantic gate cannot catch
|
|
66
|
+
* that class of corruption. Callers that format Markdown held in memory
|
|
67
|
+
* must therefore pass a `.md`-suffixed `file`.
|
|
68
|
+
*/
|
|
69
|
+
readonly formatMarkdownProse?: ProseFormatter;
|
|
52
70
|
}
|
|
53
71
|
/** Result of a format operation. */
|
|
54
72
|
export interface FormatResult {
|
|
@@ -107,6 +125,13 @@ export declare function sortAttributes(attributes: Attribute[]): Attribute[];
|
|
|
107
125
|
* 0 for entries inside source-file doc comments).
|
|
108
126
|
*/
|
|
109
127
|
export declare function renderAttributeBlock(attributes: Attribute[], indent: number): string;
|
|
128
|
+
/**
|
|
129
|
+
* Find the 0-based line index where a list item's content ends.
|
|
130
|
+
* Exported for the ADR-029 prose pass (entry-extent computation).
|
|
131
|
+
* Scans forward from the entry start, stopping at: a sibling list item
|
|
132
|
+
* (`- ` at the entry's marker column), a line with less indent, or EOF.
|
|
133
|
+
*/
|
|
134
|
+
export declare function findItemEnd(lines: readonly string[], startIdx: number, indent: number): number;
|
|
110
135
|
/**
|
|
111
136
|
* Find the 0-based line range [start, end) of the attribute block
|
|
112
137
|
* for an entry starting at the given line.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc/D;AAmSD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC;CAC/C;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AA2BD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA8Nd;AA4DD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAmB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CA2Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAcR;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2B5C"}
|
package/esm/formatter/mod.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* ULID stamping, indentation normalization, trailing backslash enforcement,
|
|
6
6
|
* and requirement block insertion.
|
|
7
7
|
*/
|
|
8
|
+
import { extname } from "@std/path";
|
|
8
9
|
import { ulid as defaultUlid } from "@std/ulid";
|
|
9
10
|
import { stringify as stringifyYaml } from "@std/yaml";
|
|
10
11
|
import { attributeSpec, CSV_SPLITTABLE_TYPES, IDENTITY_KEY, } from "../model/mod.js";
|
|
12
|
+
import { MARKDOWN_EXTENSIONS } from "../discovery/mod.js";
|
|
11
13
|
import { ATTR_LINE_RE } from "../parser/attributes.js";
|
|
12
14
|
import { extractFrontMatter } from "../parser/frontmatter.js";
|
|
13
15
|
import { parseMarkdown } from "../parser/markdown.js";
|
|
@@ -19,6 +21,9 @@ import { buildBodyAst } from "../ast/build.js";
|
|
|
19
21
|
import { render as renderBodyAst } from "../ast/render.js";
|
|
20
22
|
import { normalizeBodyAst } from "../ast/normalize.js";
|
|
21
23
|
import { astEquivalent } from "../ast/equivalence.js";
|
|
24
|
+
import { formatProseSegments } from "./prose.js";
|
|
25
|
+
import { MARKSPEC_MARKDOWN_GLOBAL_CONFIG, } from "./dprint.js";
|
|
26
|
+
import { markdownSemanticallyEquivalent } from "./md_equiv.js";
|
|
22
27
|
/**
|
|
23
28
|
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
24
29
|
* start (return value true). Delegates to the shared implementation in
|
|
@@ -175,6 +180,14 @@ const CANONICAL_ORDER = [
|
|
|
175
180
|
* string, preserving the leading/trailing blank-line delimiters
|
|
176
181
|
* that separate the body from the title and attr block.
|
|
177
182
|
*
|
|
183
|
+
* When `proseFormat` (ADR-029) is supplied, the AST-canonical body is
|
|
184
|
+
* further polished by the whole-document Markdown formatter (dprint),
|
|
185
|
+
* gated by CommonMark-semantic equivalence — NOT the strict ADR-015
|
|
186
|
+
* relation above, which is byte-verbatim on inline markup and would
|
|
187
|
+
* reject every legitimate re-wrap. A rejected polish keeps the
|
|
188
|
+
* AST-canonical body and raises an info diagnostic (MSL-F012) naming
|
|
189
|
+
* the entry.
|
|
190
|
+
*
|
|
178
191
|
* Returns `true` when any entry body was rewritten (so `format()` can
|
|
179
192
|
* keep `changed` accurate for `--check` mode); `false` when every body
|
|
180
193
|
* was already §5.2-canonical.
|
|
@@ -183,7 +196,7 @@ const CANONICAL_ORDER = [
|
|
|
183
196
|
* `normalizeBodyAst` is FORMATTER-ONLY — the validate/parse path must
|
|
184
197
|
* never call it.
|
|
185
198
|
*/
|
|
186
|
-
function emitBodyViaAst(lines, file, diagnostics, cachedEntries) {
|
|
199
|
+
function emitBodyViaAst(lines, file, diagnostics, cachedEntries, proseFormat) {
|
|
187
200
|
// When the caller supplies pre-parsed entries whose line numbers are still
|
|
188
201
|
// valid in `lines` (i.e., no line-count-changing operations occurred before
|
|
189
202
|
// this call), skip the re-parse entirely — the common hot path for files
|
|
@@ -246,6 +259,52 @@ function emitBodyViaAst(lines, file, diagnostics, cachedEntries) {
|
|
|
246
259
|
});
|
|
247
260
|
continue;
|
|
248
261
|
}
|
|
262
|
+
// ADR-029: polish the canonical body with the whole-document
|
|
263
|
+
// Markdown formatter. Gated by CommonMark-semantic equivalence —
|
|
264
|
+
// NOT the strict ADR-015 relation, which is byte-verbatim on
|
|
265
|
+
// inline markup and would reject every legitimate re-wrap. On
|
|
266
|
+
// rejection keep the AST-canonical body and say so (info).
|
|
267
|
+
let finalBody = emittedBody;
|
|
268
|
+
if (proseFormat !== undefined) {
|
|
269
|
+
// The body is formatted DEDENTED and re-indented afterwards, so the
|
|
270
|
+
// width budget must shrink by the indent — otherwise a wrap point
|
|
271
|
+
// landing near 80 columns dedented exceeds 80 re-indented, and an
|
|
272
|
+
// external whole-file dprint view (which sees the indent) re-wraps
|
|
273
|
+
// it: a formatter ping-pong. Floor of 20 keeps a pathological indent
|
|
274
|
+
// from degenerating into one-word-per-line output.
|
|
275
|
+
let polished;
|
|
276
|
+
try {
|
|
277
|
+
polished = proseFormat(emittedBody, {
|
|
278
|
+
lineWidth: Math.max(20, MARKSPEC_MARKDOWN_GLOBAL_CONFIG.lineWidth - indent),
|
|
279
|
+
}).replace(/\n$/, "");
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
// The dprint WASM formatter can throw on a pathological body.
|
|
283
|
+
// Treat a throw exactly like a rejected rewrite: keep the
|
|
284
|
+
// canonical body and report the fallback (never crash the run).
|
|
285
|
+
diagnostics.push({
|
|
286
|
+
code: "MSL-F012",
|
|
287
|
+
severity: "info",
|
|
288
|
+
message: `${entry.displayId}: Markdown pass errored — kept ` +
|
|
289
|
+
`the canonical body`,
|
|
290
|
+
location: entry.location,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (polished !== undefined && polished !== emittedBody) {
|
|
294
|
+
if (markdownSemanticallyEquivalent(emittedBody, polished)) {
|
|
295
|
+
finalBody = polished;
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
diagnostics.push({
|
|
299
|
+
code: "MSL-F012",
|
|
300
|
+
severity: "info",
|
|
301
|
+
message: `${entry.displayId}: Markdown pass produced a ` +
|
|
302
|
+
`non-equivalent body — kept the canonical body`,
|
|
303
|
+
location: entry.location,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
249
308
|
// The emitted body is the §5.2-canonical body and re-builds
|
|
250
309
|
// AST-equivalent to the canonical AST. Splice it back into the
|
|
251
310
|
// document — the AST is the load-bearing emission path.
|
|
@@ -264,7 +323,7 @@ function emitBodyViaAst(lines, file, diagnostics, cachedEntries) {
|
|
|
264
323
|
while (ei >= si && rawSegment[ei].trim() === "") {
|
|
265
324
|
trailBlanks.unshift(rawSegment[ei--]);
|
|
266
325
|
}
|
|
267
|
-
const emittedLines =
|
|
326
|
+
const emittedLines = finalBody.split("\n").map((l) => l ? `${indentStr}${l}` : l);
|
|
268
327
|
const newSegment = [...leadBlanks, ...emittedLines, ...trailBlanks];
|
|
269
328
|
// `changed` accuracy: only flag a body rewrite when the spliced
|
|
270
329
|
// segment actually differs from the original lines (a §5.2-canonical
|
|
@@ -330,7 +389,16 @@ export function format(markdown, options) {
|
|
|
330
389
|
const body = rawBody;
|
|
331
390
|
const { entries } = parseMarkdown(body, { file });
|
|
332
391
|
const diagnostics = [...fm.diagnostics];
|
|
333
|
-
|
|
392
|
+
// ADR-029: the whole-document Markdown pass is Markdown-only. Gate on the
|
|
393
|
+
// file extension HERE so the invariant has one home — a caller that wires
|
|
394
|
+
// formatMarkdownProse without its own guard (e.g. a future write tool, or
|
|
395
|
+
// formatSource forwarding options with a source-file label) cannot silently
|
|
396
|
+
// reflow a source file's doc comment as Markdown. The CommonMark-semantic
|
|
397
|
+
// gate cannot catch that class, so it must be prevented, not detected. The
|
|
398
|
+
// CLI/LSP call-site guards remain as defense-in-depth.
|
|
399
|
+
const isMarkdownFile = MARKDOWN_EXTENSIONS.has(extname(file).toLowerCase());
|
|
400
|
+
const proseFormat = isMarkdownFile ? options?.formatMarkdownProse : undefined;
|
|
401
|
+
if (entries.length === 0 && !fm.hadFrontMatter && proseFormat === undefined) {
|
|
334
402
|
// No entries and no front matter — nothing to format. Returning the
|
|
335
403
|
// original `markdown` preserves the source's exact byte sequence,
|
|
336
404
|
// including its line-ending convention.
|
|
@@ -451,9 +519,40 @@ export function format(markdown, options) {
|
|
|
451
519
|
// emitBodyViaAst skips its re-parse (the hot path for already-formatted
|
|
452
520
|
// files). When `changed` is true, any splicing or collapse may have
|
|
453
521
|
// shifted positions, so pass undefined to trigger the normal re-parse.
|
|
454
|
-
if (emitBodyViaAst(collapsedLines, file, diagnostics, changed ? undefined : entries))
|
|
522
|
+
if (emitBodyViaAst(collapsedLines, file, diagnostics, changed ? undefined : entries, proseFormat))
|
|
455
523
|
changed = true;
|
|
456
|
-
|
|
524
|
+
// ADR-029 whole-document Markdown pass: prose segments outside entry
|
|
525
|
+
// blocks through dprint, gated per segment. Entry bodies were already
|
|
526
|
+
// polished inside emitBodyViaAst. Re-parse for fresh extents when any
|
|
527
|
+
// earlier pass changed line positions.
|
|
528
|
+
let proseLines = collapsedLines;
|
|
529
|
+
if (proseFormat !== undefined) {
|
|
530
|
+
const proseEntries = changed
|
|
531
|
+
? parseMarkdown(collapsedLines.join("\n"), { file }).entries
|
|
532
|
+
: entries;
|
|
533
|
+
const extents = proseEntries.map((e) => {
|
|
534
|
+
const start = e.location.line - 1;
|
|
535
|
+
const entryIndent = (e.location.column - 1) + 2;
|
|
536
|
+
return { start, end: findItemEnd(collapsedLines, start, entryIndent) };
|
|
537
|
+
});
|
|
538
|
+
const prose = formatProseSegments(collapsedLines, extents, proseFormat);
|
|
539
|
+
if (prose.changed)
|
|
540
|
+
changed = true;
|
|
541
|
+
for (const fallback of prose.fallbacks) {
|
|
542
|
+
const cause = fallback.reason === "error"
|
|
543
|
+
? "errored"
|
|
544
|
+
: "produced non-equivalent output";
|
|
545
|
+
diagnostics.push({
|
|
546
|
+
code: "MSL-F012",
|
|
547
|
+
severity: "info",
|
|
548
|
+
message: `Markdown pass ${cause} for this prose segment — kept ` +
|
|
549
|
+
`the original text`,
|
|
550
|
+
location: { file, line: fallback.line + 1, column: 1 },
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
proseLines = prose.lines;
|
|
554
|
+
}
|
|
555
|
+
const formattedBody = proseLines.join("\n");
|
|
457
556
|
if (fm.hadFrontMatter) {
|
|
458
557
|
const canonicalFm = renderFrontMatter(fm.attributes);
|
|
459
558
|
const outputLf = canonicalFm + formattedBody;
|
|
@@ -616,10 +715,11 @@ export function renderAttributeBlock(attributes, indent) {
|
|
|
616
715
|
}
|
|
617
716
|
/**
|
|
618
717
|
* Find the 0-based line index where a list item's content ends.
|
|
718
|
+
* Exported for the ADR-029 prose pass (entry-extent computation).
|
|
619
719
|
* Scans forward from the entry start, stopping at: a sibling list item
|
|
620
720
|
* (`- ` at the entry's marker column), a line with less indent, or EOF.
|
|
621
721
|
*/
|
|
622
|
-
function findItemEnd(lines, startIdx, indent) {
|
|
722
|
+
export function findItemEnd(lines, startIdx, indent) {
|
|
623
723
|
const indentStr = " ".repeat(indent);
|
|
624
724
|
// The marker column is indent - 2 (e.g., indent 2 → marker at column 0).
|
|
625
725
|
const markerPrefix = " ".repeat(Math.max(0, indent - 2)) + "- ";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/prose
|
|
3
|
+
*
|
|
4
|
+
* ADR-029 whole-document Markdown pass: splits a document's lines into
|
|
5
|
+
* prose / entry-block segments and routes each prose segment through
|
|
6
|
+
* the injected {@linkcode ProseFormatter} (dprint-markdown). Every
|
|
7
|
+
* rewritten segment must pass {@linkcode markdownSemanticallyEquivalent}
|
|
8
|
+
* against its original — a rejected segment is kept byte-identical and
|
|
9
|
+
* reported via `fallbacks` (with its reason) so `format()` can emit an
|
|
10
|
+
* advisory diagnostic ("never make a file worse").
|
|
11
|
+
*
|
|
12
|
+
* Entry blocks (title line → item end, trailers included) are never
|
|
13
|
+
* given to dprint here; entry BODIES are polished separately inside
|
|
14
|
+
* `emitBodyViaAst` (core/formatter/mod.ts) where the parser's
|
|
15
|
+
* dedent/re-indent machinery and the body-AST gate already live.
|
|
16
|
+
*/
|
|
17
|
+
import type { ProseFormatter } from "./dprint.js";
|
|
18
|
+
/** 0-based `[start, end)` line span of one entry block. */
|
|
19
|
+
export interface EntryExtent {
|
|
20
|
+
readonly start: number;
|
|
21
|
+
readonly end: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Why a prose segment kept its original text instead of the formatted
|
|
25
|
+
* output: the dprint formatter threw (`"error"`), or its output failed the
|
|
26
|
+
* CommonMark-semantic gate (`"non-equivalent"`). Threaded so `format()`
|
|
27
|
+
* can emit an accurate MSL-F012 cause per segment rather than collapsing
|
|
28
|
+
* both into one message.
|
|
29
|
+
*/
|
|
30
|
+
export interface ProseFallback {
|
|
31
|
+
readonly line: number;
|
|
32
|
+
readonly reason: "error" | "non-equivalent";
|
|
33
|
+
}
|
|
34
|
+
/** Result of {@linkcode formatProseSegments}. */
|
|
35
|
+
export interface ProsePassResult {
|
|
36
|
+
readonly lines: string[];
|
|
37
|
+
readonly changed: boolean;
|
|
38
|
+
/** One entry per prose segment that fell back to its original text,
|
|
39
|
+
* with the 0-based first line and the reason. */
|
|
40
|
+
readonly fallbacks: readonly ProseFallback[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Format every prose gap between entry extents. Boundary blank lines
|
|
44
|
+
* stay outside the formatted chunk so entry-block separation is never
|
|
45
|
+
* disturbed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatProseSegments(lines: readonly string[], entryExtents: readonly EntryExtent[], proseFormat: ProseFormatter): ProsePassResult;
|
|
48
|
+
//# sourceMappingURL=prose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prose.d.ts","sourceRoot":"","sources":["../../src/formatter/prose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAAC;CAC7C;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;qDACiD;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,YAAY,EAAE,SAAS,WAAW,EAAE,EACpC,WAAW,EAAE,cAAc,GAC1B,eAAe,CA4DjB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/prose
|
|
3
|
+
*
|
|
4
|
+
* ADR-029 whole-document Markdown pass: splits a document's lines into
|
|
5
|
+
* prose / entry-block segments and routes each prose segment through
|
|
6
|
+
* the injected {@linkcode ProseFormatter} (dprint-markdown). Every
|
|
7
|
+
* rewritten segment must pass {@linkcode markdownSemanticallyEquivalent}
|
|
8
|
+
* against its original — a rejected segment is kept byte-identical and
|
|
9
|
+
* reported via `fallbacks` (with its reason) so `format()` can emit an
|
|
10
|
+
* advisory diagnostic ("never make a file worse").
|
|
11
|
+
*
|
|
12
|
+
* Entry blocks (title line → item end, trailers included) are never
|
|
13
|
+
* given to dprint here; entry BODIES are polished separately inside
|
|
14
|
+
* `emitBodyViaAst` (core/formatter/mod.ts) where the parser's
|
|
15
|
+
* dedent/re-indent machinery and the body-AST gate already live.
|
|
16
|
+
*/
|
|
17
|
+
import { markdownSemanticallyEquivalent } from "./md_equiv.js";
|
|
18
|
+
/**
|
|
19
|
+
* Format every prose gap between entry extents. Boundary blank lines
|
|
20
|
+
* stay outside the formatted chunk so entry-block separation is never
|
|
21
|
+
* disturbed.
|
|
22
|
+
*/
|
|
23
|
+
export function formatProseSegments(lines, entryExtents, proseFormat) {
|
|
24
|
+
const extents = [...entryExtents].sort((a, b) => a.start - b.start);
|
|
25
|
+
const out = [];
|
|
26
|
+
const fallbacks = [];
|
|
27
|
+
let changed = false;
|
|
28
|
+
let cursor = 0;
|
|
29
|
+
const flushProse = (gapStart, gapEnd) => {
|
|
30
|
+
const segment = lines.slice(gapStart, gapEnd);
|
|
31
|
+
// Keep boundary blank lines verbatim, format only the core.
|
|
32
|
+
let from = 0;
|
|
33
|
+
while (from < segment.length && segment[from].trim() === "")
|
|
34
|
+
from++;
|
|
35
|
+
let to = segment.length;
|
|
36
|
+
while (to > from && segment[to - 1].trim() === "")
|
|
37
|
+
to--;
|
|
38
|
+
if (from >= to) {
|
|
39
|
+
out.push(...segment);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const chunk = segment.slice(from, to).join("\n");
|
|
43
|
+
let formatted;
|
|
44
|
+
try {
|
|
45
|
+
formatted = proseFormat(chunk).replace(/\n$/, "");
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// The dprint WASM formatter can throw on a pathological fragment.
|
|
49
|
+
// Treat a throw exactly like a rejected rewrite: keep the original
|
|
50
|
+
// segment and report the fallback (never crash the whole run).
|
|
51
|
+
fallbacks.push({ line: gapStart + from, reason: "error" });
|
|
52
|
+
out.push(...segment);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (formatted === chunk) {
|
|
56
|
+
out.push(...segment);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!markdownSemanticallyEquivalent(chunk, formatted)) {
|
|
60
|
+
fallbacks.push({ line: gapStart + from, reason: "non-equivalent" });
|
|
61
|
+
out.push(...segment);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
changed = true;
|
|
65
|
+
out.push(...segment.slice(0, from));
|
|
66
|
+
out.push(...formatted.split("\n"));
|
|
67
|
+
out.push(...segment.slice(to));
|
|
68
|
+
};
|
|
69
|
+
for (const extent of extents) {
|
|
70
|
+
// Defensive clamp: extents from a healthy parse are disjoint and
|
|
71
|
+
// well-formed, but this module is the last guard between entry
|
|
72
|
+
// blocks and the prose formatter — never re-emit lines already
|
|
73
|
+
// written (overlap/duplicate extents) and treat end < start as
|
|
74
|
+
// zero-width instead of walking the cursor backwards.
|
|
75
|
+
const start = Math.max(extent.start, cursor);
|
|
76
|
+
const end = Math.max(extent.end, start);
|
|
77
|
+
if (start > cursor)
|
|
78
|
+
flushProse(cursor, start);
|
|
79
|
+
out.push(...lines.slice(start, end));
|
|
80
|
+
cursor = end;
|
|
81
|
+
}
|
|
82
|
+
if (cursor < lines.length)
|
|
83
|
+
flushProse(cursor, lines.length);
|
|
84
|
+
return { lines: out, changed, fallbacks };
|
|
85
|
+
}
|
package/esm/mod.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* from core/mod.ts, never from internal paths.
|
|
9
9
|
*/
|
|
10
10
|
import "./_dnt.polyfills.js";
|
|
11
|
-
export declare const VERSION = "0.
|
|
11
|
+
export declare const VERSION = "0.10.1";
|
|
12
12
|
export declare const CORE_SCHEMA_VERSION = 1;
|
|
13
13
|
export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, CORE_RELATIONS, DEFAULT_PROJECT_CONFIG, descendantsOf, KNOWN_LINK_KINDS, LOCK_EXTRA_INVERSE_KEYS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
|
|
14
|
-
export type { Attribute, BodyToken, BodyTokenKind, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, Diagnostic, Directive, Discipline, DisciplineRegistry, DisplayId, EarsTrigger, EffectiveProfile, EffectiveTypeDef, EntityRefConvention, Entry, EntryShape, EntrySource, ExtractorRule, InlineRef, KindDecl, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, LoadedProfile, ModalCase, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, RelationDef, Severity, SourceLocation, Ulid, } from "./model/mod.js";
|
|
14
|
+
export type { Attribute, BodyToken, BodyTokenKind, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, DeliveredDocument, Diagnostic, Directive, Discipline, DisciplineRegistry, DisplayId, EarsTrigger, EffectiveProfile, EffectiveTypeDef, EntityRefConvention, Entry, EntryOrigin, EntryShape, EntrySource, ExtractorRule, InlineRef, KindDecl, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, LoadedProfile, ModalCase, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, RelationDef, Severity, SourceLocation, Ulid, } from "./model/mod.js";
|
|
15
15
|
export { astEquivalent } from "./ast/equivalence.js";
|
|
16
16
|
export { normalizeBodyAst } from "./ast/normalize.js";
|
|
17
17
|
export { render } from "./ast/render.js";
|
|
@@ -29,12 +29,16 @@ export type { DisplayIdPatternShape, DisplayIdPatternValidation, } from "./profi
|
|
|
29
29
|
export { entryMatchesTargets, filterEntriesByTraceTargets, targetsForRelation, } from "./profile/mod.js";
|
|
30
30
|
export { buildProfileIntrospection } from "./profile/mod.js";
|
|
31
31
|
export type { AttributeDetail, ConventionDetail, LabelConcernDetail, ProfileElementDetail, ProfileElementKind, ProfileElementRef, ProfileIntrospection, ProfileOverview, ProvenancedDescription, RelationDetail, TypeDetail, } from "./profile/mod.js";
|
|
32
|
+
export { buildCorpusIndex, corpusOriginLabel, loadDeliveredCorpus, } from "./profile/delivered.js";
|
|
33
|
+
export type { LoadDeliveredCorpusResult } from "./profile/delivered.js";
|
|
32
34
|
export { detectCaptions, detectDirectives, detectInlineRefs, isSupportedExtension, loadGrammar, parse, parseFile, parseSource, } from "./parser/mod.js";
|
|
33
35
|
export type { DetectCaptionsOptions, DetectDirectivesOptions, DetectInlineRefsOptions, DocCommentBlockMeta, LanguageDocCommentSpec, LineMap, ParseFileResult, ParseOptions, ParseSourceOptions, ParseSourceResult, SupportedLanguage, } from "./parser/mod.js";
|
|
34
36
|
export { format } from "./formatter/mod.js";
|
|
35
37
|
export type { FormatOptions, FormatResult } from "./formatter/mod.js";
|
|
36
|
-
export {
|
|
37
|
-
export type {
|
|
38
|
+
export { loadMarkdownFormatter, MARKSPEC_MARKDOWN_GLOBAL_CONFIG, MARKSPEC_MARKDOWN_PLUGIN_CONFIG, } from "./formatter/dprint.js";
|
|
39
|
+
export type { ProseFormatOptions, ProseFormatter } from "./formatter/dprint.js";
|
|
40
|
+
export { attributeCorpusDiagnostics, classifyEntriesStage, classifyEntry, compileDisplayIdPattern, detectCorpusCollisions, effectiveScope, effectiveTraceRules, matchesAnyTarget, normalizeListValues, runPipeline, suppressDeclaredAttrR010, validate, validateAttributesForEntry, validateListingDocuments, validateTraceabilityForEntry, validateValue, } from "./validator/mod.js";
|
|
41
|
+
export type { ClassifyResult, ClassifyStageResult, CorpusCollisionResult, EffectiveAttrScope, ListingFileContext, ListingKind, PipelineOptions, PipelineResult, ValidateResult, ValueValidator, } from "./validator/mod.js";
|
|
38
42
|
export { compile, generateInverses, serializeCompileResult, } from "./compiler/mod.js";
|
|
39
43
|
export type { CompileOptions, CompileResult, GenerateInversesResult, SerializedCompileResult, SerializedEntry, SerializedTypeRegistry, } from "./compiler/mod.js";
|
|
40
44
|
export { buildManifest } from "./compiler/manifest.js";
|
|
@@ -53,4 +57,6 @@ export type { RefIndex } from "./refs/mod.js";
|
|
|
53
57
|
export { aggregateStatusByState, encodeLogLine, inferLockedAttributes, parseLogLine, parseMapping, validateMappings, } from "./sync/mod.js";
|
|
54
58
|
export type { AttributeMapping, BoundEntryStatus, ConflictPolicy, Direction as SyncDirection, Mapping, ParseMappingResult, RemoteState, SyncLogEntry, } from "./sync/mod.js";
|
|
55
59
|
export { type Arch as SelfUpgradeArch, assertTrustedReleaseUrl, classifyInstallPath, type ClassifyResult as SelfUpgradeClassifyResult, compareVersions, type Comparison, DEFAULT_RELEASES_API, DEFAULT_RELEASES_DOWNLOAD_BASE, detectTarget, type InstallSource, type Os as SelfUpgradeOs, parseSha256Line, type Platform as SelfUpgradePlatform, platformFromBuild, type ReleaseAssets, releaseAssets, type ReleaseEndpoints, type ResolveEndpointsInput, resolveReleaseEndpoints, type Target as SelfUpgradeTarget, } from "./self_upgrade/mod.js";
|
|
60
|
+
export { discoverFiles, isIgnored, MARKDOWN_EXTENSIONS, parseGitignore, RELEVANT_EXTENSIONS, SOURCE_EXTENSIONS, } from "./discovery/mod.js";
|
|
61
|
+
export type { DiscoverOptions, DiscoveryDirEntry, DiscoveryIO, GitignoreRule, } from "./discovery/mod.js";
|
|
56
62
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,qBAAqB,CAAC;AAG7B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG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