cogsbox-sync 0.0.1

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.
@@ -0,0 +1,903 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as zustand from 'zustand';
3
+ import { ReactNode } from 'react';
4
+ import z$1, { z } from 'zod';
5
+ import * as cogsbox_state from 'cogsbox-state';
6
+
7
+ type UpdateTypeDetail = {
8
+ timeStamp: number;
9
+ stateKey: string;
10
+ updateType: "update" | "insert" | "cut" | "insert_many";
11
+ path: string[];
12
+ status: "new" | "sent" | "synced";
13
+ oldValue: any;
14
+ newValue: any;
15
+ userId?: number;
16
+ itemId?: string;
17
+ insertAfterId?: string;
18
+ validation?: any[];
19
+ version?: string;
20
+ metaData?: Record<string, any>;
21
+ };
22
+ declare const clientActivitySchema: z.ZodIntersection<z.ZodObject<{
23
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
24
+ timestamp: z.ZodNumber;
25
+ duration: z.ZodOptional<z.ZodNumber>;
26
+ }, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
27
+ activityType: z.ZodLiteral<"focus">;
28
+ details: z.ZodObject<{
29
+ cursorPosition: z.ZodOptional<z.ZodNumber>;
30
+ }, z.core.$strip>;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ activityType: z.ZodLiteral<"blur">;
33
+ details: z.ZodObject<{
34
+ duration: z.ZodNumber;
35
+ }, z.core.$strip>;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ activityType: z.ZodLiteral<"input">;
38
+ details: z.ZodObject<{
39
+ value: z.ZodAny;
40
+ inputLength: z.ZodOptional<z.ZodNumber>;
41
+ isComposing: z.ZodOptional<z.ZodBoolean>;
42
+ isPasting: z.ZodOptional<z.ZodBoolean>;
43
+ keystrokeCount: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>, z.ZodObject<{
46
+ activityType: z.ZodLiteral<"select">;
47
+ details: z.ZodObject<{
48
+ selectionStart: z.ZodNumber;
49
+ selectionEnd: z.ZodNumber;
50
+ selectedText: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ }, z.core.$strip>, z.ZodObject<{
53
+ activityType: z.ZodLiteral<"hover_enter">;
54
+ details: z.ZodObject<{
55
+ cursorPosition: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strip>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ activityType: z.ZodLiteral<"hover_exit">;
59
+ details: z.ZodObject<{
60
+ duration: z.ZodNumber;
61
+ }, z.core.$strip>;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ activityType: z.ZodLiteral<"scroll">;
64
+ details: z.ZodObject<{
65
+ scrollTop: z.ZodNumber;
66
+ scrollLeft: z.ZodNumber;
67
+ }, z.core.$strip>;
68
+ }, z.core.$strip>, z.ZodObject<{
69
+ activityType: z.ZodLiteral<"cursor_move">;
70
+ details: z.ZodObject<{
71
+ cursorPosition: z.ZodNumber;
72
+ }, z.core.$strip>;
73
+ }, z.core.$strip>], "activityType">>;
74
+ type ClientActivityType = z.infer<typeof clientActivitySchema>;
75
+
76
+ type Notification = {
77
+ [key: string]: any;
78
+ timestamp: number;
79
+ };
80
+ type SubscriberCallback = (notifications: Notification[]) => void;
81
+ type NotificationState = {
82
+ isConnected: boolean;
83
+ notificationsByChannel: Record<string, Notification[]>;
84
+ channelSubscribers: Map<string, Set<SubscriberCallback>>;
85
+ setConnectionStatus: (status: boolean) => void;
86
+ addNotifications: (newNotifications: Notification[]) => void;
87
+ addSubscriber: (channel: string, callback: SubscriberCallback) => () => void;
88
+ subscribeToPath: (path: string, callback: SubscriberCallback) => () => void;
89
+ };
90
+ declare const useNotificationStore: zustand.UseBoundStore<zustand.StoreApi<NotificationState>>;
91
+ declare function SyncProvider({ children, tokens, }: {
92
+ children: ReactNode;
93
+ tokens?: {
94
+ sessionToken: string;
95
+ refreshToken: string;
96
+ serverUrl: string;
97
+ clientId: string;
98
+ };
99
+ }): react_jsx_runtime.JSX.Element;
100
+ type ClientActivityEvent = ClientActivityType & {
101
+ path: string[];
102
+ stateKey: string;
103
+ };
104
+ declare function useSync<TStateRoom = any, TApiParams = any>(options: {
105
+ stateKey: string;
106
+ stateRoom: TStateRoom;
107
+ connect?: boolean;
108
+ inMemoryState?: boolean;
109
+ apiParams?: TApiParams;
110
+ }): {
111
+ sessionId: string;
112
+ connected: boolean;
113
+ clientId: string | null;
114
+ subscribers: string[];
115
+ onInitialState: (handler: (data: any, version: string) => void) => void;
116
+ onPatch: (handler: (patch: UpdateTypeDetail, sessionId: string, version: string) => void) => void;
117
+ onValidationError: (handler: (errors: any, sessionId: string) => void) => void;
118
+ onStateRequest: (handler: () => any) => void;
119
+ onSubscribersUpdate: (handler: (subscribers: string[]) => void) => void;
120
+ onClientActivity: (handler: (status: {
121
+ clientId: string;
122
+ event: ClientActivityEvent;
123
+ metaData: any;
124
+ }) => void) => void;
125
+ reportClientActivity: (event: ClientActivityEvent) => void;
126
+ sendUpdate: (operation: UpdateTypeDetail) => void;
127
+ clientActivity: {
128
+ clientId: string;
129
+ clientActivity: ClientActivityEvent;
130
+ };
131
+ requestState: () => void;
132
+ };
133
+ declare function useNotifications(channel: string): {
134
+ notifications: null;
135
+ isConnected: boolean;
136
+ };
137
+ declare function createNotificationHook<TNotifications extends Record<string, (state: any, context: any) => object | null>>(syncSchema: {
138
+ notifications: TNotifications;
139
+ }): {
140
+ useSyncNotifications: <K extends keyof TNotifications>(type: K) => {
141
+ notifications: (ReturnType<TNotifications[K]> & {
142
+ timestamp: number;
143
+ })[];
144
+ isConnected: boolean;
145
+ };
146
+ };
147
+
148
+ type InferZodMap<T extends Record<string, Record<string, z$1.ZodTypeAny>>> = {
149
+ [K in keyof T]: {
150
+ [P in keyof T[K]]: z$1.infer<T[K][P]>;
151
+ };
152
+ };
153
+ type SyncSchemaForPlugin = {
154
+ clientSchemas: Record<string, z$1.ZodTypeAny>;
155
+ apiParams: Record<string, Record<string, z$1.ZodTypeAny>>;
156
+ metadataSchema: z$1.ZodObject<any>;
157
+ clientActivitySchema: typeof clientActivitySchema;
158
+ };
159
+ declare function createSyncPlugin<TSyncSchema extends SyncSchemaForPlugin>(syncSchema: TSyncSchema): {
160
+ name: "syncPlugin";
161
+ useHook?: ((params: cogsbox_state.UseHookParams<{
162
+ stateRoom: string;
163
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
164
+ }, {
165
+ sessionId: string;
166
+ stateVersion: string;
167
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
168
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
169
+ }, any>) => {
170
+ sessionId: string;
171
+ updateState: (operation: UpdateTypeDetail) => void;
172
+ reportClientActivity: (event: ({
173
+ path: (string | number)[];
174
+ timestamp: number;
175
+ duration?: number | undefined;
176
+ } & ({
177
+ activityType: "focus";
178
+ details: {
179
+ cursorPosition?: number | undefined;
180
+ };
181
+ } | {
182
+ activityType: "blur";
183
+ details: {
184
+ duration: number;
185
+ };
186
+ } | {
187
+ activityType: "input";
188
+ details: {
189
+ value: any;
190
+ inputLength?: number | undefined;
191
+ isComposing?: boolean | undefined;
192
+ isPasting?: boolean | undefined;
193
+ keystrokeCount?: number | undefined;
194
+ };
195
+ } | {
196
+ activityType: "select";
197
+ details: {
198
+ selectionStart: number;
199
+ selectionEnd: number;
200
+ selectedText?: string | undefined;
201
+ };
202
+ } | {
203
+ activityType: "hover_enter";
204
+ details: {
205
+ cursorPosition?: number | undefined;
206
+ };
207
+ } | {
208
+ activityType: "hover_exit";
209
+ details: {
210
+ duration: number;
211
+ };
212
+ } | {
213
+ activityType: "scroll";
214
+ details: {
215
+ scrollTop: number;
216
+ scrollLeft: number;
217
+ };
218
+ } | {
219
+ activityType: "cursor_move";
220
+ details: {
221
+ cursorPosition: number;
222
+ };
223
+ })) & {
224
+ path: string[];
225
+ stateKey: string;
226
+ }) => void;
227
+ }) | undefined;
228
+ transformState?: ((params: cogsbox_state.TransformStateParams<{
229
+ stateRoom: string;
230
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
231
+ }, {
232
+ sessionId: string;
233
+ updateState: (operation: UpdateTypeDetail) => void;
234
+ reportClientActivity: (event: ({
235
+ path: (string | number)[];
236
+ timestamp: number;
237
+ duration?: number | undefined;
238
+ } & ({
239
+ activityType: "focus";
240
+ details: {
241
+ cursorPosition?: number | undefined;
242
+ };
243
+ } | {
244
+ activityType: "blur";
245
+ details: {
246
+ duration: number;
247
+ };
248
+ } | {
249
+ activityType: "input";
250
+ details: {
251
+ value: any;
252
+ inputLength?: number | undefined;
253
+ isComposing?: boolean | undefined;
254
+ isPasting?: boolean | undefined;
255
+ keystrokeCount?: number | undefined;
256
+ };
257
+ } | {
258
+ activityType: "select";
259
+ details: {
260
+ selectionStart: number;
261
+ selectionEnd: number;
262
+ selectedText?: string | undefined;
263
+ };
264
+ } | {
265
+ activityType: "hover_enter";
266
+ details: {
267
+ cursorPosition?: number | undefined;
268
+ };
269
+ } | {
270
+ activityType: "hover_exit";
271
+ details: {
272
+ duration: number;
273
+ };
274
+ } | {
275
+ activityType: "scroll";
276
+ details: {
277
+ scrollTop: number;
278
+ scrollLeft: number;
279
+ };
280
+ } | {
281
+ activityType: "cursor_move";
282
+ details: {
283
+ cursorPosition: number;
284
+ };
285
+ })) & {
286
+ path: string[];
287
+ stateKey: string;
288
+ }) => void;
289
+ }, {
290
+ sessionId: string;
291
+ stateVersion: string;
292
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
293
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
294
+ }, any>) => void) | undefined;
295
+ onUpdate?: ((params: cogsbox_state.OnUpdateParams<{
296
+ stateRoom: string;
297
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
298
+ }, {
299
+ sessionId: string;
300
+ updateState: (operation: UpdateTypeDetail) => void;
301
+ reportClientActivity: (event: ({
302
+ path: (string | number)[];
303
+ timestamp: number;
304
+ duration?: number | undefined;
305
+ } & ({
306
+ activityType: "focus";
307
+ details: {
308
+ cursorPosition?: number | undefined;
309
+ };
310
+ } | {
311
+ activityType: "blur";
312
+ details: {
313
+ duration: number;
314
+ };
315
+ } | {
316
+ activityType: "input";
317
+ details: {
318
+ value: any;
319
+ inputLength?: number | undefined;
320
+ isComposing?: boolean | undefined;
321
+ isPasting?: boolean | undefined;
322
+ keystrokeCount?: number | undefined;
323
+ };
324
+ } | {
325
+ activityType: "select";
326
+ details: {
327
+ selectionStart: number;
328
+ selectionEnd: number;
329
+ selectedText?: string | undefined;
330
+ };
331
+ } | {
332
+ activityType: "hover_enter";
333
+ details: {
334
+ cursorPosition?: number | undefined;
335
+ };
336
+ } | {
337
+ activityType: "hover_exit";
338
+ details: {
339
+ duration: number;
340
+ };
341
+ } | {
342
+ activityType: "scroll";
343
+ details: {
344
+ scrollTop: number;
345
+ scrollLeft: number;
346
+ };
347
+ } | {
348
+ activityType: "cursor_move";
349
+ details: {
350
+ cursorPosition: number;
351
+ };
352
+ })) & {
353
+ path: string[];
354
+ stateKey: string;
355
+ }) => void;
356
+ }, {
357
+ sessionId: string;
358
+ stateVersion: string;
359
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
360
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
361
+ }, any>) => void) | undefined;
362
+ onFormUpdate?: ((params: cogsbox_state.OnFormUpdateParams<{
363
+ stateRoom: string;
364
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
365
+ }, {
366
+ sessionId: string;
367
+ updateState: (operation: UpdateTypeDetail) => void;
368
+ reportClientActivity: (event: ({
369
+ path: (string | number)[];
370
+ timestamp: number;
371
+ duration?: number | undefined;
372
+ } & ({
373
+ activityType: "focus";
374
+ details: {
375
+ cursorPosition?: number | undefined;
376
+ };
377
+ } | {
378
+ activityType: "blur";
379
+ details: {
380
+ duration: number;
381
+ };
382
+ } | {
383
+ activityType: "input";
384
+ details: {
385
+ value: any;
386
+ inputLength?: number | undefined;
387
+ isComposing?: boolean | undefined;
388
+ isPasting?: boolean | undefined;
389
+ keystrokeCount?: number | undefined;
390
+ };
391
+ } | {
392
+ activityType: "select";
393
+ details: {
394
+ selectionStart: number;
395
+ selectionEnd: number;
396
+ selectedText?: string | undefined;
397
+ };
398
+ } | {
399
+ activityType: "hover_enter";
400
+ details: {
401
+ cursorPosition?: number | undefined;
402
+ };
403
+ } | {
404
+ activityType: "hover_exit";
405
+ details: {
406
+ duration: number;
407
+ };
408
+ } | {
409
+ activityType: "scroll";
410
+ details: {
411
+ scrollTop: number;
412
+ scrollLeft: number;
413
+ };
414
+ } | {
415
+ activityType: "cursor_move";
416
+ details: {
417
+ cursorPosition: number;
418
+ };
419
+ })) & {
420
+ path: string[];
421
+ stateKey: string;
422
+ }) => void;
423
+ }, {
424
+ sessionId: string;
425
+ stateVersion: string;
426
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
427
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
428
+ }, any>) => void) | undefined;
429
+ formWrapper?: ((params: cogsbox_state.FormWrapperParams<{
430
+ stateRoom: string;
431
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
432
+ }, {
433
+ sessionId: string;
434
+ updateState: (operation: UpdateTypeDetail) => void;
435
+ reportClientActivity: (event: ({
436
+ path: (string | number)[];
437
+ timestamp: number;
438
+ duration?: number | undefined;
439
+ } & ({
440
+ activityType: "focus";
441
+ details: {
442
+ cursorPosition?: number | undefined;
443
+ };
444
+ } | {
445
+ activityType: "blur";
446
+ details: {
447
+ duration: number;
448
+ };
449
+ } | {
450
+ activityType: "input";
451
+ details: {
452
+ value: any;
453
+ inputLength?: number | undefined;
454
+ isComposing?: boolean | undefined;
455
+ isPasting?: boolean | undefined;
456
+ keystrokeCount?: number | undefined;
457
+ };
458
+ } | {
459
+ activityType: "select";
460
+ details: {
461
+ selectionStart: number;
462
+ selectionEnd: number;
463
+ selectedText?: string | undefined;
464
+ };
465
+ } | {
466
+ activityType: "hover_enter";
467
+ details: {
468
+ cursorPosition?: number | undefined;
469
+ };
470
+ } | {
471
+ activityType: "hover_exit";
472
+ details: {
473
+ duration: number;
474
+ };
475
+ } | {
476
+ activityType: "scroll";
477
+ details: {
478
+ scrollTop: number;
479
+ scrollLeft: number;
480
+ };
481
+ } | {
482
+ activityType: "cursor_move";
483
+ details: {
484
+ cursorPosition: number;
485
+ };
486
+ })) & {
487
+ path: string[];
488
+ stateKey: string;
489
+ }) => void;
490
+ }, {
491
+ sessionId: string;
492
+ stateVersion: string;
493
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
494
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
495
+ }, any>) => React.ReactNode) | undefined;
496
+ } & {
497
+ transformState(fn: (params: cogsbox_state.TransformStateParams<{
498
+ stateRoom: string;
499
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
500
+ }, {
501
+ sessionId: string;
502
+ updateState: (operation: UpdateTypeDetail) => void;
503
+ reportClientActivity: (event: ({
504
+ path: (string | number)[];
505
+ timestamp: number;
506
+ duration?: number | undefined;
507
+ } & ({
508
+ activityType: "focus";
509
+ details: {
510
+ cursorPosition?: number | undefined;
511
+ };
512
+ } | {
513
+ activityType: "blur";
514
+ details: {
515
+ duration: number;
516
+ };
517
+ } | {
518
+ activityType: "input";
519
+ details: {
520
+ value: any;
521
+ inputLength?: number | undefined;
522
+ isComposing?: boolean | undefined;
523
+ isPasting?: boolean | undefined;
524
+ keystrokeCount?: number | undefined;
525
+ };
526
+ } | {
527
+ activityType: "select";
528
+ details: {
529
+ selectionStart: number;
530
+ selectionEnd: number;
531
+ selectedText?: string | undefined;
532
+ };
533
+ } | {
534
+ activityType: "hover_enter";
535
+ details: {
536
+ cursorPosition?: number | undefined;
537
+ };
538
+ } | {
539
+ activityType: "hover_exit";
540
+ details: {
541
+ duration: number;
542
+ };
543
+ } | {
544
+ activityType: "scroll";
545
+ details: {
546
+ scrollTop: number;
547
+ scrollLeft: number;
548
+ };
549
+ } | {
550
+ activityType: "cursor_move";
551
+ details: {
552
+ cursorPosition: number;
553
+ };
554
+ })) & {
555
+ path: string[];
556
+ stateKey: string;
557
+ }) => void;
558
+ }, {
559
+ sessionId: string;
560
+ stateVersion: string;
561
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
562
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
563
+ }, any>) => void): {
564
+ name: "syncPlugin";
565
+ useHook?: ((params: cogsbox_state.UseHookParams<{
566
+ stateRoom: string;
567
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
568
+ }, {
569
+ sessionId: string;
570
+ stateVersion: string;
571
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
572
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
573
+ }, any>) => {
574
+ sessionId: string;
575
+ updateState: (operation: UpdateTypeDetail) => void;
576
+ reportClientActivity: (event: ({
577
+ path: (string | number)[];
578
+ timestamp: number;
579
+ duration?: number | undefined;
580
+ } & ({
581
+ activityType: "focus";
582
+ details: {
583
+ cursorPosition?: number | undefined;
584
+ };
585
+ } | {
586
+ activityType: "blur";
587
+ details: {
588
+ duration: number;
589
+ };
590
+ } | {
591
+ activityType: "input";
592
+ details: {
593
+ value: any;
594
+ inputLength?: number | undefined;
595
+ isComposing?: boolean | undefined;
596
+ isPasting?: boolean | undefined;
597
+ keystrokeCount?: number | undefined;
598
+ };
599
+ } | {
600
+ activityType: "select";
601
+ details: {
602
+ selectionStart: number;
603
+ selectionEnd: number;
604
+ selectedText?: string | undefined;
605
+ };
606
+ } | {
607
+ activityType: "hover_enter";
608
+ details: {
609
+ cursorPosition?: number | undefined;
610
+ };
611
+ } | {
612
+ activityType: "hover_exit";
613
+ details: {
614
+ duration: number;
615
+ };
616
+ } | {
617
+ activityType: "scroll";
618
+ details: {
619
+ scrollTop: number;
620
+ scrollLeft: number;
621
+ };
622
+ } | {
623
+ activityType: "cursor_move";
624
+ details: {
625
+ cursorPosition: number;
626
+ };
627
+ })) & {
628
+ path: string[];
629
+ stateKey: string;
630
+ }) => void;
631
+ }) | undefined;
632
+ transformState?: ((params: cogsbox_state.TransformStateParams<{
633
+ stateRoom: string;
634
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
635
+ }, {
636
+ sessionId: string;
637
+ updateState: (operation: UpdateTypeDetail) => void;
638
+ reportClientActivity: (event: ({
639
+ path: (string | number)[];
640
+ timestamp: number;
641
+ duration?: number | undefined;
642
+ } & ({
643
+ activityType: "focus";
644
+ details: {
645
+ cursorPosition?: number | undefined;
646
+ };
647
+ } | {
648
+ activityType: "blur";
649
+ details: {
650
+ duration: number;
651
+ };
652
+ } | {
653
+ activityType: "input";
654
+ details: {
655
+ value: any;
656
+ inputLength?: number | undefined;
657
+ isComposing?: boolean | undefined;
658
+ isPasting?: boolean | undefined;
659
+ keystrokeCount?: number | undefined;
660
+ };
661
+ } | {
662
+ activityType: "select";
663
+ details: {
664
+ selectionStart: number;
665
+ selectionEnd: number;
666
+ selectedText?: string | undefined;
667
+ };
668
+ } | {
669
+ activityType: "hover_enter";
670
+ details: {
671
+ cursorPosition?: number | undefined;
672
+ };
673
+ } | {
674
+ activityType: "hover_exit";
675
+ details: {
676
+ duration: number;
677
+ };
678
+ } | {
679
+ activityType: "scroll";
680
+ details: {
681
+ scrollTop: number;
682
+ scrollLeft: number;
683
+ };
684
+ } | {
685
+ activityType: "cursor_move";
686
+ details: {
687
+ cursorPosition: number;
688
+ };
689
+ })) & {
690
+ path: string[];
691
+ stateKey: string;
692
+ }) => void;
693
+ }, {
694
+ sessionId: string;
695
+ stateVersion: string;
696
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
697
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
698
+ }, any>) => void) | undefined;
699
+ onUpdate?: ((params: cogsbox_state.OnUpdateParams<{
700
+ stateRoom: string;
701
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
702
+ }, {
703
+ sessionId: string;
704
+ updateState: (operation: UpdateTypeDetail) => void;
705
+ reportClientActivity: (event: ({
706
+ path: (string | number)[];
707
+ timestamp: number;
708
+ duration?: number | undefined;
709
+ } & ({
710
+ activityType: "focus";
711
+ details: {
712
+ cursorPosition?: number | undefined;
713
+ };
714
+ } | {
715
+ activityType: "blur";
716
+ details: {
717
+ duration: number;
718
+ };
719
+ } | {
720
+ activityType: "input";
721
+ details: {
722
+ value: any;
723
+ inputLength?: number | undefined;
724
+ isComposing?: boolean | undefined;
725
+ isPasting?: boolean | undefined;
726
+ keystrokeCount?: number | undefined;
727
+ };
728
+ } | {
729
+ activityType: "select";
730
+ details: {
731
+ selectionStart: number;
732
+ selectionEnd: number;
733
+ selectedText?: string | undefined;
734
+ };
735
+ } | {
736
+ activityType: "hover_enter";
737
+ details: {
738
+ cursorPosition?: number | undefined;
739
+ };
740
+ } | {
741
+ activityType: "hover_exit";
742
+ details: {
743
+ duration: number;
744
+ };
745
+ } | {
746
+ activityType: "scroll";
747
+ details: {
748
+ scrollTop: number;
749
+ scrollLeft: number;
750
+ };
751
+ } | {
752
+ activityType: "cursor_move";
753
+ details: {
754
+ cursorPosition: number;
755
+ };
756
+ })) & {
757
+ path: string[];
758
+ stateKey: string;
759
+ }) => void;
760
+ }, {
761
+ sessionId: string;
762
+ stateVersion: string;
763
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
764
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
765
+ }, any>) => void) | undefined;
766
+ onFormUpdate?: ((params: cogsbox_state.OnFormUpdateParams<{
767
+ stateRoom: string;
768
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
769
+ }, {
770
+ sessionId: string;
771
+ updateState: (operation: UpdateTypeDetail) => void;
772
+ reportClientActivity: (event: ({
773
+ path: (string | number)[];
774
+ timestamp: number;
775
+ duration?: number | undefined;
776
+ } & ({
777
+ activityType: "focus";
778
+ details: {
779
+ cursorPosition?: number | undefined;
780
+ };
781
+ } | {
782
+ activityType: "blur";
783
+ details: {
784
+ duration: number;
785
+ };
786
+ } | {
787
+ activityType: "input";
788
+ details: {
789
+ value: any;
790
+ inputLength?: number | undefined;
791
+ isComposing?: boolean | undefined;
792
+ isPasting?: boolean | undefined;
793
+ keystrokeCount?: number | undefined;
794
+ };
795
+ } | {
796
+ activityType: "select";
797
+ details: {
798
+ selectionStart: number;
799
+ selectionEnd: number;
800
+ selectedText?: string | undefined;
801
+ };
802
+ } | {
803
+ activityType: "hover_enter";
804
+ details: {
805
+ cursorPosition?: number | undefined;
806
+ };
807
+ } | {
808
+ activityType: "hover_exit";
809
+ details: {
810
+ duration: number;
811
+ };
812
+ } | {
813
+ activityType: "scroll";
814
+ details: {
815
+ scrollTop: number;
816
+ scrollLeft: number;
817
+ };
818
+ } | {
819
+ activityType: "cursor_move";
820
+ details: {
821
+ cursorPosition: number;
822
+ };
823
+ })) & {
824
+ path: string[];
825
+ stateKey: string;
826
+ }) => void;
827
+ }, {
828
+ sessionId: string;
829
+ stateVersion: string;
830
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
831
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
832
+ }, any>) => void) | undefined;
833
+ formWrapper?: ((params: cogsbox_state.FormWrapperParams<{
834
+ stateRoom: string;
835
+ apiParams: cogsbox_state.KeyedTypes<InferZodMap<TSyncSchema["apiParams"]>>;
836
+ }, {
837
+ sessionId: string;
838
+ updateState: (operation: UpdateTypeDetail) => void;
839
+ reportClientActivity: (event: ({
840
+ path: (string | number)[];
841
+ timestamp: number;
842
+ duration?: number | undefined;
843
+ } & ({
844
+ activityType: "focus";
845
+ details: {
846
+ cursorPosition?: number | undefined;
847
+ };
848
+ } | {
849
+ activityType: "blur";
850
+ details: {
851
+ duration: number;
852
+ };
853
+ } | {
854
+ activityType: "input";
855
+ details: {
856
+ value: any;
857
+ inputLength?: number | undefined;
858
+ isComposing?: boolean | undefined;
859
+ isPasting?: boolean | undefined;
860
+ keystrokeCount?: number | undefined;
861
+ };
862
+ } | {
863
+ activityType: "select";
864
+ details: {
865
+ selectionStart: number;
866
+ selectionEnd: number;
867
+ selectedText?: string | undefined;
868
+ };
869
+ } | {
870
+ activityType: "hover_enter";
871
+ details: {
872
+ cursorPosition?: number | undefined;
873
+ };
874
+ } | {
875
+ activityType: "hover_exit";
876
+ details: {
877
+ duration: number;
878
+ };
879
+ } | {
880
+ activityType: "scroll";
881
+ details: {
882
+ scrollTop: number;
883
+ scrollLeft: number;
884
+ };
885
+ } | {
886
+ activityType: "cursor_move";
887
+ details: {
888
+ cursorPosition: number;
889
+ };
890
+ })) & {
891
+ path: string[];
892
+ stateKey: string;
893
+ }) => void;
894
+ }, {
895
+ sessionId: string;
896
+ stateVersion: string;
897
+ }, z$1.core.output<TSyncSchema["metadataSchema"]> & {
898
+ clientActivity?: z$1.core.output<TSyncSchema["clientActivitySchema"]>;
899
+ }, any>) => React.ReactNode) | undefined;
900
+ };
901
+ };
902
+
903
+ export { SyncProvider, createNotificationHook, createSyncPlugin, useNotificationStore, useNotifications, useSync };