marko 6.0.0-next.3.58 → 6.0.0-next.3.60

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.
@@ -158,168 +158,197 @@ var DEFAULT_RENDER_ID = "_";
158
158
 
159
159
  // src/dom/resume.ts
160
160
  var registeredValues = {};
161
- var Render = class {
162
- ___scopeStack = [];
163
- ___scopeLookup = {};
164
- ___serializeContext = {
165
- _: registeredValues
166
- };
167
- constructor(renders, runtimeId, renderId) {
168
- Object.assign(this, renders[renderId]);
169
- this.___renders = renders;
170
- this.___runtimeId = runtimeId;
171
- this.___renderId = renderId;
172
- this.___walk = this.w;
173
- this.___resume();
174
- this.w = () => {
175
- this.___walk();
176
- this.___resume();
177
- };
178
- }
179
- ___resume() {
180
- const serializeContext = this.___serializeContext;
181
- const scopeLookup = this.___scopeLookup;
182
- const visits = this.v;
183
- const branchIds = /* @__PURE__ */ new Set();
184
- const parentBranchIds = /* @__PURE__ */ new Map();
185
- if (visits.length) {
186
- const commentPrefix = this.i;
187
- const commentPrefixLen = commentPrefix.length;
188
- const closestBranchMarkers = /* @__PURE__ */ new Map();
189
- const visitNodes = new Set(visits);
190
- let lastEndNode;
191
- this.v = [];
192
- const branchEnd = (branchId, visit, reference) => {
193
- const branch = scopeLookup[branchId] ||= {};
194
- let endNode = reference;
195
- while (visitNodes.has(endNode = endNode.previousSibling)) ;
196
- if (endNode === lastEndNode) {
197
- endNode = reference.parentNode.insertBefore(new Text(), reference);
198
- }
199
- branch.___endNode = lastEndNode = endNode;
200
- branch.___startNode ||= endNode;
201
- for (const [markerScopeId, markerNode] of closestBranchMarkers) {
202
- if (branch.___startNode.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2) {
203
- parentBranchIds.set(markerScopeId, branchId);
204
- closestBranchMarkers.delete(markerScopeId);
205
- }
206
- }
207
- branchIds.add(branchId);
208
- closestBranchMarkers.set(branchId, visit);
209
- return branch;
210
- };
211
- for (const visit of visits) {
212
- const commentText = visit.data;
213
- const dataIndex = commentText.indexOf(" ") + 1;
214
- const scopeId = commentText.slice(
215
- commentPrefixLen + 1,
216
- dataIndex ? dataIndex - 1 : commentText.length
217
- );
218
- const scope = scopeLookup[scopeId] ||= { ___id: +scopeId };
219
- const data2 = dataIndex ? commentText.slice(dataIndex) : "";
220
- const token = commentText[commentPrefixLen];
221
- if (token === "*" /* Node */) {
222
- const node = scope[data2] = visit.previousSibling;
223
- scope[data2 + ">" /* Getter */] = () => node;
224
- } else if (token === "$" /* ClosestBranch */) {
225
- closestBranchMarkers.set(scopeId, visit);
226
- } else if (token === "[" /* BranchStart */) {
227
- if (this.___currentScopeId) {
228
- if (dataIndex) {
229
- branchEnd(this.___currentScopeId, visit, visit);
230
- }
231
- this.___scopeStack.push(this.___currentScopeId);
232
- }
233
- this.___currentScopeId = scopeId;
234
- scope.___startNode = visit;
235
- } else if (token === "]" /* BranchEnd */) {
236
- scope[data2] = visit;
237
- const curParent = visit.parentNode;
238
- const startNode = branchEnd(
239
- this.___currentScopeId,
240
- visit,
241
- visit
242
- ).___startNode;
243
- if (curParent !== startNode.parentNode) {
244
- curParent.prepend(startNode);
245
- }
246
- this.___currentScopeId = this.___scopeStack.pop();
247
- } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
248
- let next = data2.indexOf(" ");
249
- let curNode = visit;
250
- scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
251
- while (~next) {
252
- const start = next + 1;
253
- next = data2.indexOf(" ", start);
254
- const childScopeId = data2.slice(start, ~next ? next : data2.length);
255
- curNode = branchEnd(childScopeId, visit, curNode).___endNode;
256
- }
257
- }
258
- }
161
+ function init(runtimeId = DEFAULT_RUNTIME_ID) {
162
+ if (true) {
163
+ if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
164
+ throw new Error(
165
+ `Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
166
+ );
259
167
  }
260
- const resumes = this.r;
261
- if (resumes) {
262
- this.r = [];
263
- const len = resumes.length;
264
- let i = 0;
265
- try {
266
- isResuming = true;
267
- while (i < len) {
268
- const resumeData = resumes[i++];
269
- if (typeof resumeData === "function") {
270
- const scopes = resumeData(serializeContext);
271
- let { $global } = scopeLookup;
272
- if (!$global) {
273
- scopeLookup.$global = $global = scopes.$ || {};
274
- $global.runtimeId = this.___runtimeId;
275
- $global.renderId = this.___renderId;
276
- $global.___nextScopeId = 1e6;
277
- }
278
- for (const scopeId in scopes) {
279
- if (scopeId !== "$") {
280
- const scope = scopes[scopeId];
281
- const prevScope = scopeLookup[scopeId];
282
- scope.$global = $global;
283
- scope.___id = +scopeId;
284
- if (prevScope !== scope) {
285
- scopeLookup[scopeId] = Object.assign(
286
- scope,
287
- prevScope
288
- );
289
- }
290
- const parentBranchId = parentBranchIds.get(scopeId);
291
- if (parentBranchId) {
292
- scope.___closestBranch = scopes[parentBranchId];
168
+ const descriptor = Object.getOwnPropertyDescriptor(window, runtimeId);
169
+ if (descriptor && (descriptor.set || descriptor.configurable === false)) {
170
+ throw new Error(
171
+ `Marko initialized multiple times with the same $global.runtimeId of ${JSON.stringify(runtimeId)}. It could be that there are multiple copies of Marko running on the page.`
172
+ );
173
+ }
174
+ }
175
+ const renders = window[runtimeId];
176
+ const defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc);
177
+ let resumeRender;
178
+ const initRuntime = (renders2) => {
179
+ defineRuntime({
180
+ value: resumeRender = (renderId) => {
181
+ const render = resumeRender[renderId] = renders2[renderId] || renders2(renderId);
182
+ const walk2 = render.w;
183
+ const commentPrefixLen = render.i.length;
184
+ const scopeStack = [];
185
+ const scopeLookup = render.s = {};
186
+ const serializeContext = {
187
+ _: registeredValues
188
+ };
189
+ const branchIds = /* @__PURE__ */ new Set();
190
+ const parentBranchIds = /* @__PURE__ */ new Map();
191
+ const closestBranchMarkers = /* @__PURE__ */ new Map();
192
+ let currentScopeId;
193
+ render.w = () => {
194
+ walk2.call(render);
195
+ const visits = render.v;
196
+ const resumes = render.r;
197
+ if (visits.length) {
198
+ const visitNodes = new Set(visits);
199
+ let lastEndNode;
200
+ render.v = [];
201
+ const branchEnd = (branchId, visit, reference) => {
202
+ const branch = scopeLookup[branchId] ||= {};
203
+ let endNode = reference;
204
+ while (visitNodes.has(endNode = endNode.previousSibling)) ;
205
+ if (endNode === lastEndNode) {
206
+ endNode = reference.parentNode.insertBefore(
207
+ new Text(),
208
+ reference
209
+ );
210
+ }
211
+ branch.___endNode = lastEndNode = endNode;
212
+ branch.___startNode ||= endNode;
213
+ for (const [markerScopeId, markerNode] of closestBranchMarkers) {
214
+ if (branch.___startNode.compareDocumentPosition(markerNode) & 4 && reference.compareDocumentPosition(markerNode) & 2) {
215
+ parentBranchIds.set(markerScopeId, branchId);
216
+ closestBranchMarkers.delete(markerScopeId);
293
217
  }
294
- if (branchIds.has(scopeId)) {
295
- const branch = scope;
296
- const parentBranch = branch.___closestBranch;
297
- scope.___closestBranch = branch;
298
- if (parentBranch) {
299
- branch.___parentBranch = parentBranch;
300
- (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
218
+ }
219
+ branchIds.add(branchId);
220
+ closestBranchMarkers.set(branchId, visit);
221
+ return branch;
222
+ };
223
+ for (const visit of visits) {
224
+ const commentText = visit.data;
225
+ const dataIndex = commentText.indexOf(" ") + 1;
226
+ const scopeId = commentText.slice(
227
+ commentPrefixLen + 1,
228
+ dataIndex ? dataIndex - 1 : commentText.length
229
+ );
230
+ const scope = scopeLookup[scopeId] ||= {
231
+ ___id: +scopeId
232
+ };
233
+ const data2 = dataIndex ? commentText.slice(dataIndex) : "";
234
+ const token = commentText[commentPrefixLen];
235
+ if (token === "*" /* Node */) {
236
+ const node = scope[data2] = visit.previousSibling;
237
+ scope[data2 + ">" /* Getter */] = () => node;
238
+ } else if (token === "$" /* ClosestBranch */) {
239
+ closestBranchMarkers.set(scopeId, visit);
240
+ } else if (token === "[" /* BranchStart */) {
241
+ if (currentScopeId) {
242
+ if (dataIndex) {
243
+ branchEnd(currentScopeId, visit, visit);
301
244
  }
245
+ scopeStack.push(currentScopeId);
302
246
  }
303
- if (true) {
304
- scope.___debugId = "server-" + scopeId;
247
+ currentScopeId = scopeId;
248
+ scope.___startNode = visit;
249
+ } else if (token === "]" /* BranchEnd */) {
250
+ scope[data2] = visit;
251
+ const curParent = visit.parentNode;
252
+ const startNode = branchEnd(
253
+ currentScopeId,
254
+ visit,
255
+ visit
256
+ ).___startNode;
257
+ if (curParent !== startNode.parentNode) {
258
+ curParent.prepend(startNode);
259
+ }
260
+ currentScopeId = scopeStack.pop();
261
+ } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
262
+ let next = data2.indexOf(" ");
263
+ let curNode = visit;
264
+ scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
265
+ while (~next) {
266
+ const start = next + 1;
267
+ next = data2.indexOf(" ", start);
268
+ const childScopeId = data2.slice(
269
+ start,
270
+ ~next ? next : data2.length
271
+ );
272
+ curNode = branchEnd(childScopeId, visit, curNode).___endNode;
305
273
  }
306
274
  }
307
275
  }
308
- } else if (i === len || typeof resumes[i] !== "string") {
309
- delete this.___renders[this.___renderId];
310
- } else {
311
- registeredValues[resumes[i++]](
312
- scopeLookup[resumeData],
313
- scopeLookup[resumeData]
314
- );
315
276
  }
316
- }
317
- } finally {
318
- isResuming = false;
277
+ if (resumes) {
278
+ try {
279
+ render.r = [];
280
+ isResuming = true;
281
+ for (let i = 0; i < resumes.length; i++) {
282
+ const serialized = resumes[i];
283
+ if (typeof serialized === "function") {
284
+ const scopes = serialized(serializeContext);
285
+ let { $global } = scopeLookup;
286
+ if (!$global) {
287
+ scopeLookup.$global = $global = scopes.$ || {};
288
+ $global.runtimeId = runtimeId;
289
+ $global.renderId = renderId;
290
+ $global.___nextScopeId = 1e6;
291
+ }
292
+ for (const scopeId in scopes) {
293
+ if (scopeId !== "$") {
294
+ const scope = scopes[scopeId];
295
+ const prevScope = scopeLookup[scopeId];
296
+ scope.$global = $global;
297
+ scope.___id = +scopeId;
298
+ if (prevScope !== scope) {
299
+ scopeLookup[scopeId] = Object.assign(
300
+ scope,
301
+ prevScope
302
+ );
303
+ }
304
+ const parentBranchId = parentBranchIds.get(scopeId);
305
+ if (parentBranchId) {
306
+ scope.___closestBranch = scopes[parentBranchId];
307
+ }
308
+ if (branchIds.has(scopeId)) {
309
+ const branch = scope;
310
+ const parentBranch = branch.___closestBranch;
311
+ scope.___closestBranch = branch;
312
+ if (parentBranch) {
313
+ branch.___parentBranch = parentBranch;
314
+ (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(
315
+ branch
316
+ );
317
+ }
318
+ }
319
+ if (true) {
320
+ scope.___debugId = "server-" + scopeId;
321
+ }
322
+ }
323
+ }
324
+ } else {
325
+ registeredValues[resumes[++i]](
326
+ scopeLookup[serialized],
327
+ scopeLookup[serialized]
328
+ );
329
+ }
330
+ }
331
+ } finally {
332
+ isResuming = false;
333
+ }
334
+ }
335
+ };
336
+ return render;
319
337
  }
338
+ });
339
+ };
340
+ if (renders) {
341
+ initRuntime(renders);
342
+ for (const renderId in renders) {
343
+ resumeRender(renderId).w();
320
344
  }
345
+ } else {
346
+ defineRuntime({
347
+ configurable: true,
348
+ set: initRuntime
349
+ });
321
350
  }
322
- };
351
+ }
323
352
  var isResuming = false;
324
353
  function register(id, obj) {
325
354
  registeredValues[id] = obj;
@@ -333,42 +362,6 @@ function getRegisteredWithScope(id, scope) {
333
362
  const val = registeredValues[id];
334
363
  return scope ? val(scope) : val;
335
364
  }
336
- function init(runtimeId = DEFAULT_RUNTIME_ID) {
337
- if (true) {
338
- if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
339
- throw new Error(
340
- `Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
341
- );
342
- }
343
- }
344
- const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
345
- let renders;
346
- if (window[runtimeId]) {
347
- setRenders(window[runtimeId]);
348
- } else {
349
- Object.defineProperty(window, runtimeId, {
350
- configurable: true,
351
- set: setRenders
352
- });
353
- }
354
- function setRenders(v) {
355
- if (true) {
356
- if (renders) {
357
- throw new Error(
358
- "Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
359
- );
360
- }
361
- }
362
- renders = v;
363
- for (const renderId in v) {
364
- resumeRender(renderId);
365
- }
366
- Object.defineProperty(window, runtimeId, {
367
- configurable: true,
368
- value: resumeRender
369
- });
370
- }
371
- }
372
365
  function nodeRef(id, key) {
373
366
  return register(id, (scope) => () => scope[key]());
374
367
  }
@@ -950,134 +943,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
950
943
  branch.___endNode
951
944
  );
