@powerhousedao/reactor-browser 1.10.2 → 1.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 (108) hide show
  1. package/dist/package.json +47 -0
  2. package/dist/src/context/index.d.ts +1 -1
  3. package/dist/src/context/index.d.ts.map +1 -1
  4. package/dist/src/context/index.js +1 -0
  5. package/dist/src/context/read-mode.d.ts +3 -3
  6. package/dist/src/context/read-mode.d.ts.map +1 -1
  7. package/dist/src/context/read-mode.js +198 -0
  8. package/dist/src/crypto/browser.d.ts +1 -1
  9. package/dist/src/crypto/browser.d.ts.map +1 -1
  10. package/dist/src/crypto/browser.js +49 -0
  11. package/dist/src/crypto/index.js +121 -0
  12. package/dist/src/document-model.d.ts +3 -3
  13. package/dist/src/document-model.d.ts.map +1 -1
  14. package/dist/src/document-model.js +5 -0
  15. package/dist/src/hooks/index.d.ts +9 -5
  16. package/dist/src/hooks/index.d.ts.map +1 -1
  17. package/dist/src/hooks/index.js +9 -0
  18. package/dist/src/hooks/useAddDebouncedOperations.d.ts +3 -3
  19. package/dist/src/hooks/useAddDebouncedOperations.d.ts.map +1 -1
  20. package/dist/src/hooks/useAddDebouncedOperations.js +55 -0
  21. package/dist/src/hooks/useConnectCrypto.d.ts +1 -1
  22. package/dist/src/hooks/useConnectCrypto.d.ts.map +1 -1
  23. package/dist/src/hooks/useConnectCrypto.js +40 -0
  24. package/dist/src/hooks/useDocument.d.ts +3 -3
  25. package/dist/src/hooks/useDocument.d.ts.map +1 -1
  26. package/dist/src/hooks/useDocument.js +37 -0
  27. package/dist/src/hooks/useDocumentDispatch.d.ts +6 -10
  28. package/dist/src/hooks/useDocumentDispatch.d.ts.map +1 -1
  29. package/dist/src/hooks/useDocumentDispatch.js +41 -0
  30. package/dist/src/hooks/useDocumentDrives.d.ts +4 -3
  31. package/dist/src/hooks/useDocumentDrives.d.ts.map +1 -1
  32. package/dist/src/hooks/useDocumentDrives.js +84 -0
  33. package/dist/src/hooks/useDocumentEditor.d.ts +13 -13
  34. package/dist/src/hooks/useDocumentEditor.d.ts.map +1 -1
  35. package/dist/src/hooks/useDocumentEditor.js +30 -0
  36. package/dist/src/hooks/useDriveActions.d.ts +82 -0
  37. package/dist/src/hooks/useDriveActions.d.ts.map +1 -0
  38. package/dist/src/hooks/useDriveActions.js +125 -0
  39. package/dist/src/hooks/useDriveActionsWithUiNodes.d.ts +17 -0
  40. package/dist/src/hooks/useDriveActionsWithUiNodes.d.ts.map +1 -0
  41. package/dist/src/hooks/useDriveActionsWithUiNodes.js +71 -0
  42. package/dist/src/hooks/useDriveContext.d.ts +66 -0
  43. package/dist/src/hooks/useDriveContext.d.ts.map +1 -0
  44. package/dist/src/hooks/useDriveContext.js +25 -0
  45. package/dist/src/hooks/useUiNodesContext.d.ts +25 -0
  46. package/dist/src/hooks/useUiNodesContext.d.ts.map +1 -0
  47. package/dist/src/hooks/useUiNodesContext.js +167 -0
  48. package/dist/src/hooks/useUserPermissions.js +6 -0
  49. package/dist/src/index.d.ts +5 -5
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/index.js +4 -0
  52. package/dist/src/reactor.d.ts +3 -3
  53. package/dist/src/reactor.d.ts.map +1 -1
  54. package/dist/src/reactor.js +54 -0
  55. package/dist/src/renown/constants.js +39 -0
  56. package/dist/src/renown/types.d.ts +3 -3
  57. package/dist/src/renown/types.d.ts.map +1 -1
  58. package/dist/src/renown/types.js +1 -0
  59. package/dist/src/storage/index.d.ts +1 -1
  60. package/dist/src/storage/index.d.ts.map +1 -1
  61. package/dist/src/storage/index.js +1 -0
  62. package/dist/src/storage/types.js +1 -0
  63. package/dist/src/uiNodes/constants.d.ts +17 -0
  64. package/dist/src/uiNodes/constants.d.ts.map +1 -0
  65. package/dist/src/uiNodes/constants.js +23 -0
  66. package/dist/src/uiNodes/types.d.ts +61 -0
  67. package/dist/src/uiNodes/types.d.ts.map +1 -0
  68. package/dist/src/uiNodes/types.js +1 -0
  69. package/dist/src/utils/index.d.ts +3 -3
  70. package/dist/src/utils/index.d.ts.map +1 -1
  71. package/dist/src/utils/index.js +8 -0
  72. package/dist/src/utils/signature.d.ts +3 -3
  73. package/dist/src/utils/signature.d.ts.map +1 -1
  74. package/dist/src/utils/signature.js +39 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -0
  76. package/package.json +15 -22
  77. package/dist/_virtual/__vite-browser-external.js +0 -5
  78. package/dist/_virtual/__vite-browser-external.js.map +0 -1
  79. package/dist/context/read-mode.js +0 -159
  80. package/dist/context/read-mode.js.map +0 -1
  81. package/dist/crypto/browser.js +0 -50
  82. package/dist/crypto/browser.js.map +0 -1
  83. package/dist/crypto/index.js +0 -109
  84. package/dist/crypto/index.js.map +0 -1
  85. package/dist/document-model.js +0 -11
  86. package/dist/document-model.js.map +0 -1
  87. package/dist/hooks/useAddDebouncedOperations.js +0 -54
  88. package/dist/hooks/useAddDebouncedOperations.js.map +0 -1
  89. package/dist/hooks/useConnectCrypto.js +0 -34
  90. package/dist/hooks/useConnectCrypto.js.map +0 -1
  91. package/dist/hooks/useDocument.js +0 -20
  92. package/dist/hooks/useDocument.js.map +0 -1
  93. package/dist/hooks/useDocumentDispatch.js +0 -30
  94. package/dist/hooks/useDocumentDispatch.js.map +0 -1
  95. package/dist/hooks/useDocumentDrives.js +0 -86
  96. package/dist/hooks/useDocumentDrives.js.map +0 -1
  97. package/dist/hooks/useDocumentEditor.js +0 -46
  98. package/dist/hooks/useDocumentEditor.js.map +0 -1
  99. package/dist/hooks/useUserPermissions.js +0 -10
  100. package/dist/hooks/useUserPermissions.js.map +0 -1
  101. package/dist/index.js +0 -26
  102. package/dist/index.js.map +0 -1
  103. package/dist/reactor.js +0 -59
  104. package/dist/reactor.js.map +0 -1
  105. package/dist/utils/index.js +0 -16
  106. package/dist/utils/index.js.map +0 -1
  107. package/dist/utils/signature.js +0 -35
  108. package/dist/utils/signature.js.map +0 -1
