@bridgething/catalog 0.1.0 → 0.14.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joey Eamigh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @bridgething/catalog
2
+
3
+ The `catalog.v1` schema, its validator, and the rules for resolving what to
4
+ install. A catalog is the document a [bridgething](https://github.com/JoeyEamigh/bridgething)
5
+ app source publishes; the companion apps, the desktop app, and bridgething.com
6
+ all read one through this package.
7
+
8
+ ```sh
9
+ bun add @bridgething/catalog
10
+ ```
11
+
12
+ ```ts
13
+ import { newestCompatible, validate } from '@bridgething/catalog';
14
+
15
+ const catalog = validate(await (await fetch(url)).json());
16
+ const version = newestCompatible(catalog.apps[0], deviceLibVersion);
17
+ ```
18
+
19
+ `validate` checks the JSON Schema and then the cross-reference rules the schema
20
+ cannot express: app ids are unique uuidv7, a version appears once per app,
21
+ `versions[]` is newest-first by `released_at`, extension permissions are real
22
+ Deno descriptors, and an app shipping a native extension names a `github.com`
23
+ repo as its source. It throws `CatalogValidationError` listing every failure,
24
+ not the first. `validateSchema` and `validateInvariants` are exported separately.
25
+
26
+ `newestCompatible` sorts by `released_at` itself and compares
27
+ `min_libbridgething_version` against the version the device reports, leading `v`
28
+ and all. Do not pre-sort or pre-strip.
29
+
30
+ An installed app takes updates only from the source it came from. A different
31
+ source offering the same app id is a cross-grade the user picks deliberately,
32
+ never a silent update.
33
+
34
+ Publishing a source: `bun create bridgething` scaffolds one, and
35
+ [`@bridgething/source`](https://www.npmjs.com/package/@bridgething/source) is the toolkit it wires
36
+ up, which builds, hosts and validates for you. Hosting your own means
37
+ serving `Access-Control-Allow-Origin: *` on the catalog and every
38
+ `download.url`, and never changing the bytes behind a published version. The
39
+ schema ships here as `@bridgething/catalog/schema.v1.json`.
40
+
41
+ - Docs: <https://bridgething.com/docs/publishing-apps>
42
+ - Source: <https://github.com/JoeyEamigh/bridgething>
package/dist/blend.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type CatalogAppListing, type InstalledWebapp } from './resolve.ts';
1
+ import { type CatalogAppListing, type ExtensionOffering, type InstalledWebapp } from './resolve.ts';
2
2
  import type { MergedCatalog } from './sources.ts';
3
3
  import type { InstallCount, SourceCatalog } from './types.ts';
4
4
  export type StoreListings = {
@@ -13,5 +13,6 @@ export declare function blendStoreListings(args: {
13
13
  deviceLibVersion: string | null;
14
14
  installs: InstallCount[];
15
15
  subscribed: string[];
16
+ extensions: ExtensionOffering;
16
17
  }): StoreListings;
17
18
  //# sourceMappingURL=blend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blend.d.ts","sourceRoot":"","sources":["../src/blend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,eAAe,E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e,EAAE,CAAC;IAC7B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,GAAG,aAAa,CA4BhB"}
package/dist/blend.js CHANGED
@@ -14,6 +14,7 @@ export function blendStoreListings(args) {
14
14
  installed: args.installed,
15
15
  deviceLibVersion: args.deviceLibVersion,
16
16
  installs: args.installs,
17
+ extensions: args.extensions,
17
18
  });
18
19
  const sourceNames = {};
19
20
  for (const { url, catalog } of orderedCatalogs)
package/dist/blend.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"blend.js","sourceRoot":"","sources":["../src/blend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgD,MAAM,cAAc,CAAC;AAUvF,MAAM,UAAU,kBAAkB,CAAC,IAOlC;IACC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAClH,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAiB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEvG,MAAM,eAAe,GAAoB;QACvC,GAAG,IAAI,C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AAC,IAAI,CAAC,IAAI,CAAC;IAErF,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC1E,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3E,WAAW;KACZ,CAAC;AACJ,CAAC"}
package/dist/copy.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { CatalogAppListing } from './resolve.ts';
2
+ export declare const STORE_COPY: {
3
+ readonly appsTitle: "apps";
4
+ readonly appsHint: "from your sources and the bridgething directory";
5
+ readonly appsEmpty: "the catalog exists but has no apps in it.";
6
+ readonly communityTitle: "community apps";
7
+ readonly communityNote: "these are unreviewed";
8
+ readonly communityHint: "from directory sources you have not added";
9
+ readonly communityEmpty: "nothing here";
10
+ readonly suggestedTitle: "suggested sources";
11
+ readonly suggestedHint: "listed in the bridgething directory";
12
+ readonly suggestedEmpty: "nothing the directory lists is missing from your sources.";
13
+ readonly needsFirmware: "needs newer firmware";
14
+ readonly unpublished: "not published yet";
15
+ };
16
+ export declare function countLine(listings: number, sources: number): string;
17
+ export declare function failureLine(failures: number): string;
18
+ export declare function installsLabel(installs: number): string | null;
19
+ export declare function alsoAvailableLabel(alsoAvailableFrom: readonly string[]): string | null;
20
+ export declare function listingTraits(listing: CatalogAppListing): string[];
21
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAab,CAAC;AAMX,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAEtF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAQlE"}
package/dist/copy.js ADDED
@@ -0,0 +1,39 @@
1
+ export const STORE_COPY = {
2
+ appsTitle: 'apps',
3
+ appsHint: 'from your sources and the bridgething directory',
4
+ appsEmpty: 'the catalog exists but has no apps in it.',
5
+ communityTitle: 'community apps',
6
+ communityNote: 'these are unreviewed',
7
+ communityHint: 'from directory sources you have not added',
8
+ communityEmpty: 'nothing here',
9
+ suggestedTitle: 'suggested sources',
10
+ suggestedHint: 'listed in the bridgething directory',
11
+ suggestedEmpty: 'nothing the directory lists is missing from your sources.',
12
+ needsFirmware: 'needs newer firmware',
13
+ unpublished: 'not published yet',
14
+ };
15
+ function plural(count, word) {
16
+ return `${count} ${word}${count === 1 ? '' : 's'}`;
17
+ }
18
+ export function countLine(listings, sources) {
19
+ return `${listings} across ${plural(sources, 'source')}`;
20
+ }
21
+ export function failureLine(failures) {
22
+ return `${plural(failures, 'source')} could not be read.`;
23
+ }
24
+ export function installsLabel(installs) {
25
+ return installs > 0 ? plural(installs, 'install') : null;
26
+ }
27
+ export function alsoAvailableLabel(alsoAvailableFrom) {
28
+ return alsoAvailableFrom.length > 0 ? `also offered by ${plural(alsoAvailableFrom.length, 'other source')}` : null;
29
+ }
30
+ export function listingTraits(listing) {
31
+ const newest = listing.newestCompatible;
32
+ return [
33
+ newest ? `lib ${newest.min_libbridgething_version}` : null,
34
+ newest?.role === 'launcher' ? 'launcher' : null,
35
+ newest?.provides_overlay ? 'overlay' : null,
36
+ installsLabel(listing.installs),
37
+ ].filter((trait) => trait !== null);
38
+ }
39
+ //# sourceMappingURL=copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.js","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,iDAAiD;IAC3D,SAAS,EAAE,2CAA2C;IACtD,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,2CAA2C;IAC1D,cAAc,EAAE,cAAc;IAC9B,cAAc,EAAE,mBAAmB;IACnC,aAAa,EAAE,qCAAqC;IACpD,cAAc,EAAE,2DAA2D;IAC3E,aAAa,EAAE,sBAAsB;IACrC,WAAW,EAAE,mBAAmB;CACxB,CAAC;AAEX,SAAS,MAAM,CAAC,KAAa,EAAE,IAAY;IACzC,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;IACzD,OAAO,GAAG,QAAQ,WAAW,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,iBAAoC;IACrE,OAAO,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACxC,OAAO;QACL,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC,IAAI;QAC1D,MAAM,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QAC/C,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QAC3C,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;KAChC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AppEntry, AppExtension, AppVersion } from './types.ts';
2
+ export declare const EXTENSION_PERMISSION_PATTERN: RegExp;
3
+ export declare const EXTENSION_SOURCE_PATTERN: RegExp;
4
+ export declare function isExtensionPermission(permission: string): boolean;
5
+ export declare function extensionOf(version: AppVersion | null | undefined): AppExtension | null;
6
+ export declare function declaresExtension(app: AppEntry): boolean;
7
+ export declare function describeExtensionPermission(permission: string): string;
8
+ export declare function extensionRepoLabel(source: string | null | undefined): string | null;
9
+ export declare function describeExtensionPermissions(extension: AppExtension): string[];
10
+ //# sourceMappingURL=extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE,eAAO,MAAM,4BAA4B,QAA4D,CAAC;AAEtG,eAAO,MAAM,wBAAwB,QAA6C,CAAC;AAEnF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAEvF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAExD;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAyBtE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAInF;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,EAAE,CAG9E"}
@@ -0,0 +1,49 @@
1
+ export const EXTENSION_PERMISSION_PATTERN = /^(?:all|(?:net|read|write|run|env|sys|ffi)(?::[^,]+)?)$/;
2
+ export const EXTENSION_SOURCE_PATTERN = /^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/;
3
+ export function isExtensionPermission(permission) {
4
+ return EXTENSION_PERMISSION_PATTERN.test(permission);
5
+ }
6
+ export function extensionOf(version) {
7
+ return version?.extension ?? null;
8
+ }
9
+ export function declaresExtension(app) {
10
+ return app.versions.some(version => extensionOf(version) !== null);
11
+ }
12
+ export function describeExtensionPermission(permission) {
13
+ const cut = permission.indexOf(':');
14
+ const verb = cut === -1 ? permission : permission.slice(0, cut);
15
+ const scope = cut === -1 ? null : permission.slice(cut + 1);
16
+ switch (verb) {
17
+ case 'all':
18
+ return scope === null ? 'full host access' : permission;
19
+ case 'net':
20
+ return scope === null ? 'reach any network host' : `reach ${scope}`;
21
+ case 'read':
22
+ return scope === null ? 'read any file' : `read ${scope}`;
23
+ case 'write':
24
+ return scope === null ? 'write any file' : `write ${scope}`;
25
+ case 'run':
26
+ return scope === null ? 'run any program' : `run ${scope}`;
27
+ case 'env':
28
+ return scope === null ? 'read every environment variable' : `read the ${scope} environment variable`;
29
+ case 'sys':
30
+ return scope === null ? 'read system information' : `read system ${scope}`;
31
+ case 'ffi':
32
+ return scope === null ? 'load any native library' : `load the native library ${scope}`;
33
+ default:
34
+ return permission;
35
+ }
36
+ }
37
+ export function extensionRepoLabel(source) {
38
+ if (!source)
39
+ return null;
40
+ if (!EXTENSION_SOURCE_PATTERN.test(source))
41
+ return source;
42
+ return source.replace(/^https:\/\/github\.com\//, '').replace(/\/$/, '');
43
+ }
44
+ export function describeExtensionPermissions(extension) {
45
+ if (extension.permissions.length === 0)
46
+ return ['nothing beyond talking to your Car Thing'];
47
+ return extension.permissions.map(describeExtensionPermission);
48
+ }
49
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,4BAA4B,GAAG,yDAAyD,CAAC;AAEtG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0CAA0C,CAAC;AAEnF,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACtD,OAAO,4BAA4B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAsC;IAChE,OAAO,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAa;IAC7C,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,UAAkB;IAC5D,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;I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