ripple 0.2.208 → 0.2.210

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 (108) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +2 -1
  3. package/package.json +2 -6
  4. package/shims/rollup-estree-types.d.ts +1 -1
  5. package/src/compiler/index.d.ts +1 -0
  6. package/src/compiler/index.js +7 -1
  7. package/src/compiler/phases/1-parse/index.js +15 -6
  8. package/src/compiler/phases/2-analyze/css-analyze.js +100 -104
  9. package/src/compiler/phases/2-analyze/index.js +215 -2
  10. package/src/compiler/phases/3-transform/client/index.js +388 -50
  11. package/src/compiler/phases/3-transform/segments.js +123 -39
  12. package/src/compiler/phases/3-transform/server/index.js +266 -13
  13. package/src/compiler/types/index.d.ts +16 -3
  14. package/src/compiler/utils.js +1 -15
  15. package/src/constants.js +0 -2
  16. package/src/helpers.d.ts +4 -0
  17. package/src/html-tree-validation.js +211 -0
  18. package/src/jsx-runtime.d.ts +260 -259
  19. package/src/jsx-runtime.js +12 -12
  20. package/src/runtime/array.js +17 -17
  21. package/src/runtime/create-subscriber.js +1 -1
  22. package/src/runtime/index-client.js +1 -5
  23. package/src/runtime/index-server.js +15 -0
  24. package/src/runtime/internal/client/compat.js +3 -3
  25. package/src/runtime/internal/client/composite.js +6 -1
  26. package/src/runtime/internal/client/head.js +50 -4
  27. package/src/runtime/internal/client/html.js +73 -12
  28. package/src/runtime/internal/client/hydration.js +12 -0
  29. package/src/runtime/internal/client/index.js +1 -1
  30. package/src/runtime/internal/client/portal.js +54 -29
  31. package/src/runtime/internal/client/rpc.js +3 -1
  32. package/src/runtime/internal/client/switch.js +5 -0
  33. package/src/runtime/internal/client/template.js +117 -11
  34. package/src/runtime/internal/client/try.js +1 -0
  35. package/src/runtime/internal/server/index.js +113 -1
  36. package/src/runtime/internal/server/rpc.js +4 -4
  37. package/src/runtime/map.js +2 -2
  38. package/src/runtime/object.js +6 -6
  39. package/src/runtime/proxy.js +12 -11
  40. package/src/runtime/reactive-value.js +9 -1
  41. package/src/runtime/set.js +12 -7
  42. package/src/runtime/url-search-params.js +0 -1
  43. package/src/server/index.js +4 -0
  44. package/src/utils/hashing.js +15 -0
  45. package/src/utils/normalize_css_property_name.js +1 -1
  46. package/tests/client/array/array.mutations.test.ripple +8 -8
  47. package/tests/client/basic/basic.errors.test.ripple +28 -0
  48. package/tests/client/basic/basic.events.test.ripple +6 -3
  49. package/tests/client/basic/basic.utilities.test.ripple +1 -1
  50. package/tests/client/compiler/compiler.regex.test.ripple +10 -8
  51. package/tests/client/composite/composite.generics.test.ripple +5 -2
  52. package/tests/client/dynamic-elements.test.ripple +30 -1
  53. package/tests/client/function-overload-import.ripple +6 -7
  54. package/tests/client/html.test.ripple +0 -1
  55. package/tests/client/object.test.ripple +2 -2
  56. package/tests/client/portal.test.ripple +3 -3
  57. package/tests/client/return.test.ripple +2500 -0
  58. package/tests/client/try.test.ripple +69 -0
  59. package/tests/client/typescript-generics.test.ripple +1 -1
  60. package/tests/client/url/url.derived.test.ripple +1 -1
  61. package/tests/client/url/url.parsing.test.ripple +3 -3
  62. package/tests/client/url/url.partial-removal.test.ripple +7 -7
  63. package/tests/client/url/url.reactivity.test.ripple +15 -15
  64. package/tests/client/url/url.serialization.test.ripple +2 -2
  65. package/tests/hydration/basic.test.js +23 -0
  66. package/tests/hydration/build-components.js +10 -4
  67. package/tests/hydration/compiled/client/basic.js +165 -3
  68. package/tests/hydration/compiled/client/for.js +1140 -23
  69. package/tests/hydration/compiled/client/head.js +234 -0
  70. package/tests/hydration/compiled/client/html.js +135 -0
  71. package/tests/hydration/compiled/client/portal.js +172 -0
  72. package/tests/hydration/compiled/client/reactivity.js +3 -1
  73. package/tests/hydration/compiled/client/return.js +1976 -0
  74. package/tests/hydration/compiled/client/switch.js +162 -0
  75. package/tests/hydration/compiled/server/basic.js +249 -0
  76. package/tests/hydration/compiled/server/events.js +1 -1
  77. package/tests/hydration/compiled/server/for.js +891 -1
  78. package/tests/hydration/compiled/server/head.js +291 -0
  79. package/tests/hydration/compiled/server/html.js +133 -0
  80. package/tests/hydration/compiled/server/if.js +1 -1
  81. package/tests/hydration/compiled/server/portal.js +250 -0
  82. package/tests/hydration/compiled/server/reactivity.js +1 -1
  83. package/tests/hydration/compiled/server/return.js +1969 -0
  84. package/tests/hydration/compiled/server/switch.js +130 -0
  85. package/tests/hydration/components/basic.ripple +55 -0
  86. package/tests/hydration/components/for.ripple +403 -0
  87. package/tests/hydration/components/head.ripple +111 -0
  88. package/tests/hydration/components/html.ripple +38 -0
  89. package/tests/hydration/components/portal.ripple +49 -0
  90. package/tests/hydration/components/return.ripple +564 -0
  91. package/tests/hydration/components/switch.ripple +51 -0
  92. package/tests/hydration/for.test.js +363 -0
  93. package/tests/hydration/head.test.js +105 -0
  94. package/tests/hydration/html.test.js +46 -0
  95. package/tests/hydration/portal.test.js +71 -0
  96. package/tests/hydration/return.test.js +544 -0
  97. package/tests/hydration/switch.test.js +42 -0
  98. package/tests/server/basic.attributes.test.ripple +1 -1
  99. package/tests/server/compiler.test.ripple +22 -0
  100. package/tests/server/composite.test.ripple +5 -2
  101. package/tests/server/html-nesting-validation.test.ripple +237 -0
  102. package/tests/server/return.test.ripple +1379 -0
  103. package/tests/setup-hydration.js +6 -1
  104. package/tests/utils/escaping.test.js +3 -1
  105. package/tests/utils/normalize_css_property_name.test.js +0 -1
  106. package/tests/utils/patterns.test.js +6 -2
  107. package/tests/utils/sanitize_template_string.test.js +3 -2
  108. package/types/server.d.ts +16 -0
