sveast 0.5.0 → 0.6.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.
package/README.md CHANGED
@@ -34,7 +34,7 @@ sveast is a drop-in for `parse` in most tools: change the import, and pass `loc:
34
34
  | `loc`, `name_loc` | Always | With `loc: true`; otherwise only `start`/`end` offsets, for a faster parse and a smaller AST |
35
35
  | Errors | `CompileError` | `ParseError`: same `code`, `message`, `position`, `start`, `end` and `frame`; no `filename`; `reason`, the message without its link |
36
36
  | AST formats | Modern, legacy (`modern: false`), error-tolerant (`loose`) | Modern |
37
- | Scope | Parsing, `parseCss`, analysis, compilation | Parsing (`parse`, `parseModule`, `isValidType`), and walking the AST (`walk`, `visitorKeys`) |
37
+ | Scope | Parsing, `parseCss`, analysis, compilation | Parsing (`parse`, `parseModule`, `parseImportsExports`, `isValidType`), walking the AST (`walk`, `visitorKeys`), and finding references and bindings (`isReference`, `extractIdentifiers`) |
38
38
  | Non-ASCII identifiers | acorn's tables, Unicode 17 | The engine's own Unicode data, which is smaller to ship: the same as acorn's in Node 24 and Bun; an engine on another Unicode version differs on the letters added in between |
39
39
  | TypeScript-only errors | Reported, e.g. modifier order or initializers in ambient contexts | Not reported: 108 of the 2,449 TypeScript conformance tests acorn-typescript rejects still parse |
40
40
 
@@ -57,20 +57,43 @@ A syntax error throws a `ParseError` with svelte's `code` (e.g. `"block_unclosed
57
57
 
58
58
  Parses a JavaScript or TypeScript module, such as a `.ts` file a component imports, the way a component's `<script>` is parsed: estree plus TypeScript nodes, with comments attached as `leadingComments`/`trailingComments`. Options: `typescript` and `loc`, both default `false`, and `comments`, default `true`; with `false`, no node has `leadingComments` or `trailingComments`.
59
59
 
60
- ### `createParser(support?) => { parse, parseModule }` from `sveast/core`
60
+ ### `parseImportsExports(source, options?) => ModuleDeclaration[]`
61
61
 
62
- `parse` and `parseModule` without the two parts most tools can do without: the TypeScript plugin and the table of HTML's named character references. Together they're about a third of a bundle: `parse` and `parseModule` from `sveast` minify to 57.3 kB gzipped, and from `createParser()` to 38.7 kB. Pass back the parts you need; with both, the parsers are the same as `sveast`'s.
62
+ A module's top-level `import` and `export` statements, without parsing the rest, e.g. to rewrite a component's imports or follow a module graph. Each node is the one `parseModule(source, { comments: false })` has for that statement, so `start`, `end`, `specifiers` (with `imported`, `local` and `importKind`) and `source` are all there: `ImportDeclaration`, `ExportNamedDeclaration`, `ExportDefaultDeclaration` and `ExportAllDeclaration`, and, in TypeScript, `TSImportEqualsDeclaration`, `TSExportAssignment` and `TSNamespaceExportDeclaration`. `import(...)` and `import.meta` are expressions, so they aren't returned. Unlike a regex, it never matches an `import` in a comment, a string, a template or a nested block such as `declare module "a" { ... }`.
63
+
64
+ The rest is skipped by a tokenizer that only tracks strings, comments, templates, regular expressions and brackets, and only the statements it finds are parsed. A syntax error in one of them throws `parseModule`'s `ParseError`, including a name exported twice; errors elsewhere aren't reported.
65
+
66
+ | Option | Description |
67
+ |:---|:---|
68
+ | `typescript` | Parse TypeScript: `import type`, `export type`, `import a = require("a")`. Default `false`. |
69
+ | `localExports` | Return the exports of the module's own bindings, such as `export let a`, `export function b() {}`, `export { c }` and `export default d`, which are parsed in full. With `false`, only imports and the exports that have a `from` (`export * from "e"`, `export { f } from "f"`, `export import`) are returned, and the rest is skipped. Default `true`. |
70
+
71
+ On Carbon's 327 component scripts, mostly JSDoc-documented `export let` props, it takes 10.7 ms against `parseModule`'s 33.8 ms, and 4.5 ms with `localExports: false`; the largest script, 63 kB, takes 0.37 ms against 2.7 ms. It checks the TypeScript conformance tests, kit, immich and bits-ui against `parseModule`, with an `import` inserted after every top-level statement: the same nodes on all 24,354 modules.
72
+
73
+ ```ts
74
+ import { parseImportsExports } from "sveast";
75
+
76
+ function dependencies(source: string, typescript = false): string[] {
77
+ return parseImportsExports(source, { typescript, localExports: false }).flatMap(
78
+ (node) => ("source" in node && node.source ? [node.source.value] : []),
79
+ );
80
+ }
81
+ ```
82
+
83
+ ### `createParser(support?) => { parse, parseModule, parseImportsExports }` from `sveast/core`
84
+
85
+ `parse`, `parseModule` and `parseImportsExports` without the two parts most tools can do without: the TypeScript plugin and the table of HTML's named character references. Together they're about a third of a bundle: `parse` and `parseModule` from `sveast` minify to 57.3 kB gzipped, and from `createParser()` to 40.3 kB. Pass back the parts you need; with both, the parsers are the same as `sveast`'s.
63
86
 
64
87
  ```ts
65
88
  import { createParser } from "sveast/core";
66
89
  import { typescript } from "sveast/typescript";
67
90
 
68
- const { parse, parseModule } = createParser({ typescript });
91
+ const { parse, parseModule, parseImportsExports } = createParser({ typescript });
69
92
  ```
70
93
 
71
94
  | Support | Without it |
72
95
  |:---|:---|
73
- | `typescript` from `sveast/typescript` (+8.8 kB gzipped) | A component with `<script lang="ts">`, or `parseModule` with `typescript: true`, throws an `Error`, not a `ParseError`: a missing import, not a syntax error, and never a JavaScript AST of TypeScript |
96
+ | `typescript` from `sveast/typescript` (+8.8 kB gzipped) | A component with `<script lang="ts">`, or `parseModule` or `parseImportsExports` with `typescript: true`, throws an `Error`, not a `ParseError`: a missing import, not a syntax error, and never a JavaScript AST of TypeScript |
74
97
  | `entities` from `sveast/entities` (+10.0 kB gzipped) | Text and attribute values decode numeric references, such as `&#169;`, and `&amp;`, `&apos;`, `&gt;`, `&lt;` and `&quot;`, but leave other names, such as `&copy;`, as written, so `Text.data` differs from svelte's where the source uses them |
75
98
 
76
99
  `sveast/core` also exports `ParseError`, the same class as `sveast`'s, and the types.
@@ -83,15 +106,56 @@ A `//` comment runs to the end of the line, so `string // the size` is a valid t
83
106
 
84
107
  ### `walk(node, visitor) => void`
85
108
 
