@moonbase.sh/gorilla-engine 0.1.0 → 0.2.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 CHANGED
@@ -28,18 +28,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ ActivationError: () => import_licensing2.ActivationError,
33
34
  MoonbaseActivation: () => MoonbaseActivation,
35
+ MoonbaseError: () => import_licensing2.MoonbaseError,
34
36
  MoonbaseGorillaEngine: () => MoonbaseGorillaEngine,
37
+ ReleaseNotCoveredError: () => import_licensing2.ReleaseNotCoveredError,
35
38
  createMoonbase: () => createMoonbase,
36
39
  defaultLicenseFile: () => defaultLicenseFile,
40
+ gorillaEngineHost: () => gorillaEngineHost,
37
41
  useMoonbaseState: () => useMoonbaseState
38
42
  });
39
- module.exports = __toCommonJS(index_exports);
43
+ module.exports = __toCommonJS(src_exports);
40
44
 
41
45
  // src/moonbase.ts
42
46
  var import_node_child_process = require("child_process");
47
+ var import_node_fs2 = __toESM(require("fs"), 1);
43
48
  var import_promises = __toESM(require("fs/promises"), 1);
44
49
  var import_node_os = __toESM(require("os"), 1);
45
50
  var import_node_path2 = __toESM(require("path"), 1);
@@ -47,7 +52,7 @@ var import_node_process = __toESM(require("process"), 1);
47
52
  var import_licensing = require("@moonbase.sh/licensing");
48
53
 
49
54
  // package.json
50
- var version = "0.1.0";
55
+ var version = "0.2.0";
51
56
 
52
57
  // src/download.ts
53
58
  var import_node_fs = __toESM(require("fs"), 1);
@@ -77,20 +82,6 @@ function runtime() {
77
82
  var _a;
78
83
  return (_a = globalThis.GorillaEngine) != null ? _a : null;
79
84
  }
