@vibechain/os 0.4.1 → 0.5.1

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.
Files changed (84) hide show
  1. package/AGENTS.md +80 -48
  2. package/README.md +143 -55
  3. package/SECURITY.md +47 -20
  4. package/dist/app-client.d.ts +4 -1
  5. package/dist/app-client.js +15 -4
  6. package/dist/app-host.d.ts +124 -9
  7. package/dist/app-host.js +395 -57
  8. package/dist/app-protocol.d.ts +17 -1
  9. package/dist/app-protocol.js +12 -0
  10. package/dist/app-runtime.d.ts +18 -2
  11. package/dist/app-runtime.js +75 -11
  12. package/dist/app-wire.d.ts +215 -0
  13. package/dist/app-wire.js +268 -0
  14. package/dist/browser.d.ts +3 -0
  15. package/dist/browser.js +3 -0
  16. package/dist/bundle.js +6 -6
  17. package/dist/canvas.d.ts +2 -2
  18. package/dist/canvas.js +3 -1
  19. package/dist/capture.d.ts +22 -0
  20. package/dist/capture.js +99 -0
  21. package/dist/check.d.ts +12 -0
  22. package/dist/check.js +167 -0
  23. package/dist/cli-publish.d.ts +24 -0
  24. package/dist/cli-publish.js +288 -0
  25. package/dist/cli-session.d.ts +108 -0
  26. package/dist/cli-session.js +245 -0
  27. package/dist/cli.d.ts +10 -0
  28. package/dist/cli.js +46 -10
  29. package/dist/index.d.ts +8 -0
  30. package/dist/index.js +4 -0
  31. package/dist/links.d.ts +15 -0
  32. package/dist/links.js +41 -0
  33. package/dist/listing.d.ts +3 -3
  34. package/dist/listing.js +1 -1
  35. package/dist/loop.d.ts +18 -2
  36. package/dist/loop.js +13 -1
  37. package/dist/manifest.d.ts +90 -4
  38. package/dist/manifest.js +340 -5
  39. package/dist/os.d.ts +63 -0
  40. package/dist/os.js +383 -0
  41. package/dist/preview-parent.d.ts +42 -0
  42. package/dist/preview-parent.js +134 -11
  43. package/dist/preview-ui.js +1 -1
  44. package/dist/preview.js +25 -7
  45. package/dist/redact.d.ts +6 -0
  46. package/dist/redact.js +16 -0
  47. package/dist/runtime-policy.d.ts +20 -0
  48. package/dist/runtime-policy.js +45 -0
  49. package/dist/scaffold.d.ts +13 -2
  50. package/dist/scaffold.js +95 -31
  51. package/dist/submit-notice.d.ts +26 -0
  52. package/dist/submit-notice.js +34 -0
  53. package/dist/templates/plain/game.js +18 -0
  54. package/dist/testing.d.ts +68 -0
  55. package/dist/testing.js +181 -1
  56. package/dist/transport.d.ts +22 -0
  57. package/dist/transport.js +71 -19
  58. package/dist/vibemarket-os.js +1 -0
  59. package/dist/worker.d.ts +18 -0
  60. package/dist/worker.js +34 -0
  61. package/examples/paw-beat/README.md +20 -8
  62. package/examples/paw-beat/cat.ts +665 -89
  63. package/examples/paw-beat/game.ts +162 -28
  64. package/examples/paw-beat/index.html +114 -40
  65. package/examples/paw-beat/main.ts +264 -149
  66. package/examples/paw-beat/music.ts +314 -65
  67. package/examples/paw-beat/stage.ts +560 -0
  68. package/examples/paw-beat/store/icon.png +0 -0
  69. package/examples/paw-beat/store/screenshot-1.webp +0 -0
  70. package/examples/paw-beat/store/screenshot-2.webp +0 -0
  71. package/examples/paw-beat/vibemarket.json +2 -2
  72. package/examples/vibexp-app/README.md +7 -7
  73. package/examples/vibexp-app/index.html +3 -2
  74. package/examples/vibexp-app/plain/game.ts +20 -0
  75. package/examples/vibexp-app/plain/index.html +6 -0
  76. package/examples/vibexp-app/plain/vibemarket.json +17 -0
  77. package/examples/vibexp-app/src/main.ts +46 -31
  78. package/examples/vibexp-app/store/icon.png +0 -0
  79. package/examples/vibexp-app/three/README.md +21 -0
  80. package/examples/vibexp-app/three/index.html +4 -0
  81. package/examples/vibexp-app/three/src/main.ts +45 -0
  82. package/examples/vibexp-app/three/vibemarket.json +19 -0
  83. package/examples/vibexp-app/vibemarket.json +17 -11
  84. package/package.json +6 -2
