@brydio/manifest 0.1.0-alpha.4 → 0.1.0-alpha.41

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.
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Two things every app must have before it is published (owner decisions of
3
+ * 22 September 2026), checked the same way by `brydio validate` and by
4
+ * `POST /apps/publish`.
5
+ *
6
+ * - **A logo and an icon, each in colour and in one colour** (ADR-A20). The
7
+ * manifest names four image files, and a package missing any of them is
8
+ * refused.
9
+ * - **Something for the assistant to call** (ADR-A19): generated tools from a
10
+ * collection, a custom tool, an MCP server or an integration.
11
+ *
12
+ * A copy of Brydio's `apps/api/src/apps/manifest/requirements.ts`, the
13
+ * checks `POST /apps/publish` runs. Nothing here imports anything, so the
14
+ * copy is the file: not even `node:zlib`, which a PNG is inflated with, since
15
+ * a screen may bundle `@brydio/manifest` and a worker has none.
16
+ * `test/requirements.test.ts` asks Brydio the same questions whenever a
17
+ * checkout is beside this one.
18
+ *
19
+ * ## What "one colour" means
20
+ *
21
+ * The mono variant is drawn tinted by the theme, so it must be a shape and
22
+ * nothing else: one colour on transparency.
23
+ *
24
+ * - An **SVG** is read for every colour it paints with: `fill`, `stroke`,
25
+ * `stop-color`, `flood-color` and `color`, as attributes and inside `style`.
26
+ * `none`, `transparent`, `inherit` and `currentColor` are not colours.
27
+ * A shape with no fill of its own paints in the default black, unless the
28
+ * root `<svg>` or a `<g>` sets one. More than one distinct colour is
29
+ * refused, and so is an embedded `<image>`, which could be anything.
30
+ * - A **PNG** is decoded, and every pixel at least 1/16 opaque must be within
31
+ * 32 of one colour on each channel, so anti-aliased edges of a black glyph
32
+ * (black at partial alpha) pass and a two-colour picture does not. A PNG
33
+ * with no transparent pixel at all is a solid block and is refused too.
34
+ * - A **JPEG** has no transparency, and a **WebP** is not decoded here, so
35
+ * neither can be the one-colour variant. Both are fine in colour.
36
+ *
37
+ * ## Sizes
38
+ *
39
+ * - An **icon** is square: from 48 to 1,024 pixels across as a raster, and a
40
+ * square view box as an SVG.
41
+ * - A **logo** may be wider than it is tall, never taller: from 48 to 1,024
42
+ * pixels tall, at most 2,048 wide, and at most four times as wide as it is
43
+ * tall. An SVG's view box is held to the same proportions.
44
+ * - Every file is at most 512 KB.
45
+ */
46
+ export declare const BRAND_LIMITS: {
47
+ readonly bytes: number;
48
+ readonly iconMinSide: 48;
49
+ readonly iconMaxSide: 1024;
50
+ readonly logoMinHeight: 48;
51
+ readonly logoMaxHeight: 1024;
52
+ readonly logoMaxWidth: 2048;
53
+ /** Width over height, at most. */
54
+ readonly logoMaxRatio: 4;
55
+ };
56
+ /** The two images, and the two variants each one comes in. */
57
+ export declare const BRAND_FIELDS: readonly ["logo.color", "logo.mono", "icon.color", "icon.mono"];
58
+ export type BrandField = (typeof BRAND_FIELDS)[number];
59
+ export type RequirementCode = 'brand_logo_missing' | 'brand_icon_missing' | 'brand_path_invalid' | 'brand_file_missing' | 'brand_file_too_large' | 'brand_file_unreadable' | 'brand_icon_shape' | 'brand_logo_shape' | 'brand_mono_type' | 'brand_mono_colours' | 'app_has_no_tools';
60
+ export interface RequirementProblem {
61
+ code: RequirementCode;
62
+ message: string;
63
+ /** The manifest field, like `icon.mono`. */
64
+ path: string;
65
+ }
66
+ /** The files a check can see, by their path inside the package with no `./`. */
67
+ export type RequirementFiles = ReadonlyMap<string, Uint8Array>;
68
+ export type BrandImageType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/svg+xml';
69
+ /** A path the manifest wrote, as a bundle names the file: no `./`, forward slashes. */
70
+ export declare const brandFilePath: (declared: string) => string;
71
+ /**
72
+ * Whether a declared brand path is one Brydio will follow: `./`-prefixed,
73
+ * relative, inside the package, and a name a bundle can hold.
74
+ */
75
+ export declare function isBrandPath(declared: unknown): declared is string;
76
+ /**
77
+ * The brand files a manifest names, by field, as bundle paths. Only fields
78
+ * written in the two-variant shape; a legacy `icon: "./icon.png"` names none.
79
+ */
80
+ export declare function brandPathsOf(manifest: unknown): Map<BrandField, string>;
81
+ /**
82
+ * Everything wrong with an app's logo and icon.
83
+ *
84
+ * `required` is off only where a package is read that is not being published
85
+ * (an import of somebody's plugin with no screens): the images it does name
86
+ * are still checked, and the ones it leaves out are not asked for.
87
+ */
88
+ export declare function brandProblems(manifest: Record<string, unknown>, files: RequirementFiles, options?: {
89
+ required?: boolean;
90
+ }): RequirementProblem[];
91
+ /**
92
+ * Whether the assistant has anything to call in this app (ADR-A19).
93
+ *
94
+ * `parts` counts what the package bundles beside the manifest: the servers in
95
+ * its `servers.json` and the files in its `integrations/`. Where they can't
96
+ * be seen (a published bundle holds only code), `requires` still counts.
97
+ */
98
+ export declare function toolsProblem(manifest: Record<string, unknown>, parts?: {
99
+ servers?: number;
100
+ integrations?: number;
101
+ }): RequirementProblem | null;
102
+ export interface BrandShape {
103
+ type: BrandImageType;
104
+ width: number;
105
+ height: number;
106
+ }
107
+ /** What an image is and how big, from its bytes, or null for anything else. */
108
+ export declare function brandShapeOf(bytes: Uint8Array): BrandShape | null;
109
+ /** No script, no event handler, no `javascript:` and no reference that leaves the file. */
110
+ export declare function svgIsInert(svg: string): boolean;
111
+ /**
112
+ * Every distinct colour an SVG paints with, normalised, or null when it
113
+ * embeds a raster whose colours can't be read from the markup.
114
+ */
115
+ export declare function svgColours(svg: string): string[] | null;
116
+ /**
117
+ * What a PNG's pixels say about being one colour.
118
+ *
119
+ * Decodes the image (non-interlaced, every colour type and bit depth) and
120
+ * compares every pixel at least 1/16 opaque with the most opaque one.
121
+ */
122
+ export declare function pngVerdict(bytes: Uint8Array): 'one' | 'colours' | 'opaque' | 'unreadable';