sinwan-compiler 0.2.9 → 0.2.10
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.
|
@@ -660,6 +660,10 @@ function createBindingDescriptor(expr, exprPath, options) {
|
|
|
660
660
|
}
|
|
661
661
|
const parent = exprPath.parentPath;
|
|
662
662
|
if (parent && parent.isJSXAttribute && parent.isJSXAttribute()) {
|
|
663
|
+
const compInfo = getComponentExpressionInfo(exprPath);
|
|
664
|
+
if (compInfo.isComponent) {
|
|
665
|
+
return wrapExpression(expr);
|
|
666
|
+
}
|
|
663
667
|
const attrName = parent.node.name.name;
|
|
664
668
|
if (attrName === "style") {
|
|
665
669
|
return t.callExpression(t.identifier("_$bindStyle"), [
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/docs/transform.md
CHANGED
|
@@ -90,7 +90,7 @@ Not wrapped:
|
|
|
90
90
|
**User components** (`<Label>`, `<Child title={…} />`):
|
|
91
91
|
|
|
92
92
|
- **Children:** wrap reactive reads the same way as DOM text (`{count.value}`, `{checked.value ? "On" : "Off"}`) so `cc()` parents do not snapshot the value. Use a getter (`() => …`), never `_$bindText`, because the child may render nodes as well as strings. Render-prop functions (`{(v) => …}`) stay untouched.
|
|
93
|
-
- **Props:** wrap a prop if it is known-reactive for that component (built-in registry, local call graph, analyzer metadata). For *unknown* imported components, still wrap **derived reads** (`htmlFor={id.value}`, `disabled={off.value}`) and leave **container pass-through** alone (`checked={checked}`, `user={user}`) so the child receives the signal or store proxy.
|
|
93
|
+
- **Props:** wrap a prop if it is known-reactive for that component (built-in registry, local call graph, analyzer metadata). For *unknown* imported components, still wrap **derived reads** (`htmlFor={id.value}`, `disabled={off.value}`) and leave **container pass-through** alone (`checked={checked}`, `user={user}`) so the child receives the signal or store proxy. With `explicitBindings`, component props stay **getters** (`each={() => …}`), never `_$bindAttr` — `For` / `Show` / `Label` call `resolve(prop)`, which does not unwrap bind descriptors.
|
|
94
94
|
|
|
95
95
|
**Built-in control-flow** components wrap specific props, and they wrap reactive expression children (those children render directly):
|
|
96
96
|
|
|
@@ -141,6 +141,6 @@ transformJSX(code, "src/App.tsx", {
|
|
|
141
141
|
|
|
142
142
|
- **`analyze` / `analyzeMetadata`** — cross-file reactive props. Invalid JSON is ignored (transform still succeeds).
|
|
143
143
|
- **`resolveImport`** — maps `./Child` to an absolute file so imported components can use analyzer metadata. Without it, imported call sites are not wrapped at the parent.
|
|
144
|
-
- **`explicitBindings`** — wrap with `_$bindText` / `_$bindAttr` / `_$bindStyle` / `_$bindClass
|
|
144
|
+
- **`explicitBindings`** — wrap **native** text/attrs with `_$bindText` / `_$bindAttr` / `_$bindStyle` / `_$bindClass`. Component props and component children stay `() => …` so `resolve(prop)` still sees a getter.
|
|
145
145
|
|
|
146
146
|
Returns `{ code, map }` with a source map.
|