ripple 0.2.113 → 0.2.115

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.
@@ -8,7 +8,7 @@ import { sanitize_template_string } from './sanitize_template_string.js';
8
8
  * @returns {ESTree.ArrayExpression}
9
9
  */
10
10
  export function array(elements = []) {
11
- return { type: 'ArrayExpression', elements };
11
+ return { type: 'ArrayExpression', elements };
12
12
  }
13
13
 
14
14
  /**
@@ -16,7 +16,7 @@ export function array(elements = []) {
16
16
  * @returns {ESTree.ArrayPattern}
17
17
  */
18
18
  export function array_pattern(elements) {
19
- return { type: 'ArrayPattern', elements };
19
+ return { type: 'ArrayPattern', elements };
20
20
  }
21
21
 
22
22
  /**
@@ -25,7 +25,7 @@ export function array_pattern(elements) {
25
25
  * @returns {ESTree.AssignmentPattern}
26
26
  */
27
27
  export function assignment_pattern(left, right) {
28
- return { type: 'AssignmentPattern', left, right };
28
+ return { type: 'AssignmentPattern', left, right };
29
29
  }
30
30
 
31
31
  /**
@@ -34,24 +34,24 @@ export function assignment_pattern(left, right) {
34
34
  * @returns {ESTree.ArrowFunctionExpression}
35
35
  */
36
36
  export function arrow(params, body, async = false) {
37
- return {
38
- type: 'ArrowFunctionExpression',
39
- params,
40
- body,
41
- expression: body.type !== 'BlockStatement',
42
- generator: false,
43
- async,
44
- metadata: /** @type {any} */ (null), // should not be used by codegen
45
- };
37
+ return {
38
+ type: 'ArrowFunctionExpression',
39
+ params,
40
+ body,
41
+ expression: body.type !== 'BlockStatement',
42
+ generator: false,
43
+ async,
44
+ metadata: /** @type {any} */ (null), // should not be used by codegen
45
+ };
46
46
  }
47
47
 
48
48
  export function component(id, params, body) {
49
- return {
50
- type: 'Component',
51
- id,
52
- params,
53
- body,
54
- };
49
+ return {
50
+ type: 'Component',
51
+ id,
52
+ params,
53
+ body,
54
+ };
55
55
  }
56
56
 
57
57
  /**
@@ -61,7 +61,7 @@ export function component(id, params, body) {
61
61
  * @returns {ESTree.AssignmentExpression}
62
62
  */
63
63
  export function assignment(operator, left, right) {
64
- return { type: 'AssignmentExpression', operator, left, right };
64
+ return { type: 'AssignmentExpression', operator, left, right };
65
65
  }
66
66
 
67
67
  /**
@@ -70,7 +70,7 @@ export function assignment(operator, left, right) {
70
70
  * @returns {T & ESTree.BaseFunction}
71
71
  */
72
72
  export function async(func) {
73
- return { ...func, async: true };
73
+ return { ...func, async: true };
74
74
  }
75
75
 
76
76
  /**
@@ -78,7 +78,7 @@ export function async(func) {
78
78
  * @returns {ESTree.AwaitExpression}
79
79
  */
80
80
  function await_builder(argument) {
81
- return { type: 'AwaitExpression', argument };
81
+ return { type: 'AwaitExpression', argument };
82
82
  }
83
83
 
84
84
  /**
@@ -88,7 +88,7 @@ function await_builder(argument) {
88
88
  * @returns {ESTree.BinaryExpression}
89
89
  */
90
90
  export function binary(operator, left, right) {
91
- return { type: 'BinaryExpression', operator, left, right };
91
+ return { type: 'BinaryExpression', operator, left, right };
92
92
  }
93
93
 
94
94
  /**
@@ -96,7 +96,7 @@ export function binary(operator, left, right) {
96
96
  * @returns {ESTree.BlockStatement}
97
97
  */
98
98
  export function block(body) {
99
- return { type: 'BlockStatement', body };
99
+ return { type: 'BlockStatement', body };
100
100
  }
101
101
 
102
102
  /**
@@ -105,7 +105,7 @@ export function block(body) {
105
105
  * @returns {ESTree.LabeledStatement}
106
106
  */
107
107
  export function labeled(name, body) {
108
- return { type: 'LabeledStatement', label: id(name), body };
108
+ return { type: 'LabeledStatement', label: id(name), body };
109
109
  }
110
110
 
111
111
  /**
@@ -114,30 +114,30 @@ export function labeled(name, body) {
114
114
  * @returns {ESTree.CallExpression}
115
115
  */
