ripple 0.2.115 → 0.2.118
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 +16 -16
- package/src/compiler/index.js +20 -1
- package/src/compiler/phases/1-parse/index.js +79 -0
- package/src/compiler/phases/3-transform/client/index.js +54 -8
- package/src/compiler/phases/3-transform/segments.js +107 -60
- package/src/compiler/phases/3-transform/server/index.js +21 -11
- package/src/compiler/types/index.d.ts +16 -0
- package/src/runtime/index-client.js +19 -185
- package/src/runtime/index-server.js +24 -0
- package/src/runtime/internal/client/bindings.js +443 -0
- package/src/runtime/internal/client/index.js +4 -0
- package/src/runtime/internal/client/runtime.js +10 -0
- package/src/runtime/internal/client/utils.js +0 -8
- package/src/runtime/map.js +11 -1
- package/src/runtime/set.js +11 -1
- package/tests/client/__snapshots__/for.test.ripple.snap +80 -0
- package/tests/client/_etc.test.ripple +5 -0
- package/tests/client/array/array.copy-within.test.ripple +120 -0
- package/tests/client/array/array.derived.test.ripple +495 -0
- package/tests/client/array/array.iteration.test.ripple +115 -0
- package/tests/client/array/array.mutations.test.ripple +385 -0
- package/tests/client/array/array.static.test.ripple +237 -0
- package/tests/client/array/array.to-methods.test.ripple +93 -0
- package/tests/client/basic/__snapshots__/basic.attributes.test.ripple.snap +60 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.ripple.snap +106 -0
- package/tests/client/basic/__snapshots__/basic.text.test.ripple.snap +49 -0
- package/tests/client/basic/basic.attributes.test.ripple +474 -0
- package/tests/client/basic/basic.collections.test.ripple +94 -0
- package/tests/client/basic/basic.components.test.ripple +225 -0
- package/tests/client/basic/basic.errors.test.ripple +126 -0
- package/tests/client/basic/basic.events.test.ripple +222 -0
- package/tests/client/basic/basic.reactivity.test.ripple +476 -0
- package/tests/client/basic/basic.rendering.test.ripple +204 -0
- package/tests/client/basic/basic.styling.test.ripple +63 -0
- package/tests/client/basic/basic.utilities.test.ripple +25 -0
- package/tests/client/boundaries.test.ripple +2 -21
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +12 -0
- package/tests/client/compiler/__snapshots__/compiler.typescript.test.ripple.snap +22 -0
- package/tests/client/compiler/compiler.assignments.test.ripple +112 -0
- package/tests/client/compiler/compiler.attributes.test.ripple +95 -0
- package/tests/client/compiler/compiler.basic.test.ripple +203 -0
- package/tests/client/compiler/compiler.regex.test.ripple +87 -0
- package/tests/client/compiler/compiler.typescript.test.ripple +29 -0
- package/tests/client/{__snapshots__/composite.test.ripple.snap → composite/__snapshots__/composite.render.test.ripple.snap} +2 -2
- package/tests/client/composite/composite.dynamic-components.test.ripple +100 -0
- package/tests/client/composite/composite.generics.test.ripple +211 -0
- package/tests/client/composite/composite.props.test.ripple +106 -0
- package/tests/client/composite/composite.reactivity.test.ripple +184 -0
- package/tests/client/composite/composite.render.test.ripple +84 -0
- package/tests/client/computed-properties.test.ripple +2 -21
- package/tests/client/context.test.ripple +5 -22
- package/tests/client/date.test.ripple +1 -20
- package/tests/client/dynamic-elements.test.ripple +16 -24
- package/tests/client/for.test.ripple +4 -23
- package/tests/client/head.test.ripple +11 -23
- package/tests/client/html.test.ripple +1 -20
- package/tests/client/input-value.test.ripple +11 -31
- package/tests/client/map.test.ripple +82 -20
- package/tests/client/media-query.test.ripple +10 -23
- package/tests/client/object.test.ripple +5 -24
- package/tests/client/portal.test.ripple +2 -19
- package/tests/client/ref.test.ripple +8 -26
- package/tests/client/set.test.ripple +84 -22
- package/tests/client/svg.test.ripple +1 -22
- package/tests/client/switch.test.ripple +6 -25
- package/tests/client/tracked-expression.test.ripple +2 -21
- package/tests/client/typescript-generics.test.ripple +0 -21
- package/tests/client/url/url.derived.test.ripple +83 -0
- package/tests/client/url/url.parsing.test.ripple +165 -0
- package/tests/client/url/url.partial-removal.test.ripple +198 -0
- package/tests/client/url/url.reactivity.test.ripple +449 -0
- package/tests/client/url/url.serialization.test.ripple +50 -0
- package/tests/client/url-search-params/url-search-params.derived.test.ripple +84 -0
- package/tests/client/url-search-params/url-search-params.initialization.test.ripple +61 -0
- package/tests/client/url-search-params/url-search-params.iteration.test.ripple +153 -0
- package/tests/client/url-search-params/url-search-params.mutation.test.ripple +343 -0
- package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +160 -0
- package/tests/client/url-search-params/url-search-params.serialization.test.ripple +53 -0
- package/tests/client/url-search-params/url-search-params.tracked-url.test.ripple +55 -0
- package/tests/client.d.ts +12 -0
- package/tests/server/if.test.ripple +66 -0
- package/tests/setup-client.js +28 -0
- package/tsconfig.json +4 -2
- package/types/index.d.ts +92 -46
- package/LICENSE +0 -21
- package/tests/client/__snapshots__/basic.test.ripple.snap +0 -117
- package/tests/client/__snapshots__/compiler.test.ripple.snap +0 -33
- package/tests/client/array.test.ripple +0 -1455
- package/tests/client/basic.test.ripple +0 -1892
- package/tests/client/compiler.test.ripple +0 -541
- package/tests/client/composite.test.ripple +0 -692
- package/tests/client/url-search-params.test.ripple +0 -912
- package/tests/client/url.test.ripple +0 -954
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { track, flushSync, TrackedArray } from 'ripple';
|
|
2
|
+
|
|
3
|
+
describe('TrackedArray > to* methods', () => {
|
|
4
|
+
it('handles toReversed method with reactivity', (context) => {
|
|
5
|
+
if (!('toReversed' in Array.prototype)) {
|
|
6
|
+
context.skip();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
component ArrayTest() {
|
|
10
|
+
let items = new TrackedArray(1, 2, 3, 4);
|
|
11
|
+
let reversed = track(() => items.toReversed());
|
|
12
|
+
|
|
13
|
+
<button onClick={() => items.push(5)}>{'add item'}</button>
|
|
14
|
+
<pre>{JSON.stringify(items)}</pre>
|
|
15
|
+
<pre>{JSON.stringify(@reversed)}</pre>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
render(ArrayTest);
|
|
19
|
+
|
|
20
|
+
const addButton = container.querySelector('button');
|
|
21
|
+
|
|
22
|
+
// Initial state
|
|
23
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[1,2,3,4]');
|
|
24
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[4,3,2,1]');
|
|
25
|
+
|
|
26
|
+
// Test adding an item
|
|
27
|
+
addButton.click();
|
|
28
|
+
flushSync();
|
|
29
|
+
|
|
30
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[1,2,3,4,5]');
|
|
31
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[5,4,3,2,1]');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('handles toSorted method with reactivity', (context) => {
|
|
35
|
+
if (!('toSorted' in Array.prototype)) {
|
|
36
|
+
context.skip();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
component ArrayTest() {
|
|
40
|
+
let items = new TrackedArray(3, 1, 4, 2);
|
|
41
|
+
let sorted = track(() => items.toSorted());
|
|
42
|
+
|
|
43
|
+
<button onClick={() => items.push(0)}>{'add item'}</button>
|
|
44
|
+
<pre>{JSON.stringify(items)}</pre>
|
|
45
|
+
<pre>{JSON.stringify(@sorted)}</pre>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
render(ArrayTest);
|
|
49
|
+
|
|
50
|
+
const addButton = container.querySelector('button');
|
|
51
|
+
|
|
52
|
+
// Initial state
|
|
53
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[3,1,4,2]');
|
|
54
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[1,2,3,4]');
|
|
55
|
+
|
|
56
|
+
// Test adding an item
|
|
57
|
+
addButton.click();
|
|
58
|
+
flushSync();
|
|
59
|
+
|
|
60
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[3,1,4,2,0]');
|
|
61
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[0,1,2,3,4]');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('handles toSpliced method with reactivity', (context) => {
|
|
65
|
+
if (!('toSpliced' in Array.prototype)) {
|
|
66
|
+
context.skip();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
component ArrayTest() {
|
|
70
|
+
let items = new TrackedArray<string | number>(1, 2, 3, 4, 5);
|
|
71
|
+
let spliced = track(() => items.toSpliced(1, 2, 'a', 'b'));
|
|
72
|
+
|
|
73
|
+
<button onClick={() => items[2] = 30}>{'change item'}</button>
|
|
74
|
+
<pre>{JSON.stringify(items)}</pre>
|
|
75
|
+
<pre>{JSON.stringify(@spliced)}</pre>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
render(ArrayTest);
|
|
79
|
+
|
|
80
|
+
const changeButton = container.querySelector('button');
|
|
81
|
+
|
|
82
|
+
// Initial state
|
|
83
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[1,2,3,4,5]');
|
|
84
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[1,"a","b",4,5]');
|
|
85
|
+
|
|
86
|
+
// Test changing an item
|
|
87
|
+
changeButton.click();
|
|
88
|
+
flushSync();
|
|
89
|
+
|
|
90
|
+
expect(container.querySelectorAll('pre')[0].textContent).toBe('[1,2,30,4,5]');
|
|
91
|
+
expect(container.querySelectorAll('pre')[1].textContent).toBe('[1,"a","b",4,5]');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`basic client > attribute rendering > handles boolean attributes with no prop value provides 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="container"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
disabled=""
|
|
10
|
+
>
|
|
11
|
+
Button
|
|
12
|
+
</button>
|
|
13
|
+
<input
|
|
14
|
+
checked=""
|
|
15
|
+
type="checkbox"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`basic client > attribute rendering > handles boolean props correctly 1`] = `
|
|
23
|
+
<div>
|
|
24
|
+
<div
|
|
25
|
+
data-disabled=""
|
|
26
|
+
/>
|
|
27
|
+
<input
|
|
28
|
+
disabled=""
|
|
29
|
+
/>
|
|
30
|
+
<!---->
|
|
31
|
+
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`basic client > attribute rendering > render spread props without duplication 1`] = `
|
|
36
|
+
<div>
|
|
37
|
+
<div>
|
|
38
|
+
<input
|
|
39
|
+
id="vehicle1"
|
|
40
|
+
name="car"
|
|
41
|
+
type="checkbox"
|
|
42
|
+
value="Bike"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
exports[`basic client > attribute rendering > render static attributes 1`] = `
|
|
50
|
+
<div>
|
|
51
|
+
<div
|
|
52
|
+
class="foo"
|
|
53
|
+
id="bar"
|
|
54
|
+
style="color: red;"
|
|
55
|
+
>
|
|
56
|
+
Hello World
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
`;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`basic client > rendering & text > basic operations 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div>
|
|
6
|
+
0
|
|
7
|
+
</div>
|
|
8
|
+
<div>
|
|
9
|
+
2
|
|
10
|
+
</div>
|
|
11
|
+
<div>
|
|
12
|
+
5
|
|
13
|
+
</div>
|
|
14
|
+
<div>
|
|
15
|
+
2
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`basic client > rendering & text > renders semi-dynamic text 1`] = `
|
|
22
|
+
<div>
|
|
23
|
+
<div>
|
|
24
|
+
Hello World
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`basic client > rendering & text > renders simple JS expression logic correctly 1`] = `
|
|
31
|
+
<div>
|
|
32
|
+
<div>
|
|
33
|
+
{"0":"Test"}
|
|
34
|
+
</div>
|
|
35
|
+
<div>
|
|
36
|
+
1
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`basic client > rendering & text > renders static text 1`] = `
|
|
43
|
+
<div>
|
|
44
|
+
<div>
|
|
45
|
+
Hello World
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`basic client > rendering & text > should handle lexical scopes correctly 1`] = `
|
|
52
|
+
<div>
|
|
53
|
+
<section>
|
|
54
|
+
Nested scope variable
|
|
55
|
+
</section>
|
|
56
|
+
|
|
57
|
+
</div>
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
exports[`basic client > text rendering > basic operations 1`] = `
|
|
61
|
+
<div>
|
|
62
|
+
<div>
|
|
63
|
+
0
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
2
|
|
67
|
+
</div>
|
|
68
|
+
<div>
|
|
69
|
+
5
|
|
70
|
+
</div>
|
|
71
|
+
<div>
|
|
72
|
+
2
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
exports[`basic client > text rendering > renders semi-dynamic text 1`] = `
|
|
79
|
+
<div>
|
|
80
|
+
<div>
|
|
81
|
+
Hello World
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
exports[`basic client > text rendering > renders simple JS expression logic correctly 1`] = `
|
|
88
|
+
<div>
|
|
89
|
+
<div>
|
|
90
|
+
{"0":"Test"}
|
|
91
|
+
</div>
|
|
92
|
+
<div>
|
|
93
|
+
1
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
</div>
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
exports[`basic client > text rendering > renders static text 1`] = `
|
|
100
|
+
<div>
|
|
101
|
+
<div>
|
|
102
|
+
Hello World
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`basic client > text rendering > basic operations 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div>
|
|
6
|
+
0
|
|
7
|
+
</div>
|
|
8
|
+
<div>
|
|
9
|
+
2
|
|
10
|
+
</div>
|
|
11
|
+
<div>
|
|
12
|
+
5
|
|
13
|
+
</div>
|
|
14
|
+
<div>
|
|
15
|
+
2
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`basic client > text rendering > renders semi-dynamic text 1`] = `
|
|
22
|
+
<div>
|
|
23
|
+
<div>
|
|
24
|
+
Hello World
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`basic client > text rendering > renders simple JS expression logic correctly 1`] = `
|
|
31
|
+
<div>
|
|
32
|
+
<div>
|
|
33
|
+
{"0":"Test"}
|
|
34
|
+
</div>
|
|
35
|
+
<div>
|
|
36
|
+
1
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`basic client > text rendering > renders static text 1`] = `
|
|
43
|
+
<div>
|
|
44
|
+
<div>
|
|
45
|
+
Hello World
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
`;
|