@shopify/react-native-skia 0.1.116 → 0.1.120
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkApi.h +13 -9
- package/cpp/api/JsiSkCanvas.h +9 -1
- package/cpp/api/JsiSkPicture.h +71 -0
- package/cpp/api/JsiSkPictureFactory.h +50 -0
- package/cpp/api/JsiSkPictureRecorder.h +53 -0
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +3 -6
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -4
- package/ios/RNSkia-iOS/SkiaDrawView.mm +3 -2
- package/lib/commonjs/renderer/Canvas.js +22 -36
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +3 -25
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/components/{Defs.js → Drawing.js} +13 -12
- package/lib/commonjs/renderer/components/Drawing.js.map +1 -0
- package/lib/commonjs/renderer/components/Group.js +7 -4
- package/lib/commonjs/renderer/components/Group.js.map +1 -1
- package/lib/commonjs/renderer/components/Paint.js +1 -21
- package/lib/commonjs/renderer/components/Paint.js.map +1 -1
- package/lib/commonjs/renderer/components/Picture.js +35 -0
- package/lib/commonjs/renderer/components/Picture.js.map +1 -0
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +5 -34
- package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +19 -8
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -0
- package/lib/commonjs/renderer/components/imageFilters/index.js +4 -17
- package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/commonjs/renderer/components/index.js +17 -4
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/renderer/components/maskFilters/Blur.js +1 -1
- package/lib/commonjs/renderer/components/maskFilters/Blur.js.map +1 -1
- package/lib/commonjs/renderer/components/shapes/Box.js +126 -0
- package/lib/commonjs/renderer/components/shapes/Box.js.map +1 -0
- package/lib/commonjs/renderer/components/shapes/index.js +13 -0
- package/lib/commonjs/renderer/components/shapes/index.js.map +1 -1
- package/lib/commonjs/renderer/index.js +13 -0
- package/lib/commonjs/renderer/index.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Declaration.js +12 -1
- package/lib/commonjs/renderer/nodes/Declaration.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Drawing.js +9 -24
- package/lib/commonjs/renderer/nodes/Drawing.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Node.js +9 -16
- package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
- package/lib/commonjs/renderer/processors/Paint.js +24 -26
- package/lib/commonjs/renderer/processors/Paint.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Math.js +19 -1
- package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
- package/lib/commonjs/renderer/processors/math/Matrix3.js +11 -5
- package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/commonjs/renderer/typeddash.js +26 -2
- package/lib/commonjs/renderer/typeddash.js.map +1 -1
- package/lib/commonjs/renderer/useContextBridge.js +35 -0
- package/lib/commonjs/renderer/useContextBridge.js.map +1 -0
- package/lib/commonjs/skia/Canvas.js.map +1 -1
- package/lib/commonjs/skia/Picture/Picture.js +6 -0
- package/lib/commonjs/skia/Picture/Picture.js.map +1 -0
- package/lib/commonjs/skia/Picture/PictureFactory.js +6 -0
- package/lib/commonjs/skia/Picture/PictureFactory.js.map +1 -0
- package/lib/commonjs/skia/Picture/PictureRecorder.js +6 -0
- package/lib/commonjs/skia/Picture/PictureRecorder.js.map +1 -0
- package/lib/commonjs/skia/Picture/index.js +58 -0
- package/lib/commonjs/skia/Picture/index.js.map +1 -0
- package/lib/commonjs/skia/Picture/usePicture.js +30 -0
- package/lib/commonjs/skia/Picture/usePicture.js.map +1 -0
- package/lib/commonjs/skia/Skia.js +2 -0
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/commonjs/skia/index.js +14 -0
- package/lib/commonjs/skia/index.js.map +1 -1
- package/lib/commonjs/values/hooks/useDerivedValue.js +2 -2
- package/lib/commonjs/values/hooks/useDerivedValue.js.map +1 -1
- package/lib/commonjs/views/SkiaView.js +6 -5
- package/lib/commonjs/views/SkiaView.js.map +1 -1
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/renderer/Canvas.js +20 -32
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +2 -24
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/components/Drawing.js +17 -0
- package/lib/module/renderer/components/Drawing.js.map +1 -0
- package/lib/module/renderer/components/Group.js +8 -6
- package/lib/module/renderer/components/Group.js.map +1 -1
- package/lib/module/renderer/components/Paint.js +2 -22
- package/lib/module/renderer/components/Paint.js.map +1 -1
- package/lib/module/renderer/components/Picture.js +21 -0
- package/lib/module/renderer/components/Picture.js.map +1 -0
- package/lib/module/renderer/components/imageFilters/InnerShadow.js +4 -26
- package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/{DropShadow.js → Shadow.js} +16 -6
- package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -0
- package/lib/module/renderer/components/imageFilters/index.js +1 -2
- package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
- package/lib/module/renderer/components/index.js +2 -1
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/renderer/components/maskFilters/Blur.js +1 -1
- package/lib/module/renderer/components/maskFilters/Blur.js.map +1 -1
- package/lib/module/renderer/components/shapes/Box.js +102 -0
- package/lib/module/renderer/components/shapes/Box.js.map +1 -0
- package/lib/module/renderer/components/shapes/index.js +1 -0
- package/lib/module/renderer/components/shapes/index.js.map +1 -1
- package/lib/module/renderer/index.js +1 -0
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/module/renderer/nodes/Declaration.js +4 -0
- package/lib/module/renderer/nodes/Declaration.js.map +1 -1
- package/lib/module/renderer/nodes/Drawing.js +8 -21
- package/lib/module/renderer/nodes/Drawing.js.map +1 -1
- package/lib/module/renderer/nodes/Node.js +9 -15
- package/lib/module/renderer/nodes/Node.js.map +1 -1
- package/lib/module/renderer/processors/Paint.js +22 -21
- package/lib/module/renderer/processors/Paint.js.map +1 -1
- package/lib/module/renderer/processors/math/Math.js +15 -0
- package/lib/module/renderer/processors/math/Math.js.map +1 -1
- package/lib/module/renderer/processors/math/Matrix3.js +6 -2
- package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
- package/lib/module/renderer/typeddash.js +21 -0
- package/lib/module/renderer/typeddash.js.map +1 -1
- package/lib/module/renderer/useContextBridge.js +21 -0
- package/lib/module/renderer/useContextBridge.js.map +1 -0
- package/lib/module/skia/Canvas.js.map +1 -1
- package/lib/module/skia/Picture/Picture.js +2 -0
- package/lib/module/skia/Picture/Picture.js.map +1 -0
- package/lib/module/skia/Picture/PictureFactory.js +2 -0
- package/lib/module/skia/Picture/PictureFactory.js.map +1 -0
- package/lib/module/skia/Picture/PictureRecorder.js +2 -0
- package/lib/module/skia/Picture/PictureRecorder.js.map +1 -0
- package/lib/module/skia/Picture/index.js +5 -0
- package/lib/module/skia/Picture/index.js.map +1 -0
- package/lib/module/skia/Picture/usePicture.js +19 -0
- package/lib/module/skia/Picture/usePicture.js.map +1 -0
- package/lib/module/skia/Skia.js +2 -0
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/module/skia/index.js +1 -0
- package/lib/module/skia/index.js.map +1 -1
- package/lib/module/values/hooks/useDerivedValue.js +1 -1
- package/lib/module/values/hooks/useDerivedValue.js.map +1 -1
- package/lib/module/views/SkiaView.js +6 -5
- package/lib/module/views/SkiaView.js.map +1 -1
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +5 -10
- package/lib/typescript/src/renderer/components/Drawing.d.ts +7 -0
- package/lib/typescript/src/renderer/components/Picture.d.ts +6 -0
- package/lib/typescript/src/renderer/components/imageFilters/InnerShadow.d.ts +3 -12
- package/lib/typescript/src/renderer/components/imageFilters/{DropShadow.d.ts → Shadow.d.ts} +3 -2
- package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -2
- package/lib/typescript/src/renderer/components/index.d.ts +2 -1
- package/lib/typescript/src/renderer/components/shapes/Box.d.ts +23 -0
- package/lib/typescript/src/renderer/components/shapes/index.d.ts +1 -0
- package/lib/typescript/src/renderer/index.d.ts +1 -0
- package/lib/typescript/src/renderer/nodes/Declaration.d.ts +3 -0
- package/lib/typescript/src/renderer/nodes/Drawing.d.ts +2 -2
- package/lib/typescript/src/renderer/nodes/Node.d.ts +2 -2
- package/lib/typescript/src/renderer/processors/Paint.d.ts +2 -2
- package/lib/typescript/src/renderer/processors/math/Math.d.ts +14 -0
- package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -0
- package/lib/typescript/src/renderer/typeddash.d.ts +1 -0
- package/lib/typescript/src/renderer/useContextBridge.d.ts +5 -0
- package/lib/typescript/src/skia/Canvas.d.ts +6 -0
- package/lib/typescript/src/skia/Picture/Picture.d.ts +26 -0
- package/lib/typescript/src/skia/Picture/PictureFactory.d.ts +8 -0
- package/lib/typescript/src/skia/Picture/PictureRecorder.d.ts +15 -0
- package/lib/typescript/src/skia/Picture/index.d.ts +4 -0
- package/lib/typescript/src/skia/Picture/usePicture.d.ts +11 -0
- package/lib/typescript/src/skia/Skia.d.ts +5 -0
- package/lib/typescript/src/skia/index.d.ts +1 -0
- package/lib/typescript/src/views/SkiaView.d.ts +25 -1
- package/lib/typescript/src/views/types.d.ts +0 -24
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/renderer/Canvas.tsx +14 -30
- package/src/renderer/HostConfig.ts +2 -20
- package/src/renderer/components/Drawing.tsx +16 -0
- package/src/renderer/components/Group.tsx +25 -15
- package/src/renderer/components/Paint.tsx +5 -35
- package/src/renderer/components/Picture.tsx +17 -0
- package/src/renderer/components/imageFilters/InnerShadow.tsx +33 -47
- package/src/renderer/components/imageFilters/Shadow.tsx +39 -0
- package/src/renderer/components/imageFilters/index.ts +1 -2
- package/src/renderer/components/index.ts +2 -1
- package/src/renderer/components/maskFilters/Blur.tsx +1 -1
- package/src/renderer/components/shapes/Box.tsx +98 -0
- package/src/renderer/components/shapes/index.ts +1 -0
- package/src/renderer/index.ts +1 -0
- package/src/renderer/nodes/Declaration.tsx +14 -0
- package/src/renderer/nodes/Drawing.tsx +16 -26
- package/src/renderer/nodes/Node.ts +9 -12
- package/src/renderer/processors/Paint.ts +34 -31
- package/src/renderer/processors/math/Math.ts +16 -0
- package/src/renderer/processors/math/Matrix3.ts +35 -31
- package/src/renderer/typeddash.ts +18 -0
- package/src/renderer/useContextBridge.tsx +21 -0
- package/src/skia/Canvas.ts +7 -0
- package/src/skia/Picture/Picture.ts +34 -0
- package/src/skia/Picture/PictureFactory.ts +9 -0
- package/src/skia/Picture/PictureRecorder.ts +18 -0
- package/src/skia/Picture/index.ts +4 -0
- package/src/skia/Picture/usePicture.ts +28 -0
- package/src/skia/Skia.ts +5 -0
- package/src/skia/index.ts +1 -0
- package/src/values/hooks/useDerivedValue.ts +1 -1
- package/src/views/SkiaView.tsx +27 -3
- package/src/views/types.ts +0 -25
- package/lib/commonjs/renderer/components/Defs.js.map +0 -1
- package/lib/commonjs/renderer/components/imageFilters/DropShadow.js.map +0 -1
- package/lib/module/renderer/components/Defs.js +0 -16
- package/lib/module/renderer/components/Defs.js.map +0 -1
- package/lib/module/renderer/components/imageFilters/DropShadow.js.map +0 -1
- package/lib/typescript/src/renderer/components/Defs.d.ts +0 -5
- package/src/renderer/components/Defs.tsx +0 -19
- package/src/renderer/components/imageFilters/DropShadow.tsx +0 -31
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["HostConfig.ts"],"names":["DeclarationNode","DrawingNode","NodeType","exhaustiveCheck","mapKeys","DEBUG","debug","console","log","shallowEq","p1","p2","keys1","keys2","length","key","allChildrenAreMemoized","node","memoizable","child","children","memoized","bustBranchMemoization","parent","ancestor","bustBranchMemoizable","appendNode","push","removeNode","index","indexOf","splice","depMgr","unSubscribeNode","c","insertBefore","before","beforeIndex","createNode","container","type","props","Drawing","onDraw","skipProcessing","Declaration","onDeclare","skHostConfig","now","performance","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","finalizeContainerChildren","resetAfterCommit","redraw","getPublicInstance","prepareUpdate","instance","oldProps","newProps","propsAreEqual","commitUpdate","_updatePayload","prevProps","nextProps","_internalHandle","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","preparePortalMount","removeChild","removeChildFromContainer","insertInContainerBefore"],"mappings":"AAAA;AAIA,SAASA,eAAT,EAA0BC,WAA1B,EAAuCC,QAAvC,QAAuD,SAAvD;AACA,SAASC,eAAT,EAA0BC,OAA1B,QAAyC,aAAzC;AAEA,MAAMC,KAAK,GAAG,KAAd;AACA,OAAO,MAAMC,KAAK,GAAG,YAA6C;AAChE,MAAID,KAAJ,EAAW;AACTE,IAAAA,OAAO,CAACC,GAAR,C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ASJ,KAAT,EAAgBiB,MAAhB,KAA2B;AACvCD,IAAAA,YAAY,CAACZ,MAAD,EAASJ,KAAT,EAAgBiB,MAAhB,CAAZ;AACD;AAtKyC,CAArC","sourcesContent":["/*global NodeJS, performance*/\nimport type { HostConfig } from \"react-reconciler\";\n\nimport type { Node, Container, DeclarationProps, DrawingProps } from \"./nodes\";\nimport { DeclarationNode, DrawingNode, NodeType } from \"./nodes\";\nimport { exhaustiveCheck, mapKeys } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skDeclaration: DeclarationProps<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skDrawing: DrawingProps<any>;\n }\n }\n}\n\ntype Instance = Node;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Props = any;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = true;\ntype ChildSet = unknown;\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\n// Shallow eq on props (without children)\nconst shallowEq = <P extends Props>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n\nconst allChildrenAreMemoized = (node: Instance) => {\n if (!node.memoizable) {\n return false;\n }\n for (const child of node.children) {\n if (!child.memoized) {\n return false;\n }\n }\n return true;\n};\n\nconst bustBranchMemoization = (parent: Node) => {\n if (parent.memoizable) {\n let ancestor: Node | undefined = parent;\n while (ancestor) {\n ancestor.memoized = false;\n ancestor = ancestor.parent;\n }\n }\n};\n\nconst bustBranchMemoizable = (parent: Node) => {\n if (parent.memoizable) {\n let ancestor: Node | undefined = parent;\n while (ancestor) {\n ancestor.memoizable = false;\n ancestor = ancestor.parent;\n }\n }\n};\n\nconst appendNode = (parent: Node, child: Node) => {\n child.parent = parent;\n bustBranchMemoization(parent);\n if (!child.memoizable) {\n bustBranchMemoizable(parent);\n }\n if (!parent.memoizable) {\n child.memoizable = false;\n }\n parent.children.push(child);\n};\n\nconst removeNode = (parent: Node, child: Node) => {\n bustBranchMemoization(parent);\n const index = parent.children.indexOf(child);\n parent.children.splice(index, 1);\n child.depMgr.unSubscribeNode(child);\n // unsubscribe to all children as well\n for (const c of child.children) {\n removeNode(child, c);\n }\n};\n\nconst insertBefore = (parent: Node, child: Node, before: Node) => {\n bustBranchMemoization(parent);\n const index = parent.children.indexOf(child);\n if (index !== -1) {\n parent.children.splice(index, 1);\n }\n const beforeIndex = parent.children.indexOf(before);\n parent.children.splice(beforeIndex, 0, child);\n};\n\nconst createNode = (container: Container, type: NodeType, props: Props) => {\n switch (type) {\n case NodeType.Drawing:\n const { onDraw, skipProcessing, ...p1 } = props;\n return new DrawingNode(container.depMgr, onDraw, skipProcessing, p1);\n case NodeType.Declaration:\n const { onDeclare, ...p2 } = props;\n return new DeclarationNode(container.depMgr, onDeclare, p2);\n default:\n // TODO: here we need to throw a nice error message\n // This is the error that will show up when the user uses nodes not supported by Skia (View, Audio, etc)\n return exhaustiveCheck(type);\n }\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: performance.now,\n\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Node) => {\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 props,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n return createNode(container, type, props) as Node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, 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(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n finalizeContainerChildren: () => {\n debug(\"finalizeContainerChildren\");\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 prepareUpdate: (\n instance,\n type,\n oldProps,\n newProps,\n _rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual && !instance.memoizable) {\n return null;\n }\n debug(\"update \", type);\n return true;\n },\n\n commitUpdate(\n instance,\n _updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps) && allChildrenAreMemoized(instance)) {\n return;\n }\n bustBranchMemoization(instance);\n instance.props = nextProps;\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 container.children.splice(0);\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (parent, child) => {\n removeNode(parent, child);\n },\n\n insertInContainerBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n};\n"]}
|
1
|
+
{"version":3,"sources":["HostConfig.ts"],"names":["DeclarationNode","DrawingNode","NodeType","exhaustiveCheck","shallowEq","DEBUG","debug","console","log","allChildrenAreMemoized","node","memoizable","child","children","memoized","bustBranchMemoization","parent","ancestor","bustBranchMemoizable","appendNode","push","removeNode","index","indexOf","splice","depMgr","unSubscribeNode","c","insertBefore","before","beforeIndex","createNode","container","type","props","Drawing","onDraw","skipProcessing","p1","Declaration","onDeclare","p2","skHostConfig","now","performance","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","appendChildToContainer","appendChild","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","appendInitialChild","parentInstance","finalizeInitialChildren","commitMount","prepareForCommit","_containerInfo","finalizeContainerChildren","resetAfterCommit","redraw","getPublicInstance","prepareUpdate","instance","oldProps","newProps","propsAreEqual","commitUpdate","_updatePayload","prevProps","nextProps","_internalHandle","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","preparePortalMount","removeChild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,CAAT,IAAmC9E,sBAAsB,CAACuE,QAAD,CAA7D,EAAyE;AACvE;AACD;;AACDjE,IAAAA,qBAAqB,CAACiE,QAAD,CAArB;AACAA,IAAAA,QAAQ,CAAC9C,KAAT,GAAiBqD,SAAjB;AACD,GArIyC;;AAuI1CE,EAAAA,gBAAgB,EAAE,CAChBC,aADgB,EAEhBC,QAFgB,EAGhBC,QAHgB,KAIb,CACH;AACD,GA7IyC;AA+I1CC,EAAAA,cAAc,EAAG7D,SAAD,IAAe;AAC7B1B,IAAAA,KAAK,CAAC,gBAAD,CAAL;AACA0B,IAAAA,SAAS,CAACnB,QAAV,CAAmBW,MAAnB,CAA0B,CAA1B;AACD,GAlJyC;AAoJ1CsE,EAAAA,kBAAkB,EAAE,MAAM;AACxBxF,IAAAA,KAAK,CAAC,oBAAD,CAAL;AACD,GAtJyC;AAwJ1CyF,EAAAA,WAAW,EAAE,CAAC/E,MAAD,EAASJ,KAAT,KAAmB;AAC9BS,IAAAA,UAAU,CAACL,MAAD,EAASJ,KAAT,CAAV;AACD,GA1JyC;AA4J1CoF,EAAAA,wBAAwB,EAAE,CAAChF,MAAD,EAASJ,KAAT,KAAmB;AAC3CS,IAAAA,UAAU,CAACL,MAAD,EAASJ,KAAT,CAAV;AACD,GA9JyC;AAgK1CqF,EAAAA,uBAAuB,EAAE,CAACjF,MAAD,EAASJ,KAAT,EAAgBiB,MAAhB,KAA2B;AAClDD,IAAAA,YAAY,CAACZ,MAAD,EAASJ,KAAT,EAAgBiB,MAAhB,CAAZ;AACD,GAlKyC;AAoK1CD,EAAAA,YAAY,EAAE,CAACZ,MAAD,EAASJ,KAAT,EAAgBiB,MAAhB,KAA2B;AACvCD,IAAAA,YAAY,CAACZ,MAAD,EAASJ,KAAT,EAAgBiB,MAAhB,CAAZ;AACD;AAtKyC,CAArC","sourcesContent":["/*global NodeJS, performance*/\nimport type { HostConfig } from \"react-reconciler\";\n\nimport type { Node, Container, DeclarationProps, DrawingProps } from \"./nodes\";\nimport { DeclarationNode, DrawingNode, NodeType } from \"./nodes\";\nimport { exhaustiveCheck, shallowEq } from \"./typeddash\";\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skDeclaration: DeclarationProps<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skDrawing: DrawingProps<any>;\n }\n }\n}\n\ntype Instance = Node;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Props = any;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = null;\ntype UpdatePayload = true;\ntype ChildSet = unknown;\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\nconst allChildrenAreMemoized = (node: Instance) => {\n if (!node.memoizable) {\n return false;\n }\n for (const child of node.children) {\n if (!child.memoized) {\n return false;\n }\n }\n return true;\n};\n\nconst bustBranchMemoization = (parent: Node) => {\n if (parent.memoizable) {\n let ancestor: Node | undefined = parent;\n while (ancestor) {\n ancestor.memoized = null;\n ancestor = ancestor.parent;\n }\n }\n};\n\nconst bustBranchMemoizable = (parent: Node) => {\n if (parent.memoizable) {\n let ancestor: Node | undefined = parent;\n while (ancestor) {\n ancestor.memoizable = false;\n ancestor = ancestor.parent;\n }\n }\n};\n\nconst appendNode = (parent: Node, child: Node) => {\n child.parent = parent;\n bustBranchMemoization(parent);\n if (!child.memoizable) {\n bustBranchMemoizable(parent);\n }\n if (!parent.memoizable) {\n child.memoizable = false;\n }\n parent.children.push(child);\n};\n\nconst removeNode = (parent: Node, child: Node) => {\n bustBranchMemoization(parent);\n const index = parent.children.indexOf(child);\n parent.children.splice(index, 1);\n child.depMgr.unSubscribeNode(child);\n // unsubscribe to all children as well\n for (const c of child.children) {\n removeNode(child, c);\n }\n};\n\nconst insertBefore = (parent: Node, child: Node, before: Node) => {\n bustBranchMemoization(parent);\n const index = parent.children.indexOf(child);\n if (index !== -1) {\n parent.children.splice(index, 1);\n }\n const beforeIndex = parent.children.indexOf(before);\n parent.children.splice(beforeIndex, 0, child);\n};\n\nconst createNode = (container: Container, type: NodeType, props: Props) => {\n switch (type) {\n case NodeType.Drawing:\n const { onDraw, skipProcessing, ...p1 } = props;\n return new DrawingNode(container.depMgr, onDraw, skipProcessing, p1);\n case NodeType.Declaration:\n const { onDeclare, ...p2 } = props;\n return new DeclarationNode(container.depMgr, onDeclare, p2);\n default:\n // TODO: here we need to throw a nice error message\n // This is the error that will show up when the user uses nodes not supported by Skia (View, Audio, etc)\n return exhaustiveCheck(type);\n }\n};\n\nexport const skHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n now: performance.now,\n\n supportsMutation: true,\n isPrimaryRenderer: false,\n supportsPersistence: false,\n supportsHydration: false,\n //supportsMicrotask: true,\n\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n appendChildToContainer(container, child) {\n debug(\"appendChildToContainer\", container, child);\n appendNode(container, child);\n },\n\n appendChild(parent, child) {\n debug(\"appendChild\", parent, child);\n appendNode(parent, child);\n },\n\n getRootHostContext: (_rootContainerInstance: Node) => {\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 props,\n container,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createInstance\", type);\n return createNode(container, type, props) as Node;\n },\n\n appendInitialChild(parentInstance, child) {\n debug(\"appendInitialChild\");\n appendNode(parentInstance, 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(_containerInfo) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n finalizeContainerChildren: () => {\n debug(\"finalizeContainerChildren\");\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 prepareUpdate: (\n instance,\n type,\n oldProps,\n newProps,\n _rootContainerInstance,\n _hostContext\n ) => {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual && !instance.memoizable) {\n return null;\n }\n debug(\"update \", type);\n return true;\n },\n\n commitUpdate(\n instance,\n _updatePayload,\n type,\n prevProps,\n nextProps,\n _internalHandle\n ) {\n debug(\"commitUpdate: \", type);\n if (shallowEq(prevProps, nextProps) && allChildrenAreMemoized(instance)) {\n return;\n }\n bustBranchMemoization(instance);\n instance.props = nextProps;\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 container.children.splice(0);\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n removeChild: (parent, child) => {\n removeNode(parent, child);\n },\n\n removeChildFromContainer: (parent, child) => {\n removeNode(parent, child);\n },\n\n insertInContainerBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n\n insertBefore: (parent, child, before) => {\n insertBefore(parent, child, before);\n },\n};\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from "react";
|
4
|
+
import { createDrawing } from "../nodes/Drawing";
|
5
|
+
const onDraw = createDrawing((ctx, _ref) => {
|
6
|
+
let {
|
7
|
+
drawing
|
8
|
+
} = _ref;
|
9
|
+
drawing(ctx);
|
10
|
+
});
|
11
|
+
export const Drawing = props => {
|
12
|
+
return /*#__PURE__*/React.createElement("skDrawing", _extends({
|
13
|
+
onDraw: onDraw,
|
14
|
+
skipProcessing: true
|
15
|
+
}, props));
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=Drawing.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["Drawing.tsx"],"names":["React","createDrawing","onDraw","ctx","drawing","Drawing","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAMA,MAAMC,MAAM,GAAGD,aAAa,CAAe,CAACE,GAAD,WAAsB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC/DA,EAAAA,OAAO,CAACD,GAAD,CAAP;AACD,CAF2B,CAA5B;AAIA,OAAO,MAAME,OAAO,GAAIC,KAAD,IAAyB;AAC9C,sBAAO;AAAW,IAAA,MAAM,EAAEJ,MAAnB;AAA2B,IAAA,cAAc;AAAzC,KAA8CI,KAA9C,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport type { DrawingContext } from \"../DrawingContext\";\nimport { createDrawing } from \"../nodes/Drawing\";\n\ninterface DrawingProps {\n drawing: (ctx: DrawingContext) => void;\n}\n\nconst onDraw = createDrawing<DrawingProps>((ctx, { drawing }) => {\n drawing(ctx);\n});\n\nexport const Drawing = (props: DrawingProps) => {\n return <skDrawing onDraw={onDraw} skipProcessing {...props} />;\n};\n"]}
|
@@ -2,8 +2,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
2
2
|
|
3
3
|
import React from "react";
|
4
4
|
import { ClipOp } from "../../skia";
|
5
|
-
import { processTransform,
|
6
|
-
import { createDrawing } from "../nodes";
|
5
|
+
import { processTransform, processPaint, processClip } from "../processors";
|
6
|
+
import { createDrawing, DrawingNode } from "../nodes";
|
7
|
+
import { isDeclarationNode } from "../nodes/Declaration";
|
7
8
|
|
8
9
|
const isSkPaint = obj => "__typename__" in obj && obj.__typename__ === "Paint";
|
9
10
|
|
@@ -18,11 +19,12 @@ const onDraw = createDrawing((ctx, _ref, node) => {
|
|
18
19
|
canvas,
|
19
20
|
opacity
|
20
21
|
} = ctx;
|
21
|
-
const
|
22
|
-
|
22
|
+
const declarations = node.children.filter(isDeclarationNode).map(child => child.draw(ctx));
|
23
|
+
const drawings = node.children.filter(child => child instanceof DrawingNode);
|
24
|
+
const paint = processPaint(ctx.paint.copy(), opacity, groupProps, declarations);
|
23
25
|
const hasTransform = !!groupProps.transform || !!groupProps.matrix;
|
24
26
|
const hasClip = !!clip;
|
25
|
-
const shouldSave = hasTransform || hasClip;
|
27
|
+
const shouldSave = hasTransform || hasClip || !!layer;
|
26
28
|
|
27
29
|
if (shouldSave) {
|
28
30
|
if (layer) {
|
@@ -50,7 +52,7 @@ const onDraw = createDrawing((ctx, _ref, node) => {
|
|
50
52
|
node.visit({ ...ctx,
|
51
53
|
paint,
|
52
54
|
opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity
|
53
|
-
});
|
55
|
+
}, drawings);
|
54
56
|
|
55
57
|
if (shouldSave) {
|
56
58
|
canvas.restore();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processTransform","
|
1
|
+
{"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processTransform","processPaint","processClip","createDrawing","DrawingNode","isDeclarationNode","isSkPaint","obj","__typename__","onDraw","ctx","node","layer","clip","invertClip","groupProps","canvas","opacity","declarations","children","filter","map","child","draw","drawings","paint","copy","hasTransform","transform","matrix","hasClip","shouldSave","saveLayer","current","undefined","save","op","Difference","Intersect","visit","restore","Group","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,gBAAT,EAA2BC,YAA3B,EAAyCC,WAAzC,QAA4D,eAA5D;AAOA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,UAA3C;AACA,SAASC,iBAAT,QAAkC,sBAAlC;;AAEA,MAAMC,SAAS,GAAIC,GAAD,IAChB,kBAAkBA,GAAlB,IAAyBA,GAAG,CAACC,YAAJ,KAAqB,OADhD;;AASA,MAAMC,MAAM,GAAGN,aAAa,CAC1B,CAACO,GAAD,QAAkDC,IAAlD,KAA2D;AAAA,MAArD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,UAAf;AAA2B,OAAGC;AAA9B,GAAqD;AACzD,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAsBP,GAA5B;AACA,QAAMQ,YAAY,GAAGP,IAAI,CAACQ,QAAL,CAClBC,MADkB,CACXf,iBADW,EAElBgB,GAFkB,CAEbC,KAAD,IAAWA,KAAK,CAACC,IAAN,CAAWb,GAAX,CAFG,CAArB;AAIA,QAAMc,QAAQ,GAAGb,IAAI,CAACQ,QAAL,CAAcC,MAAd,CACdE,KAAD,IAAWA,KAAK,YAAYlB,WADb,CAAjB;AAGA,QAAMqB,KAAK,GAAGxB,YAAY,CACxBS,GAAG,CAACe,KAAJ,CAAUC,IAAV,EADwB,EAExBT,OAFwB,EAGxBF,UAHwB,EAIxBG,YAJwB,CAA1B;AAMA,QAAMS,YAAY,GAAG,CAAC,CAACZ,UAAU,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AAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { RefObject } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { ClipOp } from \"../../skia\";\nimport { processTransform, processPaint, processClip } from \"../processors\";\nimport type {\n CustomPaintProps,\n TransformProps,\n AnimatedProps,\n ClipDef,\n} from \"../processors\";\nimport { createDrawing, DrawingNode } from \"../nodes\";\nimport { isDeclarationNode } from \"../nodes/Declaration\";\n\nconst isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>\n \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nexport interface GroupProps extends CustomPaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: RefObject<SkPaint> | SkPaint | boolean;\n}\n\nconst onDraw = createDrawing<GroupProps>(\n (ctx, { layer, clip, invertClip, ...groupProps }, node) => {\n const { canvas, opacity } = ctx;\n const declarations = node.children\n .filter(isDeclarationNode)\n .map((child) => child.draw(ctx));\n\n const drawings = node.children.filter(\n (child) => child instanceof DrawingNode\n );\n const paint = processPaint(\n ctx.paint.copy(),\n opacity,\n groupProps,\n declarations\n );\n const hasTransform = !!groupProps.transform || !!groupProps.matrix;\n const hasClip = !!clip;\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else if (isSkPaint(layer)) {\n canvas.saveLayer(layer);\n } else {\n canvas.saveLayer(layer.current ?? undefined);\n }\n } else {\n canvas.save();\n }\n processTransform(ctx, groupProps);\n if (clip) {\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n processClip(canvas, clip, op);\n }\n }\n node.visit(\n {\n ...ctx,\n paint,\n opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,\n },\n drawings\n );\n if (shouldSave) {\n canvas.restore();\n }\n }\n);\n\nexport const Group = (props: AnimatedProps<GroupProps>) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
|
@@ -1,34 +1,14 @@
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
2
|
|
3
3
|
import React, { useRef, useMemo, forwardRef, useImperativeHandle } from "react";
|
4
|
-
import {
|
4
|
+
import { Skia } from "../../skia";
|
5
5
|
import { processPaint } from "../processors";
|
6
6
|
import { createDeclaration } from "../nodes";
|
7
7
|
export const usePaintRef = () => useRef(null);
|
8
8
|
export const Paint = /*#__PURE__*/forwardRef((props, ref) => {
|
9
9
|
const paint = useMemo(() => Skia.Paint(), []);
|
10
10
|
useImperativeHandle(ref, () => paint, [paint]);
|
11
|
-
const onDeclare = useMemo(() => createDeclaration((paintProps, children, ctx) =>
|
12
|
-
processPaint(paint, ctx.opacity, paintProps);
|
13
|
-
children.forEach(child => {
|
14
|
-
if (isShader(child)) {
|
15
|
-
paint.setShader(child);
|
16
|
-
} else if (isMaskFilter(child)) {
|
17
|
-
paint.setMaskFilter(child);
|
18
|
-
} else if (isColorFilter(child)) {
|
19
|
-
paint.setColorFilter(child);
|
20
|
-
} else if (isPathEffect(child)) {
|
21
|
-
paint.setPathEffect(child);
|
22
|
-
}
|
23
|
-
});
|
24
|
-
const filters = children.filter(isImageFilter);
|
25
|
-
|
26
|
-
if (filters.length > 0) {
|
27
|
-
paint.setImageFilter(filters.reverse().reduce(Skia.ImageFilter.MakeCompose, null));
|
28
|
-
}
|
29
|
-
|
30
|
-
return paint;
|
31
|
-
}), [paint]);
|
11
|
+
const onDeclare = useMemo(() => createDeclaration((paintProps, children, ctx) => processPaint(paint, ctx.opacity, paintProps, children)), [paint]);
|
32
12
|
return /*#__PURE__*/React.createElement("skDeclaration", _extends({
|
33
13
|
onDeclare: onDeclare
|
34
14
|
}, props));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","
|
1
|
+
{"version":3,"sources":["Paint.tsx"],"names":["React","useRef","useMemo","forwardRef","useImperativeHandle","Skia","processPaint","createDeclaration","usePaintRef","Paint","props","ref","paint","onDeclare","paintProps","children","ctx","opacity"],"mappings":";;AACA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,OAAxB,EAAiCC,UAAjC,EAA6CC,mBAA7C,QAAwE,OAAxE;AAGA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,YAAT,QAA6B,eAA7B;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAO,MAAMC,WAAW,GAAG,MAAMP,MAAM,CAAU,IAAV,CAAhC;AAMP,OAAO,MAAMQ,KAAK,gBAAGN,UAAU,CAC7B,CAACO,KAAD,EAAQC,GAAR,KAAgB;AACd,QAAMC,KAAK,GAAGV,OAAO,CAAC,MAAMG,IAAI,CAACI,KAAL,EAAP,EAAqB,EAArB,CAArB;AACAL,EAAAA,mBAAmB,CAACO,GAAD,EAAM,MAAMC,KAAZ,EAAmB,CAACA,KAAD,CAAnB,CAAnB;AACA,QAAMC,SAAS,GAAGX,OAAO,CACvB,MACEK,iBAAiB,CAAa,CAACO,UAAD,EAAaC,QAAb,EAAuBC,GAAvB,KAC5BV,YAAY,CAACM,KAAD,EAAQI,GAAG,CAACC,OAAZ,EAAqBH,UAArB,EAAiCC,QAAjC,CADG,CAFI,EAKvB,CAACH,KAAD,CALuB,CAAzB;AAOA,sBAAO;AAAe,IAAA,SAAS,EAAEC;AAA1B,KAAyCH,KAAzC,EAAP;AACD,CAZ4B,CAAxB","sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useRef, useMemo, forwardRef, useImperativeHandle } from \"react\";\n\nimport type { SkPaint } from \"../../skia\";\nimport { Skia } from \"../../skia\";\nimport type { CustomPaintProps, AnimatedProps } from \"../processors\";\nimport { processPaint } from \"../processors\";\nimport { createDeclaration } from \"../nodes\";\n\nexport const usePaintRef = () => useRef<SkPaint>(null);\n\nexport interface PaintProps extends Omit<CustomPaintProps, \"paint\"> {\n children?: ReactNode | ReactNode[];\n}\n\nexport const Paint = forwardRef<SkPaint, AnimatedProps<PaintProps>>(\n (props, ref) => {\n const paint = useMemo(() => Skia.Paint(), []);\n useImperativeHandle(ref, () => paint, [paint]);\n const onDeclare = useMemo(\n () =>\n createDeclaration<PaintProps>((paintProps, children, ctx) =>\n processPaint(paint, ctx.opacity, paintProps, children)\n ),\n [paint]\n );\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n }\n);\n"]}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from "react";
|
4
|
+
import { createDrawing } from "../nodes/Drawing";
|
5
|
+
const onDraw = createDrawing((ctx, _ref) => {
|
6
|
+
let {
|
7
|
+
picture
|
8
|
+
} = _ref;
|
9
|
+
const {
|
10
|
+
canvas
|
11
|
+
} = ctx;
|
12
|
+
canvas.drawPicture(picture);
|
13
|
+
});
|
14
|
+
export const Picture = props => {
|
15
|
+
return /*#__PURE__*/React.createElement("skDrawing", _extends({
|
16
|
+
onDraw: onDraw
|
17
|
+
}, props, {
|
18
|
+
skipProcessing: true
|
19
|
+
}));
|
20
|
+
};
|
21
|
+
//# sourceMappingURL=Picture.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["Picture.tsx"],"names":["React","createDrawing","onDraw","ctx","picture","canvas","drawPicture","Picture","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAMA,MAAMC,MAAM,GAAGD,aAAa,CAAe,CAACE,GAAD,WAAsB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAaF,GAAnB;AACAE,EAAAA,MAAM,CAACC,WAAP,CAAmBF,OAAnB;AACD,CAH2B,CAA5B;AAKA,OAAO,MAAMG,OAAO,GAAIC,KAAD,IAAyB;AAC9C,sBAAO;AAAW,IAAA,MAAM,EAAEN;AAAnB,KAA+BM,KAA/B;AAAsC,IAAA,cAAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport type { SkPicture } from \"../../skia\";\nimport { createDrawing } from \"../nodes/Drawing\";\n\nexport interface PictureProps {\n picture: SkPicture;\n}\n\nconst onDraw = createDrawing<PictureProps>((ctx, { picture }) => {\n const { canvas } = ctx;\n canvas.drawPicture(picture);\n});\n\nexport const Picture = (props: PictureProps) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
|
@@ -1,27 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import React from "react";
|
4
|
-
import { BlendMode, Skia, TileMode, processColor } from "../../../skia";
|
5
|
-
import { createDeclaration } from "../../nodes/Declaration";
|
6
|
-
import { getInput } from "./getInput";
|
7
|
-
const onDeclare = createDeclaration((_ref, children, _ref2) => {
|
8
|
-
let {
|
9
|
-
dx,
|
10
|
-
dy,
|
11
|
-
blur,
|
12
|
-
color,
|
13
|
-
shadowOnly
|
14
|
-
} = _ref;
|
15
|
-
let {
|
16
|
-
opacity
|
17
|
-
} = _ref2;
|
18
|
-
const input = getInput(children);
|
19
|
-
const cl = processColor(color, opacity);
|
1
|
+
import { BlendMode, Skia, TileMode } from "../../../skia";
|
2
|
+
export const MakeInnerShadow = (shadowOnly, dx, dy, sigmaX, sigmaY, color, input) => {
|
20
3
|
const sourceGraphic = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.Dst), null);
|
21
4
|
const sourceAlpha = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.SrcIn), null);
|
22
|
-
const f1 = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(
|
5
|
+
const f1 = Skia.ImageFilter.MakeColorFilter(Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut), null);
|
23
6
|
const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);
|
24
|
-
const f3 = Skia.ImageFilter.MakeBlur(
|
7
|
+
const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);
|
25
8
|
const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);
|
26
9
|
|
27
10
|
if (shadowOnly) {
|
@@ -29,10 +12,5 @@ const onDeclare = createDeclaration((_ref, children, _ref2) => {
|
|
29
12
|
}
|
30
13
|
|
31
14
|
return Skia.ImageFilter.MakeCompose(input, Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4));
|
32
|
-
});
|
33
|
-
export const InnerShadow = props => {
|
34
|
-
return /*#__PURE__*/React.createElement("skDeclaration", _extends({
|
35
|
-
onDeclare: onDeclare
|
36
|
-
}, props));
|
37
15
|
};
|
38
16
|
//# sourceMappingURL=InnerShadow.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["InnerShadow.tsx"],"names":["
|
1
|
+
{"version":3,"sources":["InnerShadow.tsx"],"names":["BlendMode","Skia","TileMode","MakeInnerShadow","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","Decal","f4","MakeCompose","SrcOver"],"mappings":"AACA,SAASA,SAAT,EAAoBC,IAApB,EAA0BC,QAA1B,QAA0C,eAA1C;AAGA,OAAO,MAAMC,eAAe,GAAG,CAC7BC,UAD6B,EAE7BC,EAF6B,EAG7BC,EAH6B,EAI7BC,MAJ6B,EAK7BC,MAL6B,EAM7BC,KAN6B,EAO7BC,KAP6B,KAQ1B;AACH,QAAMC,aAAa,GAAGV,IAAI,CAACW,WAAL,CAAiBC,eAAjB,CACpBZ,IAAI,CAACa,WAAL,CAAiBC,SAAjB,CAA2B,UAA3B,EAAuCf,SAAS,CAACgB,GAAjD,CADoB,EAEpB,IAFoB,CAAtB;AAIA,QAAMC,WAAW,GAAGhB,IAAI,CAACW,WAAL,CAAiBC,eAAjB,CAClBZ,IAAI,CAACa,WAAL,CAAiBC,SAAjB,CAA2B,UAA3B,EAAuCf,SAAS,CAACkB,KAAjD,CADkB,EAElB,IAFkB,CAApB;AAIA,QAAMC,EAAE,GAAGlB,IAAI,CAACW,WAAL,CAAiBC,eAAjB,CACTZ,IAAI,CAACa,WAAL,CAAiBC,SAAjB,CAA2BN,KAA3B,EAAkCT,SAAS,CAACoB,MAA5C,CADS,EAET,IAFS,CAAX;AAIA,QAAMC,EAAE,GAAGpB,IAAI,CAACW,WAAL,CAAiBU,UAAjB,CAA4BjB,EAA5B,EAAgCC,EAAhC,EAAoCa,EAApC,CAAX;AACA,QAAMI,EAAE,GAAGtB,IAAI,CAACW,WAAL,CAAiBY,QAAjB,CAA0BjB,MAA1B,EAAkCC,MAAlC,EAA0CN,QAAQ,CAACuB,KAAnD,EAA0DJ,EAA1D,CAAX;AACA,QAAMK,EAAE,GAAGzB,IAAI,CAACW,WAAL,CAAiBG,SAAjB,CAA2Bf,SAAS,CAACkB,KAArC,EAA4CD,WAA5C,EAAyDM,EAAzD,CAAX;;AACA,MAAInB,UAAJ,EAAgB;AACd,WAAOsB,EAAP;AACD;;AACD,SAAOzB,IAAI,CAACW,WAAL,CAAiBe,WAAjB,CACLjB,KADK,EAELT,IAAI,CAACW,WAAL,CAAiBG,SAAjB,CAA2Bf,SAAS,CAAC4B,OAArC,EAA8CjB,aAA9C,EAA6De,EAA7D,CAFK,CAAP;AAID,CA/BM","sourcesContent":["import type { SkColor } from \"../../../skia\";\nimport { BlendMode, Skia, TileMode } from \"../../../skia\";\nimport type { SkImageFilter } from \"../../../skia/ImageFilter/ImageFilter\";\n\nexport const MakeInnerShadow = (\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n"]}
|
@@ -5,24 +5,34 @@ import { Skia } from "../../../skia";
|
|
5
5
|
import { createDeclaration } from "../../nodes/Declaration";
|
6
6
|
import { processColor } from "../../../skia/Color";
|
7
7
|
import { getInput } from "./getInput";
|
8
|
+
import { MakeInnerShadow } from "./InnerShadow";
|
8
9
|
const onDeclare = createDeclaration((_ref, children, _ref2) => {
|
9
10
|
let {
|
10
11
|
dx,
|
11
12
|
dy,
|
12
13
|
blur,
|
13
|
-
color,
|
14
|
-
shadowOnly
|
14
|
+
color: cl,
|
15
|
+
shadowOnly,
|
16
|
+
inner
|
15
17
|
} = _ref;
|
16
18
|
let {
|
17
19
|
opacity
|
18
20
|
} = _ref2;
|
19
21
|
const input = getInput(children);
|
20
|
-
const
|
21
|
-
|
22
|
+
const color = processColor(cl, opacity);
|
23
|
+
let factory;
|
24
|
+
|
25
|
+
if (inner) {
|
26
|
+
factory = MakeInnerShadow.bind(null, shadowOnly);
|
27
|
+
} else {
|
28
|
+
factory = shadowOnly ? Skia.ImageFilter.MakeDropShadowOnly : Skia.ImageFilter.MakeDropShadow;
|
29
|
+
}
|
30
|
+
|
31
|
+
return factory(dx, dy, blur, blur, color, input);
|
22
32
|
});
|
23
|
-
export const
|
33
|
+
export const Shadow = props => {
|
24
34
|
return /*#__PURE__*/React.createElement("skDeclaration", _extends({
|
25
35
|
onDeclare: onDeclare
|
26
36
|
}, props));
|
27
37
|
};
|
28
|
-
//# sourceMappingURL=
|
38
|
+
//# sourceMappingURL=Shadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["Shadow.tsx"],"names":["React","Skia","createDeclaration","processColor","getInput","MakeInnerShadow","onDeclare","children","dx","dy","blur","color","cl","shadowOnly","inner","opacity","input","factory","bind","ImageFilter","MakeDropShadowOnly","MakeDropShadow","Shadow","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAGA,SAASC,YAAT,QAA6B,qBAA7B;AAEA,SAASC,QAAT,QAAyB,YAAzB;AACA,SAASC,eAAT,QAAgC,eAAhC;AAWA,MAAMC,SAAS,GAAGJ,iBAAiB,CACjC,OAAiDK,QAAjD,YAA2E;AAAA,MAA1E;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,EAAN;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,KAAK,EAAEC,EAAvB;AAA2BC,IAAAA,UAA3B;AAAuCC,IAAAA;AAAvC,GAA0E;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACzE,QAAMC,KAAK,GAAGZ,QAAQ,CAACG,QAAD,CAAtB;AACA,QAAMI,KAAK,GAAGR,YAAY,CAACS,EAAD,EAAKG,OAAL,CAA1B;AACA,MAAIE,OAAJ;;AACA,MAAIH,KAAJ,EAAW;AACTG,IAAAA,OAAO,GAAGZ,eAAe,CAACa,IAAhB,CAAqB,IAArB,EAA2BL,UAA3B,CAAV;AACD,GAFD,MAEO;AACLI,IAAAA,OAAO,GAAGJ,UAAU,GAChBZ,IAAI,CAACkB,WAAL,CAAiBC,kBADD,GAEhBnB,IAAI,CAACkB,WAAL,CAAiBE,cAFrB;AAGD;;AACD,SAAOJ,OAAO,CAACT,EAAD,EAAKC,EAAL,EAASC,IAAT,EAAeA,IAAf,EAAqBC,KAArB,EAA4BK,KAA5B,CAAd;AACD,CAbgC,CAAnC;AAgBA,OAAO,MAAMM,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAEjB;AAA1B,KAAyCiB,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\nimport type { Color } from \"../../../skia/Color\";\nimport { processColor } from \"../../../skia/Color\";\n\nimport { getInput } from \"./getInput\";\nimport { MakeInnerShadow } from \"./InnerShadow\";\n\nexport interface ShadowProps {\n dx: number;\n dy: number;\n blur: number;\n color: Color;\n inner?: boolean;\n shadowOnly?: boolean;\n}\n\nconst onDeclare = createDeclaration<ShadowProps>(\n ({ dx, dy, blur, color: cl, shadowOnly, inner }, children, { opacity }) => {\n const input = getInput(children);\n const color = processColor(cl, opacity);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, shadowOnly);\n } else {\n factory = shadowOnly\n ? Skia.ImageFilter.MakeDropShadowOnly\n : Skia.ImageFilter.MakeDropShadow;\n }\n return factory(dx, dy, blur, blur, color, input);\n }\n);\n\nexport const Shadow = (props: AnimatedProps<ShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,mBAAd;AACA,cAAc,
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,mBAAd;AACA,cAAc,UAAd;AACA,cAAc,cAAd","sourcesContent":["export * from \"./Blur\";\nexport * from \"./Offset\";\nexport * from \"./DisplacementMap\";\nexport * from \"./Shadow\";\nexport * from \"./Morphology\";\n"]}
|
@@ -8,10 +8,11 @@ export * from "./maskFilters";
|
|
8
8
|
export * from "./imageFilters";
|
9
9
|
export * from "./pathEffects";
|
10
10
|
export * from "../processors";
|
11
|
+
export * from "./Picture";
|
11
12
|
export * from "./Group";
|
12
13
|
export * from "./Mask";
|
13
14
|
export * from "./Paint";
|
14
15
|
export * from "./Compose";
|
15
16
|
export * from "./Blend";
|
16
|
-
export * from "./
|
17
|
+
export * from "./Drawing";
|
17
18
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AAEA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,WAAd;AAEA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd","sourcesContent":["export * from \"./shapes\";\nexport * from \"./backdrop\";\nexport * from \"./image\";\nexport * from \"./shaders\";\nexport * from \"./text\";\nexport * from \"./colorFilters\";\nexport * from \"./maskFilters\";\nexport * from \"./imageFilters\";\nexport * from \"./pathEffects\";\nexport * from \"../processors\";\nexport * from \"./Picture\";\n\nexport * from \"./Group\";\nexport * from \"./Mask\";\nexport * from \"./Paint\";\nexport * from \"./Compose\";\nexport * from \"./Blend\";\nexport * from \"./Drawing\";\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Blur.tsx"],"names":["React","BlurStyle","Skia","createDeclaration","enumKey","onDeclare","style","blur","respectCTM","MaskFilter","MakeBlur","BlurMask","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,SAAT,QAA0B,0BAA1B;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AASA,MAAMC,SAAS,GAAGF,iBAAiB,CACjC,QAAiC;AAAA,MAAhC;AAAEG,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA;AAAf,GAAgC;AAC/B,SAAON,IAAI,CAACO,UAAL,CAAgBC,QAAhB,CACLT,SAAS,CAACG,OAAO,CAACE,KAAD,CAAR,CADJ,EAELC,IAFK,EAGLC,UAHK,CAAP;AAKD,CAPgC,CAAnC;AAUA,OAAO,MAAMG,QAAQ,GAAIC,KAAD,IAAyC;AAC/D,sBAAO;AAAe,IAAA,SAAS,EAAEP;AAA1B,KAAyCO,KAAzC,EAAP;AACD,CAFM;AAIPD,QAAQ,CAACE,YAAT,GAAwB;AACtBP,EAAAA,KAAK,EAAE,QADe;AAEtBE,EAAAA,UAAU,EAAE;AAFU,CAAxB","sourcesContent":["import React from \"react\";\n\nimport { BlurStyle } from \"../../../skia/MaskFilter\";\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { SkEnum } from \"../../processors\";\nimport { enumKey } from \"../../processors\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\n\nexport interface BlurMaskProps {\n style: SkEnum<typeof BlurStyle>;\n blur: number;\n respectCTM: boolean;\n}\n\nconst onDeclare = createDeclaration<BlurMaskProps>(\n ({ style, blur, respectCTM }) => {\n return Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n }\n);\n\nexport const BlurMask = (props: AnimatedProps<BlurMaskProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nBlurMask.defaultProps = {\n style: \"normal\",\n respectCTM:
|
1
|
+
{"version":3,"sources":["Blur.tsx"],"names":["React","BlurStyle","Skia","createDeclaration","enumKey","onDeclare","style","blur","respectCTM","MaskFilter","MakeBlur","BlurMask","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,SAAT,QAA0B,0BAA1B;AACA,SAASC,IAAT,QAAqB,eAArB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,SAASC,OAAT,QAAwB,kBAAxB;AASA,MAAMC,SAAS,GAAGF,iBAAiB,CACjC,QAAiC;AAAA,MAAhC;AAAEG,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA;AAAf,GAAgC;AAC/B,SAAON,IAAI,CAACO,UAAL,CAAgBC,QAAhB,CACLT,SAAS,CAACG,OAAO,CAACE,KAAD,CAAR,CADJ,EAELC,IAFK,EAGLC,UAHK,CAAP;AAKD,CAPgC,CAAnC;AAUA,OAAO,MAAMG,QAAQ,GAAIC,KAAD,IAAyC;AAC/D,sBAAO;AAAe,IAAA,SAAS,EAAEP;AAA1B,KAAyCO,KAAzC,EAAP;AACD,CAFM;AAIPD,QAAQ,CAACE,YAAT,GAAwB;AACtBP,EAAAA,KAAK,EAAE,QADe;AAEtBE,EAAAA,UAAU,EAAE;AAFU,CAAxB","sourcesContent":["import React from \"react\";\n\nimport { BlurStyle } from \"../../../skia/MaskFilter\";\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { SkEnum } from \"../../processors\";\nimport { enumKey } from \"../../processors\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\n\nexport interface BlurMaskProps {\n style: SkEnum<typeof BlurStyle>;\n blur: number;\n respectCTM: boolean;\n}\n\nconst onDeclare = createDeclaration<BlurMaskProps>(\n ({ style, blur, respectCTM }) => {\n return Skia.MaskFilter.MakeBlur(\n BlurStyle[enumKey(style)],\n blur,\n respectCTM\n );\n }\n);\n\nexport const BlurMask = (props: AnimatedProps<BlurMaskProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nBlurMask.defaultProps = {\n style: \"normal\",\n respectCTM: true,\n};\n"]}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
import React from "react";
|
4
|
+
import { ClipOp, BlurStyle, Skia, processColor } from "../../../skia";
|
5
|
+
import { createDrawing } from "../../nodes";
|
6
|
+
import { add, vec, rrect } from "../../processors";
|
7
|
+
import { rect, isRRect } from "../../processors/Rects";
|
8
|
+
import { createDeclaration } from "../../nodes/Declaration";
|
9
|
+
|
10
|
+
const inflate = function (box, dx, dy) {
|
11
|
+
let tx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
12
|
+
let ty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
13
|
+
return rrect(rect(box.rect.x - dx + tx, box.rect.y - dy + ty, box.rect.width + 2 * dx, box.rect.height + 2 * dy), box.rx + dx, box.ry + dy);
|
14
|
+
};
|
15
|
+
|
16
|
+
const deflate = function (box, dx, dy) {
|
17
|
+
let tx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
18
|
+
let ty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
19
|
+
return inflate(box, -dx, -dy, tx, ty);
|
20
|
+
};
|
21
|
+
|
22
|
+
const onDeclare = createDeclaration(_ref => {
|
23
|
+
let {
|
24
|
+
dx,
|
25
|
+
dy,
|
26
|
+
spread,
|
27
|
+
blur,
|
28
|
+
color,
|
29
|
+
inner
|
30
|
+
} = _ref;
|
31
|
+
return {
|
32
|
+
dx,
|
33
|
+
dy,
|
34
|
+
spread,
|
35
|
+
blur,
|
36
|
+
color,
|
37
|
+
inner,
|
38
|
+
__typename__: "BoxShadow"
|
39
|
+
};
|
40
|
+
});
|
41
|
+
export const BoxShadow = props => {
|
42
|
+
return /*#__PURE__*/React.createElement("skDeclaration", _extends({
|
43
|
+
onDeclare: onDeclare
|
44
|
+
}, props));
|
45
|
+
};
|
46
|
+
|
47
|
+
const isBoxShadow = s => s.__typename__ === "BoxShadow";
|
48
|
+
|
49
|
+
const onDraw = createDrawing((ctx, _ref2, node) => {
|
50
|
+
let {
|
51
|
+
box: defaultBox
|
52
|
+
} = _ref2;
|
53
|
+
const box = isRRect(defaultBox) ? defaultBox : rrect(defaultBox, 0, 0);
|
54
|
+
const {
|
55
|
+
canvas,
|
56
|
+
paint,
|
57
|
+
opacity
|
58
|
+
} = ctx;
|
59
|
+
const shadows = node.visit(ctx).filter(isBoxShadow);
|
60
|
+
shadows.filter(shadow => !shadow.inner).map(shadow => {
|
61
|
+
const {
|
62
|
+
color = "black",
|
63
|
+
blur,
|
64
|
+
spread = 0,
|
65
|
+
dx = 0,
|
66
|
+
dy = 0
|
67
|
+
} = shadow;
|
68
|
+
const lPaint = Skia.Paint();
|
69
|
+
lPaint.setColor(processColor(color, opacity));
|
70
|
+
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
|
71
|
+
canvas.drawRRect(inflate(box, spread, spread, dx, dy), lPaint);
|
72
|
+
});
|
73
|
+
canvas.drawRRect(box, paint);
|
74
|
+
shadows.filter(shadow => shadow.inner).map(shadow => {
|
75
|
+
const {
|
76
|
+
color = "black",
|
77
|
+
blur,
|
78
|
+
spread = 0,
|
79
|
+
dx = 0,
|
80
|
+
dy = 0
|
81
|
+
} = shadow;
|
82
|
+
const delta = add(vec(10, 10), vec(Math.abs(dx), Math.abs(dy)));
|
83
|
+
canvas.save();
|
84
|
+
canvas.clipRRect(box, ClipOp.Intersect, false);
|
85
|
+
const lPaint = Skia.Paint();
|
86
|
+
lPaint.setColor(processColor(color, opacity));
|
87
|
+
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true));
|
88
|
+
const inner = deflate(box, spread, spread, dx, dy);
|
89
|
+
const outer = inflate(box, delta.x, delta.y);
|
90
|
+
canvas.drawDRRect(outer, inner, lPaint);
|
91
|
+
canvas.restore();
|
92
|
+
});
|
93
|
+
});
|
94
|
+
export const Box = props => {
|
95
|
+
return /*#__PURE__*/React.createElement("skDrawing", _extends({
|
96
|
+
onDraw: onDraw
|
97
|
+
}, props));
|
98
|
+
};
|
99
|
+
Box.defaultProps = {
|
100
|
+
shadows: []
|
101
|
+
};
|
102
|
+
//# sourceMappingURL=Box.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["Box.tsx"],"names":["React","ClipOp","BlurStyle","Skia","processColor","createDrawing","add","vec","rrect","rect","isRRect","createDeclaration","inflate","box","dx","dy","tx","ty","x","y","width","height","rx","ry","deflate","onDeclare","spread","blur","color","inner","__typename__","BoxShadow","props","isBoxShadow","s","onDraw","ctx","node","defaultBox","canvas","paint","opacity","shadows","visit","filter","shadow","map","lPaint","Paint","setColor","setMaskFilter","MaskFilter","MakeBlur","Normal","drawRRect","delta","Math","abs","save","clipRRect","Intersect","outer","drawDRRect","restore","Box","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,MAAT,EAA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D,SAAS,CAACmD,MAAnC,EAA2C1B,IAA3C,EAAiD,IAAjD,CADF;AAGA,UAAME,KAAK,GAAGL,OAAO,CAACX,GAAD,EAAMa,MAAN,EAAcA,MAAd,EAAsBZ,EAAtB,EAA0BC,EAA1B,CAArB;AACA,UAAM8C,KAAK,GAAGjD,OAAO,CAACC,GAAD,EAAM0C,KAAK,CAACrC,CAAZ,EAAeqC,KAAK,CAACpC,CAArB,CAArB;AACAoB,IAAAA,MAAM,CAACuB,UAAP,CAAkBD,KAAlB,EAAyBhC,KAAzB,EAAgCkB,MAAhC;AACAR,IAAAA,MAAM,CAACwB,OAAP;AACD,GAhBH;AAiBD,CAlC2B,CAA5B;AAoCA,OAAO,MAAMC,GAAG,GAAIhC,KAAD,IAAoC;AACrD,sBAAO;AAAW,IAAA,MAAM,EAAEG;AAAnB,KAA+BH,KAA/B,EAAP;AACD,CAFM;AAIPgC,GAAG,CAACC,YAAJ,GAAmB;AACjBvB,EAAAA,OAAO,EAAE;AADQ,CAAnB","sourcesContent":["import React from \"react\";\n\nimport type { Color, SkRRect } from \"../../../skia\";\nimport { ClipOp, BlurStyle, Skia, processColor } from \"../../../skia\";\nimport { createDrawing } from \"../../nodes\";\nimport type { AnimatedProps, CustomPaintProps } from \"../../processors\";\nimport { add, vec, rrect } from \"../../processors\";\nimport { rect, isRRect } from \"../../processors/Rects\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { SkJSIInstance } from \"../../../skia/JsiInstance\";\nimport type { SkRect } from \"../../../skia/Rect\";\n\nconst inflate = (box: SkRRect, dx: number, dy: number, tx = 0, ty = 0) =>\n rrect(\n rect(\n box.rect.x - dx + tx,\n box.rect.y - dy + ty,\n box.rect.width + 2 * dx,\n box.rect.height + 2 * dy\n ),\n box.rx + dx,\n box.ry + dy\n );\n\nconst deflate = (box: SkRRect, dx: number, dy: number, tx = 0, ty = 0) =>\n inflate(box, -dx, -dy, tx, ty);\n\ninterface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n\ninterface BoxShadowDecl extends BoxShadowProps, SkJSIInstance<\"BoxShadow\"> {}\n\nconst onDeclare = createDeclaration<BoxShadowProps>(\n ({ dx, dy, spread, blur, color, inner }) => {\n return { dx, dy, spread, blur, color, inner, __typename__: \"BoxShadow\" };\n }\n);\n\nexport const BoxShadow = (props: AnimatedProps<BoxShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nconst isBoxShadow = (s: SkJSIInstance<string>): s is BoxShadowDecl =>\n s.__typename__ === \"BoxShadow\";\n\ninterface BoxProps extends CustomPaintProps {\n box: SkRRect | SkRect;\n}\n\nconst onDraw = createDrawing<BoxProps>((ctx, { box: defaultBox }, node) => {\n const box = isRRect(defaultBox) ? defaultBox : rrect(defaultBox, 0, 0);\n const { canvas, paint, opacity } = ctx;\n const shadows = node.visit(ctx).filter<BoxShadowDecl>(isBoxShadow);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(color, opacity));\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(inflate(box, spread, spread, dx, dy), lPaint);\n });\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = add(vec(10, 10), vec(Math.abs(dx), Math.abs(dy)));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(color, opacity));\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(box, spread, spread, dx, dy);\n const outer = inflate(box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n});\n\nexport const Box = (props: AnimatedProps<BoxProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nBox.defaultProps = {\n shadows: [],\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,QAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd","sourcesContent":["export * from \"./Circle\";\nexport * from \"./Rect\";\nexport * from \"./RoundedRect\";\nexport * from \"./DiffRect\";\nexport * from \"./Line\";\nexport * from \"./Path\";\nexport * from \"./Oval\";\nexport * from \"./Points\";\nexport * from \"./Patch\";\nexport * from \"./Vertices\";\nexport * from \"./Fill\";\nexport * from \"./FitBox\";\n"]}
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,QAAd;AACA,cAAc,eAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd;AACA,cAAc,UAAd;AACA,cAAc,OAAd","sourcesContent":["export * from \"./Circle\";\nexport * from \"./Rect\";\nexport * from \"./RoundedRect\";\nexport * from \"./DiffRect\";\nexport * from \"./Line\";\nexport * from \"./Path\";\nexport * from \"./Oval\";\nexport * from \"./Points\";\nexport * from \"./Patch\";\nexport * from \"./Vertices\";\nexport * from \"./Fill\";\nexport * from \"./FitBox\";\nexport * from \"./Box\";\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd","sourcesContent":["export * from \"./Canvas\";\nexport * from \"./components\";\nexport * from \"./nodes\";\n"]}
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd;AACA,cAAc,oBAAd","sourcesContent":["export * from \"./Canvas\";\nexport * from \"./components\";\nexport * from \"./nodes\";\nexport * from \"./useContextBridge\";\n"]}
|
@@ -1,8 +1,12 @@
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
2
|
|
3
|
+
import { useCallback } from "react";
|
3
4
|
import { isAnimated, materialize } from "../processors";
|
4
5
|
import { Node } from "./Node";
|
5
6
|
export const createDeclaration = cb => cb;
|
7
|
+
export const useDeclaration = (cb, deps) => // eslint-disable-next-line react-hooks/exhaustive-deps
|
8
|
+
useCallback(cb, deps !== null && deps !== void 0 ? deps : []);
|
9
|
+
export const isDeclarationNode = node => node instanceof DeclarationNode;
|
6
10
|
export class DeclarationNode extends Node {
|
7
11
|
constructor(depMgr, onDeclare, props) {
|
8
12
|
super(depMgr, props);
|