expo-desktop 0.1.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/LICENCE.txt ADDED
@@ -0,0 +1,18 @@
1
+ Copyright 2026 Jamie Birch
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "expo-desktop",
3
+ "version": "0.1.0",
4
+ "description": "Best-effort desktop support for Expo",
5
+ "keywords": [
6
+ "android",
7
+ "expo",
8
+ "ios",
9
+ "macos",
10
+ "react native",
11
+ "react native desktop",
12
+ "windows"
13
+ ],
14
+ "homepage": "https://github.com/shirakaba/expo-desktop/tree/main/packages/expo-desktop",
15
+ "bugs": {
16
+ "url": "https://github.com/shirakaba/expo-desktop/issues"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Jamie Birch <14055146+shirakaba@users.noreply.github.com> (https://github.com/shirakaba)",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/shirakaba/expo-desktop.git"
23
+ },
24
+ "bin": {
25
+ "expo-desktop": "src/cli.ts"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "!src/fixtures",
30
+ "!src/**/*.test.ts"
31
+ ],
32
+ "type": "module",
33
+ "exports": {
34
+ "./package.json": "./package.json"
35
+ },
36
+ "scripts": {
37
+ "generate-config": "node scripts/generate-config.ts",
38
+ "schema": "node scripts/update-schema.ts",
39
+ "start": "node src/cli.ts",
40
+ "test": "bun test"
41
+ },
42
+ "dependencies": {
43
+ "@clack/prompts": "^1.2.0",
44
+ "arktype": "^2.2.0",
45
+ "citty": "^0.2.2",
46
+ "kleur": "^4.1.5",
47
+ "toml": "^4.1.1"
48
+ },
49
+ "devDependencies": {
50
+ "@tsconfig/node24": "catalog:base",
51
+ "@types/bun": "^1.3.13",
52
+ "@types/node": "catalog:base",
53
+ "@typescript/native-preview": "catalog:base"
54
+ },
55
+ "lint-staged": {
56
+ "scripts/update-schema.ts": [
57
+ "node --run schema",
58
+ "oxfmt"
59
+ ],
60
+ "src/app-config.ts": [
61
+ "node --run schema",
62
+ "oxfmt"
63
+ ]
64
+ },
65
+ "engines": {
66
+ "node": ">=22.18.0"
67
+ }
68
+ }
@@ -0,0 +1,114 @@
1
+ import { type } from "arktype";
2
+
3
+ export const SemverMajorMinorOnly = type("/^(\\d+)\\.(\\d+)$/");
4
+ export const Dns = type("/^[a-zA-Z][a-zA-Z0-9]*(?:\\.[a-zA-Z][a-zA-Z0-9]*)*$/");
5
+ export const UnderscoredDns = type("/^[a-zA-Z]\\w*(?:\\.[a-zA-Z]\\w*)*$/");
6
+ export const HyphenatedDns = type("/^[a-zA-Z][a-zA-Z0-9\\-]*(?:\\.[a-zA-Z][a-zA-Z0-9\\-]*)*$/");
7
+ export const UnderscoredOrHyphenatedDns = type("/^[a-zA-Z][\\w\\-]*(?:\\.[a-zA-Z][\\w\\-]*)*$/");
8
+
9
+ function defineAppConfig({ includeDescriptions }: { includeDescriptions: boolean }) {
10
+ const description = (text: string) => (includeDescriptions ? { description: text } : {});
11
+
12
+ return type({
13
+ ["react_native_version?"]: SemverMajorMinorOnly.configure(
14
+ description(
15
+ "The `{major}.{minor}` version of `react-native` to align to, e.g. '0.82'. Defaults to the highest mutually supported across both `react-native-macos` and `react-native-windows`.",
16
+ ),
17
+ ),
18
+ name: type({
19
+ alphanumeric: type("string.alphanumeric").configure(
20
+ description(
21
+ "A **filesafe name** for the app consisting only of alphanumeric characters (A-z, and 0-9), e.g. 'MyApp123'. Will be used mainly for file names, e.g. 'MyApp123.xcodeproj'.",
22
+ ),
23
+ ),
24
+ display_name: type("string").configure(
25
+ description(
26
+ "The **display name** of your app, e.g. 'My App 123' or '俺のアプリ'. Accepts any string. Will be used as the app name on the iOS/Android home screen, in macOS Finder, and in Windows Explorer.",
27
+ ),
28
+ ),
29
+ reverse_dns: UnderscoredOrHyphenatedDns.configure(
30
+ description(
31
+ "The **reverse-Domain Name Specifier** for your app, e.g. 'com.example.my-app-123'. Accepts alphanumeric characters (A-z and 0-9), hyphens, and underscores. Will be used to fill in `android.package_namespace`, `android.application_id`, `windows.namespace`, `ios.bundle_identifier`, and `macos.bundle_identifier`. Hyphens and underscores will be sanitised as appropriate for these destinations, so don't worry which you use here.",
32
+ ),
33
+ ),
34
+ }).configure(description("Different formats of the app name for use in different contexts.")),
35
+ ["android?"]: type({
36
+ ["application_id?"]: UnderscoredDns.configure(
37
+ description(
38
+ "The **application ID** used on the Play Store, e.g. 'com.example.my_app_123'. Accepts only alphanumeric characters (A-z and 0-9), and underscores. Corresponds to `android.defaultConfig.applicationId` in `app/build.gradle`. Recommended to match `android.package_namespace`.",
39
+ ),
40
+ ),
41
+ ["package_namespace?"]: UnderscoredDns.configure(
42
+ description(
43
+ "The **package namespace**, e.g. 'com.example.my_app_123'. Accepts only alphanumeric characters (A-z and 0-9), and underscores. Corresponds to `android.namespace` in `app/build.gradle`. Recommended to match `android.application_id`.",
44
+ ),
45
+ ),
46
+ ["root_project_name?"]: type("string").configure(
47
+ description(
48
+ "The **display name** of your app, e.g. 'My App 123' or '俺のアプリ'. Accepts any string. Corresponds to `rootProject.name` in `settings.gradle`. Will be used as the app name on the Android home screen.",
49
+ ),
50
+ ),
51
+ }).configure(
52
+ description("Android-specific overrides for the default values (which are based on `name`)."),
53
+ ),
54
+ ["ios?"]: type({
55
+ ["bundle_display_name?"]: type("string").configure(
56
+ description(
57
+ "The **display name** of your app, e.g. 'My App 123' or '俺のアプリ'. Accepts any string. Corresponds to the `CFBundleDisplayName` key in the `Info.plist` file. Will be used as the app name on the iOS home screen.",
58
+ ),
59
+ ),
60
+ ["bundle_identifier?"]: HyphenatedDns.configure(
61
+ description(
62
+ "The **bundle identifier** of your app, e.g. 'com.example.my-app-123'. Accepts only alphanumeric characters (A-z and 0-9), and hyphens. Corresponds to the `PRODUCT_BUNDLE_IDENTIFIER` Xcode build variable, used to fill in the `CFBundleIdentifier` key in the `Info.plist` file.",
63
+ ),
64
+ ),
65
+ }).configure(
66
+ description("iOS-specific overrides for the default values (which are based on `name`)."),
67
+ ),
68
+ ["macos?"]: type({
69
+ ["bundle_display_name?"]: type("string").configure(
70
+ description(
71
+ "The **display name** of your app, e.g. 'My App 123' or '俺のアプリ'. Accepts any string. Corresponds to the `PRODUCT_BUNDLE_IDENTIFIER` Xcode build variable, used to fill in the `CFBundleDisplayName` key in the `Info.plist` file. Will be used as the app name in macOS Finder.",
72
+ ),
73
+ ),
74
+ ["bundle_identifier?"]: HyphenatedDns.configure(
75
+ description(
76
+ "The **bundle identifier** of your app, e.g. 'com.example.my-app-123'. Accepts only alphanumeric characters (A-z and 0-9), and hyphens. Corresponds to the `PRODUCT_BUNDLE_IDENTIFIER` Xcode build variable, used to fill in the `CFBundleIdentifier` key in the `Info.plist` file.",
77
+ ),
78
+ ),
79
+ }).configure(
80
+ description("macOS-specific overrides for the default values (which are based on `name`)."),
81
+ ),
82
+ ["windows?"]: type({
83
+ ["display_name?"]: type("string").configure(
84
+ description(
85
+ "The **display name** of your app, e.g. 'My App 123' or '俺のアプリ'. Accepts any string. Corresponds to the `ProjectName` value in the `.vcxproj` file. Will be used as the app name in Windows Explorer.",
86
+ ),
87
+ ),
88
+ ["namespace?"]: Dns.configure(
89
+ description(
90
+ "The WinRT and C++ **namespace**, e.g. 'com.example.myapp123'. Accepts only alphanumeric characters (A-z and 0-9). When used in C++, `.` characters are converted to `::`, e.g. 'com::example::myapp123'.",
91
+ ),
92
+ ),
93
+ ["project_name?"]: type("string.alphanumeric").configure(
94
+ description(
95
+ "A **filesafe name** for the app consisting only of alphanumeric characters (A-z, and 0-9), e.g. 'MyApp123'. Will be used mainly for file names, e.g. 'MyApp123.vcxproj'.",
96
+ ),
97
+ ),
98
+ }).configure(
99
+ description("Windows-specific overrides for the default values (which are based on `name`)."),
100
+ ),
101
+ });
102
+ }
103
+
104
+ export const PartialAppConfig = defineAppConfig({ includeDescriptions: false });
105
+
106
+ export const PartialAppConfigForJsonSchema = defineAppConfig({ includeDescriptions: true });
107
+
108
+ const RequiredTopLevelAppConfig = type.keywords.Required(PartialAppConfig);
109
+ export const AppConfig = type.merge(RequiredTopLevelAppConfig, {
110
+ android: RequiredTopLevelAppConfig.get("android").required(),
111
+ ios: RequiredTopLevelAppConfig.get("ios").required(),
112
+ macos: RequiredTopLevelAppConfig.get("macos").required(),
113
+ windows: RequiredTopLevelAppConfig.get("windows").required(),
114
+ });
package/src/cli.ts ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { defineCommand, runMain } from "citty";
4
+ import { default as kleur } from "kleur";
5
+ import { grey } from "kleur/colors";
6
+
7
+ import packageJson from "../package.json" with { type: "json" };
8
+
9
+ const main = defineCommand({
10
+ meta: {
11
+ name: "expo-desktop",
12
+ version: packageJson.version,
13
+ description: "Best-effort desktop support for Expo",
14
+ },
15
+ subCommands: {
16
+ "create-app": defineCommand({
17
+ meta: { name: "create-app", description: "Create a new Expo Desktop project" },
18
+ args: {
19
+ alphanumeric: {
20
+ type: "string",
21
+ description: `The ${kleur.bold("filesafe name")} for the app in alphanumeric format ${grey("(Example: 'MyApp123')")}`,
22
+ valueHint: "name",
23
+ },
24
+ "display-name": {
25
+ type: "string",
26
+ description: `The ${kleur.bold("display name")} for the app ${grey("(Examples: 'My App 123', '俺のアプリ')")}`,
27
+ valueHint: "name",
28
+ },
29
+ rdns: {
30
+ type: "string",
31
+ description: `The ${kleur.bold("reverse DNS")} for the app ${grey("(Example: 'com.example.my-app-123')")}`,
32
+ valueHint: "name",
33
+ },
34
+ },
35
+ async run({ args }) {
36
+ (await import("./commands/new-expo-desktop-project.ts")).newExpoDesktopProject(args);
37
+ },
38
+ }),
39
+ },
40
+ });
41
+
42
+ await runMain(main);
@@ -0,0 +1,6 @@
1
+ import { exit } from "node:process";
2
+
3
+ export function addExpoDesktopToExistingExpoApp() {
4
+ console.log("Not yet implemented.");
5
+ return exit(1);
6
+ }
@@ -0,0 +1,69 @@
1
+ import { isCancel, text, log } from "@clack/prompts";
2
+ import { default as kleur } from "kleur";
3
+ import { grey } from "kleur/colors";
4
+
5
+ export async function newExpoDesktopProject(args: {
6
+ alphanumeric: string | undefined;
7
+ "display-name": string | undefined;
8
+ rdns: string | undefined;
9
+ }) {
10
+ log.info(
11
+ `🏎️ Running ${kleur.yellow("expo-desktop create-app")}. Let's create a new Expo Desktop app in a subfolder!`,
12
+ { withGuide: false },
13
+ );
14
+
15
+ log.info(kleur.bold(kleur.inverse(" Configuring app name ")), { withGuide: false });
16
+
17
+ let alphanumeric: Arg = args.alphanumeric;
18
+ if (!alphanumeric) {
19
+ alphanumeric = await text({
20
+ message: `Please provide the ${kleur.bold("filesafe name")} for the app in ${kleur.bold("alphanumeric")} format. ${grey("(Example: 'MyApp123')")}`,
21
+ placeholder: "MyApp",
22
+ initialValue: "MyApp",
23
+ validate(value) {
24
+ if (!value?.length) {
25
+ return "Must be at least one character long.";
26
+ }
27
+ },
28
+ });
29
+ }
30
+ if (isCancel(alphanumeric)) {
31
+ process.exit(0);
32
+ }
33
+
34
+ let displayName: Arg = args["display-name"];
35
+ if (!displayName) {
36
+ displayName = await text({
37
+ message: `Please provide the ${kleur.bold("display name")} for the app. ${grey("(Examples: 'My App 123', '俺のアプリ')")}`,
38
+ placeholder: "My App",
39
+ initialValue: "My App",
40
+ validate(value) {
41
+ if (!value?.length) {
42
+ return "Must be at least one character long.";
43
+ }
44
+ },
45
+ });
46
+ }
47
+ if (isCancel(displayName)) {
48
+ process.exit(0);
49
+ }
50
+
51
+ let rdns: Arg = args.rdns;
52
+ if (!rdns) {
53
+ rdns = await text({
54
+ message: `Please provide the ${kleur.bold("reverse DNS")} for the app. ${grey("(Example: 'com.example.my-app-123')")}`,
55
+ placeholder: "com.example.my-app",
56
+ initialValue: "com.example.my-app",
57
+ validate(value) {
58
+ if (!value?.length) {
59
+ return "Must be at least one character long.";
60
+ }
61
+ },
62
+ });
63
+ }
64
+ if (isCancel(rdns)) {
65
+ process.exit(0);
66
+ }
67
+ }
68
+
69
+ type Arg = string | symbol | undefined;
@@ -0,0 +1,67 @@
1
+ import { ArkErrors, type } from "arktype";
2
+ import { green, grey, yellow } from "kleur/colors";
3
+
4
+ import { AppConfig, PartialAppConfig } from "./app-config.ts";
5
+
6
+ export function defineAppConfig(config: typeof PartialAppConfig.infer) {
7
+ const partial = PartialAppConfig(config);
8
+
9
+ if (partial instanceof type.errors) {
10
+ // console.log(`Invalid config:\n${makePrettySummary(partial).join("\n")}`);
11
+ throw new Error(`Invalid config:\n${makePrettySummary(partial).join("\n")}`);
12
+ }
13
+
14
+ const {
15
+ name: { alphanumeric, display_name, reverse_dns },
16
+ } = partial;
17
+
18
+ const full = AppConfig({
19
+ ...partial,
20
+ // TODO: Dynamically grab latest minor version
21
+ react_native_version: "0.82",
22
+ android: {
23
+ application_id: reverse_dns.replaceAll("-", "_"),
24
+ package_namespace: reverse_dns.replaceAll("-", "_"),
25
+ root_project_name: display_name,
26
+ ...partial.android,
27
+ },
28
+ ios: {
29
+ bundle_display_name: display_name,
30
+ bundle_identifier: reverse_dns.replaceAll("_", "-"),
31
+ ...partial.ios,
32
+ },
33
+ macos: {
34
+ bundle_display_name: display_name,
35
+ bundle_identifier: reverse_dns.replaceAll("_", "-"),
36
+ ...partial.macos,
37
+ },
38
+ windows: {
39
+ display_name: display_name,
40
+ namespace: reverse_dns.replaceAll(/[\-_]/g, ""),
41
+ project_name: alphanumeric,
42
+ ...partial.windows,
43
+ },
44
+ } satisfies typeof PartialAppConfig.infer);
45
+
46
+ if (full instanceof type.errors) {
47
+ throw new Error(`Invalid config:\n${makePrettySummary(full).join("\n")}`);
48
+ }
49
+
50
+ return full;
51
+ }
52
+
53
+ function makePrettySummary({ byPath }: ArkErrors) {
54
+ const summary = new Array<string>();
55
+
56
+ for (const [path, error] of Object.entries(byPath)) {
57
+ const actualIndex = error.problem.lastIndexOf(" (was ");
58
+ const problem =
59
+ actualIndex === -1
60
+ ? error.problem
61
+ : `${error.problem.startsWith("must be matched by ") ? `must be matched by ${green(error.problem.slice("must be matched by ".length, actualIndex))}` : error.problem.slice(0, actualIndex)}${grey(error.problem.slice(actualIndex))}`;
62
+
63
+ summary.push(`${yellow(path)} ${problem}`);
64
+ }
65
+
66
+ return summary;
67
+ }