@askrjs/askr 0.0.1 → 0.0.3

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.
Files changed (52) hide show
  1. package/README.md +18 -10
  2. package/dist/chunk-2ONGHQ7Z.js +3115 -0
  3. package/dist/chunk-2ONGHQ7Z.js.map +1 -0
  4. package/dist/{chunk-UUM5W2RM.js → chunk-H3NSVHA7.js} +2 -6
  5. package/dist/chunk-H3NSVHA7.js.map +1 -0
  6. package/dist/chunk-JHOGWTAW.js +16 -0
  7. package/dist/chunk-JHOGWTAW.js.map +1 -0
  8. package/dist/chunk-OFW6DFBM.js +716 -0
  9. package/dist/chunk-OFW6DFBM.js.map +1 -0
  10. package/dist/chunk-SALJX5PZ.js +26 -0
  11. package/dist/chunk-SALJX5PZ.js.map +1 -0
  12. package/dist/index.cjs +2785 -2327
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +100 -45
  15. package/dist/index.d.ts +100 -45
  16. package/dist/index.js +430 -84
  17. package/dist/index.js.map +1 -1
  18. package/dist/jsx/jsx-dev-runtime.cjs +9 -3
  19. package/dist/jsx/jsx-dev-runtime.cjs.map +1 -1
  20. package/dist/jsx/jsx-dev-runtime.d.cts +4 -9
  21. package/dist/jsx/jsx-dev-runtime.d.ts +4 -9
  22. package/dist/jsx/jsx-dev-runtime.js +7 -4
  23. package/dist/jsx/jsx-dev-runtime.js.map +1 -1
  24. package/dist/jsx/jsx-runtime.cjs +14 -5
  25. package/dist/jsx/jsx-runtime.cjs.map +1 -1
  26. package/dist/jsx/jsx-runtime.d.cts +9 -6
  27. package/dist/jsx/jsx-runtime.d.ts +9 -6
  28. package/dist/jsx/jsx-runtime.js +6 -4
  29. package/dist/{navigate-NLQOZQGM.js → navigate-CZEUXFPM.js} +5 -5
  30. package/dist/{route-TVYWYCEJ.js → route-USEXGOBT.js} +4 -4
  31. package/dist/{ssr-4ELUFK65.js → ssr-QJ5NTQR6.js} +9 -5
  32. package/dist/{types-DUDmnzD8.d.cts → types-DLTViI21.d.cts} +15 -3
  33. package/dist/{types-DUDmnzD8.d.ts → types-DLTViI21.d.ts} +15 -3
  34. package/package.json +7 -4
  35. package/src/jsx/index.ts +4 -0
  36. package/src/jsx/jsx-dev-runtime.ts +7 -10
  37. package/src/jsx/jsx-runtime.ts +23 -11
  38. package/src/jsx/types.ts +22 -3
  39. package/src/jsx/utils.ts +19 -0
  40. package/dist/chunk-4CV4JOE5.js +0 -27
  41. package/dist/chunk-HIWJVOS4.js +0 -503
  42. package/dist/chunk-HIWJVOS4.js.map +0 -1
  43. package/dist/chunk-L7RL4LYV.js +0 -3442
  44. package/dist/chunk-L7RL4LYV.js.map +0 -1
  45. package/dist/chunk-UUM5W2RM.js.map +0 -1
  46. package/dist/chunk-YNH3D4KW.js +0 -29
  47. package/dist/chunk-YNH3D4KW.js.map +0 -1
  48. package/dist/ssr-4ELUFK65.js.map +0 -1
  49. package/src/jsx/react-jsx-runtime.d.ts +0 -0
  50. /package/dist/{chunk-4CV4JOE5.js.map → navigate-CZEUXFPM.js.map} +0 -0
  51. /package/dist/{navigate-NLQOZQGM.js.map → route-USEXGOBT.js.map} +0 -0
  52. /package/dist/{route-TVYWYCEJ.js.map → ssr-QJ5NTQR6.js.map} +0 -0
