@kdujs/compiler-ssr-canary
Advanced tools
Comparing version 3.20240812.0-minor.0 to 3.20240812.0
@@ -222,3 +222,3 @@ 'use strict'; | ||
const wipMap$2 = /* @__PURE__ */ new WeakMap(); | ||
const wipMap$3 = /* @__PURE__ */ new WeakMap(); | ||
function ssrTransformSuspense(node, context) { | ||
@@ -232,20 +232,24 @@ return () => { | ||
}; | ||
wipMap$2.set(node, wipEntry); | ||
wipEntry.slotsExp = compilerDom.buildSlots(node, context, (_props, children, loc) => { | ||
const fn = compilerDom.createFunctionExpression( | ||
[], | ||
void 0, | ||
// no return, assign body later | ||
true, | ||
// newline | ||
false, | ||
// suspense slots are not treated as normal slots | ||
loc | ||
); | ||
wipEntry.wipSlots.push({ | ||
fn, | ||
children | ||
}); | ||
return fn; | ||
}).slots; | ||
wipMap$3.set(node, wipEntry); | ||
wipEntry.slotsExp = compilerDom.buildSlots( | ||
node, | ||
context, | ||
(_props, _kForExp, children, loc) => { | ||
const fn = compilerDom.createFunctionExpression( | ||
[], | ||
void 0, | ||
// no return, assign body later | ||
true, | ||
// newline | ||
false, | ||
// suspense slots are not treated as normal slots | ||
loc | ||
); | ||
wipEntry.wipSlots.push({ | ||
fn, | ||
children | ||
}); | ||
return fn; | ||
} | ||
).slots; | ||
} | ||
@@ -255,3 +259,3 @@ }; | ||
function ssrProcessSuspense(node, context) { | ||
const wipEntry = wipMap$2.get(node); | ||
const wipEntry = wipMap$3.get(node); | ||
if (!wipEntry) { | ||
@@ -562,3 +566,3 @@ return; | ||
const wipMap$1 = /* @__PURE__ */ new WeakMap(); | ||
const wipMap$2 = /* @__PURE__ */ new WeakMap(); | ||
function ssrTransformTransitionGroup(node, context) { | ||
@@ -584,5 +588,6 @@ return () => { | ||
} | ||
wipMap$1.set(node, { | ||
wipMap$2.set(node, { | ||
tag, | ||
propsExp | ||
propsExp, | ||
scopeId: context.scopeId || null | ||
}); | ||
@@ -593,5 +598,5 @@ } | ||
function ssrProcessTransitionGroup(node, context) { | ||
const entry = wipMap$1.get(node); | ||
const entry = wipMap$2.get(node); | ||
if (entry) { | ||
const { tag, propsExp } = entry; | ||
const { tag, propsExp, scopeId } = entry; | ||
if (tag.type === 7) { | ||
@@ -603,2 +608,5 @@ context.pushStringPart(`<`); | ||
} | ||
if (scopeId) { | ||
context.pushStringPart(` ${scopeId}`); | ||
} | ||
context.pushStringPart(`>`); | ||
@@ -625,2 +633,5 @@ processChildren( | ||
} | ||
if (scopeId) { | ||
context.pushStringPart(` ${scopeId}`); | ||
} | ||
context.pushStringPart(`>`); | ||
@@ -635,2 +646,21 @@ processChildren(node, context, false, true); | ||
const wipMap$1 = /* @__PURE__ */ new WeakMap(); | ||
function ssrTransformTransition(node, context) { | ||
return () => { | ||
const appear = compilerDom.findProp(node, "appear", false, true); | ||
wipMap$1.set(node, !!appear); | ||
}; | ||
} | ||
function ssrProcessTransition(node, context) { | ||
node.children = node.children.filter((c) => c.type !== 3); | ||
const appear = wipMap$1.get(node); | ||
if (appear) { | ||
context.pushStringPart(`<template>`); | ||
processChildren(node, context, false, true); | ||
context.pushStringPart(`</template>`); | ||
} else { | ||
processChildren(node, context, false, true); | ||
} | ||
} | ||
const wipMap = /* @__PURE__ */ new WeakMap(); | ||
@@ -654,5 +684,6 @@ const WIP_SLOT = Symbol(); | ||
return ssrTransformSuspense(node, context); | ||
} | ||
if (component === compilerDom.TRANSITION_GROUP) { | ||
} else if (component === compilerDom.TRANSITION_GROUP) { | ||
return ssrTransformTransitionGroup(node, context); | ||
} else if (component === compilerDom.TRANSITION) { | ||
return ssrTransformTransition(node); | ||
} | ||
@@ -665,4 +696,6 @@ return; | ||
if (clonedNode.children.length) { | ||
compilerDom.buildSlots(clonedNode, context, (props, children) => { | ||
knodeBranches.push(createKNodeSlotBranch(props, children, context)); | ||
compilerDom.buildSlots(clonedNode, context, (props, kFor, children) => { | ||
knodeBranches.push( | ||
createKNodeSlotBranch(props, kFor, children, context) | ||
); | ||
return compilerDom.createFunctionExpression(void 0); | ||
@@ -686,3 +719,3 @@ }); | ||
wipMap.set(node, wipEntries); | ||
const buildSSRSlotFn = (props, children, loc) => { | ||
const buildSSRSlotFn = (props, _kForExp, children, loc) => { | ||
const param0 = props && compilerDom.stringifyExpression(props) || `_`; | ||
@@ -744,3 +777,3 @@ const fn = compilerDom.createFunctionExpression( | ||
if (component === compilerDom.TRANSITION) { | ||
node.children = node.children.filter((c) => c.type !== 3); | ||
return ssrProcessTransition(node, context); | ||
} | ||
@@ -784,3 +817,3 @@ processChildren(node, context); | ||
}; | ||
function createKNodeSlotBranch(props, children, parentContext) { | ||
function createKNodeSlotBranch(props, kForExp, children, parentContext) { | ||
const rawOptions = rawOptionsMap.get(parentContext.root); | ||
@@ -805,4 +838,4 @@ const subOptions = { | ||
isSelfClosing: false, | ||
// important: provide k-slot="props" on the wrapper for proper | ||
// scope analysis | ||
// important: provide k-slot="props" and k-for="exp" on the wrapper for | ||
// proper scope analysis | ||
props: [ | ||
@@ -816,2 +849,10 @@ { | ||
loc: compilerDom.locStub | ||
}, | ||
{ | ||
type: 7, | ||
name: "for", | ||
exp: kForExp, | ||
arg: void 0, | ||
modifiers: [], | ||
loc: compilerDom.locStub | ||
} | ||
@@ -1022,2 +1063,34 @@ ], | ||
} | ||
function processOption(plainNode) { | ||
if (plainNode.tag === "option") { | ||
if (plainNode.props.findIndex((p) => p.name === "selected") === -1) { | ||
const value = findValueBinding(plainNode); | ||
plainNode.ssrCodegenNode.elements.push( | ||
compilerDom.createConditionalExpression( | ||
compilerDom.createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [ | ||
compilerDom.createConditionalExpression( | ||
compilerDom.createCallExpression(`Array.isArray`, [model]), | ||
compilerDom.createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [ | ||
model, | ||
value | ||
]), | ||
compilerDom.createCallExpression(context.helper(SSR_LOOSE_EQUAL), [ | ||
model, | ||
value | ||
]) | ||
) | ||
]), | ||
compilerDom.createSimpleExpression(" selected", true), | ||
compilerDom.createSimpleExpression("", true), | ||
false | ||
/* no newline */ | ||
) | ||
); | ||
} | ||
} else if (plainNode.tag === "optgroup") { | ||
plainNode.children.forEach( | ||
(option) => processOption(option) | ||
); | ||
} | ||
} | ||
if (node.tagType === 0) { | ||
@@ -1105,29 +1178,5 @@ const res = { props: [] }; | ||
} else if (node.tag === "select") { | ||
node.children.forEach((option) => { | ||
if (option.type === 1) { | ||
const plainNode = option; | ||
if (plainNode.props.findIndex((p) => p.name === "selected") === -1) { | ||
const value = findValueBinding(plainNode); | ||
plainNode.ssrCodegenNode.elements.push( | ||
compilerDom.createConditionalExpression( | ||
compilerDom.createCallExpression(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [ | ||
compilerDom.createConditionalExpression( | ||
compilerDom.createCallExpression(`Array.isArray`, [model]), | ||
compilerDom.createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [ | ||
model, | ||
value | ||
]), | ||
compilerDom.createCallExpression(context.helper(SSR_LOOSE_EQUAL), [ | ||
model, | ||
value | ||
]) | ||
) | ||
]), | ||
compilerDom.createSimpleExpression(" selected", true), | ||
compilerDom.createSimpleExpression("", true), | ||
false | ||
/* no newline */ | ||
) | ||
); | ||
} | ||
node.children.forEach((child) => { | ||
if (child.type === 1) { | ||
processOption(child); | ||
} | ||
@@ -1312,3 +1361,3 @@ }); | ||
on: compilerDom.transformOn, | ||
// model and show has dedicated SSR handling | ||
// model and show have dedicated SSR handling | ||
model: ssrTransformModel, | ||
@@ -1315,0 +1364,0 @@ show: ssrTransformShow, |
{ | ||
"name": "@kdujs/compiler-ssr-canary", | ||
"version": "3.20240812.0-minor.0", | ||
"version": "3.20240812.0", | ||
"description": "@kdujs/compiler-ssr", | ||
@@ -31,5 +31,5 @@ "main": "dist/compiler-ssr.cjs.js", | ||
"dependencies": { | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20240812.0-minor.0", | ||
"@kdujs/compiler-dom": "npm:@kdujs/compiler-dom-canary@3.20240812.0-minor.0" | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20240812.0", | ||
"@kdujs/compiler-dom": "npm:@kdujs/compiler-dom-canary@3.20240812.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
45948
1341
1
+ Added@kdujs/compiler-core-canary@3.20240812.0(transitive)
+ Added@kdujs/compiler-dom-canary@3.20240812.0(transitive)
+ Added@kdujs/shared-canary@3.20240812.0(transitive)
- Removed@kdujs/compiler-core-canary@3.20240812.0-minor.0(transitive)
- Removed@kdujs/compiler-dom-canary@3.20240812.0-minor.0(transitive)
- Removed@kdujs/shared-canary@3.20240812.0-minor.0(transitive)
Updated@kdujs/compiler-dom@npm:@kdujs/compiler-dom-canary@3.20240812.0