@shopify/react-native-skia 2.11.2 → 2.12.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.
Files changed (90) hide show
  1. package/Package.swift +117 -0
  2. package/android/CMakeLists.txt +1 -2
  3. package/cpp/api/JsiSkSVGFactory.h +4 -0
  4. package/cpp/jsi/JSICache.cpp +99 -0
  5. package/cpp/jsi/JSICache.h +90 -0
  6. package/cpp/jsi/NativeObject.h +30 -97
  7. package/cpp/jsi/ViewProperty.h +0 -24
  8. package/cpp/rnskia/RNDawnContext.h +2 -1
  9. package/cpp/rnskia/RNDawnWindowContext.h +22 -0
  10. package/cpp/rnskia/RNSkManager.cpp +0 -11
  11. package/cpp/skia/include/core/RasterContext.h +25 -0
  12. package/cpp/skia/include/core/SkCanvas.h +0 -1
  13. package/cpp/skia/include/core/SkContext.h +62 -0
  14. package/cpp/skia/include/core/SkContextOptions.h +15 -0
  15. package/cpp/skia/include/core/SkMilestone.h +1 -1
  16. package/cpp/skia/include/core/SkPicture.h +36 -18
  17. package/cpp/skia/include/core/SkRecorder.h +8 -0
  18. package/cpp/skia/include/core/SkSerialProcs.h +2 -6
  19. package/cpp/skia/include/effects/SkImageFilters.h +15 -2
  20. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +73 -47
  21. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +7 -4
  22. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +12 -0
  23. package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +11 -0
  24. package/cpp/skia/include/gpu/ganesh/mtl/GrMtlDirectContext.h +11 -0
  25. package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +13 -0
  26. package/cpp/skia/include/gpu/graphite/ContextOptions.h +6 -0
  27. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +5 -4
  28. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +9 -1
  29. package/cpp/skia/include/gpu/graphite/Recorder.h +0 -2
  30. package/cpp/skia/include/gpu/graphite/Recording.h +3 -0
  31. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +8 -0
  32. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +11 -0
  33. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +11 -0
  34. package/cpp/skia/include/private/SkLog.h +1 -19
  35. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +2 -1
  36. package/cpp/skia/include/utils/SkLogHandler.h +53 -0
  37. package/cpp/skia/include/utils/SkNWayCanvas.h +1 -0
  38. package/cpp/skia/modules/skcms/src/Transform_inl.h +9 -10
  39. package/cpp/skia/modules/skcms/src/skcms_internals.h +8 -3
  40. package/cpp/skia/modules/skottie/include/SkottieProperty.h +2 -0
  41. package/cpp/skia/modules/skottie/include/TextShaper.h +1 -0
  42. package/cpp/skia/modules/skshaper/include/SkShaper.h +23 -1
  43. package/include/ReactNativeSkia.h +6 -0
  44. package/lib/commonjs/skia/web/JsiSkCanvas.js +4 -4
  45. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkImage.js +6 -3
  47. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  49. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +2 -2
  50. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -1
  51. package/lib/commonjs/skia/web/JsiSkTextStyle.js +5 -5
  52. package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +8 -8
  54. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -1
  55. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +2 -1
  56. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  57. package/lib/commonjs/views/SkiaPictureView.web.js +228 -43
  58. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  59. package/lib/module/skia/web/JsiSkCanvas.js +4 -4
  60. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  61. package/lib/module/skia/web/JsiSkImage.js +6 -3
  62. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  63. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  64. package/lib/module/skia/web/JsiSkPathBuilder.js +2 -2
  65. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -1
  66. package/lib/module/skia/web/JsiSkTextStyle.js +5 -5
  67. package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -1
  68. package/lib/module/skia/web/JsiSkottieAnimation.js +8 -8
  69. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -1
  70. package/lib/module/sksg/Recorder/commands/Drawing.js +2 -1
  71. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  72. package/lib/module/views/SkiaPictureView.web.js +228 -43
  73. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  74. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +1 -1
  75. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +1 -1
  76. package/lib/typescript/react-native.config.d.ts +3 -0
  77. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +1 -1
  78. package/package.json +12 -9
  79. package/react-native.config.js +5 -0
  80. package/src/skia/web/JsiSkCanvas.ts +11 -6
  81. package/src/skia/web/JsiSkImage.ts +6 -3
  82. package/src/skia/web/JsiSkPathBuilder.ts +2 -2
  83. package/src/skia/web/JsiSkTextStyle.ts +20 -15
  84. package/src/skia/web/JsiSkottieAnimation.ts +8 -8
  85. package/src/sksg/Recorder/commands/Drawing.ts +2 -1
  86. package/src/views/SkiaPictureView.web.tsx +228 -43
  87. package/cpp/jsi/RuntimeAwareCache.cpp +0 -8
  88. package/cpp/jsi/RuntimeAwareCache.h +0 -146
  89. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +0 -72
  90. package/cpp/jsi/RuntimeLifecycleMonitor.h +0 -32
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","useEffect","useCallback","useImperativeHandle","useLayoutEffect","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","WebGLRenderer","constructor","canvas","_defineProperty","contextHandle","CanvasKit","GetWebGLContext","Error","grContext","MakeWebGLContext","deleteContext","ctx","getContext","drawingBufferColorSpace","onResize","makeImageSnapshot","picture","surface","getCanvas","clear","TRANSPARENT","draw","ref","flush","_this$surface","window","devicePixelRatio","clientWidth","clientHeight","delete","MakeOnScreenGLSurface","ColorSpace","SRGB","Float32Array","of","save","scale","drawPicture","restore","dispose","_this$surface2","_this$canvas","releaseResourcesAndAbandonContext","getExtension","loseContext","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","preventDefault","stopPropagation","isTrusted","type","SkiaPictureView","props","onLayout","canvasRef","rendererRef","pictureRef","redrawPendingRef","flushScheduledRef","onLayoutRef","current","flushRedraw","redraw","queueMicrotask","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","scrollX","pageY","scrollY","measureInWindow","isStatic","__destroyWebGLContextAfterRender","renderer","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","contentRect","setTimeout","observe","media","onPixelDensityChange","watchPixelDensity","_media","removeEventListener","matchMedia","query","addEventListener","_media2","disconnect","_props$nativeID","nativeID","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","View","style","display"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {\n this.contextHandle = CanvasKit.GetWebGLContext(canvas);\n if (!this.contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n this.grContext = CanvasKit.MakeWebGLContext(this.contextHandle);\n if (!this.grContext) {\n CanvasKit.deleteContext(this.contextHandle);\n this.contextHandle = 0;\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = canvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext) {\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(picture: SkPicture) {\n if (this.surface) {\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n }\n\n dispose(): void {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n this.canvas\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (this.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the canvas element (and its detached DOM tree) forever.\n CanvasKit.deleteContext(this.contextHandle);\n // Making the now-deleted handle current clears CanvasKit's\n // current-context globals (GLctx/Module.ctx), which would otherwise\n // keep referencing the context (and the canvas) until another surface\n // becomes current. With a deleted handle this is a no-op that returns\n // null without creating anything.\n CanvasKit.MakeWebGLContext(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nclass StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderPictureToSurface(picture: SkPicture): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n skiaCanvas.drawPicture(picture);\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupRenderResult(renderResult);\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nconst makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref, picture, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const rendererRef = useRef<Renderer | null>(null);\n const pictureRef = useRef<SkPicture | null>(null);\n // The rendering lifecycle deliberately does not depend on layout events:\n // - The renderer is created synchronously on mount (the canvas element is\n // guaranteed to exist in useLayoutEffect; a zero size at that point is\n // fine, the surface is created once the canvas is measurable).\n // - Redraw requests coalesce into a single microtask. A microtask (not an\n // animation frame) so that a picture produced inside a rAF callback (the\n // Reanimated mapper) is drawn before the current frame paints: deferring\n // to the next rAF alternates between \"flush pending in this frame\" and\n // \"flush scheduled for the next frame\", drawing on every other frame\n // only and halving the effective frame rate. A picture dispatched before\n // the canvas has a size stays in pictureRef (drawing while unmeasured is\n // a no-op) and is painted by the resize path below once the canvas\n // becomes measurable, so it is never lost.\n // - A ResizeObserver on the canvas itself recreates the surface and repaints\n // synchronously (its callbacks run after layout, before paint), and is\n // also the source of the user-facing onLayout event.\n const redrawPendingRef = useRef(false);\n const flushScheduledRef = useRef(false);\n const onLayoutRef = useRef(onLayout);\n useLayoutEffect(() => {\n onLayoutRef.current = onLayout;\n }, [onLayout]);\n\n const flushRedraw = useCallback(() => {\n flushScheduledRef.current = false;\n if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {\n redrawPendingRef.current = false;\n rendererRef.current.draw(pictureRef.current);\n }\n // If the renderer or picture isn't available yet, the request stays\n // pending and is flushed by whichever arrives last.\n }, []);\n\n const redraw = useCallback(() => {\n redrawPendingRef.current = true;\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flushRedraw);\n }\n }, [flushRedraw]);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (rendererRef.current && pictureRef.current) {\n return rendererRef.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas);\n rendererRef.current = renderer;\n\n const drawPicture = () => {\n if (pictureRef.current) {\n redrawPendingRef.current = false;\n renderer.draw(pictureRef.current);\n }\n };\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n drawPicture();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = onLayoutRef.current;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any picture that was dispatched before the renderer existed.\n drawPicture();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [isStatic]);\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flushRedraw no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n return () => {\n api.unregisterView(nativeID);\n };\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (picture) {\n setPicture(picture);\n }\n }, [setPicture, picture]);\n\n const {\n debug: _debug,\n ref: _ref,\n onLayout: _onLayout,\n picture: _picture,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View {...viewProps}>\n <canvas\n ref={canvasRef}\n style={{ display: \"block\", width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","useEffect","useCallback","useImperativeHandle","useLayoutEffect","JsiSkSurface","Platform","SkiaViewNativeId","dp2Pixel","pd","rect","undefined","x","y","width","height","canvasWebGL","WeakMap","deleteContextHandle","handle","CanvasKit","deleteContext","MakeWebGLContext","WebGLRenderer","constructor","canvas","requestRedraw","_defineProperty","release","restoreWanted","restoreRequest","setTimeout","_canvasWebGL$get","get","loseContext","restoreContext","acquire","entry","owner","addEventListener","onContextLost","onContextRestored","known","gl","isContextLost","lossAnnounced","_known$loseContext","GetWebGLContext","Error","trackContext","grContext","contextHandle","drawingBufferColorSpace","onResize","_canvas$getContext","getContext","getExtension","set","event","preventDefault","_this$surface","surface","ref","delete","releaseResourcesAndAbandonContext","_canvasWebGL$get$gl$i","_canvasWebGL$get2","makeImageSnapshot","picture","getCanvas","clear","TRANSPARENT","draw","flush","_this$surface2","window","devicePixelRatio","clientWidth","clientHeight","MakeOnScreenGLSurface","ColorSpace","SRGB","Float32Array","of","save","scale","drawPicture","restore","dispose","removeEventListener","clearTimeout","queueMicrotask","isConnected","_entry$loseContext","StaticWebGLRenderer","cachedImage","renderPictureToSurface","tempCanvas","OffscreenCanvas","ctx","webglSurface","skiaCanvas","error","cleanupRenderResult","result","_result$surface","_result$tempCanvas$ge","renderResult","ctx2d","drawImage","console","_this$cachedImage","makeLayoutEvent","timeStamp","Date","now","nativeEvent","layout","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","isPropagationStopped","persist","stopPropagation","isTrusted","type","SkiaPictureView","props","onLayout","canvasRef","rendererRef","pictureRef","redrawPendingRef","flushScheduledRef","onLayoutRef","current","flushRedraw","redraw","getSize","_canvasRef$current","_canvasRef$current2","setPicture","newPicture","measure","callback","getBoundingClientRect","parentElement","offsetParent","parentRect","left","top","pageX","scrollX","pageY","scrollY","measureInWindow","isStatic","__destroyWebGLContextAfterRender","renderer","lastWidth","lastHeight","lastPixelDensity","resizeIfNeeded","pixelDensity","observer","ResizeObserver","entries","layoutHandler","contentRect","observe","media","onPixelDensityChange","watchPixelDensity","_media","matchMedia","query","_media2","disconnect","_props$nativeID","nativeID","api","global","SkiaViewApi","registerView","unregisterView","debug","_debug","_ref","_onLayout","_picture","_isStatic","viewProps","createElement","View","key","style","display"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["/* global HTMLCanvasElement, ResizeObserver, MediaQueryList */\nimport React, {\n useRef,\n useEffect,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport type { GrDirectContext, WebGLContextHandle } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkPicture, SkImage } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\nimport type { ISkiaViewApiWeb } from \"../specs/NativeSkiaModule.web\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst dp2Pixel = (pd: number, rect?: SkRect) => {\n if (!rect) {\n return undefined;\n }\n return {\n x: rect.x * pd,\n y: rect.y * pd,\n width: rect.width * pd,\n height: rect.height * pd,\n };\n};\n\ninterface Renderer {\n onResize(): void;\n draw(picture: SkPicture): void;\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null;\n dispose(): void;\n}\n\n// A <canvas> element owns at most one WebGL context for its whole lifetime.\n// A renderer, on the other hand, lives as long as the layout effect that\n// creates it, which is shorter: React re-runs layout effects on a *preserved*\n// host node under StrictMode's DEV double-invoke and when an Activity/offscreen\n// subtree is hidden and revealed (#3976). What belongs to the element rather\n// than to a renderer is tracked here, per element:\n// - the context, so that a new renderer can tell whether the element already\n// has one (and whether it is lost) without calling getContext() itself,\n// which on a fresh element would create a context with the wrong attributes\n// (CanvasKit.GetWebGLContext requests its own);\n// - the WEBGL_lose_context extension, captured while the context is healthy:\n// getExtension() returns null on a lost context, and this object is the only\n// way to lose a context on purpose or to ask the browser to restore one;\n// - whether the browser has announced the loss of the context yet: a lost\n// context can only be restored once its webglcontextlost event has been\n// dispatched, and that event is asynchronous;\n// - the renderer currently attached to the element, if any.\ninterface CanvasWebGL {\n gl: WebGLRenderingContext | WebGL2RenderingContext;\n // The WEBGL_lose_context extension.\n loseContext: { loseContext(): void; restoreContext(): void } | null;\n lossAnnounced: boolean;\n owner: WebGLRenderer | null;\n}\nconst canvasWebGL = new WeakMap<HTMLCanvasElement, CanvasWebGL>();\n\n// Unregisters a context from CanvasKit's registry, which otherwise retains the\n// canvas element (and its detached DOM tree) forever (#3924).\nconst deleteContextHandle = (handle: WebGLContextHandle) => {\n CanvasKit.deleteContext(handle);\n // Making the now-deleted handle current clears CanvasKit's current-context\n // globals (GLctx/Module.ctx), which would otherwise keep referencing the\n // context (and the canvas) until another surface becomes current. With a\n // deleted handle this is a no-op that returns null without creating\n // anything.\n CanvasKit.MakeWebGLContext(handle);\n};\n\nclass WebGLRenderer implements Renderer {\n private surface: JsiSkSurface | null = null;\n private grContext: GrDirectContext | null = null;\n private contextHandle: WebGLContextHandle = 0;\n private pd = 1;\n // Set while the renderer is waiting for a lost context to be restored.\n private restoreWanted = false;\n private restoreRequest: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n private canvas: HTMLCanvasElement,\n // Called when the renderer becomes able to paint again and the current\n // picture should be drawn.\n private requestRedraw: () => void\n ) {\n const entry = canvasWebGL.get(canvas);\n if (entry) {\n entry.owner = this;\n }\n canvas.addEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.addEventListener(\"webglcontextrestored\", this.onContextRestored);\n this.acquire();\n }\n\n // Builds the GrDirectContext and the surface on the element's WebGL\n // context, creating the context first if the element has none.\n private acquire() {\n const { canvas } = this;\n const known = canvasWebGL.get(canvas);\n if (known?.gl.isContextLost()) {\n // Nothing can be built on a lost context: CanvasKit.GetWebGLContext\n // happily registers it, and MakeWebGLContext then faults inside wasm\n // (#3976). Ask the browser for it back and finish in onContextRestored;\n // if the loss hasn't been announced yet, onContextLost asks.\n this.restoreWanted = true;\n if (known.lossAnnounced) {\n known.loseContext?.restoreContext();\n }\n return;\n }\n const handle = CanvasKit.GetWebGLContext(canvas);\n if (!handle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n const entry = known ?? this.trackContext();\n let grContext: GrDirectContext | null = null;\n try {\n grContext = CanvasKit.MakeWebGLContext(handle);\n } finally {\n if (!grContext) {\n // Whether it returned null or threw, don't leave the registry\n // holding on to the canvas.\n deleteContextHandle(handle);\n }\n }\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n this.restoreWanted = false;\n this.contextHandle = handle;\n this.grContext = grContext;\n if (entry) {\n entry.gl.drawingBufferColorSpace = \"display-p3\";\n }\n this.onResize();\n }\n\n // CanvasKit just created the element's context; asking for it again hands\n // back the same object (the attributes are only honored the first time).\n private trackContext(): CanvasWebGL | null {\n const { canvas } = this;\n const gl = canvas.getContext(\"webgl2\") ?? canvas.getContext(\"webgl\");\n if (!gl) {\n return null;\n }\n const entry: CanvasWebGL = {\n gl,\n loseContext: gl.getExtension(\"WEBGL_lose_context\"),\n lossAnnounced: false,\n owner: this,\n };\n canvasWebGL.set(canvas, entry);\n // Browsers restore a lost context (evicted as the oldest one when the\n // page exceeds the active-context limit, or lost to a GPU reset) only if\n // the page called preventDefault() on the webglcontextlost event. A\n // renderer isn't necessarily attached when that happens (the canvas may\n // be in a hidden Activity), so these listeners live as long as the\n // element does. They are registered ahead of any renderer's, and the\n // loss can't be announced before they exist since the event is\n // asynchronous.\n canvas.addEventListener(\"webglcontextlost\", (event) => {\n event.preventDefault();\n entry.lossAnnounced = true;\n });\n canvas.addEventListener(\"webglcontextrestored\", () => {\n entry.lossAnnounced = false;\n });\n return entry;\n }\n\n // Frees everything built on the context. The context itself belongs to the\n // element, see dispose().\n private release() {\n this.surface?.ref.delete();\n this.surface = null;\n if (this.grContext) {\n this.grContext.releaseResourcesAndAbandonContext();\n this.grContext.delete();\n this.grContext = null;\n }\n if (this.contextHandle) {\n deleteContextHandle(this.contextHandle);\n this.contextHandle = 0;\n }\n }\n\n private isContextLost() {\n return canvasWebGL.get(this.canvas)?.gl.isContextLost() ?? false;\n }\n\n private onContextLost = () => {\n // The browser already dropped every GL object; drop our references to\n // them. Restoration is left to the browser (it restores an evicted\n // context as soon as a slot frees up), except when this renderer was\n // built on an already-lost context and is waiting to paint for the first\n // time: chasing an eviction from here would evict the next-oldest context\n // in turn, and with more live canvases than the browser allows the\n // canvases would endlessly evict each other.\n this.release();\n if (this.restoreWanted) {\n // The permission granted by preventDefault() is only recorded by the\n // browser once the event dispatch is over: a restoreContext() call\n // from inside the handler is refused, so ask from a later task.\n this.restoreRequest = setTimeout(() => {\n this.restoreRequest = null;\n canvasWebGL.get(this.canvas)?.loseContext?.restoreContext();\n }, 0);\n }\n };\n\n private onContextRestored = () => {\n this.acquire();\n this.requestRedraw();\n };\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.surface || this.isContextLost()) {\n return null;\n }\n const canvas = this.surface.getCanvas();\n canvas!.clear(CanvasKit.TRANSPARENT);\n this.draw(picture);\n this.surface.ref.flush();\n return this.surface.makeImageSnapshot(dp2Pixel(this.pd, rect));\n }\n\n onResize() {\n const { canvas } = this;\n if (!this.grContext || this.isContextLost()) {\n // Waiting for the context to be restored (the restore path resizes),\n // or the loss hasn't been announced yet and onContextLost is about to\n // release everything: either way there is nothing to build on.\n return;\n }\n this.pd = window.devicePixelRatio;\n canvas.width = canvas.clientWidth * this.pd;\n canvas.height = canvas.clientHeight * this.pd;\n this.surface?.ref.delete();\n this.surface = null;\n if (canvas.width === 0 || canvas.height === 0) {\n // The canvas hasn't been laid out yet (or is hidden). The view's\n // ResizeObserver calls us again as soon as it has a size.\n return;\n }\n // Reuse the existing WebGL context and GrDirectContext: only the surface\n // needs to be recreated when the canvas is resized.\n const surface = CanvasKit.MakeOnScreenGLSurface(\n this.grContext,\n canvas.width,\n canvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this.surface = new JsiSkSurface(CanvasKit, surface);\n }\n\n draw(picture: SkPicture) {\n if (!this.surface || this.isContextLost()) {\n return;\n }\n const canvas = this.surface.getCanvas();\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(this.pd, this.pd);\n canvas.drawPicture(picture);\n canvas.restore();\n this.surface.ref.flush();\n }\n\n dispose(): void {\n const { canvas } = this;\n canvas.removeEventListener(\"webglcontextlost\", this.onContextLost);\n canvas.removeEventListener(\"webglcontextrestored\", this.onContextRestored);\n if (this.restoreRequest !== null) {\n clearTimeout(this.restoreRequest);\n this.restoreRequest = null;\n }\n this.restoreWanted = false;\n this.release();\n // Free the drawing buffer, which CanvasKit requests with depth and stencil\n // attachments (about 8 bytes per pixel): a canvas that stays in the\n // document without a renderer, hidden in an Activity say, would otherwise\n // keep a full-size buffer around. The next renderer's onResize() sizes it\n // again.\n canvas.width = 0;\n canvas.height = 0;\n const entry = canvasWebGL.get(canvas);\n if (!entry) {\n return;\n }\n entry.owner = null;\n // Whether the element is going away is only known once the commit is\n // over: on a real unmount React runs this cleanup *before* removing the\n // node from the document, while StrictMode's double-invoke and an\n // Activity hide keep the node in place (and the former builds the next\n // renderer on it right away). Losing the context of a detached element\n // matters: it would otherwise stay alive until the element is garbage\n // collected, and browsers cap the number of live contexts per page\n // (16 in Chrome, which then evicts the oldest one, visible or not).\n queueMicrotask(() => {\n if (\n entry.owner === null &&\n !canvas.isConnected &&\n !entry.gl.isContextLost()\n ) {\n entry.loseContext?.loseContext();\n }\n });\n }\n}\n\ninterface TempRenderResult {\n surface: JsiSkSurface;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext;\n contextHandle: WebGLContextHandle;\n}\n\nclass StaticWebGLRenderer implements Renderer {\n private cachedImage: SkImage | null = null;\n private pd = 1;\n\n constructor(private canvas: HTMLCanvasElement) {}\n\n onResize(): void {\n this.cachedImage = null;\n }\n\n private renderPictureToSurface(picture: SkPicture): TempRenderResult | null {\n this.pd = window.devicePixelRatio;\n if (this.canvas.clientWidth === 0 || this.canvas.clientHeight === 0) {\n return null;\n }\n const tempCanvas = new OffscreenCanvas(\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n let surface: JsiSkSurface | null = null;\n let grContext: GrDirectContext | null = null;\n let contextHandle: WebGLContextHandle = 0;\n\n try {\n contextHandle = CanvasKit.GetWebGLContext(tempCanvas);\n if (!contextHandle) {\n throw new Error(\"Could not create a WebGL context\");\n }\n grContext = CanvasKit.MakeWebGLContext(contextHandle);\n if (!grContext) {\n throw new Error(\"Could not create a graphics context\");\n }\n const ctx = tempCanvas.getContext(\"webgl2\");\n if (ctx) {\n ctx.drawingBufferColorSpace = \"display-p3\";\n }\n const webglSurface = CanvasKit.MakeOnScreenGLSurface(\n grContext,\n tempCanvas.width,\n tempCanvas.height,\n CanvasKit.ColorSpace.SRGB\n );\n\n if (!webglSurface) {\n throw new Error(\"Could not create WebGL surface\");\n }\n\n surface = new JsiSkSurface(CanvasKit, webglSurface);\n\n const skiaCanvas = surface.getCanvas();\n skiaCanvas.clear(Float32Array.of(0, 0, 0, 0));\n skiaCanvas.save();\n skiaCanvas.scale(this.pd, this.pd);\n skiaCanvas.drawPicture(picture);\n skiaCanvas.restore();\n surface.ref.flush();\n\n return { surface, tempCanvas, grContext, contextHandle };\n } catch (error) {\n this.cleanupRenderResult({\n surface,\n tempCanvas,\n grContext,\n contextHandle,\n });\n return null;\n }\n }\n\n private cleanupRenderResult(result: {\n surface: JsiSkSurface | null;\n tempCanvas: OffscreenCanvas;\n grContext: GrDirectContext | null;\n contextHandle: WebGLContextHandle;\n }): void {\n result.surface?.ref.delete();\n if (result.grContext) {\n result.grContext.releaseResourcesAndAbandonContext();\n result.grContext.delete();\n }\n result.tempCanvas\n .getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n if (result.contextHandle) {\n // Unregister the context from CanvasKit's internal registry, otherwise\n // it retains the OffscreenCanvas forever.\n CanvasKit.deleteContext(result.contextHandle);\n // Clear CanvasKit's current-context globals (see WebGLRenderer.dispose).\n CanvasKit.MakeWebGLContext(result.contextHandle);\n }\n }\n\n draw(picture: SkPicture): void {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return;\n }\n const { tempCanvas } = renderResult;\n const ctx2d = this.canvas.getContext(\"2d\");\n if (!ctx2d) {\n this.cleanupRenderResult(renderResult);\n throw new Error(\"Could not get 2D context\");\n }\n\n // Set canvas dimensions to match pixel density\n this.canvas.width = this.canvas.clientWidth * this.pd;\n this.canvas.height = this.canvas.clientHeight * this.pd;\n\n // Draw the tempCanvas scaled down to the display size\n ctx2d.drawImage(\n tempCanvas,\n 0,\n 0,\n tempCanvas.width,\n tempCanvas.height,\n 0,\n 0,\n this.canvas.clientWidth * this.pd,\n this.canvas.clientHeight * this.pd\n );\n\n this.cleanupRenderResult(renderResult);\n }\n\n makeImageSnapshot(picture: SkPicture, rect?: SkRect): SkImage | null {\n if (!this.cachedImage) {\n const renderResult = this.renderPictureToSurface(picture);\n if (!renderResult) {\n return null;\n }\n\n try {\n this.cachedImage = renderResult.surface.makeImageSnapshot(\n dp2Pixel(this.pd, rect)\n );\n } catch (error) {\n console.error(\"Error creating image snapshot:\", error);\n } finally {\n this.cleanupRenderResult(renderResult);\n }\n }\n\n return this.cachedImage;\n }\n\n dispose(): void {\n this.cachedImage?.dispose();\n this.cachedImage = null;\n }\n}\n\n// Mirrors the event react-native-web synthesizes for onLayout.\nconst makeLayoutEvent = (\n x: number,\n y: number,\n width: number,\n height: number\n): LayoutChangeEvent => ({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x, y, width, height } },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n currentTarget: 0,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n target: 0,\n bubbles: false,\n cancelable: false,\n defaultPrevented: false,\n eventPhase: 0,\n isDefaultPrevented() {\n throw new Error(\"Method not supported on web.\");\n },\n isPropagationStopped() {\n throw new Error(\"Method not supported on web.\");\n },\n persist() {\n throw new Error(\"Method not supported on web.\");\n },\n preventDefault() {\n throw new Error(\"Method not supported on web.\");\n },\n stopPropagation() {\n throw new Error(\"Method not supported on web.\");\n },\n isTrusted: true,\n type: \"\",\n});\n\nexport interface SkiaPictureViewHandle {\n setPicture(picture: SkPicture): void;\n getSize(): { width: number; height: number };\n redraw(): void;\n makeImageSnapshot(rect?: SkRect): SkImage | null;\n measure(\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ): void;\n measureInWindow(\n callback: (x: number, y: number, width: number, height: number) => void\n ): void;\n}\n\nexport interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n ref?: React.Ref<SkiaPictureViewHandle>;\n}\n\nexport const SkiaPictureView = (props: SkiaPictureViewProps) => {\n const { ref, picture, onLayout } = props;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const rendererRef = useRef<Renderer | null>(null);\n const pictureRef = useRef<SkPicture | null>(null);\n // The rendering lifecycle deliberately does not depend on layout events:\n // - The renderer is created synchronously on mount (the canvas element is\n // guaranteed to exist in useLayoutEffect; a zero size at that point is\n // fine, the surface is created once the canvas is measurable).\n // - Redraw requests coalesce into a single microtask. A microtask (not an\n // animation frame) so that a picture produced inside a rAF callback (the\n // Reanimated mapper) is drawn before the current frame paints: deferring\n // to the next rAF alternates between \"flush pending in this frame\" and\n // \"flush scheduled for the next frame\", drawing on every other frame\n // only and halving the effective frame rate. A picture dispatched before\n // the canvas has a size stays in pictureRef (drawing while unmeasured is\n // a no-op) and is painted by the resize path below once the canvas\n // becomes measurable, so it is never lost.\n // - A ResizeObserver on the canvas itself recreates the surface and repaints\n // synchronously (its callbacks run after layout, before paint), and is\n // also the source of the user-facing onLayout event.\n // - The renderer belongs to the layout effect, the WebGL context to the\n // <canvas> element, whose lifetime is longer; see WebGLRenderer for how\n // the two are reconciled.\n const redrawPendingRef = useRef(false);\n const flushScheduledRef = useRef(false);\n const onLayoutRef = useRef(onLayout);\n useLayoutEffect(() => {\n onLayoutRef.current = onLayout;\n }, [onLayout]);\n\n const flushRedraw = useCallback(() => {\n flushScheduledRef.current = false;\n if (redrawPendingRef.current && rendererRef.current && pictureRef.current) {\n redrawPendingRef.current = false;\n rendererRef.current.draw(pictureRef.current);\n }\n // If the renderer or picture isn't available yet, the request stays\n // pending and is flushed by whichever arrives last.\n }, []);\n\n const redraw = useCallback(() => {\n redrawPendingRef.current = true;\n if (!flushScheduledRef.current) {\n flushScheduledRef.current = true;\n queueMicrotask(flushRedraw);\n }\n }, [flushRedraw]);\n\n const getSize = useCallback(() => {\n return {\n width: canvasRef.current?.clientWidth || 0,\n height: canvasRef.current?.clientHeight || 0,\n };\n }, []);\n\n const setPicture = useCallback(\n (newPicture: SkPicture) => {\n pictureRef.current = newPicture;\n redraw();\n },\n [redraw]\n );\n\n const makeImageSnapshot = useCallback((rect?: SkRect) => {\n if (rendererRef.current && pictureRef.current) {\n return rendererRef.current.makeImageSnapshot(pictureRef.current, rect);\n }\n return null;\n }, []);\n\n const measure = useCallback(\n (\n callback: (\n x: number,\n y: number,\n width: number,\n height: number,\n pageX: number,\n pageY: number\n ) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n const parentElement = canvasRef.current.offsetParent as HTMLElement;\n const parentRect = parentElement?.getBoundingClientRect() || {\n left: 0,\n top: 0,\n };\n\n // x, y are relative to the parent\n const x = rect.left - parentRect.left;\n const y = rect.top - parentRect.top;\n\n // pageX, pageY are absolute screen coordinates\n const pageX = rect.left + window.scrollX;\n const pageY = rect.top + window.scrollY;\n\n callback(x, y, rect.width, rect.height, pageX, pageY);\n }\n },\n []\n );\n\n const measureInWindow = useCallback(\n (\n callback: (x: number, y: number, width: number, height: number) => void\n ) => {\n if (canvasRef.current) {\n const rect = canvasRef.current.getBoundingClientRect();\n\n // x, y are the absolute coordinates in the window\n const x = rect.left;\n const y = rect.top;\n\n callback(x, y, rect.width, rect.height);\n }\n },\n []\n );\n\n const isStatic = props.__destroyWebGLContextAfterRender === true;\n\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) {\n return undefined;\n }\n const renderer = isStatic\n ? new StaticWebGLRenderer(canvas)\n : new WebGLRenderer(canvas, redraw);\n rendererRef.current = renderer;\n\n const drawPicture = () => {\n if (pictureRef.current) {\n redrawPendingRef.current = false;\n renderer.draw(pictureRef.current);\n }\n };\n\n // The renderer constructor already sized the surface from the current\n // layout, so the observer's initial delivery only repaints if the size\n // changed in between.\n let lastWidth = canvas.clientWidth;\n let lastHeight = canvas.clientHeight;\n let lastPixelDensity = window.devicePixelRatio;\n const resizeIfNeeded = () => {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const pixelDensity = window.devicePixelRatio;\n if (\n width === lastWidth &&\n height === lastHeight &&\n pixelDensity === lastPixelDensity\n ) {\n return;\n }\n lastWidth = width;\n lastHeight = height;\n lastPixelDensity = pixelDensity;\n renderer.onResize();\n drawPicture();\n };\n\n const observer = new ResizeObserver((entries) => {\n resizeIfNeeded();\n const layoutHandler = onLayoutRef.current;\n if (layoutHandler) {\n const { left, top, width, height } = entries[0].contentRect;\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () => layoutHandler(makeLayoutEvent(left, top, width, height)),\n 0\n );\n }\n });\n observer.observe(canvas);\n\n // A pixel-density change with no CSS size change (browser zoom, moving\n // the window to another display) doesn't trigger the ResizeObserver:\n // watch it via matchMedia, re-arming the query for each new density.\n // This degrades gracefully where unsupported: without matchMedia or\n // MediaQueryList.addEventListener (older Safari), or where the query\n // never matches because the resolution feature is unknown (Safari < 16),\n // density-only changes simply don't repaint — everything else still does.\n let media: MediaQueryList | null = null;\n const onPixelDensityChange = () => {\n resizeIfNeeded();\n watchPixelDensity();\n };\n const watchPixelDensity = () => {\n media?.removeEventListener(\"change\", onPixelDensityChange);\n media = null;\n if (typeof window.matchMedia === \"function\") {\n const query = window.matchMedia(\n `(resolution: ${window.devicePixelRatio}dppx)`\n );\n if (typeof query.addEventListener === \"function\") {\n media = query;\n media.addEventListener(\"change\", onPixelDensityChange);\n }\n }\n };\n watchPixelDensity();\n\n // Paint any picture that was dispatched before the renderer existed.\n drawPicture();\n\n return () => {\n observer.disconnect();\n media?.removeEventListener(\"change\", onPixelDensityChange);\n rendererRef.current = null;\n renderer.dispose();\n };\n }, [isStatic, redraw]);\n\n // No flush cancellation is needed on unmount: a microtask queued before\n // unmount runs within the same task, and flushRedraw no-ops once the\n // layout-effect cleanup has nulled rendererRef.\n\n useImperativeHandle(\n ref,\n () => ({\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n get canvasRef() {\n return () => canvasRef.current;\n },\n }),\n [setPicture, getSize, redraw, makeImageSnapshot, measure, measureInWindow]\n );\n\n useEffect(() => {\n const nativeID = props.nativeID ?? `${SkiaViewNativeId.current++}`;\n const api = global.SkiaViewApi as ISkiaViewApiWeb;\n api.registerView(nativeID, {\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n } as SkiaPictureViewHandle);\n return () => {\n api.unregisterView(nativeID);\n };\n }, [\n setPicture,\n getSize,\n redraw,\n makeImageSnapshot,\n measure,\n measureInWindow,\n props.nativeID,\n ]);\n\n useEffect(() => {\n if (picture) {\n setPicture(picture);\n }\n }, [setPicture, picture]);\n\n const {\n debug: _debug,\n ref: _ref,\n onLayout: _onLayout,\n picture: _picture,\n __destroyWebGLContextAfterRender: _isStatic,\n ...viewProps\n } = props;\n return (\n <Platform.View {...viewProps}>\n <canvas\n // A canvas element is bound to one context kind for life (WebGL for\n // the live renderer, 2D for the static one), so switching renderers\n // needs a fresh element.\n key={isStatic ? \"static\" : \"webgl\"}\n ref={canvasRef}\n style={{ display: \"block\", width: \"100%\", height: \"100%\" }}\n />\n </Platform.View>\n );\n};\n"],"mappings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C;EACL,CAAC,GAAGhE,KAAK;EACT,oBACEpI,KAAA,CAAAqM,aAAA,CAAC9L,QAAQ,CAAC+L,IAAI,EAAKF,SAAS,eAC1BpM,KAAA,CAAAqM,aAAA;IACE;IACA;IACA;IACAE,GAAG,EAAEtC,QAAQ,GAAG,QAAQ,GAAG,OAAQ;IACnClG,GAAG,EAAEuE,SAAU;IACfkE,KAAK,EAAE;MAAEC,OAAO,EAAE,OAAO;MAAE1L,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO;EAAE,CAC5D,CACY,CAAC;AAEpB,CAAC","ignoreList":[]}
@@ -23,7 +23,7 @@ export class JsiSkPathBuilder extends _Host.HostObject {
23
23
  addOval(oval: any, isCCW: any, startIndex: any): this;
24
24
  addArc(oval: any, startAngleInDegrees: any, sweepAngleInDegrees: any): this;
25
25
  addRRect(rrect: any, isCCW: any): this;
26
- addCircle(x: any, y: any, r: any, _isCCW: any): this;
26
+ addCircle(x: any, y: any, r: any, isCCW: any): this;
27
27
  addPoly(points: any, close: any): this;
28
28
  addPath(src: any, matrix: any, extend?: boolean): this;
29
29
  setFillType(fill: any): this;
@@ -22,7 +22,7 @@ export class JsiSkPathBuilder extends HostObject {
22
22
  addOval(oval: any, isCCW: any, startIndex: any): this;
23
23
  addArc(oval: any, startAngleInDegrees: any, sweepAngleInDegrees: any): this;
24
24
  addRRect(rrect: any, isCCW: any): this;
25
- addCircle(x: any, y: any, r: any, _isCCW: any): this;
25
+ addCircle(x: any, y: any, r: any, isCCW: any): this;
26
26
  addPoly(points: any, close: any): this;
27
27
  addPath(src: any, matrix: any, extend?: boolean): this;
28
28
  setFillType(fill: any): this;
@@ -0,0 +1,3 @@
1
+ export namespace spm {
2
+ let name: string;
3
+ }
@@ -25,7 +25,7 @@ export declare class JsiSkPathBuilder extends HostObject<CKPathBuilder, "PathBui
25
25
  addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): this;
26
26
  addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): this;
