@powerhousedao/connect 1.0.0-dev.211 → 1.0.0-dev.212

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 (27) hide show
  1. package/dist/assets/{app-ec_tqKyy.js → app-B4copOtg.js} +185 -184
  2. package/dist/assets/{app-loader-D_w1htsM.js → app-loader-B6zf9XDU.js} +4 -4
  3. package/dist/assets/{browser-Ccv5jMQ2.js → browser-CZOApPej.js} +5 -5
  4. package/dist/assets/{ccip-BINxWLhB.js → ccip-DSVOeeDo.js} +5 -5
  5. package/dist/assets/{content-xyBITmn7.js → content-gm9A__42.js} +26 -8
  6. package/dist/assets/{getEnsName-DtQ0D82H.js → getEnsName-CH6-GxaA.js} +4 -4
  7. package/dist/assets/{index-B76kqOWF.js → index-BC1qgOnG.js} +3 -3
  8. package/dist/assets/{index-F6sLtgJX.js → index-BcQMOuWz.js} +3 -3
  9. package/dist/assets/{index-DMwoEUPC.js → index-Dv_4E7Nh.js} +3 -3
  10. package/dist/assets/{isAddressEqual-CVC2WsAk.js → isAddressEqual-D8xUWIQc.js} +1 -1
  11. package/dist/assets/{main.CyEpz8Xq.js → main.DUq7r3yO.js} +1 -1
  12. package/dist/assets/{react-error-boundary.esm-CSTN2MP_.js → react-error-boundary.esm-CCUHjIRz.js} +2 -2
  13. package/dist/assets/{root-wxc1EfqI.js → root-D_xEwT-n.js} +6 -6
  14. package/dist/assets/{router-BJrY_t-B.js → router-626xhE7A.js} +6 -6
  15. package/dist/index.html +1 -1
  16. package/dist/modules/@powerhousedao/reactor-browser/{chunk-5Q3OAWSW.js → chunk-ENCBIPGB.js} +8 -4
  17. package/dist/modules/@powerhousedao/reactor-browser/chunk-ENCBIPGB.js.map +7 -0
  18. package/dist/modules/@powerhousedao/reactor-browser/{chunk-NG3UCFCH.js → chunk-L7DUL4YO.js} +15 -6
  19. package/dist/modules/@powerhousedao/reactor-browser/chunk-L7DUL4YO.js.map +7 -0
  20. package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +5 -3
  21. package/dist/modules/@powerhousedao/reactor-browser/hooks/useAddDebouncedOperations.js +1 -1
  22. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentEditor.js +6 -4
  23. package/dist/modules/@powerhousedao/reactor-browser/index.js +5 -3
  24. package/dist/vite-envs.sh +1 -1
  25. package/package.json +7 -7
  26. package/dist/modules/@powerhousedao/reactor-browser/chunk-5Q3OAWSW.js.map +0 -7
  27. package/dist/modules/@powerhousedao/reactor-browser/chunk-NG3UCFCH.js.map +0 -7
package/dist/index.html CHANGED
@@ -59,7 +59,7 @@
59
59
  );
60
60
  });
61
61
  window.__VITE_ENVS = env;
