react-native-nano-icons 1.0.1 → 1.1.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 (117) hide show
  1. package/README.md +137 -21
  2. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +15 -0
  3. package/android/src/main/java/com/nanoicons/NanoIconView.kt +27 -4
  4. package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +7 -0
  5. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +3 -0
  6. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.cpp +6 -1
  7. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.h +4 -2
  8. package/ios/NanoIconView.mm +12 -0
  9. package/ios/NanoIconsFontLoader.mm +5 -0
  10. package/lib/commonjs/cli/build.d.ts +26 -0
  11. package/lib/commonjs/cli/build.js +174 -64
  12. package/lib/commonjs/cli/buildSymbols.d.ts +17 -0
  13. package/lib/commonjs/cli/buildSymbols.js +103 -42
  14. package/lib/commonjs/cli/expoConfig.d.ts +10 -0
  15. package/lib/commonjs/cli/expoConfig.js +22 -7
  16. package/lib/commonjs/cli/fingerprint.d.ts +15 -0
  17. package/lib/commonjs/cli/fingerprint.js +36 -0
  18. package/lib/commonjs/cli/index.d.ts +2 -2
  19. package/lib/commonjs/cli/index.js +3 -1
  20. package/lib/commonjs/cli/link.d.ts +4 -0
  21. package/lib/commonjs/cli/link.js +25 -0
  22. package/lib/commonjs/cli/sameOutputs.d.ts +5 -0
  23. package/lib/commonjs/cli/sameOutputs.js +45 -0
  24. package/lib/commonjs/index.node.js +1 -1
  25. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -2
  26. package/lib/commonjs/plugin/src/buildFonts.js +11 -3
  27. package/lib/commonjs/plugin/src/buildSymbols.d.ts +2 -2
  28. package/lib/commonjs/plugin/src/buildSymbols.js +10 -3
  29. package/lib/commonjs/plugin/src/frozen.d.ts +3 -0
  30. package/lib/commonjs/plugin/src/frozen.js +18 -0
  31. package/lib/commonjs/plugin/src/index.js +3 -3
  32. package/lib/commonjs/plugin/src/types.d.ts +10 -0
  33. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +1 -1
  34. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +2 -2
  35. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +3 -3
  36. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +8 -8
  37. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +1 -1
  38. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +2 -2
  39. package/lib/commonjs/scripts/cli.js +31 -2
  40. package/lib/commonjs/src/core/flatten/dom.js +40 -5
  41. package/lib/commonjs/src/core/flatten/element.js +2 -1
  42. package/lib/commonjs/src/core/flatten/stages/collapse.js +12 -0
  43. package/lib/commonjs/src/core/font/compile.d.ts +0 -1
  44. package/lib/commonjs/src/core/font/compile.js +2 -8
  45. package/lib/commonjs/src/core/glyph/merge.d.ts +2 -1
  46. package/lib/commonjs/src/core/glyph/merge.js +27 -36
  47. package/lib/commonjs/src/core/glyph/parse.d.ts +1 -2
  48. package/lib/commonjs/src/core/glyph/parse.js +31 -18
  49. package/lib/commonjs/src/core/pathkit/winding.d.ts +7 -1
  50. package/lib/commonjs/src/core/pathkit/winding.js +172 -0
  51. package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
  52. package/lib/commonjs/src/core/pipeline/prepare.d.ts +1 -1
  53. package/lib/commonjs/src/core/pipeline/prepare.js +3 -16
  54. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +1 -0
  55. package/lib/commonjs/src/core/pipeline/prepareIcon.js +1 -1
  56. package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +1 -1
  57. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +20 -12
  58. package/lib/commonjs/src/core/symbols/knockout.js +4 -3
  59. package/lib/commonjs/src/utils/fingerPrint.d.ts +1 -0
  60. package/lib/commonjs/src/utils/fingerPrint.js +3 -1
  61. package/lib/commonjs/src/utils/fontIdentity.d.ts +1 -1
  62. package/lib/commonjs/src/utils/fontIdentity.js +2 -2
  63. package/lib/module/createNanoIconsSet.js +0 -1
  64. package/lib/module/createNanoIconsSet.native.js +22 -18
  65. package/lib/module/createNanoIconsSet.shared.js +32 -18
  66. package/lib/module/createNanoIconsSet.web.js +103 -61
  67. package/lib/module/devServerFont.js +1 -1
  68. package/lib/module/devServerFont.web.js +3 -5
  69. package/lib/module/fontIntegrity.js +20 -38
  70. package/lib/module/fontIntegrity.web.js +48 -0
  71. package/lib/module/fontIntegrityStore.js +65 -0
  72. package/lib/module/index.js +1 -1
  73. package/lib/module/index.node.js +1 -1
  74. package/lib/module/index.web.js +4 -0
  75. package/lib/module/loadDynamicFont.js +3 -15
  76. package/lib/module/specs/NanoIconViewNativeComponent.ts +2 -1
  77. package/lib/module/utils/fingerPrint.js +3 -2
  78. package/lib/module/utils/fontIdentity.js +2 -2
  79. package/lib/module/utils/fontScale.js +10 -2
  80. package/lib/module/utils/glyphRuntime.js +13 -0
  81. package/lib/module/utils/iconAccessibility.js +26 -0
  82. package/lib/module/utils/iconPropsEqual.js +27 -0
  83. package/lib/module/utils/webCss.js +26 -0
  84. package/lib/module/utils/webStyle.js +86 -0
  85. package/lib/module/webFont.js +33 -0
  86. package/lib/typescript/src/const/codegenPrimitives.d.ts +1 -0
  87. package/lib/typescript/src/core/glyph/merge.d.ts +2 -1
  88. package/lib/typescript/src/core/glyph/parse.d.ts +1 -2
  89. package/lib/typescript/src/core/pathkit/winding.d.ts +7 -1
  90. package/lib/typescript/src/createNanoIconsSet.d.ts +0 -1
  91. package/lib/typescript/src/createNanoIconsSet.native.d.ts +0 -2
  92. package/lib/typescript/src/createNanoIconsSet.shared.d.ts +1 -3
  93. package/lib/typescript/src/createNanoIconsSet.web.d.ts +1 -2
  94. package/lib/typescript/src/fontIntegrity.d.ts +2 -14
  95. package/lib/typescript/src/fontIntegrity.web.d.ts +7 -0
  96. package/lib/typescript/src/fontIntegrityStore.d.ts +19 -0
  97. package/lib/typescript/src/index.d.ts +2 -1
  98. package/lib/typescript/src/index.web.d.ts +5 -0
  99. package/lib/typescript/src/loadDynamicFont.d.ts +0 -1
  100. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +2 -1
  101. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  102. package/lib/typescript/src/types.d.ts +37 -9
  103. package/lib/typescript/src/utils/fingerPrint.d.ts +1 -0
  104. package/lib/typescript/src/utils/fontIdentity.d.ts +1 -1
  105. package/lib/typescript/src/utils/glyphRuntime.d.ts +8 -0
  106. package/lib/typescript/src/utils/iconAccessibility.d.ts +4 -0
  107. package/lib/typescript/src/utils/iconPropsEqual.d.ts +4 -0
  108. package/lib/typescript/src/utils/webCss.d.ts +9 -0
  109. package/lib/typescript/src/utils/webStyle.d.ts +3 -0
  110. package/lib/typescript/src/webFont.d.ts +6 -0
  111. package/package.json +19 -3
  112. package/src/const/codegenPrimitives.ts +3 -3
  113. package/src/specs/NanoIconViewNativeComponent.ts +2 -1
  114. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  115. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +0 -12
  116. package/lib/commonjs/src/core/pathkit/evenodd.js +0 -37
  117. package/lib/typescript/src/core/pathkit/evenodd.d.ts +0 -13
