@moonbase.sh/electron 0.0.0-stage → 0.1.0

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/index.cjs ADDED
@@ -0,0 +1,577 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ MoonbaseElectron: () => MoonbaseElectron,
34
+ createMoonbase: () => createMoonbase
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_node_buffer = require("buffer");
38
+ var import_node_fs = __toESM(require("fs"), 1);
39
+ var import_promises = __toESM(require("fs/promises"), 1);
40
+ var import_node_path = __toESM(require("path"), 1);
41
+ var import_node_process = __toESM(require("process"), 1);
42
+ var import_licensing = require("@moonbase.sh/licensing");
43
+ var import_electron = require("electron");
44
+
45
+ // package.json
46
+ var version = "0.1.0";
47
+
48
+ // src/download.ts
49
+ function downloadState(phase, rest = {}) {
50
+ return { phase, progress: null, path: null, error: null, releaseAccess: null, upgradeUrl: null, ...rest };
51
+ }
52
+ function fileSafe(name) {
53
+ const cleaned = name.replace(/[\u0000-\u001F\u007F\\/:*?"<>|]/g, "-").trim().replace(/^\.+|\.+$/g, "");
54
+ return cleaned || "license";
55
+ }
56
+
57
+ // src/index.ts
58
+ var WIDTH = 660;
59
+ var MOONBASE_SITE = "https://moonbase.sh";
60
+ var READ_ONLY = /* @__PURE__ */ new Set(["state", "device", "checkUpdate", "present"]);
61
+ function errorOutcome(err) {
62
+ if (err instanceof import_licensing.ActivationError)
63
+ return { ok: false, error: { kind: err.kind, message: err.message } };
64
+ const kind = err?.type;
65
+ return { ok: false, error: { kind: typeof kind === "string" ? kind : "internal", message: err instanceof Error ? err.message : String(err) } };
66
+ }
67
+ function uiFolder() {
68
+ return __dirname;
69
+ }
70
+ function platformOs() {
71
+ switch (import_node_process.default.platform) {
72
+ case "darwin":
73
+ return "macos";
74
+ case "win32":
75
+ return "windows";
76
+ default:
77
+ return import_node_process.default.platform;
78
+ }
79
+ }
80
+ var MoonbaseElectron = class extends import_licensing.ActivationController {
81
+ constructor(options) {
82
+ const ui = options.ui === false ? null : options.ui ?? {};
83
+ const productName = ui?.productName ?? import_electron.app.getName();
84
+ super({
85
+ ...options,
86
+ appVersion: options.appVersion ?? import_electron.app.getVersion(),
87
+ licenseFile: options.licenseFile ?? import_node_path.default.join(import_electron.app.getPath("userData"), "license.mb"),
88
+ openUrl: options.openUrl ?? ((url) => import_electron.shell.openExternal(url)),
89
+ // Ahead of the SDK's own token, so Moonbase knows the product uses this module.
90
+ clientInfo: [options.clientInfo, `@moonbase.sh/electron/${version}`].filter(Boolean).join(" "),
91
+ productName,
92
+ accountName: ui?.manufacturerName
93
+ });
94
+ this.subscribers = /* @__PURE__ */ new Set();
95
+ this.folder = uiFolder();
96
+ this.window = null;
97
+ this.overlay = null;
98
+ this.pendingScreen = null;
99
+ this.lastLicensed = null;
100
+ this.download = downloadState("idle");
101
+ this.downloaded = null;
102
+ this.running = false;
103
+ this.onSubscribe = (event) => {
104
+ const contents = event.sender;
105
+ if (this.accessOf(contents) === "none" || this.subscribers.has(contents))
106
+ return;
107
+ this.subscribers.add(contents);
108
+ contents.once("destroyed", () => this.subscribers.delete(contents));
109
+ };
110
+ this.onWindowFocus = () => this.onFocusChanged(true);
111
+ this.onWindowBlur = () => this.onFocusChanged(false);
112
+ this.ui = ui;
113
+ this.rendererAccess = options.rendererAccess;
114
+ this.endpoint = options.endpoint;
115
+ this.subscribe((state) => this.afterStateChange(state));
116
+ }
117
+ /**
118
+ * Validate the stored license, start watching it, and answer the app's
119
+ * renderers. Call once, before or after the app is ready.
120
+ */
121
+ start() {
122
+ if (this.running)
123
+ return;
124
+ this.running = true;
125
+ import_electron.ipcMain.handle("moonbase:invoke", (event, command, args) => this.handleRenderer(event, command, args ?? {}));
126
+ import_electron.ipcMain.handle("moonbase:ui", (event, command, args) => this.handleUi(event, command, args ?? {}));
127
+ import_electron.ipcMain.on("moonbase:subscribe", this.onSubscribe);
128
+ import_electron.app.on("browser-window-focus", this.onWindowFocus);
129
+ import_electron.app.on("browser-window-blur", this.onWindowBlur);
130
+ super.start();
131
+ }
132
+ /** Stop watching, close the UI and stop answering renderers. */
133
+ dispose() {
134
+ if (this.running) {
135
+ import_electron.ipcMain.removeHandler("moonbase:invoke");
136
+ import_electron.ipcMain.removeHandler("moonbase:ui");
137
+ import_electron.ipcMain.off("moonbase:subscribe", this.onSubscribe);
138
+ import_electron.app.off("browser-window-focus", this.onWindowFocus);
139
+ import_electron.app.off("browser-window-blur", this.onWindowBlur);
140
+ this.running = false;
141
+ }
142
+ this.closeUi();
143
+ super.dispose();
144
+ }
145
+ isOwnUi(contents) {
146
+ return !!this.window && !this.window.isDestroyed() && this.window.webContents === contents || !!this.overlay && this.overlay.view.webContents === contents;
147
+ }
148
+ accessOf(contents) {
149
+ const access = this.rendererAccess ?? "full";
150
+ return typeof access === "function" ? access(contents) : access;
151
+ }
152
+ // -- Renderers ----------------------------------------------------------------
153
+ async handleRenderer(event, command, args) {
154
+ const access = this.isOwnUi(event.sender) ? "full" : this.accessOf(event.sender);
155
+ if (access === "none" || access === "read-only" && !READ_ONLY.has(command))
156
+ return { ok: false, error: { kind: "forbidden", message: `This window may not call ${command}` } };
157
+ try {
158
+ return { ok: true, value: await this.run(command, args) };
159
+ } catch (err) {
160
+ return errorOutcome(err);
161
+ }
162
+ }
163
+ async run(command, args) {
164
+ const id = String(args.id ?? "");
165
+ switch (command) {
166
+ case "state":
167
+ return this.state();
168
+ case "activate":
169
+ return await this.activate();
170
+ case "cancelActivation":
171
+ return this.cancelActivation();
172
+ case "refresh":
173
+ return await this.refresh({ force: args.force !== false });
174
+ case "deactivate":
175
+ return await this.deactivate();
176
+ case "forget":
177
+ return await this.forget();
178
+ case "deviceToken":
179
+ return await this.deviceToken();
180
+ case "activateOffline":
181
+ return await this.activateOffline(String(args.licenseFile ?? ""));
182
+ case "dismissError":
183
+ return this.dismissError();
184
+ case "device":
185
+ return await this.device();
186
+ case "checkUpdate":
187
+ return await this.checkUpdate();
188
+ case "updateDownloadUrl":
189
+ return await this.updateDownloadUrl();
190
+ case "present":
191
+ return await this.present(args.screen ?? void 0);
192
+ case "closeUi":
193
+ return this.closeUi();
194
+ case "upgradeLicense":
195
+ return await this.upgradeLicense();
196
+ case "loadAddOns":
197
+ return await this.loadAddOns();
198
+ case "refreshAddOns":
199
+ return await this.refreshAddOns();
200
+ case "activateSubProduct":
201
+ return await this.activateSubProduct(id);
202
+ case "requestSubProductTrial":
203
+ return await this.requestSubProductTrial(id);
204
+ case "buySubProduct":
205
+ return await this.buySubProduct(id);
206
+ default:
207
+ throw new import_licensing.ActivationError("internal", `Unknown command ${command}`);
208
+ }
209
+ }
210
+ /** The built-in UI's own commands, which only its window or overlay may call. */
211
+ async handleUi(event, command, args) {
212
+ if (!this.isOwnUi(event.sender))
213
+ return { ok: false, error: { kind: "forbidden", message: "Only the activation UI may call this" } };
214
+ try {
215
+ return { ok: true, value: await this.runUi(event.sender, command, args) };
216
+ } catch (err) {
217
+ return errorOutcome(err);
218
+ }
219
+ }
220
+ async runUi(sender, command, args) {
221
+ switch (command) {
222
+ case "ui_config":
223
+ return this.pageConfig();
224
+ case "ui_ready":
225
+ return this.uiReady(Number(args.height) || 0);
226
+ case "ui_resize":
227
+ return this.uiResize(Number(args.height) || 0);
228
+ case "close_ui":
229
+ return this.closeUi();
230
+ case "open_link":
231
+ return await this.openLink(String(args.url ?? ""));
232
+ case "copy_text":
233
+ return import_electron.clipboard.writeText(String(args.text ?? ""));
234
+ case "save_machine_file":
235
+ return await this.saveMachineFile(import_electron.BrowserWindow.fromWebContents(sender) ?? this.overlay?.target ?? null);
236
+ case "download_update":
237
+ return await this.downloadUpdate();
238
+ case "reveal_update":
239
+ return this.revealUpdate();
240
+ case "skip_update":
241
+ return await this.skipUpdate(String(args.version ?? ""));
242
+ case "cancel_activation":
243
+ return this.cancelActivation();
244
+ case "activate_offline":
245
+ return await this.activateOffline(String(args.licenseFile ?? ""));
246
+ case "upgrade_license":
247
+ return await this.upgradeLicense();
248
+ case "check_update":
249
+ return await this.checkUpdate();
250
+ case "load_add_ons":
251
+ return await this.loadAddOns();
252
+ case "refresh_add_ons":
253
+ return await this.refreshAddOns();
254
+ case "activate_sub_product":
255
+ return await this.activateSubProduct(String(args.id ?? ""));
256
+ case "request_sub_product_trial":
257
+ return await this.requestSubProductTrial(String(args.id ?? ""));
258
+ case "buy_sub_product":
259
+ return await this.buySubProduct(String(args.id ?? ""));
260
+ default:
261
+ return await this.run(command, args);
262
+ }
263
+ }
264
+ // -- The built-in UI ------------------------------------------------------------
265
+ pageConfig() {
266
+ const ui = this.ui ?? {};
267
+ const productName = ui.productName ?? import_electron.app.getName();
268
+ let logo = null;
269
+ if (ui.logoPng) {
270
+ const png = typeof ui.logoPng === "string" ? import_node_fs.default.readFileSync(ui.logoPng) : ui.logoPng;
271
+ logo = `data:image/png;base64,${import_node_buffer.Buffer.from(png).toString("base64")}`;
272
+ }
273
+ let activationHost = this.endpoint;
274
+ try {
275
+ activationHost = new URL(this.endpoint).host;
276
+ } catch {
277
+ }
278
+ return {
279
+ productName,
280
+ manufacturerName: ui.manufacturerName ?? null,
281
+ accent: ui.accent ?? "#186cdc",
282
+ logo,
283
+ logoSvg: ui.logoSvg ?? null,
284
+ trialFeatures: ui.trialFeatures ?? [],
285
+ trialLengthDays: Math.max(1, ui.trialLengthDays ?? 14),
286
+ showBadge: ui.showMoonbaseBadge ?? true,
287
+ strings: ui.strings ?? {},
288
+ showAddOns: ui.showAddOns ?? false,
289
+ reduceMotion: ui.reduceMotion ?? false,
290
+ activationHost,
291
+ requestFileName: `${fileSafe(productName)}.dt`,
292
+ os: platformOs(),
293
+ windowTitle: ui.windowTitle ?? productName
294
+ };
295
+ }
296
+ /** The app's window the overlay locks, and the activation window's parent. */
297
+ targetWindow() {
298
+ const chosen = typeof this.ui?.window === "function" ? this.ui.window() : this.ui?.window;
299
+ if (chosen && !chosen.isDestroyed())
300
+ return chosen;
301
+ return import_electron.BrowserWindow.getAllWindows().filter((candidate) => !candidate.isDestroyed() && candidate !== this.window).sort((a, b) => a.id - b.id)[0] ?? null;
302
+ }
303
+ /** Hand the UI something new, wherever it is showing. */
304
+ push(name, payload) {
305
+ const contents = this.overlay?.view.webContents ?? (this.window && !this.window.isDestroyed() ? this.window.webContents : null);
306
+ if (contents && !contents.isDestroyed())
307
+ contents.send("moonbase:push", name, payload);
308
+ }
309
+ afterStateChange(state) {
310
+ for (const contents of [...this.subscribers]) {
311
+ if (contents.isDestroyed() || this.accessOf(contents) === "none")
312
+ this.subscribers.delete(contents);
313
+ else
314
+ contents.send("moonbase:state-changed", state);
315
+ }
316
+ if (!this.ui)
317
+ return;
318
+ this.push("update", state);
319
+ if (state.status === "loading")
320
+ return;
321
+ const previous = this.lastLicensed;
322
+ this.lastLicensed = state.licensed;
323
+ if (!state.licensed && previous !== false && (this.ui.autoPresentOnLock ?? true)) {
324
+ this.presentQuietly();
325
+ } else if (previous === null && state.licensed && (this.ui.autoPresentUpdate ?? true) && state.update) {
326
+ const latest = state.update.latestVersion;
327
+ void this.isUpdateSkipped(latest).then((skipped) => {
328
+ if (!skipped)
329
+ this.presentQuietly("update");
330
+ });
331
+ }
332
+ }
333
+ presentQuietly(screen) {
334
+ this.present(screen).catch((err) => console.warn(`moonbase: couldn't present the activation UI: ${err instanceof Error ? err.message : err}`));
335
+ }
336
+ /**
337
+ * Show the activation UI and bring it to the front, creating it when needed:
338
+ * its own window, or the overlay over the app's window. `screen` opens it on a
339
+ * particular screen; without one it shows whatever the license state calls for.
340
+ */
341
+ async present(screen) {
342
+ if (!this.ui)
343
+ throw new import_licensing.ActivationError("internal", "The built-in activation UI is turned off");
344
+ await import_electron.app.whenReady();
345
+ if (this.ui.presentation === "overlay")
346
+ return this.mountOverlay(screen ?? null);
347
+ if (this.window && !this.window.isDestroyed()) {
348
+ if (screen)
349
+ this.push("show", screen);
350
+ if (this.window.isMinimized())
351
+ this.window.restore();
352
+ this.window.show();
353
+ this.window.focus();
354
+ return;
355
+ }
356
+ this.pendingScreen = screen ?? null;
357
+ this.window = this.createWindow();
358
+ }
359
+ webPreferences() {
360
+ return {
361
+ preload: import_node_path.default.join(this.folder, "ui-preload.cjs"),
362
+ contextIsolation: true,
363
+ sandbox: true,
364
+ nodeIntegration: false,
365
+ spellcheck: false
366
+ };
367
+ }
368
+ /** The UI's pages load nothing but their own files, and open nothing themselves. */
369
+ lockDown(contents) {
370
+ contents.on("will-navigate", (event) => event.preventDefault());
371
+ contents.setWindowOpenHandler(() => ({ action: "deny" }));
372
+ }
373
+ createWindow() {
374
+ const ui = this.ui ?? {};
375
+ const parent = this.targetWindow();
376
+ const window = new import_electron.BrowserWindow({
377
+ width: WIDTH,
378
+ height: 560,
379
+ useContentSize: true,
380
+ show: false,
381
+ resizable: false,
382
+ maximizable: false,
383
+ fullscreenable: false,
384
+ title: ui.windowTitle ?? ui.productName ?? import_electron.app.getName(),
385
+ backgroundColor: "#080b13",
386
+ titleBarStyle: import_node_process.default.platform === "darwin" ? "hidden" : "default",
387
+ autoHideMenuBar: true,
388
+ ...parent && { parent },
389
+ webPreferences: this.webPreferences()
390
+ });
391
+ window.setMenuBarVisibility(false);
392
+ this.lockDown(window.webContents);
393
+ window.on("closed", () => {
394
+ if (this.window === window)
395
+ this.window = null;
396
+ });
397
+ void window.loadFile(import_node_path.default.join(this.folder, "ui", "index.html"));
398
+ setTimeout(() => {
399
+ if (!window.isDestroyed() && !window.isVisible())
400
+ window.show();
401
+ }, 1500).unref?.();
402
+ return window;
403
+ }
404
+ uiReady(height) {
405
+ if (this.window && !this.window.isDestroyed()) {
406
+ this.uiResize(height);
407
+ this.window.center();
408
+ this.window.show();
409
+ this.window.focus();
410
+ }
411
+ const screen = this.pendingScreen;
412
+ this.pendingScreen = null;
413
+ return { screen };
414
+ }
415
+ uiResize(height) {
416
+ if (this.window && !this.window.isDestroyed() && height > 0)
417
+ this.window.setContentSize(WIDTH, Math.round(Math.min(900, Math.max(240, height))));
418
+ }
419
+ /** Lay the overlay over the app's window, or bring it to `screen` if it is up. */
420
+ mountOverlay(screen) {
421
+ if (this.overlay && !this.overlay.target.isDestroyed()) {
422
+ if (screen)
423
+ this.push("show", screen);
424
+ this.overlay.target.show();
425
+ this.overlay.view.webContents.focus();
426
+ return;
427
+ }
428
+ const target = this.targetWindow();
429
+ if (!target) {
430
+ this.pendingScreen = screen;
431
+ import_electron.app.once("browser-window-created", () => setImmediate(() => this.mountOverlay(this.pendingScreen)));
432
+ return;
433
+ }
434
+ if (typeof import_electron.WebContentsView !== "function")
435
+ throw new import_licensing.ActivationError("internal", "The overlay needs Electron 30 or later");
436
+ this.pendingScreen = screen;
437
+ const view = new import_electron.WebContentsView({ webPreferences: this.webPreferences() });
438
+ view.setBackgroundColor("#00000000");
439
+ this.lockDown(view.webContents);
440
+ target.contentView.addChildView(view);
441
+ const overlay = {
442
+ view,
443
+ target,
444
+ css: null,
445
+ fit: () => {
446
+ const [width = 0, height = 0] = target.getContentSize();
447
+ view.setBounds({ x: 0, y: 0, width, height });
448
+ },
449
+ reinsert: () => {
450
+ void target.webContents.insertCSS("html { filter: blur(10px) saturate(0.8) brightness(0.85); pointer-events: none; }").then((key) => {
451
+ if (this.overlay === overlay)
452
+ overlay.css = key;
453
+ else
454
+ void target.webContents.removeInsertedCSS(key);
455
+ }).catch(() => {
456
+ });
457
+ }
458
+ };
459
+ this.overlay = overlay;
460
+ overlay.fit();
461
+ overlay.reinsert();
462
+ target.on("resize", overlay.fit);
463
+ target.webContents.on("did-finish-load", overlay.reinsert);
464
+ target.once("closed", () => {
465
+ if (this.overlay === overlay)
466
+ this.overlay = null;
467
+ });
468
+ void view.webContents.loadFile(import_node_path.default.join(this.folder, "ui", "overlay.html"));
469
+ view.webContents.once("did-finish-load", () => view.webContents.focus());
470
+ target.show();
471
+ }
472
+ /** Close the activation window, or take the overlay down, if it is showing. */
473
+ closeUi() {
474
+ if (this.window && !this.window.isDestroyed())
475
+ this.window.close();
476
+ this.window = null;
477
+ const overlay = this.overlay;
478
+ if (!overlay)
479
+ return;
480
+ this.overlay = null;
481
+ if (overlay.target.isDestroyed())
482
+ return;
483
+ overlay.target.off("resize", overlay.fit);
484
+ overlay.target.webContents.off("did-finish-load", overlay.reinsert);
485
+ overlay.target.contentView.removeChildView(overlay.view);
486
+ overlay.view.webContents.close();
487
+ if (overlay.css)
488
+ void overlay.target.webContents.removeInsertedCSS(overlay.css);
489
+ overlay.target.webContents.focus();
490
+ }
491
+ /**
492
+ * Open a link from the UI in the browser: the pending activation, the store, or
493
+ * Moonbase's site from the footer. Nothing else, so the UI cannot be used to
494
+ * open arbitrary links.
495
+ */
496
+ async openLink(url) {
497
+ let parsed;
498
+ try {
499
+ parsed = new URL(url);
500
+ } catch {
501
+ throw new import_licensing.ActivationError("internal", "Not a link");
502
+ }
503
+ let sameOrigin = false;
504
+ try {
505
+ sameOrigin = new URL(this.endpoint).origin === parsed.origin;
506
+ } catch {
507
+ }
508
+ const pending = this.state().activation?.browserUrl === url;
509
+ const moonbase = url === MOONBASE_SITE && (this.ui?.showMoonbaseBadge ?? true);
510
+ if (!sameOrigin && !pending && !moonbase)
511
+ throw new import_licensing.ActivationError("internal", "That link can't be opened from here");
512
+ await import_electron.shell.openExternal(url);
513
+ }
514
+ /**
515
+ * Save the machine file for offline activation through a save dialog. Null when
516
+ * the customer cancels.
517
+ */
518
+ async saveMachineFile(parent = null) {
519
+ const token = await this.deviceToken();
520
+ const name = `${fileSafe(this.ui?.productName ?? import_electron.app.getName())}.dt`;
521
+ const options = {
522
+ title: "Save machine file",
523
+ defaultPath: import_node_path.default.join(import_electron.app.getPath("downloads"), name),
524
+ filters: [{ name: "Moonbase machine file", extensions: ["dt"] }]
525
+ };
526
+ const picked = parent ? await import_electron.dialog.showSaveDialog(parent, options) : await import_electron.dialog.showSaveDialog(options);
527
+ if (picked.canceled || !picked.filePath)
528
+ return null;
529
+ await import_promises.default.writeFile(picked.filePath, token);
530
+ return picked.filePath;
531
+ }
532
+ setDownload(next) {
533
+ this.download = next;
534
+ this.push("download", next);
535
+ }
536
+ /**
537
+ * Download the latest installer for this platform into Downloads, reporting
538
+ * progress to the UI, then show it in the file manager.
539
+ */
540
+ async downloadUpdate() {
541
+ if (this.download.phase === "downloading")
542
+ return;
543
+ this.setDownload(downloadState("downloading"));
544
+ try {
545
+ const file = await this.downloadInstaller({
546
+ directory: import_electron.app.getPath("downloads"),
547
+ onProgress: (progress) => this.setDownload(downloadState("downloading", { progress })),
548
+ // Through Chromium's network stack, which knows the system's proxy.
549
+ fetch: (url) => import_electron.net.fetch(url)
550
+ });
551
+ this.downloaded = file;
552
+ import_electron.shell.showItemInFolder(file);
553
+ this.setDownload(downloadState("done", { progress: 1, path: file }));
554
+ } catch (err) {
555
+ if (err instanceof import_licensing.ReleaseNotCoveredError) {
556
+ this.setDownload(downloadState("notCovered", { releaseAccess: err.releaseAccess ?? null, upgradeUrl: err.upgradeUrl ?? null }));
557
+ throw err;
558
+ }
559
+ this.setDownload(downloadState("failed", { error: `The download failed: ${err instanceof Error ? err.message : err}` }));
560
+ throw err;
561
+ }
562
+ }
563
+ /** Show the downloaded installer in the file manager again. */
564
+ revealUpdate() {
565
+ if (!this.downloaded)
566
+ throw new import_licensing.ActivationError("internal", "Nothing has been downloaded");
567
+ import_electron.shell.showItemInFolder(this.downloaded);
568
+ }
569
+ };
570
+ function createMoonbase(options) {
571
+ return new MoonbaseElectron(options);
572
+ }
573
+ // Annotate the CommonJS export names for ESM import in node:
574
+ 0 && (module.exports = {
575
+ MoonbaseElectron,
576
+ createMoonbase
577
+ });