ripple 0.2.215 → 0.3.0

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.
Files changed (157) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/package.json +16 -7
  3. package/src/compiler/errors.js +1 -1
  4. package/src/compiler/identifier-utils.js +2 -0
  5. package/src/compiler/index.d.ts +2 -6
  6. package/src/compiler/phases/1-parse/index.js +171 -233
  7. package/src/compiler/phases/2-analyze/index.js +216 -16
  8. package/src/compiler/phases/2-analyze/prune.js +2 -2
  9. package/src/compiler/phases/3-transform/client/index.js +326 -94
  10. package/src/compiler/phases/3-transform/segments.js +43 -15
  11. package/src/compiler/phases/3-transform/server/index.js +71 -21
  12. package/src/compiler/scope.js +31 -12
  13. package/src/compiler/source-map-utils.js +4 -6
  14. package/src/compiler/types/acorn.d.ts +11 -0
  15. package/src/compiler/types/estree-jsx.d.ts +11 -0
  16. package/src/compiler/types/estree.d.ts +11 -0
  17. package/src/compiler/types/import.d.ts +32 -18
  18. package/src/compiler/types/index.d.ts +75 -23
  19. package/src/compiler/types/parse.d.ts +7 -10
  20. package/src/compiler/utils.js +48 -0
  21. package/src/runtime/array.js +53 -22
  22. package/src/runtime/date.js +15 -5
  23. package/src/runtime/index-client.js +41 -7
  24. package/src/runtime/index-server.js +7 -7
  25. package/src/runtime/internal/client/bindings.js +2 -2
  26. package/src/runtime/internal/client/blocks.js +40 -1
  27. package/src/runtime/internal/client/context.js +8 -0
  28. package/src/runtime/internal/client/for.js +3 -3
  29. package/src/runtime/internal/client/index.js +32 -5
  30. package/src/runtime/internal/client/render.js +20 -8
  31. package/src/runtime/internal/client/runtime.js +9 -7
  32. package/src/runtime/internal/client/template.js +1 -1
  33. package/src/runtime/internal/client/try.js +15 -22
  34. package/src/runtime/internal/client/utils.js +1 -1
  35. package/src/runtime/internal/server/context.js +8 -0
  36. package/src/runtime/internal/server/index.js +99 -6
  37. package/src/runtime/map.js +7 -7
  38. package/src/runtime/media-query.js +10 -1
  39. package/src/runtime/object.js +6 -6
  40. package/src/runtime/proxy.js +6 -6
  41. package/src/runtime/set.js +11 -11
  42. package/src/runtime/url-search-params.js +13 -2
  43. package/src/runtime/url.js +15 -5
  44. package/src/utils/builders.js +13 -3
  45. package/tests/client/array/array.copy-within.test.ripple +11 -11
  46. package/tests/client/array/array.derived.test.ripple +42 -42
  47. package/tests/client/array/array.iteration.test.ripple +12 -12
  48. package/tests/client/array/array.mutations.test.ripple +25 -25
  49. package/tests/client/array/array.static.test.ripple +103 -106
  50. package/tests/client/array/array.to-methods.test.ripple +8 -8
  51. package/tests/client/async-suspend.test.ripple +94 -0
  52. package/tests/client/basic/basic.attributes.test.ripple +31 -31
  53. package/tests/client/basic/basic.collections.test.ripple +7 -7
  54. package/tests/client/basic/basic.components.test.ripple +48 -10
  55. package/tests/client/basic/basic.errors.test.ripple +111 -30
  56. package/tests/client/basic/basic.events.test.ripple +11 -11
  57. package/tests/client/basic/basic.get-set.test.ripple +18 -18
  58. package/tests/client/basic/basic.reactivity.test.ripple +47 -42
  59. package/tests/client/basic/basic.rendering.test.ripple +7 -7
  60. package/tests/client/basic/basic.utilities.test.ripple +4 -4
  61. package/tests/client/boundaries.test.ripple +7 -7
  62. package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +2 -2
  63. package/tests/client/compiler/compiler.assignments.test.ripple +21 -21
  64. package/tests/client/compiler/compiler.basic.test.ripple +223 -82
  65. package/tests/client/compiler/compiler.tracked-access.test.ripple +8 -9
  66. package/tests/client/composite/composite.dynamic-components.test.ripple +8 -8
  67. package/tests/client/composite/composite.generics.test.ripple +4 -4
  68. package/tests/client/composite/composite.props.test.ripple +9 -9
  69. package/tests/client/composite/composite.reactivity.test.ripple +32 -26
  70. package/tests/client/composite/composite.render.test.ripple +13 -4
  71. package/tests/client/computed-properties.test.ripple +3 -3
  72. package/tests/client/context.test.ripple +3 -3
  73. package/tests/client/css/global-additional-cases.test.ripple +4 -4
  74. package/tests/client/css/style-identifier.test.ripple +49 -41
  75. package/tests/client/date.test.ripple +40 -40
  76. package/tests/client/dynamic-elements.test.ripple +165 -30
  77. package/tests/client/events.test.ripple +25 -25
  78. package/tests/client/for.test.ripple +76 -8
  79. package/tests/client/function-overload.test.ripple +0 -1
  80. package/tests/client/head.test.ripple +7 -7
  81. package/tests/client/html.test.ripple +2 -2
  82. package/tests/client/input-value.test.ripple +174 -176
  83. package/tests/client/map.test.ripple +21 -21
  84. package/tests/client/media-query.test.ripple +4 -4
  85. package/tests/client/object.test.ripple +12 -12
  86. package/tests/client/portal.test.ripple +4 -4
  87. package/tests/client/ref.test.ripple +5 -5
  88. package/tests/client/return.test.ripple +17 -17
  89. package/tests/client/set.test.ripple +16 -16
  90. package/tests/client/svg.test.ripple +6 -7
  91. package/tests/client/switch.test.ripple +10 -10
  92. package/tests/client/tracked-expression.test.ripple +1 -3
  93. package/tests/client/try.test.ripple +56 -4
  94. package/tests/client/url/url.derived.test.ripple +10 -9
  95. package/tests/client/url/url.parsing.test.ripple +10 -10
  96. package/tests/client/url/url.partial-removal.test.ripple +10 -10
  97. package/tests/client/url/url.reactivity.test.ripple +17 -17
  98. package/tests/client/url/url.serialization.test.ripple +4 -4
  99. package/tests/client/url-search-params/url-search-params.derived.test.ripple +11 -10
  100. package/tests/client/url-search-params/url-search-params.initialization.test.ripple +5 -7
  101. package/tests/client/url-search-params/url-search-params.iteration.test.ripple +13 -13
  102. package/tests/client/url-search-params/url-search-params.mutation.test.ripple +19 -19
  103. package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +17 -17
  104. package/tests/client/url-search-params/url-search-params.serialization.test.ripple +5 -5
  105. package/tests/client/url-search-params/url-search-params.tracked-url.test.ripple +5 -5
  106. package/tests/hydration/compiled/client/events.js +8 -11
  107. package/tests/hydration/compiled/client/for.js +20 -23
  108. package/tests/hydration/compiled/client/head.js +17 -19
  109. package/tests/hydration/compiled/client/hmr.js +84 -0
  110. package/tests/hydration/compiled/client/html.js +1 -15
  111. package/tests/hydration/compiled/client/if-children.js +7 -9
  112. package/tests/hydration/compiled/client/if.js +5 -7
  113. package/tests/hydration/compiled/client/mixed-control-flow.js +3 -5
  114. package/tests/hydration/compiled/client/portal.js +1 -1
  115. package/tests/hydration/compiled/client/reactivity.js +9 -11
  116. package/tests/hydration/compiled/client/return.js +11 -13
  117. package/tests/hydration/compiled/client/switch.js +4 -6
  118. package/tests/hydration/compiled/server/basic.js +0 -1
  119. package/tests/hydration/compiled/server/composite.js +0 -3
  120. package/tests/hydration/compiled/server/events.js +8 -12
  121. package/tests/hydration/compiled/server/for.js +20 -23
  122. package/tests/hydration/compiled/server/head.js +17 -19
  123. package/tests/hydration/compiled/server/hmr.js +107 -0
  124. package/tests/hydration/compiled/server/html.js +1 -35
  125. package/tests/hydration/compiled/server/if-children.js +7 -11
  126. package/tests/hydration/compiled/server/if.js +5 -7
  127. package/tests/hydration/compiled/server/mixed-control-flow.js +3 -5
  128. package/tests/hydration/compiled/server/portal.js +1 -9
  129. package/tests/hydration/compiled/server/reactivity.js +9 -11
  130. package/tests/hydration/compiled/server/return.js +11 -13
  131. package/tests/hydration/compiled/server/switch.js +4 -6
  132. package/tests/hydration/components/events.ripple +8 -9
  133. package/tests/hydration/components/for.ripple +20 -21
  134. package/tests/hydration/components/head.ripple +6 -8
  135. package/tests/hydration/components/hmr.ripple +34 -0
  136. package/tests/hydration/components/html.ripple +1 -3
  137. package/tests/hydration/components/if-children.ripple +7 -8
  138. package/tests/hydration/components/if.ripple +5 -6
  139. package/tests/hydration/components/mixed-control-flow.ripple +4 -6
  140. package/tests/hydration/components/portal.ripple +1 -1
  141. package/tests/hydration/components/reactivity.ripple +9 -10
  142. package/tests/hydration/components/return.ripple +11 -12
  143. package/tests/hydration/components/switch.ripple +6 -8
  144. package/tests/hydration/hmr.test.js +74 -0
  145. package/tests/server/await.test.ripple +2 -2
  146. package/tests/server/basic.attributes.test.ripple +19 -21
  147. package/tests/server/basic.components.test.ripple +13 -7
  148. package/tests/server/basic.test.ripple +20 -21
  149. package/tests/server/compiler.test.ripple +5 -5
  150. package/tests/server/composite.props.test.ripple +6 -7
  151. package/tests/server/composite.test.ripple +4 -4
  152. package/tests/server/context.test.ripple +1 -3
  153. package/tests/server/dynamic-elements.test.ripple +24 -24
  154. package/tests/server/head.test.ripple +5 -7
  155. package/tests/server/style-identifier.test.ripple +16 -17
  156. package/types/index.d.ts +266 -62
  157. package/types/server.d.ts +6 -6
