sh-ast 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +199 -143
  2. package/dist/analyze/ansi-c-escapes.d.ts +1 -1
  3. package/dist/analyze/ansi-c-escapes.js +1 -1
  4. package/dist/analyze/enumerate-commands.d.ts +11 -16
  5. package/dist/analyze/enumerate-commands.d.ts.map +1 -1
  6. package/dist/analyze/enumerate-commands.js +82 -92
  7. package/dist/analyze/enumerate-commands.js.map +1 -1
  8. package/dist/analyze/index.d.ts +3 -2
  9. package/dist/analyze/index.d.ts.map +1 -1
  10. package/dist/analyze/index.js +1 -1
  11. package/dist/analyze/node-helpers.d.ts +10 -21
  12. package/dist/analyze/node-helpers.d.ts.map +1 -1
  13. package/dist/analyze/node-helpers.js +16 -27
  14. package/dist/analyze/node-helpers.js.map +1 -1
  15. package/dist/analyze/resolve-argv0.d.ts +6 -6
  16. package/dist/analyze/resolve-argv0.js +6 -6
  17. package/dist/analyze/resolve-word.d.ts +7 -10
  18. package/dist/analyze/resolve-word.d.ts.map +1 -1
  19. package/dist/analyze/resolve-word.js +39 -22
  20. package/dist/analyze/resolve-word.js.map +1 -1
  21. package/dist/analyze.d.ts +3780 -397
  22. package/dist/errors.d.ts +6 -79
  23. package/dist/errors.d.ts.map +1 -1
  24. package/dist/errors.js +5 -64
  25. package/dist/errors.js.map +1 -1
  26. package/dist/index.d.ts +20 -14
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +26 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/sh-ast.d.ts +3616 -1020
  31. package/dist/syntax-errors.d.ts +56 -0
  32. package/dist/syntax-errors.d.ts.map +1 -0
  33. package/dist/syntax-errors.js +80 -0
  34. package/dist/syntax-errors.js.map +1 -0
  35. package/dist/syntax-print-errors.d.ts +35 -0
  36. package/dist/syntax-print-errors.d.ts.map +1 -0
  37. package/dist/syntax-print-errors.js +37 -0
  38. package/dist/syntax-print-errors.js.map +1 -0
  39. package/dist/syntax-print.d.ts +49 -0
  40. package/dist/syntax-print.d.ts.map +1 -0
  41. package/dist/syntax-print.js +86 -0
  42. package/dist/syntax-print.js.map +1 -0
  43. package/dist/syntax-snapshot.d.ts +47 -0
  44. package/dist/syntax-snapshot.d.ts.map +1 -0
  45. package/dist/syntax-snapshot.js +121 -0
  46. package/dist/syntax-snapshot.js.map +1 -0
  47. package/dist/syntax-walk-bounds.d.ts +18 -0
  48. package/dist/syntax-walk-bounds.d.ts.map +1 -0
  49. package/dist/syntax-walk-bounds.js +188 -0
  50. package/dist/syntax-walk-bounds.js.map +1 -0
  51. package/dist/syntax-walk-errors.d.ts +19 -0
  52. package/dist/syntax-walk-errors.d.ts.map +1 -0
  53. package/dist/syntax-walk-errors.js +23 -0
  54. package/dist/syntax-walk-errors.js.map +1 -0
  55. package/dist/syntax-walk-license.d.ts +3 -0
  56. package/dist/syntax-walk-license.d.ts.map +1 -0
  57. package/dist/syntax-walk-license.js +37 -0
  58. package/dist/syntax-walk-license.js.map +1 -0
  59. package/dist/syntax-walk.d.ts +46 -0
  60. package/dist/syntax-walk.d.ts.map +1 -0
  61. package/dist/syntax-walk.js +322 -0
  62. package/dist/syntax-walk.js.map +1 -0
  63. package/dist/syntax-wire.d.ts +31 -0
  64. package/dist/syntax-wire.d.ts.map +1 -0
  65. package/dist/syntax-wire.js +202 -0
  66. package/dist/syntax-wire.js.map +1 -0
  67. package/dist/syntax.d.ts +65 -0
  68. package/dist/syntax.d.ts.map +1 -0
  69. package/dist/syntax.js +152 -0
  70. package/dist/syntax.js.map +1 -0
  71. package/dist/wasm-instance.d.ts +5 -8
  72. package/dist/wasm-instance.d.ts.map +1 -1
  73. package/dist/wasm-instance.js +44 -47
  74. package/dist/wasm-instance.js.map +1 -1
  75. package/generated/syntax-constants.d.ts +1652 -0
  76. package/generated/syntax-constants.js +1384 -0
  77. package/generated/syntax-schema.d.ts +60 -0
  78. package/generated/syntax-schema.js +1740 -0
  79. package/generated/syntax-types.d.ts +1977 -0
  80. package/package.json +2 -2
  81. package/shim/sh-ast.wasm +0 -0
  82. package/dist/normalize.d.ts +0 -52
  83. package/dist/normalize.d.ts.map +0 -1
  84. package/dist/normalize.js +0 -260
  85. package/dist/normalize.js.map +0 -1
  86. package/dist/parse.d.ts +0 -50
  87. package/dist/parse.d.ts.map +0 -1
  88. package/dist/parse.js +0 -125
  89. package/dist/parse.js.map +0 -1
  90. package/dist/types.d.ts +0 -74
  91. package/dist/types.d.ts.map +0 -1
  92. package/dist/types.js +0 -2
  93. package/dist/types.js.map +0 -1
  94. package/dist/visitor-keys.d.ts +0 -21
  95. package/dist/visitor-keys.d.ts.map +0 -1
  96. package/dist/visitor-keys.js +0 -23
  97. package/dist/visitor-keys.js.map +0 -1
  98. package/dist/walk.d.ts +0 -18
  99. package/dist/walk.d.ts.map +0 -1
  100. package/dist/walk.js +0 -40
  101. package/dist/walk.js.map +0 -1
  102. package/generated/child-type-schema.d.ts +0 -14
  103. package/generated/child-type-schema.js +0 -188
  104. package/generated/node-types.d.ts +0 -1002
  105. package/generated/position-fields.d.ts +0 -21
  106. package/generated/position-fields.js +0 -50
  107. package/generated/visitor-keys.d.ts +0 -11
  108. package/generated/visitor-keys.js +0 -50
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Error adaptation for the upstream syntax interface. Exceptions retain the Go
3
+ * error's structured information and partial result; JavaScript's display message
4
+ * is never the only copy of a byte-bearing upstream value.
5
+ */
6
+ import type { File, GoString, SyntaxPos } from '../generated/syntax-types.js';
7
+ import { ShAstError } from './errors.js';
8
+ /**
9
+ * A source grammar error reported by mvdan/sh, with the partial parsed file.
10
+ * @public
11
+ */
12
+ export declare class ParseError extends ShAstError {
13
+ readonly Message: GoString;
14
+ readonly Filename: GoString;
15
+ readonly Pos: SyntaxPos;
16
+ readonly Text: GoString;
17
+ readonly Incomplete: boolean;
18
+ readonly File: File | null;
19
+ /** Identifies a source grammar failure independently of its display text. */
20
+ readonly code = "SH_AST_SYNTAX_PARSE";
21
+ /**
22
+ * Keeps the original Go fields. Message is the formatted upstream error;
23
+ * Text is its unformatted diagnostic, and File is the result returned with it.
24
+ */
25
+ constructor(Message: GoString, Filename: GoString, Pos: SyntaxPos, Text: GoString, Incomplete: boolean, File: File | null);
26
+ }
27
+ /**
28
+ * A syntax feature rejected for the selected upstream language variant.
29
+ * @public
30
+ */
31
+ export declare class LangError extends ShAstError {
32
+ readonly Message: GoString;
33
+ readonly Filename: GoString;
34
+ readonly Pos: SyntaxPos;
35
+ readonly Feature: GoString;
36
+ readonly Langs: readonly number[];
37
+ readonly LangUsed: number;
38
+ readonly File: File | null;
39
+ /** Identifies a dialect-specific syntax failure. */
40
+ readonly code = "SH_AST_SYNTAX_LANG";
41
+ /** Preserves the feature, permitted variants, actual variant and partial tree. */
42
+ constructor(Message: GoString, Filename: GoString, Pos: SyntaxPos, Feature: GoString, Langs: readonly number[], LangUsed: number, File: File | null);
43
+ }
44
+ /**
45
+ * An argument cannot be represented by the binding or violates an upstream
46
+ * operation's input constraint. It is distinct from malformed shell source.
47
+ * @public
48
+ */
49
+ export declare class InputError extends ShAstError {
50
+ readonly Message: GoString;
51
+ /** Identifies caller input that cannot be passed faithfully to the operation. */
52
+ readonly code = "SH_AST_SYNTAX_INPUT";
53
+ /** Retains exact upstream message bytes even when Error.message needs text. */
54
+ constructor(Message: GoString);
55
+ }
56
+ //# sourceMappingURL=syntax-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-errors.d.ts","sourceRoot":"","sources":["../src/syntax-errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,qBAAa,UAAW,SAAQ,UAAU;IAStC,QAAQ,CAAC,OAAO,EAAE,Q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Q;CAIvC"}
@@ -0,0 +1,80 @@
1
+ import { ShAstError } from './errors.js';
2
+ /**
3
+ * A source grammar error reported by mvdan/sh, with the partial parsed file.
4
+ * @public
5
+ */
6
+ export class ParseError extends ShAstError {
7
+ Message;
8
+ Filename;
9
+ Pos;
10
+ Text;
11
+ Incomplete;
12
+ File;
13
+ /** Identifies a source grammar failure independently of its display text. */
14
+ code = 'SH_AST_SYNTAX_PARSE';
15
+ /**
16
+ * Keeps the original Go fields. Message is the formatted upstream error;
17
+ * Text is its unformatted diagnostic, and File is the result returned with it.
18
+ */
19
+ constructor(Message, Filename, Pos, Text, Incomplete, File) {
20
+ super(displayMessage(Message));
21
+ this.Message = Message;
22
+ this.Filename = Filename;
23
+ this.Pos = Pos;
24
+ this.Text = Text;
25
+ this.Incomplete = Incomplete;
26
+ this.File = File;
27
+ this.name = 'ParseError';
28
+ }
29
+ }
30
+ /**
31
+ * A syntax feature rejected for the selected upstream language variant.
32
+ * @public
33
+ */
34
+ export class LangError extends ShAstError {
35
+ Message;
36
+ Filename;
37
+ Pos;
38
+ Feature;
39
+ Langs;
40
+ LangUsed;
41
+ File;
42
+ /** Identifies a dialect-specific syntax failure. */
43
+ code = 'SH_AST_SYNTAX_LANG';
44
+ /** Preserves the feature, permitted variants, actual variant and partial tree. */
45
+ constructor(Message, Filename, Pos, Feature, Langs, LangUsed, File) {
46
+ super(displayMessage(Message));
47
+ this.Message = Message;
48
+ this.Filename = Filename;
49
+ this.Pos = Pos;
50
+ this.Feature = Feature;
51
+ this.Langs = Langs;
52
+ this.LangUsed = LangUsed;
53
+ this.File = File;
54
+ this.name = 'LangError';
55
+ }
56
+ }
57
+ /**
58
+ * An argument cannot be represented by the binding or violates an upstream
59
+ * operation's input constraint. It is distinct from malformed shell source.
60
+ * @public
61
+ */
62
+ export class InputError extends ShAstError {
63
+ Message;
64
+ /** Identifies caller input that cannot be passed faithfully to the operation. */
65
+ code = 'SH_AST_SYNTAX_INPUT';
66
+ /** Retains exact upstream message bytes even when Error.message needs text. */
67
+ constructor(Message) {
68
+ super(displayMessage(Message));
69
+ this.Message = Message;
70
+ this.name = 'InputError';
71
+ }
72
+ }
73
+ /**
74
+ * Error.message is a human-readable rendering only. The public Message property
75
+ * retains original bytes when the Go value is not valid UTF-8.
76
+ */
77
+ function displayMessage(value) {
78
+ return typeof value === 'string' ? value : new TextDecoder().decode(value);
79
+ }
80
+ //# sourceMappingURL=syntax-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-errors.js","sourceRoot":"","sources":["../src/syntax-errors.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAS7B;IACA;IACA;IACA;IACA;IACA;IAbX,6EAA6E;IACpE,IAAI,GAAG,qBAAqB,CAAC;IAEtC;;;OAGG;IACH,YACW,OAAiB,EACjB,QAAkB,EAClB,GAAc,EACd,IAAc,EACd,UAAmB,EACnB,IAAiB;QAE1B,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QAPtB,YAAO,GAAP,OAAO,CAAU;QACjB,aAAQ,GAAR,QAAQ,CAAU;QAClB,QAAG,GAAH,GAAG,CAAW;QACd,SAAI,GAAJ,IAAI,CAAU;QACd,eAAU,GAAV,UAAU,CAAS;QACnB,SAAI,GAAJ,IAAI,CAAa;QAG1B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAM5B;IACA;IACA;IACA;IACA;IACA;IACA;IAXX,oDAAoD;IAC3C,IAAI,GAAG,oBAAoB,CAAC;IAErC,kFAAkF;IAClF,YACW,OAAiB,EACjB,QAAkB,EAClB,GAAc,EACd,OAAiB,EACjB,KAAwB,EACxB,QAAgB,EAChB,IAAiB;QAE1B,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QARtB,YAAO,GAAP,OAAO,CAAU;QACjB,aAAQ,GAAR,QAAQ,CAAU;QAClB,QAAG,GAAH,GAAG,CAAW;QACd,YAAO,GAAP,OAAO,CAAU;QACjB,UAAK,GAAL,KAAK,CAAmB;QACxB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,SAAI,GAAJ,IAAI,CAAa;QAG1B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAKnB;IAJrB,iFAAiF;IACxE,IAAI,GAAG,qBAAqB,CAAC;IAEtC,+EAA+E;IAC/E,YAAqB,OAAiB;QACpC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QADZ,YAAO,GAAP,OAAO,CAAU;QAEpC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,KAAe;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Printing has two upstream failure modes: returned errors and panics raised by
3
+ * the operation. Both retain exact message bytes; neither is a parser failure
4
+ * or a claim that the transport itself malfunctioned.
5
+ */
6
+ import type { GoString } from '../generated/syntax-types.js';
7
+ import { ShAstError } from './errors.js';
8
+ /**
9
+ * An error returned by upstream Printer.Print, such as an unsupported root or
10
+ * incompatible formatting options. No partial writer output is exposed.
11
+ * @public
12
+ */
13
+ export declare class PrintError extends ShAstError {
14
+ /** Stable identity for an ordinary error returned by upstream Print. @public */
15
+ readonly code = "SH_AST_SYNTAX_PRINT";
16
+ /** Exact upstream error bytes; Error.message is only a display rendering. @public */
17
+ readonly Message: GoString;
18
+ /** Retains the upstream error without interpreting its human-readable text. @public */
19
+ constructor(message: GoString);
20
+ }
21
+ /**
22
+ * Upstream Printer.Print panicked for a representable tree or option value.
23
+ * Partial and typed-nil trees can trigger this independently of root support.
24
+ * Catching the panic preserves reuse of the binding's shared runtime.
25
+ * @public
26
+ */
27
+ export declare class PrintPanicError extends ShAstError {
28
+ /** Stable identity for an upstream panic caught at the Print operation. @public */
29
+ readonly code = "SH_AST_SYNTAX_PRINT_PANIC";
30
+ /** Exact panic rendering from Go; Error.message is only a display rendering. @public */
31
+ readonly Message: GoString;
32
+ /** Retains the panic message separately from ordinary returned Print errors. @public */
33
+ constructor(message: GoString);
34
+ }
35
+ //# sourceMappingURL=syntax-print-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-print-errors.d.ts","sourceRoot":"","sources":["../src/syntax-print-errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,gFAAgF;IAChF,QAAQ,CAAC,IAAI,yBAAyB;IAEtC,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAE3B,uFAAuF;gBAC3E,OAAO,EAAE,QAAQ;CAK9B;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,mFAAmF;IACnF,QAAQ,CAAC,IAAI,+BAA+B;IAE5C,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAE3B,wFAAwF;gBAC5E,OAAO,EAAE,QAAQ;CAK9B"}
@@ -0,0 +1,37 @@
1
+ import { ShAstError } from './errors.js';
2
+ /**
3
+ * An error returned by upstream Printer.Print, such as an unsupported root or
4
+ * incompatible formatting options. No partial writer output is exposed.
5
+ * @public
6
+ */
7
+ export class PrintError extends ShAstError {
8
+ /** Stable identity for an ordinary error returned by upstream Print. @public */
9
+ code = 'SH_AST_SYNTAX_PRINT';
10
+ /** Exact upstream error bytes; Error.message is only a display rendering. @public */
11
+ Message;
12
+ /** Retains the upstream error without interpreting its human-readable text. @public */
13
+ constructor(message) {
14
+ super(typeof message === 'string' ? message : new TextDecoder().decode(message));
15
+ this.Message = message;
16
+ this.name = 'PrintError';
17
+ }
18
+ }
19
+ /**
20
+ * Upstream Printer.Print panicked for a representable tree or option value.
21
+ * Partial and typed-nil trees can trigger this independently of root support.
22
+ * Catching the panic preserves reuse of the binding's shared runtime.
23
+ * @public
24
+ */
25
+ export class PrintPanicError extends ShAstError {
26
+ /** Stable identity for an upstream panic caught at the Print operation. @public */
27
+ code = 'SH_AST_SYNTAX_PRINT_PANIC';
28
+ /** Exact panic rendering from Go; Error.message is only a display rendering. @public */
29
+ Message;
30
+ /** Retains the panic message separately from ordinary returned Print errors. @public */
31
+ constructor(message) {
32
+ super(typeof message === 'string' ? message : new TextDecoder().decode(message));
33
+ this.Message = message;
34
+ this.name = 'PrintPanicError';
35
+ }
36
+ }
37
+ //# sourceMappingURL=syntax-print-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-print-errors.js","sourceRoot":"","sources":["../src/syntax-print-errors.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACxC,gFAAgF;IACvE,IAAI,GAAG,qBAAqB,CAAC;IAEtC,qFAAqF;IAC5E,OAAO,CAAW;IAE3B,uFAAuF;IACvF,YAAY,OAAiB;QAC3B,KAAK,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,mFAAmF;IAC1E,IAAI,GAAG,2BAA2B,CAAC;IAE5C,wFAAwF;IAC/E,OAAO,CAAW;IAE3B,wFAAwF;IACxF,YAAY,OAAiB;QAC3B,KAAK,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Collected-output access to upstream Printer.Print. The reverse codec rebuilds
3
+ * the current faithful tree, and Go owns formatting decisions. This module has
4
+ * no source cache, parser round trip, writer callbacks, or reusable printer state.
5
+ */
6
+ import type { GoString, Node } from '../generated/syntax-types.js';
7
+ /**
8
+ * Upstream NewPrinter controls applied to a fresh printer for each call. All
9
+ * flags default to false; zero indentation selects tabs. The pinned WASM uint
10
+ * domain is 64-bit, so Indent accepts bigint beyond JavaScript's safe integers.
11
+ * @public
12
+ */
13
+ export interface PrintOptions {
14
+ /** Spaces per level, or zero for tabs. Large values can request expensive output. */
15
+ Indent?: number | bigint;
16
+ /** Places multiline binary operators on the next line with a backslash continuation. */
17
+ BinaryNextLine?: boolean;
18
+ /** Indents case alternatives, placing their bodies two levels below the case clause. */
19
+ SwitchCaseIndent?: boolean;
20
+ /** Adds space after redirection operators except `>&`, `<&`, `>(` and `<(`. */
21
+ SpaceRedirects?: boolean;
22
+ /**
23
+ * Preserves token columns on a best-effort basis.
24
+ * @deprecated Upstream marks this option as flawed and plans removal in v4.
25
+ */
26
+ KeepPadding?: boolean;
27
+ /** Omits comments, indentation and optional whitespace. Incompatible with SingleLine. */
28
+ Minify?: boolean;
29
+ /** Reduces newlines except where comments, heredocs or File output require them. */
30
+ SingleLine?: boolean;
31
+ /** Places a function's opening brace on the next line. */
32
+ FunctionNextLine?: boolean;
33
+ }
34
+ /**
35
+ * Formats the current tree with a fresh upstream printer and collects all output.
36
+ * Supported roots are File, Stmt, Word, Assign, Command and WordPart; other Nodes
37
+ * produce PrintError. Only File output has upstream's trailing-newline behavior.
38
+ * Invalid UTF-8 output remains bytes. Upstream formatting can itself consume
39
+ * input bytes, including its tabwriter escape byte, so this is not source replay.
40
+ *
41
+ * InputError identifies unrepresentable input; PrintError is an ordinary returned
42
+ * upstream error; PrintPanicError retains an upstream operation panic. No partial
43
+ * output or arbitrary writer lifecycle is exposed. Full tree reconstruction and
44
+ * collected output require memory proportional to the values involved; extreme
45
+ * indentation or tree size is not made resource-safe by panic adaptation.
46
+ * @public
47
+ */
48
+ export declare function printSync(node: Node, options?: PrintOptions): GoString;
49
+ //# sourceMappingURL=syntax-print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-print.d.ts","sourceRoot":"","sources":["../src/syntax-print.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAOnE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wFAAwF;IACxF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yFAAyF;IACzF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,QAAQ,CAoC1E"}
@@ -0,0 +1,86 @@
1
+ import { ShInternalError } from './errors.js';
2
+ import { InputError } from './syntax-errors.js';
3
+ import { PrintError, PrintPanicError } from './syntax-print-errors.js';
4
+ import { decodeWire, encodeWire, isGoString, isRecord, isSyntaxNode } from './syntax-wire.js';
5
+ import { callSyntax } from './wasm-instance.js';
6
+ /**
7
+ * Formats the current tree with a fresh upstream printer and collects all output.
8
+ * Supported roots are File, Stmt, Word, Assign, Command and WordPart; other Nodes
9
+ * produce PrintError. Only File output has upstream's trailing-newline behavior.
10
+ * Invalid UTF-8 output remains bytes. Upstream formatting can itself consume
11
+ * input bytes, including its tabwriter escape byte, so this is not source replay.
12
+ *
13
+ * InputError identifies unrepresentable input; PrintError is an ordinary returned
14
+ * upstream error; PrintPanicError retains an upstream operation panic. No partial
15
+ * output or arbitrary writer lifecycle is exposed. Full tree reconstruction and
16
+ * collected output require memory proportional to the values involved; extreme
17
+ * indentation or tree size is not made resource-safe by panic adaptation.
18
+ * @public
19
+ */
20
+ export function printSync(node, options = {}) {
21
+ validatePrintOptions(options);
22
+ if (!isSyntaxNode(node)) {
23
+ throw new InputError('Expected a complete, acyclic upstream Node record');
24
+ }
25
+ const payload = new TextEncoder().encode(encodeWire(node));
26
+ const result = decodeWire(callSyntax('print', payload, encodeWire(options)));
27
+ if (!isRecord(result)) {
28
+ throw new ShInternalError('The syntax printer returned a non-record response');
29
+ }
30
+ if (result.Error !== undefined) {
31
+ const error = result.Error;
32
+ if (!isRecord(error) || !isGoString(error.Message)) {
33
+ throw new ShInternalError('The syntax printer returned a malformed error');
34
+ }
35
+ switch (error.Kind) {
36
+ case 'PrintError':
37
+ throw new PrintError(error.Message);
38
+ case 'PrintPanicError':
39
+ throw new PrintPanicError(error.Message);
40
+ case 'InputError':
41
+ throw new InputError(error.Message);
42
+ case 'InternalError':
43
+ throw new ShInternalError(typeof error.Message === 'string'
44
+ ? error.Message
45
+ : new TextDecoder().decode(error.Message));
46
+ default:
47
+ throw new ShInternalError('The syntax printer returned an unknown error kind');
48
+ }
49
+ }
50
+ if (!isGoString(result.Output)) {
51
+ throw new ShInternalError('The syntax printer returned an invalid output value');
52
+ }
53
+ return result.Output;
54
+ }
55
+ /** Validates exact option domains without imposing a formatting or indentation policy. */
56
+ function validatePrintOptions(options) {
57
+ if (!isRecord(options)) {
58
+ throw new InputError('Printer options must be a data record');
59
+ }
60
+ const flags = new Set([
61
+ 'BinaryNextLine',
62
+ 'SwitchCaseIndent',
63
+ 'SpaceRedirects',
64
+ 'KeepPadding',
65
+ 'Minify',
66
+ 'SingleLine',
67
+ 'FunctionNextLine',
68
+ ]);
69
+ for (const [name, value] of Object.entries(options)) {
70
+ if (name === 'Indent') {
71
+ const valid = typeof value === 'bigint'
72
+ ? value >= 0n && value <= 0xffffffffffffffffn
73
+ : typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
74
+ if (!valid) {
75
+ throw new InputError('Indent must be a safe nonnegative integer or uint64 bigint');
76
+ }
77
+ }
78
+ else if (!flags.has(name)) {
79
+ throw new InputError(`Unknown printer option: ${name}`);
80
+ }
81
+ else if (typeof value !== 'boolean') {
82
+ throw new InputError(`${name} must be boolean`);
83
+ }
84
+ }
85
+ }
86
+ //# sourceMappingURL=syntax-print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-print.js","sourceRoot":"","sources":["../src/syntax-print.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAA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IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,UAAU,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,kBAAkB,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { File, Node, SyntaxPos } from '../generated/syntax-types.js';
2
+ /**
3
+ * A node's upstream bounds as observed during parsing. These values refer to the
4
+ * original source, even when the corresponding syntax record is later edited.
5
+ * @public
6
+ */
7
+ export interface NodePositions {
8
+ /** Starting byte position observed for the original parsed node. */
9
+ readonly Pos: Readonly<SyntaxPos>;
10
+ /** Exclusive ending byte position observed for the original parsed node. */
11
+ readonly End: Readonly<SyntaxPos>;
12
+ }
13
+ /**
14
+ * Identity-based lookup of the original parse's bounds. A new or copied node has
15
+ * no observation. The index never calls WASM or recalculates edited node bounds.
16
+ * @public
17
+ */
18
+ export interface PositionSnapshot {
19
+ /**
20
+ * Returns the captured pair for a node from this parse, or undefined for a
21
+ * foreign node. If either upstream observation failed, throws the captured
22
+ * InputError without changing the successfully parsed File. Use nodePos or
23
+ * nodeEnd to request a live, independent bound from current edited fields.
24
+ */
25
+ get(node: Node): NodePositions | undefined;
26
+ }
27
+ /**
28
+ * Mutable upstream syntax together with a separate source-bound position view.
29
+ * Editing File never updates Positions; source consumers can retain original
30
+ * spans while transformations query live nodePos/nodeEnd as needed.
31
+ * @public
32
+ */
33
+ export interface ParsedFile {
34
+ /** The complete mutable upstream File; no bounds or consumer fields are added. */
35
+ readonly File: File;
36
+ /** Immutable original observations, keyed by this File's node identities. */
37
+ readonly Positions: PositionSnapshot;
38
+ }
39
+ /**
40
+ * Validates complete sidecar coverage once, then stores immutable observations in
41
+ * a weak identity map. Missing or duplicate metadata is a transport defect; no
42
+ * per-node live-position fallback may disguise it or multiply WASM transfers.
43
+ * The File must already have passed the full syntax boundary validator.
44
+ * @internal
45
+ */
46
+ export declare function createPositionSnapshot(file: File, raw: unknown): PositionSnapshot;
47
+ //# sourceMappingURL=syntax-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-snapshot.d.ts","sourceRoot":"","sources":["../src/syntax-snapshot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAY,IAAI,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAKpF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,GAAG,SAAS,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;CACtC;AAgED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAmDjF"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Correlates parse-time upstream position observations with the decoded syntax
3
+ * records. Snapshots belong to one parse and never track later edits; live
4
+ * nodePos/nodeEnd remain a separate responsibility. No traversal order or
5
+ * visitor-control protocol is exposed by this lookup-only view.
6
+ */
7
+ import { SYNTAX_INTERFACES, SYNTAX_SCHEMA } from '../generated/syntax-schema.js';
8
+ import { ShInternalError } from './errors.js';
9
+ import { InputError } from './syntax-errors.js';
10
+ import { isGoString, isRecord, isSyntaxPos } from './syntax-wire.js';
11
+ /**
12
+ * Checks only node identity within an already fully validated File. Revalidating
13
+ * each subtree here would reintroduce work proportional to all descendant sizes.
14
+ */
15
+ function isNodeIdentity(value) {
16
+ return ((typeof value.Type === 'string' && SYNTAX_INTERFACES.Node.includes(value.Type)) ||
17
+ (value.Type === 'TypedNil' &&
18
+ typeof value.Kind === 'string' &&
19
+ SYNTAX_INTERFACES.Node.includes(value.Kind)));
20
+ }
21
+ /**
22
+ * Indexes child-bearing fields once, including paths through auxiliary records.
23
+ * Metadata order is irrelevant: paths correlate observations without inventing a
24
+ * Walk order or equating auxiliary records with syntax.Node values.
25
+ */
26
+ function nodesByPath(file) {
27
+ const nodes = new Map();
28
+ const visit = (value, path) => {
29
+ if (!isRecord(value) || typeof value.Type !== 'string')
30
+ return;
31
+ if (isNodeIdentity(value))
32
+ nodes.set(JSON.stringify(path), value);
33
+ if (!Object.hasOwn(SYNTAX_SCHEMA, value.Type))
34
+ return;
35
+ for (const [name, field] of Object.entries(SYNTAX_SCHEMA[value.Type].fields)) {
36
+ if (field.kind !== 'struct' && field.kind !== 'interface')
37
+ continue;
38
+ const child = value[name];
39
+ if (Array.isArray(child)) {
40
+ child.forEach((item, index) => {
41
+ visit(item, [...path, name, index]);
42
+ });
43
+ }
44
+ else {
45
+ visit(child, [...path, name]);
46
+ }
47
+ }
48
+ };
49
+ visit(file, []);
50
+ return nodes;
51
+ }
52
+ /** Accepts the exact field/index domain used by the upstream observation sidecar. */
53
+ function isPath(value) {
54
+ return (Array.isArray(value) &&
55
+ value.every((component) => typeof component === 'string' ||
56
+ (typeof component === 'number' && Number.isSafeInteger(component) && component >= 0)));
57
+ }
58
+ /** An upstream method produced exactly one position or one preserved failure. */
59
+ function isObservation(position, error) {
60
+ return (isSyntaxPos(position) && error === null) || (position === null && isGoString(error));
61
+ }
62
+ /**
63
+ * Validates complete sidecar coverage once, then stores immutable observations in
64
+ * a weak identity map. Missing or duplicate metadata is a transport defect; no
65
+ * per-node live-position fallback may disguise it or multiply WASM transfers.
66
+ * The File must already have passed the full syntax boundary validator.
67
+ * @internal
68
+ */
69
+ export function createPositionSnapshot(file, raw) {
70
+ const nodes = nodesByPath(file);
71
+ if (!Array.isArray(raw) || raw.length !== nodes.size)
72
+ throw new ShInternalError('The syntax snapshot does not cover every parsed node');
73
+ const observations = new WeakMap();
74
+ const remaining = new Map(nodes);
75
+ for (const entry of raw) {
76
+ if (!isRecord(entry) ||
77
+ Object.keys(entry).length !== 5 ||
78
+ !isPath(entry.Path) ||
79
+ !isObservation(entry.Pos, entry.PosError) ||
80
+ !isObservation(entry.End, entry.EndError)) {
81
+ throw new ShInternalError('The syntax snapshot contains an invalid position observation');
82
+ }
83
+ const path = JSON.stringify(entry.Path);
84
+ const node = remaining.get(path);
85
+ if (node === undefined)
86
+ throw new ShInternalError('The syntax snapshot contains an unknown or duplicate node path');
87
+ remaining.delete(path);
88
+ if (isGoString(entry.PosError)) {
89
+ observations.set(node, { error: entry.PosError });
90
+ }
91
+ else if (isGoString(entry.EndError)) {
92
+ observations.set(node, { error: entry.EndError });
93
+ }
94
+ else if (isSyntaxPos(entry.Pos) && isSyntaxPos(entry.End)) {
95
+ observations.set(node, {
96
+ positions: Object.freeze({
97
+ Pos: Object.freeze({ ...entry.Pos }),
98
+ End: Object.freeze({ ...entry.End }),
99
+ }),
100
+ });
101
+ }
102
+ else {
103
+ throw new ShInternalError('The syntax snapshot dropped an upstream method outcome');
104
+ }
105
+ }
106
+ if (remaining.size !== 0)
107
+ throw new ShInternalError('The syntax snapshot omitted parsed node observations');
108
+ return Object.freeze({
109
+ get(node) {
110
+ const observation = observations.get(node);
111
+ if (observation === undefined)
112
+ return undefined;
113
+ if ('error' in observation) {
114
+ // An exception may be edited by its catcher; retain the captured bytes.
115
+ throw new InputError(typeof observation.error === 'string' ? observation.error : observation.error.slice());
116
+ }
117
+ return observation.positions;
118
+ },
119
+ });
120
+ }
121
+ //# sourceMappingURL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AAC;YACJ,CAAC;YACD,OAAO,WAAW,CAAC,SAAS,CAAC;QAC/B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Private live boundary evaluation for Walk's comment placement. These methods
3
+ * mirror the pinned mvdan/sh node methods so callback edits are visible without
4
+ * repeatedly serializing subtrees to WASM. They are not public position APIs.
5
+ *
6
+ * Adapted from mvdan.cc/sh/v3 v3.13.1 syntax/nodes.go, copyright Daniel Martí.
7
+ * The upstream BSD license is retained in syntax-walk-license.ts.
8
+ */
9
+ import type { Node, SyntaxPos } from '../generated/syntax-types.js';
10
+ /** Stmt comments at or after the live end become the single deferred comment. @internal */
11
+ export declare function atStatementEnd(node: Extract<Node, {
12
+ Type: 'Stmt';
13
+ }>, hash: SyntaxPos): boolean;
14
+ /** Case/array comments strictly after the live start become deferred. @internal */
15
+ export declare function afterItemStart(node: Extract<Node, {
16
+ Type: 'CaseItem' | 'ArrayElem';
17
+ }>, hash: SyntaxPos): boolean;
18
+ //# sourceMappingURL=syntax-walk-bounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-walk-bounds.d.ts","sourceRoot":"","sources":["../src/syntax-walk-bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AA6LpE,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAE9F;AACD,mFAAmF;AACnF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,UAAU,GAAG,WAAW,CAAA;CAAE,CAAC,EACvD,IAAI,EAAE,SAAS,GACd,OAAO,CAET"}