Merge branch 'canary' into stable

This commit is contained in:
李华桥
2023-11-23 21:31:42 +08:00
357 changed files with 16759 additions and 12832 deletions
+8 -12
View File
@@ -8,7 +8,7 @@
"dependencies": {
"foxact": "^0.2.20",
"image-blob-reduce": "^4.1.0",
"jotai": "^2.4.3",
"jotai": "^2.5.1",
"lodash.debounce": "^4.0.8",
"p-queue": "^7.4.1",
"react": "18.2.0",
@@ -18,12 +18,12 @@
"devDependencies": {
"@affine/debug": "workspace:*",
"@affine/env": "workspace:*",
"@blocksuite/block-std": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/blocks": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/editor": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/global": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/lit": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/store": "0.0.0-20231116023037-31273bb7-nightly",
"@blocksuite/block-std": "0.0.0-20231122113751-6bf81eb3-nightly",
"@blocksuite/blocks": "0.0.0-20231122113751-6bf81eb3-nightly",
"@blocksuite/editor": "0.0.0-20231122113751-6bf81eb3-nightly",
"@blocksuite/global": "0.0.0-20231122113751-6bf81eb3-nightly",
"@blocksuite/lit": "0.0.0-20231122113751-6bf81eb3-nightly",
"@blocksuite/store": "0.0.0-20231122113751-6bf81eb3-nightly",
"@testing-library/react": "^14.0.0",
"@types/image-blob-reduce": "^4.1.3",
"@types/lodash.debounce": "^4.0.7",
@@ -36,7 +36,6 @@
"@blocksuite/blocks": "*",
"@blocksuite/editor": "*",
"@blocksuite/global": "*",
"@blocksuite/lit": "*",
"@blocksuite/store": "*",
"y-provider": "workspace:*"
},
@@ -56,9 +55,6 @@
"@blocksuite/global": {
"optional": true
},
"@blocksuite/lit": {
"optional": true
},
"@blocksuite/store": {
"optional": true
},
@@ -66,5 +62,5 @@
"optional": true
}
},
"version": "0.10.2"
"version": "0.10.3-canary.2"
}
@@ -0,0 +1,29 @@
import React from 'react';
export type AsyncErrorHandler = (error: Error) => void;
/**
* App should provide a global error handler for async callback in the root.
*/
export const AsyncCallbackContext = React.createContext<AsyncErrorHandler>(
e => {
console.error(e);
}
);
/**
* Translate async function to sync function and handle error automatically.
* Only accept void function, return data here is meaningless.
*/
export function useAsyncCallback<T extends any[]>(
callback: (...args: T) => Promise<void>,
deps: any[]
): (...args: T) => void {
const handleAsyncError = React.useContext(AsyncCallbackContext);
return React.useCallback(
(...args: any) => {
callback(...args).catch(e => handleAsyncError(e));
},
[...deps] // eslint-disable-line react-hooks/exhaustive-deps
);
}