legend-state-dev-tools 0.0.4 → 0.0.5

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 ADDED
@@ -0,0 +1,142 @@
1
+ # legend-state-dev-tools
2
+
3
+ > **Early-stage project** -- I discovered Legend State recently and chose it for a project I was working on. It had everything I needed from a state manager, but I couldn't live without dev tools, so I built this. It appears to work, but it hasn't been thoroughly tested yet -- consider it a proof of concept for now.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/legend-state-dev-tools)](https://www.npmjs.com/package/legend-state-dev-tools)
6
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
+
8
+ Visual dev tools for Legend State v3 -- inspect and edit observable state in real time.
9
+
10
+ <!-- screenshot -->
11
+
12
+ ## Features
13
+
14
+ - Real-time state tree view powered by `json-edit-react`
15
+ - Inline editing of observable values
16
+ - Multiple color themes (dark and light variants)
17
+ - Draggable toolbar
18
+ - Configurable panel positioning (left or right)
19
+ - Read-only mode
20
+ - Clean teardown via `destroy()`
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install legend-state-dev-tools
26
+ ```
27
+
28
+ ```bash
29
+ pnpm add legend-state-dev-tools
30
+ ```
31
+
32
+ ```bash
33
+ yarn add legend-state-dev-tools
34
+ ```
35
+
36
+ ### Peer dependencies
37
+
38
+ | Package | Version |
39
+ |---------|---------|
40
+ | `@legendapp/state` | `>= 3.0.0-beta.0` |
41
+ | `react` | `>= 18.0.0` |
42
+ | `react-dom` | `>= 18.0.0` |
43
+
44
+ ## Quick Start
45
+
46
+ ```ts
47
+ import { observable } from '@legendapp/state';
48
+ import { init } from 'legend-state-dev-tools';
49
+ import 'legend-state-dev-tools/dist/styles.css';
50
+
51
+ const state$ = observable({ count: 0, user: { name: 'Alice' } });
52
+
53
+ const devtools = init(state$);
54
+
55
+ // Later, to clean up:
56
+ // devtools.destroy();
57
+ ```
58
+
59
+ ## API Reference
60
+
61
+ ### `init(observable$, options?)`
62
+
63
+ Mounts the dev tools UI and returns a handle for cleanup.
64
+
65
+ **Parameters**
66
+
67
+ | Parameter | Type | Description |
68
+ |-----------|------|-------------|
69
+ | `observable$` | `ObservableParam<any>` | The Legend State observable to inspect |
70
+ | `options` | `DevToolsOptions` | Optional configuration (see below) |
71
+
72
+ **Options**
73
+
74
+ | Option | Type | Default | Description |
75
+ |--------|------|---------|-------------|
76
+ | `enabled` | `boolean` | `true` | Enable or disable the dev tools |
77
+ | `readOnly` | `boolean` | `false` | Prevent editing of state values |
78
+ | `theme` | `string` | `'githubDark'` | Color theme for the JSON editor |
79
+ | `rootName` | `string` | `'state$'` | Label shown as the root node name |
80
+ | `position` | `'left' \| 'right'` | `'right'` | Side of the screen for the panel |
81
+
82
+ **Returns**
83
+
84
+ ```ts
85
+ { destroy: () => void }
86
+ ```
87
+
88
+ Call `destroy()` to unmount the toolbar, panel, and state subscription.
89
+
90
+ ## Themes
91
+
92
+ The following themes are available (provided by `json-edit-react`):
93
+
94
+ | Theme key | Description |
95
+ |-----------|-------------|
96
+ | `githubDark` | GitHub dark (default) |
97
+ | `githubLight` | GitHub light |
98
+ | `monoDark` | Monochrome dark |
99
+ | `monoLight` | Monochrome light |
100
+
101
+ ## Example
102
+
103
+ A working example is included in `examples/basic/`. To run it:
104
+
105
+ ```bash
106
+ npm install
107
+ npm run dev
108
+ ```
109
+
110
+ This builds the core package and starts the Vite dev server for the example app.
111
+
112
+ ## Development
113
+
114
+ ```bash
115
+ git clone <repo-url>
116
+ cd legend-state-dev-tools
117
+ npm install
118
+ npm run build # build the core package
119
+ npm run dev # build + start example dev server
120
+ ```
121
+
122
+ ## Architecture
123
+
124
+ The project is a monorepo with the main package in `packages/core/` and examples in `examples/`.
125
+
126
+ | Module | Path | Role |
127
+ |--------|------|------|
128
+ | `index` | `packages/core/src/index.ts` | Public API (`init`, options, lifecycle) |
129
+ | `state-bridge` | `packages/core/src/state-bridge.ts` | Subscribes to observables, produces snapshots, writes back edits |
130
+ | `json-editor-mount` | `packages/core/src/ui/json-editor-mount.tsx` | Mounts the `json-edit-react` editor with theme resolution |
131
+ | `panel` | `packages/core/src/ui/panel.ts` | Slide-out panel DOM management |
132
+ | `toolbar` | `packages/core/src/ui/toolbar.ts` | Draggable floating toolbar |
133
+ | `template-engine` | `packages/core/src/ui/template-engine.ts` | Lightweight HTML templating (Eta) |
134
+ | `styles` | `packages/core/src/styles.css` | Panel and toolbar CSS |
135
+
136
+ ## Acknowledgments
137
+
138
+ A huge thank you to [Carlos](https://github.com/CarlosNZ) for creating [`json-edit-react`](https://github.com/CarlosNZ/json-edit-react) -- the excellent React component that powers the state tree viewer and editor in this project. Without it, these dev tools simply wouldn't exist.
139
+
140
+ ## License
141
+
142
+ MIT
package/package.json CHANGED
@@ -1,40 +1,30 @@
1
1
  {
2
2
  "name": "legend-state-dev-tools",
3
- "version": "0.0.4",
4
- "description": "Dev tools for Legend State v3 - view and edit observable state",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
3
+ "version": "0.0.5",
4
+ "private": false,
5
+ "workspaces": [
6
+ "packages/*",
7
+ "examples/*"
8
+ ],
9
+ "main": "./packages/core/dist/index.js",
10
+ "module": "./packages/core/dist/index.mjs",
11
+ "types": "./packages/core/dist/index.d.ts",
8
12
  "exports": {
9
13
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "default": "./dist/index.mjs"
14
+ "types": "./packages/core/dist/index.d.ts",
15
+ "import": "./packages/core/dist/index.mjs",
16
+ "require": "./packages/core/dist/index.js",
17
+ "default": "./packages/core/dist/index.mjs"
14
18
  },
15
- "./dist/styles.css": "./dist/styles.css"
19
+ "./packages/core/dist/styles.css": "./packages/core/dist/styles.css"
16
20
  },
17
21
  "files": [
18
- "dist"
22
+ "packages/core/dist"
19
23
  ],
20
24
  "scripts": {
21
- "build": "vite build",
22
- "dev": "vite build --watch"
23
- },
24
- "devDependencies": {
25
- "@types/react": "^18.2.0",
26
- "@types/react-dom": "^18.2.0",
27
- "typescript": "^5.3.0",
28
- "vite": "^6.0.0",
29
- "vite-plugin-dts": "^4.0.0"
30
- },
31
- "peerDependencies": {
32
- "@legendapp/state": ">=3.0.0-beta.0",
33
- "react": ">=18.0.0",
34
- "react-dom": ">=18.0.0"
25
+ "build": "npm run build -w packages/core",
26
+ "dev": "npm run build && npm run dev -w examples/basic",
27
+ "clean": "rm -rf node_modules packages/*/dist packages/*/node_modules examples/*/node_modules"
35
28
  },
36
- "dependencies": {
37
- "eta": "^3.5.0",
38
- "json-edit-react": "^1.16.0"
39
- }
29
+ "license": "MIT"
40
30
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes