marko 6.0.10 → 6.0.12

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/debug/dom.js CHANGED
@@ -273,87 +273,115 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
273
273
  const render = resumeRender[renderId] = renders2[renderId] || renders2(renderId);
274
274
  const walk2 = render.w;
275
275
  const commentPrefixLen = render.i.length;
276
- const branchStack = [];
277
276
  const scopeLookup = render.s = {};
278
277
  const serializeContext = {
279
278
  _: registeredValues
280
279
  };
281
- const branchIds = /* @__PURE__ */ new Set();
282
- const parentBranchIds = /* @__PURE__ */ new Map();
283
- const branchEnd = (branchId, reference) => {
284
- const branch = scopeLookup[branchId] ||= {};
285
- let endNode = reference;
286
- let prevNode;
287
- while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
288
- branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
289
- branch.___startNode ||= lastEndNode;
290
- branchIds.add(branchId);
291
- return branch;
292
- };
293
- let currentBranchId;
280
+ const branches = branchesEnabled && /* @__PURE__ */ (() => {
281
+ const branchStack = [];
282
+ const branchIds = /* @__PURE__ */ new Set();
283
+ const parentBranchIds = /* @__PURE__ */ new Map();
284
+ let lastEndNode;
285
+ let currentBranchId;
286
+ const endBranch = (branchId, reference) => {
287
+ const branch = scopeLookup[branchId] ||= {};
288
+ let endNode = reference;
289
+ let prevNode;
290
+ while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
291
+ branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
292
+ branch.___startNode ||= lastEndNode;
293
+ branchIds.add(branchId);
294
+ return branch;
295
+ };
296
+ return {
297
+ ___visit() {
298
+ if (visitToken === "[" /* BranchStart */) {
299
+ if (currentBranchId && visitDataIndex) {
300
+ endBranch(currentBranchId, visit);
301
+ currentBranchId = branchStack.pop();
302
+ }
303
+ if (currentBranchId) {
304
+ branchStack.push(currentBranchId);
305
+ parentBranchIds.set(scopeId, currentBranchId);
306
+ }
307
+ currentBranchId = scopeId;
308
+ visitScope.___startNode = visit;
309
+ } else if (visitToken === "]" /* BranchEnd */) {
310
+ const curParent = visit.parentNode;
311
+ const startNode = endBranch(
312
+ currentBranchId,
313
+ visit
314
+ ).___startNode;
315
+ visitScope[visitData] = visit;
316
+ if (curParent !== startNode.parentNode) {
317
+ curParent.prepend(startNode);
318
+ }
319
+ currentBranchId = branchStack.pop();
320
+ } else {
321
+ let next = visitData.indexOf(" ");
322
+ let curNode = visit;
323
+ visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
324
+ while (~next) {
325
+ const start = next + 1;
326
+ next = visitData.indexOf(" ", start);
327
+ const childScopeId = +visitData.slice(
328
+ start,
329
+ ~next ? next : visitData.length
330
+ );
331
+ curNode = endBranch(childScopeId, curNode).___endNode;
332
+ parentBranchIds.set(childScopeId, scopeId);
333
+ }
334
+ }
335
+ },
336
+ ___scope(scope) {
337
+ const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
338
+ if (parentBranchId) {
339
+ scope.___closestBranch = scopeLookup[parentBranchId];
340
+ }
341
+ if (branchIds.has(scopeId)) {
342
+ const branch = scope;
343
+ const parentBranch = branch.___closestBranch;
344
+ scope.___closestBranch = branch;
345
+ if (parentBranch) {
346
+ branch.___parentBranch = parentBranch;
347
+ (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
348
+ }
349
+ }
350
+ }
351
+ };
352
+ })();
294
353
  let $global;
295
354
  let lastScopeId = 0;
296
355
  let lastEffect;
297
- let lastEndNode;
298
356
  let visits;
299
357
  let resumes;
358
+ let scopeId;
359
+ let visit;
360
+ let visitText;
361
+ let visitData;
362
+ let visitDataIndex;
363
+ let visitToken;
364
+ let visitScope;
300
365
  render.w = () => {
301
366
  try {
302
367
  walk2();
303
368
  isResuming = 1;
304
- for (const visit of visits = render.v) {
305
- const commentText = visit.data;
306
- const dataIndex = commentText.indexOf(" ") + 1;
307
- const scopeId = +commentText.slice(
369
+ for (visit of visits = render.v) {
370
+ visitText = visit.data;
371
+ visitDataIndex = visitText.indexOf(" ") + 1;
372
+ scopeId = +visitText.slice(
308
373
  commentPrefixLen + 1,
309
- dataIndex ? dataIndex - 1 : commentText.length
374
+ visitDataIndex ? visitDataIndex - 1 : visitText.length
310
375
  );
311
- const scope = scopeLookup[scopeId] ||= {
376
+ visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
377
+ visitToken = visitText[commentPrefixLen];
378
+ visitScope = scopeLookup[scopeId] ||= {
312
379
  ___id: scopeId
313
380
  };
314
- const data2 = dataIndex ? commentText.slice(dataIndex) : "";
315
- const token = commentText[commentPrefixLen];
316
- if (token === "*" /* Node */) {
317
- const node = scope[data2] = visit.previousSibling;
318
- scope["Getter:" /* Getter */ + data2] = () => node;
319
- } else if (branchesEnabled) {
320
- if (token === "[" /* BranchStart */) {
321
- if (currentBranchId && dataIndex) {
322
- branchEnd(currentBranchId, visit);
323
- currentBranchId = branchStack.pop();
324
- }
325
- if (currentBranchId) {
326
- branchStack.push(currentBranchId);
327
- parentBranchIds.set(scopeId, currentBranchId);
328
- }
329
- currentBranchId = scopeId;
330
- scope.___startNode = visit;
331
- } else if (token === "]" /* BranchEnd */) {
332
- scope[data2] = visit;
333
- const curParent = visit.parentNode;
334
- const startNode = branchEnd(
335
- currentBranchId,
336
- visit
337
- ).___startNode;
338
- if (curParent !== startNode.parentNode) {
339
- curParent.prepend(startNode);
340
- }
341
- currentBranchId = branchStack.pop();
342
- } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
343
- let next = data2.indexOf(" ");
344
- let curNode = visit;
345
- scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
346
- while (~next) {
347
- const start = next + 1;
348
- next = data2.indexOf(" ", start);
349
- const childScopeId = +data2.slice(
350
- start,
351
- ~next ? next : data2.length
352
- );
353
- curNode = branchEnd(childScopeId, curNode).___endNode;
354
- parentBranchIds.set(childScopeId, scopeId);
355
- }
356
- }
381
+ if (visitToken === "*" /* Node */) {
382
+ visitScope["Getter:" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling);
383
+ } else if (branches) {
384
+ branches.___visit();
357
385
  }
358
386
  }
359
387
  for (const serialized of resumes = render.r || []) {
@@ -374,32 +402,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
374
402
  } else if (typeof scope === "number") {
375
403
  lastScopeId += scope;
376
404
  } else {
377
- const scopeId = ++lastScopeId;
378
- const prevScope = scopeLookup[scopeId];
405
+ scopeId = ++lastScopeId;
379
406
  scope.$global = $global;
380
407
  scope.___id = scopeId;
381
- if (prevScope !== scope) {
408
+ if (scopeLookup[scopeId] !== scope) {
382
409
  scopeLookup[scopeId] = Object.assign(
383
410
  scope,
384
- prevScope
411
+ scopeLookup[scopeId]
385
412
  );
386
413
  }
387
- if (branchesEnabled) {
388
- const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
389
- if (parentBranchId) {
390
- scope.___closestBranch = scopeLookup[parentBranchId];
391
- }
392
- if (branchIds.has(scopeId)) {
393
- const branch = scope;
394
- const parentBranch = branch.___closestBranch;
395
- scope.___closestBranch = branch;
396
- if (parentBranch) {
397
- branch.___parentBranch = parentBranch;
398
- (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(
399
- branch
400
- );
401
- }
402
- }
414
+ if (branches) {
415
+ branches.___scope(scope);
403
416
  }
404
417
  if (true) {
405
418
  scope.___debugId = "server-" + scopeId;
@@ -181,87 +181,115 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
181
181
  const render = resumeRender[renderId] = renders2[renderId] || renders2(renderId);
182
182
  const walk2 = render.w;
183
183
  const commentPrefixLen = render.i.length;
184
- const branchStack = [];
185
184
  const scopeLookup = render.s = {};
186
185
  const serializeContext = {
187
186
  _: registeredValues
188
187
  };
189
- const branchIds = /* @__PURE__ */ new Set();
190
- const parentBranchIds = /* @__PURE__ */ new Map();
191
- const branchEnd = (branchId, reference) => {
192
- const branch = scopeLookup[branchId] ||= {};
193
- let endNode = reference;
194
- let prevNode;
195
- while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
196
- branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
197
- branch.___startNode ||= lastEndNode;
198
- branchIds.add(branchId);
199
- return branch;
200
- };
201
- let currentBranchId;
188
+ const branches = branchesEnabled && /* @__PURE__ */ (() => {
189
+ const branchStack = [];
190
+ const branchIds = /* @__PURE__ */ new Set();
191
+ const parentBranchIds = /* @__PURE__ */ new Map();
192
+ let lastEndNode;
193
+ let currentBranchId;
194
+ const endBranch = (branchId, reference) => {
195
+ const branch = scopeLookup[branchId] ||= {};
196
+ let endNode = reference;
197
+ let prevNode;
198
+ while ((prevNode = endNode.previousSibling) !== branch.___startNode && ~visits.indexOf(endNode = prevNode)) ;
199
+ branch.___endNode = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode;
200
+ branch.___startNode ||= lastEndNode;
201
+ branchIds.add(branchId);
202
+ return branch;
203
+ };
204
+ return {
205
+ ___visit() {
206
+ if (visitToken === "[" /* BranchStart */) {
207
+ if (currentBranchId && visitDataIndex) {
208
+ endBranch(currentBranchId, visit);
209
+ currentBranchId = branchStack.pop();
210
+ }
211
+ if (currentBranchId) {
212
+ branchStack.push(currentBranchId);
213
+ parentBranchIds.set(scopeId, currentBranchId);
214
+ }
215
+ currentBranchId = scopeId;
216
+ visitScope.___startNode = visit;
217
+ } else if (visitToken === "]" /* BranchEnd */) {
218
+ const curParent = visit.parentNode;
219
+ const startNode = endBranch(
220
+ currentBranchId,
221
+ visit
222
+ ).___startNode;
223
+ visitScope[visitData] = visit;
224
+ if (curParent !== startNode.parentNode) {
225
+ curParent.prepend(startNode);
226
+ }
227
+ currentBranchId = branchStack.pop();
228
+ } else {
229
+ let next = visitData.indexOf(" ");
230
+ let curNode = visit;
231
+ visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
232
+ while (~next) {
233
+ const start = next + 1;
234
+ next = visitData.indexOf(" ", start);
235
+ const childScopeId = +visitData.slice(
236
+ start,
237
+ ~next ? next : visitData.length
238
+ );
239
+ curNode = endBranch(childScopeId, curNode).___endNode;
240
+ parentBranchIds.set(childScopeId, scopeId);
241
+ }
242
+ }
243
+ },
244
+ ___scope(scope) {
245
+ const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
246
+ if (parentBranchId) {
247
+ scope.___closestBranch = scopeLookup[parentBranchId];
248
+ }
249
+ if (branchIds.has(scopeId)) {
250
+ const branch = scope;
251
+ const parentBranch = branch.___closestBranch;
252
+ scope.___closestBranch = branch;
253
+ if (parentBranch) {
254
+ branch.___parentBranch = parentBranch;
255
+ (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
256
+ }
257
+ }
258
+ }
259
+ };
260
+ })();
202
261
  let $global;
203
262
  let lastScopeId = 0;
204
263
  let lastEffect;
205
- let lastEndNode;
206
264
  let visits;
207
265
  let resumes;
266
+ let scopeId;
267
+ let visit;
268
+ let visitText;
269
+ let visitData;
270
+ let visitDataIndex;
271
+ let visitToken;
272
+ let visitScope;
208
273
  render.w = () => {
209
274
  try {
210
275
  walk2();
211
276
  isResuming = 1;
212
- for (const visit of visits = render.v) {
213
- const commentText = visit.data;
214
- const dataIndex = commentText.indexOf(" ") + 1;
215
- const scopeId = +commentText.slice(
277
+ for (visit of visits = render.v) {
278
+ visitText = visit.data;
279
+ visitDataIndex = visitText.indexOf(" ") + 1;
280
+ scopeId = +visitText.slice(
216
281
  commentPrefixLen + 1,
217
- dataIndex ? dataIndex - 1 : commentText.length
282
+ visitDataIndex ? visitDataIndex - 1 : visitText.length
218
283
  );
219
- const scope = scopeLookup[scopeId] ||= {
284
+ visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
285
+ visitToken = visitText[commentPrefixLen];
286
+ visitScope = scopeLookup[scopeId] ||= {
220
287
  ___id: scopeId
221
288
  };
222
- const data2 = dataIndex ? commentText.slice(dataIndex) : "";
223
- const token = commentText[commentPrefixLen];
224
- if (token === "*" /* Node */) {
225
- const node = scope[data2] = visit.previousSibling;
226
- scope["Getter:" /* Getter */ + data2] = () => node;
227
- } else if (branchesEnabled) {
228
- if (token === "[" /* BranchStart */) {
229
- if (currentBranchId && dataIndex) {
230
- branchEnd(currentBranchId, visit);
231
- currentBranchId = branchStack.pop();
232
- }
233
- if (currentBranchId) {
234
- branchStack.push(currentBranchId);
235
- parentBranchIds.set(scopeId, currentBranchId);
236
- }
237
- currentBranchId = scopeId;
238
- scope.___startNode = visit;
239
- } else if (token === "]" /* BranchEnd */) {
240
- scope[data2] = visit;
241
- const curParent = visit.parentNode;
242
- const startNode = branchEnd(
243
- currentBranchId,
244
- visit
245
- ).___startNode;
246
- if (curParent !== startNode.parentNode) {
247
- curParent.prepend(startNode);
248
- }
249
- currentBranchId = branchStack.pop();
250
- } else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
251
- let next = data2.indexOf(" ");
252
- let curNode = visit;
253
- scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit;
254
- while (~next) {
255
- const start = next + 1;
256
- next = data2.indexOf(" ", start);
257
- const childScopeId = +data2.slice(
258
- start,
259
- ~next ? next : data2.length
260
- );
261
- curNode = branchEnd(childScopeId, curNode).___endNode;
262
- parentBranchIds.set(childScopeId, scopeId);
263
- }
264
- }
289
+ if (visitToken === "*" /* Node */) {
290
+ visitScope["Getter:" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling);
291
+ } else if (branches) {
292
+ branches.___visit();
265
293
  }
266
294
  }
267
295
  for (const serialized of resumes = render.r || []) {
@@ -282,32 +310,17 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
282
310
  } else if (typeof scope === "number") {
283
311
  lastScopeId += scope;
284
312
  } else {
285
- const scopeId = ++lastScopeId;
286
- const prevScope = scopeLookup[scopeId];
313
+ scopeId = ++lastScopeId;
287
314
  scope.$global = $global;
288
315
  scope.___id = scopeId;
289
- if (prevScope !== scope) {
316
+ if (scopeLookup[scopeId] !== scope) {
290
317
  scopeLookup[scopeId] = Object.assign(
291
318
  scope,
292
- prevScope
319
+ scopeLookup[scopeId]
293
320
  );
294
321
  }
295
- if (branchesEnabled) {
296
- const parentBranchId = scope["#ClosestBranchId" /* ClosestBranchId */] || parentBranchIds.get(scopeId);
297
- if (parentBranchId) {
298
- scope.___closestBranch = scopeLookup[parentBranchId];
299
- }
300
- if (branchIds.has(scopeId)) {
301
- const branch = scope;
302
- const parentBranch = branch.___closestBranch;
303
- scope.___closestBranch = branch;
304
- if (parentBranch) {
305
- branch.___parentBranch = parentBranch;
306
- (parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(
307
- branch
308
- );
309
- }
310
- }
322
+ if (branches) {
323
+ branches.___scope(scope);
311
324
  }
312
325
  if (true) {
313
326
  scope.___debugId = "server-" + scopeId;
@@ -1,6 +1,5 @@
1
1
  import { type Scope } from "../common/types";
2
2
  import type { Signal } from "./signals";
3
- export declare let branchesEnabled: undefined | 1;
4
3
  export declare function enableBranches(): void;
5
4
  export declare function init(runtimeId?: string): void;
6
5
  export declare let isResuming: undefined | 0 | 1;