bleam 0.0.11 → 0.0.13

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 (66) hide show
  1. package/dist/ai.cjs +2315 -2173
  2. package/dist/ai.d.cts +227 -322
  3. package/dist/ai.d.ts +227 -322
  4. package/dist/ai.js +2310 -2159
  5. package/dist/app-storage-D8W4n8ey.cjs +39 -0
  6. package/dist/app-storage-Isi5Bo0R.js +34 -0
  7. package/dist/cli.cjs +148 -22
  8. package/dist/cli.d.cts +14 -1
  9. package/dist/cli.d.ts +13 -0
  10. package/dist/cli.js +148 -22
  11. package/dist/config.d.cts +1 -1
  12. package/dist/elements-CFk0QHw0.d.cts +127 -0
  13. package/dist/{ui-CHc4xEs_.d.ts → elements-ClGQ41Sc.d.ts} +84 -49
  14. package/dist/{ui.cjs → elements.cjs} +307 -168
  15. package/dist/elements.d.cts +2 -0
  16. package/dist/elements.d.ts +2 -0
  17. package/dist/{ui.js → elements.js} +306 -169
  18. package/dist/{files-Ds1wT8C2.js → files-DErLhzCB.js} +11 -12
  19. package/dist/{files-Bo7h9fik.cjs → files-lMk-CpL_.cjs} +16 -11
  20. package/dist/files.cjs +1 -1
  21. package/dist/files.d.cts +1 -1
  22. package/dist/files.js +1 -1
  23. package/dist/index.d.cts +1 -1
  24. package/dist/schema-B7ELMpuI.js +226 -0
  25. package/dist/schema-B7SLUBLN.cjs +286 -0
  26. package/dist/schema-BWsDPc6c.d.cts +125 -0
  27. package/dist/schema-LxnzAfgw.d.ts +125 -0
  28. package/dist/schema.cjs +10 -2
  29. package/dist/schema.d.cts +2 -2
  30. package/dist/schema.d.ts +2 -2
  31. package/dist/schema.js +2 -2
  32. package/dist/secrets.cjs +146 -0
  33. package/dist/secrets.d.cts +14 -0
  34. package/dist/secrets.d.ts +14 -0
  35. package/dist/secrets.js +142 -0
  36. package/dist/state-BZYyrE2-.cjs +936 -0
  37. package/dist/state-DkaRFkZJ.js +843 -0
  38. package/dist/state.cjs +17 -12
  39. package/dist/state.d.cts +144 -140
  40. package/dist/state.d.ts +145 -140
  41. package/dist/state.js +4 -3
  42. package/dist/window.d.cts +1 -1
  43. package/dist/window.d.ts +3 -3
  44. package/package.json +13 -6
  45. package/templates/basic/app/index.tsx +2 -2
  46. package/templates/foundation-models/app/index.tsx +78 -16
  47. package/templates/image-generation/app/index.tsx +4 -4
  48. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +46 -46
  49. package/templates/native/ios/Podfile.lock +173 -173
  50. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +42 -365
  51. package/templates/state/app/index.tsx +2 -2
  52. package/templates/text-generation/app/index.tsx +83 -52
  53. package/templates/updates/README.md +1 -1
  54. package/dist/schema-Bo5Jvqus.js +0 -90
  55. package/dist/schema-CYh6n8GS.d.ts +0 -58
  56. package/dist/schema-oeOrd3i1.d.cts +0 -58
  57. package/dist/schema-rQ13mrpD.cjs +0 -102
  58. package/dist/state-Bx0VlTlO.cjs +0 -852
  59. package/dist/state-CAwe-Vw1.js +0 -767
  60. package/dist/ui-1WepaMS4.d.cts +0 -92
  61. package/dist/ui.d.cts +0 -2
  62. package/dist/ui.d.ts +0 -2
  63. /package/dist/{config-CufOVJV3.d.cts → config-COcRnn5a.d.cts} +0 -0
  64. /package/dist/{files-Dt5mbzLq.d.cts → files-DwA7pzr3.d.cts} +0 -0
  65. /package/dist/{native-sqlite-yQLD5s9i.cjs → native-sqlite-Dw--FI9a.cjs} +0 -0
  66. /package/dist/{native-sqlite-xcGdamRD.js → native-sqlite-WzRNzCSh.js} +0 -0
