@torpor/view 1.3.0 → 1.3.1
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/dist/compile.cjs +12 -21
- package/dist/compile.mjs +12 -21
- package/dist/compile.mjs.map +1 -1
- package/dist/index.cjs +145 -30
- package/dist/index.d.cts +42 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +42 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +145 -30
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.iife.js +1 -1
- package/package.json +1 -1
package/dist/compile.cjs
CHANGED
|
@@ -2312,7 +2312,6 @@ function buildIfNode(node, status, b) {
|
|
|
2312
2312
|
status.imports.add("t_region");
|
|
2313
2313
|
status.imports.add("t_run_control");
|
|
2314
2314
|
status.imports.add("t_run_branch");
|
|
2315
|
-
status.imports.add("t_push_region");
|
|
2316
2315
|
status.imports.add("t_pop_region");
|
|
2317
2316
|
b.append("");
|
|
2318
2317
|
b.append("/* @if */");
|
|
@@ -2330,12 +2329,9 @@ function buildIfNode(node, status, b) {
|
|
|
2330
2329
|
}
|
|
2331
2330
|
function buildIfBranch(node, status, b, parentName, regionName, indexName, index) {
|
|
2332
2331
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
2333
|
-
b.append(`
|
|
2332
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, ${indexName}, ${index}${status.options.dev === true ? `, "if_branch"` : ""});`);
|
|
2333
|
+
b.append("if (t_old_region === null) return;");
|
|
2334
2334
|
if (node.children.length > 0) {
|
|
2335
|
-
b.append(`
|
|
2336
|
-
const t_new_region = t_region(${status.options.dev === true ? `"if_branch"` : ""});
|
|
2337
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2338
|
-
`);
|
|
2339
2335
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2340
2336
|
status.fragmentStack.push({
|
|
2341
2337
|
fragment: node.fragment,
|
|
@@ -2344,8 +2340,8 @@ function buildIfBranch(node, status, b, parentName, regionName, indexName, index
|
|
|
2344
2340
|
for (let child of node.children) buildNode(child, status, b, parentName, "t_before");
|
|
2345
2341
|
status.fragmentStack.pop();
|
|
2346
2342
|
buildAddFragment(node, status, b, parentName, "t_before");
|
|
2347
|
-
b.append("t_pop_region(t_old_region);");
|
|
2348
2343
|
}
|
|
2344
|
+
b.append("t_pop_region(t_old_region);");
|
|
2349
2345
|
b.append(`${indexName} = ${index};`);
|
|
2350
2346
|
b.append("}");
|
|
2351
2347
|
}
|
|
@@ -2359,7 +2355,6 @@ function buildReplaceNode(node, status, b) {
|
|
|
2359
2355
|
status.imports.add("t_region");
|
|
2360
2356
|
status.imports.add("t_run_control");
|
|
2361
2357
|
status.imports.add("t_run_branch");
|
|
2362
|
-
status.imports.add("t_push_region");
|
|
2363
2358
|
status.imports.add("t_pop_region");
|
|
2364
2359
|
b.append("");
|
|
2365
2360
|
b.append(`
|
|
@@ -2372,13 +2367,9 @@ function buildReplaceNode(node, status, b) {
|
|
|
2372
2367
|
b.append("");
|
|
2373
2368
|
}
|
|
2374
2369
|
function buildReplaceBranch(node, status, b, parentName, regionName) {
|
|
2375
|
-
status.imports.add("t_run_branch");
|
|
2376
2370
|
b.append(`${node.statement};`);
|
|
2377
|
-
b.append(`
|
|
2378
|
-
b.append(
|
|
2379
|
-
const t_new_region = t_region(${status.options.dev === true ? `"replace_branch"` : ""});
|
|
2380
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2381
|
-
`);
|
|
2371
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, 0, -1${status.options.dev === true ? `, "replace_branch"` : ""});`);
|
|
2372
|
+
b.append("if (t_old_region === null) return;");
|
|
2382
2373
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2383
2374
|
status.fragmentStack.push({
|
|
2384
2375
|
fragment: node.fragment,
|
|
@@ -2422,7 +2413,6 @@ function buildSwitchNode(node, status, b) {
|
|
|
2422
2413
|
status.imports.add("t_region");
|
|
2423
2414
|
status.imports.add("t_run_control");
|
|
2424
2415
|
status.imports.add("t_run_branch");
|
|
2425
|
-
status.imports.add("t_push_region");
|
|
2426
2416
|
status.imports.add("t_pop_region");
|
|
2427
2417
|
b.append("");
|
|
2428
2418
|
b.append("/* @switch */");
|
|
@@ -2443,12 +2433,9 @@ function buildSwitchNode(node, status, b) {
|
|
|
2443
2433
|
}
|
|
2444
2434
|
function buildSwitchBranch(node, status, b, parentName, regionName, indexName, index) {
|
|
2445
2435
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
2446
|
-
b.append(`
|
|
2436
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, ${indexName}, ${index}${status.options.dev === true ? `, "switch_branch"` : ""});`);
|
|
2437
|
+
b.append("if (t_old_region === null) return;");
|
|
2447
2438
|
if (node.children.length > 0) {
|
|
2448
|
-
b.append(`
|
|
2449
|
-
const t_new_region = t_region(${status.options.dev === true ? `"switch_branch"` : ""});
|
|
2450
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2451
|
-
`);
|
|
2452
2439
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2453
2440
|
status.fragmentStack.push({
|
|
2454
2441
|
fragment: node.fragment,
|
|
@@ -2457,8 +2444,8 @@ function buildSwitchBranch(node, status, b, parentName, regionName, indexName, i
|
|
|
2457
2444
|
for (let child of node.children) buildNode(child, status, b, parentName, "t_before");
|
|
2458
2445
|
status.fragmentStack.pop();
|
|
2459
2446
|
buildAddFragment(node, status, b, parentName, "t_before");
|
|
2460
|
-
b.append("t_pop_region(t_old_region);");
|
|
2461
2447
|
}
|
|
2448
|
+
b.append("t_pop_region(t_old_region);");
|
|
2462
2449
|
b.append(`
|
|
2463
2450
|
${indexName} = ${index};
|
|
2464
2451
|
break;
|
|
@@ -5928,6 +5915,10 @@ function parseControlOpen(status) {
|
|
|
5928
5915
|
if (operation === "@replace" || operation === "@html") statement = trimMatched(statement.substring(statement.indexOf("(")).trim(), "(", ")");
|
|
5929
5916
|
if (operation === "@await" && /^await\s*\(/.test(statement)) addError(status, "old `@await (expr) { … } then (…) { … }` syntax is removed — use `@await { … } with { … }` with `$async` getters", start, status.i);
|
|
5930
5917
|
} else {
|
|
5918
|
+
if (/^@[a-zA-Z]+</.test(operation)) {
|
|
5919
|
+
addError(status, `Unknown operation: ${operation}. A literal '@' in text must be escaped as '@'`, start, status.i);
|
|
5920
|
+
return null;
|
|
5921
|
+
}
|
|
5931
5922
|
addError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);
|
|
5932
5923
|
return null;
|
|
5933
5924
|
}
|
package/dist/compile.mjs
CHANGED
|
@@ -2311,7 +2311,6 @@ function buildIfNode(node, status, b) {
|
|
|
2311
2311
|
status.imports.add("t_region");
|
|
2312
2312
|
status.imports.add("t_run_control");
|
|
2313
2313
|
status.imports.add("t_run_branch");
|
|
2314
|
-
status.imports.add("t_push_region");
|
|
2315
2314
|
status.imports.add("t_pop_region");
|
|
2316
2315
|
b.append("");
|
|
2317
2316
|
b.append("/* @if */");
|
|
@@ -2329,12 +2328,9 @@ function buildIfNode(node, status, b) {
|
|
|
2329
2328
|
}
|
|
2330
2329
|
function buildIfBranch(node, status, b, parentName, regionName, indexName, index) {
|
|
2331
2330
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
2332
|
-
b.append(`
|
|
2331
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, ${indexName}, ${index}${status.options.dev === true ? `, "if_branch"` : ""});`);
|
|
2332
|
+
b.append("if (t_old_region === null) return;");
|
|
2333
2333
|
if (node.children.length > 0) {
|
|
2334
|
-
b.append(`
|
|
2335
|
-
const t_new_region = t_region(${status.options.dev === true ? `"if_branch"` : ""});
|
|
2336
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2337
|
-
`);
|
|
2338
2334
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2339
2335
|
status.fragmentStack.push({
|
|
2340
2336
|
fragment: node.fragment,
|
|
@@ -2343,8 +2339,8 @@ function buildIfBranch(node, status, b, parentName, regionName, indexName, index
|
|
|
2343
2339
|
for (let child of node.children) buildNode(child, status, b, parentName, "t_before");
|
|
2344
2340
|
status.fragmentStack.pop();
|
|
2345
2341
|
buildAddFragment(node, status, b, parentName, "t_before");
|
|
2346
|
-
b.append("t_pop_region(t_old_region);");
|
|
2347
2342
|
}
|
|
2343
|
+
b.append("t_pop_region(t_old_region);");
|
|
2348
2344
|
b.append(`${indexName} = ${index};`);
|
|
2349
2345
|
b.append("}");
|
|
2350
2346
|
}
|
|
@@ -2358,7 +2354,6 @@ function buildReplaceNode(node, status, b) {
|
|
|
2358
2354
|
status.imports.add("t_region");
|
|
2359
2355
|
status.imports.add("t_run_control");
|
|
2360
2356
|
status.imports.add("t_run_branch");
|
|
2361
|
-
status.imports.add("t_push_region");
|
|
2362
2357
|
status.imports.add("t_pop_region");
|
|
2363
2358
|
b.append("");
|
|
2364
2359
|
b.append(`
|
|
@@ -2371,13 +2366,9 @@ function buildReplaceNode(node, status, b) {
|
|
|
2371
2366
|
b.append("");
|
|
2372
2367
|
}
|
|
2373
2368
|
function buildReplaceBranch(node, status, b, parentName, regionName) {
|
|
2374
|
-
status.imports.add("t_run_branch");
|
|
2375
2369
|
b.append(`${node.statement};`);
|
|
2376
|
-
b.append(`
|
|
2377
|
-
b.append(
|
|
2378
|
-
const t_new_region = t_region(${status.options.dev === true ? `"replace_branch"` : ""});
|
|
2379
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2380
|
-
`);
|
|
2370
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, 0, -1${status.options.dev === true ? `, "replace_branch"` : ""});`);
|
|
2371
|
+
b.append("if (t_old_region === null) return;");
|
|
2381
2372
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2382
2373
|
status.fragmentStack.push({
|
|
2383
2374
|
fragment: node.fragment,
|
|
@@ -2421,7 +2412,6 @@ function buildSwitchNode(node, status, b) {
|
|
|
2421
2412
|
status.imports.add("t_region");
|
|
2422
2413
|
status.imports.add("t_run_control");
|
|
2423
2414
|
status.imports.add("t_run_branch");
|
|
2424
|
-
status.imports.add("t_push_region");
|
|
2425
2415
|
status.imports.add("t_pop_region");
|
|
2426
2416
|
b.append("");
|
|
2427
2417
|
b.append("/* @switch */");
|
|
@@ -2442,12 +2432,9 @@ function buildSwitchNode(node, status, b) {
|
|
|
2442
2432
|
}
|
|
2443
2433
|
function buildSwitchBranch(node, status, b, parentName, regionName, indexName, index) {
|
|
2444
2434
|
addMappedText("", `${node.statement}`, " {", node.span, status, b);
|
|
2445
|
-
b.append(`
|
|
2435
|
+
b.append(`const t_old_region = t_run_branch(${regionName}, ${indexName}, ${index}${status.options.dev === true ? `, "switch_branch"` : ""});`);
|
|
2436
|
+
b.append("if (t_old_region === null) return;");
|
|
2446
2437
|
if (node.children.length > 0) {
|
|
2447
|
-
b.append(`
|
|
2448
|
-
const t_new_region = t_region(${status.options.dev === true ? `"switch_branch"` : ""});
|
|
2449
|
-
const t_old_region = t_push_region(t_new_region, true);
|
|
2450
|
-
`);
|
|
2451
2438
|
buildFragment(node, status, b, parentName, "t_before");
|
|
2452
2439
|
status.fragmentStack.push({
|
|
2453
2440
|
fragment: node.fragment,
|
|
@@ -2456,8 +2443,8 @@ function buildSwitchBranch(node, status, b, parentName, regionName, indexName, i
|
|
|
2456
2443
|
for (let child of node.children) buildNode(child, status, b, parentName, "t_before");
|
|
2457
2444
|
status.fragmentStack.pop();
|
|
2458
2445
|
buildAddFragment(node, status, b, parentName, "t_before");
|
|
2459
|
-
b.append("t_pop_region(t_old_region);");
|
|
2460
2446
|
}
|
|
2447
|
+
b.append("t_pop_region(t_old_region);");
|
|
2461
2448
|
b.append(`
|
|
2462
2449
|
${indexName} = ${index};
|
|
2463
2450
|
break;
|
|
@@ -5927,6 +5914,10 @@ function parseControlOpen(status) {
|
|
|
5927
5914
|
if (operation === "@replace" || operation === "@html") statement = trimMatched(statement.substring(statement.indexOf("(")).trim(), "(", ")");
|
|
5928
5915
|
if (operation === "@await" && /^await\s*\(/.test(statement)) addError(status, "old `@await (expr) { … } then (…) { … }` syntax is removed — use `@await { … } with { … }` with `$async` getters", start, status.i);
|
|
5929
5916
|
} else {
|
|
5917
|
+
if (/^@[a-zA-Z]+</.test(operation)) {
|
|
5918
|
+
addError(status, `Unknown operation: ${operation}. A literal '@' in text must be escaped as '@'`, start, status.i);
|
|
5919
|
+
return null;
|
|
5920
|
+
}
|
|
5930
5921
|
addError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);
|
|
5931
5922
|
return null;
|
|
5932
5923
|
}
|