@mediamonks/canopy-cli 0.7.62 → 0.7.64

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.
@@ -4,7 +4,7 @@ import { i as reportErrors, n as formatDateTime, o as spinner$1, s as unwrap } f
4
4
  import { n as migrateProject, r as readMigrationFiles, t as describeMigrateResult } from "./migrations-Bmid64rT.mjs";
5
5
  import { builtinModules } from "node:module";
6
6
  import { defineCommand } from "citty";
7
- import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
7
+ import { mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { tmpdir } from "node:os";
9
9
  import { join, relative, resolve } from "node:path";
10
10
  import { spawn } from "node:child_process";
@@ -14,12 +14,14 @@ import { createHash } from "node:crypto";
14
14
  //#region src/worker-bundle.ts
15
15
  /**
16
16
  * Bundle a project's `worker/` entry for deploy (G6).
17
- * Output is a single ESM file uploaded as `_canopy/worker.mjs`.
17
+ * Output is one ESM file uploaded as `_canopy/worker.mjs`, plus each imported
18
+ * `.wasm` file uploaded as `_canopy/wasm/<hash>.wasm` (worker-wasm-modules).
18
19
  */
19
20
  async function bundleWorker(projectDir, entry) {
20
21
  const abs = resolve(projectDir, entry);
21
22
  const outDir = mkdtempSync(join(tmpdir(), "canopy-worker-"));
22
23
  const outfile = join(outDir, "worker.mjs");
24
+ const wasm = /* @__PURE__ */ new Map();
23
25
  try {
24
26
  await esbuild.build({
25
27
  entryPoints: [abs],
@@ -29,10 +31,13 @@ async function bundleWorker(projectDir, entry) {
29
31
  format: "esm",
30
32
  target: "es2022",
31
33
  packages: "bundle",
32
- plugins: [nodeBuiltins],
34
+ plugins: [nodeBuiltins, wasmModules(projectDir, wasm)],
33
35
  logLevel: "silent"
34
36
  });
35
- return new Uint8Array(readFileSync(outfile));
37
+ return {
38
+ code: new Uint8Array(readFileSync(outfile)),
39
+ wasm: [...wasm.values()]
40
+ };
36
41
  } finally {
37
42
  rmSync(outDir, {
38
43
  recursive: true,
@@ -149,6 +154,46 @@ const nodeBuiltins = {
149
154
  }));
150
155
  }
151
156
  };
157
+ const WASM_IMPORT = /\.wasm(\?module)?$/;
158
+ /**
159
+ * `import mod from "./x.wasm"` (or `x.wasm?module`, or a dependency's
160
+ * `pkg/x_bg.wasm`) gives a compiled `WebAssembly.Module`, as wrangler's
161
+ * default CompiledWasm rule does: the deployed runtime refuses to compile wasm
162
+ * from bytes, so the file ships beside the bundle and each host installs it as
163
+ * a wasm module. Named by content hash, so the same file imported twice ships
164
+ * once and no `node_modules` path reaches a module name.
165
+ */
166
+ function wasmModules(projectDir, found) {
167
+ return {
168
+ name: "canopy-wasm-modules",
169
+ setup(build) {
170
+ build.onResolve({ filter: WASM_IMPORT }, async (args) => {
171
+ if (args.pluginData === "canopy-wasm") return void 0;
172
+ const resolved = await build.resolve(args.path.replace(/\?module$/, ""), {
173
+ kind: args.kind,
174
+ resolveDir: args.resolveDir,
175
+ importer: args.importer,
176
+ pluginData: "canopy-wasm"
177
+ });
178
+ if (resolved.errors.length > 0) return { errors: resolved.errors };
179
+ const data = new Uint8Array(readFileSync(resolved.path));
180
+ const name = `${createHash("sha256").update(data).digest("hex").slice(0, 16)}.wasm`;
181
+ if (!found.has(name)) {
182
+ const source = relative(realpathSync(projectDir), resolved.path);
183
+ found.set(name, {
184
+ name,
185
+ source,
186
+ data
187
+ });
188
+ }
189
+ return {
190
+ path: `./wasm/${name}`,
191
+ external: true
192
+ };
193
+ });
194
+ }
195
+ };
196
+ }
152
197
  //#endregion
153
198
  //#region src/media.ts
154
199
  /**
@@ -416,6 +461,8 @@ function describeMediaSync(plan, pruned, opts) {
416
461
  */
417
462
  /** Must match apps/api/src/routes/deploys.ts WORKER_BUNDLE_PATH. */
418
463
  const WORKER_BUNDLE_PATH = "_canopy/worker.mjs";
464
+ /** Must match apps/api/src/storage-keys.ts WORKER_WASM_PATH_PREFIX. */
465
+ const WORKER_WASM_PATH_PREFIX = "_canopy/wasm/";
419
466
  const IGNORED = /* @__PURE__ */ new Set([
420
467
  "canopy.json",
421
468
  "AGENTS.md",
@@ -545,15 +592,18 @@ const deployCommand = defineCommand({
545
592
  path: f.path,
546
593
  size: f.data.byteLength
547
594
  })), mediaFolders);
548
- let workerBytes = null;
595
+ let worker = null;
596
+ let workerBytes = 0;
549
597
  if (config.worker && !args.worker) p.log.warn(`Skipping the backend (${config.worker}) — deploying the frontend only.`);
550
598
  if (config.worker && args.worker) {
551
599
  const spinWorker = spinner$1();
552
600
  spinWorker.start(`Bundling worker ${config.worker}`);
553
601
  try {
554
- workerBytes = await bundleWorker(dir, config.worker);
555
- total += workerBytes.byteLength;
556
- spinWorker.stop(`Worker bundle ${(workerBytes.byteLength / 1024).toFixed(1)} kB`);
602
+ worker = await bundleWorker(dir, config.worker);
603
+ workerBytes = workerSize(worker);
604
+ total += workerBytes;
605
+ const wasmNote = worker.wasm.length > 0 ? ` (${worker.wasm.length} WebAssembly module${worker.wasm.length === 1 ? "" : "s"})` : "";
606
+ spinWorker.stop(`Worker bundle ${formatSize(workerBytes)}${wasmNote}`);
557
607
  } catch (err) {
558
608
  spinWorker.error("Worker bundle failed.");
559
609
  throw err;
@@ -561,9 +611,9 @@ const deployCommand = defineCommand({
561
611
  }
562
612
  const source = onGithubActions() ? { "x-canopy-source": "github-action" } : {};
563
613
  const spin = spinner$1();
564
- const workerNote = workerBytes ? " + worker" : "";
614
+ const workerNote = worker ? " + worker" : "";
565
615
  const channelNote = channel === "staging" ? " [staging]" : "";
566
- const mediaNote = media.length > 0 ? ` + ${media.length} media files (${formatSize(total - bundleBytes - (workerBytes?.byteLength ?? 0))})` : "";
616
+ const mediaNote = media.length > 0 ? ` + ${media.length} media files (${formatSize(total - bundleBytes - workerBytes)})` : "";
567
617
  spin.start(`Deploying ${bundle.length} files${workerNote} (${(bundleBytes / 1024).toFixed(0)} kB)${mediaNote} → ${slug}${channelNote}`);
568
618
  let mediaReport = [];
569
619
  let result;
@@ -573,7 +623,7 @@ const deployCommand = defineCommand({
573
623
  let limitsSeen = {};
574
624
  try {
575
625
  const { upload, retention } = await withContext(apiRequest("POST", `/projects/${slug}/deploys`, {
576
- worker: workerBytes !== null,
626
+ worker: worker !== null,
577
627
  channel,
578
628
  ...mediaFolders.length > 0 && { media: mediaFolders }
579
629
  }, { headers: source }), { action: `deploy "${slug}"` });
@@ -591,6 +641,13 @@ const deployCommand = defineCommand({
591
641
  files: bundle.length
592
642
  }, upload, mediaFolders)}`);
593
643
  }
644
+ if (worker) {
645
+ const workerRefusal = workerLimitError(worker, upload.maxWorkerBytes);
646
+ if (workerRefusal) {
647
+ spin.error("Deploy refused — nothing was uploaded.");
648
+ throw new Error(workerRefusal);
649
+ }
650
+ }
594
651
  if (mediaFolders.length > 0 && !upload.media) {
595
652
  spin.error("Deploy refused — nothing was uploaded.");
596
653
  throw new Error("This site doesn't support site media yet. Take \"media\" out of canopy.json to deploy those folders as part of the version.");
@@ -620,10 +677,13 @@ const deployCommand = defineCommand({
620
677
  createOnly: upload.media.createOnly
621
678
  });
622
679
  }
623
- const uploads = [...bundle, ...workerBytes ? [{
680
+ const uploads = [...bundle, ...worker ? [{
624
681
  path: WORKER_BUNDLE_PATH,
625
- data: workerBytes
626
- }] : []];
682
+ data: worker.code
683
+ }, ...worker.wasm.map((m) => ({
684
+ path: `${WORKER_WASM_PATH_PREFIX}${m.name}`,
685
+ data: m.data
686
+ }))] : []];
627
687
  await uploadFiles(upload.grant, uploads);
628
688
  if (migrations !== void 0 && migrations.length > 0) {
629
689
  spin.message(`Applying schema migrations → ${slug}${channelNote}`);
@@ -728,6 +788,26 @@ const UPLOAD_CONCURRENCY = 8;
728
788
  * worker bundle has its own key and isn't counted, as on the server. A server
729
789
  * that states no limits isn't checked here; completion still enforces them.
730
790
  */
791
+ /** A worker's size as the platform counts it: the bundle plus every wasm module, uncompressed. */
792
+ function workerSize(worker) {
793
+ return worker.code.byteLength + worker.wasm.reduce((sum, m) => sum + m.data.byteLength, 0);
794
+ }
795
+ /**
796
+ * Refuse a worker the platform would refuse (worker-wasm-modules), before
797
+ * anything is uploaded: over the stated size, or carrying WebAssembly to a
798
+ * site that predates it (no `maxWorkerBytes` in the grant).
799
+ */
800
+ function workerLimitError(worker, maxWorkerBytes) {
801
+ if (maxWorkerBytes === void 0) return worker.wasm.length > 0 ? "This site doesn't support WebAssembly in the backend yet. Remove the .wasm imports from the worker, or deploy to a site that has it." : null;
802
+ const bytes = workerSize(worker);
803
+ if (bytes <= maxWorkerBytes) return null;
804
+ const largest = [...worker.wasm].sort((a, b) => b.data.byteLength - a.data.byteLength).slice(0, 3).map((m) => ` ${m.source} ${formatSize(m.data.byteLength)}`);
805
+ return [
806
+ `The backend worker is ${formatSize(bytes)}; the limit is ${formatSize(maxWorkerBytes)} (code plus WebAssembly modules).`,
807
+ ` worker code ${formatSize(worker.code.byteLength)}`,
808
+ ...largest
809
+ ].join("\n");
810
+ }
731
811
  function bundleLimitError(files, limits) {
732
812
  if (limits.maxFiles !== void 0 && files.length > limits.maxFiles) return `This deploy has ${files.length} files; the limit is ${limits.maxFiles}.`;
733
813
  const bytes = files.reduce((sum, f) => sum + f.data.byteLength, 0);
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
107
107
  console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
108
108
  return;
109
109
  }
110
- const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-DEK8fOgz.mjs");
110
+ const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-Dqj7TnAk.mjs");
111
111
  const secrets = readDevVars(flags.dir);
112
112
  const email = siteConfig().email;
113
113
  const found = await remoteUser?.() ?? (email ? {
@@ -326,7 +326,7 @@ async function devRemote(flags, slug) {
326
326
  async function devLocal(flags, slug) {
327
327
  let dump;
328
328
  if (flags.pull) {
329
- const { fetchProjectDump } = await import("./local-BZWFMNJI.mjs");
329
+ const { fetchProjectDump } = await import("./local-BJ1RM1Wb.mjs");
330
330
  console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
331
331
  dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
332
332
  }
@@ -343,7 +343,7 @@ async function devLocal(flags, slug) {
343
343
  }
344
344
  const workerAttest = randomBytes(24).toString("base64url");
345
345
  const devRoles = await resolveDevRoles(slug, flags.asRoles);
346
- const { createSandbox } = await import("./local-BZWFMNJI.mjs");
346
+ const { createSandbox } = await import("./local-BJ1RM1Wb.mjs");
347
347
  const sandbox = await createSandbox({
348
348
  slug,
349
349
  persistDir: join(flags.dir, ".canopy", "local"),
@@ -0,0 +1,2 @@
1
+ import { n as devCommand } from "./dev-CT2_x96K.mjs";
2
+ export { devCommand };
@@ -296,6 +296,17 @@ async function sendResponse(res, response) {
296
296
  res.writeHead(response.status, headers);
297
297
  res.end(Buffer.from(await response.arrayBuffer()));
298
298
  }
299
+ const WASM_IMPORT = /\.wasm(\?module)?$/;
300
+ const WASM_MODULE_PREFIX = "\0canopy-wasm:";
301
+ /** The module a worker's `.wasm` import loads as in dev: the compiled file, read at load. */
302
+ function wasmModuleSource(file) {
303
+ return `import { readFileSync } from "node:fs";\nexport default new WebAssembly.Module(readFileSync(${JSON.stringify(file)}));\n`;
304
+ }
305
+ /** Whether a resolve happens in the server (SSR) graph, where the worker lives; the SPA keeps Vite's own handling. */
306
+ function isServerGraph(ctx, opts) {
307
+ if (opts?.ssr) return true;
308
+ return ctx.environment?.config?.consumer === "server";
309
+ }
299
310
  /**
300
311
  * Serves the project's worker from the Vite dev server. Installed `pre` so
301
312
  * `/api/*` is answered before Vite's SPA fallback claims it — the same
@@ -307,6 +318,19 @@ function workerDevPlugin(options) {
307
318
  const canopyFetch = createCanopyFetch(() => apiBase, options.slug, options.channel, fetch, options.workerAttest);
308
319
  return {
309
320
  name: "canopy-project-worker",
321
+ enforce: "pre",
322
+ async resolveId(source, importer, opts) {
323
+ if (!WASM_IMPORT.test(source) || !isServerGraph(this, opts)) return null;
324
+ const resolved = await this.resolve(source.replace(/\?module$/, ""), importer, {
325
+ ...opts,
326
+ skipSelf: true
327
+ });
328
+ return resolved ? `${WASM_MODULE_PREFIX}${resolved.id}` : null;
329
+ },
330
+ load(id) {
331
+ if (!id.startsWith(WASM_MODULE_PREFIX)) return null;
332
+ return wasmModuleSource(id.slice(13));
333
+ },
310
334
  configureServer(server) {
311
335
  const load = async () => {
312
336
  const handler = (await server.ssrLoadModule(moduleId)).default;
@@ -27,7 +27,7 @@ canopy deploy --project my-app ./out
27
27
 
28
28
  1. **Build.** If `canopy.json` has a `build` command and you didn't pass `--no-build`, it runs in the project directory with your shell; a non-zero exit aborts the deploy.
29
29
  2. **Collect files.** Everything under the `dist` directory from `canopy.json` (default: the project directory itself) is gathered, skipping `canopy.json`, `README.md`, `AGENTS.md`, `CLAUDE.md`, `.gitignore`, `.DS_Store`, and any dot-directories plus `.git`, `node_modules`, and `.claude`. An empty or missing output directory is an error.
30
- 3. **Bundle the backend (if any).** When `canopy.json` names a `worker` entry, that backend code is bundled into a single file (dependencies included) and ships in the same version as the static files — frontend and backend always move together.
30
+ 3. **Bundle the backend (if any).** When `canopy.json` names a `worker` entry, that backend code is bundled into a single file (dependencies included) and ships in the same version as the static files — frontend and backend always move together. Any `.wasm` files the backend imports ship beside it as [WebAssembly modules](https://docs.canopy.website/developers/architecture#webassembly). A backend over the [size limit](https://docs.canopy.website/developers/architecture#limits) (32 MB, code plus WebAssembly) is refused before anything is uploaded.
31
31
  4. **Site media (if declared).** Folders listed in `canopy.json` `"media"` don't go into the version. The CLI compares them with what the project already stores and uploads only new and changed files; unchanged ones cost nothing. They are live as soon as they are uploaded. One line reports what happened, e.g. `media: 3 uploaded, 3,255 unchanged, 175 MB stored`.
32
32
  5. **Upload.** The files upload in parallel; the new version is staged alongside the old one, so the live site keeps serving until everything has arrived.
33
33
  6. **Migrate (if configured).** With a `"migrations"` directory in `canopy.json`, pending schema migrations apply now — after the bundle is staged, before the version flips — so the incoming code never runs against the old schema. The platform stores an automatic pre-migrate snapshot first. If a migration fails, the deploy aborts and the live version is unchanged; the error names the snapshot to restore if needed.
@@ -17,6 +17,7 @@ canopy preview off
17
17
  canopy preview image <file>
18
18
  canopy preview image --remove
19
19
  canopy preview icon <file>
20
+ canopy preview icon <svg-file> --png <png-file>
20
21
  canopy preview icon --remove
21
22
  ```
22
23
 
@@ -37,16 +38,20 @@ them.
37
38
  - `icon <file>`: a square logo for the browser tab and the dashboard. PNG,
38
39
  WebP, ICO or SVG, up to 256 KB. An SVG with scripts, event handlers,
39
40
  embedded HTML or links to other files is refused. `--remove` takes it away.
41
+ - `--png <file>` (with `icon`): a PNG version of an SVG icon. Chat apps don't
42
+ show SVG icons, so without one shared links show no icon. The dashboard
43
+ makes it for you when you upload the SVG there.
40
44
 
41
45
  ## Examples
42
46
 
43
47
  ```bash
44
- canopy preview icon logo.svg
48
+ canopy preview icon logo.svg --png logo.png
45
49
  canopy preview image card.png
46
50
  canopy preview on
47
51
  ```
48
52
 
49
- Sets an icon and a preview image, then turns the preview on.
53
+ Sets an SVG icon with its PNG version for chat apps and a preview image, then
54
+ turns the preview on.
50
55
 
51
56
  ```bash
52
57
  canopy preview off --project retro-board
@@ -131,6 +131,54 @@ else is still static serving. A few things to know:
131
131
  `node:buffer`, `node:https`, …). `process.env` holds your secrets and the
132
132
  project's own names, never the platform's.
133
133
 
134
+ ### WebAssembly
135
+
136
+ A backend can use WebAssembly libraries, such as resvg-wasm (SVG to PNG),
137
+ harfbuzzjs (text shaping), quickjs-emscripten (sandboxed scripts) or image
138
+ codecs. Import the `.wasm` file and you get a compiled `WebAssembly.Module`,
139
+ ready to instantiate:
140
+
141
+ ```ts
142
+ import addWasm from "./add.wasm";
143
+
144
+ app.get("/api/add", async (c) => {
145
+ const { exports } = await WebAssembly.instantiate(addWasm, {});
146
+ return c.json({ sum: (exports.add as (a: number, b: number) => number)(2, 3) });
147
+ });
148
+ ```
149
+
150
+ - **Your own files and your dependencies' files both work.** A library's
151
+ `.wasm` file (`import wasm from "@resvg/resvg-wasm/index_bg.wasm"`) is
152
+ picked up the same way, and a `?module` suffix on the import means the same
153
+ thing.
154
+ - **Use the library's Workers setup.** Most libraries document an init call
155
+ that takes a `WebAssembly.Module` for Cloudflare Workers. That is the one to
156
+ follow. A setup that fetches the `.wasm` file by URL or reads it from disk
157
+ won't work.
158
+ - **Wasm can't be compiled from bytes at run time.** `WebAssembly.compile()`
159
+ or `WebAssembly.instantiate()` on raw bytes fails with "Wasm code generation
160
+ disallowed by embedder". Only imported files work.
161
+ - **`canopy deploy` ships each file with the backend**, as part of the same
162
+ version, so a rollback brings back the matching wasm too. `canopy dev` gives
163
+ the same import locally.
164
+
165
+ ### Limits
166
+
167
+ A backend runs within these limits on every site:
168
+
169
+ | Limit | Value | When it's exceeded |
170
+ | -------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- |
171
+ | Backend size | 32 MB: your bundled code plus its WebAssembly files, uncompressed | `canopy deploy` refuses before uploading and lists the largest files |
172
+ | Memory | 128 MB, shared by the requests one copy of your backend is handling | The request fails with an error |
173
+ | CPU time per request | 30 seconds | The request fails with an error |
174
+ | CPU time per scheduled run | 30 seconds | The run fails and shows in the schedule's history |
175
+ | Start-up | 1 second of CPU for your top-level code | The deploy or the first request fails |
176
+
177
+ CPU time counts only the time your code is working. Waiting on `fetch`, the
178
+ database or other calls doesn't count. Do heavy set-up, like instantiating a
179
+ large WebAssembly module, inside a handler or lazily on first use rather than
180
+ at the top of the file.
181
+
134
182
  > **Note:** Backends run on the `main` and `gcp-pilot` sites. On a site without backend support, a deploy that
135
183
  > includes one answers with a clear "not supported here" rather than failing obscurely;
136
184
  > frontend-only projects deploy everywhere.
@@ -51,3 +51,9 @@ their coloured initials.
51
51
  SVG icons must be plain pictures. An SVG with scripts, event handlers,
52
52
  embedded HTML or links to other files is refused; exporting it again from a
53
53
  design tool usually fixes that.
54
+
55
+ Chat apps don't show SVG icons. When you upload an SVG in Settings, the
56
+ dashboard also makes a PNG version for chat apps, and shared links use that.
57
+ If your SVG icon was added before that, or from the CLI, Settings shows a
58
+ **Make a PNG version** button. From the CLI, add one with
59
+ `canopy preview icon logo.svg --png logo.png`.
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Cc9gi9C-.mjs";
1
+ import { t as version } from "./package-B5JwwJRq.mjs";
2
2
  import { r as siteConfig } from "./site-Bz-fEyKS.mjs";
3
3
  import { i as latestKnownVersion, r as compareSemver } from "./version-check-CcsA1QjI.mjs";
4
4
  import { n as agentHeaders } from "./api-C2cvuMD1.mjs";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Cc9gi9C-.mjs";
1
+ import { t as version } from "./package-B5JwwJRq.mjs";
2
2
  import { f as resolveProject, g as tryResolveProject, h as tryReadCanopyJson, l as projectDirArgs, r as siteConfig } from "./site-Bz-fEyKS.mjs";
3
3
  import { a as apiRequest, c as credentials, i as apiDownload, o as apiUpload, s as commonHeaders } from "./api-C2cvuMD1.mjs";
4
4
  import { i as reportErrors, n as formatDateTime } from "./ui-CVzXhfWN.mjs";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as version } from "./package-Cc9gi9C-.mjs";
2
+ import { t as version } from "./package-B5JwwJRq.mjs";
3
3
  import { i as siteHeaderLine, n as setInvocationProfile } from "./site-Bz-fEyKS.mjs";
4
4
  import { a as notifyOfUpdate, o as runRefresh } from "./version-check-CcsA1QjI.mjs";
5
5
  import { defineCommand, runMain } from "citty";
@@ -59,12 +59,12 @@ const main = defineCommand({
59
59
  projects: () => import("./projects-B3ycJGaX.mjs").then((m) => m.projectsCommand),
60
60
  delete: () => import("./projects-B3ycJGaX.mjs").then((m) => m.deleteCommand),
61
61
  rename: () => import("./rename-BY2_4F4b.mjs").then((m) => m.renameCommand),
62
- dev: () => import("./dev-CiMcqGqA.mjs").then((m) => m.devCommand),
63
- deploy: () => import("./deploy-D57a-99C.mjs").then((m) => m.deployCommand),
64
- promote: () => import("./deploy-D57a-99C.mjs").then((m) => m.promoteCommand),
62
+ dev: () => import("./dev-CtXO9PIL.mjs").then((m) => m.devCommand),
63
+ deploy: () => import("./deploy-DOe7vPjH.mjs").then((m) => m.deployCommand),
64
+ promote: () => import("./deploy-DOe7vPjH.mjs").then((m) => m.promoteCommand),
65
65
  staging: () => import("./staging-CSv8OWNT.mjs").then((m) => m.stagingCommand),
66
- rollback: () => import("./deploy-D57a-99C.mjs").then((m) => m.rollbackCommand),
67
- download: () => import("./deploy-D57a-99C.mjs").then((m) => m.downloadCommand),
66
+ rollback: () => import("./deploy-DOe7vPjH.mjs").then((m) => m.rollbackCommand),
67
+ download: () => import("./deploy-DOe7vPjH.mjs").then((m) => m.downloadCommand),
68
68
  versions: () => import("./versions-DKVNY2Zo.mjs").then((m) => m.versionsCommand),
69
69
  token: () => import("./token-DakMHZEr.mjs").then((m) => m.tokenCommand),
70
70
  egress: () => import("./egress-bVy6U5ho.mjs").then((m) => m.egressCommand),
@@ -74,22 +74,22 @@ const main = defineCommand({
74
74
  roles: () => import("./roles-wEgE5ICf.mjs").then((m) => m.rolesCommand),
75
75
  members: () => import("./roles-wEgE5ICf.mjs").then((m) => m.membersCommand),
76
76
  schedule: () => import("./schedule-D6tTBal3.mjs").then((m) => m.scheduleCommand),
77
- feedback: () => import("./feedback-w28FscrZ.mjs").then((m) => m.feedbackCommand),
77
+ feedback: () => import("./feedback-eIZOXXg1.mjs").then((m) => m.feedbackCommand),
78
78
  db: () => import("./db-BKo39uJt.mjs").then((m) => m.dbCommand),
79
79
  files: () => import("./files-DVFs1rmn.mjs").then((m) => m.filesCommand),
80
80
  usage: () => import("./usage-DcDBqrLf.mjs").then((m) => m.usageCommand),
81
81
  ai: () => import("./ai-CGYbKeZq.mjs").then((m) => m.aiCommand),
82
82
  open: () => import("./open-B2fimu3z.mjs").then((m) => m.openCommand),
83
83
  browse: () => import("./browse-CAidI-BT.mjs").then((m) => m.browseCommand),
84
- docs: () => import("./docs-D1SWYMZ-.mjs").then((m) => m.docsCommand),
85
- skill: () => import("./skill-BUWRlQd3.mjs").then((m) => m.skillCommand),
86
- upgrade: () => import("./upgrade-B-ELQVun.mjs").then((m) => m.upgradeCommand),
84
+ docs: () => import("./docs-Cpk-qZkk.mjs").then((m) => m.docsCommand),
85
+ skill: () => import("./skill-Dv8e09Xl.mjs").then((m) => m.skillCommand),
86
+ upgrade: () => import("./upgrade-CryZqevW.mjs").then((m) => m.upgradeCommand),
87
87
  logs: () => import("./logs-DTXFm5DB.mjs").then((m) => m.logsCommand),
88
- mcp: () => import("./mcp-LQyQtnsW.mjs").then((m) => m.mcpCommand),
88
+ mcp: () => import("./mcp-BOzF_oAR.mjs").then((m) => m.mcpCommand),
89
89
  repo: () => import("./repo-xl6Rb6BC.mjs").then((m) => m.repoCommand),
90
90
  template: () => import("./project-template-Ckh8JDkS.mjs").then((m) => m.templateCommand),
91
91
  audience: () => import("./audience-BspIO-MA.mjs").then((m) => m.audienceCommand),
92
- preview: () => import("./preview-BRehGrPg.mjs").then((m) => m.previewCommand)
92
+ preview: () => import("./preview-C7AYjcx7.mjs").then((m) => m.previewCommand)
93
93
  }
94
94
  });
95
95
  const quiet = process.argv[2] === "mcp" && process.argv[3] === "serve" || process.argv[2] === "repo" && process.argv[3] === "credential";
@@ -1,6 +1,6 @@
1
1
  import { c as dbRouter, h as isCreateOnly, l as hasPrivateNames, m as blobRouter, p as STREAMED_BLOB_BYTES, s as realtimeRouter, t as WORKER_ATTEST_HEADER, u as META_COLUMNS } from "./src-Dlg7aeRj.mjs";
2
2
  import { r as apiDataRequest } from "./api-C2cvuMD1.mjs";
3
- import { a as rewriteApiPath } from "./dev-CtjY0gJX.mjs";
3
+ import { a as rewriteApiPath } from "./dev-CT2_x96K.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join, relative, sep } from "node:path";
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Cc9gi9C-.mjs";
1
+ import { t as version } from "./package-B5JwwJRq.mjs";
2
2
  import { d as projectUrl, g as tryResolveProject, m as stagingUrl, r as siteConfig } from "./site-Bz-fEyKS.mjs";
3
3
  import { a as apiRequest, f as noticeRenamesOnly, l as currentSlug, t as ApiError } from "./api-C2cvuMD1.mjs";
4
4
  import { t as liveDevServer } from "./dev-server-file-Dk9pk4AR.mjs";
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.7.62";
2
+ var version = "0.7.64";
3
3
  //#endregion
4
4
  export { version as t };
@@ -16,7 +16,8 @@ import * as p from "@clack/prompts";
16
16
  const FIXES = {
17
17
  unsupported_image_type: "A preview image must be PNG, JPEG or WebP; an icon PNG, WebP, ICO or SVG.",
18
18
  unsafe_svg: "Use a plain SVG: no scripts, event handlers, embedded HTML or links to other files. Exporting it again from a design tool usually does it.",
19
- image_too_large: "A preview image can be up to 1 MB, an icon up to 256 KB."
19
+ image_too_large: "A preview image can be up to 1 MB, an icon up to 256 KB.",
20
+ icon_not_svg: "The PNG version is only for an SVG icon; upload the PNG as the icon instead."
20
21
  };
21
22
  function size(bytes) {
22
23
  return bytes < 1024 * 1024 ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
@@ -36,7 +37,8 @@ function describePreview(slug, settings) {
36
37
  return [
37
38
  settings.link_preview ? `Link preview is on: shared links to ${slug} show its name, description, image and icon.` : `Link preview is off: shared links to ${slug} show "${slug} · Sign in · Canopy".`,
38
39
  fileLine("Preview image", settings.image),
39
- fileLine("Icon", settings.icon)
40
+ fileLine("Icon", settings.icon),
41
+ ...settings.icon?.content_type === "image/svg+xml" ? [settings.icon_png ? fileLine("Icon for chat apps", settings.icon_png) : "Icon for chat apps: none. Chat apps don't show SVG icons; add one with `canopy preview icon <svg> --png <png>`."] : []
40
42
  ];
41
43
  }
42
44
  /** A content-type hint from the file name; the platform reads the bytes anyway. */
@@ -94,6 +96,10 @@ function fileCommand(kind) {
94
96
  type: "boolean",
95
97
  description: `Remove the ${what}`
96
98
  },
99
+ ...kind === "icon" ? { png: {
100
+ type: "string",
101
+ description: "A PNG version of an SVG icon, for chat apps that don't show SVG"
102
+ } } : {},
97
103
  ...projectFlagArgs
98
104
  },
99
105
  run: reportErrors(`preview ${kind}`, async ({ args }) => {
@@ -113,6 +119,15 @@ function fileCommand(kind) {
113
119
  fixes: FIXES
114
120
  });
115
121
  p.log.success(fileLine(kind === "image" ? "Preview image" : "Icon", settings[kind]));
122
+ const png = args.png;
123
+ if (kind === "icon" && settings.icon?.content_type === "image/svg+xml") if (png) {
124
+ const withPng = await withContext(apiUpload(`/projects/${slug}/preview/icon-png`, new Uint8Array(readFileSync(png)), "image/png", "PUT"), {
125
+ action: `upload ${basename(png)}`,
126
+ fixes: FIXES
127
+ });
128
+ p.log.success(fileLine("Icon for chat apps", withPng.icon_png ?? null));
129
+ } else p.log.warn("Chat apps don't show SVG icons. Add a PNG version with --png <file>, or upload the icon in the dashboard, which makes one for you.");
130
+ else if (kind === "icon" && png) p.log.info("--png is only for an SVG icon; this icon already works in chat apps.");
116
131
  if (!settings.link_preview) p.log.info(kind === "icon" ? "It is the project's mark on the dashboard now. Shared links show it once you run `canopy preview on`." : "Shared links show it once you run `canopy preview on`.");
117
132
  })
118
133
  });
@@ -1,4 +1,4 @@
1
- import { t as version } from "./package-Cc9gi9C-.mjs";
1
+ import { t as version } from "./package-B5JwwJRq.mjs";
2
2
  import { i as reportErrors } from "./ui-CVzXhfWN.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  import { cpSync, existsSync, mkdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
@@ -112,7 +112,7 @@ const upgradeCommand = defineCommand({
112
112
  const spec = `${PACKAGE_NAME}@${args.version ?? "latest"}`;
113
113
  const command = pmCommand(pm);
114
114
  const cmd = installArgs(pm, spec);
115
- const { skillInstalled } = await import("./skill-BUWRlQd3.mjs");
115
+ const { skillInstalled } = await import("./skill-Dv8e09Xl.mjs");
116
116
  const { homedir } = await import("node:os");
117
117
  const refreshGlobal = skillInstalled(homedir());
118
118
  const refreshRepo = process.cwd() !== homedir() && skillInstalled(process.cwd());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediamonks/canopy-cli",
3
- "version": "0.7.62",
3
+ "version": "0.7.64",
4
4
  "description": "Canopy CLI — create, develop and deploy Canopy projects.",
5
5
  "bin": {
6
6
  "canopy": "./dist/index.mjs"
@@ -22,8 +22,8 @@
22
22
  "esbuild": "^0.28.1",
23
23
  "hono": "^4.8.0",
24
24
  "vite-server": "npm:vite@^7",
25
- "@mediamonks/canopy": "0.0.20",
26
- "@mediamonks/canopy-data-plane": "0.0.4"
25
+ "@mediamonks/canopy-data-plane": "0.0.4",
26
+ "@mediamonks/canopy": "0.0.20"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^24",
@@ -1,2 +0,0 @@
1
- import { n as devCommand } from "./dev-CtjY0gJX.mjs";
2
- export { devCommand };