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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/LICENSES.md +40 -0
  2. package/README.md +165 -12
  3. package/android/build.gradle +8 -1
  4. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
  5. package/android/src/main/java/com/nanoicons/NanoIconView.kt +103 -19
  6. package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +42 -18
  7. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +72 -11
  8. package/android/src/main/jni/CMakeLists.txt +38 -0
  9. package/android/src/main/jni/RNNanoIconsSpec.h +19 -0
  10. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h +11 -0
  11. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +46 -0
  12. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +41 -0
  13. package/ios/NanoIconFontResolver.h +5 -0
  14. package/ios/NanoIconFontResolver.mm +32 -0
  15. package/ios/NanoIconInlineBaseline.h +4 -0
  16. package/ios/NanoIconInlineBaseline.mm +190 -0
  17. package/ios/NanoIconView.h +1 -4
  18. package/ios/NanoIconView.mm +178 -162
  19. package/ios/NanoIconsFontLoader.mm +10 -32
  20. package/lib/commonjs/cli/build.d.ts +16 -3
  21. package/lib/commonjs/cli/build.js +108 -25
  22. package/lib/commonjs/cli/buildSymbols.d.ts +26 -0
  23. package/lib/commonjs/cli/buildSymbols.js +134 -0
  24. package/lib/commonjs/cli/config.d.ts +4 -2
  25. package/lib/commonjs/cli/config.js +4 -4
  26. package/lib/commonjs/cli/expoConfig.d.ts +6 -2
  27. package/lib/commonjs/cli/expoConfig.js +37 -13
  28. package/lib/commonjs/cli/index.d.ts +7 -5
  29. package/lib/commonjs/cli/index.js +27 -14
  30. package/lib/commonjs/cli/link.d.ts +19 -3
  31. package/lib/commonjs/cli/link.js +311 -45
  32. package/lib/commonjs/cli/logger.js +9 -7
  33. package/lib/commonjs/metro/fontRebuildWatcher.d.ts +62 -0
  34. package/lib/commonjs/metro/fontRebuildWatcher.js +174 -0
  35. package/lib/commonjs/metro/index.d.ts +35 -0
  36. package/lib/commonjs/metro/index.js +92 -0
  37. package/lib/commonjs/metro/symbolRebuildWatcher.d.ts +19 -0
  38. package/lib/commonjs/metro/symbolRebuildWatcher.js +76 -0
  39. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
  40. package/lib/commonjs/plugin/src/buildFonts.js +5 -15
  41. package/lib/commonjs/plugin/src/buildSymbols.d.ts +3 -0
  42. package/lib/commonjs/plugin/src/buildSymbols.js +18 -0
  43. package/lib/commonjs/plugin/src/index.d.ts +2 -2
  44. package/lib/commonjs/plugin/src/index.js +10 -4
  45. package/lib/commonjs/plugin/src/types.d.ts +44 -3
  46. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +8 -0
  47. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +29 -0
  48. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
  49. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
  50. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +8 -0
  51. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +37 -0
  52. package/lib/commonjs/scripts/cli.js +64 -23
  53. package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
  54. package/lib/commonjs/src/core/flatten/arcs.js +136 -0
  55. package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
  56. package/lib/commonjs/src/core/flatten/document.js +164 -0
  57. package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
  58. package/lib/commonjs/src/core/flatten/dom.js +221 -0
  59. package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
  60. package/lib/commonjs/src/core/flatten/element.js +97 -0
  61. package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
  62. package/lib/commonjs/src/core/flatten/geometry.js +85 -0
  63. package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
  64. package/lib/commonjs/src/core/flatten/index.js +11 -0
  65. package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
  66. package/lib/commonjs/src/core/flatten/inherit.js +249 -0
  67. package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
  68. package/lib/commonjs/src/core/flatten/path.js +439 -0
  69. package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
  70. package/lib/commonjs/src/core/flatten/pathops.js +236 -0
  71. package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
  72. package/lib/commonjs/src/core/flatten/shape.js +415 -0
  73. package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
  74. package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
  75. package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
  76. package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
  77. package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
  78. package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
  79. package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
  80. package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
  81. package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
  82. package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
  83. package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
  84. package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
  85. package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
  86. package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
  87. package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
  88. package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
  89. package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
  90. package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
  91. package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
  92. package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
  93. package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
  94. package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
  95. package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
  96. package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
  97. package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
  98. package/lib/commonjs/src/core/flatten/stages.js +40 -0
  99. package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
  100. package/lib/commonjs/src/core/flatten/transform.js +221 -0
  101. package/lib/commonjs/src/core/font/compile.d.ts +2 -1
  102. package/lib/commonjs/src/core/font/compile.js +19 -7
  103. package/lib/commonjs/src/core/font/metrics.js +7 -0
  104. package/lib/commonjs/src/core/font/quadratic.d.ts +2 -0
  105. package/lib/commonjs/src/core/font/quadratic.js +33 -0
  106. package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
  107. package/lib/commonjs/src/core/glyph/merge.js +59 -0
  108. package/lib/commonjs/src/core/glyph/parse.d.ts +27 -0
  109. package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
  110. package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
  111. package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
  112. package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
  113. package/lib/commonjs/src/core/glyph/validate.js +33 -0
  114. package/lib/commonjs/src/core/pathkit/contours.d.ts +75 -0
  115. package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +79 -301
  116. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
  117. package/lib/commonjs/src/core/pathkit/evenodd.js +37 -0
  118. package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
  119. package/lib/commonjs/src/core/pathkit/load.js +26 -0
  120. package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
  121. package/lib/commonjs/src/core/pathkit/types.js +2 -0
  122. package/lib/commonjs/src/core/pathkit/winding.d.ts +4 -0
  123. package/lib/commonjs/src/core/pathkit/winding.js +59 -0
  124. package/lib/commonjs/src/core/pipeline/config.d.ts +2 -0
  125. package/lib/commonjs/src/core/pipeline/config.js +6 -0
  126. package/lib/commonjs/src/core/pipeline/iconPool.d.ts +14 -0
  127. package/lib/commonjs/src/core/pipeline/iconPool.js +109 -0
  128. package/lib/commonjs/src/core/pipeline/index.d.ts +5 -3
  129. package/lib/commonjs/src/core/pipeline/index.js +8 -5
  130. package/lib/commonjs/src/core/pipeline/prepare.d.ts +20 -0
  131. package/lib/commonjs/src/core/pipeline/prepare.js +74 -0
  132. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +25 -0
  133. package/lib/commonjs/src/core/pipeline/prepareIcon.js +81 -0
  134. package/lib/commonjs/src/core/pipeline/prepareSvg.d.ts +6 -0
  135. package/lib/commonjs/src/core/pipeline/prepareSvg.js +11 -0
  136. package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +26 -0
  137. package/lib/commonjs/src/core/pipeline/prepareSymbol.js +79 -0
  138. package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
  139. package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
  140. package/lib/commonjs/src/core/pipeline/preparedSvgCache.d.ts +6 -0
  141. package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +44 -0
  142. package/lib/commonjs/src/core/pipeline/runFontPipeline.d.ts +22 -0
  143. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +111 -0
  144. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +54 -0
  145. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +161 -0
  146. package/lib/commonjs/src/core/symbols/contents.d.ts +2 -0
  147. package/lib/commonjs/src/core/symbols/contents.js +15 -0
  148. package/lib/commonjs/src/core/symbols/knockout.d.ts +3 -0
  149. package/lib/commonjs/src/core/symbols/knockout.js +51 -0
  150. package/lib/commonjs/src/core/symbols/layers.d.ts +36 -0
  151. package/lib/commonjs/src/core/symbols/layers.js +182 -0
  152. package/lib/commonjs/src/core/symbols/template.d.ts +22 -0
  153. package/lib/commonjs/src/core/symbols/template.js +140 -0
  154. package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +11 -0
  155. package/lib/commonjs/src/core/symbols/vectorDrawable.js +66 -0
  156. package/lib/commonjs/src/core/types.d.ts +3 -92
  157. package/lib/commonjs/src/utils/fingerPrint.d.ts +19 -1
  158. package/lib/commonjs/src/utils/fingerPrint.js +29 -3
  159. package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
  160. package/lib/commonjs/src/utils/fontIdentity.js +24 -0
  161. package/lib/commonjs/src/utils/naming.d.ts +10 -0
  162. package/lib/commonjs/src/utils/naming.js +49 -0
  163. package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
  164. package/lib/commonjs/src/utils/packageVersion.js +37 -0
  165. package/lib/commonjs/src/utils/parse.d.ts +0 -1
  166. package/lib/commonjs/src/utils/parse.js +0 -8
  167. package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
  168. package/lib/commonjs/src/utils/svgPatterns.js +46 -0
  169. package/lib/module/const/codegenPrimitives.js +1 -2
  170. package/lib/module/const/colors.js +1 -2
  171. package/lib/module/createNanoIconsSet.js +1 -2
  172. package/lib/module/createNanoIconsSet.native.js +38 -28
  173. package/lib/module/createNanoIconsSet.shared.js +15 -9
  174. package/lib/module/createNanoIconsSet.web.js +22 -8
  175. package/lib/module/devServerFont.js +30 -0
  176. package/lib/module/devServerFont.web.js +25 -0
  177. package/lib/module/fontIntegrity.js +99 -0
  178. package/lib/module/index.js +1 -1
  179. package/lib/module/index.node.js +1 -2
  180. package/lib/module/loadDynamicFont.js +20 -10
  181. package/lib/module/nativeFontLoader.js +3 -0
  182. package/lib/module/nativeFontLoader.web.js +3 -0
  183. package/lib/module/specs/NanoIconViewNativeComponent.ts +9 -6
  184. package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
  185. package/lib/module/symbols/index.android.js +42 -0
  186. package/lib/module/symbols/index.ios.js +35 -0
  187. package/lib/module/symbols/index.js +35 -0
  188. package/lib/module/symbols/index.native.js +12 -0
  189. package/lib/module/symbols/types.js +1 -0
  190. package/lib/module/types.js +1 -2
  191. package/lib/module/utils/fingerPrint.js +20 -5
  192. package/lib/module/utils/fontIdentity.js +20 -0
  193. package/lib/module/utils/glyphRuntime.js +36 -3
  194. package/lib/module/utils/naming.js +46 -0
  195. package/lib/module/utils/packageVersion.js +29 -0
  196. package/lib/module/utils/parse.js +1 -9
  197. package/lib/module/utils/runtimeLog.js +12 -0
  198. package/lib/module/utils/shallowEqualColor.js +1 -2
  199. package/lib/module/utils/svgPatterns.js +49 -0
  200. package/lib/module/utils/validateLayerColor.js +24 -0
  201. package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
  202. package/lib/typescript/src/core/flatten/document.d.ts +36 -0
  203. package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
  204. package/lib/typescript/src/core/flatten/element.d.ts +13 -0
  205. package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
  206. package/lib/typescript/src/core/flatten/index.d.ts +3 -0
  207. package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
  208. package/lib/typescript/src/core/flatten/path.d.ts +20 -0
  209. package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
  210. package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
  211. package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
  212. package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
  213. package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
  214. package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
  215. package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
  216. package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
  217. package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
  218. package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
  219. package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
  220. package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
  221. package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
  222. package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
  223. package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
  224. package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
  225. package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
  226. package/lib/typescript/src/core/glyph/parse.d.ts +28 -0
  227. package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
  228. package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
  229. package/lib/typescript/src/core/pathkit/contours.d.ts +76 -0
  230. package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
  231. package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
  232. package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
  233. package/lib/typescript/src/core/pathkit/winding.d.ts +5 -0
  234. package/lib/typescript/src/core/symbols/contents.d.ts +3 -0
  235. package/lib/typescript/src/core/symbols/knockout.d.ts +4 -0
  236. package/lib/typescript/src/core/symbols/layers.d.ts +37 -0
  237. package/lib/typescript/src/core/symbols/template.d.ts +23 -0
  238. package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +12 -0
  239. package/lib/typescript/src/core/types.d.ts +3 -92
  240. package/lib/typescript/src/devServerFont.d.ts +4 -0
  241. package/lib/typescript/src/devServerFont.web.d.ts +4 -0
  242. package/lib/typescript/src/fontIntegrity.d.ts +24 -0
  243. package/lib/typescript/src/index.d.ts +1 -0
  244. package/lib/typescript/src/loadDynamicFont.d.ts +1 -0
  245. package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
  246. package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
  247. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +6 -5
  248. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  249. package/lib/typescript/src/symbols/index.android.d.ts +33 -0
  250. package/lib/typescript/src/symbols/index.d.ts +31 -0
  251. package/lib/typescript/src/symbols/index.ios.d.ts +31 -0
  252. package/lib/typescript/src/symbols/index.native.d.ts +8 -0
  253. package/lib/typescript/src/symbols/types.d.ts +24 -0
  254. package/lib/typescript/src/types.d.ts +7 -0
  255. package/lib/typescript/src/utils/fingerPrint.d.ts +19 -1
  256. package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
  257. package/lib/typescript/src/utils/glyphRuntime.d.ts +3 -1
  258. package/lib/typescript/src/utils/naming.d.ts +11 -0
  259. package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
  260. package/lib/typescript/src/utils/parse.d.ts +0 -1
  261. package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
  262. package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
  263. package/lib/typescript/src/utils/validateLayerColor.d.ts +3 -0
  264. package/metro.js +1 -0
  265. package/package.json +37 -11
  266. package/react-native-nano-icons.podspec +4 -1
  267. package/react-native.config.js +10 -0
  268. package/src/specs/NanoIconViewNativeComponent.ts +9 -6
  269. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  270. package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
  271. package/lib/commonjs/src/core/pipeline/managers.js +0 -104
  272. package/lib/commonjs/src/core/pipeline/run.d.ts +0 -14
  273. package/lib/commonjs/src/core/pipeline/run.js +0 -189
  274. package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
  275. package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
  276. package/lib/module/const/codegenPrimitives.js.map +0 -1
  277. package/lib/module/const/colors.js.map +0 -1
  278. package/lib/module/core/font/compile.js +0 -81
  279. package/lib/module/core/font/compile.js.map +0 -1
  280. package/lib/module/core/font/metrics.js +0 -37
  281. package/lib/module/core/font/metrics.js.map +0 -1
  282. package/lib/module/core/pipeline/config.js +0 -20
  283. package/lib/module/core/pipeline/config.js.map +0 -1
  284. package/lib/module/core/pipeline/index.js +0 -5
  285. package/lib/module/core/pipeline/index.js.map +0 -1
  286. package/lib/module/core/pipeline/managers.js +0 -94
  287. package/lib/module/core/pipeline/managers.js.map +0 -1
  288. package/lib/module/core/pipeline/run.js +0 -204
  289. package/lib/module/core/pipeline/run.js.map +0 -1
  290. package/lib/module/core/shims/pathops.py +0 -181
  291. package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  292. package/lib/module/core/svg/layers.js +0 -85
  293. package/lib/module/core/svg/layers.js.map +0 -1
  294. package/lib/module/core/svg/svg_dom.js +0 -170
  295. package/lib/module/core/svg/svg_dom.js.map +0 -1
  296. package/lib/module/core/svg/svg_pathops.js +0 -750
  297. package/lib/module/core/svg/svg_pathops.js.map +0 -1
  298. package/lib/module/core/tsconfig.json +0 -32
  299. package/lib/module/core/types.js +0 -2
  300. package/lib/module/core/types.js.map +0 -1
  301. package/lib/module/createNanoIconsSet.js.map +0 -1
  302. package/lib/module/createNanoIconsSet.native.js.map +0 -1
  303. package/lib/module/createNanoIconsSet.shared.js.map +0 -1
  304. package/lib/module/createNanoIconsSet.web.js.map +0 -1
  305. package/lib/module/index.js.map +0 -1
  306. package/lib/module/index.node.js.map +0 -1
  307. package/lib/module/loadDynamicFont.js.map +0 -1
  308. package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
  309. package/lib/module/types.js.map +0 -1
  310. package/lib/module/utils/fingerPrint.js.map +0 -1
  311. package/lib/module/utils/glyphRuntime.js.map +0 -1
  312. package/lib/module/utils/parse.js.map +0 -1
  313. package/lib/module/utils/shallowEqualColor.js.map +0 -1
  314. package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
  315. package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
  316. package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
  317. package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
  318. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
  319. package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
  320. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
  321. package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
  322. package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
  323. package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
  324. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
  325. package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
  326. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
  327. package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
  328. package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
  329. package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
  330. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
  331. package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
  332. package/lib/typescript/cli/build.d.ts +0 -32
  333. package/lib/typescript/cli/build.d.ts.map +0 -1
  334. package/lib/typescript/cli/link.d.ts +0 -12
  335. package/lib/typescript/cli/link.d.ts.map +0 -1
  336. package/lib/typescript/cli/logger.d.ts +0 -28
  337. package/lib/typescript/cli/logger.d.ts.map +0 -1
  338. package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
  339. package/lib/typescript/src/const/colors.d.ts.map +0 -1
  340. package/lib/typescript/src/core/font/compile.d.ts +0 -21
  341. package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
  342. package/lib/typescript/src/core/font/metrics.d.ts +0 -2
  343. package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
  344. package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
  345. package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
  346. package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
  347. package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
  348. package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
  349. package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
  350. package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
  351. package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
  352. package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
  353. package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
  354. package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
  355. package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
  356. package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
  357. package/lib/typescript/src/core/types.d.ts.map +0 -1
  358. package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
  359. package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
  360. package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
  361. package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
  362. package/lib/typescript/src/index.d.ts.map +0 -1
  363. package/lib/typescript/src/index.node.d.ts.map +0 -1
  364. package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
  365. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
  366. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
  367. package/lib/typescript/src/types.d.ts.map +0 -1
  368. package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
  369. package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
  370. package/lib/typescript/src/utils/parse.d.ts.map +0 -1
  371. package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
  372. package/plugin/src/buildFonts.ts +0 -42
  373. package/plugin/src/index.ts +0 -21
  374. package/plugin/src/types.ts +0 -42
  375. package/plugin/src/withNanoIconsFontLinking.ts +0 -136
  376. package/plugin/tsconfig.json +0 -9
  377. package/scripts/cli.ts +0 -63
  378. package/scripts/tsconfig.json +0 -25
  379. package/src/const/colors.ts +0 -150
  380. package/src/core/font/compile.ts +0 -99
  381. package/src/core/font/metrics.ts +0 -44
  382. package/src/core/pipeline/config.ts +0 -25
  383. package/src/core/pipeline/index.ts +0 -3
  384. package/src/core/pipeline/managers.ts +0 -132
  385. package/src/core/pipeline/run.ts +0 -274
  386. package/src/core/shims/pathops.py +0 -181
  387. package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
  388. package/src/core/svg/layers.ts +0 -110
  389. package/src/core/svg/svg_dom.ts +0 -194
  390. package/src/core/svg/svg_pathops.ts +0 -1040
  391. package/src/core/tsconfig.json +0 -32
  392. package/src/core/types.ts +0 -157
  393. package/src/createNanoIconsSet.native.tsx +0 -192
  394. package/src/createNanoIconsSet.shared.tsx +0 -174
  395. package/src/createNanoIconsSet.tsx +0 -20
  396. package/src/createNanoIconsSet.web.tsx +0 -109
  397. package/src/index.node.ts +0 -14
  398. package/src/index.ts +0 -6
  399. package/src/loadDynamicFont.ts +0 -162
  400. package/src/types.ts +0 -31
  401. package/src/utils/fingerPrint.ts +0 -20
  402. package/src/utils/glyphRuntime.ts +0 -46
  403. package/src/utils/parse.ts +0 -67
  404. package/src/utils/shallowEqualColor.ts +0 -17
@@ -1,4 +1,4 @@
1
- import type { PathKitModule } from '../types.js';
1
+ import type { PathKitModule } from '../pathkit/types';
2
2
  export declare function computePlacement(opts: {
3
3
  upm: number;
4
4
  safeZone: number;
@@ -11,18 +11,6 @@ export declare function computePlacement(opts: {
11
11
  yOff: number;
12
12
  adv: number;
13
13
  };
14
- export declare function writeLayerSvg(opts: {
15
- tempDir: string;
16
- upm: number;
17
- adv: number;
18
- vx: number;
19
- vy: number;
20
- scale: number;
21
- xOff: number;
22
- yOff: number;
23
- d: string;
24
- codepoint: number;
25
- }): Promise<void>;
26
14
  /**
27
15
  * Transform an SVG path `d` string from source SVG coordinates into font
28
16
  * glyph coordinates (Y-up, with placement scaling and centering applied).
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.computePlacement = computePlacement;
7
- exports.writeLayerSvg = writeLayerSvg;
8
4
  exports.transformPathForFont = transformPathForFont;
9
- const promises_1 = __importDefault(require("node:fs/promises"));
10
- const node_path_1 = __importDefault(require("node:path"));
11
5
  function roundInt(n) {
12
6
  return Math.round(n);
13
7
  }
@@ -30,17 +24,6 @@ function computePlacement(opts) {
30
24
  const yOff = (opts.upm - scaledH) / 2; // ~= totalPadding
31
25
  return { vx, vy, scale, xOff, yOff, adv };
32
26
  }
33
- async function writeLayerSvg(opts) {
34
- const hex = opts.codepoint.toString(16).padStart(4, '0');
35
- const layerSvg = `
36
- <svg viewBox="0 0 ${opts.adv} ${opts.upm}" xmlns="http://www.w3.org/2000/svg">
37
- <rect width="${opts.adv}" height="${opts.upm}" fill="none" />
38
- <g transform="translate(${opts.xOff}, ${opts.yOff}) scale(${opts.scale}) translate(${-opts.vx}, ${-opts.vy})">
39
- <path d="${opts.d}" fill="black" />
40
- </g>
41
- </svg>`.trim();
42
- await promises_1.default.writeFile(node_path_1.default.join(opts.tempDir, `u${hex}.svg`), layerSvg, 'utf8');
43
- }
44
27
  /**
45
28
  * Transform an SVG path `d` string from source SVG coordinates into font
46
29
  * glyph coordinates (Y-up, with placement scaling and centering applied).
@@ -0,0 +1,8 @@
1
+ export type SvgValidation = {
2
+ valid: true;
3
+ } | {
4
+ valid: false;
5
+ reason: string;
6
+ };
7
+ export declare function validateSvg(content: string): SvgValidation;
8
+ export declare function preprocessSvg(content: string): string;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSvg = validateSvg;
4
+ exports.preprocessSvg = preprocessSvg;
5
+ const svgPatterns_1 = require("../../utils/svgPatterns");
6
+ const dom_1 = require("../flatten/dom");
7
+ function validateSvg(content) {
8
+ if (svgPatterns_1.XML_MASK.test(content)) {
9
+ return { valid: false, reason: '<mask> is not supported yet' };
10
+ }
11
+ if (svgPatterns_1.XML_FILTER.test(content)) {
12
+ return { valid: false, reason: '<filter> is not supported yet' };
13
+ }
14
+ if (svgPatterns_1.XML_IMAGE.test(content)) {
15
+ return {
16
+ valid: false,
17
+ reason: 'embedded raster <image> is not supported yet',
18
+ };
19
+ }
20
+ return { valid: true };
21
+ }
22
+ function stripPxUnits(content) {
23
+ return content
24
+ .replace(svgPatterns_1.PX_ATTRIBUTE_VALUE, '=$1$2$1')
25
+ .replace(svgPatterns_1.PX_STYLE_VALUE, '$1');
26
+ }
27
+ // ensure the svg has a xmlns attribute
28
+ function preprocessSvg(content) {
29
+ const withUnits = stripPxUnits(content);
30
+ if (svgPatterns_1.XML_XMLNS.test(withUnits))
31
+ return withUnits;
32
+ return withUnits.replace(svgPatterns_1.SVG_OPEN_TAG, `<svg xmlns="${dom_1.SVG_NS}"`);
33
+ }
@@ -0,0 +1,75 @@
1
+ import type { Cmd, PathKitModule, Point, VerbMap } from './types';
2
+ export declare function verbMap(PathKit: PathKitModule): VerbMap;
3
+ export declare function fillTypes(PathKit: PathKitModule): {
4
+ EVENODD: number;
5
+ WINDING: number;
6
+ };
7
+ export declare function roundN(x: number, ndigits?: number): number;
8
+ export declare function normPt(p: Point): [number, number];
9
+ export declare function eqPt(a: Point, b: Point): boolean;
10
+ export declare function approxSignedAreaFromContourCmds(contourCmds: readonly Cmd[], VERB: VerbMap, steps?: number): number;
11
+ export declare function splitContours(cmds: readonly Cmd[], VERB: VerbMap): Cmd[][];
12
+ export declare function ensureClosed(contourCmds: readonly Cmd[], VERB: VerbMap): Cmd[];
13
+ export declare function explicitCloseWantedFromCmds(contourCmds: readonly Cmd[] | undefined, VERB: VerbMap): boolean;
14
+ type SegmentL = {
15
+ type: 'L';
16
+ start: Point;
17
+ end: Point;
18
+ synthetic: boolean;
19
+ };
20
+ type SegmentQ = {
21
+ type: 'Q';
22
+ start: Point;
23
+ ctrl: Point;
24
+ end: Point;
25
+ synthetic: boolean;
26
+ };
27
+ type SegmentC = {
28
+ type: 'C';
29
+ start: Point;
30
+ c1: Point;
31
+ c2: Point;
32
+ end: Point;
33
+ synthetic: boolean;
34
+ };
35
+ type Segment = SegmentL | SegmentQ | SegmentC;
36
+ export declare function contourToSegments(contourCmds: readonly Cmd[], VERB: VerbMap): {
37
+ start: Point;
38
+ segs: Segment[];
39
+ };
40
+ export declare function reverseClosedContourKeepStart(contourCmds: readonly Cmd[], explicitCloseWanted: boolean, VERB: VerbMap): Cmd[];
41
+ export declare function rotateClosedContourToStart(contourCmds: readonly Cmd[], desiredStart: Point, explicitCloseWanted: boolean, VERB: VerbMap): Cmd[];
42
+ export declare function mergeMoves(aMoves: readonly Point[] | undefined, bMoves: readonly Point[] | undefined): Point[];
43
+ export declare function bestStartMinYMinX(contourCmds: readonly Cmd[], VERB: VerbMap): Point | null;
44
+ /**
45
+ * Convert contour commands to a polyline by sampling curves.
46
+ * Used for ray-casting containment tests.
47
+ */
48
+ export declare function contourToPolyline(contourCmds: readonly Cmd[], V: VerbMap, steps?: number): Point[];
49
+ /**
50
+ * Ray-casting point-in-polygon test.
51
+ */
52
+ export declare function pointInPolygon(px: number, py: number, poly: Point[]): boolean;
53
+ /**
54
+ * Get a representative point on the contour boundary (midpoint of first segment).
55
+ */
56
+ export declare function getContourSamplePoint(contourCmds: readonly Cmd[], V: VerbMap): Point | null;
57
+ /**
58
+ * Apply containment-based winding fix to contour objects.
59
+ * Even nesting depth = CCW (outer), odd = CW (hole).
60
+ */
61
+ export declare function applyContainmentWinding(contourObjs: Array<{
62
+ cmds: Cmd[];
63
+ explicitCloseWanted: boolean;
64
+ absA: number;
65
+ }>, V: VerbMap): void;
66
+ export type Contour = {
67
+ cmds: Cmd[];
68
+ explicitCloseWanted: boolean;
69
+ absA: number;
70
+ };
71
+ export declare function orientedContours(cmds: readonly Cmd[], V: VerbMap): Contour[];
72
+ export declare function canonicalContourCmds(cmds: readonly Cmd[], recordedMoves: readonly Point[], preferMinYMinXStart: boolean, V: VerbMap): Cmd[];
73
+ export declare function cmdsToPathData(cmds: readonly Cmd[], V: VerbMap): string;
74
+ export declare function contoursArea(cmds: readonly Cmd[], V: VerbMap): number;
75
+ export {};
@@ -1,9 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEvenoddToWinding = convertEvenoddToWinding;
4
- exports.buildPathopsBackend = buildPathopsBackend;
5
- //** */
6
- // ----- numeric helpers -----
3
+ exports.verbMap = verbMap;
4
+ exports.fillTypes = fillTypes;
5
+ exports.roundN = roundN;
6
+ exports.normPt = normPt;
7
+ exports.eqPt = eqPt;
8
+ exports.approxSignedAreaFromContourCmds = approxSignedAreaFromContourCmds;
9
+ exports.splitContours = splitContours;
10
+ exports.ensureClosed = ensureClosed;
11
+ exports.explicitCloseWantedFromCmds = explicitCloseWantedFromCmds;
12
+ exports.contourToSegments = contourToSegments;
13
+ exports.reverseClosedContourKeepStart = reverseClosedContourKeepStart;
14
+ exports.rotateClosedContourToStart = rotateClosedContourToStart;
15
+ exports.mergeMoves = mergeMoves;
16
+ exports.bestStartMinYMinX = bestStartMinYMinX;
17
+ exports.contourToPolyline = contourToPolyline;
18
+ exports.pointInPolygon = pointInPolygon;
19
+ exports.getContourSamplePoint = getContourSamplePoint;
20
+ exports.applyContainmentWinding = applyContainmentWinding;
21
+ exports.orientedContours = orientedContours;
22
+ exports.canonicalContourCmds = canonicalContourCmds;
23
+ exports.cmdsToPathData = cmdsToPathData;
24
+ exports.contoursArea = contoursArea;
25
+ function verbMap(PathKit) {
26
+ return {
27
+ MOVE: PathKit.MOVE_VERB ?? 0,
28
+ LINE: PathKit.LINE_VERB ?? 1,
29
+ QUAD: PathKit.QUAD_VERB ?? 2,
30
+ CONIC: PathKit.CONIC_VERB ?? 3,
31
+ CUBIC: PathKit.CUBIC_VERB ?? 4,
32
+ CLOSE: PathKit.CLOSE_VERB ?? 5,
33
+ };
34
+ }
35
+ function fillTypes(PathKit) {
36
+ return {
37
+ EVENODD: PathKit?.FillType?.EVENODD ?? PathKit?.FillType?.EVEN_ODD ?? 1,
38
+ WINDING: PathKit?.FillType?.WINDING ?? PathKit?.FillType?.NONZERO ?? 0,
39
+ };
40
+ }
7
41
  const EPS = 1e-2;
8
42
  // ✅ round-half-to-even (banker's rounding) at ndigits
9
43
  function roundN(x, ndigits = 3) {
@@ -300,47 +334,6 @@ function rotateClosedContourToStart(contourCmds, desiredStart, explicitCloseWant
300
334
  applyClosePolicy(rotated, desiredStart, explicitCloseWanted);
301
335
  return segmentsToContourCmds(desiredStart, rotated, VERB);
302
336
  }
303
- function cmdsToVerbPoints(cmds, VERB) {
304
- const out = [];
305
- for (const cmd of cmds) {
306
- const v = cmd[0];
307
- if (v === VERB.MOVE)
308
- out.push([0, [[cmd[1], cmd[2]]]]);
309
- else if (v === VERB.LINE)
310
- out.push([1, [[cmd[1], cmd[2]]]]);
311
- else if (v === VERB.QUAD)
312
- out.push([
313
- 2,
314
- [
315
- [cmd[1], cmd[2]],
316
- [cmd[3], cmd[4]],
317
- ],
318
- ]);
319
- else if (v === VERB.CUBIC)
320
- out.push([
321
- 3,
322
- [
323
- [cmd[1], cmd[2]],
324
- [cmd[3], cmd[4]],
325
- [cmd[5], cmd[6]],
326
- ],
327
- ]);
328
- else if (v === VERB.CLOSE)
329
- out.push([4, []]);
330
- else
331
- throw new Error(`Unexpected verb in cmds: ${v}`);
332
- }
333
- return out;
334
- }
335
- function wrapPath(pathkitPath) {
336
- return { p: pathkitPath, meta: { moves: [] } };
337
- }
338
- function cloneWrap(h, PathKit) {
339
- const p2 = PathKit.NewPath(h.p);
340
- const out = wrapPath(p2);
341
- out.meta.moves = h.meta?.moves ? h.meta.moves.map((m) => [m[0], m[1]]) : [];
342
- return out;
343
- }
344
337
  function mergeMoves(aMoves, bMoves) {
345
338
  const out = [];
346
339
  const pushUnique = (pt) => {
@@ -382,19 +375,6 @@ function bestStartMinYMinX(contourCmds, VERB) {
382
375
  }
383
376
  return best;
384
377
  }
385
- // ---------------------------------------------------------------------------
386
- // Containment helpers (module-level for reuse by fixPathWinding)
387
- // ---------------------------------------------------------------------------
388
- function buildVerbMap(PathKit) {
389
- return {
390
- MOVE: PathKit.MOVE_VERB ?? 0,
391
- LINE: PathKit.LINE_VERB ?? 1,
392
- QUAD: PathKit.QUAD_VERB ?? 2,
393
- CONIC: PathKit.CONIC_VERB ?? 3,
394
- CUBIC: PathKit.CUBIC_VERB ?? 4,
395
- CLOSE: PathKit.CLOSE_VERB ?? 5,
396
- };
397
- }
398
378
  /**
399
379
  * Convert contour commands to a polyline by sampling curves.
400
380
  * Used for ray-casting containment tests.
@@ -548,49 +528,48 @@ function applyContainmentWinding(contourObjs, V) {
548
528
  ensureOrient(contourObjs[i], depths[i] % 2 === 0);
549
529
  }
550
530
  }
551
- /**
552
- * Convert a path `d` string with evenodd fill semantics to an equivalent
553
- * path that renders identically under nonzero winding.
554
- *
555
- * Steps:
556
- * 1. Parse via PathKit, set fill type to EVENODD, simplify (resolve topology)
557
- * 2. Split into contours, compute containment depths
558
- * 3. Fix winding: even depth = CCW (outer), odd depth = CW (hole)
559
- * 4. Reconstruct d string
560
- */
561
- function convertEvenoddToWinding(PathKit, d) {
562
- const V = buildVerbMap(PathKit);
563
- // 1. Parse and simplify with EVENODD fill type
564
- const p = PathKit.FromSVGString(d);
565
- if (!p)
566
- return d;
567
- const FILL_EVENODD = PathKit?.FillType?.EVENODD ?? PathKit?.FillType?.EVEN_ODD ?? 1;
568
- p.setFillType(FILL_EVENODD);
569
- p.simplify();
570
- // Get the simplified SVG string and re-parse for command access
571
- const simplified = p.toSVGString();
572
- p.delete?.();
573
- const p2 = PathKit.FromSVGString(simplified);
574
- if (!p2)
575
- return simplified;
576
- const cmds = p2.toCmds();
577
- p2.delete?.();
578
- if (cmds.length === 0)
579
- return simplified;
580
- // 2. Split into contours
581
- const contourObjs = splitContours(cmds, V).map((c) => {
531
+ function orientedContours(cmds, V) {
532
+ const contours = splitContours(cmds, V).map((c) => {
582
533
  const explicitCloseWanted = explicitCloseWantedFromCmds(c, V);
583
534
  const cc = ensureClosed(c, V);
584
535
  const a = approxSignedAreaFromContourCmds(cc, V);
585
536
  return { cmds: cc, absA: Math.abs(a), explicitCloseWanted };
586
537
  });
587
- contourObjs.sort((x, y) => y.absA - x.absA);
588
- // 3. Fix winding via containment analysis
589
- applyContainmentWinding(contourObjs, V);
590
- // 4. Reconstruct d string from fixed commands
591
- const allCmds = contourObjs.flatMap((x) => x.cmds);
538
+ contours.sort((x, y) => y.absA - x.absA);
539
+ applyContainmentWinding(contours, V);
540
+ return contours;
541
+ }
542
+ function canonicalContourCmds(cmds, recordedMoves, preferMinYMinXStart, V) {
543
+ const moves = recordedMoves.map((m) => normPt([m[0], m[1]]));
544
+ const used = new Array(moves.length).fill(false);
545
+ const contours = orientedContours(cmds, V);
546
+ for (const obj of contours) {
547
+ let cc = obj.cmds;
548
+ for (let i = 0; i < moves.length; i++) {
549
+ if (used[i])
550
+ continue;
551
+ const target = moves[i];
552
+ const { segs } = contourToSegments(cc, V);
553
+ const found = segs.some((s) => eqPt(s.start, target) || eqPt(s.end, target));
554
+ if (found) {
555
+ used[i] = true;
556
+ cc = rotateClosedContourToStart(cc, target, obj.explicitCloseWanted, V);
557
+ break;
558
+ }
559
+ }
560
+ if (preferMinYMinXStart) {
561
+ const best = bestStartMinYMinX(cc, V);
562
+ if (best) {
563
+ cc = rotateClosedContourToStart(cc, best, obj.explicitCloseWanted, V);
564
+ }
565
+ }
566
+ obj.cmds = cc;
567
+ }
568
+ return contours.flatMap((x) => x.cmds);
569
+ }
570
+ function cmdsToPathData(cmds, V) {
592
571
  const parts = [];
593
- for (const cmd of allCmds) {
572
+ for (const cmd of cmds) {
594
573
  const v = cmd[0];
595
574
  if (v === V.MOVE)
596
575
  parts.push(`M${roundN(cmd[1])} ${roundN(cmd[2])}`);
@@ -605,211 +584,10 @@ function convertEvenoddToWinding(PathKit, d) {
605
584
  }
606
585
  return parts.join(' ');
607
586
  }
608
- // proxy to for picosvg to interatc with pathkit
609
- function buildPathopsBackend(PathKit) {
610
- const VERB = buildVerbMap(PathKit);
611
- const FILL_EVENODD = PathKit?.FillType?.EVENODD ?? PathKit?.FillType?.EVEN_ODD ?? 1;
612
- const FILL_WINDING = PathKit?.FillType?.WINDING ?? PathKit?.FillType?.NONZERO ?? 0;
613
- function cmdsViaSvgRoundtrip(h) {
614
- const svg = h.p.toSVGString();
615
- const p2 = PathKit.FromSVGString(svg);
616
- const cmds = p2 ? p2.toCmds() : [];
617
- if (p2)
618
- p2.delete?.();
619
- return cmds;
620
- }
621
- function normalizeSortRotateContours(cmds, h, preferStrokeCanonical = false) {
622
- const moves = (h.meta?.moves || []).map((m) => normPt([m[0], m[1]]));
623
- const used = new Array(moves.length).fill(false);
624
- // Build contour objects, but DO NOT normalize orientation yet.
625
- const contourObjs = splitContours(cmds, VERB).map((c) => {
626
- const explicitCloseWanted = explicitCloseWantedFromCmds(c, VERB);
627
- const cc = ensureClosed(c, VERB);
628
- const a = approxSignedAreaFromContourCmds(cc, VERB); // signed
629
- return { cmds: cc, absA: Math.abs(a), explicitCloseWanted };
630
- });
631
- // Big-to-small ordering gives deterministic outer→inner ordering.
632
- contourObjs.sort((x, y) => y.absA - x.absA);
633
- // Containment-based winding: compute nesting depth per contour via
634
- // ray-casting point-in-polygon. Even depth = outer (CCW), odd = hole (CW).
635
- applyContainmentWinding(contourObjs, VERB);
636
- // Rotate starts deterministically:
637
- // 1) If we have recorded MOVE points, try to rotate contour to a move point that lies on it.
638
- // 2) Otherwise, rotate to minY/minX point (helps stroke-ish paths)
639
- for (const obj of contourObjs) {
640
- let cc = obj.cmds;
641
- for (let i = 0; i < moves.length; i++) {
642
- if (used[i])
643
- continue;
644
- const target = moves[i];
645
- const { segs } = contourToSegments(cc, VERB);
646
- const found = segs.some((s) => eqPt(s.start, target) || eqPt(s.end, target));
647
- if (found) {
648
- used[i] = true;
649
- cc = rotateClosedContourToStart(cc, target, obj.explicitCloseWanted, VERB);
650
- break;
651
- }
652
- }
653
- // If no move point was used, apply the deterministic start heuristic
654
- if (preferStrokeCanonical) {
655
- const best = bestStartMinYMinX(cc, VERB);
656
- if (best) {
657
- cc = rotateClosedContourToStart(cc, best, obj.explicitCloseWanted, VERB);
658
- }
659
- }
660
- obj.cmds = cc;
661
- }
662
- return contourObjs.flatMap((x) => x.cmds);
587
+ function contoursArea(cmds, V) {
588
+ let total = 0;
589
+ for (const c of splitContours(cmds, V)) {
590
+ total += Math.abs(approxSignedAreaFromContourCmds(ensureClosed(c, V), V));
663
591
  }
664
- return {
665
- create_path(fillTypeInt) {
666
- const p = PathKit.NewPath();
667
- p.setFillType(fillTypeInt === 1 ? FILL_EVENODD : FILL_WINDING);
668
- return wrapPath(p);
669
- },
670
- clone_path(h) {
671
- return cloneWrap(h, PathKit);
672
- },
673
- delete_path(h) {
674
- h?.p?.delete?.();
675
- },
676
- get_fill_type(h) {
677
- const ft = h.p.getFillType?.();
678
- return ft === FILL_EVENODD ? 1 : 0;
679
- },
680
- set_fill_type(h, fillTypeInt) {
681
- h.p.setFillType(fillTypeInt === 1 ? FILL_EVENODD : FILL_WINDING);
682
- return true;
683
- },
684
- move_to(h, x, y) {
685
- h.p.moveTo(x, y);
686
- h.meta.moves.push(normPt([x, y]));
687
- },
688
- line_to(h, x, y) {
689
- h.p.lineTo(x, y);
690
- },
691
- quad_to(h, x1, y1, x2, y2) {
692
- h.p.quadTo(x1, y1, x2, y2);
693
- },
694
- cubic_to(h, x1, y1, x2, y2, x3, y3) {
695
- h.p.cubicTo(x1, y1, x2, y2, x3, y3);
696
- },
697
- close(h) {
698
- h.p.close();
699
- },
700
- simplify(h, fixWinding = false) {
701
- try {
702
- // 1) simplify in place
703
- h.p.simplify();
704
- // 2) normalize representation via SVG roundtrip
705
- const svg = h.p.toSVGString();
706
- const p2 = PathKit.FromSVGString(svg);
707
- if (p2) {
708
- // replace underlying path handle
709
- h.p.delete?.();
710
- h.p = p2;
711
- }
712
- if (fixWinding)
713
- h.p.setFillType(FILL_WINDING);
714
- return true;
715
- }
716
- catch {
717
- return false;
718
- }
719
- },
720
- stroke(h, width, capInt, joinInt, miterLimit, dashArray, dashOffset) {
721
- const Caps = PathKit.StrokeCap ?? {};
722
- const Joins = PathKit.StrokeJoin ?? {};
723
- const cap = capInt === 1
724
- ? (Caps.ROUND ?? 1)
725
- : capInt === 2
726
- ? (Caps.SQUARE ?? 2)
727
- : (Caps.BUTT ?? 0);
728
- const join = joinInt === 1
729
- ? (Joins.ROUND ?? 1)
730
- : joinInt === 2
731
- ? (Joins.BEVEL ?? 2)
732
- : (Joins.MITER ?? 0);
733
- const work = PathKit.NewPath(h.p);
734
- try {
735
- if (Array.isArray(dashArray) &&
736
- dashArray.length === 2 &&
737
- typeof work.dash === 'function') {
738
- work.dash(Number(dashArray[0]), Number(dashArray[1]), dashOffset || 0);
739
- }
740
- let stroked = work.stroke({
741
- width,
742
- cap,
743
- join,
744
- miter_limit: miterLimit,
745
- });
746
- if (!stroked || typeof stroked.toCmds !== 'function')
747
- stroked = work;
748
- if (stroked !== work)
749
- work.delete?.();
750
- const wrapped = wrapPath(stroked);
751
- wrapped.meta.moves = [];
752
- return wrapped;
753
- }
754
- catch {
755
- const wrapped = wrapPath(work);
756
- wrapped.meta.moves = [];
757
- return wrapped;
758
- }
759
- },
760
- convert_conics_to_quads(_h, _tol) {
761
- // intentionally no-op
762
- },
763
- transform(h, a, b, c, d, e, f) {
764
- const p = PathKit.NewPath(h.p);
765
- p.transform(a, c, e, b, d, f, 0, 0, 1);
766
- const wrapped = wrapPath(p);
767
- wrapped.meta.moves = (h.meta?.moves || []).map(([x, y]) => normPt([a * x + c * y + e, b * x + d * y + f]));
768
- return wrapped;
769
- },
770
- op(aHandle, bHandle, opInt) {
771
- try {
772
- const Ops = PathKit.PathOp ?? {};
773
- const op = opInt === 1
774
- ? (Ops.INTERSECT ?? 1)
775
- : opInt === 2
776
- ? (Ops.DIFFERENCE ?? 2)
777
- : (Ops.UNION ?? 0);
778
- const out = PathKit.MakeFromOp(aHandle.p, bHandle.p, op);
779
- if (!out)
780
- return null;
781
- const wrapped = wrapPath(out);
782
- wrapped.meta.moves = mergeMoves(aHandle.meta?.moves, bHandle.meta?.moves);
783
- return wrapped;
784
- }
785
- catch {
786
- return null;
787
- }
788
- },
789
- bounds(h) {
790
- const r = h.p.getBounds();
791
- return [r.fLeft, r.fTop, r.fRight, r.fBottom];
792
- },
793
- area(h) {
794
- try {
795
- const cmds = cmdsViaSvgRoundtrip(h);
796
- const contours = splitContours(cmds, VERB);
797
- let total = 0;
798
- for (const c of contours) {
799
- const cc = ensureClosed(c, VERB);
800
- total += Math.abs(approxSignedAreaFromContourCmds(cc, VERB));
801
- }
802
- return total;
803
- }
804
- catch {
805
- return 0.0;
806
- }
807
- },
808
- iter_segments(h) {
809
- const cmds = cmdsViaSvgRoundtrip(h);
810
- const preferStrokeCanonical = (h.meta?.moves?.length || 0) === 0;
811
- const normalized = normalizeSortRotateContours(cmds, h, preferStrokeCanonical);
812
- return cmdsToVerbPoints(normalized, VERB);
813
- },
814
- };
592
+ return total;
815
593
  }
@@ -0,0 +1,12 @@
1
+ import type { PathKitModule } from './types';
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;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertEvenoddToWinding = convertEvenoddToWinding;
4
+ const contours_1 = require("./contours");
5
+ /**
6
+ * Convert a path `d` string with evenodd fill semantics to an equivalent
7
+ * path that renders identically under nonzero winding.
8
+ *
9
+ * Steps:
10
+ * 1. Parse via PathKit, set fill type to EVENODD, simplify (resolve topology)
11
+ * 2. Split into contours, compute containment depths
12
+ * 3. Fix winding: even depth = CCW (outer), odd depth = CW (hole)
13
+ * 4. Reconstruct d string
14
+ */
15
+ function convertEvenoddToWinding(PathKit, d) {
16
+ const V = (0, contours_1.verbMap)(PathKit);
17
+ // 1. Parse and simplify with EVENODD fill type
18
+ const p = PathKit.FromSVGString(d);
19
+ if (!p)
20
+ return d;
21
+ p.setFillType((0, contours_1.fillTypes)(PathKit).EVENODD);
22
+ p.simplify();
23
+ // Get the simplified SVG string and re-parse for command access
24
+ const simplified = p.toSVGString();
25
+ p.delete?.();
26
+ const p2 = PathKit.FromSVGString(simplified);
27
+ if (!p2)
28
+ return simplified;
29
+ const cmds = p2.toCmds();
30
+ p2.delete?.();
31
+ if (cmds.length === 0)
32
+ return simplified;
33
+ // 2.+3. Split into contours and fix winding via containment analysis
34
+ const allCmds = (0, contours_1.orientedContours)(cmds, V).flatMap((x) => x.cmds);
35
+ // 4. Reconstruct d string from fixed commands
36
+ return (0, contours_1.cmdsToPathData)(allCmds, V);
37
+ }
@@ -0,0 +1,2 @@
1
+ import type { PathKitModule } from './types';
2
+ export declare function loadPathKit(): Promise<PathKitModule>;
@@ -0,0 +1,26 @@
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.loadPathKit = loadPathKit;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const promises_1 = __importDefault(require("node:fs/promises"));
9
+ let instance = null;
10
+ async function loadPathKit() {
11
+ if (instance)
12
+ return instance;
13
+ const PathKitInit = require('pathkit-wasm/bin/pathkit.js');
14
+ const pathkitJsPath = require.resolve('pathkit-wasm/bin/pathkit.js');
15
+ const pathkitBinDir = node_path_1.default.dirname(pathkitJsPath);
16
+ const pathkitWasmPath = node_path_1.default.join(pathkitBinDir, 'pathkit.wasm');
17
+ const wasmBinary = await promises_1.default.readFile(pathkitWasmPath);
18
+ const pkInit = PathKitInit({
19
+ wasmBinary,
20
+ locateFile: (file) => node_path_1.default.join(pathkitBinDir, file),
21
+ });
22
+ instance = await (typeof pkInit?.ready === 'function'
23
+ ? pkInit.ready()
24
+ : pkInit);
25
+ return instance;
26
+ }