@@ -0,0 +1,66 @@
1
+ import { Node, SyncStatus } from "document-drive";
2
+ import { DocumentModelModule } from "document-model";
3
+ import { PropsWithChildren } from "react";
4
+ import type { UiNode } from "../uiNodes/types.js";
5
+ /**
6
+ * Interface representing the context values provided by the host application
7
+ * for managing document drive functionality.
8
+ */
9
+ export interface IDriveContext {
10
+ /** Controls the visibility of the search bar in the drive interface */
11
+ showSearchBar: boolean;
12
+ /** Indicates whether the current user has permissions to create new documents */
13
+ isAllowedToCreateDocuments: boolean;
14
+ /** Array of available document models that can be created */
15
+ documentModels: DocumentModelModule[];
16
+ /** Currently selected node (file/folder) in the drive */
17
+ selectedNode: Node | null;
18
+ /**
19
+ * Callback to update the selected node in the drive
20
+ * @param node - The node to be selected
21
+ */
22
+ selectNode: (node: UiNode | null) => void;
23
+ /**
24
+ * Adds a new file to the drive
25
+ * @param file - File to be added (can be a string path or File object)
26
+ * @param drive - The drive to add the file to
27
+ * @param name - Optional name for the file
28
+ * @param parentFolder - Optional parent folder of the file
29
+ * @returns Promise resolving to the newly created Node
30
+ */
31
+ addFile: (file: string | File, drive: string, name?: string, parentFolder?: string) => Promise<void>;
32
+ /**
33
+ * Shows a modal for creating a new document
34
+ * @param documentModel - Document model of the document to be created
35
+ * @returns Promise resolving to an object containing the document name
36
+ */
37
+ showCreateDocumentModal: (documentModel: DocumentModelModule) => Promise<{
38
+ name: string;
39
+ }>;
40
+ /**
41
+ * Retrieves the sync status of a document or drive
42
+ * @param driveId - ID of the drive to check sync status for
43
+ * @param documentId - ID of the document to check sync status for
44
+ * @returns SyncStatus object containing sync information
45
+ */
46
+ useSyncStatus: (driveId: string, documentId?: string) => SyncStatus | undefined;
47
+ }
48
+ export declare const DriveContextProvider: React.FC<PropsWithChildren<{
49
+ value: IDriveContext;
50
+ }>>;
51
+ /**
52
+ * Hook to access the drive context values provided by the host application.
53
+ * Must be used within a DriveContextProvider component.
54
+ *
55
+ * @returns IDriveContext - Object containing drive-related values and functions
56
+ *
57
+ * @example
58
+ * const {
59
+ * showSearchBar,
60
+ * documentModels,
61
+ * selectedNode,
62
+ * addFile
63
+ * } = useDriveContext();
64
+ */
65
+ export declare function useDriveContext(): IDriveContext;
66
+ //# sourceMappingURL=useDriveContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDriveContext.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDriveContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,aAAa,EAAE,OAAO,CAAC;IAEvB,iFAAiF;IACjF,0BAA0B,EAAE,OAAO,CAAC;IAEpC,6DAA6D;IAC7D,cAAc,EAAE,mBAAmB,EAAE,CAAC;IAEtC,yDAAyD;IACzD,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B;;;OAGG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE1C;;;;;;;OAOG;IACH,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;OAIG;IACH,uBAAuB,EAAE,CACvB,aAAa,EAAE,mBAAmB,KAC/B,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE/B;;;;;OAKG;IACH,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,KAChB,UAAU,GAAG,SAAS,CAAC;CAC7B;AAID,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC,CAG5C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,kBAQ9B"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const DriveContext = createContext(undefined);
4
+ export const DriveContextProvider = ({ value, children }) => (_jsx(DriveContext.Provider, { value: value, children: children }));
5
+ /**
6
+ * Hook to access the drive context values provided by the host application.
7
+ * Must be used within a DriveContextProvider component.
8
+ *
9
+ * @returns IDriveContext - Object containing drive-related values and functions
10
+ *
11
+ * @example
12
+ * const {
13
+ * showSearchBar,
14
+ * documentModels,
15
+ * selectedNode,
16
+ * addFile
17
+ * } = useDriveContext();
18
+ */
19
+ export function useDriveContext() {
20
+ const context = useContext(DriveContext);
21
+ if (!context) {
22
+ throw new Error("useDriveContext must be used within a DriveContextProvider");
23
+ }
24
+ return context;
25
+ }
@@ -0,0 +1,25 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { UiDriveNode, UiFolderNode, UiNode } from "../uiNodes/types.js";
3
+ export * from "../uiNodes/constants.js";
4
+ export * from "../uiNodes/types.js";
5
+ export type TUiNodesContext = {
6
+ driveNodes: UiDriveNode[];
7
+ selectedNode: UiNode | null;
8
+ selectedNodePath: UiNode[];
9
+ selectedDriveNode: UiDriveNode | null;
10
+ selectedParentNode: UiDriveNode | UiFolderNode | null;
11
+ setDriveNodes: (driveNodes: UiDriveNode[]) => void;
12
+ setSelectedNode: (node: UiNode | null) => void;
13
+ getNodeById: (id: string) => UiNode | null;
14
+ getParentNode: (uiNode: UiNode) => UiNode | null;
15
+ getIsSelected: (node: UiNode) => boolean;
16
+ getIsInSelectedNodePath: (node: UiNode) => boolean;
17
+ getSiblings: (node: UiNode) => UiNode[];
18
+ };
19
+ export declare const UiNodesContext: import("react").Context<TUiNodesContext>;
20
+ export interface UiNodesContextProviderProps {
21
+ readonly children: ReactNode;
22
+ }
23
+ export declare const UiNodesContextProvider: FC<UiNodesContextProviderProps>;
24
+ export declare const useUiNodesContext: () => TUiNodesContext;
25
+ //# sourceMappingURL=useUiNodesContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUiNodesContext.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUiNodesContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,EAAE,EACF,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExE,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AAEpC,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,WAAW,GAAG,IAAI,CAAC;IACtC,kBAAkB,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CAAC;IACtD,aAAa,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IACnD,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACjD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,uBAAuB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACnD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;CACzC,CAAC;AAiBF,eAAO,MAAM,cAAc,0CAE1B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CA6NlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,uBAG7B,CAAC"}
@@ -0,0 +1,167 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
3
+ import { DRIVE, FILE } from "../uiNodes/constants.js";
4
+ export * from "../uiNodes/constants.js";
5
+ export * from "../uiNodes/types.js";
6
+ const defaultTreeItemContextValue = {
7
+ driveNodes: [],
8
+ selectedNode: null,
9
+ selectedNodePath: [],
10
+ selectedDriveNode: null,
11
+ selectedParentNode: null,
12
+ setDriveNodes: () => { },
13
+ setSelectedNode: () => { },
14
+ getNodeById: () => null,
15
+ getParentNode: () => null,
16
+ getIsSelected: () => false,
17
+ getIsInSelectedNodePath: () => false,
18
+ getSiblings: () => [],
19
+ };
20
+ export const UiNodesContext = createContext(defaultTreeItemContextValue);
21
+ export const UiNodesContextProvider = ({ children, }) => {
22
+ const [driveNodes, setDriveNodes] = useState([]);
23
+ const [selectedNode, _setSelectedNode] = useState(null);
24
+ const [selectedNodePath, setSelectedNodePath] = useState([]);
25
+ const [selectedDriveNode, setSelectedDriveNode] = useState(null);
26
+ const [selectedParentNode, setSelectedParentNode] = useState(null);
27
+ /*
28
+ This internal function that uses `driveNodes` as an argument to prevent stale objects being used in the closure.
29
+ External `getNodeById` for use by other components doesn't need to do this because it is only invoked by external functions, and can therefore omit this argument for convenience.
30
+ */
31
+ const _getNodeById = useCallback((id, driveNodes) => {
32
+ if (!driveNodes?.length)
33
+ return null;
34
+ for (const driveNode of driveNodes) {
35
+ if (driveNode.id === id)
36
+ return driveNode;
37
+ const node = driveNode.nodeMap[id];
38
+ if (node)
39
+ return node;
40
+ }
41
+ return null;
42
+ }, []);
43
+ const getNodeById = useCallback((id) => {
44
+ return _getNodeById(id, driveNodes);
45
+ }, [_getNodeById, driveNodes]);
46
+ const getSelectedDriveNode = useCallback((selectedNode, driveNodes) => {
47
+ if (!selectedNode || !driveNodes?.length)
48
+ return null;
49
+ if (selectedNode.kind === DRIVE)
50
+ return selectedNode;
51
+ return driveNodes.find((d) => d.id === selectedNode.driveId) ?? null;
52
+ }, []);
53
+ /*
54
+ This internal function that uses `driveNodes` as an argument to prevent stale objects being used in the closure.
55
+ External `getNodeById` for use by other components doesn't need to do this because it is only invoked by external functions, and can therefore omit this argument for convenience.
56
+ */
57
+ const _getParentNode = useCallback((node, driveNodes) => {
58
+ if (!driveNodes?.length || node.kind === DRIVE) {
59
+ return null;
60
+ }
61
+ const parentNode = _getNodeById(node.parentFolder, driveNodes);
62
+ if (!parentNode)
63
+ return null;
64
+ if (parentNode.kind === FILE) {
65
+ throw new Error(`Parent node ${node.parentFolder} is a file, not a folder`);
66
+ }
67
+ return parentNode;
68
+ }, [_getNodeById]);
69
+ const getParentNode = useCallback((uiNode) => {
70
+ return _getParentNode(uiNode, driveNodes);
71
+ }, [_getParentNode, driveNodes]);
72
+ const getSelectedParentNode = useCallback((selectedNode, driveNodes) => {
73
+ if (!selectedNode || !driveNodes?.length)
74
+ return null;
75
+ if (selectedNode.kind === FILE)
76
+ return _getParentNode(selectedNode, driveNodes);
77
+ return selectedNode;
78
+ }, [_getParentNode]);
79
+ const getPathToNode = useCallback((uiNode, driveNodes) => {
80
+ const path = [];
81
+ const driveNode = driveNodes.find((d) => d.id === uiNode.driveId);
82
+ let current = uiNode;
83
+ while (current) {
84
+ path.push(current);
85
+ current =
86
+ current.parentFolder === driveNode?.id
87
+ ? driveNode
88
+ : current.parentFolder
89
+ ? driveNode?.nodeMap[current.parentFolder]
90
+ : undefined;
91
+ }
92
+ return path.reverse();
93
+ }, []);
94
+ /*
95
+ _setSelectedNode from `useState` is kept internal so that we can instead expose this function, which also manages the selectedDriveNode, selectedParentNode, and selectedNodePath states.
96
+ */
97
+ const setSelectedNode = useCallback((uiNode) => {
98
+ _setSelectedNode(uiNode);
99
+ setSelectedDriveNode(getSelectedDriveNode(uiNode, driveNodes));
100
+ setSelectedParentNode(getSelectedParentNode(uiNode, driveNodes));
101
+ if (!uiNode) {
102
+ setSelectedNodePath([]);
103
+ return;
104
+ }
105
+ if (uiNode.kind === DRIVE) {
106
+ setSelectedNodePath([uiNode]);
107
+ return;
108
+ }
109
+ const newSelectedNodePath = getPathToNode(uiNode, driveNodes);
110
+ setSelectedNodePath(newSelectedNodePath);
111
+ }, [driveNodes, getPathToNode, getSelectedDriveNode, getSelectedParentNode]);
112
+ const getIsSelected = useCallback((node) => {
113
+ return selectedNode === node;
114
+ }, [selectedNode]);
115
+ const getIsInSelectedNodePath = useCallback((node) => {
116
+ if (node.kind === FILE)
117
+ return false;
118
+ return selectedNodePath.includes(node);
119
+ }, [selectedNodePath]);
120
+ const getSiblings = useCallback((node) => {
121
+ if (node.kind === DRIVE) {
122
+ console.warn("Drive nodes do not have siblings, as they are top-level nodes");
123
+ return [];
124
+ }
125
+ const parent = _getParentNode(node, driveNodes);
126
+ return parent?.children ?? [];
127
+ }, [_getParentNode, driveNodes]);
128
+ useEffect(() => {
129
+ if (!selectedNode)
130
+ return;
131
+ const updatedSelectedNode = _getNodeById(selectedNode.id, driveNodes);
132
+ if (updatedSelectedNode) {
133
+ setSelectedNode(updatedSelectedNode);
134
+ }
135
+ }, [driveNodes, _getNodeById, selectedNode, setSelectedNode]);
136
+ const value = useMemo(() => ({
137
+ driveNodes,
138
+ selectedNode,
139
+ selectedNodePath,
140
+ selectedDriveNode,
141
+ selectedParentNode,
142
+ getNodeById,
143
+ getParentNode,
144
+ setDriveNodes,
145
+ setSelectedNode,
146
+ getIsSelected,
147
+ getIsInSelectedNodePath,
148
+ getSiblings,
149
+ }), [
150
+ driveNodes,
151
+ selectedNode,
152
+ selectedNodePath,
153
+ selectedDriveNode,
154
+ selectedParentNode,
155
+ getNodeById,
156
+ getParentNode,
157
+ setSelectedNode,
158
+ getIsSelected,
159
+ getIsInSelectedNodePath,
160
+ getSiblings,
161
+ ]);
162
+ return (_jsx(UiNodesContext.Provider, { value: value, children: children }));
163
+ };
164
+ export const useUiNodesContext = () => {
165
+ const contextValue = useContext(UiNodesContext);
166
+ return contextValue;
167
+ };
@@ -0,0 +1,6 @@
1
+ export function useUserPermissions() {
2
+ return {
3
+ isAllowedToCreateDocuments: true,
4
+ isAllowedToEditDocuments: true,
5
+ };
6
+ }
@@ -1,7 +1,7 @@
1
- import { IDocumentDriveServer } from 'document-drive';
2
- export * from './document-model';
3
- export * from './context';
4
- export * from './reactor';
5
- export * from './hooks';
1
+ import { IDocumentDriveServer } from "document-drive";
2
+ export * from "./context/index.js";
3
+ export * from "./document-model.js";
4
+ export * from "./hooks/index.js";
5
+ export * from "./reactor.js";
6
6
  export type DocumentDriveServerInterface = IDocumentDriveServer;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./context/index.js";
