@mediamonks/canopy-cli 0.7.63 → 0.7.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{deploy-D57a-99C.mjs → deploy-Bzr6p0nl.mjs} +106 -14
- package/dist/dev-Bv14Oar6.mjs +2 -0
- package/dist/{dev-CtjY0gJX.mjs → dev-PRvTQ7Cl.mjs} +3 -3
- package/dist/{dev-worker-DEK8fOgz.mjs → dev-worker-Bmea0X0L.mjs} +27 -0
- package/dist/docs/cli-deploy.md +1 -1
- package/dist/docs/developers-architecture.md +48 -0
- package/dist/{docs-HB4AzryH.mjs → docs-_Bb03nNw.mjs} +1 -1
- package/dist/{feedback-CD-it40n.mjs → feedback-m49QTrTe.mjs} +1 -1
- package/dist/index.mjs +11 -11
- package/dist/{local-BZWFMNJI.mjs → local-dg7vpGYM.mjs} +1 -1
- package/dist/{mcp-D8rMLltM.mjs → mcp-CC6yUXD0.mjs} +1 -1
- package/dist/{package-sCoeuYM_.mjs → package-DI8sTmYn.mjs} +1 -1
- package/dist/{skill-DIiVaOl6.mjs → skill-D50OjY5d.mjs} +1 -1
- package/dist/{upgrade-BHhEx9h6.mjs → upgrade-DWQ4ouir.mjs} +1 -1
- package/package.json +1 -1
- package/dist/dev-CiMcqGqA.mjs +0 -2
|
@@ -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
|
|
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],
|
|
@@ -28,11 +30,16 @@ async function bundleWorker(projectDir, entry) {
|
|
|
28
30
|
platform: "neutral",
|
|
29
31
|
format: "esm",
|
|
30
32
|
target: "es2022",
|
|
33
|
+
mainFields: ["module", "main"],
|
|
34
|
+
conditions: ["workerd", "worker"],
|
|
31
35
|
packages: "bundle",
|
|
32
|
-
plugins: [nodeBuiltins],
|
|
36
|
+
plugins: [nodeBuiltins, wasmModules(projectDir, wasm)],
|
|
33
37
|
logLevel: "silent"
|
|
34
38
|
});
|
|
35
|
-
return
|
|
39
|
+
return {
|
|
40
|
+
code: new Uint8Array(readFileSync(outfile)),
|
|
41
|
+
wasm: [...wasm.values()]
|
|
42
|
+
};
|
|
36
43
|
} finally {
|
|
37
44
|
rmSync(outDir, {
|
|
38
45
|
recursive: true,
|
|
@@ -149,6 +156,56 @@ const nodeBuiltins = {
|
|
|
149
156
|
}));
|
|
150
157
|
}
|
|
151
158
|
};
|
|
159
|
+
const WASM_IMPORT = /\.wasm(\?module)?$/;
|
|
160
|
+
/**
|
|
161
|
+
* `import mod from "./x.wasm"` (or `x.wasm?module`, or a dependency's
|
|
162
|
+
* `pkg/x_bg.wasm`) gives a compiled `WebAssembly.Module`, as wrangler's
|
|
163
|
+
* default CompiledWasm rule does: the deployed runtime refuses to compile wasm
|
|
164
|
+
* from bytes, so the file ships beside the bundle and each host installs it as
|
|
165
|
+
* a wasm module. Named by content hash, so the same file imported twice ships
|
|
166
|
+
* once and no `node_modules` path reaches a module name.
|
|
167
|
+
*/
|
|
168
|
+
function wasmModules(projectDir, found) {
|
|
169
|
+
return {
|
|
170
|
+
name: "canopy-wasm-modules",
|
|
171
|
+
setup(build) {
|
|
172
|
+
const ship = (file) => {
|
|
173
|
+
const data = new Uint8Array(readFileSync(file));
|
|
174
|
+
const name = `${createHash("sha256").update(data).digest("hex").slice(0, 16)}.wasm`;
|
|
175
|
+
if (!found.has(name)) {
|
|
176
|
+
const source = relative(realpathSync(projectDir), file);
|
|
177
|
+
found.set(name, {
|
|
178
|
+
name,
|
|
179
|
+
source,
|
|
180
|
+
data
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
path: `./wasm/${name}`,
|
|
185
|
+
external: true
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
const resolveOnce = (path, args) => build.resolve(path, {
|
|
189
|
+
kind: args.kind,
|
|
190
|
+
resolveDir: args.resolveDir,
|
|
191
|
+
importer: args.importer,
|
|
192
|
+
pluginData: "canopy-wasm"
|
|
193
|
+
});
|
|
194
|
+
build.onResolve({ filter: WASM_IMPORT }, async (args) => {
|
|
195
|
+
if (args.pluginData === "canopy-wasm") return void 0;
|
|
196
|
+
const resolved = await resolveOnce(args.path.replace(/\?module$/, ""), args);
|
|
197
|
+
if (resolved.errors.length > 0) return { errors: resolved.errors };
|
|
198
|
+
return ship(resolved.path);
|
|
199
|
+
});
|
|
200
|
+
build.onResolve({ filter: /^[^./]/ }, async (args) => {
|
|
201
|
+
if (args.pluginData === "canopy-wasm" || WASM_IMPORT.test(args.path)) return void 0;
|
|
202
|
+
const resolved = await resolveOnce(args.path, args);
|
|
203
|
+
if (resolved.errors.length > 0 || !resolved.path.endsWith(".wasm")) return void 0;
|
|
204
|
+
return ship(resolved.path);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
152
209
|
//#endregion
|
|
153
210
|
//#region src/media.ts
|
|
154
211
|
/**
|
|
@@ -416,6 +473,8 @@ function describeMediaSync(plan, pruned, opts) {
|
|
|
416
473
|
*/
|
|
417
474
|
/** Must match apps/api/src/routes/deploys.ts WORKER_BUNDLE_PATH. */
|
|
418
475
|
const WORKER_BUNDLE_PATH = "_canopy/worker.mjs";
|
|
476
|
+
/** Must match apps/api/src/storage-keys.ts WORKER_WASM_PATH_PREFIX. */
|
|
477
|
+
const WORKER_WASM_PATH_PREFIX = "_canopy/wasm/";
|
|
419
478
|
const IGNORED = /* @__PURE__ */ new Set([
|
|
420
479
|
"canopy.json",
|
|
421
480
|
"AGENTS.md",
|
|
@@ -545,15 +604,18 @@ const deployCommand = defineCommand({
|
|
|
545
604
|
path: f.path,
|
|
546
605
|
size: f.data.byteLength
|
|
547
606
|
})), mediaFolders);
|
|
548
|
-
let
|
|
607
|
+
let worker = null;
|
|
608
|
+
let workerBytes = 0;
|
|
549
609
|
if (config.worker && !args.worker) p.log.warn(`Skipping the backend (${config.worker}) — deploying the frontend only.`);
|
|
550
610
|
if (config.worker && args.worker) {
|
|
551
611
|
const spinWorker = spinner$1();
|
|
552
612
|
spinWorker.start(`Bundling worker ${config.worker}`);
|
|
553
613
|
try {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
614
|
+
worker = await bundleWorker(dir, config.worker);
|
|
615
|
+
workerBytes = workerSize(worker);
|
|
616
|
+
total += workerBytes;
|
|
617
|
+
const wasmNote = worker.wasm.length > 0 ? ` (${worker.wasm.length} WebAssembly module${worker.wasm.length === 1 ? "" : "s"})` : "";
|
|
618
|
+
spinWorker.stop(`Worker bundle ${formatSize(workerBytes)}${wasmNote}`);
|
|
557
619
|
} catch (err) {
|
|
558
620
|
spinWorker.error("Worker bundle failed.");
|
|
559
621
|
throw err;
|
|
@@ -561,9 +623,9 @@ const deployCommand = defineCommand({
|
|
|
561
623
|
}
|
|
562
624
|
const source = onGithubActions() ? { "x-canopy-source": "github-action" } : {};
|
|
563
625
|
const spin = spinner$1();
|
|
564
|
-
const workerNote =
|
|
626
|
+
const workerNote = worker ? " + worker" : "";
|
|
565
627
|
const channelNote = channel === "staging" ? " [staging]" : "";
|
|
566
|
-
const mediaNote = media.length > 0 ? ` + ${media.length} media files (${formatSize(total - bundleBytes -
|
|
628
|
+
const mediaNote = media.length > 0 ? ` + ${media.length} media files (${formatSize(total - bundleBytes - workerBytes)})` : "";
|
|
567
629
|
spin.start(`Deploying ${bundle.length} files${workerNote} (${(bundleBytes / 1024).toFixed(0)} kB)${mediaNote} → ${slug}${channelNote}`);
|
|
568
630
|
let mediaReport = [];
|
|
569
631
|
let result;
|
|
@@ -573,7 +635,7 @@ const deployCommand = defineCommand({
|
|
|
573
635
|
let limitsSeen = {};
|
|
574
636
|
try {
|
|
575
637
|
const { upload, retention } = await withContext(apiRequest("POST", `/projects/${slug}/deploys`, {
|
|
576
|
-
worker:
|
|
638
|
+
worker: worker !== null,
|
|
577
639
|
channel,
|
|
578
640
|
...mediaFolders.length > 0 && { media: mediaFolders }
|
|
579
641
|
}, { headers: source }), { action: `deploy "${slug}"` });
|
|
@@ -591,6 +653,13 @@ const deployCommand = defineCommand({
|
|
|
591
653
|
files: bundle.length
|
|
592
654
|
}, upload, mediaFolders)}`);
|
|
593
655
|
}
|
|
656
|
+
if (worker) {
|
|
657
|
+
const workerRefusal = workerLimitError(worker, upload.maxWorkerBytes);
|
|
658
|
+
if (workerRefusal) {
|
|
659
|
+
spin.error("Deploy refused — nothing was uploaded.");
|
|
660
|
+
throw new Error(workerRefusal);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
594
663
|
if (mediaFolders.length > 0 && !upload.media) {
|
|
595
664
|
spin.error("Deploy refused — nothing was uploaded.");
|
|
596
665
|
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 +689,13 @@ const deployCommand = defineCommand({
|
|
|
620
689
|
createOnly: upload.media.createOnly
|
|
621
690
|
});
|
|
622
691
|
}
|
|
623
|
-
const uploads = [...bundle, ...
|
|
692
|
+
const uploads = [...bundle, ...worker ? [{
|
|
624
693
|
path: WORKER_BUNDLE_PATH,
|
|
625
|
-
data:
|
|
626
|
-
}
|
|
694
|
+
data: worker.code
|
|
695
|
+
}, ...worker.wasm.map((m) => ({
|
|
696
|
+
path: `${WORKER_WASM_PATH_PREFIX}${m.name}`,
|
|
697
|
+
data: m.data
|
|
698
|
+
}))] : []];
|
|
627
699
|
await uploadFiles(upload.grant, uploads);
|
|
628
700
|
if (migrations !== void 0 && migrations.length > 0) {
|
|
629
701
|
spin.message(`Applying schema migrations → ${slug}${channelNote}`);
|
|
@@ -728,6 +800,26 @@ const UPLOAD_CONCURRENCY = 8;
|
|
|
728
800
|
* worker bundle has its own key and isn't counted, as on the server. A server
|
|
729
801
|
* that states no limits isn't checked here; completion still enforces them.
|
|
730
802
|
*/
|
|
803
|
+
/** A worker's size as the platform counts it: the bundle plus every wasm module, uncompressed. */
|
|
804
|
+
function workerSize(worker) {
|
|
805
|
+
return worker.code.byteLength + worker.wasm.reduce((sum, m) => sum + m.data.byteLength, 0);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Refuse a worker the platform would refuse (worker-wasm-modules), before
|
|
809
|
+
* anything is uploaded: over the stated size, or carrying WebAssembly to a
|
|
810
|
+
* site that predates it (no `maxWorkerBytes` in the grant).
|
|
811
|
+
*/
|
|
812
|
+
function workerLimitError(worker, maxWorkerBytes) {
|
|
813
|
+
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;
|
|
814
|
+
const bytes = workerSize(worker);
|
|
815
|
+
if (bytes <= maxWorkerBytes) return null;
|
|
816
|
+
const largest = [...worker.wasm].sort((a, b) => b.data.byteLength - a.data.byteLength).slice(0, 3).map((m) => ` ${m.source} ${formatSize(m.data.byteLength)}`);
|
|
817
|
+
return [
|
|
818
|
+
`The backend worker is ${formatSize(bytes)}; the limit is ${formatSize(maxWorkerBytes)} (code plus WebAssembly modules).`,
|
|
819
|
+
` worker code ${formatSize(worker.code.byteLength)}`,
|
|
820
|
+
...largest
|
|
821
|
+
].join("\n");
|
|
822
|
+
}
|
|
731
823
|
function bundleLimitError(files, limits) {
|
|
732
824
|
if (limits.maxFiles !== void 0 && files.length > limits.maxFiles) return `This deploy has ${files.length} files; the limit is ${limits.maxFiles}.`;
|
|
733
825
|
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-
|
|
110
|
+
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-Bmea0X0L.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-
|
|
329
|
+
const { fetchProjectDump } = await import("./local-dg7vpGYM.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-
|
|
346
|
+
const { createSandbox } = await import("./local-dg7vpGYM.mjs");
|
|
347
347
|
const sandbox = await createSandbox({
|
|
348
348
|
slug,
|
|
349
349
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -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,22 @@ 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
|
+
const wasmImport = WASM_IMPORT.test(source);
|
|
324
|
+
if (!wasmImport && (/^[./]/.test(source) || source.startsWith("\0"))) return null;
|
|
325
|
+
if (!isServerGraph(this, opts)) return null;
|
|
326
|
+
const resolved = await this.resolve(source.replace(/\?module$/, ""), importer, {
|
|
327
|
+
...opts,
|
|
328
|
+
skipSelf: true
|
|
329
|
+
});
|
|
330
|
+
if (!resolved || !wasmImport && !resolved.id.endsWith(".wasm")) return null;
|
|
331
|
+
return `${WASM_MODULE_PREFIX}${resolved.id}`;
|
|
332
|
+
},
|
|
333
|
+
load(id) {
|
|
334
|
+
if (!id.startsWith(WASM_MODULE_PREFIX)) return null;
|
|
335
|
+
return wasmModuleSource(id.slice(13));
|
|
336
|
+
},
|
|
310
337
|
configureServer(server) {
|
|
311
338
|
const load = async () => {
|
|
312
339
|
const handler = (await server.ssrLoadModule(moduleId)).default;
|
package/dist/docs/cli-deploy.md
CHANGED
|
@@ -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.
|
|
@@ -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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-DI8sTmYn.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-
|
|
1
|
+
import { t as version } from "./package-DI8sTmYn.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-
|
|
2
|
+
import { t as version } from "./package-DI8sTmYn.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-
|
|
63
|
-
deploy: () => import("./deploy-
|
|
64
|
-
promote: () => import("./deploy-
|
|
62
|
+
dev: () => import("./dev-Bv14Oar6.mjs").then((m) => m.devCommand),
|
|
63
|
+
deploy: () => import("./deploy-Bzr6p0nl.mjs").then((m) => m.deployCommand),
|
|
64
|
+
promote: () => import("./deploy-Bzr6p0nl.mjs").then((m) => m.promoteCommand),
|
|
65
65
|
staging: () => import("./staging-CSv8OWNT.mjs").then((m) => m.stagingCommand),
|
|
66
|
-
rollback: () => import("./deploy-
|
|
67
|
-
download: () => import("./deploy-
|
|
66
|
+
rollback: () => import("./deploy-Bzr6p0nl.mjs").then((m) => m.rollbackCommand),
|
|
67
|
+
download: () => import("./deploy-Bzr6p0nl.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,18 +74,18 @@ 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-
|
|
77
|
+
feedback: () => import("./feedback-m49QTrTe.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-
|
|
85
|
-
skill: () => import("./skill-
|
|
86
|
-
upgrade: () => import("./upgrade-
|
|
84
|
+
docs: () => import("./docs-_Bb03nNw.mjs").then((m) => m.docsCommand),
|
|
85
|
+
skill: () => import("./skill-D50OjY5d.mjs").then((m) => m.skillCommand),
|
|
86
|
+
upgrade: () => import("./upgrade-DWQ4ouir.mjs").then((m) => m.upgradeCommand),
|
|
87
87
|
logs: () => import("./logs-DTXFm5DB.mjs").then((m) => m.logsCommand),
|
|
88
|
-
mcp: () => import("./mcp-
|
|
88
|
+
mcp: () => import("./mcp-CC6yUXD0.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),
|
|
@@ -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-
|
|
3
|
+
import { a as rewriteApiPath } from "./dev-PRvTQ7Cl.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-
|
|
1
|
+
import { t as version } from "./package-DI8sTmYn.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
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-DI8sTmYn.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-
|
|
115
|
+
const { skillInstalled } = await import("./skill-D50OjY5d.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
package/dist/dev-CiMcqGqA.mjs
DELETED