@powerhousedao/reactor-browser 4.0.0-staging.6 → 4.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.
- package/dist/package.json +1 -1
- package/dist/src/hooks/document-state.d.ts.map +1 -1
- package/dist/src/hooks/document-state.js +2 -2
- package/dist/src/hooks/document-state.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAddDebouncedOperations.d.ts +2 -1
- package/dist/src/hooks/useAddDebouncedOperations.d.ts.map +1 -1
- package/dist/src/hooks/useAddDebouncedOperations.js +15 -8
- package/dist/src/hooks/useAddDebouncedOperations.js.map +1 -1
- package/dist/src/hooks/useDocument.d.ts +1 -0
- package/dist/src/hooks/useDocument.d.ts.map +1 -1
- package/dist/src/hooks/useDocument.js +14 -8
- package/dist/src/hooks/useDocument.js.map +1 -1
- package/dist/src/hooks/useDocumentEditor.d.ts +3 -3
- package/dist/src/hooks/useDocumentEditor.d.ts.map +1 -1
- package/dist/src/hooks/useDocumentEditor.js +6 -8
- package/dist/src/hooks/useDocumentEditor.js.map +1 -1
- package/dist/src/hooks/useDriveActions.d.ts +4 -1
- package/dist/src/hooks/useDriveActions.d.ts.map +1 -1
- package/dist/src/hooks/useDriveActions.js +22 -4
- package/dist/src/hooks/useDriveActions.js.map +1 -1
- package/dist/src/hooks/useDriveActionsWithUiNodes.d.ts +17 -0
- package/dist/src/hooks/useDriveActionsWithUiNodes.d.ts.map +1 -0
- package/dist/src/hooks/useDriveActionsWithUiNodes.js +72 -0
- package/dist/src/hooks/useDriveActionsWithUiNodes.js.map +1 -0
- package/dist/src/hooks/useDriveContext.d.ts +95 -1
- package/dist/src/hooks/useDriveContext.d.ts.map +1 -1
- package/dist/src/hooks/useDriveContext.js.map +1 -1
- package/dist/src/hooks/useUiNodesContext.d.ts +25 -0
- package/dist/src/hooks/useUiNodesContext.d.ts.map +1 -0
- package/dist/src/hooks/useUiNodesContext.js +168 -0
- package/dist/src/hooks/useUiNodesContext.js.map +1 -0
- package/dist/src/reactor.js +1 -1
- package/dist/src/reactor.js.map +1 -1
- package/dist/src/types/drive-editor.d.ts +69 -83
- package/dist/src/types/drive-editor.d.ts.map +1 -1
- package/dist/src/uiNodes/constants.d.ts +17 -0
- package/dist/src/uiNodes/constants.d.ts.map +1 -0
- package/dist/src/uiNodes/constants.js +24 -0
- package/dist/src/uiNodes/constants.js.map +1 -0
- package/dist/src/uiNodes/types.d.ts +61 -0
- package/dist/src/uiNodes/types.d.ts.map +1 -0
- package/dist/src/uiNodes/types.js +2 -0
- package/dist/src/uiNodes/types.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDriveContext.js","sourceRoot":"","sources":["../../../src/hooks/useDriveContext.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"useDriveContext.js","sourceRoot":"","sources":["../../../src/hooks/useDriveContext.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,aAAa,EAA0B,UAAU,EAAE,MAAM,OAAO,CAAC;AAyH1E,MAAM,YAAY,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,oBAAoB,GAE7B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC3B,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAyB,CACxE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type FC, type ReactNode } from "react";
|
|
2
|
+
import { type UiDriveNode, type UiFolderNode, type 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,KAAK,EAAE,EACP,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,MAAM,EACZ,MAAM,qBAAqB,CAAC;AAE7B,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,168 @@
|
|
|
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
|
+
};
|
|
168
|
+
//# sourceMappingURL=useUiNodesContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUiNodesContext.js","sourceRoot":"","sources":["../../../src/hooks/useUiNodesContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EAGb,WAAW,EACX,U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AAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAChD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
package/dist/src/reactor.js
CHANGED
|
@@ -45,7 +45,7 @@ export function createBrowserDocumentDriveServer(documentModelModules, routerBas
|
|
|
45
45
|
const builder = new ReactorBuilder(documentModelModules)
|
|
46
46
|
.withStorage(new BrowserStorage(routerBasename))
|
|
47
47
|
.withCache(new InMemoryCache())
|
|
48
|
-
.withQueueManager(new BaseQueueManager());
|
|
48
|
+
.withQueueManager(new BaseQueueManager(1, 10));
|
|
49
49
|
if (documentDriveServerOptions) {
|
|
50
50
|
builder.withOptions(documentDriveServerOptions);
|
|
51
51
|
}
|
package/dist/src/reactor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactor.js","sourceRoot":"","sources":["../../src/reactor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,aAAa,EACb,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOhE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,SAAqC,EAAE,EACY,EAAE;IACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC;IAEvD,MAAM,YAAY,GAA8B,gBAAgB,CAAC,GAAG,CAClE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACb,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE;YACP,WAAW,EAAE,QAAQ;YACrB,gBAAgB,EAAE,IAAI;YACtB,SAAS,EAAE;gBACT;oBACE,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,kBAAkB;wBACxB,eAAe,EAAE,iBAAiB;qBACnC;oBACD,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,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,76 +1,25 @@
|
|
|
1
|
-
import { type FileNode, type
|
|
1
|
+
import { type FileNode, type GetDocumentOptions, type IDocumentDriveServer, type Node, type SyncStatus } from "document-drive";
|
|
2
2
|
import { type Action, type ActionErrorCallback, type DocumentModelModule, type EditorContext, type EditorModule, type EditorProps, type PHDocument } from "document-model";
|
|
3
3
|
import { type FC } from "react";
|
|
4
|
+
import { type HookState } from "../hooks/document-state.js";
|
|
4
5
|
import { type User } from "../renown/types.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type IDriveContext = {
|
|
6
|
+
import type { UiNode } from "../uiNodes/types.js";
|
|
7
|
+
export interface DriveEditorContext extends Omit<EditorContext, "getDocumentRevision"> {
|
|
8
|
+
/** Reactor instance */
|
|
9
|
+
reactor: IDocumentDriveServer;
|
|
10
10
|
/** Controls the visibility of the search bar in the drive interface */
|
|
11
11
|
showSearchBar: boolean;
|
|
12
12
|
/** Indicates whether the current user has permissions to create new documents */
|
|
13
13
|
isAllowedToCreateDocuments: boolean;
|
|
14
14
|
/** Array of available document models that can be created */
|
|
15
15
|
documentModels: DocumentModelModule[];
|
|
16
|
+
/** Currently selected node (file/folder) in the drive */
|
|
17
|
+
selectedNode: Node | null;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
analyticsDatabaseName: string;
|
|
20
|
-
/**
|
|
21
|
-
* Callback to add a new file to the drive
|
|
22
|
-
* @param file - The file to be added
|
|
23
|
-
* @param parent - The parent node of the file
|
|
24
|
-
* @returns Promise resolving to the newly created Node
|
|
25
|
-
*/
|
|
26
|
-
onAddFile: (file: File, parent: Node | undefined) => Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Callback to add a new folder to the drive
|
|
29
|
-
* @param name - The name of the folder
|
|
30
|
-
* @param parent - The parent node of the folder
|
|
31
|
-
* @returns Promise resolving to the newly created FolderNode
|
|
32
|
-
*/
|
|
33
|
-
onAddFolder: (name: string, parent: Node | undefined) => Promise<FolderNode | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Callback to rename a node
|
|
36
|
-
* @param newName - The new name of the node
|
|
37
|
-
* @param node - The node to be renamed
|
|
38
|
-
* @returns Promise resolving to the newly renamed Node
|
|
39
|
-
*/
|
|
40
|
-
onRenameNode: (newName: string, node: Node) => Promise<Node | undefined>;
|
|
41
|
-
/**
|
|
42
|
-
* Callback to copy a node
|
|
43
|
-
* @param src - The node to be copied
|
|
44
|
-
* @param target - The parent node of the copied node
|
|
45
|
-
* @returns Promise resolving to the newly created Node
|
|
19
|
+
* Callback to update the selected node in the drive
|
|
20
|
+
* @param node - The node to be selected
|
|
46
21
|
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Callback to move a node
|
|
50
|
-
* @param src - The node to be moved
|
|
51
|
-
* @param target - The parent node of the moved node
|
|
52
|
-
* @returns Promise resolving to the newly created Node
|
|
53
|
-
*/
|
|
54
|
-
onMoveNode: (src: Node, target: Node | undefined) => Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Callback to duplicate a node
|
|
57
|
-
* @param src - The node to be duplicated
|
|
58
|
-
* @returns Promise resolving to the newly created Node
|
|
59
|
-
*/
|
|
60
|
-
onDuplicateNode: (src: Node) => Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Callback to add a new folder and select it
|
|
63
|
-
* @param name - The name of the folder
|
|
64
|
-
* @returns Promise resolving to the newly created FolderNode
|
|
65
|
-
*/
|
|
66
|
-
onAddAndSelectNewFolder: (name: string) => Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Callback to get the sync status of a sync
|
|
69
|
-
* @param syncId - The id of the sync
|
|
70
|
-
* @param sharingType - The sharing type of the sync
|
|
71
|
-
* @returns The sync status of the sync, or undefined if not found
|
|
72
|
-
*/
|
|
73
|
-
getSyncStatusSync: (syncId: string, sharingType: "LOCAL" | "CLOUD" | "PUBLIC") => SyncStatus | undefined;
|
|
22
|
+
selectNode: (node: UiNode | null) => void;
|
|
74
23
|
/**
|
|
75
24
|
* Adds a new file to the drive
|
|
76
25
|
* @param file - File to be added (can be a string path or File object)
|
|
@@ -87,46 +36,83 @@ export type IDriveContext = {
|
|
|
87
36
|
* @param documentType - Type of document to create
|
|
88
37
|
* @param parentFolder - Optional parent folder of the document
|
|
89
38
|
* @param document - Optional document content
|
|
90
|
-
* @param id - Optional id for the document
|
|
91
39
|
* @returns Promise resolving to the newly created
|
|
92
40
|
*/
|
|
93
|
-
addDocument: (driveId: string, name: string, documentType: string, parentFolder?: string, document?: PHDocument
|
|
41
|
+
addDocument: (driveId: string, name: string, documentType: string, parentFolder?: string, document?: PHDocument) => Promise<FileNode>;
|
|
94
42
|
/**
|
|
95
43
|
* Shows a modal for creating a new document
|
|
96
44
|
* @param documentModel - Document model of the document to be created
|
|
97
45
|
* @returns Promise resolving to an object containing the document name
|
|
98
46
|
*/
|
|
99
|
-
showCreateDocumentModal: (documentModel: DocumentModelModule) =>
|
|
47
|
+
showCreateDocumentModal: (documentModel: DocumentModelModule) => Promise<{
|
|
48
|
+
name: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves the sync status of a document or drive
|
|
52
|
+
* @param driveId - ID of the drive to check sync status for
|
|
53
|
+
* @param documentId - ID of the document to check sync status for
|
|
54
|
+
* @returns SyncStatus object containing sync information
|
|
55
|
+
*/
|
|
56
|
+
useSyncStatus: (driveId: string, documentId?: string) => SyncStatus | undefined;
|
|
57
|
+
useDocumentEditorProps: (props: {
|
|
58
|
+
driveId: string;
|
|
59
|
+
documentId: string;
|
|
60
|
+
documentType: string;
|
|
61
|
+
documentModelModule: DocumentModelModule<PHDocument>;
|
|
62
|
+
user?: User;
|
|
63
|
+
}) => {
|
|
64
|
+
dispatch: (action: Action, onErrorCallback?: ActionErrorCallback) => void;
|
|
65
|
+
document: PHDocument | undefined;
|
|
66
|
+
error: unknown;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves the states of all documents in a drive
|
|
70
|
+
* @param driveId - ID of the drive to retrieve document states for
|
|
71
|
+
* @param documentIds - IDs of the documents to retrieve states for (all if not provided)
|
|
72
|
+
* @returns Record of document IDs to their states
|
|
73
|
+
*/
|
|
74
|
+
useDriveDocumentStates: (props: {
|
|
75
|
+
driveId: string;
|
|
76
|
+
documentIds?: string[];
|
|
77
|
+
}) => readonly [
|
|
78
|
+
Record<string, HookState>,
|
|
79
|
+
(_driveId: string, _documentIds?: string[]) => Promise<void>
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves the state of a document in a drive
|
|
83
|
+
* @param driveId - ID of the drive to retrieve document state for
|
|
84
|
+
* @param documentId - ID of the document to retrieve state for
|
|
85
|
+
* @type TDocument - Type of the document to retrieve state for if known
|
|
86
|
+
* @returns State of the document
|
|
87
|
+
*/
|
|
88
|
+
useDriveDocumentState: (props: {
|
|
89
|
+
driveId: string;
|
|
90
|
+
documentId: string;
|
|
91
|
+
}) => PHDocument["state"] | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves a document from a specific revision
|
|
94
|
+
* @param documentId - ID of the document to retrieve
|
|
95
|
+
* @param options - Optional configuration options for the retrieval
|
|
96
|
+
* @returns Promise resolving to the document at the specified revision
|
|
97
|
+
*/
|
|
98
|
+
getDocumentRevision?: (documentId: string, options?: GetDocumentOptions) => Promise<PHDocument> | undefined;
|
|
100
99
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param node - The node to be deleted
|
|
100
|
+
* The name of the analytics database to use for the drive editor
|
|
103
101
|
*/
|
|
104
|
-
|
|
102
|
+
analyticsDatabaseName: string;
|
|
105
103
|
/**
|
|
106
104
|
* Retrieves the document model module for a given document type
|
|
107
105
|
* @param documentType - The type of document to retrieve the model for
|
|
108
106
|
* @returns The document model module for the given document type, or undefined if not found
|
|
109
107
|
*/
|
|
110
|
-
getDocumentModelModule: (documentType: string
|
|
108
|
+
getDocumentModelModule: (documentType: string) => DocumentModelModule<PHDocument> | undefined;
|
|
111
109
|
/**
|
|
112
110
|
* Retrieves the editor module for a given document type
|
|
113
111
|
* @param documentType - The type of document to retrieve the editor for
|
|
114
112
|
* @returns The editor module for the given document type, or null if not found
|
|
115
113
|
*/
|
|
116
|
-
getEditor: (documentType: string
|
|
117
|
-
|
|
118
|
-
driveId: string | undefined;
|
|
119
|
-
documentId: string | undefined;
|
|
120
|
-
documentType: string | undefined;
|
|
121
|
-
documentModelModule: DocumentModelModule<PHDocument> | undefined;
|
|
122
|
-
user?: User;
|
|
123
|
-
}) => {
|
|
124
|
-
dispatch: (action: Action, onErrorCallback?: ActionErrorCallback) => void;
|
|
125
|
-
document: PHDocument | undefined;
|
|
126
|
-
error: unknown;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
export type DriveEditorContext = Omit<EditorContext, "getDocumentRevision"> & IDriveContext;
|
|
114
|
+
getEditor: (documentType: string) => EditorModule | null | undefined;
|
|
115
|
+
}
|
|
130
116
|
export interface DriveEditorProps<TDocument extends PHDocument> extends Omit<EditorProps<TDocument>, "context"> {
|
|
131
117
|
context: DriveEditorContext;
|
|
132
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drive-editor.d.ts","sourceRoot":"","sources":["../../../src/types/drive-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,
|
|
1
|
+
{"version":3,"file":"drive-editor.d.ts","sourceRoot":"","sources":["../../../src/types/drive-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,IAAI,EACT,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,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AIG;IACH,sBAAsB,EAAE,CACtB,YAAY,EAAE,MAAM,KACjB,mBAAmB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;IAEjD;;;;OAIG;IACH,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;CACtE;AACD,MAAM,WAAW,gBAAgB,CAAC,SAAS,SAAS,UAAU,CAC5D,SAAQ,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/C,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,MAAM,iBAAiB,CAC3B,SAAS,SAAS,UAAU,GAAG,UAAU,EACzC,YAAY,GAAG,OAAO,EACtB,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACrE;IACF,SAAS,EAAE,EAAE,CACX,gBAAgB,CAAC,SAAS,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACrE,CAAC;IACF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,aAAa,GAAG;QACtB,EAAE,EAAE,MAAM,CAAC;QACX,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;CACH,CAAC"}
|
|
@@ -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,24 @@
|
|
|
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
|
+
];
|
|
24
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/uiNodes/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE/B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAE5D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAU,CAAC;AAEnE,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE/B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY;IACZ,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,KAAK;CACG,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Maybe, type SynchronizationUnitInput } from "document-model";
|
|
2
|
+
import { type DRIVE, type driveLocations, type FILE, type FOLDER, type sharingTypes, type 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,KAAK,EAAE,KAAK,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EACL,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC;AAC/C,MAAM,MAAM,WAAW,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