@ai-ecoverse/slicc-spectrum 1.23.0 → 1.23.2

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
@@ -8541,8 +8541,8 @@ var ModelElement = class extends i2 {
8541
8541
  subscribe(model) {
8542
8542
  return [];
8543
8543
  }
8544
- focusOn(selector) {
8545
- const focus = () => this.renderRoot.querySelector(selector)?.focus();
8544
+ focusOn(...selectors) {
8545
+ const focus = () => selectors.map((selector) => this.renderRoot.querySelector(selector)).find(Boolean)?.focus();
8546
8546
  if (this.hasUpdated) focus();
8547
8547
  else void this.updateComplete.then(focus);
8548
8548
  }
@@ -10338,6 +10338,7 @@ function deepActive(root2) {
10338
10338
  return active?.shadowRoot ? deepActive(active.shadowRoot) ?? active : active;
10339
10339
  }
10340
10340
  var scrollback = 1 << 18;
10341
+ var laid = ({ width, height }) => width > 0 && height > 0;
10341
10342
  var ended = { write() {
10342
10343
  }, resize() {
10343
10344
  }, close() {
@@ -10540,7 +10541,14 @@ var SliccTerminalPanel = class extends ThemedElement {
10540
10541
  if (this.#screen && bound?.port === model.terminals && bound.id === info.id)
10541
10542
  return this.#screen;
10542
10543
  const terminal = document.createElement("slicc-terminal");
10543
- terminal.backend = keep(model.terminals, info.id);
10544
+ const backend = keep(model.terminals, info.id);
10545
+ terminal.backend = {
10546
+ open: async (sink) => {
10547
+ await this.#placed(info.id);
10548
+ terminal.fit();
10549
+ return backend.open(sink, { cols: terminal.cols, rows: terminal.rows });
10550
+ }
10551
+ };
10544
10552
  terminal.addEventListener("exit", () => model.terminals.close(info.id));
10545
10553
  this.#screen = terminal;
10546
10554
  this.#bound = { port: model.terminals, id: info.id };
@@ -10556,6 +10564,18 @@ var SliccTerminalPanel = class extends ThemedElement {
10556
10564
  );
10557
10565
  return terminal;
10558
10566
  }
10567
+ #placed(id) {
10568
+ const host2 = this.getRootNode().host;
10569
+ const panel = host2?.localName === "slicc-dock" ? host2.api.getPanel(terminalPanel(id)) : void 0;
10570
+ if (!panel || laid(panel.api)) return Promise.resolve();
10571
+ return new Promise((resolve) => {
10572
+ const watch = panel.api.onDidDimensionsChange((size4) => {
10573
+ if (!laid(size4)) return;
10574
+ watch.dispose();
10575
+ resolve();
10576
+ });
10577
+ });
10578
+ }
10559
10579
  #request() {
10560
10580
  this.dispatchEvent(new CustomEvent("new-terminal", { bubbles: true, composed: true }));
10561
10581
  }
@@ -13689,6 +13709,10 @@ var SliccUpdates = class extends ModelElement {
13689
13709
  padding: var(--swc-spacing-400);
13690
13710
  margin: 0 auto;
13691
13711
  }
13712
+ .page:focus-visible {
13713
+ outline: var(--swc-focus-indicator-thickness) solid var(--swc-focus-indicator-color);
13714
+ outline-offset: calc(-1 * var(--swc-focus-indicator-thickness));
13715
+ }
13692
13716
  .hint {
13693
13717
  margin: 0 0 var(--swc-spacing-300);
13694
13718
  color: var(--swc-neutral-subdued-content-color-default);
@@ -13805,7 +13829,7 @@ var SliccUpdates = class extends ModelElement {
13805
13829
  ];
13806
13830
  }
13807
13831
  focus() {
13808
- this.focusOn("swc-button, summary");
13832
+ this.focusOn("swc-button, summary", ".page");
13809
13833
  }
13810
13834
  async act(id, action) {
13811
13835
  const port = this.model?.updates;
@@ -13890,7 +13914,7 @@ var SliccUpdates = class extends ModelElement {
13890
13914
  }
13891
13915
  render() {
13892
13916
  const port = this.model?.updates;
13893
- return b`<div class="page">
13917
+ return b`<div class="page" tabindex="-1">
13894
13918
  <p class="hint">${hint(port)}</p>
13895
13919
  ${c(
13896
13920
  port?.list() ?? [],
@@ -15540,9 +15564,7 @@ var SliccBrowser = class extends ModelElement {
15540
15564
  }
15541
15565
  focus() {
15542
15566
  void this.updateComplete.then(
15543
- () => this.focusOn(
15544
- this.renderRoot.querySelector('.window[aria-current="true"]') ? '.window[aria-current="true"]' : ".window"
15545
- )
15567
+ () => this.focusOn('.window[aria-current="true"]', ".window", "form swc-button")
15546
15568
  );
15547
15569
  }
15548
15570
  #key(tab) {
@@ -17118,6 +17140,21 @@ var messageCss = i`
17118
17140
  `;
17119
17141
 
17120
17142
  // src/app/chat.ts
17143
+ var touched = false;
17144
+ document.addEventListener(
17145
+ "pointerdown",
17146
+ (event) => {
17147
+ touched = event.pointerType !== "mouse";
17148
+ },
17149
+ true
17150
+ );
17151
+ document.addEventListener(
17152
+ "keydown",
17153
+ () => {
17154
+ touched = false;
17155
+ },
17156
+ true
17157
+ );
17121
17158
  var SliccChat = class extends ThemedElement {
17122
17159
  static properties = { ...ThemedElement.properties, agent: {} };
17123
17160
  constructor() {
@@ -17169,6 +17206,10 @@ var SliccChat = class extends ThemedElement {
17169
17206
  overflow-y: auto;
17170
17207
  padding: 12px 16px 24px;
17171
17208
  }
17209
+ .log:focus-visible {
17210
+ outline: var(--swc-focus-indicator-thickness) solid var(--swc-focus-indicator-color);
17211
+ outline-offset: calc(-1 * var(--swc-focus-indicator-thickness));
17212
+ }
17172
17213
  .column {
17173
17214
  max-width: 860px;
17174
17215
  margin: 0 auto;
@@ -17247,7 +17288,9 @@ var SliccChat = class extends ThemedElement {
17247
17288
  this.#observe();
17248
17289
  }
17249
17290
  focus() {
17250
- this.focusOn("slicc-composer");
17291
+ if (!touched && globalThis.matchMedia("(pointer: fine)").matches)
17292
+ this.focusOn("slicc-composer");
17293
+ else this.focusOn(".log");
17251
17294
  }
17252
17295
  #id() {
17253
17296
  return this.agent || (this.model?.agent.active() ?? "");
@@ -17340,7 +17383,14 @@ var SliccChat = class extends ThemedElement {
17340
17383
  <header>
17341
17384
  ${agent ? this.#meta(agent) : b`<span>No agent</span>`}
17342
17385
  </header>
17343
- <div class="log" role="log" aria-live="polite" aria-label="Conversation" @scroll=${this.#scroll}>
17386
+ <div
17387
+ class="log"
17388
+ role="log"
17389
+ aria-live="polite"
17390
+ aria-label="Conversation"
17391
+ tabindex="-1"
17392
+ @scroll=${this.#scroll}
17393
+ >
17344
17394
  <div class="column">
17345
17395
  ${agent && messages.length > 0 ? this.#items(messages, agent) : b`<div class="empty">No messages yet. Ask ${agent?.name ?? "the agent"} something.</div>`}
17346
17396
  </div>
@@ -18415,7 +18465,7 @@ var SliccMemory = class extends ModelElement {
18415
18465
  return [model.memory.on("memories", update), model.agent.on("agents", update)];
18416
18466
  }
18417
18467
  focus() {
18418
- this.focusOn("sp-search");
18468
+ this.focusOn(".head", ".bar swc-action-button");
18419
18469
  }
18420
18470
  #save(memory) {
18421
18471
  const form = this.renderRoot.querySelector(".editor");
@@ -18651,6 +18701,9 @@ var SliccMonitor = class extends ModelElement {
18651
18701
  subscribe(model) {
18652
18702
  return [model.monitor.on("snapshot", () => this.requestUpdate())];
18653
18703
  }
18704
+ focus() {
18705
+ this.focusOn(".bar swc-action-button");
18706
+ }
18654
18707
  #vital(vital) {
18655
18708
  if (vital.ratio !== void 0) {
18656
18709
  return b`<div class="vital" data-id=${vital.id}>
@@ -19206,6 +19259,10 @@ var SliccSprinkle = class extends ThemedElement {
19206
19259
  height: 100%;
19207
19260
  border: 0;
19208
19261
  }
19262
+ iframe:focus-visible {
19263
+ outline: var(--swc-focus-indicator-thickness) solid var(--swc-focus-indicator-color);
19264
+ outline-offset: calc(-1 * var(--swc-focus-indicator-thickness));
19265
+ }
19209
19266
  .frame {
19210
19267
  border: 1px solid var(--spectrum-gray-200);
19211
19268
  background: var(--spectrum-background-layer-1-color);
@@ -19274,6 +19331,9 @@ var SliccSprinkle = class extends ThemedElement {
19274
19331
  }
19275
19332
  };
19276
19333
  #dips = new Dips();
19334
+ focus() {
19335
+ this.focusOn("iframe");
19336
+ }
19277
19337
  subscribe(model) {
19278
19338
  this.#dips = dipsOf(this) ?? this.#dips;
19279
19339
  globalThis.addEventListener("message", this.#message);