marko 6.0.0-next.3.21 → 6.0.0-next.3.23
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 +696 -740
- package/dist/debug/dom.mjs +696 -740
- 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/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 +441 -482
- package/dist/dom.mjs +441 -482
- 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 +474 -468
- package/dist/translator/util/get-style-file.d.ts +2 -0
- 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.mjs
CHANGED
@@ -87,564 +87,62 @@ function triggerMacroTask() {
|
|
87
87
|
port2.postMessage(0);
|
88
88
|
}
|
89
89
|
|
90
|
-
// src/
|
91
|
-
var
|
92
|
-
var
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
const scope = {
|
98
|
-
___client: 1,
|
99
|
-
$global
|
100
|
-
};
|
101
|
-
if (true) {
|
102
|
-
scope.___debugId = debugID++;
|
103
|
-
}
|
104
|
-
return scope;
|
105
|
-
}
|
106
|
-
var emptyScope = createScope({});
|
107
|
-
function getEmptyScope(marker) {
|
108
|
-
emptyScope.___startNode = emptyScope.___endNode = marker;
|
109
|
-
return emptyScope;
|
110
|
-
}
|
111
|
-
function destroyScope(scope) {
|
112
|
-
_destroyScope(scope);
|
113
|
-
scope.___cleanupOwner?.___cleanup?.delete(scope);
|
114
|
-
const closureSignals = scope.___renderer?.___closureSignals;
|
115
|
-
if (closureSignals) {
|
116
|
-
for (const signal of closureSignals) {
|
117
|
-
signal.___unsubscribe?.(scope);
|
118
|
-
}
|
119
|
-
}
|
120
|
-
return scope;
|
121
|
-
}
|
122
|
-
function _destroyScope(scope) {
|
123
|
-
scope.___cleanup?.forEach(_destroyScope);
|
124
|
-
const controllers = scope.___abortControllers;
|
125
|
-
if (controllers) {
|
126
|
-
for (const ctrl of controllers.values()) {
|
127
|
-
ctrl.abort();
|
128
|
-
}
|
129
|
-
}
|
130
|
-
}
|
131
|
-
function onDestroy(scope) {
|
132
|
-
let parentScope = scope.___cleanupOwner;
|
133
|
-
while (parentScope && !parentScope.___cleanup?.has(scope)) {
|
134
|
-
(parentScope.___cleanup ||= /* @__PURE__ */ new Set()).add(scope);
|
135
|
-
scope = parentScope;
|
136
|
-
parentScope = scope.___cleanupOwner;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
function removeAndDestroyScope(scope) {
|
140
|
-
destroyScope(scope);
|
141
|
-
let current = scope.___startNode;
|
142
|
-
const stop = scope.___endNode.nextSibling;
|
143
|
-
while (current !== stop) {
|
144
|
-
const next = current.nextSibling;
|
145
|
-
current.remove();
|
146
|
-
current = next;
|
147
|
-
}
|
148
|
-
}
|
149
|
-
function insertBefore(scope, parent, nextSibling) {
|
150
|
-
let current = scope.___startNode;
|
151
|
-
const stop = scope.___endNode.nextSibling;
|
152
|
-
while (current !== stop) {
|
153
|
-
const next = current.nextSibling;
|
154
|
-
parent.insertBefore(current, nextSibling);
|
155
|
-
current = next;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
|
-
// src/dom/resume.ts
|
160
|
-
var registeredValues = {};
|
161
|
-
var Render = class {
|
162
|
-
___scopeStack = [];
|
163
|
-
___scopeLookup = {};
|
164
|
-
___serializeContext = {
|
165
|
-
_: registeredValues
|
166
|
-
};
|
167
|
-
constructor(renders, runtimeId, renderId) {
|
168
|
-
this.___renders = renders;
|
169
|
-
this.___runtimeId = runtimeId;
|
170
|
-
this.___renderId = renderId;
|
171
|
-
this.___data = renders[renderId];
|
172
|
-
this.___resume();
|
173
|
-
}
|
174
|
-
w() {
|
175
|
-
this.___data.w();
|
176
|
-
this.___resume();
|
177
|
-
}
|
178
|
-
___resume() {
|
179
|
-
const data2 = this.___data;
|
180
|
-
const serializeContext = this.___serializeContext;
|
181
|
-
const scopeLookup = this.___scopeLookup;
|
182
|
-
const visits = data2.v;
|
183
|
-
const cleanupOwners = /* @__PURE__ */ new Map();
|
184
|
-
if (visits.length) {
|
185
|
-
const commentPrefix = data2.i;
|
186
|
-
const commentPrefixLen = commentPrefix.length;
|
187
|
-
const cleanupMarkers = /* @__PURE__ */ new Map();
|
188
|
-
data2.v = [];
|
189
|
-
const sectionEnd = (visit, scopeId = this.___currentScopeId, curNode = visit) => {
|
190
|
-
const scope = scopeLookup[scopeId] ||= {};
|
191
|
-
let endNode = curNode;
|
192
|
-
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
193
|
-
scope.___endNode = endNode;
|
194
|
-
const startNode = scope.___startNode ||= endNode;
|
195
|
-
let len = cleanupMarkers.size;
|
196
|
-
for (const [markerScopeId, markerNode] of cleanupMarkers) {
|
197
|
-
if (!len--) break;
|
198
|
-
if (markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
199
|
-
cleanupOwners.set("" + markerScopeId, scopeId);
|
200
|
-
cleanupMarkers.delete(markerScopeId);
|
201
|
-
}
|
202
|
-
}
|
203
|
-
cleanupMarkers.set(scopeId, visit);
|
204
|
-
return scope;
|
205
|
-
};
|
206
|
-
for (const visit of visits) {
|
207
|
-
const commentText = visit.data;
|
208
|
-
const token = commentText[commentPrefixLen];
|
209
|
-
const scopeId = parseInt(commentText.slice(commentPrefixLen + 1));
|
210
|
-
const scope = scopeLookup[scopeId] ||= {};
|
211
|
-
const dataIndex = commentText.indexOf(" ") + 1;
|
212
|
-
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
213
|
-
if (token === "*" /* Node */) {
|
214
|
-
scope[data3] = visit.previousSibling;
|
215
|
-
} else if (token === "$" /* Cleanup */) {
|
216
|
-
cleanupMarkers.set(scopeId, visit);
|
217
|
-
} else if (token === "[" /* SectionStart */) {
|
218
|
-
if (this.___currentScopeId) {
|
219
|
-
if (data3) {
|
220
|
-
sectionEnd(visit);
|
221
|
-
}
|
222
|
-
this.___scopeStack.push(this.___currentScopeId);
|
223
|
-
}
|
224
|
-
this.___currentScopeId = scopeId;
|
225
|
-
scope.___startNode = visit;
|
226
|
-
} else if (token === "]" /* SectionEnd */) {
|
227
|
-
scope[data3] = visit;
|
228
|
-
if (scopeId < this.___currentScopeId) {
|
229
|
-
const currParent = visit.parentNode;
|
230
|
-
const startNode = sectionEnd(visit).___startNode;
|
231
|
-
if (currParent && currParent !== startNode.parentNode) {
|
232
|
-
currParent.prepend(startNode);
|
233
|
-
}
|
234
|
-
this.___currentScopeId = this.___scopeStack.pop();
|
235
|
-
}
|
236
|
-
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
237
|
-
scope[true ? data3.slice(0, data3.indexOf(" ")) : parseInt(data3)] = visit;
|
238
|
-
const childScopeIds = JSON.parse(
|
239
|
-
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
240
|
-
);
|
241
|
-
let curNode = visit;
|
242
|
-
for (let i = childScopeIds.length - 1; i >= 0; i--) {
|
243
|
-
curNode = sectionEnd(visit, childScopeIds[i], curNode).___endNode;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
}
|
247
|
-
}
|
248
|
-
const resumes = data2.r;
|
249
|
-
if (resumes) {
|
250
|
-
data2.r = [];
|
251
|
-
const len = resumes.length;
|
252
|
-
let i = 0;
|
253
|
-
try {
|
254
|
-
isResuming = true;
|
255
|
-
while (i < len) {
|
256
|
-
const resumeData = resumes[i++];
|
257
|
-
if (typeof resumeData === "function") {
|
258
|
-
const scopes = resumeData(serializeContext);
|
259
|
-
let { $global } = scopeLookup;
|
260
|
-
if (!$global) {
|
261
|
-
scopeLookup.$global = $global = scopes.$ || {};
|
262
|
-
$global.runtimeId = this.___runtimeId;
|
263
|
-
$global.renderId = this.___renderId;
|
264
|
-
}
|
265
|
-
for (const scopeId in scopes) {
|
266
|
-
if (scopeId !== "$") {
|
267
|
-
const scope = scopes[scopeId];
|
268
|
-
const prevScope = scopeLookup[scopeId];
|
269
|
-
scope.$global = $global;
|
270
|
-
if (prevScope !== scope) {
|
271
|
-
scopeLookup[scopeId] = Object.assign(
|
272
|
-
scope,
|
273
|
-
prevScope
|
274
|
-
);
|
275
|
-
}
|
276
|
-
const cleanupOwnerId = cleanupOwners.get(scopeId);
|
277
|
-
if (cleanupOwnerId) {
|
278
|
-
scope.___cleanupOwner = scopes[cleanupOwnerId];
|
279
|
-
onDestroy(scope);
|
280
|
-
}
|
281
|
-
}
|
282
|
-
}
|
283
|
-
} else if (i === len || typeof resumes[i] !== "string") {
|
284
|
-
delete this.___renders[this.___renderId];
|
285
|
-
} else {
|
286
|
-
registeredValues[resumes[i++]](
|
287
|
-
scopeLookup[resumeData],
|
288
|
-
scopeLookup[resumeData]
|
289
|
-
);
|
290
|
-
}
|
291
|
-
}
|
292
|
-
} finally {
|
293
|
-
isResuming = false;
|
294
|
-
}
|
295
|
-
}
|
296
|
-
}
|
297
|
-
};
|
298
|
-
var isResuming = false;
|
299
|
-
function register(id, obj) {
|
300
|
-
registeredValues[id] = obj;
|
301
|
-
return obj;
|
302
|
-
}
|
303
|
-
function registerBoundSignal(id, signal) {
|
304
|
-
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
305
|
-
return signal;
|
306
|
-
}
|
307
|
-
function getRegisteredWithScope(id, scope) {
|
308
|
-
const val = registeredValues[id];
|
309
|
-
return scope ? val(scope) : val;
|
310
|
-
}
|
311
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
312
|
-
if (true) {
|
313
|
-
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
314
|
-
throw new Error(
|
315
|
-
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
316
|
-
);
|
317
|
-
}
|
318
|
-
}
|
319
|
-
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
320
|
-
let renders;
|
321
|
-
if (window[runtimeId]) {
|
322
|
-
setRenders(window[runtimeId]);
|
323
|
-
} else {
|
324
|
-
Object.defineProperty(window, runtimeId, {
|
325
|
-
configurable: true,
|
326
|
-
set: setRenders
|
327
|
-
});
|
328
|
-
}
|
329
|
-
function setRenders(v) {
|
330
|
-
if (true) {
|
331
|
-
if (renders) {
|
332
|
-
throw new Error(
|
333
|
-
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
334
|
-
);
|
335
|
-
}
|
336
|
-
}
|
337
|
-
renders = v;
|
338
|
-
for (const renderId in v) {
|
339
|
-
resumeRender(renderId);
|
340
|
-
}
|
341
|
-
Object.defineProperty(window, runtimeId, {
|
342
|
-
configurable: true,
|
343
|
-
value: resumeRender
|
344
|
-
});
|
345
|
-
}
|
346
|
-
}
|
347
|
-
function registerSubscriber(id, signal) {
|
348
|
-
register(id, signal.___subscribe);
|
349
|
-
return signal;
|
350
|
-
}
|
351
|
-
function nodeRef(id, key) {
|
352
|
-
return register(id, (scope) => () => scope[key]);
|
353
|
-
}
|
354
|
-
|
355
|
-
// src/dom/signals.ts
|
356
|
-
var MARK = true ? Symbol("mark") : {};
|
357
|
-
var CLEAN = true ? Symbol("clean") : {};
|
358
|
-
var DIRTY = true ? Symbol("dirty") : {};
|
359
|
-
function state(valueAccessor, fn, getIntersection) {
|
360
|
-
const valueSignal = value(valueAccessor, fn, getIntersection);
|
361
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
362
|
-
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
363
|
-
return (scope, valueOrOp, valueChange) => {
|
364
|
-
if (rendering) {
|
365
|
-
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
366
|
-
valueSignal(
|
367
|
-
scope,
|
368
|
-
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
369
|
-
);
|
370
|
-
} else if (scope[valueChangeAccessor]) {
|
371
|
-
scope[valueChangeAccessor](valueOrOp);
|
372
|
-
} else {
|
373
|
-
queueSource(scope, valueSignal, valueOrOp);
|
374
|
-
}
|
375
|
-
return valueOrOp;
|
376
|
-
};
|
377
|
-
}
|
378
|
-
function value(valueAccessor, fn, getIntersection) {
|
379
|
-
const markAccessor = valueAccessor + "#" /* Mark */;
|
380
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
381
|
-
return (scope, valueOrOp) => {
|
382
|
-
if (valueOrOp === MARK) {
|
383
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
384
|
-
intersection2?.(scope, MARK);
|
385
|
-
}
|
386
|
-
} else if (valueOrOp !== DIRTY) {
|
387
|
-
const existing = scope[markAccessor] !== void 0;
|
388
|
-
if ((scope[markAccessor] ||= 1) === 1) {
|
389
|
-
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
390
|
-
intersection2?.(scope, CLEAN);
|
391
|
-
} else {
|
392
|
-
scope[valueAccessor] = valueOrOp;
|
393
|
-
fn && fn(scope, valueOrOp);
|
394
|
-
intersection2?.(scope, DIRTY);
|
395
|
-
}
|
396
|
-
}
|
397
|
-
scope[markAccessor]--;
|
398
|
-
}
|
399
|
-
};
|
400
|
-
}
|
401
|
-
var accessorId = 0;
|
402
|
-
function intersection(count, fn, getIntersection) {
|
403
|
-
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
404
|
-
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
405
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
406
|
-
return (scope, op) => {
|
407
|
-
if (op === MARK) {
|
408
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
409
|
-
intersection2?.(scope, MARK);
|
410
|
-
}
|
411
|
-
} else if (scope[markAccessor] === void 0) {
|
412
|
-
scope[markAccessor] = count - 1;
|
413
|
-
scope[dirtyAccessor] = true;
|
414
|
-
} else if (--scope[markAccessor] === 0) {
|
415
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
416
|
-
scope[dirtyAccessor] = false;
|
417
|
-
fn(scope, 0);
|
418
|
-
intersection2?.(scope, DIRTY);
|
419
|
-
} else {
|
420
|
-
intersection2?.(scope, CLEAN);
|
421
|
-
}
|
422
|
-
} else {
|
423
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
424
|
-
}
|
425
|
-
};
|
426
|
-
}
|
427
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
428
|
-
function closure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
429
|
-
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
430
|
-
const markAccessor = dirtyAccessor + 1;
|
431
|
-
const getOwnerValueAccessor = typeof ownerValueAccessor === "function" ? ownerValueAccessor : () => ownerValueAccessor;
|
432
|
-
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
433
|
-
return (scope, op) => {
|
434
|
-
if (op === MARK) {
|
435
|
-
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
436
|
-
intersection2?.(scope, MARK);
|
437
|
-
}
|
438
|
-
} else {
|
439
|
-
let ownerScope, ownerValueAccessor2;
|
440
|
-
if (scope[markAccessor] === void 0) {
|
441
|
-
ownerScope = getOwnerScope(scope);
|
442
|
-
ownerValueAccessor2 = getOwnerValueAccessor(scope);
|
443
|
-
const ownerMark = ownerScope[ownerValueAccessor2 + "#" /* Mark */];
|
444
|
-
const ownerHasRun = ownerMark === void 0 ? !ownerScope.___client : ownerMark === 0;
|
445
|
-
scope[markAccessor] = ownerHasRun ? 1 : 2;
|
446
|
-
op = DIRTY;
|
447
|
-
}
|
448
|
-
if (--scope[markAccessor] === 0) {
|
449
|
-
if (op === DIRTY || scope[dirtyAccessor]) {
|
450
|
-
scope[dirtyAccessor] = false;
|
451
|
-
ownerScope ||= getOwnerScope(scope);
|
452
|
-
ownerValueAccessor2 ||= getOwnerValueAccessor(scope);
|
453
|
-
fn && fn(scope, ownerScope[ownerValueAccessor2]);
|
454
|
-
intersection2?.(scope, DIRTY);
|
455
|
-
} else {
|
456
|
-
intersection2?.(scope, CLEAN);
|
457
|
-
}
|
458
|
-
} else {
|
459
|
-
scope[dirtyAccessor] ||= op === DIRTY;
|
460
|
-
}
|
461
|
-
}
|
462
|
-
};
|
463
|
-
}
|
464
|
-
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
465
|
-
const getOwnerValueAccessor = typeof ownerValueAccessor === "function" ? ownerValueAccessor : () => ownerValueAccessor;
|
466
|
-
const signalFn = closure(
|
467
|
-
getOwnerValueAccessor,
|
468
|
-
fn,
|
469
|
-
getOwnerScope,
|
470
|
-
getIntersection
|
471
|
-
);
|
472
|
-
const subscribeFns = /* @__PURE__ */ new WeakMap();
|
473
|
-
signalFn.___subscribe = (scope) => {
|
474
|
-
const subscribeFn = (value2) => signalFn(scope, value2);
|
475
|
-
const ownerScope = getOwnerScope(scope);
|
476
|
-
const providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
477
|
-
subscribeFns.set(scope, subscribeFn);
|
478
|
-
(ownerScope[providerSubscriptionsAccessor] ||= /* @__PURE__ */ new Set()).add(subscribeFn);
|
479
|
-
};
|
480
|
-
signalFn.___unsubscribe = (scope) => {
|
481
|
-
const ownerScope = getOwnerScope(scope);
|
482
|
-
const providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
483
|
-
ownerScope[providerSubscriptionsAccessor]?.delete(subscribeFns.get(scope));
|
484
|
-
subscribeFns.delete(scope);
|
485
|
-
};
|
486
|
-
return signalFn;
|
487
|
-
}
|
488
|
-
function childClosures(closureSignals, childAccessor) {
|
489
|
-
const signal = (scope, op) => {
|
490
|
-
const childScope = scope[childAccessor];
|
491
|
-
for (const closureSignal of closureSignals) {
|
492
|
-
closureSignal(childScope, op);
|
493
|
-
}
|
494
|
-
};
|
495
|
-
signal.___subscribe = (scope) => {
|
496
|
-
const childScope = scope[childAccessor];
|
497
|
-
for (const closureSignal of closureSignals) {
|
498
|
-
closureSignal.___subscribe?.(childScope);
|
499
|
-
}
|
500
|
-
};
|
501
|
-
signal.___unsubscribe = (scope) => {
|
502
|
-
const childScope = scope[childAccessor];
|
503
|
-
for (const closureSignal of closureSignals) {
|
504
|
-
closureSignal.___unsubscribe?.(childScope);
|
505
|
-
}
|
506
|
-
};
|
507
|
-
return signal;
|
508
|
-
}
|
509
|
-
function dynamicSubscribers(valueAccessor) {
|
510
|
-
const subscribersAccessor = valueAccessor + "*" /* Subscribers */;
|
511
|
-
return (scope, op) => {
|
512
|
-
const subscribers = scope[subscribersAccessor];
|
513
|
-
if (subscribers) {
|
514
|
-
for (const subscriber of subscribers) {
|
515
|
-
subscriber(op);
|
516
|
-
}
|
517
|
-
}
|
518
|
-
};
|
519
|
-
}
|
520
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
521
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
522
|
-
}
|
523
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
524
|
-
function setTagVarChange(scope, changeHandler) {
|
525
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
526
|
-
}
|
527
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
528
|
-
var contentClosures = (content, childScope, op) => {
|
529
|
-
const signals = content?.___closureSignals;
|
530
|
-
if (signals) {
|
531
|
-
for (const signal of signals) {
|
532
|
-
signal(childScope, op);
|
533
|
-
}
|
534
|
-
}
|
535
|
-
};
|
536
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
537
|
-
function nextTagId({ $global }) {
|
538
|
-
const id = tagIdsByGlobal.get($global) || 0;
|
539
|
-
tagIdsByGlobal.set($global, id + 1);
|
540
|
-
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
541
|
-
}
|
542
|
-
function inChild(childAccessor, signal) {
|
543
|
-
return (scope, valueOrOp) => {
|
544
|
-
signal(scope[childAccessor], valueOrOp);
|
545
|
-
};
|
546
|
-
}
|
547
|
-
function intersections(signals) {
|
548
|
-
return (scope, op) => {
|
549
|
-
for (const signal of signals) {
|
550
|
-
signal(scope, op);
|
551
|
-
}
|
552
|
-
};
|
553
|
-
}
|
554
|
-
function effect(id, fn) {
|
555
|
-
register(id, fn);
|
556
|
-
return (scope) => {
|
557
|
-
queueEffect(scope, fn);
|
90
|
+
// src/dom/scope.ts
|
91
|
+
var pendingScopes = [];
|
92
|
+
var debugID = 0;
|
93
|
+
function createScope($global) {
|
94
|
+
const scope = {
|
95
|
+
___pending: 1,
|
96
|
+
$global
|
558
97
|
};
|
559
|
-
|
560
|
-
|
561
|
-
// src/dom/queue.ts
|
562
|
-
var pendingSignals = [];
|
563
|
-
var pendingEffects = [];
|
564
|
-
var rendering = false;
|
565
|
-
function queueSource(scope, signal, value2) {
|
566
|
-
schedule();
|
567
|
-
rendering = true;
|
568
|
-
signal(scope, MARK);
|
569
|
-
rendering = false;
|
570
|
-
pendingSignals.push(scope, signal, value2);
|
571
|
-
return value2;
|
572
|
-
}
|
573
|
-
function queueEffect(scope, fn) {
|
574
|
-
pendingEffects.push(scope, fn);
|
575
|
-
}
|
576
|
-
function run() {
|
577
|
-
const signals = pendingSignals;
|
578
|
-
const effects = pendingEffects;
|
579
|
-
try {
|
580
|
-
rendering = true;
|
581
|
-
pendingSignals = [];
|
582
|
-
runSignals(signals);
|
583
|
-
} finally {
|
584
|
-
rendering = false;
|
98
|
+
if (true) {
|
99
|
+
scope.___debugId = "client-" + debugID++;
|
585
100
|
}
|
586
|
-
|
587
|
-
|
101
|
+
pendingScopes.push(scope);
|
102
|
+
return scope;
|
588
103
|
}
|
589
|
-
function
|
590
|
-
const
|
591
|
-
|
592
|
-
const preparedEffects = pendingEffects = [];
|
593
|
-
const preparedSignals = pendingSignals = [];
|
594
|
-
try {
|
595
|
-
rendering = true;
|
596
|
-
fn();
|
597
|
-
pendingSignals = prevSignals;
|
598
|
-
runSignals(preparedSignals);
|
599
|
-
} finally {
|
600
|
-
rendering = false;
|
601
|
-
pendingSignals = prevSignals;
|
602
|
-
pendingEffects = prevEffects;
|
104
|
+
function finishPendingScopes() {
|
105
|
+
for (const scope of pendingScopes) {
|
106
|
+
scope.___pending = 0;
|
603
107
|
}
|
604
|
-
|
108
|
+
pendingScopes = [];
|
605
109
|
}
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
fn(scope, scope);
|
611
|
-
}
|
110
|
+
var emptyScope = createScope({});
|
111
|
+
function getEmptyScope(marker) {
|
112
|
+
emptyScope.___startNode = emptyScope.___endNode = marker;
|
113
|
+
return emptyScope;
|
612
114
|
}
|
613
|
-
function
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
const
|
618
|
-
|
115
|
+
function destroyBranch(branch) {
|
116
|
+
branch.___destroyed = 1;
|
117
|
+
branch.___branchScopes?.forEach(destroyBranch);
|
118
|
+
if (branch.___abortScopes) {
|
119
|
+
for (const scope of branch.___abortScopes) {
|
120
|
+
for (const id in scope.___abortControllers) {
|
121
|
+
scope.___abortControllers[id]?.abort();
|
122
|
+
}
|
123
|
+
}
|
619
124
|
}
|
620
125
|
}
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
const
|
625
|
-
|
626
|
-
const
|
627
|
-
|
628
|
-
|
629
|
-
controllers.delete(id);
|
630
|
-
}
|
126
|
+
function removeAndDestroyBranch(branch) {
|
127
|
+
destroyBranch(branch);
|
128
|
+
let current = branch.___startNode;
|
129
|
+
const stop = branch.___endNode.nextSibling;
|
130
|
+
while (current !== stop) {
|
131
|
+
const next = current.nextSibling;
|
132
|
+
current.remove();
|
133
|
+
current = next;
|
631
134
|
}
|
632
135
|
}
|
633
|
-
function
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
136
|
+
function insertBefore(scope, parent, nextSibling) {
|
137
|
+
let current = scope.___startNode;
|
138
|
+
const stop = scope.___endNode.nextSibling;
|
139
|
+
while (current !== stop) {
|
140
|
+
const next = current.nextSibling;
|
141
|
+
parent.insertBefore(current, nextSibling);
|
142
|
+
current = next;
|
639
143
|
}
|
640
|
-
return controller.signal;
|
641
144
|
}
|
642
145
|
|
643
|
-
// src/common/compat-meta.ts
|
644
|
-
var prefix = true ? "$compat_" : "$C_";
|
645
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
646
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
647
|
-
|
648
146
|
// src/common/helpers.ts
|
649
147
|
function classValue(value2) {
|
650
148
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -702,57 +200,57 @@ function normalizeDynamicRenderer(value2) {
|
|
702
200
|
|
703
201
|
// src/dom/reconcile.ts
|
704
202
|
var WRONG_POS = 2147483647;
|
705
|
-
function reconcile(parent,
|
203
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
706
204
|
let oldStart = 0;
|
707
205
|
let newStart = 0;
|
708
|
-
let oldEnd =
|
709
|
-
let newEnd =
|
710
|
-
let
|
711
|
-
let
|
712
|
-
let
|
713
|
-
let
|
206
|
+
let oldEnd = oldBranches.length - 1;
|
207
|
+
let newEnd = newBranches.length - 1;
|
208
|
+
let oldStartBranch = oldBranches[oldStart];
|
209
|
+
let newStartBranch = newBranches[newStart];
|
210
|
+
let oldEndBranch = oldBranches[oldEnd];
|
211
|
+
let newEndBranch = newBranches[newEnd];
|
714
212
|
let i;
|
715
213
|
let j;
|
716
214
|
let k;
|
717
215
|
let nextSibling;
|
718
|
-
let
|
719
|
-
let
|
216
|
+
let oldBranch;
|
217
|
+
let newBranch;
|
720
218
|
outer: {
|
721
|
-
while (
|
219
|
+
while (oldStartBranch === newStartBranch) {
|
722
220
|
++oldStart;
|
723
221
|
++newStart;
|
724
222
|
if (oldStart > oldEnd || newStart > newEnd) {
|
725
223
|
break outer;
|
726
224
|
}
|
727
|
-
|
728
|
-
|
225
|
+
oldStartBranch = oldBranches[oldStart];
|
226
|
+
newStartBranch = newBranches[newStart];
|
729
227
|
}
|
730
|
-
while (
|
228
|
+
while (oldEndBranch === newEndBranch) {
|
731
229
|
--oldEnd;
|
732
230
|
--newEnd;
|
733
231
|
if (oldStart > oldEnd || newStart > newEnd) {
|
734
232
|
break outer;
|
735
233
|
}
|
736
|
-
|
737
|
-
|
234
|
+
oldEndBranch = oldBranches[oldEnd];
|
235
|
+
newEndBranch = newBranches[newEnd];
|
738
236
|
}
|
739
237
|
}
|
740
238
|
if (oldStart > oldEnd) {
|
741
239
|
if (newStart <= newEnd) {
|
742
240
|
k = newEnd + 1;
|
743
|
-
nextSibling = k <
|
241
|
+
nextSibling = k < newBranches.length ? newBranches[k].___startNode : afterReference;
|
744
242
|
do {
|
745
|
-
insertBefore(
|
243
|
+
insertBefore(newBranches[newStart++], parent, nextSibling);
|
746
244
|
} while (newStart <= newEnd);
|
747
245
|
}
|
748
246
|
} else if (newStart > newEnd) {
|
749
247
|
do {
|
750
|
-
|
248
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
751
249
|
} while (oldStart <= oldEnd);
|
752
250
|
} else {
|
753
251
|
const oldLength = oldEnd - oldStart + 1;
|
754
252
|
const newLength = newEnd - newStart + 1;
|
755
|
-
const aNullable =
|
253
|
+
const aNullable = oldBranches;
|
756
254
|
const sources = new Array(newLength);
|
757
255
|
for (i = 0; i < newLength; ++i) {
|
758
256
|
sources[i] = -1;
|
@@ -761,64 +259,64 @@ function reconcile(parent, oldScopes, newScopes, afterReference) {
|
|
761
259
|
let synced = 0;
|
762
260
|
const keyIndex = /* @__PURE__ */ new Map();
|
763
261
|
for (j = newStart; j <= newEnd; ++j) {
|
764
|
-
keyIndex.set(
|
262
|
+
keyIndex.set(newBranches[j], j);
|
765
263
|
}
|
766
264
|
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
767
|
-
|
768
|
-
j = keyIndex.get(
|
265
|
+
oldBranch = oldBranches[i];
|
266
|
+
j = keyIndex.get(oldBranch);
|
769
267
|
if (j !== void 0) {
|
770
268
|
pos = pos > j ? WRONG_POS : j;
|
771
269
|
++synced;
|
772
|
-
|
270
|
+
newBranch = newBranches[j];
|
773
271
|
sources[j - newStart] = i;
|
774
272
|
aNullable[i] = null;
|
775
273
|
}
|
776
274
|
}
|
777
|
-
if (oldLength ===
|
275
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
778
276
|
for (; newStart < newLength; ++newStart) {
|
779
|
-
insertBefore(
|
277
|
+
insertBefore(newBranches[newStart], parent, afterReference);
|
780
278
|
}
|
781
279
|
for (; oldStart < oldLength; ++oldStart) {
|
782
|
-
|
280
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
783
281
|
}
|
784
282
|
} else {
|
785
283
|
i = oldLength - synced;
|
786
284
|
while (i > 0) {
|
787
|
-
|
788
|
-
if (
|
789
|
-
|
285
|
+
oldBranch = aNullable[oldStart++];
|
286
|
+
if (oldBranch !== null) {
|
287
|
+
removeAndDestroyBranch(oldBranch);
|
790
288
|
i--;
|
791
289
|
}
|
792
290
|
}
|
793
291
|
if (pos === WRONG_POS) {
|
794
292
|
const seq = longestIncreasingSubsequence(sources);
|
795
293
|
j = seq.length - 1;
|
796
|
-
k =
|
294
|
+
k = newBranches.length;
|
797
295
|
for (i = newLength - 1; i >= 0; --i) {
|
798
296
|
if (sources[i] === -1) {
|
799
297
|
pos = i + newStart;
|
800
|
-
|
801
|
-
nextSibling = pos < k ?
|
802
|
-
insertBefore(
|
298
|
+
newBranch = newBranches[pos++];
|
299
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
300
|
+
insertBefore(newBranch, parent, nextSibling);
|
803
301
|
} else {
|
804
302
|
if (j < 0 || i !== seq[j]) {
|
805
303
|
pos = i + newStart;
|
806
|
-
|
807
|
-
nextSibling = pos < k ?
|
808
|
-
insertBefore(
|
304
|
+
newBranch = newBranches[pos++];
|
305
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
306
|
+
insertBefore(newBranch, parent, nextSibling);
|
809
307
|
} else {
|
810
308
|
--j;
|
811
309
|
}
|
812
310
|
}
|
813
311
|
}
|
814
312
|
} else if (synced !== newLength) {
|
815
|
-
k =
|
313
|
+
k = newBranches.length;
|
816
314
|
for (i = newLength - 1; i >= 0; --i) {
|
817
315
|
if (sources[i] === -1) {
|
818
316
|
pos = i + newStart;
|
819
|
-
|
820
|
-
nextSibling = pos < k ?
|
821
|
-
insertBefore(
|
317
|
+
newBranch = newBranches[pos++];
|
318
|
+
nextSibling = pos < k ? newBranches[pos].___startNode : afterReference;
|
319
|
+
insertBefore(newBranch, parent, nextSibling);
|
822
320
|
}
|
823
321
|
}
|
824
322
|
}
|
@@ -925,13 +423,229 @@ function resolveCursorPosition(updatedValue, initialValue, initialPosition, inpu
|
|
925
423
|
if (stripSpacesAndPunctuation(updatedValue[pos])) relevantIndex++;
|
926
424
|
pos++;
|
927
425
|
}
|
928
|
-
return pos;
|
426
|
+
return pos;
|
427
|
+
}
|
428
|
+
}
|
429
|
+
return -1;
|
430
|
+
}
|
431
|
+
function stripSpacesAndPunctuation(str) {
|
432
|
+
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
433
|
+
}
|
434
|
+
|
435
|
+
// src/common/meta.ts
|
436
|
+
var DEFAULT_RUNTIME_ID = "M";
|
437
|
+
var DEFAULT_RENDER_ID = "_";
|
438
|
+
|
439
|
+
// src/dom/resume.ts
|
440
|
+
var registeredValues = {};
|
441
|
+
var Render = class {
|
442
|
+
___scopeStack = [];
|
443
|
+
___scopeLookup = {};
|
444
|
+
___serializeContext = {
|
445
|
+
_: registeredValues
|
446
|
+
};
|
447
|
+
constructor(renders, runtimeId, renderId) {
|
448
|
+
this.___renders = renders;
|
449
|
+
this.___runtimeId = runtimeId;
|
450
|
+
this.___renderId = renderId;
|
451
|
+
this.___data = renders[renderId];
|
452
|
+
this.___resume();
|
453
|
+
}
|
454
|
+
w() {
|
455
|
+
this.___data.w();
|
456
|
+
this.___resume();
|
457
|
+
}
|
458
|
+
___resume() {
|
459
|
+
const data2 = this.___data;
|
460
|
+
const serializeContext = this.___serializeContext;
|
461
|
+
const scopeLookup = this.___scopeLookup;
|
462
|
+
const visits = data2.v;
|
463
|
+
const branchIds = /* @__PURE__ */ new Set();
|
464
|
+
const parentBranchIds = /* @__PURE__ */ new Map();
|
465
|
+
if (visits.length) {
|
466
|
+
const commentPrefix = data2.i;
|
467
|
+
const commentPrefixLen = commentPrefix.length;
|
468
|
+
const closestBranchMarkers = /* @__PURE__ */ new Map();
|
469
|
+
data2.v = [];
|
470
|
+
const branchEnd = (branchId, visit, curNode) => {
|
471
|
+
const branch = scopeLookup[branchId] ||= {};
|
472
|
+
let endNode = curNode;
|
473
|
+
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
474
|
+
branch.___endNode = endNode;
|
475
|
+
branch.___startNode ||= endNode;
|
476
|
+
for (const [markerScopeId, markerNode] of closestBranchMarkers) {
|
477
|
+
if (branch.___startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
478
|
+
parentBranchIds.set(markerScopeId, branchId);
|
479
|
+
closestBranchMarkers.delete(markerScopeId);
|
480
|
+
}
|
481
|
+
}
|
482
|
+
branchIds.add(branchId);
|
483
|
+
closestBranchMarkers.set(branchId, visit);
|
484
|
+
return branch;
|
485
|
+
};
|
486
|
+
for (const visit of visits) {
|
487
|
+
const commentText = visit.data;
|
488
|
+
const dataIndex = commentText.indexOf(" ") + 1;
|
489
|
+
const scopeId = commentText.slice(
|
490
|
+
commentPrefixLen + 1,
|
491
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
492
|
+
);
|
493
|
+
const scope = scopeLookup[scopeId] ||= {};
|
494
|
+
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
495
|
+
const token = commentText[commentPrefixLen];
|
496
|
+
if (token === "*" /* Node */) {
|
497
|
+
scope[data3] = visit.previousSibling;
|
498
|
+
} else if (token === "$" /* ClosestBranch */) {
|
499
|
+
closestBranchMarkers.set(scopeId, visit);
|
500
|
+
} else if (token === "[" /* BranchStart */) {
|
501
|
+
if (this.___currentScopeId) {
|
502
|
+
if (dataIndex) {
|
503
|
+
branchEnd(this.___currentScopeId, visit, visit);
|
504
|
+
}
|
505
|
+
this.___scopeStack.push(this.___currentScopeId);
|
506
|
+
}
|
507
|
+
this.___currentScopeId = scopeId;
|
508
|
+
scope.___startNode = visit;
|
509
|
+
} else if (token === "]" /* BranchEnd */) {
|
510
|
+
scope[data3] = visit;
|
511
|
+
const curParent = visit.parentNode;
|
512
|
+
const startNode = branchEnd(
|
513
|
+
this.___currentScopeId,
|
514
|
+
visit,
|
515
|
+
visit
|
516
|
+
).___startNode;
|
517
|
+
if (curParent !== startNode.parentNode) {
|
518
|
+
curParent.prepend(startNode);
|
519
|
+
}
|
520
|
+
this.___currentScopeId = this.___scopeStack.pop();
|
521
|
+
} else if (token === "|" /* BranchSingleNode */) {
|
522
|
+
let next = data3.indexOf(" ");
|
523
|
+
let curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
524
|
+
while (~next) {
|
525
|
+
const start = next + 1;
|
526
|
+
next = data3.indexOf(" ", start);
|
527
|
+
const childScopeId = data3.slice(start, ~next ? next : data3.length);
|
528
|
+
curNode = branchEnd(childScopeId, visit, curNode).___endNode;
|
529
|
+
}
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
const resumes = data2.r;
|
534
|
+
if (resumes) {
|
535
|
+
data2.r = [];
|
536
|
+
const len = resumes.length;
|
537
|
+
let i = 0;
|
538
|
+
try {
|
539
|
+
isResuming = true;
|
540
|
+
while (i < len) {
|
541
|
+
const resumeData = resumes[i++];
|
542
|
+
if (typeof resumeData === "function") {
|
543
|
+
const scopes = resumeData(serializeContext);
|
544
|
+
let { $global } = scopeLookup;
|
545
|
+
if (!$global) {
|
546
|
+
scopeLookup.$global = $global = scopes.$ || {};
|
547
|
+
$global.runtimeId = this.___runtimeId;
|
548
|
+
$global.renderId = this.___renderId;
|
549
|
+
}
|
550
|
+
for (const scopeId in scopes) {
|
551
|
+
if (scopeId !== "$") {
|
552
|
+
const scope = scopes[scopeId];
|
553
|
+
const prevScope = scopeLookup[scopeId];
|
554
|
+
scope.$global = $global;
|
555
|
+
if (prevScope !== scope) {
|
556
|
+
scopeLookup[scopeId] = Object.assign(
|
557
|
+
scope,
|
558
|
+
prevScope
|
559
|
+
);
|
560
|
+
}
|
561
|
+
const parentBranchId = parentBranchIds.get(scopeId);
|
562
|
+
if (parentBranchId) {
|
563
|
+
scope.___closestBranch = scopes[parentBranchId];
|
564
|
+
}
|
565
|
+
if (branchIds.has(scopeId)) {
|
566
|
+
const branch = scope;
|
567
|
+
const parentBranch = branch.___closestBranch;
|
568
|
+
scope.___closestBranch = branch;
|
569
|
+
if (parentBranch) {
|
570
|
+
branch.___parentBranch = parentBranch;
|
571
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
572
|
+
}
|
573
|
+
}
|
574
|
+
if (true) {
|
575
|
+
scope.___debugId = "server-" + scopeId;
|
576
|
+
}
|
577
|
+
}
|
578
|
+
}
|
579
|
+
} else if (i === len || typeof resumes[i] !== "string") {
|
580
|
+
delete this.___renders[this.___renderId];
|
581
|
+
} else {
|
582
|
+
registeredValues[resumes[i++]](
|
583
|
+
scopeLookup[resumeData],
|
584
|
+
scopeLookup[resumeData]
|
585
|
+
);
|
586
|
+
}
|
587
|
+
}
|
588
|
+
} finally {
|
589
|
+
isResuming = false;
|
590
|
+
}
|
591
|
+
}
|
592
|
+
}
|
593
|
+
};
|
594
|
+
var isResuming = false;
|
595
|
+
function register(id, obj) {
|
596
|
+
registeredValues[id] = obj;
|
597
|
+
return obj;
|
598
|
+
}
|
599
|
+
function registerBoundSignal(id, signal) {
|
600
|
+
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
601
|
+
return signal;
|
602
|
+
}
|
603
|
+
function getRegisteredWithScope(id, scope) {
|
604
|
+
const val = registeredValues[id];
|
605
|
+
return scope ? val(scope) : val;
|
606
|
+
}
|
607
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
608
|
+
if (true) {
|
609
|
+
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
610
|
+
throw new Error(
|
611
|
+
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
612
|
+
);
|
613
|
+
}
|
614
|
+
}
|
615
|
+
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
616
|
+
let renders;
|
617
|
+
if (window[runtimeId]) {
|
618
|
+
setRenders(window[runtimeId]);
|
619
|
+
} else {
|
620
|
+
Object.defineProperty(window, runtimeId, {
|
621
|
+
configurable: true,
|
622
|
+
set: setRenders
|
623
|
+
});
|
624
|
+
}
|
625
|
+
function setRenders(v) {
|
626
|
+
if (true) {
|
627
|
+
if (renders) {
|
628
|
+
throw new Error(
|
629
|
+
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
630
|
+
);
|
631
|
+
}
|
632
|
+
}
|
633
|
+
renders = v;
|
634
|
+
for (const renderId in v) {
|
635
|
+
resumeRender(renderId);
|
929
636
|
}
|
637
|
+
Object.defineProperty(window, runtimeId, {
|
638
|
+
configurable: true,
|
639
|
+
value: resumeRender
|
640
|
+
});
|
930
641
|
}
|
931
|
-
return -1;
|
932
642
|
}
|
933
|
-
function
|
934
|
-
|
643
|
+
function registerSubscriber(id, signal) {
|
644
|
+
register(id, signal.___subscribe);
|
645
|
+
return signal;
|
646
|
+
}
|
647
|
+
function nodeRef(id, key) {
|
648
|
+
return register(id, (scope) => () => scope[key]);
|
935
649
|
}
|
936
650
|
|
937
651
|
// src/dom/controllable.ts
|
@@ -1033,10 +747,13 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
1033
747
|
} else {
|
1034
748
|
scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */;
|
1035
749
|
}
|
1036
|
-
|
1037
|
-
scope
|
1038
|
-
|
1039
|
-
|
750
|
+
pendingEffects.unshift(
|
751
|
+
scope,
|
752
|
+
() => setSelectOptions(
|
753
|
+
scope[nodeAccessor],
|
754
|
+
value2,
|
755
|
+
valueChange
|
756
|
+
)
|
1040
757
|
);
|
1041
758
|
}
|
1042
759
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
@@ -1249,7 +966,8 @@ function textContent(node, value2) {
|
|
1249
966
|
}
|
1250
967
|
function attrs(scope, nodeAccessor, nextAttrs) {
|
1251
968
|
const el = scope[nodeAccessor];
|
1252
|
-
for (
|
969
|
+
for (let i = el.attributes.length; i--; ) {
|
970
|
+
const { name } = el.attributes.item(i);
|
1253
971
|
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) {
|
1254
972
|
el.removeAttribute(name);
|
1255
973
|
}
|
@@ -1262,7 +980,8 @@ function hasAttrAlias(element, attr2, nextAttrs) {
|
|
1262
980
|
function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
|
1263
981
|
const el = scope[nodeAccessor];
|
1264
982
|
const partial = {};
|
1265
|
-
for (
|
983
|
+
for (let i = el.attributes.length; i--; ) {
|
984
|
+
const { name } = el.attributes.item(i);
|
1266
985
|
if (!skip[name] && !(nextAttrs && name in nextAttrs)) {
|
1267
986
|
el.removeAttribute(name);
|
1268
987
|
}
|
@@ -1449,17 +1168,14 @@ function trimWalkString(walkString) {
|
|
1449
1168
|
}
|
1450
1169
|
function walk(startNode, walkCodes, scope) {
|
1451
1170
|
walker.currentNode = startNode;
|
1452
|
-
walkInternal(walkCodes, scope,
|
1453
|
-
walker.currentNode = document
|
1171
|
+
walkInternal(walkCodes, scope, 0);
|
1172
|
+
walker.currentNode = document;
|
1454
1173
|
}
|
1455
|
-
function walkInternal(walkCodes, scope,
|
1174
|
+
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
1456
1175
|
let value2;
|
1457
1176
|
let storedMultiplier = 0;
|
1458
1177
|
let currentMultiplier = 0;
|
1459
1178
|
let currentScopeIndex = 0;
|
1460
|
-
if (cleanupOwnerScope !== scope) {
|
1461
|
-
scope.___cleanupOwner = cleanupOwnerScope;
|
1462
|
-
}
|
1463
1179
|
while (value2 = walkCodes.charCodeAt(currentWalkIndex++)) {
|
1464
1180
|
currentMultiplier = storedMultiplier;
|
1465
1181
|
storedMultiplier = 0;
|
@@ -1482,12 +1198,10 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
1482
1198
|
walker.nextNode();
|
1483
1199
|
}
|
1484
1200
|
} else if (value2 === 47 /* BeginChild */) {
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
currentWalkIndex
|
1490
|
-
);
|
1201
|
+
const childScope = scope[true ? getDebugKey(currentScopeIndex++, "#childScope") : currentScopeIndex++] = createScope(scope.$global);
|
1202
|
+
childScope.___startNode = walker.currentNode;
|
1203
|
+
childScope.___closestBranch = scope.___closestBranch;
|
1204
|
+
currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
1491
1205
|
} else if (value2 === 38 /* EndChild */) {
|
1492
1206
|
return currentWalkIndex;
|
1493
1207
|
} else if (value2 === 32 /* Get */) {
|
@@ -1519,26 +1233,40 @@ function getDebugKey(index, node) {
|
|
1519
1233
|
}
|
1520
1234
|
|
1521
1235
|
// src/dom/renderer.ts
|
1522
|
-
function
|
1523
|
-
const
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
}
|
1236
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
1237
|
+
const branch = createBranch(
|
1238
|
+
$global,
|
1239
|
+
renderer.___owner || parentScope,
|
1240
|
+
parentScope
|
1241
|
+
);
|
1242
|
+
if (true) {
|
1243
|
+
branch.___renderer = renderer;
|
1531
1244
|
}
|
1532
|
-
|
1245
|
+
initRenderer(renderer, branch);
|
1246
|
+
return branch;
|
1533
1247
|
}
|
1534
|
-
function
|
1248
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
1535
1249
|
if (typeof tagNameOrRenderer !== "string") {
|
1536
|
-
return
|
1250
|
+
return createBranchScopeWithRenderer(
|
1251
|
+
tagNameOrRenderer,
|
1252
|
+
$global,
|
1253
|
+
parentScope
|
1254
|
+
);
|
1255
|
+
}
|
1256
|
+
const branch = createBranch($global, parentScope, parentScope);
|
1257
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElement(tagNameOrRenderer);
|
1258
|
+
return branch;
|
1259
|
+
}
|
1260
|
+
function createBranch($global, ownerScope, parentScope) {
|
1261
|
+
const branch = createScope($global);
|
1262
|
+
const parentBranch = parentScope.___closestBranch;
|
1263
|
+
branch._ = ownerScope;
|
1264
|
+
branch.___closestBranch = branch;
|
1265
|
+
if (parentBranch) {
|
1266
|
+
branch.___parentBranch = parentBranch;
|
1267
|
+
(parentBranch.___branchScopes ||= /* @__PURE__ */ new Set()).add(branch);
|
1537
1268
|
}
|
1538
|
-
|
1539
|
-
newScope._ = newScope.___cleanupOwner = ownerScope;
|
1540
|
-
newScope[true ? `#${tagNameOrRenderer}/0` : 0] = newScope.___startNode = newScope.___endNode = document.createElement(tagNameOrRenderer);
|
1541
|
-
return newScope;
|
1269
|
+
return branch;
|
1542
1270
|
}
|
1543
1271
|
function initRenderer(renderer, scope) {
|
1544
1272
|
const dom = renderer.___clone();
|
@@ -1550,7 +1278,7 @@ function initRenderer(renderer, scope) {
|
|
1550
1278
|
scope.___startNode = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom;
|
1551
1279
|
scope.___endNode = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom;
|
1552
1280
|
if (renderer.___setup) {
|
1553
|
-
renderer.___setup
|
1281
|
+
queueRender(scope, renderer.___setup);
|
1554
1282
|
}
|
1555
1283
|
return dom;
|
1556
1284
|
}
|
@@ -1588,9 +1316,8 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
1588
1316
|
}
|
1589
1317
|
};
|
1590
1318
|
}
|
1591
|
-
function createRendererWithOwner(template, rawWalks, setup,
|
1319
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
1592
1320
|
let args;
|
1593
|
-
let closureSignals;
|
1594
1321
|
const id = true ? Symbol("Marko Renderer") : {};
|
1595
1322
|
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1596
1323
|
return (owner) => {
|
@@ -1604,21 +1331,12 @@ function createRendererWithOwner(template, rawWalks, setup, getClosureSignals, g
|
|
1604
1331
|
___sourceNode: void 0,
|
1605
1332
|
get ___args() {
|
1606
1333
|
return args ||= getArgs?.();
|
1607
|
-
},
|
1608
|
-
get ___closureSignals() {
|
1609
|
-
return closureSignals ||= new Set(getClosureSignals?.());
|
1610
1334
|
}
|
1611
1335
|
};
|
1612
1336
|
};
|
1613
1337
|
}
|
1614
|
-
function createRenderer(template, walks, setup,
|
1615
|
-
return createRendererWithOwner(
|
1616
|
-
template,
|
1617
|
-
walks,
|
1618
|
-
setup,
|
1619
|
-
getClosureSignals,
|
1620
|
-
getArgs
|
1621
|
-
)();
|
1338
|
+
function createRenderer(template, walks, setup, getArgs) {
|
1339
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1622
1340
|
}
|
1623
1341
|
function _clone() {
|
1624
1342
|
return (this.___sourceNode ||= parseHTMLOrSingleNode(
|
@@ -1633,16 +1351,14 @@ function patchConditionals(fn) {
|
|
1633
1351
|
}
|
1634
1352
|
var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
1635
1353
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1636
|
-
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1637
1354
|
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1638
1355
|
return (scope, newRendererOrOp) => {
|
1639
1356
|
if (newRendererOrOp === DIRTY) return;
|
1640
|
-
|
1357
|
+
const currentRenderer = scope[rendererAccessor];
|
1641
1358
|
let op = newRendererOrOp;
|
1642
1359
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1643
1360
|
const normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1644
1361
|
if (isDifferentRenderer(normalizedRenderer, currentRenderer)) {
|
1645
|
-
currentRenderer = scope[rendererAccessor] = normalizedRenderer;
|
1646
1362
|
setConditionalRenderer(scope, nodeAccessor, normalizedRenderer);
|
1647
1363
|
fn && fn(scope);
|
1648
1364
|
op = DIRTY;
|
@@ -1651,46 +1367,22 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1651
1367
|
}
|
1652
1368
|
}
|
1653
1369
|
intersection2?.(scope, op);
|
1654
|
-
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1655
1370
|
};
|
1656
1371
|
};
|
1657
|
-
function inConditionalScope(signal, nodeAccessor) {
|
1658
|
-
const scopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1659
|
-
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1660
|
-
return (scope, op) => {
|
1661
|
-
const conditionalScope = scope[scopeAccessor];
|
1662
|
-
if (conditionalScope) {
|
1663
|
-
const conditionalRenderer = scope[rendererAccessor];
|
1664
|
-
if (!conditionalRenderer?.___closureSignals || conditionalRenderer.___closureSignals.has(signal)) {
|
1665
|
-
signal(conditionalScope, op);
|
1666
|
-
}
|
1667
|
-
}
|
1668
|
-
};
|
1669
|
-
}
|
1670
1372
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
1671
|
-
|
1672
|
-
|
1673
|
-
if (newRenderer) {
|
1674
|
-
newScope = scope[nodeAccessor + "!" /* ConditionalScope */] = createScopeWithTagNameOrRenderer(
|
1675
|
-
newRenderer,
|
1676
|
-
scope.$global,
|
1677
|
-
scope
|
1678
|
-
);
|
1679
|
-
prevScope = prevScope || getEmptyScope(scope[nodeAccessor]);
|
1680
|
-
} else {
|
1681
|
-
newScope = getEmptyScope(scope[nodeAccessor]);
|
1682
|
-
scope[nodeAccessor + "!" /* ConditionalScope */] = void 0;
|
1683
|
-
}
|
1373
|
+
const newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
1374
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
|
1684
1375
|
insertBefore(
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1376
|
+
newBranch || getEmptyScope(scope[nodeAccessor]),
|
1377
|
+
prevBranch.___startNode.parentNode,
|
1378
|
+
prevBranch.___startNode
|
1688
1379
|
);
|
1689
|
-
|
1380
|
+
removeAndDestroyBranch(prevBranch);
|
1381
|
+
scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer;
|
1382
|
+
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1690
1383
|
}
|
1691
1384
|
var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersection) {
|
1692
1385
|
const rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1693
|
-
const childScopeAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1694
1386
|
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1695
1387
|
return (scope, newRendererOrOp) => {
|
1696
1388
|
if (newRendererOrOp === DIRTY) return;
|
@@ -1712,20 +1404,22 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1712
1404
|
}
|
1713
1405
|
}
|
1714
1406
|
intersection2?.(scope, op);
|
1715
|
-
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1716
1407
|
};
|
1717
1408
|
};
|
1718
1409
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1719
|
-
const
|
1410
|
+
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
1720
1411
|
const referenceNode = scope[nodeAccessor];
|
1412
|
+
const newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
1721
1413
|
referenceNode.textContent = "";
|
1722
|
-
if (
|
1723
|
-
|
1724
|
-
insertBefore(newScope, referenceNode, null);
|
1414
|
+
if (newBranch) {
|
1415
|
+
insertBefore(newBranch, referenceNode, null);
|
1725
1416
|
}
|
1726
|
-
|
1417
|
+
prevBranch && destroyBranch(prevBranch);
|
1418
|
+
scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1727
1419
|
}
|
1728
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1420
|
+
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
1421
|
+
[Symbol(), getEmptyScope(void 0)]
|
1422
|
+
]);
|
1729
1423
|
var emptyMarkerArray = [
|
1730
1424
|
/* @__PURE__ */ getEmptyScope(void 0)
|
1731
1425
|
];
|
@@ -1763,18 +1457,14 @@ function loopTo(nodeAccessor, renderer) {
|
|
1763
1457
|
}
|
1764
1458
|
function loop(nodeAccessor, renderer, forEach) {
|
1765
1459
|
const loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */;
|
1766
|
-
const closureSignals = renderer.___closureSignals;
|
1767
1460
|
const params = renderer.___args;
|
1768
1461
|
return (scope, valueOrOp) => {
|
1769
1462
|
if (valueOrOp === DIRTY) return;
|
1770
1463
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1771
|
-
const
|
1772
|
-
if (
|
1773
|
-
for (const
|
1774
|
-
params?.(
|
1775
|
-
for (const signal of closureSignals) {
|
1776
|
-
signal(childScope, valueOrOp);
|
1777
|
-
}
|
1464
|
+
const loopBranches = scope[loopScopeAccessor] ?? scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1465
|
+
if (loopBranches !== emptyMarkerArray) {
|
1466
|
+
for (const branch of loopBranches) {
|
1467
|
+
params?.(branch, valueOrOp);
|
1778
1468
|
}
|
1779
1469
|
}
|
1780
1470
|
return;
|
@@ -1789,27 +1479,20 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1789
1479
|
let parentNode;
|
1790
1480
|
let needsReconciliation = true;
|
1791
1481
|
forEach(valueOrOp, (key, args) => {
|
1792
|
-
let
|
1793
|
-
|
1794
|
-
|
1795
|
-
childScope = createScopeWithRenderer(renderer, scope.$global, scope);
|
1796
|
-
closureOp = DIRTY;
|
1482
|
+
let branch = oldMap.get(key);
|
1483
|
+
if (!branch) {
|
1484
|
+
branch = createBranchScopeWithRenderer(renderer, scope.$global, scope);
|
1797
1485
|
} else {
|
1798
1486
|
}
|
1799
1487
|
if (params) {
|
1800
|
-
params(
|
1801
|
-
}
|
1802
|
-
if (closureSignals) {
|
1803
|
-
for (const signal of closureSignals) {
|
1804
|
-
signal(childScope, closureOp);
|
1805
|
-
}
|
1488
|
+
params(branch, args);
|
1806
1489
|
}
|
1807
1490
|
if (newMap) {
|
1808
|
-
newMap.set(key,
|
1809
|
-
newArray.push(
|
1491
|
+
newMap.set(key, branch);
|
1492
|
+
newArray.push(branch);
|
1810
1493
|
} else {
|
1811
|
-
newMap = /* @__PURE__ */ new Map([[key,
|
1812
|
-
newArray = [
|
1494
|
+
newMap = /* @__PURE__ */ new Map([[key, branch]]);
|
1495
|
+
newArray = [branch];
|
1813
1496
|
}
|
1814
1497
|
});
|
1815
1498
|
if (!newMap) {
|
@@ -1818,7 +1501,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1818
1501
|
newArray = emptyMarkerArray;
|
1819
1502
|
getEmptyScope(referenceNode);
|
1820
1503
|
} else {
|
1821
|
-
oldArray.forEach(
|
1504
|
+
oldArray.forEach(destroyBranch);
|
1822
1505
|
referenceNode.textContent = "";
|
1823
1506
|
newMap = emptyMap;
|
1824
1507
|
newArray = emptyArray;
|
@@ -1843,17 +1526,6 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1843
1526
|
scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
1844
1527
|
};
|
1845
1528
|
}
|
1846
|
-
function inLoopScope(signal, loopNodeAccessor) {
|
1847
|
-
const loopScopeAccessor = loopNodeAccessor + "!" /* LoopScopeArray */;
|
1848
|
-
return (scope, op) => {
|
1849
|
-
const loopScopes = scope[loopScopeAccessor] ?? scope[loopNodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1850
|
-
if (loopScopes !== emptyMarkerArray) {
|
1851
|
-
for (const scope2 of loopScopes) {
|
1852
|
-
signal(scope2, op);
|
1853
|
-
}
|
1854
|
-
}
|
1855
|
-
};
|
1856
|
-
}
|
1857
1529
|
function bySecondArg(_item, index) {
|
1858
1530
|
return index;
|
1859
1531
|
}
|
@@ -1864,6 +1536,298 @@ function isDifferentRenderer(a, b) {
|
|
1864
1536
|
return a !== b && (a?.___id || 0) !== b?.___id;
|
1865
1537
|
}
|
1866
1538
|
|
1539
|
+
// src/dom/signals.ts
|
1540
|
+
var MARK = true ? Symbol("mark") : {};
|
1541
|
+
var CLEAN = true ? Symbol("clean") : {};
|
1542
|
+
var DIRTY = true ? Symbol("dirty") : {};
|
1543
|
+
function state(valueAccessor, fn, getIntersection) {
|
1544
|
+
const valueSignal = value(valueAccessor, fn, getIntersection);
|
1545
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1546
|
+
const valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1547
|
+
return (scope, valueOrOp, valueChange) => {
|
1548
|
+
if (rendering) {
|
1549
|
+
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
1550
|
+
valueSignal(
|
1551
|
+
scope,
|
1552
|
+
valueIsOp || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1553
|
+
);
|
1554
|
+
} else if (scope[valueChangeAccessor]) {
|
1555
|
+
scope[valueChangeAccessor](valueOrOp);
|
1556
|
+
} else {
|
1557
|
+
queueSource(scope, valueSignal, valueOrOp);
|
1558
|
+
}
|
1559
|
+
return valueOrOp;
|
1560
|
+
};
|
1561
|
+
}
|
1562
|
+
function value(valueAccessor, fn, getIntersection) {
|
1563
|
+
const markAccessor = valueAccessor + "#" /* Mark */;
|
1564
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1565
|
+
return (scope, valueOrOp) => {
|
1566
|
+
if (valueOrOp === MARK) {
|
1567
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1568
|
+
intersection2?.(scope, MARK);
|
1569
|
+
}
|
1570
|
+
} else if (valueOrOp !== DIRTY) {
|
1571
|
+
const existing = scope[markAccessor] !== void 0;
|
1572
|
+
if ((scope[markAccessor] ||= 1) === 1) {
|
1573
|
+
if (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp) {
|
1574
|
+
intersection2?.(scope, CLEAN);
|
1575
|
+
} else {
|
1576
|
+
scope[valueAccessor] = valueOrOp;
|
1577
|
+
fn && fn(scope, valueOrOp);
|
1578
|
+
intersection2?.(scope, DIRTY);
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
scope[markAccessor]--;
|
1582
|
+
}
|
1583
|
+
};
|
1584
|
+
}
|
1585
|
+
var accessorId = 0;
|
1586
|
+
function intersection(count, fn, getIntersection) {
|
1587
|
+
const dirtyAccessor = "?" /* Dynamic */ + accessorId++;
|
1588
|
+
const markAccessor = dirtyAccessor + "#" /* Mark */;
|
1589
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1590
|
+
return (scope, op) => {
|
1591
|
+
if (op === MARK) {
|
1592
|
+
if ((scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1) {
|
1593
|
+
intersection2?.(scope, MARK);
|
1594
|
+
}
|
1595
|
+
} else if (scope[markAccessor] === void 0) {
|
1596
|
+
scope[markAccessor] = count - 1;
|
1597
|
+
scope[dirtyAccessor] = true;
|
1598
|
+
} else if (--scope[markAccessor] === 0) {
|
1599
|
+
if (op === DIRTY || scope[dirtyAccessor]) {
|
1600
|
+
scope[dirtyAccessor] = false;
|
1601
|
+
fn(scope, 0);
|
1602
|
+
intersection2?.(scope, DIRTY);
|
1603
|
+
} else {
|
1604
|
+
intersection2?.(scope, CLEAN);
|
1605
|
+
}
|
1606
|
+
} else {
|
1607
|
+
scope[dirtyAccessor] ||= op === DIRTY;
|
1608
|
+
}
|
1609
|
+
};
|
1610
|
+
}
|
1611
|
+
function closure(fn, getIntersection) {
|
1612
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1613
|
+
return (scope, valueOrOp) => {
|
1614
|
+
if (valueOrOp === MARK) {
|
1615
|
+
intersection2?.(scope, MARK);
|
1616
|
+
} else {
|
1617
|
+
fn && fn(scope, valueOrOp);
|
1618
|
+
intersection2?.(scope, DIRTY);
|
1619
|
+
}
|
1620
|
+
};
|
1621
|
+
}
|
1622
|
+
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1623
|
+
const signal = closure(fn, getIntersection);
|
1624
|
+
const loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */;
|
1625
|
+
const loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */;
|
1626
|
+
const helperSignal = (ownerScope, value2) => {
|
1627
|
+
const loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1628
|
+
if (loopScopes !== emptyMarkerArray) {
|
1629
|
+
for (const scope of loopScopes) {
|
1630
|
+
if (!scope.___pending) {
|
1631
|
+
queueSource(scope, signal, value2);
|
1632
|
+
}
|
1633
|
+
}
|
1634
|
+
}
|
1635
|
+
};
|
1636
|
+
helperSignal._ = signal;
|
1637
|
+
return helperSignal;
|
1638
|
+
}
|
1639
|
+
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1640
|
+
const signal = closure(fn, getIntersection);
|
1641
|
+
const scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */;
|
1642
|
+
const rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */;
|
1643
|
+
const helperSignal = (scope, value2) => {
|
1644
|
+
const conditionalScope = scope[scopeAccessor];
|
1645
|
+
if (conditionalScope && !conditionalScope.___pending && scope[rendererAccessor]?.___id === getRenderer().___id) {
|
1646
|
+
queueSource(conditionalScope, signal, value2);
|
1647
|
+
}
|
1648
|
+
};
|
1649
|
+
helperSignal._ = signal;
|
1650
|
+
return helperSignal;
|
1651
|
+
}
|
1652
|
+
var defaultGetOwnerScope = (scope) => scope._;
|
1653
|
+
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1654
|
+
const ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */;
|
1655
|
+
const _signal = closure(fn, getIntersection);
|
1656
|
+
const helperSignal = (ownerScope, value2) => {
|
1657
|
+
const subscribers = ownerScope[ownerSubscribersAccessor];
|
1658
|
+
if (subscribers) {
|
1659
|
+
for (const subscriber of subscribers) {
|
1660
|
+
if (!subscriber.___pending) {
|
1661
|
+
queueSource(subscriber, _signal, value2);
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
};
|
1666
|
+
const setupSignal = (scope, value2) => {
|
1667
|
+
_signal(scope, value2);
|
1668
|
+
subscribe(scope);
|
1669
|
+
};
|
1670
|
+
const subscribe = (scope) => {
|
1671
|
+
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope);
|
1672
|
+
getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1673
|
+
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1674
|
+
});
|
1675
|
+
};
|
1676
|
+
helperSignal._ = setupSignal;
|
1677
|
+
helperSignal.___subscribe = subscribe;
|
1678
|
+
return helperSignal;
|
1679
|
+
}
|
1680
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1681
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1682
|
+
}
|
1683
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1684
|
+
function setTagVarChange(scope, changeHandler) {
|
1685
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1686
|
+
}
|
1687
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1688
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1689
|
+
function nextTagId({ $global }) {
|
1690
|
+
const id = tagIdsByGlobal.get($global) || 0;
|
1691
|
+
tagIdsByGlobal.set($global, id + 1);
|
1692
|
+
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1693
|
+
}
|
1694
|
+
function inChild(childAccessor, signal) {
|
1695
|
+
return (scope, valueOrOp) => {
|
1696
|
+
signal(scope[childAccessor], valueOrOp);
|
1697
|
+
};
|
1698
|
+
}
|
1699
|
+
function intersections(signals) {
|
1700
|
+
return (scope, op) => {
|
1701
|
+
for (const signal of signals) {
|
1702
|
+
signal(scope, op);
|
1703
|
+
}
|
1704
|
+
};
|
1705
|
+
}
|
1706
|
+
function effect(id, fn) {
|
1707
|
+
register(id, fn);
|
1708
|
+
return (scope) => {
|
1709
|
+
queueEffect(scope, fn);
|
1710
|
+
};
|
1711
|
+
}
|
1712
|
+
|
1713
|
+
// src/dom/queue.ts
|
1714
|
+
var pendingRender;
|
1715
|
+
var pendingEffects = [];
|
1716
|
+
var rendering = false;
|
1717
|
+
function queueSource(scope, signal, value2) {
|
1718
|
+
schedule();
|
1719
|
+
const prevRendering = rendering;
|
1720
|
+
rendering = true;
|
1721
|
+
signal(scope, MARK);
|
1722
|
+
rendering = prevRendering;
|
1723
|
+
queueRender(scope, signal, value2);
|
1724
|
+
return value2;
|
1725
|
+
}
|
1726
|
+
function queueRender(scope, signal, value2) {
|
1727
|
+
const nextRender = {
|
1728
|
+
___scope: scope,
|
1729
|
+
___signal: signal,
|
1730
|
+
___value: value2,
|
1731
|
+
___next: void 0
|
1732
|
+
};
|
1733
|
+
if (!pendingRender) {
|
1734
|
+
pendingRender = nextRender;
|
1735
|
+
} else if (comparePendingRenders(pendingRender, nextRender) < 0) {
|
1736
|
+
if (rendering) {
|
1737
|
+
throw new Error(
|
1738
|
+
"attempted to queue a render before the currently executing render"
|
1739
|
+
);
|
1740
|
+
}
|
1741
|
+
nextRender.___next = pendingRender;
|
1742
|
+
pendingRender = nextRender;
|
1743
|
+
} else {
|
1744
|
+
let curRender = pendingRender;
|
1745
|
+
while (curRender.___next && comparePendingRenders(curRender.___next, nextRender) >= 0) {
|
1746
|
+
curRender = curRender.___next;
|
1747
|
+
}
|
1748
|
+
nextRender.___next = curRender.___next;
|
1749
|
+
curRender.___next = nextRender;
|
1750
|
+
}
|
1751
|
+
}
|
1752
|
+
function queueEffect(scope, fn) {
|
1753
|
+
pendingEffects.push(scope, fn);
|
1754
|
+
}
|
1755
|
+
function run() {
|
1756
|
+
const effects = pendingEffects;
|
1757
|
+
try {
|
1758
|
+
rendering = true;
|
1759
|
+
runRenders();
|
1760
|
+
} finally {
|
1761
|
+
pendingRender = void 0;
|
1762
|
+
rendering = false;
|
1763
|
+
}
|
1764
|
+
pendingEffects = [];
|
1765
|
+
runEffects(effects);
|
1766
|
+
}
|
1767
|
+
function prepareEffects(fn) {
|
1768
|
+
const prevRender = pendingRender;
|
1769
|
+
const prevEffects = pendingEffects;
|
1770
|
+
const preparedEffects = pendingEffects = [];
|
1771
|
+
pendingRender = void 0;
|
1772
|
+
try {
|
1773
|
+
rendering = true;
|
1774
|
+
fn();
|
1775
|
+
runRenders();
|
1776
|
+
} finally {
|
1777
|
+
rendering = false;
|
1778
|
+
pendingRender = prevRender;
|
1779
|
+
pendingEffects = prevEffects;
|
1780
|
+
}
|
1781
|
+
return preparedEffects;
|
1782
|
+
}
|
1783
|
+
function runEffects(effects = pendingEffects) {
|
1784
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1785
|
+
const scope = effects[i];
|
1786
|
+
const fn = effects[i + 1];
|
1787
|
+
fn(scope, scope);
|
1788
|
+
}
|
1789
|
+
}
|
1790
|
+
function runRenders() {
|
1791
|
+
while (pendingRender) {
|
1792
|
+
if (!pendingRender.___scope.___closestBranch?.___destroyed) {
|
1793
|
+
pendingRender.___signal(pendingRender.___scope, pendingRender.___value);
|
1794
|
+
}
|
1795
|
+
pendingRender = pendingRender.___next;
|
1796
|
+
}
|
1797
|
+
finishPendingScopes();
|
1798
|
+
}
|
1799
|
+
function comparePendingRenders(a, b) {
|
1800
|
+
const aStart = ownerStartNode(a.___scope);
|
1801
|
+
const bStart = ownerStartNode(b.___scope);
|
1802
|
+
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1803
|
+
}
|
1804
|
+
function ownerStartNode(scope) {
|
1805
|
+
return (scope.___closestBranch || scope).___startNode;
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
// src/dom/abort-signal.ts
|
1809
|
+
function resetAbortSignal(scope, id) {
|
1810
|
+
const ctrl = scope.___abortControllers?.[id];
|
1811
|
+
if (ctrl) {
|
1812
|
+
queueEffect(ctrl, abort);
|
1813
|
+
scope.___abortControllers[id] = void 0;
|
1814
|
+
}
|
1815
|
+
}
|
1816
|
+
function getAbortSignal(scope, id) {
|
1817
|
+
if (scope.___closestBranch) {
|
1818
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1819
|
+
}
|
1820
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1821
|
+
}
|
1822
|
+
function abort(ctrl) {
|
1823
|
+
ctrl.abort();
|
1824
|
+
}
|
1825
|
+
|
1826
|
+
// src/common/compat-meta.ts
|
1827
|
+
var prefix = true ? "$compat_" : "$C_";
|
1828
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1829
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1830
|
+
|
1867
1831
|
// src/dom/compat.ts
|
1868
1832
|
var classIdToScope = /* @__PURE__ */ new Map();
|
1869
1833
|
var compat = {
|
@@ -1893,6 +1857,11 @@ var compat = {
|
|
1893
1857
|
runComponentEffects() {
|
1894
1858
|
runEffects(this.effects);
|
1895
1859
|
},
|
1860
|
+
runComponentDestroy() {
|
1861
|
+
if (this.scope) {
|
1862
|
+
destroyBranch(this.scope);
|
1863
|
+
}
|
1864
|
+
},
|
1896
1865
|
resolveRegistered(value2, {
|
1897
1866
|
runtimeId,
|
1898
1867
|
componentIdPrefix
|
@@ -1906,13 +1875,7 @@ var compat = {
|
|
1906
1875
|
return value2;
|
1907
1876
|
},
|
1908
1877
|
createRenderer(setup, clone, args) {
|
1909
|
-
const renderer = createRenderer(
|
1910
|
-
"",
|
1911
|
-
void 0,
|
1912
|
-
setup,
|
1913
|
-
void 0,
|
1914
|
-
args && (() => args)
|
1915
|
-
);
|
1878
|
+
const renderer = createRenderer("", void 0, setup, args && (() => args));
|
1916
1879
|
renderer.___clone = clone;
|
1917
1880
|
return renderer;
|
1918
1881
|
},
|
@@ -1936,13 +1899,9 @@ var compat = {
|
|
1936
1899
|
}
|
1937
1900
|
component.effects = prepareEffects(() => {
|
1938
1901
|
if (!scope) {
|
1939
|
-
scope = component.scope =
|
1940
|
-
|
1941
|
-
|
1942
|
-
for (const signal of closures) {
|
1943
|
-
signal(component.scope, CLEAN);
|
1944
|
-
}
|
1945
|
-
}
|
1902
|
+
scope = component.scope = createScope(out.global);
|
1903
|
+
scope._ = renderer.___owner;
|
1904
|
+
initRenderer(renderer, scope);
|
1946
1905
|
} else {
|
1947
1906
|
applyArgs(scope, MARK);
|
1948
1907
|
existing = true;
|
@@ -1972,7 +1931,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1972
1931
|
return register(templateId, renderer);
|
1973
1932
|
};
|
1974
1933
|
function mount(input = {}, reference, position) {
|
1975
|
-
let
|
1934
|
+
let branch, dom;
|
1976
1935
|
let { $global } = input;
|
1977
1936
|
if ($global) {
|
1978
1937
|
({ $global, ...input } = input);
|
@@ -1989,10 +1948,10 @@ function mount(input = {}, reference, position) {
|
|
1989
1948
|
}
|
1990
1949
|
const args = this.___args;
|
1991
1950
|
const effects = prepareEffects(() => {
|
1992
|
-
|
1993
|
-
dom = initRenderer(this,
|
1951
|
+
branch = createScope($global);
|
1952
|
+
dom = initRenderer(this, branch);
|
1994
1953
|
if (args) {
|
1995
|
-
args(
|
1954
|
+
args(branch, [input]);
|
1996
1955
|
}
|
1997
1956
|
});
|
1998
1957
|
switch (position) {
|
@@ -2015,14 +1974,14 @@ function mount(input = {}, reference, position) {
|
|
2015
1974
|
if (args) {
|
2016
1975
|
runEffects(
|
2017
1976
|
prepareEffects(() => {
|
2018
|
-
args(
|
2019
|
-
args(
|
1977
|
+
args(branch, MARK);
|
1978
|
+
args(branch, [newInput]);
|
2020
1979
|
})
|
2021
1980
|
);
|
2022
1981
|
}
|
2023
1982
|
},
|
2024
1983
|
destroy: () => {
|
2025
|
-
|
1984
|
+
removeAndDestroyBranch(branch);
|
2026
1985
|
}
|
2027
1986
|
};
|
2028
1987
|
}
|
@@ -2032,11 +1991,10 @@ export {
|
|
2032
1991
|
attrTags,
|
2033
1992
|
attrs,
|
2034
1993
|
attrsEvents,
|
2035
|
-
childClosures,
|
2036
1994
|
classAttr,
|
2037
|
-
closure,
|
2038
1995
|
compat,
|
2039
1996
|
conditional,
|
1997
|
+
conditionalClosure,
|
2040
1998
|
conditionalOnlyChild,
|
2041
1999
|
controllable_detailsOrDialog_open,
|
2042
2000
|
controllable_detailsOrDialog_open_effect,
|
@@ -2056,7 +2014,6 @@ export {
|
|
2056
2014
|
createTemplate,
|
2057
2015
|
data,
|
2058
2016
|
dynamicClosure,
|
2059
|
-
dynamicSubscribers,
|
2060
2017
|
dynamicTagAttrs,
|
2061
2018
|
effect,
|
2062
2019
|
forIn,
|
@@ -2065,12 +2022,11 @@ export {
|
|
2065
2022
|
getAbortSignal,
|
2066
2023
|
html,
|
2067
2024
|
inChild,
|
2068
|
-
inConditionalScope,
|
2069
|
-
inLoopScope,
|
2070
2025
|
init,
|
2071
2026
|
intersection,
|
2072
2027
|
intersections,
|
2073
2028
|
lifecycle,
|
2029
|
+
loopClosure,
|
2074
2030
|
loopIn,
|
2075
2031
|
loopOf,
|
2076
2032
|
loopTo,
|