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