@codegraft/core 0.1.0-beta.11 → 0.1.0-beta.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,iGAAiG;AACjG,qEAAqE;AAkBrE;6FAC6F;AAC7F,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAA;AACzE,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAuB;IAClE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACpC,OAAO;QACL,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,QAAQ,CAAC,UAAU;QACtD,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,QAAQ,CAAC,GAAG;KAClC,CAAA;AACH,CAAC;AAED,SAAS,SAAS,CAAC,MAAc;IAC/B,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AAC5C,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACtC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA,CAAC,gCAAgC;IACxE,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,IAAI,YAAY,GAAG,KAAK,CAAA;IACxB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CA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,EAAE,KAAK,EAAE;YAAE,SAAQ;QACpC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAC5D,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ;QAAE,IAAI,GAAG,CAAC,CAAA,CAAC,2DAA2D;IAC3F,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjH,CAAC;AAED;yEACyE;AACzE,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,KAAa;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IACzD,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAE,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC"}
@@ -1,19 +1,18 @@
1
1
  import type { RichNode } from './types.js';
2
2
  import type { EditCollector } from './edit-collector.js';
3
- import { type FormatStyle } from './format.js';
4
3
  /**
5
- * The layout-formatting policy: how an edit is *rendered* once the codemod has decided *what* to
6
- * edit. Built per-apply from the source plus a resolved {@link FormatStyle}. The {@link Collection}
7
- * delegates the rendering of each edit to it; the {@link EditCollector} it drives stays a pure edit
8
- * buffer.
4
+ * How an edit is *rendered* once the codemod has decided *what* to edit. Built per-apply from the
5
+ * source and its detected line ending; the {@link Collection} delegates rendering to it while the
6
+ * {@link EditCollector} it drives stays a pure edit buffer.
9
7
  *
10
- * This is the single home for indentation/EOL re-rendering, container layout (separators, trailing
11
- * commas, brace padding), and line-collapse on removal and the place prettier-like options
12
- * (trailing-comma/semicolon/quote/print-width) would grow.
8
+ * Scope is deliberately narrow just enough that edits are **syntactically valid**: re-indent an
9
+ * inserted snippet to its anchor line, and give an appended/prepended element the separator its
10
+ * container needs (`,` / `;` / a line break). Cosmetics — exact indent, blank lines, brace padding,
11
+ * inline-vs-multiline reflow — are left to a downstream formatter, which sees the output anyway.
13
12
  */
