@shopify/react-native-skia 0.1.131 → 0.1.134

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/CMakeLists.txt +1 -1
  2. package/android/build.gradle +17 -2
  3. package/android/cpp/rnskia-android/RNSkDrawViewImpl.cpp +5 -0
  4. package/cpp/api/JsiSkFont.h +6 -2
  5. package/cpp/api/JsiSkImage.h +2 -19
  6. package/cpp/api/JsiSkPaint.h +5 -32
  7. package/cpp/api/JsiSkPath.h +4 -4
  8. package/cpp/rnskia/RNSkValueApi.h +6 -6
  9. package/cpp/rnskia/values/{RNSkDerivedValue.h → RNSkComputedValue.h} +7 -7
  10. package/cpp/utils/RNSkLog.h +5 -0
  11. package/ios/RNSkia-iOS/SkiaManager.mm +1 -1
  12. package/lib/commonjs/mock/index.js +190 -0
  13. package/lib/commonjs/mock/index.js.map +1 -0
  14. package/lib/commonjs/skia/core/Data.js +33 -43
  15. package/lib/commonjs/skia/core/Data.js.map +1 -1
  16. package/lib/commonjs/skia/core/Typeface.js +1 -1
  17. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  18. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  19. package/lib/commonjs/skia/types/Image/Image.js +5 -5
  20. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  21. package/lib/commonjs/skia/types/Paint/Paint.js +3 -3
  22. package/lib/commonjs/skia/types/Paint/Paint.js.map +1 -1
  23. package/lib/commonjs/skia/types/Path/Path.js +0 -1
  24. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  25. package/lib/commonjs/skia/types/Shader/Shader.js +1 -7
  26. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -1
  28. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  29. package/lib/commonjs/skia/web/JsiSkFont.js +4 -2
  30. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -2
  32. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkImage.js +10 -6
  34. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  35. package/lib/commonjs/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  36. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  37. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.js +65 -52
  39. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +1 -1
  41. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +23 -1
  43. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkia.js +2 -2
  45. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  46. package/lib/commonjs/values/api.js +3 -3
  47. package/lib/commonjs/values/api.js.map +1 -1
  48. package/lib/commonjs/values/api.web.js +3 -3
  49. package/lib/commonjs/values/api.web.js.map +1 -1
  50. package/lib/commonjs/values/hooks/index.js +4 -4
  51. package/lib/commonjs/values/hooks/index.js.map +1 -1
  52. package/lib/commonjs/values/hooks/useComputedValue.js +32 -0
  53. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -0
  54. package/lib/commonjs/values/web/{RNSkDerivedValue.js → RNSkComputedValue.js} +4 -4
  55. package/lib/commonjs/values/web/RNSkComputedValue.js.map +1 -0
  56. package/lib/commonjs/values/web/api.js +3 -3
  57. package/lib/commonjs/values/web/api.js.map +1 -1
  58. package/lib/commonjs/views/SkiaView.web.js +4 -4
  59. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  60. package/lib/commonjs/web/index.js +4 -2
  61. package/lib/commonjs/web/index.js.map +1 -1
  62. package/lib/module/mock/index.js +152 -0
  63. package/lib/module/mock/index.js.map +1 -0
  64. package/lib/module/skia/core/Data.js +32 -41
  65. package/lib/module/skia/core/Data.js.map +1 -1
  66. package/lib/module/skia/core/Typeface.js +1 -1
  67. package/lib/module/skia/core/Typeface.js.map +1 -1
  68. package/lib/module/skia/types/Font/Font.js.map +1 -1
  69. package/lib/module/skia/types/Image/Image.js +5 -5
  70. package/lib/module/skia/types/Image/Image.js.map +1 -1
  71. package/lib/module/skia/types/Paint/Paint.js +3 -3
  72. package/lib/module/skia/types/Paint/Paint.js.map +1 -1
  73. package/lib/module/skia/types/Path/Path.js +0 -1
  74. package/lib/module/skia/types/Path/Path.js.map +1 -1
  75. package/lib/module/skia/types/Shader/Shader.js +1 -7
  76. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  77. package/lib/module/skia/web/JsiSkCanvas.js +1 -1
  78. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkFont.js +5 -3
  80. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  81. package/lib/module/skia/web/JsiSkFontMgr.js +0 -2
  82. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  83. package/lib/module/skia/web/JsiSkImage.js +10 -7
  84. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  85. package/lib/module/skia/web/{JsiImageFilterFactory.js → JsiSkImageFilterFactory.js} +1 -1
  86. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -0
  87. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkPath.js +65 -52
  89. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkShaderFactory.js +1 -1
  91. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  92. package/lib/module/skia/web/JsiSkVerticesFactory.js +24 -1
  93. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  94. package/lib/module/skia/web/JsiSkia.js +1 -1
  95. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  96. package/lib/module/values/api.js +1 -1
  97. package/lib/module/values/api.js.map +1 -1
  98. package/lib/module/values/api.web.js +1 -1
  99. package/lib/module/values/api.web.js.map +1 -1
  100. package/lib/module/values/hooks/index.js +1 -1
  101. package/lib/module/values/hooks/index.js.map +1 -1
  102. package/lib/module/values/hooks/useComputedValue.js +18 -0
  103. package/lib/module/values/hooks/useComputedValue.js.map +1 -0
  104. package/lib/module/values/web/{RNSkDerivedValue.js → RNSkComputedValue.js} +2 -2
  105. package/lib/module/values/web/RNSkComputedValue.js.map +1 -0
  106. package/lib/module/values/web/api.js +3 -3
  107. package/lib/module/values/web/api.js.map +1 -1
  108. package/lib/module/views/SkiaView.web.js +4 -4
  109. package/lib/module/views/SkiaView.web.js.map +1 -1
  110. package/lib/module/web/index.js +3 -1
  111. package/lib/module/web/index.js.map +1 -1
  112. package/lib/typescript/src/mock/index.d.ts +47 -0
  113. package/lib/typescript/src/skia/core/Data.d.ts +3 -3
  114. package/lib/typescript/src/skia/types/Font/Font.d.ts +8 -9
  115. package/lib/typescript/src/skia/types/Image/Image.d.ts +5 -5
  116. package/lib/typescript/src/skia/types/Paint/Paint.d.ts +3 -3
  117. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -2
  118. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +1 -0
  119. package/lib/typescript/src/skia/types/Skia.d.ts +1 -1
  120. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
  121. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +3 -3
  122. package/lib/typescript/src/skia/web/{JsiImageFilterFactory.d.ts → JsiSkImageFilterFactory.d.ts} +0 -0
  123. package/lib/typescript/src/skia/web/JsiSkPaint.d.ts +1 -1
  124. package/lib/typescript/src/values/api.d.ts +1 -1
  125. package/lib/typescript/src/values/api.web.d.ts +1 -1
  126. package/lib/typescript/src/values/hooks/index.d.ts +1 -1
  127. package/lib/typescript/src/values/hooks/{useDerivedValue.d.ts → useComputedValue.d.ts} +2 -1
  128. package/lib/typescript/src/values/types.d.ts +2 -2
  129. package/lib/typescript/src/values/web/{RNSkDerivedValue.d.ts → RNSkComputedValue.d.ts} +1 -1
  130. package/package.json +2 -1
  131. package/src/mock/index.ts +156 -0
  132. package/src/skia/core/Data.ts +67 -50
  133. package/src/skia/core/Typeface.ts +6 -1
  134. package/src/skia/types/Font/Font.ts +9 -14
  135. package/src/skia/types/Image/Image.ts +4 -4
  136. package/src/skia/types/Paint/Paint.ts +1 -1
  137. package/src/skia/types/Path/Path.ts +0 -1
  138. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -0
  139. package/src/skia/types/Shader/Shader.ts +3 -5
  140. package/src/skia/types/Skia.ts +1 -1
  141. package/src/skia/web/JsiSkCanvas.ts +2 -2
  142. package/src/skia/web/JsiSkFont.ts +7 -3
  143. package/src/skia/web/JsiSkFontMgr.ts +0 -4
  144. package/src/skia/web/JsiSkImage.ts +37 -16
  145. package/src/skia/web/{JsiImageFilterFactory.ts → JsiSkImageFilterFactory.ts} +0 -0
  146. package/src/skia/web/JsiSkPaint.ts +1 -1
  147. package/src/skia/web/JsiSkPath.ts +64 -47
  148. package/src/skia/web/JsiSkShaderFactory.ts +4 -1
  149. package/src/skia/web/JsiSkVerticesFactory.ts +15 -1
  150. package/src/skia/web/JsiSkia.ts +2 -2
  151. package/src/values/api.ts +1 -1
  152. package/src/values/api.web.ts +1 -1
  153. package/src/values/hooks/index.ts +1 -1
  154. package/src/values/hooks/{useDerivedValue.ts → useComputedValue.ts} +8 -3
  155. package/src/values/types.ts +2 -2
  156. package/src/values/web/{RNSkDerivedValue.ts → RNSkComputedValue.ts} +1 -1
  157. package/src/values/web/api.ts +3 -3
  158. package/src/views/SkiaView.web.tsx +9 -11
  159. package/src/web/index.ts +3 -1
  160. package/lib/commonjs/skia/web/JsiImageFilterFactory.js.map +0 -1
  161. package/lib/commonjs/values/hooks/useDerivedValue.js +0 -25
  162. package/lib/commonjs/values/hooks/useDerivedValue.js.map +0 -1
  163. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +0 -1
  164. package/lib/module/skia/web/JsiImageFilterFactory.js.map +0 -1
  165. package/lib/module/values/hooks/useDerivedValue.js +0 -14
  166. package/lib/module/values/hooks/useDerivedValue.js.map +0 -1
  167. package/lib/module/values/web/RNSkDerivedValue.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["Data.ts"],"names":["resolveAsset","source","Platform","OS","default","Image","resolveAssetSource","uri","useDataCollection","sources","factory","deps","data","setData","bytesOrURIs","map","Uint8Array","Promise","all","bytesOrURI","Skia","Data","fromBytes","fromURI","then","d","useRawData","onError","prevSourceRef","current","undefined","factoryWrapper","data2","factoryResult","Error","identity","useData"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AAGA,MAAMA,YAAY,GAAIC,MAAD,IAAwC;AAC3D,SAAOC,sBAASC,EAAT,KAAgB,KAAhB,GACHF,MAAM,CAACG,OADJ,GAEHC,mBAAMC,kBAAN,CAAyBL,MAAzB,EAAiCM,GAFrC;AAGD,CAJD;;AAMO,MAAMC,iBAAiB,GAAG,UAC/BC,OAD+B,EAE/BC,OAF+B,EAI5B;AAAA,MADHC,IACG,uEADoB,EACpB;AACH,QAAM,CAACC,IAAD,EAAOC,OAAP,IAAkB,qBAAmB,IAAnB,CAAxB;AACA,wBAAU,MAAM;AACd,UAAMC,WAAW,GAAGL,OAAO,CAACM,GAAR,CAAad,MAAD,IAAY;AAC1C,UAAIA,MAAM,YAAYe,UAAtB,EAAkC;AAChC,eAAOf,MAAP;AACD;;AACD,aAAO,OAAOA,MAAP,KAAkB,QAAlB,GAA6BA,MAA7B,GAAsCD,YAAY,CAACC,MAAD,CAAzD;AACD,KALmB,CAApB;AAMAgB,IAAAA,OAAO,CAACC,GAAR,CACEJ,WAAW,CAACC,GAAZ,CAAiBI,UAAD,IACdA,UAAU,YAAYH,UAAtB,GACII,WAAKC,IAAL,CAAUC,S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iB,IAAvB,CAA6BC,CAAD,IAAOM,cAAc,CAACN,CAAD,CAAjD;AACD;AACF,OAjBD,MAiBO;AACL;AACAZ,QAAAA,OAAO,CAAC,IAAD,CAAP;AACD;AACF;AACF,GA1BD,EA0BG,CAACH,OAAD,EAAUiB,OAAV,EAAmB1B,MAAnB,CA1BH;AA2BA,SAAOW,IAAP;AACD,CAnCM;;;;AAqCP,MAAMuB,QAAQ,GAAIvB,IAAD,IAAkBA,IAAnC;;AAEO,MAAMwB,OAAO,GAAG,CACrBnC,MADqB,EAErB0B,OAFqB,KAGlBD,UAAU,CAACzB,MAAD,EAASkC,QAAT,EAAmBR,OAAnB,CAHR","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useRef, useEffect, useState } from \"react\";\nimport { Image, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSource } from \"../types\";\n\nconst resolveAsset = (source: ReturnType<typeof require>) => {\n return Platform.OS === \"web\"\n ? source.default\n : Image.resolveAssetSource(source).uri;\n};\n\nexport const useDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData[]) => T,\n deps: DependencyList = []\n) => {\n const [data, setData] = useState<T | null>(null);\n useEffect(() => {\n const bytesOrURIs = sources.map((source) => {\n if (source instanceof Uint8Array) {\n return source;\n }\n return typeof source === \"string\" ? source : resolveAsset(source);\n });\n Promise.all(\n bytesOrURIs.map((bytesOrURI) =>\n bytesOrURI instanceof Uint8Array\n ? Skia.Data.fromBytes(bytesOrURI)\n : Skia.Data.fromURI(bytesOrURI)\n )\n ).then((d) => setData(factory(d)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n return data;\n};\n\nexport const useRawData = <T>(\n source: DataSource | null | undefined,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const [data, setData] = useState<T | null>(null);\n const prevSourceRef = useRef<DataSource | null | undefined>();\n useEffect(() => {\n // Track to avoid re-fetching the same data\n if (prevSourceRef.current !== source) {\n prevSourceRef.current = source;\n if (source !== null && source !== undefined) {\n const factoryWrapper = (data2: SkData) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n setData(null);\n } else {\n setData(factoryResult);\n }\n };\n if (source instanceof Uint8Array) {\n factoryWrapper(Skia.Data.fromBytes(source));\n } else {\n const uri =\n typeof source === \"string\" ? source : resolveAsset(source);\n Skia.Data.fromURI(uri).then((d) => factoryWrapper(d));\n }\n } else {\n // new source is null or undefined -> remove cached data\n setData(null);\n }\n }\n }, [factory, onError, source]);\n return data;\n};\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) => useRawData(source, identity, onError);\n"]}
