sh-ast 0.1.0 → 0.3.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 (40) hide show
  1. package/dist/analyze/enumerate-commands.d.ts +7 -1
  2. package/dist/analyze/enumerate-commands.d.ts.map +1 -1
  3. package/dist/analyze/enumerate-commands.js +7 -1
  4. package/dist/analyze/enumerate-commands.js.map +1 -1
  5. package/dist/analyze/index.d.ts +12 -4
  6. package/dist/analyze/index.d.ts.map +1 -1
  7. package/dist/analyze/index.js +18 -15
  8. package/dist/analyze/index.js.map +1 -1
  9. package/dist/analyze/resolve-argv0.d.ts +335 -0
  10. package/dist/analyze/resolve-argv0.d.ts.map +1 -0
  11. package/dist/analyze/resolve-argv0.js +510 -0
  12. package/dist/analyze/resolve-argv0.js.map +1 -0
  13. package/dist/analyze/resolve-word.d.ts +5 -0
  14. package/dist/analyze/resolve-word.d.ts.map +1 -1
  15. package/dist/analyze/resolve-word.js +5 -0
  16. package/dist/analyze/resolve-word.js.map +1 -1
  17. package/dist/analyze.d.ts +592 -211
  18. package/dist/errors.d.ts +81 -16
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +90 -17
  21. package/dist/errors.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/parse-depth-guard.d.ts +11 -0
  27. package/dist/parse-depth-guard.d.ts.map +1 -0
  28. package/dist/parse-depth-guard.js +633 -0
  29. package/dist/parse-depth-guard.js.map +1 -0
  30. package/dist/parse.d.ts +7 -2
  31. package/dist/parse.d.ts.map +1 -1
  32. package/dist/parse.js +15 -8
  33. package/dist/parse.js.map +1 -1
  34. package/dist/sh-ast.d.ts +165 -45
  35. package/dist/types.d.ts +5 -1
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/wasm-instance.js +3 -3
  38. package/dist/wasm-instance.js.map +1 -1
  39. package/generated/node-types.d.ts +44 -0
  40. package/package.json +1 -1
package/dist/errors.d.ts CHANGED
@@ -1,18 +1,28 @@
1
1
  import type { ShellDialect } from './types.js';
2
2
  /**
3
3
  * Common base class for every error this package throws — originally just
4
- * {@link parseSync}'s errors, now also the `sh-ast/analyze` layer's (see
5
- * {@link ShAnalyzeMaxDepthError}). Provides a stable, documented `code`
6
- * discriminator (e.g. `"ESLINT_SH_PARSE_ERROR"`) alongside the usual
4
+ * {@link sh-ast#parseSync | parseSync}'s errors, now also the
5
+ * `sh-ast/analyze` layer's (see {@link ShAnalyzeMaxDepthError},
6
+ * {@link ShAnalyzeInvalidWrapperSpecError}). Provides a stable, documented
7
+ * `code` discriminator (e.g. `"SH_AST_PARSE_ERROR"`) alongside the usual
7
8
  * `instanceof` narrowing, so consumers can branch on failure kind
8
- * programmatically without parsing `.message` strings. Never thrown
9
- * directly — only via its concrete subclasses ({@link ShParseError},
10
- * {@link ShInvalidDialectError}, {@link ShBridgeInternalError},
11
- * {@link ShAnalyzeMaxDepthError}).
9
+ * programmatically without parsing `.message` strings. Never thrown directly
10
+ * — only via its concrete subclasses
11
+ * ({@link sh-ast#ShParseError | ShParseError},
12
+ * {@link sh-ast#ShInvalidDialectError | ShInvalidDialectError},
13
+ * {@link sh-ast#ShInternalError | ShInternalError},
14
+ * {@link ShAnalyzeMaxDepthError},
15
+ * {@link sh-ast#ShParseMaxDepthError | ShParseMaxDepthError},
16
+ * {@link ShAnalyzeInvalidWrapperSpecError}).
17
+ *
18
+ * Re-exported from `sh-ast/analyze` as well as the root `sh-ast` entry
19
+ * point (see #23) — every subclass thrown by `sh-ast/analyze`'s own
20
+ * functions extends this, so a consumer of that subpath alone can
21
+ * `catch`/reference the base without also importing from root.
12
22
  *
13
23
  * @public
14
24
  */
