@kudzujs/core 0.16.34 → 0.16.35
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.35](https://github.com/kudzujs/kudzu/releases/tag/v0.16.35).** Flat evaluator families omit nested context preparation and recursive dependency collection, removing another 172 raw / 50 aggregate gzip JavaScript bytes from search. Nested component-prop evaluators retain current-state reads. The optional `create-kudzu --ai` authoring tools introduced in 0.16.34 remain available; AI-token savings are unmeasured and the AI-cost/1.0 gates remain blocked.
|
|
18
18
|
|
|
19
19
|
- [Documentation](https://kudzujs.cloud/docs)
|
|
20
20
|
- [Installation guide](https://kudzujs.cloud/docs#install)
|
|
@@ -286,14 +286,14 @@ export async function loadEvaluator(descriptor) {
|
|
|
286
286
|
|
|
287
287
|
async function createBindingContext(descriptor) {
|
|
288
288
|
const scope = Object.fromEntries(Object.entries(descriptor.scope).map(([name, value]) => [name, deserialize(value, id => browserState.get(id))]))
|
|
289
|
-
const nested = {}
|
|
290
|
-
await Promise.all(Object.entries(descriptor.scopeBindings).map(async ([name, binding]) => {
|
|
289
|
+
const nested = globalThis.__KUDZU_NESTED_EVALUATORS__ !== false && {}
|
|
290
|
+
if (globalThis.__KUDZU_NESTED_EVALUATORS__ !== false) await Promise.all(Object.entries(descriptor.scopeBindings).map(async ([name, binding]) => {
|
|
291
291
|
const evaluator = await loadEvaluator(binding)
|
|
292
292
|
nested[name] = evaluator.read
|
|
293
293
|
}))
|
|
294
294
|
return {
|
|
295
295
|
get: name => browserState.get(descriptor.states[name]),
|
|
296
|
-
scope: name => name in descriptor.scopeStates ? browserState.get(descriptor.scopeStates[name]) : name in nested ? nested[name]() : scope[name]
|
|
296
|
+
scope: name => name in descriptor.scopeStates ? browserState.get(descriptor.scopeStates[name]) : globalThis.__KUDZU_NESTED_EVALUATORS__ !== false && name in nested ? nested[name]() : scope[name]
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
@@ -302,7 +302,7 @@ function bindingStateIds(descriptor) {
|
|
|
302
302
|
...Object.values(descriptor.states),
|
|
303
303
|
...Object.values(descriptor.scopeStates),
|
|
304
304
|
...(globalThis.__KUDZU_CAPTURE_STATE__ ? Object.values(descriptor.scope).flatMap(serializedStateIds) : []),
|
|
305
|
-
...Object.values(descriptor.scopeBindings).flatMap(binding => [...bindingStateIds(binding)])
|
|
305
|
+
...(globalThis.__KUDZU_NESTED_EVALUATORS__ !== false ? Object.values(descriptor.scopeBindings).flatMap(binding => [...bindingStateIds(binding)]) : [])
|
|
306
306
|
])
|
|
307
307
|
}
|
|
308
308
|
|
|
@@ -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, conditionState: false, conditionMounts: false, svgConditions: false }
|
|
18
|
+
const bindings = { count: 0, text: false, style: false, conditions: false, conditionState: false, conditionMounts: false, svgConditions: false, nestedEvaluators: false }
|
|
19
19
|
const lists = {
|
|
20
20
|
count: 0,
|
|
21
21
|
styleCount: 0,
|
|
@@ -57,6 +57,7 @@ export function planRouteCapabilities(records, { navigationRouteCount = 0 } = {}
|
|
|
57
57
|
bindings.conditionState ||= plan.conditions.some(condition => Object.values(condition.owned ?? {}).some(states => states.length > 0))
|
|
58
58
|
bindings.conditionMounts ||= plan.conditions.some(condition => condition.mount)
|
|
59
59
|
bindings.svgConditions ||= plan.conditions.some(condition => condition.svg)
|
|
60
|
+
bindings.nestedEvaluators ||= [...plan.bindings, ...plan.conditions, ...plan.lists.map(list => list.source)].some(descriptor => Object.keys(descriptor?.scopeBindings ?? {}).length > 0)
|
|
60
61
|
effects.any ||= plan.effects.length > 0
|
|
61
62
|
effects.derivedDependencies ||= plan.effects.some(effect => effect.dependencyExpressions?.length)
|
|
62
63
|
effects.itemDependencies ||= plan.effects.some(effect => effect.itemDependencies?.length)
|
|
@@ -127,7 +128,7 @@ export function assertCapabilityIR(capabilityIR, records, options = {}) {
|
|
|
127
128
|
if (!sections.every(name => isRecord(capabilityIR[name]))) throw new Error("Invalid CapabilityIR v1 structure")
|
|
128
129
|
if (!["behaviors", "regularBehaviors", "regularStateSeeds", "dependencyStateSeeds"].every(name => isCount(capabilityIR.routes[name]))) throw new Error("Invalid CapabilityIR v1 route counts")
|
|
129
130
|
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")
|
|
130
|
-
if (!isCount(capabilityIR.bindings.count) || !["text", "style", "conditions", "conditionState", "conditionMounts", "svgConditions", "attributes"].every(name => typeof capabilityIR.bindings[name] === "boolean")) throw new Error("Invalid CapabilityIR v1 bindings")
|
|
131
|
+
if (!isCount(capabilityIR.bindings.count) || !["text", "style", "conditions", "conditionState", "conditionMounts", "svgConditions", "nestedEvaluators", "attributes"].every(name => typeof capabilityIR.bindings[name] === "boolean")) throw new Error("Invalid CapabilityIR v1 bindings")
|
|
131
132
|
if (capabilityIR.bindings.conditionState && !capabilityIR.bindings.conditions) throw new Error("CapabilityIR conditional state requires conditions")
|
|
132
133
|
if (capabilityIR.bindings.conditionMounts && !capabilityIR.bindings.conditions) throw new Error("CapabilityIR conditional mounts require conditions")
|
|
133
134
|
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")
|
|
@@ -57,6 +57,7 @@ export function generateBindingRuntime(source, capabilityIR, navigable) {
|
|
|
57
57
|
"globalThis.__KUDZU_CONDITION_STATE__": String(capabilityIR.bindings.conditionState),
|
|
58
58
|
"globalThis.__KUDZU_CONDITION_MOUNTS__": String(capabilityIR.bindings.conditionMounts),
|
|
59
59
|
"globalThis.__KUDZU_SVG_CONDITIONS__": String(capabilityIR.bindings.svgConditions),
|
|
60
|
+
"globalThis.__KUDZU_NESTED_EVALUATORS__": String(capabilityIR.bindings.nestedEvaluators),
|
|
60
61
|
"globalThis.__KUDZU_CAPTURE_STATE__": String(capabilityIR.captures.nestedState)
|
|
61
62
|
}
|
|
62
63
|
}
|