@acrylblends/blends-frame 0.1.4 → 0.1.6
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/lib/client.js +56 -10
- package/lib/client.js.map +1 -1
- package/lib/contract.d.ts +5 -0
- package/lib/index.js +15 -5
- package/lib/index.js.map +1 -1
- package/lib/registry.d.ts +2 -0
- package/lib/types/client/registry-list.d.ts +8 -4
- package/lib/types/contract.d.ts +5 -0
- package/package.json +4 -4
package/lib/contract.d.ts
CHANGED
|
@@ -331,6 +331,8 @@ export interface AppReloadView {
|
|
|
331
331
|
/** @throws an Error naming the field when the answer is not an app reload view. */
|
|
332
332
|
export declare function parseAppReloadView(value: unknown): AppReloadView;
|
|
333
333
|
/** What a plugin of the registry offers, as the registry's index lists it (`https://cordisplugins.github.io/registry/index.json`, formatVersion 1). */
|
|
334
|
+
/** Official: released from one of the project's organisations; community: from anyone else. The registry decides it from the repository owner's GitHub id. */
|
|
335
|
+
export type RegistryOrigin = 'official' | 'community';
|
|
334
336
|
export interface RegistryEntryView {
|
|
335
337
|
/** The plugin's name; a scoped name keeps its scope. */
|
|
336
338
|
readonly name: string;
|
|
@@ -344,12 +346,15 @@ export interface RegistryEntryView {
|
|
|
344
346
|
readonly published?: string;
|
|
345
347
|
/** Where it runs: `ACRYL` (needs an ACRYL service), `Both`, or `DSH stock` (a Harness plugin, which an app of this kind cannot run). */
|
|
346
348
|
readonly compatibility: string;
|
|
349
|
+
readonly origin: RegistryOrigin;
|
|
347
350
|
/** The source a pull takes: `github:<owner>/<repo>@<version>`. */
|
|
348
351
|
readonly source: string;
|
|
349
352
|
/** This app already has a plugin of this name or pulled from this source. */
|
|
350
353
|
readonly installed: boolean;
|
|
351
354
|
/** The account the person is signed in to GitHub with (or shares to) released it. */
|
|
352
355
|
readonly mine: boolean;
|
|
356
|
+
/** Bytes it downloads besides itself for this computer (a native package, plugin-share/native.ts), when the index says. */
|
|
357
|
+
readonly download?: number;
|
|
353
358
|
}
|
|
354
359
|
/** The registry as the Host read it: its entries, or why they could not be read (offline, rate limited, the site changed). */
|
|
355
360
|
export type RegistryView = {
|
package/lib/index.js
CHANGED
|
@@ -1284,6 +1284,12 @@ function repoOfSource(source) {
|
|
|
1284
1284
|
const match = SOURCE.exec(source);
|
|
1285
1285
|
return match === null ? void 0 : `${match[1] ?? ""}/${match[2] ?? ""}`.toLowerCase();
|
|
1286
1286
|
}
|
|
1287
|
+
/** The unpacked size of the native package an entry brings for this computer: its OS and CPU first, then its OS for any CPU (plugin-share/native.ts). */
|
|
1288
|
+
function downloadFor(native, platform = process.platform, arch = process.arch) {
|
|
1289
|
+
if (!Array.isArray(native)) return void 0;
|
|
1290
|
+
const sized = native.filter((item) => isRecord$1(item) && typeof item.size === "number" && item.size > 0);
|
|
1291
|
+
return (sized.find((item) => item.os === platform && item.cpu === arch) ?? sized.find((item) => item.os === platform && item.cpu === void 0))?.size;
|
|
1292
|
+
}
|
|
1287
1293
|
function isRecord$1(value) {
|
|
1288
1294
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1289
1295
|
}
|
|
@@ -1296,13 +1302,15 @@ function registryEntries(index, marks) {
|
|
|
1296
1302
|
const entries = [];
|
|
1297
1303
|
for (const entry of index.entries) {
|
|
1298
1304
|
if (!isRecord$1(entry)) continue;
|
|
1299
|
-
const { name, description, repo, version, published, compatibility, acrylPull } = entry;
|
|
1300
|
-
|
|
1301
|
-
|
|
1305
|
+
const { name, description, repo, version, published, compatibility, origin, acrylPull, install, native } = entry;
|
|
1306
|
+
const pull = typeof acrylPull === "string" ? acrylPull : typeof install === "string" ? install : void 0;
|
|
1307
|
+
if (typeof name !== "string" || typeof repo !== "string" || typeof version !== "string" || pull === void 0) continue;
|
|
1308
|
+
const source = SOURCE.exec(pull)?.[0];
|
|
1302
1309
|
const where = /^https:\/\/github\.com\/([^/]+)\/([^/#?]+)/u.exec(repo);
|
|
1303
1310
|
if (source === void 0 || where === null) continue;
|
|
1304
1311
|
const owner = where[1] ?? "";
|
|
1305
1312
|
const repository = repoOfSource(source);
|
|
1313
|
+
const download = downloadFor(native);
|
|
1306
1314
|
entries.push({
|
|
1307
1315
|
name,
|
|
1308
1316
|
description: typeof description === "string" ? description : "",
|
|
@@ -1311,12 +1319,14 @@ function registryEntries(index, marks) {
|
|
|
1311
1319
|
version,
|
|
1312
1320
|
...typeof published === "string" && /^\d{4}-\d{2}-\d{2}$/u.test(published) ? { published } : {},
|
|
1313
1321
|
compatibility: typeof compatibility === "string" ? compatibility : "DSH stock",
|
|
1322
|
+
origin: origin === "official" ? "official" : "community",
|
|
1314
1323
|
source,
|
|
1315
1324
|
installed: marks.names.has(bareName(name)) || repository !== void 0 && marks.repos.has(repository),
|
|
1316
|
-
mine: marks.accounts.has(owner.toLowerCase())
|
|
1325
|
+
mine: marks.accounts.has(owner.toLowerCase()),
|
|
1326
|
+
...download === void 0 ? {} : { download }
|
|
1317
1327
|
});
|
|
1318
1328
|
}
|
|
1319
|
-
return entries.sort((a, b) => Number(b.mine) - Number(a.mine) || (b.published ?? "").localeCompare(a.published ?? "") || a.name.localeCompare(b.name));
|
|
1329
|
+
return entries.sort((a, b) => Number(b.mine) - Number(a.mine) || Number(b.origin === "official") - Number(a.origin === "official") || (b.published ?? "").localeCompare(a.published ?? "") || a.name.localeCompare(b.name));
|
|
1320
1330
|
}
|
|
1321
1331
|
/** The raw index, read once in a while: a fresh copy within `ttlMs`, else a new read, else the copy read before with the time it was read. */
|
|
1322
1332
|
function createRegistryReader(fetcher, options = {}) {
|