@askrjs/askr 0.2.3 → 0.3.0

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 (117) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/access-CEA2pOry.js +1046 -0
  3. package/dist/actions/index.d.ts +16 -2
  4. package/dist/actions/index.js +5 -5
  5. package/dist/{activity-ZxJXI9hF.js → activity-oy2YFTFF.js} +22 -16
  6. package/dist/benchmark.js +8 -9
  7. package/dist/boot/index.d.ts +21 -9
  8. package/dist/boot/index.js +1 -1
  9. package/dist/{boot-D4GaLA0d.js → boot-BMBMWUGI.js} +680 -440
  10. package/dist/capabilities-Bbf0mlp9.js +42 -0
  11. package/dist/components/index.d.ts +11 -8
  12. package/dist/components/index.js +1 -1
  13. package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
  14. package/dist/control/index.d.ts +20 -2
  15. package/dist/control/index.js +1 -1
  16. package/dist/{control-57x3wa4J.js → control-BR_mrX__.js} +4 -4
  17. package/dist/core.d.ts +163 -0
  18. package/dist/csp-nonce-BfFWcd0w.js +173 -0
  19. package/dist/data/index.d.ts +74 -2
  20. package/dist/data/index.js +3 -3
  21. package/dist/{data-B7XCDeC8.js → data-2edW0jhF.js} +133 -138
  22. package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
  23. package/dist/{deferred-BELyvMsC.js → deferred-CbgNhf67.js} +5 -5
  24. package/dist/dom-renderer.d.ts +77 -0
  25. package/dist/domains/actions.d.ts +70 -0
  26. package/dist/domains/component.d.ts +119 -0
  27. package/dist/domains/context.d.ts +73 -0
  28. package/dist/domains/control.d.ts +328 -0
  29. package/dist/domains/data.d.ts +461 -0
  30. package/dist/domains/diagnostics.d.ts +21 -0
  31. package/dist/domains/lifecycle.d.ts +112 -0
  32. package/dist/domains/refs.d.ts +18 -0
  33. package/dist/domains/renderer.d.ts +127 -0
  34. package/dist/domains/routing.d.ts +501 -0
  35. package/dist/domains/scheduler.d.ts +79 -0
  36. package/dist/domains/server.d.ts +112 -0
  37. package/dist/domains/state.d.ts +129 -0
  38. package/dist/domains/telemetry.d.ts +29 -0
  39. package/dist/eager-control.d.ts +8 -0
  40. package/dist/{effect-4LwBwV58.js → effect-C3Zsc1k6.js} +14 -41
  41. package/dist/{types-DkVJhVs9.d.ts → elements.d.ts} +84 -42
  42. package/dist/{for-internal-DeoSg_AV.js → for-state-BDykeOJL.js} +623 -511
  43. package/dist/foundations/icon/index.d.ts +67 -16
  44. package/dist/foundations/icon/index.js +1 -1
  45. package/dist/foundations/index.d.ts +26 -3
  46. package/dist/foundations/index.js +1 -1
  47. package/dist/foundations/interactions/index.d.ts +73 -34
  48. package/dist/foundations/interactions/index.js +1 -1
  49. package/dist/foundations/state/index.d.ts +12 -5
  50. package/dist/foundations/state/index.js +1 -1
  51. package/dist/foundations/structures/index.d.ts +44 -3
  52. package/dist/foundations/structures/index.js +1 -1
  53. package/dist/foundations/utilities/index.d.ts +34 -3
  54. package/dist/foundations/utilities/index.js +1 -1
  55. package/dist/fx/index.d.ts +72 -25
  56. package/dist/fx/index.js +8 -8
  57. package/dist/index.d.ts +121 -4
  58. package/dist/index.js +316 -47
  59. package/dist/{component-internal-Dl02WQKS.js → instance-VAFYVJOa.js} +495 -283
  60. package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
  61. package/dist/jsx-dev-runtime.d.ts +51 -11
  62. package/dist/jsx-globals.d.ts +2 -0
  63. package/dist/jsx-runtime-CPJXAOBF.js +43 -0
  64. package/dist/jsx-runtime.d.ts +17 -3
  65. package/dist/jsx-runtime.js +2 -42
  66. package/dist/jsx.d.ts +108 -0
  67. package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
  68. package/dist/{navigate-C46GtScG.js → navigate-prC5V8XV.js} +204 -476
  69. package/dist/{navigate-wel1e6cU.d.ts → navigation.d.ts} +10 -8
  70. package/dist/{readable-CEcteIDE.js → notify-DxxuDPeY.js} +96 -34
  71. package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
  72. package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
  73. package/dist/{ssr-BaC5qHEw.js → render-resolved-BC0W7_5b.js} +165 -558
  74. package/dist/{renderer-BhXofszH.js → renderer-CT0HeY58.js} +6866 -5715
  75. package/dist/{resolution-t8J0yNaU.js → resolution-3DskUkjG.js} +189 -180
  76. package/dist/{resource-operation-B8q-QRUx.js → resource-18-sFRl9.js} +98 -58
  77. package/dist/resources/index.d.ts +64 -46
  78. package/dist/resources/index.js +215 -9
  79. package/dist/route-activity.d.ts +21 -0
  80. package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
  81. package/dist/router/index.d.ts +378 -79
  82. package/dist/router/index.js +9 -9
  83. package/dist/router-internal-7nuNEHfG.js +36 -0
  84. package/dist/scope-Cq_iYbTR.js +403 -0
  85. package/dist/{selector-C7rIpOnN.js → selector-BSPVkjKP.js} +41 -41
  86. package/dist/{shared-CGrx2AOL.js → shared-kU8yvryp.js} +3 -6
  87. package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
  88. package/dist/ssg/index.d.ts +51 -15
  89. package/dist/ssg/index.js +269 -209
  90. package/dist/ssr/index.d.ts +121 -68
  91. package/dist/ssr/index.js +2 -1
  92. package/dist/ssr-CiNm6Vzl.js +393 -0
  93. package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
  94. package/dist/{state-BzhOW2TX.js → state-BXJfudq1.js} +10 -15
  95. package/dist/{structures-BwfeO4Iz.js → structures-CjEzfj4h.js} +37 -57
  96. package/dist/{index-r5THqzPN.d.ts → structures.d.ts} +57 -36
  97. package/dist/testing/index.d.ts +125 -24
  98. package/dist/testing/index.js +26 -62
  99. package/dist/timer-C7uqnJVt.js +85 -0
  100. package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
  101. package/dist/{verify-hydration-_Q6avFp0.js → verify-hydration-ikaxotf7.js} +8 -5
  102. package/package.json +13 -15
  103. package/dist/access-Rr7CMa06.js +0 -507
  104. package/dist/activity-CAJ5eho-.d.ts +0 -14
  105. package/dist/benchmark.d.ts +0 -26
  106. package/dist/cleanup-DsrbV-rr.js +0 -535
  107. package/dist/component-cleanup-DjpwO9WX.js +0 -143
  108. package/dist/component-scope-4I3yEMkb.js +0 -195
  109. package/dist/control-DdFw-Caz.d.ts +0 -8
  110. package/dist/csp-nonce-C9OuML0U.js +0 -72
  111. package/dist/css-BuPaTOfe.js +0 -70
  112. package/dist/fastlane-Buz1Rvlr.js +0 -166
  113. package/dist/index-DSqXWc77.d.ts +0 -1402
  114. package/dist/jsx-runtime-BTzDdBJ_.d.ts +0 -2
  115. package/dist/jsx-runtime-Cdd6Gkb0.d.ts +0 -38
  116. package/dist/lifecycle-batch-Be-CLDjV.js +0 -253
  117. package/dist/lifecycle-operations-C5m03NQc.js +0 -195
