@askrjs/askr 0.3.0 → 0.4.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 (123) hide show
  1. package/CHANGELOG.md +874 -0
  2. package/README.md +61 -29
  3. package/capabilities.json +19 -9
  4. package/dist/actions/index.js +56 -12
  5. package/dist/benchmark.js +10 -15
  6. package/dist/boot/index.d.ts +3 -2
  7. package/dist/boot/index.js +1 -1
  8. package/dist/boot-DaoTYoCw.js +3989 -0
  9. package/dist/browser-activity-CB8e-V4f.js +220 -0
  10. package/dist/components/index.d.ts +8 -1
  11. package/dist/components/index.js +1 -43
  12. package/dist/{aria-hKjThHcp.js → compose-ref-DWzdbxsD.js} +41 -4
  13. package/dist/control/index.d.ts +2 -0
  14. package/dist/control/index.js +1 -1
  15. package/dist/control-nfpT2fbK.js +209 -0
  16. package/dist/core.d.ts +5 -9
  17. package/dist/csp-nonce-DwGw1A6Q.js +35 -0
  18. package/dist/data/index.js +3 -3
  19. package/dist/{data-2edW0jhF.js → data-BCwClJiF.js} +283 -94
  20. package/dist/data-runtime-C1bFAlba.js +242 -0
  21. package/dist/{deferred-CbgNhf67.js → deferred-bEEHHvic.js} +42 -20
  22. package/dist/domains/actions.d.ts +8 -3
  23. package/dist/domains/component.d.ts +1 -107
  24. package/dist/domains/context.d.ts +0 -15
  25. package/dist/domains/control.d.ts +36 -249
  26. package/dist/domains/data.d.ts +31 -13
  27. package/dist/domains/diagnostics.d.ts +1 -2
  28. package/dist/domains/lifecycle.d.ts +2 -5
  29. package/dist/domains/refs.d.ts +0 -2
  30. package/dist/domains/routing.d.ts +43 -8
  31. package/dist/domains/scheduler.d.ts +1 -76
  32. package/dist/domains/server.d.ts +5 -2
  33. package/dist/domains/state.d.ts +2 -5
  34. package/dist/domains/telemetry.d.ts +0 -2
  35. package/dist/elements.d.ts +214 -51
  36. package/dist/error-boundary-Bpwofwps.js +293 -0
  37. package/dist/foundations/icon/index.d.ts +0 -58
  38. package/dist/foundations/icon/index.js +2 -2
  39. package/dist/foundations/index.js +2 -1
  40. package/dist/foundations/interactions/index.js +1 -1
  41. package/dist/foundations/state/index.d.ts +3 -3
  42. package/dist/foundations/state/index.js +5 -3
  43. package/dist/foundations/structures/index.js +2 -1
  44. package/dist/foundations/utilities/index.d.ts +2 -0
  45. package/dist/foundations/utilities/index.js +1 -2
  46. package/dist/fx/index.d.ts +31 -58
  47. package/dist/fx/index.js +313 -195
  48. package/dist/hooks-BimKStr4.js +202 -0
  49. package/dist/index.d.ts +11 -74
  50. package/dist/index.js +8 -447
  51. package/dist/instance-BAnfmXOR.js +988 -0
  52. package/dist/{interactions-CTeACdT_.js → interactions-D2BoREb-.js} +3 -2
  53. package/dist/jsx-dev-runtime.d.ts +41 -18
  54. package/dist/jsx-dev-runtime.js +1 -6
  55. package/dist/{jsx-runtime-CPJXAOBF.js → jsx-runtime-C4idqHY0.js} +18 -7
  56. package/dist/jsx-runtime.js +1 -1
  57. package/dist/jsx.d.ts +61 -37
  58. package/dist/{manifest-D1P3UNWV.js → manifest-CW9gyNBY.js} +3 -3
  59. package/dist/{navigate-prC5V8XV.js → navigate-CP_0Zy5U.js} +454 -87
  60. package/dist/navigation.d.ts +12 -3
  61. package/dist/peer-types.d.ts +8 -0
  62. package/dist/portal-DuOKfnLa.js +349 -0
  63. package/dist/promise-Dz8iIHAm.js +16 -0
  64. package/dist/query-registry-WMCN0BJL.js +320 -0
  65. package/dist/readable-DFWOsTac.js +21 -0
  66. package/dist/{render-context-B7ohlh6t.js → render-context-DGHnEveC.js} +27 -11
  67. package/dist/render-sync-IC5lMFpq.js +1240 -0
  68. package/dist/resolution-Cx82-xjW.js +1244 -0
  69. package/dist/resource-CLjB7RBQ.js +377 -0
  70. package/dist/resources/index.d.ts +21 -11
  71. package/dist/resources/index.js +45 -244
  72. package/dist/router/index.d.ts +14 -5
  73. package/dist/router/index.js +22 -53
  74. package/dist/scope-CwpVSHVf.js +55 -0
  75. package/dist/{shared-kU8yvryp.js → shared-O2ZnmYAf.js} +1 -7
  76. package/dist/{snapshot-source-An4iKajG.js → snapshot-Cjx4N988.js} +6 -1
  77. package/dist/ssg/index.d.ts +1 -2
  78. package/dist/ssg/index.js +5 -13
  79. package/dist/ssr/index.d.ts +26 -28
  80. package/dist/ssr/index.js +4 -4
  81. package/dist/{ssr-CiNm6Vzl.js → ssr-BJ8ug7zH.js} +133 -122
  82. package/dist/ssr-DoV-vJ-5.js +229 -0
  83. package/dist/state-DWO1KzkX.js +232 -0
  84. package/dist/structures-D4dDMqHX.js +231 -0
  85. package/dist/testing/index.d.ts +8 -4
  86. package/dist/testing/index.js +29 -34
  87. package/dist/url-CnbfpX0K.js +185 -0
  88. package/dist/utilities.d.ts +48 -2
  89. package/dist/verify-hydration-DpVaDnqz.js +152 -0
  90. package/package.json +19 -9
  91. package/dist/access-CEA2pOry.js +0 -1046
  92. package/dist/activity-oy2YFTFF.js +0 -201
  93. package/dist/boot-BMBMWUGI.js +0 -1084
  94. package/dist/capabilities-Bbf0mlp9.js +0 -42
  95. package/dist/compose-ref-v0qGlHoN.js +0 -26
  96. package/dist/control-BR_mrX__.js +0 -173
  97. package/dist/control-C-ApnFs1.js +0 -20
  98. package/dist/csp-nonce-BfFWcd0w.js +0 -173
  99. package/dist/data-runtime-CxoY98lX.js +0 -149
  100. package/dist/default-portal-runtime-DvMvWJVp.js +0 -20
  101. package/dist/dom-renderer.d.ts +0 -77
  102. package/dist/domains/renderer.d.ts +0 -127
  103. package/dist/eager-control.d.ts +0 -8
  104. package/dist/effect-C3Zsc1k6.js +0 -292
  105. package/dist/for-state-BDykeOJL.js +0 -1753
  106. package/dist/instance-VAFYVJOa.js +0 -1027
  107. package/dist/notify-DxxuDPeY.js +0 -266
  108. package/dist/portal-w3oQ6oQU.js +0 -29
  109. package/dist/query-registry-LrYpQsDJ.js +0 -83
  110. package/dist/render-resolved-BC0W7_5b.js +0 -1123
  111. package/dist/renderer-CT0HeY58.js +0 -8623
  112. package/dist/resolution-3DskUkjG.js +0 -577
  113. package/dist/resource-18-sFRl9.js +0 -344
  114. package/dist/route-matching-CUzZ31gT.js +0 -551
  115. package/dist/router-internal-7nuNEHfG.js +0 -36
  116. package/dist/scope-Cq_iYbTR.js +0 -403
  117. package/dist/selector-BSPVkjKP.js +0 -311
  118. package/dist/ssr-EPjwJH5R.js +0 -29
  119. package/dist/state-BXJfudq1.js +0 -91
  120. package/dist/structures-CjEzfj4h.js +0 -654
  121. package/dist/timer-C7uqnJVt.js +0 -85
  122. package/dist/verify-hydration-ikaxotf7.js +0 -27
  123. package/dist/vnode-D24p6IW2.js +0 -7
