bundo-appgen 0.0.1-beta.7

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 (171) hide show
  1. package/README.md +253 -0
  2. package/bin.mjs +21 -0
  3. package/lib/bin/bin.mjs +1141 -0
  4. package/lib/bin/plugin-sandbox-runner.mjs +105 -0
  5. package/lib/commonjs/index.js +125 -0
  6. package/lib/module/chunk-bhc5nymd.js +12 -0
  7. package/lib/module/chunk-dvyy3g4j.js +25 -0
  8. package/lib/module/chunk-ynqw05p0.js +70 -0
  9. package/lib/module/config/apple/create-osx-appiconset.js +6 -0
  10. package/lib/module/config/apple/index.js +7 -0
  11. package/lib/module/config/index.js +8 -0
  12. package/lib/module/index.js +8 -0
  13. package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts +3 -0
  14. package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts.map +1 -0
  15. package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts +42 -0
  16. package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts.map +1 -0
  17. package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts +21 -0
  18. package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts.map +1 -0
  19. package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts +13 -0
  20. package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts.map +1 -0
  21. package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts +5 -0
  22. package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts.map +1 -0
  23. package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts +2 -0
  24. package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts.map +1 -0
  25. package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts +2 -0
  26. package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts.map +1 -0
  27. package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts +2 -0
  28. package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts.map +1 -0
  29. package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts +6 -0
  30. package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts.map +1 -0
  31. package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts +2 -0
  32. package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts.map +1 -0
  33. package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts +9 -0
  34. package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts.map +1 -0
  35. package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts +58 -0
  36. package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts.map +1 -0
  37. package/lib/typescript/config/apple/asset-catalog-format/index.d.ts +5 -0
  38. package/lib/typescript/config/apple/asset-catalog-format/index.d.ts.map +1 -0
  39. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -0
  40. package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -0
  41. package/lib/typescript/config/apple/asset-catalogs.d.ts +73 -0
  42. package/lib/typescript/config/apple/asset-catalogs.d.ts.map +1 -0
  43. package/lib/typescript/config/apple/create-osx-appiconset.d.mts +72 -0
  44. package/lib/typescript/config/apple/create-osx-appiconset.d.mts.map +1 -0
  45. package/lib/typescript/config/apple/data.d.ts +103 -0
  46. package/lib/typescript/config/apple/data.d.ts.map +1 -0
  47. package/lib/typescript/config/apple/index.d.mts +8 -0
  48. package/lib/typescript/config/apple/index.d.mts.map +1 -0
  49. package/lib/typescript/config/apple/info-plist-value.d.ts +8 -0
  50. package/lib/typescript/config/apple/info-plist-value.d.ts.map +1 -0
  51. package/lib/typescript/config/apple/info-plist.d.ts +4 -0
  52. package/lib/typescript/config/apple/info-plist.d.ts.map +1 -0
  53. package/lib/typescript/config/apple/string-catalog.d.ts +2 -0
  54. package/lib/typescript/config/apple/string-catalog.d.ts.map +1 -0
  55. package/lib/typescript/config/data.d.ts +50 -0
  56. package/lib/typescript/config/data.d.ts.map +1 -0
  57. package/lib/typescript/config/index.d.mts +5 -0
  58. package/lib/typescript/config/index.d.mts.map +1 -0
  59. package/lib/typescript/config/plugin-item.d.ts +2 -0
  60. package/lib/typescript/config/plugin-item.d.ts.map +1 -0
  61. package/lib/typescript/config/plugin-registry.d.ts +3 -0
  62. package/lib/typescript/config/plugin-registry.d.ts.map +1 -0
  63. package/lib/typescript/index.d.mts +3 -0
  64. package/lib/typescript/index.d.mts.map +1 -0
  65. package/lib/typescript/plugin/apple/context.d.ts +28 -0
  66. package/lib/typescript/plugin/apple/context.d.ts.map +1 -0
  67. package/lib/typescript/plugin/apple/files.d.ts +7 -0
  68. package/lib/typescript/plugin/apple/files.d.ts.map +1 -0
  69. package/lib/typescript/plugin/apple/index.d.ts +6 -0
  70. package/lib/typescript/plugin/apple/index.d.ts.map +1 -0
  71. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +5 -0
  72. package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +1 -0
  73. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +11 -0
  74. package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +1 -0
  75. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +7 -0
  76. package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +1 -0
  77. package/lib/typescript/plugin/context.d.ts +9 -0
  78. package/lib/typescript/plugin/context.d.ts.map +1 -0
  79. package/lib/typescript/plugin/index.d.ts +3 -0
  80. package/lib/typescript/plugin/index.d.ts.map +1 -0
  81. package/package.json +49 -0
  82. package/src/_bin/_global-vars/_global-vars.mts +47 -0
  83. package/src/_bin/_global-vars/index.mts +30 -0
  84. package/src/_bin/_main/_check-config-validity.mts +94 -0
  85. package/src/_bin/_main/_evaluate-plugin-registry.mts +181 -0
  86. package/src/_bin/_main/_exec-plugin-runner/_spawn-plugin-sandbox-runner.mts +149 -0
  87. package/src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts +92 -0
  88. package/src/_bin/_main/_exec-plugin-runner/index.mts +1 -0
  89. package/src/_bin/_main/_get-config.mts +64 -0
  90. package/src/_bin/_main/_helpers/config/get-name.mts +24 -0
  91. package/src/_bin/_main/_helpers/config/get-project-name.mts +27 -0
  92. package/src/_bin/_main/_helpers/config/index.mts +2 -0
  93. package/src/_bin/_main/_helpers/index.mts +2 -0
  94. package/src/_bin/_main/_helpers/platform/compatibility-error.mts +7 -0
  95. package/src/_bin/_main/_helpers/platform/data.ts +9 -0
  96. package/src/_bin/_main/_helpers/platform/get-data.mts +48 -0
  97. package/src/_bin/_main/_helpers/platform/index.mts +4 -0
  98. package/src/_bin/_main/_helpers/platform/is-compatible.mts +30 -0
  99. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +223 -0
  100. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +241 -0
  101. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/appearances.mts +24 -0
  102. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/idiom.mts +22 -0
  103. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/compression-type.mts +15 -0
  104. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/display-gamut.mts +12 -0
  105. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/index.mts +3 -0
  106. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/language-direction.mts +12 -0
  107. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/index.mts +3 -0
  108. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +54 -0
  109. package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/index.mts +1 -0
  110. package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +134 -0
  111. package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/index.mts +1 -0
  112. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +62 -0
  113. package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile.mts +31 -0
  114. package/src/_bin/_main/_init-template/_init-apple/_mod-files/index.mts +1 -0
  115. package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +17 -0
  116. package/src/_bin/_main/_init-template/_init-apple/index.mts +1 -0
  117. package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +81 -0
  118. package/src/_bin/_main/_init-template/index.mts +1 -0
  119. package/src/_bin/_main/_init-template/init-template.mts +39 -0
  120. package/src/_bin/_main/_mod-plugin/index.mts +1 -0
  121. package/src/_bin/_main/_mod-plugin/mod-plugin.mts +77 -0
  122. package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +86 -0
  123. package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +216 -0
  124. package/src/_bin/_main/_xcodegen/_create-project-spec/index.mts +1 -0
  125. package/src/_bin/_main/_xcodegen/_mod-known-regions/index.ts +1 -0
  126. package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +52 -0
  127. package/src/_bin/_main/_xcodegen/index.mts +1 -0
  128. package/src/_bin/_main/_xcodegen/xcodegen.mts +46 -0
  129. package/src/_bin/_main/index.mts +1 -0
  130. package/src/_bin/_main/main.mts +160 -0
  131. package/src/_bin/bin.mts +68 -0
  132. package/src/_bin/plugin-sandbox-runner/_exec-plugins.mts +135 -0
  133. package/src/_bin/plugin-sandbox-runner/argv-json.ts +20 -0
  134. package/src/_bin/plugin-sandbox-runner/evaluated-plugin-registry.ts +12 -0
  135. package/src/_bin/plugin-sandbox-runner/index.ts +3 -0
  136. package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +33 -0
  137. package/src/_bin/plugin-sandbox-runner/plugin-sandbox-runner.mts +68 -0
  138. package/src/config/apple/asset-catalog-format/app-icon/index.ts +2 -0
  139. package/src/config/apple/asset-catalog-format/app-icon/set-type.ts +59 -0
  140. package/src/config/apple/asset-catalog-format/app-icon/size.ts +37 -0
  141. package/src/config/apple/asset-catalog-format/appearances.ts +10 -0
  142. package/src/config/apple/asset-catalog-format/idiom.ts +16 -0
  143. package/src/config/apple/asset-catalog-format/image/color-space.ts +3 -0
  144. package/src/config/apple/asset-catalog-format/image/compression-type.ts +6 -0
  145. package/src/config/apple/asset-catalog-format/image/display-gamut.ts +3 -0
  146. package/src/config/apple/asset-catalog-format/image/index.ts +6 -0
  147. package/src/config/apple/asset-catalog-format/image/language-direction.ts +3 -0
  148. package/src/config/apple/asset-catalog-format/image/scale.ts +11 -0
  149. package/src/config/apple/asset-catalog-format/image/set-type.ts +85 -0
  150. package/src/config/apple/asset-catalog-format/index.ts +4 -0
  151. package/src/config/apple/asset-catalogs-namespaced.ts +13 -0
  152. package/src/config/apple/asset-catalogs.ts +76 -0
  153. package/src/config/apple/create-osx-appiconset.mts +135 -0
  154. package/src/config/apple/data.ts +123 -0
  155. package/src/config/apple/index.mts +7 -0
  156. package/src/config/apple/info-plist-value.ts +16 -0
  157. package/src/config/apple/info-plist.ts +6 -0
  158. package/src/config/apple/string-catalog.ts +0 -0
  159. package/src/config/data.ts +59 -0
  160. package/src/config/index.mts +4 -0
  161. package/src/config/plugin-item.ts +4 -0
  162. package/src/config/plugin-registry.ts +5 -0
  163. package/src/index.mts +2 -0
  164. package/src/plugin/apple/context.ts +68 -0
  165. package/src/plugin/apple/files.ts +14 -0
  166. package/src/plugin/apple/index.ts +5 -0
  167. package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +9 -0
  168. package/src/plugin/apple/pod-spec-source-from-git.ts +13 -0
  169. package/src/plugin/apple/pod-spec-source-from-local.ts +6 -0
  170. package/src/plugin/context.ts +12 -0
  171. package/src/plugin/index.ts +2 -0
