@shopify/react-native-skia 1.11.9 → 1.11.11

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.
@@ -55,7 +55,7 @@ const Canvas = exports.Canvas = /*#__PURE__*/(0, _react.forwardRef)(({
55
55
  const root = (0, _react.useMemo)(() => new _Reconciler.SkiaSGRoot(_skia.Skia, nativeId), [nativeId]);
56
56
 
57
57
  // Render effects
58
- (0, _react.useEffect)(() => {
58
+ (0, _react.useLayoutEffect)(() => {
59
59
  root.render(children);
60
60
  }, [children, root]);
61
61
  (0, _react.useEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","NativeSkiaPictureView","SkiaPictureViewNativeComponent","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useEffect","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } 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 type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\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 // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\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 }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAA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QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfZ,QAAQ,EAAEA;EAAS,GACfgB,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","NativeSkiaPictureView","SkiaPictureViewNativeComponent","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useLayoutEffect","render","useEffect","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } 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 type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\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 // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\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 }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAYA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAA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return {
103
103
  type: instance.type,
104
- props: newProps,
104
+ props: {
105
+ ...newProps
106
+ },
105
107
  children: keepChildren ? [...instance.children] : []
106
108
  };
107
109
  },
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","_typeddash","DEBUG","debug","args","console","log","exports","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","shallowEq","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: newProps,\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AALA;;AAUA,MAAME,KAAK,GAAG,KAAK;AACZ,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AA+BK,MAAMK,cAA8B,GAAAD,OAAA,CAAAC,cAAA,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,KAAK;EACxB;EACAC,eAAe,EAAEC,UAAU;EAC3BC,aAAa,EAAEC,YAAY;EAC3BC,SAAS,EAAE,CAAC,CAAC;EAEbC,kBAAkB,EAAGC,sBAAiC,IAAK;IACzDhB,KAAK,CAAC,oBAAoB,CAAC;IAC3B,OAAO,IAAI;EACb,CAAC;EAEDiB,mBAAmBA,CAACC,kBAAkB,EAAEC,KAAK,EAAEH,sBAAsB,EAAE;IACrEhB,KAAK,CAAC,qBAAqB,CAAC;IAC5B,OAAO,IAAI;EACb,CAAC;EAEDoB,oBAAoBA,CAACD,KAAK,EAAEE,MAAM,EAAE;IAClC,OAAO,KAAK;EACd,CAAC;EAEDC,kBAAkBA,CAChBC,KAAK,EACLP,sBAAsB,EACtBQ,YAAY,EACZC,uBAAuB,EACvB;IACAzB,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,MAAM,IAAI0B,KAAK,CAAC,kCAAkC,CAAC;EACrD,CAAC;EAEDC,cAAc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,IAAI0B,KAAK,CAAC,sBAAsB,CAAC;EACzC,CAAC;EAED6C,uBAAuBA,CAACnB,SAAmB,EAAE7B,KAAa,EAAgB;IACxEvB,KAAK,CAAC,yBAAyB,CAAC;IAChC,MAAM,IAAI0B,KAAK,CAAC,sBAAsB,CAAC;EACzC,CAAC;EACD;EACA8C,uBAAuB,EAAEA,CAAA,KAAMC,+BAAoB;EACnDC,wBAAwB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClCC,uBAAuB,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjCC,qBAAqB,EAAGC,KAAe,IAAK,CAAC,CAAC;EAC9CC,mBAAmB,EAAE,SAAAA,CAAUD,KAAK,EAA4B;IAC9D,MAAM,IAAInD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDqD,kBAAkB,EAAE,SAAAA,CAAUC,cAAc,EAAE5B,SAAS,EAAQ;IAC7D,MAAM,IAAI1B,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDuD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAItD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_constants","require","_typeddash","DEBUG","debug","args","console","log","exports","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","shallowEq","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: { ...newProps },\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AALA;;AAUA,MAAME,KAAK,GAAG,KAAK;AACZ,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AA+BK,MAAMK,cAA8B,GAAAD,OAAA,CAAAC,cAAA,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EA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AAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDuD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAItD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  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); }
2
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
2
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from "react";
3
3
  import { SkiaViewNativeId } from "../views/SkiaViewNativeId";
4
4
  import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
5
5
  import { SkiaSGRoot } from "../sksg/Reconciler";
@@ -45,7 +45,7 @@ export const Canvas = /*#__PURE__*/forwardRef(({
45
45
  const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);
46
46
 
47
47
  // Render effects
48
- useEffect(() => {
48
+ useLayoutEffect(() => {
49
49
  root.render(children);
50
50
  }, [children, root]);
51
51
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","NativeSkiaPictureView","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","current","root","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } 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 type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\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 // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\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 }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";AACA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAId,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAU9B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAML,MAAM,CAAY,IAAI,CAAC;AAEzD,MAAMM,qBAAqB,GAAGJ,8BAA8B;;AAE5D;AACA,MAAMK,cAAc,GAAGA,CACrBC,WAAwC,EACxCC,QAA6C,KAC1C;EACH,OAAOb,WAAW,CACfc,KAAwB,IAAK;IAC5B,IAAID,QAAQ,EAAE;MACZA,QAAQ,CAACC,KAAK,CAAC;IACjB;IACA,MAAM;MAAEC,KAAK;M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aAAa,CAAC,CAAC;MACjB;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACX,QAAQ,EAAEH,IAAI,EAAEW,IAAI,CAAC,CAAC;EAE1B/B,SAAS,CAAC,MAAM;IACd,IAAIoB,IAAI,KAAK,YAAY,EAAE;MACzBgB,OAAO,CAACC,IAAI,CAAC,gDAAgD,CAAC;MAC9DH,aAAa,CAAC,CAAC;IACjB;IACA,OAAO,MAAM;MACX,IAAIN,KAAK,CAACE,OAAO,KAAK,IAAI,EAAE;QAC1BQ,oBAAoB,CAACV,KAAK,CAACE,OAAO,CAAC;MACrC;IACF,CAAC;EACH,CAAC,EAAE,CAACV,IAAI,EAAEc,aAAa,CAAC,CAAC;EACzB;EACAjC,mBAAmB,CAAC0B,GAAG,EAAE,OAAO;IAC9BY,iBAAiB,EAAGC,IAAa,IAAK;MACpC,OAAOC,WAAW,CAACF,iBAAiB,CAACV,QAAQ,EAAEW,IAAI,CAAC;IACtD,CAAC;IACDE,sBAAsB,EAAGF,IAAa,IAAK;MACzC,OAAOC,WAAW,CAACC,sBAAsB,CAACb,QAAQ,EAAEW,IAAI,CAAC;IAC3D,CAAC;IACDG,MAAM,EAAEA,CAAA,KAAM;MACZF,WAAW,CAACP,aAAa,CAACL,QAAQ,CAAC;IACrC,CAAC;IACDe,WAAW,EAAEA,CAAA,KAAM;MACjB,OAAOf,QAAQ;IACjB;EACF,CAAC,CAAC,CAAC;EACH,oBACEhC,KAAA,CAAAgD,aAAA,CAACpC,qBAAqB,EAAAqC,QAAA;IACpBC,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGnB,QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfV,QAAQ,EAAEA;EAAS,GACfc,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","NativeSkiaPictureView","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","current","root","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } 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 type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\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 // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\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 }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";AACA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,QACD,OAAO;AAId,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC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B;EACF,CAAC,CAAC,CAAC;EACH,oBACEjC,KAAA,CAAAiD,aAAA,CAACpC,qBAAqB,EAAAqC,QAAA;IACpBC,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGnB,QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfV,QAAQ,EAAEA;EAAS,GACfc,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
@@ -94,7 +94,9 @@ export const sksgHostConfig = {
94
94
  debug("cloneInstance");
95
95
  return {
96
96
  type: instance.type,
97
- props: newProps,
97
+ props: {
98
+ ...newProps
99
+ },
98
100
  children: keepChildren ? [...instance.children] : []
99
101
  };
100
102
  },
@@ -1 +1 @@
1
- {"version":3,"names":["DefaultEventPriority","shallowEq","DEBUG","debug","args","console","log","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: newProps,\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ,4BAA4B;AAGjE,SAASC,SAAS,QAAQ,uBAAuB;AAKjD,MAAMC,KAAK,GAAG,KAAK;AACnB,OAAO,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AA+BD,OAAO,MAAMG,cAA8B,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,KAAK;EACxB;EACAC,eAAe,EAAEC,UAAU;EAC3BC,aAAa,EAAEC,YAAY;EAC3BC,SAAS,EAAE,CAAC,CAAC;EAEbC,kBAAkB,EAAGC,sBAAiC,IAAK;IACzDf,KAAK,CAAC,oBAAoB,CAAC;IAC3B,OAAO,IAAI;EACb,CAAC;EAEDgB,mBAAmBA,CAACC,kBAAkB,EAAEC,KAAK,EAAEH,sBAAsB,EAAE;IACrEf,KAAK,CAAC,qBAAqB,CAAC;IAC5B,OAAO,IAAI;EACb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C,SAAS,CAACyB,IAAI,GAAGD,WAAW;EAC9B,CAAC;EAEDE,wBAAwBA,CAAC1B,SAAoB,EAAEwB,WAAqB,EAAE;IACpExB,SAAS,CAACyB,IAAI,GAAGD,WAAW;EAC9B,CAAC;EAEDG,mBAAmBA,CACjBjB,SAAmB,EACnBjC,KAAa,EACbE,MAAa,EACH;IACVpB,KAAK,CAAC,qBAAqB,CAAC;IAC5B,MAAM,IAAIyB,KAAK,CAAC,sBAAsB,CAAC;EACzC,CAAC;EAED4C,uBAAuBA,CAAClB,SAAmB,EAAE7B,KAAa,EAAgB;IACxEtB,KAAK,CAAC,yBAAyB,CAAC;IAChC,MAAM,IAAIyB,KAAK,CAAC,sBAAsB,CAAC;EACzC,CAAC;EACD;EACA6C,uBAAuB,EAAEA,CAAA,KAAMzE,oBAAoB;EACnD0E,wBAAwB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClCC,uBAAuB,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjCC,qBAAqB,EAAGC,KAAe,IAAK,CAAC,CAAC;EAC9CC,mBAAmB,EAAE,SAAAA,CAAUD,KAAK,EAA4B;IAC9D,MAAM,IAAIjD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDmD,kBAAkB,EAAE,SAAAA,CAAUC,cAAc,EAAE1B,SAAS,EAAQ;IAC7D,MAAM,IAAI1B,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDqD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAIpD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DefaultEventPriority","shallowEq","DEBUG","debug","args","console","log","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","preparePortalMount","cloneInstance","_updatePayload","_oldProps","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return null;\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return null;\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _updatePayload,\n _type,\n _oldProps,\n newProps,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n\n return {\n type: instance.type,\n props: { ...newProps },\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n};\n"],"mappings":"AAAA;;AAEA,SAASA,oBAAoB,QAAQ,4BAA4B;AAGjE,SAASC,SAAS,QAAQ,uBAAuB;AAKjD,MAAMC,KAAK,GAAG,KAAK;AACnB,OAAO,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,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,mBAAmB,EAAE,SAAAA,CAAUD,KAAK,EAA4B;IAC9D,MAAM,IAAIjD,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDmD,kBAAkB,EAAE,SAAAA,CAAUC,cAAc,EAAE1B,SAAS,EAAQ;IAC7D,MAAM,IAAI1B,KAAK,CAAC,2BAA2B,CAAC;EAC9C,CAAC;EACDqD,oBAAoB,EAAE,SAAAA,CAAUD,cAAc,EAAmB;IAC/D,MAAM,IAAIpD,KAAK,CAAC,2BAA2B,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "./scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "1.11.9",
11
+ "version": "1.11.11",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -4,6 +4,7 @@ import React, {
4
4
  useCallback,
5
5
  useEffect,
6
6
  useImperativeHandle,
7
+ useLayoutEffect,
7
8
  useMemo,
8
9
  useRef,
9
10
  } from "react";
@@ -79,7 +80,7 @@ export const Canvas = forwardRef(
79
80
  const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);
80
81
 
81
82
  // Render effects
82
- useEffect(() => {
83
+ useLayoutEffect(() => {
83
84
  root.render(children);
84
85
  }, [children, root]);
85
86
 
@@ -181,7 +181,7 @@ export const sksgHostConfig: SkiaHostConfig = {
181
181
 
182
182
  return {
183
183
  type: instance.type,
184
- props: newProps,
184
+ props: { ...newProps },
185
185
  children: keepChildren ? [...instance.children] : [],
186
186
  };
187
187
  },