storybook 10.1.0-alpha.9 → 10.1.0-beta.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 (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2908 -8518
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +68 -69
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
  161. package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
  162. package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
  163. package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
  164. package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
  165. package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
  166. package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
  167. package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
  168. package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
  169. package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
  170. package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
  171. package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
  172. package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
  173. package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
  174. package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
  175. package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
  176. package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
  177. package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
  178. package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
  179. package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
  180. package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
  181. package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
  182. package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
  183. package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
  184. package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
  185. package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
  186. package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
  187. package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
  188. package/dist/_node-chunks/dist-SL73W244.js +0 -175
  189. package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
  190. package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
  192. package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
  193. package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
  194. package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
@@ -0,0 +1,1126 @@
1
+ import { types } from 'storybook/internal/babel';
2
+ import { CoreConfig } from 'storybook/internal/types';
3
+
4
+ // This definition file follows a somewhat unusual format. ESTree allows
5
+ // runtime type checks based on the `type` parameter. In order to explain this
6
+ // to typescript we want to use discriminated union types:
7
+ // https://github.com/Microsoft/TypeScript/pull/9163
8
+ //
9
+ // For ESTree this is a bit tricky because the high level interfaces like
10
+ // Node or Function are pulling double duty. We want to pass common fields down
11
+ // to the interfaces that extend them (like Identifier or
12
+ // ArrowFunctionExpression), but you can't extend a type union or enforce
13
+ // common fields on them. So we've split the high level interfaces into two
14
+ // types, a base type which passes down inherited fields, and a type union of
15
+ // all types which extend the base type. Only the type union is exported, and
16
+ // the union is how other types refer to the collection of inheriting types.
17
+ //
18
+ // This makes the definitions file here somewhat more difficult to maintain,
19
+ // but it has the notable advantage of making ESTree much easier to use as
20
+ // an end user.
21
+
22
+ interface BaseNodeWithoutComments {
23
+ // Every leaf interface that extends BaseNode must specify a type property.
24
+ // The type property should be a string literal. For example, Identifier
25
+ // has: `type: "Identifier"`
26
+ type: string;
27
+ loc?: SourceLocation | null | undefined;
28
+ range?: [number, number] | undefined;
29
+ }
30
+
31
+ interface BaseNode extends BaseNodeWithoutComments {
32
+ leadingComments?: Comment[] | undefined;
33
+ trailingComments?: Comment[] | undefined;
34
+ }
35
+
36
+ interface NodeMap {
37
+ AssignmentProperty: AssignmentProperty;
38
+ CatchClause: CatchClause;
39
+ Class: Class;
40
+ ClassBody: ClassBody;
41
+ Expression: Expression;
42
+ Function: Function;
43
+ Identifier: Identifier;
44
+ Literal: Literal;
45
+ MethodDefinition: MethodDefinition;
46
+ ModuleDeclaration: ModuleDeclaration;
47
+ ModuleSpecifier: ModuleSpecifier;
48
+ Pattern: Pattern;
49
+ PrivateIdentifier: PrivateIdentifier;
50
+ Program: Program;
51
+ Property: Property;
52
+ PropertyDefinition: PropertyDefinition;
53
+ SpreadElement: SpreadElement;
54
+ Statement: Statement;
55
+ Super: Super;
56
+ SwitchCase: SwitchCase;
57
+ TemplateElement: TemplateElement;
58
+ VariableDeclarator: VariableDeclarator;
59
+ }
60
+
61
+ type Node$1 = NodeMap[keyof NodeMap];
62
+
63
+ interface Comment extends BaseNodeWithoutComments {
64
+ type: "Line" | "Block";
65
+ value: string;
66
+ }
67
+
68
+ interface SourceLocation {
69
+ source?: string | null | undefined;
70
+ start: Position;
71
+ end: Position;
72
+ }
73
+
74
+ interface Position {
75
+ /** >= 1 */
76
+ line: number;
77
+ /** >= 0 */
78
+ column: number;
79
+ }
80
+
81
+ interface Program extends BaseNode {
82
+ type: "Program";
83
+ sourceType: "script" | "module";
84
+ body: Array<Directive | Statement | ModuleDeclaration>;
85
+ comments?: Comment[] | undefined;
86
+ }
87
+
88
+ interface Directive extends BaseNode {
89
+ type: "ExpressionStatement";
90
+ expression: Literal;
91
+ directive: string;
92
+ }
93
+
94
+ interface BaseFunction extends BaseNode {
95
+ params: Pattern[];
96
+ generator?: boolean | undefined;
97
+ async?: boolean | undefined;
98
+ // The body is either BlockStatement or Expression because arrow functions
99
+ // can have a body that's either. FunctionDeclarations and
100
+ // FunctionExpressions have only BlockStatement bodies.
101
+ body: BlockStatement | Expression;
102
+ }
103
+
104
+ type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
105
+
106
+ type Statement =
107
+ | ExpressionStatement
108
+ | BlockStatement
109
+ | StaticBlock
110
+ | EmptyStatement
111
+ | DebuggerStatement
112
+ | WithStatement
113
+ | ReturnStatement
114
+ | LabeledStatement
115
+ | BreakStatement
116
+ | ContinueStatement
117
+ | IfStatement
118
+ | SwitchStatement
119
+ | ThrowStatement
120
+ | TryStatement
121
+ | WhileStatement
122
+ | DoWhileStatement
123
+ | ForStatement
124
+ | ForInStatement
125
+ | ForOfStatement
126
+ | Declaration;
127
+
128
+ interface BaseStatement extends BaseNode {}
129
+
130
+ interface EmptyStatement extends BaseStatement {
131
+ type: "EmptyStatement";
132
+ }
133
+
134
+ interface BlockStatement extends BaseStatement {
135
+ type: "BlockStatement";
136
+ body: Statement[];
137
+ innerComments?: Comment[] | undefined;
138
+ }
139
+
140
+ interface StaticBlock extends Omit<BlockStatement, "type"> {
141
+ type: "StaticBlock";
142
+ }
143
+
144
+ interface ExpressionStatement extends BaseStatement {
145
+ type: "ExpressionStatement";
146
+ expression: Expression;
147
+ }
148
+
149
+ interface IfStatement extends BaseStatement {
150
+ type: "IfStatement";
151
+ test: Expression;
152
+ consequent: Statement;
153
+ alternate?: Statement | null | undefined;
154
+ }
155
+
156
+ interface LabeledStatement extends BaseStatement {
157
+ type: "LabeledStatement";
158
+ label: Identifier;
159
+ body: Statement;
160
+ }
161
+
162
+ interface BreakStatement extends BaseStatement {
163
+ type: "BreakStatement";
164
+ label?: Identifier | null | undefined;
165
+ }
166
+
167
+ interface ContinueStatement extends BaseStatement {
168
+ type: "ContinueStatement";
169
+ label?: Identifier | null | undefined;
170
+ }
171
+
172
+ interface WithStatement extends BaseStatement {
173
+ type: "WithStatement";
174
+ object: Expression;
175
+ body: Statement;
176
+ }
177
+
178
+ interface SwitchStatement extends BaseStatement {
179
+ type: "SwitchStatement";
180
+ discriminant: Expression;
181
+ cases: SwitchCase[];
182
+ }
183
+
184
+ interface ReturnStatement extends BaseStatement {
185
+ type: "ReturnStatement";
186
+ argument?: Expression | null | undefined;
187
+ }
188
+
189
+ interface ThrowStatement extends BaseStatement {
190
+ type: "ThrowStatement";
191
+ argument: Expression;
192
+ }
193
+
194
+ interface TryStatement extends BaseStatement {
195
+ type: "TryStatement";
196
+ block: BlockStatement;
197
+ handler?: CatchClause | null | undefined;
198
+ finalizer?: BlockStatement | null | undefined;
199
+ }
200
+
201
+ interface WhileStatement extends BaseStatement {
202
+ type: "WhileStatement";
203
+ test: Expression;
204
+ body: Statement;
205
+ }
206
+
207
+ interface DoWhileStatement extends BaseStatement {
208
+ type: "DoWhileStatement";
209
+ body: Statement;
210
+ test: Expression;
211
+ }
212
+
213
+ interface ForStatement extends BaseStatement {
214
+ type: "ForStatement";
215
+ init?: VariableDeclaration | Expression | null | undefined;
216
+ test?: Expression | null | undefined;
217
+ update?: Expression | null | undefined;
218
+ body: Statement;
219
+ }
220
+
221
+ interface BaseForXStatement extends BaseStatement {
222
+ left: VariableDeclaration | Pattern;
223
+ right: Expression;
224
+ body: Statement;
225
+ }
226
+
227
+ interface ForInStatement extends BaseForXStatement {
228
+ type: "ForInStatement";
229
+ }
230
+
231
+ interface DebuggerStatement extends BaseStatement {
232
+ type: "DebuggerStatement";
233
+ }
234
+
235
+ type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
236
+
237
+ interface BaseDeclaration extends BaseStatement {}
238
+
239
+ interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
240
+ type: "FunctionDeclaration";
241
+ /** It is null when a function declaration is a part of the `export default function` statement */
242
+ id: Identifier | null;
243
+ body: BlockStatement;
244
+ }
245
+
246
+ interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
247
+ id: Identifier;
248
+ }
249
+
250
+ interface VariableDeclaration extends BaseDeclaration {
251
+ type: "VariableDeclaration";
252
+ declarations: VariableDeclarator[];
253
+ kind: "var" | "let" | "const" | "using" | "await using";
254
+ }
255
+
256
+ interface VariableDeclarator extends BaseNode {
257
+ type: "VariableDeclarator";
258
+ id: Pattern;
259
+ init?: Expression | null | undefined;
260
+ }
261
+
262
+ interface ExpressionMap {
263
+ ArrayExpression: ArrayExpression;
264
+ ArrowFunctionExpression: ArrowFunctionExpression;
265
+ AssignmentExpression: AssignmentExpression;
266
+ AwaitExpression: AwaitExpression;
267
+ BinaryExpression: BinaryExpression;
268
+ CallExpression: CallExpression;
269
+ ChainExpression: ChainExpression;
270
+ ClassExpression: ClassExpression;
271
+ ConditionalExpression: ConditionalExpression;
272
+ FunctionExpression: FunctionExpression;
273
+ Identifier: Identifier;
274
+ ImportExpression: ImportExpression;
275
+ Literal: Literal;
276
+ LogicalExpression: LogicalExpression;
277
+ MemberExpression: MemberExpression;
278
+ MetaProperty: MetaProperty;
279
+ NewExpression: NewExpression;
280
+ ObjectExpression: ObjectExpression;
281
+ SequenceExpression: SequenceExpression;
282
+ TaggedTemplateExpression: TaggedTemplateExpression;
283
+ TemplateLiteral: TemplateLiteral;
284
+ ThisExpression: ThisExpression;
285
+ UnaryExpression: UnaryExpression;
286
+ UpdateExpression: UpdateExpression;
287
+ YieldExpression: YieldExpression;
288
+ }
289
+
290
+ type Expression = ExpressionMap[keyof ExpressionMap];
291
+
292
+ interface BaseExpression extends BaseNode {}
293
+
294
+ type ChainElement = SimpleCallExpression | MemberExpression;
295
+
296
+ interface ChainExpression extends BaseExpression {
297
+ type: "ChainExpression";
298
+ expression: ChainElement;
299
+ }
300
+
301
+ interface ThisExpression extends BaseExpression {
302
+ type: "ThisExpression";
303
+ }
304
+
305
+ interface ArrayExpression extends BaseExpression {
306
+ type: "ArrayExpression";
307
+ elements: Array<Expression | SpreadElement | null>;
308
+ }
309
+
310
+ interface ObjectExpression extends BaseExpression {
311
+ type: "ObjectExpression";
312
+ properties: Array<Property | SpreadElement>;
313
+ }
314
+
315
+ interface PrivateIdentifier extends BaseNode {
316
+ type: "PrivateIdentifier";
317
+ name: string;
318
+ }
319
+
320
+ interface Property extends BaseNode {
321
+ type: "Property";
322
+ key: Expression | PrivateIdentifier;
323
+ value: Expression | Pattern; // Could be an AssignmentProperty
324
+ kind: "init" | "get" | "set";
325
+ method: boolean;
326
+ shorthand: boolean;
327
+ computed: boolean;
328
+ }
329
+
330
+ interface PropertyDefinition extends BaseNode {
331
+ type: "PropertyDefinition";
332
+ key: Expression | PrivateIdentifier;
333
+ value?: Expression | null | undefined;
334
+ computed: boolean;
335
+ static: boolean;
336
+ }
337
+
338
+ interface FunctionExpression extends BaseFunction, BaseExpression {
339
+ id?: Identifier | null | undefined;
340
+ type: "FunctionExpression";
341
+ body: BlockStatement;
342
+ }
343
+
344
+ interface SequenceExpression extends BaseExpression {
345
+ type: "SequenceExpression";
346
+ expressions: Expression[];
347
+ }
348
+
349
+ interface UnaryExpression extends BaseExpression {
350
+ type: "UnaryExpression";
351
+ operator: UnaryOperator;
352
+ prefix: true;
353
+ argument: Expression;
354
+ }
355
+
356
+ interface BinaryExpression extends BaseExpression {
357
+ type: "BinaryExpression";
358
+ operator: BinaryOperator;
359
+ left: Expression | PrivateIdentifier;
360
+ right: Expression;
361
+ }
362
+
363
+ interface AssignmentExpression extends BaseExpression {
364
+ type: "AssignmentExpression";
365
+ operator: AssignmentOperator;
366
+ left: Pattern | MemberExpression;
367
+ right: Expression;
368
+ }
369
+
370
+ interface UpdateExpression extends BaseExpression {
371
+ type: "UpdateExpression";
372
+ operator: UpdateOperator;
373
+ argument: Expression;
374
+ prefix: boolean;
375
+ }
376
+
377
+ interface LogicalExpression extends BaseExpression {
378
+ type: "LogicalExpression";
379
+ operator: LogicalOperator;
380
+ left: Expression;
381
+ right: Expression;
382
+ }
383
+
384
+ interface ConditionalExpression extends BaseExpression {
385
+ type: "ConditionalExpression";
386
+ test: Expression;
387
+ alternate: Expression;
388
+ consequent: Expression;
389
+ }
390
+
391
+ interface BaseCallExpression extends BaseExpression {
392
+ callee: Expression | Super;
393
+ arguments: Array<Expression | SpreadElement>;
394
+ }
395
+ type CallExpression = SimpleCallExpression | NewExpression;
396
+
397
+ interface SimpleCallExpression extends BaseCallExpression {
398
+ type: "CallExpression";
399
+ optional: boolean;
400
+ }
401
+
402
+ interface NewExpression extends BaseCallExpression {
403
+ type: "NewExpression";
404
+ }
405
+
406
+ interface MemberExpression extends BaseExpression, BasePattern {
407
+ type: "MemberExpression";
408
+ object: Expression | Super;
409
+ property: Expression | PrivateIdentifier;
410
+ computed: boolean;
411
+ optional: boolean;
412
+ }
413
+
414
+ type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
415
+
416
+ interface BasePattern extends BaseNode {}
417
+
418
+ interface SwitchCase extends BaseNode {
419
+ type: "SwitchCase";
420
+ test?: Expression | null | undefined;
421
+ consequent: Statement[];
422
+ }
423
+
424
+ interface CatchClause extends BaseNode {
425
+ type: "CatchClause";
426
+ param: Pattern | null;
427
+ body: BlockStatement;
428
+ }
429
+
430
+ interface Identifier extends BaseNode, BaseExpression, BasePattern {
431
+ type: "Identifier";
432
+ name: string;
433
+ }
434
+
435
+ type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
436
+
437
+ interface SimpleLiteral extends BaseNode, BaseExpression {
438
+ type: "Literal";
439
+ value: string | boolean | number | null;
440
+ raw?: string | undefined;
441
+ }
442
+
443
+ interface RegExpLiteral extends BaseNode, BaseExpression {
444
+ type: "Literal";
445
+ value?: RegExp | null | undefined;
446
+ regex: {
447
+ pattern: string;
448
+ flags: string;
449
+ };
450
+ raw?: string | undefined;
451
+ }
452
+
453
+ interface BigIntLiteral extends BaseNode, BaseExpression {
454
+ type: "Literal";
455
+ value?: bigint | null | undefined;
456
+ bigint: string;
457
+ raw?: string | undefined;
458
+ }
459
+
460
+ type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
461
+
462
+ type BinaryOperator =
463
+ | "=="
464
+ | "!="
465
+ | "==="
466
+ | "!=="
467
+ | "<"
468
+ | "<="
469
+ | ">"
470
+ | ">="
471
+ | "<<"
472
+ | ">>"
473
+ | ">>>"
474
+ | "+"
475
+ | "-"
476
+ | "*"
477
+ | "/"
478
+ | "%"
479
+ | "**"
480
+ | "|"
481
+ | "^"
482
+ | "&"
483
+ | "in"
484
+ | "instanceof";
485
+
486
+ type LogicalOperator = "||" | "&&" | "??";
487
+
488
+ type AssignmentOperator =
489
+ | "="
490
+ | "+="
491
+ | "-="
492
+ | "*="
493
+ | "/="
494
+ | "%="
495
+ | "**="
496
+ | "<<="
497
+ | ">>="
498
+ | ">>>="
499
+ | "|="
500
+ | "^="
501
+ | "&="
502
+ | "||="
503
+ | "&&="
504
+ | "??=";
505
+
506
+ type UpdateOperator = "++" | "--";
507
+
508
+ interface ForOfStatement extends BaseForXStatement {
509
+ type: "ForOfStatement";
510
+ await: boolean;
511
+ }
512
+
513
+ interface Super extends BaseNode {
514
+ type: "Super";
515
+ }
516
+
517
+ interface SpreadElement extends BaseNode {
518
+ type: "SpreadElement";
519
+ argument: Expression;
520
+ }
521
+
522
+ interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
523
+ type: "ArrowFunctionExpression";
524
+ expression: boolean;
525
+ body: BlockStatement | Expression;
526
+ }
527
+
528
+ interface YieldExpression extends BaseExpression {
529
+ type: "YieldExpression";
530
+ argument?: Expression | null | undefined;
531
+ delegate: boolean;
532
+ }
533
+
534
+ interface TemplateLiteral extends BaseExpression {
535
+ type: "TemplateLiteral";
536
+ quasis: TemplateElement[];
537
+ expressions: Expression[];
538
+ }
539
+
540
+ interface TaggedTemplateExpression extends BaseExpression {
541
+ type: "TaggedTemplateExpression";
542
+ tag: Expression;
543
+ quasi: TemplateLiteral;
544
+ }
545
+
546
+ interface TemplateElement extends BaseNode {
547
+ type: "TemplateElement";
548
+ tail: boolean;
549
+ value: {
550
+ /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
551
+ cooked?: string | null | undefined;
552
+ raw: string;
553
+ };
554
+ }
555
+
556
+ interface AssignmentProperty extends Property {
557
+ value: Pattern;
558
+ kind: "init";
559
+ method: boolean; // false
560
+ }
561
+
562
+ interface ObjectPattern extends BasePattern {
563
+ type: "ObjectPattern";
564
+ properties: Array<AssignmentProperty | RestElement>;
565
+ }
566
+
567
+ interface ArrayPattern extends BasePattern {
568
+ type: "ArrayPattern";
569
+ elements: Array<Pattern | null>;
570
+ }
571
+
572
+ interface RestElement extends BasePattern {
573
+ type: "RestElement";
574
+ argument: Pattern;
575
+ }
576
+
577
+ interface AssignmentPattern extends BasePattern {
578
+ type: "AssignmentPattern";
579
+ left: Pattern;
580
+ right: Expression;
581
+ }
582
+
583
+ type Class = ClassDeclaration | ClassExpression;
584
+ interface BaseClass extends BaseNode {
585
+ superClass?: Expression | null | undefined;
586
+ body: ClassBody;
587
+ }
588
+
589
+ interface ClassBody extends BaseNode {
590
+ type: "ClassBody";
591
+ body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
592
+ }
593
+
594
+ interface MethodDefinition extends BaseNode {
595
+ type: "MethodDefinition";
596
+ key: Expression | PrivateIdentifier;
597
+ value: FunctionExpression;
598
+ kind: "constructor" | "method" | "get" | "set";
599
+ computed: boolean;
600
+ static: boolean;
601
+ }
602
+
603
+ interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
604
+ type: "ClassDeclaration";
605
+ /** It is null when a class declaration is a part of the `export default class` statement */
606
+ id: Identifier | null;
607
+ }
608
+
609
+ interface ClassDeclaration extends MaybeNamedClassDeclaration {
610
+ id: Identifier;
611
+ }
612
+
613
+ interface ClassExpression extends BaseClass, BaseExpression {
614
+ type: "ClassExpression";
615
+ id?: Identifier | null | undefined;
616
+ }
617
+
618
+ interface MetaProperty extends BaseExpression {
619
+ type: "MetaProperty";
620
+ meta: Identifier;
621
+ property: Identifier;
622
+ }
623
+
624
+ type ModuleDeclaration =
625
+ | ImportDeclaration
626
+ | ExportNamedDeclaration
627
+ | ExportDefaultDeclaration
628
+ | ExportAllDeclaration;
629
+ interface BaseModuleDeclaration extends BaseNode {}
630
+
631
+ type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
632
+ interface BaseModuleSpecifier extends BaseNode {
633
+ local: Identifier;
634
+ }
635
+
636
+ interface ImportDeclaration extends BaseModuleDeclaration {
637
+ type: "ImportDeclaration";
638
+ specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
639
+ attributes: ImportAttribute[];
640
+ source: Literal;
641
+ }
642
+
643
+ interface ImportSpecifier extends BaseModuleSpecifier {
644
+ type: "ImportSpecifier";
645
+ imported: Identifier | Literal;
646
+ }
647
+
648
+ interface ImportAttribute extends BaseNode {
649
+ type: "ImportAttribute";
650
+ key: Identifier | Literal;
651
+ value: Literal;
652
+ }
653
+
654
+ interface ImportExpression extends BaseExpression {
655
+ type: "ImportExpression";
656
+ source: Expression;
657
+ options?: Expression | null | undefined;
658
+ }
659
+
660
+ interface ImportDefaultSpecifier extends BaseModuleSpecifier {
661
+ type: "ImportDefaultSpecifier";
662
+ }
663
+
664
+ interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
665
+ type: "ImportNamespaceSpecifier";
666
+ }
667
+
668
+ interface ExportNamedDeclaration extends BaseModuleDeclaration {
669
+ type: "ExportNamedDeclaration";
670
+ declaration?: Declaration | null | undefined;
671
+ specifiers: ExportSpecifier[];
672
+ attributes: ImportAttribute[];
673
+ source?: Literal | null | undefined;
674
+ }
675
+
676
+ interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
677
+ type: "ExportSpecifier";
678
+ local: Identifier | Literal;
679
+ exported: Identifier | Literal;
680
+ }
681
+
682
+ interface ExportDefaultDeclaration extends BaseModuleDeclaration {
683
+ type: "ExportDefaultDeclaration";
684
+ declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
685
+ }
686
+
687
+ interface ExportAllDeclaration extends BaseModuleDeclaration {
688
+ type: "ExportAllDeclaration";
689
+ exported: Identifier | Literal | null;
690
+ attributes: ImportAttribute[];
691
+ source: Literal;
692
+ }
693
+
694
+ interface AwaitExpression extends BaseExpression {
695
+ type: "AwaitExpression";
696
+ argument: Expression;
697
+ }
698
+
699
+ interface SourceMapOptions {
700
+ /**
701
+ * Whether the mapping should be high-resolution.
702
+ * Hi-res mappings map every single character, meaning (for example) your devtools will always
703
+ * be able to pinpoint the exact location of function calls and so on.
704
+ * With lo-res mappings, devtools may only be able to identify the correct
705
+ * line - but they're quicker to generate and less bulky.
706
+ * You can also set `"boundary"` to generate a semi-hi-res mappings segmented per word boundary
707
+ * instead of per character, suitable for string semantics that are separated by words.
708
+ * If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
709
+ */
710
+ hires?: boolean | 'boundary';
711
+ /**
712
+ * The filename where you plan to write the sourcemap.
713
+ */
714
+ file?: string;
715
+ /**
716
+ * The filename of the file containing the original source.
717
+ */
718
+ source?: string;
719
+ /**
720
+ * Whether to include the original content in the map's sourcesContent array.
721
+ */
722
+ includeContent?: boolean;
723
+ }
724
+
725
+ type SourceMapSegment =
726
+ | [number]
727
+ | [number, number, number, number]
728
+ | [number, number, number, number, number];
729
+
730
+ interface DecodedSourceMap {
731
+ file: string;
732
+ sources: string[];
733
+ sourcesContent?: string[];
734
+ names: string[];
735
+ mappings: SourceMapSegment[][];
736
+ x_google_ignoreList?: number[];
737
+ }
738
+
739
+ declare class SourceMap {
740
+ constructor(properties: DecodedSourceMap);
741
+
742
+ version: number;
743
+ file: string;
744
+ sources: string[];
745
+ sourcesContent?: string[];
746
+ names: string[];
747
+ mappings: string;
748
+ x_google_ignoreList?: number[];
749
+ debugId?: string;
750
+
751
+ /**
752
+ * Returns the equivalent of `JSON.stringify(map)`
753
+ */
754
+ toString(): string;
755
+ /**
756
+ * Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
757
+ * `generateMap(options?: SourceMapOptions): SourceMap;`
758
+ */
759
+ toUrl(): string;
760
+ }
761
+
762
+ type ExclusionRange = [number, number];
763
+
764
+ interface MagicStringOptions {
765
+ filename?: string;
766
+ indentExclusionRanges?: ExclusionRange | Array<ExclusionRange>;
767
+ offset?: number;
768
+ }
769
+
770
+ interface IndentOptions {
771
+ exclude?: ExclusionRange | Array<ExclusionRange>;
772
+ indentStart?: boolean;
773
+ }
774
+
775
+ interface OverwriteOptions {
776
+ storeName?: boolean;
777
+ contentOnly?: boolean;
778
+ }
779
+
780
+ interface UpdateOptions {
781
+ storeName?: boolean;
782
+ overwrite?: boolean;
783
+ }
784
+
785
+ declare class MagicString {
786
+ constructor(str: string, options?: MagicStringOptions);
787
+ /**
788
+ * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
789
+ */
790
+ addSourcemapLocation(char: number): void;
791
+ /**
792
+ * Appends the specified content to the end of the string.
793
+ */
794
+ append(content: string): this;
795
+ /**
796
+ * Appends the specified content at the index in the original string.
797
+ * If a range *ending* with index is subsequently moved, the insert will be moved with it.
798
+ * See also `s.prependLeft(...)`.
799
+ */
800
+ appendLeft(index: number, content: string): this;
801
+ /**
802
+ * Appends the specified content at the index in the original string.
803
+ * If a range *starting* with index is subsequently moved, the insert will be moved with it.
804
+ * See also `s.prependRight(...)`.
805
+ */
806
+ appendRight(index: number, content: string): this;
807
+ /**
808
+ * Does what you'd expect.
809
+ */
810
+ clone(): this;
811
+ /**
812
+ * Generates a version 3 sourcemap.
813
+ */
814
+ generateMap(options?: SourceMapOptions): SourceMap;
815
+ /**
816
+ * Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
817
+ * Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
818
+ */
819
+ generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
820
+ getIndentString(): string;
821
+
822
+ /**
823
+ * Prefixes each line of the string with prefix.
824
+ * If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
825
+ */
826
+ indent(options?: IndentOptions): this;
827
+ /**
828
+ * Prefixes each line of the string with prefix.
829
+ * If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
830
+ *
831
+ * The options argument can have an exclude property, which is an array of [start, end] character ranges.
832
+ * These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
833
+ */
834
+ indent(indentStr?: string, options?: IndentOptions): this;
835
+ indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
836
+
837
+ /**
838
+ * Moves the characters from `start` and `end` to `index`.
839
+ */
840
+ move(start: number, end: number, index: number): this;
841
+ /**
842
+ * Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
843
+ * that range. The same restrictions as `s.remove()` apply.
844
+ *
845
+ * The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
846
+ * for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only
847
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
848
+ *
849
+ * It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
850
+ */
851
+ overwrite(
852
+ start: number,
853
+ end: number,
854
+ content: string,
855
+ options?: boolean | OverwriteOptions,
856
+ ): this;
857
+ /**
858
+ * Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
859
+ *
860
+ * The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
861
+ * for later inclusion in a sourcemap's names array — and an overwrite property which determines whether only
862
+ * the content is overwritten, or anything that was appended/prepended to the range as well.
863
+ */
864
+ update(start: number, end: number, content: string, options?: boolean | UpdateOptions): this;
865
+ /**
866
+ * Prepends the string with the specified content.
867
+ */
868
+ prepend(content: string): this;
869
+ /**
870
+ * Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
871
+ */
872
+ prependLeft(index: number, content: string): this;
873
+ /**
874
+ * Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
875
+ */
876
+ prependRight(index: number, content: string): this;
877
+ /**
878
+ * Removes the characters from `start` to `end` (of the original string, **not** the generated string).
879
+ * Removing the same content twice, or making removals that partially overlap, will cause an error.
880
+ */
881
+ remove(start: number, end: number): this;
882
+ /**
883
+ * Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
884
+ */
885
+ reset(start: number, end: number): this;
886
+ /**
887
+ * Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
888
+ * Throws error if the indices are for characters that were already removed.
889
+ */
890
+ slice(start: number, end: number): string;
891
+ /**
892
+ * Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
893
+ */
894
+ snip(start: number, end: number): this;
895
+ /**
896
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
897
+ */
898
+ trim(charType?: string): this;
899
+ /**
900
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
901
+ */
902
+ trimStart(charType?: string): this;
903
+ /**
904
+ * Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
905
+ */
906
+ trimEnd(charType?: string): this;
907
+ /**
908
+ * Removes empty lines from the start and end.
909
+ */
910
+ trimLines(): this;
911
+ /**
912
+ * String replacement with RegExp or string.
913
+ */
914
+ replace(
915
+ regex: RegExp | string,
916
+ replacement: string | ((substring: string, ...args: any[]) => string),
917
+ ): this;
918
+ /**
919
+ * Same as `s.replace`, but replace all matched strings instead of just one.
920
+ */
921
+ replaceAll(
922
+ regex: RegExp | string,
923
+ replacement: string | ((substring: string, ...args: any[]) => string),
924
+ ): this;
925
+
926
+ lastChar(): string;
927
+ lastLine(): string;
928
+ /**
929
+ * Returns true if the resulting source is empty (disregarding white space).
930
+ */
931
+ isEmpty(): boolean;
932
+ length(): number;
933
+
934
+ /**
935
+ * Indicates if the string has been changed.
936
+ */
937
+ hasChanged(): boolean;
938
+
939
+ original: string;
940
+ /**
941
+ * Returns the generated string.
942
+ */
943
+ toString(): string;
944
+
945
+ offset: number;
946
+ }
947
+
948
+ type ParseFn = (code: string) => Program;
949
+ declare const __STORYBOOK_GLOBAL_THIS_ACCESSOR__ = "__vitest_mocker__";
950
+ declare function getAutomockCode(originalCode: string, isSpy: boolean, parse: ParseFn): MagicString;
951
+ /**
952
+ * Copyright (c) Vitest
953
+ * https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/mocker/src/node/automockPlugin.ts#L36C17-L36C31
954
+ * MIT License
955
+ *
956
+ * Copyright (c) 2021-Present Vitest Team
957
+ *
958
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
959
+ * associated documentation files (the "Software"), to deal in the Software without restriction,
960
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
961
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
962
+ * furnished to do so, subject to the following conditions:
963
+ *
964
+ * The above copyright notice and this permission notice shall be included in all copies or
965
+ * substantial portions of the Software.
966
+ *
967
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
968
+ * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
969
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
970
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
971
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
972
+ */
973
+ declare function automockModule(code: string, mockType: 'automock' | 'autospy', parse: (code: string) => any, options?: any): MagicString;
974
+
975
+ interface GeneratorResult {
976
+ code: string;
977
+ map: {
978
+ version: number;
979
+ sources: string[];
980
+ names: string[];
981
+ sourceRoot?: string | undefined;
982
+ sourcesContent?: string[] | undefined;
983
+ mappings: string;
984
+ file: string;
985
+ } | null;
986
+ }
987
+
988
+ declare function isModuleDirectory(path: string): boolean;
989
+ type MockCall = {
990
+ path: string;
991
+ absolutePath: string;
992
+ redirectPath: string | null;
993
+ spy: boolean;
994
+ };
995
+ interface ExtractMockCallsOptions {
996
+ /** The absolute path to the preview.tsx file where mocks are defined. */
997
+ previewConfigPath: string;
998
+ /** The absolute path to the Storybook config directory. */
999
+ coreOptions?: CoreConfig;
1000
+ /** Configuration directory */
1001
+ configDir: string;
1002
+ }
1003
+ /**
1004
+ * A wrapper around the babel parser that enables the necessary plugins to handle modern JavaScript
1005
+ * features, including TSX.
1006
+ *
1007
+ * @param code - The code to parse.
1008
+ * @returns The parsed code.
1009
+ */
1010
+ declare const babelParser: (code: string) => types.Program;
1011
+ /** Utility to rewrite sb.mock(import('...'), ...) to sb.mock('...', ...) */
1012
+ declare function rewriteSbMockImportCalls(code: string): GeneratorResult;
1013
+ /**
1014
+ * Extracts all sb.mock() calls from the preview config file.
1015
+ *
1016
+ * @param this PluginContext
1017
+ */
1018
+ declare function extractMockCalls(options: ExtractMockCallsOptions, parse: (input: string, options?: {
1019
+ allowReturnOutsideFunction?: boolean;
1020
+ jsx?: boolean;
1021
+ }) => types.Node, root: string, findMockRedirect: (root: string, absolutePath: string, externalPath: string | null) => string | null): MockCall[];
1022
+
1023
+ /**
1024
+ * Resolves an external module path to its absolute path. It considers the "exports" map in the
1025
+ * package.json file.
1026
+ *
1027
+ * @param path The raw module path from the `sb.mock()` call.
1028
+ * @param root The project's root directory.
1029
+ * @returns The absolute path to the module.
1030
+ */
1031
+ declare function resolveExternalModule(path: string, root: string): string;
1032
+ declare function getIsExternal(path: string, importer: string): boolean;
1033
+ /**
1034
+ * Resolves a mock path to its absolute path and checks for a `__mocks__` redirect. This function
1035
+ * uses `resolve.exports` to correctly handle modern ESM packages.
1036
+ *
1037
+ * @param path The raw module path from the `sb.mock()` call.
1038
+ * @param root The project's root directory.
1039
+ * @param importer The absolute path of the file containing the mock call (the preview file).
1040
+ */
1041
+ declare function resolveMock(path: string, root: string, importer: string, findMockRedirect: (root: string, absolutePath: string, externalPath: string | null) => string | null): {
1042
+ absolutePath: string;
1043
+ redirectPath: string | null;
1044
+ };
1045
+ /**
1046
+ * External mean not absolute, and not relative
1047
+ *
1048
+ * We use `require.resolve` here, because import.meta.resolve needs a experimental node flag
1049
+ * (`--experimental-import-meta-resolve`) to be enabled to respect the context option.
1050
+ *
1051
+ * @param path - The path to the mock file
1052
+ * @param from - The root of the project, this should be an absolute path
1053
+ * @returns True if the mock path is external, false otherwise
1054
+ * @link https://nodejs.org/api/cli.html#--experimental-import-meta-resolve
1055
+ */
1056
+ declare function isExternal(path: string, from: string): boolean;
1057
+ /**
1058
+ * Normalizes a file path for comparison, resolving symlinks if possible. Falls back to the original
1059
+ * path if resolution fails.
1060
+ */
1061
+ declare function getRealPath(path: string, preserveSymlinks: boolean): string;
1062
+ /**
1063
+ * This is a wrapper around `require.resolve` that tries to resolve the path with different file
1064
+ * extensions.
1065
+ *
1066
+ * @param path - The path to the mock file
1067
+ * @param from - The root of the project, this should be an absolute path
1068
+ * @returns The resolved path
1069
+ */
1070
+ declare function resolveWithExtensions(path: string, from: string): string;
1071
+
1072
+ /**
1073
+ * Copyright (c) Vitest
1074
+ * https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/mocker/src/node/esmWalker.ts MIT
1075
+ * License
1076
+ *
1077
+ * Copyright (c) 2021-Present Vitest Team
1078
+ *
1079
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
1080
+ * associated documentation files (the "Software"), to deal in the Software without restriction,
1081
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
1082
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
1083
+ * furnished to do so, subject to the following conditions:
1084
+ *
1085
+ * The above copyright notice and this permission notice shall be included in all copies or
1086
+ * substantial portions of the Software.
1087
+ *
1088
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
1089
+ * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1090
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1091
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1092
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1093
+ */
1094
+
1095
+ type Positioned<T> = T & {
1096
+ start: number;
1097
+ end: number;
1098
+ };
1099
+ type Node = Positioned<Node$1>;
1100
+ interface IdentifierInfo {
1101
+ /** If the identifier is used in a property shorthand { foo } -> { foo: **import_x**.foo } */
1102
+ hasBindingShortcut: boolean;
1103
+ /** The identifier is used in a class declaration */
1104
+ classDeclaration: boolean;
1105
+ /** The identifier is a name for a class expression */
1106
+ classExpression: boolean;
1107
+ }
1108
+ interface Visitors {
1109
+ onIdentifier?: (node: Positioned<Identifier>, info: IdentifierInfo, parentStack: Node[]) => void;
1110
+ onImportMeta?: (node: Node) => void;
1111
+ onDynamicImport?: (node: Positioned<ImportExpression>) => void;
1112
+ onCallExpression?: (node: Positioned<CallExpression>) => void;
1113
+ }
1114
+ declare function setIsNodeInPattern(node: Property): WeakSet<Node$1>;
1115
+ declare function isNodeInPattern(node: Node$1): node is Property;
1116
+ /** Same logic from @vue/compiler-core & @vue/compiler-sfc Except this is using acorn AST */
1117
+ declare function esmWalker(root: Node, { onIdentifier, onImportMeta, onDynamicImport, onCallExpression }: Visitors): void;
1118
+ declare function isStaticProperty(node: Node$1): node is Property;
1119
+ declare function isStaticPropertyKey(node: Node$1, parent: Node$1): boolean;
1120
+ declare function isFunctionNode(node: Node$1): node is Function;
1121
+ declare function isInDestructuringAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
1122
+ declare function getArbitraryModuleIdentifier(node: Identifier | Literal): string;
1123
+
1124
+ declare function getMockerRuntime(): string;
1125
+
1126
+ export { type ArrayExpression, type ArrayPattern, type ArrowFunctionExpression, type AssignmentExpression, type AssignmentOperator, type AssignmentPattern, type AssignmentProperty, type AwaitExpression, type BaseCallExpression, type BaseClass, type BaseDeclaration, type BaseExpression, type BaseForXStatement, type BaseFunction, type BaseModuleDeclaration, type BaseModuleSpecifier, type BaseNode, type BaseNodeWithoutComments, type BasePattern, type BaseStatement, type BigIntLiteral, type BinaryExpression, type BinaryOperator, type BlockStatement, type BreakStatement, type CallExpression, type CatchClause, type ChainElement, type ChainExpression, type Class, type ClassBody, type ClassDeclaration, type ClassExpression, type Comment, type ConditionalExpression, type ContinueStatement, type DebuggerStatement, type Declaration, type Directive, type DoWhileStatement, type EmptyStatement, type ExportAllDeclaration, type ExportDefaultDeclaration, type ExportNamedDeclaration, type ExportSpecifier, type Expression, type ExpressionMap, type ExpressionStatement, type ForInStatement, type ForOfStatement, type ForStatement, type Function, type FunctionDeclaration, type FunctionExpression, type Identifier, type IfStatement, type ImportAttribute, type ImportDeclaration, type ImportDefaultSpecifier, type ImportExpression, type ImportNamespaceSpecifier, type ImportSpecifier, type LabeledStatement, type Literal, type LogicalExpression, type LogicalOperator, type MaybeNamedClassDeclaration, type MaybeNamedFunctionDeclaration, type MemberExpression, type MetaProperty, type MethodDefinition, type MockCall, type ModuleDeclaration, type ModuleSpecifier, type NewExpression, type Node, type NodeMap, type ObjectExpression, type ObjectPattern, type Pattern, type Position, type Positioned, type PrivateIdentifier, type Program, type Property, type PropertyDefinition, type RegExpLiteral, type RestElement, type ReturnStatement, type SequenceExpression, type SimpleCallExpression, type SimpleLiteral, type SourceLocation, type SpreadElement, type Statement, type StaticBlock, type Super, type SwitchCase, type SwitchStatement, type TaggedTemplateExpression, type TemplateElement, type TemplateLiteral, type ThisExpression, type ThrowStatement, type TryStatement, type UnaryExpression, type UnaryOperator, type UpdateExpression, type UpdateOperator, type VariableDeclaration, type VariableDeclarator, type WhileStatement, type WithStatement, type YieldExpression, __STORYBOOK_GLOBAL_THIS_ACCESSOR__, automockModule, babelParser, esmWalker, extractMockCalls, getArbitraryModuleIdentifier, getAutomockCode, getIsExternal, getMockerRuntime, getRealPath, isExternal, isFunctionNode, isInDestructuringAssignment, isModuleDirectory, isNodeInPattern, isStaticProperty, isStaticPropertyKey, resolveExternalModule, resolveMock, resolveWithExtensions, rewriteSbMockImportCalls, setIsNodeInPattern };