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,5 @@
1
- import type { Tracked } from 'ripple';
2
- import { track, trackSplit, flushSync, effect } from 'ripple';
1
+ import type { Props, Tracked } from 'ripple';
2
+ import { flushSync } from 'ripple';
3
3
 
4
4
  describe('composite > reactivity', () => {
5
5
  it('renders composite components with object state', () => {
@@ -17,7 +17,7 @@ describe('composite > reactivity', () => {
17
17
  component App() {
18
18
  <div>
19
19
  let obj = {
20
- count: track(0),
20
+ count: #ripple.track(0),
21
21
  };
22
22
 
23
23
  <span class="count">{obj.@count}</span>
@@ -55,7 +55,7 @@ describe('composite > reactivity', () => {
55
55
  component App() {
56
56
  <div>
57
57
  let obj = {
58
- count: track(0),
58
+ count: #ripple.track(0),
59
59
  };
60
60
 
61
61
  <span class="count">{obj.@count}</span>
@@ -84,7 +84,7 @@ describe('composite > reactivity', () => {
84
84
 
85
85
  it('parents and children have isolated state', () => {
86
86
  component Button(props: { count: number }) {
87
- let count = track(() => props.count);
87
+ let count = #ripple.track(() => props.count);
88
88
  <button
89
89
  onClick={() => {
90
90
  @count++;
@@ -96,7 +96,7 @@ describe('composite > reactivity', () => {
96
96
 
97
97
  component App() {
98
98
  <div>
99
- let count = track(0);
99
+ let count = #ripple.track(0);
100
100
 
101
101
  <button
102
102
  onClick={() => {
@@ -131,7 +131,7 @@ describe('composite > reactivity', () => {
131
131
 
132
132
  it('parents and children have isolated connected state (destructured props)', () => {
133
133
  component Button({ count }: { count: number }) {
134
- let local_count = track(() => count);
134
+ let local_count = #ripple.track(() => count);
135
135
  <button
136
136
  onClick={() => {
137
137
  @local_count++;
@@ -143,7 +143,7 @@ describe('composite > reactivity', () => {
143
143
 
144
144
  component App() {
145
145
  <div>
146
- let count = track(0);
146
+ let count = #ripple.track(0);
147
147
 
148
148
  <button
149
149
  onClick={() => {
@@ -180,11 +180,11 @@ describe('composite > reactivity', () => {
180
180
  let logs: string[] = [];
181
181
 
182
182
  component App() {
183
- const a = track(1);
184
- const b = track(2);
185
- const c = track(3);
183
+ const a = #ripple.track(1);
184
+ const b = #ripple.track(2);
185
+ const c = #ripple.track(3);
186
186
 
187
- const obj = track(
187
+ const obj = #ripple.track(
188
188
  () => ({
189
189
  @a,
190
190
  @b,
@@ -206,7 +206,7 @@ describe('composite > reactivity', () => {
206
206
  }
207
207
 
208
208
  component Child({ a, b, c }: { a: number; b: number; c: number }) {
209
- effect(() => {
209
+ #ripple.effect(() => {
210
210
  logs.push(`Child effect: ${a}, ${b}, ${c}`);
211
211
  });
212
212
 
@@ -228,21 +228,21 @@ describe('composite > reactivity', () => {
228
228
  });
229
229
 
230
230
  it(
231
- 'keeps reactivity for spread props via intermediate components and usage of trackSplit()',
231
+ 'keeps reactivity for spread props via intermediate components and usage of #ripple.trackSplit()',
232
232
  () => {
233
233
  component App() {
234
- const count = track(0);
234
+ const count = #ripple.track(0);
235
235
  <CounterWrapper {@count} up={() => @count++} down={() => @count--} />
236
236
  }
237
237
 
238
- component CounterWrapper(props) {
238
+ component CounterWrapper(props: Props) {
239
239
  <div>
240
240
  <Counter {...props} />
241
241
  </div>
242
242
  }
243
243
 
244
- component Counter(props) {
245
- const [count, up, down, rest] = trackSplit(props, ['count', 'up', 'down']);
244
+ component Counter(props: Props) {
245
+ const [count, up, down, rest] = #ripple.trackSplit(props, ['count', 'up', 'down']);
246
246
  <button onClick={() => @up()}>{'UP'}</button>
247
247
  <button onClick={() => @down()}>{'DOWN'}</button>
248
248
  <span {...@rest}>{`Counter: ${@count}`}</span>
@@ -270,18 +270,18 @@ describe('composite > reactivity', () => {
270
270
 
271
271
  it('keeps reactivity on elements for element spreads and adds / removes dynamic props', () => {
272
272
  component App() {
273
- const count = track(0);
273
+ const count = #ripple.track(0);
274
274
  <CounterWrapper {@count} up={() => @count++} />
275
275
  }
276
276
 
277
- component CounterWrapper(props) {
278
- const more = #{
279
- double: track(() => props.@count * 2),
280
- another: track(0),
277
+ component CounterWrapper(props: { count: number; up: () => void }) {
278
+ const more: { double: Tracked<number>; another?: number; extra: number } = #ripple{
279
+ double: #ripple.track(() => props.count * 2),
280
+ another: 0,
281
281
  extra: 100,
282
282
  };
283
283
 
284
- effect(() => {
284
+ #ripple.effect(() => {
285
285
  props.count;
286
286
  if (props.count === 1) {
287
287
  delete more.another;
@@ -295,8 +295,14 @@ describe('composite > reactivity', () => {
295
295
  </div>
296
296
  }
297
297
 
298
- component Counter(props) {
299
- const [count, up, rest] = trackSplit(props, ['count', 'up']);
298
+ component Counter(props: {
299
+ count: number;
300
+ up: () => void;
301
+ double: Tracked<number>;
302
+ another?: number;
303
+ extra: number;
304
+ }) {
305
+ const [count, up, rest] = #ripple.trackSplit(props, ['count', 'up']);
300
306
  <div {...@rest}>{`Counter: ${@count} Double: ${props.@double}`}</div>
301
307
  <button onClick={() => @up()}>{'UP'}</button>
302
308
  }
@@ -1,4 +1,4 @@
1
- import { track, flushSync, TrackedArray } from 'ripple';
1
+ import { flushSync, RippleArray, type Component } from 'ripple';
2
2
 
3
3
  describe('composite > render', () => {
4
4
  it('renders composite components', () => {
@@ -7,7 +7,7 @@ describe('composite > render', () => {
7
7
  }
8
8
 
9
9
  component App() {
10
- let count = track(0);
10
+ let count = #ripple.track(0);
11
11
 
12
12
  <button onClick={() => @count++}>{'Increment'}</button>
13
13
  <Button {@count} />
@@ -73,7 +73,7 @@ describe('composite > render', () => {
73
73
 
74
74
  it('handles generics', () => {
75
75
  component ArrayTest() {
76
- let items = new TrackedArray<number>();
76
+ let items = new RippleArray<number>();
77
77
  items.push.apply(items, [1, 2, 3, 4, 5]);
78
78
 
79
79
  <pre>{items ? JSON.stringify(items) : 'Loading...'}</pre>
@@ -83,9 +83,18 @@ describe('composite > render', () => {
83
83
  });
84
84
 
85
85
  it('should not render <undefined> tag when a passed in component is undefined', () => {
86
- component Child({ children, NonExistent, ...props }) {
86
+ component Child({
87
+ children,
88
+ NonExistent,
89
+ ...props
90
+ }: {
91
+ children?: Component;
92
+ NonExistent?: Component;
93
+ [key: string]: any;
94
+ }) {
87
95
  <div {...props}>
88
96
  <children />
97
+ // @ts-expect-error - intentionally testing behavior when a component is undefined
89
98
  <NonExistent />
90
99
  </div>
91
100
  }
@@ -1,10 +1,10 @@
1
- import { flushSync, track } from 'ripple';
1
+ import { flushSync } from 'ripple';
2
2
 
3
3
  describe('computed tracked properties', () => {
4
4
  it('should update a property using assignment', () => {
5
5
  component App() {
6
6
  let obj = {
7
- [0]: track(0),
7
+ [0]: #ripple.track(0),
8
8
  };
9
9
 
10
10
  <div>{obj.@[0]}</div>
@@ -31,7 +31,7 @@ describe('computed tracked properties', () => {
31
31
  it('should update a property using update expressions', () => {
32
32
  component App() {
33
33
  let obj = {
34
- [0]: track(0),
34
+ [0]: #ripple.track(0),
35
35
  };
36
36
 
37
37
  <div>{obj.@[0]}</div>
@@ -1,9 +1,9 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { Context, flushSync } from 'ripple';
2
+ import { flushSync } from 'ripple';
3
3
 
4
4
  describe('context', () => {
5
5
  it('creates a reactive ref with initial value', () => {
6
- const MyContext = new Context<string | null>(null);
6
+ const MyContext = #ripple.context<string | null>(null);
7
7
 
8
8
  component Child() {
9
9
  const value = MyContext.get();
@@ -25,7 +25,7 @@ describe('context', () => {
25
25
  });
26
26
 
27
27
  it('handles context captured inside a computed tracked', () => {
28
- const MyContext = new Context<number | null>(null);
28
+ const MyContext = #ripple.context<number | null>(null);
29
29
 
30
30
  const doubleContext = () => {
31
31
  const value = MyContext.get() as number;
@@ -428,9 +428,9 @@ component Child1() {
428
428
  'handles sibling combinators with dynamic component and :global before scoped elements',
429
429
  () => {
430
430
  const source = `
431
- import { track } from 'ripple';
431
+
432
432
  export component Test({ children }) {
433
- const DynamicComponent = track(() => Child1);
433
+ const DynamicComponent = #ripple.track(() => Child1);
434
434
  <div>
435
435
  <p class="before">{'before'}</p>
436
436
 
@@ -474,9 +474,9 @@ component Child1() {
474
474
  'handles sibling combinators with dynamic element or regular element and :global before scoped elements',
475
475
  () => {
476
476
  const source = `
477
- import { track } from 'ripple';
477
+
478
478
  export component Test({ children, classes }) {
479
- const dynamicElement = track('div');
479
+ const dynamicElement = #ripple.track('div');
480
480
  <div>
481
481
  <p class="before">{'before'}</p>
482
482
  // Use Dynamic Element but it's the same with a regular one
@@ -1,15 +1,14 @@
1
1
  import { compile } from 'ripple/compiler';
2
- import { track } from 'ripple';
3
2
 
4
- describe('#style identifier', () => {
3
+ describe('#ripple.style identifier', () => {
5
4
  describe('basic usage with components', () => {
6
- it('passes scoped class to a child component via #style', () => {
5
+ it('passes scoped class to a child component via #ripple.style', () => {
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 {
@@ -28,14 +27,14 @@ describe('#style identifier', () => {
28
27
  expect(classes.some((cls: string) => cls === 'highlight')).toBe(true);
29
28
  });
30
29
 
31
- it('passes multiple #style classes to a child component', () => {
30
+ it('passes multiple #ripple.style classes to a child component', () => {
32
31
  component Child({ primary, secondary }: { primary: string; secondary: string }) {
33
32
  <div class={primary}>{'primary'}</div>
34
33
  <span class={secondary}>{'secondary'}</span>
35
34
  }
36
35
 
37
36
  component Parent() {
38
- <Child primary={#style.primary} secondary={#style.secondary} />
37
+ <Child primary={#ripple.style.primary} secondary={#ripple.style.secondary} />
39
38
 
40
39
  <style>
41
40
  .primary {
@@ -64,15 +63,15 @@ describe('#style identifier', () => {
64
63
  expect(spanClasses.some((cls: string) => cls === 'secondary')).toBe(true);
65
64
  });
66
65
 
67
- it('passes scoped class to a dynamic child component via #style', () => {
66
+ it('passes scoped class to a dynamic child component via #ripple.style', () => {
68
67
  component Child({ cls }: { cls: string }) {
69
68
  <span class={cls}>{'text'}</span>
70
69
  }
71
70
 
72
71
  component Parent() {
73
- let dynamic = track(() => Child);
72
+ let dynamic = #ripple.track(() => Child);
74
73
  <div class="wrapper">
75
- <@dynamic cls={#style.text} />
74
+ <@dynamic cls={#ripple.style.text} />
76
75
  </div>
77
76
 
78
77
  <style>
@@ -91,7 +90,7 @@ describe('#style identifier', () => {
91
90
  expect(classes.some((cls: string) => cls === 'text')).toBe(true);
92
91
  });
93
92
 
94
- it('child can combine its own classes with parent #style class', () => {
93
+ it('child can combine its own classes with parent #ripple.style class', () => {
95
94
  component Card({ className }: { className?: string }) {
96
95
  <div class={['card-base', className ?? '']}>{'card content'}</div>
97
96
 
@@ -103,7 +102,7 @@ describe('#style identifier', () => {
103
102
  }
104
103
 
105
104
  component App() {
106
- <Card className={#style.themed} />
105
+ <Card className={#ripple.style.themed} />
107
106
 
108
107
  <style>
109
108
  .themed {
@@ -128,7 +127,7 @@ describe('#style identifier', () => {
128
127
 
129
128
  component App() {
130
129
  <div class="parent">
131
- <Child cls={#style.dual} />
130
+ <Child cls={#ripple.style.dual} />
132
131
  </div>
133
132
 
134
133
  <style>
@@ -152,10 +151,10 @@ describe('#style identifier', () => {
152
151
  });
153
152
 
154
153
  describe('compile errors', () => {
155
- it('errors when #style is used directly on a DOM element', () => {
154
+ it('errors when #ripple.style is used directly on a DOM element', () => {
156
155
  const source = `
157
156
  component App() {
158
- <div class={#style.box}>{'content'}</div>
157
+ <div class={#ripple.style.box}>{'content'}</div>
159
158
 
160
159
  <style>
161
160
  .box {
@@ -168,10 +167,10 @@ component App() {
168
167
  );
169
168
  });
170
169
 
171
- it('errors when #style bracket notation is used directly on a DOM element', () => {
170
+ it('errors when #ripple.style bracket notation is used directly on a DOM element', () => {
172
171
  const source = `
173
172
  component App() {
174
- <div class={#style['container']}>{'content'}</div>
173
+ <div class={#ripple.style['container']}>{'content'}</div>
175
174
 
176
175
  <style>
177
176
  .container {
@@ -184,13 +183,15 @@ component App() {
184
183
  );
185
184
  });
186
185
 
187
- it('errors when #style references a class in a compound selector passed to component', () => {
188
- const source = `
186
+ it(
187
+ 'errors when #ripple.style references a class in a compound selector passed to component',
188
+ () => {
189
+ const source = `
189
190
  component Child({ cls }) {
190
191
  <span class={cls}>{'text'}</span>
191
192
  }
192
193
  component App() {
193
- <Child cls={#style.special} />
194
+ <Child cls={#ripple.style.special} />
194
195
 
195
196
  <style>
196
197
  span.special {
@@ -198,8 +199,11 @@ component App() {
198
199
  }
199
200
  </style>
200
201
  }`;
201
- expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
202
- });
202
+ expect(() => compile(source, 'test.ripple')).toThrow(
203
+ /does not exist as a stand-alone class/,
204
+ );
205
+ },
206
+ );
203
207
 
204
208
  it('errors if descendant class is attempted to be passed in to child component', () => {
205
209
  const source = `
@@ -210,7 +214,7 @@ component App() {
210
214
  component App() {
211
215
  <div class="wrapper">
212
216
  <Child
213
- cls={#style.nested}
217
+ cls={#ripple.style.nested}
214
218
  />
215
219
  </div>
216
220
 
@@ -238,7 +242,7 @@ component App() {
238
242
  <Child
239
243
  // @ts-expect-error - cannot use child combinator class as standalone
240
244
  // @ripple-expect-error - cannot use child combinator class as standalone
241
- cls={#style.child}
245
+ cls={#ripple.style.child}
242
246
  />
243
247
  </div>
244
248
 
@@ -265,7 +269,7 @@ component App() {
265
269
  <Child
266
270
  // @ts-expect-error - cannot use compound class as standalone
267
271
  // @ripple-expect-error - cannot use compound class as standalone
268
- cls={#style.child}
272
+ cls={#ripple.style.child}
269
273
  />
270
274
  </div>
271
275
 
@@ -281,18 +285,17 @@ component App() {
281
285
  expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
282
286
  });
283
287
 
284
- it('errors if descendant #style class is used on a dynamic component', () => {
288
+ it('errors if descendant #ripple.style class is used on a dynamic component', () => {
285
289
  const source = `
286
- import { track } from 'ripple';
287
290
 
288
291
  component Child({ cls }) {
289
292
  <span class={cls}>{'text'}</span>
290
293
  }
291
294
 
292
295
  component App() {
293
- let dynamic = track(() => Child);
296
+ let dynamic = #ripple.track(() => Child);
294
297
  <div class="wrapper">
295
- <@dynamic cls={#style.nested} />
298
+ <@dynamic cls={#ripple.style.nested} />
296
299
  </div>
297
300
 
298
301
  <style>
@@ -307,13 +310,15 @@ component App() {
307
310
  expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
308
311
  });
309
312
 
310
- it('errors when #style references a class that does not exist in the style block', () => {
311
- const source = `
313
+ it(
314
+ 'errors when #ripple.style references a class that does not exist in the style block',
315
+ () => {
316
+ const source = `
312
317
  component Child({ cls }) {
313
318
  <div class={cls}>{'text'}</div>
314
319
  }
315
320
  component App() {
316
- <Child cls={#style.missing} />
321
+ <Child cls={#ripple.style.missing} />
317
322
 
318
323
  <style>
319
324
  .other {
@@ -321,17 +326,20 @@ component App() {
321
326
  }
322
327
  </style>
323
328
  }`;
324
- expect(() => compile(source, 'test.ripple')).toThrow(/does not exist as a stand-alone class/);
325
- });
329
+ expect(() => compile(source, 'test.ripple')).toThrow(
330
+ /does not exist as a stand-alone class/,
331
+ );
332
+ },
333
+ );
326
334
 
327
- it('errors when #style is used with a dynamic expression', () => {
335
+ it('errors when #ripple.style is used with a dynamic expression', () => {
328
336
  const source = `
329
337
  component Child({ cls }) {
330
338
  <div class={cls}>{'text'}</div>
331
339
  }
332
340
  component App() {
333
341
  const key = 'highlight';
334
- <Child cls={#style[key]} />
342
+ <Child cls={#ripple.style[key]} />
335
343
 
336
344
  <style>
337
345
  .highlight {
@@ -344,22 +352,22 @@ component App() {
344
352
  );
345
353
  });
346
354
 
347
- it('errors when #style is used outside of a component', () => {
355
+ it('errors when #ripple.style is used outside of a component', () => {
348
356
  const source = `function notAComponent() {
349
- const cls = #style.foo;
357
+ const cls = #ripple.style.foo;
350
358
  }`;
351
359
  expect(() => compile(source, 'test.ripple')).toThrow(/can only be used within a component/);
352
360
  });
353
361
  });
354
362
 
355
363
  describe('compiler output', () => {
356
- it('generates #style object with standalone classes for client mode', () => {
364
+ it('generates #ripple.style object with standalone classes for client mode', () => {
357
365
  const source = `
358
366
  component Child({ cls }) {
359
367
  <div class={cls}>{'text'}</div>
360
368
  }
361
369
  export component App() {
362
- <Child cls={#style.highlight} />
370
+ <Child cls={#ripple.style.highlight} />
363
371
 
364
372
  <style>
365
373
  .highlight {
@@ -373,13 +381,13 @@ export component App() {
373
381
  expect(js.code).toMatch(/ripple-[a-z0-9]+/);
374
382
  });
375
383
 
376
- it('generates #style object with standalone classes for server mode', () => {
384
+ it('generates #ripple.style object with standalone classes for server mode', () => {
377
385
  const source = `
378
386
  component Child({ cls }) {
379
387
  <div class={cls}>{'text'}</div>
380
388
  }
381
389
  export component App() {
382
- <Child cls={#style.highlight} />
390
+ <Child cls={#ripple.style.highlight} />
383
391
 
384
392
  <style>
385
393
  .highlight {