vzcode 1.37.0 → 1.39.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.
@@ -0,0 +1,25 @@
1
+ import { diff } from './client/diff';
2
+
3
+ /**
4
+ * Creates a submitOperation function that can be used to submit diff-based operations to ShareDB.
5
+ * This is the core logic extracted from useSubmitOperation for reuse across client and server.
6
+ */
7
+ export const createSubmitOperation = <T>(shareDBDoc: {
8
+ data: T;
9
+ submitOp: (op: any) => void;
10
+ }): ((next: (data: T) => T) => void) => {
11
+ return (next) => {
12
+ const data: T = shareDBDoc.data;
13
+ const op = diff(data, next(data));
14
+ if (op && shareDBDoc) {
15
+ shareDBDoc.submitOp(op);
16
+ }
17
+ };
18
+ };
19
+
20
+ /**
21
+ * Type definition for the submitOperation function
22
+ */
23
+ export type SubmitOperationFunction<T> = (
24
+ next: (data: T) => T,
25
+ ) => void;