@close-by/clay 0.2.15 → 0.2.16

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.
@@ -68,5 +68,5 @@ With **`clay --reactive-let`**, transformed files that import known-fragile CJS
68
68
  ## Related
69
69
 
70
70
  - Helpers table: [API — dialogs and feedback](./api.md#dialogs-and-feedback)
71
- - Protocol: `clipboard`, `setUrlHash`, `setUrlSearch`, `openExternal` in [WebSocket protocol](./protocol.md)
71
+ - Protocol: `clipboard`, `setUrlHash`, `setUrlSearch`, `urlchange`, `openExternal` in [WebSocket protocol](./protocol.md)
72
72
  - Phase 1 reactivity (preferred over DOM hacks): [reactive-let](./reactive-let.md)
package/docs/protocol.md CHANGED
@@ -35,6 +35,14 @@ Sent on connect and after client-side navigation. The React client keeps matchin
35
35
  | `type` | `string` | Event name (`click`, `input`, `change`, …) |
36
36
  | `value` | `unknown` | Optional payload (string, number, boolean, …) |
37
37
 
38
+ ### `urlchange`
39
+
40
+ ```json
41
+ { "op": "urlchange", "search": "tab=orders&partner=UBER", "hash": "" }
42
+ ```
43
+
44
+ Browser Back/Forward (or other `popstate`) changed the query and/or hash **without** a path change. Server updates `session.urlSearch` / `session.urlHash` and notifies `ui.urlState` listeners — **no remount**. Path changes still use `hello`. Prefer this over reading `window` in page code. See [URL search](./url-search.md).
45
+
38
46
  ## Server → client
39
47
 
40
48
  ### `mount`
@@ -161,7 +169,7 @@ Client writes `content` with `navigator.clipboard.writeText` (shows an error toa
161
169
  { "op": "setUrlHash", "hash": "trace-abc" }
162
170
  ```
163
171
 
164
- Client sets `location.hash` via `history.replaceState` (`hash` has no leading `#`; empty string clears). Hydrated the other way on `hello.hash`. Prefer `ui.setUrlHash` / `ui.getUrlHash`.
172
+ Client sets `location.hash` via `history.replaceState` (`hash` has no leading `#`; empty string clears). Hydrated the other way on `hello.hash` and re-synced in place on `urlchange`. Prefer `ui.setUrlHash` / `ui.getUrlHash`.
165
173
 
166
174
  ### `setUrlSearch`
167
175
 
@@ -169,7 +177,7 @@ Client sets `location.hash` via `history.replaceState` (`hash` has no leading `#
169
177
  { "op": "setUrlSearch", "search": "tab=orders&partner=UBER", "mode": "replace" }
170
178
  ```
171
179
 
172
- Client sets `location.search` via `history.replaceState` or `pushState` (`mode`, default `replace`). `search` has no leading `?`; empty string clears. Pathname and hash are preserved. Hydrated the other way on `hello.search`. Prefer `ui.setUrlSearch` / `ui.updateUrlSearch` / `ui.getUrlSearch`. See [URL search](./url-search.md).
180
+ Client sets `location.search` via `history.replaceState` or `pushState` (`mode`, default `replace`). `search` has no leading `?`; empty string clears. Pathname and hash are preserved. Hydrated the other way on `hello.search` and re-synced in place on `urlchange`. Prefer `ui.setUrlSearch` / `ui.updateUrlSearch` / `ui.getUrlSearch`. See [URL search](./url-search.md).
173
181
 
174
182
  ### `openExternal`
175
183
 
@@ -61,12 +61,18 @@ tweaks so Back is not flooded.
61
61
 
62
62
  ## Protocol
63
63
 
64
- **Client → server** (`hello`):
64
+ **Client → server** (`hello` on connect / path change):
65
65
 
66
66
  ```json
67
67
  { "op": "hello", "path": "/lastmile", "hash": "", "search": "tab=orders&partner=UBER" }
68
68
  ```
69
69
 
70
+ **Client → server** (Back/Forward, same path — no remount):
71
+
72
+ ```json
73
+ { "op": "urlchange", "search": "partner=GLOVO", "hash": "" }
74
+ ```
75
+
70
76
  **Server → client**:
71
77
 
72
78
  ```json
@@ -74,7 +80,8 @@ tweaks so Back is not flooded.
74
80
  ```
75
81
 
76
82
  Client writes `pathname + ?search + hash` via `history.replaceState` / `pushState`.
77
- Hash is preserved (same as `setUrlHash` preserves search).
83
+ Hash is preserved (same as `setUrlHash` preserves search). Same-path `popstate`
84
+ sends `urlchange` so `ui.urlState` re-hydrates in place.
78
85
 
79
86
  ## Path vs query
80
87
 
@@ -84,14 +91,7 @@ Hash is preserved (same as `setUrlHash` preserves search).
84
91
  | Active tab, filters, sort, page | **Query string** (`ui.urlState`) |
85
92
  | In-page focus / trace id | Hash (`ui.setUrlHash`) when you already use it |
86
93
 
87
- ## Limits / follow-ups
88
-
89
- - Hydration runs on each `hello` (connect, reconnect, SPA path change). Pure
90
- Back/Forward that only changes the query does **not** remount yet — same
91
- limitation as hash today. A future `urlchange` client event (or popstate →
92
- hello) would close that gap and re-hydrate `urlState` in place.
93
-
94
94
  ## Related
95
95
 
96
96
  - [Browser APIs](./browser-apis.md)
97
- - [WebSocket protocol](./protocol.md) — `hello.search`, `setUrlSearch`
97
+ - [WebSocket protocol](./protocol.md) — `hello.search`, `urlchange`, `setUrlSearch`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@close-by/clay",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "NiceGUI-like ui.* facade for Clay apps",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,10 +37,10 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@close-by/clay-compiler": "0.2.15",
41
- "@close-by/clay-core": "0.2.15",
42
- "@close-by/clay-components": "0.2.15",
43
- "@close-by/clay-server": "0.2.15",
40
+ "@close-by/clay-compiler": "0.2.16",
41
+ "@close-by/clay-core": "0.2.16",
42
+ "@close-by/clay-components": "0.2.16",
43
+ "@close-by/clay-server": "0.2.16",
44
44
  "@tailwindcss/cli": "^4.3.3",
45
45
  "tailwindcss": "^4.3.3"
46
46
  }