@moonbase.sh/gorilla-engine 0.1.0 → 0.2.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/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  // src/moonbase.ts
2
+ import { Buffer } from "buffer";
2
3
  import { execFile, spawn } from "child_process";
4
+ import fsSync from "fs";
3
5
  import fs2 from "fs/promises";
4
6
  import os from "os";
5
7
  import path2 from "path";
6
8
  import process from "process";
7
- import { ActivationController, ActivationError, ReleaseNotCoveredError } from "@moonbase.sh/licensing";
9
+ import { ActivationController, ActivationError, licensingVersion, MoonbaseError, ReleaseNotCoveredError } from "@moonbase.sh/licensing";
8
10
 
9
11
  // package.json
10
- var version = "0.1.0";
12
+ var version = "0.2.1";
11
13
 
12
14
  // src/download.ts
13
15
  import fs from "fs";
@@ -32,25 +34,15 @@ function uniquePath(dir, name) {
32
34
  }
33
35
  }
34
36
 
37
+ // src/mark.ts
38
+ var MARK_PNG = "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAB8klEQVR4nIxSTUhUURQ+3503P07jrk1Bf7QIhsioqRCpiOiHcCIolIQKhvYFQa0Cly3atIgicJ5CGLUoZl5QRPBslfFeRVGbFjWBuFFReT4ddeYez3v6dBRED7z77rnn3O873znXoAYz7X8p9sbuKtBgpf3wx25A0zqGaNNbcto08CwGdfNG/tBn2sCMYOmznKOa6RNAVzZzKWS0bduoeJk/DFQL+VyWNmnqv5+5QMAeIh5sDLyyf2Ua/T7rW6tZdn8ULbeXmWFIiZfAPCNq/Sip33K3dpzaP9rNrHaX3VYdj43Xa/WXAHYQ88/i2+8HDDDtFcYmEO8yS84ZBqWNmbkPAUB24HfaB1qoVn8gqrwldQ5Yn1TCNB+4TDgLxIcF1fSbEtPFsuv5U1VP4o+laQPybWfiIdLJN3J2XEm575loWuaS1Ji/r0GXA1+C1ah0yTnBTJNQRp7U7ENhqahMc+qpbCbCIgidMUa2zjgt6ZYkDwvICIFfS0OOka7dE+YOhnoePgCz7LwTneeXGQJGoiehnkAKc5scXhXkbQL2onAx1xU+gCRwbZboq2x3LjJTWn53QgiOJh4i9hjJ+K1wjsHSlc+NJpA4GKCt6KIva2b+aEtz6vb1cy1+hLPKekrOPulsJ8Bqqds10dhfaD/ytzFvAQAA///wPXGEAAAABklEQVQDACqdwnQigg9+AAAAAElFTkSuQmCC";
39
+ var MARK_PNG_2X = "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAEk0lEQVR4nLRVbUybVRQ+977vgNJWIX47w2SG+AFztOuME2ZcIsaJLU6zojPTFVQSl2xG4x8z4+IPh8ZkiskiP2gpWdTxx9BC3aaOTP8Q+lJAmV/4MUOmzpHBRvnue8/OLbSjH5SFsSdp773n3vucc+75eFVYAvsReYFfq2bAygViw5DDNrifMQHLBMu06fYFn6PhHTo1y0B92mW3DMJVQk0nbPH1F+ps1kvTzYDYOKbk7d3zRNE0rABSPPR09Jai0I/Txk207HDZbU/CCiLBQ29bz/26rn/PGJgA4Q+jOedZWGHw2KTlWP/NOsdvo8oIgrE3nVtKwrDCiCuMzMw00DPeKOcIMBy5DdvhGiCq0B0I3UdpXx2XIjTX2WyzcA0QjSHTxWsLhYxjT6ZLzb7gMxfVvPZMmdvkD63nIHaT8RVC4dtrK61alNvT+VcOjg3/zxgzx08j2+RybOiCZaAhMJhtjozWA2NxJxBxh2nK1vrTdkAVx4fLpTIE/Iae9VF5gAP+cyXkjZq2Kutf/NRoMuyVCdbU9ouZR0a/ImVlCQcZF1LZnR0hC2fILVHZvDKJCKIhmVy2OG9b0LJQljV2g0LDkJwfDnRdx3m4ExlwREhofeTAyJqjfQUC8AHm9msfUna+kcDO2Vbj+PTJidysVyOqwfPS48XnIQPcPs3KGDaR2aW0PE5xe4Q8yIofUJVCFsG7BOpbKGkwO6Xh6GKz0/nQUY8vWK3MTLzv8WknSOoHhj/KbZwrn7V0r4hWxXR70wKOxxLpsNu11XKaOKrpqc0ySyeSLUbGnqdA7/P4tYMU389IVDH3m2NKNC9j/5dkh+cGfIW4mul52bnkM0Sxxtuh2WscGz+neCQ0AFpfIGOGUu6gWkK7fYnK4AfjVE5jc0foYcoRehE8w7nCu9MZJpDVt7YOZDFd2UkXT8eJmex6sCrVkUhgPoYxw+Qnbcd/pmwmdP0jKeOo/MwxN7+bSuLP5MwiL+8dN0wdcG2zjHKmlpNXvfNb+bR7axobCy47Bn8zUMp2OUpPmfXRQ/SUMrtHDJOWbq5fPH9HoSl8NyloSUPyOiXOQQERs2nK8CARHSDFY7AYECfp/2OTKafEOFUaokSpJ+Nq5o3wO51MZ0RApdFTRgpP0lPxdDwyPvQKuS6HJdjaOWAKhyd3UUyKiWZ1tBEinqHx1KwBvHUVtgtNbaHbORdfgPyAx8AVi6vS0hdPMaqlI6TQubjxFBMGhwRwT63d2p/ujLs9uJYD2yYEvE1nr798GT5xOWx7osbHZJ4ve/NA1QdouhqWxgj9+smKX6mEZAO3EpGMkzGNob8jmqy1VfeMJSic99JKQ1e6LFwOSFlYUdQNL1aW/haTJcSsxmELUYt6ip5gFK4SFPMPyPsXFipLUSjhsm8MkHA9mfcdLB/j9HZfRwCPJW8s2pdk9nrbtZ0IbB8tixL2AN6ii++l3pHFjm6Byru1Vda0n7glGuGcYuqpDiqD3VQf62TRk+wsFfMtMSXEcoKsCOiYfeTlqnVnM/EtqTAZjX4tVwVexEHPZ1wR00JodXbbxJXevwQAAP//kVVCeAAAAAZJREFUAwDo79Or7AZ5mAAAAABJRU5ErkJggg==";
40
+
35
41
  // src/moonbase.ts
36
42
  function runtime() {
37
43
  var _a;
38
44
  return (_a = globalThis.GorillaEngine) != null ? _a : null;
39
45
  }