116
116
  export function call(callee, ...args) {
117
- if (typeof callee === 'string') callee = id(callee);
118
- args = args.slice();
119
-
120
- // replacing missing arguments with `void(0)`, unless they're at the end in which case remove them
121
- let i = args.length;
122
- let popping = true;
123
- while (i--) {
124
- if (!args[i]) {
125
- if (popping) {
126
- args.pop();
127
- } else {
128
- args[i] = void0;
129
- }
130
- } else {
131
- popping = false;
132
- }
133
- }
134
-
135
- return {
136
- type: 'CallExpression',
137
- callee,
138
- arguments: /** @type {Array<ESTree.Expression | ESTree.SpreadElement>} */ (args),
139
- optional: false,
140
- };
117
+ if (typeof callee === 'string') callee = id(callee);
118
+ args = args.slice();
119
+
120
+ // replacing missing arguments with `void(0)`, unless they're at the end in which case remove them
121
+ let i = args.length;
122
+ let popping = true;
123
+ while (i--) {
124
+ if (!args[i]) {
125
+ if (popping) {
126
+ args.pop();
127
+ } else {
128
+ args[i] = void0;
129
+ }
130
+ } else {
131
+ popping = false;
132
+ }
133
+ }
134
+
135
+ return {
136
+ type: 'CallExpression',
137
+ callee,
138
+ arguments: /** @type {Array<ESTree.Expression | ESTree.SpreadElement>} */ (args),
139
+ optional: false,
140
+ };
141
141
  }
142
142
 
143
143
  /**
@@ -146,13 +146,13 @@ export function call(callee, ...args) {
146
146
  * @returns {ESTree.ChainExpression}
147
147
  */
148
148
  export function maybe_call(callee, ...args) {
149
- const expression = /** @type {ESTree.SimpleCallExpression} */ (call(callee, ...args));
150
- expression.optional = true;
149
+ const expression = /** @type {ESTree.SimpleCallExpression} */ (call(callee, ...args));
150
+ expression.optional = true;
151
151
 
152
- return {
153
- type: 'ChainExpression',
154
- expression,
155
- };
152
+ return {
153
+ type: 'ChainExpression',
154
+ expression,
155
+ };
156
156
  }
157
157
 
158
158
  /**
@@ -161,7 +161,7 @@ export function maybe_call(callee, ...args) {
161
161
  * @returns {ESTree.UnaryExpression}
162
162
  */
163
163
  export function unary(operator, argument) {
164
- return { type: 'UnaryExpression', argument, operator, prefix: true };
164
+ return { type: 'UnaryExpression', argument, operator, prefix: true };
165
165
  }
166
166
 
167
167
  /**
@@ -171,7 +171,7 @@ export function unary(operator, argument) {
171
171
  * @returns {ESTree.ConditionalExpression}
172
172
  */
173
173
  export function conditional(test, consequent, alternate) {
174
- return { type: 'ConditionalExpression', test, consequent, alternate };
174
+ return { type: 'ConditionalExpression', test, consequent, alternate };
175
175
  }
176
176
 
177
177
  /**
@@ -181,7 +181,7 @@ export function conditional(test, consequent, alternate) {
181
181
  * @returns {ESTree.LogicalExpression}
182
182
  */
183
183
  export function logical(operator, left, right) {
184
- return { type: 'LogicalExpression', operator, left, right };
184
+ return { type: 'LogicalExpression', operator, left, right };
185
185
  }
186
186
 
187
187
  /**
@@ -190,11 +190,11 @@ export function logical(operator, left, right) {
190
190
  * @returns {ESTree.VariableDeclaration}
191
191
  */
192
192
  export function declaration(kind, declarations) {
193
- return {
194
- type: 'VariableDeclaration',
195
- kind,
196
- declarations,
197
- };
193
+ return {
194
+ type: 'VariableDeclaration',
195
+ kind,
196
+ declarations,
197
+ };
198
198
  }
199
199
 
200
200
  /**
@@ -203,13 +203,13 @@ export function declaration(kind, declarations) {
203
203
  * @returns {ESTree.VariableDeclarator}
204
204
  */
205
205
  export function declarator(pattern, init) {
206
- if (typeof pattern === 'string') pattern = id(pattern);
207
- return { type: 'VariableDeclarator', id: pattern, init };
206
+ if (typeof pattern === 'string') pattern = id(pattern);
207
+ return { type: 'VariableDeclarator', id: pattern, init };
208
208
  }
209
209
 
210
210
  /** @type {ESTree.EmptyStatement} */
211
211
  export const empty = {
212
- type: 'EmptyStatement',
212
+ type: 'EmptyStatement',
213
213
  };