@@ -0,0 +1,4 @@
1
+ import type { IconProps } from '../types';
2
+ export type IconAccessibilityProps = Pick<IconProps<unknown>, 'accessible' | 'accessibilityLabel' | 'accessibilityRole' | 'accessibilityElementsHidden' | 'importantForAccessibility'>;
3
+ export declare function iconAccessibilityProps({ accessible, accessibilityLabel, accessibilityRole, accessibilityElementsHidden, importantForAccessibility, }: IconAccessibilityProps): IconAccessibilityProps;
4
+ //# sourceMappingURL=iconAccessibility.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { IconProps } from '../types';
2
+ export declare function shallowEqualStyle(a: unknown, b: unknown): boolean;
3
+ export declare function areIconPropsEqual<Name>(prev: IconProps<Name>, next: IconProps<Name>): boolean;
4
+ //# sourceMappingURL=iconPropsEqual.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { GlyphEntry } from '../core/types';
2
+ export declare const ICON_CLASS = "nano-icon";
3
+ export declare const STYLE_HREF = "react-native-nano-icons";
4
+ export declare const STYLE_PRECEDENCE = "react-native-nano-icons";
5
+ export declare const BASE_CSS: string;
6
+ export declare const BASE_HREF: string;
7
+ export declare function followsTextColor(layers: GlyphEntry[1]): boolean;
8
+ export declare function shortHash(value: string): string;
9
+ //# sourceMappingURL=webCss.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { CSSProperties } from 'react';
2
+ export declare function resolveWebStyle(style: unknown): CSSProperties | undefined;
3
+ //# sourceMappingURL=webStyle.d.ts.map
@@ -0,0 +1,6 @@
1
+ export declare function webFontUrl(font: unknown): string | undefined;
2
+ export declare function isWebFontRegistered(family: string): boolean;
3
+ export declare function registerWebFont(family: string, url: string): Promise<void>;
4
+ export declare function __resetWebFontsForTests(): void;
5
+ export declare function warnFontNotLoaded(fontBasename: string): void;
6
+ //# sourceMappingURL=webFont.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nano-icons",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-beta.1",
4
4
  "description": "High-performance icon rendering for React Native & Expo.",
