react-native-nano-icons 0.2.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/LICENSES.md +40 -0
  2. package/README.md +41 -10
  3. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
  4. package/android/src/main/java/com/nanoicons/NanoIconView.kt +50 -15
  5. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +78 -12
  6. package/ios/NanoIconFontResolver.h +5 -0
  7. package/ios/NanoIconFontResolver.mm +32 -0
  8. package/ios/NanoIconView.h +0 -4
  9. package/ios/NanoIconView.mm +62 -57
  10. package/ios/NanoIconsFontLoader.mm +10 -32
  11. package/lib/commonjs/cli/build.d.ts +11 -3
  12. package/lib/commonjs/cli/build.js +86 -25
  13. package/lib/commonjs/cli/config.d.ts +1 -1
  14. package/lib/commonjs/cli/config.js +1 -1
  15. package/lib/commonjs/cli/expoConfig.d.ts +3 -2
  16. package/lib/commonjs/cli/expoConfig.js +22 -9
  17. package/lib/commonjs/cli/index.d.ts +5 -5
  18. package/lib/commonjs/cli/index.js +16 -14
  19. package/lib/commonjs/cli/link.d.ts +4 -3
  20. package/lib/commonjs/cli/link.js +127 -45
  21. package/lib/commonjs/cli/logger.js +9 -7
  22. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
  23. package/lib/commonjs/plugin/src/buildFonts.js +5 -15
  24. package/lib/commonjs/plugin/src/index.d.ts +2 -2
  25. package/lib/commonjs/plugin/src/index.js +2 -2
  26. package/lib/commonjs/plugin/src/types.d.ts +10 -1
  27. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
  28. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
  29. package/lib/commonjs/scripts/cli.js +46 -23
  30. package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
  31. package/lib/commonjs/src/core/flatten/arcs.js +136 -0
  32. package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
  33. package/lib/commonjs/src/core/flatten/document.js +164 -0
  34. package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
  35. package/lib/commonjs/src/core/flatten/dom.js +221 -0
  36. package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
  37. package/lib/commonjs/src/core/flatten/element.js +97 -0
  38. package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
  39. package/lib/commonjs/src/core/flatten/geometry.js +85 -0
  40. package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
  41. package/lib/commonjs/src/core/flatten/index.js +11 -0
  42. package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
  43. package/lib/commonjs/src/core/flatten/inherit.js +249 -0
  44. package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
  45. package/lib/commonjs/src/core/flatten/path.js +439 -0
  46. package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
  47. package/lib/commonjs/src/core/flatten/pathops.js +236 -0
  48. package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
  49. package/lib/commonjs/src/core/flatten/shape.js +415 -0
  50. package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
  51. package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
  52. package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
  53. package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
  54. package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
  55. package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
  56. package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
  57. package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
  58. package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
  59. package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
  60. package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
  61. package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
  62. package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
  63. package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
  64. package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
  65. package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
  66. package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
  67. package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
  68. package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
  69. package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
  70. package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
  71. package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
  72. package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
  73. package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
  74. package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
  75. package/lib/commonjs/src/core/flatten/stages.js +40 -0
  76. package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
  77. package/lib/commonjs/src/core/flatten/transform.js +221 -0
  78. package/lib/commonjs/src/core/font/compile.d.ts +2 -1
  79. package/lib/commonjs/src/core/font/compile.js +21 -7
  80. package/lib/commonjs/src/core/font/metrics.js +7 -0
  81. package/lib/commonjs/src/core/font/quadratic.d.ts +1 -0
  82. package/lib/commonjs/src/core/font/quadratic.js +31 -0
  83. package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
  84. package/lib/commonjs/src/core/glyph/merge.js +57 -0
  85. package/lib/commonjs/src/core/glyph/parse.d.ts +26 -0
  86. package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
  87. package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
  88. package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
  89. package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
  90. package/lib/commonjs/src/core/glyph/validate.js +33 -0
  91. package/lib/commonjs/src/core/pathkit/contours.d.ts +74 -0
  92. package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +72 -312
  93. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
  94. package/lib/commonjs/src/core/pathkit/evenodd.js +51 -0
  95. package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
  96. package/lib/commonjs/src/core/pathkit/load.js +26 -0
  97. package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
  98. package/lib/commonjs/src/core/pathkit/types.js +2 -0
  99. package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
  100. package/lib/commonjs/src/core/pipeline/iconPool.d.ts +3 -0
  101. package/lib/commonjs/src/core/pipeline/iconPool.js +51 -0
  102. package/lib/commonjs/src/core/pipeline/index.d.ts +3 -3
  103. package/lib/commonjs/src/core/pipeline/index.js +6 -5
  104. package/lib/commonjs/src/core/pipeline/prepare.d.ts +19 -0
  105. package/lib/commonjs/src/core/pipeline/prepare.js +56 -0
  106. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +22 -0
  107. package/lib/commonjs/src/core/pipeline/prepareIcon.js +78 -0
  108. package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
  109. package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
  110. package/lib/commonjs/src/core/pipeline/{run.d.ts → runFontPipeline.d.ts} +7 -4
  111. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +109 -0
  112. package/lib/commonjs/src/core/types.d.ts +3 -92
  113. package/lib/commonjs/src/utils/fingerPrint.d.ts +8 -1
  114. package/lib/commonjs/src/utils/fingerPrint.js +8 -1
  115. package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
  116. package/lib/commonjs/src/utils/fontIdentity.js +24 -0
  117. package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
  118. package/lib/commonjs/src/utils/packageVersion.js +37 -0
  119. package/lib/commonjs/src/utils/parse.d.ts +0 -1
  120. package/lib/commonjs/src/utils/parse.js +0 -8
  121. package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
  122. package/lib/commonjs/src/utils/svgPatterns.js +46 -0
  123. package/lib/module/const/codegenPrimitives.js +1 -2
  124. package/lib/module/const/colors.js +1 -2
  125. package/lib/module/createNanoIconsSet.js +1 -2
  126. package/lib/module/createNanoIconsSet.native.js +11 -4
  127. package/lib/module/createNanoIconsSet.shared.js +12 -7
  128. package/lib/module/createNanoIconsSet.web.js +7 -5
  129. package/lib/module/fontIntegrity.js +99 -0
  130. package/lib/module/index.js +1 -1
  131. package/lib/module/index.node.js +1 -2
  132. package/lib/module/loadDynamicFont.js +14 -7
  133. package/lib/module/nativeFontLoader.js +3 -0
  134. package/lib/module/nativeFontLoader.web.js +3 -0
  135. package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
  136. package/lib/module/types.js +1 -2
  137. package/lib/module/utils/fingerPrint.js +3 -3
  138. package/lib/module/utils/fontIdentity.js +20 -0
  139. package/lib/module/utils/glyphRuntime.js +1 -2
  140. package/lib/module/utils/packageVersion.js +29 -0
  141. package/lib/module/utils/parse.js +1 -9
  142. package/lib/module/utils/runtimeLog.js +12 -0
  143. package/lib/module/utils/shallowEqualColor.js +1 -2
  144. package/lib/module/utils/svgPatterns.js +49 -0
  145. package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
  146. package/lib/typescript/src/core/flatten/document.d.ts +36 -0
  147. package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
  148. package/lib/typescript/src/core/flatten/element.d.ts +13 -0
  149. package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
  150. package/lib/typescript/src/core/flatten/index.d.ts +3 -0
  151. package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
  152. package/lib/typescript/src/core/flatten/path.d.ts +20 -0
  153. package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
  154. package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
  155. package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
  156. package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
  157. package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
  158. package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
  159. package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
  160. package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
  161. package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
  162. package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
  163. package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
  164. package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
  165. package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
  166. package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
  167. package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
  168. package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
  169. package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
  170. package/lib/typescript/src/core/glyph/parse.d.ts +27 -0
  171. package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
  172. package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
  173. package/lib/typescript/src/core/pathkit/contours.d.ts +75 -0
  174. package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
  175. package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
  176. package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
  177. package/lib/typescript/src/core/types.d.ts +3 -92
  178. package/lib/typescript/src/fontIntegrity.d.ts +24 -0
  179. package/lib/typescript/src/index.d.ts +1 -0
  180. package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
  181. package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
  182. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  183. package/lib/typescript/src/types.d.ts +5 -0
  184. package/lib/typescript/src/utils/fingerPrint.d.ts +8 -1
  185. package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
  186. package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
  187. package/lib/typescript/src/utils/parse.d.ts +0 -1
  188. package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
  189. package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
  190. package/package.json +13 -11
  191. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  192. package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
  193. package/lib/commonjs/src/core/pipeline/managers.js +0 -104
  194. package/lib/commonjs/src/core/pipeline/run.js +0 -189
  195. package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
  196. package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
  197. package/lib/module/const/codegenPrimitives.js.map +0 -1
  198. package/lib/module/const/colors.js.map +0 -1
  199. package/lib/module/core/font/compile.js +0 -81
  200. package/lib/module/core/font/compile.js.map +0 -1
  201. package/lib/module/core/font/metrics.js +0 -37
  202. package/lib/module/core/font/metrics.js.map +0 -1
  203. package/lib/module/core/pipeline/config.js +0 -20
  204. package/lib/module/core/pipeline/config.js.map +0 -1
  205. package/lib/module/core/pipeline/index.js +0 -5
  206. package/lib/module/core/pipeline/index.js.map +0 -1
  207. package/lib/module/core/pipeline/managers.js +0 -94
  208. package/lib/module/core/pipeline/managers.js.map +0 -1
  209. package/lib/module/core/pipeline/run.js +0 -204
  210. package/lib/module/core/pipeline/run.js.map +0 -1
  211. package/lib/module/core/shims/pathops.py +0 -181
  212. package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  213. package/lib/module/core/svg/layers.js +0 -85
  214. package/lib/module/core/svg/layers.js.map +0 -1
  215. package/lib/module/core/svg/svg_dom.js +0 -170
  216. package/lib/module/core/svg/svg_dom.js.map +0 -1
  217. package/lib/module/core/svg/svg_pathops.js +0 -750
  218. package/lib/module/core/svg/svg_pathops.js.map +0 -1
  219. package/lib/module/core/tsconfig.json +0 -32
  220. package/lib/module/core/types.js +0 -2
  221. package/lib/module/core/types.js.map +0 -1
  222. package/lib/module/createNanoIconsSet.js.map +0 -1
  223. package/lib/module/createNanoIconsSet.native.js.map +0 -1
  224. package/lib/module/createNanoIconsSet.shared.js.map +0 -1
  225. package/lib/module/createNanoIconsSet.web.js.map +0 -1
  226. package/lib/module/index.js.map +0 -1
  227. package/lib/module/index.node.js.map +0 -1
  228. package/lib/module/loadDynamicFont.js.map +0 -1
  229. package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
  230. package/lib/module/types.js.map +0 -1
  231. package/lib/module/utils/fingerPrint.js.map +0 -1
  232. package/lib/module/utils/glyphRuntime.js.map +0 -1
  233. package/lib/module/utils/parse.js.map +0 -1
  234. package/lib/module/utils/shallowEqualColor.js.map +0 -1
  235. package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
  236. package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
  237. package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
  238. package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
  239. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
  240. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
  241. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
  242. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
  243. package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
  244. package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
  245. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
  246. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
  247. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
  248. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
  249. package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
  250. package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
  251. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
  252. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
  253. package/lib/typescript/cli/build.d.ts +0 -32
  254. package/lib/typescript/cli/build.d.ts.map +0 -1
  255. package/lib/typescript/cli/link.d.ts +0 -12
  256. package/lib/typescript/cli/link.d.ts.map +0 -1
  257. package/lib/typescript/cli/logger.d.ts +0 -28
  258. package/lib/typescript/cli/logger.d.ts.map +0 -1
  259. package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
  260. package/lib/typescript/src/const/colors.d.ts.map +0 -1
  261. package/lib/typescript/src/core/font/compile.d.ts +0 -21
  262. package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
  263. package/lib/typescript/src/core/font/metrics.d.ts +0 -2
  264. package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
  265. package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
  266. package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
  267. package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
  268. package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
  269. package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
  270. package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
  271. package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
  272. package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
  273. package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
  274. package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
  275. package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
  276. package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
  277. package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
  278. package/lib/typescript/src/core/types.d.ts.map +0 -1
  279. package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
  280. package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
  281. package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
  282. package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
  283. package/lib/typescript/src/index.d.ts.map +0 -1
  284. package/lib/typescript/src/index.node.d.ts.map +0 -1
  285. package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
  286. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
  287. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
  288. package/lib/typescript/src/types.d.ts.map +0 -1
  289. package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
  290. package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
  291. package/lib/typescript/src/utils/parse.d.ts.map +0 -1
  292. package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
  293. package/plugin/src/buildFonts.ts +0 -42
  294. package/plugin/src/index.ts +0 -21
  295. package/plugin/src/types.ts +0 -42
  296. package/plugin/src/withNanoIconsFontLinking.ts +0 -136
  297. package/plugin/tsconfig.json +0 -9
  298. package/scripts/cli.ts +0 -63
  299. package/scripts/tsconfig.json +0 -25
  300. package/src/const/colors.ts +0 -150
  301. package/src/core/font/compile.ts +0 -99
  302. package/src/core/font/metrics.ts +0 -44
  303. package/src/core/pipeline/config.ts +0 -25
  304. package/src/core/pipeline/index.ts +0 -3
  305. package/src/core/pipeline/managers.ts +0 -132
  306. package/src/core/pipeline/run.ts +0 -274
  307. package/src/core/shims/pathops.py +0 -181
  308. package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  309. package/src/core/svg/layers.ts +0 -110
  310. package/src/core/svg/svg_dom.ts +0 -194
  311. package/src/core/svg/svg_pathops.ts +0 -1040
  312. package/src/core/tsconfig.json +0 -32
  313. package/src/core/types.ts +0 -157
  314. package/src/createNanoIconsSet.native.tsx +0 -192
  315. package/src/createNanoIconsSet.shared.tsx +0 -174
  316. package/src/createNanoIconsSet.tsx +0 -20
  317. package/src/createNanoIconsSet.web.tsx +0 -109
  318. package/src/index.node.ts +0 -14
  319. package/src/index.ts +0 -6
  320. package/src/loadDynamicFont.ts +0 -162
  321. package/src/types.ts +0 -31
  322. package/src/utils/fingerPrint.ts +0 -20
  323. package/src/utils/glyphRuntime.ts +0 -46
  324. package/src/utils/parse.ts +0 -67
  325. package/src/utils/shallowEqualColor.ts +0 -17