1
+ {"version":3,"sources":["Data.ts"],"names":["resolveAsset","source","Platform","OS","default","Image","resolveAssetSource","uri","factoryWrapper","data2","factory","onError","factoryResult","Error","loadDataCollection","sources","Promise","all","map","loadData","Uint8Array","resolve","Skia","Data","fromBytes","fromURI","then","d","useLoading","loader","deps","data","setData","prevSourceRef","current","useDataCollection","useRawData","identity","useData"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AAGA,MAAMA,YAAY,GAAIC,MAAD,IAAwC;AAC3D,SAAOC,sBAASC,EAAT,KAAgB,KAAhB,GACHF,MAAM,CAACG,OADJ,GAEHC,mBAAMC,kBAAN,CAAyBL,MAAzB,EAAiCM,GAFrC;AAGD,CAJD;;AAMA,MAAMC,cAAc,GAAG,CACrBC,KADqB,EAErBC,OAFqB,EAGrBC,OAHqB,KAIlB;AACH,QAAMC,aAAa,GAAGF,OAAO,CAACD,KAAD,CAA7B;;AACA,MAAIG,aAAa,KAAK,IAAtB,EAA4B;AAC1BD,IAAAA,OAAO,IAAIA,OAAO,CAAC,IAAIE,KAAJ,CAAU,qBAAV,CAAD,CAAlB;AACA,WAAO,IAAP;AACD,GAHD,MAGO;AACL,WAAOD,aAAP;AACD;AACF,CAZD;;AAcA,MAAME,kBAAkB,GAAG,CACzBC,OAD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BD;;AAmBO,MAAMI,iBAAiB,GAAG,CAC/BpB,OAD+B,EAE/BL,OAF+B,EAG/BC,OAH+B,EAI/BmB,IAJ+B,KAM/BF,UAAU,CACRb,OADQ,EAER,MAAMD,kBAAkB,CAACC,OAAD,EAAUL,OAAV,EAAmBC,OAAnB,CAFhB,EAGRmB,IAHQ,CANL;;;;AAYA,MAAMM,UAAU,GAAG,CACxBnC,MADwB,EAExBS,OAFwB,EAGxBC,OAHwB,EAIxBmB,IAJwB,KAKrBF,UAAU,CAAC3B,MAAD,EAAS,MAAMkB,QAAQ,CAAClB,MAAD,EAASS,OAAT,EAAkBC,OAAlB,CAAvB,EAAmDmB,IAAnD,CALR;;;;AAOP,MAAMO,QAAQ,GAAIN,IAAD,IAAkBA,IAAnC;;AAEO,MAAMO,OAAO,GAAG,CACrBrC,MADqB,EAErBU,OAFqB,EAGrBmB,IAHqB,KAIlBM,UAAU,CAACnC,MAAD,EAASoC,QAAT,EAAmB1B,OAAnB,EAA4BmB,IAA5B,CAJR","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useRef, useEffect, useState } from \"react\";\nimport { Image, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSource } from \"../types\";\n\nconst resolveAsset = (source: ReturnType<typeof require>) => {\n return Platform.OS === \"web\"\n ? source.default\n : Image.resolveAssetSource(source).uri;\n};\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 loadDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<(T | null)[]> =>\n Promise.all(sources.map((source) => loadData(source, factory, onError)));\n\nconst loadData = <T>(\n source: DataSource,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri = typeof source === \"string\" ? source : resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\n\ntype Source = DataSource | null | undefined;\n\nconst useLoading = <T>(\n source: Source,\n loader: () => Promise<T | null>,\n deps: DependencyList = []\n) => {\n const [data, setData] = useState<T | null>(null);\n const prevSourceRef = useRef<Source>();\n useEffect(() => {\n if (prevSourceRef.current !== source) {\n prevSourceRef.current = source;\n loader().then(setData);\n } else {\n setData(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n return data;\n};\n\nexport const useDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) =>\n useLoading(\n sources,\n () => loadDataCollection(sources, factory, onError),\n deps\n );\n\nexport const useRawData = <T>(\n source: DataSource | null | undefined,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useLoading(source, () => loadData(source, factory, onError), deps);\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useRawData(source, identity, onError, deps);\n"]}
@@ -12,7 +12,7 @@ var _Data = require("./Data");
12
12
  /**
13
13
  * Returns a Skia Typeface object
14
14
  * */
