@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/README.md +78 -8
- package/dist/index.cjs +596 -142
- package/dist/index.d.cts +156 -12
- package/dist/index.d.ts +156 -12
- package/dist/index.js +590 -140
- package/dist/moonbase-gorilla-engine.js +801 -0
- package/package.json +7 -4
package/dist/index.cjs
CHANGED
|
@@ -28,18 +28,24 @@ 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
|
|
32
|
-
__export(
|
|
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(
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
40
44
|
|
|
41
45
|
// src/moonbase.ts
|
|
46
|
+
var import_node_buffer = require("buffer");
|
|
42
47
|
var import_node_child_process = require("child_process");
|
|
48
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
43
49
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
44
50
|
var import_node_os = __toESM(require("os"), 1);
|
|
45
51
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -47,7 +53,7 @@ var import_node_process = __toESM(require("process"), 1);
|
|
|
47
53
|
var import_licensing = require("@moonbase.sh/licensing");
|
|
48
54
|
|
|
49
55
|
// package.json
|
|
50
|
-
var version = "0.1
|
|
56
|
+
var version = "0.2.1";
|
|
51
57
|
|
|
52
58
|
// src/download.ts
|
|
53
59
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
@@ -72,25 +78,15 @@ function uniquePath(dir, name) {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
// src/mark.ts
|
|
82
|
+
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";
|
|
83
|
+
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==";
|
|
84
|
+
|
|
75
85
|
// src/moonbase.ts
|
|
76
86
|
function runtime() {
|
|
77
87
|
var _a;
|
|
78
88
|
return (_a = globalThis.GorillaEngine) != null ? _a : null;
|
|
79
89
|
}
|
|
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
90
|
function run(command, args, input) {
|
|
95
91
|
return new Promise((resolve, reject) => {
|
|
96
92
|
var _a;
|
|
@@ -104,21 +100,82 @@ function openWithSystem(url) {
|
|
|
104
100
|
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
101
|
(0, import_node_child_process.spawn)(command, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
106
102
|
}
|
|
103
|
+
function gorillaEngineHost() {
|
|
104
|
+
const ge = runtime();
|
|
105
|
+
return {
|
|
106
|
+
pluginName: () => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
return (_b = (_a = ge == null ? void 0 : ge.getPluginName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
|
|
109
|
+
},
|
|
110
|
+
manufacturerName: () => {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
return (_b = (_a = ge == null ? void 0 : ge.getManufacturerName) == null ? void 0 : _a.call(ge)) != null ? _b : "";
|
|
113
|
+
},
|
|
114
|
+
openUrl: (url) => (ge == null ? void 0 : ge.openURLinBrowser) ? ge.openURLinBrowser(url) : openWithSystem(url),
|
|
115
|
+
async copyText(text2) {
|
|
116
|
+
if (import_node_process.default.platform === "darwin")
|
|
117
|
+
await run("pbcopy", [], text2);
|
|
118
|
+
else if (import_node_process.default.platform === "win32")
|
|
119
|
+
await run("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "$input | Set-Clipboard"], text2);
|
|
120
|
+
else
|
|
121
|
+
await run("xclip", ["-selection", "clipboard"], text2);
|
|
122
|
+
},
|
|
123
|
+
chooseFile: (ge == null ? void 0 : ge.openFileChooser) && ((options) => ge.openFileChooser(options)),
|
|
124
|
+
async reveal(file) {
|
|
125
|
+
if (import_node_process.default.platform === "darwin")
|
|
126
|
+
await run("open", ["-R", file]);
|
|
127
|
+
else if (import_node_process.default.platform === "win32")
|
|
128
|
+
await run("explorer.exe", [`/select,${file}`]).catch(() => {
|
|
129
|
+
});
|
|
130
|
+
else
|
|
131
|
+
await run("xdg-open", [import_node_path2.default.dirname(file)]);
|
|
132
|
+
},
|
|
133
|
+
downloadsFolder: () => import_node_path2.default.join(import_node_os.default.homedir(), "Downloads"),
|
|
134
|
+
setAudioAndMidi: (ge == null ? void 0 : ge.getPluginMM) && ge.getPluginAE && ((enabled) => {
|
|
135
|
+
ge.getPluginMM(enabled);
|
|
136
|
+
ge.getPluginAE(enabled);
|
|
137
|
+
})
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function defaultLicenseFile(storage, host = gorillaEngineHost()) {
|
|
141
|
+
const manufacturerName = (storage == null ? void 0 : storage.manufacturer) || host.manufacturerName();
|
|
142
|
+
const pluginName = (storage == null ? void 0 : storage.plugin) || host.pluginName();
|
|
143
|
+
if (!manufacturerName && !pluginName)
|
|
144
|
+
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`.");
|
|
145
|
+
const manufacturer = fileSafe(manufacturerName || "Moonbase");
|
|
146
|
+
const plugin = fileSafe(pluginName || "Plugin");
|
|
147
|
+
let base;
|
|
148
|
+
if (import_node_process.default.platform === "darwin")
|
|
149
|
+
base = import_node_path2.default.join(import_node_os.default.homedir(), "Library", "Application Support");
|
|
150
|
+
else if (import_node_process.default.platform === "win32")
|
|
151
|
+
base = import_node_process.default.env.APPDATA || import_node_path2.default.join(import_node_os.default.homedir(), "AppData", "Roaming");
|
|
152
|
+
else
|
|
153
|
+
base = import_node_process.default.env.XDG_CONFIG_HOME || import_node_path2.default.join(import_node_os.default.homedir(), ".config");
|
|
154
|
+
return import_node_path2.default.join(base, manufacturer, plugin, "license.mb");
|
|
155
|
+
}
|
|
156
|
+
function errorKind(err) {
|
|
157
|
+
var _a;
|
|
158
|
+
if (err instanceof import_licensing.ActivationError)
|
|
159
|
+
return err.kind;
|
|
160
|
+
if (err instanceof import_licensing.MoonbaseError)
|
|
161
|
+
return (_a = err.type) != null ? _a : "internal";
|
|
162
|
+
return "internal";
|
|
163
|
+
}
|
|
164
|
+
function writeIfChanged(file, data) {
|
|
165
|
+
if (import_node_fs2.default.existsSync(file) && import_node_fs2.default.readFileSync(file).equals(data))
|
|
166
|
+
return;
|
|
167
|
+
import_node_fs2.default.writeFileSync(file, data);
|
|
168
|
+
}
|
|
107
169
|
var MoonbaseGorillaEngine = class extends import_licensing.ActivationController {
|
|
108
170
|
constructor(options) {
|
|
109
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
110
172
|
const ui = (_a = options.ui) != null ? _a : {};
|
|
111
|
-
const
|
|
173
|
+
const host = { ...gorillaEngineHost(), ...options.host, ...options.openUrl && { openUrl: options.openUrl } };
|
|
174
|
+
const productName = (_b = ui.productName) != null ? _b : host.pluginName() || "the plugin";
|
|
112
175
|
super({
|
|
113
176
|
...options,
|
|
114
|
-
licenseFile: (
|
|
115
|
-
openUrl:
|
|
116
|
-
const ge = runtime();
|
|
117
|
-
if (ge == null ? void 0 : ge.openURLinBrowser)
|
|
118
|
-
ge.openURLinBrowser(url);
|
|
119
|
-
else
|
|
120
|
-
openWithSystem(url);
|
|
121
|
-
},
|
|
177
|
+
licenseFile: (_c = options.licenseFile) != null ? _c : defaultLicenseFile(options.storage, host),
|
|
178
|
+
openUrl: host.openUrl,
|
|
122
179
|
// Ahead of the SDK's own token, so Moonbase knows the product uses this module.
|
|
123
180
|
clientInfo: [options.clientInfo, `@moonbase.sh/gorilla-engine/${version}`].filter(Boolean).join(" "),
|
|
124
181
|
productName,
|
|
@@ -128,24 +185,124 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
128
185
|
this.uiState = { visible: false, screen: null, request: 0, download: downloadState("idle") };
|
|
129
186
|
this.lastLicensed = null;
|
|
130
187
|
this.gated = null;
|
|
188
|
+
this.gateMissingReported = false;
|
|
131
189
|
this.downloaded = null;
|
|
132
190
|
this.name = "This computer";
|
|
191
|
+
this.hasStarted = false;
|
|
192
|
+
this.disposed = false;
|
|
193
|
+
this.stopFocus = null;
|
|
194
|
+
/** Aborts the update download when the instance is disposed. */
|
|
195
|
+
this.aborts = new AbortController();
|
|
133
196
|
this.ui = { ...ui, productName };
|
|
134
197
|
this.endpoint = options.endpoint;
|
|
135
|
-
this.
|
|
198
|
+
this.host = host;
|
|
199
|
+
this.lockAudioAndMidi = (_d = options.lockAudioAndMidi) != null ? _d : true;
|
|
200
|
+
this.previousLicenseFiles = (_e = options.previousLicenseFiles) != null ? _e : [];
|
|
201
|
+
const warn = (_g = (_f = options.log) == null ? void 0 : _f.warn) != null ? _g : (message) => console.warn(message);
|
|
202
|
+
this.onError = (_h = options.onError) != null ? _h : (failure) => warn(`moonbase: ${failure.action} failed: ${failure.message}`);
|
|
136
203
|
this.subscribe((state) => this.afterStateChange(state));
|
|
137
204
|
}
|
|
138
205
|
/**
|
|
139
206
|
* Validate the stored license, start watching it, and bring the overlay up
|
|
140
|
-
* when the plugin has no license. Call once per plugin instance
|
|
207
|
+
* when the plugin has no license. Call once per plugin instance; a disposed
|
|
208
|
+
* instance can't start again.
|
|
141
209
|
*/
|
|
142
210
|
start() {
|
|
211
|
+
if (this.disposed)
|
|
212
|
+
throw new import_licensing.ActivationError("internal", "This Moonbase instance was disposed: create a new one");
|
|
213
|
+
if (this.hasStarted)
|
|
214
|
+
return;
|
|
215
|
+
this.hasStarted = true;
|
|
216
|
+
this.importPreviousLicense();
|
|
217
|
+
if (this.lockAudioAndMidi)
|
|
218
|
+
this.gate(false);
|
|
219
|
+
if (this.host.onFocusChange)
|
|
220
|
+
this.stopFocus = this.host.onFocusChange((focused) => this.onFocusChanged(focused));
|
|
143
221
|
super.start();
|
|
144
222
|
this.device().then((device) => {
|
|
145
223
|
this.name = device.name;
|
|
146
224
|
}, () => {
|
|
147
225
|
});
|
|
148
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Stop watching the license and stop telling the overlay anything. For tests
|
|
229
|
+
* and development reloads: a plugin does not need it. Safe to call twice;
|
|
230
|
+
* afterwards the overlay calls do nothing and {@link start} throws.
|
|
231
|
+
*/
|
|
232
|
+
dispose() {
|
|
233
|
+
var _a;
|
|
234
|
+
if (this.disposed)
|
|
235
|
+
return;
|
|
236
|
+
this.disposed = true;
|
|
237
|
+
this.uiListeners.clear();
|
|
238
|
+
(_a = this.stopFocus) == null ? void 0 : _a.call(this);
|
|
239
|
+
this.stopFocus = null;
|
|
240
|
+
this.aborts.abort();
|
|
241
|
+
super.dispose();
|
|
242
|
+
}
|
|
243
|
+
/** When the license file is missing, take the one an earlier version kept. */
|
|
244
|
+
importPreviousLicense() {
|
|
245
|
+
if (import_node_fs2.default.existsSync(this.licenseFile))
|
|
246
|
+
return;
|
|
247
|
+
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));
|
|
248
|
+
if (!previous)
|
|
249
|
+
return;
|
|
250
|
+
try {
|
|
251
|
+
import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(this.licenseFile), { recursive: true });
|
|
252
|
+
import_node_fs2.default.copyFileSync(previous, this.licenseFile);
|
|
253
|
+
} catch (err) {
|
|
254
|
+
this.reportError("previousLicense", err);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Moonbase's mark, for the overlay's footer, as an image file: Gorilla Engine
|
|
259
|
+
* draws images from files only, and a module can't add to the plugin's assets.
|
|
260
|
+
* Written beside the license file, with its `@2x`, the first time it is asked
|
|
261
|
+
* for. Null when it can't be written, and the footer goes without it.
|
|
262
|
+
*/
|
|
263
|
+
moonbaseMark() {
|
|
264
|
+
if (this.markFile !== void 0)
|
|
265
|
+
return this.markFile;
|
|
266
|
+
const file = import_node_path2.default.join(import_node_path2.default.dirname(this.licenseFile), "moonbase-mark.png");
|
|
267
|
+
try {
|
|
268
|
+
import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
269
|
+
writeIfChanged(file, import_node_buffer.Buffer.from(MARK_PNG, "base64"));
|
|
270
|
+
writeIfChanged(file.replace(/\.png$/, "@2x.png"), import_node_buffer.Buffer.from(MARK_PNG_2X, "base64"));
|
|
271
|
+
this.markFile = file;
|
|
272
|
+
} catch (err) {
|
|
273
|
+
this.reportError("moonbaseMark", err);
|
|
274
|
+
this.markFile = null;
|
|
275
|
+
}
|
|
276
|
+
return this.markFile;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Hand a failure to `onError`: the overlay does with every action that
|
|
280
|
+
* fails, and the module with the host's.
|
|
281
|
+
*/
|
|
282
|
+
reportError(action, error) {
|
|
283
|
+
var _a;
|
|
284
|
+
if (this.disposed)
|
|
285
|
+
return;
|
|
286
|
+
const message = error instanceof Error ? error.message : (_a = error == null ? void 0 : error.message) != null ? _a : String(error);
|
|
287
|
+
const kind = error == null ? void 0 : error.kind;
|
|
288
|
+
this.onError({ action, kind: typeof kind === "string" ? kind : errorKind(error), message, error });
|
|
289
|
+
}
|
|
290
|
+
/** A report for support: versions, where the license is kept and what the host can do, but nothing personal. */
|
|
291
|
+
diagnostics() {
|
|
292
|
+
const state = this.state();
|
|
293
|
+
const home = import_node_os.default.homedir();
|
|
294
|
+
return {
|
|
295
|
+
module: version,
|
|
296
|
+
licensing: import_licensing.licensingVersion,
|
|
297
|
+
platform: `${import_node_process.default.platform}-${import_node_process.default.arch}`,
|
|
298
|
+
licenseFile: home && this.licenseFile.startsWith(home) ? `~${this.licenseFile.slice(home.length)}` : this.licenseFile,
|
|
299
|
+
status: state.status,
|
|
300
|
+
licensed: state.licensed,
|
|
301
|
+
host: { gorillaEngine: !!runtime(), fileDialog: !!this.host.chooseFile, audioAndMidi: !!this.host.setAudioAndMidi, focus: !!this.host.onFocusChange },
|
|
302
|
+
audioAndMidi: { gated: this.lockAudioAndMidi, enabled: this.gated },
|
|
303
|
+
overlayVisible: this.uiState.visible
|
|
304
|
+
};
|
|
305
|
+
}
|
|
149
306
|
/** This computer's name, as the activation screen shows it. */
|
|
150
307
|
get deviceName() {
|
|
151
308
|
return this.name;
|
|
@@ -156,29 +313,30 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
156
313
|
}
|
|
157
314
|
/** Called whenever {@link uiSnapshot} changes. Returns a function that stops it. */
|
|
158
315
|
subscribeUi(listener) {
|
|
316
|
+
if (this.disposed)
|
|
317
|
+
return () => {
|
|
318
|
+
};
|
|
159
319
|
this.uiListeners.add(listener);
|
|
160
320
|
return () => this.uiListeners.delete(listener);
|
|
161
321
|
}
|
|
162
322
|
setUi(next) {
|
|
323
|
+
if (this.disposed)
|
|
324
|
+
return;
|
|
163
325
|
this.uiState = { ...this.uiState, ...next };
|
|
164
326
|
for (const listener of [...this.uiListeners])
|
|
165
327
|
listener();
|
|
166
328
|
}
|
|
167
329
|
afterStateChange(state) {
|
|
168
|
-
var _a, _b
|
|
330
|
+
var _a, _b;
|
|
169
331
|
if (state.status === "loading")
|
|
170
332
|
return;
|
|
171
|
-
if (this.lockAudioAndMidi
|
|
172
|
-
this.
|
|
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
|
-
}
|
|
333
|
+
if (this.lockAudioAndMidi)
|
|
334
|
+
this.gate(state.licensed);
|
|
177
335
|
const previous = this.lastLicensed;
|
|
178
336
|
this.lastLicensed = state.licensed;
|
|
179
|
-
if (!state.licensed && previous !== false && ((
|
|
337
|
+
if (!state.licensed && previous !== false && ((_a = this.ui.autoPresentOnLock) != null ? _a : true)) {
|
|
180
338
|
this.present();
|
|
181
|
-
} else if (previous === null && state.licensed && ((
|
|
339
|
+
} else if (previous === null && state.licensed && ((_b = this.ui.autoPresentUpdate) != null ? _b : true) && state.update) {
|
|
182
340
|
const latest = state.update.latestVersion;
|
|
183
341
|
void this.isUpdateSkipped(latest).then((skipped) => {
|
|
184
342
|
if (!skipped)
|
|
@@ -186,6 +344,25 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
186
344
|
});
|
|
187
345
|
}
|
|
188
346
|
}
|
|
347
|
+
/** Turn MIDI and audio on or off, saying so when the host can't. */
|
|
348
|
+
gate(enabled) {
|
|
349
|
+
if (this.gated === enabled)
|
|
350
|
+
return;
|
|
351
|
+
const set = this.host.setAudioAndMidi;
|
|
352
|
+
if (!set) {
|
|
353
|
+
if (!this.gateMissingReported) {
|
|
354
|
+
this.gateMissingReported = true;
|
|
355
|
+
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."));
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
set(enabled);
|
|
361
|
+
this.gated = enabled;
|
|
362
|
+
} catch (err) {
|
|
363
|
+
this.reportError("audioAndMidi", err);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
189
366
|
/**
|
|
190
367
|
* Show the activation overlay, optionally on a particular screen. Without one
|
|
191
368
|
* it shows whatever the license state calls for.
|
|
@@ -200,25 +377,14 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
200
377
|
}
|
|
201
378
|
/** Copy text to the clipboard, for the activation link and the license id. */
|
|
202
379
|
async copyText(text2) {
|
|
203
|
-
|
|
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);
|
|
380
|
+
await this.host.copyText(text2);
|
|
209
381
|
}
|
|
210
382
|
/** Show a file in the file manager. */
|
|
211
383
|
async reveal(file) {
|
|
212
|
-
|
|
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)]);
|
|
384
|
+
await this.host.reveal(file);
|
|
219
385
|
}
|
|
220
386
|
downloadsFolder() {
|
|
221
|
-
return
|
|
387
|
+
return this.host.downloadsFolder();
|
|
222
388
|
}
|
|
223
389
|
/**
|
|
224
390
|
* Save the machine file for offline activation: through Gorilla Engine's save
|
|
@@ -226,10 +392,10 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
226
392
|
* cancels.
|
|
227
393
|
*/
|
|
228
394
|
async saveMachineFile() {
|
|
229
|
-
var _a
|
|
395
|
+
var _a;
|
|
230
396
|
const token = await this.deviceToken();
|
|
231
397
|
const name = `${fileSafe((_a = this.ui.productName) != null ? _a : "license")}.dt`;
|
|
232
|
-
const chooser =
|
|
398
|
+
const chooser = this.host.chooseFile;
|
|
233
399
|
if (chooser) {
|
|
234
400
|
const picked = await chooser({ saveDialog: true, warnOnOverwrite: true, hint: "Save machine file", allowedExtensions: "*.dt", defaultLocation: import_node_path2.default.join(this.downloadsFolder(), name) });
|
|
235
401
|
const file2 = picked == null ? void 0 : picked[0];
|
|
@@ -246,8 +412,7 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
246
412
|
}
|
|
247
413
|
/** Pick the license file the customer got back for offline activation. Null when they cancel. */
|
|
248
414
|
async chooseLicenseFile() {
|
|
249
|
-
|
|
250
|
-
const chooser = (_a = runtime()) == null ? void 0 : _a.openFileChooser;
|
|
415
|
+
const chooser = this.host.chooseFile;
|
|
251
416
|
if (!chooser)
|
|
252
417
|
throw new import_licensing.ActivationError("internal", "This plugin can't open a file dialog");
|
|
253
418
|
const picked = await chooser({ hint: "Choose your license file", allowedExtensions: "*.mb;*.jwt;*.txt;*.lic" });
|
|
@@ -270,7 +435,8 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
270
435
|
try {
|
|
271
436
|
const file = await this.downloadInstaller({
|
|
272
437
|
directory: this.downloadsFolder(),
|
|
273
|
-
onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) })
|
|
438
|
+
onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) }),
|
|
439
|
+
fetch: (url) => fetch(url, { signal: this.aborts.signal })
|
|
274
440
|
});
|
|
275
441
|
this.downloaded = file;
|
|
276
442
|
await this.reveal(file).catch(() => {
|
|
@@ -304,11 +470,7 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
304
470
|
const pending = ((_a = this.state().activation) == null ? void 0 : _a.browserUrl) === url;
|
|
305
471
|
if (!sameOrigin && !pending && url !== "https://moonbase.sh")
|
|
306
472
|
throw new import_licensing.ActivationError("internal", "That link can't be opened from here");
|
|
307
|
-
|
|
308
|
-
if (ge == null ? void 0 : ge.openURLinBrowser)
|
|
309
|
-
ge.openURLinBrowser(url);
|
|
310
|
-
else
|
|
311
|
-
openWithSystem(url);
|
|
473
|
+
await this.host.openUrl(url);
|
|
312
474
|
}
|
|
313
475
|
};
|
|
314
476
|
function createMoonbase(options) {
|
|
@@ -317,7 +479,7 @@ function createMoonbase(options) {
|
|
|
317
479
|
|
|
318
480
|
// src/MoonbaseActivation.ts
|
|
319
481
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
320
|
-
var
|
|
482
|
+
var React3 = __toESM(require("react"), 1);
|
|
321
483
|
|
|
322
484
|
// src/copy.ts
|
|
323
485
|
var DAY = 864e5;
|
|
@@ -471,8 +633,111 @@ function describeAddOn(entry, license, state) {
|
|
|
471
633
|
}
|
|
472
634
|
|
|
473
635
|
// src/elements.ts
|
|
636
|
+
var React2 = __toESM(require("react"), 1);
|
|
637
|
+
|
|
638
|
+
// src/motion.ts
|
|
474
639
|
var React = __toESM(require("react"), 1);
|
|
475
|
-
var
|
|
640
|
+
var FRAME = 16;
|
|
641
|
+
function cubicBezier(x1, y1, x2, y2) {
|
|
642
|
+
const at = (a, b, t) => ((1 - 3 * b + 3 * a) * t + (3 * b - 6 * a)) * t * t + 3 * a * t;
|
|
643
|
+
const slope = (a, b, t) => 3 * (1 - 3 * b + 3 * a) * t * t + 2 * (3 * b - 6 * a) * t + 3 * a;
|
|
644
|
+
return (x) => {
|
|
645
|
+
if (x <= 0)
|
|
646
|
+
return 0;
|
|
647
|
+
if (x >= 1)
|
|
648
|
+
return 1;
|
|
649
|
+
let t = x;
|
|
650
|
+
for (let i = 0; i < 8; i++) {
|
|
651
|
+
const error = at(x1, x2, t) - x;
|
|
652
|
+
if (Math.abs(error) < 1e-6)
|
|
653
|
+
return at(y1, y2, t);
|
|
654
|
+
const d = slope(x1, x2, t);
|
|
655
|
+
if (Math.abs(d) < 1e-6)
|
|
656
|
+
break;
|
|
657
|
+
t -= error / d;
|
|
658
|
+
}
|
|
659
|
+
let low = 0;
|
|
660
|
+
let high = 1;
|
|
661
|
+
t = x;
|
|
662
|
+
for (let i = 0; i < 30 && high - low > 1e-6; i++) {
|
|
663
|
+
if (at(x1, x2, t) < x)
|
|
664
|
+
low = t;
|
|
665
|
+
else
|
|
666
|
+
high = t;
|
|
667
|
+
t = (low + high) / 2;
|
|
668
|
+
}
|
|
669
|
+
return at(y1, y2, t);
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
var EASE = cubicBezier(0.22, 1, 0.36, 1);
|
|
673
|
+
var EASE_CSS = cubicBezier(0.25, 0.1, 0.25, 1);
|
|
674
|
+
function same(a, b) {
|
|
675
|
+
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
676
|
+
}
|
|
677
|
+
function useTween(channels, still = false, initial) {
|
|
678
|
+
const targets = channels.map((channel) => channel.to);
|
|
679
|
+
const [values, setValues] = React.useState(() => initial != null ? initial : targets);
|
|
680
|
+
const latest = React.useRef(values);
|
|
681
|
+
latest.current = values;
|
|
682
|
+
const spec = React.useRef(channels);
|
|
683
|
+
spec.current = channels;
|
|
684
|
+
const key = targets.join(",");
|
|
685
|
+
React.useEffect(() => {
|
|
686
|
+
const from = latest.current;
|
|
687
|
+
const to = spec.current.map((channel) => channel.to);
|
|
688
|
+
if (still || same(from, to)) {
|
|
689
|
+
if (!same(from, to))
|
|
690
|
+
setValues(to);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
const timing = spec.current;
|
|
694
|
+
const start = Date.now();
|
|
695
|
+
let timer;
|
|
696
|
+
const step = () => {
|
|
697
|
+
const elapsed = Date.now() - start;
|
|
698
|
+
let running = false;
|
|
699
|
+
setValues(to.map((target, index) => {
|
|
700
|
+
const { duration, ease } = timing[index];
|
|
701
|
+
const t = duration > 0 ? Math.min(1, elapsed / duration) : 1;
|
|
702
|
+
if (t < 1)
|
|
703
|
+
running = true;
|
|
704
|
+
return t >= 1 ? target : from[index] + (target - from[index]) * ease(t);
|
|
705
|
+
}));
|
|
706
|
+
if (running)
|
|
707
|
+
timer = setTimeout(step, FRAME);
|
|
708
|
+
};
|
|
709
|
+
timer = setTimeout(step, FRAME);
|
|
710
|
+
return () => clearTimeout(timer);
|
|
711
|
+
}, [key, still]);
|
|
712
|
+
return still ? targets : values;
|
|
713
|
+
}
|
|
714
|
+
function useEntrance(key, duration, still = false) {
|
|
715
|
+
const [shown, setShown] = React.useState(() => ({ key, progress: still ? 1 : 0 }));
|
|
716
|
+
if (shown.key !== key)
|
|
717
|
+
setShown({ key, progress: still ? 1 : 0 });
|
|
718
|
+
React.useEffect(() => {
|
|
719
|
+
if (still) {
|
|
720
|
+
setShown((current) => current.progress === 1 ? current : { key, progress: 1 });
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const start = Date.now();
|
|
724
|
+
let timer;
|
|
725
|
+
const step = () => {
|
|
726
|
+
const progress = Math.min(1, (Date.now() - start) / duration);
|
|
727
|
+
setShown({ key, progress });
|
|
728
|
+
if (progress < 1)
|
|
729
|
+
timer = setTimeout(step, FRAME);
|
|
730
|
+
};
|
|
731
|
+
timer = setTimeout(step, FRAME);
|
|
732
|
+
return () => clearTimeout(timer);
|
|
733
|
+
}, [key, still]);
|
|
734
|
+
if (still)
|
|
735
|
+
return 1;
|
|
736
|
+
return shown.key === key ? shown.progress : 0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/elements.ts
|
|
740
|
+
var h = React2.createElement;
|
|
476
741
|
function color(hex, alpha = 1) {
|
|
477
742
|
let value = hex.trim().replace(/^#/, "");
|
|
478
743
|
if (value.length === 3)
|
|
@@ -539,10 +804,11 @@ function textHeight(text2, size, width, lineHeight = 1.5) {
|
|
|
539
804
|
}
|
|
540
805
|
return Math.ceil(lines * size * lineHeight);
|
|
541
806
|
}
|
|
542
|
-
var keys = 0;
|
|
543
807
|
function label(props, ...children) {
|
|
544
|
-
|
|
545
|
-
|
|
808
|
+
return h("geLabel", { interceptsMouseClicks: false, ...props }, ...children);
|
|
809
|
+
}
|
|
810
|
+
function each(node) {
|
|
811
|
+
return Array.isArray(node) ? node : [node];
|
|
546
812
|
}
|
|
547
813
|
function text(theme, value, x, y, width, options = {}) {
|
|
548
814
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -569,12 +835,12 @@ function space(height) {
|
|
|
569
835
|
function stack(blocks, x, y, width) {
|
|
570
836
|
const nodes = [];
|
|
571
837
|
let top = y;
|
|
572
|
-
|
|
838
|
+
blocks.forEach((block, index) => {
|
|
573
839
|
if (!block)
|
|
574
|
-
|
|
575
|
-
nodes.push(block.render(x, top, width));
|
|
840
|
+
return;
|
|
841
|
+
nodes.push(h(React2.Fragment, { key: index }, ...each(block.render(x, top, width))));
|
|
576
842
|
top += block.height;
|
|
577
|
-
}
|
|
843
|
+
});
|
|
578
844
|
return { nodes, height: top - y };
|
|
579
845
|
}
|
|
580
846
|
function paragraph(theme, value, width, options = {}) {
|
|
@@ -595,7 +861,7 @@ function heading(theme, value, width, options = {}) {
|
|
|
595
861
|
}
|
|
596
862
|
function Button(props) {
|
|
597
863
|
var _a, _b, _c;
|
|
598
|
-
const [hovered, setHovered] =
|
|
864
|
+
const [hovered, setHovered] = React2.useState(false);
|
|
599
865
|
const kind = (_a = props.kind) != null ? _a : "primary";
|
|
600
866
|
const accent = props.theme.accent;
|
|
601
867
|
const looks = {
|
|
@@ -647,7 +913,7 @@ function buttonBlock(theme, value, onClick, options = {}) {
|
|
|
647
913
|
}
|
|
648
914
|
function Link(props) {
|
|
649
915
|
var _a, _b;
|
|
650
|
-
const [hovered, setHovered] =
|
|
916
|
+
const [hovered, setHovered] = React2.useState(false);
|
|
651
917
|
const size = (_a = props.size) != null ? _a : 12.5;
|
|
652
918
|
const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
|
|
653
919
|
const base = props.link ? palette.link : palette.textSecondary;
|
|
@@ -685,7 +951,7 @@ function linksBlock(theme, links, options = {}) {
|
|
|
685
951
|
height: marginTop + Math.ceil(size * 1.6),
|
|
686
952
|
render: (x, y, width) => {
|
|
687
953
|
const widths = items.map((item) => textWidth(item.label, size, 500) + 12);
|
|
688
|
-
const total = widths.reduce((sum,
|
|
954
|
+
const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
|
|
689
955
|
let left = options.align === "left" ? x : x + (width - total) / 2;
|
|
690
956
|
return items.map((item, index) => {
|
|
691
957
|
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 });
|
|
@@ -750,6 +1016,15 @@ function card(props, ...children) {
|
|
|
750
1016
|
...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
|
|
751
1017
|
}, ...children);
|
|
752
1018
|
}
|
|
1019
|
+
var SCROLLBAR = 6;
|
|
1020
|
+
function scrollView(props, contentHeight, ...children) {
|
|
1021
|
+
return h("geScrollView", {
|
|
1022
|
+
...props,
|
|
1023
|
+
hideHorizontalScrollbar: true,
|
|
1024
|
+
scrollbarThickness: SCROLLBAR,
|
|
1025
|
+
scrollbar: { background: palette.transparent, track: palette.transparent, thumb: color("#ffffff", 0.16) }
|
|
1026
|
+
}, label({ x: 0, y: 0, width: props.width - SCROLLBAR, height: contentHeight }, ...children));
|
|
1027
|
+
}
|
|
753
1028
|
function barBlock(fraction, fill, options = {}) {
|
|
754
1029
|
var _a, _b;
|
|
755
1030
|
const marginTop = (_a = options.marginTop) != null ? _a : 14;
|
|
@@ -759,13 +1034,118 @@ function barBlock(fraction, fill, options = {}) {
|
|
|
759
1034
|
};
|
|
760
1035
|
}
|
|
761
1036
|
function useTick(interval) {
|
|
762
|
-
const [tick, setTick] =
|
|
763
|
-
|
|
1037
|
+
const [tick, setTick] = React2.useState(0);
|
|
1038
|
+
React2.useEffect(() => {
|
|
1039
|
+
if (interval === null)
|
|
1040
|
+
return;
|
|
764
1041
|
const timer = setInterval(() => setTick((value) => value + 1), interval);
|
|
765
1042
|
return () => clearInterval(timer);
|
|
766
1043
|
}, [interval]);
|
|
767
1044
|
return tick;
|
|
768
1045
|
}
|
|
1046
|
+
var GLOW_STOPS = [
|
|
1047
|
+
[0, [24, 108, 220, 0]],
|
|
1048
|
+
[0.3, [24, 108, 220, 0.9]],
|
|
1049
|
+
[0.5, [130, 206, 241, 1]],
|
|
1050
|
+
[0.7, [24, 108, 220, 0.9]],
|
|
1051
|
+
[1, [24, 108, 220, 0]]
|
|
1052
|
+
];
|
|
1053
|
+
function glowAt(at) {
|
|
1054
|
+
let index = 1;
|
|
1055
|
+
while (index < GLOW_STOPS.length - 1 && GLOW_STOPS[index][0] < at)
|
|
1056
|
+
index++;
|
|
1057
|
+
const [fromAt, from] = GLOW_STOPS[index - 1];
|
|
1058
|
+
const [toAt, to] = GLOW_STOPS[index];
|
|
1059
|
+
const f = Math.max(0, Math.min(1, (at - fromAt) / (toAt - fromAt)));
|
|
1060
|
+
const alpha = from[3] + (to[3] - from[3]) * f;
|
|
1061
|
+
const channel = (i) => {
|
|
1062
|
+
if (alpha <= 0)
|
|
1063
|
+
return from[i];
|
|
1064
|
+
const premultiplied = from[i] * from[3] + (to[i] * to[3] - from[i] * from[3]) * f;
|
|
1065
|
+
return Math.round(premultiplied / alpha);
|
|
1066
|
+
};
|
|
1067
|
+
const hex = [channel(0), channel(1), channel(2)].map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
1068
|
+
return { hex, alpha };
|
|
1069
|
+
}
|
|
1070
|
+
function glowStrips(width) {
|
|
1071
|
+
const count = Math.max(1, Math.round(width / 5));
|
|
1072
|
+
const edge = (index) => Math.round(index * width / count);
|
|
1073
|
+
return Array.from({ length: count }, (_, index) => {
|
|
1074
|
+
const x = edge(index);
|
|
1075
|
+
const stripWidth = edge(index + 1) - x;
|
|
1076
|
+
const { hex, alpha } = glowAt((x + stripWidth / 2) / width);
|
|
1077
|
+
return label({ key: `glow-${index}`, x, y: 0, width: stripWidth, height: 1, backgroundColor: color(hex, alpha) });
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
var Glow = React2.memo((props) => {
|
|
1081
|
+
useTick(props.still ? null : 100);
|
|
1082
|
+
const width = Math.round(props.width * 0.64);
|
|
1083
|
+
const strips = React2.useMemo(() => glowStrips(width), [width]);
|
|
1084
|
+
const alpha = props.still ? 1 : 0.925 - 0.075 * Math.cos(2 * Math.PI * (Date.now() % 5e3) / 5e3);
|
|
1085
|
+
return label({ x: Math.round(props.width * 0.18), y: 0, width, height: 1, alpha }, ...strips);
|
|
1086
|
+
});
|
|
1087
|
+
var CHECK_PATH = [[4.5, 12.75], [10.5, 18.75], [19.5, 5.25]];
|
|
1088
|
+
var CHECK_BOX = 34;
|
|
1089
|
+
var CHECK_STROKE = 4;
|
|
1090
|
+
var CHECK_CIRCLE = 66;
|
|
1091
|
+
var CHECK_ROOM = 3;
|
|
1092
|
+
var CHECK_DOTS = (() => {
|
|
1093
|
+
const scale = CHECK_BOX / 24;
|
|
1094
|
+
const dots = [];
|
|
1095
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1096
|
+
let travelled = 0;
|
|
1097
|
+
for (let index = 1; index < CHECK_PATH.length; index++) {
|
|
1098
|
+
const [x0, y0] = CHECK_PATH[index - 1].map((value) => value * scale);
|
|
1099
|
+
const [x1, y1] = CHECK_PATH[index].map((value) => value * scale);
|
|
1100
|
+
const length = Math.hypot(x1 - x0, y1 - y0);
|
|
1101
|
+
const steps = Math.ceil(length / 0.5);
|
|
1102
|
+
for (let step = 0; step <= steps; step++) {
|
|
1103
|
+
const f = step / steps;
|
|
1104
|
+
const x = Math.round(x0 + (x1 - x0) * f - CHECK_STROKE / 2);
|
|
1105
|
+
const y = Math.round(y0 + (y1 - y0) * f - CHECK_STROKE / 2);
|
|
1106
|
+
if (!seen.has(`${x},${y}`)) {
|
|
1107
|
+
seen.add(`${x},${y}`);
|
|
1108
|
+
dots.push({ x, y, at: travelled + length * f });
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
travelled += length;
|
|
1112
|
+
}
|
|
1113
|
+
return dots;
|
|
1114
|
+
})();
|
|
1115
|
+
var CHECK_LENGTH = CHECK_DOTS[CHECK_DOTS.length - 1].at;
|
|
1116
|
+
function SuccessCheck(props) {
|
|
1117
|
+
const elapsed = useEntrance("check", 700, props.still) * 700;
|
|
1118
|
+
const pop = Math.min(1, elapsed / 500);
|
|
1119
|
+
const scale = pop < 0.6 ? 0.4 + 0.68 * EASE(pop / 0.6) : 1.08 - 0.08 * EASE((pop - 0.6) / 0.4);
|
|
1120
|
+
const diameter = Math.round(CHECK_CIRCLE * scale);
|
|
1121
|
+
const drawn = Math.min(CHECK_LENGTH, 30 * (CHECK_BOX / 24) * EASE_CSS(Math.max(0, Math.min(1, (elapsed - 200) / 500))));
|
|
1122
|
+
const middle = CHECK_CIRCLE / 2 + CHECK_ROOM;
|
|
1123
|
+
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({
|
|
1124
|
+
key: "circle",
|
|
1125
|
+
x: Math.round(middle - diameter / 2),
|
|
1126
|
+
y: Math.round(middle - diameter / 2),
|
|
1127
|
+
width: diameter,
|
|
1128
|
+
height: diameter,
|
|
1129
|
+
cornerRadius: diameter / 2,
|
|
1130
|
+
backgroundColor: color(palette.successDeep, 0.14),
|
|
1131
|
+
border: { width: 1, color: color(palette.successDeep, 0.35) },
|
|
1132
|
+
alpha: EASE(pop)
|
|
1133
|
+
}), label({
|
|
1134
|
+
key: "tick",
|
|
1135
|
+
x: middle - CHECK_BOX / 2,
|
|
1136
|
+
y: middle - CHECK_BOX / 2,
|
|
1137
|
+
width: CHECK_BOX,
|
|
1138
|
+
height: CHECK_BOX
|
|
1139
|
+
}, ...CHECK_DOTS.filter((dot) => drawn > 0 && dot.at <= drawn).map((dot, index) => label({
|
|
1140
|
+
key: `dot-${index}`,
|
|
1141
|
+
x: dot.x,
|
|
1142
|
+
y: dot.y,
|
|
1143
|
+
width: CHECK_STROKE,
|
|
1144
|
+
height: CHECK_STROKE,
|
|
1145
|
+
cornerRadius: CHECK_STROKE / 2,
|
|
1146
|
+
backgroundColor: color(palette.success)
|
|
1147
|
+
}))));
|
|
1148
|
+
}
|
|
769
1149
|
function Spinner(props) {
|
|
770
1150
|
const tick = useTick(90);
|
|
771
1151
|
const dots = 10;
|
|
@@ -820,16 +1200,16 @@ var PAD_X = 40;
|
|
|
820
1200
|
var PAD_TOP = 34;
|
|
821
1201
|
var PAD_BOTTOM = 22;
|
|
822
1202
|
function useMoonbaseState(moonbase) {
|
|
823
|
-
const [state, setState] =
|
|
824
|
-
|
|
1203
|
+
const [state, setState] = React3.useState(() => moonbase.state());
|
|
1204
|
+
React3.useEffect(() => {
|
|
825
1205
|
setState(moonbase.state());
|
|
826
1206
|
return moonbase.subscribe(setState);
|
|
827
1207
|
}, [moonbase]);
|
|
828
1208
|
return state;
|
|
829
1209
|
}
|
|
830
1210
|
function useUiState(moonbase) {
|
|
831
|
-
const [ui, setUi] =
|
|
832
|
-
|
|
1211
|
+
const [ui, setUi] = React3.useState(() => moonbase.uiSnapshot());
|
|
1212
|
+
React3.useEffect(() => {
|
|
833
1213
|
setUi(moonbase.uiSnapshot());
|
|
834
1214
|
return moonbase.subscribeUi(() => setUi(moonbase.uiSnapshot()));
|
|
835
1215
|
}, [moonbase]);
|
|
@@ -870,15 +1250,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
870
1250
|
const strings = (_d = ui.strings) != null ? _d : {};
|
|
871
1251
|
const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
|
|
872
1252
|
const width = cardWidth - PAD_X * 2;
|
|
873
|
-
const
|
|
874
|
-
const [
|
|
875
|
-
const [
|
|
876
|
-
const [
|
|
877
|
-
const [
|
|
878
|
-
const
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
1253
|
+
const still = !!ui.reduceMotion;
|
|
1254
|
+
const [view, setView] = React3.useState(null);
|
|
1255
|
+
const [update, setUpdate] = React3.useState(null);
|
|
1256
|
+
const [cameFromDetails, setCameFromDetails] = React3.useState(false);
|
|
1257
|
+
const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
|
|
1258
|
+
const [copied, setCopied] = React3.useState(null);
|
|
1259
|
+
const previous = React3.useRef(null);
|
|
1260
|
+
const run2 = (name2, action) => {
|
|
1261
|
+
action().catch((err) => moonbase.reportError(name2, err));
|
|
882
1262
|
};
|
|
883
1263
|
const close = () => moonbase.closeUi();
|
|
884
1264
|
const canClose = state.status !== "activating" && state.status !== "loading" && state.licensed;
|
|
@@ -891,7 +1271,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
891
1271
|
if (next === "update")
|
|
892
1272
|
loadUpdate();
|
|
893
1273
|
if (next === "addons")
|
|
894
|
-
run2(() => moonbase.loadAddOns());
|
|
1274
|
+
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
895
1275
|
};
|
|
896
1276
|
const openUpdate = (fromDetails) => {
|
|
897
1277
|
setCameFromDetails(fromDetails);
|
|
@@ -901,7 +1281,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
901
1281
|
setCopied(what);
|
|
902
1282
|
setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
|
|
903
1283
|
};
|
|
904
|
-
|
|
1284
|
+
React3.useEffect(() => {
|
|
905
1285
|
if (screen === "update")
|
|
906
1286
|
return openUpdate(false);
|
|
907
1287
|
let next = screen === "license" ? "details" : screen;
|
|
@@ -909,7 +1289,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
909
1289
|
next = null;
|
|
910
1290
|
go(next);
|
|
911
1291
|
}, [request]);
|
|
912
|
-
|
|
1292
|
+
React3.useEffect(() => {
|
|
913
1293
|
var _a2;
|
|
914
1294
|
const before = previous.current;
|
|
915
1295
|
previous.current = state;
|
|
@@ -926,7 +1306,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
926
1306
|
if (next === "success" && !state.license)
|
|
927
1307
|
next = null;
|
|
928
1308
|
if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
|
|
929
|
-
run2(() => moonbase.loadAddOns());
|
|
1309
|
+
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
930
1310
|
if (next !== view)
|
|
931
1311
|
setView(next);
|
|
932
1312
|
}, [state]);
|
|
@@ -943,10 +1323,10 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
943
1323
|
render: (x, y, available) => {
|
|
944
1324
|
const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
|
|
945
1325
|
let right = x + available - (canClose ? 40 : 0);
|
|
946
|
-
for (const
|
|
947
|
-
const drawn = pill(theme,
|
|
1326
|
+
for (const each2 of [...pills].reverse()) {
|
|
1327
|
+
const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
|
|
948
1328
|
right -= drawn.width;
|
|
949
|
-
nodes.push(pill(theme,
|
|
1329
|
+
nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
|
|
950
1330
|
right -= 8;
|
|
951
1331
|
}
|
|
952
1332
|
return nodes;
|
|
@@ -959,7 +1339,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
959
1339
|
return { height: 14 + body.height, render: (x, y, available) => body.render(x, y + 14, available) };
|
|
960
1340
|
};
|
|
961
1341
|
const backLink = (value, onClick) => ({
|
|
962
|
-
height: 20 +
|
|
1342
|
+
height: 20 + 12,
|
|
963
1343
|
render: (x, y) => h(LinkNode, { key: "back", theme, x, y, value: `\u2039 ${value}`, onClick })
|
|
964
1344
|
});
|
|
965
1345
|
const notice = (value, tone) => {
|
|
@@ -981,7 +1361,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
981
1361
|
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
1362
|
};
|
|
983
1363
|
};
|
|
984
|
-
const unlock = () => buttonBlock(theme, "Unlock full version", () => run2(() => moonbase.activate()));
|
|
1364
|
+
const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()));
|
|
985
1365
|
const screens = {
|
|
986
1366
|
loading: () => [
|
|
987
1367
|
{ height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
|
|
@@ -999,7 +1379,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
999
1379
|
space(8),
|
|
1000
1380
|
paragraph(theme, body, width, { maxWidth: 430 }),
|
|
1001
1381
|
space(28),
|
|
1002
|
-
buttonBlock(theme, strings.activateOnline || "Activate online", () => run2(() => moonbase.activate()), { width: 340, height: 44 }),
|
|
1382
|
+
buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
|
|
1003
1383
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1004
1384
|
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1005
1385
|
];
|
|
@@ -1017,8 +1397,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1017
1397
|
const copyLink = () => {
|
|
1018
1398
|
if (!url)
|
|
1019
1399
|
return;
|
|
1020
|
-
moonbase.copyText(url).then(() => flashCopied(url), () =>
|
|
1021
|
-
});
|
|
1400
|
+
moonbase.copyText(url).then(() => flashCopied(url), (err) => moonbase.reportError("copyText", err));
|
|
1022
1401
|
};
|
|
1023
1402
|
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
1403
|
return [
|
|
@@ -1040,7 +1419,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1040
1419
|
},
|
|
1041
1420
|
buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
|
|
1042
1421
|
!!url && !failed && linksBlock(theme, [
|
|
1043
|
-
{ label: "Open the page again", onClick: () => run2(() => moonbase.openLink(url)) },
|
|
1422
|
+
{ label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
|
|
1044
1423
|
{ label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
|
|
1045
1424
|
]),
|
|
1046
1425
|
errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
|
|
@@ -1054,7 +1433,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1054
1433
|
return [
|
|
1055
1434
|
{
|
|
1056
1435
|
height: 66 + 6,
|
|
1057
|
-
render: (x, y, available) =>
|
|
1436
|
+
render: (x, y, available) => h(SuccessCheck, { key: "check", x: Math.round(x + available / 2 - 33), y: y + 6, still })
|
|
1058
1437
|
},
|
|
1059
1438
|
space(22),
|
|
1060
1439
|
heading(theme, license.trial ? "Your trial has started" : "You're all set", width, { align: "center" }),
|
|
@@ -1079,13 +1458,19 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1079
1458
|
setOffline((current) => ({ ...current, error: "" }));
|
|
1080
1459
|
moonbase.saveMachineFile().then(
|
|
1081
1460
|
(saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
|
|
1082
|
-
(err) =>
|
|
1461
|
+
(err) => {
|
|
1462
|
+
moonbase.reportError("saveMachineFile", err);
|
|
1463
|
+
setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }));
|
|
1464
|
+
}
|
|
1083
1465
|
);
|
|
1084
1466
|
};
|
|
1085
1467
|
const useFile = (pick) => {
|
|
1086
1468
|
pick.then(
|
|
1087
1469
|
(file) => file && setOffline((current) => ({ ...current, file, error: "" })),
|
|
1088
|
-
() =>
|
|
1470
|
+
(err) => {
|
|
1471
|
+
moonbase.reportError("readLicenseFile", err);
|
|
1472
|
+
setOffline((current) => ({ ...current, error: "Couldn't read that file." }));
|
|
1473
|
+
}
|
|
1089
1474
|
);
|
|
1090
1475
|
};
|
|
1091
1476
|
const activateOffline = () => {
|
|
@@ -1107,7 +1492,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1107
1492
|
});
|
|
1108
1493
|
};
|
|
1109
1494
|
const step = (n, value) => ({
|
|
1110
|
-
height: 20 +
|
|
1495
|
+
height: 20 + 10,
|
|
1111
1496
|
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 }))
|
|
1112
1497
|
});
|
|
1113
1498
|
return [
|
|
@@ -1115,31 +1500,31 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1115
1500
|
heading(theme, "Offline activation", width),
|
|
1116
1501
|
space(8),
|
|
1117
1502
|
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),
|
|
1118
|
-
space(
|
|
1503
|
+
space(18),
|
|
1119
1504
|
step("1", "Save your request file"),
|
|
1120
1505
|
{
|
|
1121
|
-
height:
|
|
1122
|
-
render: (x, y) => card({ x, y, width, height:
|
|
1506
|
+
height: 52 + 16,
|
|
1507
|
+
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 }))
|
|
1123
1508
|
},
|
|
1124
1509
|
step("2", "Add the license file"),
|
|
1125
1510
|
{
|
|
1126
|
-
height:
|
|
1511
|
+
height: 72,
|
|
1127
1512
|
render: (x, y) => h("geDropZone", {
|
|
1128
1513
|
key: "drop",
|
|
1129
1514
|
x,
|
|
1130
1515
|
y,
|
|
1131
1516
|
width,
|
|
1132
|
-
height:
|
|
1517
|
+
height: 72,
|
|
1133
1518
|
onDroppedFiles: (dropped) => {
|
|
1134
1519
|
const file = droppedFiles(dropped)[0];
|
|
1135
1520
|
if (file)
|
|
1136
1521
|
useFile(moonbase.readLicenseFile(file));
|
|
1137
1522
|
}
|
|
1138
|
-
}, card({ x: 0, y: 0, width, height:
|
|
1523
|
+
}, 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" })))
|
|
1139
1524
|
},
|
|
1140
1525
|
errorLine(offline.error),
|
|
1141
|
-
space(
|
|
1142
|
-
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy })
|
|
1526
|
+
space(16),
|
|
1527
|
+
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy, height: 44 })
|
|
1143
1528
|
];
|
|
1144
1529
|
},
|
|
1145
1530
|
trial: () => {
|
|
@@ -1191,9 +1576,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1191
1576
|
paragraph(theme, body, width),
|
|
1192
1577
|
space(22),
|
|
1193
1578
|
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())),
|
|
1579
|
+
buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
|
|
1195
1580
|
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()) }])
|
|
1581
|
+
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
1582
|
];
|
|
1198
1583
|
},
|
|
1199
1584
|
details: () => {
|
|
@@ -1209,6 +1594,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1209
1594
|
const seatCount = license.seatCount;
|
|
1210
1595
|
const used = license.seatsUsed;
|
|
1211
1596
|
const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
|
|
1597
|
+
const lit = !seatCount || !used ? 0 : used >= seatCount ? pipCount : Math.max(1, Math.min(pipCount - 1, Math.round(used / seatCount * pipCount)));
|
|
1212
1598
|
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";
|
|
1213
1599
|
const idCopied = copied === license.id;
|
|
1214
1600
|
const rowHeight = 44;
|
|
@@ -1219,12 +1605,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1219
1605
|
]),
|
|
1220
1606
|
{
|
|
1221
1607
|
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
|
-
}) })))
|
|
1608
|
+
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
1609
|
},
|
|
1225
1610
|
{
|
|
1226
1611
|
height: 64 + 22,
|
|
1227
|
-
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 <
|
|
1612
|
+
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, {
|
|
1228
1613
|
key: "deactivate",
|
|
1229
1614
|
theme,
|
|
1230
1615
|
x: width - 16 - 178,
|
|
@@ -1234,7 +1619,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1234
1619
|
kind: "danger",
|
|
1235
1620
|
disabled: state.busy,
|
|
1236
1621
|
label: state.busy ? "Deactivating\u2026" : license.trial || license.activationMethod === "Offline" ? "Remove from this device" : "Deactivate this device",
|
|
1237
|
-
onClick: () => run2(() => moonbase.deactivate())
|
|
1622
|
+
onClick: () => run2("deactivate", () => moonbase.deactivate())
|
|
1238
1623
|
}))
|
|
1239
1624
|
},
|
|
1240
1625
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
@@ -1263,8 +1648,10 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1263
1648
|
list = {
|
|
1264
1649
|
height: listHeight,
|
|
1265
1650
|
render: (x, y) => {
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1651
|
+
const scrolls2 = rows.length > visible;
|
|
1652
|
+
const rowWidth = scrolls2 ? width - SCROLLBAR - 8 : width;
|
|
1653
|
+
const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), rowWidth, rowHeight));
|
|
1654
|
+
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);
|
|
1268
1655
|
}
|
|
1269
1656
|
};
|
|
1270
1657
|
} else if (info.phase !== "ready") {
|
|
@@ -1286,7 +1673,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1286
1673
|
label: loading ? "Checking\u2026" : failed ? "Try again" : "Bought an add-on? Refresh",
|
|
1287
1674
|
link: true,
|
|
1288
1675
|
disabled: loading || waiting,
|
|
1289
|
-
onClick: () => run2(() => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
|
|
1676
|
+
onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
|
|
1290
1677
|
}], { align: "left" })
|
|
1291
1678
|
];
|
|
1292
1679
|
},
|
|
@@ -1319,11 +1706,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1319
1706
|
const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
|
|
1320
1707
|
let action;
|
|
1321
1708
|
if (download.phase === "done")
|
|
1322
|
-
action = buttonBlock(theme, "Show in folder", () => run2(() => moonbase.revealUpdate()));
|
|
1709
|
+
action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
|
|
1323
1710
|
else if (notCovered)
|
|
1324
|
-
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())) : null;
|
|
1711
|
+
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
|
|
1325
1712
|
else if (update.canDownload)
|
|
1326
|
-
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2(() => moonbase.downloadUpdate()), { disabled: downloading });
|
|
1713
|
+
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
|
|
1327
1714
|
else
|
|
1328
1715
|
action = update.hasDownloads ? unlock() : null;
|
|
1329
1716
|
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 +1742,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1355
1742
|
{ label: "Remind me later", onClick: back },
|
|
1356
1743
|
{ label: "Skip this version", onClick: () => {
|
|
1357
1744
|
var _a3;
|
|
1358
|
-
moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch(() =>
|
|
1359
|
-
}).then(back);
|
|
1745
|
+
moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch((err) => moonbase.reportError("skipUpdate", err)).then(back);
|
|
1360
1746
|
} }
|
|
1361
1747
|
])
|
|
1362
1748
|
];
|
|
@@ -1378,7 +1764,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1378
1764
|
const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
|
|
1379
1765
|
const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
|
|
1380
1766
|
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)) });
|
|
1767
|
+
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
1768
|
right -= 8;
|
|
1383
1769
|
return node;
|
|
1384
1770
|
});
|
|
@@ -1393,28 +1779,62 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1393
1779
|
let content;
|
|
1394
1780
|
if (scrolls) {
|
|
1395
1781
|
const inner = stack(blocks, PAD_X, 0, width);
|
|
1396
|
-
content = { height: room, nodes: [
|
|
1782
|
+
content = { height: room, nodes: [scrollView({ key: "screen", x: 0, y: PAD_TOP, width: cardWidth - 10, height: room }, inner.height, ...inner.nodes)] };
|
|
1397
1783
|
} else {
|
|
1398
1784
|
content = stack(blocks, PAD_X, PAD_TOP, width);
|
|
1399
1785
|
}
|
|
1400
1786
|
const cardHeight = PAD_TOP + content.height + footer + PAD_BOTTOM;
|
|
1401
1787
|
const top = Math.max(12, Math.round((areaHeight - cardHeight) / 2));
|
|
1402
1788
|
const left = Math.round((areaWidth - cardWidth) / 2);
|
|
1403
|
-
return
|
|
1789
|
+
return h(PanelCard, {
|
|
1790
|
+
key: "card",
|
|
1791
|
+
left,
|
|
1792
|
+
top,
|
|
1793
|
+
width: cardWidth,
|
|
1794
|
+
height: cardHeight,
|
|
1795
|
+
screen: name,
|
|
1796
|
+
contentHeight: content.height,
|
|
1797
|
+
content: content.nodes,
|
|
1798
|
+
closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }),
|
|
1799
|
+
// Kept to the card's bottom edge as it resizes.
|
|
1800
|
+
footer: showBadge ? (height) => {
|
|
1801
|
+
const divider = height - footer - PAD_BOTTOM + 30;
|
|
1802
|
+
return [
|
|
1803
|
+
label({ key: "divider", x: PAD_X, y: divider, width, height: 1, backgroundColor: color("#ffffff", 0.06) }),
|
|
1804
|
+
h(Badge, { key: "badge", theme, x: PAD_X, y: divider + 14, width, mark: moonbase.moonbaseMark(), onClick: () => run2("openLink", () => moonbase.openLink("https://moonbase.sh")) })
|
|
1805
|
+
];
|
|
1806
|
+
} : null,
|
|
1807
|
+
still
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
var PanelView = React3.memo(Panel);
|
|
1811
|
+
function PanelCard(props) {
|
|
1812
|
+
var _a, _b;
|
|
1813
|
+
const [top, height] = useTween([
|
|
1814
|
+
{ to: props.top, duration: 300, ease: EASE },
|
|
1815
|
+
{ to: props.height, duration: 300, ease: EASE }
|
|
1816
|
+
], props.still);
|
|
1817
|
+
const entered = EASE(useEntrance(props.screen, 400, props.still));
|
|
1818
|
+
const cardHeight = Math.round(height);
|
|
1819
|
+
return card(
|
|
1820
|
+
{ x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
|
|
1821
|
+
h(Glow, { key: "glow", width: props.width, still: props.still }),
|
|
1822
|
+
label({ key: "screen", x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
|
|
1823
|
+
props.closeButton,
|
|
1824
|
+
...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
|
|
1825
|
+
);
|
|
1404
1826
|
}
|
|
1405
1827
|
function LinkNode(props) {
|
|
1406
|
-
|
|
1407
|
-
const [hovered, setHovered] = React2.useState(false);
|
|
1408
|
-
const width = (_a = props.width) != null ? _a : textWidth(props.value, 12.5, 500) + 8;
|
|
1828
|
+
const [hovered, setHovered] = React3.useState(false);
|
|
1409
1829
|
return label({
|
|
1410
1830
|
x: props.x,
|
|
1411
1831
|
y: props.y,
|
|
1412
|
-
width,
|
|
1832
|
+
width: textWidth(props.value, 12.5, 500) + 8,
|
|
1413
1833
|
height: 20,
|
|
1414
1834
|
text: props.value,
|
|
1415
|
-
fontSize:
|
|
1416
|
-
textColor: hovered ? palette.textBright :
|
|
1417
|
-
textAlign:
|
|
1835
|
+
fontSize: 12.5,
|
|
1836
|
+
textColor: hovered ? palette.textBright : palette.textSecondary,
|
|
1837
|
+
textAlign: "centered left",
|
|
1418
1838
|
interceptsMouseClicks: true,
|
|
1419
1839
|
mouseCursorType: "pointing hand",
|
|
1420
1840
|
onMouseEnter: () => setHovered(true),
|
|
@@ -1422,6 +1842,27 @@ function LinkNode(props) {
|
|
|
1422
1842
|
onClick: props.onClick
|
|
1423
1843
|
});
|
|
1424
1844
|
}
|
|
1845
|
+
function Badge(props) {
|
|
1846
|
+
const [hovered, setHovered] = React3.useState(false);
|
|
1847
|
+
const lead = "Licensing secured by";
|
|
1848
|
+
const gap = 7;
|
|
1849
|
+
const size = props.mark ? 14 : 0;
|
|
1850
|
+
const markGap = props.mark ? gap : 0;
|
|
1851
|
+
const wordmark = textWidth("moonbase", 12, 500) + 16;
|
|
1852
|
+
const start = Math.round((props.width - (textWidth(lead, 11) + gap + size + markGap + wordmark)) / 2);
|
|
1853
|
+
const linkX = start + textWidth(lead, 11) + gap;
|
|
1854
|
+
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({
|
|
1855
|
+
x: linkX,
|
|
1856
|
+
y: 0,
|
|
1857
|
+
width: size + markGap + wordmark,
|
|
1858
|
+
height: 20,
|
|
1859
|
+
interceptsMouseClicks: true,
|
|
1860
|
+
mouseCursorType: "pointing hand",
|
|
1861
|
+
onMouseEnter: () => setHovered(true),
|
|
1862
|
+
onMouseExit: () => setHovered(false),
|
|
1863
|
+
onClick: props.onClick
|
|
1864
|
+
}, 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 })));
|
|
1865
|
+
}
|
|
1425
1866
|
function osLabel() {
|
|
1426
1867
|
switch (import_node_process2.default.platform) {
|
|
1427
1868
|
case "darwin":
|
|
@@ -1446,7 +1887,12 @@ function MoonbaseActivation(props) {
|
|
|
1446
1887
|
const { moonbase, width, height } = props;
|
|
1447
1888
|
const state = useMoonbaseState(moonbase);
|
|
1448
1889
|
const ui = useUiState(moonbase);
|
|
1449
|
-
|
|
1890
|
+
const shown = ui.visible ? 1 : 0;
|
|
1891
|
+
const [scrim, rise] = useTween([
|
|
1892
|
+
{ to: shown, duration: 250, ease: EASE_CSS },
|
|
1893
|
+
{ to: shown, duration: ui.visible ? 350 : 250, ease: ui.visible ? EASE : EASE_CSS }
|
|
1894
|
+
], !!moonbase.ui.reduceMotion, [0, 0]);
|
|
1895
|
+
if (!ui.visible && scrim === 0 && rise === 0)
|
|
1450
1896
|
return null;
|
|
1451
1897
|
return label({
|
|
1452
1898
|
key: "moonbase-activation",
|
|
@@ -1454,7 +1900,8 @@ function MoonbaseActivation(props) {
|
|
|
1454
1900
|
y: (_b = props.y) != null ? _b : 0,
|
|
1455
1901
|
width,
|
|
1456
1902
|
height,
|
|
1457
|
-
|
|
1903
|
+
// Never quite clear while it is there, coming or going.
|
|
1904
|
+
backgroundColor: color("#04060b", Math.max(1 / 255, 0.62 * scrim)),
|
|
1458
1905
|
alwaysOnTop: true,
|
|
1459
1906
|
// Takes every click, so the plugin underneath is locked while it is up.
|
|
1460
1907
|
interceptsMouseClicks: true,
|
|
@@ -1462,13 +1909,20 @@ function MoonbaseActivation(props) {
|
|
|
1462
1909
|
// the front, after the customer bought an add-on in the browser.
|
|
1463
1910
|
onMouseEnter: () => moonbase.onFocusChanged(true),
|
|
1464
1911
|
onMouseExit: () => moonbase.onFocusChanged(false)
|
|
1465
|
-
}, h(
|
|
1912
|
+
}, 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
1913
|
}
|
|
1914
|
+
|
|
1915
|
+
// src/index.ts
|
|
1916
|
+
var import_licensing2 = require("@moonbase.sh/licensing");
|
|
1467
1917
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1468
1918
|
0 && (module.exports = {
|
|
1919
|
+
ActivationError,
|
|
1469
1920
|
MoonbaseActivation,
|
|
1921
|
+
MoonbaseError,
|
|
1470
1922
|
MoonbaseGorillaEngine,
|
|
1923
|
+
ReleaseNotCoveredError,
|
|
1471
1924
|
createMoonbase,
|
|
1472
1925
|
defaultLicenseFile,
|
|
1926
|
+
gorillaEngineHost,
|
|
1473
1927
|
useMoonbaseState
|
|
1474
1928
|
});
|