babel-plugin-jsx-dom-expressions 0.38.1 → 0.38.5

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 (3) hide show
  1. package/index.js +1890 -1888
  2. package/package.json +5 -3
  3. package/tsconfig.json +15 -0
package/index.js CHANGED
@@ -25,60 +25,60 @@ function _interopNamespaceDefault(e) {
25
25
  var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
26
26
 
27
27
  const booleans = [
28
- "allowfullscreen",
29
- "async",
30
- "autofocus",
31
- "autoplay",
32
- "checked",
33
- "controls",
34
- "default",
35
- "disabled",
36
- "formnovalidate",
37
- "hidden",
38
- "indeterminate",
39
- "inert",
40
- "ismap",
41
- "loop",
42
- "multiple",
43
- "muted",
44
- "nomodule",
45
- "novalidate",
46
- "open",
47
- "playsinline",
48
- "readonly",
49
- "required",
50
- "reversed",
51
- "seamless",
52
- "selected"
53
- ];
54
-
55
- const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
56
-
57
- const Properties = /*#__PURE__*/ new Set([
58
- "className",
59
- "value",
60
- "readOnly",
61
- "formNoValidate",
62
- "isMap",
63
- "noModule",
64
- "playsInline",
65
- ...booleans
66
- ]);
67
-
68
- const ChildProperties = /*#__PURE__*/ new Set([
69
- "innerHTML",
70
- "textContent",
71
- "innerText",
72
- "children"
73
- ]);
28
+ "allowfullscreen",
29
+ "async",
30
+ "autofocus",
31
+ "autoplay",
32
+ "checked",
33
+ "controls",
34
+ "default",
35
+ "disabled",
36
+ "formnovalidate",
37
+ "hidden",
38
+ "indeterminate",
39
+ "inert",
40
+ "ismap",
41
+ "loop",
42
+ "multiple",
43
+ "muted",
44
+ "nomodule",
45
+ "novalidate",
46
+ "open",
47
+ "playsinline",
48
+ "readonly",
49
+ "required",
50
+ "reversed",
51
+ "seamless",
52
+ "selected"];
53
+
54
+
55
+ const BooleanAttributes = /*#__PURE__*/new Set(booleans);
56
+
57
+ const Properties = /*#__PURE__*/new Set([
58
+ "className",
59
+ "value",
60
+ "readOnly",
61
+ "formNoValidate",
62
+ "isMap",
63
+ "noModule",
64
+ "playsInline",
65
+ ...booleans]);
66
+
67
+
68
+ const ChildProperties = /*#__PURE__*/new Set([
69
+ "innerHTML",
70
+ "textContent",
71
+ "innerText",
72
+ "children"]);
73
+
74
74
 
75
75
  // React Compat
76
- const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
76
+ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
77
77
  className: "class",
78
78
  htmlFor: "for"
79
79
  });
80
80
 
81
- const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
81
+ const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
82
82
  class: "className",
83
83
  formnovalidate: {
84
84
  $: "formNoValidate",
@@ -106,118 +106,118 @@ const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
106
106
 
107
107
  function getPropAlias(prop, tagName) {
108
108
  const a = PropAliases[prop];
109
- return typeof a === "object" ? (a[tagName] ? a["$"] : undefined) : a;
109
+ return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
110
110
  }
111
111
 
112
112
  // list of Element events that will be delegated
113
- const DelegatedEvents = /*#__PURE__*/ new Set([
114
- "beforeinput",
115
- "click",
116
- "dblclick",
117
- "contextmenu",
118
- "focusin",
119
- "focusout",
120
- "input",
121
- "keydown",
122
- "keyup",
123
- "mousedown",
124
- "mousemove",
125
- "mouseout",
126
- "mouseover",
127
- "mouseup",
128
- "pointerdown",
129
- "pointermove",
130
- "pointerout",
131
- "pointerover",
132
- "pointerup",
133
- "touchend",
134
- "touchmove",
135
- "touchstart"
136
- ]);
137
-
138
- const SVGElements = /*#__PURE__*/ new Set([
139
- // "a",
140
- "altGlyph",
141
- "altGlyphDef",
142
- "altGlyphItem",
143
- "animate",
144
- "animateColor",
145
- "animateMotion",
146
- "animateTransform",
147
- "circle",
148
- "clipPath",
149
- "color-profile",
150
- "cursor",
151
- "defs",
152
- "desc",
153
- "ellipse",
154
- "feBlend",
155
- "feColorMatrix",
156
- "feComponentTransfer",
157
- "feComposite",
158
- "feConvolveMatrix",
159
- "feDiffuseLighting",
160
- "feDisplacementMap",
161
- "feDistantLight",
162
- "feDropShadow",
163
- "feFlood",
164
- "feFuncA",
165
- "feFuncB",
166
- "feFuncG",
167
- "feFuncR",
168
- "feGaussianBlur",
169
- "feImage",
170
- "feMerge",
171
- "feMergeNode",
172
- "feMorphology",
173
- "feOffset",
174
- "fePointLight",
175
- "feSpecularLighting",
176
- "feSpotLight",
177
- "feTile",
178
- "feTurbulence",
179
- "filter",
180
- "font",
181
- "font-face",
182
- "font-face-format",
183
- "font-face-name",
184
- "font-face-src",
185
- "font-face-uri",
186
- "foreignObject",
187
- "g",
188
- "glyph",
189
- "glyphRef",
190
- "hkern",
191
- "image",
192
- "line",
193
- "linearGradient",
194
- "marker",
195
- "mask",
196
- "metadata",
197
- "missing-glyph",
198
- "mpath",
199
- "path",
200
- "pattern",
201
- "polygon",
202
- "polyline",
203
- "radialGradient",
204
- "rect",
205
- // "script",
206
- "set",
207
- "stop",
208
- // "style",
209
- "svg",
210
- "switch",
211
- "symbol",
212
- "text",
213
- "textPath",
214
- // "title",
215
- "tref",
216
- "tspan",
217
- "use",
218
- "view",
219
- "vkern"
220
- ]);
113
+ const DelegatedEvents = /*#__PURE__*/new Set([
114
+ "beforeinput",
115
+ "click",
116
+ "dblclick",
117
+ "contextmenu",
118
+ "focusin",
119
+ "focusout",
120
+ "input",
121
+ "keydown",
122
+ "keyup",
123
+ "mousedown",
124
+ "mousemove",
125
+ "mouseout",
126
+ "mouseover",
127
+ "mouseup",
128
+ "pointerdown",
129
+ "pointermove",
130
+ "pointerout",
131
+ "pointerover",
132
+ "pointerup",
133
+ "touchend",
134
+ "touchmove",
135
+ "touchstart"]);
136
+
137
+
138
+ const SVGElements = /*#__PURE__*/new Set([
139
+ // "a",
140
+ "altGlyph",
141
+ "altGlyphDef",
142
+ "altGlyphItem",
143
+ "animate",
144
+ "animateColor",
145
+ "animateMotion",
146
+ "animateTransform",
147
+ "circle",
148
+ "clipPath",
149
+ "color-profile",
150
+ "cursor",
151
+ "defs",
152
+ "desc",
153
+ "ellipse",
154
+ "feBlend",
155
+ "feColorMatrix",
156
+ "feComponentTransfer",
157
+ "feComposite",
158
+ "feConvolveMatrix",
159
+ "feDiffuseLighting",
160
+ "feDisplacementMap",
161
+ "feDistantLight",
162
+ "feDropShadow",
163
+ "feFlood",
164
+ "feFuncA",
165
+ "feFuncB",
166
+ "feFuncG",
167
+ "feFuncR",
168
+ "feGaussianBlur",
169
+ "feImage",
170
+ "feMerge",
171
+ "feMergeNode",
172
+ "feMorphology",
173
+ "feOffset",
174
+ "fePointLight",
175
+ "feSpecularLighting",
176
+ "feSpotLight",
177
+ "feTile",
178
+ "feTurbulence",
179
+ "filter",
180
+ "font",
181
+ "font-face",
182
+ "font-face-format",
183
+ "font-face-name",
184
+ "font-face-src",
185
+ "font-face-uri",
186
+ "foreignObject",
187
+ "g",
188
+ "glyph",
189
+ "glyphRef",
190
+ "hkern",
191
+ "image",
192
+ "line",
193
+ "linearGradient",
194
+ "marker",
195
+ "mask",
196
+ "metadata",
197
+ "missing-glyph",
198
+ "mpath",
199
+ "path",
200
+ "pattern",
201
+ "polygon",
202
+ "polyline",
203
+ "radialGradient",
204
+ "rect",
205
+ // "script",
206
+ "set",
207
+ "stop",
208
+ // "style",
209
+ "svg",
210
+ "switch",
211
+ "symbol",
212
+ "text",
213
+ "textPath",
214
+ // "title",
215
+ "tref",
216
+ "tspan",
217
+ "use",
218
+ "view",
219
+ "vkern"]);
220
+
221
221
 
222
222
  const SVGNamespace = {
223
223
  xlink: "http://www.w3.org/1999/xlink",
@@ -225,33 +225,32 @@ const SVGNamespace = {
225
225
  };
226
226
 
227
227
  var VoidElements = [
228
- 'area',
229
- 'base',
230
- 'br',
231
- 'col',
232
- 'embed',
233
- 'hr',
234
- 'img',
235
- 'input',
236
- 'keygen',
237
- 'link',
238
- 'menuitem',
239
- 'meta',
240
- 'param',
241
- 'source',
242
- 'track',
243
- 'wbr'
244
- ];
228
+ 'area',
229
+ 'base',
230
+ 'br',
231
+ 'col',
232
+ 'embed',
233
+ 'hr',
234
+ 'img',
235
+ 'input',
236
+ 'keygen',
237
+ 'link',
238
+ 'menuitem',
239
+ 'meta',
240
+ 'param',
241
+ 'source',
242
+ 'track',
243
+ 'wbr'];
245
244
 
246
245
  const reservedNameSpaces = new Set([
247
- "class",
248
- "on",
249
- "oncapture",
250
- "style",
251
- "use",
252
- "prop",
253
- "attr"
254
- ]);
246
+ "class",
247
+ "on",
248
+ "oncapture",
249
+ "style",
250
+ "use",
251
+ "prop",
252
+ "attr"]);
253
+
255
254
 
256
255
  const nonSpreadNameSpaces = new Set(["class", "style", "use", "prop", "attr"]);
257
256
 
@@ -261,13 +260,13 @@ function getConfig(path) {
261
260
 
262
261
  const getRendererConfig = (path, renderer) => {
263
262
  const config = getConfig(path);
264
- return config?.renderers?.find(r => r.name === renderer) ?? config;
263
+ return config?.renderers?.find((r) => r.name === renderer) ?? config;
265
264
  };
266
265
 
267
266
  function registerImportMethod(path, name, moduleName) {
268
267
  const imports =
269
- path.scope.getProgramParent().data.imports ||
270
- (path.scope.getProgramParent().data.imports = new Map());
268
+ path.scope.getProgramParent().data.imports || (
269
+ path.scope.getProgramParent().data.imports = new Map());
271
270
  moduleName = moduleName || getConfig(path).moduleName;
272
271
  if (!imports.has(`${moduleName}:${name}`)) {
273
272
  let id = helperModuleImports.addNamed(path, name, moduleName, {
@@ -301,10 +300,10 @@ function getTagName(tag) {
301
300
 
302
301
  function isComponent(tagName) {
303
302
  return (
304
- (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) ||
303
+ tagName[0] && tagName[0].toLowerCase() !== tagName[0] ||
305
304
  tagName.includes(".") ||
306
- /[^a-zA-Z]/.test(tagName[0])
307
- );
305
+ /[^a-zA-Z]/.test(tagName[0]));
306
+
308
307
  }
309
308
 
310
309
  function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true, native }) {
@@ -316,18 +315,18 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
316
315
  const expr = path.node;
317
316
  if (t__namespace.isFunction(expr)) return false;
318
317
  if (
319
- expr.leadingComments &&
320
- expr.leadingComments[0] &&
321
- expr.leadingComments[0].value.trim() === config.staticMarker
322
- ) {
318
+ expr.leadingComments &&
319
+ expr.leadingComments[0] &&
320
+ expr.leadingComments[0].value.trim() === config.staticMarker)
321
+ {
323
322
  expr.leadingComments.shift();
324
323
  return false;
325
324
  }
326
325
 
327
326
  if (
328
- checkCallExpressions &&
329
- (t__namespace.isCallExpression(expr) || t__namespace.isOptionalCallExpression(expr))
330
- ) {
327
+ checkCallExpressions && (
328
+ t__namespace.isCallExpression(expr) || t__namespace.isOptionalCallExpression(expr)))
329
+ {
331
330
  return true;
332
331
  }
333
332
 
@@ -336,15 +335,15 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
336
335
  const object = path.get("object").node;
337
336
 
338
337
  if (
339
- t__namespace.isIdentifier(object) &&
340
- (!expr.computed ||
341
- !isDynamic(path.get("property"), {
342
- checkMember,
343
- checkTags,
344
- checkCallExpressions,
345
- native,
346
- }))
347
- ) {
338
+ t__namespace.isIdentifier(object) && (
339
+ !expr.computed ||
340
+ !isDynamic(path.get("property"), {
341
+ checkMember,
342
+ checkTags,
343
+ checkCallExpressions,
344
+ native
345
+ })))
346
+ {
348
347
  const binding = path.scope.getBinding(object.name);
349
348
 
350
349
  if (binding && binding.path.isImportNamespaceSpecifier()) {
@@ -356,15 +355,15 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
356
355
  }
357
356
 
358
357
  if (
359
- checkMember &&
360
- (t__namespace.isOptionalMemberExpression(expr) ||
361
- t__namespace.isSpreadElement(expr) ||
362
- (t__namespace.isBinaryExpression(expr) && expr.operator === "in"))
363
- ) {
358
+ checkMember && (
359
+ t__namespace.isOptionalMemberExpression(expr) ||
360
+ t__namespace.isSpreadElement(expr) ||
361
+ t__namespace.isBinaryExpression(expr) && expr.operator === "in"))
362
+ {
364
363
  return true;
365
364
  }
366
365
 
367
- if (checkTags && (t__namespace.isJSXElement(expr) || (t__namespace.isJSXFragment(expr) && expr.children.length))) {
366
+ if (checkTags && (t__namespace.isJSXElement(expr) || t__namespace.isJSXFragment(expr) && expr.children.length)) {
368
367
  return true;
369
368
  }
370
369
 
@@ -412,28 +411,28 @@ function getStaticExpression(path) {
412
411
  t__namespace.isJSXElement(path.parent) &&
413
412
  !isComponent(getTagName(path.parent)) &&
414
413
  !t__namespace.isSequenceExpression(node.expression) &&
415
- (value = path.get("expression").evaluate().value) !== undefined &&
416
- ((type = typeof value) === "string" || type === "number") &&
417
- value
418
- );
414
+ (value = path.get("expression").evaluate().value) !== undefined && (
415
+ (type = typeof value) === "string" || type === "number") &&
416
+ value);
417
+
419
418
  }
420
419
 
421
420
  // remove unnecessary JSX Text nodes
422
421
  function filterChildren(children) {
423
422
  return children.filter(
424
- ({ node: child }) =>
425
- !(t__namespace.isJSXExpressionContainer(child) && t__namespace.isJSXEmptyExpression(child.expression)) &&
426
- (!t__namespace.isJSXText(child) || !/^[\r\n]\s*$/.test(child.extra.raw))
427
- );
423
+ ({ node: child }) =>
424
+ !(t__namespace.isJSXExpressionContainer(child) && t__namespace.isJSXEmptyExpression(child.expression)) && (
425
+ !t__namespace.isJSXText(child) || !/^[\r\n]\s*$/.test(child.extra.raw)));
426
+
428
427
  }
429
428
 
430
429
  function checkLength(children) {
431
430
  let i = 0;
432
- children.forEach(path => {
431
+ children.forEach((path) => {
433
432
  const child = path.node;
434
- !(t__namespace.isJSXExpressionContainer(child) && t__namespace.isJSXEmptyExpression(child.expression)) &&
435
- (!t__namespace.isJSXText(child) || !/^\s*$/.test(child.extra.raw) || /^ *$/.test(child.extra.raw)) &&
436
- i++;
433
+ !(t__namespace.isJSXExpressionContainer(child) && t__namespace.isJSXEmptyExpression(child.expression)) && (
434
+ !t__namespace.isJSXText(child) || !/^\s*$/.test(child.extra.raw) || /^ *$/.test(child.extra.raw)) &&
435
+ i++;
437
436
  });
438
437
  return i > 1;
439
438
  }
@@ -441,11 +440,11 @@ function checkLength(children) {
441
440
  function trimWhitespace(text) {
442
441
  text = text.replace(/\r/g, "");
443
442
  if (/\n/g.test(text)) {
444
- text = text
445
- .split("\n")
446
- .map((t, i) => (i ? t.replace(/^\s*/g, "") : t))
447
- .filter(s => !/^\s*$/.test(s))
448
- .join(" ");
443
+ text = text.
444
+ split("\n").
445
+ map((t, i) => i ? t.replace(/^\s*/g, "") : t).
446
+ filter((s) => !/^\s*$/.test(s)).
447
+ join(" ");
449
448
  }
450
449
  return text.replace(/\s+/g, " ");
451
450
  }
@@ -487,20 +486,20 @@ function transformCondition(path, inline, deep) {
487
486
  const memo = registerImportMethod(path, config.memoWrapper);
488
487
  let dTest, cond, id;
489
488
  if (
490
- t__namespace.isConditionalExpression(expr) &&
491
- (isDynamic(path.get("consequent"), {
492
- checkTags: true
493
- }) ||
494
- isDynamic(path.get("alternate"), { checkTags: true }))
495
- ) {
489
+ t__namespace.isConditionalExpression(expr) && (
490
+ isDynamic(path.get("consequent"), {
491
+ checkTags: true
492
+ }) ||
493
+ isDynamic(path.get("alternate"), { checkTags: true })))
494
+ {
496
495
  dTest = isDynamic(path.get("test"), { checkMember: true });
497
496
  if (dTest) {
498
497
  cond = expr.test;
499
498
  if (!t__namespace.isBinaryExpression(cond))
500
- cond = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", cond, true), true);
501
- id = inline
502
- ? t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)])
503
- : path.scope.generateUidIdentifier("_c$");
499
+ cond = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", cond, true), true);
500
+ id = inline ?
501
+ t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)]) :
502
+ path.scope.generateUidIdentifier("_c$");
504
503
  expr.test = t__namespace.callExpression(id, []);
505
504
  if (t__namespace.isConditionalExpression(expr.consequent) || t__namespace.isLogicalExpression(expr.consequent)) {
506
505
  expr.consequent = transformCondition(path.get("consequent"), inline, true);
@@ -516,41 +515,41 @@ function transformCondition(path, inline, deep) {
516
515
  nextPath = nextPath.get("left");
517
516
  }
518
517
  nextPath.node.operator === "&&" &&
519
- isDynamic(nextPath.get("right"), { checkTags: true }) &&
520
- (dTest = isDynamic(nextPath.get("left"), {
521
- checkMember: true
522
- }));
518
+ isDynamic(nextPath.get("right"), { checkTags: true }) && (
519
+ dTest = isDynamic(nextPath.get("left"), {
520
+ checkMember: true
521
+ }));
523
522
  if (dTest) {
524
523
  cond = nextPath.node.left;
525
524
  if (!t__namespace.isBinaryExpression(cond))
526
- cond = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", cond, true), true);
527
- id = inline
528
- ? t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)])
529
- : path.scope.generateUidIdentifier("_c$");
525
+ cond = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", cond, true), true);
526
+ id = inline ?
527
+ t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)]) :
528
+ path.scope.generateUidIdentifier("_c$");
530
529
  nextPath.node.left = t__namespace.callExpression(id, []);
531
530
  }
532
531
  }
533
532
  if (dTest && !inline) {
534
533
  const statements = [
535
- t__namespace.variableDeclaration("var", [
536
- t__namespace.variableDeclarator(
537
- id,
538
- config.memoWrapper
539
- ? t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)])
540
- : t__namespace.arrowFunctionExpression([], cond)
541
- )
542
- ]),
543
- t__namespace.arrowFunctionExpression([], expr)
544
- ];
545
- return deep
546
- ? t__namespace.callExpression(
547
- t__namespace.arrowFunctionExpression(
548
- [],
549
- t__namespace.blockStatement([statements[0], t__namespace.returnStatement(statements[1])])
550
- ),
551
- []
552
- )
553
- : statements;
534
+ t__namespace.variableDeclaration("var", [
535
+ t__namespace.variableDeclarator(
536
+ id,
537
+ config.memoWrapper ?
538
+ t__namespace.callExpression(memo, [t__namespace.arrowFunctionExpression([], cond)]) :
539
+ t__namespace.arrowFunctionExpression([], cond))]),
540
+
541
+
542
+ t__namespace.arrowFunctionExpression([], expr)];
543
+
544
+ return deep ?
545
+ t__namespace.callExpression(
546
+ t__namespace.arrowFunctionExpression(
547
+ [],
548
+ t__namespace.blockStatement([statements[0], t__namespace.returnStatement(statements[1])])),
549
+
550
+ []) :
551
+
552
+ statements;
554
553
  }
555
554
  return deep ? expr : t__namespace.arrowFunctionExpression([], expr);
556
555
  }
@@ -609,9 +608,9 @@ function convertJSXIdentifier(node) {
609
608
  }
610
609
  } else if (t__namespace.isJSXMemberExpression(node)) {
611
610
  return t__namespace.memberExpression(
612
- convertJSXIdentifier(node.object),
613
- convertJSXIdentifier(node.property)
614
- );
611
+ convertJSXIdentifier(node.object),
612
+ convertJSXIdentifier(node.property));
613
+
615
614
  } else if (t__namespace.isJSXNamespacedName(node)) {
616
615
  return t__namespace.stringLiteral(`${node.namespace.name}:${node.name.name}`);
617
616
  }
@@ -621,7 +620,7 @@ function convertJSXIdentifier(node) {
621
620
 
622
621
  function canNativeSpread(key, { checkNameSpaces } = {}) {
623
622
  if (checkNameSpaces && key.includes(":") && nonSpreadNameSpaces.has(key.split(":")[0]))
624
- return false;
623
+ return false;
625
624
  // TODO: figure out how to detect definitely function ref
626
625
  if (key === "ref") return false;
627
626
  return true;
@@ -644,146 +643,144 @@ function getNumberedId(num) {
644
643
  }
645
644
 
646
645
  function escapeStringForTemplate(str) {
647
- return str.replace(/[{\\`\n\t\b\f\v\r\u2028\u2029]/g, ch => templateEscapes.get(ch))
646
+ return str.replace(/[{\\`\n\t\b\f\v\r\u2028\u2029]/g, (ch) => templateEscapes.get(ch));
648
647
  }
649
648
 
650
649
  const templateEscapes = new Map([
651
- ['{', '\\{'],
652
- ['`', '\\`'],
653
- ['\\', '\\\\'],
654
- ['\n', '\\n'],
655
- ['\t', '\\t'],
656
- ['\b', '\\b'],
657
- ['\f', '\\f'],
658
- ['\v', '\\v'],
659
- ['\r', '\\r'],
660
- ['\u2028', '\\u2028'],
661
- ['\u2029', '\\u2029']
662
- ]);
650
+ ['{', '\\{'],
651
+ ['`', '\\`'],
652
+ ['\\', '\\\\'],
653
+ ['\n', '\\n'],
654
+ ['\t', '\\t'],
655
+ ['\b', '\\b'],
656
+ ['\f', '\\f'],
657
+ ['\v', '\\v'],
658
+ ['\r', '\\r'],
659
+ ['\u2028', '\\u2028'],
660
+ ['\u2029', '\\u2029']]);
663
661
 
664
662
  const InlineElements = [
665
- "a",
666
- "abbr",
667
- "acronym",
668
- "b",
669
- "bdi",
670
- "bdo",
671
- "big",
672
- "br",
673
- "button",
674
- "canvas",
675
- "cite",
676
- "code",
677
- "data",
678
- "datalist",
679
- "del",
680
- "dfn",
681
- "em",
682
- "embed",
683
- "i",
684
- "iframe",
685
- "img",
686
- "input",
687
- "ins",
688
- "kbd",
689
- "label",
690
- "map",
691
- "mark",
692
- "meter",
693
- "noscript",
694
- "object",
695
- "output",
696
- "picture",
697
- "progress",
698
- "q",
699
- "ruby",
700
- "s",
701
- "samp",
702
- "script",
703
- "select",
704
- "slot",
705
- "small",
706
- "span",
707
- "strong",
708
- "sub",
709
- "sup",
710
- "svg",
711
- "template",
712
- "textarea",
713
- "time",
714
- "u",
715
- "tt",
716
- "var",
717
- "video"
718
- ];
663
+ "a",
664
+ "abbr",
665
+ "acronym",
666
+ "b",
667
+ "bdi",
668
+ "bdo",
669
+ "big",
670
+ "br",
671
+ "button",
672
+ "canvas",
673
+ "cite",
674
+ "code",
675
+ "data",
676
+ "datalist",
677
+ "del",
678
+ "dfn",
679
+ "em",
680
+ "embed",
681
+ "i",
682
+ "iframe",
683
+ "img",
684
+ "input",
685
+ "ins",
686
+ "kbd",
687
+ "label",
688
+ "map",
689
+ "mark",
690
+ "meter",
691
+ "noscript",
692
+ "object",
693
+ "output",
694
+ "picture",
695
+ "progress",
696
+ "q",
697
+ "ruby",
698
+ "s",
699
+ "samp",
700
+ "script",
701
+ "select",
702
+ "slot",
703
+ "small",
704
+ "span",
705
+ "strong",
706
+ "sub",
707
+ "sup",
708
+ "svg",
709
+ "template",
710
+ "textarea",
711
+ "time",
712
+ "u",
713
+ "tt",
714
+ "var",
715
+ "video"];
716
+
719
717
 