214
214
 
215
215
  /**
@@ -217,7 +217,7 @@ export const empty = {
217
217
  * @returns {ESTree.ExportDefaultDeclaration}
218
218
  */
219
219
  export function export_default(declaration) {
220
- return { type: 'ExportDefaultDeclaration', declaration };
220
+ return { type: 'ExportDefaultDeclaration', declaration };
221
221
  }
222
222
 
223
223
  /**
@@ -228,7 +228,7 @@ export function export_default(declaration) {
228
228
  * @returns {ESTree.ExportNamedDeclaration}
229
229
  */
230
230
  export function export_builder(declaration, specifiers = [], attributes = [], source = null) {
231
- return { type: 'ExportNamedDeclaration', declaration, specifiers, attributes, source };
231
+ return { type: 'ExportNamedDeclaration', declaration, specifiers, attributes, source };
232
232
  }
233
233
 
234
234
  /**
@@ -238,15 +238,15 @@ export function export_builder(declaration, specifiers = [], attributes = [], so
238
238
  * @returns {ESTree.FunctionDeclaration}
239
239
  */
240
240
  export function function_declaration(id, params, body) {
241
- return {
242
- type: 'FunctionDeclaration',
243
- id,
244
- params,
245
- body,
246
- generator: false,
247
- async: false,
248
- metadata: /** @type {any} */ (null), // should not be used by codegen
249
- };
241
+ return {
242
+ type: 'FunctionDeclaration',
243
+ id,
244
+ params,
245
+ body,
246
+ generator: false,
247
+ async: false,
248
+ metadata: /** @type {any} */ (null), // should not be used by codegen
249
+ };
250
250
  }
251
251
 
252
252
  /**
@@ -255,7 +255,7 @@ export function function_declaration(id, params, body) {
255
255
  * @returns {ESTree.Property & { value: ESTree.FunctionExpression}}}
256
256
  */
257
257
  export function get(name, body) {
258
- return prop('get', key(name), function_builder(null, [], block(body)));
258
+ return prop('get', key(name), function_builder(null, [], block(body)));
259
259
  }
260
260
 
261
261
  /**
@@ -263,7 +263,7 @@ export function get(name, body) {
263
263
  * @returns {ESTree.Identifier}
264
264
  */
265
265
  export function id(name) {
266
- return { type: 'Identifier', name };
266
+ return { type: 'Identifier', name };
267
267
  }
268
268
 
269
269
  /**
@@ -271,7 +271,7 @@ export function id(name) {
271
271
  * @returns {ESTree.PrivateIdentifier}
272
272
  */
273
273
  export function private_id(name) {
274
- return { type: 'PrivateIdentifier', name };
274
+ return { type: 'PrivateIdentifier', name };
275
275
  }
276
276
 
277
277
  /**
@@ -279,10 +279,10 @@ export function private_id(name) {
279
279
  * @returns {ESTree.ImportNamespaceSpecifier}
280
280
  */
281
281
  function import_namespace(local) {
282
- return {
283
- type: 'ImportNamespaceSpecifier',
284
- local: id(local),
285
- };
282
+ return {
283
+ type: 'ImportNamespaceSpecifier',
284
+ local: id(local),
285
+ };
286
286
  }
287
287
 
288
288
  /**
@@ -291,7 +291,7 @@ function import_namespace(local) {
291
291
  * @returns {ESTree.Property}
292
292
  */
293
293
  export function init(name, value) {
294
- return prop('init', key(name), value);
294
+ return prop('init', key(name), value);
295
295
  }
296
296
 
297
297
  /**
@@ -299,8 +299,8 @@ export function init(name, value) {
299
299
  * @returns {ESTree.Literal}
300
300
  */
301
301
  export function literal(value) {
302
- // @ts-expect-error we don't want to muck around with bigint here
303
- return { type: 'Literal', value };
302
+ // @ts-expect-error we don't want to muck around with bigint here
303
+ return { type: 'Literal', value };
304
304
  }
305
305
 
306
306
  /**
@@ -311,11 +311,11 @@ export function literal(value) {
311
311
  * @returns {ESTree.MemberExpression}
312
312
  */
313
313
  export function member(object, property, computed = false, optional = false) {
314
- if (typeof property === 'string') {
315
- property = id(property);
316
- }
314
+ if (typeof property === 'string') {
315
+ property = id(property);
316
+ }
317
317
 
318
- return { type: 'MemberExpression', object, property, computed, optional };
318
+ return { type: 'MemberExpression', object, property, computed, optional };
319
319
  }
320
320
 
