ripple 0.2.106 → 0.2.107
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
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.2.
|
|
6
|
+
"version": "0.2.107",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -159,11 +159,12 @@ const visitors = {
|
|
|
159
159
|
}
|
|
160
160
|
} else {
|
|
161
161
|
const binding = context.state.scope.get(node.name);
|
|
162
|
-
const
|
|
162
|
+
const is_right_side_of_assignment =
|
|
163
|
+
parent.type === 'AssignmentExpression' && parent.right === node;
|
|
163
164
|
if (
|
|
164
165
|
(context.state.metadata?.tracking === false ||
|
|
165
166
|
(parent.type !== 'AssignmentExpression' && parent.type !== 'UpdateExpression') ||
|
|
166
|
-
|
|
167
|
+
is_right_side_of_assignment) &&
|
|
167
168
|
(node.tracked ||
|
|
168
169
|
binding?.kind === 'prop' ||
|
|
169
170
|
binding?.kind === 'index' ||
|
|
@@ -469,9 +470,10 @@ const visitors = {
|
|
|
469
470
|
|
|
470
471
|
const handle_static_attr = (name, value) => {
|
|
471
472
|
const attr_value = b.literal(
|
|
472
|
-
` ${name}${
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
` ${name}${
|
|
474
|
+
is_boolean_attribute(name) && value === true
|
|
475
|
+
? ''
|
|
476
|
+
: `="${value === true ? '' : escape_html(value, true)}"`
|
|
475
477
|
}`,
|
|
476
478
|
);
|
|
477
479
|
|
|
@@ -943,10 +945,10 @@ const visitors = {
|
|
|
943
945
|
operator === '='
|
|
944
946
|
? context.visit(right)
|
|
945
947
|
: b.binary(
|
|
946
|
-
|
|
947
|
-
/** @type {
|
|
948
|
-
/** @type {Expression} */(context.visit(right)),
|
|
949
|
-
|
|
948
|
+
operator === '+=' ? '+' : operator === '-=' ? '-' : operator === '*=' ? '*' : '/',
|
|
949
|
+
/** @type {Expression} */ (context.visit(left)),
|
|
950
|
+
/** @type {Expression} */ (context.visit(right)),
|
|
951
|
+
),
|
|
950
952
|
b.id('__block'),
|
|
951
953
|
);
|
|
952
954
|
}
|
|
@@ -962,12 +964,12 @@ const visitors = {
|
|
|
962
964
|
operator === '='
|
|
963
965
|
? context.visit(right)
|
|
964
966
|
: b.binary(
|
|
965
|
-
|
|
966
|
-
/** @type {
|
|
967
|
-
|
|
967
|
+
operator === '+=' ? '+' : operator === '-=' ? '-' : operator === '*=' ? '*' : '/',
|
|
968
|
+
/** @type {Expression} */ (
|
|
969
|
+
context.visit(left, { ...context.state, metadata: { tracking: false } })
|
|
970
|
+
),
|
|
971
|
+
/** @type {Expression} */ (context.visit(right)),
|
|
968
972
|
),
|
|
969
|
-
/** @type {Expression} */(context.visit(right)),
|
|
970
|
-
),
|
|
971
973
|
b.id('__block'),
|
|
972
974
|
);
|
|
973
975
|
}
|
|
@@ -1090,7 +1092,9 @@ const visitors = {
|
|
|
1090
1092
|
for (const switch_case of node.cases) {
|
|
1091
1093
|
const consequent_scope =
|
|
1092
1094
|
context.state.scopes.get(switch_case.consequent) || context.state.scope;
|
|
1093
|
-
const consequent_id = context.state.scope.generate(
|
|
1095
|
+
const consequent_id = context.state.scope.generate(
|
|
1096
|
+
'switch_case_' + (switch_case.test == null ? 'default' : i),
|
|
1097
|
+
);
|
|
1094
1098
|
const consequent = b.block(
|
|
1095
1099
|
transform_body(switch_case.consequent, {
|
|
1096
1100
|
...context,
|
|
@@ -1172,12 +1176,12 @@ const visitors = {
|
|
|
1172
1176
|
b.stmt(b.call(b.id('__render'), b.id(consequent_id))),
|
|
1173
1177
|
alternate_id
|
|
1174
1178
|
? b.stmt(
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1179
|
+
b.call(
|
|
1180
|
+
b.id('__render'),
|
|
1181
|
+
b.id(alternate_id),
|
|
1182
|
+
node.alternate ? b.literal(false) : undefined,
|
|
1183
|
+
),
|
|
1184
|
+
)
|
|
1181
1185
|
: undefined,
|
|
1182
1186
|
),
|
|
1183
1187
|
]),
|
|
@@ -1230,9 +1234,9 @@ const visitors = {
|
|
|
1230
1234
|
node.handler === null
|
|
1231
1235
|
? b.literal(null)
|
|
1232
1236
|
: b.arrow(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1237
|
+
[b.id('__anchor'), ...(node.handler.param ? [node.handler.param] : [])],
|
|
1238
|
+
b.block(transform_body(node.handler.body.body, context)),
|
|
1239
|
+
),
|
|
1236
1240
|
node.pending === null
|
|
1237
1241
|
? undefined
|
|
1238
1242
|
: b.arrow([b.id('__anchor')], b.block(transform_body(node.pending.body, context))),
|
|
@@ -1309,7 +1313,7 @@ function join_template(items) {
|
|
|
1309
1313
|
push(e);
|
|
1310
1314
|
}
|
|
1311
1315
|
|
|
1312
|
-
const last = /** @type {
|
|
1316
|
+
const last = /** @type {any} */ (expression.quasis.at(-1));
|
|
1313
1317
|
quasi.value.cooked += /** @type {string} */ (last.value.cooked);
|
|
1314
1318
|
} else if (expression.type === 'Literal') {
|
|
1315
1319
|
/** @type {string} */ (quasi.value.cooked) += expression.value;
|
|
@@ -1328,7 +1332,7 @@ function join_template(items) {
|
|
|
1328
1332
|
}
|
|
1329
1333
|
|
|
1330
1334
|
for (const quasi of template.quasis) {
|
|
1331
|
-
quasi.value.raw = sanitize_template_string(/** @type {string} */(quasi.value.cooked));
|
|
1335
|
+
quasi.value.raw = sanitize_template_string(/** @type {string} */ (quasi.value.cooked));
|
|
1332
1336
|
}
|
|
1333
1337
|
|
|
1334
1338
|
quasi.tail = true;
|
|
@@ -1458,6 +1462,23 @@ function transform_ts_child(node, context) {
|
|
|
1458
1462
|
}
|
|
1459
1463
|
|
|
1460
1464
|
state.init.push(b.if(visit(node.test), consequent, alternate));
|
|
1465
|
+
} else if (node.type === 'SwitchStatement') {
|
|
1466
|
+
const cases = [];
|
|
1467
|
+
|
|
1468
|
+
for (const switch_case of node.cases) {
|
|
1469
|
+
const consequent_scope =
|
|
1470
|
+
context.state.scopes.get(switch_case.consequent) || context.state.scope;
|
|
1471
|
+
const consequent_body = transform_body(switch_case.consequent, {
|
|
1472
|
+
...context,
|
|
1473
|
+
state: { ...context.state, scope: consequent_scope },
|
|
1474
|
+
});
|
|
1475
|
+
|
|
1476
|
+
cases.push(
|
|
1477
|
+
b.switch_case(switch_case.test ? context.visit(switch_case.test) : null, consequent_body),
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
context.state.init.push(b.switch(context.visit(node.discriminant), cases));
|
|
1461
1482
|
} else if (node.type === 'ForOfStatement') {
|
|
1462
1483
|
const body_scope = context.state.scopes.get(node.body);
|
|
1463
1484
|
const block_body = transform_body(node.body.body, {
|
|
@@ -1510,6 +1531,8 @@ function transform_ts_child(node, context) {
|
|
|
1510
1531
|
const component = visit(node, state);
|
|
1511
1532
|
|
|
1512
1533
|
state.init.push(component);
|
|
1534
|
+
} else if (node.type === 'BreakStatement') {
|
|
1535
|
+
state.init.push(b.break);
|
|
1513
1536
|
} else {
|
|
1514
1537
|
debugger;
|
|
1515
1538
|
throw new Error('TODO');
|
|
@@ -1684,6 +1707,8 @@ function transform_children(children, context) {
|
|
|
1684
1707
|
} else if (node.type === 'SwitchStatement') {
|
|
1685
1708
|
node.is_controlled = is_controlled;
|
|
1686
1709
|
visit(node, { ...state, flush_node, namespace: state.namespace });
|
|
1710
|
+
} else if (node.type === 'BreakStatement') {
|
|
1711
|
+
// do nothing
|
|
1687
1712
|
} else {
|
|
1688
1713
|
debugger;
|
|
1689
1714
|
}
|
|
@@ -1766,7 +1791,7 @@ export function transform_client(filename, source, analysis, to_ts) {
|
|
|
1766
1791
|
};
|
|
1767
1792
|
|
|
1768
1793
|
const program = /** @type {Program} */ (
|
|
1769
|
-
walk(analysis.ast, { ...state, namespace: 'html' }, visitors)
|
|
1794
|
+
walk(/** @type {Node} */ (analysis.ast), { ...state, namespace: 'html' }, visitors)
|
|
1770
1795
|
);
|
|
1771
1796
|
|
|
1772
1797
|
for (const hoisted of state.hoisted) {
|
package/src/compiler/utils.js
CHANGED
|
@@ -808,7 +808,7 @@ export function normalize_children(children, context) {
|
|
|
808
808
|
* @param {TransformContext} context
|
|
809
809
|
*/
|
|
810
810
|
function normalize_child(node, normalized, context) {
|
|
811
|
-
if (node.type === 'EmptyStatement'
|
|
811
|
+
if (node.type === 'EmptyStatement') {
|
|
812
812
|
return;
|
|
813
813
|
} else if (
|
|
814
814
|
node.type === 'Element' &&
|