@llui/compiler 0.3.0
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/LICENSE +21 -0
- package/dist/accessor-resolver.d.ts +58 -0
- package/dist/accessor-resolver.d.ts.map +1 -0
- package/dist/accessor-resolver.js +119 -0
- package/dist/accessor-resolver.js.map +1 -0
- package/dist/binding-descriptors.d.ts +105 -0
- package/dist/binding-descriptors.d.ts.map +1 -0
- package/dist/binding-descriptors.js +340 -0
- package/dist/binding-descriptors.js.map +1 -0
- package/dist/collect-deps.d.ts +49 -0
- package/dist/collect-deps.d.ts.map +1 -0
- package/dist/collect-deps.js +444 -0
- package/dist/collect-deps.js.map +1 -0
- package/dist/compiler-cache.d.ts +20 -0
- package/dist/compiler-cache.d.ts.map +1 -0
- package/dist/compiler-cache.js +20 -0
- package/dist/compiler-cache.js.map +1 -0
- package/dist/cross-file-resolver.d.ts +109 -0
- package/dist/cross-file-resolver.d.ts.map +1 -0
- package/dist/cross-file-resolver.js +530 -0
- package/dist/cross-file-resolver.js.map +1 -0
- package/dist/cross-file-walker.d.ts +63 -0
- package/dist/cross-file-walker.d.ts.map +1 -0
- package/dist/cross-file-walker.js +516 -0
- package/dist/cross-file-walker.js.map +1 -0
- package/dist/diagnostic.d.ts +76 -0
- package/dist/diagnostic.d.ts.map +1 -0
- package/dist/diagnostic.js +59 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection-factory.d.ts +54 -0
- package/dist/introspection-factory.d.ts.map +1 -0
- package/dist/introspection-factory.js +46 -0
- package/dist/introspection-factory.js.map +1 -0
- package/dist/manifest.d.ts +144 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +209 -0
- package/dist/manifest.js.map +1 -0
- package/dist/module.d.ts +222 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +256 -0
- package/dist/module.js.map +1 -0
- package/dist/modules/_element-helpers.d.ts +4 -0
- package/dist/modules/_element-helpers.d.ts.map +1 -0
- package/dist/modules/_element-helpers.js +138 -0
- package/dist/modules/_element-helpers.js.map +1 -0
- package/dist/modules/_msg-variants.d.ts +10 -0
- package/dist/modules/_msg-variants.d.ts.map +1 -0
- package/dist/modules/_msg-variants.js +97 -0
- package/dist/modules/_msg-variants.js.map +1 -0
- package/dist/modules/_shared.d.ts +16 -0
- package/dist/modules/_shared.d.ts.map +1 -0
- package/dist/modules/_shared.js +30 -0
- package/dist/modules/_shared.js.map +1 -0
- package/dist/modules/accessibility.d.ts +3 -0
- package/dist/modules/accessibility.d.ts.map +1 -0
- package/dist/modules/accessibility.js +82 -0
- package/dist/modules/accessibility.js.map +1 -0
- package/dist/modules/accessor-side-effect.d.ts +3 -0
- package/dist/modules/accessor-side-effect.d.ts.map +1 -0
- package/dist/modules/accessor-side-effect.js +113 -0
- package/dist/modules/accessor-side-effect.js.map +1 -0
- package/dist/modules/agent-emits-drift.d.ts +3 -0
- package/dist/modules/agent-emits-drift.d.ts.map +1 -0
- package/dist/modules/agent-emits-drift.js +158 -0
- package/dist/modules/agent-emits-drift.js.map +1 -0
- package/dist/modules/agent-example-on-payload.d.ts +3 -0
- package/dist/modules/agent-example-on-payload.d.ts.map +1 -0
- package/dist/modules/agent-example-on-payload.js +53 -0
- package/dist/modules/agent-example-on-payload.js.map +1 -0
- package/dist/modules/agent-exclusive-annotations.d.ts +3 -0
- package/dist/modules/agent-exclusive-annotations.d.ts.map +1 -0
- package/dist/modules/agent-exclusive-annotations.js +68 -0
- package/dist/modules/agent-exclusive-annotations.js.map +1 -0
- package/dist/modules/agent-missing-intent.d.ts +3 -0
- package/dist/modules/agent-missing-intent.d.ts.map +1 -0
- package/dist/modules/agent-missing-intent.js +47 -0
- package/dist/modules/agent-missing-intent.js.map +1 -0
- package/dist/modules/agent-msg-resolvable.d.ts +3 -0
- package/dist/modules/agent-msg-resolvable.d.ts.map +1 -0
- package/dist/modules/agent-msg-resolvable.js +161 -0
- package/dist/modules/agent-msg-resolvable.js.map +1 -0
- package/dist/modules/agent-nonextractable-handler.d.ts +3 -0
- package/dist/modules/agent-nonextractable-handler.d.ts.map +1 -0
- package/dist/modules/agent-nonextractable-handler.js +127 -0
- package/dist/modules/agent-nonextractable-handler.js.map +1 -0
- package/dist/modules/agent-optional-field-undocumented.d.ts +3 -0
- package/dist/modules/agent-optional-field-undocumented.d.ts.map +1 -0
- package/dist/modules/agent-optional-field-undocumented.js +67 -0
- package/dist/modules/agent-optional-field-undocumented.js.map +1 -0
- package/dist/modules/agent-tagsend-translator-missing.d.ts +3 -0
- package/dist/modules/agent-tagsend-translator-missing.d.ts.map +1 -0
- package/dist/modules/agent-tagsend-translator-missing.js +58 -0
- package/dist/modules/agent-tagsend-translator-missing.js.map +1 -0
- package/dist/modules/agent-warning-on-confirm.d.ts +3 -0
- package/dist/modules/agent-warning-on-confirm.d.ts.map +1 -0
- package/dist/modules/agent-warning-on-confirm.js +46 -0
- package/dist/modules/agent-warning-on-confirm.js.map +1 -0
- package/dist/modules/async-update.d.ts +3 -0
- package/dist/modules/async-update.d.ts.map +1 -0
- package/dist/modules/async-update.js +86 -0
- package/dist/modules/async-update.js.map +1 -0
- package/dist/modules/binding-descriptors.d.ts +4 -0
- package/dist/modules/binding-descriptors.d.ts.map +1 -0
- package/dist/modules/binding-descriptors.js +48 -0
- package/dist/modules/binding-descriptors.js.map +1 -0
- package/dist/modules/bitmask-overflow.d.ts +3 -0
- package/dist/modules/bitmask-overflow.d.ts.map +1 -0
- package/dist/modules/bitmask-overflow.js +152 -0
- package/dist/modules/bitmask-overflow.js.map +1 -0
- package/dist/modules/compiler-stamp.d.ts +3 -0
- package/dist/modules/compiler-stamp.d.ts.map +1 -0
- package/dist/modules/compiler-stamp.js +44 -0
- package/dist/modules/compiler-stamp.js.map +1 -0
- package/dist/modules/component-meta.d.ts +3 -0
- package/dist/modules/component-meta.d.ts.map +1 -0
- package/dist/modules/component-meta.js +44 -0
- package/dist/modules/component-meta.js.map +1 -0
- package/dist/modules/controlled-input.d.ts +3 -0
- package/dist/modules/controlled-input.d.ts.map +1 -0
- package/dist/modules/controlled-input.js +68 -0
- package/dist/modules/controlled-input.js.map +1 -0
- package/dist/modules/core-synthesis.d.ts +18 -0
- package/dist/modules/core-synthesis.d.ts.map +1 -0
- package/dist/modules/core-synthesis.js +748 -0
- package/dist/modules/core-synthesis.js.map +1 -0
- package/dist/modules/direct-state-in-view.d.ts +3 -0
- package/dist/modules/direct-state-in-view.d.ts.map +1 -0
- package/dist/modules/direct-state-in-view.js +103 -0
- package/dist/modules/direct-state-in-view.js.map +1 -0
- package/dist/modules/each-closure-violation.d.ts +3 -0
- package/dist/modules/each-closure-violation.d.ts.map +1 -0
- package/dist/modules/each-closure-violation.js +255 -0
- package/dist/modules/each-closure-violation.js.map +1 -0
- package/dist/modules/each-memo.d.ts +15 -0
- package/dist/modules/each-memo.d.ts.map +1 -0
- package/dist/modules/each-memo.js +115 -0
- package/dist/modules/each-memo.js.map +1 -0
- package/dist/modules/effect-without-handler.d.ts +3 -0
- package/dist/modules/effect-without-handler.d.ts.map +1 -0
- package/dist/modules/effect-without-handler.js +92 -0
- package/dist/modules/effect-without-handler.js.map +1 -0
- package/dist/modules/element-rewrite.d.ts +22 -0
- package/dist/modules/element-rewrite.d.ts.map +1 -0
- package/dist/modules/element-rewrite.js +1017 -0
- package/dist/modules/element-rewrite.js.map +1 -0
- package/dist/modules/empty-props.d.ts +3 -0
- package/dist/modules/empty-props.d.ts.map +1 -0
- package/dist/modules/empty-props.js +50 -0
- package/dist/modules/empty-props.js.map +1 -0
- package/dist/modules/exhaustive-effect-handling.d.ts +3 -0
- package/dist/modules/exhaustive-effect-handling.d.ts.map +1 -0
- package/dist/modules/exhaustive-effect-handling.js +61 -0
- package/dist/modules/exhaustive-effect-handling.js.map +1 -0
- package/dist/modules/exhaustive-update.d.ts +3 -0
- package/dist/modules/exhaustive-update.d.ts.map +1 -0
- package/dist/modules/exhaustive-update.js +146 -0
- package/dist/modules/exhaustive-update.js.map +1 -0
- package/dist/modules/forgotten-spread.d.ts +3 -0
- package/dist/modules/forgotten-spread.d.ts.map +1 -0
- package/dist/modules/forgotten-spread.js +51 -0
- package/dist/modules/forgotten-spread.js.map +1 -0
- package/dist/modules/form-boilerplate.d.ts +3 -0
- package/dist/modules/form-boilerplate.d.ts.map +1 -0
- package/dist/modules/form-boilerplate.js +101 -0
- package/dist/modules/form-boilerplate.js.map +1 -0
- package/dist/modules/imperative-dom-in-view.d.ts +3 -0
- package/dist/modules/imperative-dom-in-view.d.ts.map +1 -0
- package/dist/modules/imperative-dom-in-view.js +123 -0
- package/dist/modules/imperative-dom-in-view.js.map +1 -0
- package/dist/modules/item-dedup.d.ts +7 -0
- package/dist/modules/item-dedup.d.ts.map +1 -0
- package/dist/modules/item-dedup.js +204 -0
- package/dist/modules/item-dedup.js.map +1 -0
- package/dist/modules/map-on-state-array.d.ts +3 -0
- package/dist/modules/map-on-state-array.d.ts.map +1 -0
- package/dist/modules/map-on-state-array.js +84 -0
- package/dist/modules/map-on-state-array.js.map +1 -0
- package/dist/modules/mask-legend.d.ts +10 -0
- package/dist/modules/mask-legend.d.ts.map +1 -0
- package/dist/modules/mask-legend.js +50 -0
- package/dist/modules/mask-legend.js.map +1 -0
- package/dist/modules/missing-memo.d.ts +3 -0
- package/dist/modules/missing-memo.d.ts.map +1 -0
- package/dist/modules/missing-memo.js +114 -0
- package/dist/modules/missing-memo.js.map +1 -0
- package/dist/modules/msg-annotations.d.ts +9 -0
- package/dist/modules/msg-annotations.d.ts.map +1 -0
- package/dist/modules/msg-annotations.js +54 -0
- package/dist/modules/msg-annotations.js.map +1 -0
- package/dist/modules/msg-schema.d.ts +10 -0
- package/dist/modules/msg-schema.d.ts.map +1 -0
- package/dist/modules/msg-schema.js +70 -0
- package/dist/modules/msg-schema.js.map +1 -0
- package/dist/modules/namespace-import.d.ts +3 -0
- package/dist/modules/namespace-import.d.ts.map +1 -0
- package/dist/modules/namespace-import.js +80 -0
- package/dist/modules/namespace-import.js.map +1 -0
- package/dist/modules/nested-send-in-update.d.ts +3 -0
- package/dist/modules/nested-send-in-update.d.ts.map +1 -0
- package/dist/modules/nested-send-in-update.js +77 -0
- package/dist/modules/nested-send-in-update.js.map +1 -0
- package/dist/modules/no-barrel-import-when-subpath-exists.d.ts +3 -0
- package/dist/modules/no-barrel-import-when-subpath-exists.d.ts.map +1 -0
- package/dist/modules/no-barrel-import-when-subpath-exists.js +100 -0
- package/dist/modules/no-barrel-import-when-subpath-exists.js.map +1 -0
- package/dist/modules/no-eager-item-accessor.d.ts +3 -0
- package/dist/modules/no-eager-item-accessor.d.ts.map +1 -0
- package/dist/modules/no-eager-item-accessor.js +74 -0
- package/dist/modules/no-eager-item-accessor.js.map +1 -0
- package/dist/modules/no-let-reactive-accessor.d.ts +3 -0
- package/dist/modules/no-let-reactive-accessor.d.ts.map +1 -0
- package/dist/modules/no-let-reactive-accessor.js +227 -0
- package/dist/modules/no-let-reactive-accessor.js.map +1 -0
- package/dist/modules/no-list-render-in-sample.d.ts +3 -0
- package/dist/modules/no-list-render-in-sample.d.ts.map +1 -0
- package/dist/modules/no-list-render-in-sample.js +89 -0
- package/dist/modules/no-list-render-in-sample.js.map +1 -0
- package/dist/modules/no-sample-in-accessor.d.ts +3 -0
- package/dist/modules/no-sample-in-accessor.d.ts.map +1 -0
- package/dist/modules/no-sample-in-accessor.js +141 -0
- package/dist/modules/no-sample-in-accessor.js.map +1 -0
- package/dist/modules/no-sample-in-reactive-position.d.ts +3 -0
- package/dist/modules/no-sample-in-reactive-position.d.ts.map +1 -0
- package/dist/modules/no-sample-in-reactive-position.js +72 -0
- package/dist/modules/no-sample-in-reactive-position.js.map +1 -0
- package/dist/modules/pure-update-function.d.ts +3 -0
- package/dist/modules/pure-update-function.d.ts.map +1 -0
- package/dist/modules/pure-update-function.js +127 -0
- package/dist/modules/pure-update-function.js.map +1 -0
- package/dist/modules/reactive-paths.d.ts +3 -0
- package/dist/modules/reactive-paths.d.ts.map +1 -0
- package/dist/modules/reactive-paths.js +77 -0
- package/dist/modules/reactive-paths.js.map +1 -0
- package/dist/modules/row-factory.d.ts +12 -0
- package/dist/modules/row-factory.d.ts.map +1 -0
- package/dist/modules/row-factory.js +385 -0
- package/dist/modules/row-factory.js.map +1 -0
- package/dist/modules/schema-hash.d.ts +15 -0
- package/dist/modules/schema-hash.d.ts.map +1 -0
- package/dist/modules/schema-hash.js +70 -0
- package/dist/modules/schema-hash.js.map +1 -0
- package/dist/modules/spread-in-children.d.ts +3 -0
- package/dist/modules/spread-in-children.d.ts.map +1 -0
- package/dist/modules/spread-in-children.js +144 -0
- package/dist/modules/spread-in-children.js.map +1 -0
- package/dist/modules/state-mutation.d.ts +3 -0
- package/dist/modules/state-mutation.d.ts.map +1 -0
- package/dist/modules/state-mutation.js +138 -0
- package/dist/modules/state-mutation.js.map +1 -0
- package/dist/modules/state-schema.d.ts +8 -0
- package/dist/modules/state-schema.d.ts.map +1 -0
- package/dist/modules/state-schema.js +55 -0
- package/dist/modules/state-schema.js.map +1 -0
- package/dist/modules/static-items.d.ts +3 -0
- package/dist/modules/static-items.d.ts.map +1 -0
- package/dist/modules/static-items.js +125 -0
- package/dist/modules/static-items.js.map +1 -0
- package/dist/modules/static-on.d.ts +3 -0
- package/dist/modules/static-on.d.ts.map +1 -0
- package/dist/modules/static-on.js +100 -0
- package/dist/modules/static-on.js.map +1 -0
- package/dist/modules/string-effect-callback.d.ts +3 -0
- package/dist/modules/string-effect-callback.d.ts.map +1 -0
- package/dist/modules/string-effect-callback.js +50 -0
- package/dist/modules/string-effect-callback.js.map +1 -0
- package/dist/modules/structural-mask.d.ts +8 -0
- package/dist/modules/structural-mask.d.ts.map +1 -0
- package/dist/modules/structural-mask.js +76 -0
- package/dist/modules/structural-mask.js.map +1 -0
- package/dist/modules/subapp-requires-reason.d.ts +3 -0
- package/dist/modules/subapp-requires-reason.d.ts.map +1 -0
- package/dist/modules/subapp-requires-reason.js +129 -0
- package/dist/modules/subapp-requires-reason.js.map +1 -0
- package/dist/modules/text-mask.d.ts +12 -0
- package/dist/modules/text-mask.d.ts.map +1 -0
- package/dist/modules/text-mask.js +63 -0
- package/dist/modules/text-mask.js.map +1 -0
- package/dist/modules/view-bag-import.d.ts +3 -0
- package/dist/modules/view-bag-import.d.ts.map +1 -0
- package/dist/modules/view-bag-import.js +80 -0
- package/dist/modules/view-bag-import.js.map +1 -0
- package/dist/msg-annotations.d.ts +104 -0
- package/dist/msg-annotations.d.ts.map +1 -0
- package/dist/msg-annotations.js +242 -0
- package/dist/msg-annotations.js.map +1 -0
- package/dist/msg-schema.d.ts +130 -0
- package/dist/msg-schema.d.ts.map +1 -0
- package/dist/msg-schema.js +770 -0
- package/dist/msg-schema.js.map +1 -0
- package/dist/schema-hash.d.ts +16 -0
- package/dist/schema-hash.d.ts.map +1 -0
- package/dist/schema-hash.js +31 -0
- package/dist/schema-hash.js.map +1 -0
- package/dist/state-schema.d.ts +41 -0
- package/dist/state-schema.d.ts.map +1 -0
- package/dist/state-schema.js +156 -0
- package/dist/state-schema.js.map +1 -0
- package/dist/transform.d.ts +109 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +1390 -0
- package/dist/transform.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// `row-factory` — emits `each() { ...; __tpl: ...; __rowUpd: ... }`
|
|
2
|
+
// when the each() call's render body can be hoisted into a static
|
|
3
|
+
// template + per-row patch function, eliminating per-row arrow
|
|
4
|
+
// allocation and giving the runtime a fast-path clone-and-patch loop.
|
|
5
|
+
//
|
|
6
|
+
// Fires **bottom-up** (`transformCall`, not `transformCallEnter`)
|
|
7
|
+
// because the rewrite depends on the each() call's render body
|
|
8
|
+
// already containing a rewritten `elTemplate(...)` call that
|
|
9
|
+
// `elementRewriteModule` produces via subtree-collapse. In Phase 2b's
|
|
10
|
+
// bottom-up phase the children have already gone through the
|
|
11
|
+
// registry's enter+recurse+exit chain, so the each() call this
|
|
12
|
+
// module sees has its render body in the post-element-rewrite shape.
|
|
13
|
+
//
|
|
14
|
+
// The function bails (returns null) on many shapes — no render
|
|
15
|
+
// prop, multiple `elTemplate` calls, nested structural primitives
|
|
16
|
+
// in render, selector.bind() V8-deopt patterns, etc. When it throws,
|
|
17
|
+
// the module catches and emits a one-line `[llui] Row factory
|
|
18
|
+
// failed in ...` warning matching the inline path's behavior.
|
|
19
|
+
import ts from 'typescript';
|
|
20
|
+
import { isHelperCall } from '../transform.js';
|
|
21
|
+
export function rowFactoryModule(options) {
|
|
22
|
+
const { viewHelperNames, viewHelperAliases, filename, source } = options;
|
|
23
|
+
return {
|
|
24
|
+
name: 'row-factory',
|
|
25
|
+
compilerVersion: '^0.3.0',
|
|
26
|
+
diagnostics: [],
|
|
27
|
+
visitors: {},
|
|
28
|
+
transformCall(ctx, node) {
|
|
29
|
+
if (!isHelperCall(node.expression, 'each', viewHelperNames, viewHelperAliases))
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
return tryEmitRowFactory(node, ctx.factory, source);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const sf = ctx.analysis.sourceFile;
|
|
36
|
+
const line = node.pos >= 0 ? sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1 : 0;
|
|
37
|
+
console.warn(`[llui] Row factory failed in ${filename}:${line} — ${err.message}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// ─── Rewrite implementation (moved verbatim from transform.ts) ─────
|
|
44
|
+
function tryEmitRowFactory(eachCall, f, _originalSource) {
|
|
45
|
+
const arg = eachCall.arguments[0];
|
|
46
|
+
if (!arg || !ts.isObjectLiteralExpression(arg))
|
|
47
|
+
return null;
|
|
48
|
+
// Find render property
|
|
49
|
+
let renderProp = null;
|
|
50
|
+
for (const prop of arg.properties) {
|
|
51
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
52
|
+
ts.isIdentifier(prop.name) &&
|
|
53
|
+
prop.name.text === 'render') {
|
|
54
|
+
renderProp = prop;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!renderProp)
|
|
59
|
+
return null;
|
|
60
|
+
const renderFn = renderProp.initializer;
|
|
61
|
+
if (!ts.isArrowFunction(renderFn) && !ts.isFunctionExpression(renderFn))
|
|
62
|
+
return null;
|
|
63
|
+
const body = ts.isBlock(renderFn.body) ? renderFn.body : null;
|
|
64
|
+
if (!body)
|
|
65
|
+
return null;
|
|
66
|
+
// Find the elTemplate call in the transformed render body
|
|
67
|
+
let templateCall = null;
|
|
68
|
+
let templateVarName = null;
|
|
69
|
+
for (const stmt of body.statements) {
|
|
70
|
+
if (ts.isVariableStatement(stmt)) {
|
|
71
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
72
|
+
if (ts.isIdentifier(decl.name) &&
|
|
73
|
+
decl.initializer &&
|
|
74
|
+
ts.isCallExpression(decl.initializer)) {
|
|
75
|
+
if (ts.isIdentifier(decl.initializer.expression) &&
|
|
76
|
+
decl.initializer.expression.text === 'elTemplate') {
|
|
77
|
+
if (templateCall)
|
|
78
|
+
return null; // multiple templates — bail
|
|
79
|
+
templateCall = decl.initializer;
|
|
80
|
+
templateVarName = decl.name.text;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Check for nested structural primitives — bail
|
|
86
|
+
if (containsStructuralCall(stmt))
|
|
87
|
+
return null;
|
|
88
|
+
// Bail on selector.bind() — row factory + selector causes V8 deopt
|
|
89
|
+
// even without per-row disposers (selector fn declarations per render)
|
|
90
|
+
if (_containsSelectorBind(stmt))
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
if (!templateCall || templateCall.arguments.length < 2)
|
|
94
|
+
return null;
|
|
95
|
+
// Extract HTML string
|
|
96
|
+
const htmlArg = templateCall.arguments[0];
|
|
97
|
+
if (!htmlArg || !ts.isStringLiteral(htmlArg))
|
|
98
|
+
return null;
|
|
99
|
+
const html = htmlArg.text;
|
|
100
|
+
// Extract patch function
|
|
101
|
+
const patchFn = templateCall.arguments[1];
|
|
102
|
+
if (!patchFn || (!ts.isArrowFunction(patchFn) && !ts.isFunctionExpression(patchFn)))
|
|
103
|
+
return null;
|
|
104
|
+
const patchBody = ts.isBlock(patchFn.body) ? patchFn.body : null;
|
|
105
|
+
if (!patchBody)
|
|
106
|
+
return null;
|
|
107
|
+
const rootParam = patchFn.parameters[0];
|
|
108
|
+
const bindParam = patchFn.parameters[1];
|
|
109
|
+
if (!rootParam || !bindParam)
|
|
110
|
+
return null;
|
|
111
|
+
const rootName = ts.isIdentifier(rootParam.name) ? rootParam.name.text : null;
|
|
112
|
+
const bindName = ts.isIdentifier(bindParam.name) ? bindParam.name.text : null;
|
|
113
|
+
if (!rootName || !bindName)
|
|
114
|
+
return null;
|
|
115
|
+
const bindings = [];
|
|
116
|
+
const nodeVarInitializers = new Map();
|
|
117
|
+
for (const stmt of patchBody.statements) {
|
|
118
|
+
if (ts.isVariableStatement(stmt)) {
|
|
119
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
120
|
+
if (ts.isIdentifier(decl.name) && decl.initializer) {
|
|
121
|
+
nodeVarInitializers.set(decl.name.text, decl.initializer);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (ts.isExpressionStatement(stmt) && ts.isCallExpression(stmt.expression)) {
|
|
126
|
+
const call = stmt.expression;
|
|
127
|
+
if (ts.isIdentifier(call.expression) &&
|
|
128
|
+
call.expression.text === bindName &&
|
|
129
|
+
call.arguments.length >= 5) {
|
|
130
|
+
const nodeArg = call.arguments[0];
|
|
131
|
+
const maskArg = call.arguments[1];
|
|
132
|
+
const kindArg = call.arguments[2];
|
|
133
|
+
const keyArg = call.arguments[3];
|
|
134
|
+
const accessorArg = call.arguments[4];
|
|
135
|
+
// Must be per-item (mask -1)
|
|
136
|
+
if (ts.isPrefixUnaryExpression(maskArg) && maskArg.operator === ts.SyntaxKind.MinusToken) {
|
|
137
|
+
// -1 → per-item ✓
|
|
138
|
+
}
|
|
139
|
+
else if (ts.isBinaryExpression(maskArg)) {
|
|
140
|
+
// -1 | 0 or 4294967295 | 0 → per-item ✓
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return null; // state-level binding — bail
|
|
144
|
+
}
|
|
145
|
+
const kind = ts.isStringLiteral(kindArg) ? kindArg.text : '';
|
|
146
|
+
const key = ts.isStringLiteral(keyArg) ? keyArg.text : undefined;
|
|
147
|
+
// Resolve node path — recursively expand variable references to get
|
|
148
|
+
// the full path from root, then create fresh factory nodes
|
|
149
|
+
function resolveNodePath(expr) {
|
|
150
|
+
if (ts.isIdentifier(expr)) {
|
|
151
|
+
if (expr.text === rootName)
|
|
152
|
+
return f.createIdentifier(rootName);
|
|
153
|
+
const init = nodeVarInitializers.get(expr.text);
|
|
154
|
+
if (init)
|
|
155
|
+
return resolveNodePath(init);
|
|
156
|
+
return f.createIdentifier(expr.text);
|
|
157
|
+
}
|
|
158
|
+
if (ts.isPropertyAccessExpression(expr)) {
|
|
159
|
+
return f.createPropertyAccessExpression(resolveNodePath(expr.expression), expr.name.text);
|
|
160
|
+
}
|
|
161
|
+
if (ts.isElementAccessExpression(expr)) {
|
|
162
|
+
return f.createElementAccessExpression(resolveNodePath(expr.expression), expr.argumentExpression);
|
|
163
|
+
}
|
|
164
|
+
return expr;
|
|
165
|
+
}
|
|
166
|
+
const nodeInit = resolveNodePath(nodeArg);
|
|
167
|
+
// Clone accessor to strip source position — prevents mixed-position errors
|
|
168
|
+
const clonedAccessor = ts.isIdentifier(accessorArg)
|
|
169
|
+
? f.createIdentifier(accessorArg.text)
|
|
170
|
+
: accessorArg;
|
|
171
|
+
bindings.push({ nodeInitializer: nodeInit, kind, key, accessor: clonedAccessor });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (bindings.length === 0)
|
|
176
|
+
return null;
|
|
177
|
+
// Build map of __a{N} → __s{N} for rewriting accessor references.
|
|
178
|
+
// After dedup, `__a{N} = acc(__s{N})`. In the row factory, __a{N} declarations
|
|
179
|
+
// are eliminated, so all references must be rewritten to __s{N}.
|
|
180
|
+
const accToSelector = new Map();
|
|
181
|
+
for (const stmt of body.statements) {
|
|
182
|
+
if (!ts.isVariableStatement(stmt))
|
|
183
|
+
continue;
|
|
184
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
185
|
+
if (!ts.isIdentifier(decl.name) || !decl.name.text.startsWith('__a'))
|
|
186
|
+
continue;
|
|
187
|
+
if (!decl.initializer || !ts.isCallExpression(decl.initializer))
|
|
188
|
+
continue;
|
|
189
|
+
const callArg0 = decl.initializer.arguments[0];
|
|
190
|
+
if (callArg0 && ts.isIdentifier(callArg0) && callArg0.text.startsWith('__s')) {
|
|
191
|
+
accToSelector.set(decl.name.text, callArg0.text);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Rewrite binding accessors: __a{N} → __s{N}
|
|
196
|
+
for (const b of bindings) {
|
|
197
|
+
if (ts.isIdentifier(b.accessor) && accToSelector.has(b.accessor.text)) {
|
|
198
|
+
b.accessor = f.createIdentifier(accToSelector.get(b.accessor.text));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Collect __s{N} selector definitions — needed by __rowUpd and render init.
|
|
202
|
+
// These are currently scoped to the render body; we'll hoist them into the
|
|
203
|
+
// __rowUpd IIFE so they're accessible.
|
|
204
|
+
const selectorDefs = new Map();
|
|
205
|
+
for (const stmt of body.statements) {
|
|
206
|
+
if (!ts.isVariableStatement(stmt))
|
|
207
|
+
continue;
|
|
208
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
209
|
+
if (ts.isIdentifier(decl.name) && decl.name.text.startsWith('__s') && decl.initializer) {
|
|
210
|
+
selectorDefs.set(decl.name.text, decl.initializer);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// === Generate the row factory ===
|
|
215
|
+
// 1. __tpl: IIFE that creates + caches the template element
|
|
216
|
+
const tplInit = f.createCallExpression(f.createParenthesizedExpression(f.createArrowFunction(undefined, undefined, [], undefined, f.createToken(ts.SyntaxKind.EqualsGreaterThanToken), f.createBlock([
|
|
217
|
+
f.createVariableStatement(undefined, f.createVariableDeclarationList([
|
|
218
|
+
f.createVariableDeclaration('t', undefined, undefined, f.createCallExpression(f.createPropertyAccessExpression(f.createIdentifier('document'), 'createElement'), undefined, [f.createStringLiteral('template')])),
|
|
219
|
+
], ts.NodeFlags.Const)),
|
|
220
|
+
f.createExpressionStatement(f.createBinaryExpression(f.createPropertyAccessExpression(f.createIdentifier('t'), 'innerHTML'), ts.SyntaxKind.EqualsToken, f.createStringLiteral(html))),
|
|
221
|
+
f.createReturnStatement(f.createIdentifier('t')),
|
|
222
|
+
], true))), undefined, []);
|
|
223
|
+
// 2. __rowUpd: (e) => { const t = e.current; for each binding: check + write }
|
|
224
|
+
const updStmts = [];
|
|
225
|
+
updStmts.push(f.createVariableStatement(undefined, f.createVariableDeclarationList([
|
|
226
|
+
f.createVariableDeclaration('t', undefined, undefined, f.createPropertyAccessExpression(f.createIdentifier('e'), 'current')),
|
|
227
|
+
], ts.NodeFlags.Const)));
|
|
228
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
229
|
+
const b = bindings[i];
|
|
230
|
+
const vId = f.createIdentifier(`v${i}`);
|
|
231
|
+
const cachedProp = f.createElementAccessExpression(f.createIdentifier('e'), f.createStringLiteral(`_v${i}`));
|
|
232
|
+
const nodeProp = f.createElementAccessExpression(f.createIdentifier('e'), f.createStringLiteral(`_n${i}`));
|
|
233
|
+
// const v{i} = accessor(t)
|
|
234
|
+
updStmts.push(f.createVariableStatement(undefined, f.createVariableDeclarationList([
|
|
235
|
+
f.createVariableDeclaration(vId, undefined, undefined, f.createCallExpression(b.accessor, undefined, [f.createIdentifier('t')])),
|
|
236
|
+
], ts.NodeFlags.Const)));
|
|
237
|
+
// DOM write expression
|
|
238
|
+
const domWrite = b.kind === 'text'
|
|
239
|
+
? f.createBinaryExpression(f.createPropertyAccessExpression(nodeProp, 'nodeValue'), ts.SyntaxKind.EqualsToken, vId)
|
|
240
|
+
: b.kind === 'class'
|
|
241
|
+
? f.createBinaryExpression(f.createPropertyAccessExpression(nodeProp, 'className'), ts.SyntaxKind.EqualsToken, vId)
|
|
242
|
+
: f.createBinaryExpression(f.createPropertyAccessExpression(nodeProp, 'nodeValue'), ts.SyntaxKind.EqualsToken, vId);
|
|
243
|
+
// if (v{i} !== e['_v{i}']) { e['_v{i}'] = v{i}; DOM_WRITE }
|
|
244
|
+
updStmts.push(f.createIfStatement(f.createBinaryExpression(vId, ts.SyntaxKind.ExclamationEqualsEqualsToken, cachedProp), f.createBlock([
|
|
245
|
+
f.createExpressionStatement(f.createBinaryExpression(cachedProp, ts.SyntaxKind.EqualsToken, vId)),
|
|
246
|
+
f.createExpressionStatement(domWrite),
|
|
247
|
+
], true)));
|
|
248
|
+
}
|
|
249
|
+
// Wrap __rowUpd in IIFE that declares selectors (they're scoped to the
|
|
250
|
+
// render body but __rowUpd lives on the options object outside render).
|
|
251
|
+
const rawUpdFn = f.createArrowFunction(undefined, undefined, [f.createParameterDeclaration(undefined, undefined, 'e')], undefined, f.createToken(ts.SyntaxKind.EqualsGreaterThanToken), f.createBlock(updStmts, true));
|
|
252
|
+
// Build: (() => { const __s0 = ...; const __s1 = ...; return (e) => { ... } })()
|
|
253
|
+
const selectorDecls = [];
|
|
254
|
+
for (const [name, init] of selectorDefs) {
|
|
255
|
+
selectorDecls.push(f.createVariableStatement(undefined, f.createVariableDeclarationList([f.createVariableDeclaration(name, undefined, undefined, init)], ts.NodeFlags.Const)));
|
|
256
|
+
}
|
|
257
|
+
selectorDecls.push(f.createReturnStatement(rawUpdFn));
|
|
258
|
+
const rowUpdFn = f.createCallExpression(f.createParenthesizedExpression(f.createArrowFunction(undefined, undefined, [], undefined, f.createToken(ts.SyntaxKind.EqualsGreaterThanToken), f.createBlock(selectorDecls, true))), undefined, []);
|
|
259
|
+
// 3. New render callback: ({ entry: e, __tpl, __rowUpd }) => { ... }
|
|
260
|
+
const renderStmts = [];
|
|
261
|
+
// Declare selectors at the top of render body (they're used for initial values)
|
|
262
|
+
for (const [name, init] of selectorDefs) {
|
|
263
|
+
renderStmts.push(f.createVariableStatement(undefined, f.createVariableDeclarationList([f.createVariableDeclaration(name, undefined, undefined, init)], ts.NodeFlags.Const)));
|
|
264
|
+
}
|
|
265
|
+
// const r = __tpl.content.firstElementChild.cloneNode(true)
|
|
266
|
+
renderStmts.push(f.createVariableStatement(undefined, f.createVariableDeclarationList([
|
|
267
|
+
f.createVariableDeclaration('r', undefined, undefined, f.createCallExpression(f.createPropertyAccessExpression(f.createPropertyAccessExpression(f.createPropertyAccessExpression(f.createIdentifier('__tpl'), 'content'), 'firstElementChild'), 'cloneNode'), undefined, [f.createTrue()])),
|
|
268
|
+
], ts.NodeFlags.Const)));
|
|
269
|
+
// For each binding: store node ref, compute initial, apply
|
|
270
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
271
|
+
const b = bindings[i];
|
|
272
|
+
const nProp = f.createElementAccessExpression(f.createIdentifier('e'), f.createStringLiteral(`_n${i}`));
|
|
273
|
+
const vProp = f.createElementAccessExpression(f.createIdentifier('e'), f.createStringLiteral(`_v${i}`));
|
|
274
|
+
// Rewrite node path: replace root param name with 'r'
|
|
275
|
+
const rewrittenPath = rewriteRoot(b.nodeInitializer, rootName, 'r', f);
|
|
276
|
+
// e['_n{i}'] = rewrittenPath
|
|
277
|
+
renderStmts.push(f.createExpressionStatement(f.createBinaryExpression(nProp, ts.SyntaxKind.EqualsToken, rewrittenPath)));
|
|
278
|
+
// e['_v{i}'] = accessor(e.current)
|
|
279
|
+
renderStmts.push(f.createExpressionStatement(f.createBinaryExpression(vProp, ts.SyntaxKind.EqualsToken, f.createCallExpression(b.accessor, undefined, [
|
|
280
|
+
f.createPropertyAccessExpression(f.createIdentifier('e'), 'current'),
|
|
281
|
+
]))));
|
|
282
|
+
// DOM write: e['_n{i}'].nodeValue = e['_v{i}']
|
|
283
|
+
const initWrite = b.kind === 'text'
|
|
284
|
+
? f.createBinaryExpression(f.createPropertyAccessExpression(nProp, 'nodeValue'), ts.SyntaxKind.EqualsToken, vProp)
|
|
285
|
+
: b.kind === 'class'
|
|
286
|
+
? f.createBinaryExpression(f.createPropertyAccessExpression(nProp, 'className'), ts.SyntaxKind.EqualsToken, vProp)
|
|
287
|
+
: f.createBinaryExpression(f.createPropertyAccessExpression(nProp, 'nodeValue'), ts.SyntaxKind.EqualsToken, vProp);
|
|
288
|
+
renderStmts.push(f.createExpressionStatement(initWrite));
|
|
289
|
+
}
|
|
290
|
+
// e.__rowUpdate = __rowUpd
|
|
291
|
+
renderStmts.push(f.createExpressionStatement(f.createBinaryExpression(f.createPropertyAccessExpression(f.createIdentifier('e'), '__rowUpdate'), ts.SyntaxKind.EqualsToken, f.createIdentifier('__rowUpd'))));
|
|
292
|
+
// Rewrite a statement: replace __a{N}() → __s{N}(e.current),
|
|
293
|
+
// replace template var → r, strip positions via deep clone.
|
|
294
|
+
function rewriteStmt(stmt) {
|
|
295
|
+
function visit(node) {
|
|
296
|
+
// Rewrite __a{N}() → __s{N}(e.current)
|
|
297
|
+
if (ts.isCallExpression(node) &&
|
|
298
|
+
ts.isIdentifier(node.expression) &&
|
|
299
|
+
accToSelector.has(node.expression.text) &&
|
|
300
|
+
node.arguments.length === 0) {
|
|
301
|
+
const selectorName = accToSelector.get(node.expression.text);
|
|
302
|
+
return f.createCallExpression(f.createIdentifier(selectorName), undefined, [
|
|
303
|
+
f.createPropertyAccessExpression(f.createIdentifier('e'), 'current'),
|
|
304
|
+
]);
|
|
305
|
+
}
|
|
306
|
+
// Rewrite template variable → r
|
|
307
|
+
if (ts.isIdentifier(node) && templateVarName && node.text === templateVarName) {
|
|
308
|
+
return f.createIdentifier('r');
|
|
309
|
+
}
|
|
310
|
+
// Clone identifiers to strip positions
|
|
311
|
+
if (ts.isIdentifier(node)) {
|
|
312
|
+
return f.createIdentifier(node.text);
|
|
313
|
+
}
|
|
314
|
+
return ts.visitEachChild(node, visit, undefined);
|
|
315
|
+
}
|
|
316
|
+
return ts.visitEachChild(stmt, visit, undefined);
|
|
317
|
+
}
|
|
318
|
+
// Preserve non-template, non-compiler-generated, non-return statements.
|
|
319
|
+
for (const stmt of body.statements) {
|
|
320
|
+
if (ts.isReturnStatement(stmt))
|
|
321
|
+
continue;
|
|
322
|
+
if (ts.isVariableStatement(stmt)) {
|
|
323
|
+
// Skip template declaration
|
|
324
|
+
const isTemplate = stmt.declarationList.declarations.some((d) => ts.isIdentifier(d.name) && d.name.text === templateVarName);
|
|
325
|
+
if (isTemplate)
|
|
326
|
+
continue;
|
|
327
|
+
// Skip __a{N} and __s{N} declarations (compiler-generated acc/selector)
|
|
328
|
+
const isCompilerOnly = stmt.declarationList.declarations.every((d) => ts.isIdentifier(d.name) &&
|
|
329
|
+
(d.name.text.startsWith('__a') || d.name.text.startsWith('__s')));
|
|
330
|
+
if (isCompilerOnly)
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
// Rewrite and include
|
|
334
|
+
renderStmts.push(rewriteStmt(stmt));
|
|
335
|
+
}
|
|
336
|
+
// return [r]
|
|
337
|
+
renderStmts.push(f.createReturnStatement(f.createArrayLiteralExpression([f.createIdentifier('r')])));
|
|
338
|
+
const newRenderFn = f.createArrowFunction(undefined, undefined, [
|
|
339
|
+
f.createParameterDeclaration(undefined, undefined, f.createObjectBindingPattern([
|
|
340
|
+
f.createBindingElement(undefined, 'entry', 'e'),
|
|
341
|
+
f.createBindingElement(undefined, undefined, '__tpl'),
|
|
342
|
+
f.createBindingElement(undefined, undefined, '__rowUpd'),
|
|
343
|
+
])),
|
|
344
|
+
], undefined, f.createToken(ts.SyntaxKind.EqualsGreaterThanToken), f.createBlock(renderStmts, true));
|
|
345
|
+
// 4. Build new each options. To avoid mixed-position AST issues, we keep
|
|
346
|
+
// original properties unchanged and only ADD __tpl, __rowUpd, and replace render.
|
|
347
|
+
// The trick: return the original node structure but with the render property
|
|
348
|
+
// swapped. Use ts.factory.updateObjectLiteralExpression which preserves positions.
|
|
349
|
+
const updatedProps = arg.properties.map((p) => p === renderProp ? f.createPropertyAssignment('render', newRenderFn) : p);
|
|
350
|
+
updatedProps.push(f.createPropertyAssignment('__tpl', tplInit));
|
|
351
|
+
updatedProps.push(f.createPropertyAssignment('__rowUpd', rowUpdFn));
|
|
352
|
+
const newOpts = f.updateObjectLiteralExpression(arg, updatedProps);
|
|
353
|
+
return f.updateCallExpression(eachCall, eachCall.expression, eachCall.typeArguments, [
|
|
354
|
+
newOpts,
|
|
355
|
+
...eachCall.arguments.slice(1),
|
|
356
|
+
]);
|
|
357
|
+
}
|
|
358
|
+
function _containsSelectorBind(node) {
|
|
359
|
+
if (ts.isCallExpression(node) &&
|
|
360
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
361
|
+
node.expression.name.text === 'bind') {
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
return ts.forEachChild(node, _containsSelectorBind) ?? false;
|
|
365
|
+
}
|
|
366
|
+
function containsStructuralCall(node) {
|
|
367
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
|
|
368
|
+
if (['each', 'branch', 'scope', 'show', 'child', 'foreign'].includes(node.expression.text))
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
return ts.forEachChild(node, containsStructuralCall) ?? false;
|
|
372
|
+
}
|
|
373
|
+
/** Rewrite property access chains replacing oldRoot identifier with newRoot */
|
|
374
|
+
function rewriteRoot(expr, oldRoot, newRoot, f) {
|
|
375
|
+
if (ts.isIdentifier(expr) && expr.text === oldRoot)
|
|
376
|
+
return f.createIdentifier(newRoot);
|
|
377
|
+
if (ts.isPropertyAccessExpression(expr)) {
|
|
378
|
+
return f.createPropertyAccessExpression(rewriteRoot(expr.expression, oldRoot, newRoot, f), expr.name.text);
|
|
379
|
+
}
|
|
380
|
+
if (ts.isElementAccessExpression(expr)) {
|
|
381
|
+
return f.createElementAccessExpression(rewriteRoot(expr.expression, oldRoot, newRoot, f), expr.argumentExpression);
|
|
382
|
+
}
|
|
383
|
+
return expr;
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=row-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-factory.js","sourceRoot":"","sources":["../../src/modules/row-factory.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,kEAAkE;AAClE,+DAA+D;AAC/D,sEAAsE;AACtE,EAAE;AACF,kEAAkE;AAClE,+DAA+D;AAC/D,6DAA6D;AAC7D,sEAAsE;AACtE,6DAA6D;AAC7D,+DAA+D;AAC/D,qEAAqE;AACrE,EAAE;AACF,+DAA+D;AAC/D,kEAAkE;AAClE,qEAAqE;AACrE,8DAA8D;AAC9D,8DAA8D;AAE9D,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAY9C,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IACxE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,eAAe,EAAE,QAAQ;QACzB,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,EAAE;QAEZ,aAAa,CAAC,GAAG,EAAE,IAAI;YACrB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,iBAAiB,CAAC;gBAAE,OAAO,IAAI,CAAA;Y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AAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,CAAC,6BAA6B,CACpC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EACjD,IAAI,CAAC,kBAAkB,CACxB,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// `row-factory` — emits `each() { ...; __tpl: ...; __rowUpd: ... }`\n// when the each() call's render body can be hoisted into a static\n// template + per-row patch function, eliminating per-row arrow\n// allocation and giving the runtime a fast-path clone-and-patch loop.\n//\n// Fires **bottom-up** (`transformCall`, not `transformCallEnter`)\n// because the rewrite depends on the each() call's render body\n// already containing a rewritten `elTemplate(...)` call that\n// `elementRewriteModule` produces via subtree-collapse. In Phase 2b's\n// bottom-up phase the children have already gone through the\n// registry's enter+recurse+exit chain, so the each() call this\n// module sees has its render body in the post-element-rewrite shape.\n//\n// The function bails (returns null) on many shapes — no render\n// prop, multiple `elTemplate` calls, nested structural primitives\n// in render, selector.bind() V8-deopt patterns, etc. When it throws,\n// the module catches and emits a one-line `[llui] Row factory\n// failed in ...` warning matching the inline path's behavior.\n\nimport ts from 'typescript'\nimport type { CompilerModule } from '../module.js'\nimport { isHelperCall } from '../transform.js'\n\nexport interface RowFactoryModuleOptions {\n viewHelperNames: Set<string>\n viewHelperAliases: Map<string, string>\n /** Filename for the warn message. */\n filename: string\n /** Original source text — passed through to the rewrite (unused\n * by the function, but the signature requires it). */\n source: string\n}\n\nexport function rowFactoryModule(options: RowFactoryModuleOptions): CompilerModule {\n const { viewHelperNames, viewHelperAliases, filename, source } = options\n return {\n name: 'row-factory',\n compilerVersion: '^0.3.0',\n diagnostics: [],\n visitors: {},\n\n transformCall(ctx, node) {\n if (!isHelperCall(node.expression, 'each', viewHelperNames, viewHelperAliases)) return null\n try {\n return tryEmitRowFactory(node, ctx.factory, source)\n } catch (err) {\n const sf = ctx.analysis.sourceFile\n const line =\n node.pos >= 0 ? sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1 : 0\n console.warn(`[llui] Row factory failed in ${filename}:${line} — ${(err as Error).message}`)\n return null\n }\n },\n }\n}\n\n// ─── Rewrite implementation (moved verbatim from transform.ts) ─────\n\nfunction tryEmitRowFactory(\n eachCall: ts.CallExpression,\n f: ts.NodeFactory,\n _originalSource: string,\n): ts.CallExpression | null {\n const arg = eachCall.arguments[0]\n if (!arg || !ts.isObjectLiteralExpression(arg)) return null\n\n // Find render property\n let renderProp: ts.PropertyAssignment | null = null\n for (const prop of arg.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === 'render'\n ) {\n renderProp = prop\n break\n }\n }\n if (!renderProp) return null\n\n const renderFn = renderProp.initializer\n if (!ts.isArrowFunction(renderFn) && !ts.isFunctionExpression(renderFn)) return null\n const body = ts.isBlock(renderFn.body) ? renderFn.body : null\n if (!body) return null\n\n // Find the elTemplate call in the transformed render body\n let templateCall: ts.CallExpression | null = null\n let templateVarName: string | null = null\n\n for (const stmt of body.statements) {\n if (ts.isVariableStatement(stmt)) {\n for (const decl of stmt.declarationList.declarations) {\n if (\n ts.isIdentifier(decl.name) &&\n decl.initializer &&\n ts.isCallExpression(decl.initializer)\n ) {\n if (\n ts.isIdentifier(decl.initializer.expression) &&\n decl.initializer.expression.text === 'elTemplate'\n ) {\n if (templateCall) return null // multiple templates — bail\n templateCall = decl.initializer\n templateVarName = decl.name.text\n }\n }\n }\n }\n // Check for nested structural primitives — bail\n if (containsStructuralCall(stmt)) return null\n // Bail on selector.bind() — row factory + selector causes V8 deopt\n // even without per-row disposers (selector fn declarations per render)\n if (_containsSelectorBind(stmt)) return null\n }\n\n if (!templateCall || templateCall.arguments.length < 2) return null\n\n // Extract HTML string\n const htmlArg = templateCall.arguments[0]\n if (!htmlArg || !ts.isStringLiteral(htmlArg)) return null\n const html = htmlArg.text\n\n // Extract patch function\n const patchFn = templateCall.arguments[1]\n if (!patchFn || (!ts.isArrowFunction(patchFn) && !ts.isFunctionExpression(patchFn))) return null\n const patchBody = ts.isBlock(patchFn.body) ? patchFn.body : null\n if (!patchBody) return null\n\n const rootParam = patchFn.parameters[0]\n const bindParam = patchFn.parameters[1]\n if (!rootParam || !bindParam) return null\n const rootName = ts.isIdentifier(rootParam.name) ? rootParam.name.text : null\n const bindName = ts.isIdentifier(bindParam.name) ? bindParam.name.text : null\n if (!rootName || !bindName) return null\n\n // Extract bindings from patch function\n interface RowBinding {\n nodeInitializer: ts.Expression // the node path expression (e.g., root.firstChild)\n kind: string\n key: string | undefined\n accessor: ts.Expression\n }\n const bindings: RowBinding[] = []\n const nodeVarInitializers = new Map<string, ts.Expression>()\n\n for (const stmt of patchBody.statements) {\n if (ts.isVariableStatement(stmt)) {\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && decl.initializer) {\n nodeVarInitializers.set(decl.name.text, decl.initializer)\n }\n }\n }\n\n if (ts.isExpressionStatement(stmt) && ts.isCallExpression(stmt.expression)) {\n const call = stmt.expression\n if (\n ts.isIdentifier(call.expression) &&\n call.expression.text === bindName &&\n call.arguments.length >= 5\n ) {\n const nodeArg = call.arguments[0]!\n const maskArg = call.arguments[1]!\n const kindArg = call.arguments[2]!\n const keyArg = call.arguments[3]!\n const accessorArg = call.arguments[4]!\n\n // Must be per-item (mask -1)\n if (ts.isPrefixUnaryExpression(maskArg) && maskArg.operator === ts.SyntaxKind.MinusToken) {\n // -1 → per-item ✓\n } else if (ts.isBinaryExpression(maskArg)) {\n // -1 | 0 or 4294967295 | 0 → per-item ✓\n } else {\n return null // state-level binding — bail\n }\n\n const kind = ts.isStringLiteral(kindArg) ? kindArg.text : ''\n const key = ts.isStringLiteral(keyArg) ? keyArg.text : undefined\n\n // Resolve node path — recursively expand variable references to get\n // the full path from root, then create fresh factory nodes\n function resolveNodePath(expr: ts.Expression): ts.Expression {\n if (ts.isIdentifier(expr)) {\n if (expr.text === rootName) return f.createIdentifier(rootName)\n const init = nodeVarInitializers.get(expr.text)\n if (init) return resolveNodePath(init)\n return f.createIdentifier(expr.text)\n }\n if (ts.isPropertyAccessExpression(expr)) {\n return f.createPropertyAccessExpression(\n resolveNodePath(expr.expression),\n expr.name.text,\n )\n }\n if (ts.isElementAccessExpression(expr)) {\n return f.createElementAccessExpression(\n resolveNodePath(expr.expression),\n expr.argumentExpression,\n )\n }\n return expr\n }\n const nodeInit = resolveNodePath(nodeArg)\n\n // Clone accessor to strip source position — prevents mixed-position errors\n const clonedAccessor = ts.isIdentifier(accessorArg)\n ? f.createIdentifier(accessorArg.text)\n : accessorArg\n bindings.push({ nodeInitializer: nodeInit, kind, key, accessor: clonedAccessor })\n }\n }\n }\n\n if (bindings.length === 0) return null\n\n // Build map of __a{N} → __s{N} for rewriting accessor references.\n // After dedup, `__a{N} = acc(__s{N})`. In the row factory, __a{N} declarations\n // are eliminated, so all references must be rewritten to __s{N}.\n const accToSelector = new Map<string, string>()\n for (const stmt of body.statements) {\n if (!ts.isVariableStatement(stmt)) continue\n for (const decl of stmt.declarationList.declarations) {\n if (!ts.isIdentifier(decl.name) || !decl.name.text.startsWith('__a')) continue\n if (!decl.initializer || !ts.isCallExpression(decl.initializer)) continue\n const callArg0 = decl.initializer.arguments[0]\n if (callArg0 && ts.isIdentifier(callArg0) && callArg0.text.startsWith('__s')) {\n accToSelector.set(decl.name.text, callArg0.text)\n }\n }\n }\n\n // Rewrite binding accessors: __a{N} → __s{N}\n for (const b of bindings) {\n if (ts.isIdentifier(b.accessor) && accToSelector.has(b.accessor.text)) {\n b.accessor = f.createIdentifier(accToSelector.get(b.accessor.text)!)\n }\n }\n\n // Collect __s{N} selector definitions — needed by __rowUpd and render init.\n // These are currently scoped to the render body; we'll hoist them into the\n // __rowUpd IIFE so they're accessible.\n const selectorDefs = new Map<string, ts.Expression>()\n for (const stmt of body.statements) {\n if (!ts.isVariableStatement(stmt)) continue\n for (const decl of stmt.declarationList.declarations) {\n if (ts.isIdentifier(decl.name) && decl.name.text.startsWith('__s') && decl.initializer) {\n selectorDefs.set(decl.name.text, decl.initializer)\n }\n }\n }\n\n // === Generate the row factory ===\n\n // 1. __tpl: IIFE that creates + caches the template element\n const tplInit = f.createCallExpression(\n f.createParenthesizedExpression(\n f.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n f.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n f.createBlock(\n [\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [\n f.createVariableDeclaration(\n 't',\n undefined,\n undefined,\n f.createCallExpression(\n f.createPropertyAccessExpression(\n f.createIdentifier('document'),\n 'createElement',\n ),\n undefined,\n [f.createStringLiteral('template')],\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n f.createExpressionStatement(\n f.createBinaryExpression(\n f.createPropertyAccessExpression(f.createIdentifier('t'), 'innerHTML'),\n ts.SyntaxKind.EqualsToken,\n f.createStringLiteral(html),\n ),\n ),\n f.createReturnStatement(f.createIdentifier('t')),\n ],\n true,\n ),\n ),\n ),\n undefined,\n [],\n )\n\n // 2. __rowUpd: (e) => { const t = e.current; for each binding: check + write }\n const updStmts: ts.Statement[] = []\n updStmts.push(\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [\n f.createVariableDeclaration(\n 't',\n undefined,\n undefined,\n f.createPropertyAccessExpression(f.createIdentifier('e'), 'current'),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n )\n\n for (let i = 0; i < bindings.length; i++) {\n const b = bindings[i]!\n const vId = f.createIdentifier(`v${i}`)\n const cachedProp = f.createElementAccessExpression(\n f.createIdentifier('e'),\n f.createStringLiteral(`_v${i}`),\n )\n const nodeProp = f.createElementAccessExpression(\n f.createIdentifier('e'),\n f.createStringLiteral(`_n${i}`),\n )\n\n // const v{i} = accessor(t)\n updStmts.push(\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [\n f.createVariableDeclaration(\n vId,\n undefined,\n undefined,\n f.createCallExpression(b.accessor, undefined, [f.createIdentifier('t')]),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n )\n\n // DOM write expression\n const domWrite =\n b.kind === 'text'\n ? f.createBinaryExpression(\n f.createPropertyAccessExpression(nodeProp, 'nodeValue'),\n ts.SyntaxKind.EqualsToken,\n vId,\n )\n : b.kind === 'class'\n ? f.createBinaryExpression(\n f.createPropertyAccessExpression(nodeProp, 'className'),\n ts.SyntaxKind.EqualsToken,\n vId,\n )\n : f.createBinaryExpression(\n f.createPropertyAccessExpression(nodeProp, 'nodeValue'),\n ts.SyntaxKind.EqualsToken,\n vId,\n )\n\n // if (v{i} !== e['_v{i}']) { e['_v{i}'] = v{i}; DOM_WRITE }\n updStmts.push(\n f.createIfStatement(\n f.createBinaryExpression(vId, ts.SyntaxKind.ExclamationEqualsEqualsToken, cachedProp),\n f.createBlock(\n [\n f.createExpressionStatement(\n f.createBinaryExpression(cachedProp, ts.SyntaxKind.EqualsToken, vId),\n ),\n f.createExpressionStatement(domWrite),\n ],\n true,\n ),\n ),\n )\n }\n\n // Wrap __rowUpd in IIFE that declares selectors (they're scoped to the\n // render body but __rowUpd lives on the options object outside render).\n const rawUpdFn = f.createArrowFunction(\n undefined,\n undefined,\n [f.createParameterDeclaration(undefined, undefined, 'e')],\n undefined,\n f.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n f.createBlock(updStmts, true),\n )\n\n // Build: (() => { const __s0 = ...; const __s1 = ...; return (e) => { ... } })()\n const selectorDecls: ts.Statement[] = []\n for (const [name, init] of selectorDefs) {\n selectorDecls.push(\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [f.createVariableDeclaration(name, undefined, undefined, init)],\n ts.NodeFlags.Const,\n ),\n ),\n )\n }\n selectorDecls.push(f.createReturnStatement(rawUpdFn))\n\n const rowUpdFn = f.createCallExpression(\n f.createParenthesizedExpression(\n f.createArrowFunction(\n undefined,\n undefined,\n [],\n undefined,\n f.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n f.createBlock(selectorDecls, true),\n ),\n ),\n undefined,\n [],\n )\n\n // 3. New render callback: ({ entry: e, __tpl, __rowUpd }) => { ... }\n const renderStmts: ts.Statement[] = []\n\n // Declare selectors at the top of render body (they're used for initial values)\n for (const [name, init] of selectorDefs) {\n renderStmts.push(\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [f.createVariableDeclaration(name, undefined, undefined, init)],\n ts.NodeFlags.Const,\n ),\n ),\n )\n }\n\n // const r = __tpl.content.firstElementChild.cloneNode(true)\n renderStmts.push(\n f.createVariableStatement(\n undefined,\n f.createVariableDeclarationList(\n [\n f.createVariableDeclaration(\n 'r',\n undefined,\n undefined,\n f.createCallExpression(\n f.createPropertyAccessExpression(\n f.createPropertyAccessExpression(\n f.createPropertyAccessExpression(f.createIdentifier('__tpl'), 'content'),\n 'firstElementChild',\n ),\n 'cloneNode',\n ),\n undefined,\n [f.createTrue()],\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n )\n\n // For each binding: store node ref, compute initial, apply\n for (let i = 0; i < bindings.length; i++) {\n const b = bindings[i]!\n const nProp = f.createElementAccessExpression(\n f.createIdentifier('e'),\n f.createStringLiteral(`_n${i}`),\n )\n const vProp = f.createElementAccessExpression(\n f.createIdentifier('e'),\n f.createStringLiteral(`_v${i}`),\n )\n\n // Rewrite node path: replace root param name with 'r'\n const rewrittenPath = rewriteRoot(b.nodeInitializer, rootName, 'r', f)\n\n // e['_n{i}'] = rewrittenPath\n renderStmts.push(\n f.createExpressionStatement(\n f.createBinaryExpression(nProp, ts.SyntaxKind.EqualsToken, rewrittenPath),\n ),\n )\n\n // e['_v{i}'] = accessor(e.current)\n renderStmts.push(\n f.createExpressionStatement(\n f.createBinaryExpression(\n vProp,\n ts.SyntaxKind.EqualsToken,\n f.createCallExpression(b.accessor, undefined, [\n f.createPropertyAccessExpression(f.createIdentifier('e'), 'current'),\n ]),\n ),\n ),\n )\n\n // DOM write: e['_n{i}'].nodeValue = e['_v{i}']\n const initWrite =\n b.kind === 'text'\n ? f.createBinaryExpression(\n f.createPropertyAccessExpression(nProp, 'nodeValue'),\n ts.SyntaxKind.EqualsToken,\n vProp,\n )\n : b.kind === 'class'\n ? f.createBinaryExpression(\n f.createPropertyAccessExpression(nProp, 'className'),\n ts.SyntaxKind.EqualsToken,\n vProp,\n )\n : f.createBinaryExpression(\n f.createPropertyAccessExpression(nProp, 'nodeValue'),\n ts.SyntaxKind.EqualsToken,\n vProp,\n )\n renderStmts.push(f.createExpressionStatement(initWrite))\n }\n\n // e.__rowUpdate = __rowUpd\n renderStmts.push(\n f.createExpressionStatement(\n f.createBinaryExpression(\n f.createPropertyAccessExpression(f.createIdentifier('e'), '__rowUpdate'),\n ts.SyntaxKind.EqualsToken,\n f.createIdentifier('__rowUpd'),\n ),\n ),\n )\n\n // Rewrite a statement: replace __a{N}() → __s{N}(e.current),\n // replace template var → r, strip positions via deep clone.\n function rewriteStmt(stmt: ts.Statement): ts.Statement {\n function visit(node: ts.Node): ts.Node {\n // Rewrite __a{N}() → __s{N}(e.current)\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n accToSelector.has(node.expression.text) &&\n node.arguments.length === 0\n ) {\n const selectorName = accToSelector.get(node.expression.text)!\n return f.createCallExpression(f.createIdentifier(selectorName), undefined, [\n f.createPropertyAccessExpression(f.createIdentifier('e'), 'current'),\n ])\n }\n // Rewrite template variable → r\n if (ts.isIdentifier(node) && templateVarName && node.text === templateVarName) {\n return f.createIdentifier('r')\n }\n // Clone identifiers to strip positions\n if (ts.isIdentifier(node)) {\n return f.createIdentifier(node.text)\n }\n return ts.visitEachChild(node, visit, undefined!)\n }\n return ts.visitEachChild(stmt, visit, undefined!) as ts.Statement\n }\n\n // Preserve non-template, non-compiler-generated, non-return statements.\n for (const stmt of body.statements) {\n if (ts.isReturnStatement(stmt)) continue\n\n if (ts.isVariableStatement(stmt)) {\n // Skip template declaration\n const isTemplate = stmt.declarationList.declarations.some(\n (d) => ts.isIdentifier(d.name) && d.name.text === templateVarName,\n )\n if (isTemplate) continue\n // Skip __a{N} and __s{N} declarations (compiler-generated acc/selector)\n const isCompilerOnly = stmt.declarationList.declarations.every(\n (d) =>\n ts.isIdentifier(d.name) &&\n (d.name.text.startsWith('__a') || d.name.text.startsWith('__s')),\n )\n if (isCompilerOnly) continue\n }\n\n // Rewrite and include\n renderStmts.push(rewriteStmt(stmt))\n }\n\n // return [r]\n renderStmts.push(\n f.createReturnStatement(f.createArrayLiteralExpression([f.createIdentifier('r')])),\n )\n\n const newRenderFn = f.createArrowFunction(\n undefined,\n undefined,\n [\n f.createParameterDeclaration(\n undefined,\n undefined,\n f.createObjectBindingPattern([\n f.createBindingElement(undefined, 'entry', 'e'),\n f.createBindingElement(undefined, undefined, '__tpl'),\n f.createBindingElement(undefined, undefined, '__rowUpd'),\n ]),\n ),\n ],\n undefined,\n f.createToken(ts.SyntaxKind.EqualsGreaterThanToken),\n f.createBlock(renderStmts, true),\n )\n\n // 4. Build new each options. To avoid mixed-position AST issues, we keep\n // original properties unchanged and only ADD __tpl, __rowUpd, and replace render.\n // The trick: return the original node structure but with the render property\n // swapped. Use ts.factory.updateObjectLiteralExpression which preserves positions.\n const updatedProps = arg.properties.map(\n (p): ts.ObjectLiteralElementLike =>\n p === renderProp ? f.createPropertyAssignment('render', newRenderFn) : p,\n )\n updatedProps.push(f.createPropertyAssignment('__tpl', tplInit))\n updatedProps.push(f.createPropertyAssignment('__rowUpd', rowUpdFn))\n\n const newOpts = f.updateObjectLiteralExpression(arg, updatedProps)\n\n return f.updateCallExpression(eachCall, eachCall.expression, eachCall.typeArguments, [\n newOpts,\n ...eachCall.arguments.slice(1),\n ])\n}\n\nfunction _containsSelectorBind(node: ts.Node): boolean {\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === 'bind'\n ) {\n return true\n }\n return ts.forEachChild(node, _containsSelectorBind) ?? false\n}\n\nfunction containsStructuralCall(node: ts.Node): boolean {\n if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {\n if (['each', 'branch', 'scope', 'show', 'child', 'foreign'].includes(node.expression.text))\n return true\n }\n return ts.forEachChild(node, containsStructuralCall) ?? false\n}\n\n/** Rewrite property access chains replacing oldRoot identifier with newRoot */\nfunction rewriteRoot(\n expr: ts.Expression,\n oldRoot: string,\n newRoot: string,\n f: ts.NodeFactory,\n): ts.Expression {\n if (ts.isIdentifier(expr) && expr.text === oldRoot) return f.createIdentifier(newRoot)\n if (ts.isPropertyAccessExpression(expr)) {\n return f.createPropertyAccessExpression(\n rewriteRoot(expr.expression, oldRoot, newRoot, f),\n expr.name.text,\n )\n }\n if (ts.isElementAccessExpression(expr)) {\n return f.createElementAccessExpression(\n rewriteRoot(expr.expression, oldRoot, newRoot, f),\n expr.argumentExpression,\n )\n }\n return expr\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MessageAnnotations } from '../msg-annotations.js';
|
|
2
|
+
import type { CompilerModule } from '../module.js';
|
|
3
|
+
/**
|
|
4
|
+
* Slot shape modules write to populate this module's inputs. Sibling
|
|
5
|
+
* agent modules (msg-schema, state-schema, msg-annotations) write their
|
|
6
|
+
* outputs here under the same conventional slot name.
|
|
7
|
+
*/
|
|
8
|
+
export interface SchemaHashInputs {
|
|
9
|
+
msgSchema: unknown;
|
|
10
|
+
stateSchema: unknown;
|
|
11
|
+
msgAnnotations: Record<string, MessageAnnotations> | null;
|
|
12
|
+
}
|
|
13
|
+
export declare const SCHEMA_HASH_INPUTS_SLOT = "schema-hash:inputs";
|
|
14
|
+
export declare const schemaHashModule: CompilerModule;
|
|
15
|
+
//# sourceMappingURL=schema-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-hash.d.ts","sourceRoot":"","sources":["../../src/modules/schema-hash.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,cAAc,CAAA;AAGxE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,IAAI,CAAA;CAC1D;AAED,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAE3D,eAAO,MAAM,gBAAgB,EAAE,cAyC9B,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// `schema-hash` — CompilerModule wrapper around `computeSchemaHash`.
|
|
2
|
+
//
|
|
3
|
+
// Per `MODULE-MAPPING.md`, this is an **agent** concern: the hash signals
|
|
4
|
+
// schema drift across HMR cycles, and only matters when the agent
|
|
5
|
+
// runtime cares about Msg/State schema stability. When the agent module
|
|
6
|
+
// is disabled, this module is excluded from the registry — bundles
|
|
7
|
+
// don't carry `__schemaHash` and the HMR re-send heuristic falls back
|
|
8
|
+
// to "always re-send".
|
|
9
|
+
//
|
|
10
|
+
// The module reads its inputs from sibling-module slots:
|
|
11
|
+
// - `msg-schema`'s slot for the MsgSchema object
|
|
12
|
+
// - `state-schema`'s slot for the StateSchema object
|
|
13
|
+
// - `msg-annotations`'s slot for the annotation map
|
|
14
|
+
//
|
|
15
|
+
// Today none of those sibling modules exist yet — the monolith's
|
|
16
|
+
// `transform.ts` still owns the schema extraction. So this module's
|
|
17
|
+
// `emit` falls back to "no contribution" when the slots are empty.
|
|
18
|
+
// The agent-pipeline decomposition push fills the sibling slots and
|
|
19
|
+
// flips this module from no-op to authoritative.
|
|
20
|
+
//
|
|
21
|
+
// Test fixture: `test/poc-module-schema-hash.test.ts` constructs a
|
|
22
|
+
// fake AnalysisContext with populated slots and asserts the emitted
|
|
23
|
+
// __schemaHash matches `computeSchemaHash`'s direct output. This proves
|
|
24
|
+
// the registry+module path produces a byte-identical hash without
|
|
25
|
+
// requiring the full sibling-module pipeline.
|
|
26
|
+
import ts from 'typescript';
|
|
27
|
+
import { computeSchemaHash } from '../schema-hash.js';
|
|
28
|
+
import { findComponentCalls } from './_shared.js';
|
|
29
|
+
export const SCHEMA_HASH_INPUTS_SLOT = 'schema-hash:inputs';
|
|
30
|
+
export const schemaHashModule = {
|
|
31
|
+
name: 'schema-hash',
|
|
32
|
+
compilerVersion: '^0.3.0',
|
|
33
|
+
dependsOn: [],
|
|
34
|
+
diagnostics: [],
|
|
35
|
+
// No visitor pass — this module is a pure emit consumer. Sibling
|
|
36
|
+
// modules populate the inputs slot during their own visitor pass.
|
|
37
|
+
visitors: {},
|
|
38
|
+
emit(ctx, analysis) {
|
|
39
|
+
const slot = analysis.perModule.get(SCHEMA_HASH_INPUTS_SLOT);
|
|
40
|
+
// The monolith emits `__schemaHash` unconditionally for every
|
|
41
|
+
// compiled `component()` — `computeSchemaHash({null, null, null})`
|
|
42
|
+
// is a well-defined deterministic digest. Match that behavior: an
|
|
43
|
+
// absent slot means "no agent-side producers ran", which produces
|
|
44
|
+
// a hash over null inputs. Producer modules populating the slot
|
|
45
|
+
// change the hash; their absence is itself a stable input.
|
|
46
|
+
const inputs = slot ?? {
|
|
47
|
+
msgSchema: null,
|
|
48
|
+
stateSchema: null,
|
|
49
|
+
msgAnnotations: null,
|
|
50
|
+
};
|
|
51
|
+
const hash = computeSchemaHash({
|
|
52
|
+
msgSchema: inputs.msgSchema,
|
|
53
|
+
stateSchema: inputs.stateSchema,
|
|
54
|
+
msgAnnotations: inputs.msgAnnotations,
|
|
55
|
+
});
|
|
56
|
+
// Emit per-component-call so the bridge can splice the same hash
|
|
57
|
+
// into every `component()` call's config-arg. File-global emission
|
|
58
|
+
// would also work (every component in a file shares the same
|
|
59
|
+
// hash), but per-target matches the per-call splice the monolith
|
|
60
|
+
// performed via injectSchemaHash and avoids changing the bridge's
|
|
61
|
+
// existing field-distribution semantics for this migration.
|
|
62
|
+
return findComponentCalls(ctx.sourceFile).map((call) => ({
|
|
63
|
+
module: 'schema-hash',
|
|
64
|
+
field: '__schemaHash',
|
|
65
|
+
value: ts.factory.createStringLiteral(hash),
|
|
66
|
+
target: call,
|
|
67
|
+
}));
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=schema-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-hash.js","sourceRoot":"","sources":["../../src/modules/schema-hash.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,0EAA0E;AAC1E,kEAAkE;AAClE,wEAAwE;AACxE,mEAAmE;AACnE,sEAAsE;AACtE,uBAAuB;AACvB,EAAE;AACF,yDAAyD;AACzD,mDAAmD;AACnD,uDAAuD;AACvD,sDAAsD;AACtD,EAAE;AACF,iEAAiE;AACjE,oEAAoE;AACpE,mEAAmE;AACnE,oEAAoE;AACpE,iDAAiD;AACjD,EAAE;AACF,mEAAmE;AACnE,oEAAoE;AACpE,wEAAwE;AACxE,kEAAkE;AAClE,8CAA8C;AAE9C,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAajD,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAA;AAE3D,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,IAAI,EAAE,aAAa;IACnB,eAAe,EAAE,QAAQ;IACzB,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;IAEf,iEAAiE;IACjE,kEAAkE;IAClE,QAAQ,EAAE,EAAE;IAEZ,IAAI,CAAC,GAAG,EAAE,QAAQ;QAChB,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAiC,CAAA;QAC5F,8DAA8D;QAC9D,mEAAmE;QACnE,kEAAkE;QAClE,kEAAkE;QAClE,gEAAgE;QAChE,2DAA2D;QAC3D,MAAM,MAAM,GAAqB,IAAI,IAAI;YACvC,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI;SACrB,CAAA;QACD,MAAM,IAAI,GAAG,iBAAiB,CAAC;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC,CAAC,CAAA;QACF,iEAAiE;QACjE,mEAAmE;QACnE,6DAA6D;QAC7D,iEAAiE;QACjE,kEAAkE;QAClE,4DAA4D;QAC5D,OAAO,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACvD,MAAM,EAAE,aAAa;YACrB,KAAK,EAAE,cAAc;YACrB,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC3C,MAAM,EAAE,IAAI;SACb,CAAC,CAAC,CAAA;IACL,CAAC;CACF,CAAA","sourcesContent":["// `schema-hash` — CompilerModule wrapper around `computeSchemaHash`.\n//\n// Per `MODULE-MAPPING.md`, this is an **agent** concern: the hash signals\n// schema drift across HMR cycles, and only matters when the agent\n// runtime cares about Msg/State schema stability. When the agent module\n// is disabled, this module is excluded from the registry — bundles\n// don't carry `__schemaHash` and the HMR re-send heuristic falls back\n// to \"always re-send\".\n//\n// The module reads its inputs from sibling-module slots:\n// - `msg-schema`'s slot for the MsgSchema object\n// - `state-schema`'s slot for the StateSchema object\n// - `msg-annotations`'s slot for the annotation map\n//\n// Today none of those sibling modules exist yet — the monolith's\n// `transform.ts` still owns the schema extraction. So this module's\n// `emit` falls back to \"no contribution\" when the slots are empty.\n// The agent-pipeline decomposition push fills the sibling slots and\n// flips this module from no-op to authoritative.\n//\n// Test fixture: `test/poc-module-schema-hash.test.ts` constructs a\n// fake AnalysisContext with populated slots and asserts the emitted\n// __schemaHash matches `computeSchemaHash`'s direct output. This proves\n// the registry+module path produces a byte-identical hash without\n// requiring the full sibling-module pipeline.\n\nimport ts from 'typescript'\nimport { computeSchemaHash } from '../schema-hash.js'\nimport type { MessageAnnotations } from '../msg-annotations.js'\nimport type { CompilerModule, EmissionContribution } from '../module.js'\nimport { findComponentCalls } from './_shared.js'\n\n/**\n * Slot shape modules write to populate this module's inputs. Sibling\n * agent modules (msg-schema, state-schema, msg-annotations) write their\n * outputs here under the same conventional slot name.\n */\nexport interface SchemaHashInputs {\n msgSchema: unknown\n stateSchema: unknown\n msgAnnotations: Record<string, MessageAnnotations> | null\n}\n\nexport const SCHEMA_HASH_INPUTS_SLOT = 'schema-hash:inputs'\n\nexport const schemaHashModule: CompilerModule = {\n name: 'schema-hash',\n compilerVersion: '^0.3.0',\n dependsOn: [],\n diagnostics: [],\n\n // No visitor pass — this module is a pure emit consumer. Sibling\n // modules populate the inputs slot during their own visitor pass.\n visitors: {},\n\n emit(ctx, analysis): EmissionContribution[] {\n const slot = analysis.perModule.get(SCHEMA_HASH_INPUTS_SLOT) as SchemaHashInputs | undefined\n // The monolith emits `__schemaHash` unconditionally for every\n // compiled `component()` — `computeSchemaHash({null, null, null})`\n // is a well-defined deterministic digest. Match that behavior: an\n // absent slot means \"no agent-side producers ran\", which produces\n // a hash over null inputs. Producer modules populating the slot\n // change the hash; their absence is itself a stable input.\n const inputs: SchemaHashInputs = slot ?? {\n msgSchema: null,\n stateSchema: null,\n msgAnnotations: null,\n }\n const hash = computeSchemaHash({\n msgSchema: inputs.msgSchema,\n stateSchema: inputs.stateSchema,\n msgAnnotations: inputs.msgAnnotations,\n })\n // Emit per-component-call so the bridge can splice the same hash\n // into every `component()` call's config-arg. File-global emission\n // would also work (every component in a file shares the same\n // hash), but per-target matches the per-call splice the monolith\n // performed via injectSchemaHash and avoids changing the bridge's\n // existing field-distribution semantics for this migration.\n return findComponentCalls(ctx.sourceFile).map((call) => ({\n module: 'schema-hash',\n field: '__schemaHash',\n value: ts.factory.createStringLiteral(hash),\n target: call,\n }))\n },\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spread-in-children.d.ts","sourceRoot":"","sources":["../../src/modules/spread-in-children.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AA+ElD,wBAAgB,sBAAsB,IAAI,cAAc,CAkDvD"}
|