952
945
  }
953
-
954
- // src/dom/queue.ts
955
- var pendingRenders = [];
956
- var pendingRendersLookup = /* @__PURE__ */ new Map();
957
- var pendingEffects = [];
958
- var rendering = false;
959
- var scopeKeyOffset = 1e3;
960
- function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
961
- const key = scopeKey * scopeKeyOffset + signalKey;
962
- const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
963
- if (existingRender) {
964
- existingRender.___value = value2;
965
- } else {
966
- const render = {
967
- ___key: key,
968
- ___scope: scope,
969
- ___signal: signal,
970
- ___value: value2
971
- };
972
- let i = pendingRenders.push(render) - 1;
973
- while (i) {
974
- const parentIndex = i - 1 >> 1;
975
- const parent = pendingRenders[parentIndex];
976
- if (key - parent.___key >= 0) break;
977
- pendingRenders[i] = parent;
978
- i = parentIndex;
979
- }
980
- signalKey >= 0 && pendingRendersLookup.set(key, render);
981
- pendingRenders[i] = render;
982
- }
983
- }
984
- function queueEffect(scope, fn) {
985
- pendingEffects.push(fn, scope);
986
- }
987
- function run() {
988
- const effects = pendingEffects;
989
- try {
990
- rendering = true;
991
- runRenders();
992
- } finally {
993
- pendingRenders = [];
994
- pendingRendersLookup = /* @__PURE__ */ new Map();
995
- pendingEffects = [];
996
- rendering = false;
997
- }
998
- runEffects(effects);
999
- }
1000
- function prepareEffects(fn) {
1001
- const prevRenders = pendingRenders;
1002
- const prevRendersLookup = pendingRendersLookup;
1003
- const prevEffects = pendingEffects;
1004
- const preparedEffects = pendingEffects = [];
1005
- pendingRenders = [];
1006
- pendingRendersLookup = /* @__PURE__ */ new Map();
1007
- try {
1008
- rendering = true;
1009
- fn();
1010
- runRenders();
1011
- } finally {
1012
- rendering = false;
1013
- pendingRenders = prevRenders;
1014
- pendingRendersLookup = prevRendersLookup;
1015
- pendingEffects = prevEffects;
1016
- }
1017
- return preparedEffects;
1018
- }
1019
- function runEffects(effects) {
1020
- for (let i = 0, scope; i < effects.length; ) {
1021
- effects[i++](
1022
- scope = effects[i++],
1023
- scope
1024
- );
1025
- }
1026
- }
1027
- function runRenders() {
1028
- while (pendingRenders.length) {
1029
- const render = pendingRenders[0];
1030
- const item = pendingRenders.pop();
1031
- if (render !== item) {
1032
- let i = 0;
1033
- const mid = pendingRenders.length >> 1;
1034
- const key = (pendingRenders[0] = item).___key;
1035
- while (i < mid) {
1036
- let bestChild = (i << 1) + 1;
1037
- const right = bestChild + 1;
1038
- if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
1039
- bestChild = right;
1040
- }
1041
- if (pendingRenders[bestChild].___key - key >= 0) {
1042
- break;
1043
- } else {
1044
- pendingRenders[i] = pendingRenders[bestChild];
1045
- i = bestChild;
1046
- }
1047
- }
1048
- pendingRenders[i] = item;
1049
- }
1050
- if (!render.___scope.___closestBranch?.___destroyed) {
1051
- render.___signal(render.___scope, render.___value);
1052
- }
1053
- }
1054
- finishPendingScopes();
1055
- }
1056
-
1057
- // src/dom/abort-signal.ts
1058
- function resetAbortSignal(scope, id) {
1059
- const ctrl = scope.___abortControllers?.[id];
1060
- if (ctrl) {
1061
- queueEffect(ctrl, abort);
1062
- scope.___abortControllers[id] = void 0;
1063
- }
1064
- }
1065
- function getAbortSignal(scope, id) {
1066
- if (scope.___closestBranch) {
1067
- (scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
1068
- }
1069
- return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
1070
- }
1071
- function abort(ctrl) {
1072
- ctrl.abort();
946
+ function tempDetatchBranch(branch) {
947
+ insertChildNodes(
948
+ branch.___startNode.ownerDocument.createDocumentFragment(),
949
+ null,
950
+ branch.___startNode,
951
+ branch.___endNode
952
+ );
1073
953
  }
1074
954
 
1075
- // src/common/compat-meta.ts
1076
- var prefix = true ? "$compat_" : "$C_";
1077
- var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
1078
- var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
1079
- var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
1080
-
1081
955
  // src/dom/reconcile.ts
1082
956
  var WRONG_POS = 2147483647;
1083
957
  function reconcile(parent, oldBranches, newBranches, afterReference) {
@@ -1654,6 +1528,132 @@ function hoist(...path) {
1654
1528
  }
1655
1529
 
1656
1530
  // src/dom/control-flow.ts
1531
+ function awaitTag(nodeAccessor, renderer) {
1532
+ const promiseAccessor = nodeAccessor + "?" /* Promise */;
1533
+ const branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
1534
+ return (scope, promise) => {
1535
+ let tryBranch = scope.___closestBranch;
1536
+ let awaitBranch = scope[branchAccessor];
1537
+ const referenceNode = scope[nodeAccessor];
1538
+ const namespaceNode = (awaitBranch?.___startNode ?? referenceNode).parentNode;
1539
+ while (tryBranch && !tryBranch["%" /* PlaceholderContent */]) {
1540
+ tryBranch = tryBranch.___parentBranch;
1541
+ }
1542
+ const thisPromise = scope[promiseAccessor] = promise.then((data2) => {
1543
+ if (scope.___closestBranch?.___destroyed || scope[promiseAccessor] !== thisPromise) {
1544
+ return;
1545
+ }
1546
+ scope[promiseAccessor] = void 0;
1547
+ const effects = prepareEffects(() => {
1548
+ if (!awaitBranch || !tryBranch) {
1549
+ insertBranchBefore(
1550
+ awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
1551
+ scope.$global,
1552
+ renderer,
1553
+ scope,
1554
+ namespaceNode
1555
+ ),
1556
+ referenceNode.parentNode,
1557
+ referenceNode
1558
+ );
1559
+ referenceNode.remove();
1560
+ }
1561
+ renderer.___params?.(awaitBranch, [data2]);
1562
+ });
1563
+ if (tryBranch) {
1564
+ if (!--tryBranch["." /* PendingCount */]) {
1565
+ const placeholderBranch = tryBranch["#" /* PlaceholderBranch */];
1566
+ if (placeholderBranch) {
1567
+ insertBranchBefore(
1568
+ tryBranch,
1569
+ placeholderBranch.___startNode.parentNode,
1570
+ placeholderBranch.___startNode
1571
+ );
1572
+ removeAndDestroyBranch(placeholderBranch);
1573
+ } else {
1574
+ insertBranchBefore(
1575
+ tryBranch,
1576
+ referenceNode.parentNode,
1577
+ referenceNode
1578
+ );
1579
+ }
1580
+ }
1581
+ } else {
1582
+ runEffects(effects);
1583
+ }
1584
+ }).catch((error) => {
1585
+ let tryBranch2 = scope.___closestBranch;
1586
+ while (tryBranch2 && !tryBranch2["^" /* CatchContent */]) {
1587
+ tryBranch2 = tryBranch2.___parentBranch;
1588
+ }
1589
+ if (!tryBranch2) {
1590
+ setTimeout(() => {
1591
+ throw error;
1592
+ });
1593
+ } else {
1594
+ setConditionalRenderer(
1595
+ tryBranch2._,
1596
+ tryBranch2["*" /* BranchAccessor */],
1597
+ tryBranch2["^" /* CatchContent */],
1598
+ createAndSetupBranch
1599
+ );
1600
+ tryBranch2["^" /* CatchContent */].___params?.(
1601
+ tryBranch2._[tryBranch2["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
1602
+ [error]
1603
+ );
1604
+ }
1605
+ });
1606
+ if (tryBranch) {
1607
+ if (!tryBranch["." /* PendingCount */]) {
1608
+ tryBranch["." /* PendingCount */] = 0;
1609
+ requestAnimationFrame(() => {
1610
+ if (tryBranch["." /* PendingCount */] && !tryBranch.___destroyed) {
1611
+ const placeholderBranch = tryBranch["#" /* PlaceholderBranch */] = createAndSetupBranch(
1612
+ scope.$global,
1613
+ tryBranch["%" /* PlaceholderContent */],
1614
+ tryBranch._,
1615
+ tryBranch.___startNode.parentNode
1616
+ );
1617
+ insertBranchBefore(
1618
+ placeholderBranch,
1619
+ tryBranch.___startNode.parentNode,
1620
+ tryBranch.___startNode
1621
+ );
1622
+ tempDetatchBranch(tryBranch);
1623
+ }
1624
+ });
1625
+ }
1626
+ tryBranch["." /* PendingCount */]++;
1627
+ } else if (awaitBranch) {
1628
+ awaitBranch.___startNode.parentNode.insertBefore(
1629
+ referenceNode,
1630
+ awaitBranch.___startNode
1631
+ );
1632
+ tempDetatchBranch(awaitBranch);
1633
+ }
1634
+ };
1635
+ }
1636
+ function createTry(nodeAccessor, tryContent) {
1637
+ const branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
1638
+ return (scope, input) => {
1639
+ if (!scope[branchAccessor]) {
1640
+ setConditionalRenderer(
1641
+ scope,
1642
+ nodeAccessor,
1643
+ tryContent,
1644
+ createAndSetupBranch
1645
+ );
1646
+ }
1647
+ const branch = scope[branchAccessor];
1648
+ if (branch) {
1649
+ branch["*" /* BranchAccessor */] = nodeAccessor;
1650
+ branch["^" /* CatchContent */] = normalizeDynamicRenderer(input.catch);
1651
+ branch["%" /* PlaceholderContent */] = normalizeDynamicRenderer(
1652
+ input.placeholder
1653
+ );
1654
+ }
1655
+ };
1656
+ }
1657
1657
  function conditional(nodeAccessor, ...branches) {
1658
1658
  const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
1659
1659
  return (scope, newBranch) => {
@@ -1849,6 +1849,161 @@ function byFirstArg(name) {
1849
1849
  return name;
1850
1850
  }
1851
1851
 
1852
+ // src/dom/queue.ts
1853
+ var pendingRenders = [];
1854
+ var pendingRendersLookup = /* @__PURE__ */ new Map();
1855
+ var pendingEffects = [];
1856
+ var rendering = false;
1857
+ var scopeKeyOffset = 1e3;
1858
+ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
1859
+ const key = scopeKey * scopeKeyOffset + signalKey;
1860
+ const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1861
+ if (existingRender) {
1862
+ existingRender.___value = value2;
1863
+ } else {
1864
+ const render = {
1865
+ ___key: key,
1866
+ ___scope: scope,
1867
+ ___signal: signal,
1868
+ ___value: value2
1869
+ };
1870
+ let i = pendingRenders.push(render) - 1;
1871
+ while (i) {
1872
+ const parentIndex = i - 1 >> 1;
1873
+ const parent = pendingRenders[parentIndex];
1874
+ if (key - parent.___key >= 0) break;
1875
+ pendingRenders[i] = parent;
1876
+ i = parentIndex;
1877
+ }
1878
+ signalKey >= 0 && pendingRendersLookup.set(key, render);
1879
+ pendingRenders[i] = render;
1880
+ }
1881
+ }
1882
+ function queueEffect(scope, fn) {
1883
+ pendingEffects.push(fn, scope);
1884
+ }
1885
+ function run() {
1886
+ const effects = pendingEffects;
1887
+ try {
1888
+ rendering = true;
1889
+ runRenders();
1890
+ } finally {
1891
+ pendingRenders = [];
1892
+ pendingRendersLookup = /* @__PURE__ */ new Map();
1893
+ pendingEffects = [];
1894
+ rendering = false;
1895
+ }
1896
+ runEffects(effects);
1897
+ }
1898
+ function prepareEffects(fn) {
1899
+ const prevRenders = pendingRenders;
1900
+ const prevRendersLookup = pendingRendersLookup;
1901
+ const prevEffects = pendingEffects;
1902
+ const preparedEffects = pendingEffects = [];
1903
+ pendingRenders = [];
1904
+ pendingRendersLookup = /* @__PURE__ */ new Map();
1905
+ try {
1906
+ rendering = true;
1907
+ fn();
1908
+ runRenders();
1909
+ } finally {
1910
+ rendering = false;
1911
+ pendingRenders = prevRenders;
1912
+ pendingRendersLookup = prevRendersLookup;
1913
+ pendingEffects = prevEffects;
1914
+ }
1915
+ return preparedEffects;
1916
+ }
1917
+ function runEffects(effects) {
1918
+ for (let i = 0, scope; i < effects.length; ) {
1919
+ effects[i++](
1920
+ scope = effects[i++],
1921
+ scope
1922
+ );
1923
+ }
1924
+ }
1925
+ function runRenders() {
1926
+ while (pendingRenders.length) {
1927
+ const render = pendingRenders[0];
1928
+ const item = pendingRenders.pop();
1929
+ if (render !== item) {
1930
+ let i = 0;
1931
+ const mid = pendingRenders.length >> 1;
1932
+ const key = (pendingRenders[0] = item).___key;
1933
+ while (i < mid) {
1934
+ let bestChild = (i << 1) + 1;
1935
+ const right = bestChild + 1;
1936
+ if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
1937
+ bestChild = right;
1938
+ }
1939
+ if (pendingRenders[bestChild].___key - key >= 0) {
1940
+ break;
1941
+ } else {
1942
+ pendingRenders[i] = pendingRenders[bestChild];
1943
+ i = bestChild;
1944
+ }
1945
+ }
1946
+ pendingRenders[i] = item;
1947
+ }
1948
+ if (!render.___scope.___closestBranch?.___destroyed) {
1949
+ runRender(render);
1950
+ }
1951
+ }
1952
+ finishPendingScopes();
1953
+ }
1954
+ var runRender = (render) => render.___signal(render.___scope, render.___value);
1955
+ var enableCatch = () => {
1956
+ enableCatch = () => {
1957
+ };
1958
+ runRender = /* @__PURE__ */ ((runRender2) => (render) => {
1959
+ try {
1960
+ runRender2(render);
1961
+ } catch (error) {
1962
+ let branch = render.___scope.___closestBranch;
1963
+ while (branch && !branch["^" /* CatchContent */])
1964
+ branch = branch.___parentBranch;
1965
+ if (!branch) {
1966
+ throw error;
1967
+ } else {
1968
+ setConditionalRenderer(
1969
+ branch._,
1970
+ branch["*" /* BranchAccessor */],
1971
+ branch["^" /* CatchContent */],
1972
+ createAndSetupBranch
1973
+ );
1974
+ branch["^" /* CatchContent */].___params?.(
1975
+ branch._[branch["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
1976
+ [error]
1977
+ );
1978
+ }
1979
+ }
1980
+ })(runRender);
1981
+ };
1982
+
1983
+ // src/dom/abort-signal.ts
1984
+ function resetAbortSignal(scope, id) {
1985
+ const ctrl = scope.___abortControllers?.[id];
1986
+ if (ctrl) {
1987
+ queueEffect(ctrl, abort);
1988
+ scope.___abortControllers[id] = void 0;
1989
+ }
1990
+ }
1991
+ function getAbortSignal(scope, id) {
1992
+ if (scope.___closestBranch) {
1993
+ (scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
1994
+ }
1995
+ return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
1996
+ }
1997
+ function abort(ctrl) {
1998
+ ctrl.abort();
1999
+ }
2000
+
2001
+ // src/common/compat-meta.ts
2002
+ var prefix = true ? "$compat_" : "$C_";
2003
+ var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
2004
+ var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
2005
+ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
2006
+
1852
2007
  // src/dom/compat.ts
1853
2008
  var classIdToBranch = /* @__PURE__ */ new Map();
1854
2009
  var compat = {
@@ -1888,7 +2043,7 @@ var compat = {
1888
2043
  if (Array.isArray(value2) && typeof value2[0] === "string") {
1889
2044
  return getRegisteredWithScope(
1890
2045
  value2[0],
1891
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.___scopeLookup[value2[1]]
2046
+ value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1892
2047
  );
1893
2048
  }
1894
2049
  return value2;
@@ -2031,6 +2186,7 @@ export {
2031
2186
  attrTags,
2032
2187
  attrs,
2033
2188
  attrsEvents,
2189
+ awaitTag,
2034
2190
  classAttr,
2035
2191
  compat,
2036
2192
  conditional,
@@ -2050,11 +2206,13 @@ export {
2050
2206
  createContent,
2051
2207
  createRenderer,
2052
2208
  createTemplate,
2209
+ createTry,
2053
2210
  data,
2054
2211
  dynamicClosure,
2055
2212
  dynamicClosureRead,
2056
2213
  dynamicTag,
2057
2214
  effect,
2215
+ enableCatch,
2058
2216
  forIn,
2059
2217
  forOf,
2060
2218
  forTo,