marko 6.0.0-next.3.22 → 6.0.0-next.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/for.d.ts +3 -4
- package/dist/common/types.d.ts +18 -17
- package/dist/debug/dom.js +717 -753
- package/dist/debug/dom.mjs +717 -753
- package/dist/debug/html.js +256 -99
- package/dist/debug/html.mjs +247 -95
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/compat.d.ts +1 -0
- package/dist/dom/control-flow.d.ts +6 -8
- package/dist/dom/parse-html.d.ts +1 -4
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/reconcile.d.ts +2 -2
- package/dist/dom/renderer.d.ts +7 -8
- package/dist/dom/resume.d.ts +3 -3
- package/dist/dom/scope.d.ts +4 -4
- package/dist/dom/signals.d.ts +13 -26
- package/dist/dom/template.d.ts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +459 -494
- package/dist/dom.mjs +459 -494
- package/dist/html/dynamic-tag.d.ts +3 -3
- package/dist/html/writer.d.ts +12 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +202 -65
- package/dist/html.mjs +193 -61
- package/dist/translator/core/for.d.ts +0 -2
- package/dist/translator/index.js +189 -224
- package/dist/translator/util/runtime.d.ts +1 -2
- package/dist/translator/util/sections.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +2 -2
- package/package.json +2 -2
- package/tags-html.d.ts +152 -152
package/dist/dom.mjs
CHANGED
@@ -45,346 +45,46 @@ function triggerMacroTask() {
|
|
45
45
|
port2.postMessage(0);
|
46
46
|
}
|
47
47
|
|
48
|
-
// src/common/meta.ts
|
49
|
-
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
50
|
-
|
51
48
|
// src/dom/scope.ts
|
49
|
+
var pendingScopes = [];
|
52
50
|
function createScope($global) {
|
53
|
-
|
54
|
-
|
51
|
+
let scope = {
|
52
|
+
g: 1,
|
55
53
|
$global
|
56
54
|
};
|
55
|
+
return pendingScopes.push(scope), scope;
|
56
|
+
}
|
57
|
+
function finishPendingScopes() {
|
58
|
+
for (let scope of pendingScopes)
|
59
|
+
scope.g = 0;
|
60
|
+
pendingScopes = [];
|
57
61
|
}
|
58
62
|
var emptyScope = createScope({});
|
59
63
|
function getEmptyScope(marker) {
|
60
|
-
return emptyScope.a = emptyScope.
|
61
|
-
}
|
62
|
-
function
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
scope.h?.forEach(_destroyScope);
|
72
|
-
let controllers = scope.l;
|
73
|
-
if (controllers)
|
74
|
-
for (let ctrl of controllers.values())
|
75
|
-
ctrl.abort();
|
76
|
-
}
|
77
|
-
function onDestroy(scope) {
|
78
|
-
let parentScope = scope.d;
|
79
|
-
for (; parentScope && !parentScope.h?.has(scope); )
|
80
|
-
(parentScope.h ||= /* @__PURE__ */ new Set()).add(scope), scope = parentScope, parentScope = scope.d;
|
81
|
-
}
|
82
|
-
function removeAndDestroyScope(scope) {
|
83
|
-
destroyScope(scope);
|
84
|
-
let current = scope.a, stop = scope.b.nextSibling;
|
64
|
+
return emptyScope.a = emptyScope.c = marker, emptyScope;
|
65
|
+
}
|
66
|
+
function destroyBranch(branch) {
|
67
|
+
if (branch.y = 1, branch.m?.forEach(destroyBranch), branch.n)
|
68
|
+
for (let scope of branch.n)
|
69
|
+
for (let id in scope.h)
|
70
|
+
scope.h[id]?.abort();
|
71
|
+
}
|
72
|
+
function removeAndDestroyBranch(branch) {
|
73
|
+
destroyBranch(branch);
|
74
|
+
let current = branch.a, stop = branch.c.nextSibling;
|
85
75
|
for (; current !== stop; ) {
|
86
76
|
let next = current.nextSibling;
|
87
77
|
current.remove(), current = next;
|
88
78
|
}
|
89
79
|
}
|
90
80
|
function insertBefore(scope, parent, nextSibling) {
|
91
|
-
let current = scope.a, stop = scope.
|
81
|
+
let current = scope.a, stop = scope.c.nextSibling;
|
92
82
|
for (; current !== stop; ) {
|
93
83
|
let next = current.nextSibling;
|
94
84
|
parent.insertBefore(current, nextSibling), current = next;
|
95
85
|
}
|
96
86
|
}
|
97
87
|
|
98
|
-
// src/dom/resume.ts
|
99
|
-
var registeredValues = {}, Render = class {
|
100
|
-
m = [];
|
101
|
-
n = {};
|
102
|
-
y = {
|
103
|
-
_: registeredValues
|
104
|
-
};
|
105
|
-
constructor(renders, runtimeId, renderId) {
|
106
|
-
this.z = renders, this.A = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
|
107
|
-
}
|
108
|
-
w() {
|
109
|
-
this.p.w(), this.q();
|
110
|
-
}
|
111
|
-
q() {
|
112
|
-
let data2 = this.p, serializeContext = this.y, scopeLookup = this.n, visits = data2.v, cleanupOwners = /* @__PURE__ */ new Map();
|
113
|
-
if (visits.length) {
|
114
|
-
let commentPrefixLen = data2.i.length, cleanupMarkers = /* @__PURE__ */ new Map();
|
115
|
-
data2.v = [];
|
116
|
-
let sectionEnd = (visit, scopeId = this.f, curNode = visit) => {
|
117
|
-
let scope = scopeLookup[scopeId] ||= {}, endNode = curNode;
|
118
|
-
for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
|
119
|
-
scope.b = endNode;
|
120
|
-
let startNode = scope.a ||= endNode, len = cleanupMarkers.size;
|
121
|
-
for (let [markerScopeId, markerNode] of cleanupMarkers) {
|
122
|
-
if (!len--) break;
|
123
|
-
markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (cleanupOwners.set("" + markerScopeId, scopeId), cleanupMarkers.delete(markerScopeId));
|
124
|
-
}
|
125
|
-
return cleanupMarkers.set(scopeId, visit), scope;
|
126
|
-
};
|
127
|
-
for (let visit of visits) {
|
128
|
-
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) : "";
|
129
|
-
if (token === "*" /* Node */)
|
130
|
-
scope[data3] = visit.previousSibling;
|
131
|
-
else if (token === "$" /* Cleanup */)
|
132
|
-
cleanupMarkers.set(scopeId, visit);
|
133
|
-
else if (token === "[" /* SectionStart */)
|
134
|
-
this.f && (data3 && sectionEnd(visit), this.m.push(this.f)), this.f = scopeId, scope.a = visit;
|
135
|
-
else if (token === "]" /* SectionEnd */) {
|
136
|
-
if (scope[data3] = visit, scopeId < this.f) {
|
137
|
-
let currParent = visit.parentNode, startNode = sectionEnd(visit).a;
|
138
|
-
currParent && currParent !== startNode.parentNode && currParent.prepend(startNode), this.f = this.m.pop();
|
139
|
-
}
|
140
|
-
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
141
|
-
scope[parseInt(data3)] = visit;
|
142
|
-
let childScopeIds = JSON.parse(
|
143
|
-
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
144
|
-
), curNode = visit;
|
145
|
-
for (let i = childScopeIds.length - 1; i >= 0; i--)
|
146
|
-
curNode = sectionEnd(visit, childScopeIds[i], curNode).b;
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
let resumes = data2.r;
|
151
|
-
if (resumes) {
|
152
|
-
data2.r = [];
|
153
|
-
let len = resumes.length, i = 0;
|
154
|
-
try {
|
155
|
-
for (isResuming = !0; i < len; ) {
|
156
|
-
let resumeData = resumes[i++];
|
157
|
-
if (typeof resumeData == "function") {
|
158
|
-
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
159
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.A, $global.renderId = this.o);
|
160
|
-
for (let scopeId in scopes)
|
161
|
-
if (scopeId !== "$") {
|
162
|
-
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
163
|
-
scope.$global = $global, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
164
|
-
scope,
|
165
|
-
prevScope
|
166
|
-
));
|
167
|
-
let cleanupOwnerId = cleanupOwners.get(scopeId);
|
168
|
-
cleanupOwnerId && (scope.d = scopes[cleanupOwnerId], onDestroy(scope));
|
169
|
-
}
|
170
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.z[this.o] : registeredValues[resumes[i++]](
|
171
|
-
scopeLookup[resumeData],
|
172
|
-
scopeLookup[resumeData]
|
173
|
-
);
|
174
|
-
}
|
175
|
-
} finally {
|
176
|
-
isResuming = !1;
|
177
|
-
}
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}, isResuming = !1;
|
181
|
-
function register(id, obj) {
|
182
|
-
return registeredValues[id] = obj, obj;
|
183
|
-
}
|
184
|
-
function registerBoundSignal(id, signal) {
|
185
|
-
return registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp), signal;
|
186
|
-
}
|
187
|
-
function getRegisteredWithScope(id, scope) {
|
188
|
-
let val = registeredValues[id];
|
189
|
-
return scope ? val(scope) : val;
|
190
|
-
}
|
191
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
192
|
-
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
193
|
-
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
194
|
-
configurable: !0,
|
195
|
-
set: setRenders
|
196
|
-
});
|
197
|
-
function setRenders(v) {
|
198
|
-
renders = v;
|
199
|
-
for (let renderId in v)
|
200
|
-
resumeRender(renderId);
|
201
|
-
Object.defineProperty(window, runtimeId, {
|
202
|
-
configurable: !0,
|
203
|
-
value: resumeRender
|
204
|
-
});
|
205
|
-
}
|
206
|
-
}
|
207
|
-
function registerSubscriber(id, signal) {
|
208
|
-
return register(id, signal.g), signal;
|
209
|
-
}
|
210
|
-
function nodeRef(id, key) {
|
211
|
-
return register(id, (scope) => () => scope[key]);
|
212
|
-
}
|
213
|
-
|
214
|
-
// src/dom/signals.ts
|
215
|
-
var MARK = {}, CLEAN = {}, DIRTY = {};
|
216
|
-
function state(valueAccessor, fn, getIntersection) {
|
217
|
-
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
218
|
-
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
219
|
-
scope,
|
220
|
-
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
221
|
-
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
222
|
-
}
|
223
|
-
function value(valueAccessor, fn, getIntersection) {
|
224
|
-
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
225
|
-
return (scope, valueOrOp) => {
|
226
|
-
if (valueOrOp === MARK)
|
227
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
228
|
-
else if (valueOrOp !== DIRTY) {
|
229
|
-
let existing = scope[markAccessor] !== void 0;
|
230
|
-
(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]--;
|
231
|
-
}
|
232
|
-
};
|
233
|
-
}
|
234
|
-
var accessorId = 0;
|
235
|
-
function intersection(count, fn, getIntersection) {
|
236
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
237
|
-
return (scope, op) => {
|
238
|
-
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;
|
239
|
-
};
|
240
|
-
}
|
241
|
-
var defaultGetOwnerScope = (scope) => scope._;
|
242
|
-
function closure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
243
|
-
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + 1, getOwnerValueAccessor = typeof ownerValueAccessor == "function" ? ownerValueAccessor : () => ownerValueAccessor, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
244
|
-
return (scope, op) => {
|
245
|
-
if (op === MARK)
|
246
|
-
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
247
|
-
else {
|
248
|
-
let ownerScope, ownerValueAccessor2;
|
249
|
-
if (scope[markAccessor] === void 0) {
|
250
|
-
ownerScope = getOwnerScope(scope), ownerValueAccessor2 = getOwnerValueAccessor(scope);
|
251
|
-
let ownerMark = ownerScope[ownerValueAccessor2 + "#" /* Mark */], ownerHasRun = ownerMark === void 0 ? !ownerScope.u : ownerMark === 0;
|
252
|
-
scope[markAccessor] = ownerHasRun ? 1 : 2, op = DIRTY;
|
253
|
-
}
|
254
|
-
--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;
|
255
|
-
}
|
256
|
-
};
|
257
|
-
}
|
258
|
-
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
259
|
-
let getOwnerValueAccessor = typeof ownerValueAccessor == "function" ? ownerValueAccessor : () => ownerValueAccessor, signalFn = closure(
|
260
|
-
getOwnerValueAccessor,
|
261
|
-
fn,
|
262
|
-
getOwnerScope,
|
263
|
-
getIntersection
|
264
|
-
), subscribeFns = /* @__PURE__ */ new WeakMap();
|
265
|
-
return signalFn.g = (scope) => {
|
266
|
-
let subscribeFn = (value2) => signalFn(scope, value2), ownerScope = getOwnerScope(scope), providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
267
|
-
subscribeFns.set(scope, subscribeFn), (ownerScope[providerSubscriptionsAccessor] ||= /* @__PURE__ */ new Set()).add(subscribeFn);
|
268
|
-
}, signalFn.j = (scope) => {
|
269
|
-
let ownerScope = getOwnerScope(scope), providerSubscriptionsAccessor = getOwnerValueAccessor(scope) + "*" /* Subscribers */;
|
270
|
-
ownerScope[providerSubscriptionsAccessor]?.delete(subscribeFns.get(scope)), subscribeFns.delete(scope);
|
271
|
-
}, signalFn;
|
272
|
-
}
|
273
|
-
function childClosures(closureSignals, childAccessor) {
|
274
|
-
let signal = (scope, op) => {
|
275
|
-
let childScope = scope[childAccessor];
|
276
|
-
for (let closureSignal of closureSignals)
|
277
|
-
closureSignal(childScope, op);
|
278
|
-
};
|
279
|
-
return signal.g = (scope) => {
|
280
|
-
let childScope = scope[childAccessor];
|
281
|
-
for (let closureSignal of closureSignals)
|
282
|
-
closureSignal.g?.(childScope);
|
283
|
-
}, signal.j = (scope) => {
|
284
|
-
let childScope = scope[childAccessor];
|
285
|
-
for (let closureSignal of closureSignals)
|
286
|
-
closureSignal.j?.(childScope);
|
287
|
-
}, signal;
|
288
|
-
}
|
289
|
-
function dynamicSubscribers(valueAccessor) {
|
290
|
-
let subscribersAccessor = valueAccessor + "*" /* Subscribers */;
|
291
|
-
return (scope, op) => {
|
292
|
-
let subscribers = scope[subscribersAccessor];
|
293
|
-
if (subscribers)
|
294
|
-
for (let subscriber of subscribers)
|
295
|
-
subscriber(op);
|
296
|
-
};
|
297
|
-
}
|
298
|
-
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
299
|
-
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
300
|
-
}
|
301
|
-
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
302
|
-
function setTagVarChange(scope, changeHandler) {
|
303
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
304
|
-
}
|
305
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), contentClosures = (content, childScope, op) => {
|
306
|
-
let signals = content?.c;
|
307
|
-
if (signals)
|
308
|
-
for (let signal of signals)
|
309
|
-
signal(childScope, op);
|
310
|
-
};
|
311
|
-
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
312
|
-
function nextTagId({ $global }) {
|
313
|
-
let id = tagIdsByGlobal.get($global) || 0;
|
314
|
-
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
315
|
-
}
|
316
|
-
function inChild(childAccessor, signal) {
|
317
|
-
return (scope, valueOrOp) => {
|
318
|
-
signal(scope[childAccessor], valueOrOp);
|
319
|
-
};
|
320
|
-
}
|
321
|
-
function intersections(signals) {
|
322
|
-
return (scope, op) => {
|
323
|
-
for (let signal of signals)
|
324
|
-
signal(scope, op);
|
325
|
-
};
|
326
|
-
}
|
327
|
-
function effect(id, fn) {
|
328
|
-
return register(id, fn), (scope) => {
|
329
|
-
queueEffect(scope, fn);
|
330
|
-
};
|
331
|
-
}
|
332
|
-
|
333
|
-
// src/dom/queue.ts
|
334
|
-
var pendingSignals = [], pendingEffects = [], rendering = !1;
|
335
|
-
function queueSource(scope, signal, value2) {
|
336
|
-
return schedule(), rendering = !0, signal(scope, MARK), rendering = !1, pendingSignals.push(scope, signal, value2), value2;
|
337
|
-
}
|
338
|
-
function queueEffect(scope, fn) {
|
339
|
-
pendingEffects.push(scope, fn);
|
340
|
-
}
|
341
|
-
function run() {
|
342
|
-
let signals = pendingSignals, effects = pendingEffects;
|
343
|
-
try {
|
344
|
-
rendering = !0, pendingSignals = [], runSignals(signals);
|
345
|
-
} finally {
|
346
|
-
rendering = !1;
|
347
|
-
}
|
348
|
-
pendingEffects = [], runEffects(effects);
|
349
|
-
}
|
350
|
-
function prepareEffects(fn) {
|
351
|
-
let prevSignals = pendingSignals, prevEffects = pendingEffects, preparedEffects = pendingEffects = [], preparedSignals = pendingSignals = [];
|
352
|
-
try {
|
353
|
-
rendering = !0, fn(), pendingSignals = prevSignals, runSignals(preparedSignals);
|
354
|
-
} finally {
|
355
|
-
rendering = !1, pendingSignals = prevSignals, pendingEffects = prevEffects;
|
356
|
-
}
|
357
|
-
return preparedEffects;
|
358
|
-
}
|
359
|
-
function runEffects(effects = pendingEffects) {
|
360
|
-
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
361
|
-
let scope = effects[i], fn = effects[i + 1];
|
362
|
-
fn(scope, scope);
|
363
|
-
}
|
364
|
-
}
|
365
|
-
function runSignals(signals) {
|
366
|
-
for (let i = 0; i < signals.length; i += 3 /* Total */) {
|
367
|
-
let scope = signals[i + 0 /* Scope */], signal = signals[i + 1 /* Signal */], value2 = signals[i + 2 /* Value */];
|
368
|
-
signal(scope, value2);
|
369
|
-
}
|
370
|
-
}
|
371
|
-
|
372
|
-
// src/dom/abort-signal.ts
|
373
|
-
function resetAbortSignal(scope, id) {
|
374
|
-
let controllers = scope.l;
|
375
|
-
if (controllers) {
|
376
|
-
let ctrl = controllers.get(id);
|
377
|
-
ctrl && (queueEffect(null, () => ctrl.abort()), controllers.delete(id));
|
378
|
-
}
|
379
|
-
}
|
380
|
-
function getAbortSignal(scope, id) {
|
381
|
-
let controllers = scope.l ||= /* @__PURE__ */ new Map(), controller = controllers.get(id);
|
382
|
-
return controller || (onDestroy(scope), controllers.set(id, controller = new AbortController())), controller.signal;
|
383
|
-
}
|
384
|
-
|
385
|
-
// src/common/compat-meta.ts
|
386
|
-
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
387
|
-
|
388
88
|
// src/common/helpers.ts
|
389
89
|
function classValue(value2) {
|
390
90
|
return toDelimitedString(value2, " ", stringifyClassObject);
|
@@ -433,55 +133,55 @@ function normalizeDynamicRenderer(value2) {
|
|
433
133
|
|
434
134
|
// src/dom/reconcile.ts
|
435
135
|
var WRONG_POS = 2147483647;
|
436
|
-
function reconcile(parent,
|
437
|
-
let oldStart = 0, newStart = 0, oldEnd =
|
136
|
+
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
137
|
+
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;
|
438
138
|
outer: {
|
439
|
-
for (;
|
139
|
+
for (; oldStartBranch === newStartBranch; ) {
|
440
140
|
if (++oldStart, ++newStart, oldStart > oldEnd || newStart > newEnd)
|
441
141
|
break outer;
|
442
|
-
|
142
|
+
oldStartBranch = oldBranches[oldStart], newStartBranch = newBranches[newStart];
|
443
143
|
}
|
444
|
-
for (;
|
144
|
+
for (; oldEndBranch === newEndBranch; ) {
|
445
145
|
if (--oldEnd, --newEnd, oldStart > oldEnd || newStart > newEnd)
|
446
146
|
break outer;
|
447
|
-
|
147
|
+
oldEndBranch = oldBranches[oldEnd], newEndBranch = newBranches[newEnd];
|
448
148
|
}
|
449
149
|
}
|
450
150
|
if (oldStart > oldEnd) {
|
451
151
|
if (newStart <= newEnd) {
|
452
|
-
k = newEnd + 1, nextSibling = k <
|
152
|
+
k = newEnd + 1, nextSibling = k < newBranches.length ? newBranches[k].a : afterReference;
|
453
153
|
do
|
454
|
-
insertBefore(
|
154
|
+
insertBefore(newBranches[newStart++], parent, nextSibling);
|
455
155
|
while (newStart <= newEnd);
|
456
156
|
}
|
457
157
|
} else if (newStart > newEnd)
|
458
158
|
do
|
459
|
-
|
159
|
+
removeAndDestroyBranch(oldBranches[oldStart++]);
|
460
160
|
while (oldStart <= oldEnd);
|
461
161
|
else {
|
462
|
-
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable =
|
162
|
+
let oldLength = oldEnd - oldStart + 1, newLength = newEnd - newStart + 1, aNullable = oldBranches, sources = new Array(newLength);
|
463
163
|
for (i = 0; i < newLength; ++i)
|
464
164
|
sources[i] = -1;
|
465
165
|
let pos = 0, synced = 0, keyIndex = /* @__PURE__ */ new Map();
|
466
166
|
for (j = newStart; j <= newEnd; ++j)
|
467
|
-
keyIndex.set(
|
167
|
+
keyIndex.set(newBranches[j], j);
|
468
168
|
for (i = oldStart; i <= oldEnd && synced < newLength; ++i)
|
469
|
-
|
470
|
-
if (oldLength ===
|
169
|
+
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);
|
170
|
+
if (oldLength === oldBranches.length && synced === 0) {
|
471
171
|
for (; newStart < newLength; ++newStart)
|
472
|
-
insertBefore(
|
172
|
+
insertBefore(newBranches[newStart], parent, afterReference);
|
473
173
|
for (; oldStart < oldLength; ++oldStart)
|
474
|
-
|
174
|
+
removeAndDestroyBranch(oldBranches[oldStart]);
|
475
175
|
} else {
|
476
176
|
for (i = oldLength - synced; i > 0; )
|
477
|
-
|
177
|
+
oldBranch = aNullable[oldStart++], oldBranch !== null && (removeAndDestroyBranch(oldBranch), i--);
|
478
178
|
if (pos === WRONG_POS) {
|
479
179
|
let seq = longestIncreasingSubsequence(sources);
|
480
|
-
for (j = seq.length - 1, k =
|
481
|
-
sources[i] === -1 ? (pos = i + newStart,
|
180
|
+
for (j = seq.length - 1, k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
181
|
+
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;
|
482
182
|
} else if (synced !== newLength)
|
483
|
-
for (k =
|
484
|
-
sources[i] === -1 && (pos = i + newStart,
|
183
|
+
for (k = newBranches.length, i = newLength - 1; i >= 0; --i)
|
184
|
+
sources[i] === -1 && (pos = i + newStart, newBranch = newBranches[pos++], nextSibling = pos < k ? newBranches[pos].a : afterReference, insertBefore(newBranch, parent, nextSibling));
|
485
185
|
}
|
486
186
|
}
|
487
187
|
}
|
@@ -526,7 +226,7 @@ function handleDelegated(ev) {
|
|
526
226
|
if (target) {
|
527
227
|
let handlersByElement = elementHandlersByEvent.get(ev.type);
|
528
228
|
if (handlersByElement.get(target)?.(ev, target), ev.bubbles)
|
529
|
-
for (; (target = target.
|
229
|
+
for (; (target = target.parentNode) && !ev.cancelBubble; )
|
530
230
|
handlersByElement.get(target)?.(ev, target);
|
531
231
|
}
|
532
232
|
}
|
@@ -553,6 +253,132 @@ function stripSpacesAndPunctuation(str) {
|
|
553
253
|
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
554
254
|
}
|
555
255
|
|
256
|
+
// src/common/meta.ts
|
257
|
+
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
258
|
+
|
259
|
+
// src/dom/resume.ts
|
260
|
+
var registeredValues = {}, Render = class {
|
261
|
+
o = [];
|
262
|
+
p = {};
|
263
|
+
z = {
|
264
|
+
_: registeredValues
|
265
|
+
};
|
266
|
+
constructor(renders, runtimeId, renderId) {
|
267
|
+
this.A = renders, this.B = runtimeId, this.q = renderId, this.s = renders[renderId], this.t();
|
268
|
+
}
|
269
|
+
w() {
|
270
|
+
this.s.w(), this.t();
|
271
|
+
}
|
272
|
+
t() {
|
273
|
+
let data2 = this.s, serializeContext = this.z, scopeLookup = this.p, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
274
|
+
if (visits.length) {
|
275
|
+
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map();
|
276
|
+
data2.v = [];
|
277
|
+
let branchEnd = (branchId, visit, curNode) => {
|
278
|
+
let branch = scopeLookup[branchId] ||= {}, endNode = curNode;
|
279
|
+
for (; (endNode = endNode.previousSibling).nodeType === 8; ) ;
|
280
|
+
branch.c = endNode, branch.a ||= endNode;
|
281
|
+
for (let [markerScopeId, markerNode] of closestBranchMarkers)
|
282
|
+
branch.a.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2 && (parentBranchIds.set(markerScopeId, branchId), closestBranchMarkers.delete(markerScopeId));
|
283
|
+
return branchIds.add(branchId), closestBranchMarkers.set(branchId, visit), branch;
|
284
|
+
};
|
285
|
+
for (let visit of visits) {
|
286
|
+
let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = commentText.slice(
|
287
|
+
commentPrefixLen + 1,
|
288
|
+
dataIndex ? dataIndex - 1 : commentText.length
|
289
|
+
), scope = scopeLookup[scopeId] ||= {}, data3 = dataIndex ? commentText.slice(dataIndex) : "", token = commentText[commentPrefixLen];
|
290
|
+
if (token === "*" /* Node */)
|
291
|
+
scope[data3] = visit.previousSibling;
|
292
|
+
else if (token === "$" /* ClosestBranch */)
|
293
|
+
closestBranchMarkers.set(scopeId, visit);
|
294
|
+
else if (token === "[" /* BranchStart */)
|
295
|
+
this.f && (dataIndex && branchEnd(this.f, visit, visit), this.o.push(this.f)), this.f = scopeId, scope.a = visit;
|
296
|
+
else if (token === "]" /* BranchEnd */) {
|
297
|
+
scope[data3] = visit;
|
298
|
+
let curParent = visit.parentNode, startNode = branchEnd(
|
299
|
+
this.f,
|
300
|
+
visit,
|
301
|
+
visit
|
302
|
+
).a;
|
303
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.f = this.o.pop();
|
304
|
+
} else if (token === "|" /* BranchSingleNode */) {
|
305
|
+
let next = data3.indexOf(" "), curNode = scope[~next ? data3.slice(0, next) : data3] = visit;
|
306
|
+
for (; ~next; ) {
|
307
|
+
let start = next + 1;
|
308
|
+
next = data3.indexOf(" ", start);
|
309
|
+
let childScopeId = data3.slice(start, ~next ? next : data3.length);
|
310
|
+
curNode = branchEnd(childScopeId, visit, curNode).c;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
}
|
315
|
+
let resumes = data2.r;
|
316
|
+
if (resumes) {
|
317
|
+
data2.r = [];
|
318
|
+
let len = resumes.length, i = 0;
|
319
|
+
try {
|
320
|
+
for (isResuming = !0; i < len; ) {
|
321
|
+
let resumeData = resumes[i++];
|
322
|
+
if (typeof resumeData == "function") {
|
323
|
+
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
324
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.B, $global.renderId = this.q);
|
325
|
+
for (let scopeId in scopes)
|
326
|
+
if (scopeId !== "$") {
|
327
|
+
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
328
|
+
scope.$global = $global, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
|
329
|
+
scope,
|
330
|
+
prevScope
|
331
|
+
));
|
332
|
+
let parentBranchId = parentBranchIds.get(scopeId);
|
333
|
+
if (parentBranchId && (scope.b = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
334
|
+
let branch = scope, parentBranch = branch.b;
|
335
|
+
scope.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch));
|
336
|
+
}
|
337
|
+
}
|
338
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.A[this.q] : registeredValues[resumes[i++]](
|
339
|
+
scopeLookup[resumeData],
|
340
|
+
scopeLookup[resumeData]
|
341
|
+
);
|
342
|
+
}
|
343
|
+
} finally {
|
344
|
+
isResuming = !1;
|
345
|
+
}
|
346
|
+
}
|
347
|
+
}
|
348
|
+
}, isResuming = !1;
|
349
|
+
function register(id, obj) {
|
350
|
+
return registeredValues[id] = obj, obj;
|
351
|
+
}
|
352
|
+
function registerBoundSignal(id, signal) {
|
353
|
+
return registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp), signal;
|
354
|
+
}
|
355
|
+
function getRegisteredWithScope(id, scope) {
|
356
|
+
let val = registeredValues[id];
|
357
|
+
return scope ? val(scope) : val;
|
358
|
+
}
|
359
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
360
|
+
let resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId), renders;
|
361
|
+
window[runtimeId] ? setRenders(window[runtimeId]) : Object.defineProperty(window, runtimeId, {
|
362
|
+
configurable: !0,
|
363
|
+
set: setRenders
|
364
|
+
});
|
365
|
+
function setRenders(v) {
|
366
|
+
renders = v;
|
367
|
+
for (let renderId in v)
|
368
|
+
resumeRender(renderId);
|
369
|
+
Object.defineProperty(window, runtimeId, {
|
370
|
+
configurable: !0,
|
371
|
+
value: resumeRender
|
372
|
+
});
|
373
|
+
}
|
374
|
+
}
|
375
|
+
function registerSubscriber(id, signal) {
|
376
|
+
return register(id, signal.D), signal;
|
377
|
+
}
|
378
|
+
function nodeRef(id, key) {
|
379
|
+
return register(id, (scope) => () => scope[key]);
|
380
|
+
}
|
381
|
+
|
556
382
|
// src/dom/controllable.ts
|
557
383
|
function controllable_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
558
384
|
setCheckboxValue(
|
@@ -606,10 +432,13 @@ function controllable_input_value_effect(scope, nodeAccessor) {
|
|
606
432
|
});
|
607
433
|
}
|
608
434
|
function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
609
|
-
scope[nodeAccessor + ";" /* ControlledHandler */] = valueChange, valueChange ? (scope[nodeAccessor + "=" /* ControlledType */] = 3 /* SelectValue */, scope[nodeAccessor + ":" /* ControlledValue */] = value2) : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */,
|
610
|
-
scope
|
611
|
-
|
612
|
-
|
435
|
+
scope[nodeAccessor + ";" /* ControlledHandler */] = valueChange, valueChange ? (scope[nodeAccessor + "=" /* ControlledType */] = 3 /* SelectValue */, scope[nodeAccessor + ":" /* ControlledValue */] = value2) : scope[nodeAccessor + "=" /* ControlledType */] = 5 /* None */, pendingEffects.unshift(
|
436
|
+
scope,
|
437
|
+
() => setSelectOptions(
|
438
|
+
scope[nodeAccessor],
|
439
|
+
value2,
|
440
|
+
valueChange
|
441
|
+
)
|
613
442
|
);
|
614
443
|
}
|
615
444
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
@@ -723,16 +552,22 @@ function toValueProp(it) {
|
|
723
552
|
}
|
724
553
|
|
725
554
|
// src/dom/parse-html.ts
|
726
|
-
var fallback = /* @__PURE__ */
|
555
|
+
var fallback = /* @__PURE__ */ new Text(), parser = /* @__PURE__ */ document.createElement("template");
|
727
556
|
function parseHTML(html2) {
|
728
|
-
return parser.
|
557
|
+
return parser.innerHTML = html2, parser.content;
|
729
558
|
}
|
730
559
|
function parseHTMLOrSingleNode(html2) {
|
731
560
|
let content = parseHTML(html2);
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
561
|
+
if (content.firstChild) {
|
562
|
+
if (content.firstChild === content.lastChild && // If the firstChild is a comment it's possible its
|
563
|
+
// a single replaced node, in which case the walker can't replace
|
564
|
+
// the node itself.
|
565
|
+
content.firstChild.nodeType !== 8)
|
566
|
+
return content.firstChild;
|
567
|
+
let fragment = new DocumentFragment();
|
568
|
+
return fragment.appendChild(content), fragment;
|
569
|
+
}
|
570
|
+
return fallback;
|
736
571
|
}
|
737
572
|
|
738
573
|
// src/dom/dom.ts
|
@@ -758,8 +593,10 @@ function textContent(node, value2) {
|
|
758
593
|
}
|
759
594
|
function attrs(scope, nodeAccessor, nextAttrs) {
|
760
595
|
let el = scope[nodeAccessor];
|
761
|
-
for (let
|
596
|
+
for (let i = el.attributes.length; i--; ) {
|
597
|
+
let { name } = el.attributes.item(i);
|
762
598
|
nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)) || el.removeAttribute(name);
|
599
|
+
}
|
763
600
|
attrsInternal(scope, nodeAccessor, nextAttrs);
|
764
601
|
}
|
765
602
|
function hasAttrAlias(element, attr2, nextAttrs) {
|
@@ -767,8 +604,10 @@ function hasAttrAlias(element, attr2, nextAttrs) {
|
|
767
604
|
}
|
768
605
|
function partialAttrs(scope, nodeAccessor, nextAttrs, skip) {
|
769
606
|
let el = scope[nodeAccessor], partial = {};
|
770
|
-
for (let
|
607
|
+
for (let i = el.attributes.length; i--; ) {
|
608
|
+
let { name } = el.attributes.item(i);
|
771
609
|
!skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
|
610
|
+
}
|
772
611
|
for (let key in nextAttrs)
|
773
612
|
skip[key] || (partial[key] = nextAttrs[key]);
|
774
613
|
attrsInternal(scope, nodeAccessor, partial);
|
@@ -908,11 +747,11 @@ function trimWalkString(walkString) {
|
|
908
747
|
return walkString.slice(0, end + 1);
|
909
748
|
}
|
910
749
|
function walk(startNode, walkCodes, scope) {
|
911
|
-
walker.currentNode = startNode, walkInternal(walkCodes, scope,
|
750
|
+
walker.currentNode = startNode, walkInternal(walkCodes, scope, 0), walker.currentNode = document;
|
912
751
|
}
|
913
|
-
function walkInternal(walkCodes, scope,
|
752
|
+
function walkInternal(walkCodes, scope, currentWalkIndex) {
|
914
753
|
let value2, storedMultiplier = 0, currentMultiplier = 0, currentScopeIndex = 0;
|
915
|
-
for (
|
754
|
+
for (; value2 = walkCodes.charCodeAt(currentWalkIndex++); )
|
916
755
|
if (currentMultiplier = storedMultiplier, storedMultiplier = 0, value2 >= 117 /* Multiplier */)
|
917
756
|
storedMultiplier = currentMultiplier * 10 /* Multiplier */ + value2 - 117 /* Multiplier */;
|
918
757
|
else if (value2 >= 107 /* Out */) {
|
@@ -925,20 +764,16 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
925
764
|
else if (value2 >= 67 /* Next */)
|
926
765
|
for (value2 = 20 /* Next */ * currentMultiplier + value2 - 67 /* Next */; value2--; )
|
927
766
|
walker.nextNode();
|
928
|
-
else if (value2 === 47 /* BeginChild */)
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
cleanupOwnerScope,
|
933
|
-
currentWalkIndex
|
934
|
-
);
|
935
|
-
else {
|
767
|
+
else if (value2 === 47 /* BeginChild */) {
|
768
|
+
let childScope = scope[currentScopeIndex++] = createScope(scope.$global);
|
769
|
+
childScope.a = walker.currentNode, childScope.b = scope.b, currentWalkIndex = walkInternal(walkCodes, childScope, currentWalkIndex);
|
770
|
+
} else {
|
936
771
|
if (value2 === 38 /* EndChild */)
|
937
772
|
return currentWalkIndex;
|
938
773
|
if (value2 === 32 /* Get */)
|
939
774
|
scope[currentScopeIndex++] = walker.currentNode;
|
940
775
|
else {
|
941
|
-
let newNode = scope[currentScopeIndex++] =
|
776
|
+
let newNode = scope[currentScopeIndex++] = new Text(), current = walker.currentNode;
|
942
777
|
current.parentNode.replaceChild(newNode, current), walker.currentNode = newNode;
|
943
778
|
}
|
944
779
|
}
|
@@ -946,26 +781,35 @@ function walkInternal(walkCodes, scope, cleanupOwnerScope, currentWalkIndex) {
|
|
946
781
|
}
|
947
782
|
|
948
783
|
// src/dom/renderer.ts
|
949
|
-
function
|
950
|
-
let
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
784
|
+
function createBranchScopeWithRenderer(renderer, $global, parentScope) {
|
785
|
+
let branch = createBranch(
|
786
|
+
$global,
|
787
|
+
renderer.u || parentScope,
|
788
|
+
parentScope
|
789
|
+
);
|
790
|
+
return initRenderer(renderer, branch), branch;
|
791
|
+
}
|
792
|
+
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope) {
|
957
793
|
if (typeof tagNameOrRenderer != "string")
|
958
|
-
return
|
959
|
-
|
960
|
-
|
794
|
+
return createBranchScopeWithRenderer(
|
795
|
+
tagNameOrRenderer,
|
796
|
+
$global,
|
797
|
+
parentScope
|
798
|
+
);
|
799
|
+
let branch = createBranch($global, parentScope, parentScope);
|
800
|
+
return branch[0] = branch.a = branch.c = document.createElement(tagNameOrRenderer), branch;
|
801
|
+
}
|
802
|
+
function createBranch($global, ownerScope, parentScope) {
|
803
|
+
let branch = createScope($global), parentBranch = parentScope.b;
|
804
|
+
return branch._ = ownerScope, branch.b = branch, parentBranch && (branch.C = parentBranch, (parentBranch.m ||= /* @__PURE__ */ new Set()).add(branch)), branch;
|
961
805
|
}
|
962
806
|
function initRenderer(renderer, scope) {
|
963
|
-
let dom = renderer.
|
807
|
+
let dom = renderer.l();
|
964
808
|
return walk(
|
965
809
|
dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom,
|
966
|
-
renderer.
|
810
|
+
renderer.E,
|
967
811
|
scope
|
968
|
-
), scope.a = dom.nodeType === 11 /* DocumentFragment */ ? dom.firstChild : dom, scope.
|
812
|
+
), 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;
|
969
813
|
}
|
970
814
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
971
815
|
return (scope, attrsOrOp) => {
|
@@ -992,36 +836,27 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
992
836
|
}
|
993
837
|
};
|
994
838
|
}
|
995
|
-
function createRendererWithOwner(template, rawWalks, setup,
|
996
|
-
let args,
|
839
|
+
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
840
|
+
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
997
841
|
return (owner) => ({
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
842
|
+
j: id,
|
843
|
+
F: template,
|
844
|
+
E: walks,
|
845
|
+
x: setup,
|
846
|
+
l: _clone,
|
847
|
+
u: owner,
|
848
|
+
G: void 0,
|
1005
849
|
get e() {
|
1006
850
|
return args ||= getArgs?.();
|
1007
|
-
},
|
1008
|
-
get c() {
|
1009
|
-
return closureSignals ||= new Set(getClosureSignals?.());
|
1010
851
|
}
|
1011
852
|
});
|
1012
853
|
}
|
1013
|
-
function createRenderer(template, walks, setup,
|
1014
|
-
return createRendererWithOwner(
|
1015
|
-
template,
|
1016
|
-
walks,
|
1017
|
-
setup,
|
1018
|
-
getClosureSignals,
|
1019
|
-
getArgs
|
1020
|
-
)();
|
854
|
+
function createRenderer(template, walks, setup, getArgs) {
|
855
|
+
return createRendererWithOwner(template, walks, setup, getArgs)();
|
1021
856
|
}
|
1022
857
|
function _clone() {
|
1023
|
-
return (this.
|
1024
|
-
this.
|
858
|
+
return (this.G ||= parseHTMLOrSingleNode(
|
859
|
+
this.F
|
1025
860
|
)).cloneNode(!0);
|
1026
861
|
}
|
1027
862
|
|
@@ -1030,41 +865,27 @@ function patchConditionals(fn) {
|
|
1030
865
|
conditional = fn(conditional), conditionalOnlyChild = fn(conditionalOnlyChild);
|
1031
866
|
}
|
1032
867
|
var conditional = function(nodeAccessor, fn, getIntersection) {
|
1033
|
-
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */,
|
868
|
+
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1034
869
|
return (scope, newRendererOrOp) => {
|
1035
870
|
if (newRendererOrOp === DIRTY) return;
|
1036
871
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
1037
872
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1038
873
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1039
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (
|
874
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (setConditionalRenderer(scope, nodeAccessor, normalizedRenderer), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1040
875
|
}
|
1041
|
-
intersection2?.(scope, op)
|
876
|
+
intersection2?.(scope, op);
|
1042
877
|
};
|
1043
878
|
};
|
1044
|
-
function inConditionalScope(signal, nodeAccessor) {
|
1045
|
-
let scopeAccessor = nodeAccessor + "!" /* ConditionalScope */, rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1046
|
-
return (scope, op) => {
|
1047
|
-
let conditionalScope = scope[scopeAccessor];
|
1048
|
-
if (conditionalScope) {
|
1049
|
-
let conditionalRenderer = scope[rendererAccessor];
|
1050
|
-
(!conditionalRenderer?.c || conditionalRenderer.c.has(signal)) && signal(conditionalScope, op);
|
1051
|
-
}
|
1052
|
-
};
|
1053
|
-
}
|
1054
879
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
1055
|
-
let
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
),
|
1061
|
-
newScope,
|
1062
|
-
prevScope.a.parentNode,
|
1063
|
-
prevScope.a
|
1064
|
-
), removeAndDestroyScope(prevScope);
|
880
|
+
let newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0, prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyScope(scope[nodeAccessor]);
|
881
|
+
insertBefore(
|
882
|
+
newBranch || getEmptyScope(scope[nodeAccessor]),
|
883
|
+
prevBranch.a.parentNode,
|
884
|
+
prevBranch.a
|
885
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "(" /* ConditionalRenderer */] = newRenderer, scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1065
886
|
}
|
1066
887
|
var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
1067
|
-
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */,
|
888
|
+
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1068
889
|
return (scope, newRendererOrOp) => {
|
1069
890
|
if (newRendererOrOp === DIRTY) return;
|
1070
891
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
@@ -1076,18 +897,16 @@ var conditionalOnlyChild = function(nodeAccessor, fn, getIntersection) {
|
|
1076
897
|
normalizedRenderer
|
1077
898
|
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1078
899
|
}
|
1079
|
-
intersection2?.(scope, op)
|
900
|
+
intersection2?.(scope, op);
|
1080
901
|
};
|
1081
902
|
};
|
1082
903
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1083
|
-
let
|
1084
|
-
|
1085
|
-
let newScope = scope[nodeAccessor + "!" /* ConditionalScope */] = createScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope);
|
1086
|
-
insertBefore(newScope, referenceNode, null);
|
1087
|
-
}
|
1088
|
-
prevScope && destroyScope(prevScope);
|
904
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer ? createBranchScopeWithTagNameOrRenderer(newRenderer, scope.$global, scope) : void 0;
|
905
|
+
referenceNode.textContent = "", newBranch && insertBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1089
906
|
}
|
1090
|
-
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
907
|
+
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
908
|
+
[Symbol(), getEmptyScope(void 0)]
|
909
|
+
]), emptyMarkerArray = [
|
1091
910
|
/* @__PURE__ */ getEmptyScope(void 0)
|
1092
911
|
], emptyMap = /* @__PURE__ */ new Map(), emptyArray = [];
|
1093
912
|
function loopOf(nodeAccessor, renderer) {
|
@@ -1117,31 +936,25 @@ function loopTo(nodeAccessor, renderer) {
|
|
1117
936
|
);
|
1118
937
|
}
|
1119
938
|
function loop(nodeAccessor, renderer, forEach) {
|
1120
|
-
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */,
|
939
|
+
let loopScopeAccessor = nodeAccessor + "!" /* LoopScopeArray */, params = renderer.e;
|
1121
940
|
return (scope, valueOrOp) => {
|
1122
941
|
if (valueOrOp === DIRTY) return;
|
1123
942
|
if (valueOrOp === MARK || valueOrOp === CLEAN) {
|
1124
|
-
let
|
1125
|
-
if (
|
1126
|
-
for (let
|
1127
|
-
params?.(
|
1128
|
-
for (let signal of closureSignals)
|
1129
|
-
signal(childScope, valueOrOp);
|
1130
|
-
}
|
943
|
+
let loopBranches = scope[loopScopeAccessor] ?? scope[nodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
944
|
+
if (loopBranches !== emptyMarkerArray)
|
945
|
+
for (let branch of loopBranches)
|
946
|
+
params?.(branch, valueOrOp);
|
1131
947
|
return;
|
1132
948
|
}
|
1133
949
|
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;
|
1134
950
|
if (forEach(valueOrOp, (key, args) => {
|
1135
|
-
let
|
1136
|
-
|
1137
|
-
|
1138
|
-
signal(childScope, closureOp);
|
1139
|
-
newMap ? (newMap.set(key, childScope), newArray.push(childScope)) : (newMap = /* @__PURE__ */ new Map([[key, childScope]]), newArray = [childScope]);
|
1140
|
-
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyScope), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
951
|
+
let branch = oldMap.get(key);
|
952
|
+
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]);
|
953
|
+
}), newMap || (referenceIsMarker ? (newMap = emptyMarkerMap, newArray = emptyMarkerArray, getEmptyScope(referenceNode)) : (oldArray.forEach(destroyBranch), referenceNode.textContent = "", newMap = emptyMap, newArray = emptyArray, needsReconciliation = !1)), needsReconciliation) {
|
1141
954
|
if (referenceIsMarker) {
|
1142
955
|
oldMap === emptyMarkerMap && getEmptyScope(referenceNode);
|
1143
956
|
let oldLastChild = oldArray[oldArray.length - 1];
|
1144
|
-
afterReference = oldLastChild.
|
957
|
+
afterReference = oldLastChild.c.nextSibling, parentNode = oldLastChild.a.parentNode;
|
1145
958
|
} else
|
1146
959
|
afterReference = null, parentNode = referenceNode;
|
1147
960
|
reconcile(parentNode, oldArray, newArray, afterReference);
|
@@ -1149,15 +962,6 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1149
962
|
scope[nodeAccessor + "(" /* LoopScopeMap */] = newMap, scope[nodeAccessor + "!" /* LoopScopeArray */] = newArray;
|
1150
963
|
};
|
1151
964
|
}
|
1152
|
-
function inLoopScope(signal, loopNodeAccessor) {
|
1153
|
-
let loopScopeAccessor = loopNodeAccessor + "!" /* LoopScopeArray */;
|
1154
|
-
return (scope, op) => {
|
1155
|
-
let loopScopes = scope[loopScopeAccessor] ?? scope[loopNodeAccessor + "(" /* LoopScopeMap */]?.values() ?? [];
|
1156
|
-
if (loopScopes !== emptyMarkerArray)
|
1157
|
-
for (let scope2 of loopScopes)
|
1158
|
-
signal(scope2, op);
|
1159
|
-
};
|
1160
|
-
}
|
1161
965
|
function bySecondArg(_item, index) {
|
1162
966
|
return index;
|
1163
967
|
}
|
@@ -1165,9 +969,185 @@ function byFirstArg(name) {
|
|
1165
969
|
return name;
|
1166
970
|
}
|
1167
971
|
function isDifferentRenderer(a, b) {
|
1168
|
-
return a !== b && (a?.
|
972
|
+
return a !== b && (a?.j || 0) !== b?.j;
|
973
|
+
}
|
974
|
+
|
975
|
+
// src/dom/signals.ts
|
976
|
+
var MARK = {}, CLEAN = {}, DIRTY = {};
|
977
|
+
function state(valueAccessor, fn, getIntersection) {
|
978
|
+
let valueSignal = value(valueAccessor, fn, getIntersection), markAccessor = valueAccessor + "#" /* Mark */, valueChangeAccessor = valueAccessor + "@" /* TagVariableChange */;
|
979
|
+
return (scope, valueOrOp, valueChange) => (rendering ? valueSignal(
|
980
|
+
scope,
|
981
|
+
valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY || (scope[valueChangeAccessor] = valueChange) || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
982
|
+
) : scope[valueChangeAccessor] ? scope[valueChangeAccessor](valueOrOp) : queueSource(scope, valueSignal, valueOrOp), valueOrOp);
|
983
|
+
}
|
984
|
+
function value(valueAccessor, fn, getIntersection) {
|
985
|
+
let markAccessor = valueAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
986
|
+
return (scope, valueOrOp) => {
|
987
|
+
if (valueOrOp === MARK)
|
988
|
+
(scope[markAccessor] = (scope[markAccessor] ?? 0) + 1) === 1 && intersection2?.(scope, MARK);
|
989
|
+
else if (valueOrOp !== DIRTY) {
|
990
|
+
let existing = scope[markAccessor] !== void 0;
|
991
|
+
(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]--;
|
992
|
+
}
|
993
|
+
};
|
994
|
+
}
|
995
|
+
var accessorId = 0;
|
996
|
+
function intersection(count, fn, getIntersection) {
|
997
|
+
let dirtyAccessor = "?" /* Dynamic */ + accessorId++, markAccessor = dirtyAccessor + "#" /* Mark */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
998
|
+
return (scope, op) => {
|
999
|
+
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;
|
1000
|
+
};
|
1001
|
+
}
|
1002
|
+
function closure(fn, getIntersection) {
|
1003
|
+
let intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
1004
|
+
return (scope, valueOrOp) => {
|
1005
|
+
valueOrOp === MARK ? intersection2?.(scope, MARK) : (fn && fn(scope, valueOrOp), intersection2?.(scope, DIRTY));
|
1006
|
+
};
|
1007
|
+
}
|
1008
|
+
function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
1009
|
+
let signal = closure(fn, getIntersection), loopScopeAccessor = ownerLoopNodeAccessor + "!" /* LoopScopeArray */, loopScopeMapAccessor = ownerLoopNodeAccessor + "(" /* LoopScopeMap */, helperSignal = (ownerScope, value2) => {
|
1010
|
+
let loopScopes = ownerScope[loopScopeAccessor] ?? ownerScope[loopScopeMapAccessor]?.values() ?? [];
|
1011
|
+
if (loopScopes !== emptyMarkerArray)
|
1012
|
+
for (let scope of loopScopes)
|
1013
|
+
scope.g || queueSource(scope, signal, value2);
|
1014
|
+
};
|
1015
|
+
return helperSignal._ = signal, helperSignal;
|
1016
|
+
}
|
1017
|
+
function conditionalClosure(ownerConditionalNodeAccessor, getRenderer, fn, getIntersection) {
|
1018
|
+
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, rendererAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1019
|
+
let conditionalScope = scope[scopeAccessor];
|
1020
|
+
conditionalScope && !conditionalScope.g && scope[rendererAccessor]?.j === getRenderer().j && queueSource(conditionalScope, signal, value2);
|
1021
|
+
};
|
1022
|
+
return helperSignal._ = signal, helperSignal;
|
1023
|
+
}
|
1024
|
+
var defaultGetOwnerScope = (scope) => scope._;
|
1025
|
+
function dynamicClosure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, getIntersection) {
|
1026
|
+
let ownerSubscribersAccessor = ownerValueAccessor + "*" /* Subscribers */, _signal = closure(fn, getIntersection), helperSignal = (ownerScope, value2) => {
|
1027
|
+
let subscribers = ownerScope[ownerSubscribersAccessor];
|
1028
|
+
if (subscribers)
|
1029
|
+
for (let subscriber of subscribers)
|
1030
|
+
subscriber.g || queueSource(subscriber, _signal, value2);
|
1031
|
+
}, setupSignal = (scope, value2) => {
|
1032
|
+
_signal(scope, value2), subscribe(scope);
|
1033
|
+
}, subscribe = (scope) => {
|
1034
|
+
(getOwnerScope(scope)[ownerSubscribersAccessor] ||= /* @__PURE__ */ new Set()).add(scope), getAbortSignal(scope, -1).addEventListener("abort", () => {
|
1035
|
+
getOwnerScope(scope)[ownerSubscribersAccessor].delete(scope);
|
1036
|
+
});
|
1037
|
+
};
|
1038
|
+
return helperSignal._ = setupSignal, helperSignal.D = subscribe, helperSignal;
|
1039
|
+
}
|
1040
|
+
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1041
|
+
scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
|
1042
|
+
}
|
1043
|
+
var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
|
1044
|
+
function setTagVarChange(scope, changeHandler) {
|
1045
|
+
scope["@" /* TagVariableChange */] = changeHandler;
|
1046
|
+
}
|
1047
|
+
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1048
|
+
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1049
|
+
function nextTagId({ $global }) {
|
1050
|
+
let id = tagIdsByGlobal.get($global) || 0;
|
1051
|
+
return tagIdsByGlobal.set($global, id + 1), "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
1052
|
+
}
|
1053
|
+
function inChild(childAccessor, signal) {
|
1054
|
+
return (scope, valueOrOp) => {
|
1055
|
+
signal(scope[childAccessor], valueOrOp);
|
1056
|
+
};
|
1057
|
+
}
|
1058
|
+
function intersections(signals) {
|
1059
|
+
return (scope, op) => {
|
1060
|
+
for (let signal of signals)
|
1061
|
+
signal(scope, op);
|
1062
|
+
};
|
1063
|
+
}
|
1064
|
+
function effect(id, fn) {
|
1065
|
+
return register(id, fn), (scope) => {
|
1066
|
+
queueEffect(scope, fn);
|
1067
|
+
};
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
// src/dom/queue.ts
|
1071
|
+
var pendingRender, pendingEffects = [], rendering = !1;
|
1072
|
+
function queueSource(scope, signal, value2) {
|
1073
|
+
schedule();
|
1074
|
+
let prevRendering = rendering;
|
1075
|
+
return rendering = !0, signal(scope, MARK), rendering = prevRendering, queueRender(scope, signal, value2), value2;
|
1076
|
+
}
|
1077
|
+
function queueRender(scope, signal, value2) {
|
1078
|
+
let nextRender = {
|
1079
|
+
k: scope,
|
1080
|
+
H: signal,
|
1081
|
+
I: value2,
|
1082
|
+
d: void 0
|
1083
|
+
};
|
1084
|
+
if (!pendingRender)
|
1085
|
+
pendingRender = nextRender;
|
1086
|
+
else if (comparePendingRenders(pendingRender, nextRender) < 0)
|
1087
|
+
nextRender.d = pendingRender, pendingRender = nextRender;
|
1088
|
+
else {
|
1089
|
+
let curRender = pendingRender;
|
1090
|
+
for (; curRender.d && comparePendingRenders(curRender.d, nextRender) >= 0; )
|
1091
|
+
curRender = curRender.d;
|
1092
|
+
nextRender.d = curRender.d, curRender.d = nextRender;
|
1093
|
+
}
|
1094
|
+
}
|
1095
|
+
function queueEffect(scope, fn) {
|
1096
|
+
pendingEffects.push(scope, fn);
|
1097
|
+
}
|
1098
|
+
function run() {
|
1099
|
+
let effects = pendingEffects;
|
1100
|
+
try {
|
1101
|
+
rendering = !0, runRenders();
|
1102
|
+
} finally {
|
1103
|
+
pendingRender = void 0, rendering = !1;
|
1104
|
+
}
|
1105
|
+
pendingEffects = [], runEffects(effects);
|
1106
|
+
}
|
1107
|
+
function prepareEffects(fn) {
|
1108
|
+
let prevRender = pendingRender, prevEffects = pendingEffects, preparedEffects = pendingEffects = [];
|
1109
|
+
pendingRender = void 0;
|
1110
|
+
try {
|
1111
|
+
rendering = !0, fn(), runRenders();
|
1112
|
+
} finally {
|
1113
|
+
rendering = !1, pendingRender = prevRender, pendingEffects = prevEffects;
|
1114
|
+
}
|
1115
|
+
return preparedEffects;
|
1116
|
+
}
|
1117
|
+
function runEffects(effects = pendingEffects) {
|
1118
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
1119
|
+
let scope = effects[i], fn = effects[i + 1];
|
1120
|
+
fn(scope, scope);
|
1121
|
+
}
|
1122
|
+
}
|
1123
|
+
function runRenders() {
|
1124
|
+
for (; pendingRender; )
|
1125
|
+
pendingRender.k.b?.y || pendingRender.H(pendingRender.k, pendingRender.I), pendingRender = pendingRender.d;
|
1126
|
+
finishPendingScopes();
|
1127
|
+
}
|
1128
|
+
function comparePendingRenders(a, b) {
|
1129
|
+
let aStart = ownerStartNode(a.k), bStart = ownerStartNode(b.k);
|
1130
|
+
return aStart === bStart ? 0 : aStart ? bStart ? aStart.compareDocumentPosition(bStart) & 2 ? -1 : 1 : -1 : 1;
|
1131
|
+
}
|
1132
|
+
function ownerStartNode(scope) {
|
1133
|
+
return (scope.b || scope).a;
|
1134
|
+
}
|
1135
|
+
|
1136
|
+
// src/dom/abort-signal.ts
|
1137
|
+
function resetAbortSignal(scope, id) {
|
1138
|
+
let ctrl = scope.h?.[id];
|
1139
|
+
ctrl && (queueEffect(ctrl, abort), scope.h[id] = void 0);
|
1140
|
+
}
|
1141
|
+
function getAbortSignal(scope, id) {
|
1142
|
+
return scope.b && (scope.b.n ||= /* @__PURE__ */ new Set()).add(scope), ((scope.h ||= {})[id] ||= new AbortController()).signal;
|
1143
|
+
}
|
1144
|
+
function abort(ctrl) {
|
1145
|
+
ctrl.abort();
|
1169
1146
|
}
|
1170
1147
|
|
1148
|
+
// src/common/compat-meta.ts
|
1149
|
+
var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
|
1150
|
+
|
1171
1151
|
// src/dom/compat.ts
|
1172
1152
|
var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
1173
1153
|
patchConditionals,
|
@@ -1184,35 +1164,32 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1184
1164
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1185
1165
|
},
|
1186
1166
|
isRenderer(renderer) {
|
1187
|
-
return renderer.
|
1167
|
+
return renderer.l !== void 0;
|
1188
1168
|
},
|
1189
1169
|
getStartNode(scope) {
|
1190
1170
|
return scope.a;
|
1191
1171
|
},
|
1192
1172
|
setScopeNodes(scope, startNode, endNode) {
|
1193
|
-
scope.a = startNode, scope.
|
1173
|
+
scope.a = startNode, scope.c = endNode;
|
1194
1174
|
},
|
1195
1175
|
runComponentEffects() {
|
1196
1176
|
runEffects(this.effects);
|
1197
1177
|
},
|
1178
|
+
runComponentDestroy() {
|
1179
|
+
this.scope && destroyBranch(this.scope);
|
1180
|
+
},
|
1198
1181
|
resolveRegistered(value2, {
|
1199
1182
|
runtimeId,
|
1200
1183
|
componentIdPrefix
|
1201
1184
|
}) {
|
1202
1185
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1203
1186
|
value2[0],
|
1204
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1187
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.p[value2[1]]
|
1205
1188
|
) : value2;
|
1206
1189
|
},
|
1207
1190
|
createRenderer(setup, clone, args) {
|
1208
|
-
let renderer = createRenderer(
|
1209
|
-
|
1210
|
-
void 0,
|
1211
|
-
setup,
|
1212
|
-
void 0,
|
1213
|
-
args && (() => args)
|
1214
|
-
);
|
1215
|
-
return renderer.k = clone, renderer;
|
1191
|
+
let renderer = createRenderer("", void 0, setup, args && (() => args));
|
1192
|
+
return renderer.l = clone, renderer;
|
1216
1193
|
},
|
1217
1194
|
render(out, component, renderer, args) {
|
1218
1195
|
let scope = component.scope;
|
@@ -1224,18 +1201,9 @@ var classIdToScope = /* @__PURE__ */ new Map(), compat = {
|
|
1224
1201
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1225
1202
|
}
|
1226
1203
|
if (component.effects = prepareEffects(() => {
|
1227
|
-
|
1228
|
-
applyArgs(scope, MARK), existing = !0;
|
1229
|
-
else {
|
1230
|
-
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
1231
|
-
let closures = renderer.c;
|
1232
|
-
if (closures)
|
1233
|
-
for (let signal of closures)
|
1234
|
-
signal(component.scope, CLEAN);
|
1235
|
-
}
|
1236
|
-
applyArgs(scope, args);
|
1204
|
+
scope ? (applyArgs(scope, MARK), existing = !0) : (scope = component.scope = createScope(out.global), scope._ = renderer.u, initRenderer(renderer, scope)), applyArgs(scope, args);
|
1237
1205
|
}), !existing)
|
1238
|
-
return scope.a === scope.
|
1206
|
+
return scope.a === scope.c ? scope.a : scope.a.parentNode;
|
1239
1207
|
}
|
1240
1208
|
};
|
1241
1209
|
function noop() {
|
@@ -1247,7 +1215,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
1247
1215
|
return renderer.mount = mount, renderer._ = renderer, register(templateId, renderer);
|
1248
1216
|
};
|
1249
1217
|
function mount(input = {}, reference, position) {
|
1250
|
-
let
|
1218
|
+
let branch, dom, { $global } = input;
|
1251
1219
|
$global ? ({ $global, ...input } = input, $global = {
|
1252
1220
|
runtimeId: DEFAULT_RUNTIME_ID,
|
1253
1221
|
renderId: DEFAULT_RENDER_ID,
|
@@ -1257,17 +1225,17 @@ function mount(input = {}, reference, position) {
|
|
1257
1225
|
renderId: DEFAULT_RENDER_ID
|
1258
1226
|
};
|
1259
1227
|
let args = this.e, effects = prepareEffects(() => {
|
1260
|
-
|
1228
|
+
branch = createScope($global), dom = initRenderer(this, branch), args && args(branch, [input]);
|
1261
1229
|
});
|
1262
1230
|
switch (position) {
|
1231
|
+
case "beforebegin":
|
1232
|
+
reference.parentNode.insertBefore(dom, reference);
|
1233
|
+
break;
|
1263
1234
|
case "afterbegin":
|
1264
1235
|
reference.insertBefore(dom, reference.firstChild);
|
1265
1236
|
break;
|
1266
1237
|
case "afterend":
|
1267
|
-
reference.
|
1268
|
-
break;
|
1269
|
-
case "beforebegin":
|
1270
|
-
reference.parentElement.insertBefore(dom, reference);
|
1238
|
+
reference.parentNode.insertBefore(dom, reference.nextSibling);
|
1271
1239
|
break;
|
1272
1240
|
default:
|
1273
1241
|
reference.appendChild(dom);
|
@@ -1277,12 +1245,12 @@ function mount(input = {}, reference, position) {
|
|
1277
1245
|
update: (newInput) => {
|
1278
1246
|
args && runEffects(
|
1279
1247
|
prepareEffects(() => {
|
1280
|
-
args(
|
1248
|
+
args(branch, MARK), args(branch, [newInput]);
|
1281
1249
|
})
|
1282
1250
|
);
|
1283
1251
|
},
|
1284
1252
|
destroy: () => {
|
1285
|
-
|
1253
|
+
removeAndDestroyBranch(branch);
|
1286
1254
|
}
|
1287
1255
|
};
|
1288
1256
|
}
|
@@ -1292,11 +1260,10 @@ export {
|
|
1292
1260
|
attrTags,
|
1293
1261
|
attrs,
|
1294
1262
|
attrsEvents,
|
1295
|
-
childClosures,
|
1296
1263
|
classAttr,
|
1297
|
-
closure,
|
1298
1264
|
compat,
|
1299
1265
|
conditional,
|
1266
|
+
conditionalClosure,
|
1300
1267
|
conditionalOnlyChild,
|
1301
1268
|
controllable_detailsOrDialog_open,
|
1302
1269
|
controllable_detailsOrDialog_open_effect,
|
@@ -1316,7 +1283,6 @@ export {
|
|
1316
1283
|
createTemplate,
|
1317
1284
|
data,
|
1318
1285
|
dynamicClosure,
|
1319
|
-
dynamicSubscribers,
|
1320
1286
|
dynamicTagAttrs,
|
1321
1287
|
effect,
|
1322
1288
|
forIn,
|
@@ -1325,12 +1291,11 @@ export {
|
|
1325
1291
|
getAbortSignal,
|
1326
1292
|
html,
|
1327
1293
|
inChild,
|
1328
|
-
inConditionalScope,
|
1329
|
-
inLoopScope,
|
1330
1294
|
init,
|
1331
1295
|
intersection,
|
1332
1296
|
intersections,
|
1333
1297
|
lifecycle,
|
1298
|
+
loopClosure,
|
1334
1299
|
loopIn,
|
1335
1300
|
loopOf,
|
1336
1301
|
loopTo,
|