@@ -0,0 +1,4 @@
1
+ export declare function buildFontFamily(fontFamily: string, inputHash: string): string;
2
+ export declare function configuredFontFamily(family: string): string;
3
+ export declare function isFontFileOf(fontFamily: string, fileName: string): boolean;
4
+ export declare function isBuildFontFile(fileName: string): boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildFontFamily = buildFontFamily;
4
+ exports.configuredFontFamily = configuredFontFamily;
5
+ exports.isFontFileOf = isFontFileOf;
6
+ exports.isBuildFontFile = isBuildFontFile;
7
+ const BUILD_HASH_LENGTH = 8;
8
+ const BUILD_HASH = `[0-9a-f]{${BUILD_HASH_LENGTH}}`;
9
+ const BUILD_SUFFIX = new RegExp(`-${BUILD_HASH}$`);
10
+ const BUILD_FONT_FILE = new RegExp(`-${BUILD_HASH}\\.ttf$`);
11
+ const REGEX_SPECIALS = /[.*+?^${}()|[\]\\]/g;
12
+ function buildFontFamily(fontFamily, inputHash) {
13
+ return `${fontFamily}-${inputHash.slice(0, BUILD_HASH_LENGTH)}`;
14
+ }
15
+ function configuredFontFamily(family) {
16
+ return family.replace(BUILD_SUFFIX, '');
17
+ }
18
+ function isFontFileOf(fontFamily, fileName) {
19
+ const escaped = fontFamily.replace(REGEX_SPECIALS, '\\$&');
20
+ return new RegExp(`^${escaped}(-${BUILD_HASH})?\\.ttf$`).test(fileName);
21
+ }
22
+ function isBuildFontFile(fileName) {
23
+ return BUILD_FONT_FILE.test(fileName);
24
+ }
@@ -0,0 +1,2 @@
1
+ export declare function packageVersion(): string;
2
+ export declare function fontToolchainVersions(): string[];
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageVersion = packageVersion;
4
+ exports.fontToolchainVersions = fontToolchainVersions;
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const PACKAGE_NAME = 'react-native-nano-icons';
8
+ const FONT_TOOLCHAIN = [
9
+ '@xmldom/xmldom',
10
+ 'cubic2quad',
11
+ 'fonteditor-core',
12
+ 'pathkit-wasm',
13
+ 'svg2ttf',
14
+ ];
15
+ function packageVersion() {
16
+ return installedVersion(PACKAGE_NAME, __dirname);
17
+ }
18
+ function fontToolchainVersions() {
19
+ return FONT_TOOLCHAIN.map((name) => `${name}@${installedVersion(name, path.dirname(require.resolve(name)))}`);
20
+ }
21
+ function installedVersion(name, fromDir) {
22
+ let dir = fromDir;
23
+ for (;;) {
24
+ const manifest = path.join(dir, 'package.json');
25
+ if (fs.existsSync(manifest)) {
26
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
27
+ if (pkg.name === name && typeof pkg.version === 'string') {
28
+ return pkg.version;
29
+ }
30
+ }
31
+ const parent = path.dirname(dir);
32
+ if (parent === dir) {
33
+ throw new Error(`Could not locate the ${name} package.json`);
34
+ }
35
+ dir = parent;
36
+ }
37
+ }
@@ -1,2 +1 @@
1
- export declare function parseCodepointFromFilename(filename: string): number;
2
1
  export declare function parseColor(color: string): [r: number, g: number, b: number, a: number];
