@fungi.computer/oyster 0.31.1 → 0.32.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.
@@ -7,6 +7,9 @@ import { createAppSurfaceCommandHost } from "@fungi.computer/nacre/command-host"
7
7
  // App page: mounts one installed App's sandboxed frame and gives it the
8
8
  // capabilities this Oyster host provides. Bundled into `shellScript`.
9
9
  import { RpcTarget, RpcStub } from "@fungi.computer/capnweb";
10
+ import { createElement } from "react";
11
+ import { createRoot } from "react-dom/client";
12
+ import { Toaster, showNotice } from "@fungi.computer/caps/components/toaster";
10
13
  import { OysterAgentBrowserHost } from "./agent-browser.js";
11
14
  import { createPageLifetime } from "./lifetime.js";
12
15
  import { computerTargetUrl } from "../computer-target.js";
@@ -212,6 +215,7 @@ export function oysterShellHandles(config) {
212
215
  methods: appMethods.schema.parse(new Methods(config.methodsUrl)),
213
216
  };
214
217
  }
218
+ const appNotices = "oyster-app-notices";
215
219
  /**
216
220
  * Mount one installed App's own page: its sandboxed frame and nothing else.
217
221
  * Desktop chrome (menus, palette, status) belongs to the trusted shell.
@@ -227,8 +231,14 @@ export async function mountOysterPage() {
227
231
  const commands = createAppSurfaceCommandHost();
228
232
  const mount = commands.mount(config.installationId, config.commands);
229
233
  const agentBrowser = new OysterAgentBrowserHost(lifetime.signal);
234
+ // One App fills this page, so its toasts get the page's own Caps Toaster,
235
+ // mounted when the first one arrives.
236
+ let notices;
237
+ let noticeRoot;
230
238
  lifetime.own(() => {
231
239
  commands.dispose();
240
+ notices?.unmount();
241
+ noticeRoot?.remove();
232
242
  });
233
243
  return connectOysterApp({
234
244
  config,
@@ -244,7 +254,16 @@ export async function mountOysterPage() {
244
254
  openNavigation: denied,
245
255
  reportFocus: () => Promise.resolve(),
246
256
  reportAgentSessionSelection: () => Promise.resolve(),
247
- showToast: () => Promise.resolve(),
257
+ showToast: (notice) => {
258
+ if (notices === undefined) {
259
+ noticeRoot = document.createElement("div");
260
+ document.body.append(noticeRoot);
261
+ notices = createRoot(noticeRoot);
262
+ notices.render(createElement(Toaster, { id: appNotices }));
263
+ }
264
+ showNotice(notice, appNotices);
265
+ return Promise.resolve();
266
+ },
248
267
  onDisconnect: () => {
249
268
  lifetime.dispose();
250
269
  return Promise.resolve();