@link-foundation/ui-devmode 0.0.0-stage → 0.0.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/LICENSE +24 -0
- package/README.md +353 -2
- package/package.json +78 -4
- package/src/activation.js +235 -0
- package/src/adapter.js +92 -0
- package/src/agent-instruction.d.ts +6 -0
- package/src/agent-instruction.js +17 -0
- package/src/agent-instruction.txt +8 -0
- package/src/apply-shared.js +135 -0
- package/src/comments/commands.js +77 -0
- package/src/comments/geometry.js +65 -0
- package/src/comments/index.d.ts +93 -0
- package/src/comments/index.js +205 -0
- package/src/comments/model.js +359 -0
- package/src/comments/picking.js +154 -0
- package/src/comments/style.js +36 -0
- package/src/comments/view.js +250 -0
- package/src/comments/voice.js +64 -0
- package/src/defaults-dialog.js +120 -0
- package/src/details.js +159 -0
- package/src/editors.js +194 -0
- package/src/export.js +50 -0
- package/src/foreign/adapter.js +166 -0
- package/src/foreign/apply.js +89 -0
- package/src/foreign/entry.js +173 -0
- package/src/foreign/index.d.ts +32 -0
- package/src/foreign/injected.js +6 -0
- package/src/foreign/persist.js +54 -0
- package/src/foreign/properties.js +126 -0
- package/src/foreign/runtime.js +67 -0
- package/src/index.d.ts +204 -0
- package/src/index.js +201 -0
- package/src/inspector-css.js +106 -0
- package/src/inspector.js +342 -0
- package/src/inspector.lino +50 -0
- package/src/messages.js +113 -0
- package/src/model.d.ts +101 -0
- package/src/model.js +473 -0
- package/src/overlay.js +91 -0
- package/src/policy.js +222 -0
- package/src/read-asset.browser.js +8 -0
- package/src/read-asset.js +10 -0
- package/src/session.js +555 -0
- package/src/share.js +23 -0
- package/src/validate.js +170 -0
- package/src/views.js +328 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
CHANGED
|
@@ -1,3 +1,354 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @link-foundation/ui-devmode
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The development/configuration mode of the framework: a runtime inspector over
|
|
4
|
+
any page rendered by [`@link-foundation/ui-dom`](../ui-dom/README.md). You
|
|
5
|
+
hover, select, inspect and edit every element of the page. Edits go only to the
|
|
6
|
+
`session` and `user` layers of
|
|
7
|
+
[`@link-foundation/ui-config`](../ui-config/README.md), never to the site
|
|
8
|
+
document.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { parse } from '@link-foundation/ui-core';
|
|
14
|
+
import { mountDocument } from '@link-foundation/ui-dom';
|
|
15
|
+
import {
|
|
16
|
+
createConfig,
|
|
17
|
+
persistSessionLayer,
|
|
18
|
+
persistUserLayer,
|
|
19
|
+
} from '@link-foundation/ui-config';
|
|
20
|
+
import { mountDevMode } from '@link-foundation/ui-devmode';
|
|
21
|
+
|
|
22
|
+
const root = document.getElementById('app');
|
|
23
|
+
const { store, handle } = mountDocument(root, text, { styles, tokens });
|
|
24
|
+
|
|
25
|
+
const config = createConfig({ document: parse(text) });
|
|
26
|
+
persistUserLayer(config); // restores and keeps the saved edits
|
|
27
|
+
persistSessionLayer(config); // keeps the unsaved edits of this tab
|
|
28
|
+
config.bindStore(store); // the page follows the resolved configuration
|
|
29
|
+
|
|
30
|
+
mountDevMode({
|
|
31
|
+
root,
|
|
32
|
+
config,
|
|
33
|
+
store,
|
|
34
|
+
handle,
|
|
35
|
+
styles,
|
|
36
|
+
tokens,
|
|
37
|
+
animations,
|
|
38
|
+
policy: `(site-dev-mode: dev-mode
|
|
39
|
+
(enabled true)
|
|
40
|
+
(entry shortcut url-parameter element)
|
|
41
|
+
(shortcut 'Alt+Shift+D')
|
|
42
|
+
(write-layers session user)
|
|
43
|
+
(locked-elements payment-form))`,
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`mountDevMode` itself is small: it reads the policy and installs the entry
|
|
48
|
+
points. The overlay, the inspector and the model are loaded with a dynamic
|
|
49
|
+
`import()` the first time dev mode opens. With `(enabled false)` they are never
|
|
50
|
+
requested.
|
|
51
|
+
|
|
52
|
+
External Vite applications can dynamically import
|
|
53
|
+
`@link-foundation/ui-devmode/foreign` and call `mountForeignDevMode()` without
|
|
54
|
+
conversion aliases or source transforms. The inspector layout and agent
|
|
55
|
+
instruction template use static `new URL(..., import.meta.url)` references;
|
|
56
|
+
Vite includes them in production output, including builds hosted at a subpath.
|
|
57
|
+
Native Node ESM still reads these assets from disk.
|
|
58
|
+
|
|
59
|
+
## Opening dev mode
|
|
60
|
+
|
|
61
|
+
| Entry point | How |
|
|
62
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
63
|
+
| `shortcut` | `Alt+Shift+D` (matched on `event.code`, so it works on every layout) toggles dev mode; ignored while typing in a field |
|
|
64
|
+
| `url-parameter` | `?ui-dev` opens dev mode on load (`?ui-dev=false`, `0`, `off`, `no` do not) |
|
|
65
|
+
| `element` | a `<ui-dev-mode></ui-dev-mode>` element in the page opens dev mode |
|
|
66
|
+
|
|
67
|
+
## The site policy
|
|
68
|
+
|
|
69
|
+
The policy is a `dev-mode` link, read with ui-core `parse` (the official
|
|
70
|
+
Links Notation parser):
|
|
71
|
+
|
|
72
|
+
| Property | Default | Meaning |
|
|
73
|
+
| ----------------- | -------------------------------- | ---------------------------------------------------------------------- |
|
|
74
|
+
| `enabled` | `true` | `false` turns dev mode off: no entry point, no inspector module loaded |
|
|
75
|
+
| `entry` | `shortcut url-parameter element` | the entry points that may open dev mode |
|
|
76
|
+
| `shortcut` | `'Alt+Shift+D'` | the key combination |
|
|
77
|
+
| `write-layers` | `session user` | the layers an edit may write; `user` is needed to Save |
|
|
78
|
+
| `locked-elements` | none | element ids that stay read-only, with their descendants |
|
|
79
|
+
|
|
80
|
+
Unknown keys, entry points, layers and values are reported in
|
|
81
|
+
`policy.warnings` and ignored. `defaults`, `theme` and `site` are never
|
|
82
|
+
writable.
|
|
83
|
+
|
|
84
|
+
## The overlay
|
|
85
|
+
|
|
86
|
+
While dev mode is open, the element under the pointer is outlined and labelled
|
|
87
|
+
`id: type` (for example `ok: button`). A click selects it and is not delivered
|
|
88
|
+
to the app. Escape leaves pick mode, so the page works as usual again. A second
|
|
89
|
+
Escape closes dev mode. The boxes come from `getBoundingClientRect`, have
|
|
90
|
+
`pointer-events: none`, and have no transitions under
|
|
91
|
+
`prefers-reduced-motion: reduce`.
|
|
92
|
+
|
|
93
|
+
## The inspector
|
|
94
|
+
|
|
95
|
+
The inspector is docked to the right of the page inside a shadow root. It is
|
|
96
|
+
resizable with the pointer or the arrow keys on its WAI-ARIA window splitter.
|
|
97
|
+
Its layout is [`src/inspector.lino`](src/inspector.lino), rendered by ui-dom.
|
|
98
|
+
It follows `prefers-color-scheme`, and its texts come from a message table
|
|
99
|
+
(`messages` option) that pages can translate.
|
|
100
|
+
|
|
101
|
+
| Tab | Content |
|
|
102
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
103
|
+
| Outline | a WAI-ARIA tree of the elements (`app > body > greeting, ok`); selecting a row selects the element |
|
|
104
|
+
| Properties | a grid `name, editor, resolved value, layer, reset`; changed rows (user or session layer) are marked; locked rows are read-only |
|
|
105
|
+
| Styles | the style rules that match the selected element |
|
|
106
|
+
| Tokens | the tokens the element uses, with their resolved values |
|
|
107
|
+
| Animations | the animations that target the element |
|
|
108
|
+
| Source | the Links Notation of the element |
|
|
109
|
+
|
|
110
|
+
The property editors are typed: text, number, boolean (a checkbox switch), enum
|
|
111
|
+
(select), colour, dimension (number and unit), token reference and read-only
|
|
112
|
+
values (actions).
|
|
113
|
+
|
|
114
|
+
| Action | Effect |
|
|
115
|
+
| ------- | ------------------------------------------------------------------- |
|
|
116
|
+
| edit | writes the `session` layer; the page updates at once |
|
|
117
|
+
| Save | moves the session overrides to the `user` layer, which is persisted |
|
|
118
|
+
| Discard | clears the `session` layer |
|
|
119
|
+
| Reset | removes the value from the highest writable layer that holds it |
|
|
120
|
+
|
|
121
|
+
## Automation
|
|
122
|
+
|
|
123
|
+
While dev mode is open, `globalThis.linkUiDevMode` is
|
|
124
|
+
`{ select(id), getSelection(), setProperty(id, name, value), close() }`.
|
|
125
|
+
`setProperty` writes the session layer and throws a `DevModeError` (with a
|
|
126
|
+
`code`) for a locked element or a bad value. The handle is removed when dev
|
|
127
|
+
mode closes.
|
|
128
|
+
|
|
129
|
+
The pure model is exported as `@link-foundation/ui-devmode/model`
|
|
130
|
+
(`buildOutline`, `propertyRows`, `applyEdit`, `resetProperty`,
|
|
131
|
+
`saveSession`, `discardSession`). `applyEdit` throws for the `site`, `theme`
|
|
132
|
+
and `defaults` layers and for locked elements.
|
|
133
|
+
|
|
134
|
+
## Example
|
|
135
|
+
|
|
136
|
+
`examples/index.html` renders `docs/case-studies/issue-1/samples/document.lino`
|
|
137
|
+
with dev mode. Run `node scripts/serve-static.mjs` and open
|
|
138
|
+
`http://127.0.0.1:4173/packages/ui-devmode/examples/?ui-dev`. Add
|
|
139
|
+
`&policy=disabled` for a disabled policy, or `&lock=ok` to lock an element.
|
|
140
|
+
|
|
141
|
+
## Tests
|
|
142
|
+
|
|
143
|
+
- `tests/*.test.js` (`npm test`) cover the policy, the activation, the model,
|
|
144
|
+
and the whole inspector in jsdom.
|
|
145
|
+
- `e2e/devmode.e2e.mjs` (`npm run test:ui`) covers the acceptance flow in
|
|
146
|
+
Chromium and WebKit: entry points, the lazy loading under a disabled policy,
|
|
147
|
+
pick mode, the outline, the edit, save, reload and reset flow, locked
|
|
148
|
+
elements, and axe.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
[Unlicense](LICENSE)
|
|
153
|
+
|
|
154
|
+
## Make these the defaults and share a preview
|
|
155
|
+
|
|
156
|
+
The inspector's **Make these the defaults** button opens a modal with three
|
|
157
|
+
read-only fields: the LiNo overrides, a share link and an agent instruction.
|
|
158
|
+
Each has a Copy button; blocked clipboard access selects the text for manual
|
|
159
|
+
copy. Escape closes the dialog and returns focus to its button. Links above
|
|
160
|
+
8,192 characters cannot be copied; copy the LiNo field instead.
|
|
161
|
+
|
|
162
|
+
Extend the site's dev-mode policy with these optional fields:
|
|
163
|
+
|
|
164
|
+
```lino
|
|
165
|
+
site-dev-mode: dev-mode
|
|
166
|
+
repository link-foundation/ui
|
|
167
|
+
site-config site/config/site.lino
|
|
168
|
+
comfort-keys motion.mode sound.on sound.volume
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
A valid repository enables a budgeted **Open as GitHub issue** link. Missing
|
|
172
|
+
instruction values are explicit `<unknown repository>` or `<unknown siteConfig>`
|
|
173
|
+
markers. The instruction template is shipped as `src/agent-instruction.txt`.
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
import {
|
|
177
|
+
applySharedOverrides,
|
|
178
|
+
exportOverrides,
|
|
179
|
+
shareUrl,
|
|
180
|
+
parseDevModePolicy,
|
|
181
|
+
} from '@link-foundation/ui-devmode';
|
|
182
|
+
import { renderAgentInstruction } from '@link-foundation/ui-devmode/agent-instruction';
|
|
183
|
+
|
|
184
|
+
const policy = parseDevModePolicy(sitePolicyText);
|
|
185
|
+
const { text, links, count } = exportOverrides(config);
|
|
186
|
+
const { url, tooLong } = shareUrl(window.location, text);
|
|
187
|
+
const instruction = renderAgentInstruction({
|
|
188
|
+
repository: policy.repository,
|
|
189
|
+
siteConfig: policy.siteConfig,
|
|
190
|
+
overrides: text,
|
|
191
|
+
});
|
|
192
|
+
const report = applySharedOverrides({
|
|
193
|
+
config,
|
|
194
|
+
policy,
|
|
195
|
+
location: window.location,
|
|
196
|
+
history: window.history,
|
|
197
|
+
storage: window.localStorage,
|
|
198
|
+
document: window.document,
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Call `applySharedOverrides` after restoring writable layers and binding the
|
|
203
|
+
configuration to the renderer. It validates `#ui-overrides=` text, saves both
|
|
204
|
+
previous writable layers as a **Before the link** LiNo backup under
|
|
205
|
+
`ui-overrides:before-the-link`, overlays accepted changes into `session`,
|
|
206
|
+
removes the hash with `history.replaceState`, and shows the Keep/Discard banner.
|
|
207
|
+
Keep retains the session preview; Discard restores the previous session. User
|
|
208
|
+
and site layers are untouched. If backup storage fails, nothing is applied.
|
|
209
|
+
|
|
210
|
+
For pasted text, pass `text` to the same function; it uses identical validation
|
|
211
|
+
without changing the URL. `validateOverrides(text, { schema, policy })` is also
|
|
212
|
+
available independently. `schema` is a ui-core document or
|
|
213
|
+
`{ document, vocabulary }` for an extended dialect; the apply function defaults
|
|
214
|
+
to `config.effective()`. Include token/theme nodes in that configuration to
|
|
215
|
+
share token edits. Tokens must already exist; their existing scalar value
|
|
216
|
+
determines their type. Actions, unknown targets/properties, invalid values,
|
|
217
|
+
locked elements (including descendants), and declared comfort keys are rejected.
|
|
218
|
+
A comfort key matches a property name, `element.property`, or a token key.
|
|
219
|
+
Rejected links are reported in the banner and never evaluated. Input is limited
|
|
220
|
+
to 65,536 characters and depth 16 through the official parser.
|
|
221
|
+
|
|
222
|
+
`exportOverrides(config, { id, base, layers })` returns `{ text, links, count }`.
|
|
223
|
+
Only `user` and `session` layers are accepted; their effective difference from
|
|
224
|
+
site is sorted by element ID, property and token key. The codec exports
|
|
225
|
+
`encodeShareHash`, `decodeShareHash` (malformed hashes return `null`) and
|
|
226
|
+
`shareUrl` (`{ url, tooLong }`, including the full URL in its budget).
|
|
227
|
+
|
|
228
|
+
The runnable example is `packages/ui-devmode/examples/?ui-dev`.
|
|
229
|
+
`packages/ui-devmode/e2e/defaults.e2e.mjs` covers label editing, share preview,
|
|
230
|
+
Keep/Discard, clipboard fallback, modal keyboard use, axe and URL budgets.
|
|
231
|
+
|
|
232
|
+
## Foreign pages: bookmarklet and extension
|
|
233
|
+
|
|
234
|
+
Dev mode also works on pages that do not use ui-dom. The foreign adapter uses
|
|
235
|
+
`importDom` from ui-convert, keeps node mappings in a WeakMap, and never adds
|
|
236
|
+
mapping attributes to the page. The same inspector lives in a fixed shadow host.
|
|
237
|
+
Pick an element, open Properties, and edit leaf `text`, `attr <name>` or
|
|
238
|
+
`style <property>` rows. Existing attributes and inline declarations are listed;
|
|
239
|
+
`attr title` and `style color` are available even when absent. Arbitrary safe
|
|
240
|
+
properties can also be set with
|
|
241
|
+
`linkUiForeignDevMode.setProperty(id, 'style background-color', '#eef')`.
|
|
242
|
+
Event attributes, script URLs, `srcdoc`, and whole-style attribute writes are
|
|
243
|
+
refused. Text edits cannot replace an element's children. Closed shadow roots
|
|
244
|
+
stay opaque; cross-origin iframe contents are not inspected.
|
|
245
|
+
|
|
246
|
+
Changes write the session configuration layer and are automatically persisted
|
|
247
|
+
per origin and pathname as LiNo under `link-ui-devmode:<origin>:<pathname>`.
|
|
248
|
+
Reopening restores them; Save promotes the session to user and Discard removes
|
|
249
|
+
session edits. Reset restores the previous value, including an absent attribute.
|
|
250
|
+
DOM changes re-import after 200 ms; stable IDs keep their selection. Structural
|
|
251
|
+
IDs may change when siblings are inserted; use existing HTML IDs when possible.
|
|
252
|
+
Copy overrides as LiNo exports one `set` per changed property; Copy subtree as
|
|
253
|
+
LiNo exports the selected live subtree for migration. Clipboard denial presents
|
|
254
|
+
a selected textarea for manual copying. `whenSaved()` waits for pending writes;
|
|
255
|
+
`storageError` and `restoreError` expose unavailable storage or invalid data.
|
|
256
|
+
|
|
257
|
+
Build with `npm run build --workspace @link-foundation/ui-devmode`. It writes
|
|
258
|
+
`dist/foreign.js` (one ES module), `dist/devmode.js` (the extension bundle) and
|
|
259
|
+
`dist/bookmarklet.txt`. Set `UI_DEVMODE_BUNDLE_URL=https://your-host/foreign.js`
|
|
260
|
+
at build time to configure the bookmarklet loader. Host the ES module with a
|
|
261
|
+
JavaScript content type and CORS permission for the inspected origin. The default
|
|
262
|
+
URL reserves the future documentation hosting location; self-host the bundle
|
|
263
|
+
until that location is deployed. Drag a bookmark whose URL is the contents of
|
|
264
|
+
`bookmarklet.txt` into the bookmarks bar, then click it on the page to toggle.
|
|
265
|
+
|
|
266
|
+
**Strict Content Security Policy (CSP) blocks the bookmarklet**, including the
|
|
267
|
+
loader or its module request. Use the browser extension on these pages. The
|
|
268
|
+
`tests/fixtures/foreign-csp.html` fixture checks this with `script-src 'none'`.
|
|
269
|
+
The extension injects a packaged script in Chrome's isolated world and uses
|
|
270
|
+
`chrome.storage.local`; it does not fetch executable code from the web.
|
|
271
|
+
See [extension instructions](../ui-devmode-extension/README.md). Restricted
|
|
272
|
+
browser pages cannot be inspected. No Firefox support is claimed.
|
|
273
|
+
|
|
274
|
+
For programmatic use, import `mountForeignDevMode` from
|
|
275
|
+
`@link-foundation/ui-devmode/foreign`; pass an optional `window`, inspector
|
|
276
|
+
`layout` LiNo, or async `{ getItem, setItem }` storage wrapper. The returned
|
|
277
|
+
controller supports select, exportOverrides, exportSubtree, close/toggle and
|
|
278
|
+
async destroy. Repeated mounting toggles the existing controller.
|
|
279
|
+
|
|
280
|
+
## Comment on the UI
|
|
281
|
+
|
|
282
|
+
Press **Comment on UI** in the inspector to open per-object change requests.
|
|
283
|
+
Pick an object, add/remove objects with Shift/Ctrl/Cmd, draw a freehand **Lasso**,
|
|
284
|
+
or select checkboxes with the keyboard. Type an instruction or press **Start
|
|
285
|
+
voice input**, review its transcript, and press **Add tasks**. Each selected
|
|
286
|
+
object gets an independent task. Open tasks appear in anchored comment bubbles
|
|
287
|
+
and the task panel; edit and save their instructions, resolve/reopen, or delete
|
|
288
|
+
them. Escape cancels a gesture, then leaves picking, then closes comments.
|
|
289
|
+
Closing comments returns to the inspector. Closing dev mode cleans up both.
|
|
290
|
+
|
|
291
|
+
**Export LiNo** fills the handoff field; **Copy LiNo** uses the clipboard or
|
|
292
|
+
selects the text for manual copying. Paste a review and press **Import LiNo**
|
|
293
|
+
to replace it after validation. Requests include exact canonical UI snapshots,
|
|
294
|
+
per-object target IDs, input method, status and ordered create/update/remove
|
|
295
|
+
history. `current`, `outdated` and `missing` indicators prevent stale requests
|
|
296
|
+
from looking current. Comments never execute patches or change the app.
|
|
297
|
+
The [format specification](../../docs/spec/comments.md) describes all fields,
|
|
298
|
+
validation, budgets and agent consumption.
|
|
299
|
+
|
|
300
|
+
The review persists as LiNo in localStorage under
|
|
301
|
+
`ui-comments:<pathname>` by default. `commentOptions` passed to `mountDevMode`
|
|
302
|
+
can set `storage` (`null` disables persistence), `storageKey`, initial `text`,
|
|
303
|
+
`messages` (English text to translation) and `trace(event, detail)` (off by
|
|
304
|
+
default). Multiple mounts on one path should use distinct keys. Storage errors
|
|
305
|
+
remain visible and leave in-memory tasks exportable. Imported reviews may refer
|
|
306
|
+
to older UI; the panel retains them and marks them accordingly. Comments can
|
|
307
|
+
refer to locked elements without changing the site's editing permissions.
|
|
308
|
+
|
|
309
|
+
The same panel works with the foreign-page bookmarklet/extension and the
|
|
310
|
+
WYSIWYG designer. A custom renderer with a stable-ID tree can mount it directly:
|
|
311
|
+
|
|
312
|
+
```js
|
|
313
|
+
import { mountComments } from '@link-foundation/ui-devmode/comments';
|
|
314
|
+
|
|
315
|
+
const comments = mountComments({
|
|
316
|
+
root,
|
|
317
|
+
tree: store,
|
|
318
|
+
nodeFor: (id) => handle.nodeFor(id),
|
|
319
|
+
storageKey: 'my-page.comments',
|
|
320
|
+
});
|
|
321
|
+
comments.select(['ok', 'greeting']);
|
|
322
|
+
comments.model.add(comments.selection(), 'Make this easier to understand');
|
|
323
|
+
const handoff = comments.model.export();
|
|
324
|
+
comments.destroy();
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
The pure exports are `createComments({ getDocument, text?, trace? })`,
|
|
328
|
+
`readComments(text)`, `commentDocument(tree)`, `COMMENT_LIMITS` and `lasso`.
|
|
329
|
+
The model exposes `tasks`, `revisions`, `events`, `add`, `update`, `remove`,
|
|
330
|
+
`state`, `export`, `import` and `subscribe`. Returned lists are copies.
|
|
331
|
+
`commentDocument` creates a named snapshot from a store-shaped tree. The mount
|
|
332
|
+
also exposes `host`, `tree`, `select`, `selection`, `refresh` and `destroy`.
|
|
333
|
+
Pass `observe` for adapters whose change subscription is separate from `tree`.
|
|
334
|
+
All model operations are synchronous and deterministic.
|
|
335
|
+
|
|
336
|
+
Voice input uses an optional browser service only after Start; availability,
|
|
337
|
+
permissions, language support and service connectivity depend on the browser.
|
|
338
|
+
The page language selects recognition language. Text entry remains available
|
|
339
|
+
when recognition is absent or denied; no microphone or service is required for
|
|
340
|
+
the rest of the workflow.
|
|
341
|
+
|
|
342
|
+

|
|
343
|
+
|
|
344
|
+
Tests: `node --test packages/ui-devmode/tests/comments*.test.js` and
|
|
345
|
+
`npx playwright test packages/ui-devmode/e2e/comments.e2e.mjs --workers=1`.
|
|
346
|
+
The browser suite covers text/voice tasks, freehand gestures, validation,
|
|
347
|
+
persistence, designer integration, and light/dark WCAG 2.2 AA. Set
|
|
348
|
+
`COMMENT_SCREENSHOTS=1` to refresh the two Chromium documentation images.
|
|
349
|
+
|
|
350
|
+
Foreign-page comments use the same storage channel as overrides, with a separate
|
|
351
|
+
origin/path key: local storage for a bookmarklet, `chrome.storage.local` in the
|
|
352
|
+
extension. `whenSaved()` waits for both writes; asynchronous storage failures
|
|
353
|
+
appear in the panel and `storageError`. Comment source snapshots retain the
|
|
354
|
+
imported page IDs and never apply DOM edits.
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@link-foundation/ui-devmode",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Development/configuration mode of the associative UI framework: a runtime inspector overlay over any page rendered by ui-dom, to hover, select, inspect and edit every element, writing only to the session and user configuration layers",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"default": "./src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./comments": {
|
|
12
|
+
"types": "./src/comments/index.d.ts",
|
|
13
|
+
"default": "./src/comments/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./views": "./src/views.js",
|
|
16
|
+
"./overlay": "./src/overlay.js",
|
|
17
|
+
"./model": {
|
|
18
|
+
"types": "./src/model.d.ts",
|
|
19
|
+
"default": "./src/model.js"
|
|
20
|
+
},
|
|
21
|
+
"./agent-instruction": {
|
|
22
|
+
"types": "./src/agent-instruction.d.ts",
|
|
23
|
+
"default": "./src/agent-instruction.js"
|
|
24
|
+
},
|
|
25
|
+
"./foreign": {
|
|
26
|
+
"types": "./src/foreign/index.d.ts",
|
|
27
|
+
"default": "./src/foreign/entry.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"types": "./src/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"src/",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"dist/"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"ui",
|
|
39
|
+
"links-notation",
|
|
40
|
+
"devtools",
|
|
41
|
+
"inspector",
|
|
42
|
+
"configuration"
|
|
43
|
+
],
|
|
44
|
+
"license": "Unlicense",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/link-foundation/ui.git",
|
|
48
|
+
"directory": "packages/ui-devmode"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/link-foundation/ui/tree/main/packages/ui-devmode#readme",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/link-foundation/ui/issues"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@link-foundation/ui-config": "^0.0.0",
|
|
59
|
+
"@link-foundation/ui-convert": "^0.0.0",
|
|
60
|
+
"@link-foundation/ui-core": "^0.0.0",
|
|
61
|
+
"@link-foundation/ui-dom": "^0.0.0",
|
|
62
|
+
"@link-foundation/ui-style": "^0.0.0",
|
|
63
|
+
"@link-foundation/ui-tokens": "^0.0.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@link-foundation/ui-store": "^0.0.0",
|
|
67
|
+
"jsdom": "^30.1.3",
|
|
68
|
+
"test-anywhere": "^0.8.48",
|
|
69
|
+
"vite": "^7.3.7"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "node scripts/build-bookmarklet.mjs"
|
|
76
|
+
},
|
|
77
|
+
"browser": {
|
|
78
|
+
"./src/read-asset.js": "./src/read-asset.browser.js"
|
|
79
|
+
}
|
|
80
|
+
}
|