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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/LICENSES.md +40 -0
  2. package/README.md +41 -10
  3. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
  4. package/android/src/main/java/com/nanoicons/NanoIconView.kt +50 -15
  5. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +72 -11
  6. package/ios/NanoIconFontResolver.h +5 -0
  7. package/ios/NanoIconFontResolver.mm +32 -0
  8. package/ios/NanoIconView.h +0 -4
  9. package/ios/NanoIconView.mm +62 -57
  10. package/ios/NanoIconsFontLoader.mm +10 -32
  11. package/lib/commonjs/cli/build.d.ts +11 -3
  12. package/lib/commonjs/cli/build.js +86 -25
  13. package/lib/commonjs/cli/config.d.ts +1 -1
  14. package/lib/commonjs/cli/config.js +1 -1
  15. package/lib/commonjs/cli/expoConfig.d.ts +3 -2
  16. package/lib/commonjs/cli/expoConfig.js +22 -9
  17. package/lib/commonjs/cli/index.d.ts +5 -5
  18. package/lib/commonjs/cli/index.js +16 -14
  19. package/lib/commonjs/cli/link.d.ts +4 -3
  20. package/lib/commonjs/cli/link.js +127 -45
  21. package/lib/commonjs/cli/logger.js +9 -7
  22. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
  23. package/lib/commonjs/plugin/src/buildFonts.js +5 -15
  24. package/lib/commonjs/plugin/src/index.d.ts +2 -2
  25. package/lib/commonjs/plugin/src/index.js +2 -2
  26. package/lib/commonjs/plugin/src/types.d.ts +10 -1
  27. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
  28. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
  29. package/lib/commonjs/scripts/cli.js +46 -23
  30. package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
  31. package/lib/commonjs/src/core/flatten/arcs.js +136 -0
  32. package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
  33. package/lib/commonjs/src/core/flatten/document.js +164 -0
  34. package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
  35. package/lib/commonjs/src/core/flatten/dom.js +221 -0
  36. package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
  37. package/lib/commonjs/src/core/flatten/element.js +97 -0
  38. package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
  39. package/lib/commonjs/src/core/flatten/geometry.js +85 -0
  40. package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
  41. package/lib/commonjs/src/core/flatten/index.js +11 -0
  42. package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
  43. package/lib/commonjs/src/core/flatten/inherit.js +249 -0
  44. package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
  45. package/lib/commonjs/src/core/flatten/path.js +439 -0
  46. package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
  47. package/lib/commonjs/src/core/flatten/pathops.js +236 -0
  48. package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
  49. package/lib/commonjs/src/core/flatten/shape.js +415 -0
  50. package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
  51. package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
  52. package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
  53. package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
  54. package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
  55. package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
  56. package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
  57. package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
  58. package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
  59. package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
  60. package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
  61. package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
  62. package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
  63. package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
  64. package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
  65. package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
  66. package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
  67. package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
  68. package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
  69. package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
  70. package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
  71. package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
  72. package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
  73. package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
  74. package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
  75. package/lib/commonjs/src/core/flatten/stages.js +40 -0
  76. package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
  77. package/lib/commonjs/src/core/flatten/transform.js +221 -0
  78. package/lib/commonjs/src/core/font/compile.d.ts +2 -1
  79. package/lib/commonjs/src/core/font/compile.js +21 -7
  80. package/lib/commonjs/src/core/font/metrics.js +7 -0
  81. package/lib/commonjs/src/core/font/quadratic.d.ts +1 -0
  82. package/lib/commonjs/src/core/font/quadratic.js +31 -0
  83. package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
  84. package/lib/commonjs/src/core/glyph/merge.js +57 -0
  85. package/lib/commonjs/src/core/glyph/parse.d.ts +26 -0
  86. package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
  87. package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
  88. package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
  89. package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
  90. package/lib/commonjs/src/core/glyph/validate.js +33 -0
  91. package/lib/commonjs/src/core/pathkit/contours.d.ts +74 -0
  92. package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +72 -312
  93. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
  94. package/lib/commonjs/src/core/pathkit/evenodd.js +51 -0
  95. package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
  96. package/lib/commonjs/src/core/pathkit/load.js +26 -0
  97. package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
  98. package/lib/commonjs/src/core/pathkit/types.js +2 -0
  99. package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
  100. package/lib/commonjs/src/core/pipeline/iconPool.d.ts +3 -0
  101. package/lib/commonjs/src/core/pipeline/iconPool.js +51 -0
  102. package/lib/commonjs/src/core/pipeline/index.d.ts +3 -3
  103. package/lib/commonjs/src/core/pipeline/index.js +6 -5
  104. package/lib/commonjs/src/core/pipeline/prepare.d.ts +19 -0
  105. package/lib/commonjs/src/core/pipeline/prepare.js +56 -0
  106. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +22 -0
  107. package/lib/commonjs/src/core/pipeline/prepareIcon.js +78 -0
  108. package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
  109. package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
  110. package/lib/commonjs/src/core/pipeline/{run.d.ts → runFontPipeline.d.ts} +7 -4
  111. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +109 -0
  112. package/lib/commonjs/src/core/types.d.ts +3 -92
  113. package/lib/commonjs/src/utils/fingerPrint.d.ts +8 -1
  114. package/lib/commonjs/src/utils/fingerPrint.js +8 -1
  115. package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
  116. package/lib/commonjs/src/utils/fontIdentity.js +24 -0
  117. package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
  118. package/lib/commonjs/src/utils/packageVersion.js +37 -0
  119. package/lib/commonjs/src/utils/parse.d.ts +0 -1
  120. package/lib/commonjs/src/utils/parse.js +0 -8
  121. package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
  122. package/lib/commonjs/src/utils/svgPatterns.js +46 -0
  123. package/lib/module/const/codegenPrimitives.js +1 -2
  124. package/lib/module/const/colors.js +1 -2
  125. package/lib/module/createNanoIconsSet.js +1 -2
  126. package/lib/module/createNanoIconsSet.native.js +11 -4
  127. package/lib/module/createNanoIconsSet.shared.js +12 -7
  128. package/lib/module/createNanoIconsSet.web.js +7 -5
  129. package/lib/module/fontIntegrity.js +99 -0
  130. package/lib/module/index.js +1 -1
  131. package/lib/module/index.node.js +1 -2
  132. package/lib/module/loadDynamicFont.js +14 -7
  133. package/lib/module/nativeFontLoader.js +3 -0
  134. package/lib/module/nativeFontLoader.web.js +3 -0
  135. package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
  136. package/lib/module/types.js +1 -2
  137. package/lib/module/utils/fingerPrint.js +3 -3
  138. package/lib/module/utils/fontIdentity.js +20 -0
  139. package/lib/module/utils/glyphRuntime.js +1 -2
  140. package/lib/module/utils/packageVersion.js +29 -0
  141. package/lib/module/utils/parse.js +1 -9
  142. package/lib/module/utils/runtimeLog.js +12 -0
  143. package/lib/module/utils/shallowEqualColor.js +1 -2
  144. package/lib/module/utils/svgPatterns.js +49 -0
  145. package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
  146. package/lib/typescript/src/core/flatten/document.d.ts +36 -0
  147. package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
  148. package/lib/typescript/src/core/flatten/element.d.ts +13 -0
  149. package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
  150. package/lib/typescript/src/core/flatten/index.d.ts +3 -0
  151. package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
  152. package/lib/typescript/src/core/flatten/path.d.ts +20 -0
  153. package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
  154. package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
  155. package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
  156. package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
  157. package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
  158. package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
  159. package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
  160. package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
  161. package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
  162. package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
  163. package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
  164. package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
  165. package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
  166. package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
  167. package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
  168. package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
  169. package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
  170. package/lib/typescript/src/core/glyph/parse.d.ts +27 -0
  171. package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
  172. package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
  173. package/lib/typescript/src/core/pathkit/contours.d.ts +75 -0
  174. package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
  175. package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
  176. package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
  177. package/lib/typescript/src/core/types.d.ts +3 -92
  178. package/lib/typescript/src/fontIntegrity.d.ts +24 -0
  179. package/lib/typescript/src/index.d.ts +1 -0
  180. package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
  181. package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
  182. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  183. package/lib/typescript/src/types.d.ts +5 -0
  184. package/lib/typescript/src/utils/fingerPrint.d.ts +8 -1
  185. package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
  186. package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
  187. package/lib/typescript/src/utils/parse.d.ts +0 -1
  188. package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
  189. package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
  190. package/package.json +13 -11
  191. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  192. package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
  193. package/lib/commonjs/src/core/pipeline/managers.js +0 -104
  194. package/lib/commonjs/src/core/pipeline/run.js +0 -189
  195. package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
  196. package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
  197. package/lib/module/const/codegenPrimitives.js.map +0 -1
  198. package/lib/module/const/colors.js.map +0 -1
  199. package/lib/module/core/font/compile.js +0 -81
  200. package/lib/module/core/font/compile.js.map +0 -1
  201. package/lib/module/core/font/metrics.js +0 -37
  202. package/lib/module/core/font/metrics.js.map +0 -1
  203. package/lib/module/core/pipeline/config.js +0 -20
  204. package/lib/module/core/pipeline/config.js.map +0 -1
  205. package/lib/module/core/pipeline/index.js +0 -5
  206. package/lib/module/core/pipeline/index.js.map +0 -1
  207. package/lib/module/core/pipeline/managers.js +0 -94
  208. package/lib/module/core/pipeline/managers.js.map +0 -1
  209. package/lib/module/core/pipeline/run.js +0 -204
  210. package/lib/module/core/pipeline/run.js.map +0 -1
  211. package/lib/module/core/shims/pathops.py +0 -181
  212. package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  213. package/lib/module/core/svg/layers.js +0 -85
  214. package/lib/module/core/svg/layers.js.map +0 -1
  215. package/lib/module/core/svg/svg_dom.js +0 -170
  216. package/lib/module/core/svg/svg_dom.js.map +0 -1
  217. package/lib/module/core/svg/svg_pathops.js +0 -750
  218. package/lib/module/core/svg/svg_pathops.js.map +0 -1
  219. package/lib/module/core/tsconfig.json +0 -32
  220. package/lib/module/core/types.js +0 -2
  221. package/lib/module/core/types.js.map +0 -1
  222. package/lib/module/createNanoIconsSet.js.map +0 -1
  223. package/lib/module/createNanoIconsSet.native.js.map +0 -1
  224. package/lib/module/createNanoIconsSet.shared.js.map +0 -1
  225. package/lib/module/createNanoIconsSet.web.js.map +0 -1
  226. package/lib/module/index.js.map +0 -1
  227. package/lib/module/index.node.js.map +0 -1
  228. package/lib/module/loadDynamicFont.js.map +0 -1
  229. package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
  230. package/lib/module/types.js.map +0 -1
  231. package/lib/module/utils/fingerPrint.js.map +0 -1
  232. package/lib/module/utils/glyphRuntime.js.map +0 -1
  233. package/lib/module/utils/parse.js.map +0 -1
  234. package/lib/module/utils/shallowEqualColor.js.map +0 -1
  235. package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
  236. package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
  237. package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
  238. package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
  239. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
  240. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
  241. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
  242. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
  243. package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
  244. package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
  245. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
  246. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
  247. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
  248. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
  249. package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
  250. package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
  251. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
  252. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
  253. package/lib/typescript/cli/build.d.ts +0 -32
  254. package/lib/typescript/cli/build.d.ts.map +0 -1
  255. package/lib/typescript/cli/link.d.ts +0 -12
  256. package/lib/typescript/cli/link.d.ts.map +0 -1
  257. package/lib/typescript/cli/logger.d.ts +0 -28
  258. package/lib/typescript/cli/logger.d.ts.map +0 -1
  259. package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
  260. package/lib/typescript/src/const/colors.d.ts.map +0 -1
  261. package/lib/typescript/src/core/font/compile.d.ts +0 -21
  262. package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
  263. package/lib/typescript/src/core/font/metrics.d.ts +0 -2
  264. package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
  265. package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
  266. package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
  267. package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
  268. package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
  269. package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
  270. package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
  271. package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
  272. package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
  273. package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
  274. package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
  275. package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
  276. package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
  277. package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
  278. package/lib/typescript/src/core/types.d.ts.map +0 -1
  279. package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
  280. package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
  281. package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
  282. package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
  283. package/lib/typescript/src/index.d.ts.map +0 -1
  284. package/lib/typescript/src/index.node.d.ts.map +0 -1
  285. package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
  286. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
  287. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
  288. package/lib/typescript/src/types.d.ts.map +0 -1
  289. package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
  290. package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
  291. package/lib/typescript/src/utils/parse.d.ts.map +0 -1
  292. package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
  293. package/plugin/src/buildFonts.ts +0 -42
  294. package/plugin/src/index.ts +0 -21
  295. package/plugin/src/types.ts +0 -42
  296. package/plugin/src/withNanoIconsFontLinking.ts +0 -136
  297. package/plugin/tsconfig.json +0 -9
  298. package/scripts/cli.ts +0 -63
  299. package/scripts/tsconfig.json +0 -25
  300. package/src/const/colors.ts +0 -150
  301. package/src/core/font/compile.ts +0 -99
  302. package/src/core/font/metrics.ts +0 -44
  303. package/src/core/pipeline/config.ts +0 -25
  304. package/src/core/pipeline/index.ts +0 -3
  305. package/src/core/pipeline/managers.ts +0 -132
  306. package/src/core/pipeline/run.ts +0 -274
  307. package/src/core/shims/pathops.py +0 -181
  308. package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  309. package/src/core/svg/layers.ts +0 -110
  310. package/src/core/svg/svg_dom.ts +0 -194
  311. package/src/core/svg/svg_pathops.ts +0 -1040
  312. package/src/core/tsconfig.json +0 -32
  313. package/src/core/types.ts +0 -157
  314. package/src/createNanoIconsSet.native.tsx +0 -192
  315. package/src/createNanoIconsSet.shared.tsx +0 -174
  316. package/src/createNanoIconsSet.tsx +0 -20
  317. package/src/createNanoIconsSet.web.tsx +0 -109
  318. package/src/index.node.ts +0 -14
  319. package/src/index.ts +0 -6
  320. package/src/loadDynamicFont.ts +0 -162
  321. package/src/types.ts +0 -31
  322. package/src/utils/fingerPrint.ts +0 -20
  323. package/src/utils/glyphRuntime.ts +0 -46
  324. package/src/utils/parse.ts +0 -67
  325. package/src/utils/shallowEqualColor.ts +0 -17
