ripple 0.3.22 → 0.3.24
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 +16 -0
- package/package.json +4 -4
- package/tests/client/basic/basic.errors.test.tsrx +1 -1
- package/tests/client/compiler/compiler.basic.test.tsrx +20 -0
- package/tests/hydration/compiled/client/html.js +70 -0
- package/tests/hydration/compiled/client/if-children.js +18 -0
- package/tests/hydration/compiled/server/html.js +129 -0
- package/tests/hydration/components/html.tsrx +24 -0
- package/tests/hydration/html.test.js +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# ripple
|
|
2
2
|
|
|
3
|
+
## 0.3.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- ripple@0.3.24
|
|
9
|
+
|
|
10
|
+
## 0.3.23
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
[[`73ceaac`](https://github.com/Ripple-TS/ripple/commit/73ceaacd029fb634a62252abdda59ab5f2bec15d)]:
|
|
16
|
+
- @tsrx/ripple@0.0.6
|
|
17
|
+
- ripple@0.3.23
|
|
18
|
+
|
|
3
19
|
## 0.3.22
|
|
4
20
|
|
|
5
21
|
### 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.24",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"esm-env": "^1.2.2",
|
|
77
77
|
"@types/estree": "^1.0.8",
|
|
78
78
|
"@types/estree-jsx": "^1.0.5",
|
|
79
|
-
"@tsrx/ripple": "0.0.
|
|
79
|
+
"@tsrx/ripple": "0.0.6"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "^24.3.0",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"typescript": "^5.9.3",
|
|
85
85
|
"@volar/language-core": "~2.4.28",
|
|
86
86
|
"vscode-languageserver-types": "^3.17.5",
|
|
87
|
-
"@tsrx/core": "0.0.
|
|
87
|
+
"@tsrx/core": "0.0.5"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"ripple": "0.3.
|
|
90
|
+
"ripple": "0.3.24"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -195,7 +195,7 @@ describe('basic client > errors', () => {
|
|
|
195
195
|
`;
|
|
196
196
|
expect(() => {
|
|
197
197
|
compile(code, 'test.tsrx', { mode: 'client' });
|
|
198
|
-
}).toThrow(
|
|
198
|
+
}).toThrow(/`await` is not allowed inside components\./);
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
it('should throw error for while loop inside a component', () => {
|
|
@@ -688,6 +688,26 @@ export component App() {
|
|
|
688
688
|
expect(result).toContain('_$_.normalize_children(');
|
|
689
689
|
});
|
|
690
690
|
|
|
691
|
+
it(
|
|
692
|
+
'parses a JS statement inside an element with no trailing whitespace before the closing tag',
|
|
693
|
+
() => {
|
|
694
|
+
const source = `component TodoList({ items }: { items: { text: string }[] }) {
|
|
695
|
+
<ul>var a = "123"</ul>
|
|
696
|
+
}`;
|
|
697
|
+
const ast = parse(source);
|
|
698
|
+
const comp = ast.body[0] as unknown as AST.Component;
|
|
699
|
+
const ul = comp.body.find((n) => n.type === 'Element') as AST.Element;
|
|
700
|
+
expect(ul.id.name).toBe('ul');
|
|
701
|
+
expect(ul.children).toHaveLength(1);
|
|
702
|
+
const decl = ul.children[0] as unknown as AST.VariableDeclaration;
|
|
703
|
+
expect(decl.type).toBe('VariableDeclaration');
|
|
704
|
+
expect(decl.kind).toBe('var');
|
|
705
|
+
expect((decl.declarations[0].id as AST.Identifier).name).toBe('a');
|
|
706
|
+
expect((decl.declarations[0].init as AST.Literal).value).toBe('123');
|
|
707
|
+
expect(ul.closingElement?.name?.name).toBe('ul');
|
|
708
|
+
},
|
|
709
|
+
);
|
|
710
|
+
|
|
691
711
|
it('uses spread_props for spreads that may contain children', () => {
|
|
692
712
|
const source = `
|
|
693
713
|
component Card(props) {
|
|
@@ -87,6 +87,7 @@ var root_82 = _$_.template(`<div class="wrapper"><h1>Title</h1><template id="dat
|
|
|
87
87
|
var root_83 = _$_.template(`<div class="layout"><template id="page-data"></template><main><!></main></div>`, 0);
|
|
88
88
|
var root_85 = _$_.template(`<div class="doc-content"><!></div>`, 0);
|
|
89
89
|
var root_84 = _$_.template(`<!>`, 1, 1);
|
|
90
|
+
var root_86 = _$_.template(`<section class="readable-section"><p>Ergonomics</p><h2>Sibling traversal pattern</h2><p>Before first block</p><p>Before second block</p><pre class="code-block"><code><!></code></pre><p>Between one and two</p><pre class="code-block"><code><!></code></pre><p>Between two and three</p><pre class="code-block"><code><!></code></pre></section>`, 0);
|
|
90
91
|
|
|
91
92
|
import { track } from 'ripple';
|
|
92
93
|
|
|
@@ -1908,4 +1909,73 @@ export function NestedTemplateInLayout(__anchor, _, __block) {
|
|
|
1908
1909
|
_$_.pop_component();
|
|
1909
1910
|
}
|
|
1910
1911
|
|
|
1912
|
+
export function HtmlCodeBlocksWithSiblingChain(__anchor, _, __block) {
|
|
1913
|
+
_$_.push_component();
|
|
1914
|
+
|
|
1915
|
+
const html1 = '<span class="kw">const</span> <span class="id">a</span> = 1;';
|
|
1916
|
+
const html2 = '<span class="kw">const</span> <span class="id">b</span> = 2;';
|
|
1917
|
+
const html3 = '<span class="kw">const</span> <span class="id">c</span> = 3;';
|
|
1918
|
+
var section_3 = root_86();
|
|
1919
|
+
|
|
1920
|
+
{
|
|
1921
|
+
var p_5 = _$_.child(section_3);
|
|
1922
|
+
var h2_3 = _$_.sibling(p_5);
|
|
1923
|
+
var p_4 = _$_.sibling(h2_3);
|
|
1924
|
+
var p_3 = _$_.sibling(p_4);
|
|
1925
|
+
var pre_1 = _$_.sibling(p_3);
|
|
1926
|
+
|
|
1927
|
+
{
|
|
1928
|
+
var code_1 = _$_.child(pre_1);
|
|
1929
|
+
|
|
1930
|
+
{
|
|
1931
|
+
var node_80 = _$_.child(code_1);
|
|
1932
|
+
|
|
1933
|
+
_$_.pop(code_1);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
_$_.pop(pre_1);
|
|
1938
|
+
|
|
1939
|
+
var p_6 = _$_.sibling(pre_1);
|
|
1940
|
+
var pre_2 = _$_.sibling(p_6);
|
|
1941
|
+
|
|
1942
|
+
{
|
|
1943
|
+
var code_2 = _$_.child(pre_2);
|
|
1944
|
+
|
|
1945
|
+
{
|
|
1946
|
+
var node_81 = _$_.child(code_2);
|
|
1947
|
+
|
|
1948
|
+
_$_.pop(code_2);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
_$_.pop(pre_2);
|
|
1953
|
+
|
|
1954
|
+
var p_7 = _$_.sibling(pre_2);
|
|
1955
|
+
var pre_3 = _$_.sibling(p_7);
|
|
1956
|
+
|
|
1957
|
+
{
|
|
1958
|
+
var code_3 = _$_.child(pre_3);
|
|
1959
|
+
|
|
1960
|
+
{
|
|
1961
|
+
var node_82 = _$_.child(code_3);
|
|
1962
|
+
|
|
1963
|
+
_$_.pop(code_3);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
_$_.render(
|
|
1969
|
+
(__prev) => {
|
|
1970
|
+
_$_.html(node_80, () => html1);
|
|
1971
|
+
_$_.html(node_81, () => html2);
|
|
1972
|
+
_$_.html(node_82, () => html3);
|
|
1973
|
+
},
|
|
1974
|
+
{}
|
|
1975
|
+
);
|
|
1976
|
+
|
|
1977
|
+
_$_.append(__anchor, section_3);
|
|
1978
|
+
_$_.pop_component();
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1911
1981
|
_$_.delegate(['click']);
|
|
@@ -370,6 +370,8 @@ export function DomChildrenThenStaticSiblings(__anchor, _, __block) {
|
|
|
370
370
|
_$_.pop(li_1);
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
+
|
|
374
|
+
_$_.pop(ul_1);
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
_$_.pop(div_17);
|
|
@@ -387,6 +389,22 @@ export function StaticListThenStaticSiblings(__anchor, _, __block) {
|
|
|
387
389
|
|
|
388
390
|
var div_18 = root_19();
|
|
389
391
|
|
|
392
|
+
{
|
|
393
|
+
var ul_2 = _$_.child(div_18);
|
|
394
|
+
|
|
395
|
+
{
|
|
396
|
+
var li_2 = _$_.child(ul_2);
|
|
397
|
+
|
|
398
|
+
_$_.pop(li_2);
|
|
399
|
+
|
|
400
|
+
var li_3 = _$_.sibling(li_2);
|
|
401
|
+
|
|
402
|
+
_$_.pop(li_3);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
_$_.pop(ul_2);
|
|
406
|
+
}
|
|
407
|
+
|
|
390
408
|
_$_.append(__anchor, div_18);
|
|
391
409
|
_$_.pop_component();
|
|
392
410
|
}
|
|
@@ -2309,5 +2309,134 @@ export function NestedTemplateInLayout() {
|
|
|
2309
2309
|
}
|
|
2310
2310
|
});
|
|
2311
2311
|
|
|
2312
|
+
_$_.pop_component();
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
export function HtmlCodeBlocksWithSiblingChain() {
|
|
2316
|
+
_$_.push_component();
|
|
2317
|
+
|
|
2318
|
+
const html1 = '<span class="kw">const</span> <span class="id">a</span> = 1;';
|
|
2319
|
+
const html2 = '<span class="kw">const</span> <span class="id">b</span> = 2;';
|
|
2320
|
+
const html3 = '<span class="kw">const</span> <span class="id">c</span> = 3;';
|
|
2321
|
+
|
|
2322
|
+
_$_.regular_block(() => {
|
|
2323
|
+
_$_.output_push('<section');
|
|
2324
|
+
_$_.output_push(' class="readable-section"');
|
|
2325
|
+
_$_.output_push('>');
|
|
2326
|
+
|
|
2327
|
+
{
|
|
2328
|
+
_$_.output_push('<p');
|
|
2329
|
+
_$_.output_push('>');
|
|
2330
|
+
|
|
2331
|
+
{
|
|
2332
|
+
_$_.output_push('Ergonomics');
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
_$_.output_push('</p>');
|
|
2336
|
+
_$_.output_push('<h2');
|
|
2337
|
+
_$_.output_push('>');
|
|
2338
|
+
|
|
2339
|
+
{
|
|
2340
|
+
_$_.output_push('Sibling traversal pattern');
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
_$_.output_push('</h2>');
|
|
2344
|
+
_$_.output_push('<p');
|
|
2345
|
+
_$_.output_push('>');
|
|
2346
|
+
|
|
2347
|
+
{
|
|
2348
|
+
_$_.output_push('Before first block');
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
_$_.output_push('</p>');
|
|
2352
|
+
_$_.output_push('<p');
|
|
2353
|
+
_$_.output_push('>');
|
|
2354
|
+
|
|
2355
|
+
{
|
|
2356
|
+
_$_.output_push('Before second block');
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
_$_.output_push('</p>');
|
|
2360
|
+
_$_.output_push('<pre');
|
|
2361
|
+
_$_.output_push(' class="code-block"');
|
|
2362
|
+
_$_.output_push('>');
|
|
2363
|
+
|
|
2364
|
+
{
|
|
2365
|
+
_$_.output_push('<code');
|
|
2366
|
+
_$_.output_push('>');
|
|
2367
|
+
|
|
2368
|
+
{
|
|
2369
|
+
const html_value_27 = String(html1 ?? '');
|
|
2370
|
+
|
|
2371
|
+
_$_.output_push('<!--' + _$_.hash(html_value_27) + '-->');
|
|
2372
|
+
_$_.output_push(html_value_27);
|
|
2373
|
+
_$_.output_push('<!---->');
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
_$_.output_push('</code>');
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
_$_.output_push('</pre>');
|
|
2380
|
+
_$_.output_push('<p');
|
|
2381
|
+
_$_.output_push('>');
|
|
2382
|
+
|
|
2383
|
+
{
|
|
2384
|
+
_$_.output_push('Between one and two');
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
_$_.output_push('</p>');
|
|
2388
|
+
_$_.output_push('<pre');
|
|
2389
|
+
_$_.output_push(' class="code-block"');
|
|
2390
|
+
_$_.output_push('>');
|
|
2391
|
+
|
|
2392
|
+
{
|
|
2393
|
+
_$_.output_push('<code');
|
|
2394
|
+
_$_.output_push('>');
|
|
2395
|
+
|
|
2396
|
+
{
|
|
2397
|
+
const html_value_28 = String(html2 ?? '');
|
|
2398
|
+
|
|
2399
|
+
_$_.output_push('<!--' + _$_.hash(html_value_28) + '-->');
|
|
2400
|
+
_$_.output_push(html_value_28);
|
|
2401
|
+
_$_.output_push('<!---->');
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
_$_.output_push('</code>');
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
_$_.output_push('</pre>');
|
|
2408
|
+
_$_.output_push('<p');
|
|
2409
|
+
_$_.output_push('>');
|
|
2410
|
+
|
|
2411
|
+
{
|
|
2412
|
+
_$_.output_push('Between two and three');
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
_$_.output_push('</p>');
|
|
2416
|
+
_$_.output_push('<pre');
|
|
2417
|
+
_$_.output_push(' class="code-block"');
|
|
2418
|
+
_$_.output_push('>');
|
|
2419
|
+
|
|
2420
|
+
{
|
|
2421
|
+
_$_.output_push('<code');
|
|
2422
|
+
_$_.output_push('>');
|
|
2423
|
+
|
|
2424
|
+
{
|
|
2425
|
+
const html_value_29 = String(html3 ?? '');
|
|
2426
|
+
|
|
2427
|
+
_$_.output_push('<!--' + _$_.hash(html_value_29) + '-->');
|
|
2428
|
+
_$_.output_push(html_value_29);
|
|
2429
|
+
_$_.output_push('<!---->');
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
_$_.output_push('</code>');
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
_$_.output_push('</pre>');
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
_$_.output_push('</section>');
|
|
2439
|
+
});
|
|
2440
|
+
|
|
2312
2441
|
_$_.pop_component();
|
|
2313
2442
|
}
|
|
@@ -532,3 +532,27 @@ export component NestedTemplateInLayout() {
|
|
|
532
532
|
<div class="doc-content">{html doc.html}</div>
|
|
533
533
|
</LayoutWithTemplate>
|
|
534
534
|
}
|
|
535
|
+
|
|
536
|
+
export component HtmlCodeBlocksWithSiblingChain() {
|
|
537
|
+
const html1 = '<span class="kw">const</span> <span class="id">a</span> = 1;';
|
|
538
|
+
const html2 = '<span class="kw">const</span> <span class="id">b</span> = 2;';
|
|
539
|
+
const html3 = '<span class="kw">const</span> <span class="id">c</span> = 3;';
|
|
540
|
+
|
|
541
|
+
<section class="readable-section">
|
|
542
|
+
<p>{'Ergonomics'}</p>
|
|
543
|
+
<h2>{'Sibling traversal pattern'}</h2>
|
|
544
|
+
<p>{'Before first block'}</p>
|
|
545
|
+
<p>{'Before second block'}</p>
|
|
546
|
+
<pre class="code-block">
|
|
547
|
+
<code>{html html1}</code>
|
|
548
|
+
</pre>
|
|
549
|
+
<p>{'Between one and two'}</p>
|
|
550
|
+
<pre class="code-block">
|
|
551
|
+
<code>{html html2}</code>
|
|
552
|
+
</pre>
|
|
553
|
+
<p>{'Between two and three'}</p>
|
|
554
|
+
<pre class="code-block">
|
|
555
|
+
<code>{html html3}</code>
|
|
556
|
+
</pre>
|
|
557
|
+
</section>
|
|
558
|
+
}
|
|
@@ -194,6 +194,21 @@ describe('hydration > html tags', () => {
|
|
|
194
194
|
expect(html).toContain('Footer');
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
+
it('hydrates html code blocks followed by static and dynamic sibling chains', async () => {
|
|
198
|
+
await hydrateComponent(
|
|
199
|
+
ServerComponents.HtmlCodeBlocksWithSiblingChain,
|
|
200
|
+
ClientComponents.HtmlCodeBlocksWithSiblingChain,
|
|
201
|
+
);
|
|
202
|
+
const html = container.innerHTML;
|
|
203
|
+
expect(html).toContain('Sibling traversal pattern');
|
|
204
|
+
expect(html).toContain('Between one and two');
|
|
205
|
+
expect(html).toContain('Between two and three');
|
|
206
|
+
expect(html).toContain('const');
|
|
207
|
+
expect(html).toContain('a');
|
|
208
|
+
expect(html).toContain('b');
|
|
209
|
+
expect(html).toContain('c');
|
|
210
|
+
});
|
|
211
|
+
|
|
197
212
|
it('hydrates full DocsLayout with data mismatch (StylingPage exact reproduction)', async () => {
|
|
198
213
|
await hydrateComponent(
|
|
199
214
|
ServerComponents.DocsLayoutWithData,
|