15
- const useTypeface = (source, onError) => (0, _Data.useRawData)(source, _Skia.Skia.Typeface.MakeFreeTypeFaceFromData, onError);
15
+ const useTypeface = (source, onError) => (0, _Data.useRawData)(source, _Skia.Skia.Typeface.MakeFreeTypeFaceFromData.bind(_Skia.Skia.Typeface), onError);
16
16
 
17
17
  exports.useTypeface = useTypeface;
18
18
  //# sourceMappingURL=Typeface.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Typeface.ts"],"names":["useTypeface","source","onError","Skia","Typeface","MakeFreeTypeFaceFromData"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,CACzBC,MADyB,EAEzBC,OAFyB,KAGtB,sBAAWD,MAAX,EAAmBE,WAAKC,QAAL,CAAcC,wBAAjC,EAA2DH,OAA3D,CAHE","sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSource } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n/**\n * Returns a Skia Typeface object\n * */\nexport const useTypeface = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) => useRawData(source, Skia.Typeface.MakeFreeTypeFaceFromData, onError);\n"]}
1
+ {"version":3,"sources":["Typeface.ts"],"names":["useTypeface","source","onError","Skia","Typeface","MakeFreeTypeFaceFromData","bind"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,CACzBC,MADyB,EAEzBC,OAFyB,KAIzB,sBACED,MADF,EAEEE,WAAKC,QAAL,CAAcC,wBAAd,CAAuCC,IAAvC,CAA4CH,WAAKC,QAAjD,CAFF,EAGEF,OAHF,CAJK","sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSource } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n/**\n * Returns a Skia Typeface object\n * */\nexport const useTypeface = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void\n) =>\n useRawData(\n source,\n Skia.Typeface.MakeFreeTypeFaceFromData.bind(Skia.Typeface),\n onError\n );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Font.ts"],"names":["fontStyle","weight","width","slant","FontWeight","FontWidth","FontSlant","FontEdging","FontHinting","FontStyle","Normal","Upright","Bold","Italic","BoldItalic"],"mappings":";;;;;;;AAuKA,MAAMA,SAAS,GAAG,CAChBC,MADgB,EAEhBC,KAFgB,EAGhBC,KAHgB,MAID;AAAEF,EAAAA,MAAF;AAAUC,EAAAA,KAAV;AAAiBC,EAAAA;AAAjB,CAJC,CAAlB;;IAYYC,U;;;WAAAA,U;AAAAA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S,CAACK,OAA9C,CAFQ;AAGvBE,EAAAA,MAAM,EAAEb,SAAS,CAACI,UAAU,CAACM,MAAZ,EAAoBL,SAAS,CAACK,MAA9B,EAAsCJ,SAAS,CAACO,MAAhD,CAHM;AAIvBC,EAAAA,UAAU,EAAEd,SAAS,CAACI,UAAU,CAACQ,IAAZ,EAAkBP,SAAS,CAACK,MAA5B,EAAoCJ,SAAS,CAACO,MAA9C;AAJE,CAAlB","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkPaint } from \"../Paint\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkTypeface } from \"../Typeface\";\n\nexport interface FontMetrics {\n ascent: number; // suggested space above the baseline. < 0\n descent: number; // suggested space below the baseline. > 0\n leading: number; // suggested spacing between descent of previous line and ascent of next line.\n bounds?: SkRect; // smallest rect containing all glyphs (relative to 0,0)\n}\n\nexport interface SkFont extends SkJSIInstance<\"Font\"> {\n /** Returns the advance width of text.\n The advance is the normal distance to move before drawing additional text.\n Returns the bounding box of text if bounds is not nullptr. The paint\n stroke settings, mask filter, or path effect may modify the bounds.\n\n @param text character storage encoded with SkTextEncoding\n @param byteLength length of character storage in bytes\n @param bounds returns bounding box relative to (0, 0) if not nullptr\n @param paint optional; may be nullptr\n @return number of glyphs represented by text of length byteLength\n */\n measureText: (text: string, paint?: SkPaint) => SkRect;\n\n /**\n * Returns the FontMetrics for this font.\n */\n getMetrics(): FontMetrics;\n\n /**\n * Retrieves the glyph ids for each code point in the provided string. This call is passed to\n * the typeface of this font. Note that glyph IDs are typeface-dependent; different faces\n * may have different ids for the same code point.\n * @param str\n * @param numCodePoints - the number of code points in the string. Defaults to str.length.\n */\n getGlyphIDs(str: string, numCodePoints?: number): number[];\n\n /**\n * Retrieves the advanceX measurements for each glyph.\n * If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected.\n * One width per glyph is returned in the returned array.\n * @param glyphs\n * @param paint\n * @param output - if provided, the results will be copied into this array.\n */\n getGlyphWidths(\n glyphs: number[],\n paint?: SkPaint | null,\n output?: Float32Array\n ): Float32Array;\n\n /**\n * Computes any intersections of a thick \"line\" and a run of positionsed glyphs.\n * The thick line is represented as a top and bottom coordinate (positive for\n * below the baseline, negative for above). If there are no intersections\n * (e.g. if this is intended as an underline, and there are no \"collisions\")\n * then the returned array will be empty. If there are intersections, the array\n * will contain pairs of X coordinates [start, end] for each segment that\n * intersected with a glyph.\n *\n * @param glyphs the glyphs to intersect with\n * @param positions x,y coordinates (2 per glyph) for each glyph\n * @param top top of the thick \"line\" to use for intersection testing\n * @param bottom bottom of the thick \"line\" to use for intersection testing\n * @return array of [start, end] x-coordinate pairs. Maybe be empty.\n */\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ): number[];\n\n /**\n * Returns text scale on x-axis. Default value is 1.\n */\n getScaleX(): number;\n\n /**\n * Returns text size in points.\n */\n getSize(): number;\n\n /**\n * Returns text skew on x-axis. Default value is zero.\n */\n getSkewX(): number;\n\n /**\n * Returns embolden effect for this font. Default value is false.\n */\n isEmbolden(): boolean;\n\n /**\n * Returns the Typeface set for this font.\n */\n getTypeface(): SkTypeface | null;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with partial transparency.\n * @param edging\n */\n setEdging(edging: FontEdging): void;\n\n /**\n * Requests, but does not require, to use bitmaps in fonts instead of outlines.\n * @param embeddedBitmaps\n */\n setEmbeddedBitmaps(embeddedBitmaps: boolean): void;\n\n /**\n * Sets level of glyph outline adjustment.\n * @param hinting\n */\n setHinting(hinting: FontHinting): void;\n\n /**\n * Requests, but does not require, linearly scalable font and glyph metrics.\n *\n * For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.\n * Note that some bitmap formats may not be able to scale linearly and will ignore this flag.\n * @param linearMetrics\n */\n setLinearMetrics(linearMetrics: boolean): void;\n\n /**\n * Sets the text scale on the x-axis.\n * @param sx\n */\n setScaleX(sx: number): void;\n\n /**\n * Sets the text size in points on this font.\n * @param points\n */\n setSize(points: number): void;\n\n /**\n * Sets the text-skew on the x axis for this font.\n * @param sx\n */\n setSkewX(sx: number): void;\n\n /**\n * Set embolden effect for this font.\n * @param embolden\n */\n setEmbolden(embolden: boolean): void;\n\n /**\n * Requests, but does not require, that glyphs respect sub-pixel positioning.\n * @param subpixel\n */\n setSubpixel(subpixel: boolean): void;\n\n /**\n * Sets the typeface to use with this font. null means to clear the typeface and use the\n * default one.\n * @param face\n */\n setTypeface(face: SkTypeface | null): void;\n}\n\nconst fontStyle = (\n weight: FontWeight,\n width: FontWidth,\n slant: FontSlant\n): FontStyle => ({ weight, width, slant });\n\nexport interface FontStyle {\n weight?: FontWeight;\n width?: FontWidth;\n slant?: FontSlant;\n}\n\nexport enum FontWeight {\n Invisible = 0,\n Thin = 100,\n ExtraLight = 200,\n Light = 300,\n Normal = 400,\n Medium = 500,\n SemiBold = 600,\n Bold = 700,\n ExtraBold = 800,\n Black = 900,\n ExtraBlack = 1000,\n}\n\nexport enum FontWidth {\n UltraCondensed = 1,\n ExtraCondensed = 2,\n Condensed = 3,\n SemiCondensed = 4,\n Normal = 5,\n SemiExpanded = 6,\n Expanded = 7,\n ExtraExpanded = 8,\n UltraExpanded = 9,\n}\n\nexport enum FontSlant {\n Upright,\n Italic,\n Oblique,\n}\n\nexport enum FontEdging {\n Alias,\n AntiAlias,\n SubpixelAntiAlias,\n}\n\nexport enum FontHinting {\n None,\n Slight,\n Normal,\n Full,\n}\n\nexport const FontStyle = {\n Normal: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Upright),\n Bold: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Upright),\n Italic: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Italic),\n BoldItalic: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Italic),\n};\n"]}
1
+ {"version":3,"sources":["Font.ts"],"names":["fontStyle","weight","width","slant","FontWeight","FontWidth","FontSlant","FontEdging","FontHin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AAS,GAAG;AACvBC,EAAAA,MAAM,EAAEV,SAAS,CAACI,UAAU,CAACM,MAAZ,EAAoBL,SAAS,CAACK,MAA9B,EAAsCJ,SAAS,CAACK,OAAhD,CADM;AAEvBC,EAAAA,IAAI,EAAEZ,SAAS,CAACI,UAAU,CAACQ,IAAZ,EAAkBP,SAAS,CAACK,MAA5B,EAAoCJ,SAAS,CAACK,OAA9C,CAFQ;AAGvBE,EAAAA,MAAM,EAAEb,SAAS,CAACI,UAAU,CAACM,MAAZ,EAAoBL,SAAS,CAACK,MAA9B,EAAsCJ,SAAS,CAACO,MAAhD,CAHM;AAIvBC,EAAAA,UAAU,EAAEd,SAAS,CAACI,UAAU,CAACQ,IAAZ,EAAkBP,SAAS,CAACK,MAA5B,EAAoCJ,SAAS,CAACO,MAA9C;AAJE,CAAlB","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkPaint } from \"../Paint\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkTypeface } from \"../Typeface\";\n\nexport interface FontMetrics {\n ascent: number; // suggested space above the baseline. < 0\n descent: number; // suggested space below the baseline. > 0\n leading: number; // suggested spacing between descent of previous line and ascent of next line.\n bounds?: SkRect; // smallest rect containing all glyphs (relative to 0,0)\n}\n\nexport interface SkFont extends SkJSIInstance<\"Font\"> {\n /**\n * Retrieves the advanceX measurements for each glyph.\n * If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected.\n * One width per glyph is returned in the returned array.\n * @param glyphs\n * @param paint\n */\n getGlyphWidths(glyphs: number[], paint?: SkPaint): number[];\n\n /** Returns the advance width of text.\n The advance is the normal distance to move before drawing additional text.\n Returns the bounding box of text if bounds is not nullptr. The paint\n stroke settings, mask filter, or path effect may modify the bounds.\n\n @param text character storage encoded with SkTextEncoding\n @param byteLength length of character storage in bytes\n @param bounds returns bounding box relative to (0, 0) if not nullptr\n @param paint optional; may be nullptr\n @return number of glyphs represented by text of length byteLength\n */\n measureText: (text: string, paint?: SkPaint) => SkRect;\n\n /**\n * Returns the FontMetrics for this font.\n */\n getMetrics(): FontMetrics;\n\n /**\n * Retrieves the glyph ids for each code point in the provided string. This call is passed to\n * the typeface of this font. Note that glyph IDs are typeface-dependent; different faces\n * may have different ids for the same code point.\n * @param str\n * @param numCodePoints - the number of code points in the string. Defaults to str.length.\n */\n getGlyphIDs(str: string, numCodePoints?: number): number[];\n\n /**\n * Computes any intersections of a thick \"line\" and a run of positionsed glyphs.\n * The thick line is represented as a top and bottom coordinate (positive for\n * below the baseline, negative for above). If there are no intersections\n * (e.g. if this is intended as an underline, and there are no \"collisions\")\n * then the returned array will be empty. If there are intersections, the array\n * will contain pairs of X coordinates [start, end] for each segment that\n * intersected with a glyph.\n *\n * @param glyphs the glyphs to intersect with\n * @param positions x,y coordinates (2 per glyph) for each glyph\n * @param top top of the thick \"line\" to use for intersection testing\n * @param bottom bottom of the thick \"line\" to use for intersection testing\n * @return array of [start, end] x-coordinate pairs. Maybe be empty.\n */\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ): number[];\n\n /**\n * Returns text scale on x-axis. Default value is 1.\n */\n getScaleX(): number;\n\n /**\n * Returns text size in points.\n */\n getSize(): number;\n\n /**\n * Returns text skew on x-axis. Default value is zero.\n */\n getSkewX(): number;\n\n /**\n * Returns embolden effect for this font. Default value is false.\n */\n isEmbolden(): boolean;\n\n /**\n * Returns the Typeface set for this font.\n */\n getTypeface(): SkTypeface | null;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with partial transparency.\n * @param edging\n */\n setEdging(edging: FontEdging): void;\n\n /**\n * Requests, but does not require, to use bitmaps in fonts instead of outlines.\n * @param embeddedBitmaps\n */\n setEmbeddedBitmaps(embeddedBitmaps: boolean): void;\n\n /**\n * Sets level of glyph outline adjustment.\n * @param hinting\n */\n setHinting(hinting: FontHinting): void;\n\n /**\n * Requests, but does not require, linearly scalable font and glyph metrics.\n *\n * For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.\n * Note that some bitmap formats may not be able to scale linearly and will ignore this flag.\n * @param linearMetrics\n */\n setLinearMetrics(linearMetrics: boolean): void;\n\n /**\n * Sets the text scale on the x-axis.\n * @param sx\n */\n setScaleX(sx: number): void;\n\n /**\n * Sets the text size in points on this font.\n * @param points\n */\n setSize(points: number): void;\n\n /**\n * Sets the text-skew on the x axis for this font.\n * @param sx\n */\n setSkewX(sx: number): void;\n\n /**\n * Set embolden effect for this font.\n * @param embolden\n */\n setEmbolden(embolden: boolean): void;\n\n /**\n * Requests, but does not require, that glyphs respect sub-pixel positioning.\n * @param subpixel\n */\n setSubpixel(subpixel: boolean): void;\n\n /**\n * Sets the typeface to use with this font. null means to clear the typeface and use the\n * default one.\n * @param face\n */\n setTypeface(face: SkTypeface | null): void;\n}\n\nconst fontStyle = (\n weight: FontWeight,\n width: FontWidth,\n slant: FontSlant\n): FontStyle => ({ weight, width, slant });\n\nexport interface FontStyle {\n weight?: FontWeight;\n width?: FontWidth;\n slant?: FontSlant;\n}\n\nexport enum FontWeight {\n Invisible = 0,\n Thin = 100,\n ExtraLight = 200,\n Light = 300,\n Normal = 400,\n Medium = 500,\n SemiBold = 600,\n Bold = 700,\n ExtraBold = 800,\n Black = 900,\n ExtraBlack = 1000,\n}\n\nexport enum FontWidth {\n UltraCondensed = 1,\n ExtraCondensed = 2,\n Condensed = 3,\n SemiCondensed = 4,\n Normal = 5,\n SemiExpanded = 6,\n Expanded = 7,\n ExtraExpanded = 8,\n UltraExpanded = 9,\n}\n\nexport enum FontSlant {\n Upright,\n Italic,\n Oblique,\n}\n\nexport enum FontEdging {\n Alias,\n AntiAlias,\n SubpixelAntiAlias,\n}\n\nexport enum FontHinting {\n None,\n Slight,\n Normal,\n Full,\n}\n\nexport const FontStyle = {\n Normal: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Upright),\n Bold: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Upright),\n Italic: fontStyle(FontWeight.Normal, FontWidth.Normal, FontSlant.Italic),\n BoldItalic: fontStyle(FontWeight.Bold, FontWidth.Normal, FontSlant.Italic),\n};\n"]}
@@ -8,8 +8,8 @@ let FilterMode;
8
8
  exports.FilterMode = FilterMode;
