@startside/swa 0.0.0-stage → 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 ADDED
@@ -0,0 +1,81 @@
1
+ This package holds two kinds of files, under two licences:
2
+
3
+ - The runtime, its types and the command (swa/1.0/runtime.js, swa/1.0/swa.d.ts, bin/swa.mjs): the MIT License,
4
+ below, which covers them only, not the texts. bin/swa.mjs also holds Acorn and acorn-jsx, under their own MIT
5
+ licences, at the end of this file.
6
+ - The texts (swa/1.0/spec.md, swa/1.0/quickstart.md, swa/1.0/agents.md): the Startside Widget API (SWA) 1.0
7
+ specification, SWA in 60 lines and the guide for agents, © 2026 François Hodierne, under the Creative Commons
8
+ Attribution 4.0 International licence (CC BY 4.0): https://creativecommons.org/licenses/by/4.0/
9
+ Their current versions: https://startside.app/swa/1.0/
10
+
11
+ MIT License
12
+
13
+ Copyright (c) 2026 François Hodierne
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+
33
+ ---
34
+
35
+ bin/swa.mjs holds Acorn (https://github.com/acornjs/acorn) and acorn-jsx (https://github.com/acornjs/acorn-jsx):
36
+
37
+ Acorn: MIT License
38
+
39
+ Copyright (C) 2012-2022 by various contributors (see AUTHORS)
40
+
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ of this software and associated documentation files (the "Software"), to deal
44
+ in the Software without restriction, including without limitation the rights
45
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ copies of the Software, and to permit persons to whom the Software is
47
+ furnished to do so, subject to the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be included in
50
+ all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ THE SOFTWARE.
59
+
60
+ acorn-jsx: MIT License
61
+
62
+ Copyright (C) 2012-2017 by Ingvar Stepanyan
63
+
64
+
65
+ Permission is hereby granted, free of charge, to any person obtaining a copy
66
+ of this software and associated documentation files (the "Software"), to deal
67
+ in the Software without restriction, including without limitation the rights
68
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69
+ copies of the Software, and to permit persons to whom the Software is
70
+ furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in
73
+ all copies or substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
81
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,95 @@
1
- # Temporary Holding Version
1
+ # @startside/swa
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The runtime of the **Startside Widget API (SWA) 1.0**, its TypeScript types, its specification in Markdown, and a
4
+ command that checks a widget file and inlines its runtime.
5
+
6
+ An SWA widget is a single HTML file: its head names it and loads this runtime, a hidden form declares its settings, and
7
+ its scripts draw it through one object, `widget`. Opened on its own, the file runs on a standalone page with the
8
+ runtime's title bar, settings and refresh. Added to a Startside dashboard, it runs framed with the dashboard's own
9
+ runtime, which ignores the file's runtime script.
10
+
11
+ - The specification: <https://startside.app/swa/1.0/>
12
+ - SWA in 60 lines, a complete widget and the rules as a table: <https://startside.app/swa/1.0/quickstart.html>
13
+ - For agents: <https://startside.app/swa/1.0/agents.md>
14
+
15
+ ## The texts, in the package
16
+
17
+ The same texts as startside.app publishes, as they were at this release, beside the runtime (since 1.0.1), for an author
18
+ or an agent that can reach npm or a CDN but not startside.app:
19
+
20
+ - `swa/1.0/agents.md`: the guide for agents, short enough to read whole: SWA in 60 lines, the tools, the types and an
21
+ index of the specification;
22
+ - `swa/1.0/quickstart.md`: SWA in 60 lines;
23
+ - `swa/1.0/spec.md`: the specification.
24
+
25
+ On a CDN: `https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/agents.md`. Their links point to startside.app, whose
26
+ copies are the current ones: the specification is a draft and changes between the package's releases.
27
+
28
+ ## Loading the runtime
29
+
30
+ A widget file's head loads one runtime script (SWA 1.0, 4.3). In order of preference:
31
+
32
+ ```html
33
+ <!-- From startside.app: the runtime's fixes as soon as the site has them. -->
34
+ <script src="https://startside.app/swa/1.0/runtime.js"></script>
35
+
36
+ <!-- From this package on a CDN, where startside.app can't be loaded. -->
37
+ <script src="https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/runtime.js"></script>
38
+ <script src="https://unpkg.com/@startside/swa@1/swa/1.0/runtime.js"></script>
39
+ ```
40
+
41
+ Name the package's version, `@1`: it gets the runtime's fixes, and no release of `@1` removes `swa/1.0/`. Without a
42
+ version, or with `@latest`, a later release could break the file. The CDN copy follows the site's releases: a fix
43
+ reaches startside.app first, and this package at its next release.
44
+
45
+ A runtime loaded from a CDN, or inlined, sends the widget's requests (`widget.fetch`, `widget.fetchFeed`) through
46
+ startside.app's proxies. Another Startside host is named by `data-host`, an https origin, on the runtime script:
47
+
48
+ ```html
49
+ <script src="https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/runtime.js" data-host="https://example.org"></script>
50
+ ```
51
+
52
+ **Inlined**, for a page that loads no script from another site: the head holds
53
+ `<script data-runtime="swa/1.0">…</script>` with the text of `swa/1.0/runtime.js` unchanged inside. Its requests still
54
+ go to startside.app, or to its `data-host`: where those are refused too, the widget draws but its requests fail.
55
+
56
+ ## The command
57
+
58
+ For Node 20 or later, nothing else to install:
59
+
60
+ ```sh
61
+ npx @startside/swa validate my-widget.swa.html # check a file, without running it
62
+ npx @startside/swa inline my-widget.swa.html # write my-widget-inline.swa.html, the runtime inside
63
+ ```
64
+
65
+ **`validate <files…> [--json]`** reads each file with no network: its name and document, its runtime tag, metadata and
66
+ settings form, and its scripts against SWA 1.0's API, UWA's members and globals named with what replaces them. It
67
+ prints `file:line:col: error|warning: message`, each citing the specification's section, and exits 1 on an error.
68
+ `--json` prints the findings as a list of `{ file, line, col, level, message }`, for an agent. A file it passes can
69
+ still fail as it runs: open it in a browser too.
70
+
71
+ **`inline <file> [-o <out>]`** writes a copy with its runtime script replaced by `<script data-runtime="swa/1.0">`
72
+ holding this package's runtime (its `data-host` kept), then checks the copy. It never writes over the file: keep the one
73
+ that loads the runtime by its address as the widget's own, and inline again after a release.
74
+
75
+ ## The types
76
+
77
+ `swa/1.0/swa.d.ts` types the global `widget` for an editor. With the package installed (`npm install --save-dev
78
+ @startside/swa`), in a `tsconfig.json` or `jsconfig.json`:
79
+
80
+ ```json
81
+ { "compilerOptions": { "types": ["@startside/swa"] } }
82
+ ```
83
+
84
+ Or next to a widget's code, with the file copied beside it: `/// <reference path="./swa.d.ts" />`.
85
+
86
+ ## Versions
87
+
88
+ The package has its own version. A patch is a runtime fix, the texts brought up to date, or the command's changes; a
89
+ minor release can add a version of the API beside the others (`swa/1.1/` beside `swa/1.0/`); a major release would
90
+ remove one. The API's version is the one in the path.
91
+
92
+ ## Licence
93
+
94
+ The runtime, the types and the command: MIT; the command holds Acorn and acorn-jsx, MIT too. The texts (`spec.md`,
95
+ `quickstart.md`, `agents.md`): CC BY 4.0, © François Hodierne. `LICENSE` says which is which.