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,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,74 @@
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 contoursArea(cmds: readonly Cmd[], V: VerbMap): number;
74
+ export {};
@@ -1,9 +1,42 @@
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.contoursArea = contoursArea;
24
+ function verbMap(PathKit) {
25
+ return {
26
+ MOVE: PathKit.MOVE_VERB ?? 0,
27
+ LINE: PathKit.LINE_VERB ?? 1,
28
+ QUAD: PathKit.QUAD_VERB ?? 2,
29
+ CONIC: PathKit.CONIC_VERB ?? 3,
30
+ CUBIC: PathKit.CUBIC_VERB ?? 4,
31
+ CLOSE: PathKit.CLOSE_VERB ?? 5,
32
+ };
33
+ }
34
+ function fillTypes(PathKit) {
35
+ return {
36
+ EVENODD: PathKit?.FillType?.EVENODD ?? PathKit?.FillType?.EVEN_ODD ?? 1,
37
+ WINDING: PathKit?.FillType?.WINDING ?? PathKit?.FillType?.NONZERO ?? 0,
38
+ };
39
+ }
7
40
  const EPS = 1e-2;
8
41
  // ✅ round-half-to-even (banker's rounding) at ndigits
9
42
  function roundN(x, ndigits = 3) {
@@ -300,47 +333,6 @@ function rotateClosedContourToStart(contourCmds, desiredStart, explicitCloseWant
300
333
  applyClosePolicy(rotated, desiredStart, explicitCloseWanted);
301
334
  return segmentsToContourCmds(desiredStart, rotated, VERB);
302
335
  }
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
336
  function mergeMoves(aMoves, bMoves) {
345
337
  const out = [];
346
338
  const pushUnique = (pt) => {
@@ -382,19 +374,6 @@ function bestStartMinYMinX(contourCmds, VERB) {
382
374
  }
383
375
  return best;
384
376
  }
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
377
  /**
399
378
  * Convert contour commands to a polyline by sampling curves.
400
379
  * Used for ray-casting containment tests.
@@ -548,268 +527,49 @@ function applyContainmentWinding(contourObjs, V) {
548
527
  ensureOrient(contourObjs[i], depths[i] % 2 === 0);
549
528
  }
550
529
  }
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) => {
530
+ function orientedContours(cmds, V) {
531
+ const contours = splitContours(cmds, V).map((c) => {
582
532
  const explicitCloseWanted = explicitCloseWantedFromCmds(c, V);
583
533
  const cc = ensureClosed(c, V);
584
534
  const a = approxSignedAreaFromContourCmds(cc, V);
585
535
  return { cmds: cc, absA: Math.abs(a), explicitCloseWanted };
586
536
  });
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);
592
- const parts = [];
593
- for (const cmd of allCmds) {
594
- const v = cmd[0];
595
- if (v === V.MOVE)
596
- parts.push(`M${roundN(cmd[1])} ${roundN(cmd[2])}`);
597
- else if (v === V.LINE)
598
- parts.push(`L${roundN(cmd[1])} ${roundN(cmd[2])}`);
599
- else if (v === V.QUAD)
600
- parts.push(`Q${roundN(cmd[1])} ${roundN(cmd[2])} ${roundN(cmd[3])} ${roundN(cmd[4])}`);
601
- else if (v === V.CUBIC)
602
- parts.push(`C${roundN(cmd[1])} ${roundN(cmd[2])} ${roundN(cmd[3])} ${roundN(cmd[4])} ${roundN(cmd[5])} ${roundN(cmd[6])}`);
603
- else if (v === V.CLOSE)
604
- parts.push('Z');
605
- }
606
- return parts.join(' ');
537
+ contours.sort((x, y) => y.absA - x.absA);
538
+ applyContainmentWinding(contours, V);
539
+ return contours;
607
540
  }
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
- }
541
+ function canonicalContourCmds(cmds, recordedMoves, preferMinYMinXStart, V) {
542
+ const moves = recordedMoves.map((m) => normPt([m[0], m[1]]));
543
+ const used = new Array(moves.length).fill(false);
544
+ const contours = orientedContours(cmds, V);
545
+ for (const obj of contours) {
546
+ let cc = obj.cmds;
547
+ for (let i = 0; i < moves.length; i++) {
548
+ if (used[i])
549
+ continue;
550
+ const target = moves[i];
551
+ const { segs } = contourToSegments(cc, V);
552
+ const found = segs.some((s) => eqPt(s.start, target) || eqPt(s.end, target));
553
+ if (found) {
554
+ used[i] = true;
555
+ cc = rotateClosedContourToStart(cc, target, obj.explicitCloseWanted, V);
556
+ break;
652
557
  }
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
- }
558
+ }
559
+ if (preferMinYMinXStart) {
560
+ const best = bestStartMinYMinX(cc, V);
561
+ if (best) {
562
+ cc = rotateClosedContourToStart(cc, best, obj.explicitCloseWanted, V);
659
563
  }
660
- obj.cmds = cc;
661
564
  }
662
- return contourObjs.flatMap((x) => x.cmds);
565
+ obj.cmds = cc;
663
566
  }
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
- };
567
+ return contours.flatMap((x) => x.cmds);
568
+ }
569
+ function contoursArea(cmds, V) {
570
+ let total = 0;
571
+ for (const c of splitContours(cmds, V)) {
572
+ total += Math.abs(approxSignedAreaFromContourCmds(ensureClosed(c, V), V));
573
+ }
574
+ return total;
815
575
  }
@@ -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,51 @@
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
+ const parts = [];
37
+ for (const cmd of allCmds) {
38
+ const v = cmd[0];
39
+ if (v === V.MOVE)
40
+ parts.push(`M${(0, contours_1.roundN)(cmd[1])} ${(0, contours_1.roundN)(cmd[2])}`);
41
+ else if (v === V.LINE)
42
+ parts.push(`L${(0, contours_1.roundN)(cmd[1])} ${(0, contours_1.roundN)(cmd[2])}`);
43
+ else if (v === V.QUAD)
44
+ parts.push(`Q${(0, contours_1.roundN)(cmd[1])} ${(0, contours_1.roundN)(cmd[2])} ${(0, contours_1.roundN)(cmd[3])} ${(0, contours_1.roundN)(cmd[4])}`);
45
+ else if (v === V.CUBIC)
46
+ parts.push(`C${(0, contours_1.roundN)(cmd[1])} ${(0, contours_1.roundN)(cmd[2])} ${(0, contours_1.roundN)(cmd[3])} ${(0, contours_1.roundN)(cmd[4])} ${(0, contours_1.roundN)(cmd[5])} ${(0, contours_1.roundN)(cmd[6])}`);
47
+ else if (v === V.CLOSE)
48
+ parts.push('Z');
49
+ }
50
+ return parts.join(' ');
51
+ }
@@ -0,0 +1,2 @@
1
+ import type { PathKitModule } from './types';
2
+ export declare function loadPathKit(): Promise<PathKitModule>;