9
9
 
10
10
  (function (FilterMode) {
11
- FilterMode[FilterMode["Linear"] = 0] = "Linear";
12
- FilterMode[FilterMode["Nearest"] = 1] = "Nearest";
11
+ FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
12
+ FilterMode[FilterMode["Linear"] = 1] = "Linear";
13
13
  })(FilterMode || (exports.FilterMode = FilterMode = {}));
14
14
 
15
15
  let MipmapMode;
@@ -25,8 +25,8 @@ let ImageFormat;
25
25
  exports.ImageFormat = ImageFormat;
26
26
 
27
27
  (function (ImageFormat) {
28
- ImageFormat[ImageFormat["PNG"] = 0] = "PNG";
29
- ImageFormat[ImageFormat["JPEG"] = 1] = "JPEG";
30
- ImageFormat[ImageFormat["WEBP"] = 2] = "WEBP";
28
+ ImageFormat[ImageFormat["JPEG"] = 3] = "JPEG";
29
+ ImageFormat[ImageFormat["PNG"] = 4] = "PNG";
30
+ ImageFormat[ImageFormat["WEBP"] = 6] = "WEBP";
31
31
  })(ImageFormat || (exports.ImageFormat = ImageFormat = {}));
32
32
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Image.ts"],"names":["FilterMode","MipmapMode","ImageFormat"],"mappings":";;;;;;IAKYA,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAMAC,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Linear,\n Nearest,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n PNG,\n JPEG,\n WEBP,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"]}
1
+ {"version":3,"sources":["Image.ts"],"names":["FilterMode","MipmapMode","ImageFormat"],"mappings":";;;;;;IAKYA,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAMAC,W;;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"]}
@@ -25,9 +25,9 @@ let StrokeJoin;
25
25
  exports.StrokeJoin = StrokeJoin;