@@ -0,0 +1,162 @@
1
+ import * as _$_ from 'ripple/internal/client';
2
+
3
+ var root_1 = _$_.template(`<div class="status-success">Success</div>`, 1);
4
+ var root_2 = _$_.template(`<div class="status-error">Error</div>`, 1);
5
+ var root_3 = _$_.template(`<div class="status-unknown">Unknown</div>`, 0);
6
+ var root = _$_.template(`<!>`, 1);
7
+ var root_5 = _$_.template(`<div class="case-a">Case A</div>`, 1);
8
+ var root_6 = _$_.template(`<div class="case-b">Case B</div>`, 1);
9
+ var root_7 = _$_.template(`<div class="case-c">Case C</div>`, 0);
10
+ var root_4 = _$_.template(`<button class="toggle">Toggle</button><!>`, 1);
11
+ var root_9 = _$_.template(`<div class="case-1-2">1 or 2</div>`, 1);
12
+ var root_10 = _$_.template(`<div class="case-other">Other</div>`, 0);
13
+ var root_8 = _$_.template(`<!>`, 1);
14
+
15
+ import { track } from 'ripple';
16
+
17
+ export function SwitchStatic(__anchor, _, __block) {
18
+ _$_.push_component();
19
+
20
+ const status = 'success';
21
+ var fragment = root();
22
+ var node = _$_.first_child_frag(fragment);
23
+
24
+ {
25
+ var switch_case_0 = (__anchor) => {
26
+ var fragment_1 = root_1();
27
+
28
+ _$_.append(__anchor, fragment_1);
29
+ };
30
+
31
+ var switch_case_1 = (__anchor) => {
32
+ var fragment_2 = root_2();
33
+
34
+ _$_.append(__anchor, fragment_2);
35
+ };
36
+
37
+ var switch_case_default = (__anchor) => {
38
+ var div_1 = root_3();
39
+
40
+ _$_.append(__anchor, div_1);
41
+ };
42
+
43
+ _$_.switch(node, () => {
44
+ var result = [];
45
+
46
+ switch (status) {
47
+ case 'success':
48
+ result.push(switch_case_0);
49
+ return result;
50
+
51
+ case 'error':
52
+ result.push(switch_case_1);
53
+ return result;
54
+
55
+ default:
56
+ result.push(switch_case_default);
57
+ return result;
58
+ }
59
+ });
60
+ }
61
+
62
+ _$_.append(__anchor, fragment);
63
+ _$_.pop_component();
64
+ }
65
+
66
+ export function SwitchReactive(__anchor, _, __block) {
67
+ _$_.push_component();
68
+
69
+ let status = track('a', void 0, void 0, __block);
70
+ var fragment_3 = root_4();
71
+ var button_1 = _$_.first_child_frag(fragment_3);
72
+
73
+ button_1.__click = () => {
74
+ if (_$_.get(status) === 'a') _$_.set(status, 'b'); else if (_$_.get(status) === 'b') _$_.set(status, 'c'); else _$_.set(status, 'a');
75
+ };
76
+
77
+ var node_1 = _$_.sibling(button_1);
78
+
79
+ {
80
+ var switch_case_0_1 = (__anchor) => {
81
+ var fragment_4 = root_5();
82
+
83
+ _$_.append(__anchor, fragment_4);
84
+ };
85
+
86
+ var switch_case_1_1 = (__anchor) => {
87
+ var fragment_5 = root_6();
88
+
89
+ _$_.append(__anchor, fragment_5);
90
+ };
91
+
92
+ var switch_case_default_1 = (__anchor) => {
93
+ var div_2 = root_7();
94
+
95
+ _$_.append(__anchor, div_2);
96
+ };
97
+
98
+ _$_.switch(node_1, () => {
99
+ var result = [];
100
+
101
+ switch (_$_.get(status)) {
102
+ case 'a':
103
+ result.push(switch_case_0_1);
104
+ return result;
105
+
106
+ case 'b':
107
+ result.push(switch_case_1_1);
108
+ return result;
109
+
110
+ default:
111
+ result.push(switch_case_default_1);
112
+ return result;
113
+ }
114
+ });
115
+ }
116
+
117
+ _$_.append(__anchor, fragment_3);
118
+ _$_.pop_component();
119
+ }
120
+
121
+ export function SwitchFallthrough(__anchor, _, __block) {
122
+ _$_.push_component();
123
+
124
+ const val = 1;
125
+ var fragment_6 = root_8();
126
+ var node_2 = _$_.first_child_frag(fragment_6);
127
+
128
+ {
129
+ var switch_case_0_2 = (__anchor) => {
130
+ var fragment_7 = root_9();
131
+
132
+ _$_.append(__anchor, fragment_7);
133
+ };
134
+
135
+ var switch_case_default_2 = (__anchor) => {
136
+ var div_3 = root_10();
137
+
138
+ _$_.append(__anchor, div_3);
139
+ };
140
+
141
+ _$_.switch(node_2, () => {
142
+ var result = [];
143
+
144
+ switch (val) {
145
+ case 1:
146
+
147
+ case 2:
148
+ result.push(switch_case_0_2);
149
+ return result;
150
+
151
+ default:
152
+ result.push(switch_case_default_2);
153
+ return result;
154
+ }
155
+ });
156
+ }
157
+
158
+ _$_.append(__anchor, fragment_6);
159
+ _$_.pop_component();
160
+ }
161
+
162
+ _$_.delegate(['click']);
@@ -220,5 +220,254 @@ export function ExpressionContent(__output) {
220
220
  }
