@moonbase.sh/gorilla-engine 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.cjs +722 -148
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +722 -148
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/moonbase.ts
|
|
2
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
2
3
|
import { execFile, spawn } from "child_process";
|
|
3
4
|
import fsSync from "fs";
|
|
4
5
|
import fs2 from "fs/promises";
|
|
@@ -8,7 +9,7 @@ import process from "process";
|
|
|
8
9
|
import { ActivationController, ActivationError, licensingVersion, MoonbaseError, ReleaseNotCoveredError } from "@moonbase.sh/licensing";
|
|
9
10
|
|
|
10
11
|
// package.json
|
|
11
|
-
var version = "0.
|
|
12
|
+
var version = "0.3.0";
|
|
12
13
|
|
|
13
14
|
// src/download.ts
|
|
14
15
|
import fs from "fs";
|
|
@@ -33,6 +34,300 @@ function uniquePath(dir, name) {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
// src/icons.ts
|
|
38
|
+
import { Buffer } from "buffer";
|
|
39
|
+
import { deflateSync } from "zlib";
|
|
40
|
+
var ICON_PATHS = {
|
|
41
|
+
check: "M4.5 12.75l6 6 9-13.5",
|
|
42
|
+
cross: "M6 18 18 6M6 6l12 12",
|
|
43
|
+
lock: "M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25z",
|
|
44
|
+
back: "M15.75 19.5 8.25 12l7.5-7.5",
|
|
45
|
+
chevron: "m8.25 4.5 7.5 7.5-7.5 7.5",
|
|
46
|
+
signal: "M9.348 14.652a3.75 3.75 0 010-5.304m5.304 0a3.75 3.75 0 010 5.304m-7.425 2.121a6.75 6.75 0 010-9.546m9.546 0a6.75 6.75 0 010 9.546M5.106 18.894c-3.808-3.807-3.808-9.98 0-13.788m13.788 0c3.808 3.807 3.808 9.98 0 13.788M12 12h.008v.008H12V12z",
|
|
47
|
+
computer: "M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25",
|
|
48
|
+
fileDown: "M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9z",
|
|
49
|
+
upload: "M7.5 7.5h-.75A2.25 2.25 0 0 0 4.5 9.75v7.5a2.25 2.25 0 0 0 2.25 2.25h7.5a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75m-6 3.75 3-3m0 0 3 3m-3-3v11.25m6-2.25h.75a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75",
|
|
50
|
+
okCircle: "M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",
|
|
51
|
+
warning: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",
|
|
52
|
+
blocked: "M18.364 18.364A9 9 0 0 0 5.636 5.636m12.728 12.728A9 9 0 0 1 5.636 5.636m12.728 12.728L5.636 5.636",
|
|
53
|
+
copy: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375",
|
|
54
|
+
download: "M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3",
|
|
55
|
+
puzzle: "M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.4 48.4 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.04 48.04 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.4 48.4 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0z",
|
|
56
|
+
external: "M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25",
|
|
57
|
+
sparkles: "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"
|
|
58
|
+
};
|
|
59
|
+
function polylines(d) {
|
|
60
|
+
const lines = [];
|
|
61
|
+
let at = 0;
|
|
62
|
+
let command = "";
|
|
63
|
+
let x = 0;
|
|
64
|
+
let y = 0;
|
|
65
|
+
let startX = 0;
|
|
66
|
+
let startY = 0;
|
|
67
|
+
let control = null;
|
|
68
|
+
let line = [];
|
|
69
|
+
const skip = () => {
|
|
70
|
+
while (at < d.length && /[\s,]/.test(d[at]))
|
|
71
|
+
at++;
|
|
72
|
+
};
|
|
73
|
+
const isCommand = (character) => !!character && /[MLHVCSQTAZ]/i.test(character);
|
|
74
|
+
const number = () => {
|
|
75
|
+
skip();
|
|
76
|
+
const match = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/i.exec(d.slice(at));
|
|
77
|
+
if (!match)
|
|
78
|
+
throw new Error(`Expected a number at ${at} in ${d}`);
|
|
79
|
+
at += match[0].length;
|
|
80
|
+
return Number(match[0]);
|
|
81
|
+
};
|
|
82
|
+
const flag = () => {
|
|
83
|
+
skip();
|
|
84
|
+
const character = d[at++];
|
|
85
|
+
if (character !== "0" && character !== "1")
|
|
86
|
+
throw new Error(`Expected an arc flag at ${at - 1} in ${d}`);
|
|
87
|
+
return character === "1";
|
|
88
|
+
};
|
|
89
|
+
const to = (nextX, nextY) => {
|
|
90
|
+
x = nextX;
|
|
91
|
+
y = nextY;
|
|
92
|
+
line.push([x, y]);
|
|
93
|
+
};
|
|
94
|
+
const cubic = (x1, y1, x2, y2, endX, endY) => {
|
|
95
|
+
const [x0, y0] = [x, y];
|
|
96
|
+
for (let step = 1; step <= 16; step++) {
|
|
97
|
+
const t = step / 16;
|
|
98
|
+
const u = 1 - t;
|
|
99
|
+
line.push([
|
|
100
|
+
u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * endX,
|
|
101
|
+
u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * endY
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
x = endX;
|
|
105
|
+
y = endY;
|
|
106
|
+
control = [x2, y2];
|
|
107
|
+
};
|
|
108
|
+
for (; ; ) {
|
|
109
|
+
skip();
|
|
110
|
+
if (at >= d.length)
|
|
111
|
+
break;
|
|
112
|
+
if (isCommand(d[at]))
|
|
113
|
+
command = d[at++];
|
|
114
|
+
else if (!command)
|
|
115
|
+
throw new Error(`Expected a command at ${at} in ${d}`);
|
|
116
|
+
const relative = command === command.toLowerCase();
|
|
117
|
+
const ox = relative ? x : 0;
|
|
118
|
+
const oy = relative ? y : 0;
|
|
119
|
+
const smooth = control;
|
|
120
|
+
control = null;
|
|
121
|
+
switch (command.toUpperCase()) {
|
|
122
|
+
case "M": {
|
|
123
|
+
x = number() + ox;
|
|
124
|
+
y = number() + oy;
|
|
125
|
+
startX = x;
|
|
126
|
+
startY = y;
|
|
127
|
+
line = [[x, y]];
|
|
128
|
+
lines.push(line);
|
|
129
|
+
command = relative ? "l" : "L";
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "L": {
|
|
133
|
+
const nextX = number() + ox;
|
|
134
|
+
to(nextX, number() + oy);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "H":
|
|
138
|
+
to(number() + ox, y);
|
|
139
|
+
break;
|
|
140
|
+
case "V":
|
|
141
|
+
to(x, number() + oy);
|
|
142
|
+
break;
|
|
143
|
+
case "C": {
|
|
144
|
+
const x1 = number() + ox;
|
|
145
|
+
const y1 = number() + oy;
|
|
146
|
+
const x2 = number() + ox;
|
|
147
|
+
const y2 = number() + oy;
|
|
148
|
+
const endX = number() + ox;
|
|
149
|
+
cubic(x1, y1, x2, y2, endX, number() + oy);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "S": {
|
|
153
|
+
const [x1, y1] = smooth ? [2 * x - smooth[0], 2 * y - smooth[1]] : [x, y];
|
|
154
|
+
const x2 = number() + ox;
|
|
155
|
+
const y2 = number() + oy;
|
|
156
|
+
const endX = number() + ox;
|
|
157
|
+
cubic(x1, y1, x2, y2, endX, number() + oy);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case "Q": {
|
|
161
|
+
const qx = number() + ox;
|
|
162
|
+
const qy = number() + oy;
|
|
163
|
+
const endX = number() + ox;
|
|
164
|
+
const endY = number() + oy;
|
|
165
|
+
cubic(x + 2 / 3 * (qx - x), y + 2 / 3 * (qy - y), endX + 2 / 3 * (qx - endX), endY + 2 / 3 * (qy - endY), endX, endY);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case "A": {
|
|
169
|
+
const rx = number();
|
|
170
|
+
const ry = number();
|
|
171
|
+
const rotation = number();
|
|
172
|
+
const large = flag();
|
|
173
|
+
const sweep = flag();
|
|
174
|
+
const endX = number() + ox;
|
|
175
|
+
const endY = number() + oy;
|
|
176
|
+
for (const point of arc(x, y, rx, ry, rotation, large, sweep, endX, endY))
|
|
177
|
+
line.push(point);
|
|
178
|
+
x = endX;
|
|
179
|
+
y = endY;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "Z":
|
|
183
|
+
to(startX, startY);
|
|
184
|
+
line = [[x, y]];
|
|
185
|
+
lines.push(line);
|
|
186
|
+
skip();
|
|
187
|
+
if (at < d.length && !isCommand(d[at]))
|
|
188
|
+
throw new Error(`Expected a command after Z at ${at} in ${d}`);
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
throw new Error(`Unsupported command ${command} in ${d}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return lines;
|
|
195
|
+
}
|
|
196
|
+
function arc(x1, y1, rx, ry, rotation, large, sweep, x2, y2) {
|
|
197
|
+
if (rx === 0 || ry === 0)
|
|
198
|
+
return [[x2, y2]];
|
|
199
|
+
rx = Math.abs(rx);
|
|
200
|
+
ry = Math.abs(ry);
|
|
201
|
+
const phi = rotation * Math.PI / 180;
|
|
202
|
+
const cos = Math.cos(phi);
|
|
203
|
+
const sin = Math.sin(phi);
|
|
204
|
+
const dx = (x1 - x2) / 2;
|
|
205
|
+
const dy = (y1 - y2) / 2;
|
|
206
|
+
const x1p = cos * dx + sin * dy;
|
|
207
|
+
const y1p = -sin * dx + cos * dy;
|
|
208
|
+
const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
|
|
209
|
+
if (lambda > 1) {
|
|
210
|
+
rx *= Math.sqrt(lambda);
|
|
211
|
+
ry *= Math.sqrt(lambda);
|
|
212
|
+
}
|
|
213
|
+
const numerator = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
|
|
214
|
+
const denominator = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
|
|
215
|
+
let coefficient = Math.sqrt(Math.max(0, numerator / denominator));
|
|
216
|
+
if (large === sweep)
|
|
217
|
+
coefficient = -coefficient;
|
|
218
|
+
const cxp = coefficient * rx * y1p / ry;
|
|
219
|
+
const cyp = -coefficient * ry * x1p / rx;
|
|
220
|
+
const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
|
|
221
|
+
const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
|
|
222
|
+
const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
|
|
223
|
+
const start = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
|
|
224
|
+
let delta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
|
|
225
|
+
if (!sweep && delta > 0)
|
|
226
|
+
delta -= 2 * Math.PI;
|
|
227
|
+
else if (sweep && delta < 0)
|
|
228
|
+
delta += 2 * Math.PI;
|
|
229
|
+
const steps = Math.max(2, Math.ceil(Math.abs(delta) / (Math.PI / 24)));
|
|
230
|
+
const points = [];
|
|
231
|
+
for (let step = 1; step <= steps; step++) {
|
|
232
|
+
const t = start + delta * step / steps;
|
|
233
|
+
points.push([cos * rx * Math.cos(t) - sin * ry * Math.sin(t) + cx, sin * rx * Math.cos(t) + cos * ry * Math.sin(t) + cy]);
|
|
234
|
+
}
|
|
235
|
+
return points;
|
|
236
|
+
}
|
|
237
|
+
function coverage(d, pixels, strokeWidth) {
|
|
238
|
+
const scale = pixels / 24;
|
|
239
|
+
const half = strokeWidth * scale / 2;
|
|
240
|
+
const segments = [];
|
|
241
|
+
for (const line of polylines(d)) {
|
|
242
|
+
const points = line.map(([px, py]) => [px * scale, py * scale]);
|
|
243
|
+
if (points.length === 1)
|
|
244
|
+
segments.push([points[0][0], points[0][1], points[0][0], points[0][1]]);
|
|
245
|
+
for (let index = 1; index < points.length; index++)
|
|
246
|
+
segments.push([points[index - 1][0], points[index - 1][1], points[index][0], points[index][1]]);
|
|
247
|
+
}
|
|
248
|
+
const reach = half + 1;
|
|
249
|
+
const out = new Float32Array(pixels * pixels);
|
|
250
|
+
for (const [ax, ay, bx, by] of segments) {
|
|
251
|
+
const left = Math.max(0, Math.floor(Math.min(ax, bx) - reach));
|
|
252
|
+
const right = Math.min(pixels - 1, Math.ceil(Math.max(ax, bx) + reach));
|
|
253
|
+
const top = Math.max(0, Math.floor(Math.min(ay, by) - reach));
|
|
254
|
+
const bottom = Math.min(pixels - 1, Math.ceil(Math.max(ay, by) + reach));
|
|
255
|
+
const vx = bx - ax;
|
|
256
|
+
const vy = by - ay;
|
|
257
|
+
const length = vx * vx + vy * vy;
|
|
258
|
+
for (let py = top; py <= bottom; py++) {
|
|
259
|
+
for (let px = left; px <= right; px++) {
|
|
260
|
+
const cx = px + 0.5;
|
|
261
|
+
const cy = py + 0.5;
|
|
262
|
+
const t = length === 0 ? 0 : Math.max(0, Math.min(1, ((cx - ax) * vx + (cy - ay) * vy) / length));
|
|
263
|
+
const distance = Math.hypot(cx - (ax + t * vx), cy - (ay + t * vy));
|
|
264
|
+
const value = Math.max(0, Math.min(1, half + 0.5 - distance));
|
|
265
|
+
const index = py * pixels + px;
|
|
266
|
+
if (value > out[index])
|
|
267
|
+
out[index] = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
var CRC_TABLE = (() => {
|
|
274
|
+
const table = new Uint32Array(256);
|
|
275
|
+
for (let n = 0; n < 256; n++) {
|
|
276
|
+
let c = n;
|
|
277
|
+
for (let k = 0; k < 8; k++)
|
|
278
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
279
|
+
table[n] = c >>> 0;
|
|
280
|
+
}
|
|
281
|
+
return table;
|
|
282
|
+
})();
|
|
283
|
+
function crc32(bytes) {
|
|
284
|
+
let c = 4294967295;
|
|
285
|
+
for (const byte of bytes)
|
|
286
|
+
c = CRC_TABLE[(c ^ byte) & 255] ^ c >>> 8;
|
|
287
|
+
return (c ^ 4294967295) >>> 0;
|
|
288
|
+
}
|
|
289
|
+
function chunk(type, data) {
|
|
290
|
+
const length = Buffer.alloc(4);
|
|
291
|
+
length.writeUInt32BE(data.length);
|
|
292
|
+
const body = Buffer.concat([Buffer.from(type, "ascii"), data]);
|
|
293
|
+
const crc = Buffer.alloc(4);
|
|
294
|
+
crc.writeUInt32BE(crc32(body));
|
|
295
|
+
return Buffer.concat([length, body, crc]);
|
|
296
|
+
}
|
|
297
|
+
function encodePng(width, height, rgba) {
|
|
298
|
+
const header = Buffer.alloc(13);
|
|
299
|
+
header.writeUInt32BE(width, 0);
|
|
300
|
+
header.writeUInt32BE(height, 4);
|
|
301
|
+
header[8] = 8;
|
|
302
|
+
header[9] = 6;
|
|
303
|
+
const raw = Buffer.alloc((width * 4 + 1) * height);
|
|
304
|
+
for (let row = 0; row < height; row++)
|
|
305
|
+
Buffer.from(rgba.buffer, rgba.byteOffset + row * width * 4, width * 4).copy(raw, row * (width * 4 + 1) + 1);
|
|
306
|
+
return Buffer.concat([
|
|
307
|
+
Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
|
|
308
|
+
chunk("IHDR", header),
|
|
309
|
+
chunk("IDAT", deflateSync(raw)),
|
|
310
|
+
chunk("IEND", Buffer.alloc(0))
|
|
311
|
+
]);
|
|
312
|
+
}
|
|
313
|
+
function iconPng(name, colour, pixels, strokeWidth) {
|
|
314
|
+
const argb = Number.parseInt(colour, 16);
|
|
315
|
+
const alpha = (argb >>> 24 & 255) / 255;
|
|
316
|
+
const cover = coverage(ICON_PATHS[name], pixels, strokeWidth);
|
|
317
|
+
const rgba = new Uint8Array(pixels * pixels * 4);
|
|
318
|
+
for (let index = 0; index < cover.length; index++) {
|
|
319
|
+
rgba[index * 4] = argb >>> 16 & 255;
|
|
320
|
+
rgba[index * 4 + 1] = argb >>> 8 & 255;
|
|
321
|
+
rgba[index * 4 + 2] = argb & 255;
|
|
322
|
+
rgba[index * 4 + 3] = Math.round(cover[index] * alpha * 255);
|
|
323
|
+
}
|
|
324
|
+
return encodePng(pixels, pixels, rgba);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/mark.ts
|
|
328
|
+
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";
|
|
329
|
+
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==";
|
|
330
|
+
|
|
36
331
|
// src/moonbase.ts
|
|
37
332
|
function runtime() {
|
|
38
333
|
var _a;
|
|
@@ -112,6 +407,11 @@ function errorKind(err) {
|
|
|
112
407
|
return (_a = err.type) != null ? _a : "internal";
|
|
113
408
|
return "internal";
|
|
114
409
|
}
|
|
410
|
+
function writeIfChanged(file, data) {
|
|
411
|
+
if (fsSync.existsSync(file) && fsSync.readFileSync(file).equals(data))
|
|
412
|
+
return;
|
|
413
|
+
fsSync.writeFileSync(file, data);
|
|
414
|
+
}
|
|
115
415
|
var MoonbaseGorillaEngine = class extends ActivationController {
|
|
116
416
|
constructor(options) {
|
|
117
417
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -139,6 +439,9 @@ var MoonbaseGorillaEngine = class extends ActivationController {
|
|
|
139
439
|
this.stopFocus = null;
|
|
140
440
|
/** Aborts the update download when the instance is disposed. */
|
|
141
441
|
this.aborts = new AbortController();
|
|
442
|
+
/** Each icon's file, by name, colour, size and stroke; null when it couldn't be written. */
|
|
443
|
+
this.iconFiles = /* @__PURE__ */ new Map();
|
|
444
|
+
this.iconsFailed = false;
|
|
142
445
|
this.ui = { ...ui, productName };
|
|
143
446
|
this.endpoint = options.endpoint;
|
|
144
447
|
this.host = host;
|
|
@@ -200,6 +503,54 @@ var MoonbaseGorillaEngine = class extends ActivationController {
|
|
|
200
503
|
this.reportError("previousLicense", err);
|
|
201
504
|
}
|
|
202
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Moonbase's mark, for the overlay's footer, as an image file: Gorilla Engine
|
|
508
|
+
* draws images from files only, and a module can't add to the plugin's assets.
|
|
509
|
+
* Written beside the license file, with its `@2x`, the first time it is asked
|
|
510
|
+
* for. Null when it can't be written, and the footer goes without it.
|
|
511
|
+
*/
|
|
512
|
+
moonbaseMark() {
|
|
513
|
+
if (this.markFile !== void 0)
|
|
514
|
+
return this.markFile;
|
|
515
|
+
const file = path2.join(path2.dirname(this.licenseFile), "moonbase-mark.png");
|
|
516
|
+
try {
|
|
517
|
+
fsSync.mkdirSync(path2.dirname(file), { recursive: true });
|
|
518
|
+
writeIfChanged(file, Buffer2.from(MARK_PNG, "base64"));
|
|
519
|
+
writeIfChanged(file.replace(/\.png$/, "@2x.png"), Buffer2.from(MARK_PNG_2X, "base64"));
|
|
520
|
+
this.markFile = file;
|
|
521
|
+
} catch (err) {
|
|
522
|
+
this.reportError("moonbaseMark", err);
|
|
523
|
+
this.markFile = null;
|
|
524
|
+
}
|
|
525
|
+
return this.markFile;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* One of the overlay's icons, in a colour (`AARRGGBB`) and size (points), as
|
|
529
|
+
* an image file, with its `@2x`: drawn the first time it is asked for, into
|
|
530
|
+
* `moonbase-icons` beside the license, for the same reason as the mark. Null
|
|
531
|
+
* when it can't be written, and the overlay goes without it.
|
|
532
|
+
*/
|
|
533
|
+
icon(name, colour, size, stroke = 1.8) {
|
|
534
|
+
const key = `${name}-${colour}-${size}-${stroke}`;
|
|
535
|
+
const known = this.iconFiles.get(key);
|
|
536
|
+
if (known !== void 0)
|
|
537
|
+
return known;
|
|
538
|
+
const file = path2.join(path2.dirname(this.licenseFile), "moonbase-icons", `${name}-${colour.toLowerCase()}-${size}-${Math.round(stroke * 10)}.png`);
|
|
539
|
+
let result = file;
|
|
540
|
+
try {
|
|
541
|
+
fsSync.mkdirSync(path2.dirname(file), { recursive: true });
|
|
542
|
+
writeIfChanged(file, iconPng(name, colour, Math.round(size), stroke));
|
|
543
|
+
writeIfChanged(file.replace(/\.png$/, "@2x.png"), iconPng(name, colour, Math.round(size * 2), stroke));
|
|
544
|
+
} catch (err) {
|
|
545
|
+
if (!this.iconsFailed) {
|
|
546
|
+
this.iconsFailed = true;
|
|
547
|
+
this.reportError("icons", err);
|
|
548
|
+
}
|
|
549
|
+
result = null;
|
|
550
|
+
}
|
|
551
|
+
this.iconFiles.set(key, result);
|
|
552
|
+
return result;
|
|
553
|
+
}
|
|
203
554
|
/**
|
|
204
555
|
* Hand a failure to `onError`: the overlay does with every action that
|
|
205
556
|
* fails, and the module with the host's.
|
|
@@ -403,6 +754,7 @@ function createMoonbase(options) {
|
|
|
403
754
|
}
|
|
404
755
|
|
|
405
756
|
// src/MoonbaseActivation.ts
|
|
757
|
+
import os2 from "os";
|
|
406
758
|
import process2 from "process";
|
|
407
759
|
import * as React3 from "react";
|
|
408
760
|
|
|
@@ -560,6 +912,64 @@ function describeAddOn(entry, license, state) {
|
|
|
560
912
|
// src/elements.ts
|
|
561
913
|
import * as React2 from "react";
|
|
562
914
|
|
|
915
|
+
// src/metrics.ts
|
|
916
|
+
var SIZE = 500;
|
|
917
|
+
var CHARACTERS = (() => {
|
|
918
|
+
let characters = "";
|
|
919
|
+
for (let code = 32; code < 127; code++)
|
|
920
|
+
characters += String.fromCharCode(code);
|
|
921
|
+
for (let code = 160; code < 256; code++)
|
|
922
|
+
characters += String.fromCharCode(code);
|
|
923
|
+
return `${characters}\u2026\xB7\u2018\u2019\u201C\u201D\u2013\u20AC`;
|
|
924
|
+
})();
|
|
925
|
+
var advances = /* @__PURE__ */ new Map();
|
|
926
|
+
var measuring = /* @__PURE__ */ new Map();
|
|
927
|
+
function measurer() {
|
|
928
|
+
var _a;
|
|
929
|
+
return (_a = globalThis.GorillaEngine) != null ? _a : null;
|
|
930
|
+
}
|
|
931
|
+
function measureFont(font) {
|
|
932
|
+
var _a;
|
|
933
|
+
const existing = measuring.get(font);
|
|
934
|
+
if (existing)
|
|
935
|
+
return existing;
|
|
936
|
+
const measure = (_a = measurer()) == null ? void 0 : _a.calculateTextWidth;
|
|
937
|
+
if (typeof measure !== "function")
|
|
938
|
+
return Promise.resolve(false);
|
|
939
|
+
const promise = (async () => {
|
|
940
|
+
const table = /* @__PURE__ */ new Map();
|
|
941
|
+
const widths = await Promise.all([...CHARACTERS].map((character) => measure(character, font, SIZE, 0)));
|
|
942
|
+
widths.forEach((width, index) => {
|
|
943
|
+
if (typeof width === "number" && Number.isFinite(width))
|
|
944
|
+
table.set(CHARACTERS[index], width);
|
|
945
|
+
});
|
|
946
|
+
if (!table.has("n"))
|
|
947
|
+
return false;
|
|
948
|
+
advances.set(font, table);
|
|
949
|
+
return true;
|
|
950
|
+
})().catch(() => false);
|
|
951
|
+
measuring.set(font, promise);
|
|
952
|
+
return promise;
|
|
953
|
+
}
|
|
954
|
+
async function measureFonts(fonts) {
|
|
955
|
+
const results = await Promise.all([...new Set(fonts.map((font) => font != null ? font : ""))].map(measureFont));
|
|
956
|
+
return results.some(Boolean);
|
|
957
|
+
}
|
|
958
|
+
function measuredWidth(text2, font, size, kerning = 0) {
|
|
959
|
+
var _a;
|
|
960
|
+
const table = advances.get(font != null ? font : "");
|
|
961
|
+
if (!table)
|
|
962
|
+
return null;
|
|
963
|
+
const fallback = table.get("n");
|
|
964
|
+
let width = 0;
|
|
965
|
+
let count = 0;
|
|
966
|
+
for (const character of text2) {
|
|
967
|
+
width += (_a = table.get(character)) != null ? _a : fallback;
|
|
968
|
+
count++;
|
|
969
|
+
}
|
|
970
|
+
return width * size / SIZE + kerning * size * count;
|
|
971
|
+
}
|
|
972
|
+
|
|
563
973
|
// src/motion.ts
|
|
564
974
|
import * as React from "react";
|
|
565
975
|
var FRAME = 16;
|
|
@@ -710,27 +1120,68 @@ function fontFor(theme, weight, mono = false) {
|
|
|
710
1120
|
return medium != null ? medium : regular;
|
|
711
1121
|
return regular;
|
|
712
1122
|
}
|
|
713
|
-
function textWidth(text2, size, weight = 400) {
|
|
714
|
-
return Math.ceil(text2
|
|
1123
|
+
function textWidth(theme, text2, size, weight = 400, options = {}) {
|
|
1124
|
+
return Math.ceil(exactWidth(theme, text2, size, weight, options));
|
|
1125
|
+
}
|
|
1126
|
+
function exactWidth(theme, text2, size, weight, options = {}) {
|
|
1127
|
+
var _a;
|
|
1128
|
+
const measured = measuredWidth(text2, fontFor(theme, weight, options.mono), size, options.kerning);
|
|
1129
|
+
if (measured !== null)
|
|
1130
|
+
return measured * 1.03;
|
|
1131
|
+
return text2.length * size * ((weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52) + ((_a = options.kerning) != null ? _a : 0));
|
|
715
1132
|
}
|
|
716
|
-
function
|
|
1133
|
+
function lineCount(theme, text2, size, width, weight = 400, mono = false) {
|
|
1134
|
+
const space2 = exactWidth(theme, " ", size, weight, { mono });
|
|
717
1135
|
let lines = 0;
|
|
718
1136
|
for (const paragraph2 of text2.split("\n")) {
|
|
719
1137
|
let line = 0;
|
|
720
1138
|
lines++;
|
|
721
1139
|
for (const word of paragraph2.split(" ")) {
|
|
722
|
-
const length =
|
|
723
|
-
if (line > 0 && line + length > width) {
|
|
1140
|
+
const length = exactWidth(theme, word, size, weight, { mono });
|
|
1141
|
+
if (line > 0 && line + space2 + length > width) {
|
|
724
1142
|
lines++;
|
|
725
|
-
line =
|
|
1143
|
+
line = length;
|
|
1144
|
+
} else {
|
|
1145
|
+
line += (line > 0 ? space2 : 0) + length;
|
|
726
1146
|
}
|
|
727
|
-
line += length;
|
|
728
1147
|
}
|
|
729
1148
|
}
|
|
730
|
-
return
|
|
1149
|
+
return lines;
|
|
1150
|
+
}
|
|
1151
|
+
function textHeight(theme, text2, size, width, lineHeight = 1.5, weight = 400, mono = false) {
|
|
1152
|
+
return Math.ceil(lineCount(theme, text2, size, width, weight, mono) * size * lineHeight);
|
|
731
1153
|
}
|
|
1154
|
+
function fitText(theme, text2, size, width, options = {}) {
|
|
1155
|
+
const fits = (value) => textWidth(theme, value, size, options.weight, { mono: options.mono }) <= width;
|
|
1156
|
+
if (fits(text2))
|
|
1157
|
+
return text2;
|
|
1158
|
+
const characters = [...text2];
|
|
1159
|
+
let keep = characters.length - 1;
|
|
1160
|
+
while (keep > 1) {
|
|
1161
|
+
const value = options.end ? `${characters.slice(0, keep).join("").trimEnd()}\u2026` : `${characters.slice(0, Math.ceil(keep / 2)).join("")}\u2026${characters.slice(characters.length - Math.floor(keep / 2)).join("")}`;
|
|
1162
|
+
if (fits(value))
|
|
1163
|
+
return value;
|
|
1164
|
+
keep--;
|
|
1165
|
+
}
|
|
1166
|
+
return "\u2026";
|
|
1167
|
+
}
|
|
1168
|
+
var BLANK = {
|
|
1169
|
+
text: "",
|
|
1170
|
+
backgroundColor: "00000000",
|
|
1171
|
+
cornerRadius: 0,
|
|
1172
|
+
border: { width: 0, color: "00000000" },
|
|
1173
|
+
alpha: 1,
|
|
1174
|
+
interceptsMouseClicks: false,
|
|
1175
|
+
mouseCursorType: "normal"
|
|
1176
|
+
};
|
|
732
1177
|
function label(props, ...children) {
|
|
733
|
-
return h("geLabel", {
|
|
1178
|
+
return h("geLabel", { ...BLANK, ...props }, ...children);
|
|
1179
|
+
}
|
|
1180
|
+
function icon(theme, name, x, y, size, colour, stroke = 1.8) {
|
|
1181
|
+
const file = theme.icon(name, colour, size, stroke);
|
|
1182
|
+
if (!file)
|
|
1183
|
+
return null;
|
|
1184
|
+
return h("geLabel", { ...BLANK, key: `icon-${name}`, x, y, width: size, height: size, backgroundImage: file });
|
|
734
1185
|
}
|
|
735
1186
|
function each(node) {
|
|
736
1187
|
return Array.isArray(node) ? node : [node];
|
|
@@ -738,7 +1189,7 @@ function each(node) {
|
|
|
738
1189
|
function text(theme, value, x, y, width, options = {}) {
|
|
739
1190
|
var _a, _b, _c, _d, _e, _f;
|
|
740
1191
|
const size = (_a = options.size) != null ? _a : 14;
|
|
741
|
-
const height = textHeight(value, size, width, options.lineHeight);
|
|
1192
|
+
const height = textHeight(theme, value, size, width, options.lineHeight, options.weight, options.mono);
|
|
742
1193
|
const multiLine = height > size * ((_b = options.lineHeight) != null ? _b : 1.5) * 1.2;
|
|
743
1194
|
return label({
|
|
744
1195
|
x,
|
|
@@ -772,7 +1223,7 @@ function paragraph(theme, value, width, options = {}) {
|
|
|
772
1223
|
var _a, _b, _c;
|
|
773
1224
|
const size = (_a = options.size) != null ? _a : 14;
|
|
774
1225
|
const boxWidth = Math.min(width, (_b = options.maxWidth) != null ? _b : width);
|
|
775
|
-
const height = Math.max(textHeight(value, size, boxWidth, options.lineHeight), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
|
|
1226
|
+
const height = Math.max(textHeight(theme, value, size, boxWidth, options.lineHeight, options.weight, options.mono), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
|
|
776
1227
|
return {
|
|
777
1228
|
height,
|
|
778
1229
|
render: (x, y, available) => {
|
|
@@ -784,8 +1235,16 @@ function paragraph(theme, value, width, options = {}) {
|
|
|
784
1235
|
function heading(theme, value, width, options = {}) {
|
|
785
1236
|
return paragraph(theme, value, width, { size: options.large ? 27 : 24, weight: 600, textColor: palette.textPrimary, lineHeight: 1.25, align: options.align });
|
|
786
1237
|
}
|
|
1238
|
+
function iconBeside(theme, value, size, weight, width, iconSize, gap) {
|
|
1239
|
+
if (iconSize === null)
|
|
1240
|
+
return { iconX: 0, margin: { left: 0, right: 0, top: 0, bottom: 0 } };
|
|
1241
|
+
if (!value)
|
|
1242
|
+
return { iconX: Math.round((width - iconSize) / 2), margin: { left: 0, right: 0, top: 0, bottom: 0 } };
|
|
1243
|
+
const shift = iconSize + gap;
|
|
1244
|
+
return { iconX: Math.round((width - textWidth(theme, value, size, weight) - shift) / 2), margin: { left: shift, right: 0, top: 0, bottom: 0 } };
|
|
1245
|
+
}
|
|
787
1246
|
function Button(props) {
|
|
788
|
-
var _a, _b, _c;
|
|
1247
|
+
var _a, _b, _c, _d;
|
|
789
1248
|
const [hovered, setHovered] = React2.useState(false);
|
|
790
1249
|
const kind = (_a = props.kind) != null ? _a : "primary";
|
|
791
1250
|
const accent = props.theme.accent;
|
|
@@ -799,6 +1258,9 @@ function Button(props) {
|
|
|
799
1258
|
};
|
|
800
1259
|
const look = looks[kind];
|
|
801
1260
|
const small = kind.startsWith("small") || kind === "danger" || kind === "quiet";
|
|
1261
|
+
const fontSize = (_b = props.size) != null ? _b : small ? 12.5 : 14;
|
|
1262
|
+
const iconSize = props.icon ? (_c = props.iconSize) != null ? _c : small ? 14 : 16 : null;
|
|
1263
|
+
const { iconX, margin } = iconBeside(props.theme, props.label, fontSize, look.weight, props.width, iconSize, small ? 6 : 8);
|
|
802
1264
|
return label({
|
|
803
1265
|
x: props.x,
|
|
804
1266
|
y: props.y,
|
|
@@ -806,12 +1268,13 @@ function Button(props) {
|
|
|
806
1268
|
height: props.height,
|
|
807
1269
|
text: props.label,
|
|
808
1270
|
font: fontFor(props.theme, look.weight),
|
|
809
|
-
fontSize
|
|
1271
|
+
fontSize,
|
|
810
1272
|
textColor: look.textColor,
|
|
811
1273
|
textAlign: "center",
|
|
1274
|
+
margin,
|
|
812
1275
|
backgroundColor: hovered && !props.disabled ? look.hover : look.background,
|
|
813
1276
|
cornerRadius: small ? 8 : 9,
|
|
814
|
-
border: { width: look.border ? 1 : 0, color: (
|
|
1277
|
+
border: { width: look.border ? 1 : 0, color: (_d = look.border) != null ? _d : palette.transparent },
|
|
815
1278
|
alpha: props.disabled ? 0.5 : 1,
|
|
816
1279
|
interceptsMouseClicks: true,
|
|
817
1280
|
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
@@ -821,7 +1284,7 @@ function Button(props) {
|
|
|
821
1284
|
if (!props.disabled)
|
|
822
1285
|
props.onClick();
|
|
823
1286
|
}
|
|
824
|
-
});
|
|
1287
|
+
}, props.icon && iconSize && icon(props.theme, props.icon, iconX, Math.round((props.height - iconSize) / 2), iconSize, look.textColor, 1.8));
|
|
825
1288
|
}
|
|
826
1289
|
function buttonBlock(theme, value, onClick, options = {}) {
|
|
827
1290
|
var _a;
|
|
@@ -832,27 +1295,35 @@ function buttonBlock(theme, value, onClick, options = {}) {
|
|
|
832
1295
|
var _a2;
|
|
833
1296
|
const width = Math.min(available, (_a2 = options.width) != null ? _a2 : available);
|
|
834
1297
|
const left = options.align === "center" ? x + (available - width) / 2 : x;
|
|
835
|
-
return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, onClick });
|
|
1298
|
+
return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, icon: options.icon, onClick });
|
|
836
1299
|
}
|
|
837
1300
|
};
|
|
838
1301
|
}
|
|
1302
|
+
var LINK_ICON = 14;
|
|
1303
|
+
var LINK_GAP = 6;
|
|
1304
|
+
function linkWidth(theme, value, size = 12.5, withIcon = false) {
|
|
1305
|
+
return textWidth(theme, value, size, 500) + 8 + (withIcon ? LINK_ICON + LINK_GAP : 0);
|
|
1306
|
+
}
|
|
839
1307
|
function Link(props) {
|
|
840
|
-
var _a, _b;
|
|
1308
|
+
var _a, _b, _c;
|
|
841
1309
|
const [hovered, setHovered] = React2.useState(false);
|
|
842
1310
|
const size = (_a = props.size) != null ? _a : 12.5;
|
|
843
|
-
const width = (_b = props.width) != null ? _b :
|
|
1311
|
+
const width = (_b = props.width) != null ? _b : linkWidth(props.theme, props.label, size, !!props.icon);
|
|
1312
|
+
const height = Math.ceil(size * 1.6);
|
|
844
1313
|
const base = props.link ? palette.link : palette.textSecondary;
|
|
845
1314
|
const hover = props.link ? palette.linkHover : palette.textBright;
|
|
1315
|
+
const shown = hovered && !props.disabled ? hover : base;
|
|
846
1316
|
return label({
|
|
847
1317
|
x: props.x,
|
|
848
1318
|
y: props.y,
|
|
849
1319
|
width,
|
|
850
|
-
height
|
|
1320
|
+
height,
|
|
851
1321
|
text: props.label,
|
|
852
1322
|
font: fontFor(props.theme, 500),
|
|
853
1323
|
fontSize: size,
|
|
854
|
-
textColor:
|
|
1324
|
+
textColor: shown,
|
|
855
1325
|
textAlign: props.align === "center" ? "center" : "centered left",
|
|
1326
|
+
margin: { left: props.icon ? LINK_ICON + LINK_GAP : 0, right: 0, top: 0, bottom: 0 },
|
|
856
1327
|
alpha: props.disabled ? 0.55 : 1,
|
|
857
1328
|
interceptsMouseClicks: true,
|
|
858
1329
|
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
@@ -862,7 +1333,7 @@ function Link(props) {
|
|
|
862
1333
|
if (!props.disabled)
|
|
863
1334
|
props.onClick();
|
|
864
1335
|
}
|
|
865
|
-
});
|
|
1336
|
+
}, props.icon && icon(props.theme, props.icon, 0, Math.round((height - LINK_ICON) / 2), LINK_ICON, (_c = props.iconColour) != null ? _c : shown, 1.7));
|
|
866
1337
|
}
|
|
867
1338
|
function linksBlock(theme, links, options = {}) {
|
|
868
1339
|
var _a;
|
|
@@ -875,23 +1346,26 @@ function linksBlock(theme, links, options = {}) {
|
|
|
875
1346
|
return {
|
|
876
1347
|
height: marginTop + Math.ceil(size * 1.6),
|
|
877
1348
|
render: (x, y, width) => {
|
|
878
|
-
const widths = items.map((item) =>
|
|
1349
|
+
const widths = items.map((item) => linkWidth(theme, item.label, size, !!item.icon));
|
|
879
1350
|
const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
|
|
880
1351
|
let left = options.align === "left" ? x : x + (width - total) / 2;
|
|
881
1352
|
return items.map((item, index) => {
|
|
882
|
-
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 });
|
|
1353
|
+
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], icon: item.icon, iconColour: item.iconColour, onClick: item.onClick });
|
|
883
1354
|
left += widths[index] + gap;
|
|
884
1355
|
return node;
|
|
885
1356
|
});
|
|
886
1357
|
}
|
|
887
1358
|
};
|
|
888
1359
|
}
|
|
889
|
-
function pill(theme, tone, value, x, y, onClick) {
|
|
1360
|
+
function pill(theme, tone, value, x, y, onClick, withIcon) {
|
|
890
1361
|
const upper = tone === "trial" || tone === "expired" || tone === "upgrade";
|
|
891
1362
|
const shown = upper ? value.toUpperCase() : value;
|
|
892
1363
|
const size = upper ? 10.5 : 11.5;
|
|
1364
|
+
const kerning = upper ? 0.08 : 0.02;
|
|
893
1365
|
const dot = tone === "expired" || tone === "upgrade" || tone === "active";
|
|
894
|
-
const
|
|
1366
|
+
const lead = dot ? 12 : withIcon ? 19 : 0;
|
|
1367
|
+
const textBox = textWidth(theme, shown, size, 700, { kerning }) + 4;
|
|
1368
|
+
const width = textBox + 22 + lead;
|
|
895
1369
|
const height = 24;
|
|
896
1370
|
const looks = {
|
|
897
1371
|
trial: { background: color(palette.trial), border: palette.transparent, textColor: color("#131519") },
|
|
@@ -913,15 +1387,15 @@ function pill(theme, tone, value, x, y, onClick) {
|
|
|
913
1387
|
interceptsMouseClicks: !!onClick,
|
|
914
1388
|
mouseCursorType: onClick ? "pointing hand" : "normal",
|
|
915
1389
|
...onClick && { onClick }
|
|
916
|
-
}, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), label({
|
|
917
|
-
x:
|
|
1390
|
+
}, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), withIcon && icon(theme, withIcon, 10, (height - 13) / 2, 13, color(theme.accent), 1.9), label({
|
|
1391
|
+
x: 11 + lead,
|
|
918
1392
|
y: 0,
|
|
919
|
-
width:
|
|
1393
|
+
width: textBox,
|
|
920
1394
|
height,
|
|
921
1395
|
text: shown,
|
|
922
1396
|
font: fontFor(theme, 700),
|
|
923
1397
|
fontSize: size,
|
|
924
|
-
fontKerning:
|
|
1398
|
+
fontKerning: kerning,
|
|
925
1399
|
textColor: look.textColor,
|
|
926
1400
|
textAlign: "center"
|
|
927
1401
|
}));
|
|
@@ -929,6 +1403,8 @@ function pill(theme, tone, value, x, y, onClick) {
|
|
|
929
1403
|
}
|
|
930
1404
|
function card(props, ...children) {
|
|
931
1405
|
var _a, _b, _c;
|
|
1406
|
+
if (props.onClick)
|
|
1407
|
+
return h(ClickableCard, { ...props, onClick: props.onClick }, ...children);
|
|
932
1408
|
return label({
|
|
933
1409
|
x: props.x,
|
|
934
1410
|
y: props.y,
|
|
@@ -936,11 +1412,36 @@ function card(props, ...children) {
|
|
|
936
1412
|
height: props.height,
|
|
937
1413
|
backgroundColor: (_a = props.background) != null ? _a : palette.card,
|
|
938
1414
|
cornerRadius: (_b = props.radius) != null ? _b : 12,
|
|
939
|
-
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
|
|
940
|
-
interceptsMouseClicks: !!props.onClick,
|
|
941
|
-
...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
|
|
1415
|
+
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
|
|
942
1416
|
}, ...children);
|
|
943
1417
|
}
|
|
1418
|
+
function ClickableCard(props) {
|
|
1419
|
+
var _a, _b, _c;
|
|
1420
|
+
const [hovered, setHovered] = React2.useState(false);
|
|
1421
|
+
return label({
|
|
1422
|
+
x: props.x,
|
|
1423
|
+
y: props.y,
|
|
1424
|
+
width: props.width,
|
|
1425
|
+
height: props.height,
|
|
1426
|
+
backgroundColor: hovered ? color("#ffffff", 0.05) : (_a = props.background) != null ? _a : palette.card,
|
|
1427
|
+
cornerRadius: (_b = props.radius) != null ? _b : 12,
|
|
1428
|
+
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
|
|
1429
|
+
interceptsMouseClicks: true,
|
|
1430
|
+
mouseCursorType: "pointing hand",
|
|
1431
|
+
onMouseEnter: () => setHovered(true),
|
|
1432
|
+
onMouseExit: () => setHovered(false),
|
|
1433
|
+
onClick: props.onClick
|
|
1434
|
+
}, ...React2.Children.toArray(props.children));
|
|
1435
|
+
}
|
|
1436
|
+
var SCROLLBAR = 6;
|
|
1437
|
+
function scrollView(props, contentHeight, ...children) {
|
|
1438
|
+
return h("geScrollView", {
|
|
1439
|
+
...props,
|
|
1440
|
+
hideHorizontalScrollbar: true,
|
|
1441
|
+
scrollbarThickness: SCROLLBAR,
|
|
1442
|
+
scrollbar: { background: palette.transparent, track: palette.transparent, thumb: color("#ffffff", 0.16) }
|
|
1443
|
+
}, label({ x: 0, y: 0, width: props.width - SCROLLBAR, height: contentHeight }, ...children));
|
|
1444
|
+
}
|
|
944
1445
|
function barBlock(fraction, fill, options = {}) {
|
|
945
1446
|
var _a, _b;
|
|
946
1447
|
const marginTop = (_a = options.marginTop) != null ? _a : 14;
|
|
@@ -1131,6 +1632,24 @@ function useUiState(moonbase) {
|
|
|
1131
1632
|
}, [moonbase]);
|
|
1132
1633
|
return ui;
|
|
1133
1634
|
}
|
|
1635
|
+
function useFontMetrics(ui) {
|
|
1636
|
+
var _a;
|
|
1637
|
+
const [measured, setMeasured] = React3.useState(0);
|
|
1638
|
+
const { regular, medium, semibold, mono } = (_a = ui.fonts) != null ? _a : {};
|
|
1639
|
+
React3.useEffect(() => {
|
|
1640
|
+
var _a2;
|
|
1641
|
+
let live = true;
|
|
1642
|
+
measureFonts([regular, medium != null ? medium : regular, (_a2 = semibold != null ? semibold : medium) != null ? _a2 : regular, mono != null ? mono : regular]).then((known) => {
|
|
1643
|
+
if (live && known)
|
|
1644
|
+
setMeasured((count) => count + 1);
|
|
1645
|
+
}, () => {
|
|
1646
|
+
});
|
|
1647
|
+
return () => {
|
|
1648
|
+
live = false;
|
|
1649
|
+
};
|
|
1650
|
+
}, [regular, medium, semibold, mono]);
|
|
1651
|
+
return measured;
|
|
1652
|
+
}
|
|
1134
1653
|
function statusView(state) {
|
|
1135
1654
|
switch (state.status) {
|
|
1136
1655
|
case "unlicensed":
|
|
@@ -1149,6 +1668,28 @@ function statusView(state) {
|
|
|
1149
1668
|
return "loading";
|
|
1150
1669
|
}
|
|
1151
1670
|
}
|
|
1671
|
+
function requestedView(screen, state) {
|
|
1672
|
+
const next = screen === "license" ? "details" : screen;
|
|
1673
|
+
if ((next === "details" || next === "addons") && !state.license)
|
|
1674
|
+
return null;
|
|
1675
|
+
return next;
|
|
1676
|
+
}
|
|
1677
|
+
function followState(view, before, state) {
|
|
1678
|
+
var _a;
|
|
1679
|
+
let next = view;
|
|
1680
|
+
const activated = before.status === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a = before.license) == null ? void 0 : _a.activationId);
|
|
1681
|
+
if (activated)
|
|
1682
|
+
next = "success";
|
|
1683
|
+
if ((next === "details" || next === "addons" || next === "update") && !state.license)
|
|
1684
|
+
next = null;
|
|
1685
|
+
if (state.status === "activating")
|
|
1686
|
+
next = null;
|
|
1687
|
+
if (state.status === "notCovered" && before.status !== "notCovered")
|
|
1688
|
+
next = null;
|
|
1689
|
+
if (next === "success" && !state.license)
|
|
1690
|
+
next = null;
|
|
1691
|
+
return next;
|
|
1692
|
+
}
|
|
1152
1693
|
function droppedFiles(dropped) {
|
|
1153
1694
|
if (typeof dropped === "string")
|
|
1154
1695
|
return [dropped];
|
|
@@ -1157,22 +1698,30 @@ function droppedFiles(dropped) {
|
|
|
1157
1698
|
const files = dropped == null ? void 0 : dropped.files;
|
|
1158
1699
|
return Array.isArray(files) ? files.filter((file) => typeof file === "string") : [];
|
|
1159
1700
|
}
|
|
1701
|
+
function displayPath(file) {
|
|
1702
|
+
const home = os2.homedir();
|
|
1703
|
+
return home && file.startsWith(home) ? `~${file.slice(home.length)}` : file;
|
|
1704
|
+
}
|
|
1160
1705
|
function Panel({ moonbase, state, screen, request, download, width: areaWidth, height: areaHeight }) {
|
|
1161
1706
|
var _a, _b, _c, _d, _e;
|
|
1162
1707
|
const ui = moonbase.ui;
|
|
1163
|
-
const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {} };
|
|
1708
|
+
const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {}, icon: (name2, colour, size, stroke) => moonbase.icon(name2, colour, size, stroke) };
|
|
1164
1709
|
const product = (_c = ui.productName) != null ? _c : "the plugin";
|
|
1165
1710
|
const account = ui.manufacturerName || "Moonbase";
|
|
1166
1711
|
const strings = (_d = ui.strings) != null ? _d : {};
|
|
1167
1712
|
const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
|
|
1168
1713
|
const width = cardWidth - PAD_X * 2;
|
|
1169
1714
|
const still = !!ui.reduceMotion;
|
|
1170
|
-
const
|
|
1715
|
+
const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
|
|
1716
|
+
const footer = showBadge ? 30 + 18 + 18 : 8;
|
|
1717
|
+
const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
|
|
1718
|
+
const [view, setView] = React3.useState(() => requestedView(screen, state));
|
|
1171
1719
|
const [update, setUpdate] = React3.useState(null);
|
|
1172
1720
|
const [cameFromDetails, setCameFromDetails] = React3.useState(false);
|
|
1173
1721
|
const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
|
|
1174
1722
|
const [copied, setCopied] = React3.useState(null);
|
|
1175
|
-
const
|
|
1723
|
+
const [seen, setSeen] = React3.useState({ state, request });
|
|
1724
|
+
const previous = React3.useRef(state);
|
|
1176
1725
|
const run2 = (name2, action) => {
|
|
1177
1726
|
action().catch((err) => moonbase.reportError(name2, err));
|
|
1178
1727
|
};
|
|
@@ -1195,38 +1744,38 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1195
1744
|
};
|
|
1196
1745
|
const flashCopied = (what) => {
|
|
1197
1746
|
setCopied(what);
|
|
1198
|
-
setTimeout(() => setCopied((
|
|
1747
|
+
setTimeout(() => setCopied((current2) => current2 === what ? null : current2), 2e3);
|
|
1199
1748
|
};
|
|
1749
|
+
let current = view;
|
|
1750
|
+
if (seen.request !== request || seen.state !== state) {
|
|
1751
|
+
let next = view;
|
|
1752
|
+
if (seen.request !== request) {
|
|
1753
|
+
next = requestedView(screen, state);
|
|
1754
|
+
if (screen === "update") {
|
|
1755
|
+
setCameFromDetails(false);
|
|
1756
|
+
setUpdate(null);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (seen.state !== state)
|
|
1760
|
+
next = followState(next, seen.state, state);
|
|
1761
|
+
setSeen({ state, request });
|
|
1762
|
+
if (next !== view)
|
|
1763
|
+
setView(next);
|
|
1764
|
+
current = next;
|
|
1765
|
+
}
|
|
1200
1766
|
React3.useEffect(() => {
|
|
1201
1767
|
if (screen === "update")
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
next = null;
|
|
1206
|
-
go(next);
|
|
1768
|
+
loadUpdate();
|
|
1769
|
+
else if (requestedView(screen, moonbase.state()) === "addons")
|
|
1770
|
+
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
1207
1771
|
}, [request]);
|
|
1208
1772
|
React3.useEffect(() => {
|
|
1209
|
-
var _a2;
|
|
1210
1773
|
const before = previous.current;
|
|
1211
1774
|
previous.current = state;
|
|
1212
|
-
|
|
1213
|
-
const activated = (before == null ? void 0 : before.status) === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a2 = before.license) == null ? void 0 : _a2.activationId);
|
|
1214
|
-
if (activated)
|
|
1215
|
-
next = "success";
|
|
1216
|
-
if ((next === "details" || next === "addons" || next === "update") && !state.license)
|
|
1217
|
-
next = null;
|
|
1218
|
-
if (state.status === "activating")
|
|
1219
|
-
next = null;
|
|
1220
|
-
if (state.status === "notCovered" && (before == null ? void 0 : before.status) !== "notCovered")
|
|
1221
|
-
next = null;
|
|
1222
|
-
if (next === "success" && !state.license)
|
|
1223
|
-
next = null;
|
|
1224
|
-
if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
|
|
1775
|
+
if (current === "addons" && state.license && state.addOns.phase === "idle" && before.addOns.phase !== "idle")
|
|
1225
1776
|
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
1226
|
-
if (next !== view)
|
|
1227
|
-
setView(next);
|
|
1228
1777
|
}, [state]);
|
|
1229
|
-
const name =
|
|
1778
|
+
const name = current != null ? current : statusView(state);
|
|
1230
1779
|
const lockup = (options = {}) => {
|
|
1231
1780
|
const size = options.large ? 38 : 34;
|
|
1232
1781
|
return {
|
|
@@ -1240,9 +1789,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1240
1789
|
const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
|
|
1241
1790
|
let right = x + available - (canClose ? 40 : 0);
|
|
1242
1791
|
for (const each2 of [...pills].reverse()) {
|
|
1243
|
-
const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
|
|
1792
|
+
const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick, each2.icon);
|
|
1244
1793
|
right -= drawn.width;
|
|
1245
|
-
nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
|
|
1794
|
+
nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick, each2.icon).node);
|
|
1246
1795
|
right -= 8;
|
|
1247
1796
|
}
|
|
1248
1797
|
return nodes;
|
|
@@ -1251,12 +1800,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1251
1800
|
const errorLine = (message) => {
|
|
1252
1801
|
if (!message)
|
|
1253
1802
|
return null;
|
|
1254
|
-
const body = paragraph(theme,
|
|
1255
|
-
return {
|
|
1803
|
+
const body = paragraph(theme, message, width - 22, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
|
|
1804
|
+
return {
|
|
1805
|
+
height: 14 + body.height,
|
|
1806
|
+
render: (x, y, available) => [icon(theme, "warning", x, y + 16, 15, palette.warningText), body.render(x + 22, y + 14, available - 22)]
|
|
1807
|
+
};
|
|
1256
1808
|
};
|
|
1257
1809
|
const backLink = (value, onClick) => ({
|
|
1258
|
-
height: 20 +
|
|
1259
|
-
render: (x, y) => h(
|
|
1810
|
+
height: 20 + 12,
|
|
1811
|
+
render: (x, y) => h(Link, { key: "back", theme, x, y, label: value, icon: "back", onClick })
|
|
1260
1812
|
});
|
|
1261
1813
|
const notice = (value, tone) => {
|
|
1262
1814
|
const body = paragraph(theme, value, width - 58, { size: 13, textColor: palette.textBody, lineHeight: 1.5 });
|
|
@@ -1264,7 +1816,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1264
1816
|
const tint = tone === "upgrade" ? palette.trial : palette.errorStrong;
|
|
1265
1817
|
return {
|
|
1266
1818
|
height: height + 24,
|
|
1267
|
-
render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 },
|
|
1819
|
+
render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, icon(theme, tone === "upgrade" ? "warning" : "blocked", 15, 13, 18, color(tone === "upgrade" ? palette.trial : palette.error)), body.render(44, 13, width - 58))
|
|
1268
1820
|
};
|
|
1269
1821
|
};
|
|
1270
1822
|
const features = () => {
|
|
@@ -1274,10 +1826,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1274
1826
|
return null;
|
|
1275
1827
|
return {
|
|
1276
1828
|
height: list.length * 30 - 11 + 26,
|
|
1277
|
-
render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 },
|
|
1829
|
+
render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, icon(theme, feature.included ? "check" : "cross", 0, 1, 17, feature.included ? color(palette.success) : palette.textMuted, 2), text(theme, feature.label, 27, 0, width - 27, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted, height: 20 })))
|
|
1278
1830
|
};
|
|
1279
1831
|
};
|
|
1280
|
-
const
|
|
1832
|
+
const below = (top2, block) => ({ height: top2 + block.height, render: (x, y, available) => block.render(x, y + top2, available) });
|
|
1833
|
+
const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()), { icon: "lock" });
|
|
1281
1834
|
const screens = {
|
|
1282
1835
|
loading: () => [
|
|
1283
1836
|
{ height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
|
|
@@ -1297,7 +1850,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1297
1850
|
space(28),
|
|
1298
1851
|
buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
|
|
1299
1852
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1300
|
-
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1853
|
+
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", icon: "signal", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1301
1854
|
];
|
|
1302
1855
|
},
|
|
1303
1856
|
browser: () => {
|
|
@@ -1323,20 +1876,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1323
1876
|
space(8),
|
|
1324
1877
|
paragraph(theme, body, width, { align: "center", maxWidth: 420 }),
|
|
1325
1878
|
space(22),
|
|
1326
|
-
failed && buttonBlock(theme, linkCopied ? "
|
|
1879
|
+
failed && buttonBlock(theme, linkCopied ? "Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center", icon: linkCopied ? "check" : "copy" }),
|
|
1327
1880
|
failed && space(18),
|
|
1328
1881
|
!!url && {
|
|
1329
1882
|
height: 50,
|
|
1330
1883
|
render: (x, y, available) => {
|
|
1331
1884
|
const value = `${moonbase.deviceName} \xB7 ${osLabel()}`;
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1885
|
+
const textBox = Math.min(available - 54, textWidth(theme, value, 12.5));
|
|
1886
|
+
const chipWidth = textBox + 15 + 9 + 30;
|
|
1887
|
+
return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, icon(theme, "computer", 15, 9, 15, palette.textSecondary, 1.6), text(theme, fitText(theme, value, 12.5, textBox, { end: true }), 39, 0, textBox, { size: 12.5, textColor: palette.textBright, height: 34 }));
|
|
1334
1888
|
}
|
|
1335
1889
|
},
|
|
1336
1890
|
buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
|
|
1337
1891
|
!!url && !failed && linksBlock(theme, [
|
|
1338
1892
|
{ label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
|
|
1339
|
-
{ label: linkCopied ? "
|
|
1893
|
+
{ label: linkCopied ? "Link copied" : "Browser didn't open? Copy the link", link: true, icon: linkCopied ? "check" : "copy", iconColour: linkCopied ? color(palette.success) : void 0, onClick: copyLink }
|
|
1340
1894
|
]),
|
|
1341
1895
|
errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
|
|
1342
1896
|
];
|
|
@@ -1345,7 +1899,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1345
1899
|
const license = state.license;
|
|
1346
1900
|
if (!license)
|
|
1347
1901
|
return screens[statusView(state)]();
|
|
1348
|
-
const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]];
|
|
1902
|
+
const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]].filter(([, value]) => !!value);
|
|
1349
1903
|
return [
|
|
1350
1904
|
{
|
|
1351
1905
|
height: 66 + 6,
|
|
@@ -1360,7 +1914,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1360
1914
|
height: rows.length * 34 + 32 + 26,
|
|
1361
1915
|
render: (x, y, available) => {
|
|
1362
1916
|
const cardWidth2 = Math.min(380, available);
|
|
1363
|
-
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 }))));
|
|
1917
|
+
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, fitText(theme, value, 13, cardWidth2 - 156, { weight: 500, end: true }), 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
|
|
1364
1918
|
}
|
|
1365
1919
|
},
|
|
1366
1920
|
buttonBlock(theme, `Open ${product}`, close, { width: 380, align: "center" }),
|
|
@@ -1368,24 +1922,25 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1368
1922
|
];
|
|
1369
1923
|
},
|
|
1370
1924
|
offline: () => {
|
|
1371
|
-
const saveSub = offline.saved ? `Saved to ${offline.saved}` : "Choose where to save it";
|
|
1372
1925
|
const requestFile = `${(product || "license").replace(/[\\/:*?"<>|]/g, "-")}.dt`;
|
|
1926
|
+
const textBox = width - 16 - 22 - 12 - 76;
|
|
1927
|
+
const saveSub = offline.saved ? fitText(theme, `Saved to ${displayPath(offline.saved)}`, 11.5, textBox) : "Choose where to save it";
|
|
1373
1928
|
const saveRequest = () => {
|
|
1374
|
-
setOffline((
|
|
1929
|
+
setOffline((current2) => ({ ...current2, error: "" }));
|
|
1375
1930
|
moonbase.saveMachineFile().then(
|
|
1376
|
-
(saved) => setOffline((
|
|
1931
|
+
(saved) => setOffline((current2) => ({ ...current2, saved: saved != null ? saved : current2.saved })),
|
|
1377
1932
|
(err) => {
|
|
1378
1933
|
moonbase.reportError("saveMachineFile", err);
|
|
1379
|
-
setOffline((
|
|
1934
|
+
setOffline((current2) => ({ ...current2, error: err instanceof Error ? err.message : String(err) }));
|
|
1380
1935
|
}
|
|
1381
1936
|
);
|
|
1382
1937
|
};
|
|
1383
1938
|
const useFile = (pick) => {
|
|
1384
1939
|
pick.then(
|
|
1385
|
-
(file) => file && setOffline((
|
|
1940
|
+
(file) => file && setOffline((current2) => ({ ...current2, file, error: "" })),
|
|
1386
1941
|
(err) => {
|
|
1387
1942
|
moonbase.reportError("readLicenseFile", err);
|
|
1388
|
-
setOffline((
|
|
1943
|
+
setOffline((current2) => ({ ...current2, error: "Couldn't read that file." }));
|
|
1389
1944
|
}
|
|
1390
1945
|
);
|
|
1391
1946
|
};
|
|
@@ -1393,54 +1948,58 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1393
1948
|
if (offline.busy)
|
|
1394
1949
|
return;
|
|
1395
1950
|
if (!offline.file) {
|
|
1396
|
-
setOffline((
|
|
1951
|
+
setOffline((current2) => ({ ...current2, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
|
|
1397
1952
|
return;
|
|
1398
1953
|
}
|
|
1399
|
-
setOffline((
|
|
1954
|
+
setOffline((current2) => ({ ...current2, busy: true, error: "" }));
|
|
1400
1955
|
moonbase.activateOffline(offline.file.text).then(() => {
|
|
1401
1956
|
setOffline({ saved: null, file: null, busy: false, error: "" });
|
|
1402
1957
|
setView("success");
|
|
1403
1958
|
}, () => {
|
|
1404
|
-
setOffline((
|
|
1959
|
+
setOffline((current2) => {
|
|
1405
1960
|
var _a2;
|
|
1406
|
-
return { ...
|
|
1961
|
+
return { ...current2, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
|
|
1407
1962
|
});
|
|
1408
1963
|
});
|
|
1409
1964
|
};
|
|
1410
1965
|
const step = (n, value) => ({
|
|
1411
|
-
height: 20 +
|
|
1412
|
-
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 }))
|
|
1966
|
+
height: 20 + 10,
|
|
1967
|
+
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, font: fontFor(theme, 600), fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
|
|
1413
1968
|
});
|
|
1969
|
+
const dropTitle = offline.file ? fitText(theme, offline.file.name, 13, width - 120, { mono: true }) : "Drop your license file here";
|
|
1970
|
+
const dropSub = offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb";
|
|
1971
|
+
const dropText = Math.max(textWidth(theme, dropTitle, 13, offline.file ? 400 : 500, { mono: !!offline.file }), textWidth(theme, dropSub, 11.5));
|
|
1972
|
+
const dropLeft = Math.round((width - 24 - 12 - dropText) / 2);
|
|
1414
1973
|
return [
|
|
1415
1974
|
backLink("Back", () => go(null)),
|
|
1416
1975
|
heading(theme, "Offline activation", width),
|
|
1417
1976
|
space(8),
|
|
1418
1977
|
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),
|
|
1419
|
-
space(
|
|
1978
|
+
space(18),
|
|
1420
1979
|
step("1", "Save your request file"),
|
|
1421
1980
|
{
|
|
1422
|
-
height:
|
|
1423
|
-
render: (x, y) => card({ x, y, width, height:
|
|
1981
|
+
height: 52 + 16,
|
|
1982
|
+
render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, icon(theme, "fileDown", 16, 15, 22, palette.glow, 1.6), text(theme, requestFile, 50, 7, textBox, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 50, 27, textBox, { size: 11.5, textColor: palette.textSecondary, height: 18 }), offline.saved ? icon(theme, "check", width - 16 - 20, 16, 20, color(palette.success), 2) : text(theme, "Save\u2026", width - 80, 0, 64, { size: 12, weight: 500, textColor: palette.glow, align: "right", height: 52 }))
|
|
1424
1983
|
},
|
|
1425
1984
|
step("2", "Add the license file"),
|
|
1426
1985
|
{
|
|
1427
|
-
height:
|
|
1986
|
+
height: 72,
|
|
1428
1987
|
render: (x, y) => h("geDropZone", {
|
|
1429
1988
|
key: "drop",
|
|
1430
1989
|
x,
|
|
1431
1990
|
y,
|
|
1432
1991
|
width,
|
|
1433
|
-
height:
|
|
1992
|
+
height: 72,
|
|
1434
1993
|
onDroppedFiles: (dropped) => {
|
|
1435
1994
|
const file = droppedFiles(dropped)[0];
|
|
1436
1995
|
if (file)
|
|
1437
1996
|
useFile(moonbase.readLicenseFile(file));
|
|
1438
1997
|
}
|
|
1439
|
-
}, card({ x: 0, y: 0, width, height:
|
|
1998
|
+
}, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, offline.file ? icon(theme, "okCircle", dropLeft, 24, 24, color(palette.success), 1.7) : icon(theme, "upload", dropLeft, 24, 24, palette.textSecondary, 1.6), text(theme, dropTitle, dropLeft + 36, 15, dropText + 4, { size: 13, weight: offline.file ? 400 : 500, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody }), text(theme, dropSub, dropLeft + 36, 38, dropText + 4, { size: 11.5, textColor: palette.textSecondary })))
|
|
1440
1999
|
},
|
|
1441
2000
|
errorLine(offline.error),
|
|
1442
|
-
space(
|
|
1443
|
-
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy })
|
|
2001
|
+
space(16),
|
|
2002
|
+
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy, height: 44 })
|
|
1444
2003
|
];
|
|
1445
2004
|
},
|
|
1446
2005
|
trial: () => {
|
|
@@ -1492,7 +2051,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1492
2051
|
paragraph(theme, body, width),
|
|
1493
2052
|
space(22),
|
|
1494
2053
|
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"),
|
|
1495
|
-
buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
|
|
2054
|
+
buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }),
|
|
1496
2055
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1497
2056
|
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()) }])
|
|
1498
2057
|
];
|
|
@@ -1506,25 +2065,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1506
2065
|
["Licensed to", license.issuedTo.name || license.issuedTo.email],
|
|
1507
2066
|
["Email", license.issuedTo.email],
|
|
1508
2067
|
["Plan", `${planName(license)} \xB7 ${license.expiresAt ? `until ${formatDate(license.expiresAt)}` : "perpetual"}`]
|
|
1509
|
-
];
|
|
2068
|
+
].filter(([, value]) => !!value);
|
|
1510
2069
|
const seatCount = license.seatCount;
|
|
1511
2070
|
const used = license.seatsUsed;
|
|
1512
2071
|
const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
|
|
2072
|
+
const lit = !seatCount || !used ? 0 : used >= seatCount ? pipCount : Math.max(1, Math.min(pipCount - 1, Math.round(used / seatCount * pipCount)));
|
|
1513
2073
|
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";
|
|
1514
2074
|
const idCopied = copied === license.id;
|
|
1515
2075
|
const rowHeight = 44;
|
|
2076
|
+
const valueWidth = width - 172;
|
|
1516
2077
|
return [
|
|
1517
2078
|
header([
|
|
1518
|
-
...state.update ? [{ tone: "update", text: "
|
|
2079
|
+
...state.update ? [{ tone: "update", text: "Update", icon: "download", onClick: () => openUpdate(true) }] : [],
|
|
1519
2080
|
{ tone: "active", text: license.trial ? "Trial" : "Active" }
|
|
1520
2081
|
]),
|
|
1521
2082
|
{
|
|
1522
2083
|
height: (rows.length + 1) * rowHeight + 2 + 18,
|
|
1523
|
-
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,
|
|
2084
|
+
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, fitText(theme, value, 13, valueWidth, { weight: 500, end: key !== "Email" }), 140, 0, valueWidth, { size: 13, weight: 500, textColor: key === "Email" ? 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 - 96, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 86, y: 7, width: 86, height: 30, label: idCopied ? "Copied" : "Copy", icon: idCopied ? "check" : "copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
|
|
1524
2085
|
},
|
|
1525
2086
|
{
|
|
1526
2087
|
height: 64 + 22,
|
|
1527
|
-
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 <
|
|
2088
|
+
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, {
|
|
1528
2089
|
key: "deactivate",
|
|
1529
2090
|
theme,
|
|
1530
2091
|
x: width - 16 - 178,
|
|
@@ -1540,7 +2101,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1540
2101
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1541
2102
|
ui.showAddOns && !license.trial && {
|
|
1542
2103
|
height: 62 + (state.error ? 14 : 0),
|
|
1543
|
-
render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, text(theme, "Add-ons",
|
|
2104
|
+
render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, icon(theme, "puzzle", 16, 21, 20, color(theme.accent), 1.7), text(theme, "Add-ons", 49, 12, width - 100, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 49, 32, width - 100, { size: 12, textColor: palette.textSecondary }), icon(theme, "chevron", width - 16 - 18, 22, 18, palette.textSecondary, 2))
|
|
1544
2105
|
}
|
|
1545
2106
|
];
|
|
1546
2107
|
},
|
|
@@ -1563,12 +2124,14 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1563
2124
|
list = {
|
|
1564
2125
|
height: listHeight,
|
|
1565
2126
|
render: (x, y) => {
|
|
1566
|
-
const
|
|
1567
|
-
|
|
2127
|
+
const scrolls2 = rows.length > visible;
|
|
2128
|
+
const rowWidth = scrolls2 ? width - SCROLLBAR - 8 : width;
|
|
2129
|
+
const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), rowWidth, rowHeight));
|
|
2130
|
+
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);
|
|
1568
2131
|
}
|
|
1569
2132
|
};
|
|
1570
2133
|
} else if (info.phase !== "ready") {
|
|
1571
|
-
list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight })) };
|
|
2134
|
+
list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight }, label({ x: 16, y: 13, width: 38, height: 38, cornerRadius: 10, backgroundColor: color("#ffffff", 0.05) }), label({ x: 68, y: 21, width: Math.round(width * 0.34), height: 10, cornerRadius: 5, backgroundColor: color("#ffffff", 0.07) }), label({ x: 68, y: 40, width: Math.round(width * 0.52), height: 8, cornerRadius: 4, backgroundColor: color("#ffffff", 0.07) }))) };
|
|
1572
2135
|
} else if (failed) {
|
|
1573
2136
|
list = (_a2 = errorLine(info.error)) != null ? _a2 : space(0);
|
|
1574
2137
|
} else {
|
|
@@ -1587,7 +2150,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1587
2150
|
link: true,
|
|
1588
2151
|
disabled: loading || waiting,
|
|
1589
2152
|
onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
|
|
1590
|
-
}], { align: "left" })
|
|
2153
|
+
}], { align: "left", marginTop: 18 })
|
|
1591
2154
|
];
|
|
1592
2155
|
},
|
|
1593
2156
|
update: () => {
|
|
@@ -1615,41 +2178,30 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1615
2178
|
const notCovered = update.covered === false || download.phase === "notCovered";
|
|
1616
2179
|
const access = (_a2 = download.releaseAccess) != null ? _a2 : update.releaseAccess;
|
|
1617
2180
|
const upgradeUrl = (_b2 = download.upgradeUrl) != null ? _b2 : update.upgradeUrl;
|
|
1618
|
-
const noteBlocks = notes.map((note) => paragraph(theme, note, width - 70, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
|
|
1619
|
-
const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
|
|
1620
2181
|
let action;
|
|
1621
2182
|
if (download.phase === "done")
|
|
1622
|
-
action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
|
|
2183
|
+
action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()), { icon: "download" });
|
|
1623
2184
|
else if (notCovered)
|
|
1624
|
-
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
|
|
2185
|
+
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }) : null;
|
|
1625
2186
|
else if (update.canDownload)
|
|
1626
|
-
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
|
|
2187
|
+
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading, icon: downloading ? void 0 : "download" });
|
|
1627
2188
|
else
|
|
1628
2189
|
action = update.hasDownloads ? unlock() : null;
|
|
1629
2190
|
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.";
|
|
1630
|
-
|
|
2191
|
+
const above = [
|
|
1631
2192
|
lockup(),
|
|
1632
2193
|
space(24),
|
|
1633
|
-
{ height: 24 + 14, render: (x, y) => pill(theme, "update", "
|
|
2194
|
+
{ height: 24 + 14, render: (x, y) => pill(theme, "update", "Update available", x, y, void 0, "download").node },
|
|
1634
2195
|
heading(theme, `${product} ${update.latestVersion} is ready`, width),
|
|
1635
2196
|
space(8),
|
|
1636
2197
|
paragraph(theme, `You're on ${update.currentVersion || "an earlier version"}. The latest is ${update.latestVersion}${standing}`, width),
|
|
1637
|
-
space(20)
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
render: (x, y) => {
|
|
1641
|
-
let top2 = 44;
|
|
1642
|
-
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) => {
|
|
1643
|
-
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));
|
|
1644
|
-
top2 += block.height + 8;
|
|
1645
|
-
return node;
|
|
1646
|
-
}));
|
|
1647
|
-
}
|
|
1648
|
-
},
|
|
2198
|
+
space(20)
|
|
2199
|
+
];
|
|
2200
|
+
const after = [
|
|
1649
2201
|
downloading && barBlock(percent !== null ? percent / 100 : 0.08, color(theme.accent), { marginTop: 0, marginBottom: 14 }),
|
|
1650
2202
|
action,
|
|
1651
|
-
download.phase === "done" && !!download.path &&
|
|
1652
|
-
notCovered && paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted }),
|
|
2203
|
+
download.phase === "done" && !!download.path && below(12, paragraph(theme, fitText(theme, `Saved to ${displayPath(download.path)}`, 12.5, width), width, { size: 12.5, align: "center" })),
|
|
2204
|
+
notCovered && below(16, paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted })),
|
|
1653
2205
|
errorLine(download.phase === "failed" ? download.error : null),
|
|
1654
2206
|
linksBlock(theme, [
|
|
1655
2207
|
{ label: "Remind me later", onClick: back },
|
|
@@ -1659,6 +2211,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1659
2211
|
} }
|
|
1660
2212
|
])
|
|
1661
2213
|
];
|
|
2214
|
+
const noteWidth = width - 36 - 26 - SCROLLBAR - 4;
|
|
2215
|
+
const noteBlocks = notes.map((note) => paragraph(theme, note, noteWidth, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
|
|
2216
|
+
const listNatural = noteBlocks.reduce((sum, block) => sum + block.height, 0) + Math.max(0, noteBlocks.length - 1) * 10;
|
|
2217
|
+
const chrome = 16 + 17 + 12 + 16 + 22;
|
|
2218
|
+
const taken = [...above, ...after].reduce((sum, block) => sum + (block ? block.height : 0), 0);
|
|
2219
|
+
const listHeight = Math.min(listNatural, 190, Math.max(Math.min(listNatural, 40), room - taken - chrome));
|
|
2220
|
+
const listScrolls = listHeight < listNatural;
|
|
2221
|
+
const notesBlock = notes.length > 0 && {
|
|
2222
|
+
height: listHeight + chrome,
|
|
2223
|
+
render: (x, y) => {
|
|
2224
|
+
let top2 = 0;
|
|
2225
|
+
const rowWidth = width - 36 - (listScrolls ? SCROLLBAR + 4 : 0);
|
|
2226
|
+
const rows = noteBlocks.map((block, index) => {
|
|
2227
|
+
const node = label({ key: `note-${index}`, x: 0, y: top2, width: rowWidth, height: block.height }, icon(theme, "check", 0, 2, 16, color(theme.accent), 2), block.render(26, 0, rowWidth - 26));
|
|
2228
|
+
top2 += block.height + 10;
|
|
2229
|
+
return node;
|
|
2230
|
+
});
|
|
2231
|
+
return card({ x, y, width, height: listHeight + chrome - 22 }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), listScrolls ? scrollView({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, listNatural, ...rows) : label({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, ...rows));
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
return [...above, notesBlock, ...after];
|
|
1662
2235
|
}
|
|
1663
2236
|
};
|
|
1664
2237
|
const addOnActions = {
|
|
@@ -1675,24 +2248,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1675
2248
|
const buttons = actions.reverse().map((action) => {
|
|
1676
2249
|
const primary = action === row.primary;
|
|
1677
2250
|
const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
|
|
1678
|
-
const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
|
|
2251
|
+
const buttonWidth = Math.max(76, textWidth(theme, value, 13, 600) + 32);
|
|
1679
2252
|
right -= buttonWidth;
|
|
1680
2253
|
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)) });
|
|
1681
2254
|
right -= 8;
|
|
1682
2255
|
return node;
|
|
1683
2256
|
});
|
|
1684
|
-
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),
|
|
2257
|
+
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) }, icon(theme, row.tone === "success" ? "check" : "sparkles", 9, 9, 20, tint ? color(tint) : palette.textSecondary, 1.7)), text(theme, fitText(theme, row.name, 14, right - 76, { weight: 600, end: true }), 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, fitText(theme, row.status, 12.5, right - 76, { end: true }), 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
|
|
1685
2258
|
}
|
|
1686
2259
|
const blocks = screens[name]();
|
|
1687
|
-
const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
|
|
1688
|
-
const footer = showBadge ? 30 + 18 + 18 : 8;
|
|
1689
2260
|
const screenHeight = blocks.reduce((sum, block) => sum + (block ? block.height : 0), 0);
|
|
1690
|
-
const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
|
|
1691
2261
|
const scrolls = screenHeight > room;
|
|
1692
2262
|
let content;
|
|
1693
2263
|
if (scrolls) {
|
|
1694
2264
|
const inner = stack(blocks, PAD_X, 0, width);
|
|
1695
|
-
content = { height: room, nodes: [
|
|
2265
|
+
content = { height: room, nodes: [scrollView({ key: "screen", x: 0, y: PAD_TOP, width: cardWidth - 10, height: room }, inner.height, ...inner.nodes)] };
|
|
1696
2266
|
} else {
|
|
1697
2267
|
content = stack(blocks, PAD_X, PAD_TOP, width);
|
|
1698
2268
|
}
|
|
@@ -1708,13 +2278,13 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1708
2278
|
screen: name,
|
|
1709
2279
|
contentHeight: content.height,
|
|
1710
2280
|
content: content.nodes,
|
|
1711
|
-
closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "
|
|
2281
|
+
closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "", icon: "cross", iconSize: 18, kind: "quiet", onClick: close }),
|
|
1712
2282
|
// Kept to the card's bottom edge as it resizes.
|
|
1713
2283
|
footer: showBadge ? (height) => {
|
|
1714
2284
|
const divider = height - footer - PAD_BOTTOM + 30;
|
|
1715
2285
|
return [
|
|
1716
2286
|
label({ key: "divider", x: PAD_X, y: divider, width, height: 1, backgroundColor: color("#ffffff", 0.06) }),
|
|
1717
|
-
h(
|
|
2287
|
+
h(Badge, { key: "badge", theme, x: PAD_X, y: divider + 14, width, mark: moonbase.moonbaseMark(), onClick: () => run2("openLink", () => moonbase.openLink("https://moonbase.sh")) })
|
|
1718
2288
|
];
|
|
1719
2289
|
} : null,
|
|
1720
2290
|
still
|
|
@@ -1732,30 +2302,33 @@ function PanelCard(props) {
|
|
|
1732
2302
|
return card(
|
|
1733
2303
|
{ x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
|
|
1734
2304
|
h(Glow, { key: "glow", width: props.width, still: props.still }),
|
|
1735
|
-
label({ key:
|
|
2305
|
+
label({ key: `screen-${props.screen}`, x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
|
|
1736
2306
|
props.closeButton,
|
|
1737
2307
|
...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
|
|
1738
2308
|
);
|
|
1739
2309
|
}
|
|
1740
|
-
function
|
|
1741
|
-
var _a;
|
|
2310
|
+
function Badge(props) {
|
|
1742
2311
|
const [hovered, setHovered] = React3.useState(false);
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
2312
|
+
const lead = "Licensing secured by";
|
|
2313
|
+
const gap = 7;
|
|
2314
|
+
const size = props.mark ? 14 : 0;
|
|
2315
|
+
const markGap = props.mark ? gap : 0;
|
|
2316
|
+
const lock = 14;
|
|
2317
|
+
const leadWidth = textWidth(props.theme, lead, 11);
|
|
2318
|
+
const wordmark = textWidth(props.theme, "moonbase", 12, 500, { kerning: 0.06 }) + 4;
|
|
2319
|
+
const start = Math.round((props.width - (lock + gap + leadWidth + gap + size + markGap + wordmark)) / 2);
|
|
2320
|
+
const linkX = start + lock + gap + leadWidth + gap;
|
|
2321
|
+
return label({ x: props.x, y: props.y, width: props.width, height: 20 }, icon(props.theme, "lock", start, 3, lock, palette.textMuted, 1.5), text(props.theme, lead, start + lock + gap, 0, leadWidth + 2, { size: 11, textColor: palette.textMuted, height: 20 }), label({
|
|
2322
|
+
x: linkX,
|
|
2323
|
+
y: 0,
|
|
2324
|
+
width: size + markGap + wordmark,
|
|
1748
2325
|
height: 20,
|
|
1749
|
-
text: props.value,
|
|
1750
|
-
fontSize: props.muted ? 11 : 12.5,
|
|
1751
|
-
textColor: hovered ? palette.textBright : props.muted ? palette.textMuted : palette.textSecondary,
|
|
1752
|
-
textAlign: props.center ? "center" : "centered left",
|
|
1753
2326
|
interceptsMouseClicks: true,
|
|
1754
2327
|
mouseCursorType: "pointing hand",
|
|
1755
2328
|
onMouseEnter: () => setHovered(true),
|
|
1756
2329
|
onMouseExit: () => setHovered(false),
|
|
1757
2330
|
onClick: props.onClick
|
|
1758
|
-
});
|
|
2331
|
+
}, 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 })));
|
|
1759
2332
|
}
|
|
1760
2333
|
function osLabel() {
|
|
1761
2334
|
switch (process2.platform) {
|
|
@@ -1781,6 +2354,7 @@ function MoonbaseActivation(props) {
|
|
|
1781
2354
|
const { moonbase, width, height } = props;
|
|
1782
2355
|
const state = useMoonbaseState(moonbase);
|
|
1783
2356
|
const ui = useUiState(moonbase);
|
|
2357
|
+
const metrics = useFontMetrics(moonbase.ui);
|
|
1784
2358
|
const shown = ui.visible ? 1 : 0;
|
|
1785
2359
|
const [scrim, rise] = useTween([
|
|
1786
2360
|
{ to: shown, duration: 250, ease: EASE_CSS },
|
|
@@ -1803,7 +2377,7 @@ function MoonbaseActivation(props) {
|
|
|
1803
2377
|
// the front, after the customer bought an add-on in the browser.
|
|
1804
2378
|
onMouseEnter: () => moonbase.onFocusChanged(true),
|
|
1805
2379
|
onMouseExit: () => moonbase.onFocusChanged(false)
|
|
1806
|
-
}, 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 })));
|
|
2380
|
+
}, 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, metrics })));
|
|
1807
2381
|
}
|
|
1808
2382
|
|
|
1809
2383
|
// src/index.ts
|