ripple 0.3.17 → 0.3.18
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 +7 -0
- package/package.json +2 -2
- package/src/runtime/element.js +11 -11
- package/src/runtime/internal/client/composite.js +2 -2
- package/src/runtime/internal/client/expression.js +5 -5
- package/src/runtime/internal/client/index.js +1 -1
- package/src/runtime/internal/client/portal.js +4 -4
- package/src/runtime/internal/server/index.js +4 -4
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +49 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +319 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +40 -0
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +60 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +59 -0
- package/tests/client/basic/{basic.components.test.rsrx → basic.components.test.tsrx} +51 -1
- package/tests/client/basic/{basic.errors.test.rsrx → basic.errors.test.tsrx} +12 -12
- package/tests/client/basic/{basic.styling.test.rsrx → basic.styling.test.tsrx} +1 -1
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +12 -0
- package/tests/client/compiler/__snapshots__/compiler.typescript.test.tsrx.snap +46 -0
- package/tests/client/compiler/{compiler.assignments.test.rsrx → compiler.assignments.test.tsrx} +2 -2
- package/tests/client/compiler/{compiler.attributes.test.rsrx → compiler.attributes.test.tsrx} +4 -4
- package/tests/client/compiler/{compiler.basic.test.rsrx → compiler.basic.test.tsrx} +44 -30
- package/tests/client/compiler/{compiler.tracked-access.test.rsrx → compiler.tracked-access.test.tsrx} +16 -16
- package/tests/client/compiler/{compiler.try-in-function.test.rsrx → compiler.try-in-function.test.tsrx} +8 -8
- package/tests/client/compiler/{compiler.typescript.test.rsrx → compiler.typescript.test.tsrx} +4 -4
- package/tests/client/composite/__snapshots__/composite.render.test.tsrx.snap +37 -0
- package/tests/client/css/{global-additional-cases.test.rsrx → global-additional-cases.test.tsrx} +27 -27
- package/tests/client/css/{global-advanced-selectors.test.rsrx → global-advanced-selectors.test.tsrx} +8 -8
- package/tests/client/css/{global-at-rules.test.rsrx → global-at-rules.test.tsrx} +5 -5
- package/tests/client/css/{global-basic.test.rsrx → global-basic.test.tsrx} +7 -7
- package/tests/client/css/{global-classes-ids.test.rsrx → global-classes-ids.test.tsrx} +7 -7
- package/tests/client/css/{global-combinators.test.rsrx → global-combinators.test.tsrx} +5 -5
- package/tests/client/css/{global-complex-nesting.test.rsrx → global-complex-nesting.test.tsrx} +7 -7
- package/tests/client/css/{global-edge-cases.test.rsrx → global-edge-cases.test.tsrx} +9 -9
- package/tests/client/css/{global-keyframes.test.rsrx → global-keyframes.test.tsrx} +5 -5
- package/tests/client/css/{global-nested.test.rsrx → global-nested.test.tsrx} +5 -5
- package/tests/client/css/{global-pseudo.test.rsrx → global-pseudo.test.tsrx} +6 -6
- package/tests/client/css/{global-scoping.test.rsrx → global-scoping.test.tsrx} +10 -10
- package/tests/client/css/{style-identifier.test.rsrx → style-identifier.test.tsrx} +12 -16
- package/tests/client/{function-overload.test.rsrx → function-overload.test.tsrx} +1 -1
- package/tests/client/{return.test.rsrx → return.test.tsrx} +16 -18
- package/tests/hydration/build-components.js +2 -4
- package/tests/hydration/compiled/client/basic.js +1 -1
- package/tests/hydration/compiled/client/composite.js +4 -4
- package/tests/hydration/compiled/client/head.js +11 -11
- package/tests/hydration/compiled/client/hmr.js +1 -1
- package/tests/hydration/compiled/client/html.js +19 -19
- package/tests/hydration/compiled/client/if-children.js +2 -2
- package/tests/hydration/compiled/client/portal.js +4 -4
- package/tests/hydration/compiled/server/basic.js +1 -1
- package/tests/hydration/compiled/server/composite.js +4 -4
- package/tests/hydration/compiled/server/head.js +11 -11
- package/tests/hydration/compiled/server/hmr.js +1 -1
- package/tests/hydration/compiled/server/html.js +19 -19
- package/tests/hydration/compiled/server/if-children.js +2 -2
- package/tests/hydration/compiled/server/portal.js +4 -4
- package/tests/hydration/components/{html-in-template.rsrx → html-in-template.tsrx} +1 -1
- package/tests/server/__snapshots__/compiler.test.tsrx.snap +95 -0
- package/tests/server/{basic.components.test.rsrx → basic.components.test.tsrx} +48 -0
- package/tests/server/{compiler.test.rsrx → compiler.test.tsrx} +17 -17
- package/tests/server/{html-nesting-validation.test.rsrx → html-nesting-validation.test.tsrx} +38 -38
- package/tests/server/{style-identifier.test.rsrx → style-identifier.test.tsrx} +1 -1
- package/tests/utils/compiler-compat-config.test.js +3 -3
- package/tests/utils/vite-plugin-config.test.js +1 -1
- package/tests/utils/vite-plugin-hmr.test.js +7 -7
- package/tsconfig.json +0 -4
- package/types/index.d.ts +6 -4
- /package/tests/client/{_etc.test.rsrx → _etc.test.tsrx} +0 -0
- /package/tests/client/array/{array.copy-within.test.rsrx → array.copy-within.test.tsrx} +0 -0
- /package/tests/client/array/{array.derived.test.rsrx → array.derived.test.tsrx} +0 -0
- /package/tests/client/array/{array.iteration.test.rsrx → array.iteration.test.tsrx} +0 -0
- /package/tests/client/array/{array.mutations.test.rsrx → array.mutations.test.tsrx} +0 -0
- /package/tests/client/array/{array.static.test.rsrx → array.static.test.tsrx} +0 -0
- /package/tests/client/array/{array.to-methods.test.rsrx → array.to-methods.test.tsrx} +0 -0
- /package/tests/client/{async-suspend.test.rsrx → async-suspend.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.attributes.test.rsrx → basic.attributes.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.collections.test.rsrx → basic.collections.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.events.test.rsrx → basic.events.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.get-set.test.rsrx → basic.get-set.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.hmr.test.rsrx → basic.hmr.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.reactivity.test.rsrx → basic.reactivity.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.rendering.test.rsrx → basic.rendering.test.tsrx} +0 -0
- /package/tests/client/basic/{basic.utilities.test.rsrx → basic.utilities.test.tsrx} +0 -0
- /package/tests/client/{boundaries.test.rsrx → boundaries.test.tsrx} +0 -0
- /package/tests/client/compiler/{compiler.regex.test.rsrx → compiler.regex.test.tsrx} +0 -0
- /package/tests/client/composite/{composite.dynamic-components.test.rsrx → composite.dynamic-components.test.tsrx} +0 -0
- /package/tests/client/composite/{composite.generics.test.rsrx → composite.generics.test.tsrx} +0 -0
- /package/tests/client/composite/{composite.props.test.rsrx → composite.props.test.tsrx} +0 -0
- /package/tests/client/composite/{composite.reactivity.test.rsrx → composite.reactivity.test.tsrx} +0 -0
- /package/tests/client/composite/{composite.render.test.rsrx → composite.render.test.tsrx} +0 -0
- /package/tests/client/{computed-properties.test.rsrx → computed-properties.test.tsrx} +0 -0
- /package/tests/client/{context.test.rsrx → context.test.tsrx} +0 -0
- /package/tests/client/{date.test.rsrx → date.test.tsrx} +0 -0
- /package/tests/client/{dynamic-elements.test.rsrx → dynamic-elements.test.tsrx} +0 -0
- /package/tests/client/{events.test.rsrx → events.test.tsrx} +0 -0
- /package/tests/client/{for.test.rsrx → for.test.tsrx} +0 -0
- /package/tests/client/{function-overload-import.rsrx → function-overload-import.tsrx} +0 -0
- /package/tests/client/{head.test.rsrx → head.test.tsrx} +0 -0
- /package/tests/client/{html.test.rsrx → html.test.tsrx} +0 -0
- /package/tests/client/{input-value.test.rsrx → input-value.test.tsrx} +0 -0
- /package/tests/client/{lazy-destructuring.test.rsrx → lazy-destructuring.test.tsrx} +0 -0
- /package/tests/client/{map.test.rsrx → map.test.tsrx} +0 -0
- /package/tests/client/{media-query.test.rsrx → media-query.test.tsrx} +0 -0
- /package/tests/client/{object.test.rsrx → object.test.tsrx} +0 -0
- /package/tests/client/{portal.test.rsrx → portal.test.tsrx} +0 -0
- /package/tests/client/{ref.test.rsrx → ref.test.tsrx} +0 -0
- /package/tests/client/{set.test.rsrx → set.test.tsrx} +0 -0
- /package/tests/client/{svg.test.rsrx → svg.test.tsrx} +0 -0
- /package/tests/client/{switch.test.rsrx → switch.test.tsrx} +0 -0
- /package/tests/client/{try.test.rsrx → try.test.tsrx} +0 -0
- /package/tests/client/{tsx.test.rsrx → tsx.test.tsrx} +0 -0
- /package/tests/client/{typescript-generics.test.rsrx → typescript-generics.test.tsrx} +0 -0
- /package/tests/client/url/{url.derived.test.rsrx → url.derived.test.tsrx} +0 -0
- /package/tests/client/url/{url.parsing.test.rsrx → url.parsing.test.tsrx} +0 -0
- /package/tests/client/url/{url.partial-removal.test.rsrx → url.partial-removal.test.tsrx} +0 -0
- /package/tests/client/url/{url.reactivity.test.rsrx → url.reactivity.test.tsrx} +0 -0
- /package/tests/client/url/{url.serialization.test.rsrx → url.serialization.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.derived.test.rsrx → url-search-params.derived.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.initialization.test.rsrx → url-search-params.initialization.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.iteration.test.rsrx → url-search-params.iteration.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.mutation.test.rsrx → url-search-params.mutation.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.retrieval.test.rsrx → url-search-params.retrieval.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.serialization.test.rsrx → url-search-params.serialization.test.tsrx} +0 -0
- /package/tests/client/url-search-params/{url-search-params.tracked-url.test.rsrx → url-search-params.tracked-url.test.tsrx} +0 -0
- /package/tests/hydration/components/{basic.rsrx → basic.tsrx} +0 -0
- /package/tests/hydration/components/{composite.rsrx → composite.tsrx} +0 -0
- /package/tests/hydration/components/{events.rsrx → events.tsrx} +0 -0
- /package/tests/hydration/components/{for.rsrx → for.tsrx} +0 -0
- /package/tests/hydration/components/{head.rsrx → head.tsrx} +0 -0
- /package/tests/hydration/components/{hmr.rsrx → hmr.tsrx} +0 -0
- /package/tests/hydration/components/{html.rsrx → html.tsrx} +0 -0
- /package/tests/hydration/components/{if-children.rsrx → if-children.tsrx} +0 -0
- /package/tests/hydration/components/{if.rsrx → if.tsrx} +0 -0
- /package/tests/hydration/components/{mixed-control-flow.rsrx → mixed-control-flow.tsrx} +0 -0
- /package/tests/hydration/components/{nested-control-flow.rsrx → nested-control-flow.tsrx} +0 -0
- /package/tests/hydration/components/{portal.rsrx → portal.tsrx} +0 -0
- /package/tests/hydration/components/{reactivity.rsrx → reactivity.tsrx} +0 -0
- /package/tests/hydration/components/{return.rsrx → return.tsrx} +0 -0
- /package/tests/hydration/components/{switch.rsrx → switch.tsrx} +0 -0
- /package/tests/hydration/components/{try.rsrx → try.tsrx} +0 -0
- /package/tests/server/{await.test.rsrx → await.test.tsrx} +0 -0
- /package/tests/server/{basic.attributes.test.rsrx → basic.attributes.test.tsrx} +0 -0
- /package/tests/server/{basic.test.rsrx → basic.test.tsrx} +0 -0
- /package/tests/server/{composite.props.test.rsrx → composite.props.test.tsrx} +0 -0
- /package/tests/server/{composite.test.rsrx → composite.test.tsrx} +0 -0
- /package/tests/server/{context.test.rsrx → context.test.tsrx} +0 -0
- /package/tests/server/{dynamic-elements.test.rsrx → dynamic-elements.test.tsrx} +0 -0
- /package/tests/server/{for.test.rsrx → for.test.tsrx} +0 -0
- /package/tests/server/{head.test.rsrx → head.test.tsrx} +0 -0
- /package/tests/server/{if.test.rsrx → if.test.tsrx} +0 -0
- /package/tests/server/{lazy-destructuring.test.rsrx → lazy-destructuring.test.tsrx} +0 -0
- /package/tests/server/{return.test.rsrx → return.test.tsrx} +0 -0
- /package/tests/server/{streaming-ssr.test.rsrx → streaming-ssr.test.tsrx} +0 -0
- /package/tests/server/{switch.test.rsrx → switch.test.tsrx} +0 -0
- /package/tests/server/{try.test.rsrx → try.test.tsrx} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
<!---->
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
@@ -496,7 +496,11 @@ describe('basic client > components & composition', () => {
|
|
|
496
496
|
|
|
497
497
|
component App() {
|
|
498
498
|
const extra = { id: '1', children: 'from spread' };
|
|
499
|
-
<Card
|
|
499
|
+
<Card
|
|
500
|
+
// @ts-expect-error children specified more than once
|
|
501
|
+
children="explicit"
|
|
502
|
+
{...extra}
|
|
503
|
+
/>
|
|
500
504
|
}
|
|
501
505
|
|
|
502
506
|
render(App);
|
|
@@ -516,4 +520,50 @@ describe('basic client > components & composition', () => {
|
|
|
516
520
|
render(App);
|
|
517
521
|
expect(container.querySelector('.card').textContent).toBe('explicit');
|
|
518
522
|
});
|
|
523
|
+
|
|
524
|
+
it('renders components declared inside composite element children', () => {
|
|
525
|
+
component Wrapper(props: PropsWithChildren<{}>) {
|
|
526
|
+
<div class="wrapper">{props.children}</div>
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
component App() {
|
|
530
|
+
<Wrapper>
|
|
531
|
+
component Inner() {
|
|
532
|
+
<span class="inner">{'inner content'}</span>
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
<Inner />
|
|
536
|
+
</Wrapper>
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
render(App);
|
|
540
|
+
expect(container.querySelector('.wrapper .inner').textContent).toBe('inner content');
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it('renders nested components declared inside composite children with prop passing', () => {
|
|
544
|
+
component Wrapper(props: PropsWithChildren<{}>) {
|
|
545
|
+
<div class="wrapper">{props.children}</div>
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
component App() {
|
|
549
|
+
<Wrapper>
|
|
550
|
+
component Z() {
|
|
551
|
+
<div class="z">{'I am Z'}</div>
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
component Child(&{ Z }: { Z: Component }) {
|
|
555
|
+
<div class="child">
|
|
556
|
+
{'Child Component: '}
|
|
557
|
+
<Z />
|
|
558
|
+
</div>
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
<Child {Z} />
|
|
562
|
+
</Wrapper>
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
render(App);
|
|
566
|
+
expect(container.querySelector('.wrapper .child').textContent).toBe('Child Component: I am Z');
|
|
567
|
+
expect(container.querySelector('.wrapper .z').textContent).toBe('I am Z');
|
|
568
|
+
});
|
|
519
569
|
});
|
|
@@ -47,7 +47,7 @@ describe('basic client > errors', () => {
|
|
|
47
47
|
<div></span>
|
|
48
48
|
}`;
|
|
49
49
|
expect(() => {
|
|
50
|
-
compile(malformedCode, 'test.
|
|
50
|
+
compile(malformedCode, 'test.tsrx');
|
|
51
51
|
}).toThrow('Expected closing tag to match opening tag');
|
|
52
52
|
});
|
|
53
53
|
|
|
@@ -57,7 +57,7 @@ describe('basic client > errors', () => {
|
|
|
57
57
|
}`;
|
|
58
58
|
|
|
59
59
|
expect(() => {
|
|
60
|
-
compile(malformedCode, 'test.
|
|
60
|
+
compile(malformedCode, 'test.tsrx');
|
|
61
61
|
}).toThrow('Unclosed tag');
|
|
62
62
|
});
|
|
63
63
|
|
|
@@ -69,7 +69,7 @@ describe('basic client > errors', () => {
|
|
|
69
69
|
`;
|
|
70
70
|
|
|
71
71
|
expect(() => {
|
|
72
|
-
compile(code, 'test.
|
|
72
|
+
compile(code, 'test.tsrx');
|
|
73
73
|
}).not.toThrow();
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -81,7 +81,7 @@ describe('basic client > errors', () => {
|
|
|
81
81
|
`;
|
|
82
82
|
|
|
83
83
|
expect(() => {
|
|
84
|
-
compile(code, 'test.
|
|
84
|
+
compile(code, 'test.tsrx');
|
|
85
85
|
}).not.toThrow();
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -93,7 +93,7 @@ describe('basic client > errors', () => {
|
|
|
93
93
|
`;
|
|
94
94
|
|
|
95
95
|
expect(() => {
|
|
96
|
-
compile(code, 'test.
|
|
96
|
+
compile(code, 'test.tsrx');
|
|
97
97
|
}).toThrow(
|
|
98
98
|
'`children` cannot be called like a regular function. Render it with `{children}` or `{props.children}` instead.',
|
|
99
99
|
);
|
|
@@ -107,7 +107,7 @@ describe('basic client > errors', () => {
|
|
|
107
107
|
`;
|
|
108
108
|
|
|
109
109
|
expect(() => {
|
|
110
|
-
compile(code, 'test.
|
|
110
|
+
compile(code, 'test.tsrx');
|
|
111
111
|
}).toThrow(
|
|
112
112
|
'`children` cannot be called like a regular function. Render it with `{children}` or `{props.children}` instead.',
|
|
113
113
|
);
|
|
@@ -194,7 +194,7 @@ describe('basic client > errors', () => {
|
|
|
194
194
|
}
|
|
195
195
|
`;
|
|
196
196
|
expect(() => {
|
|
197
|
-
compile(code, 'test.
|
|
197
|
+
compile(code, 'test.tsrx', { mode: 'client' });
|
|
198
198
|
}).toThrow('`await` is not allowed inside client components');
|
|
199
199
|
});
|
|
200
200
|
|
|
@@ -209,7 +209,7 @@ describe('basic client > errors', () => {
|
|
|
209
209
|
}
|
|
210
210
|
`;
|
|
211
211
|
expect(() => {
|
|
212
|
-
compile(code, 'test.
|
|
212
|
+
compile(code, 'test.tsrx');
|
|
213
213
|
}).toThrow('While loops are not supported in components.');
|
|
214
214
|
});
|
|
215
215
|
|
|
@@ -224,7 +224,7 @@ describe('basic client > errors', () => {
|
|
|
224
224
|
}
|
|
225
225
|
`;
|
|
226
226
|
expect(() => {
|
|
227
|
-
compile(code, 'test.
|
|
227
|
+
compile(code, 'test.tsrx');
|
|
228
228
|
}).toThrow('Do...while loops are not supported in components.');
|
|
229
229
|
});
|
|
230
230
|
|
|
@@ -242,7 +242,7 @@ describe('basic client > errors', () => {
|
|
|
242
242
|
}
|
|
243
243
|
`;
|
|
244
244
|
expect(() => {
|
|
245
|
-
compile(code, 'test.
|
|
245
|
+
compile(code, 'test.tsrx');
|
|
246
246
|
}).not.toThrow();
|
|
247
247
|
});
|
|
248
248
|
|
|
@@ -260,7 +260,7 @@ describe('basic client > errors', () => {
|
|
|
260
260
|
}
|
|
261
261
|
`;
|
|
262
262
|
expect(() => {
|
|
263
|
-
compile(code, 'test.
|
|
263
|
+
compile(code, 'test.tsrx');
|
|
264
264
|
}).not.toThrow();
|
|
265
265
|
});
|
|
266
266
|
|
|
@@ -272,7 +272,7 @@ describe('basic client > errors', () => {
|
|
|
272
272
|
}
|
|
273
273
|
`;
|
|
274
274
|
expect(() => {
|
|
275
|
-
compile(code, 'test.
|
|
275
|
+
compile(code, 'test.tsrx');
|
|
276
276
|
}).toThrow('identifiers starting with "_$_" are reserved');
|
|
277
277
|
});
|
|
278
278
|
});
|
|
@@ -56,7 +56,7 @@ describe('basic client > styling', () => {
|
|
|
56
56
|
</style>
|
|
57
57
|
}`;
|
|
58
58
|
|
|
59
|
-
const { css } = compile(source, 'test.
|
|
59
|
+
const { css } = compile(source, 'test.tsrx');
|
|
60
60
|
const name = css.match(/@keyframes\s+([a-zA-Z0-9_-]+)\s*\{/)[1];
|
|
61
61
|
expect(css.match(new RegExp(name, 'g'))?.length).toEqual(3);
|
|
62
62
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`compiler > assignments > compiles tracked values in effect with assignment expression 1`] = `"state.count = _$_.get(lazy);"`;
|
|
4
|
+
|
|
5
|
+
exports[`compiler > assignments > compiles tracked values in effect with update expressions 1`] = `
|
|
6
|
+
"_$_.untrack(() => {
|
|
7
|
+
state.preIncrement = _$_.update_pre(lazy);
|
|
8
|
+
state.postIncrement = _$_.update(lazy);
|
|
9
|
+
state.preDecrement = _$_.update_pre(lazy, -1);
|
|
10
|
+
state.postDecrement = _$_.update(lazy, -1);
|
|
11
|
+
});"
|
|
12
|
+
`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`compiler > typescript > compiles TSInstantiationExpression 1`] = `
|
|
4
|
+
"import * as _$_ from 'ripple/internal/client';
|
|
5
|
+
|
|
6
|
+
function makeBox(value) {
|
|
7
|
+
return { value };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const makeStringBox = (makeBox);
|
|
11
|
+
const stringBox = makeStringBox('abc');
|
|
12
|
+
const ErrorMap = (Map);
|
|
13
|
+
const errorMap = new ErrorMap();"
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`compiler > typescript > removes class TypeScript syntax from JS output 1`] = `
|
|
17
|
+
"import * as _$_ from 'ripple/internal/client';
|
|
18
|
+
|
|
19
|
+
class PrintEvent {
|
|
20
|
+
text;
|
|
21
|
+
|
|
22
|
+
constructor(text) {
|
|
23
|
+
this.text = text;
|
|
24
|
+
}
|
|
25
|
+
}"
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
exports[`compiler > typescript > removes class extends type arguments from JS output 1`] = `
|
|
29
|
+
"import * as _$_ from 'ripple/internal/client';
|
|
30
|
+
|
|
31
|
+
class StringMap extends Map {
|
|
32
|
+
constructor() {
|
|
33
|
+
var __block = _$_.scope();
|
|
34
|
+
|
|
35
|
+
super();
|
|
36
|
+
}
|
|
37
|
+
}"
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
exports[`compiler > typescript > removes type assertions from function parameters and leaves default values 1`] = `
|
|
41
|
+
"import * as _$_ from 'ripple/internal/client';
|
|
42
|
+
|
|
43
|
+
function getString(e = 'test') {
|
|
44
|
+
return e;
|
|
45
|
+
}"
|
|
46
|
+
`;
|
package/tests/client/compiler/{compiler.assignments.test.rsrx → compiler.assignments.test.tsrx}
RENAMED
|
@@ -116,7 +116,7 @@ component App() {
|
|
|
116
116
|
state.count = count;
|
|
117
117
|
});
|
|
118
118
|
}`;
|
|
119
|
-
const result = compile(source, 'test.
|
|
119
|
+
const result = compile(source, 'test.tsrx');
|
|
120
120
|
const effect_match = result.js.code.match(EFFECT_BODY_REGEX);
|
|
121
121
|
expect(effect_match?.[1].trim()).toMatchSnapshot();
|
|
122
122
|
});
|
|
@@ -135,7 +135,7 @@ component App() {
|
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
}`;
|
|
138
|
-
const result = compile(source, 'test.
|
|
138
|
+
const result = compile(source, 'test.tsrx');
|
|
139
139
|
const effect_match = result.js.code.match(EFFECT_BODY_REGEX);
|
|
140
140
|
expect(effect_match?.[1].trim()).toMatchSnapshot();
|
|
141
141
|
});
|
package/tests/client/compiler/{compiler.attributes.test.rsrx → compiler.attributes.test.tsrx}
RENAMED
|
@@ -11,7 +11,7 @@ describe('compiler > attributes', () => {
|
|
|
11
11
|
<Child data-scope="test" aria-label="accessible" class="valid" />
|
|
12
12
|
}`;
|
|
13
13
|
|
|
14
|
-
const result = compile(source, 'test.
|
|
14
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
15
15
|
|
|
16
16
|
// Should contain properly quoted hyphenated properties and unquoted valid identifiers
|
|
17
17
|
expect(result.js.code).toMatch(/'data-scope': "test"/);
|
|
@@ -32,7 +32,7 @@ describe('compiler > attributes', () => {
|
|
|
32
32
|
component Child(props) { <div /> }
|
|
33
33
|
export default component App() { <Child ${attr} /> }`;
|
|
34
34
|
|
|
35
|
-
const result = compile(source, 'test.
|
|
35
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
36
36
|
expect(result.js.code).toMatch(expected);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -54,7 +54,7 @@ describe('compiler > attributes', () => {
|
|
|
54
54
|
/>
|
|
55
55
|
}`;
|
|
56
56
|
|
|
57
|
-
const result = compile(source, 'test.
|
|
57
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
58
58
|
|
|
59
59
|
// Valid identifiers should not be quoted
|
|
60
60
|
expect(result.js.code).toMatch(/validProp: "valid"/);
|
|
@@ -77,7 +77,7 @@ describe('compiler > attributes', () => {
|
|
|
77
77
|
<Child data-scope="test" />
|
|
78
78
|
}`;
|
|
79
79
|
|
|
80
|
-
const result = compile(source, 'test.
|
|
80
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
81
81
|
|
|
82
82
|
// Extract the props object from the generated code and test it's valid JavaScript
|
|
83
83
|
const match = result.js.code.match(/Child\([^,]+,\s*(\{[^}]+\})/);
|
|
@@ -64,7 +64,7 @@ describe('compiler > basics', () => {
|
|
|
64
64
|
expect(explicit_text.type).toBe('Text');
|
|
65
65
|
expect((explicit_text.expression as AST.Identifier).name).toBe('markup');
|
|
66
66
|
|
|
67
|
-
const { js } = compile(source, 'text-directive.
|
|
67
|
+
const { js } = compile(source, 'text-directive.tsrx', { mode: 'client' });
|
|
68
68
|
expect(js.code).not.toContain('_$_.html');
|
|
69
69
|
|
|
70
70
|
const invalid_source = `export component App() {
|
|
@@ -262,7 +262,7 @@ describe('compiler > basics', () => {
|
|
|
262
262
|
</div>
|
|
263
263
|
}`;
|
|
264
264
|
|
|
265
|
-
const result = compile(source, 'test.
|
|
265
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
266
266
|
});
|
|
267
267
|
|
|
268
268
|
it('calculates fragment hop count after return-guard grouping', () => {
|
|
@@ -275,7 +275,7 @@ describe('compiler > basics', () => {
|
|
|
275
275
|
<div class="b">{'b'}</div>
|
|
276
276
|
}`;
|
|
277
277
|
|
|
278
|
-
const { js } = compile(source, 'grouped-count.
|
|
278
|
+
const { js } = compile(source, 'grouped-count.tsrx', { mode: 'client' });
|
|
279
279
|
|
|
280
280
|
expect(js.code).toMatch(/_\$_\.template\(`<!><!>`,\s*1,\s*2\)/);
|
|
281
281
|
expect(js.code).not.toMatch(/_\$_\.template\(`<!><!>`,\s*1,\s*3\)/);
|
|
@@ -295,7 +295,7 @@ describe('compiler > basics', () => {
|
|
|
295
295
|
// <div {ref () => {}} />
|
|
296
296
|
// }
|
|
297
297
|
// `;
|
|
298
|
-
// const result = compile_to_volar_mappings(source, 'test.
|
|
298
|
+
// const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
299
299
|
|
|
300
300
|
// expect(count_occurrences(result, 'RippleArray')).toBe(1);
|
|
301
301
|
// expect(count_occurrences(result, 'RippleObject')).toBe(1);
|
|
@@ -319,7 +319,7 @@ describe('compiler > basics', () => {
|
|
|
319
319
|
// <div {ref () => {}} />
|
|
320
320
|
// }
|
|
321
321
|
// `;
|
|
322
|
-
// const result = compile_to_volar_mappings(source, 'test.
|
|
322
|
+
// const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
323
323
|
|
|
324
324
|
// expect(count_occurrences(result, obfuscateIdentifier('RippleArray'))).toBe(2);
|
|
325
325
|
// expect(count_occurrences(result, 'TA')).toBe(1);
|
|
@@ -345,7 +345,7 @@ describe('compiler > basics', () => {
|
|
|
345
345
|
// <div {ref () => {}} />
|
|
346
346
|
// }
|
|
347
347
|
// `;
|
|
348
|
-
// const result = compile_to_volar_mappings(source, 'test.
|
|
348
|
+
// const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
349
349
|
|
|
350
350
|
// expect(count_occurrences(result, obfuscateIdentifier('RippleArray'))).toBe(2);
|
|
351
351
|
// expect(count_occurrences(result, obfuscateIdentifier('RippleObject'))).toBe(2);
|
|
@@ -369,7 +369,7 @@ component App() {
|
|
|
369
369
|
}
|
|
370
370
|
`;
|
|
371
371
|
|
|
372
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
372
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
373
373
|
|
|
374
374
|
expect(result).toMatch(/value:\s*value\.value/);
|
|
375
375
|
});
|
|
@@ -382,7 +382,7 @@ component App() {
|
|
|
382
382
|
const x = value;
|
|
383
383
|
}
|
|
384
384
|
`;
|
|
385
|
-
const track_result = compile_to_volar_mappings(track_source, 'test.
|
|
385
|
+
const track_result = compile_to_volar_mappings(track_source, 'test.tsrx').code;
|
|
386
386
|
expect(track_result).toContain('let [value, ...rest] = track(0);');
|
|
387
387
|
expect(track_result).toContain('const x = value;');
|
|
388
388
|
expect(track_result).not.toContain('let lazy = track(0)');
|
|
@@ -399,7 +399,7 @@ function use_nested({ value: &[count, tracked] }: { value: Tracked<number> }) {
|
|
|
399
399
|
return tracked;
|
|
400
400
|
}
|
|
401
401
|
`;
|
|
402
|
-
const { js } = compile(source, 'tracked-nested-lazy.
|
|
402
|
+
const { js } = compile(source, 'tracked-nested-lazy.tsrx', { mode: 'client' });
|
|
403
403
|
|
|
404
404
|
// Nested lazy array should still use tracked tuple fast path from outer annotation.
|
|
405
405
|
expect(js.code).toContain('_$_.update(');
|
|
@@ -415,7 +415,7 @@ function use_tuple_rest({ value: [head, &[count, tracked]] }: { value: [number,
|
|
|
415
415
|
return tracked;
|
|
416
416
|
}
|
|
417
417
|
`;
|
|
418
|
-
const { js } = compile(source, 'tracked-nested-lazy-tuple-rest.
|
|
418
|
+
const { js } = compile(source, 'tracked-nested-lazy-tuple-rest.tsrx', { mode: 'client' });
|
|
419
419
|
|
|
420
420
|
// Tuple rest element access should resolve to Tracked<number>, not Tracked<number>[].
|
|
421
421
|
expect(js.code).toContain('_$_.update(');
|
|
@@ -437,7 +437,7 @@ export component App(props: Props) {
|
|
|
437
437
|
}
|
|
438
438
|
`;
|
|
439
439
|
|
|
440
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
440
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
441
441
|
|
|
442
442
|
expect(result).toContain('extends PolymorphicProps<\'div\'>');
|
|
443
443
|
});
|
|
@@ -460,7 +460,7 @@ export component App() {
|
|
|
460
460
|
}
|
|
461
461
|
`;
|
|
462
462
|
|
|
463
|
-
expect(() => compile_to_volar_mappings(source, 'test.
|
|
463
|
+
expect(() => compile_to_volar_mappings(source, 'test.tsrx')).not.toThrow();
|
|
464
464
|
});
|
|
465
465
|
|
|
466
466
|
it('should not error on having js below markup in the same scope', () => {
|
|
@@ -483,10 +483,10 @@ export component App() {
|
|
|
483
483
|
<div>{test}</div>
|
|
484
484
|
}
|
|
485
485
|
`;
|
|
486
|
-
expect(() => compile(code, 'test.
|
|
486
|
+
expect(() => compile(code, 'test.tsrx')).not.toThrow();
|
|
487
487
|
});
|
|
488
488
|
|
|
489
|
-
it('
|
|
489
|
+
it('allows component declarations inside composite children', () => {
|
|
490
490
|
const source = `
|
|
491
491
|
export component App() {
|
|
492
492
|
<ark.div class="host-class" data-value="42">
|
|
@@ -497,8 +497,22 @@ export component App() {
|
|
|
497
497
|
}
|
|
498
498
|
`;
|
|
499
499
|
|
|
500
|
-
expect(() => compile_to_volar_mappings(source, 'test.
|
|
501
|
-
|
|
500
|
+
expect(() => compile_to_volar_mappings(source, 'test.tsrx')).not.toThrow();
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it('rejects parent element attributes referencing child-declared components', () => {
|
|
504
|
+
const source = `
|
|
505
|
+
export component App() {
|
|
506
|
+
<Test {Z}>
|
|
507
|
+
component Z() {
|
|
508
|
+
<div>{'hello'}</div>
|
|
509
|
+
}
|
|
510
|
+
</Test>
|
|
511
|
+
}
|
|
512
|
+
`;
|
|
513
|
+
|
|
514
|
+
expect(() => compile(source, 'test.tsrx')).toThrow(
|
|
515
|
+
/Cannot use component 'Z' as a prop on its parent element/,
|
|
502
516
|
);
|
|
503
517
|
});
|
|
504
518
|
|
|
@@ -512,7 +526,7 @@ export component App() {
|
|
|
512
526
|
<ark.div class="host-class" data-value="42" {asChild} />
|
|
513
527
|
}
|
|
514
528
|
`;
|
|
515
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
529
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx').code;
|
|
516
530
|
|
|
517
531
|
expect(result).toContain('<ark.div class="host-class" data-value="42" asChild={asChild}');
|
|
518
532
|
expect(result).not.toContain('children={() =>');
|
|
@@ -533,11 +547,11 @@ export component App() {
|
|
|
533
547
|
}
|
|
534
548
|
`;
|
|
535
549
|
|
|
536
|
-
const result = compile(source, 'test.
|
|
550
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' }).js.code;
|
|
537
551
|
|
|
538
552
|
// Template children should take precedence - explicit children prop should be removed
|
|
539
553
|
expect((result.match(/children:/g) || []).length).toBe(1);
|
|
540
|
-
expect(result).toContain('children: _$_.
|
|
554
|
+
expect(result).toContain('children: _$_.tsrx_element(');
|
|
541
555
|
});
|
|
542
556
|
|
|
543
557
|
it('should not error on `this` MemberExpression with a UpdateExpression', () => {
|
|
@@ -554,7 +568,7 @@ export component App() {
|
|
|
554
568
|
<div>{test.count}</div>
|
|
555
569
|
}
|
|
556
570
|
`;
|
|
557
|
-
expect(() => compile(code, 'test.
|
|
571
|
+
expect(() => compile(code, 'test.tsrx')).not.toThrow();
|
|
558
572
|
});
|
|
559
573
|
|
|
560
574
|
it('should inject __block for track() calls inside class constructors', () => {
|
|
@@ -573,7 +587,7 @@ export component App() {
|
|
|
573
587
|
<div>{store.count}</div>
|
|
574
588
|
}
|
|
575
589
|
`;
|
|
576
|
-
const result = compile(source, 'test.
|
|
590
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' });
|
|
577
591
|
const code = result.js.code;
|
|
578
592
|
|
|
579
593
|
// The constructor's compiled output should contain __block = _$_.scope()
|
|
@@ -611,11 +625,11 @@ export component App() {
|
|
|
611
625
|
}
|
|
612
626
|
`;
|
|
613
627
|
|
|
614
|
-
expect(() => compile(source, 'test.
|
|
628
|
+
expect(() => compile(source, 'test.tsrx')).toThrow(
|
|
615
629
|
'Identifier \'test\' has already been declared',
|
|
616
630
|
);
|
|
617
631
|
|
|
618
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
632
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx', { loose: true });
|
|
619
633
|
|
|
620
634
|
expect(
|
|
621
635
|
result.errors.some(
|
|
@@ -629,7 +643,7 @@ export component App() {
|
|
|
629
643
|
<tsx:react>1
|
|
630
644
|
}`;
|
|
631
645
|
|
|
632
|
-
expect(() => compile(source, 'test.
|
|
646
|
+
expect(() => compile(source, 'test.tsrx')).toThrow(
|
|
633
647
|
'Unclosed tag \'<tsx:react>\'. Expected \'</tsx:react>\' before end of component.',
|
|
634
648
|
);
|
|
635
649
|
});
|
|
@@ -639,9 +653,9 @@ export component App() {
|
|
|
639
653
|
<tsx:react>1
|
|
640
654
|
}`;
|
|
641
655
|
|
|
642
|
-
expect(() => compile_to_volar_mappings(source, 'test.
|
|
656
|
+
expect(() => compile_to_volar_mappings(source, 'test.tsrx', { loose: true })).not.toThrow();
|
|
643
657
|
|
|
644
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
658
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx', { loose: true });
|
|
645
659
|
expect(result.errors).toEqual([]);
|
|
646
660
|
});
|
|
647
661
|
|
|
@@ -649,9 +663,9 @@ export component App() {
|
|
|
649
663
|
const source = `class StringMap extends Map<string, string> {}
|
|
650
664
|
export component App() {}`;
|
|
651
665
|
|
|
652
|
-
expect(() => compile_to_volar_mappings(source, 'test.
|
|
666
|
+
expect(() => compile_to_volar_mappings(source, 'test.tsrx', { loose: true })).not.toThrow();
|
|
653
667
|
|
|
654
|
-
const result = compile_to_volar_mappings(source, 'test.
|
|
668
|
+
const result = compile_to_volar_mappings(source, 'test.tsrx', { loose: true }).code;
|
|
655
669
|
|
|
656
670
|
expect(result).toContain('class StringMap extends Map<string, string> {}');
|
|
657
671
|
});
|
|
@@ -669,7 +683,7 @@ export component App() {
|
|
|
669
683
|
}
|
|
670
684
|
`;
|
|
671
685
|
|
|
672
|
-
const result = compile(source, 'test.
|
|
686
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' }).js.code;
|
|
673
687
|
|
|
674
688
|
expect(result).toContain('_$_.normalize_children(');
|
|
675
689
|
});
|
|
@@ -687,7 +701,7 @@ export component App() {
|
|
|
687
701
|
}
|
|
688
702
|
`;
|
|
689
703
|
|
|
690
|
-
const result = compile(source, 'test.
|
|
704
|
+
const result = compile(source, 'test.tsrx', { mode: 'client' }).js.code;
|
|
691
705
|
|
|
692
706
|
expect(result).toContain('_$_.spread_props(');
|
|
693
707
|
});
|