react-native-nano-icons 0.2.1 → 1.0.0-beta.2

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 (404) hide show
  1. package/LICENSES.md +40 -0
  2. package/README.md +165 -12
  3. package/android/build.gradle +8 -1
  4. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
  5. package/android/src/main/java/com/nanoicons/NanoIconView.kt +103 -19
  6. package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +42 -18
  7. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +72 -11
  8. package/android/src/main/jni/CMakeLists.txt +38 -0
  9. package/android/src/main/jni/RNNanoIconsSpec.h +19 -0
  10. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h +11 -0
  11. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +46 -0
  12. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +41 -0
  13. package/ios/NanoIconFontResolver.h +5 -0
  14. package/ios/NanoIconFontResolver.mm +32 -0
  15. package/ios/NanoIconInlineBaseline.h +4 -0
  16. package/ios/NanoIconInlineBaseline.mm +190 -0
  17. package/ios/NanoIconView.h +1 -4
  18. package/ios/NanoIconView.mm +178 -162
  19. package/ios/NanoIconsFontLoader.mm +10 -32
  20. package/lib/commonjs/cli/build.d.ts +16 -3
  21. package/lib/commonjs/cli/build.js +108 -25
  22. package/lib/commonjs/cli/buildSymbols.d.ts +26 -0
  23. package/lib/commonjs/cli/buildSymbols.js +134 -0
  24. package/lib/commonjs/cli/config.d.ts +4 -2
  25. package/lib/commonjs/cli/config.js +4 -4
  26. package/lib/commonjs/cli/expoConfig.d.ts +6 -2
  27. package/lib/commonjs/cli/expoConfig.js +37 -13
  28. package/lib/commonjs/cli/index.d.ts +7 -5
  29. package/lib/commonjs/cli/index.js +27 -14
  30. package/lib/commonjs/cli/link.d.ts +19 -3
  31. package/lib/commonjs/cli/link.js +311 -45
  32. package/lib/commonjs/cli/logger.js +9 -7
  33. package/lib/commonjs/metro/fontRebuildWatcher.d.ts +62 -0
  34. package/lib/commonjs/metro/fontRebuildWatcher.js +174 -0
  35. package/lib/commonjs/metro/index.d.ts +35 -0
  36. package/lib/commonjs/metro/index.js +92 -0
  37. package/lib/commonjs/metro/symbolRebuildWatcher.d.ts +19 -0
  38. package/lib/commonjs/metro/symbolRebuildWatcher.js +76 -0
  39. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
  40. package/lib/commonjs/plugin/src/buildFonts.js +5 -15
  41. package/lib/commonjs/plugin/src/buildSymbols.d.ts +3 -0
  42. package/lib/commonjs/plugin/src/buildSymbols.js +18 -0
  43. package/lib/commonjs/plugin/src/index.d.ts +2 -2
  44. package/lib/commonjs/plugin/src/index.js +10 -4
  45. package/lib/commonjs/plugin/src/types.d.ts +44 -3
  46. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +8 -0
  47. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +29 -0
  48. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
  49. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
  50. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +8 -0
  51. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +37 -0
  52. package/lib/commonjs/scripts/cli.js +64 -23
  53. package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
  54. package/lib/commonjs/src/core/flatten/arcs.js +136 -0
  55. package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
  56. package/lib/commonjs/src/core/flatten/document.js +164 -0
  57. package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
  58. package/lib/commonjs/src/core/flatten/dom.js +221 -0
  59. package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
  60. package/lib/commonjs/src/core/flatten/element.js +97 -0
  61. package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
  62. package/lib/commonjs/src/core/flatten/geometry.js +85 -0
  63. package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
  64. package/lib/commonjs/src/core/flatten/index.js +11 -0
  65. package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
  66. package/lib/commonjs/src/core/flatten/inherit.js +249 -0
  67. package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
  68. package/lib/commonjs/src/core/flatten/path.js +439 -0
  69. package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
  70. package/lib/commonjs/src/core/flatten/pathops.js +236 -0
  71. package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
  72. package/lib/commonjs/src/core/flatten/shape.js +415 -0
  73. package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
  74. package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
  75. package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
  76. package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
  77. package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
  78. package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
  79. package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
  80. package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
  81. package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
  82. package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
  83. package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
  84. package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
  85. package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
  86. package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
  87. package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
  88. package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
  89. package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
  90. package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
  91. package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
  92. package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
  93. package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
  94. package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
  95. package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
  96. package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
  97. package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
  98. package/lib/commonjs/src/core/flatten/stages.js +40 -0
  99. package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
  100. package/lib/commonjs/src/core/flatten/transform.js +221 -0
  101. package/lib/commonjs/src/core/font/compile.d.ts +2 -1
  102. package/lib/commonjs/src/core/font/compile.js +19 -7
  103. package/lib/commonjs/src/core/font/metrics.js +7 -0
  104. package/lib/commonjs/src/core/font/quadratic.d.ts +2 -0
  105. package/lib/commonjs/src/core/font/quadratic.js +33 -0
  106. package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
  107. package/lib/commonjs/src/core/glyph/merge.js +59 -0
  108. package/lib/commonjs/src/core/glyph/parse.d.ts +27 -0
  109. package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
  110. package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
  111. package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
  112. package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
  113. package/lib/commonjs/src/core/glyph/validate.js +33 -0
  114. package/lib/commonjs/src/core/pathkit/contours.d.ts +75 -0
  115. package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +79 -301
  116. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
  117. package/lib/commonjs/src/core/pathkit/evenodd.js +37 -0
  118. package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
  119. package/lib/commonjs/src/core/pathkit/load.js +26 -0
  120. package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
  121. package/lib/commonjs/src/core/pathkit/types.js +2 -0
  122. package/lib/commonjs/src/core/pathkit/winding.d.ts +4 -0
  123. package/lib/commonjs/src/core/pathkit/winding.js +59 -0
  124. package/lib/commonjs/src/core/pipeline/config.d.ts +2 -0
  125. package/lib/commonjs/src/core/pipeline/config.js +6 -0
  126. package/lib/commonjs/src/core/pipeline/iconPool.d.ts +14 -0
  127. package/lib/commonjs/src/core/pipeline/iconPool.js +109 -0
  128. package/lib/commonjs/src/core/pipeline/index.d.ts +5 -3
  129. package/lib/commonjs/src/core/pipeline/index.js +8 -5
  130. package/lib/commonjs/src/core/pipeline/prepare.d.ts +20 -0
  131. package/lib/commonjs/src/core/pipeline/prepare.js +74 -0
  132. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +25 -0
  133. package/lib/commonjs/src/core/pipeline/prepareIcon.js +81 -0
  134. package/lib/commonjs/src/core/pipeline/prepareSvg.d.ts +6 -0
  135. package/lib/commonjs/src/core/pipeline/prepareSvg.js +11 -0
  136. package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +26 -0
  137. package/lib/commonjs/src/core/pipeline/prepareSymbol.js +79 -0
  138. package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
  139. package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
  140. package/lib/commonjs/src/core/pipeline/preparedSvgCache.d.ts +6 -0
  141. package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +44 -0
  142. package/lib/commonjs/src/core/pipeline/runFontPipeline.d.ts +22 -0
  143. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +111 -0
  144. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +54 -0
  145. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +161 -0
  146. package/lib/commonjs/src/core/symbols/contents.d.ts +2 -0
  147. package/lib/commonjs/src/core/symbols/contents.js +15 -0
  148. package/lib/commonjs/src/core/symbols/knockout.d.ts +3 -0
  149. package/lib/commonjs/src/core/symbols/knockout.js +51 -0
  150. package/lib/commonjs/src/core/symbols/layers.d.ts +36 -0
  151. package/lib/commonjs/src/core/symbols/layers.js +182 -0
  152. package/lib/commonjs/src/core/symbols/template.d.ts +22 -0
  153. package/lib/commonjs/src/core/symbols/template.js +140 -0
  154. package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +11 -0
  155. package/lib/commonjs/src/core/symbols/vectorDrawable.js +66 -0
  156. package/lib/commonjs/src/core/types.d.ts +3 -92
  157. package/lib/commonjs/src/utils/fingerPrint.d.ts +19 -1
  158. package/lib/commonjs/src/utils/fingerPrint.js +29 -3
  159. package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
  160. package/lib/commonjs/src/utils/fontIdentity.js +24 -0
  161. package/lib/commonjs/src/utils/naming.d.ts +10 -0
  162. package/lib/commonjs/src/utils/naming.js +49 -0
  163. package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
  164. package/lib/commonjs/src/utils/packageVersion.js +37 -0
  165. package/lib/commonjs/src/utils/parse.d.ts +0 -1
  166. package/lib/commonjs/src/utils/parse.js +0 -8
  167. package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
  168. package/lib/commonjs/src/utils/svgPatterns.js +46 -0
  169. package/lib/module/const/codegenPrimitives.js +1 -2
  170. package/lib/module/const/colors.js +1 -2
  171. package/lib/module/createNanoIconsSet.js +1 -2
  172. package/lib/module/createNanoIconsSet.native.js +38 -28
  173. package/lib/module/createNanoIconsSet.shared.js +15 -9
  174. package/lib/module/createNanoIconsSet.web.js +22 -8
  175. package/lib/module/devServerFont.js +30 -0
  176. package/lib/module/devServerFont.web.js +25 -0
  177. package/lib/module/fontIntegrity.js +99 -0
  178. package/lib/module/index.js +1 -1
  179. package/lib/module/index.node.js +1 -2
  180. package/lib/module/loadDynamicFont.js +20 -10
  181. package/lib/module/nativeFontLoader.js +3 -0
  182. package/lib/module/nativeFontLoader.web.js +3 -0
  183. package/lib/module/specs/NanoIconViewNativeComponent.ts +9 -6
  184. package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
  185. package/lib/module/symbols/index.android.js +42 -0
  186. package/lib/module/symbols/index.ios.js +35 -0
  187. package/lib/module/symbols/index.js +35 -0
  188. package/lib/module/symbols/index.native.js +12 -0
  189. package/lib/module/symbols/types.js +1 -0
  190. package/lib/module/types.js +1 -2
  191. package/lib/module/utils/fingerPrint.js +20 -5
  192. package/lib/module/utils/fontIdentity.js +20 -0
  193. package/lib/module/utils/glyphRuntime.js +36 -3
  194. package/lib/module/utils/naming.js +46 -0
  195. package/lib/module/utils/packageVersion.js +29 -0
  196. package/lib/module/utils/parse.js +1 -9
  197. package/lib/module/utils/runtimeLog.js +12 -0
  198. package/lib/module/utils/shallowEqualColor.js +1 -2
  199. package/lib/module/utils/svgPatterns.js +49 -0
  200. package/lib/module/utils/validateLayerColor.js +24 -0
  201. package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
  202. package/lib/typescript/src/core/flatten/document.d.ts +36 -0
  203. package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
  204. package/lib/typescript/src/core/flatten/element.d.ts +13 -0
  205. package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
  206. package/lib/typescript/src/core/flatten/index.d.ts +3 -0
  207. package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
  208. package/lib/typescript/src/core/flatten/path.d.ts +20 -0
  209. package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
  210. package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
  211. package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
  212. package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
  213. package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
  214. package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
  215. package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
  216. package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
  217. package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
  218. package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
  219. package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
  220. package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
  221. package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
  222. package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
  223. package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
  224. package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
  225. package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
  226. package/lib/typescript/src/core/glyph/parse.d.ts +28 -0
  227. package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
  228. package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
  229. package/lib/typescript/src/core/pathkit/contours.d.ts +76 -0
  230. package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
  231. package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
  232. package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
  233. package/lib/typescript/src/core/pathkit/winding.d.ts +5 -0
  234. package/lib/typescript/src/core/symbols/contents.d.ts +3 -0
  235. package/lib/typescript/src/core/symbols/knockout.d.ts +4 -0
  236. package/lib/typescript/src/core/symbols/layers.d.ts +37 -0
  237. package/lib/typescript/src/core/symbols/template.d.ts +23 -0
  238. package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +12 -0
  239. package/lib/typescript/src/core/types.d.ts +3 -92
  240. package/lib/typescript/src/devServerFont.d.ts +4 -0
  241. package/lib/typescript/src/devServerFont.web.d.ts +4 -0
  242. package/lib/typescript/src/fontIntegrity.d.ts +24 -0
  243. package/lib/typescript/src/index.d.ts +1 -0
  244. package/lib/typescript/src/loadDynamicFont.d.ts +1 -0
  245. package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
  246. package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
  247. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +6 -5
  248. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  249. package/lib/typescript/src/symbols/index.android.d.ts +33 -0
  250. package/lib/typescript/src/symbols/index.d.ts +31 -0
  251. package/lib/typescript/src/symbols/index.ios.d.ts +31 -0
  252. package/lib/typescript/src/symbols/index.native.d.ts +8 -0
  253. package/lib/typescript/src/symbols/types.d.ts +24 -0
  254. package/lib/typescript/src/types.d.ts +7 -0
  255. package/lib/typescript/src/utils/fingerPrint.d.ts +19 -1
  256. package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
  257. package/lib/typescript/src/utils/glyphRuntime.d.ts +3 -1
  258. package/lib/typescript/src/utils/naming.d.ts +11 -0
  259. package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
  260. package/lib/typescript/src/utils/parse.d.ts +0 -1
  261. package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
  262. package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
  263. package/lib/typescript/src/utils/validateLayerColor.d.ts +3 -0
  264. package/metro.js +1 -0
  265. package/package.json +37 -11
  266. package/react-native-nano-icons.podspec +4 -1
  267. package/react-native.config.js +10 -0
  268. package/src/specs/NanoIconViewNativeComponent.ts +9 -6
  269. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  270. package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
  271. package/lib/commonjs/src/core/pipeline/managers.js +0 -104
  272. package/lib/commonjs/src/core/pipeline/run.d.ts +0 -14
  273. package/lib/commonjs/src/core/pipeline/run.js +0 -189
  274. package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
  275. package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
  276. package/lib/module/const/codegenPrimitives.js.map +0 -1
  277. package/lib/module/const/colors.js.map +0 -1
  278. package/lib/module/core/font/compile.js +0 -81
  279. package/lib/module/core/font/compile.js.map +0 -1
  280. package/lib/module/core/font/metrics.js +0 -37
  281. package/lib/module/core/font/metrics.js.map +0 -1
  282. package/lib/module/core/pipeline/config.js +0 -20
  283. package/lib/module/core/pipeline/config.js.map +0 -1
  284. package/lib/module/core/pipeline/index.js +0 -5
  285. package/lib/module/core/pipeline/index.js.map +0 -1
  286. package/lib/module/core/pipeline/managers.js +0 -94
  287. package/lib/module/core/pipeline/managers.js.map +0 -1
  288. package/lib/module/core/pipeline/run.js +0 -204
  289. package/lib/module/core/pipeline/run.js.map +0 -1
  290. package/lib/module/core/shims/pathops.py +0 -181
  291. package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  292. package/lib/module/core/svg/layers.js +0 -85
  293. package/lib/module/core/svg/layers.js.map +0 -1
  294. package/lib/module/core/svg/svg_dom.js +0 -170
  295. package/lib/module/core/svg/svg_dom.js.map +0 -1
  296. package/lib/module/core/svg/svg_pathops.js +0 -750
  297. package/lib/module/core/svg/svg_pathops.js.map +0 -1
  298. package/lib/module/core/tsconfig.json +0 -32
  299. package/lib/module/core/types.js +0 -2
  300. package/lib/module/core/types.js.map +0 -1
  301. package/lib/module/createNanoIconsSet.js.map +0 -1
  302. package/lib/module/createNanoIconsSet.native.js.map +0 -1
  303. package/lib/module/createNanoIconsSet.shared.js.map +0 -1
  304. package/lib/module/createNanoIconsSet.web.js.map +0 -1
  305. package/lib/module/index.js.map +0 -1
  306. package/lib/module/index.node.js.map +0 -1
  307. package/lib/module/loadDynamicFont.js.map +0 -1
  308. package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
  309. package/lib/module/types.js.map +0 -1
  310. package/lib/module/utils/fingerPrint.js.map +0 -1
  311. package/lib/module/utils/glyphRuntime.js.map +0 -1
  312. package/lib/module/utils/parse.js.map +0 -1
  313. package/lib/module/utils/shallowEqualColor.js.map +0 -1
  314. package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
  315. package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
  316. package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
  317. package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
  318. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
  319. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
  320. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
  321. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
  322. package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
  323. package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
  324. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
  325. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
  326. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
  327. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
  328. package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
  329. package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
  330. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
  331. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
  332. package/lib/typescript/cli/build.d.ts +0 -32
  333. package/lib/typescript/cli/build.d.ts.map +0 -1
  334. package/lib/typescript/cli/link.d.ts +0 -12
  335. package/lib/typescript/cli/link.d.ts.map +0 -1
  336. package/lib/typescript/cli/logger.d.ts +0 -28
  337. package/lib/typescript/cli/logger.d.ts.map +0 -1
  338. package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
  339. package/lib/typescript/src/const/colors.d.ts.map +0 -1
  340. package/lib/typescript/src/core/font/compile.d.ts +0 -21
  341. package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
  342. package/lib/typescript/src/core/font/metrics.d.ts +0 -2
  343. package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
  344. package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
  345. package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
  346. package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
  347. package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
  348. package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
  349. package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
  350. package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
  351. package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
  352. package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
  353. package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
  354. package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
  355. package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
  356. package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
  357. package/lib/typescript/src/core/types.d.ts.map +0 -1
  358. package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
  359. package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
  360. package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
  361. package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
  362. package/lib/typescript/src/index.d.ts.map +0 -1
  363. package/lib/typescript/src/index.node.d.ts.map +0 -1
  364. package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
  365. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
  366. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
  367. package/lib/typescript/src/types.d.ts.map +0 -1
  368. package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
  369. package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
  370. package/lib/typescript/src/utils/parse.d.ts.map +0 -1
  371. package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
  372. package/plugin/src/buildFonts.ts +0 -42
  373. package/plugin/src/index.ts +0 -21
  374. package/plugin/src/types.ts +0 -42
  375. package/plugin/src/withNanoIconsFontLinking.ts +0 -136
  376. package/plugin/tsconfig.json +0 -9
  377. package/scripts/cli.ts +0 -63
  378. package/scripts/tsconfig.json +0 -25
  379. package/src/const/colors.ts +0 -150
  380. package/src/core/font/compile.ts +0 -99
  381. package/src/core/font/metrics.ts +0 -44
  382. package/src/core/pipeline/config.ts +0 -25
  383. package/src/core/pipeline/index.ts +0 -3
  384. package/src/core/pipeline/managers.ts +0 -132
  385. package/src/core/pipeline/run.ts +0 -274
  386. package/src/core/shims/pathops.py +0 -181
  387. package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  388. package/src/core/svg/layers.ts +0 -110
  389. package/src/core/svg/svg_dom.ts +0 -194
  390. package/src/core/svg/svg_pathops.ts +0 -1040
  391. package/src/core/tsconfig.json +0 -32
  392. package/src/core/types.ts +0 -157
  393. package/src/createNanoIconsSet.native.tsx +0 -192
  394. package/src/createNanoIconsSet.shared.tsx +0 -174
  395. package/src/createNanoIconsSet.tsx +0 -20
  396. package/src/createNanoIconsSet.web.tsx +0 -109
  397. package/src/index.node.ts +0 -14
  398. package/src/index.ts +0 -6
  399. package/src/loadDynamicFont.ts +0 -162
  400. package/src/types.ts +0 -31
  401. package/src/utils/fingerPrint.ts +0 -20
  402. package/src/utils/glyphRuntime.ts +0 -46
  403. package/src/utils/parse.ts +0 -67
  404. package/src/utils/shallowEqualColor.ts +0 -17
