@luci-dev/toolbar 0.0.0-stage → 0.5.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 +21 -0
- package/README.md +68 -2
- package/dist/devToolbar.d.ts +55 -0
- package/dist/devToolbar.d.ts.map +1 -0
- package/dist/devToolbar.js +475 -0
- package/dist/devToolbar.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/luci-toolbar.js +37593 -0
- package/dist/script.d.ts +9 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +16 -0
- package/dist/script.js.map +1 -0
- package/package.json +25 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Luci dev toolbar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Luci inside your own app while you develop it: leave notes on the running app for your coding agent (Feedback), or capture components, text, colors and spacing (Capture). Notes and saved captures go into the project's `.luci/` folder, where the agent reads them through `luci-mcp`.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
1. In your app's folder: `luci init` (once). It asks **Add Luci's dev toolbar to your app?**; press Enter.
|
|
8
|
+
2. `luci serve`, then open your app on this machine. Luci's button is in the bottom corner.
|
|
9
|
+
|
|
10
|
+
Missed it, or said no? `luci serve` asks again while the toolbar is not in the app, and `luci toolbar` adds it any time. Or ask your agent to add Luci's dev toolbar: the project's agent files tell it to run `luci toolbar`.
|
|
11
|
+
|
|
12
|
+
What it adds: a few lines between `luci:toolbar` comments, before `</body>` of the app's root file (Next.js `app/layout` or `pages/_document`, SvelteKit `src/app.html`, an Astro layout, or `index.html` for Vite, Create React App, Angular and plain sites). The loader only runs on `localhost` (Next.js: in development), so a deployed site is unchanged and nothing is installed. `luci toolbar remove` takes it out again; `luci toolbar --dry-run` shows what it would add. Without a root file Luci knows, add the line yourself:
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<script src="http://127.0.0.1:4545/toolbar.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. Optional: connect your agent to `luci-mcp` (for example `claude mcp add luci -- node <luci>/packages/mcp/dist/bin.js`), so it can read the notes and saved captures itself. Copying the prompt works without it.
|
|
19
|
+
|
|
20
|
+
`luci serve` listens on 127.0.0.1 only and answers pages on this machine only. Without it, the toolbar still works: notes stay in this browser (for this app's address) and the prompt can be copied. The **This browser** badge says why it is not connected; click it after starting `luci serve`.
|
|
21
|
+
|
|
22
|
+
## Feedback
|
|
23
|
+
|
|
24
|
+
- **Annotate:** click an element, write what should change, choose the intent (fix, change, question, approve) and priority. Hover shows the element and its component (React, Vue or Svelte). Esc stops.
|
|
25
|
+
- **Text:** select words on the page (outside Annotate) and press **Add feedback**.
|
|
26
|
+
- **Markers:** each note is a numbered marker on its element: filled when new, outlined once copied, green with ✓ when you marked it done. Click one to **Mark done** (or **Reopen**), edit it (text, intent and priority) or delete it.
|
|
27
|
+
- **Copy prompt:** the notes as one prompt, grouped by page with stable IDs (`P2-A3`) and a request to report every ID. It copies the new notes (**Copy prompt (2 new)**), or every note not done yet when all were copied before (**Copy prompt (all 4)**); **▾** chooses. Paste it to your agent and read its report.
|
|
28
|
+
- **You decide what is done:** no agent changes your notes. After checking the agent's work, mark notes done one by one, or press **Mark all copied as done** in Notes. Over MCP, the agent can only read the notes (`list_feedback`, `get_feedback_prompt`).
|
|
29
|
+
- **Watch mode:** ask your agent to "watch for my feedback". It calls `watch_feedback`, which waits until you add notes, gives it only the new ones as one prompt, and is called again for the next batch. Your notes stay New until you copy or mark them.
|
|
30
|
+
- **Notes:** every note, page by page, with tabs **Not done · Done · All**. Open a row for its file and line, components and actions; **Clear done** removes the notes you marked done. **Delete all notes** is under ⚙.
|
|
31
|
+
- **Pause:** freezes the page's animations, transitions and videos on the current frame.
|
|
32
|
+
- **Settings:** marker color, prompt detail (compact: selector and text; standard: + source file and components; detailed: + computed styles), and an optional webhook that receives the prompt and the items when you press **Send to webhook**.
|
|
33
|
+
|
|
34
|
+
With React, Vue 3 or Svelte 4/5 in development mode, each note records the components around the element (`App > Pricing > PlanCard`) and its source file (with the JSX line through source maps in React, the `.svelte` file and line from `__svelte_meta` in Svelte, and the `.vue` SFC file from `__vueParentComponent` in Vue 3). In a production build, notes keep the selector and text.
|
|
35
|
+
|
|
36
|
+
## Modes
|
|
37
|
+
|
|
38
|
+
The switch first in the bar, **Feedback · Layout · Capture**, is in the same place in every mode. The bar sits at the bottom of the window, in the corner of Luci's button (right, or left with **Dock: Left**), and grows out of the button when you open it. While nothing in a mode is active, a card above the bar says what the mode is for and its keys.
|
|
39
|
+
|
|
40
|
+
## Layout
|
|
41
|
+
|
|
42
|
+
Try layout changes on the live page, then copy them as one prompt for your agent.
|
|
43
|
+
|
|
44
|
+
- **Select** an element (**↑ Parent** takes the one around it). Drag any of its 8 handles (sides and corners) to resize it, on the side you drag (the left handle grows it to the left and keeps its right edge where it is, even when the page centers it), or the **⠿** grip above it to move it among its neighbors; a pink line shows where it lands. Orange and green show its margin and padding.
|
|
45
|
+
- **Size:** width, height, min and max width and height. These are sizes on screen, border and padding included. Type a number (px) or `none`, `auto`, `50%`, `20rem`.
|
|
46
|
+
- **Spacing:** margin and padding for each side, with − and +; 🔗 changes all four sides together.
|
|
47
|
+
- **Layout of its children:** display (block, flex, grid, inline…); for flex, direction and wrap; for grid, the number of equal columns; justify, align, row gap and column gap.
|
|
48
|
+
- **In its parent** (when the parent is flex or grid): align self, grow, shrink.
|
|
49
|
+
- Values snap to the page's spacing scale and show the custom property that has the value (`--space-6`).
|
|
50
|
+
- Changes show on the real page at once. A move really reorders in a flex or grid container, and shifts into place in a top-to-bottom stack; when neither is possible, the prompt still says where it goes. **Undo**, **Redo** (Ctrl+Z, Ctrl+Shift+Z) and **Reset** put things back. Luci never moves your app's DOM, so your app keeps working.
|
|
51
|
+
- **Insert** adds a new part: **your components** found on the page (from React, Vue or Svelte, most used first: "another PlanCard"), **saved captures** from `.luci/design/` (with `luci serve`), or a **block** (section, heading, text, button, image slot, card, card grid, navigation, footer, form field). Then click where it goes: near an element's top or bottom edge (left or right in a row) puts it before or after; the middle of a section, card or list puts it inside, at the end. With an element selected, **Before**, **After**, **Inside, start** and **Inside, end** place it next to that one. The new part is a dashed placeholder Luci draws (never put into your app's DOM); its neighbors shift to make room, and a top-to-bottom parent grows. Select it to say **what goes in it**, resize it with its handles or the size fields (**Full width** in a top-to-bottom stack), move it with **⠿**, or remove it (**Remove**, or Delete).
|
|
52
|
+
- **New page** sketches a page that does not exist yet, on a canvas over your app: type its route, then build it from rows top to bottom. Click a part to **choose what it is** (your component, a saved capture or a block; or leave it an area), say **what goes in it**, **split it in two**, or remove it. Drag a row's bottom handle to change its height (snapped to the page's scale) and the line between two parts to share the width. **+ Row**, **+ Row below**, **Move up**/**down**, **Undo**/**Redo** (Ctrl+Z). **Copy page prompt** gives the agent numbered parts top to bottom; **Add to Feedback notes** keeps the sketch as a note. **Back to the page** (or Esc) closes it.
|
|
53
|
+
- **Copy prompt:** every planned change on the page, element by element, with your note, in one prompt to paste to your agent. The page then goes back as it is in your code, and Luci says why: Layout mode only previews, and your code has not changed until your agent edits it. **Add to Feedback notes** keeps the plan as notes instead, to send with other notes in one multi-page prompt.
|
|
54
|
+
|
|
55
|
+
## Capture
|
|
56
|
+
|
|
57
|
+
**Capture** shows the capture tools of the browser extension (Component, Text, Color, Spacing, Whole page, Check, Basket). **Save to project** writes a file, or a basket export, into `.luci/design/`; the agent lists them with `list_captures`.
|
|
58
|
+
|
|
59
|
+
**How it changes by width** (v0.3, after a component or section capture) reads it at 2 or 3 widths from your site's own media queries and adds a **Responsive** table to the file. The dev toolbar loads the page in a hidden frame of each width (your app runs there for a moment; the toolbar itself does not start inside it), so the page must allow being framed by itself, as dev servers do.
|
|
60
|
+
|
|
61
|
+
**Make it a rule** (v0.3, after a component capture) saves the capture into the project and proposes a rule in `.luci/memory/proposed/`: one line for `.luci/rules.md`, "Build every primary button like `.luci/design/<file>`: ...", with its key values and state changes. To keep it, move the line into `rules.md` (Luci never edits it). The same works from the command line, `luci capture rule <file>`, and for your agent over MCP, `propose_capture_rule`.
|
|
62
|
+
|
|
63
|
+
**Automatic check** (v0.4): after a check, the dev toolbar checks the built component again whenever the page changes (your agent's edit reloads it), says what changed (`Checked again at 14:02: 1 difference (was 3).`) and keeps checking after a reload of the tab. Each run goes to the project, where your agent reads it with `get_design_checks`, so it can fix, let the page reload, and see whether the component now matches. **Check again when the page changes** switches it.
|
|
64
|
+
|
|
65
|
+
**DESIGN.md for Google Stitch**: set **File** to **DESIGN.md (Stitch)** to copy, download and export captures in the open DESIGN.md format (tokens, then prose filled in from measured values); **Save to project** keeps Luci's tables. `luci capture baseline --stitch` writes your project's own DESIGN.md.
|
|
66
|
+
|
|
67
|
+
**Use my tokens**, **Compare** and **Image** (v0.4): under any capture, **Use my tokens** rewrites it onto your project's own tokens (read from its stylesheets through `luci serve`) or tokens you paste; in the basket, tick two items to **Compare** them; the Colour tool's **Image** estimates a palette from a screenshot. Your project's own typography, colors and spacing are also in `.luci/design/project.system.*.design.md` (the design baseline, `luci capture baseline`).
|
|
68
|
+
|
|
69
|
+
**Check** (v0.3) compares a component you (or your agent) built with its design file. Choose the design from the project's `.luci/design/` (read through `luci serve`), the basket or a pasted file; click the built component and press **Check against the design**. Luci captures it the same way and lists what matches and each difference. **Add as feedback notes** pins the ticked differences on the built element as Feedback notes (intent fix, each with the design file, part, property, what the design says and what was built), saved in the project with `luci serve` (else in this browser); they go into the page-grouped prompt and `watch_feedback` like any note. **Copy as a prompt** copies them instead.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dev toolbar (M6): Luci in your own app while you develop it. Two modes in one bar: Feedback
|
|
3
|
+
* (annotate the app for your agent) and Capture (the extension's tools, with "Save to project").
|
|
4
|
+
* With `luci serve` running in the project, feedback and saved captures go to .luci/, where the
|
|
5
|
+
* agent reads them through luci-mcp; without it, feedback stays in this browser and the bar says
|
|
6
|
+
* how to connect.
|
|
7
|
+
*/
|
|
8
|
+
import { type BasketStore, type CheckNote } from '@luci-dev/capture';
|
|
9
|
+
import { type FeedbackBackend, type KeyValue } from '@luci-dev/feedback';
|
|
10
|
+
export declare const DEFAULT_BRIDGE = "http://127.0.0.1:4545";
|
|
11
|
+
export declare const LAUNCHER_TAG = "luci-launcher";
|
|
12
|
+
export type Mode = 'feedback' | 'layout' | 'capture';
|
|
13
|
+
/** The modes, as the switch shows them. */
|
|
14
|
+
export declare const MODES: readonly [{
|
|
15
|
+
readonly id: 'feedback';
|
|
16
|
+
readonly label: 'Feedback';
|
|
17
|
+
readonly title: 'Feedback: leave notes on your app for your coding agent';
|
|
18
|
+
}, {
|
|
19
|
+
readonly id: 'layout';
|
|
20
|
+
readonly label: 'Layout';
|
|
21
|
+
readonly title: 'Layout: resize, move and space elements on the live page, then send the plan to your agent';
|
|
22
|
+
}, {
|
|
23
|
+
readonly id: 'capture';
|
|
24
|
+
readonly label: 'Capture';
|
|
25
|
+
readonly title: 'Capture: take a component, text, color or spacing as a design file';
|
|
26
|
+
}];
|
|
27
|
+
export interface DevToolbarOptions {
|
|
28
|
+
/** The `luci serve` address. Default: the one the script was served from, else http://127.0.0.1:4545. */
|
|
29
|
+
bridge?: string;
|
|
30
|
+
doc?: Document;
|
|
31
|
+
/** Where settings, the basket and (without the bridge) feedback are kept. Default: localStorage. */
|
|
32
|
+
storage?: KeyValue;
|
|
33
|
+
/** The mode to open in (default: the last one used in this tab, else Feedback). */
|
|
34
|
+
mode?: Mode;
|
|
35
|
+
}
|
|
36
|
+
export interface DevToolbarHandle {
|
|
37
|
+
readonly backend: FeedbackBackend;
|
|
38
|
+
/** Check for `luci serve` again; null when connected, else why not. */
|
|
39
|
+
connect(): Promise<string | null>;
|
|
40
|
+
mode(): Mode;
|
|
41
|
+
show(mode: Mode): void;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
/** The basket in the app's storage, so it survives reloads and pages of the app. */
|
|
45
|
+
export declare function storageBasket(storage: KeyValue, key?: string): BasketStore;
|
|
46
|
+
/**
|
|
47
|
+
* A design check's differences as feedback notes on the built component (intent fix): one note per
|
|
48
|
+
* difference, each with what the design says and what was built, so the page-grouped prompt and
|
|
49
|
+
* watch_feedback carry them like any note. Returns their IDs.
|
|
50
|
+
*/
|
|
51
|
+
export declare function addCheckNotes(backend: FeedbackBackend, doc: Document, el: Element, notes: readonly CheckNote[]): Promise<string[]>;
|
|
52
|
+
export declare const CONNECTING_TAG = "luci-connecting";
|
|
53
|
+
/** Mount the dev toolbar once per page. */
|
|
54
|
+
export declare function mountDevToolbar(options?: DevToolbarOptions): Promise<DevToolbarHandle>;
|
|
55
|
+
//# sourceMappingURL=devToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devToolbar.d.ts","sourceRoot":"","sources":["../src/devToolbar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEU,KAAK,WAAW,EAAE,KAAK,SAAS,EAChD,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EASL,KAAK,eAAe,EAEpB,KAAK,QAAQ,EACd,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,cAAc,0BAA0B,CAAC;AACtD,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAC5C,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AACrD,2CAA2C;AAC3C,eAAO,MAAM,KAAK;aACd,EAAE,EAAE,UAAU;aAAE,KAAK,EAAE,UAAU;aAAE,KAAK,EAAE,yDAAyD;;aACnG,EAAE,EAAE,QAAQ;aAAE,KAAK,EAAE,QAAQ;aAAE,KAAK,EAAE,4FAA4F;;aAClI,EAAE,EAAE,SAAS;aAAE,KAAK,EAAE,SAAS;aAAE,KAAK,EAAE,oEAAoE;EACtG,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,yGAAyG;IACzG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,oGAAoG;IACpG,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,mFAAmF;IACnF,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,uEAAuE;IACvE,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,OAAO,IAAI,IAAI,CAAC;CACjB;AAoBD,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAE,MAAoB,GAAG,WAAW,CAYvF;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOxI;AAED,eAAO,MAAM,cAAc,oBAAoB,CAAC;AA0BhD,2CAA2C;AAC3C,wBAAsB,eAAe,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0VhG"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dev toolbar (M6): Luci in your own app while you develop it. Two modes in one bar: Feedback
|
|
3
|
+
* (annotate the app for your agent) and Capture (the extension's tools, with "Save to project").
|
|
4
|
+
* With `luci serve` running in the project, feedback and saved captures go to .luci/, where the
|
|
5
|
+
* agent reads them through luci-mcp; without it, feedback stays in this browser and the bar says
|
|
6
|
+
* how to connect.
|
|
7
|
+
*/
|
|
8
|
+
import { LUCI_UI_ATTRIBUTE, TOOLBAR_REPLACE_EVENT, UI_PREFS_EVENT, mountToolbar, readUiPrefs, writeUiPrefs } from '@luci-dev/capture';
|
|
9
|
+
import { basketItemSchema } from '@luci-dev/format/capture';
|
|
10
|
+
import { ANIMATIONS_CSS, COPY, TOKENS_CSS, mascotSvg } from '@luci-dev/ui';
|
|
11
|
+
import { DEFAULT_FEEDBACK_SETTINGS, bridgeBackend, bridgeReachable, browserBackend, describeTarget, mountFeedback, mountLayout } from '@luci-dev/feedback';
|
|
12
|
+
export const DEFAULT_BRIDGE = 'http://127.0.0.1:4545';
|
|
13
|
+
export const LAUNCHER_TAG = 'luci-launcher';
|
|
14
|
+
/** The modes, as the switch shows them. */
|
|
15
|
+
export const MODES = [
|
|
16
|
+
{ id: 'feedback', label: 'Feedback', title: 'Feedback: leave notes on your app for your coding agent' },
|
|
17
|
+
{ id: 'layout', label: 'Layout', title: 'Layout: resize, move and space elements on the live page, then send the plan to your agent' },
|
|
18
|
+
{ id: 'capture', label: 'Capture', title: 'Capture: take a component, text, color or spacing as a design file' }
|
|
19
|
+
];
|
|
20
|
+
const KEYS = { capture: 'luci.capture.settings', feedback: 'luci.feedback.settings', basket: 'luci.basket', items: 'luci.feedback', mode: 'luci.mode', myTokens: 'luci.myTokens' };
|
|
21
|
+
/** localStorage, or memory when the page cannot use it (a sandboxed frame, privacy settings). */
|
|
22
|
+
function defaultStorage(win) {
|
|
23
|
+
try {
|
|
24
|
+
const s = win.localStorage;
|
|
25
|
+
s.getItem(KEYS.mode);
|
|
26
|
+
return s;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
const m = new Map();
|
|
30
|
+
return { getItem: k => m.get(k) ?? null, setItem: (k, v) => { m.set(k, v); } };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const readJson = (storage, key, fallback) => {
|
|
34
|
+
try {
|
|
35
|
+
return { ...fallback, ...(JSON.parse(storage.getItem(key) ?? 'null') ?? {}) };
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return fallback;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** The basket in the app's storage, so it survives reloads and pages of the app. */
|
|
42
|
+
export function storageBasket(storage, key = KEYS.basket) {
|
|
43
|
+
return {
|
|
44
|
+
load: async () => {
|
|
45
|
+
try {
|
|
46
|
+
const raw = JSON.parse(storage.getItem(key) ?? '[]');
|
|
47
|
+
return raw.flatMap(r => { const p = basketItemSchema.safeParse(r); return p.success ? [p.data] : []; });
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
save: async (items) => storage.setItem(key, JSON.stringify(items))
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A design check's differences as feedback notes on the built component (intent fix): one note per
|
|
58
|
+
* difference, each with what the design says and what was built, so the page-grouped prompt and
|
|
59
|
+
* watch_feedback carry them like any note. Returns their IDs.
|
|
60
|
+
*/
|
|
61
|
+
export async function addCheckNotes(backend, doc, el, notes) {
|
|
62
|
+
const { target, pageSource } = await describeTarget(el, backend.resolveFrames ? { serverResolve: backend.resolveFrames } : {});
|
|
63
|
+
const page = { url: doc.location.href, title: doc.title, ...(pageSource ? { source: pageSource } : {}) };
|
|
64
|
+
const refs = [];
|
|
65
|
+
// One after another: each note's ID is the next on this page
|
|
66
|
+
for (const n of notes)
|
|
67
|
+
refs.push((await backend.add({ page, target, comment: n.comment, intent: 'fix', priority: n.priority, check: n.check })).ref);
|
|
68
|
+
return refs;
|
|
69
|
+
}
|
|
70
|
+
export const CONNECTING_TAG = 'luci-connecting';
|
|
71
|
+
/** Keep at least this much of the window between a dragged bar and its edges. */
|
|
72
|
+
const EDGE = 8;
|
|
73
|
+
const clamp = (v, min, max) => Math.max(min, Math.min(v, Math.max(min, max)));
|
|
74
|
+
/** CSS that puts something in a place's corner (the launcher, the connecting pill), never off screen. */
|
|
75
|
+
const cornerCss = (p, size) => `${p.h}:min(${p.x}px, calc(100vw - ${size + EDGE}px));${p.v}:min(${p.y}px, calc(100vh - ${size + EDGE}px))`;
|
|
76
|
+
/** "Connecting to your project…" with a spinner, where the bar will appear. */
|
|
77
|
+
function connectingPill(doc, place) {
|
|
78
|
+
const host = doc.createElement(CONNECTING_TAG);
|
|
79
|
+
host.setAttribute(LUCI_UI_ATTRIBUTE, '');
|
|
80
|
+
const root = host.attachShadow({ mode: 'open' });
|
|
81
|
+
// The Charcoal pill (brand/DESIGN.md, On-page toolbar), with a ginger ring turning
|
|
82
|
+
root.innerHTML = `<style>${TOKENS_CSS}
|
|
83
|
+
div{position:fixed;${cornerCss(place, 40)};z-index:2147483647;display:flex;gap:8px;align-items:center;padding:8px 16px 8px 12px;border-radius:var(--luci-radius-full);
|
|
84
|
+
background:var(--luci-color-bar);color:var(--luci-color-bar-ink);font:500 var(--luci-type-small-size)/var(--luci-type-small-line) var(--luci-font-body);box-shadow:var(--luci-shadow-float)}
|
|
85
|
+
i{width:14px;height:14px;border-radius:50%;border:2px solid var(--luci-color-bar-stroke);border-top-color:var(--luci-color-tool-active);animation:s .8s linear infinite}
|
|
86
|
+
@keyframes s{to{transform:rotate(360deg)}}
|
|
87
|
+
@media (prefers-reduced-motion: reduce){i{animation:none}}
|
|
88
|
+
</style><div role="status" aria-live="polite" data-part="connecting"><i aria-hidden="true"></i><span>${COPY.devToolbar.connecting}</span></div>`;
|
|
89
|
+
doc.documentElement.appendChild(host);
|
|
90
|
+
return host;
|
|
91
|
+
}
|
|
92
|
+
/** Mount the dev toolbar once per page. */
|
|
93
|
+
export async function mountDevToolbar(options = {}) {
|
|
94
|
+
const doc = options.doc ?? document;
|
|
95
|
+
const win = doc.defaultView ?? window;
|
|
96
|
+
const storage = options.storage ?? defaultStorage(win);
|
|
97
|
+
const bridge = (options.bridge ?? win.__LUCI_BRIDGE__ ?? DEFAULT_BRIDGE).replace(/\/+$/, '');
|
|
98
|
+
const noteFor = (h) => (h.ok
|
|
99
|
+
? `luci serve is running, but ${h.project ?? 'its folder'} has no .luci/ yet: run \`luci init\` there. Until then, notes stay in this browser.`
|
|
100
|
+
: `Not connected to your project (${bridge}: ${h.reason ?? 'no answer'}). Run \`luci serve\` in it to save notes where your agent reads them, then click here. Until then, they stay in this browser.`);
|
|
101
|
+
/*
|
|
102
|
+
* Where the bar is: its dock's bottom corner by default (next to Luci's button), or where the person
|
|
103
|
+
* dragged it (kept in the UI preferences as devPlace: the nearest corner and the distances from its
|
|
104
|
+
* edges). Each mode's host gets data-h, data-v, --luci-x and --luci-y; the shared styles place the bar
|
|
105
|
+
* and open its cards from there, on the side with room.
|
|
106
|
+
*/
|
|
107
|
+
const homePlace = () => ({ h: readUiPrefs(doc).dock === 'left' ? 'left' : 'right', v: 'bottom', x: 12, y: 12 });
|
|
108
|
+
let place = readUiPrefs(doc).devPlace ?? homePlace();
|
|
109
|
+
// The bar's place says what Luci is doing while it looks for `luci serve` (up to a few seconds)
|
|
110
|
+
const connecting = connectingPill(doc, place);
|
|
111
|
+
let health;
|
|
112
|
+
try {
|
|
113
|
+
health = await bridgeReachable(bridge);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
connecting.remove();
|
|
117
|
+
}
|
|
118
|
+
let connected = health.ok && health.initialized;
|
|
119
|
+
let backend = connected ? bridgeBackend(bridge) : browserBackend(storage, KEYS.items);
|
|
120
|
+
let connectNote = noteFor(health);
|
|
121
|
+
if (!connected)
|
|
122
|
+
console.info(`Luci: ${connectNote}`);
|
|
123
|
+
/** Check again (the person started luci serve): switch to the project when it answers. */
|
|
124
|
+
const connect = async () => {
|
|
125
|
+
const h = await bridgeReachable(bridge, { attempts: 1 });
|
|
126
|
+
connectNote = noteFor(h);
|
|
127
|
+
if (!(h.ok && h.initialized))
|
|
128
|
+
return connectNote;
|
|
129
|
+
connected = true;
|
|
130
|
+
backend = bridgeBackend(bridge);
|
|
131
|
+
show(mode);
|
|
132
|
+
return null;
|
|
133
|
+
};
|
|
134
|
+
let session = null;
|
|
135
|
+
try {
|
|
136
|
+
session = win.sessionStorage;
|
|
137
|
+
}
|
|
138
|
+
catch { /* not available */ }
|
|
139
|
+
let mode = options.mode ?? (session?.getItem(KEYS.mode) ?? 'feedback');
|
|
140
|
+
let current = null;
|
|
141
|
+
let launcher = null;
|
|
142
|
+
const removeLauncher = () => { launcher?.remove(); launcher = null; };
|
|
143
|
+
const showLauncher = () => {
|
|
144
|
+
removeLauncher();
|
|
145
|
+
launcher = doc.createElement(LAUNCHER_TAG);
|
|
146
|
+
launcher.setAttribute(LUCI_UI_ATTRIBUTE, '');
|
|
147
|
+
const root = launcher.attachShadow({ mode: 'open' });
|
|
148
|
+
// Luci's head in a Ginger circle: the 48 px menu button (brand/DESIGN.md, On-page toolbar), in the
|
|
149
|
+
// corner of the bar's place, where the bar grows from
|
|
150
|
+
root.innerHTML = `<style>${TOKENS_CSS}${ANIMATIONS_CSS}
|
|
151
|
+
button{position:fixed;${cornerCss(place, 48)};z-index:2147483647;display:flex;align-items:center;justify-content:center;width:48px;height:48px;padding:0;border:0;
|
|
152
|
+
border-radius:var(--luci-radius-full);background:var(--luci-color-primary);cursor:pointer;box-shadow:var(--luci-shadow-float);transition:background-color var(--luci-motion-fast)}
|
|
153
|
+
button:hover{background:var(--luci-color-primary-hover)}
|
|
154
|
+
button:focus-visible{outline:2px solid var(--luci-color-focus);outline-offset:2px}
|
|
155
|
+
button span{display:block;width:38px;line-height:0} svg{display:block;width:100%;height:auto}
|
|
156
|
+
@media (prefers-reduced-motion: reduce){button{transition:none}}
|
|
157
|
+
</style><button type="button" data-action="open-luci" aria-label="${COPY.devToolbar.open}" title="${COPY.devToolbar.open}"><span>${mascotSvg('head')}</span></button>`;
|
|
158
|
+
const button = root.querySelector('button');
|
|
159
|
+
button.style.cursor = 'grab';
|
|
160
|
+
button.style.touchAction = 'none';
|
|
161
|
+
/*
|
|
162
|
+
* The button moves on its own, without opening the bar (user request, 2026-11-15): 4 px before a
|
|
163
|
+
* press counts as a drag, so a click still opens it. Dropped, it takes the nearest corner, which is
|
|
164
|
+
* also where the bar will grow from (they share one place).
|
|
165
|
+
*/
|
|
166
|
+
let press = null;
|
|
167
|
+
let moved = false;
|
|
168
|
+
const move = (e) => {
|
|
169
|
+
const p = press;
|
|
170
|
+
if (!p || e.pointerId !== p.id)
|
|
171
|
+
return;
|
|
172
|
+
if (!p.moved && !(e.buttons & 1)) {
|
|
173
|
+
release();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const dx = e.clientX - p.x0, dy = e.clientY - p.y0;
|
|
177
|
+
if (!p.moved && Math.hypot(dx, dy) < 4)
|
|
178
|
+
return;
|
|
179
|
+
if (!p.moved) {
|
|
180
|
+
p.moved = true;
|
|
181
|
+
button.setPointerCapture?.(e.pointerId);
|
|
182
|
+
button.style.cursor = 'grabbing';
|
|
183
|
+
}
|
|
184
|
+
const left = clamp(p.rect.left + dx, EDGE, win.innerWidth - EDGE - p.rect.width);
|
|
185
|
+
const top = clamp(p.rect.top + dy, EDGE, win.innerHeight - EDGE - p.rect.height);
|
|
186
|
+
Object.assign(button.style, { left: `${left}px`, top: `${top}px`, right: 'auto', bottom: 'auto' });
|
|
187
|
+
};
|
|
188
|
+
const up = (e) => {
|
|
189
|
+
const p = press;
|
|
190
|
+
if (!p || e.pointerId !== p.id)
|
|
191
|
+
return;
|
|
192
|
+
release();
|
|
193
|
+
if (!p.moved)
|
|
194
|
+
return;
|
|
195
|
+
moved = true;
|
|
196
|
+
win.setTimeout(() => { moved = false; }, 0);
|
|
197
|
+
const r = button.getBoundingClientRect();
|
|
198
|
+
const vw = win.innerWidth, vh = win.innerHeight;
|
|
199
|
+
const h = r.left + r.width / 2 < vw / 2 ? 'left' : 'right';
|
|
200
|
+
const v = r.top + r.height / 2 < vh / 2 ? 'top' : 'bottom';
|
|
201
|
+
place = { h, v, x: Math.round(h === 'left' ? r.left : vw - r.right), y: Math.round(v === 'top' ? r.top : vh - r.bottom) };
|
|
202
|
+
// Anchored to that corner from now on (so it keeps its place when the window resizes)
|
|
203
|
+
Object.assign(button.style, { left: '', top: '', right: '', bottom: '', cursor: 'grab', [h]: `${place.x}px`, [v]: `${place.y}px`,
|
|
204
|
+
[h === 'left' ? 'right' : 'left']: 'auto', [v === 'top' ? 'bottom' : 'top']: 'auto' });
|
|
205
|
+
writeUiPrefs(doc, { ...readUiPrefs(doc), devPlace: place, dock: h });
|
|
206
|
+
};
|
|
207
|
+
const release = () => {
|
|
208
|
+
doc.removeEventListener('pointermove', move, true);
|
|
209
|
+
doc.removeEventListener('pointerup', up, true);
|
|
210
|
+
doc.removeEventListener('pointercancel', up, true);
|
|
211
|
+
press = null;
|
|
212
|
+
};
|
|
213
|
+
button.addEventListener('pointerdown', (e) => {
|
|
214
|
+
if (e.button !== 0)
|
|
215
|
+
return;
|
|
216
|
+
press = { id: e.pointerId, x0: e.clientX, y0: e.clientY, rect: button.getBoundingClientRect(), moved: false };
|
|
217
|
+
doc.addEventListener('pointermove', move, true);
|
|
218
|
+
doc.addEventListener('pointerup', up, true);
|
|
219
|
+
doc.addEventListener('pointercancel', up, true);
|
|
220
|
+
});
|
|
221
|
+
button.addEventListener('click', (e) => {
|
|
222
|
+
e.stopPropagation();
|
|
223
|
+
// The click that ends a drag only drops the button
|
|
224
|
+
if (moved) {
|
|
225
|
+
moved = false;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
show(mode, { grow: true });
|
|
229
|
+
});
|
|
230
|
+
doc.documentElement.appendChild(launcher);
|
|
231
|
+
};
|
|
232
|
+
const reducedMotion = () => { try {
|
|
233
|
+
return win.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return false;
|
|
237
|
+
} };
|
|
238
|
+
/** The bar grows out of the launcher's corner (opacity and transform only, brand/DESIGN.md motion). */
|
|
239
|
+
const grow = (host) => {
|
|
240
|
+
const bar = host.shadowRoot?.querySelector('.bar');
|
|
241
|
+
if (!bar || reducedMotion() || typeof bar.animate !== 'function')
|
|
242
|
+
return;
|
|
243
|
+
const origin = `${place.h} ${place.v}`;
|
|
244
|
+
bar.animate([
|
|
245
|
+
{ opacity: 0, transform: `translateY(${place.v === 'top' ? -8 : 8}px) scale(0.3)`, transformOrigin: origin },
|
|
246
|
+
{ opacity: 1, transform: 'none', transformOrigin: origin }
|
|
247
|
+
], { duration: 220, easing: 'cubic-bezier(0.2, 0, 0, 1)' });
|
|
248
|
+
};
|
|
249
|
+
/** Put a mode's host in the bar's place, kept inside the window. */
|
|
250
|
+
const applyPlace = (host) => {
|
|
251
|
+
const bar = host.shadowRoot?.querySelector('.bar');
|
|
252
|
+
const x = clamp(place.x, EDGE, win.innerWidth - EDGE - (bar?.offsetWidth ?? 0));
|
|
253
|
+
const y = clamp(place.y, EDGE, win.innerHeight - EDGE - (bar?.offsetHeight ?? 0));
|
|
254
|
+
host.setAttribute('data-h', place.h);
|
|
255
|
+
host.setAttribute('data-v', place.v);
|
|
256
|
+
host.style.setProperty('--luci-x', `${x}px`);
|
|
257
|
+
host.style.setProperty('--luci-y', `${y}px`);
|
|
258
|
+
};
|
|
259
|
+
/*
|
|
260
|
+
* Dragging: by the bar's own background, a separator or Luci's head (higher threshold for
|
|
261
|
+
* buttons, so a click on Luci always opens the menu without being intercepted as a drag).
|
|
262
|
+
* While it moves it keeps its corner; dropped, it takes the nearest one, so its cards open on
|
|
263
|
+
* the side with room.
|
|
264
|
+
*/
|
|
265
|
+
let drag = null;
|
|
266
|
+
let justMoved = false;
|
|
267
|
+
const stopDrag = () => {
|
|
268
|
+
doc.removeEventListener('pointermove', dragMove, true);
|
|
269
|
+
doc.removeEventListener('pointerup', dragEnd, true);
|
|
270
|
+
doc.removeEventListener('pointercancel', dragEnd, true);
|
|
271
|
+
drag?.host.removeAttribute('data-moving');
|
|
272
|
+
drag = null;
|
|
273
|
+
};
|
|
274
|
+
const dragMove = (e) => {
|
|
275
|
+
const d = drag;
|
|
276
|
+
if (!d || e.pointerId !== d.id)
|
|
277
|
+
return;
|
|
278
|
+
if (!d.moved && !(e.buttons & 1)) {
|
|
279
|
+
stopDrag();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const dx = e.clientX - d.x0, dy = e.clientY - d.y0;
|
|
283
|
+
const threshold = d.isBtn ? 14 : 4;
|
|
284
|
+
if (!d.moved && Math.hypot(dx, dy) < threshold)
|
|
285
|
+
return;
|
|
286
|
+
if (!d.moved) {
|
|
287
|
+
d.moved = true;
|
|
288
|
+
d.bar.setPointerCapture?.(e.pointerId);
|
|
289
|
+
d.host.setAttribute('data-moving', '');
|
|
290
|
+
}
|
|
291
|
+
const left = clamp(d.rect.left + dx, EDGE, win.innerWidth - EDGE - d.rect.width);
|
|
292
|
+
const top = clamp(d.rect.top + dy, EDGE, win.innerHeight - EDGE - d.rect.height);
|
|
293
|
+
place = {
|
|
294
|
+
...place,
|
|
295
|
+
x: place.h === 'left' ? left : win.innerWidth - left - d.rect.width,
|
|
296
|
+
y: place.v === 'top' ? top : win.innerHeight - top - d.rect.height
|
|
297
|
+
};
|
|
298
|
+
applyPlace(d.host);
|
|
299
|
+
};
|
|
300
|
+
const dragEnd = (e) => {
|
|
301
|
+
const d = drag;
|
|
302
|
+
if (!d || e.pointerId !== d.id)
|
|
303
|
+
return;
|
|
304
|
+
stopDrag();
|
|
305
|
+
if (!d.moved)
|
|
306
|
+
return;
|
|
307
|
+
// The click that ends a drag is not a click on Luci's head
|
|
308
|
+
justMoved = true;
|
|
309
|
+
win.setTimeout(() => { justMoved = false; }, 0);
|
|
310
|
+
const r = d.bar.getBoundingClientRect();
|
|
311
|
+
const vw = win.innerWidth, vh = win.innerHeight;
|
|
312
|
+
const h = r.left + r.width / 2 < vw / 2 ? 'left' : 'right';
|
|
313
|
+
const v = r.top + r.height / 2 < vh / 2 ? 'top' : 'bottom';
|
|
314
|
+
place = { h, v, x: Math.round(h === 'left' ? r.left : vw - r.right), y: Math.round(v === 'top' ? r.top : vh - r.bottom) };
|
|
315
|
+
applyPlace(d.host);
|
|
316
|
+
writeUiPrefs(doc, { ...readUiPrefs(doc), devPlace: place, dock: h });
|
|
317
|
+
};
|
|
318
|
+
const draggable = (host) => {
|
|
319
|
+
const root = host.shadowRoot;
|
|
320
|
+
if (!root)
|
|
321
|
+
return;
|
|
322
|
+
root.addEventListener('pointerdown', (ev) => {
|
|
323
|
+
const e = ev;
|
|
324
|
+
const t = e.composedPath()[0];
|
|
325
|
+
const bar = t?.closest?.('.bar');
|
|
326
|
+
if (e.button !== 0 || !t || !bar || (t !== bar && !t.closest('.menu-btn, .bar-sep, .brand')))
|
|
327
|
+
return;
|
|
328
|
+
const isBtn = Boolean(t.closest('.menu-btn'));
|
|
329
|
+
drag = { id: e.pointerId, x0: e.clientX, y0: e.clientY, rect: bar.getBoundingClientRect(), bar, host, moved: false, isBtn };
|
|
330
|
+
doc.addEventListener('pointermove', dragMove, true);
|
|
331
|
+
doc.addEventListener('pointerup', dragEnd, true);
|
|
332
|
+
doc.addEventListener('pointercancel', dragEnd, true);
|
|
333
|
+
});
|
|
334
|
+
root.addEventListener('click', (e) => {
|
|
335
|
+
if (!justMoved)
|
|
336
|
+
return;
|
|
337
|
+
justMoved = false;
|
|
338
|
+
e.stopPropagation();
|
|
339
|
+
e.preventDefault();
|
|
340
|
+
}, true);
|
|
341
|
+
};
|
|
342
|
+
// Dock Right or Left (in any menu) puts a dragged bar back in that corner; resizing keeps it inside
|
|
343
|
+
const followPrefs = () => {
|
|
344
|
+
const next = readUiPrefs(doc).devPlace ?? homePlace();
|
|
345
|
+
if (JSON.stringify(next) === JSON.stringify(place))
|
|
346
|
+
return;
|
|
347
|
+
place = next;
|
|
348
|
+
if (current)
|
|
349
|
+
applyPlace(current.host);
|
|
350
|
+
else if (launcher)
|
|
351
|
+
showLauncher();
|
|
352
|
+
};
|
|
353
|
+
const onResize = () => { if (current)
|
|
354
|
+
applyPlace(current.host); };
|
|
355
|
+
doc.addEventListener(UI_PREFS_EVENT, followPrefs);
|
|
356
|
+
win.addEventListener('resize', onResize);
|
|
357
|
+
/** The same switch on every mode's bar. */
|
|
358
|
+
const modeSwitch = () => ({ current: mode, modes: MODES, onSelect: (id) => show(id) });
|
|
359
|
+
/*
|
|
360
|
+
* One Luci on the page at a time. Another Capture toolbar opening (the extension's) sends the
|
|
361
|
+
* replace signal: the dev toolbar then closes to its launcher, the way its own close does, so Luci's
|
|
362
|
+
* button stays in the corner. Opening the dev toolbar sends the signal itself, which closes the
|
|
363
|
+
* extension's toolbar; while it does (and while its own Capture mounts), it ignores the signal.
|
|
364
|
+
*/
|
|
365
|
+
let opening = false;
|
|
366
|
+
const stepAside = () => {
|
|
367
|
+
if (opening || !current)
|
|
368
|
+
return;
|
|
369
|
+
current.destroy();
|
|
370
|
+
current = null;
|
|
371
|
+
showLauncher();
|
|
372
|
+
};
|
|
373
|
+
doc.addEventListener(TOOLBAR_REPLACE_EVENT, stepAside);
|
|
374
|
+
const show = (next, how = {}) => {
|
|
375
|
+
opening = true;
|
|
376
|
+
try {
|
|
377
|
+
openMode(next, how);
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
opening = false;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const openMode = (next, how) => {
|
|
384
|
+
current?.destroy();
|
|
385
|
+
removeLauncher();
|
|
386
|
+
doc.dispatchEvent(new CustomEvent(TOOLBAR_REPLACE_EVENT));
|
|
387
|
+
mode = next;
|
|
388
|
+
try {
|
|
389
|
+
session?.setItem(KEYS.mode, mode);
|
|
390
|
+
}
|
|
391
|
+
catch { /* not available */ }
|
|
392
|
+
const projectInfo = {
|
|
393
|
+
get: async () => health.project ? { project: health.project, name: health.project.split(/[\\/]/).filter(Boolean).pop(), url: bridge } : null
|
|
394
|
+
};
|
|
395
|
+
if (mode === 'feedback') {
|
|
396
|
+
current = mountFeedback({
|
|
397
|
+
doc,
|
|
398
|
+
backend,
|
|
399
|
+
...(connected ? {} : { connectNote, onConnect: connect }),
|
|
400
|
+
settings: readJson(storage, KEYS.feedback, DEFAULT_FEEDBACK_SETTINGS),
|
|
401
|
+
onSettingsChange: s => storage.setItem(KEYS.feedback, JSON.stringify(s)),
|
|
402
|
+
modes: modeSwitch(),
|
|
403
|
+
projectInfo,
|
|
404
|
+
store: storage,
|
|
405
|
+
onClose: () => { current = null; showLauncher(); }
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
else if (mode === 'layout') {
|
|
409
|
+
current = mountLayout({
|
|
410
|
+
doc,
|
|
411
|
+
backend,
|
|
412
|
+
modes: modeSwitch(),
|
|
413
|
+
...(connected ? {} : { connectNote }),
|
|
414
|
+
projectInfo,
|
|
415
|
+
store: storage,
|
|
416
|
+
onClose: () => { current = null; showLauncher(); }
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
current = mountToolbar({
|
|
421
|
+
doc,
|
|
422
|
+
settings: readJson(storage, KEYS.capture, {}),
|
|
423
|
+
onSettingsChange: s => storage.setItem(KEYS.capture, JSON.stringify(s)),
|
|
424
|
+
basket: storageBasket(storage),
|
|
425
|
+
modes: modeSwitch(),
|
|
426
|
+
store: storage,
|
|
427
|
+
...(backend.saveCapture ? { saveToProject: backend.saveCapture } : {}),
|
|
428
|
+
projectInfo,
|
|
429
|
+
// Design check (v0.3): the project's design files, and each difference as a feedback note
|
|
430
|
+
...(backend.listCaptures && backend.readCapture ? { designs: { list: backend.listCaptures, read: backend.readCapture } } : {}),
|
|
431
|
+
addCheckNotes: (el, notes) => addCheckNotes(backend, doc, el, notes),
|
|
432
|
+
// Automatic design check (v0.4): check again when the page changes; each run goes to the project for the agent
|
|
433
|
+
autoCheck: true,
|
|
434
|
+
...(backend.saveCheck ? { onCheckRun: (run) => { void backend.saveCheck(run).catch(() => { }); } } : {}),
|
|
435
|
+
// "Use my tokens" (v0.4): the project's own tokens through luci serve, or tokens pasted in this browser
|
|
436
|
+
myTokens: {
|
|
437
|
+
...(backend.projectTokens ? { project: backend.projectTokens } : {}),
|
|
438
|
+
load: async () => storage.getItem(KEYS.myTokens) ?? '',
|
|
439
|
+
save: async (css) => storage.setItem(KEYS.myTokens, css)
|
|
440
|
+
},
|
|
441
|
+
checkNotesWhere: connected ? 'your project' : 'this browser',
|
|
442
|
+
// Capture to rule (v0.3.2): save the capture, then propose a rule that points at it
|
|
443
|
+
...(backend.saveCapture && backend.proposeRule ? {
|
|
444
|
+
makeRule: async (fileName, markdown) => {
|
|
445
|
+
await backend.saveCapture(fileName, markdown);
|
|
446
|
+
return backend.proposeRule(fileName);
|
|
447
|
+
}
|
|
448
|
+
} : {}),
|
|
449
|
+
onClose: () => { current = null; showLauncher(); }
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
// In the bar's place (by its button unless the person dragged it), and draggable
|
|
453
|
+
applyPlace(current.host);
|
|
454
|
+
draggable(current.host);
|
|
455
|
+
if (how.grow)
|
|
456
|
+
grow(current.host);
|
|
457
|
+
};
|
|
458
|
+
show(mode);
|
|
459
|
+
return {
|
|
460
|
+
get backend() { return backend; },
|
|
461
|
+
connect,
|
|
462
|
+
mode: () => mode,
|
|
463
|
+
show,
|
|
464
|
+
destroy: () => {
|
|
465
|
+
doc.removeEventListener(TOOLBAR_REPLACE_EVENT, stepAside);
|
|
466
|
+
doc.removeEventListener(UI_PREFS_EVENT, followPrefs);
|
|
467
|
+
win.removeEventListener('resize', onResize);
|
|
468
|
+
stopDrag();
|
|
469
|
+
current?.destroy();
|
|
470
|
+
current = null;
|
|
471
|
+
removeLauncher();
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
//# sourceMappingURL=devToolbar.js.map
|