5
5
  "react-native": "./lib/module/index.js",
6
6
  "source": "src/index.ts",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@expo/config-plugins": ">=9.0.0",
42
- "@xmldom/xmldom": "^0.9.10",
42
+ "@xmldom/xmldom": "^0.8.15 || ^0.9.12",
43
43
  "chalk": "^5.6.2",
44
44
  "cubic2quad": "^1.2.1",
45
45
  "fonteditor-core": "^2.6.3",
@@ -53,6 +53,7 @@
53
53
  "@expo/config": ">=9.0.0",
54
54
  "expo": "*",
55
55
  "react": "*",
56
+ "react-dom": "*",
56
57
  "react-native": ">=0.81.0"
57
58
  },
58
59
  "peerDependenciesMeta": {
@@ -64,6 +65,9 @@
64
65
  },
65
66
  "expo": {
66
67
  "optional": true
68
+ },
69
+ "react-dom": {
70
+ "optional": true
67
71
  }
68
72
  },
69
73
  "devDependencies": {
@@ -72,14 +76,17 @@
72
76
  "@types/node": "^25.2.3",
73
77
  "@types/plist": "^3.0.5",
74
78
  "@types/react": "~19.1.0",
79
+ "@types/react-dom": "~19.1.0",
75
80
  "@types/svg2ttf": "^5.0.3",
76
81
  "@types/xcode": "^3.0.0",
82
+ "@xmldom/xmldom-0.8": "npm:@xmldom/xmldom@0.8.15",
77
83
  "babel-plugin-module-resolver": "^5.0.2",
78
84
  "del-cli": "^6.0.0",
79
85
  "expo-module-scripts": "^5.0.8",
80
86
  "jest": "^29.7.0",
81
87
  "patch-package": "^8.0.0",
82
88
  "react": "19.1.0",
89
+ "react-dom": "19.1.0",
83
90
  "react-native": "^0.84.0",
84
91
  "react-native-builder-bob": "^0.40.18",
85
92
  "typescript": "^5.9.3"
@@ -88,13 +95,17 @@
88
95
  ".": {
89
96
  "source": "./src/index.ts",
90
97
  "react-native": "./lib/module/index.js",
98
+ "browser": {
99
+ "types": "./lib/typescript/src/index.d.ts",
100
+ "default": "./lib/module/index.web.js"
101
+ },
91
102
  "require": {
92
103
  "types": "./lib/typescript/src/index.d.ts",
93
104
  "default": "./lib/commonjs/index.node.js"
94
105
  },
95
106
  "import": {
96
107
  "types": "./lib/typescript/src/index.d.ts",
97
- "default": "./lib/module/index.js"
108
+ "default": "./lib/module/index.web.js"
98
109
  },
99
110
  "default": "./lib/commonjs/index.node.js"
100
111
  },
@@ -121,6 +132,11 @@
121
132
  "default": "./lib/commonjs/cli/index.js"
122
133
  }
123
134
  },