321
321
  /**
@@ -323,15 +323,15 @@ export function member(object, property, computed = false, optional = false) {
323
323
  * @returns {ESTree.Identifier | ESTree.MemberExpression}
324
324
  */
325
325
  export function member_id(path) {
326
- const parts = path.split('.');
326
+ const parts = path.split('.');
327
327
 
328
- /** @type {ESTree.Identifier | ESTree.MemberExpression} */
329
- let expression = id(parts[0]);
328
+ /** @type {ESTree.Identifier | ESTree.MemberExpression} */
329
+ let expression = id(parts[0]);
330
330
 
331
- for (let i = 1; i < parts.length; i += 1) {
332
- expression = member(expression, id(parts[i]));
333
- }
334
- return expression;
331
+ for (let i = 1; i < parts.length; i += 1) {
332
+ expression = member(expression, id(parts[i]));
333
+ }
334
+ return expression;
335
335
  }
336
336
 
337
337
  /**
@@ -339,7 +339,7 @@ export function member_id(path) {
339
339
  * @returns {ESTree.ObjectExpression}
340
340
  */
341
341
  export function object(properties) {
342
- return { type: 'ObjectExpression', properties };
342
+ return { type: 'ObjectExpression', properties };
343
343
  }
344
344
 
345
345
  /**
@@ -347,8 +347,8 @@ export function object(properties) {
347
347
  * @returns {ESTree.ObjectPattern}
348
348
  */
349
349
  export function object_pattern(properties) {
350
- // @ts-expect-error the types appear to be wrong
351
- return { type: 'ObjectPattern', properties };
350
+ // @ts-expect-error the types appear to be wrong
351
+ return { type: 'ObjectPattern', properties };
352
352
  }
353
353
 
354
354
  /**
@@ -360,7 +360,7 @@ export function object_pattern(properties) {
360
360
  * @returns {ESTree.Property & { value: Value }}
361
361
  */
362
362
  export function prop(kind, key, value, computed = false) {
363
- return { type: 'Property', kind, key, value, method: false, shorthand: false, computed };
363
+ return { type: 'Property', kind, key, value, method: false, shorthand: false, computed };
364
364
  }
365
365
 
366
366
  /**
@@ -371,7 +371,7 @@ export function prop(kind, key, value, computed = false) {
371
371
  * @returns {ESTree.PropertyDefinition}
372
372
  */
373
373
  export function prop_def(key, value, computed = false, is_static = false) {
374
- return { type: 'PropertyDefinition', key, value, computed, static: is_static };
374
+ return { type: 'PropertyDefinition', key, value, computed, static: is_static };
375
375
  }
376
376
 
377
377
  /**
@@ -380,8 +380,8 @@ export function prop_def(key, value, computed = false, is_static = false) {
380
380
  * @returns {ESTree.TemplateElement}
381
381
  */
382
382
  export function quasi(cooked, tail = false) {
383
- const raw = sanitize_template_string(cooked);
384
- return { type: 'TemplateElement', value: { raw, cooked }, tail };
383
+ const raw = sanitize_template_string(cooked);
384
+ return { type: 'TemplateElement', value: { raw, cooked }, tail };
385
385
  }
386
386
 
387
387
  /**
@@ -389,7 +389,7 @@ export function quasi(cooked, tail = false) {
389
389
  * @returns {ESTree.RestElement}
390
390
  */
391
391
  export function rest(argument) {
392
- return { type: 'RestElement', argument };
392
+ return { type: 'RestElement', argument };
393
393
  }
394
394
 
395
395
  /**
@@ -397,7 +397,7 @@ export function rest(argument) {
397
397
  * @returns {ESTree.SequenceExpression}
398
398
  */
399
399
  export function sequence(expressions) {
400
- return { type: 'SequenceExpression', expressions };
400
+ return { type: 'SequenceExpression', expressions };
401
401
  }
402
402
 
403
403
  /**
@@ -406,7 +406,7 @@ export function sequence(expressions) {
406
406
  * @returns {ESTree.Property & { value: ESTree.FunctionExpression}}
407
407
  */
408
408
  export function set(name, body) {
409
- return prop('set', key(name), function_builder(null, [id('$$value')], block(body)));
409
+ return prop('set', key(name), function_builder(null, [id('$$value')], block(body)));
410
410
  }
411
411
 
412
412
  /**
@@ -414,7 +414,7 @@ export function set(name, body) {
414
414
  * @returns {ESTree.SpreadElement}
415
415
  */
416
416
  export function spread(argument) {
417
- return { type: 'SpreadElement', argument };
417
+ return { type: 'SpreadElement', argument };
418
418
  }
