@shopify/react-native-skia 2.2.8 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/android/build.gradle +0 -11
  2. package/cpp/api/JsiSkParagraph.h +40 -8
  3. package/lib/commonjs/renderer/Canvas.d.ts +1 -0
  4. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  5. package/lib/commonjs/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
  6. package/lib/commonjs/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
  7. package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +31 -1
  8. package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
  9. package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -2
  10. package/lib/commonjs/skia/web/JsiSkParagraph.js +4 -18
  11. package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
  12. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +3 -3
  13. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  14. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
  15. package/lib/commonjs/views/SkiaPictureView.web.d.ts +10 -6
  16. package/lib/commonjs/views/SkiaPictureView.web.js +253 -20
  17. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  18. package/lib/commonjs/views/types.d.ts +1 -0
  19. package/lib/commonjs/views/types.js.map +1 -1
  20. package/lib/module/renderer/Canvas.d.ts +1 -0
  21. package/lib/module/renderer/Canvas.js.map +1 -1
  22. package/lib/module/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
  23. package/lib/module/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
  24. package/lib/module/skia/types/Paragraph/Paragraph.d.ts +31 -1
  25. package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
  26. package/lib/module/skia/web/JsiSkParagraph.d.ts +2 -2
  27. package/lib/module/skia/web/JsiSkParagraph.js +4 -18
  28. package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
  29. package/lib/module/specs/NativeSkiaModule.web.d.ts +3 -3
  30. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  31. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
  32. package/lib/module/views/SkiaPictureView.web.d.ts +10 -6
  33. package/lib/module/views/SkiaPictureView.web.js +251 -18
  34. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  35. package/lib/module/views/types.d.ts +1 -0
  36. package/lib/module/views/types.js.map +1 -1
  37. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +11 -1
  38. package/lib/typescript/lib/commonjs/views/SkiaPictureView.web.d.ts +1 -6
  39. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
  40. package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +2 -6
  41. package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
  42. package/lib/typescript/src/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
  43. package/lib/typescript/src/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
  44. package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +31 -1
  45. package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +2 -2
  46. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +3 -3
  47. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -2
  48. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +10 -6
  49. package/lib/typescript/src/views/types.d.ts +1 -0
  50. package/package.json +1 -1
  51. package/src/renderer/Canvas.tsx +1 -0
  52. package/src/renderer/__tests__/e2e/ParagraphMethods.spec.tsx +388 -0
  53. package/src/skia/types/Paragraph/Paragraph.ts +32 -1
  54. package/src/skia/web/JsiSkParagraph.ts +19 -28
  55. package/src/specs/NativeSkiaModule.web.ts +4 -4
  56. package/src/views/SkiaPictureView.web.tsx +312 -18
  57. package/src/views/types.ts +4 -0
  58. package/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -40
  59. package/lib/commonjs/views/SkiaBaseWebView.js +0 -143
  60. package/lib/commonjs/views/SkiaBaseWebView.js.map +0 -1
  61. package/lib/module/views/SkiaBaseWebView.d.ts +0 -40
  62. package/lib/module/views/SkiaBaseWebView.js +0 -136
  63. package/lib/module/views/SkiaBaseWebView.js.map +0 -1
  64. package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -39
  65. package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -36
  66. package/lib/typescript/src/views/SkiaBaseWebView.d.ts +0 -40
  67. package/src/views/SkiaBaseWebView.tsx +0 -140
@@ -286,17 +286,6 @@ dependencies {
286
286
  }
287
287
  }
288
288
 
289
- afterEvaluate { project ->
290
- android.libraryVariants.all { variant ->
291
- def name = variant.name.capitalize()
292
- def javaCompileTask = variant.javaCompileProvider.get()
293
-
294
- task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
295
- from javaCompileTask.destinationDir
296
- }
297
- }
298
- }
299
-
300
289
  def localBuildDir = buildDir
301
290
  def headersConfiguration = configurations.extractHeaders
302
291
  def jniConfiguration = configurations.extractJNI
@@ -95,15 +95,47 @@ public:
95
95
  std::vector<para::LineMetrics> metrics;
96
96
  getObject()->getLineMetrics(metrics);
97
97
  auto returnValue = jsi::Array(runtime, metrics.size());
