ripple 0.3.79 → 0.3.80
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# ripple
|
|
2
2
|
|
|
3
|
+
## 0.3.80
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
[[`f001849`](https://github.com/Ripple-TS/ripple/commit/f00184940979a77cbf6873a811caaaa436feab46),
|
|
9
|
+
[`4af2591`](https://github.com/Ripple-TS/ripple/commit/4af259139d118a27d177531aa6a21435a3f3a015),
|
|
10
|
+
[`4af2591`](https://github.com/Ripple-TS/ripple/commit/4af259139d118a27d177531aa6a21435a3f3a015),
|
|
11
|
+
[`87afc5d`](https://github.com/Ripple-TS/ripple/commit/87afc5d3f4c73e604cd245865e27d29e40435482),
|
|
12
|
+
[`87afc5d`](https://github.com/Ripple-TS/ripple/commit/87afc5d3f4c73e604cd245865e27d29e40435482),
|
|
13
|
+
[`f1a4c10`](https://github.com/Ripple-TS/ripple/commit/f1a4c10d2ad8ed604375f36f7ae3b653fe95ed1a),
|
|
14
|
+
[`87afc5d`](https://github.com/Ripple-TS/ripple/commit/87afc5d3f4c73e604cd245865e27d29e40435482)]:
|
|
15
|
+
- @tsrx/core@0.1.28
|
|
16
|
+
- @tsrx/ripple@0.1.28
|
|
17
|
+
|
|
3
18
|
## 0.3.79
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ripple is an elegant TypeScript UI framework",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.80",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"clsx": "^2.1.1",
|
|
75
75
|
"devalue": "^5.8.1",
|
|
76
76
|
"esm-env": "^1.2.2",
|
|
77
|
-
"@tsrx/core": "0.1.
|
|
78
|
-
"@tsrx/ripple": "0.1.
|
|
77
|
+
"@tsrx/core": "0.1.28",
|
|
78
|
+
"@tsrx/ripple": "0.1.28"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/estree": "^1.0.8",
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { flushSync, track } from 'ripple';
|
|
3
|
+
|
|
4
|
+
describe('code blocks in template children position', () => {
|
|
5
|
+
it('renders a code block child with setup statements and output', () => {
|
|
6
|
+
function App() @{
|
|
7
|
+
<>
|
|
8
|
+
<span class="a">{'a'}</span>
|
|
9
|
+
@{
|
|
10
|
+
const x = 1;
|
|
11
|
+
<span class="x">{x}</span>
|
|
12
|
+
}
|
|
13
|
+
</>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
render(App);
|
|
17
|
+
|
|
18
|
+
expect(container.querySelector('.a').textContent).toBe('a');
|
|
19
|
+
expect(container.querySelector('.x').textContent).toBe('1');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders deeply nested code block children in source position', () => {
|
|
23
|
+
function App() @{
|
|
24
|
+
<>
|
|
25
|
+
<span class="a">{'a'}</span>
|
|
26
|
+
@{
|
|
27
|
+
const x = 1;
|
|
28
|
+
@{
|
|
29
|
+
const y = 2;
|
|
30
|
+
@{
|
|
31
|
+
<span class="sum">
|
|
32
|
+
{x + y}
|
|
33
|
+
</span>
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
<span class="b">{'b'}</span>
|
|
38
|
+
</>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render(App);
|
|
42
|
+
|
|
43
|
+
expect(container.textContent).toBe('a3b');
|
|
44
|
+
expect(container.querySelector('.sum').textContent).toBe('3');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders nothing for empty nested code blocks', () => {
|
|
48
|
+
function App() @{
|
|
49
|
+
<>
|
|
50
|
+
<span>{'a'}</span>
|
|
51
|
+
<span>{'b'}</span>
|
|
52
|
+
@{
|
|
53
|
+
@{
|
|
54
|
+
@{}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render(App);
|
|
61
|
+
|
|
62
|
+
expect(container.textContent).toBe('ab');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('keeps code block render output reactive', () => {
|
|
66
|
+
function App() @{
|
|
67
|
+
const count = track(0);
|
|
68
|
+
<>
|
|
69
|
+
<button onClick={() => count.value++}>{'+'}</button>
|
|
70
|
+
@{
|
|
71
|
+
const doubled = () => count.value * 2;
|
|
72
|
+
<span class="doubled">{doubled()}</span>
|
|
73
|
+
}
|
|
74
|
+
</>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
render(App);
|
|
78
|
+
|
|
79
|
+
expect(container.querySelector('.doubled').textContent).toBe('0');
|
|
80
|
+
|
|
81
|
+
container.querySelector('button').click();
|
|
82
|
+
flushSync();
|
|
83
|
+
|
|
84
|
+
expect(container.querySelector('.doubled').textContent).toBe('2');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('renders a code block child inside an @if branch', () => {
|
|
88
|
+
function App() @{
|
|
89
|
+
const show = track(true);
|
|
90
|
+
<>
|
|
91
|
+
<button onClick={() => (show.value = !show.value)}>{'toggle'}</button>
|
|
92
|
+
@if (show.value) {
|
|
93
|
+
@{
|
|
94
|
+
const label = 'shown';
|
|
95
|
+
<span class="label">{label}</span>
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render(App);
|
|
102
|
+
|
|
103
|
+
expect(container.querySelector('.label').textContent).toBe('shown');
|
|
104
|
+
|
|
105
|
+
container.querySelector('button').click();
|
|
106
|
+
flushSync();
|
|
107
|
+
|
|
108
|
+
expect(container.querySelector('.label')).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('gives each code block its own lexical scope', () => {
|
|
112
|
+
function App() @{
|
|
113
|
+
const y = 10;
|
|
114
|
+
<>
|
|
115
|
+
<span class="a">{'a'}</span>
|
|
116
|
+
@{
|
|
117
|
+
const x = 1;
|
|
118
|
+
@{
|
|
119
|
+
const x = 2;
|
|
120
|
+
@{
|
|
121
|
+
<span class="sum">
|
|
122
|
+
{x + y}
|
|
123
|
+
</span>
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</>
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
render(App);
|
|
131
|
+
|
|
132
|
+
// The innermost block sees the shadowing `x = 2` and the component's `y`.
|
|
133
|
+
expect(container.querySelector('.sum').textContent).toBe('12');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('scopes code-only block statements', () => {
|
|
137
|
+
function App() @{
|
|
138
|
+
const items: number[] = [];
|
|
139
|
+
<>
|
|
140
|
+
@{
|
|
141
|
+
const scoped = 1;
|
|
142
|
+
items.push(scoped);
|
|
143
|
+
}
|
|
144
|
+
@{
|
|
145
|
+
const scoped = 2;
|
|
146
|
+
items.push(scoped);
|
|
147
|
+
}
|
|
148
|
+
<span class="len">{items.join(',')}</span>
|
|
149
|
+
</>
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
render(App);
|
|
153
|
+
|
|
154
|
+
expect(container.querySelector('.len').textContent).toBe('1,2');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('renders nested code block chains without extra component levels', () => {
|
|
158
|
+
function App() @{
|
|
159
|
+
<>
|
|
160
|
+
<span class="a">{'a'}</span>
|
|
161
|
+
@{
|
|
162
|
+
const x = 1;
|
|
163
|
+
@{
|
|
164
|
+
const y = 2;
|
|
165
|
+
@{
|
|
166
|
+
<span class="sum">
|
|
167
|
+
{x + y}
|
|
168
|
+
</span>
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
</>
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
render(App);
|
|
176
|
+
|
|
177
|
+
expect(container.textContent).toBe('a3');
|
|
178
|
+
expect(container.querySelector('.sum').textContent).toBe('3');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
describe('code blocks in template children position', () => {
|
|
2
|
+
it('renders a code block child with setup statements and output', async () => {
|
|
3
|
+
function App() @{
|
|
4
|
+
<>
|
|
5
|
+
<span class="a">{'a'}</span>
|
|
6
|
+
@{
|
|
7
|
+
const x = 1;
|
|
8
|
+
<span class="x">{x}</span>
|
|
9
|
+
}
|
|
10
|
+
</>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { body } = await render(App);
|
|
14
|
+
|
|
15
|
+
expect(body).toBeHtml('<span class="a">a</span><span class="x">1</span>');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders deeply nested code block children in source position', async () => {
|
|
19
|
+
function App() @{
|
|
20
|
+
<>
|
|
21
|
+
<span class="a">{'a'}</span>
|
|
22
|
+
@{
|
|
23
|
+
const x = 1;
|
|
24
|
+
@{
|
|
25
|
+
const y = 2;
|
|
26
|
+
@{
|
|
27
|
+
<span class="sum">
|
|
28
|
+
{x + y}
|
|
29
|
+
</span>
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
<span class="b">{'b'}</span>
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { body } = await render(App);
|
|
38
|
+
|
|
39
|
+
expect(body).toBeHtml(
|
|
40
|
+
'<span class="a">a</span><span class="sum">3</span><span class="b">b</span>',
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders nothing for empty nested code blocks', async () => {
|
|
45
|
+
function App() @{
|
|
46
|
+
<>
|
|
47
|
+
<span>{'a'}</span>
|
|
48
|
+
<span>{'b'}</span>
|
|
49
|
+
@{
|
|
50
|
+
@{
|
|
51
|
+
@{}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { body } = await render(App);
|
|
58
|
+
|
|
59
|
+
expect(body).toBeHtml('<span>a</span><span>b</span>');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('renders a code block child inside an @if branch', async () => {
|
|
63
|
+
function App() @{
|
|
64
|
+
const show = true;
|
|
65
|
+
<>
|
|
66
|
+
@if (show) {
|
|
67
|
+
@{
|
|
68
|
+
const label = 'shown';
|
|
69
|
+
<span class="label">{label}</span>
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
</>
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { body } = await render(App);
|
|
76
|
+
|
|
77
|
+
expect(body).toBeHtml('<span class="label">shown</span>');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('gives each code block its own lexical scope', async () => {
|
|
81
|
+
function App() @{
|
|
82
|
+
const y = 10;
|
|
83
|
+
<>
|
|
84
|
+
<span class="a">{'a'}</span>
|
|
85
|
+
@{
|
|
86
|
+
const x = 1;
|
|
87
|
+
@{
|
|
88
|
+
const x = 2;
|
|
89
|
+
@{
|
|
90
|
+
<span class="sum">
|
|
91
|
+
{x + y}
|
|
92
|
+
</span>
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { body } = await render(App);
|
|
100
|
+
|
|
101
|
+
expect(body).toBeHtml('<span class="a">a</span><span class="sum">12</span>');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('renders nested code block chains without extra component levels', async () => {
|
|
105
|
+
function App() @{
|
|
106
|
+
<>
|
|
107
|
+
<span class="a">{'a'}</span>
|
|
108
|
+
@{
|
|
109
|
+
const x = 1;
|
|
110
|
+
@{
|
|
111
|
+
const y = 2;
|
|
112
|
+
@{
|
|
113
|
+
<span class="sum">
|
|
114
|
+
{x + y}
|
|
115
|
+
</span>
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</>
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const { body } = await render(App);
|
|
123
|
+
|
|
124
|
+
expect(body).toBeHtml('<span class="a">a</span><span class="sum">3</span>');
|
|
125
|
+
});
|
|
126
|
+
});
|