@kudzujs/core 0.6.24 → 0.6.25

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
@@ -422,7 +422,7 @@ function ItemCard({ item, onSelect }: {
422
422
 
423
423
  The nested collection must be `parent.<field>`. Its child row may be intrinsic or a same-file or relative-imported component that specializes to one intrinsic root. Child handlers receive the latest child item, and one level of child-local `&&` or ternary JSX conditions patches bounded DOM without remounting the child row. A second child list, third nesting level, computed collection, parent-item capture from the child row, conditions inside child conditions, child effects, child component tags below the specialized row root, and child row-local state remain unsupported.
424
424
 
425
- In the matched 100-parent/1,000-child component benchmark, a selected child text and condition update measured 1.2 ms, child reverse 0.4 ms, parent reverse 4.5 ms, and parent removal 0.6 ms. Svelte measured 2.2/0.8/5.2/1.1 ms, Vue 4.2/2.3/5.1/2.1 ms, React 9.2/4.3/7.5/3.8 ms, and hand-written Astro/native 0.4/0.2/3.2/0.2 ms. Kudzu shipped 6.6 KB initial JavaScript gzip and complete initial HTML. Sharing inert child-condition branches through each live child-list prototype reduced HTML from 676,086 B to 509,086 B and total deploy output from 693,806 B to 527,256 B raw; the sum of gzip-compressed files is 24,476 B. The CSR targets omit initial rows, so their artifact sizes are not architecture-equivalent.
425
+ In the matched 100-parent/1,000-child component benchmark, a selected child text and condition update measured 1.2 ms, child reverse 0.4 ms, parent reverse 4.6 ms, and parent removal 0.6 ms. Svelte measured 2.2/0.8/5.4/1.1 ms, Vue 4.3/2.3/5.0/2.0 ms, React 8.9/4.2/7.4/4.1 ms, and hand-written Astro/native 0.5/0.3/3.1/0.1 ms. Kudzu shipped 6.6 KB initial JavaScript gzip and complete initial HTML. Sharing inert child-condition branches and descriptors through each live child-list prototype reduced HTML from 676,086 B to 417,086 B and total deploy output from 693,806 B to 435,326 B raw; the sum of gzip-compressed files is 23,473 B. The CSR targets omit initial rows, so their artifact sizes are not architecture-equivalent.
426
426
 
427
427
  Each item must be an ordinary plain object with a unique string or finite-number key; nested data may contain only JSON-safe arrays, ordinary plain objects, and primitive values. Null-prototype objects are rejected to preserve JSON round-trip parity. The current syntax requires a local-state `.map`, one identifier callback parameter, one intrinsic JSX root or top-level local or relative-imported row component, and `key={item.<field>}`. State-backed list wrappers use one destructured props parameter, an intrinsic return root, no effects, and a direct local-state prop. Same-file wrappers must be unexported and state-backed at every call; relative default, named/aliased, and direct named re-export wrappers are specialized per qualifying call. Row components accept destructured projected props, top-level single-`const` calculations and inline effects before one intrinsic return. Effect dependencies inside a direct outer row may be empty, direct primitive Kudzu state identifiers, or direct `item.<field>` properties whose selected values remain JSON-safe primitives. Whole-item, computed, nested, derived, `__proto__`, `prototype`, and `constructor` dependencies are rejected. A list alias may only be rendered once and cannot be read by other JavaScript. Derived expressions must be pure and synchronous: item reads, literals, operators, templates, approved read-only string/array methods, deterministic `Math` methods, and `String`/`Number`/`Boolean` conversion are supported. Component state, imported helpers used inside calculations, browser globals, Promise values, mutation, arbitrary calls, and prototype-sensitive properties are rejected. Package, namespace, and star-export list wrappers, package or namespace row imports, same-file exported rows, reusable aliases, prop spreads/defaults/rest, children, conditions nested inside item conditions, component tags below a specialized row root, refs, and `dangerouslySetInnerHTML` remain unsupported. Keyed rows must be placed inside an explicit `<tbody>`, `<thead>`, or `<tfoot>`.
428
428
 
@@ -585,10 +585,10 @@ async function renderNode(node, namespace, selectValue = noSelectValue) {
585
585
  ? ""
586
586
  : node.kind === "and" && !node.value ? escapeHtml(renderFalsy(node.value)) : node.value ? truthy : falsy
587
587
  const initial = renderContext.listTemplate ? "" : ` data-k-list-current="${escapeAttribute(key)}"`
588
- const branches = renderContext.listInitialMarkers && !renderContext.listTemplate && owner?.descriptor.ownerField
589
- ? ""
590
- : `<template data-k-list-true>${truthy}</template><template data-k-list-false>${falsy}</template>`
591
- return `<template data-k-list-condition='${escapeJsonAttribute(descriptor)}'${initial}>${branches}</template>${current}<template data-k-list-condition-end></template>`
588
+ const shared = renderContext.listInitialMarkers && !renderContext.listTemplate && owner?.descriptor.ownerField
589
+ const condition = shared ? " data-k-list-condition" : ` data-k-list-condition='${escapeJsonAttribute(descriptor)}'`
590
+ const branches = shared ? "" : `<template data-k-list-true>${truthy}</template><template data-k-list-false>${falsy}</template>`
591
+ return `<template${condition}${initial}>${branches}</template>${current}<template data-k-list-condition-end></template>`
592
592
  }
593
593
  if (!node || typeof node !== "object" || !("type" in node)) {
594
594
  throw new Error(`Cannot render ${String(node)}`)
@@ -423,7 +423,8 @@ function listItemParts(root, nested = false) {
423
423
  if (__KUDZU_LIST_EXPRESSIONS__ && node.hasAttribute("data-k-list-expression")) parts.expressions.push([node, JSON.parse(node.dataset.kListExpression)])
424
424
  if (__KUDZU_LIST_EXPRESSION_ATTRIBUTES__ && node.hasAttribute("data-k-list-expression-attrs")) parts.expressionAttributes.push([node, JSON.parse(node.dataset.kListExpressionAttrs)])
425
425
  if (__KUDZU_LIST_CONDITIONS__ && node.hasAttribute("data-k-list-condition")) {
426
- parts.conditions.push([node, JSON.parse(node.dataset.kListCondition)])
426
+ const encoded = node.dataset.kListCondition || conditionTemplates.get(node)?.dataset.kListCondition
427
+ parts.conditions.push([node, encoded ? JSON.parse(encoded) : undefined])
427
428
  conditionOwners.set(node, root)
428
429
  }
429
430
  if (__KUDZU_LIST_EFFECTS__ && node.hasAttribute("data-k-effects")) parts.effects.push(node)
@@ -469,6 +470,7 @@ function mapListConditionTemplates(planned, initial) {
469
470
  if (planned.length !== initial.length) throw new Error("Keyed list condition markers do not match its template")
470
471
  for (let index = 0; index < initial.length; index++) {
471
472
  const marker = initial[index][0]
473
+ initial[index][1] ??= planned[index][1]
472
474
  if (!marker.content.querySelector("template[data-k-list-true],template[data-k-list-false]")) conditionTemplates.set(marker, planned[index][2])
473
475
  }
474
476
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kudzujs/core",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "HTML-first TSX framework with synchronous state semantics and no virtual DOM",
5
5
  "type": "module",
6
6
  "license": "MIT",