98
- auto height = 0;
98
+
99
99
  for (size_t i = 0; i < metrics.size(); ++i) {
100
- returnValue.setValueAtIndex(
101
- runtime, i,
102
- JsiSkRect::toValue(runtime, getContext(),
103
- SkRect::MakeXYWH(metrics[i].fLeft, height,
104
- metrics[i].fWidth,
105
- metrics[i].fHeight)));
106
- height += metrics[i].fHeight;
100
+ auto lineMetrics = jsi::Object(runtime);
101
+
102
+ // Text indices
103
+ lineMetrics.setProperty(runtime, "startIndex",
104
+ static_cast<double>(metrics[i].fStartIndex));
105
+ lineMetrics.setProperty(runtime, "endIndex",
106
+ static_cast<double>(metrics[i].fEndIndex));
107
+ lineMetrics.setProperty(runtime, "endExcludingWhitespaces",
108
+ static_cast<double>(metrics[i].fEndExcludingWhitespaces));
109
+ lineMetrics.setProperty(runtime, "endIncludingNewline",
110
+ static_cast<double>(metrics[i].fEndIncludingNewline));
111
+
112
+ // Line break info
113
+ lineMetrics.setProperty(runtime, "isHardBreak",
114
+ metrics[i].fHardBreak);
115
+
116
+ // Vertical metrics
117
+ lineMetrics.setProperty(runtime, "ascent",
118
+ static_cast<double>(metrics[i].fAscent));
119
+ lineMetrics.setProperty(runtime, "descent",
120
+ static_cast<double>(metrics[i].fDescent));
121
+ lineMetrics.setProperty(runtime, "height",
122
+ static_cast<double>(metrics[i].fHeight));
123
+
124
+ // Horizontal metrics
125
+ lineMetrics.setProperty(runtime, "width",
126
+ static_cast<double>(metrics[i].fWidth));
127
+ lineMetrics.setProperty(runtime, "left",
128
+ static_cast<double>(metrics[i].fLeft));
129
+
130
+ // Position
131
+ lineMetrics.setProperty(runtime, "baseline",
132
+ static_cast<double>(metrics[i].fBaseline));
133
+
134
+ // Line number
135
+ lineMetrics.setProperty(runtime, "lineNumber",
136
+ static_cast<double>(metrics[i].fLineNumber));
137
+
138
+ returnValue.setValueAtIndex(runtime, i, lineMetrics);
107
139
  }
108
140
  return returnValue;
109
141
  }
@@ -23,5 +23,6 @@ export interface CanvasProps extends Omit<ViewProps, "onLayout"> {
23
23
  onSize?: SharedValue<SkSize>;
24
24
  colorSpace?: "p3" | "srgb";
25
25
  ref?: React.Ref<CanvasRef>;
26
+ __destroyWebGLContextAfterRender?: boolean;
26
27
  }
27
28
  export declare const Canvas: ({ debug, opaque, children, onSize, colorSpace, ref, onLayout, ...viewProps }: CanvasProps) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","_global","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","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","measure","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAgBA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,IAAAM,OAAA;AAAA,SAAAH,uBAAAI,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,SAAAR,wBAAAQ,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,CAAA,SAAAG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,EAAEA;EAAW,GACnBE,SAAS,CACd,CAAC;AAEN,CAAC;AAAC1B,OAAA,CAAAmB,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","_global","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","useCanvasSize","userRef","ourRef","ref","size","setSize","useState","width","height","useLayoutEffect","current","measure","_x","_y","isFabric","Boolean","global","nativeFabricUIManager","Canvas","debug","opaque","children","onSize","colorSpace","onLayout","viewProps","console","error","viewRef","nativeId","useMemo","SkiaViewNativeId","root","SkiaSGRoot","Skia","render","useEffect","unmount","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","callback","_viewRef$current","measureInWindow","_viewRef$current2","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC, RefObject } from \"react\";\nimport React, {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type {\n MeasureInWindowOnSuccessCallback,\n MeasureOnSuccessCallback,\n View,\n ViewProps,\n} from \"react-native\";\nimport { type SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n measure(callback: MeasureOnSuccessCallback): void;\n measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nexport const useCanvasSize = (userRef?: RefObject<CanvasRef | null>) => {\n const ourRef = useCanvasRef();\n const ref = userRef ?? ourRef;\n const [size, setSize] = useState<SkSize>({ width: 0, height: 0 });\n useLayoutEffect(() => {\n if (ref.current) {\n ref.current.measure((_x, _y, width, height) => {\n setSize({ width, height });\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return { ref, size };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isFabric = Boolean((global as any)?.nativeFabricUIManager);\n\nexport interface CanvasProps extends Omit<ViewProps, \"onLayout\"> {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n colorSpace?: \"p3\" | \"srgb\";\n ref?: React.Ref<CanvasRef>;\n __destroyWebGLContextAfterRender?: boolean;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n colorSpace = \"p3\",\n ref,\n // Here know this is a type error but this is done on purpose to check it at runtime\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n onLayout,\n ...viewProps\n}: CanvasProps) => {\n if (onLayout && isFabric) {\n console.error(\n // eslint-disable-next-line max-len\n \"<Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size\"\n );\n }\n const viewRef = useRef<View>(null);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(\n () => new SkiaSGRoot(Skia, nativeId, onSize),\n [nativeId, onSize]\n );\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root, nativeId]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n measure: (callback) => {\n viewRef.current?.measure(callback);\n },\n measureInWindow: (callback) => {\n viewRef.current?.measureInWindow(callback);\n },\n } as CanvasRef)\n );\n\n return (\n <SkiaPictureViewNativeComponent\n ref={viewRef}\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n colorSpace={colorSpace}\n {...viewProps}\n />\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAgBA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA+B,IAAAM,OAAA;AAAA,SAAAH,uBAAAI,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,SAAAR,wBAAAQ,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,C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W,OAAA,CAAA6E,aAAA,CAACpF,+BAAA,CAAAO,OAA8B,EAAAkB,QAAA;IAC7BY,GAAG,EAAEyB,OAAQ;IACbuB,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGvB,QAAQ,EAAG;IACxBV,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfG,UAAU,EAAEA;EAAW,GACnBE,SAAS,CACd,CAAC;AAEN,CAAC;AAAC1B,OAAA,CAAAmB,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -12,7 +12,7 @@ export declare class ParagraphAsset<Ctx extends EvalContext> extends SkiaObject<
