react-native-nano-icons 1.0.0-beta.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 (129) hide show
  1. package/README.md +124 -2
  2. package/android/build.gradle +8 -1
  3. package/android/src/main/java/com/nanoicons/NanoIconView.kt +53 -4
  4. package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +42 -18
  5. package/android/src/main/jni/CMakeLists.txt +38 -0
  6. package/android/src/main/jni/RNNanoIconsSpec.h +19 -0
  7. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h +11 -0
  8. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +46 -0
  9. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +41 -0
  10. package/ios/NanoIconInlineBaseline.h +4 -0
  11. package/ios/NanoIconInlineBaseline.mm +190 -0
  12. package/ios/NanoIconView.h +1 -0
  13. package/ios/NanoIconView.mm +118 -107
  14. package/lib/commonjs/cli/build.d.ts +5 -0
  15. package/lib/commonjs/cli/build.js +37 -15
  16. package/lib/commonjs/cli/buildSymbols.d.ts +26 -0
  17. package/lib/commonjs/cli/buildSymbols.js +134 -0
  18. package/lib/commonjs/cli/config.d.ts +3 -1
  19. package/lib/commonjs/cli/config.js +3 -3
  20. package/lib/commonjs/cli/expoConfig.d.ts +3 -0
  21. package/lib/commonjs/cli/expoConfig.js +17 -6
  22. package/lib/commonjs/cli/index.d.ts +4 -2
  23. package/lib/commonjs/cli/index.js +12 -1
  24. package/lib/commonjs/cli/link.d.ts +15 -0
  25. package/lib/commonjs/cli/link.js +185 -1
  26. package/lib/commonjs/metro/fontRebuildWatcher.d.ts +62 -0
  27. package/lib/commonjs/metro/fontRebuildWatcher.js +174 -0
  28. package/lib/commonjs/metro/index.d.ts +35 -0
  29. package/lib/commonjs/metro/index.js +92 -0
  30. package/lib/commonjs/metro/symbolRebuildWatcher.d.ts +19 -0
  31. package/lib/commonjs/metro/symbolRebuildWatcher.js +76 -0
  32. package/lib/commonjs/plugin/src/buildSymbols.d.ts +3 -0
  33. package/lib/commonjs/plugin/src/buildSymbols.js +18 -0
  34. package/lib/commonjs/plugin/src/index.d.ts +1 -1
  35. package/lib/commonjs/plugin/src/index.js +9 -3
  36. package/lib/commonjs/plugin/src/types.d.ts +34 -2
  37. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +8 -0
  38. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +29 -0
  39. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +8 -0
  40. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +37 -0
  41. package/lib/commonjs/scripts/cli.js +27 -9
  42. package/lib/commonjs/src/core/font/compile.js +3 -5
  43. package/lib/commonjs/src/core/font/quadratic.d.ts +1 -0
  44. package/lib/commonjs/src/core/font/quadratic.js +2 -0
  45. package/lib/commonjs/src/core/glyph/merge.js +3 -1
  46. package/lib/commonjs/src/core/glyph/parse.d.ts +1 -0
  47. package/lib/commonjs/src/core/pathkit/contours.d.ts +1 -0
  48. package/lib/commonjs/src/core/pathkit/contours.js +18 -0
  49. package/lib/commonjs/src/core/pathkit/evenodd.js +1 -15
  50. package/lib/commonjs/src/core/pathkit/winding.d.ts +4 -0
  51. package/lib/commonjs/src/core/pathkit/winding.js +59 -0
  52. package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
  53. package/lib/commonjs/src/core/pipeline/config.js +6 -0
  54. package/lib/commonjs/src/core/pipeline/iconPool.d.ts +13 -2
  55. package/lib/commonjs/src/core/pipeline/iconPool.js +89 -31
  56. package/lib/commonjs/src/core/pipeline/index.d.ts +2 -0
  57. package/lib/commonjs/src/core/pipeline/index.js +3 -1
  58. package/lib/commonjs/src/core/pipeline/prepare.d.ts +1 -0
  59. package/lib/commonjs/src/core/pipeline/prepare.js +18 -0
  60. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +3 -0
  61. package/lib/commonjs/src/core/pipeline/prepareIcon.js +11 -8
  62. package/lib/commonjs/src/core/pipeline/prepareSvg.d.ts +6 -0
  63. package/lib/commonjs/src/core/pipeline/prepareSvg.js +11 -0
  64. package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +26 -0
  65. package/lib/commonjs/src/core/pipeline/prepareSymbol.js +79 -0
  66. package/lib/commonjs/src/core/pipeline/prepareWorker.js +3 -3
  67. package/lib/commonjs/src/core/pipeline/preparedSvgCache.d.ts +6 -0
  68. package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +44 -0
  69. package/lib/commonjs/src/core/pipeline/runFontPipeline.d.ts +5 -0
  70. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +10 -8
  71. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +54 -0
  72. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +161 -0
  73. package/lib/commonjs/src/core/symbols/contents.d.ts +2 -0
  74. package/lib/commonjs/src/core/symbols/contents.js +15 -0
  75. package/lib/commonjs/src/core/symbols/knockout.d.ts +3 -0
  76. package/lib/commonjs/src/core/symbols/knockout.js +51 -0
  77. package/lib/commonjs/src/core/symbols/layers.d.ts +36 -0
  78. package/lib/commonjs/src/core/symbols/layers.js +182 -0
  79. package/lib/commonjs/src/core/symbols/template.d.ts +22 -0
  80. package/lib/commonjs/src/core/symbols/template.js +140 -0
  81. package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +11 -0
  82. package/lib/commonjs/src/core/symbols/vectorDrawable.js +66 -0
  83. package/lib/commonjs/src/utils/fingerPrint.d.ts +11 -0
  84. package/lib/commonjs/src/utils/fingerPrint.js +28 -9
  85. package/lib/commonjs/src/utils/naming.d.ts +10 -0
  86. package/lib/commonjs/src/utils/naming.js +49 -0
  87. package/lib/module/createNanoIconsSet.native.js +29 -26
  88. package/lib/module/createNanoIconsSet.shared.js +3 -2
  89. package/lib/module/createNanoIconsSet.web.js +17 -5
  90. package/lib/module/devServerFont.js +30 -0
  91. package/lib/module/devServerFont.web.js +25 -0
  92. package/lib/module/loadDynamicFont.js +6 -3
  93. package/lib/module/specs/NanoIconViewNativeComponent.ts +9 -6
  94. package/lib/module/symbols/index.android.js +42 -0
  95. package/lib/module/symbols/index.ios.js +35 -0
  96. package/lib/module/symbols/index.js +35 -0
  97. package/lib/module/symbols/index.native.js +12 -0
  98. package/lib/module/symbols/types.js +1 -0
  99. package/lib/module/utils/fingerPrint.js +18 -3
  100. package/lib/module/utils/glyphRuntime.js +36 -2
  101. package/lib/module/utils/naming.js +46 -0
  102. package/lib/module/utils/validateLayerColor.js +24 -0
  103. package/lib/typescript/src/core/glyph/parse.d.ts +1 -0
  104. package/lib/typescript/src/core/pathkit/contours.d.ts +1 -0
  105. package/lib/typescript/src/core/pathkit/winding.d.ts +5 -0
  106. package/lib/typescript/src/core/symbols/contents.d.ts +3 -0
  107. package/lib/typescript/src/core/symbols/knockout.d.ts +4 -0
  108. package/lib/typescript/src/core/symbols/layers.d.ts +37 -0
  109. package/lib/typescript/src/core/symbols/template.d.ts +23 -0
  110. package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +12 -0
  111. package/lib/typescript/src/devServerFont.d.ts +4 -0
  112. package/lib/typescript/src/devServerFont.web.d.ts +4 -0
  113. package/lib/typescript/src/loadDynamicFont.d.ts +1 -0
  114. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +6 -5
  115. package/lib/typescript/src/symbols/index.android.d.ts +33 -0
  116. package/lib/typescript/src/symbols/index.d.ts +31 -0
  117. package/lib/typescript/src/symbols/index.ios.d.ts +31 -0
  118. package/lib/typescript/src/symbols/index.native.d.ts +8 -0
  119. package/lib/typescript/src/symbols/types.d.ts +24 -0
  120. package/lib/typescript/src/types.d.ts +2 -0
  121. package/lib/typescript/src/utils/fingerPrint.d.ts +11 -0
  122. package/lib/typescript/src/utils/glyphRuntime.d.ts +3 -1
  123. package/lib/typescript/src/utils/naming.d.ts +11 -0
  124. package/lib/typescript/src/utils/validateLayerColor.d.ts +3 -0
  125. package/metro.js +1 -0
  126. package/package.json +26 -2
  127. package/react-native-nano-icons.podspec +4 -1
  128. package/react-native.config.js +10 -0
  129. package/src/specs/NanoIconViewNativeComponent.ts +9 -6