2
+ export * from "./document-model.js";
3
+ export * from "./hooks/index.js";
4
+ export * from "./reactor.js";
@@ -1,8 +1,8 @@
1
- import { DocumentDriveServerOptions } from 'document-drive/server';
2
- import { DocumentModel } from 'document-model/document';
1
+ import { BaseDocumentDriveServer, DocumentDriveServerOptions, IReadModeDriveServer } from "document-drive";
2
+ import { DocumentModelModule } from "document-model";
3
3
  export type ReactorDefaultDrivesConfig = {
4
4
  defaultDrivesUrl?: string[];
5
5
  };
6
6
  export declare const getReactorDefaultDrivesConfig: (config?: ReactorDefaultDrivesConfig) => Pick<DocumentDriveServerOptions, "defaultDrives">;
7
- export declare function createBrowserDocumentDriveServer(documentModels: DocumentModel[], routerBasename: string, documentDriveServerOptions?: DocumentDriveServerOptions): import('document-drive').BaseDocumentDriveServer & import('document-drive').IReadModeDriveServer;
7
+ export declare function createBrowserDocumentDriveServer(documentModelModules: DocumentModelModule[], routerBasename: string, documentDriveServerOptions?: DocumentDriveServerOptions): BaseDocumentDriveServer & IReadModeDriveServer;
8
8
  //# sourceMappingURL=reactor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactor.d.ts","sourceRoot":"","sources":["../../src/reactor.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,MAAM,0BAA0B,GAAG;IACvC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAChC,0BAA0B,KACjC,IAAI,CAAC,0BAA0B,EAAE,eAAe,CA8ClD,CAAC;AAEF,wBAAgB,gCAAgC,CAC9C,cAAc,EAAE,aAAa,EAAE,EAC/B,cAAc,EAAE,MAAM,EACtB,0BAA0B,CAAC,EAAE,0BAA0B,oGASxD"}
