@shopify/react-native-skia 0.1.140 → 0.1.143
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +2 -2
- package/android/cpp/rnskia-android/RNSkDrawViewImpl.h +1 -1
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +15 -16
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDrawView.java +69 -27
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +7 -1
- package/cpp/rnskia/RNSkDrawView.cpp +66 -66
- package/cpp/rnskia/RNSkDrawView.h +22 -6
- package/cpp/rnskia/RNSkJsiViewApi.h +2 -2
- package/cpp/rnskia/values/RNSkComputedValue.h +10 -7
- package/cpp/rnskia/values/RNSkReadonlyValue.h +21 -2
- package/cpp/rnskia/values/RNSkValue.h +1 -0
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +1 -1
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -2
- package/ios/RNSkia-iOS/SkiaDrawView.mm +4 -0
- package/lib/commonjs/mock/index.js +3 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/DependencyManager.js +1 -1
- package/lib/commonjs/renderer/DependencyManager.js.map +1 -1
- package/lib/commonjs/renderer/components/Blend.js +20 -5
- package/lib/commonjs/renderer/components/Blend.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/commonjs/renderer/processors/Animations/Animations.js +18 -5
- package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/commonjs/skia/core/Data.js +10 -22
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/core/Font.js +2 -3
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/core/SVG.js.map +1 -1
- package/lib/commonjs/skia/core/Typeface.js.map +1 -1
- package/lib/commonjs/skia/types/Data/Data.js +5 -0
- package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +12 -21
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +50 -28
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +15 -6
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +16 -60
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +5 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js +9 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js +3 -3
- package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +12 -6
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/values/hooks/useComputedValue.js +6 -2
- package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
- package/lib/commonjs/values/index.js +13 -0
- package/lib/commonjs/values/index.js.map +1 -1
- package/lib/commonjs/values/selector.js +24 -0
- package/lib/commonjs/values/selector.js.map +1 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js +8 -0
- package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/commonjs/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/commonjs/views/useTouchHandler.js +13 -20
- package/lib/commonjs/views/useTouchHandler.js.map +1 -1
- package/lib/module/mock/index.js +2 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/DependencyManager.js +2 -2
- package/lib/module/renderer/DependencyManager.js.map +1 -1
- package/lib/module/renderer/components/Blend.js +21 -5
- package/lib/module/renderer/components/Blend.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/module/renderer/processors/Animations/Animations.js +13 -4
- package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/module/skia/core/Data.js +10 -20
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/core/Font.js +2 -3
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/core/SVG.js.map +1 -1
- package/lib/module/skia/core/Typeface.js.map +1 -1
- package/lib/module/skia/types/Data/Data.js +1 -1
- package/lib/module/skia/types/Data/Data.js.map +1 -1
- package/lib/module/skia/web/Host.js +9 -9
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +40 -29
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +6 -4
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +4 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +2 -2
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +11 -7
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +15 -62
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +4 -2
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
- package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkPoint.js +10 -2
- package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +10 -2
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/module/skia/web/JsiSkRect.js +4 -4
- package/lib/module/skia/web/JsiSkRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
- package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.js +3 -2
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
- package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
- package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +10 -5
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/values/hooks/useComputedValue.js +7 -3
- package/lib/module/values/hooks/useComputedValue.js.map +1 -1
- package/lib/module/values/index.js +1 -0
- package/lib/module/values/index.js.map +1 -1
- package/lib/module/values/selector.js +15 -0
- package/lib/module/values/selector.js.map +1 -0
- package/lib/module/values/web/RNSkComputedValue.js +8 -0
- package/lib/module/values/web/RNSkComputedValue.js.map +1 -1
- package/lib/module/values/web/RNSkReadonlyValue.js +4 -0
- package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -1
- package/lib/module/views/useTouchHandler.js +12 -19
- package/lib/module/views/useTouchHandler.js.map +1 -1
- package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +7 -2
- package/lib/typescript/src/skia/core/Data.d.ts +3 -5
- package/lib/typescript/src/skia/core/Font.d.ts +2 -2
- package/lib/typescript/src/skia/core/Image.d.ts +2 -2
- package/lib/typescript/src/skia/core/SVG.d.ts +2 -2
- package/lib/typescript/src/skia/core/Typeface.d.ts +2 -2
- package/lib/typescript/src/skia/types/Data/Data.d.ts +10 -3
- package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
- package/lib/typescript/src/skia/web/Host.d.ts +5 -7
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
- package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +3 -3
- package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
- package/lib/typescript/src/values/index.d.ts +1 -0
- package/lib/typescript/src/values/selector.d.ts +14 -0
- package/lib/typescript/src/values/types.d.ts +4 -0
- package/lib/typescript/src/values/web/RNSkComputedValue.d.ts +1 -0
- package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +1 -0
- package/package.json +6 -6
- package/src/mock/index.ts +2 -1
- package/src/renderer/DependencyManager.tsx +5 -2
- package/src/renderer/components/Blend.tsx +25 -5
- package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
- package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
- package/src/renderer/processors/Animations/Animations.ts +27 -5
- package/src/skia/core/Data.ts +20 -51
- package/src/skia/core/Font.ts +4 -5
- package/src/skia/core/Image.ts +2 -2
- package/src/skia/core/SVG.ts +2 -2
- package/src/skia/core/Typeface.ts +2 -2
- package/src/skia/types/Data/Data.ts +11 -1
- package/src/skia/types/Picture/Picture.ts +2 -1
- package/src/skia/web/Host.ts +11 -21
- package/src/skia/web/JsiSkCanvas.ts +99 -56
- package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
- package/src/skia/web/JsiSkFont.ts +11 -4
- package/src/skia/web/JsiSkImage.ts +4 -3
- package/src/skia/web/JsiSkImageFactory.ts +6 -3
- package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
- package/src/skia/web/JsiSkMatrix.ts +4 -2
- package/src/skia/web/JsiSkPaint.ts +11 -7
- package/src/skia/web/JsiSkPath.ts +30 -56
- package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
- package/src/skia/web/JsiSkPathFactory.ts +3 -3
- package/src/skia/web/JsiSkPicture.ts +5 -3
- package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
- package/src/skia/web/JsiSkPoint.ts +12 -2
- package/src/skia/web/JsiSkRRect.ts +16 -2
- package/src/skia/web/JsiSkRSXform.ts +1 -1
- package/src/skia/web/JsiSkRect.ts +4 -7
- package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
- package/src/skia/web/JsiSkShaderFactory.ts +24 -15
- package/src/skia/web/JsiSkSurface.ts +7 -2
- package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
- package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
- package/src/skia/web/JsiSkia.ts +17 -5
- package/src/values/hooks/useComputedValue.ts +6 -3
- package/src/values/index.ts +1 -0
- package/src/values/selector.ts +24 -0
- package/src/values/types.ts +4 -0
- package/src/values/web/RNSkComputedValue.ts +6 -0
- package/src/values/web/RNSkReadonlyValue.ts +4 -0
- package/src/views/useTouchHandler.ts +15 -21
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","
|
1
|
+
{"version":3,"sources":["useTouchHandler.ts"],"names":["useCallback","useRef","PixelRatio","TouchType","useInternalTouchHandler","handlers","deps","multiTouch","prevTouchInfoRef","prevVelocityRef","history","forEach","touches","i","length","touch","prevTouch","current","id","timeDiffseconds","timestamp","distX","x","distY","y","type","Start","End","Cancelled","get","extendedTouchInfo","velocityX","velocityY","onStart","Active","onActive","onEnd","useTouchHandler","useMultiTouchHandler"],"mappings":"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","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport { PixelRatio } from \"react-native\";\n\nimport type { Vector } from \"../skia/types\";\n\nimport type {\n ExtendedTouchInfo,\n TouchHandlers,\n TouchHandler,\n TouchInfo,\n} from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst useInternalTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = [],\n multiTouch = false\n): TouchHandler => {\n const prevTouchInfoRef = useRef<{ [key: number]: TouchInfo | undefined }>({});\n const prevVelocityRef = useRef<{ [key: number]: Vector | undefined }>({});\n\n return useCallback((history: Array<Array<TouchInfo>>) => {\n // Process all items in the current touch history\n history.forEach((touches) => {\n // Enumerate touches\n for (let i = 0; i < touches.length; i++) {\n if (!multiTouch && i > 0) {\n break;\n }\n\n const touch = touches[i];\n const prevTouch = prevTouchInfoRef.current[touch.id];\n // Calculate the velocity from the previous touch.\n const timeDiffseconds =\n touch.timestamp -\n (prevTouchInfoRef.current[touch.id]?.timestamp ?? touch.timestamp);\n\n const distX = touch.x - (prevTouch?.x ?? touch.x);\n const distY = touch.y - (prevTouch?.y ?? touch.y);\n\n if (\n touch.type !== TouchType.Start &&\n touch.type !== TouchType.End &&\n touch.type !== TouchType.Cancelled &&\n timeDiffseconds > 0\n ) {\n prevVelocityRef.current[touch.id] = {\n x: distX / timeDiffseconds / PixelRatio.get(),\n y: distY / timeDiffseconds / PixelRatio.get(),\n };\n }\n\n const extendedTouchInfo: ExtendedTouchInfo = {\n ...touch,\n velocityX: prevVelocityRef.current[touch.id]?.x ?? 0,\n velocityY: prevVelocityRef.current[touch.id]?.y ?? 0,\n };\n\n // Save previous touch\n prevTouchInfoRef.current[touch.id] = touch;\n\n if (touch.type === TouchType.Start) {\n delete prevVelocityRef.current[touch.id];\n handlers.onStart && handlers.onStart(touch);\n } else if (touch.type === TouchType.Active) {\n handlers.onActive && handlers.onActive(extendedTouchInfo);\n } else {\n handlers.onEnd && handlers.onEnd(extendedTouchInfo);\n }\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler only handles single touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, false);\n};\n\n/**\n * Provides a callback for handling touch events in the Skia View.\n * This touch handler handles multiple touches.\n * @param handlers Callbacks for the different touch states\n * @param deps optional Dependency array to update the handlers\n * @returns A function that can be used from within the onDraw callback to\n * update and handle touch events. Call it with the touches property from\n * the info object.\n */\nexport const useMultiTouchHandler = (\n handlers: TouchHandlers,\n deps: DependencyList = []\n): TouchHandler => {\n return useInternalTouchHandler(handlers, deps, true);\n};\n"]}
|
@@ -1,7 +1,12 @@
|
|
1
|
-
import type { SkiaValue } from "../../../values";
|
1
|
+
import type { SkiaSelector, SkiaValue } from "../../../values";
|
2
2
|
export declare const isValue: (value: unknown) => value is SkiaValue<unknown>;
|
3
|
+
export declare const isSelector: <T, R>(value: unknown) => value is {
|
4
|
+
selector: (v: T) => R;
|
5
|
+
value: SkiaValue<T>;
|
6
|
+
};
|
3
7
|
export declare const isAnimated: <T>(props: AnimatedProps<T>) => boolean;
|
4
8
|
export declare const materialize: <T>(props: AnimatedProps<T>) => T;
|
9
|
+
export declare type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
|
5
10
|
export declare type AnimatedProps<T> = {
|
6
|
-
[K in keyof T]:
|
11
|
+
[K in keyof T]: AnimatedProp<T[K]>;
|
7
12
|
};
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
export declare const
|
4
|
-
export declare const useRawData: <T>(source: DataSource | null | undefined, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => T | null;
|
5
|
-
export declare const useData: (source: DataSource | null | undefined, onError?: ((err: Error) => void) | undefined, deps?: DependencyList | undefined) => SkData | null;
|
1
|
+
import type { SkData, DataSourceParam } from "../types";
|
2
|
+
export declare const useRawData: <T>(source: DataSourceParam, factory: (data: SkData) => T, onError?: ((err: Error) => void) | undefined) => T | null;
|
3
|
+
export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Font object
|
4
4
|
* */
|
5
|
-
export declare const useFont: (font:
|
5
|
+
export declare const useFont: (font: DataSourceParam, size?: number | undefined, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Image object
|
4
4
|
* */
|
5
|
-
export declare const useImage: (source:
|
5
|
+
export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
export declare const useSVG: (source:
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
|
+
export declare const useSVG: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkSVG | null;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { DataSourceParam } from "../types";
|
2
2
|
/**
|
3
3
|
* Returns a Skia Typeface object
|
4
4
|
* */
|
5
|
-
export declare const useTypeface: (source:
|
5
|
+
export declare const useTypeface: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkTypeface | null;
|
@@ -1,5 +1,12 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="react-native" />
|
3
1
|
import type { SkJSIInstance } from "../JsiInstance";
|
4
2
|
export declare type SkData = SkJSIInstance<"Data">;
|
5
|
-
|
3
|
+
declare type RNModule = number;
|
4
|
+
declare type ESModule = {
|
5
|
+
__esModule: true;
|
6
|
+
default: string;
|
7
|
+
};
|
8
|
+
export declare type DataModule = RNModule | ESModule;
|
9
|
+
export declare type DataSource = DataModule | string | Uint8Array;
|
10
|
+
export declare type DataSourceParam = DataSource | null | undefined;
|
11
|
+
export declare const isRNModule: (mod: DataModule) => mod is number;
|
12
|
+
export {};
|
@@ -3,7 +3,8 @@ import type { TileMode } from "../ImageFilter";
|
|
3
3
|
import type { SkRect } from "../Rect";
|
4
4
|
import type { SkShader } from "../Shader";
|
5
5
|
import type { SkMatrix } from "../Matrix";
|
6
|
-
|
6
|
+
import type { SkJSIInstance } from "../JsiInstance";
|
7
|
+
export interface SkPicture extends SkJSIInstance<"Picture"> {
|
7
8
|
/**
|
8
9
|
* Returns a new shader that will draw with this picture.
|
9
10
|
*
|
@@ -1,21 +1,19 @@
|
|
1
1
|
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
2
2
|
import type { SkJSIInstance } from "../types";
|
3
3
|
export declare class NotImplementedOnRNWeb extends Error {
|
4
|
-
constructor();
|
4
|
+
constructor(msg?: string);
|
5
5
|
}
|
6
6
|
export declare abstract class Host {
|
7
7
|
readonly CanvasKit: CanvasKit;
|
8
8
|
constructor(CanvasKit: CanvasKit);
|
9
9
|
}
|
10
|
-
export declare abstract class
|
10
|
+
export declare abstract class BaseHostObject<T, N extends string> extends Host implements SkJSIInstance<N> {
|
11
11
|
readonly __typename__: N;
|
12
12
|
readonly ref: T;
|
13
13
|
constructor(CanvasKit: CanvasKit, ref: T, typename: N);
|
14
14
|
}
|
15
|
-
export declare
|
16
|
-
|
17
|
-
|
18
|
-
export declare const toNullableValue: <T>(value: NonNullish | null) => T | null;
|
19
|
-
export declare const toValue: <T>(value: NonNullish) => T;
|
15
|
+
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
16
|
+
static fromValue<T>(value: SkJSIInstance<string>): T;
|
17
|
+
}
|
20
18
|
export declare const ckEnum: (value: number) => EmbindEnumEntity;
|
21
19
|
export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
|
@@ -4,16 +4,16 @@ import { Host } from "./Host";
|
|
4
4
|
import { JsiSkImageFilter } from "./JsiSkImageFilter";
|
5
5
|
export declare class JsiSkImageFilterFactory extends Host implements ImageFilterFactory {
|
6
6
|
constructor(CanvasKit: CanvasKit);
|
7
|
-
MakeOffset(
|
8
|
-
MakeDisplacementMap(
|
9
|
-
MakeShader(
|
7
|
+
MakeOffset(dx: number, dy: number, input: SkImageFilter | null): JsiSkImageFilter;
|
8
|
+
MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input: SkImageFilter | null): SkImageFilter;
|
9
|
+
MakeShader(shader: SkShader, _input: SkImageFilter | null): SkImageFilter;
|
10
10
|
MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input: SkImageFilter | null): JsiSkImageFilter;
|
11
11
|
MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null): JsiSkImageFilter;
|
12
12
|
MakeCompose(outer: SkImageFilter | null, inner: SkImageFilter | null): JsiSkImageFilter;
|
13
|
-
MakeDropShadow(
|
14
|
-
MakeDropShadowOnly(
|
15
|
-
MakeErode(
|
16
|
-
MakeDilate(
|
17
|
-
MakeBlend(
|
13
|
+
MakeDropShadow(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
14
|
+
MakeDropShadowOnly(dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
15
|
+
MakeErode(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
16
|
+
MakeDilate(rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
17
|
+
MakeBlend(mode: BlendMode, background: SkImageFilter, foreground: SkImageFilter | null, cropRect?: SkRect): SkImageFilter;
|
18
18
|
MakeRuntimeShader(_builder: SkRuntimeShaderBuilder, _childShaderName: string | null, _input: SkImageFilter | null): SkImageFilter;
|
19
19
|
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import type { CanvasKit, Point } from "canvaskit-wasm";
|
2
2
|
import type { SkPoint } from "../types";
|
3
|
-
import {
|
4
|
-
export declare class JsiSkPoint extends
|
3
|
+
import { BaseHostObject } from "./Host";
|
4
|
+
export declare class JsiSkPoint extends BaseHostObject<Point, "Point"> implements SkPoint {
|
5
|
+
static fromValue(point: SkPoint): Float32Array;
|
5
6
|
constructor(CanvasKit: CanvasKit, ref: Point);
|
6
7
|
get x(): number;
|
7
8
|
get y(): number;
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
2
2
|
import type { SkRRect } from "../types";
|
3
|
-
import {
|
3
|
+
import { BaseHostObject } from "./Host";
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
5
|
-
export declare class JsiSkRRect extends
|
5
|
+
export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
|
6
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
|
6
7
|
constructor(CanvasKit: CanvasKit, ref: RRect);
|
7
8
|
get rx(): number;
|
8
9
|
get ry(): number;
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
2
2
|
import type { SkRSXform } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
|
-
declare type RSXform = Float32Array;
|
4
|
+
export declare type RSXform = Float32Array;
|
5
5
|
export declare class JsiSkRSXform extends HostObject<RSXform, "RSXform"> implements SkRSXform {
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: RSXform);
|
7
7
|
}
|
8
|
-
export {};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { CanvasKit, Rect } from "canvaskit-wasm";
|
2
2
|
import type { SkRect } from "../types";
|
3
|
-
import {
|
4
|
-
export declare class JsiSkRect extends
|
5
|
-
static fromValue(CanvasKit: CanvasKit, rect: SkRect):
|
3
|
+
import { BaseHostObject } from "./Host";
|
4
|
+
export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkRect {
|
5
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRect): Float32Array;
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Rect);
|
7
7
|
get x(): number;
|
8
8
|
get y(): number;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
-
import type { SkFont
|
2
|
+
import type { SkFont } from "../types";
|
3
3
|
import type { TextBlobFactory } from "../types/TextBlob";
|
4
|
+
import type { SkRSXform } from "../types/RSXform";
|
4
5
|
import { Host } from "./Host";
|
5
6
|
import { JsiSkTextBlob } from "./JsiSkTextBlob";
|
6
7
|
export declare class JsiSkTextBlobFactory extends Host implements TextBlobFactory {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SkiaValue } from "./types";
|
2
|
+
export declare type SkiaSelector<TReturn, TInput = unknown> = {
|
3
|
+
value: SkiaValue<TInput>;
|
4
|
+
selector: (v: TInput) => TReturn;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* Wraps a Skia Value with a selector function. The selector function can access the
|
8
|
+
* inner values of the Skia Value so that we can dynamically ready array values and
|
9
|
+
* object values when doing animations in Skia.
|
10
|
+
* @param value Dependant value
|
11
|
+
* @param selector Selector function to calculate new value from the Skia Value's value
|
12
|
+
* @returns A descriptor that will be used by the reconciler to calculate the value
|
13
|
+
*/
|
14
|
+
export declare const Selector: <TInput, TReturn>(value: SkiaValue<TInput>, selector: (v: TInput) => TReturn) => SkiaSelector<TReturn, TInput>;
|
@@ -8,6 +8,10 @@ export interface SkiaValue<T = number> {
|
|
8
8
|
* Returns unsubscribe method.
|
9
9
|
*/
|
10
10
|
addListener: (cb: (value: T) => void) => () => void;
|
11
|
+
/**
|
12
|
+
* Invalidates the value. Has different meaning depending on the type of the value.
|
13
|
+
*/
|
14
|
+
__invalidate: () => void;
|
11
15
|
/**
|
12
16
|
* Field to make typechecking easier
|
13
17
|
*/
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
8
8
|
},
|
9
9
|
"title": "React Native Skia",
|
10
|
-
"version": "0.1.
|
10
|
+
"version": "0.1.143",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -37,7 +37,7 @@
|
|
37
37
|
],
|
38
38
|
"scripts": {
|
39
39
|
"tsc": "tsc --noEmit",
|
40
|
-
"lint": "eslint . --ext .ts,.tsx --max-warnings 0",
|
40
|
+
"lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
|
41
41
|
"test": "jest",
|
42
42
|
"postinstall": "node scripts/install-npm.js",
|
43
43
|
"build": "bob build"
|
@@ -75,21 +75,21 @@
|
|
75
75
|
}
|
76
76
|
},
|
77
77
|
"devDependencies": {
|
78
|
-
"@types/jest": "^
|
78
|
+
"@types/jest": "^28.1.6",
|
79
79
|
"@types/react-native": "^0.65.0",
|
80
80
|
"@types/react-reconciler": "^0.26.4",
|
81
81
|
"eslint": "8.21.0",
|
82
82
|
"eslint-config-react-native-wcandillon": "3.9.0",
|
83
83
|
"eslint-plugin-reanimated": "2.0.0",
|
84
|
-
"jest": "
|
84
|
+
"jest": "28.1.3",
|
85
85
|
"react": "17.0.2",
|
86
86
|
"react-native": "0.66.2",
|
87
87
|
"react-native-builder-bob": "^0.18.2",
|
88
|
-
"ts-jest": "^
|
88
|
+
"ts-jest": "^28.0.7",
|
89
89
|
"typescript": "^4.6.4"
|
90
90
|
},
|
91
91
|
"dependencies": {
|
92
|
-
"canvaskit-wasm": "^0.
|
92
|
+
"canvaskit-wasm": "^0.36.0",
|
93
93
|
"react-reconciler": "^0.26.2"
|
94
94
|
},
|
95
95
|
"eslintIgnore": [
|
package/src/mock/index.ts
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
import type { Color, Skia as SkiaApi, SkRect, Vector } from "../skia/types";
|
4
4
|
import * as Values from "../values/web";
|
5
5
|
import * as ValuesHooks from "../values/hooks";
|
6
|
+
import { Selector } from "../values/selector";
|
6
7
|
import * as BaseSkia from "../skia/types";
|
7
8
|
import type * as SkiaExports from "../skia";
|
8
9
|
import type * as ExternalExports from "../external";
|
@@ -46,7 +47,6 @@ export const Mock: typeof SkiaExports &
|
|
46
47
|
Skia,
|
47
48
|
...BaseSkia,
|
48
49
|
// 2. Hooks
|
49
|
-
useDataCollection: Noop,
|
50
50
|
useRawData: Noop,
|
51
51
|
useData: Noop,
|
52
52
|
useFont: Noop,
|
@@ -87,6 +87,7 @@ export const Mock: typeof SkiaExports &
|
|
87
87
|
// ValueExports
|
88
88
|
...Values,
|
89
89
|
...ValuesHooks,
|
90
|
+
Selector,
|
90
91
|
// Animations
|
91
92
|
...timingFunctions,
|
92
93
|
...springFunctions,
|
@@ -3,7 +3,7 @@ import type { RefObject } from "react";
|
|
3
3
|
import type { SkiaView } from "../views";
|
4
4
|
import type { SkiaValue } from "../values";
|
5
5
|
|
6
|
-
import { isValue } from "./processors";
|
6
|
+
import { isSelector, isValue } from "./processors";
|
7
7
|
import type { Node } from "./nodes";
|
8
8
|
|
9
9
|
type Unsubscribe = () => void;
|
@@ -29,7 +29,10 @@ export class DependencyManager {
|
|
29
29
|
}
|
30
30
|
|
31
31
|
subscribeNode(node: Node, props: Props) {
|
32
|
-
const values = Object.values(props)
|
32
|
+
const values = Object.values(props)
|
33
|
+
.filter((v) => isValue(v) || isSelector(v))
|
34
|
+
.map((v) => (isSelector(v) ? v.value : (v as SkiaValue<unknown>)));
|
35
|
+
|
33
36
|
if (values.length > 0) {
|
34
37
|
this.subscriptions.set(node, { values, unsubscribe: null });
|
35
38
|
}
|
@@ -1,10 +1,21 @@
|
|
1
1
|
import type { ReactNode } from "react";
|
2
2
|
import React from "react";
|
3
3
|
|
4
|
+
import type { SkImageFilter, SkShader } from "../../skia/types";
|
4
5
|
import { isImageFilter, BlendMode, isShader } from "../../skia/types";
|
5
6
|
import { createDeclaration } from "../nodes";
|
6
7
|
import type { AnimatedProps, SkEnum } from "../processors";
|
7
8
|
import { enumKey } from "../processors/Paint";
|
9
|
+
import type { DeclarationResult } from "../nodes/Declaration";
|
10
|
+
|
11
|
+
const childrenAreImageFilters = (
|
12
|
+
children: DeclarationResult[]
|
13
|
+
): children is SkImageFilter[] =>
|
14
|
+
children.every((child) => isImageFilter(child));
|
15
|
+
|
16
|
+
const childrenAreShaders = (
|
17
|
+
children: DeclarationResult[]
|
18
|
+
): children is SkShader[] => children.every((child) => isShader(child));
|
8
19
|
|
9
20
|
interface BlendProps {
|
10
21
|
mode: SkEnum<typeof BlendMode>;
|
@@ -13,12 +24,21 @@ interface BlendProps {
|
|
13
24
|
|
14
25
|
const onDeclare = createDeclaration<BlendProps>(
|
15
26
|
({ mode }, children, { Skia }) => {
|
16
|
-
const [inner, outer] = children;
|
17
27
|
const blend = BlendMode[enumKey(mode)];
|
18
|
-
if (
|
19
|
-
return
|
20
|
-
|
21
|
-
|
28
|
+
if (childrenAreImageFilters(children)) {
|
29
|
+
return children.reverse().reduce<SkImageFilter | null>((inner, outer) => {
|
30
|
+
if (inner === null) {
|
31
|
+
return outer;
|
32
|
+
}
|
33
|
+
return Skia.ImageFilter.MakeBlend(blend, outer, inner);
|
34
|
+
}, null);
|
35
|
+
} else if (childrenAreShaders(children)) {
|
36
|
+
return children.reverse().reduce<SkShader | null>((inner, outer) => {
|
37
|
+
if (inner === null) {
|
38
|
+
return outer;
|
39
|
+
}
|
40
|
+
return Skia.Shader.MakeBlend(blend, outer, inner);
|
41
|
+
}, null);
|
22
42
|
}
|
23
43
|
throw new Error("<Blend /> can only blend Shaders or ImageFilters");
|
24
44
|
}
|
@@ -18,8 +18,8 @@ const onDeclare = createDeclaration<MorphologyProps>(
|
|
18
18
|
const r = processRadius(Skia, radius);
|
19
19
|
const factory =
|
20
20
|
operator === "dilate"
|
21
|
-
? Skia.ImageFilter.MakeDilate
|
22
|
-
: Skia.ImageFilter.MakeErode;
|
21
|
+
? Skia.ImageFilter.MakeDilate.bind(Skia.ImageFilter)
|
22
|
+
: Skia.ImageFilter.MakeErode.bind(Skia.ImageFilter);
|
23
23
|
return factory(r.x, r.y, input);
|
24
24
|
}
|
25
25
|
);
|
@@ -30,8 +30,8 @@ const onDeclare = createDeclaration<ShadowProps>(
|
|
30
30
|
factory = MakeInnerShadow.bind(null, Skia, shadowOnly);
|
31
31
|
} else {
|
32
32
|
factory = shadowOnly
|
33
|
-
? Skia.ImageFilter.MakeDropShadowOnly
|
34
|
-
: Skia.ImageFilter.MakeDropShadow;
|
33
|
+
? Skia.ImageFilter.MakeDropShadowOnly.bind(Skia.ImageFilter)
|
34
|
+
: Skia.ImageFilter.MakeDropShadow.bind(Skia.ImageFilter);
|
35
35
|
}
|
36
36
|
return factory(dx, dy, blur, blur, color, input);
|
37
37
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { SkiaValue } from "../../../values";
|
1
|
+
import type { SkiaSelector, SkiaValue } from "../../../values";
|
2
2
|
import { mapKeys } from "../../typeddash";
|
3
3
|
|
4
4
|
export const isValue = (value: unknown): value is SkiaValue<unknown> => {
|
@@ -17,6 +17,24 @@ export const isValue = (value: unknown): value is SkiaValue<unknown> => {
|
|
17
17
|
return false;
|
18
18
|
};
|
19
19
|
|
20
|
+
export const isSelector = <T, R>(
|
21
|
+
value: unknown
|
22
|
+
): value is {
|
23
|
+
selector: (v: T) => R;
|
24
|
+
value: SkiaValue<T>;
|
25
|
+
} => {
|
26
|
+
if (value) {
|
27
|
+
return (
|
28
|
+
typeof value === "object" &&
|
29
|
+
"selector" in value &&
|
30
|
+
"value" in value &&
|
31
|
+
(value as Record<string, unknown>).selector !== undefined &&
|
32
|
+
(value as Record<string, unknown>).value !== undefined
|
33
|
+
);
|
34
|
+
}
|
35
|
+
return false;
|
36
|
+
};
|
37
|
+
|
20
38
|
export const isAnimated = <T>(props: AnimatedProps<T>) => {
|
21
39
|
for (const value of Object.values(props)) {
|
22
40
|
if (isValue(value)) {
|
@@ -29,14 +47,18 @@ export const isAnimated = <T>(props: AnimatedProps<T>) => {
|
|
29
47
|
export const materialize = <T>(props: AnimatedProps<T>) => {
|
30
48
|
const result = { ...props };
|
31
49
|
mapKeys(props).forEach((key) => {
|
32
|
-
const
|
33
|
-
if (isValue(
|
34
|
-
result[key] = (
|
50
|
+
const prop = props[key];
|
51
|
+
if (isValue(prop)) {
|
52
|
+
result[key] = (prop as SkiaValue<T[typeof key]>).current;
|
53
|
+
} else if (isSelector(prop)) {
|
54
|
+
result[key] = prop.selector(prop.value.current) as T[typeof key];
|
35
55
|
}
|
36
56
|
});
|
37
57
|
return result as T;
|
38
58
|
};
|
39
59
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
61
|
+
export type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
|
40
62
|
export type AnimatedProps<T> = {
|
41
|
-
[K in keyof T]:
|
63
|
+
[K in keyof T]: AnimatedProp<T[K]>;
|
42
64
|
};
|
package/src/skia/core/Data.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import { Image, Platform } from "react-native";
|
1
|
+
import { useEffect, useState } from "react";
|
2
|
+
import { Image } from "react-native";
|
4
3
|
|
5
4
|
import { Skia } from "../Skia";
|
6
|
-
import
|
5
|
+
import { isRNModule } from "../types";
|
6
|
+
import type { SkData, DataModule, DataSourceParam } from "../types";
|
7
7
|
|
8
|
-
const resolveAsset = (source:
|
9
|
-
return
|
10
|
-
? source.
|
11
|
-
:
|
8
|
+
const resolveAsset = (source: DataModule) => {
|
9
|
+
return isRNModule(source)
|
10
|
+
? Image.resolveAssetSource(source).uri
|
11
|
+
: source.default;
|
12
12
|
};
|
13
13
|
|
14
14
|
const factoryWrapper = <T>(
|
@@ -25,19 +25,12 @@ const factoryWrapper = <T>(
|
|
25
25
|
}
|
26
26
|
};
|
27
27
|
|
28
|
-
const loadDataCollection = <T>(
|
29
|
-
sources: DataSource[],
|
30
|
-
factory: (data: SkData) => T,
|
31
|
-
onError?: (err: Error) => void
|
32
|
-
): Promise<(T | null)[]> =>
|
33
|
-
Promise.all(sources.map((source) => loadData(source, factory, onError)));
|
34
|
-
|
35
28
|
const loadData = <T>(
|
36
|
-
source:
|
29
|
+
source: DataSourceParam,
|
37
30
|
factory: (data: SkData) => T,
|
38
31
|
onError?: (err: Error) => void
|
39
32
|
): Promise<T | null> => {
|
40
|
-
if (source === null) {
|
33
|
+
if (source === null || source === undefined) {
|
41
34
|
return new Promise((resolve) => resolve(null));
|
42
35
|
} else if (source instanceof Uint8Array) {
|
43
36
|
return new Promise((resolve) =>
|
@@ -50,51 +43,27 @@ const loadData = <T>(
|
|
50
43
|
);
|
51
44
|
}
|
52
45
|
};
|
53
|
-
|
54
|
-
type Source = DataSource | null | undefined;
|
55
|
-
|
56
46
|
const useLoading = <T>(
|
57
|
-
source:
|
58
|
-
loader: () => Promise<T | null
|
59
|
-
deps: DependencyList = []
|
47
|
+
source: DataSourceParam,
|
48
|
+
loader: () => Promise<T | null>
|
60
49
|
) => {
|
61
50
|
const [data, setData] = useState<T | null>(null);
|
62
|
-
const prevSourceRef = useRef<Source>();
|
63
51
|
useEffect(() => {
|
64
|
-
|
65
|
-
prevSourceRef.current = source;
|
66
|
-
loader().then(setData);
|
67
|
-
} else {
|
68
|
-
setData(null);
|
69
|
-
}
|
52
|
+
loader().then(setData);
|
70
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
71
|
-
},
|
54
|
+
}, [source]);
|
72
55
|
return data;
|
73
56
|
};
|
74
57
|
|
75
|
-
export const useDataCollection = <T>(
|
76
|
-
sources: DataSource[],
|
77
|
-
factory: (data: SkData) => T,
|
78
|
-
onError?: (err: Error) => void,
|
79
|
-
deps?: DependencyList
|
80
|
-
) =>
|
81
|
-
useLoading(
|
82
|
-
sources,
|
83
|
-
() => loadDataCollection(sources, factory, onError),
|
84
|
-
deps
|
85
|
-
);
|
86
|
-
|
87
58
|
export const useRawData = <T>(
|
88
|
-
source:
|
59
|
+
source: DataSourceParam,
|
89
60
|
factory: (data: SkData) => T,
|
90
|
-
onError?: (err: Error) => void
|
91
|
-
|
92
|
-
) => useLoading(source, () => loadData(source, factory, onError), deps);
|
61
|
+
onError?: (err: Error) => void
|
62
|
+
) => useLoading(source, () => loadData(source, factory, onError));
|
93
63
|
|
94
64
|
const identity = (data: SkData) => data;
|
95
65
|
|
96
66
|
export const useData = (
|
97
|
-
source:
|
98
|
-
onError?: (err: Error) => void
|
99
|
-
|
100
|
-
) => useRawData(source, identity, onError, deps);
|
67
|
+
source: DataSourceParam,
|
68
|
+
onError?: (err: Error) => void
|
69
|
+
) => useRawData(source, identity, onError);
|