27
27
  addRRect(rrect: InputRRect, isCCW?: boolean): this;
28
- addCircle(x: number, y: number, r: number, _isCCW?: boolean): this;
28
+ addCircle(x: number, y: number, r: number, isCCW?: boolean): this;
29
29
  addPoly(points: SkPoint[], close: boolean): this;
30
30
  addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): this;
31
31
  setFillType(fill: FillType): this;
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": "2.11.2",
11
+ "version": "2.12.0",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -32,6 +32,9 @@
32
32
  "cpp/**/*.{h,cpp}",
33
33
  "apple/**",
34
34
  "react-native-skia.podspec",
35
+ "Package.swift",
36
+ "include/**",
37
+ "react-native.config.js",
35
38
  "dist/**",
36
39
  "libs/.graphite"
37
40
  ],
@@ -51,7 +54,6 @@
51
54
  "clang-format-ios": "find apple/ -iname '*.h' -o -iname '*.mm' -o -iname '*.cpp' | xargs clang-format -i",
52
55
  "clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
53
56
  "clang-format-common": "find cpp/ \\( -path 'cpp//skia' -prune \\) -o \\( -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' \\) -print | xargs clang-format -i",
54
- "workflow-copy-libs": "tsx ./scripts/workflow-copy-libs.ts",
55
57
  "cpplint": "cpplint --linelength=230 --filter=-legal/copyright,-whitespace/indent,-whitespace/comments,-whitespace/ending_newline,-build/include_order,-runtime/references,-readability/todo,-whitespace/blank_line,-whitespace/todo,-runtime/int,-build/c++11,-whitespace/parens --exclude=package/cpp/skia --exclude=package/ios --exclude=package/android/build --exclude=package/node_modules --recursive package"
