@kudzujs/core 0.16.30 → 0.16.32
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/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Kudzu compiles ordinary React-shaped TypeScript and TSX into complete static HTM
|
|
|
14
14
|
|
|
15
15
|
> Experimental `0.16.x`: the compiler API and supported TSX surface may change.
|
|
16
16
|
|
|
17
|
-
**Current release: [0.16.
|
|
17
|
+
**Current release: [0.16.32](https://github.com/kudzujs/kudzu/releases/tag/v0.16.32).** Write reusable components, native event handlers, and pure collection expressions; Kudzu specializes supported source into static content and direct browser updates. Runtime families whose branches own no state omit conditional state lifecycle code, removing 334 raw JavaScript bytes from the search fixture while preserving stateful remounts. AI-cost and 1.0 gates remain blocked.
|
|
18
18
|
|
|
19
19
|
- [Documentation](https://kudzujs.cloud/docs)
|
|
20
20
|
- [Installation guide](https://kudzujs.cloud/docs#install)
|
|
@@ -131,8 +131,8 @@ function mountConditions(root) {
|
|
|
131
131
|
const truthy = globalThis.__KUDZU_SVG_CONDITIONS__ && descriptor.svg ? start.dataset.kSvgTrue : start.content.querySelector("template[data-k-true]")
|
|
132
132
|
const falsy = globalThis.__KUDZU_SVG_CONDITIONS__ && descriptor.svg ? start.dataset.kSvgFalse : start.content.querySelector("template[data-k-false]")
|
|
133
133
|
if (!end || !truthy || !falsy) continue
|
|
134
|
-
const condition = { start, end, truthy, falsy, svg: globalThis.__KUDZU_SVG_CONDITIONS__ && descriptor.svg, kind: descriptor.kind, current: conditionKey(descriptor.kind, descriptor.initial), mount: descriptor.mount, owned: descriptor.owned }
|
|
135
|
-
mountConditionStates(condition, Boolean(descriptor.initial), false)
|
|
134
|
+
const condition = { start, end, truthy, falsy, svg: globalThis.__KUDZU_SVG_CONDITIONS__ && descriptor.svg, kind: descriptor.kind, current: conditionKey(descriptor.kind, descriptor.initial), mount: descriptor.mount, owned: globalThis.__KUDZU_CONDITION_STATE__ !== false && descriptor.owned }
|
|
135
|
+
if (globalThis.__KUDZU_CONDITION_STATE__ !== false) mountConditionStates(condition, Boolean(descriptor.initial), false)
|
|
136
136
|
const mount = evaluator => {
|
|
137
137
|
if (!start.isConnected) return
|
|
138
138
|
condition.read = evaluator.read
|
|
@@ -155,7 +155,7 @@ function updateCondition(condition) {
|
|
|
155
155
|
if (next === condition.current) return
|
|
156
156
|
const previous = condition.current === "true"
|
|
157
157
|
removeConditionRange(condition.start, condition.end, condition.mount)
|
|
158
|
-
unmountConditionStates(condition, previous)
|
|
158
|
+
if (globalThis.__KUDZU_CONDITION_STATE__ !== false) unmountConditionStates(condition, previous)
|
|
159
159
|
const truthy = Boolean(value)
|
|
160
160
|
const falseText = condition.kind === "and" && !truthy ? renderFalsy(value) : ""
|
|
161
161
|
const fragment = falseText
|
|
@@ -164,7 +164,7 @@ function updateCondition(condition) {
|
|
|
164
164
|
? svgFragment(condition.start, truthy ? condition.truthy : condition.falsy)
|
|
165
165
|
: (truthy ? condition.truthy : condition.falsy).content.cloneNode(true)
|
|
166
166
|
const nodes = condition.mount ? [...fragment.childNodes] : undefined
|
|
167
|
-
mountConditionStates(condition, truthy, true)
|
|
167
|
+
if (globalThis.__KUDZU_CONDITION_STATE__ !== false) mountConditionStates(condition, truthy, true)
|
|
168
168
|
condition.end.parentNode.insertBefore(fragment, condition.end)
|
|
169
169
|
condition.current = next
|
|
170
170
|
if (condition.mount) for (const node of nodes) mountDom(node)
|
|
@@ -195,7 +195,7 @@ function unmountConditions(root) {
|
|
|
195
195
|
for (const start of matching(root, "template[data-k-if]")) {
|
|
196
196
|
const registration = conditionRegistrations.get(start)
|
|
197
197
|
for (const [id, condition] of registration?.registrations ?? []) conditionTargets.get(id)?.delete(condition)
|
|
198
|
-
if (registration?.condition) unmountConditionStates(registration.condition, registration.condition.current === "true")
|
|
198
|
+
if (globalThis.__KUDZU_CONDITION_STATE__ !== false && registration?.condition) unmountConditionStates(registration.condition, registration.condition.current === "true")
|
|
199
199
|
conditionRegistrations.delete(start)
|
|
200
200
|
mountedConditions.delete(start)
|
|
201
201
|
}
|
|
@@ -211,7 +211,7 @@ function releaseBindings(id) {
|
|
|
211
211
|
for (const condition of conditionTargets.get(id) ?? []) {
|
|
212
212
|
const registration = conditionRegistrations.get(condition.start)
|
|
213
213
|
for (const [conditionId, entry] of registration?.registrations ?? []) conditionTargets.get(conditionId)?.delete(entry)
|
|
214
|
-
unmountConditionStates(condition, condition.current === "true")
|
|
214
|
+
if (globalThis.__KUDZU_CONDITION_STATE__ !== false) unmountConditionStates(condition, condition.current === "true")
|
|
215
215
|
conditionRegistrations.delete(condition.start)
|
|
216
216
|
}
|
|
217
217
|
conditionTargets.delete(id)
|
|
@@ -15,7 +15,7 @@ export function planRouteCapabilities(records, { navigationRouteCount = 0 } = {}
|
|
|
15
15
|
for (const plan of plans) assertRouteIR(plan, { concrete: true })
|
|
16
16
|
const commandEvents = new Set()
|
|
17
17
|
const nativeEvents = new Set()
|
|
18
|
-
const bindings = { count: 0, text: false, style: false, conditions: false, svgConditions: false }
|
|
18
|
+
const bindings = { count: 0, text: false, style: false, conditions: false, conditionState: false, svgConditions: false }
|
|
19
19
|
const lists = {
|
|
20
20
|
count: 0,
|
|
21
21
|
styleCount: 0,
|
|
@@ -54,6 +54,7 @@ export function planRouteCapabilities(records, { navigationRouteCount = 0 } = {}
|
|
|
54
54
|
bindings.text ||= plan.bindings.some(binding => binding.target === "text")
|
|
55
55
|
bindings.style ||= plan.bindings.some(binding => binding.target === "style")
|
|
56
56
|
bindings.conditions ||= plan.conditions.length > 0
|
|
57
|
+
bindings.conditionState ||= plan.conditions.some(condition => Object.values(condition.owned ?? {}).some(states => states.length > 0))
|
|
57
58
|
bindings.svgConditions ||= plan.conditions.some(condition => condition.svg)
|
|
58
59
|
effects.any ||= plan.effects.length > 0
|
|
59
60
|
effects.derivedDependencies ||= plan.effects.some(effect => effect.dependencyExpressions?.length)
|
|
@@ -125,7 +126,8 @@ export function assertCapabilityIR(capabilityIR, records, options = {}) {
|
|
|
125
126
|
if (!sections.every(name => isRecord(capabilityIR[name]))) throw new Error("Invalid CapabilityIR v1 structure")
|
|
126
127
|
if (!["behaviors", "regularBehaviors", "regularStateSeeds", "dependencyStateSeeds"].every(name => isCount(capabilityIR.routes[name]))) throw new Error("Invalid CapabilityIR v1 route counts")
|
|
127
128
|
if (!["command", "native"].every(name => Array.isArray(capabilityIR.events[name]) && capabilityIR.events[name].every(event => typeof event === "string")) || typeof capabilityIR.events.hasNativeHandlers !== "boolean") throw new Error("Invalid CapabilityIR v1 events")
|
|
128
|
-
if (!isCount(capabilityIR.bindings.count) || !["text", "style", "conditions", "svgConditions", "attributes"].every(name => typeof capabilityIR.bindings[name] === "boolean")) throw new Error("Invalid CapabilityIR v1 bindings")
|
|
129
|
+
if (!isCount(capabilityIR.bindings.count) || !["text", "style", "conditions", "conditionState", "svgConditions", "attributes"].every(name => typeof capabilityIR.bindings[name] === "boolean")) throw new Error("Invalid CapabilityIR v1 bindings")
|
|
130
|
+
if (capabilityIR.bindings.conditionState && !capabilityIR.bindings.conditions) throw new Error("CapabilityIR conditional state requires conditions")
|
|
129
131
|
if (!Array.isArray(capabilityIR.bindings.properties) || capabilityIR.bindings.properties.some(target => !propertyBindings.includes(target)) || new Set(capabilityIR.bindings.properties).size !== capabilityIR.bindings.properties.length) throw new Error("Invalid CapabilityIR v1 binding properties")
|
|
130
132
|
if (capabilityIR.bindings.style !== capabilityIR.bindings.properties.includes("style")) throw new Error("CapabilityIR binding style flag does not match its properties")
|
|
131
133
|
const listFlags = ["conditions", "svg", "deepConditions", "textRanges", "attributes", "events", "expressions", "expressionAttributes", "seeds", "effects", "rowHooks", "rowRefs", "complexRowState", "nested", "selectors", "calculated", "static", "indexes", "stableFastPaths", "generalRowHooks", "asyncParts", "mounts"]
|
|
@@ -53,6 +53,7 @@ export function generateBindingRuntime(source, capabilityIR, navigable) {
|
|
|
53
53
|
"globalThis.__KUDZU_CHECKED_BINDINGS__": String(properties.includes("checked")),
|
|
54
54
|
"globalThis.__KUDZU_VALUE_BINDINGS__": String(properties.includes("value")),
|
|
55
55
|
"globalThis.__KUDZU_CONDITIONS__": String(capabilityIR.bindings.conditions),
|
|
56
|
+
"globalThis.__KUDZU_CONDITION_STATE__": String(capabilityIR.bindings.conditionState),
|
|
56
57
|
"globalThis.__KUDZU_SVG_CONDITIONS__": String(capabilityIR.bindings.svgConditions),
|
|
57
58
|
"globalThis.__KUDZU_CAPTURE_STATE__": String(capabilityIR.captures.nestedState)
|
|
58
59
|
}
|