@shopify/react-native-skia 0.1.201 → 0.1.203

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 (166) hide show
  1. package/android/CMakeLists.txt +9 -9
  2. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +11 -0
  3. package/cpp/api/JsiSkApi.h +8 -0
  4. package/cpp/api/JsiSkFontMgr.h +54 -0
  5. package/cpp/api/JsiSkFontMgrFactory.h +40 -0
  6. package/cpp/api/JsiSkFontStyle.h +61 -0
  7. package/cpp/api/JsiSkTypeFaceFontProvider.h +80 -0
  8. package/cpp/api/JsiSkTypeFaceFontProviderFactory.h +32 -0
  9. package/cpp/rnskia/RNSkPlatformContext.h +6 -0
  10. package/cpp/rnskia/RNSkView.h +5 -2
  11. package/cpp/skia/include/core/SkColorTable.h +1 -1
  12. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +5 -14
  13. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +7 -56
  14. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +1 -0
  15. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +9 -2
  16. package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.h +31 -0
  17. package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +105 -0
  18. package/lib/commonjs/skia/core/Data.d.ts +2 -0
  19. package/lib/commonjs/skia/core/Data.js +29 -1
  20. package/lib/commonjs/skia/core/Data.js.map +1 -1
  21. package/lib/commonjs/skia/core/Font.d.ts +14 -1
  22. package/lib/commonjs/skia/core/Font.js +93 -1
  23. package/lib/commonjs/skia/core/Font.js.map +1 -1
  24. package/lib/commonjs/skia/types/Font/FontMgr.d.ts +8 -0
  25. package/lib/commonjs/skia/types/Font/FontMgr.js +6 -0
  26. package/lib/commonjs/skia/types/Font/FontMgr.js.map +1 -0
  27. package/lib/commonjs/skia/types/Font/FontMgrFactory.d.ts +4 -0
  28. package/lib/commonjs/skia/types/Font/FontMgrFactory.js +6 -0
  29. package/lib/commonjs/skia/types/Font/FontMgrFactory.js.map +1 -0
  30. package/lib/commonjs/skia/types/Font/index.d.ts +2 -0
  31. package/lib/commonjs/skia/types/Font/index.js +26 -0
  32. package/lib/commonjs/skia/types/Font/index.js.map +1 -1
  33. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProvider.d.ts +10 -0
  34. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProvider.js +6 -0
  35. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProvider.js.map +1 -0
  36. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProviderFactory.d.ts +4 -0
  37. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProviderFactory.js +6 -0
  38. package/lib/commonjs/skia/types/Paragraph/TypefaceFontProviderFactory.js.map +1 -0
  39. package/lib/commonjs/skia/types/Skia.d.ts +4 -1
  40. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  41. package/lib/commonjs/skia/web/Host.d.ts +1 -1
  42. package/lib/commonjs/skia/web/Host.js +0 -2
  43. package/lib/commonjs/skia/web/Host.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkFontMgr.d.ts +10 -0
  45. package/lib/commonjs/skia/web/JsiSkFontMgr.js +34 -0
  46. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -0
  47. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.d.ts +8 -0
  48. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +32 -0
  49. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +1 -0
  50. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +13 -0
  51. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +90 -0
  52. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -0
  53. package/lib/commonjs/skia/web/JsiSkTypefaceFontProviderFactory.d.ts +7 -0
  54. package/lib/commonjs/skia/web/JsiSkTypefaceFontProviderFactory.js +25 -0
  55. package/lib/commonjs/skia/web/JsiSkTypefaceFontProviderFactory.js.map +1 -0
  56. package/lib/commonjs/skia/web/JsiSkia.js +7 -1
  57. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  58. package/lib/module/skia/core/Data.d.ts +2 -0
  59. package/lib/module/skia/core/Data.js +24 -1
  60. package/lib/module/skia/core/Data.js.map +1 -1
  61. package/lib/module/skia/core/Font.d.ts +14 -1
  62. package/lib/module/skia/core/Font.js +83 -1
  63. package/lib/module/skia/core/Font.js.map +1 -1
  64. package/lib/module/skia/types/Font/FontMgr.d.ts +8 -0
  65. package/lib/module/skia/types/Font/FontMgr.js +2 -0
  66. package/lib/module/skia/types/Font/FontMgr.js.map +1 -0
  67. package/lib/module/skia/types/Font/FontMgrFactory.d.ts +4 -0
  68. package/lib/module/skia/types/Font/FontMgrFactory.js +2 -0
  69. package/lib/module/skia/types/Font/FontMgrFactory.js.map +1 -0
  70. package/lib/module/skia/types/Font/index.d.ts +2 -0
  71. package/lib/module/skia/types/Font/index.js +2 -0
  72. package/lib/module/skia/types/Font/index.js.map +1 -1
  73. package/lib/module/skia/types/Paragraph/TypefaceFontProvider.d.ts +10 -0
  74. package/lib/module/skia/types/Paragraph/TypefaceFontProvider.js +2 -0
  75. package/lib/module/skia/types/Paragraph/TypefaceFontProvider.js.map +1 -0
  76. package/lib/module/skia/types/Paragraph/TypefaceFontProviderFactory.d.ts +4 -0
  77. package/lib/module/skia/types/Paragraph/TypefaceFontProviderFactory.js +2 -0
  78. package/lib/module/skia/types/Paragraph/TypefaceFontProviderFactory.js.map +1 -0
  79. package/lib/module/skia/types/Skia.d.ts +4 -1
  80. package/lib/module/skia/types/Skia.js.map +1 -1
  81. package/lib/module/skia/web/Host.d.ts +1 -1
  82. package/lib/module/skia/web/Host.js +0 -2
  83. package/lib/module/skia/web/Host.js.map +1 -1
  84. package/lib/module/skia/web/JsiSkFontMgr.d.ts +10 -0
  85. package/lib/module/skia/web/JsiSkFontMgr.js +24 -0
  86. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -0
  87. package/lib/module/skia/web/JsiSkFontMgrFactory.d.ts +8 -0
  88. package/lib/module/skia/web/JsiSkFontMgrFactory.js +21 -0
  89. package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +1 -0
  90. package/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +13 -0
  91. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +80 -0
  92. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -0
  93. package/lib/module/skia/web/JsiSkTypefaceFontProviderFactory.d.ts +7 -0
  94. package/lib/module/skia/web/JsiSkTypefaceFontProviderFactory.js +14 -0
  95. package/lib/module/skia/web/JsiSkTypefaceFontProviderFactory.js.map +1 -0
  96. package/lib/module/skia/web/JsiSkia.js +5 -1
  97. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  98. package/lib/typescript/src/skia/core/Data.d.ts +2 -0
  99. package/lib/typescript/src/skia/core/Font.d.ts +14 -1
  100. package/lib/typescript/src/skia/types/Font/FontMgr.d.ts +8 -0
  101. package/lib/typescript/src/skia/types/Font/FontMgrFactory.d.ts +4 -0
  102. package/lib/typescript/src/skia/types/Font/index.d.ts +2 -0
  103. package/lib/typescript/src/skia/types/Paragraph/TypefaceFontProvider.d.ts +10 -0
  104. package/lib/typescript/src/skia/types/Paragraph/TypefaceFontProviderFactory.d.ts +4 -0
  105. package/lib/typescript/src/skia/types/Skia.d.ts +4 -1
  106. package/lib/typescript/src/skia/web/Host.d.ts +1 -1
  107. package/lib/typescript/src/skia/web/JsiSkFontMgr.d.ts +10 -0
  108. package/lib/typescript/src/skia/web/JsiSkFontMgrFactory.d.ts +8 -0
  109. package/lib/typescript/src/skia/web/JsiSkTypefaceFontProvider.d.ts +13 -0
  110. package/lib/typescript/src/skia/web/JsiSkTypefaceFontProviderFactory.d.ts +7 -0
  111. package/libs/android/arm64-v8a/libskia.a +0 -0
  112. package/libs/android/arm64-v8a/libskottie.a +0 -0
  113. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  114. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  115. package/libs/android/arm64-v8a/libskunicode.a +0 -0
  116. package/libs/android/armeabi-v7a/libskia.a +0 -0
  117. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  118. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  119. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  120. package/libs/android/armeabi-v7a/libskunicode.a +0 -0
  121. package/libs/android/x86/libskia.a +0 -0
  122. package/libs/android/x86/libskottie.a +0 -0
  123. package/libs/android/x86/libskparagraph.a +0 -0
  124. package/libs/android/x86/libskshaper.a +0 -0
  125. package/libs/android/x86/libskunicode.a +0 -0
  126. package/libs/android/x86_64/libskia.a +0 -0
  127. package/libs/android/x86_64/libskottie.a +0 -0
  128. package/libs/android/x86_64/libskparagraph.a +0 -0
  129. package/libs/android/x86_64/libskshaper.a +0 -0
  130. package/libs/android/x86_64/libskunicode.a +0 -0
  131. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  132. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  133. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  134. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  135. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  136. package/libs/ios/libskparagraph.xcframework/Info.plist +42 -0
  137. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  138. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  139. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  140. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  141. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  142. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  143. package/libs/ios/libskunicode.xcframework/Info.plist +42 -0
  144. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  145. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  146. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  147. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  148. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  149. package/package.json +3 -1
  150. package/react-native-skia.podspec +2 -2
  151. package/src/skia/core/Data.ts +31 -1
  152. package/src/skia/core/Font.ts +109 -2
  153. package/src/skia/types/Font/FontMgr.ts +10 -0
  154. package/src/skia/types/Font/FontMgrFactory.ts +5 -0
  155. package/src/skia/types/Font/index.ts +2 -0
  156. package/src/skia/types/Paragraph/TypefaceFontProvider.ts +11 -0
  157. package/src/skia/types/Paragraph/TypefaceFontProviderFactory.ts +5 -0
  158. package/src/skia/types/Skia.ts +4 -2
  159. package/src/skia/web/Host.ts +1 -1
  160. package/src/skia/web/JsiSkFontMgr.ts +26 -0
  161. package/src/skia/web/JsiSkFontMgrFactory.ts +22 -0
  162. package/src/skia/web/JsiSkTypefaceFontProvider.ts +89 -0
  163. package/src/skia/web/JsiSkTypefaceFontProviderFactory.ts +18 -0
  164. package/src/skia/web/JsiSkia.ts +4 -0
  165. package/ios/RNSkia-iOS/SkiaMetalRenderer.h +0 -5
  166. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +0 -55
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkFontMgrFactory = void 0;
7
+
8
+ var _Host = require("./Host");
9
+
10
+ var _JsiSkFontMgr = require("./JsiSkFontMgr");
11
+
12
+ class JsiSkFontMgrFactory extends _Host.Host {
13
+ constructor(CanvasKit) {
14
+ super(CanvasKit);
15
+ }
16
+
17
+ System() {
18
+ const fontMgr = this.CanvasKit.TypefaceFontProvider.Make();
19
+
20
+ if (!fontMgr) {
21
+ throw new Error("Couldn't create system font manager");
22
+ } // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-expect-error
24
+
25
+
26
+ return new _JsiSkFontMgr.JsiSkFontMgr(this.CanvasKit, fontMgr);
27
+ }
28
+
29
+ }
30
+
31
+ exports.JsiSkFontMgrFactory = JsiSkFontMgrFactory;
32
+ //# sourceMappingURL=JsiSkFontMgrFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkFontMgrFactory","Host","constructor","CanvasKit","System","fontMgr","TypefaceFontProvider","Make","Error","JsiSkFontMgr"],"sources":["JsiSkFontMgrFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { FontMgrFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkFontMgr } from \"./JsiSkFontMgr\";\n\nexport class JsiSkFontMgrFactory extends Host implements FontMgrFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n System() {\n const fontMgr = this.CanvasKit.TypefaceFontProvider.Make();\n if (!fontMgr) {\n throw new Error(\"Couldn't create system font manager\");\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n return new JsiSkFontMgr(this.CanvasKit, fontMgr);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,MAAM,GAAG;IACP,MAAMC,OAAO,GAAG,KAAKF,SAAL,CAAeG,oBAAf,CAAoCC,IAApC,EAAhB;;IACA,IAAI,CAACF,OAAL,EAAc;MACZ,MAAM,IAAIG,KAAJ,CAAU,qCAAV,CAAN;IACD,CAJM,CAKP;IACA;;;IACA,OAAO,IAAIC,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCE,OAAjC,CAAP;EACD;;AAbqE"}
@@ -0,0 +1,13 @@
1
+ import type { CanvasKit, TypefaceFontProvider } from "canvaskit-wasm";
2
+ import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
3
+ import type { FontStyle, SkTypeface } from "../types";
4
+ import { HostObject } from "./Host";
5
+ export declare class JsiSkTypefaceFontProvider extends HostObject<TypefaceFontProvider, "FontMgr"> implements SkTypefaceFontProvider {
6
+ private allocatedPointers;
7
+ constructor(CanvasKit: CanvasKit, ref: TypefaceFontProvider);
8
+ matchFamilyStyle(_name: string, _style: FontStyle): SkTypeface;
9
+ countFamilies(): any;
10
+ getFamilyName(index: number): any;
11
+ registerFont(typeface: SkTypeface, familyName: string): void;
12
+ dispose(): void;
13
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkTypefaceFontProvider = void 0;
7
+
8
+ var _Host = require("./Host");
9
+
10
+ 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; }
11
+
12
+ class JsiSkTypefaceFontProvider extends _Host.HostObject {
13
+ constructor(CanvasKit, ref) {
14
+ super(CanvasKit, ref, "FontMgr");
15
+
16
+ _defineProperty(this, "allocatedPointers", []);
17
+ }
18
+
19
+ matchFamilyStyle(_name, _style) {
20
+ throw new _Host.NotImplementedOnRNWeb();
21
+ }
22
+
23
+ countFamilies() {
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-expect-error
26
+ return this.ref.countFamilies();
27
+ }
28
+
29
+ getFamilyName(index) {
30
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
31
+ // @ts-expect-error
32
+ return this.ref.getFamilyName(index);
33
+ }
34
+
35
+ registerFont(typeface, familyName) {
36
+ const strLen = lengthBytesUTF8(familyName) + 1; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
37
+ // @ts-expect-error
38
+
39
+ const strPtr = this.CanvasKit._malloc(strLen);
40
+
41
+ stringToUTF8(this.CanvasKit, familyName, strPtr, strLen); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
+ // @ts-expect-error
43
+
44
+ this.ref._registerFont(typeface.ref, strPtr);
45
+ }
46
+
47
+ dispose() {
48
+ for (const ptr of this.allocatedPointers) {
49
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
+ // @ts-expect-error
51
+ this.CanvasKit._free(ptr);
52
+ }
53
+
54
+ this.ref.delete();
55
+ }
56
+
57
+ }
58
+
59
+ exports.JsiSkTypefaceFontProvider = JsiSkTypefaceFontProvider;
60
+
61
+ const lengthBytesUTF8 = str => {
62
+ // TextEncoder will give us the byte length in UTF8 form
63
+ const encoder = new TextEncoder();
64
+ const utf8 = encoder.encode(str);
65
+ return utf8.length;
66
+ };
67
+
68
+ const stringToUTF8 = (CanvasKit, str, outPtr, maxBytesToWrite) => {
69
+ // TextEncoder will give us the byte array in UTF8 form
70
+ const encoder = new TextEncoder();
71
+ const utf8 = encoder.encode(str); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72
+ // @ts-expect-error
73
+
74
+ const heap = CanvasKit.HEAPU8; // Check if there's enough space
75
+
76
+ if (utf8.length > maxBytesToWrite) {
77
+ throw new Error("Not enough space to write UTF8 encoded string");
78
+ } // Copy the bytes
79
+
80
+
81
+ for (let i = 0; i < utf8.length; i++) {
82
+ heap[outPtr + i] = utf8[i];
83
+ } // Null terminate
84
+
85
+
86
+ if (utf8.length < maxBytesToWrite) {
87
+ heap[outPtr + utf8.length] = 0;
88
+ }
89
+ };
90
+ //# sourceMappingURL=JsiSkTypefaceFontProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkTypefaceFontProvider","HostObject","constructor","CanvasKit","ref","matchFamilyStyle","_name","_style","NotImplementedOnRNWeb","countFamilies","getFamilyName","index","registerFont","typeface","familyName","strLen","lengthBytesUTF8","strPtr","_malloc","stringToUTF8","_registerFont","dispose","ptr","allocatedPointers","_free","delete","str","encoder","TextEncoder","utf8","encode","length","outPtr","maxBytesToWrite","heap","HEAPU8","Error","i"],"sources":["JsiSkTypefaceFontProvider.ts"],"sourcesContent":["import type { CanvasKit, TypefaceFontProvider } from \"canvaskit-wasm\";\n\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\nimport type { FontStyle, SkTypeface } from \"../types\";\n\nimport { HostObject, NotImplementedOnRNWeb } from \"./Host\";\n\nexport class JsiSkTypefaceFontProvider\n extends HostObject<TypefaceFontProvider, \"FontMgr\">\n implements SkTypefaceFontProvider\n{\n private allocatedPointers: number[] = [];\n\n constructor(CanvasKit: CanvasKit, ref: TypefaceFontProvider) {\n super(CanvasKit, ref, \"FontMgr\");\n }\n\n matchFamilyStyle(_name: string, _style: FontStyle): SkTypeface {\n throw new NotImplementedOnRNWeb();\n }\n countFamilies() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n return this.ref.countFamilies();\n }\n getFamilyName(index: number) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n return this.ref.getFamilyName(index);\n }\n registerFont(typeface: SkTypeface, familyName: string) {\n const strLen = lengthBytesUTF8(familyName) + 1;\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n const strPtr = this.CanvasKit._malloc(strLen);\n stringToUTF8(this.CanvasKit, familyName, strPtr, strLen);\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n this.ref._registerFont(typeface.ref, strPtr);\n }\n\n dispose() {\n for (const ptr of this.allocatedPointers) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n this.CanvasKit._free(ptr);\n }\n\n this.ref.delete();\n }\n}\n\nconst lengthBytesUTF8 = (str: string) => {\n // TextEncoder will give us the byte length in UTF8 form\n const encoder = new TextEncoder();\n const utf8 = encoder.encode(str);\n return utf8.length;\n};\n\nconst stringToUTF8 = (\n CanvasKit: CanvasKit,\n str: string,\n outPtr: number,\n maxBytesToWrite: number\n) => {\n // TextEncoder will give us the byte array in UTF8 form\n const encoder = new TextEncoder();\n const utf8 = encoder.encode(str);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n const heap: Int8Array = CanvasKit.HEAPU8;\n\n // Check if there's enough space\n if (utf8.length > maxBytesToWrite) {\n throw new Error(\"Not enough space to write UTF8 encoded string\");\n }\n\n // Copy the bytes\n for (let i = 0; i < utf8.length; i++) {\n heap[outPtr + i] = utf8[i];\n }\n\n // Null terminate\n if (utf8.length < maxBytesToWrite) {\n heap[outPtr + utf8.length] = 0;\n }\n};\n"],"mappings":";;;;;;;AAKA;;;;AAEO,MAAMA,yBAAN,SACGC,gBADH,CAGP;EAGEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkD;IAC3D,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,SAAtB;;IAD2D,2CAFvB,EAEuB;EAE5D;;EAEDC,gBAAgB,CAACC,KAAD,EAAgBC,MAAhB,EAA+C;IAC7D,MAAM,IAAIC,2BAAJ,EAAN;EACD;;EACDC,aAAa,GAAG;IACd;IACA;IACA,OAAO,KAAKL,GAAL,CAASK,aAAT,EAAP;EACD;;EACDC,aAAa,CAACC,KAAD,EAAgB;IAC3B;IACA;IACA,OAAO,KAAKP,GAAL,CAASM,aAAT,CAAuBC,KAAvB,CAAP;EACD;;EACDC,YAAY,CAACC,QAAD,EAAuBC,UAAvB,EAA2C;IACrD,MAAMC,MAAM,GAAGC,eAAe,CAACF,UAAD,CAAf,GAA8B,CAA7C,CADqD,CAGrD;IACA;;IACA,MAAMG,MAAM,GAAG,KAAKd,SAAL,CAAee,OAAf,CAA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,GAAcE,eAAlB,EAAmC;IACjCC,IAAI,CAACF,MAAM,GAAGH,IAAI,CAACE,MAAf,CAAJ,GAA6B,CAA7B;EACD;AACF,CA3BD"}
@@ -0,0 +1,7 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import { Host } from "./Host";
3
+ import { JsiSkTypefaceFontProvider } from "./JsiSkTypefaceFontProvider";
4
+ export declare class JsiSkTypefaceFontProviderFactory extends Host implements JsiSkTypefaceFontProviderFactory {
5
+ constructor(CanvasKit: CanvasKit);
6
+ Make(): JsiSkTypefaceFontProvider;
7
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkTypefaceFontProviderFactory = void 0;
7
+
8
+ var _Host = require("./Host");
9
+
10
+ var _JsiSkTypefaceFontProvider = require("./JsiSkTypefaceFontProvider");
11
+
12
+ class JsiSkTypefaceFontProviderFactory extends _Host.Host {
13
+ constructor(CanvasKit) {
14
+ super(CanvasKit);
15
+ }
16
+
17
+ Make() {
18
+ const tf = this.CanvasKit.TypefaceFontProvider.Make();
19
+ return new _JsiSkTypefaceFontProvider.JsiSkTypefaceFontProvider(this.CanvasKit, tf);
20
+ }
21
+
22
+ }
23
+
24
+ exports.JsiSkTypefaceFontProviderFactory = JsiSkTypefaceFontProviderFactory;
25
+ //# sourceMappingURL=JsiSkTypefaceFontProviderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkTypefaceFontProviderFactory","Host","constructor","CanvasKit","Make","tf","TypefaceFontProvider","JsiSkTypefaceFontProvider"],"sources":["JsiSkTypefaceFontProviderFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkTypefaceFontProvider } from \"./JsiSkTypefaceFontProvider\";\n\nexport class JsiSkTypefaceFontProviderFactory\n extends Host\n implements JsiSkTypefaceFontProviderFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make() {\n const tf = this.CanvasKit.TypefaceFontProvider.Make();\n return new JsiSkTypefaceFontProvider(this.CanvasKit, tf);\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEO,MAAMA,gCAAN,SACGC,UADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,GAAG;IACL,MAAMC,EAAE,GAAG,KAAKF,SAAL,CAAeG,oBAAf,CAAoCF,IAApC,EAAX;IACA,OAAO,IAAIG,oDAAJ,CAA8B,KAAKJ,SAAnC,EAA8CE,EAA9C,CAAP;EACD;;AARH"}
@@ -59,6 +59,10 @@ var _JsiSkPath = require("./JsiSkPath");
59
59
 
60
60
  var _JsiSkTypeface = require("./JsiSkTypeface");
61
61
 
62
+ var _JsiSkTypefaceFontProviderFactory = require("./JsiSkTypefaceFontProviderFactory");
63
+
64
+ var _JsiSkFontMgrFactory = require("./JsiSkFontMgrFactory");
65
+
62
66
  const JsiSkApi = CanvasKit => ({
63
67
  Point: (x, y) => new _JsiSkPoint.JsiSkPoint(CanvasKit, Float32Array.of(x, y)),
64
68
  RuntimeShaderBuilder: _ => {
@@ -93,7 +97,9 @@ const JsiSkApi = CanvasKit => ({
93
97
  XYWHRect: (x, y, width, height) => {
94
98
  return new _JsiSkRect.JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));
95
99
  },
96
- Surface: new _JsiSkSurfaceFactory.JsiSkSurfaceFactory(CanvasKit)
100
+ Surface: new _JsiSkSurfaceFactory.JsiSkSurfaceFactory(CanvasKit),
101
+ TypefaceFontProvider: new _JsiSkTypefaceFontProviderFactory.JsiSkTypefaceFontProviderFactory(CanvasKit),
102
+ FontMgr: new _JsiSkFontMgrFactory.JsiSkFontMgrFactory(CanvasKit)
97
103
  });
98
104
 
99
105
  exports.JsiSkApi = JsiSkApi;
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkApi","CanvasKit","Point","x","y","JsiSkPoint","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","JsiSkRRect","RSXform","scos","ssin","tx","ty","JsiSkRSXform","Color","ContourMeasureIter","path","forceClosed","resScale","JsiSkContourMeasureIter","JsiSkPath","fromValue","Paint","paint","JsiSkPaint","setAntiAlias","PictureRecorder","JsiSkPictureRecorder","Picture","JsiSkPictureFactory","Path","JsiSkPathFactory","Matrix","matrix","JsiSkMatrix","identity","ColorFilter","JsiSkColorFilterFactory","Font","typeface","size","JsiSkFont","undefined","JsiSkTypeface","Typeface","JsiSkTypefaceFactory","MaskFilter","JsiSkMaskFilterFactory","RuntimeEffect","JsiSkRuntimeEffectFactory","ImageFilter","JsiSkImageFilterFactory","Shader","JsiSkShaderFactory","PathEffect","JsiSkPathEffectFactory","MakeVertices","bind","Data","JsiSkDataFactory","Image","JsiSkImageFactory","SVG","JsiSkSVGFactory","TextBlob","JsiSkTextBlobFactory","XYWHRect","width","height","JsiSkRect","Surface","JsiSkSurfaceFactory"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,QAAQ,GAAIC,SAAD,KAAiC;EACvDC,KAAK,EAAE,CAACC,CAAD,EAAYC,CAAZ,KACL,IAAIC,sBAAJ,CAAeJ,SAAf,EAA0BK,Y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,EAAE,CAACvE,CAAD,EAAYC,CAAZ,EAAuBuE,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAIC,oBAAJ,CAAc5E,SAAd,EAAyBA,SAAS,CAACyE,QAAV,CAAmBvE,CAAnB,EAAsBC,CAAtB,EAAyBuE,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA9DsD;EA+DvDE,OAAO,EAAE,IAAIC,wCAAJ,CAAwB9E,SAAxB;AA/D8C,CAAjC,CAAjB"}
1
+ {"version":3,"names":["JsiSkApi","CanvasKit","Point","x","y","JsiSkPoint","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","JsiSkRRect","RSXform","scos","ssin","tx","ty","JsiSkRSXform","Color","ContourMeasureIter","path","forceClosed","resScale","JsiSkContourMeasureIter","JsiSkPath","fromValue","Paint","paint","JsiSkPaint","setAntiAlias","PictureRecorder","JsiSkPictureRecorder","Picture","JsiSkPictureFactory","Path","JsiSkPathFactory","Matrix","matrix","JsiSkMatrix","identity","ColorFilter","JsiSkColorFilterFactory","Font","typeface","size","JsiSkFont","undefined","JsiSkTypeface","Typeface","JsiSkTypefaceFactory","MaskFilter","JsiSkMaskFilterFactory","RuntimeEffect","JsiSkRuntimeEffectFactory","ImageFilter","JsiSkImageFilterFactory","Shader","JsiSkShaderFactory","PathEffect","JsiSkPathEffectFactory","MakeVertices","bind","Data","JsiSkDataFactory","Image","JsiSkImageFactory","SVG","JsiSkSVGFactory","TextBlob","JsiSkTextBlobFactory","XYWHRect","width","height","JsiSkRect","Surface","JsiSkSurfaceFactory","TypefaceFontProvider","JsiSkTypefaceFontProviderFactory","FontMgr","JsiSkFontMgrFactory"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\nimport { JsiSkTypefaceFontProviderFactory } from \"./JsiSkTypefaceFontProviderFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n});\n"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,QAAQ,GAAIC,SAAD,KAAiC;EACvDC,KAAK,EAAE,CAACC,CAAD,EAAYC,CAAZ,KACL,IAAIC,sBAAJ,CAAeJ,SAAf,EAA0BK,YAAY,CAACC,EAAb,CAAgBJ,CAAhB,EAAmBC,CAAnB,CAA1B,CAFqD;EAGvDI,oBAAoB,EAAGC,CAAD,IAAgD;IACpE,MAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;EACD,CALsD;EAMvDC,OAAO,EAAE,CAACC,IAAD,EAAeC,EAAf,EAA2BC,EAA3B,KACP,IAAIC,sBAAJ,CAAed,SAAf,EAA0BW,IAA1B,EAAgCC,EAAhC,EAAoCC,EAApC,CAPqD;EAQvDE,OAAO,EAAE,CAACC,IAAD,EAAeC,IAAf,EAA6BC,EAA7B,EAAyCC,EAAzC,KACP,IAAIC,0BAAJ,CAAiBpB,SAAjB,EAA4BK,YAAY,CAACC,EAAb,CAAgBU,IAAhB,EAAsBC,IAAtB,EAA4BC,EAA5B,EAAgCC,EAAhC,CAA5B,CATqD;EAUvDE,KAAK,EAALA,iBAVuD;EAWvDC,kBAAkB,EAAE,CAClBC,IADkB,EAElBC,WAFkB,EAGlBC,QAHkB,KAKlB,IA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EAmDvDuD,aAAa,EAAE,IAAIC,oDAAJ,CAA8BxD,SAA9B,CAnDwC;EAoDvDyD,WAAW,EAAE,IAAIC,gDAAJ,CAA4B1D,SAA5B,CApD0C;EAqDvD2D,MAAM,EAAE,IAAIC,sCAAJ,CAAuB5D,SAAvB,CArD+C;EAsDvD6D,UAAU,EAAE,IAAIC,8CAAJ,CAA2B9D,SAA3B,CAtD2C;EAuDvD+D,YAAY,EAAEA,kCAAA,CAAaC,IAAb,CAAkB,IAAlB,EAAwBhE,SAAxB,CAvDyC;EAwDvDiE,IAAI,EAAE,IAAIC,kCAAJ,CAAqBlE,SAArB,CAxDiD;EAyDvDmE,KAAK,EAAE,IAAIC,oCAAJ,CAAsBpE,SAAtB,CAzDgD;EA0DvDqE,GAAG,EAAE,IAAIC,gCAAJ,CAAoBtE,SAApB,CA1DkD;EA2DvDuE,QAAQ,EAAE,IAAIC,0CAAJ,CAAyBxE,SAAzB,CA3D6C;EA4DvDyE,QAAQ,EAAE,CAACvE,CAAD,EAAYC,CAAZ,EAAuBuE,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAIC,oBAAJ,CAAc5E,SAAd,EAAyBA,SAAS,CAACyE,QAAV,CAAmBvE,CAAnB,EAAsBC,CAAtB,EAAyBuE,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA9DsD;EA+DvDE,OAAO,EAAE,IAAIC,wCAAJ,CAAwB9E,SAAxB,CA/D8C;EAgEvD+E,oBAAoB,EAAE,IAAIC,kEAAJ,CAAqChF,SAArC,CAhEiC;EAiEvDiF,OAAO,EAAE,IAAIC,wCAAJ,CAAwBlF,SAAxB;AAjE8C,CAAjC,CAAjB"}
@@ -1,3 +1,5 @@
1
1
  import type { SkData, DataSourceParam, SkJSIInstance } from "../types";
2
+ export declare const loadData: <T>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined) => Promise<T | null>;
3
+ export declare const useCollectionLoading: <T extends SkJSIInstance<string>>(source: DataSourceParam[], loader: () => Promise<(T | null)[]>) => T[] | null;
2
4
  export declare const useRawData: <T extends SkJSIInstance<string>>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: ((err: Error) => void) | undefined) => T | null;
3
5
  export declare const useData: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkData | null;
@@ -13,7 +13,7 @@ const factoryWrapper = (data2, factory, onError) => {
13
13
  }
14
14
  };
