clodable 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/.version +1 -1
- package/dist/clodable.mjs +1732 -475
- package/package.json +10 -10
package/dist/clodable.mjs
CHANGED
|
@@ -580,6 +580,11 @@ async function exec2(command, args, options) {
|
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
+
async function commandPath(command, cwd2 = process.cwd()) {
|
|
584
|
+
const probe = process.platform === "win32" ? await exec2("where", [command], { cwd: cwd2, timeout: 1e4 }) : await exec2("sh", ["-c", `command -v ${command}`], { cwd: cwd2, timeout: 1e4 });
|
|
585
|
+
const path2 = probe.stdout.split(/\r?\n/)[0]?.trim();
|
|
586
|
+
return probe.exitCode === 0 && path2 ? path2 : void 0;
|
|
587
|
+
}
|
|
583
588
|
async function hasCommand(command, cwd2 = process.cwd()) {
|
|
584
589
|
const probe = process.platform === "win32" ? await exec2("where", [command], { cwd: cwd2, timeout: 1e4 }) : await exec2("sh", ["-c", `command -v ${command}`], { cwd: cwd2, timeout: 1e4 });
|
|
585
590
|
return probe.exitCode === 0 && probe.stdout.trim().length > 0;
|
|
@@ -599,6 +604,9 @@ function configDir() {
|
|
|
599
604
|
}
|
|
600
605
|
return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "clodable");
|
|
601
606
|
}
|
|
607
|
+
function toolsDir() {
|
|
608
|
+
return process.env.CLODABLE_TOOLS_DIR || cacheDir();
|
|
609
|
+
}
|
|
602
610
|
function cacheDir() {
|
|
603
611
|
if (process.env.CLODABLE_CACHE_DIR) return process.env.CLODABLE_CACHE_DIR;
|
|
604
612
|
if (process.platform === "darwin") return join(homedir(), "Library", "Caches", "clodable");
|
|
@@ -843,6 +851,10 @@ function detectPackageManager(root) {
|
|
|
843
851
|
if (existsSync2(join3(root, "bun.lockb")) || existsSync2(join3(root, "bun.lock"))) return "bun";
|
|
844
852
|
return "npm";
|
|
845
853
|
}
|
|
854
|
+
async function packageManagerHere(project) {
|
|
855
|
+
if (project.packageManager === "npm") return "npm";
|
|
856
|
+
return await hasCommand(project.packageManager, project.root) ? project.packageManager : "npm";
|
|
857
|
+
}
|
|
846
858
|
function runScriptCommand(pm, script) {
|
|
847
859
|
switch (pm) {
|
|
848
860
|
case "pnpm":
|
|
@@ -1091,8 +1103,8 @@ function summarizeBuildOutput(output2, root) {
|
|
|
1091
1103
|
for (const prefix2 of root ? /* @__PURE__ */ new Set([root, realRoot(root)]) : []) {
|
|
1092
1104
|
clean2 = clean2.replaceAll(`${prefix2}${sep2}`, "");
|
|
1093
1105
|
}
|
|
1094
|
-
const lines = clean2.split("\n").map((
|
|
1095
|
-
const firstError = lines.findIndex((
|
|
1106
|
+
const lines = clean2.split("\n").map((l) => l.trimEnd());
|
|
1107
|
+
const firstError = lines.findIndex((l) => ERROR_LINE.test(l));
|
|
1096
1108
|
const start = Math.max(0, firstError >= 0 ? firstError - 1 : lines.length - 12);
|
|
1097
1109
|
const excerpt = lines.slice(start, start + 12).join("\n").trim();
|
|
1098
1110
|
const locationMatch = clean2.match(LOCATION);
|
|
@@ -1110,7 +1122,7 @@ async function checkBuild(project, config2) {
|
|
|
1110
1122
|
if (!project.scripts[script]) {
|
|
1111
1123
|
return { id: "build", status: "skipped", summary: "No build step to check" };
|
|
1112
1124
|
}
|
|
1113
|
-
const [command, args] = runScriptCommand(project
|
|
1125
|
+
const [command, args] = runScriptCommand(await packageManagerHere(project), script);
|
|
1114
1126
|
const result = await exec2(command, args, {
|
|
1115
1127
|
cwd: project.root,
|
|
1116
1128
|
env: { CI: "1", NODE_ENV: "production", FORCE_COLOR: "0" },
|
|
@@ -1135,7 +1147,7 @@ async function checkPackages(project) {
|
|
|
1135
1147
|
yarn: void 0,
|
|
1136
1148
|
bun: void 0
|
|
1137
1149
|
};
|
|
1138
|
-
const command = args[project
|
|
1150
|
+
const command = args[await packageManagerHere(project)];
|
|
1139
1151
|
if (!command) {
|
|
1140
1152
|
return {
|
|
1141
1153
|
id: "packages",
|
|
@@ -1221,7 +1233,7 @@ function checksFailed(failed, hint) {
|
|
|
1221
1233
|
details: failed.map((f) => `${f.summary}
|
|
1222
1234
|
${f.details ?? ""}`).join("\n\n").trim(),
|
|
1223
1235
|
files: failed.flatMap(
|
|
1224
|
-
(f) => f.locations?.map((
|
|
1236
|
+
(f) => f.locations?.map((l) => l.line ? `${l.file}:${l.line}` : l.file) ?? []
|
|
1225
1237
|
)
|
|
1226
1238
|
});
|
|
1227
1239
|
}
|
|
@@ -20298,8 +20310,8 @@ function convertBaseSchema(schema, ctx2) {
|
|
|
20298
20310
|
});
|
|
20299
20311
|
}
|
|
20300
20312
|
ctx2.processing.add(refPath);
|
|
20301
|
-
const
|
|
20302
|
-
const zodSchema2 = convertSchema(
|
|
20313
|
+
const resolved3 = resolveRef(refPath, ctx2);
|
|
20314
|
+
const zodSchema2 = convertSchema(resolved3, ctx2);
|
|
20303
20315
|
ctx2.refs.set(refPath, zodSchema2);
|
|
20304
20316
|
ctx2.processing.delete(refPath);
|
|
20305
20317
|
return zodSchema2;
|
|
@@ -20935,8 +20947,22 @@ var ProjectConfigSchema = external_exports.object({
|
|
|
20935
20947
|
* Clodable shapes the pages, and the move to the builder's own Supabase is a guided step.
|
|
20936
20948
|
*/
|
|
20937
20949
|
backend: external_exports.enum(["unknown", "lovable-cloud", "supabase", "none"]).default("unknown"),
|
|
20938
|
-
/**
|
|
20939
|
-
|
|
20950
|
+
/**
|
|
20951
|
+
* Who puts the site live: a host that deploys from GitHub, Lovable (only on its Publish click), or
|
|
20952
|
+
* nobody yet (`none`: the builder can put it online on their own Netlify from Clodable).
|
|
20953
|
+
*/
|
|
20954
|
+
hosting: external_exports.enum(["unknown", "github", "lovable", "none"]).default("unknown"),
|
|
20955
|
+
/**
|
|
20956
|
+
* The site Clodable put on the builder's own Netlify: each Publish goes live there through a
|
|
20957
|
+
* GitHub Actions workflow. Nothing secret: the token that reaches it stays on each computer.
|
|
20958
|
+
*/
|
|
20959
|
+
netlify: external_exports.object({
|
|
20960
|
+
siteId: external_exports.string(),
|
|
20961
|
+
name: external_exports.string(),
|
|
20962
|
+
url: external_exports.string(),
|
|
20963
|
+
admin: external_exports.string(),
|
|
20964
|
+
account: external_exports.string()
|
|
20965
|
+
}).optional(),
|
|
20940
20966
|
checks: external_exports.object({
|
|
20941
20967
|
build: external_exports.boolean().default(true),
|
|
20942
20968
|
packages: external_exports.boolean().default(true),
|
|
@@ -20958,8 +20984,23 @@ var LocalStateSchema = external_exports.object({
|
|
|
20958
20984
|
title: external_exports.string(),
|
|
20959
20985
|
at: external_exports.string(),
|
|
20960
20986
|
url: external_exports.string().optional(),
|
|
20961
|
-
prNumber: external_exports.number().optional()
|
|
20962
|
-
|
|
20987
|
+
prNumber: external_exports.number().optional(),
|
|
20988
|
+
/** No host ever reported putting the app online: this publish is on GitHub only. */
|
|
20989
|
+
noHost: external_exports.boolean().optional()
|
|
20990
|
+
}).optional(),
|
|
20991
|
+
/** The exact version accepted for publication but not yet confirmed by the host. */
|
|
20992
|
+
pendingPublish: external_exports.object({
|
|
20993
|
+
sha: external_exports.string(),
|
|
20994
|
+
title: external_exports.string(),
|
|
20995
|
+
at: external_exports.string(),
|
|
20996
|
+
pullRequest: external_exports.object({ number: external_exports.number(), url: external_exports.string() }),
|
|
20997
|
+
state: external_exports.enum(["pending", "failed"]),
|
|
20998
|
+
ignoredDeploymentIds: external_exports.array(external_exports.number()).optional()
|
|
20999
|
+
}).optional(),
|
|
21000
|
+
/** When a Publish was first seen live on the site Clodable put on Netlify. */
|
|
21001
|
+
siteLiveAt: external_exports.string().optional(),
|
|
21002
|
+
/** The app's settings set on that site (names only). */
|
|
21003
|
+
siteSettings: external_exports.array(external_exports.string()).optional()
|
|
20963
21004
|
});
|
|
20964
21005
|
var CONFIG_PATH = ".clodable/config.json";
|
|
20965
21006
|
var STATE_PATH = ".clodable/local/state.json";
|
|
@@ -21603,6 +21644,13 @@ var SupabaseApi = class _SupabaseApi {
|
|
|
21603
21644
|
await forgetSecret(SUPABASE_TOKEN).catch(() => {
|
|
21604
21645
|
});
|
|
21605
21646
|
}
|
|
21647
|
+
if (response.status === 404 && method === "GET" && /^\/v1\/projects\/[a-z]+$/.test(path2)) {
|
|
21648
|
+
throw new ClodableError({
|
|
21649
|
+
code: "not-found",
|
|
21650
|
+
message: "Your new backend isn't available to this Supabase account.",
|
|
21651
|
+
hint: "Open Supabase and check the account and project. It may have been removed or your access may have changed. Your live app hasn't changed."
|
|
21652
|
+
});
|
|
21653
|
+
}
|
|
21606
21654
|
throw describeFailure(response.status, text2, permissionFor(method, path2));
|
|
21607
21655
|
}
|
|
21608
21656
|
if (!text2) return void 0;
|
|
@@ -22353,11 +22401,21 @@ function newPassword() {
|
|
|
22353
22401
|
}
|
|
22354
22402
|
async function* createHome(ws, options) {
|
|
22355
22403
|
const state = await loadMove(ws.root);
|
|
22404
|
+
const api = await SupabaseApi.required();
|
|
22356
22405
|
if (state.home) {
|
|
22406
|
+
yield step("move:create", "running", "Checking your new backend");
|
|
22407
|
+
const project = await api.project(state.home.ref);
|
|
22408
|
+
if (project.status === "INACTIVE" || project.status === "GOING_DOWN") {
|
|
22409
|
+
throw new ClodableError({
|
|
22410
|
+
code: "move-not-ready",
|
|
22411
|
+
message: "Your new backend is paused.",
|
|
22412
|
+
hint: "Restore it on its page in Supabase, then try this step again. Your live app hasn't changed."
|
|
22413
|
+
});
|
|
22414
|
+
}
|
|
22415
|
+
await waitUntilUp(api, state.home.ref);
|
|
22357
22416
|
yield step("move:create", "done", "Your new backend is ready", state.home.name);
|
|
22358
22417
|
return state.home;
|
|
22359
22418
|
}
|
|
22360
|
-
const api = await SupabaseApi.required();
|
|
22361
22419
|
yield step("move:create", "running", "Creating your new backend");
|
|
22362
22420
|
const organizations = await organizationChoices(api);
|
|
22363
22421
|
const org = organizations.find((o) => o.slug === options.org) ?? (organizations.length === 1 ? organizations[0] : void 0);
|
|
@@ -22401,9 +22459,14 @@ async function* createHome(ws, options) {
|
|
|
22401
22459
|
"Creating your new backend",
|
|
22402
22460
|
"Starting it up: about 2 minutes"
|
|
22403
22461
|
);
|
|
22462
|
+
await waitUntilUp(api, created.ref);
|
|
22463
|
+
yield step("move:create", "done", "Your new backend is ready", home.name);
|
|
22464
|
+
return home;
|
|
22465
|
+
}
|
|
22466
|
+
async function waitUntilUp(api, ref) {
|
|
22404
22467
|
const started = Date.now();
|
|
22405
22468
|
while (true) {
|
|
22406
|
-
const project = await api.project(
|
|
22469
|
+
const project = await api.project(ref);
|
|
22407
22470
|
if (project?.status === "INIT_FAILED") {
|
|
22408
22471
|
throw new ClodableError({
|
|
22409
22472
|
code: "supabase-failed",
|
|
@@ -22412,8 +22475,8 @@ async function* createHome(ws, options) {
|
|
|
22412
22475
|
});
|
|
22413
22476
|
}
|
|
22414
22477
|
if (project?.status === "ACTIVE_HEALTHY") {
|
|
22415
|
-
const health = await api.health(
|
|
22416
|
-
if (health.length > 0 && health.every((s) => s.healthy))
|
|
22478
|
+
const health = await api.health(ref, ["db", "auth", "rest", "storage"]).catch(() => []);
|
|
22479
|
+
if (health.length > 0 && health.every((s) => s.healthy)) return;
|
|
22417
22480
|
}
|
|
22418
22481
|
if (Date.now() - started > 15 * 6e4)
|
|
22419
22482
|
throw new ClodableError({
|
|
@@ -22423,8 +22486,6 @@ async function* createHome(ws, options) {
|
|
|
22423
22486
|
});
|
|
22424
22487
|
await new Promise((done) => setTimeout(done, 5e3));
|
|
22425
22488
|
}
|
|
22426
|
-
yield step("move:create", "done", "Your new backend is ready", home.name);
|
|
22427
|
-
return home;
|
|
22428
22489
|
}
|
|
22429
22490
|
async function homeKeys(api, ref) {
|
|
22430
22491
|
let keys = await api.apiKeys(ref);
|
|
@@ -22538,11 +22599,11 @@ function statement(sql) {
|
|
|
22538
22599
|
async function checkDatabase(ws) {
|
|
22539
22600
|
const { api, ref } = await database(ws);
|
|
22540
22601
|
const lints = await api.advisors(ref, "security");
|
|
22541
|
-
const findings = lints.filter((
|
|
22542
|
-
level:
|
|
22543
|
-
title:
|
|
22544
|
-
...
|
|
22545
|
-
...
|
|
22602
|
+
const findings = lints.filter((l) => l.level === "ERROR" || l.level === "WARN").map((l) => ({
|
|
22603
|
+
level: l.level === "ERROR" ? "error" : "warning",
|
|
22604
|
+
title: l.title,
|
|
22605
|
+
...l.detail ? { detail: l.detail } : {},
|
|
22606
|
+
...l.remediation ? { fix: l.remediation } : {}
|
|
22546
22607
|
}));
|
|
22547
22608
|
return { ok: !findings.some((f) => f.level === "error"), findings };
|
|
22548
22609
|
}
|
|
@@ -22589,7 +22650,7 @@ async function applyMigration(ws, file3) {
|
|
|
22589
22650
|
const text2 = await readFile5(path2, "utf8").catch(() => {
|
|
22590
22651
|
throw new ClodableError({ code: "not-found", message: `There's no ${file3}.` });
|
|
22591
22652
|
});
|
|
22592
|
-
const { sql: db } = await database(ws);
|
|
22653
|
+
const { api, ref, sql: db } = await database(ws);
|
|
22593
22654
|
const [history2] = await db.rows(
|
|
22594
22655
|
"select to_regclass('supabase_migrations.schema_migrations') is not null as present"
|
|
22595
22656
|
);
|
|
@@ -22610,13 +22671,35 @@ async function applyMigration(ws, file3) {
|
|
|
22610
22671
|
"commit;"
|
|
22611
22672
|
].join("\n")
|
|
22612
22673
|
);
|
|
22674
|
+
await untilTheApiSees(api, ref, newTables(text2));
|
|
22613
22675
|
return { version: version3, name, applied: true };
|
|
22614
22676
|
}
|
|
22677
|
+
function newTables(sql) {
|
|
22678
|
+
const found2 = sql.matchAll(
|
|
22679
|
+
/create\s+table\s+(?:if\s+not\s+exists\s+)?(?:"?(\w+)"?\.)?"?(\w+)"?/gi
|
|
22680
|
+
);
|
|
22681
|
+
return [...found2].filter((m) => !m[1] || m[1] === "public").map((m) => m[2]);
|
|
22682
|
+
}
|
|
22683
|
+
async function untilTheApiSees(api, ref, tables) {
|
|
22684
|
+
if (tables.length === 0 || localTarget()) return;
|
|
22685
|
+
const keys = await homeKeys(api, ref).catch(() => void 0);
|
|
22686
|
+
if (!keys) return;
|
|
22687
|
+
const deadline = Date.now() + 15e3;
|
|
22688
|
+
for (const table of tables) {
|
|
22689
|
+
while (Date.now() < deadline) {
|
|
22690
|
+
const answer = await fetch(`${projectUrl(ref)}/rest/v1/${table}?limit=0`, {
|
|
22691
|
+
headers: { apikey: keys.publishable }
|
|
22692
|
+
}).then((response) => response.text()).catch(() => "");
|
|
22693
|
+
if (!answer.includes("PGRST205")) break;
|
|
22694
|
+
await new Promise((done) => setTimeout(done, 1e3));
|
|
22695
|
+
}
|
|
22696
|
+
}
|
|
22697
|
+
}
|
|
22615
22698
|
|
|
22616
22699
|
// ../core/src/kit/index.ts
|
|
22617
|
-
import { existsSync as
|
|
22618
|
-
import { mkdir as
|
|
22619
|
-
import { dirname as
|
|
22700
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
22701
|
+
import { mkdir as mkdir7, readFile as readFile9, writeFile as writeFile7 } from "node:fs/promises";
|
|
22702
|
+
import { dirname as dirname6, join as join14 } from "node:path";
|
|
22620
22703
|
|
|
22621
22704
|
// ../core/src/move/site.ts
|
|
22622
22705
|
import { existsSync as existsSync8 } from "node:fs";
|
|
@@ -23001,17 +23084,51 @@ async function localSettings(root) {
|
|
|
23001
23084
|
return {};
|
|
23002
23085
|
}
|
|
23003
23086
|
}
|
|
23087
|
+
async function siteOf(ws) {
|
|
23088
|
+
const add = (names2, name) => [.../* @__PURE__ */ new Set([...names2 ?? [], name])].sort();
|
|
23089
|
+
if (ws.config.netlify) {
|
|
23090
|
+
const state = await ws.state();
|
|
23091
|
+
return {
|
|
23092
|
+
account: ws.config.netlify.account,
|
|
23093
|
+
id: ws.config.netlify.siteId,
|
|
23094
|
+
names: state.siteSettings ?? [],
|
|
23095
|
+
record: async (name) => {
|
|
23096
|
+
await ws.updateState({ siteSettings: add((await ws.state()).siteSettings, name) });
|
|
23097
|
+
}
|
|
23098
|
+
};
|
|
23099
|
+
}
|
|
23100
|
+
const move = await loadMove(ws.root);
|
|
23101
|
+
if (!move.site) return void 0;
|
|
23102
|
+
return {
|
|
23103
|
+
account: move.site.account,
|
|
23104
|
+
id: move.site.id,
|
|
23105
|
+
names: move.siteSettings ?? [],
|
|
23106
|
+
record: async (name) => {
|
|
23107
|
+
await updateMove(ws.root, (s) => {
|
|
23108
|
+
s.siteSettings = add(s.siteSettings, name);
|
|
23109
|
+
});
|
|
23110
|
+
}
|
|
23111
|
+
};
|
|
23112
|
+
}
|
|
23004
23113
|
async function settingsStatus(ws) {
|
|
23005
23114
|
const { wanted, lovable } = await appSettings(ws.root);
|
|
23006
23115
|
const values = await localSettings(ws.root);
|
|
23007
|
-
const
|
|
23116
|
+
const site = await siteOf(ws);
|
|
23008
23117
|
return {
|
|
23009
23118
|
wanted,
|
|
23010
23119
|
local: wanted.filter((name) => values[name] !== void 0),
|
|
23011
23120
|
lovable,
|
|
23012
|
-
...
|
|
23121
|
+
...site ? { site: wanted.filter((name) => site.names.includes(name)) } : {}
|
|
23013
23122
|
};
|
|
23014
23123
|
}
|
|
23124
|
+
async function rememberSettings(root, add) {
|
|
23125
|
+
const values = { ...await localSettings(root), ...add };
|
|
23126
|
+
await storeSecret(storeKey(root), JSON.stringify(values));
|
|
23127
|
+
await writeJsonFile(join11(root, SETTINGS_PATH), {
|
|
23128
|
+
names: Object.keys(values).sort(),
|
|
23129
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
23130
|
+
});
|
|
23131
|
+
}
|
|
23015
23132
|
async function setSetting(ws, name, value) {
|
|
23016
23133
|
if (!name || !/^[A-Z][A-Z0-9_]*$/.test(name)) {
|
|
23017
23134
|
throw new ClodableError({
|
|
@@ -23031,16 +23148,14 @@ async function setSetting(ws, name, value) {
|
|
|
23031
23148
|
names: Object.keys(values).sort(),
|
|
23032
23149
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
23033
23150
|
});
|
|
23034
|
-
const
|
|
23035
|
-
if (
|
|
23151
|
+
const site = await siteOf(ws);
|
|
23152
|
+
if (site) {
|
|
23036
23153
|
const netlify = await NetlifyApi.onThisComputer();
|
|
23037
23154
|
if (netlify) {
|
|
23038
|
-
await netlify.setEnv(
|
|
23155
|
+
await netlify.setEnv(site.account, site.id, name, clean2, {
|
|
23039
23156
|
secret: !name.startsWith("VITE_")
|
|
23040
23157
|
});
|
|
23041
|
-
await
|
|
23042
|
-
s.siteSettings = [.../* @__PURE__ */ new Set([...s.siteSettings ?? [], name])].sort();
|
|
23043
|
-
});
|
|
23158
|
+
await site.record(name);
|
|
23044
23159
|
}
|
|
23045
23160
|
}
|
|
23046
23161
|
return settingsStatus(ws);
|
|
@@ -23072,6 +23187,20 @@ function backendEnv(b) {
|
|
|
23072
23187
|
var BACKEND_ENV = Object.keys(
|
|
23073
23188
|
backendEnv({ ref: "", url: "", publishable: "", anon: "", serviceRole: "" })
|
|
23074
23189
|
);
|
|
23190
|
+
function envWith(text2, values) {
|
|
23191
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23192
|
+
const lines = text2.split("\n").map((line) => {
|
|
23193
|
+
const match = line.match(/^(\s*(?:export\s+)?)([A-Z0-9_]+)(\s*=\s*)(["']?)(.*?)\4\s*$/);
|
|
23194
|
+
if (!match || !(match[2] in values)) return line;
|
|
23195
|
+
seen.add(match[2]);
|
|
23196
|
+
return `${match[1]}${match[2]}${match[3]}${match[4]}${values[match[2]]}${match[4]}`;
|
|
23197
|
+
});
|
|
23198
|
+
const missing = Object.entries(values).filter(([key2]) => !seen.has(key2));
|
|
23199
|
+
if (missing.length === 0) return lines.join("\n");
|
|
23200
|
+
while (lines.length > 0 && lines.at(-1) === "") lines.pop();
|
|
23201
|
+
return `${[...lines, ...missing.map(([key2, value]) => `${key2}="${value}"`)].join("\n")}
|
|
23202
|
+
`;
|
|
23203
|
+
}
|
|
23075
23204
|
|
|
23076
23205
|
// ../core/src/move/site.ts
|
|
23077
23206
|
var NETLIFY_CLI = "netlify-cli@27.12.0";
|
|
@@ -23160,7 +23289,7 @@ function installSteps(pm, lockfile) {
|
|
|
23160
23289
|
}
|
|
23161
23290
|
}
|
|
23162
23291
|
var gha = (expression) => ["$", "{{ ", expression, " }}"].join("");
|
|
23163
|
-
function netlifyWorkflow(project, liveBranch,
|
|
23292
|
+
function netlifyWorkflow(project, liveBranch, siteUrl2) {
|
|
23164
23293
|
const lockfile = lockfileOf(project.root);
|
|
23165
23294
|
const repoApi = `repos/${gha("github.repository")}/deployments`;
|
|
23166
23295
|
return [
|
|
@@ -23204,7 +23333,7 @@ function netlifyWorkflow(project, liveBranch, siteUrl) {
|
|
|
23204
23333
|
" if: success()",
|
|
23205
23334
|
" env:",
|
|
23206
23335
|
` GH_TOKEN: ${gha("github.token")}`,
|
|
23207
|
-
` run: gh api ${repoApi}/${gha("steps.start.outputs.id")}/statuses -f state=success -f environment_url=${
|
|
23336
|
+
` run: gh api ${repoApi}/${gha("steps.start.outputs.id")}/statuses -f state=success -f environment_url=${siteUrl2} -f log_url=${gha("github.server_url")}/${gha("github.repository")}/actions/runs/${gha("github.run_id")} > /dev/null`,
|
|
23208
23337
|
" - name: Tell GitHub it didn't go live",
|
|
23209
23338
|
" if: failure() && steps.start.outputs.id",
|
|
23210
23339
|
" env:",
|
|
@@ -23226,35 +23355,9 @@ async function* putSiteOnNetlify(ws, options = {}) {
|
|
|
23226
23355
|
const netlify = await NetlifyApi.required();
|
|
23227
23356
|
const supabase = await SupabaseApi.required();
|
|
23228
23357
|
const token = await readSecret(NETLIFY_TOKEN);
|
|
23229
|
-
yield step("move:site", "running", "
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
const accounts = await netlify.accounts();
|
|
23233
|
-
const account = accounts.find((a2) => a2.slug === options.account) ?? (accounts.length === 1 ? accounts[0] : void 0);
|
|
23234
|
-
if (!account) {
|
|
23235
|
-
throw new ClodableError({
|
|
23236
|
-
code: "move-not-ready",
|
|
23237
|
-
message: "Which Netlify team should the site go in?",
|
|
23238
|
-
hint: `Pick one: ${accounts.map((a2) => `${a2.name} (${a2.slug})`).join(", ")}.`
|
|
23239
|
-
});
|
|
23240
|
-
}
|
|
23241
|
-
const base = siteName(ws.project.name);
|
|
23242
|
-
for (const name of [base, `${base}-${Math.random().toString(36).slice(2, 6)}`]) {
|
|
23243
|
-
site = await netlify.createSite(account.slug, name).catch((error62) => {
|
|
23244
|
-
if (error62 instanceof ClodableError && /422/.test(error62.details ?? "")) return void 0;
|
|
23245
|
-
throw error62;
|
|
23246
|
-
});
|
|
23247
|
-
if (site) break;
|
|
23248
|
-
}
|
|
23249
|
-
if (!site) {
|
|
23250
|
-
throw new ClodableError({
|
|
23251
|
-
code: "netlify-failed",
|
|
23252
|
-
message: "Netlify didn't accept a name for your site.",
|
|
23253
|
-
hint: "Try again: Clodable picks another name."
|
|
23254
|
-
});
|
|
23255
|
-
}
|
|
23256
|
-
}
|
|
23257
|
-
const url2 = site.ssl_url || site.url;
|
|
23358
|
+
yield step("move:site", "running", "Preparing your website", "Creating the site");
|
|
23359
|
+
const site = (state.site ? await netlify.site(state.site.id).catch(() => void 0) : void 0) ?? await createNetlifySite(netlify, ws.project.name, options.account);
|
|
23360
|
+
const url2 = siteUrl(site);
|
|
23258
23361
|
await updateMove(ws.root, (s) => {
|
|
23259
23362
|
s.site = {
|
|
23260
23363
|
id: site.id,
|
|
@@ -23264,22 +23367,60 @@ async function* putSiteOnNetlify(ws, options = {}) {
|
|
|
23264
23367
|
account: site.account_slug
|
|
23265
23368
|
};
|
|
23266
23369
|
});
|
|
23370
|
+
yield step("move:site", "running", "Preparing your website", "Pointing it at your new backend");
|
|
23371
|
+
const backend = backendOf(state.home.ref, await homeKeys(supabase, state.home.ref));
|
|
23372
|
+
const carried = await setSiteEnv(netlify, site, ws.root, backend);
|
|
23373
|
+
if (carried.length > 0) {
|
|
23374
|
+
await updateMove(ws.root, (s) => {
|
|
23375
|
+
s.siteSettings = withNames(s.siteSettings, carried);
|
|
23376
|
+
});
|
|
23377
|
+
}
|
|
23378
|
+
yield step("move:site", "running", "Preparing your website", "Setting up Publish");
|
|
23379
|
+
const files = await setUpPublish(ws, site, token);
|
|
23380
|
+
const settings2 = await siteSettingsOf(netlify, site.account_slug, site.id, ws.root);
|
|
23267
23381
|
yield step(
|
|
23268
23382
|
"move:site",
|
|
23269
|
-
"
|
|
23270
|
-
"
|
|
23271
|
-
"
|
|
23383
|
+
"done",
|
|
23384
|
+
"Your website is prepared",
|
|
23385
|
+
"Nothing has been published. Continue the move in the panel."
|
|
23272
23386
|
);
|
|
23273
|
-
|
|
23387
|
+
return { site: { name: site.name, url: url2, admin: site.admin_url }, files, settings: settings2 };
|
|
23388
|
+
}
|
|
23389
|
+
var siteUrl = (site) => site.ssl_url || site.url;
|
|
23390
|
+
async function createNetlifySite(netlify, appName, team) {
|
|
23391
|
+
const accounts = await netlify.accounts();
|
|
23392
|
+
const account = accounts.find((a2) => a2.slug === team) ?? (accounts.length === 1 ? accounts[0] : void 0);
|
|
23393
|
+
if (!account) {
|
|
23394
|
+
throw new ClodableError({
|
|
23395
|
+
code: "needs-choice",
|
|
23396
|
+
message: "Which Netlify team should the site go in?",
|
|
23397
|
+
hint: `Pick one: ${accounts.map((a2) => `${a2.name} (${a2.slug})`).join(", ")}.`
|
|
23398
|
+
});
|
|
23399
|
+
}
|
|
23400
|
+
const base = siteName(appName);
|
|
23401
|
+
for (const name of [base, `${base}-${Math.random().toString(36).slice(2, 6)}`]) {
|
|
23402
|
+
const site = await netlify.createSite(account.slug, name).catch((error62) => {
|
|
23403
|
+
if (error62 instanceof ClodableError && /422/.test(error62.details ?? "")) return void 0;
|
|
23404
|
+
throw error62;
|
|
23405
|
+
});
|
|
23406
|
+
if (site) return site;
|
|
23407
|
+
}
|
|
23408
|
+
throw new ClodableError({
|
|
23409
|
+
code: "netlify-failed",
|
|
23410
|
+
message: "Netlify didn't accept a name for your site.",
|
|
23411
|
+
hint: "Try again: Clodable picks another name."
|
|
23412
|
+
});
|
|
23413
|
+
}
|
|
23414
|
+
async function setSiteEnv(netlify, site, root, backend) {
|
|
23274
23415
|
const existing = await netlify.envKeys(site.account_slug, site.id);
|
|
23275
|
-
for (const [key2, value] of Object.entries(backendEnv(backend))) {
|
|
23416
|
+
for (const [key2, value] of Object.entries(backend ? backendEnv(backend) : {})) {
|
|
23276
23417
|
await netlify.setEnv(site.account_slug, site.id, key2, value, {
|
|
23277
23418
|
secret: key2 === "SUPABASE_SERVICE_ROLE_KEY",
|
|
23278
23419
|
existing
|
|
23279
23420
|
});
|
|
23280
23421
|
}
|
|
23281
|
-
const { wanted } = await appSettings(
|
|
23282
|
-
const mine = await localSettings(
|
|
23422
|
+
const { wanted } = await appSettings(root);
|
|
23423
|
+
const mine = await localSettings(root);
|
|
23283
23424
|
const carried = wanted.filter((name) => mine[name] !== void 0);
|
|
23284
23425
|
for (const name of carried) {
|
|
23285
23426
|
await netlify.setEnv(site.account_slug, site.id, name, mine[name], {
|
|
@@ -23287,12 +23428,9 @@ async function* putSiteOnNetlify(ws, options = {}) {
|
|
|
23287
23428
|
existing
|
|
23288
23429
|
});
|
|
23289
23430
|
}
|
|
23290
|
-
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
});
|
|
23294
|
-
}
|
|
23295
|
-
yield step("move:site", "running", "Putting your site on Netlify", "Setting up Publish");
|
|
23431
|
+
return carried;
|
|
23432
|
+
}
|
|
23433
|
+
async function setUpPublish(ws, site, token) {
|
|
23296
23434
|
const files = [];
|
|
23297
23435
|
if (!existsSync8(join12(ws.root, NETLIFY_TOML))) {
|
|
23298
23436
|
await writeFile5(
|
|
@@ -23301,7 +23439,7 @@ async function* putSiteOnNetlify(ws, options = {}) {
|
|
|
23301
23439
|
);
|
|
23302
23440
|
files.push(NETLIFY_TOML);
|
|
23303
23441
|
}
|
|
23304
|
-
const workflow = netlifyWorkflow(ws.project, ws.config.liveBranch,
|
|
23442
|
+
const workflow = netlifyWorkflow(ws.project, ws.config.liveBranch, siteUrl(site));
|
|
23305
23443
|
const workflowPath = join12(ws.root, WORKFLOW_PATH);
|
|
23306
23444
|
const before = existsSync8(workflowPath) ? await readFile7(workflowPath, "utf8") : "";
|
|
23307
23445
|
if (before !== workflow) {
|
|
@@ -23311,9 +23449,7 @@ async function* putSiteOnNetlify(ws, options = {}) {
|
|
|
23311
23449
|
}
|
|
23312
23450
|
await ws.github.setSecret("NETLIFY_AUTH_TOKEN", token);
|
|
23313
23451
|
await ws.github.setSecret("NETLIFY_SITE_ID", site.id);
|
|
23314
|
-
|
|
23315
|
-
yield step("move:site", "done", "Your site is ready on Netlify", `Publish to see it at ${url2}`);
|
|
23316
|
-
return { site: { name: site.name, url: url2, admin: site.admin_url }, files, settings: settings2 };
|
|
23452
|
+
return files;
|
|
23317
23453
|
}
|
|
23318
23454
|
async function siteSettingsOf(netlify, account, siteId, root) {
|
|
23319
23455
|
const { wanted, lovable } = await appSettings(root);
|
|
@@ -23338,21 +23474,31 @@ var LOVABLE_CLOUD = `## Database and backend: on Lovable Cloud
|
|
|
23338
23474
|
- If the builder asks for something that needs a database or backend change, say so plainly and offer the two ways forward: make that change in Lovable, or first move the app to their own Supabase (**Move off Lovable** in the Clodable panel, a guided step).
|
|
23339
23475
|
- Never write migration files, or code that relies on a database change that hasn't happened: the live app would break after Publish.
|
|
23340
23476
|
- Changes to backend functions (\`supabase/functions/\`) only reach Lovable Cloud through Lovable. Avoid them, and if one is needed, tell the builder to make it in Lovable.`;
|
|
23341
|
-
|
|
23477
|
+
var NO_BACKEND = `## Database and backend: none yet
|
|
23478
|
+
- This app has no database, no sign-in and no backend yet.
|
|
23479
|
+
- When the builder asks for something that needs one (accounts and sign-in, saving data people enter, uploads), explain why in one plain sentence and open Clodable's backend consent view with \`open_panel\` (view \`backend\`). Clodable creates it after account/cost consent, then asks you to connect the app and continue the original request. Don't ask the builder to repeat it.
|
|
23480
|
+
- Don't set up a database or a sign-in service any other way, and don't fake one in the browser's storage for things that must last.
|
|
23481
|
+
- Once the backend is there, these instructions change to say how to work with it.`;
|
|
23482
|
+
var UNKNOWN_BACKEND = `## Database and backend: not confirmed yet
|
|
23483
|
+
- Inspect the app's code and Clodable's app_context before making a database or backend change. Explain what you find in the conversation and ask only about what remains uncertain.
|
|
23484
|
+
- A Supabase URL alone does not establish whether the project belongs to Lovable Cloud or the builder. An unfamiliar service is not evidence that no backend exists.
|
|
23485
|
+
- Record confirmed facts with remember_app. Until ownership and access are established, do not change the database, deploy backend functions or create a replacement service. The preview may already use live data.`;
|
|
23486
|
+
function supabaseSection(ref, cli2) {
|
|
23342
23487
|
return `## Database: live data, handle with care
|
|
23343
23488
|
${ref ? `- The app uses Supabase project \`${ref}\`. The preview uses **live data**: real customers, real orders.` : "- If the app uses a database, the preview uses **live data**: real customers, real orders."}
|
|
23344
23489
|
- You can read and change it, as on Lovable, through Clodable's commands (no key needed; never ask for one):
|
|
23345
|
-
- Read:
|
|
23346
|
-
- Change the tables (a migration): write \`supabase/migrations/<timestamp>_<what>.sql\`, then
|
|
23347
|
-
- Change the data (insert, update, delete):
|
|
23490
|
+
- Read: \`${cli2} db query "select \u2026"\`.
|
|
23491
|
+
- Change the tables (a migration): write \`supabase/migrations/<timestamp>_<what>.sql\`, then \`${cli2} db apply supabase/migrations/<that file>\`. It runs once, in one transaction, and goes in Supabase's migration history.
|
|
23492
|
+
- Change the data (insert, update, delete): \`${cli2} db run "update \u2026"\`. Data that belongs to a person (their notes, their orders) needs their account: look it up with a query first.
|
|
23348
23493
|
- **Before any database change**, tell the builder in one plain sentence what will change and ask for confirmation, for example "I'll add a 'phone' column to Customers. This changes your live database. OK?" Wait for a yes.
|
|
23349
23494
|
- Prefer **additive** changes: add columns and tables, and don't rename or drop them. The live site keeps running the old code until the next Publish, so it must keep working. Clean up only after the builder has published.
|
|
23350
23495
|
- If something can't be undone (deleting a table or column, mass-deleting rows, turning off row-level security), say so explicitly: "This deletes 214 orders and can't be undone." Wait for an explicit yes.
|
|
23351
23496
|
- Every schema change is a migration file, so the history stays in the project. Never change the tables any other way.
|
|
23352
|
-
- Every new table gets row-level security turned on, with policies for who may read and write it. After every schema change, run
|
|
23497
|
+
- Every new table gets row-level security turned on, with policies for who may read and write it. After every schema change, run \`${cli2} db check\` (Supabase's security advice) and fix what it reports.
|
|
23353
23498
|
- **Edge functions** (\`supabase/functions/\`) go live only when the builder publishes. Edit them freely, but never deploy them yourself.`;
|
|
23354
23499
|
}
|
|
23355
23500
|
function agentsMd(input2) {
|
|
23501
|
+
const cli2 = input2.cliCommand ?? "npx clodable";
|
|
23356
23502
|
const stack = input2.appType === "tanstack-start" ? "TanStack Start (React 19, server-side rendering) with Tailwind CSS and shadcn/ui" : input2.appType === "vite-spa" ? "Vite + React + TypeScript, with Tailwind CSS and shadcn/ui" : "a web app";
|
|
23357
23503
|
return `# Working on ${input2.appName}
|
|
23358
23504
|
|
|
@@ -23370,18 +23516,27 @@ The person you're working with is a **builder**: they know their product deeply,
|
|
|
23370
23516
|
|
|
23371
23517
|
## How changes reach the live site
|
|
23372
23518
|
- Every reply is **saved** automatically to the builder's draft (\`draft/<their GitHub login>\`). You don't need to commit, push or open pull requests.
|
|
23373
|
-
${input2.hosting === "lovable" ? `- **Publish** is the builder's decision. They click Publish in Clodable, which checks the app and merges the draft into \`${input2.liveBranch}\`. The site is hosted by Lovable, so it goes live once they click **Publish \u2192 Publish changes** in Lovable. Clodable reminds them.` : `- **Publish** is the builder's decision. They click Publish in Clodable, which checks the app, merges the draft into \`${input2.liveBranch}\`, and the host puts it live.`}
|
|
23519
|
+
${input2.hosting === "lovable" ? `- **Publish** is the builder's decision. They click Publish in Clodable, which checks the app and merges the draft into \`${input2.liveBranch}\`. The site is hosted by Lovable, so it goes live once they click **Publish \u2192 Publish changes** in Lovable. Clodable reminds them.` : input2.hosting === "none" ? `- **Publish** is the builder's decision. They click Publish in Clodable, which checks the app and merges the draft into \`${input2.liveBranch}\`. The app isn't online yet: they first click **Set up hosting** in the Clodable panel (their own Netlify, free to start). This prepares a web address; it does not publish. Open the \`site\` view with Clodable's \`open_panel\` tool for account consent. The panel runs creation; do not run it yourself. Their first **Publish** makes the app public, and each Publish updates it after that.` : `- **Publish** is the builder's decision. They click Publish in Clodable, which checks the app, merges the draft into \`${input2.liveBranch}\`, and the host puts it live.`}
|
|
23374
23520
|
- Never push to \`${input2.liveBranch}\`, never force-push, and never merge pull requests yourself.
|
|
23375
23521
|
- If asked to "publish" or "put it live", tell them to click **Publish** in the Clodable bar above the message box.
|
|
23376
23522
|
|
|
23523
|
+
## Conversation and Clodable
|
|
23524
|
+
- Keep explanations and product decisions in the conversation. Open a panel only for requested details, account consent, secret fields or an action's controls.
|
|
23525
|
+
- Use Clodable's \`app_context\` tool to read status. If hosting or database ownership is unknown, inspect the code, explain the useful conclusion in plain words, and ask one focused question at a time about what you cannot establish. Wait for the answer before asking about another unknown. A Supabase URL does not prove ownership; absent hosting files do not prove a site is offline. A recorded address or database client may be stale or a placeholder, so it does not establish a live service. Leave unsupported or unresolved facts unknown.
|
|
23526
|
+
- After the builder confirms or corrects your conclusion, use \`remember_app\` to record the known facts. Don't create or change a service to find out.
|
|
23527
|
+
- Use \`open_panel\` to open \`history\`, \`settings\`, \`site\`, \`backend\`, \`move\` or \`saving\` when needed; don't ask the builder to type slash commands when this tool is available. Creation and Publish remain the builder's controls.
|
|
23528
|
+
|
|
23377
23529
|
## The preview
|
|
23378
|
-
- The app runs locally in the preview,
|
|
23530
|
+
- The app runs locally in the preview, configured in \`.claude/launch.json\`. Use that configuration; don't start another dev server.
|
|
23379
23531
|
- When they ask to see the preview, open Desktop's Browser pane at its address: \`preview_start\` with \`{"url": "http://localhost:<port>"}\`. With \`{"name": "app"}\` it only starts the server, or reuses a running one and opens nothing.
|
|
23380
23532
|
- After visible changes, check the preview yourself (take a screenshot, click through) before saying you're done.
|
|
23381
23533
|
- The preview toolbar at the bottom of the page belongs to Clodable. It's not part of the app. Don't edit or remove it.
|
|
23382
23534
|
- Requests from the preview arrive as messages that start with "From the preview". Treat them like requests from the builder.
|
|
23383
23535
|
|
|
23384
|
-
${input2.backend === "lovable-cloud" ? LOVABLE_CLOUD : supabaseSection(input2.supabaseRef)}
|
|
23536
|
+
${input2.backend === "lovable-cloud" ? LOVABLE_CLOUD : input2.backend === "none" ? NO_BACKEND : input2.backend === "unknown" ? UNKNOWN_BACKEND : supabaseSection(input2.supabaseRef, cli2)}
|
|
23537
|
+
|
|
23538
|
+
## Clodable commands
|
|
23539
|
+
- Run \`${cli2} <command>\` for status, history, restore and other Clodable commands.${input2.cliCommand ? " This is the installed copy. Don't fetch a different version with npx." : ""}
|
|
23385
23540
|
|
|
23386
23541
|
## Secrets
|
|
23387
23542
|
- Never put API keys or passwords in code. Public keys (the Supabase URL and anon key) are fine.
|
|
@@ -23398,6 +23553,42 @@ ${input2.backend === "lovable-cloud" ? LOVABLE_CLOUD : supabaseSection(input2.su
|
|
|
23398
23553
|
`;
|
|
23399
23554
|
}
|
|
23400
23555
|
|
|
23556
|
+
// ../core/src/kit/runtime.ts
|
|
23557
|
+
import { randomUUID } from "node:crypto";
|
|
23558
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
23559
|
+
import { mkdir as mkdir6, readFile as readFile8, rename as rename4, rm as rm5, writeFile as writeFile6 } from "node:fs/promises";
|
|
23560
|
+
import { dirname as dirname5, join as join13 } from "node:path";
|
|
23561
|
+
var LOCAL_CLI = ".clodable/local/clodable.mjs";
|
|
23562
|
+
var LOCAL_PREVIEW = ".clodable/local/preview.sh";
|
|
23563
|
+
function hasLocalRuntime(root) {
|
|
23564
|
+
return Boolean(process.env.CLODABLE_RUNTIME_SOURCE) || existsSync9(join13(root, LOCAL_CLI));
|
|
23565
|
+
}
|
|
23566
|
+
var shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
23567
|
+
async function replaceIfChanged(path2, content) {
|
|
23568
|
+
const bytes = Buffer.from(content);
|
|
23569
|
+
const before = await readFile8(path2).catch(() => void 0);
|
|
23570
|
+
if (before?.equals(bytes)) return;
|
|
23571
|
+
await mkdir6(dirname5(path2), { recursive: true });
|
|
23572
|
+
const temporary = `${path2}.${randomUUID()}.tmp`;
|
|
23573
|
+
try {
|
|
23574
|
+
await writeFile6(temporary, bytes);
|
|
23575
|
+
await rename4(temporary, path2);
|
|
23576
|
+
} finally {
|
|
23577
|
+
await rm5(temporary, { force: true });
|
|
23578
|
+
}
|
|
23579
|
+
}
|
|
23580
|
+
async function installRuntime(root) {
|
|
23581
|
+
const source = process.env.CLODABLE_RUNTIME_SOURCE;
|
|
23582
|
+
if (!source) return;
|
|
23583
|
+
await replaceIfChanged(join13(root, LOCAL_CLI), await readFile8(source));
|
|
23584
|
+
await replaceIfChanged(
|
|
23585
|
+
join13(root, LOCAL_PREVIEW),
|
|
23586
|
+
`#!/bin/sh
|
|
23587
|
+
exec ${shellQuote(process.execPath)} "$(dirname "$0")/clodable.mjs" dev "$@"
|
|
23588
|
+
`
|
|
23589
|
+
);
|
|
23590
|
+
}
|
|
23591
|
+
|
|
23401
23592
|
// ../core/src/kit/index.ts
|
|
23402
23593
|
var CLODABLE_FILES = [
|
|
23403
23594
|
".clodable",
|
|
@@ -23405,7 +23596,8 @@ var CLODABLE_FILES = [
|
|
|
23405
23596
|
"AGENTS.md",
|
|
23406
23597
|
"CLAUDE.md",
|
|
23407
23598
|
".mcp.json",
|
|
23408
|
-
WORKFLOW_PATH
|
|
23599
|
+
WORKFLOW_PATH,
|
|
23600
|
+
NETLIFY_TOML
|
|
23409
23601
|
];
|
|
23410
23602
|
function clodableFile(path2) {
|
|
23411
23603
|
return CLODABLE_FILES.some((own2) => path2 === own2 || path2.startsWith(`${own2}/`));
|
|
@@ -23416,8 +23608,8 @@ async function keepIgnored(root) {
|
|
|
23416
23608
|
var BEGIN = "<!-- clodable:begin";
|
|
23417
23609
|
var END = "<!-- clodable:end -->";
|
|
23418
23610
|
async function read(root, path2) {
|
|
23419
|
-
const full =
|
|
23420
|
-
return
|
|
23611
|
+
const full = join14(root, path2);
|
|
23612
|
+
return existsSync10(full) ? readFile9(full, "utf8") : void 0;
|
|
23421
23613
|
}
|
|
23422
23614
|
function json2(value) {
|
|
23423
23615
|
return `${JSON.stringify(value, null, 2)}
|
|
@@ -23450,6 +23642,13 @@ ${block2}
|
|
|
23450
23642
|
async function planKit(project, config2, options = {}) {
|
|
23451
23643
|
const root = project.root;
|
|
23452
23644
|
const ref = supabaseRef(config2, project);
|
|
23645
|
+
if (options.runtimeOnly) {
|
|
23646
|
+
return [
|
|
23647
|
+
await agentsPlan(root, project, config2, ref),
|
|
23648
|
+
await launchPlan(root, options),
|
|
23649
|
+
await gitignorePlan(root)
|
|
23650
|
+
];
|
|
23651
|
+
}
|
|
23453
23652
|
const planned = [
|
|
23454
23653
|
await agentsPlan(root, project, config2, ref),
|
|
23455
23654
|
await claudePlan(root),
|
|
@@ -23483,7 +23682,8 @@ async function agentsPlan(root, project, config2, ref) {
|
|
|
23483
23682
|
liveBranch: config2.liveBranch,
|
|
23484
23683
|
supabaseRef: ref,
|
|
23485
23684
|
backend: config2.backend,
|
|
23486
|
-
hosting: config2.hosting
|
|
23685
|
+
hosting: config2.hosting,
|
|
23686
|
+
cliCommand: hasLocalRuntime(root) ? `node "${LOCAL_CLI}"` : void 0
|
|
23487
23687
|
})
|
|
23488
23688
|
)
|
|
23489
23689
|
);
|
|
@@ -23502,14 +23702,24 @@ async function launchPlan(root, options) {
|
|
|
23502
23702
|
before,
|
|
23503
23703
|
{}
|
|
23504
23704
|
);
|
|
23505
|
-
const
|
|
23506
|
-
const
|
|
23705
|
+
const existing = launch.configurations?.find((configuration) => configuration.name === "app");
|
|
23706
|
+
const override = clodableDev(launch.configurations ?? []);
|
|
23707
|
+
if (options.runtimeOnly && override && before) {
|
|
23708
|
+
return change(
|
|
23709
|
+
".claude/launch.json",
|
|
23710
|
+
"Keeps your explicit Clodable preview command",
|
|
23711
|
+
before,
|
|
23712
|
+
before
|
|
23713
|
+
);
|
|
23714
|
+
}
|
|
23715
|
+
const dev = options.devCommand ?? override ?? (hasLocalRuntime(root) ? installedPreviewCommand() : previewCommand());
|
|
23716
|
+
const ours2 = {
|
|
23507
23717
|
name: "app",
|
|
23508
23718
|
runtimeExecutable: dev.executable,
|
|
23509
23719
|
runtimeArgs: dev.args,
|
|
23510
23720
|
// Lovable's templates, classic and TanStack Start, both serve on 8080.
|
|
23511
|
-
port: options.port ?? 8080,
|
|
23512
|
-
autoPort: true
|
|
23721
|
+
port: options.port ?? (options.runtimeOnly && typeof existing?.port === "number" ? existing.port : 8080),
|
|
23722
|
+
autoPort: options.runtimeOnly && typeof existing?.autoPort === "boolean" ? existing.autoPort : true
|
|
23513
23723
|
};
|
|
23514
23724
|
const others = (launch.configurations ?? []).filter(
|
|
23515
23725
|
(c2) => !(Array.isArray(c2.runtimeArgs) && c2.runtimeArgs.includes("clodable")) && c2.name !== "app"
|
|
@@ -23518,16 +23728,31 @@ async function launchPlan(root, options) {
|
|
|
23518
23728
|
".claude/launch.json",
|
|
23519
23729
|
"Starts your app in the preview, with the Clodable toolbar",
|
|
23520
23730
|
before,
|
|
23521
|
-
json2({ version: launch.version ?? "0.0.1", configurations: [
|
|
23731
|
+
json2({ version: launch.version ?? "0.0.1", configurations: [ours2, ...others] })
|
|
23522
23732
|
);
|
|
23523
23733
|
}
|
|
23734
|
+
var TOOLS_PATH = "$HOME/.claude/plugins/data/clodable-clodable/tools/bin";
|
|
23735
|
+
function installedPreviewCommand() {
|
|
23736
|
+
return process.platform === "win32" ? { executable: "node", args: [LOCAL_CLI, "dev"] } : { executable: "/bin/sh", args: [LOCAL_PREVIEW] };
|
|
23737
|
+
}
|
|
23738
|
+
function previewCommand(platform = process.platform) {
|
|
23739
|
+
if (platform === "win32") return { executable: "npx", args: ["clodable", "dev"] };
|
|
23740
|
+
return {
|
|
23741
|
+
executable: "/bin/sh",
|
|
23742
|
+
args: ["-c", `PATH="$PATH:${TOOLS_PATH}" exec npx clodable dev`]
|
|
23743
|
+
};
|
|
23744
|
+
}
|
|
23524
23745
|
function clodableDev(configurations) {
|
|
23525
23746
|
const app = configurations.find((c2) => c2.name === "app");
|
|
23526
|
-
const
|
|
23747
|
+
const executable3 = app?.runtimeExecutable;
|
|
23527
23748
|
const args = app?.runtimeArgs;
|
|
23528
|
-
if (typeof
|
|
23529
|
-
const words = [
|
|
23530
|
-
|
|
23749
|
+
if (typeof executable3 !== "string" || !Array.isArray(args)) return void 0;
|
|
23750
|
+
const words = [executable3, ...args].map(String);
|
|
23751
|
+
const command = words.join(" ");
|
|
23752
|
+
if (args.includes(LOCAL_PREVIEW) || args.includes(LOCAL_CLI)) return void 0;
|
|
23753
|
+
if (command === "npx clodable dev") return void 0;
|
|
23754
|
+
if (/^\/bin\/sh -c PATH="\$PATH:[^"]*" exec npx clodable dev$/.test(command)) return void 0;
|
|
23755
|
+
return words.some((w) => w.includes("clodable")) && words.includes("dev") ? { executable: executable3, args: args.map(String) } : void 0;
|
|
23531
23756
|
}
|
|
23532
23757
|
async function settingsPlan(root, options) {
|
|
23533
23758
|
const before = await read(root, ".claude/settings.json");
|
|
@@ -23577,8 +23802,8 @@ async function mcpPlan(root, config2, ref) {
|
|
|
23577
23802
|
if (config2.backend === "lovable-cloud") {
|
|
23578
23803
|
const before2 = await read(root, ".mcp.json");
|
|
23579
23804
|
const mcp2 = parseJson(before2, {});
|
|
23580
|
-
const
|
|
23581
|
-
if (before2 === void 0 || !
|
|
23805
|
+
const ours2 = mcp2.mcpServers?.supabase?.url?.startsWith("https://mcp.supabase.com/");
|
|
23806
|
+
if (before2 === void 0 || !ours2) return void 0;
|
|
23582
23807
|
const { supabase: _, ...others } = mcp2.mcpServers ?? {};
|
|
23583
23808
|
return change(
|
|
23584
23809
|
".mcp.json",
|
|
@@ -23628,7 +23853,7 @@ async function gitignorePlan(root) {
|
|
|
23628
23853
|
const before = await read(root, ".gitignore");
|
|
23629
23854
|
const wanted = [".clodable/local/", ".clodable/inbox/"];
|
|
23630
23855
|
const missing = wanted.filter(
|
|
23631
|
-
(line) => !(before ?? "").split("\n").some((
|
|
23856
|
+
(line) => !(before ?? "").split("\n").some((l) => l.trim() === line)
|
|
23632
23857
|
);
|
|
23633
23858
|
return change(
|
|
23634
23859
|
".gitignore",
|
|
@@ -23640,12 +23865,13 @@ ${missing.join("\n")}
|
|
|
23640
23865
|
);
|
|
23641
23866
|
}
|
|
23642
23867
|
async function applyKit(root, changes) {
|
|
23868
|
+
if (changes.some((change2) => change2.path === ".claude/launch.json")) await installRuntime(root);
|
|
23643
23869
|
const written = [];
|
|
23644
23870
|
for (const change2 of changes) {
|
|
23645
23871
|
if (change2.action === "unchanged") continue;
|
|
23646
|
-
const full =
|
|
23647
|
-
await
|
|
23648
|
-
await
|
|
23872
|
+
const full = join14(root, change2.path);
|
|
23873
|
+
await mkdir7(dirname6(full), { recursive: true });
|
|
23874
|
+
await writeFile7(full, change2.content);
|
|
23649
23875
|
written.push(change2);
|
|
23650
23876
|
}
|
|
23651
23877
|
return written;
|
|
@@ -23832,9 +24058,18 @@ async function countUnpublished(ws) {
|
|
|
23832
24058
|
return (await waitingSaves(ws)).length;
|
|
23833
24059
|
}
|
|
23834
24060
|
async function waitingSaves(ws) {
|
|
24061
|
+
if (await matchesPendingPublish(ws)) return [];
|
|
23835
24062
|
const saves = await unpublishedSaves(ws, { buildersOnly: true });
|
|
23836
24063
|
return saves.length > 0 && await sameAsLive(ws) ? [] : saves;
|
|
23837
24064
|
}
|
|
24065
|
+
async function matchesPendingPublish(ws) {
|
|
24066
|
+
const pending = (await ws.state()).pendingPublish;
|
|
24067
|
+
if (!pending) return false;
|
|
24068
|
+
if (!await ws.git.revParse(pending.sha)) {
|
|
24069
|
+
await ws.git.fetch(ws.remote, ws.liveBranch).catch(() => void 0);
|
|
24070
|
+
}
|
|
24071
|
+
return (await ws.git.run(["diff", "--quiet", pending.sha, "HEAD"])).exitCode === 0;
|
|
24072
|
+
}
|
|
23838
24073
|
async function sameAsLive(ws, options = {}) {
|
|
23839
24074
|
const live = await liveBase(ws);
|
|
23840
24075
|
if (!live) return false;
|
|
@@ -23856,6 +24091,7 @@ function onlyClodables(paths) {
|
|
|
23856
24091
|
return paths.length > 0 && paths.every(clodableFile);
|
|
23857
24092
|
}
|
|
23858
24093
|
async function ensurePullRequest(ws, branch) {
|
|
24094
|
+
if (await matchesPendingPublish(ws)) return void 0;
|
|
23859
24095
|
const saves = await unpublishedSaves(ws);
|
|
23860
24096
|
if (saves.length === 0) return void 0;
|
|
23861
24097
|
const existing = await ws.github.findOpenPullRequest(branch);
|
|
@@ -23899,6 +24135,24 @@ async function status(ws, options = {}) {
|
|
|
23899
24135
|
const hasLive = Boolean(await ws.git.revParse(ws.liveRef));
|
|
23900
24136
|
const unpublished = branch === ws.liveBranch ? [] : await waitingSaves(ws);
|
|
23901
24137
|
const behindLive = hasLive ? await ws.git.count(`HEAD..${ws.liveRef}`, { noMerges: true }) : 0;
|
|
24138
|
+
const site = await siteStatus(ws, state.siteLiveAt);
|
|
24139
|
+
let pendingPublish = state.pendingPublish;
|
|
24140
|
+
if (!pendingPublish && state.pullRequest && hasLive) {
|
|
24141
|
+
const [latest] = await ws.git.log(ws.liveRef, { firstParent: true, limit: 1 });
|
|
24142
|
+
if (latest?.kind === "publish" && state.lastPublish?.sha !== latest.sha) {
|
|
24143
|
+
const deliveries = await ws.github.deploymentsFor(latest.sha).catch(() => []);
|
|
24144
|
+
const delivery = deliveries.find((d) => d.isProduction) ?? deliveries[0];
|
|
24145
|
+
if (delivery?.state === "failure" || delivery?.state === "error") {
|
|
24146
|
+
pendingPublish = {
|
|
24147
|
+
sha: latest.sha,
|
|
24148
|
+
title: latest.subject,
|
|
24149
|
+
at: latest.date,
|
|
24150
|
+
pullRequest: state.pullRequest,
|
|
24151
|
+
state: "failed"
|
|
24152
|
+
};
|
|
24153
|
+
}
|
|
24154
|
+
}
|
|
24155
|
+
}
|
|
23902
24156
|
return {
|
|
23903
24157
|
project: {
|
|
23904
24158
|
name: ws.project.name,
|
|
@@ -23918,11 +24172,35 @@ async function status(ws, options = {}) {
|
|
|
23918
24172
|
merging,
|
|
23919
24173
|
conflicts,
|
|
23920
24174
|
...state.lastPublish ? { lastPublish: state.lastPublish } : {},
|
|
24175
|
+
...pendingPublish ? { pendingPublish } : {},
|
|
23921
24176
|
...state.pullRequest ? { pullRequest: state.pullRequest } : {},
|
|
23922
24177
|
...await whereTheMoveIs(ws.root),
|
|
23923
|
-
...ws.config.backend === "supabase" ? { database: { connected: Boolean(await readSecret(SUPABASE_TOKEN)) } } : {}
|
|
24178
|
+
...ws.config.backend === "supabase" || ws.config.backend === "none" ? { database: { connected: Boolean(await readSecret(SUPABASE_TOKEN)) } } : {},
|
|
24179
|
+
...site ? { site } : {},
|
|
24180
|
+
...ws.config.hosting === "none" ? { netlify: { connected: Boolean(await readSecret(NETLIFY_TOKEN)) } } : {}
|
|
23924
24181
|
};
|
|
23925
24182
|
}
|
|
24183
|
+
async function siteStatus(ws, liveAt) {
|
|
24184
|
+
const configured = ws.config.netlify;
|
|
24185
|
+
if (!configured) return void 0;
|
|
24186
|
+
const base = { url: configured.url, admin: configured.admin };
|
|
24187
|
+
if (liveAt) return { ...base, live: true };
|
|
24188
|
+
try {
|
|
24189
|
+
const api = await NetlifyApi.onThisComputer();
|
|
24190
|
+
const remote = await api?.site(configured.siteId);
|
|
24191
|
+
if (!remote || remote.id !== configured.siteId || remote.account_slug !== configured.account)
|
|
24192
|
+
return { ...base, live: false, statusKnown: false };
|
|
24193
|
+
const live = remote.published_deploy?.state === "ready";
|
|
24194
|
+
if (live) {
|
|
24195
|
+
await ws.updateState({
|
|
24196
|
+
siteLiveAt: remote.published_deploy?.published_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
24197
|
+
});
|
|
24198
|
+
}
|
|
24199
|
+
return { ...base, live };
|
|
24200
|
+
} catch {
|
|
24201
|
+
return { ...base, live: false, statusKnown: false };
|
|
24202
|
+
}
|
|
24203
|
+
}
|
|
23926
24204
|
async function history(ws, options = {}) {
|
|
23927
24205
|
const live = await liveBase(ws) ?? ws.liveBranch;
|
|
23928
24206
|
const [draft, published] = await Promise.all([
|
|
@@ -23958,8 +24236,10 @@ async function whereTheMoveIs(root) {
|
|
|
23958
24236
|
}
|
|
23959
24237
|
|
|
23960
24238
|
// ../core/src/git.ts
|
|
23961
|
-
import { existsSync as
|
|
23962
|
-
import {
|
|
24239
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
24240
|
+
import { mkdtemp as mkdtemp4, rm as rm6 } from "node:fs/promises";
|
|
24241
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
24242
|
+
import { join as join15 } from "node:path";
|
|
23963
24243
|
var COMMIT_KINDS = ["save", "restore", "sync", "publish", "undo", "setup"];
|
|
23964
24244
|
var KIND_KEY = "Clodable-Kind";
|
|
23965
24245
|
var kindTrailer = (kind) => `${KIND_KEY}: ${kind}`;
|
|
@@ -24118,6 +24398,26 @@ ${kindTrailer(options.kind)}`
|
|
|
24118
24398
|
});
|
|
24119
24399
|
return result.exitCode === 0;
|
|
24120
24400
|
}
|
|
24401
|
+
/** Check a merge away from the preview; never put conflict markers in the builder's files. */
|
|
24402
|
+
async checkMerge(ref) {
|
|
24403
|
+
const dir = await mkdtemp4(join15(tmpdir3(), "clodable-combine-"));
|
|
24404
|
+
try {
|
|
24405
|
+
await this.ok(["worktree", "add", "--quiet", "--detach", dir, "HEAD"]);
|
|
24406
|
+
const side = new _Git(dir);
|
|
24407
|
+
const result = await side.run(["merge", "--no-commit", "--no-ff", ref]);
|
|
24408
|
+
if (result.exitCode === 0) return { ok: true, conflicts: [] };
|
|
24409
|
+
const conflicts = await side.conflictedFiles();
|
|
24410
|
+
if (conflicts.length > 0) return { ok: false, conflicts };
|
|
24411
|
+
throw new ClodableError({
|
|
24412
|
+
code: "unknown",
|
|
24413
|
+
message: "Your draft couldn't be compared with the live site.",
|
|
24414
|
+
details: result.stderr || result.stdout
|
|
24415
|
+
});
|
|
24416
|
+
} finally {
|
|
24417
|
+
await this.worktreeRemove(dir);
|
|
24418
|
+
await rm6(dir, { recursive: true, force: true });
|
|
24419
|
+
}
|
|
24420
|
+
}
|
|
24121
24421
|
/** Merge `ref` into the current branch. Leaves conflicts in place for someone to resolve. */
|
|
24122
24422
|
async merge(ref, message) {
|
|
24123
24423
|
const result = await this.run(["merge", "--no-edit", "--no-ff", "-m", message, ref]);
|
|
@@ -24300,14 +24600,14 @@ ${kindTrailer(options.kind)}`
|
|
|
24300
24600
|
await this.run(["worktree", "prune"]);
|
|
24301
24601
|
}
|
|
24302
24602
|
gitDir() {
|
|
24303
|
-
return
|
|
24603
|
+
return join15(this.cwd, ".git");
|
|
24304
24604
|
}
|
|
24305
24605
|
hasGitDir() {
|
|
24306
|
-
return
|
|
24606
|
+
return existsSync11(this.gitDir());
|
|
24307
24607
|
}
|
|
24308
24608
|
};
|
|
24309
24609
|
function cleanSubject(text2) {
|
|
24310
|
-
const firstLine = text2.split("\n").map((
|
|
24610
|
+
const firstLine = text2.split("\n").map((l) => l.trim()).find(Boolean) ?? "Update";
|
|
24311
24611
|
const singleSpaced = firstLine.replace(/\s+/g, " ").replace(/[.\s]+$/, "");
|
|
24312
24612
|
const capitalized = singleSpaced.charAt(0).toUpperCase() + singleSpaced.slice(1);
|
|
24313
24613
|
return capitalized.length <= 72 ? capitalized : `${capitalized.slice(0, 71).trimEnd()}\u2026`;
|
|
@@ -24318,10 +24618,10 @@ function parseGitHubRemote(url2) {
|
|
|
24318
24618
|
}
|
|
24319
24619
|
|
|
24320
24620
|
// ../core/src/github/fake.ts
|
|
24321
|
-
import { existsSync as
|
|
24322
|
-
import { mkdtemp as
|
|
24323
|
-
import { tmpdir as
|
|
24324
|
-
import { join as
|
|
24621
|
+
import { existsSync as existsSync12, readFileSync, writeFileSync } from "node:fs";
|
|
24622
|
+
import { mkdir as mkdir8, mkdtemp as mkdtemp5, rm as rm7, writeFile as writeFile8 } from "node:fs/promises";
|
|
24623
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
24624
|
+
import { join as join16 } from "node:path";
|
|
24325
24625
|
var FakeGitHub = class _FakeGitHub {
|
|
24326
24626
|
constructor(bareRepo, user = { login: "ada", name: "Ada", email: "1+ada@users.noreply.github.com" }, info = {
|
|
24327
24627
|
owner: "crumb",
|
|
@@ -24350,6 +24650,7 @@ var FakeGitHub = class _FakeGitHub {
|
|
|
24350
24650
|
url: "https://crumb-and-co.example"
|
|
24351
24651
|
}
|
|
24352
24652
|
];
|
|
24653
|
+
retryDeployment = async () => false;
|
|
24353
24654
|
/**
|
|
24354
24655
|
* With `stateFile`, pull requests survive across processes. That lets the CLI run against a
|
|
24355
24656
|
* fake GitHub for demos (`CLODABLE_FAKE_GITHUB=<bare repo>`).
|
|
@@ -24357,7 +24658,12 @@ var FakeGitHub = class _FakeGitHub {
|
|
|
24357
24658
|
static persistent(bareRepo, stateFile = `${bareRepo}/clodable-fake-github.json`) {
|
|
24358
24659
|
const fake = new _FakeGitHub(bareRepo);
|
|
24359
24660
|
fake.stateFile = stateFile;
|
|
24360
|
-
if (
|
|
24661
|
+
if (process.env.CLODABLE_FAKE_HOST === "none") fake.deploymentFor = () => [];
|
|
24662
|
+
if (process.env.CLODABLE_FAKE_HOST === "failed")
|
|
24663
|
+
fake.deploymentFor = () => [
|
|
24664
|
+
{ id: 1, environment: "Production", isProduction: true, state: "failure" }
|
|
24665
|
+
];
|
|
24666
|
+
if (existsSync12(stateFile)) {
|
|
24361
24667
|
fake.pullRequests.push(...JSON.parse(readFileSync(stateFile, "utf8")));
|
|
24362
24668
|
}
|
|
24363
24669
|
return fake;
|
|
@@ -24369,6 +24675,32 @@ var FakeGitHub = class _FakeGitHub {
|
|
|
24369
24675
|
async ready() {
|
|
24370
24676
|
return { installed: true, authenticated: true };
|
|
24371
24677
|
}
|
|
24678
|
+
async createPrivateRepository(name) {
|
|
24679
|
+
if (existsSync12(this.bareRepo))
|
|
24680
|
+
throw new ClodableError({
|
|
24681
|
+
code: "already-there",
|
|
24682
|
+
message: "That app name is already in use."
|
|
24683
|
+
});
|
|
24684
|
+
const seed = await mkdtemp5(join16(tmpdir4(), "clodable-new-app-"));
|
|
24685
|
+
try {
|
|
24686
|
+
const git = new Git(seed);
|
|
24687
|
+
await git.ok(["init", "--quiet", "--initial-branch=main"]);
|
|
24688
|
+
await git.setLocalIdentity({ name: "GitHub", email: "noreply@github.com" });
|
|
24689
|
+
await writeFile8(join16(seed, "README.md"), `# ${name}
|
|
24690
|
+
`);
|
|
24691
|
+
await git.commitAll("Initial app", { kind: "setup" });
|
|
24692
|
+
await mkdir8(join16(this.bareRepo, ".."), { recursive: true });
|
|
24693
|
+
await git.ok(["clone", "--bare", seed, this.bareRepo]);
|
|
24694
|
+
Object.assign(this.info, {
|
|
24695
|
+
owner: this.user.login,
|
|
24696
|
+
name,
|
|
24697
|
+
url: `https://github.com/${this.user.login}/${name}`
|
|
24698
|
+
});
|
|
24699
|
+
return { repo: this.info, cloneUrl: this.bareRepo };
|
|
24700
|
+
} finally {
|
|
24701
|
+
await rm7(seed, { recursive: true, force: true });
|
|
24702
|
+
}
|
|
24703
|
+
}
|
|
24372
24704
|
async viewer() {
|
|
24373
24705
|
return this.user;
|
|
24374
24706
|
}
|
|
@@ -24409,7 +24741,7 @@ var FakeGitHub = class _FakeGitHub {
|
|
|
24409
24741
|
if (pr?.state !== "open") {
|
|
24410
24742
|
throw new ClodableError({ code: "not-found", message: "That draft isn't open any more." });
|
|
24411
24743
|
}
|
|
24412
|
-
const dir = await
|
|
24744
|
+
const dir = await mkdtemp5(join16(tmpdir4(), "clodable-fake-merge-"));
|
|
24413
24745
|
try {
|
|
24414
24746
|
const git = new Git(dir);
|
|
24415
24747
|
await git.ok(["clone", "--quiet", this.bareRepo, "."]);
|
|
@@ -24434,12 +24766,15 @@ ${input2.body}`]);
|
|
|
24434
24766
|
this.persist();
|
|
24435
24767
|
return { sha };
|
|
24436
24768
|
} finally {
|
|
24437
|
-
await
|
|
24769
|
+
await rm7(dir, { recursive: true, force: true });
|
|
24438
24770
|
}
|
|
24439
24771
|
}
|
|
24440
24772
|
async deploymentsFor(sha) {
|
|
24441
24773
|
return this.deploymentFor(sha);
|
|
24442
24774
|
}
|
|
24775
|
+
async hasDeployments() {
|
|
24776
|
+
return this.deploymentFor("HEAD").length > 0;
|
|
24777
|
+
}
|
|
24443
24778
|
/** Decides what a commit's GitHub build is doing. By default, none: the host builds elsewhere. */
|
|
24444
24779
|
buildFor = () => void 0;
|
|
24445
24780
|
async buildProgress(sha) {
|
|
@@ -24449,13 +24784,111 @@ ${input2.body}`]);
|
|
|
24449
24784
|
secrets = {};
|
|
24450
24785
|
async setSecret(name, value) {
|
|
24451
24786
|
const file3 = `${this.bareRepo}/clodable-fake-secrets.json`;
|
|
24452
|
-
const all =
|
|
24787
|
+
const all = existsSync12(file3) ? JSON.parse(readFileSync(file3, "utf8")) : {};
|
|
24453
24788
|
all[name] = value;
|
|
24454
24789
|
this.secrets[name] = value;
|
|
24455
24790
|
writeFileSync(file3, JSON.stringify(all, null, 2));
|
|
24456
24791
|
}
|
|
24457
24792
|
};
|
|
24458
24793
|
|
|
24794
|
+
// ../core/src/github/gh-binary.ts
|
|
24795
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
24796
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
24797
|
+
import { chmod as chmod5, mkdir as mkdir9, mkdtemp as mkdtemp6, rename as rename5, rm as rm8, symlink, unlink, writeFile as writeFile9 } from "node:fs/promises";
|
|
24798
|
+
import { join as join17 } from "node:path";
|
|
24799
|
+
var GH_VERSION = "2.102.0";
|
|
24800
|
+
var RELEASES2 = {
|
|
24801
|
+
"darwin-arm64": {
|
|
24802
|
+
file: "macOS_arm64.zip",
|
|
24803
|
+
sha256: "da922c20d1792e5b2cbf375593d7a658acf034c12c84e007e71c76ef959c337e"
|
|
24804
|
+
},
|
|
24805
|
+
"darwin-x64": {
|
|
24806
|
+
file: "macOS_amd64.zip",
|
|
24807
|
+
sha256: "b245f24eb2bf5f75b426b4c26da3651a107f8d5b6f4fddfbfccc5679041378b3"
|
|
24808
|
+
},
|
|
24809
|
+
"linux-arm64": {
|
|
24810
|
+
file: "linux_arm64.tar.gz",
|
|
24811
|
+
sha256: "7862c86c72f43df3a2d93ddde6f473285b4e2af61b494849846827e513ef6484"
|
|
24812
|
+
},
|
|
24813
|
+
"linux-x64": {
|
|
24814
|
+
file: "linux_amd64.tar.gz",
|
|
24815
|
+
sha256: "bb766f710eef8ede859c18578c72c327597cd4c8a85b06001b1f3843c6019386"
|
|
24816
|
+
},
|
|
24817
|
+
"win32-arm64": {
|
|
24818
|
+
file: "windows_arm64.zip",
|
|
24819
|
+
sha256: "5dcf12aa8525eabd0c46ec414f323ab6cf65229fc2cd46543cc705001bbaf223"
|
|
24820
|
+
},
|
|
24821
|
+
"win32-x64": {
|
|
24822
|
+
file: "windows_amd64.zip",
|
|
24823
|
+
sha256: "ae64e556ecc240b200f7eba60d550e4bb60d78e860e69dd88c449405b86067f4"
|
|
24824
|
+
}
|
|
24825
|
+
};
|
|
24826
|
+
var executable2 = process.platform === "win32" ? "gh.exe" : "gh";
|
|
24827
|
+
function toolsBin() {
|
|
24828
|
+
return join17(toolsDir(), "bin");
|
|
24829
|
+
}
|
|
24830
|
+
var resolved2;
|
|
24831
|
+
async function ghBinary() {
|
|
24832
|
+
if (process.env.CLODABLE_GH) return process.env.CLODABLE_GH;
|
|
24833
|
+
const installed = await commandPath("gh");
|
|
24834
|
+
if (installed && !installed.startsWith(toolsBin())) return installed;
|
|
24835
|
+
resolved2 ??= ours().catch((error62) => {
|
|
24836
|
+
resolved2 = void 0;
|
|
24837
|
+
throw error62;
|
|
24838
|
+
});
|
|
24839
|
+
return resolved2;
|
|
24840
|
+
}
|
|
24841
|
+
async function ghIsOurs() {
|
|
24842
|
+
return (await ghBinary().catch(() => "")).startsWith(toolsDir());
|
|
24843
|
+
}
|
|
24844
|
+
async function ours() {
|
|
24845
|
+
const release = RELEASES2[`${process.platform}-${process.arch}`];
|
|
24846
|
+
if (!release) throw new Error(`No GitHub CLI build for ${process.platform}-${process.arch}.`);
|
|
24847
|
+
const dir = join17(toolsDir(), "gh", GH_VERSION);
|
|
24848
|
+
const path2 = join17(dir, executable2);
|
|
24849
|
+
if (!existsSync13(path2)) {
|
|
24850
|
+
try {
|
|
24851
|
+
await download2(release, dir, path2);
|
|
24852
|
+
} catch (error62) {
|
|
24853
|
+
throw new Error(`Couldn't download the GitHub CLI ${GH_VERSION}: ${messageOf(error62)}`);
|
|
24854
|
+
}
|
|
24855
|
+
}
|
|
24856
|
+
await linkInBin(path2);
|
|
24857
|
+
return path2;
|
|
24858
|
+
}
|
|
24859
|
+
async function download2(release, dir, path2) {
|
|
24860
|
+
const name = `gh_${GH_VERSION}_${release.file}`;
|
|
24861
|
+
const url2 = `https://github.com/cli/cli/releases/download/v${GH_VERSION}/${name}`;
|
|
24862
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(18e4) });
|
|
24863
|
+
if (!response.ok) throw new Error(`GitHub answered ${response.status}`);
|
|
24864
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
24865
|
+
const digest = createHash5("sha256").update(bytes).digest("hex");
|
|
24866
|
+
if (digest !== release.sha256) throw new Error("the download didn't match its checksum");
|
|
24867
|
+
await mkdir9(dir, { recursive: true });
|
|
24868
|
+
const work = await mkdtemp6(join17(dir, ".download-"));
|
|
24869
|
+
try {
|
|
24870
|
+
await writeFile9(join17(work, name), bytes);
|
|
24871
|
+
const inside2 = process.platform === "win32" ? `bin/${executable2}` : `${name.replace(/\.(zip|tar\.gz)$/, "")}/bin/${executable2}`;
|
|
24872
|
+
const unpacked = await exec2("tar", ["-xf", name, inside2], { cwd: work, timeout: 6e4 });
|
|
24873
|
+
if (unpacked.exitCode !== 0) throw new Error(unpacked.stderr.trim() || "couldn't unpack it");
|
|
24874
|
+
await chmod5(join17(work, inside2), 493);
|
|
24875
|
+
await rename5(join17(work, inside2), path2).catch((error62) => {
|
|
24876
|
+
if (!existsSync13(path2)) throw error62;
|
|
24877
|
+
});
|
|
24878
|
+
} finally {
|
|
24879
|
+
await rm8(work, { recursive: true, force: true });
|
|
24880
|
+
}
|
|
24881
|
+
}
|
|
24882
|
+
async function linkInBin(path2) {
|
|
24883
|
+
if (process.platform === "win32") return;
|
|
24884
|
+
const link2 = join17(toolsBin(), executable2);
|
|
24885
|
+
await mkdir9(toolsBin(), { recursive: true });
|
|
24886
|
+
await unlink(link2).catch(() => {
|
|
24887
|
+
});
|
|
24888
|
+
await symlink(path2, link2).catch(() => {
|
|
24889
|
+
});
|
|
24890
|
+
}
|
|
24891
|
+
|
|
24459
24892
|
// ../core/src/github/gh.ts
|
|
24460
24893
|
var GhCli = class {
|
|
24461
24894
|
constructor(cwd2) {
|
|
@@ -24464,8 +24897,8 @@ var GhCli = class {
|
|
|
24464
24897
|
cwd;
|
|
24465
24898
|
repoCache;
|
|
24466
24899
|
/** Run `gh` without prompts, colors or update notices; never throws for its exit code. */
|
|
24467
|
-
run(args, options = {}) {
|
|
24468
|
-
return exec2(
|
|
24900
|
+
async run(args, options = {}) {
|
|
24901
|
+
return exec2(await ghBinary(), args, {
|
|
24469
24902
|
cwd: this.cwd,
|
|
24470
24903
|
timeout: options.timeout ?? 6e4,
|
|
24471
24904
|
env: { GH_PROMPT_DISABLED: "1", GH_NO_UPDATE_NOTIFIER: "1", NO_COLOR: "1" },
|
|
@@ -24489,12 +24922,54 @@ ${result.stdout}`.trim()
|
|
|
24489
24922
|
return JSON.parse(await this.gh(args));
|
|
24490
24923
|
}
|
|
24491
24924
|
async ready() {
|
|
24492
|
-
if (!await
|
|
24925
|
+
if (!await ghBinary().then(Boolean, () => false)) {
|
|
24926
|
+
return { installed: false, authenticated: false };
|
|
24927
|
+
}
|
|
24493
24928
|
const status2 = await this.run(["auth", "status", "--hostname", "github.com"], {
|
|
24494
24929
|
timeout: 2e4
|
|
24495
24930
|
});
|
|
24496
24931
|
return { installed: true, authenticated: status2.exitCode === 0 };
|
|
24497
24932
|
}
|
|
24933
|
+
async createPrivateRepository(name) {
|
|
24934
|
+
const result = await this.run(["api", "user/repos", "--method", "POST", "--input", "-"], {
|
|
24935
|
+
input: JSON.stringify({ name, private: true, auto_init: true })
|
|
24936
|
+
});
|
|
24937
|
+
if (result.exitCode !== 0) {
|
|
24938
|
+
throw ghError(result, {
|
|
24939
|
+
code: "not-found",
|
|
24940
|
+
message: "Couldn't create your private app on GitHub.",
|
|
24941
|
+
hint: "That name may already be in use, or your account may not allow new apps. Your local work is still here. Check GitHub before trying again.",
|
|
24942
|
+
details: result.stderr
|
|
24943
|
+
});
|
|
24944
|
+
}
|
|
24945
|
+
const created = JSON.parse(result.stdout);
|
|
24946
|
+
return {
|
|
24947
|
+
repo: {
|
|
24948
|
+
owner: created.owner.login,
|
|
24949
|
+
name: created.name,
|
|
24950
|
+
url: created.html_url,
|
|
24951
|
+
defaultBranch: created.default_branch,
|
|
24952
|
+
isPrivate: created.private
|
|
24953
|
+
},
|
|
24954
|
+
cloneUrl: created.clone_url
|
|
24955
|
+
};
|
|
24956
|
+
}
|
|
24957
|
+
/** Use the connected GitHub account for this app, irrespective of the Mac's SSH identity. */
|
|
24958
|
+
async configureCredentials() {
|
|
24959
|
+
const git = (args) => exec2("git", args, { cwd: this.cwd, timeout: 1e4 });
|
|
24960
|
+
const key2 = "credential.https://github.com.helper";
|
|
24961
|
+
await git(["config", "--local", "--unset-all", key2]);
|
|
24962
|
+
for (const value of ["", `!'${await ghBinary()}' auth git-credential`]) {
|
|
24963
|
+
const result = await git(["config", "--local", "--add", key2, value]);
|
|
24964
|
+
if (result.exitCode !== 0)
|
|
24965
|
+
throw new ClodableError({
|
|
24966
|
+
code: "gh-auth",
|
|
24967
|
+
message: "Couldn't connect this app to your GitHub account.",
|
|
24968
|
+
hint: "Try Set up saving again.",
|
|
24969
|
+
details: result.stderr
|
|
24970
|
+
});
|
|
24971
|
+
}
|
|
24972
|
+
}
|
|
24498
24973
|
/** The builder's own repositories (not forks), most recently changed first. */
|
|
24499
24974
|
async repositories(limit = 40) {
|
|
24500
24975
|
const repos = await this.json([
|
|
@@ -24509,8 +24984,42 @@ ${result.stdout}`.trim()
|
|
|
24509
24984
|
return repos.map((r2) => ({ name: r2.nameWithOwner, description: r2.description }));
|
|
24510
24985
|
}
|
|
24511
24986
|
/** Bring a repository onto this computer, into `target`. */
|
|
24987
|
+
/**
|
|
24988
|
+
* Clone over HTTPS, signed in as the GitHub CLI's account whatever protocol gh is set to: an SSH
|
|
24989
|
+
* key on this computer may belong to another account, or have no access. The clone keeps gh as
|
|
24990
|
+
* its sign-in for github.com, so Clodable's fetches and pushes there are that account too (what
|
|
24991
|
+
* `gh auth setup-git` does, for this folder only).
|
|
24992
|
+
*/
|
|
24512
24993
|
async clone(repo, target) {
|
|
24513
|
-
|
|
24994
|
+
const helper = `!'${await ghBinary()}' auth git-credential`;
|
|
24995
|
+
const cloned = await exec2(
|
|
24996
|
+
"git",
|
|
24997
|
+
[
|
|
24998
|
+
"-c",
|
|
24999
|
+
"credential.helper=",
|
|
25000
|
+
"-c",
|
|
25001
|
+
`credential.helper=${helper}`,
|
|
25002
|
+
"clone",
|
|
25003
|
+
`https://github.com/${repo}.git`,
|
|
25004
|
+
target
|
|
25005
|
+
],
|
|
25006
|
+
{ cwd: this.cwd, timeout: 10 * 6e4, env: { GIT_TERMINAL_PROMPT: "0" } }
|
|
25007
|
+
);
|
|
25008
|
+
if (cloned.exitCode !== 0) {
|
|
25009
|
+
throw ghError(cloned, {
|
|
25010
|
+
code: "unknown",
|
|
25011
|
+
message: "GitHub didn't accept a request.",
|
|
25012
|
+
details: `git clone https://github.com/${repo}.git
|
|
25013
|
+
${cloned.stderr}`.trim()
|
|
25014
|
+
});
|
|
25015
|
+
}
|
|
25016
|
+
const key2 = "credential.https://github.com.helper";
|
|
25017
|
+
for (const value of ["", helper]) {
|
|
25018
|
+
await exec2("git", ["config", "--local", "--add", key2, value], {
|
|
25019
|
+
cwd: target,
|
|
25020
|
+
timeout: 1e4
|
|
25021
|
+
});
|
|
25022
|
+
}
|
|
24514
25023
|
}
|
|
24515
25024
|
async viewer() {
|
|
24516
25025
|
const user = await this.json([
|
|
@@ -24665,6 +25174,35 @@ ${result.stdout}`.trim()
|
|
|
24665
25174
|
const doing = step2?.name ?? (run2.status === "completed" ? "Complete" : void 0);
|
|
24666
25175
|
return { ...doing ? { step: doing } : {}, ...lastSeconds ? { lastSeconds } : {} };
|
|
24667
25176
|
}
|
|
25177
|
+
async retryDeployment(sha) {
|
|
25178
|
+
const { owner, name } = await this.repo();
|
|
25179
|
+
const { workflow_runs: runs } = await this.json([
|
|
25180
|
+
"api",
|
|
25181
|
+
`repos/${owner}/${name}/actions/workflows/clodable-netlify.yml/runs?head_sha=${encodeURIComponent(sha)}&per_page=20`
|
|
25182
|
+
]);
|
|
25183
|
+
const run2 = runs.find(
|
|
25184
|
+
(r2) => r2.head_sha === sha && r2.path.split("@")[0] === ".github/workflows/clodable-netlify.yml"
|
|
25185
|
+
);
|
|
25186
|
+
if (!run2) return false;
|
|
25187
|
+
if (run2.status !== "completed") return "running";
|
|
25188
|
+
if (!["failure", "cancelled", "timed_out", "action_required"].includes(run2.conclusion ?? ""))
|
|
25189
|
+
return false;
|
|
25190
|
+
await this.gh([
|
|
25191
|
+
"api",
|
|
25192
|
+
"--method",
|
|
25193
|
+
"POST",
|
|
25194
|
+
`repos/${owner}/${name}/actions/runs/${run2.id}/rerun`
|
|
25195
|
+
]);
|
|
25196
|
+
return "started";
|
|
25197
|
+
}
|
|
25198
|
+
async hasDeployments() {
|
|
25199
|
+
const { owner, name } = await this.repo();
|
|
25200
|
+
const deployments = await this.json([
|
|
25201
|
+
"api",
|
|
25202
|
+
`repos/${owner}/${name}/deployments?per_page=1`
|
|
25203
|
+
]);
|
|
25204
|
+
return deployments.length > 0;
|
|
25205
|
+
}
|
|
24668
25206
|
async deploymentsFor(sha) {
|
|
24669
25207
|
const { owner, name } = await this.repo();
|
|
24670
25208
|
const deployments = await this.json(["api", `repos/${owner}/${name}/deployments?sha=${sha}&per_page=20`]);
|
|
@@ -24684,7 +25222,7 @@ ${result.stdout}`.trim()
|
|
|
24684
25222
|
return out;
|
|
24685
25223
|
}
|
|
24686
25224
|
};
|
|
24687
|
-
var OFFLINE = /error connecting to|could not resolve host|no such host|connection refused|network is unreachable|i\/o timeout|tls handshake timeout|context deadline exceeded/i;
|
|
25225
|
+
var OFFLINE = /error connecting to|could not resolve host|failed to connect to|no such host|connection refused|network is unreachable|i\/o timeout|tls handshake timeout|context deadline exceeded/i;
|
|
24688
25226
|
function ghError(result, otherwise) {
|
|
24689
25227
|
const text2 = `${result.stderr}
|
|
24690
25228
|
${result.stdout}`.trim();
|
|
@@ -24722,9 +25260,9 @@ function toPullRequest(raw) {
|
|
|
24722
25260
|
|
|
24723
25261
|
// ../core/src/inbox.ts
|
|
24724
25262
|
import { randomBytes } from "node:crypto";
|
|
24725
|
-
import { existsSync as
|
|
24726
|
-
import { readdir as readdir3, readFile as
|
|
24727
|
-
import { join as
|
|
25263
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
25264
|
+
import { readdir as readdir3, readFile as readFile10, rename as rename6, rm as rm9 } from "node:fs/promises";
|
|
25265
|
+
import { join as join18 } from "node:path";
|
|
24728
25266
|
var INBOX_DIR = ".clodable/inbox";
|
|
24729
25267
|
var Page = external_exports.object({ url: external_exports.string(), path: external_exports.string(), title: external_exports.string().optional() });
|
|
24730
25268
|
var Source = external_exports.object({
|
|
@@ -24765,24 +25303,24 @@ async function writeInbox(root, item) {
|
|
|
24765
25303
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
24766
25304
|
const id = `${item.kind}-${createdAt.replace(/[-:.TZ]/g, "")}-${randomBytes(3).toString("hex")}`;
|
|
24767
25305
|
const full = { ...item, id, createdAt };
|
|
24768
|
-
await writeJsonFile(
|
|
25306
|
+
await writeJsonFile(join18(root, INBOX_DIR, `${id}.json`), full);
|
|
24769
25307
|
return full;
|
|
24770
25308
|
}
|
|
24771
25309
|
async function waiting(root) {
|
|
24772
|
-
const dir =
|
|
24773
|
-
if (!
|
|
25310
|
+
const dir = join18(root, INBOX_DIR);
|
|
25311
|
+
if (!existsSync14(dir)) return [];
|
|
24774
25312
|
const found2 = [];
|
|
24775
25313
|
for (const name of (await readdir3(dir)).filter((n4) => n4.endsWith(".json")).sort()) {
|
|
24776
25314
|
let text2;
|
|
24777
25315
|
try {
|
|
24778
|
-
text2 = await
|
|
25316
|
+
text2 = await readFile10(join18(dir, name), "utf8");
|
|
24779
25317
|
} catch {
|
|
24780
25318
|
continue;
|
|
24781
25319
|
}
|
|
24782
25320
|
try {
|
|
24783
25321
|
found2.push({ name, item: JSON.parse(text2) });
|
|
24784
25322
|
} catch {
|
|
24785
|
-
await
|
|
25323
|
+
await rm9(join18(dir, name), { force: true });
|
|
24786
25324
|
}
|
|
24787
25325
|
}
|
|
24788
25326
|
return found2;
|
|
@@ -24793,24 +25331,24 @@ async function readInbox(root) {
|
|
|
24793
25331
|
var SAFE_ID = /^[\w-]+$/;
|
|
24794
25332
|
async function ackInbox(root, id) {
|
|
24795
25333
|
if (!SAFE_ID.test(id)) return;
|
|
24796
|
-
await
|
|
25334
|
+
await rm9(join18(root, INBOX_DIR, `${id}.json`), { force: true });
|
|
24797
25335
|
}
|
|
24798
25336
|
var PRESENCE_DIR = ".clodable/local";
|
|
24799
25337
|
var LIVE_MS = 2e4;
|
|
24800
25338
|
var GONE_MS = 24 * 60 * 6e4;
|
|
24801
25339
|
async function livePresences(root, now) {
|
|
24802
25340
|
const live = /* @__PURE__ */ new Map();
|
|
24803
|
-
const dir =
|
|
24804
|
-
if (!
|
|
25341
|
+
const dir = join18(root, PRESENCE_DIR);
|
|
25342
|
+
if (!existsSync14(dir)) return live;
|
|
24805
25343
|
for (const name of await readdir3(dir)) {
|
|
24806
25344
|
if (!/^session-[\w-]+\.json$/.test(name)) continue;
|
|
24807
25345
|
let presence;
|
|
24808
25346
|
try {
|
|
24809
|
-
presence = JSON.parse(await
|
|
25347
|
+
presence = JSON.parse(await readFile10(join18(dir, name), "utf8"));
|
|
24810
25348
|
} catch {
|
|
24811
25349
|
continue;
|
|
24812
25350
|
}
|
|
24813
|
-
if (now - presence.alive > GONE_MS) await
|
|
25351
|
+
if (now - presence.alive > GONE_MS) await rm9(join18(dir, name), { force: true });
|
|
24814
25352
|
else if (now - presence.alive <= LIVE_MS) live.set(presence.id, presence);
|
|
24815
25353
|
}
|
|
24816
25354
|
return live;
|
|
@@ -24830,37 +25368,37 @@ async function claimInbox(root, session) {
|
|
|
24830
25368
|
if (found2.length === 0) return [];
|
|
24831
25369
|
const live = await livePresences(root, Date.now());
|
|
24832
25370
|
const owner = usedLast(live);
|
|
24833
|
-
const dir =
|
|
25371
|
+
const dir = join18(root, INBOX_DIR);
|
|
24834
25372
|
const items = [];
|
|
24835
25373
|
for (const { name, item } of found2) {
|
|
24836
25374
|
const mine = item.conversation && live.has(item.conversation) ? item.conversation === session : !owner || owner === session;
|
|
24837
25375
|
if (!mine) continue;
|
|
24838
|
-
const claimed =
|
|
25376
|
+
const claimed = join18(dir, `.${name}.${session}.claimed`);
|
|
24839
25377
|
try {
|
|
24840
|
-
await
|
|
25378
|
+
await rename6(join18(dir, name), claimed);
|
|
24841
25379
|
} catch {
|
|
24842
25380
|
continue;
|
|
24843
25381
|
}
|
|
24844
25382
|
items.push(item);
|
|
24845
|
-
await
|
|
25383
|
+
await rm9(claimed, { force: true });
|
|
24846
25384
|
}
|
|
24847
25385
|
return items;
|
|
24848
25386
|
}
|
|
24849
25387
|
|
|
24850
25388
|
// ../core/src/move/copy.ts
|
|
24851
|
-
import { existsSync as
|
|
24852
|
-
import { mkdtemp as
|
|
24853
|
-
import { join as
|
|
25389
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
25390
|
+
import { mkdtemp as mkdtemp7, readdir as readdir5, readFile as readFile12, rename as rename8, rm as rm12 } from "node:fs/promises";
|
|
25391
|
+
import { join as join22 } from "node:path";
|
|
24854
25392
|
|
|
24855
25393
|
// ../core/src/move/export.ts
|
|
24856
|
-
import { createWriteStream as createWriteStream3, existsSync as
|
|
24857
|
-
import { copyFile, readdir as readdir4, rm as
|
|
25394
|
+
import { createWriteStream as createWriteStream3, existsSync as existsSync15 } from "node:fs";
|
|
25395
|
+
import { copyFile, readdir as readdir4, rm as rm11, stat as stat2, writeFile as writeFile10 } from "node:fs/promises";
|
|
24858
25396
|
import { homedir as homedir2 } from "node:os";
|
|
24859
|
-
import { basename as basename4, extname, join as
|
|
25397
|
+
import { basename as basename4, extname, join as join19 } from "node:path";
|
|
24860
25398
|
|
|
24861
25399
|
// ../core/src/move/zip.ts
|
|
24862
25400
|
import { createReadStream, createWriteStream as createWriteStream2 } from "node:fs";
|
|
24863
|
-
import { open as open2, rename as
|
|
25401
|
+
import { open as open2, rename as rename7, rm as rm10 } from "node:fs/promises";
|
|
24864
25402
|
import { Transform } from "node:stream";
|
|
24865
25403
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
24866
25404
|
import { crc32, createInflateRaw } from "node:zlib";
|
|
@@ -24981,9 +25519,9 @@ async function extractEntry(path2, entry, target) {
|
|
|
24981
25519
|
if (size !== entry.size || crc >>> 0 !== entry.crc >>> 0) {
|
|
24982
25520
|
throw new Error("the file inside the zip is damaged");
|
|
24983
25521
|
}
|
|
24984
|
-
await
|
|
25522
|
+
await rename7(partial2, target);
|
|
24985
25523
|
} catch (error62) {
|
|
24986
|
-
await
|
|
25524
|
+
await rm10(partial2, { force: true });
|
|
24987
25525
|
throw error62;
|
|
24988
25526
|
}
|
|
24989
25527
|
}
|
|
@@ -24992,29 +25530,59 @@ async function extractEntry(path2, entry, target) {
|
|
|
24992
25530
|
var BACKUP = "export.backup";
|
|
24993
25531
|
var FILES_LIST = "files.jsonl";
|
|
24994
25532
|
var JOBS_FILE = "jobs.json";
|
|
24995
|
-
|
|
24996
|
-
|
|
25533
|
+
var isBackup = (name) => /\.(backup|dump)$/i.test(name);
|
|
25534
|
+
var projectId = (text2) => text2.match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i)?.[0]?.toLowerCase();
|
|
25535
|
+
async function exportNames(source) {
|
|
25536
|
+
if (!source.toLowerCase().endsWith(".zip")) return [basename4(source)];
|
|
25537
|
+
const entries = await zipEntries(source).catch((error62) => {
|
|
25538
|
+
throw unreadable(error62);
|
|
25539
|
+
});
|
|
25540
|
+
const backups = entries.filter((e) => isBackup(e.name));
|
|
25541
|
+
if (backups.length !== 1) {
|
|
25542
|
+
throw new ClodableError({
|
|
25543
|
+
code: "export-unreadable",
|
|
25544
|
+
message: backups.length ? "That zip holds more than one database export." : "That zip doesn't hold a database export.",
|
|
25545
|
+
hint: "Choose the single .backup or .dump file for this app, or download its export again from Lovable."
|
|
25546
|
+
});
|
|
25547
|
+
}
|
|
25548
|
+
return [basename4(source), basename4(backups[0].name)];
|
|
25549
|
+
}
|
|
25550
|
+
async function checkExportSource(source, projectUrl2) {
|
|
25551
|
+
const names2 = await exportNames(source);
|
|
25552
|
+
const expected = projectUrl2 && projectId(projectUrl2);
|
|
25553
|
+
if (expected && names2.some((name) => projectId(name) && projectId(name) !== expected)) {
|
|
25554
|
+
throw new ClodableError({
|
|
25555
|
+
code: "export-unreadable",
|
|
25556
|
+
message: "That export is labelled for a different Lovable app.",
|
|
25557
|
+
hint: "Download this app's export, or tell Claude where you saved the correct file. Your saved copy hasn't changed."
|
|
25558
|
+
});
|
|
25559
|
+
}
|
|
25560
|
+
}
|
|
25561
|
+
async function findExport(folder = join19(homedir2(), "Downloads"), projectUrl2) {
|
|
25562
|
+
if (!existsSync15(folder)) return void 0;
|
|
24997
25563
|
const month = Date.now() - 31 * 24 * 60 * 6e4;
|
|
24998
25564
|
const candidates2 = [];
|
|
24999
25565
|
for (const name of await readdir4(folder).catch(() => [])) {
|
|
25000
25566
|
const ext = extname(name).toLowerCase();
|
|
25001
|
-
if (ext !== ".zip" &&
|
|
25002
|
-
const path2 =
|
|
25567
|
+
if (ext !== ".zip" && !isBackup(name)) continue;
|
|
25568
|
+
const path2 = join19(folder, name);
|
|
25003
25569
|
const info = await stat2(path2).catch(() => void 0);
|
|
25004
25570
|
if (!info?.isFile() || info.mtimeMs < month) continue;
|
|
25005
25571
|
candidates2.push({ path: path2, at: info.mtimeMs });
|
|
25006
25572
|
}
|
|
25007
25573
|
candidates2.sort((a2, b) => b.at - a2.at);
|
|
25008
|
-
|
|
25009
|
-
|
|
25010
|
-
|
|
25011
|
-
|
|
25574
|
+
const expected = projectUrl2 && projectId(projectUrl2);
|
|
25575
|
+
if (!expected) return void 0;
|
|
25576
|
+
for (const { path: path2 } of candidates2) {
|
|
25577
|
+
const names2 = await exportNames(path2).catch(() => []);
|
|
25578
|
+
const ids = names2.map(projectId).filter(Boolean);
|
|
25579
|
+
if (ids.length > 0 && ids.every((id) => id === expected)) return path2;
|
|
25012
25580
|
}
|
|
25013
25581
|
return void 0;
|
|
25014
25582
|
}
|
|
25015
25583
|
async function takeBackup(source, dir) {
|
|
25016
|
-
const target =
|
|
25017
|
-
await
|
|
25584
|
+
const target = join19(dir, BACKUP);
|
|
25585
|
+
await rm11(target, { force: true });
|
|
25018
25586
|
if (source.toLowerCase().endsWith(".zip")) {
|
|
25019
25587
|
let entries;
|
|
25020
25588
|
try {
|
|
@@ -25022,15 +25590,15 @@ async function takeBackup(source, dir) {
|
|
|
25022
25590
|
} catch (error62) {
|
|
25023
25591
|
throw unreadable(error62);
|
|
25024
25592
|
}
|
|
25025
|
-
const backups = entries.filter((e) => e.name
|
|
25026
|
-
if (backups.length
|
|
25593
|
+
const backups = entries.filter((e) => isBackup(e.name));
|
|
25594
|
+
if (backups.length !== 1) {
|
|
25027
25595
|
throw new ClodableError({
|
|
25028
25596
|
code: "export-unreadable",
|
|
25029
|
-
message: "That zip doesn't hold a database export.",
|
|
25030
|
-
hint: "
|
|
25597
|
+
message: backups.length ? "That zip holds more than one database export." : "That zip doesn't hold a database export.",
|
|
25598
|
+
hint: "Choose the single .backup or .dump file for this app, or download its export again from Lovable."
|
|
25031
25599
|
});
|
|
25032
25600
|
}
|
|
25033
|
-
const entry = backups
|
|
25601
|
+
const entry = backups[0];
|
|
25034
25602
|
try {
|
|
25035
25603
|
await extractEntry(source, entry, target);
|
|
25036
25604
|
} catch (error62) {
|
|
@@ -25048,9 +25616,9 @@ var unreadable = (error62) => new ClodableError({
|
|
|
25048
25616
|
});
|
|
25049
25617
|
async function readExport(source, dir) {
|
|
25050
25618
|
await takeBackup(source, dir);
|
|
25051
|
-
const backup =
|
|
25619
|
+
const backup = join19(dir, BACKUP);
|
|
25052
25620
|
const listing = await listArchive(backup);
|
|
25053
|
-
await
|
|
25621
|
+
await writeFile10(join19(dir, "toc.list"), listing, { mode: 384 });
|
|
25054
25622
|
const toc = parseToc(listing);
|
|
25055
25623
|
if (toc.entries.length === 0) {
|
|
25056
25624
|
throw new ClodableError({
|
|
@@ -25107,7 +25675,7 @@ async function readExport(source, dir) {
|
|
|
25107
25675
|
const wanted = (e) => e.type === "TABLE DATA" && (e.schema !== null && !isManaged(e.schema) && e.schema !== "supabase_migrations" || e.schema === "auth" && ["users", "identities", "sessions"].includes(e.tag) || e.schema === "storage" && (e.tag === "buckets" || e.tag === "objects") || e.schema === "cron" && e.tag === "job" || e.schema === "vault" && e.tag === "secrets");
|
|
25108
25676
|
await scanRows(backup, toc.entries.filter(wanted), dir, summary, sourceRefs);
|
|
25109
25677
|
summary.sourceRefs = [...sourceRefs].sort();
|
|
25110
|
-
await writeJsonFile(
|
|
25678
|
+
await writeJsonFile(join19(dir, "export.json"), summary, { private: true });
|
|
25111
25679
|
return { summary, toc };
|
|
25112
25680
|
}
|
|
25113
25681
|
var API_ROLES = /* @__PURE__ */ new Set(["anon", "authenticated", "service_role"]);
|
|
@@ -25167,7 +25735,7 @@ function copyValue(raw) {
|
|
|
25167
25735
|
);
|
|
25168
25736
|
}
|
|
25169
25737
|
async function scanRows(backup, entries, dir, summary, sourceRefs) {
|
|
25170
|
-
const files = createWriteStream3(
|
|
25738
|
+
const files = createWriteStream3(join19(dir, FILES_LIST), { mode: 384 });
|
|
25171
25739
|
const jobs = [];
|
|
25172
25740
|
const buckets = /* @__PURE__ */ new Map();
|
|
25173
25741
|
let table = null;
|
|
@@ -25259,11 +25827,11 @@ async function scanRows(backup, entries, dir, summary, sourceRefs) {
|
|
|
25259
25827
|
summary.buckets = [...buckets.values()].sort((a2, b) => a2.id.localeCompare(b.id));
|
|
25260
25828
|
summary.scheduledJobs.sort();
|
|
25261
25829
|
summary.vaultSecrets.sort();
|
|
25262
|
-
await writeJsonFile(
|
|
25830
|
+
await writeJsonFile(join19(dir, JOBS_FILE), jobs, { private: true });
|
|
25263
25831
|
}
|
|
25264
25832
|
|
|
25265
25833
|
// ../core/src/move/restore.ts
|
|
25266
|
-
import { join as
|
|
25834
|
+
import { join as join20 } from "node:path";
|
|
25267
25835
|
var managed = [...MANAGED_SCHEMAS].map((s) => `'${s}'`).join(", ");
|
|
25268
25836
|
async function emptyCopy(sql) {
|
|
25269
25837
|
await sql.run(`
|
|
@@ -25310,7 +25878,7 @@ end $$;`);
|
|
|
25310
25878
|
}
|
|
25311
25879
|
async function* copyExport(target, dir, toc, summary, options = {}) {
|
|
25312
25880
|
const plan = planRestore(toc, new Set(summary.appTriggers));
|
|
25313
|
-
const backup =
|
|
25881
|
+
const backup = join20(dir, BACKUP);
|
|
25314
25882
|
const problems = [];
|
|
25315
25883
|
const keep = (errors) => {
|
|
25316
25884
|
for (const error62 of errors) {
|
|
@@ -25454,11 +26022,22 @@ async function liveSignIn(api, ref, url2, confirmEmail, signUp) {
|
|
|
25454
26022
|
}
|
|
25455
26023
|
var backToPreview = (auth) => String(auth.uri_allow_list ?? "").includes("http://localhost:*");
|
|
25456
26024
|
var backToSite = (auth, site) => auth.site_url === site && String(auth.uri_allow_list ?? "").includes(`${site}/**`);
|
|
26025
|
+
async function newBackendSignIn(api, ref, site) {
|
|
26026
|
+
const current = await api.authConfig(ref);
|
|
26027
|
+
await api.updateAuthConfig(ref, {
|
|
26028
|
+
site_url: site ?? PREVIEW_ORIGIN,
|
|
26029
|
+
uri_allow_list: allowList(current.uri_allow_list, [
|
|
26030
|
+
...PREVIEW_REDIRECTS,
|
|
26031
|
+
...site ? [`${site}/**`] : []
|
|
26032
|
+
]),
|
|
26033
|
+
mailer_autoconfirm: true
|
|
26034
|
+
});
|
|
26035
|
+
}
|
|
25457
26036
|
|
|
25458
26037
|
// ../core/src/move/switch.ts
|
|
25459
|
-
import { existsSync as
|
|
25460
|
-
import { readFile as
|
|
25461
|
-
import { join as
|
|
26038
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
26039
|
+
import { readFile as readFile11, writeFile as writeFile11 } from "node:fs/promises";
|
|
26040
|
+
import { join as join21 } from "node:path";
|
|
25462
26041
|
function writeGrants(grants) {
|
|
25463
26042
|
const lines = [];
|
|
25464
26043
|
for (const [table, roles] of Object.entries(grants)) {
|
|
@@ -25616,9 +26195,9 @@ async function giveBackGrants(sql, grants) {
|
|
|
25616
26195
|
return lines.length;
|
|
25617
26196
|
}
|
|
25618
26197
|
async function recreateJobs(sql, dir, from, to, keys) {
|
|
25619
|
-
const path2 =
|
|
25620
|
-
if (!
|
|
25621
|
-
const jobs = JSON.parse(await
|
|
26198
|
+
const path2 = join21(dir, JOBS_FILE);
|
|
26199
|
+
if (!existsSync16(path2)) return { created: 0, check: [] };
|
|
26200
|
+
const jobs = JSON.parse(await readFile11(path2, "utf8"));
|
|
25622
26201
|
const site = to.siteUrl ? new URL(to.siteUrl).origin : void 0;
|
|
25623
26202
|
const existing = new Set(
|
|
25624
26203
|
(await sql.rows(
|
|
@@ -25710,25 +26289,25 @@ async function* goLive(ws, options = {}) {
|
|
|
25710
26289
|
const backend = backendOf(state.home.ref, keys);
|
|
25711
26290
|
const { SUPABASE_SERVICE_ROLE_KEY: _, ...values } = backendEnv(backend);
|
|
25712
26291
|
for (const name of [".env", ".env.local", ".env.production"]) {
|
|
25713
|
-
const path2 =
|
|
25714
|
-
if (!
|
|
25715
|
-
const before = await
|
|
26292
|
+
const path2 = join21(ws.root, name);
|
|
26293
|
+
if (!existsSync16(path2)) continue;
|
|
26294
|
+
const before = await readFile11(path2, "utf8");
|
|
25716
26295
|
const after = rewriteEnv(before, values);
|
|
25717
26296
|
if (after !== before) {
|
|
25718
|
-
await
|
|
26297
|
+
await writeFile11(path2, after);
|
|
25719
26298
|
files.push(name);
|
|
25720
26299
|
}
|
|
25721
26300
|
}
|
|
25722
26301
|
if (from) {
|
|
25723
|
-
const toml =
|
|
25724
|
-
if (
|
|
25725
|
-
const before = await
|
|
26302
|
+
const toml = join21(ws.root, "supabase", "config.toml");
|
|
26303
|
+
if (existsSync16(toml)) {
|
|
26304
|
+
const before = await readFile11(toml, "utf8");
|
|
25726
26305
|
const after = before.replace(
|
|
25727
26306
|
/^project_id\s*=\s*"[^"]*"/m,
|
|
25728
26307
|
`project_id = "${state.home.ref}"`
|
|
25729
26308
|
);
|
|
25730
26309
|
if (after !== before) {
|
|
25731
|
-
await
|
|
26310
|
+
await writeFile11(toml, after);
|
|
25732
26311
|
files.push("supabase/config.toml");
|
|
25733
26312
|
}
|
|
25734
26313
|
}
|
|
@@ -25736,7 +26315,7 @@ async function* goLive(ws, options = {}) {
|
|
|
25736
26315
|
if (!file3.text.includes(from)) continue;
|
|
25737
26316
|
const next = repoint(file3.text, from, state.home.ref, { ...keys.legacy, anon: backend.anon });
|
|
25738
26317
|
if (next.text !== file3.text) {
|
|
25739
|
-
await
|
|
26318
|
+
await writeFile11(join21(ws.root, file3.path), next.text);
|
|
25740
26319
|
files.push(file3.path.replace(/^\//, ""));
|
|
25741
26320
|
}
|
|
25742
26321
|
}
|
|
@@ -25921,7 +26500,7 @@ async function oldBackendCheck(sql, sourceRef) {
|
|
|
25921
26500
|
return {
|
|
25922
26501
|
id: "old-backend",
|
|
25923
26502
|
ok: naming.length === 0,
|
|
25924
|
-
label: naming.length === 0 ? "
|
|
26503
|
+
label: naming.length === 0 ? "The checked database functions and webhooks no longer name the old backend" : `${count(naming.length, "database function or webhook")} still call Lovable Cloud`,
|
|
25925
26504
|
...naming.length > 0 ? { detail: naming.join(", ") } : {}
|
|
25926
26505
|
};
|
|
25927
26506
|
}
|
|
@@ -25966,18 +26545,19 @@ var API_PRIVILEGES = /* @__PURE__ */ new Set(["SELECT", "INSERT", "UPDATE", "DEL
|
|
|
25966
26545
|
// ../core/src/move/copy.ts
|
|
25967
26546
|
async function* importExport(ws, options = {}) {
|
|
25968
26547
|
yield step("move:export", "running", "Reading your export");
|
|
25969
|
-
const file3 = options.file ?? await findExport();
|
|
26548
|
+
const file3 = options.file ?? await findExport(void 0, ws.project.lovable.projectUrl);
|
|
25970
26549
|
if (!file3) {
|
|
25971
26550
|
throw new ClodableError({
|
|
25972
26551
|
code: "export-not-found",
|
|
25973
|
-
message: "Clodable
|
|
25974
|
-
hint: "
|
|
26552
|
+
message: "Clodable couldn't match an export in Downloads to this app.",
|
|
26553
|
+
hint: "Download this app's export from Lovable, or tell Claude the name and location of its .zip, .backup or .dump file. Clodable won't guess between apps."
|
|
25975
26554
|
});
|
|
25976
26555
|
}
|
|
26556
|
+
await checkExportSource(file3, ws.project.lovable.projectUrl);
|
|
25977
26557
|
const dir = await moveDir(ws.root);
|
|
25978
26558
|
const before = await loadMove(ws.root);
|
|
25979
26559
|
const pausedAt = before.switch?.liveAt ? void 0 : before.switch?.frozenAt;
|
|
25980
|
-
const target =
|
|
26560
|
+
const target = await mkdtemp7(join22(dir, "incoming-"));
|
|
25981
26561
|
let summary;
|
|
25982
26562
|
try {
|
|
25983
26563
|
summary = (await readExport(file3, target)).summary;
|
|
@@ -25989,13 +26569,13 @@ async function* importExport(ws, options = {}) {
|
|
|
25989
26569
|
hint: "Check the pause is in place in Lovable, export again, download the new zip, then read it."
|
|
25990
26570
|
});
|
|
25991
26571
|
}
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
25995
|
-
|
|
26572
|
+
}
|
|
26573
|
+
for (const name of await readdir5(target)) {
|
|
26574
|
+
await rm12(join22(dir, name), { recursive: true, force: true });
|
|
26575
|
+
await rename8(join22(target, name), join22(dir, name));
|
|
25996
26576
|
}
|
|
25997
26577
|
} finally {
|
|
25998
|
-
|
|
26578
|
+
await rm12(target, { recursive: true, force: true });
|
|
25999
26579
|
}
|
|
26000
26580
|
const sourceRef = ws.project.supabase.projectRef ?? summary.sourceRefs[0];
|
|
26001
26581
|
await updateMove(ws.root, (s) => {
|
|
@@ -26015,8 +26595,8 @@ function describeExport(summary) {
|
|
|
26015
26595
|
].join(" \xB7 ");
|
|
26016
26596
|
}
|
|
26017
26597
|
async function migrationVersions(root) {
|
|
26018
|
-
const dir =
|
|
26019
|
-
if (!
|
|
26598
|
+
const dir = join22(root, "supabase", "migrations");
|
|
26599
|
+
if (!existsSync17(dir)) return [];
|
|
26020
26600
|
return (await readdir5(dir)).map((name) => name.match(/^(\d{8,})_.*\.sql$/)?.[1]).filter((v) => Boolean(v)).sort();
|
|
26021
26601
|
}
|
|
26022
26602
|
async function* copyData(ws) {
|
|
@@ -26037,15 +26617,15 @@ async function* copyData(ws) {
|
|
|
26037
26617
|
}
|
|
26038
26618
|
const api = await SupabaseApi.required();
|
|
26039
26619
|
const dir = await moveDir(ws.root);
|
|
26040
|
-
const backup =
|
|
26041
|
-
if (!
|
|
26620
|
+
const backup = join22(dir, "export.backup");
|
|
26621
|
+
if (!existsSync17(backup)) {
|
|
26042
26622
|
throw new ClodableError({
|
|
26043
26623
|
code: "export-not-found",
|
|
26044
26624
|
message: "The export Clodable read is gone from this computer.",
|
|
26045
26625
|
hint: "Read it again: download the export from Lovable, then run that step again."
|
|
26046
26626
|
});
|
|
26047
26627
|
}
|
|
26048
|
-
const toc = parseToc(await
|
|
26628
|
+
const toc = parseToc(await readFile12(join22(dir, "toc.list"), "utf8"));
|
|
26049
26629
|
const summary = state.export.summary;
|
|
26050
26630
|
yield step("move:data", "running", "Copying your data", "Connecting to your new database");
|
|
26051
26631
|
const pg = await homeConnection(api, state.home);
|
|
@@ -26056,6 +26636,9 @@ async function* copyData(ws) {
|
|
|
26056
26636
|
const switching = Boolean(
|
|
26057
26637
|
state.switch?.frozenAt && state.export.importedAt > state.switch.frozenAt
|
|
26058
26638
|
);
|
|
26639
|
+
await updateMove(ws.root, (s) => {
|
|
26640
|
+
s.copyStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
26641
|
+
});
|
|
26059
26642
|
const outcome = yield* copyExport(
|
|
26060
26643
|
{ pg, sql, ref: state.home.ref, keys: keys.legacy },
|
|
26061
26644
|
dir,
|
|
@@ -26229,13 +26812,15 @@ async function diagnoseCopy(ws, options = {}) {
|
|
|
26229
26812
|
const api = await SupabaseApi.required();
|
|
26230
26813
|
const ref = state.home.ref;
|
|
26231
26814
|
const findings = [];
|
|
26232
|
-
const project = await api.project(ref)
|
|
26815
|
+
const project = await api.project(ref);
|
|
26233
26816
|
const running = project?.status === "ACTIVE_HEALTHY";
|
|
26234
26817
|
findings.push({
|
|
26235
26818
|
id: "running",
|
|
26236
26819
|
ok: running,
|
|
26237
|
-
label: running ? "Your new backend is running" :
|
|
26238
|
-
...running ? {} : {
|
|
26820
|
+
label: running ? "Your new backend is running" : project.status === "INACTIVE" || project.status === "GOING_DOWN" ? "Your new backend is paused" : "Your new backend isn't ready yet",
|
|
26821
|
+
...running ? {} : {
|
|
26822
|
+
fix: project.status === "INACTIVE" || project.status === "GOING_DOWN" ? "Restore it on its page in Supabase, then look again." : "Check its status in Supabase, then look again in a minute."
|
|
26823
|
+
}
|
|
26239
26824
|
});
|
|
26240
26825
|
if (!running) return { findings };
|
|
26241
26826
|
const sql = homeSql(api, ref);
|
|
@@ -26567,20 +27152,20 @@ async function* setUpEmails(ws, options = {}) {
|
|
|
26567
27152
|
}
|
|
26568
27153
|
|
|
26569
27154
|
// ../core/src/move/files.ts
|
|
26570
|
-
import { createHash as
|
|
26571
|
-
import { existsSync as
|
|
26572
|
-
import { appendFile, readFile as
|
|
26573
|
-
import { join as
|
|
27155
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
27156
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
27157
|
+
import { appendFile, readFile as readFile13 } from "node:fs/promises";
|
|
27158
|
+
import { join as join23 } from "node:path";
|
|
26574
27159
|
var LEDGER = "files-done.txt";
|
|
26575
27160
|
var key = (f) => `${f.bucket}/${f.name}#${f.size}`;
|
|
26576
27161
|
var path = (name) => name.split("/").map(encodeURIComponent).join("/");
|
|
26577
27162
|
async function readFileList(dir) {
|
|
26578
|
-
const list =
|
|
26579
|
-
if (!
|
|
26580
|
-
return (await
|
|
27163
|
+
const list = join23(dir, FILES_LIST);
|
|
27164
|
+
if (!existsSync18(list)) return [];
|
|
27165
|
+
return (await readFile13(list, "utf8")).split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
26581
27166
|
}
|
|
26582
27167
|
var authHeaders = (key2) => key2.startsWith("sb_") ? { apikey: key2 } : { apikey: key2, Authorization: `Bearer ${key2}` };
|
|
26583
|
-
async function
|
|
27168
|
+
async function download3(from, file3, isPublic, sourceKey) {
|
|
26584
27169
|
const url2 = isPublic ? `${projectUrl(from)}/storage/v1/object/public/${encodeURIComponent(file3.bucket)}/${path(file3.name)}` : `${projectUrl(from)}/storage/v1/object/${encodeURIComponent(file3.bucket)}/${path(file3.name)}`;
|
|
26585
27170
|
const response = await fetch(url2, {
|
|
26586
27171
|
headers: sourceKey && !isPublic ? authHeaders(sourceKey) : {},
|
|
@@ -26609,13 +27194,13 @@ async function upload(to, secretKey, file3, body) {
|
|
|
26609
27194
|
throw new Error(`upload answered ${response.status} ${text2.slice(0, 200)}`);
|
|
26610
27195
|
}
|
|
26611
27196
|
}
|
|
26612
|
-
var sha2562 = (data) =>
|
|
27197
|
+
var sha2562 = (data) => createHash6("sha256").update(data).digest("hex");
|
|
26613
27198
|
async function* copyFiles(target, dir, buckets) {
|
|
26614
27199
|
const files = await readFileList(dir);
|
|
26615
27200
|
const isPublic = new Map(buckets.map((b) => [b.id, b.public]));
|
|
26616
|
-
const ledgerPath =
|
|
27201
|
+
const ledgerPath = join23(dir, LEDGER);
|
|
26617
27202
|
const done = new Set(
|
|
26618
|
-
|
|
27203
|
+
existsSync18(ledgerPath) ? (await readFile13(ledgerPath, "utf8")).split("\n").filter(Boolean) : []
|
|
26619
27204
|
);
|
|
26620
27205
|
const { todo, waiting: waiting2, tooBig, ...plan } = planCopy(files, done, isPublic, target);
|
|
26621
27206
|
let copied = plan.copied;
|
|
@@ -26630,7 +27215,7 @@ async function* copyFiles(target, dir, buckets) {
|
|
|
26630
27215
|
while (next < todo.length) {
|
|
26631
27216
|
const file3 = todo[next++];
|
|
26632
27217
|
try {
|
|
26633
|
-
const body = await
|
|
27218
|
+
const body = await download3(
|
|
26634
27219
|
target.from,
|
|
26635
27220
|
file3,
|
|
26636
27221
|
Boolean(isPublic.get(file3.bucket)),
|
|
@@ -26724,8 +27309,8 @@ async function checkSample(files, target, isPublic, skip) {
|
|
|
26724
27309
|
for (const file3 of sample) {
|
|
26725
27310
|
try {
|
|
26726
27311
|
const [before, after] = await Promise.all([
|
|
26727
|
-
|
|
26728
|
-
|
|
27312
|
+
download3(target.from, file3, Boolean(isPublic.get(bucket)), target.sourceKey),
|
|
27313
|
+
download3(target.to, file3, false, target.secretKey)
|
|
26729
27314
|
]);
|
|
26730
27315
|
if (sha2562(before) !== sha2562(after)) {
|
|
26731
27316
|
differences.push(`${bucket}: a copied file differs from the original`);
|
|
@@ -26788,18 +27373,18 @@ async function repointLinks(sql, from, to) {
|
|
|
26788
27373
|
}
|
|
26789
27374
|
|
|
26790
27375
|
// ../core/src/move/functions.ts
|
|
26791
|
-
import { existsSync as
|
|
26792
|
-
import { readdir as readdir6, readFile as
|
|
26793
|
-
import { dirname as
|
|
27376
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
27377
|
+
import { readdir as readdir6, readFile as readFile14 } from "node:fs/promises";
|
|
27378
|
+
import { dirname as dirname7, join as join24, normalize as normalize2, relative as relative3, sep as sep3 } from "node:path";
|
|
26794
27379
|
var BUILT_IN = /^SUPABASE_/;
|
|
26795
27380
|
var LOVABLE_OWN = /^LOVABLE_/;
|
|
26796
27381
|
var IMPORT = /(?:import|export)\s[^'"`;]*?from\s*["']([^"']+)["']|import\s*\(\s*["']([^"']+)["']\s*\)|import\s+["']([^"']+)["']/g;
|
|
26797
27382
|
async function jwtSettings(root) {
|
|
26798
27383
|
const settings2 = /* @__PURE__ */ new Map();
|
|
26799
|
-
const path2 =
|
|
26800
|
-
if (!
|
|
27384
|
+
const path2 = join24(root, "supabase", "config.toml");
|
|
27385
|
+
if (!existsSync19(path2)) return settings2;
|
|
26801
27386
|
let section = null;
|
|
26802
|
-
for (const line of (await
|
|
27387
|
+
for (const line of (await readFile14(path2, "utf8")).split("\n")) {
|
|
26803
27388
|
const header = line.match(/^\s*\[functions\.("?)([\w-]+)\1\]\s*$/);
|
|
26804
27389
|
if (header) {
|
|
26805
27390
|
section = header[2];
|
|
@@ -26815,35 +27400,35 @@ async function jwtSettings(root) {
|
|
|
26815
27400
|
return settings2;
|
|
26816
27401
|
}
|
|
26817
27402
|
async function localFunctions(root) {
|
|
26818
|
-
const base =
|
|
26819
|
-
if (!
|
|
27403
|
+
const base = join24(root, "supabase", "functions");
|
|
27404
|
+
if (!existsSync19(base)) return [];
|
|
26820
27405
|
const settings2 = await jwtSettings(root);
|
|
26821
27406
|
const out = [];
|
|
26822
27407
|
for (const entry of await readdir6(base, { withFileTypes: true })) {
|
|
26823
27408
|
if (!entry.isDirectory() || entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
26824
|
-
const dir =
|
|
27409
|
+
const dir = join24(base, entry.name);
|
|
26825
27410
|
const index = ["index.ts", "index.tsx", "index.js", "index.mjs"].find(
|
|
26826
|
-
(f) =>
|
|
27411
|
+
(f) => existsSync19(join24(dir, f))
|
|
26827
27412
|
);
|
|
26828
27413
|
if (!index) continue;
|
|
26829
|
-
const entrypoint =
|
|
27414
|
+
const entrypoint = join24(dir, index);
|
|
26830
27415
|
const files = /* @__PURE__ */ new Set();
|
|
26831
27416
|
const walk2 = async (file3) => {
|
|
26832
27417
|
const key2 = relative3(root, file3).split(sep3).join("/");
|
|
26833
|
-
if (files.has(key2) || !
|
|
27418
|
+
if (files.has(key2) || !existsSync19(file3)) return;
|
|
26834
27419
|
files.add(key2);
|
|
26835
27420
|
if (!/\.(m?[jt]sx?)$/.test(file3)) return;
|
|
26836
|
-
const text2 = await
|
|
27421
|
+
const text2 = await readFile14(file3, "utf8").catch(() => "");
|
|
26837
27422
|
for (const match of text2.matchAll(IMPORT)) {
|
|
26838
27423
|
const spec = match[1] ?? match[2] ?? match[3];
|
|
26839
27424
|
if (!spec || !(spec.startsWith("./") || spec.startsWith("../"))) continue;
|
|
26840
|
-
const target = normalize2(
|
|
27425
|
+
const target = normalize2(join24(dirname7(file3), spec));
|
|
26841
27426
|
if (relative3(root, target).startsWith("..")) continue;
|
|
26842
27427
|
await walk2(target);
|
|
26843
27428
|
}
|
|
26844
27429
|
};
|
|
26845
27430
|
await walk2(entrypoint);
|
|
26846
|
-
const importMap = ["deno.json", "deno.jsonc", "import_map.json"].map((f) =>
|
|
27431
|
+
const importMap = ["deno.json", "deno.jsonc", "import_map.json"].map((f) => join24(dir, f)).find((f) => existsSync19(f));
|
|
26847
27432
|
if (importMap) files.add(relative3(root, importMap).split(sep3).join("/"));
|
|
26848
27433
|
out.push({
|
|
26849
27434
|
name: entry.name,
|
|
@@ -26862,7 +27447,7 @@ async function functionSecrets(root, functions) {
|
|
|
26862
27447
|
for (const file3 of fn.files) {
|
|
26863
27448
|
if (seen.has(file3)) continue;
|
|
26864
27449
|
seen.add(file3);
|
|
26865
|
-
const text2 = await
|
|
27450
|
+
const text2 = await readFile14(join24(root, file3), "utf8").catch(() => "");
|
|
26866
27451
|
for (const match of text2.matchAll(/Deno\.env\.get\(\s*["'`]([A-Z][A-Z0-9_]*)["'`]\s*\)/g)) {
|
|
26867
27452
|
if (!BUILT_IN.test(match[1]) && !LOVABLE_OWN.test(match[1])) names2.add(match[1]);
|
|
26868
27453
|
}
|
|
@@ -26875,7 +27460,7 @@ async function stripeWebhooks(root, functions) {
|
|
|
26875
27460
|
for (const fn of functions) {
|
|
26876
27461
|
for (const file3 of fn.files) {
|
|
26877
27462
|
if (file3.includes("/_shared/")) continue;
|
|
26878
|
-
const text2 = await
|
|
27463
|
+
const text2 = await readFile14(join24(root, file3), "utf8").catch(() => "");
|
|
26879
27464
|
if (/stripe-signature|constructEvent(Async)?\(/i.test(text2)) {
|
|
26880
27465
|
names2.push(fn.name);
|
|
26881
27466
|
break;
|
|
@@ -26888,7 +27473,7 @@ async function uploadFunction(api, ref, root, fn) {
|
|
|
26888
27473
|
const files = await Promise.all(
|
|
26889
27474
|
fn.files.map(async (path2) => ({
|
|
26890
27475
|
path: path2,
|
|
26891
|
-
content: new Uint8Array(await
|
|
27476
|
+
content: new Uint8Array(await readFile14(join24(root, path2)))
|
|
26892
27477
|
}))
|
|
26893
27478
|
);
|
|
26894
27479
|
await api.deployFunction(
|
|
@@ -27265,6 +27850,87 @@ async function skipGoogle(ws) {
|
|
|
27265
27850
|
return { skipped: true };
|
|
27266
27851
|
}
|
|
27267
27852
|
|
|
27853
|
+
// ../core/src/move/rehearsal.ts
|
|
27854
|
+
var copySchema = external_exports.object({ ref: external_exports.string().min(1).max(100), dataAt: external_exports.iso.datetime() }).strict();
|
|
27855
|
+
var observationSchema = external_exports.object({
|
|
27856
|
+
feature: external_exports.string().trim().min(1).max(200),
|
|
27857
|
+
result: external_exports.enum(["passed", "failed", "blocked"]),
|
|
27858
|
+
method: external_exports.enum(["browser", "automated", "builder-report"]),
|
|
27859
|
+
observedAt: external_exports.iso.datetime(),
|
|
27860
|
+
evidence: external_exports.string().trim().min(1).max(600),
|
|
27861
|
+
limitation: external_exports.string().trim().max(600).optional()
|
|
27862
|
+
}).strict();
|
|
27863
|
+
var recordSchema = external_exports.object({
|
|
27864
|
+
copy: copySchema,
|
|
27865
|
+
observations: external_exports.array(observationSchema).min(1).max(30)
|
|
27866
|
+
}).strict();
|
|
27867
|
+
function currentCopy(state) {
|
|
27868
|
+
if (!state.home || !state.data || state.copyStartedAt && Date.parse(state.copyStartedAt) > Date.parse(state.data.at))
|
|
27869
|
+
return void 0;
|
|
27870
|
+
return { ref: state.home.ref, dataAt: state.data.at };
|
|
27871
|
+
}
|
|
27872
|
+
function rehearsalSummary(state) {
|
|
27873
|
+
const copy = currentCopy(state);
|
|
27874
|
+
return {
|
|
27875
|
+
copy,
|
|
27876
|
+
observations: (state.rehearsal ?? []).map((observation) => ({
|
|
27877
|
+
...observation,
|
|
27878
|
+
scope: copy && observation.copy.ref === copy.ref && observation.copy.dataAt === copy.dataAt ? "current-copy" : "earlier-copy"
|
|
27879
|
+
})),
|
|
27880
|
+
limit: "These are dated observations, not a fresh check or proof every feature works. Missing evidence means unknown, not never tested. Earlier-copy observations need checking again after a new copy."
|
|
27881
|
+
};
|
|
27882
|
+
}
|
|
27883
|
+
async function readRehearsal(ws) {
|
|
27884
|
+
return rehearsalSummary(await loadMove(ws.root));
|
|
27885
|
+
}
|
|
27886
|
+
async function recordRehearsal(ws, json3) {
|
|
27887
|
+
let raw;
|
|
27888
|
+
try {
|
|
27889
|
+
raw = JSON.parse(json3);
|
|
27890
|
+
} catch {
|
|
27891
|
+
raw = null;
|
|
27892
|
+
}
|
|
27893
|
+
const parsed = recordSchema.safeParse(raw);
|
|
27894
|
+
if (!parsed.success)
|
|
27895
|
+
throw new ClodableError({
|
|
27896
|
+
code: "invalid-config",
|
|
27897
|
+
message: "The rehearsal notes don't have the expected shape.",
|
|
27898
|
+
hint: "Include the copy identity from move rehearsal and dated feature observations, with their result, method and evidence. Never include keys or people's data."
|
|
27899
|
+
});
|
|
27900
|
+
const input2 = parsed.data;
|
|
27901
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
27902
|
+
const state = await updateMove(ws.root, (s) => {
|
|
27903
|
+
const copy = currentCopy(s);
|
|
27904
|
+
if (!copy || copy.ref !== input2.copy.ref || copy.dataAt !== input2.copy.dataAt) {
|
|
27905
|
+
throw new ClodableError({
|
|
27906
|
+
code: "move-not-ready",
|
|
27907
|
+
message: "These notes don't match the current copy.",
|
|
27908
|
+
hint: "Read the current rehearsal record and check which copy was actually tested. Don't relabel old checks as new ones."
|
|
27909
|
+
});
|
|
27910
|
+
}
|
|
27911
|
+
if (input2.observations.some(
|
|
27912
|
+
(o) => Date.parse(o.observedAt) < Date.parse(copy.dataAt) || Date.parse(o.observedAt) > Date.now() + 6e4
|
|
27913
|
+
)) {
|
|
27914
|
+
throw new ClodableError({
|
|
27915
|
+
code: "invalid-config",
|
|
27916
|
+
message: "A check's date is outside this copy's lifetime.",
|
|
27917
|
+
hint: "Use the date the check actually happened, after this copy was made."
|
|
27918
|
+
});
|
|
27919
|
+
}
|
|
27920
|
+
const entries = [...s.rehearsal ?? []];
|
|
27921
|
+
for (const observation of input2.observations) {
|
|
27922
|
+
const same = entries.findIndex(
|
|
27923
|
+
(o) => o.copy.ref === copy.ref && o.copy.dataAt === copy.dataAt && o.feature === observation.feature && o.method === observation.method && o.observedAt === observation.observedAt
|
|
27924
|
+
);
|
|
27925
|
+
const entry = { ...observation, copy, recordedAt: now };
|
|
27926
|
+
if (same < 0) entries.push(entry);
|
|
27927
|
+
else entries[same] = entry;
|
|
27928
|
+
}
|
|
27929
|
+
s.rehearsal = entries.slice(-100);
|
|
27930
|
+
});
|
|
27931
|
+
return rehearsalSummary(state);
|
|
27932
|
+
}
|
|
27933
|
+
|
|
27268
27934
|
// ../core/src/move/services.ts
|
|
27269
27935
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
27270
27936
|
var AI_PROVIDERS = {
|
|
@@ -27572,7 +28238,7 @@ function moveSteps(state, around) {
|
|
|
27572
28238
|
add(
|
|
27573
28239
|
{
|
|
27574
28240
|
id: "site",
|
|
27575
|
-
title: "
|
|
28241
|
+
title: "Prepare your website",
|
|
27576
28242
|
...state.site ? {
|
|
27577
28243
|
detail: settingsOpen ? `${count(settingsLeft.length, "setting")} to add` : state.site.url
|
|
27578
28244
|
} : {}
|
|
@@ -27711,8 +28377,17 @@ async function moveProgress(ws) {
|
|
|
27711
28377
|
dashboard: `https://supabase.com/dashboard/project/${state.home.ref}`
|
|
27712
28378
|
}
|
|
27713
28379
|
} : {},
|
|
28380
|
+
rehearsal: rehearsalSummary(state),
|
|
27714
28381
|
preview: state.preview ?? "live",
|
|
27715
|
-
...state.checks ? {
|
|
28382
|
+
...state.checks ? {
|
|
28383
|
+
checksAt: state.checks.at,
|
|
28384
|
+
checks: state.checks.items.map(
|
|
28385
|
+
(item) => item.id === "old-backend" && item.ok ? {
|
|
28386
|
+
...item,
|
|
28387
|
+
label: "The checked database functions and webhooks no longer name the old backend"
|
|
28388
|
+
} : item
|
|
28389
|
+
)
|
|
28390
|
+
} : {},
|
|
27716
28391
|
...state.files ? {
|
|
27717
28392
|
files: {
|
|
27718
28393
|
waiting: state.files.waiting,
|
|
@@ -27765,15 +28440,347 @@ async function moveProgress(ws) {
|
|
|
27765
28440
|
};
|
|
27766
28441
|
}
|
|
27767
28442
|
|
|
27768
|
-
// ../core/src/
|
|
27769
|
-
import {
|
|
27770
|
-
import {
|
|
28443
|
+
// ../core/src/new-app.ts
|
|
28444
|
+
import { existsSync as existsSync20 } from "node:fs";
|
|
28445
|
+
import { appendFile as appendFile2, readFile as readFile15, realpath } from "node:fs/promises";
|
|
27771
28446
|
import { join as join25 } from "node:path";
|
|
28447
|
+
var PENDING = ".clodable/local/new-app.json";
|
|
28448
|
+
async function pendingNewApp(root) {
|
|
28449
|
+
const path2 = join25(root, PENDING);
|
|
28450
|
+
return existsSync20(path2) ? JSON.parse(await readFile15(path2, "utf8")) : void 0;
|
|
28451
|
+
}
|
|
28452
|
+
async function* prepareNewApp(root, options, github = new GhCli(root)) {
|
|
28453
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$/.test(options.name) || /\.git$/i.test(options.name)) {
|
|
28454
|
+
throw new ClodableError({
|
|
28455
|
+
code: "invalid-config",
|
|
28456
|
+
message: "Give your app a short name using letters, numbers or dashes."
|
|
28457
|
+
});
|
|
28458
|
+
}
|
|
28459
|
+
const viewer = await github.viewer();
|
|
28460
|
+
if (viewer.login !== options.account) {
|
|
28461
|
+
throw new ClodableError({
|
|
28462
|
+
code: "gh-auth",
|
|
28463
|
+
message: "The connected GitHub account has changed.",
|
|
28464
|
+
hint: "Open Set up saving again and check the account before continuing."
|
|
28465
|
+
});
|
|
28466
|
+
}
|
|
28467
|
+
const project = await detectProject(root);
|
|
28468
|
+
if (project.appType === "unknown") {
|
|
28469
|
+
throw new ClodableError({
|
|
28470
|
+
code: "invalid-config",
|
|
28471
|
+
message: "Your local app needs a little preparation before saving.",
|
|
28472
|
+
hint: "Ask Claude to prepare this prototype for Clodable, keeping your design and content."
|
|
28473
|
+
});
|
|
28474
|
+
}
|
|
28475
|
+
const git = new Git(root);
|
|
28476
|
+
let pending = await pendingNewApp(root);
|
|
28477
|
+
if (pending && (pending.name !== options.name || pending.account !== options.account)) {
|
|
28478
|
+
if (pending.destination)
|
|
28479
|
+
throw new ClodableError({
|
|
28480
|
+
code: "invalid-config",
|
|
28481
|
+
message: "Saving was already started for a different app name or account.",
|
|
28482
|
+
hint: `Continue with ${pending.account}/${pending.name}. Your local work is still here.`
|
|
28483
|
+
});
|
|
28484
|
+
pending = { ...options };
|
|
28485
|
+
await writeJsonFile(join25(root, PENDING), pending);
|
|
28486
|
+
}
|
|
28487
|
+
if (await git.isRepo()) {
|
|
28488
|
+
if (!pending || await realpath(await git.root()) !== await realpath(root)) {
|
|
28489
|
+
throw new ClodableError({
|
|
28490
|
+
code: "already-there",
|
|
28491
|
+
message: "This folder already belongs to an app.",
|
|
28492
|
+
hint: "Open Clodable to set up that app. Start a new idea in an empty folder."
|
|
28493
|
+
});
|
|
28494
|
+
}
|
|
28495
|
+
} else {
|
|
28496
|
+
pending = { ...options };
|
|
28497
|
+
await writeJsonFile(join25(root, PENDING), pending);
|
|
28498
|
+
await git.ok(["init", "--initial-branch=main"]);
|
|
28499
|
+
}
|
|
28500
|
+
await keepIgnored(root);
|
|
28501
|
+
const ignored = await readFile15(join25(root, ".gitignore"), "utf8");
|
|
28502
|
+
const missing = ["node_modules/", "dist/", ".env", ".env.*", "!.env.example"].filter(
|
|
28503
|
+
(line) => !ignored.split("\n").includes(line)
|
|
28504
|
+
);
|
|
28505
|
+
if (missing.length)
|
|
28506
|
+
await appendFile2(join25(root, ".gitignore"), `
|
|
28507
|
+
# Local app files
|
|
28508
|
+
${missing.join("\n")}
|
|
28509
|
+
`);
|
|
28510
|
+
yield step("setup:app", "running", "Checking your local app before saving");
|
|
28511
|
+
await git.stageAll();
|
|
28512
|
+
const secrets = (await scanStaged(root)).filter((f) => f.severity === "block");
|
|
28513
|
+
if (secrets.length) {
|
|
28514
|
+
throw new ClodableError({
|
|
28515
|
+
code: "secret-found",
|
|
28516
|
+
message: "A secret key needs to stay out of your app's code.",
|
|
28517
|
+
hint: "Ask Claude to move it out, then try Set up saving again. Nothing was sent to GitHub.",
|
|
28518
|
+
files: secrets.map((f) => f.file)
|
|
28519
|
+
});
|
|
28520
|
+
}
|
|
28521
|
+
if (!pending.destination) {
|
|
28522
|
+
if (!github.createPrivateRepository)
|
|
28523
|
+
throw new ClodableError({
|
|
28524
|
+
code: "unknown",
|
|
28525
|
+
message: "This GitHub connection can't create a new app."
|
|
28526
|
+
});
|
|
28527
|
+
yield step(
|
|
28528
|
+
"setup:app",
|
|
28529
|
+
"running",
|
|
28530
|
+
"Creating your private app on GitHub",
|
|
28531
|
+
`${options.account}/${options.name}`
|
|
28532
|
+
);
|
|
28533
|
+
pending.destination = await github.createPrivateRepository(options.name);
|
|
28534
|
+
await writeJsonFile(join25(root, PENDING), pending);
|
|
28535
|
+
}
|
|
28536
|
+
const { repo, cloneUrl } = pending.destination;
|
|
28537
|
+
if (!repo.isPrivate || repo.owner !== options.account || repo.name !== options.name) {
|
|
28538
|
+
throw new ClodableError({
|
|
28539
|
+
code: "gh-auth",
|
|
28540
|
+
message: "GitHub returned a different app than the one you approved.",
|
|
28541
|
+
hint: "Nothing was sent. Check your GitHub account before continuing."
|
|
28542
|
+
});
|
|
28543
|
+
}
|
|
28544
|
+
const remote = await git.remoteUrl("origin");
|
|
28545
|
+
if (remote && remote !== cloneUrl)
|
|
28546
|
+
throw new ClodableError({
|
|
28547
|
+
code: "already-there",
|
|
28548
|
+
message: "This folder is connected to a different app.",
|
|
28549
|
+
hint: "Your files are unchanged. Ask Claude to check the connection before saving."
|
|
28550
|
+
});
|
|
28551
|
+
if (!remote) await git.ok(["remote", "add", "origin", cloneUrl]);
|
|
28552
|
+
if (github instanceof GhCli) await github.configureCredentials();
|
|
28553
|
+
await git.ok(["fetch", "origin", repo.defaultBranch]);
|
|
28554
|
+
if (!await git.head()) {
|
|
28555
|
+
await git.ok(["symbolic-ref", "HEAD", `refs/heads/${repo.defaultBranch}`]);
|
|
28556
|
+
await git.ok(["reset", "--mixed", `origin/${repo.defaultBranch}`]);
|
|
28557
|
+
}
|
|
28558
|
+
yield step("setup:app", "done", "Your private app is ready for its first save");
|
|
28559
|
+
return { root, liveBranch: repo.defaultBranch };
|
|
28560
|
+
}
|
|
28561
|
+
|
|
28562
|
+
// ../core/src/online.ts
|
|
28563
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
28564
|
+
import { readFile as readFile16, writeFile as writeFile12 } from "node:fs/promises";
|
|
28565
|
+
import { join as join26 } from "node:path";
|
|
28566
|
+
async function siteChoices(ws) {
|
|
28567
|
+
const netlify = await NetlifyApi.onThisComputer();
|
|
28568
|
+
const teams = netlify ? await netlify.accounts() : [];
|
|
28569
|
+
return {
|
|
28570
|
+
connected: Boolean(netlify),
|
|
28571
|
+
teams: teams.map((t2) => ({ slug: t2.slug, name: t2.name })),
|
|
28572
|
+
...ws.config.netlify ? { site: ws.config.netlify } : {}
|
|
28573
|
+
};
|
|
28574
|
+
}
|
|
28575
|
+
async function backendChoices() {
|
|
28576
|
+
if (!await SupabaseApi.onThisComputer()) return { connected: false };
|
|
28577
|
+
const choices = await homeChoices();
|
|
28578
|
+
return {
|
|
28579
|
+
connected: true,
|
|
28580
|
+
...choices,
|
|
28581
|
+
costs: Object.fromEntries(choices.organizations.map((o) => [o.slug, costOf(o)]))
|
|
28582
|
+
};
|
|
28583
|
+
}
|
|
28584
|
+
async function reconnectSite(ws) {
|
|
28585
|
+
const move = await loadMove(ws.root);
|
|
28586
|
+
const known = ws.config.netlify ?? (move.site ? { ...move.site, siteId: move.site.id } : void 0);
|
|
28587
|
+
if (!known) {
|
|
28588
|
+
throw new ClodableError({
|
|
28589
|
+
code: "not-set-up",
|
|
28590
|
+
message: "This app has no Netlify site to reconnect."
|
|
28591
|
+
});
|
|
28592
|
+
}
|
|
28593
|
+
const api = await NetlifyApi.required();
|
|
28594
|
+
const site = await api.site(known.siteId);
|
|
28595
|
+
if (site.id !== known.siteId || site.account_slug !== known.account) {
|
|
28596
|
+
throw new ClodableError({
|
|
28597
|
+
code: "netlify-auth",
|
|
28598
|
+
message: "This connection doesn't match your app's hosting account."
|
|
28599
|
+
});
|
|
28600
|
+
}
|
|
28601
|
+
await ws.github.setSecret("NETLIFY_AUTH_TOKEN", await readSecret(NETLIFY_TOKEN));
|
|
28602
|
+
return { reconnected: true, url: siteUrl(site) };
|
|
28603
|
+
}
|
|
28604
|
+
async function* putSiteOnline(ws, options = {}) {
|
|
28605
|
+
const move = await loadMove(ws.root);
|
|
28606
|
+
if (move.site || move.home) {
|
|
28607
|
+
throw new ClodableError({
|
|
28608
|
+
code: "already-there",
|
|
28609
|
+
message: "Your move off Lovable puts your site on Netlify.",
|
|
28610
|
+
hint: "Go on with the move: its website step does this, pointed at your new backend."
|
|
28611
|
+
});
|
|
28612
|
+
}
|
|
28613
|
+
const netlify = await NetlifyApi.required();
|
|
28614
|
+
const token = await readSecret(NETLIFY_TOKEN);
|
|
28615
|
+
yield step("site", "running", "Setting up hosting", "Creating your site on Netlify");
|
|
28616
|
+
const known = ws.config.netlify ? await netlify.site(ws.config.netlify.siteId) : void 0;
|
|
28617
|
+
const site = known ?? await createNetlifySite(netlify, ws.project.name, options.team);
|
|
28618
|
+
const url2 = siteUrl(site);
|
|
28619
|
+
const online = {
|
|
28620
|
+
name: site.name,
|
|
28621
|
+
url: url2,
|
|
28622
|
+
admin: site.admin_url,
|
|
28623
|
+
account: site.account_slug
|
|
28624
|
+
};
|
|
28625
|
+
await saveConfig(ws.root, {
|
|
28626
|
+
...ws.config,
|
|
28627
|
+
netlify: { siteId: site.id, ...online }
|
|
28628
|
+
});
|
|
28629
|
+
yield step("site", "running", "Setting up hosting", "Giving it your app's settings");
|
|
28630
|
+
const backend = await ownBackend(ws.config);
|
|
28631
|
+
const carried = await setSiteEnv(netlify, site, ws.root, backend?.keys);
|
|
28632
|
+
if (carried.length > 0) {
|
|
28633
|
+
const state = await ws.state();
|
|
28634
|
+
await ws.updateState({
|
|
28635
|
+
siteSettings: [.../* @__PURE__ */ new Set([...state.siteSettings ?? [], ...carried])].sort()
|
|
28636
|
+
});
|
|
28637
|
+
}
|
|
28638
|
+
if (backend) await liveSignIn(backend.api, backend.keys.ref, url2);
|
|
28639
|
+
yield step("site", "running", "Setting up hosting", "Setting up Publish");
|
|
28640
|
+
const files = await setUpPublish(ws, site, token);
|
|
28641
|
+
const config2 = {
|
|
28642
|
+
...ws.config,
|
|
28643
|
+
hosting: "github",
|
|
28644
|
+
liveUrl: url2,
|
|
28645
|
+
netlify: { siteId: site.id, ...online }
|
|
28646
|
+
};
|
|
28647
|
+
await saveConfig(ws.root, config2);
|
|
28648
|
+
await applyKit(ws.root, await planKit(await detectProject(ws.root), config2));
|
|
28649
|
+
const settings2 = await siteSettingsOf(netlify, site.account_slug, site.id, ws.root);
|
|
28650
|
+
yield step("site", "done", "Your site is ready", `Publish to put it online at ${url2}`);
|
|
28651
|
+
return { site: online, files, settings: settings2 };
|
|
28652
|
+
}
|
|
28653
|
+
async function ownBackend(config2) {
|
|
28654
|
+
const ref = config2.supabase.projectRef;
|
|
28655
|
+
if (config2.backend !== "supabase" || !ref) return void 0;
|
|
28656
|
+
const api = await SupabaseApi.onThisComputer();
|
|
28657
|
+
if (!api) return void 0;
|
|
28658
|
+
return { api, keys: backendOf(ref, await homeKeys(api, ref)) };
|
|
28659
|
+
}
|
|
28660
|
+
var ENV_FILE = ".env";
|
|
28661
|
+
async function* createBackend(ws, options = {}) {
|
|
28662
|
+
if (ws.config.backend === "lovable-cloud") {
|
|
28663
|
+
throw new ClodableError({
|
|
28664
|
+
code: "already-there",
|
|
28665
|
+
message: "Your app's data is on Lovable Cloud.",
|
|
28666
|
+
hint: "Moving off Lovable gives your app its own Supabase, with your data and your people."
|
|
28667
|
+
});
|
|
28668
|
+
}
|
|
28669
|
+
if (ws.config.backend === "supabase" && ws.config.supabase.projectRef) {
|
|
28670
|
+
throw new ClodableError({
|
|
28671
|
+
code: "already-there",
|
|
28672
|
+
message: "Your app already has its own backend on Supabase."
|
|
28673
|
+
});
|
|
28674
|
+
}
|
|
28675
|
+
const api = await SupabaseApi.required();
|
|
28676
|
+
yield step("backend", "running", "Creating your backend");
|
|
28677
|
+
const earlier = ws.config.supabase.projectRef;
|
|
28678
|
+
const started = earlier ? await api.project(earlier) : void 0;
|
|
28679
|
+
let ref;
|
|
28680
|
+
if (started) {
|
|
28681
|
+
ref = started.ref;
|
|
28682
|
+
} else {
|
|
28683
|
+
const { organizations, freeProjects } = await homeChoices();
|
|
28684
|
+
const org = pickOrganization(organizations, options.org);
|
|
28685
|
+
if (org.plan === "free" && org.freeLeft === 0) {
|
|
28686
|
+
throw new ClodableError({
|
|
28687
|
+
code: "supabase-limit",
|
|
28688
|
+
message: "Your Supabase account already runs its 2 free projects.",
|
|
28689
|
+
hint: `Pause one in Supabase (${freeProjects.map((p) => p.name).join(", ")}), or pick an organization on a paid plan, then try again.`
|
|
28690
|
+
});
|
|
28691
|
+
}
|
|
28692
|
+
const region = options.region ?? (await api.regions(org.slug).catch(() => void 0))?.recommended?.code;
|
|
28693
|
+
if (!region) {
|
|
28694
|
+
throw new ClodableError({
|
|
28695
|
+
code: "needs-choice",
|
|
28696
|
+
message: "Which part of the world should your backend run in?",
|
|
28697
|
+
hint: "Pick the region closest to the people who use your app."
|
|
28698
|
+
});
|
|
28699
|
+
}
|
|
28700
|
+
const password2 = newPassword();
|
|
28701
|
+
const created = await api.createProject({
|
|
28702
|
+
name: ws.project.name.slice(0, 60),
|
|
28703
|
+
org: org.slug,
|
|
28704
|
+
password: password2,
|
|
28705
|
+
region
|
|
28706
|
+
});
|
|
28707
|
+
await storeSecret(passwordKey(created.ref), password2);
|
|
28708
|
+
ref = created.ref;
|
|
28709
|
+
await saveConfig(ws.root, {
|
|
28710
|
+
...ws.config,
|
|
28711
|
+
supabase: { ...ws.config.supabase, projectRef: ref }
|
|
28712
|
+
});
|
|
28713
|
+
}
|
|
28714
|
+
yield step("backend", "running", "Creating your backend", "Starting it up: about 2 minutes");
|
|
28715
|
+
await waitUntilUp(api, ref);
|
|
28716
|
+
const project = await api.project(ref);
|
|
28717
|
+
yield step("backend", "running", "Creating your backend", "Connecting your app to it");
|
|
28718
|
+
const backend = backendOf(ref, await homeKeys(api, ref));
|
|
28719
|
+
const files = [];
|
|
28720
|
+
const envPath = join26(ws.root, ENV_FILE);
|
|
28721
|
+
const before = existsSync21(envPath) ? await readFile16(envPath, "utf8") : "";
|
|
28722
|
+
const after = envWith(before, {
|
|
28723
|
+
VITE_SUPABASE_PROJECT_ID: ref,
|
|
28724
|
+
VITE_SUPABASE_PUBLISHABLE_KEY: backend.publishable,
|
|
28725
|
+
VITE_SUPABASE_URL: backend.url
|
|
28726
|
+
});
|
|
28727
|
+
if (after !== before) {
|
|
28728
|
+
await writeFile12(envPath, after);
|
|
28729
|
+
files.push(ENV_FILE);
|
|
28730
|
+
}
|
|
28731
|
+
await rememberSettings(ws.root, {
|
|
28732
|
+
SUPABASE_URL: backend.url,
|
|
28733
|
+
SUPABASE_PUBLISHABLE_KEY: backend.publishable,
|
|
28734
|
+
SUPABASE_SERVICE_ROLE_KEY: backend.serviceRole
|
|
28735
|
+
});
|
|
28736
|
+
await newBackendSignIn(api, ref, ws.config.netlify?.url ?? ws.config.liveUrl);
|
|
28737
|
+
const netlify = ws.config.netlify ? await NetlifyApi.onThisComputer() : void 0;
|
|
28738
|
+
if (ws.config.netlify && netlify) {
|
|
28739
|
+
await setSiteEnv(
|
|
28740
|
+
netlify,
|
|
28741
|
+
{ id: ws.config.netlify.siteId, account_slug: ws.config.netlify.account },
|
|
28742
|
+
ws.root,
|
|
28743
|
+
backend
|
|
28744
|
+
);
|
|
28745
|
+
}
|
|
28746
|
+
const config2 = {
|
|
28747
|
+
...ws.config,
|
|
28748
|
+
backend: "supabase",
|
|
28749
|
+
supabase: { ...ws.config.supabase, projectRef: ref }
|
|
28750
|
+
};
|
|
28751
|
+
await saveConfig(ws.root, config2);
|
|
28752
|
+
await applyKit(ws.root, await planKit(await detectProject(ws.root), config2));
|
|
28753
|
+
yield step("backend", "done", "Your backend is ready", project.name);
|
|
28754
|
+
return {
|
|
28755
|
+
ref,
|
|
28756
|
+
name: project.name,
|
|
28757
|
+
region: project.region,
|
|
28758
|
+
url: projectUrl(ref),
|
|
28759
|
+
dashboard: `https://supabase.com/dashboard/project/${ref}`,
|
|
28760
|
+
files
|
|
28761
|
+
};
|
|
28762
|
+
}
|
|
28763
|
+
function pickOrganization(organizations, slug) {
|
|
28764
|
+
const org = organizations.find((o) => o.slug === slug) ?? (organizations.length === 1 ? organizations[0] : void 0);
|
|
28765
|
+
if (!org) {
|
|
28766
|
+
throw new ClodableError({
|
|
28767
|
+
code: "needs-choice",
|
|
28768
|
+
message: "Which Supabase organization should your backend go in?",
|
|
28769
|
+
hint: `Pick one: ${organizations.map((o) => `${o.name} (${costOf(o)})`).join(", ")}.`
|
|
28770
|
+
});
|
|
28771
|
+
}
|
|
28772
|
+
return org;
|
|
28773
|
+
}
|
|
28774
|
+
|
|
28775
|
+
// ../core/src/publish.ts
|
|
28776
|
+
import { mkdtemp as mkdtemp8, rm as rm13 } from "node:fs/promises";
|
|
28777
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
28778
|
+
import { join as join29 } from "node:path";
|
|
27772
28779
|
|
|
27773
28780
|
// ../core/src/publish-functions.ts
|
|
27774
|
-
import { existsSync as
|
|
28781
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
27775
28782
|
import { readdir as readdir7 } from "node:fs/promises";
|
|
27776
|
-
import { join as
|
|
28783
|
+
import { join as join27 } from "node:path";
|
|
27777
28784
|
async function changedFunctions(ws, sha) {
|
|
27778
28785
|
const files = await ws.git.diffNames(`${sha}^..${sha}`);
|
|
27779
28786
|
const names2 = /* @__PURE__ */ new Set();
|
|
@@ -27785,8 +28792,8 @@ async function changedFunctions(ws, sha) {
|
|
|
27785
28792
|
else names2.add(match[1]);
|
|
27786
28793
|
}
|
|
27787
28794
|
if (shared) {
|
|
27788
|
-
const dir =
|
|
27789
|
-
if (
|
|
28795
|
+
const dir = join27(ws.root, "supabase", "functions");
|
|
28796
|
+
if (existsSync22(dir)) {
|
|
27790
28797
|
for (const entry of await readdir7(dir, { withFileTypes: true })) {
|
|
27791
28798
|
if (entry.isDirectory() && !entry.name.startsWith("_")) names2.add(entry.name);
|
|
27792
28799
|
}
|
|
@@ -27859,9 +28866,9 @@ async function* deployThroughCli(ref, root, names2, outcome) {
|
|
|
27859
28866
|
}
|
|
27860
28867
|
|
|
27861
28868
|
// ../core/src/waits.ts
|
|
27862
|
-
import { existsSync as
|
|
27863
|
-
import { readdir as readdir8, readFile as
|
|
27864
|
-
import { join as
|
|
28869
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
28870
|
+
import { readdir as readdir8, readFile as readFile17 } from "node:fs/promises";
|
|
28871
|
+
import { join as join28 } from "node:path";
|
|
27865
28872
|
function timing(options) {
|
|
27866
28873
|
return {
|
|
27867
28874
|
sleep: options.sleep ?? ((ms) => new Promise((resolve9) => setTimeout(resolve9, ms))),
|
|
@@ -27870,11 +28877,11 @@ function timing(options) {
|
|
|
27870
28877
|
};
|
|
27871
28878
|
}
|
|
27872
28879
|
async function runsChecksOnPullRequests(root) {
|
|
27873
|
-
const dir =
|
|
27874
|
-
if (!
|
|
28880
|
+
const dir = join28(root, ".github", "workflows");
|
|
28881
|
+
if (!existsSync23(dir)) return false;
|
|
27875
28882
|
for (const name of await readdir8(dir)) {
|
|
27876
28883
|
if (!/\.ya?ml$/.test(name)) continue;
|
|
27877
|
-
const text2 = await
|
|
28884
|
+
const text2 = await readFile17(join28(dir, name), "utf8").catch(() => "");
|
|
27878
28885
|
if (/\bpull_request(_target)?\b/.test(text2)) return true;
|
|
27879
28886
|
}
|
|
27880
28887
|
return false;
|
|
@@ -27944,12 +28951,14 @@ async function* waitForCi(ws, prNumber, o) {
|
|
|
27944
28951
|
await o.sleep(o.poll);
|
|
27945
28952
|
}
|
|
27946
28953
|
}
|
|
27947
|
-
async function* followDeployment(ws, sha, o, shown) {
|
|
28954
|
+
async function* followDeployment(ws, sha, o, shown, ignoredDeploymentIds = []) {
|
|
27948
28955
|
const started = o.now().getTime();
|
|
27949
28956
|
const deadline = started + ws.config.publish.deployTimeoutMinutes * 6e4;
|
|
27950
28957
|
let line = "";
|
|
27951
28958
|
while (true) {
|
|
27952
|
-
const deployments = await ws.github.deploymentsFor(sha).catch(() => [])
|
|
28959
|
+
const deployments = (await ws.github.deploymentsFor(sha).catch(() => [])).filter(
|
|
28960
|
+
(d) => !ignoredDeploymentIds.includes(d.id)
|
|
28961
|
+
);
|
|
27953
28962
|
const deployment = deployments.find((d) => d.isProduction) ?? deployments[0];
|
|
27954
28963
|
const build = await ws.github.buildProgress?.(sha).catch(() => void 0);
|
|
27955
28964
|
if (deployment?.state === "success") return { state: "success", deployment };
|
|
@@ -27968,7 +28977,7 @@ async function* followDeployment(ws, sha, o, shown) {
|
|
|
27968
28977
|
await o.sleep(o.poll);
|
|
27969
28978
|
}
|
|
27970
28979
|
}
|
|
27971
|
-
async function* waitForDeploy(ws, sha, o) {
|
|
28980
|
+
async function* waitForDeploy(ws, sha, o, ignoredDeploymentIds = []) {
|
|
27972
28981
|
if (ws.config.hosting === "lovable") {
|
|
27973
28982
|
const url2 = ws.config.liveUrl ?? ws.project.lovable.appUrl;
|
|
27974
28983
|
yield step(
|
|
@@ -27978,15 +28987,21 @@ async function* waitForDeploy(ws, sha, o) {
|
|
|
27978
28987
|
"To put it live, click Publish, then Publish changes, in Lovable"
|
|
27979
28988
|
);
|
|
27980
28989
|
const moving = (await loadMove(ws.root)).site;
|
|
27981
|
-
const site = moving ? yield* followSite(ws, sha, o, moving.url) : void 0;
|
|
28990
|
+
const site = moving ? yield* followSite(ws, sha, o, moving.url, ignoredDeploymentIds) : void 0;
|
|
27982
28991
|
return { state: "lovable", ...url2 ? { url: url2 } : {}, ...site ? { site } : {} };
|
|
27983
28992
|
}
|
|
27984
28993
|
yield step("deploy", "running", "Going live");
|
|
27985
|
-
const end = yield* followDeployment(
|
|
27986
|
-
|
|
27987
|
-
|
|
27988
|
-
|
|
27989
|
-
|
|
28994
|
+
const end = yield* followDeployment(
|
|
28995
|
+
ws,
|
|
28996
|
+
sha,
|
|
28997
|
+
o,
|
|
28998
|
+
{
|
|
28999
|
+
id: "deploy",
|
|
29000
|
+
title: "Going live",
|
|
29001
|
+
unreportedAfterMs: 75e3
|
|
29002
|
+
},
|
|
29003
|
+
ignoredDeploymentIds
|
|
29004
|
+
);
|
|
27990
29005
|
const liveUrl = ws.config.liveUrl ? { url: ws.config.liveUrl } : {};
|
|
27991
29006
|
switch (end.state) {
|
|
27992
29007
|
case "success": {
|
|
@@ -27998,29 +29013,45 @@ async function* waitForDeploy(ws, sha, o) {
|
|
|
27998
29013
|
yield step("deploy", "failed", "Your host couldn't put it live");
|
|
27999
29014
|
throw new ClodableError({
|
|
28000
29015
|
code: "deploy-failed",
|
|
28001
|
-
message: "Your changes are
|
|
28002
|
-
hint: "Your previous version is still live.
|
|
29016
|
+
message: "Your changes are saved, but your host couldn't put them live.",
|
|
29017
|
+
hint: "Your previous version is still live. Fix the hosting problem, then retry Publish; no new app change is needed.",
|
|
28003
29018
|
...end.deployment.logUrl ? { details: end.deployment.logUrl } : {}
|
|
28004
29019
|
});
|
|
28005
|
-
case "unreported":
|
|
29020
|
+
case "unreported": {
|
|
29021
|
+
if (await ws.github.hasDeployments?.().catch(() => void 0) === false) {
|
|
29022
|
+
yield step(
|
|
29023
|
+
"deploy",
|
|
29024
|
+
"done",
|
|
29025
|
+
"Published on GitHub",
|
|
29026
|
+
"No host puts it online from there yet"
|
|
29027
|
+
);
|
|
29028
|
+
return { state: "unknown", noHost: true };
|
|
29029
|
+
}
|
|
28006
29030
|
yield step("deploy", "done", "Published", "Your host will put it live in a moment");
|
|
28007
29031
|
return { state: "unknown", ...liveUrl };
|
|
29032
|
+
}
|
|
28008
29033
|
case "late":
|
|
28009
29034
|
yield step("deploy", "warning", "Still going live", "Your host is taking longer than usual");
|
|
28010
29035
|
return { state: "pending", ...liveUrl };
|
|
28011
29036
|
}
|
|
28012
29037
|
}
|
|
28013
|
-
async function* followSite(ws, sha, o, url2) {
|
|
29038
|
+
async function* followSite(ws, sha, o, url2, ignoredDeploymentIds = []) {
|
|
28014
29039
|
yield step("move:site", "running", "Updating your site on Netlify");
|
|
28015
|
-
const end = yield* followDeployment(
|
|
28016
|
-
|
|
28017
|
-
|
|
28018
|
-
|
|
28019
|
-
|
|
29040
|
+
const end = yield* followDeployment(
|
|
29041
|
+
ws,
|
|
29042
|
+
sha,
|
|
29043
|
+
o,
|
|
29044
|
+
{
|
|
29045
|
+
id: "move:site",
|
|
29046
|
+
title: "Updating your site on Netlify",
|
|
29047
|
+
unreportedAfterMs: 12e4
|
|
29048
|
+
},
|
|
29049
|
+
ignoredDeploymentIds
|
|
29050
|
+
);
|
|
28020
29051
|
if (end.state === "success") {
|
|
28021
|
-
const
|
|
28022
|
-
yield step("move:site", "done", "Your site on Netlify is up to date",
|
|
28023
|
-
return { url:
|
|
29052
|
+
const siteUrl2 = end.deployment.url ?? url2;
|
|
29053
|
+
yield step("move:site", "done", "Your site on Netlify is up to date", siteUrl2);
|
|
29054
|
+
return { url: siteUrl2, state: "live" };
|
|
28024
29055
|
}
|
|
28025
29056
|
if (end.state === "failed") {
|
|
28026
29057
|
const { logUrl } = end.deployment;
|
|
@@ -28045,6 +29076,22 @@ function publishTitle(saves) {
|
|
|
28045
29076
|
async function* publish(ws, options = {}) {
|
|
28046
29077
|
const wait2 = timing(options);
|
|
28047
29078
|
const warnings = [];
|
|
29079
|
+
const earlier = await ws.state();
|
|
29080
|
+
if (earlier.pendingPublish || earlier.pullRequest) {
|
|
29081
|
+
await ws.git.fetch(ws.remote, ws.liveBranch);
|
|
29082
|
+
const [latest] = await ws.git.log(ws.liveRef, { firstParent: true, limit: 1 });
|
|
29083
|
+
const pending2 = earlier.pendingPublish ?? (latest?.kind === "publish" && earlier.pullRequest && earlier.lastPublish?.sha !== latest.sha ? {
|
|
29084
|
+
sha: latest.sha,
|
|
29085
|
+
title: latest.subject,
|
|
29086
|
+
at: latest.date,
|
|
29087
|
+
pullRequest: earlier.pullRequest,
|
|
29088
|
+
state: "pending"
|
|
29089
|
+
} : void 0);
|
|
29090
|
+
const branch2 = await ws.git.currentBranch();
|
|
29091
|
+
if (pending2 && branch2 && branch2 !== ws.liveBranch && latest?.sha === pending2.sha && !await ws.git.hasChanges() && (await ws.git.run(["diff", "--quiet", pending2.sha, "HEAD"])).exitCode === 0) {
|
|
29092
|
+
return yield* retryPublish(ws, pending2, branch2, wait2);
|
|
29093
|
+
}
|
|
29094
|
+
}
|
|
28048
29095
|
yield step("save", "running", "Saving your latest changes");
|
|
28049
29096
|
let saved;
|
|
28050
29097
|
try {
|
|
@@ -28089,6 +29136,16 @@ async function* publish(ws, options = {}) {
|
|
|
28089
29136
|
await ws.git.fetch(ws.remote, ws.liveBranch);
|
|
28090
29137
|
const behind = await ws.git.count(`HEAD..${ws.liveRef}`, { noMerges: true });
|
|
28091
29138
|
if (behind > 0) {
|
|
29139
|
+
const compared = await ws.git.checkMerge(ws.liveRef);
|
|
29140
|
+
if (!compared.ok) {
|
|
29141
|
+
yield step("sync", "failed", "Your draft and the live site changed the same thing");
|
|
29142
|
+
throw new ClodableError({
|
|
29143
|
+
code: "conflict",
|
|
29144
|
+
message: "Your draft and the live site both changed the same thing.",
|
|
29145
|
+
hint: "Ask Claude to review both versions with you. Your preview is unchanged.",
|
|
29146
|
+
files: compared.conflicts
|
|
29147
|
+
});
|
|
29148
|
+
}
|
|
28092
29149
|
const merged = await ws.git.merge(ws.liveRef, "Caught up with the live site");
|
|
28093
29150
|
if (!merged.ok) {
|
|
28094
29151
|
yield step("sync", "failed", "Your draft and the live site changed the same thing");
|
|
@@ -28118,9 +29175,25 @@ async function* publish(ws, options = {}) {
|
|
|
28118
29175
|
}
|
|
28119
29176
|
const saves = await ws.git.log(`${ws.liveRef}..HEAD`, { noMerges: true, limit: 200 });
|
|
28120
29177
|
if (saves.length === 0 || await sameAsLive(ws, { clodablesToo: true })) {
|
|
29178
|
+
const state = await ws.state();
|
|
29179
|
+
const [latest] = await ws.git.log(ws.liveRef, { firstParent: true, limit: 1 });
|
|
29180
|
+
let pending2 = state.pendingPublish;
|
|
29181
|
+
if (!pending2 && latest?.kind === "publish" && state.pullRequest && state.lastPublish?.sha !== latest.sha) {
|
|
29182
|
+
pending2 = {
|
|
29183
|
+
sha: latest.sha,
|
|
29184
|
+
title: latest.subject,
|
|
29185
|
+
at: latest.date,
|
|
29186
|
+
pullRequest: state.pullRequest,
|
|
29187
|
+
state: "pending"
|
|
29188
|
+
};
|
|
29189
|
+
}
|
|
29190
|
+
if (pending2 && latest?.sha === pending2.sha) {
|
|
29191
|
+
return yield* retryPublish(ws, pending2, branch, wait2);
|
|
29192
|
+
}
|
|
28121
29193
|
throw new ClodableError({
|
|
28122
29194
|
code: "nothing-to-publish",
|
|
28123
|
-
message: "There's
|
|
29195
|
+
message: "There's no new app change to publish.",
|
|
29196
|
+
hint: "This does not confirm which version visitors see. Ask Claude to check the hosting status if your site looks out of date."
|
|
28124
29197
|
});
|
|
28125
29198
|
}
|
|
28126
29199
|
if (options.skipChecks) {
|
|
@@ -28165,8 +29238,53 @@ async function* publish(ws, options = {}) {
|
|
|
28165
29238
|
kindTrailer("publish")
|
|
28166
29239
|
].join("\n");
|
|
28167
29240
|
const { sha } = await ws.github.merge(pr.number, { subject: title, body });
|
|
28168
|
-
|
|
28169
|
-
|
|
29241
|
+
const pending = {
|
|
29242
|
+
sha,
|
|
29243
|
+
title,
|
|
29244
|
+
at: wait2.now().toISOString(),
|
|
29245
|
+
pullRequest: { number: pr.number, url: pr.url },
|
|
29246
|
+
state: "pending"
|
|
29247
|
+
};
|
|
29248
|
+
await ws.updateState({ pendingPublish: pending });
|
|
29249
|
+
yield step("merge", "done", "Ready for your host");
|
|
29250
|
+
return yield* finishPublish(ws, pending, branch, wait2, warnings);
|
|
29251
|
+
}
|
|
29252
|
+
async function* retryPublish(ws, pending, branch, wait2) {
|
|
29253
|
+
await ws.updateState({ pendingPublish: pending });
|
|
29254
|
+
const deliveries = await ws.github.deploymentsFor(pending.sha);
|
|
29255
|
+
const latest = deliveries.find((d) => d.isProduction) ?? deliveries[0];
|
|
29256
|
+
if (latest?.state !== "success") {
|
|
29257
|
+
const ownedSite = ws.config.netlify ?? (await loadMove(ws.root)).site;
|
|
29258
|
+
if (ownedSite && ws.github.retryDeployment) {
|
|
29259
|
+
yield step("deploy", "running", "Retrying the same version");
|
|
29260
|
+
const retry = await ws.github.retryDeployment(pending.sha);
|
|
29261
|
+
if (retry === "started") {
|
|
29262
|
+
pending = {
|
|
29263
|
+
...pending,
|
|
29264
|
+
state: "pending",
|
|
29265
|
+
ignoredDeploymentIds: deliveries.map((d) => d.id)
|
|
29266
|
+
};
|
|
29267
|
+
await ws.updateState({ pendingPublish: pending });
|
|
29268
|
+
} else if (!retry && (latest?.state === "failure" || latest?.state === "error" || !latest)) {
|
|
29269
|
+
throw new ClodableError({
|
|
29270
|
+
code: "deploy-failed",
|
|
29271
|
+
message: "This version couldn't be retried automatically.",
|
|
29272
|
+
hint: "Ask Claude to check the hosting report. Keep the app unchanged; don't make an edit to trigger publishing."
|
|
29273
|
+
});
|
|
29274
|
+
}
|
|
29275
|
+
}
|
|
29276
|
+
}
|
|
29277
|
+
return yield* finishPublish(ws, pending, branch, wait2, []);
|
|
29278
|
+
}
|
|
29279
|
+
async function* finishPublish(ws, pending, branch, wait2, warnings) {
|
|
29280
|
+
const { sha, title, pullRequest: pr } = pending;
|
|
29281
|
+
let deployed;
|
|
29282
|
+
try {
|
|
29283
|
+
deployed = yield* waitForDeploy(ws, sha, wait2, pending.ignoredDeploymentIds);
|
|
29284
|
+
} catch (error62) {
|
|
29285
|
+
await ws.updateState({ pendingPublish: { ...pending, state: "failed" } });
|
|
29286
|
+
throw error62;
|
|
29287
|
+
}
|
|
28170
29288
|
const functions = yield* deployChangedFunctions(ws, sha);
|
|
28171
29289
|
yield step("fresh-draft", "running", "Starting a fresh draft");
|
|
28172
29290
|
await ws.git.fetch(ws.remote, ws.liveBranch);
|
|
@@ -28175,8 +29293,16 @@ async function* publish(ws, options = {}) {
|
|
|
28175
29293
|
const at = wait2.now().toISOString();
|
|
28176
29294
|
const url2 = deployed.url ?? ws.config.liveUrl;
|
|
28177
29295
|
await ws.updateState({
|
|
28178
|
-
lastPublish: {
|
|
28179
|
-
|
|
29296
|
+
lastPublish: {
|
|
29297
|
+
sha,
|
|
29298
|
+
title,
|
|
29299
|
+
at,
|
|
29300
|
+
...url2 ? { url: url2 } : {},
|
|
29301
|
+
prNumber: pr.number,
|
|
29302
|
+
...deployed.noHost ? { noHost: true } : {}
|
|
29303
|
+
},
|
|
29304
|
+
pullRequest: void 0,
|
|
29305
|
+
pendingPublish: deployed.state === "live" || deployed.state === "lovable" && (!deployed.site || deployed.site.state === "live") || deployed.noHost ? void 0 : { ...pending, state: deployed.site?.state === "failed" ? "failed" : "pending" }
|
|
28180
29306
|
});
|
|
28181
29307
|
yield step("fresh-draft", "done", "Fresh draft ready");
|
|
28182
29308
|
if (deployed.site?.state === "live" || deployed.state === "live" && (await loadMove(ws.root)).site) {
|
|
@@ -28184,6 +29310,9 @@ async function* publish(ws, options = {}) {
|
|
|
28184
29310
|
if (s.site) s.site.liveAt = at;
|
|
28185
29311
|
});
|
|
28186
29312
|
}
|
|
29313
|
+
if (deployed.state === "live" && ws.config.netlify && !(await ws.state()).siteLiveAt) {
|
|
29314
|
+
await ws.updateState({ siteLiveAt: at });
|
|
29315
|
+
}
|
|
28187
29316
|
return {
|
|
28188
29317
|
sha,
|
|
28189
29318
|
title,
|
|
@@ -28192,6 +29321,7 @@ async function* publish(ws, options = {}) {
|
|
|
28192
29321
|
deploy: deployed.state,
|
|
28193
29322
|
...lovableLink(ws, deployed.state),
|
|
28194
29323
|
...deployed.site ? { site: deployed.site } : {},
|
|
29324
|
+
...deployed.noHost ? { noHost: true } : {},
|
|
28195
29325
|
pullRequest: { number: pr.number, url: pr.url },
|
|
28196
29326
|
warnings,
|
|
28197
29327
|
functions
|
|
@@ -28208,7 +29338,7 @@ async function* undoPublish(ws, options = {}) {
|
|
|
28208
29338
|
const [target] = options.sha ? await ws.git.log(`${options.sha}^!`) : await ws.git.log(ws.liveRef, { firstParent: true, limit: 1 });
|
|
28209
29339
|
if (!target)
|
|
28210
29340
|
throw new ClodableError({ code: "not-found", message: "There's no publish to undo yet." });
|
|
28211
|
-
const dir = await
|
|
29341
|
+
const dir = await mkdtemp8(join29(tmpdir5(), "clodable-undo-"));
|
|
28212
29342
|
const branch = `undo/${target.sha.slice(0, 7)}`;
|
|
28213
29343
|
try {
|
|
28214
29344
|
const side = await ws.git.worktreeAdd(dir, branch, ws.liveRef);
|
|
@@ -28289,7 +29419,7 @@ ${kindTrailer("undo")}`
|
|
|
28289
29419
|
};
|
|
28290
29420
|
} finally {
|
|
28291
29421
|
await ws.git.worktreeRemove(dir);
|
|
28292
|
-
await
|
|
29422
|
+
await rm13(dir, { recursive: true, force: true });
|
|
28293
29423
|
await ws.git.run(["branch", "-D", branch]);
|
|
28294
29424
|
}
|
|
28295
29425
|
}
|
|
@@ -28995,7 +30125,6 @@ import { resolve as resolve4 } from "node:path";
|
|
|
28995
30125
|
// ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
|
|
28996
30126
|
import { styleText } from "node:util";
|
|
28997
30127
|
import { stdout, stdin } from "node:process";
|
|
28998
|
-
import * as l from "node:readline";
|
|
28999
30128
|
import l__default from "node:readline";
|
|
29000
30129
|
|
|
29001
30130
|
// ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
@@ -29084,7 +30213,7 @@ var getStringTruncatedWidth = (input2, truncationOptions = {}, widthOptions = {}
|
|
|
29084
30213
|
if (index >= length) {
|
|
29085
30214
|
break outer;
|
|
29086
30215
|
}
|
|
29087
|
-
for (let i2 = 0,
|
|
30216
|
+
for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
|
|
29088
30217
|
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
|
|
29089
30218
|
BLOCK_RE.lastIndex = index;
|
|
29090
30219
|
if (BLOCK_RE.test(input2)) {
|
|
@@ -29336,12 +30465,11 @@ function wrapAnsi(string4, columns, options) {
|
|
|
29336
30465
|
|
|
29337
30466
|
// ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
|
|
29338
30467
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
29339
|
-
|
|
29340
|
-
|
|
29341
|
-
if (!l2.some((r2) => !r2.disabled))
|
|
30468
|
+
function findCursor(s, o, l) {
|
|
30469
|
+
if (!l.some((r2) => !r2.disabled))
|
|
29342
30470
|
return s;
|
|
29343
|
-
const t2 = s + o, n4 = Math.max(
|
|
29344
|
-
return
|
|
30471
|
+
const t2 = s + o, n4 = Math.max(l.length - 1, 0), e = t2 < 0 ? n4 : t2 > n4 ? 0 : t2;
|
|
30472
|
+
return l[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
29345
30473
|
}
|
|
29346
30474
|
var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
29347
30475
|
var t = [
|
|
@@ -29424,37 +30552,6 @@ function setRawMode(e, r2) {
|
|
|
29424
30552
|
const o = e;
|
|
29425
30553
|
o.isTTY && o.setRawMode(r2);
|
|
29426
30554
|
}
|
|
29427
|
-
function block({
|
|
29428
|
-
input: e = stdin,
|
|
29429
|
-
output: r2 = stdout,
|
|
29430
|
-
overwrite: o = true,
|
|
29431
|
-
hideCursor: n4 = true
|
|
29432
|
-
} = {}) {
|
|
29433
|
-
const s = l.createInterface({
|
|
29434
|
-
input: e,
|
|
29435
|
-
output: r2,
|
|
29436
|
-
prompt: "",
|
|
29437
|
-
tabSize: 1
|
|
29438
|
-
});
|
|
29439
|
-
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
29440
|
-
const t2 = (f, { name: a2, sequence: w }) => {
|
|
29441
|
-
const c2 = String(f);
|
|
29442
|
-
if (isActionKey([c2, a2, w], "cancel")) {
|
|
29443
|
-
n4 && r2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
29444
|
-
return;
|
|
29445
|
-
}
|
|
29446
|
-
if (!o) return;
|
|
29447
|
-
const i2 = a2 === "return" ? 0 : -1, m = a2 === "return" ? -1 : 0;
|
|
29448
|
-
l.moveCursor(r2, i2, m, () => {
|
|
29449
|
-
l.clearLine(r2, 1, () => {
|
|
29450
|
-
e.once("keypress", t2);
|
|
29451
|
-
});
|
|
29452
|
-
});
|
|
29453
|
-
};
|
|
29454
|
-
return n4 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", t2), () => {
|
|
29455
|
-
e.off("keypress", t2), n4 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
29456
|
-
};
|
|
29457
|
-
}
|
|
29458
30555
|
var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
29459
30556
|
var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
29460
30557
|
function wrapTextWithPrefix(e, r2, o, n4 = o, s = o, t2) {
|
|
@@ -29737,7 +30834,6 @@ function isUnicodeSupported() {
|
|
|
29737
30834
|
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
29738
30835
|
}
|
|
29739
30836
|
var unicode = isUnicodeSupported();
|
|
29740
|
-
var isCI = () => process.env.CI === "true";
|
|
29741
30837
|
var unicodeOr = (o, e) => unicode ? o : e;
|
|
29742
30838
|
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
29743
30839
|
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
@@ -29796,22 +30892,22 @@ function formatInstructionFooter(o, e) {
|
|
|
29796
30892
|
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
|
|
29797
30893
|
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
29798
30894
|
}
|
|
29799
|
-
var I = (
|
|
30895
|
+
var I = (l, e, w, p, b, C = false) => {
|
|
29800
30896
|
let r2 = e, O = 0;
|
|
29801
30897
|
if (C)
|
|
29802
30898
|
for (let i2 = p - 1; i2 >= w; i2--) {
|
|
29803
|
-
const m =
|
|
30899
|
+
const m = l[i2];
|
|
29804
30900
|
if (m && (r2 -= m.length), O++, r2 <= b) break;
|
|
29805
30901
|
}
|
|
29806
30902
|
else
|
|
29807
30903
|
for (let i2 = w; i2 < p; i2++) {
|
|
29808
|
-
const m =
|
|
30904
|
+
const m = l[i2];
|
|
29809
30905
|
if (m && (r2 -= m.length), O++, r2 <= b) break;
|
|
29810
30906
|
}
|
|
29811
30907
|
return { lineCount: r2, removals: O };
|
|
29812
30908
|
};
|
|
29813
30909
|
var limitOptions = ({
|
|
29814
|
-
cursor:
|
|
30910
|
+
cursor: l,
|
|
29815
30911
|
options: e,
|
|
29816
30912
|
style: w,
|
|
29817
30913
|
output: p = process.stdout,
|
|
@@ -29821,20 +30917,20 @@ var limitOptions = ({
|
|
|
29821
30917
|
}) => {
|
|
29822
30918
|
const i2 = getColumns(p) - C, m = getRows(p), M = styleText2("dim", "..."), v = Math.max(m - r2, 0), a2 = Math.max(Math.min(b, v), 5);
|
|
29823
30919
|
let f = 0;
|
|
29824
|
-
|
|
29825
|
-
Math.min(
|
|
30920
|
+
l >= a2 - 3 && (f = Math.max(
|
|
30921
|
+
Math.min(l - a2 + 3, e.length - a2),
|
|
29826
30922
|
0
|
|
29827
30923
|
));
|
|
29828
30924
|
let d = a2 < e.length && f > 0, c2 = a2 < e.length && f + a2 < e.length;
|
|
29829
|
-
const
|
|
30925
|
+
const W = Math.min(
|
|
29830
30926
|
f + a2,
|
|
29831
30927
|
e.length
|
|
29832
30928
|
), s = [];
|
|
29833
30929
|
let g = 0;
|
|
29834
30930
|
d && g++, c2 && g++;
|
|
29835
|
-
const T = f + (d ? 1 : 0), y2 =
|
|
30931
|
+
const T = f + (d ? 1 : 0), y2 = W - (c2 ? 1 : 0);
|
|
29836
30932
|
for (let t2 = T; t2 < y2; t2++) {
|
|
29837
|
-
const n4 = e[t2], o = n4 ? w(n4, t2 ===
|
|
30933
|
+
const n4 = e[t2], o = n4 ? w(n4, t2 === l) : "", h2 = wrapAnsi(o, i2, {
|
|
29838
30934
|
hard: true,
|
|
29839
30935
|
trim: false
|
|
29840
30936
|
}).split(`
|
|
@@ -29843,7 +30939,7 @@ var limitOptions = ({
|
|
|
29843
30939
|
}
|
|
29844
30940
|
if (g > v) {
|
|
29845
30941
|
let t2 = 0, n4 = 0, o = g;
|
|
29846
|
-
const h2 =
|
|
30942
|
+
const h2 = l - T;
|
|
29847
30943
|
let u4 = v;
|
|
29848
30944
|
const L = () => I(s, o, 0, h2, u4), E = () => I(
|
|
29849
30945
|
s,
|
|
@@ -29872,10 +30968,10 @@ var confirm = (e) => {
|
|
|
29872
30968
|
output: e.output,
|
|
29873
30969
|
initialValue: e.initialValue ?? true,
|
|
29874
30970
|
render() {
|
|
29875
|
-
const i2 = e.withGuide ?? settings.withGuide, u4 = `${symbol2(this.state)} `,
|
|
30971
|
+
const i2 = e.withGuide ?? settings.withGuide, u4 = `${symbol2(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
|
|
29876
30972
|
e.output,
|
|
29877
30973
|
e.message,
|
|
29878
|
-
|
|
30974
|
+
l,
|
|
29879
30975
|
u4
|
|
29880
30976
|
), s = `${i2 ? `${styleText2("gray", S_BAR)}
|
|
29881
30977
|
` : ""}${f}
|
|
@@ -29943,86 +31039,6 @@ ${n4}
|
|
|
29943
31039
|
}
|
|
29944
31040
|
}
|
|
29945
31041
|
}).prompt();
|
|
29946
|
-
var W = (l2) => styleText2("magenta", l2);
|
|
29947
|
-
var spinner = ({
|
|
29948
|
-
indicator: l2 = "dots",
|
|
29949
|
-
onCancel: h2,
|
|
29950
|
-
output: n4 = process.stdout,
|
|
29951
|
-
cancelMessage: G,
|
|
29952
|
-
errorMessage: O,
|
|
29953
|
-
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
29954
|
-
delay: F = unicode ? 80 : 120,
|
|
29955
|
-
signal: m,
|
|
29956
|
-
...I2
|
|
29957
|
-
} = {}) => {
|
|
29958
|
-
const u4 = isCI();
|
|
29959
|
-
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
29960
|
-
const x2 = getColumns(n4), k = I2?.styleFrame ?? W, g = (e) => {
|
|
29961
|
-
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
29962
|
-
S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
|
|
29963
|
-
}, f = () => g(2), i2 = () => g(1), A = () => {
|
|
29964
|
-
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g), m && m.addEventListener("abort", i2);
|
|
29965
|
-
}, H = () => {
|
|
29966
|
-
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m && m.removeEventListener("abort", i2);
|
|
29967
|
-
}, y2 = () => {
|
|
29968
|
-
if (p === void 0) return;
|
|
29969
|
-
u4 && n4.write(`
|
|
29970
|
-
`);
|
|
29971
|
-
const r2 = wrapAnsi(p, x2, {
|
|
29972
|
-
hard: true,
|
|
29973
|
-
trim: false
|
|
29974
|
-
}).split(`
|
|
29975
|
-
`);
|
|
29976
|
-
r2.length > 1 && n4.write(import_sisteransi2.cursor.up(r2.length - 1)), n4.write(import_sisteransi2.cursor.to(0)), n4.write(import_sisteransi2.erase.down());
|
|
29977
|
-
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
29978
|
-
const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
|
|
29979
|
-
return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
|
|
29980
|
-
}, N = I2.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
29981
|
-
d = true, M = block({ output: n4 }), s = C(e), w = performance.now(), N && n4.write(`${styleText2("gray", S_BAR)}
|
|
29982
|
-
`);
|
|
29983
|
-
let r2 = 0, t2 = 0;
|
|
29984
|
-
A(), T = setInterval(() => {
|
|
29985
|
-
if (u4 && s === p)
|
|
29986
|
-
return;
|
|
29987
|
-
y2(), p = s;
|
|
29988
|
-
const o = k(E[r2]);
|
|
29989
|
-
let v;
|
|
29990
|
-
if (u4)
|
|
29991
|
-
v = `${o} ${s}...`;
|
|
29992
|
-
else if (l2 === "timer")
|
|
29993
|
-
v = `${o} ${s} ${_(w)}`;
|
|
29994
|
-
else {
|
|
29995
|
-
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
29996
|
-
v = `${o} ${s}${B}`;
|
|
29997
|
-
}
|
|
29998
|
-
const j = wrapAnsi(v, x2, {
|
|
29999
|
-
hard: true,
|
|
30000
|
-
trim: false
|
|
30001
|
-
});
|
|
30002
|
-
n4.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
30003
|
-
}, F);
|
|
30004
|
-
}, a2 = (e = "", r2 = 0, t2 = false) => {
|
|
30005
|
-
if (!d) return;
|
|
30006
|
-
d = false, clearInterval(T), y2();
|
|
30007
|
-
const o = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
30008
|
-
s = e ?? s, t2 || (l2 === "timer" ? n4.write(`${o} ${s} ${_(w)}
|
|
30009
|
-
`) : n4.write(`${o} ${s}
|
|
30010
|
-
`)), H(), M();
|
|
30011
|
-
};
|
|
30012
|
-
return {
|
|
30013
|
-
start: P,
|
|
30014
|
-
stop: (e = "") => a2(e, 0),
|
|
30015
|
-
message: (e = "") => {
|
|
30016
|
-
s = C(e ?? s);
|
|
30017
|
-
},
|
|
30018
|
-
cancel: (e = "") => a2(e, 1),
|
|
30019
|
-
error: (e = "") => a2(e, 2),
|
|
30020
|
-
clear: () => a2("", 0, true),
|
|
30021
|
-
get isCancelled() {
|
|
30022
|
-
return S;
|
|
30023
|
-
}
|
|
30024
|
-
};
|
|
30025
|
-
};
|
|
30026
31042
|
var u3 = {
|
|
30027
31043
|
light: unicodeOr("\u2500", "-"),
|
|
30028
31044
|
heavy: unicodeOr("\u2501", "="),
|
|
@@ -30254,7 +31270,7 @@ ${ash(indent(error62.details, 4))}
|
|
|
30254
31270
|
}
|
|
30255
31271
|
function indent(text2, spaces) {
|
|
30256
31272
|
const pad = " ".repeat(spaces);
|
|
30257
|
-
return text2.split("\n").map((
|
|
31273
|
+
return text2.split("\n").map((l) => pad + l).join("\n");
|
|
30258
31274
|
}
|
|
30259
31275
|
var label = (text2) => ash(text2.padEnd(11));
|
|
30260
31276
|
var link = (url2) => color ? import_picocolors.default.underline(url2) : url2;
|
|
@@ -30363,18 +31379,18 @@ async function dbCommand(ctx2, options) {
|
|
|
30363
31379
|
}
|
|
30364
31380
|
|
|
30365
31381
|
// src/commands/dev.ts
|
|
30366
|
-
import { existsSync as
|
|
30367
|
-
import { dirname as
|
|
31382
|
+
import { existsSync as existsSync27 } from "node:fs";
|
|
31383
|
+
import { dirname as dirname9, join as join31, resolve as resolve7 } from "node:path";
|
|
30368
31384
|
|
|
30369
31385
|
// ../preview/src/dev-server.ts
|
|
30370
|
-
import { existsSync as
|
|
30371
|
-
import { dirname as
|
|
31386
|
+
import { existsSync as existsSync26, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
31387
|
+
import { dirname as dirname8, join as join30 } from "node:path";
|
|
30372
31388
|
import { pathToFileURL } from "node:url";
|
|
30373
31389
|
|
|
30374
31390
|
// ../preview/src/plugin.ts
|
|
30375
31391
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
30376
|
-
import { existsSync as
|
|
30377
|
-
import { readFile as
|
|
31392
|
+
import { existsSync as existsSync25, readFileSync as readFileSync2, realpathSync as realpathSync4 } from "node:fs";
|
|
31393
|
+
import { readFile as readFile19, writeFile as writeFile13 } from "node:fs/promises";
|
|
30378
31394
|
import { isAbsolute, relative as relative4, resolve as resolve6, sep as sep4 } from "node:path";
|
|
30379
31395
|
import { stripVTControlCharacters as stripVTControlCharacters2 } from "node:util";
|
|
30380
31396
|
|
|
@@ -31550,8 +32566,8 @@ var MappingsEncoder = class {
|
|
|
31550
32566
|
drain(trailing) {
|
|
31551
32567
|
const lines = this.lines;
|
|
31552
32568
|
const lineCount = lines.length;
|
|
31553
|
-
for (let
|
|
31554
|
-
const line =
|
|
32569
|
+
for (let l = 0; l <= lineCount; l++) {
|
|
32570
|
+
const line = l < lineCount ? lines[l] : trailing;
|
|
31555
32571
|
if (line === null) break;
|
|
31556
32572
|
for (let i2 = 0; i2 < line.length; i2++) {
|
|
31557
32573
|
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
@@ -31571,7 +32587,7 @@ var MappingsEncoder = class {
|
|
|
31571
32587
|
this.prevNameIndex = segment[4];
|
|
31572
32588
|
}
|
|
31573
32589
|
}
|
|
31574
|
-
if (
|
|
32590
|
+
if (l < lineCount) {
|
|
31575
32591
|
if (this.pos > FLUSH_THRESHOLD) this.flush();
|
|
31576
32592
|
scratch[this.pos++] = SEMICOLON;
|
|
31577
32593
|
this.needsComma = false;
|
|
@@ -47119,17 +48135,17 @@ function editText(code2, file3, location, before, after) {
|
|
|
47119
48135
|
}
|
|
47120
48136
|
|
|
47121
48137
|
// ../preview/src/toolbar-source.ts
|
|
47122
|
-
import { existsSync as
|
|
47123
|
-
import { readFile as
|
|
48138
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
48139
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
47124
48140
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
47125
48141
|
var cached2;
|
|
47126
48142
|
async function toolbarSource() {
|
|
47127
|
-
if (true) return '"use strict";(()=>{var P="data-cl-src";function Q(i){let e=i.match(/^(.+):(\\d+):(\\d+)$/);if(e)return{file:e[1],line:Number(e[2]),column:Number(e[3])}}var b="/__clodable/",u={toolbar:`${b}toolbar.js`,health:`${b}health`,frame:`${b}frame`,probe:`${b}text/probe`,text:`${b}text`,inbox:`${b}inbox`,originalLine:`${b}original-line`,buildError:`${b}build-error`},C="__clodable_frame",ee={phone:{width:390,height:844},tablet:{width:820,height:1180}};function H(i,e,t){return{message:i.trim().split(`\n`)[0].slice(0,300),stack:e.slice(0,4e3),kind:"build",...t?{source:t}:{}}}var F=()=>typeof __CLODABLE__>"u"?void 0:__CLODABLE__,ye=()=>F()?.token??"",te;function oe(){te=window.fetch.bind(window)}async function x(i,e){let t=await(te??fetch)(i,{method:"POST",headers:{"content-type":"application/json","x-clodable-token":ye()},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Clodable ${i}: ${t.status}`);return await t.json()}var D=()=>{try{let i=sessionStorage.getItem("clodable:conversation");return i?{conversation:i}:{}}catch{return{}}},N=()=>({url:location.href,path:location.pathname+location.search,title:document.title}),m={probe:(i,e)=>x(u.probe,{src:i,text:e}),edit:(i,e,t)=>x(u.text,{src:i,before:e,after:t,page:N(),...D()}),ask:(i,e,t)=>x(u.inbox,{kind:"ask",page:N(),request:i,element:e,...t?{source:t}:{},...D()}),fix:(i,e)=>x(u.inbox,{kind:"fix",page:N(),error:i,console:e,...D()}),originalLine:i=>x(u.originalLine,i).then(e=>e.line),buildError:i=>x(u.buildError,{since:i}).then(e=>e.error)};var z={light:{paper:"#FBF8F3",bisque:"#F4EEE6",slip:"#E7DED2",slipStrong:"#D3C6B6",ink:"#1F1A16",ash:"#6B6158",clay:"#B9502B",clayHover:"#A44322",clayText:"#A2441F",onClay:"#FFFFFF",claySoft:"#F7E4DA",celadon:"#2B7354",celadonSoft:"#E1F0E8",cobalt:"#2D5BA6",cobaltSoft:"#E3EBF7",ochre:"#8F6210",ochreSoft:"#F7ECD4",oxide:"#B1281E",oxideSoft:"#F9E1DE",focus:"#2D5BA6",scrim:"rgba(31, 26, 22, 0.32)"},dark:{paper:"#15110E",bisque:"#1E1915",slip:"#352D27",slipStrong:"#4A4038",ink:"#F3EEE7",ash:"#A79D92",clay:"#E5764F",clayHover:"#EE8A66",clayText:"#F08F6B",onClay:"#1F1A16",claySoft:"#3A2419",celadon:"#6CC59E",celadonSoft:"#16342A",cobalt:"#8AB0F0",cobaltSoft:"#18263D",ochre:"#E6B356",ochreSoft:"#3A2C12",oxide:"#F27B70",oxideSoft:"#3E1A17",focus:"#8AB0F0",scrim:"rgba(0, 0, 0, 0.5)"}};var _={sm:"6px",md:"10px",lg:"14px",xl:"20px",pill:"999px"},w={ui:\'ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif\',mono:\'ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace\',display:\'"Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif\'};var B={light:{sm:"0 1px 2px rgba(60, 38, 20, 0.08)",md:"0 1px 2px rgba(60, 38, 20, 0.06), 0 6px 16px -4px rgba(60, 38, 20, 0.14)",lg:"0 2px 4px rgba(60, 38, 20, 0.06), 0 18px 40px -12px rgba(60, 38, 20, 0.28)"},dark:{sm:"0 1px 2px rgba(0, 0, 0, 0.4)",md:"0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px -4px rgba(0, 0, 0, 0.5)",lg:"0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 40px -12px rgba(0, 0, 0, 0.7)"}},f={fast:"120ms",base:"180ms",slow:"260ms",easeOut:"cubic-bezier(0.2, 0.8, 0.2, 1)",easeInOut:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.4, 0.64, 1)"},I={toolbar:2147483e3,toast:2147483100,overlay:2147483200};var we=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);function k(i){let e=Object.entries(z[i]).map(([o,r])=>`--cl-${we(o)}: ${r};`).join(" "),t=Object.entries(B[i]).map(([o,r])=>`--cl-shadow-${o}: ${r};`).join(" ");return`${e} ${t} color-scheme: ${i};`}var ie=[...Object.entries(_).map(([i,e])=>`--cl-radius-${i}: ${e};`),`--cl-font-ui: ${w.ui};`,`--cl-font-mono: ${w.mono};`,`--cl-font-display: ${w.display};`,`--cl-fast: ${f.fast};`,`--cl-base: ${f.base};`,`--cl-slow: ${f.slow};`,`--cl-ease-out: ${f.easeOut};`,`--cl-ease-in-out: ${f.easeInOut};`,`--cl-spring: ${f.spring};`].join(" ");function q(i={}){let e=i.selector??":root",t=i.scheme??"auto";if(t!=="auto")return`${e} { ${ie} ${k(t)} }`;let o=r=>e===":host"?`:host([data-theme="${r}"]) { ${k(r)} }`:`${e}[data-theme="${r}"] { ${k(r)} }`;return[`${e} { ${ie} ${k("light")} }`,`@media (prefers-color-scheme: dark) { ${e} { ${k("dark")} } }`,o("light"),o("dark")].join(`\n`)}var d=(...i)=>i,ne={check:d("M4.5 10.5l3.5 3.5 7.5-8"),close:d("M5.5 5.5l9 9M14.5 5.5l-9 9"),publish:d("M10 13.5v-7","M7 9.5l3-3 3 3",{circle:[10,10,7]}),undo:d("M7.5 5.5 4 9l3.5 3.5","M4.5 9h7.25a3.75 3.75 0 0 1 0 7.5H10"),restore:d("M3.5 10a6.5 6.5 0 1 0 1.9-4.6","M3.5 3.5v3h3","M10 6.75V10l2.5 1.5"),external:d("M8.5 5.5h-3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3","M11.5 4.5h4v4","M15.5 4.5 9.5 10.5"),phone:d("M8 2.5h4a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2z","M9 15h2"),tablet:d("M6 3h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z","M9 14.5h2"),desktop:d("M3.5 4.5h13a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1z","M7.5 17.5h5","M10 14.5v3"),text:d("M3.5 6V4.5h9V6","M8 4.5v11","M6 15.5h4","M15 8.5v8","M13.5 8.5h3","M13.5 16.5h3"),select:d("M4.5 3.5l10.5 4.6-4.4 1.6-1.6 4.4z","M10.6 9.7l4.4 4.4"),minimize:d("M5 10h10"),alert:d("M10 3.8 17.2 16.2H2.8z","M10 8.5v3.5","M10 14.25v.01"),info:d({circle:[10,10,7]},"M10 9.25v4.5","M10 6.5v.01"),globe:d({circle:[10,10,7]},"M3 10h14","M10 3c1.9 2 2.9 4.4 2.9 7s-1 5-2.9 7c-1.9-2-2.9-4.4-2.9-7s1-5 2.9-7z"),database:d("M4 5.5C4 4.1 6.7 3 10 3s6 1.1 6 2.5S13.3 8 10 8 4 6.9 4 5.5z","M4 5.5v9C4 15.9 6.7 17 10 17s6-1.1 6-2.5v-9","M4 10c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5"),refresh:d("M15.5 8a6 6 0 0 0-10.4-1.6L4 8","M4 4.5V8h3.5","M4.5 12a6 6 0 0 0 10.4 1.6L16 12","M16 15.5V12h-3.5"),grip:d({circle:[7.5,6,1.1],fill:!0},{circle:[12.5,6,1.1],fill:!0},{circle:[7.5,10,1.1],fill:!0},{circle:[12.5,10,1.1],fill:!0},{circle:[7.5,14,1.1],fill:!0},{circle:[12.5,14,1.1],fill:!0}),more:d({circle:[5,10,1.25],fill:!0},{circle:[10,10,1.25],fill:!0},{circle:[15,10,1.25],fill:!0}),chevronDown:d("M6 8l4 4 4-4"),chevronUp:d("M6 12l4-4 4 4"),arrowRight:d("M4.5 10h11","M11 5.5l4.5 4.5-4.5 4.5"),copy:d("M7.5 7.5h7a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z","M4.5 12.5h-.25a.75.75 0 0 1-.75-.75v-7.5a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 .75.75v.25")},re=i=>i.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");function K(i,e={}){let t=e.size??20,o=e.strokeWidth??1.6,r=e.label?`role="img" aria-label="${re(e.label)}"`:\'aria-hidden="true" focusable="false"\',n=e.className?` class="${re(e.className)}"`:"",s=ne[i].map(l=>{if(typeof l=="string")return`<path d="${l}"/>`;let[p,h,c]=l.circle;return l.fill?`<circle cx="${p}" cy="${h}" r="${c}" fill="currentColor" stroke="none"/>`:`<circle cx="${p}" cy="${h}" r="${c}"/>`}).join("");return`<svg${n} xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="${o}" stroke-linecap="round" stroke-linejoin="round" ${r}>${s}</svg>`}var ae=[".........ooo....",".......oobbbo...","......obbbbbo...","....oobbbbbbo...","...obbbbbbbbbo..","..obbbbbbbbbbbo.",".obbbbbbbbbbbbo.",".obbeebbbbeebbo.","obbbeebbbbeebbbo","obbbbbbeebbbbbbo","obbbbbbbbbbbbbbo","oobbbbbbbbbbbbbo","..obbbbbbbbbbbo.","..oobbbooobbboo.","....obo...obo...","....ooo...ooo..."],se={outline:"#3B1A10",clay:"#E88858",eyes:"#2A140C"};function ke(i){let e={o:i.outline,b:i.clay,e:i.eyes},t={};return ae.forEach((o,r)=>{for(let n=0;n<o.length;){let s=o[n],l=1;for(;o[n+l]===s;)l++;e[s]&&(t[s]=`${t[s]??""}M${n} ${r}h${l}v1h-${l}z`),n+=l}}),Object.entries(t).map(([o,r])=>`<path fill="${e[o]}" d="${r}"/>`).join("")}function j(i={}){let e=i.size??32,t=i.label?`role="img" aria-label="${i.label.replace(/"/g,""")}"`:\'aria-hidden="true" focusable="false"\';return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 16 16" shape-rendering="crispEdges" ${t}>${ke({...se,...i.colors})}</svg>`}function a(i,e={},...t){let o=document.createElement(i);for(let[r,n]of Object.entries(e))n==null||n===!1||(r==="class"?o.className=String(n):r==="style"?typeof n=="string"?o.setAttribute("style",n):Object.assign(o.style,n):r==="dataset"?Object.assign(o.dataset,n):r.startsWith("on")&&typeof n=="function"?o.addEventListener(r.slice(2).toLowerCase(),n):n===!0?o.setAttribute(r,""):o.setAttribute(r,String(n)));return Ee(o,t),o}function Ee(i,e){for(let t of e)t==null||t===!1||i.appendChild(typeof t=="object"?t:document.createTextNode(String(t)))}function g(i,e=18){let t=document.createElement("span");return t.className="ic",t.innerHTML=K(i,{size:e,strokeWidth:e<=16?1.7:1.6}),t}var T=[],le=[],X;function U(i){X?X(i):le.push(i)}var ce="Part of the app didn\'t load",de=new RegExp(`^${ce}$|Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed`,"i"),Y="clodable:fixing";function Se(){try{return Date.now()-Number(sessionStorage.getItem(Y)??0)<12e4}catch{return!1}}function $(i){try{i?sessionStorage.setItem(Y,String(Date.now())):sessionStorage.removeItem(Y)}catch{}}function pe(){addEventListener("error",e=>{let t=e.target;!(t instanceof HTMLScriptElement)||t.hasAttribute("data-clodable-toolbar")||t.src&&new URL(t.src,location.href).origin!==location.origin||U({message:ce,kind:"build"})},!0),addEventListener("error",e=>{let t=e.error;U({message:t?.message??e.message,...t?.stack?{stack:t.stack}:{},kind:"runtime"})}),addEventListener("unhandledrejection",e=>{let t=e.reason,o=typeof t=="string"?t:t?.message??"A background task failed";U({message:o,...typeof t=="object"&&t?.stack?{stack:t.stack}:{},kind:"promise"})});let i=console.error.bind(console);console.error=(...e)=>{T.push(e.map(t=>t instanceof Error?t.message:String(t)).join(" ").slice(0,400)),T.length>8&&T.shift(),i(...e)}}async function Me(){try{return(await import(`${location.origin}/@vite/client`)).createHotContext?.(u.toolbar)}catch{return}}var Ce=[/ResizeObserver loop/i,/Script error\\.?$/i,/__clodable/];function $e(i){if(i)for(let e of i.split(`\n`)){let t=e.match(/https?:\\/\\/[^/]+\\/(src\\/[^?:)\\s]+)(?:\\?[^:)]*)?:(\\d+):(\\d+)/);if(t)return{file:t[1],line:Number(t[2]),column:Number(t[3])}}}function V(){return((document.getElementById("root")??document.body).innerText??"").trim().length===0}var W=i=>i.split("/").pop()??i,v=i=>a("strong",{},i);function Te(i){let e=i.source&&W(i.source.file),t=i.message.match(/Failed to resolve import "([^"]+)" from "([^"]+)"/);if(t){let r=t[1],n=t[2];if(/^(\\.|\\/|@\\/|~\\/)/.test(r)){let s=r.replace(/^(@|~)\\//,"").replace(/^(\\.\\.?\\/)+/,"");return[v(W(n))," refers to ",v(s),", a file that doesn\\u2019t exist."]}return[v(W(n))," uses ",v(r),", a package that isn\\u2019t installed."]}let o=i.message.match(/^(?:\\w*Error: )?([\\w$]+) is not defined$|Can\'t find variable: ([\\w$]+)/);if(o){let r=o[1]??o[2];return[e?v(e):"This page"," refers to ",v(r),", which doesn\\u2019t exist."]}return de.test(i.message)?["Part of the app\\u2019s code didn\\u2019t load."]:i.kind==="build"?e?[v(e),` has a mistake on line ${i.source.line}.`]:["A mistake in the code stops it from loading."]:e?["The problem starts in ",v(e),`, line ${i.source.line}.`]:["Something in the code went wrong."]}function Le(i){let e=i.source?`${i.source.file}:${i.source.line}`:"",t=[];for(let o of(i.stack??"").split(`\n`))!o.trim()||o.endsWith(i.message)||i.source&&o.endsWith(i.source.file)||t.push(o.replace(/https?:\\/\\/[^/\\s]+\\/(@fs\\/)?/g,"").replace(/\\?[^:)\\s]*(?=:\\d)/g,""));return{where:e,frame:t.slice(0,24).join(`\n`)}}function Ae(i){let e=i.err;if(!e)return;let t=e.loc?.file??e.id??"",o=t.match(/(src\\/[^?:]+)/);return H(e.message??"The app couldn\'t be built",`${t}\n${e.message??""}\n${e.stack??""}`,o?{file:o[1],line:e.loc?.line??1}:void 0)}function Re(){let i=document.querySelector("vite-error-overlay");if(!i)return;let e=i.shadowRoot?.querySelector(".message-body")?.textContent??"The app couldn\'t be built",t=i.shadowRoot?.querySelector(".file")?.textContent??"",o=t.match(/(src\\/[^:]+):(\\d+)/);return H(e,`${t}\n${e}`,o?{file:o[1],line:Number(o[2])}:void 0)}function Oe(i,e,t){return e?"Claude is fixing it\\u2026":i.kind==="build"?"Your app can\\u2019t load":t?"This page can\\u2019t load":"Something broke on this page"}var L=class{constructor(e,t,o){this.layer=e;this.dockSlot=t;this.toast=o}layer;dockSlot;toast;card;current;dismissed=new Set;detailsOpen=!1;updateStarted=0;start(){X=t=>this.capture(t);let e=le.splice(0);for(let t of e)this.capture(t);!e.length&&V()&&m.buildError(performance.timeOrigin).then(t=>{t&&!this.current&&this.show(t)},()=>{}),setTimeout(()=>{this.current||$(!1)},3e3),Me().then(t=>{t?.on("vite:error",o=>{let r=Ae(o);r&&this.capture(r)}),t?.on("vite:beforeUpdate",()=>{this.updateStarted=Date.now()}),t?.on("vite:afterUpdate",()=>{this.afterUpdate()})}),new MutationObserver(()=>{let t=Re();t&&this.capture(t)}).observe(document.documentElement,{childList:!0})}async afterUpdate(){if(this.current){if(V()||this.current.kind==="build"){let e=await m.buildError(this.updateStarted).catch(()=>null);e?this.show(e):location.reload();return}$(!1),this.dismiss(!1)}}capture(e){if(!(!e.message||Ce.some(t=>t.test(e.message)))){if(de.test(e.message)){m.buildError(performance.timeOrigin).then(t=>this.show(t??e),()=>this.show(e));return}this.show(e)}}show(e){if(this.dismissed.has(e.message))return;let t=e.source?void 0:$e(e.stack);if(t){let o=r=>this.show({...e,source:{file:t.file,line:r??t.line}});m.originalLine(t).then(o,()=>o(null));return}this.current=e,setTimeout(()=>this.render(),60)}render(e=Se()){let t=this.current;if(!t)return;let o=t.kind==="build"||V(),r=!!this.card?.isConnected,n=this.layer.getRootNode(),s=!!this.card?.contains(n.activeElement);this.card?.remove();let{more:l,details:p}=this.detailsToggle(t),h=a("button",{class:"close","aria-label":"Dismiss",onclick:()=>this.dismiss()},g("close",16)),c=a("div",{class:`error ${o?"screen":"note"}${e?" working":""}${r?" still":""}`,role:"alert","aria-labelledby":"cl-err-title","aria-describedby":"cl-err-why"},a("div",{class:"error-body"},a("div",{class:"head"},a("span",{class:e?"spinner":"dot","aria-hidden":"true"}),a("h3",{id:"cl-err-title"},Oe(t,e,o)),o?null:h),a("p",{class:"why",id:"cl-err-why"},...e?["The preview updates by itself when it\\u2019s fixed."]:Te(t)),e?null:a("div",{class:"actions"},a("button",{class:"btn primary",onclick:()=>this.fix()},"Try to fix"),l),e?null:p),o?h:null);this.card=c,o?this.layer.append(c):this.dockSlot.prepend(c),s&&(c.querySelector(".btn.primary")??h).focus()}detailsToggle(e){let{where:t,frame:o}=Le(e),r=a("div",{class:"details",id:"cl-err-details",hidden:!this.detailsOpen},t?a("p",{class:"where"},t):null,a("p",{class:"raw"},e.message),o?a("pre",{class:"frame"},o):null),n=a("span",{},this.detailsOpen?"Hide details":"Show details"),s=a("button",{class:"btn ghost more","aria-expanded":String(this.detailsOpen),"aria-controls":"cl-err-details",onclick:()=>{this.detailsOpen=!this.detailsOpen,r.hidden=!this.detailsOpen,n.textContent=this.detailsOpen?"Hide details":"Show details",s.setAttribute("aria-expanded",String(this.detailsOpen))}},n,g("chevronDown",16));return{more:s,details:r}}async fix(){let e=this.current;if(e){$(!0),this.render(!0);try{await m.fix(e,[...T])}catch{$(!1),this.toast("Couldn\'t reach Claude. Is Clodable running?","warn"),this.render(!1)}}}dismiss(e=!0){this.current&&e&&this.dismissed.add(this.current.message),this.current=void 0,this.card?.remove(),this.card=void 0}};function y(i){let e=i?.closest(`[${P}]`),t=e?.getAttribute(P);return e&&t?{el:e,src:t}:void 0}function G(i){let e=i.tagName.toLowerCase(),t=i.getAttribute("role");if(/^h[1-6]$/.test(e))return"heading";if(e==="button"||t==="button")return"button";if(e==="a"){let r=i.getAttribute("class")??"";return/\\brounded/.test(r)&&/\\b(bg-|border)/.test(r)&&/\\b(px-|h-\\d)/.test(r)?"button":"link"}if(e==="img"||e==="picture"||e==="video")return"image";if(e==="svg")return"icon";if(["input","textarea","select"].includes(e))return"input";if(["ul","ol","li","dl"].includes(e))return"list";if(e==="nav"||e==="header"||e==="footer")return"nav";if(["section","main","article","aside"].includes(e))return"section";if(["p","span","label","strong","em","small","blockquote","figcaption"].includes(e))return"text";let o=i.getAttribute("class")??"";return/\\bcard\\b|rounded-(lg|xl|2xl)/.test(o)&&i.children.length>1?"card":i.children.length===0&&i.textContent?.trim()?"text":i.children.length>2?"section":"element"}var Pe={heading:"Heading",text:"Text",button:"Button",link:"Link",image:"Image",input:"Field",list:"List",section:"Section",nav:"Navigation",card:"Card",icon:"Icon",element:"Element"};function E(i){let e=G(i);if(e==="nav"){let t=i.tagName.toLowerCase();return t==="header"?"Header":t==="footer"?"Footer":"Navigation"}return Pe[e]}function A(i,e=42){let o=(i.getAttribute("alt")??i.getAttribute("aria-label")??i.textContent??"").replace(/\\s+/g," ").trim();return o?o.length>e?`${o.slice(0,e-1).trimEnd()}\\u2026`:o:""}function he(i){let e=i.tagName.toLowerCase(),t=(i.getAttribute("class")??"").split(/\\s+/).slice(0,8).join(" "),o=A(i,80);return`${E(i)} <${e}${t?` class="${t}"`:""}>${o?` \\u201C${o}\\u201D`:""}`}var ue={heading:["Rewrite it","Make it bigger","Change the font"],text:["Rewrite it","Make it shorter","Change the color"],button:["Change the label","Make it stand out","Change what it does"],link:["Change where it goes","Change the text","Style it as a button"],image:["Replace the image","Make it rounder","Make it bigger"],input:["Change the placeholder","Make it required","Change the label"],list:["Add an item","Change the layout","Reorder it"],section:["Change the layout","Add something here","Change the background"],nav:["Add a link","Change the logo","Make it sticky"],card:["Change the layout","Add a picture","Make it stand out"],icon:["Use a different icon","Make it bigger","Change the color"],element:["Change the style","Move it","Remove it"]};var S=class{constructor(e){this.layer=e;this.box=a("div",{class:"hl",style:"opacity:0"}),this.chip=a("div",{class:"chip",style:"opacity:0"}),e.append(this.box,this.chip)}layer;box;chip;target;frame=0;lines=[];perLine=!1;show(e,t,o,r={}){this.target=e,this.perLine=!!r.perLine,this.box.className=`hl ${t}`,this.box.style.opacity="1";for(let n of this.lines)n.className=`hl ${t}`;o?(this.chip.className=`chip ${t.startsWith("ask")?"ask":t==="locked"?"locked":""}`,this.chip.replaceChildren(...o.icon?[g(o.icon,14)]:[],a("span",{},o.strong),...o.muted?[a("span",{class:"muted"},o.muted)]:[]),this.chip.style.opacity="1"):this.chip.style.opacity="0",this.place(),this.frame||this.loop()}fadeOut(e,t){this.show(e,t),this.box.addEventListener("animationend",()=>this.hide(),{once:!0})}hide(){this.target=void 0,this.box.style.opacity="0",this.chip.style.opacity="0";for(let e of this.lines)e.remove();this.lines=[],cancelAnimationFrame(this.frame),this.frame=0}loop=()=>{this.place(),this.frame=this.target?requestAnimationFrame(this.loop):0};place(){let e=this.target?.getBoundingClientRect();if(!e)return;if(this.perLine&&this.target){let o=Array.from(this.target.getClientRects()).filter(r=>r.width>0&&r.height>0);if(o.length>1){for(;this.lines.length<o.length-1;){let n=a("div",{class:this.box.className});this.layer.append(n),this.lines.push(n)}for(;this.lines.length>o.length-1;)this.lines.pop()?.remove();let r=[this.box,...this.lines];o.forEach((n,s)=>{Object.assign(r[s].style,{top:`${n.top}px`,left:`${n.left}px`,width:`${n.width}px`,height:`${n.height}px`,opacity:"1"})});return}}Object.assign(this.box.style,{top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`});let t=e.top-30<4?e.bottom+8:e.top-30;Object.assign(this.chip.style,{top:`${t}px`,left:`${Math.max(6,Math.min(e.left-3,innerWidth-200))}px`})}};function J(i,e,t=10){let{width:o,height:r}=i.getBoundingClientRect(),s=e.bottom+t+r<innerHeight-70?e.bottom+t:Math.max(8,e.top-t-r),l=Math.min(Math.max(8,e.left),innerWidth-o-8);i.style.top=`${s}px`,i.style.left=`${l}px`}var R=class{el;constructor(){this.el=a("div",{class:"toasts",role:"status","aria-live":"polite"})}show(e,t={}){let o=a("div",{class:`toast ${t.tone==="warn"?"warn":""}`},g(t.tone==="warn"?"alert":"check",16),e);for(this.el.append(o);this.el.children.length>3;)this.el.firstElementChild?.remove();setTimeout(()=>{o.classList.add("leaving"),setTimeout(()=>o.remove(),260)},t.ms??2600)}};var ge=`\n${q({selector:":host"})}\n:host {\n all: initial;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: ${I.toolbar};\n font: 13px/18px var(--cl-font-ui);\n color: var(--cl-ink);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n --dock-bg: color-mix(in oklab, var(--cl-paper) 88%, transparent);\n --dock-border: color-mix(in oklab, var(--cl-slip-strong) 70%, transparent);\n}\n* { box-sizing: border-box; }\n.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }\n.ic svg { display: block; }\nbutton { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }\nbutton:focus-visible, [tabindex]:focus-visible, textarea:focus-visible {\n outline: 2px solid var(--cl-focus);\n outline-offset: 2px;\n}\n.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n/* \\u2500\\u2500 Dock \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.dock-wrap {\n /* No transform here: it would trap the fixed-position pebble inside this box. */\n position: fixed; left: 0; right: 0; bottom: 14px;\n display: flex; flex-direction: column; align-items: center; gap: 8px;\n pointer-events: none;\n}\n.dock {\n pointer-events: auto;\n display: flex; align-items: center; gap: 2px;\n height: 46px; padding: 0 5px;\n background: var(--dock-bg);\n -webkit-backdrop-filter: blur(18px) saturate(1.5);\n backdrop-filter: blur(18px) saturate(1.5);\n border: 1px solid var(--dock-border);\n border-radius: var(--cl-radius-pill);\n box-shadow: var(--cl-shadow-lg);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n}\n@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.97); } }\n.sep { width: 1px; height: 22px; background: var(--cl-slip); margin: 0 5px; flex: none; }\n.backend { padding: 0 6px 0 2px; color: var(--cl-ash); font-size: 12px; font-weight: 500; white-space: nowrap; }\n.brand {\n width: 36px; height: 36px; border-radius: 50%;\n display: grid; place-items: center;\n transition: transform var(--cl-fast) var(--cl-ease-out), background var(--cl-fast);\n}\n/* The clod hops; turning or scaling it would blur its pixels. */\n.brand:hover { background: var(--cl-bisque); transform: translateY(-1px); }\n.brand[aria-expanded="true"] { background: var(--cl-bisque); }\n.tool {\n height: 36px; padding: 0 12px 0 10px;\n display: inline-flex; align-items: center; gap: 7px;\n border-radius: var(--cl-radius-pill);\n color: var(--cl-ink); font-weight: 500; letter-spacing: -0.005em;\n transition: background var(--cl-fast), color var(--cl-fast);\n white-space: nowrap;\n}\n.tool:hover { background: var(--cl-bisque); }\n.tool[aria-pressed="true"] { background: var(--cl-clay-soft); color: var(--cl-clay-text); }\n.tool .key {\n font: 500 10.5px/16px var(--cl-font-ui); color: var(--cl-ash);\n padding: 0 5px; border-radius: 5px; background: var(--cl-bisque); margin-left: 2px;\n}\n.tool[aria-pressed="true"] .key { background: color-mix(in oklab, var(--cl-clay) 14%, transparent); color: var(--cl-clay-text); }\n.icon-btn {\n width: 36px; height: 36px; border-radius: 50%;\n display: grid; place-items: center; color: var(--cl-ash);\n transition: background var(--cl-fast), color var(--cl-fast);\n}\n.icon-btn:hover { background: var(--cl-bisque); color: var(--cl-ink); }\n\n/* Device switcher: a segmented control with a sliding thumb. */\n.devices { position: relative; display: flex; align-items: center; height: 36px; padding: 3px; border-radius: var(--cl-radius-pill); background: var(--cl-bisque); }\n.devices .thumb {\n position: absolute; top: 3px; left: 3px; width: 34px; height: 30px; border-radius: var(--cl-radius-pill);\n background: var(--cl-paper); box-shadow: var(--cl-shadow-sm), 0 0 0 1px var(--cl-slip);\n transition: transform var(--cl-base) var(--cl-ease-out);\n}\n.devices button { position: relative; width: 34px; height: 30px; border-radius: var(--cl-radius-pill); display: grid; place-items: center; color: var(--cl-ash); transition: color var(--cl-fast); }\n.devices button:hover { color: var(--cl-ink); }\n.devices button[aria-checked="true"] { color: var(--cl-ink); }\n\n/* Narrow screens (and the phone frame): icons only. */\n@media (max-width: 560px) {\n .tool .label, .tool .key { display: none; }\n .tool { padding: 0; width: 36px; justify-content: center; }\n .dock-wrap { bottom: 10px; }\n}\n\n/* Minimized: a single clod in the corner. */\n.pebble {\n pointer-events: auto;\n position: fixed; right: 16px; bottom: 16px;\n width: 44px; height: 44px; border-radius: 50%;\n display: grid; place-items: center;\n background: var(--dock-bg);\n -webkit-backdrop-filter: blur(18px) saturate(1.5);\n backdrop-filter: blur(18px) saturate(1.5);\n border: 1px solid var(--dock-border);\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n transition: transform var(--cl-fast) var(--cl-ease-out);\n}\n.pebble:hover { transform: translateY(-2px); }\n\n/* \\u2500\\u2500 Hint above the dock \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.hint {\n pointer-events: auto;\n display: inline-flex; align-items: center; gap: 8px;\n height: 30px; padding: 0 12px 0 10px;\n background: var(--cl-ink); color: var(--cl-paper);\n border-radius: var(--cl-radius-pill);\n font-size: 12px; font-weight: 500;\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-base) var(--cl-ease-out) both;\n}\n.hint .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cl-clay); box-shadow: 0 0 0 0 var(--cl-clay); animation: pulse 1.8s var(--cl-ease-out) infinite; }\n.hint.ask .dot { background: var(--cl-cobalt); }\n.hint kbd { font: 500 11px/16px var(--cl-font-ui); padding: 0 5px; border-radius: 4px; background: color-mix(in oklab, var(--cl-paper) 16%, transparent); }\n@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--cl-clay) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }\n\n/* \\u2500\\u2500 Menu \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.menu {\n pointer-events: auto;\n position: fixed; min-width: 248px; padding: 6px;\n background: var(--cl-paper); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-lg);\n animation: pop var(--cl-base) var(--cl-ease-out) both;\n transform-origin: bottom left;\n}\n@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }\n.menu .head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }\n.menu .head b { font: 600 14px/18px var(--cl-font-display); letter-spacing: -0.01em; }\n.menu .head span { display: block; color: var(--cl-ash); font-size: 12px; }\n.menu hr { border: 0; border-top: 1px solid var(--cl-slip); margin: 4px 2px; }\n.menu-item {\n width: 100%; display: flex; align-items: center; gap: 10px;\n padding: 7px 8px; border-radius: var(--cl-radius-md); text-align: left; color: var(--cl-ink);\n}\n.menu-item:hover, .menu-item:focus-visible { background: var(--cl-bisque); outline: none; }\n.menu-item .ic { color: var(--cl-ash); }\n.menu-item .shortcut { margin-left: auto; color: var(--cl-ash); font-size: 11.5px; }\n\n/* \\u2500\\u2500 Highlights \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.hl {\n position: fixed; pointer-events: none;\n border-radius: 6px;\n transition: top 70ms linear, left 70ms linear, width 70ms linear, height 70ms linear, opacity var(--cl-fast);\n}\n.hl.edit-hover { outline: 1.5px dashed var(--cl-clay); outline-offset: 3px; background: color-mix(in oklab, var(--cl-clay) 5%, transparent); }\n.hl.editing { outline: 2px solid var(--cl-clay); outline-offset: 3px; box-shadow: 0 0 0 6px color-mix(in oklab, var(--cl-clay) 16%, transparent); }\n.hl.ask-hover { outline: 1.5px solid var(--cl-cobalt); outline-offset: 2px; background: color-mix(in oklab, var(--cl-cobalt) 7%, transparent); }\n.hl.saved { outline: 2px solid var(--cl-celadon); outline-offset: 3px; background: color-mix(in oklab, var(--cl-celadon) 12%, transparent); animation: fade 900ms var(--cl-ease-out) forwards; }\n.hl.locked { outline: 1.5px dashed var(--cl-ash); outline-offset: 3px; }\n@keyframes fade { 60% { opacity: 1; } to { opacity: 0; } }\n.chip {\n position: fixed; pointer-events: none;\n display: inline-flex; align-items: center; gap: 5px;\n height: 22px; padding: 0 8px 0 6px; border-radius: var(--cl-radius-pill);\n font-size: 11.5px; font-weight: 600; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis;\n /* on-clay reads on every chip fill (clay, cobalt, ash), in both schemes: see design\'s contrast test. */\n color: var(--cl-on-clay); background: var(--cl-clay);\n box-shadow: var(--cl-shadow-sm);\n}\n.chip.ask { background: var(--cl-cobalt); }\n.chip.locked { background: var(--cl-ash); }\n.chip .ic { width: 14px; height: 14px; }\n.chip .muted { font-weight: 500; opacity: .85; overflow: hidden; text-overflow: ellipsis; }\n\n/* \\u2500\\u2500 Popovers: edit bar, composer, notices \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.pop {\n pointer-events: auto;\n position: fixed;\n background: var(--cl-paper); color: var(--cl-ink);\n border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-lg);\n animation: pop var(--cl-base) var(--cl-ease-out) both;\n}\n.editbar { display: flex; align-items: center; gap: 6px; padding: 5px; border-radius: var(--cl-radius-pill); }\n.editbar .note { color: var(--cl-ash); font-size: 12px; padding: 0 6px 0 8px; white-space: nowrap; }\n.btn {\n height: 30px; padding: 0 12px; border-radius: var(--cl-radius-pill);\n display: inline-flex; align-items: center; gap: 6px;\n font-weight: 600; font-size: 12.5px; white-space: nowrap;\n transition: background var(--cl-fast), color var(--cl-fast), transform var(--cl-fast);\n}\n.btn:active { transform: translateY(1px); }\n.btn.primary { background: var(--cl-clay); color: var(--cl-on-clay); }\n.btn.primary:hover { background: var(--cl-clay-hover); }\n.btn.primary[disabled] { opacity: .55; cursor: default; }\n.btn.ghost { color: var(--cl-ink); }\n.btn.ghost:hover { background: var(--cl-bisque); }\n.btn .kbd { font-weight: 500; opacity: .75; font-size: 11px; }\n.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }\n@keyframes spin { to { transform: rotate(360deg); } }\n\n.composer { width: 340px; padding: 12px; }\n.composer .target { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--cl-ash); font-size: 12px; min-width: 0; }\n.composer .target .badge { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: var(--cl-radius-pill); color: var(--cl-cobalt); background: var(--cl-cobalt-soft); font-weight: 600; }\n.composer .target .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.composer textarea {\n width: 100%; min-height: 64px; max-height: 160px; resize: none;\n font: 14px/20px var(--cl-font-ui); color: var(--cl-ink);\n padding: 10px 12px; border-radius: var(--cl-radius-md);\n border: 1px solid var(--cl-slip-strong); background: var(--cl-paper);\n transition: border-color var(--cl-fast), box-shadow var(--cl-fast);\n}\n.composer textarea::placeholder { color: var(--cl-ash); }\n.composer textarea:focus { outline: none; border-color: var(--cl-cobalt); box-shadow: 0 0 0 3px color-mix(in oklab, var(--cl-cobalt) 20%, transparent); }\n.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }\n.suggestion {\n height: 26px; padding: 0 10px; border-radius: var(--cl-radius-pill);\n border: 1px solid var(--cl-slip); color: var(--cl-ink); font-size: 12px;\n transition: background var(--cl-fast), border-color var(--cl-fast);\n}\n.suggestion:hover { background: var(--cl-bisque); border-color: var(--cl-slip-strong); }\n.actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; }\n.actions .left { margin-right: auto; color: var(--cl-ash); font-size: 11.5px; }\n\n.notice { width: 300px; padding: 14px; }\n.notice h3 { margin: 0 0 4px; font: 600 14px/19px var(--cl-font-ui); }\n.notice p { margin: 0; color: var(--cl-ash); font-size: 12.5px; line-height: 18px; }\n\n/* \\u2500\\u2500 Errors \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n/* The app can\'t show anything: a quiet sheet over the page, and the story in plain words. */\n.error.screen {\n pointer-events: auto;\n position: fixed; inset: 0;\n display: grid; place-items: center;\n padding: 32px 24px 112px;\n overflow: auto;\n background: color-mix(in oklab, var(--cl-paper) 94%, transparent);\n -webkit-backdrop-filter: blur(12px) saturate(1.2);\n backdrop-filter: blur(12px) saturate(1.2);\n animation: sheet var(--cl-base) var(--cl-ease-out) both;\n}\n@keyframes sheet { from { opacity: 0; } }\n.error.screen .error-body { width: min(440px, 100%); animation: rise var(--cl-slow) var(--cl-ease-out) both; }\n/* Something broke, but the page still works: a small note above the dock. */\n.error.note {\n pointer-events: auto;\n width: min(400px, calc(100vw - 24px));\n padding: 14px 14px 14px 16px;\n background: var(--cl-paper); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n}\n.error.still, .error.still .error-body { animation: none; }\n.error .head { display: flex; align-items: center; gap: 10px; }\n.error .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cl-oxide); }\n.error .spinner { flex: none; width: 12px; height: 12px; margin: 0 -2px; border-width: 1.75px; color: var(--cl-clay); }\n.error h3 { flex: 1; margin: 0; font: 600 14px/20px var(--cl-font-ui); letter-spacing: -0.01em; }\n.error .close {\n flex: none; width: 28px; height: 28px; margin: -4px -6px -4px 0; border-radius: 50%;\n display: grid; place-items: center; color: var(--cl-ash);\n transition: background var(--cl-fast), color var(--cl-fast);\n}\n.error .close:hover { background: var(--cl-bisque); color: var(--cl-ink); }\n.error .why { margin: 4px 0 0 18px; color: var(--cl-ash); font-size: 13px; line-height: 19px; text-wrap: balance; }\n.error .why strong { color: var(--cl-ink); font-weight: 600; }\n.error .actions { justify-content: flex-start; gap: 4px; margin: 12px 0 0 18px; }\n.error .more { padding: 0 8px 0 12px; gap: 4px; color: var(--cl-ash); }\n.error .more:hover { color: var(--cl-ink); }\n.error .more .ic { transition: transform var(--cl-base) var(--cl-ease-out); }\n.error .more[aria-expanded="true"] .ic { transform: rotate(180deg); }\n.error .details {\n margin: 14px 0 0 18px; padding: 10px 12px; max-height: 220px; overflow: auto;\n background: var(--cl-bisque); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-md);\n font: 11.5px/17px var(--cl-font-mono); color: var(--cl-ink); user-select: text;\n}\n.error .details[hidden] { display: none; }\n.error .details p { margin: 0; word-break: break-word; }\n.error .details .where { color: var(--cl-ash); }\n.error .details .frame { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--cl-slip); font: inherit; color: var(--cl-ash); white-space: pre; overflow-x: auto; }\n.error.screen h3 { font-size: 22px; line-height: 28px; letter-spacing: -0.02em; }\n.error.screen .close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; margin: 0; }\n.error.screen .why { margin-top: 6px; font-size: 14.5px; line-height: 22px; }\n.error.screen .actions { margin-top: 20px; }\n.error.screen .btn { height: 34px; font-size: 13px; }\n.error.screen .btn.primary { padding: 0 16px; }\n\n/* \\u2500\\u2500 Toasts \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }\n.toast {\n pointer-events: auto;\n display: inline-flex; align-items: center; gap: 8px;\n height: 34px; padding: 0 14px 0 10px;\n background: var(--cl-ink); color: var(--cl-paper);\n border-radius: var(--cl-radius-pill);\n font-size: 12.5px; font-weight: 500;\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-base) var(--cl-ease-out) both;\n}\n.toast .ic { color: var(--cl-celadon); }\n.toast.warn .ic { color: var(--cl-ochre); }\n.toast.leaving { animation: leave var(--cl-base) var(--cl-ease-in-out) forwards; }\n@keyframes leave { to { opacity: 0; transform: translateY(6px); } }\n\n/* \\u2500\\u2500 Device bar (frame page) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.devicebar { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); pointer-events: auto; }\n.devicebar .size { padding: 0 6px 0 12px; color: var(--cl-ash); font: 500 12px/18px var(--cl-font-ui); font-variant-numeric: tabular-nums; white-space: nowrap; }\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }\n}\n`;var me="clodable:toolbar",He=new RegExp(`[?&]${C}=1`),M={dynamic:"This text is filled in automatically, from your data or a list in your code, so it can\'t be typed over here.",notFound:"The page changed while you were editing. Try once more.",ambiguous:"That exact text appears twice here, so Claude should change it."},O=class{constructor(e){this.surface=e;let t=new URLSearchParams(location.search);this.device=e==="outer"?t.get("device")??"phone":"desktop";try{this.minimized=JSON.parse(localStorage.getItem(me)??"{}").minimized===!0}catch{this.minimized=!1}}surface;host;shadow;layer;dockWrap;hintSlot;errorSlot;dockSlot;toasts=new R;hover;active;popover;mode="idle";minimized=!1;editing;device;mount(){this.host=document.createElement("clodable-toolbar"),this.host.setAttribute("data-clodable",""),this.shadow=this.host.attachShadow({mode:"open"}),this.shadow.append(a("style",{},ge)),this.layer=a("div"),this.hintSlot=a("div"),this.errorSlot=a("div"),this.dockSlot=a("div"),this.dockWrap=a("div",{class:"dock-wrap"},this.toasts.el,this.errorSlot,this.hintSlot,this.dockSlot),this.shadow.append(this.layer,this.dockWrap),this.hover=new S(this.layer),this.active=new S(this.layer),document.body.append(this.host),new MutationObserver(()=>{this.host.isConnected||document.body.append(this.host)}).observe(document.body,{childList:!0}),this.render(),this.surface!=="outer"&&(new L(this.layer,this.errorSlot,(e,t)=>this.toasts.show(e,t?{tone:t}:{})).start(),this.listen()),this.surface==="inner"&&this.reportRoutes(),this.surface==="outer"&&this.followRoutes()}render(){let e=this.shadow.activeElement?.dataset.key;if(this.draw(),!e)return;let t=o=>this.shadow.querySelector(`[data-key="${o}"]`);(t(e)??t("pebble")??t("hide"))?.focus()}draw(){this.surface==="outer"?this.drawDeviceBar():this.minimized?this.drawPebble():this.drawDock()}drawDeviceBar(){this.dockSlot.replaceChildren();let e=new URLSearchParams(location.search),{width:t,height:o}=ee[this.device==="tablet"?"tablet":"phone"],r=e.get("landscape")==="1"?`${o} \\xD7 ${t}`:`${t} \\xD7 ${o}`,n=a("div",{class:"dock",role:"toolbar","aria-label":"Device preview"},this.deviceSwitch(),a("span",{class:"size","aria-label":`Screen size ${r}`},r),a("span",{class:"sep","aria-hidden":"true"}),a("button",{class:"icon-btn","aria-label":"Rotate",title:"Rotate",onclick:()=>this.rotate()},g("refresh")));be(n,this.shadow),this.layer.replaceChildren(this.hover.box,this.hover.chip,this.active.box,this.active.chip,a("div",{class:"devicebar"},n))}drawPebble(){this.hintSlot.replaceChildren(),this.dockSlot.replaceChildren(a("button",{class:"pebble","data-key":"pebble","aria-label":"Show Clodable tools",title:"Show Clodable tools (\\u2325\\u21E7H)",onclick:()=>this.setMinimized(!1)},this.mark(24)))}drawDock(){let e=(n,s,l,p)=>a("button",{class:"tool","data-key":n,"aria-pressed":String(this.mode===n),title:`${l} (${p})`,onclick:()=>this.setMode(this.mode===n?"idle":n)},g(s),a("span",{class:"label"},l)),t=a("button",{class:"brand","data-key":"menu","aria-label":"Clodable menu","aria-haspopup":"menu","aria-expanded":"false",onclick:n=>this.toggleMenu(n.currentTarget)},this.mark(24)),o=F()?.backend==="copy",r=a("div",{class:"dock",role:"toolbar","aria-label":"Clodable preview tools"},t,...o?[a("span",{class:"backend",title:"This preview uses your new backend, a copy of your data. Your live app is untouched."},"Copy")]:[],a("span",{class:"sep","aria-hidden":"true"}),e("edit","text","Edit text","\\u2325\\u21E7E"),e("ask","select","Point & ask","\\u2325\\u21E7A"),...this.surface==="app"?[a("span",{class:"sep","aria-hidden":"true"}),this.deviceSwitch()]:[],a("span",{class:"sep","aria-hidden":"true"}),a("button",{class:"icon-btn","data-key":"hide","aria-label":"Hide Clodable tools",title:"Hide (\\u2325\\u21E7H)",onclick:()=>this.setMinimized(!0)},g("minimize")));be(r,this.shadow),this.dockSlot.replaceChildren(r),this.renderHint()}mark(e){let t=a("span",{"aria-hidden":"true",style:"display:grid"});return t.innerHTML=j({size:e}),t}deviceSwitch(){let e=[["desktop","desktop","Full width"],["tablet","tablet","Tablet"],["phone","phone","Phone"]],t=e.findIndex(([o])=>o===this.device);return a("div",{class:"devices",role:"radiogroup","aria-label":"Preview size"},a("span",{class:"thumb","aria-hidden":"true",style:`transform: translateX(${t*100}%)`}),...e.map(([o,r,n])=>a("button",{role:"radio","aria-checked":String(this.device===o),"aria-label":n,title:n,onclick:()=>this.setDevice(o)},g(r))))}renderHint(){if(this.mode==="idle"||this.minimized){this.hintSlot.replaceChildren();return}let e=this.mode==="edit"?"Click any text to change it":"Click anything to ask Claude about it";this.hintSlot.replaceChildren(a("div",{class:`hint ${this.mode==="ask"?"ask":""}`,role:"status"},a("span",{class:"dot"}),e,a("kbd",{},"Esc")))}setMode(e){this.editing&&this.finishEdit(!1),this.closePopover(),this.mode=e,this.hover.hide(),document.documentElement.style.cursor="",this.render()}setMinimized(e){this.minimized=e;try{localStorage.setItem(me,JSON.stringify({minimized:e}))}catch{}e?this.setMode("idle"):this.render()}setDevice(e){let t=this.surface==="outer"?new URLSearchParams(location.search).get("path")??"/":location.pathname+location.search;if(e==="desktop"){this.surface==="outer"&&(location.href=t);return}let o=`${u.frame}?device=${e}&path=${encodeURIComponent(t)}`;location.href=o}rotate(){let e=new URLSearchParams(location.search);e.set("landscape",e.get("landscape")==="1"?"0":"1"),location.search=e.toString()}isOurs(e){return e instanceof Node&&(e===this.host||this.host.contains(e)||this.shadow.contains(e))}listen(){let e=0;addEventListener("pointermove",t=>{this.mode==="idle"||this.editing||this.popover||(cancelAnimationFrame(e),e=requestAnimationFrame(()=>this.onHover(t.clientX,t.clientY,t.target)))},{capture:!0,passive:!0});for(let t of["pointerdown","mousedown","pointerup","mouseup","click","dblclick","submit"])addEventListener(t,o=>this.onPointer(o),{capture:!0});addEventListener("keydown",t=>this.onKey(t),{capture:!0}),addEventListener("scroll",()=>this.closePopoverIfDetached(),{capture:!0,passive:!0})}onPointer(e){if(!(this.mode==="idle"||this.isOurs(e.target))&&!(this.editing&&e.target instanceof Node&&this.editing.editable.contains(e.target))&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type==="click")){if(this.editing){this.finishEdit(!0);return}if(this.popover){this.closePopover();return}this.mode==="edit"?this.startEdit(e.clientX,e.clientY):this.mode==="ask"&&this.openComposer(e.clientX,e.clientY)}}onHover(e,t,o){if(this.popover||this.editing||this.mode==="idle")return;if(this.isOurs(o)){this.hover.hide();return}if(this.mode==="edit"){let s=fe(e,t,this.host),l=s&&y(s.el);s&&l?(this.hover.show(s.el,"edit-hover",{icon:"text",strong:"Edit text"}),document.documentElement.style.cursor="text"):(this.hover.hide(),document.documentElement.style.cursor="");return}let r=Z(e,t,this.host),n=r&&y(r);if(r&&n){let s=A(r,32);this.hover.show(r,"ask-hover",{strong:E(r),...s?{muted:`\\xB7 ${s}`}:{}}),document.documentElement.style.cursor="pointer"}else this.hover.hide(),document.documentElement.style.cursor=""}onKey(e){let t=Fe(e.target)&&!this.isOurs(e.target);if(e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey){let r={KeyE:()=>this.setMode(this.mode==="edit"?"idle":"edit"),KeyA:()=>this.setMode(this.mode==="ask"?"idle":"ask"),KeyH:()=>this.setMinimized(!this.minimized)}[e.code];if(r&&!(t&&!this.editing)){e.preventDefault(),e.stopPropagation(),r();return}}e.key==="Escape"&&(this.editing?(e.preventDefault(),e.stopPropagation(),this.finishEdit(!1)):this.popover?(e.preventDefault(),this.closePopover()):this.mode!=="idle"&&(e.preventDefault(),this.setMode("idle")))}async startEdit(e,t){let o=fe(e,t,this.host),r=o&&y(o.el);if(!o||!r)return;let n=o.node.textContent??"",s;try{s=await m.probe(r.src,n)}catch{this.toasts.show("Couldn\'t reach Clodable. Is the preview still running?",{tone:"warn"});return}if(!s.editable){this.showLocked(o.el,n,s.reason);return}this.hover.hide();let{editable:l,restore:p}=ze(o.el,o.node),h=a("div",{class:"pop editbar",role:"group","aria-label":"Editing text"},a("span",{class:"note"},"Editing text"),a("button",{class:"btn ghost",onclick:()=>this.finishEdit(!1)},"Cancel"),a("button",{class:"btn primary",onclick:()=>this.finishEdit(!0)},"Save",a("span",{class:"kbd"},"\\u23CE")));this.layer.append(h),this.editing={el:o.el,restore:p,editable:l,node:o.node,src:r.src,before:n,bar:h,saving:!1},this.active.show(l,"editing",void 0,{perLine:l!==o.el}),l.addEventListener("keydown",this.onEditKey),l.addEventListener("focusout",this.onEditBlur),l.focus({preventScroll:!0}),_e(e,t,l);let c=()=>{this.editing&&(J(h,this.editing.el.getBoundingClientRect(),12),requestAnimationFrame(c))};c()}onEditKey=e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.finishEdit(!0))};onEditBlur=e=>{this.isOurs(e.relatedTarget)||setTimeout(()=>{this.editing&&!this.editing.saving&&document.activeElement!==this.editing.editable&&this.finishEdit(!0)},0)};async finishEdit(e){let t=this.editing;if(!t||t.saving)return;let o=(t.editable.textContent??"").replace(/\\s+/g," ").trim(),r=e&&o&&o!==t.before.replace(/\\s+/g," ").trim();if(t.editable.removeEventListener("keydown",this.onEditKey),t.editable.removeEventListener("focusout",this.onEditBlur),!r){t.restore(),t.node.textContent=t.before,this.endEdit();return}t.saving=!0,t.bar.replaceChildren(a("span",{class:"note"},a("span",{class:"spinner",style:"display:inline-block;vertical-align:-3px;margin-right:8px"}),"Saving\\u2026"));try{let n=await m.edit(t.src,t.before,o);if(t.restore(),n.ok)t.node.textContent=Ne(t.before,o),this.active.fadeOut(t.el,"saved"),this.toasts.show("Text updated \\xB7 saved to your draft");else{t.node.textContent=t.before,this.active.hide();let{reason:s}=n;this.toasts.show(s==="dynamic"?M.dynamic:s==="ambiguous"?M.ambiguous:M.notFound,{tone:"warn",ms:4200})}}catch{t.restore(),t.node.textContent=t.before,this.toasts.show("Couldn\'t save that change. Try again.",{tone:"warn"})}this.endEdit(!1)}endEdit(e=!0){this.editing?.bar.remove(),this.editing=void 0,e&&this.active.hide()}showLocked(e,t,o){this.closePopover(),this.hover.show(e,"locked",{icon:"info",strong:"Not editable here"});let r=a("button",{class:"btn primary",onclick:()=>this.openComposerFor(e,`Change \\u201C${De(t)}\\u201D to `)},"Ask Claude"),n=a("div",{class:"pop notice",role:"dialog","aria-label":"This text can\'t be edited here"},a("h3",{},"Claude can change this one for you"),a("p",{},o==="ambiguous"?M.ambiguous:M.dynamic),a("div",{class:"actions"},a("button",{class:"btn ghost",onclick:()=>this.closePopover()},"Close"),r));this.openPopover(n,e.getBoundingClientRect()),r.focus({preventScroll:!0})}openComposer(e,t){let o=Z(e,t,this.host);o&&y(o)&&this.openComposerFor(o)}openComposerFor(e,t=""){this.closePopover();let o=y(e);this.hover.show(e,"ask-hover");let r=G(e),n=a("textarea",{rows:"3",placeholder:"What should change? For example: make it bigger and bolder","aria-label":"What should change?"});n.value=t;let s=a("button",{class:"btn primary",onclick:()=>l()},"Send to Claude"),l=async()=>{let c=n.value.trim();if(!c){n.focus();return}s.setAttribute("disabled","");try{let xe=o?Q(o.src):void 0;await m.ask(c,he(e),xe),this.closePopover(),this.setMode("idle"),this.toasts.show("Sent to Claude")}catch{s.removeAttribute("disabled"),this.toasts.show("Couldn\'t reach Claude. Is Clodable running?",{tone:"warn"})}};n.addEventListener("keydown",c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),l())});let p=A(e,48),h=a("div",{class:"pop composer",role:"dialog","aria-label":`Ask Claude about this ${E(e).toLowerCase()}`},a("div",{class:"target"},a("span",{class:"badge"},g("select",14),E(e)),p?a("span",{class:"what"},`\\u201C${p}\\u201D`):null),n,a("div",{class:"suggestions"},...ue[r].map(c=>a("button",{class:"suggestion",onclick:()=>{n.value=c,n.focus()}},c))),a("div",{class:"actions"},a("span",{class:"left"},"\\u23CE to send"),a("button",{class:"btn ghost",onclick:()=>this.closePopover()},"Cancel"),s));this.openPopover(h,e.getBoundingClientRect()),n.focus({preventScroll:!0}),n.setSelectionRange(n.value.length,n.value.length)}openPopover(e,t){this.closePopover(!1),this.popover=e,this.layer.append(e),J(e,t)}closePopover(e=!0){let t=this.popover?.classList.contains("menu")&&this.popover.contains(this.shadow.activeElement);this.popover?.remove(),this.popover=void 0,e&&this.hover.hide();let o=this.shadow?.querySelector(\'.brand[aria-expanded="true"]\');o?.setAttribute("aria-expanded","false"),t&&o?.focus()}closePopoverIfDetached(){this.popover?.classList.contains("menu")||this.popover&&!this.editing&&this.closePopover()}toggleMenu(e){if(this.popover?.classList.contains("menu")){this.closePopover();return}let t=(n,s,l,p)=>a("button",{class:"menu-item",role:"menuitem",onclick:()=>{this.closePopover(),p()}},g(n),s,a("span",{class:"shortcut"},l)),o=a("div",{class:"menu",role:"menu","aria-label":"Clodable"},a("div",{class:"head"},this.mark(28),a("div",{},a("b",{},"Clodable"),a("span",{},"Only you see these tools. Visitors never do."))),a("hr"),t("text","Edit text","\\u2325\\u21E7E",()=>this.setMode("edit")),t("select","Point & ask Claude","\\u2325\\u21E7A",()=>this.setMode("ask")),...this.surface==="app"?[t("phone","Phone preview","",()=>this.setDevice("phone"))]:[],a("hr"),t("minimize","Hide these tools","\\u2325\\u21E7H",()=>this.setMinimized(!0)));ve(o,this.shadow,"ArrowUp","ArrowDown"),this.popover=o,this.layer.append(o),e.setAttribute("aria-expanded","true");let r=e.getBoundingClientRect();o.style.left=`${Math.max(8,r.left-6)}px`,o.style.top=`${r.top-o.getBoundingClientRect().height-10}px`,o.querySelector(".menu-item")?.focus()}reportRoutes(){let e=()=>parent.postMessage({type:"clodable:route",path:location.pathname+location.search.replace(He,"")},location.origin);for(let t of["pushState","replaceState"]){let o=history[t].bind(history);history[t]=((...r)=>{o(...r),e()})}addEventListener("popstate",e)}followRoutes(){addEventListener("message",e=>{if(e.origin!==location.origin||e.data?.type!=="clodable:route")return;let t=new URLSearchParams(location.search);t.set("path",e.data.path||"/"),history.replaceState(null,"",`${location.pathname}?${t.toString()}`)})}};function be(i,e){ve(i,e,"ArrowLeft","ArrowRight");let t=Array.from(i.querySelectorAll("button"));for(let[o,r]of t.entries())r.tabIndex=o===0?0:-1,r.addEventListener("focus",()=>{for(let n of t)n.tabIndex=-1;r.tabIndex=0})}function ve(i,e,t,o){i.addEventListener("keydown",r=>{let n=Array.from(i.querySelectorAll("button")),s=n.indexOf(e.activeElement);if(s<0)return;let p={[t]:s-1,[o]:s+1,Home:0,End:n.length-1}[r.key];p!==void 0&&(r.preventDefault(),n[(p+n.length)%n.length]?.focus())})}var De=i=>{let e=i.replace(/\\s+/g," ").trim();return e.length>60?`${e.slice(0,59)}\\u2026`:e};function Ne(i,e){let t=i.match(/^\\s*/)?.[0]??"",o=i.match(/\\s*$/)?.[0]??"";return`${t}${e}${o}`}function Fe(i){return i instanceof HTMLElement&&(i.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(i.tagName))}function Z(i,e,t){let o=document.elementFromPoint(i,e);if(!(!o||o===t||o===document.documentElement||o===document.body))return o}function fe(i,e,t){let o=document,r=null,n=document.caretPositionFromPoint?.(i,e);if(n?r=n.offsetNode:r=o.caretRangeFromPoint?.(i,e)?.startContainer??null,r&&r.nodeType===Node.TEXT_NODE&&r.textContent?.trim()&&r.parentElement&&!t.contains(r)){let p=document.createRange();if(p.selectNodeContents(r),Array.from(p.getClientRects()).some(c=>i>=c.left-3&&i<=c.right+3&&e>=c.top-3&&e<=c.bottom+3))return{el:r.parentElement,node:r}}let s=Z(i,e,t);if(!s)return;let l=Array.from(s.childNodes).find(p=>p.nodeType===Node.TEXT_NODE&&!!p.textContent?.trim());return l&&s instanceof HTMLElement?{el:s,node:l}:void 0}function ze(i,e){let t=Array.from(i.childNodes).filter(r=>!(r.nodeType===Node.TEXT_NODE&&!r.textContent?.trim()));if(t.length===1&&t[0]===e){let r=i.getAttribute("contenteditable"),n=Array.from(i.childNodes);return i.setAttribute("contenteditable","plaintext-only"),i.setAttribute("spellcheck","true"),{editable:i,restore:()=>{r===null?i.removeAttribute("contenteditable"):i.setAttribute("contenteditable",r),i.removeAttribute("spellcheck"),i.replaceChildren(...n)}}}let o=document.createElement("span");return o.setAttribute("contenteditable","plaintext-only"),o.setAttribute("data-clodable-editing",""),o.style.outline="none",e.replaceWith(o),o.textContent=e.textContent,{editable:o,restore:()=>{o.replaceWith(e)}}}function _e(i,e,t){let o=getSelection();if(!o)return;let r=document,n=document.caretPositionFromPoint?.(i,e),s=document.createRange();if(n&&t.contains(n.offsetNode))s.setStart(n.offsetNode,n.offset);else{let l=r.caretRangeFromPoint?.(i,e);l&&t.contains(l.startContainer)?s.setStart(l.startContainer,l.startOffset):s.selectNodeContents(t)}s.collapse(!0),o.removeAllRanges(),o.addRange(s)}function Be(){if(window.__CLODABLE_MOUNTED__)return;Object.defineProperty(window,"__CLODABLE_MOUNTED__",{value:!0}),oe(),pe();let i=location.pathname===u.frame?"outer":new URLSearchParams(location.search).has(C)?"inner":"app",e=()=>setTimeout(()=>new O(i).mount(),0);document.readyState==="complete"?e():addEventListener("load",e,{once:!0})}Be();})();\n';
|
|
48143
|
+
if (true) return '"use strict";(()=>{var H="data-cl-src";function Q(o){let e=o.match(/^(.+):(\\d+):(\\d+)$/);if(e)return{file:e[1],line:Number(e[2]),column:Number(e[3])}}var b="/__clodable/",u={toolbar:`${b}toolbar.js`,health:`${b}health`,frame:`${b}frame`,probe:`${b}text/probe`,text:`${b}text`,inbox:`${b}inbox`,originalLine:`${b}original-line`,buildError:`${b}build-error`},M="__clodable_frame",ee={phone:{width:390,height:844},tablet:{width:820,height:1180}};function D(o,e,t){return{message:o.trim().split(`\n`)[0].slice(0,300),stack:e.slice(0,4e3),kind:"build",...t?{source:t}:{}}}var $=()=>typeof __CLODABLE__>"u"?void 0:__CLODABLE__,ye=()=>$()?.token??"",te;function ie(){te=window.fetch.bind(window)}async function x(o,e){let t=await(te??fetch)(o,{method:"POST",headers:{"content-type":"application/json","x-clodable-token":ye()},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Clodable ${o}: ${t.status}`);return await t.json()}var N=()=>{try{let o=sessionStorage.getItem("clodable:conversation");return o?{conversation:o}:{}}catch{return{}}},F=()=>({url:location.href,path:location.pathname+location.search,title:document.title}),m={probe:(o,e)=>x(u.probe,{src:o,text:e}),edit:(o,e,t)=>x(u.text,{src:o,before:e,after:t,page:F(),...N()}),ask:(o,e,t)=>x(u.inbox,{kind:"ask",page:F(),request:o,element:e,...t?{source:t}:{},...N()}),fix:(o,e)=>x(u.inbox,{kind:"fix",page:F(),error:o,console:e,...N()}),originalLine:o=>x(u.originalLine,o).then(e=>e.line),buildError:o=>x(u.buildError,{since:o}).then(e=>e.error)};var z={light:{paper:"#FBF8F3",bisque:"#F4EEE6",slip:"#E7DED2",slipStrong:"#D3C6B6",ink:"#1F1A16",ash:"#6B6158",clay:"#B9502B",clayHover:"#A44322",clayText:"#A2441F",onClay:"#FFFFFF",claySoft:"#F7E4DA",celadon:"#2B7354",celadonSoft:"#E1F0E8",cobalt:"#2D5BA6",cobaltSoft:"#E3EBF7",ochre:"#8F6210",ochreSoft:"#F7ECD4",oxide:"#B1281E",oxideSoft:"#F9E1DE",focus:"#2D5BA6",scrim:"rgba(31, 26, 22, 0.32)"},dark:{paper:"#15110E",bisque:"#1E1915",slip:"#352D27",slipStrong:"#4A4038",ink:"#F3EEE7",ash:"#A79D92",clay:"#E5764F",clayHover:"#EE8A66",clayText:"#F08F6B",onClay:"#1F1A16",claySoft:"#3A2419",celadon:"#6CC59E",celadonSoft:"#16342A",cobalt:"#8AB0F0",cobaltSoft:"#18263D",ochre:"#E6B356",ochreSoft:"#3A2C12",oxide:"#F27B70",oxideSoft:"#3E1A17",focus:"#8AB0F0",scrim:"rgba(0, 0, 0, 0.5)"}};var _={sm:"6px",md:"10px",lg:"14px",xl:"20px",pill:"999px"},w={ui:\'ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif\',mono:\'ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace\',display:\'"Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif\'};var I={light:{sm:"0 1px 2px rgba(60, 38, 20, 0.08)",md:"0 1px 2px rgba(60, 38, 20, 0.06), 0 6px 16px -4px rgba(60, 38, 20, 0.14)",lg:"0 2px 4px rgba(60, 38, 20, 0.06), 0 18px 40px -12px rgba(60, 38, 20, 0.28)"},dark:{sm:"0 1px 2px rgba(0, 0, 0, 0.4)",md:"0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px -4px rgba(0, 0, 0, 0.5)",lg:"0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 40px -12px rgba(0, 0, 0, 0.7)"}},f={fast:"120ms",base:"180ms",slow:"260ms",easeOut:"cubic-bezier(0.2, 0.8, 0.2, 1)",easeInOut:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.4, 0.64, 1)"},B={toolbar:2147483e3,toast:2147483100,overlay:2147483200};var we=o=>o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);function k(o){let e=Object.entries(z[o]).map(([i,r])=>`--cl-${we(i)}: ${r};`).join(" "),t=Object.entries(I[o]).map(([i,r])=>`--cl-shadow-${i}: ${r};`).join(" ");return`${e} ${t} color-scheme: ${o};`}var oe=[...Object.entries(_).map(([o,e])=>`--cl-radius-${o}: ${e};`),`--cl-font-ui: ${w.ui};`,`--cl-font-mono: ${w.mono};`,`--cl-font-display: ${w.display};`,`--cl-fast: ${f.fast};`,`--cl-base: ${f.base};`,`--cl-slow: ${f.slow};`,`--cl-ease-out: ${f.easeOut};`,`--cl-ease-in-out: ${f.easeInOut};`,`--cl-spring: ${f.spring};`].join(" ");function K(o={}){let e=o.selector??":root",t=o.scheme??"auto";if(t!=="auto")return`${e} { ${oe} ${k(t)} }`;let i=r=>e===":host"?`:host([data-theme="${r}"]) { ${k(r)} }`:`${e}[data-theme="${r}"] { ${k(r)} }`;return[`${e} { ${oe} ${k("light")} }`,`@media (prefers-color-scheme: dark) { ${e} { ${k("dark")} } }`,i("light"),i("dark")].join(`\n`)}var d=(...o)=>o,ne={check:d("M4.5 10.5l3.5 3.5 7.5-8"),close:d("M5.5 5.5l9 9M14.5 5.5l-9 9"),publish:d("M10 13.5v-7","M7 9.5l3-3 3 3",{circle:[10,10,7]}),undo:d("M7.5 5.5 4 9l3.5 3.5","M4.5 9h7.25a3.75 3.75 0 0 1 0 7.5H10"),restore:d("M3.5 10a6.5 6.5 0 1 0 1.9-4.6","M3.5 3.5v3h3","M10 6.75V10l2.5 1.5"),external:d("M8.5 5.5h-3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-3","M11.5 4.5h4v4","M15.5 4.5 9.5 10.5"),phone:d("M8 2.5h4a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2z","M9 15h2"),tablet:d("M6 3h8a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z","M9 14.5h2"),desktop:d("M3.5 4.5h13a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1z","M7.5 17.5h5","M10 14.5v3"),text:d("M3.5 6V4.5h9V6","M8 4.5v11","M6 15.5h4","M15 8.5v8","M13.5 8.5h3","M13.5 16.5h3"),select:d("M4.5 3.5l10.5 4.6-4.4 1.6-1.6 4.4z","M10.6 9.7l4.4 4.4"),minimize:d("M5 10h10"),alert:d("M10 3.8 17.2 16.2H2.8z","M10 8.5v3.5","M10 14.25v.01"),info:d({circle:[10,10,7]},"M10 9.25v4.5","M10 6.5v.01"),globe:d({circle:[10,10,7]},"M3 10h14","M10 3c1.9 2 2.9 4.4 2.9 7s-1 5-2.9 7c-1.9-2-2.9-4.4-2.9-7s1-5 2.9-7z"),database:d("M4 5.5C4 4.1 6.7 3 10 3s6 1.1 6 2.5S13.3 8 10 8 4 6.9 4 5.5z","M4 5.5v9C4 15.9 6.7 17 10 17s6-1.1 6-2.5v-9","M4 10c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5"),refresh:d("M15.5 8a6 6 0 0 0-10.4-1.6L4 8","M4 4.5V8h3.5","M4.5 12a6 6 0 0 0 10.4 1.6L16 12","M16 15.5V12h-3.5"),grip:d({circle:[7.5,6,1.1],fill:!0},{circle:[12.5,6,1.1],fill:!0},{circle:[7.5,10,1.1],fill:!0},{circle:[12.5,10,1.1],fill:!0},{circle:[7.5,14,1.1],fill:!0},{circle:[12.5,14,1.1],fill:!0}),more:d({circle:[5,10,1.25],fill:!0},{circle:[10,10,1.25],fill:!0},{circle:[15,10,1.25],fill:!0}),chevronDown:d("M6 8l4 4 4-4"),chevronUp:d("M6 12l4-4 4 4"),arrowRight:d("M4.5 10h11","M11 5.5l4.5 4.5-4.5 4.5"),copy:d("M7.5 7.5h7a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1z","M4.5 12.5h-.25a.75.75 0 0 1-.75-.75v-7.5a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 .75.75v.25")},re=o=>o.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");function q(o,e={}){let t=e.size??20,i=e.strokeWidth??1.6,r=e.label?`role="img" aria-label="${re(e.label)}"`:\'aria-hidden="true" focusable="false"\',n=e.className?` class="${re(e.className)}"`:"",s=ne[o].map(l=>{if(typeof l=="string")return`<path d="${l}"/>`;let[p,h,c]=l.circle;return l.fill?`<circle cx="${p}" cy="${h}" r="${c}" fill="currentColor" stroke="none"/>`:`<circle cx="${p}" cy="${h}" r="${c}"/>`}).join("");return`<svg${n} xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="${i}" stroke-linecap="round" stroke-linejoin="round" ${r}>${s}</svg>`}var ae=[".........ooo....",".......oobbbo...","......obbbbbo...","....oobbbbbbo...","...obbbbbbbbbo..","..obbbbbbbbbbbo.",".obbbbbbbbbbbbo.",".obbeebbbbeebbo.","obbbeebbbbeebbbo","obbbbbbeebbbbbbo","obbbbbbbbbbbbbbo","oobbbbbbbbbbbbbo","..obbbbbbbbbbbo.","..oobbbooobbboo.","....obo...obo...","....ooo...ooo..."],se={outline:"#3B1A10",clay:"#E88858",eyes:"#2A140C"};function ke(o){let e={o:o.outline,b:o.clay,e:o.eyes},t={};return ae.forEach((i,r)=>{for(let n=0;n<i.length;){let s=i[n],l=1;for(;i[n+l]===s;)l++;e[s]&&(t[s]=`${t[s]??""}M${n} ${r}h${l}v1h-${l}z`),n+=l}}),Object.entries(t).map(([i,r])=>`<path fill="${e[i]}" d="${r}"/>`).join("")}function j(o={}){let e=o.size??32,t=o.label?`role="img" aria-label="${o.label.replace(/"/g,""")}"`:\'aria-hidden="true" focusable="false"\';return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 16 16" shape-rendering="crispEdges" ${t}>${ke({...se,...o.colors})}</svg>`}function a(o,e={},...t){let i=document.createElement(o);for(let[r,n]of Object.entries(e))n==null||n===!1||(r==="class"?i.className=String(n):r==="style"?typeof n=="string"?i.setAttribute("style",n):Object.assign(i.style,n):r==="dataset"?Object.assign(i.dataset,n):r.startsWith("on")&&typeof n=="function"?i.addEventListener(r.slice(2).toLowerCase(),n):n===!0?i.setAttribute(r,""):i.setAttribute(r,String(n)));return Ee(i,t),i}function Ee(o,e){for(let t of e)t==null||t===!1||o.appendChild(typeof t=="object"?t:document.createTextNode(String(t)))}function g(o,e=18){let t=document.createElement("span");return t.className="ic",t.innerHTML=q(o,{size:e,strokeWidth:e<=16?1.7:1.6}),t}var L=[],le=[],X;function U(o){X?X(o):le.push(o)}var ce="Part of the app didn\'t load",de=new RegExp(`^${ce}$|Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed`,"i"),Y="clodable:fixing";function Se(){try{return Date.now()-Number(sessionStorage.getItem(Y)??0)<12e4}catch{return!1}}function T(o){try{o?sessionStorage.setItem(Y,String(Date.now())):sessionStorage.removeItem(Y)}catch{}}function pe(){addEventListener("error",e=>{let t=e.target;!(t instanceof HTMLScriptElement)||t.hasAttribute("data-clodable-toolbar")||t.src&&new URL(t.src,location.href).origin!==location.origin||U({message:ce,kind:"build"})},!0),addEventListener("error",e=>{let t=e.error;U({message:t?.message??e.message,...t?.stack?{stack:t.stack}:{},kind:"runtime"})}),addEventListener("unhandledrejection",e=>{let t=e.reason,i=typeof t=="string"?t:t?.message??"A background task failed";U({message:i,...typeof t=="object"&&t?.stack?{stack:t.stack}:{},kind:"promise"})});let o=console.error.bind(console);console.error=(...e)=>{L.push(e.map(t=>t instanceof Error?t.message:String(t)).join(" ").slice(0,400)),L.length>8&&L.shift(),o(...e)}}async function Ce(){try{return(await import(`${location.origin}/@vite/client`)).createHotContext?.(u.toolbar)}catch{return}}var Me=[/ResizeObserver loop/i,/Script error\\.?$/i,/__clodable/];function $e(o){if(o)for(let e of o.split(`\n`)){let t=e.match(/https?:\\/\\/[^/]+\\/(src\\/[^?:)\\s]+)(?:\\?[^:)]*)?:(\\d+):(\\d+)/);if(t)return{file:t[1],line:Number(t[2]),column:Number(t[3])}}}function V(){return((document.getElementById("root")??document.body).innerText??"").trim().length===0}var W=o=>o.split("/").pop()??o,v=o=>a("strong",{},o);function Te(o){let e=o.source&&W(o.source.file),t=o.message.match(/Failed to resolve import "([^"]+)" from "([^"]+)"/);if(t){let r=t[1],n=t[2];if(/^(\\.|\\/|@\\/|~\\/)/.test(r)){let s=r.replace(/^(@|~)\\//,"").replace(/^(\\.\\.?\\/)+/,"");return[v(W(n))," refers to ",v(s),", a file that doesn\\u2019t exist."]}return[v(W(n))," uses ",v(r),", a package that isn\\u2019t installed."]}let i=o.message.match(/^(?:\\w*Error: )?([\\w$]+) is not defined$|Can\'t find variable: ([\\w$]+)/);if(i){let r=i[1]??i[2];return[e?v(e):"This page"," refers to ",v(r),", which doesn\\u2019t exist."]}return de.test(o.message)?["Part of the app\\u2019s code didn\\u2019t load."]:o.kind==="build"?e?[v(e),` has a mistake on line ${o.source.line}.`]:["A mistake in the code stops it from loading."]:e?["The problem starts in ",v(e),`, line ${o.source.line}.`]:["Something in the code went wrong."]}function Le(o){let e=o.source?`${o.source.file}:${o.source.line}`:"",t=[];for(let i of(o.stack??"").split(`\n`))!i.trim()||i.endsWith(o.message)||o.source&&i.endsWith(o.source.file)||t.push(i.replace(/https?:\\/\\/[^/\\s]+\\/(@fs\\/)?/g,"").replace(/\\?[^:)\\s]*(?=:\\d)/g,""));return{where:e,frame:t.slice(0,24).join(`\n`)}}function Ae(o){let e=o.err;if(!e)return;let t=e.loc?.file??e.id??"",i=t.match(/(src\\/[^?:]+)/);return D(e.message??"The app couldn\'t be built",`${t}\n${e.message??""}\n${e.stack??""}`,i?{file:i[1],line:e.loc?.line??1}:void 0)}function Re(){let o=document.querySelector("vite-error-overlay");if(!o)return;let e=o.shadowRoot?.querySelector(".message-body")?.textContent??"The app couldn\'t be built",t=o.shadowRoot?.querySelector(".file")?.textContent??"",i=t.match(/(src\\/[^:]+):(\\d+)/);return D(e,`${t}\n${e}`,i?{file:i[1],line:Number(i[2])}:void 0)}function Oe(o,e,t){return e?"Claude is fixing it\\u2026":o.kind==="build"?"Your app can\\u2019t load":t?"This page can\\u2019t load":"Something broke on this page"}var A=class{constructor(e,t,i){this.layer=e;this.dockSlot=t;this.toast=i}layer;dockSlot;toast;card;current;dismissed=new Set;detailsOpen=!1;updateStarted=0;start(){X=t=>this.capture(t);let e=le.splice(0);for(let t of e)this.capture(t);!e.length&&V()&&m.buildError(performance.timeOrigin).then(t=>{t&&!this.current&&this.show(t)},()=>{}),setTimeout(()=>{this.current||T(!1)},3e3),Ce().then(t=>{t?.on("vite:error",i=>{let r=Ae(i);r&&this.capture(r)}),t?.on("vite:beforeUpdate",()=>{this.updateStarted=Date.now()}),t?.on("vite:afterUpdate",()=>{this.afterUpdate()})}),new MutationObserver(()=>{let t=Re();t&&this.capture(t)}).observe(document.documentElement,{childList:!0})}async afterUpdate(){if(this.current){if(V()||this.current.kind==="build"){let e=await m.buildError(this.updateStarted).catch(()=>null);e?this.show(e):location.reload();return}T(!1),this.dismiss(!1)}}capture(e){if(!(!e.message||Me.some(t=>t.test(e.message)))){if(de.test(e.message)){m.buildError(performance.timeOrigin).then(t=>this.show(t??e),()=>this.show(e));return}this.show(e)}}show(e){if(this.dismissed.has(e.message))return;let t=e.source?void 0:$e(e.stack);if(t){let i=r=>this.show({...e,source:{file:t.file,line:r??t.line}});m.originalLine(t).then(i,()=>i(null));return}this.current=e,setTimeout(()=>this.render(),60)}render(e=Se()){let t=this.current;if(!t)return;let i=t.kind==="build"||V(),r=!!this.card?.isConnected,n=this.layer.getRootNode(),s=!!this.card?.contains(n.activeElement);this.card?.remove();let{more:l,details:p}=this.detailsToggle(t),h=a("button",{class:"close","aria-label":"Dismiss",onclick:()=>this.dismiss()},g("close",16)),c=a("div",{class:`error ${i?"screen":"note"}${e?" working":""}${r?" still":""}`,role:"alert","aria-labelledby":"cl-err-title","aria-describedby":"cl-err-why"},a("div",{class:"error-body"},a("div",{class:"head"},a("span",{class:e?"spinner":"dot","aria-hidden":"true"}),a("h3",{id:"cl-err-title"},Oe(t,e,i)),i?null:h),a("p",{class:"why",id:"cl-err-why"},...e?["The preview updates by itself when it\\u2019s fixed."]:Te(t)),e?null:a("div",{class:"actions"},a("button",{class:"btn primary",onclick:()=>this.fix()},"Try to fix"),l),e?null:p),i?h:null);this.card=c,i?this.layer.append(c):this.dockSlot.prepend(c),s&&(c.querySelector(".btn.primary")??h).focus()}detailsToggle(e){let{where:t,frame:i}=Le(e),r=a("div",{class:"details",id:"cl-err-details",hidden:!this.detailsOpen},t?a("p",{class:"where"},t):null,a("p",{class:"raw"},e.message),i?a("pre",{class:"frame"},i):null),n=a("span",{},this.detailsOpen?"Hide details":"Show details"),s=a("button",{class:"btn ghost more","aria-expanded":String(this.detailsOpen),"aria-controls":"cl-err-details",onclick:()=>{this.detailsOpen=!this.detailsOpen,r.hidden=!this.detailsOpen,n.textContent=this.detailsOpen?"Hide details":"Show details",s.setAttribute("aria-expanded",String(this.detailsOpen))}},n,g("chevronDown",16));return{more:s,details:r}}async fix(){let e=this.current;if(e){T(!0),this.render(!0);try{await m.fix(e,[...L])}catch{T(!1),this.toast("Couldn\'t reach Claude. Is Clodable running?","warn"),this.render(!1)}}}dismiss(e=!0){this.current&&e&&this.dismissed.add(this.current.message),this.current=void 0,this.card?.remove(),this.card=void 0}};function y(o){let e=o?.closest(`[${H}]`),t=e?.getAttribute(H);return e&&t?{el:e,src:t}:void 0}function G(o){let e=o.tagName.toLowerCase(),t=o.getAttribute("role");if(/^h[1-6]$/.test(e))return"heading";if(e==="button"||t==="button")return"button";if(e==="a"){let r=o.getAttribute("class")??"";return/\\brounded/.test(r)&&/\\b(bg-|border)/.test(r)&&/\\b(px-|h-\\d)/.test(r)?"button":"link"}if(e==="img"||e==="picture"||e==="video")return"image";if(e==="svg")return"icon";if(["input","textarea","select"].includes(e))return"input";if(["ul","ol","li","dl"].includes(e))return"list";if(e==="nav"||e==="header"||e==="footer")return"nav";if(["section","main","article","aside"].includes(e))return"section";if(["p","span","label","strong","em","small","blockquote","figcaption"].includes(e))return"text";let i=o.getAttribute("class")??"";return/\\bcard\\b|rounded-(lg|xl|2xl)/.test(i)&&o.children.length>1?"card":o.children.length===0&&o.textContent?.trim()?"text":o.children.length>2?"section":"element"}var Pe={heading:"Heading",text:"Text",button:"Button",link:"Link",image:"Image",input:"Field",list:"List",section:"Section",nav:"Navigation",card:"Card",icon:"Icon",element:"Element"};function E(o){let e=G(o);if(e==="nav"){let t=o.tagName.toLowerCase();return t==="header"?"Header":t==="footer"?"Footer":"Navigation"}return Pe[e]}function R(o,e=42){let i=(o.getAttribute("alt")??o.getAttribute("aria-label")??o.textContent??"").replace(/\\s+/g," ").trim();return i?i.length>e?`${i.slice(0,e-1).trimEnd()}\\u2026`:i:""}function he(o){let e=o.tagName.toLowerCase(),t=(o.getAttribute("class")??"").split(/\\s+/).slice(0,8).join(" "),i=R(o,80);return`${E(o)} <${e}${t?` class="${t}"`:""}>${i?` \\u201C${i}\\u201D`:""}`}var ue={heading:["Rewrite it","Make it bigger","Change the font"],text:["Rewrite it","Make it shorter","Change the color"],button:["Change the label","Make it stand out","Change what it does"],link:["Change where it goes","Change the text","Style it as a button"],image:["Replace the image","Make it rounder","Make it bigger"],input:["Change the placeholder","Make it required","Change the label"],list:["Add an item","Change the layout","Reorder it"],section:["Change the layout","Add something here","Change the background"],nav:["Add a link","Change the logo","Make it sticky"],card:["Change the layout","Add a picture","Make it stand out"],icon:["Use a different icon","Make it bigger","Change the color"],element:["Change the style","Move it","Remove it"]};var S=class{constructor(e){this.layer=e;this.box=a("div",{class:"hl",style:"opacity:0"}),this.chip=a("div",{class:"chip",style:"opacity:0"}),e.append(this.box,this.chip)}layer;box;chip;target;frame=0;lines=[];perLine=!1;show(e,t,i,r={}){this.target=e,this.perLine=!!r.perLine,this.box.className=`hl ${t}`,this.box.style.opacity="1";for(let n of this.lines)n.className=`hl ${t}`;i?(this.chip.className=`chip ${t.startsWith("ask")?"ask":t==="locked"?"locked":""}`,this.chip.replaceChildren(...i.icon?[g(i.icon,14)]:[],a("span",{},i.strong),...i.muted?[a("span",{class:"muted"},i.muted)]:[]),this.chip.style.opacity="1"):this.chip.style.opacity="0",this.place(),this.frame||this.loop()}fadeOut(e,t){this.show(e,t),this.box.addEventListener("animationend",()=>this.hide(),{once:!0})}hide(){this.target=void 0,this.box.style.opacity="0",this.chip.style.opacity="0";for(let e of this.lines)e.remove();this.lines=[],cancelAnimationFrame(this.frame),this.frame=0}loop=()=>{this.place(),this.frame=this.target?requestAnimationFrame(this.loop):0};place(){let e=this.target?.getBoundingClientRect();if(!e)return;if(this.perLine&&this.target){let i=Array.from(this.target.getClientRects()).filter(r=>r.width>0&&r.height>0);if(i.length>1){for(;this.lines.length<i.length-1;){let n=a("div",{class:this.box.className});this.layer.append(n),this.lines.push(n)}for(;this.lines.length>i.length-1;)this.lines.pop()?.remove();let r=[this.box,...this.lines];i.forEach((n,s)=>{Object.assign(r[s].style,{top:`${n.top}px`,left:`${n.left}px`,width:`${n.width}px`,height:`${n.height}px`,opacity:"1"})});return}}Object.assign(this.box.style,{top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`});let t=e.top-30<4?e.bottom+8:e.top-30;Object.assign(this.chip.style,{top:`${t}px`,left:`${Math.max(6,Math.min(e.left-3,innerWidth-200))}px`})}};function J(o,e,t=10){let{width:i,height:r}=o.getBoundingClientRect(),s=e.bottom+t+r<innerHeight-70?e.bottom+t:Math.max(8,e.top-t-r),l=Math.min(Math.max(8,e.left),innerWidth-i-8);o.style.top=`${s}px`,o.style.left=`${l}px`}var O=class{el;constructor(){this.el=a("div",{class:"toasts",role:"status","aria-live":"polite"})}show(e,t={}){let i=a("div",{class:`toast ${t.tone==="warn"?"warn":""}`},g(t.tone==="warn"?"alert":"check",16),e);for(this.el.append(i);this.el.children.length>3;)this.el.firstElementChild?.remove();setTimeout(()=>{i.classList.add("leaving"),setTimeout(()=>i.remove(),260)},t.ms??2600)}};var ge=`\n${K({selector:":host"})}\n:host {\n all: initial;\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: ${B.toolbar};\n font: 13px/18px var(--cl-font-ui);\n color: var(--cl-ink);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n --dock-bg: color-mix(in oklab, var(--cl-paper) 88%, transparent);\n --dock-border: color-mix(in oklab, var(--cl-slip-strong) 70%, transparent);\n}\n* { box-sizing: border-box; }\n.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }\n.ic svg { display: block; }\nbutton { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0; cursor: pointer; }\nbutton:focus-visible, [tabindex]:focus-visible, textarea:focus-visible {\n outline: 2px solid var(--cl-focus);\n outline-offset: 2px;\n}\n.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n/* \\u2500\\u2500 Dock \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.dock-wrap {\n /* No transform here: it would trap the fixed-position pebble inside this box. */\n position: fixed; left: 0; right: 0; bottom: 14px;\n display: flex; flex-direction: column; align-items: center; gap: 8px;\n pointer-events: none;\n}\n.dock {\n pointer-events: auto;\n display: flex; align-items: center; gap: 2px;\n height: 46px; padding: 0 5px;\n background: var(--dock-bg);\n -webkit-backdrop-filter: blur(18px) saturate(1.5);\n backdrop-filter: blur(18px) saturate(1.5);\n border: 1px solid var(--dock-border);\n border-radius: var(--cl-radius-pill);\n box-shadow: var(--cl-shadow-lg);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n}\n@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.97); } }\n.sep { width: 1px; height: 22px; background: var(--cl-slip); margin: 0 5px; flex: none; }\n.backend { padding: 0 6px 0 2px; color: var(--cl-ash); font-size: 12px; font-weight: 500; white-space: nowrap; }\n.brand {\n width: 36px; height: 36px; border-radius: 50%;\n display: grid; place-items: center;\n transition: transform var(--cl-fast) var(--cl-ease-out), background var(--cl-fast);\n}\n/* The clod hops; turning or scaling it would blur its pixels. */\n.brand:hover { background: var(--cl-bisque); transform: translateY(-1px); }\n.brand[aria-expanded="true"] { background: var(--cl-bisque); }\n.tool {\n height: 36px; padding: 0 12px 0 10px;\n display: inline-flex; align-items: center; gap: 7px;\n border-radius: var(--cl-radius-pill);\n color: var(--cl-ink); font-weight: 500; letter-spacing: -0.005em;\n transition: background var(--cl-fast), color var(--cl-fast);\n white-space: nowrap;\n}\n.tool:hover { background: var(--cl-bisque); }\n.tool[aria-pressed="true"] { background: var(--cl-clay-soft); color: var(--cl-clay-text); }\n.tool .key {\n font: 500 10.5px/16px var(--cl-font-ui); color: var(--cl-ash);\n padding: 0 5px; border-radius: 5px; background: var(--cl-bisque); margin-left: 2px;\n}\n.tool[aria-pressed="true"] .key { background: color-mix(in oklab, var(--cl-clay) 14%, transparent); color: var(--cl-clay-text); }\n.icon-btn {\n width: 36px; height: 36px; border-radius: 50%;\n display: grid; place-items: center; color: var(--cl-ash);\n transition: background var(--cl-fast), color var(--cl-fast);\n}\n.icon-btn:hover { background: var(--cl-bisque); color: var(--cl-ink); }\n\n/* Device switcher: a segmented control with a sliding thumb. */\n.devices { position: relative; display: flex; align-items: center; height: 36px; padding: 3px; border-radius: var(--cl-radius-pill); background: var(--cl-bisque); }\n.devices .thumb {\n position: absolute; top: 3px; left: 3px; width: 34px; height: 30px; border-radius: var(--cl-radius-pill);\n background: var(--cl-paper); box-shadow: var(--cl-shadow-sm), 0 0 0 1px var(--cl-slip);\n transition: transform var(--cl-base) var(--cl-ease-out);\n}\n.devices button { position: relative; width: 34px; height: 30px; border-radius: var(--cl-radius-pill); display: grid; place-items: center; color: var(--cl-ash); transition: color var(--cl-fast); }\n.devices button:hover { color: var(--cl-ink); }\n.devices button[aria-checked="true"] { color: var(--cl-ink); }\n\n/* Keep the editing tools named even in Desktop\'s narrow preview. */\n@media (max-width: 560px) {\n .dock { height: auto; min-height: 46px; max-width: calc(100vw - 24px); padding: 5px; flex-wrap: wrap; justify-content: center; border-radius: 18px; }\n .dock .sep { display: none; }\n .dock .devices { order: 1; }\n .tool { padding: 0 8px; }\n .dock-wrap { bottom: 10px; }\n}\n\n/* Minimized: a single clod in the corner. */\n.pebble {\n pointer-events: auto;\n position: fixed; right: 16px; bottom: 16px;\n width: 44px; height: 44px; border-radius: 50%;\n display: grid; place-items: center;\n background: var(--dock-bg);\n -webkit-backdrop-filter: blur(18px) saturate(1.5);\n backdrop-filter: blur(18px) saturate(1.5);\n border: 1px solid var(--dock-border);\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n transition: transform var(--cl-fast) var(--cl-ease-out);\n}\n.pebble:hover { transform: translateY(-2px); }\n.pebble.labelled {\n width: auto; min-width: 44px; max-width: calc(100vw - 32px); padding: 0 12px;\n display: flex; gap: 7px; border-radius: var(--cl-radius-pill);\n white-space: nowrap; font-size: 12px; font-weight: 500;\n}\n\n/* \\u2500\\u2500 Hint above the dock \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.hint {\n pointer-events: auto;\n display: inline-flex; align-items: center; gap: 8px;\n height: 30px; padding: 0 12px 0 10px;\n background: var(--cl-ink); color: var(--cl-paper);\n border-radius: var(--cl-radius-pill);\n font-size: 12px; font-weight: 500;\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-base) var(--cl-ease-out) both;\n}\n.hint .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cl-clay); box-shadow: 0 0 0 0 var(--cl-clay); animation: pulse 1.8s var(--cl-ease-out) infinite; }\n.hint.ask .dot { background: var(--cl-cobalt); }\n.hint kbd { font: 500 11px/16px var(--cl-font-ui); padding: 0 5px; border-radius: 4px; background: color-mix(in oklab, var(--cl-paper) 16%, transparent); }\n@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--cl-clay) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }\n\n/* \\u2500\\u2500 Menu \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.menu {\n pointer-events: auto;\n position: fixed; min-width: 248px; padding: 6px;\n background: var(--cl-paper); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-lg);\n animation: pop var(--cl-base) var(--cl-ease-out) both;\n transform-origin: bottom left;\n}\n@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }\n.menu .head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }\n.menu .head b { font: 600 14px/18px var(--cl-font-display); letter-spacing: -0.01em; }\n.menu .head span { display: block; color: var(--cl-ash); font-size: 12px; }\n.menu hr { border: 0; border-top: 1px solid var(--cl-slip); margin: 4px 2px; }\n.menu-item {\n width: 100%; display: flex; align-items: center; gap: 10px;\n padding: 7px 8px; border-radius: var(--cl-radius-md); text-align: left; color: var(--cl-ink);\n}\n.menu-item:hover, .menu-item:focus-visible { background: var(--cl-bisque); outline: none; }\n.menu-item .ic { color: var(--cl-ash); }\n.menu-item .shortcut { margin-left: auto; color: var(--cl-ash); font-size: 11.5px; }\n\n/* \\u2500\\u2500 Highlights \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.hl {\n position: fixed; pointer-events: none;\n border-radius: 6px;\n transition: top 70ms linear, left 70ms linear, width 70ms linear, height 70ms linear, opacity var(--cl-fast);\n}\n.hl.edit-hover { outline: 1.5px dashed var(--cl-clay); outline-offset: 3px; background: color-mix(in oklab, var(--cl-clay) 5%, transparent); }\n.hl.editing { outline: 2px solid var(--cl-clay); outline-offset: 3px; box-shadow: 0 0 0 6px color-mix(in oklab, var(--cl-clay) 16%, transparent); }\n.hl.ask-hover { outline: 1.5px solid var(--cl-cobalt); outline-offset: 2px; background: color-mix(in oklab, var(--cl-cobalt) 7%, transparent); }\n.hl.saved { outline: 2px solid var(--cl-celadon); outline-offset: 3px; background: color-mix(in oklab, var(--cl-celadon) 12%, transparent); animation: fade 900ms var(--cl-ease-out) forwards; }\n.hl.locked { outline: 1.5px dashed var(--cl-ash); outline-offset: 3px; }\n@keyframes fade { 60% { opacity: 1; } to { opacity: 0; } }\n.chip {\n position: fixed; pointer-events: none;\n display: inline-flex; align-items: center; gap: 5px;\n height: 22px; padding: 0 8px 0 6px; border-radius: var(--cl-radius-pill);\n font-size: 11.5px; font-weight: 600; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis;\n /* on-clay reads on every chip fill (clay, cobalt, ash), in both schemes: see design\'s contrast test. */\n color: var(--cl-on-clay); background: var(--cl-clay);\n box-shadow: var(--cl-shadow-sm);\n}\n.chip.ask { background: var(--cl-cobalt); }\n.chip.locked { background: var(--cl-ash); }\n.chip .ic { width: 14px; height: 14px; }\n.chip .muted { font-weight: 500; opacity: .85; overflow: hidden; text-overflow: ellipsis; }\n\n/* \\u2500\\u2500 Popovers: edit bar, composer, notices \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.pop {\n pointer-events: auto;\n position: fixed;\n background: var(--cl-paper); color: var(--cl-ink);\n border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-lg);\n animation: pop var(--cl-base) var(--cl-ease-out) both;\n}\n.editbar { display: flex; align-items: center; gap: 6px; padding: 5px; border-radius: var(--cl-radius-pill); }\n.editbar .note { color: var(--cl-ash); font-size: 12px; padding: 0 6px 0 8px; white-space: nowrap; }\n.btn {\n height: 30px; padding: 0 12px; border-radius: var(--cl-radius-pill);\n display: inline-flex; align-items: center; gap: 6px;\n font-weight: 600; font-size: 12.5px; white-space: nowrap;\n transition: background var(--cl-fast), color var(--cl-fast), transform var(--cl-fast);\n}\n.btn:active { transform: translateY(1px); }\n.btn.primary { background: var(--cl-clay); color: var(--cl-on-clay); }\n.btn.primary:hover { background: var(--cl-clay-hover); }\n.btn.primary[disabled] { opacity: .55; cursor: default; }\n.btn.ghost { color: var(--cl-ink); }\n.btn.ghost:hover { background: var(--cl-bisque); }\n.btn .kbd { font-weight: 500; opacity: .75; font-size: 11px; }\n.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }\n@keyframes spin { to { transform: rotate(360deg); } }\n\n.composer { width: 340px; padding: 12px; }\n.composer .target { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--cl-ash); font-size: 12px; min-width: 0; }\n.composer .target .badge { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: var(--cl-radius-pill); color: var(--cl-cobalt); background: var(--cl-cobalt-soft); font-weight: 600; }\n.composer .target .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.composer textarea {\n width: 100%; min-height: 64px; max-height: 160px; resize: none;\n font: 14px/20px var(--cl-font-ui); color: var(--cl-ink);\n padding: 10px 12px; border-radius: var(--cl-radius-md);\n border: 1px solid var(--cl-slip-strong); background: var(--cl-paper);\n transition: border-color var(--cl-fast), box-shadow var(--cl-fast);\n}\n.composer textarea::placeholder { color: var(--cl-ash); }\n.composer textarea:focus { outline: none; border-color: var(--cl-cobalt); box-shadow: 0 0 0 3px color-mix(in oklab, var(--cl-cobalt) 20%, transparent); }\n.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }\n.suggestion {\n height: 26px; padding: 0 10px; border-radius: var(--cl-radius-pill);\n border: 1px solid var(--cl-slip); color: var(--cl-ink); font-size: 12px;\n transition: background var(--cl-fast), border-color var(--cl-fast);\n}\n.suggestion:hover { background: var(--cl-bisque); border-color: var(--cl-slip-strong); }\n.actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; }\n.actions .left { margin-right: auto; color: var(--cl-ash); font-size: 11.5px; }\n\n.notice { width: 300px; padding: 14px; }\n.notice h3 { margin: 0 0 4px; font: 600 14px/19px var(--cl-font-ui); }\n.notice p { margin: 0; color: var(--cl-ash); font-size: 12.5px; line-height: 18px; }\n\n/* \\u2500\\u2500 Errors \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n/* The app can\'t show anything: a quiet sheet over the page, and the story in plain words. */\n.error.screen {\n pointer-events: auto;\n position: fixed; inset: 0;\n display: grid; place-items: center;\n padding: 32px 24px 112px;\n overflow: auto;\n background: color-mix(in oklab, var(--cl-paper) 94%, transparent);\n -webkit-backdrop-filter: blur(12px) saturate(1.2);\n backdrop-filter: blur(12px) saturate(1.2);\n animation: sheet var(--cl-base) var(--cl-ease-out) both;\n}\n@keyframes sheet { from { opacity: 0; } }\n.error.screen .error-body { width: min(440px, 100%); animation: rise var(--cl-slow) var(--cl-ease-out) both; }\n/* Something broke, but the page still works: a small note above the dock. */\n.error.note {\n pointer-events: auto;\n width: min(400px, calc(100vw - 24px));\n padding: 14px 14px 14px 16px;\n background: var(--cl-paper); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-lg);\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-slow) var(--cl-spring) both;\n}\n.error.still, .error.still .error-body { animation: none; }\n.error .head { display: flex; align-items: center; gap: 10px; }\n.error .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cl-oxide); }\n.error .spinner { flex: none; width: 12px; height: 12px; margin: 0 -2px; border-width: 1.75px; color: var(--cl-clay); }\n.error h3 { flex: 1; margin: 0; font: 600 14px/20px var(--cl-font-ui); letter-spacing: -0.01em; }\n.error .close {\n flex: none; width: 28px; height: 28px; margin: -4px -6px -4px 0; border-radius: 50%;\n display: grid; place-items: center; color: var(--cl-ash);\n transition: background var(--cl-fast), color var(--cl-fast);\n}\n.error .close:hover { background: var(--cl-bisque); color: var(--cl-ink); }\n.error .why { margin: 4px 0 0 18px; color: var(--cl-ash); font-size: 13px; line-height: 19px; text-wrap: balance; }\n.error .why strong { color: var(--cl-ink); font-weight: 600; }\n.error .actions { justify-content: flex-start; gap: 4px; margin: 12px 0 0 18px; }\n.error .more { padding: 0 8px 0 12px; gap: 4px; color: var(--cl-ash); }\n.error .more:hover { color: var(--cl-ink); }\n.error .more .ic { transition: transform var(--cl-base) var(--cl-ease-out); }\n.error .more[aria-expanded="true"] .ic { transform: rotate(180deg); }\n.error .details {\n margin: 14px 0 0 18px; padding: 10px 12px; max-height: 220px; overflow: auto;\n background: var(--cl-bisque); border: 1px solid var(--cl-slip); border-radius: var(--cl-radius-md);\n font: 11.5px/17px var(--cl-font-mono); color: var(--cl-ink); user-select: text;\n}\n.error .details[hidden] { display: none; }\n.error .details p { margin: 0; word-break: break-word; }\n.error .details .where { color: var(--cl-ash); }\n.error .details .frame { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--cl-slip); font: inherit; color: var(--cl-ash); white-space: pre; overflow-x: auto; }\n.error.screen h3 { font-size: 22px; line-height: 28px; letter-spacing: -0.02em; }\n.error.screen .close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; margin: 0; }\n.error.screen .why { margin-top: 6px; font-size: 14.5px; line-height: 22px; }\n.error.screen .actions { margin-top: 20px; }\n.error.screen .btn { height: 34px; font-size: 13px; }\n.error.screen .btn.primary { padding: 0 16px; }\n\n/* \\u2500\\u2500 Toasts \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }\n.toast {\n pointer-events: auto;\n display: inline-flex; align-items: center; gap: 8px;\n height: 34px; padding: 0 14px 0 10px;\n background: var(--cl-ink); color: var(--cl-paper);\n border-radius: var(--cl-radius-pill);\n font-size: 12.5px; font-weight: 500;\n box-shadow: var(--cl-shadow-md);\n animation: rise var(--cl-base) var(--cl-ease-out) both;\n}\n.toast .ic { color: var(--cl-celadon); }\n.toast.warn .ic { color: var(--cl-ochre); }\n.toast.leaving { animation: leave var(--cl-base) var(--cl-ease-in-out) forwards; }\n@keyframes leave { to { opacity: 0; transform: translateY(6px); } }\n\n/* \\u2500\\u2500 Device bar (frame page) \\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500\\u2500 */\n.devicebar { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); pointer-events: auto; }\n.devicebar .size { padding: 0 6px 0 12px; color: var(--cl-ash); font: 500 12px/18px var(--cl-font-ui); font-variant-numeric: tabular-nums; white-space: nowrap; }\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }\n}\n`;var me="clodable:toolbar:v2",He=new RegExp(`[?&]${M}=1`),C={dynamic:"This text is filled in automatically, from your data or a list in your code, so it can\'t be typed over here.",notFound:"The page changed while you were editing. Try once more.",ambiguous:"That exact text appears twice here, so Claude should change it."},P=class{constructor(e){this.surface=e;let t=new URLSearchParams(location.search);this.device=e==="outer"?t.get("device")??"phone":"desktop";try{this.minimized=JSON.parse(localStorage.getItem(me)??"{}").minimized!==!1}catch{this.minimized=!0}}surface;host;shadow;layer;dockWrap;hintSlot;errorSlot;dockSlot;toasts=new O;hover;active;popover;mode="idle";minimized=!0;shortViewport=innerHeight<=420;expandedInShortViewport=!1;editing;device;mount(){this.host=document.createElement("clodable-toolbar"),this.host.setAttribute("data-clodable",""),this.shadow=this.host.attachShadow({mode:"open"}),this.shadow.append(a("style",{},ge)),this.layer=a("div"),this.hintSlot=a("div"),this.errorSlot=a("div"),this.dockSlot=a("div"),this.dockWrap=a("div",{class:"dock-wrap"},this.toasts.el,this.errorSlot,this.hintSlot,this.dockSlot),this.shadow.append(this.layer,this.dockWrap),this.hover=new S(this.layer),this.active=new S(this.layer),document.body.append(this.host),new MutationObserver(()=>{this.host.isConnected||document.body.append(this.host)}).observe(document.body,{childList:!0}),this.render(),this.surface!=="outer"&&(new A(this.layer,this.errorSlot,(e,t)=>this.toasts.show(e,t?{tone:t}:{})).start(),this.listen()),this.surface==="inner"&&this.reportRoutes(),this.surface==="outer"&&this.followRoutes()}render(){let e=this.shadow.activeElement?.dataset.key;if(this.draw(),!e)return;let t=i=>this.shadow.querySelector(`[data-key="${i}"]`);(t(e)??t("pebble")??t("hide"))?.focus()}draw(){this.surface==="outer"?this.drawDeviceBar():this.collapsed?this.drawPebble():this.drawDock()}get collapsed(){return this.minimized||this.shortViewport&&!this.expandedInShortViewport&&this.mode==="idle"}drawDeviceBar(){this.dockSlot.replaceChildren();let e=new URLSearchParams(location.search),{width:t,height:i}=ee[this.device==="tablet"?"tablet":"phone"],r=e.get("landscape")==="1"?`${i} \\xD7 ${t}`:`${t} \\xD7 ${i}`,n=a("div",{class:"dock",role:"toolbar","aria-label":"Device preview"},this.deviceSwitch(),a("span",{class:"size","aria-label":`Screen size ${r}`},r),a("span",{class:"sep","aria-hidden":"true"}),a("button",{class:"icon-btn","aria-label":"Rotate",title:"Rotate",onclick:()=>this.rotate()},g("refresh")));be(n,this.shadow),this.layer.replaceChildren(this.hover.box,this.hover.chip,this.active.box,this.active.chip,a("div",{class:"devicebar"},n))}drawPebble(){let e=$()?.backend==="copy";this.hintSlot.replaceChildren(),this.dockSlot.replaceChildren(a("button",{class:"pebble labelled","data-key":"pebble","aria-label":"Show Clodable tools",...e?{"aria-description":"This preview uses a copy of your data."}:{},title:"Show Clodable tools (\\u2325\\u21E7H)",onclick:()=>this.setMinimized(!1)},this.mark(24),a("span",{},e?"Copy \\xB7 Tools":"Tools")))}drawDock(){let e=(n,s,l,p)=>a("button",{class:"tool","data-key":n,"aria-pressed":String(this.mode===n),title:`${l} (${p})`,onclick:()=>this.setMode(this.mode===n?"idle":n)},g(s),a("span",{class:"label"},l)),t=a("button",{class:"brand","data-key":"menu","aria-label":"Clodable menu","aria-haspopup":"menu","aria-expanded":"false",onclick:n=>this.toggleMenu(n.currentTarget)},this.mark(24)),i=$()?.backend==="copy",r=a("div",{class:"dock",role:"toolbar","aria-label":"Clodable preview tools"},t,...i?[a("span",{class:"backend",title:"This preview uses your new backend, a copy of your data. Your live app is untouched."},"Copy")]:[],a("span",{class:"sep","aria-hidden":"true"}),e("edit","text","Edit text","\\u2325\\u21E7E"),e("ask","select","Point & ask","\\u2325\\u21E7A"),...this.surface==="app"?[a("span",{class:"sep","aria-hidden":"true"}),this.deviceSwitch()]:[],a("span",{class:"sep","aria-hidden":"true"}),a("button",{class:"icon-btn","data-key":"hide","aria-label":"Hide Clodable tools",title:"Hide (\\u2325\\u21E7H)",onclick:()=>this.setMinimized(!0)},g("minimize")));be(r,this.shadow),this.dockSlot.replaceChildren(r),this.renderHint()}mark(e){let t=a("span",{"aria-hidden":"true",style:"display:grid"});return t.innerHTML=j({size:e}),t}deviceSwitch(){let e=[["desktop","desktop","Full width"],["tablet","tablet","Tablet"],["phone","phone","Phone"]],t=e.findIndex(([i])=>i===this.device);return a("div",{class:"devices",role:"radiogroup","aria-label":"Preview size"},a("span",{class:"thumb","aria-hidden":"true",style:`transform: translateX(${t*100}%)`}),...e.map(([i,r,n])=>a("button",{role:"radio","aria-checked":String(this.device===i),"aria-label":n,title:n,onclick:()=>this.setDevice(i)},g(r))))}renderHint(){if(this.mode==="idle"||this.minimized){this.hintSlot.replaceChildren();return}let e=this.mode==="edit"?"Click any text to change it":"Click anything to ask Claude about it";this.hintSlot.replaceChildren(a("div",{class:`hint ${this.mode==="ask"?"ask":""}`,role:"status"},a("span",{class:"dot"}),e,a("kbd",{},"Esc")))}setMode(e){this.editing&&this.finishEdit(!1),this.closePopover(),this.mode=e,e!=="idle"&&(this.minimized=!1),this.hover.hide(),document.documentElement.style.cursor="",this.render()}setMinimized(e){this.minimized=e,this.expandedInShortViewport=!e;try{localStorage.setItem(me,JSON.stringify({minimized:e}))}catch{}e?this.setMode("idle"):this.render()}setDevice(e){let t=this.surface==="outer"?new URLSearchParams(location.search).get("path")??"/":location.pathname+location.search;if(e==="desktop"){this.surface==="outer"&&(location.href=t);return}let i=`${u.frame}?device=${e}&path=${encodeURIComponent(t)}`;location.href=i}rotate(){let e=new URLSearchParams(location.search);e.set("landscape",e.get("landscape")==="1"?"0":"1"),location.search=e.toString()}isOurs(e){return e instanceof Node&&(e===this.host||this.host.contains(e)||this.shadow.contains(e))}listen(){addEventListener("resize",()=>{let t=innerHeight<=420;t!==this.shortViewport&&(this.shortViewport=t,this.expandedInShortViewport=!1,this.closePopover(),this.render())});let e=0;addEventListener("pointermove",t=>{this.mode==="idle"||this.editing||this.popover||(cancelAnimationFrame(e),e=requestAnimationFrame(()=>this.onHover(t.clientX,t.clientY,t.target)))},{capture:!0,passive:!0});for(let t of["pointerdown","mousedown","pointerup","mouseup","click","dblclick","submit"])addEventListener(t,i=>this.onPointer(i),{capture:!0});addEventListener("keydown",t=>this.onKey(t),{capture:!0}),addEventListener("scroll",()=>this.closePopoverIfDetached(),{capture:!0,passive:!0})}onPointer(e){if(!(this.mode==="idle"||this.isOurs(e.target))&&!(this.editing&&e.target instanceof Node&&this.editing.editable.contains(e.target))&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type==="click")){if(this.editing){this.finishEdit(!0);return}if(this.popover){this.closePopover();return}this.mode==="edit"?this.startEdit(e.clientX,e.clientY):this.mode==="ask"&&this.openComposer(e.clientX,e.clientY)}}onHover(e,t,i){if(this.popover||this.editing||this.mode==="idle")return;if(this.isOurs(i)){this.hover.hide();return}if(this.mode==="edit"){let s=fe(e,t,this.host),l=s&&y(s.el);s&&l?(this.hover.show(s.el,"edit-hover",{icon:"text",strong:"Edit text"}),document.documentElement.style.cursor="text"):(this.hover.hide(),document.documentElement.style.cursor="");return}let r=Z(e,t,this.host),n=r&&y(r);if(r&&n){let s=R(r,32);this.hover.show(r,"ask-hover",{strong:E(r),...s?{muted:`\\xB7 ${s}`}:{}}),document.documentElement.style.cursor="pointer"}else this.hover.hide(),document.documentElement.style.cursor=""}onKey(e){let t=Fe(e.target)&&!this.isOurs(e.target);if(e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey){let r={KeyE:()=>this.setMode(this.mode==="edit"?"idle":"edit"),KeyA:()=>this.setMode(this.mode==="ask"?"idle":"ask"),KeyH:()=>this.setMinimized(!this.collapsed)}[e.code];if(r&&!(t&&!this.editing)){e.preventDefault(),e.stopPropagation(),r();return}}e.key==="Escape"&&(this.editing?(e.preventDefault(),e.stopPropagation(),this.finishEdit(!1)):this.popover?(e.preventDefault(),this.closePopover()):this.mode!=="idle"&&(e.preventDefault(),this.setMode("idle")))}async startEdit(e,t){let i=fe(e,t,this.host),r=i&&y(i.el);if(!i||!r)return;let n=i.node.textContent??"",s;try{s=await m.probe(r.src,n)}catch{this.toasts.show("Couldn\'t reach Clodable. Is the preview still running?",{tone:"warn"});return}if(!s.editable){this.showLocked(i.el,n,s.reason);return}this.hover.hide();let{editable:l,restore:p}=ze(i.el,i.node),h=a("div",{class:"pop editbar",role:"group","aria-label":"Editing text"},a("span",{class:"note"},"Editing text"),a("button",{class:"btn ghost",onclick:()=>this.finishEdit(!1)},"Cancel"),a("button",{class:"btn primary",onclick:()=>this.finishEdit(!0)},"Save",a("span",{class:"kbd"},"\\u23CE")));this.layer.append(h),this.editing={el:i.el,restore:p,editable:l,node:i.node,src:r.src,before:n,bar:h,saving:!1},this.active.show(l,"editing",void 0,{perLine:l!==i.el}),l.addEventListener("keydown",this.onEditKey),l.addEventListener("focusout",this.onEditBlur),l.focus({preventScroll:!0}),_e(e,t,l);let c=()=>{this.editing&&(J(h,this.editing.el.getBoundingClientRect(),12),requestAnimationFrame(c))};c()}onEditKey=e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.finishEdit(!0))};onEditBlur=e=>{this.isOurs(e.relatedTarget)||setTimeout(()=>{this.editing&&!this.editing.saving&&document.activeElement!==this.editing.editable&&this.finishEdit(!0)},0)};async finishEdit(e){let t=this.editing;if(!t||t.saving)return;let i=(t.editable.textContent??"").replace(/\\s+/g," ").trim(),r=e&&i&&i!==t.before.replace(/\\s+/g," ").trim();if(t.editable.removeEventListener("keydown",this.onEditKey),t.editable.removeEventListener("focusout",this.onEditBlur),!r){t.restore(),t.node.textContent=t.before,this.endEdit();return}t.saving=!0,t.bar.replaceChildren(a("span",{class:"note"},a("span",{class:"spinner",style:"display:inline-block;vertical-align:-3px;margin-right:8px"}),"Saving\\u2026"));try{let n=await m.edit(t.src,t.before,i);if(t.restore(),n.ok)t.node.textContent=Ne(t.before,i),this.active.fadeOut(t.el,"saved"),this.toasts.show("Text updated \\xB7 saved to your draft");else{t.node.textContent=t.before,this.active.hide();let{reason:s}=n;this.toasts.show(s==="dynamic"?C.dynamic:s==="ambiguous"?C.ambiguous:C.notFound,{tone:"warn",ms:4200})}}catch{t.restore(),t.node.textContent=t.before,this.toasts.show("Couldn\'t save that change. Try again.",{tone:"warn"})}this.endEdit(!1)}endEdit(e=!0){this.editing?.bar.remove(),this.editing=void 0,e&&this.active.hide()}showLocked(e,t,i){this.closePopover(),this.hover.show(e,"locked",{icon:"info",strong:"Not editable here"});let r=a("button",{class:"btn primary",onclick:()=>this.openComposerFor(e,`Change \\u201C${De(t)}\\u201D to `)},"Ask Claude"),n=a("div",{class:"pop notice",role:"dialog","aria-label":"This text can\'t be edited here"},a("h3",{},"Claude can change this one for you"),a("p",{},i==="ambiguous"?C.ambiguous:C.dynamic),a("div",{class:"actions"},a("button",{class:"btn ghost",onclick:()=>this.closePopover()},"Close"),r));this.openPopover(n,e.getBoundingClientRect()),r.focus({preventScroll:!0})}openComposer(e,t){let i=Z(e,t,this.host);i&&y(i)&&this.openComposerFor(i)}openComposerFor(e,t=""){this.closePopover();let i=y(e);this.hover.show(e,"ask-hover");let r=G(e),n=a("textarea",{rows:"3",placeholder:"What should change? For example: make it bigger and bolder","aria-label":"What should change?"});n.value=t;let s=a("button",{class:"btn primary",onclick:()=>l()},"Send to Claude"),l=async()=>{let c=n.value.trim();if(!c){n.focus();return}s.setAttribute("disabled","");try{let xe=i?Q(i.src):void 0;await m.ask(c,he(e),xe),this.closePopover(),this.setMode("idle"),this.toasts.show("Sent to Claude")}catch{s.removeAttribute("disabled"),this.toasts.show("Couldn\'t reach Claude. Is Clodable running?",{tone:"warn"})}};n.addEventListener("keydown",c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),l())});let p=R(e,48),h=a("div",{class:"pop composer",role:"dialog","aria-label":`Ask Claude about this ${E(e).toLowerCase()}`},a("div",{class:"target"},a("span",{class:"badge"},g("select",14),E(e)),p?a("span",{class:"what"},`\\u201C${p}\\u201D`):null),n,a("div",{class:"suggestions"},...ue[r].map(c=>a("button",{class:"suggestion",onclick:()=>{n.value=c,n.focus()}},c))),a("div",{class:"actions"},a("span",{class:"left"},"\\u23CE to send"),a("button",{class:"btn ghost",onclick:()=>this.closePopover()},"Cancel"),s));this.openPopover(h,e.getBoundingClientRect()),n.focus({preventScroll:!0}),n.setSelectionRange(n.value.length,n.value.length)}openPopover(e,t){this.closePopover(!1),this.popover=e,this.layer.append(e),J(e,t)}closePopover(e=!0){let t=this.popover?.classList.contains("menu")&&this.popover.contains(this.shadow.activeElement);this.popover?.remove(),this.popover=void 0,e&&this.hover.hide();let i=this.shadow?.querySelector(\'.brand[aria-expanded="true"]\');i?.setAttribute("aria-expanded","false"),t&&i?.focus()}closePopoverIfDetached(){this.popover?.classList.contains("menu")||this.popover&&!this.editing&&this.closePopover()}toggleMenu(e){if(this.popover?.classList.contains("menu")){this.closePopover();return}let t=(n,s,l,p)=>a("button",{class:"menu-item",role:"menuitem",onclick:()=>{this.closePopover(),p()}},g(n),s,a("span",{class:"shortcut"},l)),i=a("div",{class:"menu",role:"menu","aria-label":"Clodable"},a("div",{class:"head"},this.mark(28),a("div",{},a("b",{},"Clodable"),a("span",{},"Only you see these tools. Visitors never do."))),a("hr"),t("text","Edit text","\\u2325\\u21E7E",()=>this.setMode("edit")),t("select","Point & ask Claude","\\u2325\\u21E7A",()=>this.setMode("ask")),...this.surface==="app"?[t("phone","Phone preview","",()=>this.setDevice("phone"))]:[],a("hr"),t("minimize","Hide these tools","\\u2325\\u21E7H",()=>this.setMinimized(!0)));ve(i,this.shadow,"ArrowUp","ArrowDown"),this.popover=i,this.layer.append(i),e.setAttribute("aria-expanded","true");let r=e.getBoundingClientRect();i.style.left=`${Math.max(8,r.left-6)}px`,i.style.top=`${r.top-i.getBoundingClientRect().height-10}px`,i.querySelector(".menu-item")?.focus()}reportRoutes(){let e=()=>parent.postMessage({type:"clodable:route",path:location.pathname+location.search.replace(He,"")},location.origin);for(let t of["pushState","replaceState"]){let i=history[t].bind(history);history[t]=((...r)=>{i(...r),e()})}addEventListener("popstate",e)}followRoutes(){addEventListener("message",e=>{if(e.origin!==location.origin||e.data?.type!=="clodable:route")return;let t=new URLSearchParams(location.search);t.set("path",e.data.path||"/"),history.replaceState(null,"",`${location.pathname}?${t.toString()}`)})}};function be(o,e){ve(o,e,"ArrowLeft","ArrowRight");let t=Array.from(o.querySelectorAll("button"));for(let[i,r]of t.entries())r.tabIndex=i===0?0:-1,r.addEventListener("focus",()=>{for(let n of t)n.tabIndex=-1;r.tabIndex=0})}function ve(o,e,t,i){o.addEventListener("keydown",r=>{let n=Array.from(o.querySelectorAll("button")),s=n.indexOf(e.activeElement);if(s<0)return;let p={[t]:s-1,[i]:s+1,Home:0,End:n.length-1}[r.key];p!==void 0&&(r.preventDefault(),n[(p+n.length)%n.length]?.focus())})}var De=o=>{let e=o.replace(/\\s+/g," ").trim();return e.length>60?`${e.slice(0,59)}\\u2026`:e};function Ne(o,e){let t=o.match(/^\\s*/)?.[0]??"",i=o.match(/\\s*$/)?.[0]??"";return`${t}${e}${i}`}function Fe(o){return o instanceof HTMLElement&&(o.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(o.tagName))}function Z(o,e,t){let i=document.elementFromPoint(o,e);if(!(!i||i===t||i===document.documentElement||i===document.body))return i}function fe(o,e,t){let i=document,r=null,n=document.caretPositionFromPoint?.(o,e);if(n?r=n.offsetNode:r=i.caretRangeFromPoint?.(o,e)?.startContainer??null,r&&r.nodeType===Node.TEXT_NODE&&r.textContent?.trim()&&r.parentElement&&!t.contains(r)){let p=document.createRange();if(p.selectNodeContents(r),Array.from(p.getClientRects()).some(c=>o>=c.left-3&&o<=c.right+3&&e>=c.top-3&&e<=c.bottom+3))return{el:r.parentElement,node:r}}let s=Z(o,e,t);if(!s)return;let l=Array.from(s.childNodes).find(p=>p.nodeType===Node.TEXT_NODE&&!!p.textContent?.trim());return l&&s instanceof HTMLElement?{el:s,node:l}:void 0}function ze(o,e){let t=Array.from(o.childNodes).filter(r=>!(r.nodeType===Node.TEXT_NODE&&!r.textContent?.trim()));if(t.length===1&&t[0]===e){let r=o.getAttribute("contenteditable"),n=Array.from(o.childNodes);return o.setAttribute("contenteditable","plaintext-only"),o.setAttribute("spellcheck","true"),{editable:o,restore:()=>{r===null?o.removeAttribute("contenteditable"):o.setAttribute("contenteditable",r),o.removeAttribute("spellcheck"),o.replaceChildren(...n)}}}let i=document.createElement("span");return i.setAttribute("contenteditable","plaintext-only"),i.setAttribute("data-clodable-editing",""),i.style.outline="none",e.replaceWith(i),i.textContent=e.textContent,{editable:i,restore:()=>{i.replaceWith(e)}}}function _e(o,e,t){let i=getSelection();if(!i)return;let r=document,n=document.caretPositionFromPoint?.(o,e),s=document.createRange();if(n&&t.contains(n.offsetNode))s.setStart(n.offsetNode,n.offset);else{let l=r.caretRangeFromPoint?.(o,e);l&&t.contains(l.startContainer)?s.setStart(l.startContainer,l.startOffset):s.selectNodeContents(t)}s.collapse(!0),i.removeAllRanges(),i.addRange(s)}function Ie(){if(window.__CLODABLE_MOUNTED__)return;Object.defineProperty(window,"__CLODABLE_MOUNTED__",{value:!0}),ie(),pe();let o=location.pathname===u.frame?"outer":new URLSearchParams(location.search).has(M)?"inner":"app",e=()=>setTimeout(()=>new P(o).mount(),0);document.readyState==="complete"?e():addEventListener("load",e,{once:!0})}Ie();})();\n';
|
|
47128
48144
|
const live = Boolean(process.env.CLODABLE_TOOLBAR_DEV);
|
|
47129
48145
|
if (cached2 && !live) return cached2;
|
|
47130
48146
|
const dist = fileURLToPath2(new URL("../dist/toolbar.js", import.meta.url));
|
|
47131
|
-
if (!live &&
|
|
47132
|
-
cached2 = await
|
|
48147
|
+
if (!live && existsSync24(dist)) {
|
|
48148
|
+
cached2 = await readFile18(dist, "utf8");
|
|
47133
48149
|
return cached2;
|
|
47134
48150
|
}
|
|
47135
48151
|
const esbuild = await import("esbuild");
|
|
@@ -47257,10 +48273,10 @@ ${await toolbarSource()}
|
|
|
47257
48273
|
const location = parseSourceAttr(String(body.src ?? ""));
|
|
47258
48274
|
const rel = location && inside(root, location.file);
|
|
47259
48275
|
const full = rel && resolve6(root, rel);
|
|
47260
|
-
if (!location || !full || !EDITABLE.test(full) || !tagged.has(full) || !
|
|
48276
|
+
if (!location || !full || !EDITABLE.test(full) || !tagged.has(full) || !existsSync25(full)) {
|
|
47261
48277
|
return { ok: false, editable: false, reason: "not-found" };
|
|
47262
48278
|
}
|
|
47263
|
-
const code2 = await
|
|
48279
|
+
const code2 = await readFile19(full, "utf8");
|
|
47264
48280
|
if (probe) {
|
|
47265
48281
|
return probeText(
|
|
47266
48282
|
code2,
|
|
@@ -47275,7 +48291,7 @@ ${await toolbarSource()}
|
|
|
47275
48291
|
if (!after.trim()) return { ok: false, reason: "empty" };
|
|
47276
48292
|
const result = editText(code2, location.file, location, before, after);
|
|
47277
48293
|
if (!result.ok) return result;
|
|
47278
|
-
await
|
|
48294
|
+
await writeFile13(full, result.code);
|
|
47279
48295
|
await writeInbox(root, {
|
|
47280
48296
|
kind: "edit",
|
|
47281
48297
|
page: toolbarPage(body.page) ?? { url: "", path: "/" },
|
|
@@ -47457,8 +48473,8 @@ function backendPlugin(current) {
|
|
|
47457
48473
|
function resolveProjectVite(root) {
|
|
47458
48474
|
let dir = root;
|
|
47459
48475
|
while (true) {
|
|
47460
|
-
const pkgPath =
|
|
47461
|
-
if (
|
|
48476
|
+
const pkgPath = join30(dir, "node_modules", "vite", "package.json");
|
|
48477
|
+
if (existsSync26(pkgPath)) {
|
|
47462
48478
|
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
47463
48479
|
const dot = pkg.exports?.["."];
|
|
47464
48480
|
const pick2 = (entry2) => {
|
|
@@ -47470,9 +48486,9 @@ function resolveProjectVite(root) {
|
|
|
47470
48486
|
return void 0;
|
|
47471
48487
|
};
|
|
47472
48488
|
const entry = pick2(dot) ?? pkg.module ?? pkg.main ?? "dist/node/index.js";
|
|
47473
|
-
return
|
|
48489
|
+
return join30(dirname8(pkgPath), entry);
|
|
47474
48490
|
}
|
|
47475
|
-
const parent =
|
|
48491
|
+
const parent = dirname8(dir);
|
|
47476
48492
|
if (parent === dir) break;
|
|
47477
48493
|
dir = parent;
|
|
47478
48494
|
}
|
|
@@ -47583,15 +48599,15 @@ var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
|
47583
48599
|
function findAppRoot(start) {
|
|
47584
48600
|
let dir = resolve7(start);
|
|
47585
48601
|
while (true) {
|
|
47586
|
-
if (
|
|
47587
|
-
const parent =
|
|
48602
|
+
if (existsSync27(join31(dir, "package.json"))) return dir;
|
|
48603
|
+
const parent = dirname9(dir);
|
|
47588
48604
|
if (parent === dir) return resolve7(start);
|
|
47589
48605
|
dir = parent;
|
|
47590
48606
|
}
|
|
47591
48607
|
}
|
|
47592
48608
|
async function devCommand(ctx2, options) {
|
|
47593
48609
|
const root = findAppRoot(ctx2.cwd);
|
|
47594
|
-
if (!
|
|
48610
|
+
if (!existsSync27(join31(root, "node_modules")) && existsSync27(join31(root, "package.json"))) {
|
|
47595
48611
|
const pm = detectPackageManager(root);
|
|
47596
48612
|
process.stdout.write(
|
|
47597
48613
|
`
|
|
@@ -47631,10 +48647,10 @@ async function devCommand(ctx2, options) {
|
|
|
47631
48647
|
if (fresh) known.set(move.home.ref, fresh);
|
|
47632
48648
|
return fresh;
|
|
47633
48649
|
},
|
|
47634
|
-
watch:
|
|
48650
|
+
watch: join31(root, MOVE_PATH)
|
|
47635
48651
|
},
|
|
47636
48652
|
// The settings the app's server code reads, from Clodable's private store on this computer.
|
|
47637
|
-
settings: { current: () => localSettings(root), watch:
|
|
48653
|
+
settings: { current: () => localSettings(root), watch: join31(root, SETTINGS_PATH) }
|
|
47638
48654
|
});
|
|
47639
48655
|
process.stdout.write(
|
|
47640
48656
|
`
|
|
@@ -47671,7 +48687,7 @@ async function devCommand(ctx2, options) {
|
|
|
47671
48687
|
// src/commands/move.ts
|
|
47672
48688
|
var SETTINGS = {
|
|
47673
48689
|
backend: ["lovable-cloud", "supabase", "none"],
|
|
47674
|
-
hosting: ["lovable", "github"]
|
|
48690
|
+
hosting: ["lovable", "github", "none"]
|
|
47675
48691
|
};
|
|
47676
48692
|
async function configCommand(ctx2, options) {
|
|
47677
48693
|
await run(
|
|
@@ -47797,6 +48813,27 @@ var STEPS = {
|
|
|
47797
48813
|
(progress) => renderProgress(ctx2, progress)
|
|
47798
48814
|
)
|
|
47799
48815
|
},
|
|
48816
|
+
rehearsal: {
|
|
48817
|
+
usage: "rehearsal [--set]",
|
|
48818
|
+
run: (ctx2, options) => run(
|
|
48819
|
+
ctx2,
|
|
48820
|
+
async () => {
|
|
48821
|
+
const ws = await ctx2.workspace();
|
|
48822
|
+
return options.set ? recordRehearsal(ws, await readStdin() ?? "") : readRehearsal(ws);
|
|
48823
|
+
},
|
|
48824
|
+
(record2) => {
|
|
48825
|
+
ctx2.out.header("Checks on your copy");
|
|
48826
|
+
for (const observation of record2.observations) {
|
|
48827
|
+
ctx2.out.line(
|
|
48828
|
+
`${observation.feature}: ${observation.result} (${observation.observedAt}, ${observation.method}, ${observation.scope})`
|
|
48829
|
+
);
|
|
48830
|
+
ctx2.out.line(observation.evidence);
|
|
48831
|
+
if (observation.limitation) ctx2.out.line(observation.limitation);
|
|
48832
|
+
}
|
|
48833
|
+
ctx2.out.line(record2.limit);
|
|
48834
|
+
}
|
|
48835
|
+
)
|
|
48836
|
+
},
|
|
47800
48837
|
connect: {
|
|
47801
48838
|
run: (ctx2) => run(
|
|
47802
48839
|
ctx2,
|
|
@@ -48282,6 +49319,147 @@ async function moveCommand(ctx2, options) {
|
|
|
48282
49319
|
return COMMANDS[options.step].run(ctx2, options);
|
|
48283
49320
|
}
|
|
48284
49321
|
|
|
49322
|
+
// src/commands/online.ts
|
|
49323
|
+
async function connectCommand(ctx2, service) {
|
|
49324
|
+
if (service === "supabase") {
|
|
49325
|
+
await run(
|
|
49326
|
+
ctx2,
|
|
49327
|
+
async () => {
|
|
49328
|
+
await ctx2.workspace();
|
|
49329
|
+
return connectSupabase(
|
|
49330
|
+
await secretInput(ctx2, `Your Supabase access token (create one at ${TOKENS_PAGE})`)
|
|
49331
|
+
);
|
|
49332
|
+
},
|
|
49333
|
+
(data) => {
|
|
49334
|
+
ctx2.out.line(`${celadon("\u2713")} Supabase is connected on this computer.`);
|
|
49335
|
+
for (const org of data.organizations) ctx2.out.line(ash(` ${org.name} \xB7 ${org.plan} plan`));
|
|
49336
|
+
}
|
|
49337
|
+
);
|
|
49338
|
+
return;
|
|
49339
|
+
}
|
|
49340
|
+
if (service === "netlify") {
|
|
49341
|
+
await run(
|
|
49342
|
+
ctx2,
|
|
49343
|
+
async () => {
|
|
49344
|
+
await ctx2.workspace();
|
|
49345
|
+
return connectNetlify(
|
|
49346
|
+
await secretInput(
|
|
49347
|
+
ctx2,
|
|
49348
|
+
`Your Netlify access token (create one at ${NETLIFY_TOKENS_PAGE})`
|
|
49349
|
+
)
|
|
49350
|
+
);
|
|
49351
|
+
},
|
|
49352
|
+
(data) => {
|
|
49353
|
+
ctx2.out.line(`${celadon("\u2713")} Netlify is connected on this computer.`);
|
|
49354
|
+
for (const account of data.accounts)
|
|
49355
|
+
ctx2.out.line(ash(` ${account.name} (${account.slug})`));
|
|
49356
|
+
}
|
|
49357
|
+
);
|
|
49358
|
+
return;
|
|
49359
|
+
}
|
|
49360
|
+
await run(ctx2, async () => {
|
|
49361
|
+
throw new ClodableError({
|
|
49362
|
+
code: "invalid-config",
|
|
49363
|
+
message: `Clodable can't connect \u201C${service}\u201D.`,
|
|
49364
|
+
hint: "Use supabase or netlify."
|
|
49365
|
+
});
|
|
49366
|
+
});
|
|
49367
|
+
}
|
|
49368
|
+
async function siteCommand(ctx2, options) {
|
|
49369
|
+
if (options.action === "reconnect") {
|
|
49370
|
+
await run(
|
|
49371
|
+
ctx2,
|
|
49372
|
+
async () => reconnectSite(await ctx2.workspace()),
|
|
49373
|
+
() => {
|
|
49374
|
+
ctx2.out.line(
|
|
49375
|
+
`${celadon("\u2713")} Your app's publishing connection is updated. You can retry Publish.`
|
|
49376
|
+
);
|
|
49377
|
+
}
|
|
49378
|
+
);
|
|
49379
|
+
return;
|
|
49380
|
+
}
|
|
49381
|
+
if (options.action === "create") {
|
|
49382
|
+
await run(
|
|
49383
|
+
ctx2,
|
|
49384
|
+
async () => drive(
|
|
49385
|
+
ctx2,
|
|
49386
|
+
putSiteOnline(await ctx2.workspace(), options.team ? { team: options.team } : {})
|
|
49387
|
+
),
|
|
49388
|
+
(outcome) => {
|
|
49389
|
+
ctx2.out.line(` ${link(outcome.site.url)} ${ash("\xB7 goes online at your next Publish")}`);
|
|
49390
|
+
if (outcome.files.length > 0) ctx2.out.line(ash(` Added: ${outcome.files.join(", ")}`));
|
|
49391
|
+
const missing = outcome.settings.wanted.filter((n4) => !outcome.settings.set.includes(n4));
|
|
49392
|
+
if (missing.length > 0) {
|
|
49393
|
+
ctx2.out.line(ash(` Settings your app reads, to fill in: ${missing.join(", ")}`));
|
|
49394
|
+
}
|
|
49395
|
+
}
|
|
49396
|
+
);
|
|
49397
|
+
return;
|
|
49398
|
+
}
|
|
49399
|
+
await run(
|
|
49400
|
+
ctx2,
|
|
49401
|
+
async () => {
|
|
49402
|
+
if (options.action) {
|
|
49403
|
+
throw new ClodableError({
|
|
49404
|
+
code: "invalid-config",
|
|
49405
|
+
message: `\u201C${options.action}\u201D isn't something site does.`,
|
|
49406
|
+
hint: "Use clodable site to see where it stands, or clodable site create."
|
|
49407
|
+
});
|
|
49408
|
+
}
|
|
49409
|
+
return siteChoices(await ctx2.workspace());
|
|
49410
|
+
},
|
|
49411
|
+
(choices) => {
|
|
49412
|
+
if (choices.site) ctx2.out.line(`${celadon("\u25CF")} Your site: ${link(choices.site.url)}`);
|
|
49413
|
+
else ctx2.out.line(ash("Your site isn't online with Clodable yet."));
|
|
49414
|
+
if (!choices.connected) ctx2.out.line(ash("Netlify isn't connected on this computer."));
|
|
49415
|
+
for (const team of choices.teams) ctx2.out.line(`${team.name} ${ash(`(${team.slug})`)}`);
|
|
49416
|
+
}
|
|
49417
|
+
);
|
|
49418
|
+
}
|
|
49419
|
+
async function backendCommand(ctx2, options) {
|
|
49420
|
+
if (options.action === "create") {
|
|
49421
|
+
await run(
|
|
49422
|
+
ctx2,
|
|
49423
|
+
async () => drive(
|
|
49424
|
+
ctx2,
|
|
49425
|
+
createBackend(await ctx2.workspace(), {
|
|
49426
|
+
...options.org ? { org: options.org } : {},
|
|
49427
|
+
...options.region ? { region: options.region } : {}
|
|
49428
|
+
})
|
|
49429
|
+
),
|
|
49430
|
+
(outcome) => {
|
|
49431
|
+
ctx2.out.line(ash(` ${outcome.name} \xB7 ${outcome.region}`));
|
|
49432
|
+
ctx2.out.line(` ${link(outcome.dashboard)}`);
|
|
49433
|
+
}
|
|
49434
|
+
);
|
|
49435
|
+
return;
|
|
49436
|
+
}
|
|
49437
|
+
await run(
|
|
49438
|
+
ctx2,
|
|
49439
|
+
async () => {
|
|
49440
|
+
if (options.action) {
|
|
49441
|
+
throw new ClodableError({
|
|
49442
|
+
code: "invalid-config",
|
|
49443
|
+
message: `\u201C${options.action}\u201D isn't something backend does.`,
|
|
49444
|
+
hint: "Use clodable backend to see your choices, or clodable backend create."
|
|
49445
|
+
});
|
|
49446
|
+
}
|
|
49447
|
+
await ctx2.workspace();
|
|
49448
|
+
return backendChoices();
|
|
49449
|
+
},
|
|
49450
|
+
(choices) => {
|
|
49451
|
+
if (!choices.connected) {
|
|
49452
|
+
ctx2.out.line(ash("Supabase isn't connected on this computer."));
|
|
49453
|
+
return;
|
|
49454
|
+
}
|
|
49455
|
+
for (const org of choices.organizations ?? []) {
|
|
49456
|
+
ctx2.out.line(`${org.name} ${ash(`(${org.slug}) \xB7 ${choices.costs?.[org.slug] ?? ""}`)}`);
|
|
49457
|
+
}
|
|
49458
|
+
if (choices.region) ctx2.out.line(ash(`Suggested region: ${choices.region.name}`));
|
|
49459
|
+
}
|
|
49460
|
+
);
|
|
49461
|
+
}
|
|
49462
|
+
|
|
48285
49463
|
// src/commands/publish.ts
|
|
48286
49464
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
48287
49465
|
async function publishCommand(ctx2, options) {
|
|
@@ -48417,8 +49595,8 @@ async function settingsCommand(ctx2, options) {
|
|
|
48417
49595
|
}
|
|
48418
49596
|
|
|
48419
49597
|
// src/commands/setup.ts
|
|
48420
|
-
import { existsSync as
|
|
48421
|
-
import { join as
|
|
49598
|
+
import { existsSync as existsSync28, readdirSync } from "node:fs";
|
|
49599
|
+
import { join as join32, resolve as resolve8 } from "node:path";
|
|
48422
49600
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
48423
49601
|
var MIN_NODE = [20, 19];
|
|
48424
49602
|
var REQUIRED = ["node", "git", "gh", "github"];
|
|
@@ -48430,6 +49608,14 @@ async function doctor(cwd2) {
|
|
|
48430
49608
|
const parsed = remote ? parseGitHubRemote(remote) : void 0;
|
|
48431
49609
|
const fake = process.env.CLODABLE_FAKE_GITHUB;
|
|
48432
49610
|
const standIn = Boolean(fake && remote && resolve8(cwd2, remote) === resolve8(fake));
|
|
49611
|
+
const pending = await pendingNewApp(cwd2);
|
|
49612
|
+
if (pending)
|
|
49613
|
+
items.push({
|
|
49614
|
+
id: "new-app",
|
|
49615
|
+
label: "Saving setup",
|
|
49616
|
+
status: "info",
|
|
49617
|
+
detail: `${pending.account}/${pending.name}`
|
|
49618
|
+
});
|
|
48433
49619
|
items.push({
|
|
48434
49620
|
id: "repo",
|
|
48435
49621
|
label: "Your app on GitHub",
|
|
@@ -48480,7 +49666,9 @@ async function toolChecks(cwd2) {
|
|
|
48480
49666
|
id: "gh",
|
|
48481
49667
|
label: "GitHub CLI",
|
|
48482
49668
|
status: ready2.installed ? "ok" : "fail",
|
|
48483
|
-
...ready2.installed ? {
|
|
49669
|
+
...ready2.installed ? await ghIsOurs() ? { detail: `${GH_VERSION}, Clodable's own` } : {} : {
|
|
49670
|
+
fix: "Check your internet connection: Clodable downloads it. Or install it from https://cli.github.com"
|
|
49671
|
+
}
|
|
48484
49672
|
});
|
|
48485
49673
|
if (ready2.installed) {
|
|
48486
49674
|
let login;
|
|
@@ -48506,12 +49694,12 @@ async function appChecks(git) {
|
|
|
48506
49694
|
status: project.appType === "unknown" ? "warn" : "ok",
|
|
48507
49695
|
detail: `${typeLabel}${project.lovable.generated ? ", made with Lovable" : ""}`
|
|
48508
49696
|
});
|
|
48509
|
-
const installed =
|
|
49697
|
+
const installed = existsSync28(join32(root, "node_modules"));
|
|
48510
49698
|
items.push({
|
|
48511
49699
|
id: "deps",
|
|
48512
49700
|
label: "App dependencies",
|
|
48513
49701
|
status: installed ? "ok" : "warn",
|
|
48514
|
-
...installed ? {} : { fix: `Run \`${project
|
|
49702
|
+
...installed ? {} : { fix: `Run \`${await packageManagerHere(project)} install\`` }
|
|
48515
49703
|
});
|
|
48516
49704
|
const config2 = await loadConfig(root);
|
|
48517
49705
|
const kit = await planKit(project, config2);
|
|
@@ -48628,11 +49816,10 @@ async function kitCommand(ctx2, options) {
|
|
|
48628
49816
|
ctx2,
|
|
48629
49817
|
async () => {
|
|
48630
49818
|
const ws = await ctx2.workspace({ requireSetup: false });
|
|
48631
|
-
full = await planKit(
|
|
48632
|
-
|
|
48633
|
-
|
|
48634
|
-
|
|
48635
|
-
);
|
|
49819
|
+
full = await planKit(ws.project, ws.config, {
|
|
49820
|
+
liveUrl: options.liveUrl,
|
|
49821
|
+
runtimeOnly: options.runtime
|
|
49822
|
+
});
|
|
48636
49823
|
if (options.apply) await applyKit(ws.root, full);
|
|
48637
49824
|
return {
|
|
48638
49825
|
applied: Boolean(options.apply),
|
|
@@ -48675,6 +49862,11 @@ async function whereItRuns(project, current) {
|
|
|
48675
49862
|
value: "github",
|
|
48676
49863
|
label: "Elsewhere (Netlify, Vercel\u2026)",
|
|
48677
49864
|
hint: "it updates when GitHub changes"
|
|
49865
|
+
},
|
|
49866
|
+
{
|
|
49867
|
+
value: "none",
|
|
49868
|
+
label: "Not online yet",
|
|
49869
|
+
hint: "Clodable can put it on your own Netlify"
|
|
48678
49870
|
}
|
|
48679
49871
|
]
|
|
48680
49872
|
});
|
|
@@ -48682,10 +49874,20 @@ async function whereItRuns(project, current) {
|
|
|
48682
49874
|
}
|
|
48683
49875
|
return { backend, hosting };
|
|
48684
49876
|
}
|
|
49877
|
+
function panelStep(ctx2, id, state, title) {
|
|
49878
|
+
if (ctx2.out.json) ctx2.out.event(step(id, state, title));
|
|
49879
|
+
}
|
|
48685
49880
|
async function requireTools(ctx2) {
|
|
49881
|
+
panelStep(ctx2, "setup:tools", "running", "Checking your tools");
|
|
48686
49882
|
const tools = (await toolChecks(ctx2.cwd)).filter((t2) => REQUIRED.includes(t2.id));
|
|
48687
49883
|
if (!ctx2.out.json) for (const tool2 of tools) doctorLine(ctx2, tool2);
|
|
48688
49884
|
const blocking = tools.filter((t2) => t2.status === "fail");
|
|
49885
|
+
panelStep(
|
|
49886
|
+
ctx2,
|
|
49887
|
+
"setup:tools",
|
|
49888
|
+
blocking.length > 0 ? "failed" : "done",
|
|
49889
|
+
blocking.length > 0 ? "A few tools are needed first" : "Your tools are ready"
|
|
49890
|
+
);
|
|
48689
49891
|
if (blocking.length > 0) {
|
|
48690
49892
|
throw new ClodableError({
|
|
48691
49893
|
code: blocking.some((b) => b.id === "github") ? "gh-auth" : "gh-missing",
|
|
@@ -48711,15 +49913,14 @@ async function pickRepo(ctx2, given, interactive) {
|
|
|
48711
49913
|
hint: "Run `clodable setup --repo owner/name`."
|
|
48712
49914
|
});
|
|
48713
49915
|
}
|
|
48714
|
-
async function bringIn(ctx2, repo
|
|
49916
|
+
async function bringIn(ctx2, repo) {
|
|
48715
49917
|
const empty = readdirSync(ctx2.cwd).filter((n4) => !n4.startsWith(".")).length === 0;
|
|
48716
|
-
const target = empty ? ctx2.cwd :
|
|
48717
|
-
|
|
48718
|
-
s?.start(`Bringing in ${repo}`);
|
|
49918
|
+
const target = empty ? ctx2.cwd : join32(ctx2.cwd, repo.split("/")[1]);
|
|
49919
|
+
ctx2.out.event(step("setup:app", "running", `Bringing in ${repo}`));
|
|
48719
49920
|
try {
|
|
48720
49921
|
await new GhCli(ctx2.cwd).clone(repo, target);
|
|
48721
49922
|
} catch (error62) {
|
|
48722
|
-
|
|
49923
|
+
ctx2.out.event(step("setup:app", "failed", `Couldn't bring in ${repo}`));
|
|
48723
49924
|
if (error62 instanceof ClodableError && error62.code !== "unknown") throw error62;
|
|
48724
49925
|
throw new ClodableError({
|
|
48725
49926
|
code: "not-found",
|
|
@@ -48727,7 +49928,7 @@ async function bringIn(ctx2, repo, interactive) {
|
|
|
48727
49928
|
details: error62 instanceof ClodableError ? error62.details : messageOf(error62)
|
|
48728
49929
|
});
|
|
48729
49930
|
}
|
|
48730
|
-
|
|
49931
|
+
ctx2.out.event(step("setup:app", "done", `Brought in ${repo}`));
|
|
48731
49932
|
return target;
|
|
48732
49933
|
}
|
|
48733
49934
|
async function setupCommand(ctx2, options) {
|
|
@@ -48738,14 +49939,25 @@ async function setupCommand(ctx2, options) {
|
|
|
48738
49939
|
ctx2.out.header("let's bring your app home");
|
|
48739
49940
|
await requireTools(ctx2);
|
|
48740
49941
|
const git = new Git(ctx2.cwd);
|
|
48741
|
-
|
|
49942
|
+
if (options.new !== void 0 && (!options.account || options.repo || options.publish)) {
|
|
49943
|
+
throw new ClodableError({
|
|
49944
|
+
code: "invalid-config",
|
|
49945
|
+
message: "Choose the account for your new private app in Set up saving. Publishing comes later."
|
|
49946
|
+
});
|
|
49947
|
+
}
|
|
49948
|
+
const started = options.new !== void 0 ? await drive(
|
|
49949
|
+
ctx2,
|
|
49950
|
+
prepareNewApp(ctx2.cwd, { name: options.new, account: options.account }, ctx2.github)
|
|
49951
|
+
) : void 0;
|
|
49952
|
+
const root = started?.root ?? (await git.isRepo() ? await git.root() : await bringIn(ctx2, await pickRepo(ctx2, options.repo, interactive)));
|
|
48742
49953
|
const project = await detectProject(root);
|
|
48743
49954
|
const loaded = await loadConfig(root);
|
|
48744
49955
|
const config2 = {
|
|
48745
49956
|
...loaded,
|
|
49957
|
+
...started ? { liveBranch: started.liveBranch } : {},
|
|
48746
49958
|
...await whereItRuns(project, {
|
|
48747
|
-
backend: options.backend ?? loaded.backend,
|
|
48748
|
-
hosting: options.hosting ?? loaded.hosting,
|
|
49959
|
+
backend: options.backend ?? (started && !project.supabase.used ? "none" : loaded.backend),
|
|
49960
|
+
hosting: options.hosting ?? (started ? "none" : loaded.hosting),
|
|
48749
49961
|
interactive
|
|
48750
49962
|
})
|
|
48751
49963
|
};
|
|
@@ -48763,19 +49975,37 @@ async function setupCommand(ctx2, options) {
|
|
|
48763
49975
|
message: "Setup cancelled. Nothing was changed."
|
|
48764
49976
|
});
|
|
48765
49977
|
}
|
|
49978
|
+
panelStep(ctx2, "setup:files", "running", "Adding Clodable's files");
|
|
48766
49979
|
await applyKit(root, changes);
|
|
48767
|
-
|
|
48768
|
-
|
|
48769
|
-
|
|
48770
|
-
|
|
49980
|
+
panelStep(ctx2, "setup:files", "done", "Added Clodable's files");
|
|
49981
|
+
if (!existsSync28(join32(root, "node_modules"))) {
|
|
49982
|
+
ctx2.out.event(
|
|
49983
|
+
step("setup:packages", "running", "Installing your app's packages", "a minute or two")
|
|
49984
|
+
);
|
|
49985
|
+
const installed = await exec2(await packageManagerHere(project), ["install"], {
|
|
48771
49986
|
cwd: root,
|
|
48772
49987
|
timeout: 15 * 6e4
|
|
48773
49988
|
});
|
|
48774
|
-
|
|
48775
|
-
|
|
49989
|
+
ctx2.out.event(
|
|
49990
|
+
installed.exitCode === 0 ? step("setup:packages", "done", "Installed your app's packages") : step(
|
|
49991
|
+
"setup:packages",
|
|
49992
|
+
"warning",
|
|
49993
|
+
"Your app's packages didn't install",
|
|
49994
|
+
"ask Claude to install them"
|
|
49995
|
+
)
|
|
49996
|
+
);
|
|
48776
49997
|
}
|
|
49998
|
+
ctx2.out.event(step("setup:save", "running", "Saving it to your draft on GitHub"));
|
|
48777
49999
|
const ws = await Workspace.open({ cwd: root, ...ctx2.github ? { github: ctx2.github } : {} });
|
|
48778
50000
|
const saved = await save2(ws, { message: "Set up Clodable", kind: "setup" });
|
|
50001
|
+
ctx2.out.event(
|
|
50002
|
+
!saved.saved ? step("setup:save", "skipped", "Nothing new to save") : saved.pushed ? step("setup:save", "done", "Saved to your draft on GitHub") : step(
|
|
50003
|
+
"setup:save",
|
|
50004
|
+
"warning",
|
|
50005
|
+
"Saved on this computer",
|
|
50006
|
+
saved.unscanned ? "it goes to GitHub once it's checked for secret keys" : "it goes to GitHub once you're online"
|
|
50007
|
+
)
|
|
50008
|
+
);
|
|
48779
50009
|
let published = false;
|
|
48780
50010
|
if (saved.saved && (options.publish || interactive && await confirmPublish())) {
|
|
48781
50011
|
await drive(ctx2, publish(ws, { message: "Set up Clodable" }));
|
|
@@ -48786,6 +50016,7 @@ async function setupCommand(ctx2, options) {
|
|
|
48786
50016
|
appType: project.appType,
|
|
48787
50017
|
files: changes.filter((c2) => c2.action !== "unchanged").map((c2) => c2.path),
|
|
48788
50018
|
saved: saved.saved,
|
|
50019
|
+
pushed: saved.pushed,
|
|
48789
50020
|
published
|
|
48790
50021
|
};
|
|
48791
50022
|
},
|
|
@@ -48938,7 +50169,7 @@ async function inboxCommand(ctx2, options) {
|
|
|
48938
50169
|
}
|
|
48939
50170
|
|
|
48940
50171
|
// src/index.ts
|
|
48941
|
-
var version2 = true ? "0.
|
|
50172
|
+
var version2 = true ? "0.3.0" : "0.1.0-dev";
|
|
48942
50173
|
var cli = cac("clodable");
|
|
48943
50174
|
cli.option("--json", "Print one JSON event per line (for programs)");
|
|
48944
50175
|
cli.option("--cwd <dir>", "Run in another folder");
|
|
@@ -48961,19 +50192,21 @@ cli.command("history", "Your saves and publishes").option("--limit <n>", "How ma
|
|
|
48961
50192
|
(options) => historyCommand(ctx(options), { limit: options.limit ? Number(options.limit) : void 0 })
|
|
48962
50193
|
);
|
|
48963
50194
|
cli.command("check", "Run the publish checks without publishing").action((options) => checkCommand(ctx(options)));
|
|
48964
|
-
cli.command("setup", "Bring your app home: connect GitHub, add Clodable's files").option("--repo <owner/name>", "The GitHub repository of your app").option("-y, --yes", "Don't ask questions").option("--publish", "Publish the setup right away").option("--backend <where>", "Where the data lives: lovable-cloud, supabase or none").option("--hosting <where>", "Where the site is live: lovable or
|
|
50195
|
+
cli.command("setup", "Bring your app home: connect GitHub, add Clodable's files").option("--repo <owner/name>", "The GitHub repository of your app").option("--new <name>", "Set up saving for a local prototype in a new private GitHub app").option("--account <login>", "The connected GitHub account approved for the new app").option("-y, --yes", "Don't ask questions").option("--publish", "Publish the setup right away").option("--backend <where>", "Where the data lives: lovable-cloud, supabase or none").option("--hosting <where>", "Where the site is live: lovable, github or none (not online yet)").action(
|
|
48965
50196
|
(options) => setupCommand(ctx(options), {
|
|
48966
50197
|
repo: options.repo,
|
|
50198
|
+
new: options.new,
|
|
50199
|
+
account: options.account,
|
|
48967
50200
|
yes: options.yes,
|
|
48968
50201
|
publish: options.publish,
|
|
48969
50202
|
...["lovable-cloud", "supabase", "none"].includes(options.backend) ? { backend: options.backend } : {},
|
|
48970
|
-
...["lovable", "github"].includes(options.hosting) ? { hosting: options.hosting } : {}
|
|
50203
|
+
...["lovable", "github", "none"].includes(options.hosting) ? { hosting: options.hosting } : {}
|
|
48971
50204
|
})
|
|
48972
50205
|
);
|
|
48973
50206
|
cli.command("doctor", "Check that everything Clodable needs is in place").action((options) => doctorCommand(ctx(options)));
|
|
48974
50207
|
cli.command(
|
|
48975
50208
|
"config [key] [value]",
|
|
48976
|
-
"Read or change where your app runs: backend (lovable-cloud, supabase, none), hosting (lovable, github)"
|
|
50209
|
+
"Read or change where your app runs: backend (lovable-cloud, supabase, none), hosting (lovable, github, none)"
|
|
48977
50210
|
).action((key2, value, options) => configCommand(ctx(options), { key: key2, value }));
|
|
48978
50211
|
cli.command(
|
|
48979
50212
|
"settings",
|
|
@@ -48986,12 +50219,32 @@ cli.command(
|
|
|
48986
50219
|
).action(
|
|
48987
50220
|
(action, arg, options) => dbCommand(ctx(options), { action: String(action), ...arg ? { arg: String(arg) } : {} })
|
|
48988
50221
|
);
|
|
50222
|
+
cli.command(
|
|
50223
|
+
"connect <service>",
|
|
50224
|
+
"Connect supabase or netlify on this computer, the token piped in (for a new backend or site)"
|
|
50225
|
+
).action((service, options) => connectCommand(ctx(options), String(service)));
|
|
50226
|
+
cli.command("site [action]", "Your app's site: status, create hosting, or reconnect publishing").option("--team <slug>", "create: the Netlify team the site goes in").action(
|
|
50227
|
+
(action, options) => siteCommand(ctx(options), {
|
|
50228
|
+
...action ? { action: String(action) } : {},
|
|
50229
|
+
...options.team ? { team: String(options.team) } : {}
|
|
50230
|
+
})
|
|
50231
|
+
);
|
|
50232
|
+
cli.command(
|
|
50233
|
+
"backend [action]",
|
|
50234
|
+
"Your app's backend: the choices, or create: a new one on your own Supabase"
|
|
50235
|
+
).option("--org <slug>", "create: the Supabase organization").option("--region <code>", "create: where it runs (eu-central-1\u2026)").action(
|
|
50236
|
+
(action, options) => backendCommand(ctx(options), {
|
|
50237
|
+
...action ? { action: String(action) } : {},
|
|
50238
|
+
...options.org ? { org: String(options.org) } : {},
|
|
50239
|
+
...options.region ? { region: String(options.region) } : {}
|
|
50240
|
+
})
|
|
50241
|
+
);
|
|
48989
50242
|
var text = (value) => value === void 0 || value === false || value === "" ? void 0 : String(value);
|
|
48990
50243
|
var yes = (value) => value === void 0 ? void 0 : !/^(no|false|0)$/i.test(String(value));
|
|
48991
50244
|
cli.command("move [step] [arg]", MOVE_HELP).option("--org <slug>", "create: the Supabase organization").option("--region <code>", "create: where it runs (eu-central-1\u2026)").option("--name <name>", "create: the project's name").option("--file <path>", "export: the zip Lovable gave (else the newest in Downloads)").option("--private", "files: read Lovable Cloud's service key from stdin, for private folders").option("--fix", "diagnose: apply Clodable's own fixes on the copy").option("--account <slug>", "site: the Netlify team the site goes in").option("--domain <domain>", "emails: the domain emails come from").option("--sender <address>", "emails: the sender address (no-reply@ the domain by default)").option(
|
|
48992
50245
|
"--skip",
|
|
48993
50246
|
"emails: go live without emails of your own for now; domain: keep the Netlify address; settings, secrets, vault: go on without the ones left"
|
|
48994
|
-
).option("--hook", "emails: send sign-in emails through the app's own templates (auth-email-hook)").option("--set", "facts: record
|
|
50247
|
+
).option("--hook", "emails: send sign-in emails through the app's own templates (auth-email-hook)").option("--set", "facts/rehearsal: record app facts or dated copy checks (JSON on stdin)").option("--sign-up <yes|no>", "golive: whether anyone may sign up (no: only invited people)").option("--confirm-email <yes|no>", "golive: whether new people confirm their email first").action(
|
|
48995
50248
|
(step2, arg, options) => moveCommand(ctx(options), {
|
|
48996
50249
|
step: text(step2) ?? "check",
|
|
48997
50250
|
arg: text(arg),
|
|
@@ -49011,8 +50264,12 @@ cli.command("move [step] [arg]", MOVE_HELP).option("--org <slug>", "create: the
|
|
|
49011
50264
|
confirmEmail: yes(options.confirmEmail)
|
|
49012
50265
|
})
|
|
49013
50266
|
);
|
|
49014
|
-
cli.command("kit", "Show (or add) the files Clodable keeps in your project").option("--apply", "Write them").option("--live-url <url>", "Your live site's address").action(
|
|
49015
|
-
(options) => kitCommand(ctx(options), {
|
|
50267
|
+
cli.command("kit", "Show (or add) the files Clodable keeps in your project").option("--apply", "Write them").option("--runtime", "Refresh only the installed runtime and its instructions").option("--live-url <url>", "Your live site's address").action(
|
|
50268
|
+
(options) => kitCommand(ctx(options), {
|
|
50269
|
+
apply: options.apply,
|
|
50270
|
+
liveUrl: options.liveUrl,
|
|
50271
|
+
runtime: options.runtime
|
|
50272
|
+
})
|
|
49016
50273
|
);
|
|
49017
50274
|
cli.command("inbox", "Requests from the preview toolbar (for front ends)").option("--ack <id>", "Mark one as handled").option(
|
|
49018
50275
|
"--claim <session>",
|