@@ -1,2 +0,0 @@
1
- import "./types-DkVJhVs9.js";
2
- import "./jsx-runtime-Cdd6Gkb0.js";
@@ -1,38 +0,0 @@
1
- import { a as IntrinsicFallbackProps, o as KnownIntrinsicElementProps, r as JSXElement, s as Props } from "./types-DkVJhVs9.js";
2
- import { t as EagerControlPrimitive } from "./control-DdFw-Caz.js";
3
- //#region src/jsx/jsx-runtime.d.ts
4
- declare namespace JSX {
5
- type ElementType = string | symbol | ((props: never) => unknown);
6
- interface Element extends JSXElement {
7
- readonly __askrJsxElementBrand?: never;
8
- }
9
- interface KnownIntrinsicElements extends KnownIntrinsicElementProps {}
10
- interface IntrinsicElements extends KnownIntrinsicElements {
11
- [elem: string]: IntrinsicFallbackProps | KnownIntrinsicElementProps[keyof KnownIntrinsicElementProps];
12
- }
13
- interface ElementAttributesProperty {
14
- props: Props;
15
- }
16
- interface ElementChildrenAttribute {
17
- children: unknown;
18
- }
19
- }
20
- declare function jsxDEV(type: EagerControlPrimitive, props: Props | null, key?: string | number, isStaticChildren?: boolean): unknown;
21
- declare function jsxDEV<TTag extends keyof KnownIntrinsicElementProps>(type: TTag, props: KnownIntrinsicElementProps[TTag] | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
22
- declare function jsxDEV<TTag extends string>(type: Exclude<TTag, keyof KnownIntrinsicElementProps>, props: IntrinsicFallbackProps | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
23
- declare function jsxDEV<TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
24
- declare function jsxDEV(type: symbol, props: Props | null, key?: string | number, isStaticChildren?: boolean): JSXElement;
25
- /** JSX factory for elements with a single or no child, used by the `jsxImportSource` transform. */
26
- declare function jsx(type: EagerControlPrimitive, props: Props | null, key?: string | number): unknown;
27
- declare function jsx<TTag extends keyof KnownIntrinsicElementProps>(type: TTag, props: KnownIntrinsicElementProps[TTag] | null, key?: string | number): JSXElement;
28
- declare function jsx<TTag extends string>(type: Exclude<TTag, keyof KnownIntrinsicElementProps>, props: IntrinsicFallbackProps | null, key?: string | number): JSXElement;
29
- declare function jsx<TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number): JSXElement;
30
- declare function jsx(type: symbol, props: Props | null, key?: string | number): JSXElement;
31
- /** JSX factory for elements with multiple static children, used by the `jsxImportSource` transform. */
32
- declare function jsxs(type: EagerControlPrimitive, props: Props | null, key?: string | number): unknown;
33
- declare function jsxs<TTag extends keyof KnownIntrinsicElementProps>(type: TTag, props: KnownIntrinsicElementProps[TTag] | null, key?: string | number): JSXElement;
34
- declare function jsxs<TTag extends string>(type: Exclude<TTag, keyof KnownIntrinsicElementProps>, props: IntrinsicFallbackProps | null, key?: string | number): JSXElement;
35
- declare function jsxs<TProps extends object>(type: (props: TProps) => unknown, props: TProps | null, key?: string | number): JSXElement;
36
- declare function jsxs(type: symbol, props: Props | null, key?: string | number): JSXElement;
37
- //#endregion
38
- export { jsxs as i, jsx as n, jsxDEV as r, JSX as t };
@@ -1,253 +0,0 @@
1
- import { y as logger } from "./access-Rr7CMa06.js";
2
- import { a as finalizeReadableSubscriptionsFromSnapshot } from "./readable-CEcteIDE.js";
3
- //#region src/common/promise.ts
4
- function isPromiseLike(value) {
5
- return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
6
- }
7
- //#endregion
8
- //#region src/runtime/lifecycle-operation-settlement.ts
9
- function settleLifecycleOperationResult(instance, lifecycleGeneration, result) {
10
- if (isPromiseLike(result)) Promise.resolve(result).then((cleanup) => {
11
- if (typeof cleanup === "function") {
12
- if (instance.lifecycleGeneration === lifecycleGeneration && instance.mounted) {
13
- (instance.cleanupFns ??= []).push(cleanup);
14
- return;
15
- }
16
- try {
17
- cleanup();
18
- } catch (err) {
19
- logger.error("[Askr] async mount cleanup failed:", err);
20
- }
21
- }
22
- }, (err) => {
23
- logger.error("[Askr] async mount operation failed:", err);
24
- });
25
- else if (typeof result === "function") (instance.cleanupFns ??= []).push(result);
26
- }
27
- function executeOperations(instance, operations) {
28
- if (operations.length === 0) return [];
29
- const lifecycleGeneration = instance.lifecycleGeneration;
30
- const errors = [];
31
- for (const operation of operations) try {
32
- settleLifecycleOperationResult(instance, lifecycleGeneration, operation());
33
- } catch (error) {
34
- errors.push(error);
35
- }
36
- return errors;
37
- }
38
- function discardCommitOperations(instance) {
39
- instance.commitOperations = void 0;
40
- }
41
- function executeCommittedLifecycleOperations(instance, wasFirstMount) {
42
- const errors = [];
43
- if (wasFirstMount && (instance.mountOperations?.length ?? 0) > 0) {
44
- const operations = instance.mountOperations;
45
- instance.mountOperations = void 0;
46
- errors.push(...executeOperations(instance, operations));
47
- }
48
- if ((instance.commitOperations?.length ?? 0) > 0) {
49
- const operations = instance.commitOperations;
50
- instance.commitOperations = void 0;
51
- errors.push(...executeOperations(instance, operations));
52
- }
53
- if (errors.length > 0) throw new AggregateError(errors, `Committed lifecycle operations failed for ${instance.id}`);
54
- }
55
- //#endregion
56
- //#region src/runtime/inline-render-snapshot.ts
57
- function createInlineRenderSnapshot(instance) {
58
- return {
59
- instance,
60
- props: instance.props,
61
- ownerFrame: instance.ownerFrame,
62
- portalScope: instance.portalScope,
63
- parentInstance: instance.parentInstance,
64
- isRoot: instance.isRoot,
65
- vnodeParentGeneration: instance._vnodeParentGeneration,
66
- vnodeOwner: instance._vnodeOwner,
67
- vnodeParent: instance._vnodeParent,
68
- hasVNodeKey: "_vnodeKey" in instance,
69
- vnodeKey: instance._vnodeKey,
70
- vnodePosition: instance._vnodePosition,
71
- wrapperDepth: instance._wrapperDepth,
72
- cleanupStrict: instance.cleanupStrict
73
- };
74
- }
75
- function restoreInlineRenderSnapshot(snapshot) {
76
- snapshot.instance.props = snapshot.props;
77
- snapshot.instance.ownerFrame = snapshot.ownerFrame;
78
- snapshot.instance.portalScope = snapshot.portalScope;
79
- snapshot.instance.parentInstance = snapshot.parentInstance;
80
- snapshot.instance.isRoot = snapshot.isRoot;
81
- snapshot.instance._vnodeParentGeneration = snapshot.vnodeParentGeneration;
82
- snapshot.instance._vnodeOwner = snapshot.vnodeOwner;
83
- snapshot.instance._vnodeParent = snapshot.vnodeParent;
84
- if (snapshot.hasVNodeKey) snapshot.instance._vnodeKey = snapshot.vnodeKey;
85
- else delete snapshot.instance._vnodeKey;
86
- snapshot.instance._vnodePosition = snapshot.vnodePosition;
87
- snapshot.instance._wrapperDepth = snapshot.wrapperDepth;
88
- snapshot.instance.cleanupStrict = snapshot.cleanupStrict;
89
- }
90
- //#endregion
91
- //#region src/runtime/lifecycle-batch.ts
92
- let currentLifecycleCommitBatch = null;
93
- const pendingLifecycleCommitErrors = [];
94
- /** @internal Drain commit-time cleanup errors for transaction owners such as the router. */
95
- function drainLifecycleCommitErrors() {
96
- if (pendingLifecycleCommitErrors.length === 0) return [];
97
- return pendingLifecycleCommitErrors.splice(0);
98
- }
99
- function beginLifecycleCommitBatch() {
100
- const batch = {
101
- parent: currentLifecycleCommitBatch,
102
- entries: [],
103
- entriesByInstance: /* @__PURE__ */ new Map(),
104
- readCommits: [],
105
- readCommitsByInstance: /* @__PURE__ */ new Map(),
106
- renderSnapshots: [],
107
- renderSnapshotsByInstance: /* @__PURE__ */ new Map(),
108
- transactions: [],
109
- transactionsByKey: /* @__PURE__ */ new Map(),
110
- retainedElementSnapshots: /* @__PURE__ */ new Map(),
111
- active: true
112
- };
113
- currentLifecycleCommitBatch = batch;
114
- return batch;
115
- }
116
- function getCurrentLifecycleCommitBatch() {
117
- return currentLifecycleCommitBatch?.active ? currentLifecycleCommitBatch : null;
118
- }
119
- function enqueueLifecycleTransaction(batch, transaction) {
120
- if (batch.transactionsByKey.has(transaction.key)) return;
121
- batch.transactionsByKey.set(transaction.key, transaction);
122
- batch.transactions.push(transaction);
123
- }
124
- function registerLifecycleTransaction(key, commit, rollback, merge) {
125
- if (!currentLifecycleCommitBatch?.active) return false;
126
- enqueueLifecycleTransaction(currentLifecycleCommitBatch, {
127
- key,
128
- commit,
129
- rollback,
130
- merge
131
- });
132
- return true;
133
- }
134
- function registerLifecycleRollback(rollback) {
135
- if (!currentLifecycleCommitBatch?.active) return false;
136
- currentLifecycleCommitBatch.transactions.push(rollback);
137
- return true;
138
- }
139
- function closeLifecycleCommitBatch(batch) {
140
- if (!batch.active) return false;
141
- batch.active = false;
142
- currentLifecycleCommitBatch = batch.parent;
143
- return true;
144
- }
145
- function enqueueLifecycleCommit(batch, instance, wasFirstMount) {
146
- const existing = batch.entriesByInstance.get(instance);
147
- if (existing) {
148
- existing.wasFirstMount = existing.wasFirstMount || wasFirstMount;
149
- return;
150
- }
151
- const entry = {
152
- instance,
153
- wasFirstMount
154
- };
155
- batch.entriesByInstance.set(instance, entry);
156
- batch.entries.push(entry);
157
- }
158
- function enqueueLifecycleCommitForInstance(instance, wasFirstMount) {
159
- if (!currentLifecycleCommitBatch?.active) return false;
160
- enqueueLifecycleCommit(currentLifecycleCommitBatch, instance, wasFirstMount);
161
- return true;
162
- }
163
- function enqueueReadSubscriptionCommit(batch, instance, token, pendingReadSources, pendingReadSourceVersions, ownershipGeneration = instance._ownershipGeneration) {
164
- const existing = batch.readCommitsByInstance.get(instance);
165
- const commit = existing ?? {
166
- instance,
167
- ownershipGeneration,
168
- token,
169
- pendingReadSources,
170
- pendingReadSourceVersions
171
- };
172
- commit.ownershipGeneration = ownershipGeneration;
173
- commit.token = token;
174
- commit.pendingReadSources = pendingReadSources ? new Set(pendingReadSources) : void 0;
175
- commit.pendingReadSourceVersions = pendingReadSourceVersions ? new Map(pendingReadSourceVersions) : void 0;
176
- if (!existing) {
177
- batch.readCommitsByInstance.set(instance, commit);
178
- batch.readCommits.push(commit);
179
- }
180
- }
181
- function enqueueInlineRenderSnapshot(batch, snapshot) {
182
- if (batch.renderSnapshotsByInstance.has(snapshot.instance)) return;
183
- batch.renderSnapshotsByInstance.set(snapshot.instance, snapshot);
184
- batch.renderSnapshots.push(snapshot);
185
- }
186
- function captureInlineRenderSnapshot(instance) {
187
- if (!currentLifecycleCommitBatch?.active) return;
188
- enqueueInlineRenderSnapshot(currentLifecycleCommitBatch, createInlineRenderSnapshot(instance));
189
- }
190
- function finalizeInlineReadSubscriptions(instance, token, pendingReadSources, pendingReadSourceVersions) {
191
- if ((!pendingReadSources || pendingReadSources.size === 0) && (!instance._lastReadSources || instance._lastReadSources.size === 0)) return;
192
- if (currentLifecycleCommitBatch?.active) {
193
- enqueueReadSubscriptionCommit(currentLifecycleCommitBatch, instance, token, pendingReadSources, pendingReadSourceVersions);
194
- return;
195
- }
196
- finalizeReadableSubscriptionsFromSnapshot(instance, token, pendingReadSources, pendingReadSourceVersions, instance._ownershipGeneration);
197
- }
198
- function flushLifecycleCommitBatch(batch) {
199
- if (!closeLifecycleCommitBatch(batch)) return;
200
- if (batch.parent?.active) {
201
- for (const [element, snapshot] of batch.retainedElementSnapshots) if (!batch.parent.retainedElementSnapshots.has(element)) batch.parent.retainedElementSnapshots.set(element, snapshot);
202
- for (const entry of batch.transactions) if (typeof entry === "function") batch.parent.transactions.push(entry);
203
- else {
204
- const existing = batch.parent.transactionsByKey.get(entry.key);
205
- if (existing && entry.merge) entry.merge(existing);
206
- else enqueueLifecycleTransaction(batch.parent, entry);
207
- }
208
- for (const snapshot of batch.renderSnapshots) enqueueInlineRenderSnapshot(batch.parent, snapshot);
209
- for (const commit of batch.readCommits) enqueueReadSubscriptionCommit(batch.parent, commit.instance, commit.token, commit.pendingReadSources, commit.pendingReadSourceVersions, commit.ownershipGeneration);
210
- for (const entry of batch.entries) enqueueLifecycleCommit(batch.parent, entry.instance, entry.wasFirstMount);
211
- return;
212
- }
213
- const commitErrors = [];
214
- for (const commit of batch.readCommits) try {
215
- finalizeReadableSubscriptionsFromSnapshot(commit.instance, commit.token, commit.pendingReadSources, commit.pendingReadSourceVersions, commit.ownershipGeneration);
216
- } catch (error) {
217
- commitErrors.push(error);
218
- }
219
- for (const transaction of batch.transactions) {
220
- if (typeof transaction === "function") continue;
221
- try {
222
- transaction.commit();
223
- } catch (error) {
224
- commitErrors.push(error);
225
- }
226
- }
227
- for (const entry of batch.entries) try {
228
- executeCommittedLifecycleOperations(entry.instance, entry.wasFirstMount);
229
- } catch (error) {
230
- commitErrors.push(error);
231
- }
232
- if (commitErrors.length > 0) {
233
- pendingLifecycleCommitErrors.push(...commitErrors);
234
- logger.error("[Askr] committed lifecycle work failed:", new AggregateError(commitErrors, "Committed lifecycle work failed"));
235
- }
236
- }
237
- function discardLifecycleCommitBatch(batch) {
238
- if (!closeLifecycleCommitBatch(batch)) return;
239
- for (let index = batch.transactions.length - 1; index >= 0; index -= 1) try {
240
- const transaction = batch.transactions[index];
241
- if (typeof transaction === "function") transaction();
242
- else transaction.rollback();
243
- } catch (error) {
244
- logger.error("[Askr] transaction rollback failed:", error);
245
- }
246
- for (let index = batch.renderSnapshots.length - 1; index >= 0; index -= 1) restoreInlineRenderSnapshot(batch.renderSnapshots[index]);
247
- for (const entry of batch.entries) {
248
- if (entry.wasFirstMount) entry.instance.mountOperations = void 0;
249
- discardCommitOperations(entry.instance);
250
- }
251
- }
252
- //#endregion
253
- export { enqueueLifecycleCommitForInstance as a, getCurrentLifecycleCommitBatch as c, discardCommitOperations as d, executeCommittedLifecycleOperations as f, drainLifecycleCommitErrors as i, registerLifecycleRollback as l, captureInlineRenderSnapshot as n, finalizeInlineReadSubscriptions as o, isPromiseLike as p, discardLifecycleCommitBatch as r, flushLifecycleCommitBatch as s, beginLifecycleCommitBatch as t, registerLifecycleTransaction as u };
@@ -1,195 +0,0 @@
1
- import { f as getCurrentComponentInstance, i as claimHookIndex } from "./component-scope-4I3yEMkb.js";
2
- import { a as registerCommitOperation } from "./component-internal-Dl02WQKS.js";
3
- import { t as isRouteActivityActive } from "./route-activity-CNJfpwx-.js";
4
- //#region src/runtime/lifecycle-operations.ts
5
- function normalizePredicates(predicates) {
6
- if (!predicates) return [];
7
- return typeof predicates === "function" ? [predicates] : predicates;
8
- }
9
- function allPredicatesPass(predicates) {
10
- for (const predicate of predicates) if (!predicate()) return false;
11
- return true;
12
- }
13
- function getLifecycleSlot(instance, index, kind, create) {
14
- const lifecycleSlots = instance.lifecycleSlots ??= [];
15
- const existing = lifecycleSlots[index];
16
- if (existing) {
17
- const slot = existing;
18
- if (slot.kind !== kind) throw new Error(`${kind}() lifecycle order violation: slot ${index} already belongs to ${slot.kind}(). Keep lifecycle primitives in a stable top-level order.`);
19
- return existing;
20
- }
21
- const slot = create();
22
- lifecycleSlots[index] = slot;
23
- return slot;
24
- }
25
- /** {@link ActivityPredicate} that is true while the current route matches `pathOrPaths`. */
26
- function routeActive(pathOrPaths) {
27
- return () => isRouteActivityActive(pathOrPaths);
28
- }
29
- /** {@link ActivityPredicate} that is true while the document is visible. */
30
- function documentVisible() {
31
- return () => typeof document === "undefined" || document.visibilityState !== "hidden";
32
- }
33
- /** {@link ActivityPredicate} that is true while the window has focus. */
34
- function windowFocused() {
35
- return () => typeof document === "undefined" || typeof document.hasFocus !== "function" || document.hasFocus();
36
- }
37
- function normalizeListenerOptions(options) {
38
- if (options === void 0 || typeof options === "boolean") return options;
39
- return {
40
- ...options.capture !== void 0 ? { capture: options.capture } : {},
41
- ...options.once !== void 0 ? { once: options.once } : {},
42
- ...options.passive !== void 0 ? { passive: options.passive } : {},
43
- ...options.signal !== void 0 ? { signal: options.signal } : {}
44
- };
45
- }
46
- function listenerOptionsEqual(a, b) {
47
- if (a === b) return true;
48
- if (typeof a === "boolean" || typeof b === "boolean") return a === b;
49
- if (!a || !b) return a === b;
50
- return a.capture === b.capture && a.once === b.once && a.passive === b.passive && a.signal === b.signal;
51
- }
52
- function detachListenerSlot(slot) {
53
- if (!slot.attached || !slot.target) return;
54
- slot.target.removeEventListener(slot.event, slot.listener, slot.options);
55
- slot.attached = false;
56
- }
57
- function commitListenerSlot(instance, slot) {
58
- slot.handler = slot.pendingHandler;
59
- const resolvedTarget = typeof slot.pendingTarget === "function" ? typeof window === "undefined" ? null : slot.pendingTarget() ?? null : slot.pendingTarget;
60
- if (!slot.attached || slot.target !== resolvedTarget || slot.event !== slot.pendingEvent || !listenerOptionsEqual(slot.options, slot.pendingOptions)) {
61
- detachListenerSlot(slot);
62
- slot.target = resolvedTarget;
63
- slot.event = slot.pendingEvent;
64
- slot.options = slot.pendingOptions;
65
- if (slot.target) {
66
- slot.target.addEventListener(slot.event, slot.listener, slot.options);
67
- slot.attached = true;
68
- }
69
- }
70
- if (!slot.cleanupRegistered) {
71
- slot.cleanupRegistered = true;
72
- (instance.cleanupFns ??= []).push(() => {
73
- detachListenerSlot(slot);
74
- slot.cleanupRegistered = false;
75
- });
76
- }
77
- }
78
- /** Attach an owned event listener to `target` for the current component's lifetime. */
79
- function on(target, event, handler, options) {
80
- const instance = getCurrentComponentInstance();
81
- if (!instance) return;
82
- const index = claimHookIndex(instance, "on");
83
- const normalizedOptions = normalizeListenerOptions(options);
84
- const slot = getLifecycleSlot(instance, index, "listener", () => {
85
- const createdSlot = {
86
- kind: "listener",
87
- target: null,
88
- event,
89
- handler,
90
- listener: ((evt) => {
91
- createdSlot.handler.call(createdSlot.target, evt);
92
- }),
93
- options: void 0,
94
- pendingTarget: target,
95
- pendingEvent: event,
96
- pendingHandler: handler,
97
- pendingOptions: normalizedOptions,
98
- attached: false,
99
- cleanupRegistered: false
100
- };
101
- return createdSlot;
102
- });
103
- slot.pendingTarget = target;
104
- slot.pendingEvent = event;
105
- slot.pendingHandler = handler;
106
- slot.pendingOptions = normalizedOptions;
107
- registerCommitOperation(() => {
108
- commitListenerSlot(instance, slot);
109
- });
110
- }
111
- function stopTimerSlot(slot) {
112
- if (slot.id === null) return;
113
- clearInterval(slot.id);
114
- slot.id = null;
115
- }
116
- function startTimerSlot(slot) {
117
- slot.id = setInterval(() => {
118
- if (allPredicatesPass(slot.predicates)) slot.callback();
119
- }, slot.intervalMs ?? slot.pendingIntervalMs);
120
- }
121
- function commitTimerSlot(instance, slot) {
122
- const intervalChanged = slot.intervalMs !== slot.pendingIntervalMs;
123
- slot.callback = slot.pendingCallback;
124
- slot.predicates = slot.pendingPredicates;
125
- if (slot.id === null || intervalChanged) {
126
- stopTimerSlot(slot);
127
- slot.intervalMs = slot.pendingIntervalMs;
128
- startTimerSlot(slot);
129
- }
130
- if (!slot.cleanupRegistered) {
131
- slot.cleanupRegistered = true;
132
- (instance.cleanupFns ??= []).push(() => {
133
- stopTimerSlot(slot);
134
- slot.cleanupRegistered = false;
135
- });
136
- }
137
- }
138
- /** Run `fn` on an owned interval for the current component's lifetime, optionally gated by `options.when`. */
139
- function timer(intervalMs, fn, options) {
140
- const instance = getCurrentComponentInstance();
141
- if (!instance) return;
142
- const index = claimHookIndex(instance, "timer");
143
- const predicates = normalizePredicates(options?.when);
144
- const slot = getLifecycleSlot(instance, index, "timer", () => ({
145
- kind: "timer",
146
- id: null,
147
- intervalMs: null,
148
- pendingIntervalMs: intervalMs,
149
- callback: fn,
150
- predicates,
151
- pendingCallback: fn,
152
- pendingPredicates: predicates,
153
- cleanupRegistered: false
154
- }));
155
- slot.pendingIntervalMs = intervalMs;
156
- slot.pendingCallback = fn;
157
- slot.pendingPredicates = predicates;
158
- registerCommitOperation(() => {
159
- commitTimerSlot(instance, slot);
160
- });
161
- }
162
- /** Runs an owned task after commit. */
163
- function task(fn) {
164
- const instance = getCurrentComponentInstance();
165
- if (!instance) return;
166
- const slot = getLifecycleSlot(instance, claimHookIndex(instance, "task"), "task", () => ({
167
- kind: "task",
168
- started: false,
169
- task: fn
170
- }));
171
- if (!slot.started) {
172
- slot.task = fn;
173
- registerCommitOperation(async () => {
174
- if (slot.started) return;
175
- slot.started = true;
176
- return await slot.task();
177
- });
178
- }
179
- }
180
- /**
181
- * Capture the result of a synchronous expression at call time and return a
182
- * thunk that returns the captured value later. This is a low-level helper for
183
- * cases where async continuations need to observe a snapshot of values at the
184
- * moment scheduling occurred.
185
- *
186
- * Usage (public API):
187
- * const snapshot = capture(() => someState());
188
- * Promise.resolve().then(() => { use(snapshot()); });
189
- */
190
- function capture(fn) {
191
- const value = fn();
192
- return () => value;
193
- }
194
- //#endregion
195
- export { task as a, routeActive as i, documentVisible as n, timer as o, on as r, windowFocused as s, capture as t };