ripple 0.3.7 → 0.3.8

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 (100) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +2 -2
  3. package/src/compiler/phases/1-parse/index.js +37 -194
  4. package/src/compiler/phases/2-analyze/index.js +63 -18
  5. package/src/compiler/phases/3-transform/client/index.js +19 -3
  6. package/src/compiler/phases/3-transform/server/index.js +16 -24
  7. package/src/compiler/types/parse.d.ts +0 -8
  8. package/src/runtime/internal/client/composite.js +2 -2
  9. package/tests/client/array/array.copy-within.test.ripple +12 -12
  10. package/tests/client/array/array.derived.test.ripple +46 -46
  11. package/tests/client/array/array.iteration.test.ripple +10 -10
  12. package/tests/client/array/array.mutations.test.ripple +20 -20
  13. package/tests/client/array/array.to-methods.test.ripple +6 -6
  14. package/tests/client/async-suspend.test.ripple +5 -5
  15. package/tests/client/basic/basic.attributes.test.ripple +81 -81
  16. package/tests/client/basic/basic.collections.test.ripple +9 -9
  17. package/tests/client/basic/basic.components.test.ripple +28 -28
  18. package/tests/client/basic/basic.errors.test.ripple +18 -18
  19. package/tests/client/basic/basic.events.test.ripple +37 -37
  20. package/tests/client/basic/basic.get-set.test.ripple +6 -6
  21. package/tests/client/basic/basic.reactivity.test.ripple +68 -68
  22. package/tests/client/basic/basic.rendering.test.ripple +19 -19
  23. package/tests/client/basic/basic.utilities.test.ripple +3 -3
  24. package/tests/client/boundaries.test.ripple +12 -12
  25. package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +5 -5
  26. package/tests/client/compiler/compiler.assignments.test.ripple +19 -19
  27. package/tests/client/compiler/compiler.basic.test.ripple +16 -16
  28. package/tests/client/compiler/compiler.tracked-access.test.ripple +2 -2
  29. package/tests/client/composite/composite.dynamic-components.test.ripple +9 -9
  30. package/tests/client/composite/composite.props.test.ripple +11 -11
  31. package/tests/client/composite/composite.reactivity.test.ripple +43 -43
  32. package/tests/client/composite/composite.render.test.ripple +3 -3
  33. package/tests/client/computed-properties.test.ripple +4 -4
  34. package/tests/client/date.test.ripple +42 -42
  35. package/tests/client/dynamic-elements.test.ripple +42 -42
  36. package/tests/client/events.test.ripple +70 -70
  37. package/tests/client/for.test.ripple +25 -25
  38. package/tests/client/head.test.ripple +19 -19
  39. package/tests/client/html.test.ripple +3 -3
  40. package/tests/client/input-value.test.ripple +84 -84
  41. package/tests/client/lazy-destructuring.test.ripple +71 -16
  42. package/tests/client/map.test.ripple +16 -16
  43. package/tests/client/media-query.test.ripple +7 -7
  44. package/tests/client/portal.test.ripple +11 -11
  45. package/tests/client/ref.test.ripple +4 -4
  46. package/tests/client/return.test.ripple +52 -52
  47. package/tests/client/set.test.ripple +6 -6
  48. package/tests/client/svg.test.ripple +5 -5
  49. package/tests/client/switch.test.ripple +44 -44
  50. package/tests/client/try.test.ripple +5 -5
  51. package/tests/client/url/url.derived.test.ripple +6 -6
  52. package/tests/client/url-search-params/url-search-params.derived.test.ripple +8 -8
  53. package/tests/client/url-search-params/url-search-params.iteration.test.ripple +10 -10
  54. package/tests/client/url-search-params/url-search-params.mutation.test.ripple +10 -10
  55. package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +18 -18
  56. package/tests/client/url-search-params/url-search-params.serialization.test.ripple +2 -2
  57. package/tests/hydration/compiled/client/events.js +25 -25
  58. package/tests/hydration/compiled/client/for.js +70 -66
  59. package/tests/hydration/compiled/client/head.js +25 -25
  60. package/tests/hydration/compiled/client/hmr.js +2 -2
  61. package/tests/hydration/compiled/client/html.js +3 -3
  62. package/tests/hydration/compiled/client/if-children.js +24 -24
  63. package/tests/hydration/compiled/client/if.js +18 -18
  64. package/tests/hydration/compiled/client/mixed-control-flow.js +9 -9
  65. package/tests/hydration/compiled/client/portal.js +3 -3
  66. package/tests/hydration/compiled/client/reactivity.js +16 -16
  67. package/tests/hydration/compiled/client/return.js +40 -40
  68. package/tests/hydration/compiled/client/switch.js +12 -12
  69. package/tests/hydration/compiled/server/events.js +19 -19
  70. package/tests/hydration/compiled/server/for.js +41 -41
  71. package/tests/hydration/compiled/server/head.js +26 -26
  72. package/tests/hydration/compiled/server/hmr.js +2 -2
  73. package/tests/hydration/compiled/server/html.js +2 -2
  74. package/tests/hydration/compiled/server/if-children.js +16 -16
  75. package/tests/hydration/compiled/server/if.js +11 -11
  76. package/tests/hydration/compiled/server/mixed-control-flow.js +6 -6
  77. package/tests/hydration/compiled/server/portal.js +2 -2
  78. package/tests/hydration/compiled/server/reactivity.js +16 -16
  79. package/tests/hydration/compiled/server/return.js +25 -25
  80. package/tests/hydration/compiled/server/switch.js +8 -8
  81. package/tests/hydration/components/events.ripple +25 -25
  82. package/tests/hydration/components/for.ripple +66 -66
  83. package/tests/hydration/components/head.ripple +16 -16
  84. package/tests/hydration/components/hmr.ripple +2 -2
  85. package/tests/hydration/components/html.ripple +3 -3
  86. package/tests/hydration/components/if-children.ripple +24 -24
  87. package/tests/hydration/components/if.ripple +18 -18
  88. package/tests/hydration/components/mixed-control-flow.ripple +9 -9
  89. package/tests/hydration/components/portal.ripple +3 -3
  90. package/tests/hydration/components/reactivity.ripple +16 -16
  91. package/tests/hydration/components/return.ripple +40 -40
  92. package/tests/hydration/components/switch.ripple +20 -20
  93. package/tests/server/await.test.ripple +3 -3
  94. package/tests/server/basic.attributes.test.ripple +34 -34
  95. package/tests/server/basic.components.test.ripple +10 -10
  96. package/tests/server/basic.test.ripple +38 -40
  97. package/tests/server/composite.props.test.ripple +9 -9
  98. package/tests/server/dynamic-elements.test.ripple +13 -12
  99. package/tests/server/head.test.ripple +11 -11
  100. package/tests/server/lazy-destructuring.test.ripple +27 -4
