bleam 0.0.9 → 0.0.11

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 (68) hide show
  1. package/dist/ai.cjs +608 -59
  2. package/dist/ai.d.cts +217 -89
  3. package/dist/ai.d.ts +217 -89
  4. package/dist/ai.js +601 -59
  5. package/dist/cli.cjs +142 -94
  6. package/dist/cli.d.cts +11 -27
  7. package/dist/cli.d.ts +11 -27
  8. package/dist/cli.js +143 -95
  9. package/dist/files.d.cts +1 -1
  10. package/dist/files.d.ts +1 -1
  11. package/dist/platform.cjs +1 -13
  12. package/dist/platform.d.cts +1 -26
  13. package/dist/platform.d.ts +1 -26
  14. package/dist/platform.js +1 -10
  15. package/dist/schema.d.cts +1 -1
  16. package/dist/schema.d.ts +1 -1
  17. package/dist/state.d.cts +1 -1
  18. package/dist/state.d.ts +1 -1
  19. package/dist/{ui-Bg11tvlc.d.ts → ui-CHc4xEs_.d.ts} +7 -7
  20. package/dist/ui.d.ts +1 -1
  21. package/dist/window.d.ts +1 -1
  22. package/package.json +2 -1
  23. package/templates/image-generation/app/index.tsx +3 -1
  24. package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +1 -1
  25. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +7 -2
  26. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextGenerator.swift +46 -0
  27. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextModel.swift +107 -0
  28. package/templates/native/ios/Bleam/AI/TextGeneration/Bonsai/BonsaiTextSnapshotValidator.swift +201 -0
  29. package/templates/native/ios/Bleam/AI/TextGeneration/Core/GenerationTypes.swift +85 -0
  30. package/templates/native/ios/Bleam/AI/TextGeneration/Core/ModelCapabilities.swift +21 -0
  31. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TextKVCache.swift +23 -0
  32. package/templates/native/ios/Bleam/AI/TextGeneration/Core/TokenSampler.swift +79 -0
  33. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3CheckpointLoader.swift +161 -0
  34. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Configuration.swift +119 -0
  35. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3InferenceSession.swift +84 -0
  36. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Layers.swift +197 -0
  37. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen3/Qwen3Model.swift +130 -0
  38. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Checkpoint.swift +102 -0
  39. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Configuration.swift +140 -0
  40. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Model.swift +112 -0
  41. package/templates/native/ios/Bleam/AI/TextGeneration/Qwen35/Qwen35Session.swift +121 -0
  42. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridCache.swift +42 -0
  43. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridFullAttention.swift +57 -0
  44. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLayers.swift +58 -0
  45. package/templates/native/ios/Bleam/AI/TextGeneration/QwenHybrid/QwenHybridLinearAttention.swift +111 -0
  46. package/templates/native/ios/Bleam/AppDelegate.swift +0 -97
  47. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +128 -121
  48. package/templates/native/ios/GenerationService/BonsaiTextGenerationRunner.swift +103 -0
  49. package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +19 -7
  50. package/templates/native/ios/GenerationService/main.swift +174 -48
  51. package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +3 -0
  52. package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +44 -0
  53. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +225 -5
  54. package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +47 -0
  55. package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +0 -175
  56. package/templates/text-generation/app/index.tsx +93 -0
  57. package/templates/text-generation/app.config.ts +5 -0
  58. package/templates/updates/README.md +116 -0
  59. package/templates/updates/src/index.ts +292 -0
  60. package/templates/updates/src/schema.ts +230 -0
  61. package/templates/updates/tsconfig.json +12 -0
  62. package/templates/updates/wrangler.jsonc +19 -0
  63. package/templates/native/ios/PlatformHelper/Info.plist +0 -29
  64. package/templates/native/ios/PlatformHelper/main.swift +0 -335
  65. /package/dist/{files-DwA7pzr3.d.cts → files-4ZEoAWiv.d.ts} +0 -0
  66. /package/dist/{files-VrkQlKIT.d.ts → files-Dt5mbzLq.d.cts} +0 -0
  67. /package/dist/{schema-DOOjfXvs.d.ts → schema-CYh6n8GS.d.ts} +0 -0
  68. /package/dist/{schema-ENSMX_1t.d.cts → schema-oeOrd3i1.d.cts} +0 -0
package/dist/cli.cjs CHANGED
@@ -24,6 +24,7 @@ let yoctocolors = require("yoctocolors");
24
24
  yoctocolors = require_chunk.__toESM(yoctocolors);
25
25
 
26
26
  //#region src/cli.ts
27
+ const localUpdateServiceUrl = "http://127.0.0.1:8787";
27
28
  const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
