@startside/swa 1.0.2 → 1.0.4

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/spec.md CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  <dl>
6
6
  <dt>This version:</dt><dd><a href="https://startside.app/swa/1.0/">https://startside.app/swa/1.0/</a> (Markdown: <a href="https://startside.app/swa/1.0/spec.md">spec.md</a>; for agents: <a href="https://startside.app/swa/1.0/agents.md">agents.md</a>)</dd>
7
- <dt>Previous version:</dt><dd><a href="https://startside.app/uwa/1.2/spec.md">Universal Widget API (UWA) 1.2.4</a>, Netvibes, 2008–2010</dd>
8
- <dt>Specifications built on this one:</dt><dd><a href="https://startside.app/rwa/1.0/spec.md">React Widget API (RWA) 1.0</a></dd>
9
7
  <dt>Editor:</dt><dd>François Hodierne (Startside)</dd>
10
8
  <dt>Licence:</dt><dd>© 2026 François Hodierne. This document is shared under the <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International</a> licence (CC BY 4.0).</dd>
11
9
  <dt>Implementation:</dt><dd>Startside, <a href="https://startside.app/">startside.app</a> (its status: <a href="#appendix-c-implementation-status-and-features-at-risk">Appendix C</a>)</dd>
@@ -22,7 +20,8 @@ settings; its scripts draw it through one object, `widget`, which gives it the h
22
20
  settings and memory, a shared article reader, read and unread items, kept content, the page's audio and video
23
21
  players, sharing, and its accounts. Hosts run widgets in sandboxed frames, under the same rules for every author.
24
22
 
25
- SWA is the successor of the Universal Widget API (UWA) 1.2, whose JavaScript interface it keeps.
23
+ SWA is a successor of the [Universal Widget API (UWA) 1.2](https://startside.app/uwa/1.2/spec.md) (Netvibes, 2008–2010), whose JavaScript interface
24
+ it keeps.
26
25
 
27
26
  **New to SWA?** [SWA in 60 lines](https://startside.app/swa/1.0/quickstart.md) has a complete widget, the rules as a table and a checklist;
28
27
  this document is the reference behind it.
@@ -166,7 +165,7 @@ instantiated many times.</dd>
166
165
  <dd>The runtime script running a widget file opened on its own, at its URL or from disk.</dd>
167
166
 
168
167
  <dt><a id="dfn-trusted"></a><b>trusted</b></dt>
169
- <dd>A widget file served from the host's own widget directory (in Startside, <code>/uwa/</code>). Any other file is
168
+ <dd>A widget file served from the host's own widget directory (in Startside, <code>/xwa/</code>). Any other file is
170
169
  <b>untrusted</b>: one from another site, or dropped from the person's computer.</dd>
171
170
 
172
171
  <dt><a id="dfn-setting"></a><b>setting</b></dt>
@@ -319,6 +318,7 @@ optional.
319
318
  <tr><td><code>feed</code></td><td>a URL template</td><td>The feed it reads (section 6.4)</td></tr>
320
319
  <tr><td><code>accountService</code></td><td>a service name</td><td>The service of its account (section 7.13)</td></tr>
321
320
  <tr><td><code>accountScope</code></td><td>permissions, space-separated</td><td>Only accounts allowing one of them are offered</td></tr>
321
+ <tr><td><code>acceptFiles</code></td><td>file extensions, space-separated (<code>.gpx</code>)</td><td>It takes a file dragged from the computer onto it: a host lets the drag reach the widget rather than its own page (10.1). The extensions are what it takes, a hint as <code>accept</code> on a file input is: what is dragged has no name until it is dropped, so the widget checks the file it gets</td></tr>
322
322
  <tr><td><code>debugMode</code></td><td><code>true</code></td><td><code>widget.log</code> writes to the console</td></tr>
323
323
  <tr><td><code>export</code></td><td><code>false</code></td><td>Not sent as a file: a host offers no way to send this widget with its settings to someone else, and refuses a file claiming it. For a widget showing its signed-in account's own data, which means nothing without it</td></tr>
324
324
  </tbody>
@@ -353,7 +353,7 @@ elements carry plain class names (`title`, `options`, `hint`), which an unscoped
353
353
  | class `uwa-full-window` on the root | the widget is full screen, alone over the window, whatever its `maximize` says |
354
354
  | custom properties `--module-color`, `--module-paper` | the person gave the widget a palette color: its shade, and a pastel of it |
355
355
  | custom properties `--text`, `--muted`, `--link`, `--link-visited`, `--widget-bg`, `--border`, `--hover` | always: the page style's colors |
356
- | custom properties `--accent`, `--accent-ink`, `--accent-glow` | always: the page's accent, its ink (text on it) and its light shade; changed in place, the widget not restarted, when the person picks another accent (a widget reads them in its CSS, not once in script) |
356
+ | custom properties `--accent`, `--accent-ink`, `--accent-glow` | always: the page's accent; its ink, the accent darkened until it reads at 4.5:1 or more on white (for text and lines in the accent's hue on a light ground; white text reads as well on it as a fill); its glow, the accent lightened until it reads at 4.5:1 or more on a dark ground (the same, in the dark). Not text to set on `--accent` itself, which may be pale (a yellow); changed in place, the widget not restarted, when the person picks another accent (a widget reads them in its CSS, not once in script) |
357
357
  | custom property `--font-body` | always: the page style's font family |
358
358
 
359
359
  The root is the widget's `html` element, framed and on its own page; a selector such as
@@ -449,7 +449,9 @@ attribute is the empty string.
449
449
 
450
450
  The setting's **label** is the text content of the `label` element containing the control, without the text of the
451
451
  controls inside it; else that of the `label` whose `for` is the control's `id`; else its `aria-label`; else its name.
452
- Labels **SHOULD** be short and in English.
452
+ Labels **SHOULD** be short and in English, and **SHOULD NOT** end with a colon: the host shows a label as it
453
+ likes, a colon after it or none (*Week starts on*, not *Week starts on:*). A host **MUST** drop a colon that ends a
454
+ label.
453
455
 
454
456
  ### 5.3 Attributes
455
457
 
@@ -458,7 +460,9 @@ Labels **SHOULD** be short and in English.
458
460
  | `data-hint` | any control | A text completing the label, which the host shows on request beside it |
459
461
  | `data-when` | any control | A **condition**, `name=value`, `name=a\|b` or `name!=value`: the setting is shown only while it holds. A hidden setting keeps its value. An unreadable condition is ignored |
460
462
  | `data-commit="ok"` | a `text` control | Its value applies only when confirmed (section 6.5) |
463
+ | `data-key-for` | a `password` control | An `https` origin, no path (`https://api.example`): the setting is the person's **key for that site**. The host keeps the key and adds it to the widget's `widget.fetch` requests to that origin (section 8.2); the widget never receives it, and reads the setting as an empty string. The file gives the control no `value` |
461
464
  | `data-share` | a `hidden` control | A shared link may carry its value |
465
+ | `data-send` | a `hidden` control | Its value goes with the widget when it's sent to someone (a host's conversations); every other hidden value stays home. A game's result, never its progress |
462
466
  | `data-load` | a `hidden` control with `data-share` | A label, at most 40 characters: a person who already has the widget is offered a button with it, loading the shared value into their copy |