1
+ {"version":3,"file":"reactor.d.ts","sourceRoot":"","sources":["../../src/reactor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EAGvB,0BAA0B,EAE1B,oBAAoB,EAErB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,0BAA0B,GAAG;IACvC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAChC,0BAA0B,KACjC,IAAI,CAAC,0BAA0B,EAAE,eAAe,CA8ClD,CAAC;AAEF,wBAAgB,gCAAgC,CAC9C,oBAAoB,EAAE,mBAAmB,EAAE,EAC3C,cAAc,EAAE,MAAM,EACtB,0BAA0B,CAAC,EAAE,0BAA0B,GACtD,uBAAuB,GAAG,oBAAoB,CAWhD"}
@@ -0,0 +1,54 @@
1
+ import { BaseQueueManager, InMemoryCache, ReactorBuilder, } from "document-drive";
2
+ import { BrowserStorage } from "document-drive/storage/browser";
3
+ export const getReactorDefaultDrivesConfig = (config = {}) => {
4
+ const defaultDrivesUrl = config.defaultDrivesUrl || [];
5
+ const remoteDrives = defaultDrivesUrl.map((driveUrl) => ({
6
+ url: driveUrl,
7
+ options: {
8
+ sharingType: "PUBLIC",
9
+ availableOffline: true,
10
+ listeners: [
11
+ {
12
+ block: true,
13
+ callInfo: {
14
+ data: driveUrl,
15
+ name: "switchboard-push",
16
+ transmitterType: "SwitchboardPush",
17
+ },
18
+ filter: {
19
+ branch: ["main"],
20
+ documentId: ["*"],
21
+ documentType: ["*"],
22
+ scope: ["global"],
23
+ },
24
+ label: "Switchboard Sync",
25
+ listenerId: "1",
26
+ system: true,
27
+ },
28
+ ],
29
+ triggers: [],
30
+ pullInterval: 3000,
31
+ },
32
+ }));
33
+ return {
34
+ defaultDrives: {
35
+ remoteDrives,
36
+ removeOldRemoteDrives: defaultDrivesUrl.length > 0
37
+ ? {
38
+ strategy: "preserve-by-url-and-detach",
39
+ urls: defaultDrivesUrl,
40
+ }
41
+ : { strategy: "preserve-all" },
42
+ },
43
+ };
44
+ };
45
+ export function createBrowserDocumentDriveServer(documentModelModules, routerBasename, documentDriveServerOptions) {
46
+ const builder = new ReactorBuilder(documentModelModules)
47
+ .withStorage(new BrowserStorage(routerBasename))
48
+ .withCache(new InMemoryCache())
49
+ .withQueueManager(new BaseQueueManager(1, 10));
50
+ if (documentDriveServerOptions) {
51
+ builder.withOptions(documentDriveServerOptions);
52
+ }
53
+ return builder.build();
54
+ }
@@ -0,0 +1,39 @@
1
+ export const RENOWN_URL = "https://auth.renown.id";
2
+ export const RENOWN_NETWORK_ID = "eip155";
3
+ export const RENOWN_CHAIN_ID = "1";
4
+ export const DOMAIN_TYPE = [
5
+ { name: "name", type: "string" },
6
+ { name: "version", type: "string" },
7
+ { name: "chainId", type: "uint256" },
8
+ { name: "verifyingContract", type: "address" },
9
+ ];
10
+ export const VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
11
+ { name: "@context", type: "string[]" },
12
+ { name: "type", type: "string[]" },
13
+ { name: "id", type: "string" },
14
+ { name: "issuer", type: "Issuer" },
15
+ { name: "credentialSubject", type: "CredentialSubject" },
16
+ { name: "credentialSchema", type: "CredentialSchema" },
17
+ { name: "issuanceDate", type: "string" },
18
+ { name: "expirationDate", type: "string" },
19
+ ];
20
+ export const CREDENTIAL_SCHEMA_EIP712_TYPE = [
21
+ { name: "id", type: "string" },
22
+ { name: "type", type: "string" },
23
+ ];
24
+ export const CREDENTIAL_SUBJECT_TYPE = [
25
+ { name: "app", type: "string" },
26
+ { name: "id", type: "string" },
27
+ { name: "name", type: "string" },
28
+ ];
29
+ export const ISSUER_TYPE = [
30
+ { name: "id", type: "string" },
31
+ { name: "ethereumAddress", type: "string" },
32
+ ];
33
+ export const CREDENTIAL_TYPES = {
34
+ EIP712Domain: DOMAIN_TYPE,
35
+ VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
36
+ CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
37
+ CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
38
+ Issuer: ISSUER_TYPE,
39
+ };
@@ -1,6 +1,6 @@
1
- import { User as EditorUser } from 'document-model/document';
2
- import { IStorage } from '../storage';
3
- import { CREDENTIAL_TYPES } from './constants';
1
+ import type { User as EditorUser } from "document-model";
2
+ import type { IStorage } from "../storage/index.js";
3
+ import { CREDENTIAL_TYPES } from "./constants.js";
4
4
  export type User = EditorUser & {
5
5
  did: string;
6
6
  credential: PowerhouseVerifiableCredential | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/renown/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,8BAA8B,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,EAAE,EAAE;QACF,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAK,WAAW,CAAC;KACjD,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CAAE,CAAC,CAAC;AAEjE,KAAK,UAAU,CAAC,CAAC,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,CAAC,CA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,EAAE,MAAM,CACpD,SAAQ,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,8BAA8B,GAAG,qBAAqB,CAChE,4BAA4B,EAC5B,qBAAqB,CACtB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- export * from './types';
1
+ export * from "./types.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ export declare const SWITCHBOARD = "SWITCHBOARD";
2
+ export declare const LOCAL = "LOCAL";
3
+ export declare const CLOUD = "CLOUD";
4
+ export declare const PUBLIC = "PUBLIC";
5
+ export declare const sharingTypes: readonly ["LOCAL", "CLOUD", "PUBLIC"];
6
+ export declare const driveLocations: readonly ["LOCAL", "CLOUD", "SWITCHBOARD"];
7
+ export declare const DRIVE = "DRIVE";
8
+ export declare const FILE = "FILE";
9
+ export declare const FOLDER = "FOLDER";
10
+ export declare const SYNCING = "SYNCING";
11
+ export declare const SUCCESS = "SUCCESS";
12
+ export declare const CONFLICT = "CONFLICT";
13
+ export declare const MISSING = "MISSING";
14
+ export declare const ERROR = "ERROR";
15
+ export declare const INITIAL_SYNC = "INITIAL_SYNC";
16
+ export declare const syncStatuses: readonly ["INITIAL_SYNC", "SYNCING", "SUCCESS", "CONFLICT", "MISSING", "ERROR"];
17
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/uiNodes/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAO,MAAM,YAAY,uCAAkC,CAAC;AAE5D,eAAO,MAAM,cAAc,4CAAuC,CAAC;AAEnE,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,IAAI,SAAS,CAAC;AAC3B,eAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,YAAY,iFAOf,CAAC"}
@@ -0,0 +1,23 @@
1
+ export const SWITCHBOARD = "SWITCHBOARD";
2
+ export const LOCAL = "LOCAL";
3
+ export const CLOUD = "CLOUD";
4
+ export const PUBLIC = "PUBLIC";
5
+ export const sharingTypes = [LOCAL, CLOUD, PUBLIC];
6
+ export const driveLocations = [LOCAL, CLOUD, SWITCHBOARD];
7
+ export const DRIVE = "DRIVE";
8
+ export const FILE = "FILE";
9
+ export const FOLDER = "FOLDER";
10
+ export const SYNCING = "SYNCING";
11
+ export const SUCCESS = "SUCCESS";
12
+ export const CONFLICT = "CONFLICT";
13
+ export const MISSING = "MISSING";
14
+ export const ERROR = "ERROR";
15
+ export const INITIAL_SYNC = "INITIAL_SYNC";
16
+ export const syncStatuses = [
17
+ INITIAL_SYNC,
18
+ SYNCING,
19
+ SUCCESS,
20
+ CONFLICT,
21
+ MISSING,
22
+ ERROR,
23
+ ];
@@ -0,0 +1,61 @@
1
+ import { Maybe, SynchronizationUnitInput } from "document-model";
2
+ import { DRIVE, driveLocations, FILE, FOLDER, sharingTypes, syncStatuses } from "./constants.js";
3
+ export type SharingTypes = typeof sharingTypes;
4
+ export type SharingType = SharingTypes[number];
5
+ export type DriveLocations = typeof driveLocations;
6
+ export type DriveLocation = DriveLocations[number];
7
+ export type SyncStatuses = typeof syncStatuses;
8
+ export type SyncStatus = SyncStatuses[number];
9
+ export type UiFileNode = {
10
+ kind: typeof FILE;
11
+ id: string;
12
+ name: string;
13
+ slug?: string | null;
14
+ documentType: string;
15
+ parentFolder: string;
16
+ driveId: string;
17
+ syncStatus: SyncStatus | undefined;
18
+ synchronizationUnits: SynchronizationUnitInput[];
19
+ sharingType: SharingType;
20
+ };
21
+ export type UiFolderNode = {
22
+ kind: typeof FOLDER;
23
+ id: string;
24
+ name: string;
25
+ slug?: string | null;
26
+ parentFolder: string;
27
+ driveId: string;
28
+ children: UiNode[];
29
+ syncStatus: SyncStatus | undefined;
30
+ sharingType: SharingType;
31
+ };
32
+ export type UiDriveNode = {
33
+ kind: typeof DRIVE;
34
+ id: string;
35
+ name: string;
36
+ slug: string | null;
37
+ parentFolder: null;
38
+ driveId: string;
39
+ children: UiNode[];
40
+ nodeMap: Record<string, UiNode>;
41
+ syncStatus: SyncStatus | undefined;
42
+ sharingType: SharingType;
43
+ availableOffline: boolean;
44
+ icon: string | null;
45
+ };
46
+ export type UiNode = UiDriveNode | UiFileNode | UiFolderNode;
47
+ export type FileNode = {
48
+ documentType: string;
49
+ id: string;
50
+ kind: string;
51
+ name: string;
52
+ parentFolder: Maybe<string>;
53
+ synchronizationUnits: SynchronizationUnitInput[];
54
+ };
55
+ export type FolderNode = {
56
+ id: string;
57
+ kind: string;
58
+ name: string;
59
+ parentFolder: Maybe<string>;
60
+ };
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/uiNodes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EACL,KAAK,EACL,cAAc,EACd,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AACnD,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;IACnC,oBAAoB,EAAE,wBAAwB,EAAE,CAAC;IACjD,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,Y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ocumentDriveDocument } from 'document-model-libs/document-drive';
3
- export declare function documentToHash(drive: Document): string;
1
+ import { DocumentDriveDocument } from "document-drive";
2
+ import { PHDocument } from "document-model";
3
+ export declare function documentToHash(drive: PHDocument): string;
4
4
  export declare function drivesToHash(drives: DocumentDriveDocument[]): string;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAOtD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAEpE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAkB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAOxD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAEpE"}
