@kombai/cli 0.1.2-beta.2 → 0.1.2-beta.4
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 +4 -0
- package/dist/THIRD-PARTY-NOTICES.txt +26 -0
- package/dist/kombai.mjs +2311 -270
- package/dist/mcp-apps/design-taste.js +81 -81
- package/package.json +2 -1
package/dist/kombai.mjs
CHANGED
|
@@ -48,6 +48,955 @@ var init_define_KOMBAI_TELEMETRY = __esm({
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
// ../design-mode/node_modules/fflate/esm/index.mjs
|
|
52
|
+
import { createRequire } from "module";
|
|
53
|
+
function deflateSync(data, opts) {
|
|
54
|
+
return dopt(data, opts || {}, 0, 0);
|
|
55
|
+
}
|
|
56
|
+
function strToU8(str, latin1) {
|
|
57
|
+
if (latin1) {
|
|
58
|
+
var ar_1 = new u8(str.length);
|
|
59
|
+
for (var i = 0; i < str.length; ++i)
|
|
60
|
+
ar_1[i] = str.charCodeAt(i);
|
|
61
|
+
return ar_1;
|
|
62
|
+
}
|
|
63
|
+
if (te)
|
|
64
|
+
return te.encode(str);
|
|
65
|
+
var l = str.length;
|
|
66
|
+
var ar = new u8(str.length + (str.length >> 1));
|
|
67
|
+
var ai = 0;
|
|
68
|
+
var w = function(v) {
|
|
69
|
+
ar[ai++] = v;
|
|
70
|
+
};
|
|
71
|
+
for (var i = 0; i < l; ++i) {
|
|
72
|
+
if (ai + 5 > ar.length) {
|
|
73
|
+
var n = new u8(ai + 8 + (l - i << 1));
|
|
74
|
+
n.set(ar);
|
|
75
|
+
ar = n;
|
|
76
|
+
}
|
|
77
|
+
var c = str.charCodeAt(i);
|
|
78
|
+
if (c < 128 || latin1)
|
|
79
|
+
w(c);
|
|
80
|
+
else if (c < 2048)
|
|
81
|
+
w(192 | c >> 6), w(128 | c & 63);
|
|
82
|
+
else if (c > 55295 && c < 57344)
|
|
83
|
+
c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
84
|
+
else
|
|
85
|
+
w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
86
|
+
}
|
|
87
|
+
return slc(ar, 0, ai);
|
|
88
|
+
}
|
|
89
|
+
function zipSync(data, opts) {
|
|
90
|
+
if (!opts)
|
|
91
|
+
opts = {};
|
|
92
|
+
var r = {};
|
|
93
|
+
var files = [];
|
|
94
|
+
fltn(data, "", r, opts);
|
|
95
|
+
var o = 0;
|
|
96
|
+
var tot = 0;
|
|
97
|
+
for (var fn in r) {
|
|
98
|
+
var _a3 = r[fn], file2 = _a3[0], p = _a3[1];
|
|
99
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
100
|
+
var f = strToU8(fn), s = f.length;
|
|
101
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
102
|
+
var exl = exfl(p.extra);
|
|
103
|
+
if (s > 65535)
|
|
104
|
+
err(11);
|
|
105
|
+
var d = compression ? deflateSync(file2, p) : file2, l = d.length;
|
|
106
|
+
var c = crc();
|
|
107
|
+
c.p(file2);
|
|
108
|
+
files.push(mrg(p, {
|
|
109
|
+
size: file2.length,
|
|
110
|
+
crc: c.d(),
|
|
111
|
+
c: d,
|
|
112
|
+
f,
|
|
113
|
+
m,
|
|
114
|
+
u: s != fn.length || m && com.length != ms,
|
|
115
|
+
o,
|
|
116
|
+
compression
|
|
117
|
+
}));
|
|
118
|
+
o += 30 + s + exl + l;
|
|
119
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
120
|
+
}
|
|
121
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
122
|
+
for (var i = 0; i < files.length; ++i) {
|
|
123
|
+
var f = files[i];
|
|
124
|
+
wzh(out, f.o, f, f.f, f.u, f.c.length);
|
|
125
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
126
|
+
out.set(f.c, f.o + badd);
|
|
127
|
+
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
|
|
128
|
+
}
|
|
129
|
+
wzf(out, o, files.length, cdl, oe);
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
var require2, _a, Worker, isMarkedAsUntransferable, u8, u16, i32, fleb, fdeb, clim, freb, _a, fl, revfl, _b, fd, revfd, rev, x, i, hMap, flt, i, i, i, i, fdt, i, flm, fdm, shft, slc, ec, err, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, deo, et, dflt, crct, crc, dopt, mrg, wbytes, fltn, te, td, tds, exfl, wzh, wzf;
|
|
133
|
+
var init_esm = __esm({
|
|
134
|
+
"../design-mode/node_modules/fflate/esm/index.mjs"() {
|
|
135
|
+
init_define_KOMBAI_TELEMETRY();
|
|
136
|
+
require2 = createRequire("/");
|
|
137
|
+
try {
|
|
138
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
139
|
+
} catch (e) {
|
|
140
|
+
}
|
|
141
|
+
u8 = Uint8Array;
|
|
142
|
+
u16 = Uint16Array;
|
|
143
|
+
i32 = Int32Array;
|
|
144
|
+
fleb = new u8([
|
|
145
|
+
0,
|
|
146
|
+
0,
|
|
147
|
+
0,
|
|
148
|
+
0,
|
|
149
|
+
0,
|
|
150
|
+
0,
|
|
151
|
+
0,
|
|
152
|
+
0,
|
|
153
|
+
1,
|
|
154
|
+
1,
|
|
155
|
+
1,
|
|
156
|
+
1,
|
|
157
|
+
2,
|
|
158
|
+
2,
|
|
159
|
+
2,
|
|
160
|
+
2,
|
|
161
|
+
3,
|
|
162
|
+
3,
|
|
163
|
+
3,
|
|
164
|
+
3,
|
|
165
|
+
4,
|
|
166
|
+
4,
|
|
167
|
+
4,
|
|
168
|
+
4,
|
|
169
|
+
5,
|
|
170
|
+
5,
|
|
171
|
+
5,
|
|
172
|
+
5,
|
|
173
|
+
0,
|
|
174
|
+
/* unused */
|
|
175
|
+
0,
|
|
176
|
+
0,
|
|
177
|
+
/* impossible */
|
|
178
|
+
0
|
|
179
|
+
]);
|
|
180
|
+
fdeb = new u8([
|
|
181
|
+
0,
|
|
182
|
+
0,
|
|
183
|
+
0,
|
|
184
|
+
0,
|
|
185
|
+
1,
|
|
186
|
+
1,
|
|
187
|
+
2,
|
|
188
|
+
2,
|
|
189
|
+
3,
|
|
190
|
+
3,
|
|
191
|
+
4,
|
|
192
|
+
4,
|
|
193
|
+
5,
|
|
194
|
+
5,
|
|
195
|
+
6,
|
|
196
|
+
6,
|
|
197
|
+
7,
|
|
198
|
+
7,
|
|
199
|
+
8,
|
|
200
|
+
8,
|
|
201
|
+
9,
|
|
202
|
+
9,
|
|
203
|
+
10,
|
|
204
|
+
10,
|
|
205
|
+
11,
|
|
206
|
+
11,
|
|
207
|
+
12,
|
|
208
|
+
12,
|
|
209
|
+
13,
|
|
210
|
+
13,
|
|
211
|
+
/* unused */
|
|
212
|
+
0,
|
|
213
|
+
0
|
|
214
|
+
]);
|
|
215
|
+
clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
216
|
+
freb = function(eb, start) {
|
|
217
|
+
var b = new u16(31);
|
|
218
|
+
for (var i = 0; i < 31; ++i) {
|
|
219
|
+
b[i] = start += 1 << eb[i - 1];
|
|
220
|
+
}
|
|
221
|
+
var r = new i32(b[30]);
|
|
222
|
+
for (var i = 1; i < 30; ++i) {
|
|
223
|
+
for (var j = b[i]; j < b[i + 1]; ++j) {
|
|
224
|
+
r[j] = j - b[i] << 5 | i;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return { b, r };
|
|
228
|
+
};
|
|
229
|
+
_a = freb(fleb, 2);
|
|
230
|
+
fl = _a.b;
|
|
231
|
+
revfl = _a.r;
|
|
232
|
+
fl[28] = 258, revfl[258] = 28;
|
|
233
|
+
_b = freb(fdeb, 0);
|
|
234
|
+
fd = _b.b;
|
|
235
|
+
revfd = _b.r;
|
|
236
|
+
rev = new u16(32768);
|
|
237
|
+
for (i = 0; i < 32768; ++i) {
|
|
238
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
239
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
240
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
241
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
242
|
+
}
|
|
243
|
+
hMap = (function(cd, mb, r) {
|
|
244
|
+
var s = cd.length;
|
|
245
|
+
var i = 0;
|
|
246
|
+
var l = new u16(mb);
|
|
247
|
+
for (; i < s; ++i) {
|
|
248
|
+
if (cd[i])
|
|
249
|
+
++l[cd[i] - 1];
|
|
250
|
+
}
|
|
251
|
+
var le = new u16(mb);
|
|
252
|
+
for (i = 1; i < mb; ++i) {
|
|
253
|
+
le[i] = le[i - 1] + l[i - 1] << 1;
|
|
254
|
+
}
|
|
255
|
+
var co;
|
|
256
|
+
if (r) {
|
|
257
|
+
co = new u16(1 << mb);
|
|
258
|
+
var rvb = 15 - mb;
|
|
259
|
+
for (i = 0; i < s; ++i) {
|
|
260
|
+
if (cd[i]) {
|
|
261
|
+
var sv = i << 4 | cd[i];
|
|
262
|
+
var r_1 = mb - cd[i];
|
|
263
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
264
|
+
for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
|
|
265
|
+
co[rev[v] >> rvb] = sv;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
co = new u16(s);
|
|
271
|
+
for (i = 0; i < s; ++i) {
|
|
272
|
+
if (cd[i]) {
|
|
273
|
+
co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return co;
|
|
278
|
+
});
|
|
279
|
+
flt = new u8(288);
|
|
280
|
+
for (i = 0; i < 144; ++i)
|
|
281
|
+
flt[i] = 8;
|
|
282
|
+
for (i = 144; i < 256; ++i)
|
|
283
|
+
flt[i] = 9;
|
|
284
|
+
for (i = 256; i < 280; ++i)
|
|
285
|
+
flt[i] = 7;
|
|
286
|
+
for (i = 280; i < 288; ++i)
|
|
287
|
+
flt[i] = 8;
|
|
288
|
+
fdt = new u8(32);
|
|
289
|
+
for (i = 0; i < 32; ++i)
|
|
290
|
+
fdt[i] = 5;
|
|
291
|
+
flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
292
|
+
fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
293
|
+
shft = function(p) {
|
|
294
|
+
return (p + 7) / 8 | 0;
|
|
295
|
+
};
|
|
296
|
+
slc = function(v, s, e) {
|
|
297
|
+
if (s == null || s < 0)
|
|
298
|
+
s = 0;
|
|
299
|
+
if (e == null || e > v.length)
|
|
300
|
+
e = v.length;
|
|
301
|
+
return new u8(v.subarray(s, e));
|
|
302
|
+
};
|
|
303
|
+
ec = [
|
|
304
|
+
"unexpected EOF",
|
|
305
|
+
"invalid block type",
|
|
306
|
+
"invalid length/literal",
|
|
307
|
+
"invalid distance",
|
|
308
|
+
"stream finished",
|
|
309
|
+
"no stream handler",
|
|
310
|
+
,
|
|
311
|
+
// determined by compression function
|
|
312
|
+
"no callback",
|
|
313
|
+
"invalid UTF-8 data",
|
|
314
|
+
"extra field too long",
|
|
315
|
+
"date not in range 1980-2099",
|
|
316
|
+
"filename too long",
|
|
317
|
+
"stream finishing",
|
|
318
|
+
"invalid zip data"
|
|
319
|
+
// determined by unknown compression method
|
|
320
|
+
];
|
|
321
|
+
err = function(ind, msg, nt) {
|
|
322
|
+
var e = new Error(msg || ec[ind]);
|
|
323
|
+
e.code = ind;
|
|
324
|
+
if (Error.captureStackTrace)
|
|
325
|
+
Error.captureStackTrace(e, err);
|
|
326
|
+
if (!nt)
|
|
327
|
+
throw e;
|
|
328
|
+
return e;
|
|
329
|
+
};
|
|
330
|
+
wbits = function(d, p, v) {
|
|
331
|
+
v <<= p & 7;
|
|
332
|
+
var o = p / 8 | 0;
|
|
333
|
+
d[o] |= v;
|
|
334
|
+
d[o + 1] |= v >> 8;
|
|
335
|
+
};
|
|
336
|
+
wbits16 = function(d, p, v) {
|
|
337
|
+
v <<= p & 7;
|
|
338
|
+
var o = p / 8 | 0;
|
|
339
|
+
d[o] |= v;
|
|
340
|
+
d[o + 1] |= v >> 8;
|
|
341
|
+
d[o + 2] |= v >> 16;
|
|
342
|
+
};
|
|
343
|
+
hTree = function(d, mb) {
|
|
344
|
+
var t = [];
|
|
345
|
+
for (var i = 0; i < d.length; ++i) {
|
|
346
|
+
if (d[i])
|
|
347
|
+
t.push({ s: i, f: d[i] });
|
|
348
|
+
}
|
|
349
|
+
var s = t.length;
|
|
350
|
+
var t2 = t.slice();
|
|
351
|
+
if (!s)
|
|
352
|
+
return { t: et, l: 0 };
|
|
353
|
+
if (s == 1) {
|
|
354
|
+
var v = new u8(t[0].s + 1);
|
|
355
|
+
v[t[0].s] = 1;
|
|
356
|
+
return { t: v, l: 1 };
|
|
357
|
+
}
|
|
358
|
+
t.sort(function(a, b) {
|
|
359
|
+
return a.f - b.f;
|
|
360
|
+
});
|
|
361
|
+
t.push({ s: -1, f: 25001 });
|
|
362
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
|
|
363
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
364
|
+
while (i1 != s - 1) {
|
|
365
|
+
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
|
|
366
|
+
r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
|
|
367
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
368
|
+
}
|
|
369
|
+
var maxSym = t2[0].s;
|
|
370
|
+
for (var i = 1; i < s; ++i) {
|
|
371
|
+
if (t2[i].s > maxSym)
|
|
372
|
+
maxSym = t2[i].s;
|
|
373
|
+
}
|
|
374
|
+
var tr = new u16(maxSym + 1);
|
|
375
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
376
|
+
if (mbt > mb) {
|
|
377
|
+
var i = 0, dt = 0;
|
|
378
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
379
|
+
t2.sort(function(a, b) {
|
|
380
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
381
|
+
});
|
|
382
|
+
for (; i < s; ++i) {
|
|
383
|
+
var i2_1 = t2[i].s;
|
|
384
|
+
if (tr[i2_1] > mb) {
|
|
385
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
386
|
+
tr[i2_1] = mb;
|
|
387
|
+
} else
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
dt >>= lft;
|
|
391
|
+
while (dt > 0) {
|
|
392
|
+
var i2_2 = t2[i].s;
|
|
393
|
+
if (tr[i2_2] < mb)
|
|
394
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
395
|
+
else
|
|
396
|
+
++i;
|
|
397
|
+
}
|
|
398
|
+
for (; i >= 0 && dt; --i) {
|
|
399
|
+
var i2_3 = t2[i].s;
|
|
400
|
+
if (tr[i2_3] == mb) {
|
|
401
|
+
--tr[i2_3];
|
|
402
|
+
++dt;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
mbt = mb;
|
|
406
|
+
}
|
|
407
|
+
return { t: new u8(tr), l: mbt };
|
|
408
|
+
};
|
|
409
|
+
ln = function(n, l, d) {
|
|
410
|
+
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
411
|
+
};
|
|
412
|
+
lc = function(c) {
|
|
413
|
+
var s = c.length;
|
|
414
|
+
while (s && !c[--s])
|
|
415
|
+
;
|
|
416
|
+
var cl = new u16(++s);
|
|
417
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
418
|
+
var w = function(v) {
|
|
419
|
+
cl[cli++] = v;
|
|
420
|
+
};
|
|
421
|
+
for (var i = 1; i <= s; ++i) {
|
|
422
|
+
if (c[i] == cln && i != s)
|
|
423
|
+
++cls;
|
|
424
|
+
else {
|
|
425
|
+
if (!cln && cls > 2) {
|
|
426
|
+
for (; cls > 138; cls -= 138)
|
|
427
|
+
w(32754);
|
|
428
|
+
if (cls > 2) {
|
|
429
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
430
|
+
cls = 0;
|
|
431
|
+
}
|
|
432
|
+
} else if (cls > 3) {
|
|
433
|
+
w(cln), --cls;
|
|
434
|
+
for (; cls > 6; cls -= 6)
|
|
435
|
+
w(8304);
|
|
436
|
+
if (cls > 2)
|
|
437
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
438
|
+
}
|
|
439
|
+
while (cls--)
|
|
440
|
+
w(cln);
|
|
441
|
+
cls = 1;
|
|
442
|
+
cln = c[i];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return { c: cl.subarray(0, cli), n: s };
|
|
446
|
+
};
|
|
447
|
+
clen = function(cf, cl) {
|
|
448
|
+
var l = 0;
|
|
449
|
+
for (var i = 0; i < cl.length; ++i)
|
|
450
|
+
l += cf[i] * cl[i];
|
|
451
|
+
return l;
|
|
452
|
+
};
|
|
453
|
+
wfblk = function(out, pos, dat) {
|
|
454
|
+
var s = dat.length;
|
|
455
|
+
var o = shft(pos + 2);
|
|
456
|
+
out[o] = s & 255;
|
|
457
|
+
out[o + 1] = s >> 8;
|
|
458
|
+
out[o + 2] = out[o] ^ 255;
|
|
459
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
460
|
+
for (var i = 0; i < s; ++i)
|
|
461
|
+
out[o + i + 4] = dat[i];
|
|
462
|
+
return (o + 4 + s) * 8;
|
|
463
|
+
};
|
|
464
|
+
wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
465
|
+
wbits(out, p++, final);
|
|
466
|
+
++lf[256];
|
|
467
|
+
var _a3 = hTree(lf, 15), dlt = _a3.t, mlb = _a3.l;
|
|
468
|
+
var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
|
|
469
|
+
var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
|
|
470
|
+
var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
|
|
471
|
+
var lcfreq = new u16(19);
|
|
472
|
+
for (var i = 0; i < lclt.length; ++i)
|
|
473
|
+
++lcfreq[lclt[i] & 31];
|
|
474
|
+
for (var i = 0; i < lcdt.length; ++i)
|
|
475
|
+
++lcfreq[lcdt[i] & 31];
|
|
476
|
+
var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
|
|
477
|
+
var nlcc = 19;
|
|
478
|
+
for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
479
|
+
;
|
|
480
|
+
var flen = bl + 5 << 3;
|
|
481
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
482
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
483
|
+
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
|
|
484
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
485
|
+
var lm, ll, dm, dl;
|
|
486
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
487
|
+
if (dtlen < ftlen) {
|
|
488
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
489
|
+
var llm = hMap(lct, mlcb, 0);
|
|
490
|
+
wbits(out, p, nlc - 257);
|
|
491
|
+
wbits(out, p + 5, ndc - 1);
|
|
492
|
+
wbits(out, p + 10, nlcc - 4);
|
|
493
|
+
p += 14;
|
|
494
|
+
for (var i = 0; i < nlcc; ++i)
|
|
495
|
+
wbits(out, p + 3 * i, lct[clim[i]]);
|
|
496
|
+
p += 3 * nlcc;
|
|
497
|
+
var lcts = [lclt, lcdt];
|
|
498
|
+
for (var it = 0; it < 2; ++it) {
|
|
499
|
+
var clct = lcts[it];
|
|
500
|
+
for (var i = 0; i < clct.length; ++i) {
|
|
501
|
+
var len = clct[i] & 31;
|
|
502
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
503
|
+
if (len > 15)
|
|
504
|
+
wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
509
|
+
}
|
|
510
|
+
for (var i = 0; i < li; ++i) {
|
|
511
|
+
var sym = syms[i];
|
|
512
|
+
if (sym > 255) {
|
|
513
|
+
var len = sym >> 18 & 31;
|
|
514
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
515
|
+
if (len > 7)
|
|
516
|
+
wbits(out, p, sym >> 23 & 31), p += fleb[len];
|
|
517
|
+
var dst = sym & 31;
|
|
518
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
519
|
+
if (dst > 3)
|
|
520
|
+
wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
|
|
521
|
+
} else {
|
|
522
|
+
wbits16(out, p, lm[sym]), p += ll[sym];
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
wbits16(out, p, lm[256]);
|
|
526
|
+
return p + ll[256];
|
|
527
|
+
};
|
|
528
|
+
deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
529
|
+
et = /* @__PURE__ */ new u8(0);
|
|
530
|
+
dflt = function(dat, lvl, plvl, pre, post, st) {
|
|
531
|
+
var s = st.z || dat.length;
|
|
532
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
|
|
533
|
+
var w = o.subarray(pre, o.length - post);
|
|
534
|
+
var lst = st.l;
|
|
535
|
+
var pos = (st.r || 0) & 7;
|
|
536
|
+
if (lvl) {
|
|
537
|
+
if (pos)
|
|
538
|
+
w[0] = st.r >> 3;
|
|
539
|
+
var opt = deo[lvl - 1];
|
|
540
|
+
var n = opt >> 13, c = opt & 8191;
|
|
541
|
+
var msk_1 = (1 << plvl) - 1;
|
|
542
|
+
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
|
|
543
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
544
|
+
var hsh = function(i2) {
|
|
545
|
+
return (dat[i2] ^ dat[i2 + 1] << bs1_1 ^ dat[i2 + 2] << bs2_1) & msk_1;
|
|
546
|
+
};
|
|
547
|
+
var syms = new i32(25e3);
|
|
548
|
+
var lf = new u16(288), df = new u16(32);
|
|
549
|
+
var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
|
|
550
|
+
for (; i + 2 < s; ++i) {
|
|
551
|
+
var hv = hsh(i);
|
|
552
|
+
var imod = i & 32767, pimod = head[hv];
|
|
553
|
+
prev[imod] = pimod;
|
|
554
|
+
head[hv] = imod;
|
|
555
|
+
if (wi <= i) {
|
|
556
|
+
var rem = s - i;
|
|
557
|
+
if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
|
|
558
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
559
|
+
li = lc_1 = eb = 0, bs = i;
|
|
560
|
+
for (var j = 0; j < 286; ++j)
|
|
561
|
+
lf[j] = 0;
|
|
562
|
+
for (var j = 0; j < 30; ++j)
|
|
563
|
+
df[j] = 0;
|
|
564
|
+
}
|
|
565
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
566
|
+
if (rem > 2 && hv == hsh(i - dif)) {
|
|
567
|
+
var maxn = Math.min(n, rem) - 1;
|
|
568
|
+
var maxd = Math.min(32767, i);
|
|
569
|
+
var ml = Math.min(258, rem);
|
|
570
|
+
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
571
|
+
if (dat[i + l] == dat[i + l - dif]) {
|
|
572
|
+
var nl = 0;
|
|
573
|
+
for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)
|
|
574
|
+
;
|
|
575
|
+
if (nl > l) {
|
|
576
|
+
l = nl, d = dif;
|
|
577
|
+
if (nl > maxn)
|
|
578
|
+
break;
|
|
579
|
+
var mmd = Math.min(dif, nl - 2);
|
|
580
|
+
var md = 0;
|
|
581
|
+
for (var j = 0; j < mmd; ++j) {
|
|
582
|
+
var ti = i - dif + j & 32767;
|
|
583
|
+
var pti = prev[ti];
|
|
584
|
+
var cd = ti - pti & 32767;
|
|
585
|
+
if (cd > md)
|
|
586
|
+
md = cd, pimod = ti;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
imod = pimod, pimod = prev[imod];
|
|
591
|
+
dif += imod - pimod & 32767;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (d) {
|
|
595
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
596
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
597
|
+
eb += fleb[lin] + fdeb[din];
|
|
598
|
+
++lf[257 + lin];
|
|
599
|
+
++df[din];
|
|
600
|
+
wi = i + l;
|
|
601
|
+
++lc_1;
|
|
602
|
+
} else {
|
|
603
|
+
syms[li++] = dat[i];
|
|
604
|
+
++lf[dat[i]];
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
for (i = Math.max(i, wi); i < s; ++i) {
|
|
609
|
+
syms[li++] = dat[i];
|
|
610
|
+
++lf[dat[i]];
|
|
611
|
+
}
|
|
612
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
613
|
+
if (!lst) {
|
|
614
|
+
st.r = pos & 7 | w[pos / 8 | 0] << 3;
|
|
615
|
+
pos -= 7;
|
|
616
|
+
st.h = head, st.p = prev, st.i = i, st.w = wi;
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
for (var i = st.w || 0; i < s + lst; i += 65535) {
|
|
620
|
+
var e = i + 65535;
|
|
621
|
+
if (e >= s) {
|
|
622
|
+
w[pos / 8 | 0] = lst;
|
|
623
|
+
e = s;
|
|
624
|
+
}
|
|
625
|
+
pos = wfblk(w, pos + 1, dat.subarray(i, e));
|
|
626
|
+
}
|
|
627
|
+
st.i = s;
|
|
628
|
+
}
|
|
629
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
630
|
+
};
|
|
631
|
+
crct = /* @__PURE__ */ (function() {
|
|
632
|
+
var t = new Int32Array(256);
|
|
633
|
+
for (var i = 0; i < 256; ++i) {
|
|
634
|
+
var c = i, k = 9;
|
|
635
|
+
while (--k)
|
|
636
|
+
c = (c & 1 && -306674912) ^ c >>> 1;
|
|
637
|
+
t[i] = c;
|
|
638
|
+
}
|
|
639
|
+
return t;
|
|
640
|
+
})();
|
|
641
|
+
crc = function() {
|
|
642
|
+
var c = -1;
|
|
643
|
+
return {
|
|
644
|
+
p: function(d) {
|
|
645
|
+
var cr = c;
|
|
646
|
+
for (var i = 0; i < d.length; ++i)
|
|
647
|
+
cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
|
|
648
|
+
c = cr;
|
|
649
|
+
},
|
|
650
|
+
d: function() {
|
|
651
|
+
return ~c;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
dopt = function(dat, opt, pre, post, st) {
|
|
656
|
+
if (!st) {
|
|
657
|
+
st = { l: 1 };
|
|
658
|
+
if (opt.dictionary) {
|
|
659
|
+
var dict = opt.dictionary.subarray(-32768);
|
|
660
|
+
var newDat = new u8(dict.length + dat.length);
|
|
661
|
+
newDat.set(dict);
|
|
662
|
+
newDat.set(dat, dict.length);
|
|
663
|
+
dat = newDat;
|
|
664
|
+
st.w = dict.length;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
|
|
668
|
+
};
|
|
669
|
+
mrg = function(a, b) {
|
|
670
|
+
var o = {};
|
|
671
|
+
for (var k in a)
|
|
672
|
+
o[k] = a[k];
|
|
673
|
+
for (var k in b)
|
|
674
|
+
o[k] = b[k];
|
|
675
|
+
return o;
|
|
676
|
+
};
|
|
677
|
+
wbytes = function(d, b, v) {
|
|
678
|
+
for (; v; ++b)
|
|
679
|
+
d[b] = v, v >>>= 8;
|
|
680
|
+
};
|
|
681
|
+
fltn = function(d, p, t, o) {
|
|
682
|
+
for (var k in d) {
|
|
683
|
+
var val = d[k], n = p + k, op = o;
|
|
684
|
+
if (Array.isArray(val))
|
|
685
|
+
op = mrg(o, val[1]), val = val[0];
|
|
686
|
+
if (ArrayBuffer.isView(val))
|
|
687
|
+
t[n] = [val, op];
|
|
688
|
+
else {
|
|
689
|
+
t[n += "/"] = [new u8(0), op];
|
|
690
|
+
fltn(val, n, t, o);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
te = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder();
|
|
695
|
+
td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
|
|
696
|
+
tds = 0;
|
|
697
|
+
try {
|
|
698
|
+
td.decode(et, { stream: true });
|
|
699
|
+
tds = 1;
|
|
700
|
+
} catch (e) {
|
|
701
|
+
}
|
|
702
|
+
exfl = function(ex) {
|
|
703
|
+
var le = 0;
|
|
704
|
+
if (ex) {
|
|
705
|
+
for (var k in ex) {
|
|
706
|
+
var l = ex[k].length;
|
|
707
|
+
if (l > 65535)
|
|
708
|
+
err(9);
|
|
709
|
+
le += l + 4;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return le;
|
|
713
|
+
};
|
|
714
|
+
wzh = function(d, b, f, fn, u, c, ce, co) {
|
|
715
|
+
var fl2 = fn.length, ex = f.extra, col = co && co.length;
|
|
716
|
+
var exl = exfl(ex);
|
|
717
|
+
wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
|
|
718
|
+
if (ce != null)
|
|
719
|
+
d[b++] = 20, d[b++] = f.os;
|
|
720
|
+
d[b] = 20, b += 2;
|
|
721
|
+
d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
|
|
722
|
+
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
|
|
723
|
+
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
|
|
724
|
+
if (y < 0 || y > 119)
|
|
725
|
+
err(10);
|
|
726
|
+
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
|
|
727
|
+
if (c != -1) {
|
|
728
|
+
wbytes(d, b, f.crc);
|
|
729
|
+
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
|
|
730
|
+
wbytes(d, b + 8, f.size);
|
|
731
|
+
}
|
|
732
|
+
wbytes(d, b + 12, fl2);
|
|
733
|
+
wbytes(d, b + 14, exl), b += 16;
|
|
734
|
+
if (ce != null) {
|
|
735
|
+
wbytes(d, b, col);
|
|
736
|
+
wbytes(d, b + 6, f.attrs);
|
|
737
|
+
wbytes(d, b + 10, ce), b += 14;
|
|
738
|
+
}
|
|
739
|
+
d.set(fn, b);
|
|
740
|
+
b += fl2;
|
|
741
|
+
if (exl) {
|
|
742
|
+
for (var k in ex) {
|
|
743
|
+
var exf = ex[k], l = exf.length;
|
|
744
|
+
wbytes(d, b, +k);
|
|
745
|
+
wbytes(d, b + 2, l);
|
|
746
|
+
d.set(exf, b + 4), b += 4 + l;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (col)
|
|
750
|
+
d.set(co, b), b += col;
|
|
751
|
+
return b;
|
|
752
|
+
};
|
|
753
|
+
wzf = function(o, b, c, d, e) {
|
|
754
|
+
wbytes(o, b, 101010256);
|
|
755
|
+
wbytes(o, b + 8, c);
|
|
756
|
+
wbytes(o, b + 10, c);
|
|
757
|
+
wbytes(o, b + 12, d);
|
|
758
|
+
wbytes(o, b + 16, e);
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
// ../design-mode/packages/shared/src/canvas-document.ts
|
|
764
|
+
function sanitizeCanvasSegment(segment) {
|
|
765
|
+
return segment.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
766
|
+
}
|
|
767
|
+
var CANVAS_ASSET_SRC_RE;
|
|
768
|
+
var init_canvas_document = __esm({
|
|
769
|
+
"../design-mode/packages/shared/src/canvas-document.ts"() {
|
|
770
|
+
"use strict";
|
|
771
|
+
init_define_KOMBAI_TELEMETRY();
|
|
772
|
+
CANVAS_ASSET_SRC_RE = /^\/api\/local\/images\/\.kombai\/canvas\/assets\/[a-f0-9]{64}\.(?:png|jpe?g|webp|gif|svg)$/;
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
// ../design-mode/packages/shared/src/canvas-download.ts
|
|
777
|
+
function canvasDownloadBaseName(name) {
|
|
778
|
+
const base = sanitizeCanvasSegment(name) || CANVAS_DOWNLOAD_FALLBACK_NAME;
|
|
779
|
+
return WINDOWS_DEVICE_NAME_RE.test(base) ? `${base}${WINDOWS_DEVICE_SUFFIX}` : base;
|
|
780
|
+
}
|
|
781
|
+
function downloadAssetPathOf(image) {
|
|
782
|
+
const own = `${LOCAL_IMAGES_PREFIX}${CANVAS_DOWNLOAD_ASSETS_DIR}/${image.sha256}.`;
|
|
783
|
+
if (image.path.startsWith(own) && CANVAS_ASSET_SRC_RE.test(image.path)) {
|
|
784
|
+
return image.path.slice(LOCAL_IMAGES_PREFIX.length);
|
|
785
|
+
}
|
|
786
|
+
return `${CANVAS_DOWNLOAD_ASSETS_DIR}/${image.sha256}.${EXTENSION_OF_TYPE[image.contentType]}`;
|
|
787
|
+
}
|
|
788
|
+
function swapReferences(text, swaps) {
|
|
789
|
+
if (swaps.size === 0) return text;
|
|
790
|
+
const pattern = new RegExp(
|
|
791
|
+
[...swaps.keys()].sort((a, b) => b.length - a.length).map(escapeForRegExp).join("|"),
|
|
792
|
+
"g"
|
|
793
|
+
);
|
|
794
|
+
return text.replace(pattern, (found) => swaps.get(found) ?? found);
|
|
795
|
+
}
|
|
796
|
+
function swapOverrides(overrides, swaps) {
|
|
797
|
+
const out = {};
|
|
798
|
+
if (overrides.htmlAttrs !== void 0) out.htmlAttrs = swapReferences(overrides.htmlAttrs, swaps);
|
|
799
|
+
if (overrides.bodyAttrs !== void 0) out.bodyAttrs = swapReferences(overrides.bodyAttrs, swaps);
|
|
800
|
+
if (overrides.head !== void 0) out.head = swapReferences(overrides.head, swaps);
|
|
801
|
+
return out;
|
|
802
|
+
}
|
|
803
|
+
function downloadNodeOf(lite, body, swaps) {
|
|
804
|
+
switch (lite.type) {
|
|
805
|
+
case "variant":
|
|
806
|
+
return {
|
|
807
|
+
...lite,
|
|
808
|
+
html: swapReferences(body.html ?? "", swaps),
|
|
809
|
+
...body.overrides ? { overrides: swapOverrides(body.overrides, swaps) } : {}
|
|
810
|
+
};
|
|
811
|
+
case "text":
|
|
812
|
+
return { ...lite, html: swapReferences(body.html ?? "", swaps) };
|
|
813
|
+
case "drawing": {
|
|
814
|
+
if (!body.content) return null;
|
|
815
|
+
const content = body.content.kind === "image" ? { ...body.content, src: swaps.get(body.content.src) ?? body.content.src } : body.content;
|
|
816
|
+
return { ...lite, content };
|
|
817
|
+
}
|
|
818
|
+
case "frame":
|
|
819
|
+
return { ...lite };
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
function buildCanvasDownload(read2, bodies) {
|
|
823
|
+
const nodes = {};
|
|
824
|
+
const assets = /* @__PURE__ */ new Map();
|
|
825
|
+
const unlisted = /* @__PURE__ */ new Set();
|
|
826
|
+
for (const [nodeId, lite] of Object.entries(read2.document.nodes)) {
|
|
827
|
+
const files = read2.nodeFiles[nodeId];
|
|
828
|
+
if (!files || files.state === "pending") continue;
|
|
829
|
+
const swaps = /* @__PURE__ */ new Map();
|
|
830
|
+
const nodeAssets = [];
|
|
831
|
+
for (const image of files.images ?? []) {
|
|
832
|
+
const path25 = downloadAssetPathOf(image);
|
|
833
|
+
swaps.set(image.path, `${LOCAL_IMAGES_PREFIX}${path25}`);
|
|
834
|
+
nodeAssets.push({ path: path25, url: image.url, contentType: image.contentType });
|
|
835
|
+
}
|
|
836
|
+
const body = bodies[nodeId] ?? {};
|
|
837
|
+
const node = downloadNodeOf(lite, body, swaps);
|
|
838
|
+
if (!node) continue;
|
|
839
|
+
nodes[nodeId] = node;
|
|
840
|
+
for (const asset of nodeAssets) if (!assets.has(asset.path)) assets.set(asset.path, asset);
|
|
841
|
+
const src = body.content?.kind === "image" ? body.content.src : null;
|
|
842
|
+
if (src !== null && src.startsWith(LOCAL_IMAGES_PREFIX) && !swaps.has(src)) unlisted.add(src);
|
|
843
|
+
}
|
|
844
|
+
for (const node of Object.values(nodes)) {
|
|
845
|
+
if (node.parentId !== null && !Object.hasOwn(nodes, node.parentId)) node.parentId = null;
|
|
846
|
+
if ((node.type === "text" || node.type === "drawing") && node.frameId && !Object.hasOwn(nodes, node.frameId)) {
|
|
847
|
+
node.frameId = null;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
const document2 = {
|
|
851
|
+
created: read2.document.created,
|
|
852
|
+
modified: read2.document.modified,
|
|
853
|
+
canvas: {
|
|
854
|
+
viewport: { ...read2.document.canvas.viewport },
|
|
855
|
+
selected: read2.document.canvas.selected.filter((id) => Object.hasOwn(nodes, id))
|
|
856
|
+
},
|
|
857
|
+
nodes,
|
|
858
|
+
comments: read2.document.comments,
|
|
859
|
+
nextCommentNumber: read2.document.nextCommentNumber
|
|
860
|
+
};
|
|
861
|
+
const baseName = canvasDownloadBaseName(read2.document.name);
|
|
862
|
+
return {
|
|
863
|
+
baseName,
|
|
864
|
+
canvasPath: `${CANVAS_DOWNLOAD_DIR}/${baseName}.canvas`,
|
|
865
|
+
canvasText: JSON.stringify(document2, null, 2),
|
|
866
|
+
assets: [...assets.values()].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0),
|
|
867
|
+
// An image another node lists, and so packed, is not left out.
|
|
868
|
+
unlistedImages: [...unlisted].filter((src) => !assets.has(src.slice(LOCAL_IMAGES_PREFIX.length))).sort(),
|
|
869
|
+
designCount: Object.values(nodes).filter((node) => node.type === "variant").length,
|
|
870
|
+
modified: read2.document.modified
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
function canvasDownloadFiles(download, assetBytes) {
|
|
874
|
+
const files = { [download.canvasPath]: strToU8(download.canvasText) };
|
|
875
|
+
for (const asset of download.assets) {
|
|
876
|
+
const bytes = assetBytes.get(asset.path);
|
|
877
|
+
if (bytes) files[asset.path] = bytes;
|
|
878
|
+
}
|
|
879
|
+
return files;
|
|
880
|
+
}
|
|
881
|
+
function zipCanvasDownload(download, files) {
|
|
882
|
+
const parsed = Date.parse(download.modified);
|
|
883
|
+
const mtime = Number.isFinite(parsed) ? parsed : FALLBACK_ENTRY_TIME;
|
|
884
|
+
const entries = {};
|
|
885
|
+
for (const [path25, bytes] of Object.entries(files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
|
|
886
|
+
entries[path25] = [bytes, { level: entryLevel(path25), mtime }];
|
|
887
|
+
}
|
|
888
|
+
return zipSync(entries);
|
|
889
|
+
}
|
|
890
|
+
async function mapPooled(items, limit, run3) {
|
|
891
|
+
const results = new Array(items.length);
|
|
892
|
+
let next = 0;
|
|
893
|
+
let failed2 = false;
|
|
894
|
+
const worker = async () => {
|
|
895
|
+
while (!failed2 && next < items.length) {
|
|
896
|
+
const index = next++;
|
|
897
|
+
try {
|
|
898
|
+
results[index] = await run3(items[index]);
|
|
899
|
+
} catch (err2) {
|
|
900
|
+
failed2 = true;
|
|
901
|
+
throw err2;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
906
|
+
return results;
|
|
907
|
+
}
|
|
908
|
+
async function nodeBodiesOf(read2, fetchText) {
|
|
909
|
+
const jobs = [];
|
|
910
|
+
for (const [nodeId, files] of Object.entries(read2.nodeFiles)) {
|
|
911
|
+
if (files.state !== "stored" || !Object.hasOwn(read2.document.nodes, nodeId)) continue;
|
|
912
|
+
if (files.html) jobs.push({ nodeId, file: "html", url: files.html });
|
|
913
|
+
if (files.overrides) jobs.push({ nodeId, file: "overrides", url: files.overrides });
|
|
914
|
+
if (files.content) jobs.push({ nodeId, file: "content", url: files.content });
|
|
915
|
+
}
|
|
916
|
+
const texts = await mapPooled(jobs, CANVAS_DOWNLOAD_FETCH_CONCURRENCY, (job) => fetchText(job.url));
|
|
917
|
+
const bodies = {};
|
|
918
|
+
jobs.forEach((job, index) => {
|
|
919
|
+
const text = texts[index];
|
|
920
|
+
const body = bodies[job.nodeId] ??= {};
|
|
921
|
+
if (job.file === "html") body.html = text;
|
|
922
|
+
else if (job.file === "overrides") body.overrides = JSON.parse(text);
|
|
923
|
+
else body.content = JSON.parse(text);
|
|
924
|
+
});
|
|
925
|
+
return bodies;
|
|
926
|
+
}
|
|
927
|
+
async function downloadCanvasZip(read2, fetchers) {
|
|
928
|
+
let bodies;
|
|
929
|
+
try {
|
|
930
|
+
bodies = await nodeBodiesOf(read2, fetchers.fetchText);
|
|
931
|
+
} catch (err2) {
|
|
932
|
+
throw new CanvasDownloadFetchError("node-file" /* NodeFile */, { cause: err2 });
|
|
933
|
+
}
|
|
934
|
+
const download = buildCanvasDownload(read2, bodies);
|
|
935
|
+
let fetched;
|
|
936
|
+
try {
|
|
937
|
+
fetched = await mapPooled(download.assets, CANVAS_DOWNLOAD_FETCH_CONCURRENCY, async (asset) => ({
|
|
938
|
+
asset,
|
|
939
|
+
bytes: await fetchers.fetchBytes(asset.url)
|
|
940
|
+
}));
|
|
941
|
+
} catch (err2) {
|
|
942
|
+
throw new CanvasDownloadFetchError("image" /* Image */, { cause: err2 });
|
|
943
|
+
}
|
|
944
|
+
const assetBytes = /* @__PURE__ */ new Map();
|
|
945
|
+
const missingImages = [];
|
|
946
|
+
for (const { asset, bytes } of fetched) {
|
|
947
|
+
if (bytes) assetBytes.set(asset.path, bytes);
|
|
948
|
+
else missingImages.push(asset);
|
|
949
|
+
}
|
|
950
|
+
const files = canvasDownloadFiles(download, assetBytes);
|
|
951
|
+
return {
|
|
952
|
+
fileName: `${download.baseName}.zip`,
|
|
953
|
+
zip: zipCanvasDownload(download, files),
|
|
954
|
+
files,
|
|
955
|
+
designCount: download.designCount,
|
|
956
|
+
imageCount: assetBytes.size,
|
|
957
|
+
missingImages,
|
|
958
|
+
unlistedImages: download.unlistedImages
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
var CANVAS_DOWNLOAD_DIR, CANVAS_DOWNLOAD_ASSETS_DIR, LOCAL_IMAGES_PREFIX, CANVAS_DOWNLOAD_FALLBACK_NAME, WINDOWS_DEVICE_NAME_RE, WINDOWS_DEVICE_SUFFIX, FALLBACK_ENTRY_TIME, CANVAS_DOWNLOAD_FETCH_CONCURRENCY, EXTENSION_OF_TYPE, CanvasDownloadFetchError, escapeForRegExp, entryLevel;
|
|
962
|
+
var init_canvas_download = __esm({
|
|
963
|
+
"../design-mode/packages/shared/src/canvas-download.ts"() {
|
|
964
|
+
"use strict";
|
|
965
|
+
init_define_KOMBAI_TELEMETRY();
|
|
966
|
+
init_esm();
|
|
967
|
+
init_canvas_document();
|
|
968
|
+
CANVAS_DOWNLOAD_DIR = ".kombai/canvas";
|
|
969
|
+
CANVAS_DOWNLOAD_ASSETS_DIR = ".kombai/canvas/assets";
|
|
970
|
+
LOCAL_IMAGES_PREFIX = "/api/local/images/";
|
|
971
|
+
CANVAS_DOWNLOAD_FALLBACK_NAME = "canvas";
|
|
972
|
+
WINDOWS_DEVICE_NAME_RE = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;
|
|
973
|
+
WINDOWS_DEVICE_SUFFIX = "-canvas";
|
|
974
|
+
FALLBACK_ENTRY_TIME = Date.UTC(2026, 0, 1);
|
|
975
|
+
CANVAS_DOWNLOAD_FETCH_CONCURRENCY = 8;
|
|
976
|
+
EXTENSION_OF_TYPE = {
|
|
977
|
+
"image/png": "png",
|
|
978
|
+
"image/jpeg": "jpg",
|
|
979
|
+
"image/webp": "webp",
|
|
980
|
+
"image/gif": "gif",
|
|
981
|
+
"image/svg+xml": "svg",
|
|
982
|
+
"video/mp4": "mp4",
|
|
983
|
+
"video/webm": "webm"
|
|
984
|
+
};
|
|
985
|
+
CanvasDownloadFetchError = class extends Error {
|
|
986
|
+
constructor(failure, options) {
|
|
987
|
+
super(
|
|
988
|
+
failure === "node-file" /* NodeFile */ ? "A design file could not be fetched" : "An image could not be fetched",
|
|
989
|
+
options
|
|
990
|
+
);
|
|
991
|
+
this.failure = failure;
|
|
992
|
+
this.name = "CanvasDownloadFetchError";
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
escapeForRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
996
|
+
entryLevel = (path25) => path25.endsWith(".canvas") || path25.endsWith(".svg") ? 6 : 0;
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
|
|
51
1000
|
// ../design-mode/packages/shared/src/design-api.ts
|
|
52
1001
|
function normalizeGitRemote(remote) {
|
|
53
1002
|
const trimmed = remote.trim();
|
|
@@ -176,21 +1125,12 @@ var init_id = __esm({
|
|
|
176
1125
|
}
|
|
177
1126
|
});
|
|
178
1127
|
|
|
179
|
-
// ../design-mode/packages/shared/src/canvas-document.ts
|
|
180
|
-
var CANVAS_ASSET_SRC_RE;
|
|
181
|
-
var init_canvas_document = __esm({
|
|
182
|
-
"../design-mode/packages/shared/src/canvas-document.ts"() {
|
|
183
|
-
"use strict";
|
|
184
|
-
init_define_KOMBAI_TELEMETRY();
|
|
185
|
-
CANVAS_ASSET_SRC_RE = /^\/api\/local\/images\/\.kombai\/canvas\/assets\/[a-f0-9]{64}\.(?:png|jpe?g|webp|gif|svg)$/;
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
1128
|
// src/lib/contract.js
|
|
190
1129
|
var init_contract = __esm({
|
|
191
1130
|
"src/lib/contract.js"() {
|
|
192
1131
|
"use strict";
|
|
193
1132
|
init_define_KOMBAI_TELEMETRY();
|
|
1133
|
+
init_canvas_download();
|
|
194
1134
|
init_design_api();
|
|
195
1135
|
init_id();
|
|
196
1136
|
init_canvas_document();
|
|
@@ -818,7 +1758,7 @@ var init_version = __esm({
|
|
|
818
1758
|
"src/lib/version.js"() {
|
|
819
1759
|
"use strict";
|
|
820
1760
|
init_define_KOMBAI_TELEMETRY();
|
|
821
|
-
CLI_VERSION = true ? "0.1.2-beta.
|
|
1761
|
+
CLI_VERSION = true ? "0.1.2-beta.4" : (
|
|
822
1762
|
/** @type {{ version: string }} */
|
|
823
1763
|
JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version
|
|
824
1764
|
);
|
|
@@ -849,7 +1789,7 @@ function retryAfterMs(value) {
|
|
|
849
1789
|
const at = Date.parse(value ?? "");
|
|
850
1790
|
return Number.isFinite(at) ? Math.max(0, at - Date.now()) : 2e3;
|
|
851
1791
|
}
|
|
852
|
-
function apiError(status, body, method,
|
|
1792
|
+
function apiError(status, body, method, path25) {
|
|
853
1793
|
const {
|
|
854
1794
|
errorCode,
|
|
855
1795
|
apiMessage,
|
|
@@ -863,7 +1803,7 @@ function apiError(status, body, method, path23) {
|
|
|
863
1803
|
...extras
|
|
864
1804
|
};
|
|
865
1805
|
const code2 = typeof errorCode === "string" ? errorCode : `HTTP_${status}`;
|
|
866
|
-
const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${
|
|
1806
|
+
const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${path25} answered ${status}.`;
|
|
867
1807
|
const guestRow = GUEST_ERRORS[code2];
|
|
868
1808
|
const needsLogin = status === 401 || guestRow !== void 0;
|
|
869
1809
|
const text = guestRow?.message?.(rest, typeof apiMessage === "string" ? apiMessage : "") ?? message;
|
|
@@ -874,8 +1814,8 @@ function apiError(status, body, method, path23) {
|
|
|
874
1814
|
details: Object.keys(rest).length ? rest : void 0
|
|
875
1815
|
});
|
|
876
1816
|
}
|
|
877
|
-
function timedOut(method,
|
|
878
|
-
return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${
|
|
1817
|
+
function timedOut(method, path25) {
|
|
1818
|
+
return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${path25}.`, {
|
|
879
1819
|
exit: Exit.TIMED_OUT
|
|
880
1820
|
});
|
|
881
1821
|
}
|
|
@@ -910,10 +1850,10 @@ var init_api = __esm({
|
|
|
910
1850
|
* @param {string} path
|
|
911
1851
|
* @param {number | undefined} status
|
|
912
1852
|
*/
|
|
913
|
-
constructor(method,
|
|
914
|
-
super("CLI_NETWORK", `${method} ${
|
|
1853
|
+
constructor(method, path25, status) {
|
|
1854
|
+
super("CLI_NETWORK", `${method} ${path25} got no usable answer${status ? ` (${status})` : ""}.`, {
|
|
915
1855
|
status,
|
|
916
|
-
details: { method, path:
|
|
1856
|
+
details: { method, path: path25 }
|
|
917
1857
|
});
|
|
918
1858
|
this.lost = true;
|
|
919
1859
|
}
|
|
@@ -948,9 +1888,9 @@ var init_api = __esm({
|
|
|
948
1888
|
* @returns {Promise<ApiResponse>}
|
|
949
1889
|
*/
|
|
950
1890
|
async call(options) {
|
|
951
|
-
const { method, path:
|
|
1891
|
+
const { method, path: path25, retry = "safe" } = options;
|
|
952
1892
|
const deadline = options.deadline ?? this.deadline;
|
|
953
|
-
const url2 = `${this.baseUrl}${
|
|
1893
|
+
const url2 = `${this.baseUrl}${path25}${queryString(options.query)}`;
|
|
954
1894
|
const headers = {
|
|
955
1895
|
"x-kombai-cli": this.ctx.version,
|
|
956
1896
|
"x-type": "agent",
|
|
@@ -964,7 +1904,7 @@ var init_api = __esm({
|
|
|
964
1904
|
let lostTries = 0;
|
|
965
1905
|
for (; ; ) {
|
|
966
1906
|
const limit = deadline.clamp(CALL_LIMIT_MS);
|
|
967
|
-
if (limit <= 0) throw timedOut(method,
|
|
1907
|
+
if (limit <= 0) throw timedOut(method, path25);
|
|
968
1908
|
let res;
|
|
969
1909
|
if (method !== "GET") this.ctx.changeSent = true;
|
|
970
1910
|
try {
|
|
@@ -978,12 +1918,12 @@ var init_api = __esm({
|
|
|
978
1918
|
} catch (error3) {
|
|
979
1919
|
const blocked = blockedRequest(this.ctx.sandbox, error3);
|
|
980
1920
|
if (blocked) throw blocked;
|
|
981
|
-
if (deadline.expired()) throw timedOut(method,
|
|
1921
|
+
if (deadline.expired()) throw timedOut(method, path25);
|
|
982
1922
|
if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
|
|
983
|
-
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method,
|
|
1923
|
+
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path25);
|
|
984
1924
|
continue;
|
|
985
1925
|
}
|
|
986
|
-
throw new LostAnswer(method,
|
|
1926
|
+
throw new LostAnswer(method, path25, void 0);
|
|
987
1927
|
}
|
|
988
1928
|
this.checkContractVersion(res.headers);
|
|
989
1929
|
const parsed = await readBody(res);
|
|
@@ -997,17 +1937,17 @@ var init_api = __esm({
|
|
|
997
1937
|
}
|
|
998
1938
|
if (UNKNOWN_OUTCOME_STATUSES.has(res.status)) {
|
|
999
1939
|
if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
|
|
1000
|
-
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method,
|
|
1940
|
+
await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path25);
|
|
1001
1941
|
continue;
|
|
1002
1942
|
}
|
|
1003
|
-
if (retry === "once") throw new LostAnswer(method,
|
|
1943
|
+
if (retry === "once") throw new LostAnswer(method, path25, res.status);
|
|
1004
1944
|
}
|
|
1005
1945
|
if (res.ok) {
|
|
1006
1946
|
if (headers["x-kombai-guest"] && parsed?.guest === true && typeof parsed.guestExpiresAt === "string")
|
|
1007
1947
|
await this.onGuestExpires?.(parsed.guestExpiresAt);
|
|
1008
1948
|
return { status: res.status, body: parsed, headers: res.headers };
|
|
1009
1949
|
}
|
|
1010
|
-
const error2 = apiError(res.status, parsed, method,
|
|
1950
|
+
const error2 = apiError(res.status, parsed, method, path25);
|
|
1011
1951
|
if (res.status === 503 && res.headers.has("retry-after")) {
|
|
1012
1952
|
error2.details = { ...error2.details, retryAfter: res.headers.get("retry-after") };
|
|
1013
1953
|
}
|
|
@@ -1034,10 +1974,10 @@ var init_api = __esm({
|
|
|
1034
1974
|
if (typeof form.maxBytes === "number" && data.byteLength > form.maxBytes)
|
|
1035
1975
|
throw tooLarge("CLI_FILE_TOO_LARGE", "The file", data.byteLength, form.maxBytes);
|
|
1036
1976
|
return this.storage(form.url, deadline, () => {
|
|
1037
|
-
const
|
|
1038
|
-
for (const [name, value] of Object.entries(form.fields))
|
|
1039
|
-
|
|
1040
|
-
return { method: "POST", body:
|
|
1977
|
+
const fd2 = new FormData();
|
|
1978
|
+
for (const [name, value] of Object.entries(form.fields)) fd2.append(name, value);
|
|
1979
|
+
fd2.append("file", new Blob([data], { type: contentType }));
|
|
1980
|
+
return { method: "POST", body: fd2 };
|
|
1041
1981
|
});
|
|
1042
1982
|
}
|
|
1043
1983
|
/**
|
|
@@ -1092,8 +2032,8 @@ var init_api = __esm({
|
|
|
1092
2032
|
* @param {string} method
|
|
1093
2033
|
* @param {string} path
|
|
1094
2034
|
*/
|
|
1095
|
-
async wait(ms, deadline, method,
|
|
1096
|
-
if (deadline.remaining() <= ms) throw timedOut(method,
|
|
2035
|
+
async wait(ms, deadline, method, path25) {
|
|
2036
|
+
if (deadline.remaining() <= ms) throw timedOut(method, path25);
|
|
1097
2037
|
await this.ctx.sleep(ms);
|
|
1098
2038
|
}
|
|
1099
2039
|
/** @param {Headers} headers */
|
|
@@ -3946,11 +4886,11 @@ var require_is_docker = __commonJS({
|
|
|
3946
4886
|
"../../node_modules/is-docker/index.js"(exports, module) {
|
|
3947
4887
|
"use strict";
|
|
3948
4888
|
init_define_KOMBAI_TELEMETRY();
|
|
3949
|
-
var
|
|
4889
|
+
var fs20 = __require("fs");
|
|
3950
4890
|
var isDocker;
|
|
3951
4891
|
function hasDockerEnv() {
|
|
3952
4892
|
try {
|
|
3953
|
-
|
|
4893
|
+
fs20.statSync("/.dockerenv");
|
|
3954
4894
|
return true;
|
|
3955
4895
|
} catch (_) {
|
|
3956
4896
|
return false;
|
|
@@ -3958,7 +4898,7 @@ var require_is_docker = __commonJS({
|
|
|
3958
4898
|
}
|
|
3959
4899
|
function hasDockerCGroup() {
|
|
3960
4900
|
try {
|
|
3961
|
-
return
|
|
4901
|
+
return fs20.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
3962
4902
|
} catch (_) {
|
|
3963
4903
|
return false;
|
|
3964
4904
|
}
|
|
@@ -3978,7 +4918,7 @@ var require_is_wsl = __commonJS({
|
|
|
3978
4918
|
"use strict";
|
|
3979
4919
|
init_define_KOMBAI_TELEMETRY();
|
|
3980
4920
|
var os5 = __require("os");
|
|
3981
|
-
var
|
|
4921
|
+
var fs20 = __require("fs");
|
|
3982
4922
|
var isDocker = require_is_docker();
|
|
3983
4923
|
var isWsl3 = () => {
|
|
3984
4924
|
if (process.platform !== "linux") {
|
|
@@ -3991,7 +4931,7 @@ var require_is_wsl = __commonJS({
|
|
|
3991
4931
|
return true;
|
|
3992
4932
|
}
|
|
3993
4933
|
try {
|
|
3994
|
-
return
|
|
4934
|
+
return fs20.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
|
|
3995
4935
|
} catch (_) {
|
|
3996
4936
|
return false;
|
|
3997
4937
|
}
|
|
@@ -4055,15 +4995,15 @@ function toWSLPath(dir, fallback) {
|
|
|
4055
4995
|
return fallback;
|
|
4056
4996
|
}
|
|
4057
4997
|
}
|
|
4058
|
-
function getLocalAppDataPath(
|
|
4998
|
+
function getLocalAppDataPath(path25) {
|
|
4059
4999
|
const userRegExp = /\/mnt\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
|
|
4060
|
-
const results = userRegExp.exec(
|
|
5000
|
+
const results = userRegExp.exec(path25) || [];
|
|
4061
5001
|
return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`;
|
|
4062
5002
|
}
|
|
4063
|
-
function getWSLLocalAppDataPath(
|
|
5003
|
+
function getWSLLocalAppDataPath(path25) {
|
|
4064
5004
|
const userRegExp = /\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
|
|
4065
|
-
const results = userRegExp.exec(
|
|
4066
|
-
return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(
|
|
5005
|
+
const results = userRegExp.exec(path25) || [];
|
|
5006
|
+
return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(path25));
|
|
4067
5007
|
}
|
|
4068
5008
|
function makeUnixTmpDir() {
|
|
4069
5009
|
return childProcess.execSync("mktemp -d -t lighthouse.XXXXXXX").toString().trim();
|
|
@@ -4528,8 +5468,8 @@ var init_chrome_launcher = __esm({
|
|
|
4528
5468
|
} else {
|
|
4529
5469
|
this.fs.writeFileSync(preferenceFile, JSON.stringify({ ...this.prefs }), "utf-8");
|
|
4530
5470
|
}
|
|
4531
|
-
} catch (
|
|
4532
|
-
lighthouse_logger_default.log("ChromeLauncher", `Failed to set browser prefs: ${
|
|
5471
|
+
} catch (err2) {
|
|
5472
|
+
lighthouse_logger_default.log("ChromeLauncher", `Failed to set browser prefs: ${err2.message}`);
|
|
4533
5473
|
}
|
|
4534
5474
|
}
|
|
4535
5475
|
async launch() {
|
|
@@ -4539,7 +5479,7 @@ var init_chrome_launcher = __esm({
|
|
|
4539
5479
|
await this.isDebuggerReady();
|
|
4540
5480
|
lighthouse_logger_default.log("ChromeLauncher", `Found existing Chrome already running using port ${this.port}, using that.`);
|
|
4541
5481
|
return;
|
|
4542
|
-
} catch (
|
|
5482
|
+
} catch (err2) {
|
|
4543
5483
|
if (this.portStrictMode) {
|
|
4544
5484
|
throw new Error(`found no Chrome at port ${this.requestedPort}`);
|
|
4545
5485
|
}
|
|
@@ -4612,9 +5552,9 @@ var init_chrome_launcher = __esm({
|
|
|
4612
5552
|
isDebuggerReady() {
|
|
4613
5553
|
return new Promise((resolve, reject) => {
|
|
4614
5554
|
const client = net.createConnection(this.port, "127.0.0.1");
|
|
4615
|
-
client.once("error", (
|
|
5555
|
+
client.once("error", (err2) => {
|
|
4616
5556
|
this.cleanup(client);
|
|
4617
|
-
reject(
|
|
5557
|
+
reject(err2);
|
|
4618
5558
|
});
|
|
4619
5559
|
client.once("connect", () => {
|
|
4620
5560
|
this.cleanup(client);
|
|
@@ -4638,13 +5578,13 @@ var init_chrome_launcher = __esm({
|
|
|
4638
5578
|
launcher.isDebuggerReady().then(() => {
|
|
4639
5579
|
lighthouse_logger_default.log("ChromeLauncher", waitStatus + `${lighthouse_logger_default.greenify(lighthouse_logger_default.tick)}`);
|
|
4640
5580
|
resolve();
|
|
4641
|
-
}).catch((
|
|
5581
|
+
}).catch((err2) => {
|
|
4642
5582
|
if (retries > launcher.maxConnectionRetries) {
|
|
4643
|
-
lighthouse_logger_default.error("ChromeLauncher",
|
|
5583
|
+
lighthouse_logger_default.error("ChromeLauncher", err2.message);
|
|
4644
5584
|
const stderr = this.fs.readFileSync(`${this.userDataDir}/chrome-err.log`, { encoding: "utf-8" });
|
|
4645
5585
|
lighthouse_logger_default.error("ChromeLauncher", `Logging contents of ${this.userDataDir}/chrome-err.log`);
|
|
4646
5586
|
lighthouse_logger_default.error("ChromeLauncher", stderr);
|
|
4647
|
-
return reject(
|
|
5587
|
+
return reject(err2);
|
|
4648
5588
|
}
|
|
4649
5589
|
delay(launcher.connectionPollInterval).then(poll);
|
|
4650
5590
|
});
|
|
@@ -4672,8 +5612,8 @@ var init_chrome_launcher = __esm({
|
|
|
4672
5612
|
process.kill(-this.chromeProcess.pid, "SIGKILL");
|
|
4673
5613
|
}
|
|
4674
5614
|
}
|
|
4675
|
-
} catch (
|
|
4676
|
-
const message = `Chrome could not be killed ${
|
|
5615
|
+
} catch (err2) {
|
|
5616
|
+
const message = `Chrome could not be killed ${err2.message}`;
|
|
4677
5617
|
lighthouse_logger_default.warn("ChromeLauncher", message);
|
|
4678
5618
|
}
|
|
4679
5619
|
this.destroyTmp();
|
|
@@ -4711,8 +5651,8 @@ var require_windows = __commonJS({
|
|
|
4711
5651
|
init_define_KOMBAI_TELEMETRY();
|
|
4712
5652
|
module.exports = isexe;
|
|
4713
5653
|
isexe.sync = sync;
|
|
4714
|
-
var
|
|
4715
|
-
function checkPathExt(
|
|
5654
|
+
var fs20 = __require("fs");
|
|
5655
|
+
function checkPathExt(path25, options) {
|
|
4716
5656
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
4717
5657
|
if (!pathext) {
|
|
4718
5658
|
return true;
|
|
@@ -4723,25 +5663,25 @@ var require_windows = __commonJS({
|
|
|
4723
5663
|
}
|
|
4724
5664
|
for (var i = 0; i < pathext.length; i++) {
|
|
4725
5665
|
var p = pathext[i].toLowerCase();
|
|
4726
|
-
if (p &&
|
|
5666
|
+
if (p && path25.substr(-p.length).toLowerCase() === p) {
|
|
4727
5667
|
return true;
|
|
4728
5668
|
}
|
|
4729
5669
|
}
|
|
4730
5670
|
return false;
|
|
4731
5671
|
}
|
|
4732
|
-
function checkStat(stat,
|
|
5672
|
+
function checkStat(stat, path25, options) {
|
|
4733
5673
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
4734
5674
|
return false;
|
|
4735
5675
|
}
|
|
4736
|
-
return checkPathExt(
|
|
5676
|
+
return checkPathExt(path25, options);
|
|
4737
5677
|
}
|
|
4738
|
-
function isexe(
|
|
4739
|
-
|
|
4740
|
-
cb(er, er ? false : checkStat(stat,
|
|
5678
|
+
function isexe(path25, options, cb) {
|
|
5679
|
+
fs20.stat(path25, function(er, stat) {
|
|
5680
|
+
cb(er, er ? false : checkStat(stat, path25, options));
|
|
4741
5681
|
});
|
|
4742
5682
|
}
|
|
4743
|
-
function sync(
|
|
4744
|
-
return checkStat(
|
|
5683
|
+
function sync(path25, options) {
|
|
5684
|
+
return checkStat(fs20.statSync(path25), path25, options);
|
|
4745
5685
|
}
|
|
4746
5686
|
}
|
|
4747
5687
|
});
|
|
@@ -4752,14 +5692,14 @@ var require_mode = __commonJS({
|
|
|
4752
5692
|
init_define_KOMBAI_TELEMETRY();
|
|
4753
5693
|
module.exports = isexe;
|
|
4754
5694
|
isexe.sync = sync;
|
|
4755
|
-
var
|
|
4756
|
-
function isexe(
|
|
4757
|
-
|
|
5695
|
+
var fs20 = __require("fs");
|
|
5696
|
+
function isexe(path25, options, cb) {
|
|
5697
|
+
fs20.stat(path25, function(er, stat) {
|
|
4758
5698
|
cb(er, er ? false : checkStat(stat, options));
|
|
4759
5699
|
});
|
|
4760
5700
|
}
|
|
4761
|
-
function sync(
|
|
4762
|
-
return checkStat(
|
|
5701
|
+
function sync(path25, options) {
|
|
5702
|
+
return checkStat(fs20.statSync(path25), options);
|
|
4763
5703
|
}
|
|
4764
5704
|
function checkStat(stat, options) {
|
|
4765
5705
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -4784,7 +5724,7 @@ var require_mode = __commonJS({
|
|
|
4784
5724
|
var require_isexe = __commonJS({
|
|
4785
5725
|
"../../node_modules/isexe/index.js"(exports, module) {
|
|
4786
5726
|
init_define_KOMBAI_TELEMETRY();
|
|
4787
|
-
var
|
|
5727
|
+
var fs20 = __require("fs");
|
|
4788
5728
|
var core;
|
|
4789
5729
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
4790
5730
|
core = require_windows();
|
|
@@ -4793,7 +5733,7 @@ var require_isexe = __commonJS({
|
|
|
4793
5733
|
}
|
|
4794
5734
|
module.exports = isexe;
|
|
4795
5735
|
isexe.sync = sync;
|
|
4796
|
-
function isexe(
|
|
5736
|
+
function isexe(path25, options, cb) {
|
|
4797
5737
|
if (typeof options === "function") {
|
|
4798
5738
|
cb = options;
|
|
4799
5739
|
options = {};
|
|
@@ -4803,7 +5743,7 @@ var require_isexe = __commonJS({
|
|
|
4803
5743
|
throw new TypeError("callback not provided");
|
|
4804
5744
|
}
|
|
4805
5745
|
return new Promise(function(resolve, reject) {
|
|
4806
|
-
isexe(
|
|
5746
|
+
isexe(path25, options || {}, function(er, is) {
|
|
4807
5747
|
if (er) {
|
|
4808
5748
|
reject(er);
|
|
4809
5749
|
} else {
|
|
@@ -4812,7 +5752,7 @@ var require_isexe = __commonJS({
|
|
|
4812
5752
|
});
|
|
4813
5753
|
});
|
|
4814
5754
|
}
|
|
4815
|
-
core(
|
|
5755
|
+
core(path25, options || {}, function(er, is) {
|
|
4816
5756
|
if (er) {
|
|
4817
5757
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
4818
5758
|
er = null;
|
|
@@ -4822,9 +5762,9 @@ var require_isexe = __commonJS({
|
|
|
4822
5762
|
cb(er, is);
|
|
4823
5763
|
});
|
|
4824
5764
|
}
|
|
4825
|
-
function sync(
|
|
5765
|
+
function sync(path25, options) {
|
|
4826
5766
|
try {
|
|
4827
|
-
return core.sync(
|
|
5767
|
+
return core.sync(path25, options || {});
|
|
4828
5768
|
} catch (er) {
|
|
4829
5769
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
4830
5770
|
return false;
|
|
@@ -4841,7 +5781,7 @@ var require_which = __commonJS({
|
|
|
4841
5781
|
"../../node_modules/which/which.js"(exports, module) {
|
|
4842
5782
|
init_define_KOMBAI_TELEMETRY();
|
|
4843
5783
|
var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
4844
|
-
var
|
|
5784
|
+
var path25 = __require("path");
|
|
4845
5785
|
var COLON = isWindows3 ? ";" : ":";
|
|
4846
5786
|
var isexe = require_isexe();
|
|
4847
5787
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -4879,7 +5819,7 @@ var require_which = __commonJS({
|
|
|
4879
5819
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
4880
5820
|
const ppRaw = pathEnv[i];
|
|
4881
5821
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
4882
|
-
const pCmd =
|
|
5822
|
+
const pCmd = path25.join(pathPart, cmd);
|
|
4883
5823
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
4884
5824
|
resolve(subStep(p, i, 0));
|
|
4885
5825
|
});
|
|
@@ -4906,7 +5846,7 @@ var require_which = __commonJS({
|
|
|
4906
5846
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
4907
5847
|
const ppRaw = pathEnv[i];
|
|
4908
5848
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
4909
|
-
const pCmd =
|
|
5849
|
+
const pCmd = path25.join(pathPart, cmd);
|
|
4910
5850
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
4911
5851
|
for (let j = 0; j < pathExt.length; j++) {
|
|
4912
5852
|
const cur = p + pathExt[j];
|
|
@@ -4938,8 +5878,8 @@ import { existsSync } from "fs";
|
|
|
4938
5878
|
import path10 from "path";
|
|
4939
5879
|
function getEdgeLinux(name) {
|
|
4940
5880
|
try {
|
|
4941
|
-
let
|
|
4942
|
-
return
|
|
5881
|
+
let path25 = import_which.default.sync(name);
|
|
5882
|
+
return path25;
|
|
4943
5883
|
} catch (e) {
|
|
4944
5884
|
}
|
|
4945
5885
|
return null;
|
|
@@ -5176,7 +6116,7 @@ async function markLaunchFailed(ctx, browserPath) {
|
|
|
5176
6116
|
}
|
|
5177
6117
|
async function saveBrowser(ctx, change) {
|
|
5178
6118
|
await updateConfig(ctx.home, (c) => {
|
|
5179
|
-
const { launchFailed: _f, failedPath: _p, failedAt:
|
|
6119
|
+
const { launchFailed: _f, failedPath: _p, failedAt: _a3, ...rest } = c.browser ?? {};
|
|
5180
6120
|
return { ...c, browser: { ...rest, ...change, checkedAt: new Date(ctx.now()).toISOString() } };
|
|
5181
6121
|
});
|
|
5182
6122
|
}
|
|
@@ -5309,25 +6249,812 @@ var init_tailwind_detection = __esm({
|
|
|
5309
6249
|
}
|
|
5310
6250
|
});
|
|
5311
6251
|
|
|
6252
|
+
// ../design-mode/packages/shared/src/convert-viewport-units.ts
|
|
6253
|
+
function convertViewportUnits(html, vw, vh) {
|
|
6254
|
+
if (!html) return html;
|
|
6255
|
+
const min = Math.min(vw, vh);
|
|
6256
|
+
const max = Math.max(vw, vh);
|
|
6257
|
+
return html.replace(UNIT_PATTERN, (_, n, unit) => {
|
|
6258
|
+
const num = parseFloat(n);
|
|
6259
|
+
const u = unit.toLowerCase();
|
|
6260
|
+
let base;
|
|
6261
|
+
if (u.endsWith("vmin")) base = min;
|
|
6262
|
+
else if (u.endsWith("vmax")) base = max;
|
|
6263
|
+
else if (u.endsWith("vw")) base = vw;
|
|
6264
|
+
else base = vh;
|
|
6265
|
+
return `${Math.round(num * base / 100)}px`;
|
|
6266
|
+
});
|
|
6267
|
+
}
|
|
6268
|
+
function buildViewportUnitOverrideCss(vw, vh) {
|
|
6269
|
+
return `
|
|
6270
|
+
.h-screen, .h-dvh, .h-svh, .h-lvh { height: ${vh}px !important; }
|
|
6271
|
+
.min-h-screen, .min-h-dvh, .min-h-svh, .min-h-lvh { min-height: ${vh}px !important; }
|
|
6272
|
+
.max-h-screen, .max-h-dvh, .max-h-svh, .max-h-lvh { max-height: ${vh}px !important; }
|
|
6273
|
+
.w-screen, .w-dvw, .w-svw, .w-lvw { width: ${vw}px !important; }
|
|
6274
|
+
.min-w-screen, .min-w-dvw, .min-w-svw, .min-w-lvw { min-width: ${vw}px !important; }
|
|
6275
|
+
.max-w-screen, .max-w-dvw, .max-w-svw, .max-w-lvw { max-width: ${vw}px !important; }
|
|
6276
|
+
`;
|
|
6277
|
+
}
|
|
6278
|
+
var UNIT_SOURCE, UNIT_PATTERN, HAS_UNIT;
|
|
6279
|
+
var init_convert_viewport_units = __esm({
|
|
6280
|
+
"../design-mode/packages/shared/src/convert-viewport-units.ts"() {
|
|
6281
|
+
"use strict";
|
|
6282
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6283
|
+
UNIT_SOURCE = String.raw`(-?\d*\.?\d+)(dvh|svh|lvh|vh|dvw|svw|lvw|vw|dvmin|svmin|lvmin|vmin|dvmax|svmax|lvmax|vmax)\b`;
|
|
6284
|
+
UNIT_PATTERN = new RegExp(UNIT_SOURCE, "gi");
|
|
6285
|
+
HAS_UNIT = new RegExp(UNIT_SOURCE, "i");
|
|
6286
|
+
}
|
|
6287
|
+
});
|
|
6288
|
+
|
|
6289
|
+
// ../design-mode/packages/shared/src/screenshot-height-metadata.ts
|
|
6290
|
+
var INTRINSIC_VIEWPORT_HEIGHT;
|
|
6291
|
+
var init_screenshot_height_metadata = __esm({
|
|
6292
|
+
"../design-mode/packages/shared/src/screenshot-height-metadata.ts"() {
|
|
6293
|
+
"use strict";
|
|
6294
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6295
|
+
INTRINSIC_VIEWPORT_HEIGHT = 1e3;
|
|
6296
|
+
}
|
|
6297
|
+
});
|
|
6298
|
+
|
|
6299
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/match-media-patch.ts
|
|
6300
|
+
var MATCH_MEDIA_PATCH;
|
|
6301
|
+
var init_match_media_patch = __esm({
|
|
6302
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/match-media-patch.ts"() {
|
|
6303
|
+
"use strict";
|
|
6304
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6305
|
+
MATCH_MEDIA_PATCH = `
|
|
6306
|
+
try {
|
|
6307
|
+
var origMM = window.matchMedia ? window.matchMedia.bind(window) : null;
|
|
6308
|
+
window.matchMedia = function (q) {
|
|
6309
|
+
var base = origMM ? origMM(q) : {
|
|
6310
|
+
media: q, matches: false, onchange: null,
|
|
6311
|
+
addListener: function () {}, removeListener: function () {},
|
|
6312
|
+
addEventListener: function () {}, removeEventListener: function () {},
|
|
6313
|
+
dispatchEvent: function () { return false; }
|
|
6314
|
+
};
|
|
6315
|
+
if (typeof q === 'string' && /prefers-reduced-motion/i.test(q)) {
|
|
6316
|
+
return new Proxy(base, {
|
|
6317
|
+
get: function (t, p) {
|
|
6318
|
+
if (p === 'matches') return true;
|
|
6319
|
+
if (p === 'media') return q;
|
|
6320
|
+
var v = t[p];
|
|
6321
|
+
return typeof v === 'function' ? v.bind(t) : v;
|
|
6322
|
+
}
|
|
6323
|
+
});
|
|
6324
|
+
}
|
|
6325
|
+
return base;
|
|
6326
|
+
};
|
|
6327
|
+
} catch (e) {}
|
|
6328
|
+
`;
|
|
6329
|
+
}
|
|
6330
|
+
});
|
|
6331
|
+
|
|
6332
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/css-freeze.ts
|
|
6333
|
+
var CSS_FREEZE;
|
|
6334
|
+
var init_css_freeze = __esm({
|
|
6335
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/css-freeze.ts"() {
|
|
6336
|
+
"use strict";
|
|
6337
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6338
|
+
CSS_FREEZE = `
|
|
6339
|
+
function installFreezeStyle() {
|
|
6340
|
+
var s = document.createElement('style');
|
|
6341
|
+
s.setAttribute('data-screenshot-freeze', '1');
|
|
6342
|
+
s.textContent = '*, *::before, *::after {' +
|
|
6343
|
+
'animation-duration: 0s !important;' +
|
|
6344
|
+
'animation-delay: 0s !important;' +
|
|
6345
|
+
'transition-duration: 0s !important;' +
|
|
6346
|
+
'transition-delay: 0s !important;' +
|
|
6347
|
+
'caret-color: transparent !important;' +
|
|
6348
|
+
'}';
|
|
6349
|
+
(document.head || document.documentElement).appendChild(s);
|
|
6350
|
+
}
|
|
6351
|
+
if (document.head) {
|
|
6352
|
+
installFreezeStyle();
|
|
6353
|
+
} else {
|
|
6354
|
+
var moHead = new MutationObserver(function (_, obs) {
|
|
6355
|
+
if (document.head) { installFreezeStyle(); obs.disconnect(); }
|
|
6356
|
+
});
|
|
6357
|
+
moHead.observe(document.documentElement, { childList: true, subtree: true });
|
|
6358
|
+
}
|
|
6359
|
+
`;
|
|
6360
|
+
}
|
|
6361
|
+
});
|
|
6362
|
+
|
|
6363
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/detected.ts
|
|
6364
|
+
var DETECT_SNIPPET;
|
|
6365
|
+
var init_detected = __esm({
|
|
6366
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/detected.ts"() {
|
|
6367
|
+
"use strict";
|
|
6368
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6369
|
+
DETECT_SNIPPET = `
|
|
6370
|
+
var __root = document.documentElement;
|
|
6371
|
+
var __hasGsap = typeof window.gsap !== 'undefined';
|
|
6372
|
+
var detected = {
|
|
6373
|
+
lenis: !!(window.lenis || window.__lenis ||
|
|
6374
|
+
__root.classList.contains('lenis') || __root.classList.contains('lenis-smooth')),
|
|
6375
|
+
locomotive: !!(window.locomotive || window.LocomotiveScroll ||
|
|
6376
|
+
__root.classList.contains('has-scroll-smooth') ||
|
|
6377
|
+
!!document.querySelector('[data-scroll-container]')),
|
|
6378
|
+
gsap: __hasGsap,
|
|
6379
|
+
scrolltrigger: !!(window.ScrollTrigger ||
|
|
6380
|
+
(__hasGsap && window.gsap.core && typeof window.gsap.core.getCache === 'function')),
|
|
6381
|
+
anime: typeof window.anime !== 'undefined',
|
|
6382
|
+
animeV4: !!(window.anime && window.anime.engine),
|
|
6383
|
+
motion: typeof window.motion !== 'undefined',
|
|
6384
|
+
waapi_active: document.getAnimations ? document.getAnimations().length : 0
|
|
6385
|
+
};
|
|
6386
|
+
// Read back by the renderer (render.ts) to decide whether the page is worth a live re-measure.
|
|
6387
|
+
window.__kombaiDetected = detected;
|
|
6388
|
+
log('detected', detected);
|
|
6389
|
+
`;
|
|
6390
|
+
}
|
|
6391
|
+
});
|
|
6392
|
+
|
|
6393
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/lenis.ts
|
|
6394
|
+
var LENIS_TEARDOWN;
|
|
6395
|
+
var init_lenis = __esm({
|
|
6396
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/lenis.ts"() {
|
|
6397
|
+
"use strict";
|
|
6398
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6399
|
+
LENIS_TEARDOWN = `
|
|
6400
|
+
var __lenisRoot = document.documentElement;
|
|
6401
|
+
if (
|
|
6402
|
+
window.lenis || window.__lenis ||
|
|
6403
|
+
__lenisRoot.classList.contains('lenis') ||
|
|
6404
|
+
__lenisRoot.classList.contains('lenis-smooth')
|
|
6405
|
+
) {
|
|
6406
|
+
try { window.lenis && window.lenis.destroy && window.lenis.destroy(); } catch (e) {}
|
|
6407
|
+
try { window.__lenis && window.__lenis.destroy && window.__lenis.destroy(); } catch (e) {}
|
|
6408
|
+
__lenisRoot.classList.remove('lenis', 'lenis-smooth', 'lenis-scrolling', 'lenis-stopped');
|
|
6409
|
+
__lenisRoot.style.scrollBehavior = 'auto';
|
|
6410
|
+
var __lenisUnstuck = document.createElement('style');
|
|
6411
|
+
__lenisUnstuck.textContent =
|
|
6412
|
+
'html, body { overflow: auto !important; height: auto !important; }' +
|
|
6413
|
+
'.lenis, .lenis-content, .smooth-wrapper { transform: none !important; }';
|
|
6414
|
+
document.head.appendChild(__lenisUnstuck);
|
|
6415
|
+
}
|
|
6416
|
+
`;
|
|
6417
|
+
}
|
|
6418
|
+
});
|
|
6419
|
+
|
|
6420
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/locomotive.ts
|
|
6421
|
+
var LOCOMOTIVE_TEARDOWN;
|
|
6422
|
+
var init_locomotive = __esm({
|
|
6423
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/locomotive.ts"() {
|
|
6424
|
+
"use strict";
|
|
6425
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6426
|
+
LOCOMOTIVE_TEARDOWN = `
|
|
6427
|
+
var __locoRoot = document.documentElement;
|
|
6428
|
+
if (
|
|
6429
|
+
window.locomotive || window.LocomotiveScroll ||
|
|
6430
|
+
__locoRoot.classList.contains('has-scroll-smooth') ||
|
|
6431
|
+
!!document.querySelector('[data-scroll-container]') ||
|
|
6432
|
+
!!document.querySelector('[data-scroll]')
|
|
6433
|
+
) {
|
|
6434
|
+
try { window.locomotive && window.locomotive.destroy && window.locomotive.destroy(); } catch (e) {}
|
|
6435
|
+
__locoRoot.classList.remove('has-scroll-smooth', 'has-scroll-init');
|
|
6436
|
+
__locoRoot.style.scrollBehavior = 'auto';
|
|
6437
|
+
var __locoUnstuck = document.createElement('style');
|
|
6438
|
+
__locoUnstuck.textContent =
|
|
6439
|
+
'html, body { overflow: auto !important; height: auto !important; }' +
|
|
6440
|
+
'[data-scroll-container] { transform: none !important; }';
|
|
6441
|
+
document.head.appendChild(__locoUnstuck);
|
|
6442
|
+
try {
|
|
6443
|
+
var __locoReveal = document.querySelectorAll('[data-scroll]');
|
|
6444
|
+
for (var __li = 0; __li < __locoReveal.length; __li++) {
|
|
6445
|
+
__locoReveal[__li].classList.add('is-inview', 'is-visible', 'is-revealed');
|
|
6446
|
+
}
|
|
6447
|
+
} catch (e) {}
|
|
6448
|
+
}
|
|
6449
|
+
`;
|
|
6450
|
+
}
|
|
6451
|
+
});
|
|
6452
|
+
|
|
6453
|
+
// src/render/design-mode-shared.js
|
|
6454
|
+
var init_design_mode_shared = __esm({
|
|
6455
|
+
"src/render/design-mode-shared.js"() {
|
|
6456
|
+
"use strict";
|
|
6457
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6458
|
+
init_tailwind_detection();
|
|
6459
|
+
init_tailwind_script();
|
|
6460
|
+
}
|
|
6461
|
+
});
|
|
6462
|
+
|
|
6463
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-ready.ts
|
|
6464
|
+
var TAILWIND_READY_PREDICATE, TAILWIND_WAIT_PREDICATE, TAILWIND_READY_TIMEOUT_MS;
|
|
6465
|
+
var init_tailwind_ready = __esm({
|
|
6466
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-ready.ts"() {
|
|
6467
|
+
"use strict";
|
|
6468
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6469
|
+
init_design_mode_shared();
|
|
6470
|
+
TAILWIND_READY_PREDICATE = `(() => {
|
|
6471
|
+
const probe = document.querySelector('[${TAILWIND_PROBE_ATTR}]');
|
|
6472
|
+
if (probe) return getComputedStyle(probe).display === 'flex';
|
|
6473
|
+
return !document.querySelector(${JSON.stringify(TAILWIND_DOCUMENT_SELECTOR)});
|
|
6474
|
+
})()`;
|
|
6475
|
+
TAILWIND_WAIT_PREDICATE = `(() => {
|
|
6476
|
+
const probe = document.querySelector('[${TAILWIND_PROBE_ATTR}]');
|
|
6477
|
+
if (probe) return getComputedStyle(probe).display === 'flex';
|
|
6478
|
+
if (!document.querySelector(${JSON.stringify(TAILWIND_DOCUMENT_SELECTOR)})) return true;
|
|
6479
|
+
const el = document.querySelector('.overflow-hidden, .overflow-x-hidden');
|
|
6480
|
+
if (el) return getComputedStyle(el).overflow !== 'visible';
|
|
6481
|
+
const flexEl = document.querySelector('.flex');
|
|
6482
|
+
if (flexEl) return getComputedStyle(flexEl).display === 'flex';
|
|
6483
|
+
return true;
|
|
6484
|
+
})()`;
|
|
6485
|
+
TAILWIND_READY_TIMEOUT_MS = 5e3;
|
|
6486
|
+
}
|
|
6487
|
+
});
|
|
6488
|
+
|
|
6489
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-gate.ts
|
|
6490
|
+
var TAILWIND_READY_GATE;
|
|
6491
|
+
var init_tailwind_gate = __esm({
|
|
6492
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-gate.ts"() {
|
|
6493
|
+
"use strict";
|
|
6494
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6495
|
+
init_design_mode_shared();
|
|
6496
|
+
init_tailwind_ready();
|
|
6497
|
+
TAILWIND_READY_GATE = `
|
|
6498
|
+
// A design script can replace <body> wholesale and take the sentinel with it. prepare() runs
|
|
6499
|
+
// on 'load', AFTER those scripts, so this is the first safe point to notice and repair it.
|
|
6500
|
+
// The <script> tag lives in <head> and survives a body wipe, which is how we know the
|
|
6501
|
+
// sentinel was ours to restore rather than one this document never had.
|
|
6502
|
+
//
|
|
6503
|
+
// Re-run on EVERY iteration, not once before the loop: a framework that mounts into <body>
|
|
6504
|
+
// asynchronously can wipe the sentinel at any point during the window, and by construction we
|
|
6505
|
+
// are only still in this loop because Tailwind has not finished compiling \u2014 i.e. on exactly
|
|
6506
|
+
// the heavy, JS-app pages most likely to re-mount. A one-shot restore would leave the
|
|
6507
|
+
// sentinel destroyed for the rest of the window, and render.ts's VERDICT predicate (which
|
|
6508
|
+
// polls concurrently, and now reads a destroyed sentinel as NOT ready) would then refuse a
|
|
6509
|
+
// capture that only needed the sentinel put back.
|
|
6510
|
+
var __twRestoreProbe = function () {
|
|
6511
|
+
try {
|
|
6512
|
+
if (!document.querySelector('[${TAILWIND_PROBE_ATTR}]') &&
|
|
6513
|
+
document.querySelector(${JSON.stringify(TAILWIND_DOCUMENT_SELECTOR)})) {
|
|
6514
|
+
document.body.insertAdjacentHTML('beforeend', ${JSON.stringify(TAILWIND_PROBE_HTML)});
|
|
6515
|
+
}
|
|
6516
|
+
} catch (e) {}
|
|
6517
|
+
};
|
|
6518
|
+
__twRestoreProbe();
|
|
6519
|
+
var __twGateDeadline = performance.now() + ${TAILWIND_READY_TIMEOUT_MS};
|
|
6520
|
+
while (!(${TAILWIND_WAIT_PREDICATE}) && performance.now() < __twGateDeadline) {
|
|
6521
|
+
await raf();
|
|
6522
|
+
__twRestoreProbe();
|
|
6523
|
+
}
|
|
6524
|
+
await raf(); await raf();
|
|
6525
|
+
`;
|
|
6526
|
+
}
|
|
6527
|
+
});
|
|
6528
|
+
|
|
6529
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-asset-watch.ts
|
|
6530
|
+
var TAILWIND_ASSET_FAILED_FLAG, TAILWIND_ASSET_WATCH, TAILWIND_ASSET_FAILED_PREDICATE;
|
|
6531
|
+
var init_tailwind_asset_watch = __esm({
|
|
6532
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/tailwind-asset-watch.ts"() {
|
|
6533
|
+
"use strict";
|
|
6534
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6535
|
+
init_design_mode_shared();
|
|
6536
|
+
TAILWIND_ASSET_FAILED_FLAG = "__kombaiTailwindAssetFailed";
|
|
6537
|
+
TAILWIND_ASSET_WATCH = `
|
|
6538
|
+
window.${TAILWIND_ASSET_FAILED_FLAG} = false;
|
|
6539
|
+
document.addEventListener('error', function (e) {
|
|
6540
|
+
var t = e && e.target;
|
|
6541
|
+
if (!t || t.tagName !== 'SCRIPT') return;
|
|
6542
|
+
if (!t.matches(${JSON.stringify(TAILWIND_RUNTIME_SELECTOR)})) return;
|
|
6543
|
+
window.${TAILWIND_ASSET_FAILED_FLAG} = true;
|
|
6544
|
+
}, true);
|
|
6545
|
+
`;
|
|
6546
|
+
TAILWIND_ASSET_FAILED_PREDICATE = `window.${TAILWIND_ASSET_FAILED_FLAG} === true`;
|
|
6547
|
+
}
|
|
6548
|
+
});
|
|
6549
|
+
|
|
6550
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/scroll-sweep.ts
|
|
6551
|
+
var SCROLL_SWEEP;
|
|
6552
|
+
var init_scroll_sweep = __esm({
|
|
6553
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/scroll-sweep.ts"() {
|
|
6554
|
+
"use strict";
|
|
6555
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6556
|
+
SCROLL_SWEEP = `
|
|
6557
|
+
var __sweepDeadline = performance.now() + 3000;
|
|
6558
|
+
|
|
6559
|
+
// Inner scrollers first. ScrollTrigger.batch({ scroller }) and
|
|
6560
|
+
// IntersectionObserver({ root }) reveals bind to a custom overflow-y panel,
|
|
6561
|
+
// not window \u2014 scrolling window alone never fires them. (When such a panel is
|
|
6562
|
+
// driven by a smooth-scroll lib we couldn't tear down, this sweep is swallowed
|
|
6563
|
+
// and the reveal-catchall pass is the backstop.)
|
|
6564
|
+
try {
|
|
6565
|
+
var __all = document.querySelectorAll('*');
|
|
6566
|
+
var __scrollers = [];
|
|
6567
|
+
for (var __i = 0; __i < __all.length; __i++) {
|
|
6568
|
+
var __el = __all[__i];
|
|
6569
|
+
var __cs = getComputedStyle(__el);
|
|
6570
|
+
var __oy = __cs.overflowY, __o = __cs.overflow;
|
|
6571
|
+
if ((__oy === 'auto' || __oy === 'scroll' || __o === 'auto' || __o === 'scroll') &&
|
|
6572
|
+
__el.scrollHeight > __el.clientHeight + 4) {
|
|
6573
|
+
__scrollers.push(__el);
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
for (var __si = 0; __si < __scrollers.length && performance.now() < __sweepDeadline; __si++) {
|
|
6577
|
+
var __sc = __scrollers[__si];
|
|
6578
|
+
var __scStep = Math.max(__sc.clientHeight / 2, 400);
|
|
6579
|
+
for (var __scY = 0; __scY < __sc.scrollHeight && performance.now() < __sweepDeadline; __scY += __scStep) {
|
|
6580
|
+
__sc.scrollTop = __scY;
|
|
6581
|
+
await raf();
|
|
6582
|
+
}
|
|
6583
|
+
__sc.scrollTop = 0;
|
|
6584
|
+
await raf();
|
|
6585
|
+
}
|
|
6586
|
+
} catch (e) {}
|
|
6587
|
+
|
|
6588
|
+
var __sweepStep = Math.max(window.innerHeight / 2, 600);
|
|
6589
|
+
for (var __sweepY = 0; __sweepY < document.body.scrollHeight && performance.now() < __sweepDeadline; __sweepY += __sweepStep) {
|
|
6590
|
+
window.scrollTo(0, __sweepY);
|
|
6591
|
+
await raf();
|
|
6592
|
+
}
|
|
6593
|
+
window.scrollTo(0, 0);
|
|
6594
|
+
await raf();
|
|
6595
|
+
`;
|
|
6596
|
+
}
|
|
6597
|
+
});
|
|
6598
|
+
|
|
6599
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/image-wait.ts
|
|
6600
|
+
var IMAGE_WAIT;
|
|
6601
|
+
var init_image_wait = __esm({
|
|
6602
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/image-wait.ts"() {
|
|
6603
|
+
"use strict";
|
|
6604
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6605
|
+
IMAGE_WAIT = `
|
|
6606
|
+
var __imgs = Array.prototype.slice.call(document.images);
|
|
6607
|
+
__imgs.forEach(function (img) {
|
|
6608
|
+
if (img.loading === 'lazy') img.loading = 'eager';
|
|
6609
|
+
});
|
|
6610
|
+
var __imgAll = Promise.all(__imgs.map(function (img) {
|
|
6611
|
+
var __loaded = img.complete
|
|
6612
|
+
? Promise.resolve()
|
|
6613
|
+
: new Promise(function (resolve) {
|
|
6614
|
+
img.addEventListener('load', resolve, { once: true });
|
|
6615
|
+
img.addEventListener('error', resolve, { once: true });
|
|
6616
|
+
});
|
|
6617
|
+
return __loaded.then(function () {
|
|
6618
|
+
try { return img.decode ? img.decode().catch(function () {}) : undefined; }
|
|
6619
|
+
catch (e) {}
|
|
6620
|
+
});
|
|
6621
|
+
}));
|
|
6622
|
+
await Promise.race([
|
|
6623
|
+
__imgAll,
|
|
6624
|
+
new Promise(function (resolve) { setTimeout(resolve, 6000); })
|
|
6625
|
+
]);
|
|
6626
|
+
`;
|
|
6627
|
+
}
|
|
6628
|
+
});
|
|
6629
|
+
|
|
6630
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/scrolltrigger.ts
|
|
6631
|
+
var SCROLLTRIGGER_FAST_FORWARD;
|
|
6632
|
+
var init_scrolltrigger = __esm({
|
|
6633
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/scrolltrigger.ts"() {
|
|
6634
|
+
"use strict";
|
|
6635
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6636
|
+
SCROLLTRIGGER_FAST_FORWARD = `
|
|
6637
|
+
if (window.ScrollTrigger) {
|
|
6638
|
+
try {
|
|
6639
|
+
var __sts = window.ScrollTrigger.getAll();
|
|
6640
|
+
var __ffTargets = [];
|
|
6641
|
+
__sts.forEach(function (t) {
|
|
6642
|
+
try {
|
|
6643
|
+
if (t.animation && t.animation.targets) {
|
|
6644
|
+
var __ts = t.animation.targets();
|
|
6645
|
+
if (__ts && __ts.length) Array.prototype.push.apply(__ffTargets, __ts);
|
|
6646
|
+
}
|
|
6647
|
+
} catch (e) {}
|
|
6648
|
+
});
|
|
6649
|
+
try {
|
|
6650
|
+
if (__ffTargets.length && window.gsap && typeof window.gsap.set === 'function') {
|
|
6651
|
+
window.gsap.set(__ffTargets, { clearProps: 'all' });
|
|
6652
|
+
}
|
|
6653
|
+
} catch (e) {}
|
|
6654
|
+
__sts.forEach(function (t) {
|
|
6655
|
+
try { if (t.animation && t.animation.invalidate) t.animation.invalidate(); } catch (e) {}
|
|
6656
|
+
});
|
|
6657
|
+
__sts.forEach(function (t) {
|
|
6658
|
+
try {
|
|
6659
|
+
if (t.animation && typeof t.animation.progress === 'function') {
|
|
6660
|
+
t.animation.progress(1, false);
|
|
6661
|
+
}
|
|
6662
|
+
} catch (e) {}
|
|
6663
|
+
try { t.kill(); } catch (e) {}
|
|
6664
|
+
});
|
|
6665
|
+
} catch (e) {}
|
|
6666
|
+
}
|
|
6667
|
+
`;
|
|
6668
|
+
}
|
|
6669
|
+
});
|
|
6670
|
+
|
|
6671
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/gsap.ts
|
|
6672
|
+
var GSAP_FAST_FORWARD;
|
|
6673
|
+
var init_gsap = __esm({
|
|
6674
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/gsap.ts"() {
|
|
6675
|
+
"use strict";
|
|
6676
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6677
|
+
GSAP_FAST_FORWARD = `
|
|
6678
|
+
if (typeof window.gsap !== 'undefined') {
|
|
6679
|
+
try { window.gsap.globalTimeline.progress(1, false); } catch (e) {}
|
|
6680
|
+
}
|
|
6681
|
+
`;
|
|
6682
|
+
}
|
|
6683
|
+
});
|
|
6684
|
+
|
|
6685
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/anime.ts
|
|
6686
|
+
var ANIME_FAST_FORWARD;
|
|
6687
|
+
var init_anime = __esm({
|
|
6688
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/anime.ts"() {
|
|
6689
|
+
"use strict";
|
|
6690
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6691
|
+
ANIME_FAST_FORWARD = `
|
|
6692
|
+
if (typeof window.anime !== 'undefined') {
|
|
6693
|
+
try {
|
|
6694
|
+
window.anime.running && window.anime.running.slice().forEach(function (a) {
|
|
6695
|
+
a.seek(a.duration);
|
|
6696
|
+
a.pause();
|
|
6697
|
+
});
|
|
6698
|
+
} catch (e) {}
|
|
6699
|
+
try {
|
|
6700
|
+
if (window.anime.engine && window.anime.engine.pause) {
|
|
6701
|
+
window.anime.engine.pause();
|
|
6702
|
+
}
|
|
6703
|
+
} catch (e) {}
|
|
6704
|
+
}
|
|
6705
|
+
`;
|
|
6706
|
+
}
|
|
6707
|
+
});
|
|
6708
|
+
|
|
6709
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/reveal-catchall.ts
|
|
6710
|
+
var REVEAL_CATCHALL;
|
|
6711
|
+
var init_reveal_catchall = __esm({
|
|
6712
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/reveal-catchall.ts"() {
|
|
6713
|
+
"use strict";
|
|
6714
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6715
|
+
REVEAL_CATCHALL = `
|
|
6716
|
+
try {
|
|
6717
|
+
if (window.gsap && typeof window.gsap.set === 'function') {
|
|
6718
|
+
var __revAll = document.querySelectorAll('*');
|
|
6719
|
+
var __revHidden = [];
|
|
6720
|
+
for (var __ri = 0; __ri < __revAll.length; __ri++) {
|
|
6721
|
+
var __re = __revAll[__ri];
|
|
6722
|
+
if (!__re._gsap) continue;
|
|
6723
|
+
var __rcs = getComputedStyle(__re);
|
|
6724
|
+
if (__rcs.visibility === 'hidden' || parseFloat(__rcs.opacity) < 0.01) {
|
|
6725
|
+
__revHidden.push(__re);
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6728
|
+
if (__revHidden.length) {
|
|
6729
|
+
log('reveal-catchall un-hiding', __revHidden.length, 'element(s)');
|
|
6730
|
+
window.gsap.set(__revHidden, { autoAlpha: 1 });
|
|
6731
|
+
window.gsap.set(__revHidden, { clearProps: 'transform,translate,rotate,scale,x,y' });
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
} catch (e) {}
|
|
6735
|
+
`;
|
|
6736
|
+
}
|
|
6737
|
+
});
|
|
6738
|
+
|
|
6739
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/waapi.ts
|
|
6740
|
+
var WAAPI_FREEZE_SNIPPET;
|
|
6741
|
+
var init_waapi = __esm({
|
|
6742
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/waapi.ts"() {
|
|
6743
|
+
"use strict";
|
|
6744
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6745
|
+
WAAPI_FREEZE_SNIPPET = `
|
|
6746
|
+
try {
|
|
6747
|
+
document.getAnimations().forEach(function (a) {
|
|
6748
|
+
try { a.finish(); } catch (e) {}
|
|
6749
|
+
try { a.pause(); } catch (e) {}
|
|
6750
|
+
});
|
|
6751
|
+
} catch (e) {}
|
|
6752
|
+
`;
|
|
6753
|
+
}
|
|
6754
|
+
});
|
|
6755
|
+
|
|
6756
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/fonts-ready.ts
|
|
6757
|
+
var FONTS_READY;
|
|
6758
|
+
var init_fonts_ready = __esm({
|
|
6759
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/fonts-ready.ts"() {
|
|
6760
|
+
"use strict";
|
|
6761
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6762
|
+
FONTS_READY = `
|
|
6763
|
+
try { await document.fonts.ready; } catch (e) {}
|
|
6764
|
+
`;
|
|
6765
|
+
}
|
|
6766
|
+
});
|
|
6767
|
+
|
|
6768
|
+
// ../design-mode/packages/frame-runtime/src/storage-stand-ins.ts
|
|
6769
|
+
function installStorageStandIns(win, doc, capBytes, DomException, defineProperty) {
|
|
6770
|
+
const bytesOf = (key, value) => (key.length + value.length) * 2;
|
|
6771
|
+
const quotaError = (key) => new DomException(`Setting the value of '${key}' exceeded the quota.`, "QuotaExceededError");
|
|
6772
|
+
const throwsOnRead = (read2) => {
|
|
6773
|
+
try {
|
|
6774
|
+
read2();
|
|
6775
|
+
return false;
|
|
6776
|
+
} catch {
|
|
6777
|
+
return true;
|
|
6778
|
+
}
|
|
6779
|
+
};
|
|
6780
|
+
const memoryStorage = () => {
|
|
6781
|
+
const items = /* @__PURE__ */ new Map();
|
|
6782
|
+
let bytes = 0;
|
|
6783
|
+
const api = {
|
|
6784
|
+
get length() {
|
|
6785
|
+
return items.size;
|
|
6786
|
+
},
|
|
6787
|
+
key(index) {
|
|
6788
|
+
return Array.from(items.keys())[Number(index)] ?? null;
|
|
6789
|
+
},
|
|
6790
|
+
getItem(key) {
|
|
6791
|
+
return items.get(String(key)) ?? null;
|
|
6792
|
+
},
|
|
6793
|
+
setItem(key, value) {
|
|
6794
|
+
const k = String(key);
|
|
6795
|
+
const v = String(value);
|
|
6796
|
+
const prev = items.get(k);
|
|
6797
|
+
const next = bytes - (prev === void 0 ? 0 : bytesOf(k, prev)) + bytesOf(k, v);
|
|
6798
|
+
if (next > capBytes) throw quotaError(k);
|
|
6799
|
+
items.set(k, v);
|
|
6800
|
+
bytes = next;
|
|
6801
|
+
},
|
|
6802
|
+
removeItem(key) {
|
|
6803
|
+
const k = String(key);
|
|
6804
|
+
const prev = items.get(k);
|
|
6805
|
+
if (prev === void 0) return;
|
|
6806
|
+
items.delete(k);
|
|
6807
|
+
bytes -= bytesOf(k, prev);
|
|
6808
|
+
},
|
|
6809
|
+
clear() {
|
|
6810
|
+
items.clear();
|
|
6811
|
+
bytes = 0;
|
|
6812
|
+
}
|
|
6813
|
+
};
|
|
6814
|
+
const own = (p) => typeof p === "symbol" || p in api;
|
|
6815
|
+
return new Proxy(api, {
|
|
6816
|
+
get(target, p, receiver) {
|
|
6817
|
+
if (own(p)) return Reflect.get(target, p, receiver);
|
|
6818
|
+
return target.getItem(p) ?? void 0;
|
|
6819
|
+
},
|
|
6820
|
+
set(target, p, value) {
|
|
6821
|
+
if (own(p)) return false;
|
|
6822
|
+
target.setItem(p, value);
|
|
6823
|
+
return true;
|
|
6824
|
+
},
|
|
6825
|
+
has(_target, p) {
|
|
6826
|
+
return own(p) || items.has(p);
|
|
6827
|
+
},
|
|
6828
|
+
deleteProperty(target, p) {
|
|
6829
|
+
if (!own(p)) target.removeItem(p);
|
|
6830
|
+
return true;
|
|
6831
|
+
},
|
|
6832
|
+
ownKeys() {
|
|
6833
|
+
return Array.from(items.keys());
|
|
6834
|
+
},
|
|
6835
|
+
getOwnPropertyDescriptor(target, p) {
|
|
6836
|
+
if (own(p)) return Reflect.getOwnPropertyDescriptor(target, p);
|
|
6837
|
+
const value = items.get(p);
|
|
6838
|
+
return value === void 0 ? void 0 : { value, writable: true, enumerable: true, configurable: true };
|
|
6839
|
+
}
|
|
6840
|
+
});
|
|
6841
|
+
};
|
|
6842
|
+
const cookieJar = () => {
|
|
6843
|
+
const jar = /* @__PURE__ */ new Map();
|
|
6844
|
+
let bytes = 0;
|
|
6845
|
+
return {
|
|
6846
|
+
get: () => Array.from(jar, ([k, v]) => k ? `${k}=${v}` : v).join("; "),
|
|
6847
|
+
set(raw) {
|
|
6848
|
+
const [pair = "", ...attrs] = String(raw).split(";");
|
|
6849
|
+
const eq = pair.indexOf("=");
|
|
6850
|
+
const name = (eq < 0 ? "" : pair.slice(0, eq)).trim();
|
|
6851
|
+
const value = (eq < 0 ? pair : pair.slice(eq + 1)).trim();
|
|
6852
|
+
const expired = attrs.some((a) => {
|
|
6853
|
+
const [k = "", v = ""] = a.split("=").map((s) => s.trim());
|
|
6854
|
+
if (/^max-age$/i.test(k)) return Number(v) <= 0;
|
|
6855
|
+
if (/^expires$/i.test(k)) return Date.parse(v) <= Date.now();
|
|
6856
|
+
return false;
|
|
6857
|
+
});
|
|
6858
|
+
const prev = jar.get(name);
|
|
6859
|
+
const freed = prev === void 0 ? 0 : bytesOf(name, prev);
|
|
6860
|
+
if (expired) {
|
|
6861
|
+
jar.delete(name);
|
|
6862
|
+
bytes -= freed;
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
const next = bytes - freed + bytesOf(name, value);
|
|
6866
|
+
if (next > capBytes) throw quotaError(name);
|
|
6867
|
+
jar.set(name, value);
|
|
6868
|
+
bytes = next;
|
|
6869
|
+
}
|
|
6870
|
+
};
|
|
6871
|
+
};
|
|
6872
|
+
for (const name of ["localStorage", "sessionStorage"]) {
|
|
6873
|
+
if (!throwsOnRead(() => win[name])) continue;
|
|
6874
|
+
defineProperty(win, name, { value: memoryStorage(), configurable: true, enumerable: true });
|
|
6875
|
+
}
|
|
6876
|
+
if (throwsOnRead(() => doc.cookie)) {
|
|
6877
|
+
const jar = cookieJar();
|
|
6878
|
+
defineProperty(doc, "cookie", { get: jar.get, set: jar.set, configurable: true, enumerable: true });
|
|
6879
|
+
}
|
|
6880
|
+
}
|
|
6881
|
+
var STORAGE_CAP_BYTES;
|
|
6882
|
+
var init_storage_stand_ins = __esm({
|
|
6883
|
+
"../design-mode/packages/frame-runtime/src/storage-stand-ins.ts"() {
|
|
6884
|
+
"use strict";
|
|
6885
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6886
|
+
STORAGE_CAP_BYTES = 5 * 1024 * 1024;
|
|
6887
|
+
}
|
|
6888
|
+
});
|
|
6889
|
+
|
|
6890
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/storage-stand-ins.ts
|
|
6891
|
+
var SCRIPT_BODY, STORAGE_STAND_INS_SCRIPT_TAG;
|
|
6892
|
+
var init_storage_stand_ins2 = __esm({
|
|
6893
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/storage-stand-ins.ts"() {
|
|
6894
|
+
"use strict";
|
|
6895
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6896
|
+
init_storage_stand_ins();
|
|
6897
|
+
SCRIPT_BODY = `(function () {
|
|
6898
|
+
try {
|
|
6899
|
+
(${installStorageStandIns.toString()})(window, document, ${STORAGE_CAP_BYTES}, DOMException, Object.defineProperty);
|
|
6900
|
+
} catch (e) {}
|
|
6901
|
+
})();`;
|
|
6902
|
+
STORAGE_STAND_INS_SCRIPT_TAG = `<script data-kombai-storage-stand-ins>${SCRIPT_BODY}</script>`;
|
|
6903
|
+
}
|
|
6904
|
+
});
|
|
6905
|
+
|
|
6906
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/video-pause.ts
|
|
6907
|
+
var VIDEO_PAUSE_SNIPPET;
|
|
6908
|
+
var init_video_pause = __esm({
|
|
6909
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/video-pause.ts"() {
|
|
6910
|
+
"use strict";
|
|
6911
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6912
|
+
VIDEO_PAUSE_SNIPPET = `
|
|
6913
|
+
document.querySelectorAll('video').forEach(function (v) {
|
|
6914
|
+
v.pause();
|
|
6915
|
+
if (!v.poster && v.readyState >= 2 && v.currentTime === 0) {
|
|
6916
|
+
v.currentTime = 0.1;
|
|
6917
|
+
}
|
|
6918
|
+
});
|
|
6919
|
+
`;
|
|
6920
|
+
}
|
|
6921
|
+
});
|
|
6922
|
+
|
|
6923
|
+
// ../design-mode/packages/server/src/plugins/screenshot/prep/index.ts
|
|
6924
|
+
var SCREENSHOT_READY_SELECTOR, SCREENSHOT_BOOTSTRAP_MARKER, SCRIPT_BODY2, SCREENSHOT_PREP_SCRIPT_TAG;
|
|
6925
|
+
var init_prep = __esm({
|
|
6926
|
+
"../design-mode/packages/server/src/plugins/screenshot/prep/index.ts"() {
|
|
6927
|
+
"use strict";
|
|
6928
|
+
init_define_KOMBAI_TELEMETRY();
|
|
6929
|
+
init_match_media_patch();
|
|
6930
|
+
init_css_freeze();
|
|
6931
|
+
init_detected();
|
|
6932
|
+
init_lenis();
|
|
6933
|
+
init_locomotive();
|
|
6934
|
+
init_tailwind_gate();
|
|
6935
|
+
init_tailwind_asset_watch();
|
|
6936
|
+
init_scroll_sweep();
|
|
6937
|
+
init_image_wait();
|
|
6938
|
+
init_scrolltrigger();
|
|
6939
|
+
init_gsap();
|
|
6940
|
+
init_anime();
|
|
6941
|
+
init_reveal_catchall();
|
|
6942
|
+
init_waapi();
|
|
6943
|
+
init_fonts_ready();
|
|
6944
|
+
init_storage_stand_ins2();
|
|
6945
|
+
init_waapi();
|
|
6946
|
+
init_video_pause();
|
|
6947
|
+
init_tailwind_ready();
|
|
6948
|
+
init_tailwind_asset_watch();
|
|
6949
|
+
SCREENSHOT_READY_SELECTOR = "html[data-screenshot-ready]";
|
|
6950
|
+
SCREENSHOT_BOOTSTRAP_MARKER = "data-kombai-screenshot-bootstrap";
|
|
6951
|
+
SCRIPT_BODY2 = `(function () {
|
|
6952
|
+
// 1. matchMedia patch \u2014 must run before any library reads prefers-reduced-motion.
|
|
6953
|
+
${MATCH_MEDIA_PATCH}
|
|
6954
|
+
|
|
6955
|
+
// 2. CSS freeze \u2014 install ASAP so even early CSS animations don't get a head start.
|
|
6956
|
+
${CSS_FREEZE}
|
|
6957
|
+
|
|
6958
|
+
// 3. Watch for a failed load of OUR tailwind runtime. Must be registered before the
|
|
6959
|
+
// <script> tag is parsed, which is why it lives here and not inside prepare().
|
|
6960
|
+
${TAILWIND_ASSET_WATCH}
|
|
6961
|
+
|
|
6962
|
+
var raf = function () { return new Promise(function (r) { requestAnimationFrame(r); }); };
|
|
6963
|
+
var log = function () {
|
|
6964
|
+
try { console.log.apply(console, ['[screenshot-bootstrap]'].concat([].slice.call(arguments))); } catch (e) {}
|
|
6965
|
+
};
|
|
6966
|
+
async function prepare() {
|
|
6967
|
+
try {
|
|
6968
|
+
// Single detection summary so the [screenshot-bootstrap] console line
|
|
6969
|
+
// tells us which animation libraries were active at start.
|
|
6970
|
+
${DETECT_SNIPPET}
|
|
6971
|
+
|
|
6972
|
+
// Smooth-scroll hijackers must die BEFORE scrollTo, or scroll-triggered
|
|
6973
|
+
// reveals never fire.
|
|
6974
|
+
${LENIS_TEARDOWN}
|
|
6975
|
+
${LOCOMOTIVE_TEARDOWN}
|
|
6976
|
+
|
|
6977
|
+
// Wait for Tailwind's async CSS pass before measuring layout \u2014 'load'
|
|
6978
|
+
// fires before it finishes, so utility classes aren't applied yet and an
|
|
6979
|
+
// unsized <svg viewBox> can inflate body.scrollHeight to ~700000px,
|
|
6980
|
+
// making the sweep below run for ~100s and blow past the ready timeout.
|
|
6981
|
+
${TAILWIND_READY_GATE}
|
|
6982
|
+
|
|
6983
|
+
// RAF scroll sweep so ScrollTrigger / IntersectionObserver register positions.
|
|
6984
|
+
${SCROLL_SWEEP}
|
|
6985
|
+
|
|
6986
|
+
// Wait for all images (lazy promoted to eager so distant lazy images load).
|
|
6987
|
+
${IMAGE_WAIT}
|
|
6988
|
+
|
|
6989
|
+
// Fast-forward JS animations to settled end state.
|
|
6990
|
+
${SCROLLTRIGGER_FAST_FORWARD}
|
|
6991
|
+
${GSAP_FAST_FORWARD}
|
|
6992
|
+
${ANIME_FAST_FORWARD}
|
|
6993
|
+
|
|
6994
|
+
// Reveal catch-all \u2014 un-hide GSAP-managed content whose scroll-bound
|
|
6995
|
+
// reveal never fired (custom-scroller ScrollTrigger.batch, smooth-scroll
|
|
6996
|
+
// libs we couldn't tear down). Runs after the fast-forwards so it only
|
|
6997
|
+
// touches elements still genuinely stuck at opacity/visibility hidden.
|
|
6998
|
+
${REVEAL_CATCHALL}
|
|
6999
|
+
|
|
7000
|
+
// WAAPI catch-all \u2014 covers Motion One, framer-motion-vanilla, any Animation object.
|
|
7001
|
+
${WAAPI_FREEZE_SNIPPET}
|
|
7002
|
+
|
|
7003
|
+
// Fonts + 2\xD7 rAF settle so the final frame is committed.
|
|
7004
|
+
${FONTS_READY}
|
|
7005
|
+
await new Promise(function (r) { requestAnimationFrame(function () { requestAnimationFrame(r); }); });
|
|
7006
|
+
} catch (e) {
|
|
7007
|
+
try { window.__screenshotReadyError = String((e && e.message) || e); } catch (_) {}
|
|
7008
|
+
log('error', e);
|
|
7009
|
+
} finally {
|
|
7010
|
+
try { document.documentElement.setAttribute('data-screenshot-ready', '1'); } catch (_) {}
|
|
7011
|
+
window.__screenshotReady = true;
|
|
7012
|
+
log('ready');
|
|
7013
|
+
}
|
|
7014
|
+
}
|
|
7015
|
+
|
|
7016
|
+
if (document.readyState === 'complete') {
|
|
7017
|
+
prepare();
|
|
7018
|
+
} else {
|
|
7019
|
+
window.addEventListener('load', prepare, { once: true });
|
|
7020
|
+
}
|
|
7021
|
+
})();`;
|
|
7022
|
+
SCREENSHOT_PREP_SCRIPT_TAG = `<script ${SCREENSHOT_BOOTSTRAP_MARKER}>${SCRIPT_BODY2}</script>`;
|
|
7023
|
+
}
|
|
7024
|
+
});
|
|
7025
|
+
|
|
5312
7026
|
// src/render/page.js
|
|
5313
|
-
function composePage({ html, overrides, images }) {
|
|
7027
|
+
function composePage({ html, overrides, images, anchorWidth }) {
|
|
5314
7028
|
const rewrite = (text) => rewriteImages(text, images);
|
|
5315
7029
|
const captured = Boolean(overrides);
|
|
5316
7030
|
const htmlAttrs = overrides?.htmlAttrs ? ` ${overrides.htmlAttrs.trimStart()}` : "";
|
|
5317
7031
|
const bodyAttrs = overrides?.bodyAttrs ? ` ${rewrite(overrides.bodyAttrs.trimStart())}` : "";
|
|
5318
7032
|
const tailwind = needsTailwindRuntime(tailwindScanInput(html, overrides ?? void 0)) ? TAILWIND_CDN_SCRIPT_TAG : "";
|
|
5319
|
-
|
|
7033
|
+
const head = captured ? rewrite(overrides?.head ?? "") : tailwind;
|
|
7034
|
+
const loadsTailwind = hasTailwindRuntime(head + html);
|
|
7035
|
+
const page = `<!DOCTYPE html>
|
|
5320
7036
|
<html${htmlAttrs}>
|
|
5321
7037
|
<head>
|
|
5322
7038
|
<meta charset="utf-8">
|
|
5323
|
-
${
|
|
7039
|
+
${loadsTailwind ? '<meta name="kombai-tailwind-runtime">' : ""}
|
|
7040
|
+
${STORAGE_STAND_INS_SCRIPT_TAG}
|
|
7041
|
+
${SCREENSHOT_PREP_SCRIPT_TAG}
|
|
7042
|
+
<style>${SCREENSHOT_CSS}</style>
|
|
7043
|
+
${head}
|
|
5324
7044
|
<style>${captured ? "" : FRAGMENT_RESET_CSS}
|
|
5325
7045
|
${ROOT_CSS}</style>
|
|
5326
7046
|
</head>
|
|
5327
7047
|
<body${bodyAttrs}>
|
|
5328
|
-
<div id="root">${rewrite(html)}</div
|
|
7048
|
+
<div id="root">${rewrite(html)}</div>${loadsTailwind ? TAILWIND_PROBE_HTML : ""}
|
|
5329
7049
|
</body>
|
|
5330
7050
|
</html>`;
|
|
7051
|
+
return anchorWidth ? anchorViewportUnits(page, anchorWidth) : page;
|
|
7052
|
+
}
|
|
7053
|
+
function anchorViewportUnits(page, width) {
|
|
7054
|
+
const converted = convertViewportUnits(page, width, INTRINSIC_VIEWPORT_HEIGHT);
|
|
7055
|
+
const sheet = `<style data-screenshot-vh-anchor>${buildViewportUnitOverrideCss(width, INTRINSIC_VIEWPORT_HEIGHT)}</style>`;
|
|
7056
|
+
const headEnd = converted.indexOf("</head>");
|
|
7057
|
+
return headEnd === -1 ? sheet + converted : converted.slice(0, headEnd) + sheet + converted.slice(headEnd);
|
|
5331
7058
|
}
|
|
5332
7059
|
function rewriteImages(text, images) {
|
|
5333
7060
|
let out = text;
|
|
@@ -5336,14 +7063,20 @@ function rewriteImages(text, images) {
|
|
|
5336
7063
|
}
|
|
5337
7064
|
return out;
|
|
5338
7065
|
}
|
|
5339
|
-
var FRAGMENT_RESET_CSS, ROOT_CSS;
|
|
7066
|
+
var FRAGMENT_RESET_CSS, ROOT_CSS, SCREENSHOT_CSS;
|
|
5340
7067
|
var init_page = __esm({
|
|
5341
7068
|
"src/render/page.js"() {
|
|
5342
7069
|
"use strict";
|
|
5343
7070
|
init_define_KOMBAI_TELEMETRY();
|
|
5344
7071
|
init_tailwind_detection();
|
|
7072
|
+
init_tailwind_script();
|
|
7073
|
+
init_convert_viewport_units();
|
|
7074
|
+
init_screenshot_height_metadata();
|
|
7075
|
+
init_prep();
|
|
5345
7076
|
FRAGMENT_RESET_CSS = "html, body { margin: 0; padding: 0; }";
|
|
5346
7077
|
ROOT_CSS = "#root { display: contents; }";
|
|
7078
|
+
SCREENSHOT_CSS = `* { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
|
|
7079
|
+
svg:not([height]) { max-height: 20000px !important; }`;
|
|
5347
7080
|
}
|
|
5348
7081
|
});
|
|
5349
7082
|
|
|
@@ -5674,7 +7407,14 @@ var init_proxy = __esm({
|
|
|
5674
7407
|
});
|
|
5675
7408
|
|
|
5676
7409
|
// src/render/render.js
|
|
5677
|
-
async function openRender(ctx, {
|
|
7410
|
+
async function openRender(ctx, {
|
|
7411
|
+
browserPath,
|
|
7412
|
+
page,
|
|
7413
|
+
deadline,
|
|
7414
|
+
width = DEFAULT_RENDER_WIDTH,
|
|
7415
|
+
viewportHeight = INTRINSIC_VIEWPORT_HEIGHT,
|
|
7416
|
+
readyMs = READY_MS
|
|
7417
|
+
}) {
|
|
5678
7418
|
const started = Date.now();
|
|
5679
7419
|
const limit = deadline.within(RENDER_MS);
|
|
5680
7420
|
const proxy = await startProxy();
|
|
@@ -5727,6 +7467,7 @@ async function openRender(ctx, { browserPath, page, deadline, width = 1440, view
|
|
|
5727
7467
|
const readyAt = Date.now() + readyMs;
|
|
5728
7468
|
await s("Page.navigate", { url: proxy.serve(page) });
|
|
5729
7469
|
const ready = await waitForReady(s, readyAt, SIGNALS.test(page));
|
|
7470
|
+
await s("Runtime.evaluate", { expression: SETTLE, awaitPromise: true });
|
|
5730
7471
|
await s("Runtime.evaluate", {
|
|
5731
7472
|
expression: `(() => { const st = document.createElement('style');
|
|
5732
7473
|
st.textContent = '*,*::before,*::after{animation-play-state:paused!important;transition:none!important;caret-color:transparent!important}';
|
|
@@ -5809,24 +7550,27 @@ async function waitForReady(send, readyAt, willSignal) {
|
|
|
5809
7550
|
const read2 = await by(reading, readyAt);
|
|
5810
7551
|
if (read2 === LATE) return "timeout";
|
|
5811
7552
|
const state = (
|
|
5812
|
-
/** @type {{ signalled?: boolean, declared?: boolean, settled?: boolean }} */
|
|
7553
|
+
/** @type {{ signalled?: boolean, declared?: boolean, settled?: boolean, prepared?: boolean }} */
|
|
5813
7554
|
read2.result?.value ?? {}
|
|
5814
7555
|
);
|
|
5815
|
-
if (state.signalled) return "kombai_ready";
|
|
5816
|
-
if (state.settled && !state.declared && !willSignal) return "fonts_and_images";
|
|
7556
|
+
if (state.signalled && state.prepared) return "kombai_ready";
|
|
7557
|
+
if (state.settled && state.prepared && !state.declared && !willSignal) return "fonts_and_images";
|
|
5817
7558
|
const left = readyAt - Date.now();
|
|
5818
7559
|
if (left <= 0) return "timeout";
|
|
5819
7560
|
await new Promise((resolve) => setTimeout(resolve, Math.min(READY_POLL_MS, left)));
|
|
5820
7561
|
}
|
|
5821
7562
|
}
|
|
5822
|
-
var RENDER_MS, READY_MS, READY_POLL_MS, MAX_HEIGHT, JPEG_MAX_BYTES, PNG_MAX_BYTES, JPEG_QUALITIES, RenderFailure, READY_WATCH, SIGNALS, READY_STATE, LATE;
|
|
7563
|
+
var DEFAULT_RENDER_WIDTH, RENDER_MS, READY_MS, READY_POLL_MS, MAX_HEIGHT, JPEG_MAX_BYTES, PNG_MAX_BYTES, JPEG_QUALITIES, RenderFailure, READY_WATCH, SIGNALS, READY_STATE, SETTLE, LATE;
|
|
5823
7564
|
var init_render = __esm({
|
|
5824
7565
|
"src/render/render.js"() {
|
|
5825
7566
|
"use strict";
|
|
5826
7567
|
init_define_KOMBAI_TELEMETRY();
|
|
7568
|
+
init_screenshot_height_metadata();
|
|
7569
|
+
init_prep();
|
|
5827
7570
|
init_contract();
|
|
5828
7571
|
init_cdp();
|
|
5829
7572
|
init_proxy();
|
|
7573
|
+
DEFAULT_RENDER_WIDTH = 1440;
|
|
5830
7574
|
RENDER_MS = 3e4;
|
|
5831
7575
|
READY_MS = 2e4;
|
|
5832
7576
|
READY_POLL_MS = 100;
|
|
@@ -5858,11 +7602,20 @@ var init_render = __esm({
|
|
|
5858
7602
|
SIGNALS = /KOMBAI_READY|kombai:ready/;
|
|
5859
7603
|
READY_STATE = `(() => {
|
|
5860
7604
|
const state = window.__kombaiRender;
|
|
7605
|
+
const prepared = document.readyState !== 'complete' || Boolean(document.querySelector(${JSON.stringify(SCREENSHOT_READY_SELECTOR)}));
|
|
5861
7606
|
return {
|
|
5862
7607
|
signalled: document.readyState !== 'loading' && (window.KOMBAI_READY === true || Boolean(state && state.event)),
|
|
5863
7608
|
declared: 'KOMBAI_READY' in window,
|
|
5864
7609
|
settled: Boolean(state && state.settled),
|
|
7610
|
+
prepared,
|
|
5865
7611
|
};
|
|
7612
|
+
})()`;
|
|
7613
|
+
SETTLE = `(async () => {
|
|
7614
|
+
const frame = () => new Promise((resolve) => requestAnimationFrame(resolve));
|
|
7615
|
+
${VIDEO_PAUSE_SNIPPET}
|
|
7616
|
+
await frame(); await frame();
|
|
7617
|
+
${WAAPI_FREEZE_SNIPPET}
|
|
7618
|
+
await frame();
|
|
5866
7619
|
})()`;
|
|
5867
7620
|
LATE = Symbol("late");
|
|
5868
7621
|
}
|
|
@@ -6004,7 +7757,12 @@ async function renderOne(ctx, { api, canvasId, screenshotsDir, target, deadline,
|
|
|
6004
7757
|
try {
|
|
6005
7758
|
render = await openRender(ctx, {
|
|
6006
7759
|
browserPath,
|
|
6007
|
-
page: composePage({
|
|
7760
|
+
page: composePage({
|
|
7761
|
+
html: target.html,
|
|
7762
|
+
overrides: target.overrides,
|
|
7763
|
+
images: target.images,
|
|
7764
|
+
anchorWidth: target.height === void 0 ? target.width ?? DEFAULT_RENDER_WIDTH : void 0
|
|
7765
|
+
}),
|
|
6008
7766
|
deadline,
|
|
6009
7767
|
width: target.width,
|
|
6010
7768
|
viewportHeight: target.height
|
|
@@ -6109,10 +7867,12 @@ function targetOf(nodeId, version2, files, images, node) {
|
|
|
6109
7867
|
html: files.html ? text.decode(files.html) : "",
|
|
6110
7868
|
overrides,
|
|
6111
7869
|
images,
|
|
6112
|
-
// Like the canvas's own capture: a node renders at its width, a mobile one at 390 px. A
|
|
6113
|
-
//
|
|
7870
|
+
// Like the canvas's own capture: a node renders at its width, a mobile one at 390 px. A node the canvas shows at
|
|
7871
|
+
// a height of its own renders in a window that tall: a text node, and a design with a set height, which the
|
|
7872
|
+
// canvas shows as a window onto its page (any rect.h above 0). A content-height design loads in the canvas's
|
|
7873
|
+
// measuring window, INTRINSIC_VIEWPORT_HEIGHT, with its viewport units pinned (renderOne, page.js).
|
|
6114
7874
|
width: sizeOf(node?.rect?.w, MIN_WIDTH),
|
|
6115
|
-
height: node?.type === "text" ?
|
|
7875
|
+
height: sizeOf(node?.rect?.h, node?.type === "text" ? MIN_TEXT_HEIGHT : 1)
|
|
6116
7876
|
};
|
|
6117
7877
|
}
|
|
6118
7878
|
function sizeOf(value, min) {
|
|
@@ -6148,6 +7908,18 @@ async function rememberGuestCanvas(ctx, cc, canvasId) {
|
|
|
6148
7908
|
if (cc.session.kind !== "guest") return;
|
|
6149
7909
|
await writeGuest(ctx.home, cc.session.env, { canvasId }, { ifGuest: cc.session.guest.guest });
|
|
6150
7910
|
}
|
|
7911
|
+
async function deleteStoredCanvas(api, canvasId) {
|
|
7912
|
+
for (let attempt = 0; ; attempt++) {
|
|
7913
|
+
try {
|
|
7914
|
+
await api.call({ method: "DELETE", path: `/design/canvases/${canvasId}`, retry: "once" });
|
|
7915
|
+
return;
|
|
7916
|
+
} catch (error2) {
|
|
7917
|
+
if (error2 instanceof CliError && error2.status === 410) return;
|
|
7918
|
+
if (error2 instanceof LostAnswer && attempt < 3) continue;
|
|
7919
|
+
throw error2;
|
|
7920
|
+
}
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
6151
7923
|
function named(nodeIds) {
|
|
6152
7924
|
if (nodeIds.length === 1) return nodeIds[0];
|
|
6153
7925
|
return nodeIds.length <= 5 ? `${nodeIds.length} nodes (${nodeIds.join(", ")})` : `${nodeIds.length} nodes`;
|
|
@@ -6163,15 +7935,19 @@ function layoutPatch(entry, layout, ifVersion, settled = []) {
|
|
|
6163
7935
|
} else if (field === "rect" && settledRect === "all") {
|
|
6164
7936
|
patch.rect = value;
|
|
6165
7937
|
} else if (field === "rect" && isRecord(value) && isRecord(entry.layout.rect)) {
|
|
6166
|
-
const
|
|
7938
|
+
const was2 = entry.layout.rect;
|
|
6167
7939
|
const sides = Object.entries(value).filter(
|
|
6168
|
-
([side, v]) => v !== void 0 && (settledRect.includes(side) || !sameValue(
|
|
7940
|
+
([side, v]) => v !== void 0 && (settledRect.includes(side) || !sameValue(was2[side], v))
|
|
6169
7941
|
);
|
|
6170
7942
|
patch.rect = sides.length ? Object.fromEntries(sides) : value;
|
|
6171
7943
|
} else {
|
|
6172
7944
|
patch[field] = value;
|
|
6173
7945
|
}
|
|
6174
7946
|
}
|
|
7947
|
+
const rect = patch.rect;
|
|
7948
|
+
const was = entry.layout.rect;
|
|
7949
|
+
if (entry.type === "variant" && !fields.has("viewportAuto") && layout.viewportAuto !== false && isRecord(rect) && rect.h !== void 0 && !(isRecord(was) && sameValue(was.h, rect.h)))
|
|
7950
|
+
patch.viewportAuto = false;
|
|
6175
7951
|
return Object.keys(patch).length > 1 ? patch : null;
|
|
6176
7952
|
}
|
|
6177
7953
|
function isRecord(value) {
|
|
@@ -6202,6 +7978,7 @@ async function recordLanded(ctx, paths, base, working, patches, results, seq, sa
|
|
|
6202
7978
|
if (value === null) delete layout[field];
|
|
6203
7979
|
else if (pushedOver && field === "rect" && isRecord(value) && isRecord(layout.rect))
|
|
6204
7980
|
layout.rect = { ...layout.rect, ...value };
|
|
7981
|
+
else if (field === "viewportAuto") layout[field] = value;
|
|
6205
7982
|
else layout[field] = now[field];
|
|
6206
7983
|
}
|
|
6207
7984
|
const filesBehind = saved[nodeId]?.fields.includes("files");
|
|
@@ -6623,16 +8400,7 @@ var init_canvas = __esm({
|
|
|
6623
8400
|
/** @type {{ canvasId: string, paths: import('../lib/canvasdir.js').CanvasPaths }} */
|
|
6624
8401
|
cc
|
|
6625
8402
|
);
|
|
6626
|
-
|
|
6627
|
-
try {
|
|
6628
|
-
await cc.session.api.call({ method: "DELETE", path: `/design/canvases/${canvasId}`, retry: "once" });
|
|
6629
|
-
break;
|
|
6630
|
-
} catch (error2) {
|
|
6631
|
-
if (error2 instanceof CliError && error2.status === 410) break;
|
|
6632
|
-
if (error2 instanceof LostAnswer && attempt < 3) continue;
|
|
6633
|
-
throw error2;
|
|
6634
|
-
}
|
|
6635
|
-
}
|
|
8403
|
+
await deleteStoredCanvas(cc.session.api, canvasId);
|
|
6636
8404
|
return { status: "deleted", kept: await forgetCanvas(cc, canvasId, paths) };
|
|
6637
8405
|
}
|
|
6638
8406
|
};
|
|
@@ -8284,8 +10052,8 @@ var init_parseUtil = __esm({
|
|
|
8284
10052
|
init_errors();
|
|
8285
10053
|
init_en();
|
|
8286
10054
|
makeIssue = (params) => {
|
|
8287
|
-
const { data, path:
|
|
8288
|
-
const fullPath = [...
|
|
10055
|
+
const { data, path: path25, errorMaps, issueData } = params;
|
|
10056
|
+
const fullPath = [...path25, ...issueData.path || []];
|
|
8289
10057
|
const fullIssue = {
|
|
8290
10058
|
...issueData,
|
|
8291
10059
|
path: fullPath
|
|
@@ -8568,11 +10336,11 @@ var init_types = __esm({
|
|
|
8568
10336
|
init_parseUtil();
|
|
8569
10337
|
init_util();
|
|
8570
10338
|
ParseInputLazyPath = class {
|
|
8571
|
-
constructor(parent, value,
|
|
10339
|
+
constructor(parent, value, path25, key) {
|
|
8572
10340
|
this._cachedPath = [];
|
|
8573
10341
|
this.parent = parent;
|
|
8574
10342
|
this.data = value;
|
|
8575
|
-
this._path =
|
|
10343
|
+
this._path = path25;
|
|
8576
10344
|
this._key = key;
|
|
8577
10345
|
}
|
|
8578
10346
|
get path() {
|
|
@@ -8688,8 +10456,8 @@ var init_types = __esm({
|
|
|
8688
10456
|
} : {
|
|
8689
10457
|
issues: ctx.common.issues
|
|
8690
10458
|
};
|
|
8691
|
-
} catch (
|
|
8692
|
-
if (
|
|
10459
|
+
} catch (err2) {
|
|
10460
|
+
if (err2?.message?.toLowerCase()?.includes("encountered")) {
|
|
8693
10461
|
this["~standard"].async = true;
|
|
8694
10462
|
}
|
|
8695
10463
|
ctx.common = {
|
|
@@ -11861,10 +13629,10 @@ function $constructor(name, initializer3, params) {
|
|
|
11861
13629
|
}
|
|
11862
13630
|
Object.defineProperty(Definition, "name", { value: name });
|
|
11863
13631
|
function _(def) {
|
|
11864
|
-
var
|
|
13632
|
+
var _a3;
|
|
11865
13633
|
const inst = params?.Parent ? new Definition() : this;
|
|
11866
13634
|
init(inst, def);
|
|
11867
|
-
(
|
|
13635
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
11868
13636
|
for (const fn of inst._zod.deferred) {
|
|
11869
13637
|
fn();
|
|
11870
13638
|
}
|
|
@@ -12081,10 +13849,10 @@ function mergeDefs(...defs) {
|
|
|
12081
13849
|
function cloneDef(schema) {
|
|
12082
13850
|
return mergeDefs(schema._zod.def);
|
|
12083
13851
|
}
|
|
12084
|
-
function getElementAtPath(obj,
|
|
12085
|
-
if (!
|
|
13852
|
+
function getElementAtPath(obj, path25) {
|
|
13853
|
+
if (!path25)
|
|
12086
13854
|
return obj;
|
|
12087
|
-
return
|
|
13855
|
+
return path25.reduce((acc, key) => acc?.[key], obj);
|
|
12088
13856
|
}
|
|
12089
13857
|
function promiseAllObject(promisesObj) {
|
|
12090
13858
|
const keys = Object.keys(promisesObj);
|
|
@@ -12396,11 +14164,11 @@ function aborted(x, startIndex = 0) {
|
|
|
12396
14164
|
}
|
|
12397
14165
|
return false;
|
|
12398
14166
|
}
|
|
12399
|
-
function prefixIssues(
|
|
14167
|
+
function prefixIssues(path25, issues) {
|
|
12400
14168
|
return issues.map((iss) => {
|
|
12401
|
-
var
|
|
12402
|
-
(
|
|
12403
|
-
iss.path.unshift(
|
|
14169
|
+
var _a3;
|
|
14170
|
+
(_a3 = iss).path ?? (_a3.path = []);
|
|
14171
|
+
iss.path.unshift(path25);
|
|
12404
14172
|
return iss;
|
|
12405
14173
|
});
|
|
12406
14174
|
}
|
|
@@ -12935,10 +14703,10 @@ var init_checks = __esm({
|
|
|
12935
14703
|
init_regexes();
|
|
12936
14704
|
init_util2();
|
|
12937
14705
|
$ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
12938
|
-
var
|
|
14706
|
+
var _a3;
|
|
12939
14707
|
inst._zod ?? (inst._zod = {});
|
|
12940
14708
|
inst._zod.def = def;
|
|
12941
|
-
(
|
|
14709
|
+
(_a3 = inst._zod).onattach ?? (_a3.onattach = []);
|
|
12942
14710
|
});
|
|
12943
14711
|
numericOriginMap = {
|
|
12944
14712
|
number: "number",
|
|
@@ -13004,8 +14772,8 @@ var init_checks = __esm({
|
|
|
13004
14772
|
$ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
13005
14773
|
$ZodCheck.init(inst, def);
|
|
13006
14774
|
inst._zod.onattach.push((inst2) => {
|
|
13007
|
-
var
|
|
13008
|
-
(
|
|
14775
|
+
var _a3;
|
|
14776
|
+
(_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
|
|
13009
14777
|
});
|
|
13010
14778
|
inst._zod.check = (payload) => {
|
|
13011
14779
|
if (typeof payload.value !== typeof def.value)
|
|
@@ -13138,9 +14906,9 @@ var init_checks = __esm({
|
|
|
13138
14906
|
};
|
|
13139
14907
|
});
|
|
13140
14908
|
$ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, def) => {
|
|
13141
|
-
var
|
|
14909
|
+
var _a3;
|
|
13142
14910
|
$ZodCheck.init(inst, def);
|
|
13143
|
-
(
|
|
14911
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13144
14912
|
const val = payload.value;
|
|
13145
14913
|
return !nullish(val) && val.size !== void 0;
|
|
13146
14914
|
});
|
|
@@ -13166,9 +14934,9 @@ var init_checks = __esm({
|
|
|
13166
14934
|
};
|
|
13167
14935
|
});
|
|
13168
14936
|
$ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, def) => {
|
|
13169
|
-
var
|
|
14937
|
+
var _a3;
|
|
13170
14938
|
$ZodCheck.init(inst, def);
|
|
13171
|
-
(
|
|
14939
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13172
14940
|
const val = payload.value;
|
|
13173
14941
|
return !nullish(val) && val.size !== void 0;
|
|
13174
14942
|
});
|
|
@@ -13194,9 +14962,9 @@ var init_checks = __esm({
|
|
|
13194
14962
|
};
|
|
13195
14963
|
});
|
|
13196
14964
|
$ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (inst, def) => {
|
|
13197
|
-
var
|
|
14965
|
+
var _a3;
|
|
13198
14966
|
$ZodCheck.init(inst, def);
|
|
13199
|
-
(
|
|
14967
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13200
14968
|
const val = payload.value;
|
|
13201
14969
|
return !nullish(val) && val.size !== void 0;
|
|
13202
14970
|
});
|
|
@@ -13224,9 +14992,9 @@ var init_checks = __esm({
|
|
|
13224
14992
|
};
|
|
13225
14993
|
});
|
|
13226
14994
|
$ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
13227
|
-
var
|
|
14995
|
+
var _a3;
|
|
13228
14996
|
$ZodCheck.init(inst, def);
|
|
13229
|
-
(
|
|
14997
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13230
14998
|
const val = payload.value;
|
|
13231
14999
|
return !nullish(val) && val.length !== void 0;
|
|
13232
15000
|
});
|
|
@@ -13253,9 +15021,9 @@ var init_checks = __esm({
|
|
|
13253
15021
|
};
|
|
13254
15022
|
});
|
|
13255
15023
|
$ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
13256
|
-
var
|
|
15024
|
+
var _a3;
|
|
13257
15025
|
$ZodCheck.init(inst, def);
|
|
13258
|
-
(
|
|
15026
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13259
15027
|
const val = payload.value;
|
|
13260
15028
|
return !nullish(val) && val.length !== void 0;
|
|
13261
15029
|
});
|
|
@@ -13282,9 +15050,9 @@ var init_checks = __esm({
|
|
|
13282
15050
|
};
|
|
13283
15051
|
});
|
|
13284
15052
|
$ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
13285
|
-
var
|
|
15053
|
+
var _a3;
|
|
13286
15054
|
$ZodCheck.init(inst, def);
|
|
13287
|
-
(
|
|
15055
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
13288
15056
|
const val = payload.value;
|
|
13289
15057
|
return !nullish(val) && val.length !== void 0;
|
|
13290
15058
|
});
|
|
@@ -13313,7 +15081,7 @@ var init_checks = __esm({
|
|
|
13313
15081
|
};
|
|
13314
15082
|
});
|
|
13315
15083
|
$ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
13316
|
-
var
|
|
15084
|
+
var _a3, _b2;
|
|
13317
15085
|
$ZodCheck.init(inst, def);
|
|
13318
15086
|
inst._zod.onattach.push((inst2) => {
|
|
13319
15087
|
const bag = inst2._zod.bag;
|
|
@@ -13324,7 +15092,7 @@ var init_checks = __esm({
|
|
|
13324
15092
|
}
|
|
13325
15093
|
});
|
|
13326
15094
|
if (def.pattern)
|
|
13327
|
-
(
|
|
15095
|
+
(_a3 = inst._zod).check ?? (_a3.check = (payload) => {
|
|
13328
15096
|
def.pattern.lastIndex = 0;
|
|
13329
15097
|
if (def.pattern.test(payload.value))
|
|
13330
15098
|
return;
|
|
@@ -13339,7 +15107,7 @@ var init_checks = __esm({
|
|
|
13339
15107
|
});
|
|
13340
15108
|
});
|
|
13341
15109
|
else
|
|
13342
|
-
(
|
|
15110
|
+
(_b2 = inst._zod).check ?? (_b2.check = () => {
|
|
13343
15111
|
});
|
|
13344
15112
|
});
|
|
13345
15113
|
$ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
@@ -13904,7 +15672,7 @@ var init_schemas = __esm({
|
|
|
13904
15672
|
init_versions();
|
|
13905
15673
|
init_util2();
|
|
13906
15674
|
$ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
13907
|
-
var
|
|
15675
|
+
var _a3;
|
|
13908
15676
|
inst ?? (inst = {});
|
|
13909
15677
|
inst._zod.def = def;
|
|
13910
15678
|
inst._zod.bag = inst._zod.bag || {};
|
|
@@ -13919,7 +15687,7 @@ var init_schemas = __esm({
|
|
|
13919
15687
|
}
|
|
13920
15688
|
}
|
|
13921
15689
|
if (checks.length === 0) {
|
|
13922
|
-
(
|
|
15690
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
13923
15691
|
inst._zod.deferred?.push(() => {
|
|
13924
15692
|
inst._zod.run = inst._zod.parse;
|
|
13925
15693
|
});
|
|
@@ -16078,7 +17846,7 @@ var init_locales = __esm({
|
|
|
16078
17846
|
function registry() {
|
|
16079
17847
|
return new $ZodRegistry();
|
|
16080
17848
|
}
|
|
16081
|
-
var
|
|
17849
|
+
var _a2, $output, $input, $ZodRegistry, globalRegistry;
|
|
16082
17850
|
var init_registries = __esm({
|
|
16083
17851
|
"../../node_modules/zod/v4/core/registries.js"() {
|
|
16084
17852
|
init_define_KOMBAI_TELEMETRY();
|
|
@@ -16124,7 +17892,7 @@ var init_registries = __esm({
|
|
|
16124
17892
|
return this._map.has(schema);
|
|
16125
17893
|
}
|
|
16126
17894
|
};
|
|
16127
|
-
(
|
|
17895
|
+
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
16128
17896
|
globalRegistry = globalThis.__zod_globalRegistry;
|
|
16129
17897
|
}
|
|
16130
17898
|
});
|
|
@@ -16965,7 +18733,7 @@ function initializeContext(params) {
|
|
|
16965
18733
|
};
|
|
16966
18734
|
}
|
|
16967
18735
|
function process3(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
16968
|
-
var
|
|
18736
|
+
var _a3;
|
|
16969
18737
|
const def = schema._zod.def;
|
|
16970
18738
|
const seen = ctx.seen.get(schema);
|
|
16971
18739
|
if (seen) {
|
|
@@ -17013,7 +18781,7 @@ function process3(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
17013
18781
|
delete result.schema.default;
|
|
17014
18782
|
}
|
|
17015
18783
|
if (ctx.io === "input" && result.schema._prefault)
|
|
17016
|
-
(
|
|
18784
|
+
(_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
|
|
17017
18785
|
delete result.schema._prefault;
|
|
17018
18786
|
const _result = ctx.seen.get(schema);
|
|
17019
18787
|
return _result.schema;
|
|
@@ -21331,7 +23099,7 @@ var init_zodToJsonSchema = __esm({
|
|
|
21331
23099
|
});
|
|
21332
23100
|
|
|
21333
23101
|
// ../../node_modules/zod-to-json-schema/dist/esm/index.js
|
|
21334
|
-
var
|
|
23102
|
+
var init_esm2 = __esm({
|
|
21335
23103
|
"../../node_modules/zod-to-json-schema/dist/esm/index.js"() {
|
|
21336
23104
|
init_define_KOMBAI_TELEMETRY();
|
|
21337
23105
|
init_Options();
|
|
@@ -21401,7 +23169,7 @@ var init_zod_json_schema_compat = __esm({
|
|
|
21401
23169
|
init_define_KOMBAI_TELEMETRY();
|
|
21402
23170
|
init_v4_mini();
|
|
21403
23171
|
init_zod_compat();
|
|
21404
|
-
|
|
23172
|
+
init_esm2();
|
|
21405
23173
|
}
|
|
21406
23174
|
});
|
|
21407
23175
|
|
|
@@ -22395,12 +24163,12 @@ var require_code = __commonJS({
|
|
|
22395
24163
|
return item === "" || item === '""';
|
|
22396
24164
|
}
|
|
22397
24165
|
get str() {
|
|
22398
|
-
var
|
|
22399
|
-
return (
|
|
24166
|
+
var _a3;
|
|
24167
|
+
return (_a3 = this._str) !== null && _a3 !== void 0 ? _a3 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
|
|
22400
24168
|
}
|
|
22401
24169
|
get names() {
|
|
22402
|
-
var
|
|
22403
|
-
return (
|
|
24170
|
+
var _a3;
|
|
24171
|
+
return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names, c) => {
|
|
22404
24172
|
if (c instanceof Name)
|
|
22405
24173
|
names[c.str] = (names[c.str] || 0) + 1;
|
|
22406
24174
|
return names;
|
|
@@ -22547,8 +24315,8 @@ var require_scope = __commonJS({
|
|
|
22547
24315
|
return `${prefix}${ng.index++}`;
|
|
22548
24316
|
}
|
|
22549
24317
|
_nameGroup(prefix) {
|
|
22550
|
-
var
|
|
22551
|
-
if (((
|
|
24318
|
+
var _a3, _b2;
|
|
24319
|
+
if (((_b2 = (_a3 = this._parent) === null || _a3 === void 0 ? void 0 : _a3._prefixes) === null || _b2 === void 0 ? void 0 : _b2.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
|
|
22552
24320
|
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
22553
24321
|
}
|
|
22554
24322
|
return this._names[prefix] = { prefix, index: 0 };
|
|
@@ -22581,12 +24349,12 @@ var require_scope = __commonJS({
|
|
|
22581
24349
|
return new ValueScopeName(prefix, this._newName(prefix));
|
|
22582
24350
|
}
|
|
22583
24351
|
value(nameOrPrefix, value) {
|
|
22584
|
-
var
|
|
24352
|
+
var _a3;
|
|
22585
24353
|
if (value.ref === void 0)
|
|
22586
24354
|
throw new Error("CodeGen: ref must be passed in value");
|
|
22587
24355
|
const name = this.toName(nameOrPrefix);
|
|
22588
24356
|
const { prefix } = name;
|
|
22589
|
-
const valueKey = (
|
|
24357
|
+
const valueKey = (_a3 = value.key) !== null && _a3 !== void 0 ? _a3 : value.ref;
|
|
22590
24358
|
let vs = this._values[prefix];
|
|
22591
24359
|
if (vs) {
|
|
22592
24360
|
const _name = vs.get(valueKey);
|
|
@@ -22905,8 +24673,8 @@ var require_codegen = __commonJS({
|
|
|
22905
24673
|
return this;
|
|
22906
24674
|
}
|
|
22907
24675
|
optimizeNames(names, constants2) {
|
|
22908
|
-
var
|
|
22909
|
-
this.else = (
|
|
24676
|
+
var _a3;
|
|
24677
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
22910
24678
|
if (!(super.optimizeNames(names, constants2) || this.else))
|
|
22911
24679
|
return;
|
|
22912
24680
|
this.condition = optimizeExpr(this.condition, names, constants2);
|
|
@@ -23010,17 +24778,17 @@ var require_codegen = __commonJS({
|
|
|
23010
24778
|
return code2;
|
|
23011
24779
|
}
|
|
23012
24780
|
optimizeNodes() {
|
|
23013
|
-
var
|
|
24781
|
+
var _a3, _b2;
|
|
23014
24782
|
super.optimizeNodes();
|
|
23015
|
-
(
|
|
23016
|
-
(
|
|
24783
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNodes();
|
|
24784
|
+
(_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNodes();
|
|
23017
24785
|
return this;
|
|
23018
24786
|
}
|
|
23019
24787
|
optimizeNames(names, constants2) {
|
|
23020
|
-
var
|
|
24788
|
+
var _a3, _b2;
|
|
23021
24789
|
super.optimizeNames(names, constants2);
|
|
23022
|
-
(
|
|
23023
|
-
(
|
|
24790
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants2);
|
|
24791
|
+
(_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names, constants2);
|
|
23024
24792
|
return this;
|
|
23025
24793
|
}
|
|
23026
24794
|
get names() {
|
|
@@ -23626,21 +25394,21 @@ var require_errors = __commonJS({
|
|
|
23626
25394
|
function extendErrors({ gen, keyword, schemaValue, data, errsCount, it }) {
|
|
23627
25395
|
if (errsCount === void 0)
|
|
23628
25396
|
throw new Error("ajv implementation error");
|
|
23629
|
-
const
|
|
25397
|
+
const err2 = gen.name("err");
|
|
23630
25398
|
gen.forRange("i", errsCount, names_1.default.errors, (i) => {
|
|
23631
|
-
gen.const(
|
|
23632
|
-
gen.if((0, codegen_1._)`${
|
|
23633
|
-
gen.assign((0, codegen_1._)`${
|
|
25399
|
+
gen.const(err2, (0, codegen_1._)`${names_1.default.vErrors}[${i}]`);
|
|
25400
|
+
gen.if((0, codegen_1._)`${err2}.instancePath === undefined`, () => gen.assign((0, codegen_1._)`${err2}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath)));
|
|
25401
|
+
gen.assign((0, codegen_1._)`${err2}.schemaPath`, (0, codegen_1.str)`${it.errSchemaPath}/${keyword}`);
|
|
23634
25402
|
if (it.opts.verbose) {
|
|
23635
|
-
gen.assign((0, codegen_1._)`${
|
|
23636
|
-
gen.assign((0, codegen_1._)`${
|
|
25403
|
+
gen.assign((0, codegen_1._)`${err2}.schema`, schemaValue);
|
|
25404
|
+
gen.assign((0, codegen_1._)`${err2}.data`, data);
|
|
23637
25405
|
}
|
|
23638
25406
|
});
|
|
23639
25407
|
}
|
|
23640
25408
|
exports.extendErrors = extendErrors;
|
|
23641
25409
|
function addError(gen, errObj) {
|
|
23642
|
-
const
|
|
23643
|
-
gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${
|
|
25410
|
+
const err2 = gen.const("err", errObj);
|
|
25411
|
+
gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${err2}]`), (0, codegen_1._)`${names_1.default.vErrors}.push(${err2})`);
|
|
23644
25412
|
gen.code((0, codegen_1._)`${names_1.default.errors}++`);
|
|
23645
25413
|
}
|
|
23646
25414
|
function returnErrors(it, errs) {
|
|
@@ -23805,8 +25573,8 @@ var require_applicability = __commonJS({
|
|
|
23805
25573
|
}
|
|
23806
25574
|
exports.shouldUseGroup = shouldUseGroup;
|
|
23807
25575
|
function shouldUseRule(schema, rule) {
|
|
23808
|
-
var
|
|
23809
|
-
return schema[rule.keyword] !== void 0 || ((
|
|
25576
|
+
var _a3;
|
|
25577
|
+
return schema[rule.keyword] !== void 0 || ((_a3 = rule.definition.implements) === null || _a3 === void 0 ? void 0 : _a3.some((kwd) => schema[kwd] !== void 0));
|
|
23810
25578
|
}
|
|
23811
25579
|
exports.shouldUseRule = shouldUseRule;
|
|
23812
25580
|
}
|
|
@@ -24198,14 +25966,14 @@ var require_keyword = __commonJS({
|
|
|
24198
25966
|
}
|
|
24199
25967
|
exports.macroKeywordCode = macroKeywordCode;
|
|
24200
25968
|
function funcKeywordCode(cxt, def) {
|
|
24201
|
-
var
|
|
25969
|
+
var _a3;
|
|
24202
25970
|
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
|
24203
25971
|
checkAsyncKeyword(it, def);
|
|
24204
25972
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
|
24205
25973
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
24206
25974
|
const valid = gen.let("valid");
|
|
24207
25975
|
cxt.block$data(valid, validateKeyword);
|
|
24208
|
-
cxt.ok((
|
|
25976
|
+
cxt.ok((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid);
|
|
24209
25977
|
function validateKeyword() {
|
|
24210
25978
|
if (def.errors === false) {
|
|
24211
25979
|
assignValid();
|
|
@@ -24236,8 +26004,8 @@ var require_keyword = __commonJS({
|
|
|
24236
26004
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
24237
26005
|
}
|
|
24238
26006
|
function reportErrs(errors) {
|
|
24239
|
-
var
|
|
24240
|
-
gen.if((0, codegen_1.not)((
|
|
26007
|
+
var _a4;
|
|
26008
|
+
gen.if((0, codegen_1.not)((_a4 = def.valid) !== null && _a4 !== void 0 ? _a4 : valid), errors);
|
|
24241
26009
|
}
|
|
24242
26010
|
}
|
|
24243
26011
|
exports.funcKeywordCode = funcKeywordCode;
|
|
@@ -25213,7 +26981,7 @@ var require_compile = __commonJS({
|
|
|
25213
26981
|
var validate_1 = require_validate();
|
|
25214
26982
|
var SchemaEnv = class {
|
|
25215
26983
|
constructor(env) {
|
|
25216
|
-
var
|
|
26984
|
+
var _a3;
|
|
25217
26985
|
this.refs = {};
|
|
25218
26986
|
this.dynamicAnchors = {};
|
|
25219
26987
|
let schema;
|
|
@@ -25222,7 +26990,7 @@ var require_compile = __commonJS({
|
|
|
25222
26990
|
this.schema = env.schema;
|
|
25223
26991
|
this.schemaId = env.schemaId;
|
|
25224
26992
|
this.root = env.root || this;
|
|
25225
|
-
this.baseId = (
|
|
26993
|
+
this.baseId = (_a3 = env.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
|
|
25226
26994
|
this.schemaPath = env.schemaPath;
|
|
25227
26995
|
this.localRefs = env.localRefs;
|
|
25228
26996
|
this.meta = env.meta;
|
|
@@ -25318,14 +27086,14 @@ var require_compile = __commonJS({
|
|
|
25318
27086
|
}
|
|
25319
27087
|
exports.compileSchema = compileSchema;
|
|
25320
27088
|
function resolveRef(root, baseId, ref) {
|
|
25321
|
-
var
|
|
27089
|
+
var _a3;
|
|
25322
27090
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
25323
27091
|
const schOrFunc = root.refs[ref];
|
|
25324
27092
|
if (schOrFunc)
|
|
25325
27093
|
return schOrFunc;
|
|
25326
27094
|
let _sch = resolve.call(this, root, ref);
|
|
25327
27095
|
if (_sch === void 0) {
|
|
25328
|
-
const schema = (
|
|
27096
|
+
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
25329
27097
|
const { schemaId } = this.opts;
|
|
25330
27098
|
if (schema)
|
|
25331
27099
|
_sch = new SchemaEnv({ schema, schemaId, root, baseId });
|
|
@@ -25394,8 +27162,8 @@ var require_compile = __commonJS({
|
|
|
25394
27162
|
"definitions"
|
|
25395
27163
|
]);
|
|
25396
27164
|
function getJsonPointer(parsedRef, { baseId, schema, root }) {
|
|
25397
|
-
var
|
|
25398
|
-
if (((
|
|
27165
|
+
var _a3;
|
|
27166
|
+
if (((_a3 = parsedRef.fragment) === null || _a3 === void 0 ? void 0 : _a3[0]) !== "/")
|
|
25399
27167
|
return;
|
|
25400
27168
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
25401
27169
|
if (typeof schema === "boolean")
|
|
@@ -25566,8 +27334,8 @@ var require_utils = __commonJS({
|
|
|
25566
27334
|
}
|
|
25567
27335
|
return ind;
|
|
25568
27336
|
}
|
|
25569
|
-
function removeDotSegments(
|
|
25570
|
-
let input =
|
|
27337
|
+
function removeDotSegments(path25) {
|
|
27338
|
+
let input = path25;
|
|
25571
27339
|
const output = [];
|
|
25572
27340
|
let nextSlash = -1;
|
|
25573
27341
|
let len = 0;
|
|
@@ -25767,8 +27535,8 @@ var require_schemes = __commonJS({
|
|
|
25767
27535
|
wsComponent.secure = void 0;
|
|
25768
27536
|
}
|
|
25769
27537
|
if (wsComponent.resourceName) {
|
|
25770
|
-
const [
|
|
25771
|
-
wsComponent.path =
|
|
27538
|
+
const [path25, query] = wsComponent.resourceName.split("?");
|
|
27539
|
+
wsComponent.path = path25 && path25 !== "/" ? path25 : void 0;
|
|
25772
27540
|
wsComponent.query = query;
|
|
25773
27541
|
wsComponent.resourceName = void 0;
|
|
25774
27542
|
}
|
|
@@ -26261,11 +28029,11 @@ var require_core = __commonJS({
|
|
|
26261
28029
|
};
|
|
26262
28030
|
var MAX_EXPRESSION = 200;
|
|
26263
28031
|
function requiredOptions(o) {
|
|
26264
|
-
var
|
|
28032
|
+
var _a3, _b2, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
26265
28033
|
const s = o.strict;
|
|
26266
|
-
const _optz = (
|
|
28034
|
+
const _optz = (_a3 = o.code) === null || _a3 === void 0 ? void 0 : _a3.optimize;
|
|
26267
28035
|
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
26268
|
-
const regExp = (_c = (
|
|
28036
|
+
const regExp = (_c = (_b2 = o.code) === null || _b2 === void 0 ? void 0 : _b2.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
26269
28037
|
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
26270
28038
|
return {
|
|
26271
28039
|
strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true,
|
|
@@ -26737,7 +28505,7 @@ var require_core = __commonJS({
|
|
|
26737
28505
|
}
|
|
26738
28506
|
}
|
|
26739
28507
|
function addRule(keyword, definition, dataType) {
|
|
26740
|
-
var
|
|
28508
|
+
var _a3;
|
|
26741
28509
|
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
26742
28510
|
if (dataType && post)
|
|
26743
28511
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
@@ -26763,7 +28531,7 @@ var require_core = __commonJS({
|
|
|
26763
28531
|
else
|
|
26764
28532
|
ruleGroup.rules.push(rule);
|
|
26765
28533
|
RULES.all[keyword] = rule;
|
|
26766
|
-
(
|
|
28534
|
+
(_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
|
|
26767
28535
|
}
|
|
26768
28536
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
26769
28537
|
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
@@ -26899,10 +28667,10 @@ var require_ref = __commonJS({
|
|
|
26899
28667
|
gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
|
|
26900
28668
|
}
|
|
26901
28669
|
function addEvaluatedFrom(source) {
|
|
26902
|
-
var
|
|
28670
|
+
var _a3;
|
|
26903
28671
|
if (!it.opts.unevaluated)
|
|
26904
28672
|
return;
|
|
26905
|
-
const schEvaluated = (
|
|
28673
|
+
const schEvaluated = (_a3 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a3 === void 0 ? void 0 : _a3.evaluated;
|
|
26906
28674
|
if (it.props !== true) {
|
|
26907
28675
|
if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
26908
28676
|
if (schEvaluated.props !== void 0) {
|
|
@@ -28581,7 +30349,7 @@ var require_discriminator = __commonJS({
|
|
|
28581
30349
|
return _valid;
|
|
28582
30350
|
}
|
|
28583
30351
|
function getMapping() {
|
|
28584
|
-
var
|
|
30352
|
+
var _a3;
|
|
28585
30353
|
const oneOfMapping = {};
|
|
28586
30354
|
const topRequired = hasRequired(parentSchema);
|
|
28587
30355
|
let tagRequired = true;
|
|
@@ -28595,7 +30363,7 @@ var require_discriminator = __commonJS({
|
|
|
28595
30363
|
if (sch === void 0)
|
|
28596
30364
|
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
|
28597
30365
|
}
|
|
28598
|
-
const propSch = (
|
|
30366
|
+
const propSch = (_a3 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a3 === void 0 ? void 0 : _a3[tagName];
|
|
28599
30367
|
if (typeof propSch != "object") {
|
|
28600
30368
|
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
|
|
28601
30369
|
}
|
|
@@ -29167,12 +30935,12 @@ var require_dist = __commonJS({
|
|
|
29167
30935
|
throw new Error(`Unknown format "${name}"`);
|
|
29168
30936
|
return f;
|
|
29169
30937
|
};
|
|
29170
|
-
function addFormats(ajv, list,
|
|
29171
|
-
var
|
|
29172
|
-
var
|
|
29173
|
-
(
|
|
30938
|
+
function addFormats(ajv, list, fs20, exportName) {
|
|
30939
|
+
var _a3;
|
|
30940
|
+
var _b2;
|
|
30941
|
+
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
29174
30942
|
for (const f of list)
|
|
29175
|
-
ajv.addFormat(f,
|
|
30943
|
+
ajv.addFormat(f, fs20[f]);
|
|
29176
30944
|
}
|
|
29177
30945
|
module.exports = exports = formatsPlugin;
|
|
29178
30946
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -30313,6 +32081,102 @@ var init_login_runner = __esm({
|
|
|
30313
32081
|
}
|
|
30314
32082
|
});
|
|
30315
32083
|
|
|
32084
|
+
// src/mcp/download.js
|
|
32085
|
+
import fs17 from "node:fs/promises";
|
|
32086
|
+
import path18 from "node:path";
|
|
32087
|
+
async function reserveName(dir, stem) {
|
|
32088
|
+
for (let n = 0; ; n++) {
|
|
32089
|
+
const file2 = path18.join(dir, n === 0 ? `${stem}${ZIP}` : `${stem} (${n})${ZIP}`);
|
|
32090
|
+
try {
|
|
32091
|
+
await (await fs17.open(file2, "wx")).close();
|
|
32092
|
+
return file2;
|
|
32093
|
+
} catch (error2) {
|
|
32094
|
+
if (!isErrno(error2, "EEXIST") || n >= 999) throw error2;
|
|
32095
|
+
}
|
|
32096
|
+
}
|
|
32097
|
+
}
|
|
32098
|
+
async function saveZip(dir, fileName, bytes) {
|
|
32099
|
+
const base = fileName.toLowerCase().endsWith(ZIP) ? fileName.slice(0, -ZIP.length) : fileName;
|
|
32100
|
+
const stem = WINDOWS_DEVICE_NAME_RE.test(base) ? `${base}-canvas` : base;
|
|
32101
|
+
const tmp = path18.join(dir, tempName(`.${stem}${ZIP}`));
|
|
32102
|
+
let file2 = null;
|
|
32103
|
+
try {
|
|
32104
|
+
await fs17.mkdir(dir, { recursive: true });
|
|
32105
|
+
await fs17.writeFile(tmp, bytes, { flag: "wx" });
|
|
32106
|
+
file2 = await reserveName(dir, stem);
|
|
32107
|
+
await fs17.rename(tmp, file2);
|
|
32108
|
+
return file2;
|
|
32109
|
+
} catch (error2) {
|
|
32110
|
+
await Promise.all([fs17.rm(tmp, { force: true }), file2 ? fs17.rm(file2, { force: true }) : void 0]).catch(
|
|
32111
|
+
() => void 0
|
|
32112
|
+
);
|
|
32113
|
+
const reason = isErrnoLike(error2) ? error2.code : "the file could not be written";
|
|
32114
|
+
throw new CliError("CLI_DOWNLOAD_FAILED", `Could not save the download in the Downloads folder (${reason}).`);
|
|
32115
|
+
}
|
|
32116
|
+
}
|
|
32117
|
+
function isErrnoLike(error2) {
|
|
32118
|
+
return typeof error2 === "object" && error2 !== null && typeof /** @type {{ code?: unknown }} */
|
|
32119
|
+
error2.code === "string";
|
|
32120
|
+
}
|
|
32121
|
+
function fetchersOf(api) {
|
|
32122
|
+
return {
|
|
32123
|
+
fetchText: async (url2) => decoder.decode(await api.download(url2)),
|
|
32124
|
+
fetchBytes: async (url2) => {
|
|
32125
|
+
try {
|
|
32126
|
+
return await api.download(url2);
|
|
32127
|
+
} catch (error2) {
|
|
32128
|
+
if (refusedByCdn(error2)) return null;
|
|
32129
|
+
throw error2;
|
|
32130
|
+
}
|
|
32131
|
+
}
|
|
32132
|
+
};
|
|
32133
|
+
}
|
|
32134
|
+
function fetchFailure(error2) {
|
|
32135
|
+
const cause = error2.cause;
|
|
32136
|
+
if (cause instanceof CliError) {
|
|
32137
|
+
return new CliError(cause.code, `${error2.message}: ${cause.message}`, {
|
|
32138
|
+
status: cause.status,
|
|
32139
|
+
exit: cause.exit,
|
|
32140
|
+
details: cause.details
|
|
32141
|
+
});
|
|
32142
|
+
}
|
|
32143
|
+
return new CliError(
|
|
32144
|
+
"CLI_DOWNLOAD_FAILED",
|
|
32145
|
+
`${error2.message}: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
32146
|
+
);
|
|
32147
|
+
}
|
|
32148
|
+
async function downloadCanvas(session, canvasId, dir) {
|
|
32149
|
+
const read2 = (await session.api.call({ method: "GET", path: `/design/canvases/${canvasId}` })).body;
|
|
32150
|
+
let built;
|
|
32151
|
+
try {
|
|
32152
|
+
built = await downloadCanvasZip(read2, fetchersOf(session.api));
|
|
32153
|
+
} catch (error2) {
|
|
32154
|
+
if (error2 instanceof CanvasDownloadFetchError) throw fetchFailure(error2);
|
|
32155
|
+
throw error2;
|
|
32156
|
+
}
|
|
32157
|
+
const file2 = await saveZip(dir, built.fileName, built.zip);
|
|
32158
|
+
return {
|
|
32159
|
+
canvas: canvasId,
|
|
32160
|
+
path: file2,
|
|
32161
|
+
designCount: built.designCount,
|
|
32162
|
+
imageCount: built.imageCount,
|
|
32163
|
+
missingImages: built.missingImages.length + built.unlistedImages.length
|
|
32164
|
+
};
|
|
32165
|
+
}
|
|
32166
|
+
var ZIP, decoder, refusedByCdn;
|
|
32167
|
+
var init_download = __esm({
|
|
32168
|
+
"src/mcp/download.js"() {
|
|
32169
|
+
"use strict";
|
|
32170
|
+
init_define_KOMBAI_TELEMETRY();
|
|
32171
|
+
init_contract();
|
|
32172
|
+
init_fsx();
|
|
32173
|
+
init_output();
|
|
32174
|
+
ZIP = ".zip";
|
|
32175
|
+
decoder = new TextDecoder();
|
|
32176
|
+
refusedByCdn = (error2) => error2 instanceof CliError && error2.code === "CLI_STORAGE_REFUSED" && typeof error2.status === "number" && error2.status >= 400 && error2.status < 500;
|
|
32177
|
+
}
|
|
32178
|
+
});
|
|
32179
|
+
|
|
30316
32180
|
// src/mcp/tools.js
|
|
30317
32181
|
function isVersionOf(uri, base) {
|
|
30318
32182
|
const prefix = `${base}?v=`;
|
|
@@ -30323,7 +32187,7 @@ function toolDescriptors(resourceUri) {
|
|
|
30323
32187
|
{
|
|
30324
32188
|
name: CANVAS_APP_TOOL,
|
|
30325
32189
|
title: "Kombai",
|
|
30326
|
-
description: "Show a Kombai canvas beside this chat. Pass the canvas id (cnv_\u2026) or its link; node is a design id to focus. With no canvas it shows every canvas the person can open when signed in, the guest home to a guest or to someone who never signed in, and asks someone who signed in before to sign in there. Open a canvas once: every canvas_app call opens another tab. The canvas is the live Kombai page, so it shows every change as it lands. Changes go through the work-with-kombai skill's commands, never through this tool.
|
|
32190
|
+
description: "Show a Kombai canvas beside this chat. Pass the canvas id (cnv_\u2026) or its link; node is a design id to focus. With no canvas it shows every canvas the person can open when signed in, the guest home to a guest or to someone who never signed in, and asks someone who signed in before to sign in there. Open a canvas once: every canvas_app call opens another tab. The canvas is the live Kombai page, so it shows every change as it lands. Changes go through the work-with-kombai skill's commands, never through this tool. While it shows the canvas, put no canvas or design link in your replies: name designs by their labels, and give a link only when the person asks for one. Such a link is a Kombai page, which opens in this client's browser, never a Kombai app link.",
|
|
30327
32191
|
inputSchema: {
|
|
30328
32192
|
type: "object",
|
|
30329
32193
|
properties: {
|
|
@@ -30377,6 +32241,45 @@ function toolDescriptors(resourceUri) {
|
|
|
30377
32241
|
},
|
|
30378
32242
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
30379
32243
|
_meta: { ui: { visibility: ["app"] } }
|
|
32244
|
+
},
|
|
32245
|
+
{
|
|
32246
|
+
name: RENAME_TOOL,
|
|
32247
|
+
description: "Kombai home: rename a canvas the signed-in person may edit, and answer the name the store kept. The view's own.",
|
|
32248
|
+
inputSchema: {
|
|
32249
|
+
type: "object",
|
|
32250
|
+
properties: {
|
|
32251
|
+
canvas: { type: "string", pattern: DESIGN_ID.canvas.source },
|
|
32252
|
+
name: { type: "string", minLength: 1, maxLength: DESIGN_LIMITS.nameMaxChars }
|
|
32253
|
+
},
|
|
32254
|
+
required: ["canvas", "name"],
|
|
32255
|
+
additionalProperties: false
|
|
32256
|
+
},
|
|
32257
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
32258
|
+
_meta: { ui: { visibility: ["app"] } }
|
|
32259
|
+
},
|
|
32260
|
+
{
|
|
32261
|
+
name: DELETE_TOOL,
|
|
32262
|
+
description: "Kombai home: delete a canvas the signed-in person owns, for everyone. The view's own.",
|
|
32263
|
+
inputSchema: {
|
|
32264
|
+
type: "object",
|
|
32265
|
+
properties: { canvas: { type: "string", pattern: DESIGN_ID.canvas.source } },
|
|
32266
|
+
required: ["canvas"],
|
|
32267
|
+
additionalProperties: false
|
|
32268
|
+
},
|
|
32269
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
32270
|
+
_meta: { ui: { visibility: ["app"] } }
|
|
32271
|
+
},
|
|
32272
|
+
{
|
|
32273
|
+
name: DOWNLOAD_TOOL,
|
|
32274
|
+
description: "Kombai home: save a canvas as a zip in this computer's Downloads folder, laid out to unzip into a project (.kombai/canvas/<name>.canvas and its images), and answer where it went; a guest's own canvas too. The view's own.",
|
|
32275
|
+
inputSchema: {
|
|
32276
|
+
type: "object",
|
|
32277
|
+
properties: { canvas: { type: "string", pattern: DESIGN_ID.canvas.source } },
|
|
32278
|
+
required: ["canvas"],
|
|
32279
|
+
additionalProperties: false
|
|
32280
|
+
},
|
|
32281
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
|
|
32282
|
+
_meta: { ui: { visibility: ["app"] } }
|
|
30380
32283
|
}
|
|
30381
32284
|
];
|
|
30382
32285
|
}
|
|
@@ -30508,6 +32411,39 @@ async function callCreate(ctx, args) {
|
|
|
30508
32411
|
});
|
|
30509
32412
|
return answer({ canvas: body.id, name: body.name, url: body.url, projectId });
|
|
30510
32413
|
}
|
|
32414
|
+
function cardCanvasId(value) {
|
|
32415
|
+
if (typeof value !== "string" || !DESIGN_ID.canvas.test(value))
|
|
32416
|
+
throw badArgument("canvas must be a canvas id (cnv_\u2026).");
|
|
32417
|
+
return value;
|
|
32418
|
+
}
|
|
32419
|
+
async function callRename(ctx, args) {
|
|
32420
|
+
const canvasId = cardCanvasId(args.canvas);
|
|
32421
|
+
const name = typeof args.name === "string" ? args.name.trim() : "";
|
|
32422
|
+
if (!name || name.length > DESIGN_LIMITS.nameMaxChars) {
|
|
32423
|
+
throw badArgument(`name is required: 1 to ${DESIGN_LIMITS.nameMaxChars} characters.`);
|
|
32424
|
+
}
|
|
32425
|
+
const session = await openSession(ctx, { claim: false, deadline: new Deadline(MANAGE_DEADLINE_MS, ctx.now) });
|
|
32426
|
+
const { body } = await session.api.call({ method: "PATCH", path: `/design/canvases/${canvasId}`, body: { name } });
|
|
32427
|
+
return answer({ canvas: canvasId, name: typeof body?.name === "string" ? body.name : name });
|
|
32428
|
+
}
|
|
32429
|
+
async function callDelete(ctx, args) {
|
|
32430
|
+
const canvasId = cardCanvasId(args.canvas);
|
|
32431
|
+
const session = await openSession(ctx, { claim: false, deadline: new Deadline(MANAGE_DEADLINE_MS, ctx.now) });
|
|
32432
|
+
try {
|
|
32433
|
+
await deleteStoredCanvas(session.api, canvasId);
|
|
32434
|
+
} catch (error2) {
|
|
32435
|
+
if (error2 instanceof CliError && error2.code === "DESIGN_FORBIDDEN") {
|
|
32436
|
+
throw new CliError(error2.code, ONLY_OWNER_DELETES, { status: error2.status, details: error2.details });
|
|
32437
|
+
}
|
|
32438
|
+
throw error2;
|
|
32439
|
+
}
|
|
32440
|
+
return answer({ canvas: canvasId, deleted: true });
|
|
32441
|
+
}
|
|
32442
|
+
async function callDownload(ctx, args, dir) {
|
|
32443
|
+
const canvasId = cardCanvasId(args.canvas);
|
|
32444
|
+
const session = await openAnySession(ctx, { claim: false, deadline: new Deadline(DOWNLOAD_DEADLINE_MS, ctx.now) });
|
|
32445
|
+
return answer(await downloadCanvas(session, canvasId, dir));
|
|
32446
|
+
}
|
|
30511
32447
|
async function canBeGuest(ctx) {
|
|
30512
32448
|
const { env } = await currentEnv(ctx);
|
|
30513
32449
|
return !holdsAccount(await readEntry(ctx.home, env));
|
|
@@ -30724,26 +32660,35 @@ function answer(structuredContent) {
|
|
|
30724
32660
|
), text: JSON.stringify(structuredContent) }]
|
|
30725
32661
|
};
|
|
30726
32662
|
}
|
|
30727
|
-
var CANVAS_APP_TOOL, SESSION_TOOL, ACCOUNT_TOOL, CREATE_TOOL, MULTI_TEAM_NOT_SUPPORTED, RESOURCE_URI_BASE, versionedUri, SIGN_IN_MAX_WAIT_S, INSTRUCTIONS, read, badArgument, given;
|
|
32663
|
+
var CANVAS_APP_TOOL, SESSION_TOOL, ACCOUNT_TOOL, CREATE_TOOL, RENAME_TOOL, DELETE_TOOL, DOWNLOAD_TOOL, ONLY_OWNER_DELETES, DOWNLOAD_DEADLINE_MS, MANAGE_DEADLINE_MS, MULTI_TEAM_NOT_SUPPORTED, RESOURCE_URI_BASE, versionedUri, SIGN_IN_MAX_WAIT_S, INSTRUCTIONS, read, badArgument, given;
|
|
30728
32664
|
var init_tools = __esm({
|
|
30729
32665
|
"src/mcp/tools.js"() {
|
|
30730
32666
|
"use strict";
|
|
30731
32667
|
init_define_KOMBAI_TELEMETRY();
|
|
30732
32668
|
init_kombai_icon();
|
|
30733
32669
|
init_auth();
|
|
32670
|
+
init_canvas();
|
|
30734
32671
|
init_api();
|
|
30735
32672
|
init_contract();
|
|
32673
|
+
init_deadline();
|
|
30736
32674
|
init_output();
|
|
30737
32675
|
init_project();
|
|
30738
32676
|
init_session();
|
|
30739
32677
|
init_store();
|
|
30740
32678
|
init_subscription();
|
|
30741
32679
|
init_version();
|
|
32680
|
+
init_download();
|
|
30742
32681
|
init_login_runner();
|
|
30743
32682
|
CANVAS_APP_TOOL = "canvas_app";
|
|
30744
32683
|
SESSION_TOOL = "canvas_app_session";
|
|
30745
32684
|
ACCOUNT_TOOL = "canvas_app_account";
|
|
30746
32685
|
CREATE_TOOL = "canvas_app_create";
|
|
32686
|
+
RENAME_TOOL = "canvas_app_rename";
|
|
32687
|
+
DELETE_TOOL = "canvas_app_delete";
|
|
32688
|
+
DOWNLOAD_TOOL = "canvas_app_download";
|
|
32689
|
+
ONLY_OWNER_DELETES = "Only the canvas's owner can delete it.";
|
|
32690
|
+
DOWNLOAD_DEADLINE_MS = 5e4;
|
|
32691
|
+
MANAGE_DEADLINE_MS = 5e4;
|
|
30747
32692
|
MULTI_TEAM_NOT_SUPPORTED = "Creating a canvas from more than one team is not supported yet";
|
|
30748
32693
|
RESOURCE_URI_BASE = "ui://kombai/cli-canvas-app";
|
|
30749
32694
|
versionedUri = (base, version2) => `${base}?v=${encodeURIComponent(version2)}`;
|
|
@@ -30971,8 +32916,8 @@ var init_sign_in_card = __esm({
|
|
|
30971
32916
|
});
|
|
30972
32917
|
|
|
30973
32918
|
// src/mcp/cards.js
|
|
30974
|
-
import
|
|
30975
|
-
import
|
|
32919
|
+
import fs18 from "node:fs/promises";
|
|
32920
|
+
import path19 from "node:path";
|
|
30976
32921
|
import { fileURLToPath } from "node:url";
|
|
30977
32922
|
function createCards(ctx, options) {
|
|
30978
32923
|
const dir = options.dir ?? CARDS_DIR;
|
|
@@ -30980,7 +32925,7 @@ function createCards(ctx, options) {
|
|
|
30980
32925
|
const script = (spec) => {
|
|
30981
32926
|
let read2 = scripts.get(spec);
|
|
30982
32927
|
if (!read2) {
|
|
30983
|
-
read2 =
|
|
32928
|
+
read2 = fs18.readFile(path19.join(dir, spec.bundle), "utf8").catch(() => null);
|
|
30984
32929
|
scripts.set(spec, read2);
|
|
30985
32930
|
}
|
|
30986
32931
|
return read2;
|
|
@@ -31394,9 +33339,9 @@ var init_stdio3 = __esm({
|
|
|
31394
33339
|
|
|
31395
33340
|
// src/mcp/view-html.js
|
|
31396
33341
|
function viewHtml(version2, host, options = {}) {
|
|
31397
|
-
return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS)).replace("{{COVER_MS}}", String(options.coverMs ?? COVER_MS)).replace("{{RECHECK_MS}}", String(options.recheckMs ?? RECHECK_MS));
|
|
33342
|
+
return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS)).replace("{{COVER_MS}}", String(options.coverMs ?? COVER_MS)).replace("{{RECHECK_MS}}", String(options.recheckMs ?? RECHECK_MS)).replace("{{MANAGE_WAIT_MS}}", String(options.manageWaitMs ?? MANAGE_WAIT_MS)).replace("{{DOWNLOAD_WAIT_MS}}", String(options.downloadWaitMs ?? DOWNLOAD_WAIT_MS));
|
|
31398
33343
|
}
|
|
31399
|
-
var VIEW_HTML, CLAIM_RETRY_MS, COVER_MS, RECHECK_MS;
|
|
33344
|
+
var VIEW_HTML, CLAIM_RETRY_MS, COVER_MS, RECHECK_MS, MANAGE_WAIT_MS, DOWNLOAD_WAIT_MS;
|
|
31400
33345
|
var init_view_html = __esm({
|
|
31401
33346
|
"src/mcp/view-html.js"() {
|
|
31402
33347
|
"use strict";
|
|
@@ -31460,7 +33405,9 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31460
33405
|
var HOST_LABEL = '{{HOST_LABEL}}', HOST_EMBED = '{{HOST_EMBED}}';
|
|
31461
33406
|
var CLAIM_RETRY_MS = {{CLAIM_RETRY_MS}}, CLAIM_TRIES = 3;
|
|
31462
33407
|
var COVER_MS = {{COVER_MS}}, RECHECK_MS = {{RECHECK_MS}};
|
|
33408
|
+
var MANAGE_WAIT_MS = {{MANAGE_WAIT_MS}}, DOWNLOAD_WAIT_MS = {{DOWNLOAD_WAIT_MS}};
|
|
31463
33409
|
var SESSION_TOOL = 'canvas_app_session', ACCOUNT_TOOL = 'canvas_app_account', CREATE_TOOL = 'canvas_app_create';
|
|
33410
|
+
var RENAME_TOOL = 'canvas_app_rename', DELETE_TOOL = 'canvas_app_delete', DOWNLOAD_TOOL = 'canvas_app_download';
|
|
31464
33411
|
// Every message from the page is a draft, whatever the page asked, while this and the page's ACTIONS_SENT_INTO_CHAT
|
|
31465
33412
|
// are off (embed-bridge.ts says why that is a product decision now, not a wait for the frame fix).
|
|
31466
33413
|
var SEND_ACTIONS = false;
|
|
@@ -31468,6 +33415,10 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31468
33415
|
var RESULT_WAIT_MS = 2000, SIGN_IN_WAIT_S = 20;
|
|
31469
33416
|
// The store's canvas-name limit (DESIGN_LIMITS.nameMaxChars): a longer create-canvas is a forged or broken message.
|
|
31470
33417
|
var NAME_MAX_CHARS = 200;
|
|
33418
|
+
var CANVAS_ID = /^cnv_[0-9a-f]{12}$/;
|
|
33419
|
+
var STILL_OPENING = 'Kombai is still opening; try again in a moment.';
|
|
33420
|
+
var GUEST_CANNOT = 'Sign in to Kombai to rename or delete a canvas.';
|
|
33421
|
+
var BUSY = 'Kombai is still finishing the last one; try again in a moment.';
|
|
31471
33422
|
|
|
31472
33423
|
var screen = document.getElementById('screen');
|
|
31473
33424
|
var title = document.getElementById('title');
|
|
@@ -31547,6 +33498,8 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31547
33498
|
var account = null;
|
|
31548
33499
|
// A create-canvas is being answered: a second one waits for it to settle and is otherwise dropped.
|
|
31549
33500
|
var creating = false;
|
|
33501
|
+
// The rename, delete and download being answered, by number (0: none): another of its kind meanwhile gets BUSY.
|
|
33502
|
+
var inFlight = { rename: 0, delete: 0, download: 0 }, manageCalls = 0;
|
|
31550
33503
|
// True only once the home's document has loaded: until then the old page is still the frame's window.
|
|
31551
33504
|
var framedHome = false;
|
|
31552
33505
|
// The loaded home is the guest home; the guest's canvas.
|
|
@@ -31659,9 +33612,11 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31659
33612
|
return { top: n(raw.top), right: n(raw.right), bottom: n(raw.bottom), left: n(raw.left) };
|
|
31660
33613
|
}
|
|
31661
33614
|
function hello() {
|
|
31662
|
-
// Create, the account
|
|
33615
|
+
// Create, the account, the guest canvas, Rename, Delete and Download go only to the loaded home (a design's script
|
|
33616
|
+
// could read them); Rename and Delete not to the guest home, whose guest may only download.
|
|
31663
33617
|
return {
|
|
31664
|
-
kind: 'hello', theme: theme, canvases: true, creates: framedHome,
|
|
33618
|
+
kind: 'hello', theme: theme, canvases: true, creates: framedHome, manages: framedHome && !framedGuest,
|
|
33619
|
+
downloads: framedHome, insets: insets,
|
|
31665
33620
|
account: framedHome && !framedGuest ? account : null,
|
|
31666
33621
|
guest: framedHome && framedGuest ? { canvas: guestCanvas } : null,
|
|
31667
33622
|
};
|
|
@@ -31695,6 +33650,54 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31695
33650
|
postToFrame({ kind: 'create-failed', message: error.message, code: error.code || null });
|
|
31696
33651
|
});
|
|
31697
33652
|
}
|
|
33653
|
+
// A home card's Rename and Delete: the CLI makes the change with the key, since the home's own pass has no project
|
|
33654
|
+
// and the store refuses a write from such a pass; the page is told either way. One of each kind at a time.
|
|
33655
|
+
// In flight until it settles, or until the page's own wait runs out if Codex never answers; finish() is then false.
|
|
33656
|
+
function startCall(kind, waitMs) {
|
|
33657
|
+
var call = ++manageCalls;
|
|
33658
|
+
inFlight[kind] = call;
|
|
33659
|
+
var timer = setTimeout(function () { if (inFlight[kind] === call) inFlight[kind] = 0; }, waitMs);
|
|
33660
|
+
return function finish() {
|
|
33661
|
+
clearTimeout(timer);
|
|
33662
|
+
if (inFlight[kind] !== call) return false;
|
|
33663
|
+
inFlight[kind] = 0;
|
|
33664
|
+
return true;
|
|
33665
|
+
};
|
|
33666
|
+
}
|
|
33667
|
+
function renameCanvas(id, name) {
|
|
33668
|
+
var finish = startCall('rename', MANAGE_WAIT_MS);
|
|
33669
|
+
callTool(RENAME_TOOL, { canvas: id, name: name }).then(function (answer) {
|
|
33670
|
+
if (!finish()) return;
|
|
33671
|
+
postToFrame({ kind: 'canvas-renamed', canvasId: id, name: typeof answer.name === 'string' ? answer.name : name });
|
|
33672
|
+
}, function (error) {
|
|
33673
|
+
if (!finish()) return;
|
|
33674
|
+
postToFrame({ kind: 'rename-failed', canvasId: id, message: error.message, code: error.code || null });
|
|
33675
|
+
});
|
|
33676
|
+
}
|
|
33677
|
+
function deleteCanvas(id) {
|
|
33678
|
+
var finish = startCall('delete', MANAGE_WAIT_MS);
|
|
33679
|
+
callTool(DELETE_TOOL, { canvas: id }).then(function () {
|
|
33680
|
+
if (!finish()) return;
|
|
33681
|
+
postToFrame({ kind: 'canvas-deleted', canvasId: id });
|
|
33682
|
+
}, function (error) {
|
|
33683
|
+
if (!finish()) return;
|
|
33684
|
+
postToFrame({ kind: 'delete-failed', canvasId: id, message: error.message, code: error.code || null });
|
|
33685
|
+
});
|
|
33686
|
+
}
|
|
33687
|
+
// A home card's Download: Codex's frame cannot download, and the guest home holds no pass to read a canvas with, so
|
|
33688
|
+
// the CLI reads the canvas, builds its zip and writes it to the Downloads folder; the page is told where it went.
|
|
33689
|
+
function downloadCanvas(id) {
|
|
33690
|
+
var finish = startCall('download', DOWNLOAD_WAIT_MS);
|
|
33691
|
+
callTool(DOWNLOAD_TOOL, { canvas: id }).then(function (answer) {
|
|
33692
|
+
if (typeof answer.path !== 'string') throw new Error('Kombai did not say where the file went.');
|
|
33693
|
+
if (!finish()) return;
|
|
33694
|
+
var missing = typeof answer.missingImages === 'number' ? answer.missingImages : 0;
|
|
33695
|
+
postToFrame({ kind: 'download-saved', canvasId: id, path: answer.path, missingImages: missing });
|
|
33696
|
+
}).catch(function (error) {
|
|
33697
|
+
if (!finish()) return;
|
|
33698
|
+
postToFrame({ kind: 'download-failed', canvasId: id, message: error.message, code: error.code || null });
|
|
33699
|
+
});
|
|
33700
|
+
}
|
|
31698
33701
|
function fromPage(m) {
|
|
31699
33702
|
if (!m || m.kombai !== EMBED || m.v !== PROTOCOL || typeof m.kind !== 'string') return;
|
|
31700
33703
|
if (m.kind === 'ready') { postToFrame(hello()); return; }
|
|
@@ -31720,7 +33723,7 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31720
33723
|
}
|
|
31721
33724
|
// A card on /canvases: that canvas's own ticket, then its page. Only a canvas id is taken, so a forged message
|
|
31722
33725
|
// can open nothing but a canvas, which the ticket route then judges.
|
|
31723
|
-
if (m.kind === 'open-canvas' && typeof m.canvas === 'string' &&
|
|
33726
|
+
if (m.kind === 'open-canvas' && typeof m.canvas === 'string' && CANVAS_ID.test(m.canvas)) {
|
|
31724
33727
|
canvas = m.canvas;
|
|
31725
33728
|
node = null;
|
|
31726
33729
|
open();
|
|
@@ -31739,12 +33742,31 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31739
33742
|
if (m.kind === 'create-canvas') {
|
|
31740
33743
|
if (creating || typeof m.name !== 'string' || !m.name.trim() || m.name.length > NAME_MAX_CHARS) return;
|
|
31741
33744
|
if (!framedHome) {
|
|
31742
|
-
postToFrame({ kind: 'create-failed', message:
|
|
33745
|
+
postToFrame({ kind: 'create-failed', message: STILL_OPENING });
|
|
31743
33746
|
return;
|
|
31744
33747
|
}
|
|
31745
33748
|
createCanvas(m.name.trim());
|
|
31746
33749
|
return;
|
|
31747
33750
|
}
|
|
33751
|
+
// Rename, Delete and Download: as Create, a canvas id (and a name) only, one of each kind at a time; one before
|
|
33752
|
+
// the load, a Rename or Delete from the guest home, or one while another of its kind is answered gets a failure,
|
|
33753
|
+
// so the page's menu does not wait for good.
|
|
33754
|
+
if (m.kind === 'rename-canvas' || m.kind === 'delete-canvas' || m.kind === 'download-canvas') {
|
|
33755
|
+
var kind = m.kind.split('-')[0];
|
|
33756
|
+
var busy = inFlight[kind] !== 0;
|
|
33757
|
+
if (typeof m.canvasId !== 'string' || !CANVAS_ID.test(m.canvasId)) return;
|
|
33758
|
+
if (kind === 'rename' && (typeof m.name !== 'string' || !m.name.trim() || m.name.length > NAME_MAX_CHARS)) return;
|
|
33759
|
+
var refused = !framedHome ? STILL_OPENING
|
|
33760
|
+
: framedGuest && kind !== 'download' ? GUEST_CANNOT : busy ? BUSY : null;
|
|
33761
|
+
if (refused) {
|
|
33762
|
+
postToFrame({ kind: kind + '-failed', canvasId: m.canvasId, message: refused, code: null });
|
|
33763
|
+
return;
|
|
33764
|
+
}
|
|
33765
|
+
if (kind === 'rename') renameCanvas(m.canvasId, m.name.trim());
|
|
33766
|
+
else if (kind === 'delete') deleteCanvas(m.canvasId);
|
|
33767
|
+
else downloadCanvas(m.canvasId);
|
|
33768
|
+
return;
|
|
33769
|
+
}
|
|
31748
33770
|
if (m.kind === 'open-link' && typeof m.url === 'string' && /^https:\/\//i.test(m.url)) offerLink(m.url);
|
|
31749
33771
|
}
|
|
31750
33772
|
|
|
@@ -31998,11 +34020,14 @@ html.dark #cover{background:rgba(30,30,30,.6)}
|
|
|
31998
34020
|
CLAIM_RETRY_MS = 3e3;
|
|
31999
34021
|
COVER_MS = 1e4;
|
|
32000
34022
|
RECHECK_MS = 2e4;
|
|
34023
|
+
MANAGE_WAIT_MS = 6e4;
|
|
34024
|
+
DOWNLOAD_WAIT_MS = 12e4;
|
|
32001
34025
|
}
|
|
32002
34026
|
});
|
|
32003
34027
|
|
|
32004
34028
|
// src/mcp/server.js
|
|
32005
34029
|
import os2 from "node:os";
|
|
34030
|
+
import path20 from "node:path";
|
|
32006
34031
|
function createMcpServer(ctx, options = {}) {
|
|
32007
34032
|
const place = {
|
|
32008
34033
|
cwd: ctx.cwd,
|
|
@@ -32023,6 +34048,7 @@ function createMcpServer(ctx, options = {}) {
|
|
|
32023
34048
|
const login2 = createLoginRunner(ctx);
|
|
32024
34049
|
const callSession = createSessionTool(ctx, { login: login2 });
|
|
32025
34050
|
const cards = createCards(ctx, { dir: options.cardsDir, login: login2 });
|
|
34051
|
+
const downloadsDir = path20.join(place.osHome, "Downloads");
|
|
32026
34052
|
const resourceMeta = async () => {
|
|
32027
34053
|
const { hosts } = await currentEnv(ctx);
|
|
32028
34054
|
return {
|
|
@@ -32070,6 +34096,9 @@ function createMcpServer(ctx, options = {}) {
|
|
|
32070
34096
|
if (host && name === SESSION_TOOL) return await callSession(args, host);
|
|
32071
34097
|
if (host && name === ACCOUNT_TOOL) return await callAccount(ctx);
|
|
32072
34098
|
if (host && name === CREATE_TOOL) return await callCreate(ctx, args);
|
|
34099
|
+
if (host && name === RENAME_TOOL) return await callRename(ctx, args);
|
|
34100
|
+
if (host && name === DELETE_TOOL) return await callDelete(ctx, args);
|
|
34101
|
+
if (host && name === DOWNLOAD_TOOL) return await callDownload(ctx, args, downloadsDir);
|
|
32073
34102
|
const card = await cards.call(set2, name, args);
|
|
32074
34103
|
if (card) return card;
|
|
32075
34104
|
return toolError(new CliError("CLI_UNKNOWN_TOOL", `${name} is not a tool of this server for this client.`));
|
|
@@ -32190,7 +34219,7 @@ var init_actions = __esm({
|
|
|
32190
34219
|
var brief_default;
|
|
32191
34220
|
var init_brief = __esm({
|
|
32192
34221
|
"src/skill/brief.md"() {
|
|
32193
|
-
brief_default = '# Writing a taste brief\n\nTaste reads only the brief: it cannot see the repo, the chat or any file. Write everything it needs into\nthe brief, at most 8,000 characters, in a file outside the repo, then pass it to\n`kombai taste start --brief <file> --variants <1-4>`.\n\nGive ground truth, not design advice. Taste\'s job is to bring the design ideas; ideas you add make it\ncopy yours. For "a joyful, light CRM", write "A joyful light-theme CRM application", not "a light CRM\ndashboard with a soft purple gradient".\n\nA brief says:\n\n- What to design, in plain words that name the kind of UI: a pricing section, sign-in, onboarding, a\n dashboard, a data table, an AI chat, an empty state.\n- The scope: a full page, one section, a screen, a multi-screen flow, or one reusable component. For a\n component taste returns lighter options (arrangements, looks, graphic ideas) and no assets.\n- Every fact the design shows: the product and who uses it, the real copy (names, numbers, plans,\n prices, navigation), the content of each section, and the states that matter.\n- What is already decided, from the repo or the user: brand colors, fonts, logo, an existing design\n system (its tokens, copied from tailwind config, globals.css, theme or token files), and what must stay\n as it is. Copy the values; taste cannot open the files.\n- What is still open, only when the user said so: "explore the layout", "keep our colors".\n\nSkip taste when the work copies or reflows a design instead of making a new one: a clone of a page,\nscreenshot or mock the user gave, a build of the repo\'s existing screens, a version of a design for\nanother device or mode, or an edit to part of a design. Then write the HTML straight from the reference\nor the pulled node.\n\nA taste run takes a few minutes. Tell the user it has started, and create and open the canvas while it\nruns. Run `kombai taste wait <run>` in the foreground, one wait at a time: it returns within 90 seconds,\nso while its status is running, tell the user the run is still going, as expected, and wait again.\n\nAfter `kombai taste wait`, follow directions.md: one direction per variant. In it, <stock-image> tags\ndescribe photos and <icon> tags name icons from the library its <icon-library> tag names: put icons in as\ninline SVG from that library, and photos as images, from a public https URL or saved in the repo. Its\nasset links are real; use them as given and never invent one.\n\ndirections.md is written for
|
|
34222
|
+
brief_default = '# Writing a taste brief\n\nTaste reads only the brief: it cannot see the repo, the chat or any file. Write everything it needs into\nthe brief, at most 8,000 characters, in a file outside the repo, then pass it to\n`kombai taste start --brief <file> --variants <1-4>`.\n\nGive ground truth, not design advice. Taste\'s job is to bring the design ideas; ideas you add make it\ncopy yours. For "a joyful, light CRM", write "A joyful light-theme CRM application", not "a light CRM\ndashboard with a soft purple gradient".\n\nA brief says:\n\n- What to design, in plain words that name the kind of UI: a pricing section, sign-in, onboarding, a\n dashboard, a data table, an AI chat, an empty state.\n- The scope: a full page, one section, a screen, a multi-screen flow, or one reusable component. For a\n component taste returns lighter options (arrangements, looks, graphic ideas) and no assets.\n- Every fact the design shows: the product and who uses it, the real copy (names, numbers, plans,\n prices, navigation), the content of each section, and the states that matter.\n- What is already decided, from the repo or the user: brand colors, fonts, logo, an existing design\n system (its tokens, copied from tailwind config, globals.css, theme or token files), and what must stay\n as it is. Copy the values; taste cannot open the files.\n- What is still open, only when the user said so: "explore the layout", "keep our colors".\n\nSkip taste when the work copies or reflows a design instead of making a new one: a clone of a page,\nscreenshot or mock the user gave, a build of the repo\'s existing screens, a version of a design for\nanother device or mode, or an edit to part of a design. Then write the HTML straight from the reference\nor the pulled node.\n\nA taste run takes a few minutes. Tell the user it has started, and create and open the canvas while it\nruns. Run `kombai taste wait <run>` in the foreground, one wait at a time: it returns within 90 seconds,\nso while its status is running, tell the user the run is still going, as expected, and wait again.\n\nAfter `kombai taste wait`, follow directions.md: one direction per variant. In it, <stock-image> tags\ndescribe photos and <icon> tags name icons from the library its <icon-library> tag names: put icons in as\ninline SVG from that library, and photos as images, from a public https URL or saved in the repo. Its\nasset links are real; use them as given and never invent one.\n\ndirections.md is written for a page on a canvas, as Kombai\'s own Design mode writes it. What it asks for\nruns there: scroll-driven motion (parallax, reveal or count-up on scroll, pinning), smooth scrolling\n(Lenis, Locomotive), sticky or fixed elements, and the Sticky Layout Rule it may add, once the design has a\nheight of its own (`kombai skill html`, Size and position). A\n<stock-image> or <stock-video> with no link has no asset: draw it as SVG or leave it out.\n';
|
|
32194
34223
|
}
|
|
32195
34224
|
});
|
|
32196
34225
|
|
|
@@ -32222,7 +34251,7 @@ var init_drawings = __esm({
|
|
|
32222
34251
|
var faq_default;
|
|
32223
34252
|
var init_faq = __esm({
|
|
32224
34253
|
"src/skill/faq.md"() {
|
|
32225
|
-
faq_default = "# Questions about Kombai\n\nAnswer the user's question from this text, briefly and in your own words. To answer, run only commands that\nchange nothing (`kombai whoami`, `kombai credits`, `kombai canvas list`). If the answer is not here, say so and\npoint them to support@kombai.com; don't guess. For design work, run `kombai skill` and follow it.\n\n## What Kombai is\n\n- **What it does.** Kombai is an AI design engineer. The coding agent runs the Kombai CLI: Kombai's taste agent\n writes design directions grounded in the user's brief and repo, and the agent builds each design as HTML on a\n hosted Kombai canvas, where the user compares, edits and refines the designs in the browser.\n- **Which agents.** Claude Code, Codex and Cursor have Kombai plugins; any agent with a terminal can run the CLI.\n Where the agent shows MCP views (the Codex app, the Claude desktop app's Code tab), the canvas or Kombai's\n cards can show beside the chat; elsewhere the canvas opens in the browser.\n- **The Kombai desktop app** is not needed: the CLI designs on a hosted canvas whether or not it is installed.\n- **Requirements.** Node.js 20 or later, and a Kombai account or guest mode. Thumbnails need a Chromium browser\n (Chrome, Edge, Brave, Arc or Chromium); without one, `kombai browser install` downloads a headless Chromium of\n about 100 MB, after asking.\n\n## Account and credits\n\n- **Without an account.** `kombai guest` gives one canvas, with no taste runs, repo images, design systems or\n sharing. The guest canvas ends on the date `kombai whoami` shows; signing in keeps it.\n- **Signing in.** `kombai login` shows a match code and opens a Kombai page in the browser: approve there only\n if the codes match. `kombai whoami` shows who is signed in. `kombai logout` signs this machine out;\n `kombai logout --everywhere` also signs out every other key, the Kombai app and the website.\n- **Credits.** Taste runs spend Kombai credits; `kombai credits` shows what is left, the plan and when it refills.\n On a team plan they are the team's shared pool. With none left, its next is the plans page. The designs\n themselves are written by the user's own coding agent, on that agent's usage.\n- **Organizations.** With several, `kombai config org <id>` sets which one owns new canvases and design systems.\n\n## Designs and data\n\n- **Where designs live.** On hosted canvases in the user's Kombai account. `kombai canvas list` lists this\n repo's, `kombai canvas list --all` every one, and `kombai canvas open --canvas <id>` opens one in the browser.\n- **Editing.** The user can edit text, styles and layout on the canvas, or ask for a change from it: the canvas\n gives them a request to paste into this chat.\n- **Into code.** Ask the agent to build a design in this project: it writes it in the repo's own framework,\n components and styles, with the design as the reference.\n- **Design systems** are .ds files in the Kombai account and need no canvas; `kombai ds list` lists them.\n- **Sharing.** A new canvas is private. `kombai canvas share --canvas <id> --on` lets anyone with the link view it\n and teammates edit it; `--off` turns that off. Only the canvas's owner can.\n- **What Kombai receives.** The brief the agent writes for a taste run, each design's HTML, the repo images a\n design uses, files the agent uploads, design systems it pushes, and the thumbnails rendered on this machine.\n The rest of the repo is not uploaded.\n- **What stays here.** The sign-in key and the working copies of canvases, under ~/.kombai/cli.\n- **Usage data.** The CLI sends Kombai an event for each command (which ran, how it ended, how long it took) and\n reports unexpected errors. `DO_NOT_TRACK=1` turns both off.\n- **Deleting.** `kombai canvas delete --canvas <id>` and `kombai ds delete <slug>` delete for everyone. Deleting\n ~/.kombai removes what is stored on this machine. To close the account, email support@kombai.com.\n\n## Setup and problems\n\n- **Permissions.** Kombai needs network access and writes ~/.kombai, so an agent with a sandbox asks to run it\n outside.\n- **Updates.** The plugins run the CLI through npx, which fetches the newest release itself; a global install\n updates with npm. The plugin updates through the agent's own plugin manager.\n- **Reporting a problem.** Email support@kombai.com with the command, the JSON line it printed and the version\n `kombai --version` prints.\n";
|
|
34254
|
+
faq_default = "# Questions about Kombai\n\nAnswer the user's question from this text, briefly and in your own words. To answer, run only commands that\nchange nothing (`kombai whoami`, `kombai credits`, `kombai canvas list`). If the answer is not here, say so and\npoint them to support@kombai.com; don't guess. For design work, run `kombai skill` and follow it.\n\n## What Kombai is\n\n- **What it does.** Kombai is an AI design engineer. The coding agent runs the Kombai CLI: Kombai's taste agent\n writes design directions grounded in the user's brief and repo, and the agent builds each design as HTML on a\n hosted Kombai canvas, where the user compares, edits and refines the designs in the browser.\n- **Which agents.** Claude Code, Codex and Cursor have Kombai plugins; any agent with a terminal can run the CLI.\n Where the agent shows MCP views (the Codex app, the Claude desktop app's Code tab), the canvas or Kombai's\n cards can show beside the chat; elsewhere the canvas opens in the browser.\n- **The Kombai desktop app** is not needed: the CLI designs on a hosted canvas whether or not it is installed.\n- **Requirements.** Node.js 20 or later, and a Kombai account or guest mode. Thumbnails need a Chromium browser\n (Chrome, Edge, Brave, Arc or Chromium); without one, `kombai browser install` downloads a headless Chromium of\n about 100 MB, after asking.\n\n## Account and credits\n\n- **Without an account.** `kombai guest` gives one canvas, with no taste runs, repo images, design systems or\n sharing. The guest canvas ends on the date `kombai whoami` shows; signing in keeps it.\n- **Signing in.** `kombai login` shows a match code and opens a Kombai page in the browser: approve there only\n if the codes match. `kombai whoami` shows who is signed in. `kombai logout` signs this machine out;\n `kombai logout --everywhere` also signs out every other key, the Kombai app and the website.\n- **Credits.** Taste runs spend Kombai credits; `kombai credits` shows what is left, the plan and when it refills.\n On a team plan they are the team's shared pool. With none left, its next is the plans page. The designs\n themselves are written by the user's own coding agent, on that agent's usage.\n- **Organizations.** With several, `kombai config org <id>` sets which one owns new canvases and design systems.\n\n## Designs and data\n\n- **Where designs live.** On hosted canvases in the user's Kombai account. `kombai canvas list` lists this\n repo's, `kombai canvas list --all` every one, and `kombai canvas open --canvas <id>` opens one in the browser.\n- **Editing.** The user can edit text, styles and layout on the canvas, or ask for a change from it: the canvas\n gives them a request to paste into this chat.\n- **Into code.** Ask the agent to build a design in this project: it writes it in the repo's own framework,\n components and styles, with the design as the reference.\n- **Design systems** are .ds files in the Kombai account and need no canvas; `kombai ds list` lists them.\n- **Sharing.** A new canvas is private. `kombai canvas share --canvas <id> --on` lets anyone with the link view it\n and teammates edit it; `--off` turns that off. Only the canvas's owner can.\n- **What Kombai receives.** The brief the agent writes for a taste run, each design's HTML, the repo images a\n design uses, files the agent uploads, design systems it pushes, and the thumbnails rendered on this machine.\n The rest of the repo is not uploaded.\n- **What stays here.** The sign-in key and the working copies of canvases, under ~/.kombai/cli.\n- **Usage data.** The CLI sends Kombai an event for each command (which ran, how it ended, how long it took) and\n reports unexpected errors. `DO_NOT_TRACK=1` turns both off.\n- **Deleting.** `kombai canvas delete --canvas <id>` and `kombai ds delete <slug>` delete for everyone. Deleting\n ~/.kombai removes what is stored on this machine. To close the account, email support@kombai.com.\n\n## Setup and problems\n\n- **Permissions.** Kombai needs network access and writes ~/.kombai, so an agent with a sandbox asks to run it\n outside.\n- **The desktop app's skills.** The first Kombai command on a machine removes the skills the Kombai desktop app\n wrote into the agents' skills folders (`design-with-kombai`, `kombai-faq`, `kombai-status` and the rest), which\n drive the app instead of the CLI. Only the app's own copies go; other skills, the user's own included, stay. An\n agent session that was already open lists them until it restarts.\n- **Updates.** The plugins run the CLI through npx, which fetches the newest release itself; a global install\n updates with npm. The plugin updates through the agent's own plugin manager.\n- **Reporting a problem.** Email support@kombai.com with the command, the JSON line it printed and the version\n `kombai --version` prints.\n";
|
|
32226
34255
|
}
|
|
32227
34256
|
});
|
|
32228
34257
|
|
|
@@ -32230,7 +34259,7 @@ var init_faq = __esm({
|
|
|
32230
34259
|
var html_default;
|
|
32231
34260
|
var init_html = __esm({
|
|
32232
34261
|
"src/skill/html.md"() {
|
|
32233
|
-
html_default = '# Writing a design\'s HTML\n\nThe file `kombai node start` prints holds one design. The canvas shows it live in a frame, and\n`kombai screenshot fill` renders the thumbnail most viewers see. Write it so both look the same.\n\n## Build in passes\n\nnode start creates the file, empty. Read it right after node start, before your first write, even though\nit is empty: an editor that writes only files it has read refuses the write otherwise, and the page you\nwrote is lost. Push the first pass within 30 minutes of node start, or the placeholder expires.\n\n1. First pass: every section in order, with its layout, headings and real copy.\n2. Each later pass: one or two sections\' art, motion and interactions.\n\nPush after each pass, and only once its write has succeeded: never in the same batch of tool calls as\nthe write. The canvas shows each push live, so the user watches the page fill in. Check the design once,\nafter its last pass ("Check a finished design" in the overview).\n\n## The file\n\n- Body content only: no `<!DOCTYPE>`, `<html>`, `<head>` or `<body>`. The canvas and the thumbnail\n both wrap it in their own page, inside a `<div id="root">`, so `body > \u2026` selectors match nothing.\n- So the file is a fragment, not a web page: opened on its own it looks broken. Never open, preview or\n serve it, and never link or name its path to the user. To point the user at a design, give the `url`\n node start, node pull and node push print for it: the canvas, with that design in focus. A guest\'s
|
|
34262
|
+
html_default = '# Writing a design\'s HTML\n\nThe file `kombai node start` prints holds one design. The canvas shows it live in a frame, and\n`kombai screenshot fill` renders the thumbnail most viewers see. Write it so both look the same.\n\n## Build in passes\n\nnode start creates the file, empty. Read it right after node start, before your first write, even though\nit is empty: an editor that writes only files it has read refuses the write otherwise, and the page you\nwrote is lost. Push the first pass within 30 minutes of node start, or the placeholder expires.\n\n1. First pass: every section in order, with its layout, headings and real copy.\n2. Each later pass: one or two sections\' art, motion and interactions.\n\nPush after each pass, and only once its write has succeeded: never in the same batch of tool calls as\nthe write. The canvas shows each push live, so the user watches the page fill in. Check the design once,\nafter its last pass ("Check a finished design" in the overview).\n\n## The file\n\n- Body content only: no `<!DOCTYPE>`, `<html>`, `<head>` or `<body>`. The canvas and the thumbnail\n both wrap it in their own page, inside a `<div id="root">`, so `body > \u2026` selectors match nothing.\n- So the file is a fragment, not a web page: opened on its own it looks broken. Never open, preview or\n serve it, and never link or name its path to the user. To point the user at a design, give the `url`\n node start, node pull and node push print for it: the canvas, with that design in focus. Where\n `canvas_app` shows the canvas beside the chat, name the design instead, with no link unless the user\n asks for one. A guest\'s `url` is null: point them at the canvas you showed them.\n- Style with Tailwind v4 classes or with your own CSS in a `<style>`. Put every `<style>`, `<link>` and\n library `<script>` at the top of the body. Load Google Fonts with `@import url(\u2026)` as the first line of a\n `<style>`. Set the font, text color and background on your outermost element.\n- Tailwind: add no Tailwind script; Kombai loads Tailwind v4 when the design uses its classes. The canvas\n builds CSS only from classes written in `class="\u2026"`: no config, `@apply`, `@theme` or\n `<style type="text/tailwindcss">`, and a class only a script adds gets no CSS there; write that styling as\n plain CSS in a `<style>`. Use v4 utilities (`bg-black/50`, not `bg-opacity-50`), and CSS variables as\n `bg-(--brand)` or `bg-[var(--brand)]`, never `bg-[--brand]`. On a page with Tailwind classes, style\n no `*` or bare tags in a `<style>`: CSS there beats every Tailwind class.\n- Your own CSS, with no Tailwind classes: the page owns its defaults. Start its `<style>` with a reset\n (margin, padding and box-sizing on `*`) and style headings, lists, links, buttons and images yourself,\n so the page looks the same whether or not Tailwind is loaded. Don\'t name classes like Tailwind\n utilities (`flex`, `hidden`, `text-center`, `p-4`): the canvas may take the page for Tailwind.\n- Define every `@keyframes` you use.\n- `kombai node push` writes a `data-kid="\u2026"` id onto each element of a changed file before it sends it: the id\n the canvas and the user\'s requests name an element by. Read the file again before your next pass to get them.\n Keep the ids when you edit; give a new element none, the next push numbers it.\n\n## Size and position\n\n- A design is 1280 px wide. `--viewport mobile`, `--viewport tablet` or `--viewport desktop` on\n `kombai node start` makes it 390, 768 or 1280. Design for that width: one design per device, not one\n with breakpoints.\n- A design is content height unless you give it a height: its frame is as tall as its page and never\n scrolls. So:\n - Give heights in px (`h-[720px]`, `min-height: 640px`). `h-screen`, `min-h-screen` and `100vh` come out\n 1000 px tall, on the canvas and in the thumbnail.\n - Do not size anything from `window.innerHeight`: on the canvas it is the whole page\'s height.\n- What needs the page to scroll needs a design with a height of its own: scroll-driven effects (scroll\n listeners, parallax, pinned or scrubbed sections, GSAP ScrollTrigger), `sticky` and `fixed` elements, and\n smooth scrolling (Lenis, Locomotive). At content height nothing scrolls, so none of them run: a pinned\n section\'s runway shows as empty space, a sticky element never sticks, and a fixed bottom bar lands 1000 px\n down, mid-page; selected, the canvas shows a page that pins in a device-height window it cannot scroll.\n So after the first push, set the design\'s `rect.h` in canvas.json to its device height (desktop 800,\n tablet 1024, mobile 812) and run `kombai canvas push --canvas <id>`. Selected, it then scrolls inside that\n window and all of these run as on a real page. A reveal that only waits to come into view\n (IntersectionObserver) needs no height: it runs as the viewer pans to it.\n- The thumbnail scrolls the page through once and settles its animations, so it shows the page as a\n visitor who scrolled to the bottom left it: every reveal shown, pinned sections and parallax layers at\n their end, no runway. It takes scrubbed animations at their end too, so an element that fades or slides\n out as the page scrolls is missing from it: animate things in, not out. A design with a height gets the\n whole page as its thumbnail, seen through its window: a sticky element shows where it starts, and a fixed\n one where it sits on the first screen, so a bar fixed to the bottom shows at that screen\'s foot, mid-page.\n- The thumbnail stops at 16,000 px.\n\n## Scripts\n\n- Load each library from a CDN with its own `<script src>` and a pinned version: Chart.js for charts,\n GSAP or Motion for animation. Only public https hosts load.\n- The thumbnail renders with reduced motion. It scrolls the page through, runs GSAP, ScrollTrigger, anime\n and Web Animations to their end, pauses CSS animations and video, and is taken once fonts and images\n are in. The page must look finished by then:\n - Chart.js: `options: { animation: false }`.\n - CSS entrance animations: behind `motion-safe:` or `@media (prefers-reduced-motion: no-preference)`.\n - A page that fills in late (JS entrance animations, content a script draws) sets\n `window.KOMBAI_READY = false` at the top, and `true` when done (or dispatches a `kombai:ready`\n event on window). The thumbnail waits up to 20 s, then takes the page as it is. A page whose text\n names either is waited for, so name them only if you signal.\n\n## Images and video\n\n- Repo files: `/api/local/images/<path from the repo root>`, in src, srcset, poster or CSS `url()`.\n `kombai node push` uploads each one: png, jpg, jpeg, webp, gif, svg, mp4 or webm, up to 20 MB, at\n most 100 per design. Write each path in full, with spaces as `%20`; a path a script builds is not\n uploaded.\n- A file outside the repo, such as an image you generated: `kombai asset push <file> --canvas <id>`\n prints its url. Use that url.\n- Stock photos: use the links directions.md gives, with size params added. images.unsplash.com:\n `?auto=format&w=<px>&q=80&fit=crop`. images.pexels.com: `?auto=compress&cs=tinysrgb&w=<px>&q=80`.\n The bare link is the full-size original.\n- Icons: inline SVG from the library directions.md names.\n- `<img decoding="async" alt="\u2026">`. `loading="lazy"` is fine: the thumbnail loads every image first.\n- Video: `<video src="\u2026" poster="\u2026" autoplay muted loop playsinline preload="metadata">`. Always set a\n poster: it shows until the video plays. Drop autoplay and loop only for click-to-play, such as a\n walkthrough.\n- Every other URL is absolute and public https: relative paths do not resolve, and the thumbnail\n refuses localhost and private addresses.\n- Never invent an image URL.\n\n## Content\n\n- Real copy from the brief and the repo: real names, numbers and dates. No lorem ipsum. No text for the\n reviewer: no design notes, captions explaining the layout, or "click to see".\n- Plain section headings, as a product\'s UI would have them: "Plans", "Details", "Team", not "What it\n costs", "How it works" or "Who is on site this week".\n- One page or screen per design; a modal or drawer is its own design. For a component, design only\n it, on a plain background.\n- Give each meaningful element a `data-name` saying what it is ("pricing card", "hero headline"): the\n canvas editor shows it.\n- No `dark:` classes or `prefers-color-scheme` queries: they follow the viewer\'s theme, so the canvas and\n the thumbnail can differ. A dark version is its own design.\n\n## Patterns to avoid, unless asked\n\n- Drop shadows on cards; gradient-filled headline text.\n- The stock hero: headline, image, two buttons, badges.\n- Three icon-topped cards in a row; plain pricing, testimonial or two-row stat cards.\n- A footer of only links and a logo; a form or call-out as one big card.\n- Fade-in on appear and lift on hover as the only motion; buttons with the usual radius and hover.\n';
|
|
32234
34263
|
}
|
|
32235
34264
|
});
|
|
32236
34265
|
|
|
@@ -32238,7 +34267,7 @@ var init_html = __esm({
|
|
|
32238
34267
|
var opening_default;
|
|
32239
34268
|
var init_opening = __esm({
|
|
32240
34269
|
"src/skill/opening.md"() {
|
|
32241
|
-
opening_default = "# Showing the canvas\n\nShow a canvas to the user once, when you create or first use it. The page updates live as you push, so\nnever open it again after a push. Pick the first of these that fits:\n\n1. **A `canvas_app` tool is listed** (the Kombai view): call `canvas_app` with the canvas id, and `node`\n set to a design id to focus one. It shows the canvas beside the chat. Call it once per canvas: each\n call opens another view. Make changes with the commands, never through the view.\n2. **You have a browser panel of your own**: `kombai canvas url --canvas <id> --in-app` prints a signed-in\n link. Open it in your panel. It works once, within 10 minutes; for a later visit, run it again.\n3. **Otherwise**: `kombai canvas open --canvas <id>` opens the canvas in the user's browser, signed in.\n If it answers opened: false (no browser on this machine), give the user the link it printed instead.\n\nTo point the user at one design, give the `url` node start, node pull or node push printed for it, or\nadd ?node=<node> to the canvas link. Never the design's .html file, and never a link that holds a\n#ticket=; it signs in whoever opens it first.\n\n**A new canvas is private.** When you give the user a link, don't suggest they send it to anyone before sharing it.\n\n**Never turn sharing on by yourself.** Run `kombai canvas share --on` only when the user asks for a link others can open, and tell them in the reply that anyone with the link can now view it and teammates can edit it.\n";
|
|
34270
|
+
opening_default = "# Showing the canvas\n\nShow a canvas to the user once, when you create or first use it. The page updates live as you push, so\nnever open it again after a push. Pick the first of these that fits:\n\n1. **A `canvas_app` tool is listed** (the Kombai view): call `canvas_app` with the canvas id, and `node`\n set to a design id to focus one. It shows the canvas beside the chat. Call it once per canvas: each\n call opens another view. Make changes with the commands, never through the view.\n2. **You have a browser panel of your own**: `kombai canvas url --canvas <id> --in-app` prints a signed-in\n link. Open it in your panel. It works once, within 10 minutes; for a later visit, run it again.\n3. **Otherwise**: `kombai canvas open --canvas <id>` opens the canvas in the user's browser, signed in.\n If it answers opened: false (no browser on this machine), give the user the link it printed instead.\n\nTo point the user at one design, give the `url` node start, node pull or node push printed for it, or\nadd ?node=<node> to the canvas link. Never the design's .html file, and never a link that holds a\n#ticket=; it signs in whoever opens it first.\n\n**Beside the chat, no links.** Once `canvas_app` shows the canvas, the user watches every change there.\nEnd with a short line on what you made or changed, naming designs by their labels. Put no canvas or\ndesign link in your replies, and don't ask the user to open the canvas. Give a link only when the user\nasks for one.\n\n**A new canvas is private.** When you give the user a link, don't suggest they send it to anyone before sharing it.\n\n**Never turn sharing on by yourself.** Run `kombai canvas share --on` only when the user asks for a link others can open, and tell them in the reply that anyone with the link can now view it and teammates can edit it.\n";
|
|
32242
34271
|
}
|
|
32243
34272
|
});
|
|
32244
34273
|
|
|
@@ -32348,8 +34377,8 @@ var init_mcp = __esm({
|
|
|
32348
34377
|
});
|
|
32349
34378
|
|
|
32350
34379
|
// src/commands/node.js
|
|
32351
|
-
import
|
|
32352
|
-
import
|
|
34380
|
+
import fs19 from "node:fs/promises";
|
|
34381
|
+
import path21 from "node:path";
|
|
32353
34382
|
async function placeText(cc) {
|
|
32354
34383
|
try {
|
|
32355
34384
|
const read2 = (await cc.session.api.call({ method: "GET", path: `/design/canvases/${cc.canvasId}` })).body;
|
|
@@ -32391,10 +34420,10 @@ function rectFrom(value) {
|
|
|
32391
34420
|
return { x, y, w, h };
|
|
32392
34421
|
}
|
|
32393
34422
|
async function readDrawingFile(ctx, given2) {
|
|
32394
|
-
const file2 =
|
|
34423
|
+
const file2 = path21.resolve(ctx.cwd, given2);
|
|
32395
34424
|
let bytes;
|
|
32396
34425
|
try {
|
|
32397
|
-
bytes = new Uint8Array(await
|
|
34426
|
+
bytes = new Uint8Array(await fs19.readFile(file2));
|
|
32398
34427
|
} catch (error2) {
|
|
32399
34428
|
if (isErrno(error2, "ENOENT"))
|
|
32400
34429
|
throw new CliError("CLI_FILE_MISSING", `${file2} does not exist.`, { details: { path: file2 } });
|
|
@@ -32649,7 +34678,7 @@ async function pushDrawing(ctx, cc, projectId, nodeId, entry, saved) {
|
|
|
32649
34678
|
if (!saved && sent === entry.files.content) {
|
|
32650
34679
|
return { nodeId, status: "unchanged", version: entry.version, images: { uploaded: 0, stored: 0 } };
|
|
32651
34680
|
}
|
|
32652
|
-
const before = parseStored(await
|
|
34681
|
+
const before = parseStored(await fs19.readFile(baseFile(paths, nodeId, "content")).catch(() => null));
|
|
32653
34682
|
const images = await storeDrawingPicture(cc, projectId, drawing, file2, nodeId, before?.src);
|
|
32654
34683
|
const body = {
|
|
32655
34684
|
ifVersion: saved?.version ?? entry.version,
|
|
@@ -32726,7 +34755,7 @@ async function storeDrawingPicture(cc, projectId, drawing, file2, nodeId, stored
|
|
|
32726
34755
|
}
|
|
32727
34756
|
throw error2;
|
|
32728
34757
|
}
|
|
32729
|
-
if (image.sha256 !==
|
|
34758
|
+
if (image.sha256 !== path21.posix.basename(src).split(".")[0]) {
|
|
32730
34759
|
throw badDrawing(
|
|
32731
34760
|
file2,
|
|
32732
34761
|
nodeId,
|
|
@@ -32848,14 +34877,14 @@ async function explainGone(ctx, cc, nodeId, error2) {
|
|
|
32848
34877
|
}
|
|
32849
34878
|
async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
32850
34879
|
await removeRemotes(paths, nodeId);
|
|
32851
|
-
const dir =
|
|
32852
|
-
await
|
|
32853
|
-
if (files.html) await writeFileAtomic(
|
|
32854
|
-
if (files.overrides) await writeFileAtomic(
|
|
32855
|
-
if (files.content) await writeFileAtomic(
|
|
32856
|
-
await writeJsonAtomic(
|
|
34880
|
+
const dir = path21.join(paths.remote, `${nodeId}@v${stored.version}`);
|
|
34881
|
+
await fs19.mkdir(dir, { recursive: true });
|
|
34882
|
+
if (files.html) await writeFileAtomic(path21.join(dir, "node.html"), files.html, { mode: 420 });
|
|
34883
|
+
if (files.overrides) await writeFileAtomic(path21.join(dir, "node.overrides.json"), files.overrides, { mode: 420 });
|
|
34884
|
+
if (files.content) await writeFileAtomic(path21.join(dir, "node.content.json"), files.content, { mode: 420 });
|
|
34885
|
+
await writeJsonAtomic(path21.join(dir, "images.json"), stored.images ?? [], { mode: 420 });
|
|
32857
34886
|
await writeJsonAtomic(
|
|
32858
|
-
|
|
34887
|
+
path21.join(dir, "node.json"),
|
|
32859
34888
|
{ version: stored.version, state: stored.state, modifiedBy: stored.modifiedBy, node: stored.node },
|
|
32860
34889
|
{ mode: 420 }
|
|
32861
34890
|
);
|
|
@@ -32878,16 +34907,16 @@ async function saveConflict2(paths, canvasId, nodeId, stored, files) {
|
|
|
32878
34907
|
);
|
|
32879
34908
|
}
|
|
32880
34909
|
async function latestRemote2(paths, nodeId) {
|
|
32881
|
-
const names = await
|
|
34910
|
+
const names = await fs19.readdir(paths.remote).catch(() => (
|
|
32882
34911
|
/** @type {string[]} */
|
|
32883
34912
|
[]
|
|
32884
34913
|
));
|
|
32885
34914
|
const versions = names.map((name) => name.startsWith(`${nodeId}@v`) ? Number(name.slice(nodeId.length + 2)) : NaN).filter(Number.isInteger).sort((a, b) => b - a);
|
|
32886
34915
|
if (!versions.length) return null;
|
|
32887
|
-
const dir =
|
|
34916
|
+
const dir = path21.join(paths.remote, `${nodeId}@v${versions[0]}`);
|
|
32888
34917
|
const saved = (
|
|
32889
34918
|
/** @type {{ version?: number, node?: unknown } | undefined} */
|
|
32890
|
-
await readJson(
|
|
34919
|
+
await readJson(path21.join(dir, "node.json"))
|
|
32891
34920
|
);
|
|
32892
34921
|
const node = saved?.node && typeof saved.node === "object" ? (
|
|
32893
34922
|
/** @type {Record<string, unknown>} */
|
|
@@ -32909,7 +34938,7 @@ async function readNode(cc, nodeId) {
|
|
|
32909
34938
|
}
|
|
32910
34939
|
async function readWorking(paths, nodeId, kind) {
|
|
32911
34940
|
try {
|
|
32912
|
-
return new Uint8Array(await
|
|
34941
|
+
return new Uint8Array(await fs19.readFile(workingFile(paths, nodeId, kind)));
|
|
32913
34942
|
} catch (error2) {
|
|
32914
34943
|
if (isErrno(error2, "ENOENT")) return null;
|
|
32915
34944
|
throw error2;
|
|
@@ -32917,7 +34946,7 @@ async function readWorking(paths, nodeId, kind) {
|
|
|
32917
34946
|
}
|
|
32918
34947
|
async function baseCopies2(paths, nodeId, entry) {
|
|
32919
34948
|
const files = {};
|
|
32920
|
-
for (const kind of KINDS) if (entry.files[kind]) files[kind] = await
|
|
34949
|
+
for (const kind of KINDS) if (entry.files[kind]) files[kind] = await fs19.readFile(baseFile(paths, nodeId, kind));
|
|
32921
34950
|
return files;
|
|
32922
34951
|
}
|
|
32923
34952
|
var PUSH_TRIES, START_TRIES2, TEXT_SIZE, PLACEMENT_GAP, EMPTY_HTML, CONFLICT_MARKER, RECT_PROBLEM, DATA_KIDS_MODULE, STOPS_PUSH, nodeStart, nodePull, nodePush, nodeLock, nodeUnlock;
|
|
@@ -33052,11 +35081,11 @@ var init_node = __esm({
|
|
|
33052
35081
|
return Object.keys(base.nodes).length === 0 && Object.keys(base.starts).length === 0;
|
|
33053
35082
|
});
|
|
33054
35083
|
if (fresh && unused && (error2.status === 404 || error2.status === 410)) {
|
|
33055
|
-
const files = await
|
|
35084
|
+
const files = await fs19.readdir(paths.nodes).catch(() => (
|
|
33056
35085
|
/** @type {string[]} */
|
|
33057
35086
|
[]
|
|
33058
35087
|
));
|
|
33059
|
-
if (!files.length) await
|
|
35088
|
+
if (!files.length) await fs19.rm(paths.dir, { recursive: true, force: true });
|
|
33060
35089
|
}
|
|
33061
35090
|
}
|
|
33062
35091
|
throw await canvasGone(cc, error2);
|
|
@@ -33181,7 +35210,7 @@ var init_node = __esm({
|
|
|
33181
35210
|
type,
|
|
33182
35211
|
version: read2.version,
|
|
33183
35212
|
state: read2.state,
|
|
33184
|
-
file: info.file ?
|
|
35213
|
+
file: info.file ? path21.join(paths.dir, info.file) : null,
|
|
33185
35214
|
url: nodeLink(cc, nodeId),
|
|
33186
35215
|
overrides: files.overrides ? workingFile(paths, nodeId, "overrides") : null,
|
|
33187
35216
|
images: read2.images ?? [],
|
|
@@ -33409,7 +35438,7 @@ var init_pngtiles = __esm({
|
|
|
33409
35438
|
|
|
33410
35439
|
// src/commands/screenshot.js
|
|
33411
35440
|
import { execFile as execFile2 } from "node:child_process";
|
|
33412
|
-
import
|
|
35441
|
+
import path22 from "node:path";
|
|
33413
35442
|
async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
33414
35443
|
const tiles = png ? pngTiles(png, TILE_HEIGHT) : null;
|
|
33415
35444
|
if (!tiles) {
|
|
@@ -33420,8 +35449,8 @@ async function writeTiles(ctx, dir, nodeId, version2, png, screenshotFile) {
|
|
|
33420
35449
|
});
|
|
33421
35450
|
return [screenshotFile];
|
|
33422
35451
|
}
|
|
33423
|
-
if (tiles.length === 1) return [
|
|
33424
|
-
const files = tiles.map((_, i) =>
|
|
35452
|
+
if (tiles.length === 1) return [path22.join(dir, `${nodeId}@v${version2}.png`)];
|
|
35453
|
+
const files = tiles.map((_, i) => path22.join(dir, `${nodeId}@v${version2}.tile-${i + 1}.png`));
|
|
33425
35454
|
await Promise.all(files.map((file2, i) => writeFileAtomic(file2, tiles[i], { mode: 420 })));
|
|
33426
35455
|
return files;
|
|
33427
35456
|
}
|
|
@@ -33517,7 +35546,7 @@ var init_screenshot = __esm({
|
|
|
33517
35546
|
if (named2 && flags.canvas === void 0) {
|
|
33518
35547
|
throw new CliError("CLI_BAD_FLAG", "--node needs --canvas.", { next: "kombai screenshot fill --help" });
|
|
33519
35548
|
}
|
|
33520
|
-
const browserFlag = flags.browser === void 0 ? void 0 :
|
|
35549
|
+
const browserFlag = flags.browser === void 0 ? void 0 : path22.resolve(ctx.cwd, String(flags.browser));
|
|
33521
35550
|
if (browserFlag) {
|
|
33522
35551
|
await checkNamedBrowser(
|
|
33523
35552
|
browserFlag,
|
|
@@ -33725,14 +35754,14 @@ var init_screenshot = __esm({
|
|
|
33725
35754
|
if (shot.state === "ok" && shot.screenshot) {
|
|
33726
35755
|
const dir = canvasPaths(cc.work, canvasId).screenshots;
|
|
33727
35756
|
await ensureDir(dir);
|
|
33728
|
-
const screenshotFile =
|
|
35757
|
+
const screenshotFile = path22.join(dir, `${nodeId}@v${read2.version}.jpg`);
|
|
33729
35758
|
await writeFileAtomic(screenshotFile, await cc.session.api.download(shot.screenshot, deadline), {
|
|
33730
35759
|
mode: 420
|
|
33731
35760
|
});
|
|
33732
35761
|
let screenshotPngFile = null;
|
|
33733
35762
|
let png = null;
|
|
33734
35763
|
if (shot.screenshotPng) {
|
|
33735
|
-
screenshotPngFile =
|
|
35764
|
+
screenshotPngFile = path22.join(dir, `${nodeId}@v${read2.version}.png`);
|
|
33736
35765
|
png = await cc.session.api.download(shot.screenshotPng, deadline);
|
|
33737
35766
|
await writeFileAtomic(screenshotPngFile, png, { mode: 420 });
|
|
33738
35767
|
}
|
|
@@ -33795,7 +35824,7 @@ var init_screenshot = __esm({
|
|
|
33795
35824
|
);
|
|
33796
35825
|
}
|
|
33797
35826
|
ctx.stderr.write(
|
|
33798
|
-
`Download chrome-headless-shell ${PINNED_BUILD} (about 100 MB) into ${
|
|
35827
|
+
`Download chrome-headless-shell ${PINNED_BUILD} (about 100 MB) into ${path22.join(ctx.home, "browser")}? [y/N] `
|
|
33799
35828
|
);
|
|
33800
35829
|
if (!/^y(es)?$/i.test(await readLine())) throw new CliError("CLI_CANCELLED", "Nothing was downloaded.");
|
|
33801
35830
|
}
|
|
@@ -33805,7 +35834,7 @@ var init_screenshot = __esm({
|
|
|
33805
35834
|
/** @type {typeof import('../render/install-entry.js')} */
|
|
33806
35835
|
await import(INSTALL_MODULE)
|
|
33807
35836
|
);
|
|
33808
|
-
const executable = await installHeadlessShell(
|
|
35837
|
+
const executable = await installHeadlessShell(path22.join(ctx.home, "browser"), PINNED_BUILD);
|
|
33809
35838
|
const answer2 = await askVersion(executable, 3e4);
|
|
33810
35839
|
if (!answer2.version) {
|
|
33811
35840
|
throw new CliError(
|
|
@@ -33823,7 +35852,7 @@ var init_screenshot = __esm({
|
|
|
33823
35852
|
summary: "Save the path of a Chromium browser the search missed, after checking that it answers --version as Chromium. Clears a launch-failed skip.",
|
|
33824
35853
|
args: [{ name: "path", required: true }],
|
|
33825
35854
|
async run(ctx, { args }) {
|
|
33826
|
-
const browserPath =
|
|
35855
|
+
const browserPath = path22.resolve(ctx.cwd, args[0]);
|
|
33827
35856
|
await checkNamedBrowser(browserPath, "Give the path of a Chromium browser's program.");
|
|
33828
35857
|
const version2 = (ctx.platform === "win32" ? await fileVersion(browserPath) : null) ?? (await askVersion(browserPath)).version;
|
|
33829
35858
|
if (!version2) {
|
|
@@ -33900,18 +35929,18 @@ var init_commands = __esm({
|
|
|
33900
35929
|
});
|
|
33901
35930
|
|
|
33902
35931
|
// src/lib/app-skills.js
|
|
33903
|
-
import { access, readdir, rm } from "node:fs/promises";
|
|
33904
|
-
import
|
|
35932
|
+
import { access, lstat, readdir, rm } from "node:fs/promises";
|
|
35933
|
+
import path23 from "node:path";
|
|
33905
35934
|
function appSkillDirsOf(home, env) {
|
|
33906
35935
|
const dirs = [
|
|
33907
|
-
|
|
33908
|
-
|
|
33909
|
-
|
|
33910
|
-
|
|
33911
|
-
|
|
33912
|
-
|
|
35936
|
+
path23.join(home, ".claude", "skills"),
|
|
35937
|
+
path23.join(home, ".agents", "skills"),
|
|
35938
|
+
path23.join(home, ".cursor", "skills"),
|
|
35939
|
+
path23.join(home, ".copilot", "skills"),
|
|
35940
|
+
path23.join(home, ".gemini", "skills"),
|
|
35941
|
+
path23.join(home, ".gemini", "config", "skills")
|
|
33913
35942
|
];
|
|
33914
|
-
if (env.CLAUDE_CONFIG_DIR) dirs.push(
|
|
35943
|
+
if (env.CLAUDE_CONFIG_DIR) dirs.push(path23.join(path23.resolve(env.CLAUDE_CONFIG_DIR), "skills"));
|
|
33915
35944
|
return [...new Set(dirs)];
|
|
33916
35945
|
}
|
|
33917
35946
|
async function removeAppSkillsOnce(ctx) {
|
|
@@ -33937,26 +35966,37 @@ async function removeAppSkills(dirs) {
|
|
|
33937
35966
|
try {
|
|
33938
35967
|
names = await readdir(dir);
|
|
33939
35968
|
} catch (error2) {
|
|
33940
|
-
|
|
33941
|
-
/** @type {NodeJS.ErrnoException} */
|
|
33942
|
-
error2.code
|
|
33943
|
-
);
|
|
33944
|
-
return code2 === "ENOENT" || code2 === "ENOTDIR";
|
|
35969
|
+
return isAbsent(error2);
|
|
33945
35970
|
}
|
|
33946
35971
|
const removed = await Promise.all(
|
|
33947
|
-
names.filter((name) => APP_SKILL_NAMES.has(name)).map(
|
|
33948
|
-
(name) => rm(path21.join(dir, name), { recursive: true, force: true }).then(
|
|
33949
|
-
() => true,
|
|
33950
|
-
() => false
|
|
33951
|
-
)
|
|
33952
|
-
)
|
|
35972
|
+
names.filter((name) => APP_SKILL_NAMES.has(name)).map((name) => removeIfApps(path23.join(dir, name)))
|
|
33953
35973
|
);
|
|
33954
35974
|
return removed.every(Boolean);
|
|
33955
35975
|
})
|
|
33956
35976
|
);
|
|
33957
35977
|
return done.every(Boolean);
|
|
33958
35978
|
}
|
|
33959
|
-
|
|
35979
|
+
async function removeIfApps(folder) {
|
|
35980
|
+
try {
|
|
35981
|
+
await access(path23.join(folder, APP_MARKER));
|
|
35982
|
+
} catch (error2) {
|
|
35983
|
+
return isAbsent(error2);
|
|
35984
|
+
}
|
|
35985
|
+
try {
|
|
35986
|
+
if ((await lstat(folder)).isDirectory()) {
|
|
35987
|
+
const names = (await readdir(folder)).filter((name) => name !== APP_MARKER);
|
|
35988
|
+
await Promise.all(names.map((name) => rm(path23.join(folder, name), { recursive: true, force: true })));
|
|
35989
|
+
}
|
|
35990
|
+
await rm(folder, { recursive: true, force: true });
|
|
35991
|
+
return true;
|
|
35992
|
+
} catch {
|
|
35993
|
+
return false;
|
|
35994
|
+
}
|
|
35995
|
+
}
|
|
35996
|
+
function isAbsent(error2) {
|
|
35997
|
+
return isErrno(error2, "ENOENT") || isErrno(error2, "ENOTDIR");
|
|
35998
|
+
}
|
|
35999
|
+
var APP_SKILL_NAMES, APP_MARKER;
|
|
33960
36000
|
var init_app_skills = __esm({
|
|
33961
36001
|
"src/lib/app-skills.js"() {
|
|
33962
36002
|
"use strict";
|
|
@@ -33977,6 +36017,7 @@ var init_app_skills = __esm({
|
|
|
33977
36017
|
"diagnose-kombai",
|
|
33978
36018
|
"open-in-kombai"
|
|
33979
36019
|
]);
|
|
36020
|
+
APP_MARKER = ".kombai-skill";
|
|
33980
36021
|
}
|
|
33981
36022
|
});
|
|
33982
36023
|
|
|
@@ -34395,14 +36436,14 @@ var init_telemetry = __esm({
|
|
|
34395
36436
|
// src/lib/context.js
|
|
34396
36437
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
34397
36438
|
import os4 from "node:os";
|
|
34398
|
-
import
|
|
36439
|
+
import path24 from "node:path";
|
|
34399
36440
|
function createContext(overrides = {}) {
|
|
34400
36441
|
const platform2 = overrides.platform ?? process.platform;
|
|
34401
36442
|
const stdout = overrides.stdout ?? process.stdout;
|
|
34402
36443
|
const ctx = {
|
|
34403
36444
|
stdout,
|
|
34404
36445
|
stderr: process.stderr,
|
|
34405
|
-
home:
|
|
36446
|
+
home: path24.join(os4.homedir(), ".kombai", "cli"),
|
|
34406
36447
|
cwd: process.cwd(),
|
|
34407
36448
|
fetch: globalThis.fetch,
|
|
34408
36449
|
now: Date.now,
|