@@ -1,16 +1,19 @@
1
1
  import { codegenNativeComponent } from 'react-native';
2
- import type { ViewProps } from 'react-native';
2
+ import type { ColorValue, ViewProps } from 'react-native';
3
3
  import type { Float, Int32 } from '../const/codegenPrimitives';
4
4
 
5
5
  export interface NativeProps extends ViewProps {
6
6
  fontFamily: string;
7
7
  codepoints: ReadonlyArray<Int32>;
8
- colors: ReadonlyArray<Int32>;
9
- fontSize: Float;
8
+ colors: ReadonlyArray<ColorValue>;
9
+ color?: ColorValue;
10
+ tintLayers: ReadonlyArray<Int32>;
11
+ size: Float;
12
+ allowFontScaling: boolean;
10
13
  advanceWidth: Int32;
11
14
  unitsPerEm: Int32;
12
- iconWidth: Float;
13
- iconHeight: Float;
14
15
  }
15
16
 
16
- export default codegenNativeComponent<NativeProps>('NanoIconView');
17
+ export default codegenNativeComponent<NativeProps>('NanoIconView', {
18
+ interfaceOnly: true,
19
+ });
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ import { toDrawableResourceName, toOriginalDrawableResourceName } from "../utils/naming.js";
4
+
5
+ /**
6
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
7
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
8
+ * filenames (and autocompletes them) with no explicit generic.
9
+ */
10
+
11
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
12
+
13
+ /**
14
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
15
+ *
16
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
17
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
18
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
19
+ * colors — Apple's "multicolor" symbol rendering).
20
+ *
21
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
22
+ * the same pure transform the build uses. Each icon ships two drawables;
23
+ * `renderingMode` picks the solid silhouette the bar tints (`monochrome`) or
24
+ * the untinted drawable that keeps its own colors (`original`, `_original`
25
+ * suffix), forwarded as react-navigation's `tinted`.
26
+ *
27
+ * tabBarIcon: () => nativeNanoSymbol('home')
28
+ * // tints only when unfocused, keeps the icon's own colors while focused
29
+ * tabBarIcon: ({ focused }) =>
30
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
31
+ */
32
+
33
+ export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
34
+ const resourceName = toDrawableResourceName(`${prefix}.${name}`);
35
+ return {
36
+ type: 'image',
37
+ source: {
38
+ uri: renderingMode === 'original' ? toOriginalDrawableResourceName(resourceName) : resourceName
39
+ },
40
+ tinted: renderingMode === 'monochrome'
41
+ };
42
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
5
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
6
+ * filenames (and autocompletes them) with no explicit generic.
7
+ */
8
+
9
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
10
+
11
+ /**
12
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
13
+ *
14
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
15
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
16
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
17
+ * colors — Apple's "multicolor" symbol rendering).
18
+ *
19
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
20
+ * the same pure transform the build uses. `renderingMode` controls whether the
21
+ * bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
22
+ *
23
+ * tabBarIcon: () => nativeNanoSymbol('home')
24
+ * // tints only when unfocused, keeps the icon's own colors while focused
25
+ * tabBarIcon: ({ focused }) =>
26
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
27
+ */
28
+
29
+ export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
30
+ return {
31
+ type: 'sfSymbol',
32
+ name: `${prefix}.${name}`,
33
+ renderingMode
34
+ };
35
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
5
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
6
+ * filenames (and autocompletes them) with no explicit generic.
7
+ */
8
+
9
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
10
+
11
+ /**
12
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
13
+ *
14
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
15
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
16
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
17
+ * colors — Apple's "multicolor" symbol rendering).
18
+ *
19
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
20
+ * the same pure transform the build uses. `renderingMode` controls whether the
21
+ * bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
22
+ *
23
+ * tabBarIcon: () => nativeNanoSymbol('home')
24
+ * // tints only when unfocused, keeps the icon's own colors while focused
25
+ * tabBarIcon: ({ focused }) =>
26
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
27
+ */
28
+
29
+ export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
30
+ return {
31
+ type: 'sfSymbol',
32
+ name: `${prefix}.${name}`,
33
+ renderingMode
34
+ };
35
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ import { nativeNanoSymbol as androidNanoSymbol } from "./index.android.js";
5
+ import { nativeNanoSymbol as iosNanoSymbol } from "./index.ios.js";
6
+
7
+ /**
8
+ * Runtime platform split for React Native. Metro resolves package `exports`
9
+ * targets verbatim — it never expands `.ios`/`.android` for them — so the
10
+ * filename-based split the source uses cannot survive the `exports` map.
11
+ */
12
+ export const nativeNanoSymbol = Platform.OS === 'android' ? androidNanoSymbol : iosNanoSymbol;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -4,14 +4,29 @@ const crypto = require('crypto');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  export function getFingerprintSync(dir, inputs) {
7
+ return fingerprintSvgDirSync(dir, inputs).hash;
8
+ }
9
+ export function fingerprintSvgDirSync(dir, inputs) {
10
+ return hashSvgDir(dir, [inputs.upm, inputs.safeZone, inputs.startUnicode, inputs.version, inputs.toolchain]);
11
+ }
12
+ export function fingerprintSymbolDirSync(dir, inputs) {
13
+ return hashSvgDir(dir, ['symbol', inputs.prefix, inputs.version, inputs.toolchain]);
14
+ }
15
+ function hashSvgDir(dir, settings) {
7
16
  const files = fs.readdirSync(dir).filter(f => f.endsWith('.svg')).sort();
8
17
  const hash = crypto.createHash('sha256');
18
+ const svgHashByFile = new Map();
9
19
  for (const file of files) {
10
20
  const filePath = path.join(dir, file);
21
+ const content = fs.readFileSync(filePath);
11
22
  // Hash both path and content
12
23
  hash.update(file);
13
- hash.update(fs.readFileSync(filePath));
24
+ hash.update(content);
25
+ svgHashByFile.set(file, crypto.createHash('sha256').update(content).digest('hex'));
14
26
  }
15
- hash.update(JSON.stringify([inputs.upm, inputs.safeZone, inputs.startUnicode, inputs.version, inputs.toolchain]));
16
- return hash.digest('hex');
27
+ hash.update(JSON.stringify(settings));
28
+ return {
29
+ hash: hash.digest('hex'),
30
+ svgHashByFile
31
+ };
17
32
  }