28
29
  const packageRoot = node_path.default.dirname((0, node_url.fileURLToPath)(new URL("../package.json", require("url").pathToFileURL(__filename).href)));
29
30
  const packageJson = require$1("../package.json");
@@ -96,8 +97,6 @@ Commands:
96
97
  Build and install a standalone macOS app
97
98
  publish ota [dir] [--service-url <url>]
98
99
  Publish an OTA update to the local update service
99
- publish platform [dir] [--service-url <url>]
100
- Build and publish a platform update locally
101
100
  doctor [dir] Check the local Bleam environment
102
101
  typecheck [dir] Typecheck project files
103
102
  check [dir] [--write] Format, lint, and organize imports
@@ -108,7 +107,7 @@ function parsePublishOtaOptions(argv) {
108
107
  const root = invocationRoot();
109
108
  let projectRoot = root;
110
109
  let hasProjectRootArg = false;
111
- let serviceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? "http://127.0.0.1:8787";
110
+ let serviceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
112
111
  for (let index = 0; index < argv.length; index += 1) {
113
112
  const arg = argv[index];
114
113
  if (arg === "--service-url") {
@@ -190,7 +189,7 @@ function parseDevOptions(argv) {
190
189
  function parseNewOptions(argv) {
191
190
  const root = invocationRoot();
192
191
  let projectRoot;
193
- let template = "basic";
192
+ let template = "text-generation";
194
193
  for (let index = 0; index < argv.length; index += 1) {
195
194
  const arg = argv[index];
196
195
  if (arg === "--help" || arg === "-h") {
@@ -219,6 +218,7 @@ const projectTemplates = [
219
218
  "basic",
220
219
  "state",
221
220
  "foundation-models",
221
+ "text-generation",
222
222
  "image-generation"
223
223
  ];
224
224
  function projectTemplate(value) {
@@ -479,7 +479,8 @@ function readProjectConfig(options) {
479
479
  teamId: config.teamId,
480
480
  appearance: config.appearance ?? normalizeAppearance(void 0),
481
481
  runtimeVersion,
482
- sdkVersion: runtimeVersion
482
+ sdkVersion: runtimeVersion,
483
+ iconPath: (0, node_fs.existsSync)(node_path.default.join(options.projectRoot, "icon.png")) ? node_path.default.join(options.projectRoot, "icon.png") : void 0
483
484
  };
484
485
  }
485
486
  function slugFromName(name) {
@@ -639,6 +640,18 @@ function nativeRuntimeTemplateRoot(root = packageRoot) {
639
640
  const bundledTemplate = node_path.default.join(root, "templates", "native");
640
641
  return (0, node_fs.existsSync)(bundledTemplate) ? bundledTemplate : node_path.default.resolve(root, "..", "..", "app", "bleam");
641
642
  }
643
+ function localUpdateServiceRoot(root = packageRoot) {
644
+ const bundledService = node_path.default.join(root, "templates", "updates");
645
+ return (0, node_fs.existsSync)(bundledService) ? bundledService : node_path.default.resolve(root, "..", "..", "services", "updates");
646
+ }
647
+ function localUpdateServicePaths(home = node_os.default.homedir()) {
648
+ const root = node_path.default.join(home, "Library", "Caches", "bleam", "updates");
649
+ return {
650
+ root,
651
+ state: node_path.default.join(root, "state"),
652
+ log: node_path.default.join(root, "worker.log")
653
+ };
654
+ }
642
655
  function safeArtifactName(name) {
643
656
  return name.trim().replace(/[/:\\]/g, "-").replace(/\s+/g, " ") || "App";
644
657
  }
@@ -673,11 +686,13 @@ function replaceOrInsertPlistStringArray(plist, key, values) {
673
686
  return `${plist.slice(0, closingDictionary)}\t<key>${key}</key>\n\t<array>\n${plistStringArray(values)}\n\t</array>\n${plist.slice(closingDictionary)}`;
674
687
  }
675
688
  function writeGeneratedAppJson(nativeRoot, config) {
689
+ const icon = config.iconPath ? "./icon.png" : void 0;
676
690
  (0, node_fs.writeFileSync)(node_path.default.join(nativeRoot, "app.json"), `${JSON.stringify({ expo: {
677
691
  name: config.name,
678
692
  slug: slugFromName(config.name),
679
693
  version: config.version ?? "1.0.0",
680
694
  platforms: ["ios"],
695
+ icon,
681
696
  ios: {
682
697
  appleTeamId: config.teamId,
683
698
  buildNumber: config.buildNumber,
@@ -685,24 +700,43 @@ function writeGeneratedAppJson(nativeRoot, config) {
685
700
  }
686
701
  } }, null, 2)}\n`);
687
702
  }
703
+ function prepareNativeIcon(nativeRoot, iconPath) {
704
+ const generatedIcon = node_path.default.join(nativeRoot, "icon.png");
705
+ const appIconRoot = node_path.default.join(nativeRoot, "ios", "Bleam", "Images.xcassets", "AppIcon.appiconset");
706
+ (0, node_fs.rmSync)(generatedIcon, { force: true });
707
+ (0, node_fs.rmSync)(node_path.default.join(appIconRoot, "AppIcon.png"), { force: true });
708
+ if (!iconPath) return;
709
+ (0, node_fs.cpSync)(iconPath, generatedIcon);
710
+ (0, node_fs.cpSync)(iconPath, node_path.default.join(appIconRoot, "AppIcon.png"));
711
+ (0, node_fs.writeFileSync)(node_path.default.join(appIconRoot, "Contents.json"), `${JSON.stringify({
712
+ images: [{
713
+ filename: "AppIcon.png",
714
+ idiom: "universal",
715
+ platform: "ios",
716
+ size: "1024x1024"
717
+ }],
718
+ info: {
719
+ version: 1,
720
+ author: "bleam"
721
+ }
722
+ }, null, 2)}\n`);
723
+ }
688
724
  function patchNativeProject(nativeRoot, config) {
689
725
  const projectPath = node_path.default.join(nativeRoot, "ios", "Bleam.xcodeproj", "project.pbxproj");
690
726
  const infoPlistPath = node_path.default.join(nativeRoot, "ios", "Bleam", "Info.plist");
691
727
  const generationInfoPlistPath = node_path.default.join(nativeRoot, "ios", "GenerationService", "Info.plist");
692
- const platformInfoPlistPath = node_path.default.join(nativeRoot, "ios", "PlatformHelper", "Info.plist");
693
728
  const appEntitlementsPath = node_path.default.join(nativeRoot, "ios", "Bleam", "bleam.entitlements");
694
729
  const generationEntitlementsPath = node_path.default.join(nativeRoot, "ios", "GenerationService", "GenerationService.entitlements");
695
730
  const productName = xcodeSettingValue(config.name);
696
731
  const bundleIdentifier = xcodeSettingValue(config.bundleIdentifier ?? "");
697
732
  const generationBundleIdentifier = xcodeSettingValue(`${config.bundleIdentifier}.GenerationService`);
698
- const platformBundleIdentifier = xcodeSettingValue(`${config.bundleIdentifier}.PlatformHelper`);
699
733
  const teamId = xcodeSettingValue(config.teamId ?? "");
700
734
  const version = xcodeSettingValue(config.version ?? "1.0.0");
701
735
  const buildNumber = xcodeSettingValue(config.buildNumber);
702
736
  const primaryAppGroup = config.appGroups[0];
703
737
  let project = (0, node_fs.readFileSync)(projectPath, "utf8");
704
738
  project = project.replace(/PRODUCT_BUNDLE_IDENTIFIER = ([^;]+);/g, (_, current) => {
705
- return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : current.endsWith(".PlatformHelper") ? platformBundleIdentifier : bundleIdentifier};`;
739
+ return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : bundleIdentifier};`;
706
740
  }).replace(/DEVELOPMENT_TEAM = [^;]+;/g, () => {
707
741
  return `DEVELOPMENT_TEAM = ${teamId};`;
708
742
  }).replace(/MARKETING_VERSION = [^;]+;/g, () => {
@@ -718,8 +752,8 @@ function patchNativeProject(nativeRoot, config) {
718
752
  infoPlist = replacePlistString(infoPlist, "CFBundleShortVersionString", config.version ?? "1.0.0");
719
753
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamRuntimeVersion", config.runtimeVersion);
720
754
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamTeamIdentifier", config.teamId ?? "");
721
- const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL;
722
- if (updateServiceUrl) infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
755
+ const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
756
+ infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
723
757
  infoPlist = replacePlistString(infoPlist, "CFBundleVersion", config.buildNumber);
724
758
  if (primaryAppGroup) infoPlist = replaceOrInsertPlistString(infoPlist, "AppGroupIdentifier", primaryAppGroup);
725
759
  (0, node_fs.writeFileSync)(infoPlistPath, infoPlist);
@@ -727,7 +761,6 @@ function patchNativeProject(nativeRoot, config) {
727
761
  let generationInfoPlist = (0, node_fs.readFileSync)(generationInfoPlistPath, "utf8");
728
762
  generationInfoPlist = replaceOrInsertPlistString(generationInfoPlist, "AppGroupIdentifier", primaryAppGroup);
729
763
  (0, node_fs.writeFileSync)(generationInfoPlistPath, generationInfoPlist);
730
- (0, node_fs.writeFileSync)(platformInfoPlistPath, replaceOrInsertPlistString((0, node_fs.readFileSync)(platformInfoPlistPath, "utf8"), "BleamPlatformVersion", config.runtimeVersion));
731
764
  for (const entitlementsPath of [appEntitlementsPath, generationEntitlementsPath]) (0, node_fs.writeFileSync)(entitlementsPath, replaceOrInsertPlistStringArray((0, node_fs.readFileSync)(entitlementsPath, "utf8"), "com.apple.security.application-groups", config.appGroups));
732
765
  }
733
766
  }
@@ -760,6 +793,7 @@ function createBuildNativeWorkspace(options, config) {
760
793
  (0, node_fs.writeFileSync)(node_path.default.join(nativeRoot, "index.ts"), `import { registerApp } from 'bleam/app'\nimport App from ${JSON.stringify(node_path.default.join(options.projectRoot, "app"))}\n\nregisterApp(App)\n`);
761
794
  (0, node_fs.writeFileSync)(node_path.default.join(nativeRoot, "metro.config.js"), `const { getDefaultConfig } = require(${JSON.stringify(node_path.default.join(packageRoot, "metro-config.cjs"))})\n\nmodule.exports = getDefaultConfig(__dirname)\n`);
762
795
  (0, node_fs.writeFileSync)(node_path.default.join(nativeRoot, "ios", ".xcode.env"), `export NODE_BINARY=$(command -v node)\nexport BLEAM_PROJECT_ROOT=${singleQuotedString(options.projectRoot)}\nexport BLEAM_DEV_PLATFORM=macos\n`);
796
+ prepareNativeIcon(nativeRoot, config.iconPath);
763
797
  patchNativeProject(nativeRoot, config);
764
798
  return nativeRoot;
765
799
  }
@@ -784,14 +818,13 @@ function runInheritedCommand(command, args, cwd) {
784
818
  }
785
819
  function installPods(nativeRoot) {
786
820
  const iosRoot = node_path.default.join(nativeRoot, "ios");
787
- const expectedStamp = podInstallInputStamp(iosRoot);
788
- if (hasCurrentPodInstall(iosRoot, expectedStamp)) {
821
+ if (hasCurrentPodInstall(iosRoot, podInstallInputStamp(iosRoot))) {
789
822
  console.log("Using cached native dependencies");
790
823
  return;
791
824
  }
792
825
  console.log("Installing native dependencies...");
793
826
  runInheritedCommand("pod", ["install"], iosRoot);
794
- (0, node_fs.writeFileSync)(podInstallStampPath(iosRoot), `${expectedStamp}\n`);
827
+ (0, node_fs.writeFileSync)(podInstallStampPath(iosRoot), `${podInstallInputStamp(iosRoot)}\n`);
795
828
  }
796
829
  function ensureNativeFrameworks(nativeRoot) {
797
830
  const frameworksRoot = node_path.default.join(nativeRoot, "ios", "Vendor", "MLXSwift", "0.31.6-macos");
@@ -824,7 +857,9 @@ function podInstallStampPath(iosRoot) {
824
857
  }
825
858
  function hasCurrentPodInstall(iosRoot, expectedStamp) {
826
859
  const stampPath = podInstallStampPath(iosRoot);
827
- return (0, node_fs.existsSync)(node_path.default.join(iosRoot, "Bleam.xcworkspace")) && (0, node_fs.existsSync)(node_path.default.join(iosRoot, "Pods", "Manifest.lock")) && (0, node_fs.existsSync)(stampPath) && (0, node_fs.readFileSync)(stampPath, "utf8").trim() === expectedStamp;
860
+ const lockPath = node_path.default.join(iosRoot, "Podfile.lock");
861
+ const manifestPath = node_path.default.join(iosRoot, "Pods", "Manifest.lock");
862
+ return (0, node_fs.existsSync)(node_path.default.join(iosRoot, "Bleam.xcworkspace")) && (0, node_fs.existsSync)(lockPath) && (0, node_fs.existsSync)(manifestPath) && (0, node_fs.readFileSync)(lockPath, "utf8") === (0, node_fs.readFileSync)(manifestPath, "utf8") && (0, node_fs.existsSync)(stampPath) && (0, node_fs.readFileSync)(stampPath, "utf8").trim() === expectedStamp;
828
863
  }
829
864
  function nativeArchiveArgs(options) {
830
865
  return [
@@ -999,79 +1034,6 @@ async function publishOta(options) {
999
1034
  console.log(`Published OTA update ${releaseId}`);
1000
1035
  console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/ota/${runtimeVersion}`);
1001
1036
  }
1002
- async function publishPlatform(options) {
1003
- const config = readProjectConfig(options);
1004
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1005
- if (!config.teamId) throw missingBuildFieldError("teamId");
1006
- const archivePath = await buildNativeArchives({
1007
- projectRoot: options.projectRoot,
1008
- output: node_path.default.join(options.projectRoot, "dist"),
1009
- configuration: "Release",
1010
- clean: false
1011
- });
1012
- const products = node_path.default.join(archivePath, "Products", "Applications");
1013
- const appName = (0, node_fs.readdirSync)(products).find((name) => name.endsWith(".app"));
1014
- if (!appName) throw new Error(`Archive does not contain a macOS app: ${archivePath}`);
1015
- const outputRoot = node_path.default.join(options.projectRoot, ".bleam", "publish", "platform");
1016
- const stagingRoot = node_path.default.join(outputRoot, "app");
1017
- const artifactPath = node_path.default.join(outputRoot, "platform.zip");
1018
- (0, node_fs.rmSync)(outputRoot, {
1019
- recursive: true,
1020
- force: true
1021
- });
1022
- (0, node_fs.mkdirSync)(stagingRoot, { recursive: true });
1023
- (0, node_child_process.execFileSync)("ditto", [node_path.default.join(products, appName), node_path.default.join(stagingRoot, appName)]);
1024
- runInheritedCommand("zip", [
1025
- "-q",
1026
- "-r",
1027
- "-y",
1028
- artifactPath,
1029
- "app"
1030
- ], outputRoot);
1031
- const sizeBytes = (0, node_fs.readFileSync)(artifactPath).byteLength;
1032
- const digest = sha256(artifactPath);
1033
- const releaseId = `platform_${Date.now().toString(36)}_${digest.slice(0, 12)}`;
1034
- const release = platformRelease(config, releaseId, sizeBytes, digest);
1035
- const response = await fetch(`${options.serviceUrl}/v1/local/releases/platform`, {
1036
- method: "POST",
1037
- headers: { "content-type": "application/json" },
1038
- body: JSON.stringify({
1039
- release,
1040
- artifactBase64: (0, node_fs.readFileSync)(artifactPath).toString("base64")
1041
- })
1042
- });
1043
- if (!response.ok) throw new Error(`Local platform publication failed: ${response.status} ${await response.text()}`);
1044
- console.log(`Published platform update ${releaseId}`);
1045
- console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/platform/macos-arm64`);
1046
- }
1047
- function platformRelease(config, releaseId, sizeBytes, digest) {
1048
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1049
- if (!config.teamId) throw missingBuildFieldError("teamId");
1050
- return {
1051
- schemaVersion: 1,
1052
- kind: "platform",
1053
- bundleIdentifier: config.bundleIdentifier,
1054
- teamIdentifier: config.teamId,
1055
- channel: "stable",
1056
- releaseId,
1057
- appVersion: config.version ?? "1.0.0",
1058
- buildNumber: config.buildNumber,
1059
- bleamPlatformVersion: runtimeVersion,
1060
- target: {
1061
- os: "macos",
1062
- architecture: "arm64",
1063
- installLocation: "user-applications",
1064
- minimumMacOSVersion: "14.0"
1065
- },
1066
- artifact: {
1067
- format: "bleam-macos-app-zip-v1",
1068
- downloadId: releaseId,
1069
- sizeBytes,
1070
- sha256: digest
1071
- },
1072
- publishedAt: (/* @__PURE__ */ new Date()).toISOString()
1073
- };
1074
- }
1075
1037
  function runtimeCacheRoot() {
1076
1038
  return node_path.default.join(node_os.default.homedir(), "Library", "Caches", "bleam", "runtimes", runtimeVersion, artifactPlatform());
1077
1039
  }
@@ -1405,6 +1367,92 @@ async function launchRuntimeClient(appPath, projectConfigPath, manifest) {
1405
1367
  quitRuntimeClient();
1406
1368
  openRuntimeClient(appPath, projectConfigPath, manifest);
1407
1369
  }
1370
+ async function updateServiceHealthy(serviceUrl) {
1371
+ try {
1372
+ const response = await fetch(`${serviceUrl}/v1/health`, {
1373
+ cache: "no-store",
1374
+ signal: AbortSignal.timeout(1e3)
1375
+ });
1376
+ if (!response.ok) return false;
1377
+ return (await response.json()).healthy === true;
1378
+ } catch {
1379
+ return false;
1380
+ }
1381
+ }
1382
+ function updateServiceLogTail(logPath) {
1383
+ if (!(0, node_fs.existsSync)(logPath)) return "";
1384
+ return (0, node_fs.readFileSync)(logPath, "utf8").slice(-4e3).trim();
1385
+ }
1386
+ async function waitForUpdateService(child, serviceUrl, logPath, timeoutMs = 3e4) {
1387
+ const startedAt = Date.now();
1388
+ let startupError;
1389
+ child.once("error", (error) => {
1390
+ startupError = error;
1391
+ });
1392
+ while (Date.now() - startedAt < timeoutMs) {
1393
+ if (startupError || child.exitCode !== null) break;
1394
+ if (await updateServiceHealthy(serviceUrl)) return;
1395
+ await new Promise((resolve) => setTimeout(resolve, 250));
1396
+ }
1397
+ const log = updateServiceLogTail(logPath);
1398
+ const detail = log ? `\n\n${log}` : "";
1399
+ throw new Error(`Local update Worker failed to start.\nLog: ${logPath}${detail}`, startupError ? { cause: startupError } : void 0);
1400
+ }
1401
+ async function startLocalUpdateService() {
1402
+ const configuredUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
1403
+ const serviceUrl = new URL(configuredUrl).origin;
1404
+ if (await updateServiceHealthy(serviceUrl)) {
1405
+ console.log(`Using local update Worker at ${serviceUrl}`);
1406
+ return {
1407
+ child: void 0,
1408
+ serviceUrl
1409
+ };
1410
+ }
1411
+ if (serviceUrl !== localUpdateServiceUrl) throw new Error(`BLEAM_UPDATE_SERVICE_URL is not healthy: ${serviceUrl}/v1/health`);
1412
+ const serviceRoot = localUpdateServiceRoot();
1413
+ const configPath = node_path.default.join(serviceRoot, "wrangler.jsonc");
1414
+ if (!(0, node_fs.existsSync)(configPath)) throw new Error(`Missing local update Worker: ${serviceRoot}`);
1415
+ const wrangler = node_path.default.join(resolvedDependencyRoot(), ".bin", "wrangler");
1416
+ if (!(0, node_fs.existsSync)(wrangler)) throw new Error("Missing Wrangler dependency for the local update Worker");
1417
+ const paths = localUpdateServicePaths();
1418
+ (0, node_fs.mkdirSync)(paths.state, { recursive: true });
1419
+ const log = (0, node_fs.openSync)(paths.log, "a");
1420
+ const child = (0, node_child_process.spawn)(wrangler, [
1421
+ "dev",
1422
+ "--config",
1423
+ configPath,
1424
+ "--local",
1425
+ "--persist-to",
1426
+ paths.state,
1427
+ "--ip",
1428
+ "127.0.0.1",
1429
+ "--port",
1430
+ "8787"
1431
+ ], {
1432
+ cwd: serviceRoot,
1433
+ stdio: [
1434
+ "ignore",
1435
+ log,
1436
+ log
1437
+ ],
1438
+ env: {
1439
+ ...process.env,
1440
+ NO_COLOR: "1"
1441
+ }
1442
+ });
1443
+ (0, node_fs.closeSync)(log);
1444
+ try {
1445
+ await waitForUpdateService(child, serviceUrl, paths.log);
1446
+ } catch (error) {
1447
+ child.kill("SIGTERM");
1448
+ throw error;
1449
+ }
1450
+ console.log(`Local update Worker running at ${serviceUrl}`);
1451
+ return {
1452
+ child,
1453
+ serviceUrl
1454
+ };
1455
+ }
1408
1456
  function focusRuntimeClient() {
1409
1457
  return (0, node_child_process.spawnSync)("osascript", ["-e", "tell application id \"dev.bleam.app\" to activate"], { stdio: "ignore" }).status === 0;
1410
1458
  }
@@ -1739,6 +1787,7 @@ async function startDevServer(options) {
1739
1787
  const workspaceRoot = createDevWorkspace(options.projectRoot, config);
1740
1788
  const origin = `http://localhost:${options.port}`;
1741
1789
  const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin);
1790
+ const updateService = await startLocalUpdateService();
1742
1791
  const child = (0, node_child_process.spawn)(process.execPath, [
1743
1792
  (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href),
1744
1793
  "internal:metro",
@@ -1759,6 +1808,7 @@ async function startDevServer(options) {
1759
1808
  BLEAM_DEV_PLATFORM: "macos",
1760
1809
  BLEAM_DEV_RUNTIME_VERSION: config.runtimeVersion,
1761
1810
  BLEAM_DEV_SDK_VERSION: config.sdkVersion,
1811
+ BLEAM_UPDATE_SERVICE_URL: updateService.serviceUrl,
1762
1812
  NODE_PATH: [
1763
1813
  node_path.default.join(options.projectRoot, "node_modules"),
1764
1814
  resolvedDependencyRoot(),
@@ -1778,6 +1828,7 @@ async function startDevServer(options) {
1778
1828
  didCleanupDevSession = true;
1779
1829
  cleanupInteractiveControls();
1780
1830
  if (didLaunchRuntimeClient) quitRuntimeClient();
1831
+ if (updateService.child?.exitCode === null) updateService.child.kill("SIGTERM");
1781
1832
  };
1782
1833
  const stop = (signal) => {
1783
1834
  if (stopping) return;
@@ -1859,11 +1910,7 @@ async function main(argv = process.argv.slice(2)) {
1859
1910
  await publishOta(parsePublishOtaOptions(publishArgs));
1860
1911
  return;
1861
1912
  }
1862
- if (kind === "platform") {
1863
- await publishPlatform(parsePublishOtaOptions(publishArgs));
1864
- return;
1865
- }
1866
- throw new Error("Usage: bleam publish <ota|platform> [dir] [--service-url <url>]");
1913
+ throw new Error("Usage: bleam publish ota [dir] [--service-url <url>]");
1867
1914
  }
1868
1915
  if (command === "doctor") {
1869
1916
  runDoctor(parseDoctorOptions(args));
@@ -1901,12 +1948,13 @@ const __test = {
1901
1948
  hasCurrentPodInstall,
1902
1949
  installedAppPath,
1903
1950
  installArchivedApp,
1951
+ localUpdateServicePaths,
1952
+ localUpdateServiceRoot,
1904
1953
  nativeRuntimeTemplateRoot,
1905
1954
  nativeArchiveArgs,
1906
1955
  parseBuildOptions,
1907
1956
  parseNewOptions,
1908
1957
  parsePublishOtaOptions,
1909
- platformRelease,
1910
1958
  podInstallInputStamp,
1911
1959
  replaceOrInsertPlistString
1912
1960
  };
package/dist/cli.d.cts CHANGED
@@ -23,13 +23,14 @@ interface ProjectConfig {
23
23
  appearance: BleamAppearance;
24
24
  runtimeVersion: string;
25
25
  sdkVersion: string;
26
+ iconPath?: string;
26
27
  }
27
28
  declare function parsePublishOtaOptions(argv: string[]): PublishOtaOptions;
28
29
  declare function parseNewOptions(argv: string[]): {
29
30
  projectRoot: string;
30
- template: "basic" | "state" | "foundation-models" | "image-generation";
31
+ template: "state" | "basic" | "foundation-models" | "text-generation" | "image-generation";
31
32
  };
32
- declare const projectTemplates: readonly ["basic", "state", "foundation-models", "image-generation"];
33
+ declare const projectTemplates: readonly ["basic", "state", "foundation-models", "text-generation", "image-generation"];
33
34
  type ProjectTemplate = (typeof projectTemplates)[number];
34
35
  declare function parseBuildOptions(argv: string[]): BuildOptions;
35
36
  declare function createProject(options: {
@@ -37,6 +38,12 @@ declare function createProject(options: {
37
38
  template?: ProjectTemplate;
38
39
  }): void;
39
40
  declare function nativeRuntimeTemplateRoot(root?: string): string;
41
+ declare function localUpdateServiceRoot(root?: string): string;
42
+ declare function localUpdateServicePaths(home?: string): {
43
+ root: string;
44
+ state: string;
45
+ log: string;
46
+ };
40
47
  declare function replaceOrInsertPlistString(plist: string, key: string, value: string): string;
41
48
  declare function createBuildNativeWorkspace(options: BuildOptions, config: ProjectConfig): string;
42
49
  declare function podInstallInputStamp(iosRoot: string): string;
@@ -48,42 +55,19 @@ declare function nativeArchiveArgs(options: {
48
55
  }): string[];
49
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
50
57
  declare function installedAppPath(appName: string): string;
51
- declare function platformRelease(config: ProjectConfig, releaseId: string, sizeBytes: number, digest: string): {
52
- schemaVersion: number;
53
- kind: string;
54
- bundleIdentifier: string;
55
- teamIdentifier: string;
56
- channel: string;
57
- releaseId: string;
58
- appVersion: string;
59
- buildNumber: string;
60
- bleamPlatformVersion: string;
61
- target: {
62
- os: string;
63
- architecture: string;
64
- installLocation: string;
65
- minimumMacOSVersion: string;
66
- };
67
- artifact: {
68
- format: string;
69
- downloadId: string;
70
- sizeBytes: number;
71
- sha256: string;
72
- };
73
- publishedAt: string;
74
- };
75
58
  declare const __test: {
76
59
  createProject: typeof createProject;
77
60
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
78
61
  hasCurrentPodInstall: typeof hasCurrentPodInstall;
79
62
  installedAppPath: typeof installedAppPath;
80
63
  installArchivedApp: typeof installArchivedApp;
64
+ localUpdateServicePaths: typeof localUpdateServicePaths;
65
+ localUpdateServiceRoot: typeof localUpdateServiceRoot;
81
66
  nativeRuntimeTemplateRoot: typeof nativeRuntimeTemplateRoot;
82
67
  nativeArchiveArgs: typeof nativeArchiveArgs;
83
68
  parseBuildOptions: typeof parseBuildOptions;
84
69
  parseNewOptions: typeof parseNewOptions;
85
70
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
86
- platformRelease: typeof platformRelease;
87
71
  podInstallInputStamp: typeof podInstallInputStamp;
88
72
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
89
73
  };
package/dist/cli.d.ts CHANGED
@@ -23,13 +23,14 @@ interface ProjectConfig {
23
23
  appearance: BleamAppearance;
24
24
  runtimeVersion: string;
25
25
  sdkVersion: string;
26
+ iconPath?: string;
26
27
  }
27
28
  declare function parsePublishOtaOptions(argv: string[]): PublishOtaOptions;
28
29
  declare function parseNewOptions(argv: string[]): {
29
30
  projectRoot: string;
30
- template: "basic" | "state" | "foundation-models" | "image-generation";
31
+ template: "state" | "basic" | "foundation-models" | "text-generation" | "image-generation";
31
32
  };
32
- declare const projectTemplates: readonly ["basic", "state", "foundation-models", "image-generation"];
33
+ declare const projectTemplates: readonly ["basic", "state", "foundation-models", "text-generation", "image-generation"];
33
34
  type ProjectTemplate = (typeof projectTemplates)[number];
34
35
  declare function parseBuildOptions(argv: string[]): BuildOptions;
35
36
  declare function createProject(options: {
@@ -37,6 +38,12 @@ declare function createProject(options: {
37
38
  template?: ProjectTemplate;
38
39
  }): void;
39
40
  declare function nativeRuntimeTemplateRoot(root?: string): string;
41
+ declare function localUpdateServiceRoot(root?: string): string;
42
+ declare function localUpdateServicePaths(home?: string): {
43
+ root: string;
44
+ state: string;
45
+ log: string;
46
+ };
40
47
  declare function replaceOrInsertPlistString(plist: string, key: string, value: string): string;
41
48
  declare function createBuildNativeWorkspace(options: BuildOptions, config: ProjectConfig): string;
42
49
  declare function podInstallInputStamp(iosRoot: string): string;
@@ -48,42 +55,19 @@ declare function nativeArchiveArgs(options: {
48
55
  }): string[];
49
56
  declare function installArchivedApp(archivePath: string, applications?: string): string;
50
57
  declare function installedAppPath(appName: string): string;
51
- declare function platformRelease(config: ProjectConfig, releaseId: string, sizeBytes: number, digest: string): {
52
- schemaVersion: number;
53
- kind: string;
54
- bundleIdentifier: string;
55
- teamIdentifier: string;
56
- channel: string;
57
- releaseId: string;
58
- appVersion: string;
59
- buildNumber: string;
60
- bleamPlatformVersion: string;
61
- target: {
62
- os: string;
63
- architecture: string;
64
- installLocation: string;
65
- minimumMacOSVersion: string;
66
- };
67
- artifact: {
68
- format: string;
69
- downloadId: string;
70
- sizeBytes: number;
71
- sha256: string;
72
- };
73
- publishedAt: string;
74
- };
75
58
  declare const __test: {
76
59
  createProject: typeof createProject;
77
60
  createBuildNativeWorkspace: typeof createBuildNativeWorkspace;
78
61
  hasCurrentPodInstall: typeof hasCurrentPodInstall;
79
62
  installedAppPath: typeof installedAppPath;
80
63
  installArchivedApp: typeof installArchivedApp;
64
+ localUpdateServicePaths: typeof localUpdateServicePaths;
65
+ localUpdateServiceRoot: typeof localUpdateServiceRoot;
81
66
  nativeRuntimeTemplateRoot: typeof nativeRuntimeTemplateRoot;
82
67
  nativeArchiveArgs: typeof nativeArchiveArgs;
83
68
  parseBuildOptions: typeof parseBuildOptions;
84
69
  parseNewOptions: typeof parseNewOptions;
85
70
  parsePublishOtaOptions: typeof parsePublishOtaOptions;
86
- platformRelease: typeof platformRelease;
87
71
  podInstallInputStamp: typeof podInstallInputStamp;
88
72
  replaceOrInsertPlistString: typeof replaceOrInsertPlistString;
89
73
  };