marko 6.0.10 → 6.0.11
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 +97 -84
- package/dist/debug/dom.mjs +97 -84
- package/dist/dom/resume.d.ts +0 -1
- package/dist/dom.js +95 -104
- package/dist/dom.mjs +95 -104
- package/package.json +1 -1
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
|
282
|
-
|
283
|
-
|
284
|
-
const
|
285
|
-
let
|
286
|
-
let
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
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 (
|
305
|
-
|
306
|
-
|
307
|
-
|
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
|
-
|
374
|
+
visitDataIndex ? visitDataIndex - 1 : visitText.length
|
310
375
|
);
|
311
|
-
|
376
|
+
visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
|
377
|
+
visitToken = visitText[commentPrefixLen];
|
378
|
+
visitScope = scopeLookup[scopeId] ||= {
|
312
379
|
___id: scopeId
|
313
380
|
};
|
314
|
-
|
315
|
-
|
316
|
-
if (
|
317
|
-
|
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
|
-
|
378
|
-
const prevScope = scopeLookup[scopeId];
|
405
|
+
scopeId = ++lastScopeId;
|
379
406
|
scope.$global = $global;
|
380
407
|
scope.___id = scopeId;
|
381
|
-
if (
|
408
|
+
if (scopeLookup[scopeId] !== scope) {
|
382
409
|
scopeLookup[scopeId] = Object.assign(
|
383
410
|
scope,
|
384
|
-
|
411
|
+
scopeLookup[scopeId]
|
385
412
|
);
|
386
413
|
}
|
387
|
-
if (
|
388
|
-
|
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;
|
package/dist/debug/dom.mjs
CHANGED
@@ -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
|
190
|
-
|
191
|
-
|
192
|
-
const
|
193
|
-
let
|
194
|
-
let
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
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 (
|
213
|
-
|
214
|
-
|
215
|
-
|
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
|
-
|
282
|
+
visitDataIndex ? visitDataIndex - 1 : visitText.length
|
218
283
|
);
|
219
|
-
|
284
|
+
visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "";
|
285
|
+
visitToken = visitText[commentPrefixLen];
|
286
|
+
visitScope = scopeLookup[scopeId] ||= {
|
220
287
|
___id: scopeId
|
221
288
|
};
|
222
|
-
|
223
|
-
|
224
|
-
if (
|
225
|
-
|
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
|
-
|
286
|
-
const prevScope = scopeLookup[scopeId];
|
313
|
+
scopeId = ++lastScopeId;
|
287
314
|
scope.$global = $global;
|
288
315
|
scope.___id = scopeId;
|
289
|
-
if (
|
316
|
+
if (scopeLookup[scopeId] !== scope) {
|
290
317
|
scopeLookup[scopeId] = Object.assign(
|
291
318
|
scope,
|
292
|
-
|
319
|
+
scopeLookup[scopeId]
|
293
320
|
);
|
294
321
|
}
|
295
|
-
if (
|
296
|
-
|
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;
|
package/dist/dom/resume.d.ts
CHANGED
@@ -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;
|
package/dist/dom.js
CHANGED
@@ -209,50 +209,56 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
209
209
|
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
210
210
|
defineRuntime({
|
211
211
|
value: resumeRender = (renderId) => {
|
212
|
-
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length,
|
212
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, scopeLookup = render.s = {}, serializeContext = {
|
213
213
|
_: registeredValues
|
214
|
-
},
|
215
|
-
let
|
216
|
-
|
217
|
-
|
218
|
-
|
214
|
+
}, branches = branchesEnabled && /* @__PURE__ */ (() => {
|
215
|
+
let branchStack = [], branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEndNode, currentBranchId, endBranch = (branchId, reference) => {
|
216
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = reference, prevNode;
|
217
|
+
for (; (prevNode = endNode.previousSibling) !== branch.h && ~visits.indexOf(endNode = prevNode); ) ;
|
218
|
+
return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
|
219
|
+
};
|
220
|
+
return {
|
221
|
+
J() {
|
222
|
+
if (visitToken === "[" /* BranchStart */)
|
223
|
+
currentBranchId && visitDataIndex && (endBranch(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, visitScope.h = visit;
|
224
|
+
else if (visitToken === "]" /* BranchEnd */) {
|
225
|
+
let curParent = visit.parentNode, startNode = endBranch(
|
226
|
+
currentBranchId,
|
227
|
+
visit
|
228
|
+
).h;
|
229
|
+
visitScope[visitData] = visit, curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
230
|
+
} else {
|
231
|
+
let next = visitData.indexOf(" "), curNode = visit;
|
232
|
+
for (visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
233
|
+
let start = next + 1;
|
234
|
+
next = visitData.indexOf(" ", start);
|
235
|
+
let childScopeId = +visitData.slice(
|
236
|
+
start,
|
237
|
+
~next ? next : visitData.length
|
238
|
+
);
|
239
|
+
curNode = endBranch(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
},
|
243
|
+
o(scope) {
|
244
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
245
|
+
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
246
|
+
let branch = scope, parentBranch = branch.k;
|
247
|
+
scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
|
248
|
+
}
|
249
|
+
}
|
250
|
+
};
|
251
|
+
})(), $global, lastScopeId = 0, lastEffect, visits, resumes, scopeId, visit, visitText, visitData, visitDataIndex, visitToken, visitScope;
|
219
252
|
return render.w = () => {
|
220
253
|
try {
|
221
254
|
walk2(), isResuming = 1;
|
222
|
-
for (
|
223
|
-
|
255
|
+
for (visit of visits = render.v)
|
256
|
+
visitText = visit.data, visitDataIndex = visitText.indexOf(" ") + 1, scopeId = +visitText.slice(
|
224
257
|
commentPrefixLen + 1,
|
225
|
-
|
226
|
-
),
|
258
|
+
visitDataIndex ? visitDataIndex - 1 : visitText.length
|
259
|
+
), visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "", visitToken = visitText[commentPrefixLen], visitScope = scopeLookup[scopeId] ||= {
|
227
260
|
m: scopeId
|
228
|
-
},
|
229
|
-
if (token === "*" /* Node */) {
|
230
|
-
let node = scope[data2] = visit.previousSibling;
|
231
|
-
scope["j" /* Getter */ + data2] = () => node;
|
232
|
-
} else if (branchesEnabled) {
|
233
|
-
if (token === "[" /* BranchStart */)
|
234
|
-
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
235
|
-
else if (token === "]" /* BranchEnd */) {
|
236
|
-
scope[data2] = visit;
|
237
|
-
let curParent = visit.parentNode, startNode = branchEnd(
|
238
|
-
currentBranchId,
|
239
|
-
visit
|
240
|
-
).h;
|
241
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
242
|
-
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
243
|
-
let next = data2.indexOf(" "), curNode = visit;
|
244
|
-
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
245
|
-
let start = next + 1;
|
246
|
-
next = data2.indexOf(" ", start);
|
247
|
-
let childScopeId = +data2.slice(
|
248
|
-
start,
|
249
|
-
~next ? next : data2.length
|
250
|
-
);
|
251
|
-
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
}
|
255
|
-
}
|
261
|
+
}, visitToken === "*" /* Node */ ? visitScope["j" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling) : branches && branches.J();
|
256
262
|
for (let serialized of resumes = render.r || [])
|
257
263
|
if (typeof serialized == "string")
|
258
264
|
lastEffect = serialized;
|
@@ -263,25 +269,10 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
263
269
|
);
|
264
270
|
else
|
265
271
|
for (let scope of serialized(serializeContext))
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
else {
|
271
|
-
let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
|
272
|
-
if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
273
|
-
scope,
|
274
|
-
prevScope
|
275
|
-
)), branchesEnabled) {
|
276
|
-
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
277
|
-
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
278
|
-
let branch = scope, parentBranch = branch.k;
|
279
|
-
scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
280
|
-
branch
|
281
|
-
));
|
282
|
-
}
|
283
|
-
}
|
284
|
-
}
|
272
|
+
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.m = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
|
273
|
+
scope,
|
274
|
+
scopeLookup[scopeId]
|
275
|
+
)), branches && branches.o(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
|
285
276
|
} finally {
|
286
277
|
isResuming = visits.length = resumes.length = 0;
|
287
278
|
}
|
@@ -714,29 +705,29 @@ function toInsertNode(startNode, endNode) {
|
|
714
705
|
// src/dom/scope.ts
|
715
706
|
function createScope($global, closestBranch) {
|
716
707
|
let scope = {
|
717
|
-
m: $global.
|
718
|
-
|
708
|
+
m: $global.p++,
|
709
|
+
q: 1,
|
719
710
|
k: closestBranch,
|
720
711
|
$global
|
721
712
|
};
|
722
713
|
return pendingScopes.push(scope), scope;
|
723
714
|
}
|
724
715
|
function skipScope(scope) {
|
725
|
-
return scope.$global.
|
716
|
+
return scope.$global.p++;
|
726
717
|
}
|
727
718
|
function findBranchWithKey(scope, key) {
|
728
719
|
let branch = scope.k;
|
729
720
|
for (; branch && !branch[key]; )
|
730
|
-
branch = branch.
|
721
|
+
branch = branch.u;
|
731
722
|
return branch;
|
732
723
|
}
|
733
724
|
function destroyBranch(branch) {
|
734
|
-
branch.
|
725
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
735
726
|
}
|
736
727
|
function destroyNestedBranches(branch) {
|
737
|
-
branch.
|
738
|
-
for (let id in scope.
|
739
|
-
scope.
|
728
|
+
branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
|
729
|
+
for (let id in scope.x)
|
730
|
+
scope.x[id]?.abort();
|
740
731
|
});
|
741
732
|
}
|
742
733
|
function removeAndDestroyBranch(branch) {
|
@@ -872,7 +863,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
872
863
|
// src/dom/renderer.ts
|
873
864
|
function createBranch($global, renderer, parentScope, parentNode) {
|
874
865
|
let branch = createScope($global), parentBranch = parentScope?.k;
|
875
|
-
return branch._ = renderer.
|
866
|
+
return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
|
876
867
|
branch,
|
877
868
|
parentNode.namespaceURI
|
878
869
|
), branch;
|
@@ -884,10 +875,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
884
875
|
);
|
885
876
|
}
|
886
877
|
function setupBranch(renderer, branch) {
|
887
|
-
return (renderer.
|
878
|
+
return (renderer.D || renderer.E) && queueRender(
|
888
879
|
branch,
|
889
880
|
(branch2) => {
|
890
|
-
renderer.
|
881
|
+
renderer.D?.(branch2), renderer.E?.(branch2);
|
891
882
|
},
|
892
883
|
-1
|
893
884
|
), branch;
|
@@ -908,12 +899,12 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
908
899
|
};
|
909
900
|
return (owner) => ({
|
910
901
|
m: id,
|
911
|
-
|
912
|
-
|
913
|
-
|
902
|
+
C: clone,
|
903
|
+
y: owner,
|
904
|
+
D: setup,
|
914
905
|
l: params,
|
915
906
|
E: closures,
|
916
|
-
|
907
|
+
z: dynamicScopesAccessor
|
917
908
|
});
|
918
909
|
}
|
919
910
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -984,7 +975,7 @@ function value(valueAccessor, fn = () => {
|
|
984
975
|
}
|
985
976
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
986
977
|
return (scope) => {
|
987
|
-
scope.
|
978
|
+
scope.q ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
988
979
|
};
|
989
980
|
}
|
990
981
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -994,7 +985,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
994
985
|
ownerScope,
|
995
986
|
() => {
|
996
987
|
for (let scope of scopes)
|
997
|
-
!scope.
|
988
|
+
!scope.q && !scope.B && childSignal(scope);
|
998
989
|
},
|
999
990
|
-1,
|
1000
991
|
0,
|
@@ -1006,7 +997,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1006
997
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1007
998
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
1008
999
|
let ifScope = scope[scopeAccessor];
|
1009
|
-
ifScope && !ifScope.
|
1000
|
+
ifScope && !ifScope.q && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
1010
1001
|
};
|
1011
1002
|
return ownerSignal._ = childSignal, ownerSignal;
|
1012
1003
|
}
|
@@ -1020,11 +1011,11 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
1020
1011
|
function dynamicClosure(...closureSignals) {
|
1021
1012
|
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
1022
1013
|
for (let i = closureSignals.length; i--; )
|
1023
|
-
closureSignals[i].
|
1014
|
+
closureSignals[i].L = i;
|
1024
1015
|
return (scope) => {
|
1025
1016
|
if (scope[___scopeInstancesAccessor])
|
1026
1017
|
for (let childScope of scope[___scopeInstancesAccessor])
|
1027
|
-
childScope.
|
1018
|
+
childScope.q || queueRender(
|
1028
1019
|
childScope,
|
1029
1020
|
closureSignals[childScope[___signalIndexAccessor]],
|
1030
1021
|
-1
|
@@ -1033,7 +1024,7 @@ function dynamicClosure(...closureSignals) {
|
|
1033
1024
|
}
|
1034
1025
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
1035
1026
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
1036
|
-
scope[closureSignal.G] = closureSignal.
|
1027
|
+
scope[closureSignal.G] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
|
1037
1028
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
1038
1029
|
closureSignal.F,
|
1039
1030
|
scope
|
@@ -1209,15 +1200,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1209
1200
|
0,
|
1210
1201
|
content,
|
1211
1202
|
createAndSetupBranch
|
1212
|
-
), content.
|
1213
|
-
content.x,
|
1203
|
+
), content.z && subscribeToScopeSet(
|
1214
1204
|
content.y,
|
1205
|
+
content.z,
|
1215
1206
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1216
1207
|
);
|
1217
1208
|
}
|
1218
|
-
} else normalizedRenderer?.
|
1219
|
-
normalizedRenderer.x,
|
1209
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1220
1210
|
normalizedRenderer.y,
|
1211
|
+
normalizedRenderer.z,
|
1221
1212
|
scope[childScopeAccessor]
|
1222
1213
|
);
|
1223
1214
|
if (normalizedRenderer) {
|
@@ -1315,14 +1306,14 @@ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
|
1315
1306
|
existingRender.I = value2;
|
1316
1307
|
else {
|
1317
1308
|
let render = {
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1309
|
+
t: key,
|
1310
|
+
o: scope,
|
1311
|
+
M: signal,
|
1321
1312
|
I: value2
|
1322
1313
|
}, i = pendingRenders.push(render) - 1;
|
1323
1314
|
for (; i; ) {
|
1324
1315
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1325
|
-
if (key - parent.
|
1316
|
+
if (key - parent.t >= 0) break;
|
1326
1317
|
pendingRenders[i] = parent, i = parentIndex;
|
1327
1318
|
}
|
1328
1319
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1361,54 +1352,54 @@ function runRenders() {
|
|
1361
1352
|
for (; pendingRenders.length; ) {
|
1362
1353
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1363
1354
|
if (render !== item) {
|
1364
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1355
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1365
1356
|
for (; i < mid; ) {
|
1366
1357
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1367
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1358
|
+
if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
|
1368
1359
|
break;
|
1369
1360
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1370
1361
|
}
|
1371
1362
|
pendingRenders[i] = item;
|
1372
1363
|
}
|
1373
|
-
render.
|
1364
|
+
render.o.k?.B || runRender(render);
|
1374
1365
|
}
|
1375
1366
|
for (let scope of pendingScopes)
|
1376
|
-
scope.
|
1367
|
+
scope.q = 0;
|
1377
1368
|
pendingScopes = [];
|
1378
1369
|
}
|
1379
|
-
var runRender = (render) => render.
|
1370
|
+
var runRender = (render) => render.M(render.o, render.I), enableCatch = () => {
|
1380
1371
|
enableCatch = () => {
|
1381
1372
|
}, enableBranches();
|
1382
1373
|
let handlePendingTry = (fn, scope, branch) => {
|
1383
1374
|
for (; branch; ) {
|
1384
1375
|
if (branch.n)
|
1385
1376
|
return (branch.H ||= []).push(fn, scope);
|
1386
|
-
branch = branch.
|
1377
|
+
branch = branch.u;
|
1387
1378
|
}
|
1388
1379
|
};
|
1389
1380
|
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1390
1381
|
if (checkPending || caughtError.has(effects)) {
|
1391
1382
|
let i = 0, fn, scope, branch;
|
1392
1383
|
for (; i < effects.length; )
|
1393
|
-
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.
|
1384
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.B && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1394
1385
|
} else
|
1395
1386
|
runEffects2(effects);
|
1396
1387
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1397
1388
|
try {
|
1398
1389
|
runRender2(render);
|
1399
1390
|
} catch (error) {
|
1400
|
-
renderCatch(render.
|
1391
|
+
renderCatch(render.o, error);
|
1401
1392
|
}
|
1402
1393
|
})(runRender);
|
1403
1394
|
};
|
1404
1395
|
|
1405
1396
|
// src/dom/abort-signal.ts
|
1406
1397
|
function resetAbortSignal(scope, id) {
|
1407
|
-
let ctrl = scope.
|
1408
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1398
|
+
let ctrl = scope.x?.[id];
|
1399
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1409
1400
|
}
|
1410
1401
|
function getAbortSignal(scope, id) {
|
1411
|
-
return scope.k && (scope.k.
|
1402
|
+
return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1412
1403
|
}
|
1413
1404
|
function abort(ctrl) {
|
1414
1405
|
ctrl.abort();
|
@@ -1430,7 +1421,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1430
1421
|
register(RENDERER_REGISTER_ID, fn);
|
1431
1422
|
},
|
1432
1423
|
isRenderer(renderer) {
|
1433
|
-
return renderer.
|
1424
|
+
return renderer.C;
|
1434
1425
|
},
|
1435
1426
|
getStartNode(branch) {
|
1436
1427
|
return branch.h;
|
@@ -1455,7 +1446,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1455
1446
|
},
|
1456
1447
|
createRenderer(params, clone) {
|
1457
1448
|
let renderer = createRenderer(0, 0, 0, params);
|
1458
|
-
return renderer.
|
1449
|
+
return renderer.C = (branch) => {
|
1459
1450
|
let cloned = clone();
|
1460
1451
|
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1461
1452
|
}, renderer;
|
@@ -1470,10 +1461,10 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1470
1461
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1471
1462
|
}
|
1472
1463
|
if (component.effects = prepareEffects(() => {
|
1473
|
-
branch ? existing = 1 : (out.global.
|
1464
|
+
branch ? existing = 1 : (out.global.p ||= 0, branch = component.scope = createAndSetupBranch(
|
1474
1465
|
out.global,
|
1475
1466
|
renderer,
|
1476
|
-
renderer.
|
1467
|
+
renderer.y,
|
1477
1468
|
document.body
|
1478
1469
|
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1479
1470
|
}), !existing)
|
@@ -1495,12 +1486,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1495
1486
|
function mount(input = {}, reference, position) {
|
1496
1487
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1497
1488
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1498
|
-
|
1489
|
+
p: 0,
|
1499
1490
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1500
1491
|
renderId: DEFAULT_RENDER_ID,
|
1501
1492
|
...$global
|
1502
1493
|
}) : $global = {
|
1503
|
-
|
1494
|
+
p: 0,
|
1504
1495
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1505
1496
|
renderId: DEFAULT_RENDER_ID
|
1506
1497
|
}, position) {
|
@@ -1520,7 +1511,7 @@ function mount(input = {}, reference, position) {
|
|
1520
1511
|
this,
|
1521
1512
|
void 0,
|
1522
1513
|
parentNode
|
1523
|
-
), this.
|
1514
|
+
), this.D?.(branch), args?.(branch, input);
|
1524
1515
|
});
|
1525
1516
|
return insertChildNodes(
|
1526
1517
|
parentNode,
|
package/dist/dom.mjs
CHANGED
@@ -120,50 +120,56 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
120
120
|
let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
|
121
121
|
defineRuntime({
|
122
122
|
value: resumeRender = (renderId) => {
|
123
|
-
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length,
|
123
|
+
let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, scopeLookup = render.s = {}, serializeContext = {
|
124
124
|
_: registeredValues
|
125
|
-
},
|
126
|
-
let
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
}, branches = branchesEnabled && /* @__PURE__ */ (() => {
|
126
|
+
let branchStack = [], branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEndNode, currentBranchId, endBranch = (branchId, reference) => {
|
127
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = reference, prevNode;
|
128
|
+
for (; (prevNode = endNode.previousSibling) !== branch.h && ~visits.indexOf(endNode = prevNode); ) ;
|
129
|
+
return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
|
130
|
+
};
|
131
|
+
return {
|
132
|
+
J() {
|
133
|
+
if (visitToken === "[" /* BranchStart */)
|
134
|
+
currentBranchId && visitDataIndex && (endBranch(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, visitScope.h = visit;
|
135
|
+
else if (visitToken === "]" /* BranchEnd */) {
|
136
|
+
let curParent = visit.parentNode, startNode = endBranch(
|
137
|
+
currentBranchId,
|
138
|
+
visit
|
139
|
+
).h;
|
140
|
+
visitScope[visitData] = visit, curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
141
|
+
} else {
|
142
|
+
let next = visitData.indexOf(" "), curNode = visit;
|
143
|
+
for (visitScope[~next ? visitData.slice(0, next) : visitData] = visitToken === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
144
|
+
let start = next + 1;
|
145
|
+
next = visitData.indexOf(" ", start);
|
146
|
+
let childScopeId = +visitData.slice(
|
147
|
+
start,
|
148
|
+
~next ? next : visitData.length
|
149
|
+
);
|
150
|
+
curNode = endBranch(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
},
|
154
|
+
o(scope) {
|
155
|
+
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
156
|
+
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
157
|
+
let branch = scope, parentBranch = branch.k;
|
158
|
+
scope.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch));
|
159
|
+
}
|
160
|
+
}
|
161
|
+
};
|
162
|
+
})(), $global, lastScopeId = 0, lastEffect, visits, resumes, scopeId, visit, visitText, visitData, visitDataIndex, visitToken, visitScope;
|
130
163
|
return render.w = () => {
|
131
164
|
try {
|
132
165
|
walk2(), isResuming = 1;
|
133
|
-
for (
|
134
|
-
|
166
|
+
for (visit of visits = render.v)
|
167
|
+
visitText = visit.data, visitDataIndex = visitText.indexOf(" ") + 1, scopeId = +visitText.slice(
|
135
168
|
commentPrefixLen + 1,
|
136
|
-
|
137
|
-
),
|
169
|
+
visitDataIndex ? visitDataIndex - 1 : visitText.length
|
170
|
+
), visitData = visitDataIndex ? visitText.slice(visitDataIndex) : "", visitToken = visitText[commentPrefixLen], visitScope = scopeLookup[scopeId] ||= {
|
138
171
|
m: scopeId
|
139
|
-
},
|
140
|
-
if (token === "*" /* Node */) {
|
141
|
-
let node = scope[data2] = visit.previousSibling;
|
142
|
-
scope["j" /* Getter */ + data2] = () => node;
|
143
|
-
} else if (branchesEnabled) {
|
144
|
-
if (token === "[" /* BranchStart */)
|
145
|
-
currentBranchId && dataIndex && (branchEnd(currentBranchId, visit), currentBranchId = branchStack.pop()), currentBranchId && (branchStack.push(currentBranchId), parentBranchIds.set(scopeId, currentBranchId)), currentBranchId = scopeId, scope.h = visit;
|
146
|
-
else if (token === "]" /* BranchEnd */) {
|
147
|
-
scope[data2] = visit;
|
148
|
-
let curParent = visit.parentNode, startNode = branchEnd(
|
149
|
-
currentBranchId,
|
150
|
-
visit
|
151
|
-
).h;
|
152
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), currentBranchId = branchStack.pop();
|
153
|
-
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
154
|
-
let next = data2.indexOf(" "), curNode = visit;
|
155
|
-
for (scope[~next ? data2.slice(0, next) : data2] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
156
|
-
let start = next + 1;
|
157
|
-
next = data2.indexOf(" ", start);
|
158
|
-
let childScopeId = +data2.slice(
|
159
|
-
start,
|
160
|
-
~next ? next : data2.length
|
161
|
-
);
|
162
|
-
curNode = branchEnd(childScopeId, curNode).j, parentBranchIds.set(childScopeId, scopeId);
|
163
|
-
}
|
164
|
-
}
|
165
|
-
}
|
166
|
-
}
|
172
|
+
}, visitToken === "*" /* Node */ ? visitScope["j" /* Getter */ + visitData] = /* @__PURE__ */ ((node) => () => node)(visitScope[visitData] = visit.previousSibling) : branches && branches.J();
|
167
173
|
for (let serialized of resumes = render.r || [])
|
168
174
|
if (typeof serialized == "string")
|
169
175
|
lastEffect = serialized;
|
@@ -174,25 +180,10 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
174
180
|
);
|
175
181
|
else
|
176
182
|
for (let scope of serialized(serializeContext))
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
else {
|
182
|
-
let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
|
183
|
-
if (scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
184
|
-
scope,
|
185
|
-
prevScope
|
186
|
-
)), branchesEnabled) {
|
187
|
-
let parentBranchId = scope.g || parentBranchIds.get(scopeId);
|
188
|
-
if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
|
189
|
-
let branch = scope, parentBranch = branch.k;
|
190
|
-
scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
|
191
|
-
branch
|
192
|
-
));
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
183
|
+
$global ? typeof scope == "number" ? lastScopeId += scope : (scopeId = ++lastScopeId, scope.$global = $global, scope.m = scopeId, scopeLookup[scopeId] !== scope && (scopeLookup[scopeId] = Object.assign(
|
184
|
+
scope,
|
185
|
+
scopeLookup[scopeId]
|
186
|
+
)), branches && branches.o(scope)) : ($global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.p = 1e6);
|
196
187
|
} finally {
|
197
188
|
isResuming = visits.length = resumes.length = 0;
|
198
189
|
}
|
@@ -625,29 +616,29 @@ function toInsertNode(startNode, endNode) {
|
|
625
616
|
// src/dom/scope.ts
|
626
617
|
function createScope($global, closestBranch) {
|
627
618
|
let scope = {
|
628
|
-
m: $global.
|
629
|
-
|
619
|
+
m: $global.p++,
|
620
|
+
q: 1,
|
630
621
|
k: closestBranch,
|
631
622
|
$global
|
632
623
|
};
|
633
624
|
return pendingScopes.push(scope), scope;
|
634
625
|
}
|
635
626
|
function skipScope(scope) {
|
636
|
-
return scope.$global.
|
627
|
+
return scope.$global.p++;
|
637
628
|
}
|
638
629
|
function findBranchWithKey(scope, key) {
|
639
630
|
let branch = scope.k;
|
640
631
|
for (; branch && !branch[key]; )
|
641
|
-
branch = branch.
|
632
|
+
branch = branch.u;
|
642
633
|
return branch;
|
643
634
|
}
|
644
635
|
function destroyBranch(branch) {
|
645
|
-
branch.
|
636
|
+
branch.u?.A?.delete(branch), destroyNestedBranches(branch);
|
646
637
|
}
|
647
638
|
function destroyNestedBranches(branch) {
|
648
|
-
branch.
|
649
|
-
for (let id in scope.
|
650
|
-
scope.
|
639
|
+
branch.B = 1, branch.A?.forEach(destroyNestedBranches), branch.K?.forEach((scope) => {
|
640
|
+
for (let id in scope.x)
|
641
|
+
scope.x[id]?.abort();
|
651
642
|
});
|
652
643
|
}
|
653
644
|
function removeAndDestroyBranch(branch) {
|
@@ -783,7 +774,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
783
774
|
// src/dom/renderer.ts
|
784
775
|
function createBranch($global, renderer, parentScope, parentNode) {
|
785
776
|
let branch = createScope($global), parentBranch = parentScope?.k;
|
786
|
-
return branch._ = renderer.
|
777
|
+
return branch._ = renderer.y || parentScope, branch.k = branch, parentBranch && (branch.u = parentBranch, (parentBranch.A ||= /* @__PURE__ */ new Set()).add(branch)), renderer.C?.(
|
787
778
|
branch,
|
788
779
|
parentNode.namespaceURI
|
789
780
|
), branch;
|
@@ -795,10 +786,10 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
795
786
|
);
|
796
787
|
}
|
797
788
|
function setupBranch(renderer, branch) {
|
798
|
-
return (renderer.
|
789
|
+
return (renderer.D || renderer.E) && queueRender(
|
799
790
|
branch,
|
800
791
|
(branch2) => {
|
801
|
-
renderer.
|
792
|
+
renderer.D?.(branch2), renderer.E?.(branch2);
|
802
793
|
},
|
803
794
|
-1
|
804
795
|
), branch;
|
@@ -819,12 +810,12 @@ function createContent(id, template, walks, setup, params, closures, dynamicScop
|
|
819
810
|
};
|
820
811
|
return (owner) => ({
|
821
812
|
m: id,
|
822
|
-
|
823
|
-
|
824
|
-
|
813
|
+
C: clone,
|
814
|
+
y: owner,
|
815
|
+
D: setup,
|
825
816
|
l: params,
|
826
817
|
E: closures,
|
827
|
-
|
818
|
+
z: dynamicScopesAccessor
|
828
819
|
});
|
829
820
|
}
|
830
821
|
function registerContent(id, template, walks, setup, params, closures, dynamicScopesAccessor) {
|
@@ -895,7 +886,7 @@ function value(valueAccessor, fn = () => {
|
|
895
886
|
}
|
896
887
|
function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__ */ "m") {
|
897
888
|
return (scope) => {
|
898
|
-
scope.
|
889
|
+
scope.q ? scope[id] === void 0 ? scope[id] = defaultPending : --scope[id] || fn(scope) : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
899
890
|
};
|
900
891
|
}
|
901
892
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
@@ -905,7 +896,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
905
896
|
ownerScope,
|
906
897
|
() => {
|
907
898
|
for (let scope of scopes)
|
908
|
-
!scope.
|
899
|
+
!scope.q && !scope.B && childSignal(scope);
|
909
900
|
},
|
910
901
|
-1,
|
911
902
|
0,
|
@@ -917,7 +908,7 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
917
908
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
918
909
|
let childSignal = closure(valueAccessor, fn), scopeAccessor = "d" /* ConditionalScope */ + ownerConditionalNodeAccessor, branchAccessor = "c" /* ConditionalRenderer */ + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
919
910
|
let ifScope = scope[scopeAccessor];
|
920
|
-
ifScope && !ifScope.
|
911
|
+
ifScope && !ifScope.q && scope[branchAccessor] === branch && queueRender(ifScope, childSignal, -1);
|
921
912
|
};
|
922
913
|
return ownerSignal._ = childSignal, ownerSignal;
|
923
914
|
}
|
@@ -931,11 +922,11 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
931
922
|
function dynamicClosure(...closureSignals) {
|
932
923
|
let [{ F: ___scopeInstancesAccessor, G: ___signalIndexAccessor }] = closureSignals;
|
933
924
|
for (let i = closureSignals.length; i--; )
|
934
|
-
closureSignals[i].
|
925
|
+
closureSignals[i].L = i;
|
935
926
|
return (scope) => {
|
936
927
|
if (scope[___scopeInstancesAccessor])
|
937
928
|
for (let childScope of scope[___scopeInstancesAccessor])
|
938
|
-
childScope.
|
929
|
+
childScope.q || queueRender(
|
939
930
|
childScope,
|
940
931
|
closureSignals[childScope[___signalIndexAccessor]],
|
941
932
|
-1
|
@@ -944,7 +935,7 @@ function dynamicClosure(...closureSignals) {
|
|
944
935
|
}
|
945
936
|
function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
946
937
|
let childSignal = closure(valueAccessor, fn, getOwnerScope), closureSignal = (scope) => {
|
947
|
-
scope[closureSignal.G] = closureSignal.
|
938
|
+
scope[closureSignal.G] = closureSignal.L, childSignal(scope), subscribeToScopeSet(
|
948
939
|
getOwnerScope ? getOwnerScope(scope) : scope._,
|
949
940
|
closureSignal.F,
|
950
941
|
scope
|
@@ -1120,15 +1111,15 @@ var dynamicTag = function(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1120
1111
|
0,
|
1121
1112
|
content,
|
1122
1113
|
createAndSetupBranch
|
1123
|
-
), content.
|
1124
|
-
content.x,
|
1114
|
+
), content.z && subscribeToScopeSet(
|
1125
1115
|
content.y,
|
1116
|
+
content.z,
|
1126
1117
|
scope[childScopeAccessor]["d" /* ConditionalScope */ + 0]
|
1127
1118
|
);
|
1128
1119
|
}
|
1129
|
-
} else normalizedRenderer?.
|
1130
|
-
normalizedRenderer.x,
|
1120
|
+
} else normalizedRenderer?.z && subscribeToScopeSet(
|
1131
1121
|
normalizedRenderer.y,
|
1122
|
+
normalizedRenderer.z,
|
1132
1123
|
scope[childScopeAccessor]
|
1133
1124
|
);
|
1134
1125
|
if (normalizedRenderer) {
|
@@ -1226,14 +1217,14 @@ function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
|
1226
1217
|
existingRender.I = value2;
|
1227
1218
|
else {
|
1228
1219
|
let render = {
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1220
|
+
t: key,
|
1221
|
+
o: scope,
|
1222
|
+
M: signal,
|
1232
1223
|
I: value2
|
1233
1224
|
}, i = pendingRenders.push(render) - 1;
|
1234
1225
|
for (; i; ) {
|
1235
1226
|
let parentIndex = i - 1 >> 1, parent = pendingRenders[parentIndex];
|
1236
|
-
if (key - parent.
|
1227
|
+
if (key - parent.t >= 0) break;
|
1237
1228
|
pendingRenders[i] = parent, i = parentIndex;
|
1238
1229
|
}
|
1239
1230
|
signalKey >= 0 && pendingRendersLookup.set(key, render), pendingRenders[i] = render;
|
@@ -1272,54 +1263,54 @@ function runRenders() {
|
|
1272
1263
|
for (; pendingRenders.length; ) {
|
1273
1264
|
let render = pendingRenders[0], item = pendingRenders.pop();
|
1274
1265
|
if (render !== item) {
|
1275
|
-
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).
|
1266
|
+
let i = 0, mid = pendingRenders.length >> 1, key = (pendingRenders[0] = item).t;
|
1276
1267
|
for (; i < mid; ) {
|
1277
1268
|
let bestChild = (i << 1) + 1, right = bestChild + 1;
|
1278
|
-
if (right < pendingRenders.length && pendingRenders[right].
|
1269
|
+
if (right < pendingRenders.length && pendingRenders[right].t - pendingRenders[bestChild].t < 0 && (bestChild = right), pendingRenders[bestChild].t - key >= 0)
|
1279
1270
|
break;
|
1280
1271
|
pendingRenders[i] = pendingRenders[bestChild], i = bestChild;
|
1281
1272
|
}
|
1282
1273
|
pendingRenders[i] = item;
|
1283
1274
|
}
|
1284
|
-
render.
|
1275
|
+
render.o.k?.B || runRender(render);
|
1285
1276
|
}
|
1286
1277
|
for (let scope of pendingScopes)
|
1287
|
-
scope.
|
1278
|
+
scope.q = 0;
|
1288
1279
|
pendingScopes = [];
|
1289
1280
|
}
|
1290
|
-
var runRender = (render) => render.
|
1281
|
+
var runRender = (render) => render.M(render.o, render.I), enableCatch = () => {
|
1291
1282
|
enableCatch = () => {
|
1292
1283
|
}, enableBranches();
|
1293
1284
|
let handlePendingTry = (fn, scope, branch) => {
|
1294
1285
|
for (; branch; ) {
|
1295
1286
|
if (branch.n)
|
1296
1287
|
return (branch.H ||= []).push(fn, scope);
|
1297
|
-
branch = branch.
|
1288
|
+
branch = branch.u;
|
1298
1289
|
}
|
1299
1290
|
};
|
1300
1291
|
runEffects = /* @__PURE__ */ ((runEffects2) => (effects, checkPending = placeholderShown.has(effects)) => {
|
1301
1292
|
if (checkPending || caughtError.has(effects)) {
|
1302
1293
|
let i = 0, fn, scope, branch;
|
1303
1294
|
for (; i < effects.length; )
|
1304
|
-
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.
|
1295
|
+
fn = effects[i++], scope = effects[i++], branch = scope.k, !branch?.B && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope, scope);
|
1305
1296
|
} else
|
1306
1297
|
runEffects2(effects);
|
1307
1298
|
})(runEffects), runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1308
1299
|
try {
|
1309
1300
|
runRender2(render);
|
1310
1301
|
} catch (error) {
|
1311
|
-
renderCatch(render.
|
1302
|
+
renderCatch(render.o, error);
|
1312
1303
|
}
|
1313
1304
|
})(runRender);
|
1314
1305
|
};
|
1315
1306
|
|
1316
1307
|
// src/dom/abort-signal.ts
|
1317
1308
|
function resetAbortSignal(scope, id) {
|
1318
|
-
let ctrl = scope.
|
1319
|
-
ctrl && (queueEffect(ctrl, abort), scope.
|
1309
|
+
let ctrl = scope.x?.[id];
|
1310
|
+
ctrl && (queueEffect(ctrl, abort), scope.x[id] = void 0);
|
1320
1311
|
}
|
1321
1312
|
function getAbortSignal(scope, id) {
|
1322
|
-
return scope.k && (scope.k.
|
1313
|
+
return scope.k && (scope.k.K ||= /* @__PURE__ */ new Set()).add(scope), ((scope.x ||= {})[id] ||= new AbortController()).signal;
|
1323
1314
|
}
|
1324
1315
|
function abort(ctrl) {
|
1325
1316
|
ctrl.abort();
|
@@ -1341,7 +1332,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1341
1332
|
register(RENDERER_REGISTER_ID, fn);
|
1342
1333
|
},
|
1343
1334
|
isRenderer(renderer) {
|
1344
|
-
return renderer.
|
1335
|
+
return renderer.C;
|
1345
1336
|
},
|
1346
1337
|
getStartNode(branch) {
|
1347
1338
|
return branch.h;
|
@@ -1366,7 +1357,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1366
1357
|
},
|
1367
1358
|
createRenderer(params, clone) {
|
1368
1359
|
let renderer = createRenderer(0, 0, 0, params);
|
1369
|
-
return renderer.
|
1360
|
+
return renderer.C = (branch) => {
|
1370
1361
|
let cloned = clone();
|
1371
1362
|
branch.h = cloned.startNode, branch.j = cloned.endNode;
|
1372
1363
|
}, renderer;
|
@@ -1381,10 +1372,10 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1381
1372
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1382
1373
|
}
|
1383
1374
|
if (component.effects = prepareEffects(() => {
|
1384
|
-
branch ? existing = 1 : (out.global.
|
1375
|
+
branch ? existing = 1 : (out.global.p ||= 0, branch = component.scope = createAndSetupBranch(
|
1385
1376
|
out.global,
|
1386
1377
|
renderer,
|
1387
|
-
renderer.
|
1378
|
+
renderer.y,
|
1388
1379
|
document.body
|
1389
1380
|
)), renderer.l?.(branch, renderer._ ? args[0] : args);
|
1390
1381
|
}), !existing)
|
@@ -1406,12 +1397,12 @@ var createTemplate = (id, template, walks, setup, inputSignal) => {
|
|
1406
1397
|
function mount(input = {}, reference, position) {
|
1407
1398
|
let branch, parentNode = reference, nextSibling = null, { $global } = input;
|
1408
1399
|
switch ($global ? ({ $global, ...input } = input, $global = {
|
1409
|
-
|
1400
|
+
p: 0,
|
1410
1401
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1411
1402
|
renderId: DEFAULT_RENDER_ID,
|
1412
1403
|
...$global
|
1413
1404
|
}) : $global = {
|
1414
|
-
|
1405
|
+
p: 0,
|
1415
1406
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1416
1407
|
renderId: DEFAULT_RENDER_ID
|
1417
1408
|
}, position) {
|
@@ -1431,7 +1422,7 @@ function mount(input = {}, reference, position) {
|
|
1431
1422
|
this,
|
1432
1423
|
void 0,
|
1433
1424
|
parentNode
|
1434
|
-
), this.
|
1425
|
+
), this.D?.(branch), args?.(branch, input);
|
1435
1426
|
});
|
1436
1427
|
return insertChildNodes(
|
1437
1428
|
parentNode,
|