mirinjs 0.0.1-alpha.0 → 0.0.1-alpha.1

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": "mirinjs",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1-alpha.1",
4
4
  "description": "Build desktop apps with Bun, TypeScript, and Chromium (CEF). The Bun-native Electron alternative.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/app.ts CHANGED
@@ -235,9 +235,37 @@ function normalizeMaterial(
235
235
  return typeof material === "string" ? { type: material } : material;
236
236
  }
237
237
 
238
+ /** macOS Dock-icon controls (no-ops off macOS). */
239
+ export interface Dock {
240
+ /** Hide the Dock icon and menu-bar presence (agent/accessory app). */
241
+ hide(): void;
242
+ /** Restore the Dock icon and menu bar. */
243
+ show(): void;
244
+ }
245
+
238
246
  class MirinApp extends Emitter<AppEvents> {
239
247
  readonly windows = new Windows();
240
248
 
249
+ /** macOS Dock-icon controls. Hiding suits resident, hotkey-summoned apps. */
250
+ readonly dock: Dock = {
251
+ hide: () => this.#setDock(false),
252
+ show: () => this.#setDock(true),
253
+ };
254
+
255
+ /** Apply the Dock policy now if the core is up, else once it's ready. The
256
+ * native command needs the CEF UI thread, which only runs after `ready`. */
257
+ #setDock(visible: boolean): void {
258
+ const apply = () => runtime().core.appSetDockVisible(visible);
259
+ if (runtime().core.isReady()) {
260
+ apply();
261
+ } else {
262
+ const off = this.on("ready", () => {
263
+ off();
264
+ apply();
265
+ });
266
+ }
267
+ }
268
+
241
269
  serve<R extends Router<any>>(router: R): ServeHandle<R> {
242
270
  runtime().rpc.setRouter(router);
243
271
  return { rpc: this.rpc as BroadcastEmitters<R> };
package/src/host.ts CHANGED
@@ -39,13 +39,18 @@ const coreConfig = JSON.parse(
39
39
  JSON.stringify(process.env.MIRIN_DEV_URL ? {} : { resources_path: resourcesDir }),
40
40
  );
41
41
 
42
+ // Load the native core on the main thread FIRST. The Worker also dlopens the
43
+ // same dylib in its boot; doing the main-thread dlopen before spawning the
44
+ // Worker serializes the first-time load instead of racing two concurrent
45
+ // dlopens across threads.
46
+ const core = new Core(corePath);
47
+
42
48
  const worker = new Worker(workerPath, {
43
49
  workerData: { corePath, manifest, devUrl: process.env.MIRIN_DEV_URL },
44
50
  });
45
51
  worker.on("error", (err) => console.error("[mirin worker]", err));
46
52
 
47
53
  // Hand the main thread to CEF. Blocks in the message loop until the app quits.
48
- const core = new Core(corePath);
49
54
  const exitCode = core.run(JSON.stringify(coreConfig));
50
55
 
51
56
  void worker.terminate();
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ export type {
32
32
  WindowOpenOptions,
33
33
  ServeHandle,
34
34
  BroadcastEmitters,
35
+ Dock,
35
36
  } from "./app.ts";
36
37
  export type { MenuItemTemplate, MenuRole } from "./menu.ts";
37
38
  export type { TrayOptions } from "./tray.ts";
package/src/native.ts CHANGED
@@ -24,6 +24,7 @@ const symbols = {
24
24
  mirin_window_control: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.void },
25
25
  mirin_window_set_material: { args: [FFIType.u32, FFIType.ptr], returns: FFIType.void },
26
26
  mirin_app_quit: { args: [], returns: FFIType.void },
27
+ mirin_app_set_dock_visible: { args: [FFIType.i32], returns: FFIType.void },
27
28
  mirin_set_app_menu: { args: [FFIType.ptr], returns: FFIType.void },
28
29
  mirin_popup_menu: { args: [FFIType.ptr], returns: FFIType.void },
29
30
  mirin_tray_create: { args: [FFIType.ptr], returns: FFIType.void },
@@ -111,6 +112,10 @@ export class Core {
111
112
  this.#lib.symbols.mirin_app_quit();
112
113
  }
113
114
 
115
+ appSetDockVisible(visible: boolean): void {
116
+ this.#lib.symbols.mirin_app_set_dock_visible(visible ? 1 : 0);
117
+ }
118
+
114
119
  setAppMenu(templateJson: string): void {
115
120
  const buf = nullTerminated(templateJson);
116
121
  this.#lib.symbols.mirin_set_app_menu(ptr(buf));