@startside/swa 1.0.0 → 1.0.1
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/LICENSE +60 -0
- package/README.md +39 -4
- package/bin/swa.mjs +33 -0
- package/package.json +10 -3
- package/swa/1.0/agents.md +638 -0
- package/swa/1.0/quickstart.md +145 -0
- package/swa/1.0/runtime.js +1 -1
- package/swa/1.0/spec.md +2125 -0
package/swa/1.0/spec.md
ADDED
|
@@ -0,0 +1,2125 @@
|
|
|
1
|
+
# Startside Widget API (SWA) 1.0
|
|
2
|
+
|
|
3
|
+
**Editor's Draft, 4 November 2026**
|
|
4
|
+
|
|
5
|
+
<dl>
|
|
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
|
+
<dt>Editor:</dt><dd>François Hodierne (Startside)</dd>
|
|
10
|
+
<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
|
+
<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>
|
|
12
|
+
</dl>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Abstract
|
|
17
|
+
|
|
18
|
+
This specification defines the **Startside Widget API (SWA)**: a format for widgets, small Web applications shown
|
|
19
|
+
many to a page on a personal dashboard, and the interface through which a widget and its host work together. A
|
|
20
|
+
widget is a single HTML document. Its head declares its name and metadata; a hidden form in its body declares its
|
|
21
|
+
settings; its scripts draw it through one object, `widget`, which gives it the host's services: its title bar, its
|
|
22
|
+
settings and memory, a shared article reader, read and unread items, kept content, the page's audio and video
|
|
23
|
+
players, sharing, and its accounts. Hosts run widgets in sandboxed frames, under the same rules for every author.
|
|
24
|
+
|
|
25
|
+
SWA is the successor of the Universal Widget API (UWA) 1.2, whose JavaScript interface it keeps.
|
|
26
|
+
|
|
27
|
+
**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
|
+
this document is the reference behind it.
|
|
29
|
+
|
|
30
|
+
## Status of This Document
|
|
31
|
+
|
|
32
|
+
*This section describes the status of this document at the time of its publication.*
|
|
33
|
+
|
|
34
|
+
This is an **Editor's Draft**, published by its editor for review by the people and software agents who write
|
|
35
|
+
Startside widgets. It is not a publication of the W3C, the IETF or any standards body, and is not endorsed by one; it
|
|
36
|
+
follows their conventions so that it can be read, implemented and checked as theirs are.
|
|
37
|
+
|
|
38
|
+
This document describes what the Startside host implements on the date above, except the features listed in
|
|
39
|
+
[Appendix C](#appendix-c-implementation-status-and-features-at-risk), which it specifies ahead of their
|
|
40
|
+
implementation: they are **at risk** and may change or be removed. A difference between this document and the
|
|
41
|
+
implementation, other than those, is a bug in one of them.
|
|
42
|
+
|
|
43
|
+
Questions this draft leaves open are listed in [Appendix E](#appendix-e-open-issues). Comments are welcome to its
|
|
44
|
+
editor.
|
|
45
|
+
|
|
46
|
+
## Table of Contents
|
|
47
|
+
|
|
48
|
+
1. [Introduction](#1-introduction)
|
|
49
|
+
2. [Conformance](#2-conformance)
|
|
50
|
+
3. [Terminology](#3-terminology)
|
|
51
|
+
4. [Widget files](#4-widget-files)
|
|
52
|
+
5. [The settings form](#5-the-settings-form)
|
|
53
|
+
6. [Processing model](#6-processing-model)
|
|
54
|
+
7. [The `Widget` interface](#7-the-widget-interface)
|
|
55
|
+
8. [Data access](#8-data-access)
|
|
56
|
+
9. [Built-in objects](#9-built-in-objects)
|
|
57
|
+
10. [Execution environments](#10-execution-environments)
|
|
58
|
+
11. [Compatibility with UWA 1.2](#11-compatibility-with-uwa-12)
|
|
59
|
+
12. [Security Considerations](#12-security-considerations)
|
|
60
|
+
13. [Privacy Considerations](#13-privacy-considerations)
|
|
61
|
+
14. [Accessibility Considerations](#14-accessibility-considerations)
|
|
62
|
+
- [Appendix A. Examples](#appendix-a-examples)
|
|
63
|
+
- [Appendix B. Changes from UWA 1.2.4](#appendix-b-changes-from-uwa-124)
|
|
64
|
+
- [Appendix C. Implementation status and features at risk](#appendix-c-implementation-status-and-features-at-risk)
|
|
65
|
+
- [Appendix D. IDL Index](#appendix-d-idl-index)
|
|
66
|
+
- [Appendix E. Open issues](#appendix-e-open-issues)
|
|
67
|
+
- [Appendix F. Tools for authors](#appendix-f-tools-for-authors)
|
|
68
|
+
- [References](#references)
|
|
69
|
+
- [Acknowledgements](#acknowledgements)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 1. Introduction
|
|
74
|
+
|
|
75
|
+
*This section is non-normative.*
|
|
76
|
+
|
|
77
|
+
A personal dashboard shows many small applications side by side: a weather forecast, a news feed, a radio, a game.
|
|
78
|
+
Each is written by someone else, often for many dashboards at once, and each needs the same few things from the page
|
|
79
|
+
around it: a title bar, settings, somewhere to keep its data, a way to open links, a share in the page's sound. UWA,
|
|
80
|
+
published by Netvibes in 2006–2008, defined such widgets as XHTML files with XML preferences. SWA moves them to
|
|
81
|
+
ordinary HTML and defines what the host adds.
|
|
82
|
+
|
|
83
|
+
A widget file is an HTML document with three conventions:
|
|
84
|
+
|
|
85
|
+
- its settings are a hidden `<form id="preferences">`, which the host reads without running the widget;
|
|
86
|
+
- its code works through one object, `widget`, rather than `document` and `window`;
|
|
87
|
+
- it is written for a sandboxed frame: what it keeps, fetches and opens goes through the host.
|
|
88
|
+
|
|
89
|
+
<div class="example">
|
|
90
|
+
|
|
91
|
+
**Example 1.** A widget greeting the person named in its settings.
|
|
92
|
+
|
|
93
|
+
```html
|
|
94
|
+
<!doctype html>
|
|
95
|
+
<html>
|
|
96
|
+
<head>
|
|
97
|
+
<script src="https://startside.app/swa/1.0/runtime.js"></script>
|
|
98
|
+
<title>Hello</title>
|
|
99
|
+
<meta name="description" content="Says hello." />
|
|
100
|
+
</head>
|
|
101
|
+
<body>
|
|
102
|
+
<form id="preferences" hidden>
|
|
103
|
+
<label>Who <input type="text" name="who" value="world" /></label>
|
|
104
|
+
</form>
|
|
105
|
+
<p>Hello, <span class="who">world</span>!</p>
|
|
106
|
+
<script>
|
|
107
|
+
widget.addEventListener('load', () => {
|
|
108
|
+
widget.body.querySelector('.who').textContent = String(widget.settings.get('who'));
|
|
109
|
+
});
|
|
110
|
+
</script>
|
|
111
|
+
</body>
|
|
112
|
+
</html>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Its markup is in the file and shows at once; its code only fills the name (7.3.1).
|
|
116
|
+
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
The design goals are, in order: one clean file that tools and people can read; metadata and settings declared in
|
|
120
|
+
markup, so a host reads them without running code; the same rules for every widget, the host's own included; and no
|
|
121
|
+
build step.
|
|
122
|
+
|
|
123
|
+
## 2. Conformance
|
|
124
|
+
|
|
125
|
+
Sections marked as non-normative, examples and notes are non-normative. Everything else is normative, requirements on
|
|
126
|
+
widget authors included.
|
|
127
|
+
|
|
128
|
+
The key words **MAY**, **MUST**, **MUST NOT**, **OPTIONAL**, **RECOMMENDED**, **REQUIRED**, **SHALL**, **SHALL
|
|
129
|
+
NOT**, **SHOULD** and **SHOULD NOT** in this document are to be interpreted as described in BCP 14 [[RFC2119](#ref-rfc2119)]
|
|
130
|
+
[[RFC8174](#ref-rfc8174)] when, and only when, they appear in all capitals, as shown here.
|
|
131
|
+
|
|
132
|
+
This specification defines conformance criteria for three classes of products:
|
|
133
|
+
|
|
134
|
+
- **<a id="dfn-widget-file"></a>widget files**, which satisfy every requirement on widget files and their authors;
|
|
135
|
+
- **<a id="dfn-host"></a>hosts** (user agents), which run widget files as the processing model (section 6) and the
|
|
136
|
+
interfaces (sections 7 to 9) define;
|
|
137
|
+
- **<a id="dfn-checker"></a>conformance checkers**, which verify that a widget file meets the requirements that can
|
|
138
|
+
be checked without running it.
|
|
139
|
+
|
|
140
|
+
Requirements phrased as algorithms (*"run these steps"*) may be implemented in any manner, as long as the result is
|
|
141
|
+
equivalent.
|
|
142
|
+
|
|
143
|
+
A host **MAY** implement only part of section 7: a widget calls a member it depends on only after testing that it is
|
|
144
|
+
present (`if (widget.addWidget) …`), and **MUST** remain usable where it is absent.
|
|
145
|
+
|
|
146
|
+
The interfaces are defined in Web IDL [[WEBIDL](#ref-webidl)]. Where Web IDL describes a member that a host
|
|
147
|
+
implements in a script (the reference implementation does), its argument conversions are those of the description,
|
|
148
|
+
not of a generated binding.
|
|
149
|
+
|
|
150
|
+
## 3. Terminology
|
|
151
|
+
|
|
152
|
+
This specification uses the terms *event*, *dispatch*, *listener* and *canceled flag* from [[DOM](#ref-dom)],
|
|
153
|
+
*document*, *element*, *script* and *transient activation* from [[HTML](#ref-html)],
|
|
154
|
+
*URL* and *parsing a URL* from [[URL](#ref-url)], *fetch* from [[FETCH](#ref-fetch)],
|
|
155
|
+
and *list*, *map* and *struct* from [[INFRA](#ref-infra)].
|
|
156
|
+
|
|
157
|
+
<dl>
|
|
158
|
+
<dt><a id="dfn-widget"></a><b>widget</b></dt>
|
|
159
|
+
<dd>One instance of a widget file on a page, with its own settings, memory and read state. One file can be
|
|
160
|
+
instantiated many times.</dd>
|
|
161
|
+
|
|
162
|
+
<dt><a id="dfn-dashboard"></a><b>dashboard</b></dt>
|
|
163
|
+
<dd>A host's page holding several widgets, arranged in tabs and columns.</dd>
|
|
164
|
+
|
|
165
|
+
<dt><a id="dfn-standalone-host"></a><b>standalone host</b></dt>
|
|
166
|
+
<dd>The runtime script running a widget file opened on its own, at its URL or from disk.</dd>
|
|
167
|
+
|
|
168
|
+
<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
|
|
170
|
+
<b>untrusted</b>: one from another site, or dropped from the person's computer.</dd>
|
|
171
|
+
|
|
172
|
+
<dt><a id="dfn-setting"></a><b>setting</b></dt>
|
|
173
|
+
<dd>A named preference of a widget, declared by its settings form (section 5), whose value is a string.</dd>
|
|
174
|
+
|
|
175
|
+
<dt><a id="dfn-key"></a><b>key</b></dt>
|
|
176
|
+
<dd>A widget file's short identifier, derived from its file name (section 4.1), used in the host's addresses.</dd>
|
|
177
|
+
|
|
178
|
+
<dt><a id="dfn-activation"></a><b>activation-gated</b></dt>
|
|
179
|
+
<dd>Said of an operation that a framed widget may perform only while its frame has transient activation: right after
|
|
180
|
+
a click or a key press in it.</dd>
|
|
181
|
+
|
|
182
|
+
<dt><a id="dfn-content-feed"></a><b>content feed</b></dt>
|
|
183
|
+
<dd>A JSON Feed 1.1 document [[JSONFEED](#ref-jsonfeed)], with the extensions of section 8.5.</dd>
|
|
184
|
+
|
|
185
|
+
<dt><a id="dfn-refresh"></a><b>refresh</b></dt>
|
|
186
|
+
<dd>Drawing a widget again and asking for its data again, triggered by the person, by its refresh interval, or by its
|
|
187
|
+
settings changing (section 6.6). What it asks for may still come from a cache, such as the host's proxy's (8.4).</dd>
|
|
188
|
+
</dl>
|
|
189
|
+
|
|
190
|
+
## 4. Widget files
|
|
191
|
+
|
|
192
|
+
### 4.1 File names and keys
|
|
193
|
+
|
|
194
|
+
A widget file's name **MUST** be `<name>.swa.html`, where `<name>` consists of one or more ASCII lowercase letters,
|
|
195
|
+
ASCII digits and U+002D (-). Its **key** is `<name>.swa`.
|
|
196
|
+
|
|
197
|
+
<div class="example">
|
|
198
|
+
|
|
199
|
+
**Example 2.** `weather.swa.html` has the key `weather.swa`; Startside adds it from `/add/weather.swa`.
|
|
200
|
+
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
Files named otherwise are other formats: UWA 1.2 files (`.uwa.xhtml`, ideally; `.xhtml`), section 11, and RWA files
|
|
204
|
+
(`.rwa.html`) [[RWA](#ref-rwa)], a format that extends this specification with templates.
|
|
205
|
+
|
|
206
|
+
### 4.2 Document requirements
|
|
207
|
+
|
|
208
|
+
A widget file **MUST** be a document in the HTML syntax [[HTML](#ref-html)], beginning with a DOCTYPE,
|
|
209
|
+
encoded in UTF-8. It needs no namespace, no CDATA section and no XML well-formedness. It **MUST NOT** depend on
|
|
210
|
+
content outside its `head` and `body` other than the resources it links.
|
|
211
|
+
|
|
212
|
+
Its structure, in order:
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<!doctype html>
|
|
216
|
+
<html>
|
|
217
|
+
<head>
|
|
218
|
+
<script src="…/swa/1.0/runtime.js"></script> <!-- 4.3, REQUIRED -->
|
|
219
|
+
<title>…</title> <!-- 4.4, REQUIRED -->
|
|
220
|
+
<meta name="…" content="…" /> <!-- 4.5 -->
|
|
221
|
+
<link rel="icon" href="…" /> <!-- 4.6 -->
|
|
222
|
+
<style>…</style> <!-- 4.7 -->
|
|
223
|
+
<script src="…"></script> <!-- 4.8, a library -->
|
|
224
|
+
</head>
|
|
225
|
+
<body>
|
|
226
|
+
<form id="preferences" hidden>…</form> <!-- 5 -->
|
|
227
|
+
… <!-- 4.9, initial content -->
|
|
228
|
+
<script>…</script> <!-- 4.8 -->
|
|
229
|
+
</body>
|
|
230
|
+
</html>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 4.3 The runtime script
|
|
234
|
+
|
|
235
|
+
The head **MUST** contain exactly one `script` element whose `src` is an absolute URL whose path ends with
|
|
236
|
+
`/swa/<version>/runtime.js`, `<version>` being `1.0` for this specification. The URL **SHOULD** use the `https`
|
|
237
|
+
scheme and **SHOULD** name a host that serves the runtime, so that the file runs when opened from disk. In order of
|
|
238
|
+
preference:
|
|
239
|
+
|
|
240
|
+
1. `https://startside.app/swa/1.0/runtime.js`, which has the runtime's fixes as soon as the site does;
|
|
241
|
+
2. the npm package `@startside/swa` on a CDN, where startside.app can't be loaded:
|
|
242
|
+
`https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/runtime.js` or
|
|
243
|
+
`https://unpkg.com/@startside/swa@1/swa/1.0/runtime.js`;
|
|
244
|
+
3. the runtime inlined, below.
|
|
245
|
+
|
|
246
|
+
A CDN address **SHOULD** name the package's version: `@1` gets the runtime's fixes, an exact version (`@1.0.0`) none,
|
|
247
|
+
and no version or `@latest` can bring a release that breaks the file. The package has its own version; the API's is the
|
|
248
|
+
one in the path, and a release of `@1` keeps `swa/1.0/`. A CDN's copy follows the site's releases.
|
|
249
|
+
|
|
250
|
+
**The runtime's host.** The runtime sends the widget's requests (8) through the proxies of its host: the origin its
|
|
251
|
+
script's `data-host` attribute names, an absolute `https` URL; absent, the origin the runtime is served from when it is
|
|
252
|
+
at that origin's root (its path is exactly `/swa/<version>/runtime.js`: startside.app, another Startside); else
|
|
253
|
+
`https://startside.app` (a CDN, an inlined copy).
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<script src="https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/runtime.js" data-host="https://startside.app"></script>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**The runtime inlined.** In its place, the head **MAY** contain exactly one `script` element without `src` whose
|
|
260
|
+
`data-runtime` attribute is `swa/<version>` and whose content is that runtime's text, unchanged: for an environment that
|
|
261
|
+
loads no script from another site (a chat's preview of a file, a page offline). Its requests still go to the runtime's
|
|
262
|
+
host, above: where the environment refuses them too (a preview that allows no request to another site), the widget
|
|
263
|
+
runs and draws, and its requests fail as on a page offline. A host treats it
|
|
264
|
+
as it treats the runtime's address: a dashboard **MUST NOT** run it, and reads the file's format from it. Such a copy
|
|
265
|
+
doesn't get the runtime's later fixes: a file **SHOULD** load the runtime by its address, and an inlined copy
|
|
266
|
+
**SHOULD** be made again from that address when the file is published (Appendix F).
|
|
267
|
+
|
|
268
|
+
```html
|
|
269
|
+
<script data-runtime="swa/1.0" data-host="https://startside.app">
|
|
270
|
+
/* the text of https://startside.app/swa/1.0/runtime.js */
|
|
271
|
+
</script>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The runtime's text contains no `</script`, `<!--` or `<script`, so it can be written into a `script` element as it is.
|
|
275
|
+
|
|
276
|
+
The runtime brings the standalone host and its stylesheet. A dashboard **MUST NOT** run that script: it runs the widget
|
|
277
|
+
with its own implementation of the same version, whatever URL the file names.
|
|
278
|
+
|
|
279
|
+
A host **MUST** also accept, in place of the runtime script, UWA's two platform tags: a stylesheet link whose path is
|
|
280
|
+
`/themes/uwa/style.css` and a script whose path is `/js/UWA/load.js.php`, at any origin; a dashboard ignores them as it
|
|
281
|
+
ignores the runtime script.
|
|
282
|
+
|
|
283
|
+
> **Note:** Startside serves the runtime from its development server and its build; UWA's two tags are those of UWA 1.2
|
|
284
|
+
> files, accepted so that a file moving to SWA can keep them a while.
|
|
285
|
+
|
|
286
|
+
### 4.4 The title
|
|
287
|
+
|
|
288
|
+
The head **MUST** contain one `title` element. Its text is the widget's name in the host's lists, and its title until
|
|
289
|
+
the widget sets one (section 7.3).
|
|
290
|
+
|
|
291
|
+
### 4.5 Metadata
|
|
292
|
+
|
|
293
|
+
Metadata are `meta` elements with a `name` and a `content` attribute. A host reads them without running the widget.
|
|
294
|
+
Names are case-sensitive; an unknown name, or a value that doesn't match its syntax below, is ignored. All are
|
|
295
|
+
optional.
|
|
296
|
+
|
|
297
|
+
<table>
|
|
298
|
+
<thead><tr><th>Name</th><th>Value</th><th>Meaning</th></tr></thead>
|
|
299
|
+
<tbody>
|
|
300
|
+
<tr><td colspan="3"><b>Description</b></td></tr>
|
|
301
|
+
<tr><td><code>description</code></td><td>text</td><td>One line describing the widget, in the host's lists</td></tr>
|
|
302
|
+
<tr><td><code>author</code>, <code>email</code>, <code>website</code></td><td>text, an e-mail address, a URL</td><td>Who made it</td></tr>
|
|
303
|
+
<tr><td><code>version</code></td><td>text</td><td>The widget's own version</td></tr>
|
|
304
|
+
<tr><td><code>apiVersion</code></td><td><code>1.0</code></td><td>The SWA version written for</td></tr>
|
|
305
|
+
<tr><td><code>keywords</code></td><td>text</td><td>More words the host's search finds it by</td></tr>
|
|
306
|
+
<tr><td><code>category</code></td><td>text</td><td>The section of the host's catalogue listing it (Startside: <code>Blogs</code>, <code>Games</code>, <code>Music & Radio</code>, <code>News</code>, <code>Social</code>, <code>TV & Video</code>, <code>Art</code>, <code>Vintage widgets</code>)</td></tr>
|
|
307
|
+
<tr><td><code>unlisted</code></td><td><code>true</code></td><td>Listed in no section and no search; still available from its address</td></tr>
|
|
308
|
+
<tr><td><code>addButton</code></td><td><code>false</code></td><td>No button to add it to a host on its own page (10.3): a demonstration, a widget meant for its own page</td></tr>
|
|
309
|
+
<tr><td colspan="3"><b>Appearance</b></td></tr>
|
|
310
|
+
<tr><td><code>chromeColor</code>, <code>chromeColorDark</code></td><td>a CSS color</td><td>Its title bar and border, light and dark</td></tr>
|
|
311
|
+
<tr><td><code>background</code>, <code>backgroundDark</code></td><td>a CSS color</td><td>Its body's color from the first paint, before the file loads, light and dark. <b>SHOULD</b> equal its root element's background</td></tr>
|
|
312
|
+
<tr><td><code>accentColor</code></td><td>a CSS color</td><td>Its brand color, used by the reader for the items it opens</td></tr>
|
|
313
|
+
<tr><td><code>looks</code></td><td><code>own</code>, <code>page</code>, <code>both</code></td><td>Whether it keeps its own colors, follows the page's, or offers both; <code>own</code> for a widget whose colors are its content</td></tr>
|
|
314
|
+
<tr><td><code>maximize</code></td><td><code>column</code>, <code>fill</code>, <code>fit</code></td><td>How it fills the window when maximized; <code>column</code> when absent</td></tr>
|
|
315
|
+
<tr><td><code>maximizeWidth</code></td><td>an integer, 360 to 1600</td><td>Its width in CSS pixels when maximized in a column; 600 when absent</td></tr>
|
|
316
|
+
<tr><td colspan="3"><b>Behaviour</b></td></tr>
|
|
317
|
+
<tr><td><code>autoRefresh</code></td><td>a positive integer</td><td>Minutes between automatic refreshes</td></tr>
|
|
318
|
+
<tr><td><code>livePreferences</code></td><td><code>false</code>, <code>instant</code></td><td>When settings apply (section 6.5)</td></tr>
|
|
319
|
+
<tr><td><code>feed</code></td><td>a URL template</td><td>The feed it reads (section 6.4)</td></tr>
|
|
320
|
+
<tr><td><code>accountService</code></td><td>a service name</td><td>The service of its account (section 7.13)</td></tr>
|
|
321
|
+
<tr><td><code>accountScope</code></td><td>permissions, space-separated</td><td>Only accounts allowing one of them are offered</td></tr>
|
|
322
|
+
<tr><td><code>debugMode</code></td><td><code>true</code></td><td><code>widget.log</code> writes to the console</td></tr>
|
|
323
|
+
</tbody>
|
|
324
|
+
</table>
|
|
325
|
+
|
|
326
|
+
### 4.6 Icon and thumbnail
|
|
327
|
+
|
|
328
|
+
A `link` element with `rel="icon"` gives the widget's icon, its URL relative to the file. It **MAY** be a `data:` URL
|
|
329
|
+
(an SVG, PNG or WebP image: `href="data:image/svg+xml,…"`), which travels with the file: the one icon a file shared by
|
|
330
|
+
itself, dropped or chosen from a computer, keeps, a relative URL having nothing then to resolve against. A PNG image beside the file,
|
|
331
|
+
with its base name (`weather.png` for `weather.swa.html`), is its thumbnail in the host's catalogue.
|
|
332
|
+
|
|
333
|
+
> **Note:** A best practice, not a requirement. An icon is shown small: 16 pixels in a title bar, 32 in a catalogue's
|
|
334
|
+
> list. An SVG stays sharp at every size and, inline, is a few hundred bytes of text, percent-encoded rather than in
|
|
335
|
+
> base64 (`#` written `%23`, single quotes inside the `href`'s double quotes). A PNG or WebP icon works as well: a
|
|
336
|
+
> square of 64 by 64 pixels, sharp at both sizes on a high-density screen. Either way, a few bold shapes read at 16
|
|
337
|
+
> pixels where fine detail doesn't.
|
|
338
|
+
|
|
339
|
+
### 4.7 Styles
|
|
340
|
+
|
|
341
|
+
The file's `style` elements and stylesheet links style the widget only (section 10). Rules **SHOULD** target classes of
|
|
342
|
+
the widget's own rather than element types, and **SHOULD** be scoped under the widget's own root class (`.flood .board`,
|
|
343
|
+
not `.board`): on its own page, the widget's styles share the document with the host's title bar and menu, whose
|
|
344
|
+
elements carry plain class names (`title`, `options`, `hint`), which an unscoped rule would restyle (10.3). A host provides these hooks:
|
|
345
|
+
|
|
346
|
+
| Hook | Present when |
|
|
347
|
+
|---|---|
|
|
348
|
+
| `color-scheme` on the root, `light` or `dark` | always: the page's mode; `light-dark()` in the widget's CSS follows it, as do form controls and scrollbars |
|
|
349
|
+
| attribute `data-color-scheme` on the root, `light` or `dark` | always: the same, for what isn't a color (a picture, a shadow, a layout): `:root[data-color-scheme="dark"] .x` |
|
|
350
|
+
| class `uwa-neutral` on the root | the widget follows the page's look, which replaces its own colors |
|
|
351
|
+
| class `uwa-full-size` on the root | the widget is maximized |
|
|
352
|
+
| class `uwa-full-window` on the root | the widget is full screen, alone over the window, whatever its `maximize` says |
|
|
353
|
+
| custom properties `--module-color`, `--module-paper` | the person gave the widget a palette color: its shade, and a pastel of it |
|
|
354
|
+
| custom properties `--text`, `--muted`, `--link`, `--link-visited`, `--widget-bg`, `--border`, `--hover` | always: the page style's colors |
|
|
355
|
+
| 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 property `--font-body` | always: the page style's font family |
|
|
357
|
+
|
|
358
|
+
The root is the widget's `html` element, framed and on its own page; a selector such as
|
|
359
|
+
`:root[data-color-scheme="dark"] .x` matches in both.
|
|
360
|
+
|
|
361
|
+
Another host may not set these properties: a widget **SHOULD** give each its own fallback, `var(--text, #222)`.
|
|
362
|
+
Classes in the host's base stylesheet (UWA's `.buttonClean`, `.nv-pager`, `.loading`) are UWA's, not part of this
|
|
363
|
+
specification: an SWA widget styles its own, the only classes it relies on being those this document names (`uwa-read`,
|
|
364
|
+
`ext-link`, 7.10). They still reach its document in Startside, so a widget avoids their names for its own classes
|
|
365
|
+
(`loading`, `spinner`, `buttonClean`, `nv-pager`, `uwa-error`) or prefixes its classes: `.loading`'s `display: flex`
|
|
366
|
+
outweighs the `hidden` attribute, and a "Loading…" so named stays shown.
|
|
367
|
+
|
|
368
|
+
**Light and dark.** A widget writes each of its colors once for both modes with CSS's `light-dark()`
|
|
369
|
+
[[CSS-COLOR-5](#ref-css-color-5)]: `color: light-dark(#293543, #f2f4f6)`, the first for a light page, the second for a
|
|
370
|
+
dark one, as the root's `color-scheme` says. `data-color-scheme` is for the rest. `@media (prefers-color-scheme)` is
|
|
371
|
+
the system's preference, not the page's mode (a framed widget gets it from the system in some browsers, from the page in
|
|
372
|
+
others): a widget **SHOULD NOT** use it for its look. UWA's class, `uwa-dark`, stays for UWA files (section 11).
|
|
373
|
+
|
|
374
|
+
Who draws what depends on the widget's look, which its `looks` metadata (4.5) offers and the person picks:
|
|
375
|
+
|
|
376
|
+
| | Its own look | The page's look (`uwa-neutral`) |
|
|
377
|
+
|---|---|---|
|
|
378
|
+
| The title bar, the border, the corner | the host's; `chromeColor` and `setChromeColor` color it | the host's |
|
|
379
|
+
| The body's background | the widget's (`background`, `backgroundDark`, its CSS) | the page's: the host makes every background transparent over `--widget-bg` |
|
|
380
|
+
| Text, links, borders, shadows | the widget's CSS | the page's: text `--text`, links `--link`, headings `--text`, borders a faint line, no shadows (the host overrides them) |
|
|
381
|
+
| Pictures, icons, form controls, a `canvas` | the widget's | the widget's: kept |
|
|
382
|
+
| The font | the host's base, 11 pixels and `--font-body` in Startside, unless the widget sets its own | the same |
|
|
383
|
+
| The accent | the widget uses `--accent` where it wants the page's | the same |
|
|
384
|
+
| Light and dark | the widget's, by `light-dark()` and `data-color-scheme`; without them its light look on a dark page | the page's colors, light or dark |
|
|
385
|
+
|
|
386
|
+
A widget's CSS **MUST NOT** style the host's elements (the title bar, the page around it, 10.3). A host puts the
|
|
387
|
+
widget's styles in a cascade layer under the page's look [[CSS-CASCADE-5](#ref-css-cascade-5)]: the page's look wins
|
|
388
|
+
over any of the widget's rules, whatever their specificity, and a widget's rule marked `!important` wins over the page's
|
|
389
|
+
look. A widget repairs what the page's look misses with such a rule under `html.uwa-neutral`, sparingly; one that must
|
|
390
|
+
keep its colors (a game's board) draws them in a `canvas` or an image, or declares `looks` `own`.
|
|
391
|
+
|
|
392
|
+
### 4.8 Scripts
|
|
393
|
+
|
|
394
|
+
A `script` element without a `type` attribute, or whose `type` is `text/javascript`, `application/javascript` or
|
|
395
|
+
`module`, is **widget code**, except the runtime script (4.3) and UWA's platform script, which are **platform
|
|
396
|
+
scripts**. Other `script` elements are data, not run (RWA's templates). Widget code:
|
|
397
|
+
|
|
398
|
+
- **MUST NOT** use `localStorage`, `sessionStorage`, IndexedDB, or cookies: a framed widget has an opaque origin and no
|
|
399
|
+
storage of its own (section 7.8 gives the alternatives);
|
|
400
|
+
- **SHOULD** use `widget.body` and `widget.createElement` rather than `document`, since on its own page the `document` also holds the host's title bar and menu;
|
|
401
|
+
- **SHOULD** keep its functions in one object of its own name, and start from a `load` listener (7.6).
|
|
402
|
+
|
|
403
|
+
A `script` element with a `src` attribute in the head loads a library before the widget code runs; a URL relative to
|
|
404
|
+
the file resolves against it.
|
|
405
|
+
|
|
406
|
+
### 4.9 Initial content
|
|
407
|
+
|
|
408
|
+
The body's content, the settings form and scripts excluded, is the widget's content until its code draws: a
|
|
409
|
+
placeholder, or a skeleton its code fills.
|
|
410
|
+
|
|
411
|
+
A widget **SHOULD** write its markup in the file, as a skeleton its code fills and updates in place (7.3.1), rather
|
|
412
|
+
than build it in script: a skeleton shows at once, before any code runs and again at every rebuild of the widget; its
|
|
413
|
+
structure, roles and names read as HTML, to its author and to tools; and an update that changes text and attributes
|
|
414
|
+
keeps the elements, and the keyboard focus on them.
|
|
415
|
+
|
|
416
|
+
## 5. The settings form
|
|
417
|
+
|
|
418
|
+
### 5.1 The `preferences` form
|
|
419
|
+
|
|
420
|
+
A widget's settings are declared by the first `form` element in its body whose `id` is `preferences`: its **settings
|
|
421
|
+
form**. A widget without settings has none. The settings form:
|
|
422
|
+
|
|
423
|
+
- **MUST** have the `hidden` attribute;
|
|
424
|
+
- **MUST** be static markup: a host reads it without running the widget, and widget code **MUST NOT** create or change
|
|
425
|
+
it;
|
|
426
|
+
- **MUST NOT** contain two controls with the same `name`.
|
|
427
|
+
|
|
428
|
+
### 5.2 Controls
|
|
429
|
+
|
|
430
|
+
Each `select`, `textarea` and `input` element with a non-empty `name` in the settings form declares one setting, except
|
|
431
|
+
an `input` whose `type` is `submit`, `button`, `reset` or `image`, which is a button, not a setting. Its
|
|
432
|
+
**type** and **default value** are:
|
|
433
|
+
|
|
434
|
+
| Control | Type | Default value |
|
|
435
|
+
|---|---|---|
|
|
436
|
+
| `select` | `list`, its options the `option` elements' `value` (else text) and text | the `value` of the first `option` with `selected`, else of the first `option` |
|
|
437
|
+
| `input type="checkbox"` | `boolean` | `"true"` if `checked`, else `"false"` |
|
|
438
|
+
| `input type="range"` | `range`, with `min`, `max`, `step` | `value` |
|
|
439
|
+
| `input type="number"` | `number`, with `min`, `max`, `step` | `value` |
|
|
440
|
+
| `input type="url"` | `url` | `value` |
|
|
441
|
+
| `input type="password"` | `password` | `value` |
|
|
442
|
+
| `input type="hidden"` | `hidden` | `value` |
|
|
443
|
+
| `textarea` | `text` | its text content |
|
|
444
|
+
| any other `input` | `text` | `value` |
|
|
445
|
+
|
|
446
|
+
Values are read from the controls' attributes as written in the file (not their current state); a missing `value`
|
|
447
|
+
attribute is the empty string.
|
|
448
|
+
|
|
449
|
+
The setting's **label** is the text content of the `label` element containing the control, without the text of the
|
|
450
|
+
controls inside it; else that of the `label` whose `for` is the control's `id`; else its `aria-label`; else its name.
|
|
451
|
+
Labels **SHOULD** be short and in English.
|
|
452
|
+
|
|
453
|
+
### 5.3 Attributes
|
|
454
|
+
|
|
455
|
+
| Attribute | On | Meaning |
|
|
456
|
+
|---|---|---|
|
|
457
|
+
| `data-hint` | any control | A text completing the label, which the host shows on request beside it |
|
|
458
|
+
| `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 |
|
|
459
|
+
| `data-commit="ok"` | a `text` control | Its value applies only when confirmed (section 6.5) |
|
|
460
|
+
| `data-share` | a `hidden` control | A shared link may carry its value |
|
|
461
|
+
| `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 |
|
|
462
|
+
| `data-feed` | an `option` | The feed of that choice (section 6.4); `none`: the choice has no feed |
|
|
463
|
+
|
|
464
|
+
A `button` or `input` with `type="submit"` in the settings form asks the host for a button confirming the settings,
|
|
465
|
+
labelled with its text (*OK* if empty).
|
|
466
|
+
|
|
467
|
+
`data-load` **SHOULD** be used only for what a widget plays once (a board, a set), never for what it is (a feed) or what
|
|
468
|
+
it keeps (a list of tasks).
|
|
469
|
+
|
|
470
|
+
## 6. Processing model
|
|
471
|
+
|
|
472
|
+
### 6.1 Widget records
|
|
473
|
+
|
|
474
|
+
A host keeps, for each widget, a **widget record**, a struct with:
|
|
475
|
+
|
|
476
|
+
- **file**: the widget file's URL; **key**; **trusted**, a boolean;
|
|
477
|
+
- **title**, **metadata** (a map), **settings** (a list of setting declarations);
|
|
478
|
+
- **values**: a map from setting names to strings;
|
|
479
|
+
- **memory**, **stored data**, **kept content** and **read keys** (sections 7.8 to 7.10);
|
|
480
|
+
- **environment**: `framed` or `standalone`.
|
|
481
|
+
|
|
482
|
+
### 6.2 Reading a widget file
|
|
483
|
+
|
|
484
|
+
To **read a widget file** at a URL *url*, a host runs these steps:
|
|
485
|
+
|
|
486
|
+
1. Fetch *url*. If this fails, report that the widget file can't be found, and stop.
|
|
487
|
+
2. If *url*'s path ends in `.html`, parse the response body as HTML; otherwise parse it as XML, and if that fails, as
|
|
488
|
+
HTML (section 11).
|
|
489
|
+
3. If the document is the host's own page, report that it isn't a widget file, and stop.
|
|
490
|
+
4. Let *title* be the text of the first `title` element, trimmed; if empty, a default name of the host's.
|
|
491
|
+
5. Let *metadata* be the map of every `meta` element's `name` to its `content`, in document order, a later element of the
|
|
492
|
+
same name replacing an earlier one. The host acts only on the names of 4.5 whose value has the syntax 4.5 gives;
|
|
493
|
+
`widget.metas` exposes the whole map.
|
|
494
|
+
6. Let *settings* be the settings of a UWA `widget:preferences` element if there is one (section 11), followed by the
|
|
495
|
+
result of **extracting the settings** (6.3) of the document; a name declared in both is the first one's.
|
|
496
|
+
7. Collect the widget code, the styles and the stylesheet links of the whole document, in document order. Remove the
|
|
497
|
+
settings form, `widget:preferences`, `style`, `link`, `meta`, `title` and the widget code from the body: what remains is
|
|
498
|
+
the initial content.
|
|
499
|
+
8. For each `script` element that is neither widget code nor a platform script (data for a format built on SWA, such
|
|
500
|
+
as RWA's templates), record the file's name and the line its content starts on, for that format's error reports.
|
|
501
|
+
Errors in widget code are reported at the locations the browser gives (7.15).
|
|
502
|
+
9. Return *title*, *metadata*, *settings*, the code, the styles and the initial content.
|
|
503
|
+
|
|
504
|
+
### 6.3 Extracting the settings
|
|
505
|
+
|
|
506
|
+
To **extract the settings** of a document, run these steps:
|
|
507
|
+
|
|
508
|
+
1. Let *form* be the document's settings form. If there is none, return an empty list.
|
|
509
|
+
2. Let *settings* be an empty list.
|
|
510
|
+
3. For each control of *form* that declares a setting (5.2), in tree order, append a
|
|
511
|
+
declaration: its name, type, label and default value (section 5.2); for `list`, its options; for `range` and
|
|
512
|
+
`number`, its `min`, `max` and `step` as numbers; its hint, condition, `commit` flag, `shareable` flag and load
|
|
513
|
+
label (section 5.3), the load label truncated to 40 characters.
|
|
514
|
+
4. Return *settings*.
|
|
515
|
+
|
|
516
|
+
The value of a setting is the widget's stored value for its name, or else its default value.
|
|
517
|
+
|
|
518
|
+
### 6.4 Resolving the declared feed
|
|
519
|
+
|
|
520
|
+
A widget **declares its feed** by a `feed` meta, or by `data-feed` on an option of a list setting. To **resolve the
|
|
521
|
+
declared feed** of a widget, run these steps:
|
|
522
|
+
|
|
523
|
+
1. For each list setting, if its current value's `option` has `data-feed`: if it is `none`, return null; otherwise let
|
|
524
|
+
*url* be that address and go to step 4.
|
|
525
|
+
2. Let *template* be the `feed` meta's content. If there is none, return null.
|
|
526
|
+
3. Let *url* be *template* with each `{name}` replaced by the value of the setting *name*: as written for a list
|
|
527
|
+
setting, else URL-encoded, unless the placeholder is the whole template, in which case the value as written.
|
|
528
|
+
4. Parse *url*. If this fails, or its scheme is neither `http` nor `https`, return null.
|
|
529
|
+
5. Return *url*.
|
|
530
|
+
|
|
531
|
+
A host **MAY** fetch a widget's declared feed while the widget isn't drawn, to show what's new or unread.
|
|
532
|
+
|
|
533
|
+
### 6.5 Applying a setting
|
|
534
|
+
|
|
535
|
+
When the person changes a setting, the host applies it:
|
|
536
|
+
|
|
537
|
+
- a `list`, `boolean` or `range` setting at once, grouping changes made within half a second into one;
|
|
538
|
+
- a `text` setting after a pause in typing, or when the settings are confirmed;
|
|
539
|
+
- a `url`, `number` or `data-commit` setting only when confirmed, by the person (Enter, leaving the field, a
|
|
540
|
+
confirming button) or by closing the settings; a `number` outside its range is never applied.
|
|
541
|
+
|
|
542
|
+
If `livePreferences` is `false`, every change waits for the settings to close; if `instant`, changes apply at once,
|
|
543
|
+
ungrouped. Applying settings stores the values, then **refreshes** the widget (6.6).
|
|
544
|
+
|
|
545
|
+
A password setting's value **MUST NOT** be given to a framed widget, nor carried by a link.
|
|
546
|
+
|
|
547
|
+
### 6.6 Starting and refreshing
|
|
548
|
+
|
|
549
|
+
To **start** a widget, the host runs these steps:
|
|
550
|
+
|
|
551
|
+
1. Build its environment (section 10) and put its initial content in `widget.body`.
|
|
552
|
+
2. Run the libraries, then the widget code, in document order.
|
|
553
|
+
3. **Fire a widget event** (7.6.2) named `load`, and track it as a load (below).
|
|
554
|
+
4. Fire a widget event named `loadcomplete`.
|
|
555
|
+
|
|
556
|
+
To **refresh** a widget, the host runs these steps:
|
|
557
|
+
|
|
558
|
+
1. If the widget **listens for** `refresh` (7.6.2), fire a widget event named `refresh`; otherwise fire one named
|
|
559
|
+
`load`.
|
|
560
|
+
2. Track it as a load.
|
|
561
|
+
|
|
562
|
+
A load is **in progress** from the event's dispatch until the widget calls `setBody`, an error is reported, or every
|
|
563
|
+
promise the event's listeners gave to `waitUntil` has settled, and at most
|
|
564
|
+
20 seconds; and while the widget has requests in flight. The host **SHOULD** show it in progress.
|
|
565
|
+
|
|
566
|
+
A host refreshes a widget:
|
|
567
|
+
|
|
568
|
+
- when the person asks;
|
|
569
|
+
- when settings are applied (6.5), unless a `settingschange` listener canceled it (7.5);
|
|
570
|
+
- when the widget asks, with `refresh()` (7.5);
|
|
571
|
+
- every `autoRefresh` minutes (or `setAutoRefresh`), counted from the end of the previous load or refresh; a refresh due
|
|
572
|
+
while the page is hidden waits for it to be shown.
|
|
573
|
+
|
|
574
|
+
A widget is **rebuilt**, started anew, when its tab is shown again. What it must keep across that lives in its values,
|
|
575
|
+
memory or stored data (section 7.8), never on its frame's `window`. A host **SHOULD NOT** show a rebuilt widget
|
|
576
|
+
loading when it has content kept to draw.
|
|
577
|
+
|
|
578
|
+
### 6.7 Activation-gated operations
|
|
579
|
+
|
|
580
|
+
An operation said to be **activation-gated** is, for a framed widget, honoured only if, when the host receives the
|
|
581
|
+
request, either:
|
|
582
|
+
|
|
583
|
+
- the host's own window has transient activation [[HTML](#ref-html)], the widget's frame is the host document's
|
|
584
|
+
focused area, the focus was **given** to the frame rather than taken by it, and the host has seen no click or key
|
|
585
|
+
press of its own since the frame got the focus; or
|
|
586
|
+
- the request answers a user action in the host's own interface meant for that widget (the audio bar's play button).
|
|
587
|
+
|
|
588
|
+
Activation alone isn't enough: a click anywhere on the page, in the host's own controls or in another widget, gives it
|
|
589
|
+
too. Nor is the focus: a frame can focus itself from its own script. The focus counts as given when, as the frame got
|
|
590
|
+
it, the pointer (a mouse or a pen) was over the frame, or a Tab key on the host's page had just moved it, or the host
|
|
591
|
+
had seen no click or key press of its own for longer than an activation lasts (5 seconds). A focus taken counts once
|
|
592
|
+
the host's last click or key press is older than an activation lasts: an activation then is the frame's own.
|
|
593
|
+
|
|
594
|
+
The host checks its own window and document: it never relies on what the frame says of its activation. Otherwise the
|
|
595
|
+
host **MUST** ignore the request.
|
|
596
|
+
|
|
597
|
+
A click or key press of the host's own is one that gives activation [[HTML](#ref-html)]: a mouse's or a pen's as it
|
|
598
|
+
presses, a finger's as it lifts; a scroll of the host's page, which gives none, isn't one. A finger's tap holds a frame
|
|
599
|
+
back for 1 second instead of an activation's 5: a browser on a touch screen may report touches nobody made.
|
|
600
|
+
|
|
601
|
+
> **Note:** A tap in a widget within 5 seconds of a click on the host's page, or 1 second of a tap on it, is ignored: a
|
|
602
|
+
> host can't tell it from a frame taking the focus.
|
|
603
|
+
|
|
604
|
+
## 7. The `Widget` interface
|
|
605
|
+
|
|
606
|
+
### 7.1 The `widget` object
|
|
607
|
+
|
|
608
|
+
A host exposes one `Widget` object per widget, as the global `widget` in the widget's realm.
|
|
609
|
+
|
|
610
|
+
```webidl
|
|
611
|
+
[Exposed=Window]
|
|
612
|
+
interface Widget : EventTarget {
|
|
613
|
+
// 7.2 Identity and environment
|
|
614
|
+
readonly attribute DOMString id;
|
|
615
|
+
readonly attribute DOMString title;
|
|
616
|
+
readonly attribute USVString uwaUrl;
|
|
617
|
+
readonly attribute DOMString lang;
|
|
618
|
+
readonly attribute DOMString locale;
|
|
619
|
+
readonly attribute object metas;
|
|
620
|
+
readonly attribute FrozenArray<object> preferences; // WidgetSettings
|
|
621
|
+
readonly attribute object environment; // a WidgetEnvironment
|
|
622
|
+
readonly attribute HTMLElement? body;
|
|
623
|
+
undefined log(any... data);
|
|
624
|
+
|
|
625
|
+
// 7.3 Content and title
|
|
626
|
+
undefined setBody((DOMString or Node) content);
|
|
627
|
+
undefined addBody((DOMString or Node) content);
|
|
628
|
+
HTMLElement createElement(DOMString tagName, optional object attributes);
|
|
629
|
+
undefined setTitle(DOMString title);
|
|
630
|
+
DOMString getTitle();
|
|
631
|
+
undefined setStyle(DOMString css);
|
|
632
|
+
|
|
633
|
+
// 7.4 Appearance
|
|
634
|
+
undefined setIcon(USVString? url);
|
|
635
|
+
undefined setChromeColor(DOMString? color, optional ChromeColorOptions options = {});
|
|
636
|
+
|
|
637
|
+
// 7.5 Settings
|
|
638
|
+
readonly attribute WidgetSettings settings;
|
|
639
|
+
WidgetSetting? getPreference(DOMString name);
|
|
640
|
+
undefined setMaxValue(DOMString name, long max);
|
|
641
|
+
undefined openPreferences();
|
|
642
|
+
HTMLSpanElement withPreferencesLink(DOMString text);
|
|
643
|
+
|
|
644
|
+
// 7.6 Events and lifecycle (addEventListener and the rest: EventTarget). No callbacks: UWA's are UWA files' (11.3).
|
|
645
|
+
undefined refresh();
|
|
646
|
+
undefined setAutoRefresh(unsigned long minutes);
|
|
647
|
+
undefined setPeriodical(DOMString name, Function callback, unsigned long delay, optional boolean now = false);
|
|
648
|
+
undefined clearPeriodical(DOMString name);
|
|
649
|
+
|
|
650
|
+
// 7.7 Lists and grips
|
|
651
|
+
undefined countGrip(Element box, DOMString itemSelector, optional CountGripOptions options = {});
|
|
652
|
+
undefined heightGrip(Element box, Element scroller, optional HeightGripOptions options = {});
|
|
653
|
+
|
|
654
|
+
// 7.8 Memory and stored data
|
|
655
|
+
readonly attribute WidgetStorage storage;
|
|
656
|
+
|
|
657
|
+
// 8 Data access
|
|
658
|
+
Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
|
|
659
|
+
Promise<ContentFeed> fetchFeed(USVString url, optional FetchFeedOptions options = {});
|
|
660
|
+
|
|
661
|
+
// 7.10 Read state and counts
|
|
662
|
+
undefined readItems(Element box, DOMString itemSelector, optional ReadItemsOptions options = {});
|
|
663
|
+
boolean isRead(DOMString key);
|
|
664
|
+
undefined setRead(sequence<DOMString> keys, boolean read);
|
|
665
|
+
undefined setUnreadCount(long count);
|
|
666
|
+
undefined setSearchResultCount(long count);
|
|
667
|
+
|
|
668
|
+
// 7.11 The reader
|
|
669
|
+
undefined openURL(USVString url);
|
|
670
|
+
undefined openItems(sequence<ReaderItem> items, unsigned long index, optional OpenItemsOptions options = {});
|
|
671
|
+
|
|
672
|
+
// 7.12 Sound, video, pictures
|
|
673
|
+
readonly attribute object audioState; // an AudioState
|
|
674
|
+
any playAudio(PlayAudioOptions options);
|
|
675
|
+
any pauseAudio();
|
|
676
|
+
any seekAudio(double seconds);
|
|
677
|
+
undefined audioStarted(Function stop, optional AudioControls controls = {});
|
|
678
|
+
undefined audioStopped();
|
|
679
|
+
undefined audioInfo(optional AudioInfo info = {});
|
|
680
|
+
readonly attribute object? videoState; // a VideoState
|
|
681
|
+
any playVideo(VideoSpec video);
|
|
682
|
+
any openPhoto(PhotoSpec photo);
|
|
683
|
+
|
|
684
|
+
// 7.13 The page
|
|
685
|
+
USVString? shareUrl();
|
|
686
|
+
any share(optional ShareData data = {});
|
|
687
|
+
any addWidget(AddWidgetSpec spec);
|
|
688
|
+
boolean dragWidget(Element element, (AddWidgetSpec or Function) spec);
|
|
689
|
+
readonly attribute boolean canFullSize;
|
|
690
|
+
readonly attribute boolean fullSize;
|
|
691
|
+
undefined openFull();
|
|
692
|
+
undefined closeFull();
|
|
693
|
+
readonly attribute boolean fullScreen;
|
|
694
|
+
undefined setFullScreen(boolean on);
|
|
695
|
+
};
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
The members returning `any` return what the host's operation returns (in Startside, a promise for some); widgets
|
|
699
|
+
**MUST NOT** rely on a particular value. The attributes typed `object` hold an object with the members of the
|
|
700
|
+
dictionary their comment names; the host replaces the object when the state changes.
|
|
701
|
+
|
|
702
|
+
The `readonly` attributes have no setter: assigning one changes nothing, and throws a `TypeError` in strict mode code,
|
|
703
|
+
as for a Web IDL attribute. What `metas`, `preferences` (each setting with it), `environment`, `settings`, `storage` and
|
|
704
|
+
`audioState` give is frozen; a widget changes its settings through `settings.set` (7.5), never by writing to
|
|
705
|
+
`preferences`. The `widget` object has the members of this interface and no others a widget can rely on: a host
|
|
706
|
+
**MUST NOT** expose UWA's members to an SWA widget (section 11), and names of its own start with `__` (reserved:
|
|
707
|
+
widgets **MUST NOT** use them).
|
|
708
|
+
|
|
709
|
+
### 7.2 Identity and environment
|
|
710
|
+
|
|
711
|
+
```webidl
|
|
712
|
+
dictionary WidgetEnvironment {
|
|
713
|
+
DOMString name; // the host's name
|
|
714
|
+
boolean standalone;
|
|
715
|
+
boolean inline; // false: an SWA widget never runs inline (10.2); kept for UWA files
|
|
716
|
+
DOMString style; // the page's style, or "" standalone
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
dictionary WidgetSetting {
|
|
720
|
+
required DOMString name;
|
|
721
|
+
required DOMString type; // "text", "password", "hidden", "boolean", "list", "range", "number", "url"
|
|
722
|
+
DOMString label;
|
|
723
|
+
DOMString defaultValue;
|
|
724
|
+
sequence<WidgetSettingOption> options;
|
|
725
|
+
double min;
|
|
726
|
+
double max;
|
|
727
|
+
double step;
|
|
728
|
+
DOMString hint;
|
|
729
|
+
DOMString when;
|
|
730
|
+
DOMString commit; // "ok"
|
|
731
|
+
boolean shareable;
|
|
732
|
+
DOMString load;
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
dictionary WidgetSettingOption {
|
|
736
|
+
required DOMString value;
|
|
737
|
+
DOMString label;
|
|
738
|
+
USVString feed;
|
|
739
|
+
};
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
- `id`: the widget's identifier, unique on the page. `title`: the title it's shown under, the person's name for it if
|
|
743
|
+
they renamed it, else its own (7.3). `uwaUrl`: its file's URL. `lang`,
|
|
744
|
+
`locale`: the person's language (`en_US`) and region (`us`), in UWA's form, kept (11): a language tag for `Intl` is
|
|
745
|
+
`widget.lang.replace('_', '-')`. `metas`: its metadata. `preferences`: its setting
|
|
746
|
+
declarations.
|
|
747
|
+
- `environment.style` names the page's style (in Startside: `classic`, `early`, `coriander`, `ginger`, `mac`, `aw`,
|
|
748
|
+
`neo`, `modern`). A framed widget is rebuilt when it changes.
|
|
749
|
+
- `log(…)` writes its arguments to the console when `debugMode` is `true`.
|
|
750
|
+
|
|
751
|
+
### 7.3 Content and title
|
|
752
|
+
|
|
753
|
+
- `setBody(content)` replaces the content of `body` with *content*, then fires a widget event named `updatebody`
|
|
754
|
+
(7.6.2): a node is appended once `body` is emptied; a string is parsed as HTML into it. `addBody(content)` appends
|
|
755
|
+
*content* (a string parsed as HTML in a `div` of its own), then fires the same event. `body` is null until the widget
|
|
756
|
+
starts.
|
|
757
|
+
|
|
758
|
+
`setBody` replaces everything, the elements the person was using with them (their focus, a field being typed in, a
|
|
759
|
+
list's scroll): it is for content made whole at each draw; content the person interacts with is drawn in place
|
|
760
|
+
(7.3.1). A string given to `setBody` or `addBody` is parsed as markup, and markup runs code (an `onerror`
|
|
761
|
+
attribute): a widget **SHOULD NOT** give them a string holding anything but its own fixed
|
|
762
|
+
markup, never text it fetched or a person typed, joined in (`'<p>' + title + '</p>'`) or interpolated; such text
|
|
763
|
+
goes into a node by `textContent` or an attribute, the node to `setBody`. The same holds for `innerHTML` and
|
|
764
|
+
`insertAdjacentHTML`. Escaping before joining is no substitute: one value left out, or escaped for the wrong place
|
|
765
|
+
(an attribute, an address), and the text is markup.
|
|
766
|
+
- `createElement(tagName, attributes)` returns a new `HTMLElement` (section 9). In *attributes*,
|
|
767
|
+
`class` sets its class, `styles` its style, `events` its listeners, and any other key an attribute.
|
|
768
|
+
- `setTitle(title)` sets the title shown in its title bar. *title* may contain `a` elements with `http` or `https`
|
|
769
|
+
addresses, shown as links; any other markup is reduced to its text. It is kept as the widget's title, shown
|
|
770
|
+
unless the person renamed the widget. `widget.title` is the title shown: the person's name for the widget, as text,
|
|
771
|
+
else the title as set, its links' markup included; `getTitle()` returns its text. A title is like a setting: when
|
|
772
|
+
the person renames the widget, or empties the name to give it its own back, the host fires `settingschange` with
|
|
773
|
+
the name `title` (7.5), then refreshes it unless the event is canceled; a widget showing its name (lettered on a
|
|
774
|
+
toy, in a heading) redraws it there.
|
|
775
|
+
- `setStyle(css)` adds a style sheet for the widget.
|
|
776
|
+
|
|
777
|
+
#### 7.3.1 Drawing in place
|
|
778
|
+
|
|
779
|
+
*This section is non-normative.* The practices that go with a skeleton (4.9):
|
|
780
|
+
|
|
781
|
+
- **Every state in the skeleton.** The content, and what shows while loading, when there is nothing, and after a
|
|
782
|
+
failure, are elements of the skeleton, shown or hidden with the `hidden` attribute. A style giving one of them a
|
|
783
|
+
`display` overrides `hidden`: add `.x[hidden] { display: none; }`.
|
|
784
|
+
- **Repeated items from a `template`.** A list's row, a grid's cell: a `template` element in the skeleton, its content
|
|
785
|
+
cloned for each item (`template.content.firstElementChild.cloneNode(true)`).
|
|
786
|
+
- **Parts found under `widget.body`.** In the `load` listener, `widget.body.querySelector('.count')`: on its own page
|
|
787
|
+
the document also holds the host's title bar and menu. The widget's document is its own (10.2), so an `id` is fine,
|
|
788
|
+
for `<label for>` and ARIA's references (`aria-describedby`, `aria-labelledby`, `aria-controls`) as for the rest.
|
|
789
|
+
- **Wired once.** Listeners added on the first `load`, on a container rather than on each row (`event.target.closest('.row')`), so
|
|
790
|
+
rows can be redrawn without wiring them again; a widget with a `refresh` listener has its `load` dispatched once
|
|
791
|
+
(6.6).
|
|
792
|
+
- **Filled with text, never markup.** `textContent`, attributes and `hidden`, on the skeleton's elements or a clone of
|
|
793
|
+
its `template`; `append('Posted by ', name)` adds text, never markup. Fetched text is never parsed as HTML (7.3).
|
|
794
|
+
- **HTML that is content.** A feed item's `content_html` is shown by the reader (`openItems`, 7.11), which is made for
|
|
795
|
+
a site's markup, or set with the browser's sanitizing `Element.setHTML()` [[HTML](#ref-html)]; never by `innerHTML`
|
|
796
|
+
or `setBody`.
|
|
797
|
+
- **Updated, not replaced.** A change sets the text, attributes and `hidden` of the elements there; a list replaces
|
|
798
|
+
only its rows. The keyboard focus stays on the element the person used; a widget that must replace that element
|
|
799
|
+
moves the focus to its replacement.
|
|
800
|
+
- **No `setBody`.** It replaces the skeleton. A load that draws in place gives `waitUntil` the promise of its work,
|
|
801
|
+
or none if it draws at once (6.6); the host follows the content's height without being told.
|
|
802
|
+
- **Back from what's kept.** After a rebuild (a tab switch), the skeleton is filled from what the widget kept
|
|
803
|
+
(`fetchFeed`'s kept copy, a setting, `storage.memory`) before anything is asked again (7.8, 7.9).
|
|
804
|
+
- **Changes announced.** A result, an error, new items: the text of a live region of the skeleton (section 14).
|
|
805
|
+
- **Keys heard on the widget's own element.** A `keydown` listener goes on the element that has the focus (the board,
|
|
806
|
+
the list), never on `document` or `window`: on its own page the host's menu shares the document, so a listener there plays the
|
|
807
|
+
game as the person types a title or a setting.
|
|
808
|
+
- **Nothing runs at rest.** A widget nobody uses does no work: an animation that draws the eye (a hint, a new item)
|
|
809
|
+
plays a few times and stops (`animation-iteration-count: 3`), one that runs on is for something under way (a
|
|
810
|
+
download); a timer is for what changes on screen (a clock, a countdown) and stops while `document.hidden`. Each
|
|
811
|
+
frame of an endless animation is drawn by the page, on a laptop's battery, for every widget showing it.
|
|
812
|
+
- **One Tab stop for a composite control.** A game board, a grid, a calendar, a list moved through with the keys is one
|
|
813
|
+
stop in the Tab order: the container focusable (`tabindex="0"`), its cells out of the order (`tabindex="-1"`), the
|
|
814
|
+
arrow keys moving inside it, as WAI-ARIA's Authoring Practices describe for each pattern [[ARIA-APG](#ref-aria-apg)]
|
|
815
|
+
(a grid's roving focus, a listbox's active option); a visible focus on whatever has it; a click inside leaves the
|
|
816
|
+
focus there. Not a Tab stop per cell, and no control disabled to keep the focus from it: a disabled control leaves
|
|
817
|
+
the order, and the keyboard loses its place.
|
|
818
|
+
|
|
819
|
+
`setBody` stays for content made whole at each draw.
|
|
820
|
+
|
|
821
|
+
#### 7.3.2 Size
|
|
822
|
+
|
|
823
|
+
**The width is the host's; the height is the widget's.** A host gives a widget its width (a dashboard's column, the
|
|
824
|
+
standalone page's box, which the person may resize) and fires `resize` when it changes (7.6.1, UWA's `onResize`); a
|
|
825
|
+
widget whose layout follows its width (a canvas, a board) watches its own element with the browser's `ResizeObserver`,
|
|
826
|
+
which also sees it maximized and a font arriving, rather than both; the widget's height is
|
|
827
|
+
its content's, and the host sizes the widget to it, framed by measuring the frame's document. A widget **MUST NOT**
|
|
828
|
+
size itself to the window or the viewport (`100vh`, `height: 100%` of the root): framed, the viewport is its frame,
|
|
829
|
+
whose height follows the widget's, so content sized from it grows without end or collapses.
|
|
830
|
+
|
|
831
|
+
- **Padding.** The host pads the widget's body (6 pixels by 8 in Startside: `.moduleContent`), framed and on its own
|
|
832
|
+
page alike; the widget's own wrapper adds what it wants inside, never a margin outside the body.
|
|
833
|
+
- **Edge to edge.** A widget that is a device (a toy, a console) draws to its edges by asking for the whole viewport as
|
|
834
|
+
a page does on a phone: `viewport-fit=cover` in its viewport meta (`<meta name="viewport" content="width=device-width,
|
|
835
|
+
initial-scale=1, viewport-fit=cover">`). The host then puts no padding round its body, from the first paint, framed
|
|
836
|
+
and on its own page; its frame's corners and border still clip it. What it must keep clear it keeps with
|
|
837
|
+
`env(safe-area-inset-top)` and the other three, as on the web: 0 in a dashboard's frame (the title bar is outside
|
|
838
|
+
it), a phone's notch and rounded corners on its own page. Without it, the host's padding.
|
|
839
|
+
- **Narrow and wide.** A widget lays out for any width from about 300 pixels (a phone's column; Startside's columns are
|
|
840
|
+
300 at least) to 1600 (maximized): content that needs room wraps, scales
|
|
841
|
+
(`clamp()`, `aspect-ratio`, `max-width`) or scrolls inside its own box (a wide table); the page around it never
|
|
842
|
+
scrolls sideways because of it.
|
|
843
|
+
- **Maximized** (`maximize`, 4.5 and 7.13; `fullsize`'s `detail` true, `html.uwa-full-size` on the root): with
|
|
844
|
+
`column`, a box `maximizeWidth` wide, its height still its content's; with `fill`, the whole window, the widget
|
|
845
|
+
sizing itself to its height (a board filling it); with `fit`, as wide as lets content whose height grows with its
|
|
846
|
+
width fit the window's height (a console's screen).
|
|
847
|
+
- **On its own page in a fixed-height frame** (10.3): the page scrolls; the widget still lays out for its width.
|
|
848
|
+
|
|
849
|
+
A widget never asks for more height: it takes what its content needs ([Issue 30](#issue-30)).
|
|
850
|
+
|
|
851
|
+
### 7.4 Appearance
|
|
852
|
+
|
|
853
|
+
```webidl
|
|
854
|
+
dictionary ChromeColorOptions {
|
|
855
|
+
DOMString? background = null;
|
|
856
|
+
};
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
- `setChromeColor(color, options)` sets the widget's title bar color, and its body's (`background`), while it runs,
|
|
860
|
+
over its `chromeColor` and `background` metadata; the host keeps them, so a reload paints them first; `null` restores
|
|
861
|
+
the metadata. A color the person chose wins over it.
|
|
862
|
+
- `setIcon(url)` sets its title bar's icon while it runs: an image of the host's widget directory (SVG, PNG, ICO or
|
|
863
|
+
WebP), relative to the file; the host keeps it. `null` or any other URL restores the file's icon.
|
|
864
|
+
|
|
865
|
+
### 7.5 Settings
|
|
866
|
+
|
|
867
|
+
```webidl
|
|
868
|
+
[Exposed=Window]
|
|
869
|
+
interface WidgetSettings {
|
|
870
|
+
any get(DOMString name);
|
|
871
|
+
undefined set(DOMString name, any value);
|
|
872
|
+
undefined reset(DOMString name);
|
|
873
|
+
};
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
- `settings.get(name)` returns the setting's value, typed by the control that declares it (5.2): a checkbox's is a
|
|
877
|
+
boolean; a `range`'s or a `number` field's a number, or null when it's empty; any other's (a list, text, an address,
|
|
878
|
+
a password, a hidden field) a string. A name the form doesn't declare gives `undefined`.
|
|
879
|
+
- `settings.set(name, value)` stores *value* as the setting's value, without refreshing the widget (a game's state, a
|
|
880
|
+
choice made in the widget itself): a boolean for a checkbox, a finite number for a `range` or `number` field, else
|
|
881
|
+
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
|
|
882
|
+
`TypeError`. `settings.reset(name)` restores the declared default.
|
|
883
|
+
- **`title`**, unless the form declares a setting of that name, is the widget's title, like a setting (7.3):
|
|
884
|
+
`settings.get('title')` returns the title shown, as text; `settings.set('title', name)` makes *name* the person's
|
|
885
|
+
name for the widget, as the host's own rename does, for a widget that lets the person rename it in itself (a field
|
|
886
|
+
over the name it shows), right after they acted in it (6.7); `settings.reset('title')`, an empty name or the
|
|
887
|
+
widget's own give it its own title back. The host saves it; no event fires and no refresh follows (the widget made
|
|
888
|
+
the change). A host **MAY** limit a setting's length (the
|
|
889
|
+
Appendix gives Startside's); a value over it isn't kept: `settings.get` returns it until the widget reloads, and the
|
|
890
|
+
host **SHOULD** say so in the widget's console. A widget keeping something that grows (a drawing, a long game) keeps it
|
|
891
|
+
under the limit itself.
|
|
892
|
+
- When the person applies settings (6.5), the host fires `settingschange` (7.6), its `detail.names` the settings whose
|
|
893
|
+
values changed (`title` when the person renamed the widget, 7.3); canceling it skips the refresh that follows, for a
|
|
894
|
+
widget that applies them in place. Nothing
|
|
895
|
+
changed (an OK with the same values): no event, the refresh as before.
|
|
896
|
+
- `refresh()` refreshes the widget as applying settings does (6.6): for a setting the widget changed with its own
|
|
897
|
+
control (a feed, a station chosen in it).
|
|
898
|
+
- `getPreference(name)` returns the setting's declaration, or null.
|
|
899
|
+
- `setMaxValue(name, max)` limits a `range` setting to *max* in the host's settings, never above its declared `max`
|
|
900
|
+
(a feed's length); the host keeps it.
|
|
901
|
+
- `openPreferences()` opens the widget's settings where the host keeps them. Activation-gated.
|
|
902
|
+
- `withPreferencesLink(text)` returns a `span` with *text*, in which each `[[part]]` is a link that opens the settings.
|
|
903
|
+
|
|
904
|
+
### 7.6 Events and lifecycle
|
|
905
|
+
|
|
906
|
+
`Widget` is an `EventTarget` [[DOM](#ref-dom)]: a widget listens for the host's events with
|
|
907
|
+
`addEventListener`, with any number of listeners, the options `once`, `capture` and `signal`, and
|
|
908
|
+
`removeEventListener`. Events are the only way: an SWA widget has no callbacks to assign (`widget.onLoad`), and no
|
|
909
|
+
`setCallback` or `callback`; a host **MUST NOT** call a function an SWA widget assigns to such a name. UWA's callbacks
|
|
910
|
+
are UWA files' (11.3).
|
|
911
|
+
|
|
912
|
+
#### 7.6.1 Event types
|
|
913
|
+
|
|
914
|
+
```webidl
|
|
915
|
+
[Exposed=Window]
|
|
916
|
+
interface WidgetEvent : Event {
|
|
917
|
+
constructor(DOMString type, optional WidgetEventInit eventInitDict = {});
|
|
918
|
+
readonly attribute any detail;
|
|
919
|
+
readonly attribute AbortSignal? signal;
|
|
920
|
+
undefined waitUntil(Promise<any> promise);
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
dictionary WidgetEventInit : EventInit {
|
|
924
|
+
any detail = null;
|
|
925
|
+
};
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
Every event the host fires at a widget is a `WidgetEvent`. None bubbles. `detail` carries the event's data, as the table
|
|
929
|
+
says. `waitUntil(promise)` extends a load (`load`, `refresh`) until *promise* settles; called on another event, or once the
|
|
930
|
+
event's dispatch has returned, it throws an `"InvalidStateError"` `DOMException`. A load's event (`load`, `refresh`)
|
|
931
|
+
carries a `signal` [[DOM](#ref-dom)], aborted when the next load starts or the widget goes: the widget passes it to its
|
|
932
|
+
requests (`fetch(url, { signal })`) so a superseded load stops, and stops drawing when it's aborted. Other events'
|
|
933
|
+
`signal` is null. A rejected promise is reported (7.6.3)
|
|
934
|
+
and ends its part of the load as settling does.
|
|
935
|
+
|
|
936
|
+
| Type | Fired | `detail` | Cancelable | UWA's callback (11.3) |
|
|
937
|
+
|---|---|---|---|---|
|
|
938
|
+
| `load` | as the widget starts, is rebuilt, or refreshes without a `refresh` listener (6.6) | null | no | `onLoad` |
|
|
939
|
+
| `loadcomplete` | after `load` | null | no | `onLoadComplete` |
|
|
940
|
+
| `refresh` | on a refresh (6.6) | null | no | `onRefresh` |
|
|
941
|
+
| `resize` | its width changed | null | no | `onResize` |
|
|
942
|
+
| `updatebody` | after `setBody` or `addBody` | null | no | `onUpdateBody` |
|
|
943
|
+
| `updatepreferences` | its setting declarations changed | null | no | `onUpdatePreferences` |
|
|
944
|
+
| `hideedit` | its settings closed | null | no | `onHideEdit` |
|
|
945
|
+
| `readall` | the person activated its unread count, `readItems`' or `setUnreadCount`'s (7.10) | null | yes: canceling skips marking `readItems`' items read | `onReadAll` |
|
|
946
|
+
| `audiostate` | `audioState` changed | the new `AudioState` | no | `onAudioState` |
|
|
947
|
+
| `audioresume` | the person asked to resume after a reload | null | no | `onAudioResume` |
|
|
948
|
+
| `videostate` | `videoState` changed | the new `VideoState`, or null | no | `onVideoState` |
|
|
949
|
+
| `fullsize` | it was maximized or restored, its box at its new size | `fullSize`'s new value | no | `onFullSize` |
|
|
950
|
+
| `fullscreen` | it went full screen or left it, after `fullsize` when both change | `fullScreen`'s new value | no | `onFullScreen` |
|
|
951
|
+
| `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 |
|
|
952
|
+
|
|
953
|
+
Event types are lowercase, as the platform's are. A host **MAY** fire other events; their types **MUST** be lowercase and
|
|
954
|
+
**MUST NOT** begin with `on`. Such an event isn't cancelable, and has a null `detail` unless the host says otherwise.
|
|
955
|
+
|
|
956
|
+
#### 7.6.2 Firing a widget event
|
|
957
|
+
|
|
958
|
+
A widget **listens for** an event type if, at the moment the host decides (in the widget's own realm, immediately before
|
|
959
|
+
the event would be fired), it has an event listener for it on `widget`.
|
|
960
|
+
|
|
961
|
+
To **fire a widget event** named *type* with *detail*, the host runs these steps:
|
|
962
|
+
|
|
963
|
+
1. Let *event* be a new `WidgetEvent` whose `type` is *type*, `detail` is *detail*, `cancelable` as the table says, and
|
|
964
|
+
`bubbles` false.
|
|
965
|
+
2. Dispatch *event* at `widget` [[DOM](#ref-dom)], with `widget` as each listener's `this`. An exception in a listener
|
|
966
|
+
is reported (7.6.3), and the other listeners still run.
|
|
967
|
+
3. Return whether *event*'s canceled flag is unset.
|
|
968
|
+
|
|
969
|
+
Listeners run as DOM dispatch orders them: capture listeners at the target before the others, each group in the order
|
|
970
|
+
added; `stopImmediatePropagation()` stops those that follow.
|
|
971
|
+
|
|
972
|
+
**Framed.** The host doesn't fire the events itself: it sends the frame a message naming what happened (a refresh, a
|
|
973
|
+
resize, the unread count activated, a new audio state), checked as section 10.1 says, and the runtime in the frame runs
|
|
974
|
+
the steps above in the widget's realm. So the frame decides whether the widget listens for `refresh` (6.6), and performs
|
|
975
|
+
`readall`'s default action (7.10); it tells the host when a load ends, as section 6.6 defines its end.
|
|
976
|
+
|
|
977
|
+
#### 7.6.3 Lifecycle methods
|
|
978
|
+
|
|
979
|
+
- `setAutoRefresh(minutes)` sets the refresh interval, over the `autoRefresh` metadata. Automatic refreshes are for a
|
|
980
|
+
widget that listens for `refresh` (6.6): one that doesn't has none, whatever its metadata says.
|
|
981
|
+
- `setPeriodical(name, callback, delay, now)` calls *callback* every *delay* milliseconds, at once too if *now*, until
|
|
982
|
+
`clearPeriodical(name)` or the widget goes.
|
|
983
|
+
|
|
984
|
+
An exception thrown by widget code while the host runs it or by a listener, and a promise given to
|
|
985
|
+
`waitUntil` that rejects, **MUST** be reported in the widget's box; the rest of the page goes on.
|
|
986
|
+
|
|
987
|
+
<div class="example">
|
|
988
|
+
|
|
989
|
+
**Example 3.** Listeners, removed together by a signal:
|
|
990
|
+
|
|
991
|
+
```js
|
|
992
|
+
const stop = new AbortController();
|
|
993
|
+
widget.addEventListener('load', () => MyWidget.draw());
|
|
994
|
+
widget.addEventListener('refresh', (e) => e.waitUntil(MyWidget.fetchAndDraw(e.signal)), { signal: stop.signal });
|
|
995
|
+
widget.addEventListener('fullsize', (e) => MyWidget.layout(e.detail));
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
</div>
|
|
999
|
+
|
|
1000
|
+
### 7.7 Lists and grips
|
|
1001
|
+
|
|
1002
|
+
```webidl
|
|
1003
|
+
dictionary CountGripOptions {
|
|
1004
|
+
Function onStart; // adds the items not shown yet
|
|
1005
|
+
Function onDone; // (unsigned long count)
|
|
1006
|
+
unsigned long min = 1;
|
|
1007
|
+
DOMString setting; // the setting holding the count: a double-click restores its default
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
dictionary HeightGripOptions {
|
|
1011
|
+
double height;
|
|
1012
|
+
unsigned long min;
|
|
1013
|
+
DOMString items; // a selector: the list's items
|
|
1014
|
+
Function onDone; // (double pixels)
|
|
1015
|
+
};
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
- `countGrip(box, itemSelector, options)` gives the widget a **corner grip**: dragging the widget's corner shows more or
|
|
1019
|
+
fewer of the items *itemSelector* matches in *box*. As the drag starts, `onStart()`; released, the host settles on whole
|
|
1020
|
+
items and calls `onDone(count)`, which keeps that count. A double-click on the grip calls `onStart()` then
|
|
1021
|
+
`onDone(default)`, *default* being the default value of `setting` (else of the widget's `count` or `limit` setting);
|
|
1022
|
+
maximized, it fits the window again instead.
|
|
1023
|
+
- `heightGrip(box, scroller, options)` gives the same grip to a list that keeps every item and scrolls in *scroller*: its
|
|
1024
|
+
height follows the drag, never taller than the list, then settles on whole items and calls `onDone(pixels)`. Maximized,
|
|
1025
|
+
the list takes the window's height instead.
|
|
1026
|
+
|
|
1027
|
+
Framed, the host follows the pointer once it leaves the frame and relays its moves. Either grip stays under the
|
|
1028
|
+
pointer: maximized in a centered window, which grows both ways, the height follows twice the pointer's move until the
|
|
1029
|
+
window is full, then the move itself.
|
|
1030
|
+
|
|
1031
|
+
### 7.8 Memory and stored data
|
|
1032
|
+
|
|
1033
|
+
Where a widget keeps what, in short (the table below): a choice of the person, or a game in progress, is a setting;
|
|
1034
|
+
`memory` is a cache, which a host may drop; `local` lasts across reloads.
|
|
1035
|
+
|
|
1036
|
+
```webidl
|
|
1037
|
+
[Exposed=Window]
|
|
1038
|
+
interface WidgetStorage {
|
|
1039
|
+
readonly attribute WidgetStorageArea memory;
|
|
1040
|
+
readonly attribute WidgetStorageArea local;
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
[Exposed=Window]
|
|
1044
|
+
interface WidgetStorageArea {
|
|
1045
|
+
Promise<any> get(DOMString key);
|
|
1046
|
+
Promise<undefined> set(DOMString key, any value);
|
|
1047
|
+
Promise<undefined> delete(DOMString key);
|
|
1048
|
+
};
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
`widget.storage` holds what a widget keeps, in two **storage areas**, each a map of keys to JSON values:
|
|
1052
|
+
|
|
1053
|
+
- **`memory`**: the widget's own, across rebuilds (its tab shown again) and, unless the person turned it off, across
|
|
1054
|
+
reloads; for a cache, what the widget draws at once as it starts. A host **MAY** limit it (Startside: about 2 MB per
|
|
1055
|
+
widget) and refuse the keys it keeps its own data under (Startside: `content`, `uwa-feeds`, rejected with a
|
|
1056
|
+
`TypeError`).
|
|
1057
|
+
- **`local`**: the page's, across reloads, shared by every widget of the same file; for what outlasts a game (its
|
|
1058
|
+
scores). Framed, a widget reads the values as they were when it started, with its own writes since.
|
|
1059
|
+
|
|
1060
|
+
`get(key)` resolves with a copy of the key's value, or `undefined`; `set(key, value)` keeps a copy of *value*, which
|
|
1061
|
+
**MUST** be serializable as JSON (a value that isn't, `undefined` among them, rejects with a `TypeError`); `delete(key)`
|
|
1062
|
+
removes it. A value read is a copy: changing it changes nothing kept. What a widget kept is there as it starts, so its
|
|
1063
|
+
first `get` resolves without waiting on the host (the data is in the widget's realm before its scripts run): a widget **MAY** read in its `load` listener, or as its script
|
|
1064
|
+
starts, and draw what it kept without showing a load.
|
|
1065
|
+
|
|
1066
|
+
UWA's `remember`, `recall`, `setStored` and `getStored` are UWA files' (11.1): the same data, `memory` and `local`.
|
|
1067
|
+
|
|
1068
|
+
| To keep | Use |
|
|
1069
|
+
|---|---|
|
|
1070
|
+
| a choice of the person, or a game in progress | a setting (`settings.set`), hidden if not edited by hand |
|
|
1071
|
+
| data across rebuilds, a cache | `storage.memory` |
|
|
1072
|
+
| data across reloads, shared by copies of the file | `storage.local` |
|
|
1073
|
+
| a feed | nothing: `fetchFeed` keeps it (7.9) |
|
|
1074
|
+
|
|
1075
|
+
Saved data outlives the code that wrote it: widget code **MUST** read it defensively.
|
|
1076
|
+
|
|
1077
|
+
### 7.9 Kept feeds
|
|
1078
|
+
|
|
1079
|
+
The host keeps the feeds `fetchFeed` (8.3) gives a widget, so that a widget rebuilt (its tab shown again, the page
|
|
1080
|
+
reloaded) draws at once from what it had: for a limited number of feeds per widget (Startside: 6), a feed not asked for in 30 days dropped,
|
|
1081
|
+
each stamped with when it was fetched. A kept feed less than 5 minutes old answers `fetchFeed` with no request; an
|
|
1082
|
+
older one answers it too, while the host asks for the feed behind it and, once the new copy is kept, refreshes the
|
|
1083
|
+
widget (6.6), whose `fetchFeed` then answers with that copy. With `fresh`, `fetchFeed` always asks.
|
|
1084
|
+
|
|
1085
|
+
UWA's `loadContent`, `keptContent` and `keepContent`, which did this by hand, are UWA files' (11.1).
|
|
1086
|
+
|
|
1087
|
+
### 7.10 Read state and counts
|
|
1088
|
+
|
|
1089
|
+
```webidl
|
|
1090
|
+
callback ReadKey = DOMString (Element item);
|
|
1091
|
+
dictionary ReadItemsOptions {
|
|
1092
|
+
ReadKey key;
|
|
1093
|
+
};
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
- `readItems(box, itemSelector, options)` manages a list's read state: each item *itemSelector* matches in *box* has a
|
|
1097
|
+
**read key**, `options.key(item)`, else the address of its first `a.ext-link`, else of its first link; the host adds the
|
|
1098
|
+
class `uwa-read` to read items, makes an item read when one of its links is opened, counts the unread items shown as
|
|
1099
|
+
the widget's unread count, and makes them all read when the count is activated, as `readall`'s default action, unless
|
|
1100
|
+
a listener cancels the event.
|
|
1101
|
+
- `isRead(key)` and `setRead(keys, read)` do it by hand. `setUnreadCount(count)` shows *count*, when positive, after the
|
|
1102
|
+
title and in the tab's count; activating it fires `readall` (7.6). `setSearchResultCount(count)` is accepted.
|
|
1103
|
+
|
|
1104
|
+
A host keeps the last 500 read keys of a widget. A widget file replacing another **MUST** keep its read keys.
|
|
1105
|
+
Headline links to another site **SHOULD** have the class `ext-link`.
|
|
1106
|
+
|
|
1107
|
+
### 7.11 The reader
|
|
1108
|
+
|
|
1109
|
+
The host's **reader** shows an article over the page, the list it comes from beside it.
|
|
1110
|
+
|
|
1111
|
+
```webidl
|
|
1112
|
+
dictionary ReaderItem {
|
|
1113
|
+
required USVString url;
|
|
1114
|
+
USVString link; // where its headline points, when not `url`
|
|
1115
|
+
DOMString title;
|
|
1116
|
+
DOMString content; // HTML, the reader's text
|
|
1117
|
+
DOMString prefer; // "feed", "page" or "reader": its first view
|
|
1118
|
+
DOMString date; // an RFC 3339 date, in the reader's list
|
|
1119
|
+
DOMString summary; // a short excerpt, in the reader's list
|
|
1120
|
+
DOMString author;
|
|
1121
|
+
USVString image;
|
|
1122
|
+
boolean read = false;
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
dictionary OpenItemsOptions {
|
|
1126
|
+
DOMString prefer; // "feed", "page" or "reader"
|
|
1127
|
+
sequence<DOMString> frameable; // sites that allow being framed
|
|
1128
|
+
Function onOpen; // (unsigned long index)
|
|
1129
|
+
};
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
- `openURL(url)` opens *url* in the reader; standalone, in a new tab. Only `http` and `https` URLs.
|
|
1133
|
+
- `openItems(items, index, options)` opens the reader on `items[index]`, the person moving through the others;
|
|
1134
|
+
`prefer` is the first view, `frameable` the sites the reader may show as Web pages, `onOpen(index)` is called as each
|
|
1135
|
+
item shows.
|
|
1136
|
+
|
|
1137
|
+
Framed, both are activation-gated, and never open the host's own addresses.
|
|
1138
|
+
|
|
1139
|
+
### 7.12 Sound, video and pictures
|
|
1140
|
+
|
|
1141
|
+
```webidl
|
|
1142
|
+
dictionary PlayAudioOptions {
|
|
1143
|
+
required USVString url; // https
|
|
1144
|
+
boolean relay = false; // played without a Referer, through the host's relay
|
|
1145
|
+
boolean live = true;
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
dictionary AudioState {
|
|
1149
|
+
USVString? url;
|
|
1150
|
+
boolean playing;
|
|
1151
|
+
boolean loading;
|
|
1152
|
+
DOMString? error; // null, "blocked" or "failed"
|
|
1153
|
+
unsigned long? time; // seconds, for a file
|
|
1154
|
+
unsigned long? duration;
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
dictionary AudioControls {
|
|
1158
|
+
Function resume;
|
|
1159
|
+
Function setVolume; // (double volume), 0 to 1
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
dictionary AudioInfo {
|
|
1163
|
+
DOMString source;
|
|
1164
|
+
DOMString title;
|
|
1165
|
+
DOMString artist;
|
|
1166
|
+
USVString artwork;
|
|
1167
|
+
DOMString artworkType;
|
|
1168
|
+
DOMString artworkSizes;
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
dictionary VideoSpec {
|
|
1172
|
+
required DOMString provider; // "youtube", "vimeo" or "arte"
|
|
1173
|
+
required DOMString id;
|
|
1174
|
+
DOMString title;
|
|
1175
|
+
DOMString list; // a YouTube playlist
|
|
1176
|
+
DOMString lang; // an ARTE language
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
dictionary VideoState {
|
|
1180
|
+
DOMString provider;
|
|
1181
|
+
DOMString id;
|
|
1182
|
+
DOMString list;
|
|
1183
|
+
boolean playing;
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
dictionary PhotoSpec {
|
|
1187
|
+
required USVString src;
|
|
1188
|
+
DOMString alt;
|
|
1189
|
+
DOMString title;
|
|
1190
|
+
USVString preview;
|
|
1191
|
+
unsigned long width;
|
|
1192
|
+
unsigned long height;
|
|
1193
|
+
DOMString credit;
|
|
1194
|
+
};
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
**Sound.** A page plays one sound at a time.
|
|
1198
|
+
|
|
1199
|
+
- `playAudio(options)` plays an `https` stream in the host's page, not in the widget, so that nothing happening to the
|
|
1200
|
+
widget interrupts it; a `live` stream is never played behind its live point. `pauseAudio()`; `seekAudio(seconds)` for a
|
|
1201
|
+
file. `audioState` is its state, and `audiostate` (`onAudioState`) is fired as it changes. Activation-gated.
|
|
1202
|
+
- A widget playing with a player of its own calls `audioStarted(stop, controls)` as it starts: the host stops the sound
|
|
1203
|
+
playing before, and calls *stop* when another starts or the person pauses it. `audioStopped()` says it stopped by itself;
|
|
1204
|
+
`audioInfo(info)` says what plays.
|
|
1205
|
+
- After a reload, the host **MAY** offer to resume; it then fires `audioresume` (`onAudioResume`).
|
|
1206
|
+
|
|
1207
|
+
**Video.** `playVideo(video)` plays a video in the host's player, over the page: only the providers above, by id, never a
|
|
1208
|
+
URL the widget gives. `videoState` and the `videostate` event (`onVideoState`) report what plays, where the provider tells. Activation-gated;
|
|
1209
|
+
standalone, the video opens on its site.
|
|
1210
|
+
|
|
1211
|
+
**Pictures.** `openPhoto(photo)` shows a picture at full size in the host's window: an `https` URL or one of the host's.
|
|
1212
|
+
`preview` is shown while `src` loads; `width` and `height` give its proportions at once; `credit` is what its licence asks
|
|
1213
|
+
to go with it, shared with it. 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,
|
|
1214
|
+
their required credits kept.
|
|
1215
|
+
|
|
1216
|
+
### 7.13 The page
|
|
1217
|
+
|
|
1218
|
+
```webidl
|
|
1219
|
+
dictionary ShareData {
|
|
1220
|
+
DOMString text;
|
|
1221
|
+
USVString url;
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
dictionary AddWidgetSpec {
|
|
1225
|
+
required DOMString file; // a file of the host's widget directory
|
|
1226
|
+
DOMString title;
|
|
1227
|
+
record<DOMString, DOMString> values; // at most 12, 200 characters each
|
|
1228
|
+
};
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
- `shareUrl()` returns the widget's address on its host (`/add/<key>`), or null for an untrusted file.
|
|
1232
|
+
- `share(data)` shares *data* through the system's share sheet where there is one, else the clipboard. Activation-gated.
|
|
1233
|
+
- `addWidget(spec)` adds a widget of the host's directory after this one, with *spec*'s title and values. Trusted files
|
|
1234
|
+
only; activation-gated. The member is **absent** where no widget can be added (a preview, standalone).
|
|
1235
|
+
- `dragWidget(element, spec)` makes *element* draggable onto the page, creating the widget *spec* names (or returns, if
|
|
1236
|
+
a function, as the drag starts) where it is dropped; it returns false, leaving *element* alone, where drags can't
|
|
1237
|
+
reach the page (framed, standalone).
|
|
1238
|
+
- **Maximized.** A person may maximize any widget. `canFullSize` says whether the host can; `openFull()` and
|
|
1239
|
+
`closeFull()` do it from a control of the widget's own; `fullSize` says which; `fullsize` (`onFullSize`) is fired once its
|
|
1240
|
+
box has its new size. `setFullScreen(on)`, activation-gated, puts the widget alone over the window, maximized first if it isn't, in the browser's full screen where there is one; `false` puts
|
|
1241
|
+
the widget back as it was before (on the page if the full screen maximized it). `fullScreen` says whether it is, the
|
|
1242
|
+
person's Esc included; `fullscreen` (`onFullScreen`) is fired as it changes.
|
|
1243
|
+
- **Accounts.** A trusted widget declaring `accountService` and a hidden setting named `account` has its account in its
|
|
1244
|
+
settings: the host lists the page's accounts of that service (those allowing one of `accountScope`'s permissions; an
|
|
1245
|
+
account reporting none allows none, an account's permissions read space- or comma-separated) and
|
|
1246
|
+
offers to unlink it, which clears `account`. Its requests reach that service's routes on the host (section 10.1); a
|
|
1247
|
+
sign-in window opens through the host, activation-gated. A widget **MUST NOT** assume one account per service. An
|
|
1248
|
+
untrusted file declaring `accountService` gets nothing.
|
|
1249
|
+
|
|
1250
|
+
### 7.14 Absent members
|
|
1251
|
+
|
|
1252
|
+
Where the host can't perform an operation (standalone: the reader, adding widgets), the member performs a
|
|
1253
|
+
fallback stated above or does nothing; `addWidget` alone is absent, so that `if (widget.addWidget)` tells.
|
|
1254
|
+
|
|
1255
|
+
### 7.15 Error reports
|
|
1256
|
+
|
|
1257
|
+
A host **SHOULD** report errors in widget code at the file's own lines: the file's name and the line, with an excerpt.
|
|
1258
|
+
|
|
1259
|
+
## 8. Data access
|
|
1260
|
+
|
|
1261
|
+
### 8.1 Fetching
|
|
1262
|
+
|
|
1263
|
+
Framed, the browser's `fetch` [[FETCH](#ref-fetch)] reaches `https` URLs only. The frame's origin is opaque: it has no
|
|
1264
|
+
cookies of its own, and its cross-origin requests carry an `Origin` of `null`, so they reach only APIs that allow any
|
|
1265
|
+
origin. Whether the browser attaches a site's own cookies to a request to that site is the browser's third-party
|
|
1266
|
+
cookie policy, which this specification doesn't change. A relative URL resolves against the host and reaches only its
|
|
1267
|
+
public services, and, for trusted files, the account services of section 7.13. `XMLHttpRequest` and WebSocket are not
|
|
1268
|
+
relayed. For any other site, `widget.fetch` (8.2) goes through the host.
|
|
1269
|
+
|
|
1270
|
+
### 8.2 `widget.fetch`
|
|
1271
|
+
|
|
1272
|
+
```webidl
|
|
1273
|
+
dictionary FetchFeedOptions {
|
|
1274
|
+
AbortSignal? signal = null;
|
|
1275
|
+
boolean fresh = false;
|
|
1276
|
+
};
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
`fetch(input, init)` is the platform's `fetch` [[FETCH](#ref-fetch)] made by the host for the widget, through its
|
|
1280
|
+
proxy, so that it needs no CORS: same arguments, and it resolves to a `Response`. The host **MUST** refuse addresses on
|
|
1281
|
+
local and private networks, including through redirects, and its own addresses other than its public services; it
|
|
1282
|
+
**MAY** answer from a cache of 5 minutes (8.4). In this version:
|
|
1283
|
+
|
|
1284
|
+
- only `GET` requests are made: another `method` rejects with a `TypeError`;
|
|
1285
|
+
- an `Accept` header naming JSON asks with JSON headers (a GraphQL query by `GET`); no other request header is sent;
|
|
1286
|
+
- the `Response` carries the body, as text, with the status 200 for a success (the relay keeps no other); an HTTP
|
|
1287
|
+
error gives a `Response` with its status and no
|
|
1288
|
+
body, `ok` false; a network failure, or a refused address, rejects with a `TypeError`, as the platform's does;
|
|
1289
|
+
- the response's headers aren't given, and a binary body isn't either (a picture is shown with an `img`);
|
|
1290
|
+
- the signal (`init`'s, else the `Request`'s) aborts it: the promise rejects with the signal's reason.
|
|
1291
|
+
|
|
1292
|
+
What the widget does with the body is the platform's: `res.json()` for JSON, `res.text()` for text, and for a page or
|
|
1293
|
+
an XML document `new DOMParser().parseFromString(text, 'text/html')` (or `'application/xml'`), a document whose scripts
|
|
1294
|
+
don't run. Markup from it **MUST NOT** be inserted into the widget as HTML. A widget reading a site's pages or API
|
|
1295
|
+
with `fetch` **MUST** respect the site's robots.txt [[RFC9309](#ref-rfc9309)] and its terms, as any automated client
|
|
1296
|
+
does; a host **MAY** check robots.txt itself for these requests.
|
|
1297
|
+
|
|
1298
|
+
### 8.3 `widget.fetchFeed`
|
|
1299
|
+
|
|
1300
|
+
`fetchFeed(url, options)` gives the feed at *url*, RSS, Atom or JSON Feed, as a content feed (8.5): the host parses and
|
|
1301
|
+
normalizes it, keeps it (7.9), and resolves with it; a feed with no items is a feed, not a failure. `options.signal`
|
|
1302
|
+
aborts it; `options.fresh` skips the kept copy (a refresh the person asked for, 6.6). A feed that can't be read rejects
|
|
1303
|
+
with an `Error`; a widget showing nothing then gets its load tried again sooner than its automatic refresh. A feed is
|
|
1304
|
+
asked for by kind: a JSON Feed fetched with `fetch` is the file's JSON, unnormalized.
|
|
1305
|
+
|
|
1306
|
+
A feed is fetched as the person's agent, not as a crawler: the feed a widget reads is one a person chose (its settings,
|
|
1307
|
+
the file's declared feed), so a host fetches it, and refreshes it, without consulting robots.txt, as feed readers do.
|
|
1308
|
+
It **MUST** fetch it as a good feed reader does: named in its `User-Agent`, at most every 5 minutes for any number of
|
|
1309
|
+
widgets asking (8.4), with conditional requests (`If-None-Match`, `If-Modified-Since`) once it has a copy, and honouring
|
|
1310
|
+
a `429`'s `Retry-After` (seconds or a date). Given a page's address rather than a feed's, the host **MAY** follow the
|
|
1311
|
+
first feed the page advertises (`<link rel="alternate">`, one more request, as feed readers do); crawling a site to
|
|
1312
|
+
discover feeds is not part of this specification.
|
|
1313
|
+
|
|
1314
|
+
### 8.4 Freshness
|
|
1315
|
+
|
|
1316
|
+
Responses and feeds through the host's proxy are fresh for 5 minutes; a refresh the person asks for skips that cache.
|
|
1317
|
+
A kept feed answers at once whatever its age, asked again behind it when older than 5 minutes (7.9).
|
|
1318
|
+
|
|
1319
|
+
### 8.5 Content feeds
|
|
1320
|
+
|
|
1321
|
+
A **content feed** is a JSON Feed 1.1 document [[JSONFEED](#ref-jsonfeed)] whose extension `_myvibes` carries
|
|
1322
|
+
what the host's widgets share (`kicker`, `live`, `featured`, `thumbnail`, `score`, `comments`, and at the feed level
|
|
1323
|
+
`source` and `fetched`), and `_<site>` a site's own data.
|
|
1324
|
+
|
|
1325
|
+
```webidl
|
|
1326
|
+
typedef object ContentFeed; // a content feed: its schema is Issue 11
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
To **normalize** a content feed, keep only those members, give every item an `id` (its `url` when it has none, dropping
|
|
1330
|
+
an item with neither), and write dates in [[RFC3339](#ref-rfc3339)] format. The host normalizes the feeds `fetchFeed`
|
|
1331
|
+
gives; UWA's `UWA.Content` helpers are UWA files' (11.1).
|
|
1332
|
+
|
|
1333
|
+
## 9. Built-in objects
|
|
1334
|
+
|
|
1335
|
+
SWA adds nothing to the objects of the platform. In an SWA widget's realm (its frame, or its own page: 10.2):
|
|
1336
|
+
|
|
1337
|
+
- a host **MUST NOT** add members to the prototypes of built-in objects (`HTMLElement`, `Element`, `Array`, `String`,
|
|
1338
|
+
`Function`…), nor define globals other than `widget` and `WidgetEvent`
|
|
1339
|
+
(`Widget`, `WidgetSettings`, `WidgetStorage` and `WidgetStorageArea` have no interface object: their objects are
|
|
1340
|
+
reached through `widget` alone), save names beginning with `__`, which a host **MAY** use for its own hooks and a
|
|
1341
|
+
widget **MUST NOT** use;
|
|
1342
|
+
- a host **MAY** wrap `fetch` and `window.open` in a framed widget's realm, to relay a request for one of the host's
|
|
1343
|
+
own addresses (8.1) and a sign-in window (7.13); otherwise they behave as the browser's;
|
|
1344
|
+
- a host **MUST NOT** replace a member the browser defines, whether it runs one runtime for several formats or not: an
|
|
1345
|
+
SWA widget calling `setHTML` gets the browser's [[HTML](#ref-html)], never UWA's (11.2, [Issue 13](#issue-13));
|
|
1346
|
+
- widget code **MUST NOT** rely on such members, and **SHOULD NOT** add any itself: it uses the DOM [[DOM](#ref-dom)] and
|
|
1347
|
+
ECMAScript's own (`textContent`, `classList`, `append`, `replaceChildren`, `style`, `Array.prototype.map`).
|
|
1348
|
+
|
|
1349
|
+
`widget.body` and the elements `widget.createElement` returns are ordinary `HTMLElement`s.
|
|
1350
|
+
|
|
1351
|
+
UWA's extensions of built-in objects, its globals (`$`, `$A`, `Class`, `Environment`, `Element(tag)`) and the rest of
|
|
1352
|
+
its `UWA` namespace remain for UWA files (11.2), in their realm only. A host running both formats with one runtime
|
|
1353
|
+
installs them by the file's format; an SWA widget's realm, its frame or its own page (10.2), is its own and never has
|
|
1354
|
+
them.
|
|
1355
|
+
|
|
1356
|
+
<div class="example">
|
|
1357
|
+
|
|
1358
|
+
**Example 5.** UWA's element extensions, and what an SWA widget writes instead.
|
|
1359
|
+
|
|
1360
|
+
| UWA 1.2 | SWA 1.0 |
|
|
1361
|
+
|---|---|
|
|
1362
|
+
| `el.setText(t)`, `el.setHTML(h)`, `el.empty()` | `el.textContent = t`, `el.innerHTML = h` (the widget's own fixed markup only, 7.3), `el.replaceChildren()` |
|
|
1363
|
+
| `el.addClassName(c)`, `el.hasClassName(c)` | `el.classList.add(c)`, `el.classList.contains(c)` |
|
|
1364
|
+
| `el.show()`, `el.hide()`, `el.toggle()` | `el.hidden = false`, `el.hidden = true`, `el.hidden = !el.hidden` |
|
|
1365
|
+
| `el.setStyle('color', 'red')` | `el.style.color = 'red'` |
|
|
1366
|
+
| `el.getElements('a')`, `el.getChildren()` | `el.querySelectorAll('a')`, `el.children` |
|
|
1367
|
+
| `el.addEvent('click', f)` | `el.addEventListener('click', f)` |
|
|
1368
|
+
| `el.inject(target)` | `target.append(el)` |
|
|
1369
|
+
| `$A(list)`, `'…'.stripTags()`, `JSON.encode(v)` | `Array.from(list)`, the text of a parsed document, `JSON.stringify(v)` |
|
|
1370
|
+
|
|
1371
|
+
</div>
|
|
1372
|
+
|
|
1373
|
+
## 10. Execution environments
|
|
1374
|
+
|
|
1375
|
+
### 10.1 Framed
|
|
1376
|
+
|
|
1377
|
+
A dashboard **MUST** run every widget in a frame of its own, sandboxed with an opaque origin. In it:
|
|
1378
|
+
|
|
1379
|
+
1. Connections are limited to `https` URLs by a Content Security Policy [[CSP](#ref-csp)]; requests to the
|
|
1380
|
+
host's addresses are relayed by the host, which answers only its public services and, for a trusted file, the account
|
|
1381
|
+
services of the file's declared service.
|
|
1382
|
+
2. The frame has no storage; everything a widget keeps goes through the host (section 7.8).
|
|
1383
|
+
3. Operations that cover or leave the page are activation-gated (section 6.7).
|
|
1384
|
+
4. The host accepts a message from a frame only from that frame's window, with that load's instance identifier, and
|
|
1385
|
+
checks each field's type and size. Functions never cross the frame: a callback stays in it and is called by message.
|
|
1386
|
+
5. A drag starting in the frame doesn't reach the page (`dragWidget` returns false).
|
|
1387
|
+
6. The browser's dialogs are off: `alert()` does nothing, `confirm()` answers false and `prompt()` null, at once. A
|
|
1388
|
+
widget **MUST NOT** use them, on its own page either (they work there, so a widget relying on them behaves
|
|
1389
|
+
differently framed): a question is asked in the widget's own box, its safe answer focused, Esc for it (14).
|
|
1390
|
+
|
|
1391
|
+
A widget **MUST** work framed. One that can't **MUST** say so in its box, and how to change it, rather than fail.
|
|
1392
|
+
|
|
1393
|
+
### 10.2 No inline mode
|
|
1394
|
+
|
|
1395
|
+
An SWA widget runs framed (10.1) or on its own page (10.3), always in a document and a realm of its own: its `id`s,
|
|
1396
|
+
its globals and its styles meet no other widget's and not the host's. A host **MUST NOT** run an SWA widget in the
|
|
1397
|
+
host's own page because the widget asks; `environment.inline` is `false`. How a host might run widgets of its own in
|
|
1398
|
+
its page, for its own reasons, is outside this specification, and a widget written to it makes no provision for it.
|
|
1399
|
+
UWA 1.2 files keep their `inline` metadata (section 11).
|
|
1400
|
+
|
|
1401
|
+
### 10.3 Standalone
|
|
1402
|
+
|
|
1403
|
+
Opened on its own, a widget file runs in the standalone host: its box, centred on the page, with a title bar.
|
|
1404
|
+
|
|
1405
|
+
- **The options menu.** The title bar's options button (▾) opens the widget's options menu, as a dashboard's:
|
|
1406
|
+
- its **Title**: a rename the page keeps; emptied, the widget's own;
|
|
1407
|
+
- its **Look**, when it has two: *Own* (its `chromeColor` and `background`) or *Page* (the page's bar and colors, the
|
|
1408
|
+
widget flattened under `html.uwa-neutral`, as on a dashboard);
|
|
1409
|
+
- its **Color**: the dashboard's palette, as `--module-color` and `--module-paper`;
|
|
1410
|
+
- its settings, applied as 6.5 says (addresses, numbers and `data-commit` fields on Enter or as the field is left;
|
|
1411
|
+
`livePreferences`), when it has 6 visible settings or fewer; else *Preferences…*, opening the form in the box with
|
|
1412
|
+
a confirming button;
|
|
1413
|
+
- the actions: **Refresh**, *Maximize*, *Mark all as read* and *Mark all as unread* (7.10).
|
|
1414
|
+
|
|
1415
|
+
`widget.openPreferences()` opens the menu.
|
|
1416
|
+
- **Width.** Maximized (not when it fills the window), the box has a width grip on each side: dragged, or moved with
|
|
1417
|
+
the arrow keys, they set its maximized width, which the host keeps for the page, and fire `resize`; a double-click on
|
|
1418
|
+
one, or Enter, gives it back the width its `maximize` metadata gives. Not maximized, the box has its own width.
|
|
1419
|
+
- **Maximized.** A double-click on the title bar (whose pointer says it can be clicked), or *Maximize*, maximizes the
|
|
1420
|
+
widget as a dashboard does (7.13: `canFullSize`, `fullSize`, `fullsize`, as its `maximize` metadata says; Esc
|
|
1421
|
+
restores it). Maximized in a column, the widget is told the room its content may grow into, so its lists show more
|
|
1422
|
+
whole items.
|
|
1423
|
+
- **The page's look.** It is drawn as the dashboard's Classic style draws one, its colors mixed from an **accent** the
|
|
1424
|
+
dots at the window's bottom pick (a footer under the widget when it's taller than the window; a maximized widget stops
|
|
1425
|
+
above it), light, dark or the system's by the switch beside them (dark: the widget's own dark look, by the root's
|
|
1426
|
+
`color-scheme`, 4.7), both kept for every widget the host shows on its own.
|
|
1427
|
+
- **Add to Startside.** Under the widget, a button opens the host's dashboard on its preview of the widget, by its
|
|
1428
|
+
address (`/add?url=<its address>`: trusted for the host's own files, else framed and untrusted); from disk, only for a
|
|
1429
|
+
file of the host's own widget folder, linked to the host's copy. There is no button when the file's `addButton`
|
|
1430
|
+
metadata is `false`, nor when the page runs in another page's frame (a chat's preview, a code playground, an
|
|
1431
|
+
article): its address there is rarely the file's own.
|
|
1432
|
+
- **Starting from its address.** The address's fragment sets how the page starts, for testing a widget:
|
|
1433
|
+
`#mode=dark` (or `light`, `auto`) and `#width=300` (the box's width in CSS pixels), joined by `&`. Neither is saved,
|
|
1434
|
+
the person's own switch takes over, and the fragment is never part of the address *Add to Startside* sends.
|
|
1435
|
+
- **In a frame.** In a frame shorter than it, the page scrolls.
|
|
1436
|
+
- **The host's page.** The page around the widget (its title bar, menu, footer and their elements' ids and classes) is
|
|
1437
|
+
the host's, not part of this specification, and may change: a widget **MUST NOT** style or script it, and styles
|
|
1438
|
+
only its own content.
|
|
1439
|
+
- **Data and state.** Read and unread work as on a dashboard (7.10): the read keys kept for the page, the unread count
|
|
1440
|
+
after the title. Its data requests go through the runtime's host's proxies. Its memory (7.8) lasts while the page is
|
|
1441
|
+
open, not across reloads; its settings and stored data do; its automatic refreshes keep a fixed interval.
|
|
1442
|
+
- **What differs.** The reader's operations open new tabs, videos their sites, and `addWidget` is absent.
|
|
1443
|
+
- **Without storage.** Where the browser refuses the page's storage, the widget still runs: with its declared defaults,
|
|
1444
|
+
its own width and title, nothing kept.
|
|
1445
|
+
|
|
1446
|
+
### 10.4 Trust
|
|
1447
|
+
|
|
1448
|
+
| | Trusted file | Untrusted file |
|
|
1449
|
+
|---|---|---|
|
|
1450
|
+
| Framed | yes | yes |
|
|
1451
|
+
| Account services | its declared service's, its chosen account's | no |
|
|
1452
|
+
| `addWidget` | yes | absent |
|
|
1453
|
+
| Everything else | yes | yes, checked by the host |
|
|
1454
|
+
|
|
1455
|
+
A trusted file's account services are bound (Issue 21, resolved): a host **MUST** relay a request to an account
|
|
1456
|
+
service's address, or open its sign-in window, only for the service the file declares (`accountService`, 4.5) and,
|
|
1457
|
+
once the widget has chosen an account (its `account` setting), only for that account: a request naming another, in its
|
|
1458
|
+
address or its body, is refused, and one naming none is for the chosen account (a host names it, so that a service
|
|
1459
|
+
taking the only account connected, or a default, never serves another); a file declaring no service reaches none. Anything else is refused before it reaches the service: the widget's
|
|
1460
|
+
`fetch` rejects with a `TypeError`, a sign-in window isn't opened. UWA files, which declare no service, keep UWA's
|
|
1461
|
+
access to every account service of the host (section 11).
|
|
1462
|
+
|
|
1463
|
+
**Networks** (Issue 22, resolved). The host's relays (`widget.fetch`, `fetchFeed`, a UWA file's `UWA.Data`, and its
|
|
1464
|
+
own addresses) **MUST** refuse local and private network addresses, redirects included. A widget's own requests
|
|
1465
|
+
(`fetch` from its frame, its pictures, media and scripts) go where the browser lets a page of its origin go: a host
|
|
1466
|
+
**MUST NOT** claim more for them. On a host served over `https` from a public address, browsers that enforce Private
|
|
1467
|
+
Network Access keep them off the person's local network; a host **MAY** narrow them further with its frame's policy
|
|
1468
|
+
(Issue 1).
|
|
1469
|
+
|
|
1470
|
+
## 11. Compatibility with UWA 1.2
|
|
1471
|
+
|
|
1472
|
+
A conforming host **MUST** also run UWA 1.2 widget files [[UWA](#ref-uwa)]: XHTML documents with a
|
|
1473
|
+
`widget:preferences` element and UWA's interface, which sections 7 and 8 extend. A UWA file **SHOULD** be named
|
|
1474
|
+
`<name>.uwa.xhtml`, with the key `<name>.uwa`; `<name>.xhtml`, with the key `<name>`, is accepted.
|
|
1475
|
+
|
|
1476
|
+
### 11.1 Files and preferences
|
|
1477
|
+
|
|
1478
|
+
UWA's preference types map to section 5.2's: `text`, `password`, `hidden`, `boolean`, `list` and `range`; the
|
|
1479
|
+
attributes `hint`, `when`, `commit`, `type="url"`, `type="number"` and `feed` on an option are the types and
|
|
1480
|
+
attributes of 5.2 and 5.3, the attributes without their `data-` prefix.
|
|
1481
|
+
|
|
1482
|
+
UWA files keep UWA's data access: the `UWA` object, `UWA.Data` (`request`, `getJson`, `getXml`, `getText`, and
|
|
1483
|
+
`getContentFeed` for a content feed), `UWA.Content`, `loadContent`, `keptContent` and `keepContent`, kept content
|
|
1484
|
+
being 7.9's (the same copies `fetchFeed` keeps), and `remember`, `recall`, `setStored` and `getStored`, synchronous,
|
|
1485
|
+
over the same data as `storage.memory` and `storage.local` (7.8); and `getValue`, `getInt`, `getBool`, `setValue` and
|
|
1486
|
+
`deleteValue`, string-valued, over the same settings as `widget.settings` (7.5). They keep UWA's feeds too: `UWA.Data.getFeed(url, callback)` and
|
|
1487
|
+
`request`'s `type: "feed"` give an RSS or Atom feed
|
|
1488
|
+
as UWA's feed object [[UWA](#ref-uwa)], its items with `image` and `author` besides UWA's fields; the host
|
|
1489
|
+
keeps the widget's last 4 feeds, given at once as the widget starts, unless its metadata `keepFeeds` is `false`.
|
|
1490
|
+
|
|
1491
|
+
A host **MAY** omit what UWA 1.2.4 had and SWA doesn't: `onUpdateTitle` (SWA has no `updatetitle` event), `onSearch`, `onResetSearch`, `onKeyboardAction`, `addStar`,
|
|
1492
|
+
`setTooltip`, `UWA.Controls.TabView`, `UWA.Data.Storage`, requests other than GET through the proxy, Flash, and
|
|
1493
|
+
Netvibes' hosted services. `openURL` opens the reader, not a window.
|
|
1494
|
+
|
|
1495
|
+
UWA's `onShowEdit(element)` is **deprecated**: it is not an SWA event, and an SWA widget **MUST NOT** rely on it. A host
|
|
1496
|
+
**MAY** still call it for a UWA file whose settings form it draws in the widget's box (a standalone host's
|
|
1497
|
+
*Preferences…*), with that form's element; a dashboard, which shows settings in its own menu, never calls it.
|
|
1498
|
+
|
|
1499
|
+
### 11.2 UWA's extensions of built-in objects
|
|
1500
|
+
|
|
1501
|
+
For UWA files, a host provides UWA's extensions of built-in objects [[UWA](#ref-uwa)]: on every `HTMLElement` of the
|
|
1502
|
+
widget's realm, the members below, each returning the element it was called on unless its type says otherwise, without
|
|
1503
|
+
replacing a member the browser already defines (but `setHTML`: [Issue 13](#issue-13)); `$(element)`, `$A(list)`,
|
|
1504
|
+
`Class.create()`, `_(text)` (the translation hook, returning *text*), `UWA.Utils` (`buildUrl`, `setCss`), `UWA.Json`
|
|
1505
|
+
(`encode`, `decode`, also as `JSON.encode` and `JSON.decode`), `UWA.Controls.Pager`; and UWA's `Array`, `String` and
|
|
1506
|
+
`Function` methods (`stripTags`, `truncate`, `bind`…).
|
|
1507
|
+
|
|
1508
|
+
```webidl
|
|
1509
|
+
interface mixin WidgetElement {
|
|
1510
|
+
HTMLElement setText(DOMString text);
|
|
1511
|
+
HTMLElement setHTML(DOMString html);
|
|
1512
|
+
HTMLElement setContent((DOMString or Node) content);
|
|
1513
|
+
HTMLElement addContent((DOMString or Node) content);
|
|
1514
|
+
HTMLElement appendText(DOMString text);
|
|
1515
|
+
HTMLElement empty();
|
|
1516
|
+
HTMLElement show();
|
|
1517
|
+
HTMLElement hide();
|
|
1518
|
+
HTMLElement toggle();
|
|
1519
|
+
HTMLElement addClassName(DOMString name);
|
|
1520
|
+
HTMLElement removeClassName(DOMString name);
|
|
1521
|
+
boolean hasClassName(DOMString name);
|
|
1522
|
+
HTMLElement setStyle((DOMString or object) property, optional DOMString value);
|
|
1523
|
+
HTMLElement setStyles(object styles);
|
|
1524
|
+
HTMLElement setOpacity(double value);
|
|
1525
|
+
object getDimensions(); // { width, height }
|
|
1526
|
+
Node? getParent();
|
|
1527
|
+
NodeList getChildren(); // childNodes, text and comments included
|
|
1528
|
+
Element? getElement(DOMString selector);
|
|
1529
|
+
sequence<Element> getElements(DOMString selector);
|
|
1530
|
+
HTMLElement inject(Element target, optional DOMString where);
|
|
1531
|
+
HTMLElement setAttributes(object attributes);
|
|
1532
|
+
HTMLElement addListener(DOMString type, Function listener);
|
|
1533
|
+
HTMLElement removeListener(DOMString type, Function listener);
|
|
1534
|
+
HTMLElement addEvent(DOMString type, Function listener);
|
|
1535
|
+
HTMLElement addEvents(object listeners);
|
|
1536
|
+
};
|
|
1537
|
+
HTMLElement includes WidgetElement; // in a UWA file's realm only (section 9)
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
`setHTML` inserts markup as given: widget code **MUST NOT** pass it markup fetched from elsewhere (section 12).
|
|
1541
|
+
|
|
1542
|
+
### 11.3 UWA's callbacks
|
|
1543
|
+
|
|
1544
|
+
A UWA file's `widget` also has UWA's callbacks [[UWA](#ref-uwa)]: for each event type of 7.6's table, a **callback
|
|
1545
|
+
attribute** of the name its last column gives (`onLoad`, `onRefresh`…), whose value is a function or null;
|
|
1546
|
+
`setCallback(name, callback)`, a second, **registered callback** for that name, one per name, replacing the previous
|
|
1547
|
+
one, `null` removing it; and `callback(name, argument)`, which fires the event of that name and returns undefined. For
|
|
1548
|
+
a name not in the table, `callback` calls the callback attribute and the registered callback of that name with
|
|
1549
|
+
*argument*, only if *name* begins with `on`; it calls no other member of `widget`.
|
|
1550
|
+
|
|
1551
|
+
For a UWA file, firing a widget event (7.6.2) runs one more step before the dispatch: for the callback attribute of the
|
|
1552
|
+
type's name, then its registered callback, each read as this step reaches it, if it is a function, call it with the
|
|
1553
|
+
event's `detail` and `widget` as `this`; for `load` and `refresh`, if it returns a promise, act as if `waitUntil` had
|
|
1554
|
+
been called with it, except that its rejection isn't reported, as in UWA; if it throws, report the exception and go on.
|
|
1555
|
+
A UWA file listens for an event type (7.6.2) also when that callback attribute or registered callback is a function.
|
|
1556
|
+
`readall`'s default action (7.10) is skipped when the file has an `onReadAll` callback, which marks its items itself,
|
|
1557
|
+
as in UWA.
|
|
1558
|
+
|
|
1559
|
+
## 12. Security Considerations
|
|
1560
|
+
|
|
1561
|
+
- **Isolation.** The sandboxed frame (10.1) is what lets a person add a widget written by anyone: it never runs in the
|
|
1562
|
+
page, never reads the page's storage or the person's accounts, and reaches the host only through relayed, checked
|
|
1563
|
+
operations. Hosts **MUST NOT** relax it for untrusted files.
|
|
1564
|
+
- **Markup.** Markup from a feed or an API **MUST NOT** be inserted as HTML: parse it inert (with `DOMParser`) and copy
|
|
1565
|
+
what is needed, or insert it as text.
|
|
1566
|
+
- **Proxies.** The host's proxies make requests on the widget's behalf: they **MUST** refuse local and private
|
|
1567
|
+
addresses, through redirects too, and the host's own.
|
|
1568
|
+
- **Activation.** Operations that cover the page (the reader, the video player, full screen) or leave it (sharing,
|
|
1569
|
+
sign-in windows) are activation-gated, so a widget can't take over the page by itself.
|
|
1570
|
+
- **Passwords.** A password setting never reaches a framed widget.
|
|
1571
|
+
- **Code.** Widget code **MUST NOT** evaluate fetched text as code.
|
|
1572
|
+
|
|
1573
|
+
## 13. Privacy Considerations
|
|
1574
|
+
|
|
1575
|
+
- A widget's settings, memory, stored data, kept content and read keys are kept by the host, as the host's privacy
|
|
1576
|
+
notice describes; a framed widget keeps nothing itself.
|
|
1577
|
+
- A shared link carries only settings marked `data-share`, never a password.
|
|
1578
|
+
- Framed requests come from an opaque origin; whether a site's cookies go with them is the browser's third-party
|
|
1579
|
+
cookie policy. A site asked directly (`fetch` from the frame) sees the person's network address; one asked through the
|
|
1580
|
+
host (`widget.fetch`, `fetchFeed`, `UWA.Data`) sees the host's, and the host sees the address asked.
|
|
1581
|
+
- A widget **SHOULD NOT** send the person's settings or account data to third parties beyond what its function needs,
|
|
1582
|
+
and its `description` **SHOULD** say what it connects to.
|
|
1583
|
+
- Kept content may include data from the person's accounts; a host **SHOULD** limit how long it keeps it and forget it
|
|
1584
|
+
when the account is disconnected.
|
|
1585
|
+
|
|
1586
|
+
## 14. Accessibility Considerations
|
|
1587
|
+
|
|
1588
|
+
Widgets **SHOULD** conform to WCAG 2.2 at level AA [[WCAG22](#ref-wcag22)] and follow the WAI-ARIA Authoring
|
|
1589
|
+
Practices [[ARIA-APG](#ref-aria-apg)] for each pattern they use: operable with the keyboard alone, with a visible
|
|
1590
|
+
focus; controls named and stating their state; text at 4.5:1 contrast (3:1 for large text and controls' edges) in light
|
|
1591
|
+
and dark; nothing conveyed by color alone; motion honouring `prefers-reduced-motion`; `button` and `a` elements rather
|
|
1592
|
+
than clickable generic elements. A widget's keyboard handling belongs to its own focus, never to the page's. An update
|
|
1593
|
+
keeps the keyboard focus where the person left it (7.3.1). A change the person needs to know of, which they didn't
|
|
1594
|
+
cause where their focus is (a result, a game won, an error, new items), is announced: a live region of the skeleton
|
|
1595
|
+
(`role="status"`, or `role="alert"` for an error; each implies its `aria-live`), present from the start, its text
|
|
1596
|
+
changed. Nothing is announced as the widget first draws (a "New game" at load), only what the person did or needs
|
|
1597
|
+
to know. A change of mode or focus is not announced (a "keyboard active" message at each focus repeats what the
|
|
1598
|
+
focus itself says): help for the keyboard is the control's description (`aria-describedby`), read when it's
|
|
1599
|
+
focused. A composite control (a board, a grid) is one stop in the Tab order, the arrow keys moving inside it (7.3.1).
|
|
1600
|
+
A single-key shortcut (N for a new game, a digit for a color) acts only while the widget's own element has the focus,
|
|
1601
|
+
never on the page's keys; one that throws away what the person did (a game in progress) asks first or can be undone.
|
|
1602
|
+
What a `canvas` shows that matters (a board's state, a score) is also in text: a status line, a label, a description.
|
|
1603
|
+
|
|
1604
|
+
---
|
|
1605
|
+
|
|
1606
|
+
## Appendix A. Examples
|
|
1607
|
+
|
|
1608
|
+
*This appendix is non-normative.*
|
|
1609
|
+
|
|
1610
|
+
**Example 4.** A blog's headlines, drawn in place (7.3.1): a skeleton with its states (loading, nothing posted, a
|
|
1611
|
+
failure) and a `template` row, filled with text; one listener on the list for every row; read and unread, the reader. A
|
|
1612
|
+
refresh asks for the feed again; within 5 minutes of the last request, the host's proxy may answer with what it has
|
|
1613
|
+
(8.4); a failed refresh keeps what's shown.
|
|
1614
|
+
|
|
1615
|
+
```html
|
|
1616
|
+
<!doctype html>
|
|
1617
|
+
<html>
|
|
1618
|
+
<head>
|
|
1619
|
+
<script src="https://startside.app/swa/1.0/runtime.js"></script>
|
|
1620
|
+
<title>My Blog</title>
|
|
1621
|
+
<meta name="description" content="My blog's latest posts." />
|
|
1622
|
+
<meta name="category" content="Blogs" />
|
|
1623
|
+
<meta name="autoRefresh" content="30" />
|
|
1624
|
+
<meta name="chromeColor" content="#3e454c" />
|
|
1625
|
+
<meta name="background" content="#ffffff" />
|
|
1626
|
+
<meta name="backgroundDark" content="#1c1c1e" />
|
|
1627
|
+
<meta name="feed" content="https://example.com/feed.xml" />
|
|
1628
|
+
<link rel="icon" href="myblog.svg" />
|
|
1629
|
+
<style>
|
|
1630
|
+
.blog { padding: 6px 10px; background: light-dark(#ffffff, #1c1c1e); }
|
|
1631
|
+
.blog .posts { list-style: none; margin: 0; padding: 0; }
|
|
1632
|
+
.blog [hidden] { display: none; }
|
|
1633
|
+
.blog .uwa-read a { opacity: 0.7; }
|
|
1634
|
+
</style>
|
|
1635
|
+
</head>
|
|
1636
|
+
<body>
|
|
1637
|
+
<form id="preferences" hidden>
|
|
1638
|
+
<label>Items <input type="range" name="count" min="1" max="20" value="5" /></label>
|
|
1639
|
+
</form>
|
|
1640
|
+
<div class="blog">
|
|
1641
|
+
<p class="state waiting">Loading…</p>
|
|
1642
|
+
<p class="state empty" hidden>Nothing posted yet.</p>
|
|
1643
|
+
<p class="state failed" role="alert" hidden>Could not load the blog.</p>
|
|
1644
|
+
<ul class="posts" hidden></ul>
|
|
1645
|
+
<template><li class="post"><a class="ext-link"></a></li></template>
|
|
1646
|
+
</div>
|
|
1647
|
+
<script>
|
|
1648
|
+
const MyBlog = { feed: 'https://example.com/feed.xml' };
|
|
1649
|
+
MyBlog.show = (state) => {
|
|
1650
|
+
for (const el of widget.body.querySelectorAll('.state')) el.hidden = !el.classList.contains(state);
|
|
1651
|
+
};
|
|
1652
|
+
MyBlog.draw = (feed) => {
|
|
1653
|
+
const list = widget.body.querySelector('.posts');
|
|
1654
|
+
const row = widget.body.querySelector('template').content.firstElementChild;
|
|
1655
|
+
const items = feed.items.slice(0, widget.settings.get('count'));
|
|
1656
|
+
list.replaceChildren(
|
|
1657
|
+
...items.map((item) => {
|
|
1658
|
+
const li = row.cloneNode(true);
|
|
1659
|
+
const a = li.querySelector('a');
|
|
1660
|
+
a.href = item.url;
|
|
1661
|
+
a.textContent = item.title || item.url;
|
|
1662
|
+
return li;
|
|
1663
|
+
}),
|
|
1664
|
+
);
|
|
1665
|
+
list.hidden = !items.length;
|
|
1666
|
+
MyBlog.show(items.length ? 'none' : 'empty');
|
|
1667
|
+
widget.setMaxValue('count', feed.items.length);
|
|
1668
|
+
};
|
|
1669
|
+
MyBlog.load = (e, fresh) =>
|
|
1670
|
+
widget.fetchFeed(MyBlog.feed, { signal: e.signal, fresh }).then(MyBlog.draw, (err) => {
|
|
1671
|
+
// A failed refresh keeps what's shown; with nothing shown, it says so.
|
|
1672
|
+
if (err.name !== 'AbortError' && !widget.body.querySelector('.post')) MyBlog.show('failed');
|
|
1673
|
+
});
|
|
1674
|
+
widget.addEventListener('load', (e) => {
|
|
1675
|
+
const list = widget.body.querySelector('.posts');
|
|
1676
|
+
list.addEventListener('click', (ev) => {
|
|
1677
|
+
const a = ev.target.closest('a');
|
|
1678
|
+
if (!a) return;
|
|
1679
|
+
ev.preventDefault();
|
|
1680
|
+
widget.openURL(a.href);
|
|
1681
|
+
});
|
|
1682
|
+
widget.readItems(list, '.post');
|
|
1683
|
+
e.waitUntil(MyBlog.load(e, false));
|
|
1684
|
+
});
|
|
1685
|
+
widget.addEventListener('refresh', (e) => e.waitUntil(MyBlog.load(e, true)));
|
|
1686
|
+
</script>
|
|
1687
|
+
</body>
|
|
1688
|
+
</html>
|
|
1689
|
+
```
|
|
1690
|
+
|
|
1691
|
+
**Example 6.** A game: a sliding puzzle, its board one Tab stop whose arrow keys slide a tile into the space (7.3.1),
|
|
1692
|
+
its nine tiles the skeleton's buttons relabeled at each move; a game in progress kept in a hidden setting (7.8), read
|
|
1693
|
+
defensively; the keyboard's help as the board's description, a win announced by a status line (section 14).
|
|
1694
|
+
|
|
1695
|
+
```html
|
|
1696
|
+
<!doctype html>
|
|
1697
|
+
<html lang="en">
|
|
1698
|
+
<head>
|
|
1699
|
+
<script src="https://startside.app/swa/1.0/runtime.js"></script>
|
|
1700
|
+
<title>8 Puzzle</title>
|
|
1701
|
+
<meta name="description" content="The 3 by 3 sliding number puzzle." />
|
|
1702
|
+
<meta name="category" content="Games" />
|
|
1703
|
+
<style>
|
|
1704
|
+
.puzzle { padding: 10px; }
|
|
1705
|
+
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 300px; aspect-ratio: 1; margin: 8px auto; }
|
|
1706
|
+
.board button {
|
|
1707
|
+
font: 700 28px system-ui, sans-serif;
|
|
1708
|
+
border: 0;
|
|
1709
|
+
border-radius: 6px;
|
|
1710
|
+
background: light-dark(#fffaf0, #3a4552);
|
|
1711
|
+
color: light-dark(#293543, #f2f4f6);
|
|
1712
|
+
}
|
|
1713
|
+
.board:focus-visible { outline: 3px solid #1877d2; outline-offset: 3px; }
|
|
1714
|
+
.board button.hole { visibility: hidden; }
|
|
1715
|
+
.help { font-size: 12px; text-align: center; margin: 0; }
|
|
1716
|
+
</style>
|
|
1717
|
+
</head>
|
|
1718
|
+
<body>
|
|
1719
|
+
<form id="preferences" hidden>
|
|
1720
|
+
<input type="hidden" name="game" value="" />
|
|
1721
|
+
</form>
|
|
1722
|
+
<div class="puzzle">
|
|
1723
|
+
<p>Moves: <strong class="moves">0</strong> <button type="button" class="new">New game</button></p>
|
|
1724
|
+
<!-- One Tab stop: the board; the arrows slide a tile, a click too. The tiles are out of the Tab order. -->
|
|
1725
|
+
<div class="board" role="group" tabindex="0" aria-label="Sliding puzzle" aria-describedby="puzzle-help">
|
|
1726
|
+
<button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button>
|
|
1727
|
+
<button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button>
|
|
1728
|
+
<button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button><button type="button" tabindex="-1"></button>
|
|
1729
|
+
</div>
|
|
1730
|
+
<p id="puzzle-help" class="help">Arrow keys slide a tile into the space.</p>
|
|
1731
|
+
<p class="status" role="status">Slide the tiles into number order.</p>
|
|
1732
|
+
</div>
|
|
1733
|
+
<script>
|
|
1734
|
+
const Puzzle = { order: [1, 2, 3, 4, 5, 6, 7, 8, 0] };
|
|
1735
|
+
// The places a tile at `i` can slide to.
|
|
1736
|
+
Puzzle.next = (i) => [i > 2 && i - 3, i < 6 && i + 3, i % 3 > 0 && i - 1, i % 3 < 2 && i + 1].filter((n) => n !== false);
|
|
1737
|
+
Puzzle.won = () => Puzzle.game.tiles.every((n, i) => n === Puzzle.order[i]);
|
|
1738
|
+
// Saved data outlives the code that wrote it: read defensively (7.8).
|
|
1739
|
+
Puzzle.saved = () => {
|
|
1740
|
+
try {
|
|
1741
|
+
const g = JSON.parse(widget.settings.get('game') || 'null');
|
|
1742
|
+
const ok = g && Array.isArray(g.tiles) && new Set(g.tiles).size === 9 && g.tiles.every((n) => Number.isInteger(n) && n >= 0 && n <= 8);
|
|
1743
|
+
return ok && Number.isInteger(g.moves) && g.moves >= 0 ? g : null;
|
|
1744
|
+
} catch {
|
|
1745
|
+
return null;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
// A game in progress is a setting, hidden (7.8): saved without a refresh.
|
|
1749
|
+
Puzzle.save = () => widget.settings.set('game', JSON.stringify(Puzzle.game));
|
|
1750
|
+
Puzzle.say = (text) => (widget.body.querySelector('.status').textContent = text);
|
|
1751
|
+
Puzzle.draw = () => {
|
|
1752
|
+
Puzzle.game.tiles.forEach((n, i) => {
|
|
1753
|
+
const b = Puzzle.buttons[i];
|
|
1754
|
+
b.textContent = n ? String(n) : '';
|
|
1755
|
+
b.classList.toggle('hole', !n);
|
|
1756
|
+
b.setAttribute('aria-label', n ? 'Tile ' + n : 'Empty');
|
|
1757
|
+
});
|
|
1758
|
+
widget.body.querySelector('.moves').textContent = String(Puzzle.game.moves);
|
|
1759
|
+
};
|
|
1760
|
+
Puzzle.move = (i) => {
|
|
1761
|
+
const tiles = Puzzle.game.tiles;
|
|
1762
|
+
const hole = tiles.indexOf(0);
|
|
1763
|
+
if (Puzzle.won() || !Puzzle.next(hole).includes(i)) return;
|
|
1764
|
+
[tiles[hole], tiles[i]] = [tiles[i], tiles[hole]];
|
|
1765
|
+
Puzzle.game.moves++;
|
|
1766
|
+
Puzzle.draw();
|
|
1767
|
+
Puzzle.save();
|
|
1768
|
+
if (Puzzle.won()) Puzzle.say('Solved in ' + Puzzle.game.moves + ' moves.');
|
|
1769
|
+
};
|
|
1770
|
+
Puzzle.newGame = () => {
|
|
1771
|
+
const tiles = Puzzle.order.slice();
|
|
1772
|
+
// Legal moves from the solved board: always solvable.
|
|
1773
|
+
for (let k = 0; k < 200; k++) {
|
|
1774
|
+
const hole = tiles.indexOf(0);
|
|
1775
|
+
const next = Puzzle.next(hole);
|
|
1776
|
+
const i = next[Math.floor(Math.random() * next.length)];
|
|
1777
|
+
[tiles[hole], tiles[i]] = [tiles[i], tiles[hole]];
|
|
1778
|
+
}
|
|
1779
|
+
Puzzle.game = { tiles, moves: 0 };
|
|
1780
|
+
if (Puzzle.won()) return Puzzle.newGame();
|
|
1781
|
+
Puzzle.draw();
|
|
1782
|
+
Puzzle.save();
|
|
1783
|
+
Puzzle.say('Slide the tiles into number order.');
|
|
1784
|
+
};
|
|
1785
|
+
// Wired once, on the first load; a refresh only draws again what's saved.
|
|
1786
|
+
widget.addEventListener('load', () => {
|
|
1787
|
+
Puzzle.buttons = [...widget.body.querySelectorAll('.board button')];
|
|
1788
|
+
const board = widget.body.querySelector('.board');
|
|
1789
|
+
board.addEventListener('click', (e) => {
|
|
1790
|
+
const b = e.target.closest('button');
|
|
1791
|
+
if (b) Puzzle.move(Puzzle.buttons.indexOf(b));
|
|
1792
|
+
// The focus stays on the board, the one Tab stop, not on a tile.
|
|
1793
|
+
board.focus();
|
|
1794
|
+
});
|
|
1795
|
+
// An arrow slides the tile on that side of the space towards it: ArrowUp moves the tile below the space up.
|
|
1796
|
+
const from = { ArrowUp: 3, ArrowDown: -3, ArrowLeft: 1, ArrowRight: -1 };
|
|
1797
|
+
board.addEventListener('keydown', (e) => {
|
|
1798
|
+
if (!(e.key in from)) return;
|
|
1799
|
+
e.preventDefault();
|
|
1800
|
+
const hole = Puzzle.game.tiles.indexOf(0);
|
|
1801
|
+
const i = hole + from[e.key];
|
|
1802
|
+
if (Puzzle.next(hole).includes(i)) Puzzle.move(i);
|
|
1803
|
+
});
|
|
1804
|
+
widget.body.querySelector('.new').addEventListener('click', Puzzle.newGame);
|
|
1805
|
+
Puzzle.game = Puzzle.saved();
|
|
1806
|
+
if (Puzzle.game) Puzzle.draw();
|
|
1807
|
+
else Puzzle.newGame();
|
|
1808
|
+
});
|
|
1809
|
+
widget.addEventListener('refresh', () => {
|
|
1810
|
+
Puzzle.game = Puzzle.saved() || Puzzle.game;
|
|
1811
|
+
Puzzle.draw();
|
|
1812
|
+
});
|
|
1813
|
+
</script>
|
|
1814
|
+
</body>
|
|
1815
|
+
</html>
|
|
1816
|
+
```
|
|
1817
|
+
|
|
1818
|
+
**Example 7.** A small application: a to-do list kept with the widget (a hidden setting, 7.8), its rows from a
|
|
1819
|
+
`template`, filled with text (what's typed is never markup), one listener on the list for every row; the browser's own
|
|
1820
|
+
controls for the keyboard (a form submitted by Enter, checkboxes); the focus moved to the next row when one is removed,
|
|
1821
|
+
and each change announced.
|
|
1822
|
+
|
|
1823
|
+
```html
|
|
1824
|
+
<!doctype html>
|
|
1825
|
+
<html lang="en">
|
|
1826
|
+
<head>
|
|
1827
|
+
<script src="https://startside.app/swa/1.0/runtime.js"></script>
|
|
1828
|
+
<title>To Do</title>
|
|
1829
|
+
<meta name="description" content="A short list of things to do." />
|
|
1830
|
+
<meta name="category" content="Tools" />
|
|
1831
|
+
<style>
|
|
1832
|
+
.todo { padding: 8px 10px; }
|
|
1833
|
+
.todo form { display: flex; gap: 6px; }
|
|
1834
|
+
.todo form input { flex: 1; min-width: 0; font: inherit; padding: 4px 6px; }
|
|
1835
|
+
.todo ul { list-style: none; margin: 8px 0 0; padding: 0; }
|
|
1836
|
+
.todo ul[hidden], .todo .empty[hidden] { display: none; }
|
|
1837
|
+
.todo li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
|
|
1838
|
+
.todo li label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
1839
|
+
.todo li.done label { text-decoration: line-through; opacity: 0.7; }
|
|
1840
|
+
.todo .remove { border: 0; background: none; font: inherit; cursor: pointer; padding: 2px 6px; }
|
|
1841
|
+
.todo .empty { margin: 8px 0 0; color: var(--muted, #6b6b6b); }
|
|
1842
|
+
.todo .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
1843
|
+
</style>
|
|
1844
|
+
</head>
|
|
1845
|
+
<body>
|
|
1846
|
+
<form id="preferences" hidden>
|
|
1847
|
+
<input type="hidden" name="items" value="[]" />
|
|
1848
|
+
</form>
|
|
1849
|
+
<div class="todo">
|
|
1850
|
+
<form class="add">
|
|
1851
|
+
<label class="visually-hidden">New item <input type="text" name="text" maxlength="200" autocomplete="off" required /></label>
|
|
1852
|
+
<button type="submit">Add</button>
|
|
1853
|
+
</form>
|
|
1854
|
+
<ul hidden></ul>
|
|
1855
|
+
<p class="empty">Nothing to do.</p>
|
|
1856
|
+
<template>
|
|
1857
|
+
<li><label><input type="checkbox" /> <span class="text"></span></label><button type="button" class="remove">×</button></li>
|
|
1858
|
+
</template>
|
|
1859
|
+
<p class="visually-hidden" role="status"></p>
|
|
1860
|
+
</div>
|
|
1861
|
+
<script>
|
|
1862
|
+
const Todo = {};
|
|
1863
|
+
// The list is the widget's own, saved with it: a setting, hidden (7.8). Read defensively: saved data outlives code.
|
|
1864
|
+
Todo.read = () => {
|
|
1865
|
+
try {
|
|
1866
|
+
const v = JSON.parse(widget.settings.get('items') || '[]');
|
|
1867
|
+
return Array.isArray(v) ? v.filter((x) => x && typeof x.text === 'string').map((x) => ({ text: x.text.slice(0, 200), done: x.done === true })) : [];
|
|
1868
|
+
} catch {
|
|
1869
|
+
return [];
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
Todo.save = () => widget.settings.set('items', JSON.stringify(Todo.items));
|
|
1873
|
+
Todo.say = (text) => (widget.body.querySelector('[role="status"]').textContent = text);
|
|
1874
|
+
// Drawn from the template, each row's text by textContent; the rows replaced, the form and the focus on it kept.
|
|
1875
|
+
Todo.draw = () => {
|
|
1876
|
+
const list = widget.body.querySelector('ul');
|
|
1877
|
+
const row = widget.body.querySelector('template').content.firstElementChild;
|
|
1878
|
+
list.replaceChildren(
|
|
1879
|
+
...Todo.items.map((item, i) => {
|
|
1880
|
+
const li = row.cloneNode(true);
|
|
1881
|
+
li.dataset.index = String(i);
|
|
1882
|
+
li.classList.toggle('done', item.done);
|
|
1883
|
+
li.querySelector('.text').textContent = item.text;
|
|
1884
|
+
li.querySelector('input').checked = item.done;
|
|
1885
|
+
li.querySelector('.remove').setAttribute('aria-label', 'Remove ' + item.text);
|
|
1886
|
+
return li;
|
|
1887
|
+
}),
|
|
1888
|
+
);
|
|
1889
|
+
list.hidden = !Todo.items.length;
|
|
1890
|
+
widget.body.querySelector('.empty').hidden = !!Todo.items.length;
|
|
1891
|
+
};
|
|
1892
|
+
// Wired once, on the first load: one listener on the list for every row's checkbox and button.
|
|
1893
|
+
widget.addEventListener('load', () => {
|
|
1894
|
+
Todo.items = Todo.read();
|
|
1895
|
+
const form = widget.body.querySelector('form.add');
|
|
1896
|
+
const field = form.querySelector('input');
|
|
1897
|
+
form.addEventListener('submit', (e) => {
|
|
1898
|
+
e.preventDefault();
|
|
1899
|
+
const text = field.value.trim();
|
|
1900
|
+
if (!text) return;
|
|
1901
|
+
Todo.items.push({ text, done: false });
|
|
1902
|
+
Todo.save();
|
|
1903
|
+
Todo.draw();
|
|
1904
|
+
field.value = '';
|
|
1905
|
+
Todo.say('Added: ' + text);
|
|
1906
|
+
});
|
|
1907
|
+
const list = widget.body.querySelector('ul');
|
|
1908
|
+
list.addEventListener('change', (e) => {
|
|
1909
|
+
const li = e.target.closest('li');
|
|
1910
|
+
if (!li) return;
|
|
1911
|
+
const item = Todo.items[Number(li.dataset.index)];
|
|
1912
|
+
item.done = e.target.checked;
|
|
1913
|
+
li.classList.toggle('done', item.done);
|
|
1914
|
+
Todo.save();
|
|
1915
|
+
});
|
|
1916
|
+
list.addEventListener('click', (e) => {
|
|
1917
|
+
const button = e.target.closest('.remove');
|
|
1918
|
+
if (!button) return;
|
|
1919
|
+
const i = Number(button.closest('li').dataset.index);
|
|
1920
|
+
const [gone] = Todo.items.splice(i, 1);
|
|
1921
|
+
Todo.save();
|
|
1922
|
+
Todo.draw();
|
|
1923
|
+
// The focus goes to the next row's button, else the previous one's, else the field: never lost.
|
|
1924
|
+
const buttons = list.querySelectorAll('.remove');
|
|
1925
|
+
(buttons[i] || buttons[i - 1] || field).focus();
|
|
1926
|
+
Todo.say('Removed: ' + gone.text);
|
|
1927
|
+
});
|
|
1928
|
+
Todo.draw();
|
|
1929
|
+
});
|
|
1930
|
+
widget.addEventListener('refresh', () => {
|
|
1931
|
+
Todo.items = Todo.read();
|
|
1932
|
+
Todo.draw();
|
|
1933
|
+
});
|
|
1934
|
+
</script>
|
|
1935
|
+
</body>
|
|
1936
|
+
</html>
|
|
1937
|
+
```
|
|
1938
|
+
|
|
1939
|
+
## Appendix B. Changes from UWA 1.2.4
|
|
1940
|
+
|
|
1941
|
+
*This appendix is non-normative.*
|
|
1942
|
+
|
|
1943
|
+
| | UWA 1.2.4 | SWA 1.0 |
|
|
1944
|
+
|---|---|---|
|
|
1945
|
+
| File | XHTML, well-formed XML, a namespace | HTML, `<name>.swa.html` |
|
|
1946
|
+
| Settings | `widget:preferences` (XML) | the settings form (HTML) |
|
|
1947
|
+
| Setting types | text, password, hidden, boolean, list, range | the same, and url, number, text areas |
|
|
1948
|
+
| Runtime | two tags from netvibes.com | one script, `/swa/1.0/runtime.js` |
|
|
1949
|
+
| Rendering | inline or framed, by platform | framed and sandboxed, or on its own page; no inline mode |
|
|
1950
|
+
| `openURL` | a new window | the host's reader |
|
|
1951
|
+
| Storage | the widget's data; client storage engines | settings, memory, stored data; never the frame's |
|
|
1952
|
+
| Requests | GET and POST through proxies, by callback | `widget.fetch`, a promise of a `Response`, GET through the host; the browser's `fetch` to `https` |
|
|
1953
|
+
| Events | callbacks assigned as properties, one per name (and `setCallback`) | `EventTarget` only: `addEventListener`, any number of listeners, `waitUntil`; no callbacks |
|
|
1954
|
+
| Feeds | UWA's feed object (`getFeed`) | `widget.fetchFeed`, a promise of a JSON Feed 1.1, kept by the host; UWA's stay with UWA files |
|
|
1955
|
+
| Added | | the reader, read state, grips, kept content, sound, video, pictures, sharing, adding widgets, maximizing, accounts, colors and icon at run time, declared feeds, dark looks |
|
|
1956
|
+
| Built-in objects | element, Array, String and Function extensions | none: the DOM's and ECMAScript's own (UWA's kept for UWA files) |
|
|
1957
|
+
| Removed | | search events, keyboard action, stars, TabView, client storage engines, POST through the proxy, Flash, platform compilers |
|
|
1958
|
+
|
|
1959
|
+
## Appendix C. Implementation status and features at risk
|
|
1960
|
+
|
|
1961
|
+
*This appendix is non-normative.* Startside implements this specification (November 3, 2026: keys for `.swa.html` and `.uwa.xhtml` files, `callback` limited to `on` names, the events of 7.6 and the activation check of 6.7 added; November 4: UWA's API, globals and extensions of built-in objects in UWA files' realms only, section 9, events only, `widget.fetch` and `widget.fetchFeed`, then `widget` with this interface's members only, its readonly attributes read-only, checked against the types of Appendix F), except:
|
|
1962
|
+
|
|
1963
|
+
| Feature | Status |
|
|
1964
|
+
|---|---|
|
|
1965
|
+
| `Widget` as an `EventTarget` (7.6) | listeners, `once`, `capture`, `signal`, `WidgetEvent`, `waitUntil` and a cancelable `readall` implemented; `widget` is an `EventTarget` (`widget instanceof EventTarget`), delegating to one of its own, so an event's `target` is that object, not `widget`; there is no `Widget` interface object |
|
|
1966
|
+
| `apiVersion` `1.0` | read as any metadata |
|
|
1967
|
+
| Readonly attributes and `FrozenArray` (7.1) | accessors without a setter, or non-writable properties, on `widget` itself (not on a `Widget` prototype); `preferences` a frozen array of frozen copies, made again when the declared settings change, so not the same array across such a change |
|
|
1968
|
+
| Starting on its own page (6.6, 10.3) | the widget code runs as the page reads it, before `widget.body` is set: a widget finds its parts in `load` (7.3.1), where every environment has it |
|
|
1969
|
+
| 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 |
|
|
1970
|
+
|
|
1971
|
+
The runtime is served at `https://startside.app/swa/1.0/runtime.js` (one minified script, its styles in it, with none of
|
|
1972
|
+
UWA's API, globals or extensions of built-in objects: it runs SWA files only); a Startside
|
|
1973
|
+
page skips it, and its catalogue lists the files that load it. The same runtime and types make the npm package
|
|
1974
|
+
`@startside/swa` (1.0.0 published November 8, 2026; 1.0.1 adds this specification, the quickstart and the guide for
|
|
1975
|
+
agents in Markdown, and the command `validate` and `inline`: Appendix F), served by jsDelivr and unpkg (4.3). jsDelivr keeps a
|
|
1976
|
+
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
|
|
1977
|
+
`@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 52 UWA 1.2 files and 29 RWA
|
|
1978
|
+
files; Appendix A's first example is an SWA one.
|
|
1979
|
+
|
|
1980
|
+
## Appendix D. IDL Index
|
|
1981
|
+
|
|
1982
|
+
*This appendix is non-normative.* The interfaces defined here: `Widget` (7.1), `WidgetEvent` (7.6.1); the dictionaries `WidgetEnvironment`,
|
|
1983
|
+
`WidgetSetting`, `WidgetSettingOption` (7.2), `ChromeColorOptions` (7.4), `CountGripOptions`, `HeightGripOptions` (7.7),
|
|
1984
|
+
`ReadItemsOptions` (7.10), `ReaderItem`, `OpenItemsOptions` (7.11),
|
|
1985
|
+
`PlayAudioOptions`, `AudioState`, `AudioControls`, `AudioInfo`, `VideoSpec`, `VideoState`, `PhotoSpec` (7.12),
|
|
1986
|
+
`ShareData`, `AddWidgetSpec` (7.13), `WidgetEventInit` (7.6.1), `FetchFeedOptions` (8.2); the callback `ReadKey` (7.10); the typedef `ContentFeed` (8.5); the mixin `WidgetElement` (11.2, for UWA files).
|
|
1987
|
+
|
|
1988
|
+
## Appendix E. Open issues
|
|
1989
|
+
|
|
1990
|
+
*This appendix is non-normative.* Questions this draft leaves open, most raised by a review of the 3 November 2026
|
|
1991
|
+
draft. Each is to be resolved before the specification is considered complete.
|
|
1992
|
+
|
|
1993
|
+
<a id="issue-1"></a>**Issue 1. The sandbox and Content Security Policy profile.** Section 10.1 names the sandbox, the opaque origin and `connect-src https:`, but not the full profile: the `sandbox` tokens, the policy for scripts, images, media, frames, forms and navigation, the referrer policy. A second host needs them to give the same isolation. Distinguish what is prevented (a request) from what is only hidden (its response).
|
|
1994
|
+
|
|
1995
|
+
<a id="issue-2"></a>**Issue 2. Capabilities and the message protocol.** Section 6.7 now tells a focus given from a focus taken by what the host sees (the pointer over the frame, a Tab, its own clicks and keys), which leaves a frame focusing itself while the pointer rests over it and the person types on the host's page, and refuses a tap within 5 seconds of a tap on the page. Only the browser knows where an activation came from: bind activation-gated requests to it if the platform comes to expose it to an embedder, or to a host-owned confirmation for the operations that warrant one (adding a widget), with expiry and consumption. The host checks a message's window, instance and fields (10.1), which says who sent it, not what it may do. Define the capabilities a frame holds (its file, its trust, its account, its services), how each request is authorized, how stale messages are rejected, and the messages between frame and host: events, their acknowledgement, the end of a load (7.6.3), the runtime authenticating the host's messages.
|
|
1996
|
+
|
|
1997
|
+
<a id="issue-3"></a>**Issue 3. Core and optional members.** Section 2 lets a host implement part of section 7, and 7.14 says only `addWidget` may be absent. Define a mandatory core (content, settings, events, data) and named optional capabilities, each with its presence test and fallback.
|
|
1998
|
+
|
|
1999
|
+
<a id="issue-4"></a>**Issue 4. The load state machine.** Section 6.6 ends a load on `setBody`, an error, its promises, a 20-second limit, and requests in flight. Define one state machine: a load's generation, the precedence of its endings, whether drawing kept content ends it, whether `loadcomplete` follows dispatch or completion, and what a refresh during a load does.
|
|
2000
|
+
|
|
2001
|
+
<a id="issue-5"></a>**Issue 5. Asynchronous errors.** Define how rejected promises, errors in `fetch` and `draw` callbacks and in periodicals are reported, their effect on the load and on what is shown, and whether a failing script stops the scripts after it and the `load` event. Error messages are shown as text.
|
|
2002
|
+
|
|
2003
|
+
<a id="issue-6"></a>**Issue 6. Scripts.** Define module scripts, `async` and `defer`, top-level `await`, a library that fails to load, the base URL, event-handler attributes in the initial content, and how widget code is scoped inline, where several widgets share a page.
|
|
2004
|
+
|
|
2005
|
+
<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.
|
|
2006
|
+
|
|
2007
|
+
<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.
|
|
2008
|
+
|
|
2009
|
+
<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.
|
|
2010
|
+
|
|
2011
|
+
<a id="issue-10"></a>**Issue 10. `widget.fetch`'s and `fetchFeed`'s contracts.** Define which `RequestInit` members are honoured or refused, the status and `statusText` of a `Response` for an HTTP error the proxy reports, the bounds of the retries after a failure, binary bodies and response headers (not relayed in this version), and `fetchFeed`'s refresh behind a stale copy (once per feed, its failure silent).
|
|
2012
|
+
|
|
2013
|
+
<a id="issue-11"></a>**Issue 11. The content feed's schema.** Give the feed and item schemas: the JSON Feed members kept, the types and meaning of `_myvibes`' members and of `_<site>`, and what normalization does with missing fields, malformed dates and duplicate ids. Then define `ContentFeed` in IDL.
|
|
2014
|
+
|
|
2015
|
+
<a id="issue-12"></a>**Issue 12. Kept content and stored data.** Define results of an older `fetchFeed` arriving after a newer one, eviction, one freshness boundary (5 minutes, inclusive or not); and for memory and stored data, the storage identity (what "the same file" is), JSON serialization, quotas, failures, deletion.
|
|
2016
|
+
|
|
2017
|
+
<a id="issue-13"></a>**Issue 13. `setHTML` and the HTML Sanitizer API.** UWA's `setHTML(html)` (11.2) inserts markup as given; browsers now define `Element.prototype.setHTML(html, options)`, which sanitizes it. UWA files keep UWA's, which replaces the browser's in their realm. Decide whether a UWA file's `setHTML` should become the browser's, sanitizing, as UWA widgets never pass it fetched markup by design. In an SWA widget's realm UWA's must never replace the browser's (section 9): a runtime shared by both formats installs it only for UWA files.
|
|
2018
|
+
|
|
2019
|
+
<a id="issue-14"></a>**Issue 14. Members' algorithms and states.** Many members are described, not specified: the media states' initial values, the reader's index bounds, the grips' geometry, read items' marking, `setSearchResultCount`. Give each an algorithm or a state table, closed value sets as enums, and say which state fields are always present. Add a table of the activation-gated operations (`openPhoto`, `openFull`, `pauseAudio`?), and say whether `setMaxValue` fires `updatepreferences`.
|
|
2020
|
+
|
|
2021
|
+
<a id="issue-15"></a>**Issue 15. Standalone security.** A file opened on its own runs with its own origin, or from disk: the frame's protections don't apply. State the standalone host's boundary, or run widget code in a sandboxed frame there too; and its passwords, accounts, activation and storage.
|
|
2022
|
+
|
|
2023
|
+
<a id="issue-16"></a>**Issue 16. What the host draws from widgets.** Titles, reader items, photo credits, audio artwork and other strings from widgets enter the host's own interface. Define which are text and which are markup, the markup and URL schemes allowed, how the reader frames pages, and that `frameable` never authorizes anything.
|
|
2024
|
+
|
|
2025
|
+
<a id="issue-17"></a>**Issue 17. Account data.** Make kept content and memory partitioned by account, removed or unreachable when an account is unlinked or changed; define who sees the page's audio state (its URL) and what a shared link may carry, on export and import.
|
|
2026
|
+
|
|
2027
|
+
<a id="issue-18"></a>**Issue 18. The host's accessibility.** Section 14 asks it of widgets; the host draws their settings, grips, counts, reader and windows. Define its duties: keyboard and non-drag alternatives (the grips), focus in and out of windows, names for frames, announcements, keeping the focus through a refresh.
|
|
2028
|
+
|
|
2029
|
+
<a id="issue-19"></a>**Issue 19. Inline styles.** *Resolved* (10.2): SWA has no inline mode; a widget's styles are its document's.
|
|
2030
|
+
|
|
2031
|
+
<a id="issue-20"></a>**Issue 20. Rebuilds, timers and overlapping refreshes.** Define a rebuild's teardown, a dashboard tab against a browser tab, a refresh interval of 0, two periodicals of one name, a refresh during a load, and refreshes while the page is hidden.
|
|
2032
|
+
|
|
2033
|
+
<a id="issue-21"></a>**Issue 21. Account services by declaration.** *Resolved* (10.4): bound to the declared service and the chosen account, for requests (an account named in the address or the body, or none: the chosen one) and sign-in windows; UWA files keep their access (a UWA compatibility profile, Issue 24, to say so).
|
|
2034
|
+
|
|
2035
|
+
<a id="issue-22"></a>**Issue 22. Direct requests and private networks.** *Resolved* (10.4, Networks): the relays refuse local and private addresses; a widget's own requests are the browser's to bound, and a host claims no more. Narrowing them by the frame's policy (images, media, scripts) is Issue 1's.
|
|
2036
|
+
|
|
2037
|
+
<a id="issue-23"></a>**Issue 23. Resource budgets.** A sandbox isolates data, not time or memory: a widget looping, allocating without end, or flooding the host with messages or requests slows the page. Define the host's budgets (messages and requests a second, stored data's size, memory) and what it does past them; stronger isolation (a process per widget) is a separate capability.
|
|
2038
|
+
|
|
2039
|
+
<a id="issue-24"></a>**Issue 24. A UWA compatibility profile.** Section 11 requires running UWA 1.2 files "with UWA's interface", and lists what a host may omit; the historical document (UWA 1.2.4) and Startside's runtime differ in more (UWA Appendix C, D). Define the profile a host implements for UWA files: required members, deviations, and which of the two documents prevails.
|
|
2040
|
+
|
|
2041
|
+
<a id="issue-25"></a>**Issue 25. Conversions and conformance vectors.** Section 2 asks Web IDL's argument conversions of a host implementing the interface in script; Startside's are written by hand (`setMaxValue` floors a number, `long` would convert it). Publish conversion vectors (missing arguments, null, infinities, out-of-range integers) and a host test suite that a second host can run, apart from a document checker, which would say what it covers and that "no finding" isn't "conforming".
|
|
2042
|
+
|
|
2043
|
+
<a id="issue-26"></a>**Issue 26. Handles a widget gets back.** `countGrip`, `heightGrip` and `readItems` return `undefined` in the IDL; Startside's return objects (`readItems(…).paint()`, `.stop()`) that RWA's components use. Define them, or keep them a host's private API.
|
|
2044
|
+
|
|
2045
|
+
<a id="issue-27"></a>**Issue 27. Freshness and cancellation, end to end.** `fetchFeed`'s `fresh` skips the widget's kept copy; the person's refresh also asks the host's proxy to skip its cache, which then answers a copy under 15 seconds old; aborting a request settles the widget's promise but doesn't stop the host's work. Define each intent (the widget's copy, the proxy's cache, the upstream request), how a request carries it, and cancellation through the relay.
|
|
2046
|
+
|
|
2047
|
+
<a id="issue-28"></a>**Issue 28. A widget file's identity.** A widget is known by its file name: a rename needs the host to migrate saved widgets. Consider a stable identifier in the file (`<meta name="id">`), with `version` and `author`.
|
|
2048
|
+
|
|
2049
|
+
<a id="issue-29"></a>**Issue 29. Widgets sharing a realm.** *Resolved* (10.2): SWA has no inline mode, so an SWA widget's realm is its own (section 9).
|
|
2050
|
+
|
|
2051
|
+
<a id="issue-30"></a>**Issue 30. The room a widget has.** A widget's height is its content's (7.3.2). Define whether a host tells a widget the room it has (a window shorter than the widget, a host that frames it at a fixed height: `widget.layout` or a `resize` event's `detail` with the width and the height available), and whether a widget may ask for more.
|
|
2052
|
+
|
|
2053
|
+
---
|
|
2054
|
+
|
|
2055
|
+
## Appendix F. Tools for authors
|
|
2056
|
+
|
|
2057
|
+
*This appendix is non-normative.*
|
|
2058
|
+
|
|
2059
|
+
- **This specification, published.** `https://startside.app/swa/1.0/`, and as Markdown, `spec.md` beside it; *SWA in
|
|
2060
|
+
60 lines* at `quickstart.html` (`quickstart.md`); for an agent, `agents.md`, short enough to read whole: the
|
|
2061
|
+
quickstart, these tools, the types and an index of this specification's sections.
|
|
2062
|
+
- **Types.** SWA 1.0's TypeScript types are served beside the runtime, at `https://startside.app/swa/1.0/swa.d.ts`:
|
|
2063
|
+
saved next to a widget's scripts, with `/// <reference path="swa.d.ts" />` (or a `jsconfig.json` naming it),
|
|
2064
|
+
`widget` is typed in an editor, its events with their `detail`, and what the host freezes read-only. The npm package
|
|
2065
|
+
`@startside/swa` carries them too: installed, `"types": ["@startside/swa"]` in a `tsconfig.json` or `jsconfig.json`'s
|
|
2066
|
+
`compilerOptions`.
|
|
2067
|
+
- **The npm package `@startside/swa`.** The runtime (`swa/1.0/runtime.js`, the text startside.app serves) and the types
|
|
2068
|
+
(`swa/1.0/swa.d.ts`), under the MIT licence; and, since 1.0.1, this specification, the quickstart and the guide for
|
|
2069
|
+
agents as published here (`swa/1.0/spec.md`, `quickstart.md`, `agents.md`), under CC BY 4.0, as they were at the
|
|
2070
|
+
package's release: for an author or an agent that can reach npm or a CDN but not this site
|
|
2071
|
+
(`https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/agents.md`). Served by jsDelivr and unpkg (4.3), installed
|
|
2072
|
+
with `npm install @startside/swa`. Since 1.0.1 too, a command, for Node 20 or later, with nothing else to install:
|
|
2073
|
+
`validate` and `inline`, below.
|
|
2074
|
+
- **Checking a file.** `npx @startside/swa validate my-widget.swa.html` reads a widget file without running it, with no
|
|
2075
|
+
network: the file's name and document, its runtime tag, metadata and settings form, and its scripts against this
|
|
2076
|
+
API, UWA's members and globals named with what replaces them. Each finding is `file:line:col: error|warning:
|
|
2077
|
+
message`, citing its section; `--json` gives them as a list of `{ file, line, col, level, message }`. It exits 1 on
|
|
2078
|
+
an error. Run it after each edit: a file it passes can still fail as it runs, which only trying it shows.
|
|
2079
|
+
- **Trying a widget.** A widget file opened in a browser, from disk or any server, runs on its own page with the
|
|
2080
|
+
runtime its head loads (4.3): its options menu (▾) shows its title, color and settings, applied as they change, and
|
|
2081
|
+
its `fetch` and `fetchFeed` go through Startside's proxies, which answer any origin. Errors show in the widget and
|
|
2082
|
+
in the browser's console. `widget.html#mode=dark&width=300` opens it dark and 300 pixels wide (10.3), for a test or
|
|
2083
|
+
a screenshot, rather than reaching into the page's own menu and switches, which may change.
|
|
2084
|
+
- **A copy with the runtime inlined** (4.3), for a place that loads no script from another site: the file with its
|
|
2085
|
+
runtime tag replaced by `<script data-runtime="swa/1.0">` holding the text of `https://startside.app/swa/1.0/runtime.js`,
|
|
2086
|
+
fetched as the copy is made; nothing else changed. Make it again after the runtime changes, and keep the file that
|
|
2087
|
+
loads the runtime by its address as the widget's own. `npx @startside/swa inline my-widget.swa.html` writes that
|
|
2088
|
+
copy, `my-widget-inline.swa.html` (`-o` names another, never the file itself), with the package's runtime, its
|
|
2089
|
+
`data-host` kept, then checks it; `npx @startside/swa@latest` gets the latest release's runtime.
|
|
2090
|
+
|
|
2091
|
+
## References
|
|
2092
|
+
|
|
2093
|
+
### Normative references
|
|
2094
|
+
|
|
2095
|
+
- <a id="ref-csp"></a>**[CSP]** *Content Security Policy Level 3*. W3C. <https://www.w3.org/TR/CSP3/>
|
|
2096
|
+
- <a id="ref-css-cascade-5"></a>**[CSS-CASCADE-5]** *CSS Cascading and Inheritance Level 5*, cascade layers. W3C. <https://www.w3.org/TR/css-cascade-5/#layering>
|
|
2097
|
+
- <a id="ref-css-color-5"></a>**[CSS-COLOR-5]** *CSS Color Module Level 5*, `light-dark()`. W3C. <https://www.w3.org/TR/css-color-5/#light-dark>
|
|
2098
|
+
- <a id="ref-dom"></a>**[DOM]** *DOM Standard*. WHATWG. <https://dom.spec.whatwg.org/>
|
|
2099
|
+
- <a id="ref-fetch"></a>**[FETCH]** *Fetch Standard*. WHATWG. <https://fetch.spec.whatwg.org/>
|
|
2100
|
+
- <a id="ref-html"></a>**[HTML]** *HTML Standard*. WHATWG. <https://html.spec.whatwg.org/>
|
|
2101
|
+
- <a id="ref-infra"></a>**[INFRA]** *Infra Standard*. WHATWG. <https://infra.spec.whatwg.org/>
|
|
2102
|
+
- <a id="ref-jsonfeed"></a>**[JSONFEED]** M. Reece, B. Simmons. *JSON Feed Version 1.1*. <https://jsonfeed.org/version/1.1>
|
|
2103
|
+
- <a id="ref-rfc2119"></a>**[RFC2119]** S. Bradner. *Key words for use in RFCs to Indicate Requirement Levels*. BCP 14, RFC 2119, March 1997.
|
|
2104
|
+
<https://www.rfc-editor.org/rfc/rfc2119>
|
|
2105
|
+
- <a id="ref-rfc3339"></a>**[RFC3339]** G. Klyne, C. Newman. *Date and Time on the Internet: Timestamps*. RFC 3339, July 2002.
|
|
2106
|
+
<https://www.rfc-editor.org/rfc/rfc3339>
|
|
2107
|
+
- <a id="ref-rfc9309"></a>**[RFC9309]** M. Koster, G. Illyes, H. Zeller, L. Sassman. *Robots Exclusion Protocol*. RFC 9309, September 2022. <https://www.rfc-editor.org/rfc/rfc9309>
|
|
2108
|
+
- <a id="ref-rfc8174"></a>**[RFC8174]** B. Leiba. *Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words*. BCP 14, RFC 8174, May 2017.
|
|
2109
|
+
<https://www.rfc-editor.org/rfc/rfc8174>
|
|
2110
|
+
- <a id="ref-url"></a>**[URL]** *URL Standard*. WHATWG. <https://url.spec.whatwg.org/>
|
|
2111
|
+
- <a id="ref-uwa"></a>**[UWA]** *Universal Widget API (UWA) 1.2.4*, a consolidated edition, Startside, 2026. [uwa-spec.md](https://startside.app/uwa/1.2/spec.md)
|
|
2112
|
+
- <a id="ref-wcag22"></a>**[WCAG22]** *Web Content Accessibility Guidelines (WCAG) 2.2*. W3C Recommendation. <https://www.w3.org/TR/WCAG22/>
|
|
2113
|
+
- <a id="ref-webidl"></a>**[WEBIDL]** *Web IDL Standard*. WHATWG. <https://webidl.spec.whatwg.org/>
|
|
2114
|
+
|
|
2115
|
+
### Informative references
|
|
2116
|
+
|
|
2117
|
+
- <a id="ref-aria-apg"></a>**[ARIA-APG]** *WAI-ARIA Authoring Practices Guide*. W3C.
|
|
2118
|
+
<https://www.w3.org/WAI/ARIA/apg/>
|
|
2119
|
+
- <a id="ref-rwa"></a>**[RWA]** *React Widget API (RWA) 1.0*. Startside. [docs/rwa-spec.md](https://startside.app/rwa/1.0/spec.md)
|
|
2120
|
+
- <a id="ref-w3c-widgets"></a>**[W3C-WIDGETS]** *Widget Interface*. W3C, 2013; obsolete since 2018. <https://www.w3.org/TR/widgets-apis/>
|
|
2121
|
+
|
|
2122
|
+
## Acknowledgements
|
|
2123
|
+
|
|
2124
|
+
SWA keeps the interface of the Universal Widget API, designed at Netvibes; its 1.2 Working Draft was edited by Xavier
|
|
2125
|
+
Borderie and François Hodierne (2008).
|