@@ -1,5 +1,4 @@
1
1
  import type { Tracked, PropsNoChildren } from 'ripple';
2
- import { track } from 'ripple';
3
2
 
4
3
  describe('basic client', () => {
5
4
  it('render static text', async () => {
@@ -15,7 +14,7 @@ describe('basic client', () => {
15
14
 
16
15
  it('renders tracked state updates', async () => {
17
16
  component Counter() {
18
- const count = track(0);
17
+ const count = #ripple.track(0);
19
18
 
20
19
  @count++;
21
20
  @count = @count + 5;
@@ -38,8 +37,8 @@ describe('basic client', () => {
38
37
  }
39
38
 
40
39
  component Parent() {
41
- const count = track(10);
42
- let Dynamic = track(() => Child);
40
+ const count = #ripple.track(10);
41
+ let Dynamic = #ripple.track(() => Child);
43
42
 
44
43
  <@Dynamic {count} class={{ test: true }} />
45
44
  }
@@ -51,7 +50,7 @@ describe('basic client', () => {
51
50
 
52
51
  it('renders tracked object properties', async () => {
53
52
  component ObjCounter() {
54
- const obj = { count: track(2) };
53
+ const obj = { count: #ripple.track(2) };
55
54
 
56
55
  obj.@count += 3;
57
56
  obj.@count = obj.@count + 1;
@@ -66,9 +65,9 @@ describe('basic client', () => {
66
65
 
67
66
  it('renders spread props with tracked values', async () => {
68
67
  component SpreadProps() {
69
- const id = track('unique-id');
70
- const isActive = track(true);
71
- const styles = track({ color: 'red', fontSize: '16px' });
68
+ const id = #ripple.track('unique-id');
69
+ const isActive = #ripple.track(true);
70
+ const styles = #ripple.track({ color: 'red', fontSize: '16px' });
72
71
 
73
72
  <div {...{ id: @id, class: { active: @isActive }, style: @styles }}>{'Spread Props'}</div>
74
73
  }
@@ -82,8 +81,8 @@ describe('basic client', () => {
82
81
 
83
82
  it('handles AssignExpressions with tracked values or properties correctly', async () => {
84
83
  component Assignments() {
85
- const count = track(0);
86
- const obj = { value: track(5) };
84
+ const count = #ripple.track(0);
85
+ const obj = { value: #ripple.track(5) };
87
86
 
88
87
  @count += 10;
89
88
  obj.@value *= 2;
@@ -99,9 +98,9 @@ describe('basic client', () => {
99
98
 
100
99
  it(`handles derived changes via tracked dependencies' changes`, async () => {
101
100
  component Derived() {
102
- let base = track(5);
103
- let multiplier = track(3);
104
- const derived = track(() => @base * @multiplier);
101
+ let base = #ripple.track(5);
102
+ let multiplier = #ripple.track(3);
103
+ const derived = #ripple.track(() => @base * @multiplier);
105
104
 
106
105
  <div>{@derived}</div>
107
106
 
@@ -118,10 +117,10 @@ describe('basic client', () => {
118
117
 
119
118
  it(`handles derived changes based on another derived's dependencies' changes`, async () => {
120
119
  component NestedDerived() {
121
- let a = track(2);
122
- let b = track(3);
123
- const sum = track(() => @a + @b);
124
- const product = track(() => @sum * 2);
120
+ let a = #ripple.track(2);
121
+ let b = #ripple.track(3);
122
+ const sum = #ripple.track(() => @a + @b);
123
+ const product = #ripple.track(() => @sum * 2);
125
124
 
126
125
  <div>{@product}</div>
127
126
 
@@ -138,19 +137,19 @@ describe('basic client', () => {
138
137
 
139
138
  it('handles lexical scopes correctly', async () => {
140
139
  component LexicalScopes() {
141
- let x = track(1);
140
+ let x = #ripple.track(1);
142
141
  <div>{@x}</div>
143
142
 
144
143
  <div>
145
- let x = track(10);
144
+ let x = #ripple.track(10);
146
145
  {@x}
147
146
  </div>
148
147
 
149
148
  <div>
150
- let x = track(12);
149
+ let x = #ripple.track(12);
151
150
  {@x}
152
151
  <span>
153
- let x = track(15);
152
+ let x = #ripple.track(15);
154
153
  {@x}
155
154
  </span>
156
155
  </div>
@@ -67,7 +67,7 @@ export component Layout(props) {
67
67
  describe('compiler server block tests', () => {
68
68
  it('compiles server block with with only supported types', () => {
69
69
  const source = `
70
- #server {
70
+ #ripple.server {
71
71
  function something() {
72
72
  return 'unexported function';
73
73
  }
@@ -105,7 +105,7 @@ describe('compiler server block tests', () => {
105
105
 
106
106
  it('throws error for unsupported exported object pattern in server block', () => {
107
107
  const source = `
108
- #server {
108
+ #ripple.server {
109
109
  const obj = { fn1: () => {}, fn2: () => {} };
110
110
 
111
111
  export const { fn1, fn2 } = obj;
@@ -116,7 +116,7 @@ describe('compiler server block tests', () => {
116
116
 
117
117
  it('throws error for unsupported exported array pattern in server block', () => {
118
118
  const source = `
119
- #server {
119
+ #ripple.server {
120
120
  const arr = [() => {}, () => {}];
121
121
 
122
122
  export const [fnarr1, fnarr2] = arr;
@@ -127,7 +127,7 @@ describe('compiler server block tests', () => {
127
127
 
128
128
  it('throws error for unsupported exported member expression via object in server block', () => {
129
129
  const source = `
130
- #server {
130
+ #ripple.server {
131
131
  const obj = { fn1: () => {}, fn2: () => {} };
132
132
 
133
133
  export const objProp = obj.fn1;
@@ -138,7 +138,7 @@ describe('compiler server block tests', () => {
138
138
 
139
139
  it('throws error for unsupported exported member expression via array in server block', () => {
140
140
  const source = `
141
- #server {
141
+ #ripple.server {
142
142
  const arr = [() => {}, () => {}];
143
143
 
144
144
  export const arrIndex0 = arr[0];
@@ -1,5 +1,4 @@
1
1
  import type { Tracked, Props } from 'ripple';
2
- import { track, trackSplit } from 'ripple';
3
2
 
4
3
  describe('composite > props', () => {
5
4
  it('correctly handles default prop values', async () => {
@@ -8,7 +7,7 @@ describe('composite > props', () => {
8
7
  }
9
8
 
10
9
  component App() {
11
- let foo = track(123);
10
+ let foo = #ripple.track(123);
12
11
 
13
12
  <Child />
14
13
  <Child {@foo} />
@@ -46,7 +45,7 @@ describe('composite > props', () => {
46
45
  }
47
46
 
48
47
  component App() {
49
- let foo = track(123);
48
+ let foo = #ripple.track(123);
50
49
 
51
50
  <Child />
52
51
  <Child {foo} />
@@ -65,7 +64,7 @@ describe('composite > props', () => {
65
64
  }
66
65
 
67
66
  component App() {
68
- let foo = track(123);
67
+ let foo = #ripple.track(123);
69
68
 
70
69
  <Child />
71
70
  <Child {@foo} />
@@ -80,7 +79,7 @@ describe('composite > props', () => {
80
79
 
81
80
  it('correctly retains prop accessors and reactivity when using rest props', async () => {
82
81
  component Button(props: Props) {
83
- const [children, rest] = trackSplit(props, ['children']);
82
+ const [children, rest] = #ripple.trackSplit(props, ['children']);
84
83
  <button {...@rest}>
85
84
  <@children />
86
85
  </button>
@@ -95,14 +94,14 @@ describe('composite > props', () => {
95
94
  }
96
95
 
97
96
  component Toggle(props: { pressed: Tracked<boolean> }) {
98
- const [pressed, rest] = trackSplit(props, ['pressed']);
97
+ const [pressed, rest] = #ripple.trackSplit(props, ['pressed']);
99
98
  const onClick = () => (@pressed = !@pressed);
100
99
  <Button {...@rest} class={@pressed ? 'on' : 'off'} {onClick}>{'button 1'}</Button>
101
100
  <Button class={@pressed ? 'on' : 'off'} {onClick}>{'button 2'}</Button>
102
101
  }
103
102
 
104
103
  component App() {
105
- const pressed = track(true);
104
+ const pressed = #ripple.track(true);
106
105
  <Toggle {pressed} />
107
106
  }
108
107
 
@@ -1,4 +1,4 @@
1
- import { TrackedArray, TrackedMap } from 'ripple';
1
+ import { RippleArray, RippleMap } from 'ripple';
2
2
 
3
3
  describe('generics', () => {
4
4
  it('handles advanced generic ambiguity and edge cases', () => {
@@ -143,10 +143,10 @@ describe('generics', () => {
143
143
  const s = flag ? new Box<number>(1) : new Box<string>('string');
144
144
 
145
145
  // 20. Generic inside template expression
146
- const t = `length=${new TrackedArray<number>().length}`;
146
+ const t = `length=${new RippleArray<number>().length}`;
147
147
 
148
148
  // 21. Optional chaining + generic + property access
149
- const registry = new TrackedMap<string, number>();
149
+ const registry = new RippleMap<string, number>();
150
150
  const u = registry.get('id')?.toString();
151
151
 
152
152
  // 22. Generic call used as callee for another call
@@ -208,7 +208,7 @@ describe('generics', () => {
208
208
  >();
209
209
 
210
210
  // 33. Map of generic instance as key
211
- const mm = new Map<TrackedArray<number>, TrackedArray<string>>();
211
+ const mm = new Map<RippleArray<number>, RippleArray<string>>();
212
212
  }
213
213
 
214
214
  render(App);
@@ -1,8 +1,6 @@
1
- import { Context } from 'ripple';
2
-
3
1
  describe('Context API', () => {
4
2
  it('handles context override in nested components', async () => {
5
- const MessageContext = new Context('default');
3
+ const MessageContext = #ripple.context('default');
6
4
 
7
5
  component Inner() {
8
6
  const msg = MessageContext.get();
@@ -1,10 +1,10 @@
1
1
  import type { PropsWithExtras } from 'ripple';
2
- import { track, createRefKey, trackSplit } from 'ripple';
2
+ import { createRefKey } from 'ripple';
3
3
 
4
4
  describe('server dynamic DOM elements', () => {
5
5
  it('renders static dynamic element', async () => {
6
6
  component App() {
7
- let tag = track('div');
7
+ let tag = #ripple.track('div');
8
8
 
9
9
  <@tag>{'Hello World'}</@tag>
10
10
  }
@@ -18,7 +18,7 @@ describe('server dynamic DOM elements', () => {
18
18
  // They can be ignored for now. But we'll fix them via jsx() vs <jsx>
19
19
  it('renders static dynamic element from a plain object with a tracked property', async () => {
20
20
  component App() {
21
- let obj = { tag: track('div') };
21
+ let obj = { tag: #ripple.track('div') };
22
22
 
23
23
  <obj.@tag>{'Hello World'}</obj.@tag>
24
24
  }
@@ -30,7 +30,7 @@ describe('server dynamic DOM elements', () => {
30
30
 
31
31
  it('renders static dynamic element from a tracked object with a tracked property', async () => {
32
32
  component App() {
33
- let obj = track({ tag: track('div') });
33
+ let obj = #ripple.track({ tag: #ripple.track('div') });
34
34
 
35
35
  <@obj.@tag>{'Hello World'}</@obj.@tag>
36
36
  }
@@ -44,7 +44,7 @@ describe('server dynamic DOM elements', () => {
44
44
  'renders static dynamic element from a tracked object with a computed tracked property',
45
45
  async () => {
46
46
  component App() {
47
- let obj = track({ tag: track('div') });
47
+ let obj = #ripple.track({ tag: #ripple.track('div') });
48
48
 
49
49
  <@obj.@['tag']>{'Hello World'}</@obj.@['tag']>
50
50
  }
@@ -57,7 +57,7 @@ describe('server dynamic DOM elements', () => {
57
57
 
58
58
  it('renders self-closing dynamic element', async () => {
59
59
  component App() {
60
- let tag = track('input');
60
+ let tag = #ripple.track('input');
61
61
 
62
62
  <@tag type="text" value="test" />
63
63
  }
@@ -69,8 +69,8 @@ describe('server dynamic DOM elements', () => {
69
69
 
70
70
  it('handles dynamic element with attributes', async () => {
71
71
  component App() {
72
- let tag = track('div');
73
- let className = track('test-class');
72
+ let tag = #ripple.track('div');
73
+ let className = #ripple.track('test-class');
74
74
 
75
75
  <@tag class={@className} id="test" data-testid="dynamic-element">{'Content'}</@tag>
76
76
  }
@@ -87,8 +87,8 @@ describe('server dynamic DOM elements', () => {
87
87
 
88
88
  it('handles nested dynamic elements', async () => {
89
89
  component App() {
90
- let outerTag = track('div');
91
- let innerTag = track('span');
90
+ let outerTag = #ripple.track('div');
91
+ let innerTag = #ripple.track('span');
92
92
 
93
93
  <@outerTag class="outer">
94
94
  <@innerTag class="inner">{'Nested content'}</@innerTag>
@@ -108,8 +108,8 @@ describe('server dynamic DOM elements', () => {
108
108
 
109
109
  it('handles dynamic element with class object', async () => {
110
110
  component App() {
111
- let tag = track('div');
112
- let active = track(true);
111
+ let tag = #ripple.track('div');
112
+ let active = #ripple.track(true);
113
113
 
114
114
  <@tag class={{ active: @active, 'dynamic-element': true }}>
115
115
  {'Element with class object'}
@@ -127,7 +127,7 @@ describe('server dynamic DOM elements', () => {
127
127
 
128
128
  it('handles dynamic element with style object', async () => {
129
129
  component App() {
130
- let tag = track('span');
130
+ let tag = #ripple.track('span');
131
131
 
132
132
  <@tag
133
133
  style={{
@@ -152,7 +152,7 @@ describe('server dynamic DOM elements', () => {
152
152
 
153
153
  it('handles dynamic element with spread attributes', async () => {
154
154
  component App() {
155
- let tag = track('section');
155
+ let tag = #ripple.track('section');
156
156
  const attrs = {
157
157
  id: 'spread-section',
158
158
  'data-testid': 'spread-test',
@@ -176,7 +176,7 @@ describe('server dynamic DOM elements', () => {
176
176
  let capturedElement: HTMLElement | null = null;
177
177
 
178
178
  component App() {
179
- let tag = track('article');
179
+ let tag = #ripple.track('article');
180
180
 
181
181
  <@tag
182
182
  {ref (node: HTMLElement) => {
@@ -202,7 +202,7 @@ describe('server dynamic DOM elements', () => {
202
202
 
203
203
  it('handles dynamic element with createRefKey in spread', async () => {
204
204
  component App() {
205
- let tag = track('header');
205
+ let tag = #ripple.track('header');
206
206
 
207
207
  function elementRef(node: HTMLElement) {
208
208
  // Set an attribute on the element to prove ref was called
@@ -233,7 +233,7 @@ describe('server dynamic DOM elements', () => {
233
233
 
234
234
  it('applies scoped CSS to dynamic elements', async () => {
235
235
  component App() {
236
- let tag = track('div');
236
+ let tag = #ripple.track('div');
237
237
 
238
238
  <@tag class="test-class">{'Dynamic element'}</@tag>
239
239
 
@@ -261,8 +261,8 @@ describe('server dynamic DOM elements', () => {
261
261
  class: string;
262
262
  id: string;
263
263
  }>) {
264
- const tag = track('button');
265
- const [rest] = trackSplit(props, []);
264
+ const tag = #ripple.track('button');
265
+ const [rest] = #ripple.trackSplit(props, []);
266
266
  <@tag {...@rest}>{@rest.class}</@tag>
267
267
 
268
268
  <style>
@@ -276,7 +276,7 @@ describe('server dynamic DOM elements', () => {
276
276
  }
277
277
 
278
278
  component App() {
279
- const count = track(0);
279
+ const count = #ripple.track(0);
280
280
  <DynamicButton class={@count % 2 ? 'even' : 'odd'} id={@count % 2 ? 'even' : 'odd'} />
281
281
  }
282
282
 
@@ -298,7 +298,7 @@ describe('server dynamic DOM elements', () => {
298
298
 
299
299
  it('adds scoping class to dynamic elements', async () => {
300
300
  component App() {
301
- let tag = track('div');
301
+ let tag = #ripple.track('div');
302
302
 
303
303
  <@tag class="scoped">
304
304
  <p>{'Scoped dynamic element'}</p>
@@ -327,7 +327,7 @@ describe('server dynamic DOM elements', () => {
327
327
  // NOTE: We always add the class scoping hash if there is css
328
328
  // but the tag selector will be marked as unused if it's not explicitly seen in the template.
329
329
  component App() {
330
- let tag = track('div');
330
+ let tag = #ripple.track('div');
331
331
 
332
332
  <@tag class="scoped">
333
333
  <p>{'Scoped dynamic element'}</p>
@@ -365,7 +365,7 @@ describe('server dynamic DOM elements', () => {
365
365
  }
366
366
 
367
367
  component App() {
368
- let tag = track('div');
368
+ let tag = #ripple.track('div');
369
369
 
370
370
  <@tag class="scoped">
371
371
  <p>{'Scoped dynamic element'}</p>
@@ -412,7 +412,7 @@ describe('server dynamic DOM elements', () => {
412
412
  }
413
413
 
414
414
  component App() {
415
- let tag = track(() => Child);
415
+ let tag = #ripple.track(() => Child);
416
416
 
417
417
  <@tag />
418
418
 
@@ -1,5 +1,3 @@
1
- import { track } from 'ripple';
2
-
3
1
  describe('head elements', () => {
4
2
  it('renders static title element', async () => {
5
3
  component App() {
@@ -19,7 +17,7 @@ describe('head elements', () => {
19
17
 
20
18
  it('renders reactive title element', async () => {
21
19
  component App() {
22
- let title = track('Initial Title');
20
+ let title = #ripple.track('Initial Title');
23
21
 
24
22
  <head>
25
23
  <title>{@title}</title>
@@ -38,7 +36,7 @@ describe('head elements', () => {
38
36
 
39
37
  it('renders title with template literal', async () => {
40
38
  component App() {
41
- let name = track('World');
39
+ let name = #ripple.track('World');
42
40
 
43
41
  <head>
44
42
  <title>{`Hello ${@name}!`}</title>
@@ -53,7 +51,7 @@ describe('head elements', () => {
53
51
 
54
52
  it('renders title with computed value', async () => {
55
53
  component App() {
56
- let count = track(0);
54
+ let count = #ripple.track(0);
57
55
  let prefix = 'Count: ';
58
56
 
59
57
  <head>
@@ -86,8 +84,8 @@ describe('head elements', () => {
86
84
 
87
85
  it('renders title with conditional content', async () => {
88
86
  component App() {
89
- let showPrefix = track(true);
90
- let title = track('Main Page');
87
+ let showPrefix = #ripple.track(true);
88
+ let title = #ripple.track('Main Page');
91
89
 
92
90
  <head>
93
91
  <title>{@showPrefix ? 'App - ' + @title : @title}</title>
@@ -1,15 +1,14 @@
1
1
  import { compile } from 'ripple/compiler';
2
- import { track } from 'ripple';
3
2
 
4
- describe('#style identifier (server)', () => {
3
+ describe('#ripple.style identifier (server)', () => {
5
4
  describe('basic usage with components', () => {
6
- it('passes scoped class to a child component via #style', async () => {
5
+ it('passes scoped class to a child component via #ripple.style', async () => {
7
6
  component Child({ className }: { className: string }) {
8
7
  <div class={className}>{'styled child'}</div>
9
8
  }
10
9
 
11
10
  component Parent() {
12
- <Child className={#style.highlight} />
11
+ <Child className={#ripple.style.highlight} />
13
12
 
14
13
  <style>
15
14
  .highlight {
@@ -29,14 +28,14 @@ describe('#style identifier (server)', () => {
29
28
  expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
30
29
  });
31
30
 
32
- it('passes multiple #style classes to a child component', async () => {
31
+ it('passes multiple #ripple.style classes to a child component', async () => {
33
32
  component Child({ primary, secondary }: { primary: string; secondary: string }) {
34
33
  <div class={primary}>{'primary'}</div>
35
34
  <span class={secondary}>{'secondary'}</span>
36
35
  }
37
36
 
38
37
  component Parent() {
39
- <Child primary={#style.primary} secondary={#style.secondary} />
38
+ <Child primary={#ripple.style.primary} secondary={#ripple.style.secondary} />
40
39
 
41
40
  <style>
42
41
  .primary {
@@ -68,13 +67,13 @@ describe('#style identifier (server)', () => {
68
67
  });
69
68
 
70
69
  describe('parent styling applied to child', () => {
71
- it('allows parent to style child elements via #style prop', async () => {
70
+ it('allows parent to style child elements via #ripple.style prop', async () => {
72
71
  component Button({ extraClass }: { extraClass?: string }) {
73
72
  <button class={extraClass ?? ''}>{'Click me'}</button>
74
73
  }
75
74
 
76
75
  component App() {
77
- <Button extraClass={#style.fancy} />
76
+ <Button extraClass={#ripple.style.fancy} />
78
77
 
79
78
  <style>
80
79
  .fancy {
@@ -93,7 +92,7 @@ describe('#style identifier (server)', () => {
93
92
  expect(classes.some((cls: string) => cls === 'fancy')).toBe(true);
94
93
  });
95
94
 
96
- it('child can combine its own classes with parent #style class', async () => {
95
+ it('child can combine its own classes with parent #ripple.style class', async () => {
97
96
  component Card({ className }: { className?: string }) {
98
97
  <div class={['card-base', className ?? '']}>{'card content'}</div>
99
98
 
@@ -105,7 +104,7 @@ describe('#style identifier (server)', () => {
105
104
  }
106
105
 
107
106
  component App() {
108
- <Card className={#style.themed} />
107
+ <Card className={#ripple.style.themed} />
109
108
 
110
109
  <style>
111
110
  .themed {
@@ -133,7 +132,7 @@ describe('#style identifier (server)', () => {
133
132
 
134
133
  component App() {
135
134
  <div class="parent">
136
- <Child cls={#style.dual} />
135
+ <Child cls={#ripple.style.dual} />
137
136
  </div>
138
137
 
139
138
  <style>
@@ -158,15 +157,15 @@ describe('#style identifier (server)', () => {
158
157
  );
159
158
  });
160
159
 
161
- it('passes scoped class to a dynamic child component via #style', async () => {
160
+ it('passes scoped class to a dynamic child component via #ripple.style', async () => {
162
161
  component Child({ cls }: { cls: string }) {
163
162
  <span class={cls}>{'text'}</span>
164
163
  }
165
164
 
166
165
  component Parent() {
167
- let dynamic = track(() => Child);
166
+ let dynamic = #ripple.track(() => Child);
168
167
  <div class="wrapper">
169
- <@dynamic cls={#style.text} />
168
+ <@dynamic cls={#ripple.style.text} />
170
169
  </div>
171
170
 
172
171
  <style>
@@ -187,13 +186,13 @@ describe('#style identifier (server)', () => {
187
186
  });
188
187
 
189
188
  describe('server compiler output', () => {
190
- it('generates #style object with standalone classes', () => {
189
+ it('generates #ripple.style object with standalone classes', () => {
191
190
  const source = `
192
191
  component Child({ cls }: { cls: string }) {
193
192
  <div class={cls}>{'text'}</div>
194
193
  }
195
194
  export component App() {
196
- <Child cls={#style.highlight} />
195
+ <Child cls={#ripple.style.highlight} />
197
196
 
198
197
  <style>
199
198
  .highlight {
@@ -214,7 +213,7 @@ export component App() {
214
213
  }
215
214
 
216
215
  component App() {
217
- <Child cls={#style.styled} />
216
+ <Child cls={#ripple.style.styled} />
218
217
 
219
218
  <style>
220
219
  .styled {