@launchdarkly/toolbar 0.10.1 → 0.11.1-beta.1
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 +138 -125
- package/dist/index.d.ts +3 -0
- package/dist/js/index.js +1730 -994
- package/dist/plugins/FlagOverridePlugin.d.ts +57 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/tests/DevServerProvider.test.d.ts +1 -0
- package/dist/tests/ExpandedToolbarContent.test.d.ts +1 -0
- package/dist/tests/FlagSdkOverrideProvider.test.d.ts +1 -0
- package/dist/types/devServer.d.ts +2 -2
- package/dist/types/plugin.d.ts +31 -0
- package/dist/ui/Toolbar/Header/Header.d.ts +2 -0
- package/dist/ui/Toolbar/Header/components/ActionButtons.d.ts +1 -0
- package/dist/ui/Toolbar/LaunchDarklyToolbar.d.ts +8 -2
- package/dist/ui/Toolbar/TabContent/FlagDevServerTabContent.d.ts +1 -0
- package/dist/ui/Toolbar/TabContent/FlagSdkOverrideTabContent.d.ts +6 -0
- package/dist/ui/Toolbar/TabContent/SettingsTabContent.d.ts +6 -1
- package/dist/ui/Toolbar/components/ExpandedToolbarContent.d.ts +4 -1
- package/dist/ui/Toolbar/components/LocalFlagControls.css.d.ts +4 -0
- package/dist/ui/Toolbar/components/LocalFlagControls.d.ts +20 -0
- package/dist/ui/Toolbar/components/TabContentRenderer.d.ts +4 -1
- package/dist/ui/Toolbar/constants/index.d.ts +1 -1
- package/dist/ui/Toolbar/constants/virtualization.d.ts +4 -0
- package/dist/ui/Toolbar/context/{LaunchDarklyToolbarProvider.d.ts → DevServerProvider.d.ts} +6 -6
- package/dist/ui/Toolbar/context/FlagSdkOverrideProvider.d.ts +19 -0
- package/dist/ui/Toolbar/context/index.d.ts +3 -0
- package/dist/ui/Toolbar/types/toolbar.d.ts +7 -1
- package/package.json +5 -3
- package/dist/ui/Toolbar/TabContent/FlagTabContent.d.ts +0 -1
- package/dist/ui/Toolbar/constants/config.d.ts +0 -3
- /package/dist/ui/Toolbar/TabContent/{FlagTabContent.css.d.ts → FlagDevServerTabContent.css.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,184 +1,201 @@
|
|
|
1
1
|
# LaunchDarkly Toolbar
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 🚧 **Beta:** This package is currently in beta. While functional and tested, APIs may still evolve based on feedback. Please report any issues or suggestions!
|
|
4
4
|
|
|
5
|
-
A React component that provides a developer-friendly toolbar for interacting with LaunchDarkly during development.
|
|
5
|
+
A React component that provides a developer-friendly toolbar for interacting with LaunchDarkly during development. The toolbar supports two modes:
|
|
6
|
+
|
|
7
|
+
- **SDK Mode**: Integrate with your LaunchDarkly SDK for local flag overrides and testing (recommended)
|
|
8
|
+
- **Dev Server Mode**: Connect to a LaunchDarkly CLI dev server for flag browsing and real-time updates
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
|
-
npm
|
|
11
|
-
|
|
12
|
-
yarn add @launchdarkly/toolbar
|
|
13
|
-
# or
|
|
14
|
-
pnpm add @launchdarkly/toolbar
|
|
15
|
-
```
|
|
13
|
+
# npm
|
|
14
|
+
npm install @launchdarkly/toolbar@next
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
# yarn
|
|
17
|
+
yarn add @launchdarkly/toolbar@next
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
# pnpm
|
|
20
|
+
pnpm add @launchdarkly/toolbar@next
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
**SDK Mode** (recommended - integrates with your LaunchDarkly SDK):
|
|
24
26
|
|
|
25
27
|
```tsx
|
|
28
|
+
import { useEffect, useState } from 'react';
|
|
29
|
+
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
|
|
30
|
+
import { LaunchDarklyToolbar, FlagOverridePlugin } from '@launchdarkly/toolbar';
|
|
31
|
+
|
|
32
|
+
// Create the plugin instance
|
|
33
|
+
const flagOverridePlugin = new FlagOverridePlugin();
|
|
34
|
+
|
|
26
35
|
function App() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
const [LDProvider, setLDProvider] = useState(null);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const initializeLD = async () => {
|
|
40
|
+
const Provider = await asyncWithLDProvider({
|
|
41
|
+
clientSideID: 'your-client-side-id',
|
|
42
|
+
context: { key: 'user-key', name: 'User Name' },
|
|
43
|
+
options: {
|
|
44
|
+
// Pass the plugin to the SDK
|
|
45
|
+
plugins: [flagOverridePlugin],
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
setLDProvider(() => Provider);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
initializeLD();
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
if (!LDProvider) {
|
|
55
|
+
return <div>Loading LaunchDarkly...</div>;
|
|
56
|
+
}
|
|
31
57
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
58
|
+
return (
|
|
59
|
+
<LDProvider>
|
|
60
|
+
<div>
|
|
61
|
+
<h1>My App</h1>
|
|
62
|
+
{/* Pass the same plugin instance to the toolbar */}
|
|
63
|
+
<LaunchDarklyToolbar flagOverridePlugin={flagOverridePlugin} />
|
|
64
|
+
</div>
|
|
65
|
+
</LDProvider>
|
|
35
66
|
);
|
|
36
67
|
}
|
|
37
68
|
```
|
|
38
69
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Make sure your LaunchDarkly dev server is running
|
|
43
|
-
# The toolbar will automatically connect and display your flags
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Props
|
|
47
|
-
|
|
48
|
-
| Prop | Type | Default | Description |
|
|
49
|
-
| -------------- | ------------------- | ------------------------- | --------------------------------------------- |
|
|
50
|
-
| `devServerUrl` | `string` | `"http://localhost:8765"` | URL of your LaunchDarkly development server |
|
|
51
|
-
| `position` | `"left" \| "right"` | `"right"` | Position of the toolbar on screen |
|
|
52
|
-
| `projectKey` | `string` | `undefined` | Optional project key for multi-project setups |
|
|
53
|
-
|
|
54
|
-
## Usage Examples
|
|
55
|
-
|
|
56
|
-
### Basic Usage
|
|
70
|
+
**Dev Server Mode** (connects to LaunchDarkly CLI dev server):
|
|
57
71
|
|
|
58
72
|
```tsx
|
|
59
73
|
import { LaunchDarklyToolbar } from '@launchdarkly/toolbar';
|
|
60
74
|
|
|
61
75
|
function App() {
|
|
62
76
|
return (
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</main>
|
|
68
|
-
|
|
69
|
-
<LaunchDarklyToolbar />
|
|
70
|
-
</>
|
|
77
|
+
<div>
|
|
78
|
+
<h1>My App</h1>
|
|
79
|
+
<LaunchDarklyToolbar devServerUrl="http://localhost:8765" />
|
|
80
|
+
</div>
|
|
71
81
|
);
|
|
72
82
|
}
|
|
73
83
|
```
|
|
74
84
|
|
|
75
|
-
|
|
85
|
+
## Props
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
| Prop | Type | Default | Description |
|
|
88
|
+
| -------------------- | --------------------- | ----------- | ------------------------------------------------------------------------- |
|
|
89
|
+
| `flagOverridePlugin` | `IFlagOverridePlugin` | `undefined` | Flag override plugin for SDK Mode. Enables flag overrides and testing |
|
|
90
|
+
| `devServerUrl` | `string` (optional) | `undefined` | URL of your LaunchDarkly dev server. If provided, enables Dev Server Mode |
|
|
91
|
+
| `position` | `"left" \| "right"` | `"right"` | Position of the toolbar on screen |
|
|
92
|
+
| `projectKey` | `string` (optional) | `undefined` | Optional project key for multi-project setups (Dev Server Mode only) |
|
|
93
|
+
| `pollIntervalInMs` | `number` (optional) | `5000` | Polling interval for dev server updates (Dev Server Mode only) |
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
<>
|
|
83
|
-
<main>{/* Your app content */}</main>
|
|
95
|
+
## Configuration
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
```
|
|
97
|
+
### Mode Determination
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
The toolbar automatically determines its mode:
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
- **SDK Mode**: When `flagOverridePlugin` is provided (recommended for most use cases)
|
|
102
|
+
- **Dev Server Mode**: When `devServerUrl` is provided
|
|
95
103
|
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<>
|
|
99
|
-
<main>{/* Your app content */}</main>
|
|
104
|
+
### Available Features by Mode
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
```
|
|
106
|
+
| Mode | Available Tabs |
|
|
107
|
+
| ------------------- | ------------------- |
|
|
108
|
+
| **SDK Mode** | Overrides, Settings |
|
|
109
|
+
| **Dev Server Mode** | Flags, Settings |
|
|
107
110
|
|
|
108
|
-
##
|
|
111
|
+
## Setup
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
### SDK Mode (Recommended)
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
2. **Real-time Updates** - Flag changes are reflected immediately in your application
|
|
114
|
-
3. **Event Stream** - Monitor flag evaluation events as they happen
|
|
115
|
-
4. **Search & Filter** - Quickly find flags using the built-in search functionality
|
|
115
|
+
SDK Mode integrates directly with your LaunchDarkly client, allowing you to:
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
- Override flag values locally without affecting other users
|
|
118
|
+
- Test different flag variations instantly
|
|
119
|
+
- Work offline or with any LaunchDarkly environment
|
|
120
|
+
- Maintain full type safety with your existing SDK setup
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
Setup is straightforward:
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
1. Create a `FlagOverridePlugin` instance
|
|
125
|
+
2. Pass the plugin to your LaunchDarkly SDK's `plugins` array
|
|
126
|
+
3. Pass the same plugin instance to the toolbar component
|
|
127
|
+
4. Wrap your app with the LaunchDarkly provider
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
```tsx
|
|
130
|
+
import { useEffect, useState } from 'react';
|
|
131
|
+
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
|
|
132
|
+
import { LaunchDarklyToolbar, FlagOverridePlugin } from '@launchdarkly/toolbar';
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
// Create the plugin instance (outside component to avoid recreating)
|
|
135
|
+
const flagOverridePlugin = new FlagOverridePlugin({
|
|
136
|
+
storageNamespace: 'my-app-overrides', // Optional: customize storage key
|
|
137
|
+
});
|
|
128
138
|
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
function App() {
|
|
140
|
+
const [LDProvider, setLDProvider] = useState(null);
|
|
131
141
|
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
const initializeLD = async () => {
|
|
144
|
+
const Provider = await asyncWithLDProvider({
|
|
145
|
+
clientSideID: 'your-client-side-id',
|
|
146
|
+
context: { key: 'user-key', name: 'User Name' },
|
|
147
|
+
options: {
|
|
148
|
+
plugins: [flagOverridePlugin], // Add plugin to SDK
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
setLDProvider(() => Provider);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
initializeLD();
|
|
155
|
+
}, []);
|
|
134
156
|
|
|
135
|
-
|
|
136
|
-
|
|
157
|
+
if (!LDProvider) return <div>Loading...</div>;
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<LDProvider>
|
|
161
|
+
<YourAppContent />
|
|
162
|
+
<LaunchDarklyToolbar flagOverridePlugin={flagOverridePlugin} />
|
|
163
|
+
</LDProvider>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
137
166
|
```
|
|
138
167
|
|
|
139
|
-
###
|
|
168
|
+
### Dev Server Mode
|
|
140
169
|
|
|
141
|
-
|
|
170
|
+
For teams using the LaunchDarkly CLI dev server, start it with CORS enabled:
|
|
142
171
|
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
window.ldToolbar.enable() - Enable toolbar
|
|
146
|
-
window.ldToolbar.disable() - Disable toolbar
|
|
147
|
-
window.ldToolbar.toggle() - Toggle toolbar
|
|
148
|
-
window.ldToolbar.status() - Check current status
|
|
172
|
+
```bash
|
|
173
|
+
ldcli dev-server start --project your-project --cors-enabled true
|
|
149
174
|
```
|
|
150
175
|
|
|
151
|
-
|
|
176
|
+
Then connect the toolbar:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<LaunchDarklyToolbar devServerUrl="http://localhost:8765" />
|
|
180
|
+
```
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
## Visibility Control
|
|
154
183
|
|
|
155
|
-
|
|
184
|
+
The toolbar provides a global API for show/hide control:
|
|
156
185
|
|
|
157
186
|
```javascript
|
|
158
|
-
//
|
|
159
|
-
window.ldToolbar.
|
|
160
|
-
// Console: ✅ LaunchDarkly toolbar disabled.
|
|
187
|
+
// Toggle visibility
|
|
188
|
+
window.ldToolbar.toggle();
|
|
161
189
|
|
|
162
|
-
//
|
|
190
|
+
// Enable/disable explicitly
|
|
163
191
|
window.ldToolbar.enable();
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// Check if the toolbar is currently visible
|
|
167
|
-
const isEnabled = window.ldToolbar.status();
|
|
168
|
-
// Console: LaunchDarkly toolbar is currently: ✅ ENABLED
|
|
169
|
-
// Returns: true
|
|
192
|
+
window.ldToolbar.disable();
|
|
170
193
|
|
|
171
|
-
//
|
|
172
|
-
window.ldToolbar.
|
|
194
|
+
// Check current status
|
|
195
|
+
window.ldToolbar.status(); // returns true/false
|
|
173
196
|
```
|
|
174
197
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
The toolbar requires a LaunchDarkly CLI dev-server to be running with CORS enabled.
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
ldcli dev-server start --project demo-project --cors-enabled true
|
|
181
|
-
```
|
|
198
|
+
Visibility preferences are automatically saved to localStorage.
|
|
182
199
|
|
|
183
200
|
## TypeScript
|
|
184
201
|
|
|
@@ -186,12 +203,8 @@ The package includes complete TypeScript definitions. No additional `@types` pac
|
|
|
186
203
|
|
|
187
204
|
```tsx
|
|
188
205
|
import type { LaunchDarklyToolbarProps } from '@launchdarkly/toolbar';
|
|
189
|
-
|
|
190
|
-
const toolbarConfig: LaunchDarklyToolbarProps = {
|
|
191
|
-
devServerUrl: 'http://localhost:8765',
|
|
192
|
-
position: 'right',
|
|
193
|
-
projectKey: 'my-project',
|
|
194
|
-
};
|
|
195
206
|
```
|
|
196
207
|
|
|
208
|
+
---
|
|
209
|
+
|
|
197
210
|
Built with ❤️ for the LaunchDarkly developer community.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import './globals.css';
|
|
2
2
|
export { LaunchDarklyToolbar } from './ui/Toolbar/LaunchDarklyToolbar';
|
|
3
3
|
export type { LaunchDarklyToolbarProps } from './ui/Toolbar/LaunchDarklyToolbar';
|
|
4
|
+
export type { IFlagOverridePlugin } from './types/plugin';
|
|
5
|
+
export { FlagOverridePlugin } from './plugins';
|
|
6
|
+
export type { FlagOverridePluginConfig } from './plugins';
|