ripple 0.3.9 → 0.3.11
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 +43 -0
- package/package.json +2 -2
- package/src/compiler/errors.js +1 -1
- package/src/compiler/index.d.ts +3 -1
- package/src/compiler/phases/1-parse/index.js +195 -23
- package/src/compiler/phases/2-analyze/index.js +266 -108
- package/src/compiler/phases/2-analyze/prune.js +13 -5
- package/src/compiler/phases/3-transform/client/index.js +304 -80
- package/src/compiler/phases/3-transform/server/index.js +108 -43
- package/src/compiler/types/index.d.ts +28 -3
- package/src/compiler/types/parse.d.ts +3 -1
- package/src/compiler/utils.js +275 -1
- package/src/runtime/element.js +39 -0
- package/src/runtime/index-client.js +14 -4
- package/src/runtime/internal/client/composite.js +10 -6
- package/src/runtime/internal/client/expression.js +280 -0
- package/src/runtime/internal/client/index.js +4 -0
- package/src/runtime/internal/client/portal.js +12 -6
- package/src/runtime/internal/server/index.js +26 -1
- package/src/utils/builders.js +30 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.ripple.snap +1 -0
- package/tests/client/basic/basic.components.test.ripple +85 -87
- package/tests/client/basic/basic.errors.test.ripple +4 -8
- package/tests/client/basic/basic.rendering.test.ripple +27 -10
- package/tests/client/capture-error.js +12 -0
- package/tests/client/compiler/compiler.basic.test.ripple +76 -6
- package/tests/client/composite/composite.props.test.ripple +1 -3
- package/tests/client/composite/composite.render.test.ripple +91 -13
- package/tests/client/css/global-additional-cases.test.ripple +3 -3
- package/tests/client/return.test.ripple +101 -0
- package/tests/client/svg.test.ripple +4 -4
- package/tests/client/tsx.test.ripple +486 -0
- package/tests/hydration/basic.test.js +23 -0
- package/tests/hydration/compiled/client/basic.js +111 -75
- package/tests/hydration/compiled/client/composite.js +81 -46
- package/tests/hydration/compiled/client/events.js +18 -63
- package/tests/hydration/compiled/client/for.js +90 -183
- package/tests/hydration/compiled/client/head.js +10 -25
- package/tests/hydration/compiled/client/hmr.js +10 -13
- package/tests/hydration/compiled/client/html.js +251 -380
- package/tests/hydration/compiled/client/if-children.js +35 -45
- package/tests/hydration/compiled/client/if.js +2 -2
- package/tests/hydration/compiled/client/mixed-control-flow.js +24 -72
- package/tests/hydration/compiled/client/nested-control-flow.js +115 -391
- package/tests/hydration/compiled/client/portal.js +8 -20
- package/tests/hydration/compiled/client/reactivity.js +14 -47
- package/tests/hydration/compiled/client/return.js +2 -5
- package/tests/hydration/compiled/client/try.js +4 -4
- package/tests/hydration/compiled/server/basic.js +64 -31
- package/tests/hydration/compiled/server/composite.js +62 -29
- package/tests/hydration/compiled/server/hmr.js +24 -37
- package/tests/hydration/compiled/server/html.js +472 -611
- package/tests/hydration/compiled/server/if-children.js +77 -103
- package/tests/hydration/compiled/server/portal.js +8 -8
- package/tests/hydration/components/basic.ripple +15 -5
- package/tests/hydration/components/composite.ripple +13 -1
- package/tests/hydration/components/hmr.ripple +1 -3
- package/tests/hydration/components/html.ripple +13 -35
- package/tests/hydration/components/if-children.ripple +4 -8
- package/tests/hydration/composite.test.js +11 -0
- package/tests/server/basic.attributes.test.ripple +50 -0
- package/tests/server/basic.components.test.ripple +22 -28
- package/tests/server/basic.test.ripple +12 -0
- package/tests/server/compiler.test.ripple +25 -8
- package/tests/server/composite.props.test.ripple +1 -3
- package/tests/server/style-identifier.test.ripple +2 -4
- package/tests/utils/compiler-compat-config.test.js +38 -0
- package/tests/utils/vite-plugin-config.test.js +113 -0
- package/tsconfig.typecheck.json +2 -1
- package/types/index.d.ts +8 -11
|
@@ -42,9 +42,9 @@ export function IfWithChildren(__anchor, { children }, __block) {
|
|
|
42
42
|
var div_3 = root_1();
|
|
43
43
|
|
|
44
44
|
{
|
|
45
|
-
var
|
|
45
|
+
var expression = _$_.child(div_3);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
_$_.expression(expression, () => children);
|
|
48
48
|
_$_.pop(div_3);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -63,15 +63,15 @@ export function IfWithChildren(__anchor, { children }, __block) {
|
|
|
63
63
|
_$_.pop_component();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function ChildItem(__anchor, { text }, __block) {
|
|
66
|
+
export function ChildItem(__anchor, { text: label }, __block) {
|
|
67
67
|
_$_.push_component();
|
|
68
68
|
|
|
69
69
|
var div_4 = root_2();
|
|
70
70
|
|
|
71
71
|
{
|
|
72
|
-
var
|
|
72
|
+
var expression_1 = _$_.child(div_4, true);
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
_$_.expression(expression_1, () => label);
|
|
75
75
|
_$_.pop(div_4);
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -83,25 +83,22 @@ export function TestIfWithChildren(__anchor, _, __block) {
|
|
|
83
83
|
_$_.push_component();
|
|
84
84
|
|
|
85
85
|
var fragment = root_3();
|
|
86
|
-
var
|
|
86
|
+
var node_1 = _$_.first_child_frag(fragment);
|
|
87
87
|
|
|
88
88
|
IfWithChildren(
|
|
89
|
-
|
|
89
|
+
node_1,
|
|
90
90
|
{
|
|
91
|
-
children(__anchor,
|
|
92
|
-
_$_.push_component();
|
|
93
|
-
|
|
91
|
+
children: _$_.ripple_element(function render_children(__anchor, __block) {
|
|
94
92
|
var fragment_1 = root_4();
|
|
95
|
-
var
|
|
93
|
+
var node_2 = _$_.first_child_frag(fragment_1);
|
|
96
94
|
|
|
97
|
-
ChildItem(
|
|
95
|
+
ChildItem(node_2, { text: "Item 1" }, _$_.active_block);
|
|
98
96
|
|
|
99
|
-
var
|
|
97
|
+
var node_3 = _$_.sibling(node_2);
|
|
100
98
|
|
|
101
|
-
ChildItem(
|
|
99
|
+
ChildItem(node_3, { text: "Item 2" }, _$_.active_block);
|
|
102
100
|
_$_.append(__anchor, fragment_1);
|
|
103
|
-
|
|
104
|
-
}
|
|
101
|
+
})
|
|
105
102
|
},
|
|
106
103
|
_$_.active_block
|
|
107
104
|
);
|
|
@@ -121,7 +118,7 @@ export function IfWithStaticChildren(__anchor, _, __block) {
|
|
|
121
118
|
|
|
122
119
|
div_6.__click = () => _$_.set(lazy_1, !_$_.get(lazy_1));
|
|
123
120
|
|
|
124
|
-
var
|
|
121
|
+
var node_4 = _$_.sibling(div_6);
|
|
125
122
|
|
|
126
123
|
{
|
|
127
124
|
var consequent_1 = (__anchor) => {
|
|
@@ -130,7 +127,7 @@ export function IfWithStaticChildren(__anchor, _, __block) {
|
|
|
130
127
|
_$_.append(__anchor, div_7);
|
|
131
128
|
};
|
|
132
129
|
|
|
133
|
-
_$_.if(
|
|
130
|
+
_$_.if(node_4, (__render) => {
|
|
134
131
|
if (_$_.get(lazy_1)) __render(consequent_1);
|
|
135
132
|
});
|
|
136
133
|
}
|
|
@@ -154,23 +151,23 @@ export function IfWithSiblingsAndChildren(__anchor, { children }, __block) {
|
|
|
154
151
|
div_8.__click = () => _$_.set(lazy_2, !_$_.get(lazy_2));
|
|
155
152
|
_$_.pop(div_8);
|
|
156
153
|
|
|
157
|
-
var
|
|
154
|
+
var node_5 = _$_.sibling(div_8);
|
|
158
155
|
|
|
159
156
|
{
|
|
160
157
|
var consequent_2 = (__anchor) => {
|
|
161
158
|
var div_9 = root_8();
|
|
162
159
|
|
|
163
160
|
{
|
|
164
|
-
var
|
|
161
|
+
var expression_2 = _$_.child(div_9);
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
_$_.expression(expression_2, () => children);
|
|
167
164
|
_$_.pop(div_9);
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
_$_.append(__anchor, div_9);
|
|
171
168
|
};
|
|
172
169
|
|
|
173
|
-
_$_.if(
|
|
170
|
+
_$_.if(node_5, (__render) => {
|
|
174
171
|
if (_$_.get(lazy_2)) __render(consequent_2);
|
|
175
172
|
});
|
|
176
173
|
}
|
|
@@ -186,25 +183,22 @@ export function TestIfWithSiblingsAndChildren(__anchor, _, __block) {
|
|
|
186
183
|
_$_.push_component();
|
|
187
184
|
|
|
188
185
|
var fragment_2 = root_9();
|
|
189
|
-
var
|
|
186
|
+
var node_6 = _$_.first_child_frag(fragment_2);
|
|
190
187
|
|
|
191
188
|
IfWithSiblingsAndChildren(
|
|
192
|
-
|
|
189
|
+
node_6,
|
|
193
190
|
{
|
|
194
|
-
children(__anchor,
|
|
195
|
-
_$_.push_component();
|
|
196
|
-
|
|
191
|
+
children: _$_.ripple_element(function render_children(__anchor, __block) {
|
|
197
192
|
var fragment_3 = root_10();
|
|
198
|
-
var
|
|
193
|
+
var node_7 = _$_.first_child_frag(fragment_3);
|
|
199
194
|
|
|
200
|
-
ChildItem(
|
|
195
|
+
ChildItem(node_7, { text: "Item A" }, _$_.active_block);
|
|
201
196
|
|
|
202
|
-
var
|
|
197
|
+
var node_8 = _$_.sibling(node_7);
|
|
203
198
|
|
|
204
|
-
ChildItem(
|
|
199
|
+
ChildItem(node_8, { text: "Item B" }, _$_.active_block);
|
|
205
200
|
_$_.append(__anchor, fragment_3);
|
|
206
|
-
|
|
207
|
-
}
|
|
201
|
+
})
|
|
208
202
|
},
|
|
209
203
|
_$_.active_block
|
|
210
204
|
);
|
|
@@ -225,7 +219,7 @@ export function ElementWithChildrenThenIf(__anchor, _, __block) {
|
|
|
225
219
|
|
|
226
220
|
_$_.pop(div_10);
|
|
227
221
|
|
|
228
|
-
var
|
|
222
|
+
var node_9 = _$_.sibling(div_10);
|
|
229
223
|
|
|
230
224
|
{
|
|
231
225
|
var consequent_3 = (__anchor) => {
|
|
@@ -234,7 +228,7 @@ export function ElementWithChildrenThenIf(__anchor, _, __block) {
|
|
|
234
228
|
_$_.append(__anchor, div_12);
|
|
235
229
|
};
|
|
236
230
|
|
|
237
|
-
_$_.if(
|
|
231
|
+
_$_.if(node_9, (__render) => {
|
|
238
232
|
if (_$_.get(lazy_3)) __render(consequent_3);
|
|
239
233
|
});
|
|
240
234
|
}
|
|
@@ -262,7 +256,7 @@ export function DeepNestingThenIf(__anchor, _, __block) {
|
|
|
262
256
|
|
|
263
257
|
_$_.pop(article_1);
|
|
264
258
|
|
|
265
|
-
var
|
|
259
|
+
var node_10 = _$_.sibling(article_1);
|
|
266
260
|
|
|
267
261
|
{
|
|
268
262
|
var consequent_4 = (__anchor) => {
|
|
@@ -271,7 +265,7 @@ export function DeepNestingThenIf(__anchor, _, __block) {
|
|
|
271
265
|
_$_.append(__anchor, footer_1);
|
|
272
266
|
};
|
|
273
267
|
|
|
274
|
-
_$_.if(
|
|
268
|
+
_$_.if(node_10, (__render) => {
|
|
275
269
|
if (_$_.get(lazy_4)) __render(consequent_4);
|
|
276
270
|
});
|
|
277
271
|
}
|
|
@@ -311,7 +305,7 @@ export function DomElementChildrenThenSibling(__anchor, _, __block) {
|
|
|
311
305
|
var div_15 = _$_.sibling(div_14);
|
|
312
306
|
|
|
313
307
|
{
|
|
314
|
-
var
|
|
308
|
+
var node_11 = _$_.child(div_15);
|
|
315
309
|
|
|
316
310
|
{
|
|
317
311
|
var consequent_5 = (__anchor) => {
|
|
@@ -326,7 +320,7 @@ export function DomElementChildrenThenSibling(__anchor, _, __block) {
|
|
|
326
320
|
_$_.append(__anchor, div_16);
|
|
327
321
|
};
|
|
328
322
|
|
|
329
|
-
_$_.if(
|
|
323
|
+
_$_.if(node_11, (__render) => {
|
|
330
324
|
if (_$_.get(lazy_5) === 'code') __render(consequent_5); else __render(alternate, false);
|
|
331
325
|
});
|
|
332
326
|
}
|
|
@@ -370,8 +364,9 @@ export function DomChildrenThenStaticSiblings(__anchor, _, __block) {
|
|
|
370
364
|
var li_1 = _$_.child(ul_1);
|
|
371
365
|
|
|
372
366
|
{
|
|
373
|
-
var
|
|
367
|
+
var expression_3 = _$_.child(li_1, true);
|
|
374
368
|
|
|
369
|
+
_$_.expression(expression_3, () => 'Item count: ' + _$_.with_scope(__block, () => String(_$_.get(lazy_6))));
|
|
375
370
|
_$_.pop(li_1);
|
|
376
371
|
}
|
|
377
372
|
}
|
|
@@ -383,11 +378,6 @@ export function DomChildrenThenStaticSiblings(__anchor, _, __block) {
|
|
|
383
378
|
|
|
384
379
|
button_5.__click = () => _$_.update(lazy_6);
|
|
385
380
|
_$_.next();
|
|
386
|
-
|
|
387
|
-
_$_.render(() => {
|
|
388
|
-
_$_.set_text(text_2, 'Item count: ' + _$_.with_scope(__block, () => String(_$_.get(lazy_6))));
|
|
389
|
-
});
|
|
390
|
-
|
|
391
381
|
_$_.append(__anchor, fragment_6, true);
|
|
392
382
|
_$_.pop_component();
|
|
393
383
|
}
|
|
@@ -188,8 +188,8 @@ export function NestedIf(__anchor, _, __block) {
|
|
|
188
188
|
var div_8 = root_13();
|
|
189
189
|
|
|
190
190
|
{
|
|
191
|
-
var
|
|
192
|
-
var node_6 = _$_.sibling(
|
|
191
|
+
var expression = _$_.child(div_8);
|
|
192
|
+
var node_6 = _$_.sibling(expression);
|
|
193
193
|
|
|
194
194
|
{
|
|
195
195
|
var consequent_5 = (__anchor) => {
|
|
@@ -66,27 +66,15 @@ export function MixedControlFlowStatic(__anchor, _, __block) {
|
|
|
66
66
|
var div_1 = root_4();
|
|
67
67
|
|
|
68
68
|
{
|
|
69
|
-
var
|
|
69
|
+
var expression = _$_.child(div_1, true);
|
|
70
70
|
|
|
71
|
+
_$_.expression(expression, () => `A-${_$_.get(pattern).id}`);
|
|
71
72
|
_$_.pop(div_1);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
_$_.render(
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (__prev.a !== __a) {
|
|
79
|
-
_$_.set_text(text, __prev.a = __a);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var __b = `row row-${_$_.get(pattern).id} kind-a`;
|
|
83
|
-
|
|
84
|
-
if (__prev.b !== __b) {
|
|
85
|
-
_$_.set_class(div_1, __prev.b = __b, void 0, true);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
{ a: ' ', b: Symbol() }
|
|
89
|
-
);
|
|
75
|
+
_$_.render(() => {
|
|
76
|
+
_$_.set_class(div_1, `row row-${_$_.get(pattern).id} kind-a`, void 0, true);
|
|
77
|
+
});
|
|
90
78
|
|
|
91
79
|
_$_.append(__anchor, div_1);
|
|
92
80
|
});
|
|
@@ -117,27 +105,15 @@ export function MixedControlFlowStatic(__anchor, _, __block) {
|
|
|
117
105
|
var div_3 = root_7();
|
|
118
106
|
|
|
119
107
|
{
|
|
120
|
-
var
|
|
108
|
+
var expression_1 = _$_.child(div_3, true);
|
|
121
109
|
|
|
110
|
+
_$_.expression(expression_1, () => `B-${_$_.get(pattern).id}`);
|
|
122
111
|
_$_.pop(div_3);
|
|
123
112
|
}
|
|
124
113
|
|
|
125
|
-
_$_.render(
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (__prev.a !== __a) {
|
|
130
|
-
_$_.set_text(text_1, __prev.a = __a);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
var __b = `row row-${_$_.get(pattern).id} kind-b`;
|
|
134
|
-
|
|
135
|
-
if (__prev.b !== __b) {
|
|
136
|
-
_$_.set_class(div_3, __prev.b = __b, void 0, true);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{ a: ' ', b: Symbol() }
|
|
140
|
-
);
|
|
114
|
+
_$_.render(() => {
|
|
115
|
+
_$_.set_class(div_3, `row row-${_$_.get(pattern).id} kind-b`, void 0, true);
|
|
116
|
+
});
|
|
141
117
|
|
|
142
118
|
_$_.append(__anchor, div_3);
|
|
143
119
|
});
|
|
@@ -244,27 +220,15 @@ export function MixedControlFlowReactive(__anchor, _, __block) {
|
|
|
244
220
|
var p_1 = root_13();
|
|
245
221
|
|
|
246
222
|
{
|
|
247
|
-
var
|
|
223
|
+
var expression_2 = _$_.child(p_1, true);
|
|
248
224
|
|
|
225
|
+
_$_.expression(expression_2, () => `A:${_$_.get(pattern_1).label}`);
|
|
249
226
|
_$_.pop(p_1);
|
|
250
227
|
}
|
|
251
228
|
|
|
252
|
-
_$_.render(
|
|
253
|
-
(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (__prev.a !== __a) {
|
|
257
|
-
_$_.set_text(text_2, __prev.a = __a);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
var __b = `item item-${_$_.get(pattern_1).id}`;
|
|
261
|
-
|
|
262
|
-
if (__prev.b !== __b) {
|
|
263
|
-
_$_.set_class(p_1, __prev.b = __b, void 0, true);
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
{ a: ' ', b: Symbol() }
|
|
267
|
-
);
|
|
229
|
+
_$_.render(() => {
|
|
230
|
+
_$_.set_class(p_1, `item item-${_$_.get(pattern_1).id}`, void 0, true);
|
|
231
|
+
});
|
|
268
232
|
|
|
269
233
|
_$_.append(__anchor, p_1);
|
|
270
234
|
});
|
|
@@ -291,27 +255,15 @@ export function MixedControlFlowReactive(__anchor, _, __block) {
|
|
|
291
255
|
var p_3 = root_16();
|
|
292
256
|
|
|
293
257
|
{
|
|
294
|
-
var
|
|
258
|
+
var expression_3 = _$_.child(p_3, true);
|
|
295
259
|
|
|
260
|
+
_$_.expression(expression_3, () => `B:${_$_.get(pattern_1).label}`);
|
|
296
261
|
_$_.pop(p_3);
|
|
297
262
|
}
|
|
298
263
|
|
|
299
|
-
_$_.render(
|
|
300
|
-
(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (__prev.a !== __a) {
|
|
304
|
-
_$_.set_text(text_3, __prev.a = __a);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
var __b = `item item-${_$_.get(pattern_1).id}`;
|
|
308
|
-
|
|
309
|
-
if (__prev.b !== __b) {
|
|
310
|
-
_$_.set_class(p_3, __prev.b = __b, void 0, true);
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
{ a: ' ', b: Symbol() }
|
|
314
|
-
);
|
|
264
|
+
_$_.render(() => {
|
|
265
|
+
_$_.set_class(p_3, `item item-${_$_.get(pattern_1).id}`, void 0, true);
|
|
266
|
+
});
|
|
315
267
|
|
|
316
268
|
_$_.append(__anchor, p_3);
|
|
317
269
|
});
|
|
@@ -407,9 +359,9 @@ export function MixedControlFlowAsyncPending(__anchor, _, __block) {
|
|
|
407
359
|
_$_.set_class(div_7, `pending-row pending-row-${row}`, void 0, true);
|
|
408
360
|
|
|
409
361
|
{
|
|
410
|
-
var
|
|
362
|
+
var expression_4 = _$_.child(div_7, true);
|
|
411
363
|
|
|
412
|
-
|
|
364
|
+
_$_.expression(expression_4, () => `pending ${row}`);
|
|
413
365
|
_$_.pop(div_7);
|
|
414
366
|
}
|
|
415
367
|
|
|
@@ -469,9 +421,9 @@ function AsyncRow(__anchor, { label }, __block) {
|
|
|
469
421
|
var div_9 = root_25();
|
|
470
422
|
|
|
471
423
|
{
|
|
472
|
-
var
|
|
424
|
+
var expression_5 = _$_.child(div_9, true);
|
|
473
425
|
|
|
474
|
-
|
|
426
|
+
_$_.expression(expression_5, () => value);
|
|
475
427
|
_$_.pop(div_9);
|
|
476
428
|
}
|
|
477
429
|
|