@startside/swa 1.0.2 → 1.0.3

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/swa/1.0/swa.d.ts CHANGED
@@ -45,12 +45,16 @@ declare global {
45
45
  settingschange: WidgetEvent<{ names: string[] }>;
46
46
  /** One of the widget's own actions (declared in `<menu id="actions">`, 7.13) chosen in its options menu. */
47
47
  action: WidgetEvent<{ id: string }>;
48
+ /** A picture opened with `openPhoto({ deletable: true, id })`, deleted by the person in the host's window. */
49
+ photodelete: WidgetEvent<{ id: string }>;
50
+ /** Its pictures (`storage.files`) changed: Sync, another copy of the page, or its own call. List them again. */
51
+ fileschange: WidgetEvent<null>;
48
52
  }
49
53
 
50
54
  interface Widget extends EventTarget {
51
55
  // 7.2 Identity and environment
52
56
  readonly id: string;
53
- /** The title shown: the person's name for the widget if they renamed it (then `settingschange` with `title`), else its own (7.3). */
57
+ /** The title shown: the widget's own, its file's `<title>` until it sets another (7.3). */
54
58
  readonly title: string;
55
59
  /** The widget file's address. */
56
60
  readonly uwaUrl: string;
@@ -120,6 +124,11 @@ declare global {
120
124
  fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
121
125
  /** RSS, Atom or JSON Feed as a JSON Feed 1.1, kept by the host: a kept copy answers at once. */
122
126
  fetchFeed(url: string, options?: FetchFeedOptions): Promise<ContentFeed>;
127
+ /**
128
+ * A picture fetched by the host as itself (with its Referer; 8.6): an address to show in an `img`, the same for the
129
+ * same picture. https, a raster picture of 2 MB at most; rejects with a TypeError otherwise.
130
+ */
131
+ fetchImage(url: string, options?: { signal?: AbortSignal | null }): Promise<string>;
123
132
 
124
133
  // 7.10 Read state and counts
125
134
  readItems(box: Element, itemSelector: string, options?: { key?: (item: Element) => string }): void;
@@ -148,6 +157,8 @@ declare global {
148
157
  // 7.13 The page
149
158
  shareUrl(): string | null;
150
159
  share(data?: { text?: string; url?: string }): unknown;
160
+ /** Startside's extension: the page's Send to… for this widget; nothing where environment.people is null. */
161
+ sendTo(): void;
151
162
  /** Absent where no widget can be added (a preview, a widget on its own page): `if (widget.addWidget)`. */
152
163
  addWidget?(spec: AddWidgetSpec): unknown;
153
164
  /** `spec`, or a function giving it as the drag starts, given the drag's event; nothing given, the drag doesn't start. */
@@ -205,6 +216,31 @@ declare global {
205
216
  readonly memory: WidgetStorageArea;
206
217
  /** Across reloads, shared by every widget of the same file: scores. */
207
218
  readonly local: WidgetStorageArea;
219
+ /** Its own pictures, kept for good and the same on the person's other devices (synced): photos it took. */
220
+ readonly files: WidgetFiles;
221
+ }
222
+
223
+ /** A widget's pictures (7.8): JPEG, PNG, WebP or GIF, 10 MB each at most. */
224
+ interface WidgetFiles {
225
+ /** Every one, oldest first, from this device at once. */
226
+ list(): Promise<WidgetFile[]>;
227
+ /** Its bytes, from this device or the server; rejects `NotFoundError`, or `NetworkError` offline without them. */
228
+ get(id: string): Promise<Blob>;
229
+ /** Kept here at once, sent when the host can; its id. Rejects `TypeError` (not a picture, a meta not JSON or over 1,024 bytes), `RangeError` (over 10 MB). */
230
+ add(file: Blob, meta?: unknown): Promise<string>;
231
+ /** Deleted here and on the person's other devices. */
232
+ delete(id: string): Promise<void>;
233
+ }
234
+
235
+ interface WidgetFile {
236
+ readonly id: string;
237
+ /** `image/jpeg`, `image/png`, `image/webp` or `image/gif`, told by its bytes. */
238
+ readonly type: string;
239
+ readonly size: number;
240
+ /** When it was added, in milliseconds. */
241
+ readonly at: number;
242
+ /** What the widget gave `add`. */
243
+ readonly meta: unknown;
208
244
  }
209
245
 
210
246
  interface WidgetStorageArea {
@@ -220,6 +256,11 @@ declare global {
220
256
  readonly inline: boolean;
221
257
  /** The page's style, or "" standalone. */
222
258
  readonly style: string;
259
+ /**
260
+ * Startside's extension: who plays, in the beta's conversations (this person's name, and who sent this copy,
261
+ * null on their own page); null elsewhere.
262
+ */
263
+ readonly people: Readonly<{ me: string; from: string | null; to: string | null }> | null;
223
264
  }
224
265
 
225
266
  /** A setting as the file declares it: frozen, as `preferences` and `getPreference` give it. */
@@ -322,6 +363,20 @@ declare global {
322
363
  /** Played without a Referer, through the host's relay. */
323
364
  relay?: boolean;
324
365
  live?: boolean;
366
+ /**
367
+ * For a file (`live: false`): the files the host plays after it, each as the one before ends, with no further click,
368
+ * until a pause (7.12). `audioState.url` says which plays. 100 at most.
369
+ */
370
+ next?: NextAudio[];
371
+ }
372
+
373
+ interface NextAudio {
374
+ /** https */
375
+ url: string;
376
+ relay?: boolean;
377
+ /** What the host says plays as it starts (`audioInfo`'s title and artist). */
378
+ title?: string;
379
+ artist?: string;
325
380
  }
326
381
 
327
382
  interface AudioState {
@@ -332,6 +387,21 @@ declare global {
332
387
  /** Seconds, for a file. */
333
388
  time?: number | null;
334
389
  duration?: number | null;
390
+ /**
391
+ * A file (`live: false`) another widget of the page plays, playing or loading, else null. While this widget plays
392
+ * nothing itself, `pauseAudio` and `seekAudio` act on it; `playAudio` of a file another widget holds goes on there.
393
+ */
394
+ elsewhere?: ElsewhereAudio | null;
395
+ }
396
+
397
+ interface ElsewhereAudio {
398
+ url: string;
399
+ playing: boolean;
400
+ loading: boolean;
401
+ time: number | null;
402
+ duration: number | null;
403
+ /** Its `audioInfo`'s source. */
404
+ source: string | null;
335
405
  }
336
406
 
337
407
  interface AudioControls {
@@ -369,7 +439,12 @@ declare global {
369
439
  }
370
440
 
371
441
  interface PhotoSpec {
372
- src: string;
442
+ /** An `https` picture or one of the host's; `file` instead for one of the widget's own files. */
443
+ src?: string;
444
+ /** One of its own pictures (`storage.files`), by id: the host reads it, `src` aside. */
445
+ file?: string;
446
+ /** Its own pictures to step through from `file` (their ids, in order, 5,000 at most): ‹ › and the arrow keys. */
447
+ files?: string[];
373
448
  alt?: string;
374
449
  title?: string;
375
450
  preview?: string;
@@ -379,6 +454,10 @@ declare global {
379
454
  height?: number;
380
455
  /** What the picture's licence asks to go with it. A plain string is its credit text. */
381
456
  credit?: PhotoCredit | string;
457
+ /** The window offers Delete, which asks the person first; the widget hears it as `photodelete`. */
458
+ deletable?: boolean;
459
+ /** Given back in `photodelete`'s detail: which picture (100 characters at most). With `file`, the file's id instead. */
460
+ id?: string;
382
461
  }
383
462
 
384
463
  /**