create-tldraw 4.5.0-next.dad6df23ab1f → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/main.cjs +40 -112
- package/dist-cjs/main.cjs.map +3 -3
- package/package.json +2 -2
package/dist-cjs/main.cjs
CHANGED
|
@@ -627,7 +627,6 @@ B = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), I = /* @__
|
|
|
627
627
|
// ../../node_modules/@clack/prompts/dist/index.mjs
|
|
628
628
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
629
629
|
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
630
|
-
var import_node_tty2 = require("node:tty");
|
|
631
630
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
632
631
|
function Pe() {
|
|
633
632
|
return import_node_process2.default.platform !== "win32" ? import_node_process2.default.env.TERM !== "linux" : !!import_node_process2.default.env.CI || !!import_node_process2.default.env.WT_SESSION || !!import_node_process2.default.env.TERMINUS_SUBLIME || import_node_process2.default.env.ConEmuTask === "{cmd::Cmder}" || import_node_process2.default.env.TERM_PROGRAM === "Terminus-Sublime" || import_node_process2.default.env.TERM_PROGRAM === "vscode" || import_node_process2.default.env.TERM === "xterm-256color" || import_node_process2.default.env.TERM === "alacritty" || import_node_process2.default.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
@@ -669,16 +668,6 @@ var E2 = (t) => {
|
|
|
669
668
|
return import_picocolors2.default.green(O2);
|
|
670
669
|
}
|
|
671
670
|
};
|
|
672
|
-
var j2 = (t) => {
|
|
673
|
-
const { cursor: i, options: r, style: s3 } = t, n = t.output ?? process.stdout, a = n instanceof import_node_tty2.WriteStream && n.rows !== void 0 ? n.rows : 10, l = import_picocolors2.default.dim("..."), c2 = t.maxItems ?? Number.POSITIVE_INFINITY, u3 = Math.max(a - 4, 0), $3 = Math.min(u3, Math.max(c2, 5));
|
|
674
|
-
let m3 = 0;
|
|
675
|
-
i >= m3 + $3 - 3 ? m3 = Math.max(Math.min(i - $3 + 3, r.length - $3), 0) : i < m3 + 2 && (m3 = Math.max(i - 2, 0));
|
|
676
|
-
const h3 = $3 < r.length && m3 > 0, g2 = $3 < r.length && m3 + $3 < r.length;
|
|
677
|
-
return r.slice(m3, m3 + $3).map((p4, d2, y3) => {
|
|
678
|
-
const w2 = d2 === 0 && h3, b4 = d2 === y3.length - 1 && g2;
|
|
679
|
-
return w2 || b4 ? l : s3(p4, d2 + m3 === i);
|
|
680
|
-
});
|
|
681
|
-
};
|
|
682
671
|
var Fe = (t = "", i) => {
|
|
683
672
|
(i?.output ?? process.stdout).write(`${import_picocolors2.default.gray(o)}
|
|
684
673
|
${import_picocolors2.default.gray(f2)} ${t}
|
|
@@ -735,38 +724,6 @@ var J2 = ({ indicator: t = "dots", onCancel: i, output: r = process.stdout, canc
|
|
|
735
724
|
} };
|
|
736
725
|
};
|
|
737
726
|
var de = { light: v2("\u2500", "-"), heavy: v2("\u2501", "="), block: v2("\u2588", "#") };
|
|
738
|
-
var ze = (t) => {
|
|
739
|
-
const i = (r, s3) => {
|
|
740
|
-
const n = r.label ?? String(r.value);
|
|
741
|
-
switch (s3) {
|
|
742
|
-
case "selected":
|
|
743
|
-
return `${import_picocolors2.default.dim(n)}`;
|
|
744
|
-
case "active":
|
|
745
|
-
return `${import_picocolors2.default.green(P2)} ${n} ${r.hint ? import_picocolors2.default.dim(`(${r.hint})`) : ""}`;
|
|
746
|
-
case "cancelled":
|
|
747
|
-
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(n))}`;
|
|
748
|
-
default:
|
|
749
|
-
return `${import_picocolors2.default.dim(L2)} ${import_picocolors2.default.dim(n)}`;
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
return new Xu({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
753
|
-
const r = `${import_picocolors2.default.gray(o)}
|
|
754
|
-
${E2(this.state)} ${t.message}
|
|
755
|
-
`;
|
|
756
|
-
switch (this.state) {
|
|
757
|
-
case "submit":
|
|
758
|
-
return `${r}${import_picocolors2.default.gray(o)} ${i(this.options[this.cursor], "selected")}`;
|
|
759
|
-
case "cancel":
|
|
760
|
-
return `${r}${import_picocolors2.default.gray(o)} ${i(this.options[this.cursor], "cancelled")}
|
|
761
|
-
${import_picocolors2.default.gray(o)}`;
|
|
762
|
-
default:
|
|
763
|
-
return `${r}${import_picocolors2.default.cyan(o)} ${j2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (s3, n) => i(s3, n ? "active" : "inactive") }).join(`
|
|
764
|
-
${import_picocolors2.default.cyan(o)} `)}
|
|
765
|
-
${import_picocolors2.default.cyan(f2)}
|
|
766
|
-
`;
|
|
767
|
-
}
|
|
768
|
-
} }).prompt();
|
|
769
|
-
};
|
|
770
727
|
var he = `${import_picocolors2.default.gray(o)} `;
|
|
771
728
|
var et = (t) => new eD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
772
729
|
const i = `${import_picocolors2.default.gray(o)}
|
|
@@ -792,7 +749,7 @@ ${import_picocolors2.default.cyan(f2)}
|
|
|
792
749
|
|
|
793
750
|
// src/main.ts
|
|
794
751
|
var import_node_fs8 = require("node:fs");
|
|
795
|
-
var import_node_path11 =
|
|
752
|
+
var import_node_path11 = require("node:path");
|
|
796
753
|
var import_node_process4 = __toESM(require("node:process"));
|
|
797
754
|
var import_node_stream2 = require("node:stream");
|
|
798
755
|
var import_picocolors4 = __toESM(require_picocolors());
|
|
@@ -841,9 +798,9 @@ var Cr = (s3) => !!s3 && typeof s3 == "object" && (s3 instanceof A2 || s3 instan
|
|
|
841
798
|
var Fr = (s3) => !!s3 && typeof s3 == "object" && s3 instanceof import_node_events.EventEmitter && typeof s3.pipe == "function" && s3.pipe !== import_node_stream.default.Writable.prototype.pipe;
|
|
842
799
|
var kr = (s3) => !!s3 && typeof s3 == "object" && s3 instanceof import_node_events.EventEmitter && typeof s3.write == "function" && typeof s3.end == "function";
|
|
843
800
|
var q3 = Symbol("EOF");
|
|
844
|
-
var
|
|
801
|
+
var j2 = Symbol("maybeEmitEnd");
|
|
845
802
|
var rt = Symbol("emittedEnd");
|
|
846
|
-
var
|
|
803
|
+
var xe = Symbol("emittingEnd");
|
|
847
804
|
var jt = Symbol("emittedError");
|
|
848
805
|
var Le = Symbol("closed");
|
|
849
806
|
var xs = Symbol("read");
|
|
@@ -914,7 +871,7 @@ var A2 = class extends import_node_events.EventEmitter {
|
|
|
914
871
|
[Mt];
|
|
915
872
|
[q3] = false;
|
|
916
873
|
[rt] = false;
|
|
917
|
-
[
|
|
874
|
+
[xe] = false;
|
|
918
875
|
[Le] = false;
|
|
919
876
|
[jt] = null;
|
|
920
877
|
[_2] = 0;
|
|
@@ -979,10 +936,10 @@ var A2 = class extends import_node_events.EventEmitter {
|
|
|
979
936
|
}
|
|
980
937
|
read(t) {
|
|
981
938
|
if (this[w]) return null;
|
|
982
|
-
if (this[C3] = false, this[_2] === 0 || t === 0 || t && t > this[_2]) return this[
|
|
939
|
+
if (this[C3] = false, this[_2] === 0 || t === 0 || t && t > this[_2]) return this[j2](), null;
|
|
983
940
|
this[L3] && (t = null), this[g].length > 1 && !this[L3] && (this[g] = [this[z2] ? this[g].join("") : Buffer.concat(this[g], this[_2])]);
|
|
984
941
|
let e2 = this[xs](t || null, this[g][0]);
|
|
985
|
-
return this[
|
|
942
|
+
return this[j2](), e2;
|
|
986
943
|
}
|
|
987
944
|
[xs](t, e2) {
|
|
988
945
|
if (this[L3]) this[De]();
|
|
@@ -993,10 +950,10 @@ var A2 = class extends import_node_events.EventEmitter {
|
|
|
993
950
|
return this.emit("data", e2), !this[g].length && !this[q3] && this.emit("drain"), e2;
|
|
994
951
|
}
|
|
995
952
|
end(t, e2, i) {
|
|
996
|
-
return typeof t == "function" && (i = t, t = void 0), typeof e2 == "function" && (i = e2, e2 = "utf8"), t !== void 0 && this.write(t, e2), i && this.once("end", i), this[q3] = true, this.writable = false, (this[b3] || !this[Qt]) && this[
|
|
953
|
+
return typeof t == "function" && (i = t, t = void 0), typeof e2 == "function" && (i = e2, e2 = "utf8"), t !== void 0 && this.write(t, e2), i && this.once("end", i), this[q3] = true, this.writable = false, (this[b3] || !this[Qt]) && this[j2](), this;
|
|
997
954
|
}
|
|
998
955
|
[Bt]() {
|
|
999
|
-
this[w] || (!this[yt] && !this[D2].length && (this[C3] = true), this[Qt] = false, this[b3] = true, this.emit("resume"), this[g].length ? this[Ne]() : this[q3] ? this[
|
|
956
|
+
this[w] || (!this[yt] && !this[D2].length && (this[C3] = true), this[Qt] = false, this[b3] = true, this.emit("resume"), this[g].length ? this[Ne]() : this[q3] ? this[j2]() : this.emit("drain"));
|
|
1000
957
|
}
|
|
1001
958
|
resume() {
|
|
1002
959
|
return this[Bt]();
|
|
@@ -1066,8 +1023,8 @@ var A2 = class extends import_node_events.EventEmitter {
|
|
|
1066
1023
|
get emittedEnd() {
|
|
1067
1024
|
return this[rt];
|
|
1068
1025
|
}
|
|
1069
|
-
[
|
|
1070
|
-
!this[
|
|
1026
|
+
[j2]() {
|
|
1027
|
+
!this[xe] && !this[rt] && !this[w] && this[g].length === 0 && this[q3] && (this[xe] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Le] && this.emit("close"), this[xe] = false);
|
|
1071
1028
|
}
|
|
1072
1029
|
emit(t, ...e2) {
|
|
1073
1030
|
let i = e2[0];
|
|
@@ -1081,21 +1038,21 @@ var A2 = class extends import_node_events.EventEmitter {
|
|
|
1081
1038
|
} else if (t === "error") {
|
|
1082
1039
|
this[jt] = i, super.emit(yi, i);
|
|
1083
1040
|
let n = !this[Jt] || this.listeners("error").length ? super.emit("error", i) : false;
|
|
1084
|
-
return this[
|
|
1041
|
+
return this[j2](), n;
|
|
1085
1042
|
} else if (t === "resume") {
|
|
1086
1043
|
let n = super.emit("resume");
|
|
1087
|
-
return this[
|
|
1044
|
+
return this[j2](), n;
|
|
1088
1045
|
} else if (t === "finish" || t === "prefinish") {
|
|
1089
1046
|
let n = super.emit(t);
|
|
1090
1047
|
return this.removeAllListeners(t), n;
|
|
1091
1048
|
}
|
|
1092
1049
|
let r = super.emit(t, ...e2);
|
|
1093
|
-
return this[
|
|
1050
|
+
return this[j2](), r;
|
|
1094
1051
|
}
|
|
1095
1052
|
[Ri](t) {
|
|
1096
1053
|
for (let i of this[D2]) i.dest.write(t) === false && this.pause();
|
|
1097
1054
|
let e2 = this[C3] ? false : super.emit("data", t);
|
|
1098
|
-
return this[
|
|
1055
|
+
return this[j2](), e2;
|
|
1099
1056
|
}
|
|
1100
1057
|
[Ns]() {
|
|
1101
1058
|
return this[rt] ? false : (this[rt] = true, this.readable = false, this[Z2] ? (te(() => this[bi]()), true) : this[bi]());
|
|
@@ -1578,17 +1535,17 @@ var Pe2 = class extends Me {
|
|
|
1578
1535
|
super(t, "Unzip");
|
|
1579
1536
|
}
|
|
1580
1537
|
};
|
|
1581
|
-
var
|
|
1538
|
+
var ze = class extends ne2 {
|
|
1582
1539
|
constructor(t, e2) {
|
|
1583
1540
|
t = t || {}, t.flush = t.flush || M2.BROTLI_OPERATION_PROCESS, t.finishFlush = t.finishFlush || M2.BROTLI_OPERATION_FINISH, t.fullFlushFlag = M2.BROTLI_OPERATION_FLUSH, super(t, e2);
|
|
1584
1541
|
}
|
|
1585
1542
|
};
|
|
1586
|
-
var Ue = class extends
|
|
1543
|
+
var Ue = class extends ze {
|
|
1587
1544
|
constructor(t) {
|
|
1588
1545
|
super(t, "BrotliCompress");
|
|
1589
1546
|
}
|
|
1590
1547
|
};
|
|
1591
|
-
var He = class extends
|
|
1548
|
+
var He = class extends ze {
|
|
1592
1549
|
constructor(t) {
|
|
1593
1550
|
super(t, "BrotliDecompress");
|
|
1594
1551
|
}
|
|
@@ -3703,7 +3660,7 @@ var wo = (s3) => {
|
|
|
3703
3660
|
|
|
3704
3661
|
// src/group-select.ts
|
|
3705
3662
|
var import_node_process3 = __toESM(require("node:process"));
|
|
3706
|
-
var
|
|
3663
|
+
var import_node_tty2 = require("node:tty");
|
|
3707
3664
|
var import_picocolors3 = __toESM(require_picocolors());
|
|
3708
3665
|
|
|
3709
3666
|
// ../../node_modules/ansi-styles/index.js
|
|
@@ -4246,8 +4203,8 @@ ${E2(this.state)} ${import_picocolors3.default.bold(opts.message)}
|
|
|
4246
4203
|
}
|
|
4247
4204
|
body.push(import_picocolors3.default.cyan(o), "\n", import_picocolors3.default.cyan(o), " ", selectedOption.hint);
|
|
4248
4205
|
const output = opts.output ?? import_node_process3.default.stdout;
|
|
4249
|
-
const columns = output instanceof
|
|
4250
|
-
const rows = output instanceof
|
|
4206
|
+
const columns = output instanceof import_node_tty2.WriteStream ? output.columns : 80;
|
|
4207
|
+
const rows = output instanceof import_node_tty2.WriteStream ? output.rows : 10;
|
|
4251
4208
|
const wrapped = wrapAnsi(body.join(""), columns, {
|
|
4252
4209
|
indent: [import_picocolors3.default.cyan(o), " "].join("")
|
|
4253
4210
|
});
|
|
@@ -4327,26 +4284,18 @@ var import_node_path10 = require("node:path");
|
|
|
4327
4284
|
function nicelog(...args) {
|
|
4328
4285
|
console.log(...args);
|
|
4329
4286
|
}
|
|
4330
|
-
function isDirEmpty(
|
|
4331
|
-
if (!(0, import_node_fs7.existsSync)(
|
|
4287
|
+
function isDirEmpty(path) {
|
|
4288
|
+
if (!(0, import_node_fs7.existsSync)(path)) {
|
|
4332
4289
|
return true;
|
|
4333
4290
|
}
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
}
|
|
4337
|
-
function emptyDir(dir) {
|
|
4338
|
-
if (!(0, import_node_fs7.existsSync)(dir)) {
|
|
4339
|
-
return;
|
|
4340
|
-
}
|
|
4341
|
-
for (const file of (0, import_node_fs7.readdirSync)(dir)) {
|
|
4342
|
-
if (file === ".git") {
|
|
4343
|
-
continue;
|
|
4344
|
-
}
|
|
4345
|
-
(0, import_node_fs7.rmSync)((0, import_node_path10.resolve)(dir, file), { recursive: true, force: true });
|
|
4291
|
+
if (!(0, import_node_fs7.lstatSync)(path).isDirectory()) {
|
|
4292
|
+
return false;
|
|
4346
4293
|
}
|
|
4294
|
+
const files = (0, import_node_fs7.readdirSync)(path);
|
|
4295
|
+
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
4347
4296
|
}
|
|
4348
|
-
function pathToName(
|
|
4349
|
-
return toValidPackageName((0, import_node_path10.basename)(formatTargetDir((0, import_node_path10.resolve)(
|
|
4297
|
+
function pathToName(path) {
|
|
4298
|
+
return toValidPackageName((0, import_node_path10.basename)(formatTargetDir((0, import_node_path10.resolve)(path))));
|
|
4350
4299
|
}
|
|
4351
4300
|
function formatTargetDir(targetDir) {
|
|
4352
4301
|
return targetDir.trim().replace(/[/\\]+$/g, "");
|
|
@@ -4405,10 +4354,9 @@ async function main() {
|
|
|
4405
4354
|
const args = b(import_node_process4.default.argv.slice(2), {
|
|
4406
4355
|
alias: {
|
|
4407
4356
|
h: "help",
|
|
4408
|
-
t: "template"
|
|
4409
|
-
o: "overwrite"
|
|
4357
|
+
t: "template"
|
|
4410
4358
|
},
|
|
4411
|
-
boolean: ["help", "
|
|
4359
|
+
boolean: ["help", "no-telemetry"],
|
|
4412
4360
|
string: ["template"]
|
|
4413
4361
|
});
|
|
4414
4362
|
if (args.help) {
|
|
@@ -4416,10 +4364,11 @@ async function main() {
|
|
|
4416
4364
|
import_node_process4.default.exit(0);
|
|
4417
4365
|
}
|
|
4418
4366
|
const maybeTargetDir = args._[0] ? formatTargetDir((0, import_node_path11.resolve)(String(args._[0]))) : void 0;
|
|
4419
|
-
const targetDir = maybeTargetDir ?? import_node_process4.default.cwd();
|
|
4420
4367
|
const template = await templatePicker(args.template, args["no-telemetry"]);
|
|
4421
4368
|
const name = await namePicker(maybeTargetDir);
|
|
4422
|
-
|
|
4369
|
+
const requestedDir = maybeTargetDir ?? (0, import_node_path11.resolve)(import_node_process4.default.cwd(), name);
|
|
4370
|
+
const targetDir = findAvailableDir(requestedDir);
|
|
4371
|
+
(0, import_node_fs8.mkdirSync)(targetDir, { recursive: true });
|
|
4423
4372
|
await downloadTemplate(template, targetDir);
|
|
4424
4373
|
await renameTemplate(name, targetDir);
|
|
4425
4374
|
const manager = getPackageManager();
|
|
@@ -4494,35 +4443,15 @@ async function namePicker(argOption) {
|
|
|
4494
4443
|
if (!name.trim()) return defaultName;
|
|
4495
4444
|
return pathToName(name);
|
|
4496
4445
|
}
|
|
4497
|
-
|
|
4446
|
+
function findAvailableDir(targetDir) {
|
|
4498
4447
|
if (isDirEmpty(targetDir)) {
|
|
4499
|
-
|
|
4500
|
-
return;
|
|
4501
|
-
}
|
|
4502
|
-
const overwrite = overwriteArg ? "yes" : await ze({
|
|
4503
|
-
message: import_picocolors4.default.bold(
|
|
4504
|
-
(targetDir === import_node_process4.default.cwd() ? "Current directory" : `Target directory "${import_node_path11.default.relative(import_node_process4.default.cwd(), targetDir)}"`) + ` is not empty.`
|
|
4505
|
-
),
|
|
4506
|
-
options: [
|
|
4507
|
-
{
|
|
4508
|
-
label: "Cancel",
|
|
4509
|
-
value: "no"
|
|
4510
|
-
},
|
|
4511
|
-
{
|
|
4512
|
-
label: "Remove existing files and continue",
|
|
4513
|
-
value: "yes"
|
|
4514
|
-
},
|
|
4515
|
-
{
|
|
4516
|
-
label: "Ignore existing files and continue",
|
|
4517
|
-
value: "ignore"
|
|
4518
|
-
}
|
|
4519
|
-
]
|
|
4520
|
-
});
|
|
4521
|
-
if (overwrite === "no") {
|
|
4522
|
-
cancel();
|
|
4448
|
+
return targetDir;
|
|
4523
4449
|
}
|
|
4524
|
-
|
|
4525
|
-
|
|
4450
|
+
for (let i = 1; ; i++) {
|
|
4451
|
+
const candidate = `${targetDir}-${i}`;
|
|
4452
|
+
if (isDirEmpty(candidate)) {
|
|
4453
|
+
return candidate;
|
|
4454
|
+
}
|
|
4526
4455
|
}
|
|
4527
4456
|
}
|
|
4528
4457
|
async function downloadTemplate(template, targetDir) {
|
|
@@ -4565,7 +4494,6 @@ function getHelp() {
|
|
|
4565
4494
|
const options = [
|
|
4566
4495
|
{ flags: "-h, --help", description: "Display this help message." },
|
|
4567
4496
|
{ flags: "-t, --template NAME", description: "Use a specific template." },
|
|
4568
|
-
{ flags: "-o, --overwrite", description: "Overwrite the target directory if it exists." },
|
|
4569
4497
|
{ flags: "--no-telemetry", description: "Disable anonymous usage tracking." }
|
|
4570
4498
|
];
|
|
4571
4499
|
const GAP_SIZE = 2;
|