create-tldraw 4.0.2 → 4.1.0-canary.0259516ffb8c
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 +62 -49
- 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
|
}
|
|
@@ -7362,35 +7349,47 @@ var TEMPLATES = [
|
|
|
7362
7349
|
order: 1,
|
|
7363
7350
|
repo: "tldraw/vite-template"
|
|
7364
7351
|
},
|
|
7352
|
+
{
|
|
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"
|
|
7358
|
+
},
|
|
7365
7359
|
{
|
|
7366
7360
|
name: "Agent",
|
|
7367
|
-
description: "
|
|
7361
|
+
description: "Work on the canvas with an AI agent.",
|
|
7368
7362
|
shortDescription: "An AI-powered agent.",
|
|
7363
|
+
order: 3,
|
|
7369
7364
|
repo: "tldraw/agent-template"
|
|
7370
7365
|
},
|
|
7371
7366
|
{
|
|
7372
|
-
name: "
|
|
7373
|
-
description: "Create
|
|
7374
|
-
shortDescription: "
|
|
7375
|
-
|
|
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"
|
|
7376
7372
|
},
|
|
7377
7373
|
{
|
|
7378
7374
|
name: "Chat",
|
|
7379
|
-
description: "
|
|
7375
|
+
description: "Create an AI chat that uses tldraw for sketches and annotations.",
|
|
7380
7376
|
shortDescription: "A chat UI with sketches and images as context for AI.",
|
|
7377
|
+
order: 5,
|
|
7381
7378
|
repo: "tldraw/chat-template"
|
|
7382
7379
|
},
|
|
7383
7380
|
{
|
|
7384
|
-
name: "
|
|
7385
|
-
description: "
|
|
7386
|
-
shortDescription: "
|
|
7387
|
-
|
|
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"
|
|
7388
7386
|
},
|
|
7389
7387
|
{
|
|
7390
|
-
name: "
|
|
7391
|
-
description: "
|
|
7392
|
-
shortDescription: "
|
|
7393
|
-
|
|
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"
|
|
7394
7393
|
}
|
|
7395
7394
|
];
|
|
7396
7395
|
|
|
@@ -7431,7 +7430,7 @@ function toValidPackageName(projectName) {
|
|
|
7431
7430
|
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z\d\-~]+/g, "-");
|
|
7432
7431
|
}
|
|
7433
7432
|
function cancel() {
|
|
7434
|
-
Fe("Setup cancelled.\n
|
|
7433
|
+
Fe("Setup cancelled.\n Try again or visit https://tldraw.dev/docs to learn more.");
|
|
7435
7434
|
process.exit(1);
|
|
7436
7435
|
}
|
|
7437
7436
|
async function uncancel(promise) {
|
|
@@ -7475,14 +7474,13 @@ function getRunCommand(manager, command) {
|
|
|
7475
7474
|
// src/main.ts
|
|
7476
7475
|
var DEBUG = !!import_node_process4.default.env.DEBUG;
|
|
7477
7476
|
async function main() {
|
|
7478
|
-
Ge(`Let's build a tldraw app!`);
|
|
7479
7477
|
const args = b(import_node_process4.default.argv.slice(2), {
|
|
7480
7478
|
alias: {
|
|
7481
7479
|
h: "help",
|
|
7482
7480
|
t: "template",
|
|
7483
7481
|
o: "overwrite"
|
|
7484
7482
|
},
|
|
7485
|
-
boolean: ["help", "overwrite"],
|
|
7483
|
+
boolean: ["help", "overwrite", "no-telemetry"],
|
|
7486
7484
|
string: ["template"]
|
|
7487
7485
|
});
|
|
7488
7486
|
if (args.help) {
|
|
@@ -7491,7 +7489,7 @@ async function main() {
|
|
|
7491
7489
|
}
|
|
7492
7490
|
const maybeTargetDir = args._[0] ? formatTargetDir((0, import_node_path11.resolve)(String(args._[0]))) : void 0;
|
|
7493
7491
|
const targetDir = maybeTargetDir ?? import_node_process4.default.cwd();
|
|
7494
|
-
const template = await templatePicker(args.template);
|
|
7492
|
+
const template = await templatePicker(args.template, args["no-telemetry"]);
|
|
7495
7493
|
const name2 = await namePicker(maybeTargetDir);
|
|
7496
7494
|
await ensureDirectoryEmpty(targetDir, args.overwrite);
|
|
7497
7495
|
await downloadTemplate(template, targetDir);
|
|
@@ -7504,7 +7502,7 @@ async function main() {
|
|
|
7504
7502
|
doneMessage.push(` ${getInstallCommand(manager)}`);
|
|
7505
7503
|
doneMessage.push(` ${getRunCommand(manager, "dev")}`);
|
|
7506
7504
|
doneMessage.push("");
|
|
7507
|
-
doneMessage.push(" Happy building!");
|
|
7505
|
+
doneMessage.push(" Happy building! Visit https://tldraw.dev/docs to learn more.");
|
|
7508
7506
|
Fe(doneMessage.join("\n"));
|
|
7509
7507
|
}
|
|
7510
7508
|
main().catch((err) => {
|
|
@@ -7512,27 +7510,41 @@ main().catch((err) => {
|
|
|
7512
7510
|
Fe(`it's bad`);
|
|
7513
7511
|
import_node_process4.default.exit(1);
|
|
7514
7512
|
});
|
|
7515
|
-
async function templatePicker(argOption) {
|
|
7513
|
+
async function templatePicker(argOption, noTelemetry) {
|
|
7516
7514
|
if (argOption) {
|
|
7517
|
-
const
|
|
7518
|
-
if (!
|
|
7515
|
+
const template2 = TEMPLATES.find((t) => formatTemplateId(t) === argOption.toLowerCase().trim());
|
|
7516
|
+
if (!template2) {
|
|
7519
7517
|
Fe(`Template ${argOption} not found`);
|
|
7520
7518
|
import_node_process4.default.exit(1);
|
|
7521
7519
|
}
|
|
7522
|
-
|
|
7520
|
+
trackStarterKitChoice(template2.name, noTelemetry);
|
|
7521
|
+
return template2;
|
|
7523
7522
|
}
|
|
7524
|
-
|
|
7523
|
+
const template = await uncancel(
|
|
7525
7524
|
groupSelect({
|
|
7526
|
-
message: "Select a
|
|
7525
|
+
message: "Select a tldraw starter kit:",
|
|
7527
7526
|
options: TEMPLATES.map(
|
|
7528
|
-
(
|
|
7529
|
-
label:
|
|
7530
|
-
hint:
|
|
7531
|
-
value:
|
|
7527
|
+
(template2) => ({
|
|
7528
|
+
label: template2.name,
|
|
7529
|
+
hint: template2.description,
|
|
7530
|
+
value: template2
|
|
7532
7531
|
})
|
|
7533
7532
|
)
|
|
7534
7533
|
})
|
|
7535
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
|
+
});
|
|
7536
7548
|
}
|
|
7537
7549
|
async function namePicker(argOption) {
|
|
7538
7550
|
if (argOption) {
|
|
@@ -7541,11 +7553,11 @@ async function namePicker(argOption) {
|
|
|
7541
7553
|
const defaultName = pathToName(import_node_process4.default.cwd());
|
|
7542
7554
|
const name2 = await uncancel(
|
|
7543
7555
|
et({
|
|
7544
|
-
message: import_picocolors4.default.bold("Name your
|
|
7556
|
+
message: import_picocolors4.default.bold("Name your app"),
|
|
7545
7557
|
placeholder: defaultName,
|
|
7546
7558
|
validate: (value) => {
|
|
7547
7559
|
if (value && !isValidPackageName(value)) {
|
|
7548
|
-
return `Invalid
|
|
7560
|
+
return `Invalid name: ${value}`;
|
|
7549
7561
|
}
|
|
7550
7562
|
return void 0;
|
|
7551
7563
|
}
|
|
@@ -7625,7 +7637,8 @@ function getHelp() {
|
|
|
7625
7637
|
const options = [
|
|
7626
7638
|
{ flags: "-h, --help", description: "Display this help message." },
|
|
7627
7639
|
{ flags: "-t, --template NAME", description: "Use a specific template." },
|
|
7628
|
-
{ 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." }
|
|
7629
7642
|
];
|
|
7630
7643
|
const GAP_SIZE = 2;
|
|
7631
7644
|
const optionPrefix = " ";
|
|
@@ -7638,7 +7651,7 @@ function getHelp() {
|
|
|
7638
7651
|
const lines = [
|
|
7639
7652
|
import_picocolors4.default.bold("Usage: create-tldraw [OPTION]... [DIRECTORY]"),
|
|
7640
7653
|
"",
|
|
7641
|
-
"Create a new tldraw project.",
|
|
7654
|
+
"Create a new tldraw project from a starter kit.",
|
|
7642
7655
|
"With no arguments, you'll be guided through an interactive setup.",
|
|
7643
7656
|
"",
|
|
7644
7657
|
import_picocolors4.default.bold("Options:")
|