@@ -0,0 +1,8 @@
1
+ export function documentToHash(drive) {
2
+ return Object.keys(drive.operations)
3
+ .map((key) => `${key}:${drive.operations[key].length}:${drive.operations[key].at(-1)?.hash}`)
4
+ .join(":");
5
+ }
6
+ export function drivesToHash(drives) {
7
+ return drives.map(documentToHash).join("&");
8
+ }
@@ -1,5 +1,5 @@
1
- import { Action, Document, Operation, Reducer, User } from 'document-model/document';
2
- import { User as RenownUser } from '../renown/types';
3
- export declare function signOperation<State = unknown, A extends Action = Action, LocalState = unknown>(operation: Operation<A>, sign: (data: Uint8Array) => Promise<Uint8Array>, documentId: string, document: Document<State, A, LocalState>, reducer?: Reducer<State, A, LocalState>, user?: User): Promise<Operation<A>>;
1
+ import { Action, Operation, PHDocument, Reducer, User } from "document-model";
2
+ import type { User as RenownUser } from "../renown/types.js";
3
+ export declare function signOperation<TDocument extends PHDocument>(operation: Operation, sign: (data: Uint8Array) => Promise<Uint8Array>, documentId: string, document: TDocument, reducer?: Reducer<TDocument>, user?: User): Promise<Operation>;
4
4
  export declare function addActionContext<A extends Action = Action>(action: A, connectDid?: string, user?: RenownUser): A;
5
5
  //# sourceMappingURL=signature.d.ts.map