@ghia/native 0.0.0-stage → 0.11.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 (212) hide show
  1. package/LICENSE +201 -0
  2. package/browser.mjs +7 -0
  3. package/dist/aria.d.ts +72 -0
  4. package/dist/aria.d.ts.map +1 -0
  5. package/dist/aria.js +2 -0
  6. package/dist/aria.js.map +1 -0
  7. package/dist/automation/client.d.ts +243 -0
  8. package/dist/automation/client.d.ts.map +1 -0
  9. package/dist/automation/client.js +801 -0
  10. package/dist/automation/client.js.map +1 -0
  11. package/dist/automation/index.d.ts +5 -0
  12. package/dist/automation/index.d.ts.map +1 -0
  13. package/dist/automation/index.js +4 -0
  14. package/dist/automation/index.js.map +1 -0
  15. package/dist/automation/protocol.d.ts +309 -0
  16. package/dist/automation/protocol.d.ts.map +1 -0
  17. package/dist/automation/protocol.js +320 -0
  18. package/dist/automation/protocol.js.map +1 -0
  19. package/dist/blob-images.d.ts +32 -0
  20. package/dist/blob-images.d.ts.map +1 -0
  21. package/dist/blob-images.js +55 -0
  22. package/dist/blob-images.js.map +1 -0
  23. package/dist/bounds.d.ts +61 -0
  24. package/dist/bounds.d.ts.map +1 -0
  25. package/dist/bounds.js +85 -0
  26. package/dist/bounds.js.map +1 -0
  27. package/dist/clipboard-global.d.ts +11 -0
  28. package/dist/clipboard-global.d.ts.map +1 -0
  29. package/dist/clipboard-global.js +2 -0
  30. package/dist/clipboard-global.js.map +1 -0
  31. package/dist/clipboard.d.ts +19 -0
  32. package/dist/clipboard.d.ts.map +1 -0
  33. package/dist/clipboard.js +41 -0
  34. package/dist/clipboard.js.map +1 -0
  35. package/dist/cpu-throttle.d.ts +6 -0
  36. package/dist/cpu-throttle.d.ts.map +1 -0
  37. package/dist/cpu-throttle.js +42 -0
  38. package/dist/cpu-throttle.js.map +1 -0
  39. package/dist/events/data-transfer.d.ts +23 -0
  40. package/dist/events/data-transfer.d.ts.map +1 -0
  41. package/dist/events/data-transfer.js +97 -0
  42. package/dist/events/data-transfer.js.map +1 -0
  43. package/dist/events/dispatch.d.ts +144 -0
  44. package/dist/events/dispatch.d.ts.map +1 -0
  45. package/dist/events/dispatch.js +241 -0
  46. package/dist/events/dispatch.js.map +1 -0
  47. package/dist/events/drag.d.ts +21 -0
  48. package/dist/events/drag.d.ts.map +1 -0
  49. package/dist/events/drag.js +111 -0
  50. package/dist/events/drag.js.map +1 -0
  51. package/dist/events/event-props.d.ts +19 -0
  52. package/dist/events/event-props.d.ts.map +1 -0
  53. package/dist/events/event-props.js +104 -0
  54. package/dist/events/event-props.js.map +1 -0
  55. package/dist/events/keyboard-defaults.d.ts +18 -0
  56. package/dist/events/keyboard-defaults.d.ts.map +1 -0
  57. package/dist/events/keyboard-defaults.js +121 -0
  58. package/dist/events/keyboard-defaults.js.map +1 -0
  59. package/dist/events/listeners.d.ts +18 -0
  60. package/dist/events/listeners.d.ts.map +1 -0
  61. package/dist/events/listeners.js +49 -0
  62. package/dist/events/listeners.js.map +1 -0
  63. package/dist/events/route.d.ts +17 -0
  64. package/dist/events/route.d.ts.map +1 -0
  65. package/dist/events/route.js +36 -0
  66. package/dist/events/route.js.map +1 -0
  67. package/dist/events/types.d.ts +269 -0
  68. package/dist/events/types.d.ts.map +1 -0
  69. package/dist/events/types.js +2 -0
  70. package/dist/events/types.js.map +1 -0
  71. package/dist/events/window-target.d.ts +120 -0
  72. package/dist/events/window-target.d.ts.map +1 -0
  73. package/dist/events/window-target.js +311 -0
  74. package/dist/events/window-target.js.map +1 -0
  75. package/dist/eyedropper.d.ts +33 -0
  76. package/dist/eyedropper.d.ts.map +1 -0
  77. package/dist/eyedropper.js +66 -0
  78. package/dist/eyedropper.js.map +1 -0
  79. package/dist/focus.d.ts +18 -0
  80. package/dist/focus.d.ts.map +1 -0
  81. package/dist/focus.js +26 -0
  82. package/dist/focus.js.map +1 -0
  83. package/dist/fonts.d.ts +12 -0
  84. package/dist/fonts.d.ts.map +1 -0
  85. package/dist/fonts.js +17 -0
  86. package/dist/fonts.js.map +1 -0
  87. package/dist/forms.d.ts +10 -0
  88. package/dist/forms.d.ts.map +1 -0
  89. package/dist/forms.js +9 -0
  90. package/dist/forms.js.map +1 -0
  91. package/dist/host-runtime.d.ts +108 -0
  92. package/dist/host-runtime.d.ts.map +1 -0
  93. package/dist/host-runtime.js +213 -0
  94. package/dist/host-runtime.js.map +1 -0
  95. package/dist/host.d.ts +2403 -0
  96. package/dist/host.d.ts.map +1 -0
  97. package/dist/host.js +30 -0
  98. package/dist/host.js.map +1 -0
  99. package/dist/idle-gc.d.ts +36 -0
  100. package/dist/idle-gc.d.ts.map +1 -0
  101. package/dist/idle-gc.js +70 -0
  102. package/dist/idle-gc.js.map +1 -0
  103. package/dist/keyframes.d.ts +108 -0
  104. package/dist/keyframes.d.ts.map +1 -0
  105. package/dist/keyframes.js +107 -0
  106. package/dist/keyframes.js.map +1 -0
  107. package/dist/layout-animation.d.ts +38 -0
  108. package/dist/layout-animation.d.ts.map +1 -0
  109. package/dist/layout-animation.js +41 -0
  110. package/dist/layout-animation.js.map +1 -0
  111. package/dist/match-media.d.ts +62 -0
  112. package/dist/match-media.d.ts.map +1 -0
  113. package/dist/match-media.js +272 -0
  114. package/dist/match-media.js.map +1 -0
  115. package/dist/media-query.d.ts +21 -0
  116. package/dist/media-query.d.ts.map +1 -0
  117. package/dist/media-query.js +599 -0
  118. package/dist/media-query.js.map +1 -0
  119. package/dist/motion-bindings.d.ts +36 -0
  120. package/dist/motion-bindings.d.ts.map +1 -0
  121. package/dist/motion-bindings.js +107 -0
  122. package/dist/motion-bindings.js.map +1 -0
  123. package/dist/motion-config.d.ts +20 -0
  124. package/dist/motion-config.d.ts.map +1 -0
  125. package/dist/motion-config.js +51 -0
  126. package/dist/motion-config.js.map +1 -0
  127. package/dist/motion-span.d.ts +57 -0
  128. package/dist/motion-span.d.ts.map +1 -0
  129. package/dist/motion-span.js +150 -0
  130. package/dist/motion-span.js.map +1 -0
  131. package/dist/motion-value.d.ts +269 -0
  132. package/dist/motion-value.d.ts.map +1 -0
  133. package/dist/motion-value.js +941 -0
  134. package/dist/motion-value.js.map +1 -0
  135. package/dist/motion-variants.d.ts +190 -0
  136. package/dist/motion-variants.d.ts.map +1 -0
  137. package/dist/motion-variants.js +249 -0
  138. package/dist/motion-variants.js.map +1 -0
  139. package/dist/mutations.d.ts +65 -0
  140. package/dist/mutations.d.ts.map +1 -0
  141. package/dist/mutations.js +320 -0
  142. package/dist/mutations.js.map +1 -0
  143. package/dist/nativeview.d.ts +10 -0
  144. package/dist/nativeview.d.ts.map +1 -0
  145. package/dist/nativeview.js +92 -0
  146. package/dist/nativeview.js.map +1 -0
  147. package/dist/observers.d.ts +92 -0
  148. package/dist/observers.d.ts.map +1 -0
  149. package/dist/observers.js +579 -0
  150. package/dist/observers.js.map +1 -0
  151. package/dist/presence.d.ts +63 -0
  152. package/dist/presence.d.ts.map +1 -0
  153. package/dist/presence.js +54 -0
  154. package/dist/presence.js.map +1 -0
  155. package/dist/renderer-state.d.ts +155 -0
  156. package/dist/renderer-state.d.ts.map +1 -0
  157. package/dist/renderer-state.js +302 -0
  158. package/dist/renderer-state.js.map +1 -0
  159. package/dist/reorder.d.ts +63 -0
  160. package/dist/reorder.d.ts.map +1 -0
  161. package/dist/reorder.js +303 -0
  162. package/dist/reorder.js.map +1 -0
  163. package/dist/runtime.d.ts +23 -0
  164. package/dist/runtime.d.ts.map +1 -0
  165. package/dist/runtime.js +157 -0
  166. package/dist/runtime.js.map +1 -0
  167. package/dist/screen.d.ts +8 -0
  168. package/dist/screen.d.ts.map +1 -0
  169. package/dist/screen.js +16 -0
  170. package/dist/screen.js.map +1 -0
  171. package/dist/scroll.d.ts +79 -0
  172. package/dist/scroll.d.ts.map +1 -0
  173. package/dist/scroll.js +170 -0
  174. package/dist/scroll.js.map +1 -0
  175. package/dist/style-images.d.ts +20 -0
  176. package/dist/style-images.d.ts.map +1 -0
  177. package/dist/style-images.js +57 -0
  178. package/dist/style-images.js.map +1 -0
  179. package/dist/svg.d.ts +16 -0
  180. package/dist/svg.d.ts.map +1 -0
  181. package/dist/svg.js +119 -0
  182. package/dist/svg.js.map +1 -0
  183. package/dist/testing.d.ts +811 -0
  184. package/dist/testing.d.ts.map +1 -0
  185. package/dist/testing.js +1187 -0
  186. package/dist/testing.js.map +1 -0
  187. package/dist/text-match.d.ts +8 -0
  188. package/dist/text-match.d.ts.map +1 -0
  189. package/dist/text-match.js +10 -0
  190. package/dist/text-match.js.map +1 -0
  191. package/dist/text-selection.d.ts +34 -0
  192. package/dist/text-selection.d.ts.map +1 -0
  193. package/dist/text-selection.js +23 -0
  194. package/dist/text-selection.js.map +1 -0
  195. package/dist/universal-style.d.ts +22 -0
  196. package/dist/universal-style.d.ts.map +1 -0
  197. package/dist/universal-style.js +58 -0
  198. package/dist/universal-style.js.map +1 -0
  199. package/dist/web-animations.d.ts +300 -0
  200. package/dist/web-animations.d.ts.map +1 -0
  201. package/dist/web-animations.js +1032 -0
  202. package/dist/web-animations.js.map +1 -0
  203. package/dist/webview.d.ts +39 -0
  204. package/dist/webview.d.ts.map +1 -0
  205. package/dist/webview.js +26 -0
  206. package/dist/webview.js.map +1 -0
  207. package/gpuix-native.darwin-arm64.node +4 -0
  208. package/index.cjs +789 -0
  209. package/index.d.ts +2603 -0
  210. package/index.js +729 -0
  211. package/package.json +94 -3
  212. package/README.md +0 -3