package/dist/bundle.js CHANGED
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { lstat, open, opendir, realpath } from "node:fs/promises";
3
3
  import { constants } from "node:fs";
4
4
  import path from "node:path";
5
- import { assetPath, GAME_LIMITS, parseManifest } from "./manifest.js";
5
+ import { APP_BUNDLE_LIMITS, assetPath, parseManifest } from "./manifest.js";
6
6
  import { checkListing } from "./listing.js";
7
7
  const TYPES = {
8
8
  html: "text/html; charset=utf-8", js: "text/javascript; charset=utf-8", mjs: "text/javascript; charset=utf-8",
@@ -47,7 +47,7 @@ export async function readBuiltBundle(directory) {
47
47
  const folded = new Set();
48
48
  async function walk(relative) {
49
49
  for await (const entry of await opendir(path.join(root, relative))) {
50
- if (++entries > GAME_LIMITS.files)
50
+ if (++entries > APP_BUNDLE_LIMITS.files)
51
51
  throw Error("App exceeds bundle entry limits.");
52
52
  const name = entry.name;
53
53
  const file = relative ? `${relative}/${name}` : name;
@@ -63,7 +63,7 @@ export async function readBuiltBundle(directory) {
63
63
  await walk(file);
64
64
  continue;
65
65
  }
66
- if (!stat.isFile() || !assetType(file) || stat.size > GAME_LIMITS.file || (size += stat.size) > GAME_LIMITS.expanded)
66
+ if (!stat.isFile() || !assetType(file) || stat.size > APP_BUNDLE_LIMITS.file || (size += stat.size) > APP_BUNDLE_LIMITS.expanded)
67
67
  throw Error("App exceeds bundle limits or contains unsupported files.");
68
68
  files[file] = await readBoundedAsset(path.join(root, file), stat.size);
69
69
  }
@@ -75,11 +75,11 @@ export async function readBuiltBundle(directory) {
75
75
  const manifest = parseManifest(JSON.parse(new TextDecoder().decode(input)));
76
76
  if (!files[manifest.entry])
77
77
  throw Error("Manifest entry is missing from the app bundle.");
78
- if (manifest.schemaVersion === 2) {
79
- // SVG is a document format that can carry script; schema version 2 bundles are served by the store runtime.
78
+ if (manifest.schemaVersion !== 1) {
79
+ // SVG is a document format that can carry script; schema version 2 and 3 bundles are served by the store runtime.
80
80
  const svg = Object.keys(files).sort(compareAssetNames).find(file => assetType(file) === TYPES.svg);
81
81
  if (svg)
82
- throw Error(`Schema version 2 apps cannot contain SVG files; convert ${svg} to PNG or WebP.`);
82
+ throw Error(`Schema version ${manifest.schemaVersion} apps cannot contain SVG files; convert ${svg} to PNG or WebP.`);
83
83
  const listing = checkListing(manifest, files);
84
84
  if (!listing.ok)
85
85
  throw Error(`Store listing (${listing.code}): ${listing.message}`);
package/dist/canvas.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { LifecycleSource } from "./loop.ts";
1
+ import { type LifecycleSource, type OsLifecycle } from "./loop.ts";
2
2
  export interface CanvasFit {
3
3
  /** Backing-store size in device pixels. */
4
4
  width: number;
@@ -35,6 +35,6 @@ export interface FittedCanvas {
35
35
  * cleared) only when the computed size actually changes. Style the canvas to fill the
36
36
  * app; this sets only its `width` and `height`.
37
37
  */
38
- export declare function fitCanvas(app: LifecycleSource, canvas: FitTarget, options?: FitOptions, view?: {
38
+ export declare function fitCanvas(source: LifecycleSource | OsLifecycle, canvas: FitTarget, options?: FitOptions, view?: {
39
39
  devicePixelRatio: number;
40
40
  }): FittedCanvas;
package/dist/canvas.js CHANGED
@@ -1,10 +1,12 @@
1
+ import { lifecycleSource } from "./loop.js";
1
2
  /**
2
3
  * Keep a canvas backing store matched to the host surface, with the pixel ratio capped
3
4
  * so a high-density display cannot multiply the fill cost. The canvas is resized (and so
4
5
  * cleared) only when the computed size actually changes. Style the canvas to fill the
5
6
  * app; this sets only its `width` and `height`.
6
7
  */
7
- export function fitCanvas(app, canvas, options = {}, view = window) {
8
+ export function fitCanvas(source, canvas, options = {}, view = window) {
9
+ const app = lifecycleSource(source);
8
10
  const maxRatio = options.maxPixelRatio ?? 2, maxPixels = options.maxPixels ?? 3840 * 2160;
9
11
  if (!Number.isFinite(maxRatio) || maxRatio < 1 || maxRatio > 4)
10
12
  throw Error("maxPixelRatio must be from 1 to 4.");
@@ -0,0 +1,22 @@
1
+ /** The longest side of a captured frame, in pixels. */
2
+ export declare const CAPTURE_MAX_SIDE = 1280;
3
+ /** The visible canvas with the largest on-screen area, or null. */
4
+ export declare function largestCanvas(doc: Pick<Document, "querySelectorAll">): HTMLCanvasElement | null;
5
+ /** Draw `source` downscaled to at most 1280 pixels on its longest side and encode it (WebP, else JPEG) under 1,000,000 characters; null if it cannot. */
6
+ export declare function encodeCanvas(source: HTMLCanvasElement, doc: Pick<Document, "createElement">): string | null;
7
+ /** What an `os.onCapture` handler may answer. */
8
+ export type CaptureResult = HTMLCanvasElement | string | null;
9
+ /** The picture for a handler's answer: a canvas is downscaled and encoded, a data URL is kept if it is a valid one. */
10
+ export declare function frameFrom(result: unknown, doc: Pick<Document, "createElement">): string | null;
11
+ /**
12
+ * The client half of one capture exchange, shared by `connect()` and the 0.4 client. `send` posts the `app.frame`; `closed`
13
+ * says the session is over. With no handler the answer is the largest visible canvas on the NEXT animation frame, so a
14
+ * continuously rendering WebGL game's drawing buffer still holds the frame it just drew. Nothing here ever throws.
15
+ */
16
+ export declare function createCapturer(send: (id: string, image: string | null) => void, closed: () => boolean): {
17
+ /** the latest handler wins; the returned function removes this one only if it is still the latest */
18
+ on(next: () => CaptureResult | Promise<CaptureResult>): () => void;
19
+ clear(): void;
20
+ /** the host's `app.capture` event */
21
+ event(id: unknown): void;
22
+ };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * The app side of the desktop camera: turn a canvas into the data URL an `app.frame` carries. The browser objects are passed
3
+ * in, so the helpers run (and test) without a global `document`.
4
+ */
5
+ import { captureId, frameImage } from "./app-protocol.js";
6
+ /** The longest side of a captured frame, in pixels. */
7
+ export const CAPTURE_MAX_SIDE = 1280;
8
+ const QUALITIES = [0.85, 0.6, 0.4];
9
+ /** The visible canvas with the largest on-screen area, or null. */
10
+ export function largestCanvas(doc) {
11
+ let best = null, area = 0;
12
+ for (const canvas of Array.from(doc.querySelectorAll("canvas"))) {
13
+ const box = canvas.getBoundingClientRect(), size = box.width * box.height;
14
+ if (size > area && canvas.width > 0 && canvas.height > 0) {
15
+ best = canvas;
16
+ area = size;
17
+ }
18
+ }
19
+ return best;
20
+ }
21
+ /** Draw `source` downscaled to at most 1280 pixels on its longest side and encode it (WebP, else JPEG) under 1,000,000 characters; null if it cannot. */
22
+ export function encodeCanvas(source, doc) {
23
+ try {
24
+ const width = source.width, height = source.height;
25
+ if (!(width > 0 && height > 0))
26
+ return null;
27
+ const scale = Math.min(1, CAPTURE_MAX_SIDE / Math.max(width, height));
28
+ const target = doc.createElement("canvas");
29
+ target.width = Math.max(1, Math.round(width * scale));
30
+ target.height = Math.max(1, Math.round(height * scale));
31
+ const context = target.getContext("2d");
32
+ if (!context)
33
+ return null;
34
+ context.drawImage(source, 0, 0, target.width, target.height);
35
+ for (const quality of QUALITIES) {
36
+ let url = target.toDataURL("image/webp", quality);
37
+ if (!url.startsWith("data:image/webp"))
38
+ url = target.toDataURL("image/jpeg", quality);
39
+ if (frameImage(url))
40
+ return url;
41
+ }
42
+ return null;
43
+ }
44
+ catch {
45
+ return null;
46
+ }
47
+ }
48
+ /** The picture for a handler's answer: a canvas is downscaled and encoded, a data URL is kept if it is a valid one. */
49
+ export function frameFrom(result, doc) {
50
+ if (typeof result === "string")
51
+ return frameImage(result) ? result : null;
52
+ if (result !== null && typeof result === "object" && "getContext" in result && "toDataURL" in result)
53
+ return encodeCanvas(result, doc);
54
+ return null;
55
+ }
56
+ /**
57
+ * The client half of one capture exchange, shared by `connect()` and the 0.4 client. `send` posts the `app.frame`; `closed`
58
+ * says the session is over. With no handler the answer is the largest visible canvas on the NEXT animation frame, so a
59
+ * continuously rendering WebGL game's drawing buffer still holds the frame it just drew. Nothing here ever throws.
60
+ */
61
+ export function createCapturer(send, closed) {
62
+ let handler = null;
63
+ const page = () => globalThis.document;
64
+ const answer = (id, image) => { if (closed())
65
+ return; try {
66
+ send(id, image);
67
+ }
68
+ catch { /* capture never breaks the app */ } };
69
+ return {
70
+ /** the latest handler wins; the returned function removes this one only if it is still the latest */
71
+ on(next) { handler = next; return () => { if (handler === next)
72
+ handler = null; }; },
73
+ clear() { handler = null; },
74
+ /** the host's `app.capture` event */
75
+ event(id) {
76
+ if (closed() || !captureId(id))
77
+ return;
78
+ try {
79
+ const custom = handler;
80
+ if (custom) {
81
+ Promise.resolve().then(custom).then(result => frameFrom(result, page()), () => null).then(image => answer(id, image), () => { });
82
+ return;
83
+ }
84
+ requestAnimationFrame(() => {
85
+ let image = null;
86
+ try {
87
+ const canvas = largestCanvas(page());
88
+ image = canvas ? frameFrom(canvas, page()) : null;
89
+ }
90
+ catch {
91
+ image = null;
92
+ }
93
+ answer(id, image);
94
+ });
95
+ }
96
+ catch { /* no document or animation frames: the host's timeout answers */ }
97
+ },
98
+ };
99
+ }
@@ -0,0 +1,12 @@
1
+ import { APP_BUNDLE_LIMITS } from "./manifest.ts";
2
+ type BundleLimits = {
3
+ readonly [K in keyof typeof APP_BUNDLE_LIMITS]: number;
4
+ };
5
+ export interface CheckReport {
6
+ problems: string[];
7
+ notices: string[];
8
+ bundle: string | null;
9
+ }
10
+ /** `limits` is the store's; a test passes smaller ones. */
11
+ export declare function checkApp(directory: string, limits?: BundleLimits): Promise<CheckReport>;
12
+ export {};
package/dist/check.js ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * `os check [dir]`: every problem with an app's manifest and built folder, one per line, before a submission finds the
3
+ * first. The checks are the server's (VM_OS_APPS_3.md section 11.6): the manifest rules and network origins
4
+ * (`checkManifest`), the listing images, the bundle limits, paths and file types and SVG. Nothing is written.
5
+ */
6
+ import { lstat, opendir } from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { zipSync } from "fflate";
9
+ import { assetType, compareAssetNames, readBoundedAsset } from "./bundle.js";
10
+ import { imageKind, pngSize } from "./listing.js";
11
+ import { APP_BUNDLE_LIMITS, APP_STORE_LIMITS, assetPath, checkManifest, manifestNotices, manifestProblemText, parseManifest } from "./manifest.js";
12
+ const KiB = 1024, MiB = 1024 * 1024;
13
+ const size = (bytes) => bytes >= MiB ? `${(bytes / MiB).toFixed(1)} MiB` : `${Math.ceil(bytes / KiB)} KiB`;
14
+ const missing = (error) => error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
15
+ /** Where the built app is: `<dir>/dist` when it exists, else `<dir>` itself (a plain app, or `os check dist`). */
16
+ async function bundleRoot(directory) {
17
+ const dist = path.join(directory, "dist");
18
+ try {
19
+ if ((await lstat(dist)).isDirectory())
20
+ return dist;
21
+ }
22
+ catch (error) {
23
+ if (!missing(error))
24
+ throw error;
25
+ }
26
+ return directory;
27
+ }
28
+ /** The files of a built folder within the bundle limits, and a problem for each file or limit it breaks. */
29
+ async function readFolder(root, problems, limits) {
30
+ const files = new Map(), folded = new Set();
31
+ let entries = 0, expanded = 0, counted = false, over = false;
32
+ const walk = async (relative) => {
33
+ const names = [];
34
+ for await (const entry of await opendir(path.join(root, relative)))
35
+ names.push(entry.name);
36
+ for (const name of names.sort(compareAssetNames)) {
37
+ const file = relative ? `${relative}/${name}` : name;
38
+ if (++entries > limits.files) {
39
+ if (!counted)
40
+ problems.push(`${file}: the bundle has more than ${limits.files.toLocaleString("en-US")} files and folders; remove unused files.`);
41
+ counted = true;
42
+ continue;
43
+ }
44
+ if (!assetPath(file)) {
45
+ problems.push(`${file}: use only ASCII letters, digits, _, - and . in file names, not starting with a dot.`);
46
+ continue;
47
+ }
48
+ if (folded.has(file.toLowerCase())) {
49
+ problems.push(`${file}: another file differs from it only by letter case; rename one.`);
50
+ continue;
51
+ }
52
+ folded.add(file.toLowerCase());
53
+ const stat = await lstat(path.join(root, file));
54
+ if (stat.isSymbolicLink()) {
55
+ problems.push(`${file}: is a symlink; copy the file in instead.`);
56
+ continue;
57
+ }
58
+ if (stat.isDirectory()) {
59
+ await walk(file);
60
+ continue;
61
+ }
62
+ const type = assetType(file);
63
+ if (!stat.isFile() || !type) {
64
+ problems.push(`${file}: VibeStore does not serve this file type; see the file types in the docs.`);
65
+ continue;
66
+ }
67
+ if (type.startsWith("image/svg")) {
68
+ problems.push(`${file}: SVG can carry script and is refused; convert it to PNG or WebP.`);
69
+ continue;
70
+ }
71
+ if (stat.size > limits.file) {
72
+ problems.push(`${file}: is ${size(stat.size)}; a file may be at most ${limits.file / MiB} MiB (stream larger assets from a declared server).`);
73
+ continue;
74
+ }
75
+ if ((expanded += stat.size) > limits.expanded) {
76
+ if (!over)
77
+ problems.push(`${file}: the bundle passes ${limits.expanded / MiB} MiB expanded here; remove or compress files.`);
78
+ over = true;
79
+ continue;
80
+ }
81
+ files.set(file, await readBoundedAsset(path.join(root, file), stat.size));
82
+ }
83
+ };
84
+ await walk("");
85
+ return files;
86
+ }
87
+ /** The listing images, every problem with each. */
88
+ function listingProblems(icon, screenshots, files) {
89
+ const problems = [], limits = APP_STORE_LIMITS, bytes = files.get(icon);
90
+ if (!bytes)
91
+ problems.push(`store.icon: ${icon} is not in the built folder; copy it in (os assets copies the listed store images).`);
92
+ else {
93
+ const dimensions = pngSize(bytes);
94
+ if (!dimensions)
95
+ problems.push(`store.icon: ${icon} is not a PNG file.`);
96
+ else if (dimensions.width !== limits.iconSize || dimensions.height !== limits.iconSize)
97
+ problems.push(`store.icon: ${icon} is ${dimensions.width} x ${dimensions.height}; it must be exactly ${limits.iconSize} x ${limits.iconSize} pixels.`);
98
+ if (bytes.byteLength > limits.iconBytes)
99
+ problems.push(`store.icon: ${icon} is ${size(bytes.byteLength)}; it must be at most ${limits.iconBytes / KiB} KiB.`);
100
+ }
101
+ screenshots.forEach((shot, index) => {
102
+ const image = files.get(shot), where = `store.screenshots[${index}]`;
103
+ if (!image) {
104
+ problems.push(`${where}: ${shot} is not in the built folder; copy it in.`);
105
+ return;
106
+ }
107
+ const expected = { png: "png", jpg: "jpeg", jpeg: "jpeg", webp: "webp" }[shot.slice(shot.lastIndexOf(".") + 1)];
108
+ if (imageKind(image) !== expected)
109
+ problems.push(`${where}: ${shot} is not a ${expected} image; its contents must match its extension.`);
110
+ if (image.byteLength > limits.screenshotBytes)
111
+ problems.push(`${where}: ${shot} is ${size(image.byteLength)}; a screenshot may be at most ${limits.screenshotBytes / MiB} MiB.`);
112
+ });
113
+ return problems;
114
+ }
115
+ /** Reads `vibemarket.json` text, or a problem. */
116
+ async function manifestAt(file, label) {
117
+ let bytes;
118
+ try {
119
+ bytes = await readBoundedAsset(file, 16 * KiB);
120
+ }
121
+ catch (error) {
122
+ if (missing(error))
123
+ return null;
124
+ return { problem: `${label}: must be a file of at most 16 KiB.` };
125
+ }
126
+ try {
127
+ return { value: JSON.parse(new TextDecoder().decode(bytes)) };
128
+ }
129
+ catch (error) {
130
+ return { problem: `${label}: is not valid JSON (${error.message}).` };
131
+ }
132
+ }
133
+ /** `limits` is the store's; a test passes smaller ones. */
134
+ export async function checkApp(directory, limits = APP_BUNDLE_LIMITS) {
135
+ const problems = [], notices = [];
136
+ const project = path.resolve(directory), root = await bundleRoot(project), separate = root !== project;
137
+ const source = await manifestAt(path.join(project, "vibemarket.json"), "vibemarket.json");
138
+ const built = separate ? await manifestAt(path.join(root, "vibemarket.json"), "dist/vibemarket.json") : source;
139
+ const manifest = source ?? built;
140
+ if (!manifest)
141
+ return { problems: ["vibemarket.json: is missing; create it at the root of the app (os init writes one)."], notices, bundle: null };
142
+ if ("problem" in manifest)
143
+ return { problems: [manifest.problem], notices, bundle: null };
144
+ const listed = (list) => list.map(manifestProblemText);
145
+ problems.push(...listed(checkManifest(manifest.value)));
146
+ notices.push(...listed(manifestNotices(manifest.value)));
147
+ if (separate && source && built && "value" in source && "value" in built && JSON.stringify(source.value) !== JSON.stringify(built.value))
148
+ problems.push("dist/vibemarket.json: differs from vibemarket.json; build again (os assets copies it).");
149
+ if (separate && !built)
150
+ problems.push("dist/vibemarket.json: is missing; build again (os assets copies it).");
151
+ const files = await readFolder(root, problems, limits);
152
+ if (problems.length)
153
+ return { problems, notices, bundle: root };
154
+ const parsed = parseManifest(manifest.value);
155
+ if (!files.has(parsed.entry))
156
+ problems.push(`entry: ${parsed.entry} is not in the built folder.`);
157
+ if (parsed.schemaVersion !== 1)
158
+ problems.push(...listingProblems(parsed.store.icon, parsed.store.screenshots, files));
159
+ else
160
+ notices.push("schemaVersion: 1 has no store listing and cannot be submitted to VibeStore; use 3.");
161
+ if (!problems.length) {
162
+ const zip = zipSync(Object.fromEntries([...files].map(([name, bytes]) => [name, bytes])), { level: 6 });
163
+ if (zip.length > limits.archive)
164
+ problems.push(`bundle: the ZIP would be ${size(zip.length)}, over ${limits.archive / MiB} MiB; remove files or stream large assets from a declared server.`);
165
+ }
166
+ return { problems, notices, bundle: root };
167
+ }
@@ -0,0 +1,24 @@
1
+ import { type Fetch, type Seams } from "./cli-session.ts";
2
+ /**
3
+ * `os login`, `os logout`, `os whoami`, `os submit` and `os status` (VibeStore's build contract, section 11). Sign-in is a
4
+ * browser device grant: the CLI prints a code and the page's address, the person approves it on vibechain.com/os/cli while
5
+ * signed in with Steam, and the CLI receives a token that can only submit apps to review and read their own submissions.
6
+ */
7
+ export declare const PUBLISH_COMMANDS: readonly ["login", "logout", "whoami", "submit", "status"];
8
+ export type PublishCommand = typeof PUBLISH_COMMANDS[number];
9
+ export declare const PUBLISH_USAGE: string;
10
+ export interface PublishContext {
11
+ log(line: string): void;
12
+ request: Fetch;
13
+ seams: Seams;
14
+ }
15
+ /** The build as VibeStore's Submit tab takes it: the same checks as os pack, then a ZIP whose bytes depend only on the files. */
16
+ export declare function packForSubmit(directory: string): Promise<{
17
+ manifest: import("./manifest.ts").AppManifestV2 | import("./manifest.ts").AppManifestV3;
18
+ zip: Uint8Array<ArrayBuffer>;
19
+ files: number;
20
+ expanded: number;
21
+ digest: string;
22
+ }>;
23
+ /** Runs one of the sign-in and submission commands. Errors are thrown with the token masked. */
24
+ export declare function runPublish(command: PublishCommand, args: readonly string[], context: PublishContext): Promise<void>;