56
58
  },
57
59
  "repository": {
@@ -116,6 +118,7 @@
116
118
  "eslint-config-react-native-wcandillon": "4.0.1",
117
119
  "eslint-plugin-import": "2.32.0",
118
120
  "eslint-plugin-react-hooks": "^5.2.0",
121
+ "extract-zip": "^2.0.1",
119
122
  "jest": "30.0.0",
120
123
  "jest-diff": "29.7.0",
121
124
  "jest-environment-jsdom": "30.0.0",
@@ -139,16 +142,16 @@
139
142
  },
140
143
  "dependencies": {
141
144
  "canvaskit-wasm": "0.41.0",
142
- "react-native-skia-android": "152.0.0",
143
- "react-native-skia-apple-ios": "152.0.0",
144
- "react-native-skia-apple-macos": "152.0.0",
145
- "react-native-skia-apple-tvos": "152.0.0",
145
+ "react-native-skia-android": "154.0.0",
146
+ "react-native-skia-apple-ios": "154.0.0",
147
+ "react-native-skia-apple-macos": "154.0.0",
148
+ "react-native-skia-apple-tvos": "154.0.0",
146
149
  "react-reconciler": "0.31.0"
147
150
  },
148
151
  "graphiteDependencies": {
149
- "react-native-skia-graphite-android": "152.0.0",
150
- "react-native-skia-graphite-apple-ios": "152.0.0",
151
- "react-native-skia-graphite-apple-macos": "152.0.0"
152
+ "react-native-skia-graphite-android": "154.0.0",
153
+ "react-native-skia-graphite-apple-ios": "154.0.0",
154
+ "react-native-skia-graphite-apple-macos": "154.0.0"
152
155
  },
153
156
  "eslintIgnore": [
154
157
  "node_modules/",
@@ -0,0 +1,5 @@
1
+ // Pins the SwiftPM target name. Without it the name is derived — today from the
2
+ // npm name (ReactNativeSkia), but an in-flight React Native change derives it
3
+ // from the podspec instead (react-native-skia). The name is also the header
4
+ // import prefix, so it must not move.
5
+ module.exports = {spm: {name: 'ReactNativeSkia'}};
@@ -209,7 +209,9 @@ export class JsiSkCanvas
209
209
  cubics.map(({ x, y }) => [x, y]).flat(),
210
210
  colors,
211
211
  texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,
212
- mode ? getEnum(this.CanvasKit, "BlendMode", mode) : null,
212
+ mode !== undefined && mode !== null
213
+ ? getEnum(this.CanvasKit, "BlendMode", mode)
214
+ : null,
213
215
  paint ? JsiSkPaint.fromValue(paint) : undefined
214
216
  );
215
217
  }
@@ -362,7 +364,9 @@ export class JsiSkCanvas
362
364
  drawColor(color: SkColor, blendMode?: BlendMode) {
363
365
  this.ref.drawColor(
364
366
  color,
365
- blendMode ? getEnum(this.CanvasKit, "BlendMode", blendMode) : undefined
367
+ blendMode !== undefined
368
+ ? getEnum(this.CanvasKit, "BlendMode", blendMode)
369
+ : undefined
366
370
  );
367
371
  }
368
372
 
@@ -430,9 +434,10 @@ export class JsiSkCanvas
430
434
  } else if (sampling) {
431
435
  ckSampling = {
432
436
  filter: getEnum(this.CanvasKit, "FilterMode", sampling.filter),
433
- mipmap: sampling.mipmap
434
- ? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap)
435
- : this.CanvasKit.MipmapMode.None,
437
+ mipmap:
438
+ sampling.mipmap !== undefined
439
+ ? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap)
440
+ : this.CanvasKit.MipmapMode.None,
436
441
  };
437
442
  }
438
443
  this.ref.drawAtlas(
@@ -440,7 +445,7 @@ export class JsiSkCanvas
440
445
  src,
441
446
  dst,
442
447
  JsiSkPaint.fromValue(paint),
443
- blendMode
448
+ blendMode !== undefined
444
449
  ? getEnum(this.CanvasKit, "BlendMode", blendMode)
445
450
  : this.CanvasKit.BlendMode.DstOver,
446
451
  cls,
@@ -107,12 +107,15 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
107
107
 
108
108
  encodeToBytes(fmt?: ImageFormat, quality?: number) {
109
109
  let result: Uint8Array | null;
110
- if (fmt && quality) {
110
+ if (fmt !== undefined && quality !== undefined) {
111
+ // CanvasKit's encodeToBytes() applies `quality || 100`, which would
112
+ // turn a valid quality of 0 into 100. The encoders clamp any quality
113
+ // below 1 up to 1 anyway, so pass 1 to get the same output as 0.
111
114
  result = this.ref.encodeToBytes(
112
115
  getEnum(this.CanvasKit, "ImageFormat", fmt),
113
- quality
116
+ Math.max(quality, 1)
114
117
  );
115
- } else if (fmt) {
118
+ } else if (fmt !== undefined) {
116
119
  result = this.ref.encodeToBytes(
117
120
  getEnum(this.CanvasKit, "ImageFormat", fmt)
118
121
  );
@@ -188,8 +188,8 @@ export class JsiSkPathBuilder
188
188
  return this;
189
189
  }
190
190
 
191
- addCircle(x: number, y: number, r: number, _isCCW?: boolean) {
192
- this.ref.addCircle(x, y, r);
191
+ addCircle(x: number, y: number, r: number, isCCW?: boolean) {
192
+ this.ref.addCircle(x, y, r, isCCW);
193
193
  return this;
194
194
  }
195
195
 
@@ -9,23 +9,27 @@ export class JsiSkTextStyle {
9
9
  color: value.color,
10
10
  decoration: value.decoration,
11
11
  decorationColor: value.decorationColor,
12
- decorationStyle: value.decorationStyle
13
- ? { value: value.decorationStyle }
14
- : undefined,
12
+ decorationStyle:
13
+ value.decorationStyle !== undefined
14
+ ? { value: value.decorationStyle }
15
+ : undefined,
15
16
  decorationThickness: value.decorationThickness,
16
17
  fontFamilies: value.fontFamilies,
17
18
  fontSize: value.fontSize,
18
19
  fontStyle: value.fontStyle
19
20
  ? {
20
- slant: value.fontStyle.slant
21
- ? { value: value.fontStyle.slant }
22
- : undefined,
23
- weight: value.fontStyle.weight
24
- ? { value: value.fontStyle.weight }
25
- : undefined,
26
- width: value.fontStyle.width
27
- ? { value: value.fontStyle.width }
28
- : undefined,
21
+ slant:
22
+ value.fontStyle.slant !== undefined
23
+ ? { value: value.fontStyle.slant }
24
+ : undefined,
25
+ weight:
26
+ value.fontStyle.weight !== undefined
27
+ ? { value: value.fontStyle.weight }
28
+ : undefined,
29
+ width:
30
+ value.fontStyle.width !== undefined
31
+ ? { value: value.fontStyle.width }
32
+ : undefined,
29
33
  }
30
34
  : undefined,
31
35
  fontFeatures: value.fontFeatures,
@@ -44,9 +48,10 @@ export class JsiSkTextStyle {
44
48
  : undefined,
45
49
  }))
46
50
  : undefined,
47
- textBaseline: value.textBaseline
48
- ? { value: value.textBaseline }
49
- : undefined,
51
+ textBaseline:
52
+ value.textBaseline !== undefined
53
+ ? { value: value.textBaseline }
54
+ : undefined,
50
55
  wordSpacing: value.wordSpacing,
51
56
  };
52
57
  }
@@ -164,28 +164,28 @@ export class JsiSkottieAnimation
164
164
  if (result.text) {
165
165
  textSlot.text = result.text;
166
166
  }
167
- if (result.textSize) {
167
+ if (result.textSize !== undefined) {
168
168
  textSlot.textSize = result.textSize;
169
169
  }
170
- if (result.minTextSize) {
170
+ if (result.minTextSize !== undefined) {
171
171
  textSlot.minTextSize = result.minTextSize;
172
172
  }
173
- if (result.maxTextSize) {
173
+ if (result.maxTextSize !== undefined) {
174
174
  textSlot.maxTextSize = result.maxTextSize;
175
175
  }
176
- if (result.strokeWidth) {
176
+ if (result.strokeWidth !== undefined) {
177
177
  textSlot.strokeWidth = result.strokeWidth;
178
178
  }
179
- if (result.lineHeight) {
179
+ if (result.lineHeight !== undefined) {
180
180
  textSlot.lineHeight = result.lineHeight;
181
181
  }
182
- if (result.lineShift) {
182
+ if (result.lineShift !== undefined) {
183
183
  textSlot.lineShift = result.lineShift;
184
184
  }
185
- if (result.ascent) {
185
+ if (result.ascent !== undefined) {
186
186
  textSlot.ascent = result.ascent;
187
187
  }
188
- if (result.maxLines) {
188
+ if (result.maxLines !== undefined) {
189
189
  textSlot.maxLines = result.maxLines;
190
190
  }
191
191
  // if (result.horizAlign) {
@@ -297,7 +297,8 @@ export const drawImageSVG = (ctx: DrawingContext, props: ImageSVGProps) => {
297
297
  return;
298
298
  }
299
299
  canvas.save();
300
- if (x && y) {
300
+ // An offset of 0 is a valid position, so it must not be read as "unset".
301
+ if (x !== undefined && y !== undefined) {
301
302
  canvas.translate(x, y);
302
303
  }
303
304
  canvas.drawSvg(svg, width, height);