720
718
  const BlockElements = [
721
- "address",
722
- "article",
723
- "aside",
724
- "blockquote",
725
- "dd",
726
- "details",
727
- "dialog",
728
- "div",
729
- "dl",
730
- "dt",
731
- "fieldset",
732
- "figcaption",
733
- "figure",
734
- "footer",
735
- "form",
736
- "h1",
737
- "h2",
738
- "h3",
739
- "h4",
740
- "h5",
741
- "h6",
742
- "header",
743
- "hgroup",
744
- "hr",
745
- "li",
746
- "main",
747
- "menu",
748
- "nav",
749
- "ol",
750
- "p",
751
- "pre",
752
- "section",
753
- "table",
754
- "ul"
755
- ];
719
+ "address",
720
+ "article",
721
+ "aside",
722
+ "blockquote",
723
+ "dd",
724
+ "details",
725
+ "dialog",
726
+ "div",
727
+ "dl",
728
+ "dt",
729
+ "fieldset",
730
+ "figcaption",
731
+ "figure",
732
+ "footer",
733
+ "form",
734
+ "h1",
735
+ "h2",
736
+ "h3",
737
+ "h4",
738
+ "h5",
739
+ "h6",
740
+ "header",
741
+ "hgroup",
742
+ "hr",
743
+ "li",
744
+ "main",
745
+ "menu",
746
+ "nav",
747
+ "ol",
748
+ "p",
749
+ "pre",
750
+ "section",
751
+ "table",
752
+ "ul"];
756
753
 
757
754
  const alwaysClose = [
758
- "title",
759
- "style",
760
- "a",
761
- "strong",
762
- "small",
763
- "b",
764
- "u",
765
- "i",
766
- "em",
767
- "s",
768
- "code",
769
- "object",
770
- "table",
771
- "button",
772
- "textarea",
773
- "select",
774
- "iframe",
775
- "script",
776
- "noscript",
777
- "template",
778
- "fieldset"
779
- ];
755
+ "title",
756
+ "style",
757
+ "a",
758
+ "strong",
759
+ "small",
760
+ "b",
761
+ "u",
762
+ "i",
763
+ "em",
764
+ "s",
765
+ "code",
766
+ "object",
767
+ "table",
768
+ "button",
769
+ "textarea",
770
+ "select",
771
+ "iframe",
772
+ "script",
773
+ "noscript",
774
+ "template",
775
+ "fieldset"];
776
+
780
777
 
781
778
  function transformElement$3(path, info) {
782
779
  let tagName = getTagName(path.node),
783
780
  config = getConfig(path),
784
781
  wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName),
785
782
  voidTag = VoidElements.indexOf(tagName) > -1,
786
- isCustomElement = tagName.indexOf("-") > -1 || !!path.get("openingElement").get("attributes").find(a => a.node.name?.name === "is"),
783
+ isCustomElement = tagName.indexOf("-") > -1 || !!path.get("openingElement").get("attributes").find((a) => a.node.name?.name === "is"),
787
784
  results = {
788
785
  template: `<${tagName}`,
789
786
  declarations: [],
@@ -800,20 +797,20 @@ function transformElement$3(path, info) {
800
797
  results.skipTemplate = true;
801
798
  if (tagName === "head" && info.topLevel) {
802
799
  const createComponent = registerImportMethod(
803
- path,
804
- "createComponent",
805
- getRendererConfig(path, "dom").moduleName
806
- );
800
+ path,
801
+ "createComponent",
802
+ getRendererConfig(path, "dom").moduleName);
803
+
807
804
  const NoHydration = registerImportMethod(
808
- path,
809
- "NoHydration",
810
- getRendererConfig(path, "dom").moduleName
811
- );
805
+ path,
806
+ "NoHydration",
807
+ getRendererConfig(path, "dom").moduleName);
808
+
812
809
  results.exprs.push(
813
- t__namespace.expressionStatement(
814
- t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])
815
- )
816
- );
810
+ t__namespace.expressionStatement(
811
+ t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])));
812
+
813
+
817
814
  return results;
818
815
  }
819
816
  }
@@ -827,22 +824,22 @@ function transformElement$3(path, info) {
827
824
  if (!voidTag) {
828
825
  // always close tags can still be skipped if they have no closing parents and are the last element
829
826
  const toBeClosed =
830
- !info.lastElement ||
831
- (info.toBeClosed && (!config.omitNestedClosingTags || info.toBeClosed.has(tagName)));
827
+ !info.lastElement ||
828
+ info.toBeClosed && (!config.omitNestedClosingTags || info.toBeClosed.has(tagName));
832
829
  if (toBeClosed) {
833
830
  results.toBeClosed = new Set(info.toBeClosed || alwaysClose);
834
831
  results.toBeClosed.add(tagName);
835
- if (InlineElements.includes(tagName)) BlockElements.forEach(i => results.toBeClosed.add(i));
832
+ if (InlineElements.includes(tagName)) BlockElements.forEach((i) => results.toBeClosed.add(i));
836
833
  } else results.toBeClosed = info.toBeClosed;
837
834
  if (tagName !== "noscript") transformChildren$2(path, results, config);
838
835
  if (toBeClosed) results.template += `</${tagName}>`;
839
836
  }
840
837
  if (info.topLevel && config.hydratable && results.hasHydratableEvent) {
841
838
  let runHydrationEvents = registerImportMethod(
842
- path,
843
- "runHydrationEvents",
844
- getRendererConfig(path, "dom").moduleName
845
- );
839
+ path,
840
+ "runHydrationEvents",
841
+ getRendererConfig(path, "dom").moduleName);
842
+
846
843
  results.postExprs.push(t__namespace.expressionStatement(t__namespace.callExpression(runHydrationEvents, [])));
847
844
  }
848
845
  if (wrapSVG) results.template += "</svg>";
@@ -862,73 +859,73 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE, tagN
862
859
  if (namespace === "style") {
863
860
  if (t__namespace.isStringLiteral(value)) {
864
861
  return t__namespace.callExpression(
865
- t__namespace.memberExpression(
866
- t__namespace.memberExpression(elem, t__namespace.identifier("style")),
867
- t__namespace.identifier("setProperty")
868
- ),
869
- [t__namespace.stringLiteral(name), value]
870
- );
862
+ t__namespace.memberExpression(
863
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
864
+ t__namespace.identifier("setProperty")),
865
+
866
+ [t__namespace.stringLiteral(name), value]);
867
+
871
868
  }
872
869
  if (t__namespace.isNullLiteral(value) || t__namespace.isIdentifier(value, { name: "undefined" })) {
873
870
  return t__namespace.callExpression(
874
- t__namespace.memberExpression(
875
- t__namespace.memberExpression(elem, t__namespace.identifier("style")),
876
- t__namespace.identifier("removeProperty")
877
- ),
878
- [t__namespace.stringLiteral(name)]
879
- );
871
+ t__namespace.memberExpression(
872
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
873
+ t__namespace.identifier("removeProperty")),
874
+
875
+ [t__namespace.stringLiteral(name)]);
876
+
880
877
  }
881
878
  return t__namespace.conditionalExpression(
882
- t__namespace.binaryExpression("!=", value, t__namespace.nullLiteral()),
883
- t__namespace.callExpression(
884
- t__namespace.memberExpression(
885
- t__namespace.memberExpression(elem, t__namespace.identifier("style")),
886
- t__namespace.identifier("setProperty")
887
- ),
888
- [t__namespace.stringLiteral(name), prevId ? prevId : value]
889
- ),
890
- t__namespace.callExpression(
891
- t__namespace.memberExpression(
892
- t__namespace.memberExpression(elem, t__namespace.identifier("style")),
893
- t__namespace.identifier("removeProperty")
894
- ),
895
- [t__namespace.stringLiteral(name)]
896
- )
897
- );
879
+ t__namespace.binaryExpression("!=", value, t__namespace.nullLiteral()),
880
+ t__namespace.callExpression(
881
+ t__namespace.memberExpression(
882
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
883
+ t__namespace.identifier("setProperty")),
884
+
885
+ [t__namespace.stringLiteral(name), prevId ? prevId : value]),
886
+
887
+ t__namespace.callExpression(
888
+ t__namespace.memberExpression(
889
+ t__namespace.memberExpression(elem, t__namespace.identifier("style")),
890
+ t__namespace.identifier("removeProperty")),
891
+
892
+ [t__namespace.stringLiteral(name)]));
893
+
894
+
898
895
  }
899
896
 
900
897
  if (namespace === "class") {
901
898
  return t__namespace.callExpression(
902
- t__namespace.memberExpression(
903
- t__namespace.memberExpression(elem, t__namespace.identifier("classList")),
904
- t__namespace.identifier("toggle")
905
- ),
906
- [
907
- t__namespace.stringLiteral(name),
908
- dynamic ? value : t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value))
909
- ]
910
- );
899
+ t__namespace.memberExpression(
900
+ t__namespace.memberExpression(elem, t__namespace.identifier("classList")),
901
+ t__namespace.identifier("toggle")),
902
+
903
+ [
904
+ t__namespace.stringLiteral(name),
905
+ dynamic ? value : t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value))]);
906
+
907
+
911
908
  }
912
909
 
913
910
  if (name === "style") {
914
911
  return t__namespace.callExpression(
915
- registerImportMethod(path, "style", getRendererConfig(path, "dom").moduleName),
916
- prevId ? [elem, value, prevId] : [elem, value]
917
- );
912
+ registerImportMethod(path, "style", getRendererConfig(path, "dom").moduleName),
913
+ prevId ? [elem, value, prevId] : [elem, value]);
914
+
918
915
  }
919
916
 
920
917
  if (!isSVG && name === "class") {
921
918
  return t__namespace.callExpression(
922
- registerImportMethod(path, "className", getRendererConfig(path, "dom").moduleName),
923
- [elem, value]
924
- );
919
+ registerImportMethod(path, "className", getRendererConfig(path, "dom").moduleName),
920
+ [elem, value]);
921
+
925
922
  }
926
923
 
927
924
  if (name === "classList") {
928
925
  return t__namespace.callExpression(
929
- registerImportMethod(path, "classList", getRendererConfig(path, "dom").moduleName),
930
- prevId ? [elem, value, prevId] : [elem, value]
931
- );
926
+ registerImportMethod(path, "classList", getRendererConfig(path, "dom").moduleName),
927
+ prevId ? [elem, value, prevId] : [elem, value]);
928
+
932
929
  }
933
930
 
934
931
  if (dynamic && name === "textContent") {
@@ -941,16 +938,16 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE, tagN
941
938
  const isChildProp = ChildProperties.has(name);
942
939
  const isProp = Properties.has(name);
943
940
  const alias = getPropAlias(name, tagName.toUpperCase());
944
- if (namespace !== "attr" && (isChildProp || (!isSVG && isProp) || isCE || namespace === "prop")) {
941
+ if (namespace !== "attr" && (isChildProp || !isSVG && isProp || isCE || namespace === "prop")) {
945
942
  if (isCE && !isChildProp && !isProp && namespace !== "prop") name = toPropertyName(name);
946
943
  if (config.hydratable && namespace !== "prop") {
947
944
  return t__namespace.callExpression(registerImportMethod(path, "setProperty"), [elem, t__namespace.stringLiteral(name), value]);
948
945
  }
949
946
  return t__namespace.assignmentExpression(
950
- "=",
951
- t__namespace.memberExpression(elem, t__namespace.identifier(alias || name)),
952
- value
953
- );
947
+ "=",
948
+ t__namespace.memberExpression(elem, t__namespace.identifier(alias || name)),
949
+ value);
950
+
954
951
  }
955
952
 
956
953
  let isNameSpaced = name.indexOf(":") > -1;
@@ -959,14 +956,14 @@ function setAttr$2(path, elem, name, value, { isSVG, dynamic, prevId, isCE, tagN
959
956
  const ns = isNameSpaced && SVGNamespace[name.split(":")[0]];
960
957
  if (ns) {
961
958
  return t__namespace.callExpression(
962
- registerImportMethod(path, "setAttributeNS", getRendererConfig(path, "dom").moduleName),
963
- [elem, t__namespace.stringLiteral(ns), t__namespace.stringLiteral(name), value]
964
- );
959
+ registerImportMethod(path, "setAttributeNS", getRendererConfig(path, "dom").moduleName),
960
+ [elem, t__namespace.stringLiteral(ns), t__namespace.stringLiteral(name), value]);
961
+
965
962
  } else {
966
963
  return t__namespace.callExpression(
967
- registerImportMethod(path, "setAttribute", getRendererConfig(path, "dom").moduleName),
968
- [elem, t__namespace.stringLiteral(name), value]
969
- );
964
+ registerImportMethod(path, "setAttribute", getRendererConfig(path, "dom").moduleName),
965
+ [elem, t__namespace.stringLiteral(name), value]);
966
+
970
967
  }
971
968
  }
972
969
 
@@ -997,7 +994,7 @@ function transformAttributes$2(path, results) {
997
994
  config = getConfig(path);
998
995
 
999
996
  // preprocess spreads
1000
- if (attributes.some(attribute => t__namespace.isJSXSpreadAttribute(attribute.node))) {
997
+ if (attributes.some((attribute) => t__namespace.isJSXSpreadAttribute(attribute.node))) {
1001
998
  [attributes, spreadExpr] = processSpreads$1(path, attributes, {
1002
999
  elem,
1003
1000
  isSVG,
@@ -1005,66 +1002,66 @@ function transformAttributes$2(path, results) {
1005
1002
  wrapConditionals: config.wrapConditionals
1006
1003
  });
1007
1004
  path.get("openingElement").set(
1008
- "attributes",
1009
- attributes.map(a => a.node)
1010
- );
1005
+ "attributes",
1006
+ attributes.map((a) => a.node));
1007
+
1011
1008
  //NOTE: can't be checked at compile time so add to compiled output
1012
1009
  hasHydratableEvent = true;
1013
1010
  }
1014
1011
 
1015
1012
  // preprocess styles
1016
- const styleAttribute = path
1017
- .get("openingElement")
1018
- .get("attributes")
1019
- .find(
1020
- a =>
1021
- a.node.name &&
1022
- a.node.name.name === "style" &&
1023
- t__namespace.isJSXExpressionContainer(a.node.value) &&
1024
- t__namespace.isObjectExpression(a.node.value.expression) &&
1025
- !a.node.value.expression.properties.some(p => t__namespace.isSpreadElement(p))
1026
- );
1013
+ const styleAttribute = path.
1014
+ get("openingElement").
1015
+ get("attributes").
1016
+ find(
1017
+ (a) =>
1018
+ a.node.name &&
1019
+ a.node.name.name === "style" &&
1020
+ t__namespace.isJSXExpressionContainer(a.node.value) &&
1021
+ t__namespace.isObjectExpression(a.node.value.expression) &&
1022
+ !a.node.value.expression.properties.some((p) => t__namespace.isSpreadElement(p)));
1023
+
1027
1024
  if (styleAttribute) {
1028
1025
  let i = 0,
1029
1026
  leading = styleAttribute.node.value.expression.leadingComments;
1030
1027
  styleAttribute.node.value.expression.properties.slice().forEach((p, index) => {
1031
1028
  if (!p.computed) {
1032
1029
  if (leading) p.value.leadingComments = leading;
1033
- path
1034
- .get("openingElement")
1035
- .node.attributes.splice(
1036
- styleAttribute.key + ++i,
1037
- 0,
1038
- t__namespace.jsxAttribute(
1039
- t__namespace.jsxNamespacedName(
1040
- t__namespace.jsxIdentifier("style"),
1041
- t__namespace.jsxIdentifier(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)
1042
- ),
1043
- t__namespace.jsxExpressionContainer(p.value)
1044
- )
1045
- );
1030
+ path.
1031
+ get("openingElement").
1032
+ node.attributes.splice(
1033
+ styleAttribute.key + ++i,
1034
+ 0,
1035
+ t__namespace.jsxAttribute(
1036
+ t__namespace.jsxNamespacedName(
1037
+ t__namespace.jsxIdentifier("style"),
1038
+ t__namespace.jsxIdentifier(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)),
1039
+
1040
+ t__namespace.jsxExpressionContainer(p.value)));
1041
+
1042
+
1046
1043
  styleAttribute.node.value.expression.properties.splice(index - i - 1, 1);
1047
1044
  }
1048
1045
  });
1049
1046
  if (!styleAttribute.node.value.expression.properties.length)
1050
- path.get("openingElement").node.attributes.splice(styleAttribute.key, 1);
1047
+ path.get("openingElement").node.attributes.splice(styleAttribute.key, 1);
1051
1048
  }
1052
1049
 
1053
1050
  // preprocess classList
1054
1051
  attributes = path.get("openingElement").get("attributes");
1055
1052
  const classListAttribute = attributes.find(
1056
- a =>
1057
- a.node.name &&
1058
- a.node.name.name === "classList" &&
1059
- t__namespace.isJSXExpressionContainer(a.node.value) &&
1060
- t__namespace.isObjectExpression(a.node.value.expression) &&
1061
- !a.node.value.expression.properties.some(
1062
- p =>
1063
- t__namespace.isSpreadElement(p) ||
1064
- p.computed ||
1065
- (t__namespace.isStringLiteral(p.key) && (p.key.value.includes(" ") || p.key.value.includes(":")))
1066
- )
1067
- );
1053
+ (a) =>
1054
+ a.node.name &&
1055
+ a.node.name.name === "classList" &&
1056
+ t__namespace.isJSXExpressionContainer(a.node.value) &&
1057
+ t__namespace.isObjectExpression(a.node.value.expression) &&
1058
+ !a.node.value.expression.properties.some(
1059
+ (p) =>
1060
+ t__namespace.isSpreadElement(p) ||
1061
+ p.computed ||
1062
+ t__namespace.isStringLiteral(p.key) && (p.key.value.includes(" ") || p.key.value.includes(":"))));
1063
+
1064
+
1068
1065
  if (classListAttribute) {
1069
1066
  let i = 0,
1070
1067
  leading = classListAttribute.node.value.expression.leadingComments,
@@ -1074,42 +1071,42 @@ function transformAttributes$2(path, results) {
1074
1071
  const { confident, value: computed } = propPath.get("value").evaluate();
1075
1072
  if (leading) p.value.leadingComments = leading;
1076
1073
  if (!confident) {
1077
- path
1078
- .get("openingElement")
1079
- .node.attributes.splice(
1080
- classListAttribute.key + ++i,
1081
- 0,
1082
- t__namespace.jsxAttribute(
1083
- t__namespace.jsxNamespacedName(
1084
- t__namespace.jsxIdentifier("class"),
1085
- t__namespace.jsxIdentifier(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)
1086
- ),
1087
- t__namespace.jsxExpressionContainer(p.value)
1088
- )
1089
- );
1074
+ path.
1075
+ get("openingElement").
1076
+ node.attributes.splice(
1077
+ classListAttribute.key + ++i,
1078
+ 0,
1079
+ t__namespace.jsxAttribute(
1080
+ t__namespace.jsxNamespacedName(
1081
+ t__namespace.jsxIdentifier("class"),
1082
+ t__namespace.jsxIdentifier(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)),
1083
+
1084
+ t__namespace.jsxExpressionContainer(p.value)));
1085
+
1086
+
1090
1087
  } else if (computed) {
1091
- path
1092
- .get("openingElement")
1093
- .node.attributes.splice(
1094
- classListAttribute.key + ++i,
1095
- 0,
1096
- t__namespace.jsxAttribute(
1097
- t__namespace.jsxIdentifier("class"),
1098
- t__namespace.stringLiteral(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)
1099
- )
1100
- );
1088
+ path.
1089
+ get("openingElement").
1090
+ node.attributes.splice(
1091
+ classListAttribute.key + ++i,
1092
+ 0,
1093
+ t__namespace.jsxAttribute(
1094
+ t__namespace.jsxIdentifier("class"),
1095
+ t__namespace.stringLiteral(t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value)));
1096
+
1097
+
1101
1098
  }
1102
1099
  classListProperties.splice(index - i - 1, 1);
1103
1100
  });
1104
1101
  if (!classListProperties.length)
1105
- path.get("openingElement").node.attributes.splice(classListAttribute.key, 1);
1102
+ path.get("openingElement").node.attributes.splice(classListAttribute.key, 1);
1106
1103
  }
1107
1104
 
1108
1105
  // combine class properties
1109
1106
  attributes = path.get("openingElement").get("attributes");
1110
1107
  const classAttributes = attributes.filter(
1111
- a => a.node.name && (a.node.name.name === "class" || a.node.name.name === "className")
1112
- );
1108
+ (a) => a.node.name && (a.node.name.name === "class" || a.node.name.name === "className"));
1109
+
1113
1110
  if (classAttributes.length > 1) {
1114
1111
  const first = classAttributes[0].node,
1115
1112
  values = [],
@@ -1120,377 +1117,377 @@ function transformAttributes$2(path, results) {
1120
1117
  if (!t__namespace.isJSXExpressionContainer(attr.value)) {
1121
1118
  const prev = quasis.pop();
1122
1119
  quasis.push(
1123
- t__namespace.templateElement({
1124
- raw: (prev ? prev.value.raw : "") + `${attr.value.value}` + (isLast ? "" : " ")
1125
- })
1126
- );
1120
+ t__namespace.templateElement({
1121
+ raw: (prev ? prev.value.raw : "") + `${attr.value.value}` + (isLast ? "" : " ")
1122
+ }));
1123
+
1127
1124
  } else {
1128
1125
  values.push(t__namespace.logicalExpression("||", attr.value.expression, t__namespace.stringLiteral("")));
1129
1126
  quasis.push(t__namespace.templateElement({ raw: isLast ? "" : " " }));
1130
1127
  }
1131
1128
  i && attributes.splice(attributes.indexOf(classAttributes[i]), 1);
1132
1129
  }
1133
- if (values.length) first.value = t__namespace.jsxExpressionContainer(t__namespace.templateLiteral(quasis, values));
1134
- else first.value = t__namespace.stringLiteral(quasis[0].value.raw);
1130
+ if (values.length) first.value = t__namespace.jsxExpressionContainer(t__namespace.templateLiteral(quasis, values));else
1131
+ first.value = t__namespace.stringLiteral(quasis[0].value.raw);
1135
1132
  }
1136
1133
  path.get("openingElement").set(
1137
- "attributes",
1138
- attributes.map(a => a.node)
1139
- );
1134
+ "attributes",
1135
+ attributes.map((a) => a.node));
1136
+
1140
1137
 
1141
1138
  let needsSpacing = true;
1142
1139
 