26
26
 
27
27
  (function (StrokeJoin) {
28
- StrokeJoin[StrokeJoin["Bevel"] = 0] = "Bevel";
29
- StrokeJoin[StrokeJoin["Miter"] = 1] = "Miter";
30
- StrokeJoin[StrokeJoin["Round"] = 2] = "Round";
28
+ StrokeJoin[StrokeJoin["Miter"] = 0] = "Miter";
29
+ StrokeJoin[StrokeJoin["Round"] = 1] = "Round";
30
+ StrokeJoin[StrokeJoin["Bevel"] = 2] = "Bevel";
31
31
  })(StrokeJoin || (exports.StrokeJoin = StrokeJoin = {}));
32
32
 
33
33
  const isPaint = obj => obj !== null && obj.__typename__ === "Paint";
@@ -1 +1 @@
1
- {"version":3,"sources":["Paint.ts"],"names":["PaintStyle","StrokeCap","StrokeJoin","isPaint","obj","__typename__"],"mappings":";;;;;;IAUYA,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,S;;;WAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAMAC,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;AAML,MAAMC,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC","sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { SkMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { SkColor } from \"../Color\";\nimport type { SkPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { BlendMode } from \"./BlendMode\";\n\nexport enum PaintStyle {\n Fill,\n Stroke,\n}\n\nexport enum StrokeCap {\n Butt,\n Round,\n Square,\n}\n\nexport enum StrokeJoin {\n Bevel,\n Miter,\n Round,\n}\n\nexport const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>\n obj !== null && obj.__typename__ === \"Paint\";\n\nexport interface SkPaint extends SkJSIInstance<\"Paint\"> {\n /**\n * Returns a copy of this paint.\n */\n copy(): SkPaint;\n\n /**\n * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values\n * (sRGB gamut, and encoded with the sRGB transfer function).\n */\n getColor(): SkColor;\n\n /**\n * Returns the geometry drawn at the beginning and end of strokes.\n */\n getStrokeCap(): StrokeCap;\n\n /**\n * Returns the geometry drawn at the corners of strokes.\n */\n getStrokeJoin(): StrokeJoin;\n\n /**\n * Returns the limit at which a sharp corner is drawn beveled.\n */\n getStrokeMiter(): number;\n\n /**\n * Returns the thickness of the pen used to outline the shape.\n */\n getStrokeWidth(): number;\n\n /**\n * Replaces alpha, leaving RGBA unchanged. 0 means fully transparent, 1.0 means opaque.\n * @param alpha\n */\n setAlphaf(alpha: number): void;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with\n * partial transparency.\n * @param aa\n */\n setAntiAlias: (aa: boolean) => void;\n\n /**\n * Sets the blend mode that is, the mode used to combine source color\n * with destination color.\n * @param mode\n */\n setBlendMode: (blendMode: BlendMode) => void;\n\n /**\n * Sets alpha and RGB used when stroking and filling. The color is a 32-bit\n * value, unpremultiplied, packing 8-bit components for alpha, red, blue,\n * and green.\n *\n * @param color unpremultiplied ARGB\n *\n * example: https://fiddle.skia.org/c/@Paint_setColor\n */\n setColor(color: SkColor): void;\n\n /**\n * Sets the current color filter, replacing the existing one if there was one.\n * @param filter\n */\n setColorFilter(filter: SkColorFilter | null): void;\n\n /**\n * Sets the current image filter, replacing the existing one if there was one.\n * @param filter\n */\n setImageFilter(filter: SkImageFilter | null): void;\n\n /**\n * Sets the current mask filter, replacing the existing one if there was one.\n * @param filter\n */\n setMaskFilter(filter: SkMaskFilter | null): void;\n\n /**\n * Sets the current path effect, replacing the existing one if there was one.\n * @param effect\n */\n setPathEffect(effect: SkPathEffect | null): void;\n\n /**\n * Sets the current shader, replacing the existing one if there was one.\n * @param shader\n */\n setShader(shader: SkShader | null): void;\n\n /**\n * Sets the geometry drawn at the beginning and end of strokes.\n * @param cap\n */\n setStrokeCap(cap: StrokeCap): void;\n\n /**\n * Sets the geometry drawn at the corners of strokes.\n * @param join\n */\n setStrokeJoin(join: StrokeJoin): void;\n\n /**\n * Sets the limit at which a sharp corner is drawn beveled.\n * @param limit\n */\n setStrokeMiter(limit: number): void;\n\n /**\n * Sets the thickness of the pen used to outline the shape.\n * @param width\n */\n setStrokeWidth(width: number): void;\n\n /**\n * Sets whether the geometry is filled or stroked.\n * @param style\n */\n setStyle(style: PaintStyle): void;\n}\n"]}
1
+ {"version":3,"sources":["Paint.ts"],"names":["PaintStyle","StrokeCap","StrokeJoin","isPaint","obj","__typename__"],"mappings":";;;;;;IAUYA,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,S;;;WAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;AAAAA,EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAMAC,U;;;WAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;AAML,MAAMC,OAAO,GAAIC,GAAD,IACrBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,OADhC","sourcesContent":["import type { SkImageFilter } from \"../ImageFilter\";\nimport type { SkMaskFilter } from \"../MaskFilter\";\nimport type { SkColorFilter } from \"../ColorFilter\";\nimport type { SkColor } from \"../Color\";\nimport type { SkPathEffect } from \"../PathEffect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { BlendMode } from \"./BlendMode\";\n\nexport enum PaintStyle {\n Fill,\n Stroke,\n}\n\nexport enum StrokeCap {\n Butt,\n Round,\n Square,\n}\n\nexport enum StrokeJoin {\n Miter,\n Round,\n Bevel,\n}\n\nexport const isPaint = (obj: SkJSIInstance<string> | null): obj is SkPaint =>\n obj !== null && obj.__typename__ === \"Paint\";\n\nexport interface SkPaint extends SkJSIInstance<\"Paint\"> {\n /**\n * Returns a copy of this paint.\n */\n copy(): SkPaint;\n\n /**\n * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values\n * (sRGB gamut, and encoded with the sRGB transfer function).\n */\n getColor(): SkColor;\n\n /**\n * Returns the geometry drawn at the beginning and end of strokes.\n */\n getStrokeCap(): StrokeCap;\n\n /**\n * Returns the geometry drawn at the corners of strokes.\n */\n getStrokeJoin(): StrokeJoin;\n\n /**\n * Returns the limit at which a sharp corner is drawn beveled.\n */\n getStrokeMiter(): number;\n\n /**\n * Returns the thickness of the pen used to outline the shape.\n */\n getStrokeWidth(): number;\n\n /**\n * Replaces alpha, leaving RGBA unchanged. 0 means fully transparent, 1.0 means opaque.\n * @param alpha\n */\n setAlphaf(alpha: number): void;\n\n /**\n * Requests, but does not require, that edge pixels draw opaque or with\n * partial transparency.\n * @param aa\n */\n setAntiAlias: (aa: boolean) => void;\n\n /**\n * Sets the blend mode that is, the mode used to combine source color\n * with destination color.\n * @param mode\n */\n setBlendMode: (blendMode: BlendMode) => void;\n\n /**\n * Sets alpha and RGB used when stroking and filling. The color is a 32-bit\n * value, unpremultiplied, packing 8-bit components for alpha, red, blue,\n * and green.\n *\n * @param color unpremultiplied ARGB\n *\n * example: https://fiddle.skia.org/c/@Paint_setColor\n */\n setColor(color: SkColor): void;\n\n /**\n * Sets the current color filter, replacing the existing one if there was one.\n * @param filter\n */\n setColorFilter(filter: SkColorFilter | null): void;\n\n /**\n * Sets the current image filter, replacing the existing one if there was one.\n * @param filter\n */\n setImageFilter(filter: SkImageFilter | null): void;\n\n /**\n * Sets the current mask filter, replacing the existing one if there was one.\n * @param filter\n */\n setMaskFilter(filter: SkMaskFilter | null): void;\n\n /**\n * Sets the current path effect, replacing the existing one if there was one.\n * @param effect\n */\n setPathEffect(effect: SkPathEffect | null): void;\n\n /**\n * Sets the current shader, replacing the existing one if there was one.\n * @param shader\n */\n setShader(shader: SkShader | null): void;\n\n /**\n * Sets the geometry drawn at the beginning and end of strokes.\n * @param cap\n */\n setStrokeCap(cap: StrokeCap): void;\n\n /**\n * Sets the geometry drawn at the corners of strokes.\n * @param join\n */\n setStrokeJoin(join: StrokeJoin): void;\n\n /**\n * Sets the limit at which a sharp corner is drawn beveled.\n * @param limit\n */\n setStrokeMiter(limit: number): void;\n\n /**\n * Sets the thickness of the pen used to outline the shape.\n * @param width\n */\n setStrokeWidth(width: number): void;\n\n /**\n * Sets whether the geometry is filled or stroked.\n * @param style\n */\n setStyle(style: PaintStyle): void;\n}\n"]}
@@ -39,7 +39,6 @@ exports.PathVerb = PathVerb;
39
39
  PathVerb[PathVerb["Conic"] = 3] = "Conic";