14
13
  export declare class Formatter {
15
14
  #private;
16
- constructor(collector: EditCollector, source: string, style: FormatStyle);
15
+ constructor(collector: EditCollector, source: string, eol: string);
17
16
  /** The line ending — for inserting whole statements (`ensureImport`). */
18
17
  get eol(): string;
19
18
  /** The leading whitespace of the line containing `index` — for restoring a displaced node's indent. */
@@ -21,53 +20,15 @@ export declare class Formatter {
21
20
  /** `text` re-indented to the line at `index` (single-line text is unchanged) — for a replaced or
22
21
  * inserted snippet. */
23
22
  reindent(text: string, index: number): string;
24
- /** Append `text` as the last element of `node`: a fresh indented line in a block/class body, after
25
- * the last element of a comma- or `;`-separated list, or as the sole element of an empty one. */
23
+ /** The offset just past the line break following `index` (trailing spaces/tabs + one `\n`), or
24
+ * `index` itself when `index` is not at end of line so `remove({ separator })` can drop a
25
+ * statement's now-empty line, the newline-container analogue of dropping a list element's comma. */
26
+ endOfLine(index: number): number;
27
+ /** Append `text` as the last element of `node` with a valid separator: a line break in a
28
+ * block/class body, a `,`/`;` after the last element of a delimited list, or as the sole element
29
+ * of an empty container. */
26
30
  append(node: RichNode, text: string): void;
27
31
  /** Prepend `text` as the first element of `node` — the mirror of {@link append}. */
28
32
  prepend(node: RichNode, text: string): void;
29
- /** Delete `[start, end)`, collapsing whitespace the way Prettier would: when the span owns its
30
- * line(s) — only indentation before `start`, only whitespace after `end` up to the line break —
31
- * drop the whole lines so no blank line is left; otherwise an in-line delete that also clears one
32
- * residual separating space, so a removed mid-list element (`[1, two(), 3]`) leaves `[1, 3]`, not
33
- * `[1, 3]`.
34
- *
35
- * In the own-line case the content, the leading indent, and the trailing line break are removed
36
- * separately so the deletion composes after an abutting edit: a prior `unwrap`/`dropDirective` that
37
- * already consumed the run up to `start` leaves the content abutting it (no overlap, so it lands),
38
- * while the leading-indent removal it overlaps is dropped on its own (first-wins) instead of taking
39
- * the whole line removal down with it.
40
- *
41
- * `collapse.before`/`collapse.after` (the node was the last / first surviving element of its
42
- * container) additionally drop the run of blank lines directly above / below: a blank separator
43
- * left against the container's closing / opening delimiter, which Prettier strips. Each is its own
44
- * edit, abutting (not overlapping) the line removal, so a prior edit on the line is unaffected. */
45
- removeNode(start: number, end: number, collapse?: {
46
- before?: boolean;
47
- after?: boolean;
48
- }): void;
49
- /** Delete `[start, end)` where `end` begins a following node, collapsing the lines before it: when
50
- * `start` opens its own line and `end` sits on a later line, drop `[start's line, end's line)` so
51
- * the leading run (a directive comment and any comments stacked under it) vanishes whole-line while
52
- * `end`'s own line — its indentation included — is left for a later edit to collapse independently.
53
- * Otherwise (an inline `start`, or `end` on the same line) a plain `[start, end)` delete. Used by
54
- * `dropDirective` so it composes with a following `remove`. */
55
- removeLeadingTo(start: number, end: number): void;
56
- /** Delete the whole lines `[start, end)` touches — leading indentation through the trailing newline,
57
- * so nothing blank is left. With `collapseBlankBefore`, also absorb whole blank lines immediately
58
- * above (a separator before a dropped block). The explicit whole-line removal `remove({ wholeLines })`
59
- * asks for, where collapsing per node isn't enough. */
60
- removeWholeLines(start: number, end: number, collapseBlankBefore?: boolean): void;
61
- /** Register a dedent of the lifted range `[from, to)` by `dedent` columns: every continuation line
62
- * (the lines after the first) loses up to `dedent` leading-whitespace columns. Used by `unwrap`,
63
- * whose kept statements drop a level — their first line inherits the wrapper's indent for free,
64
- * but the rest keep their deeper source indent.
65
- *
66
- * Deferred to {@link flush} rather than applied now so it yields (first-wins) to the codemod's own
67
- * edits on the kept nodes: a kept statement removed or replaced in the same pass wins the overlap,
68
- * so only lines that actually survive get dedented. A no-op unless `dedent` is positive. */
69
- deferReindent(from: number, to: number, dedent: number): void;
70
- /** Apply every {@link deferReindent}, once, after the codemod has recorded its explicit edits. */
71
- flush(): void;
72
33
  }
73
34
  //# sourceMappingURL=formatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,KAAK,WAAW,EAAyF,MAAM,aAAa,CAAA;AAGrI;;;;;;;;;GASG;AACH,qBAAa,SAAS;;gBAQR,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAMxE,yEAAyE;IACzE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,uGAAuG;IACvG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/B;4BACwB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAM7C;sGACkG;IAClG,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAY1C,oFAAoF;IACpF,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAW3C;;;;;;;;;;;;;;;wGAeoG;IACpG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,IAAI;IAuBlG;;;;;oEAKgE;IAChE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAOjD;;;4DAGwD;IACxD,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,mBAAmB,UAAQ,GAAG,IAAI;IAO/E;;;;;;;iGAO6F;IAC7F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7D,kGAAkG;IAClG,KAAK,IAAI,IAAI;CA+Ed"}
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;;;;;;GASG;AACH,qBAAa,SAAS;;gBAKR,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAMjE,yEAAyE;IACzE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,uGAAuG;IACvG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/B;4BACwB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAI7C;;yGAEqG;IACrG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMhC;;iCAE6B;IAC7B,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAY1C,oFAAoF;IACpF,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAe5C"}
package/dist/formatter.js CHANGED
@@ -1,30 +1,27 @@
1
- import { reindent, indentOf, isHSpace, lineStartOf, wholeLineRange, blankRunStart, blankRunEnd } from './format.js';
2
- import { openDelimiter, trailingSeparator, isMultiline, NEWLINE_CONTAINERS, SEMI_CONTAINERS } from './containers.js';
1
+ import { reindent, indentOf } from './format.js';
2
+ import { openDelimiter, NEWLINE_CONTAINERS, SEMI_CONTAINERS } from './containers.js';
3
3
  /**
4
- * The layout-formatting policy: how an edit is *rendered* once the codemod has decided *what* to
5
- * edit. Built per-apply from the source plus a resolved {@link FormatStyle}. The {@link Collection}
6
- * delegates the rendering of each edit to it; the {@link EditCollector} it drives stays a pure edit
7
- * buffer.
4
+ * How an edit is *rendered* once the codemod has decided *what* to edit. Built per-apply from the
5
+ * source and its detected line ending; the {@link Collection} delegates rendering to it while the
6
+ * {@link EditCollector} it drives stays a pure edit buffer.
8
7
  *
9
- * This is the single home for indentation/EOL re-rendering, container layout (separators, trailing
10
- * commas, brace padding), and line-collapse on removal and the place prettier-like options
11
- * (trailing-comma/semicolon/quote/print-width) would grow.
8
+ * Scope is deliberately narrow just enough that edits are **syntactically valid**: re-indent an
9
+ * inserted snippet to its anchor line, and give an appended/prepended element the separator its
10
+ * container needs (`,` / `;` / a line break). Cosmetics — exact indent, blank lines, brace padding,
11
+ * inline-vs-multiline reflow — are left to a downstream formatter, which sees the output anyway.
12
12
  */
13
13
  export class Formatter {
14
14
  #collector;
15
15
  #source;
16
- #style;
17
- /** Reindents deferred to {@link flush} — registered by `unwrap`, applied after the codemod's
18
- * explicit edits so they yield to them (see {@link deferReindent}). */
19
- #deferred = [];
20
- constructor(collector, source, style) {
16
+ #eol;
17
+ constructor(collector, source, eol) {
21
18
  this.#collector = collector;
22
19
  this.#source = source;
23
- this.#style = style;
20
+ this.#eol = eol;
24
21
  }
25
22
  /** The line ending — for inserting whole statements (`ensureImport`). */
26
23
  get eol() {
27
- return this.#style.eol;
24
+ return this.#eol;
28
25
  }
29
26
  /** The leading whitespace of the line containing `index` — for restoring a displaced node's indent. */
30
27
  indentAt(index) {
@@ -33,193 +30,48 @@ export class Formatter {
33
30
  /** `text` re-indented to the line at `index` (single-line text is unchanged) — for a replaced or
34
31
  * inserted snippet. */
35
32
  reindent(text, index) {
36
- return reindent(text, indentOf(this.#source, index), this.#style.eol);
37
- }
38
- // —— append / prepend an element to a container ——
39
- /** Append `text` as the last element of `node`: a fresh indented line in a block/class body, after
40
- * the last element of a comma- or `;`-separated list, or as the sole element of an empty one. */
33
+ return reindent(text, indentOf(this.#source, index), this.#eol);
34
+ }
35
+ /** The offset just past the line break following `index` (trailing spaces/tabs + one `\n`), or
36
+ * `index` itself when `index` is not at end of line so `remove({ separator })` can drop a
37
+ * statement's now-empty line, the newline-container analogue of dropping a list element's comma. */
38
+ endOfLine(index) {
39
+ let i = index;
40
+ while (this.#source[i] === ' ' || this.#source[i] === '\t' || this.#source[i] === '\r')
41
+ i++;
42
+ return this.#source[i] === '\n' ? i + 1 : index;
43
+ }
44
+ /** Append `text` as the last element of `node` with a valid separator: a line break in a
45
+ * block/class body, a `,`/`;` after the last element of a delimited list, or as the sole element
46
+ * of an empty container. */
41
47
  append(node, text) {
42
48
  const elements = node.children;
43
49
  if (NEWLINE_CONTAINERS.has(node.type)) {
44
- if (elements.length === 0)
45
- this.#fillBlock(node, text);
46
- else {
47
- const last = elements[elements.length - 1];
48
- this.#collector.insertRight(last.documentEndIndex, this.#line(text, last.documentStartIndex));
49
- }
50
+ const at = elements.length ? elements[elements.length - 1] : openDelimiter(node);
51
+ this.#collector.insertRight(at.documentEndIndex, this.#eol + text);
52
+ }
53
+ else if (elements.length === 0) {
54
+ this.#collector.insertRight(openDelimiter(node).documentEndIndex, text);
55
+ }
56
+ else {
57
+ this.#collector.insertRight(elements[elements.length - 1].documentEndIndex, this.#separator(node) + text);
50
58
  }
51
- else if (elements.length === 0)
52
- this.#fillContainer(node, text);
53
- else
54
- this.#appendElement(node, elements[elements.length - 1], text);
55
59
  }
56
60
  /** Prepend `text` as the first element of `node` — the mirror of {@link append}. */
57
61
  prepend(node, text) {
58
62
  const elements = node.children;
59
- if (NEWLINE_CONTAINERS.has(node.type)) {
60
- if (elements.length === 0)
61
- this.#fillBlock(node, text);
62
- else
63
- this.#collector.insertRight(openDelimiter(node).documentEndIndex, this.#line(text, elements[0].documentStartIndex));
64
- }
65
- else if (elements.length === 0)
66
- this.#fillContainer(node, text);
67
- else
68
- this.#prependElement(node, elements[0], text);
69
- }
70
- // —— removal: emit the collapse edits ——
71
- /** Delete `[start, end)`, collapsing whitespace the way Prettier would: when the span owns its
72
- * line(s) — only indentation before `start`, only whitespace after `end` up to the line break —
73
- * drop the whole lines so no blank line is left; otherwise an in-line delete that also clears one
74
- * residual separating space, so a removed mid-list element (`[1, two(), 3]`) leaves `[1, 3]`, not
75
- * `[1, 3]`.
76
- *
77
- * In the own-line case the content, the leading indent, and the trailing line break are removed
78
- * separately so the deletion composes after an abutting edit: a prior `unwrap`/`dropDirective` that
79
- * already consumed the run up to `start` leaves the content abutting it (no overlap, so it lands),
80
- * while the leading-indent removal it overlaps is dropped on its own (first-wins) instead of taking
81
- * the whole line removal down with it.
82
- *
83
- * `collapse.before`/`collapse.after` (the node was the last / first surviving element of its
84
- * container) additionally drop the run of blank lines directly above / below: a blank separator
85
- * left against the container's closing / opening delimiter, which Prettier strips. Each is its own
86
- * edit, abutting (not overlapping) the line removal, so a prior edit on the line is unaffected. */
87
- removeNode(start, end, collapse = {}) {
88
- const lineStart = lineStartOf(this.#source, start);
89
- const newline = this.#source.indexOf('\n', end);
90
- const lineEnd = newline === -1 ? this.#source.length : newline;
91
- const ownsLines = this.#source.slice(lineStart, start).trim() === '' && this.#source.slice(end, lineEnd).trim() === '';
92
- if (!ownsLines) {
93
- // Inline hole: drop one separating space when both sides are spaced (a mid-list element), so no
94
- // double space is left. Never at a list edge (one side non-space) or across a line break.
95
- const trim = isHSpace(this.#source[end]) && isHSpace(this.#source[start - 1]) ? 1 : 0;
96
- this.#collector.remove(start, end + trim);
97
- return;
98
- }
99
- this.#collector.remove(start, end); // the content — abuts any prior edit at `start`, so it lands
100
- this.#collector.remove(lineStart, start); // leading indent — may be already gone under a prior edit
101
- const lineBreakEnd = newline === -1 ? this.#source.length : newline + 1;
102
- this.#collector.remove(end, lineBreakEnd); // trailing line break
103
- // Collapse a blank-line separator the removal leaves dangling against a container edge: `before`
104
- // the run above the node (against the close), `after` the run below (against the open). With no
105
- // such run each helper returns the offset it was given, so the remove is a no-op.
106
- if (collapse.before)
107
- this.#collector.remove(blankRunStart(this.#source, lineStart), lineStart);
108
- if (collapse.after)
109
- this.#collector.remove(lineBreakEnd, blankRunEnd(this.#source, lineBreakEnd));
110
- }
111
- /** Delete `[start, end)` where `end` begins a following node, collapsing the lines before it: when
112
- * `start` opens its own line and `end` sits on a later line, drop `[start's line, end's line)` so
113
- * the leading run (a directive comment and any comments stacked under it) vanishes whole-line while
114
- * `end`'s own line — its indentation included — is left for a later edit to collapse independently.
115
- * Otherwise (an inline `start`, or `end` on the same line) a plain `[start, end)` delete. Used by
116
- * `dropDirective` so it composes with a following `remove`. */
117
- removeLeadingTo(start, end) {
118
- const startLine = lineStartOf(this.#source, start);
119
- const endLine = lineStartOf(this.#source, end);
120
- if (endLine > startLine && this.#source.slice(startLine, start).trim() === '')
121
- this.#collector.remove(startLine, endLine);
122
- else
123
- this.#collector.remove(start, end);
124
- }
125
- /** Delete the whole lines `[start, end)` touches — leading indentation through the trailing newline,
126
- * so nothing blank is left. With `collapseBlankBefore`, also absorb whole blank lines immediately
127
- * above (a separator before a dropped block). The explicit whole-line removal `remove({ wholeLines })`
128
- * asks for, where collapsing per node isn't enough. */
129
- removeWholeLines(start, end, collapseBlankBefore = false) {
130
- const [from, to] = wholeLineRange(this.#source, start, end, collapseBlankBefore);
131
- this.#collector.remove(from, to);
132
- }
133
- // —— unwrap reindent (deferred) ——
134
- /** Register a dedent of the lifted range `[from, to)` by `dedent` columns: every continuation line
135
- * (the lines after the first) loses up to `dedent` leading-whitespace columns. Used by `unwrap`,
136
- * whose kept statements drop a level — their first line inherits the wrapper's indent for free,
137
- * but the rest keep their deeper source indent.
138
- *
139
- * Deferred to {@link flush} rather than applied now so it yields (first-wins) to the codemod's own
140
- * edits on the kept nodes: a kept statement removed or replaced in the same pass wins the overlap,
141
- * so only lines that actually survive get dedented. A no-op unless `dedent` is positive. */
142
- deferReindent(from, to, dedent) {
143
- if (dedent > 0)
144
- this.#deferred.push({ from, to, dedent });
145
- }
146
- /** Apply every {@link deferReindent}, once, after the codemod has recorded its explicit edits. */
147
- flush() {
148
- for (const { from, to, dedent } of this.#deferred)
149
- this.#dedentLifted(from, to, dedent);
150
- this.#deferred.length = 0;
151
- }
152
- // —— internals ——
153
- /** Strip up to `dedent` leading-whitespace columns from each continuation line of `[from, to)`
154
- * (blank lines skipped). Whitespace-only edits at line starts, so they compose with edits to the
155
- * kept nodes' content; a line already consumed by another edit drops out via first-wins. */
156
- #dedentLifted(from, to, dedent) {
157
- for (let nl = this.#source.indexOf('\n', from); nl !== -1 && nl < to; nl = this.#source.indexOf('\n', nl + 1)) {
158
- const lineStart = nl + 1;
159
- let i = lineStart;
160
- while (isHSpace(this.#source[i]))
161
- i++;
162
- if (i > lineStart)
163
- this.#collector.remove(lineStart, lineStart + Math.min(dedent, i - lineStart));
63
+ const newline = NEWLINE_CONTAINERS.has(node.type);
64
+ if (newline || elements.length === 0) {
65
+ this.#collector.insertRight(openDelimiter(node).documentEndIndex, newline ? this.#eol + text : text);
164
66
  }
165
- }
166
- /** `text` as a fresh line at the indentation of the sibling at `index`. */
167
- #line(text, index) {
168
- const indent = indentOf(this.#source, index);
169
- return this.#style.eol + indent + reindent(text, indent, this.#style.eol);
170
- }
171
- /** Open an empty `{}` block onto its own indented line — `{}` → `{⏎ text⏎}`. */
172
- #fillBlock(node, text) {
173
- const blockIndent = indentOf(this.#source, node.documentStartIndex);
174
- const indent = blockIndent + this.#style.indentUnit;
175
- const eol = this.#style.eol;
176
- this.#collector.insertRight(openDelimiter(node).documentEndIndex, eol + indent + reindent(text, indent, eol) + eol + blockIndent);
177
- }
178
- /** Fill an empty delimited container with its sole element: a brace container is padded
179
- * (`{}` → `{ text }`); an array / argument list is not (`[]` → `[text]`). */
180
- #fillContainer(node, text) {
181
- const open = openDelimiter(node);
182
- const pad = open.text === '{' ? ' ' : '';
183
- this.#collector.insertRight(open.documentEndIndex, pad + text + pad);
184
- }
185
- /** Append `text` after the last element `last` of a delimited container. A multi-line container
186
- * places it on a fresh line at the elements' indent, mirroring the trailing-separator style —
187
- * extend an existing trailing `sep`, add the mandatory `,` a comma list omits, or rely on the
188
- * newline alone for a `;` list (where the separator between members is optional); an inline one
189
- * stays on one line. */
190
- #appendElement(node, last, text) {
191
- const sep = this.#separatorFor(node);
192
- if (!isMultiline(node)) {
193
- this.#collector.insertRight(last.documentEndIndex, `${sep} ${text}`);
194
- return;
195
- }
196
- const trailing = trailingSeparator(last, sep);
197
- const line = this.#line(text, last.documentStartIndex);
198
- if (trailing)
199
- this.#collector.insertRight(trailing.documentEndIndex, line + sep);
200
- else if (sep === ';')
201
- this.#collector.insertRight(last.documentEndIndex, line);
202
- else
203
- this.#collector.insertRight(last.documentEndIndex, sep + line);
204
- }
205
- /** Prepend `text` before the first element `first` — the mirror of {@link #appendElement}. The new
206
- * element is always followed by the old first, so a multi-line container puts it on a fresh line
207
- * after the open delimiter, separator-terminated (`;` only where the body terminates members with
208
- * one); an inline one inserts before the first element so brace padding stays intact
209
- * (`{ a }` → `{ x, a }`). */
210
- #prependElement(node, first, text) {
211
- const sep = this.#separatorFor(node);
212
- if (!isMultiline(node)) {
213
- this.#collector.insertLeft(first.documentStartIndex, `${text}${sep} `);
214
- return;
67
+ else {
68
+ this.#collector.insertLeft(elements[0].documentStartIndex, text + this.#separator(node));
215
69
  }
216
- const terminate = sep === ',' || trailingSeparator(first, sep) !== null;
217
- this.#collector.insertRight(openDelimiter(node).documentEndIndex, this.#line(text, first.documentStartIndex) + (terminate ? sep : ''));
218
70
  }
219
- /** The token that separates a container's elements — `;` for a TS interface / object type, else
220
- * `,`. The seam a future `semi`/separator option would hook into. */
221
- #separatorFor(node) {
222
- return SEMI_CONTAINERS.has(node.type) ? ';' : ',';
71
+ /** The separator placed between a delimited container's elements — `; ` for a TS interface /
72
+ * object type, else `, `. */
73
+ #separator(node) {
74
+ return SEMI_CONTAINERS.has(node.type) ? '; ' : ', ';
223
75
  }
224
76
  }
225
77
  //# sourceMappingURL=formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACrI,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEpH;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IACX,UAAU,CAAe;IACzB,OAAO,CAAQ;IACf,MAAM,CAAa;IAC5B;4EACwE;IAC/D,SAAS,GAAwD,EAAE,CAAA;IAE5E,YAAY,SAAwB,EAAE,MAAc,EAAE,KAAkB;QACtE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,yEAAyE;IACzE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;IACxB,CAAC;IAED,uGAAuG;IACvG,QAAQ,CAAC,KAAa;QACpB,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACtC,CAAC;IAED;4BACwB;IACxB,QAAQ,CAAC,IAAY,EAAE,KAAa;QAClC,OAAO,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACvE,CAAC;IAED,mDAAmD;IAEnD;sGACkG;IAClG,MAAM,CAAC,IAAc,EAAE,IAAY;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,Q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AAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QAC3G,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,OAAO,CAAC,IAAc,EAAE,IAAY;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjD,IAAI,OAAO,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACtG,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC;IAED;kCAC8B;IAC9B,UAAU,CAAC,IAAc;QACvB,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IACrD,CAAC;CACF"}
@@ -2,5 +2,5 @@ export { Parser } from './parser.js';
2
2
  export { EXTENSION_GRAMMAR } from './extensions.js';
3
3
  export { wrapNode } from './rich-node.js';
4
4
  export { assert } from './assert.js';
5
- export type { Node, Tree } from 'web-tree-sitter';
5
+ export type { Node, Tree } from '../vendor/web-tree-sitter/web-tree-sitter.js';
6
6
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,8CAA8C,CAAA"}
package/dist/parser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Tree } from 'web-tree-sitter';
1
+ import { type Tree } from '../vendor/web-tree-sitter/web-tree-sitter.js';
2
2
  import type { GrammarId } from './types.js';
3
3
  /** Idempotent. Loads the web-tree-sitter WASM runtime once per process. */
4
4
  declare function init(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAqC3C,2EAA2E;AAC3E,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAGnC;AAED;;;;GAIG;AACH,iBAAe,WAAW,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnF;AAcD;oFACoF;AACpF,iBAAS,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ3D;AAED;;;wCAGwC;AACxC,iBAAS,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBtE;AAED,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;CAA2C,CAAA"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,8CAA8C,CAAA;AACxG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAqC3C,2EAA2E;AAC3E,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAGnC;AAED;;;;GAIG;AACH,iBAAe,WAAW,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnF;AAcD;oFACoF;AACpF,iBAAS,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ3D;AAED;;;wCAGwC;AACxC,iBAAS,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBtE;AAED,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;CAA2C,CAAA"}
package/dist/parser.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
- import { Language, Parser as TreeSitter } from 'web-tree-sitter';
3
+ // web-tree-sitter is vendored (scripts/regen-web-tree-sitter.mjs), not a runtime dependency. The glue
4
+ // self-locates its wasm sibling via `import.meta.url`, so importing the vendored file is all it needs
5
+ // — no peer, no `locateFile`.
6
+ import { Language, Parser as TreeSitter } from '../vendor/web-tree-sitter/web-tree-sitter.js';
4
7
  import { assert } from './assert.js';
5
8
  /**
6
9
  * Every built-in grammar ships **vendored** as wasm under `wasm/`, so a consumer of `@codegraft/*`
@@ -12,7 +15,7 @@ import { assert } from './assert.js';
12
15
  * - `tsx` — rebuilt from `tree-sitter-typescript`'s grammar source, because its npm wasm is ABI-14
13
16
  * and loads without the supertype metadata `find('expression')` needs; see `scripts/regen-ts-wasm.sh`.
14
17
  * - `html`/`css` — copied verbatim from their npm packages (already ABI-current with supertypes);
15
- * see `scripts/regen-builtin-wasm.sh`.
18
+ * see `scripts/regen-builtin-wasm.mjs`.
16
19
  * - `yaml` — vendored from `@tree-sitter-grammars/tree-sitter-yaml` (the bare package ships no wasm).
17
20
  */
18
21
  const VENDORED_WASM = {
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGhE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC;;;;;;;;;;;;GAYG;AACH,MAAM,aAAa,GAAuC;IACxD,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,uBAAuB;IAC7B,GAAG,EAAE,sBAAsB;IAC3B,IAAI,EAAE,uBAAuB;CAC9B,CAAA;AAED;;;mGAGmG;AACnG,SAAS,cAAc,CAAC,EAAsB;IAC5C,OAAO,EAAE,KAAK,YAAY,IAAI,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAChE,CAAC;AAED,IAAI,WAAW,GAAyB,IAAI,CAAA;AAC5C,IAAI,MAAM,GAAsB,IAAI,CAAA;AACpC,MAAM,SAAS,GAAG,IAAI,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H,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { Node } from 'web-tree-sitter';
1
+ import type { Node } from '../vendor/web-tree-sitter/web-tree-sitter.js';
2
2
  import type { GrammarId, RichNode } from './types.js';
3
3
  /** Wrap a parsed tree's root. Children are created lazily as the tree is walked. */
4
4
  export declare function wrapNode(node: Node, language: GrammarId, startOffset: number): RichNode;
@@ -1 +1 @@
1
- {"version":3,"file":"rich-node.d.ts","sourceRoot":"","sources":["../src/rich-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAwG5D,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ,CAEvF"}
1
+ {"version":3,"file":"rich-node.d.ts","sourceRoot":"","sources":["../src/rich-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8CAA8C,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAwG5D,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ,CAEvF"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { NodeTypeAll, FieldName } from './generated/node-types.js';
2
- import type { FormatOptions } from './format.js';
3
2
  /**
4
3
  * A real tree-sitter grammar. SFC *file formats* have no id of their own — a {@link ZoneSplitter}
5
4
  * maps each section to one of these. `'vue'` is the exception: it is a real tree-sitter grammar
@@ -99,15 +98,15 @@ export interface SourceMap {
99
98
  * and is constrained to a record so it can flow into the body and `transform(src, ctx)`.
100
99
  */
101
100
  export interface Transformer<Ctx extends Record<string, unknown> = Record<string, unknown>> {
102
- /** Apply the codemod to `source`. The recorded edits are always rendered indentation-aware
103
- * inserts re-indented to the file's unit/EOL, a removed node's line collapsed — keyed off the
104
- * source's detected style; `options` overrides that detection per apply (see {@link FormatOptions}). */
105
- transform(source: string, context: Ctx, options?: FormatOptions): string;
101
+ /** Apply the codemod to `source`. Edits are rendered just enough to stay syntactically valid an
102
+ * inserted snippet re-indented to its anchor line (EOL detected from the source), an appended
103
+ * element given its container's separator. Cosmetic layout is a downstream formatter's job. */
104
+ transform(source: string, context: Ctx): string;
106
105
  /** Like {@link transform} but also returns a source map (`options.source` names the input in the
107
106
  * map). Used by build-pipeline integrations such as `@codegraft/unplugin`. */
108
107
  transformWithMap(source: string, context: Ctx, options?: {
109
108
  source?: string;
110
- } & FormatOptions): {
109
+ }): {
111
110
  code: string;
112
111
  map: SourceMap;
113
112
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAA;AAE7F,4DAA4D;AAC5D,MAAM,MAAM,KAAK,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MA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EAAE,MAAM,CAAA;IAChB,QAAQ,IAAI,MAAM,CAAA;IAClB,KAAK,IAAI,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxF;;oGAEgG;IAChG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,CAAA;IAC/C;mFAC+E;IAC/E,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAA;CAChH;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5F,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY,CAAA;IACzC,2DAA2D;IAC3D,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;CAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codegraft/core",
3
- "version": "0.1.0-beta.11",
3
+ "version": "0.1.0-beta.13",
4
4
  "description": "Tree-sitter runtime for Codegraft: parser, RichNode, comment attachment, zone splitting, the Collection, scope resolver, and edit application.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,7 +14,8 @@
14
14
  "bugs": "https://github.com/magne4000/codegraft/issues",
15
15
  "files": [
16
16
  "dist",
17
- "wasm"
17
+ "wasm",
18
+ "vendor/web-tree-sitter"
18
19
  ],
19
20
  "exports": {
20
21
  ".": {
@@ -30,18 +31,19 @@
30
31
  "node": ">=22.13"
31
32
  },
32
33
  "dependencies": {
33
- "magic-string": "^0.30.0",
34
- "web-tree-sitter": "^0.26.9"
34
+ "magic-string": "^0.30.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "tree-sitter-css": "^0.25.0",
38
38
  "tree-sitter-html": "^0.23.0",
39
- "tree-sitter-javascript": "^0.25.0"
39
+ "tree-sitter-javascript": "^0.25.0",
40
+ "web-tree-sitter": "^0.26.9"
40
41
  },
41
42
  "scripts": {
42
43
  "build": "tsc -b",
43
44
  "regen-ts-wasm": "bash scripts/regen-ts-wasm.sh",
44
- "regen-builtin-wasm": "bash scripts/regen-builtin-wasm.sh",
45
+ "regen-builtin-wasm": "node scripts/regen-builtin-wasm.mjs",
46
+ "regen-web-tree-sitter": "node scripts/regen-web-tree-sitter.mjs",
45
47
  "regen-node-types": "node scripts/regen-node-types.mjs"
46
48
  }
47
49
  }
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2026-present Joël Charles
3
+ Copyright (c) 2018 Max Brunsfeld
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal