@shopify/react-native-skia 2.2.14 → 2.2.16

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 (92) hide show
  1. package/apple/MetalContext.h +3 -25
  2. package/apple/MetalContext.mm +7 -3
  3. package/apple/MetalWindowContext.mm +11 -1
  4. package/apple/RNSkMetalCanvasProvider.mm +3 -6
  5. package/cpp/api/JsiSkImage.h +16 -1
  6. package/cpp/api/JsiSkSurface.h +17 -1
  7. package/cpp/api/JsiSkThreadSafeDeletion.h +105 -0
  8. package/cpp/api/recorder/Drawings.h +7 -7
  9. package/cpp/jsi/JsiHostObject.cpp +0 -27
  10. package/cpp/jsi/JsiHostObject.h +5 -5
  11. package/cpp/jsi/ViewProperty.h +34 -2
  12. package/cpp/rnskia/RNSkJsiViewApi.h +14 -24
  13. package/cpp/rnskia/RNSkPictureView.h +25 -2
  14. package/cpp/rnskia/RNSkView.h +7 -0
  15. package/lib/commonjs/Platform/Platform.js +2 -1
  16. package/lib/commonjs/Platform/Platform.js.map +1 -1
  17. package/lib/commonjs/Platform/Platform.web.js +3 -0
  18. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  19. package/lib/commonjs/__tests__/globalSetup.d.ts +1 -1
  20. package/lib/commonjs/renderer/Canvas.d.ts +1 -1
  21. package/lib/commonjs/renderer/Canvas.js +24 -1
  22. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  23. package/lib/commonjs/renderer/__tests__/setup.d.ts +1 -1
  24. package/lib/commonjs/skia/core/SVG.web.js +1 -1
  25. package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
  26. package/lib/commonjs/skia/types/Data/Data.d.ts +6 -1
  27. package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
  28. package/lib/commonjs/sksg/Container.d.ts +2 -3
  29. package/lib/commonjs/sksg/Container.js +1 -1
  30. package/lib/commonjs/sksg/Container.js.map +1 -1
  31. package/lib/commonjs/sksg/Container.native.d.ts +3 -5
  32. package/lib/commonjs/sksg/Container.native.js +8 -15
  33. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  34. package/lib/commonjs/sksg/Container.web.d.ts +2 -3
  35. package/lib/commonjs/sksg/Container.web.js +1 -1
  36. package/lib/commonjs/sksg/Container.web.js.map +1 -1
  37. package/lib/commonjs/sksg/Reconciler.d.ts +2 -3
  38. package/lib/commonjs/sksg/Reconciler.js +2 -2
  39. package/lib/commonjs/sksg/Reconciler.js.map +1 -1
  40. package/lib/module/Platform/Platform.js +2 -1
  41. package/lib/module/Platform/Platform.js.map +1 -1
  42. package/lib/module/Platform/Platform.web.js +3 -0
  43. package/lib/module/Platform/Platform.web.js.map +1 -1
  44. package/lib/module/__tests__/globalSetup.d.ts +1 -1
  45. package/lib/module/renderer/Canvas.d.ts +1 -1
  46. package/lib/module/renderer/Canvas.js +24 -1
  47. package/lib/module/renderer/Canvas.js.map +1 -1
  48. package/lib/module/renderer/__tests__/setup.d.ts +1 -1
  49. package/lib/module/skia/core/SVG.web.js +1 -1
  50. package/lib/module/skia/core/SVG.web.js.map +1 -1
  51. package/lib/module/skia/types/Data/Data.d.ts +6 -1
  52. package/lib/module/skia/types/Data/Data.js.map +1 -1
  53. package/lib/module/sksg/Container.d.ts +2 -3
  54. package/lib/module/sksg/Container.js +1 -1
  55. package/lib/module/sksg/Container.js.map +1 -1
  56. package/lib/module/sksg/Container.native.d.ts +3 -5
  57. package/lib/module/sksg/Container.native.js +8 -15
  58. package/lib/module/sksg/Container.native.js.map +1 -1
  59. package/lib/module/sksg/Container.web.d.ts +2 -3
  60. package/lib/module/sksg/Container.web.js +1 -1
  61. package/lib/module/sksg/Container.web.js.map +1 -1
  62. package/lib/module/sksg/Reconciler.d.ts +2 -3
  63. package/lib/module/sksg/Reconciler.js +2 -2
  64. package/lib/module/sksg/Reconciler.js.map +1 -1
  65. package/lib/typescript/lib/commonjs/sksg/Container.d.ts +1 -1
  66. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +2 -3
  67. package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +1 -1
  68. package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +1 -1
  69. package/lib/typescript/lib/module/sksg/Container.d.ts +1 -1
  70. package/lib/typescript/lib/module/sksg/Container.native.d.ts +2 -3
  71. package/lib/typescript/lib/module/sksg/Container.web.d.ts +1 -1
  72. package/lib/typescript/lib/module/sksg/Reconciler.d.ts +1 -1
  73. package/lib/typescript/src/__tests__/globalSetup.d.ts +1 -1
  74. package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
  75. package/lib/typescript/src/renderer/__tests__/setup.d.ts +1 -1
  76. package/lib/typescript/src/skia/types/Data/Data.d.ts +6 -1
  77. package/lib/typescript/src/sksg/Container.d.ts +2 -3
  78. package/lib/typescript/src/sksg/Container.native.d.ts +3 -5
  79. package/lib/typescript/src/sksg/Container.web.d.ts +2 -3
  80. package/lib/typescript/src/sksg/Reconciler.d.ts +2 -3
  81. package/package.json +1 -1
  82. package/src/Platform/Platform.ts +3 -0
  83. package/src/Platform/Platform.web.tsx +3 -0
  84. package/src/__tests__/globalSetup.ts +5 -3
  85. package/src/renderer/Canvas.tsx +27 -5
  86. package/src/renderer/__tests__/setup.tsx +1 -1
  87. package/src/skia/core/SVG.web.ts +3 -0
  88. package/src/skia/types/Data/Data.ts +7 -1
  89. package/src/sksg/Container.native.ts +10 -27
  90. package/src/sksg/Container.ts +2 -8
  91. package/src/sksg/Container.web.ts +2 -8
  92. package/src/sksg/Reconciler.ts +3 -4
@@ -1 +1 @@
1
- {"version":3,"names":["React","useLayoutEffect","useMemo","useRef","isRNModule","DOM_LAYOUT_HANDLER_NAME","resizeObserver","getObserver","window","ResizeObserver","entries","forEach","entry","node","target","left","top","width","height","contentRect","onLayout","setTimeout","timeStamp","Date","now","nativeEvent","layout","x","y","currentTarget","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","Error","isPropagationStopped","persist","preventDefault","stopPropagation","isTrusted","type","useElementLayout","ref","observer","current","observe","unobserve","View","children","style","rawStyle","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","OS","PixelRatio","devicePixelRatio","resolveAsset","source","require","getAssetByID","httpServerLocation","name","uri","default","findNodeHandle"],"sources":["Platform.web.tsx"],"sourcesContent":["import type { RefObject, CSSProperties } from \"react\";\nimport React, { useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { LayoutChangeEvent, ViewComponent, ViewProps } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\n// eslint-disable-next-line max-len\n// https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/modules/useElementLayout/index.js\nconst DOM_LAYOUT_HANDLER_NAME = \"__reactLayoutHandler\";\ntype OnLayout = ((event: LayoutChangeEvent) => void) | undefined;\ntype Div = HTMLDivElement & {\n __reactLayoutHandler: OnLayout;\n};\n\nlet resizeObserver: ResizeObserver | null = null;\n\nconst getObserver = () => {\n if (resizeObserver == null) {\n resizeObserver = new window.ResizeObserver(function (entries) {\n entries.forEach((entry) => {\n const node = entry.target as Div;\n const { left, top, width, height } = entry.contentRect;\n const onLayout = node[DOM_LAYOUT_HANDLER_NAME];\n if (typeof onLayout === \"function\") {\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () =>\n onLayout({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x: left, y: top, 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 0\n );\n }\n });\n });\n }\n return resizeObserver;\n};\n\nconst useElementLayout = (ref: RefObject<Div>, onLayout: OnLayout) => {\n const observer = getObserver();\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node !== null) {\n node[DOM_LAYOUT_HANDLER_NAME] = onLayout;\n }\n }, [ref, onLayout]);\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node != null && observer != null) {\n if (typeof node[DOM_LAYOUT_HANDLER_NAME] === \"function\") {\n observer.observe(node);\n } else {\n observer.unobserve(node);\n }\n }\n return () => {\n if (node != null && observer != null) {\n observer.unobserve(node);\n }\n };\n }, [observer, ref]);\n};\n\nconst View = (({ children, onLayout, style: rawStyle }: ViewProps) => {\n const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);\n const ref = useRef<Div>(null);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n useElementLayout(ref as any, onLayout);\n const cssStyles = useMemo(() => {\n return {\n alignItems: \"stretch\" as const,\n backgroundColor: \"transparent\" as const,\n border: \"0 solid black\" as const,\n boxSizing: \"border-box\" as const,\n display: \"flex\" as const,\n flexBasis: \"auto\" as const,\n flexDirection: \"column\" as const,\n flexShrink: 0,\n listStyle: \"none\" as const,\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: \"relative\" as const,\n textDecoration: \"none\" as const,\n zIndex: 0,\n ...style,\n };\n }, [style]);\n\n return (\n <div ref={ref} style={cssStyles}>\n {children}\n </div>\n );\n}) as unknown as typeof ViewComponent;\n\nexport const Platform: IPlatform = {\n OS: \"web\",\n PixelRatio: typeof window !== \"undefined\" ? window.devicePixelRatio : 1, // window is not defined on node\n resolveAsset: (source: DataModule) => {\n if (isRNModule(source)) {\n if (typeof source === \"number\" && typeof require === \"function\") {\n const {\n getAssetByID,\n } = require(\"react-native/Libraries/Image/AssetRegistry\");\n const { httpServerLocation, name, type } = getAssetByID(source);\n const uri = `${httpServerLocation}/${name}.${type}`;\n return uri;\n }\n throw new Error(\n \"Asset source is a number - this is not supported on the web\"\n );\n }\n return source.default;\n },\n findNodeHandle: () => {\n throw new Error(\"findNodeHandle is not supported on the web\");\n },\n View,\n};\n"],"mappings":"AACA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAI/D,SAASC,UAAU,QAAQ,eAAe;AAI1C;AACA;AACA,MAAMC,uBAAuB,GAAG,sBAAsB;AAMtD,IAAIC,cAAqC,GAAG,IAAI;AAEhD,MAAMC,WAAW,GAAGA,CAAA,KAAM;EACxB,IAAID,cAAc,IAAI,IAAI,EAAE;IAC1BA,cAAc,GAAG,IAAIE,MAAM,CAACC,cAAc,CAAC,UAAUC,OAAO,EAAE;MAC5DA,OAAO,CAACC,OAAO,CAAEC,KAAK,IAAK;QACzB,MAAMC,IAAI,GAAGD,KAAK,CAACE,MAAa;QAChC,MAAM;UAAEC,IAAI;UAAEC,GAAG;UAAEC,KAAK;UAAEC;QAAO,CAAC,GAAGN,KAAK,CAACO,WAAW;QACtD,MAAMC,QAAQ,GAAGP,IAAI,CAACR,uBAAuB,CAAC;QAC9C,IAAI,OAAOe,QAAQ,KAAK,UAAU,EAAE;UAClC;UACAC,UAAU,CACR,MACED,QAAQ,CAAC;YACPE,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;YACrBC,WAAW,EAAE;cAAEC,MAAM,EAAE;gBAAEC,CAAC,EAAEZ,IAAI;gBAAEa,CAAC,EAAEZ,GAAG;gBAAEC,KAAK;gBAAEC;cAAO;YAAE,CAAC;YAC3D;YACA;YACAW,aAAa,EAAE,CAAC;YAChB;YACA;YACAf,MAAM,EAAE,CAAC;YACTgB,OAAO,EAAE,KAAK;YACdC,UAAU,EAAE,KAAK;YACjBC,gBAAgB,EAAE,KAAK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V,CAAqC;AAErC,OAAO,MAAMqB,QAAmB,GAAG;EACjCC,EAAE,EAAE,KAAK;EACTC,UAAU,EAAE,OAAOhE,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACiE,gBAAgB,GAAG,CAAC;EAAE;EACzEC,YAAY,EAAGC,MAAkB,IAAK;IACpC,IAAIvE,UAAU,CAACuE,MAAM,CAAC,EAAE;MACtB,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,OAAOC,OAAO,KAAK,UAAU,EAAE;QAC/D,MAAM;UACJC;QACF,CAAC,GAAGD,OAAO,CAAC,4CAA4C,CAAC;QACzD,MAAM;UAAEE,kBAAkB;UAAEC,IAAI;UAAEtC;QAAK,CAAC,GAAGoC,YAAY,CAACF,MAAM,CAAC;QAC/D,MAAMK,GAAG,GAAG,GAAGF,kBAAkB,IAAIC,IAAI,IAAItC,IAAI,EAAE;QACnD,OAAOuC,GAAG;MACZ;MACA,MAAM,IAAI7C,KAAK,CACb,6DACF,CAAC;IACH;IACA,OAAOwC,MAAM,CAACM,OAAO;EACvB,CAAC;EACDC,cAAc,EAAEA,CAAA,KAAM;IACpB,MAAM,IAAI/C,KAAK,CAAC,4CAA4C,CAAC;EAC/D,CAAC;EACDa;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useLayoutEffect","useMemo","useRef","isRNModule","DOM_LAYOUT_HANDLER_NAME","resizeObserver","getObserver","window","ResizeObserver","entries","forEach","entry","node","target","left","top","width","height","contentRect","onLayout","setTimeout","timeStamp","Date","now","nativeEvent","layout","x","y","currentTarget","bubbles","cancelable","defaultPrevented","eventPhase","isDefaultPrevented","Error","isPropagationStopped","persist","preventDefault","stopPropagation","isTrusted","type","useElementLayout","ref","observer","current","observe","unobserve","View","children","style","rawStyle","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","OS","PixelRatio","devicePixelRatio","resolveAsset","source","require","getAssetByID","httpServerLocation","name","uri","default","findNodeHandle"],"sources":["Platform.web.tsx"],"sourcesContent":["import type { RefObject, CSSProperties } from \"react\";\nimport React, { useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { LayoutChangeEvent, ViewComponent, ViewProps } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\n// eslint-disable-next-line max-len\n// https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/modules/useElementLayout/index.js\nconst DOM_LAYOUT_HANDLER_NAME = \"__reactLayoutHandler\";\ntype OnLayout = ((event: LayoutChangeEvent) => void) | undefined;\ntype Div = HTMLDivElement & {\n __reactLayoutHandler: OnLayout;\n};\n\nlet resizeObserver: ResizeObserver | null = null;\n\nconst getObserver = () => {\n if (resizeObserver == null) {\n resizeObserver = new window.ResizeObserver(function (entries) {\n entries.forEach((entry) => {\n const node = entry.target as Div;\n const { left, top, width, height } = entry.contentRect;\n const onLayout = node[DOM_LAYOUT_HANDLER_NAME];\n if (typeof onLayout === \"function\") {\n // setTimeout 0 is taken from react-native-web (UIManager)\n setTimeout(\n () =>\n onLayout({\n timeStamp: Date.now(),\n nativeEvent: { layout: { x: left, y: top, 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 0\n );\n }\n });\n });\n }\n return resizeObserver;\n};\n\nconst useElementLayout = (ref: RefObject<Div>, onLayout: OnLayout) => {\n const observer = getObserver();\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node !== null) {\n node[DOM_LAYOUT_HANDLER_NAME] = onLayout;\n }\n }, [ref, onLayout]);\n\n useLayoutEffect(() => {\n const node = ref.current;\n if (node != null && observer != null) {\n if (typeof node[DOM_LAYOUT_HANDLER_NAME] === \"function\") {\n observer.observe(node);\n } else {\n observer.unobserve(node);\n }\n }\n return () => {\n if (node != null && observer != null) {\n observer.unobserve(node);\n }\n };\n }, [observer, ref]);\n};\n\nconst View = (({ children, onLayout, style: rawStyle }: ViewProps) => {\n const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);\n const ref = useRef<Div>(null);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n useElementLayout(ref as any, onLayout);\n const cssStyles = useMemo(() => {\n return {\n alignItems: \"stretch\" as const,\n backgroundColor: \"transparent\" as const,\n border: \"0 solid black\" as const,\n boxSizing: \"border-box\" as const,\n display: \"flex\" as const,\n flexBasis: \"auto\" as const,\n flexDirection: \"column\" as const,\n flexShrink: 0,\n listStyle: \"none\" as const,\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: \"relative\" as const,\n textDecoration: \"none\" as const,\n zIndex: 0,\n ...style,\n };\n }, [style]);\n\n return (\n <div ref={ref} style={cssStyles}>\n {children}\n </div>\n );\n}) as unknown as typeof ViewComponent;\n\nexport const Platform: IPlatform = {\n OS: \"web\",\n PixelRatio: typeof window !== \"undefined\" ? window.devicePixelRatio : 1, // window is not defined on node\n resolveAsset: (source: DataModule) => {\n if (isRNModule(source)) {\n if (typeof source === \"number\" && typeof require === \"function\") {\n const {\n getAssetByID,\n } = require(\"react-native/Libraries/Image/AssetRegistry\");\n const { httpServerLocation, name, type } = getAssetByID(source);\n const uri = `${httpServerLocation}/${name}.${type}`;\n return uri;\n }\n throw new Error(\n \"Asset source is a number - this is not supported on the web\"\n );\n }\n if (\"uri\" in source) {\n return source.uri;\n }\n return source.default;\n },\n findNodeHandle: () => {\n throw new Error(\"findNodeHandle is not supported on the web\");\n },\n View,\n};\n"],"mappings":"AACA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAI/D,SAASC,UAAU,QAAQ,eAAe;AAI1C;AACA;AACA,MAAMC,uBAAuB,GAAG,sBAAsB;AAMtD,IAAIC,cAAqC,GAAG,IAAI;AAEhD,MAAMC,WAAW,GAAGA,CAAA,KAAM;EACxB,IAAID,cAAc,IAAI,IAAI,EAAE;IAC1BA,cAAc,GAAG,IAAIE,MAAM,CAACC,cAAc,CAAC,UAAUC,OAAO,EAAE;MAC5DA,OAAO,CAACC,OAAO,CAAEC,KAAK,IAAK;QACzB,MAAMC,IAAI,GAAGD,KAAK,CAACE,MAAa;QAChC,MAAM;UAAEC,IAAI;UAAEC,GAAG;UAAEC,KAAK;UAAEC;QAAO,CAAC,GAAGN,KAAK,CAACO,WAAW;QACtD,MAAMC,QAAQ,GAAGP,IAAI,CAACR,uBAAuB,CAAC;QAC9C,IAAI,OAAOe,QAAQ,KAAK,UAAU,EAAE;UAClC;UACAC,UAAU,CACR,MACED,QAAQ,CAAC;YACPE,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;YACrBC,WAAW,EAAE;cAAEC,MAAM,EAAE;gBAAEC,CAAC,EAAEZ,IAAI;gBAAEa,CAAC,EAAEZ,GAAG;gBAAEC,KAAK;gBAAEC;cAAO;YAAE,CAAC;YAC3D;YACA;YACAW,aAAa,EAAE,CAAC;YAChB;YACA;YACAf,MAAM,EAAE,CAAC;YACTgB,OAAO,EAAE,KAAK;YACdC,UAAU,EAAE,KAAK;YACjBC,gBAAgB,EAAE,KAAK;YACvBC,UAAU,EAAE,CAAC;YACbC,kBAAkBA,CAAA,EAAG;cACnB,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;YACjD,CAAC;YACDC,oBAAoBA,CAAA,EAAG;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B,GAAG,CAAC;EAAE;EACzEC,YAAY,EAAGC,MAAkB,IAAK;IACpC,IAAIvE,UAAU,CAACuE,MAAM,CAAC,EAAE;MACtB,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,OAAOC,OAAO,KAAK,UAAU,EAAE;QAC/D,MAAM;UACJC;QACF,CAAC,GAAGD,OAAO,CAAC,4CAA4C,CAAC;QACzD,MAAM;UAAEE,kBAAkB;UAAEC,IAAI;UAAEtC;QAAK,CAAC,GAAGoC,YAAY,CAACF,MAAM,CAAC;QAC/D,MAAMK,GAAG,GAAG,GAAGF,kBAAkB,IAAIC,IAAI,IAAItC,IAAI,EAAE;QACnD,OAAOuC,GAAG;MACZ;MACA,MAAM,IAAI7C,KAAK,CACb,6DACF,CAAC;IACH;IACA,IAAI,KAAK,IAAIwC,MAAM,EAAE;MACnB,OAAOA,MAAM,CAACK,GAAG;IACnB;IACA,OAAOL,MAAM,CAACM,OAAO;EACvB,CAAC;EACDC,cAAc,EAAEA,CAAA,KAAM;IACpB,MAAM,IAAI/C,KAAK,CAAC,4CAA4C,CAAC;EAC/D,CAAC;EACDa;AACF,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import type { Server, WebSocket } from "ws";
2
2
  declare global {
3
3
  var testServer: Server;
4
4
  var testClient: WebSocket;
5
- var testOS: "ios" | "android" | "web" | "node";
5
+ var testOS: "ios" | "android" | "web" | "node" | "macos";
6
6
  var testArch: "paper" | "fabric";
7
7
  }
8
8
  declare const globalSetup: () => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { FC, RefObject } from "react";
2
2
  import React from "react";
3
3
  import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback, ViewProps } from "react-native";
4
- import { type SharedValue } from "react-native-reanimated";
4
+ import type { SharedValue } from "react-native-reanimated";
5
5
  import type { SkImage, SkRect, SkSize } from "../skia/types";
6
6
  export interface CanvasRef extends FC<CanvasProps> {
7
7
  makeImageSnapshot(rect?: SkRect): SkImage;
@@ -1,12 +1,15 @@
1
1
  var _global;
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React, { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import Rea from "../external/reanimated/ReanimatedProxy";
4
5
  import { SkiaViewNativeId } from "../views/SkiaViewNativeId";
5
6
  import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
6
7
  import { SkiaSGRoot } from "../sksg/Reconciler";
7
8
  import { Skia } from "../skia";
8
9
  import { Platform } from "../Platform";
10
+ import { HAS_REANIMATED_3 } from "../external";
9
11
  export const useCanvasRef = () => useRef(null);
12
+ const useReanimatedFrame = !HAS_REANIMATED_3 ? () => {} : Rea.useFrameCallback;
10
13
  export const useCanvasSize = userRef => {
11
14
  const ourRef = useCanvasRef();
12
15
  const ref = userRef !== null && userRef !== void 0 ? userRef : ourRef;
@@ -58,7 +61,27 @@ export const Canvas = ({
58
61
  }, []);
59
62
 
60
63
  // Root
61
- const root = useMemo(() => new SkiaSGRoot(Skia, nativeId, onSize), [nativeId, onSize]);
64
+ const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);
65
+ useReanimatedFrame(() => {
66
+ "worklet";
67
+ }, !!onSize);
68
+ useEffect(() => {
69
+ if (onSize) {
70
+ Rea.runOnUI(() => {
71
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72
+ // @ts-expect-error
73
+ global[`__onSize_${nativeId}`] = onSize;
74
+ })();
75
+ return () => {
76
+ Rea.runOnUI(() => {
77
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
+ // @ts-expect-error
79
+ delete global[`__onSize_${nativeId}`];
80
+ })();
81
+ };
82
+ }
83
+ return undefined;
84
+ }, [onSize, nativeId]);
62
85
 
63
86
  // Render effects
64
87
  useLayoutEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","Platform","useCanvasRef","useCanvasSize","userRef","ourRef","ref","size","setSize","width","height","current","measure","_x","_y","isFabric","Boolean","_global","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","root","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","onLayoutWeb","e","OS","nativeEvent","layout","value","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAUd,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AAWtC,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMP,MAAM,CAAY,IAAI,CAAC;AAEzD,OAAO,MAAMQ,aAAa,GAAIC,OAAqC,IAAK;EACtE,MAAMC,MAAM,GAAGH,YAAY,CAAC,CAAC;EAC7B,MAAMI,GAAG,GAAGF,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAIC,MAAM;EAC7B,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAGZ,QAAQ,CAAS;IAAEa,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACjEjB,eAAe,CAAC,MAAM;IACpB,IAAIa,GAAG,CAACK,OAAO,EAAE;MACfL,GAAG,CAACK,OAAO,CAACC,OAAO,CAAC,CAAC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CAAA+D,aAAA,CAACtD,8BAA8B,EAAAuD,QAAA;IAC7B/C,GAAG,EAAEwB,OAAQ;IACbwB,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGxB,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEoB;EAAY,GAClBnB,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","Rea","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","Platform","HAS_REANIMATED_3","useCanvasRef","useReanimatedFrame","useFrameCallback","useCanvasSize","userRef","ourRef","ref","size","setSize","width","height","current","measure","_x","_y","isFabric","Boolean","_global","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","root","runOnUI","undefined","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","onLayoutWeb","e","OS","nativeEvent","layout","value","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n LayoutChangeEvent,\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { HAS_REANIMATED_3 } from \"../external\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst useReanimatedFrame = !HAS_REANIMATED_3 ? () => {} : Rea.useFrameCallback;\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n useReanimatedFrame(() => {\n \"worklet\";\n }, !!onSize);\n useEffect(() => {\n if (onSize) {\n Rea.runOnUI(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n global[`__onSize_${nativeId}`] = onSize;\n })();\n return () => {\n Rea.runOnUI(() => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n delete global[`__onSize_${nativeId}`];\n })();\n };\n }\n return undefined;\n }, [onSize, nativeId]);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n const onLayoutWeb = useCallback(\n (e: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(e);\n }\n if (Platform.OS === \"web\" && onSize) {\n const { width, height } = e.nativeEvent.layout;\n onSize.value = { width, height };\n }\n },\n [onLayout, onSize]\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n onLayout={onLayoutWeb}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SA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9C5B,MAAM,CAAC6B,KAAK,GAAG;QAAE5C,KAAK;QAAEC;MAAO,CAAC;IAClC;EACF,CAAC,EACD,CAACgB,QAAQ,EAAEF,MAAM,CACnB,CAAC;EAED,oBACEvC,KAAA,CAAAqE,aAAA,CAAC3D,8BAA8B,EAAA4D,QAAA;IAC7BjD,GAAG,EAAEwB,OAAQ;IACb0B,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAG1B,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEsB;EAAY,GAClBrB,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
@@ -3,7 +3,7 @@ import type { Server, WebSocket } from "ws";
3
3
  import type * as SkiaExports from "../../index";
4
4
  import type { SkImage, SkFont, Skia, SkCanvas } from "../../skia/types";
5
5
  import { SkiaSGRoot } from "../../sksg/Reconciler";
6
- type TestOS = "ios" | "android" | "web" | "node";
6
+ type TestOS = "ios" | "android" | "web" | "node" | "macos";
7
7
  declare global {
8
8
  var testServer: Server;
9
9
  var testClient: WebSocket;
@@ -3,7 +3,7 @@ export const useSVG = (source, onError) => {
3
3
  if (source === null || source === undefined) {
4
4
  throw new Error(`Invalid svg data source. Got: ${source}`);
5
5
  }
6
- if (typeof source !== "object" || source instanceof Uint8Array || typeof source.default !== "string") {
6
+ if (typeof source !== "object" || source instanceof Uint8Array || !("uri" in source) || typeof source.uri !== "string" || !("default" in source) || typeof source.default !== "string") {
7
7
  throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(source, null, 2)}`);
8
8
  }
9
9
  const svg = Skia.SVG.MakeFromString(source.default);
@@ -1 +1 @@
1
- {"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","Uint8Array","default","JSON","stringify","svg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n if (\n typeof source !== \"object\" ||\n source instanceof Uint8Array ||\n typeof source.default !== \"string\"\n ) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const svg = Skia.SVG.MakeFromString(source.default);\n if (svg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n return svg;\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCH,MAAM,EAAE,CAAC;EAC5D;EACA,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,YAAYI,UAAU,IAC5B,OAAOJ,MAAM,CAACK,OAAO,KAAK,QAAQ,EAClC;IACA,MAAM,IAAIF,KAAK,CACb,iFAAiFG,IAAI,CAACC,SAAS,CAC7FP,MAAM,EACN,IAAI,EACJ,CACF,CAAC,EACH,CAAC;EACH;EACA,MAAMQ,GAAG,GAAGV,IAAI,CAACW,GAAG,CAACC,cAAc,CAACV,MAAM,CAACK,OAAO,CAAC;EACnD,IAAIG,GAAG,KAAK,IAAI,IAAIP,OAAO,KAAKC,SAAS,EAAE;IACzCD,OAAO,CAAC,IAAIE,KAAK,CAAC,mCAAmC,CAAC,CAAC;EACzD;EACA,OAAOK,GAAG;AACZ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Skia","useSVG","source","onError","undefined","Error","Uint8Array","uri","default","JSON","stringify","svg","SVG","MakeFromString"],"sources":["SVG.web.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n if (\n typeof source !== \"object\" ||\n source instanceof Uint8Array ||\n !(\"uri\" in source) ||\n typeof source.uri !== \"string\" ||\n !(\"default\" in source) ||\n typeof source.default !== \"string\"\n ) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const svg = Skia.SVG.MakeFromString(source.default);\n if (svg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n return svg;\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,IAAID,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCH,MAAM,EAAE,CAAC;EAC5D;EACA,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,YAAYI,UAAU,IAC5B,EAAE,KAAK,IAAIJ,MAAM,CAAC,IAClB,OAAOA,MAAM,CAACK,GAAG,KAAK,QAAQ,IAC9B,EAAE,SAAS,IAAIL,MAAM,CAAC,IACtB,OAAOA,MAAM,CAACM,OAAO,KAAK,QAAQ,EAClC;IACA,MAAM,IAAIH,KAAK,CACb,iFAAiFI,IAAI,CAACC,SAAS,CAC7FR,MAAM,EACN,IAAI,EACJ,CACF,CAAC,EACH,CAAC;EACH;EACA,MAAMS,GAAG,GAAGX,IAAI,CAACY,GAAG,CAACC,cAAc,CAACX,MAAM,CAACM,OAAO,CAAC;EACnD,IAAIG,GAAG,KAAK,IAAI,IAAIR,OAAO,KAAKC,SAAS,EAAE;IACzCD,OAAO,CAAC,IAAIE,KAAK,CAAC,mCAAmC,CAAC,CAAC;EACzD;EACA,OAAOM,GAAG;AACZ,CAAC","ignoreList":[]}
@@ -5,7 +5,12 @@ type ESModule = {
5
5
  __esModule: true;
6
6
  default: string;
7
7
  };
8
- export type DataModule = RNModule | ESModule;
8
+ type MetroAsset = {
9
+ uri: string;
10
+ width: number;
11
+ height: number;
12
+ };
13
+ export type DataModule = RNModule | ESModule | MetroAsset;
9
14
  export type DataSource = DataModule | string | Uint8Array;
10
15
  export type DataSourceParam = DataSource | null | undefined;
11
16
  export declare const isRNModule: (mod: DataModule) => mod is RNModule;
@@ -1 +1 @@
1
- {"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype ESModule = {\n __esModule: true;\n default: string;\n};\nexport type DataModule = RNModule | ESModule;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n"],"mappings":"AAaA,OAAO,MAAMA,UAAU,GAAIC,GAAe,IACxC,OAAOA,GAAG,KAAK,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["isRNModule","mod"],"sources":["Data.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkData = SkJSIInstance<\"Data\">;\n\ntype RNModule = number;\ntype ESModule = {\n __esModule: true;\n default: string;\n};\ntype MetroAsset = {\n uri: string;\n width: number;\n height: number;\n};\n\nexport type DataModule = RNModule | ESModule | MetroAsset;\nexport type DataSource = DataModule | string | Uint8Array;\nexport type DataSourceParam = DataSource | null | undefined;\n\nexport const isRNModule = (mod: DataModule): mod is RNModule =>\n typeof mod === \"number\";\n"],"mappings":"AAmBA,OAAO,MAAMA,UAAU,GAAIC,GAAe,IACxC,OAAOA,GAAG,KAAK,QAAQ","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
- import type { Skia, SkSize } from "../skia/types";
1
+ import type { Skia } from "../skia/types";
3
2
  import { StaticContainer } from "./StaticContainer";
4
- export declare const createContainer: (Skia: Skia, nativeId: number, _onSize?: SharedValue<SkSize>) => StaticContainer;
3
+ export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer;
@@ -1,5 +1,5 @@
1
1
  import { StaticContainer } from "./StaticContainer";
2
- export const createContainer = (Skia, nativeId, _onSize) => {
2
+ export const createContainer = (Skia, nativeId) => {
3
3
  return new StaticContainer(Skia, nativeId);
4
4
  };
5
5
  //# sourceMappingURL=Container.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["StaticContainer","createContainer","Skia","nativeId","_onSize"],"sources":["Container.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Skia, SkSize } from \"../skia/types\";\n\nimport { StaticContainer } from \"./StaticContainer\";\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n _onSize?: SharedValue<SkSize>\n) => {\n return new StaticContainer(Skia, nativeId);\n};\n"],"mappings":"AAIA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,IAAU,EACVC,QAAgB,EAChBC,OAA6B,KAC1B;EACH,OAAO,IAAIJ,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;AAC5C,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["StaticContainer","createContainer","Skia","nativeId"],"sources":["Container.ts"],"sourcesContent":["import type { Skia } from \"../skia/types\";\n\nimport { StaticContainer } from \"./StaticContainer\";\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n return new StaticContainer(Skia, nativeId);\n};\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,mBAAmB;AAEnD,OAAO,MAAMC,eAAe,GAAGA,CAACC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,OAAO,IAAIH,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -1,14 +1,12 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
- import type { Skia, SkSize } from "../skia/types";
1
+ import type { Skia } from "../skia/types";
3
2
  import { Container, StaticContainer } from "./StaticContainer";
4
3
  import "../skia/NativeSetup";
5
4
  import "../views/api";
6
5
  declare class NativeReanimatedContainer extends Container {
7
6
  private nativeId;
8
- private onSize?;
9
7
  private mapperId;
10
- constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
8
+ constructor(Skia: Skia, nativeId: number);
11
9
  redraw(): void;
12
10
  }
13
- export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | NativeReanimatedContainer;
11
+ export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | NativeReanimatedContainer;
14
12
  export {};
@@ -8,12 +8,9 @@ import { Container, StaticContainer } from "./StaticContainer";
8
8
  import { visit } from "./Recorder/Visitor";
9
9
  import "../skia/NativeSetup";
10
10
  import "../views/api";
11
- const nativeDrawOnscreen = (nativeId, recorder, onSize) => {
11
+ const nativeDrawOnscreen = (nativeId, recorder) => {
12
12
  "worklet";
13
13
 
14
- if (onSize) {
15
- SkiaViewApi.setJsiProperty(nativeId, "onSize", onSize);
16
- }
17
14
  //const start = performance.now();
18
15
  const picture = recorder.play();
19
16
  //const end = performance.now();
@@ -21,10 +18,9 @@ const nativeDrawOnscreen = (nativeId, recorder, onSize) => {
21
18
  SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
22
19
  };
23
20
  class NativeReanimatedContainer extends Container {
24
- constructor(Skia, nativeId, onSize) {
21
+ constructor(Skia, nativeId) {
25
22
  super(Skia);
26
23
  this.nativeId = nativeId;
27
- this.onSize = onSize;
28
24
  _defineProperty(this, "mapperId", null);
29
25
  }
30
26
  redraw() {
@@ -42,27 +38,24 @@ class NativeReanimatedContainer extends Container {
42
38
  visit(recorder, this.root);
43
39
  const sharedValues = recorder.getSharedValues();
44
40
  const sharedRecorder = recorder.getRecorder();
45
- Rea.runOnUI(onSize => {
41
+ Rea.runOnUI(() => {
46
42
  "worklet";
47
43
 
48
- nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
49
- })(this.onSize);
44
+ nativeDrawOnscreen(nativeId, sharedRecorder);
45
+ })();
50
46
  if (sharedValues.length > 0) {
51
- const {
52
- onSize
53
- } = this;
54
47
  this.mapperId = Rea.startMapper(() => {
55
48
  "worklet";
56
49
 
57
50
  sharedRecorder.applyUpdates(sharedValues);
58
- nativeDrawOnscreen(nativeId, sharedRecorder, onSize);
51
+ nativeDrawOnscreen(nativeId, sharedRecorder);
59
52
  }, sharedValues);
60
53
  }
61
54
  }
62
55
  }
63
- export const createContainer = (Skia, nativeId, onSize) => {
56
+ export const createContainer = (Skia, nativeId) => {
64
57
  if (HAS_REANIMATED_3 && nativeId !== -1) {
65
- return new NativeReanimatedContainer(Skia, nativeId, onSize);
58
+ return new NativeReanimatedContainer(Skia, nativeId);
66
59
  } else {
67
60
  return new StaticContainer(Skia, nativeId);
68
61
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","nativeDrawOnscreen","nativeId","recorder","onSize","SkiaViewApi","setJsiProperty","picture","play","NativeReanimatedContainer","constructor","Skia","_defineProperty","redraw","mapperId","stopMapper","unmounted","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer"],"sources":["Container.native.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkSize } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n if (onSize) {\n SkiaViewApi.setJsiProperty(nativeId, \"onSize\", onSize);\n }\n //const start = performance.now();\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n })(this.onSize);\n if (sharedValues.length > 0) {\n const { onSize } = this;\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, onSize);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId, onSize);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAEA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAC9D,SAASC,KAAK,QAAQ,oBAAoB;AAE1C,OAAO,qBAAqB;AAC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C,IAAI,CAACA,MAAM,CAAC;IACf,IAAIc,YAAY,CAACK,MAAM,GAAG,CAAC,EAAE;MAC3B,MAAM;QAAEnB;MAAO,CAAC,GAAG,IAAI;MACvB,IAAI,CAACU,QAAQ,GAAGnB,GAAG,CAAC6B,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTJ,cAAc,CAACK,YAAY,CAACP,YAAY,CAAC;QACzCjB,kBAAkB,CAACC,QAAQ,EAAEkB,cAAc,EAAEhB,MAAM,CAAC;MACtD,CAAC,EAAEc,YAAY,CAAC;IAClB;EACF;AACF;AAEA,OAAO,MAAMQ,eAAe,GAAGA,CAC7Bf,IAAU,EACVT,QAAgB,EAChBE,MAA4B,KACzB;EACH,IAAIR,gBAAgB,IAAIM,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIO,yBAAyB,CAACE,IAAI,EAAET,QAAQ,EAAEE,MAAM,CAAC;EAC9D,CAAC,MAAM;IACL,OAAO,IAAIL,eAAe,CAACY,IAAI,EAAET,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Rea","HAS_REANIMATED_3","ReanimatedRecorder","Container","StaticContainer","visit","nativeDrawOnscreen","nativeId","recorder","picture","play","SkiaViewApi","setJsiProperty","NativeReanimatedContainer","constructor","Skia","_defineProperty","redraw","mapperId","stopMapper","unmounted","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst nativeDrawOnscreen = (nativeId: number, recorder: JsiRecorder) => {\n \"worklet\";\n\n //const start = performance.now();\n const picture = recorder.play();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, private nativeId: number) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder);\n })();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC,kBAAkB,QAAQ,+BAA+B;AAClE,SAASC,SAAS,EAAEC,eAAe,QAAQ,mBAAmB;AAC9D,SAASC,KAAK,QAAQ,oBAAoB;AAE1C,OAAO,qBAAqB;AAC5B,OAAO,cAAc;AAErB,MAAMC,kBAAkB,GAAGA,CAACC,QAAgB,EAAEC,QAAqB,KAAK;EACtE,SAAS;;EAET;EACA,MAAMC,OAAO,GAAGD,QAAQ,CAACE,IAAI,CAAC,CAAC;EAC/B;EACA;EACAC,WAAW,CAACC,cAAc,CAACL,QAAQ,EAAE,SAAS,EAAEE,OA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,OAAO,IAAIM,yBAAyB,CAACE,IAAI,EAAER,QAAQ,CAAC;EACtD,CAAC,MAAM;IACL,OAAO,IAAIH,eAAe,CAACW,IAAI,EAAER,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
- import type { Skia, SkSize } from "../skia/types";
1
+ import type { Skia } from "../skia/types";
3
2
  import { Container, StaticContainer } from "./StaticContainer";
4
3
  import "../skia/NativeSetup";
5
4
  import "../views/api";
@@ -9,5 +8,5 @@ declare class ReanimatedContainer extends Container {
9
8
  constructor(Skia: Skia, nativeId: number);
10
9
  redraw(): void;
11
10
  }
12
- export declare const createContainer: (Skia: Skia, nativeId: number, _onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer;
11
+ export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | ReanimatedContainer;
13
12
  export {};
@@ -66,7 +66,7 @@ class ReanimatedContainer extends Container {
66
66
  })();
67
67
  }
68
68
  }
69
- export const createContainer = (Skia, nativeId, _onSize) => {
69
+ export const createContainer = (Skia, nativeId) => {
70
70
  if (HAS_REANIMATED_3 && nativeId !== -1) {
71
71
  return new ReanimatedContainer(Skia, nativeId);
72
72
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","redraw","mapperId","stopMapper","unmounted","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer","_onSize"],"sources":["Container.web.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkSize } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, private nativeId: number) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n _onSize?: SharedValue<SkSize>\n) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAEA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAGvE,SAASC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C,MAAM,GAAGF,QAAQ,CAACG,YAAY,CAAC,CAAC;IACtC,MAAM;MAAEC;IAAgB,CAAC,GAAGF,MAAM;IAClC,IAAI,CAACrB,SAAS,GAAG;MACfO,QAAQ,EAAEc,MAAM,CAACd,QAAQ;MACzBD,SAAS,EAAEe,MAAM,CAACf;IACpB,CAAC;IACD,MAAM;MAAEP,QAAQ;MAAED,IAAI;MAAEE;IAAU,CAAC,GAAG,IAAI;IAC1C,IAAIuB,eAAe,CAACC,IAAI,GAAG,CAAC,EAAE;MAC5B,IAAI,CAACR,QAAQ,GAAG3B,GAAG,CAACoC,WAAW,CAAC,MAAM;QACpC,SAAS;;QACT5B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAE0B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACAlC,GAAG,CAACuC,OAAO,CAAC,MAAM;MAChB,SAAS;;MACT/B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAM6B,eAAe,GAAGA,CAC7B/B,IAAU,EACVC,QAAgB,EAChB+B,OAA6B,KAC1B;EACH,IAAIxC,gBAAgB,IAAIS,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIa,mBAAmB,CAACd,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIH,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Rea","HAS_REANIMATED_3","Recorder","visit","replay","createDrawingContext","Container","StaticContainer","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","ReanimatedContainer","constructor","_defineProperty","redraw","mapperId","stopMapper","unmounted","recorder","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, private nativeId: number) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else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ACF;IACA,MAAMC,QAAQ,GAAG,IAAI5B,QAAQ,CAAC,CAAC;IAC/BC,KAAK,CAAC2B,QAAQ,EAAE,IAAI,CAACC,IAAI,CAAC;IAC1B,MAAMC,MAAM,GAAGF,QAAQ,CAACG,YAAY,CAAC,CAAC;IACtC,MAAM;MAAEC;IAAgB,CAAC,GAAGF,MAAM;IAClC,IAAI,CAACrB,SAAS,GAAG;MACfO,QAAQ,EAAEc,MAAM,CAACd,QAAQ;MACzBD,SAAS,EAAEe,MAAM,CAACf;IACpB,CAAC;IACD,MAAM;MAAEP,QAAQ;MAAED,IAAI;MAAEE;IAAU,CAAC,GAAG,IAAI;IAC1C,IAAIuB,eAAe,CAACC,IAAI,GAAG,CAAC,EAAE;MAC5B,IAAI,CAACR,QAAQ,GAAG3B,GAAG,CAACoC,WAAW,CAAC,MAAM;QACpC,SAAS;;QACT5B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAE0B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACAlC,GAAG,CAACuC,OAAO,CAAC,MAAM;MAChB,SAAS;;MACT/B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAM6B,eAAe,GAAGA,CAAC/B,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIT,gBAAgB,IAAIS,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIa,mBAAmB,CAACd,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIH,eAAe,CAACE,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
@@ -1,13 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
- import type { SharedValue } from "react-native-reanimated";
3
- import type { SkCanvas, Skia, SkSize } from "../skia/types";
2
+ import type { SkCanvas, Skia } from "../skia/types";
4
3
  import { NodeType } from "../dom/types";
5
4
  import "./Elements";
6
5
  export declare class SkiaSGRoot {
7
6
  Skia: Skia;
8
7
  private root;
9
8
  private container;
10
- constructor(Skia: Skia, nativeId?: number, onSize?: SharedValue<SkSize>);
9
+ constructor(Skia: Skia, nativeId?: number);
11
10
  get sg(): {
12
11
  type: NodeType;
13
12
  props: {};
@@ -13,11 +13,11 @@ skiaReconciler.injectIntoDevTools({
13
13
  rendererPackageName: "react-native-skia"
14
14
  });
15
15
  export class SkiaSGRoot {
16
- constructor(Skia, nativeId = -1, onSize) {
16
+ constructor(Skia, nativeId = -1) {
17
17
  this.Skia = Skia;
18
18
  _defineProperty(this, "root", void 0);
19
19
  _defineProperty(this, "container", void 0);
20
- this.container = createContainer(Skia, nativeId, onSize);
20
+ this.container = createContainer(Skia, nativeId);
21
21
  this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
22
22
  }
23
23
  get sg() {
@@ -1 +1 @@
1
- {"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","onSize","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","updateContainer","element","Promise","resolve","render","mount","redraw","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport type { SharedValue } from \"react-native-reanimated\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia, SkSize } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./StaticContainer\";\nimport { createContainer } from \"./Container\";\n\nimport \"./Elements\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1, onSize?: SharedValue<SkSize>) {\n this.container = createContainer(Skia, nativeId, onSize);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n private updateContainer(element: ReactNode) {\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n debug(\"updateContainer\");\n resolve(true);\n });\n });\n }\n\n async render(element: ReactNode) {\n this.container.mount();\n await this.updateContainer(element);\n this.container.redraw();\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmount();\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n resolve(true);\n });\n });\n }\n}\n"],"mappings":";;;AAGA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AAEpD,SAASC,eAAe,QAAQ,aAAa;AAE7C,OAAO,YAAY;AAEnB,MAAMC,cAAc,GAAGL,eAAe,CAACG,cAAc,CAAC;AAEtDE,cAAc,CAACC,kBAAkB,CAAC;EAChCC,UAAU,EAAE,CAAC;EACbC,OAAO,EAAE,OAAO;EAChBC,mBAAmB,EAAE;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAAQC,IAAU,EAAEC,QAAQ,GAAG,CAAC,CAAC,EAA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5C,MAAMH,MAAM,GAAGE,QAAQ,CAACE,cAAc,CAAC,CAAC;IACxC,IAAI,CAACL,YAAY,CAACC,MAAM,CAAC;IACzB,OAAOE,QAAQ,CAACG,wBAAwB,CAAC,CAAC;EAC5C;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACxB,SAAS,CAACwB,OAAO,CAAC,CAAC;IACxB,OAAO,IAAIZ,OAAO,CAAEC,OAAO,IAAK;MAC9BxB,cAAc,CAACqB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACT,IAAI,EAAE,IAAI,EAAE,MAAM;QAC1Df,KAAK,CAAC,kBAAkB,CAAC;QACzB2B,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
1
+ {"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","updateContainer","element","Promise","resolve","render","mount","redraw","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./StaticContainer\";\nimport { createContainer } from \"./Container\";\n\nimport \"./Elements\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n private updateContainer(element: ReactNode) {\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n debug(\"updateContainer\");\n resolve(true);\n });\n });\n }\n\n async render(element: ReactNode) {\n this.container.mount();\n await this.updateContainer(element);\n this.container.redraw();\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmount();\n return new Promise((resolve) => {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n resolve(true);\n });\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AAEpD,SAASC,eAAe,QAAQ,aAAa;AAE7C,OAAO,YAAY;AAEnB,MAAMC,cAAc,GAAGL,eAAe,CAACG,cAAc,CAAC;AAEtDE,cAAc,CAACC,kBAAkB,CAAC;EAChCC,UAAU,EAAE,CAAC;EACbC,OAAO,EAAE,OAAO;EAChBC,mBAAmB,EAAE;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,UAAU,CAAC;EAItBC,WAAWA,CAAQC,IAAU,EAAEC,QAAQ,GAAG,CAAC,CAAC,EAAE;IAAA,KAA3BD,IAAU,GAAVA,IAAU;IAAAE,eAAA;IAAAA,eAAA;IAC3B,IAAI,CAACC,SAAS,GAAGX,eAAe,CAACQ,IAAI,EAAEC,QAAQ,CAAC;IAChD,IAAI,CAACG,IAAI,GAAGX,cAAc,CAACD,eAAe,CACxC,IAAI,CAAC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IACxB,OAAO,IAAIZ,OAAO,CAAEC,OAAO,IAAK;MAC9BvB,cAAc,CAACoB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACT,IAAI,EAAE,IAAI,EAAE,MAAM;QAC1Dd,KAAK,CAAC,kBAAkB,CAAC;QACzB0B,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  export const __esModule: boolean;
2
- export function createContainer(Skia: any, nativeId: any, _onSize: any): _StaticContainer.StaticContainer;
2
+ export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer;
3
3
  import _StaticContainer = require("./StaticContainer");
@@ -1,10 +1,9 @@
1
1
  export const __esModule: boolean;
2
- export function createContainer(Skia: any, nativeId: any, onSize: any): _StaticContainer.StaticContainer | NativeReanimatedContainer;
2
+ export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer | NativeReanimatedContainer;
3
3
  import _StaticContainer = require("./StaticContainer");
4
4
  declare class NativeReanimatedContainer extends _StaticContainer.Container {
5
- constructor(Skia: any, nativeId: any, onSize: any);
5
+ constructor(Skia: any, nativeId: any);
6
6
  nativeId: any;
7
- onSize: any;
8
7
  redraw(): void;
9
8
  mapperId: any;
10
9
  }
@@ -1,5 +1,5 @@
1
1
  export const __esModule: boolean;
2
- export function createContainer(Skia: any, nativeId: any, _onSize: any): _StaticContainer.StaticContainer | ReanimatedContainer;
2
+ export function createContainer(Skia: any, nativeId: any): _StaticContainer.StaticContainer | ReanimatedContainer;
3
3
  import _StaticContainer = require("./StaticContainer");
4
4
  declare class ReanimatedContainer extends _StaticContainer.Container {
5
5
  constructor(Skia: any, nativeId: any);
@@ -1,6 +1,6 @@
1
1
  export const __esModule: boolean;
2
2
  export class SkiaSGRoot {
3
- constructor(Skia: any, nativeId: number | undefined, onSize: any);
3
+ constructor(Skia: any, nativeId?: number);
4
4
  Skia: any;
5
5
  container: import("./StaticContainer").StaticContainer;
6
6
  root: any;
@@ -1,2 +1,2 @@
1
- export function createContainer(Skia: any, nativeId: any, _onSize: any): StaticContainer;
1
+ export function createContainer(Skia: any, nativeId: any): StaticContainer;
2
2
  import { StaticContainer } from "./StaticContainer";
@@ -1,9 +1,8 @@
1
- export function createContainer(Skia: any, nativeId: any, onSize: any): StaticContainer | NativeReanimatedContainer;
1
+ export function createContainer(Skia: any, nativeId: any): StaticContainer | NativeReanimatedContainer;
2
2
  import { StaticContainer } from "./StaticContainer";
3
3
  declare class NativeReanimatedContainer extends Container {
4
- constructor(Skia: any, nativeId: any, onSize: any);
4
+ constructor(Skia: any, nativeId: any);
5
5
  nativeId: any;
6
- onSize: any;
7
6
  redraw(): void;
8
7
  mapperId: any;
9
8
  }
@@ -1,4 +1,4 @@
1
- export function createContainer(Skia: any, nativeId: any, _onSize: any): StaticContainer | ReanimatedContainer;
1
+ export function createContainer(Skia: any, nativeId: any): StaticContainer | ReanimatedContainer;
2
2
  import { StaticContainer } from "./StaticContainer";
3
3
  declare class ReanimatedContainer extends Container {
4
4
  constructor(Skia: any, nativeId: any);
@@ -1,5 +1,5 @@
1
1
  export class SkiaSGRoot {
2
- constructor(Skia: any, nativeId: number | undefined, onSize: any);
2
+ constructor(Skia: any, nativeId?: number);
3
3
  Skia: any;
4
4
  container: import("./StaticContainer").StaticContainer;
5
5
  root: any;
@@ -2,7 +2,7 @@ import type { Server, WebSocket } from "ws";
2
2
  declare global {
3
3
  var testServer: Server;
4
4
  var testClient: WebSocket;
5
- var testOS: "ios" | "android" | "web" | "node";
5
+ var testOS: "ios" | "android" | "web" | "node" | "macos";
6
6
  var testArch: "paper" | "fabric";
7
7
  }
8
8
  declare const globalSetup: () => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { FC, RefObject } from "react";
2
2
  import React from "react";
3
3
  import type { MeasureInWindowOnSuccessCallback, MeasureOnSuccessCallback, ViewProps } from "react-native";
4
- import { type SharedValue } from "react-native-reanimated";
4
+ import type { SharedValue } from "react-native-reanimated";
5
5
  import type { SkImage, SkRect, SkSize } from "../skia/types";
6
6
  export interface CanvasRef extends FC<CanvasProps> {
7
7
  makeImageSnapshot(rect?: SkRect): SkImage;
@@ -3,7 +3,7 @@ import type { Server, WebSocket } from "ws";
3
3
  import type * as SkiaExports from "../../index";
4
4
  import type { SkImage, SkFont, Skia, SkCanvas } from "../../skia/types";
5
5
  import { SkiaSGRoot } from "../../sksg/Reconciler";
6
- type TestOS = "ios" | "android" | "web" | "node";
6
+ type TestOS = "ios" | "android" | "web" | "node" | "macos";
7
7
  declare global {
8
8
  var testServer: Server;
9
9
  var testClient: WebSocket;
@@ -5,7 +5,12 @@ type ESModule = {
5
5
  __esModule: true;
6
6
  default: string;
7
7
  };
8
- export type DataModule = RNModule | ESModule;
8
+ type MetroAsset = {
9
+ uri: string;
10
+ width: number;
11
+ height: number;
12
+ };
13
+ export type DataModule = RNModule | ESModule | MetroAsset;
9
14
  export type DataSource = DataModule | string | Uint8Array;
10
15
  export type DataSourceParam = DataSource | null | undefined;
11
16
  export declare const isRNModule: (mod: DataModule) => mod is RNModule;
@@ -1,4 +1,3 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
- import type { Skia, SkSize } from "../skia/types";
1
+ import type { Skia } from "../skia/types";
3
2
  import { StaticContainer } from "./StaticContainer";
4
- export declare const createContainer: (Skia: Skia, nativeId: number, _onSize?: SharedValue<SkSize>) => StaticContainer;
3
+ export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer;