@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.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(src_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
44
|
|
|
45
45
|
// src/moonbase.ts
|
|
46
|
+
var import_node_buffer2 = require("buffer");
|
|
46
47
|
var import_node_child_process = require("child_process");
|
|
47
48
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
48
49
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
@@ -52,7 +53,7 @@ var import_node_process = __toESM(require("process"), 1);
|
|
|
52
53
|
var import_licensing = require("@moonbase.sh/licensing");
|
|
53
54
|
|
|
54
55
|
// package.json
|
|
55
|
-
var version = "0.
|
|
56
|
+
var version = "0.3.0";
|
|
56
57
|
|
|
57
58
|
// src/download.ts
|
|
58
59
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
@@ -77,6 +78,300 @@ function uniquePath(dir, name) {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
// src/icons.ts
|
|
82
|
+
var import_node_buffer = require("buffer");
|
|
83
|
+
var import_node_zlib = require("zlib");
|
|
84
|
+
var ICON_PATHS = {
|
|
85
|
+
check: "M4.5 12.75l6 6 9-13.5",
|
|
86
|
+
cross: "M6 18 18 6M6 6l12 12",
|
|
87
|
+
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",
|
|
88
|
+
back: "M15.75 19.5 8.25 12l7.5-7.5",
|
|
89
|
+
chevron: "m8.25 4.5 7.5 7.5-7.5 7.5",
|
|
90
|
+
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",
|
|
91
|
+
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",
|
|
92
|
+
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",
|
|
93
|
+
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",
|
|
94
|
+
okCircle: "M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",
|
|
95
|
+
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",
|
|
96
|
+
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",
|
|
97
|
+
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",
|
|
98
|
+
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",
|
|
99
|
+
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",
|
|
100
|
+
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",
|
|
101
|
+
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"
|
|
102
|
+
};
|
|
103
|
+
function polylines(d) {
|
|
104
|
+
const lines = [];
|
|
105
|
+
let at = 0;
|
|
106
|
+
let command = "";
|
|
107
|
+
let x = 0;
|
|
108
|
+
let y = 0;
|
|
109
|
+
let startX = 0;
|
|
110
|
+
let startY = 0;
|
|
111
|
+
let control = null;
|
|
112
|
+
let line = [];
|
|
113
|
+
const skip = () => {
|
|
114
|
+
while (at < d.length && /[\s,]/.test(d[at]))
|
|
115
|
+
at++;
|
|
116
|
+
};
|
|
117
|
+
const isCommand = (character) => !!character && /[MLHVCSQTAZ]/i.test(character);
|
|
118
|
+
const number = () => {
|
|
119
|
+
skip();
|
|
120
|
+
const match = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/i.exec(d.slice(at));
|
|
121
|
+
if (!match)
|
|
122
|
+
throw new Error(`Expected a number at ${at} in ${d}`);
|
|
123
|
+
at += match[0].length;
|
|
124
|
+
return Number(match[0]);
|
|
125
|
+
};
|
|
126
|
+
const flag = () => {
|
|
127
|
+
skip();
|
|
128
|
+
const character = d[at++];
|
|
129
|
+
if (character !== "0" && character !== "1")
|
|
130
|
+
throw new Error(`Expected an arc flag at ${at - 1} in ${d}`);
|
|
131
|
+
return character === "1";
|
|
132
|
+
};
|
|
133
|
+
const to = (nextX, nextY) => {
|
|
134
|
+
x = nextX;
|
|
135
|
+
y = nextY;
|
|
136
|
+
line.push([x, y]);
|
|
137
|
+
};
|
|
138
|
+
const cubic = (x1, y1, x2, y2, endX, endY) => {
|
|
139
|
+
const [x0, y0] = [x, y];
|
|
140
|
+
for (let step = 1; step <= 16; step++) {
|
|
141
|
+
const t = step / 16;
|
|
142
|
+
const u = 1 - t;
|
|
143
|
+
line.push([
|
|
144
|
+
u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * endX,
|
|
145
|
+
u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * endY
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
x = endX;
|
|
149
|
+
y = endY;
|
|
150
|
+
control = [x2, y2];
|
|
151
|
+
};
|
|
152
|
+
for (; ; ) {
|
|
153
|
+
skip();
|
|
154
|
+
if (at >= d.length)
|
|
155
|
+
break;
|
|
156
|
+
if (isCommand(d[at]))
|
|
157
|
+
command = d[at++];
|
|
158
|
+
else if (!command)
|
|
159
|
+
throw new Error(`Expected a command at ${at} in ${d}`);
|
|
160
|
+
const relative = command === command.toLowerCase();
|
|
161
|
+
const ox = relative ? x : 0;
|
|
162
|
+
const oy = relative ? y : 0;
|
|
163
|
+
const smooth = control;
|
|
164
|
+
control = null;
|
|
165
|
+
switch (command.toUpperCase()) {
|
|
166
|
+
case "M": {
|
|
167
|
+
x = number() + ox;
|
|
168
|
+
y = number() + oy;
|
|
169
|
+
startX = x;
|
|
170
|
+
startY = y;
|
|
171
|
+
line = [[x, y]];
|
|
172
|
+
lines.push(line);
|
|
173
|
+
command = relative ? "l" : "L";
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case "L": {
|
|
177
|
+
const nextX = number() + ox;
|
|
178
|
+
to(nextX, number() + oy);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "H":
|
|
182
|
+
to(number() + ox, y);
|
|
183
|
+
break;
|
|
184
|
+
case "V":
|
|
185
|
+
to(x, number() + oy);
|
|
186
|
+
break;
|
|
187
|
+
case "C": {
|
|
188
|
+
const x1 = number() + ox;
|
|
189
|
+
const y1 = number() + oy;
|
|
190
|
+
const x2 = number() + ox;
|
|
191
|
+
const y2 = number() + oy;
|
|
192
|
+
const endX = number() + ox;
|
|
193
|
+
cubic(x1, y1, x2, y2, endX, number() + oy);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case "S": {
|
|
197
|
+
const [x1, y1] = smooth ? [2 * x - smooth[0], 2 * y - smooth[1]] : [x, y];
|
|
198
|
+
const x2 = number() + ox;
|
|
199
|
+
const y2 = number() + oy;
|
|
200
|
+
const endX = number() + ox;
|
|
201
|
+
cubic(x1, y1, x2, y2, endX, number() + oy);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
case "Q": {
|
|
205
|
+
const qx = number() + ox;
|
|
206
|
+
const qy = number() + oy;
|
|
207
|
+
const endX = number() + ox;
|
|
208
|
+
const endY = number() + oy;
|
|
209
|
+
cubic(x + 2 / 3 * (qx - x), y + 2 / 3 * (qy - y), endX + 2 / 3 * (qx - endX), endY + 2 / 3 * (qy - endY), endX, endY);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case "A": {
|
|
213
|
+
const rx = number();
|
|
214
|
+
const ry = number();
|
|
215
|
+
const rotation = number();
|
|
216
|
+
const large = flag();
|
|
217
|
+
const sweep = flag();
|
|
218
|
+
const endX = number() + ox;
|
|
219
|
+
const endY = number() + oy;
|
|
220
|
+
for (const point of arc(x, y, rx, ry, rotation, large, sweep, endX, endY))
|
|
221
|
+
line.push(point);
|
|
222
|
+
x = endX;
|
|
223
|
+
y = endY;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
case "Z":
|
|
227
|
+
to(startX, startY);
|
|
228
|
+
line = [[x, y]];
|
|
229
|
+
lines.push(line);
|
|
230
|
+
skip();
|
|
231
|
+
if (at < d.length && !isCommand(d[at]))
|
|
232
|
+
throw new Error(`Expected a command after Z at ${at} in ${d}`);
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw new Error(`Unsupported command ${command} in ${d}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return lines;
|
|
239
|
+
}
|
|
240
|
+
function arc(x1, y1, rx, ry, rotation, large, sweep, x2, y2) {
|
|
241
|
+
if (rx === 0 || ry === 0)
|
|
242
|
+
return [[x2, y2]];
|
|
243
|
+
rx = Math.abs(rx);
|
|
244
|
+
ry = Math.abs(ry);
|
|
245
|
+
const phi = rotation * Math.PI / 180;
|
|
246
|
+
const cos = Math.cos(phi);
|
|
247
|
+
const sin = Math.sin(phi);
|
|
248
|
+
const dx = (x1 - x2) / 2;
|
|
249
|
+
const dy = (y1 - y2) / 2;
|
|
250
|
+
const x1p = cos * dx + sin * dy;
|
|
251
|
+
const y1p = -sin * dx + cos * dy;
|
|
252
|
+
const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
|
|
253
|
+
if (lambda > 1) {
|
|
254
|
+
rx *= Math.sqrt(lambda);
|
|
255
|
+
ry *= Math.sqrt(lambda);
|
|
256
|
+
}
|
|
257
|
+
const numerator = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
|
|
258
|
+
const denominator = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
|
|
259
|
+
let coefficient = Math.sqrt(Math.max(0, numerator / denominator));
|
|
260
|
+
if (large === sweep)
|
|
261
|
+
coefficient = -coefficient;
|
|
262
|
+
const cxp = coefficient * rx * y1p / ry;
|
|
263
|
+
const cyp = -coefficient * ry * x1p / rx;
|
|
264
|
+
const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
|
|
265
|
+
const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
|
|
266
|
+
const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
|
|
267
|
+
const start = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
|
|
268
|
+
let delta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
|
|
269
|
+
if (!sweep && delta > 0)
|
|
270
|
+
delta -= 2 * Math.PI;
|
|
271
|
+
else if (sweep && delta < 0)
|
|
272
|
+
delta += 2 * Math.PI;
|
|
273
|
+
const steps = Math.max(2, Math.ceil(Math.abs(delta) / (Math.PI / 24)));
|
|
274
|
+
const points = [];
|
|
275
|
+
for (let step = 1; step <= steps; step++) {
|
|
276
|
+
const t = start + delta * step / steps;
|
|
277
|
+
points.push([cos * rx * Math.cos(t) - sin * ry * Math.sin(t) + cx, sin * rx * Math.cos(t) + cos * ry * Math.sin(t) + cy]);
|
|
278
|
+
}
|
|
279
|
+
return points;
|
|
280
|
+
}
|
|
281
|
+
function coverage(d, pixels, strokeWidth) {
|
|
282
|
+
const scale = pixels / 24;
|
|
283
|
+
const half = strokeWidth * scale / 2;
|
|
284
|
+
const segments = [];
|
|
285
|
+
for (const line of polylines(d)) {
|
|
286
|
+
const points = line.map(([px, py]) => [px * scale, py * scale]);
|
|
287
|
+
if (points.length === 1)
|
|
288
|
+
segments.push([points[0][0], points[0][1], points[0][0], points[0][1]]);
|
|
289
|
+
for (let index = 1; index < points.length; index++)
|
|
290
|
+
segments.push([points[index - 1][0], points[index - 1][1], points[index][0], points[index][1]]);
|
|
291
|
+
}
|
|
292
|
+
const reach = half + 1;
|
|
293
|
+
const out = new Float32Array(pixels * pixels);
|
|
294
|
+
for (const [ax, ay, bx, by] of segments) {
|
|
295
|
+
const left = Math.max(0, Math.floor(Math.min(ax, bx) - reach));
|
|
296
|
+
const right = Math.min(pixels - 1, Math.ceil(Math.max(ax, bx) + reach));
|
|
297
|
+
const top = Math.max(0, Math.floor(Math.min(ay, by) - reach));
|
|
298
|
+
const bottom = Math.min(pixels - 1, Math.ceil(Math.max(ay, by) + reach));
|
|
299
|
+
const vx = bx - ax;
|
|
300
|
+
const vy = by - ay;
|
|
301
|
+
const length = vx * vx + vy * vy;
|
|
302
|
+
for (let py = top; py <= bottom; py++) {
|
|
303
|
+
for (let px = left; px <= right; px++) {
|
|
304
|
+
const cx = px + 0.5;
|
|
305
|
+
const cy = py + 0.5;
|
|
306
|
+
const t = length === 0 ? 0 : Math.max(0, Math.min(1, ((cx - ax) * vx + (cy - ay) * vy) / length));
|
|
307
|
+
const distance = Math.hypot(cx - (ax + t * vx), cy - (ay + t * vy));
|
|
308
|
+
const value = Math.max(0, Math.min(1, half + 0.5 - distance));
|
|
309
|
+
const index = py * pixels + px;
|
|
310
|
+
if (value > out[index])
|
|
311
|
+
out[index] = value;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
var CRC_TABLE = (() => {
|
|
318
|
+
const table = new Uint32Array(256);
|
|
319
|
+
for (let n = 0; n < 256; n++) {
|
|
320
|
+
let c = n;
|
|
321
|
+
for (let k = 0; k < 8; k++)
|
|
322
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
323
|
+
table[n] = c >>> 0;
|
|
324
|
+
}
|
|
325
|
+
return table;
|
|
326
|
+
})();
|
|
327
|
+
function crc32(bytes) {
|
|
328
|
+
let c = 4294967295;
|
|
329
|
+
for (const byte of bytes)
|
|
330
|
+
c = CRC_TABLE[(c ^ byte) & 255] ^ c >>> 8;
|
|
331
|
+
return (c ^ 4294967295) >>> 0;
|
|
332
|
+
}
|
|
333
|
+
function chunk(type, data) {
|
|
334
|
+
const length = import_node_buffer.Buffer.alloc(4);
|
|
335
|
+
length.writeUInt32BE(data.length);
|
|
336
|
+
const body = import_node_buffer.Buffer.concat([import_node_buffer.Buffer.from(type, "ascii"), data]);
|
|
337
|
+
const crc = import_node_buffer.Buffer.alloc(4);
|
|
338
|
+
crc.writeUInt32BE(crc32(body));
|
|
339
|
+
return import_node_buffer.Buffer.concat([length, body, crc]);
|
|
340
|
+
}
|
|
341
|
+
function encodePng(width, height, rgba) {
|
|
342
|
+
const header = import_node_buffer.Buffer.alloc(13);
|
|
343
|
+
header.writeUInt32BE(width, 0);
|
|
344
|
+
header.writeUInt32BE(height, 4);
|
|
345
|
+
header[8] = 8;
|
|
346
|
+
header[9] = 6;
|
|
347
|
+
const raw = import_node_buffer.Buffer.alloc((width * 4 + 1) * height);
|
|
348
|
+
for (let row = 0; row < height; row++)
|
|
349
|
+
import_node_buffer.Buffer.from(rgba.buffer, rgba.byteOffset + row * width * 4, width * 4).copy(raw, row * (width * 4 + 1) + 1);
|
|
350
|
+
return import_node_buffer.Buffer.concat([
|
|
351
|
+
import_node_buffer.Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
|
|
352
|
+
chunk("IHDR", header),
|
|
353
|
+
chunk("IDAT", (0, import_node_zlib.deflateSync)(raw)),
|
|
354
|
+
chunk("IEND", import_node_buffer.Buffer.alloc(0))
|
|
355
|
+
]);
|
|
356
|
+
}
|
|
357
|
+
function iconPng(name, colour, pixels, strokeWidth) {
|
|
358
|
+
const argb = Number.parseInt(colour, 16);
|
|
359
|
+
const alpha = (argb >>> 24 & 255) / 255;
|
|
360
|
+
const cover = coverage(ICON_PATHS[name], pixels, strokeWidth);
|
|
361
|
+
const rgba = new Uint8Array(pixels * pixels * 4);
|
|
362
|
+
for (let index = 0; index < cover.length; index++) {
|
|
363
|
+
rgba[index * 4] = argb >>> 16 & 255;
|
|
364
|
+
rgba[index * 4 + 1] = argb >>> 8 & 255;
|
|
365
|
+
rgba[index * 4 + 2] = argb & 255;
|
|
366
|
+
rgba[index * 4 + 3] = Math.round(cover[index] * alpha * 255);
|
|
367
|
+
}
|
|
368
|
+
return encodePng(pixels, pixels, rgba);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// src/mark.ts
|
|
372
|
+
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";
|
|
373
|
+
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==";
|
|
374
|
+
|
|
80
375
|
// src/moonbase.ts
|
|
81
376
|
function runtime() {
|
|
82
377
|
var _a;
|
|
@@ -156,6 +451,11 @@ function errorKind(err) {
|
|
|
156
451
|
return (_a = err.type) != null ? _a : "internal";
|
|
157
452
|
return "internal";
|
|
158
453
|
}
|
|
454
|
+
function writeIfChanged(file, data) {
|
|
455
|
+
if (import_node_fs2.default.existsSync(file) && import_node_fs2.default.readFileSync(file).equals(data))
|
|
456
|
+
return;
|
|
457
|
+
import_node_fs2.default.writeFileSync(file, data);
|
|
458
|
+
}
|
|
159
459
|
var MoonbaseGorillaEngine = class extends import_licensing.ActivationController {
|
|
160
460
|
constructor(options) {
|
|
161
461
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -183,6 +483,9 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
183
483
|
this.stopFocus = null;
|
|
184
484
|
/** Aborts the update download when the instance is disposed. */
|
|
185
485
|
this.aborts = new AbortController();
|
|
486
|
+
/** Each icon's file, by name, colour, size and stroke; null when it couldn't be written. */
|
|
487
|
+
this.iconFiles = /* @__PURE__ */ new Map();
|
|
488
|
+
this.iconsFailed = false;
|
|
186
489
|
this.ui = { ...ui, productName };
|
|
187
490
|
this.endpoint = options.endpoint;
|
|
188
491
|
this.host = host;
|
|
@@ -244,6 +547,54 @@ var MoonbaseGorillaEngine = class extends import_licensing.ActivationController
|
|
|
244
547
|
this.reportError("previousLicense", err);
|
|
245
548
|
}
|
|
246
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Moonbase's mark, for the overlay's footer, as an image file: Gorilla Engine
|
|
552
|
+
* draws images from files only, and a module can't add to the plugin's assets.
|
|
553
|
+
* Written beside the license file, with its `@2x`, the first time it is asked
|
|
554
|
+
* for. Null when it can't be written, and the footer goes without it.
|
|
555
|
+
*/
|
|
556
|
+
moonbaseMark() {
|
|
557
|
+
if (this.markFile !== void 0)
|
|
558
|
+
return this.markFile;
|
|
559
|
+
const file = import_node_path2.default.join(import_node_path2.default.dirname(this.licenseFile), "moonbase-mark.png");
|
|
560
|
+
try {
|
|
561
|
+
import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
562
|
+
writeIfChanged(file, import_node_buffer2.Buffer.from(MARK_PNG, "base64"));
|
|
563
|
+
writeIfChanged(file.replace(/\.png$/, "@2x.png"), import_node_buffer2.Buffer.from(MARK_PNG_2X, "base64"));
|
|
564
|
+
this.markFile = file;
|
|
565
|
+
} catch (err) {
|
|
566
|
+
this.reportError("moonbaseMark", err);
|
|
567
|
+
this.markFile = null;
|
|
568
|
+
}
|
|
569
|
+
return this.markFile;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* One of the overlay's icons, in a colour (`AARRGGBB`) and size (points), as
|
|
573
|
+
* an image file, with its `@2x`: drawn the first time it is asked for, into
|
|
574
|
+
* `moonbase-icons` beside the license, for the same reason as the mark. Null
|
|
575
|
+
* when it can't be written, and the overlay goes without it.
|
|
576
|
+
*/
|
|
577
|
+
icon(name, colour, size, stroke = 1.8) {
|
|
578
|
+
const key = `${name}-${colour}-${size}-${stroke}`;
|
|
579
|
+
const known = this.iconFiles.get(key);
|
|
580
|
+
if (known !== void 0)
|
|
581
|
+
return known;
|
|
582
|
+
const file = import_node_path2.default.join(import_node_path2.default.dirname(this.licenseFile), "moonbase-icons", `${name}-${colour.toLowerCase()}-${size}-${Math.round(stroke * 10)}.png`);
|
|
583
|
+
let result = file;
|
|
584
|
+
try {
|
|
585
|
+
import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
586
|
+
writeIfChanged(file, iconPng(name, colour, Math.round(size), stroke));
|
|
587
|
+
writeIfChanged(file.replace(/\.png$/, "@2x.png"), iconPng(name, colour, Math.round(size * 2), stroke));
|
|
588
|
+
} catch (err) {
|
|
589
|
+
if (!this.iconsFailed) {
|
|
590
|
+
this.iconsFailed = true;
|
|
591
|
+
this.reportError("icons", err);
|
|
592
|
+
}
|
|
593
|
+
result = null;
|
|
594
|
+
}
|
|
595
|
+
this.iconFiles.set(key, result);
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
247
598
|
/**
|
|
248
599
|
* Hand a failure to `onError`: the overlay does with every action that
|
|
249
600
|
* fails, and the module with the host's.
|
|
@@ -447,6 +798,7 @@ function createMoonbase(options) {
|
|
|
447
798
|
}
|
|
448
799
|
|
|
449
800
|
// src/MoonbaseActivation.ts
|
|
801
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
450
802
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
451
803
|
var React3 = __toESM(require("react"), 1);
|
|
452
804
|
|
|
@@ -604,6 +956,64 @@ function describeAddOn(entry, license, state) {
|
|
|
604
956
|
// src/elements.ts
|
|
605
957
|
var React2 = __toESM(require("react"), 1);
|
|
606
958
|
|
|
959
|
+
// src/metrics.ts
|
|
960
|
+
var SIZE = 500;
|
|
961
|
+
var CHARACTERS = (() => {
|
|
962
|
+
let characters = "";
|
|
963
|
+
for (let code = 32; code < 127; code++)
|
|
964
|
+
characters += String.fromCharCode(code);
|
|
965
|
+
for (let code = 160; code < 256; code++)
|
|
966
|
+
characters += String.fromCharCode(code);
|
|
967
|
+
return `${characters}\u2026\xB7\u2018\u2019\u201C\u201D\u2013\u20AC`;
|
|
968
|
+
})();
|
|
969
|
+
var advances = /* @__PURE__ */ new Map();
|
|
970
|
+
var measuring = /* @__PURE__ */ new Map();
|
|
971
|
+
function measurer() {
|
|
972
|
+
var _a;
|
|
973
|
+
return (_a = globalThis.GorillaEngine) != null ? _a : null;
|
|
974
|
+
}
|
|
975
|
+
function measureFont(font) {
|
|
976
|
+
var _a;
|
|
977
|
+
const existing = measuring.get(font);
|
|
978
|
+
if (existing)
|
|
979
|
+
return existing;
|
|
980
|
+
const measure = (_a = measurer()) == null ? void 0 : _a.calculateTextWidth;
|
|
981
|
+
if (typeof measure !== "function")
|
|
982
|
+
return Promise.resolve(false);
|
|
983
|
+
const promise = (async () => {
|
|
984
|
+
const table = /* @__PURE__ */ new Map();
|
|
985
|
+
const widths = await Promise.all([...CHARACTERS].map((character) => measure(character, font, SIZE, 0)));
|
|
986
|
+
widths.forEach((width, index) => {
|
|
987
|
+
if (typeof width === "number" && Number.isFinite(width))
|
|
988
|
+
table.set(CHARACTERS[index], width);
|
|
989
|
+
});
|
|
990
|
+
if (!table.has("n"))
|
|
991
|
+
return false;
|
|
992
|
+
advances.set(font, table);
|
|
993
|
+
return true;
|
|
994
|
+
})().catch(() => false);
|
|
995
|
+
measuring.set(font, promise);
|
|
996
|
+
return promise;
|
|
997
|
+
}
|
|
998
|
+
async function measureFonts(fonts) {
|
|
999
|
+
const results = await Promise.all([...new Set(fonts.map((font) => font != null ? font : ""))].map(measureFont));
|
|
1000
|
+
return results.some(Boolean);
|
|
1001
|
+
}
|
|
1002
|
+
function measuredWidth(text2, font, size, kerning = 0) {
|
|
1003
|
+
var _a;
|
|
1004
|
+
const table = advances.get(font != null ? font : "");
|
|
1005
|
+
if (!table)
|
|
1006
|
+
return null;
|
|
1007
|
+
const fallback = table.get("n");
|
|
1008
|
+
let width = 0;
|
|
1009
|
+
let count = 0;
|
|
1010
|
+
for (const character of text2) {
|
|
1011
|
+
width += (_a = table.get(character)) != null ? _a : fallback;
|
|
1012
|
+
count++;
|
|
1013
|
+
}
|
|
1014
|
+
return width * size / SIZE + kerning * size * count;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
607
1017
|
// src/motion.ts
|
|
608
1018
|
var React = __toESM(require("react"), 1);
|
|
609
1019
|
var FRAME = 16;
|
|
@@ -754,27 +1164,68 @@ function fontFor(theme, weight, mono = false) {
|
|
|
754
1164
|
return medium != null ? medium : regular;
|
|
755
1165
|
return regular;
|
|
756
1166
|
}
|
|
757
|
-
function textWidth(text2, size, weight = 400) {
|
|
758
|
-
return Math.ceil(text2
|
|
1167
|
+
function textWidth(theme, text2, size, weight = 400, options = {}) {
|
|
1168
|
+
return Math.ceil(exactWidth(theme, text2, size, weight, options));
|
|
1169
|
+
}
|
|
1170
|
+
function exactWidth(theme, text2, size, weight, options = {}) {
|
|
1171
|
+
var _a;
|
|
1172
|
+
const measured = measuredWidth(text2, fontFor(theme, weight, options.mono), size, options.kerning);
|
|
1173
|
+
if (measured !== null)
|
|
1174
|
+
return measured * 1.03;
|
|
1175
|
+
return text2.length * size * ((weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52) + ((_a = options.kerning) != null ? _a : 0));
|
|
759
1176
|
}
|
|
760
|
-
function
|
|
1177
|
+
function lineCount(theme, text2, size, width, weight = 400, mono = false) {
|
|
1178
|
+
const space2 = exactWidth(theme, " ", size, weight, { mono });
|
|
761
1179
|
let lines = 0;
|
|
762
1180
|
for (const paragraph2 of text2.split("\n")) {
|
|
763
1181
|
let line = 0;
|
|
764
1182
|
lines++;
|
|
765
1183
|
for (const word of paragraph2.split(" ")) {
|
|
766
|
-
const length =
|
|
767
|
-
if (line > 0 && line + length > width) {
|
|
1184
|
+
const length = exactWidth(theme, word, size, weight, { mono });
|
|
1185
|
+
if (line > 0 && line + space2 + length > width) {
|
|
768
1186
|
lines++;
|
|
769
|
-
line =
|
|
1187
|
+
line = length;
|
|
1188
|
+
} else {
|
|
1189
|
+
line += (line > 0 ? space2 : 0) + length;
|
|
770
1190
|
}
|
|
771
|
-
line += length;
|
|
772
1191
|
}
|
|
773
1192
|
}
|
|
774
|
-
return
|
|
1193
|
+
return lines;
|
|
1194
|
+
}
|
|
1195
|
+
function textHeight(theme, text2, size, width, lineHeight = 1.5, weight = 400, mono = false) {
|
|
1196
|
+
return Math.ceil(lineCount(theme, text2, size, width, weight, mono) * size * lineHeight);
|
|
775
1197
|
}
|
|
1198
|
+
function fitText(theme, text2, size, width, options = {}) {
|
|
1199
|
+
const fits = (value) => textWidth(theme, value, size, options.weight, { mono: options.mono }) <= width;
|
|
1200
|
+
if (fits(text2))
|
|
1201
|
+
return text2;
|
|
1202
|
+
const characters = [...text2];
|
|
1203
|
+
let keep = characters.length - 1;
|
|
1204
|
+
while (keep > 1) {
|
|
1205
|
+
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("")}`;
|
|
1206
|
+
if (fits(value))
|
|
1207
|
+
return value;
|
|
1208
|
+
keep--;
|
|
1209
|
+
}
|
|
1210
|
+
return "\u2026";
|
|
1211
|
+
}
|
|
1212
|
+
var BLANK = {
|
|
1213
|
+
text: "",
|
|
1214
|
+
backgroundColor: "00000000",
|
|
1215
|
+
cornerRadius: 0,
|
|
1216
|
+
border: { width: 0, color: "00000000" },
|
|
1217
|
+
alpha: 1,
|
|
1218
|
+
interceptsMouseClicks: false,
|
|
1219
|
+
mouseCursorType: "normal"
|
|
1220
|
+
};
|
|
776
1221
|
function label(props, ...children) {
|
|
777
|
-
return h("geLabel", {
|
|
1222
|
+
return h("geLabel", { ...BLANK, ...props }, ...children);
|
|
1223
|
+
}
|
|
1224
|
+
function icon(theme, name, x, y, size, colour, stroke = 1.8) {
|
|
1225
|
+
const file = theme.icon(name, colour, size, stroke);
|
|
1226
|
+
if (!file)
|
|
1227
|
+
return null;
|
|
1228
|
+
return h("geLabel", { ...BLANK, key: `icon-${name}`, x, y, width: size, height: size, backgroundImage: file });
|
|
778
1229
|
}
|
|
779
1230
|
function each(node) {
|
|
780
1231
|
return Array.isArray(node) ? node : [node];
|
|
@@ -782,7 +1233,7 @@ function each(node) {
|
|
|
782
1233
|
function text(theme, value, x, y, width, options = {}) {
|
|
783
1234
|
var _a, _b, _c, _d, _e, _f;
|
|
784
1235
|
const size = (_a = options.size) != null ? _a : 14;
|
|
785
|
-
const height = textHeight(value, size, width, options.lineHeight);
|
|
1236
|
+
const height = textHeight(theme, value, size, width, options.lineHeight, options.weight, options.mono);
|
|
786
1237
|
const multiLine = height > size * ((_b = options.lineHeight) != null ? _b : 1.5) * 1.2;
|
|
787
1238
|
return label({
|
|
788
1239
|
x,
|
|
@@ -816,7 +1267,7 @@ function paragraph(theme, value, width, options = {}) {
|
|
|
816
1267
|
var _a, _b, _c;
|
|
817
1268
|
const size = (_a = options.size) != null ? _a : 14;
|
|
818
1269
|
const boxWidth = Math.min(width, (_b = options.maxWidth) != null ? _b : width);
|
|
819
|
-
const height = Math.max(textHeight(value, size, boxWidth, options.lineHeight), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
|
|
1270
|
+
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)));
|
|
820
1271
|
return {
|
|
821
1272
|
height,
|
|
822
1273
|
render: (x, y, available) => {
|
|
@@ -828,8 +1279,16 @@ function paragraph(theme, value, width, options = {}) {
|
|
|
828
1279
|
function heading(theme, value, width, options = {}) {
|
|
829
1280
|
return paragraph(theme, value, width, { size: options.large ? 27 : 24, weight: 600, textColor: palette.textPrimary, lineHeight: 1.25, align: options.align });
|
|
830
1281
|
}
|
|
1282
|
+
function iconBeside(theme, value, size, weight, width, iconSize, gap) {
|
|
1283
|
+
if (iconSize === null)
|
|
1284
|
+
return { iconX: 0, margin: { left: 0, right: 0, top: 0, bottom: 0 } };
|
|
1285
|
+
if (!value)
|
|
1286
|
+
return { iconX: Math.round((width - iconSize) / 2), margin: { left: 0, right: 0, top: 0, bottom: 0 } };
|
|
1287
|
+
const shift = iconSize + gap;
|
|
1288
|
+
return { iconX: Math.round((width - textWidth(theme, value, size, weight) - shift) / 2), margin: { left: shift, right: 0, top: 0, bottom: 0 } };
|
|
1289
|
+
}
|
|
831
1290
|
function Button(props) {
|
|
832
|
-
var _a, _b, _c;
|
|
1291
|
+
var _a, _b, _c, _d;
|
|
833
1292
|
const [hovered, setHovered] = React2.useState(false);
|
|
834
1293
|
const kind = (_a = props.kind) != null ? _a : "primary";
|
|
835
1294
|
const accent = props.theme.accent;
|
|
@@ -843,6 +1302,9 @@ function Button(props) {
|
|
|
843
1302
|
};
|
|
844
1303
|
const look = looks[kind];
|
|
845
1304
|
const small = kind.startsWith("small") || kind === "danger" || kind === "quiet";
|
|
1305
|
+
const fontSize = (_b = props.size) != null ? _b : small ? 12.5 : 14;
|
|
1306
|
+
const iconSize = props.icon ? (_c = props.iconSize) != null ? _c : small ? 14 : 16 : null;
|
|
1307
|
+
const { iconX, margin } = iconBeside(props.theme, props.label, fontSize, look.weight, props.width, iconSize, small ? 6 : 8);
|
|
846
1308
|
return label({
|
|
847
1309
|
x: props.x,
|
|
848
1310
|
y: props.y,
|
|
@@ -850,12 +1312,13 @@ function Button(props) {
|
|
|
850
1312
|
height: props.height,
|
|
851
1313
|
text: props.label,
|
|
852
1314
|
font: fontFor(props.theme, look.weight),
|
|
853
|
-
fontSize
|
|
1315
|
+
fontSize,
|
|
854
1316
|
textColor: look.textColor,
|
|
855
1317
|
textAlign: "center",
|
|
1318
|
+
margin,
|
|
856
1319
|
backgroundColor: hovered && !props.disabled ? look.hover : look.background,
|
|
857
1320
|
cornerRadius: small ? 8 : 9,
|
|
858
|
-
border: { width: look.border ? 1 : 0, color: (
|
|
1321
|
+
border: { width: look.border ? 1 : 0, color: (_d = look.border) != null ? _d : palette.transparent },
|
|
859
1322
|
alpha: props.disabled ? 0.5 : 1,
|
|
860
1323
|
interceptsMouseClicks: true,
|
|
861
1324
|
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
@@ -865,7 +1328,7 @@ function Button(props) {
|
|
|
865
1328
|
if (!props.disabled)
|
|
866
1329
|
props.onClick();
|
|
867
1330
|
}
|
|
868
|
-
});
|
|
1331
|
+
}, props.icon && iconSize && icon(props.theme, props.icon, iconX, Math.round((props.height - iconSize) / 2), iconSize, look.textColor, 1.8));
|
|
869
1332
|
}
|
|
870
1333
|
function buttonBlock(theme, value, onClick, options = {}) {
|
|
871
1334
|
var _a;
|
|
@@ -876,27 +1339,35 @@ function buttonBlock(theme, value, onClick, options = {}) {
|
|
|
876
1339
|
var _a2;
|
|
877
1340
|
const width = Math.min(available, (_a2 = options.width) != null ? _a2 : available);
|
|
878
1341
|
const left = options.align === "center" ? x + (available - width) / 2 : x;
|
|
879
|
-
return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, onClick });
|
|
1342
|
+
return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, icon: options.icon, onClick });
|
|
880
1343
|
}
|
|
881
1344
|
};
|
|
882
1345
|
}
|
|
1346
|
+
var LINK_ICON = 14;
|
|
1347
|
+
var LINK_GAP = 6;
|
|
1348
|
+
function linkWidth(theme, value, size = 12.5, withIcon = false) {
|
|
1349
|
+
return textWidth(theme, value, size, 500) + 8 + (withIcon ? LINK_ICON + LINK_GAP : 0);
|
|
1350
|
+
}
|
|
883
1351
|
function Link(props) {
|
|
884
|
-
var _a, _b;
|
|
1352
|
+
var _a, _b, _c;
|
|
885
1353
|
const [hovered, setHovered] = React2.useState(false);
|
|
886
1354
|
const size = (_a = props.size) != null ? _a : 12.5;
|
|
887
|
-
const width = (_b = props.width) != null ? _b :
|
|
1355
|
+
const width = (_b = props.width) != null ? _b : linkWidth(props.theme, props.label, size, !!props.icon);
|
|
1356
|
+
const height = Math.ceil(size * 1.6);
|
|
888
1357
|
const base = props.link ? palette.link : palette.textSecondary;
|
|
889
1358
|
const hover = props.link ? palette.linkHover : palette.textBright;
|
|
1359
|
+
const shown = hovered && !props.disabled ? hover : base;
|
|
890
1360
|
return label({
|
|
891
1361
|
x: props.x,
|
|
892
1362
|
y: props.y,
|
|
893
1363
|
width,
|
|
894
|
-
height
|
|
1364
|
+
height,
|
|
895
1365
|
text: props.label,
|
|
896
1366
|
font: fontFor(props.theme, 500),
|
|
897
1367
|
fontSize: size,
|
|
898
|
-
textColor:
|
|
1368
|
+
textColor: shown,
|
|
899
1369
|
textAlign: props.align === "center" ? "center" : "centered left",
|
|
1370
|
+
margin: { left: props.icon ? LINK_ICON + LINK_GAP : 0, right: 0, top: 0, bottom: 0 },
|
|
900
1371
|
alpha: props.disabled ? 0.55 : 1,
|
|
901
1372
|
interceptsMouseClicks: true,
|
|
902
1373
|
mouseCursorType: props.disabled ? "normal" : "pointing hand",
|
|
@@ -906,7 +1377,7 @@ function Link(props) {
|
|
|
906
1377
|
if (!props.disabled)
|
|
907
1378
|
props.onClick();
|
|
908
1379
|
}
|
|
909
|
-
});
|
|
1380
|
+
}, props.icon && icon(props.theme, props.icon, 0, Math.round((height - LINK_ICON) / 2), LINK_ICON, (_c = props.iconColour) != null ? _c : shown, 1.7));
|
|
910
1381
|
}
|
|
911
1382
|
function linksBlock(theme, links, options = {}) {
|
|
912
1383
|
var _a;
|
|
@@ -919,23 +1390,26 @@ function linksBlock(theme, links, options = {}) {
|
|
|
919
1390
|
return {
|
|
920
1391
|
height: marginTop + Math.ceil(size * 1.6),
|
|
921
1392
|
render: (x, y, width) => {
|
|
922
|
-
const widths = items.map((item) =>
|
|
1393
|
+
const widths = items.map((item) => linkWidth(theme, item.label, size, !!item.icon));
|
|
923
1394
|
const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
|
|
924
1395
|
let left = options.align === "left" ? x : x + (width - total) / 2;
|
|
925
1396
|
return items.map((item, index) => {
|
|
926
|
-
const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], onClick: item.onClick });
|
|
1397
|
+
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 });
|
|
927
1398
|
left += widths[index] + gap;
|
|
928
1399
|
return node;
|
|
929
1400
|
});
|
|
930
1401
|
}
|
|
931
1402
|
};
|
|
932
1403
|
}
|
|
933
|
-
function pill(theme, tone, value, x, y, onClick) {
|
|
1404
|
+
function pill(theme, tone, value, x, y, onClick, withIcon) {
|
|
934
1405
|
const upper = tone === "trial" || tone === "expired" || tone === "upgrade";
|
|
935
1406
|
const shown = upper ? value.toUpperCase() : value;
|
|
936
1407
|
const size = upper ? 10.5 : 11.5;
|
|
1408
|
+
const kerning = upper ? 0.08 : 0.02;
|
|
937
1409
|
const dot = tone === "expired" || tone === "upgrade" || tone === "active";
|
|
938
|
-
const
|
|
1410
|
+
const lead = dot ? 12 : withIcon ? 19 : 0;
|
|
1411
|
+
const textBox = textWidth(theme, shown, size, 700, { kerning }) + 4;
|
|
1412
|
+
const width = textBox + 22 + lead;
|
|
939
1413
|
const height = 24;
|
|
940
1414
|
const looks = {
|
|
941
1415
|
trial: { background: color(palette.trial), border: palette.transparent, textColor: color("#131519") },
|
|
@@ -957,15 +1431,15 @@ function pill(theme, tone, value, x, y, onClick) {
|
|
|
957
1431
|
interceptsMouseClicks: !!onClick,
|
|
958
1432
|
mouseCursorType: onClick ? "pointing hand" : "normal",
|
|
959
1433
|
...onClick && { onClick }
|
|
960
|
-
}, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), label({
|
|
961
|
-
x:
|
|
1434
|
+
}, 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({
|
|
1435
|
+
x: 11 + lead,
|
|
962
1436
|
y: 0,
|
|
963
|
-
width:
|
|
1437
|
+
width: textBox,
|
|
964
1438
|
height,
|
|
965
1439
|
text: shown,
|
|
966
1440
|
font: fontFor(theme, 700),
|
|
967
1441
|
fontSize: size,
|
|
968
|
-
fontKerning:
|
|
1442
|
+
fontKerning: kerning,
|
|
969
1443
|
textColor: look.textColor,
|
|
970
1444
|
textAlign: "center"
|
|
971
1445
|
}));
|
|
@@ -973,6 +1447,8 @@ function pill(theme, tone, value, x, y, onClick) {
|
|
|
973
1447
|
}
|
|
974
1448
|
function card(props, ...children) {
|
|
975
1449
|
var _a, _b, _c;
|
|
1450
|
+
if (props.onClick)
|
|
1451
|
+
return h(ClickableCard, { ...props, onClick: props.onClick }, ...children);
|
|
976
1452
|
return label({
|
|
977
1453
|
x: props.x,
|
|
978
1454
|
y: props.y,
|
|
@@ -980,11 +1456,36 @@ function card(props, ...children) {
|
|
|
980
1456
|
height: props.height,
|
|
981
1457
|
backgroundColor: (_a = props.background) != null ? _a : palette.card,
|
|
982
1458
|
cornerRadius: (_b = props.radius) != null ? _b : 12,
|
|
983
|
-
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
|
|
984
|
-
interceptsMouseClicks: !!props.onClick,
|
|
985
|
-
...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
|
|
1459
|
+
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
|
|
986
1460
|
}, ...children);
|
|
987
1461
|
}
|
|
1462
|
+
function ClickableCard(props) {
|
|
1463
|
+
var _a, _b, _c;
|
|
1464
|
+
const [hovered, setHovered] = React2.useState(false);
|
|
1465
|
+
return label({
|
|
1466
|
+
x: props.x,
|
|
1467
|
+
y: props.y,
|
|
1468
|
+
width: props.width,
|
|
1469
|
+
height: props.height,
|
|
1470
|
+
backgroundColor: hovered ? color("#ffffff", 0.05) : (_a = props.background) != null ? _a : palette.card,
|
|
1471
|
+
cornerRadius: (_b = props.radius) != null ? _b : 12,
|
|
1472
|
+
border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
|
|
1473
|
+
interceptsMouseClicks: true,
|
|
1474
|
+
mouseCursorType: "pointing hand",
|
|
1475
|
+
onMouseEnter: () => setHovered(true),
|
|
1476
|
+
onMouseExit: () => setHovered(false),
|
|
1477
|
+
onClick: props.onClick
|
|
1478
|
+
}, ...React2.Children.toArray(props.children));
|
|
1479
|
+
}
|
|
1480
|
+
var SCROLLBAR = 6;
|
|
1481
|
+
function scrollView(props, contentHeight, ...children) {
|
|
1482
|
+
return h("geScrollView", {
|
|
1483
|
+
...props,
|
|
1484
|
+
hideHorizontalScrollbar: true,
|
|
1485
|
+
scrollbarThickness: SCROLLBAR,
|
|
1486
|
+
scrollbar: { background: palette.transparent, track: palette.transparent, thumb: color("#ffffff", 0.16) }
|
|
1487
|
+
}, label({ x: 0, y: 0, width: props.width - SCROLLBAR, height: contentHeight }, ...children));
|
|
1488
|
+
}
|
|
988
1489
|
function barBlock(fraction, fill, options = {}) {
|
|
989
1490
|
var _a, _b;
|
|
990
1491
|
const marginTop = (_a = options.marginTop) != null ? _a : 14;
|
|
@@ -1175,6 +1676,24 @@ function useUiState(moonbase) {
|
|
|
1175
1676
|
}, [moonbase]);
|
|
1176
1677
|
return ui;
|
|
1177
1678
|
}
|
|
1679
|
+
function useFontMetrics(ui) {
|
|
1680
|
+
var _a;
|
|
1681
|
+
const [measured, setMeasured] = React3.useState(0);
|
|
1682
|
+
const { regular, medium, semibold, mono } = (_a = ui.fonts) != null ? _a : {};
|
|
1683
|
+
React3.useEffect(() => {
|
|
1684
|
+
var _a2;
|
|
1685
|
+
let live = true;
|
|
1686
|
+
measureFonts([regular, medium != null ? medium : regular, (_a2 = semibold != null ? semibold : medium) != null ? _a2 : regular, mono != null ? mono : regular]).then((known) => {
|
|
1687
|
+
if (live && known)
|
|
1688
|
+
setMeasured((count) => count + 1);
|
|
1689
|
+
}, () => {
|
|
1690
|
+
});
|
|
1691
|
+
return () => {
|
|
1692
|
+
live = false;
|
|
1693
|
+
};
|
|
1694
|
+
}, [regular, medium, semibold, mono]);
|
|
1695
|
+
return measured;
|
|
1696
|
+
}
|
|
1178
1697
|
function statusView(state) {
|
|
1179
1698
|
switch (state.status) {
|
|
1180
1699
|
case "unlicensed":
|
|
@@ -1193,6 +1712,28 @@ function statusView(state) {
|
|
|
1193
1712
|
return "loading";
|
|
1194
1713
|
}
|
|
1195
1714
|
}
|
|
1715
|
+
function requestedView(screen, state) {
|
|
1716
|
+
const next = screen === "license" ? "details" : screen;
|
|
1717
|
+
if ((next === "details" || next === "addons") && !state.license)
|
|
1718
|
+
return null;
|
|
1719
|
+
return next;
|
|
1720
|
+
}
|
|
1721
|
+
function followState(view, before, state) {
|
|
1722
|
+
var _a;
|
|
1723
|
+
let next = view;
|
|
1724
|
+
const activated = before.status === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a = before.license) == null ? void 0 : _a.activationId);
|
|
1725
|
+
if (activated)
|
|
1726
|
+
next = "success";
|
|
1727
|
+
if ((next === "details" || next === "addons" || next === "update") && !state.license)
|
|
1728
|
+
next = null;
|
|
1729
|
+
if (state.status === "activating")
|
|
1730
|
+
next = null;
|
|
1731
|
+
if (state.status === "notCovered" && before.status !== "notCovered")
|
|
1732
|
+
next = null;
|
|
1733
|
+
if (next === "success" && !state.license)
|
|
1734
|
+
next = null;
|
|
1735
|
+
return next;
|
|
1736
|
+
}
|
|
1196
1737
|
function droppedFiles(dropped) {
|
|
1197
1738
|
if (typeof dropped === "string")
|
|
1198
1739
|
return [dropped];
|
|
@@ -1201,22 +1742,30 @@ function droppedFiles(dropped) {
|
|
|
1201
1742
|
const files = dropped == null ? void 0 : dropped.files;
|
|
1202
1743
|
return Array.isArray(files) ? files.filter((file) => typeof file === "string") : [];
|
|
1203
1744
|
}
|
|
1745
|
+
function displayPath(file) {
|
|
1746
|
+
const home = import_node_os2.default.homedir();
|
|
1747
|
+
return home && file.startsWith(home) ? `~${file.slice(home.length)}` : file;
|
|
1748
|
+
}
|
|
1204
1749
|
function Panel({ moonbase, state, screen, request, download, width: areaWidth, height: areaHeight }) {
|
|
1205
1750
|
var _a, _b, _c, _d, _e;
|
|
1206
1751
|
const ui = moonbase.ui;
|
|
1207
|
-
const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {} };
|
|
1752
|
+
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) };
|
|
1208
1753
|
const product = (_c = ui.productName) != null ? _c : "the plugin";
|
|
1209
1754
|
const account = ui.manufacturerName || "Moonbase";
|
|
1210
1755
|
const strings = (_d = ui.strings) != null ? _d : {};
|
|
1211
1756
|
const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
|
|
1212
1757
|
const width = cardWidth - PAD_X * 2;
|
|
1213
1758
|
const still = !!ui.reduceMotion;
|
|
1214
|
-
const
|
|
1759
|
+
const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
|
|
1760
|
+
const footer = showBadge ? 30 + 18 + 18 : 8;
|
|
1761
|
+
const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
|
|
1762
|
+
const [view, setView] = React3.useState(() => requestedView(screen, state));
|
|
1215
1763
|
const [update, setUpdate] = React3.useState(null);
|
|
1216
1764
|
const [cameFromDetails, setCameFromDetails] = React3.useState(false);
|
|
1217
1765
|
const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
|
|
1218
1766
|
const [copied, setCopied] = React3.useState(null);
|
|
1219
|
-
const
|
|
1767
|
+
const [seen, setSeen] = React3.useState({ state, request });
|
|
1768
|
+
const previous = React3.useRef(state);
|
|
1220
1769
|
const run2 = (name2, action) => {
|
|
1221
1770
|
action().catch((err) => moonbase.reportError(name2, err));
|
|
1222
1771
|
};
|
|
@@ -1239,38 +1788,38 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1239
1788
|
};
|
|
1240
1789
|
const flashCopied = (what) => {
|
|
1241
1790
|
setCopied(what);
|
|
1242
|
-
setTimeout(() => setCopied((
|
|
1791
|
+
setTimeout(() => setCopied((current2) => current2 === what ? null : current2), 2e3);
|
|
1243
1792
|
};
|
|
1793
|
+
let current = view;
|
|
1794
|
+
if (seen.request !== request || seen.state !== state) {
|
|
1795
|
+
let next = view;
|
|
1796
|
+
if (seen.request !== request) {
|
|
1797
|
+
next = requestedView(screen, state);
|
|
1798
|
+
if (screen === "update") {
|
|
1799
|
+
setCameFromDetails(false);
|
|
1800
|
+
setUpdate(null);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
if (seen.state !== state)
|
|
1804
|
+
next = followState(next, seen.state, state);
|
|
1805
|
+
setSeen({ state, request });
|
|
1806
|
+
if (next !== view)
|
|
1807
|
+
setView(next);
|
|
1808
|
+
current = next;
|
|
1809
|
+
}
|
|
1244
1810
|
React3.useEffect(() => {
|
|
1245
1811
|
if (screen === "update")
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
next = null;
|
|
1250
|
-
go(next);
|
|
1812
|
+
loadUpdate();
|
|
1813
|
+
else if (requestedView(screen, moonbase.state()) === "addons")
|
|
1814
|
+
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
1251
1815
|
}, [request]);
|
|
1252
1816
|
React3.useEffect(() => {
|
|
1253
|
-
var _a2;
|
|
1254
1817
|
const before = previous.current;
|
|
1255
1818
|
previous.current = state;
|
|
1256
|
-
|
|
1257
|
-
const activated = (before == null ? void 0 : before.status) === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a2 = before.license) == null ? void 0 : _a2.activationId);
|
|
1258
|
-
if (activated)
|
|
1259
|
-
next = "success";
|
|
1260
|
-
if ((next === "details" || next === "addons" || next === "update") && !state.license)
|
|
1261
|
-
next = null;
|
|
1262
|
-
if (state.status === "activating")
|
|
1263
|
-
next = null;
|
|
1264
|
-
if (state.status === "notCovered" && (before == null ? void 0 : before.status) !== "notCovered")
|
|
1265
|
-
next = null;
|
|
1266
|
-
if (next === "success" && !state.license)
|
|
1267
|
-
next = null;
|
|
1268
|
-
if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
|
|
1819
|
+
if (current === "addons" && state.license && state.addOns.phase === "idle" && before.addOns.phase !== "idle")
|
|
1269
1820
|
run2("loadAddOns", () => moonbase.loadAddOns());
|
|
1270
|
-
if (next !== view)
|
|
1271
|
-
setView(next);
|
|
1272
1821
|
}, [state]);
|
|
1273
|
-
const name =
|
|
1822
|
+
const name = current != null ? current : statusView(state);
|
|
1274
1823
|
const lockup = (options = {}) => {
|
|
1275
1824
|
const size = options.large ? 38 : 34;
|
|
1276
1825
|
return {
|
|
@@ -1284,9 +1833,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1284
1833
|
const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
|
|
1285
1834
|
let right = x + available - (canClose ? 40 : 0);
|
|
1286
1835
|
for (const each2 of [...pills].reverse()) {
|
|
1287
|
-
const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
|
|
1836
|
+
const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick, each2.icon);
|
|
1288
1837
|
right -= drawn.width;
|
|
1289
|
-
nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
|
|
1838
|
+
nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick, each2.icon).node);
|
|
1290
1839
|
right -= 8;
|
|
1291
1840
|
}
|
|
1292
1841
|
return nodes;
|
|
@@ -1295,12 +1844,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1295
1844
|
const errorLine = (message) => {
|
|
1296
1845
|
if (!message)
|
|
1297
1846
|
return null;
|
|
1298
|
-
const body = paragraph(theme,
|
|
1299
|
-
return {
|
|
1847
|
+
const body = paragraph(theme, message, width - 22, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
|
|
1848
|
+
return {
|
|
1849
|
+
height: 14 + body.height,
|
|
1850
|
+
render: (x, y, available) => [icon(theme, "warning", x, y + 16, 15, palette.warningText), body.render(x + 22, y + 14, available - 22)]
|
|
1851
|
+
};
|
|
1300
1852
|
};
|
|
1301
1853
|
const backLink = (value, onClick) => ({
|
|
1302
|
-
height: 20 +
|
|
1303
|
-
render: (x, y) => h(
|
|
1854
|
+
height: 20 + 12,
|
|
1855
|
+
render: (x, y) => h(Link, { key: "back", theme, x, y, label: value, icon: "back", onClick })
|
|
1304
1856
|
});
|
|
1305
1857
|
const notice = (value, tone) => {
|
|
1306
1858
|
const body = paragraph(theme, value, width - 58, { size: 13, textColor: palette.textBody, lineHeight: 1.5 });
|
|
@@ -1308,7 +1860,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1308
1860
|
const tint = tone === "upgrade" ? palette.trial : palette.errorStrong;
|
|
1309
1861
|
return {
|
|
1310
1862
|
height: height + 24,
|
|
1311
|
-
render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 },
|
|
1863
|
+
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))
|
|
1312
1864
|
};
|
|
1313
1865
|
};
|
|
1314
1866
|
const features = () => {
|
|
@@ -1318,10 +1870,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1318
1870
|
return null;
|
|
1319
1871
|
return {
|
|
1320
1872
|
height: list.length * 30 - 11 + 26,
|
|
1321
|
-
render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 },
|
|
1873
|
+
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 })))
|
|
1322
1874
|
};
|
|
1323
1875
|
};
|
|
1324
|
-
const
|
|
1876
|
+
const below = (top2, block) => ({ height: top2 + block.height, render: (x, y, available) => block.render(x, y + top2, available) });
|
|
1877
|
+
const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()), { icon: "lock" });
|
|
1325
1878
|
const screens = {
|
|
1326
1879
|
loading: () => [
|
|
1327
1880
|
{ height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
|
|
@@ -1341,7 +1894,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1341
1894
|
space(28),
|
|
1342
1895
|
buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
|
|
1343
1896
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1344
|
-
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1897
|
+
linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", icon: "signal", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
|
|
1345
1898
|
];
|
|
1346
1899
|
},
|
|
1347
1900
|
browser: () => {
|
|
@@ -1367,20 +1920,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1367
1920
|
space(8),
|
|
1368
1921
|
paragraph(theme, body, width, { align: "center", maxWidth: 420 }),
|
|
1369
1922
|
space(22),
|
|
1370
|
-
failed && buttonBlock(theme, linkCopied ? "
|
|
1923
|
+
failed && buttonBlock(theme, linkCopied ? "Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center", icon: linkCopied ? "check" : "copy" }),
|
|
1371
1924
|
failed && space(18),
|
|
1372
1925
|
!!url && {
|
|
1373
1926
|
height: 50,
|
|
1374
1927
|
render: (x, y, available) => {
|
|
1375
1928
|
const value = `${moonbase.deviceName} \xB7 ${osLabel()}`;
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1929
|
+
const textBox = Math.min(available - 54, textWidth(theme, value, 12.5));
|
|
1930
|
+
const chipWidth = textBox + 15 + 9 + 30;
|
|
1931
|
+
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 }));
|
|
1378
1932
|
}
|
|
1379
1933
|
},
|
|
1380
1934
|
buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
|
|
1381
1935
|
!!url && !failed && linksBlock(theme, [
|
|
1382
1936
|
{ label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
|
|
1383
|
-
{ label: linkCopied ? "
|
|
1937
|
+
{ 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 }
|
|
1384
1938
|
]),
|
|
1385
1939
|
errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
|
|
1386
1940
|
];
|
|
@@ -1389,7 +1943,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1389
1943
|
const license = state.license;
|
|
1390
1944
|
if (!license)
|
|
1391
1945
|
return screens[statusView(state)]();
|
|
1392
|
-
const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]];
|
|
1946
|
+
const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]].filter(([, value]) => !!value);
|
|
1393
1947
|
return [
|
|
1394
1948
|
{
|
|
1395
1949
|
height: 66 + 6,
|
|
@@ -1404,7 +1958,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1404
1958
|
height: rows.length * 34 + 32 + 26,
|
|
1405
1959
|
render: (x, y, available) => {
|
|
1406
1960
|
const cardWidth2 = Math.min(380, available);
|
|
1407
|
-
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 }))));
|
|
1961
|
+
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 }))));
|
|
1408
1962
|
}
|
|
1409
1963
|
},
|
|
1410
1964
|
buttonBlock(theme, `Open ${product}`, close, { width: 380, align: "center" }),
|
|
@@ -1412,24 +1966,25 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1412
1966
|
];
|
|
1413
1967
|
},
|
|
1414
1968
|
offline: () => {
|
|
1415
|
-
const saveSub = offline.saved ? `Saved to ${offline.saved}` : "Choose where to save it";
|
|
1416
1969
|
const requestFile = `${(product || "license").replace(/[\\/:*?"<>|]/g, "-")}.dt`;
|
|
1970
|
+
const textBox = width - 16 - 22 - 12 - 76;
|
|
1971
|
+
const saveSub = offline.saved ? fitText(theme, `Saved to ${displayPath(offline.saved)}`, 11.5, textBox) : "Choose where to save it";
|
|
1417
1972
|
const saveRequest = () => {
|
|
1418
|
-
setOffline((
|
|
1973
|
+
setOffline((current2) => ({ ...current2, error: "" }));
|
|
1419
1974
|
moonbase.saveMachineFile().then(
|
|
1420
|
-
(saved) => setOffline((
|
|
1975
|
+
(saved) => setOffline((current2) => ({ ...current2, saved: saved != null ? saved : current2.saved })),
|
|
1421
1976
|
(err) => {
|
|
1422
1977
|
moonbase.reportError("saveMachineFile", err);
|
|
1423
|
-
setOffline((
|
|
1978
|
+
setOffline((current2) => ({ ...current2, error: err instanceof Error ? err.message : String(err) }));
|
|
1424
1979
|
}
|
|
1425
1980
|
);
|
|
1426
1981
|
};
|
|
1427
1982
|
const useFile = (pick) => {
|
|
1428
1983
|
pick.then(
|
|
1429
|
-
(file) => file && setOffline((
|
|
1984
|
+
(file) => file && setOffline((current2) => ({ ...current2, file, error: "" })),
|
|
1430
1985
|
(err) => {
|
|
1431
1986
|
moonbase.reportError("readLicenseFile", err);
|
|
1432
|
-
setOffline((
|
|
1987
|
+
setOffline((current2) => ({ ...current2, error: "Couldn't read that file." }));
|
|
1433
1988
|
}
|
|
1434
1989
|
);
|
|
1435
1990
|
};
|
|
@@ -1437,54 +1992,58 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1437
1992
|
if (offline.busy)
|
|
1438
1993
|
return;
|
|
1439
1994
|
if (!offline.file) {
|
|
1440
|
-
setOffline((
|
|
1995
|
+
setOffline((current2) => ({ ...current2, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
|
|
1441
1996
|
return;
|
|
1442
1997
|
}
|
|
1443
|
-
setOffline((
|
|
1998
|
+
setOffline((current2) => ({ ...current2, busy: true, error: "" }));
|
|
1444
1999
|
moonbase.activateOffline(offline.file.text).then(() => {
|
|
1445
2000
|
setOffline({ saved: null, file: null, busy: false, error: "" });
|
|
1446
2001
|
setView("success");
|
|
1447
2002
|
}, () => {
|
|
1448
|
-
setOffline((
|
|
2003
|
+
setOffline((current2) => {
|
|
1449
2004
|
var _a2;
|
|
1450
|
-
return { ...
|
|
2005
|
+
return { ...current2, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
|
|
1451
2006
|
});
|
|
1452
2007
|
});
|
|
1453
2008
|
};
|
|
1454
2009
|
const step = (n, value) => ({
|
|
1455
|
-
height: 20 +
|
|
1456
|
-
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 }))
|
|
2010
|
+
height: 20 + 10,
|
|
2011
|
+
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 }))
|
|
1457
2012
|
});
|
|
2013
|
+
const dropTitle = offline.file ? fitText(theme, offline.file.name, 13, width - 120, { mono: true }) : "Drop your license file here";
|
|
2014
|
+
const dropSub = offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb";
|
|
2015
|
+
const dropText = Math.max(textWidth(theme, dropTitle, 13, offline.file ? 400 : 500, { mono: !!offline.file }), textWidth(theme, dropSub, 11.5));
|
|
2016
|
+
const dropLeft = Math.round((width - 24 - 12 - dropText) / 2);
|
|
1458
2017
|
return [
|
|
1459
2018
|
backLink("Back", () => go(null)),
|
|
1460
2019
|
heading(theme, "Offline activation", width),
|
|
1461
2020
|
space(8),
|
|
1462
2021
|
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),
|
|
1463
|
-
space(
|
|
2022
|
+
space(18),
|
|
1464
2023
|
step("1", "Save your request file"),
|
|
1465
2024
|
{
|
|
1466
|
-
height:
|
|
1467
|
-
render: (x, y) => card({ x, y, width, height:
|
|
2025
|
+
height: 52 + 16,
|
|
2026
|
+
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 }))
|
|
1468
2027
|
},
|
|
1469
2028
|
step("2", "Add the license file"),
|
|
1470
2029
|
{
|
|
1471
|
-
height:
|
|
2030
|
+
height: 72,
|
|
1472
2031
|
render: (x, y) => h("geDropZone", {
|
|
1473
2032
|
key: "drop",
|
|
1474
2033
|
x,
|
|
1475
2034
|
y,
|
|
1476
2035
|
width,
|
|
1477
|
-
height:
|
|
2036
|
+
height: 72,
|
|
1478
2037
|
onDroppedFiles: (dropped) => {
|
|
1479
2038
|
const file = droppedFiles(dropped)[0];
|
|
1480
2039
|
if (file)
|
|
1481
2040
|
useFile(moonbase.readLicenseFile(file));
|
|
1482
2041
|
}
|
|
1483
|
-
}, card({ x: 0, y: 0, width, height:
|
|
2042
|
+
}, 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 })))
|
|
1484
2043
|
},
|
|
1485
2044
|
errorLine(offline.error),
|
|
1486
|
-
space(
|
|
1487
|
-
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy })
|
|
2045
|
+
space(16),
|
|
2046
|
+
buttonBlock(theme, offline.busy ? "Verifying\u2026" : "Activate offline", activateOffline, { disabled: offline.busy, height: 44 })
|
|
1488
2047
|
];
|
|
1489
2048
|
},
|
|
1490
2049
|
trial: () => {
|
|
@@ -1536,7 +2095,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1536
2095
|
paragraph(theme, body, width),
|
|
1537
2096
|
space(22),
|
|
1538
2097
|
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"),
|
|
1539
|
-
buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
|
|
2098
|
+
buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }),
|
|
1540
2099
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1541
2100
|
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()) }])
|
|
1542
2101
|
];
|
|
@@ -1550,25 +2109,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1550
2109
|
["Licensed to", license.issuedTo.name || license.issuedTo.email],
|
|
1551
2110
|
["Email", license.issuedTo.email],
|
|
1552
2111
|
["Plan", `${planName(license)} \xB7 ${license.expiresAt ? `until ${formatDate(license.expiresAt)}` : "perpetual"}`]
|
|
1553
|
-
];
|
|
2112
|
+
].filter(([, value]) => !!value);
|
|
1554
2113
|
const seatCount = license.seatCount;
|
|
1555
2114
|
const used = license.seatsUsed;
|
|
1556
2115
|
const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
|
|
2116
|
+
const lit = !seatCount || !used ? 0 : used >= seatCount ? pipCount : Math.max(1, Math.min(pipCount - 1, Math.round(used / seatCount * pipCount)));
|
|
1557
2117
|
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";
|
|
1558
2118
|
const idCopied = copied === license.id;
|
|
1559
2119
|
const rowHeight = 44;
|
|
2120
|
+
const valueWidth = width - 172;
|
|
1560
2121
|
return [
|
|
1561
2122
|
header([
|
|
1562
|
-
...state.update ? [{ tone: "update", text: "
|
|
2123
|
+
...state.update ? [{ tone: "update", text: "Update", icon: "download", onClick: () => openUpdate(true) }] : [],
|
|
1563
2124
|
{ tone: "active", text: license.trial ? "Trial" : "Active" }
|
|
1564
2125
|
]),
|
|
1565
2126
|
{
|
|
1566
2127
|
height: (rows.length + 1) * rowHeight + 2 + 18,
|
|
1567
|
-
render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, value,
|
|
2128
|
+
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)) })))
|
|
1568
2129
|
},
|
|
1569
2130
|
{
|
|
1570
2131
|
height: 64 + 22,
|
|
1571
|
-
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 <
|
|
2132
|
+
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, {
|
|
1572
2133
|
key: "deactivate",
|
|
1573
2134
|
theme,
|
|
1574
2135
|
x: width - 16 - 178,
|
|
@@ -1584,7 +2145,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1584
2145
|
errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
|
|
1585
2146
|
ui.showAddOns && !license.trial && {
|
|
1586
2147
|
height: 62 + (state.error ? 14 : 0),
|
|
1587
|
-
render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, text(theme, "Add-ons",
|
|
2148
|
+
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))
|
|
1588
2149
|
}
|
|
1589
2150
|
];
|
|
1590
2151
|
},
|
|
@@ -1607,12 +2168,14 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1607
2168
|
list = {
|
|
1608
2169
|
height: listHeight,
|
|
1609
2170
|
render: (x, y) => {
|
|
1610
|
-
const
|
|
1611
|
-
|
|
2171
|
+
const scrolls2 = rows.length > visible;
|
|
2172
|
+
const rowWidth = scrolls2 ? width - SCROLLBAR - 8 : width;
|
|
2173
|
+
const content2 = rows.map((row, index) => addOnRow(row, 0, index * (rowHeight + 10), rowWidth, rowHeight));
|
|
2174
|
+
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);
|
|
1612
2175
|
}
|
|
1613
2176
|
};
|
|
1614
2177
|
} else if (info.phase !== "ready") {
|
|
1615
|
-
list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight })) };
|
|
2178
|
+
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) }))) };
|
|
1616
2179
|
} else if (failed) {
|
|
1617
2180
|
list = (_a2 = errorLine(info.error)) != null ? _a2 : space(0);
|
|
1618
2181
|
} else {
|
|
@@ -1631,7 +2194,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1631
2194
|
link: true,
|
|
1632
2195
|
disabled: loading || waiting,
|
|
1633
2196
|
onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
|
|
1634
|
-
}], { align: "left" })
|
|
2197
|
+
}], { align: "left", marginTop: 18 })
|
|
1635
2198
|
];
|
|
1636
2199
|
},
|
|
1637
2200
|
update: () => {
|
|
@@ -1659,41 +2222,30 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1659
2222
|
const notCovered = update.covered === false || download.phase === "notCovered";
|
|
1660
2223
|
const access = (_a2 = download.releaseAccess) != null ? _a2 : update.releaseAccess;
|
|
1661
2224
|
const upgradeUrl = (_b2 = download.upgradeUrl) != null ? _b2 : update.upgradeUrl;
|
|
1662
|
-
const noteBlocks = notes.map((note) => paragraph(theme, note, width - 70, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
|
|
1663
|
-
const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
|
|
1664
2225
|
let action;
|
|
1665
2226
|
if (download.phase === "done")
|
|
1666
|
-
action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
|
|
2227
|
+
action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()), { icon: "download" });
|
|
1667
2228
|
else if (notCovered)
|
|
1668
|
-
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
|
|
2229
|
+
action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }) : null;
|
|
1669
2230
|
else if (update.canDownload)
|
|
1670
|
-
action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
|
|
2231
|
+
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" });
|
|
1671
2232
|
else
|
|
1672
2233
|
action = update.hasDownloads ? unlock() : null;
|
|
1673
2234
|
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.";
|
|
1674
|
-
|
|
2235
|
+
const above = [
|
|
1675
2236
|
lockup(),
|
|
1676
2237
|
space(24),
|
|
1677
|
-
{ height: 24 + 14, render: (x, y) => pill(theme, "update", "
|
|
2238
|
+
{ height: 24 + 14, render: (x, y) => pill(theme, "update", "Update available", x, y, void 0, "download").node },
|
|
1678
2239
|
heading(theme, `${product} ${update.latestVersion} is ready`, width),
|
|
1679
2240
|
space(8),
|
|
1680
2241
|
paragraph(theme, `You're on ${update.currentVersion || "an earlier version"}. The latest is ${update.latestVersion}${standing}`, width),
|
|
1681
|
-
space(20)
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
render: (x, y) => {
|
|
1685
|
-
let top2 = 44;
|
|
1686
|
-
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) => {
|
|
1687
|
-
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));
|
|
1688
|
-
top2 += block.height + 8;
|
|
1689
|
-
return node;
|
|
1690
|
-
}));
|
|
1691
|
-
}
|
|
1692
|
-
},
|
|
2242
|
+
space(20)
|
|
2243
|
+
];
|
|
2244
|
+
const after = [
|
|
1693
2245
|
downloading && barBlock(percent !== null ? percent / 100 : 0.08, color(theme.accent), { marginTop: 0, marginBottom: 14 }),
|
|
1694
2246
|
action,
|
|
1695
|
-
download.phase === "done" && !!download.path &&
|
|
1696
|
-
notCovered && paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted }),
|
|
2247
|
+
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" })),
|
|
2248
|
+
notCovered && below(16, paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted })),
|
|
1697
2249
|
errorLine(download.phase === "failed" ? download.error : null),
|
|
1698
2250
|
linksBlock(theme, [
|
|
1699
2251
|
{ label: "Remind me later", onClick: back },
|
|
@@ -1703,6 +2255,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1703
2255
|
} }
|
|
1704
2256
|
])
|
|
1705
2257
|
];
|
|
2258
|
+
const noteWidth = width - 36 - 26 - SCROLLBAR - 4;
|
|
2259
|
+
const noteBlocks = notes.map((note) => paragraph(theme, note, noteWidth, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
|
|
2260
|
+
const listNatural = noteBlocks.reduce((sum, block) => sum + block.height, 0) + Math.max(0, noteBlocks.length - 1) * 10;
|
|
2261
|
+
const chrome = 16 + 17 + 12 + 16 + 22;
|
|
2262
|
+
const taken = [...above, ...after].reduce((sum, block) => sum + (block ? block.height : 0), 0);
|
|
2263
|
+
const listHeight = Math.min(listNatural, 190, Math.max(Math.min(listNatural, 40), room - taken - chrome));
|
|
2264
|
+
const listScrolls = listHeight < listNatural;
|
|
2265
|
+
const notesBlock = notes.length > 0 && {
|
|
2266
|
+
height: listHeight + chrome,
|
|
2267
|
+
render: (x, y) => {
|
|
2268
|
+
let top2 = 0;
|
|
2269
|
+
const rowWidth = width - 36 - (listScrolls ? SCROLLBAR + 4 : 0);
|
|
2270
|
+
const rows = noteBlocks.map((block, index) => {
|
|
2271
|
+
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));
|
|
2272
|
+
top2 += block.height + 10;
|
|
2273
|
+
return node;
|
|
2274
|
+
});
|
|
2275
|
+
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));
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
return [...above, notesBlock, ...after];
|
|
1706
2279
|
}
|
|
1707
2280
|
};
|
|
1708
2281
|
const addOnActions = {
|
|
@@ -1719,24 +2292,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1719
2292
|
const buttons = actions.reverse().map((action) => {
|
|
1720
2293
|
const primary = action === row.primary;
|
|
1721
2294
|
const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
|
|
1722
|
-
const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
|
|
2295
|
+
const buttonWidth = Math.max(76, textWidth(theme, value, 13, 600) + 32);
|
|
1723
2296
|
right -= buttonWidth;
|
|
1724
2297
|
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)) });
|
|
1725
2298
|
right -= 8;
|
|
1726
2299
|
return node;
|
|
1727
2300
|
});
|
|
1728
|
-
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),
|
|
2301
|
+
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);
|
|
1729
2302
|
}
|
|
1730
2303
|
const blocks = screens[name]();
|
|
1731
|
-
const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
|
|
1732
|
-
const footer = showBadge ? 30 + 18 + 18 : 8;
|
|
1733
2304
|
const screenHeight = blocks.reduce((sum, block) => sum + (block ? block.height : 0), 0);
|
|
1734
|
-
const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
|
|
1735
2305
|
const scrolls = screenHeight > room;
|
|
1736
2306
|
let content;
|
|
1737
2307
|
if (scrolls) {
|
|
1738
2308
|
const inner = stack(blocks, PAD_X, 0, width);
|
|
1739
|
-
content = { height: room, nodes: [
|
|
2309
|
+
content = { height: room, nodes: [scrollView({ key: "screen", x: 0, y: PAD_TOP, width: cardWidth - 10, height: room }, inner.height, ...inner.nodes)] };
|
|
1740
2310
|
} else {
|
|
1741
2311
|
content = stack(blocks, PAD_X, PAD_TOP, width);
|
|
1742
2312
|
}
|
|
@@ -1752,13 +2322,13 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
|
|
|
1752
2322
|
screen: name,
|
|
1753
2323
|
contentHeight: content.height,
|
|
1754
2324
|
content: content.nodes,
|
|
1755
|
-
closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "
|
|
2325
|
+
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 }),
|
|
1756
2326
|
// Kept to the card's bottom edge as it resizes.
|
|
1757
2327
|
footer: showBadge ? (height) => {
|
|
1758
2328
|
const divider = height - footer - PAD_BOTTOM + 30;
|
|
1759
2329
|
return [
|
|
1760
2330
|
label({ key: "divider", x: PAD_X, y: divider, width, height: 1, backgroundColor: color("#ffffff", 0.06) }),
|
|
1761
|
-
h(
|
|
2331
|
+
h(Badge, { key: "badge", theme, x: PAD_X, y: divider + 14, width, mark: moonbase.moonbaseMark(), onClick: () => run2("openLink", () => moonbase.openLink("https://moonbase.sh")) })
|
|
1762
2332
|
];
|
|
1763
2333
|
} : null,
|
|
1764
2334
|
still
|
|
@@ -1776,30 +2346,33 @@ function PanelCard(props) {
|
|
|
1776
2346
|
return card(
|
|
1777
2347
|
{ x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
|
|
1778
2348
|
h(Glow, { key: "glow", width: props.width, still: props.still }),
|
|
1779
|
-
label({ key:
|
|
2349
|
+
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),
|
|
1780
2350
|
props.closeButton,
|
|
1781
2351
|
...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
|
|
1782
2352
|
);
|
|
1783
2353
|
}
|
|
1784
|
-
function
|
|
1785
|
-
var _a;
|
|
2354
|
+
function Badge(props) {
|
|
1786
2355
|
const [hovered, setHovered] = React3.useState(false);
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2356
|
+
const lead = "Licensing secured by";
|
|
2357
|
+
const gap = 7;
|
|
2358
|
+
const size = props.mark ? 14 : 0;
|
|
2359
|
+
const markGap = props.mark ? gap : 0;
|
|
2360
|
+
const lock = 14;
|
|
2361
|
+
const leadWidth = textWidth(props.theme, lead, 11);
|
|
2362
|
+
const wordmark = textWidth(props.theme, "moonbase", 12, 500, { kerning: 0.06 }) + 4;
|
|
2363
|
+
const start = Math.round((props.width - (lock + gap + leadWidth + gap + size + markGap + wordmark)) / 2);
|
|
2364
|
+
const linkX = start + lock + gap + leadWidth + gap;
|
|
2365
|
+
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({
|
|
2366
|
+
x: linkX,
|
|
2367
|
+
y: 0,
|
|
2368
|
+
width: size + markGap + wordmark,
|
|
1792
2369
|
height: 20,
|
|
1793
|
-
text: props.value,
|
|
1794
|
-
fontSize: props.muted ? 11 : 12.5,
|
|
1795
|
-
textColor: hovered ? palette.textBright : props.muted ? palette.textMuted : palette.textSecondary,
|
|
1796
|
-
textAlign: props.center ? "center" : "centered left",
|
|
1797
2370
|
interceptsMouseClicks: true,
|
|
1798
2371
|
mouseCursorType: "pointing hand",
|
|
1799
2372
|
onMouseEnter: () => setHovered(true),
|
|
1800
2373
|
onMouseExit: () => setHovered(false),
|
|
1801
2374
|
onClick: props.onClick
|
|
1802
|
-
});
|
|
2375
|
+
}, 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 })));
|
|
1803
2376
|
}
|
|
1804
2377
|
function osLabel() {
|
|
1805
2378
|
switch (import_node_process2.default.platform) {
|
|
@@ -1825,6 +2398,7 @@ function MoonbaseActivation(props) {
|
|
|
1825
2398
|
const { moonbase, width, height } = props;
|
|
1826
2399
|
const state = useMoonbaseState(moonbase);
|
|
1827
2400
|
const ui = useUiState(moonbase);
|
|
2401
|
+
const metrics = useFontMetrics(moonbase.ui);
|
|
1828
2402
|
const shown = ui.visible ? 1 : 0;
|
|
1829
2403
|
const [scrim, rise] = useTween([
|
|
1830
2404
|
{ to: shown, duration: 250, ease: EASE_CSS },
|
|
@@ -1847,7 +2421,7 @@ function MoonbaseActivation(props) {
|
|
|
1847
2421
|
// the front, after the customer bought an add-on in the browser.
|
|
1848
2422
|
onMouseEnter: () => moonbase.onFocusChanged(true),
|
|
1849
2423
|
onMouseExit: () => moonbase.onFocusChanged(false)
|
|
1850
|
-
}, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height })));
|
|
2424
|
+
}, 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 })));
|
|
1851
2425
|
}
|
|
1852
2426
|
|
|
1853
2427
|
// src/index.ts
|