15
- export declare abstract class ShBridgeError extends Error {
25
+ export declare abstract class ShAstError extends Error {
16
26
  /**
17
27
  * Stable, machine-readable discriminator for this error kind. Distinct
18
28
  * per subclass and will not change once published.
@@ -51,8 +61,8 @@ export interface ShParseErrorInfo {
51
61
  *
52
62
  * @public
53
63
  */
54
- export declare class ShParseError extends ShBridgeError {
55
- readonly code = "ESLINT_SH_PARSE_ERROR";
64
+ export declare class ShParseError extends ShAstError {
65
+ readonly code = "SH_AST_PARSE_ERROR";
56
66
  readonly line: number;
57
67
  readonly column: number;
58
68
  readonly filename: string;
@@ -66,8 +76,8 @@ export declare class ShParseError extends ShBridgeError {
66
76
  *
67
77
  * @public
68
78
  */
69
- export declare class ShInvalidDialectError extends ShBridgeError {
70
- readonly code = "ESLINT_SH_INVALID_DIALECT";
79
+ export declare class ShInvalidDialectError extends ShAstError {
80
+ readonly code = "SH_AST_INVALID_DIALECT";
71
81
  /** The rejected dialect value, exactly as passed to {@link parseSync}. */
72
82
  readonly dialect: string;
73
83
  constructor(dialect: string, supportedDialects: readonly ShellDialect[]);
@@ -82,8 +92,8 @@ export declare class ShInvalidDialectError extends ShBridgeError {
82
92
  *
83
93
  * @public
84
94
  */
85
- export declare class ShBridgeInternalError extends ShBridgeError {
86
- readonly code = "ESLINT_SH_BRIDGE_INTERNAL";
95
+ export declare class ShInternalError extends ShAstError {
96
+ readonly code = "SH_AST_INTERNAL";
87
97
  constructor(message: string);
88
98
  }
89
99
  /**
@@ -106,10 +116,65 @@ export declare class ShBridgeInternalError extends ShBridgeError {
106
116
  *
107
117
  * @public
108
118
  */
109
- export declare class ShAnalyzeMaxDepthError extends ShBridgeError {
110
- readonly code = "ESLINT_SH_ANALYZE_MAX_DEPTH";
119
+ export declare class ShAnalyzeMaxDepthError extends ShAstError {
120
+ readonly code = "SH_AST_ANALYZE_MAX_DEPTH";
111
121
  /** The maximum nesting depth `enumerateCommands` supports; the same value every time (not caller-configurable). */
112
122
  readonly maxDepth: number;
113
123
  constructor(maxDepth: number);
114
124
  }
125
+ /**
126
+ * Thrown by {@link parseSync} when `text`'s conservatively estimated
127
+ * structural nesting depth (subshells, command/process substitutions,
128
+ * `if`/`case`/loop/function bodies, `{ }` blocks, backtick or `$(...)`
129
+ * command substitution, `$((...))` arithmetic — see
130
+ * `parse-depth-guard.ts`'s module doc for the exact heuristic) exceeds the
131
+ * limit `parseSync` accepts. Thrown *before* `text` is ever handed to the
132
+ * WASM shim: mvdan/sh's own recursive-descent parser has no recovery path
133
+ * for exhausting its call stack on pathologically deep input (a stack
134
+ * overflow deep inside the shared WASM instance is not a normal, catchable
135
+ * JS error the way a parse syntax error is), so this bridge estimates the
136
+ * risk up front and fails closed with a typed error instead of ever making
137
+ * that call — the shared WASM instance is therefore never put at risk of
138
+ * wedging on this class of input; a `parseSync` call right after catching
139
+ * this error works exactly as it would if this input had never been
140
+ * attempted.
141
+ *
142
+ * Like {@link ShAnalyzeMaxDepthError}, this is pathological-input
143
+ * protection, not a normal-usage ceiling: a legitimately deep (but
144
+ * realistic) script parses fine. The estimate can *over*-count relative to
145
+ * mvdan/sh's real grammar (rejecting some legitimate-but-unusually-deep
146
+ * input) but is designed to never *under*-count relative to it — see
147
+ * `parse-depth-guard.ts` for the documented false-positive sources this
148
+ * trades off against ever letting a genuinely crash-inducing input
149
+ * through.
150
+ *
151
+ * @public
152
+ */
153
+ export declare class ShParseMaxDepthError extends ShAstError {
154
+ readonly code = "SH_AST_PARSE_MAX_DEPTH";
155
+ /** The maximum structural nesting depth `parseSync` accepts; the same value every time (not caller-configurable). */
156
+ readonly maxDepth: number;
157
+ /**
158
+ * The conservatively estimated nesting depth that tripped the guard.
159
+ * Not necessarily `text`'s "true" nesting depth under a real parse — see
160
+ * {@link ShParseMaxDepthError}'s doc comment — only ever `> maxDepth`.
161
+ */
162
+ readonly estimatedDepth: number;
163
+ constructor(maxDepth: number, estimatedDepth: number);
164
+ }
165
+ /**
166
+ * Thrown by `sh-ast/analyze`'s `resolveArgv0` when a caller-supplied
167
+ * `options.transparentWrappers` array contains a malformed `WrapperSpec`
168
+ * entry — e.g. a non-array or empty `names`, or a flag field that isn't an
169
+ * array of strings. Fails closed with a clear, specific message at the
170
+ * point the malformed table is supplied, rather than letting the bad shape
171
+ * reach flag-matching logic and surface as a confusing native `TypeError`
172
+ * (or, worse, a silently wrong match) far from its actual cause.
173
+ *
174
+ * @public
175
+ */
176
+ export declare class ShAnalyzeInvalidWrapperSpecError extends ShAstError {
177
+ readonly code = "SH_AST_ANALYZE_INVALID_WRAPPER_SPEC";
178
+ constructor(message: string);
179
+ }
115
180
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,8BAAsB,aAAc,SAAQ,KAAK;IAC/C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAC7C,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB;CAOpD;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,YAAY,EAAE;CAOxE;AAED;;;;;;;;;GASG;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AY,EAAE;CAOxE;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,qBAAqB;gBAEtB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IACpD,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,mHAAmH;IACnH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM;CAO7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,QAAQ,CAAC,IAAI,4BAA4B;IACzC,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;gBAEpB,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAQrD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,gCAAiC,SAAQ,UAAU;IAC9D,QAAQ,CAAC,IAAI,yCAAyC;gBAE1C,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js CHANGED
@@ -1,17 +1,27 @@
1
1
  /**
2
2
  * Common base class for every error this package throws — originally just
3
- * {@link parseSync}'s errors, now also the `sh-ast/analyze` layer's (see
4
- * {@link ShAnalyzeMaxDepthError}). Provides a stable, documented `code`
5
- * discriminator (e.g. `"ESLINT_SH_PARSE_ERROR"`) alongside the usual
3
+ * {@link sh-ast#parseSync | parseSync}'s errors, now also the
4
+ * `sh-ast/analyze` layer's (see {@link ShAnalyzeMaxDepthError},
5
+ * {@link ShAnalyzeInvalidWrapperSpecError}). Provides a stable, documented
6
+ * `code` discriminator (e.g. `"SH_AST_PARSE_ERROR"`) alongside the usual
6
7
  * `instanceof` narrowing, so consumers can branch on failure kind
7
- * programmatically without parsing `.message` strings. Never thrown
8
- * directly — only via its concrete subclasses ({@link ShParseError},
9
- * {@link ShInvalidDialectError}, {@link ShBridgeInternalError},
10
- * {@link ShAnalyzeMaxDepthError}).
8
+ * programmatically without parsing `.message` strings. Never thrown directly
9
+ * — only via its concrete subclasses
10
+ * ({@link sh-ast#ShParseError | ShParseError},
11
+ * {@link sh-ast#ShInvalidDialectError | ShInvalidDialectError},
12
+ * {@link sh-ast#ShInternalError | ShInternalError},
13
+ * {@link ShAnalyzeMaxDepthError},
14
+ * {@link sh-ast#ShParseMaxDepthError | ShParseMaxDepthError},
15
+ * {@link ShAnalyzeInvalidWrapperSpecError}).
16
+ *
17
+ * Re-exported from `sh-ast/analyze` as well as the root `sh-ast` entry
18
+ * point (see #23) — every subclass thrown by `sh-ast/analyze`'s own
19
+ * functions extends this, so a consumer of that subpath alone can
20
+ * `catch`/reference the base without also importing from root.
11
21
  *
12
22
  * @public
13
23
  */
14
- export class ShBridgeError extends Error {
24
+ export class ShAstError extends Error {
15
25
  }
16
26
  /**
17
27
  * Thrown by {@link parseSync} when shell source fails to parse. Carries the
@@ -25,8 +35,8 @@ export class ShBridgeError extends Error {
25
35
  *
26
36
  * @public
27
37
  */
28
- export class ShParseError extends ShBridgeError {
29
- code = 'ESLINT_SH_PARSE_ERROR';
38
+ export class ShParseError extends ShAstError {
39
+ code = 'SH_AST_PARSE_ERROR';
30
40
  line;
31
41
  column;
32
42
  filename;
@@ -46,8 +56,8 @@ export class ShParseError extends ShBridgeError {
46
56
  *
47
57
  * @public
48
58
  */
49
- export class ShInvalidDialectError extends ShBridgeError {
50
- code = 'ESLINT_SH_INVALID_DIALECT';
59
+ export class ShInvalidDialectError extends ShAstError {
60
+ code = 'SH_AST_INVALID_DIALECT';
51
61
  /** The rejected dialect value, exactly as passed to {@link parseSync}. */
52
62
  dialect;
53
63
  constructor(dialect, supportedDialects) {
@@ -66,11 +76,11 @@ export class ShInvalidDialectError extends ShBridgeError {
66
76
  *
67
77
  * @public
68
78
  */
69
- export class ShBridgeInternalError extends ShBridgeError {
70
- code = 'ESLINT_SH_BRIDGE_INTERNAL';
79
+ export class ShInternalError extends ShAstError {
80
+ code = 'SH_AST_INTERNAL';
71
81
  constructor(message) {
72
82
  super(message);
73
- this.name = 'ShBridgeInternalError';
83
+ this.name = 'ShInternalError';
74
84
  }
75
85
  }
76
86
  /**
@@ -93,8 +103,8 @@ export class ShBridgeInternalError extends ShBridgeError {
93
103
  *
94
104
  * @public
95
105
  */
96
- export class ShAnalyzeMaxDepthError extends ShBridgeError {
97
- code = 'ESLINT_SH_ANALYZE_MAX_DEPTH';
106
+ export class ShAnalyzeMaxDepthError extends ShAstError {
107
+ code = 'SH_AST_ANALYZE_MAX_DEPTH';
98
108
  /** The maximum nesting depth `enumerateCommands` supports; the same value every time (not caller-configurable). */
99
109
  maxDepth;
100
110
  constructor(maxDepth) {
@@ -103,4 +113,67 @@ export class ShAnalyzeMaxDepthError extends ShBridgeError {
103
113
  this.maxDepth = maxDepth;
104
114
  }
105
115
  }
116
+ /**
117
+ * Thrown by {@link parseSync} when `text`'s conservatively estimated
118
+ * structural nesting depth (subshells, command/process substitutions,
119
+ * `if`/`case`/loop/function bodies, `{ }` blocks, backtick or `$(...)`
120
+ * command substitution, `$((...))` arithmetic — see
121
+ * `parse-depth-guard.ts`'s module doc for the exact heuristic) exceeds the
122
+ * limit `parseSync` accepts. Thrown *before* `text` is ever handed to the
123
+ * WASM shim: mvdan/sh's own recursive-descent parser has no recovery path
124
+ * for exhausting its call stack on pathologically deep input (a stack
125
+ * overflow deep inside the shared WASM instance is not a normal, catchable
126
+ * JS error the way a parse syntax error is), so this bridge estimates the
127
+ * risk up front and fails closed with a typed error instead of ever making
128
+ * that call — the shared WASM instance is therefore never put at risk of
129
+ * wedging on this class of input; a `parseSync` call right after catching
130
+ * this error works exactly as it would if this input had never been
131
+ * attempted.
132
+ *
133
+ * Like {@link ShAnalyzeMaxDepthError}, this is pathological-input
134
+ * protection, not a normal-usage ceiling: a legitimately deep (but
135
+ * realistic) script parses fine. The estimate can *over*-count relative to
136
+ * mvdan/sh's real grammar (rejecting some legitimate-but-unusually-deep
137
+ * input) but is designed to never *under*-count relative to it — see
138
+ * `parse-depth-guard.ts` for the documented false-positive sources this
139
+ * trades off against ever letting a genuinely crash-inducing input
140
+ * through.
141
+ *
142
+ * @public
143
+ */
144
+ export class ShParseMaxDepthError extends ShAstError {
145
+ code = 'SH_AST_PARSE_MAX_DEPTH';
146
+ /** The maximum structural nesting depth `parseSync` accepts; the same value every time (not caller-configurable). */
147
+ maxDepth;
148
+ /**
149
+ * The conservatively estimated nesting depth that tripped the guard.
150
+ * Not necessarily `text`'s "true" nesting depth under a real parse — see
151
+ * {@link ShParseMaxDepthError}'s doc comment — only ever `> maxDepth`.
152
+ */
153
+ estimatedDepth;
154
+ constructor(maxDepth, estimatedDepth) {
155
+ super(`parseSync: input's estimated structural nesting depth (${String(estimatedDepth)}+ frames) exceeds the maximum this bridge accepts (${String(maxDepth)}) — refusing to hand this input to the WASM parser, which would risk exhausting its call stack uncatchably. Treat this as a deny signal, not "input looks fine".`);
156
+ this.name = 'ShParseMaxDepthError';
157
+ this.maxDepth = maxDepth;
158
+ this.estimatedDepth = estimatedDepth;
159
+ }
160
+ }
161
+ /**
162
+ * Thrown by `sh-ast/analyze`'s `resolveArgv0` when a caller-supplied
163
+ * `options.transparentWrappers` array contains a malformed `WrapperSpec`
164
+ * entry — e.g. a non-array or empty `names`, or a flag field that isn't an
165
+ * array of strings. Fails closed with a clear, specific message at the
166
+ * point the malformed table is supplied, rather than letting the bad shape
167
+ * reach flag-matching logic and surface as a confusing native `TypeError`
168
+ * (or, worse, a silently wrong match) far from its actual cause.
169
+ *
170
+ * @public
171
+ */
172
+ export class ShAnalyzeInvalidWrapperSpecError extends ShAstError {
173
+ code = 'SH_AST_ANALYZE_INVALID_WRAPPER_SPEC';
174
+ constructor(message) {
175
+ super(`resolveArgv0: invalid transparentWrappers entry — ${message}`);
176
+ this.name = 'ShAnalyzeInvalidWrapperSpecError';
177
+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ACjD,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { parseSync } from './parse.js';
2
- export { ShAnalyzeMaxDepthError, ShBridgeError, ShBridgeInternalError, ShInvalidDialectError, ShParseError, } from './errors.js';
2
+ export { ShAnalyzeInvalidWrapperSpecError, ShAnalyzeMaxDepthError, ShAstError, ShInternalError, ShInvalidDialectError, ShParseError, ShParseMaxDepthError, } from './errors.js';
3
3
  export type { ShParseErrorInfo } from './errors.js';
4
4
  export type { ParseOptions, Position, ShellDialect, ShFile, ShNode } from './types.js';
5
5
  export { visitorKeys } from './visitor-keys.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;GASG;AACH,YAAY,KAAK,OAAO,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;GASG;AACH,YAAY,KAAK,OAAO,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { parseSync } from './parse.js';
2
- export { ShAnalyzeMaxDepthError, ShBridgeError, ShBridgeInternalError, ShInvalidDialectError, ShParseError, } from './errors.js';
2
+ export { ShAnalyzeInvalidWrapperSpecError, ShAnalyzeMaxDepthError, ShAstError, ShInternalError, ShInvalidDialectError, ShParseError, ShParseMaxDepthError, } from './errors.js';
3
3
  export { visitorKeys } from './visitor-keys.js';
4
4
  export { walk } from './walk.js';
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Throws {@link ShParseMaxDepthError} if `text`'s conservatively-estimated
3
+ * structural nesting depth (see {@link estimateMaxNestingDepth}) exceeds
4
+ * {@link MAX_PARSE_NESTING_DEPTH} — called by {@link parseSync} *before* it
5
+ * ever hands `text` to the WASM shim, so pathological input never reaches
6
+ * (and never risks crashing) the shared WASM instance in the first place.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function assertParseDepthWithinLimit(text: string): void;
11
+ //# sourceMappingURL=parse-depth-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-depth-guard.d.ts","sourceRoot":"","sources":["../src/parse-depth-guard.ts"],"names":[],"mappings":"AAgnBA;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAK9D"}