api_binding_ui 3.0.0 → 3.1.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 CHANGED
@@ -9,7 +9,7 @@ Spec: [`spec/FRAMEWORK.md`](spec/FRAMEWORK.md). Agent rules: [`SKILL.md`](SKILL.
9
9
  1. **Ids.** Every bindable component gets `componentId="<product>.<screen>[.<sub-screen>].<component>"`, e.g. `collections.worklist.add-notes.submit`.
10
10
  2. **Register.** List kinds, screens and components in `bindings.json`.
11
11
  3. **Client.** Run Orval on the same OpenAPI file (see below).
12
- 4. **Bind.** `npx api-binding studio bindings.json` opens the studio on http://localhost:5180. Edits save to the file.
12
+ 4. **Bind.** In a Vite app, add the dev plugin (below) and click **Bind API** on any screen. Elsewhere, `npx api-binding studio bindings.json` opens it on http://localhost:5180. Edits save to the file.
13
13
  5. **Generate.** `npx api-binding generate bindings.json` writes one hook per screen into `output.dir`.
14
14
  6. **Wire once.** Each screen calls its hook:
15
15
 
@@ -28,6 +28,20 @@ const options = api.notesType.options.bound ? api.notesType.options.data ?? [] :
28
28
 
29
29
  Rebinding changes only the hook bodies; the hook's types come from the registry, so call sites stay put.
30
30
 
31
+ ## Dev plugin (Vite)
32
+
33
+ ```ts
34
+ // vite.config.ts
35
+ import { bindingStudio } from "api_binding_ui/vite";
36
+
37
+ export default defineConfig({ plugins: [/* …, */ bindingStudio()] }); // reads ./bindings.json
38
+ ```
39
+
40
+ - `vite dev` only (`apply: "serve"`); `vite build` output contains nothing from it. Keep `api_binding_ui` a devDependency.
41
+ - Adds a floating **Bind API** button to every HTML page (SPA and server-rendered). It opens the studio over the app on the screen being shown, found from the `data-component-id` attributes on the page; an open dialog wins over its page.
42
+ - **Alt+click** any component to open the studio on it; holding Alt outlines components.
43
+ - The studio is served by the dev server under `/__binding/`, which reads and writes `bindings.json` and fetches the docs server-side. Writes are same-origin only.
44
+
31
45
  ## bindings.json
32
46
 
33
47
  ```jsonc
package/SKILL.md CHANGED
@@ -9,7 +9,7 @@ Spec: `node_modules/api_binding_ui/spec/FRAMEWORK.md`. The app never imports `ap
9
9
 
10
10
  ## Never
11
11
 
12
- - Import `api_binding_ui` from app code, or add a binding runtime, provider or manifest to the app.
12
+ - Import `api_binding_ui` from app code, or add a binding runtime, provider or manifest to the app. The only allowed use is `bindingStudio()` from `api_binding_ui/vite` in `vite.config.ts`, with the package as a devDependency.
13
13
  - Edit files under the Orval output or `src/api/screens`. They start with `// @generated`; regenerate instead.
14
14
  - Call APIs from screens other than through the generated screen hook.
15
15
  - Add hardcoded option lists, rows or values an API should provide.