62
- </script><script type="module" crossorigin="" src="/assets/main.CyEpz8Xq.js"></script><script type="importmap">{
62
+ </script><script type="module" crossorigin="" src="/assets/main.DUq7r3yO.js"></script><script type="importmap">{
63
63
  "imports": {
64
64
  "react": "https://esm.sh/react",
65
65
  "react/": "https://esm.sh/react/",
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-DVMSG5VM.js";
7
7
 
8
8
  // ../../packages/reactor-browser/dist/src/hooks/useAddDebouncedOperations.js
9
- import { useCallback, useMemo } from "react";
9
+ import { useCallback, useEffect, useMemo, useRef } from "react";
10
10
  function debounceOperations(callback, timeout = 50) {
11
11
  let timer;
12
12
  const operations = [];
@@ -34,10 +34,14 @@ function debounceOperations(callback, timeout = 50) {
34
34
  function useAddDebouncedOperations(reactor, props) {
35
35
  const { driveId, documentId } = props;
36
36
  const [documentDrives] = useDocumentDrives(reactor);
37
+ const documentDrivesRef = useRef(documentDrives);
37
38
  const { isAllowedToEditDocuments } = useUserPermissions() || {
38
39
  isAllowedToCreateDocuments: false,
39
40
  isAllowedToEditDocuments: false
40
41
  };
42
+ useEffect(() => {
43
+ documentDrivesRef.current = documentDrives;
44
+ }, [documentDrives]);
41
45
  const addOperations = useCallback(async (driveId2, id, operations) => {
42
46
  if (!isAllowedToEditDocuments) {
43
47
  throw new Error("User is not allowed to edit documents");
@@ -45,13 +49,13 @@ function useAddDebouncedOperations(reactor, props) {
45
49
  if (!reactor) {
46
50
  throw new Error("Reactor is not loaded");
47
51
  }
48
- const drive = documentDrives.find((drive2) => drive2.state.global.id === driveId2);
52
+ const drive = documentDrivesRef.current.find((drive2) => drive2.state.global.id === driveId2);
49
53
  if (!drive) {
50
54
  throw new Error(`Drive with id ${driveId2} not found`);
51
55
  }
52
56
  const newDocument = await reactor.queueOperations(driveId2, id, operations);
53
57
  return newDocument.document;
54
- }, [documentDrives, isAllowedToEditDocuments, reactor]);
58
+ }, [isAllowedToEditDocuments, reactor]);
55
59
  const addDebouncedOperations = useMemo(() => {
56
60
  return debounceOperations((operations) => addOperations(driveId, documentId, operations));
57
61
  }, [addOperations, driveId, documentId]);
@@ -61,4 +65,4 @@ function useAddDebouncedOperations(reactor, props) {
61
65
  export {
62
66
  useAddDebouncedOperations
63
67
  };
64
- //# sourceMappingURL=chunk-5Q3OAWSW.js.map
68
+ //# sourceMappingURL=chunk-ENCBIPGB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../packages/reactor-browser/dist/src/hooks/useAddDebouncedOperations.js"],
4
+ "sourcesContent": ["import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { useDocumentDrives } from \"./useDocumentDrives.js\";\nimport { useUserPermissions } from \"./useUserPermissions.js\";\nfunction debounceOperations(callback, timeout = 50) {\n let timer;\n const operations = [];\n return (operation) => {\n if (timer) {\n clearTimeout(timer);\n }\n const index = operations.findIndex((op) => op.scope === operation.scope && op.index === operation.index);\n if (index > -1) {\n const oldOperation = operations[index];\n if (!(oldOperation.type === operation.type &&\n JSON.stringify(operation.input) === JSON.stringify(oldOperation.input))) {\n console.warn(\"Two conflicting operations were dispatched:\", oldOperation, operation);\n }\n operations[index] = operation;\n }\n else {\n operations.push(operation);\n }\n return new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n callback(operations).then(resolve).catch(reject);\n }, timeout);\n });\n };\n}\nexport function useAddDebouncedOperations(reactor, props) {\n const { driveId, documentId } = props;\n const [documentDrives] = useDocumentDrives(reactor);\n const documentDrivesRef = useRef(documentDrives);\n const { isAllowedToEditDocuments } = useUserPermissions() || {\n isAllowedToCreateDocuments: false,\n isAllowedToEditDocuments: false,\n };\n useEffect(() => {\n documentDrivesRef.current = documentDrives;\n }, [documentDrives]);\n const addOperations = useCallback(async (driveId, id, operations) => {\n if (!isAllowedToEditDocuments) {\n throw new Error(\"User is not allowed to edit documents\");\n }\n if (!reactor) {\n throw new Error(\"Reactor is not loaded\");\n }\n const drive = documentDrivesRef.current.find((drive) => drive.state.global.id === driveId);\n if (!drive) {\n throw new Error(`Drive with id ${driveId} not found`);\n }\n const newDocument = await reactor.queueOperations(driveId, id, operations);\n return newDocument.document;\n }, [isAllowedToEditDocuments, reactor]);\n const addDebouncedOperations = useMemo(() => {\n return debounceOperations((operations) => addOperations(driveId, documentId, operations));\n }, [addOperations, driveId, documentId]);\n return addDebouncedOperations;\n}\n"],
5
+ "mappings": ";;;;;;;;AAAA,SAAS,aAAa,WAAW,SAAS,cAAc;AAGxD,SAAS,mBAAmB,UAAU,UAAU,IAAI;AAChD,MAAI;AACJ,QAAM,aAAa,CAAC;AACpB,SAAO,CAAC,cAAc;AAClB,QAAI,OAAO;AACP,mBAAa,KAAK;AAAA,IACtB;AACA,UAAM,QAAQ,WAAW,UAAU,CAAC,OAAO,GAAG,UAAU,UAAU,SAAS,GAAG,UAAU,UAAU,KAAK;AACvG,QAAI,QAAQ,IAAI;AACZ,YAAM,eAAe,WAAW,KAAK;AACrC,UAAI,EAAE,aAAa,SAAS,UAAU,QAClC,KAAK,UAAU,UAAU,KAAK,MAAM,KAAK,UAAU,aAAa,KAAK,IAAI;AACzE,gBAAQ,KAAK,+CAA+C,cAAc,SAAS;AAAA,MACvF;AACA,iBAAW,KAAK,IAAI;AAAA,IACxB,OACK;AACD,iBAAW,KAAK,SAAS;AAAA,IAC7B;AACA,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,cAAQ,WAAW,MAAM;AACrB,iBAAS,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM;AAAA,MACnD,GAAG,OAAO;AAAA,IACd,CAAC;AAAA,EACL;AACJ;AACO,SAAS,0BAA0B,SAAS,OAAO;AACtD,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,QAAM,CAAC,cAAc,IAAI,kBAAkB,OAAO;AAClD,QAAM,oBAAoB,OAAO,cAAc;AAC/C,QAAM,EAAE,yBAAyB,IAAI,mBAAmB,KAAK;AAAA,IACzD,4BAA4B;AAAA,IAC5B,0BAA0B;AAAA,EAC9B;AACA,YAAU,MAAM;AACZ,sBAAkB,UAAU;AAAA,EAChC,GAAG,CAAC,cAAc,CAAC;AACnB,QAAM,gBAAgB,YAAY,OAAOA,UAAS,IAAI,eAAe;AACjE,QAAI,CAAC,0BAA0B;AAC3B,YAAM,IAAI,MAAM,uCAAuC;AAAA,IAC3D;AACA,QAAI,CAAC,SAAS;AACV,YAAM,IAAI,MAAM,uBAAuB;AAAA,IAC3C;AACA,UAAM,QAAQ,kBAAkB,QAAQ,KAAK,CAACC,WAAUA,OAAM,MAAM,OAAO,OAAOD,QAAO;AACzF,QAAI,CAAC,OAAO;AACR,YAAM,IAAI,MAAM,iBAAiBA,QAAO,YAAY;AAAA,IACxD;AACA,UAAM,cAAc,MAAM,QAAQ,gBAAgBA,UAAS,IAAI,UAAU;AACzE,WAAO,YAAY;AAAA,EACvB,GAAG,CAAC,0BAA0B,OAAO,CAAC;AACtC,QAAM,yBAAyB,QAAQ,MAAM;AACzC,WAAO,mBAAmB,CAAC,eAAe,cAAc,SAAS,YAAY,UAAU,CAAC;AAAA,EAC5F,GAAG,CAAC,eAAe,SAAS,UAAU,CAAC;AACvC,SAAO;AACX;",
6
+ "names": ["driveId", "drive"]
7
+ }
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-ARAPK5F3.js";
5
5
  import {
6
6
  useAddDebouncedOperations
7
- } from "./chunk-5Q3OAWSW.js";
7
+ } from "./chunk-ENCBIPGB.js";
8
8
  import {
9
9
  useConnectCrypto,
10
10
  useConnectDid
@@ -14,10 +14,8 @@ import {
14
14
  } from "./chunk-ULBB7S2G.js";
15
15
 
16
16
  // ../../packages/reactor-browser/dist/src/hooks/useDocumentEditor.js
17
- function useDocumentEditor(reactor, props) {
18
- const { nodeId, driveId, documentModelModule, document: initialDocument, user } = props;
19
- const connectDid = useConnectDid();
20
- const { sign } = useConnectCrypto();
17
+ function useDocumentEditorProps(reactor, props) {
18
+ const { nodeId, driveId, documentModelModule, document: initialDocument, user, connectDid, sign } = props;
21
19
  const addDebouncedOprations = useAddDebouncedOperations(reactor, {
22
20
  driveId,
23
21
  documentId: nodeId
@@ -38,8 +36,19 @@ function useDocumentEditor(reactor, props) {
38
36
  error
39
37
  };
40
38
  }
39
+ function useDocumentEditor(reactor, props) {
40
+ const connectDid = useConnectDid();
41
+ const { sign } = useConnectCrypto();
42
+ const documentEditorDispatch = useDocumentEditorProps(reactor, {
43
+ ...props,
44
+ connectDid,
45
+ sign
46
+ });
47
+ return documentEditorDispatch;
48
+ }
41
49
 
42
50
  export {
51
+ useDocumentEditorProps,
43
52
  useDocumentEditor
44
53
  };
45
- //# sourceMappingURL=chunk-NG3UCFCH.js.map
54
+ //# sourceMappingURL=chunk-L7DUL4YO.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../packages/reactor-browser/dist/src/hooks/useDocumentEditor.js"],
4
+ "sourcesContent": ["import { addActionContext, signOperation } from \"../utils/signature.js\";\nimport { useAddDebouncedOperations } from \"./useAddDebouncedOperations.js\";\nimport { useConnectCrypto, useConnectDid } from \"./useConnectCrypto.js\";\nimport { useDocumentDispatch } from \"./useDocumentDispatch.js\";\nexport function useDocumentEditorProps(reactor, props) {\n const { nodeId, driveId, documentModelModule, document: initialDocument, user, connectDid, sign, } = props;\n const addDebouncedOprations = useAddDebouncedOperations(reactor, {\n driveId,\n documentId: nodeId,\n });\n const [document, _dispatch, error] = useDocumentDispatch(documentModelModule.reducer, initialDocument);\n function dispatch(action, onErrorCallback) {\n const callback = (operation, state) => {\n const { prevState } = state;\n signOperation(operation, sign, nodeId, prevState, documentModelModule.reducer, user)\n .then((op) => {\n return addDebouncedOprations(op);\n })\n .catch(console.error);\n };\n _dispatch(addActionContext(action, connectDid, user), callback, onErrorCallback);\n }\n return {\n dispatch,\n document,\n error,\n };\n}\nexport function useDocumentEditor(reactor, props) {\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n const documentEditorDispatch = useDocumentEditorProps(reactor, {\n ...props,\n connectDid,\n sign,\n });\n return documentEditorDispatch;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAIO,SAAS,uBAAuB,SAAS,OAAO;AACnD,QAAM,EAAE,QAAQ,SAAS,qBAAqB,UAAU,iBAAiB,MAAM,YAAY,KAAM,IAAI;AACrG,QAAM,wBAAwB,0BAA0B,SAAS;AAAA,IAC7D;AAAA,IACA,YAAY;AAAA,EAChB,CAAC;AACD,QAAM,CAAC,UAAU,WAAW,KAAK,IAAI,oBAAoB,oBAAoB,SAAS,eAAe;AACrG,WAAS,SAAS,QAAQ,iBAAiB;AACvC,UAAM,WAAW,CAAC,WAAW,UAAU;AACnC,YAAM,EAAE,UAAU,IAAI;AACtB,oBAAc,WAAW,MAAM,QAAQ,WAAW,oBAAoB,SAAS,IAAI,EAC9E,KAAK,CAAC,OAAO;AACd,eAAO,sBAAsB,EAAE;AAAA,MACnC,CAAC,EACI,MAAM,QAAQ,KAAK;AAAA,IAC5B;AACA,cAAU,iBAAiB,QAAQ,YAAY,IAAI,GAAG,UAAU,eAAe;AAAA,EACnF;AACA,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AACO,SAAS,kBAAkB,SAAS,OAAO;AAC9C,QAAM,aAAa,cAAc;AACjC,QAAM,EAAE,KAAK,IAAI,iBAAiB;AAClC,QAAM,yBAAyB,uBAAuB,SAAS;AAAA,IAC3D,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACJ,CAAC;AACD,SAAO;AACX;",
6
+ "names": []
7
+ }
@@ -37,10 +37,11 @@ import {
37
37
  useDocument
38
38
  } from "../chunk-UVZMZ4MR.js";
39
39
  import {
40
- useDocumentEditor
41
- } from "../chunk-NG3UCFCH.js";
40
+ useDocumentEditor,
41
+ useDocumentEditorProps
42
+ } from "../chunk-L7DUL4YO.js";
42
43
  import "../chunk-ARAPK5F3.js";
43
- import "../chunk-5Q3OAWSW.js";
44
+ import "../chunk-ENCBIPGB.js";
44
45
  import {
45
46
  useConnectCrypto,
46
47
  useConnectDid
@@ -88,6 +89,7 @@ export {
88
89
  useDocument,
89
90
  useDocumentDrives,
90
91
  useDocumentEditor,
92
+ useDocumentEditorProps,
91
93
  useDriveActions,
92
94
  useDriveActionsWithUiNodes,
93
95
  useDriveContext,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useAddDebouncedOperations
3
- } from "../chunk-5Q3OAWSW.js";
3
+ } from "../chunk-ENCBIPGB.js";
4
4
  import "../chunk-VNJW3K7R.js";
5
5
  import "../chunk-YAO66KBZ.js";
6
6
  import "../chunk-DVMSG5VM.js";
@@ -1,8 +1,9 @@
1
1
  import {
2
- useDocumentEditor
3
- } from "../chunk-NG3UCFCH.js";
2
+ useDocumentEditor,
3
+ useDocumentEditorProps
4
+ } from "../chunk-L7DUL4YO.js";
4
5
  import "../chunk-ARAPK5F3.js";
5
- import "../chunk-5Q3OAWSW.js";
6
+ import "../chunk-ENCBIPGB.js";
6
7
  import "../chunk-PRKHJCY6.js";
7
8
  import "../chunk-ULBB7S2G.js";
8
9
  import "../chunk-VNJW3K7R.js";
@@ -14,6 +15,7 @@ import "../chunk-GWYLZGKO.js";
14
15
  import "../chunk-SDNEXZQH.js";
15
16
  import "../chunk-PLDDJCW6.js";
16
17
  export {
17
- useDocumentEditor
18
+ useDocumentEditor,
19
+ useDocumentEditorProps
18
20
  };
19
21
  //# sourceMappingURL=useDocumentEditor.js.map
@@ -38,10 +38,11 @@ import {
38
38
  useDocument
39
39
  } from "./chunk-UVZMZ4MR.js";
40
40
  import {
41
- useDocumentEditor
42
- } from "./chunk-NG3UCFCH.js";
41
+ useDocumentEditor,
42
+ useDocumentEditorProps
43
+ } from "./chunk-L7DUL4YO.js";
43
44
  import "./chunk-ARAPK5F3.js";
44
- import "./chunk-5Q3OAWSW.js";
45
+ import "./chunk-ENCBIPGB.js";
45
46
  import {
46
47
  useConnectCrypto,
47
48
  useConnectDid
@@ -109,6 +110,7 @@ export {
109
110
  useDocument,
110
111
  useDocumentDrives,
111
112
  useDocumentEditor,
113
+ useDocumentEditorProps,
112
114
  useDriveActions,
113
115
  useDriveActionsWithUiNodes,
114
116
  useDriveContext,
package/dist/vite-envs.sh CHANGED
@@ -11,7 +11,7 @@ replaceAll() {
11
11
  }'
12
12
  }
13
13
 
14
- html=$(echo "PCFET0NUWVBFIGh0bWw+PGh0bWw+PGhlYWQ+PG1ldGEgY2hhcnNldD0iVVRGLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsaW5pdGlhbC1zY2FsZT0xIj48dGl0bGU+UG93ZXJob3VzZSBDb25uZWN0PC90aXRsZT48YmFzZSBocmVmPSIvIj48IS0tIHZpdGUtZW52cyBzY3JpcHQgcGxhY2Vob2xkZXIgeEtzUG1MczMwc3dLc2RJc1Z4IC0tPjxzY3JpcHQgdHlwZT0ibW9kdWxlIiBjcm9zc29yaWdpbj0iIiBzcmM9Ii9hc3NldHMvbWFpbi5DeUVwejhYcS5qcyI+PC9zY3JpcHQ+PC9oZWFkPjxib2R5PjxkaXYgaWQ9ImFwcCI+PC9kaXY+PC9ib2R5PjwvaHRtbD4=" | base64 -d)
14
+ html=$(echo "PCFET0NUWVBFIGh0bWw+PGh0bWw+PGhlYWQ+PG1ldGEgY2hhcnNldD0iVVRGLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsaW5pdGlhbC1zY2FsZT0xIj48dGl0bGU+UG93ZXJob3VzZSBDb25uZWN0PC90aXRsZT48YmFzZSBocmVmPSIvIj48IS0tIHZpdGUtZW52cyBzY3JpcHQgcGxhY2Vob2xkZXIgeEtzUG1MczMwc3dLc2RJc1Z4IC0tPjxzY3JpcHQgdHlwZT0ibW9kdWxlIiBjcm9zc29yaWdpbj0iIiBzcmM9Ii9hc3NldHMvbWFpbi5EVXE3cjN5Ty5qcyI+PC9zY3JpcHQ+PC9oZWFkPjxib2R5PjxkaXYgaWQ9ImFwcCI+PC9kaXY+PC9ib2R5PjwvaHRtbD4=" | base64 -d)
15
15
 
16
16
  BASE_URL_base64="eEFwV2RSclg5OWtQclZnZ0UiLyIK"
17
17
  BASE_URL=$(echo "Lwo=" | base64 -d)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/connect",
3
3
  "productName": "Powerhouse-Connect",
4
- "version": "1.0.0-dev.211",
4
+ "version": "1.0.0-dev.212",
5
5
  "description": "Powerhouse Connect",
6
6
  "main": "./dist/index.html",
7
7
  "imports": {
@@ -29,7 +29,7 @@
29
29
  "magic-string": "^0.30.17"
30
30
  },
31
31
  "peerDependencies": {
32
- "@powerhousedao/design-system": "1.29.5"
32
+ "@powerhousedao/design-system": "1.29.6"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@electron-forge/cli": "^6.1.1",
@@ -94,13 +94,13 @@
94
94
  "vite-plugin-svgr": "^4.2.0",
95
95
  "vite-tsconfig-paths": "^4.2.0",
96
96
  "xvfb-maybe": "^0.2.1",
97
- "@powerhousedao/builder-tools": "0.2.6",
98
- "@powerhousedao/common": "1.3.5",
97
+ "@powerhousedao/common": "1.4.0",
98
+ "@powerhousedao/builder-tools": "0.2.7",
99
+ "@powerhousedao/design-system": "1.29.6",
100
+ "@powerhousedao/reactor-browser": "1.13.0",
99
101
  "@powerhousedao/config": "1.18.2",
100
- "@powerhousedao/design-system": "1.29.5",
101
- "@powerhousedao/reactor-browser": "1.12.0",
102
102
  "@powerhousedao/scalars": "1.25.1",
103
- "document-drive": "1.21.0",
103
+ "document-drive": "1.21.1",
104
104
  "document-model": "2.21.1"
105
105
  },
106
106
  "optionalDependencies": {
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../packages/reactor-browser/dist/src/hooks/useAddDebouncedOperations.js"],
4
- "sourcesContent": ["import { useCallback, useMemo } from \"react\";\nimport { useDocumentDrives } from \"./useDocumentDrives.js\";\nimport { useUserPermissions } from \"./useUserPermissions.js\";\nfunction debounceOperations(callback, timeout = 50) {\n let timer;\n const operations = [];\n return (operation) => {\n if (timer) {\n clearTimeout(timer);\n }\n const index = operations.findIndex((op) => op.scope === operation.scope && op.index === operation.index);\n if (index > -1) {\n const oldOperation = operations[index];\n if (!(oldOperation.type === operation.type &&\n JSON.stringify(operation.input) === JSON.stringify(oldOperation.input))) {\n console.warn(\"Two conflicting operations were dispatched:\", oldOperation, operation);\n }\n operations[index] = operation;\n }\n else {\n operations.push(operation);\n }\n return new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n callback(operations).then(resolve).catch(reject);\n }, timeout);\n });\n };\n}\nexport function useAddDebouncedOperations(reactor, props) {\n const { driveId, documentId } = props;\n const [documentDrives] = useDocumentDrives(reactor);\n const { isAllowedToEditDocuments } = useUserPermissions() || {\n isAllowedToCreateDocuments: false,\n isAllowedToEditDocuments: false,\n };\n const addOperations = useCallback(async (driveId, id, operations) => {\n if (!isAllowedToEditDocuments) {\n throw new Error(\"User is not allowed to edit documents\");\n }\n if (!reactor) {\n throw new Error(\"Reactor is not loaded\");\n }\n const drive = documentDrives.find((drive) => drive.state.global.id === driveId);\n if (!drive) {\n throw new Error(`Drive with id ${driveId} not found`);\n }\n const newDocument = await reactor.queueOperations(driveId, id, operations);\n return newDocument.document;\n }, [documentDrives, isAllowedToEditDocuments, reactor]);\n const addDebouncedOperations = useMemo(() => {\n return debounceOperations((operations) => addOperations(driveId, documentId, operations));\n }, [addOperations, driveId, documentId]);\n return addDebouncedOperations;\n}\n"],
5
- "mappings": ";;;;;;;;AAAA,SAAS,aAAa,eAAe;AAGrC,SAAS,mBAAmB,UAAU,UAAU,IAAI;AAChD,MAAI;AACJ,QAAM,aAAa,CAAC;AACpB,SAAO,CAAC,cAAc;AAClB,QAAI,OAAO;AACP,mBAAa,KAAK;AAAA,IACtB;AACA,UAAM,QAAQ,WAAW,UAAU,CAAC,OAAO,GAAG,UAAU,UAAU,SAAS,GAAG,UAAU,UAAU,KAAK;AACvG,QAAI,QAAQ,IAAI;AACZ,YAAM,eAAe,WAAW,KAAK;AACrC,UAAI,EAAE,aAAa,SAAS,UAAU,QAClC,KAAK,UAAU,UAAU,KAAK,MAAM,KAAK,UAAU,aAAa,KAAK,IAAI;AACzE,gBAAQ,KAAK,+CAA+C,cAAc,SAAS;AAAA,MACvF;AACA,iBAAW,KAAK,IAAI;AAAA,IACxB,OACK;AACD,iBAAW,KAAK,SAAS;AAAA,IAC7B;AACA,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,cAAQ,WAAW,MAAM;AACrB,iBAAS,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM;AAAA,MACnD,GAAG,OAAO;AAAA,IACd,CAAC;AAAA,EACL;AACJ;AACO,SAAS,0BAA0B,SAAS,OAAO;AACtD,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,QAAM,CAAC,cAAc,IAAI,kBAAkB,OAAO;AAClD,QAAM,EAAE,yBAAyB,IAAI,mBAAmB,KAAK;AAAA,IACzD,4BAA4B;AAAA,IAC5B,0BAA0B;AAAA,EAC9B;AACA,QAAM,gBAAgB,YAAY,OAAOA,UAAS,IAAI,eAAe;AACjE,QAAI,CAAC,0BAA0B;AAC3B,YAAM,IAAI,MAAM,uCAAuC;AAAA,IAC3D;AACA,QAAI,CAAC,SAAS;AACV,YAAM,IAAI,MAAM,uBAAuB;AAAA,IAC3C;AACA,UAAM,QAAQ,eAAe,KAAK,CAACC,WAAUA,OAAM,MAAM,OAAO,OAAOD,QAAO;AAC9E,QAAI,CAAC,OAAO;AACR,YAAM,IAAI,MAAM,iBAAiBA,QAAO,YAAY;AAAA,IACxD;AACA,UAAM,cAAc,MAAM,QAAQ,gBAAgBA,UAAS,IAAI,UAAU;AACzE,WAAO,YAAY;AAAA,EACvB,GAAG,CAAC,gBAAgB,0BAA0B,OAAO,CAAC;AACtD,QAAM,yBAAyB,QAAQ,MAAM;AACzC,WAAO,mBAAmB,CAAC,eAAe,cAAc,SAAS,YAAY,UAAU,CAAC;AAAA,EAC5F,GAAG,CAAC,eAAe,SAAS,UAAU,CAAC;AACvC,SAAO;AACX;",
6
- "names": ["driveId", "drive"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../packages/reactor-browser/dist/src/hooks/useDocumentEditor.js"],
4
- "sourcesContent": ["import { addActionContext, signOperation } from \"../utils/signature.js\";\nimport { useAddDebouncedOperations } from \"./useAddDebouncedOperations.js\";\nimport { useConnectCrypto, useConnectDid } from \"./useConnectCrypto.js\";\nimport { useDocumentDispatch } from \"./useDocumentDispatch.js\";\nexport function useDocumentEditor(reactor, props) {\n const { nodeId, driveId, documentModelModule, document: initialDocument, user, } = props;\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n const addDebouncedOprations = useAddDebouncedOperations(reactor, {\n driveId,\n documentId: nodeId,\n });\n const [document, _dispatch, error] = useDocumentDispatch(documentModelModule.reducer, initialDocument);\n function dispatch(action, onErrorCallback) {\n const callback = (operation, state) => {\n const { prevState } = state;\n signOperation(operation, sign, nodeId, prevState, documentModelModule.reducer, user)\n .then((op) => {\n return addDebouncedOprations(op);\n })\n .catch(console.error);\n };\n _dispatch(addActionContext(action, connectDid, user), callback, onErrorCallback);\n }\n return {\n dispatch,\n document,\n error,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAIO,SAAS,kBAAkB,SAAS,OAAO;AAC9C,QAAM,EAAE,QAAQ,SAAS,qBAAqB,UAAU,iBAAiB,KAAM,IAAI;AACnF,QAAM,aAAa,cAAc;AACjC,QAAM,EAAE,KAAK,IAAI,iBAAiB;AAClC,QAAM,wBAAwB,0BAA0B,SAAS;AAAA,IAC7D;AAAA,IACA,YAAY;AAAA,EAChB,CAAC;AACD,QAAM,CAAC,UAAU,WAAW,KAAK,IAAI,oBAAoB,oBAAoB,SAAS,eAAe;AACrG,WAAS,SAAS,QAAQ,iBAAiB;AACvC,UAAM,WAAW,CAAC,WAAW,UAAU;AACnC,YAAM,EAAE,UAAU,IAAI;AACtB,oBAAc,WAAW,MAAM,QAAQ,WAAW,oBAAoB,SAAS,IAAI,EAC9E,KAAK,CAAC,OAAO;AACd,eAAO,sBAAsB,EAAE;AAAA,MACnC,CAAC,EACI,MAAM,QAAQ,KAAK;AAAA,IAC5B;AACA,cAAU,iBAAiB,QAAQ,YAAY,IAAI,GAAG,UAAU,eAAe;AAAA,EACnF;AACA,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;",
6
- "names": []
7
- }