@@ -1,14 +1,17 @@
1
1
  #import "NanoIconView.h"
2
+ #import "NanoIconFontResolver.h"
2
3
  #import <CoreText/CoreText.h>
3
4
  #import <React/RCTConversions.h>
4
5
  #import <React/RCTFabricComponentsPlugins.h>
5
- #import <react/renderer/components/RNNanoIconsSpec/ComponentDescriptors.h>
6
+ #import <react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h>
6
7
  #import <react/renderer/components/RNNanoIconsSpec/Props.h>
8
+ #import "NanoIconInlineBaseline.h"
7
9
 
8
10
  using namespace facebook::react;
9
11
 
10
12
  // Forward-declare so the layer subclass can call the drawing method.
11
13
  @interface NanoIconView ()
14
+ - (void)_resolveFontIfMissing;
12
15
  - (void)_drawIconInContext:(CGContextRef)context bounds:(CGRect)bounds;
13
16
  @end
14
17
 
@@ -24,55 +27,46 @@ using namespace facebook::react;
24
27
  }
25
28
  @end
26
29
 
27
- // CTFontRef cache keyed by "family:size" — avoids CTFontCreateWithName per render.
28
- // File-scope so NanoIconInvalidateFontCache can clear it on OTA font swap.
29
- static NSMutableDictionary *sNanoIconFontCache;
30
- static dispatch_once_t sNanoIconFontCacheOnce;
31
-
32
- static CTFontRef NanoIconGetCachedFont(NSString *family, CGFloat size) {
33
- dispatch_once(&sNanoIconFontCacheOnce, ^{ sNanoIconFontCache = [NSMutableDictionary new]; });
34
-
35
- NSString *key = [NSString stringWithFormat:@"%@:%.1f", family, size];
36
- id existing = sNanoIconFontCache[key];
37
- if (existing) {
38
- return (__bridge CTFontRef)existing;
39
- }
40
-
41
- CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)family, size, NULL);
42
- if (font) sNanoIconFontCache[key] = (__bridge id)font;
43
- return font;
44
- }
45
-
46
- // Clears cached entries for `family` after OTA font re-registration.
47
- void NanoIconInvalidateFontCache(NSString *family) {
48
- dispatch_async(dispatch_get_main_queue(), ^{
49
- if (!sNanoIconFontCache) return;
50
- NSString *prefix = [family stringByAppendingString:@":"];
51
- NSArray<NSString *> *keys = [sNanoIconFontCache.allKeys
52
- filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *k, id _) {
53
- return [k hasPrefix:prefix];
54
- }]];
55
- [sNanoIconFontCache removeObjectsForKeys:keys];
30
+ static NSHashTable<NanoIconView *> *sNanoIconLiveViews;
31
+ static dispatch_once_t sNanoIconLiveViewsOnce;
32
+
33
+ static void NanoIconTrackLiveView(NanoIconView *view) {
34
+ dispatch_once(&sNanoIconLiveViewsOnce, ^{
35
+ sNanoIconLiveViews = [NSHashTable weakObjectsHashTable];
36
+ [[NSNotificationCenter defaultCenter]
37
+ addObserverForName:(__bridge NSString *)kCTFontManagerRegisteredFontsChangedNotification
38
+ object:nil
39
+ queue:[NSOperationQueue mainQueue]
40
+ usingBlock:^(__unused NSNotification *note) {
41
+ for (NanoIconView *live in [sNanoIconLiveViews allObjects]) {
42
+ [live _resolveFontIfMissing];
43
+ }
44
+ }];
56
45
  });
46
+ [sNanoIconLiveViews addObject:view];
57
47
  }
58
48
 
59
49
  @implementation NanoIconView {
60
- CTFontRef _font; // borrowed from static cache — do NOT CFRelease
50
+ CTFontRef _font; // borrowed from the shared resolver cache — do NOT CFRelease
61
51
  NSString *_fontFamily;
62
52
  CGFloat _fontSize;
63
53
  std::vector<CGGlyph> _glyphs;
64
- std::vector<uint32_t> _colors;
54
+ // Unresolved layer colors — may be trait-dependent (DynamicColorIOS, PlatformColor).
55
+ NSArray<UIColor *> *_layerColors;
56
+ // _layerColors resolved against the current trait collection.
65
57
  std::vector<CGColorRef> _cachedCGColors;
58
+ UIColor *_tintColor;
59
+ CGColorRef _cachedTintCGColor;
60
+ std::vector<bool> _tintable;
66
61
  CGFloat _fitScale;
67
62
  CGPoint _baselinePosition;
68
63
  BOOL _metricsValid;
69
64
 
70
65
  // Inline-in-Text detection — resolved once on first layout, cached until reparenting.
71
66
  // Standalone icons (vast majority) skip the superview walk entirely after detection.
72
- BOOL _inlineDetected;
73
- BOOL _isInlineInText;
74
- UIView * __weak _paragraphView;
75
- CGFloat _cachedBaselineOffset;
67
+ BOOL _paragraphResolved;
68
+ UIView * __weak _paragraph;
69
+ CGFloat _baselineOffset;
76
70
  BOOL _baselineOffsetValid;
77
71
 
78
72
  // Drawing sublayer for inline icons — provides a shifted pixel buffer so the
@@ -92,6 +86,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
92
86
 
93
87
  _fitScale = 1.0;
94
88
  _baselinePosition = CGPointZero;
89
+ NanoIconTrackLiveView(self);
95
90
 
96
91
  // _drawingLayer is created lazily only when inline in Text
97
92
  }
@@ -122,61 +117,19 @@ void NanoIconInvalidateFontCache(NSString *family) {
122
117
  _metricsValid = YES;
123
118
  }
124
119
 
125
- // Detect whether this icon is inline inside a <Text> component and, if so,
126
- // compute the baseline offset in a single pass. Deferred to first layout
127
- // (not didMoveToSuperview) because Fabric may assemble the hierarchy bottom-up.
128
- // For standalone icons this completes in 1-3 class name checks with no
129
- // ObjC runtime method resolution or attributed string reads.
130
- - (void)_detectAndCacheInlineState {
131
- _inlineDetected = YES;
132
- _isInlineInText = NO;
133
- _paragraphView = nil;
134
- _cachedBaselineOffset = 0;
135
- _baselineOffsetValid = YES;
136
-
137
- // RCTParagraphComponentView is the immediate or near-immediate parent
138
- // when the icon is inside <Text>. Three levels covers all known layouts.
139
- UIView *current = self.superview;
140
- UIView *target = nil;
141
- for (int i = 0; i < 3 && current; i++) {
142
- if ([NSStringFromClass([current class]) isEqualToString:@"RCTParagraphComponentView"]) {
143
- target = current;
144
- break;
145
- }
146
- current = current.superview;
147
- }
148
-
149
- if (!target) return;
120
+ - (void)invalidateInlineBaseline {
121
+ _baselineOffsetValid = NO;
122
+ [self setNeedsLayout];
123
+ }
150
124
 
151
- NSAttributedString *attrStr = nil;
152
- if ([target respondsToSelector:@selector(attributedText)]) {
153
- attrStr = [target performSelector:@selector(attributedText)];
125
+ // The baseline offset depends on where RN placed the view, so a new frame
126
+ // invalidates it.
127
+ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
128
+ oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
129
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
130
+ if (layoutMetrics.frame != oldLayoutMetrics.frame) {
131
+ _baselineOffsetValid = NO;
154
132
  }
155
- if (!attrStr || attrStr.length == 0) return;
156
-
157
- UIFont *f = [attrStr attribute:NSFontAttributeName atIndex:0 effectiveRange:nil];
158
- if (!f) return;
159
-
160
- _isInlineInText = YES;
161
- _paragraphView = target;
162
-
163
- // Derive the distance from this view's bottom edge to the text baseline.
164
- // Respects custom RN lineHeight (mapped to NSParagraphStyle.maximumLineHeight)
165
- // and any baseline offset applied by Fabric's text layout.
166
- NSParagraphStyle *style = [attrStr attribute:NSParagraphStyleAttributeName
167
- atIndex:0 effectiveRange:nil];
168
- CGFloat lineHeight = (style && style.maximumLineHeight > 0)
169
- ? style.maximumLineHeight : f.lineHeight;
170
-
171
- NSNumber *bOff = [attrStr attribute:NSBaselineOffsetAttributeName
172
- atIndex:0 effectiveRange:nil];
173
- CGFloat baselineFromLineTop = f.ascender - (bOff ? bOff.doubleValue : 0);
174
-
175
- CGFloat frameBottom = self.frame.origin.y + self.frame.size.height;
176
- CGFloat posInLine = fmod(frameBottom, lineHeight);
177
- if (posInLine < 0.01) posInLine = lineHeight;
178
-
179
- _cachedBaselineOffset = MAX(0, posInLine - baselineFromLineTop);
180
133
  }
181
134
 
182
135
  // Lazily create the drawing sublayer for inline-in-Text icons.
@@ -186,6 +139,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
186
139
  NanoIconDrawingLayer *layer = [NanoIconDrawingLayer layer];
187
140
  layer.owner = self;
188
141
  layer.opaque = NO;
142
+ layer.needsDisplayOnBoundsChange = YES;
189
143
  layer.contentsScale = [UIScreen mainScreen].scale;
190
144
  [self.layer addSublayer:layer];
191
145
  _drawingLayer = layer;
@@ -194,63 +148,65 @@ void NanoIconInvalidateFontCache(NSString *family) {
194
148
  // Reset inline state when the view moves to a new parent.
195
149
  - (void)didMoveToSuperview {
196
150
  [super didMoveToSuperview];
197
- _inlineDetected = NO;
198
- _isInlineInText = NO;
199
- _paragraphView = nil;
151
+ _paragraphResolved = NO;
152
+ _paragraph = nil;
200
153
  _baselineOffsetValid = NO;
201
- if (_drawingLayer) {
202
- [_drawingLayer removeFromSuperlayer];
203
- _drawingLayer = nil;
204
- }
205
154
  }
206
155
 
207
- // Invalidate cached offset when size changes (text relayout).
156
+ // _baselineOffset and _fitScale are both derived from bounds.
208
157
  - (void)setBounds:(CGRect)bounds {
209
158
  if (!CGSizeEqualToSize(self.bounds.size, bounds.size)) {
210
159
  _baselineOffsetValid = NO;
160
+ _metricsValid = NO;
211
161
  }
212
162
  [super setBounds:bounds];
213
163
  }
214
164
 
215
165
  #pragma mark - Layout
216
166
 
217
- // Standalone: no work beyond metrics validation (drawing via drawRect: on self).
218
- // Inline: position the drawing sublayer with the cached baseline offset,
219
- // recomputing only when bounds change or the view is reparented.
220
167
  - (void)layoutSubviews {
221
168
  [super layoutSubviews];
222
169
  if (!_metricsValid) [self _updateMetrics];
223
-
224
- if (!_inlineDetected) {
225
- [self _detectAndCacheInlineState];
170
+ if (!_paragraphResolved) {
171
+ _paragraph = NanoIconParagraphNeedingBaselineCorrection(self);
172
+ _paragraphResolved = YES;
173
+ }
174
+ if (!_baselineOffsetValid) {
175
+ _baselineOffset = _paragraph ? NanoIconInlineBaselineOffset(self, _paragraph) : 0;
176
+ _baselineOffsetValid = YES;
226
177
  }
178
+ [self _layoutDrawingLayer];
179
+ }
227
180
 
228
- if (_isInlineInText) {
229
- if (!_baselineOffsetValid) {
230
- [self _detectAndCacheInlineState];
231
- }
232
- BOOL created = !_drawingLayer;
233
- [self _ensureDrawingLayer];
234
- CGRect newFrame = CGRectMake(0, -_cachedBaselineOffset,
235
- self.bounds.size.width, self.bounds.size.height);
236
- if (!CGRectEqualToRect(_drawingLayer.frame, newFrame)) {
237
- [CATransaction begin];
238
- [CATransaction setDisableActions:YES];
239
- _drawingLayer.frame = newFrame;
240
- [CATransaction commit];
181
+ // Standalone icons draw in drawRect:. An icon that needs a baseline correction
182
+ // draws in a sublayer shifted by the offset instead, so it can overflow the
183
+ // Yoga frame without moving the view itself.
184
+ - (void)_layoutDrawingLayer {
185
+ if (_baselineOffset == 0) {
186
+ if (_drawingLayer) {
187
+ [_drawingLayer removeFromSuperlayer];
188
+ _drawingLayer = nil;
189
+ [self setNeedsDisplay];
241
190
  }
242
- // First layout after inline detection: the layer missed the initial
243
- // setNeedsDisplay from updateProps (which targeted self before detection).
244
- if (created) [_drawingLayer setNeedsDisplay];
191
+ return;
245
192
  }
246
- // standalone: draws directly via drawRect: on self
193
+ BOOL created = !_drawingLayer;
194
+ [self _ensureDrawingLayer];
195
+ CGRect frame = CGRectMake(0, -_baselineOffset, self.bounds.size.width, self.bounds.size.height);
196
+ if (!CGRectEqualToRect(_drawingLayer.frame, frame)) {
197
+ [CATransaction begin];
198
+ [CATransaction setDisableActions:YES];
199
+ _drawingLayer.frame = frame;
200
+ [CATransaction commit];
201
+ }
202
+ if (created) [_drawingLayer setNeedsDisplay];
247
203
  }
248
204
 
249
205
  #pragma mark - Drawing
250
206
 
251
207
  // Standalone icons draw directly in this view's drawRect:.
252
208
  - (void)drawRect:(CGRect)rect {
253
- if (_isInlineInText) return; // inline icons draw via _drawingLayer
209
+ if (_drawingLayer) return;
254
210
  CGContextRef ctx = UIGraphicsGetCurrentContext();
255
211
  if (ctx) [self _drawIconInContext:ctx bounds:self.bounds];
256
212
  }
@@ -271,7 +227,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
271
227
  while (i < _glyphs.size()) {
272
228
  if (_glyphs[i] == 0) { i++; continue; }
273
229
 
274
- CGColorRef color = (i < _cachedCGColors.size()) ? _cachedCGColors[i] : NULL;
230
+ CGColorRef color = [self _colorForLayer:i];
275
231
  if (!color) {
276
232
  static CGColorRef sBlack = CGColorCreateSRGB(0, 0, 0, 1);
277
233
  color = sBlack;
@@ -286,7 +242,7 @@ void NanoIconInvalidateFontCache(NSString *family) {
286
242
 
287
243
  while (i < _glyphs.size()) {
288
244
  if (_glyphs[i] == 0) { i++; continue; }
289
- CGColorRef next = (i < _cachedCGColors.size()) ? _cachedCGColors[i] : NULL;
245
+ CGColorRef next = [self _colorForLayer:i];
290
246
  if (i > batchStart && next != color) break;
291
247
  if (batchCount < 16) {
292
248
  posBuf[batchCount] = _baselinePosition;
@@ -326,19 +282,34 @@ void NanoIconInvalidateFontCache(NSString *family) {
326
282
  - (void)_releaseCachedColors {
327
283
  for (CGColorRef c : _cachedCGColors) CGColorRelease(c);
328
284
  _cachedCGColors.clear();
285
+ if (_cachedTintCGColor) {
286
+ CGColorRelease(_cachedTintCGColor);
287
+ _cachedTintCGColor = NULL;
288
+ }
329
289
  }
330
290
 
331
- // Convert ARGB uint32 color values into cached CGColorRefs.
291
+ - (CGColorRef)_colorForLayer:(size_t)index {
292
+ if (_cachedTintCGColor && index < _tintable.size() && _tintable[index]) {
293
+ return _cachedTintCGColor;
294
+ }
295
+ return index < _cachedCGColors.size() ? _cachedCGColors[index] : NULL;
296
+ }
297
+
298
+ // Resolve the layer colors against the current traits into cached CGColorRefs.
299
+ // Resolving up front (rather than relying on UIKit's current trait collection at
300
+ // draw time) keeps the CALayer inline-in-Text path correct — CoreAnimation does
301
+ // not install a trait collection around -drawInContext:.
332
302
  - (void)_rebuildCachedColors {
333
303
  [self _releaseCachedColors];
334
- _cachedCGColors.resize(_colors.size());
335
- for (size_t i = 0; i < _colors.size(); i++) {
336
- uint32_t ci = _colors[i];
337
- _cachedCGColors[i] = CGColorCreateSRGB(
338
- ((ci >> 16) & 0xFF) / 255.0,
339
- ((ci >> 8) & 0xFF) / 255.0,
340
- ( ci & 0xFF) / 255.0,
341
- ((ci >> 24) & 0xFF) / 255.0);
304
+ UITraitCollection *traits = self.traitCollection;
305
+ _cachedCGColors.resize(_layerColors.count);
306
+ for (NSUInteger i = 0; i < _layerColors.count; i++) {
307
+ UIColor *resolved = [_layerColors[i] resolvedColorWithTraitCollection:traits];
308
+ _cachedCGColors[i] = CGColorRetain(resolved.CGColor);
309
+ }
310
+ if (_tintColor) {
311
+ UIColor *resolved = [_tintColor resolvedColorWithTraitCollection:traits];
312
+ _cachedTintCGColor = CGColorRetain(resolved.CGColor);
342
313
  }
343
314
  }
344
315
 
@@ -350,10 +321,10 @@ void NanoIconInvalidateFontCache(NSString *family) {
350
321
  BOOL needsRedraw = NO;
351
322
 
352
323
  if (oldViewProps.fontFamily != newViewProps.fontFamily ||
353
- oldViewProps.fontSize != newViewProps.fontSize) {
324
+ oldViewProps.size != newViewProps.size) {
354
325
  _fontFamily = [NSString stringWithUTF8String:newViewProps.fontFamily.c_str()];
355
- _fontSize = newViewProps.fontSize;
356
- _font = NanoIconGetCachedFont(_fontFamily, _fontSize);
326
+ _fontSize = newViewProps.size;
327
+ _font = NanoIconResolveFont(_fontFamily, _fontSize);
357
328
  _metricsValid = NO;
358
329
  fontChanged = YES;
359
330
  needsRedraw = YES;
@@ -361,52 +332,97 @@ void NanoIconInvalidateFontCache(NSString *family) {
361
332
 
362
333
  // Map Unicode codepoints to font glyph IDs, handling surrogate pairs for codepoints > 0xFFFF.
363
334
  if (fontChanged || oldViewProps.codepoints != newViewProps.codepoints) {
364
- // Re-fetch on codepoint change — cache may have been cleared by OTA font swap.
365
- if (!fontChanged && _fontFamily) {
366
- _font = NanoIconGetCachedFont(_fontFamily, _fontSize);
367
- }
368
- const auto &codepoints = newViewProps.codepoints;
369
- _glyphs.resize(codepoints.size());
370
- for (size_t i = 0; i < codepoints.size(); i++) {
371
- int32_t cp = codepoints[i];
372
- if (cp <= 0xFFFF) {
373
- UniChar ch = (UniChar)cp;
374
- CTFontGetGlyphsForCharacters(_font, &ch, &_glyphs[i], 1);
375
- } else {
376
- UniChar surr[2] = {
377
- (UniChar)(0xD800 + ((cp - 0x10000) >> 10)),
378
- (UniChar)(0xDC00 + ((cp - 0x10000) & 0x3FF))
379
- };
380
- CGGlyph pair[2] = {0, 0};
381
- CTFontGetGlyphsForCharacters(_font, surr, pair, 2);
382
- _glyphs[i] = pair[0];
383
- }
384
- }
335
+ [self _mapGlyphs:newViewProps.codepoints];
385
336
  needsRedraw = YES;
386
337
  }
387
338
 
388
339
  if (oldViewProps.colors != newViewProps.colors) {
389
340
  const auto &colors = newViewProps.colors;
390
- _colors.resize(colors.size());
341
+ NSMutableArray<UIColor *> *layerColors = [NSMutableArray arrayWithCapacity:colors.size()];
391
342
  for (size_t i = 0; i < colors.size(); i++) {
392
- _colors[i] = (uint32_t)colors[i];
343
+ UIColor *color = RCTUIColorFromSharedColor(colors[i]);
344
+ [layerColors addObject:color ?: [UIColor blackColor]];
393
345
  }
346
+ _layerColors = layerColors;
394
347
  [self _rebuildCachedColors];
395
348
  needsRedraw = YES;
396
349
  }
397
350
 
351
+ if (oldViewProps.color != newViewProps.color) {
352
+ _tintColor = newViewProps.color ? RCTUIColorFromSharedColor(newViewProps.color) : nil;
353
+ [self _rebuildCachedColors];
354
+ needsRedraw = YES;
355
+ }
356
+
357
+ if (oldViewProps.tintLayers != newViewProps.tintLayers ||
358
+ oldViewProps.codepoints != newViewProps.codepoints) {
359
+ _tintable.assign(newViewProps.codepoints.size(), false);
360
+ for (int layer : newViewProps.tintLayers) {
361
+ if (layer >= 0 && (size_t)layer < _tintable.size()) _tintable[layer] = true;
362
+ }
363
+ needsRedraw = YES;
364
+ }
365
+
398
366
  [super updateProps:props oldProps:oldProps];
399
- if (needsRedraw) {
400
- if (_isInlineInText && _drawingLayer) {
401
- [_drawingLayer setNeedsDisplay];
367
+ if (needsRedraw) [self _setNeedsRedraw];
368
+ }
369
+
370
+ - (void)_mapGlyphs:(const std::vector<int32_t> &)codepoints {
371
+ _glyphs.assign(codepoints.size(), 0);
372
+ if (!_font) return;
373
+ for (size_t i = 0; i < codepoints.size(); i++) {
374
+ int32_t cp = codepoints[i];
375
+ if (cp <= 0xFFFF) {
376
+ UniChar ch = (UniChar)cp;
377
+ CTFontGetGlyphsForCharacters(_font, &ch, &_glyphs[i], 1);
402
378
  } else {
403
- [self setNeedsDisplay];
379
+ UniChar surr[2] = {
380
+ (UniChar)(0xD800 + ((cp - 0x10000) >> 10)),
381
+ (UniChar)(0xDC00 + ((cp - 0x10000) & 0x3FF))
382
+ };
383
+ CGGlyph pair[2] = {0, 0};
384
+ CTFontGetGlyphsForCharacters(_font, surr, pair, 2);
385
+ _glyphs[i] = pair[0];
404
386
  }
405
387
  }
406
388
  }
407
389
 
390
+ // Trait-dependent colors (DynamicColorIOS, PlatformColor) resolve to a different
391
+ // CGColor when the interface style or contrast changes. Fabric does not re-send
392
+ // props for that, so re-resolve and redraw here.
393
+ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
394
+ [super traitCollectionDidChange:previousTraitCollection];
395
+
396
+ if (_layerColors.count == 0 && !_tintColor) return;
397
+ if (![self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) {
398
+ return;
399
+ }
400
+
401
+ [self _rebuildCachedColors];
402
+ [self _setNeedsRedraw];
403
+ }
404
+
405
+ - (void)_resolveFontIfMissing {
406
+ if (_font || _fontFamily.length == 0) return;
407
+ _font = NanoIconResolveFont(_fontFamily, _fontSize);
408
+ if (!_font) return;
409
+ const auto &viewProps = static_cast<const NanoIconViewProps &>(*_props);
410
+ [self _mapGlyphs:viewProps.codepoints];
411
+ _metricsValid = NO;
412
+ [self _setNeedsRedraw];
413
+ }
414
+
415
+ - (void)_setNeedsRedraw {
416
+ if (_drawingLayer) {
417
+ [_drawingLayer setNeedsDisplay];
418
+ } else {
419
+ [self setNeedsDisplay];
420
+ }
421
+ }
422
+
408
423
  - (void)dealloc {
409
424
  // _font is borrowed from static cache — do not release
425
+ [sNanoIconLiveViews removeObject:self];
410
426
  [self _releaseCachedColors];
411
427
  }
412
428
 
@@ -1,5 +1,5 @@
1
+ #import "NanoIconFontResolver.h"
1
2
  #import "NanoIconsFontLoader.h"
2
- #import "NanoIconView.h"
3
3
  #import <CoreText/CoreText.h>
4
4
 
5
5
  @implementation NanoIconsFontLoader
@@ -43,7 +43,7 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
43
43
  if (!nameMatches) {
44
44
  CGFontRelease(cgFont);
45
45
  reject(
46
- @"E_NANOICONS_FONT_REGISTER",
46
+ @"E_NANOICONS_FONT_MISMATCH",
47
47
  [NSString stringWithFormat:
48
48
  @"Font name \"%@\" does not match family \"%@\". "
49
49
  @"On iOS the TTF PostScript/full name must equal glyphMap.m.f.",
@@ -54,51 +54,29 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
54
54
 
55
55
  CFErrorRef error = NULL;
56
56
  bool ok = CTFontManagerRegisterGraphicsFont(cgFont, &error);
57
- // defer cgFont release — needed for re-registration if name conflict.
57
+ CGFontRelease(cgFont);
58
58
 
59
59
  if (!ok && error) {
60
60
  NSError *err = (__bridge_transfer NSError *)error;
61
-
62
61
  if (err.code == kCTFontManagerErrorAlreadyRegistered ||
63
62
  err.code == kCTFontManagerErrorDuplicatedName) {
64
- // OTA reload: process still holds the old font. Swap it out.
65
- CTFontRef existingCT = CTFontCreateWithName((__bridge CFStringRef)postScriptName, 10.0, NULL);
66
- if (existingCT) {
67
- CGFontRef existingCG = CTFontCopyGraphicsFont(existingCT, NULL);
68
- CFRelease(existingCT);
69
- if (existingCG) {
70
- CFErrorRef unregErr = NULL;
71
- CTFontManagerUnregisterGraphicsFont(existingCG, &unregErr);
72
- CFRelease(existingCG);
73
- if (unregErr) CFRelease(unregErr);
74
- }
75
- }
76
-
77
- CFErrorRef regErr = NULL;
78
- bool reok = CTFontManagerRegisterGraphicsFont(cgFont, &regErr);
79
- CGFontRelease(cgFont);
80
-
81
- if (!reok && regErr) {
82
- NSError *reErr = (__bridge_transfer NSError *)regErr;
83
- reject(@"E_NANOICONS_FONT_REGISTER", reErr.localizedDescription, reErr);
84
- return;
85
- }
86
- if (regErr) CFRelease(regErr);
87
-
88
- NanoIconInvalidateFontCache(postScriptName);
89
63
  resolve(@(YES));
90
64
  return;
91
65
  }
92
-
93
- CGFontRelease(cgFont);
94
66
  reject(@"E_NANOICONS_FONT_REGISTER", err.localizedDescription, err);
95
67
  return;
96
68
  }
97
69
 
98
- CGFontRelease(cgFont);
99
70
  resolve(@(YES));
100
71
  }
101
72
 
73
+ RCT_EXPORT_METHOD(isFontRegistered:(NSString *)family
74
+ resolve:(RCTPromiseResolveBlock)resolve
75
+ reject:(RCTPromiseRejectBlock)reject)
76
+ {
77
+ resolve(@(NanoIconIsFontResolvable(family)));
78
+ }
79
+
102
80
  #ifdef RCT_NEW_ARCH_ENABLED
103
81
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
104
82
  (const facebook::react::ObjCTurboModule::InitParams &)params
@@ -1,4 +1,5 @@
1
- import type { NanoLogger } from './logger.js';
1
+ import { type PreparedSvgCache, type SvgWorkerPool } from '../src/core/pipeline/index';
2
+ import type { NanoLogger } from './logger';
2
3
  export type IconSetConfig = {
3
4
  /** Path to folder of SVG files (relative to project root). */
4
5
  inputDir: string;
@@ -8,24 +9,36 @@ export type IconSetConfig = {
8
9
  outputDir?: string;
9
10
  /** Units per em (default 1024). */
10
11
  upm?: number;
11
- /** Safe zone inside UPM for glyphs (default 1020). */
12
+ /** Safe zone inside UPM for glyphs (default upm * 1020 / 1024, i.e. 1020 at the default upm). Must not exceed upm. */
12
13
  safeZone?: number;
13
14
  /** First Unicode codepoint for glyphs (default 0xe900). Hex string or number. */
14
15
  startUnicode?: number | string;
15
16
  /** Linking type for the font (default 'static'). Static bundles the TTF, dynamic delivers it via OTA*/
16
17
  linking?: 'static' | 'dynamic';
18
+ /** Also emit <fontFamily>.woff2 into outputDir for web (default false). Rebuilt with the TTF, never linked natively. */
19
+ web?: boolean;
17
20
  };
18
21
  export type BuiltFont = {
19
22
  fontFamily: string;
23
+ family: string;
20
24
  ttfPath: string;
21
25
  glyphmapPath: string;
22
26
  linking: 'static' | 'dynamic';
27
+ woff2Path?: string;
23
28
  };
29
+ export declare class IconSetBuildError extends Error {
30
+ built: BuiltFont[];
31
+ constructor(message: string, built: BuiltFont[]);
32
+ }
24
33
  /**
25
- * Build TTF + glyphmap for all icon sets using a single Pyodide/PathKit instance.
34
+ * Build TTF + glyphmap for all icon sets using a single PathKit instance.
26
35
  * Output is placed in a "nanoicons" folder next to each input dir (sibling to inputDir).
27
36
  * Skips generation for a set if that output folder already contains the expected .ttf and .glyphmap.json.
28
37
  */
29
38
  export declare function buildAllFonts(iconSets: IconSetConfig[], projectRoot: string, options?: {
30
39
  logger?: NanoLogger;
40
+ keepOutputsOnFailure?: boolean;
41
+ preparedSvgCache?: PreparedSvgCache;
42
+ svgWorkerPool?: SvgWorkerPool;
43
+ withWeb?: boolean;
31
44
  }): Promise<BuiltFont[]>;