40
40
  PathVerb[PathVerb["Cubic"] = 4] = "Cubic";
41
41
  PathVerb[PathVerb["Close"] = 5] = "Close";
42
- PathVerb[PathVerb["Done"] = 6] = "Done";
43
42
  })(PathVerb || (exports.PathVerb = PathVerb = {}));
44
43
 
45
44
  const isPath = obj => obj !== null && obj.__typename__ === "Path";
@@ -1 +1 @@
1
- {"version":3,"sources":["Path.ts"],"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"mappings":";;;;;;;AAOA;AACA;AACA;IAeYA,Q;;;WAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;IAOAC,M;;;WAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAQAC,Q;;;WAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;AAYL,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC","sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n // eslint-disable-next-line camelcase\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n Done,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"]}
1
+ {"version":3,"sources":["Path.ts"],"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"mappings":";;;;;;;AAOA;AACA;AACA;IAeYA,Q;;;WAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;IAOAC,M;;;WAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;AAAAA,EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAQAC,Q;;;WAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;AAAAA,EAAAA,Q,CAAAA,Q;GAAAA,Q,wBAAAA,Q;;AAWL,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC","sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n // eslint-disable-next-line camelcase\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"]}
@@ -30,13 +30,7 @@ const processUniforms = (source, uniforms, builder) => {
30
30
  throw new Error(`No value specified for uniform ${name}`);
31
31
  }
32
32
 
33
- let result;
34
-
35
- if (Array.isArray(value)) {
36
- result = value.flatMap(processValue);
37
- }
38
-
39
- result = processValue(value);
33
+ const result = Array.isArray(value) ? value.flatMap(processValue) : processValue(value);
40
34
  builder === null || builder === void 0 ? void 0 : builder.setUniform(name, typeof result === "number" ? [result] : result);
41
35
  return result;
42
36
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["Shader.ts"],"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","value","processUniforms","source","uniforms","builder","processed","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","result","isArray","setUniform","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join"],"mappings":";;;;;;;AAIO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC;;;;AAaP,MAAMC,QAAQ,GAAIF,GAAD,IACf;AACA;AACCA,GAAD,CAAaG,CAAb,KAAmBC,SAAnB,IAAiCJ,GAAD,CAAaK,CAAb,KAAmBD,SAHrD;;AAKA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIL,QAAQ,CAACK,KAAD,CAAZ,EAAqB;AACnB,WAAO,CA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AAM,CAACW,cAAP,CAAsBF,CAAtB,CAFI,CAArB;AAGA,UAAMa,aAAa,GAAGN,KAAK,CACxBK,GADmB,CACdX,IAAD,IAAU;AACb,UAAIU,YAAY,CAACG,OAAb,CAAqBb,IAArB,MAA+B,CAAC,CAApC,EAAuC;AACrC,eAAOA,IAAP;AACD;;AACD,aAAO,IAAP;AACD,KANmB,EAOnBc,MAPmB,CAOXC,CAAD,IAAOA,CAAC,KAAK,IAPD,CAAtB;AAQAC,IAAAA,OAAO,CAACC,IAAR,CAAa,oCAAoCL,aAAa,CAACM,IAAd,CAAmB,IAAnB,CAAjD;AACD;;AACD,SAAOzB,SAAP;AACD,CArCM","sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type UniformValue = number | Vector | readonly number[];\n\nexport type Uniform = UniformValue | readonly UniformValue[];\n\nexport interface Uniforms {\n [name: string]: Uniform;\n}\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport const processUniforms = (\n source: SkRuntimeEffect,\n uniforms: Uniforms,\n builder?: SkRuntimeShaderBuilder\n) => {\n const processed = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n let result: number | readonly number[];\n if (Array.isArray(value)) {\n result = value.flatMap(processValue);\n }\n result = processValue(value as UniformValue);\n builder?.setUniform(name, typeof result === \"number\" ? [result] : result);\n return result;\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\"Unused uniforms were provided: \" + unusedUniform.join(\", \"));\n }\n return processed;\n};\n"]}
1
+ {"version":3,"sources":["Shader.ts"],"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","value","processUniforms","source","uniforms","builder","processed","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","result","isArray","setUniform","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join"],"mappings":";;;;;;;AAIO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC;;;;AAaP,MAAMC,QAAQ,GAAIF,GAAD,IACf;AACA;AACCA,GAAD,CAAaG,CAAb,KAAmBC,SAAnB,IAAiCJ,GAAD,CAAaK,CAAb,KAAmBD,SAHrD;;AAKA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIL,QAAQ,CAACK,KAAD,CAAZ,EAAqB;AACnB,WAAO,CAACA,KAAK,CAACJ,CAAP,EAAUI,KAAK,CAACF,CAAhB,CAAP;AACD;;AACD,SAAOE,KAAP;AACD,CALD;;AAOO,MAAMC,eAAe,GAAG,CAC7BC,MAD6B,EAE7BC,QAF6B,EAG7BC,OAH6B,KAI1B;AACH,QAAMC,SAAS,GAAG,IAAIC,KAAJ,CAAUJ,MAAM,CAACK,eAAP,EAAV,EACfC,IADe,CACV,CADU,EAEfC,OAFe,CAEP,CAACC,CAAD,EAAIC,CAAJ,KAAU;AACjB,UAAMC,IAAI,GAAGV,MAAM,CAACW,cAAP,CAAsBF,CAAtB,CAAb;AACA,UAAM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import type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type UniformValue = number | Vector | readonly number[];\n\nexport type Uniform = UniformValue | readonly UniformValue[];\n\nexport interface Uniforms {\n [name: string]: Uniform;\n}\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport const processUniforms = (\n source: SkRuntimeEffect,\n uniforms: Uniforms,\n builder?: SkRuntimeShaderBuilder\n) => {\n const processed = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n const result = Array.isArray(value)\n ? value.flatMap(processValue)\n : processValue(value as UniformValue);\n builder?.setUniform(name, typeof result === \"number\" ? [result] : result);\n return result;\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\"Unused uniforms were provided: \" + unusedUniform.join(\", \"));\n }\n return processed;\n};\n"]}
@@ -115,7 +115,7 @@ class JsiSkCanvas extends _Host.HostObject {
115
115
  }
116
116
 
117
117
  drawGlyphs(glyphs, positions, x, y, font, paint) {
118
- this.ref.drawGlyphs(glyphs, (0, _Host.toValue)(positions), x, y, (0, _Host.toValue)(font), (0, _Host.toValue)(paint));
118
+ this.ref.drawGlyphs(glyphs, positions.map(p => [p.x, p.y]).flat(), x, y, (0, _Host.toValue)(font), (0, _Host.toValue)(paint));
119
119
  }
120
120
 
