react-native-nano-icons 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -56,13 +56,13 @@ The library uses an Expo Config Plugin to hook into the prebuild phase. This aut
56
56
 
57
57
  The plugin accepts an object with an `iconSets` array, allowing you to generate multiple distinct fonts in a single build.
58
58
 
59
- | Property | Type | Required | Default | Description |
60
- | :------------- | :------- | :-------- | :------------- | :------------------------------------------------------------------------------------------------------------------------- |
61
- | `inputDir` | `string` | **Yes** | — | Path to the directory containing your `.svg` files (e.g., `./assets/icons/ui`). |
62
- | `fontFamily` | `string` | No | Folder Name | The name of the generated font family and file. If omitted, the name of the `inputDir` folder is used (e.g., `ui`). |
63
- | `outputDir` | `string` | No | `../nanoicons` | Path where the `.ttf` and `.json` artifacts will be saved. Defaults to a sibling `nanoicons` folder relative to the input. |
64
- | `upm` | `number` | No | `1024` | Units Per Em. Defines the resolution of the font grid. |
65
- | `startUnicode` | `string` | No | `0xe900` | The starting Hex Unicode point for the first icon glyph. |
59
+ | Property | Type | Required | Default | Description |
60
+ | :------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------- |
61
+ | `inputDir` | `string` | **Yes** | — | Path to the directory containing your `.svg` files (e.g., `./assets/icons/ui`). |
62
+ | `fontFamily` | `string` | No | Folder Name | The name of the generated font family and file. If omitted, the name of the `inputDir` folder is used (e.g., `ui`). |
63
+ | `outputDir` | `string` | No | `../nanoicons` | Path where the `.ttf` and `.json` artifacts will be saved. Defaults to a sibling `nanoicons` folder relative to the input. |
64
+ | `upm` | `number` | No | `1024` | Units Per Em. Defines the resolution of the font grid. |
65
+ | `startUnicode` | `string` | No | `0xe900` | The starting Hex Unicode point for the first icon glyph. |
66
66
 
67
67
  <details>
68
68
  <summary>Default Dir Path Behavior</summary>