419
419
 
420
420
  /**
@@ -422,7 +422,7 @@ export function spread(argument) {
422
422
  * @returns {ESTree.ExpressionStatement}
423
423
  */
424
424
  export function stmt(expression) {
425
- return { type: 'ExpressionStatement', expression };
425
+ return { type: 'ExpressionStatement', expression };
426
426
  }
427
427
 
428
428
  /**
@@ -431,7 +431,7 @@ export function stmt(expression) {
431
431
  * @returns {ESTree.TemplateLiteral}
432
432
  */
433
433
  export function template(elements, expressions) {
434
- return { type: 'TemplateLiteral', quasis: elements, expressions };
434
+ return { type: 'TemplateLiteral', quasis: elements, expressions };
435
435
  }
436
436
 
437
437
  /**
@@ -440,9 +440,9 @@ export function template(elements, expressions) {
440
440
  * @returns {ESTree.Expression}
441
441
  */
442
442
  export function thunk(expression, async = false) {
443
- const fn = arrow([], expression);
444
- if (async) fn.async = true;
445
- return unthunk(fn);
443
+ const fn = arrow([], expression);
444
+ if (async) fn.async = true;
445
+ return unthunk(fn);
446
446
  }
447
447
 
448
448
  /**
@@ -451,20 +451,20 @@ export function thunk(expression, async = false) {
451
451
  * @returns {ESTree.Expression}
452
452
  */
453
453
  export function unthunk(expression) {
454
- if (
455
- expression.type === 'ArrowFunctionExpression' &&
456
- expression.async === false &&
457
- expression.body.type === 'CallExpression' &&
458
- expression.body.callee.type === 'Identifier' &&
459
- expression.params.length === expression.body.arguments.length &&
460
- expression.params.every((param, index) => {
461
- const arg = /** @type {ESTree.SimpleCallExpression} */ (expression.body).arguments[index];
462
- return param.type === 'Identifier' && arg.type === 'Identifier' && param.name === arg.name;
463
- })
464
- ) {
465
- return expression.body.callee;
466
- }
467
- return expression;
454
+ if (
455
+ expression.type === 'ArrowFunctionExpression' &&
456
+ expression.async === false &&
457
+ expression.body.type === 'CallExpression' &&
458
+ expression.body.callee.type === 'Identifier' &&
459
+ expression.params.length === expression.body.arguments.length &&
460
+ expression.params.every((param, index) => {
461
+ const arg = /** @type {ESTree.SimpleCallExpression} */ (expression.body).arguments[index];
462
+ return param.type === 'Identifier' && arg.type === 'Identifier' && param.name === arg.name;
463
+ })
464
+ ) {
465
+ return expression.body.callee;
466
+ }
467
+ return expression;
468
468
  }
469
469
 
470
470
  /**
@@ -474,13 +474,13 @@ export function unthunk(expression) {
474
474
  * @returns {ESTree.NewExpression}
475
475
  */
476
476
  function new_builder(expression, ...args) {
477
- if (typeof expression === 'string') expression = id(expression);
477
+ if (typeof expression === 'string') expression = id(expression);
478
478
 
479
- return {
480
- callee: expression,
481
- arguments: args,
482
- type: 'NewExpression',
483
- };
479
+ return {
480
+ callee: expression,
481
+ arguments: args,
482
+ type: 'NewExpression',
483
+ };
484
484
  }
485
485
 
486
486
  /**
@@ -490,7 +490,7 @@ function new_builder(expression, ...args) {
490
490
  * @returns {ESTree.UpdateExpression}
491
491
  */
492
492
  export function update(operator, argument, prefix = false) {
493
- return { type: 'UpdateExpression', operator, argument, prefix };
493
+ return { type: 'UpdateExpression', operator, argument, prefix };
494
494
  }
495
495
 
496
496
  /**
@@ -499,7 +499,7 @@ export function update(operator, argument, prefix = false) {
499
499
  * @returns {ESTree.DoWhileStatement}
500
500
  */
501
501
  export function do_while(test, body) {
502
- return { type: 'DoWhileStatement', test, body };
502
+ return { type: 'DoWhileStatement', test, body };
503
503
  }
504
504
 
505
505
  const true_instance = literal(true);
@@ -508,12 +508,12 @@ const null_instane = literal(null);
508
508
 
509
509
  /** @type {ESTree.DebuggerStatement} */
510
510
  const debugger_builder = {
511
- type: 'DebuggerStatement',
511
+ type: 'DebuggerStatement',
512
512
  };
513
513
 
514
514
  /** @type {ESTree.ThisExpression} */