221
221
 
222
222
  __output.push('</span>');
223
+ _$_.pop_component();
224
+ }
225
+
226
+ function StaticHeader(__output) {
227
+ _$_.push_component();
228
+ __output.push('<h1');
229
+ __output.push(' class="sr-only"');
230
+ __output.push('>');
231
+
232
+ {
233
+ __output.push('heading');
234
+ }
235
+
236
+ __output.push('</h1>');
237
+ __output.push('<p');
238
+ __output.push(' class="subtitle"');
239
+ __output.push('>');
240
+
241
+ {
242
+ __output.push('first paragraph');
243
+ }
244
+
245
+ __output.push('</p>');
246
+ __output.push('<p');
247
+ __output.push(' class="subtitle"');
248
+ __output.push('>');
249
+
250
+ {
251
+ __output.push('second paragraph');
252
+ }
253
+
254
+ __output.push('</p>');
255
+ _$_.pop_component();
256
+ }
257
+
258
+ export function StaticChildWithSiblings(__output) {
259
+ _$_.push_component();
260
+
261
+ const foo = 'bar';
262
+
263
+ {
264
+ const comp = StaticHeader;
265
+ const args = [__output, {}];
266
+
267
+ comp(...args);
268
+ }
269
+
270
+ __output.push('<span');
271
+ __output.push(' class="sibling1"');
272
+ __output.push('>');
273
+
274
+ {
275
+ __output.push(_$_.escape(foo));
276
+ }
277
+
278
+ __output.push('</span>');
279
+ __output.push('<span');
280
+ __output.push(' class="sibling2"');
281
+ __output.push('>');
282
+
283
+ {
284
+ __output.push(_$_.escape(foo));
285
+ }
286
+
287
+ __output.push('</span>');
288
+ _$_.pop_component();
289
+ }
290
+
291
+ function Header(__output) {
292
+ _$_.push_component();
293
+ __output.push('<h1');
294
+ __output.push(' class="sr-only"');
295
+ __output.push('>');
296
+
297
+ {
298
+ __output.push('Ripple');
299
+ }
300
+
301
+ __output.push('</h1>');
302
+ __output.push('<img');
303
+ __output.push(' src="/images/logo.png"');
304
+ __output.push(' alt="Logo"');
305
+ __output.push(' class="logo"');
306
+ __output.push(' />');
307
+ __output.push('<p');
308
+ __output.push(' class="subtitle"');
309
+ __output.push('>');
310
+
311
+ {
312
+ __output.push('the elegant TypeScript UI framework');
313
+ }
314
+
315
+ __output.push('</p>');
316
+ _$_.pop_component();
317
+ }
318
+
319
+ function Actions(__output, { playgroundVisible = false }) {
320
+ _$_.push_component();
321
+ __output.push('<div');
322
+ __output.push(' class="social-links"');
323
+ __output.push('>');
324
+
325
+ {
326
+ __output.push('<a');
327
+ __output.push(' href="https://github.com"');
328
+ __output.push(' class="github-link"');
329
+ __output.push('>');
330
+
331
+ {
332
+ __output.push('GitHub');
333
+ }
334
+
335
+ __output.push('</a>');
336
+ __output.push('<a');
337
+ __output.push(' href="https://discord.com"');
338
+ __output.push(' class="discord-link"');
339
+ __output.push('>');
340
+
341
+ {
342
+ __output.push('Discord');
343
+ }
344
+
345
+ __output.push('</a>');
346
+ __output.push('<!--[-->');
347
+
348
+ if (_$_.get(playgroundVisible)) {
349
+ __output.push('<a');
350
+ __output.push(' href="/playground"');
351
+ __output.push(' class="playground-link"');
352
+ __output.push('>');
353
+
354
+ {
355
+ __output.push('Playground');
356
+ }
357
+
358
+ __output.push('</a>');
359
+ }
360
+
361
+ __output.push('<!--]-->');
362
+ }
363
+
364
+ __output.push('</div>');
365
+ _$_.pop_component();
366
+ }
367
+
368
+ async function Layout(__output, { children }) {
369
+ return _$_.async(async () => {
370
+ _$_.push_component();
371
+ __output.push('<main');
372
+ __output.push('>');
373
+
374
+ {
375
+ __output.push('<div');
376
+ __output.push(' class="container"');
377
+ __output.push('>');
378
+
379
+ {
380
+ {
381
+ const comp = children;
382
+ const args = [__output, {}];
383
+
384
+ if (comp?.async) {
385
+ await comp(...args);
386
+ } else if (comp) {
387
+ comp(...args);
388
+ }
389
+ }
390
+ }
391
+
392
+ __output.push('</div>');
393
+ }
394
+
395
+ __output.push('</main>');
396
+ _$_.pop_component();
397
+ });
398
+ }
399
+
400
+ Layout.async = true;
401
+
402
+ function Content(__output) {
403
+ _$_.push_component();
404
+ __output.push('<div');
405
+ __output.push(' class="content"');
406
+ __output.push('>');
407
+
408
+ {
409
+ __output.push('<p');
410
+ __output.push('>');
411
+
412
+ {
413
+ __output.push('Some content here');
414
+ }
415
+
416
+ __output.push('</p>');
417
+ }
418
+
419
+ __output.push('</div>');
420
+ _$_.pop_component();
421
+ }
422
+
423
+ export function WebsiteIndex(__output) {
424
+ _$_.push_component();
425
+
426
+ {
427
+ const comp = Layout;
428
+
429
+ const args = [
430
+ __output,
431
+
432
+ {
433
+ children: function children(__output) {
434
+ _$_.push_component();
435
+
436
+ {
437
+ const comp = Header;
438
+ const args = [__output, {}];
439
+
440
+ comp(...args);
441
+ }
442
+
443
+ {
444
+ const comp = Actions;
445
+ const args = [__output, { playgroundVisible: true }];
446
+
447
+ comp(...args);
448
+ }
449
+
450
+ {
451
+ const comp = Content;
452
+ const args = [__output, {}];
453
+
454
+ comp(...args);
455
+ }
456
+
457
+ {
458
+ const comp = Actions;
459
+ const args = [__output, { playgroundVisible: false }];
460
+
461
+ comp(...args);
462
+ }
463
+
464
+ _$_.pop_component();
465
+ }
466
+ }
467
+ ];
468
+
469
+ comp(...args);
470
+ }
471
+
223
472
  _$_.pop_component();
224
473
  }
@@ -1,6 +1,6 @@
1
1
  import * as _$_ from 'ripple/internal/server';
2
2
 
3
- import { track } from 'ripple/ssr';
3
+ import { track } from 'ripple/server';
4
4
 
5
5
  export function ClickCounter(__output) {
6
6
  _$_.push_component();