@marko/runtime-tags 0.1.9 → 0.1.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/dist/common/types.d.ts +1 -8
- package/dist/debug/dom.js +34 -35
- package/dist/debug/dom.mjs +34 -35
- package/dist/debug/html.js +40 -33
- package/dist/debug/html.mjs +40 -33
- package/dist/dom/resume.d.ts +2 -2
- package/dist/dom.js +82 -85
- package/dist/dom.mjs +82 -85
- package/dist/html/serializer.d.ts +3 -1
- package/dist/html/writer.d.ts +1 -2
- package/dist/html.js +30 -24
- package/dist/html.mjs +30 -24
- package/package.json +1 -1
package/dist/common/types.d.ts
CHANGED
|
@@ -19,20 +19,14 @@ export type Scope<T extends {
|
|
|
19
19
|
[x: string | number]: any;
|
|
20
20
|
} & T;
|
|
21
21
|
export declare enum ResumeSymbol {
|
|
22
|
-
DefaultRuntimeId = "M",
|
|
23
22
|
SectionStart = "[",
|
|
24
23
|
SectionEnd = "]",
|
|
25
24
|
SectionSingleNodesEnd = "|",
|
|
26
|
-
Node = "*"
|
|
27
|
-
PlaceholderStart = "",
|
|
28
|
-
PlaceholderEnd = "",
|
|
29
|
-
ReplacementId = "",
|
|
30
|
-
VarReorderRuntime = "$r"
|
|
25
|
+
Node = "*"
|
|
31
26
|
}
|
|
32
27
|
export declare enum AccessorChar {
|
|
33
28
|
Dynamic = "?",
|
|
34
29
|
Mark = "#",
|
|
35
|
-
Stale = "&",
|
|
36
30
|
Subscribers = "*",
|
|
37
31
|
LifecycleAbortController = "-",
|
|
38
32
|
DynamicPlaceholderLastChild = "-",
|
|
@@ -41,7 +35,6 @@ export declare enum AccessorChar {
|
|
|
41
35
|
ConditionalRenderer = "(",
|
|
42
36
|
LoopScopeArray = "!",
|
|
43
37
|
LoopScopeMap = "(",
|
|
44
|
-
LoopValue = ")",
|
|
45
38
|
EventAttributes = "~"
|
|
46
39
|
}
|
|
47
40
|
export declare enum NodeType {
|
package/dist/debug/dom.js
CHANGED
|
@@ -1303,6 +1303,10 @@ function runBatch() {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
1305
|
|
|
1306
|
+
// src/common/meta.ts
|
|
1307
|
+
var DEFAULT_RUNTIME_ID = "M";
|
|
1308
|
+
var DEFAULT_RENDER_ID = "_";
|
|
1309
|
+
|
|
1306
1310
|
// src/dom/resume.ts
|
|
1307
1311
|
var registeredValues = {};
|
|
1308
1312
|
var Render = class {
|
|
@@ -1369,41 +1373,40 @@ var Render = class {
|
|
|
1369
1373
|
}
|
|
1370
1374
|
}
|
|
1371
1375
|
}
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1374
|
-
data2.
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
$global
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
if (
|
|
1389
|
-
|
|
1376
|
+
const resumes = data2.r;
|
|
1377
|
+
if (resumes) {
|
|
1378
|
+
data2.r = [];
|
|
1379
|
+
const len = resumes.length;
|
|
1380
|
+
let i = 0;
|
|
1381
|
+
while (i < len) {
|
|
1382
|
+
const resumeData = resumes[i++];
|
|
1383
|
+
if (typeof resumeData === "function") {
|
|
1384
|
+
const scopes = resumeData(serializeContext);
|
|
1385
|
+
let { $global } = scopeLookup;
|
|
1386
|
+
if (!$global) {
|
|
1387
|
+
scopeLookup.$global = $global = scopes.$ || {};
|
|
1388
|
+
$global.runtimeId = this.___runtimeId;
|
|
1389
|
+
$global.renderId = this.___renderId;
|
|
1390
|
+
}
|
|
1391
|
+
for (const scopeId in scopes) {
|
|
1392
|
+
if (scopeId !== "$") {
|
|
1393
|
+
const scope = scopes[scopeId];
|
|
1394
|
+
const prevScope = scopeLookup[scopeId];
|
|
1395
|
+
scope.$global = $global;
|
|
1396
|
+
if (prevScope !== scope) {
|
|
1397
|
+
scopeLookup[scopeId] = Object.assign(scope, prevScope);
|
|
1398
|
+
}
|
|
1390
1399
|
}
|
|
1391
1400
|
}
|
|
1401
|
+
} else if (i === len || typeof resumes[i] !== "string") {
|
|
1402
|
+
delete this.___renders[this.___renderId];
|
|
1403
|
+
} else {
|
|
1404
|
+
registeredValues[resumes[i++]](
|
|
1405
|
+
scopeLookup[resumeData]
|
|
1406
|
+
);
|
|
1392
1407
|
}
|
|
1393
1408
|
}
|
|
1394
1409
|
}
|
|
1395
|
-
const effects = data2.e;
|
|
1396
|
-
if (effects) {
|
|
1397
|
-
data2.e = [];
|
|
1398
|
-
for (let i = 0; i < effects.length; i += 2) {
|
|
1399
|
-
registeredValues[effects[i + 1]](
|
|
1400
|
-
scopeLookup[effects[i]]
|
|
1401
|
-
);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
if (data2.d) {
|
|
1405
|
-
delete this.___renders[this.___renderId];
|
|
1406
|
-
}
|
|
1407
1410
|
}
|
|
1408
1411
|
};
|
|
1409
1412
|
function register(id, obj) {
|
|
@@ -1430,7 +1433,7 @@ function getRegisteredWithScope(id, scope) {
|
|
|
1430
1433
|
}
|
|
1431
1434
|
return val;
|
|
1432
1435
|
}
|
|
1433
|
-
function init(runtimeId =
|
|
1436
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
1434
1437
|
if (true) {
|
|
1435
1438
|
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
|
1436
1439
|
throw new Error(
|
|
@@ -1551,10 +1554,6 @@ var compat = {
|
|
|
1551
1554
|
function noop() {
|
|
1552
1555
|
}
|
|
1553
1556
|
|
|
1554
|
-
// src/common/meta.ts
|
|
1555
|
-
var DEFAULT_RUNTIME_ID = "M";
|
|
1556
|
-
var DEFAULT_RENDER_ID = "_";
|
|
1557
|
-
|
|
1558
1557
|
// src/dom/template.ts
|
|
1559
1558
|
var createTemplate = (renderer, templateId) => register(templateId, new ClientTemplate(renderer));
|
|
1560
1559
|
var ClientTemplate = class {
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -1227,6 +1227,10 @@ function runBatch() {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
+
// src/common/meta.ts
|
|
1231
|
+
var DEFAULT_RUNTIME_ID = "M";
|
|
1232
|
+
var DEFAULT_RENDER_ID = "_";
|
|
1233
|
+
|
|
1230
1234
|
// src/dom/resume.ts
|
|
1231
1235
|
var registeredValues = {};
|
|
1232
1236
|
var Render = class {
|
|
@@ -1293,41 +1297,40 @@ var Render = class {
|
|
|
1293
1297
|
}
|
|
1294
1298
|
}
|
|
1295
1299
|
}
|
|
1296
|
-
const
|
|
1297
|
-
if (
|
|
1298
|
-
data2.
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
$global
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1300
|
+
const resumes = data2.r;
|
|
1301
|
+
if (resumes) {
|
|
1302
|
+
data2.r = [];
|
|
1303
|
+
const len = resumes.length;
|
|
1304
|
+
let i = 0;
|
|
1305
|
+
while (i < len) {
|
|
1306
|
+
const resumeData = resumes[i++];
|
|
1307
|
+
if (typeof resumeData === "function") {
|
|
1308
|
+
const scopes = resumeData(serializeContext);
|
|
1309
|
+
let { $global } = scopeLookup;
|
|
1310
|
+
if (!$global) {
|
|
1311
|
+
scopeLookup.$global = $global = scopes.$ || {};
|
|
1312
|
+
$global.runtimeId = this.___runtimeId;
|
|
1313
|
+
$global.renderId = this.___renderId;
|
|
1314
|
+
}
|
|
1315
|
+
for (const scopeId in scopes) {
|
|
1316
|
+
if (scopeId !== "$") {
|
|
1317
|
+
const scope = scopes[scopeId];
|
|
1318
|
+
const prevScope = scopeLookup[scopeId];
|
|
1319
|
+
scope.$global = $global;
|
|
1320
|
+
if (prevScope !== scope) {
|
|
1321
|
+
scopeLookup[scopeId] = Object.assign(scope, prevScope);
|
|
1322
|
+
}
|
|
1314
1323
|
}
|
|
1315
1324
|
}
|
|
1325
|
+
} else if (i === len || typeof resumes[i] !== "string") {
|
|
1326
|
+
delete this.___renders[this.___renderId];
|
|
1327
|
+
} else {
|
|
1328
|
+
registeredValues[resumes[i++]](
|
|
1329
|
+
scopeLookup[resumeData]
|
|
1330
|
+
);
|
|
1316
1331
|
}
|
|
1317
1332
|
}
|
|
1318
1333
|
}
|
|
1319
|
-
const effects = data2.e;
|
|
1320
|
-
if (effects) {
|
|
1321
|
-
data2.e = [];
|
|
1322
|
-
for (let i = 0; i < effects.length; i += 2) {
|
|
1323
|
-
registeredValues[effects[i + 1]](
|
|
1324
|
-
scopeLookup[effects[i]]
|
|
1325
|
-
);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
if (data2.d) {
|
|
1329
|
-
delete this.___renders[this.___renderId];
|
|
1330
|
-
}
|
|
1331
1334
|
}
|
|
1332
1335
|
};
|
|
1333
1336
|
function register(id, obj) {
|
|
@@ -1354,7 +1357,7 @@ function getRegisteredWithScope(id, scope) {
|
|
|
1354
1357
|
}
|
|
1355
1358
|
return val;
|
|
1356
1359
|
}
|
|
1357
|
-
function init(runtimeId =
|
|
1360
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
1358
1361
|
if (true) {
|
|
1359
1362
|
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
|
1360
1363
|
throw new Error(
|
|
@@ -1475,10 +1478,6 @@ var compat = {
|
|
|
1475
1478
|
function noop() {
|
|
1476
1479
|
}
|
|
1477
1480
|
|
|
1478
|
-
// src/common/meta.ts
|
|
1479
|
-
var DEFAULT_RUNTIME_ID = "M";
|
|
1480
|
-
var DEFAULT_RENDER_ID = "_";
|
|
1481
|
-
|
|
1482
1481
|
// src/dom/template.ts
|
|
1483
1482
|
var createTemplate = (renderer, templateId) => register(templateId, new ClientTemplate(renderer));
|
|
1484
1483
|
var ClientTemplate = class {
|
package/dist/debug/html.js
CHANGED
|
@@ -199,12 +199,12 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
|
|
|
199
199
|
// repurpose "op" for callbacks ...carefully
|
|
200
200
|
placeholderCallback = placeholder.c;
|
|
201
201
|
(op = runtime.j[id]) &&
|
|
202
|
-
(placeholder.c = () => placeholderCallback() + op());
|
|
202
|
+
(placeholder.c = () => placeholderCallback() + op(runtime));
|
|
203
203
|
|
|
204
204
|
if (node.attributes.c) placeholder.c();
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
-
})` : `(e=>{let t,
|
|
207
|
+
})` : `(e=>{let i,t,r,l,d={},n=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(o,a,c,p,b)=>{"#"==o?(d[a]=t).i++:c==r&&i(),"T"==c.tagName&&(a=c.getAttribute(e.i))&&((p=e.l["^"+a])?t=d[a]={i:0,c(i=e.l[a]||l||c){for(;i.parentNode!==p.parentNode;)i=i.parentNode;for(;i!=r;(r=p.nextSibling).remove());n(p,c)}}:(i=()=>{l=c.previousSibling,n(e.l[a],c),--p.i||p.c()},p=t=d[a],r=c.nextElementSibling||i()),b=t.c,(o=e.j[a])&&(t.c=()=>b()+o(e)),c.attributes.c&&t.c())}})`;
|
|
208
208
|
|
|
209
209
|
// src/html/serializer.ts
|
|
210
210
|
var { hasOwnProperty } = {};
|
|
@@ -481,6 +481,9 @@ var Reference = class {
|
|
|
481
481
|
};
|
|
482
482
|
var Serializer = class {
|
|
483
483
|
#state = new State();
|
|
484
|
+
get flushed() {
|
|
485
|
+
return this.#state.flushed;
|
|
486
|
+
}
|
|
484
487
|
stringify(val, boundary) {
|
|
485
488
|
try {
|
|
486
489
|
this.#state.flushed = false;
|
|
@@ -490,8 +493,13 @@ var Serializer = class {
|
|
|
490
493
|
this.#flush();
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
|
|
494
|
-
return this.#state
|
|
496
|
+
nextId() {
|
|
497
|
+
return nextId(this.#state);
|
|
498
|
+
}
|
|
499
|
+
symbol(id) {
|
|
500
|
+
const symbol = Symbol();
|
|
501
|
+
this.#state.refs.set(symbol, new Reference(null, null, 0, null, id));
|
|
502
|
+
return symbol;
|
|
495
503
|
}
|
|
496
504
|
#flush() {
|
|
497
505
|
this.#state.flush++;
|
|
@@ -1278,12 +1286,15 @@ function assignId(state, ref) {
|
|
|
1278
1286
|
return ref.id + "=" + accessPrevValue;
|
|
1279
1287
|
}
|
|
1280
1288
|
function nextRefAccess(state) {
|
|
1289
|
+
return "_." + nextId(state);
|
|
1290
|
+
}
|
|
1291
|
+
function nextId(state) {
|
|
1281
1292
|
const encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
|
|
1282
1293
|
const encodeLen = encodeChars.length;
|
|
1283
1294
|
const encodeStartLen = encodeLen - 11;
|
|
1284
1295
|
let index = state.ids++;
|
|
1285
1296
|
let mod = index % encodeStartLen;
|
|
1286
|
-
let id =
|
|
1297
|
+
let id = encodeChars[mod];
|
|
1287
1298
|
index = (index - mod) / encodeStartLen;
|
|
1288
1299
|
while (index > 0) {
|
|
1289
1300
|
mod = index % encodeLen;
|
|
@@ -1534,8 +1545,7 @@ var State2 = class {
|
|
|
1534
1545
|
needsMainRuntime = false;
|
|
1535
1546
|
hasMainRuntime = false;
|
|
1536
1547
|
hasReorderRuntime = false;
|
|
1537
|
-
|
|
1538
|
-
hasWrittenEffects = false;
|
|
1548
|
+
hasWrittenResume = false;
|
|
1539
1549
|
serializer = new Serializer();
|
|
1540
1550
|
writeReorders = null;
|
|
1541
1551
|
scopes = /* @__PURE__ */ new Map();
|
|
@@ -1719,31 +1729,31 @@ function prepareChunk(chunk) {
|
|
|
1719
1729
|
WALKER_RUNTIME_CODE + '("' + $global.runtimeId + '")("' + $global.renderId + '")'
|
|
1720
1730
|
);
|
|
1721
1731
|
}
|
|
1732
|
+
let resumes = "";
|
|
1722
1733
|
if (state.writeScopes || serializer.flushed) {
|
|
1723
|
-
|
|
1724
|
-
state.writeScopes || {},
|
|
1725
|
-
boundary
|
|
1726
|
-
);
|
|
1727
|
-
let script = runtimePrefix + ".s" /* Scopes */;
|
|
1734
|
+
resumes = state.serializer.stringify(state.writeScopes || {}, boundary);
|
|
1728
1735
|
state.writeScopes = null;
|
|
1729
|
-
if (state.hasWrittenScopes) {
|
|
1730
|
-
script += ".push(" + serialized + ")";
|
|
1731
|
-
} else {
|
|
1732
|
-
state.hasWrittenScopes = true;
|
|
1733
|
-
script += "=[" + serialized + "]";
|
|
1734
|
-
}
|
|
1735
|
-
scripts = concatScripts(scripts, script);
|
|
1736
1736
|
}
|
|
1737
1737
|
if (effects) {
|
|
1738
|
-
let script = runtimePrefix + ".e" /* Effects */;
|
|
1739
1738
|
hasWalk = true;
|
|
1740
|
-
|
|
1741
|
-
|
|
1739
|
+
resumes = resumes ? resumes + "," + effects : effects;
|
|
1740
|
+
}
|
|
1741
|
+
if (boundary.done && (resumes || state.hasWrittenResume)) {
|
|
1742
|
+
resumes = resumes ? resumes + ",0" : "0";
|
|
1743
|
+
}
|
|
1744
|
+
if (resumes) {
|
|
1745
|
+
if (state.hasWrittenResume) {
|
|
1746
|
+
scripts = concatScripts(
|
|
1747
|
+
scripts,
|
|
1748
|
+
runtimePrefix + ".r.push(" + resumes + ")"
|
|
1749
|
+
);
|
|
1742
1750
|
} else {
|
|
1743
|
-
state.
|
|
1744
|
-
|
|
1751
|
+
state.hasWrittenResume = true;
|
|
1752
|
+
scripts = concatScripts(
|
|
1753
|
+
scripts,
|
|
1754
|
+
runtimePrefix + ".r=[" + resumes + "]"
|
|
1755
|
+
);
|
|
1745
1756
|
}
|
|
1746
|
-
scripts = concatScripts(scripts, script);
|
|
1747
1757
|
}
|
|
1748
1758
|
if (state.writeReorders) {
|
|
1749
1759
|
hasWalk = true;
|
|
@@ -1783,29 +1793,26 @@ function prepareChunk(chunk) {
|
|
|
1783
1793
|
}
|
|
1784
1794
|
}
|
|
1785
1795
|
if (reorderEffects) {
|
|
1786
|
-
if (!state.
|
|
1787
|
-
state.
|
|
1796
|
+
if (!state.hasWrittenResume) {
|
|
1797
|
+
state.hasWrittenResume = true;
|
|
1788
1798
|
scripts = concatScripts(
|
|
1789
1799
|
scripts,
|
|
1790
|
-
runtimePrefix + ".
|
|
1800
|
+
runtimePrefix + ".r=[]"
|
|
1791
1801
|
);
|
|
1792
1802
|
}
|
|
1793
1803
|
reorderScripts = concatScripts(
|
|
1794
1804
|
reorderScripts,
|
|
1795
|
-
|
|
1805
|
+
"_.push(" + reorderEffects + ")"
|
|
1796
1806
|
);
|
|
1797
1807
|
}
|
|
1798
1808
|
scripts = concatScripts(
|
|
1799
1809
|
scripts,
|
|
1800
|
-
reorderScripts && runtimePrefix + ".j." + reorderId + "=
|
|
1810
|
+
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
|
1801
1811
|
);
|
|
1802
1812
|
html += "<t " + (isSync ? "c " : "") + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1803
1813
|
}
|
|
1804
1814
|
state.writeReorders = null;
|
|
1805
1815
|
}
|
|
1806
|
-
if (state.needsMainRuntime && boundary.done) {
|
|
1807
|
-
scripts = concatScripts(scripts, runtimePrefix + ".d=1");
|
|
1808
|
-
}
|
|
1809
1816
|
if (hasWalk) {
|
|
1810
1817
|
scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
1811
1818
|
}
|
package/dist/debug/html.mjs
CHANGED
|
@@ -144,12 +144,12 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
|
|
|
144
144
|
// repurpose "op" for callbacks ...carefully
|
|
145
145
|
placeholderCallback = placeholder.c;
|
|
146
146
|
(op = runtime.j[id]) &&
|
|
147
|
-
(placeholder.c = () => placeholderCallback() + op());
|
|
147
|
+
(placeholder.c = () => placeholderCallback() + op(runtime));
|
|
148
148
|
|
|
149
149
|
if (node.attributes.c) placeholder.c();
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
})` : `(e=>{let t,
|
|
152
|
+
})` : `(e=>{let i,t,r,l,d={},n=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(o,a,c,p,b)=>{"#"==o?(d[a]=t).i++:c==r&&i(),"T"==c.tagName&&(a=c.getAttribute(e.i))&&((p=e.l["^"+a])?t=d[a]={i:0,c(i=e.l[a]||l||c){for(;i.parentNode!==p.parentNode;)i=i.parentNode;for(;i!=r;(r=p.nextSibling).remove());n(p,c)}}:(i=()=>{l=c.previousSibling,n(e.l[a],c),--p.i||p.c()},p=t=d[a],r=c.nextElementSibling||i()),b=t.c,(o=e.j[a])&&(t.c=()=>b()+o(e)),c.attributes.c&&t.c())}})`;
|
|
153
153
|
|
|
154
154
|
// src/html/serializer.ts
|
|
155
155
|
var { hasOwnProperty } = {};
|
|
@@ -426,6 +426,9 @@ var Reference = class {
|
|
|
426
426
|
};
|
|
427
427
|
var Serializer = class {
|
|
428
428
|
#state = new State();
|
|
429
|
+
get flushed() {
|
|
430
|
+
return this.#state.flushed;
|
|
431
|
+
}
|
|
429
432
|
stringify(val, boundary) {
|
|
430
433
|
try {
|
|
431
434
|
this.#state.flushed = false;
|
|
@@ -435,8 +438,13 @@ var Serializer = class {
|
|
|
435
438
|
this.#flush();
|
|
436
439
|
}
|
|
437
440
|
}
|
|
438
|
-
|
|
439
|
-
return this.#state
|
|
441
|
+
nextId() {
|
|
442
|
+
return nextId(this.#state);
|
|
443
|
+
}
|
|
444
|
+
symbol(id) {
|
|
445
|
+
const symbol = Symbol();
|
|
446
|
+
this.#state.refs.set(symbol, new Reference(null, null, 0, null, id));
|
|
447
|
+
return symbol;
|
|
440
448
|
}
|
|
441
449
|
#flush() {
|
|
442
450
|
this.#state.flush++;
|
|
@@ -1223,12 +1231,15 @@ function assignId(state, ref) {
|
|
|
1223
1231
|
return ref.id + "=" + accessPrevValue;
|
|
1224
1232
|
}
|
|
1225
1233
|
function nextRefAccess(state) {
|
|
1234
|
+
return "_." + nextId(state);
|
|
1235
|
+
}
|
|
1236
|
+
function nextId(state) {
|
|
1226
1237
|
const encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
|
|
1227
1238
|
const encodeLen = encodeChars.length;
|
|
1228
1239
|
const encodeStartLen = encodeLen - 11;
|
|
1229
1240
|
let index = state.ids++;
|
|
1230
1241
|
let mod = index % encodeStartLen;
|
|
1231
|
-
let id =
|
|
1242
|
+
let id = encodeChars[mod];
|
|
1232
1243
|
index = (index - mod) / encodeStartLen;
|
|
1233
1244
|
while (index > 0) {
|
|
1234
1245
|
mod = index % encodeLen;
|
|
@@ -1479,8 +1490,7 @@ var State2 = class {
|
|
|
1479
1490
|
needsMainRuntime = false;
|
|
1480
1491
|
hasMainRuntime = false;
|
|
1481
1492
|
hasReorderRuntime = false;
|
|
1482
|
-
|
|
1483
|
-
hasWrittenEffects = false;
|
|
1493
|
+
hasWrittenResume = false;
|
|
1484
1494
|
serializer = new Serializer();
|
|
1485
1495
|
writeReorders = null;
|
|
1486
1496
|
scopes = /* @__PURE__ */ new Map();
|
|
@@ -1664,31 +1674,31 @@ function prepareChunk(chunk) {
|
|
|
1664
1674
|
WALKER_RUNTIME_CODE + '("' + $global.runtimeId + '")("' + $global.renderId + '")'
|
|
1665
1675
|
);
|
|
1666
1676
|
}
|
|
1677
|
+
let resumes = "";
|
|
1667
1678
|
if (state.writeScopes || serializer.flushed) {
|
|
1668
|
-
|
|
1669
|
-
state.writeScopes || {},
|
|
1670
|
-
boundary
|
|
1671
|
-
);
|
|
1672
|
-
let script = runtimePrefix + ".s" /* Scopes */;
|
|
1679
|
+
resumes = state.serializer.stringify(state.writeScopes || {}, boundary);
|
|
1673
1680
|
state.writeScopes = null;
|
|
1674
|
-
if (state.hasWrittenScopes) {
|
|
1675
|
-
script += ".push(" + serialized + ")";
|
|
1676
|
-
} else {
|
|
1677
|
-
state.hasWrittenScopes = true;
|
|
1678
|
-
script += "=[" + serialized + "]";
|
|
1679
|
-
}
|
|
1680
|
-
scripts = concatScripts(scripts, script);
|
|
1681
1681
|
}
|
|
1682
1682
|
if (effects) {
|
|
1683
|
-
let script = runtimePrefix + ".e" /* Effects */;
|
|
1684
1683
|
hasWalk = true;
|
|
1685
|
-
|
|
1686
|
-
|
|
1684
|
+
resumes = resumes ? resumes + "," + effects : effects;
|
|
1685
|
+
}
|
|
1686
|
+
if (boundary.done && (resumes || state.hasWrittenResume)) {
|
|
1687
|
+
resumes = resumes ? resumes + ",0" : "0";
|
|
1688
|
+
}
|
|
1689
|
+
if (resumes) {
|
|
1690
|
+
if (state.hasWrittenResume) {
|
|
1691
|
+
scripts = concatScripts(
|
|
1692
|
+
scripts,
|
|
1693
|
+
runtimePrefix + ".r.push(" + resumes + ")"
|
|
1694
|
+
);
|
|
1687
1695
|
} else {
|
|
1688
|
-
state.
|
|
1689
|
-
|
|
1696
|
+
state.hasWrittenResume = true;
|
|
1697
|
+
scripts = concatScripts(
|
|
1698
|
+
scripts,
|
|
1699
|
+
runtimePrefix + ".r=[" + resumes + "]"
|
|
1700
|
+
);
|
|
1690
1701
|
}
|
|
1691
|
-
scripts = concatScripts(scripts, script);
|
|
1692
1702
|
}
|
|
1693
1703
|
if (state.writeReorders) {
|
|
1694
1704
|
hasWalk = true;
|
|
@@ -1728,29 +1738,26 @@ function prepareChunk(chunk) {
|
|
|
1728
1738
|
}
|
|
1729
1739
|
}
|
|
1730
1740
|
if (reorderEffects) {
|
|
1731
|
-
if (!state.
|
|
1732
|
-
state.
|
|
1741
|
+
if (!state.hasWrittenResume) {
|
|
1742
|
+
state.hasWrittenResume = true;
|
|
1733
1743
|
scripts = concatScripts(
|
|
1734
1744
|
scripts,
|
|
1735
|
-
runtimePrefix + ".
|
|
1745
|
+
runtimePrefix + ".r=[]"
|
|
1736
1746
|
);
|
|
1737
1747
|
}
|
|
1738
1748
|
reorderScripts = concatScripts(
|
|
1739
1749
|
reorderScripts,
|
|
1740
|
-
|
|
1750
|
+
"_.push(" + reorderEffects + ")"
|
|
1741
1751
|
);
|
|
1742
1752
|
}
|
|
1743
1753
|
scripts = concatScripts(
|
|
1744
1754
|
scripts,
|
|
1745
|
-
reorderScripts && runtimePrefix + ".j." + reorderId + "=
|
|
1755
|
+
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
|
1746
1756
|
);
|
|
1747
1757
|
html += "<t " + (isSync ? "c " : "") + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
|
1748
1758
|
}
|
|
1749
1759
|
state.writeReorders = null;
|
|
1750
1760
|
}
|
|
1751
|
-
if (state.needsMainRuntime && boundary.done) {
|
|
1752
|
-
scripts = concatScripts(scripts, runtimePrefix + ".d=1");
|
|
1753
|
-
}
|
|
1754
1761
|
if (hasWalk) {
|
|
1755
1762
|
scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
1756
1763
|
}
|
package/dist/dom/resume.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Scope } from "../common/types";
|
|
2
2
|
import type { Renderer } from "./renderer";
|
|
3
3
|
import type { IntersectionSignal, ValueSignal } from "./signals";
|
|
4
4
|
export declare function register<T>(id: string, obj: T): T;
|
|
5
5
|
export declare function registerBoundSignal<T extends ValueSignal>(id: string, signal: T): T;
|
|
6
6
|
export declare function registerRenderer(id: string, renderer: Renderer): Renderer;
|
|
7
7
|
export declare function getRegisteredWithScope(id: string, scope?: Scope): unknown;
|
|
8
|
-
export declare function init(runtimeId?:
|
|
8
|
+
export declare function init(runtimeId?: string): void;
|
|
9
9
|
export declare function registerSubscriber(id: string, signal: IntersectionSignal): IntersectionSignal;
|