@hozo/engine 0.1.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 (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -0
  3. package/dist/activate.d.ts +14 -0
  4. package/dist/activate.d.ts.map +1 -0
  5. package/dist/activate.js +38 -0
  6. package/dist/activate.js.map +1 -0
  7. package/dist/ambient.d.ts +79 -0
  8. package/dist/ambient.d.ts.map +1 -0
  9. package/dist/ambient.js +117 -0
  10. package/dist/ambient.js.map +1 -0
  11. package/dist/backdrop.d.ts +36 -0
  12. package/dist/backdrop.d.ts.map +1 -0
  13. package/dist/backdrop.js +41 -0
  14. package/dist/backdrop.js.map +1 -0
  15. package/dist/class-name.native.d.ts +20 -0
  16. package/dist/class-name.native.d.ts.map +1 -0
  17. package/dist/class-name.native.js +34 -0
  18. package/dist/class-name.native.js.map +1 -0
  19. package/dist/class-resolver.d.ts +26 -0
  20. package/dist/class-resolver.d.ts.map +1 -0
  21. package/dist/class-resolver.js +56 -0
  22. package/dist/class-resolver.js.map +1 -0
  23. package/dist/color-transition.d.ts +3 -0
  24. package/dist/color-transition.d.ts.map +1 -0
  25. package/dist/color-transition.js +31 -0
  26. package/dist/color-transition.js.map +1 -0
  27. package/dist/dom-style.d.ts +10 -0
  28. package/dist/dom-style.d.ts.map +1 -0
  29. package/dist/dom-style.js +145 -0
  30. package/dist/dom-style.js.map +1 -0
  31. package/dist/dom-style.native.d.ts +7 -0
  32. package/dist/dom-style.native.d.ts.map +1 -0
  33. package/dist/dom-style.native.js +9 -0
  34. package/dist/dom-style.native.js.map +1 -0
  35. package/dist/external-link.d.ts +6 -0
  36. package/dist/external-link.d.ts.map +1 -0
  37. package/dist/external-link.js +9 -0
  38. package/dist/external-link.js.map +1 -0
  39. package/dist/generated/animation.d.ts +2 -0
  40. package/dist/generated/animation.d.ts.map +1 -0
  41. package/dist/generated/animation.js +3 -0
  42. package/dist/generated/animation.js.map +1 -0
  43. package/dist/generated/class-resolver.d.ts +2 -0
  44. package/dist/generated/class-resolver.d.ts.map +1 -0
  45. package/dist/generated/class-resolver.js +3 -0
  46. package/dist/generated/class-resolver.js.map +1 -0
  47. package/dist/generated/dom-style.d.ts +2 -0
  48. package/dist/generated/dom-style.d.ts.map +1 -0
  49. package/dist/generated/dom-style.js +2 -0
  50. package/dist/generated/dom-style.js.map +1 -0
  51. package/dist/generated/dom-style.native.d.ts +2 -0
  52. package/dist/generated/dom-style.native.d.ts.map +1 -0
  53. package/dist/generated/dom-style.native.js +2 -0
  54. package/dist/generated/dom-style.native.js.map +1 -0
  55. package/dist/generated/environment.d.ts +2 -0
  56. package/dist/generated/environment.d.ts.map +1 -0
  57. package/dist/generated/environment.js +5 -0
  58. package/dist/generated/environment.js.map +1 -0
  59. package/dist/generated/image-source.d.ts +2 -0
  60. package/dist/generated/image-source.d.ts.map +1 -0
  61. package/dist/generated/image-source.js +3 -0
  62. package/dist/generated/image-source.js.map +1 -0
  63. package/dist/generated/interactive.d.ts +2 -0
  64. package/dist/generated/interactive.d.ts.map +1 -0
  65. package/dist/generated/interactive.js +2 -0
  66. package/dist/generated/interactive.js.map +1 -0
  67. package/dist/generated/safe-area.d.ts +2 -0
  68. package/dist/generated/safe-area.d.ts.map +1 -0
  69. package/dist/generated/safe-area.js +4 -0
  70. package/dist/generated/safe-area.js.map +1 -0
  71. package/dist/generated/scrollable.d.ts +2 -0
  72. package/dist/generated/scrollable.d.ts.map +1 -0
  73. package/dist/generated/scrollable.js +2 -0
  74. package/dist/generated/scrollable.js.map +1 -0
  75. package/dist/hooks.native.d.ts +92 -0
  76. package/dist/hooks.native.d.ts.map +1 -0
  77. package/dist/hooks.native.js +284 -0
  78. package/dist/hooks.native.js.map +1 -0
  79. package/dist/image-source.native.d.ts +5 -0
  80. package/dist/image-source.native.d.ts.map +1 -0
  81. package/dist/image-source.native.js +5 -0
  82. package/dist/image-source.native.js.map +1 -0
  83. package/dist/index.d.ts +11 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +30 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/index.native.d.ts +8 -0
  88. package/dist/index.native.d.ts.map +1 -0
  89. package/dist/index.native.js +28 -0
  90. package/dist/index.native.js.map +1 -0
  91. package/dist/interactive.d.ts +31 -0
  92. package/dist/interactive.d.ts.map +1 -0
  93. package/dist/interactive.js +64 -0
  94. package/dist/interactive.js.map +1 -0
  95. package/dist/navigation-context.d.ts +11 -0
  96. package/dist/navigation-context.d.ts.map +1 -0
  97. package/dist/navigation-context.js +12 -0
  98. package/dist/navigation-context.js.map +1 -0
  99. package/dist/navigation-entry.d.ts +3 -0
  100. package/dist/navigation-entry.d.ts.map +1 -0
  101. package/dist/navigation-entry.js +3 -0
  102. package/dist/navigation-entry.js.map +1 -0
  103. package/dist/navigation-entry.native.d.ts +2 -0
  104. package/dist/navigation-entry.native.d.ts.map +1 -0
  105. package/dist/navigation-entry.native.js +6 -0
  106. package/dist/navigation-entry.native.js.map +1 -0
  107. package/dist/navigation.d.ts +34 -0
  108. package/dist/navigation.d.ts.map +1 -0
  109. package/dist/navigation.js +27 -0
  110. package/dist/navigation.js.map +1 -0
  111. package/dist/project.d.ts +10 -0
  112. package/dist/project.d.ts.map +1 -0
  113. package/dist/project.js +10 -0
  114. package/dist/project.js.map +1 -0
  115. package/dist/project.native.d.ts +2 -0
  116. package/dist/project.native.d.ts.map +1 -0
  117. package/dist/project.native.js +2 -0
  118. package/dist/project.native.js.map +1 -0
  119. package/dist/responder.d.ts +100 -0
  120. package/dist/responder.d.ts.map +1 -0
  121. package/dist/responder.js +256 -0
  122. package/dist/responder.js.map +1 -0
  123. package/dist/safe-area.native.d.ts +18 -0
  124. package/dist/safe-area.native.d.ts.map +1 -0
  125. package/dist/safe-area.native.js +72 -0
  126. package/dist/safe-area.native.js.map +1 -0
  127. package/dist/scrollable.d.ts +16 -0
  128. package/dist/scrollable.d.ts.map +1 -0
  129. package/dist/scrollable.js +114 -0
  130. package/dist/scrollable.js.map +1 -0
  131. package/dist/text-size.d.ts +12 -0
  132. package/dist/text-size.d.ts.map +1 -0
  133. package/dist/text-size.js +22 -0
  134. package/dist/text-size.js.map +1 -0
  135. package/package.json +131 -0
  136. package/src/activate.ts +45 -0
  137. package/src/ambient.ts +199 -0
  138. package/src/backdrop.ts +66 -0
  139. package/src/class-name.native.ts +53 -0
  140. package/src/class-resolver.ts +74 -0
  141. package/src/color-transition.ts +27 -0
  142. package/src/dom-style.native.ts +13 -0
  143. package/src/dom-style.ts +173 -0
  144. package/src/external-link.ts +12 -0
  145. package/src/generated/animation.ts +2 -0
  146. package/src/generated/class-resolver.ts +2 -0
  147. package/src/generated/dom-style.native.ts +1 -0
  148. package/src/generated/dom-style.ts +1 -0
  149. package/src/generated/environment.ts +10 -0
  150. package/src/generated/image-source.ts +2 -0
  151. package/src/generated/interactive.ts +1 -0
  152. package/src/generated/safe-area.ts +3 -0
  153. package/src/generated/scrollable.ts +1 -0
  154. package/src/hooks.native.ts +408 -0
  155. package/src/image-source.native.ts +4 -0
  156. package/src/index.native.ts +38 -0
  157. package/src/index.ts +50 -0
  158. package/src/interactive.ts +68 -0
  159. package/src/navigation-context.tsx +20 -0
  160. package/src/navigation-entry.native.ts +5 -0
  161. package/src/navigation-entry.ts +12 -0
  162. package/src/navigation.ts +55 -0
  163. package/src/project.native.ts +1 -0
  164. package/src/project.ts +9 -0
  165. package/src/responder.ts +372 -0
  166. package/src/safe-area.native.ts +87 -0
  167. package/src/scrollable.ts +119 -0
  168. package/src/text-size.ts +25 -0
@@ -0,0 +1,34 @@
1
+ /** A destination-bearing interaction after component-specific events run. */
2
+ export interface HozoNavigationRequest {
3
+ href: string;
4
+ /** Bypass application routing and use the platform destination handler. */
5
+ external?: boolean;
6
+ /** Replace the current router history entry instead of pushing a new one. */
7
+ replace?: boolean;
8
+ }
9
+ /**
10
+ * The deliberately small seam between universal primitives and a router.
11
+ *
12
+ * `true` means the router accepted the destination. Returning `false` lets
13
+ * the platform fallback handle it instead. The adapter owns route matching;
14
+ * the runtime cannot reliably infer whether an absolute URL belongs to an
15
+ * application, or whether a custom scheme is an internal native route.
16
+ */
17
+ export interface HozoNavigationAdapter {
18
+ navigate(request: HozoNavigationRequest): boolean | Promise<boolean>;
19
+ /** Warms an application-owned destination without navigating to it. */
20
+ prefetch?(request: HozoNavigationRequest): unknown | Promise<unknown>;
21
+ }
22
+ export type HozoNavigationFallback = (href: string) => unknown | Promise<unknown>;
23
+ /**
24
+ * Offers an internal destination to the installed router, then falls back.
25
+ *
26
+ * Explicit external links never enter application routing. A declined route
27
+ * and an absent adapter are equivalent, which keeps every primitive useful
28
+ * before `@hozo/navigation` is installed and prevents the adapter from
29
+ * becoming a required global singleton.
30
+ */
31
+ export declare function activateHozoNavigation(adapter: HozoNavigationAdapter | null, request: HozoNavigationRequest, fallback: HozoNavigationFallback): Promise<void>;
32
+ /** Offers a destination to an installed router without a platform fallback. */
33
+ export declare function prefetchHozoNavigation(adapter: HozoNavigationAdapter | null, request: HozoNavigationRequest): void;
34
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACpE,uEAAuE;IACvE,QAAQ,CAAC,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACtE;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEjF;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,qBAAqB,GAAG,IAAI,EACrC,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,sBAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,qBAAqB,GAAG,IAAI,EACrC,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAQN"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Offers an internal destination to the installed router, then falls back.
3
+ *
4
+ * Explicit external links never enter application routing. A declined route
5
+ * and an absent adapter are equivalent, which keeps every primitive useful
6
+ * before `@hozo/navigation` is installed and prevents the adapter from
7
+ * becoming a required global singleton.
8
+ */
9
+ export async function activateHozoNavigation(adapter, request, fallback) {
10
+ if (!request.external && adapter && (await adapter.navigate(request)))
11
+ return;
12
+ await fallback(request.href);
13
+ }
14
+ /** Offers a destination to an installed router without a platform fallback. */
15
+ export function prefetchHozoNavigation(adapter, request) {
16
+ if (request.external)
17
+ return;
18
+ try {
19
+ const result = adapter?.prefetch?.(request);
20
+ if (result !== undefined)
21
+ void Promise.resolve(result).catch(() => { });
22
+ }
23
+ catch {
24
+ // Prefetch is speculative. A cache warm-up must never break interaction.
25
+ }
26
+ }
27
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAqC,EACrC,OAA8B,EAC9B,QAAgC;IAEhC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,IAAI,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAAE,OAAM;IAC7E,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CACpC,OAAqC,EACrC,OAA8B;IAE9B,IAAI,OAAO,CAAC,QAAQ;QAAE,OAAM;IAC5B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAA;QAC3C,IAAI,MAAM,KAAK,SAAS;YAAE,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;IAC3E,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Project-wide Native defaults when no bundler integration supplies them.
3
+ *
4
+ * `@hozo/metro` redirects this entry to the generated candidate module,
5
+ * whose value is the resolved `preflight` option. Keeping a real entry here
6
+ * makes unconfigured builds and component tests deterministic; Tailwind's
7
+ * reset is the common case and was the fallback before this entry existed.
8
+ */
9
+ export declare const hozoPreflight = true;
10
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,OAAO,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Project-wide Native defaults when no bundler integration supplies them.
3
+ *
4
+ * `@hozo/metro` redirects this entry to the generated candidate module,
5
+ * whose value is the resolved `preflight` option. Keeping a real entry here
6
+ * makes unconfigured builds and component tests deterministic; Tailwind's
7
+ * reset is the common case and was the fallback before this entry existed.
8
+ */
9
+ export const hozoPreflight = true;
10
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { hozoPreflight } from './project.ts';
2
+ //# sourceMappingURL=project.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.native.d.ts","sourceRoot":"","sources":["../src/project.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { hozoPreflight } from './project.js';
2
+ //# sourceMappingURL=project.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.native.js","sourceRoot":"","sources":["../src/project.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,100 @@
1
+ import { type PointerEventHandler, type RefObject } from 'react';
2
+ export interface HozoResponderTouch {
3
+ identifier: number;
4
+ locationX: number;
5
+ locationY: number;
6
+ pageX: number;
7
+ pageY: number;
8
+ /**
9
+ * What was touched, in whichever platform's currency.
10
+ *
11
+ * A DOM node in the browser and a native view tag -- a number -- on
12
+ * device, with `undefined` because React Native's own touch declares it
13
+ * optional. This said `EventTarget | null` and nothing else, which is
14
+ * the browser's answer written into a shape whose whole purpose is to
15
+ * be platform-free.
16
+ *
17
+ * That was invisible for the same reason the missing `className` was:
18
+ * the `react-native` export condition carried no `types`, so `tsc` in a
19
+ * React Native app never asked React Native's declarations whether these
20
+ * handlers fit. Asked, it says no -- `{...pan.panHandlers}` on a native
21
+ * `View` does not type-check, because a handler taking this event is not
22
+ * one React Native may call.
23
+ */
24
+ target: EventTarget | number | null | undefined;
25
+ timestamp: number;
26
+ }
27
+ export interface HozoResponderEvent {
28
+ nativeEvent: HozoResponderTouch & {
29
+ changedTouches: readonly HozoResponderTouch[];
30
+ touches: readonly HozoResponderTouch[];
31
+ };
32
+ touchHistory: HozoTouchHistory;
33
+ preventDefault(): void;
34
+ stopPropagation(): void;
35
+ }
36
+ export interface HozoTouchTrack {
37
+ touchActive: boolean;
38
+ currentPageX: number;
39
+ currentPageY: number;
40
+ currentTimeStamp: number;
41
+ previousPageX: number;
42
+ previousPageY: number;
43
+ previousTimeStamp: number;
44
+ }
45
+ export interface HozoTouchHistory {
46
+ /** `readonly` for the same reason the touch lists are. */
47
+ touchBank: readonly HozoTouchTrack[];
48
+ numberActiveTouches: number;
49
+ indexOfSingleActiveTouch: number;
50
+ mostRecentTimeStamp: number;
51
+ }
52
+ export interface ResponderProps {
53
+ onStartShouldSetResponder?: (event: HozoResponderEvent) => boolean;
54
+ onStartShouldSetResponderCapture?: (event: HozoResponderEvent) => boolean;
55
+ onMoveShouldSetResponder?: (event: HozoResponderEvent) => boolean;
56
+ onMoveShouldSetResponderCapture?: (event: HozoResponderEvent) => boolean;
57
+ onResponderGrant?: (event: HozoResponderEvent) => void;
58
+ onResponderStart?: (event: HozoResponderEvent) => void;
59
+ onResponderMove?: (event: HozoResponderEvent) => void;
60
+ onResponderEnd?: (event: HozoResponderEvent) => void;
61
+ onResponderRelease?: (event: HozoResponderEvent) => void;
62
+ onResponderReject?: (event: HozoResponderEvent) => void;
63
+ onResponderTerminate?: (event: HozoResponderEvent) => void;
64
+ onResponderTerminationRequest?: (event: HozoResponderEvent) => boolean;
65
+ }
66
+ export declare function useResponderDomProps<T extends HTMLElement>(elementRef: RefObject<T | null>, props: ResponderProps, enabled?: boolean): {
67
+ onPointerDown?: undefined;
68
+ onPointerDownCapture?: undefined;
69
+ onPointerMove?: undefined;
70
+ onPointerMoveCapture?: undefined;
71
+ onPointerUp?: undefined;
72
+ onPointerCancel?: undefined;
73
+ onLostPointerCapture?: undefined;
74
+ } | {
75
+ onPointerDown: PointerEventHandler<T>;
76
+ onPointerDownCapture: PointerEventHandler<T>;
77
+ onPointerMove: PointerEventHandler<T>;
78
+ onPointerMoveCapture: PointerEventHandler<T>;
79
+ onPointerUp: PointerEventHandler<T>;
80
+ onPointerCancel: PointerEventHandler<T>;
81
+ onLostPointerCapture: PointerEventHandler<T>;
82
+ };
83
+ export declare function createResponderDomProps<T extends HTMLElement>(elementRef: RefObject<T | null>, propsRef: RefObject<ResponderProps>, enabled?: boolean): {
84
+ onPointerDown?: undefined;
85
+ onPointerDownCapture?: undefined;
86
+ onPointerMove?: undefined;
87
+ onPointerMoveCapture?: undefined;
88
+ onPointerUp?: undefined;
89
+ onPointerCancel?: undefined;
90
+ onLostPointerCapture?: undefined;
91
+ } | {
92
+ onPointerDown: PointerEventHandler<T>;
93
+ onPointerDownCapture: PointerEventHandler<T>;
94
+ onPointerMove: PointerEventHandler<T>;
95
+ onPointerMoveCapture: PointerEventHandler<T>;
96
+ onPointerUp: PointerEventHandler<T>;
97
+ onPointerCancel: PointerEventHandler<T>;
98
+ onLostPointerCapture: PointerEventHandler<T>;
99
+ };
100
+ //# sourceMappingURL=responder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responder.d.ts","sourceRoot":"","sources":["../src/responder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAA;AAEd,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;;;;;;;;OAeG;IACH,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAC/C,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,kBAAkB,GAAG;QAGhC,cAAc,EAAE,SAAS,kBAAkB,EAAE,CAAA;QAC7C,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAA;KACvC,CAAA;IACD,YAAY,EAAE,gBAAgB,CAAA;IAC9B,cAAc,IAAI,IAAI,CAAA;IACtB,eAAe,IAA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BAAkB,KAAK,IAAI,CAAA;IAC1D,6BAA6B,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,OAAO,CAAA;CACvE;AAiMD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,EACxD,UAAU,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,EAC/B,KAAK,EAAE,cAAc,EACrB,OAAO,UAAO;;;;;;;;;;;;;;;;EAWf;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAC3D,UAAU,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,EAC/B,QAAQ,EAAE,SAAS,CAAC,cAAc,CAAC,EACnC,OAAO,UAAO;;;;;;;;;;;;;;;;EAkFf"}
@@ -0,0 +1,256 @@
1
+ import { useEffect, useRef, } from 'react';
2
+ let activeResponder;
3
+ const activePointers = new Map();
4
+ const pointerHistory = new Map();
5
+ const trackedEvents = new WeakSet();
6
+ let globalCleanupInstalled = false;
7
+ function endPointer(pointerId, pageX, pageY, timestamp) {
8
+ activePointers.delete(pointerId);
9
+ const track = pointerHistory.get(pointerId);
10
+ if (track) {
11
+ track.touchActive = false;
12
+ if (pageX !== undefined && pageY !== undefined && timestamp !== undefined) {
13
+ track.previousPageX = track.currentPageX;
14
+ track.previousPageY = track.currentPageY;
15
+ track.previousTimeStamp = track.currentTimeStamp;
16
+ track.currentPageX = pageX;
17
+ track.currentPageY = pageY;
18
+ track.currentTimeStamp = timestamp;
19
+ }
20
+ }
21
+ }
22
+ function ensureGlobalPointerCleanup() {
23
+ if (globalCleanupInstalled || typeof window === 'undefined')
24
+ return;
25
+ globalCleanupInstalled = true;
26
+ const remove = (event) => {
27
+ endPointer(event.pointerId, event.pageX, event.pageY, event.timeStamp);
28
+ };
29
+ window.addEventListener('pointerup', remove);
30
+ window.addEventListener('pointercancel', remove);
31
+ }
32
+ function eventKey(event) {
33
+ return typeof event.nativeEvent === 'object' && event.nativeEvent !== null
34
+ ? event.nativeEvent
35
+ : event;
36
+ }
37
+ function trackPointer(event, phase) {
38
+ const key = eventKey(event);
39
+ if (trackedEvents.has(key))
40
+ return false;
41
+ trackedEvents.add(key);
42
+ if (phase === 'end') {
43
+ endPointer(event.pointerId, event.pageX, event.pageY, event.timeStamp);
44
+ }
45
+ else {
46
+ ensureGlobalPointerCleanup();
47
+ if (phase === 'start' && activePointers.size === 0)
48
+ pointerHistory.clear();
49
+ activePointers.set(event.pointerId, {
50
+ identifier: event.pointerId,
51
+ clientX: event.clientX,
52
+ clientY: event.clientY,
53
+ pageX: event.pageX,
54
+ pageY: event.pageY,
55
+ target: event.target,
56
+ timestamp: event.timeStamp,
57
+ });
58
+ const previous = pointerHistory.get(event.pointerId);
59
+ pointerHistory.set(event.pointerId, {
60
+ touchActive: true,
61
+ currentPageX: event.pageX,
62
+ currentPageY: event.pageY,
63
+ currentTimeStamp: event.timeStamp,
64
+ previousPageX: phase === 'move' && previous ? previous.currentPageX : event.pageX,
65
+ previousPageY: phase === 'move' && previous ? previous.currentPageY : event.pageY,
66
+ previousTimeStamp: phase === 'move' && previous ? previous.currentTimeStamp : event.timeStamp,
67
+ });
68
+ }
69
+ return true;
70
+ }
71
+ function releaseRegistration(props) {
72
+ const incumbent = activeResponder;
73
+ if (!incumbent || incumbent.props !== props)
74
+ return;
75
+ activeResponder = undefined;
76
+ for (const pointerId of incumbent.pointerIds) {
77
+ if (incumbent.element.hasPointerCapture?.(pointerId)) {
78
+ incumbent.element.releasePointerCapture?.(pointerId);
79
+ }
80
+ }
81
+ }
82
+ function responderEvent(event, ended = false) {
83
+ const rect = event.currentTarget.getBoundingClientRect();
84
+ const toTouch = (pointer) => ({
85
+ identifier: pointer.identifier,
86
+ locationX: pointer.clientX - rect.left,
87
+ locationY: pointer.clientY - rect.top,
88
+ pageX: pointer.pageX,
89
+ pageY: pointer.pageY,
90
+ target: pointer.target,
91
+ timestamp: pointer.timestamp,
92
+ });
93
+ const changed = toTouch({
94
+ identifier: event.pointerId,
95
+ clientX: event.clientX,
96
+ clientY: event.clientY,
97
+ pageX: event.pageX,
98
+ pageY: event.pageY,
99
+ target: event.target,
100
+ timestamp: event.timeStamp,
101
+ });
102
+ const touches = [...activePointers.values()].map(toTouch);
103
+ const touchBank = [...pointerHistory.values()];
104
+ const activeIndices = touchBank
105
+ .map((track, index) => (track.touchActive ? index : -1))
106
+ .filter((index) => index >= 0);
107
+ return {
108
+ nativeEvent: {
109
+ ...changed,
110
+ changedTouches: [changed],
111
+ touches: ended ? touches.filter((touch) => touch.identifier !== event.pointerId) : touches,
112
+ },
113
+ touchHistory: {
114
+ touchBank,
115
+ numberActiveTouches: activePointers.size,
116
+ indexOfSingleActiveTouch: activeIndices.length === 1 ? activeIndices[0] : -1,
117
+ mostRecentTimeStamp: touchBank.reduce((latest, track) => Math.max(latest, track.currentTimeStamp), 0),
118
+ },
119
+ preventDefault: () => event.preventDefault(),
120
+ stopPropagation: () => event.stopPropagation(),
121
+ };
122
+ }
123
+ function claim(element, props, event) {
124
+ if (!event.isPrimary || activeResponder?.element === element)
125
+ return false;
126
+ const value = responderEvent(event);
127
+ if (activeResponder) {
128
+ const incumbent = activeResponder;
129
+ const allowsTermination = incumbent.props.current.onResponderTerminationRequest?.(value) ?? true;
130
+ if (!allowsTermination) {
131
+ props.current.onResponderReject?.(value);
132
+ return false;
133
+ }
134
+ activeResponder = undefined;
135
+ incumbent.props.current.onResponderTerminate?.(value);
136
+ for (const pointerId of incumbent.pointerIds) {
137
+ if (incumbent.element.hasPointerCapture?.(pointerId)) {
138
+ incumbent.element.releasePointerCapture?.(pointerId);
139
+ }
140
+ }
141
+ }
142
+ activeResponder = { element, pointerIds: new Set([event.pointerId]), props };
143
+ element.setPointerCapture?.(event.pointerId);
144
+ props.current.onResponderGrant?.(value);
145
+ props.current.onResponderStart?.(value);
146
+ return true;
147
+ }
148
+ function finish(element, event, terminated) {
149
+ const incumbent = activeResponder;
150
+ if (!incumbent || incumbent.element !== element || !incumbent.pointerIds.has(event.pointerId))
151
+ return;
152
+ incumbent.pointerIds.delete(event.pointerId);
153
+ const value = responderEvent(event, true);
154
+ incumbent.props.current.onResponderEnd?.(value);
155
+ if (element.hasPointerCapture?.(event.pointerId))
156
+ element.releasePointerCapture?.(event.pointerId);
157
+ if (!terminated && incumbent.pointerIds.size > 0)
158
+ return;
159
+ activeResponder = undefined;
160
+ if (terminated)
161
+ incumbent.props.current.onResponderTerminate?.(value);
162
+ else
163
+ incumbent.props.current.onResponderRelease?.(value);
164
+ }
165
+ export function useResponderDomProps(elementRef, props, enabled = true) {
166
+ const propsRef = useRef(props);
167
+ propsRef.current = props;
168
+ // `enabled` is not read in the effect and is not there for that: the
169
+ // cleanup is the body, and it has to run when a responder is turned off
170
+ // rather than only when it unmounts. Dropping the dependency leaves a
171
+ // disabled element holding the pointer capture.
172
+ // biome-ignore lint/correctness/useExhaustiveDependencies: turning it off has to release
173
+ useEffect(() => () => releaseRegistration(propsRef), [enabled]);
174
+ return createResponderDomProps(elementRef, propsRef, enabled);
175
+ }
176
+ export function createResponderDomProps(elementRef, propsRef, enabled = true) {
177
+ if (!enabled)
178
+ return {};
179
+ const negotiate = (shouldSet, event) => {
180
+ const element = elementRef.current;
181
+ if (!element || activeResponder?.element === element || !shouldSet?.(responderEvent(event)))
182
+ return false;
183
+ return claim(element, propsRef, event);
184
+ };
185
+ const onPointerDown = (event) => {
186
+ const isNewPointer = trackPointer(event, 'start');
187
+ const element = elementRef.current;
188
+ const incumbent = activeResponder;
189
+ if (isNewPointer && element && incumbent?.element === element) {
190
+ incumbent.pointerIds.add(event.pointerId);
191
+ element.setPointerCapture?.(event.pointerId);
192
+ propsRef.current.onResponderStart?.(responderEvent(event));
193
+ return;
194
+ }
195
+ // The responder negotiation bubbles deepest-first. Once a child wins,
196
+ // ancestors must not make a second claim from the same pointer start.
197
+ if (negotiate(propsRef.current.onStartShouldSetResponder, event))
198
+ event.stopPropagation();
199
+ };
200
+ const onPointerDownCapture = (event) => {
201
+ const isNewPointer = trackPointer(event, 'start');
202
+ const element = elementRef.current;
203
+ const incumbent = activeResponder;
204
+ if (isNewPointer && element && incumbent?.element === element) {
205
+ incumbent.pointerIds.add(event.pointerId);
206
+ element.setPointerCapture?.(event.pointerId);
207
+ propsRef.current.onResponderStart?.(responderEvent(event));
208
+ event.stopPropagation();
209
+ return;
210
+ }
211
+ if (negotiate(propsRef.current.onStartShouldSetResponderCapture, event))
212
+ event.stopPropagation();
213
+ };
214
+ const onPointerMove = (event) => {
215
+ trackPointer(event, 'move');
216
+ const element = elementRef.current;
217
+ const incumbent = activeResponder;
218
+ if (element &&
219
+ incumbent &&
220
+ incumbent.element === element &&
221
+ incumbent.pointerIds.has(event.pointerId)) {
222
+ propsRef.current.onResponderMove?.(responderEvent(event));
223
+ }
224
+ else {
225
+ if (negotiate(propsRef.current.onMoveShouldSetResponder, event))
226
+ event.stopPropagation();
227
+ }
228
+ };
229
+ const onPointerMoveCapture = (event) => {
230
+ trackPointer(event, 'move');
231
+ if (negotiate(propsRef.current.onMoveShouldSetResponderCapture, event))
232
+ event.stopPropagation();
233
+ };
234
+ const onPointerUp = (event) => {
235
+ trackPointer(event, 'end');
236
+ finish(event.currentTarget, event, false);
237
+ };
238
+ const onPointerCancel = (event) => {
239
+ trackPointer(event, 'end');
240
+ finish(event.currentTarget, event, true);
241
+ };
242
+ const onLostPointerCapture = (event) => {
243
+ trackPointer(event, 'end');
244
+ finish(event.currentTarget, event, true);
245
+ };
246
+ return {
247
+ onPointerDown,
248
+ onPointerDownCapture,
249
+ onPointerMove,
250
+ onPointerMoveCapture,
251
+ onPointerUp,
252
+ onPointerCancel,
253
+ onLostPointerCapture,
254
+ };
255
+ }
256
+ //# sourceMappingURL=responder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responder.js","sourceRoot":"","sources":["../src/responder.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAA;AA+Ed,IAAI,eAAyC,CAAA;AAY7C,M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AAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAA;IACD,MAAM,oBAAoB,GAA2B,CAAC,KAAK,EAAE,EAAE;QAC7D,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC1B,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAA;IAED,OAAO;QACL,aAAa;QACb,oBAAoB;QACpB,aAAa;QACb,oBAAoB;QACpB,WAAW;QACX,eAAe;QACf,oBAAoB;KACrB,CAAA;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** The four insets, in the shape the compiled style reads them. */
2
+ export interface HozoSafeAreaInsets {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ }
8
+ /**
9
+ * The current safe-area insets. Drives `pt-[env(safe-area-inset-top)]` and
10
+ * the other three sides, the way `useHozoViewport` drives `h-screen`.
11
+ *
12
+ * A wrapper with no logic in it is the point: the number belongs to the
13
+ * platform, this package's job is to make one spelling reach both, and
14
+ * anything clever here would be Hozo having an opinion about a value it
15
+ * cannot measure.
16
+ */
17
+ export declare function useHozoSafeArea(): HozoSafeAreaInsets;
18
+ //# sourceMappingURL=safe-area.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-area.native.d.ts","sourceRoot":"","sources":["../src/safe-area.native.ts"],"names":[],"mappings":"AAuBA,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AA8CD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,kBAAkB,CAEpD"}
@@ -0,0 +1,72 @@
1
+ // The insets a notch, a home indicator and a status bar take out of the
2
+ // window, read from the package every React Native app already has.
3
+ //
4
+ // `pt-[env(safe-area-inset-top)]` is a class Tailwind itself produces, and
5
+ // on Web it needs nothing from Hozo: the browser resolves `env()`. On React
6
+ // Native there is no cascade to resolve it in, and -- this is the part that
7
+ // decided the design -- no way to read the real number from React Native's
8
+ // core either. Core exposes a deprecated iOS-only `SafeAreaView`, which
9
+ // applies padding rather than reporting a value, and an Android-only
10
+ // `StatusBar.currentHeight`, which is the status bar and not the cutout.
11
+ // `safeAreaInsets` appears nowhere in its JavaScript.
12
+ //
13
+ // So the value needs native code: `UIView.safeAreaInsets` on iOS,
14
+ // `WindowInsets` on Android. Hozo could ship that itself, and chose not to.
15
+ // `@hozo/*` is a compiler and JavaScript today, which means a project can
16
+ // add it without a rebuild, without autolinking, and without leaving Expo
17
+ // Go; shipping a native module to avoid one dependency would trade that
18
+ // away for every user in order to save one `pnpm add` for some of them.
19
+ //
20
+ // `react-native-safe-area-context` is that dependency, and it is not an
21
+ // obscure one: `@react-navigation` pulls it in, so most applications with
22
+ // more than one screen already have it.
23
+ const NONE = { top: 0, right: 0, bottom: 0, left: 0 };
24
+ /**
25
+ * The package's hook, or a hook-shaped constant when it is not installed.
26
+ *
27
+ * Resolved at module load, which is both the simple answer and the correct
28
+ * one. Simple, because a hook chosen once is a hook called unconditionally
29
+ * afterwards -- selecting per render would be calling a hook inside a
30
+ * branch, which is the rule React does not bend even when the branch is
31
+ * decided by the bundle and never changes.
32
+ *
33
+ * Correct, because this module is only loaded when the compiler emitted a
34
+ * safe-area class. A project that writes none never imports it, never
35
+ * resolves anything, and never sees the warning; a project that writes one
36
+ * sees it exactly once, at startup, when there is still time to act.
37
+ */
38
+ function resolveInsetsHook() {
39
+ try {
40
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
41
+ const module = require('react-native-safe-area-context');
42
+ if (typeof module.useSafeAreaInsets === 'function')
43
+ return module.useSafeAreaInsets;
44
+ }
45
+ catch {
46
+ // Not installed. Fall through to the warning: an optional dependency
47
+ // that throws on absence is not optional.
48
+ }
49
+ console.warn('[hozo] a safe-area class needs `react-native-safe-area-context`, which is not installed. ' +
50
+ 'Insets are zero until it is: add it, then wrap the app in its `<SafeAreaProvider>`. ' +
51
+ 'Hozo ships no native code of its own, and the real inset is `UIView.safeAreaInsets` on ' +
52
+ 'iOS and `WindowInsets` on Android -- neither of which React Native exposes to JavaScript.');
53
+ // Zeros rather than a throw, because of what each costs: a missing inset
54
+ // draws content under a notch, which is ugly and recoverable, and a
55
+ // thrown error is a blank app. The warning is what makes the ugly one
56
+ // findable.
57
+ return () => NONE;
58
+ }
59
+ const useInsets = resolveInsetsHook();
60
+ /**
61
+ * The current safe-area insets. Drives `pt-[env(safe-area-inset-top)]` and
62
+ * the other three sides, the way `useHozoViewport` drives `h-screen`.
63
+ *
64
+ * A wrapper with no logic in it is the point: the number belongs to the
65
+ * platform, this package's job is to make one spelling reach both, and
66
+ * anything clever here would be Hozo having an opinion about a value it
67
+ * cannot measure.
68
+ */
69
+ export function useHozoSafeArea() {
70
+ return useInsets();
71
+ }
72
+ //# sourceMappingURL=safe-area.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-area.native.js","sourceRoot":"","sources":["../src/safe-area.native.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,qEAAqE;AACrE,yEAAyE;AACzE,sDAAsD;AACtD,EAAE;AACF,kEAAkE;AAClE,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,wCAAwC;AAYxC,MAAM,IAAI,GAAuB,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;AAEzE;;;;;;;;;;;;;GAaG;AACH,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAEtD,CAAA;QACD,IAAI,OAAO,MAAM,CAAC,iBAAiB,KAAK,UAAU;YAAE,OAAO,MAAM,CAAC,iBAAiB,CAAA;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;QACrE,0CAA0C;IAC5C,CAAC;IACD,OAAO,CAAC,IAAI,CACV,2FAA2F;QACzF,sFAAsF;QACtF,yFAAyF;QACzF,2FAA2F,CAC9F,CAAA;IACD,yEAAyE;IACzE,oEAAoE;IACpE,sEAAsE;IACtE,YAAY;IACZ,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA;AACnB,CAAC;AAED,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAA;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,SAAS,EAAE,CAAA;AACpB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Props for a compiled `ScrollView`, from `{...hozoScrollable()}`.
3
+ *
4
+ * A ref callback rather than state: this sets one attribute on one element
5
+ * and has no business re-rendering the tree to do it. The observers are
6
+ * torn down when React hands back `null`.
7
+ *
8
+ * Not emitted at all when the author wrote their own `tabIndex` -- that
9
+ * precedence is settled by the compiler, which can see the attribute, so
10
+ * there is no branch here to get wrong. An author saying `tabIndex={-1}`
11
+ * means it, and nothing in this file will argue.
12
+ */
13
+ export declare function hozoScrollable(): {
14
+ ref: (element: HTMLElement | null) => void;
15
+ };
16
+ //# sourceMappingURL=scrollable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollable.d.ts","sourceRoot":"","sources":["../src/scrollable.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc;IAmB1B,GAAG,YAAY,WAAW,GAAG,IAAI;EAsBpC"}