@@ -131,14 +131,14 @@ export default function App() {
131
131
  return (
132
132
  <>
133
133
  // Renders the icon with its original multi-color layers from the SVG
134
- <Icon name="avatar-1" size={32} />
134
+ <UserIcon name="avatar-1" size={32} />
135
135
 
136
136
  // Overrides all color layers with the provided colors respectively
137
- <Icon name="avatar-1" size={24} colorPalette={["blue", "#ffffff", "#fc2930"]} />
137
+ <UserIcon name="avatar-1" size={24} colorPalette={["blue", "#ffffff", "#fc2930"]} />
138
138
 
139
139
  // Renders icon inline within a paragraph
140
140
  <Text>
141
- User <Icon name="avatar-1" size={12} /> liked your photo!
141
+ User <UserIcon name="avatar-1" size={12} /> liked your photo!
142
142
  </Text>
143
143
  </>
144
144
  );
@@ -3,7 +3,7 @@ export type IconSetConfig = {
3
3
  /** Path to folder of SVG files (relative to project root). */
4
4
  inputDir: string;
5
5
  /** Font family name (used for TTF and glyphmap filenames). */
6
- fontFamily: string;
6
+ fontFamily?: string;
7
7
  /** Path where .ttf and .glyphmap.json will be saved. Defaults to a sibling nanoicons folder relative to inputDir. */
8
8
  outputDir?: string;
9
9
  /** Units per em (default 1024). */
@@ -39,17 +39,18 @@ async function buildAllFonts(iconSets, projectRoot, options) {
39
39
  for (let i = 0; i < iconSets.length; i++) {
40
40
  const set = iconSets[i];
41
41
  const inputDir = path_1.default.resolve(projectRoot, set.inputDir);
42
+ const fontFamily = set.fontFamily ?? path_1.default.basename(inputDir);
42
43
  if (!fs_1.default.existsSync(inputDir)) {
43
44
  throw new Error(`[react-native-nano-icons] Input directory does not exist: ${inputDir} (from "${set.inputDir}")`);
44
45
  }
45
46
  const outputDir = set.outputDir
46
47
  ? path_1.default.resolve(projectRoot, set.outputDir)
47
48
  : path_1.default.join(path_1.default.dirname(inputDir), 'nanoicons');
48
- const ttfPath = path_1.default.join(outputDir, `${set.fontFamily}.ttf`);
49
- const glyphmapPath = path_1.default.join(outputDir, `${set.fontFamily}.glyphmap.json`);
49
+ const ttfPath = path_1.default.join(outputDir, `${fontFamily}.ttf`);
50
+ const glyphmapPath = path_1.default.join(outputDir, `${fontFamily}.glyphmap.json`);
50
51
  const inputHash = (0, fingerPrint_js_1.getFingerprintSync)(inputDir);
51
- if (shouldSkipGeneration(inputHash, outputDir, set.fontFamily, logger)) {
52
- results.push({ fontFamily: set.fontFamily, ttfPath, glyphmapPath });
52
+ if (shouldSkipGeneration(inputHash, outputDir, fontFamily, logger)) {
53
+ results.push({ fontFamily, ttfPath, glyphmapPath });
53
54
  continue;
54
55
  }
55
56
  if (fs_1.default.existsSync(ttfPath))
@@ -57,9 +58,9 @@ async function buildAllFonts(iconSets, projectRoot, options) {
57
58
  if (fs_1.default.existsSync(glyphmapPath))
58
59
  fs_1.default.unlinkSync(glyphmapPath);
59
60
  allSkipped = false;
60
- const tempDir = path_1.default.join(projectRoot, '.temp_layers', set.fontFamily);
61
+ const tempDir = path_1.default.join(projectRoot, '.temp_layers', fontFamily);
61
62
  const config = {
62
- fontFamily: set.fontFamily,
63
+ fontFamily,
63
64
  upm: set.upm ?? DEFAULT_UPM,
64
65
  safeZone: set.safeZone ?? DEFAULT_SAFE_ZONE,
65
66
  startUnicode: set.startUnicode !== undefined
@@ -68,10 +69,10 @@ async function buildAllFonts(iconSets, projectRoot, options) {
68
69
  : set.startUnicode
69
70
  : DEFAULT_START_UNICODE,
70
71
  };
71
- logger?.start(`Building ${set.fontFamily} (${i + 1}/${iconSets.length})…`);
72
+ logger?.start(`Building ${fontFamily} (${i + 1}/${iconSets.length})…`);
72
73
  const out = await (0, index_js_1.runPipeline)(config, { inputDir, outputDir, tempDir }, { logger, inputHash });
73
74
  results.push({
74
- fontFamily: set.fontFamily,
75
+ fontFamily,
75
76
  ttfPath: out.ttfPath,
76
77
  glyphmapPath: out.glyphmapPath,
77
78
  });
@@ -5,3 +5,4 @@ import type { IconSetConfig, BuiltFont } from './types.js';
5
5
  * unless EXPO_DEBUG is set, in which case the full error is re-thrown.
6
6
  */
7
7
  export declare function buildAllFonts(iconSets: IconSetConfig[], projectRoot: string): Promise<BuiltFont[]>;
8
+ export declare function getOrBuildFonts(projectRoot: string, iconSets: IconSetConfig[]): Promise<BuiltFont[]>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildAllFonts = buildAllFonts;
4
+ exports.getOrBuildFonts = getOrBuildFonts;
4
5
  const index_js_1 = require("../../cli/index.js");
5
6
  /**
6
7
  * Build TTF + glyphmap for all icon sets.
@@ -21,3 +22,11 @@ async function buildAllFonts(iconSets, projectRoot) {
21
22
  return [];
22
23
  }
23
24
  }
25
+ // Single build run per process; reused across ios/android mods.
26
+ let _buildPromise = null;
27
+ function getOrBuildFonts(projectRoot, iconSets) {
28
+ if (!_buildPromise) {
29
+ _buildPromise = buildAllFonts(iconSets, projectRoot);
30
+ }
31
+ return _buildPromise;
32
+ }
@@ -1,43 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_plugins_1 = require("@expo/config-plugins");
4
- const buildFonts_js_1 = require("./buildFonts.js");
5
3
  const withNanoIconsFontLinking_js_1 = require("./withNanoIconsFontLinking.js");
6
- const BUILT_FONTS_KEY = '_nanoIconsBuilt';
7
- // Single Pyodide/PathKit run for the whole prebuild; reused across ios/android mods.
8
- let _builtFontsCache = null;
9
- function getOrBuildFonts(projectRoot, iconSets) {
10
- if (_builtFontsCache)
11
- return Promise.resolve(_builtFontsCache);
12
- return (0, buildFonts_js_1.buildAllFonts)(iconSets, projectRoot).then((built) => {
13
- _builtFontsCache = built;
14
- return built;
15
- });
16
- }
17
4
  const withNanoIcons = (config, options) => {
18
5
  if (!options?.iconSets?.length)
19
6
  return config;
20
- // Build fonts (once per process, cached) and attach to config for linking mods.
21
- config = (0, config_plugins_1.withDangerousMod)(config, [
22
- 'ios',
23
- async (config) => {
24
- const projectRoot = config.modRequest.projectRoot;
25
- const built = await getOrBuildFonts(projectRoot, options.iconSets);
26
- config[BUILT_FONTS_KEY] = built;
27
- return config;
28
- },
29
- ]);
30
- config = (0, config_plugins_1.withDangerousMod)(config, [
31
- 'android',
32
- async (config) => {
33
- const projectRoot = config.modRequest.projectRoot;
34
- const built = await getOrBuildFonts(projectRoot, options.iconSets);
35
- config[BUILT_FONTS_KEY] = built;
36
- return config;
37
- },
38
- ]);
39
- // Link built TTFs into native projects (reads _nanoIconsBuilt from config).
40
- config = (0, withNanoIconsFontLinking_js_1.withNanoIconsFontLinking)(config);
7
+ config = (0, withNanoIconsFontLinking_js_1.withNanoIconsFontLinking)(config, options.iconSets);
41
8
  return config;
42
9
  };
43
10
  exports.default = withNanoIcons;
@@ -1,14 +1,14 @@
1
1
  import { withXcodeProject, withDangerousMod } from '@expo/config-plugins';
2
+ import type { IconSetConfig } from './types.js';
2
3
  /**
3
4
  * Add TTFs to the iOS project (Resources group + UIAppFonts in Info.plist).
4
- * Reads cached built font paths from config._nanoIconsBuilt (set by the build mod) to prevent redundant builds for iOS and Android.
5
5
  */
6
- export declare function withNanoIconsIos(config: Parameters<typeof withXcodeProject>[0]): ReturnType<typeof withXcodeProject>;
6
+ export declare function withNanoIconsIos(config: Parameters<typeof withXcodeProject>[0], iconSets: IconSetConfig[]): ReturnType<typeof withXcodeProject>;
7
7
  /**
8
- * Copy TTFs to Android assets/fonts. Reads paths from config._nanoIconsBuilt.
8
+ * Copy TTFs to Android assets/fonts.
9
9
  */
10
- export declare function withNanoIconsAndroid(config: Parameters<typeof withDangerousMod>[0]): ReturnType<typeof withDangerousMod>;
10
+ export declare function withNanoIconsAndroid(config: Parameters<typeof withDangerousMod>[0], iconSets: IconSetConfig[]): ReturnType<typeof withDangerousMod>;
11
11
  /**
12
- * Apply iOS and Android font linking. Built font list is read from config (set by build mod).
12
+ * Apply iOS and Android font linking.
13
13
  */
14
- export declare function withNanoIconsFontLinking(config: Parameters<typeof withNanoIconsIos>[0]): ReturnType<typeof withNanoIconsAndroid>;
14
+ export declare function withNanoIconsFontLinking(config: Parameters<typeof withNanoIconsIos>[0], iconSets: IconSetConfig[]): ReturnType<typeof withNanoIconsAndroid>;
@@ -9,18 +9,14 @@ exports.withNanoIconsFontLinking = withNanoIconsFontLinking;
9
9
  const config_plugins_1 = require("@expo/config-plugins");
10
10
  const promises_1 = __importDefault(require("fs/promises"));
11
11
  const path_1 = __importDefault(require("path"));
12
+ const buildFonts_js_1 = require("./buildFonts.js");
12
13
  const ANDROID_ASSETS_FONTS_DIR = 'app/src/main/assets/fonts';
13
- const BUILT_FONTS_KEY = '_nanoIconsBuilt';
14
- function getBuiltFonts(config) {
15
- return config[BUILT_FONTS_KEY];
16
- }
17
14
  /**
18
15
  * Add TTFs to the iOS project (Resources group + UIAppFonts in Info.plist).
19
- * Reads cached built font paths from config._nanoIconsBuilt (set by the build mod) to prevent redundant builds for iOS and Android.
20
16
  */
21
- function withNanoIconsIos(config) {
17
+ function withNanoIconsIos(config, iconSets) {
22
18
  config = (0, config_plugins_1.withXcodeProject)(config, async (config) => {
23
- const built = getBuiltFonts(config);
19
+ const built = await (0, buildFonts_js_1.getOrBuildFonts)(config.modRequest.projectRoot, iconSets);
24
20
  if (!built?.length)
25
21
  return config;
26
22
  const ttfPaths = built.map((b) => b.ttfPath);
@@ -40,7 +36,7 @@ function withNanoIconsIos(config) {
40
36
  return config;
41
37
  });
42
38
  config = (0, config_plugins_1.withInfoPlist)(config, async (config) => {
43
- const built = getBuiltFonts(config);
39
+ const built = await (0, buildFonts_js_1.getOrBuildFonts)(config.modRequest.projectRoot, iconSets);
44
40
  if (!built?.length)
45
41
  return config;
46
42
  const ttfPaths = built.map((b) => b.ttfPath);
@@ -62,13 +58,13 @@ function getUIAppFonts(infoPlist) {
62
58
  return [];
63
59
  }
64
60
  /**
65
- * Copy TTFs to Android assets/fonts. Reads paths from config._nanoIconsBuilt.
61
+ * Copy TTFs to Android assets/fonts.
66
62
  */
67
- function withNanoIconsAndroid(config) {
63
+ function withNanoIconsAndroid(config, iconSets) {
68
64
  return (0, config_plugins_1.withDangerousMod)(config, [
69
65
  'android',
70
66
  async (config) => {
71
- const built = getBuiltFonts(config);
67
+ const built = await (0, buildFonts_js_1.getOrBuildFonts)(config.modRequest.projectRoot, iconSets);
72
68
  if (!built?.length)
73
69
  return config;
74
70
  const fontsDir = path_1.default.join(config.modRequest.platformProjectRoot, ANDROID_ASSETS_FONTS_DIR);
@@ -83,10 +79,10 @@ function withNanoIconsAndroid(config) {
83
79
  ]);
84
80
  }
85
81
  /**
86
- * Apply iOS and Android font linking. Built font list is read from config (set by build mod).
82
+ * Apply iOS and Android font linking.
87
83
  */
88
- function withNanoIconsFontLinking(config) {
89
- config = withNanoIconsIos(config);
90
- config = withNanoIconsAndroid(config);
84
+ function withNanoIconsFontLinking(config, iconSets) {
85
+ config = withNanoIconsIos(config, iconSets);
86
+ config = withNanoIconsAndroid(config, iconSets);
91
87
  return config;
92
88
  }
@@ -3,7 +3,7 @@ export type IconSetConfig = {
3
3
  /** Path to folder of SVG files (relative to project root). */
4
4
  inputDir: string;
5
5
  /** Font family name (used for TTF and glyphmap filenames). */
6
- fontFamily: string;
6
+ fontFamily?: string;
7
7
  /** Path where .ttf and .glyphmap.json will be saved. Defaults to a sibling nanoicons folder relative to inputDir. */
8
8
  outputDir?: string;
9
9
  /** Units per em (default 1024). */
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../cli/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,MAAM,aAAa,GAAG;IAC1B,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,qHAAqH;IACrH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAkCF;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,GAChC,OAAO,CAAC,SAAS,EAAE,CAAC,CAqEtB"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../cli/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,MAAM,aAAa,GAAG;IAC1B,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qHAAqH;IACrH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAkCF;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,GAChC,OAAO,CAAC,SAAS,EAAE,CAAC,CAmEtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nano-icons",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Use any svg as font. High-performance, build-time icon font generation for React Native & Expo.",
5
5
  "react-native": "src/index.ts",
6
6
  "source": "src/index.ts",
@@ -27,3 +27,16 @@ export async function buildAllFonts(
27
27
  return [];
28
28
  }
29
29
  }
30
+
31
+ // Single build run per process; reused across ios/android mods.
32
+ let _buildPromise: Promise<BuiltFont[]> | null = null;
33
+
34
+ export function getOrBuildFonts(
35
+ projectRoot: string,
36
+ iconSets: IconSetConfig[]
37
+ ): Promise<BuiltFont[]> {
38
+ if (!_buildPromise) {
39
+ _buildPromise = buildAllFonts(iconSets, projectRoot);
40
+ }
41
+ return _buildPromise;
42
+ }
@@ -1,31 +1,6 @@
1
- import type {
2
- ConfigPlugin,
3
- ExportedConfigWithProps,
4
- } from '@expo/config-plugins';
5
- import { withDangerousMod } from '@expo/config-plugins';
6
- import { buildAllFonts } from './buildFonts.js';
1
+ import type { ConfigPlugin } from '@expo/config-plugins';
7
2
  import { withNanoIconsFontLinking } from './withNanoIconsFontLinking.js';
8
- import type {
9
- NanoIconsPluginOptions,
10
- IconSetConfig,
11
- BuiltFont,
12
- } from './types.js';
13
-
14
- const BUILT_FONTS_KEY = '_nanoIconsBuilt';
15
-
16
- // Single Pyodide/PathKit run for the whole prebuild; reused across ios/android mods.
17
- let _builtFontsCache: BuiltFont[] | null = null;
18
-
19
- function getOrBuildFonts(
20
- projectRoot: string,
21
- iconSets: IconSetConfig[]
22
- ): Promise<BuiltFont[]> {
23
- if (_builtFontsCache) return Promise.resolve(_builtFontsCache);
24
- return buildAllFonts(iconSets, projectRoot).then((built: BuiltFont[]) => {
25
- _builtFontsCache = built;
26
- return built;
27
- });
28
- }
3
+ import type { NanoIconsPluginOptions } from './types.js';
29
4
 
30
5
  const withNanoIcons: ConfigPlugin<NanoIconsPluginOptions> = (
31
6
  config,
@@ -33,29 +8,7 @@ const withNanoIcons: ConfigPlugin<NanoIconsPluginOptions> = (
33
8
  ) => {
34
9
  if (!options?.iconSets?.length) return config;
35
10
 
36
- // Build fonts (once per process, cached) and attach to config for linking mods.
37
- config = withDangerousMod(config, [
38
- 'ios',
39
- async (config: ExportedConfigWithProps<unknown>) => {
40
- const projectRoot = config.modRequest.projectRoot;
41
- const built = await getOrBuildFonts(projectRoot, options.iconSets);
42
- (config as unknown as Record<string, unknown>)[BUILT_FONTS_KEY] = built;
43
- return config;
44
- },
45
- ]);
46
-
47
- config = withDangerousMod(config, [
48
- 'android',
49
- async (config: ExportedConfigWithProps<unknown>) => {
50
- const projectRoot = config.modRequest.projectRoot;
51
- const built = await getOrBuildFonts(projectRoot, options.iconSets);
52
- (config as unknown as Record<string, unknown>)[BUILT_FONTS_KEY] = built;
53
- return config;
54
- },
55
- ]);
56
-
57
- // Link built TTFs into native projects (reads _nanoIconsBuilt from config).
58
- config = withNanoIconsFontLinking(config);
11
+ config = withNanoIconsFontLinking(config, options.iconSets);
59
12
 
60
13
  return config;
61
14
  };
@@ -4,31 +4,25 @@ import {
4
4
  withXcodeProject,
5
5
  withDangerousMod,
6
6
  } from '@expo/config-plugins';
7
+ import type { InfoPlist } from '@expo/config-plugins';
7
8
  import fs from 'fs/promises';
8
9
  import path from 'path';
9
- import type { BuiltFont } from './types.js';
10
- type InfoPlist = Record<string, unknown>;
10
+ import { getOrBuildFonts } from './buildFonts.js';
11
+ import type { IconSetConfig } from './types.js';
11
12
 
12
13
  const ANDROID_ASSETS_FONTS_DIR = 'app/src/main/assets/fonts';
13
14
 
14
- const BUILT_FONTS_KEY = '_nanoIconsBuilt' as const;
15
-
16
- function getBuiltFonts(config: {
17
- [key: string]: unknown;
18
- }): BuiltFont[] | undefined {
19
- return config[BUILT_FONTS_KEY] as BuiltFont[] | undefined;
20
- }
21
-
22
15
  /**
23
16
  * Add TTFs to the iOS project (Resources group + UIAppFonts in Info.plist).
24
- * Reads cached built font paths from config._nanoIconsBuilt (set by the build mod) to prevent redundant builds for iOS and Android.
25
17
  */
26
18
  export function withNanoIconsIos(
27
- config: Parameters<typeof withXcodeProject>[0]
19
+ config: Parameters<typeof withXcodeProject>[0],
20
+ iconSets: IconSetConfig[]
28
21
  ): ReturnType<typeof withXcodeProject> {
29
22
  config = withXcodeProject(config, async (config) => {
30
- const built = getBuiltFonts(
31
- config as unknown as { [key: string]: unknown }
23
+ const built = await getOrBuildFonts(
24
+ config.modRequest.projectRoot,
25
+ iconSets
32
26
  );
33
27
  if (!built?.length) return config;
34
28
  const ttfPaths = built.map((b) => b.ttfPath);
@@ -51,8 +45,9 @@ export function withNanoIconsIos(
51
45
  config = withInfoPlist(
52
46
  config as Parameters<typeof withInfoPlist>[0],
53
47
  async (config) => {
54
- const built = getBuiltFonts(
55
- config as unknown as { [key: string]: unknown }
48
+ const built = await getOrBuildFonts(
49
+ config.modRequest.projectRoot,
50
+ iconSets
56
51
  );
57
52
  if (!built?.length) return config;
58
53
  const ttfPaths = built.map((b) => b.ttfPath);
@@ -80,16 +75,18 @@ function getUIAppFonts(infoPlist: InfoPlist): string[] {
80
75
  }
81
76
 
82
77
  /**
83
- * Copy TTFs to Android assets/fonts. Reads paths from config._nanoIconsBuilt.
78
+ * Copy TTFs to Android assets/fonts.
84
79
  */
85
80
  export function withNanoIconsAndroid(
86
- config: Parameters<typeof withDangerousMod>[0]
81
+ config: Parameters<typeof withDangerousMod>[0],
82
+ iconSets: IconSetConfig[]
87
83
  ): ReturnType<typeof withDangerousMod> {
88
84
  return withDangerousMod(config, [
89
85
  'android',
90
86
  async (config) => {
91
- const built = getBuiltFonts(
92
- config as unknown as { [key: string]: unknown }
87
+ const built = await getOrBuildFonts(
88
+ config.modRequest.projectRoot,
89
+ iconSets
93
90
  );
94
91
  if (!built?.length) return config;
95
92
  const fontsDir = path.join(
@@ -108,12 +105,13 @@ export function withNanoIconsAndroid(
108
105
  }
109
106
 
110
107
  /**
111
- * Apply iOS and Android font linking. Built font list is read from config (set by build mod).
108
+ * Apply iOS and Android font linking.
112
109
  */
113
110
  export function withNanoIconsFontLinking(
114
- config: Parameters<typeof withNanoIconsIos>[0]
111
+ config: Parameters<typeof withNanoIconsIos>[0],
112
+ iconSets: IconSetConfig[]
115
113
  ): ReturnType<typeof withNanoIconsAndroid> {
116
- config = withNanoIconsIos(config);
117
- config = withNanoIconsAndroid(config);
114
+ config = withNanoIconsIos(config, iconSets);
115
+ config = withNanoIconsAndroid(config, iconSets);
118
116
  return config;
119
117
  }