ripple 0.2.39 → 0.2.41

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 a TypeScript UI framework for the web",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.39",
6
+ "version": "0.2.41",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -2,6 +2,7 @@ import * as acorn from 'acorn';
2
2
  import { tsPlugin } from 'acorn-typescript';
3
3
  import { parse_style } from './style.js';
4
4
  import { walk } from 'zimmerframe';
5
+ import { regex_newline_characters } from '../../../utils/patterns.js';
5
6
 
6
7
  const parser = acorn.Parser.extend(tsPlugin({ allowSatisfies: true }), RipplePlugin());
7
8
 
@@ -412,7 +413,9 @@ function RipplePlugin(config) {
412
413
  }
413
414
  } else {
414
415
  if (open.name.name === 'style') {
415
- const start = this.start;
416
+ // jsx_parseOpeningElementAt can treat a html element selector as an identifier and read it
417
+ // In that case, need to backtrack to include it in the css content
418
+ const start = this.pos - (this.value?.length ?? 1)
416
419
  const input = this.input.slice(start);
417
420
  const end = input.indexOf('</style>');
418
421
  const content = input.slice(0, end);
@@ -423,7 +426,13 @@ function RipplePlugin(config) {
423
426
  }
424
427
  component.css = parse_style(content);
425
428
 
426
- this.pos = start + end + 1;
429
+ const newLines = content.match(regex_newline_characters)?.length;
430
+ if (newLines) {
431
+ this.curLine += newLines;
432
+ this.lineStart = start + content.lastIndexOf('\n') + 1;
433
+ }
434
+ this.pos = start + content.length + 1;
435
+
427
436
  this.type = tok.jsxTagStart;
428
437
  this.next();
429
438
  if (this.value === '/') {
@@ -431,6 +431,10 @@ const visitors = {
431
431
  },
432
432
 
433
433
  ForOfStatement(node, context) {
434
+ if (!is_inside_component(context)) {
435
+ return context.next();
436
+ }
437
+
434
438
  node.metadata = {
435
439
  has_template: false,
436
440
  };
@@ -12,6 +12,7 @@ export const regex_whitespaces_strict = /[ \t\n\r\f]+/g;
12
12
 
13
13
  export const regex_only_whitespaces = /^[ \t\n\r\f]+$/;
14
14
 
15
+ export const regex_newline_characters = /\n/g;
15
16
  export const regex_not_newline_characters = /[^\n]/g;
16
17
 
17
18
  export const regex_is_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;