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.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { execFileSync, spawn, spawnSync } from "node:child_process";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
- import { appendFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
5
+ import { appendFileSync, closeSync, cpSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
6
6
  import http from "node:http";
7
7
  import os from "node:os";
8
8
  import path from "node:path";
@@ -12,6 +12,7 @@ import yoctoSpinner from "yocto-spinner";
12
12
  import { bold, dim, green, red, yellow } from "yoctocolors";
13
13
 
14
14
  //#region src/cli.ts
15
+ const localUpdateServiceUrl = "http://127.0.0.1:8787";
15
16
  const require = createRequire(import.meta.url);
16
17
  const packageRoot = path.dirname(fileURLToPath(new URL("../package.json", import.meta.url)));
17
18
  const packageJson = require("../package.json");
@@ -84,8 +85,6 @@ Commands:
84
85
  Build and install a standalone macOS app
85
86
  publish ota [dir] [--service-url <url>]
86
87
  Publish an OTA update to the local update service
87
- publish platform [dir] [--service-url <url>]
88
- Build and publish a platform update locally
89
88
  doctor [dir] Check the local Bleam environment
90
89
  typecheck [dir] Typecheck project files
91
90
  check [dir] [--write] Format, lint, and organize imports
@@ -96,7 +95,7 @@ function parsePublishOtaOptions(argv) {
96
95
  const root = invocationRoot();
97
96
  let projectRoot = root;
98
97
  let hasProjectRootArg = false;
99
- let serviceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? "http://127.0.0.1:8787";
98
+ let serviceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
100
99
  for (let index = 0; index < argv.length; index += 1) {
101
100
  const arg = argv[index];
102
101
  if (arg === "--service-url") {
@@ -178,7 +177,7 @@ function parseDevOptions(argv) {
178
177
  function parseNewOptions(argv) {
179
178
  const root = invocationRoot();
180
179
  let projectRoot;
181
- let template = "basic";
180
+ let template = "text-generation";
182
181
  for (let index = 0; index < argv.length; index += 1) {
183
182
  const arg = argv[index];
184
183
  if (arg === "--help" || arg === "-h") {
@@ -207,6 +206,7 @@ const projectTemplates = [
207
206
  "basic",
208
207
  "state",
209
208
  "foundation-models",
209
+ "text-generation",
210
210
  "image-generation"
211
211
  ];
212
212
  function projectTemplate(value) {
@@ -467,7 +467,8 @@ function readProjectConfig(options) {
467
467
  teamId: config.teamId,
468
468
  appearance: config.appearance ?? normalizeAppearance(void 0),
469
469
  runtimeVersion,
470
- sdkVersion: runtimeVersion
470
+ sdkVersion: runtimeVersion,
471
+ iconPath: existsSync(path.join(options.projectRoot, "icon.png")) ? path.join(options.projectRoot, "icon.png") : void 0
471
472
  };
472
473
  }
473
474
  function slugFromName(name) {
@@ -627,6 +628,18 @@ function nativeRuntimeTemplateRoot(root = packageRoot) {
627
628
  const bundledTemplate = path.join(root, "templates", "native");
628
629
  return existsSync(bundledTemplate) ? bundledTemplate : path.resolve(root, "..", "..", "app", "bleam");
629
630
  }
631
+ function localUpdateServiceRoot(root = packageRoot) {
632
+ const bundledService = path.join(root, "templates", "updates");
633
+ return existsSync(bundledService) ? bundledService : path.resolve(root, "..", "..", "services", "updates");
634
+ }
635
+ function localUpdateServicePaths(home = os.homedir()) {
636
+ const root = path.join(home, "Library", "Caches", "bleam", "updates");
637
+ return {
638
+ root,
639
+ state: path.join(root, "state"),
640
+ log: path.join(root, "worker.log")
641
+ };
642
+ }
630
643
  function safeArtifactName(name) {
631
644
  return name.trim().replace(/[/:\\]/g, "-").replace(/\s+/g, " ") || "App";
632
645
  }
@@ -661,11 +674,13 @@ function replaceOrInsertPlistStringArray(plist, key, values) {
661
674
  return `${plist.slice(0, closingDictionary)}\t<key>${key}</key>\n\t<array>\n${plistStringArray(values)}\n\t</array>\n${plist.slice(closingDictionary)}`;
662
675
  }
663
676
  function writeGeneratedAppJson(nativeRoot, config) {
677
+ const icon = config.iconPath ? "./icon.png" : void 0;
664
678
  writeFileSync(path.join(nativeRoot, "app.json"), `${JSON.stringify({ expo: {
665
679
  name: config.name,
666
680
  slug: slugFromName(config.name),
667
681
  version: config.version ?? "1.0.0",
668
682
  platforms: ["ios"],
683
+ icon,
669
684
  ios: {
670
685
  appleTeamId: config.teamId,
671
686
  buildNumber: config.buildNumber,
@@ -673,24 +688,43 @@ function writeGeneratedAppJson(nativeRoot, config) {
673
688
  }
674
689
  } }, null, 2)}\n`);
675
690
  }
691
+ function prepareNativeIcon(nativeRoot, iconPath) {
692
+ const generatedIcon = path.join(nativeRoot, "icon.png");
693
+ const appIconRoot = path.join(nativeRoot, "ios", "Bleam", "Images.xcassets", "AppIcon.appiconset");
694
+ rmSync(generatedIcon, { force: true });
695
+ rmSync(path.join(appIconRoot, "AppIcon.png"), { force: true });
696
+ if (!iconPath) return;
697
+ cpSync(iconPath, generatedIcon);
698
+ cpSync(iconPath, path.join(appIconRoot, "AppIcon.png"));
699
+ writeFileSync(path.join(appIconRoot, "Contents.json"), `${JSON.stringify({
700
+ images: [{
701
+ filename: "AppIcon.png",
702
+ idiom: "universal",
703
+ platform: "ios",
704
+ size: "1024x1024"
705
+ }],
706
+ info: {
707
+ version: 1,
708
+ author: "bleam"
709
+ }
710
+ }, null, 2)}\n`);
711
+ }
676
712
  function patchNativeProject(nativeRoot, config) {
677
713
  const projectPath = path.join(nativeRoot, "ios", "Bleam.xcodeproj", "project.pbxproj");
678
714
  const infoPlistPath = path.join(nativeRoot, "ios", "Bleam", "Info.plist");
679
715
  const generationInfoPlistPath = path.join(nativeRoot, "ios", "GenerationService", "Info.plist");
680
- const platformInfoPlistPath = path.join(nativeRoot, "ios", "PlatformHelper", "Info.plist");
681
716
  const appEntitlementsPath = path.join(nativeRoot, "ios", "Bleam", "bleam.entitlements");
682
717
  const generationEntitlementsPath = path.join(nativeRoot, "ios", "GenerationService", "GenerationService.entitlements");
683
718
  const productName = xcodeSettingValue(config.name);
684
719
  const bundleIdentifier = xcodeSettingValue(config.bundleIdentifier ?? "");
685
720
  const generationBundleIdentifier = xcodeSettingValue(`${config.bundleIdentifier}.GenerationService`);
686
- const platformBundleIdentifier = xcodeSettingValue(`${config.bundleIdentifier}.PlatformHelper`);
687
721
  const teamId = xcodeSettingValue(config.teamId ?? "");
688
722
  const version = xcodeSettingValue(config.version ?? "1.0.0");
689
723
  const buildNumber = xcodeSettingValue(config.buildNumber);
690
724
  const primaryAppGroup = config.appGroups[0];
691
725
  let project = readFileSync(projectPath, "utf8");
692
726
  project = project.replace(/PRODUCT_BUNDLE_IDENTIFIER = ([^;]+);/g, (_, current) => {
693
- return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : current.endsWith(".PlatformHelper") ? platformBundleIdentifier : bundleIdentifier};`;
727
+ return `PRODUCT_BUNDLE_IDENTIFIER = ${current.endsWith(".GenerationService") ? generationBundleIdentifier : bundleIdentifier};`;
694
728
  }).replace(/DEVELOPMENT_TEAM = [^;]+;/g, () => {
695
729
  return `DEVELOPMENT_TEAM = ${teamId};`;
696
730
  }).replace(/MARKETING_VERSION = [^;]+;/g, () => {
@@ -706,8 +740,8 @@ function patchNativeProject(nativeRoot, config) {
706
740
  infoPlist = replacePlistString(infoPlist, "CFBundleShortVersionString", config.version ?? "1.0.0");
707
741
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamRuntimeVersion", config.runtimeVersion);
708
742
  infoPlist = replaceOrInsertPlistString(infoPlist, "BleamTeamIdentifier", config.teamId ?? "");
709
- const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL;
710
- if (updateServiceUrl) infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
743
+ const updateServiceUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
744
+ infoPlist = replaceOrInsertPlistString(infoPlist, "BleamUpdateServiceURL", updateServiceUrl);
711
745
  infoPlist = replacePlistString(infoPlist, "CFBundleVersion", config.buildNumber);
712
746
  if (primaryAppGroup) infoPlist = replaceOrInsertPlistString(infoPlist, "AppGroupIdentifier", primaryAppGroup);
713
747
  writeFileSync(infoPlistPath, infoPlist);
@@ -715,7 +749,6 @@ function patchNativeProject(nativeRoot, config) {
715
749
  let generationInfoPlist = readFileSync(generationInfoPlistPath, "utf8");
716
750
  generationInfoPlist = replaceOrInsertPlistString(generationInfoPlist, "AppGroupIdentifier", primaryAppGroup);
717
751
  writeFileSync(generationInfoPlistPath, generationInfoPlist);
718
- writeFileSync(platformInfoPlistPath, replaceOrInsertPlistString(readFileSync(platformInfoPlistPath, "utf8"), "BleamPlatformVersion", config.runtimeVersion));
719
752
  for (const entitlementsPath of [appEntitlementsPath, generationEntitlementsPath]) writeFileSync(entitlementsPath, replaceOrInsertPlistStringArray(readFileSync(entitlementsPath, "utf8"), "com.apple.security.application-groups", config.appGroups));
720
753
  }
721
754
  }
@@ -748,6 +781,7 @@ function createBuildNativeWorkspace(options, config) {
748
781
  writeFileSync(path.join(nativeRoot, "index.ts"), `import { registerApp } from 'bleam/app'\nimport App from ${JSON.stringify(path.join(options.projectRoot, "app"))}\n\nregisterApp(App)\n`);
749
782
  writeFileSync(path.join(nativeRoot, "metro.config.js"), `const { getDefaultConfig } = require(${JSON.stringify(path.join(packageRoot, "metro-config.cjs"))})\n\nmodule.exports = getDefaultConfig(__dirname)\n`);
750
783
  writeFileSync(path.join(nativeRoot, "ios", ".xcode.env"), `export NODE_BINARY=$(command -v node)\nexport BLEAM_PROJECT_ROOT=${singleQuotedString(options.projectRoot)}\nexport BLEAM_DEV_PLATFORM=macos\n`);
784
+ prepareNativeIcon(nativeRoot, config.iconPath);
751
785
  patchNativeProject(nativeRoot, config);
752
786
  return nativeRoot;
753
787
  }
@@ -772,14 +806,13 @@ function runInheritedCommand(command, args, cwd) {
772
806
  }
773
807
  function installPods(nativeRoot) {
774
808
  const iosRoot = path.join(nativeRoot, "ios");
775
- const expectedStamp = podInstallInputStamp(iosRoot);
776
- if (hasCurrentPodInstall(iosRoot, expectedStamp)) {
809
+ if (hasCurrentPodInstall(iosRoot, podInstallInputStamp(iosRoot))) {
777
810
  console.log("Using cached native dependencies");
778
811
  return;
779
812
  }
780
813
  console.log("Installing native dependencies...");
781
814
  runInheritedCommand("pod", ["install"], iosRoot);
782
- writeFileSync(podInstallStampPath(iosRoot), `${expectedStamp}\n`);
815
+ writeFileSync(podInstallStampPath(iosRoot), `${podInstallInputStamp(iosRoot)}\n`);
783
816
  }
784
817
  function ensureNativeFrameworks(nativeRoot) {
785
818
  const frameworksRoot = path.join(nativeRoot, "ios", "Vendor", "MLXSwift", "0.31.6-macos");
@@ -812,7 +845,9 @@ function podInstallStampPath(iosRoot) {
812
845
  }
813
846
  function hasCurrentPodInstall(iosRoot, expectedStamp) {
814
847
  const stampPath = podInstallStampPath(iosRoot);
815
- return existsSync(path.join(iosRoot, "Bleam.xcworkspace")) && existsSync(path.join(iosRoot, "Pods", "Manifest.lock")) && existsSync(stampPath) && readFileSync(stampPath, "utf8").trim() === expectedStamp;
848
+ const lockPath = path.join(iosRoot, "Podfile.lock");
849
+ const manifestPath = path.join(iosRoot, "Pods", "Manifest.lock");
850
+ return existsSync(path.join(iosRoot, "Bleam.xcworkspace")) && existsSync(lockPath) && existsSync(manifestPath) && readFileSync(lockPath, "utf8") === readFileSync(manifestPath, "utf8") && existsSync(stampPath) && readFileSync(stampPath, "utf8").trim() === expectedStamp;
816
851
  }
817
852
  function nativeArchiveArgs(options) {
818
853
  return [
@@ -987,79 +1022,6 @@ async function publishOta(options) {
987
1022
  console.log(`Published OTA update ${releaseId}`);
988
1023
  console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/ota/${runtimeVersion}`);
989
1024
  }
990
- async function publishPlatform(options) {
991
- const config = readProjectConfig(options);
992
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
993
- if (!config.teamId) throw missingBuildFieldError("teamId");
994
- const archivePath = await buildNativeArchives({
995
- projectRoot: options.projectRoot,
996
- output: path.join(options.projectRoot, "dist"),
997
- configuration: "Release",
998
- clean: false
999
- });
1000
- const products = path.join(archivePath, "Products", "Applications");
1001
- const appName = readdirSync(products).find((name) => name.endsWith(".app"));
1002
- if (!appName) throw new Error(`Archive does not contain a macOS app: ${archivePath}`);
1003
- const outputRoot = path.join(options.projectRoot, ".bleam", "publish", "platform");
1004
- const stagingRoot = path.join(outputRoot, "app");
1005
- const artifactPath = path.join(outputRoot, "platform.zip");
1006
- rmSync(outputRoot, {
1007
- recursive: true,
1008
- force: true
1009
- });
1010
- mkdirSync(stagingRoot, { recursive: true });
1011
- execFileSync("ditto", [path.join(products, appName), path.join(stagingRoot, appName)]);
1012
- runInheritedCommand("zip", [
1013
- "-q",
1014
- "-r",
1015
- "-y",
1016
- artifactPath,
1017
- "app"
1018
- ], outputRoot);
1019
- const sizeBytes = readFileSync(artifactPath).byteLength;
1020
- const digest = sha256(artifactPath);
1021
- const releaseId = `platform_${Date.now().toString(36)}_${digest.slice(0, 12)}`;
1022
- const release = platformRelease(config, releaseId, sizeBytes, digest);
1023
- const response = await fetch(`${options.serviceUrl}/v1/local/releases/platform`, {
1024
- method: "POST",
1025
- headers: { "content-type": "application/json" },
1026
- body: JSON.stringify({
1027
- release,
1028
- artifactBase64: readFileSync(artifactPath).toString("base64")
1029
- })
1030
- });
1031
- if (!response.ok) throw new Error(`Local platform publication failed: ${response.status} ${await response.text()}`);
1032
- console.log(`Published platform update ${releaseId}`);
1033
- console.log(`${options.serviceUrl}/v1/apps/${encodeURIComponent(config.bundleIdentifier)}/platform/macos-arm64`);
1034
- }
1035
- function platformRelease(config, releaseId, sizeBytes, digest) {
1036
- if (!config.bundleIdentifier) throw missingBuildFieldError("bundleIdentifier");
1037
- if (!config.teamId) throw missingBuildFieldError("teamId");
1038
- return {
1039
- schemaVersion: 1,
1040
- kind: "platform",
1041
- bundleIdentifier: config.bundleIdentifier,
1042
- teamIdentifier: config.teamId,
1043
- channel: "stable",
1044
- releaseId,
1045
- appVersion: config.version ?? "1.0.0",
1046
- buildNumber: config.buildNumber,
1047
- bleamPlatformVersion: runtimeVersion,
1048
- target: {
1049
- os: "macos",
1050
- architecture: "arm64",
1051
- installLocation: "user-applications",
1052
- minimumMacOSVersion: "14.0"
1053
- },
1054
- artifact: {
1055
- format: "bleam-macos-app-zip-v1",
1056
- downloadId: releaseId,
1057
- sizeBytes,
1058
- sha256: digest
1059
- },
1060
- publishedAt: (/* @__PURE__ */ new Date()).toISOString()
1061
- };
1062
- }
1063
1025
  function runtimeCacheRoot() {
1064
1026
  return path.join(os.homedir(), "Library", "Caches", "bleam", "runtimes", runtimeVersion, artifactPlatform());
1065
1027
  }
@@ -1393,6 +1355,92 @@ async function launchRuntimeClient(appPath, projectConfigPath, manifest) {
1393
1355
  quitRuntimeClient();
1394
1356
  openRuntimeClient(appPath, projectConfigPath, manifest);
1395
1357
  }
1358
+ async function updateServiceHealthy(serviceUrl) {
1359
+ try {
1360
+ const response = await fetch(`${serviceUrl}/v1/health`, {
1361
+ cache: "no-store",
1362
+ signal: AbortSignal.timeout(1e3)
1363
+ });
1364
+ if (!response.ok) return false;
1365
+ return (await response.json()).healthy === true;
1366
+ } catch {
1367
+ return false;
1368
+ }
1369
+ }
1370
+ function updateServiceLogTail(logPath) {
1371
+ if (!existsSync(logPath)) return "";
1372
+ return readFileSync(logPath, "utf8").slice(-4e3).trim();
1373
+ }
1374
+ async function waitForUpdateService(child, serviceUrl, logPath, timeoutMs = 3e4) {
1375
+ const startedAt = Date.now();
1376
+ let startupError;
1377
+ child.once("error", (error) => {
1378
+ startupError = error;
1379
+ });
1380
+ while (Date.now() - startedAt < timeoutMs) {
1381
+ if (startupError || child.exitCode !== null) break;
1382
+ if (await updateServiceHealthy(serviceUrl)) return;
1383
+ await new Promise((resolve) => setTimeout(resolve, 250));
1384
+ }
1385
+ const log = updateServiceLogTail(logPath);
1386
+ const detail = log ? `\n\n${log}` : "";
1387
+ throw new Error(`Local update Worker failed to start.\nLog: ${logPath}${detail}`, startupError ? { cause: startupError } : void 0);
1388
+ }
1389
+ async function startLocalUpdateService() {
1390
+ const configuredUrl = process.env.BLEAM_UPDATE_SERVICE_URL ?? localUpdateServiceUrl;
1391
+ const serviceUrl = new URL(configuredUrl).origin;
1392
+ if (await updateServiceHealthy(serviceUrl)) {
1393
+ console.log(`Using local update Worker at ${serviceUrl}`);
1394
+ return {
1395
+ child: void 0,
1396
+ serviceUrl
1397
+ };
1398
+ }
1399
+ if (serviceUrl !== localUpdateServiceUrl) throw new Error(`BLEAM_UPDATE_SERVICE_URL is not healthy: ${serviceUrl}/v1/health`);
1400
+ const serviceRoot = localUpdateServiceRoot();
1401
+ const configPath = path.join(serviceRoot, "wrangler.jsonc");
1402
+ if (!existsSync(configPath)) throw new Error(`Missing local update Worker: ${serviceRoot}`);
1403
+ const wrangler = path.join(resolvedDependencyRoot(), ".bin", "wrangler");
1404
+ if (!existsSync(wrangler)) throw new Error("Missing Wrangler dependency for the local update Worker");
1405
+ const paths = localUpdateServicePaths();
1406
+ mkdirSync(paths.state, { recursive: true });
1407
+ const log = openSync(paths.log, "a");
1408
+ const child = spawn(wrangler, [
1409
+ "dev",
1410
+ "--config",
1411
+ configPath,
1412
+ "--local",
1413
+ "--persist-to",
1414
+ paths.state,
1415
+ "--ip",
1416
+ "127.0.0.1",
1417
+ "--port",
1418
+ "8787"
1419
+ ], {
1420
+ cwd: serviceRoot,
1421
+ stdio: [
1422
+ "ignore",
1423
+ log,
1424
+ log
1425
+ ],
1426
+ env: {
1427
+ ...process.env,
1428
+ NO_COLOR: "1"
1429
+ }
1430
+ });
1431
+ closeSync(log);
1432
+ try {
1433
+ await waitForUpdateService(child, serviceUrl, paths.log);
1434
+ } catch (error) {
1435
+ child.kill("SIGTERM");
1436
+ throw error;
1437
+ }
1438
+ console.log(`Local update Worker running at ${serviceUrl}`);
1439
+ return {
1440
+ child,
1441
+ serviceUrl
1442
+ };
1443
+ }
1396
1444
  function focusRuntimeClient() {
1397
1445
  return spawnSync("osascript", ["-e", "tell application id \"dev.bleam.app\" to activate"], { stdio: "ignore" }).status === 0;
1398
1446
  }
@@ -1727,6 +1775,7 @@ async function startDevServer(options) {
1727
1775
  const workspaceRoot = createDevWorkspace(options.projectRoot, config);
1728
1776
  const origin = `http://localhost:${options.port}`;
1729
1777
  const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin);
1778
+ const updateService = await startLocalUpdateService();
1730
1779
  const child = spawn(process.execPath, [
1731
1780
  fileURLToPath(import.meta.url),
1732
1781
  "internal:metro",
@@ -1747,6 +1796,7 @@ async function startDevServer(options) {
1747
1796
  BLEAM_DEV_PLATFORM: "macos",
1748
1797
  BLEAM_DEV_RUNTIME_VERSION: config.runtimeVersion,
1749
1798
  BLEAM_DEV_SDK_VERSION: config.sdkVersion,
1799
+ BLEAM_UPDATE_SERVICE_URL: updateService.serviceUrl,
1750
1800
  NODE_PATH: [
1751
1801
  path.join(options.projectRoot, "node_modules"),
1752
1802
  resolvedDependencyRoot(),
@@ -1766,6 +1816,7 @@ async function startDevServer(options) {
1766
1816
  didCleanupDevSession = true;
1767
1817
  cleanupInteractiveControls();
1768
1818
  if (didLaunchRuntimeClient) quitRuntimeClient();
1819
+ if (updateService.child?.exitCode === null) updateService.child.kill("SIGTERM");
1769
1820
  };
1770
1821
  const stop = (signal) => {
1771
1822
  if (stopping) return;
@@ -1847,11 +1898,7 @@ async function main(argv = process.argv.slice(2)) {
1847
1898
  await publishOta(parsePublishOtaOptions(publishArgs));
1848
1899
  return;
1849
1900
  }
1850
- if (kind === "platform") {
1851
- await publishPlatform(parsePublishOtaOptions(publishArgs));
1852
- return;
1853
- }
1854
- throw new Error("Usage: bleam publish <ota|platform> [dir] [--service-url <url>]");
1901
+ throw new Error("Usage: bleam publish ota [dir] [--service-url <url>]");
1855
1902
  }
1856
1903
  if (command === "doctor") {
1857
1904
  runDoctor(parseDoctorOptions(args));
@@ -1889,12 +1936,13 @@ const __test = {
1889
1936
  hasCurrentPodInstall,
1890
1937
  installedAppPath,
1891
1938
  installArchivedApp,
1939
+ localUpdateServicePaths,
1940
+ localUpdateServiceRoot,
1892
1941
  nativeRuntimeTemplateRoot,
1893
1942
  nativeArchiveArgs,
1894
1943
  parseBuildOptions,
1895
1944
  parseNewOptions,
1896
1945
  parsePublishOtaOptions,
1897
- platformRelease,
1898
1946
  podInstallInputStamp,
1899
1947
  replaceOrInsertPlistString
1900
1948
  };
package/dist/files.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-DwA7pzr3.cjs";
1
+ import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-Dt5mbzLq.cjs";
2
2
  export { CreateDirectoryOptions, DirectoryRef, DownloadOptions, DownloadProgress, DownloadTask, FilePaths, FileRef, FileStat, FileType, PickFileType, PickOptions, RemoveOptions, WriteOptions, files };
package/dist/files.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-VrkQlKIT.js";
1
+ import { a as DownloadTask, c as FileStat, d as PickOptions, f as RemoveOptions, i as DownloadProgress, l as FileType, m as files, n as DirectoryRef, o as FilePaths, p as WriteOptions, r as DownloadOptions, s as FileRef, t as CreateDirectoryOptions, u as PickFileType } from "./files-4ZEoAWiv.js";
2
2
  export { CreateDirectoryOptions, DirectoryRef, DownloadOptions, DownloadProgress, DownloadTask, FilePaths, FileRef, FileStat, FileType, PickFileType, PickOptions, RemoveOptions, WriteOptions, files };
package/dist/platform.cjs CHANGED
@@ -3,15 +3,6 @@ let expo = require("expo");
3
3
  expo = require_chunk.__toESM(expo);
4
4
 
5
5
  //#region src/platform.ts
6
- function getHelperStatus() {
7
- return (0, expo.requireNativeModule)("Platform").helperStatus();
8
- }
9
- function downloadPlatformUpdate() {
10
- return (0, expo.requireNativeModule)("Platform").downloadPlatformUpdate();
11
- }
12
- function updateAndRelaunch(releaseId) {
13
- return (0, expo.requireNativeModule)("Platform").updateAndRelaunch(releaseId);
14
- }
15
6
  function getPermissionState(capability) {
16
7
  return (0, expo.requireNativeModule)("Platform").permissionState(capability);
17
8
  }
@@ -20,8 +11,5 @@ function getPermissionStates() {
20
11
  }
21
12
 
22
13
  //#endregion
23
- exports.downloadPlatformUpdate = downloadPlatformUpdate;
24
- exports.getHelperStatus = getHelperStatus;
25
14
  exports.getPermissionState = getPermissionState;
26
- exports.getPermissionStates = getPermissionStates;
27
- exports.updateAndRelaunch = updateAndRelaunch;
15
+ exports.getPermissionStates = getPermissionStates;
@@ -1,5 +1,4 @@
1
1
  //#region src/platform.d.ts
2
- type HelperCapability = 'platform-updates';
3
2
  type PermissionCapability = 'camera' | 'microphone' | 'photos' | 'contacts' | 'calendars' | 'reminders' | 'location';
4
3
  type PermissionStatus = 'not-determined' | 'denied' | 'restricted' | 'limited' | 'granted' | 'unsupported';
5
4
  interface PermissionState {
@@ -9,31 +8,7 @@ interface PermissionState {
9
8
  canAskAgain: boolean;
10
9
  expires: 'never';
11
10
  }
12
- interface HelperStatus {
13
- healthy: boolean;
14
- protocolVersion: 1;
15
- helperVersion: string;
16
- platformVersion: string;
17
- capabilities: HelperCapability[];
18
- updatesSupported: boolean;
19
- installPath: string;
20
- reason?: 'reinstall_required';
21
- }
22
- interface PlatformDownload {
23
- releaseId: string;
24
- appVersion: string;
25
- buildNumber: string;
26
- platformVersion: string;
27
- artifactPath: string;
28
- appPath: string;
29
- sizeBytes: number;
30
- sha256: string;
31
- verified: true;
32
- }
33
- declare function getHelperStatus(): Promise<HelperStatus>;
34
- declare function downloadPlatformUpdate(): Promise<PlatformDownload>;
35
- declare function updateAndRelaunch(releaseId: string): Promise<void>;
36
11
  declare function getPermissionState(capability: PermissionCapability): Promise<PermissionState>;
37
12
  declare function getPermissionStates(): Promise<PermissionState[]>;
38
13
  //#endregion
39
- export { HelperCapability, HelperStatus, PermissionCapability, PermissionState, PermissionStatus, PlatformDownload, downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
14
+ export { PermissionCapability, PermissionState, PermissionStatus, getPermissionState, getPermissionStates };
@@ -1,5 +1,4 @@
1
1
  //#region src/platform.d.ts
2
- type HelperCapability = 'platform-updates';
3
2
  type PermissionCapability = 'camera' | 'microphone' | 'photos' | 'contacts' | 'calendars' | 'reminders' | 'location';
4
3
  type PermissionStatus = 'not-determined' | 'denied' | 'restricted' | 'limited' | 'granted' | 'unsupported';
5
4
  interface PermissionState {
@@ -9,31 +8,7 @@ interface PermissionState {
9
8
  canAskAgain: boolean;
10
9
  expires: 'never';
11
10
  }
12
- interface HelperStatus {
13
- healthy: boolean;
14
- protocolVersion: 1;
15
- helperVersion: string;
16
- platformVersion: string;
17
- capabilities: HelperCapability[];
18
- updatesSupported: boolean;
19
- installPath: string;
20
- reason?: 'reinstall_required';
21
- }
22
- interface PlatformDownload {
23
- releaseId: string;
24
- appVersion: string;
25
- buildNumber: string;
26
- platformVersion: string;
27
- artifactPath: string;
28
- appPath: string;
29
- sizeBytes: number;
30
- sha256: string;
31
- verified: true;
32
- }
33
- declare function getHelperStatus(): Promise<HelperStatus>;
34
- declare function downloadPlatformUpdate(): Promise<PlatformDownload>;
35
- declare function updateAndRelaunch(releaseId: string): Promise<void>;
36
11
  declare function getPermissionState(capability: PermissionCapability): Promise<PermissionState>;
37
12
  declare function getPermissionStates(): Promise<PermissionState[]>;
38
13
  //#endregion
39
- export { HelperCapability, HelperStatus, PermissionCapability, PermissionState, PermissionStatus, PlatformDownload, downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
14
+ export { PermissionCapability, PermissionState, PermissionStatus, getPermissionState, getPermissionStates };
package/dist/platform.js CHANGED
@@ -1,15 +1,6 @@
1
1
  import { requireNativeModule } from "expo";
2
2
 
3
3
  //#region src/platform.ts
4
- function getHelperStatus() {
5
- return requireNativeModule("Platform").helperStatus();
6
- }
7
- function downloadPlatformUpdate() {
8
- return requireNativeModule("Platform").downloadPlatformUpdate();
9
- }
10
- function updateAndRelaunch(releaseId) {
11
- return requireNativeModule("Platform").updateAndRelaunch(releaseId);
12
- }
13
4
  function getPermissionState(capability) {
14
5
  return requireNativeModule("Platform").permissionState(capability);
15
6
  }
@@ -18,4 +9,4 @@ function getPermissionStates() {
18
9
  }
19
10
 
20
11
  //#endregion
21
- export { downloadPlatformUpdate, getHelperStatus, getPermissionState, getPermissionStates, updateAndRelaunch };
12
+ export { getPermissionState, getPermissionStates };
package/dist/schema.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-ENSMX_1t.cjs";
1
+ import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-oeOrd3i1.cjs";
2
2
  export { BleamSchema, FieldDefault, FieldSchema, FieldToken, FieldValue, InferInput, InferOutput, SchemaError, SchemaInput, SchemaIssue, SchemaJSONSchema, SchemaOutput, SchemaResult, SchemaShape, StandardSchema, schema };
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-DOOjfXvs.js";
1
+ import { a as FieldValue, c as SchemaError, d as SchemaJSONSchema, f as SchemaOutput, g as schema, h as StandardSchema, i as FieldToken, l as SchemaInput, m as SchemaShape, n as FieldDefault, o as InferInput, p as SchemaResult, r as FieldSchema, s as InferOutput, t as BleamSchema, u as SchemaIssue } from "./schema-CYh6n8GS.js";
2
2
  export { BleamSchema, FieldDefault, FieldSchema, FieldToken, FieldValue, InferInput, InferOutput, SchemaError, SchemaInput, SchemaIssue, SchemaJSONSchema, SchemaOutput, SchemaResult, SchemaShape, StandardSchema, schema };
package/dist/state.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-ENSMX_1t.cjs";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-oeOrd3i1.cjs";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
package/dist/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-DOOjfXvs.js";
1
+ import { a as FieldValue, f as SchemaOutput, l as SchemaInput, m as SchemaShape, t as BleamSchema } from "./schema-CYh6n8GS.js";
2
2
 
3
3
  //#region src/state/atom.d.ts
4
4
  type Listener = () => void;
@@ -1,4 +1,4 @@
1
- import * as _nativescript_react_native27 from "@nativescript/react-native";
1
+ import * as _nativescript_react_native25 from "@nativescript/react-native";
2
2
  import { ReactNode } from "react";
3
3
  import { ColorValue, StyleProp, TextStyle, ViewStyle } from "react-native";
4
4
 
@@ -18,7 +18,7 @@ type ButtonProps = {
18
18
  onPress?: () => void;
19
19
  style?: StyleProp<NativeStyle>;
20
20
  };
21
- declare const Button: _nativescript_react_native27.UIKitViewComponent<ButtonProps, UIButton>;
21
+ declare const Button: _nativescript_react_native25.UIKitViewComponent<ButtonProps, UIButton>;
22
22
  //#endregion
23
23
  //#region src/ui/label.d.ts
24
24
  type LabelTone = 'primary' | 'secondary' | 'tertiary';
@@ -29,7 +29,7 @@ type LabelProps = {
29
29
  numberOfLines?: number;
30
30
  style?: StyleProp<NativeStyle>;
31
31
  };
32
- declare const Label: _nativescript_react_native27.UIKitViewComponent<LabelProps, UILabel>;
32
+ declare const Label: _nativescript_react_native25.UIKitViewComponent<LabelProps, UILabel>;
33
33
  //#endregion
34
34
  //#region src/ui/symbol.d.ts
35
35
  type SymbolName = string;
@@ -43,7 +43,7 @@ type SymbolProps = {
43
43
  color?: ColorValue;
44
44
  style?: StyleProp<NativeStyle>;
45
45
  };
46
- declare const Symbol: _nativescript_react_native27.UIKitViewComponent<SymbolProps, UIImageView>;
46
+ declare const Symbol: _nativescript_react_native25.UIKitViewComponent<SymbolProps, UIImageView>;
47
47
  //#endregion
48
48
  //#region src/ui/glass-shared.d.ts
49
49
  type GlassStyle = 'regular' | 'clear' | 'none';
@@ -73,10 +73,10 @@ type GlassContainerProps = {
73
73
  };
74
74
  //#endregion
75
75
  //#region src/ui/glass-view.d.ts
76
- declare const GlassView: _nativescript_react_native27.UIKitViewComponent<GlassViewProps, _nativescript_react_native27.UIKitContainerResult<UIVisualEffectView, UIView>>;
76
+ declare const GlassView: _nativescript_react_native25.UIKitViewComponent<GlassViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
77
77
  //#endregion
78
78
  //#region src/ui/glass-container.d.ts
79
- declare const GlassContainer: _nativescript_react_native27.UIKitViewComponent<GlassContainerProps, _nativescript_react_native27.UIKitContainerResult<UIVisualEffectView, UIView>>;
79
+ declare const GlassContainer: _nativescript_react_native25.UIKitViewComponent<GlassContainerProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
80
80
  //#endregion
81
81
  //#region src/ui/blur-view.d.ts
82
82
  type BlurIntensity = 'ultraThin' | 'thin' | 'regular' | 'thick' | 'chrome';
@@ -87,6 +87,6 @@ type BlurViewProps = {
87
87
  intensity?: BlurIntensity;
88
88
  colorScheme?: BlurColorScheme;
89
89
  };
90
- declare const BlurView: _nativescript_react_native27.UIKitViewComponent<BlurViewProps, _nativescript_react_native27.UIKitContainerResult<UIVisualEffectView, UIView>>;
90
+ declare const BlurView: _nativescript_react_native25.UIKitViewComponent<BlurViewProps, _nativescript_react_native25.UIKitContainerResult<UIVisualEffectView, UIView>>;
91
91
  //#endregion
92
92
  export { ButtonVariant as C, ButtonSize as S, Label as _, GlassContainer as a, Button as b, GlassEffectStyleConfig as c, GlassVisualStyle as d, Symbol as f, SymbolWeight as g, SymbolScale as h, BlurViewProps as i, GlassStyle as l, SymbolProps as m, BlurIntensity as n, GlassView as o, SymbolName as p, BlurView as r, GlassContainerProps as s, BlurColorScheme as t, GlassViewProps as u, LabelProps as v, ButtonProps as x, LabelTone as y };
package/dist/ui.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-Bg11tvlc.js";
1
+ import { C as ButtonVariant, S as ButtonSize, _ as Label, a as GlassContainer, b as Button, c as GlassEffectStyleConfig, d as GlassVisualStyle, f as Symbol, g as SymbolWeight, h as SymbolScale, i as BlurViewProps, l as GlassStyle, m as SymbolProps, n as BlurIntensity, o as GlassView, p as SymbolName, r as BlurView, s as GlassContainerProps, t as BlurColorScheme, u as GlassViewProps, v as LabelProps, x as ButtonProps, y as LabelTone } from "./ui-CHc4xEs_.js";
2
2
  export { BlurColorScheme, BlurIntensity, BlurView, BlurViewProps, Button, ButtonProps, ButtonSize, ButtonVariant, GlassContainer, GlassContainerProps, GlassEffectStyleConfig, GlassStyle, GlassView, GlassViewProps, GlassVisualStyle, Label, LabelProps, LabelTone, Symbol, SymbolName, SymbolProps, SymbolScale, SymbolWeight };
package/dist/window.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as SymbolName } from "./ui-Bg11tvlc.js";
1
+ import { p as SymbolName } from "./ui-CHc4xEs_.js";
2
2
  import * as react3 from "react";
3
3
  import { ComponentType } from "react";
4
4
  import { StyleProp, ViewStyle } from "react-native";