1143
- path
1144
- .get("openingElement")
1145
- .get("attributes")
1146
- .forEach(attribute => {
1147
- const node = attribute.node;
1148
- let value = node.value,
1149
- key = t__namespace.isJSXNamespacedName(node.name)
1150
- ? `${node.name.namespace.name}:${node.name.name.name}`
1151
- : node.name.name,
1152
- reservedNameSpace =
1153
- t__namespace.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
1154
- if (t__namespace.isJSXExpressionContainer(value) && !key.startsWith("use:")) {
1155
- const evaluated = attribute.get("value").get("expression").evaluate().value;
1156
- let type;
1157
- if (
1158
- evaluated !== undefined &&
1159
- ((type = typeof evaluated) === "string" || type === "number")
1160
- ) {
1161
- if (type === "number" && (Properties.has(key) || key.startsWith("prop:"))) {
1162
- value = t__namespace.jsxExpressionContainer(t__namespace.numericLiteral(evaluated));
1163
- } else value = t__namespace.stringLiteral(String(evaluated));
1164
- }
1165
- }
1140
+ path.
1141
+ get("openingElement").
1142
+ get("attributes").
1143
+ forEach((attribute) => {
1144
+ const node = attribute.node;
1145
+ let value = node.value,
1146
+ key = t__namespace.isJSXNamespacedName(node.name) ?
1147
+ `${node.name.namespace.name}:${node.name.name.name}` :
1148
+ node.name.name,
1149
+ reservedNameSpace =
1150
+ t__namespace.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
1151
+ if (t__namespace.isJSXExpressionContainer(value) && !key.startsWith("use:")) {
1152
+ const evaluated = attribute.get("value").get("expression").evaluate().value;
1153
+ let type;
1166
1154
  if (
1167
- t__namespace.isJSXNamespacedName(node.name) &&
1168
- reservedNameSpace &&
1169
- !t__namespace.isJSXExpressionContainer(value)
1170
- ) {
1171
- node.value = value = t__namespace.jsxExpressionContainer(value || t__namespace.jsxEmptyExpression());
1155
+ evaluated !== undefined && (
1156
+ (type = typeof evaluated) === "string" || type === "number"))
1157
+ {
1158
+ if (type === "number" && (Properties.has(key) || key.startsWith("prop:"))) {
1159
+ value = t__namespace.jsxExpressionContainer(t__namespace.numericLiteral(evaluated));
1160
+ } else value = t__namespace.stringLiteral(String(evaluated));
1172
1161
  }
1173
- if (
1174
- t__namespace.isJSXExpressionContainer(value) &&
1175
- (reservedNameSpace ||
1176
- !(t__namespace.isStringLiteral(value.expression) || t__namespace.isNumericLiteral(value.expression)))
1177
- ) {
1178
- if (key === "ref") {
1179
- // Normalize expressions for non-null and type-as
1180
- while (
1181
- t__namespace.isTSNonNullExpression(value.expression) ||
1182
- t__namespace.isTSAsExpression(value.expression)
1183
- ) {
1184
- value.expression = value.expression.expression;
1185
- }
1186
- let binding,
1187
- isFunction =
1188
- t__namespace.isIdentifier(value.expression) &&
1189
- (binding = path.scope.getBinding(value.expression.name)) &&
1190
- binding.kind === "const";
1191
- if (!isFunction && t__namespace.isLVal(value.expression)) {
1192
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1193
- results.exprs.unshift(
1194
- t__namespace.variableDeclaration("var", [
1195
- t__namespace.variableDeclarator(refIdentifier, value.expression)
1196
- ]),
1162
+ }
1163
+ if (
1164
+ t__namespace.isJSXNamespacedName(node.name) &&
1165
+ reservedNameSpace &&
1166
+ !t__namespace.isJSXExpressionContainer(value))
1167
+ {
1168
+ node.value = value = t__namespace.jsxExpressionContainer(value || t__namespace.jsxEmptyExpression());
1169
+ }
1170
+ if (
1171
+ t__namespace.isJSXExpressionContainer(value) && (
1172
+ reservedNameSpace ||
1173
+ !(t__namespace.isStringLiteral(value.expression) || t__namespace.isNumericLiteral(value.expression))))
1174
+ {
1175
+ if (key === "ref") {
1176
+ // Normalize expressions for non-null and type-as
1177
+ while (
1178
+ t__namespace.isTSNonNullExpression(value.expression) ||
1179
+ t__namespace.isTSAsExpression(value.expression))
1180
+ {
1181
+ value.expression = value.expression.expression;
1182
+ }
1183
+ let binding,
1184
+ isFunction =
1185
+ t__namespace.isIdentifier(value.expression) && (
1186
+ binding = path.scope.getBinding(value.expression.name)) &&
1187
+ binding.kind === "const";
1188
+ if (!isFunction && t__namespace.isLVal(value.expression)) {
1189
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1190
+ results.exprs.unshift(
1191
+ t__namespace.variableDeclaration("var", [
1192
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
1193
+
1194
+ t__namespace.expressionStatement(
1195
+ t__namespace.conditionalExpression(
1196
+ t__namespace.binaryExpression(
1197
+ "===",
1198
+ t__namespace.unaryExpression("typeof", refIdentifier),
1199
+ t__namespace.stringLiteral("function")),
1200
+
1201
+ t__namespace.callExpression(
1202
+ registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1203
+ [refIdentifier, elem]),
1204
+
1205
+ t__namespace.assignmentExpression("=", value.expression, elem))));
1206
+
1207
+
1208
+
1209
+ } else if (isFunction || t__namespace.isFunction(value.expression)) {
1210
+ results.exprs.unshift(
1211
+ t__namespace.expressionStatement(
1212
+ t__namespace.callExpression(
1213
+ registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1214
+ [value.expression, elem])));
1215
+
1216
+
1217
+
1218
+ } else {
1219
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1220
+ results.exprs.unshift(
1221
+ t__namespace.variableDeclaration("var", [
1222
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
1223
+
1224
+ t__namespace.expressionStatement(
1225
+ t__namespace.logicalExpression(
1226
+ "&&",
1227
+ t__namespace.binaryExpression(
1228
+ "===",
1229
+ t__namespace.unaryExpression("typeof", refIdentifier),
1230
+ t__namespace.stringLiteral("function")),
1231
+
1232
+ t__namespace.callExpression(
1233
+ registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1234
+ [refIdentifier, elem]))));
1235
+
1236
+
1237
+
1238
+
1239
+ }
1240
+ } else if (key.startsWith("use:")) {
1241
+ // Some trick to treat JSXIdentifier as Identifier
1242
+ node.name.name.type = "Identifier";
1243
+ results.exprs.unshift(
1244
+ t__namespace.expressionStatement(
1245
+ t__namespace.callExpression(
1246
+ registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1247
+ [
1248
+ node.name.name,
1249
+ elem,
1250
+ t__namespace.arrowFunctionExpression(
1251
+ [],
1252
+ t__namespace.isJSXEmptyExpression(value.expression) ?
1253
+ t__namespace.booleanLiteral(true) :
1254
+ value.expression)])));
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+ } else if (key === "children") {
1261
+ children = value;
1262
+ } else if (key.startsWith("on")) {
1263
+ const ev = toEventName(key);
1264
+ if (key.startsWith("on:") || key.startsWith("oncapture:")) {
1265
+ const listenerOptions = [t__namespace.stringLiteral(key.split(":")[1]), value.expression];
1266
+ results.exprs.push(
1267
+ t__namespace.expressionStatement(
1268
+ t__namespace.callExpression(
1269
+ t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")),
1270
+ key.startsWith("oncapture:") ?
1271
+ listenerOptions.concat(t__namespace.booleanLiteral(true)) :
1272
+ listenerOptions)));
1273
+
1274
+
1275
+
1276
+ } else if (
1277
+ config.delegateEvents && (
1278
+ DelegatedEvents.has(ev) || config.delegatedEvents.indexOf(ev) !== -1))
1279
+ {
1280
+ // can only hydrate delegated events
1281
+ hasHydratableEvent = true;
1282
+ const events =
1283
+ attribute.scope.getProgramParent().data.events || (
1284
+ attribute.scope.getProgramParent().data.events = new Set());
1285
+ events.add(ev);
1286
+ let handler = value.expression;
1287
+ const resolveable = detectResolvableEventHandler(attribute, handler);
1288
+ if (t__namespace.isArrayExpression(handler)) {
1289
+ if (handler.elements.length > 1) {
1290
+ results.exprs.unshift(
1197
1291
  t__namespace.expressionStatement(
1198
- t__namespace.conditionalExpression(
1199
- t__namespace.binaryExpression(
1200
- "===",
1201
- t__namespace.unaryExpression("typeof", refIdentifier),
1202
- t__namespace.stringLiteral("function")
1203
- ),
1204
- t__namespace.callExpression(
1205
- registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1206
- [refIdentifier, elem]
1207
- ),
1208
- t__namespace.assignmentExpression("=", value.expression, elem)
1209
- )
1210
- )
1211
- );
1212
- } else if (isFunction || t__namespace.isFunction(value.expression)) {
1292
+ t__namespace.assignmentExpression(
1293
+ "=",
1294
+ t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}Data`)),
1295
+ handler.elements[1])));
1296
+
1297
+
1298
+
1299
+ }
1300
+ handler = handler.elements[0];
1213
1301
  results.exprs.unshift(
1214
- t__namespace.expressionStatement(
1215
- t__namespace.callExpression(
1216
- registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1217
- [value.expression, elem]
1218
- )
1219
- )
1220
- );
1302
+ t__namespace.expressionStatement(
1303
+ t__namespace.assignmentExpression(
1304
+ "=",
1305
+ t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}`)),
1306
+ handler)));
1307
+
1308
+
1309
+
1310
+ } else if (t__namespace.isFunction(handler) || resolveable) {
1311
+ results.exprs.unshift(
1312
+ t__namespace.expressionStatement(
1313
+ t__namespace.assignmentExpression(
1314
+ "=",
1315
+ t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}`)),
1316
+ handler)));
1317
+
1318
+
1319
+
1221
1320
  } else {
1222
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
1223
1321
  results.exprs.unshift(
1224
- t__namespace.variableDeclaration("var", [
1225
- t__namespace.variableDeclarator(refIdentifier, value.expression)
1226
- ]),
1227
- t__namespace.expressionStatement(
1228
- t__namespace.logicalExpression(
1229
- "&&",
1230
- t__namespace.binaryExpression(
1231
- "===",
1232
- t__namespace.unaryExpression("typeof", refIdentifier),
1233
- t__namespace.stringLiteral("function")
1234
- ),
1235
- t__namespace.callExpression(
1236
- registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1237
- [refIdentifier, elem]
1238
- )
1239
- )
1240
- )
1241
- );
1322
+ t__namespace.expressionStatement(
1323
+ t__namespace.callExpression(
1324
+ registerImportMethod(
1325
+ path,
1326
+ "addEventListener",
1327
+ getRendererConfig(path, "dom").moduleName),
1328
+
1329
+ [elem, t__namespace.stringLiteral(ev), handler, t__namespace.booleanLiteral(true)])));
1330
+
1331
+
1332
+
1242
1333
  }
1243
- } else if (key.startsWith("use:")) {
1244
- // Some trick to treat JSXIdentifier as Identifier
1245
- node.name.name.type = "Identifier";
1246
- results.exprs.unshift(
1334
+ } else {
1335
+ let handler = value.expression;
1336
+ const resolveable = detectResolvableEventHandler(attribute, handler);
1337
+ if (t__namespace.isArrayExpression(handler)) {
1338
+ if (handler.elements.length > 1) {
1339
+ handler = t__namespace.arrowFunctionExpression(
1340
+ [t__namespace.identifier("e")],
1341
+ t__namespace.callExpression(handler.elements[0], [handler.elements[1], t__namespace.identifier("e")]));
1342
+
1343
+ } else handler = handler.elements[0];
1344
+ results.exprs.unshift(
1247
1345
  t__namespace.expressionStatement(
1248
- t__namespace.callExpression(
1249
- registerImportMethod(path, "use", getRendererConfig(path, "dom").moduleName),
1250
- [
1251
- node.name.name,
1252
- elem,
1253
- t__namespace.arrowFunctionExpression(
1254
- [],
1255
- t__namespace.isJSXEmptyExpression(value.expression)
1256
- ? t__namespace.booleanLiteral(true)
1257
- : value.expression
1258
- )
1259
- ]
1260
- )
1261
- )
1262
- );
1263
- } else if (key === "children") {
1264
- children = value;
1265
- } else if (key.startsWith("on")) {
1266
- const ev = toEventName(key);
1267
- if (key.startsWith("on:") || key.startsWith("oncapture:")) {
1268
- const listenerOptions = [t__namespace.stringLiteral(key.split(":")[1]), value.expression];
1269
- results.exprs.push(
1270
- t__namespace.expressionStatement(
1271
- t__namespace.callExpression(
1272
- t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")),
1273
- key.startsWith("oncapture:")
1274
- ? listenerOptions.concat(t__namespace.booleanLiteral(true))
1275
- : listenerOptions
1276
- )
1277
- )
1278
- );
1279
- } else if (
1280
- config.delegateEvents &&
1281
- (DelegatedEvents.has(ev) || config.delegatedEvents.indexOf(ev) !== -1)
1282
- ) {
1283
- // can only hydrate delegated events
1284
- hasHydratableEvent = true;
1285
- const events =
1286
- attribute.scope.getProgramParent().data.events ||
1287
- (attribute.scope.getProgramParent().data.events = new Set());
1288
- events.add(ev);
1289
- let handler = value.expression;
1290
- const resolveable = detectResolvableEventHandler(attribute, handler);
1291
- if (t__namespace.isArrayExpression(handler)) {
1292
- if (handler.elements.length > 1) {
1293
- results.exprs.unshift(
1294
- t__namespace.expressionStatement(
1295
- t__namespace.assignmentExpression(
1296
- "=",
1297
- t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}Data`)),
1298
- handler.elements[1]
1299
- )
1300
- )
1301
- );
1302
- }
1303
- handler = handler.elements[0];
1304
- results.exprs.unshift(
1305
- t__namespace.expressionStatement(
1306
- t__namespace.assignmentExpression(
1307
- "=",
1308
- t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}`)),
1309
- handler
1310
- )
1311
- )
1312
- );
1313
- } else if (t__namespace.isFunction(handler) || resolveable) {
1314
- results.exprs.unshift(
1315
- t__namespace.expressionStatement(
1316
- t__namespace.assignmentExpression(
1317
- "=",
1318
- t__namespace.memberExpression(elem, t__namespace.identifier(`$$${ev}`)),
1319
- handler
1320
- )
1321
- )
1322
- );
1323
- } else {
1324
- results.exprs.unshift(
1325
- t__namespace.expressionStatement(
1326
- t__namespace.callExpression(
1327
- registerImportMethod(
1328
- path,
1329
- "addEventListener",
1330
- getRendererConfig(path, "dom").moduleName
1331
- ),
1332
- [elem, t__namespace.stringLiteral(ev), handler, t__namespace.booleanLiteral(true)]
1333
- )
1334
- )
1335
- );
1336
- }
1346
+ t__namespace.callExpression(t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")), [
1347
+ t__namespace.stringLiteral(ev),
1348
+ handler])));
1349
+
1350
+
1351
+
1352
+ } else if (t__namespace.isFunction(handler) || resolveable) {
1353
+ results.exprs.unshift(
1354
+ t__namespace.expressionStatement(
1355
+ t__namespace.callExpression(t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")), [
1356
+ t__namespace.stringLiteral(ev),
1357
+ handler])));
1358
+
1359
+
1360
+
1337
1361
  } else {
1338
- let handler = value.expression;
1339
- const resolveable = detectResolvableEventHandler(attribute, handler);
1340
- if (t__namespace.isArrayExpression(handler)) {
1341
- if (handler.elements.length > 1) {
1342
- handler = t__namespace.arrowFunctionExpression(
1343
- [t__namespace.identifier("e")],
1344
- t__namespace.callExpression(handler.elements[0], [handler.elements[1], t__namespace.identifier("e")])
1345
- );
1346
- } else handler = handler.elements[0];
1347
- results.exprs.unshift(
1348
- t__namespace.expressionStatement(
1349
- t__namespace.callExpression(t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")), [
1350
- t__namespace.stringLiteral(ev),
1351
- handler
1352
- ])
1353
- )
1354
- );
1355
- } else if (t__namespace.isFunction(handler) || resolveable) {
1356
- results.exprs.unshift(
1357
- t__namespace.expressionStatement(
1358
- t__namespace.callExpression(t__namespace.memberExpression(elem, t__namespace.identifier("addEventListener")), [
1359
- t__namespace.stringLiteral(ev),
1360
- handler
1361
- ])
1362
- )
1363
- );
1364
- } else {
1365
- results.exprs.unshift(
1366
- t__namespace.expressionStatement(
1367
- t__namespace.callExpression(
1368
- registerImportMethod(
1369
- path,
1370
- "addEventListener",
1371
- getRendererConfig(path, "dom").moduleName
1372
- ),
1373
- [elem, t__namespace.stringLiteral(ev), handler]
1374
- )
1375
- )
1376
- );
1377
- }
1378
- }
1379
- } else if (
1380
- config.effectWrapper &&
1381
- (isDynamic(attribute.get("value").get("expression"), {
1382
- checkMember: true
1383
- }) ||
1384
- ((key === "classList" || key === "style") &&
1385
- !attribute.get("value").get("expression").evaluate().confident))
1386
- ) {
1387
- let nextElem = elem;
1388
- if (key === "value" || key === "checked") {
1389
- const effectWrapperId = registerImportMethod(path, config.effectWrapper);
1390
- results.postExprs.push(
1391
- t__namespace.expressionStatement(
1392
- t__namespace.callExpression(effectWrapperId, [
1393
- t__namespace.arrowFunctionExpression(
1394
- [],
1395
- setAttr$2(path, elem, key, value.expression, {
1396
- tagName,
1397
- isSVG,
1398
- isCE
1399
- })
1400
- )
1401
- ])
1402
- )
1403
- );
1404
- return;
1405
- }
1406
- if (key === "textContent") {
1407
- nextElem = attribute.scope.generateUidIdentifier("el$");
1408
- children = t__namespace.jsxText(" ");
1409
- children.extra = { raw: " ", rawValue: " " };
1410
- results.declarations.push(
1411
- t__namespace.variableDeclarator(nextElem, t__namespace.memberExpression(elem, t__namespace.identifier("firstChild")))
1412
- );
1362
+ results.exprs.unshift(
1363
+ t__namespace.expressionStatement(
1364
+ t__namespace.callExpression(
1365
+ registerImportMethod(
1366
+ path,
1367
+ "addEventListener",
1368
+ getRendererConfig(path, "dom").moduleName),
1369
+
1370
+ [elem, t__namespace.stringLiteral(ev), handler])));
1371
+
1372
+
1373
+
1413
1374
  }
1414
- results.dynamics.push({
1415
- elem: nextElem,
1416
- key,
1417
- value: value.expression,
1375
+ }
1376
+ } else if (
1377
+ config.effectWrapper && (
1378
+ isDynamic(attribute.get("value").get("expression"), {
1379
+ checkMember: true
1380
+ }) ||
1381
+ (key === "classList" || key === "style") &&
1382
+ !attribute.get("value").get("expression").evaluate().confident))
1383
+ {
1384
+ let nextElem = elem;
1385
+ if (key === "value" || key === "checked") {
1386
+ const effectWrapperId = registerImportMethod(path, config.effectWrapper);
1387
+ results.postExprs.push(
1388
+ t__namespace.expressionStatement(
1389
+ t__namespace.callExpression(effectWrapperId, [
1390
+ t__namespace.arrowFunctionExpression(
1391
+ [],
1392
+ setAttr$2(path, elem, key, value.expression, {
1393
+ tagName,
1418
1394
  isSVG,
1419
- isCE,
1420
- tagName
1421
- });
1422
- } else {
1423
- results.exprs.push(
1424
- t__namespace.expressionStatement(
1425
- setAttr$2(attribute, elem, key, value.expression, { isSVG, isCE, tagName })
1426
- )
1427
- );
1395
+ isCE
1396
+ }))])));
1397
+
1398
+
1399
+
1400
+
1401
+ return;
1428
1402
  }
1403
+ if (key === "textContent") {
1404
+ nextElem = attribute.scope.generateUidIdentifier("el$");
1405
+ children = t__namespace.jsxText(" ");
1406
+ children.extra = { raw: " ", rawValue: " " };
1407
+ results.declarations.push(
1408
+ t__namespace.variableDeclarator(nextElem, t__namespace.memberExpression(elem, t__namespace.identifier("firstChild"))));
1409
+
1410
+ }
1411
+ results.dynamics.push({
1412
+ elem: nextElem,
1413
+ key,
1414
+ value: value.expression,
1415
+ isSVG,
1416
+ isCE,
1417
+ tagName
1418
+ });
1419
+ } else {
1420
+ results.exprs.push(
1421
+ t__namespace.expressionStatement(
1422
+ setAttr$2(attribute, elem, key, value.expression, { isSVG, isCE, tagName })));
1423
+
1424
+
1425
+ }
1426
+ } else {
1427
+ if (config.hydratable && key === "$ServerOnly") {
1428
+ results.skipTemplate = true;
1429
+ return;
1430
+ }
1431
+ if (t__namespace.isJSXExpressionContainer(value)) value = value.expression;
1432
+ key = Aliases[key] || key;
1433
+ if (value && ChildProperties.has(key)) {
1434
+ results.exprs.push(
1435
+ t__namespace.expressionStatement(setAttr$2(attribute, elem, key, value, { isSVG, isCE, tagName })));
1436
+
1429
1437
  } else {
1430
- if (config.hydratable && key === "$ServerOnly") {
1431
- results.skipTemplate = true;
1438
+ !isSVG && (key = key.toLowerCase());
1439
+ results.template += `${needsSpacing ? ' ' : ''}${key}`;
1440
+ if (!value) {
1441
+ needsSpacing = true;
1432
1442
  return;
1433
1443
  }
1434
- if (t__namespace.isJSXExpressionContainer(value)) value = value.expression;
1435
- key = Aliases[key] || key;
1436
- if (value && ChildProperties.has(key)) {
1437
- results.exprs.push(
1438
- t__namespace.expressionStatement(setAttr$2(attribute, elem, key, value, { isSVG, isCE, tagName }))
1439
- );
1440
- } else {
1441
- !isSVG && (key = key.toLowerCase());
1442
- results.template += `${needsSpacing ? ' ' : ''}${key}`;
1443
- if (!value) {
1444
- needsSpacing = true;
1445
- return;
1446
- }
1447
1444
 
1448
- let text = value.value;
1449
- if (typeof text === "number") text = String(text);
1450
- let needsQuoting = false;
1445
+ let text = value.value;
1446
+ if (typeof text === "number") text = String(text);
1447
+ let needsQuoting = false;
1451
1448
 
1452
- if (key === "style" || key === "class") {
1453
- text = trimWhitespace(text);
1454
- if (key === "style") {
1455
- text = text.replace(/; /g, ";").replace(/: /g, ":");
1456
- }
1449
+ if (key === "style" || key === "class") {
1450
+ text = trimWhitespace(text);
1451
+ if (key === "style") {
1452
+ text = text.replace(/; /g, ";").replace(/: /g, ":");
1457
1453
  }
1454
+ }
1458
1455
 
1459
- if (!text.length) {
1460
- needsSpacing = false;
1461
- results.template += `=""`;
1462
- return;
1463
- }
1456
+ if (!text.length) {
1457
+ needsSpacing = false;
1458
+ results.template += `=""`;
1459
+ return;
1460
+ }
1464
1461
 
1465
- for (let i = 0, len = text.length; i < len; i++) {
1466
- let char = text[i];
1467
-
1468
- if (
1469
- char === "'" ||
1470
- char === '"' ||
1471
- char === " " ||
1472
- char === "\t" ||
1473
- char === "\n" ||
1474
- char === "\r" ||
1475
- char === "`" ||
1476
- char === "=" ||
1477
- char === "<" ||
1478
- char === ">"
1479
- ) {
1480
- needsQuoting = true;
1481
- }
1482
- }
1462
+ for (let i = 0, len = text.length; i < len; i++) {
1463
+ let char = text[i];
1483
1464
 
1484
- if (needsQuoting) {
1485
- needsSpacing = false;
1486
- results.template += `="${escapeHTML(text, true)}"`;
1487
- } else {
1488
- needsSpacing = true;
1489
- results.template += `=${escapeHTML(text, true)}`;
1465
+ if (
1466
+ char === "'" ||
1467
+ char === '"' ||
1468
+ char === " " ||
1469
+ char === "\t" ||
1470
+ char === "\n" ||
1471
+ char === "\r" ||
1472
+ char === "`" ||
1473
+ char === "=" ||
1474
+ char === "<" ||
1475
+ char === ">")
1476
+ {
1477
+ needsQuoting = true;
1490
1478
  }
1491
1479
  }
1480
+
1481
+ if (needsQuoting) {
1482
+ needsSpacing = false;
1483
+ results.template += `="${escapeHTML(text, true)}"`;
1484
+ } else {
1485
+ needsSpacing = true;
1486
+ results.template += `=${escapeHTML(text, true)}`;
1487
+ }
1492
1488
  }
1493
- });
1489
+ }
1490
+ });
1494
1491
  if (!hasChildren && children) {
1495
1492
  path.node.children.push(children);
1496
1493
  }
@@ -1505,11 +1502,11 @@ function findLastElement(children, hydratable) {
1505
1502
  for (let i = children.length - 1; i >= 0; i--) {
1506
1503
  const node = children[i].node;
1507
1504
  if (
1508
- hydratable ||
1509
- t__namespace.isJSXText(node) ||
1510
- getStaticExpression(children[i]) !== false ||
1511
- (t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && !isComponent(tagName))
1512
- ) {
1505
+ hydratable ||
1506
+ t__namespace.isJSXText(node) ||
1507
+ getStaticExpression(children[i]) !== false ||
1508
+ t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && !isComponent(tagName))
1509
+ {
1513
1510
  lastElement = i;
1514
1511
  break;
1515
1512
  }
@@ -1528,8 +1525,8 @@ function transformChildren$2(path, results, config) {
1528
1525
  childNodes = filteredChildren.reduce((memo, child, index) => {
1529
1526
  if (child.isJSXFragment()) {
1530
1527
  throw new Error(
1531
- `Fragments can only be used top level in JSX. Not used under a <${tagName}>.`
1532
- );
1528
+ `Fragments can only be used top level in JSX. Not used under a <${tagName}>.`);
1529
+
1533
1530
  }
1534
1531
  const transformed = transformNode(child, {
1535
1532
  toBeClosed: results.toBeClosed,
@@ -1556,20 +1553,20 @@ function transformChildren$2(path, results, config) {
1556
1553
  if (child.tagName === "head") {
1557
1554
  if (config.hydratable) {
1558
1555
  const createComponent = registerImportMethod(
1559
- path,
1560
- "createComponent",
1561
- getRendererConfig(path, "dom").moduleName
1562
- );
1556
+ path,
1557
+ "createComponent",
1558
+ getRendererConfig(path, "dom").moduleName);
1559
+
1563
1560
  const NoHydration = registerImportMethod(
1564
- path,
1565
- "NoHydration",
1566
- getRendererConfig(path, "dom").moduleName
1567
- );
1568
- results.exprs.push(
1569
- t__namespace.expressionStatement(
1570
- t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])
1571
- )
1572
- );
1561
+ path,
1562
+ "NoHydration",
1563
+ getRendererConfig(path, "dom").moduleName);
1564
+
1565
+ results.exprs.push(
1566
+ t__namespace.expressionStatement(
1567
+ t__namespace.callExpression(createComponent, [NoHydration, t__namespace.objectExpression([])])));
1568
+
1569
+
1573
1570
  }
1574
1571
  return;
1575
1572
  }
@@ -1577,23 +1574,23 @@ function transformChildren$2(path, results, config) {
1577
1574
  let getNextMatch;
1578
1575
  if (config.hydratable && tagName === "html") {
1579
1576
  getNextMatch = registerImportMethod(
1580
- path,
1581
- "getNextMatch",
1582
- getRendererConfig(path, "dom").moduleName
1583
- );
1577
+ path,
1578
+ "getNextMatch",
1579
+ getRendererConfig(path, "dom").moduleName);
1580
+
1584
1581
  }
1585
1582
  const walk = t__namespace.memberExpression(
1586
- t__namespace.identifier(tempPath),
1587
- t__namespace.identifier(i === 0 ? "firstChild" : "nextSibling")
1588
- );
1583
+ t__namespace.identifier(tempPath),
1584
+ t__namespace.identifier(i === 0 ? "firstChild" : "nextSibling"));
1585
+
1589
1586
  results.declarations.push(
1590
- t__namespace.variableDeclarator(
1591
- child.id,
1592
- config.hydratable && tagName === "html"
1593
- ? t__namespace.callExpression(getNextMatch, [walk, t__namespace.stringLiteral(child.tagName)])
1594
- : walk
1595
- )
1596
- );
1587
+ t__namespace.variableDeclarator(
1588
+ child.id,
1589
+ config.hydratable && tagName === "html" ?
1590
+ t__namespace.callExpression(getNextMatch, [walk, t__namespace.stringLiteral(child.tagName)]) :
1591
+ walk));
1592
+
1593
+
1597
1594
  results.declarations.push(...child.declarations);
1598
1595
  results.exprs.push(...child.exprs);
1599
1596
  results.dynamics.push(...child.dynamics);
@@ -1618,30 +1615,30 @@ function transformChildren$2(path, results, config) {
1618
1615
  }
1619
1616
  if (!markers) nextPlaceholder = exprId;
1620
1617
  results.exprs.push(
1621
- t__namespace.expressionStatement(
1622
- t__namespace.callExpression(
1623
- insert,
1624
- contentId
1625
- ? [results.id, child.exprs[0], exprId, contentId]
1626
- : [results.id, child.exprs[0], exprId]
1627
- )
1628
- )
1629
- );
1618
+ t__namespace.expressionStatement(
1619
+ t__namespace.callExpression(
1620
+ insert,
1621
+ contentId ?
1622
+ [results.id, child.exprs[0], exprId, contentId] :
1623
+ [results.id, child.exprs[0], exprId])));
1624
+
1625
+
1626
+
1630
1627
  tempPath = exprId.name;
1631
1628
  } else if (multi) {
1632
1629
  results.exprs.push(
1633
- t__namespace.expressionStatement(
1634
- t__namespace.callExpression(insert, [
1635
- results.id,
1636
- child.exprs[0],
1637
- nextChild$1(childNodes, index) || t__namespace.nullLiteral()
1638
- ])
1639
- )
1640
- );
1630
+ t__namespace.expressionStatement(
1631
+ t__namespace.callExpression(insert, [
1632
+ results.id,
1633
+ child.exprs[0],
1634
+ nextChild$1(childNodes, index) || t__namespace.nullLiteral()])));
1635
+
1636
+
1637
+
1641
1638
  } else {
1642
1639
  results.exprs.push(
1643
- t__namespace.expressionStatement(t__namespace.callExpression(insert, [results.id, child.exprs[0]]))
1644
- );
1640
+ t__namespace.expressionStatement(t__namespace.callExpression(insert, [results.id, child.exprs[0]])));
1641
+
1645
1642
  }