@@ -29,8 +29,42 @@ export function createCharCache() {
29
29
  * color wins, else the last supplied palette color spills onto remaining
30
30
  * layers, else the glyph's own source color, else black.
31
31
  */
32
- export function createLayerColorResolver(color) {
32
+
33
+ export function createLayerColorResolver(color, tintMode = 'all', layers = []) {
33
34
  const colorArray = Array.isArray(color) ? color : [color];
34
35
  const lastPaletteColor = colorArray[colorArray.length - 1];
35
- return (index, srcColor) => colorArray[index] ?? lastPaletteColor ?? srcColor ?? 'black';
36
+ const paletteIndexByLayer = tintMode === 'currentColor' ? currentColorPositions(layers) : undefined;
37
+ return (index, srcColor) => {
38
+ const paletteIndex = paletteIndexByLayer ? paletteIndexByLayer[index] ?? -1 : index;
39
+ const paletteColor = paletteIndex < 0 ? undefined : colorArray[paletteIndex] ?? lastPaletteColor;
40
+ return paletteColor ?? srcColor ?? 'black';
41
+ };
42
+ }
43
+ export function tintableLayers(layers, tintMode = 'all') {
44
+ if (tintMode === 'all') return allLayerIndices(layers);
45
+ const positions = currentColorPositions(layers);
46
+ const indices = [];
47
+ for (let i = 0; i < positions.length; i++) {
48
+ if (positions[i] >= 0) indices.push(i);
49
+ }
50
+ return indices;
51
+ }
52
+ const allIndicesByLayers = new WeakMap();
53
+ function allLayerIndices(layers) {
54
+ let indices = allIndicesByLayers.get(layers);
55
+ if (!indices) {
56
+ indices = layers.map((_, i) => i);
57
+ allIndicesByLayers.set(layers, indices);
58
+ }
59
+ return indices;
60
+ }
61
+ const positionsByLayers = new WeakMap();
62
+ function currentColorPositions(layers) {
63
+ let positions = positionsByLayers.get(layers);
64
+ if (!positions) {
65
+ let next = 0;
66
+ positions = layers.map(([, srcColor]) => srcColor === 'currentColor' ? next++ : -1);
67
+ positionsByLayers.set(layers, positions);
68
+ }
69
+ return positions;
36
70
  }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ // Shared regexes + helpers for sanitizing asset/symbol names into valid
4
+ // Android resource ids and TypeScript manifest identifiers.
5
+
6
+ /** Chars illegal in an Android drawable resource name → `_`. */
7
+ const NON_RESOURCE_CHARS = /[^a-z0-9_]+/g;
8
+ /** Leading/trailing underscores to trim. */
9
+ const EDGE_UNDERSCORES = /^_+|_+$/g;
10
+ /** Resource names must start with a lowercase letter. */
11
+ const STARTS_WITH_LOWER = /^[a-z]/;
12
+ /** Word separators in a set name (split → PascalCase parts). */
13
+ const NAME_SEPARATORS = /[^a-zA-Z0-9]+/;
14
+ /** Manifest identifiers must start with a letter. */
15
+ const STARTS_WITH_LETTER = /^[a-zA-Z]/;
16
+
17
+ /** Prefix used when a sanitized name would be empty or start with a non-letter. */
18
+ const RESOURCE_FALLBACK_PREFIX = 'nano_';
19
+
20
+ /**
21
+ * Resource names must match `[a-z][a-z0-9_]*` — no dots/uppercase.
22
+ * `nano.home` → `nano_home`, `nano.person-walking` → `nano_person_walking`.
23
+ */
24
+ export function toDrawableResourceName(assetName) {
25
+ let name = assetName.toLowerCase().replace(NON_RESOURCE_CHARS, '_');
26
+ name = name.replace(EDGE_UNDERSCORES, '');
27
+ if (name === '' || !STARTS_WITH_LOWER.test(name)) {
28
+ name = `${RESOURCE_FALLBACK_PREFIX}${name}`;
29
+ }
30
+ return name;
31
+ }
32
+ const ORIGINAL_DRAWABLE_SUFFIX = '_original';
33
+ export function toOriginalDrawableResourceName(resourceName) {
34
+ return `${resourceName}${ORIGINAL_DRAWABLE_SUFFIX}`;
35
+ }
36
+
37
+ /** "my-tab icons" → "MyTabIcons" — PascalCase base for manifest identifiers. */
38
+ export function manifestBaseName(setName) {
39
+ const pascal = setName.split(NAME_SEPARATORS).filter(Boolean).map(part => part[0].toUpperCase() + part.slice(1)).join('');
40
+ return STARTS_WITH_LETTER.test(pascal) ? pascal : `Set${pascal}`;
41
+ }
42
+
43
+ /** Manifest export name, e.g. `MyTabIconsSymbols` / `MyTabIconsDrawables`. */
44
+ export function manifestExportName(setName, suffix = 'Symbols') {
45
+ return `${manifestBaseName(setName)}${suffix}`;
46
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ import { processColor } from 'react-native';
4
+ import { errorRuntime } from "./runtimeLog.js";
5
+ const validityByString = new Map();
6
+ const reportedInvalid = new Set();
7
+ export function validateLayerColor(value, iconName, layerIndex) {
8
+ if (value === undefined || value === 'currentColor') return 'black';
9
+ if (typeof value !== 'string') return value;
10
+ let valid = validityByString.get(value);
11
+ if (valid === undefined) {
12
+ valid = processColor(value) != null;
13
+ validityByString.set(value, valid);
14
+ }
15
+ if (valid) return value;
16
+ if (__DEV__) {
17
+ const key = `${iconName}\u0000${value}`;
18
+ if (!reportedInvalid.has(key)) {
19
+ reportedInvalid.add(key);
20
+ errorRuntime(`Invalid color "${value}" for icon "${iconName}" (layer ${layerIndex}). Falling back to black.`);
21
+ }
22
+ }
23
+ return 'black';
24
+ }
@@ -4,6 +4,7 @@ export type ParsedPath = {
4
4
  fill: string | null;
5
5
  fillRule?: 'evenodd';
6
6
  noMerge?: boolean;
7
+ knockout?: boolean;
7
8
  };
8
9
  export type ParsedFlatSvg = {
9
10
  viewBox: [number, number, number, number];
@@ -70,6 +70,7 @@ export type Contour = {
70
70
  };
71
71
  export declare function orientedContours(cmds: readonly Cmd[], V: VerbMap): Contour[];
72
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;
73
74
  export declare function contoursArea(cmds: readonly Cmd[], V: VerbMap): number;
74
75
  export {};
75
76
  //# sourceMappingURL=contours.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { PathKitModule, PathKitPath } from './types';
2
+ export declare function orientedPathData(PathKit: PathKitModule, path: PathKitPath): string;
3
+ export declare function canonicalWinding(PathKit: PathKitModule, d: string): string;
4
+ export declare function reversedWinding(PathKit: PathKitModule, d: string): string;
5
+ //# sourceMappingURL=winding.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare function symbolsetContentsJson(svgFilename: string): string;
2
+ export declare function catalogRootContentsJson(): string;
3
+ //# sourceMappingURL=contents.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare const KNOCKOUT_ATTRIBUTE = "data-nano-knockout";
2
+ export declare const KNOCKOUT_MARKER_FILL = "#fe01fe";
3
+ export declare function markKnockoutFills(svg: string): string | null;
4
+ //# sourceMappingURL=knockout.d.ts.map
@@ -0,0 +1,37 @@
1
+ import type { PathKitModule } from '../pathkit/types';
2
+ /**
3
+ * Resolve stacked layers into SF Symbol template layers. Monochrome joins every
4
+ * layer into one nonzero-filled path, multicolor paints each layer on its own:
5
+ * 1. Knockouts: layers annotated with `data-nano-knockout`, or (when nothing is
6
+ * annotated) near-white layers over ink. Their part over ink is emitted with
7
+ * reversed winding, so it cancels the ink beneath it in monochrome while
8
+ * multicolor still paints it in its own fill. Their part over nothing is
9
+ * drawn in both modes.
10
+ * 2. Occlusion: subtract layers above from each layer; ink is never cut by a
11
+ * knockout, so the winding under every knockout is exactly one.
12
+ * In: back→front layers with fills. Out: visible layers in z-order plus the
13
+ * monochrome silhouette.
14
+ */
15
+ export type SymbolLayerInput = {
16
+ d: string;
17
+ fill: string | null;
18
+ knockout?: boolean;
19
+ };
20
+ export type SymbolLayer = {
21
+ d: string;
22
+ fill: string | null;
23
+ };
24
+ export type ResolvedSymbolLayers = {
25
+ layers: SymbolLayer[];
26
+ monochrome: string;
27
+ };
28
+ export declare function isKnockoutFill(fill: string | null): boolean;
29
+ export declare function resolveSymbolLayers(PathKit: PathKitModule, layers: SymbolLayerInput[], options?: {
30
+ onKnockoutLayer?: (index: number) => void;
31
+ }): ResolvedSymbolLayers;
32
+ /**
33
+ * Tight bounding box [x, y, w, h] of path `d` strings in source coords, or null.
34
+ * Used to fit icon content (not the padded viewBox) to the cap band.
35
+ */
36
+ export declare function contentBounds(PathKit: PathKitModule, ds: string[]): [number, number, number, number] | null;
37
+ //# sourceMappingURL=layers.d.ts.map
@@ -0,0 +1,23 @@
1
+ import type { NanoLogger } from '../types';
2
+ export type SymbolTemplateLayer = {
3
+ /** Path data in source viewBox coordinates (nonzero winding). */
4
+ d: string;
5
+ fill: string | null;
6
+ };
7
+ export declare function layerHexColor(fill: string | null): string;
8
+ export declare function layerClass(layerIndex: number): string;
9
+ /**
10
+ * Build the template SVG for one symbol. Layers are back→front; every layer
11
+ * gets `monochrome-N multicolor-N:custom` classes, with the layer fills
12
+ * declared in a `<style>` block.
13
+ */
14
+ export declare function buildSymbolTemplate(opts: {
15
+ layers: SymbolTemplateLayer[];
16
+ viewBox: [number, number, number, number];
17
+ /** Tight content box `[x, y, w, h]`; used instead of the viewBox when given. */
18
+ contentBounds?: [number, number, number, number];
19
+ /** Shown in the template's Notes group. */
20
+ descriptiveName?: string;
21
+ logger?: NanoLogger;
22
+ }): string;
23
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { SymbolTemplateLayer } from './template';
2
+ /**
3
+ * VectorDrawable XML from z-ordered layers. `contentBounds` (tight `[x,y,w,h]`,
4
+ * defaults to viewBox) sets the viewport so padding doesn't shrink the icon.
5
+ */
6
+ export declare function buildVectorDrawableXml(opts: {
7
+ layers: SymbolTemplateLayer[];
8
+ viewBox: [number, number, number, number];
9
+ /** Tight content box `[x, y, w, h]`; used instead of the viewBox when given. */
10
+ contentBounds?: [number, number, number, number];
11
+ }): string;
12
+ //# sourceMappingURL=vectorDrawable.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare const DEV_SERVER_FONT_ROUTE = "/__nanoicons/";
2
+ export declare function devServerFontUri(family: string): string | undefined;
3
+ export declare function loadFontFromDevServer(family: string): Promise<boolean>;
4
+ //# sourceMappingURL=devServerFont.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare const DEV_SERVER_FONT_ROUTE = "/__nanoicons/";
2
+ export declare function devServerFontUri(family: string): string | undefined;
3
+ export declare function loadFontFromDevServer(family: string): Promise<boolean>;
4
+ //# sourceMappingURL=devServerFont.web.d.ts.map
@@ -22,6 +22,7 @@ export declare function loadDynamicFont(family: string, font: unknown, opts?: {
22
22
  * errored, or not managed by us).
23
23
  */
24
24
  export declare function useDynamicFontPending(managed: boolean, family: string): boolean;
25
+ export declare function useDynamicFontStatus(family: string): FontStatus | undefined;
25
26
  /** Test-only: reset module state between tests. */
26
27
  export declare function __resetDynamicFontsForTests(): void;
27
28
  export {};
@@ -1,14 +1,15 @@
1
- import type { ViewProps } from 'react-native';
1
+ import type { ColorValue, ViewProps } from 'react-native';
2
2
  import type { Float, Int32 } from '../const/codegenPrimitives';
3
3
  export interface NativeProps extends ViewProps {
4
4
  fontFamily: string;
5
5
  codepoints: ReadonlyArray<Int32>;
6
- colors: ReadonlyArray<Int32>;
7
- fontSize: Float;
6
+ colors: ReadonlyArray<ColorValue>;
7
+ color?: ColorValue;
8
+ tintLayers: ReadonlyArray<Int32>;
9
+ size: Float;
10
+ allowFontScaling: boolean;
8
11
  advanceWidth: Int32;
9
12
  unitsPerEm: Int32;
10
- iconWidth: Float;
11
- iconHeight: Float;
12
13
  }
13
14
  declare const _default: import("react-native/types_generated/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
14
15
  export default _default;
@@ -0,0 +1,33 @@
1
+ import type { NanoSymbolDescriptor, NanoSymbolRenderingMode } from './types';
2
+ export type { NativeNanoSymbol, NanoSymbolDescriptor, NanoSymbolRenderingMode, } from './types';
3
+ /**
4
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
5
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
6
+ * filenames (and autocompletes them) with no explicit generic.
7
+ */
8
+ export interface NanoSymbolNames {
9
+ }
10
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
11
+ type NanoSymbolName = [keyof NanoSymbolNames] extends [never] ? string : Extract<keyof NanoSymbolNames, string>;
12
+ /**
13
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
14
+ *
15
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
16
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
17
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
18
+ * colors — Apple's "multicolor" symbol rendering).
19
+ *
20
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
21
+ * the same pure transform the build uses. Each icon ships two drawables;
22
+ * `renderingMode` picks the solid silhouette the bar tints (`monochrome`) or
23
+ * the untinted drawable that keeps its own colors (`original`, `_original`
24
+ * suffix), forwarded as react-navigation's `tinted`.
25
+ *
26
+ * tabBarIcon: () => nativeNanoSymbol('home')
27
+ * // tints only when unfocused, keeps the icon's own colors while focused
28
+ * tabBarIcon: ({ focused }) =>
29
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
30
+ */
31
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName>(name: Name, renderingMode?: NanoSymbolRenderingMode): NanoSymbolDescriptor<Name, 'nano'>;
32
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName, P extends string>(name: Name, renderingMode: NanoSymbolRenderingMode | undefined, prefix: P): NanoSymbolDescriptor<Name, P>;
33
+ //# sourceMappingURL=index.android.d.ts.map
@@ -0,0 +1,31 @@
1
+ import type { NanoSymbolDescriptor, NanoSymbolRenderingMode } from './types';
2
+ export type { NativeNanoSymbol, NanoSymbolDescriptor, NanoSymbolRenderingMode, } from './types';
3
+ /**
4
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
5
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
6
+ * filenames (and autocompletes them) with no explicit generic.
7
+ */
8
+ export interface NanoSymbolNames {
9
+ }
10
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
11
+ type NanoSymbolName = [keyof NanoSymbolNames] extends [never] ? string : Extract<keyof NanoSymbolNames, string>;
12
+ /**
13
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
14
+ *
15
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
16
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
17
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
18
+ * colors — Apple's "multicolor" symbol rendering).
19
+ *
20
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
21
+ * the same pure transform the build uses. `renderingMode` controls whether the
22
+ * bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
23
+ *
24
+ * tabBarIcon: () => nativeNanoSymbol('home')
25
+ * // tints only when unfocused, keeps the icon's own colors while focused
26
+ * tabBarIcon: ({ focused }) =>
27
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
28
+ */
29
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName>(name: Name, renderingMode?: NanoSymbolRenderingMode): NanoSymbolDescriptor<Name, 'nano'>;
30
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName, P extends string>(name: Name, renderingMode: NanoSymbolRenderingMode | undefined, prefix: P): NanoSymbolDescriptor<Name, P>;
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,31 @@
1
+ import type { NanoSymbolDescriptor, NanoSymbolRenderingMode } from './types';
2
+ export type { NativeNanoSymbol, NanoSymbolDescriptor, NanoSymbolRenderingMode, } from './types';
3
+ /**
4
+ * Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
5
+ * set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
6
+ * filenames (and autocompletes them) with no explicit generic.
7
+ */
8
+ export interface NanoSymbolNames {
9
+ }
10
+ /** Accepted icon names — the augmented union, or any string until a set is generated. */
11
+ type NanoSymbolName = [keyof NanoSymbolNames] extends [never] ? string : Extract<keyof NanoSymbolNames, string>;
12
+ /**
13
+ * Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
14
+ *
15
+ * iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
16
+ * path. Every forged symbol carries both rendering modes; `renderingMode`
17
+ * picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
18
+ * colors — Apple's "multicolor" symbol rendering).
19
+ *
20
+ * Android — the drawable resource name is derived from `${prefix}.${name}` with
21
+ * the same pure transform the build uses. `renderingMode` controls whether the
22
+ * bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
23
+ *
24
+ * tabBarIcon: () => nativeNanoSymbol('home')
25
+ * // tints only when unfocused, keeps the icon's own colors while focused
26
+ * tabBarIcon: ({ focused }) =>
27
+ * nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
28
+ */
29
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName>(name: Name, renderingMode?: NanoSymbolRenderingMode): NanoSymbolDescriptor<Name, 'nano'>;
30
+ export declare function nativeNanoSymbol<Name extends NanoSymbolName, P extends string>(name: Name, renderingMode: NanoSymbolRenderingMode | undefined, prefix: P): NanoSymbolDescriptor<Name, P>;
31
+ //# sourceMappingURL=index.ios.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { nativeNanoSymbol as iosNanoSymbol } from './index.ios';
2
+ /**
3
+ * Runtime platform split for React Native. Metro resolves package `exports`
4
+ * targets verbatim — it never expands `.ios`/`.android` for them — so the
5
+ * filename-based split the source uses cannot survive the `exports` map.
6
+ */
7
+ export declare const nativeNanoSymbol: typeof iosNanoSymbol;
8
+ //# sourceMappingURL=index.native.d.ts.map
@@ -0,0 +1,24 @@
1
+ export type NanoSymbolRenderingMode = 'monochrome' | 'original';
2
+ export type NativeNanoSymbol = {
3
+ type: 'sfSymbol';
4
+ name: string;
5
+ renderingMode: NanoSymbolRenderingMode;
6
+ } | {
7
+ type: 'image';
8
+ source: {
9
+ uri: string;
10
+ };
11
+ tinted: boolean;
12
+ };
13
+ export type NanoSymbolDescriptor<Name extends string, P extends string> = {
14
+ type: 'sfSymbol';
15
+ name: `${P}.${Name}`;
16
+ renderingMode: NanoSymbolRenderingMode;
17
+ } | {
18
+ type: 'image';
19
+ source: {
20
+ uri: string;
21
+ };
22
+ tinted: boolean;
23
+ };
24
+ //# sourceMappingURL=types.d.ts.map
@@ -1,11 +1,13 @@
1
1
  import type { ComponentRef, Ref } from 'react';
2
2
  import type { AccessibilityRole, ColorValue, View, ViewStyle } from 'react-native';
3
3
  import type { NanoGlyphMapInput } from './core/types';
4
+ import type { TintMode } from './utils/glyphRuntime';
4
5
  type ViewRef = ComponentRef<typeof View>;
5
6
  export type IconProps<Name> = {
6
7
  name: Name;
7
8
  size?: number;
8
9
  color?: ColorValue | ColorValue[];
10
+ tintMode?: TintMode;
9
11
  allowFontScaling?: boolean;
10
12
  style?: ViewStyle;
11
13
  accessible?: boolean;
@@ -5,5 +5,16 @@ export type FingerprintInputs = {
5
5
  version: string;
6
6
  toolchain: readonly string[];
7
7
  };
8
+ export type SymbolFingerprintInputs = {
9
+ prefix: string;
10
+ version: string;
11
+ toolchain: readonly string[];
12
+ };
13
+ export type SvgDirFingerprint = {
14
+ hash: string;
15
+ svgHashByFile: Map<string, string>;
16
+ };
8
17
  export declare function getFingerprintSync(dir: string, inputs: FingerprintInputs): string;
18
+ export declare function fingerprintSvgDirSync(dir: string, inputs: FingerprintInputs): SvgDirFingerprint;
19
+ export declare function fingerprintSymbolDirSync(dir: string, inputs: SymbolFingerprintInputs): SvgDirFingerprint;
9
20
  //# sourceMappingURL=fingerPrint.d.ts.map
@@ -14,5 +14,7 @@ export declare function createCharCache(): (codepoint: number) => string;
14
14
  * color wins, else the last supplied palette color spills onto remaining
15
15
  * layers, else the glyph's own source color, else black.
16
16
  */
17
- export declare function createLayerColorResolver(color: ColorValue | ColorValue[] | undefined): (index: number, srcColor: string | undefined) => ColorValue;
17
+ export type TintMode = 'all' | 'currentColor';
18
+ export declare function createLayerColorResolver(color: ColorValue | ColorValue[] | undefined, tintMode?: TintMode, layers?: GlyphEntry[1]): (index: number, srcColor: string | undefined) => ColorValue;
19
+ export declare function tintableLayers(layers: GlyphEntry[1], tintMode?: TintMode): readonly number[];
18
20
  //# sourceMappingURL=glyphRuntime.d.ts.map