@gjsify/example-gtk-adwaita-storybook 0.33.0 → 0.35.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.md +91 -2
- package/dist/browser-main.js +4757 -0
- package/dist/gjs.node.mjs +91 -0
- package/dist/index.html +23 -0
- package/package.json +15 -8
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gjsify/example-gtk-adwaita-storybook
|
|
2
2
|
|
|
3
3
|
An interactive **component browser for [Libadwaita](https://gnome.pages.gitlab.gnome.org/libadwaita/)**
|
|
4
4
|
widgets — the GNOME equivalent of a web "storybook". Each widget is rendered live, in
|
|
5
5
|
isolation, with a two-way-bound **Controls** panel so you can poke at its properties and
|
|
6
|
-
watch it update.
|
|
6
|
+
watch it update. 35 stories across 7 categories.
|
|
7
|
+
|
|
8
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
7
9
|
|
|
8
10
|
It is a showcase for three pieces of gjsify tooling working together:
|
|
9
11
|
|
|
@@ -15,18 +17,70 @@ It is a showcase for three pieces of gjsify tooling working together:
|
|
|
15
17
|
|
|
16
18
|

|
|
17
19
|
|
|
20
|
+
## Targets
|
|
21
|
+
|
|
22
|
+
| Target | Bundle | Renderer |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| GJS / GTK 4 | `dist/gjs.js` (`--app gjs`) | `@gjsify/storybook` — native `Adw.*` widgets |
|
|
25
|
+
| Node · Bun · Deno | `dist/gjs.node.mjs` (`--app node`) | the same GTK renderer through the `@gjsify/node-gi` reverse bridge |
|
|
26
|
+
| Browser | `dist/browser-main.js` (`--app browser`) | `@gjsify/adwaita-storybook` — `@gjsify/adwaita-web` components |
|
|
27
|
+
| Android (NativeScript) | [`adwaita-storybook-nativescript`](../../dom/adwaita-storybook-nativescript) | `@gjsify/storybook-nativescript` — real native NS views |
|
|
28
|
+
|
|
29
|
+
Every target renders the SAME stories: the renderer-free `*.meta.ts` metadata is exported from
|
|
30
|
+
this package's `./metas` barrel and the shared logic lives in
|
|
31
|
+
[`@gjsify/storybook-core`](../../../packages/framework/storybook-core), so each renderer is a
|
|
32
|
+
thin adapter and the four renderings are comparable 1:1 by screenshot.
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
GJS ≥ 1.86 with GTK 4 and Libadwaita 1.x. `gjsify system-check` reports what is missing.
|
|
37
|
+
|
|
18
38
|
## Run it
|
|
19
39
|
|
|
20
40
|
```bash
|
|
21
41
|
# from this directory
|
|
22
42
|
gjsify storybook # discover every *.story.ts, build (--app gjs), launch the browser
|
|
23
43
|
gjsify storybook --watch # rebuild + relaunch on change
|
|
44
|
+
|
|
45
|
+
# without a checkout
|
|
46
|
+
gjsify showcase adwaita-storybook
|
|
24
47
|
```
|
|
25
48
|
|
|
26
49
|
`gjsify storybook` reads the `gjsify.storybook` block in [`package.json`](package.json)
|
|
27
50
|
(application id, window title, the `src` story dir, and `--globals auto`). No per-project
|
|
28
51
|
storybook *app* — just `*.story.ts` files plus the shared renderer.
|
|
29
52
|
|
|
53
|
+
### On Node, Bun and Deno
|
|
54
|
+
|
|
55
|
+
The same window and the same stories on the other three runtimes, with GTK reached through
|
|
56
|
+
[`@gjsify/node-gi`](../../../packages/node-gi/node-gi) instead of GJS:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
gjsify storybook --runtime node # or --runtime bun / --runtime deno
|
|
60
|
+
gjsify showcase adwaita-storybook --runtime bun # without a checkout
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
ONE bundle serves all three (`dist/gjs.node.mjs`), because Node-API is their common native
|
|
64
|
+
ABI — there is no per-runtime build, and `build:node` produces it once. `--runtime gjs`
|
|
65
|
+
builds the separate `--app gjs` bundle.
|
|
66
|
+
|
|
67
|
+
This is not a fourth story format. The stories are renderer-free and this is the same native
|
|
68
|
+
GTK renderer reached over a different bridge; what a runtime has to prove is that the bridge
|
|
69
|
+
holds. All three open the window and claim `org.gjsify.AdwaitaStorybook` on the session bus,
|
|
70
|
+
which is exactly what the DBus harness below drives — so "it works there" is a checkable
|
|
71
|
+
claim, not a build that merely completed.
|
|
72
|
+
|
|
73
|
+
### In the browser
|
|
74
|
+
|
|
75
|
+
The web renderer builds the same stories as `@gjsify/adwaita-web` components:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
gjsify run build:web # build:browser + build:assets
|
|
79
|
+
gjsify run start:browser # http-server dist; open localhost:8080
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The `./browser` export is the embeddable entry the project website uses.
|
|
83
|
+
|
|
30
84
|
## Debug / drive it over DBus + MCP
|
|
31
85
|
|
|
32
86
|
Launch with the devtools control plane enabled, then drive it from `gdbus`, an MCP client,
|
|
@@ -58,6 +112,32 @@ GJSIFY_DEVTOOLS=1 gjsify storybook & # launch
|
|
|
58
112
|
gjs -m tools/shoot-stories.js org.gjsify.AdwaitaStorybook ./shots # capture all stories
|
|
59
113
|
```
|
|
60
114
|
|
|
115
|
+
## What it demonstrates
|
|
116
|
+
|
|
117
|
+
- A real Libadwaita component browser built from `*.story.ts` files alone — no per-project
|
|
118
|
+
storybook application, the renderer and the CLI command are the shared parts
|
|
119
|
+
- Two-way-bound live controls over native GObject properties: editing a control writes the
|
|
120
|
+
widget property, and a `notify::` on the widget updates the control
|
|
121
|
+
- ONE renderer-free story contract driving four renderings (GTK, Node/Bun/Deno over node-gi,
|
|
122
|
+
browser, NativeScript) — the same `*.meta.ts` metadata, shared across package boundaries
|
|
123
|
+
- The `@gjsify/devtools` DBus + MCP control plane: an agent can list and open stories, set
|
|
124
|
+
story args, dump the widget tree and screenshot the window headlessly
|
|
125
|
+
- Breadth of the Libadwaita widget set working under gjsify — rows, navigation, view
|
|
126
|
+
switching, dialogs and toasts (see the table below)
|
|
127
|
+
- `gjsify storybook` as a first-class workflow: discovery, build, launch, `--watch`, `--runtime`
|
|
128
|
+
|
|
129
|
+
## Layout
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
src/
|
|
133
|
+
<category>/<name>.meta.ts renderer-free story metadata (title + controls) — shared by ALL targets
|
|
134
|
+
<category>/<name>.story.ts the GTK story (StoryWidget subclass)
|
|
135
|
+
metas.ts the ./metas barrel the other renderers import
|
|
136
|
+
browser/<category>/<name>.web.ts the adwaita-web story for the same meta
|
|
137
|
+
browser/{main,embed,stories}.ts + index.html the browser shell and ./browser export
|
|
138
|
+
tools/shoot-stories.js open + screenshot every story over the devtools DBus surface
|
|
139
|
+
```
|
|
140
|
+
|
|
61
141
|
## Stories
|
|
62
142
|
|
|
63
143
|
Stories live under [`src/`](src), grouped into category folders. The sidebar group comes
|
|
@@ -115,6 +195,15 @@ Rules of thumb: globally-unique `GTypeName` (prefix `AdwStorybook…`), wrap `Ad
|
|
|
115
195
|
`Adw.PreferencesGroup`, give space-filling widgets a `widthRequest`/`heightRequest`, and
|
|
116
196
|
present dialogs from a button rather than embedding them.
|
|
117
197
|
|
|
198
|
+
## Related
|
|
199
|
+
|
|
200
|
+
- [`@gjsify/storybook`](../../../packages/framework/storybook) — the GTK story renderer
|
|
201
|
+
- [`@gjsify/storybook-core`](../../../packages/framework/storybook-core) — the renderer-free logic all targets share
|
|
202
|
+
- [`@gjsify/adwaita-storybook`](../../../packages/web/adwaita-storybook) — the browser renderer
|
|
203
|
+
- [`@gjsify/devtools`](../../../packages/framework/devtools) — the DBus + MCP control plane
|
|
204
|
+
- [`@gjsify/node-gi`](../../../packages/node-gi/node-gi) — the reverse bridge behind the Node/Bun/Deno target
|
|
205
|
+
- [`adwaita-storybook-nativescript`](../../dom/adwaita-storybook-nativescript) — the same stories as a native Android app
|
|
206
|
+
|
|
118
207
|
## License
|
|
119
208
|
|
|
120
209
|
MIT © Pascal Garber. Libadwaita is LGPL-2.1+ © GNOME contributors.
|