80
- function defaultLicenseFile() {
81
- var _a, _b;
82
- const ge = runtime();
83
- const manufacturer = fileSafe(((_a = ge == null ? void 0 : ge.getManufacturerName) == null ? void 0 : _a.call(ge)) || "Moonbase");
84
- const plugin = fileSafe(((_b = ge == null ? void 0 : ge.getPluginName) == null ? void 0 : _b.call(ge)) || "Plugin");
85
- let base;
86
- if (import_node_process.default.platform === "darwin")
87
- base = import_node_path2.default.join(import_node_os.default.homedir(), "Library", "Application Support");
88
- else if (import_node_process.default.platform === "win32")
89
- base = import_node_process.default.env.APPDATA || import_node_path2.default.join(import_node_os.default.homedir(), "AppData", "Roaming");
90
- else
91
- base = import_node_process.default.env.XDG_CONFIG_HOME || import_node_path2.default.join(import_node_os.default.homedir(), ".config");
92
- return import_node_path2.default.join(base, manufacturer, plugin, "license.mb");
93
- }
94
85
  function run(command, args, input) {
95
86
  return new Promise((resolve, reject) => {
96
87
  var _a;
@@ -104,21 +95,77 @@ function openWithSystem(url) {
104
95
  const [command, args] = import_node_process.default.platform === "darwin" ? ["open", [url]] : import_node_process.default.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
105
96
  (0, import_node_child_process.spawn)(command, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
106
97
  }
98
+ function gorillaEngineHost() {
99
+ const ge = runtime();
100
+ return {
101
+ pluginName: () => {
102
+ var _a, _b;
103
+ return (_b = (_a = ge == null ? void 0 : ge.getPluginName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
104
+ },
105
+ manufacturerName: () => {
106
+ var _a, _b;
107
+ return (_b = (_a = ge == null ? void 0 : ge.getManufacturerName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
108
+ },
109
+ openUrl: (url) => (ge == null ? void 0 : ge.openURLinBrowser) ? ge.openURLinBrowser(url) : openWithSystem(url),
110
+ async copyText(text2) {
111
+ if (import_node_process.default.platform === "darwin")
112
+ await run("pbcopy", [], text2);
113
+ else if (import_node_process.default.platform === "win32")
114
+ await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "$input | Set-Clipboard"], text2);
115
+ else
116
+ await run("xclip", ["-selection", "clipboard"], text2);
117
+ },
118
+ chooseFile: (ge == null ? void 0 : ge.openFileChooser) && ((options) => ge.openFileChooser(options)),
119
+ async reveal(file) {
120
+ if (import_node_process.default.platform === "darwin")
121
+ await run("open", ["-R", file]);
122
+ else if (import_node_process.default.platform === "win32")
123
+ await run("explorer.exe", [`/select,${file}`]).catch(() => {
124
+ });
125
+ else
126
+ await run("xdg-open", [import_node_path2.default.dirname(file)]);
127
+ },
128
+ downloadsFolder: () => import_node_path2.default.join(import_node_os.default.homedir(), "Downloads"),
129
+ setAudioAndMidi: (ge == null ? void 0 : ge.getPluginMM) && ge.getPluginAE && ((enabled) => {
130
+ ge.getPluginMM(enabled);
131
+ ge.getPluginAE(enabled);
132
+ })
133
+ };
134
+ }
135
+ function defaultLicenseFile(storage, host = gorillaEngineHost()) {
136
+ const manufacturerName = (storage == null ? void 0 : storage.manufacturer) || host.manufacturerName();
137
+ const pluginName = (storage == null ? void 0 : storage.plugin) || host.pluginName();
138
+ if (!manufacturerName && !pluginName)
139
+ throw new import_licensing.ActivationError("internal", "Can't tell where to keep the license: Gorilla Engine hasn't named the plugin. Pass `storage: { manufacturer, plugin }` or `licenseFile`.");
140
+ const manufacturer = fileSafe(manufacturerName || "Moonbase");
141
+ const plugin = fileSafe(pluginName || "Plugin");
142
+ let base;
143
+ if (import_node_process.default.platform === "darwin")
144
+ base = import_node_path2.default.join(import_node_os.default.homedir(), "Library", "Application Support");
145
+ else if (import_node_process.default.platform === "win32")
146
+ base = import_node_process.default.env.APPDATA || import_node_path2.default.join(import_node_os.default.homedir(), "AppData", "Roaming");
147
+ else
148
+ base = import_node_process.default.env.XDG_CONFIG_HOME || import_node_path2.default.join(import_node_os.default.homedir(), ".config");
149
+ return import_node_path2.default.join(base, manufacturer, plugin, "license.mb");
150
+ }
151
+ function errorKind(err) {
152
+ var _a;
153
+ if (err instanceof import_licensing.ActivationError)
154
+ return err.kind;
155
+ if (err instanceof import_licensing.MoonbaseError)
156
+ return (_a = err.type) != null ? _a : "internal";
157
+ return "internal";
158
+ }
107
159
  var MoonbaseGorillaEngine = class extends import_licensing.ActivationController {
108
160
  constructor(options) {
109
- var _a, _b, _c, _d, _e, _f, _g;
161
+ var _a, _b, _c, _d, _e, _f, _g, _h;
110
162
  const ui = (_a = options.ui) != null ? _a : {};
111
- const productName = (_d = ui.productName) != null ? _d : ((_c = (_b = runtime()) == null ? void 0 : _b.getPluginName) == null ? void 0 : _c.call(_b)) || "the plugin";
163
+ const host = { ...gorillaEngineHost(), ...options.host, ...options.openUrl && { openUrl: options.openUrl } };
164
+ const productName = (_b = ui.productName) != null ? _b : host.pluginName() || "the plugin";
112
165
  super({
113
166
  ...options,
114
- licenseFile: (_e = options.licenseFile) != null ? _e : defaultLicenseFile(),
115
- openUrl: (_f = options.openUrl) != null ? _f : (url) => {
116
- const ge = runtime();
117
- if (ge == null ? void 0 : ge.openURLinBrowser)
118
- ge.openURLinBrowser(url);
119
- else
120
- openWithSystem(url);
121
- },
167
+ licenseFile: (_c = options.licenseFile) != null ? _c : defaultLicenseFile(options.storage, host),
168
+ openUrl: host.openUrl,
122
169
  // Ahead of the SDK's own token, so Moonbase knows the product uses this module.
123
170
  clientInfo: [options.clientInfo, `@moonbase.sh/gorilla-engine/${version}`].filter(Boolean).join(" "),
124
171
  productName,
@@ -128,24 +175,103 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
128
175
  this.uiState = { visible: false, screen: null, request: 0, download: downloadState("idle") };
129
176
  this.lastLicensed = null;
130
177
  this.gated = null;
178
+ this.gateMissingReported = false;
131
179
  this.downloaded = null;
132
180
  this.name = "This computer";
181
+ this.hasStarted = false;
182
+ this.disposed = false;
183
+ this.stopFocus = null;
184
+ /** Aborts the update download when the instance is disposed. */
185
+ this.aborts = new AbortController();
133
186
  this.ui = { ...ui, productName };
134
187
  this.endpoint = options.endpoint;
135
- this.lockAudioAndMidi = (_g = options.lockAudioAndMidi) != null ? _g : true;
188
+ this.host = host;
189
+ this.lockAudioAndMidi = (_d = options.lockAudioAndMidi) != null ? _d : true;
190
+ this.previousLicenseFiles = (_e = options.previousLicenseFiles) != null ? _e : [];
191
+ const warn = (_g = (_f = options.log) == null ? void 0 : _f.warn) != null ? _g : (message) => console.warn(message);
192
+ this.onError = (_h = options.onError) != null ? _h : (failure) => warn(`moonbase: ${failure.action} failed: ${failure.message}`);
136
193
  this.subscribe((state) => this.afterStateChange(state));
137
194
  }
138
195
  /**
139
196
  * Validate the stored license, start watching it, and bring the overlay up
140
- * when the plugin has no license. Call once per plugin instance.
197
+ * when the plugin has no license. Call once per plugin instance; a disposed
198
+ * instance can't start again.
141
199
  */
142
200
  start() {
201
+ if (this.disposed)
202
+ throw new import_licensing.ActivationError("internal", "This Moonbase instance was disposed: create a new one");
203
+ if (this.hasStarted)
204
+ return;
205
+ this.hasStarted = true;
206
+ this.importPreviousLicense();
207
+ if (this.lockAudioAndMidi)
208
+ this.gate(false);
209
+ if (this.host.onFocusChange)
210
+ this.stopFocus = this.host.onFocusChange((focused) => this.onFocusChanged(focused));
143
211
  super.start();
144
212
  this.device().then((device) => {
145
213
  this.name = device.name;
146
214
  }, () => {
147
215
  });
148
216
  }
217
+ /**
218
+ * Stop watching the license and stop telling the overlay anything. For tests
219
+ * and development reloads: a plugin does not need it. Safe to call twice;
220
+ * afterwards the overlay calls do nothing and {@link start} throws.
221
+ */
222
+ dispose() {
223
+ var _a;
224
+ if (this.disposed)
225
+ return;
226
+ this.disposed = true;
227
+ this.uiListeners.clear();
228
+ (_a = this.stopFocus) == null ? void 0 : _a.call(this);
229
+ this.stopFocus = null;
230
+ this.aborts.abort();
231
+ super.dispose();
232
+ }
233
+ /** When the license file is missing, take the one an earlier version kept. */
234
+ importPreviousLicense() {
235
+ if (import_node_fs2.default.existsSync(this.licenseFile))
236
+ return;
237
+ const previous = this.previousLicenseFiles.find((file) => import_node_path2.default.resolve(file) !== import_node_path2.default.resolve(this.licenseFile) && import_node_fs2.default.existsSync(file));
238
+ if (!previous)
239
+ return;
240
+ try {
241
+ import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(this.licenseFile), { recursive: true });
242
+ import_node_fs2.default.copyFileSync(previous, this.licenseFile);
243
+ } catch (err) {
244
+ this.reportError("previousLicense", err);
245
+ }
246
+ }
247
+ /**
248
+ * Hand a failure to `onError`: the overlay does with every action that
249
+ * fails, and the module with the host's.
250
+ */
251
+ reportError(action, error) {
252
+ var _a;
253
+ if (this.disposed)
254
+ return;
255
+ const message = error instanceof Error ? error.message : (_a = error == null ? void 0 : error.message) != null ? _a : String(error);
256
+ const kind = error == null ? void 0 : error.kind;
257
+ this.onError({ action, kind: typeof kind === "string" ? kind : errorKind(error), message, error });
258
+ }
259
+ /** A report for support: versions, where the license is kept and what the host can do, but nothing personal. */
260
+ diagnostics() {
261
+ const state = this.state();
262
+ const home = import_node_os.default.homedir();
263
+ return {
264
+ module: version,
265
+ licensing: import_licensing.licensingVersion,
266
+ platform: `${import_node_process.default.platform}-${import_node_process.default.arch}`,
267
+ licenseFile: home && this.licenseFile.startsWith(home) ? `~${this.licenseFile.slice(home.length)}` : this.licenseFile,
268
+ status: state.status,
269
+ licensed: state.licensed,
270
+ host: { gorillaEngine: !!runtime(), fileDialog: !!this.host.chooseFile, audioAndMidi: !!this.host.setAudioAndMidi, focus: !!this.host.onFocusChange },
271
+ audioAndMidi: { gated: this.lockAudioAndMidi, enabled: this.gated },
272
+ overlayVisible: this.uiState.visible
273
+ };
274
+ }
149
275
  /** This computer's name, as the activation screen shows it. */
150
276
  get deviceName() {
151
277
  return this.name;
@@ -156,29 +282,30 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
156
282
  }
157
283
  /** Called whenever {@link uiSnapshot} changes. Returns a function that stops it. */
158
284
  subscribeUi(listener) {
285
+ if (this.disposed)
286
+ return () => {
287
+ };
159
288
  this.uiListeners.add(listener);
160
289
  return () => this.uiListeners.delete(listener);
161
290
  }
162
291
  setUi(next) {
292
+ if (this.disposed)
293
+ return;
163
294
  this.uiState = { ...this.uiState, ...next };
164
295
  for (const listener of [...this.uiListeners])
165
296
  listener();
166
297
  }
167
298
  afterStateChange(state) {
168
- var _a, _b, _c, _d;
299
+ var _a, _b;
169
300
  if (state.status === "loading")
170
301
  return;
171
- if (this.lockAudioAndMidi && this.gated !== state.licensed) {
172
- this.gated = state.licensed;
173
- const ge = runtime();
174
- (_a = ge == null ? void 0 : ge.getPluginMM) == null ? void 0 : _a.call(ge, state.licensed);
175
- (_b = ge == null ? void 0 : ge.getPluginAE) == null ? void 0 : _b.call(ge, state.licensed);
176
- }
302
+ if (this.lockAudioAndMidi)
303
+ this.gate(state.licensed);
177
304
  const previous = this.lastLicensed;
178
305
  this.lastLicensed = state.licensed;
179
- if (!state.licensed && previous !== false && ((_c = this.ui.autoPresentOnLock) != null ? _c : true)) {
306
+ if (!state.licensed && previous !== false && ((_a = this.ui.autoPresentOnLock) != null ? _a : true)) {
180
307
  this.present();
181
- } else if (previous === null && state.licensed && ((_d = this.ui.autoPresentUpdate) != null ? _d : true) && state.update) {
308
+ } else if (previous === null && state.licensed && ((_b = this.ui.autoPresentUpdate) != null ? _b : true) && state.update) {
182
309
  const latest = state.update.latestVersion;
183
310
  void this.isUpdateSkipped(latest).then((skipped) => {
184
311
  if (!skipped)
@@ -186,6 +313,25 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
186
313
  });
187
314
  }
188
315
  }
316
+ /** Turn MIDI and audio on or off, saying so when the host can't. */
317
+ gate(enabled) {
318
+ if (this.gated === enabled)
319
+ return;
320
+ const set = this.host.setAudioAndMidi;
321
+ if (!set) {
322
+ if (!this.gateMissingReported) {
323
+ this.gateMissingReported = true;
324
+ this.reportError("audioAndMidi", new import_licensing.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."));
325
+ }
326
+ return;
327
+ }
328
+ try {
329
+ set(enabled);
330
+ this.gated = enabled;
331
+ } catch (err) {
332
+ this.reportError("audioAndMidi", err);
333
+ }
334
+ }
189
335
  /**
190
336
  * Show the activation overlay, optionally on a particular screen. Without one
191
337
  * it shows whatever the license state calls for.
@@ -200,25 +346,14 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
200
346
  }
201
347
  /** Copy text to the clipboard, for the activation link and the license id. */
202
348
  async copyText(text2) {
203
- if (import_node_process.default.platform === "darwin")
204
- await run("pbcopy", [], text2);
205
- else if (import_node_process.default.platform === "win32")
206
- await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "$input | Set-Clipboard"], text2);
207
- else
208
- await run("xclip", ["-selection", "clipboard"], text2);
349
+ await this.host.copyText(text2);
209
350
  }
210
351
  /** Show a file in the file manager. */
211
352
  async reveal(file) {
212
- if (import_node_process.default.platform === "darwin")
213
- await run("open", ["-R", file]);
214
- else if (import_node_process.default.platform === "win32")
215
- await run("explorer.exe", [`/select,${file}`]).catch(() => {
216
- });
217
- else
218
- await run("xdg-open", [import_node_path2.default.dirname(file)]);
353
+ await this.host.reveal(file);
219
354
  }
220
355
  downloadsFolder() {
221
- return import_node_path2.default.join(import_node_os.default.homedir(), "Downloads");
356
+ return this.host.downloadsFolder();
222
357
  }
223
358
  /**
224
359
  * Save the machine file for offline activation: through Gorilla Engine's save
@@ -226,10 +361,10 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
226
361
  * cancels.
227
362
  */
228
363
  async saveMachineFile() {
229
- var _a, _b;
364
+ var _a;
230
365
  const token = await this.deviceToken();
231
366
  const name = `${fileSafe((_a = this.ui.productName) != null ? _a : "license")}.dt`;
232
- const chooser = (_b = runtime()) == null ? void 0 : _b.openFileChooser;
367
+ const chooser = this.host.chooseFile;
233
368
  if (chooser) {
234
369
  const picked = await chooser({ saveDialog: true, warnOnOverwrite: true, hint: "Save machine file", allowedExtensions: "*.dt", defaultLocation: import_node_path2.default.join(this.downloadsFolder(), name) });
235
370
  const file2 = picked == null ? void 0 : picked[0];
@@ -246,8 +381,7 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
246
381
  }
247
382
  /** Pick the license file the customer got back for offline activation. Null when they cancel. */
248
383
  async chooseLicenseFile() {
249
- var _a;
250
- const chooser = (_a = runtime()) == null ? void 0 : _a.openFileChooser;
384
+ const chooser = this.host.chooseFile;
251
385
  if (!chooser)
252
386
  throw new import_licensing.ActivationError("internal", "This plugin can't open a file dialog");
253
387
  const picked = await chooser({ hint: "Choose your license file", allowedExtensions: "*.mb;*.jwt;*.txt;*.lic" });
@@ -270,7 +404,8 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
270
404
  try {
271
405
  const file = await this.downloadInstaller({
272
406
  directory: this.downloadsFolder(),
273
- onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) })
407
+ onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) }),
408
+ fetch: (url) => fetch(url, { signal: this.aborts.signal })
274
409
  });
275
410
  this.downloaded = file;
276
411
  await this.reveal(file).catch(() => {
@@ -304,11 +439,7 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
304
439
  const pending = ((_a = this.state().activation) == null ? void 0 : _a.browserUrl) === url;
305
440
  if (!sameOrigin && !pending && url !== "https://moonbase.sh")
306
441
  throw new import_licensing.ActivationError("internal", "That link can't be opened from here");
307
- const ge = runtime();
308
- if (ge == null ? void 0 : ge.openURLinBrowser)
309
- ge.openURLinBrowser(url);
310
- else
311
- openWithSystem(url);
442
+ await this.host.openUrl(url);
312
443
  }
313
444
  };
314
445
  function createMoonbase(options) {
@@ -317,7 +448,7 @@ function createMoonbase(options) {
317
448
 
318
449
  // src/MoonbaseActivation.ts
319
450
  var import_node_process2 = __toESM(require("process"), 1);
320
- var React2 = __toESM(require("react"), 1);
451
+ var React3 = __toESM(require("react"), 1);
321
452
 
322
453
  // src/copy.ts
323
454
  var DAY = 864e5;
@@ -471,8 +602,111 @@ function describeAddOn(entry, license, state) {
471
602
  }
472
603
 
473
604
  // src/elements.ts
605
+ var React2 = __toESM(require("react"), 1);
606
+
607
+ // src/motion.ts
474
608
  var React = __toESM(require("react"), 1);
475
- var h = React.createElement;
609
+ var FRAME = 16;
610
+ function cubicBezier(x1, y1, x2, y2) {
611
+ const at = (a, b, t) => ((1 - 3 * b + 3 * a) * t + (3 * b - 6 * a)) * t * t + 3 * a * t;
612
+ const slope = (a, b, t) => 3 * (1 - 3 * b + 3 * a) * t * t + 2 * (3 * b - 6 * a) * t + 3 * a;
613
+ return (x) => {
614
+ if (x <= 0)
615
+ return 0;
616
+ if (x >= 1)
617
+ return 1;
618
+ let t = x;
619
+ for (let i = 0; i < 8; i++) {
620
+ const error = at(x1, x2, t) - x;
621
+ if (Math.abs(error) < 1e-6)
622
+ return at(y1, y2, t);
623
+ const d = slope(x1, x2, t);
624
+ if (Math.abs(d) < 1e-6)
625
+ break;
626
+ t -= error / d;
627
+ }
628
+ let low = 0;
629
+ let high = 1;
630
+ t = x;
631
+ for (let i = 0; i < 30 && high - low > 1e-6; i++) {
632
+ if (at(x1, x2, t) < x)
633
+ low = t;
634
+ else
635
+ high = t;
636
+ t = (low + high) / 2;
637
+ }
638
+ return at(y1, y2, t);
639
+ };
640
+ }
641
+ var EASE = cubicBezier(0.22, 1, 0.36, 1);
642
+ var EASE_CSS = cubicBezier(0.25, 0.1, 0.25, 1);
643
+ function same(a, b) {
644
+ return a.length === b.length && a.every((value, index) => value === b[index]);
645
+ }
646
+ function useTween(channels, still = false, initial) {
647
+ const targets = channels.map((channel) => channel.to);
648
+ const [values, setValues] = React.useState(() => initial != null ? initial : targets);
649
+ const latest = React.useRef(values);
650
+ latest.current = values;
651
+ const spec = React.useRef(channels);
652
+ spec.current = channels;
653
+ const key = targets.join(",");
654
+ React.useEffect(() => {
655
+ const from = latest.current;
656
+ const to = spec.current.map((channel) => channel.to);
657
+ if (still || same(from, to)) {
658
+ if (!same(from, to))
659
+ setValues(to);
660
+ return;
661
+ }
662
+ const timing = spec.current;
663
+ const start = Date.now();
664
+ let timer;
665
+ const step = () => {
666
+ const elapsed = Date.now() - start;
667
+ let running = false;
668
+ setValues(to.map((target, index) => {
669
+ const { duration, ease } = timing[index];
670
+ const t = duration > 0 ? Math.min(1, elapsed / duration) : 1;
671
+ if (t < 1)
672
+ running = true;
673
+ return t >= 1 ? target : from[index] + (target - from[index]) * ease(t);
674
+ }));
675
+ if (running)
676
+ timer = setTimeout(step, FRAME);
677
+ };
678
+ timer = setTimeout(step, FRAME);
679
+ return () => clearTimeout(timer);
680
+ }, [key, still]);
681
+ return still ? targets : values;
682
+ }
683
+ function useEntrance(key, duration, still = false) {
684
+ const [shown, setShown] = React.useState(() => ({ key, progress: still ? 1 : 0 }));
685
+ if (shown.key !== key)
686
+ setShown({ key, progress: still ? 1 : 0 });
687
+ React.useEffect(() => {
688
+ if (still) {
689
+ setShown((current) => current.progress === 1 ? current : { key, progress: 1 });
690
+ return;
691
+ }
692
+ const start = Date.now();
693
+ let timer;
694
+ const step = () => {
695
+ const progress = Math.min(1, (Date.now() - start) / duration);
696
+ setShown({ key, progress });
697
+ if (progress < 1)
698
+ timer = setTimeout(step, FRAME);
699
+ };
700
+ timer = setTimeout(step, FRAME);
701
+ return () => clearTimeout(timer);
702
+ }, [key, still]);
703
+ if (still)
704
+ return 1;
705
+ return shown.key === key ? shown.progress : 0;
706
+ }
707
+
708
+ // src/elements.ts
709
+ var h = React2.createElement;
476
710
  function color(hex, alpha = 1) {
477
711
  let value = hex.trim().replace(/^#/, "");
478
712
  if (value.length === 3)
@@ -539,10 +773,11 @@ function textHeight(text2, size, width, lineHeight = 1.5) {
539
773
  }
540
774
  return Math.ceil(lines * size * lineHeight);
541
775
  }
542
- var keys = 0;
543
776
  function label(props, ...children) {
544
- var _a;
545
- return h("geLabel", { key: (_a = props.key) != null ? _a : `mb-${keys++}`, interceptsMouseClicks: false, ...props }, ...children);
777
+ return h("geLabel", { interceptsMouseClicks: false, ...props }, ...children);
778
+ }
779
+ function each(node) {
780
+ return Array.isArray(node) ? node : [node];
546
781
  }
547
782
  function text(theme, value, x, y, width, options = {}) {
548
783
  var _a, _b, _c, _d, _e, _f;
@@ -569,12 +804,12 @@ function space(height) {
569
804
  function stack(blocks, x, y, width) {
570
805
  const nodes = [];
571
806
  let top = y;
572
- for (const block of blocks) {
807
+ blocks.forEach((block, index) => {
573
808
  if (!block)
574
- continue;
575
- nodes.push(block.render(x, top, width));
809
+ return;
810
+ nodes.push(h(React2.Fragment, { key: index }, ...each(block.render(x, top, width))));
576
811
  top += block.height;
577
- }
812
+ });
578
813
  return { nodes, height: top - y };
579
814
  }
580
815
  function paragraph(theme, value, width, options = {}) {
@@ -595,7 +830,7 @@ function heading(theme, value, width, options = {}) {
595
830
  }
596
831
  function Button(props) {
597
832
  var _a, _b, _c;
598
- const [hovered, setHovered] = React.useState(false);
833
+ const [hovered, setHovered] = React2.useState(false);
599
834
  const kind = (_a = props.kind) != null ? _a : "primary";
600
835
  const accent = props.theme.accent;
601
836
  const looks = {
@@ -647,7 +882,7 @@ function buttonBlock(theme, value, onClick, options = {}) {
647
882
  }
648
883
  function Link(props) {
649
884
  var _a, _b;
650
- const [hovered, setHovered] = React.useState(false);
885
+ const [hovered, setHovered] = React2.useState(false);
651
886
  const size = (_a = props.size) != null ? _a : 12.5;
652
887
  const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
653
888
  const base = props.link ? palette.link : palette.textSecondary;
@@ -685,7 +920,7 @@ function linksBlock(theme, links, options = {}) {
685
920
  height: marginTop + Math.ceil(size * 1.6),
686
921
  render: (x, y, width) => {
687
922
  const widths = items.map((item) => textWidth(item.label, size, 500) + 12);
688
- const total = widths.reduce((sum, each) => sum + each, 0) + gap * (items.length - 1);
923
+ const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
689
924
  let left = options.align === "left" ? x : x + (width - total) / 2;
690
925
  return items.map((item, index) => {
691
926
  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 });
@@ -759,13 +994,118 @@ function barBlock(fraction, fill, options = {}) {
759
994
  };
760
995
  }
761
996
  function useTick(interval) {
762
- const [tick, setTick] = React.useState(0);
763
- React.useEffect(() => {
997
+ const [tick, setTick] = React2.useState(0);
998
+ React2.useEffect(() => {
999
+ if (interval === null)
1000
+ return;
764
1001
  const timer = setInterval(() => setTick((value) => value + 1), interval);
765
1002
  return () => clearInterval(timer);
766
1003
  }, [interval]);
767
1004
  return tick;
768
1005
  }
1006
+ var GLOW_STOPS = [
1007
+ [0, [24, 108, 220, 0]],
1008
+ [0.3, [24, 108, 220, 0.9]],
1009
+ [0.5, [130, 206, 241, 1]],
1010
+ [0.7, [24, 108, 220, 0.9]],
1011
+ [1, [24, 108, 220, 0]]
1012
+ ];
1013
+ function glowAt(at) {
1014
+ let index = 1;
1015
+ while (index < GLOW_STOPS.length - 1 && GLOW_STOPS[index][0] < at)
1016
+ index++;
1017
+ const [fromAt, from] = GLOW_STOPS[index - 1];
1018
+ const [toAt, to] = GLOW_STOPS[index];
1019
+ const f = Math.max(0, Math.min(1, (at - fromAt) / (toAt - fromAt)));
1020
+ const alpha = from[3] + (to[3] - from[3]) * f;
1021
+ const channel = (i) => {
1022
+ if (alpha <= 0)
1023
+ return from[i];
1024
+ const premultiplied = from[i] * from[3] + (to[i] * to[3] - from[i] * from[3]) * f;
1025
+ return Math.round(premultiplied / alpha);
1026
+ };
1027
+ const hex = [channel(0), channel(1), channel(2)].map((value) => value.toString(16).padStart(2, "0")).join("");
1028
+ return { hex, alpha };
1029
+ }
1030
+ function glowStrips(width) {
1031
+ const count = Math.max(1, Math.round(width / 5));
1032
+ const edge = (index) => Math.round(index * width / count);
1033
+ return Array.from({ length: count }, (_, index) => {
1034
+ const x = edge(index);
1035
+ const stripWidth = edge(index + 1) - x;
1036
+ const { hex, alpha } = glowAt((x + stripWidth / 2) / width);
1037
+ return label({ key: `glow-${index}`, x, y: 0, width: stripWidth, height: 1, backgroundColor: color(hex, alpha) });
1038
+ });
1039
+ }
1040
+ var Glow = React2.memo((props) => {
1041
+ useTick(props.still ? null : 100);
1042
+ const width = Math.round(props.width * 0.64);
1043
+ const strips = React2.useMemo(() => glowStrips(width), [width]);
1044
+ const alpha = props.still ? 1 : 0.925 - 0.075 * Math.cos(2 * Math.PI * (Date.now() % 5e3) / 5e3);
1045
+ return label({ x: Math.round(props.width * 0.18), y: 0, width, height: 1, alpha }, ...strips);
1046
+ });
1047
+ var CHECK_PATH = [[4.5, 12.75], [10.5, 18.75], [19.5, 5.25]];
1048
+ var CHECK_BOX = 34;
1049
+ var CHECK_STROKE = 4;
1050
+ var CHECK_CIRCLE = 66;
1051
+ var CHECK_ROOM = 3;
1052
+ var CHECK_DOTS = (() => {
1053
+ const scale = CHECK_BOX / 24;
1054
+ const dots = [];
1055
+ const seen = /* @__PURE__ */ new Set();
1056
+ let travelled = 0;
1057
+ for (let index = 1; index < CHECK_PATH.length; index++) {
1058
+ const [x0, y0] = CHECK_PATH[index - 1].map((value) => value * scale);
1059
+ const [x1, y1] = CHECK_PATH[index].map((value) => value * scale);
1060
+ const length = Math.hypot(x1 - x0, y1 - y0);
1061
+ const steps = Math.ceil(length / 0.5);
1062
+ for (let step = 0; step <= steps; step++) {
1063
+ const f = step / steps;
1064
+ const x = Math.round(x0 + (x1 - x0) * f - CHECK_STROKE / 2);
1065
+ const y = Math.round(y0 + (y1 - y0) * f - CHECK_STROKE / 2);
1066
+ if (!seen.has(`${x},${y}`)) {
1067
+ seen.add(`${x},${y}`);
1068
+ dots.push({ x, y, at: travelled + length * f });
1069
+ }
1070
+ }
1071
+ travelled += length;
1072
+ }
1073
+ return dots;
1074
+ })();
1075
+ var CHECK_LENGTH = CHECK_DOTS[CHECK_DOTS.length - 1].at;
1076
+ function SuccessCheck(props) {
1077
+ const elapsed = useEntrance("check", 700, props.still) * 700;
1078
+ const pop = Math.min(1, elapsed / 500);
1079
+ const scale = pop < 0.6 ? 0.4 + 0.68 * EASE(pop / 0.6) : 1.08 - 0.08 * EASE((pop - 0.6) / 0.4);
1080
+ const diameter = Math.round(CHECK_CIRCLE * scale);
1081
+ const drawn = Math.min(CHECK_LENGTH, 30 * (CHECK_BOX / 24) * EASE_CSS(Math.max(0, Math.min(1, (elapsed - 200) / 500))));
1082
+ const middle = CHECK_CIRCLE / 2 + CHECK_ROOM;
1083
+ 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({
1084
+ key: "circle",
1085
+ x: Math.round(middle - diameter / 2),
1086
+ y: Math.round(middle - diameter / 2),
1087
+ width: diameter,
1088
+ height: diameter,
1089
+ cornerRadius: diameter / 2,
1090
+ backgroundColor: color(palette.successDeep, 0.14),
1091
+ border: { width: 1, color: color(palette.successDeep, 0.35) },
1092
+ alpha: EASE(pop)
1093
+ }), label({
1094
+ key: "tick",
1095
+ x: middle - CHECK_BOX / 2,
1096
+ y: middle - CHECK_BOX / 2,
1097
+ width: CHECK_BOX,
1098
+ height: CHECK_BOX
1099
+ }, ...CHECK_DOTS.filter((dot) => drawn > 0 && dot.at <= drawn).map((dot, index) => label({
1100
+ key: `dot-${index}`,
1101
+ x: dot.x,
1102
+ y: dot.y,
1103
+ width: CHECK_STROKE,
1104
+ height: CHECK_STROKE,
1105
+ cornerRadius: CHECK_STROKE / 2,
1106
+ backgroundColor: color(palette.success)
1107
+ }))));
1108
+ }
769
1109
  function Spinner(props) {
770
1110
  const tick = useTick(90);
771
1111
  const dots = 10;
@@ -820,16 +1160,16 @@ var PAD_X = 40;
820
1160
  var PAD_TOP = 34;
821
1161
  var PAD_BOTTOM = 22;
822
1162
  function useMoonbaseState(moonbase) {
823
- const [state, setState] = React2.useState(() => moonbase.state());
824
- React2.useEffect(() => {
1163
+ const [state, setState] = React3.useState(() => moonbase.state());
1164
+ React3.useEffect(() => {
825
1165
  setState(moonbase.state());
826
1166
  return moonbase.subscribe(setState);
827
1167
  }, [moonbase]);
828
1168
  return state;
829
1169
  }
830
1170
  function useUiState(moonbase) {
831
- const [ui, setUi] = React2.useState(() => moonbase.uiSnapshot());
832
- React2.useEffect(() => {
1171
+ const [ui, setUi] = React3.useState(() => moonbase.uiSnapshot());
1172
+ React3.useEffect(() => {
833
1173
  setUi(moonbase.uiSnapshot());
834
1174
  return moonbase.subscribeUi(() => setUi(moonbase.uiSnapshot()));
835
1175
  }, [moonbase]);
@@ -870,15 +1210,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
870
1210
  const strings = (_d = ui.strings) != null ? _d : {};
871
1211
  const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
872
1212
  const width = cardWidth - PAD_X * 2;
873
- const [view, setView] = React2.useState(null);
874
- const [update, setUpdate] = React2.useState(null);
875
- const [cameFromDetails, setCameFromDetails] = React2.useState(false);
876
- const [offline, setOffline] = React2.useState({ saved: null, file: null, busy: false, error: "" });
877
- const [copied, setCopied] = React2.useState(null);
878
- const previous = React2.useRef(null);
879
- const run2 = (action) => {
880
- action().catch(() => {
881
- });
1213
+ const still = !!ui.reduceMotion;
1214
+ const [view, setView] = React3.useState(null);
1215
+ const [update, setUpdate] = React3.useState(null);
1216
+ const [cameFromDetails, setCameFromDetails] = React3.useState(false);
1217
+ const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
1218
+ const [copied, setCopied] = React3.useState(null);
1219
+ const previous = React3.useRef(null);
1220
+ const run2 = (name2, action) => {
1221
+ action().catch((err) => moonbase.reportError(name2, err));
882
1222
  };
883
1223
  const close = () => moonbase.closeUi();
884
1224
  const canClose = state.status !== "activating" && state.status !== "loading" && state.licensed;
@@ -891,7 +1231,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
891
1231
  if (next === "update")
892
1232
  loadUpdate();
893
1233
  if (next === "addons")
894
- run2(() => moonbase.loadAddOns());
1234
+ run2("loadAddOns", () => moonbase.loadAddOns());
895
1235
  };
896
1236
  const openUpdate = (fromDetails) => {
897
1237
  setCameFromDetails(fromDetails);
@@ -901,7 +1241,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
901
1241
  setCopied(what);
902
1242
  setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
903
1243
  };
904
- React2.useEffect(() => {
1244
+ React3.useEffect(() => {
905
1245
  if (screen === "update")
906
1246
  return openUpdate(false);
907
1247
  let next = screen === "license" ? "details" : screen;
@@ -909,7 +1249,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
909
1249
  next = null;
910
1250
  go(next);
911
1251
  }, [request]);
912
- React2.useEffect(() => {
1252
+ React3.useEffect(() => {
913
1253
  var _a2;
914
1254
  const before = previous.current;
915
1255
  previous.current = state;
@@ -926,7 +1266,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
926
1266
  if (next === "success" && !state.license)
927
1267
  next = null;
928
1268
  if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
929
- run2(() => moonbase.loadAddOns());
1269
+ run2("loadAddOns", () => moonbase.loadAddOns());
930
1270
  if (next !== view)
931
1271
  setView(next);
932
1272
  }, [state]);
@@ -943,10 +1283,10 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
943
1283
  render: (x, y, available) => {
944
1284
  const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
945
1285
  let right = x + available - (canClose ? 40 : 0);
946
- for (const each of [...pills].reverse()) {
947
- const drawn = pill(theme, each.tone, each.text, 0, 0, each.onClick);
1286
+ for (const each2 of [...pills].reverse()) {
1287
+ const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
948
1288
  right -= drawn.width;
949
- nodes.push(pill(theme, each.tone, each.text, right, y + 5, each.onClick).node);
1289
+ nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
950
1290
  right -= 8;
951
1291
  }
952
1292
  return nodes;
@@ -981,7 +1321,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
981
1321
  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 })))
982
1322
  };
983
1323
  };
984
- const unlock = () => buttonBlock(theme, "Unlock full version", () => run2(() => moonbase.activate()));
1324
+ const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()));
985
1325
  const screens = {
986
1326
  loading: () => [
987
1327
  { height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
@@ -999,7 +1339,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
999
1339
  space(8),
1000
1340
  paragraph(theme, body, width, { maxWidth: 430 }),
1001
1341
  space(28),
1002
- buttonBlock(theme, strings.activateOnline || "Activate online", () => run2(() => moonbase.activate()), { width: 340, height: 44 }),
1342
+ buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
1003
1343
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1004
1344
  linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
1005
1345
  ];
@@ -1017,8 +1357,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1017
1357
  const copyLink = () => {
1018
1358
  if (!url)
1019
1359
  return;
1020
- moonbase.copyText(url).then(() => flashCopied(url), () => {
1021
- });
1360
+ moonbase.copyText(url).then(() => flashCopied(url), (err) => moonbase.reportError("copyText", err));
1022
1361
  };
1023
1362
  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.`;
1024
1363
  return [
@@ -1040,7 +1379,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1040
1379
  },
1041
1380
  buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
1042
1381
  !!url && !failed && linksBlock(theme, [
1043
- { label: "Open the page again", onClick: () => run2(() => moonbase.openLink(url)) },
1382
+ { label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
1044
1383
  { label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
1045
1384
  ]),
1046
1385
  errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
@@ -1054,7 +1393,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1054
1393
  return [
1055
1394
  {
1056
1395
  height: 66 + 6,
1057
- 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" }))
1396
+ render: (x, y, available) => h(SuccessCheck, { key: "check", x: Math.round(x + available / 2 - 33), y: y + 6, still })
1058
1397
  },
1059
1398
  space(22),
1060
1399
  heading(theme, license.trial ? "Your trial has started" : "You're all set", width, { align: "center" }),
@@ -1079,13 +1418,19 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1079
1418
  setOffline((current) => ({ ...current, error: "" }));
1080
1419
  moonbase.saveMachineFile().then(
1081
1420
  (saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
1082
- (err) => setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }))
1421
+ (err) => {
1422
+ moonbase.reportError("saveMachineFile", err);
1423
+ setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }));
1424
+ }
1083
1425
  );
1084
1426
  };
1085
1427
  const useFile = (pick) => {
1086
1428
  pick.then(
1087
1429
  (file) => file && setOffline((current) => ({ ...current, file, error: "" })),
1088
- () => setOffline((current) => ({ ...current, error: "Couldn't read that file." }))
1430
+ (err) => {
1431
+ moonbase.reportError("readLicenseFile", err);
1432
+ setOffline((current) => ({ ...current, error: "Couldn't read that file." }));
1433
+ }
1089
1434
  );
1090
1435
  };
1091
1436
  const activateOffline = () => {
@@ -1191,9 +1536,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1191
1536
  paragraph(theme, body, width),
1192
1537
  space(22),
1193
1538
  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"),
1194
- buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())),
1539
+ buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
1195
1540
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1196
- 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()) }])
1541
+ 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()) }])
1197
1542
  ];
1198
1543
  },
1199
1544
  details: () => {
@@ -1219,8 +1564,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1219
1564
  ]),
1220
1565
  {
1221
1566
  height: (rows.length + 1) * rowHeight + 2 + 18,
1222
- 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), () => {
1223
- }) })))
1567
+ 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)) })))
1224
1568
  },
1225
1569
  {
1226
1570
  height: 64 + 22,
@@ -1234,7 +1578,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1234
1578
  kind: "danger",
1235
1579
  disabled: state.busy,
1236
1580
  label: state.busy ? "Deactivating\u2026" : license.trial || license.activationMethod === "Offline" ? "Remove from this device" : "Deactivate this device",
1237
- onClick: () => run2(() => moonbase.deactivate())
1581
+ onClick: () => run2("deactivate", () => moonbase.deactivate())
1238
1582
  }))
1239
1583
  },
1240
1584
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
@@ -1286,7 +1630,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1286
1630
  label: loading ? "Checking\u2026" : failed ? "Try again" : "Bought an add-on? Refresh",
1287
1631
  link: true,
1288
1632
  disabled: loading || waiting,
1289
- onClick: () => run2(() => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1633
+ onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1290
1634
  }], { align: "left" })
1291
1635
  ];
1292
1636
  },
@@ -1319,11 +1663,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1319
1663
  const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
1320
1664
  let action;
1321
1665
  if (download.phase === "done")
1322
- action = buttonBlock(theme, "Show in folder", () => run2(() => moonbase.revealUpdate()));
1666
+ action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
1323
1667
  else if (notCovered)
1324
- action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())) : null;
1668
+ action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
1325
1669
  else if (update.canDownload)
1326
- action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2(() => moonbase.downloadUpdate()), { disabled: downloading });
1670
+ action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
1327
1671
  else
1328
1672
  action = update.hasDownloads ? unlock() : null;
1329
1673
  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.";
@@ -1355,8 +1699,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1355
1699
  { label: "Remind me later", onClick: back },
1356
1700
  { label: "Skip this version", onClick: () => {
1357
1701
  var _a3;
1358
- moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch(() => {
1359
- }).then(back);
1702
+ moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch((err) => moonbase.reportError("skipUpdate", err)).then(back);
1360
1703
  } }
1361
1704
  ])
1362
1705
  ];
@@ -1378,7 +1721,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1378
1721
  const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
1379
1722
  const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
1380
1723
  right -= buttonWidth;
1381
- 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)) });
1724
+ 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)) });
1382
1725
  right -= 8;
1383
1726
  return node;
1384
1727
  });
@@ -1400,11 +1743,47 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1400
1743
  const cardHeight = PAD_TOP + content.height + footer + PAD_BOTTOM;
1401
1744
  const top = Math.max(12, Math.round((areaHeight - cardHeight) / 2));
1402
1745
  const left = Math.round((areaWidth - cardWidth) / 2);
1403
- 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")) }));
1746
+ return h(PanelCard, {
1747
+ key: "card",
1748
+ left,
1749
+ top,
1750
+ width: cardWidth,
1751
+ height: cardHeight,
1752
+ screen: name,
1753
+ contentHeight: content.height,
1754
+ content: content.nodes,
1755
+ closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }),
1756
+ // Kept to the card's bottom edge as it resizes.
1757
+ footer: showBadge ? (height) => {
1758
+ const divider = height - footer - PAD_BOTTOM + 30;
1759
+ return [
1760
+ label({ key: "divider", x: PAD_X, y: divider, width, height: 1, backgroundColor: color("#ffffff", 0.06) }),
1761
+ h(LinkNode, { key: "badge", theme, x: PAD_X, y: divider + 14, width, value: "Licensing secured by moonbase", center: true, muted: true, onClick: () => run2("openLink", () => moonbase.openLink("https://moonbase.sh")) })
1762
+ ];
1763
+ } : null,
1764
+ still
1765
+ });
1766
+ }
1767
+ var PanelView = React3.memo(Panel);
1768
+ function PanelCard(props) {
1769
+ var _a, _b;
1770
+ const [top, height] = useTween([
1771
+ { to: props.top, duration: 300, ease: EASE },
1772
+ { to: props.height, duration: 300, ease: EASE }
1773
+ ], props.still);
1774
+ const entered = EASE(useEntrance(props.screen, 400, props.still));
1775
+ const cardHeight = Math.round(height);
1776
+ return card(
1777
+ { x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
1778
+ h(Glow, { key: "glow", width: props.width, still: props.still }),
1779
+ label({ key: "screen", x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
1780
+ props.closeButton,
1781
+ ...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
1782
+ );
1404
1783
  }
1405
1784
  function LinkNode(props) {
1406
1785
  var _a;
1407
- const [hovered, setHovered] = React2.useState(false);
1786
+ const [hovered, setHovered] = React3.useState(false);
1408
1787
  const width = (_a = props.width) != null ? _a : textWidth(props.value, 12.5, 500) + 8;
1409
1788
  return label({
1410
1789
  x: props.x,
@@ -1446,7 +1825,12 @@ function MoonbaseActivation(props) {
1446
1825
  const { moonbase, width, height } = props;
1447
1826
  const state = useMoonbaseState(moonbase);
1448
1827
  const ui = useUiState(moonbase);
1449
- if (!ui.visible)
1828
+ const shown = ui.visible ? 1 : 0;
1829
+ const [scrim, rise] = useTween([
1830
+ { to: shown, duration: 250, ease: EASE_CSS },
1831
+ { to: shown, duration: ui.visible ? 350 : 250, ease: ui.visible ? EASE : EASE_CSS }
1832
+ ], !!moonbase.ui.reduceMotion, [0, 0]);
1833
+ if (!ui.visible && scrim === 0 && rise === 0)
1450
1834
  return null;
1451
1835
  return label({
1452
1836
  key: "moonbase-activation",
@@ -1454,7 +1838,8 @@ function MoonbaseActivation(props) {
1454
1838
  y: (_b = props.y) != null ? _b : 0,
1455
1839
  width,
1456
1840
  height,
1457
- backgroundColor: palette.scrim,
1841
+ // Never quite clear while it is there, coming or going.
1842
+ backgroundColor: color("#04060b", Math.max(1 / 255, 0.62 * scrim)),
1458
1843
  alwaysOnTop: true,
1459
1844
  // Takes every click, so the plugin underneath is locked while it is up.
1460
1845
  interceptsMouseClicks: true,
@@ -1462,13 +1847,20 @@ function MoonbaseActivation(props) {
1462
1847
  // the front, after the customer bought an add-on in the browser.
1463
1848
  onMouseEnter: () => moonbase.onFocusChanged(true),
1464
1849
  onMouseExit: () => moonbase.onFocusChanged(false)
1465
- }, h(Panel, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height }));
1850
+ }, 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 })));
1466
1851
  }
1852
+
1853
+ // src/index.ts
1854
+ var import_licensing2 = require("@moonbase.sh/licensing");
1467
1855
  // Annotate the CommonJS export names for ESM import in node:
1468
1856
  0 && (module.exports = {
1857
+ ActivationError,
1469
1858
  MoonbaseActivation,
1859
+ MoonbaseError,
1470
1860
  MoonbaseGorillaEngine,
1861
+ ReleaseNotCoveredError,
1471
1862
  createMoonbase,
1472
1863
  defaultLicenseFile,
1864
+ gorillaEngineHost,
1473
1865
  useMoonbaseState
1474
1866
  });