@the-w1zard/the-cloud 1.0.2 → 1.0.4

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 (43) hide show
  1. package/dist/index.js +25850 -8
  2. package/package.json +12 -4
  3. package/dist/hooks/callback.d.ts +0 -1
  4. package/dist/hooks/callback.js +0 -13
  5. package/dist/hooks/compose-event-handlers.d.ts +0 -10
  6. package/dist/hooks/compose-event-handlers.js +0 -10
  7. package/dist/hooks/core/index.d.ts +0 -1
  8. package/dist/hooks/core/index.js +0 -1
  9. package/dist/hooks/core/use-id.d.ts +0 -1
  10. package/dist/hooks/core/use-id.js +0 -4
  11. package/dist/hooks/core/use-reducer.d.ts +0 -1
  12. package/dist/hooks/core/use-reducer.js +0 -14
  13. package/dist/hooks/core/use-ref.d.ts +0 -92
  14. package/dist/hooks/core/use-ref.js +0 -559
  15. package/dist/hooks/core/use-state2.d.ts +0 -1
  16. package/dist/hooks/core/use-state2.js +0 -15
  17. package/dist/hooks/deferred_value.d.ts +0 -1
  18. package/dist/hooks/deferred_value.js +0 -12
  19. package/dist/hooks/effect.d.ts +0 -1
  20. package/dist/hooks/effect.js +0 -37
  21. package/dist/hooks/hooks.d.ts +0 -1
  22. package/dist/hooks/hooks.js +0 -1
  23. package/dist/hooks/impertaive_handle.d.ts +0 -3
  24. package/dist/hooks/impertaive_handle.js +0 -24
  25. package/dist/hooks/index.d.ts +0 -1
  26. package/dist/hooks/index.js +0 -4
  27. package/dist/hooks/init_hooks.d.ts +0 -285
  28. package/dist/hooks/init_hooks.js +0 -285
  29. package/dist/hooks/lazy.d.ts +0 -3
  30. package/dist/hooks/lazy.js +0 -15
  31. package/dist/hooks/memo.d.ts +0 -2
  32. package/dist/hooks/memo.js +0 -44
  33. package/dist/hooks/rect.d.ts +0 -24
  34. package/dist/hooks/rect.js +0 -77
  35. package/dist/hooks/state.d.ts +0 -1
  36. package/dist/hooks/state.js +0 -34
  37. package/dist/hooks/suspense.d.ts +0 -4
  38. package/dist/hooks/suspense.js +0 -10
  39. package/dist/hooks/types.d.ts +0 -25
  40. package/dist/hooks/types.js +0 -1
  41. package/dist/index.d.ts +0 -8
  42. package/dist/the-cloud.d.ts +0 -406
  43. package/dist/the-cloud.js +0 -1386