@@ -1,15 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCodepointFromFilename = parseCodepointFromFilename;
4
3
  exports.parseColor = parseColor;
5
4
  const colors_1 = require("../const/colors");
6
- // e.g. u0041.svg -> 65
7
- function parseCodepointFromFilename(filename) {
8
- const m = /^u([0-9a-fA-F]+)\.svg$/.exec(filename);
9
- if (!m)
10
- throw new Error(`Unexpected glyph filename: ${filename}`);
11
- return parseInt(m[1], 16);
12
- }
13
5
  // e.g. #ff0000 -> [255, 0, 0, 1], rgba(255, 0, 0, 0.5) -> [255, 0, 0, 0.5], rgb(255, 0, 0) -> [255, 0, 0, 1], blue -> [0, 0, 255, 1] etc.
14
6
  function parseColor(color) {
15
7
  const c = color.trim();
@@ -0,0 +1,38 @@
1
+ /** Path already starts with a moveto. */
2
+ export declare const SVG_MOVE_PREFIX: RegExp;
3
+ /** Trailing close-path command (+ optional whitespace). */
4
+ export declare const SVG_TRAILING_CLOSE: RegExp;
5
+ /** A signed int/float token. */
6
+ export declare const SVG_NUMBER: RegExp;
7
+ /** Whitespace separator (e.g. viewBox parts). */
8
+ export declare const WHITESPACE: RegExp;
9
+ /** `<mask …>` element (unsupported). */
10
+ export declare const XML_MASK: RegExp;
11
+ /** `<filter …>` element (unsupported). */
12
+ export declare const XML_FILTER: RegExp;
13
+ /** `<image …>` element (unsupported). */
14
+ export declare const XML_IMAGE: RegExp;
15
+ /** An `xmlns=` attribute. */
16
+ export declare const XML_XMLNS: RegExp;
17
+ /** Opening `<svg` tag. */
18
+ export declare const SVG_OPEN_TAG: RegExp;
19
+ export declare const PX_ATTRIBUTE_VALUE: RegExp;
20
+ export declare const PX_STYLE_VALUE: RegExp;
21
+ /** viewBox: comma or whitespace separated. */
22
+ export declare const VIEWBOX_SEPARATOR: RegExp;
23
+ /** transform() arguments: comma and/or whitespace separated. */
24
+ export declare const TRANSFORM_ARG_SEPARATOR: RegExp;
25
+ /** stroke-dasharray: single comma or space separated. */
26
+ export declare const DASHARRAY_SEPARATOR: RegExp;
27
+ /** One transform function call, e.g. `rotate(30)`; captures name and args. */
28
+ export declare const TRANSFORM_FUNCTION: RegExp;
29
+ /** `url(#id)` reference; captures the id. */
30
+ export declare const URL_ID_REFERENCE: RegExp;
31
+ /** A well-formed XML attribute name. */
32
+ export declare const XML_ATTRIBUTE_NAME: RegExp;
33
+ export declare const XML_AMP: RegExp;
34
+ export declare const XML_LT: RegExp;
35
+ export declare const XML_GT: RegExp;
36
+ export declare const XML_QUOT: RegExp;
37
+ /** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
38
+ export declare const GLYPH_CODEPOINT: RegExp;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ // Regexes for parsing/validating SVG path data and XML markup.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GLYPH_CODEPOINT = exports.XML_QUOT = exports.XML_GT = exports.XML_LT = exports.XML_AMP = exports.XML_ATTRIBUTE_NAME = exports.URL_ID_REFERENCE = exports.TRANSFORM_FUNCTION = exports.DASHARRAY_SEPARATOR = exports.TRANSFORM_ARG_SEPARATOR = exports.VIEWBOX_SEPARATOR = exports.PX_STYLE_VALUE = exports.PX_ATTRIBUTE_VALUE = exports.SVG_OPEN_TAG = exports.XML_XMLNS = exports.XML_IMAGE = exports.XML_FILTER = exports.XML_MASK = exports.WHITESPACE = exports.SVG_NUMBER = exports.SVG_TRAILING_CLOSE = exports.SVG_MOVE_PREFIX = void 0;
5
+ // --- SVG path data ---
6
+ /** Path already starts with a moveto. */
7
+ exports.SVG_MOVE_PREFIX = /^[Mm]/;
8
+ /** Trailing close-path command (+ optional whitespace). */
9
+ exports.SVG_TRAILING_CLOSE = /[Zz]\s*$/;
10
+ /** A signed int/float token. */
11
+ exports.SVG_NUMBER = /-?\d+(?:\.\d+)?/g;
12
+ /** Whitespace separator (e.g. viewBox parts). */
13
+ exports.WHITESPACE = /\s+/;
14
+ // --- SVG/XML validation ---
15
+ /** `<mask …>` element (unsupported). */
16
+ exports.XML_MASK = /<mask[\s>]/i;
17
+ /** `<filter …>` element (unsupported). */
18
+ exports.XML_FILTER = /<filter[\s>]/i;
19
+ /** `<image …>` element (unsupported). */
20
+ exports.XML_IMAGE = /<image[\s>]/i;
21
+ /** An `xmlns=` attribute. */
22
+ exports.XML_XMLNS = /xmlns\s*=/;
23
+ /** Opening `<svg` tag. */
24
+ exports.SVG_OPEN_TAG = /<svg\b/;
25
+ exports.PX_ATTRIBUTE_VALUE = /=(["'])(\s*-?(?:\d+\.?\d*|\.\d+))px\s*\1/g;
26
+ exports.PX_STYLE_VALUE = /(:\s*-?(?:\d+\.?\d*|\.\d+))px(?=\s*(?:;|["']|$))/g;
27
+ // --- SVG attribute value separators ---
28
+ /** viewBox: comma or whitespace separated. */
29
+ exports.VIEWBOX_SEPARATOR = /,|\s+/;
30
+ /** transform() arguments: comma and/or whitespace separated. */
31
+ exports.TRANSFORM_ARG_SEPARATOR = /\s*[,\s]\s*/;
32
+ /** stroke-dasharray: single comma or space separated. */
33
+ exports.DASHARRAY_SEPARATOR = /[, ]/;
34
+ /** One transform function call, e.g. `rotate(30)`; captures name and args. */
35
+ exports.TRANSFORM_FUNCTION = /(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/gi;
36
+ /** `url(#id)` reference; captures the id. */
37
+ exports.URL_ID_REFERENCE = /^url[(]#([\w-]+)[)]$/;
38
+ /** A well-formed XML attribute name. */
39
+ exports.XML_ATTRIBUTE_NAME = /^[A-Za-z_][\w.-]*$/;
40
+ // --- XML escaping / font emit ---
41
+ exports.XML_AMP = /&/g;
42
+ exports.XML_LT = /</g;
43
+ exports.XML_GT = />/g;
44
+ exports.XML_QUOT = /"/g;
45
+ /** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
46
+ exports.GLYPH_CODEPOINT = /glyph\s+"u([0-9a-fA-F]+)"/;
@@ -1,2 +1 @@
1
- "use strict";
2
- //# sourceMappingURL=codegenPrimitives.js.map
1
+ "use strict";
@@ -149,5 +149,4 @@ export const CSS_NAMED_COLORS = {
149
149
  whitesmoke: [245, 245, 245],
150
150
  yellow: [255, 255, 0],
151
151
  yellowgreen: [154, 205, 50]
152
- };
153
- //# sourceMappingURL=colors.js.map
152
+ };
@@ -4,5 +4,4 @@ import { createJSIconSet } from "./createNanoIconsSet.shared.js";
4
4
  export { shallowEqualColor } from "./utils/shallowEqualColor.js";
5
5
  export function createIconSet(glyphMap, font) {
6
6
  return createJSIconSet(glyphMap, font);
7
- }
8
- //# sourceMappingURL=createNanoIconsSet.js.map
7
+ }
@@ -7,6 +7,7 @@ import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createLayerColorResolver } from "
7
7
  import NanoIconViewNative from './specs/NanoIconViewNativeComponent';
8
8
  import { createJSIconSet, warnIfLinkingMismatch } from "./createNanoIconsSet.shared.js";
9
9
  import { loadDynamicFont, useDynamicFontPending } from "./loadDynamicFont.js";
10
+ import { checkFontIntegrity, isFontMismatch, reportDynamicFontLoadFailure, reportFontMismatch } from "./fontIntegrity.js";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  export { shallowEqualColor };
12
13
  const HAS_NATIVE_IMPL = UIManager.hasViewManagerConfig('NanoIconView');
@@ -32,10 +33,17 @@ export function createIconSet(glyphMap, font) {
32
33
 
33
34
  // dynamically linked font - register and hide icons until ready
34
35
  const managed = glyphMap.m.l === 'd' && font != null;
36
+ const linking = glyphMap.m.l === 'd' ? 'dynamic' : 'static';
35
37
  if (managed) {
36
- void loadDynamicFont(fontFamilyBasename, font).catch(err => {
37
- if (__DEV__) console.warn(`[react-native-nano-icons] Failed to load dynamic font "${fontFamilyBasename}".`, err);
38
+ void loadDynamicFont(fontFamilyBasename, font).then(() => checkFontIntegrity(fontFamilyBasename, linking), err => {
39
+ if (isFontMismatch(err)) {
40
+ reportFontMismatch(fontFamilyBasename, linking);
41
+ } else {
42
+ void reportDynamicFontLoadFailure(fontFamilyBasename, err);
43
+ }
38
44
  });
45
+ } else if (linking === 'static') {
46
+ void checkFontIntegrity(fontFamilyBasename, linking);
39
47
  }
40
48
 
41
49
  // Pre-compute per-icon static data (codepoints, default colors) once at set creation
@@ -131,5 +139,4 @@ export function createIconSet(glyphMap, font) {
131
139
  force: true
132
140
  }) : Promise.resolve();
133
141
  return IconComp;
134
- }
135
- //# sourceMappingURL=createNanoIconsSet.native.js.map
142
+ }
@@ -5,6 +5,9 @@ import { PixelRatio, Platform, Text, View } from 'react-native';
5
5
  import { shallowEqualColor } from "./utils/shallowEqualColor.js";
6
6
  import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createCharCache, createLayerColorResolver } from "./utils/glyphRuntime.js";
7
7
  import { loadDynamicFont, useDynamicFontPending } from "./loadDynamicFont.js";
8
+ import { warnRuntime } from "./utils/runtimeLog.js";
9
+ import { isFontMismatch, reportDynamicFontLoadFailure, reportFontMismatch, reportMissingDynamicFont } from "./fontIntegrity.js";
10
+ import { configuredFontFamily } from "./utils/fontIdentity.js";
8
11
  import { jsx as _jsx } from "react/jsx-runtime";
9
12
  export { shallowEqualColor };
10
13
 
@@ -18,14 +21,13 @@ export { shallowEqualColor };
18
21
  * Fires once per `createIconSet` call (not per render).
19
22
  */
20
23
  export function warnIfLinkingMismatch(fontFamily, linking, font) {
21
- if (!__DEV__) return;
22
24
  const isDynamic = linking === 'd';
23
25
  if (isDynamic && font == null) {
24
- console.warn(`[react-native-nano-icons] "${fontFamily}" is built with dynamic linking ` + `but no font was passed to createIconSet. Icons will render as tofu ` + `until a font is loaded and registered under family "${fontFamily}".`);
26
+ void reportMissingDynamicFont(fontFamily);
25
27
  return;
26
28
  }
27
- if (!isDynamic && font != null) {
28
- console.warn(`[react-native-nano-icons] "${fontFamily}" is built with static linking; ` + `the font argument passed to createIconSet is ignored. ` + `Set linking: 'dynamic' in your config to opt into OTA delivery.`);
29
+ if (__DEV__ && !isDynamic && font != null) {
30
+ warnRuntime(`Icon font "${configuredFontFamily(fontFamily)}" is built with static linking, so the font passed to createNanoIconSet is ignored. ` + `Set linking: 'dynamic' in your config to deliver it at runtime.`);
29
31
  }
30
32
  }
31
33
 
@@ -42,7 +44,11 @@ export function createJSIconSet(glyphMap, font) {
42
44
  const managed = glyphMap.m.l === 'd' && font != null;
43
45
  if (managed) {
44
46
  void loadDynamicFont(fontBasename, font).catch(err => {
45
- if (__DEV__) console.warn(`[react-native-nano-icons] Failed to load dynamic font "${fontBasename}".`, err);
47
+ if (isFontMismatch(err)) {
48
+ reportFontMismatch(fontBasename, 'dynamic');
49
+ } else {
50
+ void reportDynamicFontLoadFailure(fontBasename, err);
51
+ }
46
52
  });
47
53
  }
48
54
  const fontReference = Platform.select({
@@ -116,5 +122,4 @@ export function createJSIconSet(glyphMap, font) {
116
122
  force: true
117
123
  }) : Promise.resolve();
118
124
  return IconComp;
119
- }
120
- //# sourceMappingURL=createNanoIconsSet.shared.js.map
125
+ }
@@ -3,12 +3,13 @@
3
3
  import { memo, useMemo } from 'react';
4
4
  import { shallowEqualColor } from "./utils/shallowEqualColor.js";
5
5
  import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createCharCache, createLayerColorResolver } from "./utils/glyphRuntime.js";
6
+ import { configuredFontFamily } from "./utils/fontIdentity.js";
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  export { shallowEqualColor };
8
9
 
9
10
  // Web renderer: uses inline <span> elements so icons flow out of the box (display: inline-block keeps width/height)
10
11
  export function createIconSet(glyphMap) {
11
- const fontBasename = glyphMap.m.f;
12
+ const fontBasename = configuredFontFamily(glyphMap.m.f);
12
13
  const unitsPerEm = glyphMap.m.u;
13
14
  const getChar = createCharCache();
14
15
  const Icon = /*#__PURE__*/memo(({
@@ -21,6 +22,7 @@ export function createIconSet(glyphMap) {
21
22
  accessibilityRole = 'image',
22
23
  accessibilityElementsHidden,
23
24
  testID,
25
+ className,
24
26
  ref
25
27
  }) => {
26
28
  const [adv, layers] = resolveGlyphEntry(glyphMap, name);
@@ -50,6 +52,7 @@ export function createIconSet(glyphMap) {
50
52
  const role = accessibilityRole === 'image' ? 'img' : accessibilityRole;
51
53
  return /*#__PURE__*/_jsx("span", {
52
54
  ref: ref,
55
+ className: className,
53
56
  style: containerStyle,
54
57
  role: isHidden ? undefined : role,
55
58
  "aria-label": isHidden ? undefined : accessibilityLabel ?? name,
@@ -67,12 +70,11 @@ export function createIconSet(glyphMap) {
67
70
  }, i);
68
71
  })
69
72
  });
70
- }, (prev, next) => prev.name === next.name && prev.size === next.size && prev.style === next.style && shallowEqualColor(prev.color, next.color));
73
+ }, (prev, next) => prev.name === next.name && prev.size === next.size && prev.style === next.style && prev.className === next.className && shallowEqualColor(prev.color, next.color));
71
74
  Icon.displayName = `NanoIcon(${fontBasename})`;
72
75
 
73
- // No-op on web: fonts come from CSS @font-face, nothing to load at runtime.
76
+ // No-op on web: the host app links the font under the configured family name, nothing to load at runtime.
74
77
  const IconComp = Icon;
75
78
  IconComp.loadFont = () => Promise.resolve();
76
79
  return IconComp;
77
- }
78
- //# sourceMappingURL=createNanoIconsSet.web.js.map
80
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ import NanoIconsFontLoader from './nativeFontLoader';
4
+ import { configuredFontFamily } from "./utils/fontIdentity.js";
5
+ import { errorRuntime, LOG_PREFIX, warnRuntime } from "./utils/runtimeLog.js";
6
+ const checked = new Set();
7
+ const issues = new Map();
8
+ const listeners = new Set();
9
+ let staleBinaryReported = false;
10
+ function hasNativeCheck() {
11
+ return typeof NanoIconsFontLoader?.isFontRegistered === 'function';
12
+ }
13
+ export function isFontRegistered(family) {
14
+ if (!NanoIconsFontLoader || !hasNativeCheck()) return Promise.resolve(false);
15
+ return NanoIconsFontLoader.isFontRegistered(family);
16
+ }
17
+ export async function checkFontIntegrity(family, linking) {
18
+ if (!NanoIconsFontLoader || checked.has(family)) return;
19
+ checked.add(family);
20
+ if (!hasNativeCheck()) {
21
+ if (!staleBinaryReported) {
22
+ staleBinaryReported = true;
23
+ errorRuntime('The app binary was built with an older version of react-native-nano-icons. Rebuild the app.');
24
+ }
25
+ return;
26
+ }
27
+ if (await isFontRegistered(family)) return;
28
+ recordIssue(family, linking, `Icon font "${configuredFontFamily(family)}" is missing or out of date, so its icons will render blank. ` + 'Regenerate the icon fonts with the react-native-nano-icons CLI.');
29
+ }
30
+ export const FONT_MISMATCH_CODE = 'E_NANOICONS_FONT_MISMATCH';
31
+ export function isFontMismatch(err) {
32
+ return err?.code === FONT_MISMATCH_CODE;
33
+ }
34
+ export const FONT_SOURCE_CODE = 'E_NANOICONS_FONT_SOURCE';
35
+ function isFontSourceError(err) {
36
+ return err?.code === FONT_SOURCE_CODE;
37
+ }
38
+ export function reportFontMismatch(family, linking) {
39
+ recordIssue(family, linking, `Icon font "${configuredFontFamily(family)}" does not match its glyphmap, so its icons will render blank. ` + 'Regenerate the icon fonts with the react-native-nano-icons CLI and deliver the .ttf together with its .glyphmap.json.');
40
+ }
41
+ export function reportMissingDynamicFont(family) {
42
+ return reportDynamicFontIssue(family, `Icon font "${configuredFontFamily(family)}" is built with dynamic linking but no font was passed to createNanoIconSet, ` + 'so its icons will render blank until a font is registered under the family name in glyphMap.m.f.');
43
+ }
44
+ export function reportDynamicFontLoadFailure(family, cause) {
45
+ const name = configuredFontFamily(family);
46
+ const message = isFontSourceError(cause) ? `Icon font "${name}" has no usable font source, so its icons will render blank. ` + `Pass require("${name}.ttf") or { uri } to createNanoIconSet.` : `Icon font "${name}" could not be loaded: ${describeCause(cause)} Its icons will render blank. ` + 'Make sure the .ttf is delivered with your update.';
47
+ return reportDynamicFontIssue(family, message, cause);
48
+ }
49
+ function describeCause(cause) {
50
+ const text = (cause instanceof Error ? cause.message : String(cause)).replace(`${LOG_PREFIX} ✖ `, '');
51
+ return /[.!?]$/.test(text) ? text : `${text}.`;
52
+ }
53
+ async function reportDynamicFontIssue(family, message, cause) {
54
+ if (await isFontRegistered(family)) return;
55
+ if (NanoIconsFontLoader) {
56
+ recordIssue(family, 'dynamic', message, cause);
57
+ } else if (__DEV__) {
58
+ warnRuntime(message, ...causeDetail(cause));
59
+ }
60
+ }
61
+ function causeDetail(cause) {
62
+ return cause === undefined ? [] : [cause];
63
+ }
64
+ function recordIssue(family, linking, message, cause) {
65
+ const issue = {
66
+ fontFamily: configuredFontFamily(family),
67
+ family,
68
+ linking,
69
+ message,
70
+ ...(cause === undefined ? {} : {
71
+ cause
72
+ })
73
+ };
74
+ issues.set(family, issue);
75
+ if (__DEV__) warnRuntime(message, ...causeDetail(cause));
76
+ for (const listener of listeners) listener(issue, 'found');
77
+ }
78
+ export function resolveFontIssue(family) {
79
+ const issue = issues.get(family);
80
+ if (!issue) return;
81
+ issues.delete(family);
82
+ for (const listener of listeners) listener(issue, 'resolved');
83
+ }
84
+ export function addFontIntegrityListener(listener) {
85
+ listeners.add(listener);
86
+ for (const issue of issues.values()) listener(issue, 'found');
87
+ return () => {
88
+ listeners.delete(listener);
89
+ };
90
+ }
91
+ export function getFontIntegrityIssues() {
92
+ return [...issues.values()];
93
+ }
94
+ export function __resetFontIntegrityForTests() {
95
+ staleBinaryReported = false;
96
+ checked.clear();
97
+ issues.clear();
98
+ listeners.clear();
99
+ }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
 
3
3
  export { createIconSet as createNanoIconSet } from './createNanoIconsSet';
4
- //# sourceMappingURL=index.js.map
4
+ export { addFontIntegrityListener, getFontIntegrityIssues } from "./fontIntegrity.js";
@@ -9,5 +9,4 @@ const createNanoIconSet = (...args) => {
9
9
  const plugin = require('./plugin/src/index').default;
10
10
  module.exports = Object.assign(plugin, {
11
11
  createNanoIconSet
12
- });
13
- //# sourceMappingURL=index.node.js.map
12
+ });
@@ -2,7 +2,9 @@
2
2
 
3
3
  import { useSyncExternalStore } from 'react';
4
4
  import { Image, Platform } from 'react-native';
5
- import NanoIconsFontLoader from "./specs/NativeNanoIconsFontLoader.js";
5
+ import { FONT_SOURCE_CODE, resolveFontIssue } from "./fontIntegrity.js";
6
+ import NanoIconsFontLoader from './nativeFontLoader';
7
+ import { runtimeError } from "./utils/runtimeLog.js";
6
8
 
7
9
  /**
8
10
  * Runtime registration of dynamically-linked (`l:"d"`) fonts.
@@ -24,11 +26,16 @@ export function getFontStatus(family) {
24
26
 
25
27
  /** A font source: a require()'d module, an { uri }, or a path/uri string. */
26
28
 
29
+ function fontSourceError(message) {
30
+ return Object.assign(runtimeError(message), {
31
+ code: FONT_SOURCE_CODE
32
+ });
33
+ }
27
34
  export function resolveFontUri(font) {
28
35
  if (typeof font === 'number') {
29
36
  const source = Image.resolveAssetSource(font);
30
37
  if (!source?.uri) {
31
- throw new Error('[react-native-nano-icons] Could not resolve the font asset to a uri.');
38
+ throw fontSourceError('Could not resolve the font asset to a uri.');
32
39
  }
33
40
  return source.uri;
34
41
  }
@@ -36,7 +43,7 @@ export function resolveFontUri(font) {
36
43
  if (font != null && typeof font === 'object' && typeof font.uri === 'string') {
37
44
  return font.uri;
38
45
  }
39
- throw new Error('[react-native-nano-icons] Unsupported font source. Pass require("Foo.ttf"), { uri }, or a path string.');
46
+ throw fontSourceError('Unsupported font source. Pass require("Foo.ttf"), { uri }, or a path string.');
40
47
  }
41
48
  async function register(family, uri) {
42
49
  if (Platform.OS === 'web') {
@@ -44,7 +51,7 @@ async function register(family, uri) {
44
51
  // lib config and a DOM-aware app config without depending on the DOM lib.
45
52
  const g = globalThis;
46
53
  if (!g.FontFace || !g.document?.fonts) {
47
- throw new Error('[react-native-nano-icons] FontFace API unavailable; cannot load dynamic font on this platform.');
54
+ throw runtimeError('FontFace API unavailable; cannot load dynamic font on this platform.');
48
55
  }
49
56
  const face = new g.FontFace(family, `url(${uri})`);
50
57
  await face.load();
@@ -52,7 +59,7 @@ async function register(family, uri) {
52
59
  return;
53
60
  }
54
61
  if (!NanoIconsFontLoader) {
55
- throw new Error('[react-native-nano-icons] Native font loader is unavailable (Expo Go or module not built). ' + 'Load the font yourself, or use a development/production build.');
62
+ throw runtimeError('Native font loader is unavailable (Expo Go or module not built). ' + 'Load the font yourself, or use a development/production build.');
56
63
  }
57
64
  await NanoIconsFontLoader.registerFont(family, uri);
58
65
  }
@@ -76,6 +83,7 @@ export function loadDynamicFont(family, font, opts) {
76
83
  try {
77
84
  await register(family, resolveFontUri(font));
78
85
  setStatus(family, 'ready');
86
+ resolveFontIssue(family);
79
87
  } catch (err) {
80
88
  setStatus(family, 'error');
81
89
  throw err;
@@ -114,5 +122,4 @@ export function __resetDynamicFontsForTests() {
114
122
  statusByFamily.clear();
115
123
  inFlight.clear();
116
124
  listeners.clear();
117
- }
118
- //# sourceMappingURL=loadDynamicFont.js.map
125
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export { default } from "./specs/NativeNanoIconsFontLoader.js";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export default null;
@@ -3,5 +3,4 @@
3
3
  import { TurboModuleRegistry } from 'react-native';
4
4
  // `get` (not `getEnforcing`) so the absence of the native module (web, Expo Go,
5
5
  // module not built) returns null and the caller can degrade gracefully.
6
- export default TurboModuleRegistry.get('NanoIconsFontLoader');
7
- //# sourceMappingURL=NativeNanoIconsFontLoader.js.map
6
+ export default TurboModuleRegistry.get('NanoIconsFontLoader');
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
2
 
3
- export {};
4
- //# sourceMappingURL=types.js.map
3
+ export {};
@@ -3,7 +3,7 @@
3
3
  const crypto = require('crypto');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
- export function getFingerprintSync(dir) {
6
+ export function getFingerprintSync(dir, inputs) {
7
7
  const files = fs.readdirSync(dir).filter(f => f.endsWith('.svg')).sort();
8
8
  const hash = crypto.createHash('sha256');
9
9
  for (const file of files) {
@@ -12,6 +12,6 @@ export function getFingerprintSync(dir) {
12
12
  hash.update(file);
13
13
  hash.update(fs.readFileSync(filePath));
14
14
  }
15
+ hash.update(JSON.stringify([inputs.upm, inputs.safeZone, inputs.startUnicode, inputs.version, inputs.toolchain]));
15
16
  return hash.digest('hex');
16
- }
17
- //# sourceMappingURL=fingerPrint.js.map
17
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ const BUILD_HASH_LENGTH = 8;
4
+ const BUILD_HASH = `[0-9a-f]{${BUILD_HASH_LENGTH}}`;
5
+ const BUILD_SUFFIX = new RegExp(`-${BUILD_HASH}$`);
6
+ const BUILD_FONT_FILE = new RegExp(`-${BUILD_HASH}\\.ttf$`);
7
+ const REGEX_SPECIALS = /[.*+?^${}()|[\]\\]/g;
8
+ export function buildFontFamily(fontFamily, inputHash) {
9
+ return `${fontFamily}-${inputHash.slice(0, BUILD_HASH_LENGTH)}`;
10
+ }
11
+ export function configuredFontFamily(family) {
12
+ return family.replace(BUILD_SUFFIX, '');
13
+ }
14
+ export function isFontFileOf(fontFamily, fileName) {
15
+ const escaped = fontFamily.replace(REGEX_SPECIALS, '\\$&');
16
+ return new RegExp(`^${escaped}(-${BUILD_HASH})?\\.ttf$`).test(fileName);
17
+ }
18
+ export function isBuildFontFile(fileName) {
19
+ return BUILD_FONT_FILE.test(fileName);
20
+ }
@@ -33,5 +33,4 @@ export function createLayerColorResolver(color) {
33
33
  const colorArray = Array.isArray(color) ? color : [color];
34
34
  const lastPaletteColor = colorArray[colorArray.length - 1];
35
35
  return (index, srcColor) => colorArray[index] ?? lastPaletteColor ?? srcColor ?? 'black';
36
- }
37
- //# sourceMappingURL=glyphRuntime.js.map
36
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const PACKAGE_NAME = 'react-native-nano-icons';
6
+ const FONT_TOOLCHAIN = ['@xmldom/xmldom', 'cubic2quad', 'fonteditor-core', 'pathkit-wasm', 'svg2ttf'];
7
+ export function packageVersion() {
8
+ return installedVersion(PACKAGE_NAME, __dirname);
9
+ }
10
+ export function fontToolchainVersions() {
11
+ return FONT_TOOLCHAIN.map(name => `${name}@${installedVersion(name, path.dirname(require.resolve(name)))}`);
12
+ }
13
+ function installedVersion(name, fromDir) {
14
+ let dir = fromDir;
15
+ for (;;) {
16
+ const manifest = path.join(dir, 'package.json');
17
+ if (fs.existsSync(manifest)) {
18
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
19
+ if (pkg.name === name && typeof pkg.version === 'string') {
20
+ return pkg.version;
21
+ }
22
+ }
23
+ const parent = path.dirname(dir);
24
+ if (parent === dir) {
25
+ throw new Error(`Could not locate the ${name} package.json`);
26
+ }
27
+ dir = parent;
28
+ }
29
+ }
@@ -2,13 +2,6 @@
2
2
 
3
3
  import { CSS_NAMED_COLORS } from "../const/colors.js";
4
4
 
5
- // e.g. u0041.svg -> 65
6
- export function parseCodepointFromFilename(filename) {
7
- const m = /^u([0-9a-fA-F]+)\.svg$/.exec(filename);
8
- if (!m) throw new Error(`Unexpected glyph filename: ${filename}`);
9
- return parseInt(m[1], 16);
10
- }
11
-
12
5
  // e.g. #ff0000 -> [255, 0, 0, 1], rgba(255, 0, 0, 0.5) -> [255, 0, 0, 0.5], rgb(255, 0, 0) -> [255, 0, 0, 1], blue -> [0, 0, 255, 1] etc.
13
6
  export function parseColor(color) {
14
7
  const c = color.trim();
@@ -49,5 +42,4 @@ export function parseColor(color) {
49
42
 
50
43
  // unknown — SVG default is opaque black
51
44
  return [0, 0, 0, 1];
52
- }
53
- //# sourceMappingURL=parse.js.map
45
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ export const LOG_PREFIX = '🔬 react-native-nano-icons';
4
+ export function warnRuntime(message, ...rest) {
5
+ console.warn(`${LOG_PREFIX} ⚠ ${message}`, ...rest);
6
+ }
7
+ export function errorRuntime(message) {
8
+ console.error(`${LOG_PREFIX} ✖ ${message}`);
9
+ }
10
+ export function runtimeError(message) {
11
+ return new Error(`${LOG_PREFIX} ✖ ${message}`);
12
+ }