create-tldraw 4.1.0 → 4.1.2
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 +60 -53
- package/dist-cjs/main.cjs.map +3 -3
- package/package.json +2 -2
package/dist-cjs/main.cjs
CHANGED
|
@@ -679,10 +679,6 @@ var j2 = (t) => {
|
|
|
679
679
|
return w || b3 ? l : s(p3, d2 + m2 === i);
|
|
680
680
|
});
|
|
681
681
|
};
|
|
682
|
-
var Ge = (t = "", i) => {
|
|
683
|
-
(i?.output ?? process.stdout).write(`${import_picocolors2.default.gray(oe)} ${t}
|
|
684
|
-
`);
|
|
685
|
-
};
|
|
686
682
|
var Fe = (t = "", i) => {
|
|
687
683
|
(i?.output ?? process.stdout).write(`${import_picocolors2.default.gray(o)}
|
|
688
684
|
${import_picocolors2.default.gray(f2)} ${t}
|
|
@@ -7282,17 +7278,7 @@ function groupSelect(opts) {
|
|
|
7282
7278
|
if (state !== "active") {
|
|
7283
7279
|
return [import_picocolors3.default.dim(L2), " ", import_picocolors3.default.dim(label)].join("");
|
|
7284
7280
|
}
|
|
7285
|
-
return [
|
|
7286
|
-
import_picocolors3.default.green(P2),
|
|
7287
|
-
" ",
|
|
7288
|
-
import_picocolors3.default.bold(label),
|
|
7289
|
-
"\n ",
|
|
7290
|
-
import_picocolors3.default.cyan(o),
|
|
7291
|
-
" ",
|
|
7292
|
-
option.hint,
|
|
7293
|
-
"\n",
|
|
7294
|
-
import_picocolors3.default.cyan(o)
|
|
7295
|
-
].join("");
|
|
7281
|
+
return [import_picocolors3.default.green(P2), " ", import_picocolors3.default.bold(label)].join("");
|
|
7296
7282
|
};
|
|
7297
7283
|
return new Xu({
|
|
7298
7284
|
options: opts.options,
|
|
@@ -7337,6 +7323,7 @@ ${E2(this.state)} ${import_picocolors3.default.bold(opts.message)}
|
|
|
7337
7323
|
);
|
|
7338
7324
|
previousGroup = option.group;
|
|
7339
7325
|
}
|
|
7326
|
+
body.push(import_picocolors3.default.cyan(o), "\n", import_picocolors3.default.cyan(o), " ", selectedOption.hint);
|
|
7340
7327
|
const output = opts.output ?? import_node_process3.default.stdout;
|
|
7341
7328
|
const columns = output instanceof import_node_tty3.WriteStream ? output.columns : 80;
|
|
7342
7329
|
const rows = output instanceof import_node_tty3.WriteStream ? output.rows : 10;
|
|
@@ -7349,7 +7336,7 @@ ${E2(this.state)} ${import_picocolors3.default.bold(opts.message)}
|
|
|
7349
7336
|
P2,
|
|
7350
7337
|
[import_picocolors3.default.cyan(o), import_picocolors3.default.dim(" ...")].join("")
|
|
7351
7338
|
);
|
|
7352
|
-
return [title, limited].join("");
|
|
7339
|
+
return [title, import_picocolors3.default.cyan(o), "\n", limited].join("");
|
|
7353
7340
|
}
|
|
7354
7341
|
}).prompt();
|
|
7355
7342
|
}
|
|
@@ -7363,40 +7350,46 @@ var TEMPLATES = [
|
|
|
7363
7350
|
repo: "tldraw/vite-template"
|
|
7364
7351
|
},
|
|
7365
7352
|
{
|
|
7366
|
-
name: "
|
|
7367
|
-
description: "
|
|
7368
|
-
|
|
7369
|
-
|
|
7353
|
+
name: "Multiplayer",
|
|
7354
|
+
description: "Real-time multiplayer with a self-hosted backend.",
|
|
7355
|
+
shortDescription: "Real-time multiplayer.",
|
|
7356
|
+
order: 2,
|
|
7357
|
+
repo: "tldraw/tldraw-sync-cloudflare"
|
|
7370
7358
|
},
|
|
7371
7359
|
{
|
|
7372
7360
|
name: "Agent",
|
|
7373
|
-
description: "
|
|
7361
|
+
description: "Work on the canvas with an AI agent.",
|
|
7374
7362
|
shortDescription: "An AI-powered agent.",
|
|
7363
|
+
order: 3,
|
|
7375
7364
|
repo: "tldraw/agent-template"
|
|
7376
7365
|
},
|
|
7377
7366
|
{
|
|
7378
|
-
name: "
|
|
7379
|
-
description: "Create
|
|
7380
|
-
shortDescription: "
|
|
7381
|
-
|
|
7367
|
+
name: "Workflow",
|
|
7368
|
+
description: "Create a node-based builder for visual workflows.",
|
|
7369
|
+
shortDescription: "Visual node-based builder for workflows.",
|
|
7370
|
+
order: 4,
|
|
7371
|
+
repo: "tldraw/workflow-template"
|
|
7382
7372
|
},
|
|
7383
7373
|
{
|
|
7384
7374
|
name: "Chat",
|
|
7385
|
-
description: "
|
|
7375
|
+
description: "Create an AI chat that uses tldraw for sketches and annotations.",
|
|
7386
7376
|
shortDescription: "A chat UI with sketches and images as context for AI.",
|
|
7377
|
+
order: 5,
|
|
7387
7378
|
repo: "tldraw/chat-template"
|
|
7388
7379
|
},
|
|
7389
7380
|
{
|
|
7390
|
-
name: "
|
|
7391
|
-
description: "
|
|
7392
|
-
shortDescription: "
|
|
7393
|
-
|
|
7381
|
+
name: "Branching chat",
|
|
7382
|
+
description: "Chat with an AI using a branching conversation interface.",
|
|
7383
|
+
shortDescription: "A branching chat interface.",
|
|
7384
|
+
order: 6,
|
|
7385
|
+
repo: "tldraw/branching-chat-template"
|
|
7394
7386
|
},
|
|
7395
7387
|
{
|
|
7396
|
-
name: "
|
|
7397
|
-
description: "
|
|
7398
|
-
shortDescription: "
|
|
7399
|
-
|
|
7388
|
+
name: "Shader",
|
|
7389
|
+
description: "Create WebGL shaders that respond to shapes on the canvas.",
|
|
7390
|
+
shortDescription: "Shaders on the canvas.",
|
|
7391
|
+
order: 7,
|
|
7392
|
+
repo: "tldraw/shader-starter-kit"
|
|
7400
7393
|
}
|
|
7401
7394
|
];
|
|
7402
7395
|
|
|
@@ -7437,7 +7430,7 @@ function toValidPackageName(projectName) {
|
|
|
7437
7430
|
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z\d\-~]+/g, "-");
|
|
7438
7431
|
}
|
|
7439
7432
|
function cancel() {
|
|
7440
|
-
Fe("Setup cancelled.\n
|
|
7433
|
+
Fe("Setup cancelled.\n Try again or visit https://tldraw.dev/docs to learn more.");
|
|
7441
7434
|
process.exit(1);
|
|
7442
7435
|
}
|
|
7443
7436
|
async function uncancel(promise) {
|
|
@@ -7481,14 +7474,13 @@ function getRunCommand(manager, command) {
|
|
|
7481
7474
|
// src/main.ts
|
|
7482
7475
|
var DEBUG = !!import_node_process4.default.env.DEBUG;
|
|
7483
7476
|
async function main() {
|
|
7484
|
-
Ge(`Let's build a tldraw app!`);
|
|
7485
7477
|
const args = b(import_node_process4.default.argv.slice(2), {
|
|
7486
7478
|
alias: {
|
|
7487
7479
|
h: "help",
|
|
7488
7480
|
t: "template",
|
|
7489
7481
|
o: "overwrite"
|
|
7490
7482
|
},
|
|
7491
|
-
boolean: ["help", "overwrite"],
|
|
7483
|
+
boolean: ["help", "overwrite", "no-telemetry"],
|
|
7492
7484
|
string: ["template"]
|
|
7493
7485
|
});
|
|
7494
7486
|
if (args.help) {
|
|
@@ -7497,7 +7489,7 @@ async function main() {
|
|
|
7497
7489
|
}
|
|
7498
7490
|
const maybeTargetDir = args._[0] ? formatTargetDir((0, import_node_path11.resolve)(String(args._[0]))) : void 0;
|
|
7499
7491
|
const targetDir = maybeTargetDir ?? import_node_process4.default.cwd();
|
|
7500
|
-
const template = await templatePicker(args.template);
|
|
7492
|
+
const template = await templatePicker(args.template, args["no-telemetry"]);
|
|
7501
7493
|
const name2 = await namePicker(maybeTargetDir);
|
|
7502
7494
|
await ensureDirectoryEmpty(targetDir, args.overwrite);
|
|
7503
7495
|
await downloadTemplate(template, targetDir);
|
|
@@ -7510,7 +7502,7 @@ async function main() {
|
|
|
7510
7502
|
doneMessage.push(` ${getInstallCommand(manager)}`);
|
|
7511
7503
|
doneMessage.push(` ${getRunCommand(manager, "dev")}`);
|
|
7512
7504
|
doneMessage.push("");
|
|
7513
|
-
doneMessage.push(" Happy building!");
|
|
7505
|
+
doneMessage.push(" Happy building! Visit https://tldraw.dev/docs to learn more.");
|
|
7514
7506
|
Fe(doneMessage.join("\n"));
|
|
7515
7507
|
}
|
|
7516
7508
|
main().catch((err) => {
|
|
@@ -7518,27 +7510,41 @@ main().catch((err) => {
|
|
|
7518
7510
|
Fe(`it's bad`);
|
|
7519
7511
|
import_node_process4.default.exit(1);
|
|
7520
7512
|
});
|
|
7521
|
-
async function templatePicker(argOption) {
|
|
7513
|
+
async function templatePicker(argOption, noTelemetry) {
|
|
7522
7514
|
if (argOption) {
|
|
7523
|
-
const
|
|
7524
|
-
if (!
|
|
7515
|
+
const template2 = TEMPLATES.find((t) => formatTemplateId(t) === argOption.toLowerCase().trim());
|
|
7516
|
+
if (!template2) {
|
|
7525
7517
|
Fe(`Template ${argOption} not found`);
|
|
7526
7518
|
import_node_process4.default.exit(1);
|
|
7527
7519
|
}
|
|
7528
|
-
|
|
7520
|
+
trackStarterKitChoice(template2.name, noTelemetry);
|
|
7521
|
+
return template2;
|
|
7529
7522
|
}
|
|
7530
|
-
|
|
7523
|
+
const template = await uncancel(
|
|
7531
7524
|
groupSelect({
|
|
7532
|
-
message: "Select a
|
|
7525
|
+
message: "Select a tldraw starter kit:",
|
|
7533
7526
|
options: TEMPLATES.map(
|
|
7534
|
-
(
|
|
7535
|
-
label:
|
|
7536
|
-
hint:
|
|
7537
|
-
value:
|
|
7527
|
+
(template2) => ({
|
|
7528
|
+
label: template2.name,
|
|
7529
|
+
hint: template2.description,
|
|
7530
|
+
value: template2
|
|
7538
7531
|
})
|
|
7539
7532
|
)
|
|
7540
7533
|
})
|
|
7541
7534
|
);
|
|
7535
|
+
trackStarterKitChoice(template.name, noTelemetry);
|
|
7536
|
+
return template;
|
|
7537
|
+
}
|
|
7538
|
+
function trackStarterKitChoice(templateId, noTelemetry) {
|
|
7539
|
+
if (noTelemetry) return;
|
|
7540
|
+
fetch("https://dashboard.tldraw.pro/api/starter-kit-choice", {
|
|
7541
|
+
method: "POST",
|
|
7542
|
+
headers: {
|
|
7543
|
+
"Content-Type": "application/json"
|
|
7544
|
+
},
|
|
7545
|
+
body: JSON.stringify({ id: templateId })
|
|
7546
|
+
}).catch(() => {
|
|
7547
|
+
});
|
|
7542
7548
|
}
|
|
7543
7549
|
async function namePicker(argOption) {
|
|
7544
7550
|
if (argOption) {
|
|
@@ -7547,11 +7553,11 @@ async function namePicker(argOption) {
|
|
|
7547
7553
|
const defaultName = pathToName(import_node_process4.default.cwd());
|
|
7548
7554
|
const name2 = await uncancel(
|
|
7549
7555
|
et({
|
|
7550
|
-
message: import_picocolors4.default.bold("Name your
|
|
7556
|
+
message: import_picocolors4.default.bold("Name your app"),
|
|
7551
7557
|
placeholder: defaultName,
|
|
7552
7558
|
validate: (value) => {
|
|
7553
7559
|
if (value && !isValidPackageName(value)) {
|
|
7554
|
-
return `Invalid
|
|
7560
|
+
return `Invalid name: ${value}`;
|
|
7555
7561
|
}
|
|
7556
7562
|
return void 0;
|
|
7557
7563
|
}
|
|
@@ -7631,7 +7637,8 @@ function getHelp() {
|
|
|
7631
7637
|
const options = [
|
|
7632
7638
|
{ flags: "-h, --help", description: "Display this help message." },
|
|
7633
7639
|
{ flags: "-t, --template NAME", description: "Use a specific template." },
|
|
7634
|
-
{ flags: "-o, --overwrite", description: "Overwrite the target directory if it exists." }
|
|
7640
|
+
{ flags: "-o, --overwrite", description: "Overwrite the target directory if it exists." },
|
|
7641
|
+
{ flags: "--no-telemetry", description: "Disable anonymous usage tracking." }
|
|
7635
7642
|
];
|
|
7636
7643
|
const GAP_SIZE = 2;
|
|
7637
7644
|
const optionPrefix = " ";
|
|
@@ -7644,7 +7651,7 @@ function getHelp() {
|
|
|
7644
7651
|
const lines = [
|
|
7645
7652
|
import_picocolors4.default.bold("Usage: create-tldraw [OPTION]... [DIRECTORY]"),
|
|
7646
7653
|
"",
|
|
7647
|
-
"Create a new tldraw project.",
|
|
7654
|
+
"Create a new tldraw project from a starter kit.",
|
|
7648
7655
|
"With no arguments, you'll be guided through an interactive setup.",
|
|
7649
7656
|
"",
|
|
7650
7657
|
import_picocolors4.default.bold("Options:")
|