@marko/runtime-tags 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/dom.js +587 -623
- package/dist/debug/dom.mjs +587 -623
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/control-flow.d.ts +2 -2
- package/dist/dom/queue.d.ts +2 -4
- package/dist/dom/renderer.d.ts +2 -3
- package/dist/dom/signals.d.ts +5 -5
- package/dist/dom/template.d.ts +2 -3
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +343 -376
- package/dist/dom.mjs +343 -376
- package/dist/html/template.d.ts +1 -1
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -25,7 +25,6 @@ __export(dom_exports, {
|
|
|
25
25
|
attrTags: () => attrTags,
|
|
26
26
|
attrs: () => attrs,
|
|
27
27
|
attrsEvents: () => attrsEvents,
|
|
28
|
-
changeHandler: () => changeHandler,
|
|
29
28
|
childClosures: () => childClosures,
|
|
30
29
|
classAttr: () => classAttr,
|
|
31
30
|
closure: () => closure,
|
|
@@ -52,6 +51,7 @@ __export(dom_exports, {
|
|
|
52
51
|
dynamicClosure: () => dynamicClosure,
|
|
53
52
|
dynamicSubscribers: () => dynamicSubscribers,
|
|
54
53
|
dynamicTagAttrs: () => dynamicTagAttrs,
|
|
54
|
+
effect: () => effect,
|
|
55
55
|
forIn: () => forIn,
|
|
56
56
|
forOf: () => forOf,
|
|
57
57
|
forTo: () => forTo,
|
|
@@ -61,7 +61,6 @@ __export(dom_exports, {
|
|
|
61
61
|
inConditionalScope: () => inConditionalScope,
|
|
62
62
|
inLoopScope: () => inLoopScope,
|
|
63
63
|
init: () => init,
|
|
64
|
-
initValue: () => initValue,
|
|
65
64
|
intersection: () => intersection,
|
|
66
65
|
intersections: () => intersections,
|
|
67
66
|
lifecycle: () => lifecycle,
|
|
@@ -72,18 +71,14 @@ __export(dom_exports, {
|
|
|
72
71
|
nodeRef: () => nodeRef,
|
|
73
72
|
on: () => on,
|
|
74
73
|
partialAttrs: () => partialAttrs,
|
|
75
|
-
prepare: () => prepare,
|
|
76
74
|
props: () => props,
|
|
77
|
-
queueControllableSource: () => queueControllableSource,
|
|
78
|
-
queueEffect: () => queueEffect,
|
|
79
|
-
queueSource: () => queueSource,
|
|
80
75
|
register: () => register,
|
|
81
76
|
registerBoundSignal: () => registerBoundSignal,
|
|
82
77
|
registerSubscriber: () => registerSubscriber,
|
|
83
78
|
resetAbortSignal: () => resetAbortSignal,
|
|
84
79
|
run: () => run,
|
|
85
|
-
runEffects: () => runEffects,
|
|
86
80
|
setTagVar: () => setTagVar,
|
|
81
|
+
state: () => state,
|
|
87
82
|
styleAttr: () => styleAttr,
|
|
88
83
|
tagVarSignal: () => tagVarSignal,
|
|
89
84
|
value: () => value
|
|
@@ -136,6 +131,51 @@ function forTo(to, from, step, cb) {
|
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
133
|
|
|
134
|
+
// src/dom/schedule.ts
|
|
135
|
+
var task;
|
|
136
|
+
var port2 = /* @__PURE__ */ (() => {
|
|
137
|
+
const { port1, port2: port22 } = new MessageChannel();
|
|
138
|
+
port1.onmessage = () => {
|
|
139
|
+
isScheduled = false;
|
|
140
|
+
if (true) {
|
|
141
|
+
task.run(run);
|
|
142
|
+
task = void 0;
|
|
143
|
+
} else {
|
|
144
|
+
run();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return port22;
|
|
148
|
+
})();
|
|
149
|
+
var isScheduled;
|
|
150
|
+
function schedule() {
|
|
151
|
+
if (!isScheduled) {
|
|
152
|
+
if (true) {
|
|
153
|
+
task = console.createTask?.("queue") || {
|
|
154
|
+
run(fn) {
|
|
155
|
+
fn();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
isScheduled = true;
|
|
160
|
+
queueMicrotask(flushAndWaitFrame);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function flushAndWaitFrame() {
|
|
164
|
+
if (true) {
|
|
165
|
+
task.run(run);
|
|
166
|
+
} else {
|
|
167
|
+
run();
|
|
168
|
+
}
|
|
169
|
+
requestAnimationFrame(triggerMacroTask);
|
|
170
|
+
}
|
|
171
|
+
function triggerMacroTask() {
|
|
172
|
+
port2.postMessage(0);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/common/meta.ts
|
|
176
|
+
var DEFAULT_RUNTIME_ID = "M";
|
|
177
|
+
var DEFAULT_RENDER_ID = "_";
|
|
178
|
+
|
|
139
179
|
// src/dom/scope.ts
|
|
140
180
|
var debugID = 0;
|
|
141
181
|
function createScope($global) {
|
|
@@ -165,12 +205,7 @@ function destroyScope(scope) {
|
|
|
165
205
|
return scope;
|
|
166
206
|
}
|
|
167
207
|
function _destroyScope(scope) {
|
|
168
|
-
|
|
169
|
-
if (cleanup) {
|
|
170
|
-
for (const instance of cleanup) {
|
|
171
|
-
_destroyScope(instance);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
208
|
+
scope.___cleanup?.forEach(_destroyScope);
|
|
174
209
|
const controllers = scope.___abortControllers;
|
|
175
210
|
if (controllers) {
|
|
176
211
|
for (const ctrl of controllers.values()) {
|
|
@@ -206,365 +241,221 @@ function insertBefore(scope, parent, nextSibling) {
|
|
|
206
241
|
}
|
|
207
242
|
}
|
|
208
243
|
|
|
209
|
-
// src/dom/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
244
|
+
// src/dom/resume.ts
|
|
245
|
+
var registeredValues = {};
|
|
246
|
+
var Render = class {
|
|
247
|
+
___scopeStack = [];
|
|
248
|
+
___scopeLookup = {};
|
|
249
|
+
___serializeContext = {
|
|
250
|
+
_: registeredValues
|
|
251
|
+
};
|
|
252
|
+
constructor(renders, runtimeId, renderId) {
|
|
253
|
+
this.___renders = renders;
|
|
254
|
+
this.___runtimeId = runtimeId;
|
|
255
|
+
this.___renderId = renderId;
|
|
256
|
+
this.___data = renders[renderId];
|
|
257
|
+
this.___resume();
|
|
218
258
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
let controller = controllers.get(id);
|
|
223
|
-
if (!controller) {
|
|
224
|
-
onDestroy(scope);
|
|
225
|
-
controllers.set(id, controller = new AbortController());
|
|
259
|
+
w() {
|
|
260
|
+
this.___data.w();
|
|
261
|
+
this.___resume();
|
|
226
262
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
___resume() {
|
|
264
|
+
const data2 = this.___data;
|
|
265
|
+
const serializeContext = this.___serializeContext;
|
|
266
|
+
const scopeLookup = this.___scopeLookup;
|
|
267
|
+
const visits = data2.v;
|
|
268
|
+
const cleanupOwners = /* @__PURE__ */ new Map();
|
|
269
|
+
if (visits.length) {
|
|
270
|
+
const commentPrefix = data2.i;
|
|
271
|
+
const commentPrefixLen = commentPrefix.length;
|
|
272
|
+
const cleanupMarkers = /* @__PURE__ */ new Map();
|
|
273
|
+
data2.v = [];
|
|
274
|
+
const sectionEnd = (visit, scopeId = this.___currentScopeId, curNode = visit) => {
|
|
275
|
+
const scope = scopeLookup[scopeId] ||= {};
|
|
276
|
+
let endNode = curNode;
|
|
277
|
+
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
|
278
|
+
scope.___endNode = endNode;
|
|
279
|
+
const startNode = scope.___startNode ||= endNode;
|
|
280
|
+
let len = cleanupMarkers.size;
|
|
281
|
+
for (const [markerScopeId, markerNode] of cleanupMarkers) {
|
|
282
|
+
if (!len--) break;
|
|
283
|
+
if (markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
|
284
|
+
cleanupOwners.set("" + markerScopeId, scopeId);
|
|
285
|
+
cleanupMarkers.delete(markerScopeId);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
cleanupMarkers.set(scopeId, visit);
|
|
289
|
+
return scope;
|
|
290
|
+
};
|
|
291
|
+
for (const visit of visits) {
|
|
292
|
+
const commentText = visit.data;
|
|
293
|
+
const token = commentText[commentPrefixLen];
|
|
294
|
+
const scopeId = parseInt(commentText.slice(commentPrefixLen + 1));
|
|
295
|
+
const scope = scopeLookup[scopeId] ||= {};
|
|
296
|
+
const dataIndex = commentText.indexOf(" ") + 1;
|
|
297
|
+
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
|
298
|
+
if (token === "*" /* Node */) {
|
|
299
|
+
scope[data3] = visit.previousSibling;
|
|
300
|
+
} else if (token === "$" /* Cleanup */) {
|
|
301
|
+
cleanupMarkers.set(scopeId, visit);
|
|
302
|
+
} else if (token === "[" /* SectionStart */) {
|
|
303
|
+
if (this.___currentScopeId) {
|
|
304
|
+
if (data3) {
|
|
305
|
+
sectionEnd(visit);
|
|
263
306
|
}
|
|
307
|
+
this.___scopeStack.push(this.___currentScopeId);
|
|
264
308
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
309
|
+
this.___currentScopeId = scopeId;
|
|
310
|
+
scope.___startNode = visit;
|
|
311
|
+
} else if (token === "]" /* SectionEnd */) {
|
|
312
|
+
scope[data3] = visit;
|
|
313
|
+
if (scopeId < this.___currentScopeId) {
|
|
314
|
+
const currParent = visit.parentNode;
|
|
315
|
+
const startNode = sectionEnd(visit).___startNode;
|
|
316
|
+
if (currParent && currParent !== startNode.parentNode) {
|
|
317
|
+
currParent.prepend(startNode);
|
|
272
318
|
}
|
|
319
|
+
this.___currentScopeId = this.___scopeStack.pop();
|
|
320
|
+
}
|
|
321
|
+
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
|
322
|
+
scope[true ? data3.slice(0, data3.indexOf(" ")) : parseInt(data3)] = visit;
|
|
323
|
+
const childScopeIds = JSON.parse(
|
|
324
|
+
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
|
325
|
+
);
|
|
326
|
+
let curNode = visit;
|
|
327
|
+
for (let i = childScopeIds.length - 1; i >= 0; i--) {
|
|
328
|
+
curNode = sectionEnd(visit, childScopeIds[i], curNode).___endNode;
|
|
273
329
|
}
|
|
274
330
|
}
|
|
275
|
-
return result;
|
|
276
331
|
}
|
|
332
|
+
}
|
|
333
|
+
const resumes = data2.r;
|
|
334
|
+
if (resumes) {
|
|
335
|
+
data2.r = [];
|
|
336
|
+
const len = resumes.length;
|
|
337
|
+
let i = 0;
|
|
338
|
+
try {
|
|
339
|
+
isResuming = true;
|
|
340
|
+
while (i < len) {
|
|
341
|
+
const resumeData = resumes[i++];
|
|
342
|
+
if (typeof resumeData === "function") {
|
|
343
|
+
const scopes = resumeData(serializeContext);
|
|
344
|
+
let { $global } = scopeLookup;
|
|
345
|
+
if (!$global) {
|
|
346
|
+
scopeLookup.$global = $global = scopes.$ || {};
|
|
347
|
+
$global.runtimeId = this.___runtimeId;
|
|
348
|
+
$global.renderId = this.___renderId;
|
|
349
|
+
}
|
|
350
|
+
for (const scopeId in scopes) {
|
|
351
|
+
if (scopeId !== "$") {
|
|
352
|
+
const scope = scopes[scopeId];
|
|
353
|
+
const prevScope = scopeLookup[scopeId];
|
|
354
|
+
scope.$global = $global;
|
|
355
|
+
if (prevScope !== scope) {
|
|
356
|
+
scopeLookup[scopeId] = Object.assign(
|
|
357
|
+
scope,
|
|
358
|
+
prevScope
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
const cleanupOwnerId = cleanupOwners.get(scopeId);
|
|
362
|
+
if (cleanupOwnerId) {
|
|
363
|
+
scope.___cleanupOwner = scopes[cleanupOwnerId];
|
|
364
|
+
onDestroy(scope);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} else if (i === len || typeof resumes[i] !== "string") {
|
|
369
|
+
delete this.___renders[this.___renderId];
|
|
370
|
+
} else {
|
|
371
|
+
registeredValues[resumes[i++]](
|
|
372
|
+
scopeLookup[resumeData]
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} finally {
|
|
377
|
+
isResuming = false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
277
380
|
}
|
|
278
|
-
|
|
381
|
+
};
|
|
382
|
+
var isResuming = false;
|
|
383
|
+
function register(id, obj) {
|
|
384
|
+
registeredValues[id] = obj;
|
|
385
|
+
return obj;
|
|
279
386
|
}
|
|
280
|
-
function
|
|
281
|
-
|
|
387
|
+
function registerBoundSignal(id, signal) {
|
|
388
|
+
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
|
389
|
+
return signal;
|
|
282
390
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
function reconcile(parent, oldScopes, newScopes, afterReference) {
|
|
287
|
-
let oldStart = 0;
|
|
288
|
-
let newStart = 0;
|
|
289
|
-
let oldEnd = oldScopes.length - 1;
|
|
290
|
-
let newEnd = newScopes.length - 1;
|
|
291
|
-
let oldStartScope = oldScopes[oldStart];
|
|
292
|
-
let newStartScope = newScopes[newStart];
|
|
293
|
-
let oldEndScope = oldScopes[oldEnd];
|
|
294
|
-
let newEndScope = newScopes[newEnd];
|
|
295
|
-
let i;
|
|
296
|
-
let j;
|
|
297
|
-
let k;
|
|
298
|
-
let nextSibling;
|
|
299
|
-
let oldScope;
|
|
300
|
-
let newScope;
|
|
301
|
-
outer: {
|
|
302
|
-
while (oldStartScope === newStartScope) {
|
|
303
|
-
++oldStart;
|
|
304
|
-
++newStart;
|
|
305
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
306
|
-
break outer;
|
|
307
|
-
}
|
|
308
|
-
oldStartScope = oldScopes[oldStart];
|
|
309
|
-
newStartScope = newScopes[newStart];
|
|
310
|
-
}
|
|
311
|
-
while (oldEndScope === newEndScope) {
|
|
312
|
-
--oldEnd;
|
|
313
|
-
--newEnd;
|
|
314
|
-
if (oldStart > oldEnd || newStart > newEnd) {
|
|
315
|
-
break outer;
|
|
316
|
-
}
|
|
317
|
-
oldEndScope = oldScopes[oldEnd];
|
|
318
|
-
newEndScope = newScopes[newEnd];
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (oldStart > oldEnd) {
|
|
322
|
-
if (newStart <= newEnd) {
|
|
323
|
-
k = newEnd + 1;
|
|
324
|
-
nextSibling = k < newScopes.length ? newScopes[k].___startNode : afterReference;
|
|
325
|
-
do {
|
|
326
|
-
insertBefore(newScopes[newStart++], parent, nextSibling);
|
|
327
|
-
} while (newStart <= newEnd);
|
|
328
|
-
}
|
|
329
|
-
} else if (newStart > newEnd) {
|
|
330
|
-
do {
|
|
331
|
-
removeAndDestroyScope(oldScopes[oldStart++]);
|
|
332
|
-
} while (oldStart <= oldEnd);
|
|
333
|
-
} else {
|
|
334
|
-
const oldLength = oldEnd - oldStart + 1;
|
|
335
|
-
const newLength = newEnd - newStart + 1;
|
|
336
|
-
const aNullable = oldScopes;
|
|
337
|
-
const sources = new Array(newLength);
|
|
338
|
-
for (i = 0; i < newLength; ++i) {
|
|
339
|
-
sources[i] = -1;
|
|
340
|
-
}
|
|
341
|
-
let pos = 0;
|
|
342
|
-
let synced = 0;
|
|
343
|
-
const keyIndex = /* @__PURE__ */ new Map();
|
|
344
|
-
for (j = newStart; j <= newEnd; ++j) {
|
|
345
|
-
keyIndex.set(newScopes[j], j);
|
|
346
|
-
}
|
|
347
|
-
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
|
348
|
-
oldScope = oldScopes[i];
|
|
349
|
-
j = keyIndex.get(oldScope);
|
|
350
|
-
if (j !== void 0) {
|
|
351
|
-
pos = pos > j ? WRONG_POS : j;
|
|
352
|
-
++synced;
|
|
353
|
-
newScope = newScopes[j];
|
|
354
|
-
sources[j - newStart] = i;
|
|
355
|
-
aNullable[i] = null;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (oldLength === oldScopes.length && synced === 0) {
|
|
359
|
-
for (; newStart < newLength; ++newStart) {
|
|
360
|
-
insertBefore(newScopes[newStart], parent, afterReference);
|
|
361
|
-
}
|
|
362
|
-
for (; oldStart < oldLength; ++oldStart) {
|
|
363
|
-
removeAndDestroyScope(oldScopes[oldStart]);
|
|
364
|
-
}
|
|
365
|
-
} else {
|
|
366
|
-
i = oldLength - synced;
|
|
367
|
-
while (i > 0) {
|
|
368
|
-
oldScope = aNullable[oldStart++];
|
|
369
|
-
if (oldScope !== null) {
|
|
370
|
-
removeAndDestroyScope(oldScope);
|
|
371
|
-
i--;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (pos === WRONG_POS) {
|
|
375
|
-
const seq = longestIncreasingSubsequence(sources);
|
|
376
|
-
j = seq.length - 1;
|
|
377
|
-
k = newScopes.length;
|
|
378
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
379
|
-
if (sources[i] === -1) {
|
|
380
|
-
pos = i + newStart;
|
|
381
|
-
newScope = newScopes[pos++];
|
|
382
|
-
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
383
|
-
insertBefore(newScope, parent, nextSibling);
|
|
384
|
-
} else {
|
|
385
|
-
if (j < 0 || i !== seq[j]) {
|
|
386
|
-
pos = i + newStart;
|
|
387
|
-
newScope = newScopes[pos++];
|
|
388
|
-
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
389
|
-
insertBefore(newScope, parent, nextSibling);
|
|
390
|
-
} else {
|
|
391
|
-
--j;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
} else if (synced !== newLength) {
|
|
396
|
-
k = newScopes.length;
|
|
397
|
-
for (i = newLength - 1; i >= 0; --i) {
|
|
398
|
-
if (sources[i] === -1) {
|
|
399
|
-
pos = i + newStart;
|
|
400
|
-
newScope = newScopes[pos++];
|
|
401
|
-
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
402
|
-
insertBefore(newScope, parent, nextSibling);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
391
|
+
function getRegisteredWithScope(id, scope) {
|
|
392
|
+
const val = registeredValues[id];
|
|
393
|
+
return scope ? val(scope) : val;
|
|
408
394
|
}
|
|
409
|
-
function
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
for (let i = 0, il = a.length; i < il; ++i) {
|
|
416
|
-
if (a[i] === -1) {
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
const j = result[result.length - 1];
|
|
420
|
-
if (a[j] < a[i]) {
|
|
421
|
-
p[i] = j;
|
|
422
|
-
result.push(i);
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
u = 0;
|
|
426
|
-
v = result.length - 1;
|
|
427
|
-
while (u < v) {
|
|
428
|
-
const c = (u + v) / 2 | 0;
|
|
429
|
-
if (a[result[c]] < a[i]) {
|
|
430
|
-
u = c + 1;
|
|
431
|
-
} else {
|
|
432
|
-
v = c;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (a[i] < a[result[u]]) {
|
|
436
|
-
if (u > 0) {
|
|
437
|
-
p[i] = result[u - 1];
|
|
438
|
-
}
|
|
439
|
-
result[u] = i;
|
|
395
|
+
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
396
|
+
if (true) {
|
|
397
|
+
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
|
398
|
+
throw new Error(
|
|
399
|
+
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
|
400
|
+
);
|
|
440
401
|
}
|
|
441
402
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// src/dom/event.ts
|
|
452
|
-
var elementHandlersByEvent = /* @__PURE__ */ new Map();
|
|
453
|
-
var defaultDelegator = createDelegator();
|
|
454
|
-
function on(element, type, handler) {
|
|
455
|
-
let handlersByElement = elementHandlersByEvent.get(type);
|
|
456
|
-
if (!handlersByElement) {
|
|
457
|
-
elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap());
|
|
458
|
-
}
|
|
459
|
-
if (!handlersByElement.has(element)) {
|
|
460
|
-
defaultDelegator(element, type, handleDelegated);
|
|
461
|
-
}
|
|
462
|
-
handlersByElement.set(element, handler || void 0);
|
|
463
|
-
}
|
|
464
|
-
function createDelegator() {
|
|
465
|
-
const delegatedEventsByRoot = /* @__PURE__ */ new WeakMap();
|
|
466
|
-
return function ensureDelegated(node, type, handler) {
|
|
467
|
-
const root = node.getRootNode();
|
|
468
|
-
let delegatedEvents = delegatedEventsByRoot.get(root);
|
|
469
|
-
if (!delegatedEvents) {
|
|
470
|
-
delegatedEventsByRoot.set(root, delegatedEvents = /* @__PURE__ */ new Set());
|
|
471
|
-
}
|
|
472
|
-
if (!delegatedEvents.has(type)) {
|
|
473
|
-
delegatedEvents.add(type);
|
|
474
|
-
root.addEventListener(type, handler, true);
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function handleDelegated(ev) {
|
|
479
|
-
let target = ev.target;
|
|
480
|
-
if (target) {
|
|
481
|
-
const handlersByElement = elementHandlersByEvent.get(ev.type);
|
|
482
|
-
handlersByElement.get(target)?.(ev, target);
|
|
483
|
-
if (ev.bubbles) {
|
|
484
|
-
while ((target = target.parentElement) && !ev.cancelBubble) {
|
|
485
|
-
handlersByElement.get(target)?.(ev, target);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
403
|
+
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
|
404
|
+
let renders;
|
|
405
|
+
if (window[runtimeId]) {
|
|
406
|
+
setRenders(window[runtimeId]);
|
|
407
|
+
} else {
|
|
408
|
+
Object.defineProperty(window, runtimeId, {
|
|
409
|
+
configurable: true,
|
|
410
|
+
set: setRenders
|
|
411
|
+
});
|
|
488
412
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// src/dom/schedule.ts
|
|
492
|
-
var task;
|
|
493
|
-
var port2 = /* @__PURE__ */ (() => {
|
|
494
|
-
const { port1, port2: port22 } = new MessageChannel();
|
|
495
|
-
port1.onmessage = () => {
|
|
496
|
-
isScheduled = false;
|
|
413
|
+
function setRenders(v) {
|
|
497
414
|
if (true) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
415
|
+
if (renders) {
|
|
416
|
+
throw new Error(
|
|
417
|
+
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
|
418
|
+
);
|
|
419
|
+
}
|
|
502
420
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
var isScheduled;
|
|
507
|
-
function schedule() {
|
|
508
|
-
if (!isScheduled) {
|
|
509
|
-
if (true) {
|
|
510
|
-
task = console.createTask?.("queue") || {
|
|
511
|
-
run(fn) {
|
|
512
|
-
fn();
|
|
513
|
-
}
|
|
514
|
-
};
|
|
421
|
+
renders = v;
|
|
422
|
+
for (const renderId in v) {
|
|
423
|
+
resumeRender(renderId);
|
|
515
424
|
}
|
|
516
|
-
|
|
517
|
-
|
|
425
|
+
Object.defineProperty(window, runtimeId, {
|
|
426
|
+
configurable: true,
|
|
427
|
+
value: resumeRender
|
|
428
|
+
});
|
|
518
429
|
}
|
|
519
430
|
}
|
|
520
|
-
function
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
} else {
|
|
524
|
-
run();
|
|
525
|
-
}
|
|
526
|
-
requestAnimationFrame(triggerMacroTask);
|
|
431
|
+
function registerSubscriber(id, signal) {
|
|
432
|
+
register(id, signal.___subscribe);
|
|
433
|
+
return signal;
|
|
527
434
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
435
|
+
function nodeRef(id, key) {
|
|
436
|
+
return register(id, (scope) => () => scope[key]);
|
|
530
437
|
}
|
|
531
438
|
|
|
532
439
|
// src/dom/signals.ts
|
|
533
440
|
var MARK = true ? Symbol("mark") : {};
|
|
534
441
|
var CLEAN = true ? Symbol("clean") : {};
|
|
535
442
|
var DIRTY = true ? Symbol("dirty") : {};
|
|
536
|
-
function
|
|
443
|
+
function state(valueAccessor, fn, getIntersection) {
|
|
444
|
+
const valueSignal = value(valueAccessor, fn, getIntersection);
|
|
537
445
|
const markAccessor = valueAccessor + "#" /* Mark */;
|
|
538
|
-
return (scope, valueOrOp) => {
|
|
539
|
-
if (
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (valueOrOp != null && typeof valueOrOp !== "function") {
|
|
550
|
-
throw new Error(
|
|
551
|
-
`Invalid value ${valueOrOp} for change handler '${valueAccessor}'`
|
|
552
|
-
);
|
|
553
|
-
} else if (scope[markAccessor] !== void 0) {
|
|
554
|
-
const prevValue = scope[valueAccessor];
|
|
555
|
-
if (prevValue && !valueOrOp) {
|
|
556
|
-
throw new Error(
|
|
557
|
-
`Change handler '${valueAccessor}' cannot change from a function to ${valueOrOp}`
|
|
558
|
-
);
|
|
559
|
-
} else if (!prevValue && valueOrOp) {
|
|
560
|
-
throw new Error(
|
|
561
|
-
`Change handler '${valueAccessor}' cannot change from a nullish to a function`
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
446
|
+
return (scope, valueOrOp, valueChange) => {
|
|
447
|
+
if (rendering) {
|
|
448
|
+
const valueIsOp = valueOrOp === MARK || valueOrOp === CLEAN || valueOrOp === DIRTY;
|
|
449
|
+
valueSignal(
|
|
450
|
+
scope,
|
|
451
|
+
valueIsOp || valueChange || scope[markAccessor] === void 0 ? valueOrOp : CLEAN
|
|
452
|
+
);
|
|
453
|
+
} else if (valueChange) {
|
|
454
|
+
valueChange(valueOrOp);
|
|
455
|
+
} else {
|
|
456
|
+
queueSource(scope, valueSignal, valueOrOp);
|
|
566
457
|
}
|
|
567
|
-
|
|
458
|
+
return valueOrOp;
|
|
568
459
|
};
|
|
569
460
|
}
|
|
570
461
|
function value(valueAccessor, fn, getIntersection) {
|
|
@@ -582,7 +473,7 @@ function value(valueAccessor, fn, getIntersection) {
|
|
|
582
473
|
intersection2?.(scope, CLEAN);
|
|
583
474
|
} else {
|
|
584
475
|
scope[valueAccessor] = valueOrOp;
|
|
585
|
-
fn
|
|
476
|
+
fn && fn(scope, valueOrOp);
|
|
586
477
|
intersection2?.(scope, DIRTY);
|
|
587
478
|
}
|
|
588
479
|
}
|
|
@@ -642,7 +533,7 @@ function closure(ownerValueAccessor, fn, getOwnerScope = defaultGetOwnerScope, g
|
|
|
642
533
|
scope[dirtyAccessor] = false;
|
|
643
534
|
ownerScope ||= getOwnerScope(scope);
|
|
644
535
|
ownerValueAccessor2 ||= getOwnerValueAccessor(scope);
|
|
645
|
-
fn
|
|
536
|
+
fn && fn(scope, ownerScope[ownerValueAccessor2]);
|
|
646
537
|
intersection2?.(scope, DIRTY);
|
|
647
538
|
} else {
|
|
648
539
|
intersection2?.(scope, CLEAN);
|
|
@@ -739,80 +630,353 @@ function intersections(signals) {
|
|
|
739
630
|
}
|
|
740
631
|
};
|
|
741
632
|
}
|
|
633
|
+
function effect(id, fn) {
|
|
634
|
+
register(id, fn);
|
|
635
|
+
return (scope) => {
|
|
636
|
+
queueEffect(scope, fn);
|
|
637
|
+
};
|
|
638
|
+
}
|
|
742
639
|
|
|
743
640
|
// src/dom/queue.ts
|
|
744
|
-
var
|
|
745
|
-
var
|
|
746
|
-
|
|
747
|
-
if (changeHandler2) {
|
|
748
|
-
changeHandler2(value2);
|
|
749
|
-
return value2;
|
|
750
|
-
}
|
|
751
|
-
return queueSource(scope, signal, value2);
|
|
752
|
-
}
|
|
641
|
+
var pendingSignals = [];
|
|
642
|
+
var pendingEffects = [];
|
|
643
|
+
var rendering = false;
|
|
753
644
|
function queueSource(scope, signal, value2) {
|
|
754
645
|
schedule();
|
|
646
|
+
rendering = true;
|
|
755
647
|
signal(scope, MARK);
|
|
756
|
-
|
|
648
|
+
rendering = false;
|
|
649
|
+
pendingSignals.push(scope, signal, value2);
|
|
757
650
|
return value2;
|
|
758
651
|
}
|
|
759
652
|
function queueEffect(scope, fn) {
|
|
760
|
-
|
|
653
|
+
pendingEffects.push(scope, fn);
|
|
761
654
|
}
|
|
762
655
|
function run() {
|
|
656
|
+
const signals = pendingSignals;
|
|
657
|
+
const effects = pendingEffects;
|
|
763
658
|
try {
|
|
764
|
-
|
|
659
|
+
rendering = true;
|
|
660
|
+
pendingSignals = [];
|
|
661
|
+
runSignals(signals);
|
|
765
662
|
} finally {
|
|
766
|
-
|
|
663
|
+
rendering = false;
|
|
767
664
|
}
|
|
665
|
+
pendingEffects = [];
|
|
666
|
+
runEffects(effects);
|
|
667
|
+
}
|
|
668
|
+
function prepareEffects(fn) {
|
|
669
|
+
const prevSignals = pendingSignals;
|
|
670
|
+
const prevEffects = pendingEffects;
|
|
671
|
+
const preparedEffects = pendingEffects = [];
|
|
672
|
+
const preparedSignals = pendingSignals = [];
|
|
768
673
|
try {
|
|
769
|
-
|
|
674
|
+
rendering = true;
|
|
675
|
+
fn();
|
|
676
|
+
pendingSignals = prevSignals;
|
|
677
|
+
runSignals(preparedSignals);
|
|
770
678
|
} finally {
|
|
771
|
-
|
|
679
|
+
rendering = false;
|
|
680
|
+
pendingSignals = prevSignals;
|
|
681
|
+
pendingEffects = prevEffects;
|
|
682
|
+
}
|
|
683
|
+
return preparedEffects;
|
|
684
|
+
}
|
|
685
|
+
function runEffects(effects = pendingEffects) {
|
|
686
|
+
for (let i = 0; i < effects.length; i += 2 /* Total */) {
|
|
687
|
+
const scope = effects[i];
|
|
688
|
+
const fn = effects[i + 1];
|
|
689
|
+
fn(scope);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
function runSignals(signals) {
|
|
693
|
+
for (let i = 0; i < signals.length; i += 3 /* Total */) {
|
|
694
|
+
const scope = signals[i + 0 /* Scope */];
|
|
695
|
+
const signal = signals[i + 1 /* Signal */];
|
|
696
|
+
const value2 = signals[i + 2 /* Value */];
|
|
697
|
+
signal(scope, value2);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/dom/abort-signal.ts
|
|
702
|
+
function resetAbortSignal(scope, id) {
|
|
703
|
+
const controllers = scope.___abortControllers;
|
|
704
|
+
if (controllers) {
|
|
705
|
+
const ctrl = controllers.get(id);
|
|
706
|
+
if (ctrl) {
|
|
707
|
+
queueEffect(null, () => ctrl.abort());
|
|
708
|
+
controllers.delete(id);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function getAbortSignal(scope, id) {
|
|
713
|
+
const controllers = scope.___abortControllers ||= /* @__PURE__ */ new Map();
|
|
714
|
+
let controller = controllers.get(id);
|
|
715
|
+
if (!controller) {
|
|
716
|
+
onDestroy(scope);
|
|
717
|
+
controllers.set(id, controller = new AbortController());
|
|
718
|
+
}
|
|
719
|
+
return controller.signal;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/common/compat-meta.ts
|
|
723
|
+
var prefix = true ? "$compat_" : "$C_";
|
|
724
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
|
725
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
|
726
|
+
|
|
727
|
+
// src/common/helpers.ts
|
|
728
|
+
function classValue(value2) {
|
|
729
|
+
return toDelimitedString(value2, " ", stringifyClassObject);
|
|
730
|
+
}
|
|
731
|
+
function stringifyClassObject(name, value2) {
|
|
732
|
+
return value2 ? name : "";
|
|
733
|
+
}
|
|
734
|
+
function styleValue(value2) {
|
|
735
|
+
return toDelimitedString(value2, ";", stringifyStyleObject);
|
|
736
|
+
}
|
|
737
|
+
var NON_DIMENSIONAL = /^(--|ta|or|li|z)|n-c|i(do|nk|m|t)|w$|we/;
|
|
738
|
+
function stringifyStyleObject(name, value2) {
|
|
739
|
+
return value2 || value2 === 0 ? `${name}:${typeof value2 === "number" && value2 && !NON_DIMENSIONAL.test(name) ? value2 + "px" : value2}` : "";
|
|
740
|
+
}
|
|
741
|
+
function toDelimitedString(val, delimiter, stringify) {
|
|
742
|
+
switch (typeof val) {
|
|
743
|
+
case "string":
|
|
744
|
+
return val;
|
|
745
|
+
case "object":
|
|
746
|
+
if (val !== null) {
|
|
747
|
+
let result = "";
|
|
748
|
+
let curDelimiter = "";
|
|
749
|
+
if (Array.isArray(val)) {
|
|
750
|
+
for (const v of val) {
|
|
751
|
+
const part = toDelimitedString(v, delimiter, stringify);
|
|
752
|
+
if (part !== "") {
|
|
753
|
+
result += curDelimiter + part;
|
|
754
|
+
curDelimiter = delimiter;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
for (const name in val) {
|
|
759
|
+
const v = val[name];
|
|
760
|
+
const part = stringify(name, v);
|
|
761
|
+
if (part !== "") {
|
|
762
|
+
result += curDelimiter + part;
|
|
763
|
+
curDelimiter = delimiter;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return result;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return "";
|
|
771
|
+
}
|
|
772
|
+
function normalizeDynamicRenderer(value2) {
|
|
773
|
+
if (value2) return value2.renderBody || value2.default || value2;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// src/dom/reconcile.ts
|
|
777
|
+
var WRONG_POS = 2147483647;
|
|
778
|
+
function reconcile(parent, oldScopes, newScopes, afterReference) {
|
|
779
|
+
let oldStart = 0;
|
|
780
|
+
let newStart = 0;
|
|
781
|
+
let oldEnd = oldScopes.length - 1;
|
|
782
|
+
let newEnd = newScopes.length - 1;
|
|
783
|
+
let oldStartScope = oldScopes[oldStart];
|
|
784
|
+
let newStartScope = newScopes[newStart];
|
|
785
|
+
let oldEndScope = oldScopes[oldEnd];
|
|
786
|
+
let newEndScope = newScopes[newEnd];
|
|
787
|
+
let i;
|
|
788
|
+
let j;
|
|
789
|
+
let k;
|
|
790
|
+
let nextSibling;
|
|
791
|
+
let oldScope;
|
|
792
|
+
let newScope;
|
|
793
|
+
outer: {
|
|
794
|
+
while (oldStartScope === newStartScope) {
|
|
795
|
+
++oldStart;
|
|
796
|
+
++newStart;
|
|
797
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
|
798
|
+
break outer;
|
|
799
|
+
}
|
|
800
|
+
oldStartScope = oldScopes[oldStart];
|
|
801
|
+
newStartScope = newScopes[newStart];
|
|
802
|
+
}
|
|
803
|
+
while (oldEndScope === newEndScope) {
|
|
804
|
+
--oldEnd;
|
|
805
|
+
--newEnd;
|
|
806
|
+
if (oldStart > oldEnd || newStart > newEnd) {
|
|
807
|
+
break outer;
|
|
808
|
+
}
|
|
809
|
+
oldEndScope = oldScopes[oldEnd];
|
|
810
|
+
newEndScope = newScopes[newEnd];
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (oldStart > oldEnd) {
|
|
814
|
+
if (newStart <= newEnd) {
|
|
815
|
+
k = newEnd + 1;
|
|
816
|
+
nextSibling = k < newScopes.length ? newScopes[k].___startNode : afterReference;
|
|
817
|
+
do {
|
|
818
|
+
insertBefore(newScopes[newStart++], parent, nextSibling);
|
|
819
|
+
} while (newStart <= newEnd);
|
|
820
|
+
}
|
|
821
|
+
} else if (newStart > newEnd) {
|
|
822
|
+
do {
|
|
823
|
+
removeAndDestroyScope(oldScopes[oldStart++]);
|
|
824
|
+
} while (oldStart <= oldEnd);
|
|
825
|
+
} else {
|
|
826
|
+
const oldLength = oldEnd - oldStart + 1;
|
|
827
|
+
const newLength = newEnd - newStart + 1;
|
|
828
|
+
const aNullable = oldScopes;
|
|
829
|
+
const sources = new Array(newLength);
|
|
830
|
+
for (i = 0; i < newLength; ++i) {
|
|
831
|
+
sources[i] = -1;
|
|
832
|
+
}
|
|
833
|
+
let pos = 0;
|
|
834
|
+
let synced = 0;
|
|
835
|
+
const keyIndex = /* @__PURE__ */ new Map();
|
|
836
|
+
for (j = newStart; j <= newEnd; ++j) {
|
|
837
|
+
keyIndex.set(newScopes[j], j);
|
|
838
|
+
}
|
|
839
|
+
for (i = oldStart; i <= oldEnd && synced < newLength; ++i) {
|
|
840
|
+
oldScope = oldScopes[i];
|
|
841
|
+
j = keyIndex.get(oldScope);
|
|
842
|
+
if (j !== void 0) {
|
|
843
|
+
pos = pos > j ? WRONG_POS : j;
|
|
844
|
+
++synced;
|
|
845
|
+
newScope = newScopes[j];
|
|
846
|
+
sources[j - newStart] = i;
|
|
847
|
+
aNullable[i] = null;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (oldLength === oldScopes.length && synced === 0) {
|
|
851
|
+
for (; newStart < newLength; ++newStart) {
|
|
852
|
+
insertBefore(newScopes[newStart], parent, afterReference);
|
|
853
|
+
}
|
|
854
|
+
for (; oldStart < oldLength; ++oldStart) {
|
|
855
|
+
removeAndDestroyScope(oldScopes[oldStart]);
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
i = oldLength - synced;
|
|
859
|
+
while (i > 0) {
|
|
860
|
+
oldScope = aNullable[oldStart++];
|
|
861
|
+
if (oldScope !== null) {
|
|
862
|
+
removeAndDestroyScope(oldScope);
|
|
863
|
+
i--;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if (pos === WRONG_POS) {
|
|
867
|
+
const seq = longestIncreasingSubsequence(sources);
|
|
868
|
+
j = seq.length - 1;
|
|
869
|
+
k = newScopes.length;
|
|
870
|
+
for (i = newLength - 1; i >= 0; --i) {
|
|
871
|
+
if (sources[i] === -1) {
|
|
872
|
+
pos = i + newStart;
|
|
873
|
+
newScope = newScopes[pos++];
|
|
874
|
+
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
875
|
+
insertBefore(newScope, parent, nextSibling);
|
|
876
|
+
} else {
|
|
877
|
+
if (j < 0 || i !== seq[j]) {
|
|
878
|
+
pos = i + newStart;
|
|
879
|
+
newScope = newScopes[pos++];
|
|
880
|
+
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
881
|
+
insertBefore(newScope, parent, nextSibling);
|
|
882
|
+
} else {
|
|
883
|
+
--j;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
} else if (synced !== newLength) {
|
|
888
|
+
k = newScopes.length;
|
|
889
|
+
for (i = newLength - 1; i >= 0; --i) {
|
|
890
|
+
if (sources[i] === -1) {
|
|
891
|
+
pos = i + newStart;
|
|
892
|
+
newScope = newScopes[pos++];
|
|
893
|
+
nextSibling = pos < k ? newScopes[pos].___startNode : afterReference;
|
|
894
|
+
insertBefore(newScope, parent, nextSibling);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
function longestIncreasingSubsequence(a) {
|
|
902
|
+
const p = a.slice();
|
|
903
|
+
const result = [];
|
|
904
|
+
result.push(0);
|
|
905
|
+
let u;
|
|
906
|
+
let v;
|
|
907
|
+
for (let i = 0, il = a.length; i < il; ++i) {
|
|
908
|
+
if (a[i] === -1) {
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
const j = result[result.length - 1];
|
|
912
|
+
if (a[j] < a[i]) {
|
|
913
|
+
p[i] = j;
|
|
914
|
+
result.push(i);
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
u = 0;
|
|
918
|
+
v = result.length - 1;
|
|
919
|
+
while (u < v) {
|
|
920
|
+
const c = (u + v) / 2 | 0;
|
|
921
|
+
if (a[result[c]] < a[i]) {
|
|
922
|
+
u = c + 1;
|
|
923
|
+
} else {
|
|
924
|
+
v = c;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (a[i] < a[result[u]]) {
|
|
928
|
+
if (u > 0) {
|
|
929
|
+
p[i] = result[u - 1];
|
|
930
|
+
}
|
|
931
|
+
result[u] = i;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
u = result.length;
|
|
935
|
+
v = result[u - 1];
|
|
936
|
+
while (u-- > 0) {
|
|
937
|
+
result[u] = v;
|
|
938
|
+
v = p[v];
|
|
772
939
|
}
|
|
940
|
+
return result;
|
|
773
941
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
currentBatch = prevBatch;
|
|
783
|
-
runEffects();
|
|
784
|
-
} finally {
|
|
785
|
-
currentBatch = prevBatch;
|
|
786
|
-
currentEffects = prevEffects;
|
|
942
|
+
|
|
943
|
+
// src/dom/event.ts
|
|
944
|
+
var elementHandlersByEvent = /* @__PURE__ */ new Map();
|
|
945
|
+
var defaultDelegator = createDelegator();
|
|
946
|
+
function on(element, type, handler) {
|
|
947
|
+
let handlersByElement = elementHandlersByEvent.get(type);
|
|
948
|
+
if (!handlersByElement) {
|
|
949
|
+
elementHandlersByEvent.set(type, handlersByElement = /* @__PURE__ */ new WeakMap());
|
|
787
950
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const prevBatch = currentBatch;
|
|
791
|
-
const prevEffects = currentEffects;
|
|
792
|
-
const preparedEffects = currentEffects = [];
|
|
793
|
-
currentBatch = [];
|
|
794
|
-
try {
|
|
795
|
-
fn();
|
|
796
|
-
runBatch();
|
|
797
|
-
} finally {
|
|
798
|
-
currentBatch = prevBatch;
|
|
799
|
-
currentEffects = prevEffects;
|
|
951
|
+
if (!handlersByElement.has(element)) {
|
|
952
|
+
defaultDelegator(element, type, handleDelegated);
|
|
800
953
|
}
|
|
801
|
-
|
|
954
|
+
handlersByElement.set(element, handler || void 0);
|
|
802
955
|
}
|
|
803
|
-
function
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
956
|
+
function createDelegator() {
|
|
957
|
+
const delegatedEventsByRoot = /* @__PURE__ */ new WeakMap();
|
|
958
|
+
return function ensureDelegated(node, type, handler) {
|
|
959
|
+
const root = node.getRootNode();
|
|
960
|
+
let delegatedEvents = delegatedEventsByRoot.get(root);
|
|
961
|
+
if (!delegatedEvents) {
|
|
962
|
+
delegatedEventsByRoot.set(root, delegatedEvents = /* @__PURE__ */ new Set());
|
|
963
|
+
}
|
|
964
|
+
if (!delegatedEvents.has(type)) {
|
|
965
|
+
delegatedEvents.add(type);
|
|
966
|
+
root.addEventListener(type, handler, true);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
809
969
|
}
|
|
810
|
-
function
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
970
|
+
function handleDelegated(ev) {
|
|
971
|
+
let target = ev.target;
|
|
972
|
+
if (target) {
|
|
973
|
+
const handlersByElement = elementHandlersByEvent.get(ev.type);
|
|
974
|
+
handlersByElement.get(target)?.(ev, target);
|
|
975
|
+
if (ev.bubbles) {
|
|
976
|
+
while ((target = target.parentElement) && !ev.cancelBubble) {
|
|
977
|
+
handlersByElement.get(target)?.(ev, target);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
816
980
|
}
|
|
817
981
|
}
|
|
818
982
|
|
|
@@ -843,205 +1007,6 @@ function stripSpacesAndPunctuation(str) {
|
|
|
843
1007
|
return str.replace(/[^\p{L}\p{N}]/gu, "");
|
|
844
1008
|
}
|
|
845
1009
|
|
|
846
|
-
// src/common/meta.ts
|
|
847
|
-
var DEFAULT_RUNTIME_ID = "M";
|
|
848
|
-
var DEFAULT_RENDER_ID = "_";
|
|
849
|
-
|
|
850
|
-
// src/dom/resume.ts
|
|
851
|
-
var registeredValues = {};
|
|
852
|
-
var Render = class {
|
|
853
|
-
___scopeStack = [];
|
|
854
|
-
___scopeLookup = {};
|
|
855
|
-
___serializeContext = {
|
|
856
|
-
_: registeredValues
|
|
857
|
-
};
|
|
858
|
-
constructor(renders, runtimeId, renderId) {
|
|
859
|
-
this.___renders = renders;
|
|
860
|
-
this.___runtimeId = runtimeId;
|
|
861
|
-
this.___renderId = renderId;
|
|
862
|
-
this.___data = renders[renderId];
|
|
863
|
-
this.___resume();
|
|
864
|
-
}
|
|
865
|
-
w() {
|
|
866
|
-
this.___data.w();
|
|
867
|
-
this.___resume();
|
|
868
|
-
}
|
|
869
|
-
___resume() {
|
|
870
|
-
const data2 = this.___data;
|
|
871
|
-
const serializeContext = this.___serializeContext;
|
|
872
|
-
const scopeLookup = this.___scopeLookup;
|
|
873
|
-
const visits = data2.v;
|
|
874
|
-
const cleanupOwners = /* @__PURE__ */ new Map();
|
|
875
|
-
if (visits.length) {
|
|
876
|
-
const commentPrefix = data2.i;
|
|
877
|
-
const commentPrefixLen = commentPrefix.length;
|
|
878
|
-
const cleanupMarkers = /* @__PURE__ */ new Map();
|
|
879
|
-
data2.v = [];
|
|
880
|
-
const sectionEnd = (visit, scopeId = this.___currentScopeId, curNode = visit) => {
|
|
881
|
-
const scope = scopeLookup[scopeId] ||= {};
|
|
882
|
-
let endNode = curNode;
|
|
883
|
-
while ((endNode = endNode.previousSibling).nodeType === 8) ;
|
|
884
|
-
scope.___endNode = endNode;
|
|
885
|
-
const startNode = scope.___startNode ||= endNode;
|
|
886
|
-
let len = cleanupMarkers.size;
|
|
887
|
-
for (const [markerScopeId, markerNode] of cleanupMarkers) {
|
|
888
|
-
if (!len--) break;
|
|
889
|
-
if (markerScopeId !== scopeId && startNode.compareDocumentPosition(markerNode) & 4 && curNode.compareDocumentPosition(markerNode) & 2) {
|
|
890
|
-
cleanupOwners.set("" + markerScopeId, scopeId);
|
|
891
|
-
cleanupMarkers.delete(markerScopeId);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
cleanupMarkers.set(scopeId, visit);
|
|
895
|
-
return scope;
|
|
896
|
-
};
|
|
897
|
-
for (const visit of visits) {
|
|
898
|
-
const commentText = visit.data;
|
|
899
|
-
const token = commentText[commentPrefixLen];
|
|
900
|
-
const scopeId = parseInt(commentText.slice(commentPrefixLen + 1));
|
|
901
|
-
const scope = scopeLookup[scopeId] ||= {};
|
|
902
|
-
const dataIndex = commentText.indexOf(" ") + 1;
|
|
903
|
-
const data3 = dataIndex ? commentText.slice(dataIndex) : "";
|
|
904
|
-
if (token === "*" /* Node */) {
|
|
905
|
-
scope[data3] = visit.previousSibling;
|
|
906
|
-
} else if (token === "$" /* Cleanup */) {
|
|
907
|
-
cleanupMarkers.set(scopeId, visit);
|
|
908
|
-
} else if (token === "[" /* SectionStart */) {
|
|
909
|
-
if (this.___currentScopeId) {
|
|
910
|
-
if (data3) {
|
|
911
|
-
sectionEnd(visit);
|
|
912
|
-
}
|
|
913
|
-
this.___scopeStack.push(this.___currentScopeId);
|
|
914
|
-
}
|
|
915
|
-
this.___currentScopeId = scopeId;
|
|
916
|
-
scope.___startNode = visit;
|
|
917
|
-
} else if (token === "]" /* SectionEnd */) {
|
|
918
|
-
scope[data3] = visit;
|
|
919
|
-
if (scopeId < this.___currentScopeId) {
|
|
920
|
-
const currParent = visit.parentNode;
|
|
921
|
-
const startNode = sectionEnd(visit).___startNode;
|
|
922
|
-
if (currParent && currParent !== startNode.parentNode) {
|
|
923
|
-
currParent.prepend(startNode);
|
|
924
|
-
}
|
|
925
|
-
this.___currentScopeId = this.___scopeStack.pop();
|
|
926
|
-
}
|
|
927
|
-
} else if (token === "|" /* SectionSingleNodesEnd */) {
|
|
928
|
-
scope[true ? data3.slice(0, data3.indexOf(" ")) : parseInt(data3)] = visit;
|
|
929
|
-
const childScopeIds = JSON.parse(
|
|
930
|
-
"[" + data3.slice(data3.indexOf(" ") + 1) + "]"
|
|
931
|
-
);
|
|
932
|
-
let curNode = visit;
|
|
933
|
-
for (let i = childScopeIds.length - 1; i >= 0; i--) {
|
|
934
|
-
curNode = sectionEnd(visit, childScopeIds[i], curNode).___endNode;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
const resumes = data2.r;
|
|
940
|
-
if (resumes) {
|
|
941
|
-
data2.r = [];
|
|
942
|
-
const len = resumes.length;
|
|
943
|
-
let i = 0;
|
|
944
|
-
try {
|
|
945
|
-
isResuming = true;
|
|
946
|
-
while (i < len) {
|
|
947
|
-
const resumeData = resumes[i++];
|
|
948
|
-
if (typeof resumeData === "function") {
|
|
949
|
-
const scopes = resumeData(serializeContext);
|
|
950
|
-
let { $global } = scopeLookup;
|
|
951
|
-
if (!$global) {
|
|
952
|
-
scopeLookup.$global = $global = scopes.$ || {};
|
|
953
|
-
$global.runtimeId = this.___runtimeId;
|
|
954
|
-
$global.renderId = this.___renderId;
|
|
955
|
-
}
|
|
956
|
-
for (const scopeId in scopes) {
|
|
957
|
-
if (scopeId !== "$") {
|
|
958
|
-
const scope = scopes[scopeId];
|
|
959
|
-
const prevScope = scopeLookup[scopeId];
|
|
960
|
-
scope.$global = $global;
|
|
961
|
-
if (prevScope !== scope) {
|
|
962
|
-
scopeLookup[scopeId] = Object.assign(
|
|
963
|
-
scope,
|
|
964
|
-
prevScope
|
|
965
|
-
);
|
|
966
|
-
}
|
|
967
|
-
const cleanupOwnerId = cleanupOwners.get(scopeId);
|
|
968
|
-
if (cleanupOwnerId) {
|
|
969
|
-
scope.___cleanupOwner = scopes[cleanupOwnerId];
|
|
970
|
-
onDestroy(scope);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
} else if (i === len || typeof resumes[i] !== "string") {
|
|
975
|
-
delete this.___renders[this.___renderId];
|
|
976
|
-
} else {
|
|
977
|
-
registeredValues[resumes[i++]](
|
|
978
|
-
scopeLookup[resumeData]
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
} finally {
|
|
983
|
-
isResuming = false;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
var isResuming = false;
|
|
989
|
-
function register(id, obj) {
|
|
990
|
-
registeredValues[id] = obj;
|
|
991
|
-
return obj;
|
|
992
|
-
}
|
|
993
|
-
function registerBoundSignal(id, signal) {
|
|
994
|
-
registeredValues[id] = (scope) => (valueOrOp) => signal(scope, valueOrOp);
|
|
995
|
-
return signal;
|
|
996
|
-
}
|
|
997
|
-
function getRegisteredWithScope(id, scope) {
|
|
998
|
-
const val = registeredValues[id];
|
|
999
|
-
return scope ? val(scope) : val;
|
|
1000
|
-
}
|
|
1001
|
-
function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
1002
|
-
if (true) {
|
|
1003
|
-
if (!runtimeId.match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
|
1004
|
-
throw new Error(
|
|
1005
|
-
`Invalid runtimeId: "${runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
|
1006
|
-
);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
const resumeRender = (renderId) => resumeRender[renderId] = renders[renderId] = new Render(renders, runtimeId, renderId);
|
|
1010
|
-
let renders;
|
|
1011
|
-
if (window[runtimeId]) {
|
|
1012
|
-
setRenders(window[runtimeId]);
|
|
1013
|
-
} else {
|
|
1014
|
-
Object.defineProperty(window, runtimeId, {
|
|
1015
|
-
configurable: true,
|
|
1016
|
-
set: setRenders
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
function setRenders(v) {
|
|
1020
|
-
if (true) {
|
|
1021
|
-
if (renders) {
|
|
1022
|
-
throw new Error(
|
|
1023
|
-
"Marko tried to initialize multiple times. It could be that there are multiple instances of Marko running on the page."
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
renders = v;
|
|
1028
|
-
for (const renderId in v) {
|
|
1029
|
-
resumeRender(renderId);
|
|
1030
|
-
}
|
|
1031
|
-
Object.defineProperty(window, runtimeId, {
|
|
1032
|
-
configurable: true,
|
|
1033
|
-
value: resumeRender
|
|
1034
|
-
});
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
function registerSubscriber(id, signal) {
|
|
1038
|
-
register(id, signal.___subscribe);
|
|
1039
|
-
return signal;
|
|
1040
|
-
}
|
|
1041
|
-
function nodeRef(id, key) {
|
|
1042
|
-
return register(id, (scope) => () => scope[key]);
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
1010
|
// src/dom/controllable.ts
|
|
1046
1011
|
function controllable_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
1047
1012
|
setCheckboxValue(
|
|
@@ -1058,7 +1023,8 @@ function controllable_input_checked_effect(scope, nodeAccessor) {
|
|
|
1058
1023
|
const checkedChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
|
1059
1024
|
if (checkedChange) {
|
|
1060
1025
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
|
1061
|
-
|
|
1026
|
+
checkedChange(el.checked);
|
|
1027
|
+
run();
|
|
1062
1028
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
|
1063
1029
|
el.checked = !el.checked;
|
|
1064
1030
|
}
|
|
@@ -1083,10 +1049,10 @@ function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
|
|
1083
1049
|
if (checkedValueChange) {
|
|
1084
1050
|
const oldValue = scope[nodeAccessor + ":" /* ControlledValue */];
|
|
1085
1051
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
|
1086
|
-
|
|
1087
|
-
checkedValueChange,
|
|
1052
|
+
checkedValueChange(
|
|
1088
1053
|
Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0
|
|
1089
1054
|
);
|
|
1055
|
+
run();
|
|
1090
1056
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
|
1091
1057
|
el.checked = !el.checked;
|
|
1092
1058
|
}
|
|
@@ -1120,7 +1086,8 @@ function controllable_input_value_effect(scope, nodeAccessor) {
|
|
|
1120
1086
|
if (valueChange) {
|
|
1121
1087
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
|
1122
1088
|
if (ev) inputType = ev.inputType;
|
|
1123
|
-
|
|
1089
|
+
valueChange(el.value);
|
|
1090
|
+
run();
|
|
1124
1091
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
|
1125
1092
|
setValueAndUpdateSelection(
|
|
1126
1093
|
el,
|
|
@@ -1151,10 +1118,10 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
|
1151
1118
|
const valueChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
|
1152
1119
|
if (valueChange) {
|
|
1153
1120
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
|
1154
|
-
|
|
1155
|
-
valueChange,
|
|
1121
|
+
valueChange(
|
|
1156
1122
|
Array.isArray(scope[nodeAccessor + ":" /* ControlledValue */]) ? Array.from(el.selectedOptions, toValueProp) : el.value
|
|
1157
1123
|
);
|
|
1124
|
+
run();
|
|
1158
1125
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
|
1159
1126
|
setSelectOptions(
|
|
1160
1127
|
el,
|
|
@@ -1207,7 +1174,8 @@ function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
|
|
1207
1174
|
const openChange = scope[nodeAccessor + ";" /* ControlledHandler */];
|
|
1208
1175
|
if (openChange) {
|
|
1209
1176
|
scope[nodeAccessor + "=" /* ControlledType */] = 6 /* Pending */;
|
|
1210
|
-
|
|
1177
|
+
openChange(el.open);
|
|
1178
|
+
run();
|
|
1211
1179
|
if (scope[nodeAccessor + "=" /* ControlledType */] === 6 /* Pending */) {
|
|
1212
1180
|
el.open = !el.open;
|
|
1213
1181
|
}
|
|
@@ -1684,7 +1652,7 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
|
1684
1652
|
}
|
|
1685
1653
|
};
|
|
1686
1654
|
}
|
|
1687
|
-
function createRendererWithOwner(template, rawWalks, setup, getClosureSignals,
|
|
1655
|
+
function createRendererWithOwner(template, rawWalks, setup, getClosureSignals, getArgs) {
|
|
1688
1656
|
let args;
|
|
1689
1657
|
let closureSignals;
|
|
1690
1658
|
const id = true ? Symbol("Marko Renderer") : {};
|
|
@@ -1697,7 +1665,6 @@ function createRendererWithOwner(template, rawWalks, setup, getClosureSignals, h
|
|
|
1697
1665
|
___setup: setup,
|
|
1698
1666
|
___clone: _clone,
|
|
1699
1667
|
___owner: owner,
|
|
1700
|
-
___hasUserEffects: hasUserEffects,
|
|
1701
1668
|
___sourceNode: void 0,
|
|
1702
1669
|
get ___args() {
|
|
1703
1670
|
return args ||= getArgs?.();
|
|
@@ -1708,13 +1675,12 @@ function createRendererWithOwner(template, rawWalks, setup, getClosureSignals, h
|
|
|
1708
1675
|
};
|
|
1709
1676
|
};
|
|
1710
1677
|
}
|
|
1711
|
-
function createRenderer(template, walks, setup, getClosureSignals,
|
|
1678
|
+
function createRenderer(template, walks, setup, getClosureSignals, getArgs) {
|
|
1712
1679
|
return createRendererWithOwner(
|
|
1713
1680
|
template,
|
|
1714
1681
|
walks,
|
|
1715
1682
|
setup,
|
|
1716
1683
|
getClosureSignals,
|
|
1717
|
-
hasUserEffects,
|
|
1718
1684
|
getArgs
|
|
1719
1685
|
)();
|
|
1720
1686
|
}
|
|
@@ -1742,7 +1708,7 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
|
1742
1708
|
if (isDifferentRenderer(normalizedRenderer, currentRenderer)) {
|
|
1743
1709
|
currentRenderer = scope[rendererAccessor] = normalizedRenderer;
|
|
1744
1710
|
setConditionalRenderer(scope, nodeAccessor, normalizedRenderer);
|
|
1745
|
-
fn
|
|
1711
|
+
fn && fn(scope);
|
|
1746
1712
|
op = DIRTY;
|
|
1747
1713
|
} else {
|
|
1748
1714
|
op = CLEAN;
|
|
@@ -1803,7 +1769,7 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
|
1803
1769
|
nodeAccessor,
|
|
1804
1770
|
normalizedRenderer
|
|
1805
1771
|
);
|
|
1806
|
-
fn
|
|
1772
|
+
fn && fn(scope);
|
|
1807
1773
|
op = DIRTY;
|
|
1808
1774
|
} else {
|
|
1809
1775
|
op = CLEAN;
|
|
@@ -1916,11 +1882,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
|
1916
1882
|
newArray = emptyMarkerArray;
|
|
1917
1883
|
getEmptyScope(referenceNode);
|
|
1918
1884
|
} else {
|
|
1919
|
-
|
|
1920
|
-
for (let i = 0; i < oldArray.length; i++) {
|
|
1921
|
-
destroyScope(oldArray[i]);
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1885
|
+
oldArray.forEach(destroyScope);
|
|
1924
1886
|
referenceNode.textContent = "";
|
|
1925
1887
|
newMap = emptyMap;
|
|
1926
1888
|
newArray = emptyArray;
|
|
@@ -2013,7 +1975,6 @@ var compat = {
|
|
|
2013
1975
|
void 0,
|
|
2014
1976
|
setup,
|
|
2015
1977
|
void 0,
|
|
2016
|
-
1,
|
|
2017
1978
|
args && (() => args)
|
|
2018
1979
|
);
|
|
2019
1980
|
renderer.___clone = clone;
|
|
@@ -2030,7 +1991,7 @@ var compat = {
|
|
|
2030
1991
|
}
|
|
2031
1992
|
const args = renderer.___args || noop;
|
|
2032
1993
|
let existing = false;
|
|
2033
|
-
component.effects =
|
|
1994
|
+
component.effects = prepareEffects(() => {
|
|
2034
1995
|
if (!scope) {
|
|
2035
1996
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
|
2036
1997
|
const closures = renderer.___closureSignals;
|
|
@@ -2054,7 +2015,8 @@ function noop() {
|
|
|
2054
2015
|
}
|
|
2055
2016
|
|
|
2056
2017
|
// src/dom/template.ts
|
|
2057
|
-
var createTemplate = (
|
|
2018
|
+
var createTemplate = (templateId, ...rendererArgs) => {
|
|
2019
|
+
const renderer = createRenderer(...rendererArgs);
|
|
2058
2020
|
renderer.mount = mount;
|
|
2059
2021
|
renderer._ = renderer;
|
|
2060
2022
|
if (true) {
|
|
@@ -2083,7 +2045,7 @@ function mount(input = {}, reference, position) {
|
|
|
2083
2045
|
};
|
|
2084
2046
|
}
|
|
2085
2047
|
const args = this.___args;
|
|
2086
|
-
const effects =
|
|
2048
|
+
const effects = prepareEffects(() => {
|
|
2087
2049
|
scope = createScope($global);
|
|
2088
2050
|
dom = initRenderer(this, scope);
|
|
2089
2051
|
if (args) {
|
|
@@ -2108,10 +2070,12 @@ function mount(input = {}, reference, position) {
|
|
|
2108
2070
|
return {
|
|
2109
2071
|
update: (newInput) => {
|
|
2110
2072
|
if (args) {
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2073
|
+
runEffects(
|
|
2074
|
+
prepareEffects(() => {
|
|
2075
|
+
args(scope, MARK);
|
|
2076
|
+
args(scope, [newInput]);
|
|
2077
|
+
})
|
|
2078
|
+
);
|
|
2115
2079
|
}
|
|
2116
2080
|
},
|
|
2117
2081
|
destroy: () => {
|