@graview/guest 0.2.14 → 0.2.16

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.
Files changed (88) hide show
  1. package/README.md +88 -1
  2. package/dist/headless/describe.d.ts +3 -0
  3. package/dist/headless/describe.d.ts.map +1 -1
  4. package/dist/headless/describe.js +15 -0
  5. package/dist/headless/describe.js.map +1 -1
  6. package/dist/headless/index.d.ts +3 -0
  7. package/dist/headless/index.d.ts.map +1 -1
  8. package/dist/headless/index.js +1 -0
  9. package/dist/headless/index.js.map +1 -1
  10. package/dist/headless/judge.js +2 -2
  11. package/dist/headless/judge.js.map +1 -1
  12. package/dist/headless/protocol.d.ts +3 -0
  13. package/dist/headless/protocol.d.ts.map +1 -1
  14. package/dist/headless/protocol.js.map +1 -1
  15. package/dist/headless/runtime.generated.d.ts.map +1 -1
  16. package/dist/headless/runtime.generated.js +1 -1
  17. package/dist/headless/runtime.generated.js.map +1 -1
  18. package/dist/host/embed-player.d.ts +16 -0
  19. package/dist/host/embed-player.d.ts.map +1 -0
  20. package/dist/host/embed-player.js +248 -0
  21. package/dist/host/embed-player.js.map +1 -0
  22. package/dist/host/embeds.d.ts +48 -0
  23. package/dist/host/embeds.d.ts.map +1 -0
  24. package/dist/host/embeds.js +153 -0
  25. package/dist/host/embeds.js.map +1 -0
  26. package/dist/host/frame.d.ts +12 -0
  27. package/dist/host/frame.d.ts.map +1 -1
  28. package/dist/host/frame.js +71 -4
  29. package/dist/host/frame.js.map +1 -1
  30. package/dist/host/media.d.ts +3 -0
  31. package/dist/host/media.d.ts.map +1 -1
  32. package/dist/host/media.js +23 -0
  33. package/dist/host/media.js.map +1 -1
  34. package/dist/host/mine.d.ts +11 -1
  35. package/dist/host/mine.d.ts.map +1 -1
  36. package/dist/host/mine.js +111 -15
  37. package/dist/host/mine.js.map +1 -1
  38. package/dist/host/open-draw.d.ts +1 -1
  39. package/dist/host/open-draw.d.ts.map +1 -1
  40. package/dist/host/open-draw.js +2 -0
  41. package/dist/host/open-draw.js.map +1 -1
  42. package/dist/host/problems.d.ts +1 -1
  43. package/dist/host/problems.d.ts.map +1 -1
  44. package/dist/host/problems.js +6 -0
  45. package/dist/host/problems.js.map +1 -1
  46. package/dist/host/react.d.ts +17 -0
  47. package/dist/host/react.d.ts.map +1 -1
  48. package/dist/host/react.js +77 -11
  49. package/dist/host/react.js.map +1 -1
  50. package/dist/host/session.d.ts +18 -0
  51. package/dist/host/session.d.ts.map +1 -1
  52. package/dist/host/session.js +38 -4
  53. package/dist/host/session.js.map +1 -1
  54. package/dist/host/view-ahead.d.ts +21 -0
  55. package/dist/host/view-ahead.d.ts.map +1 -0
  56. package/dist/host/view-ahead.js +29 -0
  57. package/dist/host/view-ahead.js.map +1 -0
  58. package/dist/host/view-runtime.generated.d.ts.map +1 -1
  59. package/dist/host/view-runtime.generated.js +1 -1
  60. package/dist/host/view-runtime.generated.js.map +1 -1
  61. package/dist/host/view-script.d.ts +1 -0
  62. package/dist/host/view-script.d.ts.map +1 -1
  63. package/dist/host/view-script.js +1 -1
  64. package/dist/host/view-script.js.map +1 -1
  65. package/dist/host/view.d.ts +30 -0
  66. package/dist/host/view.d.ts.map +1 -1
  67. package/dist/host/view.js +203 -22
  68. package/dist/host/view.js.map +1 -1
  69. package/dist/host/views.d.ts +2 -0
  70. package/dist/host/views.d.ts.map +1 -1
  71. package/dist/host/views.js +1 -0
  72. package/dist/host/views.js.map +1 -1
  73. package/dist/host/worker-react.d.ts +3 -0
  74. package/dist/host/worker-react.d.ts.map +1 -1
  75. package/dist/host/worker-react.js +114 -24
  76. package/dist/host/worker-react.js.map +1 -1
  77. package/dist/host/worker.d.ts +4 -0
  78. package/dist/host/worker.d.ts.map +1 -1
  79. package/dist/host/worker.js +4 -0
  80. package/dist/host/worker.js.map +1 -1
  81. package/dist/open-kit.d.ts +1 -1
  82. package/dist/open-kit.d.ts.map +1 -1
  83. package/dist/open-kit.js +8 -2
  84. package/dist/open-kit.js.map +1 -1
  85. package/dist/worker/view-global.d.ts.map +1 -1
  86. package/dist/worker/view-global.js +64 -17
  87. package/dist/worker/view-global.js.map +1 -1
  88. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"view-runtime.generated.js","sourceRoot":"","sources":["../../src/host/view-runtime.generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAW,o0qEAAo0qE,CAAC"}
