@shopify/react-native-skia 0.1.160 → 0.1.163

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/android/CMakeLists.txt +9 -9
  2. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +2 -0
  3. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +2 -2
  4. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  5. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +5 -5
  6. package/cpp/api/JsiSkCanvas.h +8 -8
  7. package/cpp/api/JsiSkColor.h +1 -1
  8. package/cpp/api/JsiSkColorFilter.h +1 -1
  9. package/cpp/api/JsiSkColorFilterFactory.h +2 -2
  10. package/cpp/api/JsiSkContourMeasure.h +1 -1
  11. package/cpp/api/JsiSkContourMeasureIter.h +2 -2
  12. package/cpp/api/JsiSkData.h +2 -2
  13. package/cpp/api/JsiSkDataFactory.h +1 -1
  14. package/cpp/api/JsiSkFont.h +2 -2
  15. package/cpp/api/JsiSkImage.h +3 -3
  16. package/cpp/api/JsiSkImageFilter.h +1 -1
  17. package/cpp/api/JsiSkImageFilterFactory.h +1 -1
  18. package/cpp/api/JsiSkImageInfo.h +1 -1
  19. package/cpp/api/JsiSkMaskFilter.h +1 -1
  20. package/cpp/api/JsiSkMaskFilterFactory.h +1 -1
  21. package/cpp/api/JsiSkMatrix.h +1 -1
  22. package/cpp/api/JsiSkPaint.h +1 -1
  23. package/cpp/api/JsiSkPath.h +15 -15
  24. package/cpp/api/JsiSkPathEffect.h +1 -1
  25. package/cpp/api/JsiSkPathEffectFactory.h +4 -4
  26. package/cpp/api/JsiSkPathFactory.h +2 -2
  27. package/cpp/api/JsiSkPicture.h +1 -1
  28. package/cpp/api/JsiSkPictureFactory.h +2 -2
  29. package/cpp/api/JsiSkPictureRecorder.h +2 -2
  30. package/cpp/api/JsiSkPoint.h +1 -1
  31. package/cpp/api/JsiSkRRect.h +1 -1
  32. package/cpp/api/JsiSkRSXform.h +1 -1
  33. package/cpp/api/JsiSkRect.h +1 -1
  34. package/cpp/api/JsiSkRuntimeEffect.h +1 -1
  35. package/cpp/api/JsiSkRuntimeShaderBuilder.h +1 -1
  36. package/cpp/api/JsiSkSVGFactory.h +1 -1
  37. package/cpp/api/JsiSkShader.h +2 -2
  38. package/cpp/api/JsiSkShaderFactory.h +3 -3
  39. package/cpp/api/JsiSkSurface.h +1 -1
  40. package/cpp/api/JsiSkSurfaceFactory.h +2 -2
  41. package/cpp/api/JsiSkTextBlob.h +1 -1
  42. package/cpp/api/JsiSkTextBlobFactory.h +1 -1
  43. package/cpp/api/JsiSkTypeface.h +2 -2
  44. package/cpp/api/JsiSkVertices.h +1 -1
  45. package/cpp/rnskia/RNSkDomView.cpp +1 -2
  46. package/cpp/rnskia/RNSkJsView.h +3 -3
  47. package/cpp/rnskia/RNSkPictureView.h +3 -3
  48. package/cpp/rnskia/RNSkPlatformContext.h +5 -3
  49. package/cpp/rnskia/RNSkView.h +2 -2
  50. package/cpp/rnskia/dom/nodes/JsiBlendNode.h +6 -7
  51. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
  52. package/cpp/rnskia/dom/nodes/JsiPathNode.h +10 -8
  53. package/cpp/rnskia/dom/props/BlendModeProp.h +2 -2
  54. package/cpp/rnskia/dom/props/PaintProps.h +5 -1
  55. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +8 -7
  56. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -1
  57. package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +4 -4
  58. package/ios/RNSkia-iOS/SkiaManager.mm +5 -5
  59. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +3 -3
  60. package/ios/RNSkia-iOS/SkiaUIView.mm +10 -10
  61. package/lib/commonjs/renderer/Canvas.js +2 -11
  62. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  63. package/lib/commonjs/renderer/Container.js +2 -1
  64. package/lib/commonjs/renderer/Container.js.map +1 -1
  65. package/lib/commonjs/renderer/components/Mask.js +11 -25
  66. package/lib/commonjs/renderer/components/Mask.js.map +1 -1
  67. package/lib/commonjs/renderer/index.js +0 -13
  68. package/lib/commonjs/renderer/index.js.map +1 -1
  69. package/lib/module/renderer/Canvas.js +3 -10
  70. package/lib/module/renderer/Canvas.js.map +1 -1
  71. package/lib/module/renderer/Container.js +2 -1
  72. package/lib/module/renderer/Container.js.map +1 -1
  73. package/lib/module/renderer/components/Mask.js +9 -21
  74. package/lib/module/renderer/components/Mask.js.map +1 -1
  75. package/lib/module/renderer/index.js +0 -1
  76. package/lib/module/renderer/index.js.map +1 -1
  77. package/lib/typescript/src/renderer/Container.d.ts +1 -1
  78. package/lib/typescript/src/renderer/index.d.ts +0 -1
  79. package/libs/android/arm64-v8a/libskottie.a +0 -0
  80. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  81. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  82. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  83. package/libs/android/x86/libskottie.a +0 -0
  84. package/libs/android/x86/libskshaper.a +0 -0
  85. package/libs/android/x86_64/libskottie.a +0 -0
  86. package/libs/android/x86_64/libskshaper.a +0 -0
  87. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  88. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  89. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  90. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  91. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  92. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  93. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  94. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  95. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  96. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  97. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  98. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  99. package/package.json +9 -4
  100. package/react-native-skia.podspec +2 -2
  101. package/src/renderer/Canvas.tsx +2 -12
  102. package/src/renderer/Container.tsx +1 -1
  103. package/src/renderer/components/Mask.tsx +11 -20
  104. package/src/renderer/index.ts +0 -1
  105. package/lib/commonjs/renderer/useCanvas.js +0 -32
  106. package/lib/commonjs/renderer/useCanvas.js.map +0 -1
  107. package/lib/module/renderer/useCanvas.js +0 -15
  108. package/lib/module/renderer/useCanvas.js.map +0 -1
  109. package/lib/typescript/src/renderer/useCanvas.d.ts +0 -9
  110. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  111. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  112. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  113. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  114. package/libs/android/x86/libskparagraph.a +0 -0
  115. package/libs/android/x86/libskunicode.a +0 -0
  116. package/libs/android/x86_64/libskparagraph.a +0 -0
  117. package/libs/android/x86_64/libskunicode.a +0 -0
  118. package/libs/ios/libskparagraph.xcframework/Info.plist +0 -42
  119. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  120. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  121. package/libs/ios/libskunicode.xcframework/Info.plist +0 -42
  122. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  123. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  124. package/src/renderer/useCanvas.ts +0 -21
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","useState","ReactReconciler","Platform","SkiaDomView","Skia","debug","hostDebug","skHostConfig","Container","DependencyManager","CanvasProvider","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","update","useCanvasRef","createDependencyManager","registerValues","global","SkiaDomApi","Canvas","forwardedRef","children","style","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","setTick","redraw","OS","tick","current","values","Error","createContainer","console","error","remove","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n useState,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\nimport { Platform } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaValue } from \"../values\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./Container\";\nimport { DependencyManager } from \"./DependencyManager\";\nimport { CanvasProvider } from \"./useCanvas\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n container.depMgr.update();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nconst createDependencyManager = (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaDomView> {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [, setTick] = useState(0);\n const redraw = useCallback(() => {\n Platform.OS === \"web\"\n ? setTick((tick) => tick + 1)\n : innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n\n const container = useMemo(() => {\n return new Container(\n Skia,\n createDependencyManager(registerValues),\n redraw\n );\n }, [redraw, registerValues]);\n\n const root = useMemo(\n () =>\n skiaReconciler.createContainer(\n container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n ),\n [container]\n );\n\n // Render effect\n useEffect(() => {\n render(\n <CanvasProvider value={{ Skia }}>{children}</CanvasProvider>,\n root,\n container\n );\n }, [children, root, redraw, container]);\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.remove();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={container.root}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);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,CAACO,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
1
+ {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","ReactReconciler","SkiaDomView","Skia","debug","hostDebug","skHostConfig","Container","DependencyManager","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","update","useCanvasRef","createDependencyManager","registerValues","global","SkiaDomApi","Canvas","forwardedRef","children","style","mode","onTouch","onSize","props","innerRef","ref","useCombinedRefs","redraw","current","values","Error","createContainer","console","error","remove","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaDomView } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaValue } from \"../values\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./Container\";\nimport { DependencyManager } from \"./DependencyManager\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n container.depMgr.update();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nconst createDependencyManager = (\n registerValues: (values: Array<SkiaValue<unknown>>) => () => void\n) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaDomView> {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize, ...props },\n forwardedRef\n ) => {\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current === null) {\n throw new Error(\"Canvas ref is not set\");\n }\n return ref.current.registerValues(values);\n },\n [ref]\n );\n\n const container = useMemo(() => {\n return new Container(\n Skia,\n createDependencyManager(registerValues),\n redraw\n );\n }, [redraw, registerValues]);\n\n const root = useMemo(\n () =>\n skiaReconciler.createContainer(\n container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n ),\n [container]\n );\n\n // Render effect\n useEffect(() => {\n render(children, root, container);\n }, [children, root, redraw, container]);\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.remove();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={container.root}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,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AAV,CAAiByB,MAAjB;MACD,CAFD;IAGD,CAJD;EAKD,CANQ,EAMN,CAAC3B,SAAD,EAAYD,IAAZ,CANM,CAAT;EAQA,oBACE,oBAAC,WAAD;IACE,GAAG,EAAEmB,GADP;IAEE,KAAK,EAAEN,KAFT;IAGE,IAAI,EAAEZ,SAAS,CAACD,IAHlB;IAIE,OAAO,EAAEe,OAJX;IAKE,MAAM,EAAEC,MALV;IAME,IAAI,EAAEF,IANR;IAOE,KAAK,EAAE1B;EAPT,GAQM6B,KARN,EADF;AAYD,CArE6B,CAAzB;AAwEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAS,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAGnD,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpBiD,IAAI,CAACE,OAAL,CAAcZ,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACW,SAAS,CAACR,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcQ,SAAS,CAACR,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACO,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -2,7 +2,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
2
2
 