135
+ "./fingerprint": {
136
+ "source": "./cli/fingerprint.ts",
137
+ "types": "./lib/commonjs/cli/fingerprint.d.ts",
138
+ "default": "./lib/commonjs/cli/fingerprint.js"
139
+ },
124
140
  "./pipeline": {
125
141
  "source": "./src/core/pipeline/index.ts",
126
142
  "require": {
@@ -1,4 +1,4 @@
1
- // Local numeric aliases for RN codegen TS spec parsing.
1
+ // Local type aliases for RN codegen TS spec parsing.
2
2
  //
3
3
  // RN 0.79 and lower's codegen resolves any TSTypeAliasDeclaration found in the spec
4
4
  // file back to its original RHS before the array-element handler runs — so a
@@ -8,7 +8,7 @@
8
8
  // importing `Int32` / `Float` from here leaves a bare identifier that matches
9
9
  // the primitive-type branch (`case 'Int32'` / `case 'Float'`).
10
10
  //
11
- // These are pure number aliases at runtime; RN codegen only cares about the
12
- // identifier name.
11
+ // These are plain TS aliases; RN codegen only cares about the identifier name.
13
12
  export type Int32 = number;
14
13
  export type Float = number;
14
+ export type WithDefault<Type, _Value extends Type> = Type | null | undefined;
@@ -1,6 +1,6 @@
1
1
  import { codegenNativeComponent } from 'react-native';
2
2
  import type { ColorValue, ViewProps } from 'react-native';
3
- import type { Float, Int32 } from '../const/codegenPrimitives';
3
+ import type { Float, Int32, WithDefault } from '../const/codegenPrimitives';
4
4
 
5
5
  export interface NativeProps extends ViewProps {
6
6
  fontFamily: string;
@@ -12,6 +12,7 @@ export interface NativeProps extends ViewProps {
12
12
  fontScale: Float;
13
13
  advanceWidth: Int32;
14
14
  unitsPerEm: Int32;
15
+ squareGlyphScale?: WithDefault<Float, 0>;
15
16
  }
16
17
 
17
18
  export default codegenNativeComponent<NativeProps>('NanoIconView', {
@@ -5,6 +5,7 @@ export interface Spec extends TurboModule {
5
5
  /** Pass glyphMap.m.f as `family`. On iOS it must also match the TTF's embedded PostScript/full name. */
6
6
  registerFont(family: string, uri: string): Promise<boolean>;
7
7
  isFontRegistered(family: string): Promise<boolean>;
8
+ isFontAvailable(family: string): boolean;
8
9
  }
9
10
 
10
11
  // `get` (not `getEnforcing`) so the absence of the native module (web, Expo Go,
@@ -1,12 +0,0 @@
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;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEvenoddToWinding = convertEvenoddToWinding;
4
- const contours_1 = require("./contours");
5
- /**
6
- * Convert a path `d` string with evenodd fill semantics to an equivalent
7
- * path that renders identically under nonzero winding.
8
- *
9
- * Steps:
10
- * 1. Parse via PathKit, set fill type to EVENODD, simplify (resolve topology)
11
- * 2. Split into contours, compute containment depths
12
- * 3. Fix winding: even depth = CCW (outer), odd depth = CW (hole)
13
- * 4. Reconstruct d string
14
- */
15
- function convertEvenoddToWinding(PathKit, d) {
16
- const V = (0, contours_1.verbMap)(PathKit);
17
- // 1. Parse and simplify with EVENODD fill type
18
- const p = PathKit.FromSVGString(d);
19
- if (!p)
20
- return d;
21
- p.setFillType((0, contours_1.fillTypes)(PathKit).EVENODD);
22
- p.simplify();
23
- // Get the simplified SVG string and re-parse for command access
24
- const simplified = p.toSVGString();
25
- p.delete?.();
26
- const p2 = PathKit.FromSVGString(simplified);
27
- if (!p2)
28
- return simplified;
29
- const cmds = p2.toCmds();
30
- p2.delete?.();
31
- if (cmds.length === 0)
32
- return simplified;
33
- // 2.+3. Split into contours and fix winding via containment analysis
34
- const allCmds = (0, contours_1.orientedContours)(cmds, V).flatMap((x) => x.cmds);
35
- // 4. Reconstruct d string from fixed commands
36
- return (0, contours_1.cmdsToPathData)(allCmds, V);
37
- }
@@ -1,13 +0,0 @@
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;
13
- //# sourceMappingURL=evenodd.d.ts.map