@orbit-work/oem-dev-host 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-work/oem-dev-host",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Live OEM bridge for full Desktop, isolated-profile sandbox, and Slot workbench modes.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -19,7 +19,7 @@
19
19
  "src/server.mjs"
20
20
  ],
21
21
  "dependencies": {
22
- "@orbit-work/oem-sdk": "0.1.1",
22
+ "@orbit-work/oem-sdk": "0.1.2",
23
23
  "@orbit-work/ui": "0.1.2",
24
24
  "@vitejs/plugin-react": "^4.3.4",
25
25
  "react": "^19.0.0",
package/src/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { realpathSync } from "node:fs"
4
- import { access } from "node:fs/promises"
3
+ import { realpathSync, statSync } from "node:fs"
4
+ import { access, readFile } from "node:fs/promises"
5
5
  import path from "node:path"
6
6
  import { fileURLToPath } from "node:url"
7
7
  import { startDevelopmentServer } from "./server.mjs"
@@ -27,6 +27,21 @@ export function parseArgs(argv, env = process.env) {
27
27
  return result
28
28
  }
29
29
 
30
+ /**
31
+ * Accept a bare macOS .app bundle: spawn needs the executable inside it, so
32
+ * resolve Contents/MacOS/<CFBundleExecutable> from the bundle's Info.plist.
33
+ */
34
+ async function resolveHostExecutable(hostPath) {
35
+ const resolved = path.resolve(hostPath)
36
+ if (!resolved.endsWith(".app") || !statSync(resolved, { throwIfNoEntry: false })?.isDirectory()) {
37
+ return resolved
38
+ }
39
+ const plist = await readFile(path.join(resolved, "Contents", "Info.plist"), "utf8").catch(() => "")
40
+ const executable = /<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/.exec(plist)?.[1]
41
+ if (!executable) throw new Error(`could not read CFBundleExecutable from ${resolved}/Contents/Info.plist`)
42
+ return path.join(resolved, "Contents", "MacOS", executable)
43
+ }
44
+
30
45
  export async function main(argv = process.argv.slice(2)) {
31
46
  const args = parseArgs(argv)
32
47
  if (args.help) {
@@ -41,7 +56,7 @@ export async function main(argv = process.argv.slice(2)) {
41
56
  if (!args.host) {
42
57
  throw new Error("Install the compiled Orbitwork OEM Dev Host, then set ORBIT_OEM_DEV_HOST_EXECUTABLE or pass --host")
43
58
  }
44
- const executable = path.resolve(args.host)
59
+ const executable = await resolveHostExecutable(args.host)
45
60
  await access(executable)
46
61
  const server = await startDevelopmentServer(path.resolve(args.project), { launch: executable, mode: args.mode })
47
62
  console.log(
package/src/compiler.mjs CHANGED
@@ -87,7 +87,14 @@ async function externalPlugin() {
87
87
 
88
88
  function dataUrl(file, bytes) {
89
89
  const extension = path.extname(file).toLowerCase()
90
- const mime = extension === ".svg" ? "image/svg+xml" : extension === ".webp" ? "image/webp" : "image/png"
90
+ const mime =
91
+ extension === ".svg"
92
+ ? "image/svg+xml"
93
+ : extension === ".webp"
94
+ ? "image/webp"
95
+ : extension === ".jpg" || extension === ".jpeg"
96
+ ? "image/jpeg"
97
+ : "image/png"
91
98
  return `data:${mime};base64,${bytes.toString("base64")}`
92
99
  }
93
100
 
@@ -142,6 +149,13 @@ export async function compileOemDevelopmentProject(projectRoot, { expectedIdenti
142
149
  const trayFile = path.resolve(root, audit.manifest.assets.tray)
143
150
  tray = dataUrl(trayFile, await readFile(trayFile))
144
151
  }
152
+ // The login KV is mutable design data (not immutable identity), so it is
153
+ // refreshed with every reload like the logo rather than pinned at build time.
154
+ let loginBackground = null
155
+ if (audit.manifest.assets.loginBackground) {
156
+ const loginBackgroundFile = path.resolve(root, audit.manifest.assets.loginBackground)
157
+ loginBackground = dataUrl(loginBackgroundFile, await readFile(loginBackgroundFile))
158
+ }
145
159
  let javascript = ""
146
160
  let css = ""
147
161
  if (audit.manifest.entry) {
@@ -174,7 +188,7 @@ export async function compileOemDevelopmentProject(projectRoot, { expectedIdenti
174
188
  }
175
189
  return {
176
190
  identity,
177
- snapshot: { manifest: audit.manifest, locales, logo, appIcon, tray, development },
191
+ snapshot: { manifest: audit.manifest, locales, logo, appIcon, tray, loginBackground, development },
178
192
  javascript,
179
193
  css,
180
194
  }
package/src/server.mjs CHANGED
@@ -158,6 +158,10 @@ export async function startDevelopmentServer(
158
158
  }),
159
159
  })
160
160
  : null
161
+ child?.once("error", (error) => {
162
+ console.error(`[oem-dev-host] failed to launch ${launch}: ${error.message}`)
163
+ void close().finally(() => process.exit(1))
164
+ })
161
165
  const close = async () => {
162
166
  clearTimeout(timer)
163
167
  watcher.close()