463
467
  | `maxlength` | a `hidden` control with `data-share` | The longest value a shared link may carry for it, line breaks and tabs included (a whole text); a host **MAY** cap it (Startside: 16,000). Without it, a short value with no line breaks |
464
468
  | `data-file` | a `hidden` control | File extensions, space-separated (`.cook`): a file of one of them, opened in the host (dropped on the page, chosen), makes this widget with the file's text as this setting's value; a host that exports a widget as files **SHOULD** write this setting's value as a file of that extension rather than among the settings. *At risk* (Appendix C) |
@@ -545,7 +549,8 @@ When the person changes a setting, the host applies it:
545
549
  If `livePreferences` is `false`, every change waits for the settings to close; if `instant`, changes apply at once,
546
550
  ungrouped. Applying settings stores the values, then **refreshes** the widget (6.6).
547
551
 
548
- A password setting's value **MUST NOT** be given to a framed widget, nor carried by a link.
552
+ A password setting's value **MUST NOT** be given to a framed widget, nor carried by a link. A key for a site
553
+ (`data-key-for`, 5.3) **MUST NOT** be given to the widget in any environment; the host uses it only as section 8.2 says.
549
554
 
550
555
  ### 6.6 Starting and refreshing
551
556
 
@@ -706,6 +711,7 @@ interface Widget : EventTarget {
706
711
  // 8 Data access
707
712
  Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
708
713
  Promise<ContentFeed> fetchFeed(USVString url, optional FetchFeedOptions options = {});
714
+ Promise<USVString> fetchImage(USVString url, optional FetchFeedOptions options = {});
709
715
 
710
716
  // 7.10 Read state and counts
711
717
  undefined readItems(Element box, DOMString itemSelector, optional ReadItemsOptions options = {});
@@ -733,6 +739,7 @@ interface Widget : EventTarget {
733
739
  // 7.13 The page
734
740
  USVString? shareUrl();
735
741
  any share(optional ShareData data = {});
742
+ undefined sendTo();
736
743
  any addWidget(AddWidgetSpec spec);
737
744
  boolean dragWidget(Element element, (AddWidgetSpec or DragWidgetCallback) spec);
738
745
  readonly attribute boolean canFullSize;
@@ -790,13 +797,15 @@ dictionary WidgetSettingOption {
790
797
  };
791
798
  ```
792
799
 
793
- - `id`: the widget's identifier, unique on the page. `title`: the title it's shown under, the person's name for it if
794
- they renamed it, else its own (7.3). `uwaUrl`: its file's URL. `lang`,
800
+ - `id`: the widget's identifier, unique on the page. `title`: the title it's shown under, its own (7.3). `uwaUrl`: its file's URL. `lang`,
795
801
  `locale`: the person's language (`en_US`) and region (`us`), in UWA's form, kept (11): a language tag for `Intl` is
796
802
  `widget.lang.replace('_', '-')`. `metas`: its metadata. `preferences`: its setting
797
803
  declarations.
798
804
  - `environment.style` names the page's style (in Startside: `classic`, `early`, `coriander`, `ginger`, `mac`, `aw`,
799
805
  `neo`, `modern`). A framed widget is rebuilt when it changes.
806
+ - `environment.people` (a host's extension, Startside's conversations): `{ me, from, to }`, the person's name, for a copy someone sent them the sender's name, for a copy they
807
+ sent the recipient's (`null` on their own page); `null` where the host has no conversations or
808
+ the person isn't in them. A widget may key what it sends by name (`data-send`) and tell a received copy's from its own.
800
809
  - `log(…)` writes its arguments to the console when `debugMode` is `true`.
801
810
 
802
811
  ### 7.3 Content and title
@@ -817,12 +826,11 @@ dictionary WidgetSettingOption {
817
826
  - `createElement(tagName, attributes)` returns a new `HTMLElement` (section 9). In *attributes*,
818
827
  `class` sets its class, `styles` its style, `events` its listeners, and any other key an attribute.
819
828
  - `setTitle(title)` sets the title shown in its title bar. *title* may contain `a` elements with `http` or `https`
820
- addresses, shown as links; any other markup is reduced to its text. It is kept as the widget's title, shown
821
- unless the person renamed the widget. `widget.title` is the title shown: the person's name for the widget, as text,
822
- else the title as set, its links' markup included; `getTitle()` returns its text. A title is like a setting: when
823
- the person renames the widget, or empties the name to give it its own back, the host fires `settingschange` with
824
- the name `title` (7.5), then refreshes it unless the event is canceled; a widget showing its name (lettered on a
825
- toy, in a heading) redraws it there.
829
+ addresses, shown as links; any other markup is reduced to its text. It is kept as the widget's title and shown: a
830
+ widget's title is its own, and the host offers no way of its own to rename it. Until the widget sets one, its title
831
+ is its file's `title` element. `widget.title` is the title shown, its links' markup included; `getTitle()` returns
832
+ its text. A widget that lets the person name it declares a setting named `title` (7.5) and uses it as it sees fit:
833
+ in its title bar (`setTitle` with it), lettered on a toy, in a heading.
826
834
  - `setStyle(css)` adds a style sheet for the widget.
827
835
 
828
836
  #### 7.3.1 Drawing in place
@@ -936,17 +944,21 @@ interface WidgetSettings {
936
944
  choice made in the widget itself): a boolean for a checkbox, a finite number for a `range` or `number` field, else
937
945
  anything, converted to a string (`null` and `undefined` to `""`). A value of the wrong type, or a name the form doesn't declare, throws a
938
946
  `TypeError`. `settings.reset(name)` restores the declared default.
939
- - **`title`**, unless the form declares a setting of that name, is the widget's title, like a setting (7.3):
940
- `settings.get('title')` returns the title shown, as text; `settings.set('title', name)` makes *name* the person's
941
- name for the widget, as the host's own rename does, for a widget that lets the person rename it in itself (a field
942
- over the name it shows), right after they acted in it (6.7); `settings.reset('title')`, an empty name or the
943
- widget's own give it its own title back. The host saves it; no event fires and no refresh follows (the widget made
944
- the change). A host **MAY** limit a setting's length (the
947
+ - **`title`**: declaring a setting of that name is how a widget offers the person to name it (7.3); it is then a
948
+ setting like any other, which the widget uses as it sees fit. Undeclared, `settings.get('title')` returns the title
949
+ shown, as text, read-only: `settings.set('title', …)` and `settings.reset('title')` throw a `TypeError`, as for any
950
+ undeclared name. A host **MAY** limit a setting's length (the
945
951
  Appendix gives Startside's); a value over it isn't kept: `settings.get` returns it until the widget reloads, and the
946
952
  host **SHOULD** say so in the widget's console. A widget keeping something that grows (a drawing, a long game) keeps it
947
953
  under the limit itself.
954
+ - **`countInTab`**: a checkbox of that name lets the person choose whether the widget's unread count (7.10) adds up in
955
+ the host's totals (Startside: its tab's count, and an installed app's badge, the sum of the tabs'). Unticked, the host
956
+ **MUST** still show the count after the widget's title, and **MUST NOT** add it to those totals, nor make the widget's
957
+ items read when a total is activated. Undeclared, the count adds up. The checkbox **MUST** be declared `checked`: the
958
+ count adds up until the person unticks it (a host reads only a value the person saved). It suits a count the person
959
+ can't bring to zero in the widget (a mailbox's unread mail, read elsewhere).
948
960
  - When the person applies settings (6.5), the host fires `settingschange` (7.6), its `detail.names` the settings whose
949
- values changed (`title` when the person renamed the widget, 7.3); canceling it skips the refresh that follows, for a
961
+ values changed; canceling it skips the refresh that follows, for a
950
962
  widget that applies them in place. Nothing
951
963
  changed (an OK with the same values): no event, the refresh as before.
952
964
  - `refresh()` refreshes the widget as applying settings does (6.6): for a setting the widget changed with its own
@@ -1004,8 +1016,11 @@ and ends its part of the load as settling does.
1004
1016
  | `videostate` | `videoState` changed | the new `VideoState`, or null | no | `onVideoState` |
1005
1017
  | `fullsize` | it was maximized or restored, its box at its new size | `fullSize`'s new value | no | `onFullSize` |
1006
1018
  | `fullscreen` | it went full screen or left it, after `fullsize` when both change | `fullScreen`'s new value | no | `onFullScreen` |
1007
- | `settingschange` | the person applied settings that changed, or renamed the widget (7.3, 7.5) | `{ names }`: the settings changed, `title` for a rename | yes: canceling skips the refresh | none |
1019
+ | `settingschange` | the person applied settings that changed (7.5) | `{ names }`: the settings changed | yes: canceling skips the refresh | none |
1008
1020
  | `action` | the person chose one of the widget's own actions in its options menu (7.13) | `{ id }`: the action's | no | none |
1021
+ | `photodelete` | the person deleted a picture the widget opened with `deletable` (7.12) | `{ id }`: the `id` it gave, or `""` | no | none |
1022
+ | `storagechange` | another copy of the same widget changed a value of `storage.local` (this copy's already updated) | `{ key }` | no | none |
1023
+ | `fileschange` | the widget's files (`storage.files`, 7.8) changed: on another device, in another copy of the page, or by its own call | null | no | none |
1009
1024
 
1010
1025
  Event types are lowercase, as the platform's are. A host **MAY** fire other events; their types **MUST** be lowercase and
1011
1026
  **MUST NOT** begin with `on`. Such an event isn't cancelable, and has a null `detail` unless the host says otherwise.
@@ -1082,6 +1097,14 @@ dictionary HeightGripOptions {
1082
1097
  them (a title with nothing under it: it ends on the item before), and calls `onDone(pixels)`. Maximized,
1083
1098
  the list takes the window's height instead.
1084
1099
 
1100
+ Either grip also works from the keyboard, as WAI-ARIA's window splitter: it takes the focus (shown), is named, and says
1101
+ its value (the items shown, "6 of 20 items"). ↓ shows one item more (the grip goes down as the list grows), ↑ one
1102
+ fewer, Home the fewest (`min`), End every item the box has; for `heightGrip`, ↓ and ↑ go to the next whole item and End
1103
+ shows the whole list. A key on `countGrip` is a drag of one row: `onStart()`, then `onDone(count)`. When ↓ asks for an
1104
+ item past those the box has, the host gives the items `onStart()` fetched a moment to arrive (2 seconds at most, less
1105
+ when it knows no request is pending), then keeps one more if one came. Height changes ease, at once under
1106
+ `prefers-reduced-motion`.
1107
+
1085
1108
  Framed, the host follows the pointer once it leaves the frame and relays its moves. Either grip stays under the
1086
1109
  pointer: maximized in a centered window, which grows both ways, the height follows twice the pointer's move until the
1087
1110
  window is full, then the move itself.
@@ -1089,13 +1112,15 @@ window is full, then the move itself.
1089
1112
  ### 7.8 Memory and stored data
1090
1113
 
1091
1114
  Where a widget keeps what, in short (the table below): a choice of the person, or a game in progress, is a setting;
1092
- `memory` is a cache, which a host may drop; `local` lasts across reloads.
1115
+ `memory` is a cache, which a host may drop; `local` lasts across reloads; `files` keeps pictures for good, on the
1116
+ person's other devices too.
1093
1117
 
1094
1118
  ```webidl
1095
1119
  [Exposed=Window]
1096
1120
  interface WidgetStorage {
1097
1121
  readonly attribute WidgetStorageArea memory;
1098
1122
  readonly attribute WidgetStorageArea local;
1123
+ readonly attribute WidgetFiles files;
1099
1124
  };
1100
1125
 
1101
1126
  [Exposed=Window]
@@ -1104,6 +1129,22 @@ interface WidgetStorageArea {
1104
1129
  Promise<undefined> set(DOMString key, any value);
1105
1130
  Promise<undefined> delete(DOMString key);
1106
1131
  };
1132
+
1133
+ [Exposed=Window]
1134
+ interface WidgetFiles {
1135
+ Promise<sequence<WidgetFile>> list();
1136
+ Promise<Blob> get(DOMString id);
1137
+ Promise<DOMString> add(Blob file, optional any meta);
1138
+ Promise<undefined> delete(DOMString id);
1139
+ };
1140
+
1141
+ dictionary WidgetFile {
1142
+ DOMString id;
1143
+ DOMString type;
1144
+ unsigned long size;
1145
+ unsigned long long at;
1146
+ any meta;
1147
+ };
1107
1148
  ```
1108
1149
 
1109
1150
  `widget.storage` holds what a widget keeps, in two **storage areas**, each a map of keys to JSON values:
@@ -1123,11 +1164,32 @@ starts, and draw what it kept without showing a load.
1123
1164
 
1124
1165
  UWA's `remember`, `recall`, `setStored` and `getStored` are UWA files' (11.1): the same data, `memory` and `local`.
1125
1166
 
1167
+ `widget.storage.files` holds the widget's own **files**: pictures it keeps for good (a camera's photos), the same on the
1168
+ person's other devices where the host syncs (Startside: with Sync on). Each copy of a widget has its own; a host
1169
+ **MUST NOT** let a widget reach another's.
1170
+
1171
+ - **`list()`** resolves with the widget's files, oldest first, each a `WidgetFile`: its `id`, its `type`, its `size` in
1172
+ bytes, `at` (when it was added, in milliseconds since the epoch) and the `meta` the widget gave `add`. It resolves
1173
+ from what the host has at once, offline included; files added on another device are listed once the host has
1174
+ learned of them, and `fileschange` says so.
1175
+ - **`get(id)`** resolves with the file's bytes, a `Blob` of its type: a widget makes its own address for it
1176
+ (`URL.createObjectURL`), since a framed widget can't load one the host made. It rejects with a `NotFoundError`
1177
+ `DOMException` for an id that isn't the widget's, and a `NetworkError` when the bytes are elsewhere and can't be
1178
+ fetched.
1179
+ - **`add(file, meta)`** keeps `file` and resolves with its new id. A host **MUST** take only a JPEG, PNG, WebP or GIF
1180
+ picture, told by its first bytes, never by the `Blob`'s type (in Startside, 10 MB at most); anything else rejects
1181
+ with a `TypeError`, too big with a `RangeError`. `meta`, optional, **MUST** be serializable as JSON, 1,024 bytes at
1182
+ most as UTF-8 (a `TypeError` otherwise). A host **MAY** refuse more files past its limits (Startside: 5,000 files
1183
+ and 1 GB a widget), with a `QuotaExceededError`.
1184
+ - **`delete(id)`** removes the file, on the person's other devices too; an id already gone resolves.
1185
+ - **`fileschange`** (7.6.1) fires when the list changed, whatever changed it: a widget lists its files again.
1186
+
1126
1187
  | To keep | Use |
1127
1188
  |---|---|
1128
1189
  | a choice of the person, or a game in progress | a setting (`settings.set`), hidden if not edited by hand |
1129
1190
  | data across rebuilds, a cache | `storage.memory` |
1130
1191
  | data across reloads, shared by copies of the file | `storage.local` |
1192
+ | pictures to keep, on the person's other devices too | `storage.files` |
1131
1193
  | a feed | nothing: `fetchFeed` keeps it (7.9) |
1132
1194
 
1133
1195
  Saved data outlives the code that wrote it: widget code **MUST** read it defensively.
@@ -1157,7 +1219,8 @@ dictionary ReadItemsOptions {
1157
1219
  the widget's unread count, and makes them all read when the count is activated, as `readall`'s default action, unless
1158
1220
  a listener cancels the event.
1159
1221
  - `isRead(key)` and `setRead(keys, read)` do it by hand. `setUnreadCount(count)` shows *count*, when positive, after the
1160
- title and in the tab's count; activating it fires `readall` (7.6). `setSearchResultCount(count)` is accepted.
1222
+ title and in the tab's count (unless the person turned the widget's `countInTab` setting off, 7.5); activating it
1223
+ fires `readall` (7.6). `setSearchResultCount(count)` is accepted.
1161
1224
 
1162
1225
  A host keeps the last 500 read keys of a widget. A widget file replacing another **MUST** keep its read keys.
1163
1226
  Headline links to another site **SHOULD** have the class `ext-link`.
@@ -1201,6 +1264,14 @@ dictionary PlayAudioOptions {
1201
1264
  required USVString url; // https
1202
1265
  boolean relay = false; // played without a Referer, through the host's relay
1203
1266
  boolean live = true;
1267
+ sequence<NextAudio> next; // for a file: the files to play after it
1268
+ };
1269
+
1270
+ dictionary NextAudio {
1271
+ required USVString url; // https
1272
+ boolean relay = false;
1273
+ DOMString title; // what the host says plays, as audioInfo's
1274
+ DOMString artist;
1204
1275
  };
1205
1276
 
1206
1277
  dictionary AudioState {
@@ -1210,6 +1281,16 @@ dictionary AudioState {
1210
1281
  DOMString? error; // null, "blocked" or "failed"
1211
1282
  unsigned long? time; // seconds, for a file
1212
1283
  unsigned long? duration;
1284
+ ElsewhereAudio? elsewhere; // a file another widget plays
1285
+ };
1286
+
1287
+ dictionary ElsewhereAudio {
1288
+ USVString url;
1289
+ boolean playing;
1290
+ boolean loading;
1291
+ unsigned long? time;
1292
+ unsigned long? duration;
1293
+ DOMString? source; // its audioInfo's source
1213
1294
  };
1214
1295
 
1215
1296
  dictionary AudioControls {
@@ -1242,7 +1323,9 @@ dictionary VideoState {
1242
1323
  };
1243
1324
 
1244
1325
  dictionary PhotoSpec {
1245
- required USVString src;
1326
+ USVString src;
1327
+ DOMString file;
1328
+ sequence<DOMString> files;
1246
1329
  DOMString alt;
1247
1330
  DOMString title;
1248
1331
  USVString preview;
@@ -1250,6 +1333,8 @@ dictionary PhotoSpec {
1250
1333
  unsigned long width;
1251
1334
  unsigned long height;
1252
1335
  (PhotoCredit or DOMString) credit;
1336
+ boolean deletable = false;
1337
+ DOMString id;
1253
1338
  };
1254
1339
 
1255
1340
  dictionary PhotoCredit {
@@ -1267,6 +1352,18 @@ dictionary PhotoCredit {
1267
1352
  - `playAudio(options)` plays an `https` stream in the host's page, not in the widget, so that nothing happening to the
1268
1353
  widget interrupts it; a `live` stream is never played behind its live point. `pauseAudio()`; `seekAudio(seconds)` for a
1269
1354
  file. `audioState` is its state, and `audiostate` (`onAudioState`) is fired as it changes. Activation-gated.
1355
+ - A file (`live` false) may come with a programme, `next`: the files the host plays after it, in order, each as the one
1356
+ before plays to its end, with no further activation (the one that started the first covers exactly what the widget
1357
+ declared with it). `audioState.url` is the file playing; where an entry has a `title`, the host says it plays (as
1358
+ `audioInfo`'s title and artist, the rest of the widget's `audioInfo` kept). A pause, from the widget, the host or the
1359
+ system, ends the programme: playing again plays that file, not the rest, unless the widget's `playAudio()` declares
1360
+ them again; another `playAudio()` replaces it. The host plays the first 100 entries at most, and leaves out an entry
1361
+ whose address it wouldn't play as the first.
1362
+ - `audioState.elsewhere` is a file (`live` false) another widget of the page plays, playing or loading, else null: two
1363
+ widgets offering the same recording both show it playing. While the widget plays nothing itself, `pauseAudio()` and
1364
+ `seekAudio()` act on that file; `playAudio()` of a file another widget holds, playing or paused, goes on with it there,
1365
+ from its place, rather than starting it again. `playing` and `url` stay the widget's own sound: a widget that reads
1366
+ them alone is never told another's sound is its own. A host without other widgets keeps it null.
1270
1367
  - A widget playing with a player of its own calls `audioStarted(stop, controls)` as it starts: the host stops the sound
1271
1368
  playing before, and calls *stop* when another starts or the person pauses it. `audioStopped()` says it stopped by itself;
1272
1369
  `audioInfo(info)` says what plays.
@@ -1283,7 +1380,17 @@ to go with it: a `PhotoCredit`, whose members are schema.org's `ImageObject` pro
1283
1380
  `name`, its `creator` as a name, the `creditText` naming who keeps or gives the picture, the `copyrightNotice` naming who
1284
1381
  the licence says to name, the `license`'s address, the picture's page `url`; all optional, the addresses `https`), or a
1285
1382
  plain string, read as its `creditText`. The host shares it with the picture as text and keeps it with what it makes of
1286
- the picture; it **MAY** shorten its text, and drops what it can't read. Standalone, a new tab. Pictures a widget shows **MUST** be ones it may show: public domain, or under a licence or permission that allows it,
1383
+ the picture; it **MAY** shorten its text, and drops what it can't read. With `deletable` true, the window also offers
1384
+ Delete: the host **MUST** ask the person first, and once they confirm, closes the window and fires `photodelete` at the
1385
+ widget, its `detail` the `id` the widget gave (at most 100 characters; `""` without one); the widget removes the picture
1386
+ itself. A picture the widget keeps (one it took or made) is what this is for. Standalone, a new tab.
1387
+
1388
+ One of the widget's own files (`storage.files`, 7.8) opens by its id, `file`, in place of `src`: the host reads it, and
1389
+ an id that isn't the widget's shows nothing. With `files` too (ids of its files, in the order to show them, `file` among
1390
+ them; at most 5,000), the window steps through them: a previous and a next control beside the picture and the left and
1391
+ right arrow keys (not while zoomed in), each named for assistive technology, and which of how many is shown said
1392
+ politely as it changes. A file gone meanwhile is skipped. Delete then fires `photodelete` with the shown file's id
1393
+ (the widget removes it) and shows the next one, or the one before at the end, closing when none is left. Pictures a widget shows **MUST** be ones it may show: public domain, or under a licence or permission that allows it,
1287
1394
  their required credits kept.
1288
1395
 
1289
1396
  ### 7.13 The page
@@ -1321,6 +1428,8 @@ dictionary WidgetActionState { // a member left out: as it was; n
1321
1428
 
1322
1429
  - `shareUrl()` returns the widget's address on its host (`/add/<key>`), or null for an untrusted file.
1323
1430
  - `share(data)` shares *data* through the system's share sheet where there is one, else the clipboard. Activation-gated.
1431
+ - `sendTo()` (a host's extension) opens the host's own way to send this widget to someone (Startside: Send to…), its
1432
+ `data-send` values going with it. Activation-gated; does nothing where `environment.people` is `null`.
1324
1433
  - `addWidget(spec)` adds a widget of the host's directory after this one, with *spec*'s title and values. Trusted files
1325
1434
  only; activation-gated. The member is **absent** where no widget can be added (a preview, standalone).
1326
1435
  - `dragWidget(element, spec)` makes *element* draggable onto the page, creating the widget *spec* names (or returns, if
@@ -1408,11 +1517,12 @@ dictionary WidgetActionState { // a member left out: as it was; n
1408
1517
  its extension, a fallback when nothing is left. Its extension is read after cleaning and is the last one; an
1409
1518
  extension before it loses its dot (`invoice.exe.cook` becomes `invoice-exe.cook`).
1410
1519
  - **The extension** must be one the action declares **and** one the host allows. A host keeps an allow-list of
1411
- data formats, never a block-list; Startside's is `.cook`, `.txt`, `.md`, `.csv`, `.json`, `.ics` and `.opml`.
1520
+ data formats, never a block-list; Startside's is `.cook`, `.txt`, `.md`, `.csv`, `.json`, `.ics`, `.opml`
1521
+ and `.gpx`.
1412
1522
  An action declaring another extension gets nothing for it.
1413
1523
  - **The type** must be one the extension takes (Startside: `text/plain` for each of them; also `text/markdown`
1414
1524
  for `.md`, `text/csv` for `.csv`, `application/json` for `.json`, `text/calendar` for `.ics`, `text/x-opml`,
1415
- `application/xml` and `text/xml` for `.opml`); `""` asks for the usual one. A `Blob`'s own type is ignored:
1525
+ `application/xml` and `text/xml` for `.opml`, `application/gpx+xml`, `application/xml` and `text/xml` for `.gpx`); `""` asks for the usual one. A `Blob`'s own type is ignored:
1416
1526
  the host makes the file. A host **MUST NOT** render, preview or open the content, nor give the widget the
1417
1527
  file's address.
1418
1528
  - **Delivery.** While the person's choice still counts as activation in the host's page, the download starts.
@@ -1429,6 +1539,15 @@ dictionary WidgetActionState { // a member left out: as it was; n
1429
1539
  "Saved" notice and no path.
1430
1540
  - On a widget's own page (10.3) the call and its rules are the same; there they shape the API and do not
1431
1541
  protect, since the widget isn't sandboxed ([Issue 15](#issue-15)).
1542
+ - **An album of its pictures** (a host's extension; Startside's since November 24, 2026). An action declaring
1543
+ `data-album` is the host's to carry out: chosen, the host makes a photo widget of its own holding the widget's
1544
+ pictures (its files, 7.8), in the order they were kept, right after it, and fires no `action` event. The widget only
1545
+ offers it and says when it can (`setActionStates`: greyed while it has no picture). A host without photo widgets
1546
+ leaves such an action out of the menu; so does a widget's own page (10.3).
1547
+
1548
+ ```html
1549
+ <button type="button" name="album" data-album data-icon="add" disabled>Make an album</button>
1550
+ ```
1432
1551
  - There is no way to make a list of actions in script: none of the widgets written so far needs one only known as
1433
1552
  it runs ([Issue 32](#issue-32)).
1434
1553
  - **Accounts.** A trusted widget declaring `accountService` and a hidden setting named `account` has its account in its
@@ -1473,7 +1592,13 @@ local and private networks, including through redirects, and its own addresses o
1473
1592
  **MAY** answer from a cache of 5 minutes (8.4). In this version:
1474
1593
 
1475
1594
  - only `GET` requests are made: another `method` rejects with a `TypeError`;
1476
- - an `Accept` header naming JSON asks with JSON headers (a GraphQL query by `GET`); no other request header is sent;
1595
+ - an `Accept` header naming JSON asks with JSON headers (a GraphQL query by `GET`); no other request header of the
1596
+ widget's is sent;
1597
+ - to the origin of a setting declared `data-key-for` (5.3), when the person has given a key for it, the host adds
1598
+ `Authorization: Bearer <key>`: only to that exact origin (scheme, host and port), never through a redirect to another,
1599
+ and it **MUST NOT** answer one key's request from what it kept for another key or for none. Without a key the request
1600
+ goes as any other, and the site's refusal (401, 403) reaches the widget as that status. A host that can't keep keys
1601
+ sends none;
1477
1602
  - the `Response` carries the body, as text, with the status 200 for a success (the relay keeps no other); an HTTP
1478
1603
  error gives a `Response` with its status and no
1479
1604
  body, `ok` false; a network failure, or a refused address, rejects with a `TypeError`, as the platform's does;
@@ -1521,6 +1646,23 @@ To **normalize** a content feed, keep only those members, give every item an `id
1521
1646
  an item with neither), and write dates in [[RFC3339](#ref-rfc3339)] format. The host normalizes the feeds `fetchFeed`
1522
1647
  gives; UWA's `UWA.Content` helpers are UWA files' (11.1).
1523
1648
 
1649
+ ### 8.6 `widget.fetchImage`
1650
+
1651
+ `fetchImage(url, options)` resolves with an address the widget shows in an `img`: the picture at *url*, fetched by the
1652
+ host as itself. Framed, the widget's own requests carry no `Referer` (its origin is opaque), and some sites refuse a
1653
+ picture asked without one (OpenStreetMap's tiles, whose usage policy asks for it); fetched by the host, the request
1654
+ carries the host's. The host:
1655
+
1656
+ - fetches only an `https` address that isn't its own nor one on the person's computer or network (an IP address,
1657
+ `localhost`, a `.local` name), without credentials, as CORS allows: a site that doesn't allow it rejects;
1658
+ - accepts only a raster picture (PNG, JPEG, GIF, WebP, AVIF, BMP, an icon; not SVG) of 2 MB at most;
1659
+ - answers the same address for the same picture while the widget lives, at once once it came, and **MAY** let go of
1660
+ the oldest past a few hundred.
1661
+
1662
+ A picture refused or failing rejects with a `TypeError`; `options.signal` aborts the wait (its `fresh` is ignored). On
1663
+ its own page (10.2) the widget isn't sandboxed: the host **MAY** resolve with *url* itself. A widget **SHOULD** credit
1664
+ the pictures as their licence asks (a map's data).
1665
+
1524
1666
  ## 9. Built-in objects
1525
1667
 
1526
1668
  SWA adds nothing to the objects of the platform. In an SWA widget's realm (its frame, or its own page: 10.2):
@@ -1578,6 +1720,11 @@ A dashboard **MUST** run every widget in a frame of its own, sandboxed with an o
1578
1720
  6. The browser's dialogs are off: `alert()` does nothing, `confirm()` answers false and `prompt()` null, at once. A
1579
1721
  widget **MUST NOT** use them, on its own page either (they work there, so a widget relying on them behaves
1580
1722
  differently framed): a question is asked in the widget's own box, its safe answer focused, Esc for it (14).
1723
+ 7. A file dragged from the computer over the page is the host's (a host may make a widget of it where it is dropped),
1724
+ and doesn't reach a frame on its way, except a frame whose file declares `acceptFiles` (4.5): there the drag and
1725
+ the drop are the widget's, which takes the file with its own `dragover` and `drop` listeners. A file its listeners
1726
+ leave uncancelled is refused in the frame (no drop effect): never opened by the browser in place of the page, never
1727
+ passed on to the host.
1581
1728
 
1582
1729
  A widget **MUST** work framed. One that can't **MUST** say so in its box, and how to change it, rather than fail.
1583
1730
 
@@ -1594,7 +1741,6 @@ UWA 1.2 files keep their `inline` metadata (section 11).
1594
1741
  Opened on its own, a widget file runs in the standalone host: its box, centred on the page, with a title bar.
1595
1742
 
1596
1743
  - **The options menu.** The title bar's options button (▾) opens the widget's options menu, as a dashboard's:
1597
- - its **Title**: a rename the page keeps; emptied, the widget's own;
1598
1744
  - its **Look**, when it has two: *Own* (its `chromeColor` and `background`) or *Page* (the page's bar and colors, the
1599
1745
  widget flattened under `html.uwa-neutral`, as on a dashboard);
1600
1746
  - its **Color**: the dashboard's palette, as `--module-color` and `--module-paper`;
@@ -1758,7 +1904,10 @@ as in UWA.
1758
1904
  addresses, through redirects too, and the host's own.
1759
1905
  - **Activation.** Operations that cover the page (the reader, the video player, full screen) or leave it (sharing,
1760
1906
  sign-in windows) are activation-gated, so a widget can't take over the page by itself.
1761
- - **Passwords.** A password setting never reaches a framed widget.
1907
+ - **Passwords.** A password setting never reaches a framed widget. A key for a site (`data-key-for`, 5.3) never reaches
1908
+ the widget from the host: the host adds it only to requests to that one origin (8.2). The widget chooses the paths it
1909
+ asks there, so a site whose answers carry the key (one echoing `Authorization`) lets the widget read it; a person
1910
+ gives a key only to a widget they trust, and a host **MAY** review the widgets it offers for that.
1762
1911
  - **Code.** Widget code **MUST NOT** evaluate fetched text as code.
1763
1912
 
1764
1913
  ## 13. Privacy Considerations
@@ -1766,6 +1915,8 @@ as in UWA.
1766
1915
  - A widget's settings, memory, stored data, kept content and read keys are kept by the host, as the host's privacy
1767
1916
  notice describes; a framed widget keeps nothing itself.
1768
1917
  - A shared link carries only settings marked `data-share`, never a password.
1918
+ - A key given for a `data-key-for` setting is kept by the host, as its privacy notice describes, and sent only to its
1919
+ site, with the widget's requests there.
1769
1920
  - Framed requests come from an opaque origin; whether a site's cookies go with them is the browser's third-party
1770
1921
  cookie policy. A site asked directly (`fetch` from the frame) sees the person's network address; one asked through the
1771
1922
  host (`widget.fetch`, `fetchFeed`, `UWA.Data`) sees the host's, and the host sees the address asked.
@@ -2178,6 +2329,7 @@ greyed until an item is done, the host asking before it runs.
2178
2329
  | Host limits (unspecified) | a framed widget's settings: a value of 20,000 characters, a name of 100, all of them 100,000 together (a value over isn't kept; the widget's console says so); read keys over 2000 characters dropped; feeds cut to 99 items and an item's HTML to 120,000 characters; the unread count shown up to 99; the reader's list 500 items, titles 300 and content 200,000 characters; an added widget's file name 40 characters |
2179
2330
  | The keyboard coming into a widget (6.8) | implemented in Startside (November 13, 2026): Enter on a widget's title bar moves the focus in, by `autofocus` and the steps of 6.8; an uncancelled Escape gives it back, an uncancelled arrow goes on to the next widget; a game controller read by the page is given as arrow keys, Enter and Escape. On a widget's own page there is no other widget: the browser's own `autofocus` applies |
2180
2331
  | A widget's own actions and `saveFile` (7.13) | implemented in Startside (November 12, 2026): actions declared in `<menu id="actions" hidden>`, listed in the options menu, `setActionStates`, the `action` event, `data-confirm` asked by the host, and one file per choice through `saveFile` (8 MiB at most, the extension among the action's `data-save` and the host's allow-list). On a widget's own page the runtime's menu lists them the same way. Used by the Recipe (Reset, Download as .cook), Dial Slate (Reset), Bluesky and Mastodon (Disconnect); Example 7 declares one |
2332
+ | `acceptFiles` (4.5, 10.1) | added November 21, 2026 for Startside Run (a run's GPX dropped on it): implemented in Startside only; while a file is dragged over the page, a frame keeps the pointer when its file declares `acceptFiles`, every other frame giving it to the page; a dragover no listener of the widget cancelled is cancelled by the runtime with the drop effect `none`. The extensions aren't checked by the host. `.gpx` joined `saveFile`'s allow-list the same day (7.13) |
2181
2333
  | A picture's credit in fields (7.12) | implemented in Startside (November 13, 2026): `PhotoCredit`, schema.org's `ImageObject` property names, or a plain string read as `creditText`; shared with the picture as text |
2182
2334
 
2183
2335
  The runtime is served at `https://startside.app/swa/1.0/runtime.js` (one minified script, its styles in it, with none of
@@ -2185,7 +2337,7 @@ UWA's API, globals or extensions of built-in objects: it runs SWA files only); a
2185
2337
  page skips it, and its catalogue lists the files that load it. The same runtime and types make the npm package
2186
2338
  `@startside/swa` (1.0.0 published November 8, 2026; 1.0.1 adds this specification, the quickstart and the guide for
2187
2339
  agents in Markdown, and the command `validate` and `inline`: Appendix F; 1.0.2, November 16, the API's additions since,
2188
- declared actions and saved files (7.13), a photo's zoom and credit (7.12), and its types corrected), served by jsDelivr and unpkg (4.3). jsDelivr keeps a
2340
+ declared actions and saved files (7.13), a photo's zoom and credit (7.12), and its types corrected; 1.0.3, November 25, what another host needs to run widgets in frames: Appendix F; 1.0.4, the host's side of a file as code, `host.js`), served by jsDelivr and unpkg (4.3). jsDelivr keeps a
2189
2341
  range's file (`@1`) up to 12 hours and lets a browser keep it up to 7 days, an exact version's for good; unpkg sends
2190
2342
  `@1` on to the exact version: a runtime fix reaches a CDN address within those times, startside.app's at once. Startside's own widgets are 57 SWA files (51 of
2191
2343
  them its UWA widgets, rewritten November 11, 2026), 29 RWA files and one UWA 1.2 file (xkcd), as of November 15, 2026; Appendix A's first example is
@@ -2196,7 +2348,7 @@ an SWA one.
2196
2348
  *This appendix is non-normative.* The interfaces defined here: `Widget` (7.1), `WidgetEvent` (7.6.1); the dictionaries `WidgetEnvironment`,
2197
2349
  `WidgetSetting`, `WidgetSettingOption` (7.2), `ChromeColorOptions` (7.4), `CountGripOptions`, `HeightGripOptions` (7.7),
2198
2350
  `ReadItemsOptions` (7.10), `ReaderItem`, `OpenItemsOptions` (7.11),
2199
- `PlayAudioOptions`, `AudioState`, `AudioControls`, `AudioInfo`, `VideoSpec`, `VideoState`, `PhotoSpec` (7.12),
2351
+ `PlayAudioOptions`, `AudioState`, `ElsewhereAudio`, `AudioControls`, `AudioInfo`, `VideoSpec`, `VideoState`, `PhotoSpec` (7.12),
2200
2352
  `ShareData`, `AddWidgetSpec`, `WidgetActionState` (7.13), `WidgetEventInit` (7.6.1), `FetchFeedOptions` (8.2); the callbacks `ReadKey` (7.10) and `DragWidgetCallback` (7.13); the typedef `ContentFeed` (8.5); the mixin `WidgetElement` (11.2, for UWA files).
2201
2353
 
2202
2354
  ## Appendix E. Open issues
@@ -2218,7 +2370,7 @@ draft. Each is to be resolved before the specification is considered complete.
2218
2370
 
2219
2371
  <a id="issue-7"></a>**Issue 7. Settings: edge cases and applying them.** Define empty and multiple `select`s, duplicate options, disabled controls, `step="any"`, malformed numbers, labels with several `label`s; the timing of a pause and of grouping; the precedence of `livePreferences`, `data-commit` and the type; the grammar of `data-when`; what applying a password does (an empty field keeping the stored one?); the validation of `url` and `number` values against their `step`; whether `setValue` accepts undeclared names, validates, or fires an event.
2220
2372
 
2221
- <a id="issue-8"></a>**Issue 8. Passwords on every path.** Section 6.5 keeps a password's value from a framed widget. Name every path it must not take: `preferences`, `getPreference`, restored values, the declared feed's template, shared links, diagnostics; and whether a file may declare a password's default.
2373
+ <a id="issue-8"></a>**Issue 8. Passwords on every path.** Section 6.5 keeps a password's value from a framed widget, and a key for a site (`data-key-for`, 5.3) from every widget. Name every path a password must not take: `preferences`, `getPreference`, restored values, the declared feed's template, shared links, diagnostics; and whether a file may declare a password's default.
2222
2374
 
2223
2375
  <a id="issue-9"></a>**Issue 9. URLs, proxies and the fetch relay.** Define one URL resolution and authorization algorithm (what a relative URL resolves against, which of the host's addresses are public services), the proxies' address checks (resolved addresses, IPv4 and IPv6, redirects, credentials in URLs), and the subset of Fetch the relay supports: methods, bodies, headers, aborts, redirects, response URLs, CORS.
2224
2376
 
@@ -2298,6 +2450,11 @@ and an `action` event carrying the `id` when one is chosen; a question it then a
2298
2450
  (`https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/agents.md`). Served by jsDelivr and unpkg (4.3), installed
2299
2451
  with `npm install @startside/swa`. Since 1.0.1 too, a command, for Node 20 or later, with nothing else to install:
2300
2452
  `validate` and `inline`, below.
2453
+ - **Running widgets in another page.** Since 1.0.3, `@startside/swa` also carries the runtime a host writes into a
2454
+ widget's frame (`swa/1.0/frame.js`, SWA files only), its base styles (`frame.css`), and `host.md`: how a host runs a
2455
+ frame (10.1), the configuration that runtime reads and the messages a host answers. Since 1.0.4, `host.js` too: a
2456
+ widget file read (6.2), its settings' values, the frame's document written and a message checked, by the code
2457
+ Startside's dashboard runs, as a module for the browser.
2301
2458
  - **Checking a file.** `npx @startside/swa validate my-widget.swa.html` reads a widget file without running it, with no
2302
2459
  network: the file's name and document, its runtime tag, metadata and settings form, and its scripts against this
2303
2460
  API, UWA's members and globals named with what replaces them. Each finding is `file:line:col: error|warning:
@@ -2348,5 +2505,6 @@ and an `action` event carrying the `id` when one is chosen; a question it then a
2348
2505
 
2349
2506
  ## Acknowledgements
2350
2507
 
2351
- SWA keeps the interface of the Universal Widget API, designed at Netvibes; its 1.2 Working Draft was edited by Xavier
2352
- Borderie and François Hodierne (2008).
2508
+ SWA keeps the interface of the [Universal Widget API](https://startside.app/uwa/1.2/spec.md), designed at Netvibes, whose runtime Netvibes.org
2509
+ published as open source (NVO; [an archive](https://github.com/znarf/nvo), forked from the original); its 1.2 Working
2510
+ Draft was edited by Xavier Borderie and François Hodierne (2008).