1646
1643
  } else nextPlaceholder = null;
1647
1644
  });
@@ -1656,24 +1653,24 @@ function createPlaceholder(path, results, tempPath, i, char) {
1656
1653
  if (config.hydratable && char === "/") {
1657
1654
  contentId = path.scope.generateUidIdentifier("co$");
1658
1655
  results.declarations.push(
1659
- t__namespace.variableDeclarator(
1660
- t__namespace.arrayPattern([exprId, contentId]),
1661
- t__namespace.callExpression(
1662
- registerImportMethod(path, "getNextMarker", getRendererConfig(path, "dom").moduleName),
1663
- [t__namespace.memberExpression(t__namespace.identifier(tempPath), t__namespace.identifier("nextSibling"))]
1664
- )
1665
- )
1666
- );
1656
+ t__namespace.variableDeclarator(
1657
+ t__namespace.arrayPattern([exprId, contentId]),
1658
+ t__namespace.callExpression(
1659
+ registerImportMethod(path, "getNextMarker", getRendererConfig(path, "dom").moduleName),
1660
+ [t__namespace.memberExpression(t__namespace.identifier(tempPath), t__namespace.identifier("nextSibling"))])));
1661
+
1662
+
1663
+
1667
1664
  } else
1668
- results.declarations.push(
1669
- t__namespace.variableDeclarator(
1670
- exprId,
1671
- t__namespace.memberExpression(
1672
- t__namespace.identifier(tempPath),
1673
- t__namespace.identifier(i === 0 ? "firstChild" : "nextSibling")
1674
- )
1675
- )
1676
- );
1665
+ results.declarations.push(
1666
+ t__namespace.variableDeclarator(
1667
+ exprId,
1668
+ t__namespace.memberExpression(
1669
+ t__namespace.identifier(tempPath),
1670
+ t__namespace.identifier(i === 0 ? "firstChild" : "nextSibling"))));
1671
+
1672
+
1673
+
1677
1674
  return [exprId, contentId];
1678
1675
  }
1679
1676
 
@@ -1686,11 +1683,11 @@ function detectExpressions(children, index, config) {
1686
1683
  if (children[index - 1]) {
1687
1684
  const node = children[index - 1].node;
1688
1685
  if (
1689
- t__namespace.isJSXExpressionContainer(node) &&
1690
- !t__namespace.isJSXEmptyExpression(node.expression) &&
1691
- getStaticExpression(children[index - 1]) === false
1692
- )
1693
- return true;
1686
+ t__namespace.isJSXExpressionContainer(node) &&
1687
+ !t__namespace.isJSXEmptyExpression(node.expression) &&
1688
+ getStaticExpression(children[index - 1]) === false)
1689
+
1690
+ return true;
1694
1691
  let tagName;
1695
1692
  if (t__namespace.isJSXElement(node) && (tagName = getTagName(node)) && isComponent(tagName)) return true;
1696
1693
  }
@@ -1698,26 +1695,26 @@ function detectExpressions(children, index, config) {
1698
1695
  const child = children[i].node;
1699
1696
  if (t__namespace.isJSXExpressionContainer(child)) {
1700
1697
  if (!t__namespace.isJSXEmptyExpression(child.expression) && getStaticExpression(children[i]) === false)
1701
- return true;
1698
+ return true;
1702
1699
  } else if (t__namespace.isJSXElement(child)) {
1703
1700
  const tagName = getTagName(child);
1704
1701
  if (isComponent(tagName)) return true;
1705
1702
  if (config.contextToCustomElements && (tagName === "slot" || tagName.indexOf("-") > -1))
1706
- return true;
1703
+ return true;
1707
1704
  if (
1708
- child.openingElement.attributes.some(
1709
- attr =>
1710
- t__namespace.isJSXSpreadAttribute(attr) ||
1711
- ["textContent", "innerHTML", "innerText"].includes(attr.name.name) ||
1712
- (attr.name.namespace && attr.name.namespace.name === "use") ||
1713
- (t__namespace.isJSXExpressionContainer(attr.value) &&
1714
- !(
1715
- t__namespace.isStringLiteral(attr.value.expression) ||
1716
- t__namespace.isNumericLiteral(attr.value.expression)
1717
- ))
1718
- )
1719
- )
1720
- return true;
1705
+ child.openingElement.attributes.some(
1706
+ (attr) =>
1707
+ t__namespace.isJSXSpreadAttribute(attr) ||
1708
+ ["textContent", "innerHTML", "innerText"].includes(attr.name.name) ||
1709
+ attr.name.namespace && attr.name.namespace.name === "use" ||
1710
+ t__namespace.isJSXExpressionContainer(attr.value) &&
1711
+ !(
1712
+ t__namespace.isStringLiteral(attr.value.expression) ||
1713
+ t__namespace.isNumericLiteral(attr.value.expression))))
1714
+
1715
+
1716
+
1717
+ return true;
1721
1718
  const nextChildren = filterChildren(children[i].get("children"));
1722
1719
  if (nextChildren.length) if (detectExpressions(nextChildren, 0, config)) return true;
1723
1720
  }
@@ -1726,17 +1723,17 @@ function detectExpressions(children, index, config) {
1726
1723
 
1727
1724
  function contextToCustomElement(path, results) {
1728
1725
  results.exprs.push(
1729
- t__namespace.expressionStatement(
1730
- t__namespace.assignmentExpression(
1731
- "=",
1732
- t__namespace.memberExpression(results.id, t__namespace.identifier("_$owner")),
1733
- t__namespace.callExpression(
1734
- registerImportMethod(path, "getOwner", getRendererConfig(path, "dom").moduleName),
1735
- []
1736
- )
1737
- )
1738
- )
1739
- );
1726
+ t__namespace.expressionStatement(
1727
+ t__namespace.assignmentExpression(
1728
+ "=",
1729
+ t__namespace.memberExpression(results.id, t__namespace.identifier("_$owner")),
1730
+ t__namespace.callExpression(
1731
+ registerImportMethod(path, "getOwner", getRendererConfig(path, "dom").moduleName),
1732
+ []))));
1733
+
1734
+
1735
+
1736
+
1740
1737
  }
1741
1738
 
1742
1739
  function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapConditionals }) {
@@ -1746,13 +1743,13 @@ function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapCond
1746
1743
  let runningObject = [];
1747
1744
  let dynamicSpread = false;
1748
1745
  let firstSpread = false;
1749
- attributes.forEach(attribute => {
1746
+ attributes.forEach((attribute) => {
1750
1747
  const node = attribute.node;
1751
1748
  const key =
1752
- !t__namespace.isJSXSpreadAttribute(node) &&
1753
- (t__namespace.isJSXNamespacedName(node.name)
1754
- ? `${node.name.namespace.name}:${node.name.name.name}`
1755
- : node.name.name);
1749
+ !t__namespace.isJSXSpreadAttribute(node) && (
1750
+ t__namespace.isJSXNamespacedName(node.name) ?
1751
+ `${node.name.namespace.name}:${node.name.name.name}` :
1752
+ node.name.name);
1756
1753
  if (t__namespace.isJSXSpreadAttribute(node)) {
1757
1754
  firstSpread = true;
1758
1755
  if (runningObject.length) {
@@ -1760,52 +1757,52 @@ function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapCond
1760
1757
  runningObject = [];
1761
1758
  }
1762
1759
  spreadArgs.push(
1763
- isDynamic(attribute.get("argument"), {
1764
- checkMember: true
1765
- }) && (dynamicSpread = true)
1766
- ? t__namespace.isCallExpression(node.argument) &&
1767
- !node.argument.arguments.length &&
1768
- !t__namespace.isCallExpression(node.argument.callee) &&
1769
- !t__namespace.isMemberExpression(node.argument.callee)
1770
- ? node.argument.callee
1771
- : t__namespace.arrowFunctionExpression([], node.argument)
1772
- : node.argument
1773
- );
1760
+ isDynamic(attribute.get("argument"), {
1761
+ checkMember: true
1762
+ }) && (dynamicSpread = true) ?
1763
+ t__namespace.isCallExpression(node.argument) &&
1764
+ !node.argument.arguments.length &&
1765
+ !t__namespace.isCallExpression(node.argument.callee) &&
1766
+ !t__namespace.isMemberExpression(node.argument.callee) ?
1767
+ node.argument.callee :
1768
+ t__namespace.arrowFunctionExpression([], node.argument) :
1769
+ node.argument);
1770
+
1774
1771
  } else if (
1775
- (firstSpread ||
1776
- (t__namespace.isJSXExpressionContainer(node.value) &&
1777
- isDynamic(attribute.get("value").get("expression"), { checkMember: true }))) &&
1778
- canNativeSpread(key, { checkNameSpaces: true })
1779
- ) {
1772
+ (firstSpread ||
1773
+ t__namespace.isJSXExpressionContainer(node.value) &&
1774
+ isDynamic(attribute.get("value").get("expression"), { checkMember: true })) &&
1775
+ canNativeSpread(key, { checkNameSpaces: true }))
1776
+ {
1780
1777
  const isContainer = t__namespace.isJSXExpressionContainer(node.value);
1781
1778
  const dynamic =
1782
- isContainer && isDynamic(attribute.get("value").get("expression"), { checkMember: true });
1779
+ isContainer && isDynamic(attribute.get("value").get("expression"), { checkMember: true });
1783
1780
  if (dynamic) {
1784
1781
  const id = convertJSXIdentifier(node.name);
1785
1782
  let expr =
1786
- wrapConditionals &&
1787
- (t__namespace.isLogicalExpression(node.value.expression) ||
1788
- t__namespace.isConditionalExpression(node.value.expression))
1789
- ? transformCondition(attribute.get("value").get("expression"), true)
1790
- : t__namespace.arrowFunctionExpression([], node.value.expression);
1783
+ wrapConditionals && (
1784
+ t__namespace.isLogicalExpression(node.value.expression) ||
1785
+ t__namespace.isConditionalExpression(node.value.expression)) ?
1786
+ transformCondition(attribute.get("value").get("expression"), true) :
1787
+ t__namespace.arrowFunctionExpression([], node.value.expression);
1791
1788
  runningObject.push(
1792
- t__namespace.objectMethod(
1793
- "get",
1794
- id,
1795
- [],
1796
- t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
1797
- !t__namespace.isValidIdentifier(key)
1798
- )
1799
- );
1789
+ t__namespace.objectMethod(
1790
+ "get",
1791
+ id,
1792
+ [],
1793
+ t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
1794
+ !t__namespace.isValidIdentifier(key)));
1795
+
1796
+
1800
1797
  } else {
1801
1798
  runningObject.push(
1802
- t__namespace.objectProperty(
1803
- t__namespace.stringLiteral(key),
1804
- isContainer
1805
- ? node.value.expression
1806
- : node.value || (Properties.has(key) ? t__namespace.booleanLiteral(true) : t__namespace.stringLiteral(""))
1807
- )
1808
- );
1799
+ t__namespace.objectProperty(
1800
+ t__namespace.stringLiteral(key),
1801
+ isContainer ?
1802
+ node.value.expression :
1803
+ node.value || (Properties.has(key) ? t__namespace.booleanLiteral(true) : t__namespace.stringLiteral(""))));
1804
+
1805
+
1809
1806
  }
1810
1807
  } else filteredAttributes.push(attribute);
1811
1808
  });
@@ -1815,19 +1812,19 @@ function processSpreads$1(path, attributes, { elem, isSVG, hasChildren, wrapCond
1815
1812
  }
1816
1813
 
1817
1814
  const props =
1818
- spreadArgs.length === 1 && !dynamicSpread
1819
- ? spreadArgs[0]
1820
- : t__namespace.callExpression(registerImportMethod(path, "mergeProps"), spreadArgs);
1815
+ spreadArgs.length === 1 && !dynamicSpread ?
1816
+ spreadArgs[0] :
1817
+ t__namespace.callExpression(registerImportMethod(path, "mergeProps"), spreadArgs);
1821
1818
 
1822
1819
  return [
1823
- filteredAttributes,
1824
- t__namespace.expressionStatement(
1825
- t__namespace.callExpression(
1826
- registerImportMethod(path, "spread", getRendererConfig(path, "dom").moduleName),
1827
- [elem, props, t__namespace.booleanLiteral(isSVG), t__namespace.booleanLiteral(hasChildren)]
1828
- )
1829
- )
1830
- ];
1820
+ filteredAttributes,
1821
+ t__namespace.expressionStatement(
1822
+ t__namespace.callExpression(
1823
+ registerImportMethod(path, "spread", getRendererConfig(path, "dom").moduleName),
1824
+ [elem, props, t__namespace.booleanLiteral(isSVG), t__namespace.booleanLiteral(hasChildren)]))];
1825
+
1826
+
1827
+
1831
1828
  }
1832
1829
 
