electrobun 1.17.3-beta.0 → 1.17.3-beta.10
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/dist/api/browser/index.ts +5 -0
- package/package.json +1 -1
- package/src/cli/index.ts +66 -21
|
@@ -42,6 +42,11 @@ class Electroview<T extends RPCWithTransport> {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
initSocketToBun() {
|
|
45
|
+
// Skip native socket when running in a remote browser (no port/webview ID)
|
|
46
|
+
if (!RPC_SOCKET_PORT || !WEBVIEW_ID) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
// Note: Using ws:// for localhost is intentional - all RPC messages are
|
|
46
51
|
// encrypted with per-webview AES-GCM keys, making TLS redundant
|
|
47
52
|
const socket = new WebSocket(
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -1529,7 +1529,17 @@ const defaultConfig = {
|
|
|
1529
1529
|
mode?: "window" | "background";
|
|
1530
1530
|
permissions?: Record<string, unknown>;
|
|
1531
1531
|
dependencies?: Record<string, string>;
|
|
1532
|
-
|
|
1532
|
+
// Map of remote UI ID → config. Two flavors:
|
|
1533
|
+
// 1. { name, entrypoint, ...bunBuildOpts } — electrobun builds it via Bun.build
|
|
1534
|
+
// 2. { name, path } — point at an already-built HTML file (e.g. produced by postBuild)
|
|
1535
|
+
// In both cases, the manifest gets a remoteUIs block that ears reads to expose
|
|
1536
|
+
// the UIs for remote loading via Hop. `name` is the human-readable label shown in Farm.
|
|
1537
|
+
remoteUIs?: Record<string, {
|
|
1538
|
+
name?: string;
|
|
1539
|
+
entrypoint?: string;
|
|
1540
|
+
path?: string;
|
|
1541
|
+
[key: string]: unknown;
|
|
1542
|
+
}>;
|
|
1533
1543
|
carrotOnly?: boolean;
|
|
1534
1544
|
} | undefined,
|
|
1535
1545
|
},
|
|
@@ -3073,29 +3083,55 @@ Categories=Utility;Application;
|
|
|
3073
3083
|
}
|
|
3074
3084
|
}
|
|
3075
3085
|
|
|
3076
|
-
// Build remote UIs if configured
|
|
3086
|
+
// Build remote UIs if configured.
|
|
3087
|
+
// remoteUIs has two flavors:
|
|
3088
|
+
// 1. entrypoint set → CLI runs Bun.build, output to remote-ui/{name}/
|
|
3089
|
+
// 2. path set → already built (e.g. by postBuild), just record in manifest
|
|
3090
|
+
// The resolved manifest entries are collected here and written below.
|
|
3091
|
+
const resolvedRemoteUIs: Record<string, { name: string; path: string }> = {};
|
|
3077
3092
|
if (carrotConfig.remoteUIs) {
|
|
3078
3093
|
for (const remoteUIName in carrotConfig.remoteUIs) {
|
|
3079
3094
|
const remoteUIConfig = carrotConfig.remoteUIs[remoteUIName]!;
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
+
const label = remoteUIConfig.name || remoteUIName;
|
|
3096
|
+
|
|
3097
|
+
if (remoteUIConfig.entrypoint) {
|
|
3098
|
+
const remoteUISource = join(projectRoot, remoteUIConfig.entrypoint);
|
|
3099
|
+
if (!existsSync(remoteUISource)) {
|
|
3100
|
+
console.error(`Remote UI entrypoint not found: ${remoteUISource}`);
|
|
3101
|
+
continue;
|
|
3102
|
+
}
|
|
3103
|
+
const remoteUIDestFolder = join(carrotBuildDir, "remote-ui", remoteUIName);
|
|
3104
|
+
mkdirSync(remoteUIDestFolder, { recursive: true });
|
|
3105
|
+
|
|
3106
|
+
const { entrypoint: _entrypoint, name: _name, path: _path, ...remoteUIBuildOptions } = remoteUIConfig;
|
|
3107
|
+
const remoteUIBuildResult = await Bun.build({
|
|
3108
|
+
...remoteUIBuildOptions,
|
|
3109
|
+
entrypoints: [remoteUISource],
|
|
3110
|
+
outdir: remoteUIDestFolder,
|
|
3111
|
+
target: "browser",
|
|
3112
|
+
});
|
|
3095
3113
|
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3114
|
+
if (!remoteUIBuildResult.success) {
|
|
3115
|
+
console.error(`Failed to build remote UI: ${remoteUIName}`);
|
|
3116
|
+
printBuildLogs(remoteUIBuildResult.logs);
|
|
3117
|
+
continue;
|
|
3118
|
+
}
|
|
3119
|
+
// Bun.build produces a JS bundle; the entry HTML (if any) is up to the
|
|
3120
|
+
// builder. We record the directory entry as index.html by convention.
|
|
3121
|
+
resolvedRemoteUIs[remoteUIName] = {
|
|
3122
|
+
name: label,
|
|
3123
|
+
path: `remote-ui/${remoteUIName}/index.html`,
|
|
3124
|
+
};
|
|
3125
|
+
} else if (remoteUIConfig.path) {
|
|
3126
|
+
// Pre-built path (e.g. produced by a postBuild script). Just record it.
|
|
3127
|
+
resolvedRemoteUIs[remoteUIName] = {
|
|
3128
|
+
name: label,
|
|
3129
|
+
path: remoteUIConfig.path,
|
|
3130
|
+
};
|
|
3131
|
+
} else {
|
|
3132
|
+
console.warn(
|
|
3133
|
+
`Remote UI "${remoteUIName}" has neither entrypoint nor path; skipping.`,
|
|
3134
|
+
);
|
|
3099
3135
|
}
|
|
3100
3136
|
}
|
|
3101
3137
|
}
|
|
@@ -3108,9 +3144,18 @@ Categories=Utility;Application;
|
|
|
3108
3144
|
description: carrotConfig.description || config.app.description || "",
|
|
3109
3145
|
mode: carrotConfig.mode || "window",
|
|
3110
3146
|
permissions: carrotConfig.permissions || {},
|
|
3111
|
-
dependencies:
|
|
3147
|
+
dependencies: Object.fromEntries(
|
|
3148
|
+
Object.entries(carrotConfig.dependencies || {}).map(([id, spec]) => [
|
|
3149
|
+
id,
|
|
3150
|
+
// Strip file:/workspace: specifiers for artifact manifests — just keep the carrot ID
|
|
3151
|
+
typeof spec === "string" && (spec.startsWith("file:") || spec.startsWith("workspace:"))
|
|
3152
|
+
? "*"
|
|
3153
|
+
: spec,
|
|
3154
|
+
]),
|
|
3155
|
+
),
|
|
3112
3156
|
worker: { relativePath: "worker.js" },
|
|
3113
3157
|
view: existsSync(viewsSrc) ? { relativePath: "views/index.html" } : undefined,
|
|
3158
|
+
remoteUIs: Object.keys(resolvedRemoteUIs).length > 0 ? resolvedRemoteUIs : undefined,
|
|
3114
3159
|
};
|
|
3115
3160
|
writeFileSync(
|
|
3116
3161
|
join(carrotBuildDir, "carrot.json"),
|