babel-plugin-essor 0.0.17-beta.7 → 0.0.18-beta.1

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/dist/index.cjs +228 -106
  2. package/dist/index.js +228 -106
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -146,6 +146,7 @@ function createCompileContext(options, programPath) {
146
146
  delegateEvents: /* @__PURE__ */ new Set(),
147
147
  imports: /* @__PURE__ */ new Set(),
148
148
  importIdentifiers: createImportIdentifiers(programPath, options.mode),
149
+ signalBindings: /* @__PURE__ */ new WeakSet(),
149
150
  declarations: /* @__PURE__ */ new Map(),
150
151
  hmrComponents: /* @__PURE__ */ new Set(),
151
152
  hmrSignatures: /* @__PURE__ */ new Map(),
@@ -259,35 +260,46 @@ function createImport(path) {
259
260
  }
260
261
 
261
262
  // ../shared/dist/shared.js
262
- var p = Array.isArray;
263
+ var g = (e) => e !== null && typeof e == "object";
264
+ var m = Array.isArray;
263
265
  function i(e) {
264
266
  return typeof e == "string";
265
267
  }
266
- function g(e) {
268
+ function d(e) {
267
269
  return typeof e == "number";
268
270
  }
269
- function E(e) {
271
+ function T(e) {
270
272
  return e === null;
271
273
  }
272
- var P = (e) => u.call(e) === "[object Object]";
273
- function $(e) {
274
+ var F = (e) => {
275
+ if (u.call(e) !== "[object Object]") return false;
276
+ let t13 = Object.getPrototypeOf(e);
277
+ return t13 === null || t13 === Object.prototype;
278
+ };
279
+ function A(e) {
274
280
  return typeof e == "boolean";
275
281
  }
276
- function G(e) {
282
+ function U(e) {
277
283
  return typeof e == "bigint";
278
284
  }
279
285
  var u = Object.prototype.toString;
286
+ var f = (e) => {
287
+ let t13 = /* @__PURE__ */ Object.create(null);
288
+ return ((n) => t13[n] || (t13[n] = e(n)));
289
+ };
290
+ var ne = /\B([A-Z])/g;
291
+ var b = f((e) => e.replaceAll(ne, "-$1").toLowerCase());
280
292
  function x(e, t13) {
281
293
  return i(e) ? e.indexOf(t13) === 0 : false;
282
294
  }
283
- function re(e, ...t13) {
295
+ function se(e, ...t13) {
284
296
  console.warn(`[Essor warn]: ${e}`, ...t13);
285
297
  }
286
- var ae = /["&'<>]/;
287
- function le(e) {
288
- let t13 = `${e}`, n = ae.exec(t13);
298
+ var ce = /["&'<>]/;
299
+ function pe(e) {
300
+ let t13 = `${e}`, n = ce.exec(t13);
289
301
  if (!n) return t13;
290
- let o = "", r, s, m = 0;
302
+ let o = "", r, s, l = 0;
291
303
  for (s = n.index; s < t13.length; s++) {
292
304
  switch (t13.charCodeAt(s)) {
293
305
  case 34:
@@ -308,35 +320,71 @@ function le(e) {
308
320
  default:
309
321
  continue;
310
322
  }
311
- m !== s && (o += t13.slice(m, s)), m = s + 1, o += r;
323
+ l !== s && (o += t13.slice(l, s)), l = s + 1, o += r;
312
324
  }
313
- return m !== s ? o + t13.slice(m, s) : o;
325
+ return l !== s ? o + t13.slice(l, s) : o;
314
326
  }
315
327
  function a(e) {
316
328
  let t13 = /* @__PURE__ */ Object.create(null);
317
329
  for (let n of e.split(",")) t13[n] = 1;
318
330
  return (n) => n in t13;
319
331
  }
320
- var w = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";
321
- a(w);
322
- a(`${w},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
323
- var xe = { acceptCharset: "accept-charset", className: "class", htmlFor: "for", httpEquiv: "http-equiv" };
332
+ var N = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";
333
+ a(N);
334
+ a(`${N},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
335
+ var ke = { acceptCharset: "accept-charset", className: "class", htmlFor: "for", httpEquiv: "http-equiv" };
324
336
  a("accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap");
325
337
  a("xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan");
326
- var we = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
327
- var Te = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
328
- var Se = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
329
- var ve = "beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart";
330
- var Ae = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
331
- a(we);
332
- var Ne = a(Te);
338
+ var Se = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
339
+ var ve = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
340
+ var Ae = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
341
+ var Ee = "beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart";
342
+ var Ne = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
333
343
  a(Se);
334
- var Ce = a(Ae);
335
- var Oe = a(ve);
336
- var Re = "data-hk-idx";
337
- var ze = "_$spread$";
338
-
339
- // src/ast-utils.ts
344
+ var Ce = a(ve);
345
+ a(Ae);
346
+ var Re = a(Ne);
347
+ var ze = a(Ee);
348
+ var je = "data-hk-idx";
349
+ var He = "_$spread$";
350
+ var $e = /;(?![^(]*\))/g;
351
+ var Ue = /:([\s\S]+)/;
352
+ var Ge = /\/\*[\s\S]*?\*\//g;
353
+ function k(e) {
354
+ let t13 = {};
355
+ return e.replaceAll(Ge, "").split($e).forEach((n) => {
356
+ if (n) {
357
+ let o = n.split(Ue);
358
+ o.length > 1 && (t13[o[0].trim()] = o[1].trim());
359
+ }
360
+ }), t13;
361
+ }
362
+ function w(e) {
363
+ if (m(e)) {
364
+ let t13 = {};
365
+ for (let n of e) {
366
+ let o = i(n) ? k(n) : w(n);
367
+ if (o) for (let r in o) t13[r] = o[r];
368
+ }
369
+ return t13;
370
+ }
371
+ if (i(e)) return e;
372
+ if (g(e)) {
373
+ let t13 = {};
374
+ for (let n in e) {
375
+ let o = e[n];
376
+ if (i(o) || d(o)) {
377
+ t13[n] = o;
378
+ continue;
379
+ }
380
+ let r = w(o);
381
+ if (!r) continue;
382
+ let s = i(r) ? k(r) : r;
383
+ for (let l in s) t13[l] = s[l];
384
+ }
385
+ return t13;
386
+ }
387
+ }
340
388
  function isAnyFunctionPath(path) {
341
389
  return path.isFunctionDeclaration() || path.isFunctionExpression() || path.isArrowFunctionExpression();
342
390
  }
@@ -398,7 +446,7 @@ function serializeStaticAttrs(attrs) {
398
446
  const merged = [];
399
447
  let classValue;
400
448
  for (const attr of attrs) {
401
- const name = (_a = xe[attr.name]) != null ? _a : attr.name;
449
+ const name = (_a = ke[attr.name]) != null ? _a : attr.name;
402
450
  if (name === "class") {
403
451
  classValue = classValue ? `${classValue} ${attr.value}` : String(attr.value);
404
452
  } else {
@@ -408,7 +456,7 @@ function serializeStaticAttrs(attrs) {
408
456
  if (classValue) merged.unshift({ name: "class", value: classValue });
409
457
  return merged.map((attr) => {
410
458
  if (attr.value === true) return ` ${attr.name}`;
411
- return ` ${attr.name}="${le(attr.value)}"`;
459
+ return ` ${attr.name}="${pe(attr.value)}"`;
412
460
  }).join("");
413
461
  }
414
462
  function resolveComponentCallee(tag, fallback) {
@@ -427,16 +475,16 @@ function isSerializableStaticValue(value) {
427
475
  const stack = [value];
428
476
  while (stack.length > 0) {
429
477
  const current = stack.pop();
430
- if (E(current) || $(current) || g(current) || i(current) || G(current)) {
478
+ if (T(current) || A(current) || d(current) || i(current) || U(current)) {
431
479
  continue;
432
480
  }
433
- if (p(current)) {
481
+ if (m(current)) {
434
482
  for (const item of current) {
435
483
  stack.push(item);
436
484
  }
437
485
  continue;
438
486
  }
439
- if (!P(current)) {
487
+ if (!F(current)) {
440
488
  return false;
441
489
  }
442
490
  const values = Object.values(current);
@@ -447,21 +495,29 @@ function isSerializableStaticValue(value) {
447
495
  return true;
448
496
  }
449
497
  function styleToString(style) {
450
- return Object.entries(style).map(([key, value]) => {
451
- const kebabKey = key.replaceAll(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
452
- return `${kebabKey}:${value}`;
453
- }).join(";");
498
+ const normalized = w(style);
499
+ if (!normalized) return void 0;
500
+ if (i(normalized)) return normalized;
501
+ const parts = [];
502
+ for (const key in normalized) {
503
+ const value = normalized[key];
504
+ if (i(value) || d(value)) {
505
+ const prop = x(key, "--") ? key : b(key);
506
+ parts.push(`${prop}:${value}`);
507
+ }
508
+ }
509
+ return parts.join(";");
454
510
  }
455
511
  function shouldResolveStaticCollection(attrName) {
456
512
  return attrName !== "ref" && !x(attrName, "bind:") && !normalizeEventName(attrName);
457
513
  }
458
514
  function normalizeTemplateAttrName(attrName) {
459
515
  var _a;
460
- return (_a = xe[attrName]) != null ? _a : attrName;
516
+ return (_a = ke[attrName]) != null ? _a : attrName;
461
517
  }
462
518
  function createStaticAttr(attrName, value, order) {
463
519
  return {
464
- attr: { name: attrName, value },
520
+ attr: { name: attrName, value, order },
465
521
  order,
466
522
  templateName: normalizeTemplateAttrName(attrName)
467
523
  };
@@ -472,7 +528,8 @@ function createDynamicAttr(attrPath, attrName, value, effectKind, order) {
472
528
  path: attrPath,
473
529
  name: attrName,
474
530
  value,
475
- effectKind
531
+ effectKind,
532
+ order
476
533
  },
477
534
  order,
478
535
  templateName: normalizeTemplateAttrName(attrName)
@@ -487,13 +544,15 @@ function resolveStaticExpressionValue(attrName, expressionPath) {
487
544
  return void 0;
488
545
  }
489
546
  let value = evaluated.value;
490
- if (attrName === "style" && P(value)) {
491
- value = styleToString(value);
547
+ if (attrName === "style") {
548
+ const style = styleToString(value);
549
+ if (style === void 0) return void 0;
550
+ value = style;
492
551
  }
493
- if (i(value) || $(value)) {
552
+ if (i(value) || A(value)) {
494
553
  return value;
495
554
  }
496
- if (g(value)) {
555
+ if (d(value)) {
497
556
  return String(value);
498
557
  }
499
558
  return void 0;
@@ -546,7 +605,8 @@ function parseAttributes(path) {
546
605
  if (attrPath.isJSXSpreadAttribute()) {
547
606
  spreadAttrs.push({
548
607
  value: attrPath.node.argument,
549
- effectKind: classifyAttrValue(attrPath.node.argument).kind
608
+ effectKind: classifyAttrValue(attrPath.node.argument).kind,
609
+ order
550
610
  });
551
611
  continue;
552
612
  }
@@ -634,7 +694,7 @@ function unwrapTopLevelDeclaration(statementPath) {
634
694
  }
635
695
  if (statementPath.isExportNamedDeclaration() || statementPath.isExportDefaultDeclaration()) {
636
696
  const declarationPath = statementPath.get("declaration");
637
- if (declarationPath && !Array.isArray(declarationPath) && (declarationPath.isFunctionDeclaration() || declarationPath.isVariableDeclaration())) {
697
+ if (declarationPath && !m(declarationPath) && (declarationPath.isFunctionDeclaration() || declarationPath.isVariableDeclaration())) {
638
698
  return declarationPath;
639
699
  }
640
700
  }
@@ -1043,7 +1103,7 @@ function patternHasSignalBinding(node) {
1043
1103
  if (types.isIdentifier(node)) return isSignal(node.name);
1044
1104
  if (types.isObjectPattern(node)) {
1045
1105
  return node.properties.some(
1046
- (p2) => types.isRestElement(p2) ? patternHasSignalBinding(p2.argument) : patternHasSignalBinding(p2.value)
1106
+ (p) => types.isRestElement(p) ? patternHasSignalBinding(p.argument) : patternHasSignalBinding(p.value)
1047
1107
  );
1048
1108
  }
1049
1109
  if (types.isArrayPattern(node)) {
@@ -1191,9 +1251,9 @@ function isAlreadyValueAccess(path) {
1191
1251
  if (!types.isParenthesizedExpression(parent) && !types.isTSAsExpression(parent) && !types.isTSNonNullExpression(parent)) {
1192
1252
  return false;
1193
1253
  }
1194
- const ancestor = path.findParent((p2) => {
1195
- if (!isMemberLike(p2.node)) return false;
1196
- return isMemberAccessingProperty(p2.node, "value");
1254
+ const ancestor = path.findParent((p) => {
1255
+ if (!isMemberLike(p.node)) return false;
1256
+ return isMemberAccessingProperty(p.node, "value");
1197
1257
  });
1198
1258
  return !!ancestor;
1199
1259
  }
@@ -1288,7 +1348,7 @@ function collectObjectPattern(pattern, base, leaves, rests) {
1288
1348
  continue;
1289
1349
  }
1290
1350
  const { keyExpr, computed, excludeKey } = resolveKey(prop);
1291
- if (excludeKey !== null) excludeKeys.push(excludeKey);
1351
+ if (!T(excludeKey)) excludeKeys.push(excludeKey);
1292
1352
  const access = types.memberExpression(clone2(base), keyExpr, computed);
1293
1353
  collectTarget(prop.value, access, leaves, rests);
1294
1354
  }
@@ -1320,7 +1380,7 @@ function ensureBlockBody(path) {
1320
1380
  return block;
1321
1381
  }
1322
1382
  function isInsidePattern(ref, pattern) {
1323
- return !!ref.findParent((p2) => p2.node === pattern);
1383
+ return !!ref.findParent((p) => p.node === pattern);
1324
1384
  }
1325
1385
  function accessorFor(pattern, base, name) {
1326
1386
  var _a;
@@ -1340,7 +1400,7 @@ function transformFnProps(path) {
1340
1400
  collectObjectPattern(firstParam, base, initLeaves, initRests);
1341
1401
  const conflicts = [...initLeaves, ...initRests].map((b2) => b2.name).filter((name) => x(name, signalPrefix));
1342
1402
  if (conflicts.length > 0) {
1343
- re("transformProps", "Property names cannot start with signal prefix", conflicts);
1403
+ se("transformProps", "Property names cannot start with signal prefix", conflicts);
1344
1404
  }
1345
1405
  if (initLeaves.length === 0 && initRests.length === 1 && firstParam.properties.length === 1 && types.isRestElement(firstParam.properties[0])) {
1346
1406
  path.node.params[0] = types.identifier(initRests[0].name);
@@ -1396,11 +1456,15 @@ function createPatchCall(importFn, target, attrName, value, options = {}) {
1396
1456
  const { helper, name } = getPatchHelper(attrName);
1397
1457
  const nextValue = (_a = options.nextValue) != null ? _a : value;
1398
1458
  const isAttr = helper === "patchAttr";
1459
+ const emitSVGFlag = helper === "patchClass" && options.isSVG === true;
1399
1460
  const args = isAttr ? [target, types.stringLiteral(name)] : [target];
1400
- if (options.previousValue != null || options.includePreviousValuePlaceholder) {
1461
+ if (options.previousValue != null || options.includePreviousValuePlaceholder || emitSVGFlag) {
1401
1462
  args.push((_b = options.previousValue) != null ? _b : types.identifier("undefined"));
1402
1463
  }
1403
1464
  args.push(nextValue);
1465
+ if (emitSVGFlag) {
1466
+ args.push(types.booleanLiteral(true));
1467
+ }
1404
1468
  return types.callExpression(importFn(helper), args);
1405
1469
  }
1406
1470
  function createRefExpression(target, value) {
@@ -1448,6 +1512,18 @@ function hasDynamicBoundary(children, index) {
1448
1512
  const isDynamic = (n) => (n == null ? void 0 : n.type) === 3 /* EXPRESSION */ || (n == null ? void 0 : n.type) === 1 /* COMPONENT */ || (n == null ? void 0 : n.type) === 4 /* FOR */;
1449
1513
  return isText(prev) || isText(next) || isDynamic(prev) || isDynamic(next);
1450
1514
  }
1515
+ function getDynamicAnchorKind(children, index, mode) {
1516
+ if (!hasDynamicBoundary(children, index)) {
1517
+ const next = children[index + 1];
1518
+ if ((mode === "hydrate" || mode === "server") && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
1519
+ return "element";
1520
+ }
1521
+ if (!next) {
1522
+ return "tail";
1523
+ }
1524
+ }
1525
+ return "comment";
1526
+ }
1451
1527
  function buildIR(path, ctx) {
1452
1528
  if (path.isJSXFragment()) {
1453
1529
  useImport("Fragment");
@@ -1464,14 +1540,14 @@ function buildElementIR(tag, path, ctx) {
1464
1540
  const node = {
1465
1541
  type: 0 /* ELEMENT */,
1466
1542
  tag,
1467
- isSVG: Ne(tag),
1543
+ isSVG: Ce(tag),
1468
1544
  staticAttrs,
1469
1545
  dynamicAttrs: [],
1470
1546
  events: [],
1471
- spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
1547
+ spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
1472
1548
  binds: [],
1473
1549
  children: [],
1474
- selfClosing: Ce(tag),
1550
+ selfClosing: Re(tag),
1475
1551
  loc: path.node.loc
1476
1552
  };
1477
1553
  for (const attr of dynamicAttrs) {
@@ -1491,7 +1567,8 @@ function buildComponentIR(tag, path, ctx) {
1491
1567
  props.push({
1492
1568
  name: attr.name,
1493
1569
  value: i(attr.value) ? types.stringLiteral(attr.value) : types.booleanLiteral(attr.value),
1494
- kind: "static"
1570
+ kind: "static",
1571
+ order: attr.order
1495
1572
  });
1496
1573
  }
1497
1574
  for (const attr of dynamicAttrs) {
@@ -1500,7 +1577,8 @@ function buildComponentIR(tag, path, ctx) {
1500
1577
  props.push({
1501
1578
  name: attr.name,
1502
1579
  value: attr.value,
1503
- kind: attr.effectKind
1580
+ kind: attr.effectKind,
1581
+ order: attr.order
1504
1582
  });
1505
1583
  } else if (x(attr.name, "bind:")) {
1506
1584
  const binding = attr.name.slice("bind:".length);
@@ -1511,18 +1589,21 @@ function buildComponentIR(tag, path, ctx) {
1511
1589
  props.push({
1512
1590
  name: binding,
1513
1591
  value: types.cloneNode(valueExpr),
1514
- kind: attr.effectKind
1592
+ kind: attr.effectKind,
1593
+ order: attr.order
1515
1594
  });
1516
1595
  props.push({
1517
1596
  name: `update:${binding}`,
1518
1597
  value: createBindingSetter(valueExpr),
1519
- kind: "static"
1598
+ kind: "static",
1599
+ order: attr.order
1520
1600
  });
1521
1601
  } else {
1522
1602
  props.push({
1523
1603
  name: attr.name,
1524
1604
  value: attr.value,
1525
- kind: attr.effectKind
1605
+ kind: attr.effectKind,
1606
+ order: attr.order
1526
1607
  });
1527
1608
  }
1528
1609
  }
@@ -1530,7 +1611,7 @@ function buildComponentIR(tag, path, ctx) {
1530
1611
  type: 1 /* COMPONENT */,
1531
1612
  tag,
1532
1613
  props,
1533
- spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
1614
+ spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
1534
1615
  children: buildChildren(path, ctx),
1535
1616
  loc: path.node.loc
1536
1617
  };
@@ -1539,7 +1620,7 @@ function applyDynamicAttr(node, attr, ctx) {
1539
1620
  const { name, value, effectKind, path } = attr;
1540
1621
  const eventName = normalizeEventName(name);
1541
1622
  if (eventName) {
1542
- const delegated = !!(ctx.options.delegateEvents && Oe(eventName));
1623
+ const delegated = !!(ctx.options.delegateEvents && ze(eventName));
1543
1624
  node.events.push({
1544
1625
  name: eventName,
1545
1626
  handler: value,
@@ -1627,7 +1708,7 @@ function isPropsChildrenExpression(expression) {
1627
1708
  const binding = expression.scope.getBinding(node.object.name);
1628
1709
  const bindingPath = binding == null ? void 0 : binding.path;
1629
1710
  if (!(bindingPath == null ? void 0 : bindingPath.isIdentifier())) return false;
1630
- const owner = bindingPath.findParent((p2) => isAnyFunctionPath(p2));
1711
+ const owner = bindingPath.findParent((p) => isAnyFunctionPath(p));
1631
1712
  if (!owner) return false;
1632
1713
  const fn = owner.node;
1633
1714
  const componentName = getEnclosingFunctionName(owner);
@@ -1690,6 +1771,7 @@ function buildForIR(expression, ctx) {
1690
1771
  };
1691
1772
  }
1692
1773
  function extractKeyExpression(path) {
1774
+ if (path.isJSXFragment()) return extractFragmentKeyExpression(path);
1693
1775
  if (!path.isJSXElement()) return null;
1694
1776
  for (const attrPath of path.get("openingElement.attributes")) {
1695
1777
  if (!attrPath.isJSXAttribute()) continue;
@@ -1704,7 +1786,7 @@ function extractKeyExpression(path) {
1704
1786
  return types.stringLiteral(value.value);
1705
1787
  }
1706
1788
  const valuePath = attrPath.get("value");
1707
- if (!Array.isArray(valuePath) && valuePath.isJSXExpressionContainer()) {
1789
+ if (!m(valuePath) && valuePath.isJSXExpressionContainer()) {
1708
1790
  const expressionPath = valuePath.get("expression");
1709
1791
  attrPath.remove();
1710
1792
  if (expressionPath.isJSXEmptyExpression()) return null;
@@ -1715,9 +1797,16 @@ function extractKeyExpression(path) {
1715
1797
  }
1716
1798
  return null;
1717
1799
  }
1800
+ function extractFragmentKeyExpression(path) {
1801
+ const children = path.get("children").filter(isValidChild);
1802
+ if (children.length !== 1) return null;
1803
+ const child = children[0];
1804
+ if (!child.isJSXElement() && !child.isJSXFragment()) return null;
1805
+ return extractKeyExpression(child);
1806
+ }
1718
1807
  function getForCallbackBody(callback) {
1719
1808
  const bodyPath = callback.get("body");
1720
- if (Array.isArray(bodyPath)) return null;
1809
+ if (m(bodyPath)) return null;
1721
1810
  if (bodyPath.isJSXElement() || bodyPath.isJSXFragment()) {
1722
1811
  return {
1723
1812
  path: bodyPath,
@@ -1734,7 +1823,7 @@ function getForCallbackBody(callback) {
1734
1823
  continue;
1735
1824
  }
1736
1825
  const argument = statement.get("argument");
1737
- if (Array.isArray(argument) || !argument.node) {
1826
+ if (m(argument) || !argument.node) {
1738
1827
  prelude.push(statement.node);
1739
1828
  continue;
1740
1829
  }
@@ -1810,16 +1899,55 @@ function createPropNode(name, value, kind, options) {
1810
1899
  function composePropsExpression(props, spreads, options) {
1811
1900
  if (spreads.length === 0) {
1812
1901
  if (props.length === 0) return types.objectExpression([]);
1813
- return types.objectExpression(props.map((p2) => createPropNode(p2.name, p2.value, p2.kind, options)));
1902
+ return types.objectExpression(props.map((p) => createPropNode(p.name, p.value, p.kind, options)));
1903
+ }
1904
+ if (props.some((prop) => prop.order == null) || spreads.some((spread) => spread.order == null)) {
1905
+ return composeUnorderedPropsExpression(props, spreads, options);
1906
+ }
1907
+ const ordered = [
1908
+ ...props.map((prop, sequence) => ({
1909
+ type: "prop",
1910
+ order: prop.order,
1911
+ sequence,
1912
+ prop
1913
+ })),
1914
+ ...spreads.map((spread, sequence) => ({
1915
+ type: "spread",
1916
+ order: spread.order,
1917
+ sequence,
1918
+ spread
1919
+ }))
1920
+ ].sort((a2, b2) => a2.order - b2.order || a2.sequence - b2.sequence);
1921
+ const parts = [];
1922
+ let propNodes = [];
1923
+ const flushProps = () => {
1924
+ if (propNodes.length === 0) return;
1925
+ parts.push(types.objectExpression(propNodes));
1926
+ propNodes = [];
1927
+ };
1928
+ for (const entry of ordered) {
1929
+ if (entry.type === "prop") {
1930
+ propNodes.push(createPropNode(entry.prop.name, entry.prop.value, entry.prop.kind, options));
1931
+ continue;
1932
+ }
1933
+ flushProps();
1934
+ parts.push(cloneValue(entry.spread.value, options.cloneValues));
1814
1935
  }
1936
+ flushProps();
1937
+ return composeAssignParts(parts);
1938
+ }
1939
+ function composeUnorderedPropsExpression(props, spreads, options) {
1815
1940
  const parts = [];
1816
- const propNodes = props.map((p2) => createPropNode(p2.name, p2.value, p2.kind, options));
1941
+ const propNodes = props.map((p) => createPropNode(p.name, p.value, p.kind, options));
1817
1942
  if (propNodes.length > 0) {
1818
1943
  parts.push(types.objectExpression(propNodes));
1819
1944
  }
1820
1945
  for (const spread of spreads) {
1821
1946
  parts.push(cloneValue(spread.value, options.cloneValues));
1822
1947
  }
1948
+ return composeAssignParts(parts);
1949
+ }
1950
+ function composeAssignParts(parts) {
1823
1951
  if (parts.length === 0) return types.objectExpression([]);
1824
1952
  if (parts.length === 1) return parts[0];
1825
1953
  return types.callExpression(types.memberExpression(types.identifier("Object"), types.identifier("assign")), [
@@ -2091,7 +2219,7 @@ function generateServerFor(node, ctx) {
2091
2219
  return buildForCall(node, bodyExpr);
2092
2220
  }
2093
2221
  function generateServerElement(node, ctx, withHydrationKey = true, staticIndex, options = {}) {
2094
- var _a, _b;
2222
+ var _a;
2095
2223
  const dynamicAttrExprs = [...(_a = options.prependAttrExprs) != null ? _a : []];
2096
2224
  for (const attr of node.dynamicAttrs) {
2097
2225
  let expr;
@@ -2119,7 +2247,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
2119
2247
  }
2120
2248
  const templates = [];
2121
2249
  const expressions = [];
2122
- const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: Re, value: String(staticIndex) }];
2250
+ const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
2123
2251
  const attrs = serializeStaticAttrs(staticAttrs);
2124
2252
  const textareaValueBind = node.tag === "textarea" ? findBind(node, "value") : null;
2125
2253
  let currentStr = `<${node.tag}`;
@@ -2150,11 +2278,11 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
2150
2278
  if (child.type === 2 /* TEXT */) {
2151
2279
  currentStr += escapeServerTemplateText(child.value);
2152
2280
  } else if (child.type === 3 /* EXPRESSION */ || child.type === 1 /* COMPONENT */ || child.type === 4 /* FOR */) {
2153
- const marker = hasDynamicBoundary(node.children, i2);
2281
+ const anchorKind = getDynamicAnchorKind(node.children, i2, "server");
2154
2282
  const slotIndex = markerIndex++;
2155
2283
  templates.push(currentStr);
2156
- currentStr = marker ? `<!--${slotIndex}-->` : "";
2157
- if (!marker && ((_b = node.children[i2 + 1]) == null ? void 0 : _b.type) === 0 /* ELEMENT */) {
2284
+ currentStr = anchorKind === "comment" ? `<!--${slotIndex}-->` : "";
2285
+ if (anchorKind === "element") {
2158
2286
  pendingAnchorIndex = slotIndex;
2159
2287
  }
2160
2288
  expressions.push(generateServerNode(child, ctx));
@@ -2177,7 +2305,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
2177
2305
  }
2178
2306
  }
2179
2307
  const staticHTML = buildStaticServerHTML(child, anchorIndex);
2180
- if (staticHTML !== null) {
2308
+ if (!T(staticHTML)) {
2181
2309
  currentStr += staticHTML;
2182
2310
  } else {
2183
2311
  templates.push(currentStr);
@@ -2222,7 +2350,7 @@ function buildStaticServerHTML(node, staticIndex) {
2222
2350
  if (node.binds.length > 0 || node.dynamicAttrs.length > 0 || node.spreads.length > 0) {
2223
2351
  return null;
2224
2352
  }
2225
- const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: Re, value: String(staticIndex) }];
2353
+ const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
2226
2354
  const attrs = serializeStaticAttrs(staticAttrs);
2227
2355
  if (node.selfClosing) {
2228
2356
  return `<${node.tag}${attrs} />`;
@@ -2234,7 +2362,7 @@ function buildStaticServerHTML(node, staticIndex) {
2234
2362
  } else if (child.type === 0 /* ELEMENT */) {
2235
2363
  if (child.binds.length > 0) return null;
2236
2364
  const nested = buildStaticServerHTML(child);
2237
- if (nested === null) return null;
2365
+ if (T(nested)) return null;
2238
2366
  html += nested;
2239
2367
  } else {
2240
2368
  return null;
@@ -2272,18 +2400,6 @@ function shouldCloseTag(element, isLastElement, hasClosingParent, options) {
2272
2400
  function closeTag(element, isLastElement, hasClosingParent, options) {
2273
2401
  return shouldCloseTag(element, isLastElement, hasClosingParent, options) ? `</${element.tag}>` : "";
2274
2402
  }
2275
- function getDynamicAnchorKind(children, index, mode) {
2276
- if ((mode === "client" || mode === "hydrate") && !hasDynamicBoundary(children, index)) {
2277
- const next = children[index + 1];
2278
- if (mode === "hydrate" && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
2279
- return "element";
2280
- }
2281
- if (!next) {
2282
- return "tail";
2283
- }
2284
- }
2285
- return "comment";
2286
- }
2287
2403
  function findLastOmittableElementIndex(children, mode) {
2288
2404
  for (let i2 = children.length - 1; i2 >= 0; i2--) {
2289
2405
  const child = children[i2];
@@ -2308,7 +2424,7 @@ function buildTemplateAndFlatten(root, mode) {
2308
2424
  const myId = nextId++;
2309
2425
  const staticAttrs = mode === "hydrate" && forcedStaticIndex !== void 0 ? [
2310
2426
  ...element.staticAttrs,
2311
- { name: Re, value: String(forcedStaticIndex) }
2427
+ { name: je, value: String(forcedStaticIndex) }
2312
2428
  ] : element.staticAttrs;
2313
2429
  const attrs = serializeStaticAttrs(staticAttrs);
2314
2430
  if (element.selfClosing) {
@@ -2347,7 +2463,7 @@ function buildTemplateAndFlatten(root, mode) {
2347
2463
  const child = element.children[i2];
2348
2464
  switch (child.type) {
2349
2465
  case 2 /* TEXT */:
2350
- template += mode === "hydrate" ? child.value : le(child.value);
2466
+ template += mode === "hydrate" ? child.value : pe(child.value);
2351
2467
  nodes.push({
2352
2468
  id: nextId++,
2353
2469
  kind: "text",
@@ -2414,7 +2530,7 @@ function buildStaticTemplateString(node, mode) {
2414
2530
  function visit(current, isLastElement, hasClosingParent) {
2415
2531
  switch (current.type) {
2416
2532
  case 2 /* TEXT */:
2417
- return mode === "hydrate" ? current.value : le(current.value);
2533
+ return mode === "hydrate" ? current.value : pe(current.value);
2418
2534
  case 0 /* ELEMENT */: {
2419
2535
  const attrs = serializeStaticAttrs(current.staticAttrs);
2420
2536
  if (current.selfClosing) return selfClosingTag(current, attrs);
@@ -2610,10 +2726,10 @@ function emitElementEffect(element, target, state, body, pendingMemoPatches) {
2610
2726
  emitBind(bind, target, body);
2611
2727
  }
2612
2728
  for (const attr of element.dynamicAttrs) {
2613
- emitDynamicAttr(attr, target, body, state, pendingMemoPatches);
2729
+ emitDynamicAttr(attr, target, body, state, pendingMemoPatches, element.isSVG);
2614
2730
  }
2615
2731
  for (const spread of element.spreads) {
2616
- emitSpread(spread, target, body, state, pendingMemoPatches);
2732
+ emitSpread(spread, target, body, state, pendingMemoPatches, element.isSVG);
2617
2733
  }
2618
2734
  }
2619
2735
  function emitDynamicChildInserts(flatNodes, varMap, state, body) {
@@ -2703,7 +2819,7 @@ function emitBind(bind, target, body) {
2703
2819
  if (modifiersArg) args.push(types.cloneNode(modifiersArg));
2704
2820
  body.push(types.expressionStatement(types.callExpression(useImport("bindElement"), args)));
2705
2821
  }
2706
- function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
2822
+ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches, isSVG) {
2707
2823
  emitPatchOrEffect(
2708
2824
  target,
2709
2825
  attr.name,
@@ -2711,30 +2827,35 @@ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
2711
2827
  attr.kind,
2712
2828
  body,
2713
2829
  () => createEffectKey(attr.name, state.effectIndex++),
2714
- pendingMemoPatches
2830
+ pendingMemoPatches,
2831
+ isSVG
2715
2832
  );
2716
2833
  }
2717
- function emitSpread(spread, target, body, state, pendingMemoPatches) {
2834
+ function emitSpread(spread, target, body, state, pendingMemoPatches, isSVG) {
2718
2835
  emitPatchOrEffect(
2719
2836
  target,
2720
- ze,
2837
+ He,
2721
2838
  spread.value,
2722
2839
  spread.kind,
2723
2840
  body,
2724
2841
  () => createSpreadEffectKey(state.effectIndex++),
2725
- pendingMemoPatches
2842
+ pendingMemoPatches,
2843
+ isSVG
2726
2844
  );
2727
2845
  }
2728
- function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches) {
2846
+ function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches, isSVG) {
2729
2847
  if (kind === "static") {
2730
- body.push(types.expressionStatement(createPatchCall(useImport, target, attrName, value)));
2848
+ body.push(
2849
+ types.expressionStatement(createPatchCall(useImport, target, attrName, value, { isSVG }))
2850
+ );
2731
2851
  return;
2732
2852
  }
2733
2853
  pendingMemoPatches.push({
2734
2854
  effectKey: getEffectKey(),
2735
2855
  target,
2736
2856
  attrName,
2737
- value
2857
+ value,
2858
+ isSVG
2738
2859
  });
2739
2860
  }
2740
2861
  function emitMergedMemoEffect(patches, body) {
@@ -2756,7 +2877,8 @@ function createMemoPatchStatements(patch, memoStateId) {
2756
2877
  const valueId = genUid(MEMO_NEXT_VALUE_ID);
2757
2878
  const updateCall = createPatchCall(useImport, patch.target, patch.attrName, valueId, {
2758
2879
  previousValue: effectState,
2759
- nextValue: types.assignmentExpression("=", effectState, valueId)
2880
+ nextValue: types.assignmentExpression("=", effectState, valueId),
2881
+ isSVG: patch.isSVG
2760
2882
  });
2761
2883
  return [
2762
2884
  types.variableDeclaration("let", [types.variableDeclarator(valueId, types.cloneNode(patch.value, true))]),