@@ -0,0 +1,39 @@
1
+ const require_native_runtime = require('./native-runtime-CsXnXkQn.cjs');
2
+
3
+ //#region src/app-storage.ts
4
+ let cachedStorageKey;
5
+ function launchArgument(name) {
6
+ const argumentsList = NSProcessInfo.processInfo.arguments();
7
+ const count = Number(argumentsList.count ?? 0);
8
+ for (let index = 0; index < count - 1; index += 1) if (String(argumentsList.objectAtIndex(index)) === name) return String(argumentsList.objectAtIndex(index + 1));
9
+ }
10
+ function storageKey(name) {
11
+ return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "app";
12
+ }
13
+ function currentAppStorageKey() {
14
+ if (cachedStorageKey) return cachedStorageKey;
15
+ require_native_runtime.ensureNativeScript();
16
+ const configPath = launchArgument("--bleam-project-config");
17
+ if (configPath) try {
18
+ const text = String(NSString.stringWithContentsOfFileEncodingError(configPath, NSUTF8StringEncoding, null));
19
+ const config = JSON.parse(text);
20
+ if (typeof config.id === "string" && config.id) {
21
+ cachedStorageKey = config.id;
22
+ return cachedStorageKey;
23
+ }
24
+ if (typeof config.name === "string" && config.name) {
25
+ cachedStorageKey = storageKey(config.name);
26
+ return cachedStorageKey;
27
+ }
28
+ } catch {}
29
+ cachedStorageKey = "app";
30
+ return cachedStorageKey;
31
+ }
32
+
33
+ //#endregion
34
+ Object.defineProperty(exports, 'currentAppStorageKey', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return currentAppStorageKey;
38
+ }
39
+ });
@@ -0,0 +1,34 @@
1
+ import { t as ensureNativeScript } from "./native-runtime-C85Nuc4F.js";
2
+
3
+ //#region src/app-storage.ts
4
+ let cachedStorageKey;
5
+ function launchArgument(name) {
6
+ const argumentsList = NSProcessInfo.processInfo.arguments();
7
+ const count = Number(argumentsList.count ?? 0);
8
+ for (let index = 0; index < count - 1; index += 1) if (String(argumentsList.objectAtIndex(index)) === name) return String(argumentsList.objectAtIndex(index + 1));
9
+ }
10
+ function storageKey(name) {
11
+ return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "app";
12
+ }
13
+ function currentAppStorageKey() {
14
+ if (cachedStorageKey) return cachedStorageKey;
15
+ ensureNativeScript();
16
+ const configPath = launchArgument("--bleam-project-config");
17
+ if (configPath) try {
18
+ const text = String(NSString.stringWithContentsOfFileEncodingError(configPath, NSUTF8StringEncoding, null));
19
+ const config = JSON.parse(text);
20
+ if (typeof config.id === "string" && config.id) {
21
+ cachedStorageKey = config.id;
22
+ return cachedStorageKey;
23
+ }
24
+ if (typeof config.name === "string" && config.name) {
25
+ cachedStorageKey = storageKey(config.name);
26
+ return cachedStorageKey;
27
+ }
28
+ } catch {}
29
+ cachedStorageKey = "app";
30
+ return cachedStorageKey;
31
+ }
32
+
33
+ //#endregion
34
+ export { currentAppStorageKey as t };
package/dist/cli.cjs CHANGED
@@ -621,13 +621,14 @@ function writeBiomeConfig(configPath) {
621
621
  }
