@acrylblends/blends-frame 0.1.4 → 0.1.5

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/contract.d.ts CHANGED
@@ -350,6 +350,8 @@ export interface RegistryEntryView {
350
350
  readonly installed: boolean;
351
351
  /** The account the person is signed in to GitHub with (or shares to) released it. */
352
352
  readonly mine: boolean;
353
+ /** Bytes it downloads besides itself for this computer (a native package, plugin-share/native.ts), when the index says. */
354
+ readonly download?: number;
353
355
  }
354
356
  /** The registry as the Host read it: its entries, or why they could not be read (offline, rate limited, the site changed). */
355
357
  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
- if (typeof name !== "string" || typeof repo !== "string" || typeof version !== "string" || typeof acrylPull !== "string") continue;
1301
- const source = SOURCE.exec(acrylPull)?.[0];
1305
+ const { name, description, repo, version, published, compatibility, 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 : "",
@@ -1313,7 +1321,8 @@ function registryEntries(index, marks) {
1313
1321
  compatibility: typeof compatibility === "string" ? compatibility : "DSH stock",
1314
1322
  source,
1315
1323
  installed: marks.names.has(bareName(name)) || repository !== void 0 && marks.repos.has(repository),
1316
- mine: marks.accounts.has(owner.toLowerCase())
1324
+ mine: marks.accounts.has(owner.toLowerCase()),
1325
+ ...download === void 0 ? {} : { download }
1317
1326
  });
1318
1327
  }
1319
1328
  return entries.sort((a, b) => Number(b.mine) - Number(a.mine) || (b.published ?? "").localeCompare(a.published ?? "") || a.name.localeCompare(b.name));