marko 6.0.0-next.3.22 → 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 +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/dom.js
CHANGED
@@ -22,11 +22,10 @@ __export(dom_exports, {
|
|
22
22
|
attrTags: () => attrTags,
|
23
23
|
attrs: () => attrs,
|
24
24
|
attrsEvents: () => attrsEvents,
|
25
|
-
childClosures: () => childClosures,
|
26
25
|
classAttr: () => classAttr,
|
27
|
-
closure: () => closure,
|
28
26
|
compat: () => compat,
|
29
27
|
conditional: () => conditional,
|
28
|
+
conditionalClosure: () => conditionalClosure,
|
30
29
|
conditionalOnlyChild: () => conditionalOnlyChild,
|
31
30
|
controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
|
32
31
|
controllable_detailsOrDialog_open_effect: () => controllable_detailsOrDialog_open_effect,
|
@@ -46,7 +45,6 @@ __export(dom_exports, {
|
|
46
45
|
createTemplate: () => createTemplate,
|
47
46
|
data: () => data,
|
48
47
|
dynamicClosure: () => dynamicClosure,
|
49
|
-
dynamicSubscribers: () => dynamicSubscribers,
|
50
48
|
dynamicTagAttrs: () => dynamicTagAttrs,
|
51
49
|
effect: () => effect,
|
52
50
|
forIn: () => forIn,
|
@@ -55,12 +53,11 @@ __export(dom_exports, {
|
|
55
53
|
getAbortSignal: () => getAbortSignal,
|
56
54
|
html: () => html,
|
57
55
|
inChild: () => inChild,
|
58
|
-
inConditionalScope: () => inConditionalScope,
|
59
|
-
inLoopScope: () => inLoopScope,
|
60
56
|
init: () => init,
|
61
57
|
intersection: () => intersection,
|
62
58
|
intersections: () => intersections,
|
63
59
|
lifecycle: () => lifecycle,
|
60
|
+
loopClosure: () => loopClosure,
|
64
61
|
loopIn: () => loopIn,
|
65
62
|
loopOf: () => loopOf,
|
66
63
|
loopTo: () => loopTo,
|
@@ -132,346 +129,46 @@ function triggerMacroTask() {
|
|
132
129
|
port2.postMessage(0);
|
133
130
|
}
|
134
131
|
|
135
|
-
// src/common/meta.ts
|
136
|
-
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
137
|
-
|
138
132
|
// src/dom/scope.ts
|
133
|
+
var pendingScopes = [];
|
139
134
|
function createScope($global) {
|
140
|
-
|
141
|
-
|
135
|
+
let scope = {
|
136
|
+
g: 1,
|
142
137
|
$global
|
143
138
|
};
|
139
|
+
return pendingScopes.push(scope), scope;
|
140
|
+
}
|
141
|
+
function finishPendingScopes() {
|
142
|
+
for (let scope of pendingScopes)
|
143
|
+
scope.g = 0;
|
144
|
+
pendingScopes = [];
|
144
145
|
}
|
145
146
|
var emptyScope = createScope({});
|
146
147
|
function getEmptyScope(marker) {
|
147
|
-
return emptyScope.a = emptyScope.
|
148
|
-
}
|
149
|
-
function
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
scope.h?.forEach(_destroyScope);
|
159
|
-
let controllers = scope.l;
|
160
|
-
if (controllers)
|
161
|
-
for (let ctrl of controllers.values())
|
162
|
-
ctrl.abort();
|
163
|
-
}
|
164
|
-
function onDestroy(scope) {
|
165
|
-
let parentScope = scope.d;
|
166
|
-
for (; parentScope && !parentScope.h?.has(scope); )
|
167
|
-
(parentScope.h ||= /* @__PURE__ */ new Set()).add(scope), scope = parentScope, parentScope = scope.d;
|
168
|
-
}
|
169
|
-
function removeAndDestroyScope(scope) {
|
170
|
-
destroyScope(scope);
|
171
|
-
let current = scope.a, stop = scope.b.nextSibling;
|
148
|
+
return emptyScope.a = emptyScope.c = marker, emptyScope;
|
149
|
+
}
|
150
|
+
function destroyBranch(branch) {
|
151
|
+
if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
|
152
|
+
for (let scope of branch.n)
|
153
|
+
for (let id in scope.h)
|
154
|
+
scope.h[id]?.abort();
|
155
|
+
}
|
156
|
+
function removeAndDestroyBranch(branch) {
|
157
|
+
destroyBranch(branch);
|
158
|
+
let current = branch.a, stop = branch.c.nextSibling;
|
172
159
|
for (; current !== stop; ) {
|
173
160
|
let next = current.nextSibling;
|
174
161
|
current.remove(), current = next;
|
175
162
|
}
|
176
163
|
}
|
177
164
|
function insertBefore(scope, parent, nextSibling) {
|
178
|
-
let current = scope.a, stop = scope.
|
165
|
+
let current = scope.a, stop = scope.c.nextSibling;
|
179
166
|
for (; current !== stop; ) {
|
180
167
|
let next = current.nextSibling;
|
181
168
|
parent.insertBefore(current, nextSibling), current = next;
|
182
169
|
}
|
183
170
|
}
|
184
171
|
|
185
|
-
// src/dom/resume.ts
|
186
|
-
var registeredValues = {}, Render = class {
|
187
|
-
m = [];
|
188
|
-
n = {};
|
189
|
-
y = {
|
190
|
-
_: registeredValues
|
191
|
-
};
|
192
|
-
constructor(renders, runtimeId, renderId) {
|
193
|
-
this.z = renders, this.A = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
|
194
|
-
}
|
195
|
-
w() {
|
196
|
-
this.p.w(), this.q();
|
197
|
-
}
|
198
|
-
q() {
|
199
|
-
let data2 = this.p, serializeContext = this.y, scopeLookup = this.n, visits = data2.v, cleanupOwners = /* @__PURE__ */ new Map();
|
200
|
-
if (visits.length) {
|
201
|
-
let commentPrefixLen = data2.i.length, cleanupMarkers = /* @__PURE__ */ new Map();
|
202
|
-
data2.v = [];
|
203
|
-
let sectionEnd = (visit, scopeId = this.f, curNode = visit) => {
|
204
|
-
let scope = scopeLookup[scopeId] ||= {}, endNode = curNode;
|
205
|
-
for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
|
206
|
-
scope.b = endNode;
|
207
|
-
let startNode = scope.a ||= endNode, len = cleanupMarkers.size;
|
208
|
-
for (let [markerScopeId, markerNode] of cleanupMarkers) {
|
209
|
-
if (!len--) break;
|
210
|
-
markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (cleanupOwners.set("" + markerScopeId, scopeId), cleanupMarkers.delete(markerScopeId));
|
211
|
-
}
|
212
|
-
return cleanupMarkers.set(scopeId, visit), scope;
|
213
|
-
};
|
214
|
-
for (let visit of visits) {
|
215
|
-
let commentText = visit.data, token = commentText[commentPrefixLen], scopeId = parseInt(commentText.slice(commentPrefixLen + 1)), scope = scopeLookup[scopeId] ||= {}, dataIndex = commentText.indexOf(" ") + 1, data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
216
|
-
if (token === "*" /* Node */)
|
217
|
-
scope[data3] = visit.previousSibling;
|
218
|
-
else if (token === "$" /* Cleanup */)
|
219
|
-
cleanupMarkers.set(scopeId, visit);
|
220
|
-
else if (token === "[" /* SectionStart */)
|
221
|
-
this.f && (data3 && sectionEnd(visit), this.m.push(this.f)), this.f = scopeId, scope.a = visit;
|
222
|
-
else if (token === "]" /* SectionEnd */) {
|
223
|
-
if (scope[data3] = visit, scopeId < this.f) {
|
224
|
-
let currParent = visit.parentNode, startNode = sectionEnd(visit).a;
|
225
|
-
currParent && currParent !== startNode.parentNode && currParent.prepend(startNode), this.f = this.m.pop();
|
226
|
-
}
|
227
|
-
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
228
|
-
scope[parseInt(data3)] = visit;
|
229
|
-
let childScopeIds = JSON.parse(
|
230
|
-
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
231
|
-
), curNode = visit;
|
232
|
-
for (let i = childScopeIds.length - 1; i >= 0; i--)
|
233
|
-
curNode = sectionEnd(visit, childScopeIds[i], curNode).b;
|
234
|
-
}
|
235
|
-
}
|
236
|
-
}
|
237
|
-
let resumes = data2.r;
|
238
|
-
if (resumes) {
|
239
|
-
data2.r = [];
|
240
|
-
let len = resumes.length, i = 0;
|
241
|
-
try {
|
242
|
-
for (isResuming = !0; i < len; ) {
|
243
|
-
let resumeData = resumes[i++];
|
244
|
-
if (typeof resumeData == "function") {
|
245
|
-
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
246
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.A, $global.renderId = this.o);
|
247
|
-
for (let scopeId in scopes)
|
248
|
-
if (scopeId !== "$") {
|
249
|
-
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
250
|
-
scope.$global = $global, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
251
|
-
scope,
|
252
|
-
prevScope
|
253
|
-
));
|
254
|
-
let cleanupOwnerId = cleanupOwners.get(scopeId);
|
255
|
-
cleanupOwnerId && (scope.d = scopes[cleanupOwnerId], onDestroy(scope));
|
256
|
-
}
|
257
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.z[this.o] : registeredValues[resumes[i++]](
|
258
|
-
scopeLookup[resumeData],
|
259
|
-
scopeLookup[resumeData]
|
260
|
-
);
|
261
|
-
}
|
262
|
-
} finally {
|
263
|
-
isResuming = !1;
|
264
|
-
}
|
265
|
-
}
|
266
|
-
}
|
267
|
-
}, isResuming = !1;
|
268
|
-
function register(id, obj) {
|
269
|
-
return registeredValues[id] = obj, obj;
|
270
|
-
}
|
271
|
-
function registerBoundSignal(id, signal) {
|
272
|
-
return registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp), signal;
|
273
|
-
}
|
274
|
-
function getRegisteredWithScope(id, scope) {
|
275
|
-
let val = registeredValues[id];
|
276
|
-
return scope ? val(scope) : val;
|
277
|
-
}
|
278
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
279
|
-
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
280
|
-
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
281
|
-
configurable: !0,
|
282
|
-
set: setRenders
|
283
|
-
});
|
284
|
-
function setRenders(v) {
|
285
|
-
renders = v;
|
286
|
-
for (let renderId in v)
|
287
|
-
resumeRender(renderId);
|
288
|
-
Object.defineProperty(window, runtimeId, {
|
289
|
-
configurable: !0,
|
290
|
-
value: resumeRender
|
291
|
-
});
|
292
|
-
}
|
293
|
-
}
|
294
|
-
function registerSubscriber(id, signal) {
|
295
|
-
return register(id, signal.g), signal;
|
296
|
-
}
|
297
|
-
function nodeRef(id, key) {
|
298
|
-
return register(id, (scope) => () => scope[key]);
|
299
|
-
}
|
300
|
-
|
301
|
-
// src/dom/signals.ts
|
302
|
-
var MARK = {}, CLEAN = {}, DIRTY = {};
|
303
|
-
function state(valueAccessor, fn, getIntersection) {
|
304
|
-
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
305
|
-
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
306
|
-
scope,
|
307
|
-
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
308
|
-
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
309
|
-
}
|
310
|
-
function value(valueAccessor, fn, getIntersection) {
|
311
|
-
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
312
|
-
return (scope, valueOrOp) => {
|
313
|
-
if (valueOrOp === MARK)
|
314
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
315
|
-
else if (valueOrOp !== DIRTY) {
|
316
|
-
let existing = scope[markAccessor] !== void 0;
|
317
|
-
(scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? intersection2?.(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY))), scope[markAccessor]--;
|
318
|
-
}
|
319
|
-
};
|
320
|
-
}
|
321
|
-
var accessorId = 0;
|
322
|
-
function intersection(count, fn, getIntersection) {
|
323
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
324
|
-
return (scope, op) => {
|
325
|
-
op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK) : scope[markAccessor] === void 0 ? (scope[markAccessor] = count - 1, scope[dirtyAccessor] = !0) : --scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, fn(scope, 0), intersection2?.(scope, DIRTY)) : intersection2?.(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
|
326
|
-
};
|
327
|
-
}
|
328
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
329
|
-
function closure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
330
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + 1, getOwnerValueAccessor = typeof ownerValueAccessor == "function" ? ownerValueAccessor : () => ownerValueAccessor, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
331
|
-
return (scope, op) => {
|
332
|
-
if (op === MARK)
|
333
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
334
|
-
else {
|
335
|
-
let ownerScope, ownerValueAccessor2;
|
336
|
-
if (scope[markAccessor] === void 0) {
|
337
|
-
ownerScope = getOwnerScope(scope), ownerValueAccessor2 = getOwnerValueAccessor(scope);
|
338
|
-
let ownerMark = ownerScope[ownerValueAccessor2 + "#" /* Mark */], ownerHasRun = ownerMark === void 0 ? !ownerScope.u : ownerMark === 0;
|
339
|
-
scope[markAccessor] = ownerHasRun ? 1 : 2, op = DIRTY;
|
340
|
-
}
|
341
|
-
--scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, ownerScope ||= getOwnerScope(scope), ownerValueAccessor2 ||= getOwnerValueAccessor(scope), fn && fn(scope, ownerScope[ownerValueAccessor2]), intersection2?.(scope, DIRTY)) : intersection2?.(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
|
342
|
-
}
|
343
|
-
};
|
344
|
-
}
|
345
|
-
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
346
|
-
let getOwnerValueAccessor = typeof ownerValueAccessor == "function" ? ownerValueAccessor : () => ownerValueAccessor, signalFn = closure(
|
347
|
-
getOwnerValueAccessor,
|
348
|
-
fn,
|
349
|
-
getOwnerScope,
|
350
|
-
getIntersection
|
351
|
-
), subscribeFns = /* @__PURE__ */ new WeakMap();
|
352
|
-
return signalFn.g = (scope) => {
|
353
|
-
let subscribeFn = (value2) => signalFn(scope, value2), ownerScope = getOwnerScope(scope), providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
354
|
-
subscribeFns.set(scope, subscribeFn), (ownerScope[providerSubscriptionsAccessor] ||= /* @__PURE__ */ new Set()).add(subscribeFn);
|
355
|
-
}, signalFn.j = (scope) => {
|
356
|
-
let ownerScope = getOwnerScope(scope), providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
357
|
-
ownerScope[providerSubscriptionsAccessor]?.delete(subscribeFns.get(scope)), subscribeFns.delete(scope);
|
358
|
-
}, signalFn;
|
359
|
-
}
|
360
|
-
function childClosures(closureSignals, childAccessor) {
|
361
|
-
let signal = (scope, op) => {
|
362
|
-
let childScope = scope[childAccessor];
|
363
|
-
for (let closureSignal of closureSignals)
|
364
|
-
closureSignal(childScope, op);
|
365
|
-
};
|
366
|
-
return signal.g = (scope) => {
|
367
|
-
let childScope = scope[childAccessor];
|
368
|
-
for (let closureSignal of closureSignals)
|
369
|
-
closureSignal.g?.(childScope);
|
370
|
-
}, signal.j = (scope) => {
|
371
|
-
let childScope = scope[childAccessor];
|
372
|
-
for (let closureSignal of closureSignals)
|
373
|
-
closureSignal.j?.(childScope);
|
374
|
-
}, signal;
|
375
|
-
}
|
376
|
-
function dynamicSubscribers(valueAccessor) {
|
377
|
-
let subscribersAccessor = valueAccessor + "*" /* Subscribers */;
|
378
|
-
return (scope, op) => {
|
379
|
-
let subscribers = scope[subscribersAccessor];
|
380
|
-
if (subscribers)
|
381
|
-
for (let subscriber of subscribers)
|
382
|
-
subscriber(op);
|
383
|
-
};
|
384
|
-
}
|
385
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
386
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
387
|
-
}
|
388
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
389
|
-
function setTagVarChange(scope, changeHandler) {
|
390
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
391
|
-
}
|
392
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), contentClosures = (content, childScope, op) => {
|
393
|
-
let signals = content?.c;
|
394
|
-
if (signals)
|
395
|
-
for (let signal of signals)
|
396
|
-
signal(childScope, op);
|
397
|
-
};
|
398
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
399
|
-
function nextTagId({ $global }) {
|
400
|
-
let id = tagIdsByGlobal.get($global) || 0;
|
401
|
-
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
402
|
-
}
|
403
|
-
function inChild(childAccessor, signal) {
|
404
|
-
return (scope, valueOrOp) => {
|
405
|
-
signal(scope[childAccessor], valueOrOp);
|
406
|
-
};
|
407
|
-
}
|
408
|
-
function intersections(signals) {
|
409
|
-
return (scope, op) => {
|
410
|
-
for (let signal of signals)
|
411
|
-
signal(scope, op);
|
412
|
-
};
|
413
|
-
}
|
414
|
-
function effect(id, fn) {
|
415
|
-
return register(id, fn), (scope) => {
|
416
|
-
queueEffect(scope, fn);
|
417
|
-
};
|
418
|
-
}
|
419
|
-
|
420
|
-
// src/dom/queue.ts
|
421
|
-
var pendingSignals = [], pendingEffects = [], rendering = !1;
|
422
|
-
function queueSource(scope, signal, value2) {
|
423
|
-
return schedule(), rendering = !0, signal(scope, MARK), rendering = !1, pendingSignals.push(scope, signal, value2), value2;
|
424
|
-
}
|
425
|
-
function queueEffect(scope, fn) {
|
426
|
-
pendingEffects.push(scope, fn);
|
427
|
-
}
|
428
|
-
function run() {
|
429
|
-
let signals = pendingSignals, effects = pendingEffects;
|
430
|
-
try {
|
431
|
-
rendering = !0, pendingSignals = [], runSignals(signals);
|
432
|
-
} finally {
|
433
|
-
rendering = !1;
|
434
|
-
}
|
435
|
-
pendingEffects = [], runEffects(effects);
|
436
|
-
}
|
437
|
-
function prepareEffects(fn) {
|
438
|
-
let prevSignals = pendingSignals, prevEffects = pendingEffects, preparedEffects = pendingEffects = [], preparedSignals = pendingSignals = [];
|
439
|
-
try {
|
440
|
-
rendering = !0, fn(), pendingSignals = prevSignals, runSignals(preparedSignals);
|
441
|
-
} finally {
|
442
|
-
rendering = !1, pendingSignals = prevSignals, pendingEffects = prevEffects;
|
443
|
-
}
|
444
|
-
return preparedEffects;
|
445
|
-
}
|
446
|
-
function runEffects(effects = pendingEffects) {
|
447
|
-
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
448
|
-
let scope = effects[i], fn = effects[i + 1];
|
449
|
-
fn(scope, scope);
|
450
|
-
}
|
451
|
-
}
|
452
|
-
function runSignals(signals) {
|
453
|
-
for (let i = 0; i < signals.length; i += 3 /* Total */) {
|
454
|
-
let scope = signals[i + 0 /* Scope */], signal = signals[i + 1 /* Signal */], value2 = signals[i + 2 /* Value */];
|
455
|
-
signal(scope, value2);
|
456
|
-
}
|
457
|
-
}
|
458
|
-
|
459
|
-
// src/dom/abort-signal.ts
|
460
|
-
function resetAbortSignal(scope, id) {
|
461
|
-
let controllers = scope.l;
|
462
|
-
if (controllers) {
|
463
|
-
let ctrl = controllers.get(id);
|
464
|
-
ctrl && (queueEffect(null, () => ctrl.abort()), controllers.delete(id));
|
465
|
-
}
|
466
|
-
}
|
467
|
-
function getAbortSignal(scope, id) {
|
468
|
-
let controllers = scope.l ||= /* @__PURE__ */ new Map(), controller = controllers.get(id);
|
469
|
-
return controller || (onDestroy(scope), controllers.set(id, controller = new AbortController())), controller.signal;
|
470
|
-
}
|
471
|
-
|
472
|
-
// src/common/compat-meta.ts
|
473
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
474
|
-
|
475
172
|
// src/common/helpers.ts
|
476
173
|
function classValue(value2) {
|
477
174
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -520,55 +217,55 @@ function normalizeDynamicRenderer(value2) {
|
|
520
217
|
|
521
218
|
// src/dom/reconcile.ts
|
522
219
|
var WRONG_POS = 2147483647;
|
523
|
-
function reconcile(parent,
|
524
|
-
let oldStart = 0, newStart = 0, oldEnd =
|
220
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
221
|
+
let oldStart = 0, newStart = 0, oldEnd = oldBranches.length - 1, newEnd = newBranches.length - 1, oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart], oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd], i, j, k, nextSibling, oldBranch, newBranch;
|
525
222
|
outer: {
|
526
|
-
for (;
|
223
|
+
for (; oldStartBranch === newStartBranch; ) {
|
527
224
|
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
528
225
|
break outer;
|
529
|
-
|
226
|
+
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
530
227
|
}
|
531
|
-
for (;
|
228
|
+
for (; oldEndBranch === newEndBranch; ) {
|
532
229
|
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
533
230
|
break outer;
|
534
|
-
|
231
|
+
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
535
232
|
}
|
536
233
|
}
|
537
234
|
if (oldStart > oldEnd) {
|
538
235
|
if (newStart <= newEnd) {
|
539
|
-
k = newEnd + 1, nextSibling = k <
|
236
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
540
237
|
do
|
541
|
-
insertBefore(
|
238
|
+
insertBefore(newBranches[newStart++], parent, nextSibling);
|
542
239
|
while (newStart <= newEnd);
|
543
240
|
}
|
544
241
|
} else if (newStart > newEnd)
|
545
242
|
do
|
546
|
-
|
243
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
547
244
|
while (oldStart <= oldEnd);
|
548
245
|
else {
|
549
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable =
|
246
|
+
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
550
247
|
for (i = 0; i < newLength; ++i)
|
551
248
|
sources[i] = -1;
|
552
249
|
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
553
250
|
for (j = newStart; j <= newEnd; ++j)
|
554
|
-
keyIndex.set(
|
251
|
+
keyIndex.set(newBranches[j], j);
|
555
252
|
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
556
|
-
|
557
|
-
if (oldLength ===
|
253
|
+
oldBranch = oldBranches[i], j = keyIndex.get(oldBranch), j !== void 0 && (pos = pos > j ? WRONG_POS : j, ++synced, newBranch = newBranches[j], sources[j - newStart] = i, aNullable[i] = null);
|
254
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
558
255
|
for (; newStart < newLength; ++newStart)
|
559
|
-
insertBefore(
|
256
|
+
insertBefore(newBranches[newStart], parent, afterReference);
|
560
257
|
for (; oldStart < oldLength; ++oldStart)
|
561
|
-
|
258
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
562
259
|
} else {
|
563
260
|
for (i = oldLength - synced; i > 0; )
|
564
|
-
|
261
|
+
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
565
262
|
if (pos === WRONG_POS) {
|
566
263
|
let seq = longestIncreasingSubsequence(sources);
|
567
|
-
for (j = seq.length - 1, k =
|
568
|
-
sources[i] === -1 ? (pos = i + newStart,
|
264
|
+
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
265
|
+
sources[i] === -1 ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : j < 0 || i !== seq[j] ? (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling)) : --j;
|
569
266
|
} else if (synced !== newLength)
|
570
|
-
for (k =
|
571
|
-
sources[i] === -1 && (pos = i + newStart,
|
267
|
+
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
268
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling));
|
572
269
|
}
|
573
270
|
}
|
574
271
|
}
|
@@ -640,6 +337,132 @@ function stripSpacesAndPunctuation(str) {
|
|
640
337
|
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
641
338
|
}
|
642
339
|
|
340
|
+
// src/common/meta.ts
|
341
|
+
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
342
|
+
|
343
|
+
// src/dom/resume.ts
|
344
|
+
var registeredValues = {}, Render = class {
|
345
|
+
o = [];
|
346
|
+
p = {};
|
347
|
+
z = {
|
348
|
+
_: registeredValues
|
349
|
+
};
|
350
|
+
constructor(renders, runtimeId, renderId) {
|
351
|
+
this.A = renders, this.B = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
|
352
|
+
}
|
353
|
+
w() {
|
354
|
+
this.s.w(), this.t();
|
355
|
+
}
|
356
|
+
t() {
|
357
|
+
let data2 = this.s, serializeContext = this.z, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
358
|
+
if (visits.length) {
|
359
|
+
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
360
|
+
data2.v = [];
|
361
|
+
let branchEnd = (branchId, visit, curNode) => {
|
362
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = curNode;
|
363
|
+
for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
|
364
|
+
branch.c = endNode, branch.a ||= endNode;
|
365
|
+
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
366
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
367
|
+
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
368
|
+
};
|
369
|
+
for (let visit of visits) {
|
370
|
+
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
371
|
+
commentPrefixLen + 1,
|
372
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
373
|
+
), scope = scopeLookup[scopeId] ||= {}, data3 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
374
|
+
if (token === "*" /* Node */)
|
375
|
+
scope[data3] = visit.previousSibling;
|
376
|
+
else if (token === "$" /* ClosestBranch */)
|
377
|
+
closestBranchMarkers.set(scopeId, visit);
|
378
|
+
else if (token === "[" /* BranchStart */)
|
379
|
+
this.f && (dataIndex && branchEnd(this.f, visit, visit), this.o.push(this.f)), this.f = scopeId, scope.a = visit;
|
380
|
+
else if (token === "]" /* BranchEnd */) {
|
381
|
+
scope[data3] = visit;
|
382
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
383
|
+
this.f,
|
384
|
+
visit,
|
385
|
+
visit
|
386
|
+
).a;
|
387
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.o.pop();
|
388
|
+
} else if (token === "|" /* BranchSingleNode */) {
|
389
|
+
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
390
|
+
for (; ~next; ) {
|
391
|
+
let start = next + 1;
|
392
|
+
next = data3.indexOf(" ", start);
|
393
|
+
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
394
|
+
curNode = branchEnd(childScopeId, visit, curNode).c;
|
395
|
+
}
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
let resumes = data2.r;
|
400
|
+
if (resumes) {
|
401
|
+
data2.r = [];
|
402
|
+
let len = resumes.length, i = 0;
|
403
|
+
try {
|
404
|
+
for (isResuming = !0; i < len; ) {
|
405
|
+
let resumeData = resumes[i++];
|
406
|
+
if (typeof resumeData == "function") {
|
407
|
+
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
408
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.q);
|
409
|
+
for (let scopeId in scopes)
|
410
|
+
if (scopeId !== "$") {
|
411
|
+
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
412
|
+
scope.$global = $global, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
413
|
+
scope,
|
414
|
+
prevScope
|
415
|
+
));
|
416
|
+
let parentBranchId = parentBranchIds.get(scopeId);
|
417
|
+
if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
418
|
+
let branch = scope, parentBranch = branch.b;
|
419
|
+
scope.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch));
|
420
|
+
}
|
421
|
+
}
|
422
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.A[this.q] : registeredValues[resumes[i++]](
|
423
|
+
scopeLookup[resumeData],
|
424
|
+
scopeLookup[resumeData]
|
425
|
+
);
|
426
|
+
}
|
427
|
+
} finally {
|
428
|
+
isResuming = !1;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}, isResuming = !1;
|
433
|
+
function register(id, obj) {
|
434
|
+
return registeredValues[id] = obj, obj;
|
435
|
+
}
|
436
|
+
function registerBoundSignal(id, signal) {
|
437
|
+
return registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp), signal;
|
438
|
+
}
|
439
|
+
function getRegisteredWithScope(id, scope) {
|
440
|
+
let val = registeredValues[id];
|
441
|
+
return scope ? val(scope) : val;
|
442
|
+
}
|
443
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
444
|
+
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
445
|
+
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
446
|
+
configurable: !0,
|
447
|
+
set: setRenders
|
448
|
+
});
|
449
|
+
function setRenders(v) {
|
450
|
+
renders = v;
|
451
|
+
for (let renderId in v)
|
452
|
+
resumeRender(renderId);
|
453
|
+
Object.defineProperty(window, runtimeId, {
|
454
|
+
configurable: !0,
|
455
|
+
value: resumeRender
|
456
|
+
});
|
457
|
+
}
|
458
|
+
}
|
459
|
+
function registerSubscriber(id, signal) {
|
460
|
+
return register(id, signal.D), signal;
|
461
|
+
}
|
462
|
+
function nodeRef(id, key) {
|
463
|
+
return register(id, (scope) => () => scope[key]);
|
464
|
+
}
|
465
|
+
|
643
466
|
// src/dom/controllable.ts
|
644
467
|
function controllable_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
645
468
|
setCheckboxValue(
|
@@ -693,10 +516,13 @@ function controllable_input_value_effect(scope, nodeAccessor) {
|
|
693
516
|
});
|
694
517
|
}
|
695
518
|
function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
696
|
-
scope[nodeAccessor + ";" /* ControlledHandler */] = valueChange, valueChange ? (scope[nodeAccessor + "=" /* ControlledType */] = 3 /* SelectValue */, scope[nodeAccessor + ":" /* ControlledValue */] = value2) : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */,
|
697
|
-
scope
|
698
|
-
|
699
|
-
|
519
|
+
scope[nodeAccessor + ";" /* ControlledHandler */] = valueChange, valueChange ? (scope[nodeAccessor + "=" /* ControlledType */] = 3 /* SelectValue */, scope[nodeAccessor + ":" /* ControlledValue */] = value2) : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, pendingEffects.unshift(
|
520
|
+
scope,
|
521
|
+
() => setSelectOptions(
|
522
|
+
scope[nodeAccessor],
|
523
|
+
value2,
|
524
|
+
valueChange
|
525
|
+
)
|
700
526
|
);
|
701
527
|
}
|
702
528
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
@@ -845,8 +671,10 @@ function textContent(node, value2) {
|
|
845
671
|
}
|
846
672
|
function attrs(scope, nodeAccessor, nextAttrs) {
|
847
673
|
let el = scope[nodeAccessor];
|
848
|
-
for (let
|
674
|
+
for (let i = el.attributes.length; i--; ) {
|
675
|
+
let { name } = el.attributes.item(i);
|
849
676
|
nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
|
677
|
+
}
|
850
678
|
attrsInternal(scope, nodeAccessor, nextAttrs);
|
851
679
|
}
|
852
680
|
function hasAttrAlias(element, attr2, nextAttrs) {
|
@@ -854,8 +682,10 @@ function hasAttrAlias(element, attr2, nextAttrs) {
|
|
854
682
|
}
|
855
683
|
function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
|
856
684
|
let el = scope[nodeAccessor], partial = {};
|
857
|
-
for (let
|
685
|
+
for (let i = el.attributes.length; i--; ) {
|
686
|
+
let { name } = el.attributes.item(i);
|
858
687
|
!skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
|
688
|
+
}
|
859
689
|
for (let key in nextAttrs)
|
860
690
|
skip[key] || (partial[key] = nextAttrs[key]);
|
861
691
|
attrsInternal(scope, nodeAccessor, partial);
|
@@ -995,11 +825,11 @@ function trimWalkString(walkString) {
|
|
995
825
|
return walkString.slice(0, end + 1);
|
996
826
|
}
|
997
827
|
function walk(startNode, walkCodes, scope) {
|
998
|
-
walker.currentNode = startNode, walkInternal(walkCodes, scope,
|
828
|
+
walker.currentNode = startNode, walkInternal(walkCodes, scope, 0), walker.currentNode = document;
|
999
829
|
}
|
1000
|
-
function walkInternal(walkCodes, scope,
|
830
|
+
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
1001
831
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
1002
|
-
for (
|
832
|
+
for (; value2 = walkCodes.charCodeAt(currentWalkIndex++); )
|
1003
833
|
if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 >= 117 /* Multiplier */)
|
1004
834
|
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
1005
835
|
else if (value2 >= 107 /* Out */) {
|
@@ -1012,14 +842,10 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
1012
842
|
else if (value2 >= 67 /* Next */)
|
1013
843
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
1014
844
|
walker.nextNode();
|
1015
|
-
else if (value2 === 47 /* BeginChild */)
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
cleanupOwnerScope,
|
1020
|
-
currentWalkIndex
|
1021
|
-
);
|
1022
|
-
else {
|
845
|
+
else if (value2 === 47 /* BeginChild */) {
|
846
|
+
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
847
|
+
childScope.a = walker.currentNode, childScope.b = scope.b, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
848
|
+
} else {
|
1023
849
|
if (value2 === 38 /* EndChild */)
|
1024
850
|
return currentWalkIndex;
|
1025
851
|
if (value2 === 32 /* Get */)
|
@@ -1033,26 +859,35 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
1033
859
|
}
|
1034
860
|
|
1035
861
|
// src/dom/renderer.ts
|
1036
|
-
function
|
1037
|
-
let
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
862
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
863
|
+
let branch = createBranch(
|
864
|
+
$global,
|
865
|
+
renderer.u || parentScope,
|
866
|
+
parentScope
|
867
|
+
);
|
868
|
+
return initRenderer(renderer, branch), branch;
|
869
|
+
}
|
870
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
1044
871
|
if (typeof tagNameOrRenderer != "string")
|
1045
|
-
return
|
1046
|
-
|
1047
|
-
|
872
|
+
return createBranchScopeWithRenderer(
|
873
|
+
tagNameOrRenderer,
|
874
|
+
$global,
|
875
|
+
parentScope
|
876
|
+
);
|
877
|
+
let branch = createBranch($global, parentScope, parentScope);
|
878
|
+
return branch[0] = branch.a = branch.c = document.createElement(tagNameOrRenderer), branch;
|
879
|
+
}
|
880
|
+
function createBranch($global, ownerScope, parentScope) {
|
881
|
+
let branch = createScope($global), parentBranch = parentScope.b;
|
882
|
+
return branch._ = ownerScope, branch.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch)), branch;
|
1048
883
|
}
|
1049
884
|
function initRenderer(renderer, scope) {
|
1050
|
-
let dom = renderer.
|
885
|
+
let dom = renderer.l();
|
1051
886
|
return walk(
|
1052
887
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
1053
|
-
renderer.
|
888
|
+
renderer.E,
|
1054
889
|
scope
|
1055
|
-
), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.
|
890
|
+
), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.c = dom.nodeType === 11 /* DocumentFragment */ ? dom.lastChild : dom, renderer.x && queueRender(scope, renderer.x), dom;
|
1056
891
|
}
|
1057
892
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1058
893
|
return (scope, attrsOrOp) => {
|
@@ -1079,36 +914,27 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
1079
914
|
}
|
1080
915
|
};
|
1081
916
|
}
|
1082
|
-
function createRendererWithOwner(template, rawWalks, setup,
|
1083
|
-
let args,
|
917
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
918
|
+
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
1084
919
|
return (owner) => ({
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
920
|
+
j: id,
|
921
|
+
F: template,
|
922
|
+
E: walks,
|
923
|
+
x: setup,
|
924
|
+
l: _clone,
|
925
|
+
u: owner,
|
926
|
+
G: void 0,
|
1092
927
|
get e() {
|
1093
928
|
return args ||= getArgs?.();
|
1094
|
-
},
|
1095
|
-
get c() {
|
1096
|
-
return closureSignals ||= new Set(getClosureSignals?.());
|
1097
929
|
}
|
1098
930
|
});
|
1099
931
|
}
|
1100
|
-
function createRenderer(template, walks, setup,
|
1101
|
-
return createRendererWithOwner(
|
1102
|
-
template,
|
1103
|
-
walks,
|
1104
|
-
setup,
|
1105
|
-
getClosureSignals,
|
1106
|
-
getArgs
|
1107
|
-
)();
|
932
|
+
function createRenderer(template, walks, setup, getArgs) {
|
933
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1108
934
|
}
|
1109
935
|
function _clone() {
|
1110
|
-
return (this.
|
1111
|
-
this.
|
936
|
+
return (this.G ||= parseHTMLOrSingleNode(
|
937
|
+
this.F
|
1112
938
|
)).cloneNode(!0);
|
1113
939
|
}
|
1114
940
|
|
@@ -1117,41 +943,27 @@ function patchConditionals(fn) {
|
|
1117
943
|
conditional = fn(conditional), conditionalOnlyChild = fn(conditionalOnlyChild);
|
1118
944
|
}
|
1119
945
|
var conditional = function(nodeAccessor, fn, getIntersection) {
|
1120
|
-
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */,
|
946
|
+
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1121
947
|
return (scope, newRendererOrOp) => {
|
1122
948
|
if (newRendererOrOp === DIRTY) return;
|
1123
949
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
1124
950
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1125
951
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1126
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (
|
952
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1127
953
|
}
|
1128
|
-
intersection2?.(scope, op)
|
954
|
+
intersection2?.(scope, op);
|
1129
955
|
};
|
1130
956
|
};
|
1131
|
-
function inConditionalScope(signal, nodeAccessor) {
|
1132
|
-
let scopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1133
|
-
return (scope, op) => {
|
1134
|
-
let conditionalScope = scope[scopeAccessor];
|
1135
|
-
if (conditionalScope) {
|
1136
|
-
let conditionalRenderer = scope[rendererAccessor];
|
1137
|
-
(!conditionalRenderer?.c || conditionalRenderer.c.has(signal)) && signal(conditionalScope, op);
|
1138
|
-
}
|
1139
|
-
};
|
1140
|
-
}
|
1141
957
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
1142
|
-
let
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
),
|
1148
|
-
newScope,
|
1149
|
-
prevScope.a.parentNode,
|
1150
|
-
prevScope.a
|
1151
|
-
), removeAndDestroyScope(prevScope);
|
958
|
+
let newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0, prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
|
959
|
+
insertBefore(
|
960
|
+
newBranch || getEmptyScope(scope[nodeAccessor]),
|
961
|
+
prevBranch.a.parentNode,
|
962
|
+
prevBranch.a
|
963
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer, scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1152
964
|
}
|
1153
965
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
1154
|
-
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */,
|
966
|
+
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1155
967
|
return (scope, newRendererOrOp) => {
|
1156
968
|
if (newRendererOrOp === DIRTY) return;
|
1157
969
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
@@ -1163,18 +975,16 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
1163
975
|
normalizedRenderer
|
1164
976
|
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1165
977
|
}
|
1166
|
-
intersection2?.(scope, op)
|
978
|
+
intersection2?.(scope, op);
|
1167
979
|
};
|
1168
980
|
};
|
1169
981
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1170
|
-
let
|
1171
|
-
|
1172
|
-
let newScope = scope[nodeAccessor + "!" /* ConditionalScope */] = createScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope);
|
1173
|
-
insertBefore(newScope, referenceNode, null);
|
1174
|
-
}
|
1175
|
-
prevScope && destroyScope(prevScope);
|
982
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
983
|
+
referenceNode.textContent = "", newBranch && insertBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1176
984
|
}
|
1177
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
985
|
+
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
986
|
+
[Symbol(), getEmptyScope(void 0)]
|
987
|
+
]), emptyMarkerArray = [
|
1178
988
|
/* @__PURE__ */ getEmptyScope(void 0)
|
1179
989
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
1180
990
|
function loopOf(nodeAccessor, renderer) {
|
@@ -1204,31 +1014,25 @@ function loopTo(nodeAccessor, renderer) {
|
|
1204
1014
|
);
|
1205
1015
|
}
|
1206
1016
|
function loop(nodeAccessor, renderer, forEach) {
|
1207
|
-
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */,
|
1017
|
+
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.e;
|
1208
1018
|
return (scope, valueOrOp) => {
|
1209
1019
|
if (valueOrOp === DIRTY) return;
|
1210
1020
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1211
|
-
let
|
1212
|
-
if (
|
1213
|
-
for (let
|
1214
|
-
params?.(
|
1215
|
-
for (let signal of closureSignals)
|
1216
|
-
signal(childScope, valueOrOp);
|
1217
|
-
}
|
1021
|
+
let loopBranches = scope[loopScopeAccessor] ?? scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1022
|
+
if (loopBranches !== emptyMarkerArray)
|
1023
|
+
for (let branch of loopBranches)
|
1024
|
+
params?.(branch, valueOrOp);
|
1218
1025
|
return;
|
1219
1026
|
}
|
1220
1027
|
let referenceNode = scope[nodeAccessor], referenceIsMarker = referenceNode.nodeType === 8 || referenceNode.nodeType === 3, oldMap = scope[nodeAccessor + "(" /* LoopScopeMap */] || (referenceIsMarker ? emptyMarkerMap : emptyMap), oldArray = scope[nodeAccessor + "!" /* LoopScopeArray */] || Array.from(oldMap.values()), newMap, newArray, afterReference, parentNode, needsReconciliation = !0;
|
1221
1028
|
if (forEach(valueOrOp, (key, args) => {
|
1222
|
-
let
|
1223
|
-
|
1224
|
-
|
1225
|
-
signal(childScope, closureOp);
|
1226
|
-
newMap ? (newMap.set(key, childScope), newArray.push(childScope)) : (newMap = /* @__PURE__ */ new Map([[key, childScope]]), newArray = [childScope]);
|
1227
|
-
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyScope), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
1029
|
+
let branch = oldMap.get(key);
|
1030
|
+
branch || (branch = createBranchScopeWithRenderer(renderer, scope.$global, scope)), params && params(branch, args), newMap ? (newMap.set(key, branch), newArray.push(branch)) : (newMap = /* @__PURE__ */ new Map([[key, branch]]), newArray = [branch]);
|
1031
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
1228
1032
|
if (referenceIsMarker) {
|
1229
1033
|
oldMap === emptyMarkerMap && getEmptyScope(referenceNode);
|
1230
1034
|
let oldLastChild = oldArray[oldArray.length - 1];
|
1231
|
-
afterReference = oldLastChild.
|
1035
|
+
afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
|
1232
1036
|
} else
|
1233
1037
|
afterReference = null, parentNode = referenceNode;
|
1234
1038
|
reconcile(parentNode, oldArray, newArray, afterReference);
|
@@ -1236,15 +1040,6 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1236
1040
|
scope[nodeAccessor + "(" /* LoopScopeMap */] = newMap, scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
1237
1041
|
};
|
1238
1042
|
}
|
1239
|
-
function inLoopScope(signal, loopNodeAccessor) {
|
1240
|
-
let loopScopeAccessor = loopNodeAccessor + "!" /* LoopScopeArray */;
|
1241
|
-
return (scope, op) => {
|
1242
|
-
let loopScopes = scope[loopScopeAccessor] ?? scope[loopNodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1243
|
-
if (loopScopes !== emptyMarkerArray)
|
1244
|
-
for (let scope2 of loopScopes)
|
1245
|
-
signal(scope2, op);
|
1246
|
-
};
|
1247
|
-
}
|
1248
1043
|
function bySecondArg(_item, index) {
|
1249
1044
|
return index;
|
1250
1045
|
}
|
@@ -1252,9 +1047,185 @@ function byFirstArg(name) {
|
|
1252
1047
|
return name;
|
1253
1048
|
}
|
1254
1049
|
function isDifferentRenderer(a, b) {
|
1255
|
-
return a !== b && (a?.
|
1050
|
+
return a !== b && (a?.j || 0) !== b?.j;
|
1256
1051
|
}
|
1257
1052
|
|
1053
|
+
// src/dom/signals.ts
|
1054
|
+
var MARK = {}, CLEAN = {}, DIRTY = {};
|
1055
|
+
function state(valueAccessor, fn, getIntersection) {
|
1056
|
+
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
1057
|
+
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
1058
|
+
scope,
|
1059
|
+
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
1060
|
+
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
1061
|
+
}
|
1062
|
+
function value(valueAccessor, fn, getIntersection) {
|
1063
|
+
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1064
|
+
return (scope, valueOrOp) => {
|
1065
|
+
if (valueOrOp === MARK)
|
1066
|
+
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
1067
|
+
else if (valueOrOp !== DIRTY) {
|
1068
|
+
let existing = scope[markAccessor] !== void 0;
|
1069
|
+
(scope[markAccessor] ||= 1) === 1 && (valueOrOp === CLEAN || existing && scope[valueAccessor] === valueOrOp ? intersection2?.(scope, CLEAN) : (scope[valueAccessor] = valueOrOp, fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY))), scope[markAccessor]--;
|
1070
|
+
}
|
1071
|
+
};
|
1072
|
+
}
|
1073
|
+
var accessorId = 0;
|
1074
|
+
function intersection(count, fn, getIntersection) {
|
1075
|
+
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1076
|
+
return (scope, op) => {
|
1077
|
+
op === MARK ? (scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK) : scope[markAccessor] === void 0 ? (scope[markAccessor] = count - 1, scope[dirtyAccessor] = !0) : --scope[markAccessor] === 0 ? op === DIRTY || scope[dirtyAccessor] ? (scope[dirtyAccessor] = !1, fn(scope, 0), intersection2?.(scope, DIRTY)) : intersection2?.(scope, CLEAN) : scope[dirtyAccessor] ||= op === DIRTY;
|
1078
|
+
};
|
1079
|
+
}
|
1080
|
+
function closure(fn, getIntersection) {
|
1081
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1082
|
+
return (scope, valueOrOp) => {
|
1083
|
+
valueOrOp === MARK ? intersection2?.(scope, MARK) : (fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY));
|
1084
|
+
};
|
1085
|
+
}
|
1086
|
+
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1087
|
+
let signal = closure(fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, helperSignal = (ownerScope, value2) => {
|
1088
|
+
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1089
|
+
if (loopScopes !== emptyMarkerArray)
|
1090
|
+
for (let scope of loopScopes)
|
1091
|
+
scope.g || queueSource(scope, signal, value2);
|
1092
|
+
};
|
1093
|
+
return helperSignal._ = signal, helperSignal;
|
1094
|
+
}
|
1095
|
+
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1096
|
+
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1097
|
+
let conditionalScope = scope[scopeAccessor];
|
1098
|
+
conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1099
|
+
};
|
1100
|
+
return helperSignal._ = signal, helperSignal;
|
1101
|
+
}
|
1102
|
+
var defaultGetOwnerScope = (scope) => scope._;
|
1103
|
+
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1104
|
+
let ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1105
|
+
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1106
|
+
if (subscribers)
|
1107
|
+
for (let subscriber of subscribers)
|
1108
|
+
subscriber.g || queueSource(subscriber, _signal, value2);
|
1109
|
+
}, setupSignal = (scope, value2) => {
|
1110
|
+
_signal(scope, value2), subscribe(scope);
|
1111
|
+
}, subscribe = (scope) => {
|
1112
|
+
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope), getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1113
|
+
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1114
|
+
});
|
1115
|
+
};
|
1116
|
+
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1117
|
+
}
|
1118
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1119
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1120
|
+
}
|
1121
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1122
|
+
function setTagVarChange(scope, changeHandler) {
|
1123
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1124
|
+
}
|
1125
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1126
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1127
|
+
function nextTagId({ $global }) {
|
1128
|
+
let id = tagIdsByGlobal.get($global) || 0;
|
1129
|
+
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1130
|
+
}
|
1131
|
+
function inChild(childAccessor, signal) {
|
1132
|
+
return (scope, valueOrOp) => {
|
1133
|
+
signal(scope[childAccessor], valueOrOp);
|
1134
|
+
};
|
1135
|
+
}
|
1136
|
+
function intersections(signals) {
|
1137
|
+
return (scope, op) => {
|
1138
|
+
for (let signal of signals)
|
1139
|
+
signal(scope, op);
|
1140
|
+
};
|
1141
|
+
}
|
1142
|
+
function effect(id, fn) {
|
1143
|
+
return register(id, fn), (scope) => {
|
1144
|
+
queueEffect(scope, fn);
|
1145
|
+
};
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
// src/dom/queue.ts
|
1149
|
+
var pendingRender, pendingEffects = [], rendering = !1;
|
1150
|
+
function queueSource(scope, signal, value2) {
|
1151
|
+
schedule();
|
1152
|
+
let prevRendering = rendering;
|
1153
|
+
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1154
|
+
}
|
1155
|
+
function queueRender(scope, signal, value2) {
|
1156
|
+
let nextRender = {
|
1157
|
+
k: scope,
|
1158
|
+
H: signal,
|
1159
|
+
I: value2,
|
1160
|
+
d: void 0
|
1161
|
+
};
|
1162
|
+
if (!pendingRender)
|
1163
|
+
pendingRender = nextRender;
|
1164
|
+
else if (comparePendingRenders(pendingRender, nextRender) < 0)
|
1165
|
+
nextRender.d = pendingRender, pendingRender = nextRender;
|
1166
|
+
else {
|
1167
|
+
let curRender = pendingRender;
|
1168
|
+
for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
|
1169
|
+
curRender = curRender.d;
|
1170
|
+
nextRender.d = curRender.d, curRender.d = nextRender;
|
1171
|
+
}
|
1172
|
+
}
|
1173
|
+
function queueEffect(scope, fn) {
|
1174
|
+
pendingEffects.push(scope, fn);
|
1175
|
+
}
|
1176
|
+
function run() {
|
1177
|
+
let effects = pendingEffects;
|
1178
|
+
try {
|
1179
|
+
rendering = !0, runRenders();
|
1180
|
+
} finally {
|
1181
|
+
pendingRender = void 0, rendering = !1;
|
1182
|
+
}
|
1183
|
+
pendingEffects = [], runEffects(effects);
|
1184
|
+
}
|
1185
|
+
function prepareEffects(fn) {
|
1186
|
+
let prevRender = pendingRender, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1187
|
+
pendingRender = void 0;
|
1188
|
+
try {
|
1189
|
+
rendering = !0, fn(), runRenders();
|
1190
|
+
} finally {
|
1191
|
+
rendering = !1, pendingRender = prevRender, pendingEffects = prevEffects;
|
1192
|
+
}
|
1193
|
+
return preparedEffects;
|
1194
|
+
}
|
1195
|
+
function runEffects(effects = pendingEffects) {
|
1196
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1197
|
+
let scope = effects[i], fn = effects[i + 1];
|
1198
|
+
fn(scope, scope);
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
function runRenders() {
|
1202
|
+
for (; pendingRender; )
|
1203
|
+
pendingRender.k.b?.y || pendingRender.H(pendingRender.k, pendingRender.I), pendingRender = pendingRender.d;
|
1204
|
+
finishPendingScopes();
|
1205
|
+
}
|
1206
|
+
function comparePendingRenders(a, b) {
|
1207
|
+
let aStart = ownerStartNode(a.k), bStart = ownerStartNode(b.k);
|
1208
|
+
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1209
|
+
}
|
1210
|
+
function ownerStartNode(scope) {
|
1211
|
+
return (scope.b || scope).a;
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
// src/dom/abort-signal.ts
|
1215
|
+
function resetAbortSignal(scope, id) {
|
1216
|
+
let ctrl = scope.h?.[id];
|
1217
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1218
|
+
}
|
1219
|
+
function getAbortSignal(scope, id) {
|
1220
|
+
return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1221
|
+
}
|
1222
|
+
function abort(ctrl) {
|
1223
|
+
ctrl.abort();
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
// src/common/compat-meta.ts
|
1227
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1228
|
+
|
1258
1229
|
// src/dom/compat.ts
|
1259
1230
|
var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
1260
1231
|
patchConditionals,
|
@@ -1271,35 +1242,32 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1271
1242
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1272
1243
|
},
|
1273
1244
|
isRenderer(renderer) {
|
1274
|
-
return renderer.
|
1245
|
+
return renderer.l !== void 0;
|
1275
1246
|
},
|
1276
1247
|
getStartNode(scope) {
|
1277
1248
|
return scope.a;
|
1278
1249
|
},
|
1279
1250
|
setScopeNodes(scope, startNode, endNode) {
|
1280
|
-
scope.a = startNode, scope.
|
1251
|
+
scope.a = startNode, scope.c = endNode;
|
1281
1252
|
},
|
1282
1253
|
runComponentEffects() {
|
1283
1254
|
runEffects(this.effects);
|
1284
1255
|
},
|
1256
|
+
runComponentDestroy() {
|
1257
|
+
this.scope && destroyBranch(this.scope);
|
1258
|
+
},
|
1285
1259
|
resolveRegistered(value2, {
|
1286
1260
|
runtimeId,
|
1287
1261
|
componentIdPrefix
|
1288
1262
|
}) {
|
1289
1263
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1290
1264
|
value2[0],
|
1291
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1265
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.p[value2[1]]
|
1292
1266
|
) : value2;
|
1293
1267
|
},
|
1294
1268
|
createRenderer(setup, clone, args) {
|
1295
|
-
let renderer = createRenderer(
|
1296
|
-
|
1297
|
-
void 0,
|
1298
|
-
setup,
|
1299
|
-
void 0,
|
1300
|
-
args && (() => args)
|
1301
|
-
);
|
1302
|
-
return renderer.k = clone, renderer;
|
1269
|
+
let renderer = createRenderer("", void 0, setup, args && (() => args));
|
1270
|
+
return renderer.l = clone, renderer;
|
1303
1271
|
},
|
1304
1272
|
render(out, component, renderer, args) {
|
1305
1273
|
let scope = component.scope;
|
@@ -1311,18 +1279,9 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1311
1279
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1312
1280
|
}
|
1313
1281
|
if (component.effects = prepareEffects(() => {
|
1314
|
-
|
1315
|
-
applyArgs(scope, MARK), existing = !0;
|
1316
|
-
else {
|
1317
|
-
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
1318
|
-
let closures = renderer.c;
|
1319
|
-
if (closures)
|
1320
|
-
for (let signal of closures)
|
1321
|
-
signal(component.scope, CLEAN);
|
1322
|
-
}
|
1323
|
-
applyArgs(scope, args);
|
1282
|
+
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initRenderer(renderer, scope)), applyArgs(scope, args);
|
1324
1283
|
}), !existing)
|
1325
|
-
return scope.a === scope.
|
1284
|
+
return scope.a === scope.c ? scope.a : scope.a.parentNode;
|
1326
1285
|
}
|
1327
1286
|
};
|
1328
1287
|
function noop() {
|
@@ -1334,7 +1293,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1334
1293
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1335
1294
|
};
|
1336
1295
|
function mount(input = {}, reference, position) {
|
1337
|
-
let
|
1296
|
+
let branch, dom, { $global } = input;
|
1338
1297
|
$global ? ({ $global, ...input } = input, $global = {
|
1339
1298
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1340
1299
|
renderId: DEFAULT_RENDER_ID,
|
@@ -1344,7 +1303,7 @@ function mount(input = {}, reference, position) {
|
|
1344
1303
|
renderId: DEFAULT_RENDER_ID
|
1345
1304
|
};
|
1346
1305
|
let args = this.e, effects = prepareEffects(() => {
|
1347
|
-
|
1306
|
+
branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
|
1348
1307
|
});
|
1349
1308
|
switch (position) {
|
1350
1309
|
case "afterbegin":
|
@@ -1364,12 +1323,12 @@ function mount(input = {}, reference, position) {
|
|
1364
1323
|
update: (newInput) => {
|
1365
1324
|
args && runEffects(
|
1366
1325
|
prepareEffects(() => {
|
1367
|
-
args(
|
1326
|
+
args(branch, MARK), args(branch, [newInput]);
|
1368
1327
|
})
|
1369
1328
|
);
|
1370
1329
|
},
|
1371
1330
|
destroy: () => {
|
1372
|
-
|
1331
|
+
removeAndDestroyBranch(branch);
|
1373
1332
|
}
|
1374
1333
|
};
|
1375
1334
|
}
|