86
- Visits `node` and every node under it, depth-first and in source order, calling `visitor.enter(node, parent, key, index)` before a node's children and `visitor.leave(node, parent, key, index)` after them. `parent[key]` is the node, or `parent[key][index]` when the field is an array; all three are `null` for the node you pass. Return `false` from `enter` to skip the node's children; `leave` is still called, so a stack you push in `enter` and pop in `leave` stays balanced. Return `STOP` from `enter` or `leave` to end the walk there: no more `enter` or `leave` calls, not even `leave` on the node's ancestors, e.g. to find the first use of a rune. Return another node from `enter` to put it in this one's place: `walk` writes it to `parent[key]` (or `parent[key][index]`), then calls `enter` on it and visits its children instead, and `leave` gets the replacement. So `return node.expression` on each `TSAsExpression` strips `a as B as C` down to `a`, one layer per `enter`. The node you pass to `walk` can't be replaced. Checking `node.type` narrows `node`.
109
+ Visits `node` and every node under it, depth-first and in source order, calling `visitor.enter(node, parent, key, index)` before a node's children and `visitor.leave(node, parent, key, index)` after them. `parent[key]` is the node, or `parent[key][index]` when the field is an array; all three are `null` for the node you pass. Return `SKIP` from `enter` to skip the node's children; `leave` is still called, so a stack you push in `enter` and pop in `leave` stays balanced. Return `STOP` from `enter` or `leave` to end the walk there: no more `enter` or `leave` calls, not even `leave` on the node's ancestors, e.g. to find the first use of a rune. Return another node from `enter` to put it in this one's place: `walk` writes it to `parent[key]` (or `parent[key][index]`), then calls `enter` on it and visits its children instead, and `leave` gets the replacement. So `return node.expression` on each `TSAsExpression` strips `a as B as C` down to `a`, one layer per `enter`. The node you pass to `walk` can't be replaced. Any other return value, `false` included, is ignored, so an expression-bodied `enter: (node) => node.type === "Component" && names.add(node.name)` still visits every node. Checking `node.type` narrows `node`.
87
110
 
88
111
  It works on any node the parsers return: a component's `Root`, a `Fragment`, an expression, a `parseModule` program, a `<style>`'s rules. It only reads the fields that hold child nodes, so it never descends into `loc`, comments or strings, and it throws on a node type it doesn't know. Two exceptions to source order: a component's sections are visited in scope order, `module`, `instance`, `fragment`, then `css`; and a template literal's `quasis` come before its `expressions`. `Root.options` isn't a node, so `<svelte:options>`'s attributes aren't visited; read them from `ast.options?.attributes`. acorn shares one `Identifier` between both names of `import { a }`, so it's visited once as `imported` and once as `local`, and likewise as `local` and `exported` in `export { a }`.
89
112
 
90
113
  `visitorKeys` is the table `walk` reads: the fields of each node type that hold child nodes, in source order, e.g. `visitorKeys.IfBlock` is `["test", "consequent", "alternate"]`. Use it with another walker, or to write your own.
91
114
 