12
12
  getLongestLine(): number;
13
13
  getGlyphPositionAtCoordinate(x: number, y: number): number;
14
14
  getRectsForRange(start: number, end: number): import("../../../../skia/types").SkRect[];
15
- getLineMetrics(): import("../../../../skia/types").SkRect[];
15
+ getLineMetrics(): import("../../../../skia/types").LineMetrics[];
16
16
  getRectsForPlaceholders(): import("../../../../skia/types").SkRectWithDirection[];
17
17
  __typename__: "Paragraph";
18
18
  dispose(): void;
@@ -2,6 +2,36 @@ import type { SkCanvas } from "../Canvas";
2
2
  import type { SkJSIInstance } from "../JsiInstance";
3
3
  import type { SkRect } from "../Rect";
4
4
  import type { TextDirection } from "./ParagraphStyle";
5
+ export interface LineMetrics {
6
+ /** The index in the text buffer the line begins. */
7
+ startIndex: number;
8
+ /** The index in the text buffer the line ends. */
9
+ endIndex: number;
10
+ endExcludingWhitespaces: number;
11
+ endIncludingNewline: number;
12
+ /** True if the line ends in a hard break (e.g. newline) */
13
+ isHardBreak: boolean;
14
+ /**
15
+ * The final computed ascent for the line. This can be impacted by
16
+ * the strut, height, scaling, as well as outlying runs that are very tall.
17
+ */
18
+ ascent: number;
19
+ /**
20
+ * The final computed descent for the line. This can be impacted by
21
+ * the strut, height, scaling, as well as outlying runs that are very tall.
22
+ */
23
+ descent: number;
24
+ /** round(ascent + descent) */
25
+ height: number;
26
+ /** width of the line */
27
+ width: number;
28
+ /** The left edge of the line. The right edge can be obtained with `left + width` */
29
+ left: number;
30
+ /** The y position of the baseline for this line from the top of the paragraph. */
31
+ baseline: number;
32
+ /** Zero indexed line number. */
33
+ lineNumber: number;
34
+ }
5
35
  export interface SkRectWithDirection {
6
36
  rect: SkRect;
7
37
  direction: TextDirection;
@@ -70,7 +100,7 @@ export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
70
100
  * Returns the bounding boxes for all lines in the paragraph. This method
71
101
  * requires the layout method to have been called first.
72
102
  */
73
- getLineMetrics(): Array<SkRect>;
103
+ getLineMetrics(): LineMetrics[];
74
104
  /**
75
105
  * Returns a list of rects with direction info for the placeholders added
76
106
  * to the paragraph.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Paragraph.ts"],"sourcesContent":["import type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nimport type { TextDirection } from \"./ParagraphStyle\";\n\nexport interface SkRectWithDirection {\n rect: SkRect;\n direction: TextDirection;\n}\n\nexport interface SkParagraph extends SkJSIInstance<\"Paragraph\"> {\n /**\n * Calculates the position of the the glyphs in the paragraph\n * @param width Max width of the paragraph\n */\n layout(width: number): void;\n /**\n * Paints the paragraph to the provded canvas\n * @param canvas Canvas to paint into\n * @param x X coordinate to paint at\n * @param y Y coordinate to paint at\n */\n paint(canvas: SkCanvas, x: number, y: number): void;\n /**\n * Returns the height of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getHeight(): number;\n /**\n * Returns the max width of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getMaxWidth(): number;\n /**\n * Returns the minimum intrinsic width of the paragraph.\n * The minimum intrinsic width is the width beyond which increasing the width of the paragraph\n * does not decrease the height. This is effectively the width at which the paragraph\n * can no longer wrap lines and is forced to overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The minimum intrinsic width of the paragraph.\n */\n getMinIntrinsicWidth(): number;\n /**\n * Returns the maximum intrinsic width of the paragraph.\n * The maximum intrinsic width is the width at which the paragraph can layout its content without line breaks,\n * meaning it's the width of the widest line or the widest word if the widest line is shorter than that.\n * This width represents the ideal width for the paragraph to display all content in a single line without overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The maximum intrinsic width of the paragraph.\n */\n getMaxIntrinsicWidth(): number;\n\n /**\n * Returns the width of the longest line in the paragraph.\n * This method requires the layout method to have been called first.\n */\n getLongestLine(): number;\n\n /**\n * Returns the index of the glyph at the given position. This method requires\n * the layout method to have been called first.\n * @param x X coordinate of the position\n * @param y Y coordinate of the position\n */\n getGlyphPositionAtCoordinate(x: number, y: number): number;\n /**\n * Returns the bounding boxes of the glyphs in the given range. This method\n * requires the layout method to have been called first.\n * @param start Start index of the range\n * @param end End index of the range\n */\n getRectsForRange(start: number, end: number): SkRect[];\n /**\n * Returns the bounding boxes for all lines in the paragraph. This method\n * requires the layout method to have been called first.\n */\n getLineMetrics(): Array<SkRect>;\n /**\n * Returns a list of rects with direction info for the placeholders added\n * to the paragraph.\n */\n getRectsForPlaceholders(): SkRectWithDirection[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["Paragraph.ts"],"sourcesContent":["import type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nimport type { TextDirection } from \"./ParagraphStyle\";\n\nexport interface LineMetrics {\n /** The index in the text buffer the line begins. */\n startIndex: number;\n /** The index in the text buffer the line ends. */\n endIndex: number;\n endExcludingWhitespaces: number;\n endIncludingNewline: number;\n /** True if the line ends in a hard break (e.g. newline) */\n isHardBreak: boolean;\n /**\n * The final computed ascent for the line. This can be impacted by\n * the strut, height, scaling, as well as outlying runs that are very tall.\n */\n ascent: number;\n /**\n * The final computed descent for the line. This can be impacted by\n * the strut, height, scaling, as well as outlying runs that are very tall.\n */\n descent: number;\n /** round(ascent + descent) */\n height: number;\n /** width of the line */\n width: number;\n /** The left edge of the line. The right edge can be obtained with `left + width` */\n left: number;\n /** The y position of the baseline for this line from the top of the paragraph. */\n baseline: number;\n /** Zero indexed line number. */\n lineNumber: number;\n}\n\nexport interface SkRectWithDirection {\n rect: SkRect;\n direction: TextDirection;\n}\n\nexport interface SkParagraph extends SkJSIInstance<\"Paragraph\"> {\n /**\n * Calculates the position of the the glyphs in the paragraph\n * @param width Max width of the paragraph\n */\n layout(width: number): void;\n /**\n * Paints the paragraph to the provded canvas\n * @param canvas Canvas to paint into\n * @param x X coordinate to paint at\n * @param y Y coordinate to paint at\n */\n paint(canvas: SkCanvas, x: number, y: number): void;\n /**\n * Returns the height of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getHeight(): number;\n /**\n * Returns the max width of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getMaxWidth(): number;\n /**\n * Returns the minimum intrinsic width of the paragraph.\n * The minimum intrinsic width is the width beyond which increasing the width of the paragraph\n * does not decrease the height. This is effectively the width at which the paragraph\n * can no longer wrap lines and is forced to overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The minimum intrinsic width of the paragraph.\n */\n getMinIntrinsicWidth(): number;\n /**\n * Returns the maximum intrinsic width of the paragraph.\n * The maximum intrinsic width is the width at which the paragraph can layout its content without line breaks,\n * meaning it's the width of the widest line or the widest word if the widest line is shorter than that.\n * This width represents the ideal width for the paragraph to display all content in a single line without overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The maximum intrinsic width of the paragraph.\n */\n getMaxIntrinsicWidth(): number;\n\n /**\n * Returns the width of the longest line in the paragraph.\n * This method requires the layout method to have been called first.\n */\n getLongestLine(): number;\n\n /**\n * Returns the index of the glyph at the given position. This method requires\n * the layout method to have been called first.\n * @param x X coordinate of the position\n * @param y Y coordinate of the position\n */\n getGlyphPositionAtCoordinate(x: number, y: number): number;\n /**\n * Returns the bounding boxes of the glyphs in the given range. This method\n * requires the layout method to have been called first.\n * @param start Start index of the range\n * @param end End index of the range\n */\n getRectsForRange(start: number, end: number): SkRect[];\n /**\n * Returns the bounding boxes for all lines in the paragraph. This method\n * requires the layout method to have been called first.\n */\n getLineMetrics(): LineMetrics[];\n /**\n * Returns a list of rects with direction info for the placeholders added\n * to the paragraph.\n */\n getRectsForPlaceholders(): SkRectWithDirection[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { CanvasKit, Paragraph } from "canvaskit-wasm";
2
- import type { SkRect, SkRectWithDirection, SkParagraph } from "../types";
2
+ import type { SkRect, SkRectWithDirection, SkParagraph, LineMetrics } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import type { JsiSkCanvas } from "./JsiSkCanvas";
5
5
  export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> implements SkParagraph {
@@ -14,6 +14,6 @@ export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> i
14
14
  getGlyphPositionAtCoordinate(x: number, y: number): number;
15
15
  getRectsForPlaceholders(): SkRectWithDirection[];
16
16
  getRectsForRange(start: number, end: number): SkRect[];
17
- getLineMetrics(): SkRect[];
17
+ getLineMetrics(): LineMetrics[];
18
18
  dispose(): void;
19
19
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.JsiSkParagraph = void 0;
7
7
  var _Host = require("./Host");
8
+ var _JsiSkRect = require("./JsiSkRect");
8
9
  class JsiSkParagraph extends _Host.HostObject {
9
10
  constructor(CanvasKit, ref) {
10
11
  super(CanvasKit, ref, "Paragraph");
@@ -38,12 +39,7 @@ class JsiSkParagraph extends _Host.HostObject {
38
39
  rect,
39
40
  dir
40
41
  }) => ({
41
- rect: {
42
- x: rect.at(0),
43
- y: rect.at(1),
44
- width: rect.at(2),
45
- height: rect.at(3)
46
- },
42
+ rect: new _JsiSkRect.JsiSkRect(this.CanvasKit, rect),
47
43
  direction: dir.value
48
44
  }));
49
45
  }
@@ -54,20 +50,10 @@ class JsiSkParagraph extends _Host.HostObject {
54
50
  value: 0
55
51
  } /** kTight */).map(({
56
52
  rect
57
- }) => ({
58
- x: rect[0],
59
- y: rect[1],
60
- width: rect[2],
61
- height: rect[3]
62
- }));
53
+ }) => new _JsiSkRect.JsiSkRect(this.CanvasKit, rect));
63
54
  }
