ripple 0.2.93 → 0.2.94

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.93",
6
+ "version": "0.2.94",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -1458,12 +1458,14 @@ function transform_ts_child(node, context) {
1458
1458
  state.init.push(b.if(visit(node.test), consequent, alternate));
1459
1459
  } else if (node.type === 'ForOfStatement') {
1460
1460
  const body_scope = context.state.scopes.get(node.body);
1461
- const body = b.block(
1462
- transform_body(node.body.body, {
1463
- ...context,
1464
- state: { ...context.state, scope: body_scope },
1465
- }),
1466
- );
1461
+ const block_body = transform_body(node.body.body, {
1462
+ ...context,
1463
+ state: { ...context.state, scope: body_scope },
1464
+ });
1465
+ if (node.index) {
1466
+ block_body.unshift(b.let(visit(node.index), b.literal(0)));
1467
+ }
1468
+ const body = b.block(block_body);
1467
1469
 
1468
1470
  state.init.push(b.for_of(visit(node.left), visit(node.right), body, node.await));
1469
1471
  } else if (node.type === 'TryStatement') {
@@ -22,6 +22,15 @@ export function convert_source_map_to_mappings(ast, source, generated_code) {
22
22
  let sourceIndex = 0;
23
23
  let generatedIndex = 0;
24
24
 
25
+ /**
26
+ * Check if character is a word boundary (not alphanumeric or underscore)
27
+ * @param {string} char
28
+ * @returns {boolean}
29
+ */
30
+ const isWordBoundary = (char) => {
31
+ return char === undefined || !/[a-zA-Z0-9_$]/.test(char);
32
+ };
33
+
25
34
  /**
26
35
  * Find text in source string, searching character by character from sourceIndex
27
36
  * @param {string} text - Text to find
@@ -37,6 +46,16 @@ export function convert_source_map_to_mappings(ast, source, generated_code) {
37
46
  }
38
47
  }
39
48
  if (match) {
49
+ // Check word boundaries for identifier-like tokens
50
+ const isIdentifierLike = /^[a-zA-Z_$]/.test(text);
51
+ if (isIdentifierLike) {
52
+ const charBefore = source[i - 1];
53
+ const charAfter = source[i + text.length];
54
+ if (!isWordBoundary(charBefore) || !isWordBoundary(charAfter)) {
55
+ continue; // Not a whole word match, keep searching
56
+ }
57
+ }
58
+
40
59
  sourceIndex = i + text.length;
41
60
  return i;
42
61
  }
@@ -59,6 +78,16 @@ export function convert_source_map_to_mappings(ast, source, generated_code) {
59
78
  }
60
79
  }
61
80
  if (match) {
81
+ // Check word boundaries for identifier-like tokens
82
+ const isIdentifierLike = /^[a-zA-Z_$]/.test(text);
83
+ if (isIdentifierLike) {
84
+ const charBefore = generated_code[i - 1];
85
+ const charAfter = generated_code[i + text.length];
86
+ if (!isWordBoundary(charBefore) || !isWordBoundary(charAfter)) {
87
+ continue; // Not a whole word match, keep searching
88
+ }
89
+ }
90
+
62
91
  generatedIndex = i + text.length;
63
92
  return i;
64
93
  }
@@ -204,13 +233,17 @@ export function convert_source_map_to_mappings(ast, source, generated_code) {
204
233
  }
205
234
  return;
206
235
  } else if (node.type === 'ForOfStatement' || node.type === 'ForInStatement') {
207
- // Visit in source order: left, right, body
236
+ // Visit in source order: left, right, index (Ripple-specific), body
208
237
  if (node.left) {
209
238
  visit(node.left);
210
239
  }
211
240
  if (node.right) {
212
241
  visit(node.right);
213
242
  }
243
+ // Ripple-specific: index variable
244
+ if (node.index) {
245
+ visit(node.index);
246
+ }
214
247
  if (node.body) {
215
248
  visit(node.body);
216
249
  }