121
121
  drawSvg(_svgDom, _width, _height) {
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkCanvas.ts"],"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","drawRect","rect","paint","JsiSkRect","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","drawPatch","cubics","colors","texs","map","flat","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","undefined","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","drawPicture","skp"],"mappings":";;;;;;;AA0BA;;AAOA;;AAEO,MAAMA,WAAN,SACGC,gBADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAoC;AAC7C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;AACD;;AAEDC,EAAAA,QAAQ,CAACC,IAAD,EAAeC,KAAf,EAA+B;AACrC,SAAKH,GAAL,CAASC,QAAT,CACEG,qBAAUC,SAAV,CAAoB,KAAKN,SAAzB,EAAoCG,IAApC,EAA0CF,GAD5C,EAEE,mBAAeG,KAAf,CAFF;AAID;;AAEDG,EAAAA,SAAS,CAACC,KAAD,EAAiBC,CAAjB,EAA4BC,CAA5B,EAAuCN,KAAvC,EAAwD;AAC/D,SAAK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import type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport {\n ckEnum,\n HostObject,\n toValue,\n toUndefinedableValue,\n toOptionalValue,\n} from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect).ref,\n toValue<Paint>(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(toValue<Image>(image), x, y, toOptionalValue(paint));\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n toValue<Paint>(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n toValue(img),\n left,\n top,\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n toValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n toValue(img),\n toValue(center),\n toValue(dest),\n ckEnum(filter),\n toOptionalValue(paint)\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(toValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, toValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, toValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(toValue(verts), ckEnum(mode), toValue(paint));\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n toOptionalValue(texs),\n mode ? ckEnum(mode) : null,\n toUndefinedableValue(paint)\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n toValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n toValue(oval),\n startAngle,\n sweepAngle,\n useCenter,\n toValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(toValue(rrect), toValue(paint));\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(toValue(outer), toValue(inner), toValue(paint));\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(toValue(oval), toValue(paint));\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(toValue(path), toValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(str, x, y, toValue(paint), toValue(font));\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(toValue(blob), x, y, toValue(paint));\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n toValue(positions),\n x,\n y,\n toValue(font),\n toValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n toUndefinedableValue(paint),\n toOptionalValue(bounds),\n toOptionalValue(backdrop),\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(toValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(toValue(rect), ckEnum(op), doAntiAlias);\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(toValue(rrect), ckEnum(op), doAntiAlias);\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(toValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(toValue(skp));\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkCanvas.ts"],"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","drawRect","rect","paint","JsiSkRect","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","drawPatch","cubics","colors","texs","map","flat","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","p","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","undefined","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","drawPicture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,GAAL,CAASuG,QAAT,CAAkB,mBAAQrG,IAAR,CAAlB,EAAiC,kBAAOmG,EAAP,CAAjC,EAA6CC,WAA7C;AACD;;AAEDE,EAAAA,SAAS,CAAC/C,KAAD,EAAiB4C,EAAjB,EAA6BC,WAA7B,EAAmD;AAC1D,SAAKtG,GAAL,CAASwG,SAAT,CAAmB,mBAAQ/C,KAAR,CAAnB,EAAmC,kBAAO4C,EAAP,CAAnC,EAA+CC,WAA/C;AACD;;AAEDG,EAAAA,MAAM,CAACC,CAAD,EAAc;AAClB,SAAK1G,GAAL,CAASyG,MAAT,CAAgB,mBAAQC,CAAR,CAAhB;AACD;;AAEDC,EAAAA,WAAW,CAACC,GAAD,EAAiB;AAC1B,SAAK5G,GAAL,CAAS2G,WAAT,CAAqB,mBAAQC,GAAR,CAArB;AACD;;AAlSH","sourcesContent":["import type { Canvas, Image, CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport {\n ckEnum,\n HostObject,\n toValue,\n toUndefinedableValue,\n toOptionalValue,\n} from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect).ref,\n toValue<Paint>(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(toValue<Image>(image), x, y, toOptionalValue(paint));\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n toValue<Paint>(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n toValue(img),\n left,\n top,\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n toValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n toValue(img),\n toValue(center),\n toValue(dest),\n ckEnum(filter),\n toOptionalValue(paint)\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src).ref,\n JsiSkRect.fromValue(this.CanvasKit, dest).ref,\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(toValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, toValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, toValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(toValue(verts), ckEnum(mode), toValue(paint));\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n toOptionalValue(texs),\n mode ? ckEnum(mode) : null,\n toUndefinedableValue(paint)\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n toValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n toValue(oval),\n startAngle,\n sweepAngle,\n useCenter,\n toValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(toValue(rrect), toValue(paint));\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(toValue(outer), toValue(inner), toValue(paint));\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(toValue(oval), toValue(paint));\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(toValue(path), toValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(str, x, y, toValue(paint), toValue(font));\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(toValue(blob), x, y, toValue(paint));\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n toValue(font),\n toValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n toUndefinedableValue(paint),\n toOptionalValue(bounds),\n toOptionalValue(backdrop),\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(toValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(toValue(rect), ckEnum(op), doAntiAlias);\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(toValue(rrect), ckEnum(op), doAntiAlias);\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(toValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(toValue(skp));\n }\n}\n"]}
@@ -17,7 +17,9 @@ class JsiSkFont extends _Host.HostObject {
17
17
  }
18
18
 
19
19
  measureText(_text, _paint) {
20
- throw new _Host.NotImplementedOnRNWeb();
20
+ console.warn(`measureText() is deprecated an returns an empty rectangle on React Native Web.
21
+ Clients should use "Font.getGlyphWidths" instead (the latter does no shaping)`);
22
+ return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));
21
23
  }
22
24
 
23
25
  getMetrics() {
@@ -37,7 +39,7 @@ class JsiSkFont extends _Host.HostObject {
37
39
 
38
40
 
39
41
  getGlyphWidths(glyphs, paint) {
40
- return this.ref.getGlyphWidths(glyphs, paint ? (0, _Host.toValue)(paint) : null);
42
+ return [...this.ref.getGlyphWidths(glyphs, paint ? (0, _Host.toValue)(paint) : null)];
41
43
  }
42
44
 
43
45
  getGlyphIntercepts(glyphs, positions, top, bottom) {
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkFont.ts"],"names":["JsiSkFont","HostObject","constructor","CanvasKit","ref","measureText","_text","_paint","NotImplementedOnRNWeb","getMetrics","result","ascent","descent","leading","bounds","JsiSkRect","undefined","getGlyphIDs","str","numCodePoints","getGlyphWidths","glyphs","paint","getGlyphIntercepts","positions","top","bottom","map","p","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AAEO,MAAMA,SAAN,SAAwBC,gBAAxB,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;AAC3C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;AACD;;AAEDC,EAAAA,WAAW,CAACC,KAAD,EAAgBC,MAAhB,EAA0C;AACnD,UAAM,IAAIC,2BAAJ,EAAN;A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AT,CAAqBC,IAAI,GAAG,mBAAQA,IAAR,CAAH,GAAmB,IAA5C;AACD;;AA1GuE","sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, NotImplementedOnRNWeb, toValue, ckEnum } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint): SkRect {\n throw new NotImplementedOnRNWeb();\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return this.ref.getGlyphWidths(glyphs, paint ? toValue(paint) : null);\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => toValue(p)),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? toValue(face) : null);\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkFont.ts"],"names":["JsiSkFont","HostObject","constructor","CanvasKit","ref","measureText","_text","_paint","console","warn","JsiSkRect","XYWHRect","getMetrics","result","ascent","descent","leading","bounds","undefined","getGlyphIDs","str","numCodePoints","getGlyphWidths","glyphs","paint","getGlyphIntercepts","positions","top","bottom","map","p","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AAEO,MAAMA,SAAN,SAAwBC,gBAAxB,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;AAC3C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;AACD;;AAEDC,EAAAA,WAAW,CAACC,KAAD,EAAgBC,MAAhB,EAA0C;AACnDC,IAAAA,OAAO,CAACC,IAAR,CACG;AACP,8EAFI;AAIA,WAAO,IAAIC,oBAAJ,CAAc,KAAKP,S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D,EAAoB;AAC7B,SAAKlD,GAAL,CAASiD,WAAT,CAAqBC,QAArB;AACD;;AAEDC,EAAAA,WAAW,CAACC,IAAD,EAA0B;AACnC,SAAKpD,GAAL,CAASmD,WAAT,CAAqBC,IAAI,GAAG,mBAAQA,IAAR,CAAH,GAAmB,IAA5C;AACD;;AA9GuE","sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, toValue, ckEnum } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint): SkRect {\n console.warn(\n `measureText() is deprecated an returns an empty rectangle on React Native Web.\nClients should use \"Font.getGlyphWidths\" instead (the latter does no shaping)`\n );\n return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [...this.ref.getGlyphWidths(glyphs, paint ? toValue(paint) : null)];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => toValue(p)),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? toValue(face) : null);\n }\n}\n"]}
@@ -9,8 +9,6 @@ var _Host = require("./Host");
9
9
 
10
10
  class JsiSkFontMgr extends _Host.HostObject {
11
11
  constructor(CanvasKit) {
12
- console.warn( // eslint-disable-next-line max-len
13
- "Using system fonts is deprecated. Please use the font property instead: https://shopify.github.io/react-native-skia/docs/text/fonts");
14
12
  super(CanvasKit, null, "FontMgr");
15
13
  }
16
14
 
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkFontMgr.ts"],"names":["JsiSkFontMgr","HostObject","constructor","CanvasKit","console","warn","countFamilies","getFamilyName","_index","matchFamilyStyle","_familyName","_fontStyle"],"mappings":";;;;;;;AAIA;;AAEO,MAAMA,YAAN,SACGC,gBADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChCC,IAAAA,OAAO,CAACC,IAAR,EACE;AACA,yIAFF;AAIA,UAAMF,SAAN,EAAiB,IAAjB,EAAuB,SAAvB;AACD;;AAEDG,EAAAA,aAAa,GAAG;AACdF,IAAAA,OAAO,CAACC,IAAR,CACE,iEADF;AAGA,WAAO,CAAP;AACD;;AAEDE,EAAAA,aAAa,CAACC,MAAD,EAAiB;AAC5BJ,IAAAA,OAAO,CAACC,IAAR,CACE,+EADF;AAGA,WAAO,EAAP;AACD;;AAEDI,EAAAA,gBAAgB,CACdC,WADc,EAEdC,UAFc,EAGK;AACnBP,IAAAA,OAAO,CAACC,IAAR,CACE,uEADF;AAGA,WAAO,IAAP;AACD;;AA/BH","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { FontStyle, SkFontMgr, SkTypeface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkFontMgr\n extends HostObject<null, \"FontMgr\">\n implements SkFontMgr\n{\n constructor(CanvasKit: CanvasKit) {\n console.warn(\n // eslint-disable-next-line max-len\n \"Using system fonts is deprecated. Please use the font property instead: https://shopify.github.io/react-native-skia/docs/text/fonts\"\n );\n super(CanvasKit, null, \"FontMgr\");\n }\n\n countFamilies() {\n console.warn(\n \"countFamilies() is deprecated. It returns 0 on React Native Web\"\n );\n return 0;\n }\n\n getFamilyName(_index: number) {\n console.warn(\n \"getFamilyName() is deprecated. It returns an empty string on React Native Web\"\n );\n return \"\";\n }\n\n matchFamilyStyle(\n _familyName: string,\n _fontStyle?: FontStyle\n ): SkTypeface | null {\n console.warn(\n \"matchFamilyStyle() is deprecated. It returns null on React Native Web\"\n );\n return null;\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkFontMgr.ts"],"names":["JsiSkFontMgr","HostObject","constructor","CanvasKit","countFamilies","console","warn","getFamilyName","_index","matchFamilyStyle","_familyName","_fontStyle"],"mappings":";;;;;;;AAIA;;AAEO,MAAMA,YAAN,SACGC,gBADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN,EAAiB,IAAjB,EAAuB,SAAvB;AACD;;AAEDC,EAAAA,aAAa,GAAG;AACdC,IAAAA,OAAO,CAACC,IAAR,CACE,iEADF;AAGA,WAAO,CAAP;AACD;;AAEDC,EAAAA,aAAa,CAACC,MAAD,EAAiB;AAC5BH,IAAAA,OAAO,CAACC,IAAR,CACE,+EADF;AAGA,WAAO,EAAP;AACD;;AAEDG,EAAAA,gBAAgB,CACdC,WADc,EAEdC,UAFc,EAGK;AACnBN,IAAAA,OAAO,CAACC,IAAR,CACE,uEADF;AAGA,WAAO,IAAP;AACD;;AA3BH","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { FontStyle, SkFontMgr, SkTypeface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\n\nexport class JsiSkFontMgr\n extends HostObject<null, \"FontMgr\">\n implements SkFontMgr\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit, null, \"FontMgr\");\n }\n\n countFamilies() {\n console.warn(\n \"countFamilies() is deprecated. It returns 0 on React Native Web\"\n );\n return 0;\n }\n\n getFamilyName(_index: number) {\n console.warn(\n \"getFamilyName() is deprecated. It returns an empty string on React Native Web\"\n );\n return \"\";\n }\n\n matchFamilyStyle(\n _familyName: string,\n _fontStyle?: FontStyle\n ): SkTypeface | null {\n console.warn(\n \"matchFamilyStyle() is deprecated. It returns null on React Native Web\"\n );\n return null;\n }\n}\n"]}
@@ -7,6 +7,9 @@ exports.JsiSkImage = void 0;
7
7
 
8
8
  var _Host = require("./Host");
9
9
 
10
+ var _JsiSkShader = require("./JsiSkShader");
11
+
12
+ /*global btoa, atob*/
10
13
  class JsiSkImage extends _Host.HostObject {
11
14
  constructor(CanvasKit, ref) {
12
15
  super(CanvasKit, ref, "Image");
@@ -20,12 +23,12 @@ class JsiSkImage extends _Host.HostObject {
20
23
  return this.ref.width();
21
24
  }
22
25
 
23
- makeShaderOptions(_tx, _ty, _fm, _mm, _localMatrix) {
24
- throw new Error("Not implemented yet");
26
+ makeShaderOptions(tx, ty, fm, mm, localMatrix) {
27
+ return new _JsiSkShader.JsiSkShader(this.CanvasKit, this.ref.makeShaderOptions((0, _Host.ckEnum)(tx), (0, _Host.ckEnum)(ty), (0, _Host.ckEnum)(fm), (0, _Host.ckEnum)(mm), localMatrix ? (0, _Host.toValue)(localMatrix) : undefined));
25
28
  }
26
29
 
27
- makeShaderCubic(_tx, _ty, _B, _C, _localMatrix) {
28
- throw new Error("Not implemented yet");
30
+ makeShaderCubic(tx, ty, B, C, localMatrix) {
31
+ return new _JsiSkShader.JsiSkShader(this.CanvasKit, this.ref.makeShaderCubic((0, _Host.ckEnum)(tx), (0, _Host.ckEnum)(ty), B, C, localMatrix ? (0, _Host.toValue)(localMatrix) : undefined));
29
32
  }
30
33
 
31
34
  encodeToBytes(fmt, quality) {
@@ -46,8 +49,9 @@ class JsiSkImage extends _Host.HostObject {
46
49
  return result;
47
50
  }
48
51
 
49
- encodeToBase64(_fmt, _quality) {
50
- throw new Error("Not implemented yet");
52
+ encodeToBase64(fmt, quality) {
53
+ const bytes = this.encodeToBytes(fmt, quality);
54
+ return btoa(String.fromCharCode(...bytes));
51
55
  }
52
56
 
53
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkImage.ts"],"names":["JsiSkImage","HostObject","constructor","CanvasKit","ref","height","width","makeShaderOptions","_tx","_ty","_fm","_mm","_localMatrix","Error","makeShaderCubic","_B","_C","encodeToBytes","fmt","quality","result","encodeToBase64","_fmt","_quality"],"mappings":";;;;;;;AAYA;;AAEO,MAAMA,UAAN,SAAyBC,gBAAzB,CAAuE;AAC5EC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAmC;AAC5C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,OAAtB;AACD;;AAEDC,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKD,GAAL,CAASC,MAAT,EAAP;AACD;;AAEDC,EAAAA,KAAK,GAAG;AACN,WAAO,KAAKF,GAAL,CAASE,KAAT,EAAP;AACD;;AAEDC,EAAAA,iBAAiB,CACfC,GADe,EAEfC,GAFe,EAGfC,GAHe,EAIfC,GAJe,EAKfC,YALe,EAML;AACV,UAAM,IAAIC,KAAJ,CAAU,qBAAV,CAAN;AACD;;AAEDC,EAAAA,eAAe,CACbN,GADa,EAEbC,GAFa,EAGbM,EAHa,EAIbC,EAJa,EAKbJ,YALa,EAMH;AACV,UAAM,IAAIC,KAAJ,CAAU,qBAAV,CAAN;AACD;;AAEDI,EAAAA,aAAa,CAACC,GAAD,EAAoBC,OAApB,EAAkD;AAC7D,QAAIC,MAAJ;;AACA,QAAIF,GAAG,IAAIC,OAAX,EAAoB;AAClBC,MAAAA,MAAM,GAAG,KAAKhB,GAAL,CAASa,aAAT,CAAuB,kBAAOC,GAAP,CAAvB,EAAoCC,OAApC,CAAT;AACD,KAFD,MAEO,IAAID,GAAJ,EAAS;AACdE,MAAAA,MAAM,GAAG,KAAKhB,GAAL,CAASa,aAAT,CAAuB,kBAAOC,GAAP,CAAvB,CAAT;AACD,KAFM,MAEA;AACLE,MAAAA,MAAM,GAAG,KAAKhB,GAAL,CAASa,aAAT,EAAT;AACD;;AACD,QAAI,CAACG,MAAL,EAAa;AACX,YAAM,IAAIP,KAAJ,CAAU,sBAAV,CAAN;AACD;;AACD,WAAOO,MAAP;AACD;;AAEDC,EAAAA,cAAc,CAACC,IAAD,EAAqBC,QAArB,EAAgD;AAC5D,UAAM,IAAIV,KAAJ,CAAU,qBAAV,CAAN;AACD;;AAlD2E","sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n _tx: TileMode,\n _ty: TileMode,\n _fm: FilterMode,\n _mm: MipmapMode,\n _localMatrix?: SkMatrix\n ): SkShader {\n throw new Error(\"Not implemented yet\");\n }\n\n makeShaderCubic(\n _tx: TileMode,\n _ty: TileMode,\n _B: number,\n _C: number,\n _localMatrix?: SkMatrix\n ): SkShader {\n throw new Error(\"Not implemented yet\");\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(_fmt?: ImageFormat, _quality?: number): string {\n throw new Error(\"Not implemented yet\");\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkImage.ts"],"names":["JsiSkImage","HostObject","constructor","CanvasKit","ref","height","width","makeShaderOptions","tx","ty","fm","mm","localMatrix","JsiSkShader","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","result","Error","encodeToBase64","bytes","btoa","String","fromCharCode"],"mappings":";;;;;;;AAaA;;AACA;;AAdA;AAgBO,MAAMA,UAAN,SAAyBC,gBAAzB,CAAuE;AAC5EC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAmC;AAC5C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,OAAtB;AACD;;AAEDC,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKD,GAAL,CAASC,MAAT,EAAP;AACD;;AAEDC,EAAAA,KAAK,GAAG;AACN,WAAO,KAAKF,GAAL,CAASE,KAAT,EAAP;AACD;;AAEDC,EAAAA,iBAAiB,CACfC,EADe,EAEfC,EAFe,EAGfC,EAHe,EAIfC,EAJe,EAKfC,WALe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WAAOK,IAAI,CAACC,MAAM,CAACC,YAAP,CAAoB,GAAGH,KAAvB,CAAD,CAAX;AACD;;AArE2E","sourcesContent":["/*global btoa, atob*/\nimport type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject, toValue } from \"./Host\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? toValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? toValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return btoa(String.fromCharCode(...bytes));\n }\n}\n"]}
@@ -65,4 +65,4 @@ class JsiSkImageFilterFactory extends _Host.Host {
65
65
  }
66
66
 
67
67
  exports.JsiSkImageFilterFactory = JsiSkImageFilterFactory;
68
- //# sourceMappingURL=JsiImageFilterFactory.js.map
68
+ //# sourceMappingURL=JsiSkImageFilterFactory.js.map