ripple 0.2.53 → 0.2.55
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 +1 -1
- package/src/compiler/phases/2-analyze/index.js +1 -32
- package/src/compiler/phases/3-transform/index.js +13 -84
- package/src/compiler/phases/3-transform/stylesheet.js +16 -3
- package/src/compiler/utils.js +0 -20
- package/src/runtime/array.js +158 -610
- package/src/runtime/index.js +3 -3
- package/src/runtime/internal/client/constants.js +1 -1
- package/src/runtime/internal/client/for.js +5 -5
- package/src/runtime/internal/client/index.js +1 -11
- package/src/runtime/internal/client/operations.js +0 -3
- package/src/runtime/internal/client/portal.js +5 -6
- package/src/runtime/internal/client/runtime.js +48 -315
- package/src/runtime/internal/client/utils.js +0 -10
- package/src/runtime/map.js +28 -15
- package/src/runtime/set.js +47 -21
- package/tests/array.test.ripple +75 -187
- package/tests/basic.test.ripple +33 -9
- package/tests/compiler.test.ripple +5 -5
- package/tests/composite.test.ripple +253 -3
- package/tests/for.test.ripple +3 -3
- package/tests/map.test.ripple +10 -10
- package/tests/ref.test.ripple +3 -3
- package/tests/set.test.ripple +7 -7
- package/types/index.d.ts +18 -31
package/package.json
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
is_event_attribute,
|
|
8
8
|
is_inside_component,
|
|
9
9
|
is_ripple_import,
|
|
10
|
-
is_tracked_computed_property,
|
|
11
10
|
is_void_element,
|
|
12
11
|
} from '../../utils.js';
|
|
13
12
|
import { extract_paths } from '../../../utils/ast.js';
|
|
@@ -166,37 +165,7 @@ const visitors = {
|
|
|
166
165
|
(declarator.init.callee.name === 'untrack' || declarator.init.callee.name === 'deferred');
|
|
167
166
|
|
|
168
167
|
if (declarator.id.type === 'Identifier') {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (binding !== null && parent?.type !== 'ForOfStatement') {
|
|
172
|
-
if (binding.initial?.type !== 'Literal') {
|
|
173
|
-
for (const ref of binding.references) {
|
|
174
|
-
const path = ref.path;
|
|
175
|
-
const parent_node = path?.at(-1);
|
|
176
|
-
|
|
177
|
-
// We're reading a computed property, which might mean it's a reactive property
|
|
178
|
-
if (
|
|
179
|
-
!ref.node.tracked &&
|
|
180
|
-
parent_node?.type === 'MemberExpression' &&
|
|
181
|
-
parent_node.computed
|
|
182
|
-
) {
|
|
183
|
-
binding.transform = {
|
|
184
|
-
assign: (node, value, computed) => {
|
|
185
|
-
if (!computed) {
|
|
186
|
-
return node;
|
|
187
|
-
}
|
|
188
|
-
return b.call('$.old_set_property', node, computed, value, b.id('__block'));
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
visit(declarator, state);
|
|
197
|
-
} else {
|
|
198
|
-
visit(declarator, state);
|
|
199
|
-
}
|
|
168
|
+
visit(declarator, state);
|
|
200
169
|
} else {
|
|
201
170
|
const paths = extract_paths(declarator.id);
|
|
202
171
|
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
is_ripple_import,
|
|
19
19
|
is_declared_function_within_component,
|
|
20
20
|
is_inside_call_expression,
|
|
21
|
-
is_tracked_computed_property,
|
|
22
21
|
is_value_static,
|
|
23
22
|
is_void_element,
|
|
24
23
|
is_component_level_function,
|
|
@@ -141,10 +140,6 @@ const visitors = {
|
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
if (node.name === 'structuredClone' && binding === null) {
|
|
145
|
-
return b.id('$.structured_clone');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
143
|
return build_getter(node, context);
|
|
149
144
|
}
|
|
150
145
|
}
|
|
@@ -225,11 +220,14 @@ const visitors = {
|
|
|
225
220
|
return b.call(
|
|
226
221
|
'$.with_scope',
|
|
227
222
|
b.id('__block'),
|
|
228
|
-
b.thunk(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
b.thunk(
|
|
224
|
+
{
|
|
225
|
+
...node,
|
|
226
|
+
callee: context.visit(callee),
|
|
227
|
+
arguments: node.arguments.map((arg) => context.visit(arg)),
|
|
228
|
+
},
|
|
229
|
+
context.state.metadata?.await ?? false,
|
|
230
|
+
),
|
|
233
231
|
);
|
|
234
232
|
},
|
|
235
233
|
|
|
@@ -303,20 +301,6 @@ const visitors = {
|
|
|
303
301
|
const object = node.object;
|
|
304
302
|
const property = node.property;
|
|
305
303
|
|
|
306
|
-
// TODO should we enforce that the identifier is tracked too?
|
|
307
|
-
if (node.computed && is_tracked_computed_property(node.object, node.property, context)) {
|
|
308
|
-
if (context.state.metadata?.tracking === false) {
|
|
309
|
-
context.state.metadata.tracking = true;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return b.call(
|
|
313
|
-
'$.old_get_property',
|
|
314
|
-
context.visit(object),
|
|
315
|
-
context.visit(property),
|
|
316
|
-
node.optional ? b.true : undefined,
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
304
|
if (object.type === 'Identifier' && object.name === 'Object') {
|
|
321
305
|
const binding = context.state.scope.get(object.name);
|
|
322
306
|
|
|
@@ -359,16 +343,6 @@ const visitors = {
|
|
|
359
343
|
}
|
|
360
344
|
},
|
|
361
345
|
|
|
362
|
-
SpreadElement(node, context) {
|
|
363
|
-
const parent = context.path.at(-1);
|
|
364
|
-
|
|
365
|
-
if (parent.type === 'ObjectExpression') {
|
|
366
|
-
return b.spread(b.call('$.spread_object', context.visit(node.argument)));
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
context.next();
|
|
370
|
-
},
|
|
371
|
-
|
|
372
346
|
VariableDeclaration(node, context) {
|
|
373
347
|
const declarations = [];
|
|
374
348
|
|
|
@@ -635,7 +609,7 @@ const visitors = {
|
|
|
635
609
|
}
|
|
636
610
|
}
|
|
637
611
|
} else if (attr.type === 'SpreadAttribute') {
|
|
638
|
-
spread_attributes.push(b.spread(
|
|
612
|
+
spread_attributes.push(b.spread(visit(attr.argument, state)));
|
|
639
613
|
} else if (attr.type === 'RefAttribute') {
|
|
640
614
|
const id = state.flush_node();
|
|
641
615
|
state.init.push(b.stmt(b.call('$.ref', id, b.thunk(visit(attr.argument, state)))));
|
|
@@ -735,10 +709,7 @@ const visitors = {
|
|
|
735
709
|
} else if (attr.type === 'SpreadAttribute') {
|
|
736
710
|
props.push(
|
|
737
711
|
b.spread(
|
|
738
|
-
|
|
739
|
-
'$.spread_object',
|
|
740
|
-
visit(attr.argument, { ...state, metadata: { ...state.metadata, spread: true } }),
|
|
741
|
-
),
|
|
712
|
+
visit(attr.argument, { ...state, metadata: { ...state.metadata, spread: true } }),
|
|
742
713
|
),
|
|
743
714
|
);
|
|
744
715
|
} else if (attr.type === 'RefAttribute') {
|
|
@@ -823,7 +794,7 @@ const visitors = {
|
|
|
823
794
|
b.call(
|
|
824
795
|
node.id,
|
|
825
796
|
id,
|
|
826
|
-
b.call('$.
|
|
797
|
+
b.call('$.spread_props', b.thunk(b.object(props)), b.id('__block')),
|
|
827
798
|
b.id('$.active_block'),
|
|
828
799
|
),
|
|
829
800
|
),
|
|
@@ -952,23 +923,6 @@ const visitors = {
|
|
|
952
923
|
);
|
|
953
924
|
}
|
|
954
925
|
|
|
955
|
-
if (left.type === 'MemberExpression') {
|
|
956
|
-
// need to capture setting length of array to throw a runtime error
|
|
957
|
-
if (left.property.type === 'Identifier' && left.property.name === 'length') {
|
|
958
|
-
if (left.property.name !== '$length') {
|
|
959
|
-
return b.call(
|
|
960
|
-
'$.old_set_property',
|
|
961
|
-
context.visit(left.object),
|
|
962
|
-
left.computed ? context.visit(left.property) : b.literal(left.property.name),
|
|
963
|
-
visit_assignment_expression(node, context, build_assignment) ?? context.next(),
|
|
964
|
-
b.id('__block'),
|
|
965
|
-
);
|
|
966
|
-
}
|
|
967
|
-
} else if (!is_tracked_computed_property(left.object, left.property, context)) {
|
|
968
|
-
return context.next();
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
926
|
if (left.type === 'Identifier' && left.tracked) {
|
|
973
927
|
add_ripple_internal_import(context);
|
|
974
928
|
const operator = node.operator;
|
|
@@ -990,18 +944,7 @@ const visitors = {
|
|
|
990
944
|
);
|
|
991
945
|
}
|
|
992
946
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
if (
|
|
996
|
-
left.type === 'MemberExpression' &&
|
|
997
|
-
left.property.type === 'Identifier' &&
|
|
998
|
-
left.property.name === '$length' &&
|
|
999
|
-
!left.computed
|
|
1000
|
-
) {
|
|
1001
|
-
return b.call('$.with_scope', b.id('__block'), b.thunk(visited));
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
return visited;
|
|
947
|
+
return visit_assignment_expression(node, context, build_assignment) ?? context.next();
|
|
1005
948
|
},
|
|
1006
949
|
|
|
1007
950
|
UpdateExpression(node, context) {
|
|
@@ -1028,20 +971,6 @@ const visitors = {
|
|
|
1028
971
|
);
|
|
1029
972
|
}
|
|
1030
973
|
|
|
1031
|
-
if (
|
|
1032
|
-
argument.type === 'MemberExpression' &&
|
|
1033
|
-
argument.computed &&
|
|
1034
|
-
is_tracked_computed_property(argument.object, argument.property, context)
|
|
1035
|
-
) {
|
|
1036
|
-
return b.call(
|
|
1037
|
-
node.prefix ? '$.old_update_pre_property' : '$.old_update_property',
|
|
1038
|
-
context.visit(argument.object),
|
|
1039
|
-
argument.computed ? context.visit(argument.property) : b.literal(argument.property.name),
|
|
1040
|
-
b.id('__block'),
|
|
1041
|
-
node.operator === '--' ? b.literal(-1) : undefined,
|
|
1042
|
-
);
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
974
|
if (argument.type === 'Identifier' && argument.tracked) {
|
|
1046
975
|
return b.call(
|
|
1047
976
|
node.prefix ? '$.update_pre' : '$.update',
|
|
@@ -1543,7 +1472,7 @@ function transform_children(children, context) {
|
|
|
1543
1472
|
if (
|
|
1544
1473
|
node.type === 'VariableDeclaration' ||
|
|
1545
1474
|
node.type === 'ExpressionStatement' ||
|
|
1546
|
-
|
|
1475
|
+
node.type === 'ThrowStatement' ||
|
|
1547
1476
|
node.type === 'FunctionDeclaration' ||
|
|
1548
1477
|
node.type === 'DebuggerStatement' ||
|
|
1549
1478
|
node.type === 'ClassDeclaration'
|
|
@@ -62,6 +62,10 @@ function escape_comment_close(node, code) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function append_hash(state, index) {
|
|
66
|
+
state.code.prependRight(index, `${state.hash}-`);
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
/**
|
|
66
70
|
* @param {AST.CSS.Rule} rule
|
|
67
71
|
* @param {boolean} is_in_global_block
|
|
@@ -106,7 +110,9 @@ const visitors = {
|
|
|
106
110
|
if (node.prelude.startsWith('-global-')) {
|
|
107
111
|
state.code.remove(start, start + 8);
|
|
108
112
|
} else if (!is_in_global_block(path)) {
|
|
109
|
-
state
|
|
113
|
+
append_hash(state, start);
|
|
114
|
+
state.keyframes[node.prelude]?.indexes.forEach((index) => append_hash(state, index));
|
|
115
|
+
state.keyframes[node.prelude] = { indexes: [], local: true };
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
return; // don't transform anything within
|
|
@@ -124,8 +130,14 @@ const visitors = {
|
|
|
124
130
|
const character = state.code.original[index];
|
|
125
131
|
|
|
126
132
|
if (regex_css_name_boundary.test(character)) {
|
|
127
|
-
if (
|
|
128
|
-
|
|
133
|
+
if (character !== ' ') {
|
|
134
|
+
const append_index = index - name.length;
|
|
135
|
+
state.keyframes[name] ??= { indexes: [], local: undefined };
|
|
136
|
+
if (state.keyframes[name].local) {
|
|
137
|
+
append_hash(state, append_index);
|
|
138
|
+
} else {
|
|
139
|
+
state.keyframes[name].indexes.push(append_index);
|
|
140
|
+
}
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
if (character === ';' || character === '}') {
|
|
@@ -360,6 +372,7 @@ export function render_stylesheets(stylesheets) {
|
|
|
360
372
|
code,
|
|
361
373
|
hash: stylesheet.hash,
|
|
362
374
|
selector: `.${stylesheet.hash}`,
|
|
375
|
+
keyframes: {},
|
|
363
376
|
specificity: {
|
|
364
377
|
bumped: false,
|
|
365
378
|
},
|
package/src/compiler/utils.js
CHANGED
|
@@ -454,26 +454,6 @@ export function is_value_static(node) {
|
|
|
454
454
|
return false;
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
export function is_tracked_computed_property(object, property, context) {
|
|
458
|
-
if (object.tracked) {
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
const binding = context.state.scope.get(object.name);
|
|
462
|
-
|
|
463
|
-
if (binding) {
|
|
464
|
-
const initial = binding.initial;
|
|
465
|
-
if (initial && is_value_static(initial)) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
if (property.type === 'Identifier') {
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// TODO: do we need to handle more logic here? default to false for now
|
|
474
|
-
return true;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
457
|
export function is_ripple_import(callee, context) {
|
|
478
458
|
if (callee.type === 'Identifier') {
|
|
479
459
|
const binding = context.state.scope.get(callee.name);
|