ripple 0.2.41 → 0.2.42

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.41",
6
+ "version": "0.2.42",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -413,9 +413,9 @@ function RipplePlugin(config) {
413
413
  }
414
414
  } else {
415
415
  if (open.name.name === 'style') {
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
+ // jsx_parseOpeningElementAt treats ID selectors (ie. #myid) or type selectors (ie. div) as identifier and read it
417
+ // So backtrack to the end of the <style> tag to make sure everything is included
418
+ const start = open.end;
419
419
  const input = this.input.slice(start);
420
420
  const end = input.indexOf('</style>');
421
421
  const content = input.slice(0, end);
@@ -428,7 +428,7 @@ function RipplePlugin(config) {
428
428
 
429
429
  const newLines = content.match(regex_newline_characters)?.length;
430
430
  if (newLines) {
431
- this.curLine += newLines;
431
+ this.curLine = open.loc.end.line + newLines;
432
432
  this.lineStart = start + content.lastIndexOf('\n') + 1;
433
433
  }
434
434
  this.pos = start + content.length + 1;
@@ -199,6 +199,20 @@ const visitors = {
199
199
  );
200
200
  },
201
201
 
202
+ TSTypeAliasDeclaration(_, context) {
203
+ if (!context.state.to_ts) {
204
+ return b.empty;
205
+ }
206
+ context.next();
207
+ },
208
+
209
+ TSInterfaceDeclaration(_, context) {
210
+ if (!context.state.to_ts) {
211
+ return b.empty;
212
+ }
213
+ context.next();
214
+ },
215
+
202
216
  NewExpression(node, context) {
203
217
  const callee = node.callee;
204
218
  const parent = context.path.at(-1);
@@ -1,5 +1,6 @@
1
1
  import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
2
  import { mount, RippleArray } from 'ripple';
3
+ import { parse } from 'ripple/compiler'
3
4
 
4
5
  describe('compiler success tests', () => {
5
6
  let container;
@@ -20,6 +21,30 @@ describe('compiler success tests', () => {
20
21
  container = null;
21
22
  });
22
23
 
24
+
25
+ it('Parses style content correctly', () => {
26
+ const source = `export component App() {
27
+ <div id="myid" class="myclass">{"Hello World"}</div>
28
+
29
+ <style>#style</style>
30
+ }`;
31
+ const style1 = '.myid {color: green }';
32
+ const style2 = '#myid {color: green }';
33
+ const style3 = 'div {color: green }';
34
+
35
+ let input = source.replace('#style', style1);
36
+ let ast = parse(input);
37
+ expect(ast.body[0].declaration.css.source).toEqual(style1);
38
+
39
+ input = source.replace('#style', style2);
40
+ ast = parse(input);
41
+ expect(ast.body[0].declaration.css.source).toEqual(style2);
42
+
43
+ input = source.replace('#style', style3);
44
+ ast = parse(input);
45
+ expect(ast.body[0].declaration.css.source).toEqual(style3);
46
+ });
47
+
23
48
  it('renders without crashing', () => {
24
49
  component App() {
25
50
  let foo;