@moonbase.sh/gorilla-engine 0.0.0-next-20261028214425
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 +69 -0
- package/dist/index.cjs +1474 -0
- package/dist/index.d.cts +187 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +1433 -0
- package/package.json +57 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1474 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
MoonbaseActivation: () => MoonbaseActivation,
|
|
34
|
+
MoonbaseGorillaEngine: () => MoonbaseGorillaEngine,
|
|
35
|
+
createMoonbase: () => createMoonbase,
|
|
36
|
+
defaultLicenseFile: () => defaultLicenseFile,
|
|
37
|
+
useMoonbaseState: () => useMoonbaseState
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
|
|
41
|
+
// src/moonbase.ts
|
|
42
|
+
var import_node_child_process = require("child_process");
|
|
43
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
44
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
45
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
46
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
47
|
+
var import_licensing = require("@moonbase.sh/licensing");
|
|
48
|
+
|
|
49
|
+
// package.json
|
|
50
|
+
var version = "0.0.0-next-20261028214425";
|
|
51
|
+
|
|
52
|
+
// src/download.ts
|
|
53
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
54
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
55
|
+
function downloadState(phase, rest = {}) {
|
|
56
|
+
return { phase, progress: null, path: null, error: null, releaseAccess: null, upgradeUrl: null, ...rest };
|
|
57
|
+
}
|
|
58
|
+
function fileSafe(name) {
|
|
59
|
+
const cleaned = name.replace(/[\u0000-\u001F\u007F\\/:*?"<>|]/g, "-").trim().replace(/^\.+|\.+$/g, "");
|
|
60
|
+
return cleaned || "license";
|
|
61
|
+
}
|
|
62
|
+
function uniquePath(dir, name) {
|
|
63
|
+
const candidate = import_node_path.default.join(dir, name);
|
|
64
|
+
if (!import_node_fs.default.existsSync(candidate))
|
|
65
|
+
return candidate;
|
|
66
|
+
const dot = name.lastIndexOf(".");
|
|
67
|
+
const [stem, extension] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, ""];
|
|
68
|
+
for (let n = 2; ; n++) {
|
|
69
|
+
const next = import_node_path.default.join(dir, `${stem} (${n})${extension}`);
|
|
70
|
+
if (!import_node_fs.default.existsSync(next))
|
|
71
|
+
return next;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/moonbase.ts
|
|
76
|
+
function runtime() {
|
|
77
|
+
var _a;
|
|
78
|
+
return (_a = globalThis.GorillaEngine) != null ? _a : null;
|
|
79
|
+
}
|
|
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
|
+
function run(command, args, input) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
var _a;
|
|
97
|
+
const child = (0, import_node_child_process.execFile)(command, args, { windowsHide: true }, (error) => error ? reject(error) : resolve());
|
|
98
|
+
if (input !== void 0) {
|
|
99
|
+
(_a = child.stdin) == null ? void 0 : _a.end(input);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function openWithSystem(url) {
|
|
104
|
+
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
|
+
(0, import_node_child_process.spawn)(command, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
106
|
+
}
|
|
107
|
+
var MoonbaseGorillaEngine = class extends import_licensing.ActivationController {
|
|
108
|
+
constructor(options) {
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
110
|
+
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";
|
|
112
|
+
super({
|
|
113
|
+
...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
|
+
},
|
|
122
|
+
// Ahead of the SDK's own token, so Moonbase knows the product uses this module.
|
|
123
|
+
clientInfo: [options.clientInfo, `@moonbase.sh/gorilla-engine/${version}`].filter(Boolean).join(" "),
|
|
124
|
+
productName,
|
|
125
|
+
accountName: ui.manufacturerName
|
|
126
|
+
});
|
|
127
|
+
this.uiListeners = /* @__PURE__ */ new Set();
|
|
128
|
+
this.uiState = { visible: false, screen: null, request: 0, download: downloadState("idle") };
|
|
129
|
+
this.lastLicensed = null;
|
|
130
|
+
this.gated = null;
|
|
131
|
+
this.downloaded = null;
|
|
132
|
+
this.name = "This computer";
|
|
133
|
+
this.ui = { ...ui, productName };
|
|
134
|
+
this.endpoint = options.endpoint;
|
|
135
|
+
this.lockAudioAndMidi = (_g = options.lockAudioAndMidi) != null ? _g : true;
|
|
136
|
+
this.subscribe((state) => this.afterStateChange(state));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Validate the stored license, start watching it, and bring the overlay up
|
|
140
|
+
* when the plugin has no license. Call once per plugin instance.
|
|
141
|
+
*/
|
|
142
|
+
start() {
|
|
143
|
+
super.start();
|
|
144
|
+
this.device().then((device) => {
|
|
145
|
+
this.name = device.name;
|
|
146
|
+
}, () => {
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/** This computer's name, as the activation screen shows it. */
|
|
150
|
+
get deviceName() {
|
|
151
|
+
return this.name;
|
|
152
|
+
}
|
|
153
|
+
/** What the overlay shows, besides the license state. */
|
|
154
|
+
uiSnapshot() {
|
|
155
|
+
return this.uiState;
|
|
156
|
+
}
|
|
157
|
+
/** Called whenever {@link uiSnapshot} changes. Returns a function that stops it. */
|
|
158
|
+
subscribeUi(listener) {
|
|
159
|
+
this.uiListeners.add(listener);
|
|
160
|
+
return () => this.uiListeners.delete(listener);
|
|
161
|
+
}
|
|
162
|
+
setUi(next) {
|
|
163
|
+
this.uiState = { ...this.uiState, ...next };
|
|
164
|
+
for (const listener of [...this.uiListeners])
|
|
165
|
+
listener();
|
|
166
|
+
}
|
|
167
|
+
afterStateChange(state) {
|
|
168
|
+
var _a, _b, _c, _d;
|
|
169
|
+
if (state.status === "loading")
|
|
170
|
+
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
|
+
}
|
|
177
|
+
const previous = this.lastLicensed;
|
|
178
|
+
this.lastLicensed = state.licensed;
|
|
179
|
+
if (!state.licensed && previous !== false && ((_c = this.ui.autoPresentOnLock) != null ? _c : true)) {
|
|
180
|
+
this.present();
|
|
181
|
+
} else if (previous === null && state.licensed && ((_d = this.ui.autoPresentUpdate) != null ? _d : true) && state.update) {
|
|
182
|
+
const latest = state.update.latestVersion;
|
|
183
|
+
void this.isUpdateSkipped(latest).then((skipped) => {
|
|
184
|
+
if (!skipped)
|
|
185
|
+
this.present("update");
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Show the activation overlay, optionally on a particular screen. Without one
|
|
191
|
+
* it shows whatever the license state calls for.
|
|
192
|
+
*/
|
|
193
|
+
present(screen) {
|
|
194
|
+
this.setUi({ visible: true, screen: screen != null ? screen : null, request: this.uiState.request + 1 });
|
|
195
|
+
}
|
|
196
|
+
/** Take the overlay down. */
|
|
197
|
+
closeUi() {
|
|
198
|
+
if (this.uiState.visible)
|
|
199
|
+
this.setUi({ visible: false });
|
|
200
|
+
}
|
|
201
|
+
/** Copy text to the clipboard, for the activation link and the license id. */
|
|
202
|
+
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);
|
|
209
|
+
}
|
|
210
|
+
/** Show a file in the file manager. */
|
|
211
|
+
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)]);
|
|
219
|
+
}
|
|
220
|
+
downloadsFolder() {
|
|
221
|
+
return import_node_path2.default.join(import_node_os.default.homedir(), "Downloads");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Save the machine file for offline activation: through Gorilla Engine's save
|
|
225
|
+
* dialog, or into Downloads, shown in the file manager. Null when the customer
|
|
226
|
+
* cancels.
|
|
227
|
+
*/
|
|
228
|
+
async saveMachineFile() {
|
|
229
|
+
var _a, _b;
|
|
230
|
+
const token = await this.deviceToken();
|
|
231
|
+
const name = `${fileSafe((_a = this.ui.productName) != null ? _a : "license")}.dt`;
|
|
232
|
+
const chooser = (_b = runtime()) == null ? void 0 : _b.openFileChooser;
|
|
233
|
+
if (chooser) {
|
|
234
|
+
const picked = await chooser({ saveDialog: true, warnOnOverwrite: true, hint: "Save machine file", allowedExtensions: "*.dt", defaultLocation: import_node_path2.default.join(this.downloadsFolder(), name) });
|
|
235
|
+
const file2 = picked == null ? void 0 : picked[0];
|
|
236
|
+
if (!file2)
|
|
237
|
+
return null;
|
|
238
|
+
await import_promises.default.writeFile(file2, token);
|
|
239
|
+
return file2;
|
|
240
|
+
}
|
|
241
|
+
const file = uniquePath(this.downloadsFolder(), name);
|
|
242
|
+
await import_promises.default.writeFile(file, token);
|
|
243
|
+
await this.reveal(file).catch(() => {
|
|
244
|
+
});
|
|
245
|
+
return file;
|
|
246
|
+
}
|
|
247
|
+
/** Pick the license file the customer got back for offline activation. Null when they cancel. */
|
|
248
|
+
async chooseLicenseFile() {
|
|
249
|
+
var _a;
|
|
250
|
+
const chooser = (_a = runtime()) == null ? void 0 : _a.openFileChooser;
|
|
251
|
+
if (!chooser)
|
|
252
|
+
throw new import_licensing.ActivationError("internal", "This plugin can't open a file dialog");
|
|
253
|
+
const picked = await chooser({ hint: "Choose your license file", allowedExtensions: "*.mb;*.jwt;*.txt;*.lic" });
|
|
254
|
+
const file = picked == null ? void 0 : picked[0];
|
|
255
|
+
return file ? await this.readLicenseFile(file) : null;
|
|
256
|
+
}
|
|
257
|
+
/** Read a license file the customer dropped or picked. */
|
|
258
|
+
async readLicenseFile(file) {
|
|
259
|
+
return { name: import_node_path2.default.basename(file), text: await import_promises.default.readFile(file, "utf8") };
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Download the latest installer for this platform into Downloads, reporting
|
|
263
|
+
* progress to the overlay, then show it in the file manager.
|
|
264
|
+
*/
|
|
265
|
+
async downloadUpdate() {
|
|
266
|
+
var _a, _b;
|
|
267
|
+
if (this.uiState.download.phase === "downloading")
|
|
268
|
+
return;
|
|
269
|
+
this.setUi({ download: downloadState("downloading") });
|
|
270
|
+
try {
|
|
271
|
+
const file = await this.downloadInstaller({
|
|
272
|
+
directory: this.downloadsFolder(),
|
|
273
|
+
onProgress: (progress) => this.setUi({ download: downloadState("downloading", { progress }) })
|
|
274
|
+
});
|
|
275
|
+
this.downloaded = file;
|
|
276
|
+
await this.reveal(file).catch(() => {
|
|
277
|
+
});
|
|
278
|
+
this.setUi({ download: downloadState("done", { progress: 1, path: file }) });
|
|
279
|
+
} catch (err) {
|
|
280
|
+
if (err instanceof import_licensing.ReleaseNotCoveredError)
|
|
281
|
+
this.setUi({ download: downloadState("notCovered", { releaseAccess: (_a = err.releaseAccess) != null ? _a : null, upgradeUrl: (_b = err.upgradeUrl) != null ? _b : null }) });
|
|
282
|
+
else
|
|
283
|
+
this.setUi({ download: downloadState("failed", { error: `The download failed: ${err instanceof Error ? err.message : err}` }) });
|
|
284
|
+
throw err;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** Show the downloaded installer in the file manager again. */
|
|
288
|
+
async revealUpdate() {
|
|
289
|
+
if (!this.downloaded)
|
|
290
|
+
throw new import_licensing.ActivationError("internal", "Nothing has been downloaded");
|
|
291
|
+
await this.reveal(this.downloaded);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Open a link from the overlay in the browser: the pending activation, the
|
|
295
|
+
* store, or Moonbase's site from the footer.
|
|
296
|
+
*/
|
|
297
|
+
async openLink(url) {
|
|
298
|
+
var _a;
|
|
299
|
+
let sameOrigin = false;
|
|
300
|
+
try {
|
|
301
|
+
sameOrigin = new URL(this.endpoint).origin === new URL(url).origin;
|
|
302
|
+
} catch (e) {
|
|
303
|
+
}
|
|
304
|
+
const pending = ((_a = this.state().activation) == null ? void 0 : _a.browserUrl) === url;
|
|
305
|
+
if (!sameOrigin && !pending && url !== "https://moonbase.sh")
|
|
306
|
+
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);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
function createMoonbase(options) {
|
|
315
|
+
return new MoonbaseGorillaEngine(options);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/MoonbaseActivation.ts
|
|
319
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
320
|
+
var React2 = __toESM(require("react"), 1);
|
|
321
|
+
|
|
322
|
+
// src/copy.ts
|
|
323
|
+
var DAY = 864e5;
|
|
324
|
+
function formatDate(date) {
|
|
325
|
+
return new Date(date).toLocaleDateString("en-GB", { day: "numeric", month: "long", year: "numeric" });
|
|
326
|
+
}
|
|
327
|
+
function daysUntil(when) {
|
|
328
|
+
return Math.max(0, Math.ceil((new Date(when).getTime() - Date.now()) / DAY));
|
|
329
|
+
}
|
|
330
|
+
function join(a, b) {
|
|
331
|
+
return !a ? b : !b ? a : `${a} \xB7 ${b}`;
|
|
332
|
+
}
|
|
333
|
+
function trialLength(license, fallback) {
|
|
334
|
+
if (!(license == null ? void 0 : license.expiresAt) || !license.issuedAt)
|
|
335
|
+
return fallback;
|
|
336
|
+
const days = Math.round((new Date(license.expiresAt).getTime() - new Date(license.issuedAt).getTime()) / DAY);
|
|
337
|
+
return days >= 1 ? days : fallback;
|
|
338
|
+
}
|
|
339
|
+
function planName(license) {
|
|
340
|
+
if (license.trial)
|
|
341
|
+
return `${license.product.name} trial`;
|
|
342
|
+
if (license.activationMethod === "Offline")
|
|
343
|
+
return `${license.product.name} (offline)`;
|
|
344
|
+
return license.product.name;
|
|
345
|
+
}
|
|
346
|
+
function releaseAccessText(access) {
|
|
347
|
+
if (!access)
|
|
348
|
+
return "";
|
|
349
|
+
const sentences = [];
|
|
350
|
+
if (access.updatesUntil && new Date(access.updatesUntil) < /* @__PURE__ */ new Date())
|
|
351
|
+
sentences.push(`Your updates ended on ${formatDate(access.updatesUntil)}.`);
|
|
352
|
+
const covers = [];
|
|
353
|
+
if (access.upToMajor !== void 0 && access.upToMajor !== null)
|
|
354
|
+
covers.push(`versions up to ${access.upToMajor}.x`);
|
|
355
|
+
if (access.upToVersion)
|
|
356
|
+
covers.push(`releases up to ${access.upToVersion}`);
|
|
357
|
+
if (covers.length)
|
|
358
|
+
sentences.push(`Your license covers ${covers.join(" and ")}.`);
|
|
359
|
+
return sentences.join(" ");
|
|
360
|
+
}
|
|
361
|
+
function upgradeLabel(access) {
|
|
362
|
+
return (access == null ? void 0 : access.updatesUntil) ? "Renew updates" : "Upgrade license";
|
|
363
|
+
}
|
|
364
|
+
function welcomeCopy(reason, strings, product, account) {
|
|
365
|
+
const pick = (custom, fallback) => custom || fallback;
|
|
366
|
+
switch (reason) {
|
|
367
|
+
case "deactivated":
|
|
368
|
+
return [pick(strings.deactivatedTitle, "Deactivated on this computer"), pick(strings.deactivatedBody, `${product} no longer has an active license here. Activate it again to keep using it.`)];
|
|
369
|
+
case "expired":
|
|
370
|
+
return [pick(strings.licenseExpiredTitle, "Your license has expired"), pick(strings.licenseExpiredBody, `Renew your ${product} license in your ${account} account, then activate it again.`)];
|
|
371
|
+
case "invalid":
|
|
372
|
+
return [pick(strings.licenseInvalidTitle, "Your license is no longer valid"), pick(strings.licenseInvalidBody, `${account} no longer accepts this license on this computer. Activate again, or contact ${account} if this seems wrong.`)];
|
|
373
|
+
case "unverified":
|
|
374
|
+
return [pick(strings.licenseUnverifiedTitle, "Couldn't verify your license"), pick(strings.licenseUnverifiedBody, `${product} has gone too long without checking its license online. Connect to the internet and activate again.`)];
|
|
375
|
+
default:
|
|
376
|
+
return [pick(strings.welcomeTitle, `Activate ${product}`), pick(strings.welcomeBody, `Unlock ${product} through your ${account} account, or take it for a spin with a free trial.`)];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
var cycleSuffix = { Daily: " / day", Weekly: " / week", Monthly: " / month", Quarterly: " / quarter", Yearly: " / year" };
|
|
380
|
+
function formatAmount(amount, currency) {
|
|
381
|
+
const whole = Math.abs(amount - Math.round(amount)) < 5e-3;
|
|
382
|
+
try {
|
|
383
|
+
return new Intl.NumberFormat("en-GB", { style: "currency", currency, minimumFractionDigits: whole ? 0 : 2, maximumFractionDigits: whole ? 0 : 2 }).format(amount);
|
|
384
|
+
} catch (e) {
|
|
385
|
+
return `${whole ? Math.round(amount) : amount.toFixed(2)} ${currency}`;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function priceText(entry, currency) {
|
|
389
|
+
var _a, _b, _c, _d, _e, _f;
|
|
390
|
+
const pricing = (_b = entry.product.defaultVariation) != null ? _b : (_a = entry.product.variations) == null ? void 0 : _a[0];
|
|
391
|
+
const amount = currency ? pricing == null ? void 0 : pricing.price[currency] : void 0;
|
|
392
|
+
if (amount === void 0 || amount === null || !pricing)
|
|
393
|
+
return "";
|
|
394
|
+
const recurring = ((_c = pricing.recurrence) == null ? void 0 : _c.type) === "Recurring";
|
|
395
|
+
return formatAmount(amount, currency) + (recurring ? (_f = cycleSuffix[(_e = (_d = pricing.recurrence) == null ? void 0 : _d.cycleLength) != null ? _e : ""]) != null ? _f : "" : "");
|
|
396
|
+
}
|
|
397
|
+
function findSubProduct(license, id) {
|
|
398
|
+
var _a, _b;
|
|
399
|
+
const prefix = `${license.product.id}.`;
|
|
400
|
+
const own = id.startsWith(prefix) && id.length > prefix.length ? id.slice(prefix.length) : id;
|
|
401
|
+
return (_b = ((_a = license.subProducts) != null ? _a : []).find((entry) => entry.id === own)) != null ? _b : null;
|
|
402
|
+
}
|
|
403
|
+
function describeAddOn(entry, license, state) {
|
|
404
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
405
|
+
const price = priceText(entry, state.addOns.currency);
|
|
406
|
+
const owns = entry.product.owned || entry.product.subscribed;
|
|
407
|
+
const forSale = !!entry.buyUrl;
|
|
408
|
+
const row = { id: entry.id, name: entry.product.name, status: "", tone: "muted", primary: null, secondary: null };
|
|
409
|
+
const held = findSubProduct(license, entry.id);
|
|
410
|
+
const active = entry.includedInLicense ? state.activeSubProducts.includes(entry.id) : entry.active;
|
|
411
|
+
const wasActive = held ? held.active : entry.active;
|
|
412
|
+
const revoked = held ? held.revoked : entry.revoked;
|
|
413
|
+
const ends = held ? (_a = held.expiresAt) != null ? _a : null : (_d = (_c = entry.expiresAt) != null ? _c : (_b = entry.trial) == null ? void 0 : _b.expiresAt) != null ? _d : null;
|
|
414
|
+
const lapsed = wasActive && !active && !!ends && daysUntil(ends) === 0;
|
|
415
|
+
const trialStatus = ((_f = (_e = entry.trial) == null ? void 0 : _e.status) != null ? _f : "Unavailable").toLowerCase();
|
|
416
|
+
const onTrial = held ? held.trial : trialStatus === "active";
|
|
417
|
+
let trial = trialStatus;
|
|
418
|
+
if (held == null ? void 0 : held.trial)
|
|
419
|
+
trial = active ? "active" : "expired";
|
|
420
|
+
else if (trial === "active" && lapsed)
|
|
421
|
+
trial = "expired";
|
|
422
|
+
if (active && owns && !onTrial) {
|
|
423
|
+
row.status = entry.includedInLicense ? "Active on this computer" : entry.product.subscribed ? "Subscribed" : "Owned";
|
|
424
|
+
row.tone = "success";
|
|
425
|
+
} else if (active) {
|
|
426
|
+
const days = ends ? daysUntil(ends) : null;
|
|
427
|
+
row.status = join("Trial", days === null ? "" : days === 1 ? "1 day left" : `${days} days left`);
|
|
428
|
+
row.tone = "trial";
|
|
429
|
+
if (owns && entry.includedInLicense)
|
|
430
|
+
row.primary = "activate";
|
|
431
|
+
else if (forSale)
|
|
432
|
+
row.primary = "buy";
|
|
433
|
+
} else if (lapsed && owns && !onTrial) {
|
|
434
|
+
row.status = join("Expired", price);
|
|
435
|
+
if (forSale)
|
|
436
|
+
row.primary = "buy";
|
|
437
|
+
} else if (entry.includedInLicense && owns) {
|
|
438
|
+
const listSeats = (_g = entry.seats) != null ? _g : null;
|
|
439
|
+
const licenseSeats = (_h = held == null ? void 0 : held.seats) != null ? _h : null;
|
|
440
|
+
const seatsInUse = (!!listSeats || !!licenseSeats) && (!listSeats || listSeats.remaining <= 0) && (!licenseSeats || licenseSeats.remaining <= 0);
|
|
441
|
+
if (revoked) {
|
|
442
|
+
row.status = "Deactivated on this computer";
|
|
443
|
+
row.primary = "activate";
|
|
444
|
+
} else if (seatsInUse) {
|
|
445
|
+
const total = (listSeats != null ? listSeats : licenseSeats).total;
|
|
446
|
+
row.status = total === 1 ? "Its seat is in use on another computer" : `All ${total} seats are in use`;
|
|
447
|
+
} else {
|
|
448
|
+
row.status = "Not activated on this computer";
|
|
449
|
+
row.primary = "activate";
|
|
450
|
+
}
|
|
451
|
+
} else if (trial === "available") {
|
|
452
|
+
const days = (_i = entry.trial) == null ? void 0 : _i.numberOfDays;
|
|
453
|
+
row.status = join(days ? `${days}-day free trial` : "Free trial", price);
|
|
454
|
+
row.primary = "tryIt";
|
|
455
|
+
if (forSale)
|
|
456
|
+
row.secondary = "buy";
|
|
457
|
+
} else if (trial === "expired") {
|
|
458
|
+
row.status = join("Trial ended", price);
|
|
459
|
+
if (forSale)
|
|
460
|
+
row.primary = "buy";
|
|
461
|
+
} else if (trial === "unavailable" && ((_j = entry.trial) == null ? void 0 : _j.requiresNewsletterOptIn)) {
|
|
462
|
+
row.status = join("Join the newsletter to try it free", price);
|
|
463
|
+
if (forSale)
|
|
464
|
+
row.primary = "buy";
|
|
465
|
+
} else {
|
|
466
|
+
row.status = join(price, (_k = entry.product.tagline) != null ? _k : "");
|
|
467
|
+
if (forSale)
|
|
468
|
+
row.primary = "buy";
|
|
469
|
+
}
|
|
470
|
+
return row;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// src/elements.ts
|
|
474
|
+
var React = __toESM(require("react"), 1);
|
|
475
|
+
var h = React.createElement;
|
|
476
|
+
function color(hex, alpha = 1) {
|
|
477
|
+
let value = hex.trim().replace(/^#/, "");
|
|
478
|
+
if (value.length === 3)
|
|
479
|
+
value = value.split("").map((digit) => digit + digit).join("");
|
|
480
|
+
if (!/^[0-9a-f]{6}$/i.test(value))
|
|
481
|
+
value = "186cdc";
|
|
482
|
+
const a = Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, "0");
|
|
483
|
+
return `${a}${value}`.toUpperCase();
|
|
484
|
+
}
|
|
485
|
+
var palette = {
|
|
486
|
+
panel: color("#0a0e16"),
|
|
487
|
+
scrim: color("#04060b", 0.62),
|
|
488
|
+
textPrimary: color("#f5f8fb"),
|
|
489
|
+
textBody: color("#cdd8e6"),
|
|
490
|
+
textBright: color("#9fb3cc"),
|
|
491
|
+
textSecondary: color("#768aa4"),
|
|
492
|
+
textMuted: color("#5a6b82"),
|
|
493
|
+
card: color("#ffffff", 0.025),
|
|
494
|
+
cardBorder: color("#ffffff", 0.07),
|
|
495
|
+
divider: color("#ffffff", 0.05),
|
|
496
|
+
ghost: color("#ffffff", 0.04),
|
|
497
|
+
ghostBorder: color("#ffffff", 0.13),
|
|
498
|
+
ghostHover: color("#ffffff", 0.08),
|
|
499
|
+
link: color("#6aa8ff"),
|
|
500
|
+
linkHover: color("#9cc6ff"),
|
|
501
|
+
glow: color("#82cef1"),
|
|
502
|
+
success: "#34d27b",
|
|
503
|
+
successDeep: "#16a34a",
|
|
504
|
+
trial: "#eab308",
|
|
505
|
+
trialBright: "#f5c542",
|
|
506
|
+
error: "#f08a8a",
|
|
507
|
+
errorStrong: "#dc5050",
|
|
508
|
+
warningText: color("#f59e8b"),
|
|
509
|
+
white: color("#ffffff"),
|
|
510
|
+
transparent: "00000000"
|
|
511
|
+
};
|
|
512
|
+
function fontFor(theme, weight, mono = false) {
|
|
513
|
+
var _a;
|
|
514
|
+
const { regular, medium, semibold, mono: monoFont } = theme.fonts;
|
|
515
|
+
if (mono)
|
|
516
|
+
return monoFont != null ? monoFont : regular;
|
|
517
|
+
if (weight >= 600)
|
|
518
|
+
return (_a = semibold != null ? semibold : medium) != null ? _a : regular;
|
|
519
|
+
if (weight === 500)
|
|
520
|
+
return medium != null ? medium : regular;
|
|
521
|
+
return regular;
|
|
522
|
+
}
|
|
523
|
+
function textWidth(text2, size, weight = 400) {
|
|
524
|
+
return Math.ceil(text2.length * size * (weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52));
|
|
525
|
+
}
|
|
526
|
+
function textHeight(text2, size, width, lineHeight = 1.5) {
|
|
527
|
+
let lines = 0;
|
|
528
|
+
for (const paragraph2 of text2.split("\n")) {
|
|
529
|
+
let line = 0;
|
|
530
|
+
lines++;
|
|
531
|
+
for (const word of paragraph2.split(" ")) {
|
|
532
|
+
const length = textWidth(`${word} `, size);
|
|
533
|
+
if (line > 0 && line + length > width) {
|
|
534
|
+
lines++;
|
|
535
|
+
line = 0;
|
|
536
|
+
}
|
|
537
|
+
line += length;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return Math.ceil(lines * size * lineHeight);
|
|
541
|
+
}
|
|
542
|
+
var keys = 0;
|
|
543
|
+
function label(props, ...children) {
|
|
544
|
+
var _a;
|
|
545
|
+
return h("geLabel", { key: (_a = props.key) != null ? _a : `mb-${keys++}`, interceptsMouseClicks: false, ...props }, ...children);
|
|
546
|
+
}
|
|
547
|
+
function text(theme, value, x, y, width, options = {}) {
|
|
548
|
+
var _a, _b, _c, _d, _e, _f;
|
|
549
|
+
const size = (_a = options.size) != null ? _a : 14;
|
|
550
|
+
const height = textHeight(value, size, width, options.lineHeight);
|
|
551
|
+
const multiLine = height > size * ((_b = options.lineHeight) != null ? _b : 1.5) * 1.2;
|
|
552
|
+
return label({
|
|
553
|
+
x,
|
|
554
|
+
y,
|
|
555
|
+
width,
|
|
556
|
+
height: (_c = options.height) != null ? _c : Math.max(height, Math.ceil(size * 1.5)),
|
|
557
|
+
text: value,
|
|
558
|
+
font: fontFor(theme, (_d = options.weight) != null ? _d : 400, options.mono),
|
|
559
|
+
fontSize: size,
|
|
560
|
+
fontKerning: (_e = options.kerning) != null ? _e : 0,
|
|
561
|
+
textColor: (_f = options.textColor) != null ? _f : palette.textSecondary,
|
|
562
|
+
textAlign: multiLine ? options.align === "center" ? "top center" : options.align === "right" ? "top right" : "top left" : options.align === "center" ? "center" : options.align === "right" ? "centered right" : "centered left",
|
|
563
|
+
multiLine
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function space(height) {
|
|
567
|
+
return { height, render: () => null };
|
|
568
|
+
}
|
|
569
|
+
function stack(blocks, x, y, width) {
|
|
570
|
+
const nodes = [];
|
|
571
|
+
let top = y;
|
|
572
|
+
for (const block of blocks) {
|
|
573
|
+
if (!block)
|
|
574
|
+
continue;
|
|
575
|
+
nodes.push(block.render(x, top, width));
|
|
576
|
+
top += block.height;
|
|
577
|
+
}
|
|
578
|
+
return { nodes, height: top - y };
|
|
579
|
+
}
|
|
580
|
+
function paragraph(theme, value, width, options = {}) {
|
|
581
|
+
var _a, _b, _c;
|
|
582
|
+
const size = (_a = options.size) != null ? _a : 14;
|
|
583
|
+
const boxWidth = Math.min(width, (_b = options.maxWidth) != null ? _b : width);
|
|
584
|
+
const height = Math.max(textHeight(value, size, boxWidth, options.lineHeight), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
|
|
585
|
+
return {
|
|
586
|
+
height,
|
|
587
|
+
render: (x, y, available) => {
|
|
588
|
+
const left = options.align === "center" ? x + (available - boxWidth) / 2 : x;
|
|
589
|
+
return text(theme, value, left, y, boxWidth, { textColor: palette.textSecondary, ...options });
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function heading(theme, value, width, options = {}) {
|
|
594
|
+
return paragraph(theme, value, width, { size: options.large ? 27 : 24, weight: 600, textColor: palette.textPrimary, lineHeight: 1.25, align: options.align });
|
|
595
|
+
}
|
|
596
|
+
function Button(props) {
|
|
597
|
+
var _a, _b, _c;
|
|
598
|
+
const [hovered, setHovered] = React.useState(false);
|
|
599
|
+
const kind = (_a = props.kind) != null ? _a : "primary";
|
|
600
|
+
const accent = props.theme.accent;
|
|
601
|
+
const looks = {
|
|
602
|
+
"primary": { background: color(accent), hover: color(accent, 0.88), textColor: palette.white, weight: 600 },
|
|
603
|
+
"small-primary": { background: color(accent), hover: color(accent, 0.88), textColor: palette.white, weight: 600 },
|
|
604
|
+
"ghost": { background: palette.ghost, hover: palette.ghostHover, border: palette.ghostBorder, textColor: palette.textPrimary, weight: 500 },
|
|
605
|
+
"small-ghost": { background: palette.ghost, hover: palette.ghostHover, border: palette.ghostBorder, textColor: palette.textPrimary, weight: 500 },
|
|
606
|
+
"danger": { background: color(palette.errorStrong, 0.08), hover: color(palette.errorStrong, 0.16), border: color(palette.errorStrong, 0.3), textColor: color(palette.error), weight: 500 },
|
|
607
|
+
"quiet": { background: palette.ghost, hover: palette.ghostHover, border: palette.ghostBorder, textColor: palette.textBody, weight: 500 }
|
|
608
|
+
};
|
|
609
|
+
const look = looks[kind];
|
|
610
|
+
const small = kind.startsWith("small") || kind === "danger" || kind === "quiet";
|
|
611
|
+
return label({
|
|
612
|
+
x: props.x,
|
|
613
|
+
y: props.y,
|
|
614
|
+
width: props.width,
|
|
615
|
+
height: props.height,
|
|
616
|
+
text: props.label,
|
|
617
|
+
font: fontFor(props.theme, look.weight),
|
|
618
|
+
fontSize: (_b = props.size) != null ? _b : small ? 12.5 : 14,
|
|
619
|
+
textColor: look.textColor,
|
|
620
|
+
textAlign: "center",
|
|
621
|
+
backgroundColor: hovered && !props.disabled ? look.hover : look.background,
|
|
622
|
+
cornerRadius: small ? 8 : 9,
|
|
623
|
+
border: { width: look.border ? 1 : 0, color: (_c = look.border) != null ? _c : palette.transparent },
|
|
624
|
+
alpha: props.disabled ? 0.5 : 1,
|
|
625
|
+
interceptsMouseClicks: true,
|
|
626
|
+
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
627
|
+
onMouseEnter: () => setHovered(true),
|
|
628
|
+
onMouseExit: () => setHovered(false),
|
|
629
|
+
onClick: () => {
|
|
630
|
+
if (!props.disabled)
|
|
631
|
+
props.onClick();
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function buttonBlock(theme, value, onClick, options = {}) {
|
|
636
|
+
var _a;
|
|
637
|
+
const height = (_a = options.height) != null ? _a : 46;
|
|
638
|
+
return {
|
|
639
|
+
height,
|
|
640
|
+
render: (x, y, available) => {
|
|
641
|
+
var _a2;
|
|
642
|
+
const width = Math.min(available, (_a2 = options.width) != null ? _a2 : available);
|
|
643
|
+
const left = options.align === "center" ? x + (available - width) / 2 : x;
|
|
644
|
+
return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, onClick });
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function Link(props) {
|
|
649
|
+
var _a, _b;
|
|
650
|
+
const [hovered, setHovered] = React.useState(false);
|
|
651
|
+
const size = (_a = props.size) != null ? _a : 12.5;
|
|
652
|
+
const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
|
|
653
|
+
const base = props.link ? palette.link : palette.textSecondary;
|
|
654
|
+
const hover = props.link ? palette.linkHover : palette.textBright;
|
|
655
|
+
return label({
|
|
656
|
+
x: props.x,
|
|
657
|
+
y: props.y,
|
|
658
|
+
width,
|
|
659
|
+
height: Math.ceil(size * 1.6),
|
|
660
|
+
text: props.label,
|
|
661
|
+
font: fontFor(props.theme, 500),
|
|
662
|
+
fontSize: size,
|
|
663
|
+
textColor: hovered && !props.disabled ? hover : base,
|
|
664
|
+
textAlign: props.align === "center" ? "center" : "centered left",
|
|
665
|
+
alpha: props.disabled ? 0.55 : 1,
|
|
666
|
+
interceptsMouseClicks: true,
|
|
667
|
+
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
668
|
+
onMouseEnter: () => setHovered(true),
|
|
669
|
+
onMouseExit: () => setHovered(false),
|
|
670
|
+
onClick: () => {
|
|
671
|
+
if (!props.disabled)
|
|
672
|
+
props.onClick();
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
function linksBlock(theme, links, options = {}) {
|
|
677
|
+
var _a;
|
|
678
|
+
const items = links.filter((link) => !!link);
|
|
679
|
+
if (!items.length)
|
|
680
|
+
return null;
|
|
681
|
+
const size = 12.5;
|
|
682
|
+
const gap = 18;
|
|
683
|
+
const marginTop = (_a = options.marginTop) != null ? _a : 14;
|
|
684
|
+
return {
|
|
685
|
+
height: marginTop + Math.ceil(size * 1.6),
|
|
686
|
+
render: (x, y, width) => {
|
|
687
|
+
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);
|
|
689
|
+
let left = options.align === "left" ? x : x + (width - total) / 2;
|
|
690
|
+
return items.map((item, index) => {
|
|
691
|
+
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 });
|
|
692
|
+
left += widths[index] + gap;
|
|
693
|
+
return node;
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function pill(theme, tone, value, x, y, onClick) {
|
|
699
|
+
const upper = tone === "trial" || tone === "expired" || tone === "upgrade";
|
|
700
|
+
const shown = upper ? value.toUpperCase() : value;
|
|
701
|
+
const size = upper ? 10.5 : 11.5;
|
|
702
|
+
const dot = tone === "expired" || tone === "upgrade" || tone === "active";
|
|
703
|
+
const width = Math.ceil(textWidth(shown, size, 700) * (upper ? 1.18 : 1) + (upper ? shown.length * size * 0.08 : 0)) + 24 + (dot ? 12 : 0);
|
|
704
|
+
const height = 24;
|
|
705
|
+
const looks = {
|
|
706
|
+
trial: { background: color(palette.trial), border: palette.transparent, textColor: color("#131519") },
|
|
707
|
+
expired: { background: color(palette.errorStrong, 0.12), border: color(palette.errorStrong, 0.32), textColor: color(palette.error) },
|
|
708
|
+
upgrade: { background: color(palette.trial, 0.12), border: color(palette.trial, 0.32), textColor: color(palette.trialBright) },
|
|
709
|
+
active: { background: color(palette.successDeep, 0.12), border: color(palette.successDeep, 0.3), textColor: color(palette.success) },
|
|
710
|
+
update: { background: color(theme.accent, 0.16), border: color(theme.accent, 0.4), textColor: palette.textPrimary }
|
|
711
|
+
};
|
|
712
|
+
const look = looks[tone];
|
|
713
|
+
const node = label({
|
|
714
|
+
key: `pill-${tone}`,
|
|
715
|
+
x,
|
|
716
|
+
y,
|
|
717
|
+
width,
|
|
718
|
+
height,
|
|
719
|
+
backgroundColor: look.background,
|
|
720
|
+
cornerRadius: height / 2,
|
|
721
|
+
border: { width: 1, color: look.border },
|
|
722
|
+
interceptsMouseClicks: !!onClick,
|
|
723
|
+
mouseCursorType: onClick ? "pointing hand" : "normal",
|
|
724
|
+
...onClick && { onClick }
|
|
725
|
+
}, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), label({
|
|
726
|
+
x: dot ? 22 : 10,
|
|
727
|
+
y: 0,
|
|
728
|
+
width: width - (dot ? 32 : 20),
|
|
729
|
+
height,
|
|
730
|
+
text: shown,
|
|
731
|
+
font: fontFor(theme, 700),
|
|
732
|
+
fontSize: size,
|
|
733
|
+
fontKerning: upper ? 0.08 : 0.02,
|
|
734
|
+
textColor: look.textColor,
|
|
735
|
+
textAlign: "center"
|
|
736
|
+
}));
|
|
737
|
+
return { node, width };
|
|
738
|
+
}
|
|
739
|
+
function card(props, ...children) {
|
|
740
|
+
var _a, _b, _c;
|
|
741
|
+
return label({
|
|
742
|
+
x: props.x,
|
|
743
|
+
y: props.y,
|
|
744
|
+
width: props.width,
|
|
745
|
+
height: props.height,
|
|
746
|
+
backgroundColor: (_a = props.background) != null ? _a : palette.card,
|
|
747
|
+
cornerRadius: (_b = props.radius) != null ? _b : 12,
|
|
748
|
+
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
|
|
749
|
+
interceptsMouseClicks: !!props.onClick,
|
|
750
|
+
...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
|
|
751
|
+
}, ...children);
|
|
752
|
+
}
|
|
753
|
+
function barBlock(fraction, fill, options = {}) {
|
|
754
|
+
var _a, _b;
|
|
755
|
+
const marginTop = (_a = options.marginTop) != null ? _a : 14;
|
|
756
|
+
return {
|
|
757
|
+
height: marginTop + 6 + ((_b = options.marginBottom) != null ? _b : 24),
|
|
758
|
+
render: (x, y, width) => label({ x, y: y + marginTop, width, height: 6, cornerRadius: 3, backgroundColor: color("#ffffff", 0.07) }, fraction > 0 && label({ x: 0, y: 0, width: Math.max(6, Math.round(width * Math.min(1, fraction))), height: 6, cornerRadius: 3, backgroundColor: fill }))
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
function useTick(interval) {
|
|
762
|
+
const [tick, setTick] = React.useState(0);
|
|
763
|
+
React.useEffect(() => {
|
|
764
|
+
const timer = setInterval(() => setTick((value) => value + 1), interval);
|
|
765
|
+
return () => clearInterval(timer);
|
|
766
|
+
}, [interval]);
|
|
767
|
+
return tick;
|
|
768
|
+
}
|
|
769
|
+
function Spinner(props) {
|
|
770
|
+
const tick = useTick(90);
|
|
771
|
+
const dots = 10;
|
|
772
|
+
const dot = Math.max(3, Math.round(props.size / 8));
|
|
773
|
+
const radius = props.size / 2 - dot / 2;
|
|
774
|
+
return label({ x: props.x, y: props.y, width: props.size, height: props.size }, ...Array.from({ length: dots }, (_, index) => {
|
|
775
|
+
const angle = index / dots * Math.PI * 2 - Math.PI / 2;
|
|
776
|
+
const age = (tick - index + dots * 100) % dots;
|
|
777
|
+
return label({
|
|
778
|
+
key: `dot-${index}`,
|
|
779
|
+
x: Math.round(props.size / 2 + Math.cos(angle) * radius - dot / 2),
|
|
780
|
+
y: Math.round(props.size / 2 + Math.sin(angle) * radius - dot / 2),
|
|
781
|
+
width: dot,
|
|
782
|
+
height: dot,
|
|
783
|
+
cornerRadius: dot / 2,
|
|
784
|
+
backgroundColor: color(props.tint, Math.max(0.15, 1 - age / dots))
|
|
785
|
+
});
|
|
786
|
+
}));
|
|
787
|
+
}
|
|
788
|
+
function mark(theme, x, y, size, logo, dim = false) {
|
|
789
|
+
if (logo)
|
|
790
|
+
return label({ key: "mark", x, y, width: size, height: size, backgroundImage: logo, alpha: dim ? 0.55 : 1 });
|
|
791
|
+
const tint = dim ? color("#768aa4", 0.6) : color(theme.accent);
|
|
792
|
+
const unit = size / 38;
|
|
793
|
+
const ring = Math.round(26 * unit);
|
|
794
|
+
const center = size / 2;
|
|
795
|
+
const rays = Array.from({ length: 8 }, (_, index) => {
|
|
796
|
+
const angle = index / 8 * Math.PI * 2;
|
|
797
|
+
const distance = 16.5 * unit;
|
|
798
|
+
const length = Math.max(2, Math.round((index % 2 === 0 ? 4.5 : 3) * unit));
|
|
799
|
+
const width = Math.max(2, Math.round(2 * unit));
|
|
800
|
+
const horizontal = index % 4 === 2;
|
|
801
|
+
const diagonal = index % 2 === 1;
|
|
802
|
+
const w = diagonal ? width + 1 : horizontal ? length : width;
|
|
803
|
+
const hgt = diagonal ? width + 1 : horizontal ? width : length;
|
|
804
|
+
return label({
|
|
805
|
+
key: `ray-${index}`,
|
|
806
|
+
x: Math.round(center + Math.sin(angle) * distance - w / 2),
|
|
807
|
+
y: Math.round(center - Math.cos(angle) * distance - hgt / 2),
|
|
808
|
+
width: w,
|
|
809
|
+
height: hgt,
|
|
810
|
+
cornerRadius: Math.min(w, hgt) / 2,
|
|
811
|
+
backgroundColor: tint
|
|
812
|
+
});
|
|
813
|
+
});
|
|
814
|
+
return label({ key: "mark", x, y, width: size, height: size }, label({ x: Math.round(center - ring / 2), y: Math.round(center - ring / 2), width: ring, height: ring, cornerRadius: ring / 2, border: { width: Math.max(1.5, 2 * unit), color: tint }, backgroundColor: palette.transparent }), label({ x: Math.round(center - 4.5 * unit), y: Math.round(center - 4.5 * unit), width: Math.round(9 * unit), height: Math.round(9 * unit), cornerRadius: 4.5 * unit, backgroundColor: tint }), ...rays);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// src/MoonbaseActivation.ts
|
|
818
|
+
var CARD_WIDTH = 620;
|
|
819
|
+
var PAD_X = 40;
|
|
820
|
+
var PAD_TOP = 34;
|
|
821
|
+
var PAD_BOTTOM = 22;
|
|
822
|
+
function useMoonbaseState(moonbase) {
|
|
823
|
+
const [state, setState] = React2.useState(() => moonbase.state());
|
|
824
|
+
React2.useEffect(() => {
|
|
825
|
+
setState(moonbase.state());
|
|
826
|
+
return moonbase.subscribe(setState);
|
|
827
|
+
}, [moonbase]);
|
|
828
|
+
return state;
|
|
829
|
+
}
|
|
830
|
+
function useUiState(moonbase) {
|
|
831
|
+
const [ui, setUi] = React2.useState(() => moonbase.uiSnapshot());
|
|
832
|
+
React2.useEffect(() => {
|
|
833
|
+
setUi(moonbase.uiSnapshot());
|
|
834
|
+
return moonbase.subscribeUi(() => setUi(moonbase.uiSnapshot()));
|
|
835
|
+
}, [moonbase]);
|
|
836
|
+
return ui;
|
|
837
|
+
}
|
|
838
|
+
function statusView(state) {
|
|
839
|
+
switch (state.status) {
|
|
840
|
+
case "unlicensed":
|
|
841
|
+
return "welcome";
|
|
842
|
+
case "activating":
|
|
843
|
+
return "browser";
|
|
844
|
+
case "licensed":
|
|
845
|
+
return "details";
|
|
846
|
+
case "trial":
|
|
847
|
+
return "trial";
|
|
848
|
+
case "trialExpired":
|
|
849
|
+
return "expired";
|
|
850
|
+
case "notCovered":
|
|
851
|
+
return "notCovered";
|
|
852
|
+
default:
|
|
853
|
+
return "loading";
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function droppedFiles(dropped) {
|
|
857
|
+
if (typeof dropped === "string")
|
|
858
|
+
return [dropped];
|
|
859
|
+
if (Array.isArray(dropped))
|
|
860
|
+
return dropped.filter((file) => typeof file === "string");
|
|
861
|
+
const files = dropped == null ? void 0 : dropped.files;
|
|
862
|
+
return Array.isArray(files) ? files.filter((file) => typeof file === "string") : [];
|
|
863
|
+
}
|
|
864
|
+
function Panel({ moonbase, state, screen, request, download, width: areaWidth, height: areaHeight }) {
|
|
865
|
+
var _a, _b, _c, _d, _e;
|
|
866
|
+
const ui = moonbase.ui;
|
|
867
|
+
const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {} };
|
|
868
|
+
const product = (_c = ui.productName) != null ? _c : "the plugin";
|
|
869
|
+
const account = ui.manufacturerName || "Moonbase";
|
|
870
|
+
const strings = (_d = ui.strings) != null ? _d : {};
|
|
871
|
+
const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
|
|
872
|
+
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
|
+
});
|
|
882
|
+
};
|
|
883
|
+
const close = () => moonbase.closeUi();
|
|
884
|
+
const canClose = state.status !== "activating" && state.status !== "loading" && state.licensed;
|
|
885
|
+
const loadUpdate = () => {
|
|
886
|
+
setUpdate(null);
|
|
887
|
+
moonbase.checkUpdate().then(setUpdate, (err) => setUpdate({ available: false, error: err instanceof Error ? err.message : String(err) }));
|
|
888
|
+
};
|
|
889
|
+
const go = (next) => {
|
|
890
|
+
setView(next);
|
|
891
|
+
if (next === "update")
|
|
892
|
+
loadUpdate();
|
|
893
|
+
if (next === "addons")
|
|
894
|
+
run2(() => moonbase.loadAddOns());
|
|
895
|
+
};
|
|
896
|
+
const openUpdate = (fromDetails) => {
|
|
897
|
+
setCameFromDetails(fromDetails);
|
|
898
|
+
go("update");
|
|
899
|
+
};
|
|
900
|
+
const flashCopied = (what) => {
|
|
901
|
+
setCopied(what);
|
|
902
|
+
setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
|
|
903
|
+
};
|
|
904
|
+
React2.useEffect(() => {
|
|
905
|
+
if (screen === "update")
|
|
906
|
+
return openUpdate(false);
|
|
907
|
+
let next = screen === "license" ? "details" : screen;
|
|
908
|
+
if ((next === "details" || next === "addons") && !moonbase.state().license)
|
|
909
|
+
next = null;
|
|
910
|
+
go(next);
|
|
911
|
+
}, [request]);
|
|
912
|
+
React2.useEffect(() => {
|
|
913
|
+
var _a2;
|
|
914
|
+
const before = previous.current;
|
|
915
|
+
previous.current = state;
|
|
916
|
+
let next = view;
|
|
917
|
+
const activated = (before == null ? void 0 : before.status) === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a2 = before.license) == null ? void 0 : _a2.activationId);
|
|
918
|
+
if (activated)
|
|
919
|
+
next = "success";
|
|
920
|
+
if ((next === "details" || next === "addons" || next === "update") && !state.license)
|
|
921
|
+
next = null;
|
|
922
|
+
if (state.status === "activating")
|
|
923
|
+
next = null;
|
|
924
|
+
if (state.status === "notCovered" && (before == null ? void 0 : before.status) !== "notCovered")
|
|
925
|
+
next = null;
|
|
926
|
+
if (next === "success" && !state.license)
|
|
927
|
+
next = null;
|
|
928
|
+
if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
|
|
929
|
+
run2(() => moonbase.loadAddOns());
|
|
930
|
+
if (next !== view)
|
|
931
|
+
setView(next);
|
|
932
|
+
}, [state]);
|
|
933
|
+
const name = view != null ? view : statusView(state);
|
|
934
|
+
const lockup = (options = {}) => {
|
|
935
|
+
const size = options.large ? 38 : 34;
|
|
936
|
+
return {
|
|
937
|
+
height: size,
|
|
938
|
+
render: (x, y) => label({ key: "lockup", x, y, width: 320, height: size }, mark(theme, 0, 0, size, ui.logo, options.dim), text(theme, product, size + 13, ui.manufacturerName ? 0 : (size - 22) / 2, 260, { size: options.large ? 17 : 15, weight: 600, textColor: palette.textPrimary }), ui.manufacturerName && text(theme, ui.manufacturerName, size + 13, options.large ? 22 : 20, 260, { size: 11, kerning: 0.04, textColor: palette.textSecondary }))
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
const header = (pills, options = {}) => ({
|
|
942
|
+
height: 34 + 26,
|
|
943
|
+
render: (x, y, available) => {
|
|
944
|
+
const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
|
|
945
|
+
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);
|
|
948
|
+
right -= drawn.width;
|
|
949
|
+
nodes.push(pill(theme, each.tone, each.text, right, y + 5, each.onClick).node);
|
|
950
|
+
right -= 8;
|
|
951
|
+
}
|
|
952
|
+
return nodes;
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
const errorLine = (message) => {
|
|
956
|
+
if (!message)
|
|
957
|
+
return null;
|
|
958
|
+
const body = paragraph(theme, `\u26A0 ${message}`, width, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
|
|
959
|
+
return { height: 14 + body.height, render: (x, y, available) => body.render(x, y + 14, available) };
|
|
960
|
+
};
|
|
961
|
+
const backLink = (value, onClick) => ({
|
|
962
|
+
height: 20 + 20,
|
|
963
|
+
render: (x, y) => h(LinkNode, { key: "back", theme, x, y, value: `\u2039 ${value}`, onClick })
|
|
964
|
+
});
|
|
965
|
+
const notice = (value, tone) => {
|
|
966
|
+
const body = paragraph(theme, value, width - 58, { size: 13, textColor: palette.textBody, lineHeight: 1.5 });
|
|
967
|
+
const height = body.height + 26;
|
|
968
|
+
const tint = tone === "upgrade" ? palette.trial : palette.errorStrong;
|
|
969
|
+
return {
|
|
970
|
+
height: height + 24,
|
|
971
|
+
render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, text(theme, tone === "upgrade" ? "\u26A0" : "\u2298", 15, 12, 20, { size: 15, textColor: color(tone === "upgrade" ? palette.trial : palette.error) }), body.render(44, 13, width - 58))
|
|
972
|
+
};
|
|
973
|
+
};
|
|
974
|
+
const features = () => {
|
|
975
|
+
var _a2;
|
|
976
|
+
const list = (_a2 = ui.trialFeatures) != null ? _a2 : [];
|
|
977
|
+
if (!list.length)
|
|
978
|
+
return null;
|
|
979
|
+
return {
|
|
980
|
+
height: list.length * 30 - 11 + 26,
|
|
981
|
+
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
|
+
};
|
|
983
|
+
};
|
|
984
|
+
const unlock = () => buttonBlock(theme, "Unlock full version", () => run2(() => moonbase.activate()));
|
|
985
|
+
const screens = {
|
|
986
|
+
loading: () => [
|
|
987
|
+
{ height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
|
|
988
|
+
space(18),
|
|
989
|
+
paragraph(theme, "Checking your license\u2026", width, { align: "center" }),
|
|
990
|
+
space(10)
|
|
991
|
+
],
|
|
992
|
+
welcome: () => {
|
|
993
|
+
var _a2;
|
|
994
|
+
const [title, body] = welcomeCopy(state.lockReason, strings, product, account);
|
|
995
|
+
return [
|
|
996
|
+
lockup({ large: true }),
|
|
997
|
+
space(30),
|
|
998
|
+
heading(theme, title, width, { large: true }),
|
|
999
|
+
space(8),
|
|
1000
|
+
paragraph(theme, body, width, { maxWidth: 430 }),
|
|
1001
|
+
space(28),
|
|
1002
|
+
buttonBlock(theme, strings.activateOnline || "Activate online", () => run2(() => moonbase.activate()), { width: 340, height: 44 }),
|
|
1003
|
+
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1004
|
+
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1005
|
+
];
|
|
1006
|
+
},
|
|
1007
|
+
browser: () => {
|
|
1008
|
+
var _a2, _b2, _c2, _d2;
|
|
1009
|
+
const url = (_b2 = (_a2 = state.activation) == null ? void 0 : _a2.browserUrl) != null ? _b2 : null;
|
|
1010
|
+
let host = "";
|
|
1011
|
+
try {
|
|
1012
|
+
host = url ? new URL(url).host : "";
|
|
1013
|
+
} catch (e) {
|
|
1014
|
+
}
|
|
1015
|
+
const failed = !!url && !!((_c2 = state.activation) == null ? void 0 : _c2.browserOpenFailed);
|
|
1016
|
+
const linkCopied = !!url && copied === url;
|
|
1017
|
+
const copyLink = () => {
|
|
1018
|
+
if (!url)
|
|
1019
|
+
return;
|
|
1020
|
+
moonbase.copyText(url).then(() => flashCopied(url), () => {
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
1023
|
+
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
|
+
return [
|
|
1025
|
+
{ height: 54, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 27, y, size: 54, tint: "#82cef1" }) },
|
|
1026
|
+
space(22),
|
|
1027
|
+
heading(theme, url ? "Waiting for activation" : "Starting activation\u2026", width, { align: "center" }),
|
|
1028
|
+
space(8),
|
|
1029
|
+
paragraph(theme, body, width, { align: "center", maxWidth: 420 }),
|
|
1030
|
+
space(22),
|
|
1031
|
+
failed && buttonBlock(theme, linkCopied ? "\u2713 Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center" }),
|
|
1032
|
+
failed && space(18),
|
|
1033
|
+
!!url && {
|
|
1034
|
+
height: 50,
|
|
1035
|
+
render: (x, y, available) => {
|
|
1036
|
+
const value = `${moonbase.deviceName} \xB7 ${osLabel()}`;
|
|
1037
|
+
const chipWidth = Math.min(available, textWidth(value, 12.5) + 30);
|
|
1038
|
+
return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, text(theme, value, 0, 0, chipWidth, { size: 12.5, textColor: palette.textBright, align: "center", height: 34 }));
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
|
|
1042
|
+
!!url && !failed && linksBlock(theme, [
|
|
1043
|
+
{ label: "Open the page again", onClick: () => run2(() => moonbase.openLink(url)) },
|
|
1044
|
+
{ label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
|
|
1045
|
+
]),
|
|
1046
|
+
errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
|
|
1047
|
+
];
|
|
1048
|
+
},
|
|
1049
|
+
success: () => {
|
|
1050
|
+
const license = state.license;
|
|
1051
|
+
if (!license)
|
|
1052
|
+
return screens[statusView(state)]();
|
|
1053
|
+
const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]];
|
|
1054
|
+
return [
|
|
1055
|
+
{
|
|
1056
|
+
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" }))
|
|
1058
|
+
},
|
|
1059
|
+
space(22),
|
|
1060
|
+
heading(theme, license.trial ? "Your trial has started" : "You're all set", width, { align: "center" }),
|
|
1061
|
+
space(8),
|
|
1062
|
+
paragraph(theme, license.trial ? `Enjoy ${product}${license.daysRemaining !== null ? ` for the next ${license.daysRemaining} days` : ""}. Unlock the full version any time.` : `${product} is activated on this machine. Your license is linked to your account.`, width, { align: "center", maxWidth: 380 }),
|
|
1063
|
+
space(24),
|
|
1064
|
+
{
|
|
1065
|
+
height: rows.length * 34 + 32 + 26,
|
|
1066
|
+
render: (x, y, available) => {
|
|
1067
|
+
const cardWidth2 = Math.min(380, available);
|
|
1068
|
+
return card({ x: x + (available - cardWidth2) / 2, y, width: cardWidth2, height: rows.length * 34 + 32 }, ...rows.map(([key, value], index) => label({ key, x: 18, y: 16 + index * 34, width: cardWidth2 - 36, height: 34 }, text(theme, key, 0, 0, 120, { size: 12.5, height: 34 }), text(theme, value, 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
buttonBlock(theme, `Open ${product}`, close, { width: 380, align: "center" }),
|
|
1072
|
+
linksBlock(theme, [{ label: "View license details", link: true, onClick: () => go("details") }])
|
|
1073
|
+
];
|
|
1074
|
+
},
|
|
1075
|
+
offline: () => {
|
|
1076
|
+
const saveSub = offline.saved ? `Saved to ${offline.saved}` : "Choose where to save it";
|
|
1077
|
+
const requestFile = `${(product || "license").replace(/[\\/:*?"<>|]/g, "-")}.dt`;
|
|
1078
|
+
const saveRequest = () => {
|
|
1079
|
+
setOffline((current) => ({ ...current, error: "" }));
|
|
1080
|
+
moonbase.saveMachineFile().then(
|
|
1081
|
+
(saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
|
|
1082
|
+
(err) => setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }))
|
|
1083
|
+
);
|
|
1084
|
+
};
|
|
1085
|
+
const useFile = (pick) => {
|
|
1086
|
+
pick.then(
|
|
1087
|
+
(file) => file && setOffline((current) => ({ ...current, file, error: "" })),
|
|
1088
|
+
() => setOffline((current) => ({ ...current, error: "Couldn't read that file." }))
|
|
1089
|
+
);
|
|
1090
|
+
};
|
|
1091
|
+
const activateOffline = () => {
|
|
1092
|
+
if (offline.busy)
|
|
1093
|
+
return;
|
|
1094
|
+
if (!offline.file) {
|
|
1095
|
+
setOffline((current) => ({ ...current, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
setOffline((current) => ({ ...current, busy: true, error: "" }));
|
|
1099
|
+
moonbase.activateOffline(offline.file.text).then(() => {
|
|
1100
|
+
setOffline({ saved: null, file: null, busy: false, error: "" });
|
|
1101
|
+
setView("success");
|
|
1102
|
+
}, () => {
|
|
1103
|
+
setOffline((current) => {
|
|
1104
|
+
var _a2;
|
|
1105
|
+
return { ...current, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
|
|
1106
|
+
});
|
|
1107
|
+
});
|
|
1108
|
+
};
|
|
1109
|
+
const step = (n, value) => ({
|
|
1110
|
+
height: 20 + 11,
|
|
1111
|
+
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
|
+
});
|
|
1113
|
+
return [
|
|
1114
|
+
backLink("Back", () => go(null)),
|
|
1115
|
+
heading(theme, "Offline activation", width),
|
|
1116
|
+
space(8),
|
|
1117
|
+
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(24),
|
|
1119
|
+
step("1", "Save your request file"),
|
|
1120
|
+
{
|
|
1121
|
+
height: 58 + 22,
|
|
1122
|
+
render: (x, y) => card({ x, y, width, height: 58, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, text(theme, requestFile, 16, 10, width - 120, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 16, 30, width - 120, { size: 11.5, textColor: palette.textSecondary }), text(theme, offline.saved ? "\u2713" : "Save\u2026", width - 80, 0, 64, { size: offline.saved ? 18 : 12.5, weight: 600, textColor: offline.saved ? color(palette.success) : palette.link, align: "right", height: 58 }))
|
|
1123
|
+
},
|
|
1124
|
+
step("2", "Add the license file"),
|
|
1125
|
+
{
|
|
1126
|
+
height: 96,
|
|
1127
|
+
render: (x, y) => h("geDropZone", {
|
|
1128
|
+
key: "drop",
|
|
1129
|
+
x,
|
|
1130
|
+
y,
|
|
1131
|
+
width,
|
|
1132
|
+
height: 96,
|
|
1133
|
+
onDroppedFiles: (dropped) => {
|
|
1134
|
+
const file = droppedFiles(dropped)[0];
|
|
1135
|
+
if (file)
|
|
1136
|
+
useFile(moonbase.readLicenseFile(file));
|
|
1137
|
+
}
|
|
1138
|
+
}, card({ x: 0, y: 0, width, height: 96, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, text(theme, offline.file ? offline.file.name : "Drop your license file here", 0, 26, width, { size: 13, weight: 600, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody, align: "center" }), text(theme, offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb", 0, 50, width, { size: 11.5, textColor: palette.textSecondary, align: "center" })))
|
|
1139
|
+
},
|
|
1140
|
+
errorLine(offline.error),
|
|
1141
|
+
space(22),
|
|
1142
|
+
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy })
|
|
1143
|
+
];
|
|
1144
|
+
},
|
|
1145
|
+
trial: () => {
|
|
1146
|
+
var _a2, _b2;
|
|
1147
|
+
const license = state.license;
|
|
1148
|
+
const left2 = license.daysRemaining;
|
|
1149
|
+
const total = trialLength(license, (_a2 = ui.trialLengthDays) != null ? _a2 : 14);
|
|
1150
|
+
const endless = left2 === null;
|
|
1151
|
+
return [
|
|
1152
|
+
header([{ tone: "trial", text: endless ? "Trial" : `Trial \xB7 ${left2} ${left2 === 1 ? "day" : "days"} left` }]),
|
|
1153
|
+
heading(theme, "You're on a free trial", width),
|
|
1154
|
+
space(8),
|
|
1155
|
+
paragraph(theme, endless ? "Unlock the full version any time to keep everything." : `${left2} of ${total} days remaining. Unlock the full version any time to keep everything.`, width),
|
|
1156
|
+
endless ? space(26) : barBlock(left2 / total, color(palette.trial)),
|
|
1157
|
+
features(),
|
|
1158
|
+
unlock(),
|
|
1159
|
+
errorLine((_b2 = state.error) == null ? void 0 : _b2.message),
|
|
1160
|
+
linksBlock(theme, [{ label: "Continue trial", onClick: close }, { label: "License details", onClick: () => go("details") }])
|
|
1161
|
+
];
|
|
1162
|
+
},
|
|
1163
|
+
expired: () => {
|
|
1164
|
+
var _a2, _b2;
|
|
1165
|
+
const trial = state.expiredTrial;
|
|
1166
|
+
const days = trialLength(trial, (_a2 = ui.trialLengthDays) != null ? _a2 : 14);
|
|
1167
|
+
return [
|
|
1168
|
+
header([{ tone: "expired", text: "Trial expired" }], { dim: true }),
|
|
1169
|
+
heading(theme, "Your trial has ended", width),
|
|
1170
|
+
space(8),
|
|
1171
|
+
paragraph(theme, (trial == null ? void 0 : trial.expiresAt) ? `Your ${days}-day trial of ${product} ended on ${formatDate(trial.expiresAt)}. Unlock the full version to keep using it.` : `Your trial of ${product} has ended. Unlock the full version to keep using it.`, width),
|
|
1172
|
+
barBlock(1, color(palette.errorStrong, 0.7), { marginBottom: 22 }),
|
|
1173
|
+
notice(strings.expiredNotice || `${product}'s full features are locked until it is activated. Your work is safe and opens as usual.`, "error"),
|
|
1174
|
+
unlock(),
|
|
1175
|
+
errorLine((_b2 = state.error) == null ? void 0 : _b2.message),
|
|
1176
|
+
linksBlock(theme, [{ label: "Activate offline instead", onClick: () => go("offline") }])
|
|
1177
|
+
];
|
|
1178
|
+
},
|
|
1179
|
+
notCovered: () => {
|
|
1180
|
+
var _a2;
|
|
1181
|
+
const info = state.notCovered;
|
|
1182
|
+
const access = info == null ? void 0 : info.releaseAccess;
|
|
1183
|
+
const renewal = !!(access == null ? void 0 : access.updatesUntil);
|
|
1184
|
+
const offlineLicense = (info == null ? void 0 : info.license.activationMethod) === "Offline";
|
|
1185
|
+
const title = strings.notCoveredTitle || ((info == null ? void 0 : info.appVersion) ? `Version ${info.appVersion} needs an upgrade` : "This version needs an upgrade");
|
|
1186
|
+
const body = strings.notCoveredBody || releaseAccessText(access) || `Your ${product} license doesn't cover this version.`;
|
|
1187
|
+
return [
|
|
1188
|
+
header([{ tone: "upgrade", text: "Upgrade needed" }], { dim: true }),
|
|
1189
|
+
heading(theme, title, width),
|
|
1190
|
+
space(8),
|
|
1191
|
+
paragraph(theme, body, width),
|
|
1192
|
+
space(22),
|
|
1193
|
+
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())),
|
|
1195
|
+
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()) }])
|
|
1197
|
+
];
|
|
1198
|
+
},
|
|
1199
|
+
details: () => {
|
|
1200
|
+
var _a2;
|
|
1201
|
+
const license = state.license;
|
|
1202
|
+
if (!license)
|
|
1203
|
+
return screens[statusView(state)]();
|
|
1204
|
+
const rows = [
|
|
1205
|
+
["Licensed to", license.issuedTo.name || license.issuedTo.email],
|
|
1206
|
+
["Email", license.issuedTo.email],
|
|
1207
|
+
["Plan", `${planName(license)} \xB7 ${license.expiresAt ? `until ${formatDate(license.expiresAt)}` : "perpetual"}`]
|
|
1208
|
+
];
|
|
1209
|
+
const seatCount = license.seatCount;
|
|
1210
|
+
const used = license.seatsUsed;
|
|
1211
|
+
const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
|
|
1212
|
+
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
|
+
const idCopied = copied === license.id;
|
|
1214
|
+
const rowHeight = 44;
|
|
1215
|
+
return [
|
|
1216
|
+
header([
|
|
1217
|
+
...state.update ? [{ tone: "update", text: "\u2193 Update", onClick: () => openUpdate(true) }] : [],
|
|
1218
|
+
{ tone: "active", text: license.trial ? "Trial" : "Active" }
|
|
1219
|
+
]),
|
|
1220
|
+
{
|
|
1221
|
+
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
|
+
}) })))
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
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 < (used != null ? used : 0) ? color(theme.accent) : color("#ffffff", 0.1) })), h(Button, {
|
|
1228
|
+
key: "deactivate",
|
|
1229
|
+
theme,
|
|
1230
|
+
x: width - 16 - 178,
|
|
1231
|
+
y: 15,
|
|
1232
|
+
width: 178,
|
|
1233
|
+
height: 34,
|
|
1234
|
+
kind: "danger",
|
|
1235
|
+
disabled: state.busy,
|
|
1236
|
+
label: state.busy ? "Deactivating\u2026" : license.trial || license.activationMethod === "Offline" ? "Remove from this device" : "Deactivate this device",
|
|
1237
|
+
onClick: () => run2(() => moonbase.deactivate())
|
|
1238
|
+
}))
|
|
1239
|
+
},
|
|
1240
|
+
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1241
|
+
ui.showAddOns && !license.trial && {
|
|
1242
|
+
height: 62 + (state.error ? 14 : 0),
|
|
1243
|
+
render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, text(theme, "Add-ons", 16, 12, width - 80, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 16, 32, width - 80, { size: 12, textColor: palette.textSecondary }), text(theme, "\u203A", width - 36, 0, 20, { size: 22, textColor: palette.textSecondary, align: "center", height: 62 }))
|
|
1244
|
+
}
|
|
1245
|
+
];
|
|
1246
|
+
},
|
|
1247
|
+
addons: () => {
|
|
1248
|
+
var _a2;
|
|
1249
|
+
const license = state.license;
|
|
1250
|
+
if (!license)
|
|
1251
|
+
return screens[statusView(state)]();
|
|
1252
|
+
const info = state.addOns;
|
|
1253
|
+
const loading = info.phase === "loading";
|
|
1254
|
+
const failed = !!info.error && info.addOns.length === 0;
|
|
1255
|
+
const rows = info.addOns.map((entry) => describeAddOn(entry, license, state));
|
|
1256
|
+
const message = info.actionError || (info.addOns.length ? info.error : null);
|
|
1257
|
+
const waiting = !!info.busyId;
|
|
1258
|
+
const rowHeight = 64;
|
|
1259
|
+
const visible = Math.min(rows.length, 4);
|
|
1260
|
+
let list;
|
|
1261
|
+
if (rows.length) {
|
|
1262
|
+
const listHeight = visible * (rowHeight + 10) - 10;
|
|
1263
|
+
list = {
|
|
1264
|
+
height: listHeight,
|
|
1265
|
+
render: (x, y) => {
|
|
1266
|
+
const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), width, rowHeight));
|
|
1267
|
+
return rows.length > visible ? h("geScrollView", { key: "addon-list", x, y, width, height: listHeight }, label({ x: 0, y: 0, width, height: rows.length * (rowHeight + 10) - 10 }, ...content2)) : label({ key: "addon-list", x, y, width, height: listHeight }, ...content2);
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
} else if (info.phase !== "ready") {
|
|
1271
|
+
list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight })) };
|
|
1272
|
+
} else if (failed) {
|
|
1273
|
+
list = (_a2 = errorLine(info.error)) != null ? _a2 : space(0);
|
|
1274
|
+
} else {
|
|
1275
|
+
list = paragraph(theme, `There are no add-ons for ${product} yet.`, width);
|
|
1276
|
+
}
|
|
1277
|
+
return [
|
|
1278
|
+
backLink("License details", () => go("details")),
|
|
1279
|
+
heading(theme, "Add-ons", width),
|
|
1280
|
+
space(8),
|
|
1281
|
+
paragraph(theme, `Everything you can add to ${product}.`, width),
|
|
1282
|
+
space(20),
|
|
1283
|
+
list,
|
|
1284
|
+
errorLine(message),
|
|
1285
|
+
linksBlock(theme, [{
|
|
1286
|
+
label: loading ? "Checking\u2026" : failed ? "Try again" : "Bought an add-on? Refresh",
|
|
1287
|
+
link: true,
|
|
1288
|
+
disabled: loading || waiting,
|
|
1289
|
+
onClick: () => run2(() => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
|
|
1290
|
+
}], { align: "left" })
|
|
1291
|
+
];
|
|
1292
|
+
},
|
|
1293
|
+
update: () => {
|
|
1294
|
+
var _a2, _b2;
|
|
1295
|
+
const back = () => cameFromDetails ? go(null) : close();
|
|
1296
|
+
if (!update) {
|
|
1297
|
+
return [
|
|
1298
|
+
{ height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
|
|
1299
|
+
space(18),
|
|
1300
|
+
paragraph(theme, "Fetching the release notes\u2026", width, { align: "center" })
|
|
1301
|
+
];
|
|
1302
|
+
}
|
|
1303
|
+
if (update.error || !update.available) {
|
|
1304
|
+
return [
|
|
1305
|
+
header([]),
|
|
1306
|
+
heading(theme, `${product} is up to date`, width),
|
|
1307
|
+
space(8),
|
|
1308
|
+
paragraph(theme, update.error ? `Couldn't check for updates: ${update.error}` : "You're on the latest version.", width),
|
|
1309
|
+
linksBlock(theme, [{ label: "Back", onClick: back }])
|
|
1310
|
+
];
|
|
1311
|
+
}
|
|
1312
|
+
const notes = update.releaseNotes.split("\n").map((line) => line.replace(/^\s*[-*•]\s*/, "").trim()).filter(Boolean);
|
|
1313
|
+
const downloading = download.phase === "downloading";
|
|
1314
|
+
const percent = download.progress !== null ? Math.round(download.progress * 100) : null;
|
|
1315
|
+
const notCovered = update.covered === false || download.phase === "notCovered";
|
|
1316
|
+
const access = (_a2 = download.releaseAccess) != null ? _a2 : update.releaseAccess;
|
|
1317
|
+
const upgradeUrl = (_b2 = download.upgradeUrl) != null ? _b2 : update.upgradeUrl;
|
|
1318
|
+
const noteBlocks = notes.map((note) => paragraph(theme, note, width - 70, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
|
|
1319
|
+
const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
|
|
1320
|
+
let action;
|
|
1321
|
+
if (download.phase === "done")
|
|
1322
|
+
action = buttonBlock(theme, "Show in folder", () => run2(() => moonbase.revealUpdate()));
|
|
1323
|
+
else if (notCovered)
|
|
1324
|
+
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2(() => moonbase.upgradeLicense())) : null;
|
|
1325
|
+
else if (update.canDownload)
|
|
1326
|
+
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2(() => moonbase.downloadUpdate()), { disabled: downloading });
|
|
1327
|
+
else
|
|
1328
|
+
action = update.hasDownloads ? unlock() : null;
|
|
1329
|
+
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.";
|
|
1330
|
+
return [
|
|
1331
|
+
lockup(),
|
|
1332
|
+
space(24),
|
|
1333
|
+
{ height: 24 + 14, render: (x, y) => pill(theme, "update", "\u2193 Update available", x, y).node },
|
|
1334
|
+
heading(theme, `${product} ${update.latestVersion} is ready`, width),
|
|
1335
|
+
space(8),
|
|
1336
|
+
paragraph(theme, `You're on ${update.currentVersion || "an earlier version"}. The latest is ${update.latestVersion}${standing}`, width),
|
|
1337
|
+
space(20),
|
|
1338
|
+
notes.length > 0 && {
|
|
1339
|
+
height: notesHeight + 20,
|
|
1340
|
+
render: (x, y) => {
|
|
1341
|
+
let top2 = 44;
|
|
1342
|
+
return card({ x, y, width, height: notesHeight }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), ...noteBlocks.map((block, index) => {
|
|
1343
|
+
const node = label({ key: `note-${index}`, x: 18, y: top2, width: width - 36, height: block.height }, text(theme, "\u2713", 0, 0, 18, { size: 13, weight: 700, textColor: color(theme.accent) }), block.render(28, 0, width - 70));
|
|
1344
|
+
top2 += block.height + 8;
|
|
1345
|
+
return node;
|
|
1346
|
+
}));
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
downloading && barBlock(percent !== null ? percent / 100 : 0.08, color(theme.accent), { marginTop: 0, marginBottom: 14 }),
|
|
1350
|
+
action,
|
|
1351
|
+
download.phase === "done" && !!download.path && { ...paragraph(theme, `Saved to ${download.path}`, width, { size: 12.5, align: "center" }), height: 12 + 20 },
|
|
1352
|
+
notCovered && paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted }),
|
|
1353
|
+
errorLine(download.phase === "failed" ? download.error : null),
|
|
1354
|
+
linksBlock(theme, [
|
|
1355
|
+
{ label: "Remind me later", onClick: back },
|
|
1356
|
+
{ label: "Skip this version", onClick: () => {
|
|
1357
|
+
var _a3;
|
|
1358
|
+
moonbase.skipUpdate((_a3 = update.latestVersion) != null ? _a3 : "").catch(() => {
|
|
1359
|
+
}).then(back);
|
|
1360
|
+
} }
|
|
1361
|
+
])
|
|
1362
|
+
];
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
const addOnActions = {
|
|
1366
|
+
tryIt: { label: "Try free", run: (id) => moonbase.requestSubProductTrial(id) },
|
|
1367
|
+
activate: { label: "Activate", run: (id) => moonbase.activateSubProduct(id) },
|
|
1368
|
+
buy: { label: "Buy", run: (id) => moonbase.buySubProduct(id) }
|
|
1369
|
+
};
|
|
1370
|
+
function addOnRow(row, x, y, rowWidth, rowHeight) {
|
|
1371
|
+
const busyId = state.addOns.busyId;
|
|
1372
|
+
const anyBusy = !!busyId || state.addOns.phase === "loading";
|
|
1373
|
+
const tint = row.tone === "success" ? palette.success : row.tone === "trial" ? palette.trialBright : null;
|
|
1374
|
+
const actions = [row.secondary, row.primary].filter((action) => !!action);
|
|
1375
|
+
let right = rowWidth - 14;
|
|
1376
|
+
const buttons = actions.reverse().map((action) => {
|
|
1377
|
+
const primary = action === row.primary;
|
|
1378
|
+
const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
|
|
1379
|
+
const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
|
|
1380
|
+
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)) });
|
|
1382
|
+
right -= 8;
|
|
1383
|
+
return node;
|
|
1384
|
+
});
|
|
1385
|
+
return card({ x, y, width: rowWidth, height: rowHeight, background: tint ? color(tint, 0.04) : palette.card, border: tint ? color(tint, 0.25) : palette.cardBorder }, label({ x: 16, y: (rowHeight - 38) / 2, width: 38, height: 38, cornerRadius: 10, backgroundColor: tint ? color(tint, 0.12) : color("#ffffff", 0.05), text: row.tone === "success" ? "\u2713" : "\u2726", fontSize: 16, textColor: tint ? color(tint) : palette.textSecondary, textAlign: "center" }), text(theme, row.name, 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, row.status, 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
|
|
1386
|
+
}
|
|
1387
|
+
const blocks = screens[name]();
|
|
1388
|
+
const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
|
|
1389
|
+
const footer = showBadge ? 30 + 18 + 18 : 8;
|
|
1390
|
+
const screenHeight = blocks.reduce((sum, block) => sum + (block ? block.height : 0), 0);
|
|
1391
|
+
const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
|
|
1392
|
+
const scrolls = screenHeight > room;
|
|
1393
|
+
let content;
|
|
1394
|
+
if (scrolls) {
|
|
1395
|
+
const inner = stack(blocks, PAD_X, 0, width);
|
|
1396
|
+
content = { height: room, nodes: [h("geScrollView", { key: "screen", x: 0, y: PAD_TOP, width: cardWidth, height: room }, label({ x: 0, y: 0, width: cardWidth, height: inner.height }, ...inner.nodes))] };
|
|
1397
|
+
} else {
|
|
1398
|
+
content = stack(blocks, PAD_X, PAD_TOP, width);
|
|
1399
|
+
}
|
|
1400
|
+
const cardHeight = PAD_TOP + content.height + footer + PAD_BOTTOM;
|
|
1401
|
+
const top = Math.max(12, Math.round((areaHeight - cardHeight) / 2));
|
|
1402
|
+
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")) }));
|
|
1404
|
+
}
|
|
1405
|
+
function LinkNode(props) {
|
|
1406
|
+
var _a;
|
|
1407
|
+
const [hovered, setHovered] = React2.useState(false);
|
|
1408
|
+
const width = (_a = props.width) != null ? _a : textWidth(props.value, 12.5, 500) + 8;
|
|
1409
|
+
return label({
|
|
1410
|
+
x: props.x,
|
|
1411
|
+
y: props.y,
|
|
1412
|
+
width,
|
|
1413
|
+
height: 20,
|
|
1414
|
+
text: props.value,
|
|
1415
|
+
fontSize: props.muted ? 11 : 12.5,
|
|
1416
|
+
textColor: hovered ? palette.textBright : props.muted ? palette.textMuted : palette.textSecondary,
|
|
1417
|
+
textAlign: props.center ? "center" : "centered left",
|
|
1418
|
+
interceptsMouseClicks: true,
|
|
1419
|
+
mouseCursorType: "pointing hand",
|
|
1420
|
+
onMouseEnter: () => setHovered(true),
|
|
1421
|
+
onMouseExit: () => setHovered(false),
|
|
1422
|
+
onClick: props.onClick
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
function osLabel() {
|
|
1426
|
+
switch (import_node_process2.default.platform) {
|
|
1427
|
+
case "darwin":
|
|
1428
|
+
return "macOS";
|
|
1429
|
+
case "win32":
|
|
1430
|
+
return "Windows";
|
|
1431
|
+
case "linux":
|
|
1432
|
+
return "Linux";
|
|
1433
|
+
default:
|
|
1434
|
+
return "This computer";
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
function activationHost(moonbase) {
|
|
1438
|
+
try {
|
|
1439
|
+
return new URL(moonbase.endpoint).host;
|
|
1440
|
+
} catch (e) {
|
|
1441
|
+
return moonbase.endpoint;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function MoonbaseActivation(props) {
|
|
1445
|
+
var _a, _b;
|
|
1446
|
+
const { moonbase, width, height } = props;
|
|
1447
|
+
const state = useMoonbaseState(moonbase);
|
|
1448
|
+
const ui = useUiState(moonbase);
|
|
1449
|
+
if (!ui.visible)
|
|
1450
|
+
return null;
|
|
1451
|
+
return label({
|
|
1452
|
+
key: "moonbase-activation",
|
|
1453
|
+
x: (_a = props.x) != null ? _a : 0,
|
|
1454
|
+
y: (_b = props.y) != null ? _b : 0,
|
|
1455
|
+
width,
|
|
1456
|
+
height,
|
|
1457
|
+
backgroundColor: palette.scrim,
|
|
1458
|
+
alwaysOnTop: true,
|
|
1459
|
+
// Takes every click, so the plugin underneath is locked while it is up.
|
|
1460
|
+
interceptsMouseClicks: true,
|
|
1461
|
+
// The pointer coming back to the plugin stands in for the app coming back to
|
|
1462
|
+
// the front, after the customer bought an add-on in the browser.
|
|
1463
|
+
onMouseEnter: () => moonbase.onFocusChanged(true),
|
|
1464
|
+
onMouseExit: () => moonbase.onFocusChanged(false)
|
|
1465
|
+
}, h(Panel, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height }));
|
|
1466
|
+
}
|
|
1467
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1468
|
+
0 && (module.exports = {
|
|
1469
|
+
MoonbaseActivation,
|
|
1470
|
+
MoonbaseGorillaEngine,
|
|
1471
|
+
createMoonbase,
|
|
1472
|
+
defaultLicenseFile,
|
|
1473
|
+
useMoonbaseState
|
|
1474
|
+
});
|