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
@@ -11,7 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.author = package["author"]
12
12
  s.source = { :git => package["repository"], :tag => "#{s.version}" }
13
13
  s.platforms = { :ios => "15.1", :tvos => "15.1" }
14
- s.source_files = "ios/**/*.{h,m,mm,cpp}"
14
+ s.source_files = "ios/**/*.{h,m,mm,cpp}", "common/cpp/**/*.{h,cpp}"
15
+ s.pod_target_xcconfig = {
16
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\""
17
+ }
15
18
  s.requires_arc = true
16
19
 
17
20
  install_modules_dependencies(s)
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ componentDescriptors: ['NanoIconViewComponentDescriptor'],
6
+ cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
7
+ },
8
+ },
9
+ },
10
+ };
@@ -1,16 +1,19 @@
1
1
  import { codegenNativeComponent } from 'react-native';
2
- import type { ViewProps } from 'react-native';
2
+ import type { ColorValue, ViewProps } from 'react-native';
3
3
  import type { Float, Int32 } from '../const/codegenPrimitives';
4
4
 
5
5
  export interface NativeProps extends ViewProps {
6
6
  fontFamily: string;
7
7
  codepoints: ReadonlyArray<Int32>;
8
- colors: ReadonlyArray<Int32>;
9
- fontSize: Float;
8
+ colors: ReadonlyArray<ColorValue>;
9
+ color?: ColorValue;
10
+ tintLayers: ReadonlyArray<Int32>;
11
+ size: Float;
12
+ allowFontScaling: boolean;
10
13
  advanceWidth: Int32;
11
14
  unitsPerEm: Int32;
12
- iconWidth: Float;
13
- iconHeight: Float;
14
15
  }
15
16
 
16
- export default codegenNativeComponent<NativeProps>('NanoIconView');
17
+ export default codegenNativeComponent<NativeProps>('NanoIconView', {
18
+ interfaceOnly: true,
19
+ });
@@ -4,6 +4,7 @@ import { TurboModuleRegistry } from 'react-native';
4
4
  export interface Spec extends TurboModule {
5
5
  /** Pass glyphMap.m.f as `family`. On iOS it must also match the TTF's embedded PostScript/full name. */
6
6
  registerFont(family: string, uri: string): Promise<boolean>;
7
+ isFontRegistered(family: string): Promise<boolean>;
7
8
  }
8
9
 
9
10
  // `get` (not `getEnforcing`) so the absence of the native module (web, Expo Go,
