@shopify/react-native-skia 1.11.4 → 1.11.6
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/android/CMakeLists.txt +0 -1
- package/cpp/api/JsiSkParagraph.h +1 -3
- package/cpp/api/recorder/Convertor.h +57 -9
- package/cpp/api/recorder/Drawings.h +11 -36
- package/cpp/jsi/ViewProperty.h +1 -3
- package/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +2 -2
- package/lib/commonjs/dom/types/NodeType.js +8 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/external/reanimated/buffers.d.ts +1 -1
- package/lib/commonjs/renderer/__tests__/setup.d.ts +1 -1
- package/lib/commonjs/skia/types/Image/ColorType.js +20 -2
- package/lib/commonjs/skia/types/Image/ColorType.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ColorType.web.js +18 -2
- package/lib/commonjs/skia/types/Image/ColorType.web.js.map +1 -1
- package/lib/commonjs/skia/types/ImageFilter/ImageFilter.js +14 -0
- package/lib/commonjs/skia/types/ImageFilter/ImageFilter.js.map +1 -1
- package/lib/commonjs/skia/types/MaskFilter.js +5 -2
- package/lib/commonjs/skia/types/MaskFilter.js.map +1 -1
- package/lib/commonjs/skia/types/Paint/BlendMode.js +31 -2
- package/lib/commonjs/skia/types/Paint/BlendMode.js.map +1 -1
- package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js +14 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.js +4 -0
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkPaint.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPoint.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkRSXform.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.d.ts +1 -1
- package/lib/commonjs/sksg/Container.d.ts +1 -0
- package/lib/commonjs/sksg/Container.js +8 -9
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Core.js +2 -0
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +6 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js +33 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +9 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +32 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/views/types.d.ts +1 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/commonjs/web/LoadSkiaWeb.js +1 -2
- package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -1
- package/lib/module/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.d.ts +2 -2
- package/lib/module/dom/types/NodeType.js +8 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/external/reanimated/buffers.d.ts +1 -1
- package/lib/module/renderer/__tests__/setup.d.ts +1 -1
- package/lib/module/skia/types/Image/ColorType.js +20 -2
- package/lib/module/skia/types/Image/ColorType.js.map +1 -1
- package/lib/module/skia/types/Image/ColorType.web.js +18 -2
- package/lib/module/skia/types/Image/ColorType.web.js.map +1 -1
- package/lib/module/skia/types/ImageFilter/ImageFilter.js +14 -0
- package/lib/module/skia/types/ImageFilter/ImageFilter.js.map +1 -1
- package/lib/module/skia/types/MaskFilter.js +5 -2
- package/lib/module/skia/types/MaskFilter.js.map +1 -1
- package/lib/module/skia/types/Paint/BlendMode.js +31 -2
- package/lib/module/skia/types/Paint/BlendMode.js.map +1 -1
- package/lib/module/skia/types/Paragraph/ParagraphBuilder.js +14 -0
- package/lib/module/skia/types/Paragraph/ParagraphBuilder.js.map +1 -1
- package/lib/module/skia/types/Path/Path.js +4 -0
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +2 -2
- package/lib/module/skia/web/JsiSkPaint.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPicture.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPoint.d.ts +1 -1
- package/lib/module/skia/web/JsiSkRRect.d.ts +1 -1
- package/lib/module/skia/web/JsiSkRSXform.d.ts +1 -1
- package/lib/module/skia/web/JsiSkRect.d.ts +1 -1
- package/lib/module/sksg/Container.d.ts +1 -0
- package/lib/module/sksg/Container.js +8 -9
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Recorder/Core.js +2 -0
- package/lib/module/sksg/Recorder/Core.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +6 -0
- package/lib/module/specs/NativeSkiaModule.web.js +30 -1
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +9 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +26 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +1 -0
- package/lib/module/views/types.d.ts +1 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/image/ImageShader.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkColor.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -1
- package/lib/typescript/lib/commonjs/specs/NativeSkiaModule.web.d.ts +1 -0
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +10 -0
- package/lib/typescript/lib/module/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +2 -2
- package/lib/typescript/lib/module/renderer/components/image/ImageShader.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkColor.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -1
- package/lib/typescript/lib/module/specs/NativeSkiaModule.web.d.ts +1 -0
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +9 -0
- package/lib/typescript/src/animation/functions/interpolateColors.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +2 -2
- package/lib/typescript/src/external/reanimated/buffers.d.ts +1 -1
- package/lib/typescript/src/renderer/__tests__/setup.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkPicture.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +1 -1
- package/lib/typescript/src/sksg/Container.d.ts +1 -0
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +6 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +9 -0
- package/lib/typescript/src/views/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/sksg/Container.ts +8 -8
- package/src/specs/NativeSkiaModule.web.ts +38 -0
- package/src/specs/SkiaPictureViewNativeComponent.web.ts +39 -0
- package/src/views/types.ts +1 -0
- package/cpp/jsi/JsiValue.cpp +0 -345
- package/cpp/jsi/JsiValue.h +0 -222
- package/lib/commonjs/renderer/Canvas.web.d.ts +0 -10
- package/lib/commonjs/renderer/Canvas.web.js +0 -110
- package/lib/commonjs/renderer/Canvas.web.js.map +0 -1
- package/lib/module/renderer/Canvas.web.d.ts +0 -10
- package/lib/module/renderer/Canvas.web.js +0 -105
- package/lib/module/renderer/Canvas.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/renderer/Canvas.web.d.ts +0 -3
- package/lib/typescript/lib/module/renderer/Canvas.web.d.ts +0 -1
- package/lib/typescript/src/renderer/Canvas.web.d.ts +0 -10
- package/src/renderer/Canvas.web.tsx +0 -134
|
@@ -8,6 +8,7 @@ import { visit } from "./Recorder/Visitor";
|
|
|
8
8
|
import { replay } from "./Recorder/Player";
|
|
9
9
|
import { createDrawingContext } from "./Recorder/DrawingContext";
|
|
10
10
|
import { ReanimatedRecorder } from "./Recorder/ReanimatedRecorder";
|
|
11
|
+
import "../views/api";
|
|
11
12
|
const drawOnscreen = (Skia, nativeId, recording) => {
|
|
12
13
|
"worklet";
|
|
13
14
|
|
|
@@ -21,8 +22,6 @@ const drawOnscreen = (Skia, nativeId, recording) => {
|
|
|
21
22
|
//const end = performance.now();
|
|
22
23
|
//console.log("Recording time: ", end - start);
|
|
23
24
|
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
|
24
|
-
rec.dispose();
|
|
25
|
-
picture.dispose();
|
|
26
25
|
};
|
|
27
26
|
const nativeDrawOnscreen = (nativeId, recorder) => {
|
|
28
27
|
"worklet";
|
|
@@ -131,6 +130,11 @@ class NativeReanimatedContainer extends Container {
|
|
|
131
130
|
visit(recorder, this.root);
|
|
132
131
|
const sharedValues = recorder.getSharedValues();
|
|
133
132
|
const sharedRecorder = recorder.getRecorder();
|
|
133
|
+
Rea.runOnUI(() => {
|
|
134
|
+
"worklet";
|
|
135
|
+
|
|
136
|
+
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
137
|
+
})();
|
|
134
138
|
if (sharedValues.length > 0) {
|
|
135
139
|
this.mapperId = Rea.startMapper(() => {
|
|
136
140
|
"worklet";
|
|
@@ -139,17 +143,12 @@ class NativeReanimatedContainer extends Container {
|
|
|
139
143
|
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
140
144
|
}, sharedValues);
|
|
141
145
|
}
|
|
142
|
-
Rea.runOnUI(() => {
|
|
143
|
-
"worklet";
|
|
144
|
-
|
|
145
|
-
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
146
|
-
})();
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
export const createContainer = (Skia, nativeId) => {
|
|
150
|
-
const
|
|
149
|
+
const web = global.SkiaViewApi && global.SkiaViewApi.web;
|
|
151
150
|
if (HAS_REANIMATED_3 && nativeId !== -1) {
|
|
152
|
-
if (
|
|
151
|
+
if (!web) {
|
|
153
152
|
return new NativeReanimatedContainer(Skia, nativeId);
|
|
154
153
|
} else {
|
|
155
154
|
return new ReanimatedContainer(Skia, nativeId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","dispose","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","unmount","unmounted","drawOnCanvas","Error","StaticContainer","redraw","root","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","native","global","undefined"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n rec.dispose();\n picture.dispose();\n};\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nexport abstract class Container {\n public root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const native = global.SkiaViewApi !== undefined;\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (native) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, native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AAK,CAAC,CAAC,EAAE;IACvC,IAAI+C,MAAM,EAAE;MACV,OAAO,IAAIR,yBAAyB,CAACxC,IAAI,EAAEC,QAAQ,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,IAAI6B,mBAAmB,CAAC9B,IAAI,EAAEC,QAAQ,CAAC;IAChD;EACF,CAAC,MAAM;IACL,OAAO,IAAIwB,eAAe,CAACzB,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","unmount","unmounted","drawOnCanvas","Error","StaticContainer","redraw","root","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","web","global"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport type { Node } from \"./Node\";\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nexport abstract class Container {\n public root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const web = global.SkiaViewApi && global.SkiaViewApi.web;\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (!web) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, nativeId);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAKvE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,OAAO,cAAc;AAErB,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;E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
|
|
44
45
|
CommandType[CommandType["Group"] = 0] = "Group";
|
|
45
46
|
CommandType[CommandType["SavePaint"] = 1] = "SavePaint";
|
|
46
47
|
CommandType[CommandType["RestorePaint"] = 2] = "RestorePaint";
|
|
@@ -58,6 +59,7 @@ export let CommandType = /*#__PURE__*/function (CommandType) {
|
|
|
58
59
|
CommandType[CommandType["SaveBackdropFilter"] = 14] = "SaveBackdropFilter";
|
|
59
60
|
CommandType[CommandType["SaveLayer"] = 15] = "SaveLayer";
|
|
60
61
|
CommandType[CommandType["RestorePaintDeclaration"] = 16] = "RestorePaintDeclaration";
|
|
62
|
+
// Drawing
|
|
61
63
|
CommandType[CommandType["DrawBox"] = 17] = "DrawBox";
|
|
62
64
|
CommandType[CommandType["DrawImage"] = 18] = "DrawImage";
|
|
63
65
|
CommandType[CommandType["DrawCircle"] = 19] = "DrawCircle";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CommandType","materializeProps","command","animatedProps","key","props","value","isCommand","type","isGroup","Group","isDrawCommand"],"sources":["Core.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\n\n// export enum CommandType {\n// // Context\n// Group = \"Group\",\n// SavePaint = \"SavePaint\",\n// RestorePaint = \"RestorePaint\",\n// SaveCTM = \"SaveCTM\",\n// RestoreCTM = \"RestoreCTM\",\n// PushColorFilter = \"PushColorFilter\",\n// PushBlurMaskFilter = \"PushBlurMaskFilter\",\n// PushImageFilter = \"PushImageFilter\",\n// PushPathEffect = \"PushPathEffect\",\n// PushShader = \"PushShader\",\n// ComposeColorFilter = \"ComposeColorFilter\",\n// ComposeImageFilter = \"ComposeImageFilter\",\n// ComposePathEffect = \"ComposePathEffect\",\n// MaterializePaint = \"MaterializePaint\",\n// SaveBackdropFilter = \"SaveBackdropFilter\",\n// SaveLayer = \"SaveLayer\",\n// RestorePaintDeclaration = \"RestorePaintDeclaration\",\n// // Drawing\n// DrawBox = \"DrawBox\",\n// DrawImage = \"DrawImage\",\n// DrawCircle = \"DrawCircle\",\n// DrawPaint = \"DrawPaint\",\n// DrawPoints = \"DrawPoints\",\n// DrawPath = \"DrawPath\",\n// DrawRect = \"DrawRect\",\n// DrawRRect = \"DrawRRect\",\n// DrawOval = \"DrawOval\",\n// DrawLine = \"DrawLine\",\n// DrawPatch = \"DrawPatch\",\n// DrawVertices = \"DrawVertices\",\n// DrawDiffRect = \"DrawDiffRect\",\n// DrawText = \"DrawText\",\n// DrawTextPath = \"DrawTextPath\",\n// DrawTextBlob = \"DrawTextBlob\",\n// DrawGlyphs = \"DrawGlyphs\",\n// DrawPicture = \"DrawPicture\",\n// DrawImageSVG = \"DrawImageSVG\",\n// DrawParagraph = \"DrawParagraph\",\n// DrawAtlas = \"DrawAtlas\",\n// }\nexport enum CommandType {\n // Context\n Group,\n SavePaint,\n RestorePaint,\n SaveCTM,\n RestoreCTM,\n PushColorFilter,\n PushBlurMaskFilter,\n PushImageFilter,\n PushPathEffect,\n PushShader,\n ComposeColorFilter,\n ComposeImageFilter,\n ComposePathEffect,\n MaterializePaint,\n SaveBackdropFilter,\n SaveLayer,\n RestorePaintDeclaration,\n // Drawing\n DrawBox,\n DrawImage,\n DrawCircle,\n DrawPaint,\n DrawPoints,\n DrawPath,\n DrawRect,\n DrawRRect,\n DrawOval,\n DrawLine,\n DrawPatch,\n DrawVertices,\n DrawDiffRect,\n DrawText,\n DrawTextPath,\n DrawTextBlob,\n DrawGlyphs,\n DrawPicture,\n DrawImageSVG,\n DrawParagraph,\n DrawAtlas,\n}\n\nexport type Command<T extends CommandType = CommandType> = {\n type: T;\n [key: string]: unknown;\n};\n\nexport const materializeProps = (command: {\n props: Record<string, unknown>;\n animatedProps?: Record<string, SharedValue<unknown>>;\n}) => {\n \"worklet\";\n if (command.animatedProps) {\n for (const key in command.animatedProps) {\n command.props[key] = command.animatedProps[key].value;\n }\n }\n};\n\nexport const isCommand = <T extends CommandType>(\n command: Command,\n type: T\n): command is Command<T> => {\n \"worklet\";\n return command.type === type;\n};\n\ninterface GroupCommand extends Command<CommandType.Group> {\n children: Command[];\n}\n\nexport const isGroup = (command: Command): command is GroupCommand => {\n \"worklet\";\n return command.type === CommandType.Group;\n};\n\ninterface Props {\n [CommandType.DrawImage]: ImageProps;\n [CommandType.DrawCircle]: CircleProps;\n [CommandType.SaveCTM]: CTMProps;\n [CommandType.SavePaint]: DrawingNodeProps;\n [CommandType.PushBlurMaskFilter]: BlurMaskFilterProps;\n [CommandType.DrawPoints]: PointsProps;\n [CommandType.DrawPath]: PathProps;\n [CommandType.DrawRect]: RectProps;\n [CommandType.DrawRRect]: RoundedRectProps;\n [CommandType.DrawOval]: OvalProps;\n [CommandType.DrawLine]: LineProps;\n [CommandType.DrawPatch]: PatchProps;\n [CommandType.DrawVertices]: VerticesProps;\n [CommandType.DrawDiffRect]: DiffRectProps;\n [CommandType.DrawText]: TextProps;\n [CommandType.DrawTextPath]: TextPathProps;\n [CommandType.DrawTextBlob]: TextBlobProps;\n [CommandType.DrawGlyphs]: GlyphsProps;\n [CommandType.DrawPicture]: PictureProps;\n [CommandType.DrawImageSVG]: ImageSVGProps;\n [CommandType.DrawParagraph]: ParagraphProps;\n [CommandType.DrawAtlas]: AtlasProps;\n}\n\ninterface DrawCommand<T extends CommandType> extends Command<T> {\n props: T extends keyof Props ? Props[T] : never;\n}\n\nexport const isDrawCommand = <T extends keyof Props>(\n command: Command,\n type: T\n): command is DrawCommand<T> => {\n \"worklet\";\n return command.type === type;\n};\n"],"mappings":"AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,WAAW,0BAAXA,WAAW;
|
|
1
|
+
{"version":3,"names":["CommandType","materializeProps","command","animatedProps","key","props","value","isCommand","type","isGroup","Group","isDrawCommand"],"sources":["Core.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n BlurMaskFilterProps,\n CircleProps,\n CTMProps,\n ImageProps,\n PointsProps,\n PathProps,\n RectProps,\n RoundedRectProps,\n OvalProps,\n LineProps,\n PatchProps,\n VerticesProps,\n DiffRectProps,\n TextProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n PictureProps,\n ImageSVGProps,\n ParagraphProps,\n AtlasProps,\n DrawingNodeProps,\n} from \"../../dom/types\";\n\n// export enum CommandType {\n// // Context\n// Group = \"Group\",\n// SavePaint = \"SavePaint\",\n// RestorePaint = \"RestorePaint\",\n// SaveCTM = \"SaveCTM\",\n// RestoreCTM = \"RestoreCTM\",\n// PushColorFilter = \"PushColorFilter\",\n// PushBlurMaskFilter = \"PushBlurMaskFilter\",\n// PushImageFilter = \"PushImageFilter\",\n// PushPathEffect = \"PushPathEffect\",\n// PushShader = \"PushShader\",\n// ComposeColorFilter = \"ComposeColorFilter\",\n// ComposeImageFilter = \"ComposeImageFilter\",\n// ComposePathEffect = \"ComposePathEffect\",\n// MaterializePaint = \"MaterializePaint\",\n// SaveBackdropFilter = \"SaveBackdropFilter\",\n// SaveLayer = \"SaveLayer\",\n// RestorePaintDeclaration = \"RestorePaintDeclaration\",\n// // Drawing\n// DrawBox = \"DrawBox\",\n// DrawImage = \"DrawImage\",\n// DrawCircle = \"DrawCircle\",\n// DrawPaint = \"DrawPaint\",\n// DrawPoints = \"DrawPoints\",\n// DrawPath = \"DrawPath\",\n// DrawRect = \"DrawRect\",\n// DrawRRect = \"DrawRRect\",\n// DrawOval = \"DrawOval\",\n// DrawLine = \"DrawLine\",\n// DrawPatch = \"DrawPatch\",\n// DrawVertices = \"DrawVertices\",\n// DrawDiffRect = \"DrawDiffRect\",\n// DrawText = \"DrawText\",\n// DrawTextPath = \"DrawTextPath\",\n// DrawTextBlob = \"DrawTextBlob\",\n// DrawGlyphs = \"DrawGlyphs\",\n// DrawPicture = \"DrawPicture\",\n// DrawImageSVG = \"DrawImageSVG\",\n// DrawParagraph = \"DrawParagraph\",\n// DrawAtlas = \"DrawAtlas\",\n// }\nexport enum CommandType {\n // Context\n Group,\n SavePaint,\n RestorePaint,\n SaveCTM,\n RestoreCTM,\n PushColorFilter,\n PushBlurMaskFilter,\n PushImageFilter,\n PushPathEffect,\n PushShader,\n ComposeColorFilter,\n ComposeImageFilter,\n ComposePathEffect,\n MaterializePaint,\n SaveBackdropFilter,\n SaveLayer,\n RestorePaintDeclaration,\n // Drawing\n DrawBox,\n DrawImage,\n DrawCircle,\n DrawPaint,\n DrawPoints,\n DrawPath,\n DrawRect,\n DrawRRect,\n DrawOval,\n DrawLine,\n DrawPatch,\n DrawVertices,\n DrawDiffRect,\n DrawText,\n DrawTextPath,\n DrawTextBlob,\n DrawGlyphs,\n DrawPicture,\n DrawImageSVG,\n DrawParagraph,\n DrawAtlas,\n}\n\nexport type Command<T extends CommandType = CommandType> = {\n type: T;\n [key: string]: unknown;\n};\n\nexport const materializeProps = (command: {\n props: Record<string, unknown>;\n animatedProps?: Record<string, SharedValue<unknown>>;\n}) => {\n \"worklet\";\n if (command.animatedProps) {\n for (const key in command.animatedProps) {\n command.props[key] = command.animatedProps[key].value;\n }\n }\n};\n\nexport const isCommand = <T extends CommandType>(\n command: Command,\n type: T\n): command is Command<T> => {\n \"worklet\";\n return command.type === type;\n};\n\ninterface GroupCommand extends Command<CommandType.Group> {\n children: Command[];\n}\n\nexport const isGroup = (command: Command): command is GroupCommand => {\n \"worklet\";\n return command.type === CommandType.Group;\n};\n\ninterface Props {\n [CommandType.DrawImage]: ImageProps;\n [CommandType.DrawCircle]: CircleProps;\n [CommandType.SaveCTM]: CTMProps;\n [CommandType.SavePaint]: DrawingNodeProps;\n [CommandType.PushBlurMaskFilter]: BlurMaskFilterProps;\n [CommandType.DrawPoints]: PointsProps;\n [CommandType.DrawPath]: PathProps;\n [CommandType.DrawRect]: RectProps;\n [CommandType.DrawRRect]: RoundedRectProps;\n [CommandType.DrawOval]: OvalProps;\n [CommandType.DrawLine]: LineProps;\n [CommandType.DrawPatch]: PatchProps;\n [CommandType.DrawVertices]: VerticesProps;\n [CommandType.DrawDiffRect]: DiffRectProps;\n [CommandType.DrawText]: TextProps;\n [CommandType.DrawTextPath]: TextPathProps;\n [CommandType.DrawTextBlob]: TextBlobProps;\n [CommandType.DrawGlyphs]: GlyphsProps;\n [CommandType.DrawPicture]: PictureProps;\n [CommandType.DrawImageSVG]: ImageSVGProps;\n [CommandType.DrawParagraph]: ParagraphProps;\n [CommandType.DrawAtlas]: AtlasProps;\n}\n\ninterface DrawCommand<T extends CommandType> extends Command<T> {\n props: T extends keyof Props ? Props[T] : never;\n}\n\nexport const isDrawCommand = <T extends keyof Props>(\n command: Command,\n type: T\n): command is DrawCommand<T> => {\n \"worklet\";\n return command.type === type;\n};\n"],"mappings":"AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,WAAW,0BAAXA,WAAW;EACrB;EADUA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA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AO,CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC;AAMD,OAAO,MAAMC,OAAO,GAAIP,OAAgB,IAA8B;EACpE,SAAS;;EACT,OAAOA,OAAO,CAACM,IAAI,KAAKR,WAAW,CAACU,KAAK;AAC3C,CAAC;AA+BD,OAAO,MAAMC,aAAa,GAAGA,CAC3BT,OAAgB,EAChBM,IAAO,KACuB;EAC9B,SAAS;;EACT,OAAON,OAAO,CAACM,IAAI,KAAKA,IAAI;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISkiaViewApi } from "../views/types";
|
|
2
|
+
import type { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
3
|
+
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
|
4
|
+
views: Record<string, SkiaPictureView>;
|
|
5
|
+
registerView(nativeId: string, view: SkiaPictureView): void;
|
|
6
|
+
};
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
global.SkiaViewApi = {
|
|
2
|
+
views: {},
|
|
3
|
+
web: true,
|
|
4
|
+
registerView(nativeId, view) {
|
|
5
|
+
this.views[nativeId] = view;
|
|
6
|
+
},
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
setJsiProperty(nativeId, name, value) {
|
|
9
|
+
if (name === "picture") {
|
|
10
|
+
this.views[`${nativeId}`].setPicture(value);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
requestRedraw(nativeId) {
|
|
14
|
+
this.views[`${nativeId}`].redraw();
|
|
15
|
+
},
|
|
16
|
+
makeImageSnapshot(nativeId, rect) {
|
|
17
|
+
return this.views[`${nativeId}`].makeImageSnapshot(rect);
|
|
18
|
+
},
|
|
19
|
+
makeImageSnapshotAsync(nativeId, rect) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const result = this.views[`${nativeId}`].makeImageSnapshot(rect);
|
|
22
|
+
if (result) {
|
|
23
|
+
resolve(result);
|
|
24
|
+
} else {
|
|
25
|
+
reject(new Error("Failed to make image snapshot"));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
2
31
|
//# sourceMappingURL=NativeSkiaModule.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":[""],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["global","SkiaViewApi","views","web","registerView","nativeId","view","setJsiProperty","name","value","setPicture","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["import type { SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureView } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureView>;\n registerView(nativeId: string, view: SkiaPictureView): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureView) {\n this.views[nativeId] = view;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n this.views[`${nativeId}`].setPicture(value);\n }\n },\n requestRedraw(nativeId: number) {\n this.views[`${nativeId}`].redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n return this.views[`${nativeId}`].makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const result = this.views[`${nativeId}`].makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n"],"mappings":"AASAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,IAAqB,EAAE;IACpD,IAAI,CAACJ,KAAK,CAACG,QAAQ,CAAC,GAAGC,IAAI;EAC7B,CAAC;EACD;EACAC,cAAcA,CAACF,QAAgB,EAAEG,IAAY,EAAEC,KAAU,EAAE;IACzD,IAAID,IAAI,KAAK,SAAS,EAAE;MACtB,IAAI,CAACN,KAAK,CAAC,GAAGG,QAAQ,EAAE,CAAC,CAACK,UAAU,CAACD,KAAK,CAAC;IAC7C;EACF,CAAC;EACDE,aAAaA,CAACN,QAAgB,EAAE;IAC9B,IAAI,CAACH,KAAK,CAAC,GAAGG,QAAQ,EAAE,CAAC,CAACO,MAAM,CAAC,CAAC;EACpC,CAAC;EACDC,iBAAiBA,CAACR,QAAgB,EAAES,IAAa,EAAE;IACjD,OAAO,IAAI,CAACZ,KAAK,CAAC,GAAGG,QAAQ,EAAE,CAAC,CAACQ,iBAAiB,CAACC,IAAI,CAAC;EAC1D,CAAC;EACDC,sBAAsBA,CAACV,QAAgB,EAAES,IAAa,EAAE;IACtD,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,MAAM,GAAG,IAAI,CAACjB,KAAK,CAAC,GAAGG,QAAQ,EAAE,CAAC,CAACQ,iBAAiB,CAACC,IAAI,CAAC;MAChE,IAAIK,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIE,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;AAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViewProps } from "react-native";
|
|
2
|
+
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
opaque?: boolean;
|
|
6
|
+
nativeID: string;
|
|
7
|
+
}
|
|
8
|
+
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").CElement<import("..").SkiaPictureViewNativeProps, SkiaPictureView>;
|
|
9
|
+
export default SkiaPictureViewNativeComponent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef } from "react";
|
|
2
|
+
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
3
|
+
const SkiaPictureViewNativeComponent = ({
|
|
4
|
+
nativeID,
|
|
5
|
+
debug,
|
|
6
|
+
opaque,
|
|
7
|
+
onLayout,
|
|
8
|
+
...viewProps
|
|
9
|
+
}) => {
|
|
10
|
+
const ref = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (ref.current) {
|
|
13
|
+
global.SkiaViewApi.registerView(nativeID, ref.current);
|
|
14
|
+
}
|
|
15
|
+
}, [nativeID]);
|
|
16
|
+
return /*#__PURE__*/createElement(SkiaPictureView, {
|
|
17
|
+
ref,
|
|
18
|
+
debug,
|
|
19
|
+
opaque,
|
|
20
|
+
onLayout,
|
|
21
|
+
...viewProps
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
// eslint-disable-next-line import/no-default-export
|
|
25
|
+
export default SkiaPictureViewNativeComponent;
|
|
26
|
+
//# sourceMappingURL=SkiaPictureViewNativeComponent.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElement","useEffect","useRef","SkiaPictureView","SkiaPictureViewNativeComponent","nativeID","debug","opaque","onLayout","viewProps","ref","current","global","SkiaViewApi","registerView"],"sources":["SkiaPictureViewNativeComponent.web.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport { createElement, useEffect, useRef } from \"react\";\n\nimport { SkiaPictureView } from \"../views/SkiaPictureView.web\";\n\nimport type { ISkiaViewApiWeb } from \"./NativeSkiaModule.web\";\n\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n nativeID: string;\n}\n\nconst SkiaPictureViewNativeComponent = ({\n nativeID,\n debug,\n opaque,\n onLayout,\n ...viewProps\n}: NativeProps) => {\n const ref = useRef(null);\n useEffect(() => {\n if (ref.current) {\n (global.SkiaViewApi as ISkiaViewApiWeb).registerView(\n nativeID,\n ref.current\n );\n }\n }, [nativeID]);\n return createElement(SkiaPictureView, {\n ref,\n debug,\n opaque,\n onLayout,\n ...viewProps,\n });\n};\n// eslint-disable-next-line import/no-default-export\nexport default SkiaPictureViewNativeComponent;\n"],"mappings":"AACA,SAASA,aAAa,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAExD,SAASC,eAAe,QAAQ,8BAA8B;AAU9D,MAAMC,8BAA8B,GAAGA,CAAC;EACtCC,QAAQ;EACRC,KAAK;EACLC,MAAM;EACNC,QAAQ;EACR,GAAGC;AACQ,CAAC,KAAK;EACjB,MAAMC,GAAG,GAAGR,MAAM,CAAC,IAAI,CAAC;EACxBD,SAAS,CAAC,MAAM;IACd,IAAIS,GAAG,CAACC,OAAO,EAAE;MACdC,MAAM,CAACC,WAAW,CAAqBC,YAAY,CAClDT,QAAQ,EACRK,GAAG,CAACC,OACN,CAAC;IACH;EACF,CAAC,EAAE,CAACN,QAAQ,CAAC,CAAC;EACd,oBAAOL,aAAa,CAACG,eAAe,EAAE;IACpCO,GAAG;IACHJ,KAAK;IACLC,MAAM;IACNC,QAAQ;IACR,GAAGC;EACL,CAAC,CAAC;AACJ,CAAC;AACD;AACA,eAAeL,8BAA8B","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ export type NativeSkiaViewProps = ViewProps & {
|
|
|
7
7
|
opaque?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export interface ISkiaViewApi {
|
|
10
|
+
web?: boolean;
|
|
10
11
|
setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
|
|
11
12
|
requestRedraw: (nativeId: number) => void;
|
|
12
13
|
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Node } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n opaque?: boolean;\n};\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValue<SkSize>;\n\n opaque?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: Node<unknown>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Node } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n opaque?: boolean;\n};\n\nexport interface ISkiaViewApi {\n web?: boolean;\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValue<SkSize>;\n\n opaque?: boolean;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: Node<unknown>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const __esModule: boolean;
|
|
2
2
|
export function interpolateColors(value: any, inputRange: any, _outputRange: any): any[];
|
|
3
|
-
export function mixColors(value: any, x: any, y: any): Float32Array
|
|
3
|
+
export function mixColors(value: any, x: any, y: any): Float32Array<ArrayBuffer>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const __esModule: boolean;
|
|
2
|
-
export function Color(color: any): Float32Array
|
|
2
|
+
export function Color(color: any): Float32Array<ArrayBufferLike>;
|
|
@@ -5,7 +5,7 @@ export function JsiSkApi(CanvasKit: any): {
|
|
|
5
5
|
RRectXY: (rect: any, rx: any, ry: any) => _JsiSkRRect.JsiSkRRect;
|
|
6
6
|
RSXform: (scos: any, ssin: any, tx: any, ty: any) => _JsiSkRSXform.JsiSkRSXform;
|
|
7
7
|
RSXformFromRadians: (scale: any, r: any, tx: any, ty: any, px: any, py: any) => _JsiSkRSXform.JsiSkRSXform;
|
|
8
|
-
Color: (color: any) => Float32Array
|
|
8
|
+
Color: (color: any) => Float32Array<ArrayBufferLike>;
|
|
9
9
|
ContourMeasureIter: (path: any, forceClosed: any, resScale: any) => _JsiSkContourMeasureIter.JsiSkContourMeasureIter;
|
|
10
10
|
Paint: () => _JsiSkPaint.JsiSkPaint;
|
|
11
11
|
PictureRecorder: () => _JsiSkPictureRecorder.JsiSkPictureRecorder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const __esModule: boolean;
|
|
2
|
+
export default SkiaPictureViewNativeComponent;
|
|
3
|
+
declare function SkiaPictureViewNativeComponent({ nativeID, debug, opaque, onLayout, ...viewProps }: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
nativeID: any;
|
|
6
|
+
debug: any;
|
|
7
|
+
opaque: any;
|
|
8
|
+
onLayout: any;
|
|
9
|
+
}): _react.DetailedReactHTMLElement<_react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
10
|
+
import _react = require("react");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export function interpolateColors(value: any, inputRange: any, _outputRange: any): any[];
|
|
2
|
-
export function mixColors(value: any, x: any, y: any): Float32Array
|
|
2
|
+
export function mixColors(value: any, x: any, y: any): Float32Array<ArrayBuffer>;
|
|
@@ -138,7 +138,7 @@ export function Mock(CanvasKit: any): {
|
|
|
138
138
|
interpolate(x: any, input: any, output: any, type: any): any;
|
|
139
139
|
Extrapolate: {};
|
|
140
140
|
interpolateColors: (value: any, inputRange: any, _outputRange: any) => any[];
|
|
141
|
-
mixColors: (value: any, x: any, y: any) => Float32Array
|
|
141
|
+
mixColors: (value: any, x: any, y: any) => Float32Array<ArrayBuffer>;
|
|
142
142
|
interpolateVector: (value: any, inputRange: any, outputRange: any, options: any) => {
|
|
143
143
|
x: any;
|
|
144
144
|
y: any;
|
|
@@ -356,7 +356,7 @@ export function Mock(CanvasKit: any): {
|
|
|
356
356
|
tx?: string | undefined;
|
|
357
357
|
ty?: string | undefined;
|
|
358
358
|
fit?: string | undefined;
|
|
359
|
-
transform?:
|
|
359
|
+
transform?: never[] | undefined;
|
|
360
360
|
}) => import("react").DOMElement<any, Element>;
|
|
361
361
|
ImageSVG: (props: any) => import("react").DOMElement<any, Element>;
|
|
362
362
|
RadialGradient: (props: any) => import("react").DOMElement<any, Element>;
|
|
@@ -3,6 +3,6 @@ export function ImageShader({ tx, ty, fit, transform, ...props }: {
|
|
|
3
3
|
tx?: string | undefined;
|
|
4
4
|
ty?: string | undefined;
|
|
5
5
|
fit?: string | undefined;
|
|
6
|
-
transform?:
|
|
6
|
+
transform?: never[] | undefined;
|
|
7
7
|
}): React.DOMElement<any, Element>;
|
|
8
8
|
import React from "react";
|
|
@@ -4,7 +4,7 @@ export const Skia: {
|
|
|
4
4
|
RRectXY: (rect: any, rx: any, ry: any) => import("./web/JsiSkRRect").JsiSkRRect;
|
|
5
5
|
RSXform: (scos: any, ssin: any, tx: any, ty: any) => import("./web/JsiSkRSXform").JsiSkRSXform;
|
|
6
6
|
RSXformFromRadians: (scale: any, r: any, tx: any, ty: any, px: any, py: any) => import("./web/JsiSkRSXform").JsiSkRSXform;
|
|
7
|
-
Color: (color: any) => Float32Array
|
|
7
|
+
Color: (color: any) => Float32Array<ArrayBufferLike>;
|
|
8
8
|
ContourMeasureIter: (path: any, forceClosed: any, resScale: any) => import("./web/JsiSkContourMeasureIter").JsiSkContourMeasureIter;
|
|
9
9
|
Paint: () => import("./web/JsiSkPaint").JsiSkPaint;
|
|
10
10
|
PictureRecorder: () => import("./web/JsiSkPictureRecorder").JsiSkPictureRecorder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function Color(color: any): Float32Array
|
|
1
|
+
export function Color(color: any): Float32Array<ArrayBufferLike>;
|
|
@@ -4,7 +4,7 @@ export function JsiSkApi(CanvasKit: any): {
|
|
|
4
4
|
RRectXY: (rect: any, rx: any, ry: any) => JsiSkRRect;
|
|
5
5
|
RSXform: (scos: any, ssin: any, tx: any, ty: any) => JsiSkRSXform;
|
|
6
6
|
RSXformFromRadians: (scale: any, r: any, tx: any, ty: any, px: any, py: any) => JsiSkRSXform;
|
|
7
|
-
Color: (color: any) => Float32Array
|
|
7
|
+
Color: (color: any) => Float32Array<ArrayBufferLike>;
|
|
8
8
|
ContourMeasureIter: (path: any, forceClosed: any, resScale: any) => JsiSkContourMeasureIter;
|
|
9
9
|
Paint: () => JsiSkPaint;
|
|
10
10
|
PictureRecorder: () => JsiSkPictureRecorder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default SkiaPictureViewNativeComponent;
|
|
2
|
+
declare function SkiaPictureViewNativeComponent({ nativeID, debug, opaque, onLayout, ...viewProps }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
nativeID: any;
|
|
5
|
+
debug: any;
|
|
6
|
+
opaque: any;
|
|
7
|
+
onLayout: any;
|
|
8
|
+
}): import("react").CElement<any, SkiaPictureView>;
|
|
9
|
+
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Color } from "../../skia";
|
|
2
2
|
export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) => number[];
|
|
3
|
-
export declare const mixColors: (value: number, x: Color, y: Color) => Float32Array
|
|
3
|
+
export declare const mixColors: (value: number, x: Color, y: Color) => Float32Array<ArrayBuffer>;
|
|
@@ -242,9 +242,9 @@ export declare const transformOrigin: (origin: Vector, transform: Transforms3d)
|
|
|
242
242
|
rotateY: number;
|
|
243
243
|
matrix: import("../../../skia/types").Matrix4;
|
|
244
244
|
}, "matrix">)[];
|
|
245
|
-
export declare const processColor: (Skia: Skia, color: number | string | Float32Array | number[]) =>
|
|
245
|
+
export declare const processColor: (Skia: Skia, color: number | string | Float32Array | number[]) => import("../../../skia/types").SkColor;
|
|
246
246
|
export declare const processGradientProps: (Skia: Skia, { colors, positions, mode, flags, ...transform }: GradientProps) => {
|
|
247
|
-
colors:
|
|
247
|
+
colors: import("../../../skia/types").SkColor[];
|
|
248
248
|
positions: number[] | null;
|
|
249
249
|
mode: TileMode;
|
|
250
250
|
flags: number | undefined;
|
|
@@ -3,5 +3,5 @@ type Modifier<T> = (input: T, index: number) => void;
|
|
|
3
3
|
export declare const useRectBuffer: (size: number, modifier: Modifier<SkHostRect>) => import("react-native-reanimated/lib/typescript/commonTypes").Mutable<SkHostRect[]>;
|
|
4
4
|
export declare const useRSXformBuffer: (size: number, modifier: Modifier<SkRSXform>) => import("react-native-reanimated/lib/typescript/commonTypes").Mutable<SkRSXform[]>;
|
|
5
5
|
export declare const usePointBuffer: (size: number, modifier: Modifier<SkPoint>) => import("react-native-reanimated/lib/typescript/commonTypes").Mutable<SkPoint[]>;
|
|
6
|
-
export declare const useColorBuffer: (size: number, modifier: Modifier<SkColor>) => import("react-native-reanimated/lib/typescript/commonTypes").Mutable<
|
|
6
|
+
export declare const useColorBuffer: (size: number, modifier: Modifier<SkColor>) => import("react-native-reanimated/lib/typescript/commonTypes").Mutable<SkColor[]>;
|
|
7
7
|
export {};
|
|
@@ -24,7 +24,7 @@ export declare let fonts: {
|
|
|
24
24
|
DinMedium: SkFont;
|
|
25
25
|
};
|
|
26
26
|
export declare const wait: (ms: number) => Promise<unknown>;
|
|
27
|
-
export declare const resolveFile: (uri: string) => Buffer
|
|
27
|
+
export declare const resolveFile: (uri: string) => Buffer<ArrayBufferLike>;
|
|
28
28
|
export declare const resolveFont: (uri: string) => number[];
|
|
29
29
|
export declare const testingFonts: {
|
|
30
30
|
Roboto: number[][];
|
|
@@ -43,5 +43,5 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
|
43
43
|
concat(m: SkMatrix | number[]): void;
|
|
44
44
|
drawPicture(skp: SkPicture): void;
|
|
45
45
|
drawAtlas(atlas: SkImage, srcs: SkRect[], dsts: SkRSXform[], paint: SkPaint, blendMode?: BlendMode, colors?: SkColor[], sampling?: CubicResampler | FilterOptions): void;
|
|
46
|
-
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
|
|
46
|
+
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null;
|
|
47
47
|
}
|
|
@@ -9,9 +9,9 @@ export declare class JsiSkImage extends HostObject<Image, "Image"> implements Sk
|
|
|
9
9
|
getImageInfo(): ImageInfo;
|
|
10
10
|
makeShaderOptions(tx: TileMode, ty: TileMode, fm: FilterMode, mm: MipmapMode, localMatrix?: SkMatrix): SkShader;
|
|
11
11
|
makeShaderCubic(tx: TileMode, ty: TileMode, B: number, C: number, localMatrix?: SkMatrix): SkShader;
|
|
12
|
-
encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array
|
|
12
|
+
encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array<ArrayBufferLike>;
|
|
13
13
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
|
14
|
-
readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo): Float32Array | Uint8Array | null;
|
|
14
|
+
readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo): Float32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null;
|
|
15
15
|
dispose: () => void;
|
|
16
16
|
makeNonTextureImage(): SkImage;
|
|
17
17
|
getNativeTextureUnstable(): unknown;
|
|
@@ -8,7 +8,7 @@ export declare class JsiSkPaint extends HostObject<Paint, "Paint"> implements Sk
|
|
|
8
8
|
assign(paint: JsiSkPaint): void;
|
|
9
9
|
reset(): void;
|
|
10
10
|
getAlphaf(): number;
|
|
11
|
-
getColor():
|
|
11
|
+
getColor(): import("canvaskit-wasm").Color;
|
|
12
12
|
getStrokeCap(): number;
|
|
13
13
|
getStrokeJoin(): number;
|
|
14
14
|
getStrokeMiter(): number;
|
|
@@ -6,5 +6,5 @@ export declare class JsiSkPicture extends HostObject<Picture, "Picture"> impleme
|
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Picture);
|
|
7
7
|
dispose: () => void;
|
|
8
8
|
makeShader(tmx: TileMode, tmy: TileMode, mode: FilterMode, localMatrix?: SkMatrix, tileRect?: SkRect): JsiSkShader;
|
|
9
|
-
serialize(): Uint8Array | null;
|
|
9
|
+
serialize(): Uint8Array<ArrayBufferLike> | null;
|
|
10
10
|
}
|
|
@@ -2,7 +2,7 @@ import type { CanvasKit, Point } from "canvaskit-wasm";
|
|
|
2
2
|
import type { SkPoint } from "../types";
|
|
3
3
|
import { BaseHostObject } from "./Host";
|
|
4
4
|
export declare class JsiSkPoint extends BaseHostObject<Point, "Point"> implements SkPoint {
|
|
5
|
-
static fromValue(point: SkPoint): Float32Array
|
|
5
|
+
static fromValue(point: SkPoint): Float32Array<ArrayBuffer>;
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Point);
|
|
7
7
|
dispose: () => void;
|
|
8
8
|
get x(): number;
|
|
@@ -4,7 +4,7 @@ import { BaseHostObject } from "./Host";
|
|
|
4
4
|
import { JsiSkRect } from "./JsiSkRect";
|
|
5
5
|
export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
|
|
6
6
|
dispose: () => void;
|
|
7
|
-
static fromValue(CanvasKit: CanvasKit, rect: InputRRect): Float32Array
|
|
7
|
+
static fromValue(CanvasKit: CanvasKit, rect: InputRRect): Float32Array<ArrayBuffer>;
|
|
8
8
|
constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number);
|
|
9
9
|
get rx(): number;
|
|
10
10
|
get ry(): number;
|
|
@@ -3,7 +3,7 @@ import type { SkRSXform } from "../types";
|
|
|
3
3
|
import { BaseHostObject } from "./Host";
|
|
4
4
|
export type RSXform = Float32Array;
|
|
5
5
|
export declare class JsiSkRSXform extends BaseHostObject<RSXform, "RSXform"> implements SkRSXform {
|
|
6
|
-
static fromValue(rsxform: SkRSXform): Float32Array
|
|
6
|
+
static fromValue(rsxform: SkRSXform): Float32Array<ArrayBuffer>;
|
|
7
7
|
constructor(CanvasKit: CanvasKit, ref: RSXform);
|
|
8
8
|
set(scos: number, ssin: number, tx: number, ty: number): void;
|
|
9
9
|
get scos(): number;
|
|
@@ -2,7 +2,7 @@ import type { CanvasKit, Rect } from "canvaskit-wasm";
|
|
|
2
2
|
import type { SkHostRect, SkRect } from "../types";
|
|
3
3
|
import { BaseHostObject } from "./Host";
|
|
4
4
|
export declare class JsiSkRect extends BaseHostObject<Rect, "Rect"> implements SkHostRect {
|
|
5
|
-
static fromValue(CanvasKit: CanvasKit, rect: SkRect):
|
|
5
|
+
static fromValue(CanvasKit: CanvasKit, rect: SkRect): Rect;
|
|
6
6
|
dispose: () => void;
|
|
7
7
|
constructor(CanvasKit: CanvasKit, ref: Rect);
|
|
8
8
|
setXYWH(x: number, y: number, width: number, height: number): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Skia, SkCanvas } from "../skia/types";
|
|
2
2
|
import type { Node } from "./Node";
|
|
3
3
|
import type { Recording } from "./Recorder/Recorder";
|
|
4
|
+
import "../views/api";
|
|
4
5
|
export declare abstract class Container {
|
|
5
6
|
protected Skia: Skia;
|
|
6
7
|
protected nativeId: number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISkiaViewApi } from "../views/types";
|
|
2
|
+
import type { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
3
|
+
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
|
4
|
+
views: Record<string, SkiaPictureView>;
|
|
5
|
+
registerView(nativeId: string, view: SkiaPictureView): void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViewProps } from "react-native";
|
|
2
|
+
import { SkiaPictureView } from "../views/SkiaPictureView.web";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
opaque?: boolean;
|
|
6
|
+
nativeID: string;
|
|
7
|
+
}
|
|
8
|
+
declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").CElement<import("..").SkiaPictureViewNativeProps, SkiaPictureView>;
|
|
9
|
+
export default SkiaPictureViewNativeComponent;
|
|
@@ -7,6 +7,7 @@ export type NativeSkiaViewProps = ViewProps & {
|
|
|
7
7
|
opaque?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export interface ISkiaViewApi {
|
|
10
|
+
web?: boolean;
|
|
10
11
|
setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
|
|
11
12
|
requestRedraw: (nativeId: number) => void;
|
|
12
13
|
makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
|
9
9
|
},
|
|
10
10
|
"title": "React Native Skia",
|
|
11
|
-
"version": "1.11.
|
|
11
|
+
"version": "1.11.6",
|
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
|
13
13
|
"main": "lib/module/index.js",
|
|
14
14
|
"react-native": "src/index.ts",
|
package/src/sksg/Container.ts
CHANGED
|
@@ -11,6 +11,8 @@ import { replay } from "./Recorder/Player";
|
|
|
11
11
|
import { createDrawingContext } from "./Recorder/DrawingContext";
|
|
12
12
|
import { ReanimatedRecorder } from "./Recorder/ReanimatedRecorder";
|
|
13
13
|
|
|
14
|
+
import "../views/api";
|
|
15
|
+
|
|
14
16
|
const drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {
|
|
15
17
|
"worklet";
|
|
16
18
|
|
|
@@ -24,8 +26,6 @@ const drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {
|
|
|
24
26
|
//const end = performance.now();
|
|
25
27
|
//console.log("Recording time: ", end - start);
|
|
26
28
|
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
|
27
|
-
rec.dispose();
|
|
28
|
-
picture.dispose();
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {
|
|
@@ -140,6 +140,10 @@ class NativeReanimatedContainer extends Container {
|
|
|
140
140
|
visit(recorder, this.root);
|
|
141
141
|
const sharedValues = recorder.getSharedValues();
|
|
142
142
|
const sharedRecorder = recorder.getRecorder();
|
|
143
|
+
Rea.runOnUI(() => {
|
|
144
|
+
"worklet";
|
|
145
|
+
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
146
|
+
})();
|
|
143
147
|
if (sharedValues.length > 0) {
|
|
144
148
|
this.mapperId = Rea.startMapper(() => {
|
|
145
149
|
"worklet";
|
|
@@ -147,17 +151,13 @@ class NativeReanimatedContainer extends Container {
|
|
|
147
151
|
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
148
152
|
}, sharedValues);
|
|
149
153
|
}
|
|
150
|
-
Rea.runOnUI(() => {
|
|
151
|
-
"worklet";
|
|
152
|
-
nativeDrawOnscreen(nativeId, sharedRecorder);
|
|
153
|
-
})();
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
export const createContainer = (Skia: Skia, nativeId: number) => {
|
|
158
|
-
const
|
|
158
|
+
const web = global.SkiaViewApi && global.SkiaViewApi.web;
|
|
159
159
|
if (HAS_REANIMATED_3 && nativeId !== -1) {
|
|
160
|
-
if (
|
|
160
|
+
if (!web) {
|
|
161
161
|
return new NativeReanimatedContainer(Skia, nativeId);
|
|
162
162
|
} else {
|
|
163
163
|
return new ReanimatedContainer(Skia, nativeId);
|