@@ -0,0 +1,3115 @@
1
+ import {
2
+ Fragment as Fragment2
3
+ } from "./chunk-SALJX5PZ.js";
4
+ import {
5
+ Fragment,
6
+ __export
7
+ } from "./chunk-JHOGWTAW.js";
8
+
9
+ // src/router/route.ts
10
+ var route_exports = {};
11
+ __export(route_exports, {
12
+ _lockRouteRegistrationForTests: () => _lockRouteRegistrationForTests,
13
+ _unlockRouteRegistrationForTests: () => _unlockRouteRegistrationForTests,
14
+ clearRoutes: () => clearRoutes,
15
+ getLoadedNamespaces: () => getLoadedNamespaces,
16
+ getNamespaceRoutes: () => getNamespaceRoutes,
17
+ getRoutes: () => getRoutes,
18
+ lockRouteRegistration: () => lockRouteRegistration,
19
+ registerRoute: () => registerRoute,
20
+ resolveRoute: () => resolveRoute,
21
+ route: () => route,
22
+ setServerLocation: () => setServerLocation,
23
+ unloadNamespace: () => unloadNamespace
24
+ });
25
+
26
+ // src/router/match.ts
27
+ function match(path, pattern) {
28
+ const normalizedPath = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
29
+ const normalizedPattern = pattern.endsWith("/") && pattern !== "/" ? pattern.slice(0, -1) : pattern;
30
+ const pathSegments = normalizedPath.split("/").filter(Boolean);
31
+ const patternSegments = normalizedPattern.split("/").filter(Boolean);
32
+ if (patternSegments.length === 1 && patternSegments[0] === "*") {
33
+ return {
34
+ matched: true,
35
+ params: {
36
+ "*": pathSegments.length > 1 ? normalizedPath : pathSegments[0]
37
+ }
38
+ };
39
+ }
40
+ if (pathSegments.length !== patternSegments.length) {
41
+ return { matched: false, params: {} };
42
+ }
43
+ const params = {};
44
+ for (let i = 0; i < patternSegments.length; i++) {
45
+ const patternSegment = patternSegments[i];
46
+ const pathSegment = pathSegments[i];
47
+ if (patternSegment.startsWith("{") && patternSegment.endsWith("}")) {
48
+ const paramName = patternSegment.slice(1, -1);
49
+ params[paramName] = decodeURIComponent(pathSegment);
50
+ } else if (patternSegment === "*") {
51
+ params["*"] = pathSegment;
52
+ } else if (patternSegment !== pathSegment) {
53
+ return { matched: false, params: {} };
54
+ }
55
+ }
56
+ return { matched: true, params };
57
+ }
58
+
59
+ // src/dev/invariant.ts
60
+ function invariant(condition, message, context) {
61
+ if (!condition) {
62
+ const contextStr = context ? "\n" + JSON.stringify(context, null, 2) : "";
63
+ throw new Error(`[Askr Invariant] ${message}${contextStr}`);
64
+ }
65
+ }
66
+ function assertSchedulingPrecondition(condition, violationMessage) {
67
+ invariant(condition, `[Scheduler Precondition] ${violationMessage}`);
68
+ }
69
+
70
+ // src/dev/logger.ts
71
+ function callConsole(method, args) {
72
+ const c = typeof console !== "undefined" ? console : void 0;
73
+ if (!c) return;
74
+ const fn = c[method];
75
+ if (typeof fn === "function") {
76
+ try {
77
+ fn.apply(console, args);
78
+ } catch {
79
+ }
80
+ }
81
+ }
82
+ var logger = {
83
+ debug: (...args) => {
84
+ if (process.env.NODE_ENV === "production") return;
85
+ callConsole("debug", args);
86
+ },
87
+ info: (...args) => {
88
+ if (process.env.NODE_ENV === "production") return;
89
+ callConsole("info", args);
90
+ },
91
+ warn: (...args) => {
92
+ if (process.env.NODE_ENV === "production") return;
93
+ callConsole("warn", args);
94
+ },
95
+ error: (...args) => {
96
+ callConsole("error", args);
97
+ }
98
+ };
99
+
100
+ // src/runtime/scheduler.ts
101
+ var MAX_FLUSH_DEPTH = 50;
102
+ function isBulkCommitActive() {
103
+ try {
104
+ const fb = globalThis.__ASKR_FASTLANE;
105
+ return typeof fb?.isBulkCommitActive === "function" ? !!fb.isBulkCommitActive() : false;
106
+ } catch (e) {
107
+ void e;
108
+ return false;
109
+ }
110
+ }
111
+ var Scheduler = class {
112
+ constructor() {
113
+ this.q = [];
114
+ this.head = 0;
115
+ this.running = false;
116
+ this.inHandler = false;
117
+ this.depth = 0;
118
+ this.executionDepth = 0;
119
+ // for compat with existing diagnostics
120
+ // Monotonic flush version increments at end of each flush
121
+ this.flushVersion = 0;
122
+ // Best-effort microtask kick scheduling
123
+ this.kickScheduled = false;
124
+ // Escape hatch flag for runWithSyncProgress
125
+ this.allowSyncProgress = false;
126
+ // Waiters waiting for flushVersion >= target
127
+ this.waiters = [];
128
+ // Keep a lightweight taskCount for compatibility/diagnostics
129
+ this.taskCount = 0;
130
+ }
131
+ enqueue(task) {
132
+ assertSchedulingPrecondition(
133
+ typeof task === "function",
134
+ "enqueue() requires a function"
135
+ );
136
+ if (isBulkCommitActive() && !this.allowSyncProgress) {
137
+ if (process.env.NODE_ENV !== "production") {
138
+ throw new Error(
139
+ "[Scheduler] enqueue() during bulk commit (not allowed)"
140
+ );
141
+ }
142
+ return;
143
+ }
144
+ this.q.push(task);
145
+ this.taskCount++;
146
+ if (!this.running && !this.kickScheduled && !this.inHandler && !isBulkCommitActive()) {
147
+ this.kickScheduled = true;
148
+ queueMicrotask(() => {
149
+ this.kickScheduled = false;
150
+ if (this.running) return;
151
+ if (isBulkCommitActive()) return;
152
+ try {
153
+ this.flush();
154
+ } catch (err) {
155
+ setTimeout(() => {
156
+ throw err;
157
+ });
158
+ }
159
+ });
160
+ }
161
+ }
162
+ flush() {
163
+ invariant(
164
+ !this.running,
165
+ "[Scheduler] flush() called while already running"
166
+ );
167
+ if (process.env.NODE_ENV !== "production") {
168
+ if (isBulkCommitActive() && !this.allowSyncProgress) {
169
+ throw new Error(
170
+ "[Scheduler] flush() started during bulk commit (not allowed)"
171
+ );
172
+ }
173
+ }
174
+ this.running = true;
175
+ this.depth = 0;
176
+ let fatal = null;
177
+ try {
178
+ while (this.head < this.q.length) {
179
+ this.depth++;
180
+ if (process.env.NODE_ENV !== "production" && this.depth > MAX_FLUSH_DEPTH) {
181
+ throw new Error(
182
+ `[Scheduler] exceeded MAX_FLUSH_DEPTH (${MAX_FLUSH_DEPTH}). Likely infinite update loop.`
183
+ );
184
+ }
185
+ const task = this.q[this.head++];
186
+ try {
187
+ this.executionDepth++;
188
+ task();
189
+ this.executionDepth--;
190
+ } catch (err) {
191
+ if (this.executionDepth > 0) this.executionDepth = 0;
192
+ fatal = err;
193
+ break;
194
+ }
195
+ if (this.taskCount > 0) this.taskCount--;
196
+ }
197
+ } finally {
198
+ this.running = false;
199
+ this.depth = 0;
200
+ this.executionDepth = 0;
201
+ if (this.head >= this.q.length) {
202
+ this.q.length = 0;
203
+ this.head = 0;
204
+ } else if (this.head > 0) {
205
+ const remaining = this.q.length - this.head;
206
+ if (this.head > 1024 || this.head > remaining) {
207
+ this.q = this.q.slice(this.head);
208
+ } else {
209
+ for (let i = 0; i < remaining; i++) {
210
+ this.q[i] = this.q[this.head + i];
211
+ }
212
+ this.q.length = remaining;
213
+ }
214
+ this.head = 0;
215
+ }
216
+ this.flushVersion++;
217
+ this.resolveWaiters();
218
+ }
219
+ if (fatal) throw fatal;
220
+ }
221
+ runWithSyncProgress(fn) {
222
+ const prev = this.allowSyncProgress;
223
+ this.allowSyncProgress = true;
224
+ const g = globalThis;
225
+ const origQueueMicrotask = g.queueMicrotask;
226
+ const origSetTimeout = g.setTimeout;
227
+ if (process.env.NODE_ENV !== "production") {
228
+ g.queueMicrotask = () => {
229
+ throw new Error(
230
+ "[Scheduler] queueMicrotask not allowed during runWithSyncProgress"
231
+ );
232
+ };
233
+ g.setTimeout = () => {
234
+ throw new Error(
235
+ "[Scheduler] setTimeout not allowed during runWithSyncProgress"
236
+ );
237
+ };
238
+ }
239
+ const startVersion = this.flushVersion;
240
+ try {
241
+ const res = fn();
242
+ if (!this.running && this.q.length - this.head > 0) {
243
+ this.flush();
244
+ }
245
+ if (process.env.NODE_ENV !== "production") {
246
+ if (this.q.length - this.head > 0) {
247
+ throw new Error(
248
+ "[Scheduler] tasks remain after runWithSyncProgress flush"
249
+ );
250
+ }
251
+ }
252
+ return res;
253
+ } finally {
254
+ if (process.env.NODE_ENV !== "production") {
255
+ g.queueMicrotask = origQueueMicrotask;
256
+ g.setTimeout = origSetTimeout;
257
+ }
258
+ try {
259
+ if (this.flushVersion === startVersion) {
260
+ this.flushVersion++;
261
+ this.resolveWaiters();
262
+ }
263
+ } catch (e) {
264
+ void e;
265
+ }
266
+ this.allowSyncProgress = prev;
267
+ }
268
+ }
269
+ waitForFlush(targetVersion, timeoutMs = 2e3) {
270
+ const target = typeof targetVersion === "number" ? targetVersion : this.flushVersion + 1;
271
+ if (this.flushVersion >= target) return Promise.resolve();
272
+ return new Promise((resolve, reject) => {
273
+ const timer = setTimeout(() => {
274
+ const ns = globalThis.__ASKR__ || {};
275
+ const diag = {
276
+ flushVersion: this.flushVersion,
277
+ queueLen: this.q.length - this.head,
278
+ running: this.running,
279
+ inHandler: this.inHandler,
280
+ bulk: isBulkCommitActive(),
281
+ namespace: ns
282
+ };
283
+ reject(
284
+ new Error(
285
+ `waitForFlush timeout ${timeoutMs}ms: ${JSON.stringify(diag)}`
286
+ )
287
+ );
288
+ }, timeoutMs);
289
+ this.waiters.push({ target, resolve, reject, timer });
290
+ });
291
+ }
292
+ getState() {
293
+ return {
294
+ queueLength: this.q.length - this.head,
295
+ running: this.running,
296
+ depth: this.depth,
297
+ executionDepth: this.executionDepth,
298
+ taskCount: this.taskCount,
299
+ flushVersion: this.flushVersion,
300
+ // New fields for optional inspection
301
+ inHandler: this.inHandler,
302
+ allowSyncProgress: this.allowSyncProgress
303
+ };
304
+ }
305
+ setInHandler(v) {
306
+ this.inHandler = v;
307
+ }
308
+ isInHandler() {
309
+ return this.inHandler;
310
+ }
311
+ isExecuting() {
312
+ return this.running || this.executionDepth > 0;
313
+ }
314
+ // Clear pending synchronous tasks (used by fastlane enter/exit)
315
+ clearPendingSyncTasks() {
316
+ const remaining = this.q.length - this.head;
317
+ if (remaining <= 0) return 0;
318
+ if (this.running) {
319
+ this.q.length = this.head;
320
+ this.taskCount = Math.max(0, this.taskCount - remaining);
321
+ queueMicrotask(() => {
322
+ try {
323
+ this.flushVersion++;
324
+ this.resolveWaiters();
325
+ } catch (e) {
326
+ void e;
327
+ }
328
+ });
329
+ return remaining;
330
+ }
331
+ this.q.length = 0;
332
+ this.head = 0;
333
+ this.taskCount = Math.max(0, this.taskCount - remaining);
334
+ this.flushVersion++;
335
+ this.resolveWaiters();
336
+ return remaining;
337
+ }
338
+ resolveWaiters() {
339
+ if (this.waiters.length === 0) return;
340
+ const ready = [];
341
+ const remaining = [];
342
+ for (const w of this.waiters) {
343
+ if (this.flushVersion >= w.target) {
344
+ if (w.timer) clearTimeout(w.timer);
345
+ ready.push(w.resolve);
346
+ } else {
347
+ remaining.push(w);
348
+ }
349
+ }
350
+ this.waiters = remaining;
351
+ for (const r of ready) r();
352
+ }
353
+ };
354
+ var globalScheduler = new Scheduler();
355
+ function isSchedulerExecuting() {
356
+ return globalScheduler.isExecuting();
357
+ }
358
+ function scheduleEventHandler(handler) {
359
+ return (event) => {
360
+ globalScheduler.setInHandler(true);
361
+ try {
362
+ handler.call(null, event);
363
+ } catch (error) {
364
+ logger.error("[Askr] Event handler error:", error);
365
+ } finally {
366
+ globalScheduler.setInHandler(false);
367
+ const state = globalScheduler.getState();
368
+ if ((state.queueLength ?? 0) > 0 && !state.running) {
369
+ queueMicrotask(() => {
370
+ try {
371
+ if (!globalScheduler.isExecuting()) globalScheduler.flush();
372
+ } catch (err) {
373
+ setTimeout(() => {
374
+ throw err;
375
+ });
376
+ }
377
+ });
378
+ }
379
+ }
380
+ };
381
+ }
382
+
383
+ // src/runtime/context.ts
384
+ var CONTEXT_FRAME_SYMBOL = /* @__PURE__ */ Symbol("__tempoContextFrame__");
385
+ var currentContextFrame = null;
386
+ var currentAsyncResourceFrame = null;
387
+ function withContext(frame, fn) {
388
+ const oldFrame = currentContextFrame;
389
+ currentContextFrame = frame;
390
+ try {
391
+ return fn();
392
+ } finally {
393
+ currentContextFrame = oldFrame;
394
+ }
395
+ }
396
+ function withAsyncResourceContext(frame, fn) {
397
+ const oldFrame = currentAsyncResourceFrame;
398
+ currentAsyncResourceFrame = frame;
399
+ try {
400
+ return fn();
401
+ } finally {
402
+ currentAsyncResourceFrame = oldFrame;
403
+ }
404
+ }
405
+ function defineContext(defaultValue) {
406
+ const key = /* @__PURE__ */ Symbol("AskrContext");
407
+ return {
408
+ key,
409
+ defaultValue,
410
+ Scope: (props) => {
411
+ const value = props.value;
412
+ return {
413
+ type: ContextScopeComponent,
414
+ props: { key, value, children: props.children }
415
+ };
416
+ }
417
+ };
418
+ }
419
+ function readContext(context) {
420
+ const frame = currentContextFrame || currentAsyncResourceFrame;
421
+ if (!frame) {
422
+ throw new Error(
423
+ "readContext() can only be called during component render or async resource execution. Ensure you are calling this from inside your component or resource function."
424
+ );
425
+ }
426
+ let current = frame;
427
+ while (current) {
428
+ const values = current.values;
429
+ if (values && values.has(context.key)) {
430
+ return values.get(context.key);
431
+ }
432
+ current = current.parent;
433
+ }
434
+ return context.defaultValue;
435
+ }
436
+ function ContextScopeComponent(props) {
437
+ const key = props["key"];
438
+ const value = props["value"];
439
+ const children = props["children"];
440
+ const instance = getCurrentComponentInstance();
441
+ const parentFrame = (() => {
442
+ if (currentContextFrame) return currentContextFrame;
443
+ if (instance && instance.ownerFrame) return instance.ownerFrame;
444
+ return null;
445
+ })();
446
+ const newFrame = {
447
+ parent: parentFrame,
448
+ values: /* @__PURE__ */ new Map([[key, value]])
449
+ };
450
+ function createFunctionChildInvoker(fn, frame, owner) {
451
+ return {
452
+ type: ContextFunctionChildInvoker,
453
+ props: { fn, __frame: frame, __owner: owner }
454
+ };
455
+ }
456
+ if (Array.isArray(children)) {
457
+ return children.map((child) => {
458
+ if (typeof child === "function") {
459
+ return createFunctionChildInvoker(
460
+ child,
461
+ newFrame,
462
+ getCurrentComponentInstance()
463
+ );
464
+ }
465
+ return markWithFrame(child, newFrame);
466
+ });
467
+ } else if (typeof children === "function") {
468
+ return createFunctionChildInvoker(
469
+ children,
470
+ newFrame,
471
+ getCurrentComponentInstance()
472
+ );
473
+ } else if (children) {
474
+ return markWithFrame(children, newFrame);
475
+ }
476
+ return null;
477
+ }
478
+ function markWithFrame(node, frame) {
479
+ if (typeof node === "object" && node !== null) {
480
+ const obj = node;
481
+ obj[CONTEXT_FRAME_SYMBOL] = frame;
482
+ const children = obj.children;
483
+ if (Array.isArray(children)) {
484
+ for (let i = 0; i < children.length; i++) {
485
+ const child = children[i];
486
+ if (child) {
487
+ children[i] = markWithFrame(child, frame);
488
+ }
489
+ }
490
+ } else if (children) {
491
+ obj.children = markWithFrame(children, frame);
492
+ }
493
+ }
494
+ return node;
495
+ }
496
+ function ContextFunctionChildInvoker(props) {
497
+ const { fn, __frame } = props;
498
+ const res = withContext(__frame, () => fn());
499
+ if (res) return markWithFrame(res, __frame);
500
+ return null;
501
+ }
502
+ function getCurrentContextFrame() {
503
+ return currentContextFrame;
504
+ }
505
+
506
+ // src/renderer/diag/index.ts
507
+ function getDiagMap() {
508
+ try {
509
+ const root = globalThis;
510
+ if (!root.__ASKR_DIAG) root.__ASKR_DIAG = {};
511
+ return root.__ASKR_DIAG;
512
+ } catch (e) {
513
+ void e;
514
+ return {};
515
+ }
516
+ }
517
+ function __ASKR_set(key, value) {
518
+ try {
519
+ const g = getDiagMap();
520
+ g[key] = value;
521
+ try {
522
+ const root = globalThis;
523
+ try {
524
+ const ns = root.__ASKR__ || (root.__ASKR__ = {});
525
+ try {
526
+ ns[key] = value;
527
+ } catch (e) {
528
+ void e;
529
+ }
530
+ } catch (e) {
531
+ void e;
532
+ }
533
+ } catch (e) {
534
+ void e;
535
+ }
536
+ } catch (e) {
537
+ void e;
538
+ }
539
+ }
540
+ function __ASKR_incCounter(key) {
541
+ try {
542
+ const g = getDiagMap();
543
+ const prev = typeof g[key] === "number" ? g[key] : 0;
544
+ const next = prev + 1;
545
+ g[key] = next;
546
+ try {
547
+ const root = globalThis;
548
+ const ns = root.__ASKR__ || (root.__ASKR__ = {});
549
+ try {
550
+ const nsPrev = typeof ns[key] === "number" ? ns[key] : 0;
551
+ ns[key] = nsPrev + 1;
552
+ } catch (e) {
553
+ void e;
554
+ }
555
+ } catch (e) {
556
+ void e;
557
+ }
558
+ } catch (e) {
559
+ void e;
560
+ }
561
+ }
562
+
563
+ // src/runtime/dev-namespace.ts
564
+ function getDevNamespace() {
565
+ if (process.env.NODE_ENV === "production") return {};
566
+ try {
567
+ const g = globalThis;
568
+ if (!g.__ASKR__) g.__ASKR__ = {};
569
+ return g.__ASKR__;
570
+ } catch {
571
+ return {};
572
+ }
573
+ }
574
+ function setDevValue(key, value) {
575
+ if (process.env.NODE_ENV === "production") return;
576
+ try {
577
+ getDevNamespace()[key] = value;
578
+ } catch {
579
+ }
580
+ }
581
+ function getDevValue(key) {
582
+ if (process.env.NODE_ENV === "production") return void 0;
583
+ try {
584
+ return getDevNamespace()[key];
585
+ } catch {
586
+ return void 0;
587
+ }
588
+ }
589
+
590
+ // src/runtime/fastlane-shared.ts
591
+ var _bulkCommitActive = false;
592
+ var _appliedParents = null;
593
+ function enterBulkCommit() {
594
+ _bulkCommitActive = true;
595
+ _appliedParents = /* @__PURE__ */ new WeakSet();
596
+ try {
597
+ const cleared = globalScheduler.clearPendingSyncTasks?.() ?? 0;
598
+ setDevValue("__ASKR_FASTLANE_CLEARED_TASKS", cleared);
599
+ } catch (err) {
600
+ if (process.env.NODE_ENV !== "production") throw err;
601
+ }
602
+ }
603
+ function exitBulkCommit() {
604
+ _bulkCommitActive = false;
605
+ _appliedParents = null;
606
+ }
607
+ function isBulkCommitActive2() {
608
+ return _bulkCommitActive;
609
+ }
610
+ function markFastPathApplied(parent) {
611
+ if (!_appliedParents) return;
612
+ try {
613
+ _appliedParents.add(parent);
614
+ } catch (e) {
615
+ void e;
616
+ }
617
+ }
618
+ function isFastPathApplied(parent) {
619
+ return !!(_appliedParents && _appliedParents.has(parent));
620
+ }
621
+
622
+ // src/renderer/types.ts
623
+ function _isDOMElement(node) {
624
+ return typeof node === "object" && node !== null && "type" in node;
625
+ }
626
+
627
+ // src/renderer/cleanup.ts
628
+ function cleanupSingleInstance(node, errors, strict) {
629
+ const inst = node.__ASKR_INSTANCE;
630
+ if (!inst) return;
631
+ try {
632
+ cleanupComponent(inst);
633
+ } catch (err) {
634
+ if (strict) errors.push(err);
635
+ else logger.warn("[Askr] cleanupComponent failed:", err);
636
+ }
637
+ try {
638
+ delete node.__ASKR_INSTANCE;
639
+ } catch (e) {
640
+ if (strict) errors.push(e);
641
+ }
642
+ }
643
+ function cleanupInstanceIfPresent(node, opts) {
644
+ if (!node || !(node instanceof Element)) return;
645
+ const errors = [];
646
+ const strict = opts?.strict ?? false;
647
+ try {
648
+ cleanupSingleInstance(node, errors, strict);
649
+ } catch (err) {
650
+ if (strict) errors.push(err);
651
+ else logger.warn("[Askr] cleanupInstanceIfPresent failed:", err);
652
+ }
653
+ try {
654
+ const descendants = node.querySelectorAll("*");
655
+ for (const d of Array.from(descendants)) {
656
+ try {
657
+ cleanupSingleInstance(d, errors, strict);
658
+ } catch (err) {
659
+ if (strict) errors.push(err);
660
+ else
661
+ logger.warn(
662
+ "[Askr] cleanupInstanceIfPresent descendant cleanup failed:",
663
+ err
664
+ );
665
+ }
666
+ }
667
+ } catch (err) {
668
+ if (strict) errors.push(err);
669
+ else
670
+ logger.warn(
671
+ "[Askr] cleanupInstanceIfPresent descendant query failed:",
672
+ err
673
+ );
674
+ }
675
+ if (errors.length > 0) {
676
+ throw new AggregateError(errors, "cleanupInstanceIfPresent failed");
677
+ }
678
+ }
679
+ function cleanupInstancesUnder(node, opts) {
680
+ cleanupInstanceIfPresent(node, opts);
681
+ }
682
+ var elementListeners = /* @__PURE__ */ new WeakMap();
683
+ function removeElementListeners(element) {
684
+ const map = elementListeners.get(element);
685
+ if (map) {
686
+ for (const [eventName, entry] of map) {
687
+ if (entry.options !== void 0)
688
+ element.removeEventListener(eventName, entry.handler, entry.options);
689
+ else element.removeEventListener(eventName, entry.handler);
690
+ }
691
+ elementListeners.delete(element);
692
+ }
693
+ }
694
+ function removeAllListeners(root) {
695
+ if (!root) return;
696
+ removeElementListeners(root);
697
+ const children = root.querySelectorAll("*");
698
+ for (let i = 0; i < children.length; i++) {
699
+ removeElementListeners(children[i]);
700
+ }
701
+ }
702
+
703
+ // src/renderer/utils.ts
704
+ function parseEventName(propName) {
705
+ if (!propName.startsWith("on") || propName.length <= 2) return null;
706
+ return propName.slice(2).charAt(0).toLowerCase() + propName.slice(3).toLowerCase();
707
+ }
708
+ function getPassiveOptions(eventName) {
709
+ if (eventName === "wheel" || eventName === "scroll" || eventName.startsWith("touch")) {
710
+ return { passive: true };
711
+ }
712
+ return void 0;
713
+ }
714
+ function createWrappedHandler(handler, flushAfter = false) {
715
+ return (event) => {
716
+ globalScheduler.setInHandler(true);
717
+ try {
718
+ handler(event);
719
+ } catch (error) {
720
+ logger.error("[Askr] Event handler error:", error);
721
+ } finally {
722
+ globalScheduler.setInHandler(false);
723
+ if (flushAfter) {
724
+ const state = globalScheduler.getState();
725
+ if ((state.queueLength ?? 0) > 0 && !state.running) {
726
+ queueMicrotask(() => {
727
+ try {
728
+ if (!globalScheduler.isExecuting()) globalScheduler.flush();
729
+ } catch (err) {
730
+ queueMicrotask(() => {
731
+ throw err;
732
+ });
733
+ }
734
+ });
735
+ }
736
+ }
737
+ }
738
+ };
739
+ }
740
+ function isSkippedProp(key) {
741
+ return key === "children" || key === "key";
742
+ }
743
+ function isIgnoredForPropChanges(key) {
744
+ if (key === "children" || key === "key") return true;
745
+ if (key.startsWith("on") && key.length > 2) return true;
746
+ if (key.startsWith("data-")) return true;
747
+ return false;
748
+ }
749
+ function hasPropChanged(el, key, value) {
750
+ try {
751
+ if (key === "class" || key === "className") {
752
+ return el.className !== String(value);
753
+ }
754
+ if (key === "value" || key === "checked") {
755
+ return el[key] !== value;
756
+ }
757
+ const attr = el.getAttribute(key);
758
+ if (value === void 0 || value === null || value === false) {
759
+ return attr !== null;
760
+ }
761
+ return String(value) !== attr;
762
+ } catch {
763
+ return true;
764
+ }
765
+ }
766
+ function hasNonTrivialProps(props) {
767
+ for (const k of Object.keys(props)) {
768
+ if (isIgnoredForPropChanges(k)) continue;
769
+ return true;
770
+ }
771
+ return false;
772
+ }
773
+ function checkPropChanges(el, props) {
774
+ for (const k of Object.keys(props)) {
775
+ if (isIgnoredForPropChanges(k)) continue;
776
+ if (hasPropChanged(el, k, props[k])) {
777
+ return true;
778
+ }
779
+ }
780
+ return false;
781
+ }
782
+ function extractKey(vnode) {
783
+ if (typeof vnode !== "object" || vnode === null) return void 0;
784
+ const obj = vnode;
785
+ const rawKey = obj.key ?? obj.props?.key;
786
+ if (rawKey === void 0) return void 0;
787
+ return typeof rawKey === "symbol" ? String(rawKey) : rawKey;
788
+ }
789
+ function buildKeyMapFromChildren(parent) {
790
+ const map = /* @__PURE__ */ new Map();
791
+ const children = Array.from(parent.children);
792
+ for (const ch of children) {
793
+ const k = ch.getAttribute("data-key");
794
+ if (k !== null) {
795
+ map.set(k, ch);
796
+ const n = Number(k);
797
+ if (!Number.isNaN(n)) map.set(n, ch);
798
+ }
799
+ }
800
+ return map;
801
+ }
802
+ function recordDOMReplace(source) {
803
+ try {
804
+ __ASKR_incCounter("__DOM_REPLACE_COUNT");
805
+ __ASKR_set(`__LAST_DOM_REPLACE_STACK_${source}`, new Error().stack);
806
+ } catch {
807
+ }
808
+ }
809
+ function recordFastPathStats(stats, counterName) {
810
+ try {
811
+ __ASKR_set("__LAST_FASTPATH_STATS", stats);
812
+ __ASKR_set("__LAST_FASTPATH_COMMIT_COUNT", 1);
813
+ if (counterName) {
814
+ __ASKR_incCounter(counterName);
815
+ }
816
+ } catch {
817
+ }
818
+ }
819
+ function logFastPathDebug(message, indexOrData, data) {
820
+ if (process.env.ASKR_FASTPATH_DEBUG === "1" || process.env.ASKR_FASTPATH_DEBUG === "true") {
821
+ if (data !== void 0) {
822
+ logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData, data);
823
+ } else if (indexOrData !== void 0) {
824
+ logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData);
825
+ } else {
826
+ logger.warn(`[Askr][FASTPATH] ${message}`);
827
+ }
828
+ }
829
+ }
830
+ function now() {
831
+ return typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
832
+ }
833
+
834
+ // src/renderer/keyed.ts
835
+ var keyedElements = /* @__PURE__ */ new WeakMap();
836
+ function getKeyMapForElement(el) {
837
+ return keyedElements.get(el);
838
+ }
839
+ function populateKeyMapForElement(parent) {
840
+ try {
841
+ if (keyedElements.has(parent)) return;
842
+ let domMap = buildKeyMapFromChildren(parent);
843
+ if (domMap.size === 0) {
844
+ domMap = /* @__PURE__ */ new Map();
845
+ const children = Array.from(parent.children);
846
+ for (const ch of children) {
847
+ const text = (ch.textContent || "").trim();
848
+ if (text) {
849
+ domMap.set(text, ch);
850
+ const n = Number(text);
851
+ if (!Number.isNaN(n)) domMap.set(n, ch);
852
+ }
853
+ }
854
+ }
855
+ if (domMap.size > 0) keyedElements.set(parent, domMap);
856
+ } catch {
857
+ }
858
+ }
859
+ var _reconcilerRecordedParents = /* @__PURE__ */ new WeakSet();
860
+ function extractKeyedVnodes(newChildren) {
861
+ const result = [];
862
+ for (const child of newChildren) {
863
+ const key = extractKey(child);
864
+ if (key !== void 0) {
865
+ result.push({ key, vnode: child });
866
+ }
867
+ }
868
+ return result;
869
+ }
870
+ function computeLISLength(positions) {
871
+ const tails = [];
872
+ for (const pos of positions) {
873
+ if (pos === -1) continue;
874
+ let lo = 0;
875
+ let hi = tails.length;
876
+ while (lo < hi) {
877
+ const mid = lo + hi >> 1;
878
+ if (tails[mid] < pos) lo = mid + 1;
879
+ else hi = mid;
880
+ }
881
+ if (lo === tails.length) tails.push(pos);
882
+ else tails[lo] = pos;
883
+ }
884
+ return tails.length;
885
+ }
886
+ function checkVnodesHaveProps(keyedVnodes) {
887
+ for (const { vnode } of keyedVnodes) {
888
+ if (typeof vnode !== "object" || vnode === null) continue;
889
+ const vnodeObj = vnode;
890
+ if (vnodeObj.props && hasNonTrivialProps(vnodeObj.props)) {
891
+ return true;
892
+ }
893
+ }
894
+ return false;
895
+ }
896
+ function checkVnodePropChanges(keyedVnodes, oldKeyMap) {
897
+ for (const { key, vnode } of keyedVnodes) {
898
+ const el = oldKeyMap?.get(key);
899
+ if (!el || typeof vnode !== "object" || vnode === null) continue;
900
+ const vnodeObj = vnode;
901
+ const props = vnodeObj.props || {};
902
+ for (const k of Object.keys(props)) {
903
+ if (isIgnoredForPropChanges(k)) continue;
904
+ if (hasPropChanged(el, k, props[k])) {
905
+ return true;
906
+ }
907
+ }
908
+ }
909
+ return false;
910
+ }
911
+ function isKeyedReorderFastPathEligible(parent, newChildren, oldKeyMap) {
912
+ const keyedVnodes = extractKeyedVnodes(newChildren);
913
+ const totalKeyed = keyedVnodes.length;
914
+ const newKeyOrder = keyedVnodes.map((kv) => kv.key);
915
+ const oldKeyOrder = oldKeyMap ? Array.from(oldKeyMap.keys()) : [];
916
+ let moveCount = 0;
917
+ for (let i = 0; i < newKeyOrder.length; i++) {
918
+ const k = newKeyOrder[i];
919
+ if (i >= oldKeyOrder.length || oldKeyOrder[i] !== k || !oldKeyMap?.has(k)) {
920
+ moveCount++;
921
+ }
922
+ }
923
+ const FAST_MOVE_THRESHOLD_ABS = 64;
924
+ const FAST_MOVE_THRESHOLD_REL = 0.1;
925
+ const cheapMoveTrigger = totalKeyed >= 128 && oldKeyOrder.length > 0 && moveCount > Math.max(
926
+ FAST_MOVE_THRESHOLD_ABS,
927
+ Math.floor(totalKeyed * FAST_MOVE_THRESHOLD_REL)
928
+ );
929
+ let lisTrigger = false;
930
+ let lisLen = 0;
931
+ if (totalKeyed >= 128) {
932
+ const parentChildren = Array.from(parent.children);
933
+ const positions = keyedVnodes.map(({ key }) => {
934
+ const el = oldKeyMap?.get(key);
935
+ return el?.parentElement === parent ? parentChildren.indexOf(el) : -1;
936
+ });
937
+ lisLen = computeLISLength(positions);
938
+ lisTrigger = lisLen < Math.floor(totalKeyed * 0.5);
939
+ }
940
+ const hasPropsPresent = checkVnodesHaveProps(keyedVnodes);
941
+ const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);
942
+ const useFastPath = (cheapMoveTrigger || lisTrigger) && !hasPropChanges && !hasPropsPresent;
943
+ return {
944
+ useFastPath,
945
+ totalKeyed,
946
+ moveCount,
947
+ lisLen,
948
+ hasPropChanges
949
+ };
950
+ }
951
+
952
+ // src/renderer/dom.ts
953
+ var IS_DOM_AVAILABLE = typeof document !== "undefined";
954
+ function addTrackedListener(el, eventName, handler) {
955
+ const wrappedHandler = createWrappedHandler(handler, true);
956
+ const options = getPassiveOptions(eventName);
957
+ if (options !== void 0) {
958
+ el.addEventListener(eventName, wrappedHandler, options);
959
+ } else {
960
+ el.addEventListener(eventName, wrappedHandler);
961
+ }
962
+ if (!elementListeners.has(el)) {
963
+ elementListeners.set(el, /* @__PURE__ */ new Map());
964
+ }
965
+ elementListeners.get(el).set(eventName, {
966
+ handler: wrappedHandler,
967
+ original: handler,
968
+ options
969
+ });
970
+ }
971
+ function applyPropsToElement(el, props, tagName) {
972
+ for (const key in props) {
973
+ const value = props[key];
974
+ if (isSkippedProp(key)) continue;
975
+ if (value === void 0 || value === null || value === false) continue;
976
+ const eventName = parseEventName(key);
977
+ if (eventName) {
978
+ addTrackedListener(el, eventName, value);
979
+ continue;
980
+ }
981
+ if (key === "class" || key === "className") {
982
+ el.className = String(value);
983
+ } else if (key === "value" || key === "checked") {
984
+ applyFormControlProp(el, key, value, tagName);
985
+ } else {
986
+ el.setAttribute(key, String(value));
987
+ }
988
+ }
989
+ }
990
+ function applyFormControlProp(el, key, value, tagName) {
991
+ const tag = tagName.toLowerCase();
992
+ if (key === "value") {
993
+ if (tag === "input" || tag === "textarea" || tag === "select") {
994
+ el.value = String(value);
995
+ el.setAttribute("value", String(value));
996
+ } else {
997
+ el.setAttribute("value", String(value));
998
+ }
999
+ } else if (key === "checked") {
1000
+ if (tag === "input") {
1001
+ el.checked = Boolean(value);
1002
+ el.setAttribute("checked", String(Boolean(value)));
1003
+ } else {
1004
+ el.setAttribute("checked", String(Boolean(value)));
1005
+ }
1006
+ }
1007
+ }
1008
+ function materializeKey(el, vnode, props) {
1009
+ const vnodeKey = vnode.key ?? props?.key;
1010
+ if (vnodeKey !== void 0) {
1011
+ el.setAttribute("data-key", String(vnodeKey));
1012
+ }
1013
+ }
1014
+ function warnMissingKeys(children) {
1015
+ if (process.env.NODE_ENV === "production") return;
1016
+ let hasElements = false;
1017
+ let hasKeys = false;
1018
+ for (const item of children) {
1019
+ if (typeof item === "object" && item !== null && "type" in item) {
1020
+ hasElements = true;
1021
+ const rawKey = item.key ?? item.props?.key;
1022
+ if (rawKey !== void 0) {
1023
+ hasKeys = true;
1024
+ break;
1025
+ }
1026
+ }
1027
+ }
1028
+ if (hasElements && !hasKeys) {
1029
+ try {
1030
+ const inst = getCurrentInstance();
1031
+ const name = inst?.fn?.name || "<anonymous>";
1032
+ logger.warn(
1033
+ `Missing keys on dynamic lists in ${name}. Each child in a list should have a unique "key" prop.`
1034
+ );
1035
+ } catch {
1036
+ logger.warn(
1037
+ 'Missing keys on dynamic lists. Each child in a list should have a unique "key" prop.'
1038
+ );
1039
+ }
1040
+ }
1041
+ }
1042
+ function createDOMNode(node) {
1043
+ if (!IS_DOM_AVAILABLE) {
1044
+ if (process.env.NODE_ENV !== "production") {
1045
+ try {
1046
+ logger.warn("[Askr] createDOMNode called in non-DOM environment");
1047
+ } catch {
1048
+ }
1049
+ }
1050
+ return null;
1051
+ }
1052
+ if (typeof node === "string") {
1053
+ return document.createTextNode(node);
1054
+ }
1055
+ if (typeof node === "number") {
1056
+ return document.createTextNode(String(node));
1057
+ }
1058
+ if (!node) {
1059
+ return null;
1060
+ }
1061
+ if (Array.isArray(node)) {
1062
+ const fragment = document.createDocumentFragment();
1063
+ for (const child of node) {
1064
+ const dom = createDOMNode(child);
1065
+ if (dom) fragment.appendChild(dom);
1066
+ }
1067
+ return fragment;
1068
+ }
1069
+ if (typeof node === "object" && node !== null && "type" in node) {
1070
+ const type = node.type;
1071
+ const props = node.props || {};
1072
+ if (typeof type === "string") {
1073
+ return createIntrinsicElement(node, type, props);
1074
+ }
1075
+ if (typeof type === "function") {
1076
+ return createComponentElement(node, type, props);
1077
+ }
1078
+ if (typeof type === "symbol" && (type === Fragment2 || String(type) === "Symbol(Fragment)")) {
1079
+ return createFragmentElement(node, props);
1080
+ }
1081
+ }
1082
+ return null;
1083
+ }
1084
+ function createIntrinsicElement(node, type, props) {
1085
+ const el = document.createElement(type);
1086
+ materializeKey(el, node, props);
1087
+ applyPropsToElement(el, props, type);
1088
+ const children = props.children || node.children;
1089
+ if (children) {
1090
+ if (Array.isArray(children)) {
1091
+ warnMissingKeys(children);
1092
+ for (const child of children) {
1093
+ const dom = createDOMNode(child);
1094
+ if (dom) el.appendChild(dom);
1095
+ }
1096
+ } else {
1097
+ const dom = createDOMNode(children);
1098
+ if (dom) el.appendChild(dom);
1099
+ }
1100
+ }
1101
+ return el;
1102
+ }
1103
+ function createComponentElement(node, type, props) {
1104
+ const frame = node[CONTEXT_FRAME_SYMBOL];
1105
+ const snapshot = frame || getCurrentContextFrame();
1106
+ const componentFn = type;
1107
+ const isAsync = componentFn.constructor.name === "AsyncFunction";
1108
+ if (isAsync) {
1109
+ throw new Error(
1110
+ "Async components are not supported. Use resource() for async work."
1111
+ );
1112
+ }
1113
+ let childInstance = node.__instance;
1114
+ if (!childInstance) {
1115
+ childInstance = createComponentInstance(
1116
+ `comp-${Math.random().toString(36).slice(2, 7)}`,
1117
+ componentFn,
1118
+ props || {},
1119
+ null
1120
+ );
1121
+ node.__instance = childInstance;
1122
+ }
1123
+ if (snapshot) {
1124
+ childInstance.ownerFrame = snapshot;
1125
+ }
1126
+ const result = withContext(
1127
+ snapshot,
1128
+ () => renderComponentInline(childInstance)
1129
+ );
1130
+ if (result instanceof Promise) {
1131
+ throw new Error(
1132
+ "Async components are not supported. Components must return synchronously."
1133
+ );
1134
+ }
1135
+ const dom = withContext(snapshot, () => createDOMNode(result));
1136
+ if (dom instanceof Element) {
1137
+ mountInstanceInline(childInstance, dom);
1138
+ return dom;
1139
+ }
1140
+ if (!dom) {
1141
+ const placeholder = document.createComment("");
1142
+ childInstance._placeholder = placeholder;
1143
+ childInstance.mounted = true;
1144
+ childInstance.notifyUpdate = childInstance._enqueueRun;
1145
+ return placeholder;
1146
+ }
1147
+ const host = document.createElement("div");
1148
+ host.appendChild(dom);
1149
+ mountInstanceInline(childInstance, host);
1150
+ return host;
1151
+ }
1152
+ function createFragmentElement(node, props) {
1153
+ const fragment = document.createDocumentFragment();
1154
+ const children = props.children || node.children;
1155
+ if (children) {
1156
+ if (Array.isArray(children)) {
1157
+ for (const child of children) {
1158
+ const dom = createDOMNode(child);
1159
+ if (dom) fragment.appendChild(dom);
1160
+ }
1161
+ } else {
1162
+ const dom = createDOMNode(children);
1163
+ if (dom) fragment.appendChild(dom);
1164
+ }
1165
+ }
1166
+ return fragment;
1167
+ }
1168
+ function updateElementFromVnode(el, vnode, updateChildren = true) {
1169
+ if (!_isDOMElement(vnode)) {
1170
+ return;
1171
+ }
1172
+ const props = vnode.props || {};
1173
+ materializeKey(el, vnode, props);
1174
+ const existingListeners = elementListeners.get(el);
1175
+ const desiredEventNames = /* @__PURE__ */ new Set();
1176
+ for (const key in props) {
1177
+ const value = props[key];
1178
+ if (isSkippedProp(key)) continue;
1179
+ const eventName = parseEventName(key);
1180
+ if (value === void 0 || value === null || value === false) {
1181
+ if (key === "class" || key === "className") {
1182
+ el.className = "";
1183
+ } else if (eventName && existingListeners?.has(eventName)) {
1184
+ const entry = existingListeners.get(eventName);
1185
+ if (entry.options !== void 0) {
1186
+ el.removeEventListener(eventName, entry.handler, entry.options);
1187
+ } else {
1188
+ el.removeEventListener(eventName, entry.handler);
1189
+ }
1190
+ existingListeners.delete(eventName);
1191
+ } else {
1192
+ el.removeAttribute(key);
1193
+ }
1194
+ continue;
1195
+ }
1196
+ if (key === "class" || key === "className") {
1197
+ el.className = String(value);
1198
+ } else if (key === "value" || key === "checked") {
1199
+ el[key] = value;
1200
+ } else if (eventName) {
1201
+ desiredEventNames.add(eventName);
1202
+ const existing = existingListeners?.get(eventName);
1203
+ if (existing && existing.original === value) {
1204
+ continue;
1205
+ }
1206
+ if (existing) {
1207
+ el.removeEventListener(eventName, existing.handler);
1208
+ }
1209
+ const wrappedHandler = createWrappedHandler(
1210
+ value,
1211
+ false
1212
+ );
1213
+ const options = getPassiveOptions(eventName);
1214
+ if (options !== void 0) {
1215
+ el.addEventListener(eventName, wrappedHandler, options);
1216
+ } else {
1217
+ el.addEventListener(eventName, wrappedHandler);
1218
+ }
1219
+ if (!elementListeners.has(el)) {
1220
+ elementListeners.set(el, /* @__PURE__ */ new Map());
1221
+ }
1222
+ elementListeners.get(el).set(eventName, {
1223
+ handler: wrappedHandler,
1224
+ original: value,
1225
+ options
1226
+ });
1227
+ } else {
1228
+ el.setAttribute(key, String(value));
1229
+ }
1230
+ }
1231
+ if (existingListeners) {
1232
+ for (const eventName of existingListeners.keys()) {
1233
+ if (!desiredEventNames.has(eventName)) {
1234
+ const entry = existingListeners.get(eventName);
1235
+ el.removeEventListener(eventName, entry.handler);
1236
+ existingListeners.delete(eventName);
1237
+ }
1238
+ }
1239
+ if (existingListeners.size === 0) elementListeners.delete(el);
1240
+ }
1241
+ if (updateChildren) {
1242
+ const children = vnode.children || props.children;
1243
+ updateElementChildren(el, children);
1244
+ }
1245
+ }
1246
+ function updateElementChildren(el, children) {
1247
+ if (!children) {
1248
+ el.textContent = "";
1249
+ return;
1250
+ }
1251
+ if (!Array.isArray(children) && (typeof children === "string" || typeof children === "number")) {
1252
+ if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {
1253
+ el.firstChild.data = String(children);
1254
+ } else {
1255
+ el.textContent = String(children);
1256
+ }
1257
+ return;
1258
+ }
1259
+ if (Array.isArray(children)) {
1260
+ updateUnkeyedChildren(el, children);
1261
+ return;
1262
+ }
1263
+ el.textContent = "";
1264
+ const dom = createDOMNode(children);
1265
+ if (dom) el.appendChild(dom);
1266
+ }
1267
+ function updateUnkeyedChildren(parent, newChildren) {
1268
+ const existing = Array.from(parent.children);
1269
+ if (newChildren.length === 1 && existing.length === 0 && parent.childNodes.length === 1) {
1270
+ const firstNewChild = newChildren[0];
1271
+ const firstExisting = parent.firstChild;
1272
+ if ((typeof firstNewChild === "string" || typeof firstNewChild === "number") && firstExisting?.nodeType === 3) {
1273
+ firstExisting.data = String(firstNewChild);
1274
+ return;
1275
+ }
1276
+ }
1277
+ if (existing.length === 0 && parent.childNodes.length > 0) {
1278
+ parent.textContent = "";
1279
+ }
1280
+ const max = Math.max(existing.length, newChildren.length);
1281
+ for (let i = 0; i < max; i++) {
1282
+ const current = existing[i];
1283
+ const next = newChildren[i];
1284
+ if (next === void 0 && current) {
1285
+ cleanupInstanceIfPresent(current);
1286
+ current.remove();
1287
+ continue;
1288
+ }
1289
+ if (!current && next !== void 0) {
1290
+ const dom = createDOMNode(next);
1291
+ if (dom) parent.appendChild(dom);
1292
+ continue;
1293
+ }
1294
+ if (!current || next === void 0) continue;
1295
+ if (typeof next === "string" || typeof next === "number") {
1296
+ current.textContent = String(next);
1297
+ } else if (_isDOMElement(next)) {
1298
+ if (typeof next.type === "string") {
1299
+ if (current.tagName.toLowerCase() === next.type.toLowerCase()) {
1300
+ updateElementFromVnode(current, next);
1301
+ } else {
1302
+ const dom = createDOMNode(next);
1303
+ if (dom) {
1304
+ if (current instanceof Element) removeAllListeners(current);
1305
+ cleanupInstanceIfPresent(current);
1306
+ parent.replaceChild(dom, current);
1307
+ }
1308
+ }
1309
+ } else {
1310
+ const dom = createDOMNode(next);
1311
+ if (dom) {
1312
+ if (current instanceof Element) removeAllListeners(current);
1313
+ cleanupInstanceIfPresent(current);
1314
+ parent.replaceChild(dom, current);
1315
+ }
1316
+ }
1317
+ } else {
1318
+ const dom = createDOMNode(next);
1319
+ if (dom) {
1320
+ if (current instanceof Element) removeAllListeners(current);
1321
+ cleanupInstanceIfPresent(current);
1322
+ parent.replaceChild(dom, current);
1323
+ }
1324
+ }
1325
+ }
1326
+ }
1327
+ function performBulkPositionalKeyedTextUpdate(parent, keyedVnodes) {
1328
+ const total = keyedVnodes.length;
1329
+ let reused = 0;
1330
+ let updatedKeys = 0;
1331
+ const t0 = now();
1332
+ for (let i = 0; i < total; i++) {
1333
+ const { key, vnode } = keyedVnodes[i];
1334
+ const ch = parent.children[i];
1335
+ if (ch && _isDOMElement(vnode) && typeof vnode.type === "string") {
1336
+ const vnodeType = vnode.type;
1337
+ if (ch.tagName.toLowerCase() === vnodeType.toLowerCase()) {
1338
+ const children = vnode.children || vnode.props?.children;
1339
+ logFastPathDebug("positional idx", i, {
1340
+ chTag: ch.tagName.toLowerCase(),
1341
+ vnodeType,
1342
+ chChildNodes: ch.childNodes.length,
1343
+ childrenType: Array.isArray(children) ? "array" : typeof children
1344
+ });
1345
+ updateTextContent(ch, children);
1346
+ setDataKey(ch, key, () => updatedKeys++);
1347
+ reused++;
1348
+ continue;
1349
+ } else {
1350
+ logFastPathDebug("positional tag mismatch", i, {
1351
+ chTag: ch.tagName.toLowerCase(),
1352
+ vnodeType
1353
+ });
1354
+ }
1355
+ } else {
1356
+ logFastPathDebug("positional missing or invalid", i, { ch: !!ch });
1357
+ }
1358
+ replaceNodeAtPosition(parent, i, vnode);
1359
+ }
1360
+ const t = now() - t0;
1361
+ updateKeyedElementsMap(parent, keyedVnodes);
1362
+ const stats = { n: total, reused, updatedKeys, t };
1363
+ recordFastPathStats(stats, "bulkKeyedPositionalHits");
1364
+ return stats;
1365
+ }
1366
+ function updateTextContent(el, children) {
1367
+ if (typeof children === "string" || typeof children === "number") {
1368
+ setTextNodeData(el, String(children));
1369
+ } else if (Array.isArray(children) && children.length === 1 && (typeof children[0] === "string" || typeof children[0] === "number")) {
1370
+ setTextNodeData(el, String(children[0]));
1371
+ } else {
1372
+ updateElementFromVnode(el, el);
1373
+ }
1374
+ }
1375
+ function setTextNodeData(el, text) {
1376
+ if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {
1377
+ el.firstChild.data = text;
1378
+ } else {
1379
+ el.textContent = text;
1380
+ }
1381
+ }
1382
+ function setDataKey(el, key, onSet) {
1383
+ try {
1384
+ el.setAttribute("data-key", String(key));
1385
+ onSet();
1386
+ } catch {
1387
+ }
1388
+ }
1389
+ function replaceNodeAtPosition(parent, index, vnode) {
1390
+ const dom = createDOMNode(vnode);
1391
+ if (dom) {
1392
+ const existing = parent.children[index];
1393
+ if (existing) {
1394
+ cleanupInstanceIfPresent(existing);
1395
+ parent.replaceChild(dom, existing);
1396
+ } else {
1397
+ parent.appendChild(dom);
1398
+ }
1399
+ }
1400
+ }
1401
+ function updateKeyedElementsMap(parent, keyedVnodes) {
1402
+ try {
1403
+ const newKeyMap = /* @__PURE__ */ new Map();
1404
+ for (let i = 0; i < keyedVnodes.length; i++) {
1405
+ const k = keyedVnodes[i].key;
1406
+ const ch = parent.children[i];
1407
+ if (ch) newKeyMap.set(k, ch);
1408
+ }
1409
+ keyedElements.set(parent, newKeyMap);
1410
+ } catch {
1411
+ }
1412
+ }
1413
+ function performBulkTextReplace(parent, newChildren) {
1414
+ const t0 = now();
1415
+ const existing = Array.from(parent.childNodes);
1416
+ const finalNodes = [];
1417
+ let reused = 0;
1418
+ let created = 0;
1419
+ for (let i = 0; i < newChildren.length; i++) {
1420
+ const result = processChildNode(newChildren[i], existing[i], finalNodes);
1421
+ if (result === "reused") reused++;
1422
+ else if (result === "created") created++;
1423
+ }
1424
+ const tBuild = now() - t0;
1425
+ cleanupRemovedNodes(parent, finalNodes);
1426
+ const tCommit = commitBulkReplace(parent, finalNodes);
1427
+ keyedElements.delete(parent);
1428
+ const stats = {
1429
+ n: newChildren.length,
1430
+ reused,
1431
+ created,
1432
+ tBuild,
1433
+ tCommit
1434
+ };
1435
+ recordBulkTextStats(stats);
1436
+ return stats;
1437
+ }
1438
+ function processChildNode(vnode, existingNode, finalNodes) {
1439
+ if (typeof vnode === "string" || typeof vnode === "number") {
1440
+ return processTextVnode(String(vnode), existingNode, finalNodes);
1441
+ }
1442
+ if (typeof vnode === "object" && vnode !== null && "type" in vnode) {
1443
+ return processElementVnode(vnode, existingNode, finalNodes);
1444
+ }
1445
+ return "skipped";
1446
+ }
1447
+ function processTextVnode(text, existingNode, finalNodes) {
1448
+ if (existingNode && existingNode.nodeType === 3) {
1449
+ existingNode.data = text;
1450
+ finalNodes.push(existingNode);
1451
+ return "reused";
1452
+ }
1453
+ finalNodes.push(document.createTextNode(text));
1454
+ return "created";
1455
+ }
1456
+ function processElementVnode(vnode, existingNode, finalNodes) {
1457
+ const vnodeObj = vnode;
1458
+ if (typeof vnodeObj.type === "string") {
1459
+ const tag = vnodeObj.type;
1460
+ if (existingNode && existingNode.nodeType === 1 && existingNode.tagName.toLowerCase() === tag.toLowerCase()) {
1461
+ updateElementFromVnode(existingNode, vnode);
1462
+ finalNodes.push(existingNode);
1463
+ return "reused";
1464
+ }
1465
+ }
1466
+ const dom = createDOMNode(vnode);
1467
+ if (dom) {
1468
+ finalNodes.push(dom);
1469
+ return "created";
1470
+ }
1471
+ return "skipped";
1472
+ }
1473
+ function cleanupRemovedNodes(parent, keepNodes) {
1474
+ try {
1475
+ const toRemove = Array.from(parent.childNodes).filter(
1476
+ (n) => !keepNodes.includes(n)
1477
+ );
1478
+ for (const n of toRemove) {
1479
+ if (n instanceof Element) removeAllListeners(n);
1480
+ cleanupInstanceIfPresent(n);
1481
+ }
1482
+ } catch {
1483
+ }
1484
+ }
1485
+ function commitBulkReplace(parent, nodes) {
1486
+ const fragStart = Date.now();
1487
+ const fragment = document.createDocumentFragment();
1488
+ for (let i = 0; i < nodes.length; i++) {
1489
+ fragment.appendChild(nodes[i]);
1490
+ }
1491
+ recordDOMReplace("bulk-text-replace");
1492
+ parent.replaceChildren(fragment);
1493
+ return Date.now() - fragStart;
1494
+ }
1495
+ function recordBulkTextStats(stats) {
1496
+ try {
1497
+ __ASKR_set("__LAST_BULK_TEXT_FASTPATH_STATS", stats);
1498
+ __ASKR_set("__LAST_FASTPATH_STATS", stats);
1499
+ __ASKR_set("__LAST_FASTPATH_COMMIT_COUNT", 1);
1500
+ __ASKR_incCounter("bulkTextFastpathHits");
1501
+ } catch {
1502
+ }
1503
+ }
1504
+ function isBulkTextFastPathEligible(parent, newChildren) {
1505
+ const threshold = Number(process.env.ASKR_BULK_TEXT_THRESHOLD) || 1024;
1506
+ const requiredFraction = 0.8;
1507
+ const total = Array.isArray(newChildren) ? newChildren.length : 0;
1508
+ if (total < threshold) {
1509
+ recordBulkDiag({
1510
+ phase: "bulk-unkeyed-eligible",
1511
+ reason: "too-small",
1512
+ total,
1513
+ threshold
1514
+ });
1515
+ return false;
1516
+ }
1517
+ const result = countSimpleChildren(newChildren);
1518
+ if (result.componentFound !== void 0) {
1519
+ recordBulkDiag({
1520
+ phase: "bulk-unkeyed-eligible",
1521
+ reason: "component-child",
1522
+ index: result.componentFound
1523
+ });
1524
+ return false;
1525
+ }
1526
+ const fraction = result.simple / total;
1527
+ const eligible = fraction >= requiredFraction && parent.childNodes.length >= total;
1528
+ recordBulkDiag({
1529
+ phase: "bulk-unkeyed-eligible",
1530
+ total,
1531
+ simple: result.simple,
1532
+ fraction,
1533
+ requiredFraction,
1534
+ eligible
1535
+ });
1536
+ return eligible;
1537
+ }
1538
+ function countSimpleChildren(children) {
1539
+ let simple = 0;
1540
+ for (let i = 0; i < children.length; i++) {
1541
+ const c = children[i];
1542
+ if (typeof c === "string" || typeof c === "number") {
1543
+ simple++;
1544
+ continue;
1545
+ }
1546
+ if (typeof c === "object" && c !== null && "type" in c) {
1547
+ const dv = c;
1548
+ if (typeof dv.type === "function") {
1549
+ return { simple, componentFound: i };
1550
+ }
1551
+ if (typeof dv.type === "string" && isSimpleElement(dv)) {
1552
+ simple++;
1553
+ }
1554
+ }
1555
+ }
1556
+ return { simple };
1557
+ }
1558
+ function isSimpleElement(dv) {
1559
+ const children = dv.children || dv.props?.children;
1560
+ if (!children) return true;
1561
+ if (typeof children === "string" || typeof children === "number") {
1562
+ return true;
1563
+ }
1564
+ if (Array.isArray(children) && children.length === 1 && (typeof children[0] === "string" || typeof children[0] === "number")) {
1565
+ return true;
1566
+ }
1567
+ return false;
1568
+ }
1569
+ function recordBulkDiag(data) {
1570
+ if (process.env.NODE_ENV !== "production" || process.env.ASKR_FASTPATH_DEBUG === "1") {
1571
+ try {
1572
+ __ASKR_set("__BULK_DIAG", data);
1573
+ } catch {
1574
+ }
1575
+ }
1576
+ }
1577
+
1578
+ // src/renderer/fastpath.ts
1579
+ function applyRendererFastPath(parent, keyedVnodes, oldKeyMap, unkeyedVnodes) {
1580
+ if (typeof document === "undefined") return null;
1581
+ const totalKeyed = keyedVnodes.length;
1582
+ if (totalKeyed === 0 && (!unkeyedVnodes || unkeyedVnodes.length === 0))
1583
+ return null;
1584
+ if (!isSchedulerExecuting()) {
1585
+ logger.warn(
1586
+ "[Askr][FASTPATH][DEV] Fast-path reconciliation invoked outside scheduler execution"
1587
+ );
1588
+ }
1589
+ let parentChildrenArr;
1590
+ let localOldKeyMap;
1591
+ if (totalKeyed <= 20) {
1592
+ try {
1593
+ const pc = parent.children;
1594
+ parentChildrenArr = new Array(pc.length);
1595
+ for (let i = 0; i < pc.length; i++)
1596
+ parentChildrenArr[i] = pc[i];
1597
+ } catch (e) {
1598
+ parentChildrenArr = void 0;
1599
+ void e;
1600
+ }
1601
+ } else {
1602
+ localOldKeyMap = /* @__PURE__ */ new Map();
1603
+ try {
1604
+ const parentChildren = Array.from(parent.children);
1605
+ for (let i = 0; i < parentChildren.length; i++) {
1606
+ const ch = parentChildren[i];
1607
+ const k = ch.getAttribute("data-key");
1608
+ if (k !== null) {
1609
+ localOldKeyMap.set(k, ch);
1610
+ const n = Number(k);
1611
+ if (!Number.isNaN(n)) localOldKeyMap.set(n, ch);
1612
+ }
1613
+ }
1614
+ } catch (e) {
1615
+ localOldKeyMap = void 0;
1616
+ void e;
1617
+ }
1618
+ }
1619
+ const finalNodes = [];
1620
+ let mapLookups = 0;
1621
+ let createdNodes = 0;
1622
+ let reusedCount = 0;
1623
+ for (let i = 0; i < keyedVnodes.length; i++) {
1624
+ const { key, vnode } = keyedVnodes[i];
1625
+ mapLookups++;
1626
+ let el;
1627
+ if (totalKeyed <= 20 && parentChildrenArr) {
1628
+ const ks = String(key);
1629
+ for (let j = 0; j < parentChildrenArr.length; j++) {
1630
+ const ch = parentChildrenArr[j];
1631
+ const k = ch.getAttribute("data-key");
1632
+ if (k !== null && (k === ks || Number(k) === key)) {
1633
+ el = ch;
1634
+ break;
1635
+ }
1636
+ }
1637
+ if (!el) el = oldKeyMap?.get(key);
1638
+ } else {
1639
+ el = localOldKeyMap?.get(key) ?? oldKeyMap?.get(key);
1640
+ }
1641
+ if (el) {
1642
+ finalNodes.push(el);
1643
+ reusedCount++;
1644
+ } else {
1645
+ const newEl = createDOMNode(vnode);
1646
+ if (newEl) {
1647
+ finalNodes.push(newEl);
1648
+ createdNodes++;
1649
+ }
1650
+ }
1651
+ }
1652
+ if (unkeyedVnodes && unkeyedVnodes.length) {
1653
+ for (const vnode of unkeyedVnodes) {
1654
+ const newEl = createDOMNode(vnode);
1655
+ if (newEl) {
1656
+ finalNodes.push(newEl);
1657
+ createdNodes++;
1658
+ }
1659
+ }
1660
+ }
1661
+ try {
1662
+ const tFragmentStart = Date.now();
1663
+ const fragment = document.createDocumentFragment();
1664
+ let fragmentAppendCount = 0;
1665
+ for (let i = 0; i < finalNodes.length; i++) {
1666
+ fragment.appendChild(finalNodes[i]);
1667
+ fragmentAppendCount++;
1668
+ }
1669
+ try {
1670
+ const existing = Array.from(parent.childNodes);
1671
+ const toRemove = existing.filter((n) => !finalNodes.includes(n));
1672
+ for (const n of toRemove) {
1673
+ if (n instanceof Element) removeAllListeners(n);
1674
+ cleanupInstanceIfPresent(n);
1675
+ }
1676
+ } catch (e) {
1677
+ void e;
1678
+ }
1679
+ try {
1680
+ __ASKR_incCounter("__DOM_REPLACE_COUNT");
1681
+ __ASKR_set("__LAST_DOM_REPLACE_STACK_FASTPATH", new Error().stack);
1682
+ } catch (e) {
1683
+ void e;
1684
+ }
1685
+ parent.replaceChildren(fragment);
1686
+ try {
1687
+ __ASKR_set("__LAST_FASTPATH_COMMIT_COUNT", 1);
1688
+ } catch (e) {
1689
+ void e;
1690
+ }
1691
+ try {
1692
+ if (isBulkCommitActive2()) markFastPathApplied(parent);
1693
+ } catch (e) {
1694
+ void e;
1695
+ }
1696
+ const newKeyMap = /* @__PURE__ */ new Map();
1697
+ for (let i = 0; i < keyedVnodes.length; i++) {
1698
+ const key = keyedVnodes[i].key;
1699
+ const node = finalNodes[i];
1700
+ if (node instanceof Element) newKeyMap.set(key, node);
1701
+ }
1702
+ try {
1703
+ const stats = {
1704
+ n: totalKeyed,
1705
+ moves: 0,
1706
+ lisLen: 0,
1707
+ t_lookup: 0,
1708
+ t_fragment: Date.now() - tFragmentStart,
1709
+ t_commit: 0,
1710
+ t_bookkeeping: 0,
1711
+ fragmentAppendCount,
1712
+ mapLookups,
1713
+ createdNodes,
1714
+ reusedCount
1715
+ };
1716
+ if (typeof globalThis !== "undefined") {
1717
+ __ASKR_set("__LAST_FASTPATH_STATS", stats);
1718
+ __ASKR_set("__LAST_FASTPATH_REUSED", reusedCount > 0);
1719
+ __ASKR_incCounter("fastpathHistoryPush");
1720
+ }
1721
+ if (process.env.ASKR_FASTPATH_DEBUG === "1" || process.env.ASKR_FASTPATH_DEBUG === "true") {
1722
+ logger.warn(
1723
+ "[Askr][FASTPATH]",
1724
+ JSON.stringify({ n: totalKeyed, createdNodes, reusedCount })
1725
+ );
1726
+ }
1727
+ } catch (e) {
1728
+ void e;
1729
+ }
1730
+ try {
1731
+ _reconcilerRecordedParents.add(parent);
1732
+ } catch (e) {
1733
+ void e;
1734
+ }
1735
+ return newKeyMap;
1736
+ } catch (e) {
1737
+ void e;
1738
+ return null;
1739
+ }
1740
+ }
1741
+
1742
+ // src/renderer/reconcile.ts
1743
+ function reconcileKeyedChildren(parent, newChildren, oldKeyMap) {
1744
+ logReconcileDebug(newChildren);
1745
+ const { keyedVnodes, unkeyedVnodes } = partitionChildren(newChildren);
1746
+ const fastPathResult = tryFastPaths(
1747
+ parent,
1748
+ newChildren,
1749
+ keyedVnodes,
1750
+ unkeyedVnodes,
1751
+ oldKeyMap
1752
+ );
1753
+ if (fastPathResult) return fastPathResult;
1754
+ return performFullReconciliation(parent, newChildren, keyedVnodes, oldKeyMap);
1755
+ }
1756
+ function logReconcileDebug(newChildren) {
1757
+ if (process.env.NODE_ENV !== "production") {
1758
+ try {
1759
+ logger.warn(
1760
+ "[Askr][RECONCILE] reconcileKeyedChildren newChildren sample",
1761
+ {
1762
+ sample: newChildren && newChildren.length && newChildren[0] || null,
1763
+ len: newChildren.length
1764
+ }
1765
+ );
1766
+ } catch {
1767
+ }
1768
+ }
1769
+ }
1770
+ function partitionChildren(newChildren) {
1771
+ const keyedVnodes = [];
1772
+ const unkeyedVnodes = [];
1773
+ for (let i = 0; i < newChildren.length; i++) {
1774
+ const child = newChildren[i];
1775
+ const key = extractKey(child);
1776
+ if (key !== void 0) {
1777
+ keyedVnodes.push({ key, vnode: child });
1778
+ } else {
1779
+ unkeyedVnodes.push(child);
1780
+ }
1781
+ }
1782
+ return { keyedVnodes, unkeyedVnodes };
1783
+ }
1784
+ function tryFastPaths(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap) {
1785
+ try {
1786
+ const rendererResult = tryRendererFastPath(
1787
+ parent,
1788
+ newChildren,
1789
+ keyedVnodes,
1790
+ unkeyedVnodes,
1791
+ oldKeyMap
1792
+ );
1793
+ if (rendererResult) return rendererResult;
1794
+ const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);
1795
+ if (positionalResult) return positionalResult;
1796
+ } catch {
1797
+ }
1798
+ return null;
1799
+ }
1800
+ function tryRendererFastPath(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap) {
1801
+ const decision = isKeyedReorderFastPathEligible(
1802
+ parent,
1803
+ newChildren,
1804
+ oldKeyMap
1805
+ );
1806
+ if (decision.useFastPath && keyedVnodes.length >= 128 || isBulkCommitActive2()) {
1807
+ try {
1808
+ const map = applyRendererFastPath(
1809
+ parent,
1810
+ keyedVnodes,
1811
+ oldKeyMap,
1812
+ unkeyedVnodes
1813
+ );
1814
+ if (map) {
1815
+ keyedElements.set(parent, map);
1816
+ return map;
1817
+ }
1818
+ } catch {
1819
+ }
1820
+ }
1821
+ return null;
1822
+ }
1823
+ function tryPositionalBulkUpdate(parent, keyedVnodes) {
1824
+ const total = keyedVnodes.length;
1825
+ if (total < 10) return null;
1826
+ const matchCount = countPositionalMatches(parent, keyedVnodes);
1827
+ logPositionalCheck(total, matchCount, parent.children.length);
1828
+ if (matchCount / total < 0.9) return null;
1829
+ if (hasPositionalPropChanges(parent, keyedVnodes)) return null;
1830
+ try {
1831
+ const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);
1832
+ recordFastPathStats(stats, "bulkKeyedPositionalHits");
1833
+ rebuildKeyedMap(parent);
1834
+ return keyedElements.get(parent);
1835
+ } catch {
1836
+ return null;
1837
+ }
1838
+ }
1839
+ function countPositionalMatches(parent, keyedVnodes) {
1840
+ let matchCount = 0;
1841
+ try {
1842
+ for (let i = 0; i < keyedVnodes.length; i++) {
1843
+ const vnode = keyedVnodes[i].vnode;
1844
+ if (!vnode || typeof vnode !== "object" || typeof vnode.type !== "string")
1845
+ continue;
1846
+ const el = parent.children[i];
1847
+ if (!el) continue;
1848
+ if (el.tagName.toLowerCase() === String(vnode.type).toLowerCase()) {
1849
+ matchCount++;
1850
+ }
1851
+ }
1852
+ } catch {
1853
+ }
1854
+ return matchCount;
1855
+ }
1856
+ function logPositionalCheck(total, matchCount, parentChildren) {
1857
+ if (process.env.NODE_ENV !== "production") {
1858
+ try {
1859
+ logger.warn("[Askr][FASTPATH] positional check", {
1860
+ total,
1861
+ matchCount,
1862
+ parentChildren
1863
+ });
1864
+ } catch {
1865
+ }
1866
+ }
1867
+ }
1868
+ function hasPositionalPropChanges(parent, keyedVnodes) {
1869
+ try {
1870
+ for (let i = 0; i < keyedVnodes.length; i++) {
1871
+ const vnode = keyedVnodes[i].vnode;
1872
+ const el = parent.children[i];
1873
+ if (!el || !vnode || typeof vnode !== "object") continue;
1874
+ if (checkPropChanges(el, vnode.props || {})) {
1875
+ return true;
1876
+ }
1877
+ }
1878
+ } catch {
1879
+ return true;
1880
+ }
1881
+ return false;
1882
+ }
1883
+ function rebuildKeyedMap(parent) {
1884
+ try {
1885
+ const map = /* @__PURE__ */ new Map();
1886
+ const children = Array.from(parent.children);
1887
+ for (let i = 0; i < children.length; i++) {
1888
+ const el = children[i];
1889
+ const k = el.getAttribute("data-key");
1890
+ if (k !== null) {
1891
+ map.set(k, el);
1892
+ const n = Number(k);
1893
+ if (!Number.isNaN(n)) map.set(n, el);
1894
+ }
1895
+ }
1896
+ keyedElements.set(parent, map);
1897
+ } catch {
1898
+ }
1899
+ }
1900
+ function performFullReconciliation(parent, newChildren, keyedVnodes, oldKeyMap) {
1901
+ const newKeyMap = /* @__PURE__ */ new Map();
1902
+ const finalNodes = [];
1903
+ const usedOldEls = /* @__PURE__ */ new WeakSet();
1904
+ const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);
1905
+ for (let i = 0; i < newChildren.length; i++) {
1906
+ const child = newChildren[i];
1907
+ const node = reconcileSingleChild(
1908
+ child,
1909
+ i,
1910
+ parent,
1911
+ resolveOldElOnce,
1912
+ usedOldEls,
1913
+ newKeyMap
1914
+ );
1915
+ if (node) finalNodes.push(node);
1916
+ }
1917
+ if (typeof document === "undefined") return newKeyMap;
1918
+ commitReconciliation(parent, finalNodes);
1919
+ keyedElements.delete(parent);
1920
+ return newKeyMap;
1921
+ }
1922
+ function createOldElResolver(parent, oldKeyMap, usedOldEls) {
1923
+ return (k) => {
1924
+ if (!oldKeyMap) return void 0;
1925
+ const direct = oldKeyMap.get(k);
1926
+ if (direct && !usedOldEls.has(direct)) {
1927
+ usedOldEls.add(direct);
1928
+ return direct;
1929
+ }
1930
+ const s = String(k);
1931
+ const byString = oldKeyMap.get(s);
1932
+ if (byString && !usedOldEls.has(byString)) {
1933
+ usedOldEls.add(byString);
1934
+ return byString;
1935
+ }
1936
+ const n = Number(s);
1937
+ if (!Number.isNaN(n)) {
1938
+ const byNum = oldKeyMap.get(n);
1939
+ if (byNum && !usedOldEls.has(byNum)) {
1940
+ usedOldEls.add(byNum);
1941
+ return byNum;
1942
+ }
1943
+ }
1944
+ return scanForElementByKey(parent, k, s, usedOldEls);
1945
+ };
1946
+ }
1947
+ function scanForElementByKey(parent, k, keyStr, usedOldEls) {
1948
+ try {
1949
+ const children = Array.from(parent.children);
1950
+ for (const ch of children) {
1951
+ if (usedOldEls.has(ch)) continue;
1952
+ const attr = ch.getAttribute("data-key");
1953
+ if (attr === keyStr) {
1954
+ usedOldEls.add(ch);
1955
+ return ch;
1956
+ }
1957
+ const numAttr = Number(attr);
1958
+ if (!Number.isNaN(numAttr) && numAttr === k) {
1959
+ usedOldEls.add(ch);
1960
+ return ch;
1961
+ }
1962
+ }
1963
+ } catch {
1964
+ }
1965
+ return void 0;
1966
+ }
1967
+ function reconcileSingleChild(child, index, parent, resolveOldElOnce, usedOldEls, newKeyMap) {
1968
+ const key = extractKey(child);
1969
+ if (key !== void 0) {
1970
+ return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);
1971
+ }
1972
+ return reconcileUnkeyedChild(child, index, parent, usedOldEls);
1973
+ }
1974
+ function reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap) {
1975
+ const el = resolveOldElOnce(key);
1976
+ if (el && el.parentElement === parent) {
1977
+ updateElementFromVnode(el, child);
1978
+ newKeyMap.set(key, el);
1979
+ return el;
1980
+ }
1981
+ const dom = createDOMNode(child);
1982
+ if (dom) {
1983
+ if (dom instanceof Element) newKeyMap.set(key, dom);
1984
+ return dom;
1985
+ }
1986
+ return null;
1987
+ }
1988
+ function reconcileUnkeyedChild(child, index, parent, usedOldEls) {
1989
+ try {
1990
+ const existing = parent.children[index];
1991
+ if (existing && (typeof child === "string" || typeof child === "number") && existing.nodeType === 1) {
1992
+ existing.textContent = String(child);
1993
+ usedOldEls.add(existing);
1994
+ return existing;
1995
+ }
1996
+ if (canReuseElement(existing, child)) {
1997
+ updateElementFromVnode(existing, child);
1998
+ usedOldEls.add(existing);
1999
+ return existing;
2000
+ }
2001
+ const avail = findAvailableUnkeyedElement(parent, usedOldEls);
2002
+ if (avail) {
2003
+ const reuseResult = tryReuseElement(avail, child, usedOldEls);
2004
+ if (reuseResult) return reuseResult;
2005
+ }
2006
+ } catch {
2007
+ }
2008
+ const dom = createDOMNode(child);
2009
+ return dom;
2010
+ }
2011
+ function canReuseElement(existing, child) {
2012
+ if (!existing) return false;
2013
+ if (typeof child !== "object" || child === null || !("type" in child))
2014
+ return false;
2015
+ const childObj = child;
2016
+ const hasNoKey = existing.getAttribute("data-key") === null || existing.getAttribute("data-key") === void 0;
2017
+ return hasNoKey && typeof childObj.type === "string" && existing.tagName.toLowerCase() === String(childObj.type).toLowerCase();
2018
+ }
2019
+ function findAvailableUnkeyedElement(parent, usedOldEls) {
2020
+ return Array.from(parent.children).find(
2021
+ (ch) => !usedOldEls.has(ch) && ch.getAttribute("data-key") === null
2022
+ );
2023
+ }
2024
+ function tryReuseElement(avail, child, usedOldEls) {
2025
+ if (typeof child === "string" || typeof child === "number") {
2026
+ avail.textContent = String(child);
2027
+ usedOldEls.add(avail);
2028
+ return avail;
2029
+ }
2030
+ if (typeof child === "object" && child !== null && "type" in child) {
2031
+ const childObj = child;
2032
+ if (typeof childObj.type === "string" && avail.tagName.toLowerCase() === String(childObj.type).toLowerCase()) {
2033
+ updateElementFromVnode(avail, child);
2034
+ usedOldEls.add(avail);
2035
+ return avail;
2036
+ }
2037
+ }
2038
+ return null;
2039
+ }
2040
+ function commitReconciliation(parent, finalNodes) {
2041
+ const fragment = document.createDocumentFragment();
2042
+ for (let i = 0; i < finalNodes.length; i++) {
2043
+ fragment.appendChild(finalNodes[i]);
2044
+ }
2045
+ try {
2046
+ const existing = Array.from(parent.childNodes);
2047
+ for (const n of existing) {
2048
+ if (n instanceof Element) removeAllListeners(n);
2049
+ cleanupInstanceIfPresent(n);
2050
+ }
2051
+ } catch {
2052
+ }
2053
+ recordDOMReplace("reconcile");
2054
+ parent.replaceChildren(fragment);
2055
+ }
2056
+
2057
+ // src/renderer/evaluate.ts
2058
+ var domRanges = /* @__PURE__ */ new WeakMap();
2059
+ function checkSimpleText(vnodeChildren) {
2060
+ if (!Array.isArray(vnodeChildren)) {
2061
+ if (typeof vnodeChildren === "string" || typeof vnodeChildren === "number") {
2062
+ return { isSimple: true, text: String(vnodeChildren) };
2063
+ }
2064
+ } else if (vnodeChildren.length === 1) {
2065
+ const child = vnodeChildren[0];
2066
+ if (typeof child === "string" || typeof child === "number") {
2067
+ return { isSimple: true, text: String(child) };
2068
+ }
2069
+ }
2070
+ return { isSimple: false };
2071
+ }
2072
+ function tryUpdateTextInPlace(element, text) {
2073
+ if (element.childNodes.length === 1 && element.firstChild?.nodeType === 3) {
2074
+ element.firstChild.data = text;
2075
+ return true;
2076
+ }
2077
+ return false;
2078
+ }
2079
+ function buildKeyMapFromDOM(parent) {
2080
+ const keyMap = /* @__PURE__ */ new Map();
2081
+ const children = Array.from(parent.children);
2082
+ for (const child of children) {
2083
+ const k = child.getAttribute("data-key");
2084
+ if (k !== null) {
2085
+ keyMap.set(k, child);
2086
+ const n = Number(k);
2087
+ if (!Number.isNaN(n)) keyMap.set(n, child);
2088
+ }
2089
+ }
2090
+ return keyMap;
2091
+ }
2092
+ function getOrBuildKeyMap(parent) {
2093
+ let keyMap = keyedElements.get(parent);
2094
+ if (!keyMap) {
2095
+ keyMap = buildKeyMapFromDOM(parent);
2096
+ if (keyMap.size > 0) {
2097
+ keyedElements.set(parent, keyMap);
2098
+ }
2099
+ }
2100
+ return keyMap.size > 0 ? keyMap : void 0;
2101
+ }
2102
+ function hasKeyedChildren(children) {
2103
+ return children.some(
2104
+ (child) => typeof child === "object" && child !== null && "key" in child
2105
+ );
2106
+ }
2107
+ function trackBulkTextStats(stats) {
2108
+ if (process.env.NODE_ENV !== "production") {
2109
+ try {
2110
+ __ASKR_set("__LAST_BULK_TEXT_FASTPATH_STATS", stats);
2111
+ __ASKR_incCounter("bulkTextHits");
2112
+ } catch {
2113
+ }
2114
+ }
2115
+ }
2116
+ function trackBulkTextMiss() {
2117
+ if (process.env.NODE_ENV !== "production") {
2118
+ try {
2119
+ __ASKR_incCounter("bulkTextMisses");
2120
+ } catch {
2121
+ }
2122
+ }
2123
+ }
2124
+ function reconcileKeyed(parent, children, oldKeyMap) {
2125
+ if (process.env.ASKR_FORCE_BULK_POSREUSE === "1") {
2126
+ const result = tryForcedBulkKeyedPath(parent, children);
2127
+ if (result) return;
2128
+ }
2129
+ const newKeyMap = reconcileKeyedChildren(parent, children, oldKeyMap);
2130
+ keyedElements.set(parent, newKeyMap);
2131
+ }
2132
+ function tryForcedBulkKeyedPath(parent, children) {
2133
+ try {
2134
+ const keyedVnodes = [];
2135
+ for (const child of children) {
2136
+ if (_isDOMElement(child) && child.key !== void 0) {
2137
+ keyedVnodes.push({
2138
+ key: child.key,
2139
+ vnode: child
2140
+ });
2141
+ }
2142
+ }
2143
+ if (keyedVnodes.length === 0 || keyedVnodes.length !== children.length) {
2144
+ return false;
2145
+ }
2146
+ if (process.env.ASKR_FASTPATH_DEBUG === "1" || process.env.ASKR_FASTPATH_DEBUG === "true") {
2147
+ logger.warn(
2148
+ "[Askr][FASTPATH] forced positional bulk keyed reuse (evaluate-level)"
2149
+ );
2150
+ }
2151
+ const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);
2152
+ if (process.env.NODE_ENV !== "production" || process.env.ASKR_FASTPATH_DEBUG === "1") {
2153
+ try {
2154
+ __ASKR_set("__LAST_FASTPATH_STATS", stats);
2155
+ __ASKR_set("__LAST_FASTPATH_COMMIT_COUNT", 1);
2156
+ __ASKR_incCounter("bulkKeyedPositionalForced");
2157
+ } catch {
2158
+ }
2159
+ }
2160
+ const newMap = buildKeyMapFromDOM(parent);
2161
+ keyedElements.set(parent, newMap);
2162
+ return true;
2163
+ } catch (err) {
2164
+ if (process.env.ASKR_FASTPATH_DEBUG === "1" || process.env.ASKR_FASTPATH_DEBUG === "true") {
2165
+ logger.warn(
2166
+ "[Askr][FASTPATH] forced bulk path failed, falling back",
2167
+ err
2168
+ );
2169
+ }
2170
+ return false;
2171
+ }
2172
+ }
2173
+ function reconcileUnkeyed(parent, children) {
2174
+ if (isBulkTextFastPathEligible(parent, children)) {
2175
+ const stats = performBulkTextReplace(parent, children);
2176
+ trackBulkTextStats(stats);
2177
+ } else {
2178
+ trackBulkTextMiss();
2179
+ updateUnkeyedChildren(parent, children);
2180
+ }
2181
+ keyedElements.delete(parent);
2182
+ }
2183
+ function updateElementChildren2(element, vnodeChildren) {
2184
+ if (!vnodeChildren) {
2185
+ element.textContent = "";
2186
+ keyedElements.delete(element);
2187
+ return;
2188
+ }
2189
+ if (!Array.isArray(vnodeChildren)) {
2190
+ element.textContent = "";
2191
+ const dom = createDOMNode(vnodeChildren);
2192
+ if (dom) element.appendChild(dom);
2193
+ keyedElements.delete(element);
2194
+ return;
2195
+ }
2196
+ if (hasKeyedChildren(vnodeChildren)) {
2197
+ const oldKeyMap = getOrBuildKeyMap(element);
2198
+ try {
2199
+ reconcileKeyed(element, vnodeChildren, oldKeyMap);
2200
+ } catch {
2201
+ const newKeyMap = reconcileKeyedChildren(
2202
+ element,
2203
+ vnodeChildren,
2204
+ oldKeyMap
2205
+ );
2206
+ keyedElements.set(element, newKeyMap);
2207
+ }
2208
+ } else {
2209
+ reconcileUnkeyed(element, vnodeChildren);
2210
+ }
2211
+ }
2212
+ function smartUpdateElement(element, vnode) {
2213
+ const vnodeChildren = vnode.children || vnode.props?.children;
2214
+ const textCheck = checkSimpleText(vnodeChildren);
2215
+ if (textCheck.isSimple && tryUpdateTextInPlace(element, textCheck.text)) {
2216
+ } else {
2217
+ updateElementChildren2(element, vnodeChildren);
2218
+ }
2219
+ updateElementFromVnode(element, vnode, false);
2220
+ }
2221
+ function processFragmentChildren(target, childArray) {
2222
+ const existingChildren = Array.from(target.children);
2223
+ for (let i = 0; i < childArray.length; i++) {
2224
+ const childVnode = childArray[i];
2225
+ const existingNode = existingChildren[i];
2226
+ if (existingNode && _isDOMElement(childVnode) && typeof childVnode.type === "string" && existingNode.tagName.toLowerCase() === childVnode.type.toLowerCase()) {
2227
+ smartUpdateElement(existingNode, childVnode);
2228
+ continue;
2229
+ }
2230
+ const newDom = createDOMNode(childVnode);
2231
+ if (newDom) {
2232
+ if (existingNode) {
2233
+ target.replaceChild(newDom, existingNode);
2234
+ } else {
2235
+ target.appendChild(newDom);
2236
+ }
2237
+ }
2238
+ }
2239
+ while (target.children.length > childArray.length) {
2240
+ target.removeChild(target.lastChild);
2241
+ }
2242
+ }
2243
+ function createWrappedEventHandler(handler) {
2244
+ return (event) => {
2245
+ globalScheduler.setInHandler(true);
2246
+ try {
2247
+ handler(event);
2248
+ } catch (error) {
2249
+ logger.error("[Askr] Event handler error:", error);
2250
+ } finally {
2251
+ globalScheduler.setInHandler(false);
2252
+ }
2253
+ };
2254
+ }
2255
+ function applyPropsToElement2(el, props) {
2256
+ for (const [key, value] of Object.entries(props)) {
2257
+ if (key === "children" || key === "key") continue;
2258
+ if (value === void 0 || value === null || value === false) continue;
2259
+ if (key.startsWith("on") && key.length > 2) {
2260
+ const eventName = key.slice(2).charAt(0).toLowerCase() + key.slice(3).toLowerCase();
2261
+ const wrappedHandler = createWrappedEventHandler(value);
2262
+ const options = eventName === "wheel" || eventName === "scroll" || eventName.startsWith("touch") ? { passive: true } : void 0;
2263
+ if (options !== void 0) {
2264
+ el.addEventListener(eventName, wrappedHandler, options);
2265
+ } else {
2266
+ el.addEventListener(eventName, wrappedHandler);
2267
+ }
2268
+ if (!elementListeners.has(el)) {
2269
+ elementListeners.set(el, /* @__PURE__ */ new Map());
2270
+ }
2271
+ elementListeners.get(el).set(eventName, {
2272
+ handler: wrappedHandler,
2273
+ original: value,
2274
+ options
2275
+ });
2276
+ continue;
2277
+ }
2278
+ if (key === "class" || key === "className") {
2279
+ el.className = String(value);
2280
+ } else if (key === "value" || key === "checked") {
2281
+ el[key] = value;
2282
+ } else {
2283
+ el.setAttribute(key, String(value));
2284
+ }
2285
+ }
2286
+ }
2287
+ function tryFirstRenderKeyedChildren(target, vnode) {
2288
+ const children = vnode.children;
2289
+ if (!Array.isArray(children) || !hasKeyedChildren(children)) {
2290
+ return false;
2291
+ }
2292
+ const el = document.createElement(vnode.type);
2293
+ target.appendChild(el);
2294
+ applyPropsToElement2(el, vnode.props || {});
2295
+ const newKeyMap = reconcileKeyedChildren(el, children, void 0);
2296
+ keyedElements.set(el, newKeyMap);
2297
+ return true;
2298
+ }
2299
+ function isFragment(vnode) {
2300
+ return _isDOMElement(vnode) && typeof vnode.type === "symbol" && (vnode.type === Fragment || String(vnode.type) === "Symbol(askr.fragment)");
2301
+ }
2302
+ function getFragmentChildren(vnode) {
2303
+ const fragmentChildren = vnode.props?.children || vnode.children || [];
2304
+ return Array.isArray(fragmentChildren) ? fragmentChildren : [fragmentChildren];
2305
+ }
2306
+ function evaluate(node, target, context) {
2307
+ if (!target) return;
2308
+ if (typeof document === "undefined") {
2309
+ if (process.env.NODE_ENV !== "production") {
2310
+ try {
2311
+ console.warn("[Askr] evaluate() called in non-DOM environment; no-op.");
2312
+ } catch (e) {
2313
+ void e;
2314
+ }
2315
+ }
2316
+ return;
2317
+ }
2318
+ if (context && domRanges.has(context)) {
2319
+ const range = domRanges.get(context);
2320
+ let current = range.start.nextSibling;
2321
+ while (current && current !== range.end) {
2322
+ const next = current.nextSibling;
2323
+ current.remove();
2324
+ current = next;
2325
+ }
2326
+ const dom = createDOMNode(node);
2327
+ if (dom) {
2328
+ target.insertBefore(dom, range.end);
2329
+ }
2330
+ } else if (context) {
2331
+ const start = document.createComment("component-start");
2332
+ const end = document.createComment("component-end");
2333
+ target.appendChild(start);
2334
+ target.appendChild(end);
2335
+ domRanges.set(context, { start, end });
2336
+ const dom = createDOMNode(node);
2337
+ if (dom) {
2338
+ target.insertBefore(dom, end);
2339
+ }
2340
+ } else {
2341
+ let vnode = node;
2342
+ if (isFragment(vnode)) {
2343
+ const childArray = getFragmentChildren(vnode);
2344
+ if (childArray.length === 1 && _isDOMElement(childArray[0]) && typeof childArray[0].type === "string") {
2345
+ vnode = childArray[0];
2346
+ } else {
2347
+ processFragmentChildren(target, childArray);
2348
+ return;
2349
+ }
2350
+ }
2351
+ const firstChild = target.children[0];
2352
+ if (firstChild && _isDOMElement(vnode) && typeof vnode.type === "string" && firstChild.tagName.toLowerCase() === vnode.type.toLowerCase()) {
2353
+ smartUpdateElement(firstChild, vnode);
2354
+ } else {
2355
+ target.textContent = "";
2356
+ if (_isDOMElement(vnode) && typeof vnode.type === "string" && tryFirstRenderKeyedChildren(target, vnode)) {
2357
+ return;
2358
+ }
2359
+ const dom = createDOMNode(vnode);
2360
+ if (dom) {
2361
+ target.appendChild(dom);
2362
+ }
2363
+ }
2364
+ }
2365
+ }
2366
+
2367
+ // src/renderer/index.ts
2368
+ if (typeof globalThis !== "undefined") {
2369
+ const _g = globalThis;
2370
+ _g.__ASKR_RENDERER = {
2371
+ evaluate,
2372
+ isKeyedReorderFastPathEligible,
2373
+ getKeyMapForElement
2374
+ };
2375
+ }
2376
+
2377
+ // src/runtime/component.ts
2378
+ function createComponentInstance(id, fn, props, target) {
2379
+ const instance = {
2380
+ id,
2381
+ fn,
2382
+ props,
2383
+ target,
2384
+ mounted: false,
2385
+ abortController: new AbortController(),
2386
+ // Create per-component
2387
+ stateValues: [],
2388
+ evaluationGeneration: 0,
2389
+ notifyUpdate: null,
2390
+ // Prebound helpers (initialized below) to avoid per-update allocations
2391
+ _pendingFlushTask: void 0,
2392
+ _pendingRunTask: void 0,
2393
+ _enqueueRun: void 0,
2394
+ stateIndexCheck: -1,
2395
+ expectedStateIndices: [],
2396
+ firstRenderComplete: false,
2397
+ mountOperations: [],
2398
+ cleanupFns: [],
2399
+ hasPendingUpdate: false,
2400
+ ownerFrame: null,
2401
+ // Will be set by renderer when vnode is marked
2402
+ ssr: false,
2403
+ cleanupStrict: false,
2404
+ isRoot: false,
2405
+ // Render-tracking (for precise state subscriptions)
2406
+ _currentRenderToken: void 0,
2407
+ lastRenderToken: 0,
2408
+ _pendingReadStates: /* @__PURE__ */ new Set(),
2409
+ _lastReadStates: /* @__PURE__ */ new Set()
2410
+ };
2411
+ instance._pendingRunTask = () => {
2412
+ instance.hasPendingUpdate = false;
2413
+ runComponent(instance);
2414
+ };
2415
+ instance._enqueueRun = () => {
2416
+ if (!instance.hasPendingUpdate) {
2417
+ instance.hasPendingUpdate = true;
2418
+ globalScheduler.enqueue(instance._pendingRunTask);
2419
+ }
2420
+ };
2421
+ instance._pendingFlushTask = () => {
2422
+ instance.hasPendingUpdate = false;
2423
+ instance._enqueueRun?.();
2424
+ };
2425
+ return instance;
2426
+ }
2427
+ var currentInstance = null;
2428
+ var stateIndex = 0;
2429
+ function getCurrentComponentInstance() {
2430
+ return currentInstance;
2431
+ }
2432
+ function setCurrentComponentInstance(instance) {
2433
+ currentInstance = instance;
2434
+ }
2435
+ function registerMountOperation(operation) {
2436
+ const instance = getCurrentComponentInstance();
2437
+ if (instance) {
2438
+ if (isBulkCommitActive2()) {
2439
+ if (process.env.NODE_ENV !== "production") {
2440
+ throw new Error(
2441
+ "registerMountOperation called during bulk commit fast-lane"
2442
+ );
2443
+ }
2444
+ return;
2445
+ }
2446
+ instance.mountOperations.push(operation);
2447
+ }
2448
+ }
2449
+ function executeMountOperations(instance) {
2450
+ if (!instance.isRoot) return;
2451
+ for (const operation of instance.mountOperations) {
2452
+ const result = operation();
2453
+ if (result instanceof Promise) {
2454
+ result.then((cleanup) => {
2455
+ if (typeof cleanup === "function") {
2456
+ instance.cleanupFns.push(cleanup);
2457
+ }
2458
+ });
2459
+ } else if (typeof result === "function") {
2460
+ instance.cleanupFns.push(result);
2461
+ }
2462
+ }
2463
+ instance.mountOperations = [];
2464
+ }
2465
+ function mountInstanceInline(instance, target) {
2466
+ instance.target = target;
2467
+ try {
2468
+ if (target instanceof Element)
2469
+ target.__ASKR_INSTANCE = instance;
2470
+ } catch (err) {
2471
+ void err;
2472
+ }
2473
+ instance.notifyUpdate = instance._enqueueRun;
2474
+ const wasFirstMount = !instance.mounted;
2475
+ instance.mounted = true;
2476
+ if (wasFirstMount && instance.mountOperations.length > 0) {
2477
+ executeMountOperations(instance);
2478
+ }
2479
+ }
2480
+ var _globalRenderCounter = 0;
2481
+ function runComponent(instance) {
2482
+ instance.notifyUpdate = instance._enqueueRun;
2483
+ instance._currentRenderToken = ++_globalRenderCounter;
2484
+ instance._pendingReadStates = /* @__PURE__ */ new Set();
2485
+ const domSnapshot = instance.target ? instance.target.innerHTML : "";
2486
+ const result = executeComponentSync(instance);
2487
+ if (result instanceof Promise) {
2488
+ throw new Error(
2489
+ "Async components are not supported. Components must be synchronous."
2490
+ );
2491
+ } else {
2492
+ const fastlaneBridge = globalThis.__ASKR_FASTLANE;
2493
+ try {
2494
+ const used = fastlaneBridge?.tryRuntimeFastLaneSync?.(instance, result);
2495
+ if (used) return;
2496
+ } catch (err) {
2497
+ if (process.env.NODE_ENV !== "production") throw err;
2498
+ }
2499
+ globalScheduler.enqueue(() => {
2500
+ if (!instance.target && instance._placeholder) {
2501
+ if (result === null || result === void 0) {
2502
+ finalizeReadSubscriptions(instance);
2503
+ return;
2504
+ }
2505
+ const placeholder = instance._placeholder;
2506
+ const parent = placeholder.parentNode;
2507
+ if (!parent) {
2508
+ logger.warn(
2509
+ "[Askr] placeholder no longer in DOM, cannot render component"
2510
+ );
2511
+ return;
2512
+ }
2513
+ const host = document.createElement("div");
2514
+ const oldInstance = currentInstance;
2515
+ currentInstance = instance;
2516
+ try {
2517
+ evaluate(result, host);
2518
+ parent.replaceChild(host, placeholder);
2519
+ instance.target = host;
2520
+ instance._placeholder = void 0;
2521
+ host.__ASKR_INSTANCE = instance;
2522
+ finalizeReadSubscriptions(instance);
2523
+ } finally {
2524
+ currentInstance = oldInstance;
2525
+ }
2526
+ return;
2527
+ }
2528
+ if (instance.target) {
2529
+ let oldChildren = [];
2530
+ try {
2531
+ const wasFirstMount = !instance.mounted;
2532
+ const oldInstance = currentInstance;
2533
+ currentInstance = instance;
2534
+ oldChildren = Array.from(instance.target.childNodes);
2535
+ try {
2536
+ evaluate(result, instance.target);
2537
+ } catch (e) {
2538
+ try {
2539
+ const newChildren = Array.from(instance.target.childNodes);
2540
+ for (const n of newChildren) {
2541
+ try {
2542
+ cleanupInstancesUnder(n);
2543
+ } catch (err) {
2544
+ logger.warn(
2545
+ "[Askr] error cleaning up failed commit children:",
2546
+ err
2547
+ );
2548
+ }
2549
+ }
2550
+ } catch (_err) {
2551
+ void _err;
2552
+ }
2553
+ try {
2554
+ __ASKR_incCounter("__DOM_REPLACE_COUNT");
2555
+ __ASKR_set(
2556
+ "__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE",
2557
+ new Error().stack
2558
+ );
2559
+ } catch (e2) {
2560
+ void e2;
2561
+ }
2562
+ instance.target.replaceChildren(...oldChildren);
2563
+ throw e;
2564
+ } finally {
2565
+ currentInstance = oldInstance;
2566
+ }
2567
+ finalizeReadSubscriptions(instance);
2568
+ instance.mounted = true;
2569
+ if (wasFirstMount && instance.mountOperations.length > 0) {
2570
+ executeMountOperations(instance);
2571
+ }
2572
+ } catch (renderError) {
2573
+ try {
2574
+ const currentChildren = Array.from(instance.target.childNodes);
2575
+ for (const n of currentChildren) {
2576
+ try {
2577
+ cleanupInstancesUnder(n);
2578
+ } catch (err) {
2579
+ logger.warn(
2580
+ "[Askr] error cleaning up partial children during rollback:",
2581
+ err
2582
+ );
2583
+ }
2584
+ }
2585
+ } catch (_err) {
2586
+ void _err;
2587
+ }
2588
+ try {
2589
+ try {
2590
+ __ASKR_incCounter("__DOM_REPLACE_COUNT");
2591
+ __ASKR_set(
2592
+ "__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK",
2593
+ new Error().stack
2594
+ );
2595
+ } catch (e) {
2596
+ void e;
2597
+ }
2598
+ instance.target.replaceChildren(...oldChildren);
2599
+ } catch {
2600
+ instance.target.innerHTML = domSnapshot;
2601
+ }
2602
+ throw renderError;
2603
+ }
2604
+ }
2605
+ });
2606
+ }
2607
+ }
2608
+ function renderComponentInline(instance) {
2609
+ const hadToken = instance._currentRenderToken !== void 0;
2610
+ const prevToken = instance._currentRenderToken;
2611
+ const prevPendingReads = instance._pendingReadStates;
2612
+ if (!hadToken) {
2613
+ instance._currentRenderToken = ++_globalRenderCounter;
2614
+ instance._pendingReadStates = /* @__PURE__ */ new Set();
2615
+ }
2616
+ try {
2617
+ const result = executeComponentSync(instance);
2618
+ if (!hadToken) {
2619
+ finalizeReadSubscriptions(instance);
2620
+ }
2621
+ return result;
2622
+ } finally {
2623
+ instance._currentRenderToken = prevToken;
2624
+ instance._pendingReadStates = prevPendingReads ?? /* @__PURE__ */ new Set();
2625
+ }
2626
+ }
2627
+ function executeComponentSync(instance) {
2628
+ instance.stateIndexCheck = -1;
2629
+ for (const state of instance.stateValues) {
2630
+ if (state) {
2631
+ state._hasBeenRead = false;
2632
+ }
2633
+ }
2634
+ instance._pendingReadStates = /* @__PURE__ */ new Set();
2635
+ currentInstance = instance;
2636
+ stateIndex = 0;
2637
+ try {
2638
+ const renderStartTime = process.env.NODE_ENV !== "production" ? Date.now() : 0;
2639
+ const context = {
2640
+ signal: instance.abortController.signal
2641
+ };
2642
+ const executionFrame = {
2643
+ parent: instance.ownerFrame,
2644
+ values: null
2645
+ };
2646
+ const result = withContext(
2647
+ executionFrame,
2648
+ () => instance.fn(instance.props, context)
2649
+ );
2650
+ const renderTime = Date.now() - renderStartTime;
2651
+ if (renderTime > 5) {
2652
+ logger.warn(
2653
+ `[askr] Slow render detected: ${renderTime}ms. Consider optimizing component performance.`
2654
+ );
2655
+ }
2656
+ if (!instance.firstRenderComplete) {
2657
+ instance.firstRenderComplete = true;
2658
+ }
2659
+ for (let i = 0; i < instance.stateValues.length; i++) {
2660
+ const state = instance.stateValues[i];
2661
+ if (state && !state._hasBeenRead) {
2662
+ try {
2663
+ const name = instance.fn?.name || "<anonymous>";
2664
+ logger.warn(
2665
+ `[askr] Unused state variable detected in ${name} at index ${i}. State should be read during render or removed.`
2666
+ );
2667
+ } catch {
2668
+ logger.warn(
2669
+ `[askr] Unused state variable detected. State should be read during render or removed.`
2670
+ );
2671
+ }
2672
+ }
2673
+ }
2674
+ return result;
2675
+ } finally {
2676
+ currentInstance = null;
2677
+ }
2678
+ }
2679
+ function executeComponent(instance) {
2680
+ instance.abortController = new AbortController();
2681
+ instance.notifyUpdate = instance._enqueueRun;
2682
+ globalScheduler.enqueue(() => runComponent(instance));
2683
+ }
2684
+ function getCurrentInstance() {
2685
+ return currentInstance;
2686
+ }
2687
+ function getSignal() {
2688
+ if (!currentInstance) {
2689
+ throw new Error(
2690
+ "getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function."
2691
+ );
2692
+ }
2693
+ return currentInstance.abortController.signal;
2694
+ }
2695
+ function finalizeReadSubscriptions(instance) {
2696
+ const newSet = instance._pendingReadStates ?? /* @__PURE__ */ new Set();
2697
+ const oldSet = instance._lastReadStates ?? /* @__PURE__ */ new Set();
2698
+ const token = instance._currentRenderToken;
2699
+ if (token === void 0) return;
2700
+ for (const s of oldSet) {
2701
+ if (!newSet.has(s)) {
2702
+ const readers = s._readers;
2703
+ if (readers) readers.delete(instance);
2704
+ }
2705
+ }
2706
+ instance.lastRenderToken = token;
2707
+ for (const s of newSet) {
2708
+ let readers = s._readers;
2709
+ if (!readers) {
2710
+ readers = /* @__PURE__ */ new Map();
2711
+ s._readers = readers;
2712
+ }
2713
+ readers.set(instance, instance.lastRenderToken ?? 0);
2714
+ }
2715
+ instance._lastReadStates = newSet;
2716
+ instance._pendingReadStates = /* @__PURE__ */ new Set();
2717
+ instance._currentRenderToken = void 0;
2718
+ }
2719
+ function getNextStateIndex() {
2720
+ return stateIndex++;
2721
+ }
2722
+ function mountComponent(instance) {
2723
+ executeComponent(instance);
2724
+ }
2725
+ function cleanupComponent(instance) {
2726
+ const cleanupErrors = [];
2727
+ for (const cleanup of instance.cleanupFns) {
2728
+ try {
2729
+ cleanup();
2730
+ } catch (err) {
2731
+ if (instance.cleanupStrict) {
2732
+ cleanupErrors.push(err);
2733
+ } else {
2734
+ if (process.env.NODE_ENV !== "production") {
2735
+ logger.warn("[Askr] cleanup function threw:", err);
2736
+ }
2737
+ }
2738
+ }
2739
+ }
2740
+ instance.cleanupFns = [];
2741
+ if (cleanupErrors.length > 0) {
2742
+ throw new AggregateError(
2743
+ cleanupErrors,
2744
+ `Cleanup failed for component ${instance.id}`
2745
+ );
2746
+ }
2747
+ if (instance._lastReadStates) {
2748
+ for (const s of instance._lastReadStates) {
2749
+ const readers = s._readers;
2750
+ if (readers) readers.delete(instance);
2751
+ }
2752
+ instance._lastReadStates = /* @__PURE__ */ new Set();
2753
+ }
2754
+ instance.abortController.abort();
2755
+ instance.notifyUpdate = null;
2756
+ instance.mounted = false;
2757
+ }
2758
+
2759
+ // src/router/route.ts
2760
+ var routes = [];
2761
+ var namespaces = /* @__PURE__ */ new Set();
2762
+ var routesByDepth = /* @__PURE__ */ new Map();
2763
+ function getDepth(path) {
2764
+ const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
2765
+ return normalized === "/" ? 0 : normalized.split("/").filter(Boolean).length;
2766
+ }
2767
+ function getSpecificity(path) {
2768
+ const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
2769
+ if (normalized === "/*") {
2770
+ return 0;
2771
+ }
2772
+ const segments = normalized.split("/").filter(Boolean);
2773
+ let score = 0;
2774
+ for (const segment of segments) {
2775
+ if (segment.startsWith("{") && segment.endsWith("}")) {
2776
+ score += 2;
2777
+ } else if (segment === "*") {
2778
+ score += 1;
2779
+ } else {
2780
+ score += 3;
2781
+ }
2782
+ }
2783
+ return score;
2784
+ }
2785
+ var serverLocation = null;
2786
+ function setServerLocation(url) {
2787
+ serverLocation = url;
2788
+ }
2789
+ function parseLocation(url) {
2790
+ try {
2791
+ const u = new URL(url, "http://localhost");
2792
+ return { pathname: u.pathname, search: u.search, hash: u.hash };
2793
+ } catch {
2794
+ return { pathname: "/", search: "", hash: "" };
2795
+ }
2796
+ }
2797
+ function deepFreeze(obj) {
2798
+ if (obj && typeof obj === "object" && !Object.isFrozen(obj)) {
2799
+ Object.freeze(obj);
2800
+ for (const key of Object.keys(obj)) {
2801
+ const value = obj[key];
2802
+ if (value && typeof value === "object") deepFreeze(value);
2803
+ }
2804
+ }
2805
+ return obj;
2806
+ }
2807
+ function makeQuery(search) {
2808
+ const usp = new URLSearchParams(search || "");
2809
+ const mapping = /* @__PURE__ */ new Map();
2810
+ for (const [k, v] of usp.entries()) {
2811
+ const existing = mapping.get(k);
2812
+ if (existing) existing.push(v);
2813
+ else mapping.set(k, [v]);
2814
+ }
2815
+ const obj = {
2816
+ get(key) {
2817
+ const arr = mapping.get(key);
2818
+ return arr ? arr[0] : null;
2819
+ },
2820
+ getAll(key) {
2821
+ const arr = mapping.get(key);
2822
+ return arr ? [...arr] : [];
2823
+ },
2824
+ has(key) {
2825
+ return mapping.has(key);
2826
+ },
2827
+ toJSON() {
2828
+ const out = {};
2829
+ for (const [k, arr] of mapping.entries()) {
2830
+ out[k] = arr.length > 1 ? [...arr] : arr[0];
2831
+ }
2832
+ return out;
2833
+ }
2834
+ };
2835
+ return deepFreeze(obj);
2836
+ }
2837
+ function computeMatches(pathname) {
2838
+ const routesList = getRoutes();
2839
+ const matches = [];
2840
+ function getSpecificity2(path) {
2841
+ const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
2842
+ if (normalized === "/*") return 0;
2843
+ const segments = normalized.split("/").filter(Boolean);
2844
+ let score = 0;
2845
+ for (const segment of segments) {
2846
+ if (segment.startsWith("{") && segment.endsWith("}")) score += 2;
2847
+ else if (segment === "*") score += 1;
2848
+ else score += 3;
2849
+ }
2850
+ return score;
2851
+ }
2852
+ for (const r of routesList) {
2853
+ const result = match(pathname, r.path);
2854
+ if (result.matched) {
2855
+ matches.push({
2856
+ pattern: r.path,
2857
+ params: result.params,
2858
+ name: r.name,
2859
+ namespace: r.namespace,
2860
+ specificity: getSpecificity2(r.path)
2861
+ });
2862
+ }
2863
+ }
2864
+ matches.sort((a, b) => b.specificity - a.specificity);
2865
+ return matches.map((m) => ({
2866
+ path: m.pattern,
2867
+ params: deepFreeze({ ...m.params }),
2868
+ name: m.name,
2869
+ namespace: m.namespace
2870
+ }));
2871
+ }
2872
+ var registrationLocked = false;
2873
+ function lockRouteRegistration() {
2874
+ registrationLocked = true;
2875
+ }
2876
+ function _lockRouteRegistrationForTests() {
2877
+ registrationLocked = true;
2878
+ }
2879
+ function _unlockRouteRegistrationForTests() {
2880
+ registrationLocked = false;
2881
+ }
2882
+ function route(path, handler, namespace) {
2883
+ if (typeof path === "undefined") {
2884
+ const instance = getCurrentComponentInstance();
2885
+ if (!instance) {
2886
+ throw new Error(
2887
+ "route() can only be called during component render execution. Call route() from inside your component function."
2888
+ );
2889
+ }
2890
+ let pathname = "/";
2891
+ let search = "";
2892
+ let hash = "";
2893
+ if (typeof window !== "undefined" && window.location) {
2894
+ pathname = window.location.pathname || "/";
2895
+ search = window.location.search || "";
2896
+ hash = window.location.hash || "";
2897
+ } else if (serverLocation) {
2898
+ const parsed = parseLocation(serverLocation);
2899
+ pathname = parsed.pathname;
2900
+ search = parsed.search;
2901
+ hash = parsed.hash;
2902
+ }
2903
+ const params = deepFreeze({
2904
+ ...instance.props || {}
2905
+ });
2906
+ const query = makeQuery(search);
2907
+ const matches = computeMatches(pathname);
2908
+ const snapshot = Object.freeze({
2909
+ path: pathname,
2910
+ params,
2911
+ query,
2912
+ hash: hash || null,
2913
+ matches: Object.freeze(matches)
2914
+ });
2915
+ return snapshot;
2916
+ }
2917
+ const currentInst = getCurrentComponentInstance();
2918
+ if (currentInst && currentInst.ssr) {
2919
+ throw new Error(
2920
+ "route() cannot be called during SSR rendering. Register routes at module load time instead."
2921
+ );
2922
+ }
2923
+ if (registrationLocked) {
2924
+ throw new Error(
2925
+ "Route registration is locked after app startup. Register routes at module load time before calling createIsland()."
2926
+ );
2927
+ }
2928
+ if (typeof handler !== "function") {
2929
+ throw new Error(
2930
+ "route(path, handler) requires a function handler that returns a VNode (e.g. () => <Page />). Passing JSX elements or VNodes directly is not supported."
2931
+ );
2932
+ }
2933
+ const routeObj = { path, handler, namespace };
2934
+ routes.push(routeObj);
2935
+ const depth = getDepth(path);
2936
+ let depthRoutes = routesByDepth.get(depth);
2937
+ if (!depthRoutes) {
2938
+ depthRoutes = [];
2939
+ routesByDepth.set(depth, depthRoutes);
2940
+ }
2941
+ depthRoutes.push(routeObj);
2942
+ if (namespace) {
2943
+ namespaces.add(namespace);
2944
+ }
2945
+ }
2946
+ function getRoutes() {
2947
+ return [...routes];
2948
+ }
2949
+ function getNamespaceRoutes(namespace) {
2950
+ return routes.filter((r) => r.namespace === namespace);
2951
+ }
2952
+ function unloadNamespace(namespace) {
2953
+ const before = routes.length;
2954
+ for (let i = routes.length - 1; i >= 0; i--) {
2955
+ if (routes[i].namespace === namespace) {
2956
+ const removed = routes[i];
2957
+ routes.splice(i, 1);
2958
+ const depth = getDepth(removed.path);
2959
+ const depthRoutes = routesByDepth.get(depth);
2960
+ if (depthRoutes) {
2961
+ const idx = depthRoutes.indexOf(removed);
2962
+ if (idx >= 0) {
2963
+ depthRoutes.splice(idx, 1);
2964
+ }
2965
+ }
2966
+ }
2967
+ }
2968
+ namespaces.delete(namespace);
2969
+ return before - routes.length;
2970
+ }
2971
+ function clearRoutes() {
2972
+ routes.length = 0;
2973
+ namespaces.clear();
2974
+ routesByDepth.clear();
2975
+ }
2976
+ function normalizeHandler(handler) {
2977
+ if (handler == null) return void 0;
2978
+ if (typeof handler === "function") {
2979
+ return (params, ctx) => {
2980
+ try {
2981
+ return handler(params, ctx);
2982
+ } catch {
2983
+ return handler(params);
2984
+ }
2985
+ };
2986
+ }
2987
+ return void 0;
2988
+ }
2989
+ function registerRoute(path, handler, ...children) {
2990
+ const isRelative = !path.startsWith("/");
2991
+ const descriptor = {
2992
+ path,
2993
+ handler,
2994
+ children: children.filter(Boolean),
2995
+ _isDescriptor: true
2996
+ };
2997
+ if (!isRelative) {
2998
+ const normalized = normalizeHandler(handler);
2999
+ if (handler != null && !normalized) {
3000
+ throw new Error(
3001
+ "registerRoute(path, handler) requires a function handler. Passing JSX elements or VNodes directly is not supported."
3002
+ );
3003
+ }
3004
+ if (normalized) route(path, normalized);
3005
+ for (const child of descriptor.children || []) {
3006
+ const base = path === "/" ? "" : path.replace(/\/$/, "");
3007
+ const childPath = `${base}/${child.path.replace(/^\//, "")}`.replace(
3008
+ /\/\//g,
3009
+ "/"
3010
+ );
3011
+ if (child.handler) {
3012
+ const childNormalized = normalizeHandler(child.handler);
3013
+ if (!childNormalized) {
3014
+ throw new Error(
3015
+ "registerRoute child handler must be a function. Passing JSX elements directly is not supported."
3016
+ );
3017
+ }
3018
+ if (childNormalized) route(childPath, childNormalized);
3019
+ }
3020
+ if (child.children && child.children.length) {
3021
+ registerRoute(
3022
+ childPath,
3023
+ null,
3024
+ ...child.children
3025
+ );
3026
+ }
3027
+ }
3028
+ return descriptor;
3029
+ }
3030
+ return descriptor;
3031
+ }
3032
+ function getLoadedNamespaces() {
3033
+ return Array.from(namespaces);
3034
+ }
3035
+ function resolveRoute(pathname) {
3036
+ const normalized = pathname.endsWith("/") && pathname !== "/" ? pathname.slice(0, -1) : pathname;
3037
+ const depth = normalized === "/" ? 0 : normalized.split("/").filter(Boolean).length;
3038
+ const candidates = [];
3039
+ const depthRoutes = routesByDepth.get(depth);
3040
+ if (depthRoutes) {
3041
+ for (const r of depthRoutes) {
3042
+ const result = match(pathname, r.path);
3043
+ if (result.matched) {
3044
+ candidates.push({
3045
+ route: r,
3046
+ specificity: getSpecificity(r.path),
3047
+ params: result.params
3048
+ });
3049
+ }
3050
+ }
3051
+ }
3052
+ for (const r of routes) {
3053
+ if (depthRoutes?.includes(r)) continue;
3054
+ const result = match(pathname, r.path);
3055
+ if (result.matched) {
3056
+ candidates.push({
3057
+ route: r,
3058
+ specificity: getSpecificity(r.path),
3059
+ params: result.params
3060
+ });
3061
+ }
3062
+ }
3063
+ candidates.sort((a, b) => b.specificity - a.specificity);
3064
+ if (candidates.length > 0) {
3065
+ const best = candidates[0];
3066
+ return { handler: best.route.handler, params: best.params };
3067
+ }
3068
+ return null;
3069
+ }
3070
+
3071
+ export {
3072
+ invariant,
3073
+ logger,
3074
+ globalScheduler,
3075
+ scheduleEventHandler,
3076
+ withAsyncResourceContext,
3077
+ defineContext,
3078
+ readContext,
3079
+ getCurrentContextFrame,
3080
+ setDevValue,
3081
+ getDevValue,
3082
+ enterBulkCommit,
3083
+ exitBulkCommit,
3084
+ isBulkCommitActive2 as isBulkCommitActive,
3085
+ markFastPathApplied,
3086
+ isFastPathApplied,
3087
+ removeAllListeners,
3088
+ getKeyMapForElement,
3089
+ populateKeyMapForElement,
3090
+ isKeyedReorderFastPathEligible,
3091
+ createComponentInstance,
3092
+ getCurrentComponentInstance,
3093
+ setCurrentComponentInstance,
3094
+ registerMountOperation,
3095
+ getCurrentInstance,
3096
+ getSignal,
3097
+ finalizeReadSubscriptions,
3098
+ getNextStateIndex,
3099
+ mountComponent,
3100
+ cleanupComponent,
3101
+ setServerLocation,
3102
+ lockRouteRegistration,
3103
+ _lockRouteRegistrationForTests,
3104
+ _unlockRouteRegistrationForTests,
3105
+ route,
3106
+ getRoutes,
3107
+ getNamespaceRoutes,
3108
+ unloadNamespace,
3109
+ clearRoutes,
3110
+ registerRoute,
3111
+ getLoadedNamespaces,
3112
+ resolveRoute,
3113
+ route_exports
3114
+ };
3115
+ //# sourceMappingURL=chunk-2ONGHQ7Z.js.map