ripple 0.3.8 → 0.3.10
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 +19 -0
- package/package.json +2 -2
- package/src/compiler/phases/1-parse/index.js +38 -172
- package/src/compiler/phases/2-analyze/index.js +308 -115
- package/src/compiler/phases/2-analyze/prune.js +13 -5
- package/src/compiler/phases/3-transform/client/index.js +197 -213
- package/src/compiler/phases/3-transform/segments.js +0 -7
- package/src/compiler/phases/3-transform/server/index.js +77 -170
- package/src/compiler/types/acorn.d.ts +1 -1
- package/src/compiler/types/estree.d.ts +1 -1
- package/src/compiler/types/import.d.ts +0 -2
- package/src/compiler/types/index.d.ts +14 -18
- package/src/compiler/types/parse.d.ts +3 -9
- package/src/compiler/utils.js +154 -21
- package/src/runtime/element.js +39 -0
- package/src/runtime/index-client.js +2 -13
- package/src/runtime/index-server.js +2 -2
- package/src/runtime/internal/client/bindings.js +3 -1
- package/src/runtime/internal/client/composite.js +11 -6
- package/src/runtime/internal/client/events.js +1 -1
- package/src/runtime/internal/client/expression.js +218 -0
- package/src/runtime/internal/client/head.js +3 -4
- package/src/runtime/internal/client/index.js +4 -1
- package/src/runtime/internal/client/portal.js +12 -6
- package/src/runtime/internal/client/runtime.js +0 -52
- package/src/runtime/internal/server/index.js +57 -56
- package/tests/client/basic/basic.components.test.ripple +85 -87
- package/tests/client/basic/basic.errors.test.ripple +28 -4
- package/tests/client/basic/basic.reactivity.test.ripple +10 -155
- package/tests/client/basic/basic.rendering.test.ripple +23 -8
- package/tests/client/capture-error.js +12 -0
- package/tests/client/compiler/compiler.basic.test.ripple +107 -18
- package/tests/client/composite/composite.props.test.ripple +5 -9
- package/tests/client/composite/composite.reactivity.test.ripple +35 -36
- package/tests/client/composite/composite.render.test.ripple +45 -13
- package/tests/client/css/global-additional-cases.test.ripple +3 -3
- package/tests/client/dynamic-elements.test.ripple +3 -4
- package/tests/client/lazy-destructuring.test.ripple +69 -12
- package/tests/client/svg.test.ripple +4 -4
- package/tests/hydration/basic.test.js +23 -0
- package/tests/hydration/compiled/client/basic.js +118 -66
- package/tests/hydration/compiled/client/composite.js +90 -37
- package/tests/hydration/compiled/client/events.js +18 -18
- package/tests/hydration/compiled/client/for.js +62 -62
- package/tests/hydration/compiled/client/head.js +10 -10
- package/tests/hydration/compiled/client/hmr.js +13 -10
- package/tests/hydration/compiled/client/html.js +274 -236
- package/tests/hydration/compiled/client/if-children.js +41 -35
- package/tests/hydration/compiled/client/if.js +2 -2
- package/tests/hydration/compiled/client/mixed-control-flow.js +12 -12
- package/tests/hydration/compiled/client/nested-control-flow.js +46 -46
- package/tests/hydration/compiled/client/portal.js +8 -8
- package/tests/hydration/compiled/client/reactivity.js +14 -14
- package/tests/hydration/compiled/client/return.js +2 -2
- 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 +43 -4
- package/tests/server/composite.props.test.ripple +5 -9
- package/tests/server/dynamic-elements.test.ripple +3 -4
- package/tests/server/lazy-destructuring.test.ripple +68 -12
- package/tests/server/style-identifier.test.ripple +2 -4
- package/tsconfig.typecheck.json +4 -0
- package/types/index.d.ts +9 -21
- package/tests/client/__snapshots__/tracked-expression.test.ripple.snap +0 -34
- package/tests/client/tracked-expression.test.ripple +0 -26
|
@@ -23,11 +23,12 @@ import {
|
|
|
23
23
|
is_inside_component,
|
|
24
24
|
is_void_element,
|
|
25
25
|
normalize_children,
|
|
26
|
+
is_children_template_expression,
|
|
26
27
|
is_binding_function,
|
|
27
28
|
is_element_dynamic,
|
|
28
29
|
is_ripple_track_call,
|
|
29
30
|
is_ripple_import,
|
|
30
|
-
|
|
31
|
+
replace_lazy_param_pattern,
|
|
31
32
|
hash,
|
|
32
33
|
flatten_switch_consequent,
|
|
33
34
|
get_ripple_namespace_call_name,
|
|
@@ -51,6 +52,7 @@ import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../constants.js';
|
|
|
51
52
|
function is_template_or_control_flow(node) {
|
|
52
53
|
return (
|
|
53
54
|
node.type === 'Element' ||
|
|
55
|
+
node.type === 'RippleExpression' ||
|
|
54
56
|
node.type === 'Text' ||
|
|
55
57
|
node.type === 'Html' ||
|
|
56
58
|
node.type === 'TsxCompat' ||
|
|
@@ -355,7 +357,7 @@ const visitors = {
|
|
|
355
357
|
// Lazy destructuring: use __props identifier, bindings resolved via transforms
|
|
356
358
|
props_param_output = b.id('__props');
|
|
357
359
|
} else {
|
|
358
|
-
props_param_output = props_param;
|
|
360
|
+
props_param_output = replace_lazy_param_pattern(props_param);
|
|
359
361
|
}
|
|
360
362
|
} else {
|
|
361
363
|
props_param_output = props_param;
|
|
@@ -500,7 +502,7 @@ const visitors = {
|
|
|
500
502
|
|
|
501
503
|
const track_call_name = is_ripple_track_call(callee, context);
|
|
502
504
|
if (track_call_name) {
|
|
503
|
-
const track_method_name =
|
|
505
|
+
const track_method_name = 'track';
|
|
504
506
|
|
|
505
507
|
return {
|
|
506
508
|
...node,
|
|
@@ -597,16 +599,12 @@ const visitors = {
|
|
|
597
599
|
}
|
|
598
600
|
// Replace lazy destructuring params with generated identifiers
|
|
599
601
|
const pattern = param.type === 'AssignmentPattern' ? param.left : param;
|
|
600
|
-
if (
|
|
601
|
-
|
|
602
|
-
pattern.lazy &&
|
|
603
|
-
pattern.metadata?.lazy_id
|
|
604
|
-
) {
|
|
605
|
-
const id = b.id(pattern.metadata.lazy_id);
|
|
602
|
+
if (pattern.type === 'ObjectPattern' || pattern.type === 'ArrayPattern') {
|
|
603
|
+
const transformed_pattern = replace_lazy_param_pattern(pattern);
|
|
606
604
|
node.params[i] =
|
|
607
605
|
param.type === 'AssignmentPattern'
|
|
608
|
-
? /** @type {AST.AssignmentPattern} */ ({ ...param, left:
|
|
609
|
-
:
|
|
606
|
+
? /** @type {AST.AssignmentPattern} */ ({ ...param, left: transformed_pattern })
|
|
607
|
+
: transformed_pattern;
|
|
610
608
|
}
|
|
611
609
|
}
|
|
612
610
|
}
|
|
@@ -626,16 +624,12 @@ const visitors = {
|
|
|
626
624
|
}
|
|
627
625
|
// Replace lazy destructuring params with generated identifiers
|
|
628
626
|
const pattern = param.type === 'AssignmentPattern' ? param.left : param;
|
|
629
|
-
if (
|
|
630
|
-
|
|
631
|
-
pattern.lazy &&
|
|
632
|
-
pattern.metadata?.lazy_id
|
|
633
|
-
) {
|
|
634
|
-
const id = b.id(pattern.metadata.lazy_id);
|
|
627
|
+
if (pattern.type === 'ObjectPattern' || pattern.type === 'ArrayPattern') {
|
|
628
|
+
const transformed_pattern = replace_lazy_param_pattern(pattern);
|
|
635
629
|
node.params[i] =
|
|
636
630
|
param.type === 'AssignmentPattern'
|
|
637
|
-
? /** @type {AST.AssignmentPattern} */ ({ ...param, left:
|
|
638
|
-
:
|
|
631
|
+
? /** @type {AST.AssignmentPattern} */ ({ ...param, left: transformed_pattern })
|
|
632
|
+
: transformed_pattern;
|
|
639
633
|
}
|
|
640
634
|
}
|
|
641
635
|
}
|
|
@@ -665,16 +659,12 @@ const visitors = {
|
|
|
665
659
|
}
|
|
666
660
|
// Replace lazy destructuring params with generated identifiers
|
|
667
661
|
const pattern = param.type === 'AssignmentPattern' ? param.left : param;
|
|
668
|
-
if (
|
|
669
|
-
|
|
670
|
-
pattern.lazy &&
|
|
671
|
-
pattern.metadata?.lazy_id
|
|
672
|
-
) {
|
|
673
|
-
const id = b.id(pattern.metadata.lazy_id);
|
|
662
|
+
if (pattern.type === 'ObjectPattern' || pattern.type === 'ArrayPattern') {
|
|
663
|
+
const transformed_pattern = replace_lazy_param_pattern(pattern);
|
|
674
664
|
node.params[i] =
|
|
675
665
|
param.type === 'AssignmentPattern'
|
|
676
|
-
? /** @type {AST.AssignmentPattern} */ ({ ...param, left:
|
|
677
|
-
:
|
|
666
|
+
? /** @type {AST.AssignmentPattern} */ ({ ...param, left: transformed_pattern })
|
|
667
|
+
: transformed_pattern;
|
|
678
668
|
}
|
|
679
669
|
}
|
|
680
670
|
|
|
@@ -1094,7 +1084,7 @@ const visitors = {
|
|
|
1094
1084
|
} else {
|
|
1095
1085
|
/** @type {(AST.Property | AST.SpreadElement)[]} */
|
|
1096
1086
|
const props = [];
|
|
1097
|
-
/** @type {AST.
|
|
1087
|
+
/** @type {AST.Property | null} */
|
|
1098
1088
|
let children_prop = null;
|
|
1099
1089
|
|
|
1100
1090
|
const apply_parent_css_scope = state.applyParentCssScope;
|
|
@@ -1114,7 +1104,11 @@ const visitors = {
|
|
|
1114
1104
|
);
|
|
1115
1105
|
|
|
1116
1106
|
if (attr.name.name === 'children') {
|
|
1117
|
-
children_prop =
|
|
1107
|
+
children_prop = b.prop(
|
|
1108
|
+
'init',
|
|
1109
|
+
b.id('children'),
|
|
1110
|
+
b.call('_$_.normalize_children', property),
|
|
1111
|
+
);
|
|
1118
1112
|
continue;
|
|
1119
1113
|
}
|
|
1120
1114
|
|
|
@@ -1131,50 +1125,44 @@ const visitors = {
|
|
|
1131
1125
|
}
|
|
1132
1126
|
}
|
|
1133
1127
|
|
|
1134
|
-
const children_filtered =
|
|
1128
|
+
const children_filtered = node.children.filter(
|
|
1129
|
+
(child) => child.type !== 'EmptyStatement' && child.type !== 'Component',
|
|
1130
|
+
);
|
|
1135
1131
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1132
|
+
if (children_filtered.length > 0) {
|
|
1133
|
+
const component_scope = /** @type {ScopeInterface} */ (context.state.scopes.get(node));
|
|
1134
|
+
const children = b.call(
|
|
1135
|
+
'_$_.ripple_element',
|
|
1136
|
+
/** @type {AST.Expression} */ (
|
|
1137
|
+
visit(b.component(b.id('render_children'), [], children_filtered), {
|
|
1138
|
+
...context.state,
|
|
1139
|
+
...(apply_parent_css_scope ||
|
|
1140
|
+
(is_element_dynamic(node) && node.metadata.scoped && state.component?.css)
|
|
1141
|
+
? {
|
|
1142
|
+
applyParentCssScope:
|
|
1143
|
+
apply_parent_css_scope ||
|
|
1144
|
+
/** @type {AST.CSS.StyleSheet} */ (state.component?.css).hash,
|
|
1145
|
+
}
|
|
1146
|
+
: {}),
|
|
1147
|
+
scope: component_scope,
|
|
1148
|
+
namespace: child_namespace,
|
|
1149
|
+
})
|
|
1150
|
+
),
|
|
1151
|
+
);
|
|
1152
|
+
|
|
1153
|
+
if (children_prop) {
|
|
1154
|
+
children_prop.value = b.logical(
|
|
1155
|
+
'??',
|
|
1156
|
+
/** @type {AST.Expression} */ (children_prop.value),
|
|
1157
|
+
children,
|
|
1149
1158
|
);
|
|
1150
1159
|
} else {
|
|
1151
|
-
|
|
1160
|
+
children_prop = b.prop('init', b.id('children'), children);
|
|
1152
1161
|
}
|
|
1153
1162
|
}
|
|
1154
1163
|
|
|
1155
1164
|
if (children_prop) {
|
|
1156
|
-
props.push(
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
if (children_filtered.length > 0) {
|
|
1160
|
-
const component_scope = /** @type {ScopeInterface} */ (context.state.scopes.get(node));
|
|
1161
|
-
const children = /** @type {AST.Expression} */ (
|
|
1162
|
-
visit(b.component(b.id('children'), [], children_filtered), {
|
|
1163
|
-
...context.state,
|
|
1164
|
-
...(apply_parent_css_scope ||
|
|
1165
|
-
(is_element_dynamic(node) && node.metadata.scoped && state.component?.css)
|
|
1166
|
-
? {
|
|
1167
|
-
applyParentCssScope:
|
|
1168
|
-
apply_parent_css_scope ||
|
|
1169
|
-
/** @type {AST.CSS.StyleSheet} */ (state.component?.css).hash,
|
|
1170
|
-
}
|
|
1171
|
-
: {}),
|
|
1172
|
-
scope: component_scope,
|
|
1173
|
-
namespace: child_namespace,
|
|
1174
|
-
})
|
|
1175
|
-
);
|
|
1176
|
-
|
|
1177
|
-
props.push(b.prop('init', b.id('children'), children));
|
|
1165
|
+
props.push(children_prop);
|
|
1178
1166
|
}
|
|
1179
1167
|
|
|
1180
1168
|
// For SSR, determine if we should await based on component metadata
|
|
@@ -1429,53 +1417,6 @@ const visitors = {
|
|
|
1429
1417
|
}
|
|
1430
1418
|
}
|
|
1431
1419
|
|
|
1432
|
-
if (
|
|
1433
|
-
left.type === 'MemberExpression' &&
|
|
1434
|
-
(left.tracked || (left.property.type === 'Identifier' && left.property.tracked))
|
|
1435
|
-
) {
|
|
1436
|
-
const operator = node.operator;
|
|
1437
|
-
const right = node.right;
|
|
1438
|
-
|
|
1439
|
-
return b.call(
|
|
1440
|
-
'_$_.set_property',
|
|
1441
|
-
/** @type {AST.Expression} */ (context.visit(left.object)),
|
|
1442
|
-
left.computed
|
|
1443
|
-
? /** @type {AST.Expression} */ (context.visit(left.property))
|
|
1444
|
-
: b.literal(/** @type {AST.Identifier} */ (left.property).name),
|
|
1445
|
-
operator === '='
|
|
1446
|
-
? /** @type {AST.Expression} */ (context.visit(right))
|
|
1447
|
-
: b.binary(
|
|
1448
|
-
operator === '+=' ? '+' : operator === '-=' ? '-' : operator === '*=' ? '*' : '/',
|
|
1449
|
-
b.call(
|
|
1450
|
-
'_$_.get_property',
|
|
1451
|
-
/** @type {AST.Expression} */ (context.visit(left.object)),
|
|
1452
|
-
left.computed
|
|
1453
|
-
? /** @type {AST.Expression} */ (context.visit(left.property))
|
|
1454
|
-
: b.literal(/** @type {AST.Identifier} */ (left.property).name),
|
|
1455
|
-
undefined,
|
|
1456
|
-
),
|
|
1457
|
-
/** @type {AST.Expression} */ (context.visit(right)),
|
|
1458
|
-
),
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
if (left.type === 'Identifier' && left.tracked) {
|
|
1463
|
-
const operator = node.operator;
|
|
1464
|
-
const right = node.right;
|
|
1465
|
-
|
|
1466
|
-
return b.call(
|
|
1467
|
-
'_$_.set',
|
|
1468
|
-
/** @type {AST.Expression} */ (context.visit(left)),
|
|
1469
|
-
operator === '='
|
|
1470
|
-
? /** @type {AST.Expression} */ (context.visit(right))
|
|
1471
|
-
: b.binary(
|
|
1472
|
-
operator === '+=' ? '+' : operator === '-=' ? '-' : operator === '*=' ? '*' : '/',
|
|
1473
|
-
b.call('_$_.get', left),
|
|
1474
|
-
/** @type {AST.Expression} */ (context.visit(right)),
|
|
1475
|
-
),
|
|
1476
|
-
);
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
1420
|
return context.next();
|
|
1480
1421
|
},
|
|
1481
1422
|
|
|
@@ -1489,39 +1430,6 @@ const visitors = {
|
|
|
1489
1430
|
return binding.transform.update(node);
|
|
1490
1431
|
}
|
|
1491
1432
|
}
|
|
1492
|
-
|
|
1493
|
-
if (
|
|
1494
|
-
argument.type === 'MemberExpression' &&
|
|
1495
|
-
(argument.tracked || (argument.property.type === 'Identifier' && argument.property.tracked))
|
|
1496
|
-
) {
|
|
1497
|
-
return b.call(
|
|
1498
|
-
node.prefix ? '_$_.update_pre_property' : '_$_.update_property',
|
|
1499
|
-
/** @type {AST.Expression} */
|
|
1500
|
-
(context.visit(argument.object, { ...context.state, metadata: { tracking: false } })),
|
|
1501
|
-
argument.computed
|
|
1502
|
-
? /** @type {AST.Expression} */ (context.visit(argument.property))
|
|
1503
|
-
: b.literal(/** @type {AST.Identifier} */ (argument.property).name),
|
|
1504
|
-
node.operator === '--' ? b.literal(-1) : undefined,
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
if (argument.type === 'Identifier' && argument.tracked) {
|
|
1509
|
-
return b.call(
|
|
1510
|
-
node.prefix ? '_$_.update_pre' : '_$_.update',
|
|
1511
|
-
/** @type {AST.Expression} */
|
|
1512
|
-
(context.visit(argument)),
|
|
1513
|
-
node.operator === '--' ? b.literal(-1) : undefined,
|
|
1514
|
-
);
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
if (argument.type === 'TrackedExpression') {
|
|
1518
|
-
return b.call(
|
|
1519
|
-
node.prefix ? '_$_.update_pre' : '_$_.update',
|
|
1520
|
-
/** @type {AST.Expression} */
|
|
1521
|
-
(context.visit(argument.argument)),
|
|
1522
|
-
node.operator === '--' ? b.literal(-1) : undefined,
|
|
1523
|
-
);
|
|
1524
|
-
}
|
|
1525
1433
|
},
|
|
1526
1434
|
|
|
1527
1435
|
ServerIdentifier(node, context) {
|
|
@@ -1703,36 +1611,14 @@ const visitors = {
|
|
|
1703
1611
|
return b.await(/** @type {AST.AwaitExpression} */ (context.visit(node.argument)));
|
|
1704
1612
|
},
|
|
1705
1613
|
|
|
1706
|
-
TrackedExpression(node, context) {
|
|
1707
|
-
return b.call('_$_.get', /** @type {AST.Expression} */ (context.visit(node.argument)));
|
|
1708
|
-
},
|
|
1709
|
-
|
|
1710
1614
|
MemberExpression(node, context) {
|
|
1711
|
-
if (
|
|
1712
|
-
node.tracked ||
|
|
1713
|
-
((node.property.type === 'Identifier' || node.property.type === 'Literal') &&
|
|
1714
|
-
node.property.tracked)
|
|
1715
|
-
) {
|
|
1716
|
-
return b.call(
|
|
1717
|
-
'_$_.get_property',
|
|
1718
|
-
/** @type {AST.Expression} */ (context.visit(node.object)),
|
|
1719
|
-
node.computed
|
|
1720
|
-
? /** @type {AST.Expression} */ (context.visit(node.property))
|
|
1721
|
-
: b.literal(/** @type {AST.Identifier} */ (node.property).name),
|
|
1722
|
-
node.optional ? b.true : undefined,
|
|
1723
|
-
);
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
1615
|
return context.next();
|
|
1727
1616
|
},
|
|
1728
1617
|
|
|
1729
|
-
|
|
1618
|
+
RippleExpression(node, { visit, state }) {
|
|
1730
1619
|
const metadata = { await: false };
|
|
1731
1620
|
let expression = /** @type {AST.Expression} */ (visit(node.expression, { ...state, metadata }));
|
|
1732
|
-
|
|
1733
|
-
if (expression.type === 'Identifier' && expression.tracked) {
|
|
1734
|
-
expression = b.call('_$_.get', expression);
|
|
1735
|
-
}
|
|
1621
|
+
const is_children_expression = is_children_template_expression(node.expression, state.scope);
|
|
1736
1622
|
|
|
1737
1623
|
if (expression.type === 'Literal') {
|
|
1738
1624
|
state.init?.push(
|
|
@@ -1740,6 +1626,8 @@ const visitors = {
|
|
|
1740
1626
|
b.call(b.member(b.id('__output'), b.id('push')), b.literal(escape(expression.value))),
|
|
1741
1627
|
),
|
|
1742
1628
|
);
|
|
1629
|
+
} else if (is_children_expression) {
|
|
1630
|
+
state.init?.push(b.stmt(b.call('_$_.render_expression', b.id('__output'), expression)));
|
|
1743
1631
|
} else {
|
|
1744
1632
|
state.init?.push(
|
|
1745
1633
|
b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.call('_$_.escape', expression))),
|
|
@@ -1747,6 +1635,25 @@ const visitors = {
|
|
|
1747
1635
|
}
|
|
1748
1636
|
},
|
|
1749
1637
|
|
|
1638
|
+
Text(node, context) {
|
|
1639
|
+
const metadata = { await: false };
|
|
1640
|
+
let expression = /** @type {AST.Expression} */ (
|
|
1641
|
+
context.visit(node.expression, { ...context.state, metadata })
|
|
1642
|
+
);
|
|
1643
|
+
|
|
1644
|
+
if (expression.type === 'Literal') {
|
|
1645
|
+
context.state.init?.push(
|
|
1646
|
+
b.stmt(
|
|
1647
|
+
b.call(b.member(b.id('__output'), b.id('push')), b.literal(escape(expression.value))),
|
|
1648
|
+
),
|
|
1649
|
+
);
|
|
1650
|
+
} else {
|
|
1651
|
+
context.state.init?.push(
|
|
1652
|
+
b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.call('_$_.escape', expression))),
|
|
1653
|
+
);
|
|
1654
|
+
}
|
|
1655
|
+
},
|
|
1656
|
+
|
|
1750
1657
|
Html(node, { visit, state }) {
|
|
1751
1658
|
const metadata = { await: false };
|
|
1752
1659
|
const expression = /** @type {AST.Expression} */ (
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The relative import of './parser' loads the augmentation declarations
|
|
8
8
|
// (declare module 'acorn' { ... }) so the re-exported types include
|
|
9
|
-
// Ripple-specific nodes like Component, Element,
|
|
9
|
+
// Ripple-specific nodes like Component, Element, etc.
|
|
10
10
|
import './parser.d.ts';
|
|
11
11
|
export * from 'acorn';
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The relative import of './index' loads the augmentation declarations
|
|
8
8
|
// (declare module 'estree' { ... }) so the re-exported types include
|
|
9
|
-
// Ripple-specific nodes like Component, Element,
|
|
9
|
+
// Ripple-specific nodes like Component, Element, etc.
|
|
10
10
|
import './index';
|
|
11
11
|
export * from 'estree';
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
MediaQuery as _$_MediaQuery__,
|
|
42
42
|
createRefKey as _$_RefKey__create,
|
|
43
43
|
track as _$_track__,
|
|
44
|
-
trackSplit as _$_trackSplit__,
|
|
45
44
|
effect as _$_effect__,
|
|
46
45
|
untrack as _$_untrack__,
|
|
47
46
|
ripple_namespace as _$__u0023_ripple,
|
|
@@ -59,7 +58,6 @@ export {
|
|
|
59
58
|
_$_MediaQuery__,
|
|
60
59
|
_$_RefKey__create,
|
|
61
60
|
_$_track__,
|
|
62
|
-
_$_trackSplit__,
|
|
63
61
|
_$_effect__,
|
|
64
62
|
_$_untrack__,
|
|
65
63
|
_$__u0023_ripple,
|
|
@@ -116,19 +116,17 @@ declare module 'estree' {
|
|
|
116
116
|
|
|
117
117
|
// We mark the whole node as marked when member is @[expression]
|
|
118
118
|
// Otherwise, we only mark Identifier nodes
|
|
119
|
-
interface MemberExpression
|
|
119
|
+
interface MemberExpression {}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
interface
|
|
124
|
-
interface RegExpLiteral extends AST.LiteralTrackedNode {}
|
|
125
|
-
interface BigIntLiteral extends AST.LiteralTrackedNode {}
|
|
121
|
+
interface SimpleLiteral extends AST.LiteralNode {}
|
|
122
|
+
interface RegExpLiteral extends AST.LiteralNode {}
|
|
123
|
+
interface BigIntLiteral extends AST.LiteralNode {}
|
|
126
124
|
|
|
127
125
|
interface TrackedNode {
|
|
128
126
|
tracked?: boolean;
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
interface
|
|
129
|
+
interface LiteralNode {
|
|
132
130
|
was_expression?: boolean;
|
|
133
131
|
}
|
|
134
132
|
|
|
@@ -136,6 +134,7 @@ declare module 'estree' {
|
|
|
136
134
|
interface NodeMap {
|
|
137
135
|
Component: Component;
|
|
138
136
|
TsxCompat: TsxCompat;
|
|
137
|
+
RippleExpression: RippleExpression;
|
|
139
138
|
Html: Html;
|
|
140
139
|
Element: Element;
|
|
141
140
|
Text: TextNode;
|
|
@@ -143,7 +142,6 @@ declare module 'estree' {
|
|
|
143
142
|
ServerBlockStatement: ServerBlockStatement;
|
|
144
143
|
ServerIdentifier: ServerIdentifier;
|
|
145
144
|
StyleIdentifier: StyleIdentifier;
|
|
146
|
-
TrackedExpression: TrackedExpression;
|
|
147
145
|
Attribute: Attribute;
|
|
148
146
|
RefAttribute: RefAttribute;
|
|
149
147
|
SpreadAttribute: SpreadAttribute;
|
|
@@ -152,7 +150,6 @@ declare module 'estree' {
|
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
interface ExpressionMap {
|
|
155
|
-
TrackedExpression: TrackedExpression;
|
|
156
153
|
StyleIdentifier: StyleIdentifier;
|
|
157
154
|
ServerIdentifier: ServerIdentifier;
|
|
158
155
|
Text: TextNode;
|
|
@@ -286,7 +283,13 @@ declare module 'estree' {
|
|
|
286
283
|
|
|
287
284
|
interface Html extends AST.BaseNode {
|
|
288
285
|
type: 'Html';
|
|
289
|
-
expression: Expression;
|
|
286
|
+
expression: AST.Expression;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface RippleExpression extends AST.BaseExpression {
|
|
290
|
+
type: 'RippleExpression';
|
|
291
|
+
expression: AST.Expression;
|
|
292
|
+
loc?: AST.SourceLocation;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
interface Element extends AST.BaseNode {
|
|
@@ -345,14 +348,6 @@ declare module 'estree' {
|
|
|
345
348
|
content: string;
|
|
346
349
|
}
|
|
347
350
|
|
|
348
|
-
/**
|
|
349
|
-
* Tracked Expressions
|
|
350
|
-
*/
|
|
351
|
-
interface TrackedExpression extends AST.BaseExpression {
|
|
352
|
-
argument: AST.Expression;
|
|
353
|
-
type: 'TrackedExpression';
|
|
354
|
-
}
|
|
355
|
-
|
|
356
351
|
/**
|
|
357
352
|
* Ripple attribute nodes
|
|
358
353
|
*/
|
|
@@ -613,6 +608,7 @@ declare module 'estree-jsx' {
|
|
|
613
608
|
|
|
614
609
|
interface JSXExpressionContainer {
|
|
615
610
|
html?: boolean;
|
|
611
|
+
text?: boolean;
|
|
616
612
|
}
|
|
617
613
|
|
|
618
614
|
interface JSXMemberExpression {
|
|
@@ -924,13 +924,7 @@ export namespace Parse {
|
|
|
924
924
|
refDestructuringErrors?: DestructuringErrors,
|
|
925
925
|
forInit?: ForInit,
|
|
926
926
|
forNew?: boolean,
|
|
927
|
-
):
|
|
928
|
-
| AST.ServerIdentifier
|
|
929
|
-
| AST.StyleIdentifier
|
|
930
|
-
| AST.TrackedExpression
|
|
931
|
-
| AST.Component
|
|
932
|
-
| AST.Identifier
|
|
933
|
-
| AST.Literal;
|
|
927
|
+
): AST.ServerIdentifier | AST.StyleIdentifier | AST.Component | AST.Identifier | AST.Literal;
|
|
934
928
|
|
|
935
929
|
/** Default handler for parseExprAtom when no other case matches */
|
|
936
930
|
parseExprAtomDefault(): AST.Expression;
|
|
@@ -950,8 +944,6 @@ export namespace Parse {
|
|
|
950
944
|
/** Parse parenthesized expression (just the expression) */
|
|
951
945
|
parseParenExpression(): AST.Expression;
|
|
952
946
|
|
|
953
|
-
parseTrackedExpression(): AST.TrackedExpression;
|
|
954
|
-
|
|
955
947
|
/**
|
|
956
948
|
* Parse item in parentheses (can be overridden for flow/ts)
|
|
957
949
|
*/
|
|
@@ -1203,6 +1195,8 @@ export namespace Parse {
|
|
|
1203
1195
|
topLevel?: boolean,
|
|
1204
1196
|
exports?: AST.ExportSpecifier,
|
|
1205
1197
|
):
|
|
1198
|
+
| AST.RippleExpression
|
|
1199
|
+
| AST.Html
|
|
1206
1200
|
| AST.TextNode
|
|
1207
1201
|
| ESTreeJSX.JSXEmptyExpression
|
|
1208
1202
|
| ESTreeJSX.JSXExpressionContainer
|