1833
1830
  function createTemplate$2(path, result, wrap) {
@@ -1835,25 +1832,25 @@ function createTemplate$2(path, result, wrap) {
1835
1832
  if (result.id) {
1836
1833
  registerTemplate(path, result);
1837
1834
  if (
1838
- !(result.exprs.length || result.dynamics.length || result.postExprs.length) &&
1839
- result.decl.declarations.length === 1
1840
- ) {
1835
+ !(result.exprs.length || result.dynamics.length || result.postExprs.length) &&
1836
+ result.decl.declarations.length === 1)
1837
+ {
1841
1838
  return result.decl.declarations[0].init;
1842
1839
  } else {
1843
1840
  return t__namespace.callExpression(
1844
- t__namespace.arrowFunctionExpression(
1845
- [],
1846
- t__namespace.blockStatement([
1847
- result.decl,
1848
- ...result.exprs.concat(
1849
- wrapDynamics$1(path, result.dynamics) || [],
1850
- result.postExprs || []
1851
- ),
1852
- t__namespace.returnStatement(result.id)
1853
- ])
1854
- ),
1855
- []
1856
- );
1841
+ t__namespace.arrowFunctionExpression(
1842
+ [],
1843
+ t__namespace.blockStatement([
1844
+ result.decl,
1845
+ ...result.exprs.concat(
1846
+ wrapDynamics$1(path, result.dynamics) || [],
1847
+ result.postExprs || []),
1848
+
1849
+ t__namespace.returnStatement(result.id)])),
1850
+
1851
+
1852
+ []);
1853
+
1857
1854
  }
1858
1855
  }
1859
1856
  if (wrap && result.dynamic && config.memoWrapper) {
@@ -1863,26 +1860,26 @@ function createTemplate$2(path, result, wrap) {
1863
1860
  }
1864
1861
 
1865
1862
  function appendTemplates$1(path, templates) {
1866
- const declarators = templates.map(template => {
1863
+ const declarators = templates.map((template) => {
1867
1864
  const tmpl = {
1868
1865
  cooked: template.template,
1869
1866
  raw: escapeStringForTemplate(template.template)
1870
1867
  };
1871
1868
  return t__namespace.variableDeclarator(
1872
- template.id,
1873
- t__namespace.addComment(
1874
- t__namespace.callExpression(
1875
- registerImportMethod(path, "template", getRendererConfig(path, "dom").moduleName),
1876
- [t__namespace.templateLiteral([t__namespace.templateElement(tmpl, true)], [])].concat(
1877
- template.isSVG || template.isCE
1878
- ? [t__namespace.booleanLiteral(template.isCE), t__namespace.booleanLiteral(template.isSVG)]
1879
- : []
1880
- )
1881
- ),
1882
- "leading",
1883
- "#__PURE__"
1884
- )
1885
- );
1869
+ template.id,
1870
+ t__namespace.addComment(
1871
+ t__namespace.callExpression(
1872
+ registerImportMethod(path, "template", getRendererConfig(path, "dom").moduleName),
1873
+ [t__namespace.templateLiteral([t__namespace.templateElement(tmpl, true)], [])].concat(
1874
+ template.isSVG || template.isCE ?
1875
+ [t__namespace.booleanLiteral(template.isCE), t__namespace.booleanLiteral(template.isSVG)] :
1876
+ [])),
1877
+
1878
+
1879
+ "leading",
1880
+ "#__PURE__"));
1881
+
1882
+
1886
1883
  });
1887
1884
  path.node.body.unshift(t__namespace.variableDeclaration("var", declarators));
1888
1885
  }
@@ -1894,9 +1891,9 @@ function registerTemplate(path, results) {
1894
1891
  let templateDef, templateId;
1895
1892
  if (!results.skipTemplate) {
1896
1893
  const templates =
1897
- path.scope.getProgramParent().data.templates ||
1898
- (path.scope.getProgramParent().data.templates = []);
1899
- if ((templateDef = templates.find(t => t.template === results.template))) {
1894
+ path.scope.getProgramParent().data.templates || (
1895
+ path.scope.getProgramParent().data.templates = []);
1896
+ if (templateDef = templates.find((t) => t.template === results.template)) {
1900
1897
  templateId = templateDef.id;
1901
1898
  } else {
1902
1899
  templateId = path.scope.generateUidIdentifier("tmpl$");
@@ -1910,14 +1907,14 @@ function registerTemplate(path, results) {
1910
1907
  }
1911
1908
  }
1912
1909
  decl = t__namespace.variableDeclarator(
1913
- results.id,
1914
- hydratable
1915
- ? t__namespace.callExpression(
1916
- registerImportMethod(path, "getNextElement", getRendererConfig(path, "dom").moduleName),
1917
- templateId ? [templateId] : []
1918
- )
1919
- : t__namespace.callExpression(templateId, [])
1920
- );
1910
+ results.id,
1911
+ hydratable ?
1912
+ t__namespace.callExpression(
1913
+ registerImportMethod(path, "getNextElement", getRendererConfig(path, "dom").moduleName),
1914
+ templateId ? [templateId] : []) :
1915
+
1916
+ t__namespace.callExpression(templateId, []));
1917
+
1921
1918
  }
1922
1919
  results.declarations.unshift(decl);
1923
1920
  results.decl = t__namespace.variableDeclaration("var", results.declarations);
@@ -1932,35 +1929,35 @@ function wrapDynamics$1(path, dynamics) {
1932
1929
  if (dynamics.length === 1) {
1933
1930
  let dynamicStyle;
1934
1931
  const prevValue =
1935
- dynamics[0].key === "classList" ||
1936
- dynamics[0].key === "style" ||
1937
- (dynamicStyle = dynamics[0].key.startsWith("style:"))
1938
- ? t__namespace.identifier("_$p")
1939
- : undefined;
1932
+ dynamics[0].key === "classList" ||
1933
+ dynamics[0].key === "style" || (
1934
+ dynamicStyle = dynamics[0].key.startsWith("style:")) ?
1935
+ t__namespace.identifier("_$p") :
1936
+ undefined;
1940
1937
  if (dynamicStyle) {
1941
1938
  dynamics[0].value = t__namespace.assignmentExpression("=", prevValue, dynamics[0].value);
1942
1939
  } else if (
1943
- dynamics[0].key.startsWith("class:") &&
1944
- !t__namespace.isBooleanLiteral(dynamics[0].value) &&
1945
- !t__namespace.isUnaryExpression(dynamics[0].value)
1946
- ) {
1940
+ dynamics[0].key.startsWith("class:") &&
1941
+ !t__namespace.isBooleanLiteral(dynamics[0].value) &&
1942
+ !t__namespace.isUnaryExpression(dynamics[0].value))
1943
+ {
1947
1944
  dynamics[0].value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", dynamics[0].value));
1948
1945
  }
1949
1946
 
1950
1947
  return t__namespace.expressionStatement(
1951
- t__namespace.callExpression(effectWrapperId, [
1952
- t__namespace.arrowFunctionExpression(
1953
- prevValue ? [prevValue] : [],
1954
- setAttr$2(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
1955
- isSVG: dynamics[0].isSVG,
1956
- isCE: dynamics[0].isCE,
1957
- tagName: dynamics[0].tagName,
1958
- dynamic: true,
1959
- prevId: prevValue
1960
- })
1961
- )
1962
- ])
1963
- );
1948
+ t__namespace.callExpression(effectWrapperId, [
1949
+ t__namespace.arrowFunctionExpression(
1950
+ prevValue ? [prevValue] : [],
1951
+ setAttr$2(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
1952
+ isSVG: dynamics[0].isSVG,
1953
+ isCE: dynamics[0].isCE,
1954
+ tagName: dynamics[0].tagName,
1955
+ dynamic: true,
1956
+ prevId: prevValue
1957
+ }))]));
1958
+
1959
+
1960
+
1964
1961
  }
1965
1962
 
1966
1963
  const prevId = t__namespace.identifier("_p$");
@@ -1979,10 +1976,10 @@ function wrapDynamics$1(path, dynamics) {
1979
1976
  const propMember = t__namespace.memberExpression(prevId, propIdent);
1980
1977
 
1981
1978
  if (
1982
- key.startsWith("class:") &&
1983
- !t__namespace.isBooleanLiteral(value) &&
1984
- !t__namespace.isUnaryExpression(value)
1985
- ) {
1979
+ key.startsWith("class:") &&
1980
+ !t__namespace.isBooleanLiteral(value) &&
1981
+ !t__namespace.isUnaryExpression(value))
1982
+ {
1986
1983
  value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value));
1987
1984
  }
1988
1985
 
@@ -1991,55 +1988,55 @@ function wrapDynamics$1(path, dynamics) {
1991
1988
 
1992
1989
  if (key === "classList" || key === "style") {
1993
1990
  statements.push(
1994
- t__namespace.expressionStatement(
1995
- t__namespace.assignmentExpression(
1996
- "=",
1997
- propMember,
1998
- setAttr$2(path, elem, key, varIdent, {
1999
- isSVG,
2000
- isCE,
2001
- tagName,
2002
- dynamic: true,
2003
- prevId: propMember,
2004
- }),
2005
- ),
2006
- ),
2007
- );
1991
+ t__namespace.expressionStatement(
1992
+ t__namespace.assignmentExpression(
1993
+ "=",
1994
+ propMember,
1995
+ setAttr$2(path, elem, key, varIdent, {
1996
+ isSVG,
1997
+ isCE,
1998
+ tagName,
1999
+ dynamic: true,
2000
+ prevId: propMember
2001
+ }))));
2002
+
2003
+
2004
+
2008
2005
  } else {
2009
2006
  const prev = key.startsWith("style:") ? varIdent : undefined;
2010
2007
  statements.push(
2011
- t__namespace.expressionStatement(
2012
- t__namespace.logicalExpression(
2013
- "&&",
2014
- t__namespace.binaryExpression("!==", varIdent, propMember),
2015
- setAttr$2(
2016
- path,
2017
- elem,
2018
- key,
2019
- t__namespace.assignmentExpression("=", propMember, varIdent),
2020
- { isSVG, isCE, tagName, dynamic: true, prevId: prev },
2021
- ),
2022
- ),
2023
- ),
2024
- );
2008
+ t__namespace.expressionStatement(
2009
+ t__namespace.logicalExpression(
2010
+ "&&",
2011
+ t__namespace.binaryExpression("!==", varIdent, propMember),
2012
+ setAttr$2(
2013
+ path,
2014
+ elem,
2015
+ key,
2016
+ t__namespace.assignmentExpression("=", propMember, varIdent),
2017
+ { isSVG, isCE, tagName, dynamic: true, prevId: prev }))));
2018
+
2019
+
2020
+
2021
+
2025
2022
  }
2026
2023
  });
2027
2024
 
2028
2025
  return t__namespace.expressionStatement(
2029
- t__namespace.callExpression(effectWrapperId, [
2030
- t__namespace.arrowFunctionExpression(
2031
- [prevId],
2032
- t__namespace.blockStatement([
2033
- t__namespace.variableDeclaration("var", declarations),
2034
- ...statements,
2035
- t__namespace.returnStatement(prevId),
2036
- ]),
2037
- ),
2038
- t__namespace.objectExpression(
2039
- properties.map((id) => t__namespace.objectProperty(id, t__namespace.identifier("undefined"))),
2040
- ),
2041
- ]),
2042
- );
2026
+ t__namespace.callExpression(effectWrapperId, [
2027
+ t__namespace.arrowFunctionExpression(
2028
+ [prevId],
2029
+ t__namespace.blockStatement([
2030
+ t__namespace.variableDeclaration("var", declarations),
2031
+ ...statements,
2032
+ t__namespace.returnStatement(prevId)])),
2033
+
2034
+
2035
+ t__namespace.objectExpression(
2036
+ properties.map((id) => t__namespace.objectProperty(id, t__namespace.identifier("undefined"))))]));
2037
+
2038
+
2039
+
2043
2040
  }
2044
2041
 
2045
2042
  function createTemplate$1(path, result) {
@@ -2054,18 +2051,18 @@ function createTemplate$1(path, result) {
2054
2051
  } else if (result.template.length === 1) {
2055
2052
  template = t__namespace.stringLiteral(result.template[0]);
2056
2053
  } else {
2057
- const strings = result.template.map(tmpl => t__namespace.stringLiteral(tmpl));
2054
+ const strings = result.template.map((tmpl) => t__namespace.stringLiteral(tmpl));
2058
2055
  template = t__namespace.arrayExpression(strings);
2059
2056
  }
2060
2057
 
2061
2058
  const templates =
2062
- path.scope.getProgramParent().data.templates ||
2063
- (path.scope.getProgramParent().data.templates = []);
2064
- const found = templates.find(tmp => {
2059
+ path.scope.getProgramParent().data.templates || (
2060
+ path.scope.getProgramParent().data.templates = []);
2061
+ const found = templates.find((tmp) => {
2065
2062
  if (t__namespace.isArrayExpression(tmp.template) && t__namespace.isArrayExpression(template)) {
2066
2063
  return tmp.template.elements.every(
2067
- (el, i) => template.elements[i] && el.value === template.elements[i].value
2068
- );
2064
+ (el, i) => template.elements[i] && el.value === template.elements[i].value);
2065
+
2069
2066
  }
2070
2067
  return tmp.template.value === template.value;
2071
2068
  });
@@ -2079,35 +2076,35 @@ function createTemplate$1(path, result) {
2079
2076
  } else id = found.id;
2080
2077
 
2081
2078
  if (result.wontEscape) {
2082
- if (!Array.isArray(result.template) || result.template.length === 1) return id;
2083
- else if (
2084
- Array.isArray(result.template) &&
2085
- result.template.length === 2 &&
2086
- result.templateValues[0].type === "CallExpression" &&
2087
- result.templateValues[0].callee.name === "_$ssrHydrationKey"
2088
- ) {
2079
+ if (!Array.isArray(result.template) || result.template.length === 1) return id;else
2080
+ if (
2081
+ Array.isArray(result.template) &&
2082
+ result.template.length === 2 &&
2083
+ result.templateValues[0].type === "CallExpression" &&
2084
+ result.templateValues[0].callee.name === "_$ssrHydrationKey")
2085
+ {
2089
2086
  // remove unnecessary ssr call when only hydration key is used
2090
2087
  return t__namespace.binaryExpression(
2091
- "+",
2092
- t__namespace.binaryExpression(
2093
- "+",
2094
- t__namespace.memberExpression(id, t__namespace.numericLiteral(0), true),
2095
- result.templateValues[0]
2096
- ),
2097
- t__namespace.memberExpression(id, t__namespace.numericLiteral(1), true)
2098
- );
2088
+ "+",
2089
+ t__namespace.binaryExpression(
2090
+ "+",
2091
+ t__namespace.memberExpression(id, t__namespace.numericLiteral(0), true),
2092
+ result.templateValues[0]),
2093
+
2094
+ t__namespace.memberExpression(id, t__namespace.numericLiteral(1), true));
2095
+
2099
2096
  }
2100
2097
  }
2101
2098
  return t__namespace.callExpression(
2102
- registerImportMethod(path, "ssr"),
2103
- Array.isArray(result.template) && result.template.length > 1
2104
- ? [id, ...result.templateValues]
2105
- : [id]
2106
- );
2099
+ registerImportMethod(path, "ssr"),
2100
+ Array.isArray(result.template) && result.template.length > 1 ?
2101
+ [id, ...result.templateValues] :
2102
+ [id]);
2103
+
2107
2104
  }
2108
2105
 
2109
2106
  function appendTemplates(path, templates) {
2110
- const declarators = templates.map(template => {
2107
+ const declarators = templates.map((template) => {
2111
2108
  return t__namespace.variableDeclarator(template.id, template.template);
2112
2109
  });
2113
2110
  path.node.body.unshift(t__namespace.variableDeclaration("var", declarators));
@@ -2125,8 +2122,8 @@ function appendToTemplate(template, value) {
2125
2122
  function transformElement$2(path, info) {
2126
2123
  const config = getConfig(path);
2127
2124
  // contains spread attributes
2128
- if (path.node.openingElement.attributes.some(a => t__namespace.isJSXSpreadAttribute(a)))
2129
- return createElement(path, { ...info, ...config });
2125
+ if (path.node.openingElement.attributes.some((a) => t__namespace.isJSXSpreadAttribute(a)))
2126
+ return createElement(path, { ...info, ...config });
2130
2127
 
2131
2128
  const tagName = getTagName(path.node),
2132
2129
  voidTag = VoidElements.indexOf(tagName) > -1,
@@ -2149,24 +2146,24 @@ function transformElement$2(path, info) {
2149
2146
  const child = transformElement$2(path, { ...info, topLevel: false });
2150
2147
  results.template = "";
2151
2148
  results.exprs.push(
2152
- t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
2153
- t__namespace.identifier("_$NoHydration"),
2154
- t__namespace.objectExpression([
2155
- t__namespace.objectMethod(
2156
- "get",
2157
- t__namespace.identifier("children"),
2158
- [],
2159
- t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))])
2160
- )
2161
- ])
2162
- ])
2163
- );
2149
+ t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
2150
+ t__namespace.identifier("_$NoHydration"),
2151
+ t__namespace.objectExpression([
2152
+ t__namespace.objectMethod(
2153
+ "get",
2154
+ t__namespace.identifier("children"),
2155
+ [],
2156
+ t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))]))])]));
2157
+
2158
+
2159
+
2160
+
2164
2161
  return results;
2165
2162
  }
2166
2163
  results.template.push("");
2167
2164
  results.templateValues.push(
2168
- t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), [])
2169
- );
2165
+ t__namespace.callExpression(registerImportMethod(path, "ssrHydrationKey"), []));
2166
+
2170
2167
  }
2171
2168
  transformAttributes$1(path, results, { ...config, ...info });
2172
2169
  appendToTemplate(results.template, ">");
