@ai-ecoverse/slicc-spectrum 1.56.2 → 1.58.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
@@ -9668,6 +9668,7 @@ var SliccFiles = class extends ModelElement {
9668
9668
  ...ModelElement.properties,
9669
9669
  count: { state: true },
9670
9670
  mounted: { state: true },
9671
+ sources: { state: true },
9671
9672
  mounting: { state: true },
9672
9673
  ejecting: { state: true },
9673
9674
  waiting: { state: true },
@@ -9681,6 +9682,7 @@ var SliccFiles = class extends ModelElement {
9681
9682
  super();
9682
9683
  this.count = 0;
9683
9684
  this.mounted = [];
9685
+ this.sources = /* @__PURE__ */ new Map();
9684
9686
  this.mounting = false;
9685
9687
  this.ejecting = /* @__PURE__ */ new Set();
9686
9688
  this.waiting = [];
@@ -9733,6 +9735,20 @@ var SliccFiles = class extends ModelElement {
9733
9735
  gap: var(--swc-spacing-100);
9734
9736
  min-height: var(--swc-component-height-75);
9735
9737
  }
9738
+ .mounts .source {
9739
+ color: var(--swc-neutral-subdued-content-color-default);
9740
+ }
9741
+ .mounts .path[data-source] {
9742
+ display: flex;
9743
+ flex-wrap: wrap;
9744
+ }
9745
+ .mounts .path[data-source] > span {
9746
+ min-width: 0;
9747
+ max-width: 100%;
9748
+ overflow: hidden;
9749
+ text-overflow: ellipsis;
9750
+ white-space: pre;
9751
+ }
9736
9752
  .mounts .path {
9737
9753
  flex: 1;
9738
9754
  min-width: 0;
@@ -9780,7 +9796,11 @@ var SliccFiles = class extends ModelElement {
9780
9796
  void this.updateComplete.then(() => this.#sync());
9781
9797
  }
9782
9798
  #mounts(files) {
9783
- this.mounted = files.mounts?.() ?? [];
9799
+ const info = files.mountInfo?.();
9800
+ this.mounted = info ? info.map((item2) => item2.target) : files.mounts?.() ?? [];
9801
+ this.sources = new Map(
9802
+ (info ?? []).flatMap((item2) => item2.source ? [[item2.target, item2.source]] : [])
9803
+ );
9784
9804
  this.waiting = files.needsFolder?.() ?? [];
9785
9805
  }
9786
9806
  #sync() {
@@ -9887,6 +9907,11 @@ var SliccFiles = class extends ModelElement {
9887
9907
  </ul>
9888
9908
  </section>`;
9889
9909
  }
9910
+ #mounted(path) {
9911
+ const source = this.sources.get(path);
9912
+ if (!source) return b`<span class="path" title=${path}>${path}</span>`;
9913
+ return b`<span class="path" title=${`${path} \xB7 ${source}`} data-source=${source}><span class="target">${path}</span><span class="source"> · ${source}</span></span>`;
9914
+ }
9890
9915
  #strip(files) {
9891
9916
  if (this.mounted.length === 0) return A;
9892
9917
  const eject = files?.eject?.bind(files);
@@ -9895,7 +9920,7 @@ var SliccFiles = class extends ModelElement {
9895
9920
  <ul aria-labelledby="mounted">
9896
9921
  ${this.mounted.map(
9897
9922
  (path) => b`<li>
9898
- <span class="path" title=${path}>${path}</span>
9923
+ ${this.#mounted(path)}
9899
9924
  ${eject ? b`<swc-action-button
9900
9925
  size="s"
9901
9926
  quiet
@@ -11952,8 +11977,20 @@ function budgetVariant(percent2) {
11952
11977
  const variant = meterVariant(percent2);
11953
11978
  return variant === "informative" ? "neutral" : variant;
11954
11979
  }
11955
- function budgetLine(status2) {
11956
- return `Spent $${status2.spent.toFixed(2)} \xB7 $${status2.rate.toFixed(2)}/h. ${status2.budget.percent}% of the ${status2.budget.window} budget, ${status2.budget.resets}.`;
11980
+ function spendLine(status2) {
11981
+ const parts2 = [
11982
+ status2.spent ? `Spent $${status2.spent.toFixed(2)}` : "",
11983
+ status2.rate ? `$${status2.rate.toFixed(2)}/h` : ""
11984
+ ];
11985
+ const line = parts2.filter(Boolean).join(" \xB7 ");
11986
+ return line ? `${line}. ` : "";
11987
+ }
11988
+ function budgetLine(status2, budget) {
11989
+ return `${spendLine(status2)}${budget.percent}% of the ${budget.window} budget, ${budget.resets}.`;
11990
+ }
11991
+ function shownBudget(status2) {
11992
+ const budget = status2.budget;
11993
+ return budget && (budget.percent > 0 || status2.spent || status2.rate) ? budget : null;
11957
11994
  }
11958
11995
  var SliccTray = class extends ModelElement {
11959
11996
  static properties = {
@@ -12022,7 +12059,7 @@ var SliccTray = class extends ModelElement {
12022
12059
  const connection = connectionLabel[status2.connection];
12023
12060
  const followers = `${status2.followers.length} ${status2.followers.length === 1 ? "follower" : "followers"}`;
12024
12061
  const light = status2.connection === "live" ? status2.name : `${status2.name}, ${connection}`;
12025
- const budget = `Budget ${status2.budget.percent}%`;
12062
+ const budget = shownBudget(status2);
12026
12063
  return b`${this.#item(
12027
12064
  "chip",
12028
12065
  "network",
@@ -12036,14 +12073,18 @@ var SliccTray = class extends ModelElement {
12036
12073
  () => this.#open("network", "sync")
12037
12074
  )}
12038
12075
  <swc-tooltip for="chip" placement="bottom">${`${connection}, ${followers}`}</swc-tooltip>
12039
- ${this.#item(
12076
+ ${budget ? this.#usage(status2, budget) : A}`;
12077
+ }
12078
+ #usage(status2, budget) {
12079
+ const label = `Budget ${budget.percent}%`;
12080
+ return b`${this.#item(
12040
12081
  "usage",
12041
12082
  "monitor",
12042
- `${budget}. ${budgetLine(status2)}`,
12043
- b`<swc-status-light size="s" variant=${budgetVariant(status2.budget.percent)}>${budget}</swc-status-light>`,
12083
+ `${label}. ${budgetLine(status2, budget)}`,
12084
+ b`<swc-status-light size="s" variant=${budgetVariant(budget.percent)}>${label}</swc-status-light>`,
12044
12085
  () => this.#open("monitor")
12045
12086
  )}
12046
- <swc-tooltip for="usage" placement="bottom">${budgetLine(status2)}</swc-tooltip>`;
12087
+ <swc-tooltip for="usage" placement="bottom">${budgetLine(status2, budget)}</swc-tooltip>`;
12047
12088
  }
12048
12089
  };
12049
12090
 
@@ -12064,7 +12105,7 @@ var automation = {
12064
12105
  extension: "Browser automation: through the SLICC extension.",
12065
12106
  proxy: "Browser automation: through slicc-node.",
12066
12107
  link: "Browser automation: through a linked device.",
12067
- none: "Browser automation: not available. Install the extension or run slicc-node."
12108
+ none: "Browser automation: not available. Install the extension, or run slicc-node or npx sliccy@next."
12068
12109
  };
12069
12110
  function automationOf(browser) {
12070
12111
  return browser.via ?? "none";
@@ -12507,7 +12548,43 @@ var SliccNetwork = class extends ModelElement {
12507
12548
  color: var(--swc-neutral-subdued-content-color-default);
12508
12549
  overflow-wrap: anywhere;
12509
12550
  }
12551
+ .folders ul {
12552
+ display: flex;
12553
+ flex-direction: column;
12554
+ gap: var(--swc-spacing-75);
12555
+ margin: var(--swc-spacing-75) 0 0;
12556
+ padding: 0;
12557
+ list-style: none;
12558
+ }
12559
+ .folders li {
12560
+ display: flex;
12561
+ align-items: center;
12562
+ gap: var(--swc-spacing-100);
12563
+ min-width: 0;
12564
+ }
12565
+ .folders swc-icon-folder {
12566
+ flex: none;
12567
+ color: var(--swc-neutral-subdued-content-color-default);
12568
+ }
12569
+ .folder {
12570
+ flex: 1;
12571
+ display: flex;
12572
+ flex-wrap: wrap;
12573
+ align-items: center;
12574
+ gap: var(--swc-spacing-50) var(--swc-spacing-100);
12575
+ min-width: 0;
12576
+ overflow-wrap: anywhere;
12577
+ }
12578
+ .folder > code {
12579
+ flex: none;
12580
+ max-width: 100%;
12581
+ }
12582
+ .folder .muted {
12583
+ flex-basis: 100%;
12584
+ font-size: var(--swc-font-size-75);
12585
+ }
12510
12586
  .where code,
12587
+ .folder code,
12511
12588
  [data-browsers] code {
12512
12589
  font-family: var(--swc-code-font-family-stack);
12513
12590
  }
@@ -12892,10 +12969,35 @@ var SliccNetwork = class extends ModelElement {
12892
12969
  <span class="where">${device.host ? b`<code>${device.host}</code>` : A}<span>${device.address ? b`<code>${device.address}</code> · ` : A}${device.mode === "local" ? "This computer" : "Remote"}${device.kind === "seven" ? " \xB7 Follower" : ""}</span></span>
12893
12970
  ${device.policy ? b`<span class="muted" data-policy>Reaches ${device.policy}.</span>` : A}
12894
12971
  ${device.browsers?.length ? b`<span class="muted" data-browsers>${device.browsers.length === 1 ? "Browser" : "Browsers"}: ${device.browsers.map((item2, index) => b`${index ? ", " : ""}${item2.name} (<code>${item2.runtime}</code>)`)}</span>` : A}
12972
+ ${device.folders?.length ? this.#folders(port, device, device.folders) : A}
12895
12973
  ${device.asking ? this.#ask(port, device) : this.#access(port, device)}
12896
12974
  ${device.offers.includes("ssh") ? b`<div class="command" data-copy="ssh"><code>ssh ${device.host}</code>${this.#copyButton(`ssh:${device.id}`, "ssh", "ssh command", `ssh ${device.host}`, "linksError")}</div>` : A}
12897
12975
  </li>`;
12898
12976
  }
12977
+ #folders(port, device, folders) {
12978
+ const heading = `folders-${device.id}`;
12979
+ return b`<div class="folders" data-folders>
12980
+ <span class="muted" id=${heading}>Folders</span>
12981
+ <ul aria-labelledby=${heading}>${folders.map((folder2) => this.#folder(port, device, folder2))}</ul>
12982
+ </div>`;
12983
+ }
12984
+ #folder(port, device, folder2) {
12985
+ const action = `folder:${folder2.source}`;
12986
+ const busy = this.busy === action;
12987
+ const button = folder2.mounted ? port.ejectFolder ? b`<swc-button size="s" variant="secondary" fill-style="outline" data-action="eject-folder" data-id=${folder2.source} accessible-label=${`Eject ${folder2.mounted}`} ?pending=${busy} ?disabled=${this.#waiting(action)} @click=${() => this.#act(action, () => port.ejectFolder?.(folder2.source), "linksError")}>Eject</swc-button>` : A : port.mountFolder ? b`<swc-button size="s" variant="secondary" fill-style="outline" data-action="mount-folder" data-id=${folder2.source} accessible-label=${`Mount ${folder2.source}`} ?pending=${busy} ?disabled=${this.#waiting(action) || device.state !== "connected"} @click=${() => this.#act(action, () => this.#mountFolder(port, folder2.source), "linksError")}>Mount</swc-button>` : A;
12988
+ return b`<li data-folder=${folder2.source} data-mounted=${folder2.mounted ? "yes" : "no"}>
12989
+ <swc-icon-folder size="s" aria-hidden="true"></swc-icon-folder>
12990
+ <span class="folder">
12991
+ <code title=${folder2.source}>${folder2.name}</code>
12992
+ ${folder2.readonly ? b`<swc-badge size="s" variant="neutral" subtle data-readonly>Read-only</swc-badge>` : A}
12993
+ ${folder2.mounted ? b`<span class="muted" data-mounted-at>Mounted at <code>${folder2.mounted}</code></span>` : A}
12994
+ </span>
12995
+ ${button}
12996
+ </li>`;
12997
+ }
12998
+ async #mountFolder(port, source) {
12999
+ await port.mountFolder?.(source);
13000
+ }
12899
13001
  #join(port, links) {
12900
13002
  const ready = links.joinCommand || links.joinUrl;
12901
13003
  const follow = links.followUrl;
@@ -26795,8 +26897,24 @@ var surfaces2 = {
26795
26897
  agents: "agents",
26796
26898
  terminals: "terminal",
26797
26899
  tabs: "browser",
26798
- changes: "changes"
26900
+ changes: "changes",
26901
+ processes: "terminal"
26799
26902
  };
26903
+ var rowLights = {
26904
+ active: "info",
26905
+ idle: "neutral",
26906
+ warn: "notice",
26907
+ error: "negative"
26908
+ };
26909
+ var rowSpoken = {
26910
+ active: "Active",
26911
+ idle: "Idle",
26912
+ warn: "Needs attention",
26913
+ error: "Error"
26914
+ };
26915
+ function indent2(depth) {
26916
+ return Math.min(Math.max(Math.floor(depth ?? 0), 0), 6);
26917
+ }
26800
26918
  function attention(section) {
26801
26919
  const errors = section.rows.filter((row) => row.status === "error").length;
26802
26920
  if (errors)
@@ -26810,6 +26928,14 @@ function attention(section) {
26810
26928
  return null;
26811
26929
  }
26812
26930
  var SliccMonitor = class extends ModelElement {
26931
+ static properties = {
26932
+ ...ModelElement.properties,
26933
+ expanded: { state: true }
26934
+ };
26935
+ constructor() {
26936
+ super();
26937
+ this.expanded = {};
26938
+ }
26813
26939
  static styles = [
26814
26940
  shared,
26815
26941
  panelCss,
@@ -26900,6 +27026,9 @@ var SliccMonitor = class extends ModelElement {
26900
27026
  list-style: none;
26901
27027
  }
26902
27028
  .section {
27029
+ display: grid;
27030
+ }
27031
+ .line {
26903
27032
  display: flex;
26904
27033
  flex-wrap: wrap;
26905
27034
  align-items: center;
@@ -26907,14 +27036,82 @@ var SliccMonitor = class extends ModelElement {
26907
27036
  min-height: var(--swc-component-height-100);
26908
27037
  padding: var(--swc-spacing-50) 0;
26909
27038
  }
26910
- .section .name {
27039
+ .toggle {
27040
+ all: unset;
27041
+ box-sizing: border-box;
26911
27042
  flex: 1;
26912
27043
  min-width: 0;
27044
+ display: flex;
27045
+ align-items: center;
27046
+ gap: var(--swc-spacing-75);
27047
+ cursor: pointer;
27048
+ border-radius: var(--swc-corner-radius-small-default);
26913
27049
  }
26914
- .section .num {
27050
+ .toggle:focus-visible {
27051
+ outline: var(--swc-focus-indicator-thickness) solid var(--swc-focus-indicator-color);
27052
+ outline-offset: var(--swc-focus-ring-gap);
27053
+ }
27054
+ .chevron {
27055
+ flex: none;
27056
+ width: var(--swc-component-height-50);
27057
+ display: inline-flex;
27058
+ justify-content: center;
27059
+ color: var(--swc-neutral-subdued-content-color-default);
27060
+ }
27061
+ .toggle[aria-expanded='true'] swc-icon-chevron-right {
27062
+ transform: rotate(90deg);
27063
+ }
27064
+ :host(:dir(rtl)) .toggle[aria-expanded='false'] swc-icon-chevron-right {
27065
+ transform: scaleX(-1);
27066
+ }
27067
+ .line .name {
27068
+ flex: 1;
27069
+ min-width: 0;
27070
+ }
27071
+ .line .num {
26915
27072
  font-weight: var(--swc-bold-font-weight);
26916
27073
  font-variant-numeric: tabular-nums;
26917
27074
  }
27075
+ .rows {
27076
+ display: grid;
27077
+ gap: var(--swc-spacing-50);
27078
+ margin: 0 0 var(--swc-spacing-100);
27079
+ padding: 0;
27080
+ padding-inline-start: calc(var(--swc-component-height-50) + var(--swc-spacing-75));
27081
+ list-style: none;
27082
+ }
27083
+ .row {
27084
+ display: grid;
27085
+ grid-template-columns: minmax(0, 1fr) auto;
27086
+ align-items: center;
27087
+ column-gap: var(--swc-spacing-100);
27088
+ padding-inline-start: calc(var(--depth, 0) * var(--swc-spacing-300));
27089
+ }
27090
+ .row swc-status-light {
27091
+ min-width: 0;
27092
+ overflow-wrap: anywhere;
27093
+ }
27094
+ .row .badges {
27095
+ grid-column: 2;
27096
+ grid-row: 1 / span 2;
27097
+ align-self: start;
27098
+ display: flex;
27099
+ flex-wrap: wrap;
27100
+ justify-content: end;
27101
+ gap: var(--swc-spacing-50);
27102
+ }
27103
+ .row swc-status-light {
27104
+ grid-column: 1;
27105
+ grid-row: 1;
27106
+ }
27107
+ .row .meta {
27108
+ grid-column: 1;
27109
+ grid-row: 2;
27110
+ padding-inline-start: var(--swc-spacing-300);
27111
+ color: var(--swc-neutral-subdued-content-color-default);
27112
+ font-size: var(--swc-font-size-75);
27113
+ overflow-wrap: anywhere;
27114
+ }
26918
27115
  `
26919
27116
  ];
26920
27117
  subscribe(model) {
@@ -26954,16 +27151,36 @@ var SliccMonitor = class extends ModelElement {
26954
27151
  new CustomEvent("show-surface", { detail: { id }, bubbles: true, composed: true })
26955
27152
  );
26956
27153
  }
27154
+ #row(row) {
27155
+ const depth = indent2(row.depth);
27156
+ return b`<li class="row" data-id=${row.id ?? A} data-status=${row.status} data-depth=${depth || A} style=${depth ? `--depth: ${depth}` : A}>
27157
+ <swc-status-light size="s" variant=${rowLights[row.status]}><span class="sr">${rowSpoken[row.status]}: </span>${row.name}</swc-status-light>
27158
+ <span class="badges">${(row.badges ?? []).map((badge) => b`<swc-badge size="s" variant="neutral" subtle>${badge}</swc-badge>`)}</span>
27159
+ ${row.meta ? b`<span class="meta">${row.meta}</span>` : A}
27160
+ </li>`;
27161
+ }
26957
27162
  #section(section) {
26958
27163
  const flag = attention(section);
26959
27164
  const surface2 = surfaces2[section.id];
26960
- return b`<li class="section" data-id=${section.id}>
26961
- <span class="name">${section.label}</span>
26962
- ${flag ? b`<swc-badge size="s" variant=${flag.variant} subtle>${flag.text}</swc-badge>` : A}
26963
- <span class="num">${section.rows.length}</span>
26964
- ${surface2 ? b`<swc-action-button size="s" quiet accessible-label=${`Open ${section.label}`} @click=${() => this.#open(surface2)}
26965
- >Open</swc-action-button
26966
- >` : A}
27165
+ const rows = section.rows.length > 0;
27166
+ const open = rows && (this.expanded[section.id] ?? flag !== null);
27167
+ const list4 = `rows-${section.id}`;
27168
+ return b`<li class="section" data-id=${section.id} data-open=${open ? "" : A}>
27169
+ <div class="line">
27170
+ ${rows ? b`<button class="toggle" aria-expanded=${open ? "true" : "false"} aria-controls=${open ? list4 : A} @click=${() => {
27171
+ this.expanded = { ...this.expanded, [section.id]: !open };
27172
+ }}><span class="chevron"><swc-icon-chevron-right size="s" aria-hidden="true"></swc-icon-chevron-right></span><span class="name">${section.label}</span></button>` : b`<span class="chevron"></span><span class="name">${section.label}</span>`}
27173
+ ${flag ? b`<swc-badge size="s" variant=${flag.variant} subtle>${flag.text}</swc-badge>` : A}
27174
+ <span class="num">${section.rows.length}</span>
27175
+ ${surface2 ? b`<swc-action-button size="s" quiet accessible-label=${`Open ${section.label}`} @click=${() => this.#open(surface2)}
27176
+ >Open</swc-action-button
27177
+ >` : A}
27178
+ </div>
27179
+ ${open ? b`<ul class="rows" id=${list4} aria-label=${section.label}>${c(
27180
+ section.rows,
27181
+ (row, i25) => row.id ?? i25,
27182
+ (row) => this.#row(row)
27183
+ )}</ul>` : A}
26967
27184
  </li>`;
26968
27185
  }
26969
27186
  render() {