@ai-ecoverse/slicc-spectrum 1.89.1 → 1.90.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/slicc-ui.js CHANGED
@@ -34906,6 +34906,19 @@ function requiresText(item2, all2) {
34906
34906
  ].filter(Boolean);
34907
34907
  return parts2.length ? parts2.join("; ") : null;
34908
34908
  }
34909
+ var fetched = (progress) => progress.phase === "download" && (progress.bytes?.total ?? 0) > 0 ? progress.bytes : null;
34910
+ var phased = (progress) => {
34911
+ const { done: done2, total } = fetched(progress) ?? progress;
34912
+ const half = progress.phase === "link" ? 1 : 0;
34913
+ return Math.round((half + (total ? Math.min(done2 / total, 1) : 0)) * 50);
34914
+ };
34915
+ var counted = (progress, unit = "") => {
34916
+ const bytes = fetched(progress);
34917
+ if (bytes) return `${size3(bytes.done)} of ${size3(bytes.total)}`;
34918
+ return `${progress.done} of ${progress.total}${unit}`;
34919
+ };
34920
+ var itemBusy = (item2) => running.has(item2.state) || item2.state === "starting" || item2.progress !== null;
34921
+ var packageBusy = (item2) => packageRunning.has(item2.state) || item2.progress !== null;
34909
34922
  var snapshot = (items) => new Map(items.map(({ id, state: state2, error }) => [id, { state: state2, error }]));
34910
34923
  function settled2(failures, before, after) {
34911
34924
  return new Map(
@@ -34963,6 +34976,7 @@ var SliccUpdates = class extends ModelElement {
34963
34976
  problems: { state: true }
34964
34977
  };
34965
34978
  #logs = new ViewSet(this, "updates");
34979
+ #reached = /* @__PURE__ */ new Map();
34966
34980
  constructor() {
34967
34981
  super();
34968
34982
  this.pending = /* @__PURE__ */ new Set();
@@ -35199,6 +35213,7 @@ var SliccUpdates = class extends ModelElement {
35199
35213
  this.failures = /* @__PURE__ */ new Map();
35200
35214
  this.busy = /* @__PURE__ */ new Map();
35201
35215
  this.problems = /* @__PURE__ */ new Map();
35216
+ this.#reached.clear();
35202
35217
  const port = model.updates;
35203
35218
  if (!port) return [];
35204
35219
  let previous = snapshot(port.list());
@@ -35207,6 +35222,7 @@ var SliccUpdates = class extends ModelElement {
35207
35222
  const next = snapshot(items);
35208
35223
  this.failures = settled2(this.failures, previous, next);
35209
35224
  previous = next;
35225
+ this.#prune("item", items, itemBusy);
35210
35226
  this.requestUpdate();
35211
35227
  })
35212
35228
  ];
@@ -35218,6 +35234,7 @@ var SliccUpdates = class extends ModelElement {
35218
35234
  const next = snapshot(items);
35219
35235
  this.problems = settled2(this.problems, packages, next);
35220
35236
  packages = next;
35237
+ this.#prune("package", items, packageBusy);
35221
35238
  this.requestUpdate();
35222
35239
  })
35223
35240
  ];
@@ -35271,25 +35288,43 @@ var SliccUpdates = class extends ModelElement {
35271
35288
  }
35272
35289
  }
35273
35290
  }
35274
- #progress(item2) {
35275
- const progress = item2.progress;
35276
- if (progress) {
35277
- return b`<swc-progress-bar
35278
- size="s"
35279
- min-value="0"
35280
- max-value=${progress.total}
35281
- value=${progress.done}
35282
- value-label=${`${progress.done} of ${progress.total}`}
35283
- accessible-label=${`${item2.label}: ${progress.phase === "download" ? "downloading" : "linking"}`}
35284
- ></swc-progress-bar>`;
35285
- }
35286
- if (!running.has(item2.state) && item2.state !== "starting") return A;
35291
+ #prune(kind, items, busy) {
35292
+ const live = new Set(items.filter(busy).map((item2) => `${kind}:${item2.id}`));
35293
+ for (const key2 of this.#reached.keys()) {
35294
+ if (key2.startsWith(`${kind}:`) && !live.has(key2)) this.#reached.delete(key2);
35295
+ }
35296
+ }
35297
+ #bar(key2, busy, progress, count2, accessible) {
35298
+ if (!busy) {
35299
+ this.#reached.delete(key2);
35300
+ return A;
35301
+ }
35302
+ const before = this.#reached.get(key2);
35303
+ const shown4 = progress ? { value: Math.max(before?.value ?? 0, phased(progress)), label: count2 } : before;
35304
+ if (!shown4) {
35305
+ return b`<swc-progress-bar size="s" indeterminate accessible-label=${accessible}></swc-progress-bar>`;
35306
+ }
35307
+ this.#reached.set(key2, shown4);
35287
35308
  return b`<swc-progress-bar
35288
35309
  size="s"
35289
- indeterminate
35290
- accessible-label=${`${item2.label}: ${states[item2.state][1].toLowerCase()}`}
35310
+ min-value="0"
35311
+ max-value="100"
35312
+ value=${shown4.value}
35313
+ value-label=${shown4.label}
35314
+ accessible-label=${accessible}
35291
35315
  ></swc-progress-bar>`;
35292
35316
  }
35317
+ #progress(item2) {
35318
+ const progress = item2.progress;
35319
+ const phase = progress ? progress.phase === "download" ? "downloading" : "linking" : null;
35320
+ return this.#bar(
35321
+ `item:${item2.id}`,
35322
+ itemBusy(item2),
35323
+ progress,
35324
+ progress ? counted(progress) : "",
35325
+ `${item2.label}: ${phase ?? states[item2.state][1].toLowerCase()}`
35326
+ );
35327
+ }
35293
35328
  #actions(item2) {
35294
35329
  if (!item2.actions.length) return A;
35295
35330
  const busy = this.pending.has(item2.id);
@@ -35353,22 +35388,14 @@ var SliccUpdates = class extends ModelElement {
35353
35388
  }
35354
35389
  #packageProgress(item2) {
35355
35390
  const progress = item2.progress;
35356
- if (progress) {
35357
- return b`<swc-progress-bar
35358
- size="s"
35359
- min-value="0"
35360
- max-value=${progress.total}
35361
- value=${progress.done}
35362
- value-label=${`${progress.done} of ${progress.total} packages`}
35363
- accessible-label=${`${item2.label}: ${progress.phase === "download" ? "downloading" : "linking"}`}
35364
- ></swc-progress-bar>`;
35365
- }
35366
- if (!packageRunning.has(item2.state)) return A;
35367
- return b`<swc-progress-bar
35368
- size="s"
35369
- indeterminate
35370
- accessible-label=${`${item2.label}: ${packageLight(item2)?.[1].toLowerCase()}`}
35371
- ></swc-progress-bar>`;
35391
+ const phase = progress ? progress.phase === "download" ? "downloading" : "linking" : null;
35392
+ return this.#bar(
35393
+ `package:${item2.id}`,
35394
+ packageBusy(item2),
35395
+ progress,
35396
+ progress ? counted(progress, " packages") : "",
35397
+ `${item2.label}: ${phase ?? packageLight(item2)?.[1].toLowerCase()}`
35398
+ );
35372
35399
  }
35373
35400
  #package(item2, all2, act2) {
35374
35401
  const light = packageLight(item2);