@@ -1,559 +0,0 @@
1
- import { createHook, } from '#the-cloud';
2
- import { useEffect, useCallback, } from '#sauron'; // useSignal,
3
- import * as React from "#sauron";
4
- export function useRef(initialValue, __sauron_id__ = _sid()) {
5
- return createHook('useRef', __sauron_id__, () => {
6
- const subscribers = new Set();
7
- let current = (initialValue ?? null);
8
- let isAttached = false;
9
- const notify = () => { subscribers.forEach(fn => fn(current)); };
10
- return { value: { current, isAttached, subscribers, notify } };
11
- }, (hook) => {
12
- const state = hook.value;
13
- const get = () => state.current;
14
- const set = (value) => {
15
- state.current = value;
16
- state.isAttached = value !== null;
17
- state.notify();
18
- };
19
- const subscribe = (callback) => {
20
- state.subscribers.add(callback);
21
- callback(state.current);
22
- return () => {
23
- state.subscribers.delete(callback);
24
- };
25
- };
26
- const waitForAttach = (timeout) => {
27
- return new Promise((resolve, reject) => {
28
- if (state.isAttached && state.current !== null) {
29
- return resolve(state.current);
30
- }
31
- const timeoutId = timeout
32
- ? setTimeout(() => reject(new Error('Ref attach timeout')), timeout)
33
- : null;
34
- const unsubscribe = subscribe((value) => {
35
- if (value !== null) {
36
- if (timeoutId)
37
- clearTimeout(timeoutId);
38
- unsubscribe();
39
- resolve(value);
40
- }
41
- });
42
- });
43
- };
44
- const toReact = () => ({
45
- get current() { return state.current; },
46
- set current(value) { set(value); }
47
- });
48
- const toCallback = () => (instance) => {
49
- set(instance);
50
- };
51
- return {
52
- current: state.current,
53
- get,
54
- set,
55
- subscribe,
56
- isAttached: state.isAttached,
57
- waitForAttach,
58
- toReact,
59
- toCallback
60
- };
61
- });
62
- }
63
- export function useComposedRefs(...refs) {
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
- return useCallback(composeRefs(...refs), refs);
66
- }
67
- function setRef(ref, value) {
68
- if (ref !== undefined) {
69
- ref.set(value);
70
- }
71
- }
72
- export function composeRefs1(...refs) {
73
- return (instance) => {
74
- refs.forEach(ref => {
75
- if (!ref)
76
- return;
77
- if (typeof ref === 'function') {
78
- ref(instance);
79
- }
80
- else if ('set' in ref) {
81
- ref.set(instance);
82
- }
83
- else if ('current' in ref) {
84
- ref.current = instance;
85
- }
86
- });
87
- };
88
- }
89
- export function composeRefs(...refs) {
90
- return (node) => {
91
- let hasCleanup = false;
92
- const cleanups = refs.map((ref) => {
93
- const cleanup = setRef(ref, node);
94
- if (!hasCleanup && typeof cleanup === 'function') {
95
- hasCleanup = true;
96
- }
97
- return cleanup;
98
- });
99
- // React <19 will log an error to the console if a callback ref returns a
100
- // value. We don't use ref cleanups internally so this will only happen if a
101
- // user's ref callback returns a value, which we only expect if they are
102
- // using the cleanup functionality added in React 19.
103
- if (hasCleanup) {
104
- return () => {
105
- for (let i = 0; i < cleanups.length; i++) {
106
- const cleanup = cleanups[i];
107
- if (typeof cleanup == 'function') {
108
- cleanup();
109
- }
110
- /**else {
111
- setRef(refs[i], null);
112
- } */
113
- }
114
- };
115
- }
116
- };
117
- }
118
- export function createRefForwarder(render, options = {}) {
119
- return function RefForwardedComponent(props) {
120
- const { ref: externalRef, ...rest } = props;
121
- const internalRef = useRef();
122
- if (options.validate) {
123
- internalRef.subscribe((value) => {
124
- if (value && !options.validate(value)) {
125
- console.warn('Ref validation failed:', value);
126
- }
127
- });
128
- }
129
- if (options.transform) {
130
- internalRef.subscribe((value) => {
131
- if (value) {
132
- options.transform(value);
133
- }
134
- });
135
- }
136
- const composedRef = (instance) => {
137
- internalRef.set(instance);
138
- if (typeof externalRef === 'function') {
139
- externalRef(instance);
140
- }
141
- else if (externalRef && 'set' in externalRef) {
142
- externalRef.set(instance);
143
- }
144
- else if (externalRef && 'current' in externalRef) {
145
- externalRef.current = instance;
146
- }
147
- };
148
- return render(rest, { ...internalRef, set: composedRef });
149
- };
150
- }
151
- export function useDomRef() {
152
- const ref = useRef();
153
- const measure = () => {
154
- if (!ref.current)
155
- return null;
156
- return {
157
- width: ref.current.offsetWidth,
158
- height: ref.current.offsetHeight,
159
- top: ref.current.offsetTop,
160
- left: ref.current.offsetLeft,
161
- bottom: ref.current.offsetTop + ref.current.offsetHeight,
162
- right: ref.current.offsetLeft + ref.current.offsetWidth,
163
- scrollWidth: ref.current.scrollWidth,
164
- scrollHeight: ref.current.scrollHeight,
165
- scrollTop: ref.current.scrollTop,
166
- scrollLeft: ref.current.scrollLeft
167
- };
168
- };
169
- const focus = (options) => ref.current?.focus(options);
170
- const blur = () => ref.current?.blur();
171
- const click = () => ref.current?.click();
172
- const scrollIntoView = (options) => ref.current?.scrollIntoView(options);
173
- return {
174
- ...ref,
175
- measure,
176
- focus,
177
- blur,
178
- click,
179
- scrollIntoView,
180
- useMeasure: () => {
181
- // const sig = useSignal(measure());
182
- //ref.subscribe(() => { sig.value = measure(); });
183
- //return sig;
184
- }
185
- };
186
- }
187
- export function forwardRef(render) {
188
- const component = (props) => {
189
- const { ref: externalRef, ...rest } = props;
190
- const internalRef = useRef();
191
- const composedRef = (instance) => {
192
- internalRef.set(instance);
193
- if (typeof externalRef === 'function')
194
- externalRef(instance);
195
- else if (externalRef && 'current' in externalRef)
196
- externalRef.current = instance;
197
- else if (externalRef && 'set' in externalRef)
198
- externalRef.set(instance);
199
- };
200
- return render(rest, composedRef);
201
- };
202
- return component;
203
- }
204
- export function mergeAnyRefs(...refs) {
205
- return (instance) => {
206
- refs.forEach(ref => {
207
- if (!ref)
208
- return;
209
- if ('set' in ref && typeof ref.set === 'function')
210
- ref.set(instance);
211
- else if (typeof ref === 'function')
212
- ref(instance);
213
- else if ('current' in ref)
214
- ref.current = instance;
215
- });
216
- };
217
- }
218
- export function useReactRef(ref) {
219
- const internalRef = useRef();
220
- if (ref) {
221
- if (typeof ref === 'function') {
222
- internalRef.subscribe((value) => ref(value));
223
- }
224
- else if (ref && 'current' in ref) {
225
- internalRef.subscribe((value) => { ref.current = value; });
226
- }
227
- }
228
- return internalRef;
229
- }
230
- export function toReactRef(handle) {
231
- return {
232
- get current() { return handle.get(); },
233
- set current(value) { handle.set(value); }
234
- };
235
- }
236
- export function mergeForwardRefs(...refs) {
237
- return (instance) => {
238
- refs.forEach(ref => {
239
- if (typeof ref === 'function') {
240
- ref(instance);
241
- }
242
- else if (ref && 'current' in ref) {
243
- ref.current = instance;
244
- }
245
- });
246
- };
247
- }
248
- export function useForwardedRef(forwardedRef) {
249
- // Create internal ref
250
- const internalRef = useRef(undefined);
251
- useEffect(() => {
252
- // Update forwarded ref whenever internal ref changes
253
- if (!forwardedRef)
254
- return;
255
- if (typeof forwardedRef === 'function') {
256
- forwardedRef(internalRef.current);
257
- }
258
- else if (forwardedRef && 'current' in forwardedRef) {
259
- forwardedRef.current = internalRef.current;
260
- }
261
- }, []);
262
- return internalRef;
263
- }
264
- export function createForwardRef() {
265
- return { current: null };
266
- }
267
- export function isForwardRefObject(ref) {
268
- return ref && typeof ref === 'object' && 'current' in ref;
269
- }
270
- export function isForwardRefCallback(ref) {
271
- return typeof ref === 'function';
272
- }
273
- /** REF V2
274
-
275
- export function useRef2<T = any>(initial?: T, __sauron_id__ = _sid()): RefHandle<T> {
276
- return createHook(
277
- 'useRef',
278
- __sauron_id__,
279
- (): RefHookState<T> => ({
280
- value: initial ?? null,
281
- isAttached: false,
282
- subscribers: new Set<(value: T) => void>()
283
- }),
284
- (state) => {
285
- const hook = state as RefHookState<T>
286
-
287
- const get = (): T => hook.value
288
- const set = (value: T) => {
289
- hook.value = value
290
- hook.isAttached = value !== null
291
- hook.subscribers.forEach(fn => fn(value))
292
- }
293
- const subscribe = (cb: (value: T) => void) => {
294
- hook.subscribers.add(cb)
295
- cb(hook.value)
296
- return () => hook.subscribers.delete(cb)
297
- }
298
- const waitForAttach = (timeout?: number): Promise<T> =>
299
- new Promise((resolve, reject) => {
300
- if (hook.isAttached && hook.value !== null) return resolve(hook.value)
301
- const tid = timeout ? setTimeout(() => reject(new Error('Ref attach timeout')), timeout) : null
302
- const unsub = subscribe((v) => {
303
- if (v !== null) {
304
- if (tid) clearTimeout(tid)
305
- unsub()
306
- resolve(v)
307
- }
308
- })
309
- })
310
- const toReact = (): MutableRefObject<T> => ({
311
- get current() { return hook.value },
312
- set current(v) { set(v) }
313
- })
314
- const toCallback = (): RefCallback<T> => (v) => set(v)
315
-
316
- return {
317
- get current() { return hook.value },
318
- set current(v) { set(v) },
319
- get isAttached() { return hook.isAttached },
320
- get, set, subscribe, waitForAttach, toReact, toCallback
321
- }
322
- }
323
- )
324
- }
325
- export function mergeAnyRefs2<T = any>(...refs: Array<AnyRef<T> | undefined>): RefCallback<T> {
326
- return (instance: T) => {
327
- refs.forEach(ref => {
328
- if (!ref) return
329
- if ('set' in ref && typeof (ref as any).set === 'function') (ref as RefHandle<T>).set(instance)
330
- else if (typeof ref === 'function') ref(instance)
331
- else if ('current' in ref) (ref as any).current = instance
332
- })
333
- }
334
- }
335
- export function forwardRef2<T = any, P = {}>(
336
- render: (props: P, ref: ForwardedRef<T>) => any
337
- ): ((props: P & { ref?: ForwardedRef<T> }) => any) & { displayName?: string } {
338
- const component = (props: P & { ref?: ForwardedRef<T> }) => {
339
- const { ref: externalRef, ...rest } = props as any
340
- const internalRef = useRef<T>()
341
- const composedRef = (instance: T) => {
342
- internalRef.set(instance)
343
- if (typeof externalRef === 'function') externalRef(instance)
344
- else if (externalRef && 'current' in externalRef) externalRef.current = instance
345
- else if (externalRef && 'set' in externalRef) externalRef.set(instance)
346
- }
347
- return render(rest as P, composedRef)
348
- }
349
- return component
350
- }
351
- export function useDomRef2<T extends HTMLElement = HTMLElement>(__sauron_id__ = _sid()) {
352
- const ref = useRef<T>(null, __sauron_id__)
353
- return {
354
- ...ref,
355
- measure: () => {
356
- if (!ref.current) return null
357
- return {
358
- width: ref.current.offsetWidth,
359
- height: ref.current.offsetHeight,
360
- top: ref.current.offsetTop,
361
- left: ref.current.offsetLeft,
362
- bottom: ref.current.offsetTop + ref.current.offsetHeight,
363
- right: ref.current.offsetLeft + ref.current.offsetWidth,
364
- scrollWidth: ref.current.scrollWidth,
365
- scrollHeight: ref.current.scrollHeight,
366
- scrollTop: ref.current.scrollTop,
367
- scrollLeft: ref.current.scrollLeft
368
- }
369
- },
370
- focus: (options?: FocusOptions) => ref.current?.focus(options),
371
- blur: () => ref.current?.blur(),
372
- click: () => ref.current?.click(),
373
- scrollIntoView: (options?: ScrollIntoViewOptions) => ref.current?.scrollIntoView(options)
374
- }
375
- }
376
- export function useReactRef2<T = any>(ref: ForwardedRef<T>): RefHandle<T> {
377
- const internalRef = useRef<T>()
378
- if (ref) {
379
- if (typeof ref === 'function') {
380
- internalRef.subscribe((value) => ref(value))
381
- } else if (ref && 'current' in ref) {
382
- internalRef.subscribe((value) => { ref.current = value })
383
- }
384
- }
385
- return internalRef
386
- }
387
- interface RefHandle2<T = any> {
388
- current: T
389
- get: () => T
390
- set: (value: T) => void
391
- subscribe: (callback: (value: T) => void) => () => void
392
- isAttached: boolean
393
- waitForAttach: (timeout?: number) => Promise<T>
394
- toReact: () => MutableRefObject<T>
395
- toCallback: () => RefCallback<T>
396
- }
397
- interface RefForwardingOptions2 {
398
- autoAttach?: boolean
399
- validate?: (target: any) => boolean
400
- transform?: <T, R>(value: T) => R
401
- }
402
-
403
- export function createRefForwarder2<T = any, P = {}>(
404
- render: (props: P, ref: RefHandle2<T>) => any,
405
- options: RefForwardingOptions2 = {}
406
- ): (props: P & { ref?: RefHandle2<T> | ((instance: T) => void) | { current: T } }) => any {
407
- return function RefForwardedComponent(props) {
408
- const { ref: externalRef, ...rest } = props as any
409
- const internalRef = useRef<T>()
410
-
411
- if (options.validate) {
412
- internalRef.subscribe((value) => {
413
- if (value && !options.validate!(value)) {
414
- console.warn('Ref validation failed:', value)
415
- }
416
- })
417
- }
418
-
419
- if (options.transform) {
420
- internalRef.subscribe((value) => {
421
- if (value) options.transform!(value)
422
- })
423
- }
424
-
425
- const composedRef = (instance: T) => {
426
- internalRef.set(instance)
427
- if (typeof externalRef === 'function') externalRef(instance)
428
- else if (externalRef && 'set' in externalRef) externalRef.set(instance)
429
- else if (externalRef && 'current' in externalRef) externalRef.current = instance
430
- }
431
-
432
- // Fix: Pass both props AND the ref handle to render
433
- return render({ ...rest, ref: { ...internalRef, set: composedRef } } as P, internalRef as RefHandle2<T>)
434
- }
435
- }
436
- export function toReactRef2<T = any>(handle: RefHandle<T>): MutableRefObject<T> {
437
- return {
438
- get current() { return handle.get() },
439
- set current(value: T) { handle.set(value) }
440
- }
441
- }
442
- export function mergeForwardRefs2<T = any>(
443
- ...refs: (FowardRef<T> | undefined)[]
444
- ): (instance: T) => void {
445
- return (instance: T) => {
446
- refs.forEach(ref => {
447
- if (typeof ref === 'function') {
448
- ref(instance);
449
- } else if (ref && 'current' in ref) {
450
- (ref as { current: T }).current = instance;
451
- }
452
- });
453
- };
454
- }
455
- export function useForwardedRef2<T = any>(forwardedRef: FowardRef<T>): { current: T } {
456
- // Create internal ref
457
- const internalRef = useRef<T>(null);
458
-
459
- useEffect(() => {
460
- // Update forwarded ref whenever internal ref changes
461
- if (!forwardedRef) return;
462
-
463
- if (typeof forwardedRef === 'function') {
464
- forwardedRef(internalRef.current);
465
- } else if (forwardedRef && 'current' in forwardedRef) {
466
- (forwardedRef as { current: T }).current = internalRef.current;
467
- }
468
- }, []);
469
-
470
- return internalRef;
471
- }
472
- export function createForwardRef2<T = any>(): { current: T } {
473
- return { current: null };
474
- }
475
- export function isForwardRefObject2(ref: any): ref is { current: any } {
476
- return ref && typeof ref === 'object' && 'current' in ref;
477
- }
478
- export function isForwardRefCallback2(ref: any): ref is (instance: any) => void {
479
- return typeof ref === 'function';
480
- } */
481
- // Example implementation of how your renderer would handle forwardRef
482
- /*
483
- // In your renderer:
484
- import { FWD_REF_SYMBOL } from '#sauron/forward-ref';
485
-
486
- function renderElement(vnode) {
487
- if (vnode && vnode.$$typeof === FWD_REF_SYMBOL) {
488
- const { __forwardRefRender, ...props } = vnode;
489
-
490
- // Create a ref callback that will be passed to the render function
491
- let currentRef = null;
492
- const refHandler = (instance) => {
493
- currentRef = instance;
494
-
495
- // If props.ref exists, also set that
496
- if (props.ref) {
497
- if (typeof props.ref === 'function') {
498
- props.ref(instance);
499
- } else if (props.ref && 'current' in props.ref) {
500
- props.ref.current = instance;
501
- }
502
- }
503
- };
504
-
505
- // Call the render function with props and the ref handler
506
- return __forwardRefRender(props, refHandler);
507
- }
508
-
509
- // Handle regular elements
510
- if (typeof vnode === 'object' && vnode !== null && 'ref' in vnode) {
511
- const { ref, ...props } = vnode;
512
- // Store ref to be applied to DOM element
513
- return createElement(vnode.type, { ...props, __ref: ref });
514
- }
515
-
516
- // ... rest of rendering logic
517
- }
518
- */
519
- // Example usage with your component:
520
- /*
521
- import { forwardRef, useForwardedRef } from '#sauron/forward-ref';
522
-
523
- interface ButtonProps {
524
- onClick?: () => void;
525
- children?: any;
526
- className?: string;
527
- }
528
-
529
- const Button = forwardRef<HTMLButtonElement, ButtonProps>(
530
- ({ children, ...props }, ref) => {
531
- const buttonRef = useForwardedRef(ref);
532
-
533
- return (
534
- <button
535
- {...props}
536
- ref={buttonRef}
537
- className={`px-4 py-2 bg-blue-500 text-white rounded ${props.className || ''}`}
538
- >
539
- {children}
540
- </button>
541
- );
542
- }
543
- );
544
-
545
- // In a component:
546
- function Form() {
547
- const submitButtonRef = createForwardRef<HTMLButtonElement>();
548
-
549
- return (
550
- <form>
551
- <Button ref={submitButtonRef} onClick={() => console.log('submitted')}>
552
- Submit
553
- </Button>
554
- </form>
555
- );
556
- }
557
- */
558
- const _UNDEFINED_VOID_ONLY = Symbol();
559
- export const UNDEFINED_VOID_ONLY = _UNDEFINED_VOID_ONLY;
@@ -1 +0,0 @@
1
- export declare function useState2<T>(initial?: T | (() => T), __sauron_id__?: string): [T, (v: T | ((prev: T) => T)) => void];
@@ -1,15 +0,0 @@
1
- import { createHook, getCurrentComponent, subscribeToHook, notifyHook } from '#the-cloud';
2
- export function useState2(initial, __sauron_id__ = _sid()) {
3
- return createHook('useState', __sauron_id__, () => ({ value: typeof initial === 'function' ? initial() : initial }), (state, key, notify) => {
4
- const setValue = (v) => {
5
- const next = typeof v === 'function' ? v(state.value) : v;
6
- console.log(`[USESTATE][SETVALUE][KEY]${key}[NEXT]${next}[SAME]${next === state.value}`);
7
- if (Object.is(state.value, next))
8
- return;
9
- state.value = next;
10
- notify(key);
11
- return next;
12
- };
13
- return [state.value, setValue];
14
- });
15
- }
@@ -1 +0,0 @@
1
- export declare function useDeferredValue<T>(value: T, __sauron_id__?: string): T;
@@ -1,12 +0,0 @@
1
- import { createHook } from "#tc";
2
- export function useDeferredValue(value, __sauron_id__ = _sid()) {
3
- return createHook('useDeferredValue', __sauron_id__, () => ({ value }), (state, key, notify) => {
4
- if (!Object.is(state.value, value)) {
5
- queueMicrotask(() => {
6
- state.value = value;
7
- notify(key);
8
- });
9
- }
10
- return state.value;
11
- });
12
- }
@@ -1 +0,0 @@
1
- export declare function useEffect(effect: (signal?: AbortSignal) => void | (() => void), deps?: A[], __sauron_id__?: string): void;
@@ -1,37 +0,0 @@
1
- export function useEffect(effect, deps, __sauron_id__ = _sid()) {
2
- createHook('useEffect', __sauron_id__, () => {
3
- const controller = new AbortController();
4
- const cleanup = effect(controller.signal);
5
- return {
6
- value: undefined,
7
- deps: deps ?? [],
8
- cleanup: () => {
9
- controller.abort();
10
- if (typeof cleanup === 'function')
11
- cleanup();
12
- }
13
- };
14
- }, (state) => {
15
- if (deps === undefined || !_depsEqual(state.deps ?? [], deps)) {
16
- state.cleanup?.();
17
- const controller = new AbortController();
18
- const cleanup = effect(controller.signal);
19
- state.deps = deps ?? [];
20
- state.cleanup = () => {
21
- controller.abort();
22
- if (typeof cleanup === 'function')
23
- cleanup();
24
- };
25
- }
26
- return undefined;
27
- });
28
- }
29
- function _depsEqual(a, b) {
30
- if (a.length !== b.length)
31
- return false;
32
- for (let i = 0; i < a.length; i++) {
33
- if (!Object.is(a[i], b[i]))
34
- return false;
35
- }
36
- return true;
37
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export declare function useImperativeHandle<T>(ref: {
2
- current: T | null;
3
- }, init: () => T, deps?: A[], __sauron_id__?: string): void;
@@ -1,24 +0,0 @@
1
- import { createHook } from "#tc";
2
- function _depsEqual(a, b) {
3
- if (a.length !== b.length)
4
- return false;
5
- for (let i = 0; i < a.length; i++) {
6
- if (!Object.is(a[i], b[i]))
7
- return false;
8
- }
9
- return true;
10
- }
11
- export function useImperativeHandle(ref, init, deps, __sauron_id__ = _sid()) {
12
- createHook('useImperativeHandle', __sauron_id__, () => {
13
- if (ref)
14
- ref.current = init();
15
- return { value: undefined, deps: deps ?? [] };
16
- }, (state) => {
17
- if (deps === undefined || !_depsEqual(state.deps ?? [], deps)) {
18
- if (ref)
19
- ref.current = init();
20
- state.deps = deps ?? [];
21
- }
22
- return undefined;
23
- });
24
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- // Auto-generated index file
2
- // DO NOT EDIT MANUALLY
3
- export {};
4
- // hooks/ui-interactions/index.ts