@startside/swa 1.0.0 → 1.0.2
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 +711 -0
- package/swa/1.0/quickstart.md +154 -0
- package/swa/1.0/runtime.js +3 -3
- package/swa/1.0/spec.md +2352 -0
- package/swa/1.0/swa.d.ts +67 -4
package/swa/1.0/swa.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ declare global {
|
|
|
43
43
|
fullscreen: WidgetEvent<boolean>;
|
|
44
44
|
/** Cancelable: canceling skips the refresh that follows. */
|
|
45
45
|
settingschange: WidgetEvent<{ names: string[] }>;
|
|
46
|
+
/** One of the widget's own actions (declared in `<menu id="actions">`, 7.13) chosen in its options menu. */
|
|
47
|
+
action: WidgetEvent<{ id: string }>;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
interface Widget extends EventTarget {
|
|
@@ -106,8 +108,9 @@ declare global {
|
|
|
106
108
|
clearPeriodical(name: string): void;
|
|
107
109
|
|
|
108
110
|
// 7.7 Lists and grips
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
/** `box` an HTML element: the grip sets its style. */
|
|
112
|
+
countGrip(box: HTMLElement, itemSelector: string, options?: CountGripOptions): void;
|
|
113
|
+
heightGrip(box: HTMLElement, scroller: HTMLElement, options?: HeightGripOptions): void;
|
|
111
114
|
|
|
112
115
|
// 7.8 Memory and stored data
|
|
113
116
|
readonly storage: WidgetStorage;
|
|
@@ -147,7 +150,8 @@ declare global {
|
|
|
147
150
|
share(data?: { text?: string; url?: string }): unknown;
|
|
148
151
|
/** Absent where no widget can be added (a preview, a widget on its own page): `if (widget.addWidget)`. */
|
|
149
152
|
addWidget?(spec: AddWidgetSpec): unknown;
|
|
150
|
-
|
|
153
|
+
/** `spec`, or a function giving it as the drag starts, given the drag's event; nothing given, the drag doesn't start. */
|
|
154
|
+
dragWidget(element: Element, spec: AddWidgetSpec | ((event: DragEvent) => AddWidgetSpec | null | undefined)): boolean;
|
|
151
155
|
readonly canFullSize: boolean;
|
|
152
156
|
readonly fullSize: boolean;
|
|
153
157
|
openFull(): void;
|
|
@@ -155,6 +159,30 @@ declare global {
|
|
|
155
159
|
/** Full screen: the browser's, or the widget alone over the window where the browser has none (7.13). */
|
|
156
160
|
readonly fullScreen: boolean;
|
|
157
161
|
setFullScreen(on: boolean): void;
|
|
162
|
+
/**
|
|
163
|
+
* Changes the state of actions the file declares (`<menu id="actions">`, 7.13), by id: greyed, hidden, another
|
|
164
|
+
* label. An id the file doesn't declare throws a TypeError. States last while the widget runs.
|
|
165
|
+
*/
|
|
166
|
+
setActionStates(states: Record<string, WidgetActionState>): void;
|
|
167
|
+
/**
|
|
168
|
+
* A file the widget made, for the person to keep (7.13): the host checks its name, its extension and its type,
|
|
169
|
+
* and delivers it. `options.action`: the `action` event of a choice of an action whose declaration carries
|
|
170
|
+
* `data-save`; one file per choice, within 30 seconds. Resolves once the host handed the file to the browser
|
|
171
|
+
* (not "saved"); rejects with a DOMException: NotAllowedError (no such choice, or already used), NotSupportedError
|
|
172
|
+
* (a name, an extension or a type the action or the host doesn't take), QuotaExceededError (over 8 MiB),
|
|
173
|
+
* AbortError (the person cancelled). Without `options.action`: NotAllowedError.
|
|
174
|
+
*/
|
|
175
|
+
saveFile(file: WidgetSaveFile, options?: { action?: WidgetEvent<{ id: string }> }): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** A file a widget saves (7.13). */
|
|
179
|
+
interface WidgetSaveFile {
|
|
180
|
+
/** Its name, with its extension: one the action declares (`data-save`). The host cleans it. */
|
|
181
|
+
name: string;
|
|
182
|
+
/** Its type, one its extension takes ('' for the usual one): "text/plain;charset=utf-8". */
|
|
183
|
+
type: string;
|
|
184
|
+
/** Its content, 8 MiB at most (a string's as UTF-8); copied as the call is made. */
|
|
185
|
+
data: string | Blob | ArrayBuffer;
|
|
158
186
|
}
|
|
159
187
|
|
|
160
188
|
/** Settings typed by the control that declares them (7.5): a checkbox's a boolean, a range's or a number's a number. */
|
|
@@ -345,9 +373,44 @@ declare global {
|
|
|
345
373
|
alt?: string;
|
|
346
374
|
title?: string;
|
|
347
375
|
preview?: string;
|
|
376
|
+
/** A larger picture of the same, asked only when the person zooms in. */
|
|
377
|
+
zoom?: string;
|
|
348
378
|
width?: number;
|
|
349
379
|
height?: number;
|
|
350
|
-
credit
|
|
380
|
+
/** What the picture's licence asks to go with it. A plain string is its credit text. */
|
|
381
|
+
credit?: PhotoCredit | string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* A picture's credit, in schema.org's ImageObject names (https://schema.org/ImageObject), every member optional.
|
|
386
|
+
* Addresses are `https`.
|
|
387
|
+
*/
|
|
388
|
+
interface PhotoCredit {
|
|
389
|
+
/** The work's title. */
|
|
390
|
+
name?: string;
|
|
391
|
+
/** Who made it. */
|
|
392
|
+
creator?: string;
|
|
393
|
+
/** The credit line: who keeps or gives the picture (a museum, an agency). */
|
|
394
|
+
creditText?: string;
|
|
395
|
+
/** Who the licence says to name, as it asks ("Photo: …", "© …"). */
|
|
396
|
+
copyrightNotice?: string;
|
|
397
|
+
/** The licence's address. */
|
|
398
|
+
license?: string;
|
|
399
|
+
/** The picture's page at its source. */
|
|
400
|
+
url?: string;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* What a running widget may change of an action its file declares (7.13). A field left out stays as it was; `null`
|
|
405
|
+
* puts it back to what the file declares.
|
|
406
|
+
*/
|
|
407
|
+
interface WidgetActionState {
|
|
408
|
+
/** Greyed: nothing to act on. */
|
|
409
|
+
disabled?: boolean | null;
|
|
410
|
+
/** Not in the menu. */
|
|
411
|
+
hidden?: boolean | null;
|
|
412
|
+
/** Another label, 1 to 40 characters: a word that depends on its state, or a translation. */
|
|
413
|
+
label?: string | null;
|
|
351
414
|
}
|
|
352
415
|
|
|
353
416
|
interface AddWidgetSpec {
|