@octane-xplat/nano-icons 0.0.0-stage → 0.15.0

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES.md +31 -0
  3. package/README.md +219 -2
  4. package/bin/nano-icons.mjs +2 -0
  5. package/dist/build/build-BbWkFu_9.js +4308 -0
  6. package/dist/build/cli.js +59 -0
  7. package/dist/build/index.js +2 -0
  8. package/package.json +109 -3
  9. package/src/NanoIcon.macos.tsrx +110 -0
  10. package/src/NanoIcon.tsrx +97 -0
  11. package/src/NanoIcon.web.tsrx +105 -0
  12. package/src/base64.ts +51 -0
  13. package/src/build/cli.ts +94 -0
  14. package/src/build/core/colors.ts +152 -0
  15. package/src/build/core/config.ts +30 -0
  16. package/src/build/core/fingerPrint.ts +68 -0
  17. package/src/build/core/flatten/arcs.ts +187 -0
  18. package/src/build/core/flatten/document.ts +237 -0
  19. package/src/build/core/flatten/dom.ts +268 -0
  20. package/src/build/core/flatten/element.ts +111 -0
  21. package/src/build/core/flatten/geometry.ts +95 -0
  22. package/src/build/core/flatten/index.ts +12 -0
  23. package/src/build/core/flatten/inherit.ts +281 -0
  24. package/src/build/core/flatten/path.ts +554 -0
  25. package/src/build/core/flatten/pathops.ts +294 -0
  26. package/src/build/core/flatten/shape.ts +513 -0
  27. package/src/build/core/flatten/stages/clip-path.ts +44 -0
  28. package/src/build/core/flatten/stages/collapse.ts +119 -0
  29. package/src/build/core/flatten/stages/defs.ts +60 -0
  30. package/src/build/core/flatten/stages/discard.ts +62 -0
  31. package/src/build/core/flatten/stages/fill-rule.ts +8 -0
  32. package/src/build/core/flatten/stages/nested-svg.ts +174 -0
  33. package/src/build/core/flatten/stages/opacity.ts +8 -0
  34. package/src/build/core/flatten/stages/shapes.ts +49 -0
  35. package/src/build/core/flatten/stages/stroke.ts +49 -0
  36. package/src/build/core/flatten/stages/styles.ts +32 -0
  37. package/src/build/core/flatten/stages/use.ts +98 -0
  38. package/src/build/core/flatten/stages/validate.ts +50 -0
  39. package/src/build/core/flatten/stages.ts +56 -0
  40. package/src/build/core/flatten/transform.ts +265 -0
  41. package/src/build/core/font/compile.ts +115 -0
  42. package/src/build/core/font/metrics.ts +56 -0
  43. package/src/build/core/font/quadratic.ts +61 -0
  44. package/src/build/core/fontIdentity.ts +24 -0
  45. package/src/build/core/glyph/merge.ts +74 -0
  46. package/src/build/core/glyph/parse.ts +147 -0
  47. package/src/build/core/glyph/placement.ts +82 -0
  48. package/src/build/core/glyph/validate.ts +57 -0
  49. package/src/build/core/naming.ts +18 -0
  50. package/src/build/core/parse.ts +64 -0
  51. package/src/build/core/pathkit/contours.ts +770 -0
  52. package/src/build/core/pathkit/evenodd.ts +49 -0
  53. package/src/build/core/pathkit/load.ts +34 -0
  54. package/src/build/core/pathkit/types.ts +81 -0
  55. package/src/build/core/pathkit/winding.ts +81 -0
  56. package/src/build/core/prepare.ts +98 -0
  57. package/src/build/core/prepareIcon.ts +115 -0
  58. package/src/build/core/runFontPipeline.ts +190 -0
  59. package/src/build/core/svgPatterns.ts +51 -0
  60. package/src/build/core/types.ts +54 -0
  61. package/src/build/externals.d.ts +17 -0
  62. package/src/build/iconify.ts +52 -0
  63. package/src/build/index.ts +304 -0
  64. package/src/build/module.ts +62 -0
  65. package/src/font.macos.ts +133 -0
  66. package/src/font.ts +137 -0
  67. package/src/font.web.ts +71 -0
  68. package/src/glyphmap.ts +129 -0
  69. package/src/index.macos.ts +31 -0
  70. package/src/index.ts +30 -0
  71. package/src/index.web.ts +31 -0
  72. package/src/props.ts +59 -0
  73. package/src/set.ts +140 -0
  74. package/types/generated/.tsrx-typegen-manifest.json +68 -0
  75. package/types/generated/NanoIcon.d.ts +7 -0
  76. package/types/generated/NanoIcon.macos.d.ts +7 -0
  77. package/types/generated/NanoIcon.web.d.ts +2 -0
  78. package/types/generated/base64.d.ts +4 -0
  79. package/types/generated/build/cli.d.ts +1 -0
  80. package/types/generated/build/core/colors.d.ts +1 -0
  81. package/types/generated/build/core/config.d.ts +11 -0
  82. package/types/generated/build/core/flatten/arcs.d.ts +2 -0
  83. package/types/generated/build/core/flatten/document.d.ts +35 -0
  84. package/types/generated/build/core/flatten/dom.d.ts +24 -0
  85. package/types/generated/build/core/flatten/element.d.ts +12 -0
  86. package/types/generated/build/core/flatten/geometry.d.ts +21 -0
  87. package/types/generated/build/core/flatten/index.d.ts +2 -0
  88. package/types/generated/build/core/flatten/inherit.d.ts +13 -0
  89. package/types/generated/build/core/flatten/path.d.ts +19 -0
  90. package/types/generated/build/core/flatten/pathops.d.ts +14 -0
  91. package/types/generated/build/core/flatten/shape.d.ts +29 -0
  92. package/types/generated/build/core/flatten/stages/clip-path.d.ts +4 -0
  93. package/types/generated/build/core/flatten/stages/collapse.d.ts +2 -0
  94. package/types/generated/build/core/flatten/stages/defs.d.ts +4 -0
  95. package/types/generated/build/core/flatten/stages/discard.d.ts +4 -0
  96. package/types/generated/build/core/flatten/stages/fill-rule.d.ts +2 -0
  97. package/types/generated/build/core/flatten/stages/nested-svg.d.ts +2 -0
  98. package/types/generated/build/core/flatten/stages/opacity.d.ts +2 -0
  99. package/types/generated/build/core/flatten/stages/shapes.d.ts +7 -0
  100. package/types/generated/build/core/flatten/stages/stroke.d.ts +3 -0
  101. package/types/generated/build/core/flatten/stages/styles.d.ts +2 -0
  102. package/types/generated/build/core/flatten/stages/use.d.ts +4 -0
  103. package/types/generated/build/core/flatten/stages/validate.d.ts +2 -0
  104. package/types/generated/build/core/flatten/stages.d.ts +2 -0
  105. package/types/generated/build/core/flatten/transform.d.ts +35 -0
  106. package/types/generated/build/core/font/compile.d.ts +21 -0
  107. package/types/generated/build/core/font/metrics.d.ts +1 -0
  108. package/types/generated/build/core/font/quadratic.d.ts +2 -0
  109. package/types/generated/build/core/fontIdentity.d.ts +4 -0
  110. package/types/generated/build/core/glyph/merge.d.ts +7 -0
  111. package/types/generated/build/core/glyph/parse.d.ts +27 -0
  112. package/types/generated/build/core/glyph/placement.d.ts +28 -0
  113. package/types/generated/build/core/glyph/validate.d.ts +8 -0
  114. package/types/generated/build/core/naming.d.ts +2 -0
  115. package/types/generated/build/core/parse.d.ts +1 -0
  116. package/types/generated/build/core/pathkit/contours.d.ts +75 -0
  117. package/types/generated/build/core/pathkit/evenodd.d.ts +12 -0
  118. package/types/generated/build/core/pathkit/load.d.ts +2 -0
  119. package/types/generated/build/core/pathkit/types.d.ts +69 -0
  120. package/types/generated/build/core/prepare.d.ts +20 -0
  121. package/types/generated/build/core/prepareIcon.d.ts +26 -0
  122. package/types/generated/build/core/runFontPipeline.d.ts +32 -0
  123. package/types/generated/build/core/svgPatterns.d.ts +39 -0
  124. package/types/generated/build/core/types.d.ts +49 -0
  125. package/types/generated/build/externals.d.ts +17 -0
  126. package/types/generated/build/iconify.d.ts +18 -0
  127. package/types/generated/build/index.d.ts +75 -0
  128. package/types/generated/build/module.d.ts +14 -0
  129. package/types/generated/font.d.ts +10 -0
  130. package/types/generated/font.macos.d.ts +9 -0
  131. package/types/generated/font.web.d.ts +8 -0
  132. package/types/generated/glyphmap.d.ts +62 -0
  133. package/types/generated/index.d.ts +21 -0
  134. package/types/generated/index.macos.d.ts +22 -0
  135. package/types/generated/index.web.d.ts +22 -0
  136. package/types/generated/props.d.ts +55 -0
  137. package/types/generated/set.d.ts +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Alec Larson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/LICENSES.md ADDED