@@ -2193,10 +2190,10 @@ function setAttr$1(attribute, results, name, value, isSVG) {
2193
2190
 
2194
2191
  name = toAttribute(name, isSVG);
2195
2192
  const attr = t__namespace.callExpression(registerImportMethod(attribute, "ssrAttribute"), [
2196
- t__namespace.stringLiteral(name),
2197
- value,
2198
- t__namespace.booleanLiteral(false)
2199
- ]);
2193
+ t__namespace.stringLiteral(name),
2194
+ value,
2195
+ t__namespace.booleanLiteral(false)]);
2196
+
2200
2197
  if (results.template[results.template.length - 1].length) {
2201
2198
  results.template.push("");
2202
2199
  results.templateValues.push(attr);
@@ -2208,29 +2205,29 @@ function setAttr$1(attribute, results, name, value, isSVG) {
2208
2205
 
2209
2206
  function escapeExpression(path, expression, attr, escapeLiterals) {
2210
2207
  if (
2211
- t__namespace.isStringLiteral(expression) ||
2212
- t__namespace.isNumericLiteral(expression) ||
2213
- (t__namespace.isTemplateLiteral(expression) && expression.expressions.length === 0)
2214
- ) {
2208
+ t__namespace.isStringLiteral(expression) ||
2209
+ t__namespace.isNumericLiteral(expression) ||
2210
+ t__namespace.isTemplateLiteral(expression) && expression.expressions.length === 0)
2211
+ {
2215
2212
  if (escapeLiterals) {
2216
- if (t__namespace.isStringLiteral(expression)) return t__namespace.stringLiteral(escapeHTML(expression.value, attr));
2217
- else if (t__namespace.isTemplateLiteral(expression))
2218
- return t__namespace.stringLiteral(escapeHTML(expression.quasis[0].value.raw, attr));
2213
+ if (t__namespace.isStringLiteral(expression)) return t__namespace.stringLiteral(escapeHTML(expression.value, attr));else
2214
+ if (t__namespace.isTemplateLiteral(expression))
2215
+ return t__namespace.stringLiteral(escapeHTML(expression.quasis[0].value.raw, attr));
2219
2216
  }
2220
2217
  return expression;
2221
2218
  } else if (t__namespace.isFunction(expression)) {
2222
2219
  if (t__namespace.isBlockStatement(expression.body)) {
2223
- expression.body.body = expression.body.body.map(e => {
2220
+ expression.body.body = expression.body.body.map((e) => {
2224
2221
  if (t__namespace.isReturnStatement(e))
2225
- e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
2222
+ e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
2226
2223
  return e;
2227
2224
  });
2228
2225
  } else expression.body = escapeExpression(path, expression.body, attr, escapeLiterals);
2229
2226
  return expression;
2230
2227
  } else if (t__namespace.isTemplateLiteral(expression)) {
2231
- expression.expressions = expression.expressions.map(e =>
2232
- escapeExpression(path, e, attr, escapeLiterals)
2233
- );
2228
+ expression.expressions = expression.expressions.map((e) =>
2229
+ escapeExpression(path, e, attr, escapeLiterals));
2230
+
2234
2231
  return expression;
2235
2232
  } else if (t__namespace.isUnaryExpression(expression)) {
2236
2233
  return expression;
@@ -2250,13 +2247,13 @@ function escapeExpression(path, expression, attr, escapeLiterals) {
2250
2247
  return expression;
2251
2248
  } else if (t__namespace.isCallExpression(expression) && t__namespace.isFunction(expression.callee)) {
2252
2249
  if (t__namespace.isBlockStatement(expression.callee.body)) {
2253
- expression.callee.body.body = expression.callee.body.body.map(e => {
2250
+ expression.callee.body.body = expression.callee.body.body.map((e) => {
2254
2251
  if (t__namespace.isReturnStatement(e))
2255
- e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
2252
+ e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
2256
2253
  return e;
2257
2254
  });
2258
2255
  } else
2259
- expression.callee.body = escapeExpression(path, expression.callee.body, attr, escapeLiterals);
2256
+ expression.callee.body = escapeExpression(path, expression.callee.body, attr, escapeLiterals);
2260
2257
  return expression;
2261
2258
  } else if (t__namespace.isJSXElement(expression) && !isComponent(getTagName(expression))) {
2262
2259
  expression.wontEscape = true;
@@ -2264,14 +2261,14 @@ function escapeExpression(path, expression, attr, escapeLiterals) {
2264
2261
  }
2265
2262
 
2266
2263
  return t__namespace.callExpression(
2267
- registerImportMethod(path, "escape"),
2268
- [expression].concat(attr ? [t__namespace.booleanLiteral(true)] : [])
2269
- );
2264
+ registerImportMethod(path, "escape"),
2265
+ [expression].concat(attr ? [t__namespace.booleanLiteral(true)] : []));
2266
+
2270
2267
  }
2271
2268
 
2272
2269
  function transformToObject(attrName, attributes, selectedAttributes) {
2273
2270
  const properties = [];
2274
- const existingAttribute = attributes.find(a => a.node.name.name === attrName);
2271
+ const existingAttribute = attributes.find((a) => a.node.name.name === attrName);
2275
2272
  for (let i = 0; i < selectedAttributes.length; i++) {
2276
2273
  const attr = selectedAttributes[i].node;
2277
2274
  const computed = !t__namespace.isValidIdentifier(attr.name.name.name);
@@ -2279,44 +2276,44 @@ function transformToObject(attrName, attributes, selectedAttributes) {
2279
2276
  attr.name.name.type = "Identifier";
2280
2277
  }
2281
2278
  properties.push(
2282
- t__namespace.objectProperty(
2283
- computed ? t__namespace.stringLiteral(attr.name.name.name) : attr.name.name,
2284
- t__namespace.isJSXExpressionContainer(attr.value) ? attr.value.expression : attr.value
2285
- )
2286
- );
2279
+ t__namespace.objectProperty(
2280
+ computed ? t__namespace.stringLiteral(attr.name.name.name) : attr.name.name,
2281
+ t__namespace.isJSXExpressionContainer(attr.value) ? attr.value.expression : attr.value));
2282
+
2283
+
2287
2284
  (existingAttribute || i) && attributes.splice(selectedAttributes[i].key, 1);
2288
2285
  }
2289
2286
  if (
2290
- existingAttribute &&
2291
- t__namespace.isJSXExpressionContainer(existingAttribute.node.value) &&
2292
- t__namespace.isObjectExpression(existingAttribute.node.value.expression)
2293
- ) {
2287
+ existingAttribute &&
2288
+ t__namespace.isJSXExpressionContainer(existingAttribute.node.value) &&
2289
+ t__namespace.isObjectExpression(existingAttribute.node.value.expression))
2290
+ {
2294
2291
  existingAttribute.node.value.expression.properties.push(...properties);
2295
2292
  } else {
2296
2293
  selectedAttributes[0].node = t__namespace.jsxAttribute(
2297
- t__namespace.jsxIdentifier(attrName),
2298
- t__namespace.jsxExpressionContainer(t__namespace.objectExpression(properties))
2299
- );
2294
+ t__namespace.jsxIdentifier(attrName),
2295
+ t__namespace.jsxExpressionContainer(t__namespace.objectExpression(properties)));
2296
+
2300
2297
  }
2301
2298
  }
2302
2299
 
2303
2300
  function normalizeAttributes(path) {
2304
2301
  const attributes = path.get("openingElement").get("attributes"),
2305
2302
  styleAttributes = attributes.filter(
2306
- a => t__namespace.isJSXNamespacedName(a.node.name) && a.node.name.namespace.name === "style"
2307
- ),
2303
+ (a) => t__namespace.isJSXNamespacedName(a.node.name) && a.node.name.namespace.name === "style"),
2304
+
2308
2305
  classNamespaceAttributes = attributes.filter(
2309
- a => t__namespace.isJSXNamespacedName(a.node.name) && a.node.name.namespace.name === "class"
2310
- );
2306
+ (a) => t__namespace.isJSXNamespacedName(a.node.name) && a.node.name.namespace.name === "class");
2307
+
2311
2308
  if (classNamespaceAttributes.length)
2312
- transformToObject("classList", attributes, classNamespaceAttributes);
2309
+ transformToObject("classList", attributes, classNamespaceAttributes);
2313
2310
  const classAttributes = attributes.filter(
2314
- a =>
2315
- a.node.name &&
2316
- (a.node.name.name === "class" ||
2317
- a.node.name.name === "className" ||
2318
- a.node.name.name === "classList")
2319
- );
2311
+ (a) =>
2312
+ a.node.name && (
2313
+ a.node.name.name === "class" ||
2314
+ a.node.name.name === "className" ||
2315
+ a.node.name.name === "classList"));
2316
+
2320
2317
  // combine class propertoes
2321
2318
  if (classAttributes.length > 1) {
2322
2319
  const first = classAttributes[0].node,
@@ -2328,17 +2325,17 @@ function normalizeAttributes(path) {
2328
2325
  if (!t__namespace.isJSXExpressionContainer(attr.value)) {
2329
2326
  const prev = quasis.pop();
2330
2327
  quasis.push(
2331
- t__namespace.templateElement({
2332
- raw:
2333
- (prev ? prev.value.raw : "") +
2334
- `${attr.value.value}` +
2335
- (isLast ? "" : " ")
2336
- })
2337
- );
2328
+ t__namespace.templateElement({
2329
+ raw:
2330
+ (prev ? prev.value.raw : "") +
2331
+ `${attr.value.value}` + (
2332
+ isLast ? "" : " ")
2333
+ }));
2334
+
2338
2335
  } else {
2339
2336
  let expr = attr.value.expression;
2340
2337
  if (attr.name.name === "classList") {
2341
- if (t__namespace.isObjectExpression(expr) && !expr.properties.some(p => t__namespace.isSpreadElement(p))) {
2338
+ if (t__namespace.isObjectExpression(expr) && !expr.properties.some((p) => t__namespace.isSpreadElement(p))) {
2342
2339
  transformClasslistObject(path, expr, values, quasis);
2343
2340
  if (!isLast) quasis[quasis.length - 1].value.raw += " ";
2344
2341
  i && attributes.splice(attributes.indexOf(classAttributes[i]), 1);
@@ -2365,36 +2362,36 @@ function transformAttributes$1(path, results, info) {
2365
2362
  attributes = normalizeAttributes(path);
2366
2363
  let children;
2367
2364
 
2368
- attributes.forEach(attribute => {
2365
+ attributes.forEach((attribute) => {
2369
2366
  const node = attribute.node;
2370
2367
 
2371
2368
  let value = node.value,
2372
- key = t__namespace.isJSXNamespacedName(node.name)
2373
- ? `${node.name.namespace.name}:${node.name.name.name}`
2374
- : node.name.name,
2369
+ key = t__namespace.isJSXNamespacedName(node.name) ?
2370
+ `${node.name.namespace.name}:${node.name.name.name}` :
2371
+ node.name.name,
2375
2372
  reservedNameSpace =
2376
- t__namespace.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
2373
+ t__namespace.isJSXNamespacedName(node.name) && reservedNameSpaces.has(node.name.namespace.name);
2377
2374
  if (
2378
- ((t__namespace.isJSXNamespacedName(node.name) && reservedNameSpace) || ChildProperties.has(key)) &&
2379
- !t__namespace.isJSXExpressionContainer(value)
2380
- ) {
2375
+ (t__namespace.isJSXNamespacedName(node.name) && reservedNameSpace || ChildProperties.has(key)) &&
2376
+ !t__namespace.isJSXExpressionContainer(value))
2377
+ {
2381
2378
  node.value = value = t__namespace.jsxExpressionContainer(value || t__namespace.jsxEmptyExpression());
2382
2379
  }
2383
2380
 
2384
2381
  if (
2385
- t__namespace.isJSXExpressionContainer(value) &&
2386
- (reservedNameSpace ||
2387
- ChildProperties.has(key) ||
2388
- !(t__namespace.isStringLiteral(value.expression) || t__namespace.isNumericLiteral(value.expression) || t__namespace.isBooleanLiteral(value.expression)))
2389
- ) {
2382
+ t__namespace.isJSXExpressionContainer(value) && (
2383
+ reservedNameSpace ||
2384
+ ChildProperties.has(key) ||
2385
+ !(t__namespace.isStringLiteral(value.expression) || t__namespace.isNumericLiteral(value.expression) || t__namespace.isBooleanLiteral(value.expression))))
2386
+ {
2390
2387
  if (
2391
- key === "ref" ||
2392
- key.startsWith("use:") ||
2393
- key.startsWith("prop:") ||
2394
- key.startsWith("on")
2395
- )
2396
- return;
2397
- else if (ChildProperties.has(key)) {
2388
+ key === "ref" ||
2389
+ key.startsWith("use:") ||
2390
+ key.startsWith("prop:") ||
2391
+ key.startsWith("on"))
2392
+
2393
+ return;else
2394
+ if (ChildProperties.has(key)) {
2398
2395
  if (info.hydratable && key === "textContent" && value && value.expression) {
2399
2396
  value.expression = t__namespace.logicalExpression("||", value.expression, t__namespace.stringLiteral(" "));
2400
2397
  }
@@ -2402,31 +2399,32 @@ function transformAttributes$1(path, results, info) {
2402
2399
  children = value;
2403
2400
  } else {
2404
2401
  let doEscape = true;
2402
+ if (key.startsWith("attr:")) key = key.replace("attr:", "");
2405
2403
  if (BooleanAttributes.has(key)) {
2406
2404
  results.template.push("");
2407
2405
  const fn = t__namespace.callExpression(registerImportMethod(attribute, "ssrAttribute"), [
2408
- t__namespace.stringLiteral(key),
2409
- value.expression,
2410
- t__namespace.booleanLiteral(true)
2411
- ]);
2406
+ t__namespace.stringLiteral(key),
2407
+ value.expression,
2408
+ t__namespace.booleanLiteral(true)]);
2409
+
2412
2410
  results.templateValues.push(fn);
2413
2411
  return;
2414
2412
  }
2415
2413
  if (key === "style") {
2416
2414
  if (
2417
- t__namespace.isJSXExpressionContainer(value) &&
2418
- t__namespace.isObjectExpression(value.expression) &&
2419
- !value.expression.properties.some(p => t__namespace.isSpreadElement(p))
2420
- ) {
2415
+ t__namespace.isJSXExpressionContainer(value) &&
2416
+ t__namespace.isObjectExpression(value.expression) &&
2417
+ !value.expression.properties.some((p) => t__namespace.isSpreadElement(p)))
2418
+ {
2421
2419
  const props = value.expression.properties.map((p, i) =>
2422
- t__namespace.binaryExpression(
2423
- "+",
2424
- t__namespace.stringLiteral(
2425
- (i ? ";" : "") + (t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value) + ":"
2426
- ),
2427
- escapeExpression(path, p.value, true, true)
2428
- )
2429
- );
2420
+ t__namespace.binaryExpression(
2421
+ "+",
2422
+ t__namespace.stringLiteral(
2423
+ (i ? ";" : "") + (t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value) + ":"),
2424
+
2425
+ escapeExpression(path, p.value, true, true)));
2426
+
2427
+
2430
2428
  let res = props[0];
2431
2429
  for (let i = 1; i < props.length; i++) {
2432
2430
  res = t__namespace.binaryExpression("+", res, props[i]);
@@ -2434,27 +2432,27 @@ function transformAttributes$1(path, results, info) {
2434
2432
  value.expression = res;
2435
2433
  } else {
2436
2434
  value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrStyle"), [
2437
- value.expression
2438
- ]);
2435
+ value.expression]);
2436
+
2439
2437
  }
2440
2438
  doEscape = false;
2441
2439
  }
2442
2440
  if (key === "classList") {
2443
2441
  if (
2444
- t__namespace.isObjectExpression(value.expression) &&
2445
- !value.expression.properties.some(p => t__namespace.isSpreadElement(p))
2446
- ) {
2442
+ t__namespace.isObjectExpression(value.expression) &&
2443
+ !value.expression.properties.some((p) => t__namespace.isSpreadElement(p)))
2444
+ {
2447
2445
  const values = [],
2448
2446
  quasis = [t__namespace.templateElement({ raw: "" })];
2449
2447
  transformClasslistObject(path, value.expression, values, quasis);
2450
- if (!values.length) value.expression = t__namespace.stringLiteral(quasis[0].value.raw);
2451
- else if (values.length === 1 && !quasis[0].value.raw && !quasis[1].value.raw) {
2448
+ if (!values.length) value.expression = t__namespace.stringLiteral(quasis[0].value.raw);else
2449
+ if (values.length === 1 && !quasis[0].value.raw && !quasis[1].value.raw) {
2452
2450
  value.expression = values[0];
2453
2451
  } else value.expression = t__namespace.templateLiteral(quasis, values);
2454
2452
  } else {
2455
2453
  value.expression = t__namespace.callExpression(registerImportMethod(path, "ssrClassList"), [
2456
- value.expression
2457
- ]);
2454
+ value.expression]);
2455
+
2458
2456
  }
2459
2457
  key = "class";
2460
2458
  doEscape = false;
@@ -2495,23 +2493,23 @@ function transformClasslistObject(path, expr, values, quasis) {
2495
2493
  expr.properties.forEach((prop, i) => {
2496
2494
  const isLast = expr.properties.length - 1 === i;
2497
2495
  let key = prop.key;
2498
- if (t__namespace.isIdentifier(prop.key) && !prop.computed) key = t__namespace.stringLiteral(key.name);
2499
- else if (prop.computed) {
2496
+ if (t__namespace.isIdentifier(prop.key) && !prop.computed) key = t__namespace.stringLiteral(key.name);else
2497
+ if (prop.computed) {
2500
2498
  key = t__namespace.callExpression(registerImportMethod(path, "escape"), [
2501
- prop.key,
2502
- t__namespace.booleanLiteral(true)
2503
- ]);
2499
+ prop.key,
2500
+ t__namespace.booleanLiteral(true)]);
2501
+
2504
2502
  } else key = t__namespace.stringLiteral(escapeHTML(prop.key.value));
2505
2503
  if (t__namespace.isBooleanLiteral(prop.value)) {
2506
2504
  if (prop.value.value === true) {
2507
2505
  if (!prop.computed) {
2508
2506
  const prev = quasis.pop();
2509
2507
  quasis.push(
2510
- t__namespace.templateElement({
2511
- raw:
2512
- (prev ? prev.value.raw : "") + (i ? " " : "") + `${key.value}` + (isLast ? "" : " ")
2513
- })
2514
- );
2508
+ t__namespace.templateElement({
2509
+ raw:
2510
+ (prev ? prev.value.raw : "") + (i ? " " : "") + `${key.value}` + (isLast ? "" : " ")
2511
+ }));
2512
+
2515
2513
  } else {
2516
2514
  values.push(key);
2517
2515
  quasis.push(t__namespace.templateElement({ raw: isLast ? "" : " " }));
@@ -2529,25 +2527,25 @@ function transformChildren$1(path, results, { hydratable }) {
2529
2527
  const filteredChildren = filterChildren(path.get("children"));
2530
2528
  const multi = checkLength(filteredChildren),
2531
2529
  markers = hydratable && multi;
2532
- filteredChildren.forEach(node => {
2530
+ filteredChildren.forEach((node) => {
2533
2531
  if (t__namespace.isJSXElement(node.node) && getTagName(node.node) === "head") {
2534
2532
  const child = transformNode(node, { doNotEscape, hydratable: false });
2535
2533
  registerImportMethod(path, "NoHydration");
2536
2534
  registerImportMethod(path, "createComponent");
2537
2535
  results.template.push("");
2538
2536
  results.templateValues.push(
2539
- t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
2540
- t__namespace.identifier("_$NoHydration"),
2541
- t__namespace.objectExpression([
2542
- t__namespace.objectMethod(
2543
- "get",
2544
- t__namespace.identifier("children"),
2545
- [],
2546
- t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))])
2547
- )
2548
- ])
2549
- ])
2550
- );
2537
+ t__namespace.callExpression(t__namespace.identifier("_$createComponent"), [
2538
+ t__namespace.identifier("_$NoHydration"),
2539
+ t__namespace.objectExpression([
2540
+ t__namespace.objectMethod(
2541
+ "get",
2542
+ t__namespace.identifier("children"),
2543
+ [],
2544
+ t__namespace.blockStatement([t__namespace.returnStatement(createTemplate$1(path, child))]))])]));
2545
+
2546
+
2547
+
2548
+
2551
2549
  return;
2552
2550
  }
2553
2551
  const child = transformNode(node, { doNotEscape });
@@ -2556,7 +2554,7 @@ function transformChildren$1(path, results, { hydratable }) {
2556
2554
  results.templateValues.push.apply(results.templateValues, child.templateValues || []);
2557
2555
  if (child.exprs.length) {
2558
2556
  if (!doNotEscape && !child.spreadElement)
2559
- child.exprs[0] = escapeExpression(path, child.exprs[0]);
2557
+ child.exprs[0] = escapeExpression(path, child.exprs[0]);
2560
2558
 
2561
2559
  // boxed by textNodes
2562
2560
  if (markers && !child.spreadElement) {
@@ -2587,12 +2585,12 @@ function createElement(path, { topLevel, hydratable }) {
2587
2585
  } else {
2588
2586
  const child = transformNode(path);
2589
2587
  if (markers && child.exprs.length && !child.spreadElement)
2590
- memo.push(t__namespace.stringLiteral("<!--$-->"));
2588
+ memo.push(t__namespace.stringLiteral("<!--$-->"));
2591
2589
  if (child.exprs.length && !child.spreadElement)
2592
- child.exprs[0] = escapeExpression(path, child.exprs[0]);
2590
+ child.exprs[0] = escapeExpression(path, child.exprs[0]);
2593
2591
  memo.push(getCreateTemplate(config, path, child)(path, child, true));
2594
2592
  if (markers && child.exprs.length && !child.spreadElement)
2595
- memo.push(t__namespace.stringLiteral("<!--/-->"));
2593
+ memo.push(t__namespace.stringLiteral("<!--/-->"));
2596
2594
  }
2597
2595
  return memo;
2598
2596
  }, []);
@@ -2606,7 +2604,7 @@ function createElement(path, { topLevel, hydratable }) {
2606
2604
  dynamicSpread = false,
2607
2605
  hasChildren = path.node.children.length > 0;
2608
2606
 
2609
- attributes.forEach(attribute => {
2607
+ attributes.forEach((attribute) => {
2610
2608
  const node = attribute.node;
2611
2609
  if (t__namespace.isJSXSpreadAttribute(node)) {
2612
2610
  if (runningObject.length) {
@@ -2614,51 +2612,51 @@ function createElement(path, { topLevel, hydratable }) {
2614
2612
  runningObject = [];
2615
2613
  }
2616
2614
  props.push(
2617
- isDynamic(attribute.get("argument"), {
2618
- checkMember: true
2619
- }) && (dynamicSpread = true)
2620
- ? t__namespace.isCallExpression(node.argument) &&
2621
- !node.argument.arguments.length &&
2622
- !t__namespace.isCallExpression(node.argument.callee) &&
2623
- !t__namespace.isMemberExpression(node.argument.callee)
2624
- ? node.argument.callee
2625
- : t__namespace.arrowFunctionExpression([], node.argument)
2626
- : node.argument
2627
- );
2615
+ isDynamic(attribute.get("argument"), {
2616
+ checkMember: true
2617
+ }) && (dynamicSpread = true) ?
2618
+ t__namespace.isCallExpression(node.argument) &&
2619
+ !node.argument.arguments.length &&
2620
+ !t__namespace.isCallExpression(node.argument.callee) &&
2621
+ !t__namespace.isMemberExpression(node.argument.callee) ?
2622
+ node.argument.callee :
2623
+ t__namespace.arrowFunctionExpression([], node.argument) :
2624
+ node.argument);
2625
+
2628
2626
  } else {
2629
2627
  const value = node.value || t__namespace.booleanLiteral(true),
2630
2628
  id = convertJSXIdentifier(node.name),
2631
- key = t__namespace.isJSXNamespacedName(node.name)
2632
- ? `${node.name.namespace.name}:${node.name.name.name}`
2633
- : node.name.name;
2629
+ key = t__namespace.isJSXNamespacedName(node.name) ?
2630
+ `${node.name.namespace.name}:${node.name.name.name}` :
2631
+ node.name.name;
2634
2632
 
2635
2633
  if (hasChildren && key === "children") return;
2636
2634
  if (
2637
- key === "ref" ||
2638
- key.startsWith("use:") ||
2639
- key.startsWith("prop:") ||
2640
- key.startsWith("on")
2641
- )
2642
- return;
2643
- if (t__namespace.isJSXExpressionContainer(value))
2635
+ key === "ref" ||
2636
+ key.startsWith("use:") ||
2637
+ key.startsWith("prop:") ||
2638
+ key.startsWith("on"))
2639
+
2640
+ return;
2641
+ if (t__namespace.isJSXExpressionContainer(value)) {
2644
2642
  if (
2645
- isDynamic(attribute.get("value").get("expression"), {
2646
- checkMember: true,
2647
- checkTags: true
2648
- })
2649
- ) {
2643
+ isDynamic(attribute.get("value").get("expression"), {
2644
+ checkMember: true,
2645
+ checkTags: true
2646
+ }))
2647
+ {
2650
2648
  let expr = t__namespace.arrowFunctionExpression([], value.expression);
2651
2649
  runningObject.push(
2652
- t__namespace.objectMethod(
2653
- "get",
2654
- id,
2655
- [],
2656
- t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
2657
- !t__namespace.isValidIdentifier(key)
2658
- )
2659
- );
2660
- } else runningObject.push(t__namespace.objectProperty(id, value.expression));
2661
- else runningObject.push(t__namespace.objectProperty(id, value));
2650
+ t__namespace.objectMethod(
2651
+ "get",
2652
+ id,
2653
+ [],
2654
+ t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
2655
+ !t__namespace.isValidIdentifier(key)));
2656
+
2657
+
2658
+ } else runningObject.push(t__namespace.objectProperty(id, value.expression));} else
2659
+ runningObject.push(t__namespace.objectProperty(id, value));
2662
2660
  }
2663
2661
  });
2664
2662
 
@@ -2670,22 +2668,22 @@ function createElement(path, { topLevel, hydratable }) {
2670
2668
  }
2671
2669
 
2672
2670
  const exprs = [
2673
- t__namespace.callExpression(registerImportMethod(path, "ssrElement"), [
2674
- t__namespace.stringLiteral(tagName),
2675
- props[0],
2676
- childNodes.length
2677
- ? hydratable
2678
- ? t__namespace.arrowFunctionExpression(
2679
- [],
2680
- childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes)
2681
- )
2682
- : childNodes.length === 1
2683
- ? childNodes[0]
2684
- : t__namespace.arrayExpression(childNodes)
2685
- : t__namespace.identifier("undefined"),
2686
- t__namespace.booleanLiteral(Boolean(topLevel && config.hydratable))
2687
- ])
2688
- ];
2671
+ t__namespace.callExpression(registerImportMethod(path, "ssrElement"), [
2672
+ t__namespace.stringLiteral(tagName),
2673
+ props[0],
2674
+ childNodes.length ?
2675
+ hydratable ?
2676
+ t__namespace.arrowFunctionExpression(
2677
+ [],
2678
+ childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes)) :
2679
+
2680
+ childNodes.length === 1 ?
2681
+ childNodes[0] :
2682
+ t__namespace.arrayExpression(childNodes) :
2683
+ t__namespace.identifier("undefined"),
2684
+ t__namespace.booleanLiteral(Boolean(topLevel && config.hydratable))])];
2685
+
2686
+
2689
2687
  return { exprs, template: "", spreadElement: true };
2690
2688
  }
2691
2689
 
@@ -2702,18 +2700,18 @@ function transformElement$1(path, info) {
2702
2700
  };
2703
2701
 
2704
2702
  results.declarations.push(
2705
- t__namespace.variableDeclarator(
2706
- results.id,
2707
- t__namespace.callExpression(
2708
- registerImportMethod(
2709
- path,
2710
- "createElement",
2711
- getRendererConfig(path, "universal").moduleName
2712
- ),
2713
- [t__namespace.stringLiteral(tagName)]
2714
- )
2715
- )
2716
- );
2703
+ t__namespace.variableDeclarator(
2704
+ results.id,
2705
+ t__namespace.callExpression(
2706
+ registerImportMethod(
2707
+ path,
2708
+ "createElement",
2709
+ getRendererConfig(path, "universal").moduleName),
2710
+
2711
+ [t__namespace.stringLiteral(tagName)])));
2712
+
2713
+
2714
+
2717
2715
 
2718
2716
  transformAttributes(path, results);
2719
2717
  transformChildren(path, results);
@@ -2729,147 +2727,147 @@ function transformAttributes(path, results) {
2729
2727
  config = getConfig(path);
2730
2728
 
2731
2729
  // preprocess spreads
2732
- if (attributes.some(attribute => t__namespace.isJSXSpreadAttribute(attribute.node))) {
2730
+ if (attributes.some((attribute) => t__namespace.isJSXSpreadAttribute(attribute.node))) {
2733
2731
  [attributes, spreadExpr] = processSpreads(path, attributes, {
2734
2732
  elem,
2735
2733
  hasChildren,
2736
2734
  wrapConditionals: config.wrapConditionals
2737
2735
  });
2738
2736
  path.get("openingElement").set(
2739
- "attributes",
2740
- attributes.map(a => a.node)
2741
- );
2737
+ "attributes",
2738
+ attributes.map((a) => a.node));
2739
+
2742
2740
  }
2743
2741
 
2744
- path
2745
- .get("openingElement")
2746
- .get("attributes")
2747
- .forEach(attribute => {
2748
- const node = attribute.node;
2742
+ path.
2743
+ get("openingElement").
2744
+ get("attributes").
2745
+ forEach((attribute) => {
2746
+ const node = attribute.node;
2749
2747
 
2750
- let value = node.value,
2751
- key = t__namespace.isJSXNamespacedName(node.name)
2752
- ? `${node.name.namespace.name}:${node.name.name.name}`
2753
- : node.name.name,
2754
- reservedNameSpace = t__namespace.isJSXNamespacedName(node.name) && node.name.namespace.name === "use";
2755
- if (
2756
- t__namespace.isJSXNamespacedName(node.name) &&
2757
- reservedNameSpace &&
2758
- !t__namespace.isJSXExpressionContainer(value)
2759
- ) {
2760
- node.value = value = t__namespace.jsxExpressionContainer(value || t__namespace.jsxEmptyExpression());
2761
- }
2762
- if (t__namespace.isJSXExpressionContainer(value)) {
2763
- if (key === "ref") {
2764
- // Normalize expressions for non-null and type-as
2765
- while (
2766
- t__namespace.isTSNonNullExpression(value.expression) ||
2767
- t__namespace.isTSAsExpression(value.expression)
2768
- ) {
2769
- value.expression = value.expression.expression;
2770
- }
2771
- if (t__namespace.isLVal(value.expression)) {
2772
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
2773
- results.exprs.unshift(
2774
- t__namespace.variableDeclaration("var", [
2775
- t__namespace.variableDeclarator(refIdentifier, value.expression)
2776
- ]),
2777
- t__namespace.expressionStatement(
2778
- t__namespace.conditionalExpression(
2779
- t__namespace.binaryExpression(
2780
- "===",
2781
- t__namespace.unaryExpression("typeof", refIdentifier),
2782
- t__namespace.stringLiteral("function")
2783
- ),
2784
- t__namespace.callExpression(
2785
- registerImportMethod(
2786
- path,
2787
- "use",
2788
- getRendererConfig(path, "universal").moduleName
2789
- ),
2790
- [refIdentifier, elem]
2791
- ),
2792
- t__namespace.assignmentExpression("=", value.expression, elem)
2793
- )
2794
- )
2795
- );
2796
- } else if (t__namespace.isFunction(value.expression)) {
2797
- results.exprs.unshift(
2798
- t__namespace.expressionStatement(
2799
- t__namespace.callExpression(
2800
- registerImportMethod(
2801
- path,
2802
- "use",
2803
- getRendererConfig(path, "universal").moduleName
2804
- ),
2805
- [value.expression, elem]
2806
- )
2807
- )
2808
- );
2809
- } else {
2810
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
2811
- results.exprs.unshift(
2812
- t__namespace.variableDeclaration("var", [
2813
- t__namespace.variableDeclarator(refIdentifier, value.expression)
2814
- ]),
2815
- t__namespace.expressionStatement(
2816
- t__namespace.logicalExpression(
2817
- "&&",
2818
- t__namespace.binaryExpression(
2819
- "===",
2820
- t__namespace.unaryExpression("typeof", refIdentifier),
2821
- t__namespace.stringLiteral("function")
2822
- ),
2823
- t__namespace.callExpression(
2824
- registerImportMethod(
2825
- path,
2826
- "use",
2827
- getRendererConfig(path, "universal").moduleName
2828
- ),
2829
- [refIdentifier, elem]
2830
- )
2831
- )
2832
- )
2833
- );
2834
- }
2835
- } else if (key.startsWith("use:")) {
2836
- // Some trick to treat JSXIdentifier as Identifier
2837
- node.name.name.type = "Identifier";
2748
+ let value = node.value,
2749
+ key = t__namespace.isJSXNamespacedName(node.name) ?
2750
+ `${node.name.namespace.name}:${node.name.name.name}` :
2751
+ node.name.name,
2752
+ reservedNameSpace = t__namespace.isJSXNamespacedName(node.name) && node.name.namespace.name === "use";
2753
+ if (
2754
+ t__namespace.isJSXNamespacedName(node.name) &&
2755
+ reservedNameSpace &&
2756
+ !t__namespace.isJSXExpressionContainer(value))
2757
+ {
2758
+ node.value = value = t__namespace.jsxExpressionContainer(value || t__namespace.jsxEmptyExpression());
2759
+ }
2760
+ if (t__namespace.isJSXExpressionContainer(value)) {
2761
+ if (key === "ref") {
2762
+ // Normalize expressions for non-null and type-as
2763
+ while (
2764
+ t__namespace.isTSNonNullExpression(value.expression) ||
2765
+ t__namespace.isTSAsExpression(value.expression))
2766
+ {
2767
+ value.expression = value.expression.expression;
2768
+ }
2769
+ if (t__namespace.isLVal(value.expression)) {
2770
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
2838
2771
  results.exprs.unshift(
2839
- t__namespace.expressionStatement(
2840
- t__namespace.callExpression(
2841
- registerImportMethod(path, "use", getRendererConfig(path, "universal").moduleName),
2842
- [
2843
- node.name.name,
2844
- elem,
2845
- t__namespace.arrowFunctionExpression(
2846
- [],
2847
- t__namespace.isJSXEmptyExpression(value.expression)
2848
- ? t__namespace.booleanLiteral(true)
2849
- : value.expression
2850
- )
2851
- ]
2852
- )
2853
- )
2854
- );
2855
- } else if (key === "children") {
2856
- children = value;
2857
- } else if (
2858
- config.effectWrapper &&
2859
- isDynamic(attribute.get("value").get("expression"), {
2860
- checkMember: true
2861
- })
2862
- ) {
2863
- results.dynamics.push({ elem, key, value: value.expression });
2772
+ t__namespace.variableDeclaration("var", [
2773
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
2774
+
2775
+ t__namespace.expressionStatement(
2776
+ t__namespace.conditionalExpression(
2777
+ t__namespace.binaryExpression(
2778
+ "===",
2779
+ t__namespace.unaryExpression("typeof", refIdentifier),
2780
+ t__namespace.stringLiteral("function")),
2781
+
2782
+ t__namespace.callExpression(
2783
+ registerImportMethod(
2784
+ path,
2785
+ "use",
2786
+ getRendererConfig(path, "universal").moduleName),
2787
+
2788
+ [refIdentifier, elem]),
2789
+
2790
+ t__namespace.assignmentExpression("=", value.expression, elem))));
2791
+
2792
+
2793
+
2794
+ } else if (t__namespace.isFunction(value.expression)) {
2795
+ results.exprs.unshift(
2796
+ t__namespace.expressionStatement(
2797
+ t__namespace.callExpression(
2798
+ registerImportMethod(
2799
+ path,
2800
+ "use",
2801
+ getRendererConfig(path, "universal").moduleName),
2802
+
2803
+ [value.expression, elem])));
2804
+
2805
+
2806
+
2864
2807
  } else {
2865
- results.exprs.push(
2866
- t__namespace.expressionStatement(setAttr(attribute, elem, key, value.expression))
2867
- );
2808
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
2809
+ results.exprs.unshift(
2810
+ t__namespace.variableDeclaration("var", [
2811
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
2812
+
2813
+ t__namespace.expressionStatement(
2814
+ t__namespace.logicalExpression(
2815
+ "&&",
2816
+ t__namespace.binaryExpression(
2817
+ "===",
2818
+ t__namespace.unaryExpression("typeof", refIdentifier),
2819
+ t__namespace.stringLiteral("function")),
2820
+
2821
+ t__namespace.callExpression(
2822
+ registerImportMethod(
2823
+ path,
2824
+ "use",
2825
+ getRendererConfig(path, "universal").moduleName),
2826
+
2827
+ [refIdentifier, elem]))));
2828
+
2829
+
2830
+
2831
+
2868
2832
  }
2833
+ } else if (key.startsWith("use:")) {
2834
+ // Some trick to treat JSXIdentifier as Identifier
2835
+ node.name.name.type = "Identifier";
2836
+ results.exprs.unshift(
2837
+ t__namespace.expressionStatement(
2838
+ t__namespace.callExpression(
2839
+ registerImportMethod(path, "use", getRendererConfig(path, "universal").moduleName),
2840
+ [
2841
+ node.name.name,
2842
+ elem,
2843
+ t__namespace.arrowFunctionExpression(
2844
+ [],
2845
+ t__namespace.isJSXEmptyExpression(value.expression) ?
2846
+ t__namespace.booleanLiteral(true) :
2847
+ value.expression)])));
2848
+
2849
+
2850
+
2851
+
2852
+
2853
+ } else if (key === "children") {
2854
+ children = value;
2855
+ } else if (
2856
+ config.effectWrapper &&
2857
+ isDynamic(attribute.get("value").get("expression"), {
2858
+ checkMember: true
2859
+ }))
2860
+ {
2861
+ results.dynamics.push({ elem, key, value: value.expression });
2869
2862
  } else {
2870
- results.exprs.push(t__namespace.expressionStatement(setAttr(attribute, elem, key, value)));
2863
+ results.exprs.push(
2864
+ t__namespace.expressionStatement(setAttr(attribute, elem, key, value.expression)));
2865
+
2871
2866
  }
2872
- });
2867
+ } else {
2868
+ results.exprs.push(t__namespace.expressionStatement(setAttr(attribute, elem, key, value)));
2869
+ }
2870
+ });
2873
2871
  if (spreadExpr) results.exprs.push(spreadExpr);
2874
2872
  if (!hasChildren && children) {
2875
2873
  path.node.children.push(children);
@@ -2879,9 +2877,9 @@ function transformAttributes(path, results) {
2879
2877
  function setAttr(path, elem, name, value, { prevId } = {}) {
2880
2878
  if (!value) value = t__namespace.booleanLiteral(true);
2881
2879
  return t__namespace.callExpression(
2882
- registerImportMethod(path, "setProp", getRendererConfig(path, "universal").moduleName),
2883
- prevId ? [elem, t__namespace.stringLiteral(name), value, prevId] : [elem, t__namespace.stringLiteral(name), value]
2884
- );
2880
+ registerImportMethod(path, "setProp", getRendererConfig(path, "universal").moduleName),
2881
+ prevId ? [elem, t__namespace.stringLiteral(name), value, prevId] : [elem, t__namespace.stringLiteral(name), value]);
2882
+
2885
2883
  }
2886
2884
 
2887
2885
  function transformChildren(path, results) {
@@ -2905,30 +2903,30 @@ function transformChildren(path, results) {
2905
2903
  }
2906
2904
  if (child.id) {
2907
2905
  let insertNode = registerImportMethod(
2908
- path,
2909
- "insertNode",
2910
- getRendererConfig(path, "universal").moduleName
2911
- );
2906
+ path,
2907
+ "insertNode",
2908
+ getRendererConfig(path, "universal").moduleName);
2909
+
2912
2910
  let insert = child.id;
2913
2911
  if (child.text) {
2914
2912
  let createTextNode = registerImportMethod(
2915
- path,
2916
- "createTextNode",
2917
- getRendererConfig(path, "universal").moduleName
2918
- );
2913
+ path,
2914
+ "createTextNode",
2915
+ getRendererConfig(path, "universal").moduleName);
2916
+
2919
2917
  if (multi) {
2920
2918
  results.declarations.push(
2921
- t__namespace.variableDeclarator(
2922
- child.id,
2923
- t__namespace.callExpression(createTextNode, [
2924
- t__namespace.templateLiteral([t__namespace.templateElement({ raw: escapeStringForTemplate(child.template) })], [])
2925
- ])
2926
- )
2927
- );
2919
+ t__namespace.variableDeclarator(
2920
+ child.id,
2921
+ t__namespace.callExpression(createTextNode, [
2922
+ t__namespace.templateLiteral([t__namespace.templateElement({ raw: escapeStringForTemplate(child.template) })], [])])));
2923
+
2924
+
2925
+
2928
2926
  } else
2929
- insert = t__namespace.callExpression(createTextNode, [
2930
- t__namespace.templateLiteral([t__namespace.templateElement({ raw: escapeStringForTemplate(child.template) })], [])
2931
- ]);
2927
+ insert = t__namespace.callExpression(createTextNode, [
2928
+ t__namespace.templateLiteral([t__namespace.templateElement({ raw: escapeStringForTemplate(child.template) })], [])]);
2929
+
2932
2930
  }
2933
2931
  appends.push(t__namespace.expressionStatement(t__namespace.callExpression(insertNode, [results.id, insert])));
2934
2932
  results.declarations.push(...child.declarations);
@@ -2936,24 +2934,24 @@ function transformChildren(path, results) {
2936
2934
  results.dynamics.push(...child.dynamics);
2937
2935
  } else if (child.exprs.length) {
2938
2936
  let insert = registerImportMethod(
2939
- path,
2940
- "insert",
2941
- getRendererConfig(path, "universal").moduleName
2942
- );
2937
+ path,
2938
+ "insert",
2939
+ getRendererConfig(path, "universal").moduleName);
2940
+
2943
2941
  if (multi) {
2944
2942
  results.exprs.push(
2945
- t__namespace.expressionStatement(
2946
- t__namespace.callExpression(insert, [
2947
- results.id,
2948
- child.exprs[0],
2949
- nextChild(childNodes, index) || t__namespace.nullLiteral()
2950
- ])
2951
- )
2952
- );
2943
+ t__namespace.expressionStatement(
2944
+ t__namespace.callExpression(insert, [
2945
+ results.id,
2946
+ child.exprs[0],
2947
+ nextChild(childNodes, index) || t__namespace.nullLiteral()])));
2948
+
2949
+
2950
+
2953
2951
  } else {
2954
2952
  results.exprs.push(
2955
- t__namespace.expressionStatement(t__namespace.callExpression(insert, [results.id, child.exprs[0]]))
2956
- );
2953
+ t__namespace.expressionStatement(t__namespace.callExpression(insert, [results.id, child.exprs[0]])));
2954
+
2957
2955
  }
2958
2956
  }
2959
2957
  });
@@ -2971,13 +2969,13 @@ function processSpreads(path, attributes, { elem, hasChildren, wrapConditionals
2971
2969
  let runningObject = [];
2972
2970
  let dynamicSpread = false;
2973
2971
  let firstSpread = false;
2974
- attributes.forEach(attribute => {
2972
+ attributes.forEach((attribute) => {
2975
2973
  const node = attribute.node;
2976
2974
  const key =
2977
- !t__namespace.isJSXSpreadAttribute(node) &&
2978
- (t__namespace.isJSXNamespacedName(node.name)
2979
- ? `${node.name.namespace.name}:${node.name.name.name}`
2980
- : node.name.name);
2975
+ !t__namespace.isJSXSpreadAttribute(node) && (
2976
+ t__namespace.isJSXNamespacedName(node.name) ?
2977
+ `${node.name.namespace.name}:${node.name.name.name}` :
2978
+ node.name.name);
2981
2979
  if (t__namespace.isJSXSpreadAttribute(node)) {
2982
2980
  firstSpread = true;
2983
2981
  if (runningObject.length) {
@@ -2985,50 +2983,50 @@ function processSpreads(path, attributes, { elem, hasChildren, wrapConditionals
2985
2983
  runningObject = [];
2986
2984
  }
2987
2985
  spreadArgs.push(
2988
- isDynamic(attribute.get("argument"), {
2989
- checkMember: true
2990
- }) && (dynamicSpread = true)
2991
- ? t__namespace.isCallExpression(node.argument) &&
2992
- !node.argument.arguments.length &&
2993
- !t__namespace.isCallExpression(node.argument.callee) &&
2994
- !t__namespace.isMemberExpression(node.argument.callee)
2995
- ? node.argument.callee
2996
- : t__namespace.arrowFunctionExpression([], node.argument)
2997
- : node.argument
2998
- );
2986
+ isDynamic(attribute.get("argument"), {
2987
+ checkMember: true
2988
+ }) && (dynamicSpread = true) ?
2989
+ t__namespace.isCallExpression(node.argument) &&
2990
+ !node.argument.arguments.length &&
2991
+ !t__namespace.isCallExpression(node.argument.callee) &&
2992
+ !t__namespace.isMemberExpression(node.argument.callee) ?
2993
+ node.argument.callee :
2994
+ t__namespace.arrowFunctionExpression([], node.argument) :
2995
+ node.argument);
2996
+
2999
2997
  } else if (
3000
- (firstSpread ||
3001
- (t__namespace.isJSXExpressionContainer(node.value) &&
3002
- isDynamic(attribute.get("value").get("expression"), { checkMember: true }))) &&
3003
- canNativeSpread(key, { checkNameSpaces: true })
3004
- ) {
2998
+ (firstSpread ||
2999
+ t__namespace.isJSXExpressionContainer(node.value) &&
3000
+ isDynamic(attribute.get("value").get("expression"), { checkMember: true })) &&
3001
+ canNativeSpread(key, { checkNameSpaces: true }))
3002
+ {
3005
3003
  const isContainer = t__namespace.isJSXExpressionContainer(node.value);
3006
3004
  const dynamic =
3007
- isContainer && isDynamic(attribute.get("value").get("expression"), { checkMember: true });
3005
+ isContainer && isDynamic(attribute.get("value").get("expression"), { checkMember: true });
3008
3006
  if (dynamic) {
3009
3007
  const id = convertJSXIdentifier(node.name);
3010
3008
  let expr =
3011
- wrapConditionals &&
3012
- (t__namespace.isLogicalExpression(node.value.expression) ||
3013
- t__namespace.isConditionalExpression(node.value.expression))
3014
- ? transformCondition(attribute.get("value").get("expression"), true)
3015
- : t__namespace.arrowFunctionExpression([], node.value.expression);
3009
+ wrapConditionals && (
3010
+ t__namespace.isLogicalExpression(node.value.expression) ||
3011
+ t__namespace.isConditionalExpression(node.value.expression)) ?
3012
+ transformCondition(attribute.get("value").get("expression"), true) :
3013
+ t__namespace.arrowFunctionExpression([], node.value.expression);
3016
3014
  runningObject.push(
3017
- t__namespace.objectMethod(
3018
- "get",
3019
- id,
3020
- [],
3021
- t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
3022
- !t__namespace.isValidIdentifier(key)
3023
- )
3024
- );
3015
+ t__namespace.objectMethod(
3016
+ "get",
3017
+ id,
3018
+ [],
3019
+ t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
3020
+ !t__namespace.isValidIdentifier(key)));
3021
+
3022
+
3025
3023
  } else {
3026
3024
  runningObject.push(
3027
- t__namespace.objectProperty(
3028
- t__namespace.stringLiteral(key),
3029
- isContainer ? node.value.expression : node.value || t__namespace.booleanLiteral(true)
3030
- )
3031
- );
3025
+ t__namespace.objectProperty(
3026
+ t__namespace.stringLiteral(key),
3027
+ isContainer ? node.value.expression : node.value || t__namespace.booleanLiteral(true)));
3028
+
3029
+
3032
3030
  }
3033
3031
  } else filteredAttributes.push(attribute);
3034
3032
  });
@@ -3038,19 +3036,19 @@ function processSpreads(path, attributes, { elem, hasChildren, wrapConditionals
3038
3036
  }
3039
3037
 
3040
3038
  const props =
3041
- spreadArgs.length === 1 && !dynamicSpread
3042
- ? spreadArgs[0]
3043
- : t__namespace.callExpression(registerImportMethod(path, "mergeProps"), spreadArgs);
3039
+ spreadArgs.length === 1 && !dynamicSpread ?
3040
+ spreadArgs[0] :
3041
+ t__namespace.callExpression(registerImportMethod(path, "mergeProps"), spreadArgs);
3044
3042
 
3045
3043
  return [
3046
- filteredAttributes,
3047
- t__namespace.expressionStatement(
3048
- t__namespace.callExpression(
3049
- registerImportMethod(path, "spread", getRendererConfig(path, "universal").moduleName),
3050
- [elem, props, t__namespace.booleanLiteral(hasChildren)]
3051
- )
3052
- )
3053
- ];
3044
+ filteredAttributes,
3045
+ t__namespace.expressionStatement(
3046
+ t__namespace.callExpression(
3047
+ registerImportMethod(path, "spread", getRendererConfig(path, "universal").moduleName),
3048
+ [elem, props, t__namespace.booleanLiteral(hasChildren)]))];
3049
+
3050
+
3051
+
3054
3052
  }
3055
3053
 
3056
3054
  function createTemplate(path, result, wrap) {
@@ -3058,25 +3056,25 @@ function createTemplate(path, result, wrap) {
3058
3056
  if (result.id) {
3059
3057
  result.decl = t__namespace.variableDeclaration("var", result.declarations);
3060
3058
  if (
3061
- !(result.exprs.length || result.dynamics.length || result.postExprs.length) &&
3062
- result.decl.declarations.length === 1
3063
- ) {
3059
+ !(result.exprs.length || result.dynamics.length || result.postExprs.length) &&
3060
+ result.decl.declarations.length === 1)
3061
+ {
3064
3062
  return result.decl.declarations[0].init;
3065
3063
  } else {
3066
3064
  return t__namespace.callExpression(
3067
- t__namespace.arrowFunctionExpression(
3068
- [],
3069
- t__namespace.blockStatement([
3070
- result.decl,
3071
- ...result.exprs.concat(
3072
- wrapDynamics(path, result.dynamics) || [],
3073
- result.postExprs || []
3074
- ),
3075
- t__namespace.returnStatement(result.id)
3076
- ])
3077
- ),
3078
- []
3079
- );
3065
+ t__namespace.arrowFunctionExpression(
3066
+ [],
3067
+ t__namespace.blockStatement([
3068
+ result.decl,
3069
+ ...result.exprs.concat(
3070
+ wrapDynamics(path, result.dynamics) || [],
3071
+ result.postExprs || []),
3072
+
3073
+ t__namespace.returnStatement(result.id)])),
3074
+
3075
+
3076
+ []);
3077
+
3080
3078
  }
3081
3079
  }
3082
3080
  if (wrap && result.dynamic && config.memoWrapper) {
@@ -3095,16 +3093,16 @@ function wrapDynamics(path, dynamics) {
3095
3093
  const prevValue = t__namespace.identifier("_$p");
3096
3094
 
3097
3095
  return t__namespace.expressionStatement(
3098
- t__namespace.callExpression(effectWrapperId, [
3099
- t__namespace.arrowFunctionExpression(
3100
- [prevValue],
3101
- setAttr(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
3102
- dynamic: true,
3103
- prevId: prevValue
3104
- })
3105
- )
3106
- ])
3107
- );
3096
+ t__namespace.callExpression(effectWrapperId, [
3097
+ t__namespace.arrowFunctionExpression(
3098
+ [prevValue],
3099
+ setAttr(path, dynamics[0].elem, dynamics[0].key, dynamics[0].value, {
3100
+ dynamic: true,
3101
+ prevId: prevValue
3102
+ }))]));
3103
+
3104
+
3105
+
3108
3106
  }
3109
3107
 
3110
3108
  const prevId = t__namespace.identifier("_p$");
@@ -3126,42 +3124,42 @@ function wrapDynamics(path, dynamics) {
3126
3124
  declarations.push(t__namespace.variableDeclarator(varIdent, value));
3127
3125
 
3128
3126
  statements.push(
3129
- t__namespace.expressionStatement(
3130
- t__namespace.logicalExpression(
3131
- "&&",
3132
- t__namespace.binaryExpression("!==", varIdent, propMember),
3133
- t__namespace.assignmentExpression(
3134
- "=",
3135
- propMember,
3136
- setAttr(path, elem, key, varIdent, { dynamic: true, prevId: propMember }),
3137
- ),
3138
- ),
3139
- ),
3140
- );
3127
+ t__namespace.expressionStatement(
3128
+ t__namespace.logicalExpression(
3129
+ "&&",
3130
+ t__namespace.binaryExpression("!==", varIdent, propMember),
3131
+ t__namespace.assignmentExpression(
3132
+ "=",
3133
+ propMember,
3134
+ setAttr(path, elem, key, varIdent, { dynamic: true, prevId: propMember })))));
3135
+
3136
+
3137
+
3138
+
3141
3139
  });
3142
3140
 
3143
3141
  return t__namespace.expressionStatement(
3144
- t__namespace.callExpression(effectWrapperId, [
3145
- t__namespace.arrowFunctionExpression(
3146
- [prevId],
3147
- t__namespace.blockStatement([
3148
- t__namespace.variableDeclaration("var", declarations),
3149
- ...statements,
3150
- t__namespace.returnStatement(prevId),
3151
- ]),
3152
- ),
3153
- t__namespace.objectExpression(
3154
- properties.map((id) => t__namespace.objectProperty(id, t__namespace.identifier("undefined"))),
3155
- ),
3156
- ]),
3157
- );
3142
+ t__namespace.callExpression(effectWrapperId, [
3143
+ t__namespace.arrowFunctionExpression(
3144
+ [prevId],
3145
+ t__namespace.blockStatement([
3146
+ t__namespace.variableDeclaration("var", declarations),
3147
+ ...statements,
3148
+ t__namespace.returnStatement(prevId)])),
3149
+
3150
+
3151
+ t__namespace.objectExpression(
3152
+ properties.map((id) => t__namespace.objectProperty(id, t__namespace.identifier("undefined"))))]));
3153
+
3154
+
3155
+
3158
3156
  }
3159
3157
 
3160
3158
  function convertComponentIdentifier(node) {
3161
3159
  if (t__namespace.isJSXIdentifier(node)) {
3162
3160
  if (node.name === 'this') return t__namespace.thisExpression();
3163
- if (t__namespace.isValidIdentifier(node.name)) node.type = "Identifier";
3164
- else return t__namespace.stringLiteral(node.name);
3161
+ if (t__namespace.isValidIdentifier(node.name)) node.type = "Identifier";else
3162
+ return t__namespace.stringLiteral(node.name);
3165
3163
  } else if (t__namespace.isJSXMemberExpression(node)) {
3166
3164
  const prop = convertComponentIdentifier(node.property);
3167
3165
  const computed = t__namespace.isStringLiteral(prop);
@@ -3185,168 +3183,168 @@ function transformComponent(path) {
3185
3183
  tagId.name = newTagId.name;
3186
3184
  }
3187
3185
 
3188
- path
3189
- .get("openingElement")
3190
- .get("attributes")
3191
- .forEach(attribute => {
3192
- const node = attribute.node;
3193
- if (t__namespace.isJSXSpreadAttribute(node)) {
3194
- if (runningObject.length) {
3195
- props.push(t__namespace.objectExpression(runningObject));
3196
- runningObject = [];
3197
- }
3198
- props.push(
3199
- isDynamic(attribute.get("argument"), {
3200
- checkMember: true
3201
- }) && (dynamicSpread = true)
3202
- ? t__namespace.isCallExpression(node.argument) &&
3203
- !node.argument.arguments.length &&
3204
- !t__namespace.isCallExpression(node.argument.callee) &&
3205
- !t__namespace.isMemberExpression(node.argument.callee)
3206
- ? node.argument.callee
3207
- : t__namespace.arrowFunctionExpression([], node.argument)
3208
- : node.argument
3209
- );
3210
- } else {
3211
- // handle weird babel bug around HTML entities
3212
- const value = (t__namespace.isStringLiteral(node.value) ? t__namespace.stringLiteral(node.value.value): node.value) || t__namespace.booleanLiteral(true),
3213
- id = convertJSXIdentifier(node.name),
3214
- key = id.name;
3215
- if (hasChildren && key === "children") return;
3216
- if (t__namespace.isJSXExpressionContainer(value))
3217
- if (key === "ref") {
3218
- if (config.generate === "ssr") return;
3219
- // Normalize expressions for non-null and type-as
3220
- while (
3221
- t__namespace.isTSNonNullExpression(value.expression) ||
3222
- t__namespace.isTSAsExpression(value.expression) ||
3223
- t__namespace.isTSSatisfiesExpression(value.expression)
3224
- ) {
3225
- value.expression = value.expression.expression;
3226
- }
3227
- let binding,
3228
- isFunction =
3229
- t__namespace.isIdentifier(value.expression) &&
3230
- (binding = path.scope.getBinding(value.expression.name)) &&
3231
- binding.kind === "const";
3232
- if (!isFunction && t__namespace.isLVal(value.expression)) {
3233
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
3234
- runningObject.push(
3235
- t__namespace.objectMethod(
3236
- "method",
3237
- t__namespace.identifier("ref"),
3238
- [t__namespace.identifier("r$")],
3239
- t__namespace.blockStatement([
3240
- t__namespace.variableDeclaration("var", [
3241
- t__namespace.variableDeclarator(refIdentifier, value.expression)
3242
- ]),
3243
- t__namespace.expressionStatement(
3244
- t__namespace.conditionalExpression(
3245
- t__namespace.binaryExpression(
3246
- "===",
3247
- t__namespace.unaryExpression("typeof", refIdentifier),
3248
- t__namespace.stringLiteral("function")
3249
- ),
3250
- t__namespace.callExpression(refIdentifier, [t__namespace.identifier("r$")]),
3251
- t__namespace.assignmentExpression("=", value.expression, t__namespace.identifier("r$"))
3252
- )
3253
- )
3254
- ])
3255
- )
3256
- );
3257
- } else if (isFunction || t__namespace.isFunction(value.expression)) {
3258
- runningObject.push(t__namespace.objectProperty(t__namespace.identifier("ref"), value.expression));
3259
- } else if (t__namespace.isCallExpression(value.expression)) {
3260
- const refIdentifier = path.scope.generateUidIdentifier("_ref$");
3261
- runningObject.push(
3262
- t__namespace.objectMethod(
3263
- "method",
3264
- t__namespace.identifier("ref"),
3265
- [t__namespace.identifier("r$")],
3266
- t__namespace.blockStatement([
3267
- t__namespace.variableDeclaration("var", [
3268
- t__namespace.variableDeclarator(refIdentifier, value.expression)
3269
- ]),
3270
- t__namespace.expressionStatement(
3271
- t__namespace.logicalExpression(
3272
- "&&",
3273
- t__namespace.binaryExpression(
3274
- "===",
3275
- t__namespace.unaryExpression("typeof", refIdentifier),
3276
- t__namespace.stringLiteral("function")
3277
- ),
3278
- t__namespace.callExpression(refIdentifier, [t__namespace.identifier("r$")])
3279
- )
3280
- )
3281
- ])
3282
- )
3283
- );
3284
- }
3285
- } else if (
3286
- isDynamic(attribute.get("value").get("expression"), {
3287
- checkMember: true,
3288
- checkTags: true
3289
- })
3290
- ) {
3291
- if (
3292
- config.wrapConditionals &&
3293
- config.generate !== "ssr" &&
3294
- (t__namespace.isLogicalExpression(value.expression) ||
3295
- t__namespace.isConditionalExpression(value.expression))
3296
- ) {
3297
- const expr = transformCondition(attribute.get("value").get("expression"), true);
3298
-
3299
- runningObject.push(
3300
- t__namespace.objectMethod(
3301
- "get",
3302
- id,
3303
- [],
3304
- t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
3305
- !t__namespace.isValidIdentifier(key)
3306
- )
3307
- );
3308
- } else if (
3309
- t__namespace.isCallExpression(value.expression) &&
3310
- t__namespace.isArrowFunctionExpression(value.expression.callee) &&
3311
- value.expression.callee.params.length === 0
3312
- ) {
3313
- const callee = value.expression.callee;
3314
- const body = t__namespace.isBlockStatement(callee.body)
3315
- ? callee.body
3316
- : t__namespace.blockStatement([t__namespace.returnStatement(callee.body)]);
3317
-
3318
- runningObject.push(t__namespace.objectMethod("get", id, [], body, !t__namespace.isValidIdentifier(key)));
3319
- } else {
3320
- runningObject.push(
3321
- t__namespace.objectMethod(
3322
- "get",
3323
- id,
3324
- [],
3325
- t__namespace.blockStatement([t__namespace.returnStatement(value.expression)]),
3326
- !t__namespace.isValidIdentifier(key)
3327
- )
3328
- );
3329
- }
3330
- } else runningObject.push(t__namespace.objectProperty(id, value.expression));
3331
- else runningObject.push(t__namespace.objectProperty(id, value));
3186
+ path.
3187
+ get("openingElement").
3188
+ get("attributes").
3189
+ forEach((attribute) => {
3190
+ const node = attribute.node;
3191
+ if (t__namespace.isJSXSpreadAttribute(node)) {
3192
+ if (runningObject.length) {
3193
+ props.push(t__namespace.objectExpression(runningObject));
3194
+ runningObject = [];
3332
3195
  }
3333
- });
3196
+ props.push(
3197
+ isDynamic(attribute.get("argument"), {
3198
+ checkMember: true
3199
+ }) && (dynamicSpread = true) ?
3200
+ t__namespace.isCallExpression(node.argument) &&
3201
+ !node.argument.arguments.length &&
3202
+ !t__namespace.isCallExpression(node.argument.callee) &&
3203
+ !t__namespace.isMemberExpression(node.argument.callee) ?
3204
+ node.argument.callee :
3205
+ t__namespace.arrowFunctionExpression([], node.argument) :
3206
+ node.argument);
3207
+
3208
+ } else {
3209
+ // handle weird babel bug around HTML entities
3210
+ const value = (t__namespace.isStringLiteral(node.value) ? t__namespace.stringLiteral(node.value.value) : node.value) || t__namespace.booleanLiteral(true),
3211
+ id = convertJSXIdentifier(node.name),
3212
+ key = id.name;
3213
+ if (hasChildren && key === "children") return;
3214
+ if (t__namespace.isJSXExpressionContainer(value)) {
3215
+ if (key === "ref") {
3216
+ if (config.generate === "ssr") return;
3217
+ // Normalize expressions for non-null and type-as
3218
+ while (
3219
+ t__namespace.isTSNonNullExpression(value.expression) ||
3220
+ t__namespace.isTSAsExpression(value.expression) ||
3221
+ t__namespace.isTSSatisfiesExpression(value.expression))
3222
+ {
3223
+ value.expression = value.expression.expression;
3224
+ }
3225
+ let binding,
3226
+ isFunction =
3227
+ t__namespace.isIdentifier(value.expression) && (
3228
+ binding = path.scope.getBinding(value.expression.name)) &&
3229
+ binding.kind === "const";
3230
+ if (!isFunction && t__namespace.isLVal(value.expression)) {
3231
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
3232
+ runningObject.push(
3233
+ t__namespace.objectMethod(
3234
+ "method",
3235
+ t__namespace.identifier("ref"),
3236
+ [t__namespace.identifier("r$")],
3237
+ t__namespace.blockStatement([
3238
+ t__namespace.variableDeclaration("var", [
3239
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
3240
+
3241
+ t__namespace.expressionStatement(
3242
+ t__namespace.conditionalExpression(
3243
+ t__namespace.binaryExpression(
3244
+ "===",
3245
+ t__namespace.unaryExpression("typeof", refIdentifier),
3246
+ t__namespace.stringLiteral("function")),
3247
+
3248
+ t__namespace.callExpression(refIdentifier, [t__namespace.identifier("r$")]),
3249
+ t__namespace.assignmentExpression("=", value.expression, t__namespace.identifier("r$"))))])));
3250
+
3251
+
3252
+
3253
+
3254
+
3255
+ } else if (isFunction || t__namespace.isFunction(value.expression)) {
3256
+ runningObject.push(t__namespace.objectProperty(t__namespace.identifier("ref"), value.expression));
3257
+ } else if (t__namespace.isCallExpression(value.expression)) {
3258
+ const refIdentifier = path.scope.generateUidIdentifier("_ref$");
3259
+ runningObject.push(
3260
+ t__namespace.objectMethod(
3261
+ "method",
3262
+ t__namespace.identifier("ref"),
3263
+ [t__namespace.identifier("r$")],
3264
+ t__namespace.blockStatement([
3265
+ t__namespace.variableDeclaration("var", [
3266
+ t__namespace.variableDeclarator(refIdentifier, value.expression)]),
3267
+
3268
+ t__namespace.expressionStatement(
3269
+ t__namespace.logicalExpression(
3270
+ "&&",
3271
+ t__namespace.binaryExpression(
3272
+ "===",
3273
+ t__namespace.unaryExpression("typeof", refIdentifier),
3274
+ t__namespace.stringLiteral("function")),
3275
+
3276
+ t__namespace.callExpression(refIdentifier, [t__namespace.identifier("r$")])))])));
3277
+
3278
+
3279
+
3280
+
3281
+
3282
+ }
3283
+ } else if (
3284
+ isDynamic(attribute.get("value").get("expression"), {
3285
+ checkMember: true,
3286
+ checkTags: true
3287
+ }))
3288
+ {
3289
+ if (
3290
+ config.wrapConditionals &&
3291
+ config.generate !== "ssr" && (
3292
+ t__namespace.isLogicalExpression(value.expression) ||
3293
+ t__namespace.isConditionalExpression(value.expression)))
3294
+ {
3295
+ const expr = transformCondition(attribute.get("value").get("expression"), true);
3296
+
3297
+ runningObject.push(
3298
+ t__namespace.objectMethod(
3299
+ "get",
3300
+ id,
3301
+ [],
3302
+ t__namespace.blockStatement([t__namespace.returnStatement(expr.body)]),
3303
+ !t__namespace.isValidIdentifier(key)));
3304
+
3305
+
3306
+ } else if (
3307
+ t__namespace.isCallExpression(value.expression) &&
3308
+ t__namespace.isArrowFunctionExpression(value.expression.callee) &&
3309
+ value.expression.callee.params.length === 0)
3310
+ {
3311
+ const callee = value.expression.callee;
3312
+ const body = t__namespace.isBlockStatement(callee.body) ?
3313
+ callee.body :
3314
+ t__namespace.blockStatement([t__namespace.returnStatement(callee.body)]);
3315
+
3316
+ runningObject.push(t__namespace.objectMethod("get", id, [], body, !t__namespace.isValidIdentifier(key)));
3317
+ } else {
3318
+ runningObject.push(
3319
+ t__namespace.objectMethod(
3320
+ "get",
3321
+ id,
3322
+ [],
3323
+ t__namespace.blockStatement([t__namespace.returnStatement(value.expression)]),
3324
+ !t__namespace.isValidIdentifier(key)));
3325
+
3326
+
3327
+ }
3328
+ } else runningObject.push(t__namespace.objectProperty(id, value.expression));} else
3329
+ runningObject.push(t__namespace.objectProperty(id, value));
3330
+ }
3331
+ });
3334
3332
 
3335
3333
  const childResult = transformComponentChildren(path.get("children"), config);
3336
3334
  if (childResult && childResult[0]) {
3337
3335
  if (childResult[1]) {
3338
3336
  const body =
3339
- t__namespace.isCallExpression(childResult[0]) && t__namespace.isFunction(childResult[0].arguments[0])
3340
- ? childResult[0].arguments[0].body
3341
- : childResult[0].body ? childResult[0].body : childResult[0];
3337
+ t__namespace.isCallExpression(childResult[0]) && t__namespace.isFunction(childResult[0].arguments[0]) ?
3338
+ childResult[0].arguments[0].body :
3339
+ childResult[0].body ? childResult[0].body : childResult[0];
3342
3340
  runningObject.push(
3343
- t__namespace.objectMethod(
3344
- "get",
3345
- t__namespace.identifier("children"),
3346
- [],
3347
- t__namespace.isExpression(body) ? t__namespace.blockStatement([t__namespace.returnStatement(body)]) : body
3348
- )
3349
- );
3341
+ t__namespace.objectMethod(
3342
+ "get",
3343
+ t__namespace.identifier("children"),
3344
+ [],
3345
+ t__namespace.isExpression(body) ? t__namespace.blockStatement([t__namespace.returnStatement(body)]) : body));
3346
+
3347
+
3350
3348
  } else runningObject.push(t__namespace.objectProperty(t__namespace.identifier("children"), childResult[0]));
3351
3349
  }
3352
3350
  if (runningObject.length || !props.length) props.push(t__namespace.objectExpression(runningObject));
@@ -3361,11 +3359,11 @@ function transformComponent(path) {
3361
3359
  if (exprs.length > 1) {
3362
3360
  const ret = exprs.pop();
3363
3361
  exprs = [
3364
- t__namespace.callExpression(
3365
- t__namespace.arrowFunctionExpression([], t__namespace.blockStatement([...exprs, t__namespace.returnStatement(ret)])),
3366
- []
3367
- )
3368
- ];
3362
+ t__namespace.callExpression(
3363
+ t__namespace.arrowFunctionExpression([], t__namespace.blockStatement([...exprs, t__namespace.returnStatement(ret)])),
3364
+ [])];
3365
+
3366
+
3369
3367
  }
3370
3368
  return { exprs, template: "", component: true };
3371
3369
  }
@@ -3391,11 +3389,11 @@ function transformComponentChildren(children, config) {
3391
3389
  });
3392
3390
  dynamic = dynamic || child.dynamic;
3393
3391
  if (
3394
- config.generate === "ssr" &&
3395
- filteredChildren.length > 1 &&
3396
- child.dynamic &&
3397
- t__namespace.isFunction(child.exprs[0])
3398
- ) {
3392
+ config.generate === "ssr" &&
3393
+ filteredChildren.length > 1 &&
3394
+ child.dynamic &&
3395
+ t__namespace.isFunction(child.exprs[0]))
3396
+ {
3399
3397
  child.exprs[0] = child.exprs[0].body;
3400
3398
  }
3401
3399
  pathNodes.push(path.node);
@@ -3407,16 +3405,16 @@ function transformComponentChildren(children, config) {
3407
3405
  if (transformedChildren.length === 1) {
3408
3406
  transformedChildren = transformedChildren[0];
3409
3407
  if (
3410
- !t__namespace.isJSXExpressionContainer(pathNodes[0]) &&
3411
- !t__namespace.isJSXSpreadChild(pathNodes[0]) &&
3412
- !t__namespace.isJSXText(pathNodes[0])
3413
- ) {
3408
+ !t__namespace.isJSXExpressionContainer(pathNodes[0]) &&
3409
+ !t__namespace.isJSXSpreadChild(pathNodes[0]) &&
3410
+ !t__namespace.isJSXText(pathNodes[0]))
3411
+ {
3414
3412
  transformedChildren =
3415
- t__namespace.isCallExpression(transformedChildren) &&
3416
- !transformedChildren.arguments.length &&
3417
- !t__namespace.isIdentifier(transformedChildren.callee)
3418
- ? transformedChildren.callee
3419
- : t__namespace.arrowFunctionExpression([], transformedChildren);
3413
+ t__namespace.isCallExpression(transformedChildren) &&
3414
+ !transformedChildren.arguments.length &&
3415
+ !t__namespace.isIdentifier(transformedChildren.callee) ?
3416
+ transformedChildren.callee :
3417
+ t__namespace.arrowFunctionExpression([], transformedChildren);
3420
3418
  dynamic = true;
3421
3419
  }
3422
3420
  } else {
@@ -3445,14 +3443,14 @@ function transformJSX(path) {
3445
3443
  const config = getConfig(path);
3446
3444
  const replace = transformThis(path);
3447
3445
  const result = transformNode(
3448
- path,
3449
- t__namespace.isJSXFragment(path.node)
3450
- ? {}
3451
- : {
3452
- topLevel: true,
3453
- lastElement: true
3454
- }
3455
- );
3446
+ path,
3447
+ t__namespace.isJSXFragment(path.node) ?
3448
+ {} :
3449
+ {
3450
+ topLevel: true,
3451
+ lastElement: true
3452
+ });
3453
+
3456
3454
 
3457
3455
  const template = getCreateTemplate(config, path, result);
3458
3456
 
@@ -3496,20 +3494,20 @@ function transformThis(path) {
3496
3494
  }
3497
3495
  }
3498
3496
  });
3499
- return node => {
3497
+ return (node) => {
3500
3498
  if (thisId) {
3501
3499
  if (!parent || parent.block.type === "ClassMethod") {
3502
3500
  const decl = t__namespace.variableDeclaration("const", [
3503
- t__namespace.variableDeclarator(thisId, t__namespace.thisExpression())
3504
- ]);
3501
+ t__namespace.variableDeclarator(thisId, t__namespace.thisExpression())]);
3502
+
3505
3503
  if (parent) {
3506
3504
  const stmt = path.getStatementParent();
3507
3505
  stmt.insertBefore(decl);
3508
3506
  } else {
3509
3507
  return t__namespace.callExpression(
3510
- t__namespace.arrowFunctionExpression([], t__namespace.blockStatement([decl, t__namespace.returnStatement(node)])),
3511
- []
3512
- );
3508
+ t__namespace.arrowFunctionExpression([], t__namespace.blockStatement([decl, t__namespace.returnStatement(node)])),
3509
+ []);
3510
+
3513
3511
  }
3514
3512
  } else {
3515
3513
  parent.push({
@@ -3536,11 +3534,11 @@ function transformNode(path, info = {}) {
3536
3534
  return results;
3537
3535
  } else if (t__namespace.isJSXText(node) || (staticValue = getStaticExpression(path)) !== false) {
3538
3536
  const text =
3539
- staticValue !== undefined
3540
- ? info.doNotEscape
3541
- ? staticValue.toString()
3542
- : escapeHTML(staticValue.toString())
3543
- : trimWhitespace(node.extra.raw);
3537
+ staticValue !== undefined ?
3538
+ info.doNotEscape ?
3539
+ staticValue.toString() :
3540
+ escapeHTML(staticValue.toString()) :
3541
+ trimWhitespace(node.extra.raw);
3544
3542
  if (!text.length) return null;
3545
3543
  const results = {
3546
3544
  template: text,
@@ -3551,56 +3549,56 @@ function transformNode(path, info = {}) {
3551
3549
  text: true
3552
3550
  };
3553
3551
  if (!info.skipId && config.generate !== "ssr")
3554
- results.id = path.scope.generateUidIdentifier("el$");
3552
+ results.id = path.scope.generateUidIdentifier("el$");
3555
3553
  return results;
3556
3554
  } else if (t__namespace.isJSXExpressionContainer(node)) {
3557
3555
  if (t__namespace.isJSXEmptyExpression(node.expression)) return null;
3558
3556
  if (
3559
- !isDynamic(path.get("expression"), {
3560
- checkMember: true,
3561
- checkTags: !!info.componentChild,
3562
- native: !info.componentChild
3563
- })
3564
- ) {
3557
+ !isDynamic(path.get("expression"), {
3558
+ checkMember: true,
3559
+ checkTags: !!info.componentChild,
3560
+ native: !info.componentChild
3561
+ }))
3562
+ {
3565
3563
  return { exprs: [node.expression], template: "" };
3566
3564
  }
3567
3565
  const expr =
3568
- config.wrapConditionals &&
3569
- config.generate !== "ssr" &&
3570
- (t__namespace.isLogicalExpression(node.expression) || t__namespace.isConditionalExpression(node.expression))
3571
- ? transformCondition(path.get("expression"), info.componentChild || info.fragmentChild)
3572
- : !info.componentChild &&
3573
- (config.generate !== "ssr" || info.fragmentChild) &&
3574
- t__namespace.isCallExpression(node.expression) &&
3575
- !t__namespace.isCallExpression(node.expression.callee) &&
3576
- !t__namespace.isMemberExpression(node.expression.callee) &&
3577
- node.expression.arguments.length === 0
3578
- ? node.expression.callee
3579
- : t__namespace.arrowFunctionExpression([], node.expression);
3566
+ config.wrapConditionals &&
3567
+ config.generate !== "ssr" && (
3568
+ t__namespace.isLogicalExpression(node.expression) || t__namespace.isConditionalExpression(node.expression)) ?
3569
+ transformCondition(path.get("expression"), info.componentChild || info.fragmentChild) :
3570
+ !info.componentChild && (
3571
+ config.generate !== "ssr" || info.fragmentChild) &&
3572
+ t__namespace.isCallExpression(node.expression) &&
3573
+ !t__namespace.isCallExpression(node.expression.callee) &&
3574
+ !t__namespace.isMemberExpression(node.expression.callee) &&
3575
+ node.expression.arguments.length === 0 ?
3576
+ node.expression.callee :
3577
+ t__namespace.arrowFunctionExpression([], node.expression);
3580
3578
  return {
3581
3579
  exprs:
3582
- expr.length > 1
3583
- ? [
3584
- t__namespace.callExpression(
3585
- t__namespace.arrowFunctionExpression(
3586
- [],
3587
- t__namespace.blockStatement([expr[0], t__namespace.returnStatement(expr[1])])
3588
- ),
3589
- []
3590
- )
3591
- ]
3592
- : [expr],
3580
+ expr.length > 1 ?
3581
+ [
3582
+ t__namespace.callExpression(
3583
+ t__namespace.arrowFunctionExpression(
3584
+ [],
3585
+ t__namespace.blockStatement([expr[0], t__namespace.returnStatement(expr[1])])),
3586
+
3587
+ [])] :
3588
+
3589
+
3590
+ [expr],
3593
3591
  template: "",
3594
3592
  dynamic: true
3595
3593
  };
3596
3594
  } else if (t__namespace.isJSXSpreadChild(node)) {
3597
3595
  if (
3598
- !isDynamic(path.get("expression"), {
3599
- checkMember: true,
3600
- native: !info.componentChild
3601
- })
3602
- )
3603
- return { exprs: [node.expression], template: "" };
3596
+ !isDynamic(path.get("expression"), {
3597
+ checkMember: true,
3598
+ native: !info.componentChild
3599
+ }))
3600
+
3601
+ return { exprs: [node.expression], template: "" };
3604
3602
  const expr = t__namespace.arrowFunctionExpression([], node.expression);
3605
3603
  return {
3606
3604
  exprs: [expr],
@@ -3611,7 +3609,7 @@ function transformNode(path, info = {}) {
3611
3609
  }
3612
3610
 
3613
3611
  function getCreateTemplate(config, path, result) {
3614
- if ((result.tagName && result.renderer === "dom") || config.generate === "dom") {
3612
+ if (result.tagName && result.renderer === "dom" || config.generate === "dom") {
3615
3613
  return createTemplate$2;
3616
3614
  }
3617
3615
 
@@ -3631,9 +3629,9 @@ function transformElement(config, path, info = {}) {
3631
3629
  // <div ...></div>
3632
3630
  // const element = getTransformElemet(config, path, tagName);
3633
3631
 
3634
- const tagRenderer = (config.renderers ?? []).find(renderer =>
3635
- renderer.elements.includes(tagName)
3636
- );
3632
+ const tagRenderer = (config.renderers ?? []).find((renderer) =>
3633
+ renderer.elements.includes(tagName));
3634
+
3637
3635
 
3638
3636
  if (tagRenderer?.name === "dom" || getConfig(path).generate === "dom") {
3639
3637
  return transformElement$3(path, info);
@@ -3647,24 +3645,24 @@ function transformElement(config, path, info = {}) {
3647
3645
  }
3648
3646
 
3649
3647
  // add to the top/bottom of the module.
3650
- var postprocess = path => {
3648
+ var postprocess = ((path) => {
3651
3649
  if (path.scope.data.events) {
3652
3650
  path.node.body.push(
3653
- t__namespace.expressionStatement(
3654
- t__namespace.callExpression(
3655
- registerImportMethod(path, "delegateEvents", getRendererConfig(path, "dom").moduleName),
3656
- [t__namespace.arrayExpression(Array.from(path.scope.data.events).map(e => t__namespace.stringLiteral(e)))]
3657
- )
3658
- )
3659
- );
3651
+ t__namespace.expressionStatement(
3652
+ t__namespace.callExpression(
3653
+ registerImportMethod(path, "delegateEvents", getRendererConfig(path, "dom").moduleName),
3654
+ [t__namespace.arrayExpression(Array.from(path.scope.data.events).map((e) => t__namespace.stringLiteral(e)))])));
3655
+
3656
+
3657
+
3660
3658
  }
3661
3659
  if (path.scope.data.templates?.length) {
3662
- let domTemplates = path.scope.data.templates.filter(temp => temp.renderer === "dom");
3663
- let ssrTemplates = path.scope.data.templates.filter(temp => temp.renderer === "ssr");
3660
+ let domTemplates = path.scope.data.templates.filter((temp) => temp.renderer === "dom");
3661
+ let ssrTemplates = path.scope.data.templates.filter((temp) => temp.renderer === "ssr");
3664
3662
  domTemplates.length > 0 && appendTemplates$1(path, domTemplates);
3665
3663
  ssrTemplates.length > 0 && appendTemplates(path, ssrTemplates);
3666
3664
  }
3667
- };
3665
+ });
3668
3666
 
3669
3667
  var config = {
3670
3668
  moduleName: "dom",
@@ -3699,15 +3697,15 @@ const JSXValidator = {
3699
3697
  if (!isComponent(parentElTagName)) {
3700
3698
  if (!isValidHTMLNesting(parentElTagName, elTagName)) {
3701
3699
  throw path.buildCodeFrameError(
3702
- `Invalid JSX: <${elTagName}> cannot be child of <${parentElTagName}>`
3703
- );
3700
+ `Invalid JSX: <${elTagName}> cannot be child of <${parentElTagName}>`);
3701
+
3704
3702
  }
3705
3703
  }
3706
3704
  }
3707
3705
  };
3708
3706
 
3709
- var preprocess = (path, { opts }) => {
3710
- const merged = (path.hub.file.metadata.config = Object.assign({}, config, opts));
3707
+ var preprocess = ((path, { opts }) => {
3708
+ const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
3711
3709
  const lib = merged.requireImportSource;
3712
3710
  if (lib) {
3713
3711
  const comments = path.hub.file.ast.comments;
@@ -3726,9 +3724,13 @@ var preprocess = (path, { opts }) => {
3726
3724
  }
3727
3725
  }
3728
3726
  if (merged.validate) path.traverse(JSXValidator);
3729
- };
3727
+ });
3728
+
3729
+ var index = (() =>
3730
+
3730
3731
 
3731
- var index = () => {
3732
+
3733
+ {
3732
3734
  return {
3733
3735
  name: "JSX DOM Expressions",
3734
3736
  inherits: SyntaxJSX.default,
@@ -3741,6 +3743,6 @@ var index = () => {
3741
3743
  }
3742
3744
  }
3743
3745
  };
3744
- };
3746
+ });
3745
3747
 
3746
3748
  module.exports = index;