ripple 0.2.64 → 0.2.66

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.64",
6
+ "version": "0.2.66",
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
  }
@@ -259,11 +259,12 @@ const visitors = {
259
259
  context.state.metadata.tracking = true;
260
260
  }
261
261
 
262
- if (!is_inside_component(context, true) || is_inside_call_expression(context)) {
263
- return context.next();
264
- }
265
-
266
- if (is_value_static(node)) {
262
+ if (
263
+ context.state.to_ts ||
264
+ !is_inside_component(context, true) ||
265
+ is_inside_call_expression(context) ||
266
+ is_value_static(node)
267
+ ) {
267
268
  return context.next();
268
269
  }
269
270
 
@@ -628,7 +629,7 @@ const visitors = {
628
629
  } else if (node.metadata.scoped && state.component.css) {
629
630
  const value = state.component.css.hash;
630
631
 
631
- handle_static_attr('class', value);
632
+ handle_static_attr(is_spreading ? '#class' : 'class', value);
632
633
  }
633
634
 
634
635
  state.template.push('>');
@@ -1472,6 +1473,7 @@ function transform_children(children, context) {
1472
1473
  node.type === 'FunctionDeclaration' ||
1473
1474
  node.type === 'DebuggerStatement' ||
1474
1475
  node.type === 'ClassDeclaration' ||
1476
+ node.type === 'TSTypeAliasDeclaration' ||
1475
1477
  node.type === 'Component'
1476
1478
  ) {
1477
1479
  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);
@@ -2,6 +2,11 @@ import { TEMPLATE_FRAGMENT, TEMPLATE_USE_IMPORT_NODE } from '../../../constants.
2
2
  import { first_child, is_firefox } from './operations.js';
3
3
  import { active_block } from './runtime.js';
4
4
 
5
+ /**
6
+ * Assigns start and end nodes to the active block's state.
7
+ * @param {Node} start - The start node.
8
+ * @param {Node} end - The end node.
9
+ */
5
10
  export function assign_nodes(start, end) {
6
11
  var block = /** @type {Effect} */ (active_block);
7
12
  if (block.s === null) {
@@ -12,12 +17,23 @@ export function assign_nodes(start, end) {
12
17
  }
13
18
  }
14
19
 
20
+ /**
21
+ * Creates a DocumentFragment from an HTML string.
22
+ * @param {string} html - The HTML string.
23
+ * @returns {DocumentFragment}
24
+ */
15
25
  function create_fragment_from_html(html) {
16
26
  var elem = document.createElement('template');
17
27
  elem.innerHTML = html;
18
28
  return elem.content;
19
29
  }
20
30
 
31
+ /**
32
+ * Creates a template node or fragment from content and flags.
33
+ * @param {string} content - The template content.
34
+ * @param {number} flags - Flags for template type.
35
+ * @returns {Node}
36
+ */
21
37
  export function template(content, flags) {
22
38
  var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;
23
39
  var use_import_node = (flags & TEMPLATE_USE_IMPORT_NODE) !== 0;
@@ -46,6 +62,11 @@ export function template(content, flags) {
46
62
  };
47
63
  }
48
64
 
65
+ /**
66
+ * Appends a DOM node before the anchor node.
67
+ * @param {Node} anchor - The anchor node.
68
+ * @param {Node} dom - The DOM node to append.
69
+ */
49
70
  export function append(anchor, dom) {
50
71
  anchor.before(/** @type {Node} */ (dom));
51
72
  }
@@ -24,6 +24,11 @@ export function is_positive_integer(value) {
24
24
  return Number.isInteger(value) && /**@type {number} */ (value) >= 0;
25
25
  }
26
26
 
27
+ /**
28
+ * Checks if an object is a tracked object (has a numeric 'f' property).
29
+ * @param {object} v - The object to check.
30
+ * @returns {boolean}
31
+ */
27
32
  export function is_tracked_object(v) {
28
33
  return typeof v === 'object' && v !== null && typeof v.f === 'number';
29
34
  }
@@ -34,6 +34,11 @@ export function is_delegated(event_name) {
34
34
  return DELEGATED_EVENTS.includes(event_name);
35
35
  }
36
36
 
37
+ /**
38
+ * Determines if an attribute is an event attribute (e.g., 'onClick').
39
+ * @param {string} attr - The attribute name.
40
+ * @returns {boolean}
41
+ */
37
42
  export function is_event_attribute(attr) {
38
43
  return attr.startsWith('on') && attr.length > 2 && attr[2] === attr[2].toUpperCase();
39
44
  }
@@ -62,6 +67,11 @@ export function get_attribute_event_name(event_name) {
62
67
 
63
68
  const PASSIVE_EVENTS = ['touchstart', 'touchmove'];
64
69
 
70
+ /**
71
+ * Checks if an event is passive (e.g., 'touchstart', 'touchmove').
72
+ * @param {string} name - The event name.
73
+ * @returns {boolean}
74
+ */
65
75
  export function is_passive_event(name) {
66
76
  return PASSIVE_EVENTS.includes(name);
67
77
  }