@shopify/react-native-skia 2.6.9 → 2.7.0
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/cpp/jni/include/JniSkiaBaseView.h +6 -4
- package/android/cpp/jni/include/JniSkiaPictureView.h +8 -6
- package/android/cpp/rnskia-android/OpenGLContext.h +10 -1
- package/android/cpp/rnskia-android/RNSkAndroidView.h +8 -8
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +9 -5
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +4 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +48 -12
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +5 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -7
- package/apple/MetalContext.h +7 -6
- package/apple/MetalLayerColorSpace.mm +39 -0
- package/apple/MetalLayerColorSpaceUtils.h +34 -0
- package/apple/MetalWindowContext.h +3 -1
- package/apple/MetalWindowContext.mm +9 -8
- package/apple/RNSkAppleView.h +6 -0
- package/apple/RNSkMetalCanvasProvider.h +2 -0
- package/apple/RNSkMetalCanvasProvider.mm +15 -2
- package/apple/SkiaPictureView.mm +1 -0
- package/apple/SkiaPictureViewManager.mm +5 -0
- package/apple/SkiaUIView.h +1 -0
- package/apple/SkiaUIView.mm +9 -0
- package/cpp/api/JsiSkSurface.h +8 -2
- package/cpp/rnskia/RNDawnContext.h +4 -3
- package/cpp/rnskia/RNDawnUtils.h +25 -6
- package/cpp/rnskia/RNDawnWindowContext.h +44 -10
- package/cpp/rnskia/RNMetalLayerColorSpace.h +16 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +46 -24
- package/cpp/rnwgpu/SurfaceRegistry.h +10 -4
- package/lib/commonjs/Platform/Platform.web.js +2 -90
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +10 -1
- package/lib/commonjs/renderer/Canvas.js +2 -0
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +5 -1
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +14 -3
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +2 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/sksg/Container.native.d.ts +1 -0
- package/lib/commonjs/sksg/Container.native.js +11 -0
- package/lib/commonjs/sksg/Container.native.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.d.ts +1 -0
- package/lib/commonjs/sksg/Container.web.js +11 -0
- package/lib/commonjs/sksg/Container.web.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js +32 -7
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +2 -0
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +279 -94
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/formats.d.ts +1 -0
- package/lib/commonjs/views/formats.js +28 -0
- package/lib/commonjs/views/formats.js.map +1 -0
- package/lib/commonjs/views/index.d.ts +1 -0
- package/lib/commonjs/views/index.js +11 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +6 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +3 -91
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/mock/index.js +1 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +10 -1
- package/lib/module/renderer/Canvas.js +2 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +5 -1
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +14 -3
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/module/skia/web/JsiSkSurface.js +2 -1
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/sksg/Container.native.d.ts +1 -0
- package/lib/module/sksg/Container.native.js +11 -0
- package/lib/module/sksg/Container.native.js.map +1 -1
- package/lib/module/sksg/Container.web.d.ts +1 -0
- package/lib/module/sksg/Container.web.js +11 -0
- package/lib/module/sksg/Container.web.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
- package/lib/module/specs/NativeSkiaModule.web.js +32 -7
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +2 -0
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +280 -95
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/formats.d.ts +1 -0
- package/lib/module/views/formats.js +22 -0
- package/lib/module/views/formats.js.map +1 -0
- package/lib/module/views/index.d.ts +1 -0
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/module/views/types.d.ts +6 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/Platform/Platform.web.d.ts +1 -2
- package/lib/typescript/lib/commonjs/mock/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +2 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +1 -1
- package/lib/typescript/lib/commonjs/views/formats.d.ts +2 -0
- package/lib/typescript/lib/module/Platform/Platform.web.d.ts +1 -3
- package/lib/typescript/lib/module/mock/index.d.ts +2 -2
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +2 -1
- package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.native.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +1 -1
- package/lib/typescript/lib/module/views/formats.d.ts +1 -0
- package/lib/typescript/lib/module/views/index.d.ts +1 -0
- package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +5 -1
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/typescript/src/sksg/Container.native.d.ts +1 -0
- package/lib/typescript/src/sksg/Container.web.d.ts +1 -0
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/typescript/src/views/formats.d.ts +1 -0
- package/lib/typescript/src/views/index.d.ts +1 -0
- package/lib/typescript/src/views/types.d.ts +6 -0
- package/package.json +4 -1
- package/react-native-skia.podspec +1 -0
- package/src/Platform/Platform.web.tsx +7 -99
- package/src/mock/index.ts +1 -0
- package/src/renderer/Canvas.tsx +11 -0
- package/src/skia/types/Surface/Surface.ts +5 -1
- package/src/skia/web/JsiSkParagraphStyle.ts +16 -2
- package/src/skia/web/JsiSkSurface.ts +2 -1
- package/src/sksg/Container.native.ts +12 -0
- package/src/sksg/Container.web.ts +12 -0
- package/src/specs/NativeSkiaModule.web.ts +39 -7
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
- package/src/views/SkiaPictureView.tsx +2 -0
- package/src/views/SkiaPictureView.web.tsx +318 -106
- package/src/views/formats.ts +21 -0
- package/src/views/index.ts +1 -0
- package/src/views/types.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TextDirection","JsiSkParagraphStyle","toParagraphStyle","ck","value","_value$disableHinting","_value$ellipsis","_value$heightMultipli","_value$maxLines","_value$replaceTabChar","_ps$strutStyle","_value$strutStyle$fon","_value$strutStyle","_value$strutStyle$fon2","_value$strutStyle2","_value$strutStyle$hei","_value$strutStyle3","_value$strutStyle$lea","_value$strutStyle4","_value$strutStyle$for","_value$strutStyle5","_ps$strutStyle$fontSt","_value$strutStyle6","_value$strutStyle7","_value$strutStyle8","_value$strutStyle$hal","_value$strutStyle9","_value$strutStyle$str","_value$strutStyle0","
|
|
1
|
+
{"version":3,"names":["TextDirection","JsiSkTextStyle","JsiSkParagraphStyle","toParagraphStyle","ck","value","_value$disableHinting","_value$ellipsis","_value$heightMultipli","_value$maxLines","_value$replaceTabChar","_ps$strutStyle","_value$strutStyle$fon","_value$strutStyle","_value$strutStyle$fon2","_value$strutStyle2","_value$strutStyle$hei","_value$strutStyle3","_value$strutStyle$lea","_value$strutStyle4","_value$strutStyle$for","_value$strutStyle5","_ps$strutStyle$fontSt","_value$strutStyle6","_value$strutStyle7","_value$strutStyle8","_value$strutStyle$hal","_value$strutStyle9","_value$strutStyle$str","_value$strutStyle0","textStyle","color","BLACK","Object","entries","toTextStyle","forEach","key","v","undefined","ps","ParagraphStyle","disableHinting","ellipsis","heightMultiplier","maxLines","replaceTabCharacters","textAlign","textDirection","LTR","textHeightBehavior","strutStyle","fontFamilies","fontSize","leading","forceStrutHeight","fontStyle","slant","width","weight","halfLeading","strutEnabled"],"sources":["JsiSkParagraphStyle.ts"],"sourcesContent":["import type { CanvasKit, ParagraphStyle, TextStyle } from \"canvaskit-wasm\";\n\nimport { TextDirection } from \"../types\";\nimport type { SkParagraphStyle } from \"../types\";\n\nimport { JsiSkTextStyle } from \"./JsiSkTextStyle\";\n\nexport class JsiSkParagraphStyle {\n static toParagraphStyle(\n ck: CanvasKit,\n value: SkParagraphStyle\n ): ParagraphStyle {\n // Seems like we need to provide the textStyle.color value, otherwise\n // the constructor crashes.\n const textStyle: TextStyle = { color: ck.BLACK };\n if (value.textStyle) {\n // Only merge the properties that are set; toTextStyle() emits undefined\n // for the others and the ParagraphStyle constructor requires a color.\n Object.entries(JsiSkTextStyle.toTextStyle(value.textStyle)).forEach(\n ([key, v]) => {\n if (v !== undefined) {\n (textStyle as Record<string, unknown>)[key] = v;\n }\n }\n );\n }\n const ps = new ck.ParagraphStyle({ textStyle });\n\n ps.disableHinting = value.disableHinting ?? ps.disableHinting;\n ps.ellipsis = value.ellipsis ?? ps.ellipsis;\n ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;\n ps.maxLines = value.maxLines ?? ps.maxLines;\n ps.replaceTabCharacters =\n value.replaceTabCharacters ?? ps.replaceTabCharacters;\n ps.textAlign =\n value.textAlign !== undefined ? { value: value.textAlign } : ps.textAlign;\n ps.textDirection =\n value.textDirection !== undefined\n ? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }\n : ps.textDirection;\n ps.textHeightBehavior =\n value.textHeightBehavior !== undefined\n ? { value: value.textHeightBehavior }\n : ps.textHeightBehavior;\n\n ps.strutStyle = ps.strutStyle ?? {};\n ps.strutStyle.fontFamilies =\n value.strutStyle?.fontFamilies ?? ps.strutStyle.fontFamilies;\n ps.strutStyle.fontSize =\n value.strutStyle?.fontSize ?? ps.strutStyle.fontSize;\n ps.strutStyle.heightMultiplier =\n value.strutStyle?.heightMultiplier ?? ps.strutStyle.heightMultiplier;\n ps.strutStyle.leading = value.strutStyle?.leading ?? ps.strutStyle.leading;\n ps.strutStyle.forceStrutHeight =\n value.strutStyle?.forceStrutHeight ?? ps.strutStyle.forceStrutHeight;\n\n ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};\n\n ps.strutStyle.fontStyle.slant =\n value.strutStyle?.fontStyle?.slant !== undefined\n ? { value: value.strutStyle.fontStyle.slant }\n : ps.strutStyle.fontStyle.slant;\n ps.strutStyle.fontStyle.width =\n value.strutStyle?.fontStyle?.width !== undefined\n ? { value: value.strutStyle.fontStyle.width }\n : ps.strutStyle.fontStyle.width;\n ps.strutStyle.fontStyle.weight =\n value.strutStyle?.fontStyle?.weight !== undefined\n ? { value: value.strutStyle.fontStyle.weight }\n : ps.strutStyle.fontStyle.weight;\n ps.strutStyle.halfLeading =\n value.strutStyle?.halfLeading ?? ps.strutStyle.halfLeading;\n ps.strutStyle.strutEnabled =\n value.strutStyle?.strutEnabled ?? ps.strutStyle.strutEnabled;\n\n return ps;\n }\n}\n"],"mappings":"AAEA,SAASA,aAAa,QAAQ,UAAU;AAGxC,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,MAAMC,mBAAmB,CAAC;EAC/B,OAAOC,gBAAgBA,CACrBC,EAAa,EACbC,KAAuB,EACP;IAAA,IAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,cAAA,EAAAC,qBAAA,EAAAC,iBAAA,EAAAC,sBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA;IAChB;IACA;IACA,MAAMC,SAAoB,GAAG;MAAEC,KAAK,EAAE3B,EAAE,CAAC4B;IAAM,CAAC;IAChD,IAAI3B,KAAK,CAACyB,SAAS,EAAE;MACnB;MACA;M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/B,kBAAA,uBAA3BA,kBAAA,CAA6BkC,MAAM,MAAKpB,SAAS,GAC7C;MAAElC,KAAK,EAAEA,KAAK,CAAC8C,UAAU,CAACK,SAAS,CAACG;IAAO,CAAC,GAC5CnB,EAAE,CAACW,UAAU,CAACK,SAAS,CAACG,MAAM;IACpCnB,EAAE,CAACW,UAAU,CAACS,WAAW,IAAAlC,qBAAA,IAAAC,kBAAA,GACvBtB,KAAK,CAAC8C,UAAU,cAAAxB,kBAAA,uBAAhBA,kBAAA,CAAkBiC,WAAW,cAAAlC,qBAAA,cAAAA,qBAAA,GAAIc,EAAE,CAACW,UAAU,CAACS,WAAW;IAC5DpB,EAAE,CAACW,UAAU,CAACU,YAAY,IAAAjC,qBAAA,IAAAC,kBAAA,GACxBxB,KAAK,CAAC8C,UAAU,cAAAtB,kBAAA,uBAAhBA,kBAAA,CAAkBgC,YAAY,cAAAjC,qBAAA,cAAAA,qBAAA,GAAIY,EAAE,CAACW,UAAU,CAACU,YAAY;IAE9D,OAAOrB,EAAE;EACX;AACF","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ import { JsiSkImage } from "./JsiSkImage";
|
|
|
5
5
|
export declare class JsiSkSurface extends HostObject<Surface, "Surface"> implements SkSurface {
|
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Surface);
|
|
7
7
|
[Symbol.dispose](): void;
|
|
8
|
-
flush(): void;
|
|
8
|
+
flush(_sync?: boolean): void;
|
|
9
9
|
width(): number;
|
|
10
10
|
height(): number;
|
|
11
11
|
getCanvas(): SkCanvas;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkCanvas","JsiSkImage","JsiSkRect","JsiSkSurface","constructor","CanvasKit","ref","Symbol","dispose","flush","width","height","getCanvas","makeImageSnapshot","bounds","outputImage","image","Array","from","fromValue","undefined","getNativeTextureUnstable","console","warn"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n [Symbol.dispose]() {\n this.ref.dispose();\n }\n\n flush() {\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n if (outputImage) {\n outputImage.ref = image;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":"AAIA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AAEvC,OAAO,MAAMC,YAAY,SACfJ,UAAU,CAEpB;EACEK,WAAWA,CAACC,SAAoB,EAAEC,GAAY,EAAE;IAC9C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,SAAS,CAAC;EAClC;EAEA,CAACC,MAAM,CAACC,OAAO,IAAI;IACjB,IAAI,CAACF,GAAG,CAACE,OAAO,CAAC,CAAC;EACpB;EAEAC,KAAKA,
|
|
1
|
+
{"version":3,"names":["HostObject","JsiSkCanvas","JsiSkImage","JsiSkRect","JsiSkSurface","constructor","CanvasKit","ref","Symbol","dispose","flush","_sync","width","height","getCanvas","makeImageSnapshot","bounds","outputImage","image","Array","from","fromValue","undefined","getNativeTextureUnstable","console","warn"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n [Symbol.dispose]() {\n this.ref.dispose();\n }\n\n flush(_sync?: boolean) {\n // CanvasKit has no separate CPU sync; flush() is sufficient on the web backend.\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n if (outputImage) {\n outputImage.ref = image;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":"AAIA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAAQ,aAAa;AAEvC,OAAO,MAAMC,YAAY,SACfJ,UAAU,CAEpB;EACEK,WAAWA,CAACC,SAAoB,EAAEC,GAAY,EAAE;IAC9C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,SAAS,CAAC;EAClC;EAEA,CAACC,MAAM,CAACC,OAAO,IAAI;IACjB,IAAI,CAACF,GAAG,CAACE,OAAO,CAAC,CAAC;EACpB;EAEAC,KAAKA,CAACC,KAAe,EAAE;IACrB;IACA,IAAI,CAACJ,GAAG,CAACG,KAAK,CAAC,CAAC;EAClB;EAEAE,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACL,GAAG,CAACK,KAAK,CAAC,CAAC;EACzB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACN,GAAG,CAACM,MAAM,CAAC,CAAC;EAC1B;EAEAC,SAASA,CAAA,EAAa;IACpB,OAAO,IAAIb,WAAW,CAAC,IAAI,CAACK,SAAS,EAAE,IAAI,CAACC,GAAG,CAACO,SAAS,CAAC,CAAC,CAAC;EAC9D;EAEAC,iBAAiBA,CAACC,MAAe,EAAEC,WAAwB,EAAW;IACpE,MAAMC,KAAK,GAAG,IAAI,CAACX,GAAG,CAACQ,iBAAiB,CACtCC,MAAM,GACFG,KAAK,CAACC,IAAI,CAACjB,SAAS,CAACkB,SAAS,CAAC,IAAI,CAACf,SAAS,EAAEU,MAAM,CAAC,CAAC,GACvDM,SACN,CAAC;IACD,IAAIL,WAAW,EAAE;MACfA,WAAW,CAACV,GAAG,GAAGW,KAAK;IACzB;IACA,OAAO,IAAIhB,UAAU,CAAC,IAAI,CAACI,SAAS,EAAEY,KAAK,CAAC;EAC9C;EAEAK,wBAAwBA,CAAA,EAAY;IAClCC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAC;IAC3D,OAAO,IAAI;EACb;AACF","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ declare class NativeReanimatedContainer extends Container {
|
|
|
7
7
|
private mapperId;
|
|
8
8
|
private picture;
|
|
9
9
|
constructor(Skia: Skia, nativeId: number);
|
|
10
|
+
unmount(): void;
|
|
10
11
|
redraw(): void;
|
|
11
12
|
}
|
|
12
13
|
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | NativeReanimatedContainer;
|
|
@@ -30,9 +30,20 @@ class NativeReanimatedContainer extends Container {
|
|
|
30
30
|
_defineProperty(this, "picture", void 0);
|
|
31
31
|
this.picture = Skia.Picture.MakePicture(null);
|
|
32
32
|
}
|
|
33
|
+
unmount() {
|
|
34
|
+
super.unmount();
|
|
35
|
+
if (this.mapperId !== null) {
|
|
36
|
+
// The mapper closure retains the recorder and its resources (e.g.
|
|
37
|
+
// images) on the UI runtime and keeps updating the picture of an
|
|
38
|
+
// unmounted view — stop it or it leaks for the lifetime of the app.
|
|
39
|
+
Rea.stopMapper(this.mapperId);
|
|
40
|
+
this.mapperId = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
33
43
|
redraw() {
|
|
34
44
|
if (this.mapperId !== null) {
|
|
35
45
|
Rea.stopMapper(this.mapperId);
|
|
46
|
+
this.mapperId = null;
|
|
36
47
|
}
|
|
37
48
|
if (this.unmounted) {
|
|
38
49
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","SkiaViewApi","globalThis","nativeDrawOnscreen","nativeId","recorder","picture","play","setJsiProperty","NativeReanimatedContainer","constructor","Skia","_defineProperty","Picture","MakePicture","
|
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","SkiaViewApi","globalThis","nativeDrawOnscreen","nativeId","recorder","picture","play","setJsiProperty","NativeReanimatedContainer","constructor","Skia","_defineProperty","Picture","MakePicture","unmount","mapperId","stopMapper","redraw","unmounted","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkPicture } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n picture: SkPicture\n) => {\n \"worklet\";\n\n //const start = performance.now();\n recorder.play(picture);\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n private picture: SkPicture;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n this.picture = Skia.Picture.MakePicture(null)!;\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recorder and its resources (e.g.\n // images) on the UI runtime and keeps updating the picture of an\n // unmounted view — stop it or it leaks for the lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new ReanimatedRecorder(this.Skia);\n const { nativeId, picture } = this;\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n // Draw first frame\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n })();\n // Animate\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativ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AAI,IAAI,CAACG,SAAS,EAAE;MAClB;IACF;IACA,MAAMd,QAAQ,GAAG,IAAIR,kBAAkB,CAAC,IAAI,CAACc,IAAI,CAAC;IAClD,MAAM;MAAEP,QAAQ;MAAEE;IAAQ,CAAC,GAAG,IAAI;IAClCN,KAAK,CAACK,QAAQ,EAAE,IAAI,CAACe,IAAI,CAAC;IAC1B,MAAMC,YAAY,GAAGhB,QAAQ,CAACiB,eAAe,CAAC,CAAC;IAC/C,MAAMC,cAAc,GAAGlB,QAAQ,CAACmB,WAAW,CAAC,CAAC;IAC7C;IACA7B,GAAG,CAAC8B,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTtB,kBAAkB,CAACC,QAAQ,EAAEmB,cAAc,EAAEjB,OAAO,CAAC;IACvD,CAAC,CAAC,CAAC,CAAC;IACJ;IACA,IAAIe,YAAY,CAACK,MAAM,GAAG,CAAC,EAAE;MAC3B,IAAI,CAACV,QAAQ,GAAGrB,GAAG,CAACgC,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTJ,cAAc,CAACK,YAAY,CAACP,YAAY,CAAC;QACzClB,kBAAkB,CAACC,QAAQ,EAAEmB,cAAc,EAAEjB,OAAO,CAAC;MACvD,CAAC,EAAEe,YAAY,CAAC;IAClB;EACF;AACF;AAEA,OAAO,MAAMQ,eAAe,GAAGA,CAAClB,IAAU,EAAEP,QAAgB,KAAK;EAC/D,IAAIR,gBAAgB,IAAIQ,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIK,yBAAyB,CAACE,IAAI,EAAEP,QAAQ,CAAC;EACtD,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACY,IAAI,EAAEP,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ declare class ReanimatedContainer extends Container {
|
|
|
6
6
|
private nativeId;
|
|
7
7
|
private mapperId;
|
|
8
8
|
constructor(Skia: Skia, nativeId: number);
|
|
9
|
+
unmount(): void;
|
|
9
10
|
redraw(): void;
|
|
10
11
|
}
|
|
11
12
|
export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | ReanimatedContainer;
|
|
@@ -36,9 +36,20 @@ class ReanimatedContainer extends Container {
|
|
|
36
36
|
this.nativeId = nativeId;
|
|
37
37
|
_defineProperty(this, "mapperId", null);
|
|
38
38
|
}
|
|
39
|
+
unmount() {
|
|
40
|
+
super.unmount();
|
|
41
|
+
if (this.mapperId !== null) {
|
|
42
|
+
// The mapper closure retains the recording and keeps updating the
|
|
43
|
+
// picture of an unmounted view — stop it or it leaks for the
|
|
44
|
+
// lifetime of the app.
|
|
45
|
+
Rea.stopMapper(this.mapperId);
|
|
46
|
+
this.mapperId = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
redraw() {
|
|
40
50
|
if (this.mapperId !== null) {
|
|
41
51
|
Rea.stopMapper(this.mapperId);
|
|
52
|
+
this.mapperId = null;
|
|
42
53
|
}
|
|
43
54
|
if (this.unmounted) {
|
|
44
55
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","dispose","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","
|
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","dispose","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","unmount","mapperId","stopMapper","redraw","unmounted","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\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 { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\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 rec.dispose();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recording and keeps updating the\n // picture of an unmounted view — stop it or it leaks for the\n // lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\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\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAE9D,OAAO,qBAAqB;AAC5B,OAAO,cAAc;;AAErB;AACA,MAAM;EAAEC;AAAY,CAAC,GAAGC,UAAU;AAElC,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;EACT,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGb,oBAAoB,CAACM,IAAI,EAAEE,SAAS,CAACM,SAAS,EAAEH,MAAM,CAAC;EACnEZ,MAAM,CAACc,GAAG,EAAEL,SAAS,CAACO,QAAQ,CAAC;EAC/B,MAAMC,OAAO,GAAGP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;EAC9CR,GAAG,CAACS,OAAO,CAAC,CAAC;EACb;EACA;EACAf,WAAW,CAACgB,cAAc,CAACZ,QAAQ,EAAE,SAAS,EAAES,OAAO,CAAC;AAC1D,CAAC;AAED,MAAMI,mBAAmB,SAASnB,SAAS,CAAC;EAG1CoB,WAAWA,CACTf,IAAU,EACFC,QAAgB,EACxB;IACA,KAAK,CAACD,IAAI,CAAC;IAAC,KAFJC,QAAgB,GAAhBA,QAA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C,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAM8B,eAAe,GAAGA,CAAChC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIX,gBAAgB,IAAIW,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIa,mBAAmB,CAACd,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACI,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,9 @@ import type { SkiaPictureViewHandle } from "../views/SkiaPictureView.web";
|
|
|
4
4
|
export type ISkiaViewApiWeb = ISkiaViewApi & {
|
|
5
5
|
views: Record<string, SkiaPictureViewHandle>;
|
|
6
6
|
deferedPictures: Record<string, SkPicture>;
|
|
7
|
+
unregisteredViews: Set<string>;
|
|
7
8
|
registerView(nativeId: string, view: SkiaPictureViewHandle): void;
|
|
9
|
+
unregisterView(nativeId: string): void;
|
|
8
10
|
};
|
|
9
11
|
declare const _default: {};
|
|
10
12
|
export default _default;
|
|
@@ -3,23 +3,37 @@
|
|
|
3
3
|
global.SkiaViewApi = {
|
|
4
4
|
views: {},
|
|
5
5
|
deferedPictures: {},
|
|
6
|
+
unregisteredViews: new Set(),
|
|
6
7
|
deferedOnSize: {},
|
|
7
8
|
web: true,
|
|
8
9
|
registerView(nativeId, view) {
|
|
10
|
+
this.unregisteredViews.delete(nativeId);
|
|
9
11
|
// Maybe a picture for this view was already set
|
|
10
12
|
if (this.deferedPictures[nativeId]) {
|
|
11
13
|
view.setPicture(this.deferedPictures[nativeId]);
|
|
14
|
+
delete this.deferedPictures[nativeId];
|
|
12
15
|
}
|
|
13
16
|
this.views[nativeId] = view;
|
|
14
17
|
},
|
|
18
|
+
unregisterView(nativeId) {
|
|
19
|
+
// Views must be removed on unmount: the handle's closures capture the
|
|
20
|
+
// canvas element, so a stale entry retains the whole detached DOM tree.
|
|
21
|
+
this.unregisteredViews.add(nativeId);
|
|
22
|
+
delete this.views[nativeId];
|
|
23
|
+
delete this.deferedPictures[nativeId];
|
|
24
|
+
},
|
|
15
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
26
|
setJsiProperty(nativeId, name, value) {
|
|
17
27
|
if (name === "picture") {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
const id = `${nativeId}`;
|
|
29
|
+
if (this.views[id]) {
|
|
30
|
+
this.views[id].setPicture(value);
|
|
31
|
+
} else if (!this.unregisteredViews.has(id)) {
|
|
32
|
+
this.deferedPictures[id] = value;
|
|
22
33
|
}
|
|
34
|
+
// Otherwise the view has unmounted (e.g. a trailing animation frame):
|
|
35
|
+
// drop the picture instead of deferring it for an id that will never
|
|
36
|
+
// register again, which would retain it forever.
|
|
23
37
|
}
|
|
24
38
|
},
|
|
25
39
|
size(nativeId) {
|
|
@@ -33,14 +47,25 @@ global.SkiaViewApi = {
|
|
|
33
47
|
}
|
|
34
48
|
},
|
|
35
49
|
requestRedraw(nativeId) {
|
|
36
|
-
|
|
50
|
+
var _this$views;
|
|
51
|
+
// The view may already have unmounted (e.g. a trailing animation frame).
|
|
52
|
+
(_this$views = this.views[`${nativeId}`]) === null || _this$views === void 0 || _this$views.redraw();
|
|
37
53
|
},
|
|
38
54
|
makeImageSnapshot(nativeId, rect) {
|
|
39
|
-
|
|
55
|
+
const view = this.views[`${nativeId}`];
|
|
56
|
+
if (!view) {
|
|
57
|
+
throw new Error(`Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`);
|
|
58
|
+
}
|
|
59
|
+
return view.makeImageSnapshot(rect);
|
|
40
60
|
},
|
|
41
61
|
makeImageSnapshotAsync(nativeId, rect) {
|
|
42
62
|
return new Promise((resolve, reject) => {
|
|
43
|
-
const
|
|
63
|
+
const view = this.views[`${nativeId}`];
|
|
64
|
+
if (!view) {
|
|
65
|
+
reject(new Error(`Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const result = view.makeImageSnapshot(rect);
|
|
44
69
|
if (result) {
|
|
45
70
|
resolve(result);
|
|
46
71
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","deferedOnSize","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result"
|
|
1
|
+
{"version":3,"names":["global","SkiaViewApi","views","deferedPictures","unregisteredViews","Set","deferedOnSize","web","registerView","nativeId","view","delete","setPicture","unregisterView","add","setJsiProperty","name","value","id","has","size","getSize","width","height","requestRedraw","_this$views","redraw","makeImageSnapshot","rect","Error","makeImageSnapshotAsync","Promise","resolve","reject","result"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureViewHandle } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n unregisteredViews: Set<string>;\n registerView(nativeId: string, view: SkiaPictureViewHandle): void;\n unregisterView(nativeId: string): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n unregisteredViews: new Set<string>(),\n deferedOnSize: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureViewHandle) {\n this.unregisteredViews.delete(nativeId);\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n delete this.deferedPictures[nativeId];\n }\n this.views[nativeId] = view;\n },\n unregisterView(nativeId: string) {\n // Views must be removed on unmount: the handle's closures capture the\n // canvas element, so a stale entry retains the whole detached DOM tree.\n this.unregisteredViews.add(nativeId);\n delete this.views[nativeId];\n delete this.deferedPictures[nativeId];\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n const id = `${nativeId}`;\n if (this.views[id]) {\n this.views[id].setPicture(value);\n } else if (!this.unregisteredViews.has(id)) {\n this.deferedPictures[id] = value;\n }\n // Otherwise the view has unmounted (e.g. a trailing animation frame):\n // drop the picture instead of deferring it for an id that will never\n // register again, which would retain it forever.\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n // The view may already have unmounted (e.g. a trailing animation frame).\n this.views[`${nativeId}`]?.redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n const view = this.views[`${nativeId}`];\n if (!view) {\n throw new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n );\n }\n return view.makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const view = this.views[`${nativeId}`];\n if (!view) {\n reject(\n new Error(\n `Cannot make image snapshot: view with nativeID ${nativeId} is not registered (it may have unmounted)`\n )\n );\n return;\n }\n const result = view.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\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":"AAAA;;AAaAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,iBAAiB,EAAE,IAAIC,GAAG,CAAS,CAAC;EACpCC,aAAa,EAAE,CAAC,CAAC;EACjBC,GAAG,EAAE,IA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"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import { codegenNativeComponent, type ViewProps } from \"react-native\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n colorSpace?: string;\n androidWarmup?: boolean;\n pointerEvents?: WithDefault<\n \"auto\" | \"none\" | \"box-none\" | \"box-only\",\n \"auto\"\n >;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAwB,cAAc;;AAGrE;AACA;;
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import { codegenNativeComponent, type ViewProps } from \"react-native\";\nimport type { WithDefault } from \"react-native/Libraries/Types/CodegenTypes\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore - pointerEvents needs to be redeclared for codegen to generate native bindings\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n colorSpace?: string;\n highBitDepth?: boolean;\n androidWarmup?: boolean;\n pointerEvents?: WithDefault<\n \"auto\" | \"none\" | \"box-none\" | \"box-only\",\n \"auto\"\n >;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAwB,cAAc;;AAGrE;AACA;;AAaA;AACA,eAAeA,sBAAsB,CAAc,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -79,6 +79,7 @@ export class SkiaPictureView extends React.Component {
|
|
|
79
79
|
mode,
|
|
80
80
|
debug = false,
|
|
81
81
|
opaque = false,
|
|
82
|
+
highBitDepth = false,
|
|
82
83
|
androidWarmup = false,
|
|
83
84
|
...viewProps
|
|
84
85
|
} = this.props;
|
|
@@ -87,6 +88,7 @@ export class SkiaPictureView extends React.Component {
|
|
|
87
88
|
nativeID: `${this._nativeId}`,
|
|
88
89
|
debug: debug,
|
|
89
90
|
opaque: opaque,
|
|
91
|
+
highBitDepth: highBitDepth,
|
|
90
92
|
androidWarmup: androidWarmup
|
|
91
93
|
}, viewProps));
|
|
92
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SkiaPictureViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","onSize","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","debug","opaque","androidWarmup","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n androidWarmup?: boolean;\n}\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture, onSize } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture, onSize } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const {\n mode,\n debug = false,\n opaque = false,\n androidWarmup = false,\n ...viewProps\n } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n opaque={opaque}\n androidWarmup={androidWarmup}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,qBAAqB,GAAGH,8BAA8B;AAO5D,OAAO,MAAMI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AAC;IACtC;EACF;EAEQL,IAAIA,CAAA,EAAG;IACb,IAAI,CAACO,MAAM,CAAC,CAAC;IACb,IAAI,IAAI,CAACf,KAAK,CAACgB,IAAI,KAAK,YAAY,EAAE;MACpC,IAAI,CAACH,SAAS,GAAGI,qBAAqB,CAAC,IAAI,CAACT,IAAI,CAACU,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D;EACF;;EAEA;AACF;AACA;AACA;AACA;EACSC,iBAAiBA,CAACC,IAAa,EAAE;IACtCd,iBAAiB,CAAC,CAAC;IACnB,OAAOZ,WAAW,CAACyB,iBAAiB,CAAC,IAAI,CAACjB,SAAS,EAAEkB,IAAI,CAAC;EAC5D;;EAEA;AACF;AACA;EACSL,MAAMA,CAAA,EAAG;IACdT,iBAAiB,CAAC,CAAC;IACnBZ,WAAW,CAAC2B,aAAa,CAAC,IAAI,CAACnB,SAAS,CAAC;EAC3C;EAEAoB,MAAMA,CAAA,EAAG;IACP,MAAM;MACJN,IAAI;MACJO,KAAK,GAAG,KAAK;MACbC,MAAM,GAAG,KAAK;MACdC,aAAa,GAAG,KAAK;MACrB,GAAGC;IACL,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"names":["React","SkiaPictureViewNativeComponent","SkiaViewApi","SkiaViewNativeId","NativeSkiaPictureView","SkiaPictureView","Component","constructor","props","_defineProperty","_nativeId","current","picture","onSize","assertSkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","bind","makeImageSnapshot","rect","requestRedraw","render","debug","opaque","highBitDepth","androidWarmup","viewProps","createElement","_extends","collapsable","nativeID","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n androidWarmup?: boolean;\n}\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture, onSize } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture, onSize } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const {\n mode,\n debug = false,\n opaque = false,\n highBitDepth = false,\n androidWarmup = false,\n ...viewProps\n } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n opaque={opaque}\n highBitDepth={highBitDepth}\n androidWarmup={androidWarmup}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,qBAAqB,GAAGH,8BAA8B;AAO5D,OAAO,MAAMI,eAAe,SAASL,KAAK,CAACM,SAAS,CAAuB;EAGzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHK,CAAC;IAAAA,eAAA;IAInB,IAAI,CAACC,SAAS,GAAGP,gBAAgB,CAACQ,OAAO,EAAE;IAC3C,MAAM;MAAEC,OAAO;MAAEC;IAAO,CAAC,GAAGL,KAAK;IACjC,IAAII,OAAO,EAAE;MACXE,iBAAiB,CAAC,CAAC;MACnBZ,WAAW,CAACa,cAAc,CAAC,IAAI,CAACL,SAAS,EAAE,SAAS,EAAEE,OAAO,CAAC;IAChE;IACA,IAAIC,MAAM,EAAE;MACVC,iBAAiB,CAAC,CAAC;MACnBZ,WAAW,CAACa,cAAc,CAAC,IAAI,CAACL,SAAS,EAAE,QAAQ,EAAEG,MAAM,CAAC;IAC9D;IACA,IAAI,CAACG,IAAI,CAAC,CAAC;EACb;EAIA,IAAWC,QAAQA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,SAAS;EACvB;EAEAQ,kBAAkBA,CAACC,SAA+B,EAAE;IAClD,MAAM;MAAEP,OAAO;MAAEC;IAAO,CAAC,GAAG,IAAI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