515
515
  const this_instance = {
516
- type: 'ThisExpression',
516
+ type: 'ThisExpression',
517
517
  };
518
518
 
519
519
  /**
@@ -522,7 +522,7 @@ const this_instance = {
522
522
  * @returns {ESTree.VariableDeclaration}
523
523
  */
524
524
  function let_builder(pattern, init) {
525
- return declaration('let', [declarator(pattern, init)]);
525
+ return declaration('let', [declarator(pattern, init)]);
526
526
  }
527
527
 
528
528
  /**
@@ -531,7 +531,7 @@ function let_builder(pattern, init) {
531
531
  * @returns {ESTree.VariableDeclaration}
532
532
  */
533
533
  function const_builder(pattern, init) {
534
- return declaration('const', [declarator(pattern, init)]);
534
+ return declaration('const', [declarator(pattern, init)]);
535
535
  }
536
536
 
537
537
  /**
@@ -540,7 +540,7 @@ function const_builder(pattern, init) {
540
540
  * @returns {ESTree.VariableDeclaration}
541
541
  */
542
542
  function var_builder(pattern, init) {
543
- return declaration('var', [declarator(pattern, init)]);
543
+ return declaration('var', [declarator(pattern, init)]);
544
544
  }
545
545
 
546
546
  /**
@@ -552,7 +552,7 @@ function var_builder(pattern, init) {
552
552
  * @returns {ESTree.ForStatement}
553
553
  */
554
554
  function for_builder(init, test, update, body) {
555
- return { type: 'ForStatement', init, test, update, body };
555
+ return { type: 'ForStatement', init, test, update, body };
556
556
  }
557
557
 
558
558
  /**
@@ -563,7 +563,7 @@ function for_builder(init, test, update, body) {
563
563
  * @returns {ESTree.ForOfStatement}
564
564
  */
565
565
  export function for_of(left, right, body, await_flag = false) {
566
- return { type: 'ForOfStatement', left, right, body, await: await_flag };
566
+ return { type: 'ForOfStatement', left, right, body, await: await_flag };
567
567
  }
568
568
 
569
569
  /**
@@ -577,14 +577,14 @@ export function for_of(left, right, body, await_flag = false) {
577
577
  * @returns {ESTree.MethodDefinition}
578
578
  */
579
579
  export function method(kind, key, params, body, computed = false, is_static = false) {
580
- return {
581
- type: 'MethodDefinition',
582
- key,
583
- kind,
584
- value: function_builder(null, params, block(body)),
585
- computed,
586
- static: is_static,
587
- };
580
+ return {
581
+ type: 'MethodDefinition',
582
+ key,
583
+ kind,
584
+ value: function_builder(null, params, block(body)),
585
+ computed,
586
+ static: is_static,
587
+ };
588
588
  }
589
589
 
590
590
  /**
@@ -596,15 +596,15 @@ export function method(kind, key, params, body, computed = false, is_static = fa
596
596
  * @returns {ESTree.FunctionExpression}
597
597
  */
598
598
  function function_builder(id, params, body, async = false) {
599
- return {
600
- type: 'FunctionExpression',
601
- id,
602
- params,
603
- body,
604
- generator: false,
605
- async,
606
- metadata: /** @type {any} */ (null), // should not be used by codegen
607
- };
599
+ return {
600
+ type: 'FunctionExpression',
601
+ id,
602
+ params,
603
+ body,
604
+ generator: false,
605
+ async,
606
+ metadata: /** @type {any} */ (null), // should not be used by codegen
607
+ };
608
608
  }
609
609
 
610
610
  /**
@@ -614,7 +614,7 @@ function function_builder(id, params, body, async = false) {
614
614
  * @returns {ESTree.IfStatement}
615
615
  */
616
616
  function if_builder(test, consequent, alternate) {
617
- return { type: 'IfStatement', test, consequent, alternate };
617
+ return { type: 'IfStatement', test, consequent, alternate };
618
618
  }
619
619
 
620
620
  /**
@@ -623,11 +623,11 @@ function if_builder(test, consequent, alternate) {
623
623
  * @returns {ESTree.ImportDeclaration}
624
624
  */
625
625
  export function import_all(as, source) {
626
- return {
627
- type: 'ImportDeclaration',
628
- source: literal(source),
629
- specifiers: [import_namespace(as)],
630
- };
626
+ return {
627
+ type: 'ImportDeclaration',
628
+ source: literal(source),
629
+ specifiers: [import_namespace(as)],
630
+ };
631
631
  }
632
632
 