3
3
  import { JsiSkDOM } from "../dom/nodes";
4
4
  export class Container {
5
- constructor(Skia, depMgr, redraw) {
5
+ constructor(Skia, depMgr) {
6
+ let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
6
7
  this.depMgr = depMgr;
7
8
  this.redraw = redraw;
8
9
 
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAGFC,MAHE,EAIT;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
1
+ {"version":3,"names":["JsiSkDOM","Container","constructor","Skia","depMgr","redraw","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nimport type { DependencyManager } from \"./DependencyManager\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public depMgr: DependencyManager,\n public redraw: () => void = () => {}\n ) {\n this.Sk = new JsiSkDOM({ Skia, depMgr });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AAWA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAEFC,MAFE,EAIT;IAAA,IADOC,MACP,uEAD4B,MAAM,CAAE,CACpC;IAAA,KAFOD,MAEP,GAFOA,MAEP;IAAA,KADOC,MACP,GADOA,MACP;;IAAA;;IAAA;;IACA,KAAKC,EAAL,GAAU,IAAIN,QAAJ,CAAa;MAAEG,IAAF;MAAQC;IAAR,CAAb,CAAV;IACA,KAAKG,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAlBoB"}
@@ -1,7 +1,7 @@
1
- import React, { useMemo } from "react";
2
- import { BlendMode } from "../../skia/types";
3
- import { useSkiaPrivate } from "../useCanvas";
1
+ import React from "react";
4
2
  import { Group } from "./Group";
3
+ import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
4
+ import { Paint } from "./Paint";
5
5
  export const Mask = _ref => {
6
6
  let {
7
7
  children,
@@ -9,28 +9,16 @@ export const Mask = _ref => {
9
9
  mode,
10
10
  clip
11
11
  } = _ref;
12
- const Skia = useSkiaPrivate();
13
- const maskPaint = useMemo(() => {
14
- const paint = Skia.Paint();
15
- paint.setBlendMode(BlendMode.Src);
16
-
17
- if (mode === "luminance") {
18
- paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
19
- }
20
-
21
- return paint;
22
- }, [Skia, mode]);
23
- const clippingPaint = useMemo(() => {
24
- const paint = Skia.Paint();
25
- paint.setBlendMode(BlendMode.DstIn);
26
- return paint;
27
- }, [Skia]);
28
12
  return /*#__PURE__*/React.createElement(Group, {
29
13
  layer: true
30
14
  }, /*#__PURE__*/React.createElement(Group, {
31
- layer: maskPaint
15
+ layer: /*#__PURE__*/React.createElement(Paint, {
16
+ blendMode: "src"
17
+ }, mode === "luminance" && /*#__PURE__*/React.createElement(LumaColorFilter, null))
32
18
  }, mask, clip && /*#__PURE__*/React.createElement(Group, {
33
- layer: clippingPaint
19
+ layer: /*#__PURE__*/React.createElement(Paint, {
20
+ blendMode: "dstIn"
21
+ })
34
22
  }, children)), /*#__PURE__*/React.createElement(Group, {
35
23
  blendMode: "srcIn"
36
24
  }, children));
@@ -1 +1 @@
1
- {"version":3,"names":["React","useMemo","BlendMode","useSkiaPrivate","Group","Mask","children","mask","mode","clip","Skia","maskPaint","paint","Paint","setBlendMode","Src","setColorFilter","ColorFilter","MakeLumaColorFilter","clippingPaint","DstIn","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\n\nimport { BlendMode } from \"../../skia/types\";\nimport { useSkiaPrivate } from \"../useCanvas\";\n\nimport { Group } from \"./Group\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n const Skia = useSkiaPrivate();\n const maskPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.Src);\n if (mode === \"luminance\") {\n paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());\n }\n return paint;\n }, [Skia, mode]);\n const clippingPaint = useMemo(() => {\n const paint = Skia.Paint();\n paint.setBlendMode(BlendMode.DstIn);\n return paint;\n }, [Skia]);\n return (\n <Group layer>\n <Group layer={maskPaint}>\n {mask}\n {clip && <Group layer={clippingPaint}>{children}</Group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D,CAxBM;AA0BPD,IAAI,CAACgB,YAAL,GAAoB;EAClBb,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
1
+ {"version":3,"names":["React","Group","LumaColorFilter","Paint","Mask","children","mask","mode","clip","defaultProps"],"sources":["Mask.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport { Group } from \"./Group\";\nimport { LumaColorFilter } from \"./colorFilters/LumaColorFilter\";\nimport { Paint } from \"./Paint\";\n\ninterface MaskProps {\n mode: \"luminance\" | \"alpha\";\n clip: boolean;\n mask: ReactNode | ReactNode[];\n children: ReactNode | ReactNode[];\n}\n\nexport const Mask = ({ children, mask, mode, clip }: MaskProps) => {\n return (\n <Group layer>\n <Group\n layer={\n <Paint blendMode=\"src\">\n {mode === \"luminance\" && <LumaColorFilter />}\n </Paint>\n }\n >\n {mask}\n {clip && <Group layer={<Paint blendMode=\"dstIn\" />}>{children}</Group>}\n </Group>\n <Group blendMode=\"srcIn\">{children}</Group>\n </Group>\n );\n};\n\nMask.defaultProps = {\n mode: \"alpha\",\n clip: true,\n};\n"],"mappings":"AACA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,KAAT,QAAsB,SAAtB;AASA,OAAO,MAAMC,IAAI,GAAG,QAA+C;EAAA,IAA9C;IAAEC,QAAF;IAAYC,IAAZ;IAAkBC,IAAlB;IAAwBC;EAAxB,CAA8C;EACjE,oBACE,oBAAC,KAAD;IAAO,KAAK;EAAZ,gBACE,oBAAC,KAAD;IACE,KAAK,eACH,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB,GACGD,IAAI,KAAK,WAAT,iBAAwB,oBAAC,eAAD,OAD3B;EAFJ,GAOGD,IAPH,EAQGE,IAAI,iBAAI,oBAAC,KAAD;IAAO,KAAK,eAAE,oBAAC,KAAD;MAAO,SAAS,EAAC;IAAjB;EAAd,GAA4CH,QAA5C,CARX,CADF,eAWE,oBAAC,KAAD;IAAO,SAAS,EAAC;EAAjB,GAA0BA,QAA1B,CAXF,CADF;AAeD,CAhBM;AAkBPD,IAAI,CAACK,YAAL,GAAoB;EAClBF,IAAI,EAAE,OADY;EAElBC,IAAI,EAAE;AAFY,CAApB"}
@@ -1,5 +1,4 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
5
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\nexport * from \"./useCanvas\";\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,qBAAd;AACA,cAAc,aAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./useContextBridge\";\nexport * from \"./DependencyManager\";\n"],"mappings":"AAAA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,qBAAd"}
@@ -6,7 +6,7 @@ export declare class Container {
6
6
  redraw: () => void;
7
7
  private _root;
8
8
  Sk: SkDOM;
9
- constructor(Skia: Skia, depMgr: DependencyManager, redraw: () => void);
9
+ constructor(Skia: Skia, depMgr: DependencyManager, redraw?: () => void);
10
10
  draw(ctx: DrawingContext): void;
11
11
  get root(): RenderNode<GroupProps>;
12
12
  }
@@ -1,4 +1,3 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e</string>
9
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libskia.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
+ <string>x86_64</string>
16
17
  </array>
17
18
  <key>SupportedPlatform</key>
18
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
19
22
  </dict>
20
23
  <dict>
21
24
  <key>LibraryIdentifier</key>
22
- <string>ios-arm64_arm64e_x86_64-simulator</string>
25
+ <string>ios-arm64_arm64e</string>
23
26
  <key>LibraryPath</key>
24
27
  <string>libskia.a</string>
25
28
  <key>SupportedArchitectures</key>
26
29
  <array>
27
30
  <string>arm64</string>
28
31
  <string>arm64e</string>
29
- <string>x86_64</string>
30
32
  </array>
31
33
  <key>SupportedPlatform</key>
32
34
  <string>ios</string>
33
- <key>SupportedPlatformVariant</key>
34
- <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e</string>
9
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libskshaper.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
+ <string>x86_64</string>
16
17
  </array>
17
18
  <key>SupportedPlatform</key>
18
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
19
22
  </dict>
20
23
  <dict>
21
24
  <key>LibraryIdentifier</key>
22
- <string>ios-arm64_arm64e_x86_64-simulator</string>
25
+ <string>ios-arm64_arm64e</string>
23
26
  <key>LibraryPath</key>
24
27
  <string>libskshaper.a</string>
25
28
  <key>SupportedArchitectures</key>
26
29
  <array>
27
30
  <string>arm64</string>
28
31
  <string>arm64e</string>
29
- <string>x86_64</string>
30
32
  </array>
31
33
  <key>SupportedPlatform</key>
32
34
  <string>ios</string>
33
- <key>SupportedPlatformVariant</key>
34
- <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.160",
10
+ "version": "0.1.163",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -32,8 +32,6 @@
32
32
  "libs/ios/libsvg.xcframework",
33
33
  "libs/ios/libskottie.xcframework",
34
34
  "libs/ios/libsksg.xcframework",
35
- "libs/ios/libskparagraph.xcframework",
36
- "libs/ios/libskunicode.xcframework",
37
35
  "react-native-skia.podspec",
38
36
  "scripts/install-npm.js",
39
37
  "scripts/setup-canvaskit.js",
@@ -43,6 +41,7 @@
43
41
  "tsc": "tsc --noEmit",
44
42
  "lint": "eslint . --ext .ts,.tsx --max-warnings 0 --cache",
45
43
  "test": "jest",
44
+ "e2e": "E2E=true yarn test -i e2e",
46
45
  "postinstall": "node scripts/install-npm.js",
47
46
  "build": "bob build"
48
47
  },
@@ -94,8 +93,14 @@
94
93
  "typescript": "4.8.3"
95
94
  },
96
95
  "dependencies": {
96
+ "@types/pixelmatch": "^5.2.4",
97
+ "@types/pngjs": "^6.0.1",
98
+ "@types/ws": "^8.5.3",
97
99
  "canvaskit-wasm": "0.36.1",
98
- "react-reconciler": "^0.27.0"
100
+ "pixelmatch": "^5.3.0",
101
+ "pngjs": "^6.0.0",
102
+ "react-reconciler": "^0.27.0",
103
+ "ws": "^8.11.0"
99
104
  },
100
105
  "eslintIgnore": [
101
106
  "node_modules/",
@@ -33,8 +33,8 @@ Pod::Spec.new do |s|
33
33
  'libs/ios/libskia.xcframework',
34
34
  'libs/ios/libsvg.xcframework',
35
35
  'libs/ios/libskshaper.xcframework',
36
- 'libs/ios/libskparagraph.xcframework',
37
- 'libs/ios/libskunicode.xcframework',
36
+ #'libs/ios/libskparagraph.xcframework',
37
+ #'libs/ios/libskunicode.xcframework',
38
38
  ]
39
39
 
40
40
  # All iOS cpp/h files
@@ -4,7 +4,6 @@ import React, {
4
4
  useMemo,
5
5
  forwardRef,
6
6
  useRef,
7
- useState,
8
7
  } from "react";
9
8
  import type {
10
9
  RefObject,
@@ -15,7 +14,6 @@ import type {
15
14
  } from "react";
16
15
  import type { OpaqueRoot } from "react-reconciler";
17
16
  import ReactReconciler from "react-reconciler";
18
- import { Platform } from "react-native";
19
17
 
20
18
  import { SkiaDomView } from "../views";
21
19
  import type { TouchHandler } from "../views";
@@ -26,7 +24,6 @@ import { debug as hostDebug, skHostConfig } from "./HostConfig";
26
24
  // import { debugTree } from "./nodes";
27
25
  import { Container } from "./Container";
28
26
  import { DependencyManager } from "./DependencyManager";
29
- import { CanvasProvider } from "./useCanvas";
30
27
 
31
28
  export const skiaReconciler = ReactReconciler(skHostConfig);
32
29
 
@@ -65,11 +62,8 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
65
62
  ) => {
66
63
  const innerRef = useCanvasRef();
67
64
  const ref = useCombinedRefs(forwardedRef, innerRef);
68
- const [, setTick] = useState(0);
69
65
  const redraw = useCallback(() => {
70
- Platform.OS === "web"
71
- ? setTick((tick) => tick + 1)
72
- : innerRef.current?.redraw();
66
+ innerRef.current?.redraw();
73
67
  }, [innerRef]);
74
68
 
75
69
  const registerValues = useCallback(
@@ -107,11 +101,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
107
101
 
108
102
  // Render effect
109
103
  useEffect(() => {
110
- render(
111
- <CanvasProvider value={{ Skia }}>{children}</CanvasProvider>,
112
- root,
113
- container
114
- );
104
+ render(children, root, container);
115
105
  }, [children, root, redraw, container]);
116
106
 
117
107
  useEffect(() => {
@@ -15,7 +15,7 @@ export class Container {
15
15
  constructor(
16
16
  Skia: Skia,
17
17
  public depMgr: DependencyManager,
18
- public redraw: () => void
18
+ public redraw: () => void = () => {}
19
19
  ) {
20
20
  this.Sk = new JsiSkDOM({ Skia, depMgr });
21
21
  this._root = this.Sk.Group();
@@ -1,10 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- import React, { useMemo } from "react";
3
-
4
- import { BlendMode } from "../../skia/types";
5
- import { useSkiaPrivate } from "../useCanvas";
2
+ import React from "react";
6
3
 
7
4
  import { Group } from "./Group";
5
+ import { LumaColorFilter } from "./colorFilters/LumaColorFilter";
6
+ import { Paint } from "./Paint";
8
7
 
9
8
  interface MaskProps {
10
9
  mode: "luminance" | "alpha";
@@ -14,25 +13,17 @@ interface MaskProps {
14
13
  }
15
14
 
16
15
  export const Mask = ({ children, mask, mode, clip }: MaskProps) => {
17
- const Skia = useSkiaPrivate();
18
- const maskPaint = useMemo(() => {
19
- const paint = Skia.Paint();
20
- paint.setBlendMode(BlendMode.Src);
21
- if (mode === "luminance") {
22
- paint.setColorFilter(Skia.ColorFilter.MakeLumaColorFilter());
23
- }
24
- return paint;
25
- }, [Skia, mode]);
26
- const clippingPaint = useMemo(() => {
27
- const paint = Skia.Paint();
28
- paint.setBlendMode(BlendMode.DstIn);
29
- return paint;
30
- }, [Skia]);
31
16
  return (
32
17
  <Group layer>
33
- <Group layer={maskPaint}>
18
+ <Group
19
+ layer={
20
+ <Paint blendMode="src">
21
+ {mode === "luminance" && <LumaColorFilter />}
22
+ </Paint>
23
+ }
24
+ >
34
25
  {mask}
35
- {clip && <Group layer={clippingPaint}>{children}</Group>}
26
+ {clip && <Group layer={<Paint blendMode="dstIn" />}>{children}</Group>}
36
27
  </Group>
37
28
  <Group blendMode="srcIn">{children}</Group>
38
29
  </Group>
@@ -1,4 +1,3 @@
1
1
  export * from "./components";
2
2
  export * from "./useContextBridge";
3
3
  export * from "./DependencyManager";
4
- export * from "./useCanvas";
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useSkiaPrivate = exports.CanvasProvider = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
- const CanvasContext = /*#__PURE__*/_react.default.createContext(null);
15
-
16
- const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
17
- // implement the Mask component as a node (will be faster too)
18
-
19
- exports.CanvasProvider = CanvasProvider;
20
-
21
- const useSkiaPrivate = () => {
22
- const ctx = (0, _react.useContext)(CanvasContext);
23
-
24
- if (!ctx) {
25
- throw new Error("Skia Canvas context is not available");
26
- }
27
-
28
- return ctx.Skia;
29
- };
30
-
31
- exports.useSkiaPrivate = useSkiaPrivate;
32
- //# sourceMappingURL=useCanvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CanvasContext","React","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","useContext","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":";;;;;;;AAAA;;;;;;AAQA,MAAMA,aAAa,gBAAGC,cAAA,CAAMC,aAAN,CAA0C,IAA1C,CAAtB;;AAEO,MAAMC,cAAc,GAAGH,aAAa,CAACI,QAArC,C,CAEP;AACA;;;;AACO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAG,IAAAC,iBAAA,EAAWP,aAAX,CAAZ;;EACA,IAAI,CAACM,GAAL,EAAU;IACR,MAAM,IAAIE,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOF,GAAG,CAACG,IAAX;AACD,CANM"}
@@ -1,15 +0,0 @@
1
- import React, { useContext } from "react";
2
- const CanvasContext = /*#__PURE__*/React.createContext(null);
3
- export const CanvasProvider = CanvasContext.Provider; // This private function will be removed once we remove the useCanvas hook and
4
- // implement the Mask component as a node (will be faster too)
5
-
6
- export const useSkiaPrivate = () => {
7
- const ctx = useContext(CanvasContext);
8
-
9
- if (!ctx) {
10
- throw new Error("Skia Canvas context is not available");
11
- }
12
-
13
- return ctx.Skia;
14
- };
15
- //# sourceMappingURL=useCanvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","useContext","CanvasContext","createContext","CanvasProvider","Provider","useSkiaPrivate","ctx","Error","Skia"],"sources":["useCanvas.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nimport type { Skia } from \"../skia/types\";\n\ninterface CanvasContext {\n Skia: Skia;\n}\n\nconst CanvasContext = React.createContext<CanvasContext | null>(null);\n\nexport const CanvasProvider = CanvasContext.Provider;\n\n// This private function will be removed once we remove the useCanvas hook and\n// implement the Mask component as a node (will be faster too)\nexport const useSkiaPrivate = () => {\n const ctx = useContext(CanvasContext);\n if (!ctx) {\n throw new Error(\"Skia Canvas context is not available\");\n }\n return ctx.Skia;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AAQA,MAAMC,aAAa,gBAAGF,KAAK,CAACG,aAAN,CAA0C,IAA1C,CAAtB;AAEA,OAAO,MAAMC,cAAc,GAAGF,aAAa,CAACG,QAArC,C,CAEP;AACA;;AACA,OAAO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAMC,GAAG,GAAGN,UAAU,CAACC,aAAD,CAAtB;;EACA,IAAI,CAACK,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;EACD;;EACD,OAAOD,GAAG,CAACE,IAAX;AACD,CANM"}
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import type { Skia } from "../skia/types";
3
- interface CanvasContext {
4
- Skia: Skia;
5
- }
6
- declare const CanvasContext: React.Context<CanvasContext | null>;
7
- export declare const CanvasProvider: React.Provider<CanvasContext | null>;
8
- export declare const useSkiaPrivate: () => Skia;
9
- export {};
Binary file
Binary file
Binary file
@@ -1,42 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>AvailableLibraries</key>
6
- <array>
7
- <dict>
8
- <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e_x86_64-simulator</string>
10
- <key>LibraryPath</key>
11
- <string>libskparagraph.a</string>
12
- <key>SupportedArchitectures</key>
13
- <array>
14
- <string>arm64</string>
15
- <string>arm64e</string>
16
- <string>x86_64</string>
17
- </array>
18
- <key>SupportedPlatform</key>
19
- <string>ios</string>
20
- <key>SupportedPlatformVariant</key>
21
- <string>simulator</string>
22
- </dict>
23
- <dict>
24
- <key>LibraryIdentifier</key>
25
- <string>ios-arm64_arm64e</string>
26
- <key>LibraryPath</key>
27
- <string>libskparagraph.a</string>
28
- <key>SupportedArchitectures</key>
29
- <array>
30
- <string>arm64</string>
31
- <string>arm64e</string>
32
- </array>
33
- <key>SupportedPlatform</key>
34
- <string>ios</string>
35
- </dict>
36
- </array>
37
- <key>CFBundlePackageType</key>
38
- <string>XFWK</string>
39
- <key>XCFrameworkFormatVersion</key>
40
- <string>1.0</string>
41
- </dict>
42
- </plist>