@@ -33,57 +33,6 @@ type IconProps = Omit<
33
33
  children?: unknown;
34
34
  ref?: Ref<SVGSVGElement>;
35
35
  };
36
- /** Check whether `value` is one of the named icon size tokens ('sm'|'md'|'lg'|'xl'). */
37
- declare function isIconSizeToken(value: unknown): value is IconSizeToken;
38
- /** Normalize a numeric icon size to a `px` string; strings pass through unchanged. */
39
- declare function normalizeIconSizeValue(size: number | string): string;
40
- /** Resolve a size (token or literal) to a CSS `var(--ak-icon-size-*, ...)` expression or literal value. */
41
- declare function resolveIconSizeVariable(size: number | string): string;
42
- /** Resolve a stroke width to a CSS `var(--ak-icon-stroke-width-*, ...)` expression, scoped to `sizeToken` when given. */
43
- declare function resolveIconStrokeWidthVariable(
44
- strokeWidth: number,
45
- sizeToken: IconSizeToken | undefined
46
- ): string;
47
- /** Serialize an inline style object (or pass through a string) to a CSS declaration string. */
48
- declare function serializeIconStyle(
49
- style: string | IconStyleObject | undefined
50
- ): string;
51
- /** Join non-empty CSS declaration fragments with `;`, dropping any that are blank. */
52
- declare function joinIconStyle(
53
- ...styles: Array<string | undefined>
54
- ): string | undefined;
55
- /** Compute the shared SVG attributes and inline style implementing the icon size/stroke/color contract. */
56
- declare function getIconContractProps({
57
- size,
58
- strokeWidth,
59
- color,
60
- title,
61
- style,
62
- iconName,
63
- }: Pick<
64
- IconProps,
65
- 'color' | 'iconName' | 'size' | 'strokeWidth' | 'style' | 'title'
66
- >): {
67
- sizeToken: IconSizeToken | undefined;
68
- decorative: string | undefined;
69
- iconStyle: string | undefined;
70
- attrs: {
71
- xmlns: string;
72
- width: string;
73
- height: string;
74
- fill: string;
75
- stroke: string;
76
- 'stroke-width': string;
77
- role: string;
78
- 'aria-hidden': string | undefined;
79
- style: string | undefined;
80
- 'data-slot': string;
81
- 'data-icon': string | undefined;
82
- 'data-size': IconSizeToken | undefined;
83
- 'data-decorative': string | undefined;
84
- 'data-color': string | undefined;
85
- };
86
- };
87
36
  /** Base `<svg>` wrapper implementing the icon contract; generated icon components render into it. */
