babel-plugin-essor 0.0.17-beta.6 → 0.0.17
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 +237 -116
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +237 -116
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -99,7 +99,8 @@ var IMPORTS_MAPS = [
|
|
|
99
99
|
"nthChild"
|
|
100
100
|
];
|
|
101
101
|
var SERVER_IMPORT_REMAPS = {
|
|
102
|
-
createComponent: "
|
|
102
|
+
createComponent: "ssrComponent",
|
|
103
|
+
render: "ssr",
|
|
103
104
|
patchAttr: "ssrAttrDynamic"
|
|
104
105
|
};
|
|
105
106
|
var HYDRATE_IMPORT_REMAPS = {
|
|
@@ -145,6 +146,7 @@ function createCompileContext(options, programPath) {
|
|
|
145
146
|
delegateEvents: /* @__PURE__ */ new Set(),
|
|
146
147
|
imports: /* @__PURE__ */ new Set(),
|
|
147
148
|
importIdentifiers: createImportIdentifiers(programPath, options.mode),
|
|
149
|
+
signalBindings: /* @__PURE__ */ new WeakSet(),
|
|
148
150
|
declarations: /* @__PURE__ */ new Map(),
|
|
149
151
|
hmrComponents: /* @__PURE__ */ new Set(),
|
|
150
152
|
hmrSignatures: /* @__PURE__ */ new Map(),
|
|
@@ -258,35 +260,46 @@ function createImport(path) {
|
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
// ../shared/dist/shared.js
|
|
261
|
-
var
|
|
263
|
+
var g = (e) => e !== null && typeof e == "object";
|
|
264
|
+
var m = Array.isArray;
|
|
262
265
|
function i(e) {
|
|
263
266
|
return typeof e == "string";
|
|
264
267
|
}
|
|
265
|
-
function
|
|
268
|
+
function d(e) {
|
|
266
269
|
return typeof e == "number";
|
|
267
270
|
}
|
|
268
|
-
function
|
|
271
|
+
function T(e) {
|
|
269
272
|
return e === null;
|
|
270
273
|
}
|
|
271
|
-
var
|
|
272
|
-
|
|
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) {
|
|
273
280
|
return typeof e == "boolean";
|
|
274
281
|
}
|
|
275
|
-
function
|
|
282
|
+
function U(e) {
|
|
276
283
|
return typeof e == "bigint";
|
|
277
284
|
}
|
|
278
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());
|
|
279
292
|
function x(e, t13) {
|
|
280
293
|
return i(e) ? e.indexOf(t13) === 0 : false;
|
|
281
294
|
}
|
|
282
|
-
function
|
|
295
|
+
function se(e, ...t13) {
|
|
283
296
|
console.warn(`[Essor warn]: ${e}`, ...t13);
|
|
284
297
|
}
|
|
285
|
-
var
|
|
286
|
-
function
|
|
287
|
-
let t13 = `${e}`, n =
|
|
298
|
+
var ce = /["&'<>]/;
|
|
299
|
+
function pe(e) {
|
|
300
|
+
let t13 = `${e}`, n = ce.exec(t13);
|
|
288
301
|
if (!n) return t13;
|
|
289
|
-
let o = "", r, s,
|
|
302
|
+
let o = "", r, s, l = 0;
|
|
290
303
|
for (s = n.index; s < t13.length; s++) {
|
|
291
304
|
switch (t13.charCodeAt(s)) {
|
|
292
305
|
case 34:
|
|
@@ -307,35 +320,71 @@ function le(e) {
|
|
|
307
320
|
default:
|
|
308
321
|
continue;
|
|
309
322
|
}
|
|
310
|
-
|
|
323
|
+
l !== s && (o += t13.slice(l, s)), l = s + 1, o += r;
|
|
311
324
|
}
|
|
312
|
-
return
|
|
325
|
+
return l !== s ? o + t13.slice(l, s) : o;
|
|
313
326
|
}
|
|
314
327
|
function a(e) {
|
|
315
328
|
let t13 = /* @__PURE__ */ Object.create(null);
|
|
316
329
|
for (let n of e.split(",")) t13[n] = 1;
|
|
317
330
|
return (n) => n in t13;
|
|
318
331
|
}
|
|
319
|
-
var
|
|
320
|
-
a(
|
|
321
|
-
a(`${
|
|
322
|
-
var
|
|
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" };
|
|
323
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");
|
|
324
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");
|
|
325
|
-
var
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
var
|
|
330
|
-
a(we);
|
|
331
|
-
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";
|
|
332
343
|
a(Se);
|
|
333
|
-
var Ce = a(
|
|
334
|
-
|
|
335
|
-
var Re =
|
|
336
|
-
var ze =
|
|
337
|
-
|
|
338
|
-
|
|
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
|
+
}
|
|
339
388
|
function isAnyFunctionPath(path) {
|
|
340
389
|
return path.isFunctionDeclaration() || path.isFunctionExpression() || path.isArrowFunctionExpression();
|
|
341
390
|
}
|
|
@@ -397,7 +446,7 @@ function serializeStaticAttrs(attrs) {
|
|
|
397
446
|
const merged = [];
|
|
398
447
|
let classValue;
|
|
399
448
|
for (const attr of attrs) {
|
|
400
|
-
const name = (_a =
|
|
449
|
+
const name = (_a = ke[attr.name]) != null ? _a : attr.name;
|
|
401
450
|
if (name === "class") {
|
|
402
451
|
classValue = classValue ? `${classValue} ${attr.value}` : String(attr.value);
|
|
403
452
|
} else {
|
|
@@ -407,7 +456,7 @@ function serializeStaticAttrs(attrs) {
|
|
|
407
456
|
if (classValue) merged.unshift({ name: "class", value: classValue });
|
|
408
457
|
return merged.map((attr) => {
|
|
409
458
|
if (attr.value === true) return ` ${attr.name}`;
|
|
410
|
-
return ` ${attr.name}="${
|
|
459
|
+
return ` ${attr.name}="${pe(attr.value)}"`;
|
|
411
460
|
}).join("");
|
|
412
461
|
}
|
|
413
462
|
function resolveComponentCallee(tag, fallback) {
|
|
@@ -426,16 +475,16 @@ function isSerializableStaticValue(value) {
|
|
|
426
475
|
const stack = [value];
|
|
427
476
|
while (stack.length > 0) {
|
|
428
477
|
const current = stack.pop();
|
|
429
|
-
if (
|
|
478
|
+
if (T(current) || A(current) || d(current) || i(current) || U(current)) {
|
|
430
479
|
continue;
|
|
431
480
|
}
|
|
432
|
-
if (
|
|
481
|
+
if (m(current)) {
|
|
433
482
|
for (const item of current) {
|
|
434
483
|
stack.push(item);
|
|
435
484
|
}
|
|
436
485
|
continue;
|
|
437
486
|
}
|
|
438
|
-
if (!
|
|
487
|
+
if (!F(current)) {
|
|
439
488
|
return false;
|
|
440
489
|
}
|
|
441
490
|
const values = Object.values(current);
|
|
@@ -446,21 +495,29 @@ function isSerializableStaticValue(value) {
|
|
|
446
495
|
return true;
|
|
447
496
|
}
|
|
448
497
|
function styleToString(style) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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(";");
|
|
453
510
|
}
|
|
454
511
|
function shouldResolveStaticCollection(attrName) {
|
|
455
512
|
return attrName !== "ref" && !x(attrName, "bind:") && !normalizeEventName(attrName);
|
|
456
513
|
}
|
|
457
514
|
function normalizeTemplateAttrName(attrName) {
|
|
458
515
|
var _a;
|
|
459
|
-
return (_a =
|
|
516
|
+
return (_a = ke[attrName]) != null ? _a : attrName;
|
|
460
517
|
}
|
|
461
518
|
function createStaticAttr(attrName, value, order) {
|
|
462
519
|
return {
|
|
463
|
-
attr: { name: attrName, value },
|
|
520
|
+
attr: { name: attrName, value, order },
|
|
464
521
|
order,
|
|
465
522
|
templateName: normalizeTemplateAttrName(attrName)
|
|
466
523
|
};
|
|
@@ -471,7 +528,8 @@ function createDynamicAttr(attrPath, attrName, value, effectKind, order) {
|
|
|
471
528
|
path: attrPath,
|
|
472
529
|
name: attrName,
|
|
473
530
|
value,
|
|
474
|
-
effectKind
|
|
531
|
+
effectKind,
|
|
532
|
+
order
|
|
475
533
|
},
|
|
476
534
|
order,
|
|
477
535
|
templateName: normalizeTemplateAttrName(attrName)
|
|
@@ -486,13 +544,15 @@ function resolveStaticExpressionValue(attrName, expressionPath) {
|
|
|
486
544
|
return void 0;
|
|
487
545
|
}
|
|
488
546
|
let value = evaluated.value;
|
|
489
|
-
if (attrName === "style"
|
|
490
|
-
|
|
547
|
+
if (attrName === "style") {
|
|
548
|
+
const style = styleToString(value);
|
|
549
|
+
if (style === void 0) return void 0;
|
|
550
|
+
value = style;
|
|
491
551
|
}
|
|
492
|
-
if (i(value) ||
|
|
552
|
+
if (i(value) || A(value)) {
|
|
493
553
|
return value;
|
|
494
554
|
}
|
|
495
|
-
if (
|
|
555
|
+
if (d(value)) {
|
|
496
556
|
return String(value);
|
|
497
557
|
}
|
|
498
558
|
return void 0;
|
|
@@ -545,7 +605,8 @@ function parseAttributes(path) {
|
|
|
545
605
|
if (attrPath.isJSXSpreadAttribute()) {
|
|
546
606
|
spreadAttrs.push({
|
|
547
607
|
value: attrPath.node.argument,
|
|
548
|
-
effectKind: classifyAttrValue(attrPath.node.argument).kind
|
|
608
|
+
effectKind: classifyAttrValue(attrPath.node.argument).kind,
|
|
609
|
+
order
|
|
549
610
|
});
|
|
550
611
|
continue;
|
|
551
612
|
}
|
|
@@ -633,7 +694,7 @@ function unwrapTopLevelDeclaration(statementPath) {
|
|
|
633
694
|
}
|
|
634
695
|
if (statementPath.isExportNamedDeclaration() || statementPath.isExportDefaultDeclaration()) {
|
|
635
696
|
const declarationPath = statementPath.get("declaration");
|
|
636
|
-
if (declarationPath && !
|
|
697
|
+
if (declarationPath && !m(declarationPath) && (declarationPath.isFunctionDeclaration() || declarationPath.isVariableDeclaration())) {
|
|
637
698
|
return declarationPath;
|
|
638
699
|
}
|
|
639
700
|
}
|
|
@@ -1042,7 +1103,7 @@ function patternHasSignalBinding(node) {
|
|
|
1042
1103
|
if (types.isIdentifier(node)) return isSignal(node.name);
|
|
1043
1104
|
if (types.isObjectPattern(node)) {
|
|
1044
1105
|
return node.properties.some(
|
|
1045
|
-
(
|
|
1106
|
+
(p) => types.isRestElement(p) ? patternHasSignalBinding(p.argument) : patternHasSignalBinding(p.value)
|
|
1046
1107
|
);
|
|
1047
1108
|
}
|
|
1048
1109
|
if (types.isArrayPattern(node)) {
|
|
@@ -1071,7 +1132,7 @@ function bindObjectPattern(pattern, base) {
|
|
|
1071
1132
|
}
|
|
1072
1133
|
function resolveObjectProp(prop) {
|
|
1073
1134
|
const target = prop.value;
|
|
1074
|
-
const shorthandId = types.isAssignmentPattern(target) ? target.left : target;
|
|
1135
|
+
const shorthandId = unwrapBindingTarget(types.isAssignmentPattern(target) ? target.left : target);
|
|
1075
1136
|
if (prop.shorthand && types.isIdentifier(shorthandId) && isSignal(shorthandId.name)) {
|
|
1076
1137
|
return { keyExpr: types.identifier(stripSignalPrefix(shorthandId.name)), computed: false, target };
|
|
1077
1138
|
}
|
|
@@ -1091,7 +1152,9 @@ function bindArrayPattern(pattern, base) {
|
|
|
1091
1152
|
out.push(...bindTarget(el.argument, slice));
|
|
1092
1153
|
return;
|
|
1093
1154
|
}
|
|
1094
|
-
out.push(
|
|
1155
|
+
out.push(
|
|
1156
|
+
...bindTarget(el, types.memberExpression(clone(base), types.numericLiteral(i2), true))
|
|
1157
|
+
);
|
|
1095
1158
|
});
|
|
1096
1159
|
return out;
|
|
1097
1160
|
}
|
|
@@ -1099,14 +1162,28 @@ function bindTarget(target, access) {
|
|
|
1099
1162
|
if (types.isAssignmentPattern(target)) {
|
|
1100
1163
|
return bindTarget(target.left, applyDefault(access, target.right));
|
|
1101
1164
|
}
|
|
1165
|
+
if (isTSWrappedBindingTarget(target)) {
|
|
1166
|
+
return bindTarget(unwrapBindingTarget(target), access);
|
|
1167
|
+
}
|
|
1102
1168
|
if (types.isIdentifier(target)) {
|
|
1103
1169
|
const value = isSignal(target.name) ? makeComputed(access) : access;
|
|
1104
1170
|
return [types.variableDeclarator(types.identifier(target.name), value)];
|
|
1105
1171
|
}
|
|
1106
1172
|
if (types.isObjectPattern(target)) return bindObjectPattern(target, access);
|
|
1107
1173
|
if (types.isArrayPattern(target)) return bindArrayPattern(target, access);
|
|
1174
|
+
if (types.isMemberExpression(target)) return [];
|
|
1108
1175
|
return [types.variableDeclarator(target, access)];
|
|
1109
1176
|
}
|
|
1177
|
+
function isTSWrappedBindingTarget(target) {
|
|
1178
|
+
return types.isTSAsExpression(target) || types.isTSSatisfiesExpression(target) || types.isTSTypeAssertion(target) || types.isTSNonNullExpression(target);
|
|
1179
|
+
}
|
|
1180
|
+
function unwrapBindingTarget(target) {
|
|
1181
|
+
let current = target;
|
|
1182
|
+
while (isTSWrappedBindingTarget(current)) {
|
|
1183
|
+
current = current.expression;
|
|
1184
|
+
}
|
|
1185
|
+
return current;
|
|
1186
|
+
}
|
|
1110
1187
|
function applyDefault(access, def) {
|
|
1111
1188
|
return types.conditionalExpression(
|
|
1112
1189
|
types.binaryExpression("===", clone(access), types.identifier("undefined")),
|
|
@@ -1174,9 +1251,9 @@ function isAlreadyValueAccess(path) {
|
|
|
1174
1251
|
if (!types.isParenthesizedExpression(parent) && !types.isTSAsExpression(parent) && !types.isTSNonNullExpression(parent)) {
|
|
1175
1252
|
return false;
|
|
1176
1253
|
}
|
|
1177
|
-
const ancestor = path.findParent((
|
|
1178
|
-
if (!isMemberLike(
|
|
1179
|
-
return isMemberAccessingProperty(
|
|
1254
|
+
const ancestor = path.findParent((p) => {
|
|
1255
|
+
if (!isMemberLike(p.node)) return false;
|
|
1256
|
+
return isMemberAccessingProperty(p.node, "value");
|
|
1180
1257
|
});
|
|
1181
1258
|
return !!ancestor;
|
|
1182
1259
|
}
|
|
@@ -1271,7 +1348,7 @@ function collectObjectPattern(pattern, base, leaves, rests) {
|
|
|
1271
1348
|
continue;
|
|
1272
1349
|
}
|
|
1273
1350
|
const { keyExpr, computed, excludeKey } = resolveKey(prop);
|
|
1274
|
-
if (excludeKey
|
|
1351
|
+
if (!T(excludeKey)) excludeKeys.push(excludeKey);
|
|
1275
1352
|
const access = types.memberExpression(clone2(base), keyExpr, computed);
|
|
1276
1353
|
collectTarget(prop.value, access, leaves, rests);
|
|
1277
1354
|
}
|
|
@@ -1303,7 +1380,7 @@ function ensureBlockBody(path) {
|
|
|
1303
1380
|
return block;
|
|
1304
1381
|
}
|
|
1305
1382
|
function isInsidePattern(ref, pattern) {
|
|
1306
|
-
return !!ref.findParent((
|
|
1383
|
+
return !!ref.findParent((p) => p.node === pattern);
|
|
1307
1384
|
}
|
|
1308
1385
|
function accessorFor(pattern, base, name) {
|
|
1309
1386
|
var _a;
|
|
@@ -1323,7 +1400,7 @@ function transformFnProps(path) {
|
|
|
1323
1400
|
collectObjectPattern(firstParam, base, initLeaves, initRests);
|
|
1324
1401
|
const conflicts = [...initLeaves, ...initRests].map((b2) => b2.name).filter((name) => x(name, signalPrefix));
|
|
1325
1402
|
if (conflicts.length > 0) {
|
|
1326
|
-
|
|
1403
|
+
se("transformProps", "Property names cannot start with signal prefix", conflicts);
|
|
1327
1404
|
}
|
|
1328
1405
|
if (initLeaves.length === 0 && initRests.length === 1 && firstParam.properties.length === 1 && types.isRestElement(firstParam.properties[0])) {
|
|
1329
1406
|
path.node.params[0] = types.identifier(initRests[0].name);
|
|
@@ -1431,6 +1508,18 @@ function hasDynamicBoundary(children, index) {
|
|
|
1431
1508
|
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 */;
|
|
1432
1509
|
return isText(prev) || isText(next) || isDynamic(prev) || isDynamic(next);
|
|
1433
1510
|
}
|
|
1511
|
+
function getDynamicAnchorKind(children, index, mode) {
|
|
1512
|
+
if (!hasDynamicBoundary(children, index)) {
|
|
1513
|
+
const next = children[index + 1];
|
|
1514
|
+
if ((mode === "hydrate" || mode === "server") && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
|
|
1515
|
+
return "element";
|
|
1516
|
+
}
|
|
1517
|
+
if (!next) {
|
|
1518
|
+
return "tail";
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
return "comment";
|
|
1522
|
+
}
|
|
1434
1523
|
function buildIR(path, ctx) {
|
|
1435
1524
|
if (path.isJSXFragment()) {
|
|
1436
1525
|
useImport("Fragment");
|
|
@@ -1447,14 +1536,14 @@ function buildElementIR(tag, path, ctx) {
|
|
|
1447
1536
|
const node = {
|
|
1448
1537
|
type: 0 /* ELEMENT */,
|
|
1449
1538
|
tag,
|
|
1450
|
-
isSVG:
|
|
1539
|
+
isSVG: Ce(tag),
|
|
1451
1540
|
staticAttrs,
|
|
1452
1541
|
dynamicAttrs: [],
|
|
1453
1542
|
events: [],
|
|
1454
|
-
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
|
|
1543
|
+
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
|
|
1455
1544
|
binds: [],
|
|
1456
1545
|
children: [],
|
|
1457
|
-
selfClosing:
|
|
1546
|
+
selfClosing: Re(tag),
|
|
1458
1547
|
loc: path.node.loc
|
|
1459
1548
|
};
|
|
1460
1549
|
for (const attr of dynamicAttrs) {
|
|
@@ -1474,7 +1563,8 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1474
1563
|
props.push({
|
|
1475
1564
|
name: attr.name,
|
|
1476
1565
|
value: i(attr.value) ? types.stringLiteral(attr.value) : types.booleanLiteral(attr.value),
|
|
1477
|
-
kind: "static"
|
|
1566
|
+
kind: "static",
|
|
1567
|
+
order: attr.order
|
|
1478
1568
|
});
|
|
1479
1569
|
}
|
|
1480
1570
|
for (const attr of dynamicAttrs) {
|
|
@@ -1483,7 +1573,8 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1483
1573
|
props.push({
|
|
1484
1574
|
name: attr.name,
|
|
1485
1575
|
value: attr.value,
|
|
1486
|
-
kind: attr.effectKind
|
|
1576
|
+
kind: attr.effectKind,
|
|
1577
|
+
order: attr.order
|
|
1487
1578
|
});
|
|
1488
1579
|
} else if (x(attr.name, "bind:")) {
|
|
1489
1580
|
const binding = attr.name.slice("bind:".length);
|
|
@@ -1494,18 +1585,21 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1494
1585
|
props.push({
|
|
1495
1586
|
name: binding,
|
|
1496
1587
|
value: types.cloneNode(valueExpr),
|
|
1497
|
-
kind: attr.effectKind
|
|
1588
|
+
kind: attr.effectKind,
|
|
1589
|
+
order: attr.order
|
|
1498
1590
|
});
|
|
1499
1591
|
props.push({
|
|
1500
1592
|
name: `update:${binding}`,
|
|
1501
1593
|
value: createBindingSetter(valueExpr),
|
|
1502
|
-
kind: "static"
|
|
1594
|
+
kind: "static",
|
|
1595
|
+
order: attr.order
|
|
1503
1596
|
});
|
|
1504
1597
|
} else {
|
|
1505
1598
|
props.push({
|
|
1506
1599
|
name: attr.name,
|
|
1507
1600
|
value: attr.value,
|
|
1508
|
-
kind: attr.effectKind
|
|
1601
|
+
kind: attr.effectKind,
|
|
1602
|
+
order: attr.order
|
|
1509
1603
|
});
|
|
1510
1604
|
}
|
|
1511
1605
|
}
|
|
@@ -1513,7 +1607,7 @@ function buildComponentIR(tag, path, ctx) {
|
|
|
1513
1607
|
type: 1 /* COMPONENT */,
|
|
1514
1608
|
tag,
|
|
1515
1609
|
props,
|
|
1516
|
-
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind })),
|
|
1610
|
+
spreads: spreadAttrs.map((s) => ({ value: s.value, kind: s.effectKind, order: s.order })),
|
|
1517
1611
|
children: buildChildren(path, ctx),
|
|
1518
1612
|
loc: path.node.loc
|
|
1519
1613
|
};
|
|
@@ -1522,7 +1616,7 @@ function applyDynamicAttr(node, attr, ctx) {
|
|
|
1522
1616
|
const { name, value, effectKind, path } = attr;
|
|
1523
1617
|
const eventName = normalizeEventName(name);
|
|
1524
1618
|
if (eventName) {
|
|
1525
|
-
const delegated = !!(ctx.options.delegateEvents &&
|
|
1619
|
+
const delegated = !!(ctx.options.delegateEvents && ze(eventName));
|
|
1526
1620
|
node.events.push({
|
|
1527
1621
|
name: eventName,
|
|
1528
1622
|
handler: value,
|
|
@@ -1610,7 +1704,7 @@ function isPropsChildrenExpression(expression) {
|
|
|
1610
1704
|
const binding = expression.scope.getBinding(node.object.name);
|
|
1611
1705
|
const bindingPath = binding == null ? void 0 : binding.path;
|
|
1612
1706
|
if (!(bindingPath == null ? void 0 : bindingPath.isIdentifier())) return false;
|
|
1613
|
-
const owner = bindingPath.findParent((
|
|
1707
|
+
const owner = bindingPath.findParent((p) => isAnyFunctionPath(p));
|
|
1614
1708
|
if (!owner) return false;
|
|
1615
1709
|
const fn = owner.node;
|
|
1616
1710
|
const componentName = getEnclosingFunctionName(owner);
|
|
@@ -1673,6 +1767,7 @@ function buildForIR(expression, ctx) {
|
|
|
1673
1767
|
};
|
|
1674
1768
|
}
|
|
1675
1769
|
function extractKeyExpression(path) {
|
|
1770
|
+
if (path.isJSXFragment()) return extractFragmentKeyExpression(path);
|
|
1676
1771
|
if (!path.isJSXElement()) return null;
|
|
1677
1772
|
for (const attrPath of path.get("openingElement.attributes")) {
|
|
1678
1773
|
if (!attrPath.isJSXAttribute()) continue;
|
|
@@ -1687,7 +1782,7 @@ function extractKeyExpression(path) {
|
|
|
1687
1782
|
return types.stringLiteral(value.value);
|
|
1688
1783
|
}
|
|
1689
1784
|
const valuePath = attrPath.get("value");
|
|
1690
|
-
if (!
|
|
1785
|
+
if (!m(valuePath) && valuePath.isJSXExpressionContainer()) {
|
|
1691
1786
|
const expressionPath = valuePath.get("expression");
|
|
1692
1787
|
attrPath.remove();
|
|
1693
1788
|
if (expressionPath.isJSXEmptyExpression()) return null;
|
|
@@ -1698,9 +1793,16 @@ function extractKeyExpression(path) {
|
|
|
1698
1793
|
}
|
|
1699
1794
|
return null;
|
|
1700
1795
|
}
|
|
1796
|
+
function extractFragmentKeyExpression(path) {
|
|
1797
|
+
const children = path.get("children").filter(isValidChild);
|
|
1798
|
+
if (children.length !== 1) return null;
|
|
1799
|
+
const child = children[0];
|
|
1800
|
+
if (!child.isJSXElement() && !child.isJSXFragment()) return null;
|
|
1801
|
+
return extractKeyExpression(child);
|
|
1802
|
+
}
|
|
1701
1803
|
function getForCallbackBody(callback) {
|
|
1702
1804
|
const bodyPath = callback.get("body");
|
|
1703
|
-
if (
|
|
1805
|
+
if (m(bodyPath)) return null;
|
|
1704
1806
|
if (bodyPath.isJSXElement() || bodyPath.isJSXFragment()) {
|
|
1705
1807
|
return {
|
|
1706
1808
|
path: bodyPath,
|
|
@@ -1717,7 +1819,7 @@ function getForCallbackBody(callback) {
|
|
|
1717
1819
|
continue;
|
|
1718
1820
|
}
|
|
1719
1821
|
const argument = statement.get("argument");
|
|
1720
|
-
if (
|
|
1822
|
+
if (m(argument) || !argument.node) {
|
|
1721
1823
|
prelude.push(statement.node);
|
|
1722
1824
|
continue;
|
|
1723
1825
|
}
|
|
@@ -1793,16 +1895,55 @@ function createPropNode(name, value, kind, options) {
|
|
|
1793
1895
|
function composePropsExpression(props, spreads, options) {
|
|
1794
1896
|
if (spreads.length === 0) {
|
|
1795
1897
|
if (props.length === 0) return types.objectExpression([]);
|
|
1796
|
-
return types.objectExpression(props.map((
|
|
1898
|
+
return types.objectExpression(props.map((p) => createPropNode(p.name, p.value, p.kind, options)));
|
|
1899
|
+
}
|
|
1900
|
+
if (props.some((prop) => prop.order == null) || spreads.some((spread) => spread.order == null)) {
|
|
1901
|
+
return composeUnorderedPropsExpression(props, spreads, options);
|
|
1902
|
+
}
|
|
1903
|
+
const ordered = [
|
|
1904
|
+
...props.map((prop, sequence) => ({
|
|
1905
|
+
type: "prop",
|
|
1906
|
+
order: prop.order,
|
|
1907
|
+
sequence,
|
|
1908
|
+
prop
|
|
1909
|
+
})),
|
|
1910
|
+
...spreads.map((spread, sequence) => ({
|
|
1911
|
+
type: "spread",
|
|
1912
|
+
order: spread.order,
|
|
1913
|
+
sequence,
|
|
1914
|
+
spread
|
|
1915
|
+
}))
|
|
1916
|
+
].sort((a2, b2) => a2.order - b2.order || a2.sequence - b2.sequence);
|
|
1917
|
+
const parts = [];
|
|
1918
|
+
let propNodes = [];
|
|
1919
|
+
const flushProps = () => {
|
|
1920
|
+
if (propNodes.length === 0) return;
|
|
1921
|
+
parts.push(types.objectExpression(propNodes));
|
|
1922
|
+
propNodes = [];
|
|
1923
|
+
};
|
|
1924
|
+
for (const entry of ordered) {
|
|
1925
|
+
if (entry.type === "prop") {
|
|
1926
|
+
propNodes.push(createPropNode(entry.prop.name, entry.prop.value, entry.prop.kind, options));
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1929
|
+
flushProps();
|
|
1930
|
+
parts.push(cloneValue(entry.spread.value, options.cloneValues));
|
|
1797
1931
|
}
|
|
1932
|
+
flushProps();
|
|
1933
|
+
return composeAssignParts(parts);
|
|
1934
|
+
}
|
|
1935
|
+
function composeUnorderedPropsExpression(props, spreads, options) {
|
|
1798
1936
|
const parts = [];
|
|
1799
|
-
const propNodes = props.map((
|
|
1937
|
+
const propNodes = props.map((p) => createPropNode(p.name, p.value, p.kind, options));
|
|
1800
1938
|
if (propNodes.length > 0) {
|
|
1801
1939
|
parts.push(types.objectExpression(propNodes));
|
|
1802
1940
|
}
|
|
1803
1941
|
for (const spread of spreads) {
|
|
1804
1942
|
parts.push(cloneValue(spread.value, options.cloneValues));
|
|
1805
1943
|
}
|
|
1944
|
+
return composeAssignParts(parts);
|
|
1945
|
+
}
|
|
1946
|
+
function composeAssignParts(parts) {
|
|
1806
1947
|
if (parts.length === 0) return types.objectExpression([]);
|
|
1807
1948
|
if (parts.length === 1) return parts[0];
|
|
1808
1949
|
return types.callExpression(types.memberExpression(types.identifier("Object"), types.identifier("assign")), [
|
|
@@ -1905,7 +2046,7 @@ function renderChildExpressions(children, render, options = {}) {
|
|
|
1905
2046
|
}
|
|
1906
2047
|
function buildComponentInvocation(tag, node, options) {
|
|
1907
2048
|
const createComponentId = options.wrap ? useImport("createComponent") : null;
|
|
1908
|
-
const callee = resolveComponentCallee(tag,
|
|
2049
|
+
const callee = resolveComponentCallee(tag, buildComponentTagExpression(tag));
|
|
1909
2050
|
const props = buildComponentPropsExpression(node, {
|
|
1910
2051
|
dynamicPropsAsGetters: options.dynamicPropsAsGetters,
|
|
1911
2052
|
cloneValues: options.cloneValues,
|
|
@@ -1918,6 +2059,13 @@ function buildComponentInvocation(tag, node, options) {
|
|
|
1918
2059
|
}
|
|
1919
2060
|
return types.callExpression(callee, [props]);
|
|
1920
2061
|
}
|
|
2062
|
+
function buildComponentTagExpression(tag) {
|
|
2063
|
+
const [head, ...parts] = tag.split(".");
|
|
2064
|
+
return parts.reduce(
|
|
2065
|
+
(expr, part) => types.memberExpression(expr, types.identifier(part)),
|
|
2066
|
+
types.identifier(head)
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
1921
2069
|
|
|
1922
2070
|
// src/jsx/server.ts
|
|
1923
2071
|
var SERVER_TEXT_ESCAPES = {
|
|
@@ -2020,28 +2168,13 @@ function escapeChildExpression(expr) {
|
|
|
2020
2168
|
if (isSafeServerHtml(expr)) {
|
|
2021
2169
|
return expr;
|
|
2022
2170
|
}
|
|
2023
|
-
if (types.isParenthesizedExpression(expr)) {
|
|
2024
|
-
expr.expression = escapeChildExpression(expr.expression);
|
|
2025
|
-
return expr;
|
|
2026
|
-
}
|
|
2027
2171
|
if (types.isLogicalExpression(expr)) {
|
|
2028
2172
|
if (expr.operator === "&&") {
|
|
2029
2173
|
expr.right = escapeChildExpression(expr.right);
|
|
2174
|
+
return expr;
|
|
2030
2175
|
} else {
|
|
2031
|
-
|
|
2032
|
-
expr.right = escapeChildExpression(expr.right);
|
|
2176
|
+
return types.callExpression(useImport("escape"), [expr]);
|
|
2033
2177
|
}
|
|
2034
|
-
return expr;
|
|
2035
|
-
}
|
|
2036
|
-
if (types.isConditionalExpression(expr)) {
|
|
2037
|
-
expr.consequent = escapeChildExpression(expr.consequent);
|
|
2038
|
-
expr.alternate = escapeChildExpression(expr.alternate);
|
|
2039
|
-
return expr;
|
|
2040
|
-
}
|
|
2041
|
-
if (types.isSequenceExpression(expr) && expr.expressions.length > 0) {
|
|
2042
|
-
const last = expr.expressions.length - 1;
|
|
2043
|
-
expr.expressions[last] = escapeChildExpression(expr.expressions[last]);
|
|
2044
|
-
return expr;
|
|
2045
2178
|
}
|
|
2046
2179
|
return types.callExpression(useImport("escape"), [expr]);
|
|
2047
2180
|
}
|
|
@@ -2082,7 +2215,7 @@ function generateServerFor(node, ctx) {
|
|
|
2082
2215
|
return buildForCall(node, bodyExpr);
|
|
2083
2216
|
}
|
|
2084
2217
|
function generateServerElement(node, ctx, withHydrationKey = true, staticIndex, options = {}) {
|
|
2085
|
-
var _a
|
|
2218
|
+
var _a;
|
|
2086
2219
|
const dynamicAttrExprs = [...(_a = options.prependAttrExprs) != null ? _a : []];
|
|
2087
2220
|
for (const attr of node.dynamicAttrs) {
|
|
2088
2221
|
let expr;
|
|
@@ -2110,7 +2243,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2110
2243
|
}
|
|
2111
2244
|
const templates = [];
|
|
2112
2245
|
const expressions = [];
|
|
2113
|
-
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name:
|
|
2246
|
+
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
|
|
2114
2247
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2115
2248
|
const textareaValueBind = node.tag === "textarea" ? findBind(node, "value") : null;
|
|
2116
2249
|
let currentStr = `<${node.tag}`;
|
|
@@ -2141,11 +2274,11 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2141
2274
|
if (child.type === 2 /* TEXT */) {
|
|
2142
2275
|
currentStr += escapeServerTemplateText(child.value);
|
|
2143
2276
|
} else if (child.type === 3 /* EXPRESSION */ || child.type === 1 /* COMPONENT */ || child.type === 4 /* FOR */) {
|
|
2144
|
-
const
|
|
2277
|
+
const anchorKind = getDynamicAnchorKind(node.children, i2, "server");
|
|
2145
2278
|
const slotIndex = markerIndex++;
|
|
2146
2279
|
templates.push(currentStr);
|
|
2147
|
-
currentStr =
|
|
2148
|
-
if (
|
|
2280
|
+
currentStr = anchorKind === "comment" ? `<!--${slotIndex}-->` : "";
|
|
2281
|
+
if (anchorKind === "element") {
|
|
2149
2282
|
pendingAnchorIndex = slotIndex;
|
|
2150
2283
|
}
|
|
2151
2284
|
expressions.push(generateServerNode(child, ctx));
|
|
@@ -2168,7 +2301,7 @@ function generateServerElement(node, ctx, withHydrationKey = true, staticIndex,
|
|
|
2168
2301
|
}
|
|
2169
2302
|
}
|
|
2170
2303
|
const staticHTML = buildStaticServerHTML(child, anchorIndex);
|
|
2171
|
-
if (staticHTML
|
|
2304
|
+
if (!T(staticHTML)) {
|
|
2172
2305
|
currentStr += staticHTML;
|
|
2173
2306
|
} else {
|
|
2174
2307
|
templates.push(currentStr);
|
|
@@ -2213,7 +2346,7 @@ function buildStaticServerHTML(node, staticIndex) {
|
|
|
2213
2346
|
if (node.binds.length > 0 || node.dynamicAttrs.length > 0 || node.spreads.length > 0) {
|
|
2214
2347
|
return null;
|
|
2215
2348
|
}
|
|
2216
|
-
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name:
|
|
2349
|
+
const staticAttrs = staticIndex === void 0 ? node.staticAttrs : [...node.staticAttrs, { name: je, value: String(staticIndex) }];
|
|
2217
2350
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2218
2351
|
if (node.selfClosing) {
|
|
2219
2352
|
return `<${node.tag}${attrs} />`;
|
|
@@ -2225,7 +2358,7 @@ function buildStaticServerHTML(node, staticIndex) {
|
|
|
2225
2358
|
} else if (child.type === 0 /* ELEMENT */) {
|
|
2226
2359
|
if (child.binds.length > 0) return null;
|
|
2227
2360
|
const nested = buildStaticServerHTML(child);
|
|
2228
|
-
if (nested
|
|
2361
|
+
if (T(nested)) return null;
|
|
2229
2362
|
html += nested;
|
|
2230
2363
|
} else {
|
|
2231
2364
|
return null;
|
|
@@ -2263,18 +2396,6 @@ function shouldCloseTag(element, isLastElement, hasClosingParent, options) {
|
|
|
2263
2396
|
function closeTag(element, isLastElement, hasClosingParent, options) {
|
|
2264
2397
|
return shouldCloseTag(element, isLastElement, hasClosingParent, options) ? `</${element.tag}>` : "";
|
|
2265
2398
|
}
|
|
2266
|
-
function getDynamicAnchorKind(children, index, mode) {
|
|
2267
|
-
if ((mode === "client" || mode === "hydrate") && !hasDynamicBoundary(children, index)) {
|
|
2268
|
-
const next = children[index + 1];
|
|
2269
|
-
if (mode === "hydrate" && (next == null ? void 0 : next.type) === 0 /* ELEMENT */) {
|
|
2270
|
-
return "element";
|
|
2271
|
-
}
|
|
2272
|
-
if (!next) {
|
|
2273
|
-
return "tail";
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
return "comment";
|
|
2277
|
-
}
|
|
2278
2399
|
function findLastOmittableElementIndex(children, mode) {
|
|
2279
2400
|
for (let i2 = children.length - 1; i2 >= 0; i2--) {
|
|
2280
2401
|
const child = children[i2];
|
|
@@ -2299,7 +2420,7 @@ function buildTemplateAndFlatten(root, mode) {
|
|
|
2299
2420
|
const myId = nextId++;
|
|
2300
2421
|
const staticAttrs = mode === "hydrate" && forcedStaticIndex !== void 0 ? [
|
|
2301
2422
|
...element.staticAttrs,
|
|
2302
|
-
{ name:
|
|
2423
|
+
{ name: je, value: String(forcedStaticIndex) }
|
|
2303
2424
|
] : element.staticAttrs;
|
|
2304
2425
|
const attrs = serializeStaticAttrs(staticAttrs);
|
|
2305
2426
|
if (element.selfClosing) {
|
|
@@ -2338,7 +2459,7 @@ function buildTemplateAndFlatten(root, mode) {
|
|
|
2338
2459
|
const child = element.children[i2];
|
|
2339
2460
|
switch (child.type) {
|
|
2340
2461
|
case 2 /* TEXT */:
|
|
2341
|
-
template += mode === "hydrate" ? child.value :
|
|
2462
|
+
template += mode === "hydrate" ? child.value : pe(child.value);
|
|
2342
2463
|
nodes.push({
|
|
2343
2464
|
id: nextId++,
|
|
2344
2465
|
kind: "text",
|
|
@@ -2405,7 +2526,7 @@ function buildStaticTemplateString(node, mode) {
|
|
|
2405
2526
|
function visit(current, isLastElement, hasClosingParent) {
|
|
2406
2527
|
switch (current.type) {
|
|
2407
2528
|
case 2 /* TEXT */:
|
|
2408
|
-
return mode === "hydrate" ? current.value :
|
|
2529
|
+
return mode === "hydrate" ? current.value : pe(current.value);
|
|
2409
2530
|
case 0 /* ELEMENT */: {
|
|
2410
2531
|
const attrs = serializeStaticAttrs(current.staticAttrs);
|
|
2411
2532
|
if (current.selfClosing) return selfClosingTag(current, attrs);
|
|
@@ -2708,7 +2829,7 @@ function emitDynamicAttr(attr, target, body, state, pendingMemoPatches) {
|
|
|
2708
2829
|
function emitSpread(spread, target, body, state, pendingMemoPatches) {
|
|
2709
2830
|
emitPatchOrEffect(
|
|
2710
2831
|
target,
|
|
2711
|
-
|
|
2832
|
+
He,
|
|
2712
2833
|
spread.value,
|
|
2713
2834
|
spread.kind,
|
|
2714
2835
|
body,
|