@glazeen/mod-sdk 0.0.0-stage → 0.2.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/dist/cli.js ADDED
@@ -0,0 +1,474 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
+ import { basename, join, resolve } from "node:path";
4
+ import { parseArgs } from "node:util";
5
+ // src/manifest.ts
6
+ const WIDGET_SIZES = [
7
+ "s",
8
+ "m",
9
+ "l"
10
+ ];
11
+ /** Mod ids: 2-64 chars of letters, digits, ".", "_" or "-", starting with a letter or digit. */
12
+ const MOD_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{1,63}$/i;
13
+ // src/validate.ts
14
+ /** "path: message", or just the message for the root. */
15
+ function formatIssue(issue) {
16
+ return issue.path ? `${issue.path}: ${issue.message}` : issue.message;
17
+ }
18
+ const PERMISSION_PATTERN = /^(system|open-url|net:(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*)$/i;
19
+ /**
20
+ * Hosts bearbar refuses whatever the manifest says (it checks the same at runtime): IP addresses,
21
+ * localhost and other names that only mean something on this PC or the LAN, and wildcards over a
22
+ * whole top-level domain.
23
+ */
24
+ function netHostProblem(pattern) {
25
+ const wild = pattern.startsWith("*.");
26
+ const host = (wild ? pattern.slice(2) : pattern).toLowerCase();
27
+ if (/^[\d.]+$/.test(host)) return "IP addresses are not allowed, use a host name";
28
+ if (/(^|\.)(localhost|local|internal|home\.arpa)$/.test(host)) return "local network names are not allowed";
29
+ if (!host.includes(".")) return wild ? "a wildcard must cover a domain, not a top-level domain" : "use a full host name";
30
+ return null;
31
+ }
32
+ const SEMVER = /^\d+\.\d+\.\d+(-[0-9a-z.-]+)?(\+[0-9a-z.-]+)?$/i;
33
+ const MANIFEST_KEYS = [
34
+ "$schema",
35
+ "id",
36
+ "name",
37
+ "version",
38
+ "apiVersion",
39
+ "description",
40
+ "author",
41
+ "category",
42
+ "sizes",
43
+ "tile",
44
+ "panel",
45
+ "panelSize",
46
+ "permissions",
47
+ "settings"
48
+ ];
49
+ const BASE_FIELD_KEYS = [
50
+ "type",
51
+ "label",
52
+ "description",
53
+ "visibleWhen",
54
+ "default"
55
+ ];
56
+ const FIELD_KEYS = {
57
+ text: [...BASE_FIELD_KEYS, "placeholder"],
58
+ number: [
59
+ ...BASE_FIELD_KEYS,
60
+ "min",
61
+ "max",
62
+ "step"
63
+ ],
64
+ toggle: BASE_FIELD_KEYS,
65
+ select: [...BASE_FIELD_KEYS, "options"]
66
+ };
67
+ const FIELD_TYPES = Object.keys(FIELD_KEYS);
68
+ const DEFAULT_TYPE = {
69
+ text: "string",
70
+ select: "string",
71
+ number: "number",
72
+ toggle: "boolean"
73
+ };
74
+ const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
75
+ const isNum = (v) => typeof v === "number" && Number.isFinite(v);
76
+ const isPositive = (v) => isNum(v) && v > 0;
77
+ const json = (v) => JSON.stringify(v);
78
+ /** True for an .html file inside the mod folder: relative, no "..", no drive or scheme. */
79
+ function isPagePath(p) {
80
+ return typeof p === "string" && !/^([a-z][a-z0-9+.-]*:|[\\/])/i.test(p) && !p.split(/[\\/]/).includes("..") && /.\.html$/i.test(p);
81
+ }
82
+ /**
83
+ * Checks a parsed bearbar.mod.json and reports every problem, with a path to each.
84
+ *
85
+ * Stricter than the dock, which loads what it can and fills in defaults: use it in tooling
86
+ * and CI to catch mistakes early. It checks the manifest only; the `bearbar-mod validate`
87
+ * command also checks that the pages exist.
88
+ *
89
+ * @example
90
+ * const result = validateManifest(JSON.parse(text));
91
+ * if (!result.ok) for (const e of result.errors) console.error(formatIssue(e));
92
+ */
93
+ function validateManifest(input) {
94
+ const errors = [];
95
+ const warnings = [];
96
+ const error = (path, message) => errors.push({
97
+ path,
98
+ message
99
+ });
100
+ const warn = (path, message) => warnings.push({
101
+ path,
102
+ message
103
+ });
104
+ if (!isObj(input)) return {
105
+ ok: false,
106
+ errors: [{
107
+ path: "",
108
+ message: "must be a JSON object"
109
+ }],
110
+ warnings
111
+ };
112
+ const m = input;
113
+ for (const key of Object.keys(m)) if (!MANIFEST_KEYS.includes(key)) warn(key, `unknown property${suggest(key, MANIFEST_KEYS)}`);
114
+ if (m.id === void 0) error("id", "is required");
115
+ else if (typeof m.id !== "string" || !MOD_ID_PATTERN.test(m.id)) error("id", "must be 2-64 letters, digits, \".\", \"_\" or \"-\", starting with a letter or digit");
116
+ if (m.name === void 0) error("name", "is required");
117
+ else if (typeof m.name !== "string" || m.name.trim() === "") error("name", "must be a non-empty string");
118
+ if (m.version === void 0) error("version", "is required");
119
+ else if (typeof m.version !== "string" || m.version.trim() === "") error("version", "must be a non-empty string");
120
+ else if (!SEMVER.test(m.version)) warn("version", `${json(m.version)} is not a semantic version like "1.0.0"`);
121
+ if (m.apiVersion !== void 0) {
122
+ if (typeof m.apiVersion !== "number" || !Number.isInteger(m.apiVersion) || m.apiVersion < 1) error("apiVersion", "must be a positive integer");
123
+ else if (m.apiVersion > 1) warn("apiVersion", `${m.apiVersion} is newer than this SDK supports (1)`);
124
+ }
125
+ for (const key of ["description", "author"]) if (m[key] !== void 0 && typeof m[key] !== "string") error(key, "must be a string");
126
+ if (m.category !== void 0) warn("category", "is ignored: mods are always listed under Mods");
127
+ if (m.tile === void 0) error("tile", "is required");
128
+ else if (!isPagePath(m.tile)) error("tile", "must be an .html file inside the mod folder");
129
+ if (m.panel !== void 0 && !isPagePath(m.panel)) error("panel", "must be an .html file inside the mod folder");
130
+ if (m.sizes !== void 0) {
131
+ if (!isObj(m.sizes) || Object.keys(m.sizes).length === 0) error("sizes", "must be an object with at least one of s, m, l");
132
+ else for (const [size, units] of Object.entries(m.sizes)) if (!WIDGET_SIZES.includes(size)) error(`sizes.${size}`, "unknown size (use s, m or l)");
133
+ else if (!isPositive(units)) error(`sizes.${size}`, "must be a positive number");
134
+ }
135
+ if (m.panelSize !== void 0) {
136
+ if (!isObj(m.panelSize) || !isPositive(m.panelSize.width) || !isPositive(m.panelSize.height)) error("panelSize", "must be { width, height } with positive numbers");
137
+ else for (const key of Object.keys(m.panelSize)) if (key !== "width" && key !== "height") error(`panelSize.${key}`, "unknown property");
138
+ if (m.panel === void 0) warn("panelSize", "is set but there is no panel");
139
+ }
140
+ if (m.permissions !== void 0) {
141
+ if (!Array.isArray(m.permissions)) error("permissions", "must be an array");
142
+ else {
143
+ const seen = /* @__PURE__ */ new Set();
144
+ m.permissions.forEach((p, i) => {
145
+ if (typeof p !== "string" || !PERMISSION_PATTERN.test(p)) error(`permissions[${i}]`, `unknown permission ${json(p)} (use "net:<host>", "system" or "open-url")`);
146
+ else if (seen.has(p.toLowerCase())) error(`permissions[${i}]`, `duplicate ${json(p)}`);
147
+ else {
148
+ seen.add(p.toLowerCase());
149
+ const problem = p.toLowerCase().startsWith("net:") ? netHostProblem(p.slice(4)) : null;
150
+ if (problem) error(`permissions[${i}]`, `${json(p)}: ${problem}`);
151
+ }
152
+ });
153
+ }
154
+ }
155
+ if (m.settings !== void 0) {
156
+ if (!isObj(m.settings)) error("settings", "must be an object");
157
+ else for (const [key, field] of Object.entries(m.settings)) validateField(`settings.${key}`, field, m.settings, error, warn);
158
+ }
159
+ return errors.length ? {
160
+ ok: false,
161
+ errors,
162
+ warnings
163
+ } : {
164
+ ok: true,
165
+ manifest: m,
166
+ errors: [],
167
+ warnings
168
+ };
169
+ }
170
+ function validateField(path, f, all, error, warn) {
171
+ if (!isObj(f)) {
172
+ error(path, "must be an object");
173
+ return;
174
+ }
175
+ const type = f.type;
176
+ if (!FIELD_TYPES.includes(type)) {
177
+ error(`${path}.type`, `must be one of ${FIELD_TYPES.join(", ")}`);
178
+ return;
179
+ }
180
+ const allowed = FIELD_KEYS[type];
181
+ for (const key of Object.keys(f)) if (!allowed.includes(key)) error(`${path}.${key}`, `not allowed on a ${type} field${suggest(key, allowed)}`);
182
+ if (typeof f.label !== "string") error(`${path}.label`, "must be a string");
183
+ if (f.description !== void 0 && typeof f.description !== "string") error(`${path}.description`, "must be a string");
184
+ const vw = f.visibleWhen;
185
+ if (vw !== void 0) {
186
+ if (!isObj(vw) || typeof vw.field !== "string" || ![
187
+ "string",
188
+ "number",
189
+ "boolean"
190
+ ].includes(typeof vw.equals) || Object.keys(vw).some((k) => k !== "field" && k !== "equals")) error(`${path}.visibleWhen`, "must be { field, equals }");
191
+ else if (!(vw.field in all) || `settings.${vw.field}` === path) error(`${path}.visibleWhen.field`, `${json(vw.field)} is not another setting`);
192
+ }
193
+ const def = f.default;
194
+ if (def !== void 0 && typeof def !== DEFAULT_TYPE[type]) error(`${path}.default`, `must be a ${DEFAULT_TYPE[type]}`);
195
+ if (type === "text" && f.placeholder !== void 0 && typeof f.placeholder !== "string") error(`${path}.placeholder`, "must be a string");
196
+ if (type === "number") {
197
+ for (const key of [
198
+ "min",
199
+ "max",
200
+ "step"
201
+ ]) if (f[key] !== void 0 && !isNum(f[key])) error(`${path}.${key}`, "must be a number");
202
+ const { min, max, step } = f;
203
+ if (isNum(step) && step <= 0) error(`${path}.step`, "must be greater than 0");
204
+ if (isNum(min) && isNum(max) && min > max) error(`${path}.min`, "is greater than max");
205
+ if (isNum(def) && (isNum(min) && def < min || isNum(max) && def > max)) warn(`${path}.default`, "is outside min..max");
206
+ }
207
+ if (type === "select") {
208
+ const options = f.options;
209
+ if (!Array.isArray(options) || options.length === 0) error(`${path}.options`, "must be a non-empty array");
210
+ else {
211
+ const values = /* @__PURE__ */ new Set();
212
+ options.forEach((o, i) => {
213
+ if (!isObj(o) || typeof o.value !== "string" || typeof o.label !== "string" || Object.keys(o).some((k) => k !== "value" && k !== "label")) error(`${path}.options[${i}]`, "must be { value, label } strings");
214
+ else if (values.has(o.value)) error(`${path}.options[${i}].value`, `duplicate ${json(o.value)}`);
215
+ else values.add(o.value);
216
+ });
217
+ if (typeof def === "string" && values.size && !values.has(def)) error(`${path}.default`, `${json(def)} is not one of the option values`);
218
+ }
219
+ }
220
+ }
221
+ /** ' (did you mean "x"?)' when a known key is a likely typo of `key`. */
222
+ function suggest(key, known) {
223
+ let best = "";
224
+ let bestDist = 3;
225
+ for (const k of known) {
226
+ const d = distance(key.toLowerCase(), k.toLowerCase());
227
+ if (d < bestDist) [best, bestDist] = [k, d];
228
+ }
229
+ return best ? ` (did you mean ${json(best)}?)` : "";
230
+ }
231
+ /** Levenshtein distance. */
232
+ function distance(a, b) {
233
+ let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
234
+ for (let i = 1; i <= a.length; i++) {
235
+ const cur = [i];
236
+ for (let j = 1; j <= b.length; j++) cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
237
+ prev = cur;
238
+ }
239
+ return prev[b.length];
240
+ }
241
+ // src/cli.ts
242
+ /**
243
+ * bearbar-mod: validate and scaffold bearbar mods.
244
+ *
245
+ * bearbar-mod validate [dir...] a mod folder, or a folder of mods (default ".")
246
+ * bearbar-mod init [dir] create a mod in dir (default ".")
247
+ */
248
+ const MANIFEST = "bearbar.mod.json";
249
+ const SCHEMA_URL = "https://unpkg.com/@glazeen/mod-sdk/schema/bearbar.mod.schema.json";
250
+ const HELP = `bearbar-mod 0.2.0: tools for bearbar dock mods
251
+
252
+ Usage:
253
+ bearbar-mod validate [dir...] Check mods: a mod folder, or a folder of mods (default ".")
254
+ --strict Fail on warnings too
255
+ --json Print the results as JSON
256
+ bearbar-mod init [dir] Create a mod in dir (default "."), without overwriting files
257
+ --name <name> Display name (default: from the folder name)
258
+
259
+ -h, --help Show this help
260
+ -v, --version Show the version
261
+
262
+ Docs: https://github.com/glazeen/bearbar/blob/main/packages/mod-sdk/docs/guide.md`;
263
+ const color = process.stdout.isTTY && !process.env.NO_COLOR;
264
+ const paint = (code) => (s) => color ? `\x1b[${code}m${s}\x1b[0m` : s;
265
+ const red = paint(31);
266
+ const yellow = paint(33);
267
+ const green = paint(32);
268
+ const dim = paint(2);
269
+ function main(argv) {
270
+ const { values, positionals } = parseArgs({
271
+ args: argv,
272
+ allowPositionals: true,
273
+ options: {
274
+ strict: { type: "boolean" },
275
+ json: { type: "boolean" },
276
+ name: { type: "string" },
277
+ help: {
278
+ type: "boolean",
279
+ short: "h"
280
+ },
281
+ version: {
282
+ type: "boolean",
283
+ short: "v"
284
+ }
285
+ }
286
+ });
287
+ const [command, ...rest] = positionals;
288
+ if (values.version) return print("0.2.0");
289
+ if (values.help || !command) return print(HELP);
290
+ if (command === "validate") return validate(rest.length ? rest : ["."], values);
291
+ if (command === "init") return init(rest[0] ?? ".", values.name);
292
+ console.error(`Unknown command "${command}".\n\n${HELP}`);
293
+ return 2;
294
+ }
295
+ function print(text) {
296
+ console.log(text);
297
+ return 0;
298
+ }
299
+ function validate(roots, opts) {
300
+ const reports = [];
301
+ for (const root of roots) {
302
+ const dir = resolve(root);
303
+ if (!isDir(dir)) {
304
+ console.error(`${root}: not a folder`);
305
+ return 2;
306
+ }
307
+ if (existsSync(join(dir, MANIFEST))) reports.push(checkMod(dir));
308
+ else for (const name of readdirSync(dir).sort()) {
309
+ const sub = join(dir, name);
310
+ if (isDir(sub) && existsSync(join(sub, MANIFEST))) reports.push(checkMod(sub));
311
+ }
312
+ }
313
+ const failed = reports.filter((r) => r.errors.length || opts.strict && r.warnings.length);
314
+ if (opts.json) console.log(JSON.stringify({
315
+ mods: reports,
316
+ failed: failed.length
317
+ }, null, 2));
318
+ else {
319
+ for (const r of reports) {
320
+ const bad = failed.includes(r);
321
+ const label = r.id && r.id !== basename(r.dir) ? `${basename(r.dir)} (${r.id})` : r.id;
322
+ console.log(`${bad ? red("✗") : green("✓")} ${label ?? basename(r.dir)} ${dim(r.dir)}`);
323
+ for (const e of r.errors) console.log(` ${red("error")} ${formatIssue(e)}`);
324
+ for (const w of r.warnings) console.log(` ${yellow("warning")} ${formatIssue(w)}`);
325
+ }
326
+ if (reports.length === 0) console.log(`No ${MANIFEST} found in ${roots.join(", ")}.`);
327
+ else console.log(`\n${reports.length} mod(s) checked, ${failed.length} failed.`);
328
+ }
329
+ return reports.length === 0 ? 1 : failed.length ? 1 : 0;
330
+ }
331
+ /** The manifest checks plus what needs the file system: pages exist and load nothing remote. */
332
+ function checkMod(dir) {
333
+ let raw;
334
+ try {
335
+ raw = JSON.parse(readFileSync(join(dir, MANIFEST), "utf8").replace(/^/, ""));
336
+ } catch (err) {
337
+ return {
338
+ dir,
339
+ errors: [{
340
+ path: "",
341
+ message: `invalid JSON: ${err.message}`
342
+ }],
343
+ warnings: []
344
+ };
345
+ }
346
+ const result = validateManifest(raw);
347
+ const report = {
348
+ dir,
349
+ id: typeof raw?.id === "string" ? raw.id : void 0,
350
+ errors: [...result.errors],
351
+ warnings: [...result.warnings]
352
+ };
353
+ if (!result.ok) return report;
354
+ for (const key of ["tile", "panel"]) {
355
+ const page = result.manifest[key];
356
+ if (page === void 0) continue;
357
+ const file = join(dir, page);
358
+ if (!existsSync(file)) {
359
+ report.errors.push({
360
+ path: key,
361
+ message: `file not found: ${page}`
362
+ });
363
+ continue;
364
+ }
365
+ for (const url of remoteUrls(readFileSync(file, "utf8"))) report.warnings.push({
366
+ path: key,
367
+ message: `${page} loads ${url}, which the mod sandbox blocks: copy the file into the mod folder, or use bb.fetch for data`
368
+ });
369
+ }
370
+ return report;
371
+ }
372
+ /** URLs of remote scripts, styles, images and fonts in an HTML page. */
373
+ function remoteUrls(html) {
374
+ const urls = /* @__PURE__ */ new Set();
375
+ const source = html.replace(/<!--[\s\S]*?-->/g, "");
376
+ for (const m of source.matchAll(/<(?:script|img|link|source|iframe|video|audio)\b[^>]*?\s(?:src|href)\s*=\s*["']?((?:https?:)?\/\/[^"'\s>]+)/gi)) urls.add(m[1]);
377
+ for (const m of source.matchAll(/url\(\s*["']?((?:https?:)?\/\/[^"')\s]+)/gi)) urls.add(m[1]);
378
+ for (const m of source.matchAll(/@import\s+["']((?:https?:)?\/\/[^"']+)/gi)) urls.add(m[1]);
379
+ return [...urls];
380
+ }
381
+ function init(target, name) {
382
+ const dir = resolve(target);
383
+ const folder = basename(dir);
384
+ const id = folder.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[^a-z0-9]+|-+$/g, "").slice(0, 64) || "my-mod";
385
+ const display = name ?? (folder.replace(/[-_.]+/g, " ").replace(/^\w/, (c) => c.toUpperCase()) || "My mod");
386
+ const files = {
387
+ [MANIFEST]: `${JSON.stringify({
388
+ $schema: SCHEMA_URL,
389
+ id: id.length >= 2 ? id : `${id}-mod`,
390
+ name: display,
391
+ version: "0.1.0",
392
+ description: "What this widget shows, in one line.",
393
+ sizes: {
394
+ s: 1,
395
+ m: 2
396
+ },
397
+ tile: "tile.html",
398
+ permissions: [],
399
+ settings: { label: {
400
+ type: "text",
401
+ label: "Label",
402
+ default: "Hello"
403
+ } }
404
+ }, null, 2)}\n`,
405
+ "tile.html": `<!doctype html>
406
+ <html lang="en">
407
+ <head>
408
+ <meta charset="utf-8" />
409
+ <!-- The dock injects the bb runtime and a base stylesheet into this page. -->
410
+ </head>
411
+ <body>
412
+ <div class="bb-tile">
413
+ <div class="bb-stack">
414
+ <span class="bb-label" id="label"></span>
415
+ <span class="bb-value" id="value">…</span>
416
+ </div>
417
+ </div>
418
+ <script src="tile.js"><\/script>
419
+ </body>
420
+ </html>
421
+ `,
422
+ "tile.js": `// @ts-check
423
+ /// <reference types="@glazeen/mod-sdk/global" />
424
+ // Editor completion for \`bb\`: npm install --save-dev @glazeen/mod-sdk
425
+
426
+ const $ = (/** @type {string} */ id) => /** @type {HTMLElement} */ (document.getElementById(id));
427
+
428
+ function render() {
429
+ $("label").textContent = String(bb.config.label ?? "");
430
+ $("value").textContent = bb.preview ? "42" : new Date().toLocaleTimeString([], { timeStyle: "short" });
431
+ }
432
+
433
+ bb.ready.then(() => {
434
+ render();
435
+ bb.on("config", render);
436
+ setInterval(render, 30_000);
437
+ });
438
+ `
439
+ };
440
+ mkdirSync(dir, { recursive: true });
441
+ const written = [];
442
+ const skipped = [];
443
+ for (const [file, content] of Object.entries(files)) {
444
+ const path = join(dir, file);
445
+ if (existsSync(path)) skipped.push(file);
446
+ else {
447
+ writeFileSync(path, content);
448
+ written.push(file);
449
+ }
450
+ }
451
+ for (const f of written) console.log(`${green("created")} ${f}`);
452
+ for (const f of skipped) console.log(`${yellow("skipped")} ${f} ${dim("(already exists)")}`);
453
+ console.log(`
454
+ Next:
455
+ 1. Copy or link this folder into %APPDATA%\\bearbar\\mods
456
+ (right-click the dock > Add widget… > Mods folder).
457
+ 2. Add the widget from Add widget > Mods. Saving a file reloads it.
458
+ 3. Check it with: npx @glazeen/mod-sdk validate ${target === "." ? "" : target}`.trimEnd());
459
+ return 0;
460
+ }
461
+ function isDir(p) {
462
+ try {
463
+ return statSync(p).isDirectory();
464
+ } catch {
465
+ return false;
466
+ }
467
+ }
468
+ try {
469
+ process.exitCode = main(process.argv.slice(2));
470
+ } catch (err) {
471
+ console.error(err.message);
472
+ process.exitCode = 2;
473
+ }
474
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Declares the `bb` global. Reference it from a plain-JS mod page script:
3
+ *
4
+ * /// <reference types="@glazeen/mod-sdk/global" />
5
+ *
6
+ * or add "@glazeen/mod-sdk/global" to `compilerOptions.types` in tsconfig/jsconfig.
7
+ */
8
+ /**
9
+ * Declares the `bb` global. Reference it from a plain-JS mod page script:
10
+ *
11
+ * /// <reference types="@glazeen/mod-sdk/global" />
12
+ *
13
+ * or add "@glazeen/mod-sdk/global" to `compilerOptions.types` in tsconfig/jsconfig.
14
+ */
15
+ import { t as Bb } from "./bb-JW737zq0.js";
16
+ declare global {
17
+ /** The bearbar mod API, injected by the dock. */
18
+ var bb: Bb;
19
+ }
package/dist/global.js ADDED
File without changes
@@ -0,0 +1,33 @@
1
+ import { A as WidgetCategory, C as SettingField, D as ToggleField, E as TextField, M as defineManifest, O as WIDGET_CATEGORIES, S as SelectOption, T as SettingsSchema, _ as MOD_ID_PATTERN, a as HeadersLike, b as Permission, c as STORAGE_QUOTA, d as THEME_TOKENS, f as Theme, g as InferConfig, h as API_VERSION, i as BbResponse, j as WidgetSize, k as WIDGET_SIZES, l as Surface, m as ThemeToken, n as BbEvents, o as Register, p as ThemeAttrs, r as BbFetchInit, s as RegisteredConfig, t as Bb, u as SystemStats, v as ModManifest, w as SettingFieldBase, x as SelectField, y as NumberField } from "./bb-JW737zq0.js";
2
+ /** A problem found in a manifest. */
3
+ export interface ManifestIssue {
4
+ /** Where the problem is, e.g. "settings.unit.default" or "permissions[1]". Empty for the root. */
5
+ path: string;
6
+ message: string;
7
+ }
8
+ export type ValidationResult = {
9
+ ok: true;
10
+ manifest: ModManifest;
11
+ errors: [];
12
+ warnings: ManifestIssue[];
13
+ } | {
14
+ ok: false;
15
+ manifest?: undefined;
16
+ errors: ManifestIssue[];
17
+ warnings: ManifestIssue[];
18
+ };
19
+ /** "path: message", or just the message for the root. */
20
+ export declare function formatIssue(issue: ManifestIssue): string;
21
+ /**
22
+ * Checks a parsed bearbar.mod.json and reports every problem, with a path to each.
23
+ *
24
+ * Stricter than the dock, which loads what it can and fills in defaults: use it in tooling
25
+ * and CI to catch mistakes early. It checks the manifest only; the `bearbar-mod validate`
26
+ * command also checks that the pages exist.
27
+ *
28
+ * @example
29
+ * const result = validateManifest(JSON.parse(text));
30
+ * if (!result.ok) for (const e of result.errors) console.error(formatIssue(e));
31
+ */
32
+ export declare function validateManifest(input: unknown): ValidationResult;
33
+ export { API_VERSION, Bb, BbEvents, BbFetchInit, BbResponse, HeadersLike, InferConfig, MOD_ID_PATTERN, ModManifest, NumberField, Permission, Register, RegisteredConfig, STORAGE_QUOTA, SelectField, SelectOption, SettingField, SettingFieldBase, SettingsSchema, Surface, SystemStats, THEME_TOKENS, TextField, Theme, ThemeAttrs, ThemeToken, ToggleField, WIDGET_CATEGORIES, WIDGET_SIZES, WidgetCategory, WidgetSize, defineManifest };