mirinjs 0.1.0-alpha.6 → 0.1.0-alpha.7
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 +1 -1
- package/src/app.ts +19 -0
- package/src/host.ts +3 -0
- package/src/runtime.ts +7 -0
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -289,6 +289,25 @@ class MirinApp extends Emitter<AppEvents> {
|
|
|
289
289
|
/** Auto-updater (macOS). Inert unless the app was built with `release` set. */
|
|
290
290
|
readonly updater: Updater = updater;
|
|
291
291
|
|
|
292
|
+
/** This app's bundle id (mirin.config `id`). `undefined` when run detached. */
|
|
293
|
+
get id(): string | undefined {
|
|
294
|
+
try {
|
|
295
|
+
return runtime().id;
|
|
296
|
+
} catch {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** True under `mirin dev`; false in a packaged build (and when detached). Use it
|
|
302
|
+
* to keep dev and installed data (caches, databases) separate. */
|
|
303
|
+
get isDev(): boolean {
|
|
304
|
+
try {
|
|
305
|
+
return runtime().isDev;
|
|
306
|
+
} catch {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
292
311
|
/** macOS Dock-icon controls. Hiding suits resident, hotkey-summoned apps. */
|
|
293
312
|
readonly dock: Dock = {
|
|
294
313
|
hide: () => this.#setDock(false),
|
package/src/host.ts
CHANGED
|
@@ -52,6 +52,8 @@ const coreConfig = JSON.parse(
|
|
|
52
52
|
);
|
|
53
53
|
// Opt out of single-instance (the core default) when the app allows multiple.
|
|
54
54
|
if (manifest.singleInstance === false) coreConfig.single_instance = false;
|
|
55
|
+
// The app's bundle id keys the per-app CEF cache dir (Windows has no OS bundle id).
|
|
56
|
+
if (typeof manifest.id === "string") coreConfig.identifier = manifest.id;
|
|
55
57
|
|
|
56
58
|
// Load the native core on the main thread FIRST. The Worker also dlopens the
|
|
57
59
|
// same dylib in its boot; doing the main-thread dlopen before spawning the
|
|
@@ -63,6 +65,7 @@ const worker = new Worker(workerPath, {
|
|
|
63
65
|
workerData: {
|
|
64
66
|
corePath,
|
|
65
67
|
manifest,
|
|
68
|
+
id: typeof manifest.id === "string" ? manifest.id : undefined,
|
|
66
69
|
devUrl: process.env.MIRIN_DEV_URL,
|
|
67
70
|
resourcesDir,
|
|
68
71
|
sidecarDir,
|
package/src/runtime.ts
CHANGED
|
@@ -18,6 +18,10 @@ export interface Runtime {
|
|
|
18
18
|
core: Core;
|
|
19
19
|
rpc: RpcServer;
|
|
20
20
|
manifestWindows: ManifestWindowConfig[];
|
|
21
|
+
/** App bundle id (mirin.config `id`); undefined when detached. */
|
|
22
|
+
id?: string;
|
|
23
|
+
/** True under `mirin dev`; false in a packaged build. */
|
|
24
|
+
isDev: boolean;
|
|
21
25
|
devUrl?: string;
|
|
22
26
|
/** Contents/Resources of the running .app (for the updater). Absent in dev. */
|
|
23
27
|
resourcesDir?: string;
|
|
@@ -87,6 +91,7 @@ export function boot(): void {
|
|
|
87
91
|
const data = (workerData ?? {}) as {
|
|
88
92
|
corePath?: string;
|
|
89
93
|
manifest?: { windows?: Record<string, WindowConfig> };
|
|
94
|
+
id?: string;
|
|
90
95
|
devUrl?: string;
|
|
91
96
|
resourcesDir?: string;
|
|
92
97
|
sidecarDir?: string;
|
|
@@ -126,6 +131,8 @@ export function boot(): void {
|
|
|
126
131
|
core,
|
|
127
132
|
rpc,
|
|
128
133
|
manifestWindows,
|
|
134
|
+
id: data.id,
|
|
135
|
+
isDev: !!data.devUrl,
|
|
129
136
|
devUrl: data.devUrl,
|
|
130
137
|
resourcesDir: data.resourcesDir,
|
|
131
138
|
corePath,
|