marko 6.0.0-next.3.22 → 6.0.0-next.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/for.d.ts +3 -4
- package/dist/common/types.d.ts +18 -17
- package/dist/debug/dom.js +717 -753
- package/dist/debug/dom.mjs +717 -753
- package/dist/debug/html.js +256 -99
- package/dist/debug/html.mjs +247 -95
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/compat.d.ts +1 -0
- package/dist/dom/control-flow.d.ts +6 -8
- package/dist/dom/parse-html.d.ts +1 -4
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/reconcile.d.ts +2 -2
- package/dist/dom/renderer.d.ts +7 -8
- package/dist/dom/resume.d.ts +3 -3
- package/dist/dom/scope.d.ts +4 -4
- package/dist/dom/signals.d.ts +13 -26
- package/dist/dom/template.d.ts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +459 -494
- package/dist/dom.mjs +459 -494
- package/dist/html/dynamic-tag.d.ts +3 -3
- package/dist/html/writer.d.ts +12 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +202 -65
- package/dist/html.mjs +193 -61
- package/dist/translator/core/for.d.ts +0 -2
- package/dist/translator/index.js +189 -224
- package/dist/translator/util/runtime.d.ts +1 -2
- package/dist/translator/util/sections.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +2 -2
- package/package.json +2 -2
- package/tags-html.d.ts +152 -152
package/dist/debug/dom.js
CHANGED
@@ -25,11 +25,10 @@ __export(dom_exports, {
|
|
25
25
|
attrTags: () => attrTags,
|
26
26
|
attrs: () => attrs,
|
27
27
|
attrsEvents: () => attrsEvents,
|
28
|
-
childClosures: () => childClosures,
|
29
28
|
classAttr: () => classAttr,
|
30
|
-
closure: () => closure,
|
31
29
|
compat: () => compat,
|
32
30
|
conditional: () => conditional,
|
31
|
+
conditionalClosure: () => conditionalClosure,
|
33
32
|
conditionalOnlyChild: () => conditionalOnlyChild,
|
34
33
|
controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
|
35
34
|
controllable_detailsOrDialog_open_effect: () => controllable_detailsOrDialog_open_effect,
|
@@ -49,7 +48,6 @@ __export(dom_exports, {
|
|
49
48
|
createTemplate: () => createTemplate,
|
50
49
|
data: () => data,
|
51
50
|
dynamicClosure: () => dynamicClosure,
|
52
|
-
dynamicSubscribers: () => dynamicSubscribers,
|
53
51
|
dynamicTagAttrs: () => dynamicTagAttrs,
|
54
52
|
effect: () => effect,
|
55
53
|
forIn: () => forIn,
|
@@ -58,12 +56,11 @@ __export(dom_exports, {
|
|
58
56
|
getAbortSignal: () => getAbortSignal,
|
59
57
|
html: () => html,
|
60
58
|
inChild: () => inChild,
|
61
|
-
inConditionalScope: () => inConditionalScope,
|
62
|
-
inLoopScope: () => inLoopScope,
|
63
59
|
init: () => init,
|
64
60
|
intersection: () => intersection,
|
65
61
|
intersections: () => intersections,
|
66
62
|
lifecycle: () => lifecycle,
|
63
|
+
loopClosure: () => loopClosure,
|
67
64
|
loopIn: () => loopIn,
|
68
65
|
loopOf: () => loopOf,
|
69
66
|
loopTo: () => loopTo,
|
@@ -177,564 +174,62 @@ function triggerMacroTask() {
|
|
177
174
|
port2.postMessage(0);
|
178
175
|
}
|
179
176
|
|
180
|
-
// src/
|
181
|
-
var
|
182
|
-
var
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
const scope = {
|
188
|
-
___client: 1,
|
189
|
-
$global
|
190
|
-
};
|
191
|
-
if (true) {
|
192
|
-
scope.___debugId = debugID++;
|
193
|
-
}
|
194
|
-
return scope;
|
195
|
-
}
|
196
|
-
var emptyScope = createScope({});
|
197
|
-
function getEmptyScope(marker) {
|
198
|
-
emptyScope.___startNode = emptyScope.___endNode = marker;
|
199
|
-
return emptyScope;
|
200
|
-
}
|
201
|
-
function destroyScope(scope) {
|
202
|
-
_destroyScope(scope);
|
203
|
-
scope.___cleanupOwner?.___cleanup?.delete(scope);
|
204
|
-
const closureSignals = scope.___renderer?.___closureSignals;
|
205
|
-
if (closureSignals) {
|
206
|
-
for (const signal of closureSignals) {
|
207
|
-
signal.___unsubscribe?.(scope);
|
208
|
-
}
|
209
|
-
}
|
210
|
-
return scope;
|
211
|
-
}
|
212
|
-
function _destroyScope(scope) {
|
213
|
-
scope.___cleanup?.forEach(_destroyScope);
|
214
|
-
const controllers = scope.___abortControllers;
|
215
|
-
if (controllers) {
|
216
|
-
for (const ctrl of controllers.values()) {
|
217
|
-
ctrl.abort();
|
218
|
-
}
|
219
|
-
}
|
220
|
-
}
|
221
|
-
function onDestroy(scope) {
|
222
|
-
let parentScope = scope.___cleanupOwner;
|
223
|
-
while (parentScope && !parentScope.___cleanup?.has(scope)) {
|
224
|
-
(parentScope.___cleanup ||= /* @__PURE__ */ new Set()).add(scope);
|
225
|
-
scope = parentScope;
|
226
|
-
parentScope = scope.___cleanupOwner;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
function removeAndDestroyScope(scope) {
|
230
|
-
destroyScope(scope);
|
231
|
-
let current = scope.___startNode;
|
232
|
-
const stop = scope.___endNode.nextSibling;
|
233
|
-
while (current !== stop) {
|
234
|
-
const next = current.nextSibling;
|
235
|
-
current.remove();
|
236
|
-
current = next;
|
237
|
-
}
|
238
|
-
}
|
239
|
-
function insertBefore(scope, parent, nextSibling) {
|
240
|
-
let current = scope.___startNode;
|
241
|
-
const stop = scope.___endNode.nextSibling;
|
242
|
-
while (current !== stop) {
|
243
|
-
const next = current.nextSibling;
|
244
|
-
parent.insertBefore(current, nextSibling);
|
245
|
-
current = next;
|
246
|
-
}
|
247
|
-
}
|
248
|
-
|
249
|
-
// src/dom/resume.ts
|
250
|
-
var registeredValues = {};
|
251
|
-
var Render = class {
|
252
|
-
___scopeStack = [];
|
253
|
-
___scopeLookup = {};
|
254
|
-
___serializeContext = {
|
255
|
-
_: registeredValues
|
256
|
-
};
|
257
|
-
constructor(renders, runtimeId, renderId) {
|
258
|
-
this.___renders = renders;
|
259
|
-
this.___runtimeId = runtimeId;
|
260
|
-
this.___renderId = renderId;
|
261
|
-
this.___data = renders[renderId];
|
262
|
-
this.___resume();
|
263
|
-
}
|
264
|
-
w() {
|
265
|
-
this.___data.w();
|
266
|
-
this.___resume();
|
267
|
-
}
|
268
|
-
___resume() {
|
269
|
-
const data2 = this.___data;
|
270
|
-
const serializeContext = this.___serializeContext;
|
271
|
-
const scopeLookup = this.___scopeLookup;
|
272
|
-
const visits = data2.v;
|
273
|
-
const cleanupOwners = /* @__PURE__ */ new Map();
|
274
|
-
if (visits.length) {
|
275
|
-
const commentPrefix = data2.i;
|
276
|
-
const commentPrefixLen = commentPrefix.length;
|
277
|
-
const cleanupMarkers = /* @__PURE__ */ new Map();
|
278
|
-
data2.v = [];
|
279
|
-
const sectionEnd = (visit, scopeId = this.___currentScopeId, curNode = visit) => {
|
280
|
-
const scope = scopeLookup[scopeId] ||= {};
|
281
|
-
let endNode = curNode;
|
282
|
-
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
283
|
-
scope.___endNode = endNode;
|
284
|
-
const startNode = scope.___startNode ||= endNode;
|
285
|
-
let len = cleanupMarkers.size;
|
286
|
-
for (const [markerScopeId, markerNode] of cleanupMarkers) {
|
287
|
-
if (!len--) break;
|
288
|
-
if (markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
289
|
-
cleanupOwners.set("" + markerScopeId, scopeId);
|
290
|
-
cleanupMarkers.delete(markerScopeId);
|
291
|
-
}
|
292
|
-
}
|
293
|
-
cleanupMarkers.set(scopeId, visit);
|
294
|
-
return scope;
|
295
|
-
};
|
296
|
-
for (const visit of visits) {
|
297
|
-
const commentText = visit.data;
|
298
|
-
const token = commentText[commentPrefixLen];
|
299
|
-
const scopeId = parseInt(commentText.slice(commentPrefixLen + 1));
|
300
|
-
const scope = scopeLookup[scopeId] ||= {};
|
301
|
-
const dataIndex = commentText.indexOf(" ") + 1;
|
302
|
-
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
303
|
-
if (token === "*" /* Node */) {
|
304
|
-
scope[data3] = visit.previousSibling;
|
305
|
-
} else if (token === "$" /* Cleanup */) {
|
306
|
-
cleanupMarkers.set(scopeId, visit);
|
307
|
-
} else if (token === "[" /* SectionStart */) {
|
308
|
-
if (this.___currentScopeId) {
|
309
|
-
if (data3) {
|
310
|
-
sectionEnd(visit);
|
311
|
-
}
|
312
|
-
this.___scopeStack.push(this.___currentScopeId);
|
313
|
-
}
|
314
|
-
this.___currentScopeId = scopeId;
|
315
|
-
scope.___startNode = visit;
|
316
|
-
} else if (token === "]" /* SectionEnd */) {
|
317
|
-
scope[data3] = visit;
|
318
|
-
if (scopeId < this.___currentScopeId) {
|
319
|
-
const currParent = visit.parentNode;
|
320
|
-
const startNode = sectionEnd(visit).___startNode;
|
321
|
-
if (currParent && currParent !== startNode.parentNode) {
|
322
|
-
currParent.prepend(startNode);
|
323
|
-
}
|
324
|
-
this.___currentScopeId = this.___scopeStack.pop();
|
325
|
-
}
|
326
|
-
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
327
|
-
scope[true ? data3.slice(0, data3.indexOf(" ")) : parseInt(data3)] = visit;
|
328
|
-
const childScopeIds = JSON.parse(
|
329
|
-
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
330
|
-
);
|
331
|
-
let curNode = visit;
|
332
|
-
for (let i = childScopeIds.length - 1; i >= 0; i--) {
|
333
|
-
curNode = sectionEnd(visit, childScopeIds[i], curNode).___endNode;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
}
|
337
|
-
}
|
338
|
-
const resumes = data2.r;
|
339
|
-
if (resumes) {
|
340
|
-
data2.r = [];
|
341
|
-
const len = resumes.length;
|
342
|
-
let i = 0;
|
343
|
-
try {
|
344
|
-
isResuming = true;
|
345
|
-
while (i < len) {
|
346
|
-
const resumeData = resumes[i++];
|
347
|
-
if (typeof resumeData === "function") {
|
348
|
-
const scopes = resumeData(serializeContext);
|
349
|
-
let { $global } = scopeLookup;
|
350
|
-
if (!$global) {
|
351
|
-
scopeLookup.$global = $global = scopes.$ || {};
|
352
|
-
$global.runtimeId = this.___runtimeId;
|
353
|
-
$global.renderId = this.___renderId;
|
354
|
-
}
|
355
|
-
for (const scopeId in scopes) {
|
356
|
-
if (scopeId !== "$") {
|
357
|
-
const scope = scopes[scopeId];
|
358
|
-
const prevScope = scopeLookup[scopeId];
|
359
|
-
scope.$global = $global;
|
360
|
-
if (prevScope !== scope) {
|
361
|
-
scopeLookup[scopeId] = Object.assign(
|
362
|
-
scope,
|
363
|
-
prevScope
|
364
|
-
);
|
365
|
-
}
|
366
|
-
const cleanupOwnerId = cleanupOwners.get(scopeId);
|
367
|
-
if (cleanupOwnerId) {
|
368
|
-
scope.___cleanupOwner = scopes[cleanupOwnerId];
|
369
|
-
onDestroy(scope);
|
370
|
-
}
|
371
|
-
}
|
372
|
-
}
|
373
|
-
} else if (i === len || typeof resumes[i] !== "string") {
|
374
|
-
delete this.___renders[this.___renderId];
|
375
|
-
} else {
|
376
|
-
registeredValues[resumes[i++]](
|
377
|
-
scopeLookup[resumeData],
|
378
|
-
scopeLookup[resumeData]
|
379
|
-
);
|
380
|
-
}
|
381
|
-
}
|
382
|
-
} finally {
|
383
|
-
isResuming = false;
|
384
|
-
}
|
385
|
-
}
|
386
|
-
}
|
387
|
-
};
|
388
|
-
var isResuming = false;
|
389
|
-
function register(id, obj) {
|
390
|
-
registeredValues[id] = obj;
|
391
|
-
return obj;
|
392
|
-
}
|
393
|
-
function registerBoundSignal(id, signal) {
|
394
|
-
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
395
|
-
return signal;
|
396
|
-
}
|
397
|
-
function getRegisteredWithScope(id, scope) {
|
398
|
-
const val = registeredValues[id];
|
399
|
-
return scope ? val(scope) : val;
|
400
|
-
}
|
401
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
402
|
-
if (true) {
|
403
|
-
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
404
|
-
throw new Error(
|
405
|
-
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
406
|
-
);
|
407
|
-
}
|
408
|
-
}
|
409
|
-
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
410
|
-
let renders;
|
411
|
-
if (window[runtimeId]) {
|
412
|
-
setRenders(window[runtimeId]);
|
413
|
-
} else {
|
414
|
-
Object.defineProperty(window, runtimeId, {
|
415
|
-
configurable: true,
|
416
|
-
set: setRenders
|
417
|
-
});
|
418
|
-
}
|
419
|
-
function setRenders(v) {
|
420
|
-
if (true) {
|
421
|
-
if (renders) {
|
422
|
-
throw new Error(
|
423
|
-
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
424
|
-
);
|
425
|
-
}
|
426
|
-
}
|
427
|
-
renders = v;
|
428
|
-
for (const renderId in v) {
|
429
|
-
resumeRender(renderId);
|
430
|
-
}
|
431
|
-
Object.defineProperty(window, runtimeId, {
|
432
|
-
configurable: true,
|
433
|
-
value: resumeRender
|
434
|
-
});
|
435
|
-
}
|
436
|
-
}
|
437
|
-
function registerSubscriber(id, signal) {
|
438
|
-
register(id, signal.___subscribe);
|
439
|
-
return signal;
|
440
|
-
}
|
441
|
-
function nodeRef(id, key) {
|
442
|
-
return register(id, (scope) => () => scope[key]);
|
443
|
-
}
|
444
|
-
|
445
|
-
// src/dom/signals.ts
|
446
|
-
var MARK = true ? Symbol("mark") : {};
|
447
|
-
var CLEAN = true ? Symbol("clean") : {};
|
448
|
-
var DIRTY = true ? Symbol("dirty") : {};
|
449
|
-
function state(valueAccessor, fn, getIntersection) {
|
450
|
-
const valueSignal = value(valueAccessor, fn, getIntersection);
|
451
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
452
|
-
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
453
|
-
return (scope, valueOrOp, valueChange) => {
|
454
|
-
if (rendering) {
|
455
|
-
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
456
|
-
valueSignal(
|
457
|
-
scope,
|
458
|
-
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
459
|
-
);
|
460
|
-
} else if (scope[valueChangeAccessor]) {
|
461
|
-
scope[valueChangeAccessor](valueOrOp);
|
462
|
-
} else {
|
463
|
-
queueSource(scope, valueSignal, valueOrOp);
|
464
|
-
}
|
465
|
-
return valueOrOp;
|
466
|
-
};
|
467
|
-
}
|
468
|
-
function value(valueAccessor, fn, getIntersection) {
|
469
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
470
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
471
|
-
return (scope, valueOrOp) => {
|
472
|
-
if (valueOrOp === MARK) {
|
473
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
474
|
-
intersection2?.(scope, MARK);
|
475
|
-
}
|
476
|
-
} else if (valueOrOp !== DIRTY) {
|
477
|
-
const existing = scope[markAccessor] !== void 0;
|
478
|
-
if ((scope[markAccessor] ||= 1) === 1) {
|
479
|
-
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
480
|
-
intersection2?.(scope, CLEAN);
|
481
|
-
} else {
|
482
|
-
scope[valueAccessor] = valueOrOp;
|
483
|
-
fn && fn(scope, valueOrOp);
|
484
|
-
intersection2?.(scope, DIRTY);
|
485
|
-
}
|
486
|
-
}
|
487
|
-
scope[markAccessor]--;
|
488
|
-
}
|
489
|
-
};
|
490
|
-
}
|
491
|
-
var accessorId = 0;
|
492
|
-
function intersection(count, fn, getIntersection) {
|
493
|
-
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
494
|
-
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
495
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
496
|
-
return (scope, op) => {
|
497
|
-
if (op === MARK) {
|
498
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
499
|
-
intersection2?.(scope, MARK);
|
500
|
-
}
|
501
|
-
} else if (scope[markAccessor] === void 0) {
|
502
|
-
scope[markAccessor] = count - 1;
|
503
|
-
scope[dirtyAccessor] = true;
|
504
|
-
} else if (--scope[markAccessor] === 0) {
|
505
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
506
|
-
scope[dirtyAccessor] = false;
|
507
|
-
fn(scope, 0);
|
508
|
-
intersection2?.(scope, DIRTY);
|
509
|
-
} else {
|
510
|
-
intersection2?.(scope, CLEAN);
|
511
|
-
}
|
512
|
-
} else {
|
513
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
514
|
-
}
|
515
|
-
};
|
516
|
-
}
|
517
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
518
|
-
function closure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
519
|
-
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
520
|
-
const markAccessor = dirtyAccessor + 1;
|
521
|
-
const getOwnerValueAccessor = typeof ownerValueAccessor === "function" ? ownerValueAccessor : () => ownerValueAccessor;
|
522
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
523
|
-
return (scope, op) => {
|
524
|
-
if (op === MARK) {
|
525
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
526
|
-
intersection2?.(scope, MARK);
|
527
|
-
}
|
528
|
-
} else {
|
529
|
-
let ownerScope, ownerValueAccessor2;
|
530
|
-
if (scope[markAccessor] === void 0) {
|
531
|
-
ownerScope = getOwnerScope(scope);
|
532
|
-
ownerValueAccessor2 = getOwnerValueAccessor(scope);
|
533
|
-
const ownerMark = ownerScope[ownerValueAccessor2 + "#" /* Mark */];
|
534
|
-
const ownerHasRun = ownerMark === void 0 ? !ownerScope.___client : ownerMark === 0;
|
535
|
-
scope[markAccessor] = ownerHasRun ? 1 : 2;
|
536
|
-
op = DIRTY;
|
537
|
-
}
|
538
|
-
if (--scope[markAccessor] === 0) {
|
539
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
540
|
-
scope[dirtyAccessor] = false;
|
541
|
-
ownerScope ||= getOwnerScope(scope);
|
542
|
-
ownerValueAccessor2 ||= getOwnerValueAccessor(scope);
|
543
|
-
fn && fn(scope, ownerScope[ownerValueAccessor2]);
|
544
|
-
intersection2?.(scope, DIRTY);
|
545
|
-
} else {
|
546
|
-
intersection2?.(scope, CLEAN);
|
547
|
-
}
|
548
|
-
} else {
|
549
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
550
|
-
}
|
551
|
-
}
|
552
|
-
};
|
553
|
-
}
|
554
|
-
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
555
|
-
const getOwnerValueAccessor = typeof ownerValueAccessor === "function" ? ownerValueAccessor : () => ownerValueAccessor;
|
556
|
-
const signalFn = closure(
|
557
|
-
getOwnerValueAccessor,
|
558
|
-
fn,
|
559
|
-
getOwnerScope,
|
560
|
-
getIntersection
|
561
|
-
);
|
562
|
-
const subscribeFns = /* @__PURE__ */ new WeakMap();
|
563
|
-
signalFn.___subscribe = (scope) => {
|
564
|
-
const subscribeFn = (value2) => signalFn(scope, value2);
|
565
|
-
const ownerScope = getOwnerScope(scope);
|
566
|
-
const providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
567
|
-
subscribeFns.set(scope, subscribeFn);
|
568
|
-
(ownerScope[providerSubscriptionsAccessor] ||= /* @__PURE__ */ new Set()).add(subscribeFn);
|
569
|
-
};
|
570
|
-
signalFn.___unsubscribe = (scope) => {
|
571
|
-
const ownerScope = getOwnerScope(scope);
|
572
|
-
const providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
573
|
-
ownerScope[providerSubscriptionsAccessor]?.delete(subscribeFns.get(scope));
|
574
|
-
subscribeFns.delete(scope);
|
575
|
-
};
|
576
|
-
return signalFn;
|
577
|
-
}
|
578
|
-
function childClosures(closureSignals, childAccessor) {
|
579
|
-
const signal = (scope, op) => {
|
580
|
-
const childScope = scope[childAccessor];
|
581
|
-
for (const closureSignal of closureSignals) {
|
582
|
-
closureSignal(childScope, op);
|
583
|
-
}
|
584
|
-
};
|
585
|
-
signal.___subscribe = (scope) => {
|
586
|
-
const childScope = scope[childAccessor];
|
587
|
-
for (const closureSignal of closureSignals) {
|
588
|
-
closureSignal.___subscribe?.(childScope);
|
589
|
-
}
|
590
|
-
};
|
591
|
-
signal.___unsubscribe = (scope) => {
|
592
|
-
const childScope = scope[childAccessor];
|
593
|
-
for (const closureSignal of closureSignals) {
|
594
|
-
closureSignal.___unsubscribe?.(childScope);
|
595
|
-
}
|
596
|
-
};
|
597
|
-
return signal;
|
598
|
-
}
|
599
|
-
function dynamicSubscribers(valueAccessor) {
|
600
|
-
const subscribersAccessor = valueAccessor + "*" /* Subscribers */;
|
601
|
-
return (scope, op) => {
|
602
|
-
const subscribers = scope[subscribersAccessor];
|
603
|
-
if (subscribers) {
|
604
|
-
for (const subscriber of subscribers) {
|
605
|
-
subscriber(op);
|
606
|
-
}
|
607
|
-
}
|
608
|
-
};
|
609
|
-
}
|
610
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
611
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
612
|
-
}
|
613
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
614
|
-
function setTagVarChange(scope, changeHandler) {
|
615
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
616
|
-
}
|
617
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
618
|
-
var contentClosures = (content, childScope, op) => {
|
619
|
-
const signals = content?.___closureSignals;
|
620
|
-
if (signals) {
|
621
|
-
for (const signal of signals) {
|
622
|
-
signal(childScope, op);
|
623
|
-
}
|
624
|
-
}
|
625
|
-
};
|
626
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
627
|
-
function nextTagId({ $global }) {
|
628
|
-
const id = tagIdsByGlobal.get($global) || 0;
|
629
|
-
tagIdsByGlobal.set($global, id + 1);
|
630
|
-
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
631
|
-
}
|
632
|
-
function inChild(childAccessor, signal) {
|
633
|
-
return (scope, valueOrOp) => {
|
634
|
-
signal(scope[childAccessor], valueOrOp);
|
635
|
-
};
|
636
|
-
}
|
637
|
-
function intersections(signals) {
|
638
|
-
return (scope, op) => {
|
639
|
-
for (const signal of signals) {
|
640
|
-
signal(scope, op);
|
641
|
-
}
|
642
|
-
};
|
643
|
-
}
|
644
|
-
function effect(id, fn) {
|
645
|
-
register(id, fn);
|
646
|
-
return (scope) => {
|
647
|
-
queueEffect(scope, fn);
|
177
|
+
// src/dom/scope.ts
|
178
|
+
var pendingScopes = [];
|
179
|
+
var debugID = 0;
|
180
|
+
function createScope($global) {
|
181
|
+
const scope = {
|
182
|
+
___pending: 1,
|
183
|
+
$global
|
648
184
|
};
|
649
|
-
|
650
|
-
|
651
|
-
// src/dom/queue.ts
|
652
|
-
var pendingSignals = [];
|
653
|
-
var pendingEffects = [];
|
654
|
-
var rendering = false;
|
655
|
-
function queueSource(scope, signal, value2) {
|
656
|
-
schedule();
|
657
|
-
rendering = true;
|
658
|
-
signal(scope, MARK);
|
659
|
-
rendering = false;
|
660
|
-
pendingSignals.push(scope, signal, value2);
|
661
|
-
return value2;
|
662
|
-
}
|
663
|
-
function queueEffect(scope, fn) {
|
664
|
-
pendingEffects.push(scope, fn);
|
665
|
-
}
|
666
|
-
function run() {
|
667
|
-
const signals = pendingSignals;
|
668
|
-
const effects = pendingEffects;
|
669
|
-
try {
|
670
|
-
rendering = true;
|
671
|
-
pendingSignals = [];
|
672
|
-
runSignals(signals);
|
673
|
-
} finally {
|
674
|
-
rendering = false;
|
185
|
+
if (true) {
|
186
|
+
scope.___debugId = "client-" + debugID++;
|
675
187
|
}
|
676
|
-
|
677
|
-
|
188
|
+
pendingScopes.push(scope);
|
189
|
+
return scope;
|
678
190
|
}
|
679
|
-
function
|
680
|
-
const
|
681
|
-
|
682
|
-
const preparedEffects = pendingEffects = [];
|
683
|
-
const preparedSignals = pendingSignals = [];
|
684
|
-
try {
|
685
|
-
rendering = true;
|
686
|
-
fn();
|
687
|
-
pendingSignals = prevSignals;
|
688
|
-
runSignals(preparedSignals);
|
689
|
-
} finally {
|
690
|
-
rendering = false;
|
691
|
-
pendingSignals = prevSignals;
|
692
|
-
pendingEffects = prevEffects;
|
191
|
+
function finishPendingScopes() {
|
192
|
+
for (const scope of pendingScopes) {
|
193
|
+
scope.___pending = 0;
|
693
194
|
}
|
694
|
-
|
195
|
+
pendingScopes = [];
|
695
196
|
}
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
fn(scope, scope);
|
701
|
-
}
|
197
|
+
var emptyScope = createScope({});
|
198
|
+
function getEmptyScope(marker) {
|
199
|
+
emptyScope.___startNode = emptyScope.___endNode = marker;
|
200
|
+
return emptyScope;
|
702
201
|
}
|
703
|
-
function
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
const
|
708
|
-
|
202
|
+
function destroyBranch(branch) {
|
203
|
+
branch.___destroyed = 1;
|
204
|
+
branch.___branchScopes?.forEach(destroyBranch);
|
205
|
+
if (branch.___abortScopes) {
|
206
|
+
for (const scope of branch.___abortScopes) {
|
207
|
+
for (const id in scope.___abortControllers) {
|
208
|
+
scope.___abortControllers[id]?.abort();
|
209
|
+
}
|
210
|
+
}
|
709
211
|
}
|
710
212
|
}
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
const
|
715
|
-
|
716
|
-
const
|
717
|
-
|
718
|
-
|
719
|
-
controllers.delete(id);
|
720
|
-
}
|
213
|
+
function removeAndDestroyBranch(branch) {
|
214
|
+
destroyBranch(branch);
|
215
|
+
let current = branch.___startNode;
|
216
|
+
const stop = branch.___endNode.nextSibling;
|
217
|
+
while (current !== stop) {
|
218
|
+
const next = current.nextSibling;
|
219
|
+
current.remove();
|
220
|
+
current = next;
|
721
221
|
}
|
722
222
|
}
|
723
|
-
function
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
223
|
+
function insertBefore(scope, parent, nextSibling) {
|
224
|
+
let current = scope.___startNode;
|
225
|
+
const stop = scope.___endNode.nextSibling;
|
226
|
+
while (current !== stop) {
|
227
|
+
const next = current.nextSibling;
|
228
|
+
parent.insertBefore(current, nextSibling);
|
229
|
+
current = next;
|
729
230
|
}
|
730
|
-
return controller.signal;
|
731
231
|
}
|
732
232
|
|
733
|
-
// src/common/compat-meta.ts
|
734
|
-
var prefix = true ? "$compat_" : "$C_";
|
735
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
736
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
737
|
-
|
738
233
|
// src/common/helpers.ts
|
739
234
|
function classValue(value2) {
|
740
235
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -792,57 +287,57 @@ function normalizeDynamicRenderer(value2) {
|
|
792
287
|
|
793
288
|
// src/dom/reconcile.ts
|
794
289
|
var WRONG_POS = 2147483647;
|
795
|
-
function reconcile(parent,
|
290
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
796
291
|
let oldStart = 0;
|
797
292
|
let newStart = 0;
|
798
|
-
let oldEnd =
|
799
|
-
let newEnd =
|
800
|
-
let
|
801
|
-
let
|
802
|
-
let
|
803
|
-
let
|
293
|
+
let oldEnd = oldBranches.length - 1;
|
294
|
+
let newEnd = newBranches.length - 1;
|
295
|
+
let oldStartBranch = oldBranches[oldStart];
|
296
|
+
let newStartBranch = newBranches[newStart];
|
297
|
+
let oldEndBranch = oldBranches[oldEnd];
|
298
|
+
let newEndBranch = newBranches[newEnd];
|
804
299
|
let i;
|
805
300
|
let j;
|
806
301
|
let k;
|
807
302
|
let nextSibling;
|
808
|
-
let
|
809
|
-
let
|
303
|
+
let oldBranch;
|
304
|
+
let newBranch;
|
810
305
|
outer: {
|
811
|
-
while (
|
306
|
+
while (oldStartBranch === newStartBranch) {
|
812
307
|
++oldStart;
|
813
308
|
++newStart;
|
814
309
|
if (oldStart > oldEnd || newStart > newEnd) {
|
815
310
|
break outer;
|
816
311
|
}
|
817
|
-
|
818
|
-
|
312
|
+
oldStartBranch = oldBranches[oldStart];
|
313
|
+
newStartBranch = newBranches[newStart];
|
819
314
|
}
|
820
|
-
while (
|
315
|
+
while (oldEndBranch === newEndBranch) {
|
821
316
|
--oldEnd;
|
822
317
|
--newEnd;
|
823
318
|
if (oldStart > oldEnd || newStart > newEnd) {
|
824
319
|
break outer;
|
825
320
|
}
|
826
|
-
|
827
|
-
|
321
|
+
oldEndBranch = oldBranches[oldEnd];
|
322
|
+
newEndBranch = newBranches[newEnd];
|
828
323
|
}
|
829
324
|
}
|
830
325
|
if (oldStart > oldEnd) {
|
831
326
|
if (newStart <= newEnd) {
|
832
327
|
k = newEnd + 1;
|
833
|
-
nextSibling = k <
|
328
|
+
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
834
329
|
do {
|
835
|
-
insertBefore(
|
330
|
+
insertBefore(newBranches[newStart++], parent, nextSibling);
|
836
331
|
} while (newStart <= newEnd);
|
837
332
|
}
|
838
333
|
} else if (newStart > newEnd) {
|
839
334
|
do {
|
840
|
-
|
335
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
841
336
|
} while (oldStart <= oldEnd);
|
842
337
|
} else {
|
843
338
|
const oldLength = oldEnd - oldStart + 1;
|
844
339
|
const newLength = newEnd - newStart + 1;
|
845
|
-
const aNullable =
|
340
|
+
const aNullable = oldBranches;
|
846
341
|
const sources = new Array(newLength);
|
847
342
|
for (i = 0; i < newLength; ++i) {
|
848
343
|
sources[i] = -1;
|
@@ -851,64 +346,64 @@ function reconcile(parent, oldScopes, newScopes, afterReference) {
|
|
851
346
|
let synced = 0;
|
852
347
|
const keyIndex = /* @__PURE__ */ new Map();
|
853
348
|
for (j = newStart; j <= newEnd; ++j) {
|
854
|
-
keyIndex.set(
|
349
|
+
keyIndex.set(newBranches[j], j);
|
855
350
|
}
|
856
351
|
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
857
|
-
|
858
|
-
j = keyIndex.get(
|
352
|
+
oldBranch = oldBranches[i];
|
353
|
+
j = keyIndex.get(oldBranch);
|
859
354
|
if (j !== void 0) {
|
860
355
|
pos = pos > j ? WRONG_POS : j;
|
861
356
|
++synced;
|
862
|
-
|
357
|
+
newBranch = newBranches[j];
|
863
358
|
sources[j - newStart] = i;
|
864
359
|
aNullable[i] = null;
|
865
360
|
}
|
866
361
|
}
|
867
|
-
if (oldLength ===
|
362
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
868
363
|
for (; newStart < newLength; ++newStart) {
|
869
|
-
insertBefore(
|
364
|
+
insertBefore(newBranches[newStart], parent, afterReference);
|
870
365
|
}
|
871
366
|
for (; oldStart < oldLength; ++oldStart) {
|
872
|
-
|
367
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
873
368
|
}
|
874
369
|
} else {
|
875
370
|
i = oldLength - synced;
|
876
371
|
while (i > 0) {
|
877
|
-
|
878
|
-
if (
|
879
|
-
|
372
|
+
oldBranch = aNullable[oldStart++];
|
373
|
+
if (oldBranch !== null) {
|
374
|
+
removeAndDestroyBranch(oldBranch);
|
880
375
|
i--;
|
881
376
|
}
|
882
377
|
}
|
883
378
|
if (pos === WRONG_POS) {
|
884
379
|
const seq = longestIncreasingSubsequence(sources);
|
885
380
|
j = seq.length - 1;
|
886
|
-
k =
|
381
|
+
k = newBranches.length;
|
887
382
|
for (i = newLength - 1; i >= 0; --i) {
|
888
383
|
if (sources[i] === -1) {
|
889
384
|
pos = i + newStart;
|
890
|
-
|
891
|
-
nextSibling = pos < k ?
|
892
|
-
insertBefore(
|
385
|
+
newBranch = newBranches[pos++];
|
386
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
387
|
+
insertBefore(newBranch, parent, nextSibling);
|
893
388
|
} else {
|
894
389
|
if (j < 0 || i !== seq[j]) {
|
895
390
|
pos = i + newStart;
|
896
|
-
|
897
|
-
nextSibling = pos < k ?
|
898
|
-
insertBefore(
|
391
|
+
newBranch = newBranches[pos++];
|
392
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
393
|
+
insertBefore(newBranch, parent, nextSibling);
|
899
394
|
} else {
|
900
395
|
--j;
|
901
396
|
}
|
902
397
|
}
|
903
398
|
}
|
904
399
|
} else if (synced !== newLength) {
|
905
|
-
k =
|
400
|
+
k = newBranches.length;
|
906
401
|
for (i = newLength - 1; i >= 0; --i) {
|
907
402
|
if (sources[i] === -1) {
|
908
403
|
pos = i + newStart;
|
909
|
-
|
910
|
-
nextSibling = pos < k ?
|
911
|
-
insertBefore(
|
404
|
+
newBranch = newBranches[pos++];
|
405
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
406
|
+
insertBefore(newBranch, parent, nextSibling);
|
912
407
|
}
|
913
408
|
}
|
914
409
|
}
|
@@ -990,7 +485,7 @@ function handleDelegated(ev) {
|
|
990
485
|
const handlersByElement = elementHandlersByEvent.get(ev.type);
|
991
486
|
handlersByElement.get(target)?.(ev, target);
|
992
487
|
if (ev.bubbles) {
|
993
|
-
while ((target = target.
|
488
|
+
while ((target = target.parentNode) && !ev.cancelBubble) {
|
994
489
|
handlersByElement.get(target)?.(ev, target);
|
995
490
|
}
|
996
491
|
}
|
@@ -1018,10 +513,226 @@ function resolveCursorPosition(updatedValue, initialValue, initialPosition, inpu
|
|
1018
513
|
return pos;
|
1019
514
|
}
|
1020
515
|
}
|
1021
|
-
return -1;
|
516
|
+
return -1;
|
517
|
+
}
|
518
|
+
function stripSpacesAndPunctuation(str) {
|
519
|
+
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
520
|
+
}
|
521
|
+
|
522
|
+
// src/common/meta.ts
|
523
|
+
var DEFAULT_RUNTIME_ID = "M";
|
524
|
+
var DEFAULT_RENDER_ID = "_";
|
525
|
+
|
526
|
+
// src/dom/resume.ts
|
527
|
+
var registeredValues = {};
|
528
|
+
var Render = class {
|
529
|
+
___scopeStack = [];
|
530
|
+
___scopeLookup = {};
|
531
|
+
___serializeContext = {
|
532
|
+
_: registeredValues
|
533
|
+
};
|
534
|
+
constructor(renders, runtimeId, renderId) {
|
535
|
+
this.___renders = renders;
|
536
|
+
this.___runtimeId = runtimeId;
|
537
|
+
this.___renderId = renderId;
|
538
|
+
this.___data = renders[renderId];
|
539
|
+
this.___resume();
|
540
|
+
}
|
541
|
+
w() {
|
542
|
+
this.___data.w();
|
543
|
+
this.___resume();
|
544
|
+
}
|
545
|
+
___resume() {
|
546
|
+
const data2 = this.___data;
|
547
|
+
const serializeContext = this.___serializeContext;
|
548
|
+
const scopeLookup = this.___scopeLookup;
|
549
|
+
const visits = data2.v;
|
550
|
+
const branchIds = /* @__PURE__ */ new Set();
|
551
|
+
const parentBranchIds = /* @__PURE__ */ new Map();
|
552
|
+
if (visits.length) {
|
553
|
+
const commentPrefix = data2.i;
|
554
|
+
const commentPrefixLen = commentPrefix.length;
|
555
|
+
const closestBranchMarkers = /* @__PURE__ */ new Map();
|
556
|
+
data2.v = [];
|
557
|
+
const branchEnd = (branchId, visit, curNode) => {
|
558
|
+
const branch = scopeLookup[branchId] ||= {};
|
559
|
+
let endNode = curNode;
|
560
|
+
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
561
|
+
branch.___endNode = endNode;
|
562
|
+
branch.___startNode ||= endNode;
|
563
|
+
for (const [markerScopeId, markerNode] of closestBranchMarkers) {
|
564
|
+
if (branch.___startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
565
|
+
parentBranchIds.set(markerScopeId, branchId);
|
566
|
+
closestBranchMarkers.delete(markerScopeId);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
branchIds.add(branchId);
|
570
|
+
closestBranchMarkers.set(branchId, visit);
|
571
|
+
return branch;
|
572
|
+
};
|
573
|
+
for (const visit of visits) {
|
574
|
+
const commentText = visit.data;
|
575
|
+
const dataIndex = commentText.indexOf(" ") + 1;
|
576
|
+
const scopeId = commentText.slice(
|
577
|
+
commentPrefixLen + 1,
|
578
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
579
|
+
);
|
580
|
+
const scope = scopeLookup[scopeId] ||= {};
|
581
|
+
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
582
|
+
const token = commentText[commentPrefixLen];
|
583
|
+
if (token === "*" /* Node */) {
|
584
|
+
scope[data3] = visit.previousSibling;
|
585
|
+
} else if (token === "$" /* ClosestBranch */) {
|
586
|
+
closestBranchMarkers.set(scopeId, visit);
|
587
|
+
} else if (token === "[" /* BranchStart */) {
|
588
|
+
if (this.___currentScopeId) {
|
589
|
+
if (dataIndex) {
|
590
|
+
branchEnd(this.___currentScopeId, visit, visit);
|
591
|
+
}
|
592
|
+
this.___scopeStack.push(this.___currentScopeId);
|
593
|
+
}
|
594
|
+
this.___currentScopeId = scopeId;
|
595
|
+
scope.___startNode = visit;
|
596
|
+
} else if (token === "]" /* BranchEnd */) {
|
597
|
+
scope[data3] = visit;
|
598
|
+
const curParent = visit.parentNode;
|
599
|
+
const startNode = branchEnd(
|
600
|
+
this.___currentScopeId,
|
601
|
+
visit,
|
602
|
+
visit
|
603
|
+
).___startNode;
|
604
|
+
if (curParent !== startNode.parentNode) {
|
605
|
+
curParent.prepend(startNode);
|
606
|
+
}
|
607
|
+
this.___currentScopeId = this.___scopeStack.pop();
|
608
|
+
} else if (token === "|" /* BranchSingleNode */) {
|
609
|
+
let next = data3.indexOf(" ");
|
610
|
+
let curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
611
|
+
while (~next) {
|
612
|
+
const start = next + 1;
|
613
|
+
next = data3.indexOf(" ", start);
|
614
|
+
const childScopeId = data3.slice(start, ~next ? next : data3.length);
|
615
|
+
curNode = branchEnd(childScopeId, visit, curNode).___endNode;
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
}
|
620
|
+
const resumes = data2.r;
|
621
|
+
if (resumes) {
|
622
|
+
data2.r = [];
|
623
|
+
const len = resumes.length;
|
624
|
+
let i = 0;
|
625
|
+
try {
|
626
|
+
isResuming = true;
|
627
|
+
while (i < len) {
|
628
|
+
const resumeData = resumes[i++];
|
629
|
+
if (typeof resumeData === "function") {
|
630
|
+
const scopes = resumeData(serializeContext);
|
631
|
+
let { $global } = scopeLookup;
|
632
|
+
if (!$global) {
|
633
|
+
scopeLookup.$global = $global = scopes.$ || {};
|
634
|
+
$global.runtimeId = this.___runtimeId;
|
635
|
+
$global.renderId = this.___renderId;
|
636
|
+
}
|
637
|
+
for (const scopeId in scopes) {
|
638
|
+
if (scopeId !== "$") {
|
639
|
+
const scope = scopes[scopeId];
|
640
|
+
const prevScope = scopeLookup[scopeId];
|
641
|
+
scope.$global = $global;
|
642
|
+
if (prevScope !== scope) {
|
643
|
+
scopeLookup[scopeId] = Object.assign(
|
644
|
+
scope,
|
645
|
+
prevScope
|
646
|
+
);
|
647
|
+
}
|
648
|
+
const parentBranchId = parentBranchIds.get(scopeId);
|
649
|
+
if (parentBranchId) {
|
650
|
+
scope.___closestBranch = scopes[parentBranchId];
|
651
|
+
}
|
652
|
+
if (branchIds.has(scopeId)) {
|
653
|
+
const branch = scope;
|
654
|
+
const parentBranch = branch.___closestBranch;
|
655
|
+
scope.___closestBranch = branch;
|
656
|
+
if (parentBranch) {
|
657
|
+
branch.___parentBranch = parentBranch;
|
658
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
659
|
+
}
|
660
|
+
}
|
661
|
+
if (true) {
|
662
|
+
scope.___debugId = "server-" + scopeId;
|
663
|
+
}
|
664
|
+
}
|
665
|
+
}
|
666
|
+
} else if (i === len || typeof resumes[i] !== "string") {
|
667
|
+
delete this.___renders[this.___renderId];
|
668
|
+
} else {
|
669
|
+
registeredValues[resumes[i++]](
|
670
|
+
scopeLookup[resumeData],
|
671
|
+
scopeLookup[resumeData]
|
672
|
+
);
|
673
|
+
}
|
674
|
+
}
|
675
|
+
} finally {
|
676
|
+
isResuming = false;
|
677
|
+
}
|
678
|
+
}
|
679
|
+
}
|
680
|
+
};
|
681
|
+
var isResuming = false;
|
682
|
+
function register(id, obj) {
|
683
|
+
registeredValues[id] = obj;
|
684
|
+
return obj;
|
685
|
+
}
|
686
|
+
function registerBoundSignal(id, signal) {
|
687
|
+
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
688
|
+
return signal;
|
689
|
+
}
|
690
|
+
function getRegisteredWithScope(id, scope) {
|
691
|
+
const val = registeredValues[id];
|
692
|
+
return scope ? val(scope) : val;
|
693
|
+
}
|
694
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
695
|
+
if (true) {
|
696
|
+
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
697
|
+
throw new Error(
|
698
|
+
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
699
|
+
);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
703
|
+
let renders;
|
704
|
+
if (window[runtimeId]) {
|
705
|
+
setRenders(window[runtimeId]);
|
706
|
+
} else {
|
707
|
+
Object.defineProperty(window, runtimeId, {
|
708
|
+
configurable: true,
|
709
|
+
set: setRenders
|
710
|
+
});
|
711
|
+
}
|
712
|
+
function setRenders(v) {
|
713
|
+
if (true) {
|
714
|
+
if (renders) {
|
715
|
+
throw new Error(
|
716
|
+
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
717
|
+
);
|
718
|
+
}
|
719
|
+
}
|
720
|
+
renders = v;
|
721
|
+
for (const renderId in v) {
|
722
|
+
resumeRender(renderId);
|
723
|
+
}
|
724
|
+
Object.defineProperty(window, runtimeId, {
|
725
|
+
configurable: true,
|
726
|
+
value: resumeRender
|
727
|
+
});
|
728
|
+
}
|
1022
729
|
}
|
1023
|
-
function
|
1024
|
-
|
730
|
+
function registerSubscriber(id, signal) {
|
731
|
+
register(id, signal.___subscribe);
|
732
|
+
return signal;
|
733
|
+
}
|
734
|
+
function nodeRef(id, key) {
|
735
|
+
return register(id, (scope) => () => scope[key]);
|
1025
736
|
}
|
1026
737
|
|
1027
738
|
// src/dom/controllable.ts
|
@@ -1123,10 +834,13 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
1123
834
|
} else {
|
1124
835
|
scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */;
|
1125
836
|
}
|
1126
|
-
|
1127
|
-
scope
|
1128
|
-
|
1129
|
-
|
837
|
+
pendingEffects.unshift(
|
838
|
+
scope,
|
839
|
+
() => setSelectOptions(
|
840
|
+
scope[nodeAccessor],
|
841
|
+
value2,
|
842
|
+
valueChange
|
843
|
+
)
|
1130
844
|
);
|
1131
845
|
}
|
1132
846
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
@@ -1292,18 +1006,26 @@ function toValueProp(it) {
|
|
1292
1006
|
}
|
1293
1007
|
|
1294
1008
|
// src/dom/parse-html.ts
|
1295
|
-
var fallback = /* @__PURE__ */
|
1296
|
-
var parser = /* @__PURE__ */
|
1009
|
+
var fallback = /* @__PURE__ */ new Text();
|
1010
|
+
var parser = /* @__PURE__ */ document.createElement("template");
|
1297
1011
|
function parseHTML(html2) {
|
1298
|
-
|
1012
|
+
parser.innerHTML = html2;
|
1013
|
+
return parser.content;
|
1299
1014
|
}
|
1300
1015
|
function parseHTMLOrSingleNode(html2) {
|
1301
1016
|
const content = parseHTML(html2);
|
1302
|
-
if (
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1017
|
+
if (content.firstChild) {
|
1018
|
+
if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
|
1019
|
+
// a single replaced node, in which case the walker can't replace
|
1020
|
+
// the node itself.
|
1021
|
+
content.firstChild.nodeType !== 8) {
|
1022
|
+
return content.firstChild;
|
1023
|
+
}
|
1024
|
+
const fragment = new DocumentFragment();
|
1025
|
+
fragment.appendChild(content);
|
1026
|
+
return fragment;
|
1027
|
+
}
|
1028
|
+
return fallback;
|
1307
1029
|
}
|
1308
1030
|
|
1309
1031
|
// src/dom/dom.ts
|
@@ -1339,7 +1061,8 @@ function textContent(node, value2) {
|
|
1339
1061
|
}
|
1340
1062
|
function attrs(scope, nodeAccessor, nextAttrs) {
|
1341
1063
|
const el = scope[nodeAccessor];
|
1342
|
-
for (
|
1064
|
+
for (let i = el.attributes.length; i--; ) {
|
1065
|
+
const { name } = el.attributes.item(i);
|
1343
1066
|
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) {
|
1344
1067
|
el.removeAttribute(name);
|
1345
1068
|
}
|
@@ -1352,7 +1075,8 @@ function hasAttrAlias(element, attr2, nextAttrs) {
|
|
1352
1075
|
function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
|
1353
1076
|
const el = scope[nodeAccessor];
|
1354
1077
|
const partial = {};
|
1355
|
-
for (
|
1078
|
+
for (let i = el.attributes.length; i--; ) {
|
1079
|
+
const { name } = el.attributes.item(i);
|
1356
1080
|
if (!skip[name] && !(nextAttrs && name in nextAttrs)) {
|
1357
1081
|
el.removeAttribute(name);
|
1358
1082
|
}
|
@@ -1539,17 +1263,14 @@ function trimWalkString(walkString) {
|
|
1539
1263
|
}
|
1540
1264
|
function walk(startNode, walkCodes, scope) {
|
1541
1265
|
walker.currentNode = startNode;
|
1542
|
-
walkInternal(walkCodes, scope,
|
1543
|
-
walker.currentNode = document
|
1266
|
+
walkInternal(walkCodes, scope, 0);
|
1267
|
+
walker.currentNode = document;
|
1544
1268
|
}
|
1545
|
-
function walkInternal(walkCodes, scope,
|
1269
|
+
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
1546
1270
|
let value2;
|
1547
1271
|
let storedMultiplier = 0;
|
1548
1272
|
let currentMultiplier = 0;
|
1549
1273
|
let currentScopeIndex = 0;
|
1550
|
-
if (cleanupOwnerScope !== scope) {
|
1551
|
-
scope.___cleanupOwner = cleanupOwnerScope;
|
1552
|
-
}
|
1553
1274
|
while (value2 = walkCodes.charCodeAt(currentWalkIndex++)) {
|
1554
1275
|
currentMultiplier = storedMultiplier;
|
1555
1276
|
storedMultiplier = 0;
|
@@ -1572,18 +1293,16 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
1572
1293
|
walker.nextNode();
|
1573
1294
|
}
|
1574
1295
|
} else if (value2 === 47 /* BeginChild */) {
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
currentWalkIndex
|
1580
|
-
);
|
1296
|
+
const childScope = scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global);
|
1297
|
+
childScope.___startNode = walker.currentNode;
|
1298
|
+
childScope.___closestBranch = scope.___closestBranch;
|
1299
|
+
currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
1581
1300
|
} else if (value2 === 38 /* EndChild */) {
|
1582
1301
|
return currentWalkIndex;
|
1583
1302
|
} else if (value2 === 32 /* Get */) {
|
1584
1303
|
scope[true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++] = walker.currentNode;
|
1585
1304
|
} else {
|
1586
|
-
const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] =
|
1305
|
+
const newNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text();
|
1587
1306
|
const current = walker.currentNode;
|
1588
1307
|
const parentNode = current.parentNode;
|
1589
1308
|
if (value2 !== 37 /* Replace */) {
|
@@ -1609,26 +1328,40 @@ function getDebugKey(index, node) {
|
|
1609
1328
|
}
|
1610
1329
|
|
1611
1330
|
// src/dom/renderer.ts
|
1612
|
-
function
|
1613
|
-
const
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
}
|
1331
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
1332
|
+
const branch = createBranch(
|
1333
|
+
$global,
|
1334
|
+
renderer.___owner || parentScope,
|
1335
|
+
parentScope
|
1336
|
+
);
|
1337
|
+
if (true) {
|
1338
|
+
branch.___renderer = renderer;
|
1621
1339
|
}
|
1622
|
-
|
1340
|
+
initRenderer(renderer, branch);
|
1341
|
+
return branch;
|
1623
1342
|
}
|
1624
|
-
function
|
1343
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
1625
1344
|
if (typeof tagNameOrRenderer !== "string") {
|
1626
|
-
return
|
1345
|
+
return createBranchScopeWithRenderer(
|
1346
|
+
tagNameOrRenderer,
|
1347
|
+
$global,
|
1348
|
+
parentScope
|
1349
|
+
);
|
1350
|
+
}
|
1351
|
+
const branch = createBranch($global, parentScope, parentScope);
|
1352
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElement(tagNameOrRenderer);
|
1353
|
+
return branch;
|
1354
|
+
}
|
1355
|
+
function createBranch($global, ownerScope, parentScope) {
|
1356
|
+
const branch = createScope($global);
|
1357
|
+
const parentBranch = parentScope.___closestBranch;
|
1358
|
+
branch._ = ownerScope;
|
1359
|
+
branch.___closestBranch = branch;
|
1360
|
+
if (parentBranch) {
|
1361
|
+
branch.___parentBranch = parentBranch;
|
1362
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
1627
1363
|
}
|
1628
|
-
|
1629
|
-
newScope._ = newScope.___cleanupOwner = ownerScope;
|
1630
|
-
newScope[true ? `#${tagNameOrRenderer}/0` : 0] = newScope.___startNode = newScope.___endNode = document.createElement(tagNameOrRenderer);
|
1631
|
-
return newScope;
|
1364
|
+
return branch;
|
1632
1365
|
}
|
1633
1366
|
function initRenderer(renderer, scope) {
|
1634
1367
|
const dom = renderer.___clone();
|
@@ -1640,7 +1373,7 @@ function initRenderer(renderer, scope) {
|
|
1640
1373
|
scope.___startNode = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom;
|
1641
1374
|
scope.___endNode = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom;
|
1642
1375
|
if (renderer.___setup) {
|
1643
|
-
renderer.___setup
|
1376
|
+
queueRender(scope, renderer.___setup);
|
1644
1377
|
}
|
1645
1378
|
return dom;
|
1646
1379
|
}
|
@@ -1678,9 +1411,8 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
1678
1411
|
}
|
1679
1412
|
};
|
1680
1413
|
}
|
1681
|
-
function createRendererWithOwner(template, rawWalks, setup,
|
1414
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
1682
1415
|
let args;
|
1683
|
-
let closureSignals;
|
1684
1416
|
const id = true ? Symbol("Marko Renderer") : {};
|
1685
1417
|
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1686
1418
|
return (owner) => {
|
@@ -1694,21 +1426,12 @@ function createRendererWithOwner(template, rawWalks, setup, getClosureSignals, g
|
|
1694
1426
|
___sourceNode: void 0,
|
1695
1427
|
get ___args() {
|
1696
1428
|
return args ||= getArgs?.();
|
1697
|
-
},
|
1698
|
-
get ___closureSignals() {
|
1699
|
-
return closureSignals ||= new Set(getClosureSignals?.());
|
1700
1429
|
}
|
1701
1430
|
};
|
1702
1431
|
};
|
1703
1432
|
}
|
1704
|
-
function createRenderer(template, walks, setup,
|
1705
|
-
return createRendererWithOwner(
|
1706
|
-
template,
|
1707
|
-
walks,
|
1708
|
-
setup,
|
1709
|
-
getClosureSignals,
|
1710
|
-
getArgs
|
1711
|
-
)();
|
1433
|
+
function createRenderer(template, walks, setup, getArgs) {
|
1434
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1712
1435
|
}
|
1713
1436
|
function _clone() {
|
1714
1437
|
return (this.___sourceNode ||= parseHTMLOrSingleNode(
|
@@ -1723,16 +1446,14 @@ function patchConditionals(fn) {
|
|
1723
1446
|
}
|
1724
1447
|
var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
1725
1448
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1726
|
-
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1727
1449
|
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1728
1450
|
return (scope, newRendererOrOp) => {
|
1729
1451
|
if (newRendererOrOp === DIRTY) return;
|
1730
|
-
|
1452
|
+
const currentRenderer = scope[rendererAccessor];
|
1731
1453
|
let op = newRendererOrOp;
|
1732
1454
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1733
1455
|
const normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1734
1456
|
if (isDifferentRenderer(normalizedRenderer, currentRenderer)) {
|
1735
|
-
currentRenderer = scope[rendererAccessor] = normalizedRenderer;
|
1736
1457
|
setConditionalRenderer(scope, nodeAccessor, normalizedRenderer);
|
1737
1458
|
fn && fn(scope);
|
1738
1459
|
op = DIRTY;
|
@@ -1741,46 +1462,22 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1741
1462
|
}
|
1742
1463
|
}
|
1743
1464
|
intersection2?.(scope, op);
|
1744
|
-
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1745
1465
|
};
|
1746
1466
|
};
|
1747
|
-
function inConditionalScope(signal, nodeAccessor) {
|
1748
|
-
const scopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1749
|
-
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1750
|
-
return (scope, op) => {
|
1751
|
-
const conditionalScope = scope[scopeAccessor];
|
1752
|
-
if (conditionalScope) {
|
1753
|
-
const conditionalRenderer = scope[rendererAccessor];
|
1754
|
-
if (!conditionalRenderer?.___closureSignals || conditionalRenderer.___closureSignals.has(signal)) {
|
1755
|
-
signal(conditionalScope, op);
|
1756
|
-
}
|
1757
|
-
}
|
1758
|
-
};
|
1759
|
-
}
|
1760
1467
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
1761
|
-
|
1762
|
-
|
1763
|
-
if (newRenderer) {
|
1764
|
-
newScope = scope[nodeAccessor + "!" /* ConditionalScope */] = createScopeWithTagNameOrRenderer(
|
1765
|
-
newRenderer,
|
1766
|
-
scope.$global,
|
1767
|
-
scope
|
1768
|
-
);
|
1769
|
-
prevScope = prevScope || getEmptyScope(scope[nodeAccessor]);
|
1770
|
-
} else {
|
1771
|
-
newScope = getEmptyScope(scope[nodeAccessor]);
|
1772
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = void 0;
|
1773
|
-
}
|
1468
|
+
const newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
1469
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
|
1774
1470
|
insertBefore(
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1471
|
+
newBranch || getEmptyScope(scope[nodeAccessor]),
|
1472
|
+
prevBranch.___startNode.parentNode,
|
1473
|
+
prevBranch.___startNode
|
1778
1474
|
);
|
1779
|
-
|
1475
|
+
removeAndDestroyBranch(prevBranch);
|
1476
|
+
scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer;
|
1477
|
+
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1780
1478
|
}
|
1781
1479
|
var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersection) {
|
1782
1480
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1783
|
-
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1784
1481
|
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1785
1482
|
return (scope, newRendererOrOp) => {
|
1786
1483
|
if (newRendererOrOp === DIRTY) return;
|
@@ -1802,20 +1499,22 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1802
1499
|
}
|
1803
1500
|
}
|
1804
1501
|
intersection2?.(scope, op);
|
1805
|
-
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1806
1502
|
};
|
1807
1503
|
};
|
1808
1504
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1809
|
-
const
|
1505
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1810
1506
|
const referenceNode = scope[nodeAccessor];
|
1507
|
+
const newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
1811
1508
|
referenceNode.textContent = "";
|
1812
|
-
if (
|
1813
|
-
|
1814
|
-
insertBefore(newScope, referenceNode, null);
|
1509
|
+
if (newBranch) {
|
1510
|
+
insertBefore(newBranch, referenceNode, null);
|
1815
1511
|
}
|
1816
|
-
|
1512
|
+
prevBranch && destroyBranch(prevBranch);
|
1513
|
+
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1817
1514
|
}
|
1818
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1515
|
+
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1516
|
+
[Symbol(), getEmptyScope(void 0)]
|
1517
|
+
]);
|
1819
1518
|
var emptyMarkerArray = [
|
1820
1519
|
/* @__PURE__ */ getEmptyScope(void 0)
|
1821
1520
|
];
|
@@ -1853,18 +1552,14 @@ function loopTo(nodeAccessor, renderer) {
|
|
1853
1552
|
}
|
1854
1553
|
function loop(nodeAccessor, renderer, forEach) {
|
1855
1554
|
const loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */;
|
1856
|
-
const closureSignals = renderer.___closureSignals;
|
1857
1555
|
const params = renderer.___args;
|
1858
1556
|
return (scope, valueOrOp) => {
|
1859
1557
|
if (valueOrOp === DIRTY) return;
|
1860
1558
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1861
|
-
const
|
1862
|
-
if (
|
1863
|
-
for (const
|
1864
|
-
params?.(
|
1865
|
-
for (const signal of closureSignals) {
|
1866
|
-
signal(childScope, valueOrOp);
|
1867
|
-
}
|
1559
|
+
const loopBranches = scope[loopScopeAccessor] ?? scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1560
|
+
if (loopBranches !== emptyMarkerArray) {
|
1561
|
+
for (const branch of loopBranches) {
|
1562
|
+
params?.(branch, valueOrOp);
|
1868
1563
|
}
|
1869
1564
|
}
|
1870
1565
|
return;
|
@@ -1879,27 +1574,20 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1879
1574
|
let parentNode;
|
1880
1575
|
let needsReconciliation = true;
|
1881
1576
|
forEach(valueOrOp, (key, args) => {
|
1882
|
-
let
|
1883
|
-
|
1884
|
-
|
1885
|
-
childScope = createScopeWithRenderer(renderer, scope.$global, scope);
|
1886
|
-
closureOp = DIRTY;
|
1577
|
+
let branch = oldMap.get(key);
|
1578
|
+
if (!branch) {
|
1579
|
+
branch = createBranchScopeWithRenderer(renderer, scope.$global, scope);
|
1887
1580
|
} else {
|
1888
1581
|
}
|
1889
1582
|
if (params) {
|
1890
|
-
params(
|
1891
|
-
}
|
1892
|
-
if (closureSignals) {
|
1893
|
-
for (const signal of closureSignals) {
|
1894
|
-
signal(childScope, closureOp);
|
1895
|
-
}
|
1583
|
+
params(branch, args);
|
1896
1584
|
}
|
1897
1585
|
if (newMap) {
|
1898
|
-
newMap.set(key,
|
1899
|
-
newArray.push(
|
1586
|
+
newMap.set(key, branch);
|
1587
|
+
newArray.push(branch);
|
1900
1588
|
} else {
|
1901
|
-
newMap = /* @__PURE__ */ new Map([[key,
|
1902
|
-
newArray = [
|
1589
|
+
newMap = /* @__PURE__ */ new Map([[key, branch]]);
|
1590
|
+
newArray = [branch];
|
1903
1591
|
}
|
1904
1592
|
});
|
1905
1593
|
if (!newMap) {
|
@@ -1908,7 +1596,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1908
1596
|
newArray = emptyMarkerArray;
|
1909
1597
|
getEmptyScope(referenceNode);
|
1910
1598
|
} else {
|
1911
|
-
oldArray.forEach(
|
1599
|
+
oldArray.forEach(destroyBranch);
|
1912
1600
|
referenceNode.textContent = "";
|
1913
1601
|
newMap = emptyMap;
|
1914
1602
|
newArray = emptyArray;
|
@@ -1933,17 +1621,6 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1933
1621
|
scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
1934
1622
|
};
|
1935
1623
|
}
|
1936
|
-
function inLoopScope(signal, loopNodeAccessor) {
|
1937
|
-
const loopScopeAccessor = loopNodeAccessor + "!" /* LoopScopeArray */;
|
1938
|
-
return (scope, op) => {
|
1939
|
-
const loopScopes = scope[loopScopeAccessor] ?? scope[loopNodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1940
|
-
if (loopScopes !== emptyMarkerArray) {
|
1941
|
-
for (const scope2 of loopScopes) {
|
1942
|
-
signal(scope2, op);
|
1943
|
-
}
|
1944
|
-
}
|
1945
|
-
};
|
1946
|
-
}
|
1947
1624
|
function bySecondArg(_item, index) {
|
1948
1625
|
return index;
|
1949
1626
|
}
|
@@ -1954,6 +1631,298 @@ function isDifferentRenderer(a, b) {
|
|
1954
1631
|
return a !== b && (a?.___id || 0) !== b?.___id;
|
1955
1632
|
}
|
1956
1633
|
|
1634
|
+
// src/dom/signals.ts
|
1635
|
+
var MARK = true ? Symbol("mark") : {};
|
1636
|
+
var CLEAN = true ? Symbol("clean") : {};
|
1637
|
+
var DIRTY = true ? Symbol("dirty") : {};
|
1638
|
+
function state(valueAccessor, fn, getIntersection) {
|
1639
|
+
const valueSignal = value(valueAccessor, fn, getIntersection);
|
1640
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1641
|
+
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1642
|
+
return (scope, valueOrOp, valueChange) => {
|
1643
|
+
if (rendering) {
|
1644
|
+
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
1645
|
+
valueSignal(
|
1646
|
+
scope,
|
1647
|
+
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1648
|
+
);
|
1649
|
+
} else if (scope[valueChangeAccessor]) {
|
1650
|
+
scope[valueChangeAccessor](valueOrOp);
|
1651
|
+
} else {
|
1652
|
+
queueSource(scope, valueSignal, valueOrOp);
|
1653
|
+
}
|
1654
|
+
return valueOrOp;
|
1655
|
+
};
|
1656
|
+
}
|
1657
|
+
function value(valueAccessor, fn, getIntersection) {
|
1658
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1659
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1660
|
+
return (scope, valueOrOp) => {
|
1661
|
+
if (valueOrOp === MARK) {
|
1662
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1663
|
+
intersection2?.(scope, MARK);
|
1664
|
+
}
|
1665
|
+
} else if (valueOrOp !== DIRTY) {
|
1666
|
+
const existing = scope[markAccessor] !== void 0;
|
1667
|
+
if ((scope[markAccessor] ||= 1) === 1) {
|
1668
|
+
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
1669
|
+
intersection2?.(scope, CLEAN);
|
1670
|
+
} else {
|
1671
|
+
scope[valueAccessor] = valueOrOp;
|
1672
|
+
fn && fn(scope, valueOrOp);
|
1673
|
+
intersection2?.(scope, DIRTY);
|
1674
|
+
}
|
1675
|
+
}
|
1676
|
+
scope[markAccessor]--;
|
1677
|
+
}
|
1678
|
+
};
|
1679
|
+
}
|
1680
|
+
var accessorId = 0;
|
1681
|
+
function intersection(count, fn, getIntersection) {
|
1682
|
+
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
1683
|
+
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
1684
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1685
|
+
return (scope, op) => {
|
1686
|
+
if (op === MARK) {
|
1687
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1688
|
+
intersection2?.(scope, MARK);
|
1689
|
+
}
|
1690
|
+
} else if (scope[markAccessor] === void 0) {
|
1691
|
+
scope[markAccessor] = count - 1;
|
1692
|
+
scope[dirtyAccessor] = true;
|
1693
|
+
} else if (--scope[markAccessor] === 0) {
|
1694
|
+
if (op === DIRTY || scope[dirtyAccessor]) {
|
1695
|
+
scope[dirtyAccessor] = false;
|
1696
|
+
fn(scope, 0);
|
1697
|
+
intersection2?.(scope, DIRTY);
|
1698
|
+
} else {
|
1699
|
+
intersection2?.(scope, CLEAN);
|
1700
|
+
}
|
1701
|
+
} else {
|
1702
|
+
scope[dirtyAccessor] ||= op === DIRTY;
|
1703
|
+
}
|
1704
|
+
};
|
1705
|
+
}
|
1706
|
+
function closure(fn, getIntersection) {
|
1707
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1708
|
+
return (scope, valueOrOp) => {
|
1709
|
+
if (valueOrOp === MARK) {
|
1710
|
+
intersection2?.(scope, MARK);
|
1711
|
+
} else {
|
1712
|
+
fn && fn(scope, valueOrOp);
|
1713
|
+
intersection2?.(scope, DIRTY);
|
1714
|
+
}
|
1715
|
+
};
|
1716
|
+
}
|
1717
|
+
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1718
|
+
const signal = closure(fn, getIntersection);
|
1719
|
+
const loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */;
|
1720
|
+
const loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */;
|
1721
|
+
const helperSignal = (ownerScope, value2) => {
|
1722
|
+
const loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1723
|
+
if (loopScopes !== emptyMarkerArray) {
|
1724
|
+
for (const scope of loopScopes) {
|
1725
|
+
if (!scope.___pending) {
|
1726
|
+
queueSource(scope, signal, value2);
|
1727
|
+
}
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
};
|
1731
|
+
helperSignal._ = signal;
|
1732
|
+
return helperSignal;
|
1733
|
+
}
|
1734
|
+
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1735
|
+
const signal = closure(fn, getIntersection);
|
1736
|
+
const scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */;
|
1737
|
+
const rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */;
|
1738
|
+
const helperSignal = (scope, value2) => {
|
1739
|
+
const conditionalScope = scope[scopeAccessor];
|
1740
|
+
if (conditionalScope && !conditionalScope.___pending && scope[rendererAccessor]?.___id === getRenderer().___id) {
|
1741
|
+
queueSource(conditionalScope, signal, value2);
|
1742
|
+
}
|
1743
|
+
};
|
1744
|
+
helperSignal._ = signal;
|
1745
|
+
return helperSignal;
|
1746
|
+
}
|
1747
|
+
var defaultGetOwnerScope = (scope) => scope._;
|
1748
|
+
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1749
|
+
const ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */;
|
1750
|
+
const _signal = closure(fn, getIntersection);
|
1751
|
+
const helperSignal = (ownerScope, value2) => {
|
1752
|
+
const subscribers = ownerScope[ownerSubscribersAccessor];
|
1753
|
+
if (subscribers) {
|
1754
|
+
for (const subscriber of subscribers) {
|
1755
|
+
if (!subscriber.___pending) {
|
1756
|
+
queueSource(subscriber, _signal, value2);
|
1757
|
+
}
|
1758
|
+
}
|
1759
|
+
}
|
1760
|
+
};
|
1761
|
+
const setupSignal = (scope, value2) => {
|
1762
|
+
_signal(scope, value2);
|
1763
|
+
subscribe(scope);
|
1764
|
+
};
|
1765
|
+
const subscribe = (scope) => {
|
1766
|
+
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope);
|
1767
|
+
getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1768
|
+
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1769
|
+
});
|
1770
|
+
};
|
1771
|
+
helperSignal._ = setupSignal;
|
1772
|
+
helperSignal.___subscribe = subscribe;
|
1773
|
+
return helperSignal;
|
1774
|
+
}
|
1775
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1776
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1777
|
+
}
|
1778
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1779
|
+
function setTagVarChange(scope, changeHandler) {
|
1780
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1781
|
+
}
|
1782
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1783
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1784
|
+
function nextTagId({ $global }) {
|
1785
|
+
const id = tagIdsByGlobal.get($global) || 0;
|
1786
|
+
tagIdsByGlobal.set($global, id + 1);
|
1787
|
+
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1788
|
+
}
|
1789
|
+
function inChild(childAccessor, signal) {
|
1790
|
+
return (scope, valueOrOp) => {
|
1791
|
+
signal(scope[childAccessor], valueOrOp);
|
1792
|
+
};
|
1793
|
+
}
|
1794
|
+
function intersections(signals) {
|
1795
|
+
return (scope, op) => {
|
1796
|
+
for (const signal of signals) {
|
1797
|
+
signal(scope, op);
|
1798
|
+
}
|
1799
|
+
};
|
1800
|
+
}
|
1801
|
+
function effect(id, fn) {
|
1802
|
+
register(id, fn);
|
1803
|
+
return (scope) => {
|
1804
|
+
queueEffect(scope, fn);
|
1805
|
+
};
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
// src/dom/queue.ts
|
1809
|
+
var pendingRender;
|
1810
|
+
var pendingEffects = [];
|
1811
|
+
var rendering = false;
|
1812
|
+
function queueSource(scope, signal, value2) {
|
1813
|
+
schedule();
|
1814
|
+
const prevRendering = rendering;
|
1815
|
+
rendering = true;
|
1816
|
+
signal(scope, MARK);
|
1817
|
+
rendering = prevRendering;
|
1818
|
+
queueRender(scope, signal, value2);
|
1819
|
+
return value2;
|
1820
|
+
}
|
1821
|
+
function queueRender(scope, signal, value2) {
|
1822
|
+
const nextRender = {
|
1823
|
+
___scope: scope,
|
1824
|
+
___signal: signal,
|
1825
|
+
___value: value2,
|
1826
|
+
___next: void 0
|
1827
|
+
};
|
1828
|
+
if (!pendingRender) {
|
1829
|
+
pendingRender = nextRender;
|
1830
|
+
} else if (comparePendingRenders(pendingRender, nextRender) < 0) {
|
1831
|
+
if (rendering) {
|
1832
|
+
throw new Error(
|
1833
|
+
"attempted to queue a render before the currently executing render"
|
1834
|
+
);
|
1835
|
+
}
|
1836
|
+
nextRender.___next = pendingRender;
|
1837
|
+
pendingRender = nextRender;
|
1838
|
+
} else {
|
1839
|
+
let curRender = pendingRender;
|
1840
|
+
while (curRender.___next && comparePendingRenders(curRender.___next, nextRender) >= 0) {
|
1841
|
+
curRender = curRender.___next;
|
1842
|
+
}
|
1843
|
+
nextRender.___next = curRender.___next;
|
1844
|
+
curRender.___next = nextRender;
|
1845
|
+
}
|
1846
|
+
}
|
1847
|
+
function queueEffect(scope, fn) {
|
1848
|
+
pendingEffects.push(scope, fn);
|
1849
|
+
}
|
1850
|
+
function run() {
|
1851
|
+
const effects = pendingEffects;
|
1852
|
+
try {
|
1853
|
+
rendering = true;
|
1854
|
+
runRenders();
|
1855
|
+
} finally {
|
1856
|
+
pendingRender = void 0;
|
1857
|
+
rendering = false;
|
1858
|
+
}
|
1859
|
+
pendingEffects = [];
|
1860
|
+
runEffects(effects);
|
1861
|
+
}
|
1862
|
+
function prepareEffects(fn) {
|
1863
|
+
const prevRender = pendingRender;
|
1864
|
+
const prevEffects = pendingEffects;
|
1865
|
+
const preparedEffects = pendingEffects = [];
|
1866
|
+
pendingRender = void 0;
|
1867
|
+
try {
|
1868
|
+
rendering = true;
|
1869
|
+
fn();
|
1870
|
+
runRenders();
|
1871
|
+
} finally {
|
1872
|
+
rendering = false;
|
1873
|
+
pendingRender = prevRender;
|
1874
|
+
pendingEffects = prevEffects;
|
1875
|
+
}
|
1876
|
+
return preparedEffects;
|
1877
|
+
}
|
1878
|
+
function runEffects(effects = pendingEffects) {
|
1879
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1880
|
+
const scope = effects[i];
|
1881
|
+
const fn = effects[i + 1];
|
1882
|
+
fn(scope, scope);
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
function runRenders() {
|
1886
|
+
while (pendingRender) {
|
1887
|
+
if (!pendingRender.___scope.___closestBranch?.___destroyed) {
|
1888
|
+
pendingRender.___signal(pendingRender.___scope, pendingRender.___value);
|
1889
|
+
}
|
1890
|
+
pendingRender = pendingRender.___next;
|
1891
|
+
}
|
1892
|
+
finishPendingScopes();
|
1893
|
+
}
|
1894
|
+
function comparePendingRenders(a, b) {
|
1895
|
+
const aStart = ownerStartNode(a.___scope);
|
1896
|
+
const bStart = ownerStartNode(b.___scope);
|
1897
|
+
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1898
|
+
}
|
1899
|
+
function ownerStartNode(scope) {
|
1900
|
+
return (scope.___closestBranch || scope).___startNode;
|
1901
|
+
}
|
1902
|
+
|
1903
|
+
// src/dom/abort-signal.ts
|
1904
|
+
function resetAbortSignal(scope, id) {
|
1905
|
+
const ctrl = scope.___abortControllers?.[id];
|
1906
|
+
if (ctrl) {
|
1907
|
+
queueEffect(ctrl, abort);
|
1908
|
+
scope.___abortControllers[id] = void 0;
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
function getAbortSignal(scope, id) {
|
1912
|
+
if (scope.___closestBranch) {
|
1913
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1914
|
+
}
|
1915
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1916
|
+
}
|
1917
|
+
function abort(ctrl) {
|
1918
|
+
ctrl.abort();
|
1919
|
+
}
|
1920
|
+
|
1921
|
+
// src/common/compat-meta.ts
|
1922
|
+
var prefix = true ? "$compat_" : "$C_";
|
1923
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1924
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1925
|
+
|
1957
1926
|
// src/dom/compat.ts
|
1958
1927
|
var classIdToScope = /* @__PURE__ */ new Map();
|
1959
1928
|
var compat = {
|
@@ -1983,6 +1952,11 @@ var compat = {
|
|
1983
1952
|
runComponentEffects() {
|
1984
1953
|
runEffects(this.effects);
|
1985
1954
|
},
|
1955
|
+
runComponentDestroy() {
|
1956
|
+
if (this.scope) {
|
1957
|
+
destroyBranch(this.scope);
|
1958
|
+
}
|
1959
|
+
},
|
1986
1960
|
resolveRegistered(value2, {
|
1987
1961
|
runtimeId,
|
1988
1962
|
componentIdPrefix
|
@@ -1996,13 +1970,7 @@ var compat = {
|
|
1996
1970
|
return value2;
|
1997
1971
|
},
|
1998
1972
|
createRenderer(setup, clone, args) {
|
1999
|
-
const renderer = createRenderer(
|
2000
|
-
"",
|
2001
|
-
void 0,
|
2002
|
-
setup,
|
2003
|
-
void 0,
|
2004
|
-
args && (() => args)
|
2005
|
-
);
|
1973
|
+
const renderer = createRenderer("", void 0, setup, args && (() => args));
|
2006
1974
|
renderer.___clone = clone;
|
2007
1975
|
return renderer;
|
2008
1976
|
},
|
@@ -2026,13 +1994,9 @@ var compat = {
|
|
2026
1994
|
}
|
2027
1995
|
component.effects = prepareEffects(() => {
|
2028
1996
|
if (!scope) {
|
2029
|
-
scope = component.scope =
|
2030
|
-
|
2031
|
-
|
2032
|
-
for (const signal of closures) {
|
2033
|
-
signal(component.scope, CLEAN);
|
2034
|
-
}
|
2035
|
-
}
|
1997
|
+
scope = component.scope = createScope(out.global);
|
1998
|
+
scope._ = renderer.___owner;
|
1999
|
+
initRenderer(renderer, scope);
|
2036
2000
|
} else {
|
2037
2001
|
applyArgs(scope, MARK);
|
2038
2002
|
existing = true;
|
@@ -2062,7 +2026,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
2062
2026
|
return register(templateId, renderer);
|
2063
2027
|
};
|
2064
2028
|
function mount(input = {}, reference, position) {
|
2065
|
-
let
|
2029
|
+
let branch, dom;
|
2066
2030
|
let { $global } = input;
|
2067
2031
|
if ($global) {
|
2068
2032
|
({ $global, ...input } = input);
|
@@ -2079,21 +2043,21 @@ function mount(input = {}, reference, position) {
|
|
2079
2043
|
}
|
2080
2044
|
const args = this.___args;
|
2081
2045
|
const effects = prepareEffects(() => {
|
2082
|
-
|
2083
|
-
dom = initRenderer(this,
|
2046
|
+
branch = createScope($global);
|
2047
|
+
dom = initRenderer(this, branch);
|
2084
2048
|
if (args) {
|
2085
|
-
args(
|
2049
|
+
args(branch, [input]);
|
2086
2050
|
}
|
2087
2051
|
});
|
2088
2052
|
switch (position) {
|
2053
|
+
case "beforebegin":
|
2054
|
+
reference.parentNode.insertBefore(dom, reference);
|
2055
|
+
break;
|
2089
2056
|
case "afterbegin":
|
2090
2057
|
reference.insertBefore(dom, reference.firstChild);
|
2091
2058
|
break;
|
2092
2059
|
case "afterend":
|
2093
|
-
reference.
|
2094
|
-
break;
|
2095
|
-
case "beforebegin":
|
2096
|
-
reference.parentElement.insertBefore(dom, reference);
|
2060
|
+
reference.parentNode.insertBefore(dom, reference.nextSibling);
|
2097
2061
|
break;
|
2098
2062
|
default:
|
2099
2063
|
reference.appendChild(dom);
|
@@ -2105,14 +2069,14 @@ function mount(input = {}, reference, position) {
|
|
2105
2069
|
if (args) {
|
2106
2070
|
runEffects(
|
2107
2071
|
prepareEffects(() => {
|
2108
|
-
args(
|
2109
|
-
args(
|
2072
|
+
args(branch, MARK);
|
2073
|
+
args(branch, [newInput]);
|
2110
2074
|
})
|
2111
2075
|
);
|
2112
2076
|
}
|
2113
2077
|
},
|
2114
2078
|
destroy: () => {
|
2115
|
-
|
2079
|
+
removeAndDestroyBranch(branch);
|
2116
2080
|
}
|
2117
2081
|
};
|
2118
2082
|
}
|