@@ -0,0 +1,31 @@
1
+ # Third-Party Notices
2
+
3
+ `@octane-xplat/nano-icons` ports and adapts the font pipeline from
4
+ [react-native-nano-icons](https://github.com/software-mansion-labs/react-native-nano-icons)
5
+ (commit `3ffd367068fc7566b10cced3ea101c16b16acbe6`), © 2026 Software Mansion —
6
+ MIT License. The React Native host-view, Expo/Metro plugin, and worker layer are
7
+ not ported; `src/build/core` carries the pipeline and `src/glyphmap.ts`,
8
+ `src/set.ts` carry the runtime model adapted from it.
9
+
10
+ Upstream third-party notices are kept for the ported `flatten/` tree, which is
11
+ itself a TypeScript port of picosvg (© 2020 Google LLC, Apache-2.0):
12
+
13
+ - picosvg — Apache-2.0 — https://github.com/googlefonts/picosvg
14
+ (attribution for `src/build/core/flatten/`)
15
+ - PathKit / pathkit-wasm — BSD-3-Clause — https://github.com/googlefonts/PathKit
16
+ (ported `src/build/core/pathkit/*` wrappers; `pathkit-wasm` is also a runtime
17
+ dependency of the build pipeline)
18
+
19
+ Build-time dependencies (`@octane-xplat/nano-icons/build`):
20
+
21
+ - `pathkit-wasm` — BSD-3-Clause — https://www.npmjs.com/package/pathkit-wasm
22
+ - `svg2ttf` — MIT — https://www.npmjs.com/package/svg2ttf
23
+ - `fonteditor-core` — MIT — https://github.com/kekee000/fonteditor-core
24
+ - `cubic2quad` — MIT — https://www.npmjs.com/package/cubic2quad
25
+ - `@xmldom/xmldom` — MIT — https://github.com/xmldom/xmldom
26
+
27
+ Full license texts:
28
+
29
+ - MIT License: https://opensource.org/licenses/MIT
30
+ - BSD 3-Clause License: https://opensource.org/licenses/BSD-3-Clause
31
+ - Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0
package/README.md CHANGED
@@ -1,3 +1,220 @@
1
- # Temporary Holding Version
1
+ # @octane-xplat/nano-icons
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Compile icon sets to a real font — one glyph per color layer — and render them on web,
4
+ iOS, Android, and experimental AppKit macOS with stacked font-glyph spans/labels. The
5
+ pipeline and runtime model are adapted from
6
+ [react-native-nano-icons](https://github.com/software-mansion-labs/react-native-nano-icons)
7
+ (MIT, © Software Mansion): a build turns SVG files into a hashed `.ttf` (plus `.woff2` for
8
+ web), a typed glyph map, and a bound icon component — at runtime there is no SVG parsing,
9
+ just text drawing. See [Licenses and upstream credit](#licenses-and-upstream-credit).
10
+
11
+ Reach for this package when a screen repeats icons and the artwork is a static, flat
12
+ shape set — the font wins on repeated-instance cost and multicolor layering. For
13
+ arbitrary SVG fidelity (gradients, filters, `<defs>` paint servers) keep using
14
+ [`@octane-xplat/icons`](../icons).
15
+
16
+ ## Quick start
17
+
18
+ Generate a font set from a directory of SVGs:
19
+
20
+ ```sh
21
+ pnpm add @octane-xplat/nano-icons
22
+
23
+ # writes src/icons-font/MyIcons.ttf/.woff2/.glyphmap.json/MyIcons.ts
24
+ pnpm exec nano-icons build --input assets/icons --out src/icons-font --family MyIcons --web
25
+ ```
26
+
27
+ Every artifact is content-hashed into the family (`MyIcons-<hash>`), so regenerated sets
28
+ never collide with a stale file. The generated `.ts` module registers the set on import —
29
+ drop it into your app and use its bound component or the unbound `NanoIcon`:
30
+
31
+ ```tsx
32
+ import { MyIcons, NanoIcon as MyIcon } from './icons-font/MyIcons'
33
+
34
+ export function NextAction() {
35
+ return (
36
+ <>
37
+ <MyIcon name="arrow-right" size={24} color="#2563eb" label="Next" />
38
+ <MyIcons.Icon name="check" size={20} />
39
+ </>
40
+ )
41
+ }
42
+ ```
43
+
44
+ Or keep using the registry-resolving component — after any `createNanoIconSet` ran,
45
+ `NanoIcon` finds names across registered sets:
46
+
47
+ ```tsx
48
+ import { NanoIcon } from '@octane-xplat/nano-icons'
49
+ import './icons-font/MyIcons' // registers on import
50
+
51
+ export function Row() {
52
+ return <NanoIcon name="bell" size={24} />
53
+ }
54
+ ```
55
+
56
+ ## Wiring the font file per platform
57
+
58
+ `createNanoIconSet(glyphMap, { font })` takes a `NanoFontSource`; the generated module
59
+ fills in the defaults so the common path needs no extra work:
60
+
61
+ | Platform | Source used | What you must do |
62
+ | -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
63
+ | Web | `font.url` (→ `FontFace`) | Nothing if you import the generated `.ts` — the `.woff2` beside it is loaded lazily. |
64
+ | iOS | `font.fileName` | Copy `<family>.ttf` into your app's `app/fonts` (the CLI's `--app-fonts` writes it there). iOS registers it at startup. |
65
+ | Android | `font.fileName` | Same `app/fonts` copy — Android resolves `app/fonts/<family>.ttf`. The TTF must ship with the app; there is no runtime injection hook. |
66
+ | macOS | `font.path` or `font.data` | Register bytes or a file path — `registerNanoIconFont` runs `CTFontManagerCreateFontDescriptorsFromURL` + `registerFontFamily`. |
67
+
68
+ Web apps that already emit their own `@font-face` can omit `font` entirely —
69
+ `registerNanoIconFont` checks `document.fonts` first and resolves `'ready'`.
70
+ `set.ready` is a `Promise<'ready' | 'missing' | 'unavailable'>` you can await (tests) or
71
+ surface in error reporting; a missing font still renders the container so failures stay
72
+ visible without crashing the tree.
73
+
74
+ ## Input sources
75
+
76
+ `buildNanoIconFont` accepts a directory (`inputDir`), explicit `{ name, svg }` inputs, or
77
+ an Iconify collection — names become `<prefix>:<name>`, matching `Icon`/`NanoIcon` naming:
78
+
79
+ ```ts
80
+ import { buildNanoIconFont, iconifyCollectionToSvgs } from '@octane-xplat/nano-icons/build'
81
+ import heroicons from '@iconify-json/heroicons/icons.json' with { type: 'json' }
82
+
83
+ await buildNanoIconFont({
84
+ inputs: iconifyCollectionToSvgs(heroicons),
85
+ outputDir: 'src/icons-font',
86
+ fontFamily: 'HeroIcons',
87
+ web: true,
88
+ })
89
+ ```
90
+
91
+ For several sets or repeatable builds, put `.nanoicons.json` at the package root and run
92
+ `nano-icons build` with no flags:
93
+
94
+ ```json
95
+ {
96
+ "iconSets": [
97
+ {
98
+ "inputDir": "assets/icons",
99
+ "fontFamily": "MyIcons",
100
+ "outputDir": "src/icons-font",
101
+ "appFontsDir": "app/fonts"
102
+ }
103
+ ]
104
+ }
105
+ ```
106
+
107
+ ## Colors and sizing
108
+
109
+ A glyph's layers stack in one layout cell: each entry in
110
+ `name → [advanceWidth, [[codepoint, sourceColor], ...]]` becomes one text element in the
111
+ family, drawn top-to-bottom in source order. `color` tints by `tintMode`:
112
+
113
+ ```tsx
114
+ <MyIcon name="bell" color="#e11d48" /> // tintMode 'currentColor' (default):
115
+ // only currentColor layers tint
116
+ <MyIcon name="bell" color="#e11d48" tintMode="all" /> // every layer tinted
117
+ <MyIcon name="bell" color={['#f59e0b', '#1d4ed8']} // palette applies per
118
+ tintMode="all" /> // tintable-layer position
119
+ ```
120
+
121
+ Without `color`, source fills render as authored; `currentColor` layers fall back to the
122
+ platform text color. `size` sets height; width is `advanceWidth / unitsPerEm × size` (a
123
+ wide icon stays wide). `rotate`, `hFlip`, `vFlip` transform the stacked container, not the
124
+ glyphs — the font is never re-generated for orientation variants.
125
+
126
+ ```tsx
127
+ <NanoIcon name="check" size={20} rotate={1} hFlip label="Done" />
128
+ ```
129
+
130
+ ## Unsupported SVG input
131
+
132
+ Only solid-color painted vector geometry survives font compilation. The build is strict —
133
+ rather than silently rasterizing or dropping artwork it fails or skips with a reason:
134
+
135
+ - **Rejected (build fails, file named):** paint-server fills/strokes (`url(#…)` —
136
+ gradients, patterns), malformed path data.
137
+ - **Skipped (warned):** `<mask>`, `<filter>`, `<image>`, empty or fully transparent
138
+ layers, missing viewBox/geometry.
139
+ - **Flattened in:** transforms and `rotate()`/`scale()`/`translate()`, `<use>`,
140
+ `<symbol>`, clipping, `stroke` → outline conversion, `fill-rule="evenodd"` holes
141
+ (converted to nonzero winding), opacity folded into the layer color.
142
+
143
+ If your set needs gradients or filters, keep those icons in `@octane-xplat/icons` and use
144
+ `Icon` for them — the packages coexist.
145
+
146
+ ## Migration from the SVG adapter
147
+
148
+ The previous `@octane-xplat/nano-icons` was a caching wrapper over SVG rendering. If you
149
+ used `NanoIcon` with `addCollection` names:
150
+
151
+ - Names and props survive. `NanoIcon` still takes `name`, `size`, `color`, `rotate`,
152
+ `hFlip`/`vFlip`, `id`, `className`, `label`, and the per-platform bags — but `name` is
153
+ now resolved against generated font sets, not Iconify collections. Run the build over
154
+ the same SVGs and update names if you change the namespace (Iconify sources keep their
155
+ `prefix:name` shape).
156
+ - `color` now accepts `string | string[]` and there's a new `tintMode`; single-color
157
+ strings tint exactly as before.
158
+ - `prepareNanoIcon`/`materializeNanoIcon`/`PreparedNanoIcon`/`IconSvg` are gone —
159
+ geometry is baked into the font, so there is nothing to cache per-instance. The
160
+ `@octane-xplat/icons` `addCollection`/`resolveIcon` registry is no longer consulted.
161
+ - The TTF/WOFF2 and glyph map are generated assets — commit them like other generated
162
+ sources, and copy the TTF into `app/fonts` for iOS/Android.
163
+
164
+ ## Programmatic API
165
+
166
+ ```ts
167
+ import {
168
+ buildNanoIconFont, // Node: run the pipeline
169
+ iconifyCollectionToSvgs, // Node: Iconify collection → svg inputs
170
+ type NanoIconFontOptions, // inputDir/inputs, outputDir, fontFamily, web, appFontsDir…
171
+ } from '@octane-xplat/nano-icons/build'
172
+ import {
173
+ NanoIcon, // registry-resolving component
174
+ createNanoIconSet, // bind a glyph map (+ font source) to a set
175
+ registerNanoIconFont, // platform registration primitive
176
+ resolveNanoIcon, // name → { set, entry } lookup
177
+ type NanoIconProps,
178
+ NanoIconSet,
179
+ NanoGlyphMap,
180
+ NanoFontSource,
181
+ } from '@octane-xplat/nano-icons'
182
+ ```
183
+
184
+ The `./build` subpath is Node-only and kept out of runtime bundles; the platform entries
185
+ contain no Node code. `NanoIcon`'s props contract is unchanged on the shared surface; the
186
+ platform bags (`ios`, `android`, `macos`, `web`) still reach the underlying host view.
187
+
188
+ ## Verification
189
+
190
+ Package checks:
191
+
192
+ ```sh
193
+ pnpm --filter @octane-xplat/nano-icons build
194
+ pnpm --filter @octane-xplat/nano-icons typecheck
195
+ pnpm --filter @octane-xplat/nano-icons test
196
+ pnpm --filter @octane-xplat/nano-icons pack:check
197
+ ```
198
+
199
+ Maintained probes (nonvisual: font registration, layer structure, sizing, tint):
200
+
201
+ ```sh
202
+ pnpm probe doctor
203
+ pnpm probe run examples/probes/nano-icons.tsrx --target web --deps @octane-xplat/nano-icons
204
+ pnpm probe run examples/probes/nano-icons.tsrx --target ios --device SIMULATOR_UDID --deps @octane-xplat/nano-icons
205
+ pnpm probe run examples/probes/nano-icons.macos.tsrx --target macos --deps @octane-xplat/nano-icons
206
+ ```
207
+
208
+ Host/source assertions are not pixel parity or OS accessibility traversal evidence — run
209
+ the probe on every target you ship.
210
+
211
+ ## Licenses and upstream credit
212
+
213
+ This package is MIT, like the rest of Octane Xplat. The geometry pipeline in
214
+ `src/build/core` and the glyph-map/runtime model are ported or adapted from
215
+ [react-native-nano-icons](https://github.com/software-mansion-labs/react-native-nano-icons)
216
+ @ `3ffd367` — MIT, © Software Mansion. Third-party engine dependencies carry their own
217
+ licenses; see [LICENSES.md](./LICENSES.md) for the full attribution text.
218
+
219
+ Icon sets retain their own licenses exactly as with `@octane-xplat/icons`; check each
220
+ set's `info.json` and license files before bundling.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/build/cli.js'