40
- function defaultLicenseFile() {
41
- var _a, _b;
42
- const ge = runtime();
43
- const manufacturer = fileSafe(((_a = ge == null ? void 0 : ge.getManufacturerName) == null ? void 0 : _a.call(ge)) || "Moonbase");
44
- const plugin = fileSafe(((_b = ge == null ? void 0 : ge.getPluginName) == null ? void 0 : _b.call(ge)) || "Plugin");
45
- let base;
46
- if (process.platform === "darwin")
47
- base = path2.join(os.homedir(), "Library", "Application Support");
48
- else if (process.platform === "win32")
49
- base = process.env.APPDATA || path2.join(os.homedir(), "AppData", "Roaming");
50
- else
51
- base = process.env.XDG_CONFIG_HOME || path2.join(os.homedir(), ".config");
52
- return path2.join(base, manufacturer, plugin, "license.mb");
53
- }
54
46
  function run(command, args, input) {
55
47
  return new Promise((resolve, reject) => {
56
48
  var _a;
@@ -64,21 +56,82 @@ function openWithSystem(url) {
64
56
  const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
65
57
  spawn(command, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
66
58
  }
59
+ function gorillaEngineHost() {
60
+ const ge = runtime();
61
+ return {
62
+ pluginName: () => {
63
+ var _a, _b;
64
+ return (_b = (_a = ge == null ? void 0 : ge.getPluginName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
65
+ },
66
+ manufacturerName: () => {
67
+ var _a, _b;
68
+ return (_b = (_a = ge == null ? void 0 : ge.getManufacturerName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
69
+ },
70
+ openUrl: (url) => (ge == null ? void 0 : ge.openURLinBrowser) ? ge.openURLinBrowser(url) : openWithSystem(url),
71
+ async copyText(text2) {
72
+ if (process.platform === "darwin")
73
+ await run("pbcopy", [], text2);
74
+ else if (process.platform === "win32")
75
+ await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "$input | Set-Clipboard"], text2);
76
+ else
77
+ await run("xclip", ["-selection", "clipboard"], text2);
78
+ },
79
+ chooseFile: (ge == null ? void 0 : ge.openFileChooser) && ((options) => ge.openFileChooser(options)),
80
+ async reveal(file) {
81
+ if (process.platform === "darwin")
82
+ await run("open", ["-R", file]);
83
+ else if (process.platform === "win32")
84
+ await run("explorer.exe", [`/select,${file}`]).catch(() => {
85
+ });
86
+ else
87
+ await run("xdg-open", [path2.dirname(file)]);
88
+ },
89
+ downloadsFolder: () => path2.join(os.homedir(), "Downloads"),
90
+ setAudioAndMidi: (ge == null ? void 0 : ge.getPluginMM) && ge.getPluginAE && ((enabled) => {
91
+ ge.getPluginMM(enabled);
92
+ ge.getPluginAE(enabled);
93
+ })
94
+ };
95
+ }
96
+ function defaultLicenseFile(storage, host = gorillaEngineHost()) {
97
+ const manufacturerName = (storage == null ? void 0 : storage.manufacturer) || host.manufacturerName();
98
+ const pluginName = (storage == null ? void 0 : storage.plugin) || host.pluginName();
99
+ if (!manufacturerName && !pluginName)
100
+ throw new ActivationError("internal", "Can't tell where to keep the license: Gorilla Engine hasn't named the plugin. Pass `storage: { manufacturer, plugin }` or `licenseFile`.");
101
+ const manufacturer = fileSafe(manufacturerName || "Moonbase");
102
+ const plugin = fileSafe(pluginName || "Plugin");
103
+ let base;
104
+ if (process.platform === "darwin")
105
+ base = path2.join(os.homedir(), "Library", "Application Support");
106
+ else if (process.platform === "win32")
107
+ base = process.env.APPDATA || path2.join(os.homedir(), "AppData", "Roaming");
108
+ else
109
+ base = process.env.XDG_CONFIG_HOME || path2.join(os.homedir(), ".config");
110
+ return path2.join(base, manufacturer, plugin, "license.mb");
111
+ }
112
+ function errorKind(err) {
113
+ var _a;
114
+ if (err instanceof ActivationError)
115
+ return err.kind;
116
+ if (err instanceof MoonbaseError)
117
+ return (_a = err.type) != null ? _a : "internal";
118
+ return "internal";
119
+ }
120
+ function writeIfChanged(file, data) {
121
+ if (fsSync.existsSync(file) && fsSync.readFileSync(file).equals(data))
122
+ return;
123
+ fsSync.writeFileSync(file, data);
124
+ }
67
125
  var MoonbaseGorillaEngine = class extends ActivationController {
68
126
  constructor(options) {
69
- var _a, _b, _c, _d, _e, _f, _g;
127
+ var _a, _b, _c, _d, _e, _f, _g, _h;
70
128
  const ui = (_a = options.ui) != null ? _a : {};
71
- const productName = (_d = ui.productName) != null ? _d : ((_c = (_b = runtime()) == null ? void 0 : _b.getPluginName) == null ? void 0 : _c.call(_b)) || "the plugin";
129
+ const host = { ...gorillaEngineHost(), ...options.host, ...options.openUrl && { openUrl: options.openUrl } };
130
+ const productName = (_b = ui.productName) != null ? _b : host.pluginName() || "the plugin";
72
131
  super({
73
132
  ...options,
74
- licenseFile: (_e = options.licenseFile) != null ? _e : defaultLicenseFile(),
75
- openUrl: (_f = options.openUrl) != null ? _f : (url) => {
76
- const ge = runtime();
77
- if (ge == null ? void 0 : ge.openURLinBrowser)
78
- ge.openURLinBrowser(url);
79
- else
80
- openWithSystem(url);
81
- },
133
+ licenseFile: (_c = options.licenseFile) != null ? _c : defaultLicenseFile(options.storage, host),
134
+ openUrl: host.openUrl,
82
135
  // Ahead of the SDK's own token, so Moonbase knows the product uses this module.
83
136
  clientInfo: [options.clientInfo, `@moonbase.sh/gorilla-engine/${version}`].filter(Boolean).join(" "),
84
137
  productName,
@@ -88,24 +141,124 @@ var MoonbaseGorillaEngine = class extends ActivationController {
88
141
  this.uiState = { visible: false, screen: null, request: 0, download: downloadState("idle") };
89
142
  this.lastLicensed = null;
90
143
  this.gated = null;
144
+ this.gateMissingReported = false;
91
145
  this.downloaded = null;
92
146
  this.name = "This computer";
147
+ this.hasStarted = false;
148
+ this.disposed = false;
149
+ this.stopFocus = null;
150
+ /** Aborts the update download when the instance is disposed. */
151
+ this.aborts = new AbortController();
93
152
  this.ui = { ...ui, productName };
94
153
  this.endpoint = options.endpoint;
95
- this.lockAudioAndMidi = (_g = options.lockAudioAndMidi) != null ? _g : true;
154
+ this.host = host;
155
+ this.lockAudioAndMidi = (_d = options.lockAudioAndMidi) != null ? _d : true;
156
+ this.previousLicenseFiles = (_e = options.previousLicenseFiles) != null ? _e : [];
157
+ const warn = (_g = (_f = options.log) == null ? void 0 : _f.warn) != null ? _g : (message) => console.warn(message);
158
+ this.onError = (_h = options.onError) != null ? _h : (failure) => warn(`moonbase: ${failure.action} failed: ${failure.message}`);
96
159
  this.subscribe((state) => this.afterStateChange(state));
97
160
  }
98
161
  /**
99
162
  * Validate the stored license, start watching it, and bring the overlay up
100
- * when the plugin has no license. Call once per plugin instance.
163
+ * when the plugin has no license. Call once per plugin instance; a disposed
164
+ * instance can't start again.
101
165
  */
102
166
  start() {
167
+ if (this.disposed)
168
+ throw new ActivationError("internal", "This Moonbase instance was disposed: create a new one");
169
+ if (this.hasStarted)
170
+ return;
171
+ this.hasStarted = true;
172
+ this.importPreviousLicense();
173
+ if (this.lockAudioAndMidi)
174
+ this.gate(false);
175
+ if (this.host.onFocusChange)
176
+ this.stopFocus = this.host.onFocusChange((focused) => this.onFocusChanged(focused));
103
177
  super.start();
104
178
  this.device().then((device) => {
105
179
  this.name = device.name;
106
180
  }, () => {
107
181
  });
108
182
  }
183
+ /**
184
+ * Stop watching the license and stop telling the overlay anything. For tests
185
+ * and development reloads: a plugin does not need it. Safe to call twice;
186
+ * afterwards the overlay calls do nothing and {@link start} throws.
187
+ */
188
+ dispose() {
189
+ var _a;
190
+ if (this.disposed)
191
+ return;
192
+ this.disposed = true;
193
+ this.uiListeners.clear();
194
+ (_a = this.stopFocus) == null ? void 0 : _a.call(this);
195
+ this.stopFocus = null;
196
+ this.aborts.abort();
197
+ super.dispose();
198
+ }
199
+ /** When the license file is missing, take the one an earlier version kept. */
200
+ importPreviousLicense() {
201
+ if (fsSync.existsSync(this.licenseFile))
202
+ return;
203
+ const previous = this.previousLicenseFiles.find((file) => path2.resolve(file) !== path2.resolve(this.licenseFile) && fsSync.existsSync(file));
204
+ if (!previous)
205
+ return;
206
+ try {
207
+ fsSync.mkdirSync(path2.dirname(this.licenseFile), { recursive: true });
208
+ fsSync.copyFileSync(previous, this.licenseFile);
209
+ } catch (err) {
210
+ this.reportError("previousLicense", err);
211
+ }
212
+ }
213
+ /**
214
+ * Moonbase's mark, for the overlay's footer, as an image file: Gorilla Engine
215
+ * draws images from files only, and a module can't add to the plugin's assets.
216
+ * Written beside the license file, with its `@2x`, the first time it is asked
217
+ * for. Null when it can't be written, and the footer goes without it.
218
+ */
219
+ moonbaseMark() {
220
+ if (this.markFile !== void 0)
221
+ return this.markFile;
222
+ const file = path2.join(path2.dirname(this.licenseFile), "moonbase-mark.png");
223
+ try {
224
+ fsSync.mkdirSync(path2.dirname(file), { recursive: true });
225
+ writeIfChanged(file, Buffer.from(MARK_PNG, "base64"));
226
+ writeIfChanged(file.replace(/\.png$/, "@2x.png"), Buffer.from(MARK_PNG_2X, "base64"));
227
+ this.markFile = file;
228
+ } catch (err) {
229
+ this.reportError("moonbaseMark", err);
230
+ this.markFile = null;
231
+ }
232
+ return this.markFile;
233
+ }
234
+ /**
235
+ * Hand a failure to `onError`: the overlay does with every action that
236
+ * fails, and the module with the host's.
237
+ */
238
+ reportError(action, error) {
239
+ var _a;
240
+ if (this.disposed)
241
+ return;
242
+ const message = error instanceof Error ? error.message : (_a = error == null ? void 0 : error.message) != null ? _a : String(error);
243
+ const kind = error == null ? void 0 : error.kind;
244
+ this.onError({ action, kind: typeof kind === "string" ? kind : errorKind(error), message, error });
245
+ }
246
+ /** A report for support: versions, where the license is kept and what the host can do, but nothing personal. */
247
+ diagnostics() {
248
+ const state = this.state();
249
+ const home = os.homedir();
250
+ return {
251
+ module: version,
252
+ licensing: licensingVersion,
253
+ platform: `${process.platform}-${process.arch}`,
254
+ licenseFile: home && this.licenseFile.startsWith(home) ? `~${this.licenseFile.slice(home.length)}` : this.licenseFile,
255
+ status: state.status,
256
+ licensed: state.licensed,
257
+ host: { gorillaEngine: !!runtime(), fileDialog: !!this.host.chooseFile, audioAndMidi: !!this.host.setAudioAndMidi, focus: !!this.host.onFocusChange },
258
+ audioAndMidi: { gated: this.lockAudioAndMidi, enabled: this.gated },
259
+ overlayVisible: this.uiState.visible
260
+ };
261
+ }
109
262
  /** This computer's name, as the activation screen shows it. */
110
263
  get deviceName() {
111
264
  return this.name;
@@ -116,29 +269,30 @@ var MoonbaseGorillaEngine = class extends ActivationController {
116
269
  }
117
270
  /** Called whenever {@link uiSnapshot} changes. Returns a function that stops it. */
118
271
  subscribeUi(listener) {
272
+ if (this.disposed)
273
+ return () => {
274
+ };
119
275
  this.uiListeners.add(listener);
120
276
  return () => this.uiListeners.delete(listener);
121
277
  }
122
278
  setUi(next) {
279
+ if (this.disposed)
280
+ return;
123
281
  this.uiState = { ...this.uiState, ...next };
124
282
  for (const listener of [...this.uiListeners])
125
283
  listener();
126
284
  }
127
285
  afterStateChange(state) {
128
- var _a, _b, _c, _d;
286
+ var _a, _b;
129
287
  if (state.status === "loading")
130
288
  return;
131
- if (this.lockAudioAndMidi && this.gated !== state.licensed) {
132
- this.gated = state.licensed;
133
- const ge = runtime();
134
- (_a = ge == null ? void 0 : ge.getPluginMM) == null ? void 0 : _a.call(ge, state.licensed);
135
- (_b = ge == null ? void 0 : ge.getPluginAE) == null ? void 0 : _b.call(ge, state.licensed);
136
- }
289
+ if (this.lockAudioAndMidi)
290
+ this.gate(state.licensed);
137
291
  const previous = this.lastLicensed;
138
292
  this.lastLicensed = state.licensed;
139
- if (!state.licensed && previous !== false && ((_c = this.ui.autoPresentOnLock) != null ? _c : true)) {
293
+ if (!state.licensed && previous !== false && ((_a = this.ui.autoPresentOnLock) != null ? _a : true)) {
140
294
  this.present();
141
- } else if (previous === null && state.licensed && ((_d = this.ui.autoPresentUpdate) != null ? _d : true) && state.update) {
295
+ } else if (previous === null && state.licensed && ((_b = this.ui.autoPresentUpdate) != null ? _b : true) && state.update) {
142
296
  const latest = state.update.latestVersion;
143
297
  void this.isUpdateSkipped(latest).then((skipped) => {
144
298
  if (!skipped)
@@ -146,6 +300,25 @@ var MoonbaseGorillaEngine = class extends ActivationController {
146
300
  });
147
301
  }
148
302
  }
303
+ /** Turn MIDI and audio on or off, saying so when the host can't. */
304
+ gate(enabled) {
305
+ if (this.gated === enabled)
306
+ return;
307
+ const set = this.host.setAudioAndMidi;
308
+ if (!set) {
309
+ if (!this.gateMissingReported) {
310
+ this.gateMissingReported = true;
311
+ this.reportError("audioAndMidi", new ActivationError("internal", "Gorilla Engine's getPluginMM and getPluginAE are not there, so the module can't turn MIDI and audio on or off. Pass lockAudioAndMidi: false to gate them yourself."));
312
+ }
313
+ return;
314
+ }
315
+ try {
316
+ set(enabled);
317
+ this.gated = enabled;
318
+ } catch (err) {
319
+ this.reportError("audioAndMidi", err);
320
+ }
321
+ }
149
322
  /**
150
323
  * Show the activation overlay, optionally on a particular screen. Without one
151
324
  * it shows whatever the license state calls for.
@@ -160,25 +333,14 @@ var MoonbaseGorillaEngine = class extends ActivationController {
160
333
  }
161
334
  /** Copy text to the clipboard, for the activation link and the license id. */
162
335
  async copyText(text2) {
163
- if (process.platform === "darwin")
164
- await run("pbcopy", [], text2);
165
- else if (process.platform === "win32")
166
- await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "$input | Set-Clipboard"], text2);
167
- else
168
- await run("xclip", ["-selection", "clipboard"], text2);
336
+ await this.host.copyText(text2);
169
337
  }
170
338
  /** Show a file in the file manager. */
171
339
  async reveal(file) {
172
- if (process.platform === "darwin")
173
- await run("open", ["-R", file]);
174
- else if (process.platform === "win32")
175
- await run("explorer.exe", [`/select,${file}`]).catch(() => {
176
- });
177
- else
178
- await run("xdg-open", [path2.dirname(file)]);
340
+ await this.host.reveal(file);
179
341
  }
180
342
  downloadsFolder() {
181
- return path2.join(os.homedir(), "Downloads");
343
+ return this.host.downloadsFolder();
182
344
  }
183
345
  /**
184
346
  * Save the machine file for offline activation: through Gorilla Engine's save
@@ -186,10 +348,10 @@ var MoonbaseGorillaEngine = class extends ActivationController {
186
348
  * cancels.
187
349
  */
188
350
  async saveMachineFile() {
189
- var _a, _b;
351
+ var _a;
190
352
  const token = await this.deviceToken();
191
353
  const name = `${fileSafe((_a = this.ui.productName) != null ? _a : "license")}.dt`;
192
- const chooser = (_b = runtime()) == null ? void 0 : _b.openFileChooser;
354
+ const chooser = this.host.chooseFile;
193
355
  if (chooser) {
194
356
  const picked = await chooser({ saveDialog: true, warnOnOverwrite: true, hint: "Save machine file", allowedExtensions: "*.dt", defaultLocation: path2.join(this.downloadsFolder(), name) });
195
357
  const file2 = picked == null ? void 0 : picked[0];
@@ -206,8 +368,7 @@ var MoonbaseGorillaEngine = class extends ActivationController {
206
368
  }
207
369
  /** Pick the license file the customer got back for offline activation. Null when they cancel. */
208
370
  async chooseLicenseFile() {
209
- var _a;
210
- const chooser = (_a = runtime()) == null ? void 0 : _a.openFileChooser;
371
+ const chooser = this.host.chooseFile;
211
372
  if (!chooser)
212
373
  throw new ActivationError("internal", "This plugin can't open a file dialog");
213
374
  const picked = await chooser({ hint: "Choose your license file", allowedExtensions: "*.mb;*.jwt;*.txt;*.lic" });
@@ -230,7 +391,8 @@ var MoonbaseGorillaEngine = class extends ActivationController {
230
391
  try {
231
392
  const file = await this.downloadInstaller({
232
393
  directory: this.downloadsFolder(),
233
- onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) })
394
+ onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) }),
395
+ fetch: (url) => fetch(url, { signal: this.aborts.signal })
234
396
  });
235
397
  this.downloaded = file;
236
398
  await this.reveal(file).catch(() => {
@@ -264,11 +426,7 @@ var MoonbaseGorillaEngine = class extends ActivationController {
264
426
  const pending = ((_a = this.state().activation) == null ? void 0 : _a.browserUrl) === url;
265
427
  if (!sameOrigin && !pending && url !== "https://moonbase.sh")
266
428
  throw new ActivationError("internal", "That link can't be opened from here");
267
- const ge = runtime();
268
- if (ge == null ? void 0 : ge.openURLinBrowser)
269
- ge.openURLinBrowser(url);
270
- else
271
- openWithSystem(url);
429
+ await this.host.openUrl(url);
272
430
  }
273
431
  };
274
432
  function createMoonbase(options) {
@@ -277,7 +435,7 @@ function createMoonbase(options) {
277
435
 
278
436
  // src/MoonbaseActivation.ts
279
437
  import process2 from "process";
280
- import * as React2 from "react";
438
+ import * as React3 from "react";
281
439
 
282
440
  // src/copy.ts
283
441
  var DAY = 864e5;
@@ -431,8 +589,111 @@ function describeAddOn(entry, license, state) {
431
589
  }
432
590
 
433
591
  // src/elements.ts
592
+ import * as React2 from "react";
593
+
594
+ // src/motion.ts
434
595
  import * as React from "react";
435
- var h = React.createElement;
596
+ var FRAME = 16;
597
+ function cubicBezier(x1, y1, x2, y2) {
598
+ const at = (a, b, t) => ((1 - 3 * b + 3 * a) * t + (3 * b - 6 * a)) * t * t + 3 * a * t;
599
+ const slope = (a, b, t) => 3 * (1 - 3 * b + 3 * a) * t * t + 2 * (3 * b - 6 * a) * t + 3 * a;
600
+ return (x) => {
601
+ if (x <= 0)
602
+ return 0;
603
+ if (x >= 1)
604
+ return 1;
605
+ let t = x;
606
+ for (let i = 0; i < 8; i++) {
607
+ const error = at(x1, x2, t) - x;
608
+ if (Math.abs(error) < 1e-6)
609
+ return at(y1, y2, t);
610
+ const d = slope(x1, x2, t);
611
+ if (Math.abs(d) < 1e-6)
612
+ break;
613
+ t -= error / d;
614
+ }
615
+ let low = 0;
616
+ let high = 1;
617
+ t = x;
618
+ for (let i = 0; i < 30 && high - low > 1e-6; i++) {
619
+ if (at(x1, x2, t) < x)
620
+ low = t;
621
+ else
622
+ high = t;
623
+ t = (low + high) / 2;
624
+ }
625
+ return at(y1, y2, t);
626
+ };
627
+ }
628
+ var EASE = cubicBezier(0.22, 1, 0.36, 1);
629
+ var EASE_CSS = cubicBezier(0.25, 0.1, 0.25, 1);
630
+ function same(a, b) {
631
+ return a.length === b.length && a.every((value, index) => value === b[index]);
632
+ }
633
+ function useTween(channels, still = false, initial) {
634
+ const targets = channels.map((channel) => channel.to);
635
+ const [values, setValues] = React.useState(() => initial != null ? initial : targets);
636
+ const latest = React.useRef(values);
637
+ latest.current = values;
638
+ const spec = React.useRef(channels);
639
+ spec.current = channels;
640
+ const key = targets.join(",");
641
+ React.useEffect(() => {
642
+ const from = latest.current;
643
+ const to = spec.current.map((channel) => channel.to);
644
+ if (still || same(from, to)) {
645
+ if (!same(from, to))
646
+ setValues(to);
647
+ return;
648
+ }
649
+ const timing = spec.current;
650
+ const start = Date.now();
651
+ let timer;
652
+ const step = () => {
653
+ const elapsed = Date.now() - start;
654
+ let running = false;
655
+ setValues(to.map((target, index) => {
656
+ const { duration, ease } = timing[index];
657
+ const t = duration > 0 ? Math.min(1, elapsed / duration) : 1;
658
+ if (t < 1)
659
+ running = true;
660
+ return t >= 1 ? target : from[index] + (target - from[index]) * ease(t);
661
+ }));
662
+ if (running)
663
+ timer = setTimeout(step, FRAME);
664
+ };
665
+ timer = setTimeout(step, FRAME);
666
+ return () => clearTimeout(timer);
667
+ }, [key, still]);
668
+ return still ? targets : values;
669
+ }
670
+ function useEntrance(key, duration, still = false) {
671
+ const [shown, setShown] = React.useState(() => ({ key, progress: still ? 1 : 0 }));
672
+ if (shown.key !== key)
673
+ setShown({ key, progress: still ? 1 : 0 });
674
+ React.useEffect(() => {
675
+ if (still) {
676
+ setShown((current) => current.progress === 1 ? current : { key, progress: 1 });
677
+ return;
678
+ }
679
+ const start = Date.now();
680
+ let timer;
681
+ const step = () => {
682
+ const progress = Math.min(1, (Date.now() - start) / duration);
683
+ setShown({ key, progress });
684
+ if (progress < 1)
685
+ timer = setTimeout(step, FRAME);
686
+ };
687
+ timer = setTimeout(step, FRAME);
688
+ return () => clearTimeout(timer);
689
+ }, [key, still]);
690
+ if (still)
691
+ return 1;
692
+ return shown.key === key ? shown.progress : 0;
693
+ }
694
+
695
+ // src/elements.ts
696
+ var h = React2.createElement;
436
697
  function color(hex, alpha = 1) {
437
698
  let value = hex.trim().replace(/^#/, "");
438
699
  if (value.length === 3)
@@ -499,10 +760,11 @@ function textHeight(text2, size, width, lineHeight = 1.5) {
499
760
  }
500
761
  return Math.ceil(lines * size * lineHeight);
501
762
  }
502
- var keys = 0;
503
763
  function label(props, ...children) {
504
- var _a;
505
- return h("geLabel", { key: (_a = props.key) != null ? _a : `mb-${keys++}`, interceptsMouseClicks: false, ...props }, ...children);
764
+ return h("geLabel", { interceptsMouseClicks: false, ...props }, ...children);
765
+ }
766
+ function each(node) {
767
+ return Array.isArray(node) ? node : [node];
506
768
  }
507
769
  function text(theme, value, x, y, width, options = {}) {
508
770
  var _a, _b, _c, _d, _e, _f;
@@ -529,12 +791,12 @@ function space(height) {
529
791
  function stack(blocks, x, y, width) {
530
792
  const nodes = [];
531
793
  let top = y;
532
- for (const block of blocks) {
794
+ blocks.forEach((block, index) => {
533
795
  if (!block)
534
- continue;
535
- nodes.push(block.render(x, top, width));
796
+ return;
797
+ nodes.push(h(React2.Fragment, { key: index }, ...each(block.render(x, top, width))));
536
798
  top += block.height;
537
- }
799
+ });
538
800
  return { nodes, height: top - y };
539
801
  }
540
802
  function paragraph(theme, value, width, options = {}) {
@@ -555,7 +817,7 @@ function heading(theme, value, width, options = {}) {
555
817
  }
556
818
  function Button(props) {
557
819
  var _a, _b, _c;
558
- const [hovered, setHovered] = React.useState(false);
820
+ const [hovered, setHovered] = React2.useState(false);
559
821
  const kind = (_a = props.kind) != null ? _a : "primary";
560
822
  const accent = props.theme.accent;
561
823
  const looks = {
@@ -607,7 +869,7 @@ function buttonBlock(theme, value, onClick, options = {}) {
607
869
  }
608
870
  function Link(props) {
609
871
  var _a, _b;
610
- const [hovered, setHovered] = React.useState(false);
872
+ const [hovered, setHovered] = React2.useState(false);
611
873
  const size = (_a = props.size) != null ? _a : 12.5;
612
874
  const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
613
875
  const base = props.link ? palette.link : palette.textSecondary;
@@ -645,7 +907,7 @@ function linksBlock(theme, links, options = {}) {
645
907
  height: marginTop + Math.ceil(size * 1.6),
646
908
  render: (x, y, width) => {
647
909
  const widths = items.map((item) => textWidth(item.label, size, 500) + 12);
648
- const total = widths.reduce((sum, each) => sum + each, 0) + gap * (items.length - 1);
910
+ const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
649
911
  let left = options.align === "left" ? x : x + (width - total) / 2;
650
912
  return items.map((item, index) => {
651
913
  const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], onClick: item.onClick });
@@ -710,6 +972,15 @@ function card(props, ...children) {
710
972
  ...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
711
973
  }, ...children);
712
974
  }
975
+ var SCROLLBAR = 6;
976
+ function scrollView(props, contentHeight, ...children) {
977
+ return h("geScrollView", {
978
+ ...props,
979
+ hideHorizontalScrollbar: true,
980
+ scrollbarThickness: SCROLLBAR,
981
+ scrollbar: { background: palette.transparent, track: palette.transparent, thumb: color("#ffffff", 0.16) }
982
+ }, label({ x: 0, y: 0, width: props.width - SCROLLBAR, height: contentHeight }, ...children));
983
+ }
713
984
  function barBlock(fraction, fill, options = {}) {
714
985
  var _a, _b;
715
986
  const marginTop = (_a = options.marginTop) != null ? _a : 14;
@@ -719,13 +990,118 @@ function barBlock(fraction, fill, options = {}) {
719
990
  };
720
991
  }
721
992
  function useTick(interval) {
722
- const [tick, setTick] = React.useState(0);
723
- React.useEffect(() => {
993
+ const [tick, setTick] = React2.useState(0);
994
+ React2.useEffect(() => {
995
+ if (interval === null)
996
+ return;
724
997
  const timer = setInterval(() => setTick((value) => value + 1), interval);
725
998
  return () => clearInterval(timer);
726
999
  }, [interval]);
727
1000
  return tick;
728
1001
  }
1002
+ var GLOW_STOPS = [
1003
+ [0, [24, 108, 220, 0]],
1004
+ [0.3, [24, 108, 220, 0.9]],
1005
+ [0.5, [130, 206, 241, 1]],
1006
+ [0.7, [24, 108, 220, 0.9]],
1007
+ [1, [24, 108, 220, 0]]
1008
+ ];
1009
+ function glowAt(at) {
1010
+ let index = 1;
1011
+ while (index < GLOW_STOPS.length - 1 && GLOW_STOPS[index][0] < at)
1012
+ index++;
1013
+ const [fromAt, from] = GLOW_STOPS[index - 1];
1014
+ const [toAt, to] = GLOW_STOPS[index];
1015
+ const f = Math.max(0, Math.min(1, (at - fromAt) / (toAt - fromAt)));
1016
+ const alpha = from[3] + (to[3] - from[3]) * f;
1017
+ const channel = (i) => {
1018
+ if (alpha <= 0)
1019
+ return from[i];
1020
+ const premultiplied = from[i] * from[3] + (to[i] * to[3] - from[i] * from[3]) * f;
1021
+ return Math.round(premultiplied / alpha);
1022
+ };
1023
+ const hex = [channel(0), channel(1), channel(2)].map((value) => value.toString(16).padStart(2, "0")).join("");
1024
+ return { hex, alpha };
1025
+ }
1026
+ function glowStrips(width) {
1027
+ const count = Math.max(1, Math.round(width / 5));
1028
+ const edge = (index) => Math.round(index * width / count);
1029
+ return Array.from({ length: count }, (_, index) => {
1030
+ const x = edge(index);
1031
+ const stripWidth = edge(index + 1) - x;
1032
+ const { hex, alpha } = glowAt((x + stripWidth / 2) / width);
1033
+ return label({ key: `glow-${index}`, x, y: 0, width: stripWidth, height: 1, backgroundColor: color(hex, alpha) });
1034
+ });
1035
+ }
1036
+ var Glow = React2.memo((props) => {
1037
+ useTick(props.still ? null : 100);
1038
+ const width = Math.round(props.width * 0.64);
1039
+ const strips = React2.useMemo(() => glowStrips(width), [width]);
1040
+ const alpha = props.still ? 1 : 0.925 - 0.075 * Math.cos(2 * Math.PI * (Date.now() % 5e3) / 5e3);
1041
+ return label({ x: Math.round(props.width * 0.18), y: 0, width, height: 1, alpha }, ...strips);
1042
+ });
1043
+ var CHECK_PATH = [[4.5, 12.75], [10.5, 18.75], [19.5, 5.25]];
1044
+ var CHECK_BOX = 34;
1045
+ var CHECK_STROKE = 4;
1046
+ var CHECK_CIRCLE = 66;
1047
+ var CHECK_ROOM = 3;
1048
+ var CHECK_DOTS = (() => {
1049
+ const scale = CHECK_BOX / 24;
1050
+ const dots = [];
1051
+ const seen = /* @__PURE__ */ new Set();
1052
+ let travelled = 0;
1053
+ for (let index = 1; index < CHECK_PATH.length; index++) {
1054
+ const [x0, y0] = CHECK_PATH[index - 1].map((value) => value * scale);
1055
+ const [x1, y1] = CHECK_PATH[index].map((value) => value * scale);
1056
+ const length = Math.hypot(x1 - x0, y1 - y0);
1057
+ const steps = Math.ceil(length / 0.5);
1058
+ for (let step = 0; step <= steps; step++) {
1059
+ const f = step / steps;
1060
+ const x = Math.round(x0 + (x1 - x0) * f - CHECK_STROKE / 2);
1061
+ const y = Math.round(y0 + (y1 - y0) * f - CHECK_STROKE / 2);
1062
+ if (!seen.has(`${x},${y}`)) {
1063
+ seen.add(`${x},${y}`);
1064
+ dots.push({ x, y, at: travelled + length * f });
1065
+ }
1066
+ }
1067
+ travelled += length;
1068
+ }
1069
+ return dots;
1070
+ })();
1071
+ var CHECK_LENGTH = CHECK_DOTS[CHECK_DOTS.length - 1].at;
1072
+ function SuccessCheck(props) {
1073
+ const elapsed = useEntrance("check", 700, props.still) * 700;
1074
+ const pop = Math.min(1, elapsed / 500);
1075
+ const scale = pop < 0.6 ? 0.4 + 0.68 * EASE(pop / 0.6) : 1.08 - 0.08 * EASE((pop - 0.6) / 0.4);
1076
+ const diameter = Math.round(CHECK_CIRCLE * scale);
1077
+ const drawn = Math.min(CHECK_LENGTH, 30 * (CHECK_BOX / 24) * EASE_CSS(Math.max(0, Math.min(1, (elapsed - 200) / 500))));
1078
+ const middle = CHECK_CIRCLE / 2 + CHECK_ROOM;
1079
+ return label({ x: props.x - CHECK_ROOM, y: props.y - CHECK_ROOM, width: CHECK_CIRCLE + CHECK_ROOM * 2, height: CHECK_CIRCLE + CHECK_ROOM * 2 }, label({
1080
+ key: "circle",
1081
+ x: Math.round(middle - diameter / 2),
1082
+ y: Math.round(middle - diameter / 2),
1083
+ width: diameter,
1084
+ height: diameter,
1085
+ cornerRadius: diameter / 2,
1086
+ backgroundColor: color(palette.successDeep, 0.14),
1087
+ border: { width: 1, color: color(palette.successDeep, 0.35) },
1088
+ alpha: EASE(pop)
1089
+ }), label({
1090
+ key: "tick",
1091
+ x: middle - CHECK_BOX / 2,
1092
+ y: middle - CHECK_BOX / 2,
1093
+ width: CHECK_BOX,
1094
+ height: CHECK_BOX
1095
+ }, ...CHECK_DOTS.filter((dot) => drawn > 0 && dot.at <= drawn).map((dot, index) => label({
1096
+ key: `dot-${index}`,
1097
+ x: dot.x,
1098
+ y: dot.y,
1099
+ width: CHECK_STROKE,
1100
+ height: CHECK_STROKE,
1101
+ cornerRadius: CHECK_STROKE / 2,
1102
+ backgroundColor: color(palette.success)
1103
+ }))));
1104
+ }
729
1105
  function Spinner(props) {
730
1106
  const tick = useTick(90);
731
1107
  const dots = 10;
@@ -780,16 +1156,16 @@ var PAD_X = 40;
780
1156
  var PAD_TOP = 34;
781
1157
  var PAD_BOTTOM = 22;
782
1158
  function useMoonbaseState(moonbase) {
783
- const [state, setState] = React2.useState(() => moonbase.state());
784
- React2.useEffect(() => {
1159
+ const [state, setState] = React3.useState(() => moonbase.state());
1160
+ React3.useEffect(() => {
785
1161
  setState(moonbase.state());
786
1162
  return moonbase.subscribe(setState);
787
1163
  }, [moonbase]);
788
1164
  return state;
789
1165
  }
790
1166
  function useUiState(moonbase) {
791
- const [ui, setUi] = React2.useState(() => moonbase.uiSnapshot());
792
- React2.useEffect(() => {
1167
+ const [ui, setUi] = React3.useState(() => moonbase.uiSnapshot());
1168
+ React3.useEffect(() => {
793
1169
  setUi(moonbase.uiSnapshot());
794
1170
  return moonbase.subscribeUi(() => setUi(moonbase.uiSnapshot()));
795
1171
  }, [moonbase]);
@@ -830,15 +1206,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
830
1206
  const strings = (_d = ui.strings) != null ? _d : {};
831
1207
  const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
832
1208
  const width = cardWidth - PAD_X * 2;
833
- const [view, setView] = React2.useState(null);
834
- const [update, setUpdate] = React2.useState(null);
835
- const [cameFromDetails, setCameFromDetails] = React2.useState(false);
836
- const [offline, setOffline] = React2.useState({ saved: null, file: null, busy: false, error: "" });
837
- const [copied, setCopied] = React2.useState(null);
838
- const previous = React2.useRef(null);
839
- const run2 = (action) => {
840
- action().catch(() => {
841
- });
1209
+ const still = !!ui.reduceMotion;
1210
+ const [view, setView] = React3.useState(null);
1211
+ const [update, setUpdate] = React3.useState(null);
1212
+ const [cameFromDetails, setCameFromDetails] = React3.useState(false);
1213
+ const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
1214
+ const [copied, setCopied] = React3.useState(null);
1215
+ const previous = React3.useRef(null);
1216
+ const run2 = (name2, action) => {
1217
+ action().catch((err) => moonbase.reportError(name2, err));
842
1218
  };
843
1219
  const close = () => moonbase.closeUi();
844
1220
  const canClose = state.status !== "activating" && state.status !== "loading" && state.licensed;
@@ -851,7 +1227,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
851
1227
  if (next === "update")
852
1228
  loadUpdate();
853
1229
  if (next === "addons")
854
- run2(() => moonbase.loadAddOns());
1230
+ run2("loadAddOns", () => moonbase.loadAddOns());
855
1231
  };
856
1232
  const openUpdate = (fromDetails) => {
857
1233
  setCameFromDetails(fromDetails);
@@ -861,7 +1237,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
861
1237
  setCopied(what);
862
1238
  setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
863
1239
  };
864
- React2.useEffect(() => {
1240
+ React3.useEffect(() => {
865
1241
  if (screen === "update")
866
1242
  return openUpdate(false);
867
1243
  let next = screen === "license" ? "details" : screen;
@@ -869,7 +1245,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
869
1245
  next = null;
870
1246
  go(next);
871
1247
  }, [request]);
872
- React2.useEffect(() => {
1248
+ React3.useEffect(() => {
873
1249
  var _a2;
874
1250
  const before = previous.current;
875
1251
  previous.current = state;
@@ -886,7 +1262,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
886
1262
  if (next === "success" && !state.license)
887
1263
  next = null;
888
1264
  if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
889
- run2(() => moonbase.loadAddOns());
1265
+ run2("loadAddOns", () => moonbase.loadAddOns());
890
1266
  if (next !== view)
891
1267
  setView(next);
892
1268
  }, [state]);
@@ -903,10 +1279,10 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
903
1279
  render: (x, y, available) => {
904
1280
  const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
905
1281
  let right = x + available - (canClose ? 40 : 0);
906
- for (const each of [...pills].reverse()) {
907
- const drawn = pill(theme, each.tone, each.text, 0, 0, each.onClick);
1282
+ for (const each2 of [...pills].reverse()) {
1283
+ const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
908
1284
  right -= drawn.width;
909
- nodes.push(pill(theme, each.tone, each.text, right, y + 5, each.onClick).node);
1285
+ nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
910
1286
  right -= 8;
911
1287
  }
912
1288
  return nodes;
@@ -919,7 +1295,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
919
1295
  return { height: 14 + body.height, render: (x, y, available) => body.render(x, y + 14, available) };
920
1296
  };
921
1297
  const backLink = (value, onClick) => ({
922
- height: 20 + 20,
1298
+ height: 20 + 12,
923
1299
  render: (x, y) => h(LinkNode, { key: "back", theme, x, y, value: `\u2039 ${value}`, onClick })
924
1300
  });
925
1301
  const notice = (value, tone) => {
@@ -941,7 +1317,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
941
1317
  render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, text(theme, feature.included ? "\u2713" : "\xD7", 0, 0, 20, { size: 14, weight: 700, textColor: feature.included ? color(palette.success) : palette.textMuted }), text(theme, feature.label, 28, 0, width - 28, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted })))
942
1318
  };
943
1319
  };
944
- const unlock = () => buttonBlock(theme, "Unlock full version", () => run2(() => moonbase.activate()));
1320
+ const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()));
945
1321
  const screens = {
946
1322
  loading: () => [
947
1323
  { height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
@@ -959,7 +1335,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
959
1335
  space(8),
960
1336
  paragraph(theme, body, width, { maxWidth: 430 }),
961
1337
  space(28),
962
- buttonBlock(theme, strings.activateOnline || "Activate online", () => run2(() => moonbase.activate()), { width: 340, height: 44 }),
1338
+ buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
963
1339
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
964
1340
  linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
965
1341
  ];
@@ -977,8 +1353,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
977
1353
  const copyLink = () => {
978
1354
  if (!url)
979
1355
  return;
980
- moonbase.copyText(url).then(() => flashCopied(url), () => {
981
- });
1356
+ moonbase.copyText(url).then(() => flashCopied(url), (err) => moonbase.reportError("copyText", err));
982
1357
  };
983
1358
  const body = !url ? "Creating a secure activation request with your store." : failed ? "We couldn't open your browser. Copy the activation link, open it in any browser on this computer or another, then sign in and confirm this device." : `We opened ${host} in your browser. Sign in and confirm this device; we'll pick it up automatically.`;
984
1359
  return [
@@ -1000,7 +1375,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1000
1375
  },
1001
1376
  buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
1002
1377
  !!url && !failed && linksBlock(theme, [
1003
- { label: "Open the page again", onClick: () => run2(() => moonbase.openLink(url)) },
1378
+ { label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
1004
1379
  { label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
1005
1380
  ]),
1006
1381
  errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
@@ -1014,7 +1389,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1014
1389
  return [
1015
1390
  {
1016
1391
  height: 66 + 6,
1017
- render: (x, y, available) => label({ key: "check", x: x + available / 2 - 33, y: y + 6, width: 66, height: 66, cornerRadius: 33, backgroundColor: color(palette.successDeep, 0.14), border: { width: 1, color: color(palette.successDeep, 0.35) } }, text(theme, "\u2713", 0, 0, 66, { size: 30, weight: 700, textColor: color(palette.success), align: "center" }))
1392
+ render: (x, y, available) => h(SuccessCheck, { key: "check", x: Math.round(x + available / 2 - 33), y: y + 6, still })
1018
1393
  },
1019
1394
  space(22),
1020
1395
  heading(theme, license.trial ? "Your trial has started" : "You're all set", width, { align: "center" }),
@@ -1039,13 +1414,19 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1039
1414
  setOffline((current) => ({ ...current, error: "" }));
1040
1415
  moonbase.saveMachineFile().then(
1041
1416
  (saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
1042
- (err) => setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }))
1417
+ (err) => {
1418
+ moonbase.reportError("saveMachineFile", err);
1419
+ setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }));
1420
+ }
1043
1421
  );
1044
1422
  };
1045
1423
  const useFile = (pick) => {
1046
1424
  pick.then(
1047
1425
  (file) => file && setOffline((current) => ({ ...current, file, error: "" })),
1048
- () => setOffline((current) => ({ ...current, error: "Couldn't read that file." }))
1426
+ (err) => {
1427
+ moonbase.reportError("readLicenseFile", err);
1428
+ setOffline((current) => ({ ...current, error: "Couldn't read that file." }));
1429
+ }
1049
1430
  );
1050
1431
  };
1051
1432
  const activateOffline = () => {
@@ -1067,7 +1448,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1067
1448
  });
1068
1449
  };
1069
1450
  const step = (n, value) => ({
1070
- height: 20 + 11,
1451
+ height: 20 + 10,
1071
1452
  render: (x, y) => label({ key: `step-${n}`, x, y, width, height: 20 }, label({ x: 0, y: 0, width: 20, height: 20, cornerRadius: 10, backgroundColor: color(theme.accent), text: n, fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
1072
1453
  });
1073
1454
  return [
@@ -1075,31 +1456,31 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1075
1456
  heading(theme, "Offline activation", width),
1076
1457
  space(8),
1077
1458
  paragraph(theme, `For computers without internet. Save your request file, take it to ${activationHost(moonbase)}/activate on a connected device, and bring back the license file.`, width),
1078
- space(24),
1459
+ space(18),
1079
1460
  step("1", "Save your request file"),
1080
1461
  {
1081
- height: 58 + 22,
1082
- render: (x, y) => card({ x, y, width, height: 58, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, text(theme, requestFile, 16, 10, width - 120, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 16, 30, width - 120, { size: 11.5, textColor: palette.textSecondary }), text(theme, offline.saved ? "\u2713" : "Save\u2026", width - 80, 0, 64, { size: offline.saved ? 18 : 12.5, weight: 600, textColor: offline.saved ? color(palette.success) : palette.link, align: "right", height: 58 }))
1462
+ height: 52 + 16,
1463
+ render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, text(theme, requestFile, 16, 7, width - 120, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 16, 27, width - 120, { size: 11.5, textColor: palette.textSecondary }), text(theme, offline.saved ? "\u2713" : "Save\u2026", width - 80, 0, 64, { size: offline.saved ? 18 : 12.5, weight: 600, textColor: offline.saved ? color(palette.success) : palette.link, align: "right", height: 52 }))
1083
1464
  },
1084
1465
  step("2", "Add the license file"),
1085
1466
  {
1086
- height: 96,
1467
+ height: 72,
1087
1468
  render: (x, y) => h("geDropZone", {
1088
1469
  key: "drop",
1089
1470
  x,
1090
1471
  y,
1091
1472
  width,
1092
- height: 96,
1473
+ height: 72,
1093
1474
  onDroppedFiles: (dropped) => {
1094
1475
  const file = droppedFiles(dropped)[0];
1095
1476
  if (file)
1096
1477
  useFile(moonbase.readLicenseFile(file));
1097
1478
  }
1098
- }, card({ x: 0, y: 0, width, height: 96, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, text(theme, offline.file ? offline.file.name : "Drop your license file here", 0, 26, width, { size: 13, weight: 600, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody, align: "center" }), text(theme, offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb", 0, 50, width, { size: 11.5, textColor: palette.textSecondary, align: "center" })))
1479
+ }, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, text(theme, offline.file ? offline.file.name : "Drop your license file here", 0, 15, width, { size: 13, weight: 600, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody, align: "center" }), text(theme, offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb", 0, 38, width, { size: 11.5, textColor: palette.textSecondary, align: "center" })))
1099
1480
  },
1100
1481
  errorLine(offline.error),
1101
- space(22),
1102
- buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy })
1482
+ space(16),
1483
+ buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy, height: 44 })
1103
1484
  ];
1104
1485
  },
1105
1486
  trial: () => {
@@ -1151,9 +1532,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1151
1532
  paragraph(theme, body, width),
1152
1533
  space(22),
1153
1534
  notice(`${product} is locked. Your license still works with the versions it covers, so you can go back to one of those, or upgrade to use this one.`, "upgrade"),
1154
- buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())),
1535
+ buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
1155
1536
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1156
- linksBlock(theme, [offlineLicense ? { label: "Load an upgraded license file", onClick: () => go("offline") } : { label: state.refreshing ? "Checking your license\u2026" : renewal ? "Already renewed? Check again" : "Already upgraded? Check again", disabled: state.refreshing, onClick: () => run2(() => moonbase.refresh()) }])
1537
+ linksBlock(theme, [offlineLicense ? { label: "Load an upgraded license file", onClick: () => go("offline") } : { label: state.refreshing ? "Checking your license\u2026" : renewal ? "Already renewed? Check again" : "Already upgraded? Check again", disabled: state.refreshing, onClick: () => run2("refresh", () => moonbase.refresh()) }])
1157
1538
  ];
1158
1539
  },
1159
1540
  details: () => {
@@ -1169,6 +1550,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1169
1550
  const seatCount = license.seatCount;
1170
1551
  const used = license.seatsUsed;
1171
1552
  const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
1553
+ const lit = !seatCount || !used ? 0 : used >= seatCount ? pipCount : Math.max(1, Math.min(pipCount - 1, Math.round(used / seatCount * pipCount)));
1172
1554
  const seatsTitle = seatCount ? `Activations \xB7 ${used != null ? used : "?"} of ${seatCount} ${seatCount === 1 ? "device" : "devices"}` : license.activationMethod === "Offline" ? "Activated offline on this device" : "Activated on this device";
1173
1555
  const idCopied = copied === license.id;
1174
1556
  const rowHeight = 44;
@@ -1179,12 +1561,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1179
1561
  ]),
1180
1562
  {
1181
1563
  height: (rows.length + 1) * rowHeight + 2 + 18,
1182
- render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, value, 140, 0, width - 172, { size: 13, weight: 500, textColor: index === 1 ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 84, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 74, y: 7, width: 74, height: 30, label: idCopied ? "\u2713 Copied" : "Copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), () => {
1183
- }) })))
1564
+ render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, value, 140, 0, width - 172, { size: 13, weight: 500, textColor: index === 1 ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 84, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 74, y: 7, width: 74, height: 30, label: idCopied ? "\u2713 Copied" : "Copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
1184
1565
  },
1185
1566
  {
1186
1567
  height: 64 + 22,
1187
- render: (x, y) => card({ x, y, width, height: 64 }, text(theme, seatsTitle, 16, pipCount ? 11 : 0, width - 220, { size: 12.5, weight: 500, textColor: palette.textBright, height: pipCount ? 22 : 64 }), ...Array.from({ length: pipCount }, (_, index) => label({ key: `pip-${index}`, x: 16 + index * 40, y: 40, width: 34, height: 6, cornerRadius: 3, backgroundColor: index < (used != null ? used : 0) ? color(theme.accent) : color("#ffffff", 0.1) })), h(Button, {
1568
+ render: (x, y) => card({ x, y, width, height: 64 }, text(theme, seatsTitle, 16, pipCount ? 11 : 0, width - 220, { size: 12.5, weight: 500, textColor: palette.textBright, height: pipCount ? 22 : 64 }), ...Array.from({ length: pipCount }, (_, index) => label({ key: `pip-${index}`, x: 16 + index * 40, y: 40, width: 34, height: 6, cornerRadius: 3, backgroundColor: index < lit ? color(theme.accent) : color("#ffffff", 0.1) })), h(Button, {
1188
1569
  key: "deactivate",
1189
1570
  theme,
1190
1571
  x: width - 16 - 178,
@@ -1194,7 +1575,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1194
1575
  kind: "danger",
1195
1576
  disabled: state.busy,
1196
1577
  label: state.busy ? "Deactivating\u2026" : license.trial || license.activationMethod === "Offline" ? "Remove from this device" : "Deactivate this device",
1197
- onClick: () => run2(() => moonbase.deactivate())
1578
+ onClick: () => run2("deactivate", () => moonbase.deactivate())
1198
1579
  }))
1199
1580
  },
1200
1581
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
@@ -1223,8 +1604,10 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1223
1604
  list = {
1224
1605
  height: listHeight,
1225
1606
  render: (x, y) => {
1226
- const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), width, rowHeight));
1227
- return rows.length > visible ? h("geScrollView", { key: "addon-list", x, y, width, height: listHeight }, label({ x: 0, y: 0, width, height: rows.length * (rowHeight + 10) - 10 }, ...content2)) : label({ key: "addon-list", x, y, width, height: listHeight }, ...content2);
1607
+ const scrolls2 = rows.length > visible;
1608
+ const rowWidth = scrolls2 ? width - SCROLLBAR - 8 : width;
1609
+ const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), rowWidth, rowHeight));
1610
+ return scrolls2 ? scrollView({ key: "addon-list", x, y, width, height: listHeight }, rows.length * (rowHeight + 10) - 10, ...content2) : label({ key: "addon-list", x, y, width, height: listHeight }, ...content2);
1228
1611
  }
1229
1612
  };
1230
1613
  } else if (info.phase !== "ready") {
@@ -1246,7 +1629,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1246
1629
  label: loading ? "Checking\u2026" : failed ? "Try again" : "Bought an add-on? Refresh",
1247
1630
  link: true,
1248
1631
  disabled: loading || waiting,
1249
- onClick: () => run2(() => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1632
+ onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1250
1633
  }], { align: "left" })
1251
1634
  ];
1252
1635
  },
@@ -1279,11 +1662,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1279
1662
  const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
1280
1663
  let action;
1281
1664
  if (download.phase === "done")
1282
- action = buttonBlock(theme, "Show in folder", () => run2(() => moonbase.revealUpdate()));
1665
+ action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
1283
1666
  else if (notCovered)
1284
- action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())) : null;
1667
+ action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
1285
1668
  else if (update.canDownload)
1286
- action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2(() => moonbase.downloadUpdate()), { disabled: downloading });
1669
+ action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
1287
1670
  else
1288
1671
  action = update.hasDownloads ? unlock() : null;
1289
1672
  const standing = notCovered ? ", which your license doesn't cover." : !update.hasDownloads ? ", which has no download for this computer yet." : update.canDownload ? ", included in your license." : ", which your license doesn't include yet.";
@@ -1315,8 +1698,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1315
1698
  { label: "Remind me later", onClick: back },
1316
1699
  { label: "Skip this version", onClick: () => {
1317
1700
  var _a3;
1318
- moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch(() => {
1319
- }).then(back);
1701
+ moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch((err) => moonbase.reportError("skipUpdate", err)).then(back);
1320
1702
  } }
1321
1703
  ])
1322
1704
  ];
@@ -1338,7 +1720,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1338
1720
  const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
1339
1721
  const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
1340
1722
  right -= buttonWidth;
1341
- const node = h(Button, { key: action, theme, x: right, y: (rowHeight - 34) / 2, width: buttonWidth, height: 34, size: 13, label: value, kind: primary ? "small-primary" : "small-ghost", disabled: anyBusy, onClick: () => run2(() => addOnActions[action].run(row.id)) });
1723
+ const node = h(Button, { key: action, theme, x: right, y: (rowHeight - 34) / 2, width: buttonWidth, height: 34, size: 13, label: value, kind: primary ? "small-primary" : "small-ghost", disabled: anyBusy, onClick: () => run2(action, () => addOnActions[action].run(row.id)) });
1342
1724
  right -= 8;
1343
1725
  return node;
1344
1726
  });
@@ -1353,28 +1735,62 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1353
1735
  let content;
1354
1736
  if (scrolls) {
1355
1737
  const inner = stack(blocks, PAD_X, 0, width);
1356
- content = { height: room, nodes: [h("geScrollView", { key: "screen", x: 0, y: PAD_TOP, width: cardWidth, height: room }, label({ x: 0, y: 0, width: cardWidth, height: inner.height }, ...inner.nodes))] };
1738
+ content = { height: room, nodes: [scrollView({ key: "screen", x: 0, y: PAD_TOP, width: cardWidth - 10, height: room }, inner.height, ...inner.nodes)] };
1357
1739
  } else {
1358
1740
  content = stack(blocks, PAD_X, PAD_TOP, width);
1359
1741
  }
1360
1742
  const cardHeight = PAD_TOP + content.height + footer + PAD_BOTTOM;
1361
1743
  const top = Math.max(12, Math.round((areaHeight - cardHeight) / 2));
1362
1744
  const left = Math.round((areaWidth - cardWidth) / 2);
1363
- return card({ x: left, y: top, width: cardWidth, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 }, label({ key: "glow", x: Math.round(cardWidth * 0.18), y: 0, width: Math.round(cardWidth * 0.64), height: 1, backgroundColor: color("#82cef1", 0.8) }), ...content.nodes, canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }), showBadge && label({ key: "divider", x: PAD_X, y: PAD_TOP + content.height + 30, width, height: 1, backgroundColor: color("#ffffff", 0.06) }), showBadge && h(LinkNode, { key: "badge", theme, x: PAD_X, y: PAD_TOP + content.height + 30 + 14, width, value: "Licensing secured by moonbase", center: true, muted: true, onClick: () => run2(() => moonbase.openLink("https://moonbase.sh")) }));
1745
+ return h(PanelCard, {
1746
+ key: "card",
1747
+ left,
1748
+ top,
1749
+ width: cardWidth,
1750
+ height: cardHeight,
1751
+ screen: name,
1752
+ contentHeight: content.height,
1753
+ content: content.nodes,
1754
+ closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }),
1755
+ // Kept to the card's bottom edge as it resizes.
1756
+ footer: showBadge ? (height) => {
1757
+ const divider = height - footer - PAD_BOTTOM + 30;
1758
+ return [
1759
+ label({ key: "divider", x: PAD_X, y: divider, width, height: 1, backgroundColor: color("#ffffff", 0.06) }),
1760
+ h(Badge, { key: "badge", theme, x: PAD_X, y: divider + 14, width, mark: moonbase.moonbaseMark(), onClick: () => run2("openLink", () => moonbase.openLink("https://moonbase.sh")) })
1761
+ ];
1762
+ } : null,
1763
+ still
1764
+ });
1765
+ }
1766
+ var PanelView = React3.memo(Panel);
1767
+ function PanelCard(props) {
1768
+ var _a, _b;
1769
+ const [top, height] = useTween([
1770
+ { to: props.top, duration: 300, ease: EASE },
1771
+ { to: props.height, duration: 300, ease: EASE }
1772
+ ], props.still);
1773
+ const entered = EASE(useEntrance(props.screen, 400, props.still));
1774
+ const cardHeight = Math.round(height);
1775
+ return card(
1776
+ { x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
1777
+ h(Glow, { key: "glow", width: props.width, still: props.still }),
1778
+ label({ key: "screen", x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
1779
+ props.closeButton,
1780
+ ...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
1781
+ );
1364
1782
  }
1365
1783
  function LinkNode(props) {
1366
- var _a;
1367
- const [hovered, setHovered] = React2.useState(false);
1368
- const width = (_a = props.width) != null ? _a : textWidth(props.value, 12.5, 500) + 8;
1784
+ const [hovered, setHovered] = React3.useState(false);
1369
1785
  return label({
1370
1786
  x: props.x,
1371
1787
  y: props.y,
1372
- width,
1788
+ width: textWidth(props.value, 12.5, 500) + 8,
1373
1789
  height: 20,
1374
1790
  text: props.value,
1375
- fontSize: props.muted ? 11 : 12.5,
1376
- textColor: hovered ? palette.textBright : props.muted ? palette.textMuted : palette.textSecondary,
1377
- textAlign: props.center ? "center" : "centered left",
1791
+ fontSize: 12.5,
1792
+ textColor: hovered ? palette.textBright : palette.textSecondary,
1793
+ textAlign: "centered left",
1378
1794
  interceptsMouseClicks: true,
1379
1795
  mouseCursorType: "pointing hand",
1380
1796
  onMouseEnter: () => setHovered(true),
@@ -1382,6 +1798,27 @@ function LinkNode(props) {
1382
1798
  onClick: props.onClick
1383
1799
  });
1384
1800
  }
1801
+ function Badge(props) {
1802
+ const [hovered, setHovered] = React3.useState(false);
1803
+ const lead = "Licensing secured by";
1804
+ const gap = 7;
1805
+ const size = props.mark ? 14 : 0;
1806
+ const markGap = props.mark ? gap : 0;
1807
+ const wordmark = textWidth("moonbase", 12, 500) + 16;
1808
+ const start = Math.round((props.width - (textWidth(lead, 11) + gap + size + markGap + wordmark)) / 2);
1809
+ const linkX = start + textWidth(lead, 11) + gap;
1810
+ return label({ x: props.x, y: props.y, width: props.width, height: 20 }, text(props.theme, lead, 0, 0, linkX - gap, { size: 11, textColor: palette.textMuted, align: "right", height: 20 }), label({
1811
+ x: linkX,
1812
+ y: 0,
1813
+ width: size + markGap + wordmark,
1814
+ height: 20,
1815
+ interceptsMouseClicks: true,
1816
+ mouseCursorType: "pointing hand",
1817
+ onMouseEnter: () => setHovered(true),
1818
+ onMouseExit: () => setHovered(false),
1819
+ onClick: props.onClick
1820
+ }, props.mark && label({ x: 0, y: (20 - size) / 2, width: size, height: size, backgroundImage: props.mark, alpha: hovered ? 1 : 0.85 }), text(props.theme, "moonbase", size + markGap, 0, wordmark, { size: 12, weight: 500, kerning: 0.06, textColor: hovered ? palette.textPrimary : palette.textBright, height: 20 })));
1821
+ }
1385
1822
  function osLabel() {
1386
1823
  switch (process2.platform) {
1387
1824
  case "darwin":
@@ -1406,7 +1843,12 @@ function MoonbaseActivation(props) {
1406
1843
  const { moonbase, width, height } = props;
1407
1844
  const state = useMoonbaseState(moonbase);
1408
1845
  const ui = useUiState(moonbase);
1409
- if (!ui.visible)
1846
+ const shown = ui.visible ? 1 : 0;
1847
+ const [scrim, rise] = useTween([
1848
+ { to: shown, duration: 250, ease: EASE_CSS },
1849
+ { to: shown, duration: ui.visible ? 350 : 250, ease: ui.visible ? EASE : EASE_CSS }
1850
+ ], !!moonbase.ui.reduceMotion, [0, 0]);
1851
+ if (!ui.visible && scrim === 0 && rise === 0)
1410
1852
  return null;
1411
1853
  return label({
1412
1854
  key: "moonbase-activation",
@@ -1414,7 +1856,8 @@ function MoonbaseActivation(props) {
1414
1856
  y: (_b = props.y) != null ? _b : 0,
1415
1857
  width,
1416
1858
  height,
1417
- backgroundColor: palette.scrim,
1859
+ // Never quite clear while it is there, coming or going.
1860
+ backgroundColor: color("#04060b", Math.max(1 / 255, 0.62 * scrim)),
1418
1861
  alwaysOnTop: true,
1419
1862
  // Takes every click, so the plugin underneath is locked while it is up.
1420
1863
  interceptsMouseClicks: true,
@@ -1422,12 +1865,19 @@ function MoonbaseActivation(props) {
1422
1865
  // the front, after the customer bought an add-on in the browser.
1423
1866
  onMouseEnter: () => moonbase.onFocusChanged(true),
1424
1867
  onMouseExit: () => moonbase.onFocusChanged(false)
1425
- }, h(Panel, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height }));
1868
+ }, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height })));
1426
1869
  }
1870
+
1871
+ // src/index.ts
1872
+ import { ActivationError as ActivationError2, MoonbaseError as MoonbaseError2, ReleaseNotCoveredError as ReleaseNotCoveredError2 } from "@moonbase.sh/licensing";
1427
1873
  export {
1874
+ ActivationError2 as ActivationError,
1428
1875
  MoonbaseActivation,
1876
+ MoonbaseError2 as MoonbaseError,
1429
1877
  MoonbaseGorillaEngine,
1878
+ ReleaseNotCoveredError2 as ReleaseNotCoveredError,
1430
1879
  createMoonbase,
1431
1880
  defaultLicenseFile,
1881
+ gorillaEngineHost,
1432
1882
  useMoonbaseState
1433
1883
  };