633
633
  /**
@@ -636,15 +636,15 @@ export function import_all(as, source) {
636
636
  * @returns {ESTree.ImportDeclaration}
637
637
  */
638
638
  export function imports(parts, source) {
639
- return {
640
- type: 'ImportDeclaration',
641
- source: literal(source),
642
- specifiers: parts.map((p) => ({
643
- type: 'ImportSpecifier',
644
- imported: id(p[0]),
645
- local: id(p[1]),
646
- })),
647
- };
639
+ return {
640
+ type: 'ImportDeclaration',
641
+ source: literal(source),
642
+ specifiers: parts.map((p) => ({
643
+ type: 'ImportSpecifier',
644
+ imported: id(p[0]),
645
+ local: id(p[1]),
646
+ })),
647
+ };
648
648
  }
649
649
 
650
650
  /**
@@ -652,7 +652,7 @@ export function imports(parts, source) {
652
652
  * @returns {ESTree.ReturnStatement}
653
653
  */
654
654
  function return_builder(argument = null) {
655
- return { type: 'ReturnStatement', argument };
655
+ return { type: 'ReturnStatement', argument };
656
656
  }
657
657
 
658
658
  /**
@@ -660,10 +660,10 @@ function return_builder(argument = null) {
660
660
  * @returns {ESTree.ThrowStatement}
661
661
  */
662
662
  export function throw_error(str) {
663
- return {
664
- type: 'ThrowStatement',
665
- argument: new_builder('Error', literal(str)),
666
- };
663
+ return {
664
+ type: 'ThrowStatement',
665
+ argument: new_builder('Error', literal(str)),
666
+ };
667
667
  }
668
668
 
669
669
  /**
@@ -673,12 +673,12 @@ export function throw_error(str) {
673
673
  * @returns {ESTree.TryStatement}
674
674
  */
675
675
  export function try_builder(block, handler = null, finalizer = null) {
676
- return {
677
- type: 'TryStatement',
678
- block,
679
- handler,
680
- finalizer,
681
- };
676
+ return {
677
+ type: 'TryStatement',
678
+ block,
679
+ handler,
680
+ finalizer,
681
+ };
682
682
  }
683
683
 
684
684
  /**
@@ -687,11 +687,11 @@ export function try_builder(block, handler = null, finalizer = null) {
687
687
  * @returns {ESTree.CatchClause}
688
688
  */
689
689
  export function catch_clause_builder(param, body) {
690
- return {
691
- type: 'CatchClause',
692
- param,
693
- body,
694
- };
690
+ return {
691
+ type: 'CatchClause',
692
+ param,
693
+ body,
694
+ };
695
695
  }
696
696
 
697
697
  export { catch_clause_builder as catch_clause };
@@ -701,7 +701,7 @@ export { catch_clause_builder as catch_clause };
701
701
  * @returns {ESTree.Expression}
702
702
  */
703
703
  export function key(name) {
704
- return regex_is_valid_identifier.test(name) ? id(name) : literal(name);
704
+ return regex_is_valid_identifier.test(name) ? id(name) : literal(name);
705
705
  }
706
706
 
707
707
  /**
@@ -710,11 +710,11 @@ export function key(name) {
710
710
  * @returns {ESTree.JSXAttribute}
711
711
  */
712
712
  export function jsx_attribute(name, value = null) {
713
- return {
714
- type: 'JSXAttribute',
715
- name,
716
- value,
717
- };
713
+ return {
714
+ type: 'JSXAttribute',
715
+ name,
716
+ value,
717
+ };
718
718
  }
719
719
 
720
720
  /**
@@ -725,32 +725,32 @@ export function jsx_attribute(name, value = null) {
725
725
  * @returns {{ element: ESTree.JSXElement, opening_element: ESTree.JSXOpeningElement }}
726
726
  */
727
727
  export function jsx_element(
728
- name,
729
- attributes = [],
730
- children = [],
731
- self_closing = false,
732
- closing_name = name,
728
+ name,
729
+ attributes = [],
730
+ children = [],
731
+ self_closing = false,
732
+ closing_name = name,
733
733
  ) {
734
- const opening_element = {
735
- type: 'JSXOpeningElement',
736
- name,
737
- attributes,
738
- selfClosing: self_closing,
739
- };
734
+ const opening_element = {
735
+ type: 'JSXOpeningElement',
736
+ name,
737
+ attributes,
738
+ selfClosing: self_closing,
739
+ };
740
740
 
741
- const element = {
742
- type: 'JSXElement',
743
- openingElement: opening_element,
744
- closingElement: self_closing
745
- ? null
746
- : {
747
- type: 'JSXClosingElement',
748
- name: closing_name,
749
- },
750
- children,
751
- };
741
+ const element = {
742
+ type: 'JSXElement',
743
+ openingElement: opening_element,
744
+ closingElement: self_closing
745
+ ? null
746
+ : {
747
+ type: 'JSXClosingElement',
748
+ name: closing_name,
749
+ },
750
+ children,
751
+ };
752
752
 
753
- return element;
753
+ return element;
754
754
  }
