@llui/vite-plugin 0.0.40 → 0.0.42

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.
@@ -0,0 +1,58 @@
1
+ import ts from 'typescript';
2
+ /**
3
+ * Helpers for resolving identifier references at reactive-accessor
4
+ * positions. Shared by `transform.ts` (compile-time prop classification
5
+ * + Pass 2 mask injection) and `collect-deps.ts` (state-path scanning
6
+ * for `__dirty` / `__maskLegend`).
7
+ *
8
+ * The compiler must distinguish the legitimate accessor shapes:
9
+ *
10
+ * - Inline arrow / function expression at the call site
11
+ * - Inline `memo(arrow)` at the call site
12
+ * - Identifier referencing a const-bound arrow / function expression
13
+ * - Identifier referencing a hoisted function declaration
14
+ * - Identifier referencing `const x = memo(arrow)`
15
+ *
16
+ * …from values we can't classify (imports, parameters, opaque calls), so
17
+ * those can be bailed-to-runtime instead of silently miscompiled. See the
18
+ * `disabled` binding bug, where a function reference at a reactive prop
19
+ * position was statically assigned (`__e.disabled = isGated`) — writing
20
+ * the function object onto the boolean DOM property and never re-evaluating.
21
+ */
22
+ /**
23
+ * Walk parent chains to find a `const X = ...` declaration matching
24
+ * `use.text`, or a hoisted `function X(...)` declaration. Returns the
25
+ * resolved declaration or `null` for unresolvable references (imports,
26
+ * parameters, this-bindings, etc.).
27
+ *
28
+ * Limitations:
29
+ * - Only `const`. `let` resolution is unsafe — we can't track later
30
+ * reassignments without a type checker.
31
+ * - Only single-binding declarations (`const a = …`, not `const a = …, b = …`).
32
+ * - The declaration must dominate the use (lexical scope).
33
+ */
34
+ export declare function resolveLocalConstInitializer(use: ts.Identifier): ts.Expression | ts.FunctionDeclaration | null;
35
+ /**
36
+ * Recognize `memo(arrow)` / `memo(fn)` calls so the inner accessor can
37
+ * be analyzed for state-path masking. The runtime `memo()` returns a
38
+ * cached accessor — its body's reads determine when it re-evaluates,
39
+ * not the call site.
40
+ */
41
+ export declare function isMemoCallWithArrowArg(expr: ts.Expression): expr is ts.CallExpression & {
42
+ arguments: readonly [ts.ArrowFunction | ts.FunctionExpression, ...ts.Expression[]];
43
+ };
44
+ /**
45
+ * Resolve a value at a reactive-accessor position down to the callable
46
+ * AST node we can mask-analyze. Returns `null` when the value isn't a
47
+ * recognized accessor shape — caller leaves the call unchanged (runtime
48
+ * falls back to FULL_MASK, which is correct just slower).
49
+ *
50
+ * Recognized shapes:
51
+ * - `(s) => …` (ArrowFunction)
52
+ * - `function (s) { … }` (FunctionExpression)
53
+ * - `memo((s) => …)` — returns the inner arrow
54
+ * - `someIdentifier` resolving to any of the above (or to a hoisted
55
+ * `function X(s) { … }` declaration)
56
+ */
57
+ export declare function resolveAccessorBody(value: ts.Expression): ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | null;
58
+ //# sourceMappingURL=accessor-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessor-resolver.d.ts","sourceRoot":"","sources":["../src/accessor-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,EAAE,CAAC,UAAU,GACjB,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,mBAAmB,GAAG,IAAI,CA8B/C;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,GAAG;IACvF,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,CAAA;CACnF,CAQA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,EAAE,CAAC,UAAU,GACnB,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAoB1E"}
@@ -0,0 +1,119 @@
1
+ import ts from 'typescript';
2
+ /**
3
+ * Helpers for resolving identifier references at reactive-accessor
4
+ * positions. Shared by `transform.ts` (compile-time prop classification
5
+ * + Pass 2 mask injection) and `collect-deps.ts` (state-path scanning
6
+ * for `__dirty` / `__maskLegend`).
7
+ *
8
+ * The compiler must distinguish the legitimate accessor shapes:
9
+ *
10
+ * - Inline arrow / function expression at the call site
11
+ * - Inline `memo(arrow)` at the call site
12
+ * - Identifier referencing a const-bound arrow / function expression
13
+ * - Identifier referencing a hoisted function declaration
14
+ * - Identifier referencing `const x = memo(arrow)`
15
+ *
16
+ * …from values we can't classify (imports, parameters, opaque calls), so
17
+ * those can be bailed-to-runtime instead of silently miscompiled. See the
18
+ * `disabled` binding bug, where a function reference at a reactive prop
19
+ * position was statically assigned (`__e.disabled = isGated`) — writing
20
+ * the function object onto the boolean DOM property and never re-evaluating.
21
+ */
22
+ /**
23
+ * Walk parent chains to find a `const X = ...` declaration matching
24
+ * `use.text`, or a hoisted `function X(...)` declaration. Returns the
25
+ * resolved declaration or `null` for unresolvable references (imports,
26
+ * parameters, this-bindings, etc.).
27
+ *
28
+ * Limitations:
29
+ * - Only `const`. `let` resolution is unsafe — we can't track later
30
+ * reassignments without a type checker.
31
+ * - Only single-binding declarations (`const a = …`, not `const a = …, b = …`).
32
+ * - The declaration must dominate the use (lexical scope).
33
+ */
34
+ export function resolveLocalConstInitializer(use) {
35
+ const name = use.text;
36
+ let node = use;
37
+ while (node.parent) {
38
+ const parent = node.parent;
39
+ let statements = null;
40
+ if (ts.isBlock(parent) || ts.isSourceFile(parent) || ts.isModuleBlock(parent)) {
41
+ statements = parent.statements;
42
+ }
43
+ else if (ts.isCaseClause(parent) || ts.isDefaultClause(parent)) {
44
+ statements = parent.statements;
45
+ }
46
+ if (statements) {
47
+ for (const stmt of statements) {
48
+ if (ts.isFunctionDeclaration(stmt)) {
49
+ if (stmt.name && stmt.name.text === name)
50
+ return stmt;
51
+ continue;
52
+ }
53
+ if (!ts.isVariableStatement(stmt))
54
+ continue;
55
+ const flags = stmt.declarationList.flags;
56
+ if (!(flags & ts.NodeFlags.Const))
57
+ continue;
58
+ if (stmt.declarationList.declarations.length !== 1)
59
+ continue;
60
+ const decl = stmt.declarationList.declarations[0];
61
+ if (!ts.isIdentifier(decl.name) || decl.name.text !== name)
62
+ continue;
63
+ if (!decl.initializer)
64
+ continue;
65
+ return decl.initializer;
66
+ }
67
+ }
68
+ node = parent;
69
+ }
70
+ return null;
71
+ }
72
+ /**
73
+ * Recognize `memo(arrow)` / `memo(fn)` calls so the inner accessor can
74
+ * be analyzed for state-path masking. The runtime `memo()` returns a
75
+ * cached accessor — its body's reads determine when it re-evaluates,
76
+ * not the call site.
77
+ */
78
+ export function isMemoCallWithArrowArg(expr) {
79
+ return (ts.isCallExpression(expr) &&
80
+ ts.isIdentifier(expr.expression) &&
81
+ expr.expression.text === 'memo' &&
82
+ expr.arguments.length >= 1 &&
83
+ (ts.isArrowFunction(expr.arguments[0]) || ts.isFunctionExpression(expr.arguments[0])));
84
+ }
85
+ /**
86
+ * Resolve a value at a reactive-accessor position down to the callable
87
+ * AST node we can mask-analyze. Returns `null` when the value isn't a
88
+ * recognized accessor shape — caller leaves the call unchanged (runtime
89
+ * falls back to FULL_MASK, which is correct just slower).
90
+ *
91
+ * Recognized shapes:
92
+ * - `(s) => …` (ArrowFunction)
93
+ * - `function (s) { … }` (FunctionExpression)
94
+ * - `memo((s) => …)` — returns the inner arrow
95
+ * - `someIdentifier` resolving to any of the above (or to a hoisted
96
+ * `function X(s) { … }` declaration)
97
+ */
98
+ export function resolveAccessorBody(value) {
99
+ if (ts.isArrowFunction(value) || ts.isFunctionExpression(value))
100
+ return value;
101
+ if (isMemoCallWithArrowArg(value)) {
102
+ return value.arguments[0];
103
+ }
104
+ if (ts.isIdentifier(value)) {
105
+ const resolved = resolveLocalConstInitializer(value);
106
+ if (!resolved)
107
+ return null;
108
+ if (ts.isArrowFunction(resolved) ||
109
+ ts.isFunctionExpression(resolved) ||
110
+ ts.isFunctionDeclaration(resolved)) {
111
+ return resolved;
112
+ }
113
+ if (isMemoCallWithArrowArg(resolved)) {
114
+ return resolved.arguments[0];
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ //# sourceMappingURL=accessor-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessor-resolver.js","sourceRoot":"","sources":["../src/accessor-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,4BAA4B,CAC1C,GAAkB;IAElB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;IACrB,IAAI,IAAI,GAAY,GAAG,CAAA;IACvB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC1B,IAAI,UAAU,GAAmC,IAAI,CAAA;QACrD,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9E,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QAChC,CAAC;aAAM,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;YACjE,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QAChC,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;gBAC9B,IAAI,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI;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,UAAU,mBAAmB,CACjC,KAAoB;IAEpB,IAAI,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC7E,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAA6C,CAAA;IACvE,CAAC;IACD,IAAI,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAA;QACpD,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAA;QAC1B,IACE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC;YAC5B,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACjC,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAClC,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,IAAI,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,CAA6C,CAAA;QAC1E,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import ts from 'typescript'\n\n/**\n * Helpers for resolving identifier references at reactive-accessor\n * positions. Shared by `transform.ts` (compile-time prop classification\n * + Pass 2 mask injection) and `collect-deps.ts` (state-path scanning\n * for `__dirty` / `__maskLegend`).\n *\n * The compiler must distinguish the legitimate accessor shapes:\n *\n * - Inline arrow / function expression at the call site\n * - Inline `memo(arrow)` at the call site\n * - Identifier referencing a const-bound arrow / function expression\n * - Identifier referencing a hoisted function declaration\n * - Identifier referencing `const x = memo(arrow)`\n *\n * …from values we can't classify (imports, parameters, opaque calls), so\n * those can be bailed-to-runtime instead of silently miscompiled. See the\n * `disabled` binding bug, where a function reference at a reactive prop\n * position was statically assigned (`__e.disabled = isGated`) — writing\n * the function object onto the boolean DOM property and never re-evaluating.\n */\n\n/**\n * Walk parent chains to find a `const X = ...` declaration matching\n * `use.text`, or a hoisted `function X(...)` declaration. Returns the\n * resolved declaration or `null` for unresolvable references (imports,\n * parameters, this-bindings, etc.).\n *\n * Limitations:\n * - Only `const`. `let` resolution is unsafe — we can't track later\n * reassignments without a type checker.\n * - Only single-binding declarations (`const a = …`, not `const a = …, b = …`).\n * - The declaration must dominate the use (lexical scope).\n */\nexport function resolveLocalConstInitializer(\n use: ts.Identifier,\n): ts.Expression | ts.FunctionDeclaration | null {\n const name = use.text\n let node: ts.Node = use\n while (node.parent) {\n const parent = node.parent\n let statements: readonly ts.Statement[] | null = null\n if (ts.isBlock(parent) || ts.isSourceFile(parent) || ts.isModuleBlock(parent)) {\n statements = parent.statements\n } else if (ts.isCaseClause(parent) || ts.isDefaultClause(parent)) {\n statements = parent.statements\n }\n if (statements) {\n for (const stmt of statements) {\n if (ts.isFunctionDeclaration(stmt)) {\n if (stmt.name && stmt.name.text === name) return stmt\n continue\n }\n if (!ts.isVariableStatement(stmt)) continue\n const flags = stmt.declarationList.flags\n if (!(flags & ts.NodeFlags.Const)) continue\n if (stmt.declarationList.declarations.length !== 1) continue\n const decl = stmt.declarationList.declarations[0]!\n if (!ts.isIdentifier(decl.name) || decl.name.text !== name) continue\n if (!decl.initializer) continue\n return decl.initializer\n }\n }\n node = parent\n }\n return null\n}\n\n/**\n * Recognize `memo(arrow)` / `memo(fn)` calls so the inner accessor can\n * be analyzed for state-path masking. The runtime `memo()` returns a\n * cached accessor — its body's reads determine when it re-evaluates,\n * not the call site.\n */\nexport function isMemoCallWithArrowArg(expr: ts.Expression): expr is ts.CallExpression & {\n arguments: readonly [ts.ArrowFunction | ts.FunctionExpression, ...ts.Expression[]]\n} {\n return (\n ts.isCallExpression(expr) &&\n ts.isIdentifier(expr.expression) &&\n expr.expression.text === 'memo' &&\n expr.arguments.length >= 1 &&\n (ts.isArrowFunction(expr.arguments[0]!) || ts.isFunctionExpression(expr.arguments[0]!))\n )\n}\n\n/**\n * Resolve a value at a reactive-accessor position down to the callable\n * AST node we can mask-analyze. Returns `null` when the value isn't a\n * recognized accessor shape — caller leaves the call unchanged (runtime\n * falls back to FULL_MASK, which is correct just slower).\n *\n * Recognized shapes:\n * - `(s) => …` (ArrowFunction)\n * - `function (s) { … }` (FunctionExpression)\n * - `memo((s) => …)` — returns the inner arrow\n * - `someIdentifier` resolving to any of the above (or to a hoisted\n * `function X(s) { … }` declaration)\n */\nexport function resolveAccessorBody(\n value: ts.Expression,\n): ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | null {\n if (ts.isArrowFunction(value) || ts.isFunctionExpression(value)) return value\n if (isMemoCallWithArrowArg(value)) {\n return value.arguments[0] as ts.ArrowFunction | ts.FunctionExpression\n }\n if (ts.isIdentifier(value)) {\n const resolved = resolveLocalConstInitializer(value)\n if (!resolved) return null\n if (\n ts.isArrowFunction(resolved) ||\n ts.isFunctionExpression(resolved) ||\n ts.isFunctionDeclaration(resolved)\n ) {\n return resolved\n }\n if (isMemoCallWithArrowArg(resolved)) {\n return resolved.arguments[0] as ts.ArrowFunction | ts.FunctionExpression\n }\n }\n return null\n}\n"]}
@@ -1,16 +1,23 @@
1
1
  import ts from 'typescript';
2
2
  /**
3
3
  * Walk the AST and collect every unique state access path referenced by
4
- * a reactive accessor. A reactive accessor is an arrow/function whose
5
- * placement passes `isReactiveAccessor` — text()/memo() first args,
6
- * element-helper prop values, and allowlisted framework-API prop values.
7
- * Paths are rooted at the accessor's single parameter name.
4
+ * a reactive accessor. A reactive accessor is one of:
5
+ *
6
+ * - An inline arrow / function expression at a reactive position
7
+ * (`text(s => s.count)`, `div({ title: s => s.title })`,
8
+ * `show({ when: s => s.gated })`, etc.).
9
+ * - An Identifier at a reactive position that resolves to a callable
10
+ * in this file — a const-bound arrow / function expression,
11
+ * a hoisted function declaration, or `const x = memo(arrow)`.
12
+ *
13
+ * The second case lets authors refactor a literal arrow into a named
14
+ * helper without losing the reactive-mask optimization (a precise mask
15
+ * for `__dirty` and structural-primitive `__mask`). Without it, the
16
+ * runtime falls back to FULL_MASK — correct, but every binding fires
17
+ * on every state change.
8
18
  *
9
19
  * Shared by the bit-assignment path (`collectDeps`, below) and the
10
- * `diagnostics.ts` bitmask-overflow warning. Extracted so both consumers
11
- * see the same truth — previously the diagnostics side had its own naïve
12
- * walker that produced false positives for `each({ key })`, `item(...)`,
13
- * array-method callbacks, and user-land helpers.
20
+ * `diagnostics.ts` bitmask-overflow warning.
14
21
  */
15
22
  export declare function collectStatePathsFromSource(sourceFile: ts.SourceFile): Set<string>;
16
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"collect-deps.d.ts","sourceRoot":"","sources":["../src/collect-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAyBlF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAoBhF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA4B/D"}
1
+ {"version":3,"file":"collect-deps.d.ts","sourceRoot":"","sources":["../src/collect-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAyG3B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAuBlF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAwBhF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA4B/D"}
@@ -1,34 +1,131 @@
1
1
  import ts from 'typescript';
2
+ import { resolveAccessorBody } from './accessor-resolver.js';
3
+ /**
4
+ * Names whose first arg is itself a reactive accessor (the existing
5
+ * arrow walker handles them) or which are explicitly excluded
6
+ * (sample/item read state imperatively / per-row, not as state
7
+ * accessors). When a delegating accessor's body contains a call to one
8
+ * of these, we don't follow it — recursion is reserved for "this is
9
+ * just a thin wrapper that hands the state to another local helper."
10
+ */
11
+ const NON_DELEGATION_HELPERS = new Set(['sample', 'item', 'memo', 'text', 'unsafeHtml']);
12
+ /**
13
+ * Walk a delegating accessor's body looking for calls to OTHER local
14
+ * functions that take the state param verbatim — `helper(s)` where
15
+ * `s` matches the outer accessor's param name. For each, hand the
16
+ * resolved declaration back so the caller can recurse into its body.
17
+ *
18
+ * Skips:
19
+ * - Framework helpers (`memo`, `text`, etc.) — their arrow args are
20
+ * visited by the top-level arrow walker; we'd double-count.
21
+ * - Method calls (`s.items.filter(...)`) — the callee is a builtin,
22
+ * not a local function we can resolve.
23
+ * - Nested function bodies — params inside a `(item) => …` shadow
24
+ * ours, so a `helper(s)` deep in there isn't (necessarily)
25
+ * handing OUR state in. Conservative: don't recurse through
26
+ * lambda boundaries.
27
+ */
28
+ function visitTopLevelDelegations(body, stateParamName, follow) {
29
+ function visit(node) {
30
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
31
+ const name = node.expression.text;
32
+ if (!NON_DELEGATION_HELPERS.has(name)) {
33
+ const arg0 = node.arguments[0];
34
+ if (arg0 && ts.isIdentifier(arg0) && arg0.text === stateParamName) {
35
+ const resolved = resolveAccessorBody(node.expression);
36
+ if (resolved)
37
+ follow(resolved);
38
+ }
39
+ }
40
+ }
41
+ // Don't descend into nested function bodies — their params shadow
42
+ // ours, and any call inside them isn't unambiguously delegating
43
+ // our state.
44
+ if (ts.isArrowFunction(node) ||
45
+ ts.isFunctionExpression(node) ||
46
+ ts.isFunctionDeclaration(node)) {
47
+ return;
48
+ }
49
+ ts.forEachChild(node, visit);
50
+ }
51
+ // If the body itself is a function, there's nothing at the top
52
+ // level to inspect — its own body is a separate scope.
53
+ if (ts.isArrowFunction(body) || ts.isFunctionExpression(body) || ts.isFunctionDeclaration(body)) {
54
+ return;
55
+ }
56
+ visit(body);
57
+ }
58
+ /**
59
+ * Extract paths from a callable accessor (arrow / fn-expr / fn-decl)
60
+ * into the given set. Recurses through call-delegations to other local
61
+ * helpers so that `(s) => filtered(s)` / `(s) => { void s.x; return
62
+ * inner(s) }` correctly contribute the helper's state-path reads.
63
+ * Without recursion the precise mask under-counts — fields read only
64
+ * via the helper drop off the bitmask, and any sibling reactive
65
+ * accessor that reads them produces a non-zero `dirty` that AND'd with
66
+ * the narrow each.__mask is zero, silently skipping the reconcile.
67
+ *
68
+ * `visited` breaks cycles on mutually-recursive helpers — terminates
69
+ * the walk; doesn't try to be precise about what such helpers read.
70
+ */
71
+ function extractAccessorPaths(accessor, paths, visited = new Set()) {
72
+ if (visited.has(accessor))
73
+ return false;
74
+ visited.add(accessor);
75
+ const params = accessor.parameters;
76
+ if (params.length !== 1)
77
+ return false;
78
+ const paramName = params[0].name;
79
+ if (!ts.isIdentifier(paramName))
80
+ return false;
81
+ if (!accessor.body)
82
+ return false;
83
+ const before = paths.size;
84
+ extractPaths(accessor.body, paramName.text, '', paths);
85
+ // Follow delegations: `(s) => helper(s)` — extract `helper`'s body's
86
+ // state paths too. Reuses the `visited` set across the recursion
87
+ // chain so cycles terminate.
88
+ visitTopLevelDelegations(accessor.body, paramName.text, (resolved) => {
89
+ extractAccessorPaths(resolved, paths, visited);
90
+ });
91
+ return paths.size > before;
92
+ }
2
93
  /**
3
94
  * Walk the AST and collect every unique state access path referenced by
4
- * a reactive accessor. A reactive accessor is an arrow/function whose
5
- * placement passes `isReactiveAccessor` — text()/memo() first args,
6
- * element-helper prop values, and allowlisted framework-API prop values.
7
- * Paths are rooted at the accessor's single parameter name.
95
+ * a reactive accessor. A reactive accessor is one of:
96
+ *
97
+ * - An inline arrow / function expression at a reactive position
98
+ * (`text(s => s.count)`, `div({ title: s => s.title })`,
99
+ * `show({ when: s => s.gated })`, etc.).
100
+ * - An Identifier at a reactive position that resolves to a callable
101
+ * in this file — a const-bound arrow / function expression,
102
+ * a hoisted function declaration, or `const x = memo(arrow)`.
103
+ *
104
+ * The second case lets authors refactor a literal arrow into a named
105
+ * helper without losing the reactive-mask optimization (a precise mask
106
+ * for `__dirty` and structural-primitive `__mask`). Without it, the
107
+ * runtime falls back to FULL_MASK — correct, but every binding fires
108
+ * on every state change.
8
109
  *
9
110
  * Shared by the bit-assignment path (`collectDeps`, below) and the
10
- * `diagnostics.ts` bitmask-overflow warning. Extracted so both consumers
11
- * see the same truth — previously the diagnostics side had its own naïve
12
- * walker that produced false positives for `each({ key })`, `item(...)`,
13
- * array-method callbacks, and user-land helpers.
111
+ * `diagnostics.ts` bitmask-overflow warning.
14
112
  */
15
113
  export function collectStatePathsFromSource(sourceFile) {
16
114
  const paths = new Set();
17
115
  function visit(node) {
18
- // Look for arrow functions that are reactive accessors:
19
- // - First arg to text(): text(s => s.count)
20
- // - Prop values in element helper calls: div({ title: s => s.title })
116
+ // Inline arrow / function expression at a reactive position.
21
117
  if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
22
- const params = node.parameters;
23
- if (params.length === 1) {
24
- const paramName = params[0].name;
25
- if (ts.isIdentifier(paramName)) {
26
- // Check if this looks like a reactive accessor (not an event handler)
27
- if (isReactiveAccessor(node)) {
28
- extractPaths(node.body, paramName.text, '', paths);
29
- }
30
- }
31
- }
118
+ if (isReactiveAccessor(node))
119
+ extractAccessorPaths(node, paths);
120
+ }
121
+ // Identifier at a reactive position — resolve to its declaration
122
+ // and extract paths from the resolved body. Skip identifiers
123
+ // imported from elsewhere (resolver returns null) — there's no
124
+ // body to scan, runtime falls back to FULL_MASK.
125
+ if (ts.isIdentifier(node) && isReactiveAccessor(node)) {
126
+ const resolved = resolveAccessorBody(node);
127
+ if (resolved)
128
+ extractAccessorPaths(resolved, paths);
32
129
  }
33
130
  ts.forEachChild(node, visit);
34
131
  }
@@ -44,15 +141,18 @@ export function collectAccessorPathSets(sourceFile) {
44
141
  const sets = [];
45
142
  function visit(node) {
46
143
  if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
47
- const params = node.parameters;
48
- if (params.length === 1) {
49
- const paramName = params[0].name;
50
- if (ts.isIdentifier(paramName) && isReactiveAccessor(node)) {
51
- const set = new Set();
52
- extractPaths(node.body, paramName.text, '', set);
53
- if (set.size > 0)
54
- sets.push(set);
55
- }
144
+ if (isReactiveAccessor(node)) {
145
+ const set = new Set();
146
+ if (extractAccessorPaths(node, set))
147
+ sets.push(set);
148
+ }
149
+ }
150
+ if (ts.isIdentifier(node) && isReactiveAccessor(node)) {
151
+ const resolved = resolveAccessorBody(node);
152
+ if (resolved) {
153
+ const set = new Set();
154
+ if (extractAccessorPaths(resolved, set))
155
+ sets.push(set);
56
156
  }
57
157
  }
58
158
  ts.forEachChild(node, visit);
@@ -102,8 +202,10 @@ function hasLluiImport(sourceFile) {
102
202
  return false;
103
203
  }
104
204
  /**
105
- * Determines if an arrow/function expression is a reactive accessor
106
- * (not an event handler, not a callback like onClick).
205
+ * Determines if a node is at a reactive-accessor position — either an
206
+ * inline arrow / function expression OR an identifier that's about to
207
+ * be resolved to one. The check is identity-based on `parent.arguments[0]`
208
+ * etc., so the same logic works for both shapes.
107
209
  */
108
210
  function isReactiveAccessor(node) {
109
211
  const parent = node.parent;
@@ -1 +1 @@
1
- {"version":3,"file":"collect-deps.js","sourceRoot":"","sources":["../src/collect-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAAyB;IACnE,MAAM,KAAK,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C,YAAY,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAA;IACb,CAAC;IAED,mBAAmB;IACnB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAgC,EAAE,SAAiB;IAC/E,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAA;IACrC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import ts from 'typescript'\n\n/**\n * Walk the AST and collect every unique state access path referenced by\n * a reactive accessor. A reactive accessor is an arrow/function whose\n * placement passes `isReactiveAccessor` — text()/memo() first args,\n * element-helper prop values, and allowlisted framework-API prop values.\n * Paths are rooted at the accessor's single parameter name.\n *\n * Shared by the bit-assignment path (`collectDeps`, below) and the\n * `diagnostics.ts` bitmask-overflow warning. Extracted so both consumers\n * see the same truth — previously the diagnostics side had its own naïve\n * walker that produced false positives for `each({ key })`, `item(...)`,\n * array-method callbacks, and user-land helpers.\n */\nexport function collectStatePathsFromSource(sourceFile: ts.SourceFile): Set<string> {\n const paths = new Set<string>()\n\n function visit(node: ts.Node): void {\n // Look for arrow functions that are reactive accessors:\n // - First arg to text(): text(s => s.count)\n // - Prop values in element helper calls: div({ title: s => s.title })\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n const params = node.parameters\n if (params.length === 1) {\n const paramName = params[0]!.name\n if (ts.isIdentifier(paramName)) {\n // Check if this looks like a reactive accessor (not an event handler)\n if (isReactiveAccessor(node)) {\n extractPaths(node.body, paramName.text, '', paths)\n }\n }\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return paths\n}\n\n/**\n * Per-accessor path sets — one entry per reactive arrow/function. Used\n * by the bitmask-overflow diagnostic to find clusters of paths that\n * always fire together (co-occurrence analysis).\n */\nexport function collectAccessorPathSets(sourceFile: ts.SourceFile): Set<string>[] {\n const sets: Set<string>[] = []\n\n function visit(node: ts.Node): void {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n const params = node.parameters\n if (params.length === 1) {\n const paramName = params[0]!.name\n if (ts.isIdentifier(paramName) && isReactiveAccessor(node)) {\n const set = new Set<string>()\n extractPaths(node.body, paramName.text, '', set)\n if (set.size > 0) sets.push(set)\n }\n }\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return sets\n}\n\n/**\n * Pre-scan a source file to collect all unique state access paths\n * referenced by reactive accessors (arrow functions in props and text() calls).\n * Returns a Map<path, bitPosition> where each path gets a unique power-of-two bit.\n */\nexport function collectDeps(source: string): Map<string, number> {\n const sourceFile = ts.createSourceFile('input.ts', source, ts.ScriptTarget.Latest, true)\n\n // Check if file imports from @llui/dom\n if (!hasLluiImport(sourceFile)) {\n return new Map()\n }\n\n const paths = collectStatePathsFromSource(sourceFile)\n\n // Assign bit positions. The bitmask holds 31 unique paths (positions\n // 0..30). When the count exceeds 31, overflow paths use FULL_MASK (-1)\n // — they always trigger re-evaluation, degrading gracefully. The\n // diagnostic warns the user to decompose.\n const fieldBits = new Map<string, number>()\n let bit = 1\n let index = 0\n for (const path of paths) {\n if (index >= 31) {\n fieldBits.set(path, -1)\n } else {\n fieldBits.set(path, bit)\n bit <<= 1\n }\n index++\n }\n\n return fieldBits\n}\n\nfunction hasLluiImport(sourceFile: ts.SourceFile): boolean {\n for (const stmt of sourceFile.statements) {\n if (\n ts.isImportDeclaration(stmt) &&\n ts.isStringLiteral(stmt.moduleSpecifier) &&\n stmt.moduleSpecifier.text === '@llui/dom'\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * Determines if an arrow/function expression is a reactive accessor\n * (not an event handler, not a callback like onClick).\n */\nfunction isReactiveAccessor(node: ts.ArrowFunction | ts.FunctionExpression): boolean {\n const parent = node.parent\n\n // text(s => s.count) — first arg to a call\n if (ts.isCallExpression(parent) && parent.arguments[0] === node) {\n // Skip item(t => t.id) — per-item selectors inside each() render.\n // Skip sample(s => s.x) — imperative one-shot read, no binding created\n // (both the top-level import and the destructured-from-h form).\n if (ts.isIdentifier(parent.expression)) {\n if (parent.expression.text === 'item' || parent.expression.text === 'sample') {\n return false\n }\n }\n // Skip array method callbacks: .filter(t => ...), .map(t => ...), .some(t => ...), etc.\n // Allow view-helper primitive calls: h.text(s => ...), h.memo(s => ...)\n if (ts.isPropertyAccessExpression(parent.expression)) {\n const methodName = parent.expression.name.text\n if (methodName === 'text' || methodName === 'memo') {\n return true\n }\n return false\n }\n return true\n }\n\n // div({ title: s => s.title }) — value in a property assignment inside an object literal.\n // Only treat as reactive if the containing call is a known framework API whose\n // properties are reactive accessors. Otherwise user-land helpers like\n // sliceHandler({ narrow: (m) => m.type === ... }) would pollute the path set.\n if (ts.isPropertyAssignment(parent)) {\n const key = parent.name\n if (ts.isIdentifier(key)) {\n // Skip event handlers (onClick, onInput, etc.)\n if (/^on[A-Z]/.test(key.text)) return false\n // Skip each() key function and other non-reactive props\n if (key.text === 'key' || key.text === 'name') return false\n // Walk up to find the enclosing call expression\n let ancestor: ts.Node | undefined = parent.parent // ObjectLiteralExpression\n while (ancestor && !ts.isCallExpression(ancestor)) {\n ancestor = ancestor.parent\n }\n if (!ancestor) return false\n const callExpr = ancestor as ts.CallExpression\n if (!ts.isIdentifier(callExpr.expression)) return false\n return REACTIVE_API_NAMES.has(callExpr.expression.text)\n }\n }\n\n return false\n}\n\n// Framework APIs whose object-literal arguments contain reactive accessors.\n// Arrow functions in property values of these calls are state-tracked.\nconst REACTIVE_API_NAMES = new Set([\n // Element helpers (see ELEMENT_HELPERS in transform.ts — we keep a superset here)\n ...[\n 'a',\n 'abbr',\n 'article',\n 'aside',\n 'b',\n 'blockquote',\n 'br',\n 'button',\n 'canvas',\n 'code',\n 'dd',\n 'details',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hr',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'mark',\n 'nav',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'pre',\n 'progress',\n 'section',\n 'select',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'ul',\n 'video',\n ],\n // Structural primitives\n 'each',\n 'branch',\n 'scope',\n 'show',\n 'memo',\n 'portal',\n 'foreign',\n 'child',\n 'errorBoundary',\n])\n\n/**\n * Extract state access paths from an expression body.\n * Handles:\n * - Direct property access: param.field, param.field.subfield\n * - Bracket notation with string literal: param['field']\n */\nfunction extractPaths(node: ts.Node, paramName: string, _prefix: string, paths: Set<string>): void {\n if (ts.isPropertyAccessExpression(node)) {\n // Skip if this is an intermediate in a deeper chain\n if (ts.isPropertyAccessExpression(node.parent)) {\n // handled when the leaf is visited\n }\n // Skip if this is the callee of a method call: s.todos.filter(...)\n else if (ts.isCallExpression(node.parent) && node.parent.expression === node) {\n // It's a method call — record the object, not the method\n // e.g. s.todos.filter(...) → record 'todos', not 'todos.filter'\n if (ts.isPropertyAccessExpression(node.expression)) {\n const chain = resolvePropertyChain(node.expression, paramName)\n if (chain) paths.add(chain)\n }\n } else {\n const chain = resolvePropertyChain(node, paramName)\n if (chain) {\n paths.add(chain)\n }\n }\n }\n\n if (ts.isElementAccessExpression(node)) {\n const chain = resolveElementAccess(node, paramName)\n if (chain) {\n paths.add(chain)\n }\n }\n\n ts.forEachChild(node, (child) => extractPaths(child, paramName, _prefix, paths))\n}\n\n/**\n * Resolve a property access chain like s.user.name to \"user.name\".\n * Returns null if the chain doesn't start with the state parameter.\n * Stops at depth 2.\n */\nfunction resolvePropertyChain(node: ts.PropertyAccessExpression, paramName: string): string | null {\n const parts: string[] = []\n let current: ts.Expression = node\n\n while (ts.isPropertyAccessExpression(current)) {\n parts.unshift(current.name.text)\n current = current.expression\n }\n\n // The root must be the state parameter\n if (!ts.isIdentifier(current) || current.text !== paramName) {\n return null\n }\n\n // Limit to depth 2\n if (parts.length > 2) {\n return parts.slice(0, 2).join('.')\n }\n\n return parts.join('.')\n}\n\n/**\n * Resolve bracket access with string literal: s['count'] → \"count\"\n */\nfunction resolveElementAccess(node: ts.ElementAccessExpression, paramName: string): string | null {\n if (!ts.isIdentifier(node.expression) || node.expression.text !== paramName) {\n return null\n }\n\n if (ts.isStringLiteral(node.argumentExpression)) {\n return node.argumentExpression.text\n }\n\n return null\n}\n"]}
1
+ {"version":3,"file":"collect-deps.js","sourceRoot":"","sources":["../src/collect-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAA;AAExF;;;;;;;;;;;;;;;GAeG;AACH,SAAS,wBAAwB,CAC/B,IAAa,EACb,cAAsB,EACtB,MAA6F;IAE7F,SA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AC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAgC,EAAE,SAAiB;IAC/E,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAA;IACrC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import ts from 'typescript'\nimport { resolveAccessorBody } from './accessor-resolver.js'\n\n/**\n * Names whose first arg is itself a reactive accessor (the existing\n * arrow walker handles them) or which are explicitly excluded\n * (sample/item read state imperatively / per-row, not as state\n * accessors). When a delegating accessor's body contains a call to one\n * of these, we don't follow it — recursion is reserved for \"this is\n * just a thin wrapper that hands the state to another local helper.\"\n */\nconst NON_DELEGATION_HELPERS = new Set(['sample', 'item', 'memo', 'text', 'unsafeHtml'])\n\n/**\n * Walk a delegating accessor's body looking for calls to OTHER local\n * functions that take the state param verbatim — `helper(s)` where\n * `s` matches the outer accessor's param name. For each, hand the\n * resolved declaration back so the caller can recurse into its body.\n *\n * Skips:\n * - Framework helpers (`memo`, `text`, etc.) — their arrow args are\n * visited by the top-level arrow walker; we'd double-count.\n * - Method calls (`s.items.filter(...)`) — the callee is a builtin,\n * not a local function we can resolve.\n * - Nested function bodies — params inside a `(item) => …` shadow\n * ours, so a `helper(s)` deep in there isn't (necessarily)\n * handing OUR state in. Conservative: don't recurse through\n * lambda boundaries.\n */\nfunction visitTopLevelDelegations(\n body: ts.Node,\n stateParamName: string,\n follow: (resolved: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration) => void,\n): void {\n function visit(node: ts.Node): void {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {\n const name = node.expression.text\n if (!NON_DELEGATION_HELPERS.has(name)) {\n const arg0 = node.arguments[0]\n if (arg0 && ts.isIdentifier(arg0) && arg0.text === stateParamName) {\n const resolved = resolveAccessorBody(node.expression)\n if (resolved) follow(resolved)\n }\n }\n }\n // Don't descend into nested function bodies — their params shadow\n // ours, and any call inside them isn't unambiguously delegating\n // our state.\n if (\n ts.isArrowFunction(node) ||\n ts.isFunctionExpression(node) ||\n ts.isFunctionDeclaration(node)\n ) {\n return\n }\n ts.forEachChild(node, visit)\n }\n // If the body itself is a function, there's nothing at the top\n // level to inspect — its own body is a separate scope.\n if (ts.isArrowFunction(body) || ts.isFunctionExpression(body) || ts.isFunctionDeclaration(body)) {\n return\n }\n visit(body)\n}\n\n/**\n * Extract paths from a callable accessor (arrow / fn-expr / fn-decl)\n * into the given set. Recurses through call-delegations to other local\n * helpers so that `(s) => filtered(s)` / `(s) => { void s.x; return\n * inner(s) }` correctly contribute the helper's state-path reads.\n * Without recursion the precise mask under-counts — fields read only\n * via the helper drop off the bitmask, and any sibling reactive\n * accessor that reads them produces a non-zero `dirty` that AND'd with\n * the narrow each.__mask is zero, silently skipping the reconcile.\n *\n * `visited` breaks cycles on mutually-recursive helpers — terminates\n * the walk; doesn't try to be precise about what such helpers read.\n */\nfunction extractAccessorPaths(\n accessor: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n paths: Set<string>,\n visited: Set<ts.Node> = new Set(),\n): boolean {\n if (visited.has(accessor)) return false\n visited.add(accessor)\n\n const params = accessor.parameters\n if (params.length !== 1) return false\n const paramName = params[0]!.name\n if (!ts.isIdentifier(paramName)) return false\n if (!accessor.body) return false\n const before = paths.size\n\n extractPaths(accessor.body, paramName.text, '', paths)\n\n // Follow delegations: `(s) => helper(s)` — extract `helper`'s body's\n // state paths too. Reuses the `visited` set across the recursion\n // chain so cycles terminate.\n visitTopLevelDelegations(accessor.body, paramName.text, (resolved) => {\n extractAccessorPaths(resolved, paths, visited)\n })\n\n return paths.size > before\n}\n\n/**\n * Walk the AST and collect every unique state access path referenced by\n * a reactive accessor. A reactive accessor is one of:\n *\n * - An inline arrow / function expression at a reactive position\n * (`text(s => s.count)`, `div({ title: s => s.title })`,\n * `show({ when: s => s.gated })`, etc.).\n * - An Identifier at a reactive position that resolves to a callable\n * in this file — a const-bound arrow / function expression,\n * a hoisted function declaration, or `const x = memo(arrow)`.\n *\n * The second case lets authors refactor a literal arrow into a named\n * helper without losing the reactive-mask optimization (a precise mask\n * for `__dirty` and structural-primitive `__mask`). Without it, the\n * runtime falls back to FULL_MASK — correct, but every binding fires\n * on every state change.\n *\n * Shared by the bit-assignment path (`collectDeps`, below) and the\n * `diagnostics.ts` bitmask-overflow warning.\n */\nexport function collectStatePathsFromSource(sourceFile: ts.SourceFile): Set<string> {\n const paths = new Set<string>()\n\n function visit(node: ts.Node): void {\n // Inline arrow / function expression at a reactive position.\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n if (isReactiveAccessor(node)) extractAccessorPaths(node, paths)\n }\n\n // Identifier at a reactive position — resolve to its declaration\n // and extract paths from the resolved body. Skip identifiers\n // imported from elsewhere (resolver returns null) — there's no\n // body to scan, runtime falls back to FULL_MASK.\n if (ts.isIdentifier(node) && isReactiveAccessor(node)) {\n const resolved = resolveAccessorBody(node)\n if (resolved) extractAccessorPaths(resolved, paths)\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return paths\n}\n\n/**\n * Per-accessor path sets — one entry per reactive arrow/function. Used\n * by the bitmask-overflow diagnostic to find clusters of paths that\n * always fire together (co-occurrence analysis).\n */\nexport function collectAccessorPathSets(sourceFile: ts.SourceFile): Set<string>[] {\n const sets: Set<string>[] = []\n\n function visit(node: ts.Node): void {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {\n if (isReactiveAccessor(node)) {\n const set = new Set<string>()\n if (extractAccessorPaths(node, set)) sets.push(set)\n }\n }\n\n if (ts.isIdentifier(node) && isReactiveAccessor(node)) {\n const resolved = resolveAccessorBody(node)\n if (resolved) {\n const set = new Set<string>()\n if (extractAccessorPaths(resolved, set)) sets.push(set)\n }\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n return sets\n}\n\n/**\n * Pre-scan a source file to collect all unique state access paths\n * referenced by reactive accessors (arrow functions in props and text() calls).\n * Returns a Map<path, bitPosition> where each path gets a unique power-of-two bit.\n */\nexport function collectDeps(source: string): Map<string, number> {\n const sourceFile = ts.createSourceFile('input.ts', source, ts.ScriptTarget.Latest, true)\n\n // Check if file imports from @llui/dom\n if (!hasLluiImport(sourceFile)) {\n return new Map()\n }\n\n const paths = collectStatePathsFromSource(sourceFile)\n\n // Assign bit positions. The bitmask holds 31 unique paths (positions\n // 0..30). When the count exceeds 31, overflow paths use FULL_MASK (-1)\n // — they always trigger re-evaluation, degrading gracefully. The\n // diagnostic warns the user to decompose.\n const fieldBits = new Map<string, number>()\n let bit = 1\n let index = 0\n for (const path of paths) {\n if (index >= 31) {\n fieldBits.set(path, -1)\n } else {\n fieldBits.set(path, bit)\n bit <<= 1\n }\n index++\n }\n\n return fieldBits\n}\n\nfunction hasLluiImport(sourceFile: ts.SourceFile): boolean {\n for (const stmt of sourceFile.statements) {\n if (\n ts.isImportDeclaration(stmt) &&\n ts.isStringLiteral(stmt.moduleSpecifier) &&\n stmt.moduleSpecifier.text === '@llui/dom'\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * Determines if a node is at a reactive-accessor position — either an\n * inline arrow / function expression OR an identifier that's about to\n * be resolved to one. The check is identity-based on `parent.arguments[0]`\n * etc., so the same logic works for both shapes.\n */\nfunction isReactiveAccessor(node: ts.Node): boolean {\n const parent = node.parent\n\n // text(s => s.count) — first arg to a call\n if (ts.isCallExpression(parent) && parent.arguments[0] === node) {\n // Skip item(t => t.id) — per-item selectors inside each() render.\n // Skip sample(s => s.x) — imperative one-shot read, no binding created\n // (both the top-level import and the destructured-from-h form).\n if (ts.isIdentifier(parent.expression)) {\n if (parent.expression.text === 'item' || parent.expression.text === 'sample') {\n return false\n }\n }\n // Skip array method callbacks: .filter(t => ...), .map(t => ...), .some(t => ...), etc.\n // Allow view-helper primitive calls: h.text(s => ...), h.memo(s => ...)\n if (ts.isPropertyAccessExpression(parent.expression)) {\n const methodName = parent.expression.name.text\n if (methodName === 'text' || methodName === 'memo') {\n return true\n }\n return false\n }\n return true\n }\n\n // div({ title: s => s.title }) — value in a property assignment inside an object literal.\n // Only treat as reactive if the containing call is a known framework API whose\n // properties are reactive accessors. Otherwise user-land helpers like\n // sliceHandler({ narrow: (m) => m.type === ... }) would pollute the path set.\n if (ts.isPropertyAssignment(parent)) {\n const key = parent.name\n if (ts.isIdentifier(key)) {\n // Skip event handlers (onClick, onInput, etc.)\n if (/^on[A-Z]/.test(key.text)) return false\n // Skip each() key function and other non-reactive props\n if (key.text === 'key' || key.text === 'name') return false\n // Walk up to find the enclosing call expression\n let ancestor: ts.Node | undefined = parent.parent // ObjectLiteralExpression\n while (ancestor && !ts.isCallExpression(ancestor)) {\n ancestor = ancestor.parent\n }\n if (!ancestor) return false\n const callExpr = ancestor as ts.CallExpression\n if (!ts.isIdentifier(callExpr.expression)) return false\n return REACTIVE_API_NAMES.has(callExpr.expression.text)\n }\n }\n\n return false\n}\n\n// Framework APIs whose object-literal arguments contain reactive accessors.\n// Arrow functions in property values of these calls are state-tracked.\nconst REACTIVE_API_NAMES = new Set([\n // Element helpers (see ELEMENT_HELPERS in transform.ts — we keep a superset here)\n ...[\n 'a',\n 'abbr',\n 'article',\n 'aside',\n 'b',\n 'blockquote',\n 'br',\n 'button',\n 'canvas',\n 'code',\n 'dd',\n 'details',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hr',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'mark',\n 'nav',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'pre',\n 'progress',\n 'section',\n 'select',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'ul',\n 'video',\n ],\n // Structural primitives\n 'each',\n 'branch',\n 'scope',\n 'show',\n 'memo',\n 'portal',\n 'foreign',\n 'child',\n 'errorBoundary',\n])\n\n/**\n * Extract state access paths from an expression body.\n * Handles:\n * - Direct property access: param.field, param.field.subfield\n * - Bracket notation with string literal: param['field']\n */\nfunction extractPaths(node: ts.Node, paramName: string, _prefix: string, paths: Set<string>): void {\n if (ts.isPropertyAccessExpression(node)) {\n // Skip if this is an intermediate in a deeper chain\n if (ts.isPropertyAccessExpression(node.parent)) {\n // handled when the leaf is visited\n }\n // Skip if this is the callee of a method call: s.todos.filter(...)\n else if (ts.isCallExpression(node.parent) && node.parent.expression === node) {\n // It's a method call — record the object, not the method\n // e.g. s.todos.filter(...) → record 'todos', not 'todos.filter'\n if (ts.isPropertyAccessExpression(node.expression)) {\n const chain = resolvePropertyChain(node.expression, paramName)\n if (chain) paths.add(chain)\n }\n } else {\n const chain = resolvePropertyChain(node, paramName)\n if (chain) {\n paths.add(chain)\n }\n }\n }\n\n if (ts.isElementAccessExpression(node)) {\n const chain = resolveElementAccess(node, paramName)\n if (chain) {\n paths.add(chain)\n }\n }\n\n ts.forEachChild(node, (child) => extractPaths(child, paramName, _prefix, paths))\n}\n\n/**\n * Resolve a property access chain like s.user.name to \"user.name\".\n * Returns null if the chain doesn't start with the state parameter.\n * Stops at depth 2.\n */\nfunction resolvePropertyChain(node: ts.PropertyAccessExpression, paramName: string): string | null {\n const parts: string[] = []\n let current: ts.Expression = node\n\n while (ts.isPropertyAccessExpression(current)) {\n parts.unshift(current.name.text)\n current = current.expression\n }\n\n // The root must be the state parameter\n if (!ts.isIdentifier(current) || current.text !== paramName) {\n return null\n }\n\n // Limit to depth 2\n if (parts.length > 2) {\n return parts.slice(0, 2).join('.')\n }\n\n return parts.join('.')\n}\n\n/**\n * Resolve bracket access with string literal: s['count'] → \"count\"\n */\nfunction resolveElementAccess(node: ts.ElementAccessExpression, paramName: string): string | null {\n if (!ts.isIdentifier(node.expression) || node.expression.text !== paramName) {\n return null\n }\n\n if (ts.isStringLiteral(node.argumentExpression)) {\n return node.argumentExpression.text\n }\n\n return null\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EAIpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,qBAAqB,EAA2B,MAAM,sBAAsB,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAkB,MAAM,mBAAmB,CAAA;AA6KtE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9C;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,UAAU,CAAC,O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