juxscript 1.1.285 → 1.1.288
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../lib/state/pageState.ts"],"names":[],"mappings":"AAeA,cAAM,SAAS;IACX,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,MAAM,CAAsB;IAEpC,MAAM,CAAC,QAAQ,CAAC,WAAW,mKAQhB;;IA2BX,OAAO,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../lib/state/pageState.ts"],"names":[],"mappings":"AAeA,cAAM,SAAS;IACX,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,MAAM,CAAsB;IAEpC,MAAM,CAAC,QAAQ,CAAC,WAAW,mKAQhB;;IA2BX,OAAO,CAAC,qBAAqB;IAsG7B,OAAO,CAAC,SAAS;IA+DjB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,MAAM;IAmBd,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAGlC;AAID,eAAO,MAAM,SAAS,qBAAuB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -81,20 +81,40 @@ class PageState {
|
|
|
81
81
|
comp[setterName](value);
|
|
82
82
|
}
|
|
83
83
|
// Fallback: direct DOM manipulation for known props
|
|
84
|
-
else if (prop === '
|
|
84
|
+
else if (prop === 'value') {
|
|
85
85
|
if (typeof comp.setValue === 'function') {
|
|
86
86
|
comp.setValue(value);
|
|
87
87
|
}
|
|
88
|
-
else
|
|
88
|
+
else {
|
|
89
|
+
const el = this._findElement(comp);
|
|
90
|
+
if (el && 'value' in el) {
|
|
91
|
+
el.value = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (prop === 'content') {
|
|
96
|
+
if (typeof comp.setContent === 'function') {
|
|
89
97
|
comp.setContent(value);
|
|
90
98
|
}
|
|
99
|
+
else {
|
|
100
|
+
// Direct DOM update for elements that don't have setContent
|
|
101
|
+
const el = this._findElement(comp);
|
|
102
|
+
if (el) {
|
|
103
|
+
el.textContent = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
else if (prop === 'innerHTML') {
|
|
93
108
|
if (typeof comp.setInnerHTML === 'function') {
|
|
94
109
|
comp.setInnerHTML(value);
|
|
95
110
|
}
|
|
111
|
+
else {
|
|
112
|
+
const el = this._findElement(comp);
|
|
113
|
+
if (el) {
|
|
114
|
+
el.innerHTML = value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
96
117
|
}
|
|
97
|
-
// Don't call fluent methods as setters — they return `this`
|
|
98
118
|
// Update tracked props
|
|
99
119
|
entry.props[prop] = value;
|
|
100
120
|
// Notify listeners
|
|
@@ -252,7 +272,12 @@ class PageState {
|
|
|
252
272
|
reactionDeps.set(reaction, new Set());
|
|
253
273
|
activeReaction = reaction;
|
|
254
274
|
try {
|
|
255
|
-
fn();
|
|
275
|
+
const result = fn();
|
|
276
|
+
if (result && typeof result.catch === 'function') {
|
|
277
|
+
result.catch((err) => {
|
|
278
|
+
console.error('[pageState] async watch error:', err);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
256
281
|
}
|
|
257
282
|
finally {
|
|
258
283
|
activeReaction = null;
|
package/machinery/autowrap.js
CHANGED
|
@@ -144,16 +144,35 @@ export function autowrap(source, filename = '') {
|
|
|
144
144
|
// Check if the body has multiple independent reactive groups
|
|
145
145
|
const groups = groupBodyStatements(bodyStmts, source);
|
|
146
146
|
if (groups.length > 1) {
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
// Verify no cross-group variable dependencies before splitting
|
|
148
|
+
const allDeclared = [];
|
|
149
|
+
let hasCrossDep = false;
|
|
150
|
+
for (const group of groups) {
|
|
151
|
+
const groupVars = [];
|
|
152
|
+
for (const s of group.stmts) {
|
|
153
|
+
groupVars.push(...getDeclaredVarNames(s));
|
|
154
|
+
}
|
|
155
|
+
// Check if this group uses vars declared in a previous group
|
|
156
|
+
for (const s of group.stmts) {
|
|
157
|
+
if (allDeclared.some(v => usesIdentifier(s, v))) {
|
|
158
|
+
hasCrossDep = true;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (hasCrossDep) break;
|
|
163
|
+
allDeclared.push(...groupVars);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!hasCrossDep) {
|
|
167
|
+
const watchStart = getLineNumber(source, stmt.start);
|
|
168
|
+
const watchEnd = getLineNumber(source, stmt.end);
|
|
169
|
+
needsWatch.push({
|
|
170
|
+
line: watchStart,
|
|
171
|
+
endLine: watchEnd,
|
|
172
|
+
replace: true,
|
|
173
|
+
groups: groups,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
178
|
i++;
|
|
@@ -268,8 +287,11 @@ function groupBodyStatements(bodyStmts, source) {
|
|
|
268
287
|
|
|
269
288
|
while (j < bodyStmts.length) {
|
|
270
289
|
const next = bodyStmts[j];
|
|
271
|
-
|
|
290
|
+
// Also collect any new variable names declared within grouped statements
|
|
291
|
+
if (varNames.some(v => usesIdentifier(next, v)) || !containsPageStateRef(next)) {
|
|
272
292
|
groupStmts.push(next);
|
|
293
|
+
// Track any new variable declarations in the consumed statement
|
|
294
|
+
getDeclaredVarNames(next).forEach(v => varNames.push(v));
|
|
273
295
|
j++;
|
|
274
296
|
} else {
|
|
275
297
|
break;
|