ripple 0.2.65 → 0.2.67

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.65",
6
+ "version": "0.2.67",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -486,12 +486,6 @@ const visitors = {
486
486
  state.analysis.module.filename,
487
487
  attribute,
488
488
  );
489
- } else {
490
- error(
491
- 'Cannot have a `children` prop on a component, did you mean `$children`?',
492
- state.analysis.module.filename,
493
- attribute,
494
- );
495
489
  }
496
490
  }
497
491
  }
@@ -324,6 +324,13 @@ const visitors = {
324
324
  }
325
325
  },
326
326
 
327
+ PropertyDefinition(node, context) {
328
+ if (!context.state.to_ts) {
329
+ delete node.typeAnnotation;
330
+ }
331
+ return context.next();
332
+ },
333
+
327
334
  VariableDeclaration(node, context) {
328
335
  const declarations = [];
329
336
 
@@ -629,7 +636,7 @@ const visitors = {
629
636
  } else if (node.metadata.scoped && state.component.css) {
630
637
  const value = state.component.css.hash;
631
638
 
632
- handle_static_attr('class', value);
639
+ handle_static_attr(is_spreading ? '#class' : 'class', value);
633
640
  }
634
641
 
635
642
  state.template.push('>');
@@ -1152,7 +1159,9 @@ const visitors = {
1152
1159
  },
1153
1160
 
1154
1161
  TemplateLiteral(node, context) {
1155
- if (node.expressions.length === 0) {
1162
+ const parent = context.path.at(-1);
1163
+
1164
+ if (node.expressions.length === 0 && parent?.type !== 'TaggedTemplateExpression') {
1156
1165
  return b.literal(node.quasis[0].value.cooked);
1157
1166
  }
1158
1167
 
@@ -1473,6 +1482,8 @@ function transform_children(children, context) {
1473
1482
  node.type === 'FunctionDeclaration' ||
1474
1483
  node.type === 'DebuggerStatement' ||
1475
1484
  node.type === 'ClassDeclaration' ||
1485
+ node.type === 'TSTypeAliasDeclaration' ||
1486
+ node.type === 'TSInterfaceDeclaration' ||
1476
1487
  node.type === 'Component'
1477
1488
  ) {
1478
1489
  const metadata = { await: false };
@@ -30,7 +30,7 @@ export function jsxs(
30
30
  * JSX Fragment component
31
31
  * In Ripple, fragments are imperative and don't return anything
32
32
  */
33
- export function Fragment(props: { $children?: any }): void;
33
+ export function Fragment(props: { children?: any }): void;
34
34
 
35
35
  // Base HTML attributes
36
36
  interface HTMLAttributes {
@@ -41,7 +41,7 @@ interface HTMLAttributes {
41
41
  onClick?: (event: MouseEvent) => void;
42
42
  onInput?: (event: InputEvent) => void;
43
43
  onChange?: (event: Event) => void;
44
- $children?: any;
44
+ children?: any;
45
45
  [key: string]: any;
46
46
  }
47
47
 
@@ -88,7 +88,7 @@ declare global {
88
88
  }
89
89
 
90
90
  interface ElementChildrenAttribute {
91
- $children: {};
91
+ children: {};
92
92
  }
93
93
  }
94
94
  }
@@ -7,7 +7,11 @@ import {
7
7
  is_tracked_object,
8
8
  } from './utils.js';
9
9
  import { delegate, event } from './events.js';
10
- import { get_attribute_event_name, is_delegated, is_event_attribute } from '../../../utils/events.js';
10
+ import {
11
+ get_attribute_event_name,
12
+ is_delegated,
13
+ is_event_attribute,
14
+ } from '../../../utils/events.js';
11
15
  import { get } from './runtime.js';
12
16
 
13
17
  export function set_text(text, value) {
@@ -81,6 +85,9 @@ export function set_attributes(element, attributes) {
81
85
 
82
86
  if (key === 'class') {
83
87
  set_class(element, value);
88
+ } else if (key === '#class') {
89
+ // Special case for static class when spreading props
90
+ element.classList.add(value);
84
91
  } else if (is_event_attribute(key)) {
85
92
  // Handle event handlers in spread props
86
93
  const event_name = get_attribute_event_name(key);
@@ -65,7 +65,7 @@ describe('compiler success tests', () => {
65
65
  });
66
66
 
67
67
 
68
- /*it('renders without crashing using < character', () => {
68
+ it('renders without crashing using < character', () => {
69
69
  component App() {
70
70
  function bar() {
71
71
  for (let i = 0; i < 10; i++) {
@@ -80,7 +80,7 @@ describe('compiler success tests', () => {
80
80
  }
81
81
 
82
82
  render(App);
83
- });*/
83
+ });
84
84
 
85
85
  it('render lexical blocks without crashing', () => {
86
86
  component App() {
@@ -240,4 +240,44 @@ describe('compiler success tests', () => {
240
240
 
241
241
  render(App);
242
242
  });
243
+
244
+ it('should not fail with random TS syntax', () => {
245
+ function tagFn() {
246
+ return null;
247
+ }
248
+
249
+ function Wrapper() {
250
+ return {
251
+ unwrap: function<T>() {
252
+ return null as unknown as T;
253
+ }
254
+ }
255
+ }
256
+
257
+ component App() {
258
+ let x: number[] = [] as number[];
259
+
260
+ const n = new Wrapper<number>().unwrap<string>();
261
+
262
+ const tagResult = tagFn`value`;
263
+
264
+ interface Node<T> {
265
+ value: T;
266
+ }
267
+
268
+ class Box<T> {
269
+ value: T;
270
+
271
+ method<T>(): T {
272
+ return this.value;
273
+ }
274
+ }
275
+
276
+ let flag = true;
277
+
278
+ const s = flag ? new Box<number>() : new Box<string>();
279
+ }
280
+
281
+ render(App);
282
+ });
243
283
  });