@quickwatch/preview 0.2.0 → 0.3.0
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/README.api.md +43 -0
- package/README.md +102 -30
- package/dist/cli.mjs +13225 -0
- package/dist/node.mjs +13178 -0
- package/dist/quickwatch-preview.min.js +31 -28
- package/package.json +14 -2
package/README.api.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
## The package
|
|
2
|
+
|
|
3
|
+
`@quickwatch/preview` is QuickWatch's watch preview as one script, plus QuickWatch's validator for Node.
|
|
4
|
+
|
|
5
|
+
In a page (the script from jsDelivr, `window.QuickWatch`):
|
|
6
|
+
|
|
7
|
+
- **Auto-mount** (above): `<script type="application/json" data-qw-watch>` and `data-qw-data` blocks are drawn as the
|
|
8
|
+
widget whenever the script finishes loading. Pair several by value (`data-qw-watch="a"` with `data-qw-data="a"`),
|
|
9
|
+
put the widget in a `[data-qw-mount]` element, and set the site with `data-qw-origin`.
|
|
10
|
+
- `QuickWatch.widget(element, watch, data, options)`: the same widget, into an element. Options: `title`, `origin`
|
|
11
|
+
(default `https://quickwatch.app`) and those of `render`.
|
|
12
|
+
- `QuickWatch.render(element, watch, data, options)`: just the watch. Options: `surface` (`overview`, `tile`,
|
|
13
|
+
`complication`, `page:<id>`), `experience`, `device` (`QuickWatch.devices`), `theme` (`auto` or
|
|
14
|
+
`QuickWatch.themes`), `data` (`sample`, `loading`, `error`, `empty`, `stale`), `ambient`, `size` (CSS px across the
|
|
15
|
+
face), `frame`, `onUpdate`, `onError`. Returns `{ surfaces, surface, show(key), update(watch, data), errors,
|
|
16
|
+
destroy() }`.
|
|
17
|
+
- `await QuickWatch.link(watch, data)`: the Open in QuickWatch link.
|
|
18
|
+
|
|
19
|
+
`watch` and `data` are objects or JSON text (comments and trailing commas allowed). Nothing is fetched except the two
|
|
20
|
+
font files next to the script; sources show their sample data and actions are simulated.
|
|
21
|
+
|
|
22
|
+
The widget and the watch draw inside shadow roots (with `all: initial` on the host), so the page's styles, such as a
|
|
23
|
+
chat panel's rules for buttons, links and text, cannot change them; only the two `@font-face` rules go into the page's
|
|
24
|
+
`<head>`. The widget's light or dark look follows the background it sits on (`appearance: 'light' | 'dark'` to
|
|
25
|
+
choose).
|
|
26
|
+
|
|
27
|
+
In Node (`import { check, link } from '@quickwatch/preview'`) and the shell:
|
|
28
|
+
|
|
29
|
+
- `npx @quickwatch/preview check watch.json data.json [--origin <url>] [--json]`: validates with QuickWatch's own
|
|
30
|
+
validator, prints the problems (JSON path, rule, line and column) and the Open in QuickWatch link. Exit code 1 when
|
|
31
|
+
there are errors.
|
|
32
|
+
- `await check(watch, data)`: `{ issues, errors, warnings, link }`. `await link(watch, data)`: the link.
|
|
33
|
+
|
|
34
|
+
Pin an exact version (`@quickwatch/preview@0.3.0`) to skip jsDelivr's redirect from `@0`.
|
|
35
|
+
|
|
36
|
+
Roboto Flex is under the SIL Open Font License (`dist/fonts/RobotoFlex-OFL.txt`).
|
|
37
|
+
|
|
38
|
+
## Building and publishing (maintainers)
|
|
39
|
+
|
|
40
|
+
`pnpm build` writes `dist/` and this README (from `docs/quickstart.md` and `README.api.md`): the browser IIFE with the
|
|
41
|
+
engine, `watch.css` and the device profiles inlined, the fonts, `node.mjs` and `cli.mjs` (the app's validator and link
|
|
42
|
+
encoder, bundled). `pnpm pack`, then publish the tarball with `npm publish <tgz> --access public` (pnpm's publish has
|
|
43
|
+
no web two-factor flow). Major versions follow the format: 0.x while `schemaVersion` 2 settles.
|
package/README.md
CHANGED
|
@@ -1,48 +1,120 @@
|
|
|
1
1
|
# @quickwatch/preview
|
|
2
2
|
|
|
3
|
-
QuickWatch's watch preview
|
|
4
|
-
same engine as the QuickWatch site and the watch's own rules (the bundle the watch gets, a device profile, the theme).
|
|
5
|
-
Made for pages QuickWatch does not serve, such as a chat assistant's inline widget. Sources show their sample data;
|
|
6
|
-
taps and actions are simulated; nothing is fetched except the two font files next to the script.
|
|
3
|
+
QuickWatch's watch preview for chats and pages, and its validator for Node.
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
## Quick start for AI assistants
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
QuickWatch puts a small app on a Wear OS watch. The app is two JSON documents: `watch.json` (the app) and `data.json`
|
|
8
|
+
(sample or mock data). You don't need the QuickWatch connector.
|
|
9
|
+
|
|
10
|
+
### How do I show a preview in the chat?
|
|
11
|
+
|
|
12
|
+
Put this HTML in an inline HTML widget or artifact (in Claude: the `show_widget` tool). It works as it is. For your
|
|
13
|
+
app, replace the two JSON blocks and change nothing else:
|
|
12
14
|
|
|
13
15
|
```html
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
+
<script type="application/json" data-qw-watch>
|
|
17
|
+
{
|
|
18
|
+
"schemaVersion": 2,
|
|
19
|
+
"sources": { "weather": { "type": "http", "url": "https://api.example.com/weather", "refresh": { "poll": "15m" } } },
|
|
20
|
+
"experiences": {
|
|
21
|
+
"weather": {
|
|
22
|
+
"title": "Weather",
|
|
23
|
+
"icon": "cloud",
|
|
24
|
+
"pages": { "now": { "title": "Stockholm", "root": { "type": "text", "value": "{{ weather.temp | round }}°" } } },
|
|
25
|
+
"tile": { "template": "text", "title": "Weather", "text": "{{ weather.temp | round }}°" },
|
|
26
|
+
"complication": { "kind": "shortText", "text": "{{ weather.temp | round }}°" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
<script type="application/json" data-qw-data>
|
|
32
|
+
{ "weather": { "temp": 14.2 } }
|
|
33
|
+
</script>
|
|
16
34
|
<script>
|
|
17
|
-
|
|
35
|
+
var s = document.createElement("script");
|
|
36
|
+
s.src = "https://cdn.jsdelivr.net/npm/@quickwatch/preview@0.3.0/dist/quickwatch-preview.min.js";
|
|
37
|
+
s.onerror = function () { document.body.append("Could not load the QuickWatch preview."); };
|
|
38
|
+
document.head.appendChild(s);
|
|
18
39
|
</script>
|
|
19
40
|
```
|
|
20
41
|
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
It shows the real watch, drawn by QuickWatch's own renderer, with a button for each screen (pages, tile, complication),
|
|
43
|
+
any problems in red, and an **Open in QuickWatch** button. The user presses it to keep the app and send it to their
|
|
44
|
+
watch. Don't draw the watch by hand.
|
|
23
45
|
|
|
24
|
-
|
|
46
|
+
### What goes in watch.json?
|
|
25
47
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
- `schemaVersion` is `2`.
|
|
49
|
+
- `sources`: where data comes from, by name. `"type": "http"` with a `url` (QuickWatch fetches it; add
|
|
50
|
+
`"mode": "direct"` to have the watch fetch it), or `"type": "feed"` (your server pushes values).
|
|
51
|
+
- `experiences`: the apps on the watch. Each needs `title`, `pages` and `tile`. `complication` is optional.
|
|
52
|
+
- A page has a `title` and a `root` component: `text`, `stat`, `list`, `status`, `progress`, `countdown`, `button`,
|
|
53
|
+
`toggle`, `icon`, or `stack` to lay out several.
|
|
54
|
+
- Text reads data with `{{ source.field }}`, for example `{{ weather.temp | round }}`.
|
|
55
|
+
- `data.json` has sample data for every source, by name. Put mock data there.
|
|
56
|
+
- Ids are lowercase letters, digits and `-`. Unknown properties are errors. API keys never go in the JSON.
|
|
57
|
+
|
|
58
|
+
### How do I check it?
|
|
59
|
+
|
|
60
|
+
Run `npx @quickwatch/preview check watch.json data.json`. It validates exactly as QuickWatch does, prints the
|
|
61
|
+
problems with their JSON paths, and prints the Open in QuickWatch link. The widget also shows problems in red.
|
|
62
|
+
|
|
63
|
+
### How does the user keep it?
|
|
64
|
+
|
|
65
|
+
With the widget's **Open in QuickWatch** button. To put the link in your reply too, take it from the check above. The
|
|
66
|
+
format is `https://quickwatch.app/new#c=<payload>`, where the payload is base64url of deflate-raw of the JSON
|
|
67
|
+
`{ "v": 1, "config": <watch.json>, "data": <data.json> }`. Encoders:
|
|
68
|
+
https://quickwatch.app/docs/agent-guide.md#the-open-in-quickwatch-link
|
|
69
|
+
|
|
70
|
+
### More
|
|
71
|
+
|
|
72
|
+
- Assistant guide: https://quickwatch.app/llms.txt
|
|
73
|
+
- Full format, worked examples and errors: https://quickwatch.app/docs/agent-guide.md
|
|
74
|
+
- JSON Schema: https://quickwatch.app/schema/quickwatch.schema.json
|
|
75
|
+
- Every component, tile template, complication kind and icon: https://quickwatch.app/schema/capabilities.json
|
|
76
|
+
- Connector, to build straight to the watch: https://quickwatch.app/mcp
|
|
77
|
+
|
|
78
|
+
## The package
|
|
79
|
+
|
|
80
|
+
`@quickwatch/preview` is QuickWatch's watch preview as one script, plus QuickWatch's validator for Node.
|
|
81
|
+
|
|
82
|
+
In a page (the script from jsDelivr, `window.QuickWatch`):
|
|
83
|
+
|
|
84
|
+
- **Auto-mount** (above): `<script type="application/json" data-qw-watch>` and `data-qw-data` blocks are drawn as the
|
|
85
|
+
widget whenever the script finishes loading. Pair several by value (`data-qw-watch="a"` with `data-qw-data="a"`),
|
|
86
|
+
put the widget in a `[data-qw-mount]` element, and set the site with `data-qw-origin`.
|
|
87
|
+
- `QuickWatch.widget(element, watch, data, options)`: the same widget, into an element. Options: `title`, `origin`
|
|
88
|
+
(default `https://quickwatch.app`) and those of `render`.
|
|
89
|
+
- `QuickWatch.render(element, watch, data, options)`: just the watch. Options: `surface` (`overview`, `tile`,
|
|
90
|
+
`complication`, `page:<id>`), `experience`, `device` (`QuickWatch.devices`), `theme` (`auto` or
|
|
91
|
+
`QuickWatch.themes`), `data` (`sample`, `loading`, `error`, `empty`, `stale`), `ambient`, `size` (CSS px across the
|
|
92
|
+
face), `frame`, `onUpdate`, `onError`. Returns `{ surfaces, surface, show(key), update(watch, data), errors,
|
|
93
|
+
destroy() }`.
|
|
94
|
+
- `await QuickWatch.link(watch, data)`: the Open in QuickWatch link.
|
|
95
|
+
|
|
96
|
+
`watch` and `data` are objects or JSON text (comments and trailing commas allowed). Nothing is fetched except the two
|
|
97
|
+
font files next to the script; sources show their sample data and actions are simulated.
|
|
98
|
+
|
|
99
|
+
The widget and the watch draw inside shadow roots (with `all: initial` on the host), so the page's styles, such as a
|
|
100
|
+
chat panel's rules for buttons, links and text, cannot change them; only the two `@font-face` rules go into the page's
|
|
101
|
+
`<head>`. The widget's light or dark look follows the background it sits on (`appearance: 'light' | 'dark'` to
|
|
102
|
+
choose).
|
|
103
|
+
|
|
104
|
+
In Node (`import { check, link } from '@quickwatch/preview'`) and the shell:
|
|
105
|
+
|
|
106
|
+
- `npx @quickwatch/preview check watch.json data.json [--origin <url>] [--json]`: validates with QuickWatch's own
|
|
107
|
+
validator, prints the problems (JSON path, rule, line and column) and the Open in QuickWatch link. Exit code 1 when
|
|
108
|
+
there are errors.
|
|
109
|
+
- `await check(watch, data)`: `{ issues, errors, warnings, link }`. `await link(watch, data)`: the link.
|
|
35
110
|
|
|
36
|
-
|
|
37
|
-
(default the first), `surface` (`overview`, `tile`, `complication`, `page:<id>`), `device` (`QuickWatch.devices`,
|
|
38
|
-
default `galaxy-watch`), `theme` (`auto` or one of `QuickWatch.themes`), `data` (`sample`, `loading`, `error`,
|
|
39
|
-
`empty`, `stale`), `ambient`, `size` (CSS px across the face), `frame` (draw the case, default true) and `onUpdate`.
|
|
111
|
+
Pin an exact version (`@quickwatch/preview@0.3.0`) to skip jsDelivr's redirect from `@0`.
|
|
40
112
|
|
|
41
113
|
Roboto Flex is under the SIL Open Font License (`dist/fonts/RobotoFlex-OFL.txt`).
|
|
42
114
|
|
|
43
115
|
## Building and publishing (maintainers)
|
|
44
116
|
|
|
45
|
-
`pnpm build` writes `dist
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
117
|
+
`pnpm build` writes `dist/` and this README (from `docs/quickstart.md` and `README.api.md`): the browser IIFE with the
|
|
118
|
+
engine, `watch.css` and the device profiles inlined, the fonts, `node.mjs` and `cli.mjs` (the app's validator and link
|
|
119
|
+
encoder, bundled). `pnpm pack`, then publish the tarball with `npm publish <tgz> --access public` (pnpm's publish has
|
|
120
|
+
no web two-factor flow). Major versions follow the format: 0.x while `schemaVersion` 2 settles.
|