@@ -1,99 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- import { forceTtfMetrics } from './metrics.js';
5
- import svg2ttf from 'svg2ttf';
6
-
7
- export type FontGlyph = {
8
- codepoint: number;
9
- advanceWidth: number;
10
- /** Path data already in font coordinates (Y-up, placement applied). */
11
- d: string;
12
- };
13
-
14
- function escapeXml(s: string): string {
15
- return s.replace(/&/g, '&').replace(/"/g, '"');
16
- }
17
-
18
- /**
19
- * Build an SVG font XML string from pre-transformed glyph data.
20
- */
21
- function buildSvgFontXml(opts: {
22
- fontName: string;
23
- glyphs: FontGlyph[];
24
- upm: number;
25
- ascent: number;
26
- descent: number;
27
- }): string {
28
- const { fontName, glyphs, upm, ascent, descent } = opts;
29
-
30
- const glyphLines = glyphs.map((g) => {
31
- const hex = g.codepoint.toString(16);
32
- const name = `u${hex.padStart(4, '0')}`;
33
- return `<glyph glyph-name="${name}" unicode="&#x${hex};" horiz-adv-x="${g.advanceWidth}" d="${escapeXml(g.d)}"/>`;
34
- });
35
-
36
- return `<?xml version="1.0" standalone="no"?>
37
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
38
- <svg xmlns="http://www.w3.org/2000/svg">
39
- <defs>
40
- <font id="${escapeXml(fontName)}" horiz-adv-x="${upm}">
41
- <font-face font-family="${escapeXml(fontName)}" units-per-em="${upm}" ascent="${ascent}" descent="${-Math.abs(descent)}"/>
42
- <missing-glyph horiz-adv-x="0"/>
43
- ${glyphLines.join('\n')}
44
- </font>
45
- </defs>
46
- </svg>`;
47
- }
48
-
49
- export function parseCompileTtfFromGlyphsError(
50
- err: unknown,
51
- codepointToIcon: Map<number, string>
52
- ) {
53
- const msg = err instanceof Error ? err.message : String(err);
54
- const cpMatch = msg.match(/glyph\s+"u([0-9a-fA-F]+)"/);
55
- if (cpMatch) {
56
- const cp = parseInt(cpMatch[1]!, 16);
57
- const iconName = codepointToIcon.get(cp);
58
- const detail = iconName
59
- ? `icon "${iconName}" (codepoint u${cpMatch[1]})`
60
- : `codepoint u${cpMatch[1]}`;
61
- throw new Error(`Font compilation failed for ${detail}: ${msg}`);
62
- }
63
- throw err;
64
- }
65
-
66
- /**
67
- * Compile a TTF font from pre-transformed glyph data.
68
- * Builds SVG font XML directly (no intermediate files), then converts via svg2ttf.
69
- */
70
- export async function compileTtfFromGlyphs(opts: {
71
- glyphs: FontGlyph[];
72
- outTtfPath: string;
73
- fontName: string;
74
- upm: number;
75
- ascent: number;
76
- descent: number;
77
- lineGap?: number;
78
- }): Promise<void> {
79
- const { glyphs, outTtfPath, fontName, upm, ascent, descent } = opts;
80
- const lineGap = opts.lineGap ?? 0;
81
-
82
- if (glyphs.length === 0) throw new Error('No glyphs to compile');
83
-
84
- const svgFontString = buildSvgFontXml({
85
- fontName,
86
- glyphs,
87
- upm,
88
- ascent,
89
- descent,
90
- });
91
-
92
- const ttfRaw = svg2ttf(svgFontString);
93
- const rawBuf = Buffer.from(ttfRaw.buffer);
94
-
95
- const fixedBuf = forceTtfMetrics(rawBuf, upm, ascent, descent, lineGap);
96
-
97
- fs.mkdirSync(path.dirname(outTtfPath), { recursive: true });
98
- fs.writeFileSync(outTtfPath, fixedBuf);
99
- }
@@ -1,44 +0,0 @@
1
- import { Font } from 'fonteditor-core';
2
-
3
- export function forceTtfMetrics(
4
- ttfBuffer: Buffer,
5
- upm: number,
6
- ascent: number,
7
- descent: number,
8
- lineGap: number
9
- ): Buffer {
10
- const font = Font.create(ttfBuffer, {
11
- type: 'ttf',
12
- hinting: false,
13
- compound2simple: false,
14
- combinePath: false,
15
- });
16
-
17
- const data = font.get();
18
-
19
- data.head.unitsPerEm = upm;
20
-
21
- data.hhea.ascent = ascent;
22
- data.hhea.descent = -Math.abs(descent);
23
- data.hhea.lineGap = lineGap;
24
-
25
- data['OS/2'].usWinAscent = ascent;
26
- data['OS/2'].usWinDescent = Math.abs(descent);
27
- data['OS/2'].sTypoAscender = ascent;
28
- data['OS/2'].sTypoDescender = -Math.abs(descent);
29
- data['OS/2'].sTypoLineGap = lineGap;
30
-
31
- // Set USE_TYPO_METRICS flag (bit 7) in fsSelection.
32
- // This tells renderers to use sTypoAscender/sTypoDescender/sTypoLineGap for
33
- // line height calculations instead of the Win metrics (usWinAscent/usWinDescent).
34
- // Without this flag, Windows and some Android renderers ignore the Typo values
35
- // set above and fall back to Win metrics, causing icons to appear clipped or
36
- // misaligned vertically. The bitwise OR preserves all other existing style flags
37
- // (italic, bold, etc.) while ensuring this bit is always on.
38
- data['OS/2'].fsSelection = (data['OS/2'].fsSelection || 0) | (1 << 7);
39
-
40
- font.set(data);
41
-
42
- const out = font.write({ type: 'ttf', hinting: false }) as ArrayBuffer;
43
- return Buffer.from(out);
44
- }
@@ -1,25 +0,0 @@
1
- import fs from 'node:fs';
2
-
3
- export type PipelineConfig = {
4
- fontFamily: string;
5
- upm: number;
6
- safeZone: number;
7
- startUnicode: number;
8
- linking: 'static' | 'dynamic';
9
- };
10
-
11
- export type PipelinePaths = {
12
- inputDir: string;
13
- outputDir: string;
14
- tempDir: string;
15
- };
16
-
17
- export function ensureEmptyDir(dir: string): void {
18
- if (fs.existsSync(dir)) fs.rmSync(dir, { recursive: true, force: true });
19
- fs.mkdirSync(dir, { recursive: true });
20
- }
21
-
22
- /** Create directory if it does not exist; do not remove existing contents (for shared output dirs). */
23
- export function ensureDir(dir: string): void {
24
- fs.mkdirSync(dir, { recursive: true });
25
- }
@@ -1,3 +0,0 @@
1
- export { runPipeline, type PipelineResult } from './run.js';
2
- export type { PipelineConfig, PipelinePaths } from './config.js';
3
- export { ensureEmptyDir } from './config.js';
@@ -1,132 +0,0 @@
1
- import { loadPyodide } from 'pyodide';
2
- import path from 'node:path';
3
- import fs from 'node:fs/promises';
4
- import type { PathKitModule, PyodideModule } from '../types.js';
5
- import { buildPathopsBackend } from '../svg/svg_pathops.js';
6
-
7
- /** Package root (where package.json lives). */
8
- function getPackageRoot(): string {
9
- // Compiled to lib/commonjs/src/core/pipeline/ — 5 dirs up is package root.
10
- // Running from source (Jest/ts-node) in src/core/pipeline/ — 3 dirs up is package root.
11
- return __dirname.includes(`${path.sep}lib${path.sep}`)
12
- ? path.resolve(__dirname, '../../../../..')
13
- : path.resolve(__dirname, '../../..');
14
- }
15
-
16
- export class PathKitManager {
17
- private static instance: PathKitModule | null = null;
18
-
19
- static async getInstance(): Promise<PathKitModule> {
20
- if (this.instance) return this.instance;
21
-
22
- const PathKitInit = require('pathkit-wasm/bin/pathkit.js') as (
23
- opts: unknown
24
- ) => any;
25
- const pathkitJsPath =
26
- require.resolve('pathkit-wasm/bin/pathkit.js') as string;
27
- const pathkitBinDir = path.dirname(pathkitJsPath);
28
- const pathkitWasmPath = path.join(pathkitBinDir, 'pathkit.wasm');
29
-
30
- const wasmBinary = await fs.readFile(pathkitWasmPath);
31
-
32
- const pkInit = PathKitInit({
33
- wasmBinary,
34
- locateFile: (file: string) => path.join(pathkitBinDir, file),
35
- });
36
-
37
- const PathKit: PathKitModule = await (typeof pkInit?.ready === 'function'
38
- ? pkInit.ready()
39
- : pkInit);
40
- this.instance = PathKit;
41
- return PathKit;
42
- }
43
- }
44
-
45
- export class PyodideManager {
46
- private static instance: PyodideModule | null = null;
47
-
48
- static async getInstance(): Promise<PyodideModule> {
49
- if (this.instance) return this.instance;
50
-
51
- const pyodideAsmPath = require.resolve('pyodide/pyodide.asm.js') as string;
52
- const pyodideDir = path.dirname(pyodideAsmPath) + path.sep;
53
-
54
- const py = (await loadPyodide({
55
- indexURL: pyodideDir,
56
- })) as unknown as PyodideModule;
57
- py.mountNodeFS('/app', process.cwd());
58
-
59
- const PathKit = await PathKitManager.getInstance();
60
- py.registerJsModule('_pathops_js', buildPathopsBackend(PathKit));
61
-
62
- const pathopsPyPath = path.join(
63
- getPackageRoot(),
64
- 'src',
65
- 'core',
66
- 'shims',
67
- 'pathops.py'
68
- );
69
-
70
- const pathopsPy = await fs.readFile(pathopsPyPath, 'utf8');
71
- py.FS.writeFile('/pathops.py', pathopsPy);
72
-
73
- await py.loadPackage(['micropip', 'lxml'], { messageCallback: () => {} });
74
-
75
- // Resolve local picosvg wheel path for offline-first installation.
76
- const picosvgWhlDir = path.join(getPackageRoot(), 'src', 'core', 'shims');
77
- const picosvgWhl = (await fs.readdir(picosvgWhlDir)).find(
78
- (f) => f.startsWith('picosvg-') && f.endsWith('.whl')
79
- );
80
- const localWhlUrl = picosvgWhl
81
- ? `file://${path.join(picosvgWhlDir, picosvgWhl)}`
82
- : null;
83
-
84
- py.globals.set('_picosvg_local_whl', localWhlUrl);
85
-
86
- await py.runPythonAsync(`
87
- import sys
88
- if "/" not in sys.path:
89
- sys.path.insert(0, "/")
90
-
91
- import micropip
92
-
93
- _whl = _picosvg_local_whl
94
- if _whl:
95
- try:
96
- await micropip.install(_whl, deps=False)
97
- except Exception:
98
- await micropip.install("picosvg", deps=False)
99
- else:
100
- await micropip.install("picosvg", deps=False)
101
-
102
- import pathops
103
- import picosvg
104
- `);
105
-
106
- this.instance = py;
107
- return py;
108
- }
109
-
110
- static async picoFromFile(
111
- hostFilePath: string,
112
- content?: string
113
- ): Promise<string> {
114
- const py = await this.getInstance();
115
- const svgContent = content ?? (await fs.readFile(hostFilePath, 'utf-8'));
116
- py.globals.set('_svg_content', svgContent);
117
- const out = py.runPython(`
118
- from picosvg.svg import SVG
119
- svg = SVG.fromstring(_svg_content)
120
- pico = svg.topicosvg()
121
- pico.tostring(pretty_print=True)
122
- `);
123
- return out;
124
- }
125
- }
126
-
127
- export async function picoFromFile(
128
- hostFilePath: string,
129
- content?: string
130
- ): Promise<string> {
131
- return PyodideManager.picoFromFile(hostFilePath, content);
132
- }
@@ -1,274 +0,0 @@
1
- import fsp from 'node:fs/promises';
2
- import path from 'node:path';
3
-
4
- import {
5
- compileTtfFromGlyphs,
6
- parseCompileTtfFromGlyphsError,
7
- type FontGlyph,
8
- } from '../font/compile.js';
9
- import { picoFromFile, PathKitManager } from './managers.js';
10
-
11
- import {
12
- ensureDir,
13
- type PipelineConfig,
14
- type PipelinePaths,
15
- } from './config.js';
16
- import {
17
- parseFlattenedSvg,
18
- preprocessSvg,
19
- shouldSkipPath,
20
- validateSvg,
21
- extractOriginalEvenoddDs,
22
- restoreOriginalEvenoddDs,
23
- } from '../svg/svg_dom.js';
24
- import { computePlacement, transformPathForFont } from '../svg/layers.js';
25
- import { convertEvenoddToWinding } from '../svg/svg_pathops.js';
26
- import type { GlyphLayer, NanoGlyphMap } from '../types.js';
27
- import type { NanoLogger } from '../types.js';
28
-
29
- export type PipelineResult = {
30
- ttfPath: string;
31
- glyphmapPath: string;
32
- };
33
-
34
- // ---------------------------------------------------------------------------
35
- // Same-color path merging
36
- // ---------------------------------------------------------------------------
37
-
38
- type ParsedPath = {
39
- d: string;
40
- fill: string | null;
41
- fillRule?: 'evenodd';
42
- noMerge?: boolean;
43
- };
44
-
45
- /**
46
- * Concatenate multiple SVG path `d` strings into a single compound path.
47
- * This preserves the exact geometry of each path (no boolean operations)
48
- * while combining them into one glyph. Under nonzero winding, this renders
49
- * identically to drawing each path separately with the same color.
50
- */
51
- function concatPathDs(ds: string[]): string | null {
52
- if (ds.length === 0) return null;
53
- if (ds.length === 1) return ds[0]!;
54
- return ds.join(' ');
55
- }
56
-
57
- /**
58
- * Merge consecutive same-color paths into single compound paths via boolean UNION.
59
- * Preserves z-order: only merges runs of adjacent paths with identical fill color.
60
- */
61
- function mergeSameColorPaths(
62
- paths: ParsedPath[],
63
- logger?: NanoLogger
64
- ): ParsedPath[] {
65
- if (paths.length <= 1) return paths;
66
-
67
- const result: ParsedPath[] = [];
68
- let i = 0;
69
-
70
- while (i < paths.length) {
71
- const fill = paths[i]!.fill;
72
-
73
- // Find consecutive run of same fill that are all mergeable.
74
- // Paths converted from evenodd have compound hole structure and must not
75
- // be merged — their CW hole contours would cancel CCW contours from
76
- // adjacent paths, producing incorrect fill.
77
- let j = i + 1;
78
- if (!paths[i]!.noMerge) {
79
- while (
80
- j < paths.length &&
81
- paths[j]!.fill === fill &&
82
- !paths[j]!.noMerge
83
- ) {
84
- j++;
85
- }
86
- }
87
-
88
- if (j - i === 1) {
89
- result.push(paths[i]!);
90
- } else {
91
- const group = paths.slice(i, j);
92
- const merged = concatPathDs(group.map((p) => p.d));
93
- if (merged) {
94
- logger?.info(
95
- ` ⊕ Merged ${group.length} same-color paths (fill=${fill})`
96
- );
97
- result.push({ d: merged, fill });
98
- } else {
99
- result.push(...group);
100
- }
101
- }
102
- i = j;
103
- }
104
- return result;
105
- }
106
-
107
- // ---------------------------------------------------------------------------
108
- // Pipeline
109
- // ---------------------------------------------------------------------------
110
-
111
- /**
112
- * Run the font pipeline with given config and paths.
113
- * Uses the singleton Pyodide/PathKit instance (initialized on first call).
114
- */
115
- export async function runPipeline(
116
- config: PipelineConfig,
117
- paths: PipelinePaths,
118
- options?: { logger?: NanoLogger; inputHash?: string }
119
- ): Promise<PipelineResult> {
120
- const startTime = Date.now();
121
- const logger = options?.logger;
122
-
123
- logger?.update(`Building "${config.fontFamily}"…`);
124
-
125
- ensureDir(paths.outputDir);
126
-
127
- const files = (await fsp.readdir(paths.inputDir)).filter((f) =>
128
- f.toLowerCase().endsWith('.svg')
129
- );
130
-
131
- const glyphMap: NanoGlyphMap = {
132
- m: {
133
- f: config.fontFamily,
134
- u: config.upm,
135
- z: config.safeZone,
136
- s: config.startUnicode,
137
- ...(config.linking === 'dynamic' ? { l: 'd' as const } : {}),
138
- },
139
- i: {},
140
- };
141
-
142
- let currentUnicode = config.startUnicode;
143
- const codepointToIcon = new Map<number, string>();
144
- const allGlyphs: FontGlyph[] = [];
145
-
146
- const PathKit = await PathKitManager.getInstance();
147
-
148
- for (const file of files) {
149
- const iconName = path.parse(file).name;
150
- const filePath = path.join(paths.inputDir, file);
151
-
152
- logger?.info(`Processing ${file}`);
153
-
154
- const rawContent = await fsp.readFile(filePath, 'utf-8');
155
-
156
- const validation = validateSvg(rawContent);
157
- if (validation.valid === false) {
158
- logger?.warn(
159
- `Skipping "${config.fontFamily}:${file}": ${validation.reason}`
160
- );
161
- continue;
162
- }
163
-
164
- const preprocessed = preprocessSvg(rawContent);
165
-
166
- // Preserve original evenodd `d` strings BEFORE picosvg processes them.
167
- // Picosvg's simplify (via our PathKit shim) can drop contours from
168
- // multi-subpath evenodd paths — we restore the originals after.
169
- const originalEvenoddDs = extractOriginalEvenoddDs(preprocessed);
170
-
171
- const flattenedSvg = await picoFromFile(filePath, preprocessed);
172
- const parsed = parseFlattenedSvg(flattenedSvg, {
173
- onSanitize: (original) => {
174
- logger?.info(
175
- ` ⚠ Sanitized path in "${file}": path was missing initial moveto (prepended M from endpoint)`
176
- );
177
- logger?.info(` Original: ${original.slice(0, 80)}…`);
178
- },
179
- });
180
-
181
- // Restore original evenodd path data (undamaged by picosvg's simplify),
182
- // then convert to nonzero winding with our containment-based algorithm.
183
- // Mark as noMerge — compound paths with holes must stay separate so their
184
- // CW hole contours don't cancel adjacent paths' CCW contours.
185
- if (originalEvenoddDs.length > 0) {
186
- restoreOriginalEvenoddDs(parsed.paths, originalEvenoddDs);
187
- }
188
- for (const p of parsed.paths) {
189
- if (p.fillRule === 'evenodd') {
190
- logger?.info(
191
- ` ↻ Converting evenodd path to nonzero winding in "${file}"`
192
- );
193
- p.d = convertEvenoddToWinding(PathKit, p.d);
194
- delete p.fillRule;
195
- (p as ParsedPath).noMerge = true;
196
- }
197
- }
198
-
199
- // Merge consecutive same-color paths into single compound glyphs
200
- const mergedPaths = mergeSameColorPaths(parsed.paths, logger);
201
-
202
- const { vx, vy, scale, xOff, yOff, adv } = computePlacement({
203
- upm: config.upm,
204
- safeZone: config.safeZone,
205
- viewBox: parsed.viewBox,
206
- });
207
-
208
- const layers: GlyphLayer[] = [];
209
-
210
- for (const p of mergedPaths) {
211
- if (shouldSkipPath(p.d, p.fill)) continue;
212
-
213
- const cp = currentUnicode++;
214
- codepointToIcon.set(cp, iconName);
215
-
216
- const fontD = transformPathForFont(PathKit, p.d, {
217
- vx,
218
- vy,
219
- scale,
220
- xOff,
221
- yOff,
222
- upm: config.upm,
223
- });
224
-
225
- allGlyphs.push({
226
- codepoint: cp,
227
- advanceWidth: adv,
228
- d: fontD,
229
- });
230
-
231
- layers.push([cp, p.fill || 'black']);
232
- }
233
-
234
- if (layers.length > 0) {
235
- glyphMap.i[iconName] = [adv, layers];
236
- }
237
- }
238
-
239
- const glyphmapPath = path.join(
240
- paths.outputDir,
241
- `${config.fontFamily}.glyphmap.json`
242
- );
243
-
244
- if (options?.inputHash) {
245
- glyphMap.m.h = options.inputHash;
246
- }
247
- await fsp.writeFile(glyphmapPath, JSON.stringify(glyphMap), 'utf8');
248
-
249
- logger?.info(`Compiling TTF…`);
250
- const ttfPath = path.join(paths.outputDir, `${config.fontFamily}.ttf`);
251
-
252
- try {
253
- await compileTtfFromGlyphs({
254
- glyphs: allGlyphs,
255
- outTtfPath: ttfPath,
256
- fontName: config.fontFamily,
257
- upm: config.upm,
258
- ascent: config.upm,
259
- descent: 0,
260
- });
261
- } catch (err: unknown) {
262
- parseCompileTtfFromGlyphsError(err, codepointToIcon);
263
- }
264
-
265
- const iconCount = Object.keys(glyphMap.i).length;
266
- const elapsed = Date.now() - startTime;
267
- logger?.succeed(
268
- `Built ${config.fontFamily}.ttf [${iconCount} icon${
269
- iconCount === 1 ? '' : 's'
270
- } in ${elapsed}ms]`
271
- );
272
-
273
- return { ttfPath, glyphmapPath };
274
- }