marko 6.0.61 → 6.0.63

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.
@@ -28,9 +28,10 @@ export declare enum ResumeSymbol {
28
28
  Node = "*",
29
29
  BranchStart = "[",
30
30
  BranchEnd = "]",
31
- BranchSingleNode = "|",
32
- BranchNativeTag = "'",
33
- BranchSingleNodeOnlyChildInParent = "="
31
+ BranchEndNativeTag = "'",
32
+ BranchEndSingleNode = "|",
33
+ BranchEndOnlyChildInParent = ")",
34
+ BranchEndSingleNodeOnlyChildInParent = "}"
34
35
  }
35
36
  export { AccessorPrefix, AccessorProp } from "./accessor.debug";
36
37
  export declare enum NodeType {
package/dist/debug/dom.js CHANGED
@@ -398,84 +398,72 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
398
398
  value: resumeRender = ((renderId) => {
399
399
  const render = resumeRender[renderId] = renders2[renderId] || renders2(renderId);
400
400
  const walk2 = render.w;
401
- const commentPrefixLen = render.i.length;
402
401
  const scopeLookup = render.s = {};
403
402
  const serializeContext = {
404
403
  _: registeredValues
405
404
  };
406
405
  const branches = branchesEnabled && /* @__PURE__ */ (() => {
407
- const branchStack = [];
408
- const branchIds = /* @__PURE__ */ new Set();
409
- const parentBranchIds = /* @__PURE__ */ new Map();
410
- let lastEndNode;
411
- let currentBranchId;
412
- const endBranch = (branchId, reference) => {
413
- const branch = scopeLookup[branchId] ||= {};
414
- let endNode = reference;
415
- let prevNode;
416
- while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
417
- branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
418
- branch.___startNode ||= lastEndNode;
419
- branchIds.add(branchId);
420
- return branch;
406
+ const branchParents = /* @__PURE__ */ new Map();
407
+ const branchStarts = [];
408
+ const orphanBranches = [];
409
+ const endBranch = (singleNode) => {
410
+ const parent = visit.parentNode;
411
+ let startVisit = visit;
412
+ let i = orphanBranches.length;
413
+ let claimed = 0;
414
+ let branchId;
415
+ let branch;
416
+ while (branchId = +lastToken) {
417
+ branch = scopeLookup[branchId] ||= {};
418
+ if (singleNode) {
419
+ while (startVisit.previousSibling && ~visits.indexOf(
420
+ startVisit = startVisit.previousSibling
421
+ )) ;
422
+ branch.___endNode = branch.___startNode = startVisit;
423
+ if (visitType === "'" /* BranchEndNativeTag */) {
424
+ branch[true ? getDebugKey(0, startVisit) : 0] = startVisit;
425
+ }
426
+ } else {
427
+ startVisit = branchStarts.pop();
428
+ if (parent !== startVisit.parentNode) {
429
+ parent.prepend(startVisit);
430
+ }
431
+ branch.___startNode = startVisit;
432
+ branch.___endNode = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
433
+ }
434
+ while (i-- && orphanBranches[i] > branchId) {
435
+ branchParents.set(orphanBranches[i], branchId);
436
+ claimed++;
437
+ }
438
+ orphanBranches.push(branchId);
439
+ branchParents.set(branchId, 0);
440
+ nextToken();
441
+ }
442
+ orphanBranches.splice(i, claimed);
421
443
  };
422
444
  return {
423
445
  ___visit() {
424
- if (visitToken === "[" /* BranchStart */) {
425
- if (currentBranchId && visitDataIndex) {
426
- endBranch(currentBranchId, visit);
427
- currentBranchId = branchStack.pop();
428
- }
429
- if (currentBranchId) {
430
- branchStack.push(currentBranchId);
431
- parentBranchIds.set(scopeId, currentBranchId);
432
- }
433
- currentBranchId = scopeId;
434
- visitScope.___startNode = visit;
435
- } else if (visitToken === "]" /* BranchEnd */) {
436
- const curParent = visit.parentNode;
437
- const startNode = endBranch(
438
- currentBranchId,
439
- visit
440
- ).___startNode;
441
- visitScope[visitData] = visit;
442
- if (curParent !== startNode.parentNode) {
443
- curParent.prepend(startNode);
444
- }
445
- currentBranchId = branchStack.pop();
446
+ if (visitType === "[" /* BranchStart */) {
447
+ endBranch();
448
+ branchStarts.push(visit);
446
449
  } else {
447
- let next = visitData.indexOf(" ");
448
- let curNode = visit;
449
- visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
450
- while (~next) {
451
- const start = next + 1;
452
- next = visitData.indexOf(" ", start);
453
- const childScopeId = +visitData.slice(
454
- start,
455
- ~next ? next : visitData.length
456
- );
457
- curNode = endBranch(childScopeId, curNode).___endNode;
458
- parentBranchIds.set(childScopeId, scopeId);
459
- if (visitToken === "'" /* BranchNativeTag */) {
460
- const childBranch = scopeLookup[childScopeId];
461
- childBranch[true ? getDebugKey(0, curNode) : 0] = childBranch.___startNode = childBranch.___endNode = curNode;
462
- }
463
- }
450
+ visitScope[
451
+ nextToken()
452
+ /* read accessor */
453
+ ] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
454
+ nextToken();
455
+ endBranch(
456
+ visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */
457
+ );
464
458
  }
465
459
  },
466
460
  ___scope(scope) {
467
- const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
468
- if (parentBranchId) {
469
- scope.___closestBranch = scopeLookup[parentBranchId];
470
- }
471
- if (branchIds.has(scopeId)) {
472
- const branch = scope;
473
- const parentBranch = branch.___closestBranch;
474
- scope.___closestBranch = branch;
475
- if (parentBranch) {
476
- branch.___parentBranch = parentBranch;
477
- (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
461
+ scope.___closestBranch = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */] || branchParents.get(scopeId)];
462
+ if (branchParents.has(scopeId)) {
463
+ if (scope.___closestBranch) {
464
+ ((scope.___parentBranch = scope.___closestBranch).___branchScopes ||= /* @__PURE__ */ new Set()).add(scope);
478
465
  }
466
+ scope.___closestBranch = scope;
479
467
  }
480
468
  }
481
469
  };
@@ -488,29 +476,31 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
488
476
  let scopeId;
489
477
  let visit;
490
478
  let visitText;
491
- let visitData;
492
- let visitDataIndex;
493
- let visitToken;
479
+ let visitType;
494
480
  let visitScope;
481
+ let lastToken;
482
+ let lastTokenIndex;
483
+ const nextToken = () => lastToken = visitText.slice(
484
+ lastTokenIndex,
485
+ // eslint-disable-next-line no-cond-assign
486
+ (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
487
+ );
495
488
  render.w = () => {
496
489
  try {
497
490
  walk2();
498
491
  isResuming = 1;
499
492
  for (visit of visits = render.v) {
493
+ lastTokenIndex = render.i.length;
500
494
  visitText = visit.data;
501
- visitDataIndex = visitText.indexOf(" ") + 1;
502
- scopeId = +visitText.slice(
503
- commentPrefixLen + 1,
504
- visitDataIndex ? visitDataIndex - 1 : visitText.length
505
- );
506
- visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
507
- visitToken = visitText[commentPrefixLen];
508
- visitScope = scopeLookup[scopeId] ||= {
509
- ___id: scopeId
510
- };
511
- if (visitToken === "*" /* Node */) {
512
- visitScope["Getter:" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling);
513
- } else if (branches) {
495
+ visitType = visitText[lastTokenIndex++];
496
+ if (scopeId = +nextToken()) {
497
+ visitScope = scopeLookup[scopeId] ||= {
498
+ ___id: scopeId
499
+ };
500
+ }
501
+ if (visitType === "*" /* Node */) {
502
+ visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
503
+ } else if (branchesEnabled) {
514
504
  branches.___visit();
515
505
  }
516
506
  }
@@ -543,7 +533,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
543
533
  scopeLookup[scopeId]
544
534
  );
545
535
  }
546
- if (branches) {
536
+ if (branchesEnabled) {
547
537
  branches.___scope(scope);
548
538
  }
549
539
  if (true) {
@@ -301,84 +301,72 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
301
301
  value: resumeRender = ((renderId) => {
302
302
  const render = resumeRender[renderId] = renders2[renderId] || renders2(renderId);
303
303
  const walk2 = render.w;
304
- const commentPrefixLen = render.i.length;
305
304
  const scopeLookup = render.s = {};
306
305
  const serializeContext = {
307
306
  _: registeredValues
308
307
  };
309
308
  const branches = branchesEnabled && /* @__PURE__ */ (() => {
310
- const branchStack = [];
311
- const branchIds = /* @__PURE__ */ new Set();
312
- const parentBranchIds = /* @__PURE__ */ new Map();
313
- let lastEndNode;
314
- let currentBranchId;
315
- const endBranch = (branchId, reference) => {
316
- const branch = scopeLookup[branchId] ||= {};
317
- let endNode = reference;
318
- let prevNode;
319
- while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
320
- branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
321
- branch.___startNode ||= lastEndNode;
322
- branchIds.add(branchId);
323
- return branch;
309
+ const branchParents = /* @__PURE__ */ new Map();
310
+ const branchStarts = [];
311
+ const orphanBranches = [];
312
+ const endBranch = (singleNode) => {
313
+ const parent = visit.parentNode;
314
+ let startVisit = visit;
315
+ let i = orphanBranches.length;
316
+ let claimed = 0;
317
+ let branchId;
318
+ let branch;
319
+ while (branchId = +lastToken) {
320
+ branch = scopeLookup[branchId] ||= {};
321
+ if (singleNode) {
322
+ while (startVisit.previousSibling && ~visits.indexOf(
323
+ startVisit = startVisit.previousSibling
324
+ )) ;
325
+ branch.___endNode = branch.___startNode = startVisit;
326
+ if (visitType === "'" /* BranchEndNativeTag */) {
327
+ branch[true ? getDebugKey(0, startVisit) : 0] = startVisit;
328
+ }
329
+ } else {
330
+ startVisit = branchStarts.pop();
331
+ if (parent !== startVisit.parentNode) {
332
+ parent.prepend(startVisit);
333
+ }
334
+ branch.___startNode = startVisit;
335
+ branch.___endNode = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
336
+ }
337
+ while (i-- && orphanBranches[i] > branchId) {
338
+ branchParents.set(orphanBranches[i], branchId);
339
+ claimed++;
340
+ }
341
+ orphanBranches.push(branchId);
342
+ branchParents.set(branchId, 0);
343
+ nextToken();
344
+ }
345
+ orphanBranches.splice(i, claimed);
324
346
  };
325
347
  return {
326
348
  ___visit() {
327
- if (visitToken === "[" /* BranchStart */) {
328
- if (currentBranchId && visitDataIndex) {
329
- endBranch(currentBranchId, visit);
330
- currentBranchId = branchStack.pop();
331
- }
332
- if (currentBranchId) {
333
- branchStack.push(currentBranchId);
334
- parentBranchIds.set(scopeId, currentBranchId);
335
- }
336
- currentBranchId = scopeId;
337
- visitScope.___startNode = visit;
338
- } else if (visitToken === "]" /* BranchEnd */) {
339
- const curParent = visit.parentNode;
340
- const startNode = endBranch(
341
- currentBranchId,
342
- visit
343
- ).___startNode;
344
- visitScope[visitData] = visit;
345
- if (curParent !== startNode.parentNode) {
346
- curParent.prepend(startNode);
347
- }
348
- currentBranchId = branchStack.pop();
349
+ if (visitType === "[" /* BranchStart */) {
350
+ endBranch();
351
+ branchStarts.push(visit);
349
352
  } else {
350
- let next = visitData.indexOf(" ");
351
- let curNode = visit;
352
- visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
353
- while (~next) {
354
- const start = next + 1;
355
- next = visitData.indexOf(" ", start);
356
- const childScopeId = +visitData.slice(
357
- start,
358
- ~next ? next : visitData.length
359
- );
360
- curNode = endBranch(childScopeId, curNode).___endNode;
361
- parentBranchIds.set(childScopeId, scopeId);
362
- if (visitToken === "'" /* BranchNativeTag */) {
363
- const childBranch = scopeLookup[childScopeId];
364
- childBranch[true ? getDebugKey(0, curNode) : 0] = childBranch.___startNode = childBranch.___endNode = curNode;
365
- }
366
- }
353
+ visitScope[
354
+ nextToken()
355
+ /* read accessor */
356
+ ] = visitType === ")" /* BranchEndOnlyChildInParent */ || visitType === "}" /* BranchEndSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
357
+ nextToken();
358
+ endBranch(
359
+ visitType !== "]" /* BranchEnd */ && visitType !== ")" /* BranchEndOnlyChildInParent */
360
+ );
367
361
  }
368
362
  },
369
363
  ___scope(scope) {
370
- const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
371
- if (parentBranchId) {
372
- scope.___closestBranch = scopeLookup[parentBranchId];
373
- }
374
- if (branchIds.has(scopeId)) {
375
- const branch = scope;
376
- const parentBranch = branch.___closestBranch;
377
- scope.___closestBranch = branch;
378
- if (parentBranch) {
379
- branch.___parentBranch = parentBranch;
380
- (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
364
+ scope.___closestBranch = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */] || branchParents.get(scopeId)];
365
+ if (branchParents.has(scopeId)) {
366
+ if (scope.___closestBranch) {
367
+ ((scope.___parentBranch = scope.___closestBranch).___branchScopes ||= /* @__PURE__ */ new Set()).add(scope);
381
368
  }
369
+ scope.___closestBranch = scope;
382
370
  }
383
371
  }
384
372
  };
@@ -391,29 +379,31 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
391
379
  let scopeId;
392
380
  let visit;
393
381
  let visitText;
394
- let visitData;
395
- let visitDataIndex;
396
- let visitToken;
382
+ let visitType;
397
383
  let visitScope;
384
+ let lastToken;
385
+ let lastTokenIndex;
386
+ const nextToken = () => lastToken = visitText.slice(
387
+ lastTokenIndex,
388
+ // eslint-disable-next-line no-cond-assign
389
+ (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
390
+ );
398
391
  render.w = () => {
399
392
  try {
400
393
  walk2();
401
394
  isResuming = 1;
402
395
  for (visit of visits = render.v) {
396
+ lastTokenIndex = render.i.length;
403
397
  visitText = visit.data;
404
- visitDataIndex = visitText.indexOf(" ") + 1;
405
- scopeId = +visitText.slice(
406
- commentPrefixLen + 1,
407
- visitDataIndex ? visitDataIndex - 1 : visitText.length
408
- );
409
- visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
410
- visitToken = visitText[commentPrefixLen];
411
- visitScope = scopeLookup[scopeId] ||= {
412
- ___id: scopeId
413
- };
414
- if (visitToken === "*" /* Node */) {
415
- visitScope["Getter:" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling);
416
- } else if (branches) {
398
+ visitType = visitText[lastTokenIndex++];
399
+ if (scopeId = +nextToken()) {
400
+ visitScope = scopeLookup[scopeId] ||= {
401
+ ___id: scopeId
402
+ };
403
+ }
404
+ if (visitType === "*" /* Node */) {
405
+ visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
406
+ } else if (branchesEnabled) {
417
407
  branches.___visit();
418
408
  }
419
409
  }
@@ -446,7 +436,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
446
436
  scopeLookup[scopeId]
447
437
  );
448
438
  }
449
- if (branches) {
439
+ if (branchesEnabled) {
450
440
  branches.___scope(scope);
451
441
  }
452
442
  if (true) {