juxscript 1.1.289 → 1.1.291

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.
@@ -189,16 +189,18 @@ export function autowrap(source, filename = '') {
189
189
 
190
190
  // VariableDeclaration reading pageState — group with subsequent stmts that use declared vars
191
191
  if (stmt.type === 'VariableDeclaration' && containsPageStateRef(stmt)) {
192
- const varNames = getDeclaredVarNames(stmt);
192
+ const varNames = [...getDeclaredVarNames(stmt)];
193
193
  const groupStmts = [stmt];
194
194
  let j = i + 1;
195
195
 
196
196
  // Greedily consume following statements that use any of the declared variable names
197
197
  while (j < ast.body.length) {
198
198
  const next = ast.body[j];
199
- if (isAlreadyWrapped(next) || isSetupStatement(next)) break;
199
+ // Check variable dependency FIRST — if it uses our vars, consume it
200
200
  if (varNames.some(v => usesIdentifier(next, v))) {
201
201
  groupStmts.push(next);
202
+ // Track any new variable declarations in the consumed statement
203
+ getDeclaredVarNames(next).forEach(v => varNames.push(v));
202
204
  j++;
203
205
  } else {
204
206
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juxscript",
3
- "version": "1.1.289",
3
+ "version": "1.1.291",
4
4
  "type": "module",
5
5
  "description": "A JavaScript UX authorship platform",
6
6
  "main": "./dist/lib/index.js",