622
622
  }, null, 2)}\n`);
623
623
  }
624
- function writeProjectRuntimeConfig(projectRoot, config, origin) {
624
+ function writeProjectRuntimeConfig(projectRoot, config, origin, client) {
625
625
  const projectConfigPath = node_path.default.join(projectRoot, ".bleam", "project.json");
626
626
  (0, node_fs.mkdirSync)(node_path.default.dirname(projectConfigPath), { recursive: true });
627
627
  (0, node_fs.writeFileSync)(projectConfigPath, `${JSON.stringify({
628
628
  name: config.name,
629
+ id: client.projectId,
629
630
  version: config.version,
630
- bundleIdentifier: config.bundleIdentifier,
631
+ bundleIdentifier: client.bundleIdentifier,
631
632
  teamId: config.teamId,
632
633
  appearance: config.appearance,
633
634
  devServer: origin,
@@ -1166,19 +1167,127 @@ async function resolveRuntimeArtifact() {
1166
1167
  throw new Error(`Failed to resolve the Bleam runtime.\n${runtimeResolutionDetails()}\n\nCause: ${error instanceof Error ? error.message : String(error)}`);
1167
1168
  }
1168
1169
  }
1169
- function copyRuntimeClient(projectRoot, runtime) {
1170
- const clientAppPath = node_path.default.join(projectRoot, ".bleam", "client", "Bleam.app");
1170
+ function devProjectId(projectRoot) {
1171
+ const idPath = node_path.default.join(projectRoot, ".bleam", "project-id");
1172
+ if ((0, node_fs.existsSync)(idPath)) {
1173
+ const projectId$1 = (0, node_fs.readFileSync)(idPath, "utf8").trim();
1174
+ if (/^[0-9a-f]{32}$/i.test(projectId$1)) return projectId$1.toLowerCase();
1175
+ throw new Error(`Invalid Bleam project ID at ${prettyPath(idPath)}`);
1176
+ }
1177
+ const projectId = (0, node_crypto.randomUUID)().replaceAll("-", "");
1178
+ (0, node_fs.mkdirSync)(node_path.default.dirname(idPath), { recursive: true });
1179
+ (0, node_fs.writeFileSync)(idPath, `${projectId}\n`);
1180
+ return projectId;
1181
+ }
1182
+ function devBundleIdentifier(projectId) {
1183
+ return `dev.bleam.project.p${projectId}`;
1184
+ }
1185
+ function runBundleCommand(command, args) {
1186
+ const result = (0, node_child_process.spawnSync)(command, args, {
1187
+ encoding: "utf8",
1188
+ env: process.env
1189
+ });
1190
+ if (result.error) throw result.error;
1191
+ if (result.status !== 0) {
1192
+ const detail = result.stderr.trim() || result.stdout.trim();
1193
+ throw new Error(`${commandText(command, args)} failed${detail ? `: ${detail}` : ""}`);
1194
+ }
1195
+ }
1196
+ function devAppFileName(name) {
1197
+ return `${name.replaceAll("/", "-")}.app`;
1198
+ }
1199
+ function setPlistValue(plistPath, key, type, value) {
1200
+ (0, node_child_process.spawnSync)("plutil", [
1201
+ "-remove",
1202
+ key,
1203
+ plistPath
1204
+ ], { stdio: "ignore" });
1205
+ runBundleCommand("plutil", [
1206
+ "-insert",
1207
+ key,
1208
+ type,
1209
+ value,
1210
+ plistPath
1211
+ ]);
1212
+ }
1213
+ function removePlistValue(plistPath, key) {
1214
+ (0, node_child_process.spawnSync)("plutil", [
1215
+ "-remove",
1216
+ key,
1217
+ plistPath
1218
+ ], { stdio: "ignore" });
1219
+ }
1220
+ function personalizeRuntimeClient(options) {
1221
+ const appPlist = node_path.default.join(options.appPath, "Contents", "Info.plist");
1222
+ const servicePath = node_path.default.join(options.appPath, "Contents", "XPCServices", "GenerationService.xpc");
1223
+ const servicePlist = node_path.default.join(servicePath, "Contents", "Info.plist");
1224
+ setPlistValue(appPlist, "CFBundleIdentifier", "-string", options.bundleIdentifier);
1225
+ setPlistValue(appPlist, "CFBundleDisplayName", "-string", options.name);
1226
+ setPlistValue(appPlist, "CFBundleName", "-string", options.name);
1227
+ removePlistValue(appPlist, "AppGroupIdentifier");
1228
+ if ((0, node_fs.existsSync)(servicePlist)) {
1229
+ setPlistValue(servicePlist, "CFBundleIdentifier", "-string", `${options.bundleIdentifier}.GenerationService`);
1230
+ removePlistValue(servicePlist, "AppGroupIdentifier");
1231
+ }
1232
+ if (options.iconPath) {
1233
+ const iconName = "BleamProjectIcon.png";
1234
+ (0, node_fs.cpSync)(options.iconPath, node_path.default.join(options.appPath, "Contents", "Resources", iconName));
1235
+ setPlistValue(appPlist, "CFBundleIconFile", "-string", iconName);
1236
+ setPlistValue(appPlist, "CFBundleIcons", "-json", JSON.stringify({ CFBundlePrimaryIcon: {
1237
+ CFBundleIconFiles: ["BleamProjectIcon"],
1238
+ CFBundleIconName: "BleamProjectIcon"
1239
+ } }));
1240
+ }
1241
+ (0, node_fs.rmSync)(node_path.default.join(options.appPath, "Contents", "embedded.provisionprofile"), { force: true });
1242
+ (0, node_fs.rmSync)(node_path.default.join(servicePath, "Contents", "embedded.provisionprofile"), { force: true });
1243
+ if ((0, node_fs.existsSync)(servicePath)) runBundleCommand("codesign", [
1244
+ "--force",
1245
+ "--sign",
1246
+ "-",
1247
+ "--timestamp=none",
1248
+ servicePath
1249
+ ]);
1250
+ runBundleCommand("codesign", [
1251
+ "--force",
1252
+ "--sign",
1253
+ "-",
1254
+ "--timestamp=none",
1255
+ options.appPath
1256
+ ]);
1257
+ runBundleCommand("codesign", [
1258
+ "--verify",
1259
+ "--deep",
1260
+ "--strict",
1261
+ options.appPath
1262
+ ]);
1263
+ }
1264
+ function copyRuntimeClient(projectRoot, runtime, config) {
1265
+ const projectId = devProjectId(projectRoot);
1266
+ const bundleIdentifier = devBundleIdentifier(projectId);
1267
+ const clientRoot = node_path.default.join(projectRoot, ".bleam", "client");
1268
+ const appFileName = devAppFileName(config.name);
1269
+ const clientAppPath = node_path.default.join(clientRoot, appFileName);
1171
1270
  console.log(`Preparing Bleam app at ${prettyPath(clientAppPath)}`);
1172
- (0, node_fs.rmSync)(clientAppPath, {
1271
+ (0, node_fs.rmSync)(clientRoot, {
1173
1272
  recursive: true,
1174
1273
  force: true
1175
1274
  });
1176
- (0, node_fs.mkdirSync)(node_path.default.dirname(clientAppPath), { recursive: true });
1275
+ (0, node_fs.mkdirSync)(clientRoot, { recursive: true });
1177
1276
  (0, node_fs.cpSync)(runtime.appPath, clientAppPath, {
1178
1277
  recursive: true,
1179
1278
  verbatimSymlinks: true
1180
1279
  });
1181
- return clientAppPath;
1280
+ personalizeRuntimeClient({
1281
+ appPath: clientAppPath,
1282
+ name: config.name,
1283
+ bundleIdentifier,
1284
+ iconPath: config.iconPath
1285
+ });
1286
+ return {
1287
+ appPath: clientAppPath,
1288
+ bundleIdentifier,
1289
+ projectId
1290
+ };
1182
1291
  }
1183
1292
  function cleanDevArtifacts(projectRoot) {
1184
1293
  const bleamRoot = node_path.default.join(projectRoot, ".bleam");
@@ -1360,11 +1469,12 @@ function openRuntimeClient(appPath, projectConfigPath, manifest) {
1360
1469
  if (code && code !== 0) console.error(`Failed to open Bleam runtime at ${appPath}`);
1361
1470
  });
1362
1471
  }
1363
- function quitRuntimeClient() {
1364
- (0, node_child_process.spawnSync)("osascript", ["-e", "tell application id \"dev.bleam.app\" to quit"], { stdio: "ignore" });
1472
+ function quitRuntimeClient(bundleIdentifier) {
1473
+ const application = `application id ${JSON.stringify(bundleIdentifier)}`;
1474
+ (0, node_child_process.spawnSync)("osascript", ["-e", `if ${application} is running then tell ${application} to quit`], { stdio: "ignore" });
1365
1475
  }
1366
- async function launchRuntimeClient(appPath, projectConfigPath, manifest) {
1367
- quitRuntimeClient();
1476
+ async function launchRuntimeClient(appPath, bundleIdentifier, projectConfigPath, manifest) {
1477
+ quitRuntimeClient(bundleIdentifier);
1368
1478
  openRuntimeClient(appPath, projectConfigPath, manifest);
1369
1479
  }
1370
1480
  async function updateServiceHealthy(serviceUrl) {
@@ -1453,8 +1563,14 @@ async function startLocalUpdateService() {
1453
1563
  serviceUrl
1454
1564
  };
1455
1565
  }
1456
- function focusRuntimeClient() {
1457
- return (0, node_child_process.spawnSync)("osascript", ["-e", "tell application id \"dev.bleam.app\" to activate"], { stdio: "ignore" }).status === 0;
1566
+ function focusRuntimeClient(bundleIdentifier) {
1567
+ const application = `application id ${JSON.stringify(bundleIdentifier)}`;
1568
+ const result = (0, node_child_process.spawnSync)("osascript", ["-e", `if ${application} is running then
1569
+ tell ${application} to activate
1570
+ return true
1571
+ end if
1572
+ return false`], { encoding: "utf8" });
1573
+ return result.status === 0 && result.stdout.trim() === "true";
1458
1574
  }
1459
1575
  function sendJson(res, status, value) {
1460
1576
  res.writeHead(status, {
@@ -1593,12 +1709,14 @@ function setupInteractiveControls(options) {
1593
1709
  if (key === "o") {
1594
1710
  (async () => {
1595
1711
  try {
1596
- if (focusRuntimeClient()) {
1597
- console.log("Focused Bleam app");
1712
+ if (focusRuntimeClient(options.bundleIdentifier)) {
1713
+ options.onOpen();
1714
+ console.log("Focused project app");
1598
1715
  return;
1599
1716
  }
1600
1717
  console.log(`Opening Bleam app at ${prettyPath(options.clientAppPath)}`);
1601
- await launchRuntimeClient(options.clientAppPath, options.projectConfigPath, options.manifest);
1718
+ await launchRuntimeClient(options.clientAppPath, options.bundleIdentifier, options.projectConfigPath, options.manifest);
1719
+ options.onOpen();
1602
1720
  } catch (error) {
1603
1721
  console.error(error instanceof Error ? error.message : String(error));
1604
1722
  }
@@ -1782,11 +1900,11 @@ async function startDevServer(options) {
1782
1900
  const config = readProjectConfig(options);
1783
1901
  if (options.clean) cleanDevArtifacts(options.projectRoot);
1784
1902
  const runtime = await resolveRuntimeArtifact();
1785
- const clientAppPath = copyRuntimeClient(options.projectRoot, runtime);
1903
+ const client = copyRuntimeClient(options.projectRoot, runtime, config);
1786
1904
  console.log("Preparing Bleam dev workspace");
1787
1905
  const workspaceRoot = createDevWorkspace(options.projectRoot, config);
1788
1906
  const origin = `http://localhost:${options.port}`;
1789
- const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin);
1907
+ const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin, client);
1790
1908
  const updateService = await startLocalUpdateService();
1791
1909
  const child = (0, node_child_process.spawn)(process.execPath, [
1792
1910
  (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href),
@@ -1827,7 +1945,7 @@ async function startDevServer(options) {
1827
1945
  if (didCleanupDevSession) return;
1828
1946
  didCleanupDevSession = true;
1829
1947
  cleanupInteractiveControls();
1830
- if (didLaunchRuntimeClient) quitRuntimeClient();
1948
+ if (didLaunchRuntimeClient) quitRuntimeClient(client.bundleIdentifier);
1831
1949
  if (updateService.child?.exitCode === null) updateService.child.kill("SIGTERM");
1832
1950
  };
1833
1951
  const stop = (signal) => {
@@ -1853,15 +1971,19 @@ async function startDevServer(options) {
1853
1971
  const manifest = await readDevManifest(origin);
1854
1972
  cleanupInteractiveControls = setupInteractiveControls({
1855
1973
  origin,
1856
- clientAppPath,
1974
+ clientAppPath: client.appPath,
1975
+ bundleIdentifier: client.bundleIdentifier,
1857
1976
  projectConfigPath,
1858
1977
  manifest,
1978
+ onOpen: () => {
1979
+ didLaunchRuntimeClient = true;
1980
+ },
1859
1981
  stop: () => stop("SIGINT")
1860
1982
  });
1861
1983
  if (options.run && process.env.BLEAM_NO_OPEN !== "1") try {
1862
1984
  await waitForDevBundle(manifest.bundleUrl);
1863
- console.log(`Opening Bleam app at ${prettyPath(clientAppPath)}`);
1864
- await launchRuntimeClient(clientAppPath, projectConfigPath, manifest);
1985
+ console.log(`Opening project app at ${prettyPath(client.appPath)}`);
1986
+ await launchRuntimeClient(client.appPath, client.bundleIdentifier, projectConfigPath, manifest);
1865
1987
  didLaunchRuntimeClient = true;
1866
1988
  } catch (error) {
1867
1989
  console.error(`Initial app launch failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -1945,6 +2067,9 @@ if (process.env.VITEST !== "true") main().catch((error) => {
1945
2067
  const __test = {
1946
2068
  createProject,
1947
2069
  createBuildNativeWorkspace,
2070
+ devAppFileName,
2071
+ devBundleIdentifier,
2072
+ devProjectId,
1948
2073
  hasCurrentPodInstall,
1949
2074
  installedAppPath,
1950
2075
  installArchivedApp,
@@ -1955,6 +2080,7 @@ const __test = {
1955
2080
  parseBuildOptions,
1956
2081
  parseNewOptions,
1957
2082
  parsePublishOtaOptions,
2083
+ personalizeRuntimeClient,
1958
2084
  podInstallInputStamp,
1959
2085
  replaceOrInsertPlistString
1960
2086
  };
package/dist/cli.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as BleamAppearance } from "./config-CufOVJV3.cjs";
2
+ import { t as BleamAppearance } from "./config-COcRnn5a.cjs";
3
3
 
4
4
  //#region src/cli.d.ts
5
5
  interface BuildOptions {
@@ -55,9 +55,21 @@ declare function nativeArchiveArgs(options: {
55
55
  }): string[];
56
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
57
57
  declare function installedAppPath(appName: string): string;
58
+ declare function devProjectId(projectRoot: string): string;
59
+ declare function devBundleIdentifier(projectId: string): string;
60
+ declare function devAppFileName(name: string): string;
61
+ declare function personalizeRuntimeClient(options: {
62
+ appPath: string;
63
+ name: string;
64
+ bundleIdentifier: string;
65
+ iconPath?: string;
66
+ }): void;
58
67
  declare const __test: {
59
68
  createProject: typeof createProject;
60
69
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
70
+ devAppFileName: typeof devAppFileName;
71
+ devBundleIdentifier: typeof devBundleIdentifier;
72
+ devProjectId: typeof devProjectId;
61
73
  hasCurrentPodInstall: typeof hasCurrentPodInstall;
62
74
  installedAppPath: typeof installedAppPath;
63
75
  installArchivedApp: typeof installArchivedApp;
@@ -68,6 +80,7 @@ declare const __test: {
68
80
  parseBuildOptions: typeof parseBuildOptions;
69
81
  parseNewOptions: typeof parseNewOptions;
70
82
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
83
+ personalizeRuntimeClient: typeof personalizeRuntimeClient;
71
84
  podInstallInputStamp: typeof podInstallInputStamp;
72
85
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
73
86
  };
package/dist/cli.d.ts CHANGED
@@ -55,9 +55,21 @@ declare function nativeArchiveArgs(options: {
55
55
  }): string[];
56
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
57
57
  declare function installedAppPath(appName: string): string;
58
+ declare function devProjectId(projectRoot: string): string;
59
+ declare function devBundleIdentifier(projectId: string): string;
60
+ declare function devAppFileName(name: string): string;
61
+ declare function personalizeRuntimeClient(options: {
62
+ appPath: string;
63
+ name: string;
64
+ bundleIdentifier: string;
65
+ iconPath?: string;
66
+ }): void;
58
67
  declare const __test: {
59
68
  createProject: typeof createProject;
60
69
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
70
+ devAppFileName: typeof devAppFileName;
71
+ devBundleIdentifier: typeof devBundleIdentifier;
72
+ devProjectId: typeof devProjectId;
61
73
  hasCurrentPodInstall: typeof hasCurrentPodInstall;
62
74
  installedAppPath: typeof installedAppPath;
63
75
  installArchivedApp: typeof installArchivedApp;
@@ -68,6 +80,7 @@ declare const __test: {
68
80
  parseBuildOptions: typeof parseBuildOptions;
69
81
  parseNewOptions: typeof parseNewOptions;
70
82
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
83
+ personalizeRuntimeClient: typeof personalizeRuntimeClient;
71
84
  podInstallInputStamp: typeof podInstallInputStamp;
72
85
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
73
86
  };
package/dist/cli.js CHANGED
@@ -609,13 +609,14 @@ function writeBiomeConfig(configPath) {
609
609
  }
610
610
  }, null, 2)}\n`);
611
611
  }
612
- function writeProjectRuntimeConfig(projectRoot, config, origin) {
612
+ function writeProjectRuntimeConfig(projectRoot, config, origin, client) {
613
613
  const projectConfigPath = path.join(projectRoot, ".bleam", "project.json");
614
614
  mkdirSync(path.dirname(projectConfigPath), { recursive: true });
615
615
  writeFileSync(projectConfigPath, `${JSON.stringify({
616
616
  name: config.name,
617
+ id: client.projectId,
617
618
  version: config.version,
618
- bundleIdentifier: config.bundleIdentifier,
619
+ bundleIdentifier: client.bundleIdentifier,
619
620
  teamId: config.teamId,
620
621
  appearance: config.appearance,
621
622
  devServer: origin,
@@ -1154,19 +1155,127 @@ async function resolveRuntimeArtifact() {
1154
1155
  throw new Error(`Failed to resolve the Bleam runtime.\n${runtimeResolutionDetails()}\n\nCause: ${error instanceof Error ? error.message : String(error)}`);
1155
1156
  }
1156
1157
  }
1157
- function copyRuntimeClient(projectRoot, runtime) {
1158
- const clientAppPath = path.join(projectRoot, ".bleam", "client", "Bleam.app");
1158
+ function devProjectId(projectRoot) {
1159
+ const idPath = path.join(projectRoot, ".bleam", "project-id");
1160
+ if (existsSync(idPath)) {
1161
+ const projectId$1 = readFileSync(idPath, "utf8").trim();
1162
+ if (/^[0-9a-f]{32}$/i.test(projectId$1)) return projectId$1.toLowerCase();
1163
+ throw new Error(`Invalid Bleam project ID at ${prettyPath(idPath)}`);
1164
+ }
1165
+ const projectId = randomUUID().replaceAll("-", "");
1166
+ mkdirSync(path.dirname(idPath), { recursive: true });
1167
+ writeFileSync(idPath, `${projectId}\n`);
1168
+ return projectId;
1169
+ }
1170
+ function devBundleIdentifier(projectId) {
1171
+ return `dev.bleam.project.p${projectId}`;
1172
+ }
1173
+ function runBundleCommand(command, args) {
1174
+ const result = spawnSync(command, args, {
1175
+ encoding: "utf8",
1176
+ env: process.env
1177
+ });
1178
+ if (result.error) throw result.error;
1179
+ if (result.status !== 0) {
1180
+ const detail = result.stderr.trim() || result.stdout.trim();
1181
+ throw new Error(`${commandText(command, args)} failed${detail ? `: ${detail}` : ""}`);
1182
+ }
1183
+ }
1184
+ function devAppFileName(name) {
1185
+ return `${name.replaceAll("/", "-")}.app`;
1186
+ }
1187
+ function setPlistValue(plistPath, key, type, value) {
1188
+ spawnSync("plutil", [
1189
+ "-remove",
1190
+ key,
1191
+ plistPath
1192
+ ], { stdio: "ignore" });
1193
+ runBundleCommand("plutil", [
1194
+ "-insert",
1195
+ key,
1196
+ type,
1197
+ value,
1198
+ plistPath
1199
+ ]);
1200
+ }
1201
+ function removePlistValue(plistPath, key) {
1202
+ spawnSync("plutil", [
1203
+ "-remove",
1204
+ key,
1205
+ plistPath
1206
+ ], { stdio: "ignore" });
1207
+ }
1208
+ function personalizeRuntimeClient(options) {
1209
+ const appPlist = path.join(options.appPath, "Contents", "Info.plist");
1210
+ const servicePath = path.join(options.appPath, "Contents", "XPCServices", "GenerationService.xpc");
1211
+ const servicePlist = path.join(servicePath, "Contents", "Info.plist");
1212
+ setPlistValue(appPlist, "CFBundleIdentifier", "-string", options.bundleIdentifier);
1213
+ setPlistValue(appPlist, "CFBundleDisplayName", "-string", options.name);
1214
+ setPlistValue(appPlist, "CFBundleName", "-string", options.name);
1215
+ removePlistValue(appPlist, "AppGroupIdentifier");
1216
+ if (existsSync(servicePlist)) {
1217
+ setPlistValue(servicePlist, "CFBundleIdentifier", "-string", `${options.bundleIdentifier}.GenerationService`);
1218
+ removePlistValue(servicePlist, "AppGroupIdentifier");
1219
+ }
1220
+ if (options.iconPath) {
1221
+ const iconName = "BleamProjectIcon.png";
1222
+ cpSync(options.iconPath, path.join(options.appPath, "Contents", "Resources", iconName));
1223
+ setPlistValue(appPlist, "CFBundleIconFile", "-string", iconName);
1224
+ setPlistValue(appPlist, "CFBundleIcons", "-json", JSON.stringify({ CFBundlePrimaryIcon: {
1225
+ CFBundleIconFiles: ["BleamProjectIcon"],
1226
+ CFBundleIconName: "BleamProjectIcon"
1227
+ } }));
1228
+ }
1229
+ rmSync(path.join(options.appPath, "Contents", "embedded.provisionprofile"), { force: true });
1230
+ rmSync(path.join(servicePath, "Contents", "embedded.provisionprofile"), { force: true });
1231
+ if (existsSync(servicePath)) runBundleCommand("codesign", [
1232
+ "--force",
1233
+ "--sign",
1234
+ "-",
1235
+ "--timestamp=none",
1236
+ servicePath
1237
+ ]);
1238
+ runBundleCommand("codesign", [
1239
+ "--force",
1240
+ "--sign",
1241
+ "-",
1242
+ "--timestamp=none",
1243
+ options.appPath
1244
+ ]);
1245
+ runBundleCommand("codesign", [
1246
+ "--verify",
1247
+ "--deep",
1248
+ "--strict",
1249
+ options.appPath
1250
+ ]);
1251
+ }
1252
+ function copyRuntimeClient(projectRoot, runtime, config) {
1253
+ const projectId = devProjectId(projectRoot);
1254
+ const bundleIdentifier = devBundleIdentifier(projectId);
1255
+ const clientRoot = path.join(projectRoot, ".bleam", "client");
1256
+ const appFileName = devAppFileName(config.name);
1257
+ const clientAppPath = path.join(clientRoot, appFileName);
1159
1258
  console.log(`Preparing Bleam app at ${prettyPath(clientAppPath)}`);
1160
- rmSync(clientAppPath, {
1259
+ rmSync(clientRoot, {
1161
1260
  recursive: true,
1162
1261
  force: true
1163
1262
  });
1164
- mkdirSync(path.dirname(clientAppPath), { recursive: true });
1263
+ mkdirSync(clientRoot, { recursive: true });
1165
1264
  cpSync(runtime.appPath, clientAppPath, {
1166
1265
  recursive: true,
1167
1266
  verbatimSymlinks: true
1168
1267
  });
1169
- return clientAppPath;
1268
+ personalizeRuntimeClient({
1269
+ appPath: clientAppPath,
1270
+ name: config.name,
1271
+ bundleIdentifier,
1272
+ iconPath: config.iconPath
1273
+ });
1274
+ return {
1275
+ appPath: clientAppPath,
1276
+ bundleIdentifier,
1277
+ projectId
1278
+ };
1170
1279
  }
1171
1280
  function cleanDevArtifacts(projectRoot) {
1172
1281
  const bleamRoot = path.join(projectRoot, ".bleam");
@@ -1348,11 +1457,12 @@ function openRuntimeClient(appPath, projectConfigPath, manifest) {
1348
1457
  if (code && code !== 0) console.error(`Failed to open Bleam runtime at ${appPath}`);
1349
1458
  });
1350
1459
  }
1351
- function quitRuntimeClient() {
1352
- spawnSync("osascript", ["-e", "tell application id \"dev.bleam.app\" to quit"], { stdio: "ignore" });
1460
+ function quitRuntimeClient(bundleIdentifier) {
1461
+ const application = `application id ${JSON.stringify(bundleIdentifier)}`;
1462
+ spawnSync("osascript", ["-e", `if ${application} is running then tell ${application} to quit`], { stdio: "ignore" });
1353
1463
  }
1354
- async function launchRuntimeClient(appPath, projectConfigPath, manifest) {
1355
- quitRuntimeClient();
1464
+ async function launchRuntimeClient(appPath, bundleIdentifier, projectConfigPath, manifest) {
1465
+ quitRuntimeClient(bundleIdentifier);
1356
1466
  openRuntimeClient(appPath, projectConfigPath, manifest);
1357
1467
  }
1358
1468
  async function updateServiceHealthy(serviceUrl) {
@@ -1441,8 +1551,14 @@ async function startLocalUpdateService() {
1441
1551
  serviceUrl
1442
1552
  };
1443
1553
  }
1444
- function focusRuntimeClient() {
1445
- return spawnSync("osascript", ["-e", "tell application id \"dev.bleam.app\" to activate"], { stdio: "ignore" }).status === 0;
1554
+ function focusRuntimeClient(bundleIdentifier) {
1555
+ const application = `application id ${JSON.stringify(bundleIdentifier)}`;
1556
+ const result = spawnSync("osascript", ["-e", `if ${application} is running then
1557
+ tell ${application} to activate
1558
+ return true
1559
+ end if
1560
+ return false`], { encoding: "utf8" });
1561
+ return result.status === 0 && result.stdout.trim() === "true";
1446
1562
  }
1447
1563
  function sendJson(res, status, value) {
1448
1564
  res.writeHead(status, {
@@ -1581,12 +1697,14 @@ function setupInteractiveControls(options) {
1581
1697
  if (key === "o") {
1582
1698
  (async () => {
1583
1699
  try {
1584
- if (focusRuntimeClient()) {
1585
- console.log("Focused Bleam app");
1700
+ if (focusRuntimeClient(options.bundleIdentifier)) {
1701
+ options.onOpen();
1702
+ console.log("Focused project app");
1586
1703
  return;
1587
1704
  }
1588
1705
  console.log(`Opening Bleam app at ${prettyPath(options.clientAppPath)}`);
1589
- await launchRuntimeClient(options.clientAppPath, options.projectConfigPath, options.manifest);
1706
+ await launchRuntimeClient(options.clientAppPath, options.bundleIdentifier, options.projectConfigPath, options.manifest);
1707
+ options.onOpen();
1590
1708
  } catch (error) {
1591
1709
  console.error(error instanceof Error ? error.message : String(error));
1592
1710
  }
@@ -1770,11 +1888,11 @@ async function startDevServer(options) {
1770
1888
  const config = readProjectConfig(options);
1771
1889
  if (options.clean) cleanDevArtifacts(options.projectRoot);
1772
1890
  const runtime = await resolveRuntimeArtifact();
1773
- const clientAppPath = copyRuntimeClient(options.projectRoot, runtime);
1891
+ const client = copyRuntimeClient(options.projectRoot, runtime, config);
1774
1892
  console.log("Preparing Bleam dev workspace");
1775
1893
  const workspaceRoot = createDevWorkspace(options.projectRoot, config);
1776
1894
  const origin = `http://localhost:${options.port}`;
1777
- const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin);
1895
+ const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin, client);
1778
1896
  const updateService = await startLocalUpdateService();
1779
1897
  const child = spawn(process.execPath, [
1780
1898
  fileURLToPath(import.meta.url),
@@ -1815,7 +1933,7 @@ async function startDevServer(options) {
1815
1933
  if (didCleanupDevSession) return;
1816
1934
  didCleanupDevSession = true;
1817
1935
  cleanupInteractiveControls();
1818
- if (didLaunchRuntimeClient) quitRuntimeClient();
1936
+ if (didLaunchRuntimeClient) quitRuntimeClient(client.bundleIdentifier);
1819
1937
  if (updateService.child?.exitCode === null) updateService.child.kill("SIGTERM");
1820
1938
  };
1821
1939
  const stop = (signal) => {
@@ -1841,15 +1959,19 @@ async function startDevServer(options) {
1841
1959
  const manifest = await readDevManifest(origin);
1842
1960
  cleanupInteractiveControls = setupInteractiveControls({
1843
1961
  origin,
1844
- clientAppPath,
1962
+ clientAppPath: client.appPath,
1963
+ bundleIdentifier: client.bundleIdentifier,
1845
1964
  projectConfigPath,
1846
1965
  manifest,
1966
+ onOpen: () => {
1967
+ didLaunchRuntimeClient = true;
1968
+ },
1847
1969
  stop: () => stop("SIGINT")
1848
1970
  });
1849
1971
  if (options.run && process.env.BLEAM_NO_OPEN !== "1") try {
1850
1972
  await waitForDevBundle(manifest.bundleUrl);
1851
- console.log(`Opening Bleam app at ${prettyPath(clientAppPath)}`);
1852
- await launchRuntimeClient(clientAppPath, projectConfigPath, manifest);
1973
+ console.log(`Opening project app at ${prettyPath(client.appPath)}`);
1974
+ await launchRuntimeClient(client.appPath, client.bundleIdentifier, projectConfigPath, manifest);
1853
1975
  didLaunchRuntimeClient = true;
1854
1976
  } catch (error) {
1855
1977
  console.error(`Initial app launch failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -1933,6 +2055,9 @@ if (process.env.VITEST !== "true") main().catch((error) => {
1933
2055
  const __test = {
1934
2056
  createProject,
1935
2057
  createBuildNativeWorkspace,
2058
+ devAppFileName,
2059
+ devBundleIdentifier,
2060
+ devProjectId,
1936
2061
  hasCurrentPodInstall,
1937
2062
  installedAppPath,
1938
2063
  installArchivedApp,
@@ -1943,6 +2068,7 @@ const __test = {
1943
2068
  parseBuildOptions,
1944
2069
  parseNewOptions,
1945
2070
  parsePublishOtaOptions,
2071
+ personalizeRuntimeClient,
1946
2072
  podInstallInputStamp,
1947
2073
  replaceOrInsertPlistString
1948
2074
  };
package/dist/config.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as HexColor, c as defineConfig, i as BleamUserInterfaceStyle, n as BleamConfig, o as appConfig, r as BleamInternalExpoConfig, s as createExpoConfig, t as BleamAppearance } from "./config-CufOVJV3.cjs";
1
+ import { a as HexColor, c as defineConfig, i as BleamUserInterfaceStyle, n as BleamConfig, o as appConfig, r as BleamInternalExpoConfig, s as createExpoConfig, t as BleamAppearance } from "./config-COcRnn5a.cjs";
2
2
  export { BleamAppearance, BleamConfig, BleamInternalExpoConfig, BleamUserInterfaceStyle, HexColor, appConfig, createExpoConfig, defineConfig };