@@ -0,0 +1,579 @@
1
+ import { flushPendingMutations, HOST_BINDING, HOST_MOUNT, toBoundingClientRect, } from "./bounds.js";
2
+ /**
3
+ * `ResizeObserver` and `IntersectionObserver` for host elements.
4
+ *
5
+ * Native reports an observed element's border box, content box and visible
6
+ * (clipped) rect after each paint where they changed; the rules of the two DOM
7
+ * APIs are applied here. Entries are delivered once per batch of native
8
+ * events, after all of a frame's reports have arrived.
9
+ *
10
+ * Observing does not read layout. The first observation of every element
11
+ * observed since the last frame is probed together, in one step after the
12
+ * commit, so N observers started by one commit cost one draw, not N.
13
+ */
14
+ export const RESIZE_OBSERVE_EVENT = "resizeObserve";
15
+ export const INTERSECT_OBSERVE_EVENT = "intersectObserve";
16
+ const EPSILON = 0.01;
17
+ const RESIZE_DELIVERY = 0;
18
+ const INTERSECTION_DELIVERY = 1;
19
+ /** Creation order of the observers of this realm, across renderers: only comparisons within one hub matter. */
20
+ let observersCreated = 0;
21
+ const HUBS_KEY = Symbol.for("@ghia/native/observer-hubs");
22
+ function hubFor(renderer) {
23
+ let hubs = Reflect.get(globalThis, HUBS_KEY);
24
+ if (!hubs) {
25
+ hubs = new WeakMap();
26
+ Reflect.set(globalThis, HUBS_KEY, hubs);
27
+ }
28
+ let hub = hubs.get(renderer);
29
+ if (!hub) {
30
+ hub = {
31
+ listening: {
32
+ [RESIZE_OBSERVE_EVENT]: new Map(),
33
+ [INTERSECT_OBSERVE_EVENT]: new Map(),
34
+ },
35
+ evaluating: new Set(),
36
+ queued: new Set(),
37
+ probes: [],
38
+ scheduled: undefined,
39
+ };
40
+ hubs.set(renderer, hub);
41
+ }
42
+ return hub;
43
+ }
44
+ function setNativeListener(binding, id, kind, on, flush) {
45
+ binding.mutations.setEventListener(id, kind, on);
46
+ if (flush)
47
+ binding.mutations.flushMutations();
48
+ }
49
+ /**
50
+ * Add a subscriber to the element's reports. The first report, or the
51
+ * subscriber's own copy of the last one, comes with the next `settleObservations`:
52
+ * the DOM too delivers an initial observation at the next rendering step.
53
+ */
54
+ function attach(binding, id, kind, subscriber) {
55
+ const hub = hubFor(binding.renderer);
56
+ const listening = hub.listening[kind];
57
+ let entry = listening.get(id);
58
+ if (!entry) {
59
+ entry = { binding, subscribers: new Set(), last: undefined };
60
+ listening.set(id, entry);
61
+ setNativeListener(binding, id, kind, true, false);
62
+ }
63
+ const current = entry;
64
+ current.subscribers.add(subscriber);
65
+ subscriber.bound?.(binding);
66
+ const probe = { binding, id, entry: current, subscriber, cancelled: false };
67
+ hub.probes.push(probe);
68
+ ensureScheduled(binding.renderer);
69
+ return () => {
70
+ probe.cancelled = true;
71
+ current.subscribers.delete(subscriber);
72
+ if (current.subscribers.size > 0 || listening.get(id) !== current)
73
+ return;
74
+ listening.delete(id);
75
+ setNativeListener(binding, id, kind, false, true);
76
+ };
77
+ }
78
+ /**
79
+ * Subscribe to an element's native reports. An element that is not mounted yet
80
+ * (a Solid `ref` runs before the tree is inserted) stays pending, as in the
81
+ * DOM, and reports once it has a box. An element created natively again after
82
+ * a removal is subscribed again.
83
+ */
84
+ function listen(kind, element, subscriber) {
85
+ let release;
86
+ const bind = () => {
87
+ const binding = element[HOST_BINDING]();
88
+ if (!binding)
89
+ return;
90
+ if (release) {
91
+ // Created again: the native element is new and has no listener.
92
+ setNativeListener(binding, element.id, kind, true, false);
93
+ return;
94
+ }
95
+ release = attach(binding, element.id, kind, subscriber);
96
+ };
97
+ bind();
98
+ const stopMountWatch = element[HOST_MOUNT]?.(bind);
99
+ return () => {
100
+ stopMountWatch?.();
101
+ release?.();
102
+ release = undefined;
103
+ };
104
+ }
105
+ function schedule(run) {
106
+ return typeof setImmediate === "function" ? setImmediate(run) : setTimeout(run, 0);
107
+ }
108
+ function cancelScheduled(handle) {
109
+ if (typeof clearImmediate === "function")
110
+ clearImmediate(handle);
111
+ clearTimeout(handle);
112
+ }
113
+ function ensureScheduled(renderer) {
114
+ const hub = hubFor(renderer);
115
+ if (hub.scheduled === undefined)
116
+ hub.scheduled = schedule(() => flushObservations(renderer));
117
+ }
118
+ function queueEvaluation(renderer, evaluation) {
119
+ hubFor(renderer).evaluating.add(evaluation);
120
+ ensureScheduled(renderer);
121
+ }
122
+ function queueDelivery(renderer, delivery) {
123
+ hubFor(renderer).queued.add(delivery);
124
+ ensureScheduled(renderer);
125
+ }
126
+ /**
127
+ * Probe every subscription made since the last probe, now: the pending
128
+ * mutations are sent and the window is laid out once for all of them. A
129
+ * subscriber that joined an element that has reported already is handed that
130
+ * report instead, with no layout read.
131
+ */
132
+ export function settleObservations(renderer) {
133
+ const hub = hubFor(renderer);
134
+ const probes = hub.probes.filter((probe) => !probe.cancelled);
135
+ hub.probes = [];
136
+ if (probes.length === 0)
137
+ return;
138
+ flushPendingMutations(renderer);
139
+ for (const probe of probes) {
140
+ if (probe.entry.last) {
141
+ probe.subscriber.receive(probe.entry.last);
142
+ continue;
143
+ }
144
+ if (!probe.binding.renderer.probeElementBounds) {
145
+ throw new Error("This renderer cannot observe elements: it has no probeElementBounds");
146
+ }
147
+ // Read even for a subscriber that does not care: the read is what draws
148
+ // the frame whose report it is waiting for. It leaves the content of a
149
+ // skipped element unbuilt: an observer never gathers it, and the read of
150
+ // a target in it is told there is no box, as Chrome's first report is.
151
+ const painted = probe.binding.renderer.probeElementBounds(probe.id) !== null;
152
+ probe.subscriber.settled?.(probe.binding, painted);
153
+ }
154
+ }
155
+ function reportCallbackError(error) {
156
+ const report = globalThis.reportError;
157
+ if (report)
158
+ report(error);
159
+ else
160
+ queueMicrotask(() => {
161
+ throw error;
162
+ });
163
+ }
164
+ /**
165
+ * Run the callbacks of every observer with entries waiting, now. The frame
166
+ * loop delivers on its own right after a frame's reports; a test calls this
167
+ * after draining native events, since nothing else would run.
168
+ */
169
+ export function flushObservations(renderer) {
170
+ settleObservations(renderer);
171
+ const hub = hubFor(renderer);
172
+ const evaluating = [...hub.evaluating];
173
+ hub.evaluating.clear();
174
+ for (const evaluation of evaluating)
175
+ evaluation.evaluate();
176
+ if (hub.scheduled !== undefined) {
177
+ cancelScheduled(hub.scheduled);
178
+ hub.scheduled = undefined;
179
+ }
180
+ const queued = [...hub.queued].sort((a, b) => a.kind - b.kind || a.order - b.order);
181
+ hub.queued.clear();
182
+ for (const delivery of queued)
183
+ delivery.deliver();
184
+ }
185
+ /** Called for every native event. Returns whether an observer wanted it. */
186
+ export function deliverObservation(renderer, event) {
187
+ if (event.eventType !== RESIZE_OBSERVE_EVENT && event.eventType !== INTERSECT_OBSERVE_EVENT) {
188
+ return false;
189
+ }
190
+ const entry = hubFor(renderer).listening[event.eventType].get(event.elementId);
191
+ if (!entry || !event.observation)
192
+ return false;
193
+ entry.last = event;
194
+ for (const subscriber of [...entry.subscribers])
195
+ subscriber.receive(event);
196
+ return true;
197
+ }
198
+ function near(left, right) {
199
+ return Math.abs(left - right) < EPSILON;
200
+ }
201
+ export class ResizeObserver {
202
+ #callback;
203
+ #records = new Map();
204
+ #pending = new Map();
205
+ #delivery = {
206
+ kind: RESIZE_DELIVERY,
207
+ order: observersCreated++,
208
+ deliver: () => this.#deliver(),
209
+ };
210
+ /** Set when the first record binds; every event arrives after that. */
211
+ #renderer;
212
+ constructor(callback) {
213
+ if (typeof callback !== "function") {
214
+ throw new TypeError("ResizeObserver: the callback is not a function");
215
+ }
216
+ this.#callback = callback;
217
+ }
218
+ /** Start observing, or restart: observing an element again reports its size again. */
219
+ observe(target, options = {}) {
220
+ const box = options.box ?? "content-box";
221
+ if (box !== "content-box" && box !== "border-box") {
222
+ throw new TypeError(`ResizeObserver: unsupported box "${String(box)}"`);
223
+ }
224
+ this.unobserve(target);
225
+ const record = {
226
+ target,
227
+ box,
228
+ last: [0, 0],
229
+ stop: () => { },
230
+ };
231
+ this.#records.set(target, record);
232
+ record.stop = listen(RESIZE_OBSERVE_EVENT, target, {
233
+ receive: (event) => this.#receive(record, event),
234
+ bound: (binding) => {
235
+ this.#renderer = binding.renderer;
236
+ },
237
+ });
238
+ }
239
+ unobserve(target) {
240
+ this.#records.get(target)?.stop();
241
+ this.#records.delete(target);
242
+ this.#pending.delete(target);
243
+ }
244
+ disconnect() {
245
+ for (const record of this.#records.values())
246
+ record.stop();
247
+ this.#records.clear();
248
+ this.#pending.clear();
249
+ }
250
+ #receive(record, event) {
251
+ const observation = event.observation;
252
+ const borderWidth = event.width ?? 0;
253
+ const borderHeight = event.height ?? 0;
254
+ const size = record.box === "border-box"
255
+ ? [borderWidth, borderHeight]
256
+ : [observation.contentWidth, observation.contentHeight];
257
+ if (near(size[0], record.last[0]) && near(size[1], record.last[1]))
258
+ return;
259
+ record.last = size;
260
+ const left = observation.paddingLeft;
261
+ const top = observation.paddingTop;
262
+ this.#pending.set(record.target, {
263
+ target: record.target,
264
+ contentRect: {
265
+ x: left,
266
+ y: top,
267
+ width: observation.contentWidth,
268
+ height: observation.contentHeight,
269
+ left,
270
+ top,
271
+ right: left + observation.contentWidth,
272
+ bottom: top + observation.contentHeight,
273
+ },
274
+ borderBoxSize: [{ inlineSize: borderWidth, blockSize: borderHeight }],
275
+ contentBoxSize: [
276
+ { inlineSize: observation.contentWidth, blockSize: observation.contentHeight },
277
+ ],
278
+ });
279
+ queueDelivery(this.#renderer, this.#delivery);
280
+ }
281
+ #deliver() {
282
+ if (this.#pending.size === 0)
283
+ return;
284
+ // In the order the targets were observed, not the order the frame reported them in.
285
+ const entries = [];
286
+ for (const target of this.#records.keys()) {
287
+ const entry = this.#pending.get(target);
288
+ if (entry)
289
+ entries.push(entry);
290
+ }
291
+ this.#pending.clear();
292
+ try {
293
+ this.#callback.call(this, entries, this);
294
+ }
295
+ catch (error) {
296
+ reportCallbackError(error);
297
+ }
298
+ }
299
+ }
300
+ const MARGIN_LENGTH = /^(-?(?:\d+\.?\d*|\.\d+))(px|%)$/;
301
+ function parseRootMargin(text) {
302
+ const tokens = text.trim().split(/\s+/);
303
+ if (text.trim() === "" || tokens.length > 4) {
304
+ throw new SyntaxError(`IntersectionObserver: invalid rootMargin "${text}"`);
305
+ }
306
+ const lengths = tokens.map((token) => {
307
+ const match = MARGIN_LENGTH.exec(token);
308
+ if (!match)
309
+ throw new SyntaxError(`IntersectionObserver: invalid rootMargin "${text}"`);
310
+ return { value: Number(match[1]), percent: match[2] === "%" };
311
+ });
312
+ const [top, right = top, bottom = top, left = right] = lengths;
313
+ return [top, right, bottom, left];
314
+ }
315
+ function area(rect) {
316
+ return rect.width * rect.height;
317
+ }
318
+ function overlap(left, right) {
319
+ const x = Math.max(left.x, right.x);
320
+ const y = Math.max(left.y, right.y);
321
+ return {
322
+ x,
323
+ y,
324
+ width: Math.max(0, Math.min(left.x + left.width, right.x + right.width) - x),
325
+ height: Math.max(0, Math.min(left.y + left.height, right.y + right.height) - y),
326
+ };
327
+ }
328
+ function contains(outer, inner) {
329
+ return (inner.x >= outer.x &&
330
+ inner.y >= outer.y &&
331
+ inner.x + inner.width <= outer.x + outer.width &&
332
+ inner.y + inner.height <= outer.y + outer.height);
333
+ }
334
+ const NO_BOX = { x: 0, y: 0, width: 0, height: 0 };
335
+ /** What an element root exposes: its client box, which is the padding box less a classic scrollbar. */
336
+ function clientBox(borderBox, observation) {
337
+ return {
338
+ x: borderBox.x + observation.borderLeft,
339
+ y: borderBox.y + observation.borderTop,
340
+ width: Math.max(0, borderBox.width - observation.borderLeft - observation.borderRight - observation.scrollbarWidth),
341
+ height: Math.max(0, borderBox.height - observation.borderTop - observation.borderBottom - observation.scrollbarHeight),
342
+ };
343
+ }
344
+ function asBoundingClientRect(rect) {
345
+ return toBoundingClientRect(rect);
346
+ }
347
+ export class IntersectionObserver {
348
+ root;
349
+ rootMargin;
350
+ thresholds;
351
+ #callback;
352
+ #margin;
353
+ #records = new Map();
354
+ #queue = [];
355
+ #delivery = {
356
+ kind: INTERSECTION_DELIVERY,
357
+ order: observersCreated++,
358
+ deliver: () => this.#deliver(),
359
+ };
360
+ #evaluation = { evaluate: () => this.#evaluateDirty() };
361
+ #renderer;
362
+ #stopWatchingRoot;
363
+ /** Set by the root's own report; an element root has no box before it. */
364
+ #rootBox;
365
+ constructor(callback, options = {}) {
366
+ if (typeof callback !== "function") {
367
+ throw new TypeError("IntersectionObserver: the callback is not a function");
368
+ }
369
+ this.#callback = callback;
370
+ this.root = options.root ?? null;
371
+ this.#margin = parseRootMargin(options.rootMargin ?? "0px");
372
+ this.rootMargin = this.#margin
373
+ .map((length) => `${length.value}${length.percent ? "%" : "px"}`)
374
+ .join(" ");
375
+ const threshold = options.threshold ?? 0;
376
+ const thresholds = (Array.isArray(threshold) ? threshold : [threshold]).slice();
377
+ for (const value of thresholds) {
378
+ if (typeof value !== "number" || !(value >= 0 && value <= 1)) {
379
+ throw new RangeError(`IntersectionObserver: threshold ${String(value)} is not between 0 and 1`);
380
+ }
381
+ }
382
+ this.thresholds = (thresholds.length === 0 ? [0] : thresholds).sort((a, b) => a - b);
383
+ }
384
+ /** Start observing. The first entry arrives after the next frame, whatever the state. */
385
+ observe(target) {
386
+ if (this.#records.has(target))
387
+ return;
388
+ const record = {
389
+ target,
390
+ sample: undefined,
391
+ dirty: false,
392
+ previousThresholdIndex: -1,
393
+ previousIsIntersecting: false,
394
+ stop: () => { },
395
+ };
396
+ this.#records.set(target, record);
397
+ if (this.root && !this.#stopWatchingRoot) {
398
+ // The root moving or resizing changes what the targets intersect, and
399
+ // nothing else tells us: a target that does not move reports nothing.
400
+ this.#stopWatchingRoot = listen(INTERSECT_OBSERVE_EVENT, this.root, {
401
+ receive: (event) => {
402
+ const observation = event.observation;
403
+ this.#rootBox = observation.present
404
+ ? clientBox({ x: event.x ?? 0, y: event.y ?? 0, width: event.width ?? 0, height: event.height ?? 0 }, observation)
405
+ : NO_BOX;
406
+ this.#markAllDirty();
407
+ },
408
+ settled: (_, painted) => {
409
+ if (painted || this.#rootBox)
410
+ return;
411
+ this.#rootBox = NO_BOX;
412
+ this.#markAllDirty();
413
+ },
414
+ });
415
+ }
416
+ record.stop = listen(INTERSECT_OBSERVE_EVENT, target, {
417
+ receive: (event) => this.#receive(record, event),
418
+ bound: (binding) => {
419
+ this.#renderer = binding.renderer;
420
+ },
421
+ settled: (binding, painted) => {
422
+ // An element that does not paint sends no report, but the DOM still
423
+ // reports it once, as not intersecting.
424
+ if (!painted && record.sample === undefined) {
425
+ record.sample = absentSample(binding.renderer.getWindowSize?.());
426
+ this.#markDirty(record);
427
+ }
428
+ },
429
+ });
430
+ }
431
+ unobserve(target) {
432
+ this.#records.get(target)?.stop();
433
+ this.#records.delete(target);
434
+ this.#queue = this.#queue.filter((entry) => entry.target !== target);
435
+ if (this.#records.size === 0)
436
+ this.#stopRoot();
437
+ }
438
+ disconnect() {
439
+ for (const record of this.#records.values())
440
+ record.stop();
441
+ this.#records.clear();
442
+ this.#queue = [];
443
+ this.#stopRoot();
444
+ }
445
+ /** Entries not yet delivered, removed from the queue. */
446
+ takeRecords() {
447
+ // In the order the targets were observed, not the order the frame reported them in. The sort
448
+ // is stable, so the entries of one target stay in the order they arose.
449
+ const order = new Map([...this.#records.keys()].map((target, index) => [target, index]));
450
+ const entries = this.#queue.sort((a, b) => order.get(a.target) - order.get(b.target));
451
+ this.#queue = [];
452
+ return entries;
453
+ }
454
+ #stopRoot() {
455
+ this.#stopWatchingRoot?.();
456
+ this.#stopWatchingRoot = undefined;
457
+ this.#rootBox = undefined;
458
+ }
459
+ #receive(record, event) {
460
+ const observation = event.observation;
461
+ const sample = observation.present
462
+ ? {
463
+ present: true,
464
+ border: {
465
+ x: event.x ?? 0,
466
+ y: event.y ?? 0,
467
+ width: event.width ?? 0,
468
+ height: event.height ?? 0,
469
+ },
470
+ clips: observation.clips.map((clip) => ({
471
+ id: clip.id,
472
+ rect: { x: clip.x, y: clip.y, width: clip.width, height: clip.height },
473
+ })),
474
+ viewport: { width: observation.viewportWidth, height: observation.viewportHeight },
475
+ }
476
+ : absentSample(record.sample?.viewport);
477
+ record.sample = sample;
478
+ this.#markDirty(record);
479
+ }
480
+ #markDirty(record) {
481
+ record.dirty = true;
482
+ queueEvaluation(this.#renderer, this.#evaluation);
483
+ }
484
+ #markAllDirty() {
485
+ for (const record of this.#records.values()) {
486
+ if (record.sample)
487
+ this.#markDirty(record);
488
+ }
489
+ }
490
+ #evaluateDirty() {
491
+ for (const record of this.#records.values()) {
492
+ if (!record.dirty)
493
+ continue;
494
+ record.dirty = false;
495
+ this.#evaluate(record);
496
+ }
497
+ }
498
+ #rootRect(sample) {
499
+ let base;
500
+ if (this.root) {
501
+ base = this.root[HOST_BINDING]() ? this.#rootBox : NO_BOX;
502
+ }
503
+ else {
504
+ base = { x: 0, y: 0, width: sample.viewport.width, height: sample.viewport.height };
505
+ }
506
+ const [top, right, bottom, left] = this.#margin.map((length, index) => length.percent ? (length.value / 100) * (index % 2 === 0 ? base.height : base.width) : length.value);
507
+ return {
508
+ x: base.x - left,
509
+ y: base.y - top,
510
+ width: base.width + left + right,
511
+ height: base.height + top + bottom,
512
+ };
513
+ }
514
+ #evaluate(record) {
515
+ const sample = record.sample;
516
+ // The root's report re-evaluates every record.
517
+ if (sample.present && this.root && this.root[HOST_BINDING]() && !this.#rootBox)
518
+ return;
519
+ // A target with no box (in skipped content, removed) has no root bounds either.
520
+ const rootBounds = sample.present ? this.#rootRect(sample) : NO_BOX;
521
+ let intersection = NO_BOX;
522
+ let intersects = false;
523
+ const border = sample.present ? sample.border : NO_BOX;
524
+ if (sample.present) {
525
+ // Clip by the ancestors between the target and the root, like the DOM.
526
+ // Ancestors above the root, and the window edge, do not clip.
527
+ let clipped = border;
528
+ for (const clip of sample.clips) {
529
+ if (this.root && clip.id === this.root.id)
530
+ break;
531
+ clipped = overlap(clipped, clip.rect);
532
+ }
533
+ intersection = overlap(clipped, rootBounds);
534
+ intersects = area(intersection) > 0 || (area(border) === 0 && contains(rootBounds, border));
535
+ if (area(intersection) === 0 && !intersects)
536
+ intersection = NO_BOX;
537
+ }
538
+ const ratio = !intersects ? 0 : area(border) === 0 ? 1 : Math.min(1, area(intersection) / area(border));
539
+ let thresholdIndex = this.thresholds.findIndex((threshold) => threshold > ratio);
540
+ if (thresholdIndex < 0)
541
+ thresholdIndex = this.thresholds.length;
542
+ // Chrome reports an intersection that is under the first threshold as not intersecting (with its
543
+ // ratio), which is what makes `threshold: 0.5` mean "half of it shows" to a caller that reads
544
+ // `isIntersecting`, as Framer's `whileInView` does.
545
+ const isIntersecting = intersects && thresholdIndex > 0;
546
+ if (thresholdIndex === record.previousThresholdIndex &&
547
+ isIntersecting === record.previousIsIntersecting) {
548
+ return;
549
+ }
550
+ record.previousThresholdIndex = thresholdIndex;
551
+ record.previousIsIntersecting = isIntersecting;
552
+ this.#queue.push({
553
+ time: performance.now(),
554
+ rootBounds: asBoundingClientRect(rootBounds),
555
+ boundingClientRect: asBoundingClientRect(border),
556
+ intersectionRect: asBoundingClientRect(intersection),
557
+ isIntersecting,
558
+ intersectionRatio: ratio,
559
+ target: record.target,
560
+ });
561
+ queueDelivery(this.#renderer, this.#delivery);
562
+ }
563
+ #deliver() {
564
+ const entries = this.takeRecords();
565
+ if (entries.length === 0)
566
+ return;
567
+ try {
568
+ this.#callback.call(this, entries, this);
569
+ }
570
+ catch (error) {
571
+ reportCallbackError(error);
572
+ }
573
+ }
574
+ }
575
+ function absentSample(viewport = { width: 0, height: 0 }) {
576
+ const zero = { x: 0, y: 0, width: 0, height: 0 };
577
+ return { present: false, border: zero, clips: [], viewport };
578
+ }
579
+ //# sourceMappingURL=observers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observers.js","sourceRoot":"","sources":["../js/observers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,oBAAoB,GAIrB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAA;AACnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAIzD,MAAM,OAAO,GAAG,IAAI,CAAA;AA6CpB,MAAM,eAAe,GAAG,CAAC,CAAA;AACzB,MAAM,qBAAqB,GAAG,CAAC,CAAA;AAE/B,+GAA+G;AAC/G,IAAI,gBAAgB,GAAG,CAAC,CAAA;AAkBxB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAEzD,SAAS,MAAM,CAAC,QAAgB;IAC9B,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAqC,CAAA;IAChF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,OAAO,EAAE,CAAA;QACpB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,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Aa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IAC/C,CAAC;IAED,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;QAClC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QAChC,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;CACF;AAED,SAAS,YAAY,CAAC,QAAQ,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;IACtD,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;IAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { ElementBounds } from "../index.js";
2
+ /**
3
+ * `"sync"`: entering and exiting children animate together. `"wait"`: a
4
+ * child that enters while another is leaving renders only after every exit is
5
+ * done. `"popLayout"`: a leaving child is taken out of flow, at the box it
6
+ * last had inside its parent, so its siblings reflow at once.
7
+ */
8
+ export type PresenceMode = "sync" | "wait" | "popLayout";
9
+ /**
10
+ * An `exit` target, or a function that returns one from the `custom` value of
11
+ * the `AnimatePresence` the child is leaving. Framer resolves `exit` the same
12
+ * way from its variants.
13
+ */
14
+ export type ExitTarget<Style extends object> = Style | {
15
+ exit(custom: unknown): Style;
16
+ }["exit"];
17
+ export declare function resolveExit<Style extends object>(exit: ExitTarget<Style> | undefined, custom: unknown): Style | undefined;
18
+ /** Swaps a motion prop type's `exit` for an `ExitTarget` and adds `custom`. */
19
+ export type WithExitFunction<Props extends {
20
+ exit?: object;
21
+ }> = Omit<Props, "exit"> & {
22
+ exit?: ExitTarget<NonNullable<Props["exit"]>>;
23
+ /** Handed to an `exit` function when this child leaves; the `custom` of the `AnimatePresence` wins. */
24
+ custom?: unknown;
25
+ };
26
+ export type PopLayoutStyle = {
27
+ position: "absolute";
28
+ top: number;
29
+ left: number;
30
+ width: number;
31
+ height: number;
32
+ margin: 0;
33
+ marginTop: 0;
34
+ marginRight: 0;
35
+ marginBottom: 0;
36
+ marginLeft: 0;
37
+ };
38
+ /** What `popLayoutStyle` needs to know of the parent: its box and how far its content is scrolled. */
39
+ export type PopLayoutParent = {
40
+ bounds: ElementBounds;
41
+ scrollLeft: number;
42
+ scrollTop: number;
43
+ };
44
+ /**
45
+ * The style that paints `child` exactly where it painted before it left the
46
+ * flow. An absolute box is placed from the parent's padding box (inside its
47
+ * border), moves with the parent's scrolled content, and sits `margin` away
48
+ * from its offsets, so the margin is zeroed rather than counted twice.
49
+ * `parent` is `undefined` for a child of the window root, which sits at the
50
+ * window origin.
51
+ */
52
+ export declare function popLayoutStyle(child: ElementBounds, parent: PopLayoutParent | undefined): PopLayoutStyle;
53
+ type BoundsHost = {
54
+ getElementBounds?: (elementId: number) => ElementBounds | null;
55
+ getScrollMetrics?: (elementId: number) => Array<number> | null;
56
+ };
57
+ /**
58
+ * The style that keeps an element where it last painted, or `undefined` when
59
+ * it has not painted (nothing to hold in place).
60
+ */
61
+ export declare function measurePopLayout(renderer: BoundsHost, childId: number, parentId: number | undefined): PopLayoutStyle | undefined;
62
+ export {};
63
+ //# sourceMappingURL=presence.d.ts.map