@@ -0,0 +1,12 @@
1
+ import type {
2
+ Plugin,
3
+ } from "../../index.mts"
4
+
5
+ export type EvaluatedPluginRegistry = {
6
+ /**
7
+ * This is the name registered in the plugin registry.
8
+ */
9
+ name: string,
10
+ mainPath: string,
11
+ parameter: Plugin.Context["parameter"],
12
+ }[]
@@ -0,0 +1,3 @@
1
+ export type * from "./argv-json"
2
+ export type * from "./evaluated-plugin-registry"
3
+ export type * from "./plugin-runner-context-result"
@@ -0,0 +1,33 @@
1
+ import type {
2
+ Plugin,
3
+ } from "../../index.mts"
4
+
5
+ export interface PluginRunnerContextResult extends Omit<Plugin.Context, "parameter"> {
6
+ }
7
+
8
+ // export interface PluginRunnerContextResult extends Omit<Plugin.Context, "parameter" | "macos"> {
9
+ // macos: Omit<
10
+ // Plugin.Context["macos"],
11
+ // | "files"
12
+ // > & {
13
+ // files: Omit<
14
+ // Plugin.Apple.Files,
15
+ // | "add"
16
+ // | "Project"
17
+ // > & {
18
+ // Project: Omit<
19
+ // Plugin.Apple.Files["Project"],
20
+ // | "add"
21
+ // > & {
22
+ // pluginFiles: {
23
+ // filename: string,
24
+ // source: string,
25
+ // }[],
26
+ // },
27
+ // pluginFiles: {
28
+ // filename: string,
29
+ // source: string,
30
+ // }[],
31
+ // }
32
+ // }
33
+ // }
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+
3
+ import yargs from "yargs"
4
+ import * as YargsHelpers from "yargs/helpers"
5
+
6
+ import {
7
+ execPlugins,
8
+ } from "./_exec-plugins.mts"
9
+
10
+ import type {
11
+ ArgvJSON,
12
+ } from "./argv-json.ts"
13
+
14
+ // Please, only allow permission in this script for
15
+
16
+ // - File System read for:
17
+ // - <projectDirectory>/macos/<projectName>/AppDelegate.swift
18
+ // - <projectDirectory>/macos/Podfile
19
+
20
+ try {
21
+
22
+ const
23
+ argv =
24
+ yargs(YargsHelpers.hideBin(process.argv))
25
+ .options({
26
+ "json": {
27
+ type: "string",
28
+ description: "See bundo-appgen/src/_bin/plugin-sandbox-runner/_argv-json.ts",
29
+ },
30
+ })
31
+ .parseSync(),
32
+
33
+ argvJSON =
34
+ JSON.parse(argv.json || "") as unknown as ArgvJSON
35
+
36
+ if(!argvJSON.evaluatedPluginRegistry?.length) {
37
+ // we already do a preventing to exec this plugin-sandbox-runner.mts
38
+ // if plugin registry is empty.
39
+ // Just in case, if we don't.
40
+ throw new Error("Not a valid Evaluated Plugin Registry array.")
41
+ }
42
+
43
+ const result = await execPlugins({
44
+ projectDirectory: argvJSON.projectDirectory,
45
+ projectName: argvJSON.projectName,
46
+ registry: argvJSON.evaluatedPluginRegistry,
47
+ })
48
+
49
+ // send message through IPC channel
50
+ process.send?.(
51
+ JSON.stringify({
52
+ ...result,
53
+ messageID: argvJSON.messageID,
54
+ }),
55
+ )
56
+
57
+ } catch(err) {
58
+ if(err instanceof Error && err.message) {
59
+ console.error(
60
+ "\x1b[31mPlugin Sandbox Runner Error\x1b[0m: " +
61
+ err.message,
62
+ )
63
+ process.exitCode = 1
64
+ } else {
65
+ console.error("Unknown error. Please report it to https://github.com/RakaDoank/bundo.rn", { cause: err })
66
+ process.exitCode = 1
67
+ }
68
+ }
@@ -0,0 +1,2 @@
1
+ export type * from "./set-type"
2
+ export type * from "./size"
@@ -0,0 +1,59 @@
1
+ import type {
2
+ Appearances,
3
+ } from "../appearances"
4
+
5
+ import type {
6
+ Idiom,
7
+ } from "../idiom"
8
+
9
+ import type * as Image from "../image"
10
+
11
+ import type {
12
+ Size,
13
+ } from "./size"
14
+
15
+ export interface SetType {
16
+
17
+ name: string,
18
+
19
+ images: {
20
+ // In Xcode, it generates "appearances" with array value, even the image is only one appearance variant per image.
21
+ appearances?: Appearances,
22
+ "display-gamut"?: Image.DisplayGamut,
23
+ /**
24
+ * @default "universal"
25
+ */
26
+ idiom?: Idiom,
27
+ /**
28
+ * The filename in the path will be used as the filename property for the `Contents.json`.
29
+ * Currently only support for PNG file.
30
+ */
31
+ path: string,
32
+ /**
33
+ * - 16x16 - An OS X icon
34
+ * - 20x20 - An iPhone or iPad notification icon
35
+ * - 24x24 - A 38mm Apple Watch notification center icon
36
+ * - 27.5x27.5 - A 42mm Apple Watch notification center icon
37
+ * - 29x29 - An iPhone or iPad settings icon for iOS 7 or later. An Apple Watch companion settings icon
38
+ * - 32x32 - An OS X icon
39
+ * - 40x40 - An iPhone or iPad Spotlight search results icon on iOS 7 or later. The main Apple Watch app icon.
40
+ * - 44x44 - An Apple Watch long-look notification icon
41
+ * - 60x60 - The main iPhone app icon for iOS 7 or later
42
+ * - 76x76 - The main iPad app icon for iOS 7 or later
43
+ * - 83.5x83.5 - The main iPad Pro app icon
44
+ * - 86x86 - A 38mm Apple Watch short-look notification icon
45
+ * - 98x98 - A 42mm Apple Watch short-look notification icon
46
+ * - 128x128 - An OS X icon
47
+ * - 256x256 - An OS X icon
48
+ * - 512x512 - An OS X icon
49
+ * - 1024x1024 - The App Store icon
50
+ */
51
+ size: Size,
52
+
53
+ // Even though from this documentation https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/AppIconType.html
54
+ // states that `appiconset` has `scale`, but I never find it in Xcode inspector.
55
+ // However, Xcode still generate the Contents.json with scale property.
56
+ scale?: Exclude<Image.Scale, "3x">
57
+ }[],
58
+
59
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * - 16x16 - An OS X icon
3
+ * - 20x20 - An iPhone or iPad notification icon
4
+ * - 24x24 - A 38mm Apple Watch notification center icon
5
+ * - 27.5x27.5 - A 42mm Apple Watch notification center icon
6
+ * - 29x29 - An iPhone or iPad settings icon for iOS 7 or later. An Apple Watch companion settings icon
7
+ * - 32x32 - An OS X icon
8
+ * - 40x40 - An iPhone or iPad Spotlight search results icon on iOS 7 or later. The main Apple Watch app icon.
9
+ * - 44x44 - An Apple Watch long-look notification icon
10
+ * - 60x60 - The main iPhone app icon for iOS 7 or later
11
+ * - 76x76 - The main iPad app icon for iOS 7 or later
12
+ * - 83.5x83.5 - The main iPad Pro app icon
13
+ * - 86x86 - A 38mm Apple Watch short-look notification icon
14
+ * - 98x98 - A 42mm Apple Watch short-look notification icon
15
+ * - 128x128 - An OS X icon
16
+ * - 256x256 - An OS X icon
17
+ * - 512x512 - An OS X icon
18
+ * - 1024x1024 - The App Store icon
19
+ */
20
+ export type Size =
21
+ | "16x16"
22
+ | "20x20"
23
+ | "24x24"
24
+ | "27.5x27.5"
25
+ | "29x29"
26
+ | "32x32"
27
+ | "40x40"
28
+ | "44x44"
29
+ | "60x60"
30
+ | "76x76"
31
+ | "83.5x83.5"
32
+ | "86x86"
33
+ | "98x98"
34
+ | "128x128"
35
+ | "256x256"
36
+ | "512x512"
37
+ | "1024x1024"
@@ -0,0 +1,10 @@
1
+ /**
2
+ * We mock this value from Xcode.
3
+ * Xcode generates "appearances" with array value, even the image is only one appearance variant per image.
4
+ *
5
+ * Probably, they have plan for the appearances in the future.
6
+ */
7
+ export type Appearances = [{
8
+ appearance: "luminosity" | "contrast",
9
+ value: "light" | "dark",
10
+ }]
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/ImageSetType.html#//apple_ref/doc/uid/TP40015170-CH25-SW2
3
+ */
4
+ export type Idiom =
5
+ | "appLauncher"
6
+ | "companionSettings"
7
+ | "ios-marketing"
8
+ | "iphone"
9
+ | "ipad"
10
+ | "mac"
11
+ | "notificationCenter"
12
+ | "quickLook"
13
+ | "tv"
14
+ | "universal"
15
+ | "watch"
16
+ | "watch-marketing"
@@ -0,0 +1,3 @@
1
+ export type ColorSpace =
2
+ | "sRGB"
3
+ | "display-P3"
@@ -0,0 +1,6 @@
1
+ export type CompressionType =
2
+ | "automatic"
3
+ | "gpu-optimized-best"
4
+ | "gpu-optimized-smallest"
5
+ | "lossless"
6
+ | "lossy"
@@ -0,0 +1,3 @@
1
+ export type DisplayGamut =
2
+ | "sRGB"
3
+ | "display-P3"
@@ -0,0 +1,6 @@
1
+ // export type * from "./color-space"
2
+ export type * from "./compression-type"
3
+ export type * from "./display-gamut"
4
+ export type * from "./language-direction"
5
+ export type * from "./scale"
6
+ export type * from "./set-type"
@@ -0,0 +1,3 @@
1
+ export type LanguageDirection =
2
+ | "left-to-right"
3
+ | "right-to-left"
@@ -0,0 +1,11 @@
1
+ /**
2
+ * - 1x - Targeted for unscaled displays
3
+ * - 2x - Targeted for Retina displays
4
+ * - 3x - Targeted for Retina displays with higher density such as those on the iPhone 6 Plus
5
+ *
6
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/ImageSetType.html#//apple_ref/doc/uid/TP40015170-CH25-SW3
7
+ */
8
+ export type Scale =
9
+ | "1x"
10
+ | "2x"
11
+ | "3x"
@@ -0,0 +1,85 @@
1
+ import type {
2
+ Appearances,
3
+ } from "../appearances"
4
+
5
+ import type {
6
+ Idiom,
7
+ } from "../idiom"
8
+
9
+ // import type {
10
+ // ColorSpace,
11
+ // } from "./color-space"
12
+
13
+ import type {
14
+ CompressionType,
15
+ } from "./compression-type"
16
+
17
+ import type {
18
+ DisplayGamut,
19
+ } from "./display-gamut"
20
+
21
+ import type {
22
+ LanguageDirection,
23
+ } from "./language-direction"
24
+
25
+ import type {
26
+ Scale,
27
+ } from "./scale"
28
+
29
+ /**
30
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/ImageSetType.html
31
+ */
32
+ export interface SetType {
33
+
34
+ /**
35
+ * This is the actual image name and also be used for the .imageset folder name.
36
+ *
37
+ * For example, if the name is `FooBar`, a "FooBar.imageset" directory will be created under our Asset Catalogs directory template.
38
+ * You can check later at "macos/&lt;Project&gt;/Assets.xcassets/FooBar.imageset".
39
+ *
40
+ * Then, you can access use the image in React Native by the name,
41
+ * ```tsx
42
+ * import { Image } from "react-native"
43
+ *
44
+ * export function Component() {
45
+ * return (<>
46
+ * <Image source={{ uri: "FooBar" }}/>
47
+ *
48
+ * // if a namespace is given
49
+ * <Image source={{ uri: "WithNamespace/FooBar" }}/>
50
+ * </>)
51
+ * }
52
+ * ```
53
+ */
54
+ name: string,
55
+
56
+ images: {
57
+ // In Xcode, it generates "appearances" with array value, even the image is only one appearance variant per image.
58
+ appearances?: Appearances,
59
+ // We cannot find "color-space" option in Xcode imageset inspector
60
+ // "color-space"?: ColorSpace,
61
+ "compression-type"?: CompressionType,
62
+ "display-gamut"?: DisplayGamut,
63
+ /**
64
+ * @default "universal"
65
+ */
66
+ idiom?: Idiom,
67
+ languageDirection?: LanguageDirection,
68
+ /**
69
+ * The filename in the path will be used as the filename property for the `Contents.json`.
70
+ *
71
+ * The file itself supported for
72
+ * - .heif
73
+ * - .heic
74
+ * - .jpg
75
+ * - .jpeg
76
+ * - .png
77
+ */
78
+ path: string,
79
+ /**
80
+ * @default "1x"
81
+ */
82
+ scale?: Scale,
83
+ }[],
84
+
85
+ }
@@ -0,0 +1,4 @@
1
+ export type * as AppIcon from "./app-icon"
2
+ export type * from "./appearances"
3
+ export type * from "./idiom"
4
+ export type * as Image from "./image"
@@ -0,0 +1,13 @@
1
+ import type {
2
+ AssetCatalogs,
3
+ } from "./asset-catalogs"
4
+
5
+ export type AssetCatalogsNamespaced =
6
+ & AssetCatalogs
7
+ & {
8
+ /**
9
+ * Stated by Xcode
10
+ * "The app icon set must be a top level object in the asset."
11
+ */
12
+ [Namespace in string]?: Omit<AssetCatalogs | AssetCatalogsNamespaced, "appiconsets">
13
+ }
@@ -0,0 +1,76 @@
1
+ import type * as AssetCatalogFormat from "./asset-catalog-format"
2
+
3
+ /**
4
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/AssetTypes.html
5
+ */
6
+ export interface AssetCatalogs {
7
+
8
+ /**
9
+ * Provide app icons in Asset Catalogs.
10
+ *
11
+ * Be aware! This configuration doesn't prevent you to provide incorrect or invalid app icon catalog data.
12
+ * You may prefer to use our helper such as `Config.Apple.createOSXappiconset()` to provide correct data.
13
+ *
14
+ * If you want to learn it, you can still use Xcode to provide app icon in Asset Catalogs,
15
+ * and see how Xcode instructs you to provide correct image size for each platform, along with its variant.
16
+ *
17
+ * Based on Apple documentation:
18
+ * - iOS, iPadOS, tvOS, and watchOS apps can auto-generate all icon variations from a single 1024×1024 pixel image.
19
+ * - For macOS and tvOS, you need to supply an asset for each size. At a minimum, you must provide all OS X icon sizes: 16x16, 32x32, 128x128, 256x256, 512x512, and 1024x1024.
20
+ * - For visionOS, you need to supply a single 1024x1024 pixel asset
21
+ *
22
+ * @see https://developer.apple.com/documentation/xcode/configuring-your-app-icon
23
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/AppIconType.html
24
+ */
25
+ appiconsets?: AssetCatalogFormat.AppIcon.SetType[],
26
+
27
+ /**
28
+ * Provide image assets in the {@link https://developer.apple.com/documentation/xcode/managing-assets-with-asset-catalogs|Asset Catalogs}.
29
+ *
30
+ * For React Native side, this is useful if you want to bundle your image files by the system, instead of using raw loose file next to the JavaScript bundle, so the system ships only the scale a device needs.
31
+ *
32
+ * ```tsx
33
+ * // bundo.config.mjs
34
+ * export default {
35
+ * macos: {
36
+ * assetCatalogs: {
37
+ * imagesets: [{
38
+ * name: "FooImg",
39
+ * images: [{
40
+ * path: "./path/to/your-image.png",
41
+ * scale: "1x",
42
+ * }, {
43
+ * path: "./path/to/your-image-much-larger-scale.png",
44
+ * scale: "2x",
45
+ * }],
46
+ * }],
47
+ *
48
+ * BarName: {
49
+ * imagesets: [{
50
+ * name: "MyImage",
51
+ * images: [{
52
+ * path: "./path/to/my-image.png"
53
+ * }],
54
+ * }]
55
+ * },
56
+ * }
57
+ * },
58
+ * }
59
+ * // ---
60
+ *
61
+ * // React Native
62
+ * import { Image } from "react-native"
63
+ *
64
+ * export function Component() {
65
+ * return (<>
66
+ * <Image source={{ uri: "FooImg" }}/>
67
+ * <Image source={{ uri: "BarName/MyImage" }}/>
68
+ * </>)
69
+ * }
70
+ * ```
71
+ *
72
+ * @see https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/ImageSetType.html
73
+ */
74
+ imagesets?: AssetCatalogFormat.Image.SetType[],
75
+
76
+ }
@@ -0,0 +1,135 @@
1
+ import type * as AssetCatalogFormat from "./asset-catalog-format/index.ts"
2
+
3
+ /**
4
+ * An helper to provide correct OS X app icon in the catalog.
5
+ * You can provide a single image for 1024x1024 size in the `images` property.
6
+ * However, if you want to customize your app’s icon variants, such as to show more or less detail at a specific size, you can provide individual assets for the variations.
7
+ */
8
+ export function createOSXappiconset(
9
+ data: {
10
+ name: string,
11
+ images: OSXappiconsetImages,
12
+ },
13
+ ) {
14
+
15
+ return {
16
+ name: data.name,
17
+ images: [
18
+ {
19
+ path: data.images["16x16"] || data.images["1024x1024"],
20
+ size: "16x16",
21
+ idiom: "mac",
22
+ scale: "1x",
23
+ },
24
+
25
+ {
26
+ path: data.images["32x32"] || data.images["1024x1024"],
27
+ size: "16x16",
28
+ idiom: "mac",
29
+ scale: "2x",
30
+ },
31
+
32
+ {
33
+ path: data.images["32x32"] || data.images["1024x1024"],
34
+ size: "32x32",
35
+ idiom: "mac",
36
+ scale: "1x",
37
+ },
38
+
39
+ {
40
+ path: data.images["64x64"] || data.images["1024x1024"],
41
+ size: "32x32",
42
+ idiom: "mac",
43
+ scale: "2x",
44
+ },
45
+
46
+ {
47
+ path: data.images["128x128"] || data.images["1024x1024"],
48
+ size: "128x128",
49
+ idiom: "mac",
50
+ scale: "1x",
51
+ },
52
+
53
+ {
54
+ path: data.images["256x256"] || data.images["1024x1024"],
55
+ size: "128x128",
56
+ idiom: "mac",
57
+ scale: "2x",
58
+ },
59
+
60
+ {
61
+ path: data.images["256x256"] || data.images["1024x1024"],
62
+ size: "256x256",
63
+ idiom: "mac",
64
+ scale: "1x",
65
+ },
66
+
67
+ {
68
+ path: data.images["512x512"] || data.images["1024x1024"],
69
+ size: "256x256",
70
+ idiom: "mac",
71
+ scale: "2x",
72
+ },
73
+
74
+ {
75
+ path: data.images["512x512"] || data.images["1024x1024"],
76
+ size: "512x512",
77
+ idiom: "mac",
78
+ scale: "1x",
79
+ },
80
+
81
+ // This is an actual valid metadata for App Store.
82
+ {
83
+ path: data.images["1024x1024"],
84
+ size: "512x512",
85
+ idiom: "mac",
86
+ scale: "2x",
87
+ },
88
+ ],
89
+ } satisfies OSXappiconset
90
+
91
+ }
92
+
93
+ type OSXIconSize =
94
+ | Extract<
95
+ AssetCatalogFormat.AppIcon.Size,
96
+ | "16x16"
97
+ | "32x32"
98
+ | "128x128"
99
+ | "256x256"
100
+ | "512x512"
101
+ | "1024x1024"
102
+ >
103
+ | "64x64" // 2x scale - 32x32
104
+
105
+ type OSXappiconsetImagesRequired = {
106
+ [Size in Extract<OSXIconSize, "1024x1024">]: string
107
+ }
108
+
109
+ type OSXappiconsetImages =
110
+ & OSXappiconsetImagesRequired
111
+ & Partial<{
112
+ [Size in Exclude<OSXIconSize, "1024x1024">]: string
113
+ }>
114
+
115
+ interface OSXappiconImageData<Size extends OSXIconSize, Scale extends Exclude<AssetCatalogFormat.Image.Scale, "3x">> extends Pick<AssetCatalogFormat.AppIcon.SetType["images"][0], "path"> {
116
+ size: Size,
117
+ idiom: "mac"
118
+ scale: Scale,
119
+ }
120
+
121
+ interface OSXappiconset {
122
+ name: string,
123
+ images: [
124
+ OSXappiconImageData<"16x16", "1x">,
125
+ OSXappiconImageData<"16x16", "2x">,
126
+ OSXappiconImageData<"32x32", "1x">,
127
+ OSXappiconImageData<"32x32", "2x">,
128
+ OSXappiconImageData<"128x128", "1x">,
129
+ OSXappiconImageData<"128x128", "2x">,
130
+ OSXappiconImageData<"256x256", "1x">,
131
+ OSXappiconImageData<"256x256", "2x">,
132
+ OSXappiconImageData<"512x512", "1x">,
133
+ OSXappiconImageData<"512x512", "2x">, // App Store
134
+ ]
135
+ }