88
37
  declare function IconBase({
89
38
  size,
@@ -103,11 +52,4 @@ export {
103
52
  type IconProps,
104
53
  type IconSizeToken,
105
54
  type IconStyleObject,
106
- getIconContractProps,
107
- isIconSizeToken,
108
- joinIconStyle,
109
- normalizeIconSizeValue,
110
- resolveIconSizeVariable,
111
- resolveIconStrokeWidthVariable,
112
- serializeIconStyle,
113
55
  };
@@ -1,4 +1,4 @@
1
- import { r as jsxs, t as jsx } from "../../jsx-runtime-CPJXAOBF.js";
1
+ import { i as jsxs, n as jsx } from "../../jsx-runtime-C4idqHY0.js";
2
2
  //#region src/foundations/icon/icon.tsx
3
3
  const ICON_SIZE_TOKENS = [
4
4
  "sm",
@@ -92,4 +92,4 @@ function IconBase({ size = 20, strokeWidth = 2, color = "currentColor", title, c
92
92
  return jsxs("svg", svgProps);
93
93
  }
94
94
  //#endregion
95
- export { IconBase, getIconContractProps, isIconSizeToken, joinIconStyle, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle };
95
+ export { IconBase };
@@ -1,2 +1,3 @@
1
- import { a as definePortal, c as layout, i as Portal, o as Presence, r as DefaultPortal, s as Slot } from "../structures-CjEzfj4h.js";
1
+ import { a as layout, i as Slot, r as Presence } from "../structures-D4dDMqHX.js";
2
+ import { n as Portal, r as definePortal, t as DefaultPortal } from "../portal-DuOKfnLa.js";
2
3
  export { DefaultPortal, Portal, Presence, Slot, definePortal, layout };
@@ -1,2 +1,2 @@
1
- import { a as focusable, i as hoverable, n as mergeInteractionProps, o as dismissable, r as rovingFocus, s as pressable, t as applyInteractionPolicy } from "../../interactions-CTeACdT_.js";
1
+ import { a as focusable, i as hoverable, n as mergeInteractionProps, o as dismissable, r as rovingFocus, s as pressable, t as applyInteractionPolicy } from "../../interactions-D2BoREb-.js";
2
2
  export { applyInteractionPolicy, dismissable, focusable, hoverable, mergeInteractionProps, pressable, rovingFocus };
@@ -1,4 +1,4 @@
1
- import { State } from '../../core.js';
1
+ import { StateTuple } from '../../core.js';
2
2
  /** Whether `value` represents controlled mode (not `undefined`). */
3
3
  declare function isControlled<T>(value: T | undefined): value is T;
4
4
  /** Resolve the effective value and controlled-ness for a controllable prop. */
@@ -22,8 +22,8 @@ declare function makeControllable<T>(options: {
22
22
  set: (next: T) => void;
23
23
  isControlled: boolean;
24
24
  };
25
- /** A {@link State} accessor that also reports whether it is controlled. */
26
- type ControllableState<T> = State<T> & {
25
+ /** A {@link StateTuple} accessor that also reports whether it is controlled. */
26
+ type ControllableState<T> = StateTuple<T> & {
27
27
  isControlled: boolean;
28
28
  };
29
29
  /**
@@ -1,4 +1,5 @@
1
- import { t as state } from "../../state-BXJfudq1.js";
1
+ import { t as markReadable } from "../../readable-DFWOsTac.js";
2
+ import { a as state, r as makeDestructurable } from "../../state-DWO1KzkX.js";
2
3
  //#region src/foundations/state/controllable.ts
3
4
  /**
4
5
  * controllable
@@ -76,11 +77,12 @@ function controllableState(options) {
76
77
  options.onChange?.(next);
77
78
  return;
78
79
  }
79
- internal.set(nextOrUpdater);
80
+ internal.set((() => next));
80
81
  options.onChange?.(next);
81
82
  };
82
83
  read.isControlled = isControlled;
83
- return read;
84
+ markReadable(read);
85
+ return makeDestructurable(read);
84
86
  }
85
87
  //#endregion
86
88
  export { controllableState, isControlled, makeControllable, resolveControllable };
@@ -1,2 +1,3 @@
1
- import { a as definePortal, c as layout, i as Portal, l as cloneElement, n as createCollection, o as Presence, r as DefaultPortal, s as Slot, t as createLayer, u as isElement } from "../../structures-CjEzfj4h.js";
1
+ import { a as layout, i as Slot, n as createCollection, o as cloneElement, r as Presence, s as isElement, t as createLayer } from "../../structures-D4dDMqHX.js";
2
+ import { n as Portal, r as definePortal, t as DefaultPortal } from "../../portal-DuOKfnLa.js";
2
3
  export { DefaultPortal, Portal, Presence, Slot, cloneElement, createCollection, createLayer, definePortal, isElement, layout };
@@ -8,6 +8,7 @@ import {
8
8
  DefaultPreventable,
9
9
  formatId,
10
10
  mergeProps,
11
+ MergedProps,
11
12
  PropagationStoppable,
12
13
  ariaDisabled,
13
14
  ComposeHandlersOptions,
@@ -20,6 +21,7 @@ export {
20
21
  type FocusLikeEvent,
21
22
  type FormatIdOptions,
22
23
  type KeyboardLikeEvent,
24
+ type MergedProps,
23
25
  type PointerLikeEvent,
24
26
  type PropagationStoppable,
25
27
  type Ref,
@@ -1,4 +1,3 @@
1
- import { n as setRef, t as composeRefs } from "../../compose-ref-v0qGlHoN.js";
2
- import { a as composeHandlers, i as mergeProps, n as ariaExpanded, r as ariaSelected, t as ariaDisabled } from "../../aria-hKjThHcp.js";
1
+ import { a as ariaSelected, i as ariaExpanded, n as setRef, o as mergeProps, r as ariaDisabled, s as composeHandlers, t as composeRefs } from "../../compose-ref-DWzdbxsD.js";
3
2
  import { t as formatId } from "../../utilities-C_CGX4Dz.js";
4
3
  export { ariaDisabled, ariaExpanded, ariaSelected, composeHandlers, composeRefs, formatId, mergeProps, setRef };
@@ -1,13 +1,14 @@
1
1
  import { scheduleEventHandler } from '../core.js';
2
2
  /**
3
- * Timing utilities — pure helpers for common async patterns
4
- * No framework coupling. No lifecycle awareness.
3
+ * Timing and event-scheduling helpers.
4
+ *
5
+ * The timing helpers (`throttle`, `once`, `raf`, `idle`,
6
+ * `timeout`, `retry`) are plain functions with no runtime dependency. The
7
+ * event and `schedule*` helpers use the Askr scheduler and lifecycle ownership.
8
+ * `debounceEvent`, `throttleEvent`, and `rafEvent` reject invocation during
9
+ * render and cancel pending work on owner cleanup. `scheduleEventHandler`
10
+ * runs its handler in the captured owner's scope.
5
11
  */
6
- /** Options for {@link debounce}. */
7
- interface DebounceOptions {
8
- leading?: boolean;
9
- trailing?: boolean;
10
- }
11
12
  /** Options for {@link throttle}. */
12
13
  interface ThrottleOptions {
13
14
  leading?: boolean;
@@ -24,30 +25,6 @@ type Scheduled<T extends AnyFn> = (
24
25
  this: ThisParameterType<T>,
25
26
  ...args: Parameters<T>
26
27
  ) => void;
27
- /**
28
- * Debounce — delay execution, coalesce rapid calls
29
- *
30
- * Useful for: text input, resize, autosave
31
- *
32
- * @param fn Function to debounce
33
- * @param ms Delay in milliseconds
34
- * @param options trailing (default true), leading
35
- * @returns Debounced function with cancel() method
36
- *
37
- * @example
38
- * ```ts
39
- * const save = debounce((text) => api.save(text), 500);
40
- * input.addEventListener('input', (e) => save(e.target.value));
41
- * save.cancel(); // stop any pending execution
42
- * ```
43
- */
44
- declare function debounce<T extends AnyFn>(
45
- fn: T,
46
- ms: number,
47
- options?: DebounceOptions
48
- ): Scheduled<T> & {
49
- cancel(): void;
50
- };
51
28
  /**
52
29
  * Throttle — rate-limit execution, keep first/last
53
30
  *
@@ -89,20 +66,6 @@ declare function throttle<T extends AnyFn>(
89
66
  * ```
90
67
  */
91
68
  declare function once<T extends AnyFn>(fn: T): T;
92
- /**
93
- * Defer — schedule on microtask queue
94
- *
95
- * Useful for: run-after-current-stack logic
96
- * More reliable than setTimeout(..., 0)
97
- *
98
- * @param fn Function to defer
99
- *
100
- * @example
101
- * ```ts
102
- * defer(() => update()); // runs after current stack, before next macrotask
103
- * ```
104
- */
105
- declare function defer(fn: () => void): void;
106
69
  /**
107
70
  * RAF — coalesce multiple updates into single frame
108
71
  *
@@ -118,7 +81,7 @@ declare function defer(fn: () => void): void;
118
81
  * update(); // same frame, no duplicate
119
82
  * ```
120
83
  */
121
- declare function raf<T extends AnyFn>(fn: T): Scheduled<T>;
84
+ declare function raf<T extends AnyFn>(fn: T): Scheduled<T> & { cancel(): void };
122
85
  /**
123
86
  * Idle — schedule low-priority work
124
87
  *
@@ -203,34 +166,44 @@ declare function throttleEvent(
203
166
  declare function rafEvent(handler: EventListener): EventListener & {
204
167
  cancel(): void;
205
168
  };
206
- /** Schedule `fn` after `ms`, auto-cancelling on component cleanup; returns a cancel function. */
169
+ /**
170
+ * Schedule `fn` after `ms`; returns a cancel function. Called from a mounted
171
+ * component's task, watch callback, or event handler, it is also cancelled
172
+ * when that component is cleaned up.
173
+ */
207
174
  declare function scheduleTimeout(ms: number, fn: () => void): CancelFn;
208
- /** Schedule `fn` during browser idle time, auto-cancelling on component cleanup. */
175
+ /**
176
+ * Schedule `fn` during browser idle time; returns a cancel function. Called
177
+ * from a mounted component's task, watch callback, or event handler, it is
178
+ * also cancelled when that component is cleaned up.
179
+ */
209
180
  declare function scheduleIdle(
210
181
  fn: () => void,
211
182
  options?: {
212
183
  timeout?: number;
213
184
  }
214
185
  ): CancelFn;
215
- interface RetryOptions$1 {
216
- maxAttempts?: number;
217
- delayMs?: number;
218
- backoff?: (attemptIndex: number) => number;
219
- }
220
- /** Run `fn`, retrying with backoff on failure, auto-cancelling on component cleanup. */
186
+ /**
187
+ * Run `fn`, retrying with backoff on failure. Called from a mounted
188
+ * component's task, watch callback, or event handler, pending attempts are
189
+ * also cancelled when that component is cleaned up.
190
+ */
191
+ type RetryOutcome<T> =
192
+ | { status: 'success'; value: T }
193
+ | { status: 'error'; error: unknown }
194
+ | { status: 'cancelled' };
221
195
  declare function scheduleRetry<T>(
222
196
  fn: () => Promise<T>,
223
- options?: RetryOptions$1
197
+ options?: RetryOptions
224
198
  ): {
225
199
  cancel(): void;
200
+ result: Promise<RetryOutcome<T>>;
226
201
  };
227
202
  export {
228
- type DebounceOptions,
229
203
  type RetryOptions,
204
+ type RetryOutcome,
230
205
  type ThrottleOptions,
231
- debounce,
232
206
  debounceEvent,
233
- defer,
234
207
  idle,
235
208
  once,
236
209
  raf,