expo-app-icon 1.2.0 → 1.4.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.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </div>
4
4
 
5
5
  # Expo App Icon
6
- Programmatically change your app's icon at runtime in Expo, with proper Android adaptive-icon support.
6
+ Programmatically change your app's icon at runtime in Expo.
7
7
 
8
8
  ## Install
9
9
 
@@ -31,18 +31,21 @@ Add the plugin to your `app.json` config and declare your icons. Each icon is ju
31
31
  }
32
32
  ```
33
33
 
34
- The same image is used for both platforms. To use a different image per platform, pass an object instead:
34
+ The same image is used for both platforms. For per-platform images, use the object form:
35
35
 
36
36
  ```json
37
37
  {
38
38
  "red": "./assets/icons/red.png",
39
- "blue": {
40
- "ios": "./assets/icons/blue-ios.png",
41
- "android": "./assets/icons/blue-android.png"
39
+ "blue": { "image": "./assets/icons/blue.png" },
40
+ "split": {
41
+ "ios": "./assets/icons/split-ios.png",
42
+ "android": "./assets/icons/split-android.png"
42
43
  }
43
44
  }
44
45
  ```
45
46
 
47
+ - `image` sets both platforms; `ios` / `android` override it per platform.
48
+
46
49
  Then create a new build (the plugin runs during prebuild):
47
50
 
48
51
  ```sh
@@ -51,15 +54,34 @@ npx expo prebuild --clean
51
54
 
52
55
  ## Usage
53
56
 
57
+ Switch icons at runtime with the `useAppIcon` hook — no per-app persistence needed (the native module is the source of truth). `IconName` is typed to your configured keys:
58
+
59
+ ```tsx
60
+ import { useAppIcon, type IconName } from "expo-app-icon";
61
+
62
+ const ICONS: IconName[] = ["red", "blue"];
63
+
64
+ function IconPicker() {
65
+ const { icon, setIcon, isDefault } = useAppIcon();
66
+
67
+ return ICONS.map((name) => (
68
+ <Pressable key={name} onPress={() => setIcon(name)}>
69
+ <Text>{name}{icon === name ? " ✓" : ""}</Text>
70
+ </Pressable>
71
+ ));
72
+ }
73
+ ```
74
+
75
+ - `icon` — the current icon key, or `null` for the default.
76
+ - `setIcon(name | null)` — switch icons; pass `null` to reset to the default. (The iOS timing fix is built in.)
77
+ - `isDefault` / `isSupported` — handy flags (`isSupported` is `false` on web).
78
+
79
+ Or call the underlying functions directly:
80
+
54
81
  ```ts
55
82
  import { getAppIcon, setAppIcon } from "expo-app-icon";
56
83
 
57
- // Get the name of the current icon ("DEFAULT" when none is set)
58
- const current = getAppIcon();
59
-
60
- // Switch to one of your configured icons by key
84
+ const current = getAppIcon(); // icon name, or "DEFAULT"
61
85
  setAppIcon("red");
62
-
63
- // Reset back to the default icon
64
- setAppIcon(null);
86
+ setAppIcon(null); // reset to default
65
87
  ```
package/build/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { DynamicAppIconRegistry } from "./types";
2
+ export { useAppIcon } from "./useAppIcon";
3
+ export type { UseAppIcon } from "./useAppIcon";
2
4
  /**
3
5
  * Union of the icon keys declared in the plugin config (widened to string when none).
4
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAG,SAAkB,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,GAAG,IAAI,GACpB,QAAQ,GAAG,OAAO,YAAY,GAAG,KAAK,CAExC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,QAAQ,GAAG,OAAO,YAAY,CAE3D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAG,SAAkB,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,GAAG,IAAI,GACpB,QAAQ,GAAG,OAAO,YAAY,GAAG,KAAK,CAExC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,QAAQ,GAAG,OAAO,YAAY,CAE3D"}
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import NativeAppIcon from "./ExpoAppIconChangerModule";
2
+ export { useAppIcon } from "./useAppIcon";
2
3
  /**
3
4
  * Value reported / accepted for the project's default launcher icon.
4
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAOvD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,IAAqB;IAErB,OAAO,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,CAAC,UAAU,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type { DynamicAppIconRegistry } from \"./types\";\nimport NativeAppIcon from \"./ExpoAppIconChangerModule\";\n\n/**\n * Union of the icon keys declared in the plugin config (widened to string when none).\n */\nexport type IconName = DynamicAppIconRegistry[\"IconName\"];\n\n/**\n * Value reported / accepted for the project's default launcher icon.\n */\nexport const DEFAULT_ICON = \"DEFAULT\" as const;\n\n/**\n * Switch the launcher icon at runtime.\n *\n * @param name A configured icon key, or `null` to reset to the default icon.\n * @returns The applied icon name, `\"DEFAULT\"`, or `false` if unsupported.\n */\nexport function setAppIcon(\n name: IconName | null\n): IconName | typeof DEFAULT_ICON | false {\n return NativeAppIcon.setAppIcon(name);\n}\n\n/**\n * Get the currently active icon name, or `\"DEFAULT\"` when none is set.\n */\nexport function getAppIcon(): IconName | typeof DEFAULT_ICON {\n return NativeAppIcon.getAppIcon();\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,IAAqB;IAErB,OAAO,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,CAAC,UAAU,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import type { DynamicAppIconRegistry } from \"./types\";\nimport NativeAppIcon from \"./ExpoAppIconChangerModule\";\n\nexport { useAppIcon } from \"./useAppIcon\";\nexport type { UseAppIcon } from \"./useAppIcon\";\n\n/**\n * Union of the icon keys declared in the plugin config (widened to string when none).\n */\nexport type IconName = DynamicAppIconRegistry[\"IconName\"];\n\n/**\n * Value reported / accepted for the project's default launcher icon.\n */\nexport const DEFAULT_ICON = \"DEFAULT\" as const;\n\n/**\n * Switch the launcher icon at runtime.\n *\n * @param name A configured icon key, or `null` to reset to the default icon.\n * @returns The applied icon name, `\"DEFAULT\"`, or `false` if unsupported.\n */\nexport function setAppIcon(\n name: IconName | null\n): IconName | typeof DEFAULT_ICON | false {\n return NativeAppIcon.setAppIcon(name);\n}\n\n/**\n * Get the currently active icon name, or `\"DEFAULT\"` when none is set.\n */\nexport function getAppIcon(): IconName | typeof DEFAULT_ICON {\n return NativeAppIcon.getAppIcon();\n}\n"]}
@@ -1,6 +1,12 @@
1
1
  import type { DynamicAppIconRegistry } from "./types";
