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.
- package/dist/index.cjs +228 -106
- package/dist/index.js +228 -106
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -148,6 +148,7 @@ function createCompileContext(options, programPath) {
|
|
|
148
148
|
delegateEvents: /* @__PURE__ */ new Set(),
|
|
149
149
|
imports: /* @__PURE__ */ new Set(),
|
|
150
150
|
importIdentifiers: createImportIdentifiers(programPath, options.mode),
|
|
151
|
+
signalBindings: /* @__PURE__ */ new WeakSet(),
|
|
151
152
|
declarations: /* @__PURE__ */ new Map(),
|
|
152
153
|
hmrComponents: /* @__PURE__ */ new Set(),
|
|
153
154
|
hmrSignatures: /* @__PURE__ */ new Map(),
|
|
@@ -261,35 +262,46 @@ function createImport(path) {
|
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
// ../shared/dist/shared.js
|
|
264
|
-
var
|
|
265
|
+
var g = (e) => e !== null && typeof e == "object";
|
|
266
|
+
var m = Array.isArray;
|
|
265
267
|
function i(e) {
|
|
266
268
|
return typeof e == "string";
|
|
267
269
|
}
|
|
268
|
-
function
|
|
270
|
+
function d(e) {
|
|
269
271
|
return typeof e == "number";
|
|
270
272
|
}
|
|
271
|
-
function
|
|
273
|
+
function T(e) {
|
|
272
274
|
return e === null;
|
|
273
275
|
}
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
+
var F = (e) => {
|
|
277
|
+
if (u.call(e) !== "[object Object]") return false;
|
|
278
|
+
let t13 = Object.getPrototypeOf(e);
|
|
279
|
+
return t13 === null || t13 === Object.prototype;
|
|
280
|
+
};
|
|
281
|
+
function A(e) {
|
|
276
282
|
return typeof e == "boolean";
|
|
277
283
|
}
|
|
278
|
-
function
|
|
284
|
+
function U(e) {
|
|
279
285
|
return typeof e == "bigint";
|
|
280
286
|
}
|
|
281
287
|
var u = Object.prototype.toString;
|
|
288
|
+
var f = (e) => {
|
|
289
|
+
let t13 = /* @__PURE__ */ Object.create(null);
|
|
290
|
+
return ((n) => t13[n] || (t13[n] = e(n)));
|
|
291
|
+
};
|
|
292
|
+
var ne = /\B([A-Z])/g;
|
|
293
|
+
var b = f((e) => e.replaceAll(ne, "-$1").toLowerCase());
|
|
282
294
|
function x(e, t13) {
|
|
283
295
|
return i(e) ? e.indexOf(t13) === 0 : false;
|
|
284
296
|
}
|
|
285
|
-
function
|
|
297
|
+
function se(e, ...t13) {
|
|
286
298
|
console.warn(`[Essor warn]: ${e}`, ...t13);
|
|
287
299
|
}
|
|
288
|
-
var
|
|
289
|
-
function
|
|
290
|
-
let t13 = `${e}`, n =
|
|
300
|
+
var ce = /["&'<>]/;
|
|
301
|
+
function pe(e) {
|
|
302
|
+
let t13 = `${e}`, n = ce.exec(t13);
|
|
291
303
|
if (!n) return t13;
|
|
292
|
-
let o = "", r, s,
|
|
304
|
+
let o = "", r, s, l = 0;
|
|
293
305
|
for (s = n.index; s < t13.length; s++) {
|
|
294
306
|
switch (t13.charCodeAt(s)) {
|
|
295
307
|
case 34:
|
|
@@ -310,35 +322,71 @@ function le(e) {
|
|
|
310
322
|
default:
|
|
311
323
|
continue;
|
|
312
324
|
}
|
|
313
|
-
|
|
325
|
+
l !== s && (o += t13.slice(l, s)), l = s + 1, o += r;
|
|
314
326
|
}
|
|
315
|
-
return
|
|
327
|
+
return l !== s ? o + t13.slice(l, s) : o;
|
|
316
328
|
}
|
|
317
329
|
function a(e) {
|
|
318
330
|
let t13 = /* @__PURE__ */ Object.create(null);
|
|
319
331
|
for (let n of e.split(",")) t13[n] = 1;
|
|
320
332
|
return (n) => n in t13;
|
|
321
333
|
}
|
|
322
|
-
var
|
|
323
|
-
a(
|
|
324
|
-
a(`${
|
|
325
|
-
var
|
|
334
|
+
var N = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";
|
|
335
|
+
a(N);
|
|
336
|
+
a(`${N},async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
|
|
337
|
+
var ke = { acceptCharset: "accept-charset", className: "class", htmlFor: "for", httpEquiv: "http-equiv" };
|
|
326
338
|
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");
|
|
327
339
|
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");
|
|
328
|
-
var
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var
|
|
332
|
-
var
|
|
333
|
-
a(we);
|
|
334
|
-
var Ne = a(Te);
|
|
340
|
+
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";
|
|
341
|
+
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";
|
|
342
|
+
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";
|
|
343
|
+
var Ee = "beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart";
|
|
344
|
+
var Ne = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
335
345
|
a(Se);
|
|
336
|
-
var Ce = a(
|
|
337
|
-
|
|
338
|
-
var Re =
|
|
339
|
-
var ze =
|
|
340
|
-
|
|
341
|
-
|
|
346
|
+
var Ce = a(ve);
|
|
347
|
+
a(Ae);
|
|
348
|
+
var Re = a(Ne);
|
|
349
|
+
var ze = a(Ee);
|
|
350
|
+
var je = "data-hk-idx";
|
|
351
|
+
var He = "_$spread$";
|
|
352
|
+
var $e = /;(?![^(]*\))/g;
|
|
353
|
+
var Ue = /:([\s\S]+)/;
|
|
354
|
+
var Ge = /\/\*[\s\S]*?\*\//g;
|
|
355
|
+
function k(e) {
|
|
356
|
+
let t13 = {};
|
|
357
|
+
return e.replaceAll(Ge, "").split($e).forEach((n) => {
|
|
358
|
+
if (n) {
|
|
359
|
+
let o = n.split(Ue);
|
|
360
|
+
o.length > 1 && (t13[o[0].trim()] = o[1].trim());
|
|
361
|
+
}
|
|
362
|
+
}), t13;
|
|
363
|
+
}
|
|
364
|
+
function w(e) {
|
|
365
|
+
if (m(e)) {
|
|
366
|
+
let t13 = {};
|
|
367
|
+
for (let n of e) {
|
|
368
|
+
let o = i(n) ? k(n) : w(n);
|
|
369
|
+
if (o) for (let r in o) t13[r] = o[r];
|
|
370
|
+
}
|
|
371
|
+
return t13;
|
|
372
|
+
}
|
|
373
|
+
if (i(e)) return e;
|
|
374
|
+
if (g(e)) {
|
|
375
|
+
let t13 = {};
|
|
376
|
+
for (let n in e) {
|
|
377
|
+
let o = e[n];
|
|
378
|
+
if (i(o) || d(o)) {
|
|
379
|
+
t13[n] = o;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
let r = w(o);
|
|
383
|
+
if (!r) continue;
|
|
384
|
+
let s = i(r) ? k(r) : r;
|
|
385
|
+
for (let l in s) t13[l] = s[l];
|
|
386
|
+
}
|
|
387
|
+
return t13;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
342
390
|
function isAnyFunctionPath(path) {
|
|
343
391
|
return path.isFunctionDeclaration() || path.isFunctionExpression() || path.isArrowFunctionExpression();
|
|
344
392
|
}
|
|
@@ -400,7 +448,7 @@ function serializeStaticAttrs(attrs) {
|
|
|
400
448
|
const merged = [];
|
|
401
449
|
let classValue;
|
|
402
450
|
for (const attr of attrs) {
|
|
403
|
-
const name = (_a =
|
|
451
|
+
const name = (_a = ke[attr.name]) != null ? _a : attr.name;
|
|
404
452
|
if (name === "class") {
|
|
405
453
|
classValue = classValue ? `${classValue} ${attr.value}` : String(attr.value);
|
|
406
454
|
} else {
|
|
@@ -410,7 +458,7 @@ function serializeStaticAttrs(attrs) {
|
|
|
410
458
|
if (classValue) merged.unshift({ name: "class", value: classValue });
|
|
411
459
|
return merged.map((attr) => {
|
|
412
460
|
if (attr.value === true) return ` ${attr.name}`;
|
|
413
|
-
return ` ${attr.name}="${
|
|
461
|
+
return ` ${attr.name}="${pe(attr.value)}"`;
|
|
414
462
|
}).join("");
|
|
415
463
|
}
|
|
416
464
|
function resolveComponentCallee(tag, fallback) {
|
|
@@ -429,16 +477,16 @@ function isSerializableStaticValue(value) {
|
|
|
429
477
|
const stack = [value];
|
|
430
478
|
while (stack.length > 0) {
|
|
431
479
|
const current = stack.pop();
|
|
432
|
-
if (
|
|
480
|
+
if (T(current) || A(current) || d(current) || i(current) || U(current)) {
|
|
433
481
|
continue;
|
|
434
482
|
}
|
|
435
|
-
if (
|
|
483
|
+
if (m(current)) {
|
|
436
484
|
for (const item of current) {
|
|
437
485
|
stack.push(item);
|
|
438
486
|
}
|
|
439
487
|
continue;
|
|
440
488
|
}
|
|
441
|
-
if (!
|
|
489
|
+
if (!F(current)) {
|
|
442
490
|
return false;
|
|
443
491
|
}
|
|
444
492
|
const values = Object.values(current);
|
|
@@ -449,21 +497,29 @@ function isSerializableStaticValue(value) {
|
|
|
449
497
|
return true;
|
|
450
498
|
}
|
|
451
499
|
function styleToString(style) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
500
|
+
const normalized = w(style);
|
|
501
|
+
if (!normalized) return void 0;
|
|
502
|
+
if (i(normalized)) return normalized;
|
|
503
|
+
const parts = [];
|
|
504
|
+
for (const key in normalized) {
|
|
505
|
+
const value = normalized[key];
|
|
506
|
+
if (i(value) || d(value)) {
|
|
507
|
+
const prop = x(key, "--") ? key : b(key);
|
|
508
|
+
parts.push(`${prop}:${value}`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return parts.join(";");
|
|
456
512
|
}
|
|
457
513
|
function shouldResolveStaticCollection(attrName) {
|
|
458
514
|
return attrName !== "ref" && !x(attrName, "bind:") && !normalizeEventName(attrName);
|
|
459
515
|
}
|
|
460
516
|
function normalizeTemplateAttrName(attrName) {
|
|
461
517
|
var _a;
|
|
462
|
-
return (_a =
|
|
518
|
+
return (_a = ke[attrName]) != null ? _a : attrName;
|
|
463
519
|
}
|
|
464
520
|
function createStaticAttr(attrName, value, order) {
|
|
465
521
|
return {
|
|
466
|
-
attr: { name: attrName, value },
|
|
522
|
+
attr: { name: attrName, value, order },
|
|
467
523
|
order,
|
|
468
524
|
templateName: normalizeTemplateAttrName(attrName)
|
|
469
525
|
};
|
|
@@ -474,7 +530,8 @@ function createDynamicAttr(attrPath, attrName, value, effectKind, order) {
|
|
|
474
530
|
path: attrPath,
|
|
475
531
|
name: attrName,
|
|
476
532
|
value,
|
|
477
|
-
effectKind
|
|
533
|
+
effectKind,
|
|
534
|
+
order
|
|
478
535
|
},
|
|
479
536
|
order,
|
|
480
537
|
templateName: normalizeTemplateAttrName(attrName)
|
|
@@ -489,13 +546,15 @@ function resolveStaticExpressionValue(attrName, expressionPath) {
|
|
|
489
546
|
return void 0;
|
|
490
547
|
}
|
|
491
548
|
let value = evaluated.value;
|
|
492
|
-
if (attrName === "style"
|
|
493
|
-
|
|
549
|
+
if (attrName === "style") {
|
|
550
|
+
const style = styleToString(value);
|
|
551
|
+
if (style === void 0) return void 0;
|
|
552
|
+
value = style;
|
|
494
553
|
}
|
|
495
|
-
if (i(value) ||
|
|
554
|
+
if (i(value) || A(value)) {
|
|
496
555
|
return value;
|
|
497
556
|
}
|
|
498
|
-
if (
|
|
557
|
+
if (d(value)) {
|
|
499
558
|
return String(value);
|
|
500
559
|
}
|
|
501
560
|
return void 0;
|
|
@@ -548,7 +607,8 @@ function parseAttributes(path) {
|
|
|
548
607
|
if (attrPath.isJSXSpreadAttribute()) {
|
|
549
608
|
spreadAttrs.push({
|
|
550
609
|
value: attrPath.node.argument,
|
|
551
|
-
effectKind: classifyAttrValue(attrPath.node.argument).kind
|
|
610
|
+
effectKind: classifyAttrValue(attrPath.node.argument).kind,
|
|
611
|
+
order
|
|
552
612
|
});
|
|
553
613
|
continue;
|
|
554
614
|
}
|
|
@@ -636,7 +696,7 @@ function unwrapTopLevelDeclaration(statementPath) {
|
|
|
636
696
|
}
|
|
637
697
|
if (statementPath.isExportNamedDeclaration() || statementPath.isExportDefaultDeclaration()) {
|
|
638
698
|
const declarationPath = statementPath.get("declaration");
|
|
639
|
-
if (declarationPath && !
|
|
699
|
+
if (declarationPath && !m(declarationPath) && (declarationPath.isFunctionDeclaration() || declarationPath.isVariableDeclaration())) {
|
|
640
700
|
return declarationPath;
|
|
641
701
|
}
|
|
642
702
|
}
|
|
@@ -1045,7 +1105,7 @@ function patternHasSignalBinding(node) {
|
|
|
1045
1105
|
if (core.types.isIdentifier(node)) return isSignal(node.name);
|
|
1046
1106
|
if (core.types.isObjectPattern(node)) {
|
|
1047
1107
|
return node.properties.some(
|
|
1048
|
-
(
|
|
1108
|
+
(p) => core.types.isRestElement(p) ? patternHasSignalBinding(p.argument) : patternHasSignalBinding(p.value)
|
|
1049
1109
|
);
|
|
1050
1110
|
}
|
|
1051
1111
|
if (core.types.isArrayPattern(node)) {
|
|
@@ -1193,9 +1253,9 @@ function isAlreadyValueAccess(path) {
|
|
|
1193
1253
|
if (!core.types.isParenthesizedExpression(parent) && !core.types.isTSAsExpression(parent) && !core.types.isTSNonNullExpression(parent)) {
|
|
1194
1254
|
return false;
|
|
1195
1255
|
}
|
|
1196
|
-
const ancestor = path.findParent((
|
|
1197
|
-
if (!isMemberLike(
|
|
1198
|
-
return isMemberAccessingProperty(
|
|
1256
|
+
const ancestor = path.findParent((p) => {
|
|
1257
|
+
if (!isMemberLike(p.node)) return false;
|
|
1258
|
+
return isMemberAccessingProperty(p.node, "value");
|
|
1199
1259
|
});
|
|
1200
1260
|
return !!ancestor;
|
|
1201
1261
|
}
|
|
@@ -1290,7 +1350,7 @@ function collectObjectPattern(pattern, base, leaves, rests) {
|
|
|
1290
1350
|
continue;
|
|
1291
1351
|
}
|
|
1292
1352
|
const { keyExpr, computed, excludeKey } = resolveKey(prop);
|
|
1293
|
-
if (excludeKey
|
|
1353
|
+
if (!T(excludeKey)) excludeKeys.push(excludeKey);
|
|
1294
1354
|
const access = core.types.memberExpression(clone2(base), keyExpr, computed);
|
|
1295
1355
|
collectTarget(prop.value, access, leaves, rests);
|
|
1296
1356
|
}
|
|
@@ -1322,7 +1382,7 @@ function ensureBlockBody(path) {
|
|
|
1322
1382
|
return block;
|
|
1323
1383
|
}
|
|
1324
1384
|
function isInsidePattern(ref, pattern) {
|
|
1325
|
-
return !!ref.findParent((
|
|
1385
|
+
return !!ref.findParent((p) => p.node === pattern);
|
|
1326
1386
|
}
|
|
1327
1387
|
function accessorFor(pattern, base, name) {
|
|
1328
1388
|
var _a;
|
|
@@ -1342,7 +1402,7 @@ function transformFnProps(path) {
|
|
|
1342
1402
|
collectObjectPattern(firstParam, base, initLeaves, initRests);
|
|
1343
1403
|
const conflicts = [...initLeaves, ...initRests].map((b2) => b2.name).filter((name) => x(name, signalPrefix));
|
|
1344
1404
|
if (conflicts.length > 0) {
|
|
1345
|
-
|
|
1405
|
+
se("transformProps", "Property names cannot start with signal prefix", conflicts);
|
|
1346
1406
|
}
|
|
1347
1407
|
if (initLeaves.length === 0 && initRests.length === 1 && firstParam.properties.length === 1 && core.types.isRestElement(firstParam.properties[0])) {
|
|
1348
1408
|
path.node.params[0] = core.types.identifier(initRests[0].name);
|
|
@@ -1398,11 +1458,15 @@ function createPatchCall(importFn, target, attrName, value, options = {}) {
|
|
|
1398
1458
|
const { helper, name } = getPatchHelper(attrName);
|
|
1399
1459
|
const nextValue = (_a = options.nextValue) != null ? _a : value;
|
|
1400
1460
|
const isAttr = helper === "patchAttr";
|
|
1461
|
+
const emitSVGFlag = helper === "patchClass" && options.isSVG === true;
|
|
1401
1462
|
const args = isAttr ? [target, core.types.stringLiteral(name)] : [target];
|
|
1402
|
-
if (options.previousValue != null || options.includePreviousValuePlaceholder) {
|
|
1463
|
+
if (options.previousValue != null || options.includePreviousValuePlaceholder || emitSVGFlag) {
|
|
1403
1464
|
args.push((_b = options.previousValue) != null ? _b : core.types.identifier("undefined"));
|
|
1404
1465
|
}
|
|
1405
1466
|
args.push(nextValue);
|
|
1467
|
+
if (emitSVGFlag) {
|
|
1468
|
+
args.push(core.types.booleanLiteral(true));
|
|
1469
|
+
}
|
|
1406
1470
|
return core.types.callExpression(importFn(helper), args);
|
|
1407
1471
|
}
|
|
1408
1472
|
function createRefExpression(target, value) {
|
|
@@ -1450,6 +1514,18 @@ function hasDynamicBoundary(children, index) {
|
|
|
1450
1514
|
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 */;
|
|
1451
1515
|
return isText(prev) || isText(next) || isDynamic(prev) || isDynamic(next);
|
|
1452
1516
|
}
|
|
1517
|
+
function getDynamicAnchorKind(children, index, mode) {
|
|
1518
|
+
if (!hasDynamicBoundary(children, index)) {
|
|
1519
|
+
const next = children[index + 1];
|
|
1520
|
+
if ((mode === "hydrate" || mode === "server") && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
|
|
1521
|
+
return "element";
|
|
1522
|
+
}
|
|
1523
|
+
if (!next) {
|
|
1524
|
+
return "tail";
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
return "comment";
|
|
1528
|
+
}
|
|
1453
1529
|
function buildIR(path, ctx) {
|
|
1454
1530
|
if (path.isJSXFragment()) {
|
|
1455
1531
|
useImport("Fragment");
|
|
@@ -1466,14 +1542,14 @@ function buildElementIR(tag, path, ctx) {
|
|
|
1466
1542
|
const node = {
|
|
1467
1543
|
type: 0 /* ELEMENT */,
|
|
1468
1544
|
tag,
|
|
1469
|
-
isSVG:
|
|
1545
|
+
isSVG: Ce(tag),
|
|
1470
1546
|
staticAttrs,
|
|
1471
1547
|
dynamicAttrs: [],
|
|
1472
1548
|
events: [],
|
|
1473
|
-
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
|
|
1549
|
+
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
|
|
1474
1550
|
binds: [],
|
|
1475
1551
|
children: [],
|
|
1476
|
-
selfClosing:
|
|
1552
|
+
selfClosing: Re(tag),
|
|
1477
1553
|
loc: path.node.loc
|
|
1478
1554
|
};
|
|
1479
1555
|
for (const attr of dynamicAttrs) {
|
|
@@ -1493,7 +1569,8 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1493
1569
|
props.push({
|
|
1494
1570
|
name: attr.name,
|
|
1495
1571
|
value: i(attr.value) ? core.types.stringLiteral(attr.value) : core.types.booleanLiteral(attr.value),
|
|
1496
|
-
kind: "static"
|
|
1572
|
+
kind: "static",
|
|
1573
|
+
order: attr.order
|
|
1497
1574
|
});
|
|
1498
1575
|
}
|
|
1499
1576
|
for (const attr of dynamicAttrs) {
|
|
@@ -1502,7 +1579,8 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1502
1579
|
props.push({
|
|
1503
1580
|
name: attr.name,
|
|
1504
1581
|
value: attr.value,
|
|
1505
|
-
kind: attr.effectKind
|
|
1582
|
+
kind: attr.effectKind,
|
|
1583
|
+
order: attr.order
|
|
1506
1584
|
});
|
|
1507
1585
|
} else if (x(attr.name, "bind:")) {
|
|
1508
1586
|
const binding = attr.name.slice("bind:".length);
|
|
@@ -1513,18 +1591,21 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1513
1591
|
props.push({
|
|
1514
1592
|
name: binding,
|
|
1515
1593
|
value: core.types.cloneNode(valueExpr),
|
|
1516
|
-
kind: attr.effectKind
|
|
1594
|
+
kind: attr.effectKind,
|
|
1595
|
+
order: attr.order
|
|
1517
1596
|
});
|
|
1518
1597
|
props.push({
|
|
1519
1598
|
name: `update:${binding}`,
|
|
1520
1599
|
value: createBindingSetter(valueExpr),
|
|
1521
|
-
kind: "static"
|
|
1600
|
+
kind: "static",
|
|
1601
|
+
order: attr.order
|
|
1522
1602
|
});
|
|
1523
1603
|
} else {
|
|
1524
1604
|
props.push({
|
|
1525
1605
|
name: attr.name,
|
|
1526
1606
|
value: attr.value,
|
|
1527
|
-
kind: attr.effectKind
|
|
1607
|
+
kind: attr.effectKind,
|
|
1608
|
+
order: attr.order
|
|
1528
1609
|
});
|
|
1529
1610
|
}
|
|
1530
1611
|
}
|
|
@@ -1532,7 +1613,7 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1532
1613
|
type: 1 /* COMPONENT */,
|
|
1533
1614
|
tag,
|
|
1534
1615
|
props,
|
|
1535
|
-
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
|
|
1616
|
+
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
|
|
1536
1617
|
children: buildChildren(path, ctx),
|
|
1537
1618
|
loc: path.node.loc
|
|
1538
1619
|
};
|
|
@@ -1541,7 +1622,7 @@ function applyDynamicAttr(node, attr, ctx) {
|
|
|
1541
1622
|
const { name, value, effectKind, path } = attr;
|
|
1542
1623
|
const eventName = normalizeEventName(name);
|
|
1543
1624
|
if (eventName) {
|
|
1544
|
-
const delegated = !!(ctx.options.delegateEvents &&
|
|
1625
|
+
const delegated = !!(ctx.options.delegateEvents && ze(eventName));
|
|
1545
1626
|
node.events.push({
|
|
1546
1627
|
name: eventName,
|
|
1547
1628
|
handler: value,
|
|
@@ -1629,7 +1710,7 @@ function isPropsChildrenExpression(expression) {
|
|
|
1629
1710
|
const binding = expression.scope.getBinding(node.object.name);
|
|
1630
1711
|
const bindingPath = binding == null ? void 0 : binding.path;
|
|
1631
1712
|
if (!(bindingPath == null ? void 0 : bindingPath.isIdentifier())) return false;
|
|
1632
|
-
const owner = bindingPath.findParent((
|
|
1713
|
+
const owner = bindingPath.findParent((p) => isAnyFunctionPath(p));
|
|
1633
1714
|
if (!owner) return false;
|
|
1634
1715
|
const fn = owner.node;
|
|
1635
1716
|
const componentName = getEnclosingFunctionName(owner);
|
|
@@ -1692,6 +1773,7 @@ function buildForIR(expression, ctx) {
|
|
|
1692
1773
|
};
|
|
1693
1774
|
}
|
|
1694
1775
|
function extractKeyExpression(path) {
|
|
1776
|
+
if (path.isJSXFragment()) return extractFragmentKeyExpression(path);
|
|
1695
1777
|
if (!path.isJSXElement()) return null;
|
|
1696
1778
|
for (const attrPath of path.get("openingElement.attributes")) {
|
|
1697
1779
|
if (!attrPath.isJSXAttribute()) continue;
|
|
@@ -1706,7 +1788,7 @@ function extractKeyExpression(path) {
|
|
|
1706
1788
|
return core.types.stringLiteral(value.value);
|
|
1707
1789
|
}
|
|
1708
1790
|
const valuePath = attrPath.get("value");
|
|
1709
|
-
if (!
|
|
1791
|
+
if (!m(valuePath) && valuePath.isJSXExpressionContainer()) {
|
|
1710
1792
|
const expressionPath = valuePath.get("expression");
|
|
1711
1793
|
attrPath.remove();
|
|
1712
1794
|
if (expressionPath.isJSXEmptyExpression()) return null;
|
|
@@ -1717,9 +1799,16 @@ function extractKeyExpression(path) {
|
|
|
1717
1799
|
}
|
|
1718
1800
|
return null;
|
|
1719
1801
|
}
|
|
1802
|
+
function extractFragmentKeyExpression(path) {
|
|
1803
|
+
const children = path.get("children").filter(isValidChild);
|
|
1804
|
+
if (children.length !== 1) return null;
|
|
1805
|
+
const child = children[0];
|
|
1806
|
+
if (!child.isJSXElement() && !child.isJSXFragment()) return null;
|
|
1807
|
+
return extractKeyExpression(child);
|
|
1808
|
+
}
|
|
1720
1809
|
function getForCallbackBody(callback) {
|
|
1721
1810
|
const bodyPath = callback.get("body");
|
|
1722
|
-
if (
|
|
1811
|
+
if (m(bodyPath)) return null;
|
|
1723
1812
|
if (bodyPath.isJSXElement() || bodyPath.isJSXFragment()) {
|
|
1724
1813
|
return {
|
|
1725
1814
|
path: bodyPath,
|
|
@@ -1736,7 +1825,7 @@ function getForCallbackBody(callback) {
|
|
|
1736
1825
|
continue;
|
|
1737
1826
|
}
|
|
1738
1827
|
const argument = statement.get("argument");
|
|
1739
|
-
if (
|
|
1828
|
+
if (m(argument) || !argument.node) {
|
|
1740
1829
|
prelude.push(statement.node);
|
|
1741
1830
|
continue;
|
|
1742
1831
|
}
|
|
@@ -1812,16 +1901,55 @@ function createPropNode(name, value, kind, options) {
|
|
|
1812
1901
|
function composePropsExpression(props, spreads, options) {
|
|
1813
1902
|
if (spreads.length === 0) {
|
|
1814
1903
|
if (props.length === 0) return core.types.objectExpression([]);
|
|
1815
|
-
return core.types.objectExpression(props.map((
|
|
1904
|
+
return core.types.objectExpression(props.map((p) => createPropNode(p.name, p.value, p.kind, options)));
|
|
1905
|
+
}
|
|
1906
|
+
if (props.some((prop) => prop.order == null) || spreads.some((spread) => spread.order == null)) {
|
|
1907
|
+
return composeUnorderedPropsExpression(props, spreads, options);
|
|
1908
|
+
}
|
|
1909
|
+
const ordered = [
|
|
1910
|
+
...props.map((prop, sequence) => ({
|
|
1911
|
+
type: "prop",
|
|
1912
|
+
order: prop.order,
|
|
1913
|
+
sequence,
|
|
1914
|
+
prop
|
|
1915
|
+
})),
|
|
1916
|
+
...spreads.map((spread, sequence) => ({
|
|
1917
|
+
type: "spread",
|
|
1918
|
+
order: spread.order,
|
|
1919
|
+
sequence,
|
|
1920
|
+
spread
|
|
1921
|
+
}))
|
|
1922
|
+
].sort((a2, b2) => a2.order - b2.order || a2.sequence - b2.sequence);
|
|
1923
|
+
const parts = [];
|
|
1924
|
+
let propNodes = [];
|
|
1925
|
+
const flushProps = () => {
|
|
1926
|
+
if (propNodes.length === 0) return;
|
|
1927
|
+
parts.push(core.types.objectExpression(propNodes));
|
|
1928
|
+
propNodes = [];
|
|
1929
|
+
};
|
|
1930
|
+
for (const entry of ordered) {
|
|
1931
|
+
if (entry.type === "prop") {
|
|
1932
|
+
propNodes.push(createPropNode(entry.prop.name, entry.prop.value, entry.prop.kind, options));
|
|
1933
|
+
continue;
|
|
1934
|
+
}
|
|
1935
|
+
flushProps();
|
|
1936
|
+
parts.push(cloneValue(entry.spread.value, options.cloneValues));
|
|
1816
1937
|
}
|
|
1938
|
+
flushProps();
|
|
1939
|
+
return composeAssignParts(parts);
|
|
1940
|
+
}
|
|
1941
|
+
function composeUnorderedPropsExpression(props, spreads, options) {
|
|
1817
1942
|
const parts = [];
|
|
1818
|
-
const propNodes = props.map((
|
|
1943
|
+
const propNodes = props.map((p) => createPropNode(p.name, p.value, p.kind, options));
|
|
1819
1944
|
if (propNodes.length > 0) {
|
|
1820
1945
|
parts.push(core.types.objectExpression(propNodes));
|
|
1821
1946
|
}
|
|
1822
1947
|
for (const spread of spreads) {
|
|
1823
1948
|
parts.push(cloneValue(spread.value, options.cloneValues));
|
|
1824
1949
|
}
|
|
1950
|
+
return composeAssignParts(parts);
|
|
1951
|
+
}
|
|
1952
|
+
function composeAssignParts(parts) {
|
|
1825
1953
|
if (parts.length === 0) return core.types.objectExpression([]);
|
|
1826
1954
|
if (parts.length === 1) return parts[0];
|
|
1827
1955
|
return core.types.callExpression(core.types.memberExpression(core.types.identifier("Object"), core.types.identifier("assign")), [
|
|
@@ -2093,7 +2221,7 @@ function generateServerFor(node, ctx) {
|
|
|
2093
2221
|
return buildForCall(node, bodyExpr);
|
|
2094
2222
|
}
|
|
2095
2223
|
function generateServerElement(node, ctx, withHydrationKey = true, staticIndex, options = {}) {
|
|
2096
|
-
var _a
|
|
2224
|
+
var _a;
|
|
2097
2225
|
const dynamicAttrExprs = [...(_a = options.prependAttrExprs) != null ? _a : []];
|
|
2098
2226
|
for (const attr of node.dynamicAttrs) {
|
|
2099
2227
|
let expr;
|
|
@@ -2121,7 +2249,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2121
2249
|
}
|
|
2122
2250
|
const templates = [];
|
|
2123
2251
|
const expressions = [];
|
|
2124
|
-
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name:
|
|
2252
|
+
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
|
|
2125
2253
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2126
2254
|
const textareaValueBind = node.tag === "textarea" ? findBind(node, "value") : null;
|
|
2127
2255
|
let currentStr = `<${node.tag}`;
|
|
@@ -2152,11 +2280,11 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2152
2280
|
if (child.type === 2 /* TEXT */) {
|
|
2153
2281
|
currentStr += escapeServerTemplateText(child.value);
|
|
2154
2282
|
} else if (child.type === 3 /* EXPRESSION */ || child.type === 1 /* COMPONENT */ || child.type === 4 /* FOR */) {
|
|
2155
|
-
const
|
|
2283
|
+
const anchorKind = getDynamicAnchorKind(node.children, i2, "server");
|
|
2156
2284
|
const slotIndex = markerIndex++;
|
|
2157
2285
|
templates.push(currentStr);
|
|
2158
|
-
currentStr =
|
|
2159
|
-
if (
|
|
2286
|
+
currentStr = anchorKind === "comment" ? `<!--${slotIndex}-->` : "";
|
|
2287
|
+
if (anchorKind === "element") {
|
|
2160
2288
|
pendingAnchorIndex = slotIndex;
|
|
2161
2289
|
}
|
|
2162
2290
|
expressions.push(generateServerNode(child, ctx));
|
|
@@ -2179,7 +2307,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2179
2307
|
}
|
|
2180
2308
|
}
|
|
2181
2309
|
const staticHTML = buildStaticServerHTML(child, anchorIndex);
|
|
2182
|
-
if (staticHTML
|
|
2310
|
+
if (!T(staticHTML)) {
|
|
2183
2311
|
currentStr += staticHTML;
|
|
2184
2312
|
} else {
|
|
2185
2313
|
templates.push(currentStr);
|
|
@@ -2224,7 +2352,7 @@ function buildStaticServerHTML(node, staticIndex) {
|
|
|
2224
2352
|
if (node.binds.length > 0 || node.dynamicAttrs.length > 0 || node.spreads.length > 0) {
|
|
2225
2353
|
return null;
|
|
2226
2354
|
}
|
|
2227
|
-
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name:
|
|
2355
|
+
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
|
|
2228
2356
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2229
2357
|
if (node.selfClosing) {
|
|
2230
2358
|
return `<${node.tag}${attrs} />`;
|
|
@@ -2236,7 +2364,7 @@ function buildStaticServerHTML(node, staticIndex) {
|
|
|
2236
2364
|
} else if (child.type === 0 /* ELEMENT */) {
|
|
2237
2365
|
if (child.binds.length > 0) return null;
|
|
2238
2366
|
const nested = buildStaticServerHTML(child);
|
|
2239
|
-
if (nested
|
|
2367
|
+
if (T(nested)) return null;
|
|
2240
2368
|
html += nested;
|
|
2241
2369
|
} else {
|
|
2242
2370
|
return null;
|
|
@@ -2274,18 +2402,6 @@ function shouldCloseTag(element, isLastElement, hasClosingParent, options) {
|
|
|
2274
2402
|
function closeTag(element, isLastElement, hasClosingParent, options) {
|
|
2275
2403
|
return shouldCloseTag(element, isLastElement, hasClosingParent, options) ? `</${element.tag}>` : "";
|
|
2276
2404
|
}
|
|
2277
|
-
function getDynamicAnchorKind(children, index, mode) {
|
|
2278
|
-
if ((mode === "client" || mode === "hydrate") && !hasDynamicBoundary(children, index)) {
|
|
2279
|
-
const next = children[index + 1];
|
|
2280
|
-
if (mode === "hydrate" && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
|
|
2281
|
-
return "element";
|
|
2282
|
-
}
|
|
2283
|
-
if (!next) {
|
|
2284
|
-
return "tail";
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
return "comment";
|
|
2288
|
-
}
|
|
2289
2405
|
function findLastOmittableElementIndex(children, mode) {
|
|
2290
2406
|
for (let i2 = children.length - 1; i2 >= 0; i2--) {
|
|
2291
2407
|
const child = children[i2];
|
|
@@ -2310,7 +2426,7 @@ function buildTemplateAndFlatten(root, mode) {
|
|
|
2310
2426
|
const myId = nextId++;
|
|
2311
2427
|
const staticAttrs = mode === "hydrate" && forcedStaticIndex !== void 0 ? [
|
|
2312
2428
|
...element.staticAttrs,
|
|
2313
|
-
{ name:
|
|
2429
|
+
{ name: je, value: String(forcedStaticIndex) }
|
|
2314
2430
|
] : element.staticAttrs;
|
|
2315
2431
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2316
2432
|
if (element.selfClosing) {
|
|
@@ -2349,7 +2465,7 @@ function buildTemplateAndFlatten(root, mode) {
|
|
|
2349
2465
|
const child = element.children[i2];
|
|
2350
2466
|
switch (child.type) {
|
|
2351
2467
|
case 2 /* TEXT */:
|
|
2352
|
-
template += mode === "hydrate" ? child.value :
|
|
2468
|
+
template += mode === "hydrate" ? child.value : pe(child.value);
|
|
2353
2469
|
nodes.push({
|
|
2354
2470
|
id: nextId++,
|
|
2355
2471
|
kind: "text",
|
|
@@ -2416,7 +2532,7 @@ function buildStaticTemplateString(node, mode) {
|
|
|
2416
2532
|
function visit(current, isLastElement, hasClosingParent) {
|
|
2417
2533
|
switch (current.type) {
|
|
2418
2534
|
case 2 /* TEXT */:
|
|
2419
|
-
return mode === "hydrate" ? current.value :
|
|
2535
|
+
return mode === "hydrate" ? current.value : pe(current.value);
|
|
2420
2536
|
case 0 /* ELEMENT */: {
|
|
2421
2537
|
const attrs = serializeStaticAttrs(current.staticAttrs);
|
|
2422
2538
|
if (current.selfClosing) return selfClosingTag(current, attrs);
|
|
@@ -2612,10 +2728,10 @@ function emitElementEffect(element, target, state, body, pendingMemoPatches) {
|
|
|
2612
2728
|
emitBind(bind, target, body);
|
|
2613
2729
|
}
|
|
2614
2730
|
for (const attr of element.dynamicAttrs) {
|
|
2615
|
-
emitDynamicAttr(attr, target, body, state, pendingMemoPatches);
|
|
2731
|
+
emitDynamicAttr(attr, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2616
2732
|
}
|
|
2617
2733
|
for (const spread of element.spreads) {
|
|
2618
|
-
emitSpread(spread, target, body, state, pendingMemoPatches);
|
|
2734
|
+
emitSpread(spread, target, body, state, pendingMemoPatches, element.isSVG);
|
|
2619
2735
|
}
|
|
2620
2736
|
}
|
|
2621
2737
|
function emitDynamicChildInserts(flatNodes, varMap, state, body) {
|
|
@@ -2705,7 +2821,7 @@ function emitBind(bind, target, body) {
|
|
|
2705
2821
|
if (modifiersArg) args.push(core.types.cloneNode(modifiersArg));
|
|
2706
2822
|
body.push(core.types.expressionStatement(core.types.callExpression(useImport("bindElement"), args)));
|
|
2707
2823
|
}
|
|
2708
|
-
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
2824
|
+
function emitDynamicAttr(attr, target, body, state, pendingMemoPatches, isSVG) {
|
|
2709
2825
|
emitPatchOrEffect(
|
|
2710
2826
|
target,
|
|
2711
2827
|
attr.name,
|
|
@@ -2713,30 +2829,35 @@ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
|
2713
2829
|
attr.kind,
|
|
2714
2830
|
body,
|
|
2715
2831
|
() => createEffectKey(attr.name, state.effectIndex++),
|
|
2716
|
-
pendingMemoPatches
|
|
2832
|
+
pendingMemoPatches,
|
|
2833
|
+
isSVG
|
|
2717
2834
|
);
|
|
2718
2835
|
}
|
|
2719
|
-
function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
2836
|
+
function emitSpread(spread, target, body, state, pendingMemoPatches, isSVG) {
|
|
2720
2837
|
emitPatchOrEffect(
|
|
2721
2838
|
target,
|
|
2722
|
-
|
|
2839
|
+
He,
|
|
2723
2840
|
spread.value,
|
|
2724
2841
|
spread.kind,
|
|
2725
2842
|
body,
|
|
2726
2843
|
() => createSpreadEffectKey(state.effectIndex++),
|
|
2727
|
-
pendingMemoPatches
|
|
2844
|
+
pendingMemoPatches,
|
|
2845
|
+
isSVG
|
|
2728
2846
|
);
|
|
2729
2847
|
}
|
|
2730
|
-
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches) {
|
|
2848
|
+
function emitPatchOrEffect(target, attrName, value, kind, body, getEffectKey, pendingMemoPatches, isSVG) {
|
|
2731
2849
|
if (kind === "static") {
|
|
2732
|
-
body.push(
|
|
2850
|
+
body.push(
|
|
2851
|
+
core.types.expressionStatement(createPatchCall(useImport, target, attrName, value, { isSVG }))
|
|
2852
|
+
);
|
|
2733
2853
|
return;
|
|
2734
2854
|
}
|
|
2735
2855
|
pendingMemoPatches.push({
|
|
2736
2856
|
effectKey: getEffectKey(),
|
|
2737
2857
|
target,
|
|
2738
2858
|
attrName,
|
|
2739
|
-
value
|
|
2859
|
+
value,
|
|
2860
|
+
isSVG
|
|
2740
2861
|
});
|
|
2741
2862
|
}
|
|
2742
2863
|
function emitMergedMemoEffect(patches, body) {
|
|
@@ -2758,7 +2879,8 @@ function createMemoPatchStatements(patch, memoStateId) {
|
|
|
2758
2879
|
const valueId = genUid(MEMO_NEXT_VALUE_ID);
|
|
2759
2880
|
const updateCall = createPatchCall(useImport, patch.target, patch.attrName, valueId, {
|
|
2760
2881
|
previousValue: effectState,
|
|
2761
|
-
nextValue: core.types.assignmentExpression("=", effectState, valueId)
|
|
2882
|
+
nextValue: core.types.assignmentExpression("=", effectState, valueId),
|
|
2883
|
+
isSVG: patch.isSVG
|
|
2762
2884
|
});
|
|
2763
2885
|
return [
|
|
2764
2886
|
core.types.variableDeclaration("let", [core.types.variableDeclarator(valueId, core.types.cloneNode(patch.value, true))]),
|