15
15
 
16
- const loadData = (source, factory, onError) => {
16
+ export const loadData = (source, factory, onError) => {
17
17
  if (source === null || source === undefined) {
18
18
  return new Promise(resolve => resolve(null));
19
19
  } else if (source instanceof Uint8Array) {
@@ -46,6 +46,29 @@ const useLoading = (source, loader) => {
46
46
  return data;
47
47
  };
48
48
 
49
+ export const useCollectionLoading = (source, loader) => {
50
+ const mounted = useRef(false);
51
+ const [data, setData] = useState(null);
52
+ const dataRef = useRef(null);
53
+ useEffect(() => {
54
+ mounted.current = true;
55
+ loader().then(result => {
56
+ const value = result.filter(r => r !== null);
57
+
58
+ if (mounted.current) {
59
+ setData(value);
60
+ dataRef.current = value;
61
+ }
62
+ });
63
+ return () => {
64
+ var _dataRef$current2;
65
+
66
+ (_dataRef$current2 = dataRef.current) === null || _dataRef$current2 === void 0 ? void 0 : _dataRef$current2.forEach(instance => instance === null || instance === void 0 ? void 0 : instance.dispose());
67
+ mounted.current = false;
68
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ }, [source]);
70
+ return data;
71
+ };
49
72
  export const useRawData = (source, factory, onError) => useLoading(source, () => loadData(source, factory, onError));
50
73
 
51
74
  const identity = data => data;
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","useState","Skia","Platform","factoryWrapper","data2","factory","onError","factoryResult","Error","loadData","source","undefined","Promise","resolve","Uint8Array","Data","fromBytes","uri","resolveAsset","fromURI","then","d","useLoading","loader","mounted","data","setData","dataRef","current","value","dispose","useRawData","identity","useData"],"sources":["Data.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSourceParam, SkJSIInstance } from \"../types\";\nimport { Platform } from \"../../Platform\";\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nconst loadData = <T>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source === null || source === undefined) {\n return new Promise((resolve) => resolve(null));\n } else if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri =\n typeof source === \"string\" ? source : Platform.resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\nconst useLoading = <T extends SkJSIInstance<string>>(\n source: DataSourceParam,\n loader: () => Promise<T | null>\n) => {\n const mounted = useRef(false);\n const [data, setData] = useState<T | null>(null);\n const dataRef = useRef<T | null>(null);\n useEffect(() => {\n mounted.current = true;\n loader().then((value) => {\n if (mounted.current) {\n setData(value);\n dataRef.current = value;\n }\n });\n return () => {\n dataRef.current?.dispose();\n mounted.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source]);\n return data;\n};\n\nexport const useRawData = <T extends SkJSIInstance<string>>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n) => useLoading(source, () => loadData<T>(source, factory, onError));\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, identity, onError);\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,OAA5C;AAEA,SAASC,IAAT,QAAqB,SAArB;AAEA,SAASC,QAAT,QAAyB,gBA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,CAAW,IAAX,CAAhC;EACA,MAAM2B,OAAO,GAAG5B,MAAM,CAAW,IAAX,CAAtB;EACAD,SAAS,CAAC,MAAM;IACd0B,OAAO,CAACI,OAAR,GAAkB,IAAlB;IACAL,MAAM,GAAGH,IAAT,CAAeS,KAAD,IAAW;MACvB,IAAIL,OAAO,CAACI,OAAZ,EAAqB;QACnBF,OAAO,CAACG,KAAD,CAAP;QACAF,OAAO,CAACC,OAAR,GAAkBC,KAAlB;MACD;IACF,CALD;IAMA,OAAO,MAAM;MAAA;;MACX,oBAAAF,OAAO,CAACC,OAAR,sEAAiBE,OAAjB;MACAN,OAAO,CAACI,OAAR,GAAkB,KAAlB;IACD,CAHD,CARc,CAYd;EACD,CAbQ,EAaN,CAAClB,MAAD,CAbM,CAAT;EAcA,OAAOe,IAAP;AACD,CAtBD;;AAwBA,OAAO,MAAMM,UAAU,GAAG,CACxBrB,MADwB,EAExBL,OAFwB,EAGxBC,OAHwB,KAIrBgB,UAAU,CAACZ,MAAD,EAAS,MAAMD,QAAQ,CAAIC,MAAJ,EAAYL,OAAZ,EAAqBC,OAArB,CAAvB,CAJR;;AAMP,MAAM0B,QAAQ,GAAIP,IAAD,IAAkBA,IAAnC;;AAEA,OAAO,MAAMQ,OAAO,GAAG,CACrBvB,MADqB,EAErBJ,OAFqB,KAGlByB,UAAU,CAACrB,MAAD,EAASsB,QAAT,EAAmB1B,OAAnB,CAHR"}
1
+ {"version":3,"names":["useEffect","useRef","useState","Skia","Platform","factoryWrapper","data2","factory","onError","factoryResult","Error","loadData","source","undefined","Promise","resolve","Uint8Array","Data","fromBytes","uri","resolveAsset","fromURI","then","d","useLoading","loader","mounted","data","setData","dataRef","current","value","dispose","useCollectionLoading","result","filter","r","forEach","instance","useRawData","identity","useData"],"sources":["Data.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSourceParam, SkJSIInstance } from \"../types\";\nimport { Platform } from \"../../Platform\";\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nexport const loadData = <T>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source === null || source === undefined) {\n return new Promise((resolve) => resolve(null));\n } else if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri =\n typeof source === \"string\" ? source : Platform.resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\n\nconst useLoading = <T extends SkJSIInstance<string>>(\n source: DataSourceParam,\n loader: () => Promise<T | null>\n) => {\n const mounted = useRef(false);\n const [data, setData] = useState<T | null>(null);\n const dataRef = useRef<T | null>(null);\n useEffect(() => {\n mounted.current = true;\n loader().then((value) => {\n if (mounted.current) {\n setData(value);\n dataRef.current = value;\n }\n });\n return () => {\n dataRef.current?.dispose();\n mounted.current = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source]);\n return data;\n};\n\nexport const useCollectionLoading = <T extends SkJSIInstance<string>>(\n source: DataSourceParam[],\n loader: () => Promise<(T | null)[]>\n) => {\n const mounted = useRef(false);\n const [data, setData] = useState<T[] | null>(null);\n const dataRef = useRef<T[] | null>(null);\n\n useEffect(() => {\n mounted.current = true;\n loader().then((result) => {\n const value = result.filter((r) => r !== null) as T[];\n if (mounted.current) {\n setData(value);\n dataRef.current = value;\n }\n });\n\n return () => {\n dataRef.current?.forEach((instance) => instance?.dispose());\n mounted.current = false;\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source]);\n\n return data;\n};\n\nexport const useRawData = <T extends SkJSIInstance<string>>(\n source: DataSourceParam,\n factory: (data: SkData) => T | null,\n onError?: (err: Error) => void\n) => useLoading(source, () => loadData<T>(source, factory, onError));\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, identity, onError);\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,OAA5C;AAEA,SAASC,IAAT,QAAqB,SAArB;AAEA,SAASC,QAAT,QAAyB,gBAAzB;;AAEA,MAAMC,cAAc,GAAG,CACrBC,KADqB,EAErBC,OAFqB,EAGrBC,OAHqB,KAIlB;EACH,MAAMC,aAAa,GAAGF,OAAO,CAACD,KAAD,CAA7B;;EACA,IAAIG,aAAa,KAAK,IAAtB,EAA4B;IAC1BD,OAAO,IAAIA,OAAO,CAAC,IAAIE,KAAJ,CAAU,qBAAV,CAAD,CAAlB;IACA,OAAO,IAAP;EACD,CAHD,MAGO;IACL,OAAOD,aAAP;EACD;AACF,CAZD;;AAcA,OAAO,MAAME,QAAQ,GAAG,CACtBC,MADsB,EAEtBL,OAFsB,EAGtBC,OAHsB,KAIA;EACtB,IAAII,MAAM,KAAK,IAAX,IAAmBA,MAAM,KAAKC,SAAlC,EAA6C;IAC3C,OAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAaA,OAAO,CAAC,IAAD,CAAhC,CAAP;EACD,CAFD,MAEO,IAAIH,MAAM,YAAYI,UAAtB,EAAkC;IACvC,OAAO,IAAIF,OAAJ,CAAaC,OAAD,IACjBA,OAAO,CAACV,cAAc,CAACF,IAAI,CAACc,IAAL,CAAUC,SAAV,CAAoBN,MAApB,CAAD,EAA8BL,OAA9B,EAAuCC,OAAvC,CAAf,CADF,CAAP;EAGD,CAJM,MAIA;IACL,MAAMW,GAAG,GACP,OAAOP,MAAP,KAAkB,QAAlB,GAA6BA,MAA7B,GAAsCR,QAAQ,CAACgB,YAAT,CAAsBR,MAAtB,CADxC;IAEA,OAAOT,IAAI,CAACc,IAAL,CAAUI,OAAV,CAAkBF,GAAl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C,KAAK,IAA3B,CAAd;;MACA,IAAIV,OAAO,CAACI,OAAZ,EAAqB;QACnBF,OAAO,CAACG,KAAD,CAAP;QACAF,OAAO,CAACC,OAAR,GAAkBC,KAAlB;MACD;IACF,CAND;IAQA,OAAO,MAAM;MAAA;;MACX,qBAAAF,OAAO,CAACC,OAAR,wEAAiBO,OAAjB,CAA0BC,QAAD,IAAcA,QAAd,aAAcA,QAAd,uBAAcA,QAAQ,CAAEN,OAAV,EAAvC;MACAN,OAAO,CAACI,OAAR,GAAkB,KAAlB;IACD,CAHD,CAVc,CAed;EACD,CAhBQ,EAgBN,CAAClB,MAAD,CAhBM,CAAT;EAkBA,OAAOe,IAAP;AACD,CA3BM;AA6BP,OAAO,MAAMY,UAAU,GAAG,CACxB3B,MADwB,EAExBL,OAFwB,EAGxBC,OAHwB,KAIrBgB,UAAU,CAACZ,MAAD,EAAS,MAAMD,QAAQ,CAAIC,MAAJ,EAAYL,OAAZ,EAAqBC,OAArB,CAAvB,CAJR;;AAMP,MAAMgC,QAAQ,GAAIb,IAAD,IAAkBA,IAAnC;;AAEA,OAAO,MAAMc,OAAO,GAAG,CACrB7B,MADqB,EAErBJ,OAFqB,KAGlB+B,UAAU,CAAC3B,MAAD,EAAS4B,QAAT,EAAmBhC,OAAnB,CAHR"}
@@ -1,5 +1,18 @@
1
- import type { DataSourceParam } from "../types";
1
+ import type { DataModule, DataSourceParam, SkFontMgr } from "../types";
2
+ import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
2
3
  /**
3
4
  * Returns a Skia Font object
4
5
  * */
5
6
  export declare const useFont: (font: DataSourceParam, size?: number, onError?: ((err: Error) => void) | undefined) => import("../types").SkFont | null;
7
+ declare type Slant = "normal" | "italic" | "oblique";
8
+ declare type Weight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
9
+ interface RNFontStyle {
10
+ fontFamily: string;
11
+ fontSize: number;
12
+ fontStyle: Slant;
13
+ fontWeight: Weight;
14
+ }
15
+ export declare const matchFont: (inputStyle?: Partial<RNFontStyle>, fontMgr?: SkFontMgr) => import("../types").SkFont;
16
+ export declare const listFontFamilies: (fontMgr?: SkFontMgr) => string[];
17
+ export declare const useFonts: (sources: Record<string, DataModule[]>) => SkTypefaceFontProvider | null;
18
+ export {};
@@ -1,6 +1,8 @@
1
1
  /*global SkiaApi*/
2
- import { useMemo } from "react";
2
+ import { useEffect, useMemo, useState } from "react";
3
3
  import { Skia } from "../Skia";
4
+ import { FontSlant } from "../types";
5
+ import { Platform } from "../../Platform";
4
6
  import { useTypeface } from "./Typeface";
5
7
  /**
6
8
  * Returns a Skia Font object
@@ -18,4 +20,84 @@ export const useFont = (font, size, onError) => {
18
20
  }
19
21
  }, [size, typeface]);
20
22
  };
23
+ const defaultFontStyle = {
24
+ fontFamily: "System",
25
+ fontSize: 14,
26
+ fontStyle: "normal",
27
+ fontWeight: "normal"
28
+ };
29
+
30
+ const slant = s => {
31
+ if (s === "italic") {
32
+ return FontSlant.Italic;
33
+ } else if (s === "oblique") {
34
+ return FontSlant.Oblique;
35
+ } else {
36
+ return FontSlant.Upright;
37
+ }
38
+ };
39
+
40
+ const weight = fontWeight => {
41
+ switch (fontWeight) {
42
+ case "normal":
43
+ return 400;
44
+
45
+ case "bold":
46
+ return 700;
47
+
48
+ default:
49
+ return parseInt(fontWeight, 10);
50
+ }
51
+ };
52
+
53
+ export const matchFont = function () {
54
+ let inputStyle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
55
+ let fontMgr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Skia.FontMgr.System();
56
+ const fontStyle = { ...defaultFontStyle,
57
+ ...inputStyle
58
+ };
59
+ const style = {
60
+ weight: weight(fontStyle.fontWeight),
61
+ width: 5,
62
+ slant: slant(fontStyle.fontStyle)
63
+ };
64
+ const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);
65
+ return Skia.Font(typeface, fontStyle.fontSize);
66
+ };
67
+ export const listFontFamilies = function () {
68
+ let fontMgr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Skia.FontMgr.System();
69
+ return new Array(fontMgr.countFamilies()).fill(0).map((_, i) => fontMgr.getFamilyName(i));
70
+ };
71
+
72
+ const loadTypefaces = typefacesToLoad => {
73
+ const promises = Object.keys(typefacesToLoad).flatMap(familyName => {
74
+ return typefacesToLoad[familyName].map(typefaceToLoad => {
75
+ return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(data => {
76
+ const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);
77
+
78
+ if (tf === null) {
79
+ throw new Error(`Couldn't create typeface for ${familyName}`);
80
+ }
81
+
82
+ return [familyName, tf];
83
+ });
84
+ });
85
+ });
86
+ return Promise.all(promises);
87
+ };
88
+
89
+ export const useFonts = sources => {
90
+ const [fontMgr, setFontMgr] = useState(null);
91
+ useEffect(() => {
92
+ loadTypefaces(sources).then(result => {
93
+ const fMgr = Skia.TypefaceFontProvider.Make();
94
+ result.forEach(_ref => {
95
+ let [familyName, typeface] = _ref;
96
+ fMgr.registerFont(typeface, familyName);
97
+ });
98
+ setFontMgr(fMgr);
99
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ }, []);
101
+ return fontMgr;
102
+ };
21
103
  //# sourceMappingURL=Font.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","Skia","useTypeface","useFont","font","size","onError","typeface","Font"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useMemo } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nimport { useTypeface } from \"./Typeface\";\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size?: number,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface && size) {\n return Skia.Font(typeface, size);\n } else if (typeface && !size) {\n return Skia.Font(typeface);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n"],"mappings":"AAAA;AACA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,IAAT,QAAqB,SAArB;AAGA,SAASC,WAAT,QAA4B,YAA5B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,OAAO,GAAG,CACrBC,IADqB,EAErBC,IAFqB,EAGrBC,OAHqB,KAIlB;EACH,MAAMC,QAAQ,GAAGL,WAAW,CAACE,IAAD,EAAOE,OAAP,CAA5B;EACA,OAAON,OAAO,CAAC,MAAM;IACnB,IAAIO,QAAQ,IAAIF,IAAhB,EAAsB;MACpB,OAAOJ,IAAI,CAACO,IAAL,CAAUD,QAAV,EAAoBF,IAApB,CAAP;IACD,CAFD,MAEO,IAAIE,QAAQ,IAAI,CAACF,IAAjB,EAAuB;MAC5B,OAAOJ,IAAI,CAACO,IAAL,CAAUD,QAAV,CAAP;IACD,CAFM,MAEA;MACL,OAAO,IAAP;IACD;EACF,CARa,EAQX,CAACF,IAAD,EAAOE,QAAP,CARW,CAAd;AASD,CAfM"}
1
+ {"version":3,"names":["useEffect","useMemo","useState","Skia","FontSlant","Platform","useTypeface","useFont","font","size","onError","typeface","Font","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","Italic","Oblique","Upright","weight","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","Array","countFamilies","fill","map","_","i","getFamilyName","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","typefaceToLoad","Data","fromURI","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size?: number,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface && size) {\n return Skia.Font(typeface, size);\n } else if (typeface && !size) {\n return Skia.Font(typeface);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\ntype Slant = \"normal\" | \"italic\" | \"oblique\";\ntype Weight =\n | \"normal\"\n | \"bold\"\n | \"100\"\n | \"200\"\n | \"300\"\n | \"400\"\n | \"500\"\n | \"600\"\n | \"700\"\n | \"800\"\n | \"900\";\n\ninterface RNFontStyle {\n fontFamily: string;\n fontSize: number;\n fontStyle: Slant;\n fontWeight: Weight;\n}\n\nconst defaultFontStyle: RNFontStyle = {\n fontFamily: \"System\",\n fontSize: 14,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n};\n\nconst slant = (s: Slant) => {\n if (s === \"italic\") {\n return FontSlant.Italic;\n } else if (s === \"oblique\") {\n return FontSlant.Oblique;\n } else {\n return FontSlant.Upright;\n }\n};\n\nconst weight = (fontWeight: Weight) => {\n switch (fontWeight) {\n case \"normal\":\n return 400;\n case \"bold\":\n return 700;\n default:\n return parseInt(fontWeight, 10);\n }\n};\n\nexport const matchFont = (\n inputStyle: Partial<RNFontStyle> = {},\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const fontStyle = {\n ...defaultFontStyle,\n ...inputStyle,\n };\n const style = {\n weight: weight(fontStyle.fontWeight),\n width: 5,\n slant: slant(fontStyle.fontStyle),\n };\n const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);\n return Skia.Font(typeface, fontStyle.fontSize);\n};\n\nexport const listFontFamilies = (fontMgr: SkFontMgr = Skia.FontMgr.System()) =>\n new Array(fontMgr.countFamilies())\n .fill(0)\n .map((_, i) => fontMgr.getFamilyName(i));\n\nconst loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {\n const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {\n return typefacesToLoad[familyName].map((typefaceToLoad) => {\n return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(\n (data) => {\n const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);\n if (tf === null) {\n throw new Error(`Couldn't create typeface for ${familyName}`);\n }\n return [familyName, tf] as const;\n }\n );\n });\n });\n return Promise.all(promises);\n};\n\nexport const useFonts = (sources: Record<string, DataModule[]>) => {\n const [fontMgr, setFontMgr] = useState<null | SkTypefaceFontProvider>(null);\n\n useEffect(() => {\n loadTypefaces(sources).then((result) => {\n const fMgr = Skia.TypefaceFontProvider.Make();\n result.forEach(([familyName, typeface]) => {\n fMgr.registerFont(typeface, familyName);\n });\n setFontMgr(fMgr);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return fontMgr;\n};\n"],"mappings":"AAAA;AACA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,OAA7C;AAEA,SAASC,IAAT,QAAqB,SAArB;AACA,SAASC,SAAT,QAA0B,UAA1B;AAEA,SAASC,QAAT,QAAyB,gBAAzB;AAGA,SAASC,WAAT,QAA4B,YAA5B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,OAAO,GAAG,CACrBC,IADqB,EAErBC,IAFqB,EAGrBC,OAHqB,KAIlB;EACH,MAAMC,QAAQ,GAAGL,WAAW,CAACE,IAAD,EAAOE,OAAP,CAA5B;EACA,OAAOT,OAAO,CAAC,MAAM;IACnB,IAAIU,QAAQ,IAAIF,IAAhB,EAAsB;MACpB,OAAON,IAAI,CAACS,IAAL,CAAUD,QAAV,EAAoBF,IAApB,CAAP;IACD,CAFD,MAEO,IAAIE,QAAQ,IAAI,CAACF,IAAjB,EAAuB;MAC5B,OAAON,IAAI,CAACS,IAAL,CAAUD,QAAV,CAAP;IACD,CAFM,MAEA;MACL,OAAO,IA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ACtC,MAAMC,IAAI,GAAG7D,IAAI,CAAC8D,oBAAL,CAA0BC,IAA1B,EAAb;MACAH,MAAM,CAACI,OAAP,CAAe,QAA4B;QAAA,IAA3B,CAACpB,UAAD,EAAapC,QAAb,CAA2B;QACzCqD,IAAI,CAACI,YAAL,CAAkBzD,QAAlB,EAA4BoC,UAA5B;MACD,CAFD;MAGAe,UAAU,CAACE,IAAD,CAAV;IACD,CAND,EADc,CAQd;EACD,CATQ,EASN,EATM,CAAT;EAUA,OAAOrC,OAAP;AACD,CAdM"}
@@ -0,0 +1,8 @@
1
+ import type { SkJSIInstance } from "../JsiInstance";
2
+ import type { SkTypeface } from "../Typeface";
3
+ import type { FontStyle } from "./Font";
4
+ export interface SkFontMgr extends SkJSIInstance<"FontMgr"> {
5
+ countFamilies(): number;
6
+ getFamilyName(index: number): string;
7
+ matchFamilyStyle(name: string, style: FontStyle): SkTypeface;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FontMgr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["FontMgr.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkTypeface } from \"../Typeface\";\n\nimport type { FontStyle } from \"./Font\";\n\nexport interface SkFontMgr extends SkJSIInstance<\"FontMgr\"> {\n countFamilies(): number;\n getFamilyName(index: number): string;\n matchFamilyStyle(name: string, style: FontStyle): SkTypeface;\n}\n"],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { SkFontMgr } from "./FontMgr";
2
+ export interface FontMgrFactory {
3
+ System(): SkFontMgr;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=FontMgrFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["FontMgrFactory.ts"],"sourcesContent":["import type { SkFontMgr } from \"./FontMgr\";\n\nexport interface FontMgrFactory {\n System(): SkFontMgr;\n}\n"],"mappings":""}
@@ -1 +1,3 @@
1
1
  export * from "./Font";
2
+ export * from "./FontMgr";
3
+ export * from "./FontMgrFactory";
@@ -1,2 +1,4 @@
1
1
  export * from "./Font";
2
+ export * from "./FontMgr";
3
+ export * from "./FontMgrFactory";
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Font\";\n"],"mappings":"AAAA,cAAc,QAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Font\";\nexport * from \"./FontMgr\";\nexport * from \"./FontMgrFactory\";\n"],"mappings":"AAAA,cAAc,QAAd;AACA,cAAc,WAAd;AACA,cAAc,kBAAd"}
@@ -0,0 +1,10 @@
1
+ import type { SkFontMgr } from "../Font";
2
+ import type { SkTypeface } from "../Typeface";
3
+ export interface SkTypefaceFontProvider extends SkFontMgr {
4
+ /**
5
+ * Registers a given typeface with the given family name.
6
+ * @param typeface - Typeface.
7
+ * @param family
8
+ */
9
+ registerFont(typeface: SkTypeface, familyName: string): void;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TypefaceFontProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["TypefaceFontProvider.ts"],"sourcesContent":["import type { SkFontMgr } from \"../Font\";\nimport type { SkTypeface } from \"../Typeface\";\n\nexport interface SkTypefaceFontProvider extends SkFontMgr {\n /**\n * Registers a given typeface with the given family name.\n * @param typeface - Typeface.\n * @param family\n */\n registerFont(typeface: SkTypeface, familyName: string): void;\n}\n"],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { SkTypefaceFontProvider } from "./TypefaceFontProvider";
2
+ export interface TypefaceFontProviderFactory {
3
+ Make(): SkTypefaceFontProvider;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TypefaceFontProviderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["TypefaceFontProviderFactory.ts"],"sourcesContent":["import type { SkTypefaceFontProvider } from \"./TypefaceFontProvider\";\n\nexport interface TypefaceFontProviderFactory {\n Make(): SkTypefaceFontProvider;\n}\n"],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import type { ImageFilterFactory } from "./ImageFilter";
2
2
  import type { PathFactory } from "./Path";
3
3
  import type { ColorFilterFactory } from "./ColorFilter";
4
- import type { SkFont } from "./Font";
4
+ import type { SkFont, FontMgrFactory } from "./Font";
5
5
  import type { SkTypeface, TypefaceFactory } from "./Typeface";
6
6
  import type { ImageFactory } from "./Image";
7
7
  import type { MaskFilterFactory } from "./MaskFilter";
@@ -23,6 +23,7 @@ import type { SkPath } from "./Path/Path";
23
23
  import type { SkContourMeasureIter } from "./ContourMeasure";
24
24
  import type { PictureFactory, SkPictureRecorder } from "./Picture";
25
25
  import type { Color, SkColor } from "./Color";
26
+ import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
26
27
  /**
27
28
  * Declares the interface for the native Skia API
28
29
  */
@@ -42,6 +43,8 @@ export interface Skia {
42
43
  ColorFilter: ColorFilterFactory;
43
44
  Font: (typeface?: SkTypeface, size?: number) => SkFont;
44
45
  Typeface: TypefaceFactory;
46
+ TypefaceFontProvider: TypefaceFontProviderFactory;
47
+ FontMgr: FontMgrFactory;
45
48
  MaskFilter: MaskFilterFactory;
46
49
  RuntimeEffect: RuntimeEffectFactory;
47
50
  ImageFilter: ImageFilterFactory;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n"],"mappings":""}
@@ -11,7 +11,7 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
11
11
  readonly __typename__: N;
12
12
  ref: T;
13
13
  constructor(CanvasKit: CanvasKit, ref: T, typename: N);
14
- abstract dispose: () => void;
14
+ abstract dispose(): void;
15
15
  }
16
16
  export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
17
17
  static fromValue<T>(value: SkJSIInstance<string>): T;