2
+ import type { UseAppIcon } from "./useAppIcon";
3
+ export type { UseAppIcon } from "./useAppIcon";
2
4
  export type IconName = DynamicAppIconRegistry["IconName"];
3
5
  export declare const DEFAULT_ICON: "DEFAULT";
6
+ /**
7
+ * Web has no launcher icon; the hook reports an unsupported, default state.
8
+ */
9
+ export declare function useAppIcon(): UseAppIcon;
4
10
  /**
5
11
  * Web has no launcher icon; this is a no-op that reports failure.
6
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAE1D,eAAO,MAAM,YAAY,EAAG,SAAkB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,GAAG,IAAI,GACrB,QAAQ,GAAG,OAAO,YAAY,GAAG,KAAK,CAGxC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,QAAQ,GAAG,OAAO,YAAY,CAG3D"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAE1D,eAAO,MAAM,YAAY,EAAG,SAAkB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAEvC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,GAAG,IAAI,GACrB,QAAQ,GAAG,OAAO,YAAY,GAAG,KAAK,CAGxC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,QAAQ,GAAG,OAAO,YAAY,CAG3D"}
@@ -1,4 +1,10 @@
1
1
  export const DEFAULT_ICON = "DEFAULT";
2
+ /**
3
+ * Web has no launcher icon; the hook reports an unsupported, default state.
4
+ */
5
+ export function useAppIcon() {
6
+ return { icon: null, setIcon: () => { }, isDefault: true, isSupported: false };
7
+ }
2
8
  /**
3
9
  * Web has no launcher icon; this is a no-op that reports failure.
4
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.js","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB;IAEtB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACpD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type { DynamicAppIconRegistry } from \"./types\";\n\nexport type IconName = DynamicAppIconRegistry[\"IconName\"];\n\nexport const DEFAULT_ICON = \"DEFAULT\" as const;\n\n/**\n * Web has no launcher icon; this is a no-op that reports failure.\n */\nexport function setAppIcon(\n _name: IconName | null\n): IconName | typeof DEFAULT_ICON | false {\n console.error(\"setAppIcon is not supported on web\");\n return false;\n}\n\n/**\n * Web has no launcher icon; always reports the default.\n */\nexport function getAppIcon(): IconName | typeof DEFAULT_ICON {\n console.error(\"getAppIcon is not supported on web\");\n return DEFAULT_ICON;\n}\n"]}
1
+ {"version":3,"file":"index.web.js","sourceRoot":"","sources":["../src/index.web.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,YAAY,GAAG,SAAkB,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB;IAEtB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACpD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type { DynamicAppIconRegistry } from \"./types\";\nimport type { UseAppIcon } from \"./useAppIcon\";\n\nexport type { UseAppIcon } from \"./useAppIcon\";\n\nexport type IconName = DynamicAppIconRegistry[\"IconName\"];\n\nexport const DEFAULT_ICON = \"DEFAULT\" as const;\n\n/**\n * Web has no launcher icon; the hook reports an unsupported, default state.\n */\nexport function useAppIcon(): UseAppIcon {\n return { icon: null, setIcon: () => {}, isDefault: true, isSupported: false };\n}\n\n/**\n * Web has no launcher icon; this is a no-op that reports failure.\n */\nexport function setAppIcon(\n _name: IconName | null\n): IconName | typeof DEFAULT_ICON | false {\n console.error(\"setAppIcon is not supported on web\");\n return false;\n}\n\n/**\n * Web has no launcher icon; always reports the default.\n */\nexport function getAppIcon(): IconName | typeof DEFAULT_ICON {\n console.error(\"getAppIcon is not supported on web\");\n return DEFAULT_ICON;\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { DynamicAppIconRegistry } from "./types";
2
+ type IconName = DynamicAppIconRegistry["IconName"];
3
+ export type UseAppIcon = {
4
+ /** Current icon; `null` means the default icon. */
5
+ icon: IconName | null;
6
+ /** Set the icon, or pass `null` to reset to the default. */
7
+ setIcon: (name: IconName | null) => void;
8
+ /** Whether the current icon is the default. */
9
+ isDefault: boolean;
10
+ /** Whether changing the icon is supported on this platform. */
11
+ isSupported: boolean;
12
+ };
13
+ /**
14
+ * React hook for the app's launcher icon. The native module is the source of
15
+ * truth (the value survives the app restart an Android change triggers), so no
16
+ * extra persistence is needed.
17
+ */
18
+ export declare function useAppIcon(): UseAppIcon;
19
+ export {};
20
+ //# sourceMappingURL=useAppIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAppIcon.d.ts","sourceRoot":"","sources":["../src/useAppIcon.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,KAAK,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAWnD,MAAM,MAAM,UAAU,GAAG;IACvB,mDAAmD;IACnD,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,4DAA4D;IAC5D,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAuBvC"}
@@ -0,0 +1,40 @@
1
+ import { useCallback, useState } from "react";
2
+ import NativeAppIcon from "./ExpoAppIconChangerModule";
3
+ /**
4
+ * Read the current icon from the native module, normalising the default
5
+ * (`"DEFAULT"`) to `null`.
6
+ */
7
+ function readCurrentIcon() {
8
+ const current = NativeAppIcon.getAppIcon();
9
+ return current === "DEFAULT" ? null : current;
10
+ }
11
+ /**
12
+ * React hook for the app's launcher icon. The native module is the source of
13
+ * truth (the value survives the app restart an Android change triggers), so no
14
+ * extra persistence is needed.
15
+ */
16
+ export function useAppIcon() {
17
+ const [icon, setIconState] = useState(() => {
18
+ try {
19
+ return readCurrentIcon();
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ });
25
+ const setIcon = useCallback((name) => {
26
+ // Defer so any parent re-render (e.g. a menu closing) settles before the
27
+ // native call, which can present a system alert / restart the app.
28
+ setTimeout(() => {
29
+ try {
30
+ NativeAppIcon.setAppIcon(name);
31
+ setIconState(name);
32
+ }
33
+ catch (error) {
34
+ console.error("Failed to set app icon:", error);
35
+ }
36
+ }, 0);
37
+ }, []);
38
+ return { icon, setIcon, isDefault: icon === null, isSupported: true };
39
+ }
40
+ //# sourceMappingURL=useAppIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAppIcon.js","sourceRoot":"","sources":["../src/useAppIcon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAKvD;;;GAGG;AACH,SAAS,eAAe;IACtB,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;IAC3C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,OAAoB,CAAC;AAC9D,CAAC;AAaD;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAkB,GAAG,EAAE;QAC1D,IAAI,CAAC;YACH,OAAO,eAAe,EAAE,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,IAAqB,EAAE,EAAE;QACpD,yEAAyE;QACzE,mEAAmE;QACnE,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC;gBACH,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAC/B,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,KAAK,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACxE,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\n\nimport NativeAppIcon from \"./ExpoAppIconChangerModule\";\nimport type { DynamicAppIconRegistry } from \"./types\";\n\ntype IconName = DynamicAppIconRegistry[\"IconName\"];\n\n/**\n * Read the current icon from the native module, normalising the default\n * (`\"DEFAULT\"`) to `null`.\n */\nfunction readCurrentIcon(): IconName | null {\n const current = NativeAppIcon.getAppIcon();\n return current === \"DEFAULT\" ? null : (current as IconName);\n}\n\nexport type UseAppIcon = {\n /** Current icon; `null` means the default icon. */\n icon: IconName | null;\n /** Set the icon, or pass `null` to reset to the default. */\n setIcon: (name: IconName | null) => void;\n /** Whether the current icon is the default. */\n isDefault: boolean;\n /** Whether changing the icon is supported on this platform. */\n isSupported: boolean;\n};\n\n/**\n * React hook for the app's launcher icon. The native module is the source of\n * truth (the value survives the app restart an Android change triggers), so no\n * extra persistence is needed.\n */\nexport function useAppIcon(): UseAppIcon {\n const [icon, setIconState] = useState<IconName | null>(() => {\n try {\n return readCurrentIcon();\n } catch {\n return null;\n }\n });\n\n const setIcon = useCallback((name: IconName | null) => {\n // Defer so any parent re-render (e.g. a menu closing) settles before the\n // native call, which can present a system alert / restart the app.\n setTimeout(() => {\n try {\n NativeAppIcon.setAppIcon(name);\n setIconState(name);\n } catch (error) {\n console.error(\"Failed to set app icon:\", error);\n }\n }, 0);\n }, []);\n\n return { icon, setIcon, isDefault: icon === null, isSupported: true };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-app-icon",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Programmatically change the app icon at runtime in Expo, with Android adaptive-icon support.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -2,7 +2,8 @@ import type { AppleIconVariant, IconConfig, IconPluginInput, IconSet, ResolvedIc
2
2
  /**
3
3
  * Coerce whatever the user placed in app config into a normalized icon map.
4
4
  * A bare array of image paths is expanded to keyed entries that share the same
5
- * image for both platforms.
5
+ * image for both platforms. For the object form, the `image` convenience is
6
+ * expanded to `ios`/`android` (which override it).
6
7
  */
7
8
  export declare function normalizeIconSet(input: IconPluginInput): IconSet;
8
9
  /**
@@ -14,7 +14,8 @@ const APPLE_ICON_BLUEPRINTS = [
14
14
  /**
15
15
  * Coerce whatever the user placed in app config into a normalized icon map.
16
16
  * A bare array of image paths is expanded to keyed entries that share the same
17
- * image for both platforms.
17
+ * image for both platforms. For the object form, the `image` convenience is
18
+ * expanded to `ios`/`android` (which override it).
18
19
  */
19
20
  function normalizeIconSet(input) {
20
21
  if (Array.isArray(input)) {
@@ -25,11 +26,18 @@ function normalizeIconSet(input) {
25
26
  }
26
27
  if (!input)
27
28
  return {};
28
- return Object.fromEntries(Object.entries(input).map(([key, value]) => [
29
- key,
29
+ return Object.fromEntries(Object.entries(input).map(([key, value]) => {
30
30
  // String shorthand: one image path used for both platforms.
31
- typeof value === "string" ? { ios: value, android: value } : value,
32
- ]));
31
+ if (typeof value === "string") {
32
+ return [key, { ios: value, android: value }];
33
+ }
34
+ const { image, ios, android } = value;
35
+ const config = {
36
+ ios: ios ?? image,
37
+ android: android ?? image,
38
+ };
39
+ return [key, config];
40
+ }));
33
41
  }
34
42
  /**
35
43
  * Build the list of Apple icon variants to emit for the given tablet support.
@@ -26,13 +26,14 @@ const withDynamicIcon = (config, input) => {
26
26
  return config;
27
27
  };
28
28
  /**
29
- * Rewrite the shipped `IconName` union in `build/types.d.ts` to the configured
30
- * icon keys, so `getAppIcon()` / `setAppIcon()` are typed to this project.
29
+ * Rewrite the `IconName` union in the shipped `build/types.d.ts` so
30
+ * `getAppIcon()` / `setAppIcon()` / `useAppIcon()` are typed to the configured
31
+ * keys. The types file only exists in a built package, so the write is
32
+ * best-effort.
31
33
  */
32
34
  function withTypedIconNames(config, icons) {
33
- const union = Object.keys(icons)
34
- .map((name) => `"${name}"`)
35
- .join(" | ") || "string";
35
+ const names = Object.keys(icons);
36
+ const union = names.map((name) => `"${name}"`).join(" | ") || "string";
36
37
  const typesFile = path_1.default.join(PACKAGE_ROOT, "build", "types.d.ts");
37
38
  try {
38
39
  const current = fs_1.default.readFileSync(typesFile, "utf8");
@@ -1,5 +1,6 @@
1
1
  /**
2
- * A single icon entry as declared in the plugin config.
2
+ * A normalized icon entry as used everywhere internally (the `image`
3
+ * convenience has been expanded to `ios`/`android`).
3
4
  */
4
5
  export type IconConfig = {
5
6
  /**
@@ -16,11 +17,19 @@ export type IconConfig = {
16
17
  * fully-resolved object form).
17
18
  */
18
19
  export type IconSet = Record<string, IconConfig>;
20
+ /**
21
+ * The object form a consumer may declare. Adds `image` as a convenience that
22
+ * sets both platforms (`ios`/`android` override it when present).
23
+ */
24
+ export type IconInputObject = IconConfig & {
25
+ /** Single image used for both platforms (shorthand for ios + android). */
26
+ image?: string;
27
+ };
19
28
  /**
20
29
  * An icon as declared by the user: either a single image path used for both
21
- * platforms (`"red": "./assets/red.png"`) or the explicit per-platform object.
30
+ * platforms (`"red": "./assets/red.png"`) or the explicit object form.
22
31
  */
23
- export type IconInput = string | IconConfig;
32
+ export type IconInput = string | IconInputObject;
24
33
  /**
25
34
  * What the plugin accepts from the app config: a keyed map (string shorthand or
26
35
  * object per icon), a bare list of image paths, or nothing.