@kudzujs/core 0.7.27 → 0.7.29

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
@@ -10,7 +10,7 @@ Kudzu compiles ordinary React-shaped TypeScript and TSX into complete static HTM
10
10
 
11
11
  > Experimental `0.7.x`: the compiler API and supported TSX surface may change.
12
12
 
13
- **Latest release: 0.7.27 - Stateful component migration.** Setter-adapter children can retain ordinary state, IDs, refs, effects, prop-synchronized drafts, and derived JSX locals while Kudzu still emits no browser component runtime. Read the [release notes](./RELEASES.md#0727---stateful-component-migration) or open the [release page](https://kudzujs.cloud/releases/0.7.27).
13
+ **Latest release: 0.7.29 - Hermetic TypeScript checks.** Project and fixture typechecks no longer inherit unrelated ambient types or third-party declarations from ancestor `node_modules` directories. Read the [release notes](./RELEASES.md#0729---hermetic-typescript-checks) or open the [release page](https://kudzujs.cloud/releases/0.7.29).
14
14
 
15
15
  - [Documentation](https://kudzujs.cloud/docs)
16
16
  - [Installation guide](https://kudzujs.cloud/docs#install)
package/RELEASES.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Kudzu Releases
2
2
 
3
+ ## 0.7.29 - Hermetic TypeScript checks
4
+
5
+ Kudzu 0.7.29 makes project and migration-fixture typechecks independent of unrelated ambient types and package declarations installed in ancestor directories.
6
+
7
+ ### New in 0.7.29
8
+
9
+ - The root TypeScript configuration declares an empty ambient `types` set instead of scanning every visible ancestor `node_modules/@types` directory.
10
+ - `create-kudzu` emits the same isolated TypeScript configuration for new projects.
11
+ - Migration fixture checks skip third-party declaration bodies while continuing to typecheck fixture TS and TSX against Kudzu's reduced declarations.
12
+ - A clean `npm ci` checkout nested below conflicting `@types/minimatch`, React, and React Router installations now passes `npm run check`.
13
+ - The complete suite continues to pass 122/122 tests.
14
+
15
+ ### Upgrade
16
+
17
+ ```bash
18
+ npm install @kudzujs/core@^0.7.29
19
+ ```
20
+
21
+ ## 0.7.28 - Nested component specialization
22
+
23
+ Kudzu 0.7.28 recursively specializes components rendered inside setter-adapter children, allowing conventional optional UI such as an imported hookful Tooltip to remain declarative without adding a browser component runtime.
24
+
25
+ ### New in 0.7.28
26
+
27
+ - Setter-adapter children may recursively render synchronous same-file or relative-imported components.
28
+ - Nested component props, defaults, JSX children, static assets, handlers, and relative TypeScript imports reuse the existing call-site specialization path.
29
+ - Nested `useState()`, `useId()`, `useRef()`, and supported effects join the outer generated owner on unconditional or statically truthy paths.
30
+ - Literal `&&` and ternary conditions fold before specialization, so omitted and false optional components allocate no hooks or browser capabilities.
31
+ - Recursive component cycles, namespace/package components, and unresolved component imports retain source diagnostics.
32
+ - Hookful nested components on dynamic paths fail instead of receiving incorrect unconditional ownership.
33
+ - Setter callbacks cannot cross a second component boundary.
34
+ - A migration-derived FIRE `AgeInput` now restores its imported hookful `Tooltip`, including generated ARIA identity and hover/focus state.
35
+ - The complete suite passes 122/122 tests with Chrome coverage for nested tooltip state, omitted optional UI, and existing parent/child lifecycle behavior.
36
+
37
+ ### Boundary
38
+
39
+ Nested hooks are accepted only when the nested component is unconditional or guarded by a statically truthy literal after outer prop substitution. Dynamic conditional hook ownership and forwarding the setter through another component remain unsupported. Components still erase to intrinsic HTML and route-specific capabilities; React is never emitted or executed.
40
+
41
+ ### Upgrade
42
+
43
+ ```bash
44
+ npm install @kudzujs/core@^0.7.28
45
+ ```
46
+
3
47
  ## 0.7.27 - Stateful component migration
4
48
 
5
49
  Kudzu 0.7.27 lets ordinary setter-adapter components keep their local hooks and derived render values while compiling them into static HTML plus existing route-specific capabilities, not a browser component runtime.
@@ -47,7 +47,7 @@ Rendered collection selectors compile immutable local aliases and inline `(item)
47
47
 
48
48
  The reduced `useReducer` form reuses ordinary state slots and React's pure reducer contract. An optional inline, same-file, or relative-imported synchronous one-parameter initializer may derive a directly serializable literal only from its directly serializable initial argument; the compiler substitutes that argument and lowers the call to the ordinary two-argument ownership path. A direct dispatch in a compiled handler becomes a functional `set` whose reducer is bundled from a relative TypeScript module into that handler graph. Pure reducer-owned keyed lists reuse unchanged item identities for reorder, one removal, and append fast paths; ordinary `useState` lists retain full validation. One direct dispatch prop into a same-file or relative-imported synchronous component, including a direct keyed row, is specialized to intrinsic JSX at the call site, so its handler retains the parent reducer scope and no dispatch capture or child handler asset is emitted. A reducer row reads the latest item through the existing list scope and uses the same multiple serializable state, effect, condition, and object-ref specialization as other keyed rows. Relative TypeScript imports referenced inside that child handler receive collision-free call-site aliases and join the parent handler graph. One nested relative-imported intrinsic child may receive an inline or simple `const` callback containing dispatch; the compiler recursively substitutes that callback once and omits the nested child handler asset. Missing directly serializable literal defaults and direct intrinsic rest props in these reducer specializations are substituted at the same call site. Reducer-free routes and shared runtimes are unchanged; no reducer runtime or browser component instance exists.
49
49
 
50
- A direct setter may cross one same-file or relative-imported component boundary when the child invokes it exactly once inside an intrinsic event handler. Inline and simple `const` setter callbacks may use that adapter shape or direct event forwarding. Value adapters such as `event => onValueChange(event.currentTarget.value)` specialize into the parent setter graph instead of serializing a function. The child may also own directly serializable `useState()` values or initialize string state with one direct primitive state prop's zero-argument `.toString()`, plus `useId()` values, supported effects, and object refs initialized with `null`. Other dynamic state initializers remain unsupported. A parent-owned `null`-initialized object ref may cross the same boundary to the direct intrinsic root. These remain compiler-owned descriptors: conditional removal drops the handler with the element, deletes child state, resolves refs to `null`, and runs effect cleanup, while remount creates fresh ownership and dependency effects synchronize prop-derived state without retaining a component instance.
50
+ A direct setter may cross one same-file or relative-imported component boundary when the child invokes it exactly once inside an intrinsic event handler. Inline and simple `const` setter callbacks may use that adapter shape or direct event forwarding. Value adapters such as `event => onValueChange(event.currentTarget.value)` specialize into the parent setter graph instead of serializing a function. The child may also own directly serializable `useState()` values or initialize string state with one direct primitive state prop's zero-argument `.toString()`, plus `useId()` values, supported effects, and object refs initialized with `null`. Same-file and relative-imported nested components recursively specialize away; nested hooks join the same generated owner only on unconditional or statically truthy paths. Dynamic nested hook paths, forwarding the setter through a second boundary, and other dynamic state initializers remain unsupported. A parent-owned `null`-initialized object ref may cross the same boundary to the direct intrinsic root. These remain compiler-owned descriptors: conditional removal drops the handler with the element, deletes child state, resolves refs to `null`, and runs effect cleanup, while remount creates fresh ownership and dependency effects synchronize prop-derived state without retaining a component instance.
51
51
 
52
52
  `kudzu.config` may opt one emitted shared-layout group into same-document navigation with legacy `navigation: { routes: ["/product", "/items/[id]"] }`, or multiple groups with `navigation: { groups: [{ routes: [...] }, { routes: [...] }] }`. The forms are mutually exclusive. Identities are globally unique emitted exact paths or `runtimeParams` patterns; each group uses one page-exported layout function identity. Runtime records securely match concrete pathnames under `base`, and their cache-safe parameter initializer runs before route DOM/effects mount on every transition. Each group receives a deterministic route-hashed asset specialized to only its records, pattern decoder, and effect/parameter lifecycle needs. Cross-group and ungrouped anchors remain native and are not prefetched; overlapping path domains across groups fail the build. Route effect entries export cache-safe layout and route mount functions: layout effects, including conditional/keyed DOM-owned effects, persist for the group session; route effects receive a fresh owner registry after each route insertion; and non-persisted page disposal cleans route before layout. Direct primitive state, runtime parameter, and keyed-item property dependencies and cleanup are supported. Fragment payloads and coordinated View Transitions are not implemented.
53
53
 
@@ -2851,6 +2851,89 @@ function createKudzuTransformer(nativeHandlers, effectHandlers, reactiveBindings
2851
2851
  expanded.parent = root.parent
2852
2852
  return expanded
2853
2853
  }
2854
+ const staticConditionValue = expression => {
2855
+ const value = unwrapExpression(expression)
2856
+ if (value.kind === ts.SyntaxKind.TrueKeyword) return true
2857
+ if (value.kind === ts.SyntaxKind.FalseKeyword || value.kind === ts.SyntaxKind.NullKeyword || ts.isIdentifier(value) && value.text === "undefined") return false
2858
+ if (ts.isStringLiteral(value) || ts.isNoSubstitutionTemplateLiteral(value)) return Boolean(value.text)
2859
+ if (ts.isNumericLiteral(value)) return Number(value.text) !== 0
2860
+ return undefined
2861
+ }
2862
+ const foldSetterStaticConditions = root => {
2863
+ const visit = node => {
2864
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
2865
+ const condition = staticConditionValue(node.left)
2866
+ if (condition !== undefined) return condition ? ts.visitNode(node.right, visit) : node.left
2867
+ }
2868
+ if (ts.isConditionalExpression(node)) {
2869
+ const condition = staticConditionValue(node.condition)
2870
+ if (condition !== undefined) return ts.visitNode(condition ? node.whenTrue : node.whenFalse, visit)
2871
+ }
2872
+ return ts.visitEachChild(node, visit, context)
2873
+ }
2874
+ const folded = ts.visitNode(root, visit)
2875
+ ts.setParentRecursive(folded, false)
2876
+ folded.parent = root.parent
2877
+ return folded
2878
+ }
2879
+ const expandSetterComponents = (root, componentSource, trail, aggregate, parentSetters) => {
2880
+ root = foldSetterStaticConditions(root)
2881
+ const replacements = new WeakMap()
2882
+ let count = 0
2883
+ const visit = (node, dynamic = false) => {
2884
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken) {
2885
+ visit(node.left, dynamic)
2886
+ visit(node.right, true)
2887
+ return
2888
+ }
2889
+ if (ts.isConditionalExpression(node)) {
2890
+ visit(node.condition, dynamic)
2891
+ visit(node.whenTrue, true)
2892
+ visit(node.whenFalse, true)
2893
+ return
2894
+ }
2895
+ const tag = jsxTagName(node)
2896
+ if (tag && (!ts.isIdentifier(tag) || tag.text[0] !== tag.text[0].toLowerCase())) {
2897
+ if (!ts.isIdentifier(tag)) fail(node, "Nested setter-callback components must use identifier JSX tags")
2898
+ const name = tag.text
2899
+ let component = localComponentDeclaration(componentSource, name)
2900
+ let imported = false
2901
+ if (!component) {
2902
+ const binding = clientImportBindings(componentSource, componentSource.fileName, sourceFiles).get(name)
2903
+ if (!binding || binding.kind === "namespace") fail(node, `Nested setter-callback component ${name} must be declared locally or imported from a relative TypeScript module`)
2904
+ component = resolveComponentExport(binding.target, binding.kind === "default" ? "default" : binding.imported, importedSource, sourceFiles)
2905
+ imported = true
2906
+ }
2907
+ if (trail.includes(component)) {
2908
+ const chain = [...trail, component].map(entry => entry.name?.text || "anonymous").join(" -> ")
2909
+ fail(node, `Nested setter-callback component cycle: ${chain}`)
2910
+ }
2911
+ const setters = new Map(parentSetters)
2912
+ for (const state of aggregate.ordinaryStates) setters.set(state.setter, state.state)
2913
+ if (jsxSetterCallbackProps(node, setters, functions, reducersForNode(node, reducersByFunction)).length) fail(node, "Setter callbacks cannot cross a second component boundary")
2914
+ const nested = specializeComponentCall(node, component, sourceFile, factory, context, fail, "Nested setter-callback", true, true, new Set(setters.values()))
2915
+ if (dynamic && (nested.hookDeclarations.length || nested.effects.length)) fail(node, "Hookful nested setter-callback components require an unconditional or statically truthy render path")
2916
+ nested.root = expandSetterComponents(nested.root, component.getSourceFile(), [...trail, component], nested, setters)
2917
+ if (imported) synthesizeTree(nested.root = mergeSpecializedImports(nested.root, component.getSourceFile(), node, nested.effects))
2918
+ aggregate.calculations.push(...nested.calculations)
2919
+ aggregate.effects.push(...nested.effects)
2920
+ aggregate.hookDeclarations.push(...nested.hookDeclarations)
2921
+ aggregate.ordinaryStates.push(...nested.ordinaryStates)
2922
+ aggregate.ordinaryRefs.push(...nested.ordinaryRefs)
2923
+ aggregate.usesComponentId ||= nested.usesComponentId
2924
+ replacements.set(node, nested.root)
2925
+ count++
2926
+ return
2927
+ }
2928
+ ts.forEachChild(node, child => visit(child, dynamic))
2929
+ }
2930
+ visit(root)
2931
+ if (!count) return root
2932
+ const expanded = replaceSpecializedCalls(root, replacements, context)
2933
+ ts.setParentRecursive(expanded, false)
2934
+ expanded.parent = root.parent
2935
+ return expanded
2936
+ }
2854
2937
  for (const [name, component] of components) {
2855
2938
  const calls = jsxTagUses(sourceFile, name)
2856
2939
  const stateBackedCalls = calls.filter(call => isStateBackedListComponentCall(call, component.function, settersByFunction.get(nearestFunction(call)) ?? new Map()))
@@ -2915,6 +2998,7 @@ function createKudzuTransformer(nativeHandlers, effectHandlers, reactiveBindings
2915
2998
  for (const effect of specialization.effects) effect.call = substituteClone(effect.call, substitutions, factory, context)
2916
2999
  }
2917
3000
  }
3001
+ specialization.root = expandSetterComponents(specialization.root, component.getSourceFile(), [component], specialization, settersForNode(call, settersByFunction))
2918
3002
  if (imported) synthesizeTree(specialization.root = mergeSpecializedImports(specialization.root, component.getSourceFile(), call, specialization.effects))
2919
3003
  if (specialization.hookDeclarations.length || specialization.effects.length) {
2920
3004
  const owner = nearestFunction(call)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kudzujs/core",
3
- "version": "0.7.27",
3
+ "version": "0.7.29",
4
4
  "description": "HTML-first TSX framework with synchronous state semantics and no virtual DOM",
5
5
  "type": "module",
6
6
  "license": "MIT",