@@ -1,11 +0,0 @@
1
- import type { PathKitModule, PyodideModule } from '../types.js';
2
- export declare class PathKitManager {
3
- private static instance;
4
- static getInstance(): Promise<PathKitModule>;
5
- }
6
- export declare class PyodideManager {
7
- private static instance;
8
- static getInstance(): Promise<PyodideModule>;
9
- static picoFromFile(hostFilePath: string, content?: string): Promise<string>;
10
- }
11
- export declare function picoFromFile(hostFilePath: string, content?: string): Promise<string>;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PyodideManager = exports.PathKitManager = void 0;
7
- exports.picoFromFile = picoFromFile;
8
- const pyodide_1 = require("pyodide");
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const promises_1 = __importDefault(require("node:fs/promises"));
11
- const svg_pathops_js_1 = require("../svg/svg_pathops.js");
12
- /** Package root (where package.json lives). */
13
- function getPackageRoot() {
14
- // Compiled to lib/commonjs/src/core/pipeline/ — 5 dirs up is package root.
15
- // Running from source (Jest/ts-node) in src/core/pipeline/ — 3 dirs up is package root.
16
- return __dirname.includes(`${node_path_1.default.sep}lib${node_path_1.default.sep}`)
17
- ? node_path_1.default.resolve(__dirname, '../../../../..')
18
- : node_path_1.default.resolve(__dirname, '../../..');
19
- }
20
- class PathKitManager {
21
- static instance = null;
22
- static async getInstance() {
23
- if (this.instance)
24
- return this.instance;
25
- const PathKitInit = require('pathkit-wasm/bin/pathkit.js');
26
- const pathkitJsPath = require.resolve('pathkit-wasm/bin/pathkit.js');
27
- const pathkitBinDir = node_path_1.default.dirname(pathkitJsPath);
28
- const pathkitWasmPath = node_path_1.default.join(pathkitBinDir, 'pathkit.wasm');
29
- const wasmBinary = await promises_1.default.readFile(pathkitWasmPath);
30
- const pkInit = PathKitInit({
31
- wasmBinary,
32
- locateFile: (file) => node_path_1.default.join(pathkitBinDir, file),
33
- });
34
- const PathKit = await (typeof pkInit?.ready === 'function'
35
- ? pkInit.ready()
36
- : pkInit);
37
- this.instance = PathKit;
38
- return PathKit;
39
- }
40
- }
41
- exports.PathKitManager = PathKitManager;
42
- class PyodideManager {
43
- static instance = null;
44
- static async getInstance() {
45
- if (this.instance)
46
- return this.instance;
47
- const pyodideAsmPath = require.resolve('pyodide/pyodide.asm.js');
48
- const pyodideDir = node_path_1.default.dirname(pyodideAsmPath) + node_path_1.default.sep;
49
- const py = (await (0, pyodide_1.loadPyodide)({
50
- indexURL: pyodideDir,
51
- }));
52
- py.mountNodeFS('/app', process.cwd());
53
- const PathKit = await PathKitManager.getInstance();
54
- py.registerJsModule('_pathops_js', (0, svg_pathops_js_1.buildPathopsBackend)(PathKit));
55
- const pathopsPyPath = node_path_1.default.join(getPackageRoot(), 'src', 'core', 'shims', 'pathops.py');
56
- const pathopsPy = await promises_1.default.readFile(pathopsPyPath, 'utf8');
57
- py.FS.writeFile('/pathops.py', pathopsPy);
58
- await py.loadPackage(['micropip', 'lxml'], { messageCallback: () => { } });
59
- // Resolve local picosvg wheel path for offline-first installation.
60
- const picosvgWhlDir = node_path_1.default.join(getPackageRoot(), 'src', 'core', 'shims');
61
- const picosvgWhl = (await promises_1.default.readdir(picosvgWhlDir)).find((f) => f.startsWith('picosvg-') && f.endsWith('.whl'));
62
- const localWhlUrl = picosvgWhl
63
- ? `file://${node_path_1.default.join(picosvgWhlDir, picosvgWhl)}`
64
- : null;
65
- py.globals.set('_picosvg_local_whl', localWhlUrl);
66
- await py.runPythonAsync(`
67
- import sys
68
- if "/" not in sys.path:
69
- sys.path.insert(0, "/")
70
-
71
- import micropip
72
-
73
- _whl = _picosvg_local_whl
74
- if _whl:
75
- try:
76
- await micropip.install(_whl, deps=False)
77
- except Exception:
78
- await micropip.install("picosvg", deps=False)
79
- else:
80
- await micropip.install("picosvg", deps=False)
81
-
82
- import pathops
83
- import picosvg
84
- `);
85
- this.instance = py;
86
- return py;
87
- }
88
- static async picoFromFile(hostFilePath, content) {
89
- const py = await this.getInstance();
90
- const svgContent = content ?? (await promises_1.default.readFile(hostFilePath, 'utf-8'));
91
- py.globals.set('_svg_content', svgContent);
92
- const out = py.runPython(`
93
- from picosvg.svg import SVG
94
- svg = SVG.fromstring(_svg_content)
95
- pico = svg.topicosvg()
96
- pico.tostring(pretty_print=True)
97
- `);
98
- return out;
99
- }
100
- }
101
- exports.PyodideManager = PyodideManager;
102
- async function picoFromFile(hostFilePath, content) {
103
- return PyodideManager.picoFromFile(hostFilePath, content);
104
- }
@@ -1,14 +0,0 @@
1
- import { type PipelineConfig, type PipelinePaths } from './config.js';
2
- import type { NanoLogger } from '../types.js';
3
- export type PipelineResult = {
4
- ttfPath: string;
5
- glyphmapPath: string;
6
- };
7
- /**
8
- * Run the font pipeline with given config and paths.
9
- * Uses the singleton Pyodide/PathKit instance (initialized on first call).
10
- */
11
- export declare function runPipeline(config: PipelineConfig, paths: PipelinePaths, options?: {
12
- logger?: NanoLogger;
13
- inputHash?: string;
14
- }): Promise<PipelineResult>;
@@ -1,189 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.runPipeline = runPipeline;
7
- const promises_1 = __importDefault(require("node:fs/promises"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const compile_js_1 = require("../font/compile.js");
10
- const managers_js_1 = require("./managers.js");
11
- const config_js_1 = require("./config.js");
12
- const svg_dom_js_1 = require("../svg/svg_dom.js");
13
- const layers_js_1 = require("../svg/layers.js");
14
- const svg_pathops_js_1 = require("../svg/svg_pathops.js");
15
- /**
16
- * Concatenate multiple SVG path `d` strings into a single compound path.
17
- * This preserves the exact geometry of each path (no boolean operations)
18
- * while combining them into one glyph. Under nonzero winding, this renders
19
- * identically to drawing each path separately with the same color.
20
- */
21
- function concatPathDs(ds) {
22
- if (ds.length === 0)
23
- return null;
24
- if (ds.length === 1)
25
- return ds[0];
26
- return ds.join(' ');
27
- }
28
- /**
29
- * Merge consecutive same-color paths into single compound paths via boolean UNION.
30
- * Preserves z-order: only merges runs of adjacent paths with identical fill color.
31
- */
32
- function mergeSameColorPaths(paths, logger) {
33
- if (paths.length <= 1)
34
- return paths;
35
- const result = [];
36
- let i = 0;
37
- while (i < paths.length) {
38
- const fill = paths[i].fill;
39
- // Find consecutive run of same fill that are all mergeable.
40
- // Paths converted from evenodd have compound hole structure and must not
41
- // be merged — their CW hole contours would cancel CCW contours from
42
- // adjacent paths, producing incorrect fill.
43
- let j = i + 1;
44
- if (!paths[i].noMerge) {
45
- while (j < paths.length &&
46
- paths[j].fill === fill &&
47
- !paths[j].noMerge) {
48
- j++;
49
- }
50
- }
51
- if (j - i === 1) {
52
- result.push(paths[i]);
53
- }
54
- else {
55
- const group = paths.slice(i, j);
56
- const merged = concatPathDs(group.map((p) => p.d));
57
- if (merged) {
58
- logger?.info(` ⊕ Merged ${group.length} same-color paths (fill=${fill})`);
59
- result.push({ d: merged, fill });
60
- }
61
- else {
62
- result.push(...group);
63
- }
64
- }
65
- i = j;
66
- }
67
- return result;
68
- }
69
- // ---------------------------------------------------------------------------
70
- // Pipeline
71
- // ---------------------------------------------------------------------------
72
- /**
73
- * Run the font pipeline with given config and paths.
74
- * Uses the singleton Pyodide/PathKit instance (initialized on first call).
75
- */
76
- async function runPipeline(config, paths, options) {
77
- const startTime = Date.now();
78
- const logger = options?.logger;
79
- logger?.update(`Building "${config.fontFamily}"…`);
80
- (0, config_js_1.ensureDir)(paths.outputDir);
81
- const files = (await promises_1.default.readdir(paths.inputDir)).filter((f) => f.toLowerCase().endsWith('.svg'));
82
- const glyphMap = {
83
- m: {
84
- f: config.fontFamily,
85
- u: config.upm,
86
- z: config.safeZone,
87
- s: config.startUnicode,
88
- ...(config.linking === 'dynamic' ? { l: 'd' } : {}),
89
- },
90
- i: {},
91
- };
92
- let currentUnicode = config.startUnicode;
93
- const codepointToIcon = new Map();
94
- const allGlyphs = [];
95
- const PathKit = await managers_js_1.PathKitManager.getInstance();
96
- for (const file of files) {
97
- const iconName = node_path_1.default.parse(file).name;
98
- const filePath = node_path_1.default.join(paths.inputDir, file);
99
- logger?.info(`Processing ${file}`);
100
- const rawContent = await promises_1.default.readFile(filePath, 'utf-8');
101
- const validation = (0, svg_dom_js_1.validateSvg)(rawContent);
102
- if (validation.valid === false) {
103
- logger?.warn(`Skipping "${config.fontFamily}:${file}": ${validation.reason}`);
104
- continue;
105
- }
106
- const preprocessed = (0, svg_dom_js_1.preprocessSvg)(rawContent);
107
- // Preserve original evenodd `d` strings BEFORE picosvg processes them.
108
- // Picosvg's simplify (via our PathKit shim) can drop contours from
109
- // multi-subpath evenodd paths — we restore the originals after.
110
- const originalEvenoddDs = (0, svg_dom_js_1.extractOriginalEvenoddDs)(preprocessed);
111
- const flattenedSvg = await (0, managers_js_1.picoFromFile)(filePath, preprocessed);
112
- const parsed = (0, svg_dom_js_1.parseFlattenedSvg)(flattenedSvg, {
113
- onSanitize: (original) => {
114
- logger?.info(` ⚠ Sanitized path in "${file}": path was missing initial moveto (prepended M from endpoint)`);
115
- logger?.info(` Original: ${original.slice(0, 80)}…`);
116
- },
117
- });
118
- // Restore original evenodd path data (undamaged by picosvg's simplify),
119
- // then convert to nonzero winding with our containment-based algorithm.
120
- // Mark as noMerge — compound paths with holes must stay separate so their
121
- // CW hole contours don't cancel adjacent paths' CCW contours.
122
- if (originalEvenoddDs.length > 0) {
123
- (0, svg_dom_js_1.restoreOriginalEvenoddDs)(parsed.paths, originalEvenoddDs);
124
- }
125
- for (const p of parsed.paths) {
126
- if (p.fillRule === 'evenodd') {
127
- logger?.info(` ↻ Converting evenodd path to nonzero winding in "${file}"`);
128
- p.d = (0, svg_pathops_js_1.convertEvenoddToWinding)(PathKit, p.d);
129
- delete p.fillRule;
130
- p.noMerge = true;
131
- }
132
- }
133
- // Merge consecutive same-color paths into single compound glyphs
134
- const mergedPaths = mergeSameColorPaths(parsed.paths, logger);
135
- const { vx, vy, scale, xOff, yOff, adv } = (0, layers_js_1.computePlacement)({
136
- upm: config.upm,
137
- safeZone: config.safeZone,
138
- viewBox: parsed.viewBox,
139
- });
140
- const layers = [];
141
- for (const p of mergedPaths) {
142
- if ((0, svg_dom_js_1.shouldSkipPath)(p.d, p.fill))
143
- continue;
144
- const cp = currentUnicode++;
145
- codepointToIcon.set(cp, iconName);
146
- const fontD = (0, layers_js_1.transformPathForFont)(PathKit, p.d, {
147
- vx,
148
- vy,
149
- scale,
150
- xOff,
151
- yOff,
152
- upm: config.upm,
153
- });
154
- allGlyphs.push({
155
- codepoint: cp,
156
- advanceWidth: adv,
157
- d: fontD,
158
- });
159
- layers.push([cp, p.fill || 'black']);
160
- }
161
- if (layers.length > 0) {
162
- glyphMap.i[iconName] = [adv, layers];
163
- }
164
- }
165
- const glyphmapPath = node_path_1.default.join(paths.outputDir, `${config.fontFamily}.glyphmap.json`);
166
- if (options?.inputHash) {
167
- glyphMap.m.h = options.inputHash;
168
- }
169
- await promises_1.default.writeFile(glyphmapPath, JSON.stringify(glyphMap), 'utf8');
170
- logger?.info(`Compiling TTF…`);
171
- const ttfPath = node_path_1.default.join(paths.outputDir, `${config.fontFamily}.ttf`);
172
- try {
173
- await (0, compile_js_1.compileTtfFromGlyphs)({
174
- glyphs: allGlyphs,
175
- outTtfPath: ttfPath,
176
- fontName: config.fontFamily,
177
- upm: config.upm,
178
- ascent: config.upm,
179
- descent: 0,
180
- });
181
- }
182
- catch (err) {
183
- (0, compile_js_1.parseCompileTtfFromGlyphsError)(err, codepointToIcon);
184
- }
185
- const iconCount = Object.keys(glyphMap.i).length;
186
- const elapsed = Date.now() - startTime;
187
- logger?.succeed(`Built ${config.fontFamily}.ttf [${iconCount} icon${iconCount === 1 ? '' : 's'} in ${elapsed}ms]`);
188
- return { ttfPath, glyphmapPath };
189
- }
@@ -1,51 +0,0 @@
1
- import { type Element } from '@xmldom/xmldom';
2
- export type ParsedFlatSvg = {
3
- viewBox: [number, number, number, number];
4
- paths: Array<{
5
- d: string;
6
- fill: string | null;
7
- fillRule?: 'evenodd';
8
- }>;
9
- };
10
- export declare function calculateOpColor(fill: string | null, opacity: number, el: Element): `rgba(${number},${number},${number},${number})`;
11
- /**
12
- * If a flattened path lost its initial moveto (e.g. picosvg dropped an empty
13
- * `Mx y z` subpath), prepend `M` using the path's last coordinate pair.
14
- * For closed icon shapes the endpoint equals the start point.
15
- */
16
- export declare function sanitizePathData(d: string): {
17
- d: string;
18
- sanitized: boolean;
19
- };
20
- export declare const parsePath: (p: Element) => {
21
- d: string;
22
- fill: string | null;
23
- fillRule?: "evenodd";
24
- };
25
- export declare function parseFlattenedSvg(flattenedSvg: string, options?: {
26
- onSanitize?: (original: string) => void;
27
- }): ParsedFlatSvg;
28
- export declare function shouldSkipPath(d: string, fill: string | null): boolean;
29
- export type SvgValidation = {
30
- valid: true;
31
- } | {
32
- valid: false;
33
- reason: string;
34
- };
35
- export declare function validateSvg(content: string): SvgValidation;
36
- /**
37
- * Extract the original `d` strings of evenodd paths from the raw SVG
38
- * BEFORE picosvg processes it. Picosvg's simplify (via our PathKit shim)
39
- * can drop contours from multi-subpath evenodd paths, so we preserve
40
- * the originals and apply our own winding conversion later.
41
- *
42
- * Returns one `d` string per evenodd path, in document order.
43
- */
44
- export declare function extractOriginalEvenoddDs(svgContent: string): string[];
45
- /**
46
- * Replace picosvg's (potentially damaged) evenodd path data with the
47
- * preserved originals. Matches by position: the Nth evenodd path in
48
- * the parsed output gets the Nth original `d` string.
49
- */
50
- export declare function restoreOriginalEvenoddDs(paths: ParsedFlatSvg['paths'], originalDs: string[]): void;
51
- export declare function preprocessSvg(content: string): string;
@@ -1,32 +0,0 @@
1
- import type { PathKitModule, WrappedPath, Point } from '../types.js';
2
- /**
3
- * Convert a path `d` string with evenodd fill semantics to an equivalent
4
- * path that renders identically under nonzero winding.
5
- *
6
- * Steps:
7
- * 1. Parse via PathKit, set fill type to EVENODD, simplify (resolve topology)
8
- * 2. Split into contours, compute containment depths
9
- * 3. Fix winding: even depth = CCW (outer), odd depth = CW (hole)
10
- * 4. Reconstruct d string
11
- */
12
- export declare function convertEvenoddToWinding(PathKit: PathKitModule, d: string): string;
13
- export declare function buildPathopsBackend(PathKit: PathKitModule): {
14
- create_path(fillTypeInt: number): WrappedPath;
15
- clone_path(h: WrappedPath): WrappedPath;
16
- delete_path(h: WrappedPath): void;
17
- get_fill_type(h: WrappedPath): number;
18
- set_fill_type(h: WrappedPath, fillTypeInt: number): true;
19
- move_to(h: WrappedPath, x: number, y: number): void;
20
- line_to(h: WrappedPath, x: number, y: number): void;
21
- quad_to(h: WrappedPath, x1: number, y1: number, x2: number, y2: number): void;
22
- cubic_to(h: WrappedPath, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): void;
23
- close(h: WrappedPath): void;
24
- simplify(h: WrappedPath, fixWinding?: boolean): boolean;
25
- stroke(h: WrappedPath, width: number, capInt: number, joinInt: number, miterLimit: number, dashArray: unknown, dashOffset: number): WrappedPath;
26
- convert_conics_to_quads(_h: WrappedPath, _tol: number): void;
27
- transform(h: WrappedPath, a: number, b: number, c: number, d: number, e: number, f: number): WrappedPath;
28
- op(aHandle: WrappedPath, bHandle: WrappedPath, opInt: number): WrappedPath | null;
29
- bounds(h: WrappedPath): [number, number, number, number];
30
- area(h: WrappedPath): number;
31
- iter_segments(h: WrappedPath): Array<[number, Point[]]>;
32
- };
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["const/codegenPrimitives.ts"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["CSS_NAMED_COLORS","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],"sourceRoot":"../../../src","sources":["const/colors.ts"],"mappings":";;AAAA,OAAO,MAAMA,gBAA0D,GAAG;EACxEC,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EAC1BC,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EAC7BC,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;EACnBC,UAAU,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EAC3BC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EACtBC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EACtBC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EACvBC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EAChBC,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;EAC/BC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;EACjBC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GA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';
6
- import svg2ttf from 'svg2ttf';
7
- function escapeXml(s) {
8
- return s.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
9
- }
10
-
11
- /**
12
- * Build an SVG font XML string from pre-transformed glyph data.
13
- */
14
- function buildSvgFontXml(opts) {
15
- const {
16
- fontName,
17
- glyphs,
18
- upm,
19
- ascent,
20
- descent
21
- } = opts;
22
- const glyphLines = glyphs.map(g => {
23
- const hex = g.codepoint.toString(16);
24
- const name = `u${hex.padStart(4, '0')}`;
25
- return `<glyph glyph-name="${name}" unicode="&#x${hex};" horiz-adv-x="${g.advanceWidth}" d="${escapeXml(g.d)}"/>`;
26
- });
27
- return `<?xml version="1.0" standalone="no"?>
28
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
29
- <svg xmlns="http://www.w3.org/2000/svg">
30
- <defs>
31
- <font id="${escapeXml(fontName)}" horiz-adv-x="${upm}">
32
- <font-face font-family="${escapeXml(fontName)}" units-per-em="${upm}" ascent="${ascent}" descent="${-Math.abs(descent)}"/>
33
- <missing-glyph horiz-adv-x="0"/>
34
- ${glyphLines.join('\n')}
35
- </font>
36
- </defs>
37
- </svg>`;
38
- }
39
- export function parseCompileTtfFromGlyphsError(err, codepointToIcon) {
40
- const msg = err instanceof Error ? err.message : String(err);
41
- const cpMatch = msg.match(/glyph\s+"u([0-9a-fA-F]+)"/);
42
- if (cpMatch) {
43
- const cp = parseInt(cpMatch[1], 16);
44
- const iconName = codepointToIcon.get(cp);
45
- const detail = iconName ? `icon "${iconName}" (codepoint u${cpMatch[1]})` : `codepoint u${cpMatch[1]}`;
46
- throw new Error(`Font compilation failed for ${detail}: ${msg}`);
47
- }
48
- throw err;
49
- }
50
-
51
- /**
52
- * Compile a TTF font from pre-transformed glyph data.
53
- * Builds SVG font XML directly (no intermediate files), then converts via svg2ttf.
54
- */
55
- export async function compileTtfFromGlyphs(opts) {
56
- const {
57
- glyphs,
58
- outTtfPath,
59
- fontName,
60
- upm,
61
- ascent,
62
- descent
63
- } = opts;
64
- const lineGap = opts.lineGap ?? 0;
65
- if (glyphs.length === 0) throw new Error('No glyphs to compile');
66
- const svgFontString = buildSvgFontXml({
67
- fontName,
68
- glyphs,
69
- upm,
70
- ascent,
71
- descent
72
- });
73
- const ttfRaw = svg2ttf(svgFontString);
74
- const rawBuf = Buffer.from(ttfRaw.buffer);
75
- const fixedBuf = forceTtfMetrics(rawBuf, upm, ascent, descent, lineGap);
76
- fs.mkdirSync(path.dirname(outTtfPath), {
77
- recursive: true
78
- });
79
- fs.writeFileSync(outTtfPath, fixedBuf);
80
- }
81
- //# sourceMappingURL=compile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["fs","path","forceTtfMetrics","svg2ttf","escapeXml","s","replace","buildSvgFontXml","opts","fontName","glyphs","upm","ascent","descent","glyphLines","map","g","hex","codepoint","toString","name","padStart","advanceWidth","d","Math","abs","join","parseCompileTtfFromGlyphsError","err","codepointToIcon","msg","Error","message","String","cpMatch","match","cp","parseInt","iconName","get","detail","compileTtfFromGlyphs","outTtfPath","lineGap","length","svgFontString","ttfRaw","rawBuf","Buffer","from","buffer","fixedBuf","mkdirSync","dirname","recursive","writeFileSync"],"sourceRoot":"../../../../src","sources":["core/font/compile.ts"],"mappings":";;AAAA,OAAOA,EAAE,MAAM,SAAS;AACxB,OAAOC,IAAI,MAAM,WAAW;AAE5B,SAASC,eAAe,QAAQ,cAAc;AAC9C,OAAOC,OAAO,MAAM,SAAS;AAS7B,SAASC,SAASA,CAACC,CAAS,EAAU;EACpC,OAAOA,CAAC,CAACC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;AACzD;;AAEA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,IAMxB,EAAU;EACT,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,GAAG;IAAEC,MAAM;IAAEC;EAAQ,CAAC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+BAA+BS,MAAM,KAAKV,GAAG,EAAE,CAAC;EAClE;EACA,MAAMF,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAea,oBAAoBA,CAACjC,IAQ1C,EAAiB;EAChB,MAAM;IAAEE,MAAM;IAAEgC,UAAU;IAAEjC,QAAQ;IAAEE,GAAG;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGL,IAAI;EACnE,MAAMmC,OAAO,GAAGnC,IAAI,CAACmC,OAAO,IAAI,CAAC;EAEjC,IAAIjC,MAAM,CAACkC,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIb,KAAK,CAAC,sBAAsB,CAAC;EAEhE,MAAMc,aAAa,GAAGtC,eAAe,CAAC;IACpCE,QAAQ;IACRC,MAAM;IACNC,GAAG;IACHC,MAAM;IACNC;EACF,CAAC,CAAC;EAEF,MAAMiC,MAAM,GAAG3C,OAAO,CAAC0C,aAAa,CAAC;EACrC,MAAME,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACH,MAAM,CAACI,MAAM,CAAC;EAEzC,MAAMC,QAAQ,GAAGjD,eAAe,CAAC6C,MAAM,EAAEpC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAE8B,OAAO,CAAC;EAEvE3C,EAAE,CAACoD,SAAS,CAACnD,IAAI,CAACoD,OAAO,CAACX,UAAU,CAAC,EAAE;IAAEY,SAAS,EAAE;EAAK,CAAC,CAAC;EAC3DtD,EAAE,CAACuD,aAAa,CAACb,UAAU,EAAES,QAAQ,CAAC;AACxC","ignoreList":[]}
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- import { Font } from 'fonteditor-core';
4
- export function forceTtfMetrics(ttfBuffer, upm, ascent, descent, lineGap) {
5
- const font = Font.create(ttfBuffer, {
6
- type: 'ttf',
7
- hinting: false,
8
- compound2simple: false,
9
- combinePath: false
10
- });
11
- const data = font.get();
12
- data.head.unitsPerEm = upm;
13
- data.hhea.ascent = ascent;
14
- data.hhea.descent = -Math.abs(descent);
15
- data.hhea.lineGap = lineGap;
16
- data['OS/2'].usWinAscent = ascent;
17
- data['OS/2'].usWinDescent = Math.abs(descent);
18
- data['OS/2'].sTypoAscender = ascent;
19
- data['OS/2'].sTypoDescender = -Math.abs(descent);
20
- data['OS/2'].sTypoLineGap = lineGap;
21
-
22
- // Set USE_TYPO_METRICS flag (bit 7) in fsSelection.
23
- // This tells renderers to use sTypoAscender/sTypoDescender/sTypoLineGap for
24
- // line height calculations instead of the Win metrics (usWinAscent/usWinDescent).
25
- // Without this flag, Windows and some Android renderers ignore the Typo values
26
- // set above and fall back to Win metrics, causing icons to appear clipped or
27
- // misaligned vertically. The bitwise OR preserves all other existing style flags
28
- // (italic, bold, etc.) while ensuring this bit is always on.
29
- data['OS/2'].fsSelection = (data['OS/2'].fsSelection || 0) | 1 << 7;
30
- font.set(data);
31
- const out = font.write({
32
- type: 'ttf',
33
- hinting: false
34
- });
35
- return Buffer.from(out);
36
- }
37
- //# sourceMappingURL=metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Font","forceTtfMetrics","ttfBuffer","upm","ascent","descent","lineGap","font","create","type","hinting","compound2simple","combinePath","data","get","head","unitsPerEm","hhea","Math","abs","usWinAscent","usWinDescent","sTypoAscender","sTypoDescender","sTypoLineGap","fsSelection","set","out","write","Buffer","from"],"sourceRoot":"../../../../src","sources":["core/font/metrics.ts"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,iBAAiB;AAEtC,OAAO,SAASC,eAAeA,CAC7BC,SAAiB,EACjBC,GAAW,EACXC,MAAc,EACdC,OAAe,EACfC,OAAe,EACP;EACR,MAAMC,IAAI,GAAGP,IAAI,CAACQ,MAAM,CAACN,SAAS,EAAE;IAClCO,IAAI,EAAE,KAAK;IACXC,OAAO,EAAE,KAAK;IACdC,eAAe,EAAE,KAAK;IACtBC,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,IAAI,GAAGN,IAAI,CAACO,GAAG,CAAC,CAAC;EAEvBD,IAAI,CAACE,IAAI,CAACC,UAAU,GAAGb,GAAG;EAE1BU,IAAI,CAACI,IAAI,CAACb,MAAM,GAAGA,MAAM;EACzBS,IAAI,CAACI,IAAI,CAACZ,OAAO,GAAG,CAACa,IAAI,CAACC,GAAG,CAACd,OAAO,CAAC;EACtCQ,IAAI,CAACI,IAAI,CAACX,OAAO,GAAGA,OAAO;EAE3BO,IAAI,CAAC,MAAM,CAAC,CAACO,WAAW,GAAGhB,MAAM;EACjCS,IAAI,CAAC,MAAM,CAAC,CAACQ,YAAY,GAAGH,IAAI,CAACC,GAAG,CAACd,OAAO,CAAC;EAC7CQ,IAAI,CAAC,MAAM,CAAC,CAACS,aAAa,GAAGlB,MAAM;EACnCS,IAAI,CAAC,MAAM,CAAC,CAACU,cAAc,GAAG,CAACL,IAAI,CAACC,GAAG,CAACd,OAAO,CAAC;EAChDQ,IAAI,CAAC,MAAM,CAAC,CAACW,YAAY,GAAGlB,OAAO;;EAEnC;EACA;EACA;EACA;EACA;EACA;EACA;EACAO,IAAI,CAAC,MAAM,CAAC,CAACY,WAAW,GAAG,CAACZ,IAAI,CAAC,MAAM,CAAC,CAACY,WAAW,IAAI,CAAC,IAAK,CAAC,IAAI,CAAE;EAErElB,IAAI,CAACmB,GAAG,CAACb,IAAI,CAAC;EAEd,MAAMc,GAAG,GAAGpB,IAAI,CAACqB,KAAK,CAAC;IAAEnB,IAAI,EAAE,KAAK;IAAEC,OAAO,EAAE;EAAM,CAAC,CAAgB;EACtE,OAAOmB,MAAM,CAACC,IAAI,CAACH,GAAG,CAAC;AACzB","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- import fs from 'node:fs';
4
- export function ensureEmptyDir(dir) {
5
- if (fs.existsSync(dir)) fs.rmSync(dir, {
6
- recursive: true,
7
- force: true
8
- });
9
- fs.mkdirSync(dir, {
10
- recursive: true
11
- });
12
- }
13
-
14
- /** Create directory if it does not exist; do not remove existing contents (for shared output dirs). */
15
- export function ensureDir(dir) {
16
- fs.mkdirSync(dir, {
17
- recursive: true
18
- });
19
- }
20
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["fs","ensureEmptyDir","dir","existsSync","rmSync","recursive","force","mkdirSync","ensureDir"],"sourceRoot":"../../../../src","sources":["core/pipeline/config.ts"],"mappings":";;AAAA,OAAOA,EAAE,MAAM,SAAS;AAgBxB,OAAO,SAASC,cAAcA,CAACC,GAAW,EAAQ;EAChD,IAAIF,EAAE,CAACG,UAAU,CAACD,GAAG,CAAC,EAAEF,EAAE,CAACI,MAAM,CAACF,GAAG,EAAE;IAAEG,SAAS,EAAE,IAAI;IAAEC,KAAK,EAAE;EAAK,CAAC,CAAC;EACxEN,EAAE,CAACO,SAAS,CAACL,GAAG,EAAE;IAAEG,SAAS,EAAE;EAAK,CAAC,CAAC;AACxC;;AAEA;AACA,OAAO,SAASG,SAASA,CAACN,GAAW,EAAQ;EAC3CF,EAAE,CAACO,SAAS,CAACL,GAAG,EAAE;IAAEG,SAAS,EAAE;EAAK,CAAC,CAAC;AACxC","ignoreList":[]}