115
+ ### `isReference(node, parent) => boolean`
116
+
117
+ Whether `node` is an `Identifier` that names a variable, function, class, import or other binding, where it's declared or where it's used, given the `parent` `walk` passes. It's the check svelte's analyzer makes, from the [`is-reference`](https://github.com/Rich-Harris/is-reference) package: `false` for a property or method name (`b` in `a.b`, `{ b: a }` and `class { b() {} }`, unless computed), the renamed side of an import or export (`b` in `import { b as a }` and `export { a as b }`), and labels. Unlike `is-reference`, it's also `false` for `import` and `new` in `import.meta` and `new.target`, an import attribute's key, and `b` in `export * as b from`, and for any node that isn't an `Identifier`.
118
+
119
+ TypeScript nodes hold types, so an `Identifier` whose parent is a TypeScript node isn't a reference (`B` in `let a: B`, `typeof b` in a type, interface and type alias names), except where it's a value: the expression of `as`, `satisfies`, `<T>a`, `a!`, `a<T>` and `export =`, an enum member's initializer, a parameter property (`a` in `constructor(private a)`), an enum's name, and the name and target of `import a = b`. Names of namespaces and of functions without a body (overloads, `declare function`) aren't references.
120
+
121
+ acorn shares one `Identifier` between both names of `import { a }` and `export { a }`, and `walk` visits it twice, so it's a reference on both visits.
122
+
123
+ ```ts
124
+ import { isReference, parseModule, walk } from "sveast";
125
+
126
+ const used = new Set<string>();
127
+ walk(parseModule("const a = b.c({ d: e });"), {
128
+ enter(node, parent) {
129
+ if (node.type === "Identifier" && isReference(node, parent)) used.add(node.name);
130
+ },
131
+ });
132
+ used; // Set { "a", "b", "e" }
133
+ ```
134
+
135
+ ### `extractIdentifiers(pattern) => Identifier[]`
136
+
137
+ The `Identifier` nodes a pattern binds, in source order, as svelte's `extract_identifiers` returns them: `a`, `c`, `d`, `e` and `f` in `let { a, b: [c, ...d], e = 1, ...f } = x`. Property keys, defaults and type annotations aren't included. It returns nodes rather than names, so you keep their positions; `.map((node) => node.name)` for the names.
138
+
139
+ It takes any binding or assignment target: a declarator's `id`, a function's params, including a parameter property (`a` in `constructor(private a)`), a catch clause's `param`, an each block's `context`, a snippet's `parameters`, or an assignment's `left`. A member expression binds nothing, so `[a.b, c] = x` yields only `c`, as in svelte. On an assignment's `left`, `a!`, `a as T`, `a satisfies T` and `<T>a` yield `a`.
140
+
141
+ ```ts
142
+ import { extractIdentifiers, parseModule } from "sveast";
143
+
144
+ const [declaration] = parseModule("let { a, b: [c] } = x;").body;
145
+ if (declaration.type === "VariableDeclaration") {
146
+ declaration.declarations.flatMap((d) => extractIdentifiers(d.id)).map((node) => node.name); // ["a", "c"]
147
+ }
148
+ ```
149
+
150
+ `walk`, `SKIP`, `STOP`, `visitorKeys`, `Visitor`, `isReference`, `extractIdentifiers` and the types are also exported from `sveast/walk`, which loads neither acorn nor the parser: for code that walks ASTs it gets from elsewhere, such as a cache, and must not pay for loading the parser. They're the same values as `sveast`'s.
151
+
152
+ ```ts
153
+ import { STOP, walk } from "sveast/walk";
154
+ ```
155
+
92
156
  ### Types
93
157
 
94
- `AST` is svelte's `AST` namespace (`AST.Root`, `AST.RegularElement`, `AST.CSS.Rule`, ...), corrected to match what the parser returns: `name_loc` and a comment's `loc` are optional, `Root.instance`/`module` are absent rather than `null` when there's no such `<script>`, `Root.js` is declared, and every directive has `modifiers`. `ParseOptions` and `ParseModuleOptions` are exported too.
158
+ `AST` is svelte's `AST` namespace (`AST.Root`, `AST.RegularElement`, `AST.CSS.Rule`, ...), corrected to match what the parser returns: `name_loc` and a comment's `loc` are optional, `Root.instance`/`module` are absent rather than `null` when there's no such `<script>`, `Root.js` is declared, and every directive has `modifiers`. `ParseOptions`, `ParseModuleOptions` and `ParseImportsExportsOptions` are exported too.
95
159
 
96
160
  The estree node types are exported as well (`Program`, `Node`, `Statement`, `Expression`, `Identifier`, ...), so you don't need `@types/estree`. They're estree's, plus what the parser adds: `start`/`end` on every node, and the TypeScript plugin's nodes (`TSInterfaceDeclaration`, `TSTypeAnnotation`, `TSTypeReference`, ...; `TSNode` is their union) and fields (`typeAnnotation`, `typeParameters`, `typeArguments`, `returnType`, `importKind`/`exportKind`, ...). The TypeScript nodes are in the `Statement`, `Declaration` and `Expression` unions, so checking `node.type` narrows to them. Where the grammar only allows a string, such as an import's `source`, the type is `StringLiteral`, a `Literal` whose `value` is a `string`.
97
161
 
@@ -204,7 +268,7 @@ const css = parse(source, { css: false }).css?.content.styles ?? "";
204
268
  - **TypeScript without acorn-typescript.** The built-in plugin produces the same AST as `@sveltejs/acorn-typescript`, key order and `loc` included, on 6,604 real-world modules and on all but 2 of the 9,586 TypeScript conformance tests that acorn-typescript parses. It rejects the same redeclarations, and supports decorators.
205
269
  - **About 2.4× faster than svelte/compiler** (2.2–3.0× depending on the input), and its ASTs retain 47% less memory without `loc`.
206
270
  - **Fast to load.** A fresh process imports sveast in about 5 ms, against about 45 ms for `svelte/compiler`.
207
- - **Zero dependencies,** types included. 64 kB gzipped, acorn included.
271
+ - **Zero dependencies,** types included. 67 kB gzipped, acorn included.
208
272
 
209
273
  ## Benchmarks
210
274
 
package/core.d.ts CHANGED
@@ -21,13 +21,16 @@ export interface Parser {
21
21
  parse(source: string, options?: ParseOptions): AST.Root;
22
22
  /** `parseModule` from `sveast`, with only what the parser was created with. */
23
23
  parseModule(source: string, options?: ParseModuleOptions): Program;
24
+ /** `parseImportsExports` from `sveast`, with only what the parser was created with. */
25
+ parseImportsExports(source: string, options?: ParseImportsExportsOptions): ModuleDeclaration[];
24
26
  }
25
27
 
26
28
  /**
27
- * Creates `parse` and `parseModule` that bundle only what's passed in:
28
- * the TypeScript plugin and the table of HTML's named character
29
- * references are about a third of sveast's size, and a bundler leaves
30
- * out whichever isn't imported. With both, they're the same as `sveast`'s.
29
+ * Creates `parse`, `parseModule` and `parseImportsExports` that bundle
30
+ * only what's passed in: the TypeScript plugin and the table of HTML's
31
+ * named character references are about a third of sveast's size, and a
32
+ * bundler leaves out whichever isn't imported. With both, they're the
33
+ * same as `sveast`'s.
31
34
  *
32
35
  * ```ts
33
36
  * import { createParser } from "sveast/core";
@@ -87,6 +90,25 @@ export interface ParseModuleOptions {
87
90
  comments?: boolean;
88
91
  }
89
92
 
93
+ /** Options for {@link parseImportsExports}. */
94
+ export interface ParseImportsExportsOptions {
95
+ /**
96
+ * Parse TypeScript, e.g. `import type`, `export type` and
97
+ * `import a = require("a")`. Default `false`.
98
+ */
99
+ typescript?: boolean;
100
+ /**
101
+ * Return the `export` statements that export the module's own bindings,
102
+ * such as `export let a`, `export function b() {}`, `export { c }` and
103
+ * `export default d`. With `false`, only imports and the exports that
104
+ * have a `from`, such as `export * from "e"` and `export { f } from "f"`,
105
+ * are returned, and the rest is skipped like other code, which is faster
106
+ * when most statements are exported, as in a component's props.
107
+ * Default `true`.
108
+ */
109
+ localExports?: boolean;
110
+ }
111
+
90
112
  /** TypeScript support for {@link createParser}, from `sveast/typescript`. */
91
113
  export interface TypeScriptSupport {
92
114
  readonly support: "typescript";
package/core.js CHANGED
@@ -1 +1 @@
1
- import{d}from"./shared-7q7hyetp.js";import"./shared-cx7c0gk3.js";import{e}from"./shared-t6kshmn4.js";import{Ee}from"./shared-c2k7d7rg.js";import{m}from"./shared-kqcn291j.js";import{_e,Pe}from"./shared-da2hc1fx.js";function u(p={}){let o=_e(p.typescript),s={typescript:o,entityNames:Pe(p.entities)??Ee};return{parse:(t,r)=>d(t,r,s),parseModule:(t,r={})=>m(t,r,o)}}export{e as ParseError,u as createParser};
1
+ import{m}from"./shared-rfyyd11j.js";import"./shared-f8ty80r9.js";import{e}from"./shared-3xek95jd.js";import{Ce}from"./shared-9f69x2q9.js";import{x}from"./shared-etx1q7m5.js";import{y}from"./shared-88pt6me6.js";import{Le,Ie}from"./shared-0ehch67h.js";function P(o={}){let p=Le(o.typescript),s={typescript:p,entityNames:Ie(o.entities)??Ce};return{parse:(t,r)=>m(t,r,s),parseModule:(t,r={})=>y(t,r,p),parseImportsExports:(t,r={})=>x(t,r,p)}}export{e as ParseError,P as createParser};
package/entities.js CHANGED
@@ -1 +1 @@
1
- import"./shared-c2k7d7rg.js";import{S}from"./shared-p7c7qbej.js";import{Ce}from"./shared-da2hc1fx.js";var p=Ce(S);export{p as entities};
1
+ import"./shared-9f69x2q9.js";import{k}from"./shared-y4gayx8p.js";import{Pe}from"./shared-0ehch67h.js";var p=Pe(k);export{p as entities};
package/index.d.ts CHANGED
@@ -64,6 +64,25 @@ export interface ParseModuleOptions {
64
64
  comments?: boolean;
65
65
  }
66
66
 
67
+ /** Options for {@link parseImportsExports}. */
68
+ export interface ParseImportsExportsOptions {
69
+ /**
70
+ * Parse TypeScript, e.g. `import type`, `export type` and
71
+ * `import a = require("a")`. Default `false`.
72
+ */
73
+ typescript?: boolean;
74
+ /**
75
+ * Return the `export` statements that export the module's own bindings,
76
+ * such as `export let a`, `export function b() {}`, `export { c }` and
77
+ * `export default d`. With `false`, only imports and the exports that
78
+ * have a `from`, such as `export * from "e"` and `export { f } from "f"`,
79
+ * are returned, and the rest is skipped like other code, which is faster
80
+ * when most statements are exported, as in a component's props.
81
+ * Default `true`.
82
+ */
83
+ localExports?: boolean;
84
+ }
85
+
67
86
  /**
68
87
  * Parses a Svelte component into svelte's modern AST, the same as
69
88
  * `parse(source, { modern: true })` from svelte/compiler. From svelte's
@@ -1697,6 +1716,21 @@ export interface TSInstantiationExpression extends BaseNode {
1697
1716
  typeArguments: TSTypeParameterInstantiation;
1698
1717
  }
1699
1718
 
1719
+ /**
1720
+ * Parses only a module's top-level `import` and `export` statements, e.g.
1721
+ * to rewrite or follow its imports, and skips the rest without building
1722
+ * it. Each node is the one {@link parseModule} returns for the statement
1723
+ * with `comments: false`: `ImportDeclaration`, `ExportNamedDeclaration`,
1724
+ * `ExportDefaultDeclaration` and `ExportAllDeclaration`, plus, with
1725
+ * `typescript: true`, `TSImportEqualsDeclaration`, `TSExportAssignment`
1726
+ * and `TSNamespaceExportDeclaration`. `import(...)` and `import.meta`
1727
+ * aren't statements, so they aren't returned.
1728
+ *
1729
+ * Throws a {@link ParseError} (`js_parse_error`) on a syntax error in one
1730
+ * of those statements. Syntax errors in the rest aren't reported.
1731
+ */
1732
+ export declare function parseImportsExports(source: string, options?: ParseImportsExportsOptions): ModuleDeclaration[];
1733
+
1700
1734
  /**
1701
1735
  * Parses a JavaScript or TypeScript module, e.g. a `.ts` file a component
1702
1736
  * imports, into the same kind of AST as a component's `<script>`:
@@ -1954,14 +1988,22 @@ export declare const visitorKeys: {
1954
1988
  */
1955
1989
  export declare const STOP: unique symbol;
1956
1990
 
1991
+ /**
1992
+ * Return it from `enter` to skip the node's children; `leave` is still
1993
+ * called on the node.
1994
+ */
1995
+ export declare const SKIP: unique symbol;
1996
+
1957
1997
  /** The callbacks {@link walk} calls for each node. */
1958
1998
  export interface Visitor {
1959
1999
  /**
1960
- * Called before the node's children. Return `false` to skip them; `leave`
1961
- * is still called, so the two stay paired. Return {@link STOP} to end the
1962
- * walk. Return another node to put it in this one's place: `walk` writes it
1963
- * to `parent[key]` (or `parent[key][index]`), then calls `enter` on it and
1964
- * visits its children instead.
2000
+ * Called before the node's children. Return {@link SKIP} to skip them;
2001
+ * `leave` is still called, so the two stay paired. Return {@link STOP} to
2002
+ * end the walk. Return another node to put it in this one's place: `walk`
2003
+ * writes it to `parent[key]` (or `parent[key][index]`), then calls `enter`
2004
+ * on it and visits its children instead. Any other value, `false`
2005
+ * included, is ignored, so `(node) => node.type === "Component" &&
2006
+ * names.add(node.name)` visits every node.
1965
2007
  */
1966
2008
  enter?(node: AST.SvelteNode, parent: AST.SvelteNode | null, key: string | null, index: number | null): unknown;
1967
2009
  /** Called after the node's children. Return {@link STOP} to end the walk. */
@@ -1975,3 +2017,29 @@ export interface Visitor {
1975
2017
  * array; all three are `null` for `node` itself.
1976
2018
  */
1977
2019
  export declare function walk(node: AST.SvelteNode, visitor: Visitor): void;
2020
+
2021
+ /**
2022
+ * The `Identifier` nodes a pattern binds, in source order: `a`, `c`, `d`,
2023
+ * `e` and `f` in `{ a, b: [c, ...d], e = 1, ...f }`. Not the property
2024
+ * keys, defaults or type annotations. A member expression, which an
2025
+ * assignment's pattern can hold, as in `[a.b] = c`, binds nothing, so it
2026
+ * yields no identifiers, as in svelte's `extract_identifiers`. Also takes
2027
+ * a function's params as they are, parameter properties included, and an
2028
+ * assignment's `left`, where `a!`, `a as T`, `a satisfies T` and `<T>a`
2029
+ * yield `a`.
2030
+ */
2031
+ export declare function extractIdentifiers(pattern: Pattern | TSParameterProperty | AssignmentExpression["left"]): Identifier[];
2032
+
2033
+ /**
2034
+ * Whether `node` is an `Identifier` that names a binding in the value
2035
+ * namespace, where it's declared or where it's used, given its `parent`
2036
+ * from `walk`. `false` for a property, method or label name, the
2037
+ * renamed side of an import or export specifier, `import.meta`'s and
2038
+ * `new.target`'s names, an import attribute's key, and every name in a
2039
+ * type. The check svelte's analyzer makes, from the `is-reference` package,
2040
+ * plus TypeScript: an `Identifier` whose parent is a TypeScript node is a
2041
+ * reference only as the expression of `as`, `satisfies`, `<T>x`, `x!`,
2042
+ * `f<T>` or `export =`, an enum member's initializer, a parameter
2043
+ * property, an enum's name, or the name or target of `import a = b`.
2044
+ */
2045
+ export declare function isReference(node: AST.SvelteNode, parent: AST.SvelteNode | null): boolean;
package/index.js CHANGED
@@ -1 +1 @@
1
- import{isValidType as o}from"./is-valid-type.js";import{parse as p}from"./parse.js";import{ParseError as y,parseModule as i}from"./parse-module.js";import{STOP as f,visitorKeys as m,walk as x}from"./walk.js";export{y as ParseError,f as STOP,o as isValidType,p as parse,i as parseModule,m as visitorKeys,x as walk};
1
+ import{isValidType as t}from"./is-valid-type.js";import{parse as p}from"./parse.js";import{parseImportsExports as i}from"./parse-imports-exports.js";import{ParseError as a,parseModule as f}from"./parse-module.js";import{extractIdentifiers as y,isReference as l,SKIP as n,STOP as P,visitorKeys as d,walk as I}from"./walk.js";export{a as ParseError,n as SKIP,P as STOP,y as extractIdentifiers,l as isReference,t as isValidType,p as parse,i as parseImportsExports,f as parseModule,d as visitorKeys,I as walk};
package/is-valid-type.js CHANGED
@@ -1 +1 @@
1
- import{t}from"./shared-cx7c0gk3.js";import{y}from"./shared-xw9zc4rz.js";var a=new Set("abstract accessor arguments as asserts async await break case catch class const continue debugger declare default delete do else enum eval export extends false finally for function get global if implements import in infer instanceof interface intrinsic is keyof let module namespace new null of out override package private protected public readonly return satisfies set static super switch this throw true try type typeof unique var void while with yield".split(" ")),c=new Set("any bigint boolean false never null number object string symbol true undefined unknown void".split(" ")),d=new Set("get set new readonly static public private protected".split(" "));function u(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function o(e){return e>=48&&e<=57}function h(e){return u(e)||o(e)}class l{text;pos=0;constructor(e){this.text=e}readAll(){if(!this.type())return!1;return this.peek(),this.pos===this.text.length}peek(){let e=this.text,s=this.pos,r=e.charCodeAt(s);while(r===32||r===9)r=e.charCodeAt(++s);return this.pos=s,r}eat(e){if(this.peek()!==e.charCodeAt(0))return!1;return this.pos++,!0}word(){if(!u(this.peek()))return;let e=this.pos,s=e+1;while(h(this.text.charCodeAt(s)))s++;return this.pos=s,this.text.slice(e,s)}name(){let e=this.word();return e!==void 0&&!a.has(e)}string(){let e=this.peek();if(e!==34&&e!==39)return!1;let s=this.text;for(let r=this.pos+1;r<s.length;r++){let i=s.charCodeAt(r);if(i===e)return this.pos=r+1,!0;if(i===92||i===10||i===13||i===8232||i===8233)return!1}return!1}number(){let e=this.text,s=this.pos;if(e.charCodeAt(s)===45)s++;let r=s;while(o(e.charCodeAt(s)))s++;if(s===r||s-r>1&&e.charCodeAt(r)===48)return!1;if(e.charCodeAt(s)===46){let n=++s;while(o(e.charCodeAt(s)))s++;if(s===n)return!1}let i=e.charCodeAt(s);if(h(i)||i===46)return!1;return this.pos=s,!0}type(){if(this.peek()===40){let e=this.pos;if(this.functionType())return!0;this.pos=e}do do if(!this.operatorType())return!1;while(this.eat("&"));while(this.eat("|"));return!0}operatorType(){let e=this.pos;if(this.word()==="keyof")return this.operatorType();if(this.pos=e,!this.primaryType())return!1;while(this.eat("[")){if(this.eat("]"))continue;if(!this.type()||!this.eat("]"))return!1}return!0}primaryType(){let e=this.peek();if(e===40)return this.pos++,this.type()&&this.eat(")");if(e===123)return this.objectType();if(e===91)return this.tupleType();if(e===34||e===39)return this.string();if(e===45||o(e))return this.number();let s=this.word();if(s===void 0)return!1;if(s==="typeof")return this.typeQuery();if(s==="import")return this.importType(!0);if(c.has(s)){let r=this.peek();return r!==46&&r!==60}if(a.has(s))return!1;while(this.eat("."))if(this.word()===void 0)return!1;return!this.eat("<")||this.typeArguments()}typeArguments(){do if(!this.type())return!1;while(this.eat(","));return this.eat(">")}typeQuery(){let e=this.pos;if(this.word()==="import")return this.importType(!1);this.pos=e;do if(!this.name())return!1;while(this.eat("."));return!0}importType(e){if(!this.eat("(")||!this.string()||!this.eat(")"))return!1;while(this.eat("."))if(!this.name())return!1;return!e||!this.eat("<")||this.typeArguments()}objectType(){this.pos++;while(!this.eat("}")){if(!this.typeMember())return!1;if(!this.eat(";")&&!this.eat(",")&&this.peek()!==125)return!1}return!0}typeMember(){let e=this.peek();if(this.eat("[")){let s=this.peek();if(s===34||s===39){if(!this.string()||!this.eat("]"))return!1}else return this.name()&&this.eat(":")&&this.type()&&this.eat("]")&&this.eat(":")&&this.type()}else if(e===34||e===39){if(!this.string())return!1}else{let s=this.word();if(s===void 0||d.has(s))return!1}return this.eat("?"),this.eat(":")&&this.type()}tupleType(){if(this.pos++,this.eat("]"))return!0;do if(!this.type())return!1;while(this.eat(","));return this.eat("]")}functionType(){if(this.pos++,!this.eat(")")){let e=new Set;for(;;){this.peek();let s=this.text.startsWith("...",this.pos);if(s)this.pos+=3;let r=this.word();if(r===void 0||a.has(r)||e.has(r))return!1;if(e.add(r),!s)this.eat("?");if(!this.eat(":")||!this.type())return!1;if(s||!this.eat(","))break}if(!this.eat(")"))return!1}if(this.peek(),!this.text.startsWith("=>",this.pos))return!1;return this.pos+=2,this.type()}}function f(e){return new l(e).readAll()}var m=t.extend(y);function S(e,s={}){return f(e)||b(e,s.inline??!1)}function b(e,s){let r=!1,i=new m(s?{ecmaVersion:16,sourceType:"module",onComment:(n,T,A,p)=>{if(!n&&p===e.length)r=!0}}:{ecmaVersion:16,sourceType:"module"},e);try{return i.parseWholeType(),!r}catch(n){if(n instanceof SyntaxError)return!1;throw n}}export{S as isValidType,b as parsesAsType};
1
+ import{t}from"./shared-f8ty80r9.js";import{g}from"./shared-c4vs4cam.js";var a=new Set("abstract accessor arguments as asserts async await break case catch class const continue debugger declare default delete do else enum eval export extends false finally for function get global if implements import in infer instanceof interface intrinsic is keyof let module namespace new null of out override package private protected public readonly return satisfies set static super switch this throw true try type typeof unique var void while with yield".split(" ")),c=new Set("any bigint boolean false never null number object string symbol true undefined unknown void".split(" ")),d=new Set("get set new readonly static public private protected".split(" "));function u(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function o(e){return e>=48&&e<=57}function h(e){return u(e)||o(e)}class l{text;pos=0;constructor(e){this.text=e}readAll(){if(!this.type())return!1;return this.peek(),this.pos===this.text.length}peek(){let e=this.text,s=this.pos,r=e.charCodeAt(s);while(r===32||r===9)r=e.charCodeAt(++s);return this.pos=s,r}eat(e){if(this.peek()!==e.charCodeAt(0))return!1;return this.pos++,!0}word(){if(!u(this.peek()))return;let e=this.pos,s=e+1;while(h(this.text.charCodeAt(s)))s++;return this.pos=s,this.text.slice(e,s)}name(){let e=this.word();return e!==void 0&&!a.has(e)}string(){let e=this.peek();if(e!==34&&e!==39)return!1;let s=this.text;for(let r=this.pos+1;r<s.length;r++){let i=s.charCodeAt(r);if(i===e)return this.pos=r+1,!0;if(i===92||i===10||i===13||i===8232||i===8233)return!1}return!1}number(){let e=this.text,s=this.pos;if(e.charCodeAt(s)===45)s++;let r=s;while(o(e.charCodeAt(s)))s++;if(s===r||s-r>1&&e.charCodeAt(r)===48)return!1;if(e.charCodeAt(s)===46){let n=++s;while(o(e.charCodeAt(s)))s++;if(s===n)return!1}let i=e.charCodeAt(s);if(h(i)||i===46)return!1;return this.pos=s,!0}type(){if(this.peek()===40){let e=this.pos;if(this.functionType())return!0;this.pos=e}do do if(!this.operatorType())return!1;while(this.eat("&"));while(this.eat("|"));return!0}operatorType(){let e=this.pos;if(this.word()==="keyof")return this.operatorType();if(this.pos=e,!this.primaryType())return!1;while(this.eat("[")){if(this.eat("]"))continue;if(!this.type()||!this.eat("]"))return!1}return!0}primaryType(){let e=this.peek();if(e===40)return this.pos++,this.type()&&this.eat(")");if(e===123)return this.objectType();if(e===91)return this.tupleType();if(e===34||e===39)return this.string();if(e===45||o(e))return this.number();let s=this.word();if(s===void 0)return!1;if(s==="typeof")return this.typeQuery();if(s==="import")return this.importType(!0);if(c.has(s)){let r=this.peek();return r!==46&&r!==60}if(a.has(s))return!1;while(this.eat("."))if(this.word()===void 0)return!1;return!this.eat("<")||this.typeArguments()}typeArguments(){do if(!this.type())return!1;while(this.eat(","));return this.eat(">")}typeQuery(){let e=this.pos;if(this.word()==="import")return this.importType(!1);this.pos=e;do if(!this.name())return!1;while(this.eat("."));return!0}importType(e){if(!this.eat("(")||!this.string()||!this.eat(")"))return!1;while(this.eat("."))if(!this.name())return!1;return!e||!this.eat("<")||this.typeArguments()}objectType(){this.pos++;while(!this.eat("}")){if(!this.typeMember())return!1;if(!this.eat(";")&&!this.eat(",")&&this.peek()!==125)return!1}return!0}typeMember(){let e=this.peek();if(this.eat("[")){let s=this.peek();if(s===34||s===39){if(!this.string()||!this.eat("]"))return!1}else return this.name()&&this.eat(":")&&this.type()&&this.eat("]")&&this.eat(":")&&this.type()}else if(e===34||e===39){if(!this.string())return!1}else{let s=this.word();if(s===void 0||d.has(s))return!1}return this.eat("?"),this.eat(":")&&this.type()}tupleType(){if(this.pos++,this.eat("]"))return!0;do if(!this.type())return!1;while(this.eat(","));return this.eat("]")}functionType(){if(this.pos++,!this.eat(")")){let e=new Set;for(;;){this.peek();let s=this.text.startsWith("...",this.pos);if(s)this.pos+=3;let r=this.word();if(r===void 0||a.has(r)||e.has(r))return!1;if(e.add(r),!s)this.eat("?");if(!this.eat(":")||!this.type())return!1;if(s||!this.eat(","))break}if(!this.eat(")"))return!1}if(this.peek(),!this.text.startsWith("=>",this.pos))return!1;return this.pos+=2,this.type()}}function f(e){return new l(e).readAll()}var y=t.extend(g);function S(e,s={}){return f(e)||m(e,s.inline??!1)}function m(e,s){let r=!1,i=new y(s?{ecmaVersion:16,sourceType:"module",onComment:(n,b,T,p)=>{if(!n&&p===e.length)r=!0}}:{ecmaVersion:16,sourceType:"module"},e);try{return i.parseWholeType(),!r}catch(n){if(n instanceof SyntaxError)return!1;throw n}}export{S as isValidType,m as parsesAsType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveast",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "description": "Zero-dependency Svelte 5 parser, TypeScript included, with svelte/compiler's exact AST, 2-3x faster.",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -27,6 +27,11 @@
27
27
  "types": "./entities.d.ts",
28
28
  "import": "./entities.js",
29
29
  "default": "./entities.js"
30
+ },
31
+ "./walk": {
32
+ "types": "./walk.d.ts",
33
+ "import": "./walk.js",
34
+ "default": "./walk.js"
30
35
  }
31
36
  },
32
37
  "sideEffects": false,
@@ -0,0 +1 @@
1
+ import"./shared-f8ty80r9.js";import"./shared-3xek95jd.js";import{x}from"./shared-etx1q7m5.js";import"./shared-c4vs4cam.js";import{r}from"./shared-nqsechtt.js";function e(t,o={}){return x(t,o,r)}export{e as parseImportsExports};
package/parse-module.js CHANGED
@@ -1 +1 @@
1
- import"./shared-cx7c0gk3.js";import{e}from"./shared-t6kshmn4.js";import"./shared-xw9zc4rz.js";import{m}from"./shared-kqcn291j.js";import{l}from"./shared-xvd609sh.js";function s(r,o={}){return m(r,o,l)}export{e as ParseError,s as parseModule};
1
+ import"./shared-f8ty80r9.js";import{e}from"./shared-3xek95jd.js";import"./shared-c4vs4cam.js";import{y}from"./shared-88pt6me6.js";import{r}from"./shared-nqsechtt.js";function i(o,t={}){return y(o,t,r)}export{e as ParseError,i as parseModule};
package/parse.js CHANGED
@@ -1 +1 @@
1
- import{d}from"./shared-7q7hyetp.js";import"./shared-cx7c0gk3.js";import"./shared-t6kshmn4.js";import"./shared-c2k7d7rg.js";import"./shared-xw9zc4rz.js";import{l}from"./shared-xvd609sh.js";import{S}from"./shared-p7c7qbej.js";var o={typescript:l,entityNames:S};function i(t,r){return d(t,r,o)}export{i as parse};
1
+ import{m}from"./shared-rfyyd11j.js";import"./shared-f8ty80r9.js";import"./shared-3xek95jd.js";import"./shared-9f69x2q9.js";import"./shared-c4vs4cam.js";import{r}from"./shared-nqsechtt.js";import{k}from"./shared-y4gayx8p.js";var p={typescript:r,entityNames:k};function n(t,o){return m(t,o,p)}export{n as parse};
@@ -0,0 +1,2 @@
1
+ function _e(t){return{support:"typescript",parser:t}}function Pe(t){return{support:"entities",names:t}}function Le(t){return t&&"parser"in t?t.parser:void 0}function Ie(t){return t&&"names"in t?t.names:void 0}function T(){throw Error('sveast: parsing TypeScript needs `typescript` from "sveast/typescript": createParser({ typescript })')}
2
+ export{_e,Pe,Le,Ie,T};
@@ -0,0 +1,12 @@
1
+ import{v,S}from"./shared-f8ty80r9.js";import{a,u,f}from"./shared-c1jf0gfc.js";import{T}from"./shared-0ehch67h.js";var We="",Le,$e=0;function p(t){We=t,Le=void 0,$e=0}function o(t){if(!Le){Le=[0];let l=We.indexOf(`
2
+ `);while(l!==-1)Le.push(l+1),l=We.indexOf(`
3
+ `,l+1)}let n=0,r=Le.length-1;if(t>=Le[$e])n=$e;else r=$e-1;if(n<r&&t<Le[n+1])r=n;while(n<r){let l=n+r+1>>>1;if(Le[l]<=t)n=l;else r=l-1}return $e=n,{line:n+1,column:t-Le[n],character:t}}function c(t){let{line:n,column:r}=o(t);return{line:n,column:r}}function ze(){return We.split(`
4
+ `)}var et=/^\t+/;class e extends Error{name="ParseError";code;reason;position;start;end;frame;constructor(t,n,r){super(`${r}
5
+ https://svelte.dev/e/${n}`);this.code=n,this.reason=r;let l=typeof t==="number"?t:t?.start,d=typeof t==="number"?t:t?.end;if(l!==void 0)this.position=[l,d??l],this.start=o(this.position[0]),this.end=o(this.position[1]),this.frame=tt(this.start.line-1,this.end.column)}}var Me=(t)=>t.replace(et,(n)=>" ".repeat(n.length));function tt(t,n){let r=ze(),l=Math.max(0,t-2),d=Math.min(t+3,r.length),w=String(d+1).length;return r.slice(l,d).map((m,g)=>{let k=String(g+l+1).padStart(w," ");if(l+g!==t)return`${k}: ${Me(m)}`;let x=`${" ".repeat(w+2+Me(m.slice(0,n)).length)}^`;return`${k}: ${Me(m)}
6
+ ${x}`}).join(`
7
+ `)}function O(t){throw new e(t,"attribute_duplicate","Attributes need to be unique")}function D(t){throw new e(t,"attribute_empty_shorthand","Attribute shorthand cannot be empty")}function B(t,n){throw new e(t,"block_duplicate_clause",`${n} cannot appear more than once within a block`)}function F(t){throw new e(t,"block_invalid_continuation_placement","{:...} block is invalid at this position (did you forget to close the preceding element or block?)")}function V(t){throw new e(t,"block_invalid_elseif","'elseif' should be 'else if'")}function M(t,n,r){throw new e(t,"block_invalid_placement",`{#${n} ...} block cannot be ${r}`)}function j(t){throw new e(t,"block_unclosed","Block was left open")}function W(t){throw new e(t,"block_unexpected_close","Unexpected block closing tag")}function z(t){throw new e(t,"const_tag_invalid_expression","{@const ...} must consist of a single variable declaration")}function U(t){throw new e(t,"css_empty_declaration","Declaration cannot be empty")}function N(t){throw new e(t,"css_expected_identifier","Expected a valid CSS identifier")}function H(t){throw new e(t,"css_selector_invalid","Invalid selector")}function G(t){throw new e(t,"debug_tag_invalid_arguments","{@debug ...} arguments must be identifiers, not arbitrary expressions")}function C(t){throw new e(t,"declaration_tag_invalid_type","Declaration tags must be `let` or `const` declarations")}function K(t){throw new e(t,"directive_invalid_value","Directive value must be a JavaScript expression enclosed in curly braces")}function Q(t,n){throw new e(t,"directive_missing_name",`\`${n}\` name cannot be empty`)}function X(t,n){throw new e(t,"element_invalid_closing_tag",`\`</${n}>\` attempted to close an element that was not open`)}function Y(t,n,r){throw new e(t,"element_invalid_closing_tag_autoclosed",`\`</${n}>\` attempted to close element that was already automatically closed by \`<${r}>\` (cannot nest \`<${r}>\` inside \`<${n}>\`)`)}function A(t,n){throw new e(t,"element_unclosed",`\`<${n}>\` was left open`)}function _(t){throw new e(t,"expected_attribute_value","Expected attribute value")}function J(t){throw new e(t,"expected_block_type","Expected 'if', 'each', 'await', 'key' or 'snippet'")}function P(t){throw new e(t,"expected_identifier","Expected an identifier")}function Z(t){throw new e(t,"expected_pattern","Expected identifier or destructure pattern")}function ee(t){throw new e(t,"expected_tag","Expected 'html', 'render', 'attach', 'const', or 'debug'")}function s(t,n){throw new e(t,"expected_token",`Expected token ${n}`)}function te(t){throw new e(t,"expected_whitespace","Expected whitespace")}function Ue(t,n){throw new e(t,"js_parse_error",`${n}`)}function ie(t){throw new e(t,"render_tag_invalid_expression","`{@render ...}` tags can only contain call expressions")}function re(t){throw new e(t,"script_duplicate","A component can have a single top-level `<script>` element and/or a single top-level `<script module>` element")}function se(t,n){throw new e(t,"script_invalid_attribute_value",`If the \`${n}\` attribute is supplied, it must be a boolean attribute`)}function ne(t){throw new e(t,"script_invalid_context",'If the context attribute is supplied, its value must be "module"')}function oe(t,n){throw new e(t,"script_reserved_attribute",`The \`${n}\` attribute is reserved and cannot be used`)}function ae(t){throw new e(t,"style_duplicate","A component can have a single top-level `<style>` element")}function le(t){throw new e(t,"svelte_component_invalid_this","Invalid component definition — must be an `{expression}`")}function pe(t){throw new e(t,"svelte_component_missing_this","`<svelte:component>` must have a 'this' attribute")}function L(t){throw new e(t,"svelte_element_missing_this","`<svelte:element>` must have a 'this' attribute with a value")}function ce(t,n){throw new e(t,"svelte_meta_duplicate",`A component can only have one \`<${n}>\` element`)}function he(t,n){throw new e(t,"svelte_meta_invalid_content",`<${n}> cannot have children`)}function ue(t,n){throw new e(t,"svelte_meta_invalid_placement",`\`<${n}>\` tags cannot be inside elements or blocks`)}function fe(t,n){throw new e(t,"svelte_meta_invalid_tag",`Valid \`<svelte:...>\` tag names are ${n}`)}function de(t){throw new e(t,"svelte_options_deprecated_tag",'"tag" option is deprecated — use "customElement" instead')}function me(t){throw new e(t,"svelte_options_invalid_attribute","`<svelte:options>` can only receive static attributes")}function E(t,n){throw new e(t,"svelte_options_invalid_attribute_value",`Value must be ${n}, if specified`)}function ye(t){throw new e(t,"svelte_options_invalid_customelement",'"customElement" must be a string literal defining a valid custom element name or an object of the form { tag?: string; shadow?: "open" | "none" | `ShadowRootInit`; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } }')}function xe(t){throw new e(t,"svelte_options_invalid_customelement_props",'"props" must be a statically analyzable object literal of the form "{ [key: string]: { attribute?: string; reflect?: boolean; type?: "String" | "Boolean" | "Number" | "Array" | "Object" }"')}function ge(t){throw new e(t,"svelte_options_invalid_customelement_shadow",'"shadow" must be either "open", "none" or `ShadowRootInit` object.')}function I(t){throw new e(t,"svelte_options_invalid_tagname","Tag name must be lowercase and hyphenated")}function be(t){throw new e(t,"svelte_options_reserved_tagname","Tag name is reserved")}function ve(t,n){throw new e(t,"svelte_options_unknown_attribute",`\`<svelte:options>\` unknown attribute '${n}'`)}function Se(t){throw new e(t,"tag_invalid_name","Expected a valid element or component name. Components must have a valid variable name or dot notation expression")}function ke(t,n,r){throw new e(t,"tag_invalid_placement",`{@${n} ...} tag cannot be ${r}`)}function i(t){throw new e(t,"unexpected_eof","Unexpected end of input")}function we(t,n){throw new e(t,"unexpected_reserved_word",`'${n}' is a reserved word in JavaScript and cannot be used here`)}function Te(t){throw new e(t,"unterminated_string_constant","Unterminated string constant")}function Ae(t){throw new e(t,"void_element_invalid_content","Void elements cannot have children or closing tags")}var Pe="",Ge=[],Ie=0;function Je(t,n){Pe=t,Ge=n,Ie=0}function Xe(){return Ie}function qe(t,n,r,l){Ie=l}function Ke(t,n,r,l,d,w){Ie=l;let m=n;if(t&&m.includes(`
8
+ `)){let k=Pe.lastIndexOf(`
9
+ `,r-1)+1,x=k,_e=Pe.charCodeAt(x);while(_e===32||_e===9)_e=Pe.charCodeAt(++x);if(x>k)m=nt(m,Pe.slice(k,x))}let g={type:t?"Block":"Line",value:m,start:r,end:l};if(d&&w)g.loc={start:d,end:w};Ge.push(g)}function nt(t,n){let r=t.startsWith(n)?n.length:0,l="",d=t.indexOf(`
10
+ `,r);while(d!==-1){if(l+=t.slice(r,d+1),r=d+1,t.startsWith(n,r))r+=n.length;d=t.indexOf(`
11
+ `,r)}return l+t.slice(r)}function Ye(t,n,r){let l=0,d=n.length;while(l<d){let w=l+d>>>1;if(n[w].start<r)l=w+1;else d=w}if(l>=n.length)return;if(y=n.slice(l).map(({type:w,value:m,start:g,end:k})=>({type:w,value:m,start:g,end:k})),R=0,Be(t,void 0,!1),R<y.length&&(y[R].start>=t.end||t.type==="Program")){t.trailingComments??=[];while(R<y.length)t.trailingComments.push(y[R++])}}var y=[],R=0,ot=new Map([["BlockStatement","body"],["Program","body"],["ArrayExpression","elements"],["ObjectExpression","properties"]]);function Ve(t,n){for(let r=t;r<n;r++){let l=Pe.charCodeAt(r);if(l!==44&&l!==41&&l!==32&&l!==9)return!0}return!1}function Be(t,n,r){while(R<y.length&&y[R].start<t.start)t.leadingComments??=[],t.leadingComments.push(y[R++]);if(R>=y.length)return;let l=y[R].start;if(l<t.end||!Ve(t.end,l)){let d=u(t),w=ot.get(t.type),m=w===void 0?void 0:d[w],g=Array.isArray(m)&&m.length===0;for(let k in d){if(R>=y.length)return;if(k==="type")continue;let x=d[k];if(Array.isArray(x)){let _e=k===w;for(let Ce=0;Ce<x.length;Ce++){let Fe=x[Ce];if(a(Fe))Be(Fe,t,_e?Ce===x.length-1:g)}}else if(a(x))Be(x,t,g)}if(R>=y.length)return}if(n!==void 0&&t.end===n.end)return;if(r)while(R<y.length){if(n&&y[R].start>=n.end)break;t.trailingComments??=[],t.trailingComments.push(y[R++])}else if(t.end<=y[R].start&&!Ve(t.end,y[R].start))t.trailingComments=[y[R++]]}var Re=!1,He=new Map;function je(t){if(!(t instanceof RegExp))return t;let n=He.get(t);if(!n){let r=new Set(t.source.slice(4,-2).split("|"));n={test:(l)=>r.has(l)},He.set(t,n)}return n}var q=v((t)=>{let{keywordTypes:n,tokTypes:r}=t.acorn,l=new Map("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this const class extends export import super".split(" ").map((d)=>[d,n[d]]));return class extends t{constructor(d,w,m){super(d,w,m);this.keywords=je(this.keywords),this.reservedWords=je(this.reservedWords),this.reservedWordsStrict=je(this.reservedWordsStrict),this.reservedWordsStrictBind=je(this.reservedWordsStrictBind)}parseParenAndDistinguishExpression(d,w){let m=super.parseParenAndDistinguishExpression(d,w);if(m.type==="ParenthesizedExpression")Re=!0;return m}checkLocalExport(){}skipSpace(){let d=this.input,w=this.options.locations,m=this.pos,g=d.charCodeAt(m);for(;;)if(g===32||g===9)g=d.charCodeAt(++m);else if(g===10){if(g=d.charCodeAt(++m),w)this.curLine++,this.lineStart=m}else break;if(this.pos=m,g===47||g<33||g>=128)super.skipSpace()}readWord1(){let d=this.input,w=this.pos,m=w,g=d.charCodeAt(m);while(g>=97&&g<=122||g>=65&&g<=90||g>=48&&g<=57||g===95||g===36)g=d.charCodeAt(++m);if(g>=128||g===92)return super.readWord1();return this.containsEsc=!1,this.pos=m,d.slice(w,m)}readWord(){let d=this.readWord1();return this.finishToken(l.get(d)??r.name,d)}}}),rt=S(q),it=/ \(\d+:\d+\)$/;function Oe(t){return t}function Qe(t){return t instanceof SyntaxError&&"pos"in t&&typeof t.pos==="number"}function De(t,n,r,l,d,w=t.root.comments.length){let m=t.root.comments;Je(n,m);let g={onComment:t.comments?Ke:qe,sourceType:"module",ecmaVersion:16,locations:t.loc,preserveParens:l};if(t.lfOnly)g.startLocation=o(r);let k=t.isTypeScript?t.typescript:rt;if(!k)T();let x;try{x=d(k,g)}catch(_e){if(!Qe(_e))throw _e;Ue(_e.pos,_e.message.replace(it,""))}if(m.length>w)Ye(Oe(x),m,r);return x}function b(t,n,r=0){return Oe(De(t,n,0,!1,(l,d)=>{if(r>0&&d.locations)d.startLocation=o(r);let w=new l(d,n,r).parse();return w.start=0,w},0))}var st={count:0};function h(t,n,r,l=!1){st.count+=1,Re=!1;let d=Oe(De(t,n,r,!0,(m,g)=>m.parseExpressionAt(n,r,g))),w=Math.max(d.end,Xe());return{node:Re&&!l?Ze(d):d,end:w}}function Ee(t,n,r){return Oe(De(t,n,r,!1,(l,d)=>{let w=new l(d,n,r);try{return w.nextToken(),w.parseStatement(null,!0,Object.create(null))}catch(m){if(Qe(m)&&m.pos===n.length)i(n.length);throw m}}))}function Ne(t,n,r){let l=De(t,n,0,!1,(d,w)=>{let m=new d(w,n,0),g=m.startNode(),k=[],x=Object.create(null);return r((_e)=>{m.pos=_e,m.context=m.initialContext(),m.exprAllowed=!0,m.nextToken();let Ce=m.parseStatement(null,!0,x);return k.push(Ce),Ce.end}),g.body=k,m.finishNode(g,"Program")});return Oe(l).body}function Ze(t){let n=t;while(n.type==="ParenthesizedExpression")n=n.expression;return f(n,Ze),n}
12
+ export{p,o,c,e,O,D,B,F,V,M,j,W,z,U,N,H,G,C,K,Q,X,Y,A,_,J,P,Z,ee,s,te,ie,re,se,ne,oe,ae,le,pe,L,ce,he,ue,fe,de,me,E,ye,xe,ge,I,be,ve,Se,ke,i,we,Te,Ae,q,b,h,Ee,Ne};
@@ -0,0 +1,2 @@
1
+ import{p,b}from"./shared-3xek95jd.js";function y(e,r,o){return p(e),b({isTypeScript:r.typescript??!1,typescript:o,loc:r.loc??!1,comments:r.comments??!0,root:{comments:[]}},e)}
2
+ export{y};
@@ -1,2 +1,2 @@
1
- var b=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376],p=/[:!]/;function q(e){let n;return()=>(n??=m(e),n)}function m(e){let n=new Map,a=0,t="";for(let u of e.split(" ")){let o=u.search(p);t=t.slice(0,Number.parseInt(u[0],36))+u.slice(1,o);let r=Number.parseInt(u.slice(o+1),36);if(n.set(`${t};`,r),u[o]==="!")n.set(t,r);a=Math.max(a,t.length+1)}return{table:n,longest:a}}var Ee=q("0amp!12 1pos:13 0gt!1q 0lt!1o 0quot!y"),l=(e)=>e>=48&&e<=57,E=(e)=>l(e)||e>=65&&e<=70||e>=97&&e<=102,g=(e)=>l(e)||e>=65&&e<=90||e>=97&&e<=122,c=0;function N(e,n,a,t){if(e.charCodeAt(n)===35){let i=(e.charCodeAt(n+1)|32)===120,f=n+(i?2:1),s=f;while(s<e.length&&(i?E:l)(e.charCodeAt(s)))s++;if(s===f)return 0;return c=e.charCodeAt(s)===59?s+1:s,Number.parseInt(e.slice(f,s),i?16:10)}let{table:u,longest:o}=t(),r=n;while(r-n<o&&g(e.charCodeAt(r)))r++;if(e.charCodeAt(r)===59){let i=u.get(e.slice(n,r+1));if(i!==void 0)return c=r+1,i}for(let i=r;i>n;i--){let f=u.get(e.slice(n,i));if(f===void 0)continue;if(a){let s=e.charCodeAt(i);if(g(s)||s===95||s===61)continue}return c=i,f}return 0}function y(e,n){if(e===10&&!n)return 32;if(e<128)return e;if(e<=159)return b[e-128];if(e>=55296&&e<=57343)return 0;if(e<=196607)return e;if(e>=917504&&e<=917631||e>=917760&&e<=917999)return e;return 0}function k(e,n,a){let t=e.indexOf("&");if(t===-1)return e;let u="",o=0;while(t!==-1){let r=N(e,t+1,n,a);if(r)u+=e.slice(o,t)+String.fromCodePoint(y(r,n)),o=c;t=e.indexOf("&",r?o:t+1)}return u+e.slice(o)}
2
- export{q,Ee,k};
1
+ var b=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376],p=/[:!]/;function R(e){let n;return()=>(n??=m(e),n)}function m(e){let n=new Map,a=0,t="";for(let u of e.split(" ")){let o=u.search(p);t=t.slice(0,Number.parseInt(u[0],36))+u.slice(1,o);let r=Number.parseInt(u.slice(o+1),36);if(n.set(`${t};`,r),u[o]==="!")n.set(t,r);a=Math.max(a,t.length+1)}return{table:n,longest:a}}var Ce=R("0amp!12 1pos:13 0gt!1q 0lt!1o 0quot!y"),l=(e)=>e>=48&&e<=57,E=(e)=>l(e)||e>=65&&e<=70||e>=97&&e<=102,g=(e)=>l(e)||e>=65&&e<=90||e>=97&&e<=122,c=0;function N(e,n,a,t){if(e.charCodeAt(n)===35){let i=(e.charCodeAt(n+1)|32)===120,f=n+(i?2:1),s=f;while(s<e.length&&(i?E:l)(e.charCodeAt(s)))s++;if(s===f)return 0;return c=e.charCodeAt(s)===59?s+1:s,Number.parseInt(e.slice(f,s),i?16:10)}let{table:u,longest:o}=t(),r=n;while(r-n<o&&g(e.charCodeAt(r)))r++;if(e.charCodeAt(r)===59){let i=u.get(e.slice(n,r+1));if(i!==void 0)return c=r+1,i}for(let i=r;i>n;i--){let f=u.get(e.slice(n,i));if(f===void 0)continue;if(a){let s=e.charCodeAt(i);if(g(s)||s===95||s===61)continue}return c=i,f}return 0}function y(e,n){if(e===10&&!n)return 32;if(e<128)return e;if(e<=159)return b[e-128];if(e>=55296&&e<=57343)return 0;if(e<=196607)return e;if(e>=917504&&e<=917631||e>=917760&&e<=917999)return e;return 0}function w(e,n,a){let t=e.indexOf("&");if(t===-1)return e;let u="",o=0;while(t!==-1){let r=N(e,t+1,n,a);if(r)u+=e.slice(o,t)+String.fromCodePoint(y(r,n)),o=c;t=e.indexOf("&",r?o:t+1)}return u+e.slice(o)}
2
+ export{R,Ce,w};
@@ -0,0 +1,2 @@
1
+ function a(e){return typeof e==="object"&&e!==null&&typeof u(e).type==="string"}function u(e){return e}function f(e,t){let n=u(e);for(let o in n){let s=n[o];if(Array.isArray(s)){for(let r=0;r<s.length;r++)if(a(s[r]))s[r]=t(s[r])}else if(a(s))n[o]=t(s)}}function d(e,...t){if(!t.some((n)=>n===e.type))throw Error(`expected ${t.join(" or ")}, got ${e.type}`)}
2
+ export{a,u,f,d};