755
755
 
756
756
  /**
@@ -758,10 +758,10 @@ export function jsx_element(
758
758
  * @returns {ESTree.JSXExpressionContainer}
759
759
  */
760
760
  export function jsx_expression_container(expression) {
761
- return {
762
- type: 'JSXExpressionContainer',
763
- expression,
764
- };
761
+ return {
762
+ type: 'JSXExpressionContainer',
763
+ expression,
764
+ };
765
765
  }
766
766
 
767
767
  /**
@@ -769,10 +769,23 @@ export function jsx_expression_container(expression) {
769
769
  * @returns {ESTree.JSXIdentifier}
770
770
  */
771
771
  export function jsx_id(name) {
772
- return {
773
- type: 'JSXIdentifier',
774
- name,
775
- };
772
+ return {
773
+ type: 'JSXIdentifier',
774
+ name,
775
+ };
776
+ }
777
+
778
+ /**
779
+ * @param {ESTree.JSXIdentifier | ESTree.JSXMemberExpression} object
780
+ * @param {ESTree.JSXIdentifier} property
781
+ * @returns {ESTree.JSXMemberExpression}
782
+ */
783
+ export function jsx_member(object, property) {
784
+ return {
785
+ type: 'JSXMemberExpression',
786
+ object,
787
+ property,
788
+ };
776
789
  }
777
790
 
778
791
  /**
@@ -780,33 +793,32 @@ export function jsx_id(name) {
780
793
  * @returns {ESTree.JSXSpreadAttribute}
781
794
  */
782
795
  export function jsx_spread_attribute(argument) {
783
- return {
784
- type: 'JSXSpreadAttribute',
785
- argument,
786
- };
796
+ return {
797
+ type: 'JSXSpreadAttribute',
798
+ argument,
799
+ };
787
800
  }
788
801
 
789
-
790
802
  /**
791
803
  * @returns {ESTree.SwitchStatement}
792
804
  */
793
805
  export function switch_builder(discriminant, cases) {
794
- return {
795
- type: 'SwitchStatement',
796
- discriminant,
797
- cases,
798
- };
806
+ return {
807
+ type: 'SwitchStatement',
808
+ discriminant,
809
+ cases,
810
+ };
799
811
  }
800
812
 
801
813
  /**
802
814
  * @returns {ESTree.SwitchCase}
803
815
  */
804
816
  export function switch_case(test = null, consequent = []) {
805
- return {
806
- type: 'SwitchCase',
807
- test,
808
- consequent,
809
- };
817
+ return {
818
+ type: 'SwitchCase',
819
+ test,
820
+ consequent,
821
+ };
810
822
  }
811
823
 
812
824
  export const void0 = unary('void', literal(0));
@@ -815,27 +827,27 @@ export const void0 = unary('void', literal(0));
815
827
  * @returns {ESTree.BreakStatement}
816
828
  */
817
829
  export const break_statement = {
818
- type: 'BreakStatement',
819
- label: null,
830
+ type: 'BreakStatement',
831
+ label: null,
820
832
  };
821
833
 
822
834
  export {
823
- await_builder as await,
824
- let_builder as let,
825
- const_builder as const,
826
- var_builder as var,
827
- export_builder as export,
828
- true_instance as true,
829
- false_instance as false,
830
- break_statement as break,
831
- for_builder as for,
832
- switch_builder as switch,
833
- function_builder as function,
834
- return_builder as return,
835
- if_builder as if,
836
- this_instance as this,
837
- null_instane as null,
838
- debugger_builder as debugger,
839
- try_builder as try,
840
- new_builder as new,
835
+ await_builder as await,
836
+ let_builder as let,
837
+ const_builder as const,
838
+ var_builder as var,
839
+ export_builder as export,
840
+ true_instance as true,
841
+ false_instance as false,
842
+ break_statement as break,
843
+ for_builder as for,
844
+ switch_builder as switch,
845
+ function_builder as function,
846
+ return_builder as return,
847
+ if_builder as if,
848
+ this_instance as this,
849
+ null_instane as null,
850
+ debugger_builder as debugger,
851
+ try_builder as try,
852
+ new_builder as new,
841
853
  };