@@ -19,13 +19,13 @@ describe('head elements', () => {
19
19
 
20
20
  it('renders reactive title element', async () => {
21
21
  component App() {
22
- let title = track('Initial Title');
22
+ let &[title] = track('Initial Title');
23
23
 
24
24
  <head>
25
- <title>{@title}</title>
25
+ <title>{title}</title>
26
26
  </head>
27
27
  <div>
28
- <span>{@title}</span>
28
+ <span>{title}</span>
29
29
  </div>
30
30
  }
31
31
 
@@ -38,10 +38,10 @@ describe('head elements', () => {
38
38
 
39
39
  it('renders title with template literal', async () => {
40
40
  component App() {
41
- let name = track('World');
41
+ let &[name] = track('World');
42
42
 
43
43
  <head>
44
- <title>{`Hello ${@name}!`}</title>
44
+ <title>{`Hello ${name}!`}</title>
45
45
  </head>
46
46
  }
47
47
 
@@ -53,14 +53,14 @@ describe('head elements', () => {
53
53
 
54
54
  it('renders title with computed value', async () => {
55
55
  component App() {
56
- let count = track(0);
56
+ let &[count] = track(0);
57
57
  let prefix = 'Count: ';
58
58
 
59
59
  <head>
60
- <title>{prefix + @count}</title>
60
+ <title>{prefix + count}</title>
61
61
  </head>
62
62
  <div>
63
- <span>{@count}</span>
63
+ <span>{count}</span>
64
64
  </div>
65
65
  }
66
66
 
@@ -86,11 +86,11 @@ describe('head elements', () => {
86
86
 
87
87
  it('renders title with conditional content', async () => {
88
88
  component App() {
89
- let showPrefix = track(true);
90
- let title = track('Main Page');
89
+ let &[showPrefix] = track(true);
90
+ let &[title] = track('Main Page');
91
91
 
92
92
  <head>
93
- <title>{@showPrefix ? 'App - ' + @title : @title}</title>
93
+ <title>{showPrefix ? 'App - ' + title : title}</title>
94
94
  </head>
95
95
  }
96
96
 
@@ -117,11 +117,11 @@ describe('lazy destructuring', () => {
117
117
  expect(body).toBeHtml('<pre>Alice-30</pre>');
118
118
  });
119
119
 
120
- it('treats lazy array destructuring of trackSplit as regular array access', async () => {
120
+ it('treats array destructuring of trackSplit as regular array access', async () => {
121
121
  component Test() {
122
122
  const source = { a: 1, b: 2, c: 3 };
123
- const &[a, b, rest] = trackSplit(source, ['a', 'b']);
124
- <pre>{`${@a}-${@b}-${@rest.c}`}</pre>
123
+ const [a, b, rest] = trackSplit(source, ['a', 'b']);
124
+ <pre>{`${a.value}-${b.value}-${rest.value.c}`}</pre>
125
125
  }
126
126
 
127
127
  const { body } = await render(Test);
@@ -132,7 +132,7 @@ describe('lazy destructuring', () => {
132
132
  component Test() {
133
133
  let tracked_value = track(0);
134
134
  let &[value, ...rest] = tracked_value;
135
- <pre>{`${value}-${@rest.length}-${@rest[0] === tracked_value}`}</pre>
135
+ <pre>{`${value}-${rest.length}-${rest[0] === tracked_value}`}</pre>
136
136
  }
137
137
 
138
138
  const { body } = await render(Test);
@@ -149,4 +149,27 @@ describe('lazy destructuring', () => {
149
149
  const { body } = await render(Test);
150
150
  expect(body).toBeHtml('<pre>x-yz</pre>');
151
151
  });
152
+
153
+ it('supports standalone lazy array destructuring with track()', async () => {
154
+ component Test() {
155
+ let count;
156
+ &[count] = track(0);
157
+ <div>{count}</div>
158
+ }
159
+
160
+ const { body } = await render(Test);
161
+ expect(body).toBeHtml('<div>0</div>');
162
+ });
163
+
164
+ it('supports standalone lazy object destructuring', async () => {
165
+ component Test() {
166
+ let a;
167
+ let b;
168
+ &{ a, b } = { a: 10, b: 20 };
169
+ <pre>{`${a}-${b}`}</pre>
170
+ }
171
+
172
+ const { body } = await render(Test);
173
+ expect(body).toBeHtml('<pre>10-20</pre>');
174
+ });
152
175
  });