@askrjs/askr 0.0.21 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +160 -46
- package/dist/_virtual/___vite-browser-external.js +1 -0
- package/dist/_virtual/__vite-browser-external.js +1 -0
- package/dist/_virtual/_commonjsHelpers.js +1 -0
- package/dist/_virtual/main.js +1 -0
- package/dist/_virtual/preload-helper.js +1 -0
- package/dist/{benchmark.d.ts → bench/benchmark-entry.d.ts} +3 -3
- package/dist/bench/benchmark-entry.d.ts.map +1 -0
- package/dist/benchmark.js +1 -1
- package/dist/boot/index.d.ts +70 -0
- package/dist/boot/index.d.ts.map +1 -0
- package/dist/boot/index.js +2 -0
- package/dist/common/component.d.ts +16 -0
- package/dist/common/component.d.ts.map +1 -0
- package/dist/common/errors.d.ts +53 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/index.d.ts +14 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/jsx.d.ts +17 -0
- package/dist/common/jsx.d.ts.map +1 -0
- package/dist/common/jsx.js +1 -0
- package/dist/{jsx-CPjsGyEg.d.ts → common/props.d.ts} +6 -18
- package/dist/common/props.d.ts.map +1 -0
- package/dist/{router-DaGtH1Sq.d.ts → common/router.d.ts} +10 -7
- package/dist/common/router.d.ts.map +1 -0
- package/dist/common/ssr-errors.d.ts +8 -0
- package/dist/common/ssr-errors.d.ts.map +1 -0
- package/dist/common/ssr-errors.js +1 -0
- package/dist/common/ssr.d.ts +17 -0
- package/dist/common/ssr.d.ts.map +1 -0
- package/dist/common/vnode.d.ts +17 -0
- package/dist/common/vnode.d.ts.map +1 -0
- package/dist/common/vnode.js +1 -0
- package/dist/components/link.d.ts +56 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +1 -0
- package/dist/dev/invariant.d.ts +83 -0
- package/dist/dev/invariant.d.ts.map +1 -0
- package/dist/dev/invariant.js +2 -0
- package/dist/dev/logger.d.ts +13 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +1 -0
- package/dist/dev/vite-plugin-askr.d.ts +18 -0
- package/dist/dev/vite-plugin-askr.d.ts.map +1 -0
- package/dist/dev/warnings.d.ts +5 -0
- package/dist/dev/warnings.d.ts.map +1 -0
- package/dist/for/for.d.ts +16 -0
- package/dist/for/for.d.ts.map +1 -0
- package/dist/for/for.js +1 -0
- package/dist/for/index.d.ts +2 -63
- package/dist/for/index.d.ts.map +1 -0
- package/dist/for/index.js +1 -1
- package/dist/foundations/core.d.ts +23 -0
- package/dist/foundations/core.d.ts.map +1 -0
- package/dist/foundations/core.js +1 -0
- package/dist/foundations/index.d.ts +3 -669
- package/dist/foundations/index.d.ts.map +1 -0
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/dismissable.d.ts +58 -0
- package/dist/foundations/interactions/dismissable.d.ts.map +1 -0
- package/dist/foundations/interactions/dismissable.js +1 -0
- package/dist/foundations/interactions/focusable.d.ts +16 -0
- package/dist/foundations/interactions/focusable.d.ts.map +1 -0
- package/dist/foundations/interactions/focusable.js +1 -0
- package/dist/foundations/interactions/hoverable.d.ts +19 -0
- package/dist/foundations/interactions/hoverable.d.ts.map +1 -0
- package/dist/foundations/interactions/hoverable.js +1 -0
- package/dist/foundations/interactions/index.d.ts +5 -0
- package/dist/foundations/interactions/index.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.d.ts +96 -0
- package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.js +1 -0
- package/dist/foundations/interactions/pressable.d.ts +54 -0
- package/dist/foundations/interactions/pressable.d.ts.map +1 -0
- package/dist/foundations/interactions/pressable.js +1 -0
- package/dist/foundations/interactions/roving-focus.d.ts +117 -0
- package/dist/foundations/interactions/roving-focus.d.ts.map +1 -0
- package/dist/foundations/interactions/roving-focus.js +1 -0
- package/dist/foundations/state/controllable.d.ts +53 -0
- package/dist/foundations/state/controllable.d.ts.map +1 -0
- package/dist/foundations/state/controllable.js +1 -0
- package/dist/foundations/state/index.d.ts +2 -0
- package/dist/foundations/state/index.d.ts.map +1 -0
- package/dist/foundations/structures/collection.d.ts +67 -0
- package/dist/foundations/structures/collection.d.ts.map +1 -0
- package/dist/foundations/structures/collection.js +1 -0
- package/dist/foundations/structures/index.d.ts +5 -0
- package/dist/foundations/structures/index.d.ts.map +1 -0
- package/dist/foundations/structures/layer.d.ts +102 -0
- package/dist/foundations/structures/layer.d.ts.map +1 -0
- package/dist/foundations/structures/layer.js +1 -0
- package/dist/{layout-BINPv-nz.d.ts → foundations/structures/layout.d.ts} +3 -4
- package/dist/foundations/structures/layout.d.ts.map +1 -0
- package/dist/foundations/structures/layout.js +1 -0
- package/dist/foundations/structures/portal.d.ts +33 -0
- package/dist/foundations/structures/portal.d.ts.map +1 -0
- package/dist/foundations/structures/portal.js +1 -0
- package/dist/foundations/structures/presence.d.ts +30 -0
- package/dist/foundations/structures/presence.d.ts.map +1 -0
- package/dist/foundations/structures/presence.js +1 -0
- package/dist/foundations/structures/slot.d.ts +31 -0
- package/dist/foundations/structures/slot.d.ts.map +1 -0
- package/dist/foundations/structures/slot.js +1 -0
- package/dist/foundations/structures.d.ts +14 -0
- package/dist/foundations/structures.d.ts.map +1 -0
- package/dist/foundations/structures.js +1 -0
- package/dist/foundations/utilities/aria.d.ts +13 -0
- package/dist/foundations/utilities/aria.d.ts.map +1 -0
- package/dist/foundations/utilities/aria.js +1 -0
- package/dist/foundations/utilities/compose-handlers.d.ts +34 -0
- package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-handlers.js +1 -0
- package/dist/foundations/utilities/compose-ref.d.ts +24 -0
- package/dist/foundations/utilities/compose-ref.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-ref.js +1 -0
- package/dist/foundations/utilities/event-types.d.ts +17 -0
- package/dist/foundations/utilities/event-types.d.ts.map +1 -0
- package/dist/foundations/utilities/index.d.ts +7 -0
- package/dist/foundations/utilities/index.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.d.ts +2 -0
- package/dist/foundations/utilities/merge-props.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.js +1 -0
- package/dist/foundations/utilities/use-id.d.ts +29 -0
- package/dist/foundations/utilities/use-id.d.ts.map +1 -0
- package/dist/foundations/utilities/use-id.js +1 -0
- package/dist/fx/fx.d.ts +30 -0
- package/dist/fx/fx.d.ts.map +1 -0
- package/dist/fx/fx.js +1 -0
- package/dist/fx/index.d.ts +5 -184
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/index.js +1 -1
- package/dist/fx/noop.d.ts +12 -0
- package/dist/fx/noop.d.ts.map +1 -0
- package/dist/fx/noop.js +1 -0
- package/dist/fx/timing.d.ts +155 -0
- package/dist/fx/timing.d.ts.map +1 -0
- package/dist/fx/timing.js +1 -0
- package/dist/index.d.ts +18 -37
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/jsx/index.d.ts +4 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +10 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/{types-BTT0Fc9S.d.ts → jsx/types.d.ts} +6 -3
- package/dist/jsx/types.d.ts.map +1 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/utils.d.ts +4 -0
- package/dist/jsx/utils.d.ts.map +1 -0
- package/dist/jsx/utils.js +1 -0
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/node_modules/esbuild/lib/main.js +65 -0
- package/dist/renderer/cleanup.d.ts +25 -0
- package/dist/renderer/cleanup.d.ts.map +1 -0
- package/dist/renderer/cleanup.js +1 -0
- package/dist/renderer/dom.d.ts +44 -0
- package/dist/renderer/dom.d.ts.map +1 -0
- package/dist/renderer/dom.js +1 -0
- package/dist/renderer/evaluate.d.ts +4 -0
- package/dist/renderer/evaluate.d.ts.map +1 -0
- package/dist/renderer/evaluate.js +1 -0
- package/dist/renderer/fastpath.d.ts +7 -0
- package/dist/renderer/fastpath.d.ts.map +1 -0
- package/dist/renderer/fastpath.js +1 -0
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +1 -0
- package/dist/renderer/keyed.d.ts +23 -0
- package/dist/renderer/keyed.d.ts.map +1 -0
- package/dist/renderer/keyed.js +1 -0
- package/dist/renderer/reconcile.d.ts +88 -0
- package/dist/renderer/reconcile.d.ts.map +1 -0
- package/dist/renderer/reconcile.js +1 -0
- package/dist/renderer/types.d.ts +3 -0
- package/dist/renderer/types.d.ts.map +1 -0
- package/dist/renderer/types.js +1 -0
- package/dist/renderer/utils.d.ts +63 -0
- package/dist/renderer/utils.d.ts.map +1 -0
- package/dist/renderer/utils.js +1 -0
- package/dist/resources/index.d.ts +7 -22
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +1 -1
- package/dist/router/index.d.ts +8 -87
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +1 -1
- package/dist/router/match.d.ts +22 -0
- package/dist/router/match.d.ts.map +1 -0
- package/dist/router/match.js +1 -0
- package/dist/router/navigate.d.ts +20 -0
- package/dist/router/navigate.d.ts.map +1 -0
- package/dist/router/navigate.js +1 -0
- package/dist/router/route.d.ts +52 -0
- package/dist/router/route.d.ts.map +1 -0
- package/dist/router/route.js +1 -0
- package/dist/runtime/component.d.ts +123 -0
- package/dist/runtime/component.d.ts.map +1 -0
- package/dist/runtime/component.js +1 -0
- package/dist/runtime/context.d.ts +80 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +1 -0
- package/dist/runtime/derive.d.ts +7 -0
- package/dist/runtime/derive.d.ts.map +1 -0
- package/dist/runtime/derive.js +1 -0
- package/dist/runtime/dev-namespace.d.ts +31 -0
- package/dist/runtime/dev-namespace.d.ts.map +1 -0
- package/dist/runtime/dev-namespace.js +1 -0
- package/dist/runtime/events.d.ts +52 -0
- package/dist/runtime/events.d.ts.map +1 -0
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/execution-model.d.ts +4 -0
- package/dist/runtime/execution-model.d.ts.map +1 -0
- package/dist/runtime/execution-model.js +1 -0
- package/dist/runtime/fastlane.d.ts +27 -0
- package/dist/runtime/fastlane.d.ts.map +1 -0
- package/dist/runtime/fastlane.js +1 -0
- package/dist/runtime/for.d.ts +52 -0
- package/dist/runtime/for.d.ts.map +1 -0
- package/dist/runtime/for.js +1 -0
- package/dist/runtime/hydration.d.ts +25 -0
- package/dist/runtime/hydration.d.ts.map +1 -0
- package/dist/runtime/operations.d.ts +39 -0
- package/dist/runtime/operations.d.ts.map +1 -0
- package/dist/runtime/operations.js +1 -0
- package/dist/runtime/resource-cell.d.ts +35 -0
- package/dist/runtime/resource-cell.d.ts.map +1 -0
- package/dist/runtime/resource-cell.js +1 -0
- package/dist/runtime/scheduler.d.ts +48 -0
- package/dist/runtime/scheduler.d.ts.map +1 -0
- package/dist/runtime/scheduler.js +1 -0
- package/dist/runtime/snapshot.d.ts +25 -0
- package/dist/runtime/snapshot.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.d.ts +10 -0
- package/dist/runtime/ssr-bridge.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.js +1 -0
- package/dist/runtime/state.d.ts +56 -0
- package/dist/runtime/state.d.ts.map +1 -0
- package/dist/runtime/state.js +1 -0
- package/dist/ssr/attrs.d.ts +26 -0
- package/dist/ssr/attrs.d.ts.map +1 -0
- package/dist/ssr/attrs.js +1 -0
- package/dist/ssr/context.d.ts +47 -0
- package/dist/ssr/context.d.ts.map +1 -0
- package/dist/ssr/context.js +1 -0
- package/dist/ssr/create-ssr.d.ts +19 -0
- package/dist/ssr/create-ssr.d.ts.map +1 -0
- package/dist/ssr/errors.d.ts +6 -0
- package/dist/ssr/errors.d.ts.map +1 -0
- package/dist/ssr/errors.js +1 -0
- package/dist/ssr/escape.d.ts +38 -0
- package/dist/ssr/escape.d.ts.map +1 -0
- package/dist/ssr/escape.js +1 -0
- package/dist/ssr/index.d.ts +18 -94
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +1 -1
- package/dist/ssr/render-keys.d.ts +39 -0
- package/dist/ssr/render-keys.d.ts.map +1 -0
- package/dist/ssr/render-keys.js +1 -0
- package/dist/ssr/sink.d.ts +23 -0
- package/dist/ssr/sink.d.ts.map +1 -0
- package/dist/ssr/sink.js +1 -0
- package/dist/ssr/stream-render.d.ts +7 -0
- package/dist/ssr/stream-render.d.ts.map +1 -0
- package/dist/ssr/stream-render.js +1 -0
- package/dist/ssr/types.d.ts +21 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite/index.js +3 -1
- package/package.json +11 -10
- package/dist/chunk-37RC6ZT3.js +0 -1
- package/dist/chunk-3L6PFAJ3.js +0 -1
- package/dist/chunk-47D5SNYH.js +0 -1
- package/dist/chunk-4RTKQ7SC.js +0 -1
- package/dist/chunk-5PLQPS3O.js +0 -1
- package/dist/chunk-62D2TNHX.js +0 -1
- package/dist/chunk-BP2CKUO6.js +0 -1
- package/dist/chunk-D2JSJKCW.js +0 -1
- package/dist/chunk-EQ5S5GU4.js +0 -1
- package/dist/chunk-HGMOQ3I7.js +0 -1
- package/dist/chunk-HZKAD5DE.js +0 -1
- package/dist/chunk-ILZCMHZM.js +0 -2
- package/dist/chunk-NL44ANML.js +0 -2
- package/dist/chunk-YRY4OLQF.js +0 -1
- package/dist/component-AJMg1Gmv.d.ts +0 -177
- package/dist/jsx-dev-runtime.d.ts +0 -7
- package/dist/jsx-runtime.d.ts +0 -14
- package/dist/logger-NGZDJLVS.js +0 -1
- package/dist/main-EPE35NMW.js +0 -65
- package/dist/navigate-4VAVLF3A.js +0 -1
- package/dist/route-IVG3V65Y.js +0 -1
- package/dist/vite/index.d.ts +0 -17
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createLayer
|
|
3
|
+
*
|
|
4
|
+
* Manages stacking order and coordination for overlays (modals, popovers, etc).
|
|
5
|
+
*
|
|
6
|
+
* INVARIANTS:
|
|
7
|
+
* 1. Layers are ordered by registration time (FIFO)
|
|
8
|
+
* 2. Only the top layer handles Escape key
|
|
9
|
+
* 3. Only the top layer handles outside pointer events
|
|
10
|
+
* 4. Nested layers are supported
|
|
11
|
+
* 5. Does not implement portals (orthogonal concern)
|
|
12
|
+
* 6. No automatic DOM insertion (caller controls mounting)
|
|
13
|
+
*
|
|
14
|
+
* DESIGN:
|
|
15
|
+
* - Returns a layer manager with register/unregister API
|
|
16
|
+
* - Each layer has a unique ID and can query if it's the top layer
|
|
17
|
+
* - Escape and outside pointer coordination via callbacks
|
|
18
|
+
* - No z-index management (CSS concern)
|
|
19
|
+
*
|
|
20
|
+
* USAGE:
|
|
21
|
+
* const manager = createLayer();
|
|
22
|
+
*
|
|
23
|
+
* const layer = manager.register({
|
|
24
|
+
* onEscape: () => { ... },
|
|
25
|
+
* onOutsidePointer: () => { ... }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* layer.isTop(); // true if this is the topmost layer
|
|
29
|
+
* layer.unregister();
|
|
30
|
+
*/
|
|
31
|
+
export interface LayerOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Called when Escape is pressed and this is the top layer
|
|
34
|
+
*/
|
|
35
|
+
onEscape?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Called when pointer event occurs outside and this is the top layer
|
|
38
|
+
*/
|
|
39
|
+
onOutsidePointer?: (e: PointerEvent) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Optional node reference for outside pointer detection
|
|
42
|
+
*/
|
|
43
|
+
node?: Node | null;
|
|
44
|
+
}
|
|
45
|
+
export interface Layer {
|
|
46
|
+
/**
|
|
47
|
+
* Unique layer ID
|
|
48
|
+
*/
|
|
49
|
+
id: number;
|
|
50
|
+
/**
|
|
51
|
+
* Check if this layer is the topmost
|
|
52
|
+
*/
|
|
53
|
+
isTop(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Remove this layer from the stack
|
|
56
|
+
*/
|
|
57
|
+
unregister(): void;
|
|
58
|
+
}
|
|
59
|
+
export interface LayerManager {
|
|
60
|
+
/**
|
|
61
|
+
* Register a new layer
|
|
62
|
+
*/
|
|
63
|
+
register(options: LayerOptions): Layer;
|
|
64
|
+
/**
|
|
65
|
+
* Get all active layers in order
|
|
66
|
+
*/
|
|
67
|
+
layers(): ReadonlyArray<Layer>;
|
|
68
|
+
/**
|
|
69
|
+
* Manually trigger escape handling on the top layer
|
|
70
|
+
*/
|
|
71
|
+
handleEscape(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Manually trigger outside pointer handling on the top layer
|
|
74
|
+
*/
|
|
75
|
+
handleOutsidePointer(e: PointerEvent): void;
|
|
76
|
+
}
|
|
77
|
+
export declare function createLayer(): LayerManager;
|
|
78
|
+
/**
|
|
79
|
+
* USAGE EXAMPLE:
|
|
80
|
+
*
|
|
81
|
+
* const layerManager = createLayer();
|
|
82
|
+
*
|
|
83
|
+
* function Modal({ onClose }) {
|
|
84
|
+
* const modalRef = ref<HTMLDivElement>();
|
|
85
|
+
*
|
|
86
|
+
* const layer = layerManager.register({
|
|
87
|
+
* node: modalRef.current,
|
|
88
|
+
* onEscape: onClose,
|
|
89
|
+
* onOutsidePointer: onClose,
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* onUnmount(() => layer.unregister());
|
|
93
|
+
*
|
|
94
|
+
* return (
|
|
95
|
+
* <div ref={modalRef}>
|
|
96
|
+
* <h1>Modal</h1>
|
|
97
|
+
* {layer.isTop() && <p>I am on top!</p>}
|
|
98
|
+
* </div>
|
|
99
|
+
* );
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
//# sourceMappingURL=layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../../../src/foundations/structures/layer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;IAE7C;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,KAAK,CAAC;IAEvC;;OAEG;IACH,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;IAE/B;;OAEG;IACH,YAAY,IAAI,IAAI,CAAC;IAErB;;OAEG;IACH,oBAAoB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,WAAW,IAAI,YAAY,CAyE1C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(){const n=[];let s=1;function d(t){const i=s++,e={id:i,options:t};n.push(e);function f(){return n[n.length-1]?.id===i}function p(){const o=n.findIndex(a=>a.id===i);o!==-1&&n.splice(o,1)}return{id:i,isTop:f,unregister:p}}function r(){return n.map(t=>({id:t.id,isTop:()=>n[n.length-1]?.id===t.id,unregister:()=>{const i=n.findIndex(e=>e.id===t.id);i!==-1&&n.splice(i,1)}}))}function c(){const t=n[n.length-1];t&&t.options.onEscape?.()}function u(t){const i=n[n.length-1];if(!i)return;const e=i.options.node;e&&t.target instanceof Node&&e.contains(t.target)||i.options.onOutsidePointer?.(t)}return{register:d,layers:r,handleEscape:c,handleOutsidePointer:u}}export{l as createLayer};
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
* Props are spread into the layout component. This is intentional
|
|
22
22
|
* and deterministic — no merging or composition.
|
|
23
23
|
*/
|
|
24
|
-
type LayoutComponent<P = object> = (props: P & {
|
|
24
|
+
export type LayoutComponent<P = object> = (props: P & {
|
|
25
25
|
children?: unknown;
|
|
26
26
|
}) => unknown;
|
|
27
|
-
declare function layout<P = object>(Layout: LayoutComponent<P>): (children?: unknown, props?: P) => unknown;
|
|
28
|
-
|
|
29
|
-
export { type LayoutComponent as L, layout as l };
|
|
27
|
+
export declare function layout<P = object>(Layout: LayoutComponent<P>): (children?: unknown, props?: P) => unknown;
|
|
28
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/foundations/structures/layout.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,IAAI,CACxC,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAC9B,OAAO,CAAC;AAEb,wBAAgB,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,IACnD,WAAW,OAAO,EAAE,QAAQ,CAAC,aAItC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(r){return(t,e)=>{const n={...e,children:t};return r(n)}}export{o as layout};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portal / Host primitive.
|
|
3
|
+
*
|
|
4
|
+
* Foundations remain runtime-agnostic: a portal is an explicit read/write slot.
|
|
5
|
+
* Scheduling and attachment are owned by the runtime when `createPortalSlot`
|
|
6
|
+
* exists; otherwise this falls back to a local slot (deterministic, but does
|
|
7
|
+
* not schedule updates).
|
|
8
|
+
*
|
|
9
|
+
* POLICY DECISIONS (LOCKED):
|
|
10
|
+
*
|
|
11
|
+
* 1. Local Mutable State
|
|
12
|
+
* Foundations may use local mutable state ONLY to model deterministic slots,
|
|
13
|
+
* never to coordinate timing, effects, or ordering. The fallback mode uses
|
|
14
|
+
* closure-local `mounted` and `value` variables which are non-escaping and
|
|
15
|
+
* deterministic.
|
|
16
|
+
*
|
|
17
|
+
* 2. Return Type Philosophy
|
|
18
|
+
* Portal call signatures return `unknown` (intentionally opaque). The runtime
|
|
19
|
+
* owns the concrete type. This prevents foundations from assuming JSX.Element
|
|
20
|
+
* or DOM node types, maintaining runtime-agnostic portability.
|
|
21
|
+
*/
|
|
22
|
+
export interface Portal<T = unknown> {
|
|
23
|
+
/** Mount point — rendered exactly once */
|
|
24
|
+
(): unknown;
|
|
25
|
+
/** Render content into the portal */
|
|
26
|
+
render(props: {
|
|
27
|
+
children?: T;
|
|
28
|
+
}): unknown;
|
|
29
|
+
}
|
|
30
|
+
export declare function definePortal<T = unknown>(): Portal<T>;
|
|
31
|
+
export declare function _resetDefaultPortal(): void;
|
|
32
|
+
export declare const DefaultPortal: Portal<unknown>;
|
|
33
|
+
//# sourceMappingURL=portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/foundations/structures/portal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,OAAO;IACjC,0CAA0C;IAC1C,IAAI,OAAO,CAAC;IAEZ,qCAAqC;IACrC,MAAM,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,EAAE,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC;CAC1C;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CA6CrD;AAaD,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAOD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,OAAO,CAUtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(){if(typeof createPortalSlot=="function"){let o=function(){return n.read()};const n=createPortalSlot();return o.render=function(a){return n.write(a.children),null},o}let r=!1,t;function e(){return r=!0,t}return e.render=function(n){return r&&(t=n.children),null},e}let l;function i(){l=void 0}function u(){return l||(l=f()),l}const d=(()=>{function r(){const t=u()();return t===void 0?null:t}return r.render=function(e){return u().render(e),null},r})();export{d as DefaultPortal,i as _resetDefaultPortal,f as definePortal};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { JSXElement } from '../../jsx';
|
|
2
|
+
export interface PresenceProps {
|
|
3
|
+
present: boolean | (() => boolean);
|
|
4
|
+
children?: unknown;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Presence
|
|
8
|
+
*
|
|
9
|
+
* Structural policy primitive for conditional mount/unmount.
|
|
10
|
+
* - No timers
|
|
11
|
+
* - No animation coupling
|
|
12
|
+
* - No DOM side-effects
|
|
13
|
+
*
|
|
14
|
+
* POLICY DECISIONS (LOCKED):
|
|
15
|
+
*
|
|
16
|
+
* 1. Present as Function
|
|
17
|
+
* Accepts boolean OR function to support lazy evaluation patterns.
|
|
18
|
+
* Function is called once per render. Use boolean form for static values.
|
|
19
|
+
*
|
|
20
|
+
* 2. Children Type
|
|
21
|
+
* `children` is intentionally `unknown` to remain runtime-agnostic.
|
|
22
|
+
* The runtime owns child normalization and validation.
|
|
23
|
+
*
|
|
24
|
+
* 3. Immediate Mount/Unmount
|
|
25
|
+
* No exit animations or transitions. When `present` becomes false,
|
|
26
|
+
* children are removed immediately. Animation must be layered above
|
|
27
|
+
* this primitive.
|
|
28
|
+
*/
|
|
29
|
+
export declare function Presence({ present, children, }: PresenceProps): JSXElement | null;
|
|
30
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../../src/foundations/structures/presence.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,QAAQ,GACT,EAAE,aAAa,GAAG,UAAU,GAAG,IAAI,CAYnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../jsx/index.js";import{Fragment as t,ELEMENT_TYPE as o}from"../../common/jsx.js";function m({present:e,children:n}){return(typeof e=="function"?e():!!e)?{$$typeof:o,type:t,props:{children:n},key:null}:null}export{m as Presence};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { JSXElement } from '../../jsx';
|
|
2
|
+
export type SlotProps = {
|
|
3
|
+
asChild: true;
|
|
4
|
+
children: JSXElement;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
asChild?: false;
|
|
8
|
+
children?: unknown;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Slot
|
|
12
|
+
*
|
|
13
|
+
* Structural primitive for prop forwarding patterns.
|
|
14
|
+
*
|
|
15
|
+
* POLICY DECISIONS (LOCKED):
|
|
16
|
+
*
|
|
17
|
+
* 1. asChild Pattern
|
|
18
|
+
* When asChild=true, merges props into the single child element.
|
|
19
|
+
* Child must be a valid JSXElement; non-element children return null.
|
|
20
|
+
* **Slot props override child props** (injection pattern).
|
|
21
|
+
*
|
|
22
|
+
* 2. Fallback Behavior
|
|
23
|
+
* When asChild=false, returns a Fragment (structural no-op).
|
|
24
|
+
* No DOM element is introduced.
|
|
25
|
+
*
|
|
26
|
+
* 3. Type Safety
|
|
27
|
+
* asChild=true requires exactly one JSXElement child (enforced by type).
|
|
28
|
+
* Runtime validates with isElement() check.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Slot(props: SlotProps): JSXElement | null;
|
|
31
|
+
//# sourceMappingURL=slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../../src/foundations/structures/slot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,MAAM,SAAS,GACjB;IACE,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,UAAU,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,GACD;IACE,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAmBxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../jsx/index.js";import{isElement as l,cloneElement as r}from"../../jsx/utils.js";import{Fragment as i,ELEMENT_TYPE as o}from"../../common/jsx.js";function s(e){if(e.asChild){const{children:t,asChild:c,...n}=e;return l(t)?r(t,n):null}return{$$typeof:o,type:i,props:{children:e.children},key:null}}export{s as Slot};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { layout } from './structures/layout';
|
|
2
|
+
export type { LayoutComponent } from './structures/layout';
|
|
3
|
+
export { Slot } from './structures/slot';
|
|
4
|
+
export type { SlotProps } from './structures/slot';
|
|
5
|
+
export type { JSXElement } from '../jsx';
|
|
6
|
+
export { Presence } from './structures/presence';
|
|
7
|
+
export type { PresenceProps } from './structures/presence';
|
|
8
|
+
export { definePortal, DefaultPortal } from './structures/portal';
|
|
9
|
+
export type { Portal } from './structures/portal';
|
|
10
|
+
export { createCollection } from './structures/collection';
|
|
11
|
+
export type { Collection, CollectionItem } from './structures/collection';
|
|
12
|
+
export { createLayer } from './structures/layer';
|
|
13
|
+
export type { Layer, LayerManager, LayerOptions } from './structures/layer';
|
|
14
|
+
//# sourceMappingURL=structures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structures.d.ts","sourceRoot":"","sources":["../../src/foundations/structures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{layout as r}from"./structures/layout.js";import{Slot as f}from"./structures/slot.js";import{Presence as l}from"./structures/presence.js";import{DefaultPortal as p,definePortal as x}from"./structures/portal.js";import{createCollection as n}from"./structures/collection.js";import{createLayer as i}from"./structures/layer.js";export{p as DefaultPortal,l as Presence,f as Slot,n as createCollection,i as createLayer,x as definePortal,r as layout};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny aria helpers
|
|
3
|
+
*/
|
|
4
|
+
export declare function ariaDisabled(disabled?: boolean): {
|
|
5
|
+
'aria-disabled'?: 'true';
|
|
6
|
+
};
|
|
7
|
+
export declare function ariaExpanded(expanded?: boolean): {
|
|
8
|
+
'aria-expanded'?: 'true' | 'false';
|
|
9
|
+
};
|
|
10
|
+
export declare function ariaSelected(selected?: boolean): {
|
|
11
|
+
'aria-selected'?: 'true' | 'false';
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=aria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/aria.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAE7E;AAED,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG;IAChD,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC,CAIA;AAED,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG;IAChD,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC,CAIA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a(r){return r?{"aria-disabled":"true"}:{}}function i(r){return r===void 0?{}:{"aria-expanded":String(r)}}function n(r){return r===void 0?{}:{"aria-selected":String(r)}}export{a as ariaDisabled,i as ariaExpanded,n as ariaSelected};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* composeHandlers
|
|
3
|
+
*
|
|
4
|
+
* Compose two event handlers into one. The first handler runs, and unless it
|
|
5
|
+
* calls `event.preventDefault()` (or sets `defaultPrevented`), the second
|
|
6
|
+
* handler runs. This prevents accidental clobbering of child handlers when
|
|
7
|
+
* injecting props.
|
|
8
|
+
*
|
|
9
|
+
* POLICY DECISIONS (LOCKED):
|
|
10
|
+
*
|
|
11
|
+
* 1. Execution Order
|
|
12
|
+
* First handler runs before second (injected before base).
|
|
13
|
+
* This allows injected handlers to prevent default behavior.
|
|
14
|
+
*
|
|
15
|
+
* 2. Default Prevention Check
|
|
16
|
+
* By default, checks `defaultPrevented` on first argument.
|
|
17
|
+
* Can be disabled via options.checkDefaultPrevented = false.
|
|
18
|
+
*
|
|
19
|
+
* 3. Undefined Handler Support
|
|
20
|
+
* Undefined handlers are skipped (no-op). This simplifies usage
|
|
21
|
+
* where handlers are optional.
|
|
22
|
+
*
|
|
23
|
+
* 4. Type Safety
|
|
24
|
+
* Args are readonly to prevent mutation. Return type matches input.
|
|
25
|
+
*/
|
|
26
|
+
export interface ComposeHandlersOptions {
|
|
27
|
+
/**
|
|
28
|
+
* When true (default), do not run the second handler if the first prevented default.
|
|
29
|
+
* When false, always run both handlers.
|
|
30
|
+
*/
|
|
31
|
+
checkDefaultPrevented?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function composeHandlers<A extends readonly unknown[]>(first?: (...args: A) => void, second?: (...args: A) => void, options?: ComposeHandlersOptions): (...args: A) => void;
|
|
34
|
+
//# sourceMappingURL=compose-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-handlers.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/compose-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAaD,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAC1D,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAC5B,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAsBtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(e){return typeof e=="object"&&e!==null&&"defaultPrevented"in e&&e.defaultPrevented===!0}function i(e,t,r){if(!e&&!t)return o;if(!e)return t;if(!t)return e;const u=r?.checkDefaultPrevented!==!1;return function(...n){e(...n),!(u&&f(n[0]))&&t(...n)}}function o(){}export{i as composeHandlers};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ref composition utilities
|
|
3
|
+
*
|
|
4
|
+
* POLICY DECISIONS (LOCKED):
|
|
5
|
+
*
|
|
6
|
+
* 1. Ref Types Supported
|
|
7
|
+
* - Callback refs: (value: T | null) => void
|
|
8
|
+
* - Object refs: { current: T | null }
|
|
9
|
+
* - null/undefined (no-op)
|
|
10
|
+
*
|
|
11
|
+
* 2. Write Failure Handling
|
|
12
|
+
* setRef catches write failures (readonly refs) and ignores them.
|
|
13
|
+
* This is intentional — refs may be readonly in some contexts.
|
|
14
|
+
*
|
|
15
|
+
* 3. Composition Order
|
|
16
|
+
* composeRefs applies refs in array order (left to right).
|
|
17
|
+
* All refs are called even if one fails.
|
|
18
|
+
*/
|
|
19
|
+
export type Ref<T> = ((value: T | null) => void) | {
|
|
20
|
+
current: T | null;
|
|
21
|
+
} | null | undefined;
|
|
22
|
+
export declare function setRef<T>(ref: Ref<T>, value: T | null): void;
|
|
23
|
+
export declare function composeRefs<T>(...refs: Array<Ref<T>>): (value: T | null) => void;
|
|
24
|
+
//# sourceMappingURL=compose-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-ref.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/compose-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC,IACb,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC,GAC3B;IAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GACrB,IAAI,GACJ,SAAS,CAAC;AAEd,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAU5D;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAI3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(t,n){if(t){if(typeof t=="function"){t(n);return}Object.isExtensible(t)&&(t.current=n)}}function f(...t){return n=>{for(const o of t)e(o,n)}}export{f as composeRefs,e as setRef};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DefaultPreventable {
|
|
2
|
+
defaultPrevented?: boolean;
|
|
3
|
+
preventDefault?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export interface PropagationStoppable {
|
|
6
|
+
stopPropagation?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface KeyboardLikeEvent extends DefaultPreventable, PropagationStoppable {
|
|
9
|
+
key: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PointerLikeEvent extends DefaultPreventable, PropagationStoppable {
|
|
12
|
+
target?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface FocusLikeEvent extends DefaultPreventable, PropagationStoppable {
|
|
15
|
+
relatedTarget?: unknown;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=event-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/event-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,iBACf,SAAQ,kBAAkB,EAAE,oBAAoB;IAChD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBACf,SAAQ,kBAAkB,EAAE,oBAAoB;IAChD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cACf,SAAQ,kBAAkB,EAAE,oBAAoB;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-props.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/merge-props.ts"],"names":[],"mappings":"AAiCA,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,EACvE,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,GAClB,SAAS,GAAG,KAAK,CA+BnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{composeHandlers as f}from"./compose-handlers.js";function u(n){return n.startsWith("on")}function a(n,o){const s=Object.keys(n);if(s.length===0)return o;const e={...o};for(const t of s){const r=n[t],c=o[t];if(u(t)&&typeof r=="function"&&typeof c=="function"){e[t]=f(c,r);continue}e[t]=r}return e}export{a as mergeProps};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface FormatIdOptions {
|
|
2
|
+
/** Defaults to 'askr' */
|
|
3
|
+
prefix?: string;
|
|
4
|
+
/** Stable, caller-provided identity */
|
|
5
|
+
id: string | number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* formatId
|
|
9
|
+
*
|
|
10
|
+
* Formats a stable ID from a caller-provided identity.
|
|
11
|
+
* - Pure and deterministic (no time/randomness/global counters)
|
|
12
|
+
* - SSR-safe
|
|
13
|
+
*
|
|
14
|
+
* POLICY DECISIONS (LOCKED):
|
|
15
|
+
*
|
|
16
|
+
* 1. No Auto-Generation
|
|
17
|
+
* Caller must provide the `id`. No random/sequential generation.
|
|
18
|
+
* This ensures determinism and SSR safety.
|
|
19
|
+
*
|
|
20
|
+
* 2. Format Convention
|
|
21
|
+
* IDs are formatted as `{prefix}-{id}`.
|
|
22
|
+
* Default prefix is "askr".
|
|
23
|
+
*
|
|
24
|
+
* 3. Type Coercion
|
|
25
|
+
* Numbers are coerced to strings via String().
|
|
26
|
+
* This is deterministic and consistent.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatId(options: FormatIdOptions): string;
|
|
29
|
+
//# sourceMappingURL=use-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-id.d.ts","sourceRoot":"","sources":["../../../src/foundations/utilities/use-id.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAGzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(r){return`${r.prefix??"askr"}-${String(r.id)}`}export{f as formatId};
|
package/dist/fx/fx.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type CancelFn = () => void;
|
|
2
|
+
export declare function debounceEvent(ms: number, handler: EventListener, options?: {
|
|
3
|
+
leading?: boolean;
|
|
4
|
+
trailing?: boolean;
|
|
5
|
+
}): EventListener & {
|
|
6
|
+
cancel(): void;
|
|
7
|
+
flush(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function throttleEvent(ms: number, handler: EventListener, options?: {
|
|
10
|
+
leading?: boolean;
|
|
11
|
+
trailing?: boolean;
|
|
12
|
+
}): EventListener & {
|
|
13
|
+
cancel(): void;
|
|
14
|
+
};
|
|
15
|
+
export declare function rafEvent(handler: EventListener): EventListener & {
|
|
16
|
+
cancel(): void;
|
|
17
|
+
};
|
|
18
|
+
export declare function scheduleTimeout(ms: number, fn: () => void): CancelFn;
|
|
19
|
+
export declare function scheduleIdle(fn: () => void, options?: {
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}): CancelFn;
|
|
22
|
+
export interface RetryOptions {
|
|
23
|
+
maxAttempts?: number;
|
|
24
|
+
delayMs?: number;
|
|
25
|
+
backoff?: (attemptIndex: number) => number;
|
|
26
|
+
}
|
|
27
|
+
export declare function scheduleRetry<T>(fn: () => Promise<T>, options?: RetryOptions): {
|
|
28
|
+
cancel(): void;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=fx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx.d.ts","sourceRoot":"","sources":["../../src/fx/fx.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAwClC,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAClD,aAAa,GAAG;IAAE,MAAM,IAAI,IAAI,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE,CAoEnD;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAClD,aAAa,GAAG;IAAE,MAAM,IAAI,IAAI,CAAA;CAAE,CAwDpC;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,GACrB,aAAa,GAAG;IAAE,MAAM,IAAI,IAAI,CAAA;CAAE,CAmDpC;AAID,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,QAAQ,CAqBpE;AAED,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,IAAI,EACd,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,QAAQ,CAwCV;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAED,wBAAgB,aAAa,CAAC,CAAC,EAC7B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB;IAAE,MAAM,IAAI,IAAI,CAAA;CAAE,CAiDpB"}
|
package/dist/fx/fx.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{globalScheduler as h}from"../runtime/scheduler.js";import{getCurrentComponentInstance as d}from"../runtime/component.js";import{logger as T}from"../dev/logger.js";import{noopEventListenerWithFlush as g,noopEventListener as F}from"./noop.js";function p(){if(d()!==null)throw new Error("[Askr] calling FX handler during render is not allowed. Move calls to event handlers or effects.")}function m(c){h.enqueue(()=>{try{c()}catch(u){T.error("[Askr] FX handler error:",u)}})}function A(c,u,e){const{leading:n=!1,trailing:o=!0}=e||{},r=d();if(r&&r.ssr)return g;let l=null,t=null,s=0;const i=function(f){p();const a=Date.now();t=f,l!==null&&(clearTimeout(l),l=null),n&&a-s>=c&&(m(()=>u.call(null,f)),s=a),o&&(l=setTimeout(()=>{t&&m(()=>u.call(null,t)),l=null,s=Date.now()},c))};return i.cancel=()=>{l!==null&&(clearTimeout(l),l=null),t=null},i.flush=()=>{if(l!==null){clearTimeout(l);const f=t;t=null,l=null,f&&m(()=>u.call(null,f))}},r&&r.cleanupFns.push(()=>{i.cancel()}),i}function C(c,u,e){const{leading:n=!0,trailing:o=!0}=e||{},r=d();if(r&&r.ssr)return F;let l=0,t=null,s=null;const i=function(f){p();const a=Date.now();if(s=f,n&&a-l>=c?(m(()=>u.call(null,f)),l=a,t!==null&&(clearTimeout(t),t=null)):!n&&l===0&&(l=a),o&&t===null){const w=c-(a-l);t=setTimeout(()=>{s&&m(()=>u.call(null,s)),l=Date.now(),t=null},Math.max(0,w))}};return i.cancel=()=>{t!==null&&(clearTimeout(t),t=null),s=null},r&&r.cleanupFns.push(()=>i.cancel()),i}function k(c){const u=d();if(u&&u.ssr)return F;let e=null,n=null;const o=()=>{e=(typeof requestAnimationFrame<"u"?requestAnimationFrame:t=>setTimeout(()=>t(Date.now()),16))(()=>{if(e=null,n){const t=n;n=null,m(()=>c.call(null,t))}})},r=function(l){p(),n=l,e===null&&o()};return r.cancel=()=>{e!==null&&(typeof cancelAnimationFrame<"u"&&typeof e=="number"?cancelAnimationFrame(e):clearTimeout(e),e=null),n=null},u&&u.cleanupFns.push(()=>r.cancel()),r}function E(c,u){p();const e=d();if(e&&e.ssr)return()=>{};let n=setTimeout(()=>{n=null,m(u)},c);const o=()=>{n!==null&&(clearTimeout(n),n=null)};return e&&e.cleanupFns.push(o),o}function q(c,u){p();const e=d();if(e&&e.ssr)return()=>{};let n=null,o=!1;typeof requestIdleCallback<"u"?(o=!0,n=requestIdleCallback(()=>{n=null,m(c)},u)):n=setTimeout(()=>{n=null,m(c)},0);const r=()=>{n!==null&&(o&&typeof cancelIdleCallback<"u"&&typeof n=="number"?cancelIdleCallback(n):clearTimeout(n),n=null)};return e&&e.cleanupFns.push(r),r}function D(c,u){p();const e=d();if(e&&e.ssr)return{cancel:()=>{}};const{maxAttempts:n=3,delayMs:o=100,backoff:r=i=>o*Math.pow(2,i)}=u||{};let l=!1;const t=i=>{l||h.enqueue(()=>{if(l)return;c().then(()=>{},()=>{if(!l&&i+1<n){const a=r(i);setTimeout(()=>{t(i+1)},a)}}).catch(a=>{T.error("[Askr] scheduleRetry error:",a)})})};t(0);const s=()=>{l=!0};return e&&e.cleanupFns.push(s),{cancel:s}}export{A as debounceEvent,k as rafEvent,q as scheduleIdle,D as scheduleRetry,E as scheduleTimeout,C as throttleEvent};
|