64
55
  getLineMetrics() {
65
- return this.ref.getLineMetrics().map((r, index) => ({
66
- x: r.left,
67
- y: index * r.height,
68
- width: r.width,
69
- height: r.height
70
- }));
56
+ return this.ref.getLineMetrics();
71
57
  }
72
58
  dispose() {
73
59
  this.ref.delete();
@@ -1 +1 @@
1
- {"version":3,"names":["_Host","require","JsiSkParagraph","HostObject","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","at","height","direction","value","getRectsForRange","start","end","getLineMetrics","r","index","left","dispose","delete","exports"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkRectWithDirection, SkParagraph } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n getMinIntrinsicWidth(): number {\n return this.ref.getMinIntrinsicWidth();\n }\n\n getMaxIntrinsicWidth(): number {\n return this.ref.getMaxIntrinsicWidth();\n }\n\n getLongestLine(): number {\n return this.ref.getLongestLine();\n }\n\n layout(width: number): void {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number): void {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight(): number {\n return this.ref.getHeight();\n }\n getMaxWidth(): number {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number): number {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: {\n x: rect.at(0)!,\n y: rect.at(1)!,\n width: rect.at(2)!,\n height: rect.at(3)!,\n },\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => ({\n x: rect[0],\n y: rect[1],\n width: rect[2],\n height: rect[3],\n }));\n }\n getLineMetrics(): SkRect[] {\n return this.ref.getLineMetrics().map((r, index) => ({\n x: r.left,\n y: index * r.height,\n width: r.width,\n height: r.height,\n }));\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAGO,MAAMC,cAAc,SACjBC,gBAAU,CAEpB;EACEC,WAAWA,CAACC,SAAoB,EAAEC,GAAc,EAAE;IAChD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,WAAW,CAAC;EACpC;EACAC,oBAAoBA,CAAA,EAAW;IAC7B,OAAO,IAAI,CAACD,GAAG,CAACC,oBAAoB,CAAC,CAAC;EACxC;EAEAC,oBAAoBA,CAAA,EAAW;IAC7B,OAAO,IAAI,CAACF,GAAG,CAACE,oBAAoB,CAAC,CAAC;EACxC;EAEAC,cAAcA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACH,GAAG,CAACG,cAAc,CAAC,CAAC;EAClC;EAEAC,MAAMA,CAACC,KAAa,EAAQ;IAC1B,IAAI,CAACL,GAAG,CAACI,MAAM,CAACC,KAAK,CAAC;EACxB;EACAC,KAAKA,CAACC,MAAmB,EAAEC,CAAS,EAAEC,CAAS,EAAQ;IACrDF,MAAM,CAACP,GAAG,CAACU,aAAa,CAAC,IAAI,CAACV,GAAG,EAAEQ,CAAC,EAAEC,CAAC,CAAC;EAC1C;EACAE,SAAS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A,CAAA,EAAa;IACzB,OAAO,IAAI,CAAC1B,GAAG,CAAC0B,cAAc,CAAC,CAAC,CAACV,GAAG,CAAC,CAACW,CAAC,EAAEC,KAAK,MAAM;MAClDpB,CAAC,EAAEmB,CAAC,CAACE,IAAI;MACTpB,CAAC,EAAEmB,KAAK,GAAGD,CAAC,CAACP,MAAM;MACnBf,KAAK,EAAEsB,CAAC,CAACtB,KAAK;MACde,MAAM,EAAEO,CAAC,CAACP;IACZ,CAAC,CAAC,CAAC;EACL;EAEAU,OAAOA,CAAA,EAAG;IACR,IAAI,CAAC9B,GAAG,CAAC+B,MAAM,CAAC,CAAC;EACnB;AACF;AAACC,OAAA,CAAApC,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Host","require","_JsiSkRect","JsiSkParagraph","HostObject","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","JsiSkRect","direction","value","getRectsForRange","start","end","getLineMetrics","dispose","delete","exports"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type {\n SkRect,\n SkRectWithDirection,\n SkParagraph,\n LineMetrics,\n} from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n getMinIntrinsicWidth() {\n return this.ref.getMinIntrinsicWidth();\n }\n\n getMaxIntrinsicWidth() {\n return this.ref.getMaxIntrinsicWidth();\n }\n\n getLongestLine() {\n return this.ref.getLongestLine();\n }\n\n layout(width: number) {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number) {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight() {\n return this.ref.getHeight();\n }\n getMaxWidth() {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number) {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: new JsiSkRect(this.CanvasKit, rect),\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => new JsiSkRect(this.CanvasKit, rect));\n }\n getLineMetrics(): LineMetrics[] {\n return this.ref.getLineMetrics();\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":";;;;;;AASA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,SACjBC,gBAAU,CAEpB;EACEC,WAAWA,CAACC,SAAoB,EAAEC,GAAc,EAAE;IAChD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,WAAW,CAAC;EACpC;EACAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACD,GAAG,CAACC,oBAAoB,CAAC,CAAC;EACxC;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,GAAG,CAACE,oBAAoB,CAAC,CAAC;EACxC;EAEAC,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,GAAG,CAACG,cAAc,CAAC,CAAC;EAClC;EAEAC,MAAMA,CAACC,KAAa,EAAE;IACpB,IAAI,CAACL,GAAG,CAACI,MAAM,CAACC,KAAK,CAAC;EACxB;EACAC,KAAKA,CAACC,MAAmB,EAAEC,CAAS,EAAEC,CAAS,EAAE;IAC/CF,MAAM,CAACP,GAA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AAA","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  import type { SkPicture } from "../skia/types";
2
2
  import type { ISkiaViewApi } from "../views/types";
3
- import type { SkiaPictureView } from "../views/SkiaPictureView.web";
3
+ import type { SkiaPictureViewHandle } from "../views/SkiaPictureView.web";
4
4
  export type ISkiaViewApiWeb = ISkiaViewApi & {
5
- views: Record<string, SkiaPictureView>;
5
+ views: Record<string, SkiaPictureViewHandle>;
6
6
  deferedPictures: Record<string, SkPicture>;
7
- registerView(nativeId: string, view: SkiaPictureView): void;
7
+ registerView(nativeId: string, view: SkiaPictureViewHandle): void;
8
8
  };
9
9
  declare const _default: {};
10
10
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error","_default","exports","default"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureView } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureView>;\n deferedPictures: Record<string, SkPicture>;\n registerView(nativeId: string, view: SkiaPictureView): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureView) {\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n }\n this.views[nativeId] = view;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n if (!this.views[`${nativeId}`]) {\n this.deferedPictures[`${nativeId}`] = value;\n } else {\n this.views[`${nativeId}`].setPicture(value);\n }\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n this.views[`${nativeId}`].redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n return this.views[`${nativeId}`].makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const result = this.views[`${nativeId}`].makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":";;;;;;AAAA;;AAWAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,IAAqB,EAAE;IACpD;IACA,IAAI,IAAI,CAACJ,eAAe,CAACG,QAAQ,CAAC,EAAE;MAClCC,IAAI,CAACC,UAAU,CAAC,IAAI,CAACL,eAAe,CAACG,QAAQ,CAAc,CAAC;IAC9D;IACA,IAAI,CAACJ,KAAK,CAACI,QAAQ,CAAC,GAAGC,IAAI;EAC7B,CAAC;EACD;EACAE,cAAcA,CAACH,QAAgB,EAAEI,IAAY,EAAEC,KAAU,EAAE;IACzD,IAAID,IAAI,KAAK,SAAS,EAAE;MACtB,IAAI,CAAC,IAAI,CAACR,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,EAAE;QAC9B,IAAI,CAACH,eAAe,CAAC,GAAGG,QAAQ,EAAE,CAAC,GAAGK,KAAK;MAC7C,CAAC,MAAM;QACL,IAAI,CAACT,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACE,UAAU,CAACG,KAAK,CAAC;MAC7C;IACF;EACF,CAAC;EACDC,IAAIA,CAACN,QAAgB,EAAE;IACrB,IAAI,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,EAAE;MAC7B,OAAO,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACO,OAAO,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO;QAAEC,KAAK,EAAE,CAAC;QAAEC,MAAM,EAAE;MAAE,CAAC;IAChC;EACF,CAAC;EACDC,aAAaA,CAACV,QAAgB,EAAE;IAC9B,IAAI,CAACJ,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACW,MAAM,CAAC,CAAC;EACpC,CAAC;EACDC,iBAAiBA,CAACZ,QAAgB,EAAEa,IAAa,EAAE;IACjD,OAAO,IAAI,CAACjB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;EAC1D,CAAC;EACDC,sBAAsBA,CAACd,QAAgB,EAAEa,IAAa,EAAE;IACtD,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,MAAM,GAAG,IAAI,CAACtB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;MAChE,IAAIK,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIE,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["global","SkiaViewApi","views","deferedPictures","web","registerView","nativeId","view","setPicture","setJsiProperty","name","value","size","getSize","width","height","requestRedraw","redraw","makeImageSnapshot","rect","makeImageSnapshotAsync","Promise","resolve","reject","result","Error","_default","exports","default"],"sources":["NativeSkiaModule.web.ts"],"sourcesContent":["/* eslint-disable import/no-anonymous-default-export */\nimport type { SkPicture, SkRect } from \"../skia/types\";\nimport type { ISkiaViewApi } from \"../views/types\";\nimport type { SkiaPictureViewHandle } from \"../views/SkiaPictureView.web\";\n\nexport type ISkiaViewApiWeb = ISkiaViewApi & {\n views: Record<string, SkiaPictureViewHandle>;\n deferedPictures: Record<string, SkPicture>;\n registerView(nativeId: string, view: SkiaPictureViewHandle): void;\n};\n\nglobal.SkiaViewApi = {\n views: {},\n deferedPictures: {},\n web: true,\n registerView(nativeId: string, view: SkiaPictureViewHandle) {\n // Maybe a picture for this view was already set\n if (this.deferedPictures[nativeId]) {\n view.setPicture(this.deferedPictures[nativeId] as SkPicture);\n }\n this.views[nativeId] = view;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setJsiProperty(nativeId: number, name: string, value: any) {\n if (name === \"picture\") {\n if (!this.views[`${nativeId}`]) {\n this.deferedPictures[`${nativeId}`] = value;\n } else {\n this.views[`${nativeId}`].setPicture(value);\n }\n }\n },\n size(nativeId: number) {\n if (this.views[`${nativeId}`]) {\n return this.views[`${nativeId}`].getSize();\n } else {\n return { width: 0, height: 0 };\n }\n },\n requestRedraw(nativeId: number) {\n this.views[`${nativeId}`].redraw();\n },\n makeImageSnapshot(nativeId: number, rect?: SkRect) {\n return this.views[`${nativeId}`].makeImageSnapshot(rect);\n },\n makeImageSnapshotAsync(nativeId: number, rect?: SkRect) {\n return new Promise((resolve, reject) => {\n const result = this.views[`${nativeId}`].makeImageSnapshot(rect);\n if (result) {\n resolve(result);\n } else {\n reject(new Error(\"Failed to make image snapshot\"));\n }\n });\n },\n} as ISkiaViewApiWeb;\n\n// eslint-disable-next-line import/no-default-export\nexport default {};\n"],"mappings":";;;;;;AAAA;;AAWAA,MAAM,CAACC,WAAW,GAAG;EACnBC,KAAK,EAAE,CAAC,CAAC;EACTC,eAAe,EAAE,CAAC,CAAC;EACnBC,GAAG,EAAE,IAAI;EACTC,YAAYA,CAACC,QAAgB,EAAEC,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tD,OAAO,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;MACtC,MAAMC,MAAM,GAAG,IAAI,CAACtB,KAAK,CAAC,GAAGI,QAAQ,EAAE,CAAC,CAACY,iBAAiB,CAACC,IAAI,CAAC;MAChE,IAAIK,MAAM,EAAE;QACVF,OAAO,CAACE,MAAM,CAAC;MACjB,CAAC,MAAM;QACLD,MAAM,CAAC,IAAIE,KAAK,CAAC,+BAA+B,CAAC,CAAC;MACpD;IACF,CAAC,CAAC;EACJ;AACF,CAAoB;;AAEpB;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe,CAAC,CAAC","ignoreList":[]}
@@ -1,9 +1,8 @@
1
1
  import type { ViewProps } from "react-native";
2
- import { SkiaPictureView } from "../views/SkiaPictureView.web";
3
2
  export interface NativeProps extends ViewProps {
4
3
  debug?: boolean;
5
4
  opaque?: boolean;
6
5
  nativeID: string;
7
6
  }
8
- declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").CElement<import("..").SkiaPictureViewNativeProps, SkiaPictureView>;
7
+ declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("..").SkiaPictureViewNativeProps & import("react").RefAttributes<import("../views/SkiaPictureView.web").SkiaPictureViewHandle>>;
9
8
  export default SkiaPictureViewNativeComponent;
@@ -1,9 +1,13 @@
1
- import type { SkCanvas, SkPicture } from "../skia/types";
1
+ import React from "react";
2
+ import type { SkRect, SkPicture, SkImage } from "../skia/types";
2
3
  import type { SkiaPictureViewNativeProps } from "./types";
3
- import { SkiaBaseWebView } from "./SkiaBaseWebView";
4
- export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {
5
- private picture;
6
- constructor(props: SkiaPictureViewNativeProps);
4
+ export interface SkiaPictureViewHandle {
7
5
  setPicture(picture: SkPicture): void;
8
- protected renderInCanvas(canvas: SkCanvas): void;
6
+ getSize(): {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ redraw(): void;
11
+ makeImageSnapshot(rect?: SkRect): SkImage | null;
9
12
  }
13
+ export declare const SkiaPictureView: React.ForwardRefExoticComponent<SkiaPictureViewNativeProps & React.RefAttributes<SkiaPictureViewHandle>>;