1
+ {"version":3,"file":"view-runtime.generated.js","sourceRoot":"","sources":["../../src/host/view-runtime.generated.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAW,+zsEAA+zsE,CAAC"}
@@ -1,3 +1,4 @@
1
+ export declare const viewRuntime: () => Promise<typeof import("./view-runtime.generated.js")>;
1
2
  /**
2
3
  * The worker's whole script for a view's source: the runtime, then the view
3
4
  * in a strict function of its own. What the host makes a `blob:` worker of;
@@ -1 +1 @@
1
- {"version":3,"file":"view-script.d.ts","sourceRoot":"","sources":["../../src/host/view-script.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE"}
1
+ {"version":3,"file":"view-script.d.ts","sourceRoot":"","sources":["../../src/host/view-script.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,6DAInB,CAAC;AAEN;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE"}
@@ -5,7 +5,7 @@
5
5
  * `import()` whose specifier is computed at run time.
6
6
  */
7
7
  let loading;
8
- const viewRuntime = () => (loading ??= import("./view-runtime.generated.js").catch((error) => {
8
+ export const viewRuntime = () => (loading ??= import("./view-runtime.generated.js").catch((error) => {
9
9
  loading = undefined;
10
10
  throw error;
11
11
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"view-script.js","sourceRoot":"","sources":["../../src/host/view-script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,IAAI,OAA0E,CAAC;AAC/E,MAAM,WAAW,GAAG,GAAG,EAAE,CACvB,CAAC,OAAO,KAAK,MAAM,CAAC,6BAA6B,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1E,OAAO,GAAG,SAAS,CAAC;IACpB,MAAM,KAAK,CAAC;AACd,CAAC,CAAC,CAAC,CAAC;AAEN;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;IAC7C,OAAO,GAAG,YAAY,qCAAqC,MAAM,WAAW,CAAC;AAC/E,CAAC"}
1
+ {"version":3,"file":"view-script.js","sourceRoot":"","sources":["../../src/host/view-script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,IAAI,OAA0E,CAAC;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAC9B,CAAC,OAAO,KAAK,MAAM,CAAC,6BAA6B,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1E,OAAO,GAAG,SAAS,CAAC;IACpB,MAAM,KAAK,CAAC;AACd,CAAC,CAAC,CAAC,CAAC;AAEN;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;IAC7C,OAAO,GAAG,YAAY,qCAAqC,MAAM,WAAW,CAAC;AAC/E,CAAC"}
@@ -6,6 +6,7 @@ import type { ViewRefusal } from "./open-draw.js";
6
6
  import { type GuestLimits, type GuestStats, type GuestViewInput } from "./session.js";
7
7
  import { type Arrival } from "./links.js";
8
8
  import type { GoTo } from "@graview/react/provider";
9
+ import type { EmbedHost } from "./embeds.js";
9
10
  import { readTheme, type GuestBrand } from "./theme.js";
10
11
  import { type WorkerViewCode, type WorkerViewLoad } from "./code-of.js";
11
12
  export type { WorkerViewCode, WorkerViewLoad } from "./code-of.js";
@@ -215,6 +216,17 @@ export interface MountWorkerViewOptions<S extends AnySchema> {
215
216
  readonly links?: {
216
217
  readonly origins: readonly string[];
217
218
  };
219
+ /**
220
+ * WHICH PROVIDERS A VIEW MAY PLAY A VIDEO FROM (HQ f-view-video-embeds),
221
+ * of the closed list `EMBED_PROVIDERS` ("youtube", "vimeo"): both unsaid,
222
+ * so a host whose page plays from one says it alone, and `{ providers: [] }`
223
+ * turns every one off. One turned off is drawn as its link out, alone.
224
+ * Nothing is asked of a provider before a person presses play; the page's
225
+ * own policy must allow its frame (`frame-src` https://www.youtube-nocookie.com
226
+ * https://player.vimeo.com), and where it does not the video says so and
227
+ * keeps its link.
228
+ */
229
+ readonly embeds?: EmbedHost;
218
230
  /** Who made it, said under the region (ADR 0007: "Made by Claude for Nick"). Nothing by default. */
219
231
  readonly author?: string;
220
232
  /**
@@ -258,6 +270,24 @@ export interface WorkerView {
258
270
  readonly worker: Worker | undefined;
259
271
  /** Push again: the view's input, or the app's look, moved. */
260
272
  update(): void;
273
+ /**
274
+ * OFF THE PAGE, TO BE GONE BACK TO (Graview HQ f-custom-pages-do-not-flash):
275
+ * the region is taken out of the document with its worker kept, the view
276
+ * handed nothing meanwhile, an act it asks for refused and a navigate of
277
+ * its dropped. False where it has not drawn, failed, or is taking a file:
278
+ * the host disposes of it as ever. `gone` is called where it shows a record
279
+ * its seat may no longer see: the host disposes of it then.
280
+ */
281
+ rest(gone: () => void): boolean;
282
+ /**
283
+ * BACK ON THE PAGE, in this element, as it stood: what a person typed and
284
+ * where it was scrolled as they were, and, where what it shows has changed,
285
+ * pushed at once and a press made before that is drawn waiting for it.
286
+ * Undefined where it stands with something its seat is no longer shown: the
287
+ * host disposes of it and draws it anew. Else what puts the keyboard back
288
+ * in the field it was in, for the host to call once its page has arrived.
289
+ */
290
+ wake(onto: HTMLElement): (() => void) | undefined;
261
291
  readonly stats: Readonly<GuestStats>;
262
292
  /** What of the view's drawing and stylesheet was refused. */
263
293
  readonly refused: readonly ViewRefusal[];
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/host/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,eAAe,CAAC;AAIlE,OAAO,EAA0B,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAkB,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAKxM,OAAO,KAAK,EAAiB,UAAU,EAAc,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGxF,OAAO,EAA6H,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnL,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAuD,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ3I,OAAO,EAAyC,KAAK,OAAO,EAAoB,MAAM,YAAY,CAAC;AAEnG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAOpD,OAAO,EAAmB,SAAS,EAA8B,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAErG,OAAO,EAAU,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEhF,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA+BnE,MAAM,MAAM,iBAAiB;AAC3B,2GAA2G;AACzG,UAAU;AACZ,sEAAsE;GACpE,QAAQ;AACV;;;;GAIG;GACD,OAAO;AACT,uDAAuD;GACrD,OAAO;AACT,8FAA8F;GAC5F,QAAQ;AACV,oCAAoC;GAClC,OAAO;AACT,kEAAkE;GAChE,OAAO;AACT;;;;G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CAAC;IACpC,8DAA8D;IAC9D,MAAM,IAAI,IAAI,CAAC;IACf;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;IAChC;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IACrC,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,8HAA8H;IAC9H,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,+HAA+H;IAC/H,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,UAAU,CA+nCzH"}
package/dist/host/view.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { imageRefusedWords } from "./open-judge.js";
2
2
  import { keepClicked } from "./clicked.js";
3
3
  import { guestPlacesOf } from "./links-words.js";
4
- import { actingAs, seatPersonOf } from "@graview/core";
4
+ import {} from "@graview/core";
5
5
  import { readsOnlyUnseen, unseenOf, viewKinds } from "./unseen.js";
6
- import { createMine, keptForTheVisit, visitOf } from "./mine.js";
6
+ import { createMine, keptForTheVisit, viewerOf, visitOf } from "./mine.js";
7
7
  import { storedFilesOf } from "./marks.js";
8
8
  import { retryingImport } from "@graview/core/retry";
9
9
  import { PART_SHARE } from "../part.js";
@@ -139,6 +139,11 @@ export function mountWorkerView(element, options) {
139
139
  let started;
140
140
  let drawing;
141
141
  let failed = false;
142
+ /* Off the page, to be gone back to: what it stood as, and how it is let go of (`rest`). */
143
+ let resting;
144
+ /* Back on the page with something changed since: a press waits for the push that answers it (`wake`). */
145
+ let refreshing = false;
146
+ let heldPresses = [];
142
147
  /*
143
148
  * WHERE ITS RECORDS ARE (Graview HQ feature:f-one-face-lines-from-frame-views,
144
149
  * view-records.ts): each element it drew marked with `data-record`, of a
@@ -192,6 +197,8 @@ export function mountWorkerView(element, options) {
192
197
  if (heights || !root || typeof Observer !== "function")
193
198
  return;
194
199
  heights = new Observer((entries) => {
200
+ if (resting)
201
+ return;
195
202
  const box = entries[entries.length - 1]?.borderBoxSize?.[0];
196
203
  const height = Math.ceil(box ? box.blockSize : root.offsetHeight);
197
204
  if (height === contentHeight)
@@ -215,6 +222,8 @@ export function mountWorkerView(element, options) {
215
222
  let timing = 0;
216
223
  /* What the person typed into a field saved as it is typed and not yet saved (FR-191, press.ts): saved as the view goes. */
217
224
  let flushSaves = () => { };
225
+ /* The same, with the view staying: its page is being left, to be gone back to (`rest`). */
226
+ let saveNow = () => { };
218
227
  /* This drawing has gone: what it asked the host to keep still lands. */
219
228
  let letGoOfMine = () => { };
220
229
  /* A jump, what is in sight and a record's file (sections.ts); why a press was refused, beside it (refused-note.ts). */
@@ -419,6 +428,8 @@ export function mountWorkerView(element, options) {
419
428
  };
420
429
  let pushed = "";
421
430
  const push = () => {
431
+ if (resting)
432
+ return;
422
433
  pushed = JSON.stringify(theme());
423
434
  dress();
424
435
  session?.push();
@@ -426,7 +437,7 @@ export function mountWorkerView(element, options) {
426
437
  media?.refresh(shadow);
427
438
  };
428
439
  const looked = () => {
429
- if (session && JSON.stringify(theme()) !== pushed)
440
+ if (session && !resting && JSON.stringify(theme()) !== pushed)
430
441
  push();
431
442
  };
432
443
  const unwatchTheme = watchTheme(document, looked);
@@ -491,7 +502,9 @@ export function mountWorkerView(element, options) {
491
502
  * `data-worker-view-failed` instead, its plain face drawn.
492
503
  */
493
504
  let answered = false;
494
- const mark = () => region.toggleAttribute("data-worker-view-drawn", !failed && answered && drawing !== undefined && waiting.length === 0 && pending.size === 0 && !pictures?.waiting() && !(drops?.waiting ?? 0));
505
+ /* Its videos' player is on its way: what it stands in is not drawn yet. */
506
+ let mediaWaits = false;
507
+ const mark = () => region.toggleAttribute("data-worker-view-drawn", !failed && answered && drawing !== undefined && waiting.length === 0 && pending.size === 0 && !mediaWaits && !pictures?.waiting() && !(drops?.waiting ?? 0));
495
508
  /*
496
509
  * TIME PER PUSH (FR-94). Each push of what the view is shown is timed
497
510
  * from when the host sends it to when the runtime says it has drawn it,
@@ -605,18 +618,27 @@ export function mountWorkerView(element, options) {
605
618
  */
606
619
  let media;
607
620
  let mediaAsked = false;
608
- const wantMedia = () => {
621
+ let mediaTurn = 0;
622
+ let mediaMissed = false;
623
+ /* Nothing is fetched for a view at rest: what it placed is marked again as it is gone back to. */
624
+ const wantMedia = (waits) => {
625
+ if (resting)
626
+ return;
627
+ if (waits && !media && !mediaMissed)
628
+ mediaWaits = true;
609
629
  if (mediaAsked)
610
630
  return;
611
631
  mediaAsked = true;
632
+ const turn = (mediaTurn += 1);
612
633
  void mediaChunk().then(({ createGuestMedia }) => {
613
- if (failed)
634
+ if (failed || turn !== mediaTurn)
614
635
  return;
615
636
  media = createGuestMedia(window, {
616
637
  view: `"${manifest.title ?? manifest.name}"`,
617
638
  pictures: manifest.pictures !== undefined,
618
639
  shown: () => lastProps,
619
640
  ...(options.reel ? { reel: options.reel } : {}),
641
+ ...(options.embeds ? { embeds: options.embeds } : {}),
620
642
  ...(options.file ? { file: options.file } : {}),
621
643
  onProblem: (said, problem) => {
622
644
  port?.postMessage({ type: "notice", text: said });
@@ -624,7 +646,19 @@ export function mountWorkerView(element, options) {
624
646
  },
625
647
  });
626
648
  media.refresh(shadow);
627
- }, () => options.onProblem?.(`The view "${manifest.title ?? manifest.name}" places a video or a full-screen viewer, and the host's player could not be loaded.`, { code: "host-part-not-loaded" }));
649
+ mediaWaits = false;
650
+ mark();
651
+ }, () => {
652
+ if (turn !== mediaTurn)
653
+ return;
654
+ /* Asked for again as the view next draws. */
655
+ mediaWaits = mediaAsked = false;
656
+ const said = mediaMissed;
657
+ mediaMissed = true;
658
+ mark();
659
+ if (!said)
660
+ options.onProblem?.(`The view "${manifest.title ?? manifest.name}" places a video or a full-screen viewer, and the host's player could not be loaded.`, { code: "host-part-not-loaded" });
661
+ });
628
662
  };
629
663
  /*
630
664
  * FILES DROPPED ON WHAT IT DREW (FR-193, drop.ts): fetched the first time
@@ -731,14 +765,21 @@ export function mountWorkerView(element, options) {
731
765
  options.onProblem?.(`The view "${manifest.title ?? manifest.name}" draws a jump or a file link, and the host's part of it could not be loaded.`, { code: "host-part-not-loaded" });
732
766
  return undefined;
733
767
  }));
768
+ /* Its players and its full-screen viewer, let go with its page; drawn again as it is gone back to. */
769
+ const letGoOfMedia = () => {
770
+ media?.dispose();
771
+ media = undefined;
772
+ mediaAsked = mediaWaits = false;
773
+ mediaTurn += 1;
774
+ };
734
775
  const marksMedia = (element) => {
735
776
  if (element.localName === "graview-video")
736
- return wantMedia();
777
+ return wantMedia(element.hasAttribute("data-provider") || element.hasAttribute("data-watch"));
737
778
  if (!element.hasAttribute("data-lightbox"))
738
779
  return;
739
780
  /* It opens the host's viewer: said so to assistive technology. */
740
781
  element.setAttribute("aria-haspopup", "dialog");
741
- wantMedia();
782
+ wantMedia(false);
742
783
  };
743
784
  void Promise.all([openDrawChunk(), pressChunk()]).then(([{ createOpenDrawing, createPartFallbacks, handedLinks, judgeLink, linkRefusedWords }, { createPressReader, createSaver, fillPrefills, judgePress, markPresses, prefillOf, quietPictures }]) => {
744
785
  if (failed)
@@ -788,6 +829,7 @@ export function mountWorkerView(element, options) {
788
829
  });
789
830
  const leaving = () => saver.flush();
790
831
  window.addEventListener("pagehide", leaving);
832
+ saveNow = leaving;
791
833
  flushSaves = () => {
792
834
  window.removeEventListener("pagehide", leaving);
793
835
  saver.flush();
@@ -803,7 +845,10 @@ export function mountWorkerView(element, options) {
803
845
  markPresses(shadow);
804
846
  quietPictures(shadow);
805
847
  fillPrefills(shadow, reader, prefilled, (asked) => prefillOf(options.store, options.principal, manifest, shown, asked));
806
- media?.refresh(shadow);
848
+ if (media)
849
+ media.refresh(shadow);
850
+ else if (mediaMissed)
851
+ wantMedia(false);
807
852
  drops?.refresh();
808
853
  notes?.refresh();
809
854
  if (sections)
@@ -838,7 +883,7 @@ export function mountWorkerView(element, options) {
838
883
  port?.postMessage({ type: "notice", text: said });
839
884
  return options.onProblem?.(said, { code: "link-refused" });
840
885
  }
841
- if (refusal.reason !== "url" || refusal.element !== "img" || refusal.address === undefined || toldImages.has(refusal.address))
886
+ if (refusal.reason !== "url" || (refusal.element !== "img" && refusal.element !== "graview-video") || refusal.address === undefined || toldImages.has(refusal.address))
842
887
  return;
843
888
  toldImages.add(refusal.address);
844
889
  const said = imageRefusedWords(refusal.address, { ...(options.images ? { origins: options.images.origins } : {}), assets: options.asset !== undefined }, refusal.length);
@@ -902,15 +947,41 @@ export function mountWorkerView(element, options) {
902
947
  if (!press || !session)
903
948
  return;
904
949
  event.stopPropagation();
905
- notes?.clear(at.closest("[data-act]"));
950
+ const bound = at.closest("[data-act]");
951
+ notes?.clear(bound);
906
952
  /* Space on a press is the press, never the page scrolling under it. */
907
953
  if (event.type === "keydown")
908
954
  event.preventDefault();
955
+ /*
956
+ * GONE BACK TO, AND NOT YET UP TO DATE: a press waits until what
957
+ * changed since has been drawn, and is then read again on what stands
958
+ * — applied where the control asks exactly what it asked. Where it is
959
+ * gone, or asks something else (a row drawn over for another record),
960
+ * the press was for what no longer stands, and does nothing.
961
+ */
962
+ if (refreshing) {
963
+ const meant = JSON.stringify(press);
964
+ heldPresses.push(() => {
965
+ if (failed || !session || !bound.isConnected || !at.isConnected)
966
+ return;
967
+ const now = reader.press(event, at, root);
968
+ /* Not what was pressed any more: said beside the control, and nothing done. */
969
+ if (!now || JSON.stringify(now) !== meant)
970
+ return acted(bound, { as: press.as, ok: false, reason: "refused", message: "This changed as you pressed it, so nothing was done." });
971
+ const outcome = session.pressed(judgePress(options.store, manifest, shown, now));
972
+ tally();
973
+ const pressed = { as: now.as, ...outcome };
974
+ const target = drawing?.renderer.idOf(at);
975
+ if (target !== undefined)
976
+ send({ type: "dom-event", target, event: event.type, pressed });
977
+ acted(bound, pressed);
978
+ });
979
+ return false;
980
+ }
909
981
  const outcome = session.pressed(judgePress(options.store, manifest, shown, press));
910
982
  tally();
911
983
  const pressed = { as: press.as, ...outcome };
912
984
  /* Told with the click, and then as `acted`, the one event a view hears every act's outcome by. */
913
- const bound = at.closest("[data-act]");
914
985
  queueMicrotask(() => acted(bound, pressed));
915
986
  return { pressed };
916
987
  },
@@ -931,8 +1002,7 @@ export function mountWorkerView(element, options) {
931
1002
  * problem says no value. Never the graph's.
932
1003
  */
933
1004
  const hostState = options.draft ? undefined : options.viewerState?.();
934
- /* A seat, as a binding names it (`seatPersonOf`): a profile is its own viewer; a seat whose id holds a `~` has none, and is still nobody else, never falling to the key of a seat with no id. */
935
- const viewer = seatPersonOf(options.principal) ?? actingAs(options.principal).id ?? options.principal.visitorKey ?? "";
1005
+ const viewer = viewerOf(options.principal);
936
1006
  const mine = createMine({
937
1007
  view: manifest.name,
938
1008
  viewer,
@@ -946,6 +1016,14 @@ export function mountWorkerView(element, options) {
946
1016
  onLate: () => session?.push(),
947
1017
  });
948
1018
  letGoOfMine = () => mine.dispose();
1019
+ /* What it is shown now, as its seat sees it: one answer to what the seat is kept from, for its places and what it is told it cannot see (`batch.kept`). */
1020
+ const propsNow = () => {
1021
+ let made;
1022
+ inOneBatch(() => {
1023
+ made = workerViewProps(options.store, options.principal, { manifest, ...(options.input ? { input: options.input() } : {}), theme: theme(), places: guestPlacesOf(vocabulary()), kept: kept(), ...(computed ? { computed } : {}) });
1024
+ });
1025
+ return { ...made, mine: mine.values() };
1026
+ };
949
1027
  const begin = (source) => (started = startWorker(window, {
950
1028
  source,
951
1029
  name: manifest.name,
@@ -987,12 +1065,7 @@ export function mountWorkerView(element, options) {
987
1065
  },
988
1066
  mine,
989
1067
  props: () => {
990
- /* One answer to what the seat is kept from, for its places and what it is told it cannot see (`batch.kept`). */
991
- let made;
992
- inOneBatch(() => {
993
- made = workerViewProps(options.store, options.principal, { manifest, ...(options.input ? { input: options.input() } : {}), theme: theme(), places: guestPlacesOf(vocabulary()), kept: kept(), ...(computed ? { computed } : {}) });
994
- });
995
- const props = { ...made, mine: mine.values() };
1068
+ const props = propsNow();
996
1069
  const was = shown;
997
1070
  shown = new Set([...(props.node ? [props.node.id] : []), ...(props.nodes ?? []).map((node) => node.id)]);
998
1071
  /* The record it shows changed (Roadmap f-app-wide-view-theme): under the brand's "fade", what is drawn goes before the new one comes. */
@@ -1032,6 +1105,12 @@ export function mountWorkerView(element, options) {
1032
1105
  return fail("slow");
1033
1106
  answered = true;
1034
1107
  mark();
1108
+ /* Brought up to date since its page was gone back to: a press made meanwhile is read now, on what stands now. */
1109
+ if (refreshing && pending.size === 0) {
1110
+ refreshing = false;
1111
+ for (const press of heldPresses.splice(0))
1112
+ press();
1113
+ }
1035
1114
  },
1036
1115
  /* Past the message allowance, a view is stopped, not read on (FR-94). */
1037
1116
  onFlood: () => fail("flood"),
@@ -1047,7 +1126,7 @@ export function mountWorkerView(element, options) {
1047
1126
  live.receive(data);
1048
1127
  tally();
1049
1128
  /* Where the view asked to go is the links' to judge, so one that goes nowhere says why (FR-93); one that names no string is refused unsaid. */
1050
- if (!failed && data?.nonce === nonce && data.type === "navigate") {
1129
+ if (!failed && !resting && data?.nonce === nonce && data.type === "navigate") {
1051
1130
  /* Narrowed and to a section, as it asked: the links hold the filter to the kind's fields. */
1052
1131
  const also = { ...(data.where !== undefined ? { where: data.where } : {}), ...(data.section !== undefined ? { section: data.section } : {}) };
1053
1132
  const to = typeof data.place === "string" ? { place: data.place, ...also } : typeof data.to === "string" && { record: data.to, ...also };
@@ -1099,6 +1178,90 @@ export function mountWorkerView(element, options) {
1099
1178
  else
1100
1179
  run(given);
1101
1180
  return handle();
1181
+ /** What its seat is kept from of the app's kinds, as one string. */
1182
+ function keptSaid() {
1183
+ return [...keptNow()].sort().join(" ");
1184
+ }
1185
+ /** Off the page, to be gone back to: `WorkerView.rest`. */
1186
+ function rest(gone) {
1187
+ if (failed || resting || !drawing || !session || !answered || waiting.length > 0 || !lastProps || (drops?.waiting ?? 0) > 0 || region.style.display === "none")
1188
+ return false;
1189
+ /* What the person typed into a field saved as it is typed is saved as its page is left, as it was when the view went with it. */
1190
+ saveNow();
1191
+ if (failed || !session)
1192
+ return false;
1193
+ const at = shadow.activeElement;
1194
+ resting = {
1195
+ scrolled: [...shadow.querySelectorAll("*")].flatMap((one) => (one.scrollTop !== 0 || one.scrollLeft !== 0 ? [[one, one.scrollTop, one.scrollLeft]] : [])),
1196
+ field: at && /^(input|textarea|select)$/.test(at.localName) ? at : undefined,
1197
+ said: JSON.stringify(lastProps),
1198
+ kept: keptSaid(),
1199
+ };
1200
+ letGoOfMedia();
1201
+ heldPresses = [];
1202
+ const was = resting;
1203
+ session.rest({
1204
+ push: false,
1205
+ /* A record it shows gone from its seat's sight, or a kind kept from the seat: let go at once. */
1206
+ moved: () => {
1207
+ if (keptSaid() === was.kept && [...shown].every(seesNow))
1208
+ return true;
1209
+ gone();
1210
+ return false;
1211
+ },
1212
+ });
1213
+ unfollowPanel();
1214
+ unfollowPanel = () => { };
1215
+ region.remove();
1216
+ author?.remove();
1217
+ return true;
1218
+ }
1219
+ /** Back on the page, in `onto`: `WorkerView.wake`. */
1220
+ function wake(onto) {
1221
+ const was = resting;
1222
+ if (failed || !was || !session || !lastProps)
1223
+ return undefined;
1224
+ onto.append(region, ...(author ? [author] : []));
1225
+ const now = propsNow();
1226
+ const changed = JSON.stringify(now) !== was.said;
1227
+ /* Anything it stands with that its seat is no longer shown, or text of a record's it was given to edit that may have moved: drawn anew. */
1228
+ if (changed && (keptSaid() !== was.kept || lost(lastProps, now) || (shadow.querySelector("[data-prefill]") && recordsSaid(lastProps) !== recordsSaid(now)))) {
1229
+ region.remove();
1230
+ author?.remove();
1231
+ return undefined;
1232
+ }
1233
+ resting = undefined;
1234
+ session.rest(undefined);
1235
+ unfollowPanel = followInPanel(region, () => shadow.querySelector("[data-graview-view-root]"));
1236
+ /* Where it was scrolled, before the page is painted. */
1237
+ for (const [one, top, left] of was.scrolled) {
1238
+ one.scrollTop = top;
1239
+ one.scrollLeft = left;
1240
+ }
1241
+ /* An entrance it played as it was first drawn is not played again; what runs forever, or with a scroll, runs on. */
1242
+ for (const one of shadow.getAnimations?.() ?? []) {
1243
+ if (one.timeline !== document.timeline || one.effect?.getComputedTiming().endTime === Infinity)
1244
+ continue;
1245
+ one.finish();
1246
+ }
1247
+ for (const one of shadow.querySelectorAll("graview-video, [data-lightbox]"))
1248
+ marksMedia(one);
1249
+ recordsMoved();
1250
+ /* What another of the viewer's devices kept meanwhile. */
1251
+ if (hostState)
1252
+ mine.reread();
1253
+ refreshing = changed || pending.size > 0;
1254
+ options.onContentHeight?.(contentHeight);
1255
+ /* Pushed whether or not its records moved: its pictures, the app's stylesheet and its faces may have (`dress`). */
1256
+ push();
1257
+ return () => {
1258
+ const field = was.field;
1259
+ const on = document.activeElement;
1260
+ /* The keyboard back in the field it was in, unless the person has put it in another since: a page arrived at puts it on its heading. */
1261
+ if (field?.isConnected && (!on || on === document.body || on.getAttribute("tabindex") === "-1"))
1262
+ field.focus({ preventScroll: true });
1263
+ };
1264
+ }
1102
1265
  function handle() {
1103
1266
  return {
1104
1267
  element: region,
@@ -1110,6 +1273,8 @@ export function mountWorkerView(element, options) {
1110
1273
  if (session)
1111
1274
  push();
1112
1275
  },
1276
+ rest,
1277
+ wake,
1113
1278
  get stats() {
1114
1279
  tally();
1115
1280
  return stats;
@@ -1139,6 +1304,22 @@ export function mountWorkerView(element, options) {
1139
1304
  };
1140
1305
  }
1141
1306
  }
1307
+ /** The records a view was shown, as one string. */
1308
+ const recordsSaid = (props) => JSON.stringify([props.node, props.nodes]);
1309
+ /** Whether what a view was shown holds anything it would not be shown now: a record, a field of one, a computed value, a link. */
1310
+ function lost(was, now) {
1311
+ if (JSON.stringify(was.unseen) !== JSON.stringify(now.unseen))
1312
+ return true;
1313
+ const of = (props) => [...(props.node ? [props.node] : []), ...(props.nodes ?? [])];
1314
+ const by = new Map(of(now).map((node) => [node.id, node]));
1315
+ const ties = new Set(now.edges?.map((edge) => JSON.stringify(edge)));
1316
+ if (was.edges?.some((edge) => !ties.has(JSON.stringify(edge))))
1317
+ return true;
1318
+ return of(was).some((node) => {
1319
+ const here = by.get(node.id);
1320
+ return !here || Object.entries(node).some(([field, value]) => value !== undefined && value !== null && here[field] === undefined);
1321
+ });
1322
+ }
1142
1323
  /** The line drawn where every kind a view reads is kept from its seat: the host's way in, or that nothing here is shown. */
1143
1324
  function drawKept(shadow, region, signIn) {
1144
1325
  const document = region.ownerDocument;