@launchdarkly/toolbar 0.10.1 → 0.11.0-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.
Files changed (30) hide show
  1. package/README.md +48 -132
  2. package/dist/index.d.ts +3 -0
  3. package/dist/js/index.js +1730 -994
  4. package/dist/plugins/FlagOverridePlugin.d.ts +57 -0
  5. package/dist/plugins/index.d.ts +2 -0
  6. package/dist/tests/DevServerProvider.test.d.ts +1 -0
  7. package/dist/tests/ExpandedToolbarContent.test.d.ts +1 -0
  8. package/dist/tests/FlagSdkOverrideProvider.test.d.ts +1 -0
  9. package/dist/types/devServer.d.ts +2 -2
  10. package/dist/types/plugin.d.ts +31 -0
  11. package/dist/ui/Toolbar/Header/Header.d.ts +2 -0
  12. package/dist/ui/Toolbar/Header/components/ActionButtons.d.ts +1 -0
  13. package/dist/ui/Toolbar/LaunchDarklyToolbar.d.ts +8 -2
  14. package/dist/ui/Toolbar/TabContent/FlagDevServerTabContent.d.ts +1 -0
  15. package/dist/ui/Toolbar/TabContent/FlagSdkOverrideTabContent.d.ts +6 -0
  16. package/dist/ui/Toolbar/TabContent/SettingsTabContent.d.ts +6 -1
  17. package/dist/ui/Toolbar/components/ExpandedToolbarContent.d.ts +4 -1
  18. package/dist/ui/Toolbar/components/LocalFlagControls.css.d.ts +4 -0
  19. package/dist/ui/Toolbar/components/LocalFlagControls.d.ts +20 -0
  20. package/dist/ui/Toolbar/components/TabContentRenderer.d.ts +4 -1
  21. package/dist/ui/Toolbar/constants/index.d.ts +1 -1
  22. package/dist/ui/Toolbar/constants/virtualization.d.ts +4 -0
  23. package/dist/ui/Toolbar/context/{LaunchDarklyToolbarProvider.d.ts → DevServerProvider.d.ts} +6 -6
  24. package/dist/ui/Toolbar/context/FlagSdkOverrideProvider.d.ts +19 -0
  25. package/dist/ui/Toolbar/context/index.d.ts +3 -0
  26. package/dist/ui/Toolbar/types/toolbar.d.ts +7 -1
  27. package/package.json +5 -3
  28. package/dist/ui/Toolbar/TabContent/FlagTabContent.d.ts +0 -1
  29. package/dist/ui/Toolbar/constants/config.d.ts +0 -3
  30. /package/dist/ui/Toolbar/TabContent/{FlagTabContent.css.d.ts → FlagDevServerTabContent.css.d.ts} +0 -0
package/README.md CHANGED
@@ -2,183 +2,103 @@
2
2
 
3
3
  > ⚠️ **Warning:** This package is currently not ready for production use and is considered unsupported. Features, APIs, and behavior may change without notice.
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
+ - **Dev Server Mode**: Connect to a LaunchDarkly CLI dev server for flag browsing and real-time updates
8
+ - **SDK Mode**: Integrate with flag override plugins for local flag testing
6
9
 
7
10
  ## Installation
8
11
 
9
12
  ```bash
10
13
  npm install @launchdarkly/toolbar
11
- # or
12
- yarn add @launchdarkly/toolbar
13
- # or
14
- pnpm add @launchdarkly/toolbar
15
14
  ```
16
15
 
17
- 1. **Import the component and styles:**
16
+ ## Quick Start
17
+
18
+ **Dev Server Mode** (connects to LaunchDarkly CLI dev server):
18
19
 
19
20
  ```tsx
20
21
  import { LaunchDarklyToolbar } from '@launchdarkly/toolbar';
21
- ```
22
-
23
- 2. **Add the toolbar to your app:**
24
22
 
25
- ```tsx
26
23
  function App() {
27
24
  return (
28
25
  <div>
29
- {/* Your app content */}
30
26
  <h1>My App</h1>
31
-
32
- {/* LaunchDarkly Toolbar */}
33
- <LaunchDarklyToolbar devServerUrl="http://localhost:8765" position="right" />
27
+ <LaunchDarklyToolbar devServerUrl="http://localhost:8765" />
34
28
  </div>
35
29
  );
36
30
  }
37
31
  ```
38
32
 
39
- 3. **Start your LaunchDarkly dev server:**
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
33
+ **SDK Mode** (integrates with flag override override plugins):
57
34
 
58
35
  ```tsx
59
36
  import { LaunchDarklyToolbar } from '@launchdarkly/toolbar';
37
+ import { flagOverridePlugin } from './your-flag-override-plugin';
60
38
 
61
39
  function App() {
62
40
  return (
63
- <>
64
- <main>
65
- <h1>My Application</h1>
66
- {/* Your app content */}
67
- </main>
68
-
69
- <LaunchDarklyToolbar />
70
- </>
71
- );
72
- }
73
- ```
74
-
75
- ### Custom Configuration
76
-
77
- ```tsx
78
- import { LaunchDarklyToolbar } from '@launchdarkly/toolbar';
79
-
80
- function App() {
81
- return (
82
- <>
83
- <main>{/* Your app content */}</main>
84
-
85
- <LaunchDarklyToolbar devServerUrl="http://localhost:3001" position="left" projectKey="my-project" />
86
- </>
87
- );
88
- }
89
- ```
90
-
91
- ### Usage
92
-
93
- ```tsx
94
- import { LaunchDarklyToolbar } from '@launchdarkly/toolbar';
95
-
96
- function App() {
97
- return (
98
- <>
99
- <main>{/* Your app content */}</main>
100
-
101
- {/* Only show toolbar in development */}
102
- {process.env.NODE_ENV === 'development' && <LaunchDarklyToolbar />}
103
- </>
41
+ <div>
42
+ <h1>My App</h1>
43
+ <LaunchDarklyToolbar flagOverridePlugin={flagOverridePlugin} />
44
+ </div>
104
45
  );
105
46
  }
106
47
  ```
107
48
 
108
- ## How It Works
109
-
110
- The LaunchDarkly Toolbar connects to your LaunchDarkly development server to provide real-time flag management capabilities:
111
-
112
- 1. **Automatic Discovery** - The toolbar automatically discovers available flags from your dev server
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
49
+ ## Props
116
50
 
117
- ## Toolbar Visibility Control
51
+ | Prop | Type | Default | Description |
52
+ | -------------------- | --------------------- | ----------- | ------------------------------------------------------------------------- |
53
+ | `devServerUrl` | `string` (optional) | `undefined` | URL of your LaunchDarkly dev server. If provided, enables Dev Server Mode |
54
+ | `flagOverridePlugin` | `IFlagOverridePlugin` | `undefined` | Flag override plugin for SDK Mode. Shows Overrides tab when provided |
55
+ | `position` | `"left" \| "right"` | `"right"` | Position of the toolbar on screen |
56
+ | `projectKey` | `string` (optional) | `undefined` | Optional project key for multi-project setups (Dev Server Mode only) |
57
+ | `pollIntervalInMs` | `number` (optional) | `5000` | Polling interval for dev server updates (Dev Server Mode only) |
118
58
 
119
- The toolbar includes built-in visibility controls that allow developers to easily show/hide the toolbar during development. When the toolbar loads, it automatically exposes a global API on the browser's window object.
59
+ ## Configuration
120
60
 
121
- ### Global API
61
+ ### Mode Determination
122
62
 
123
- The toolbar provides a `window.ldToolbar` API with the following methods:
63
+ The toolbar automatically determines its mode:
124
64
 
125
- ```javascript
126
- // Enable the toolbar (removes it from localStorage and shows the toolbar)
127
- window.ldToolbar.enable();
128
-
129
- // Disable the toolbar (saves preference to localStorage and hides the toolbar)
130
- window.ldToolbar.disable();
65
+ - **Dev Server Mode**: When `devServerUrl` is provided
66
+ - **SDK Mode**: When `devServerUrl` is omitted
131
67
 
132
- // Toggle the toolbar visibility
133
- window.ldToolbar.toggle();
68
+ ### Available Features by Mode
134
69
 
135
- // Check current status (returns true if enabled, false if disabled)
136
- window.ldToolbar.status();
137
- ```
70
+ | Mode | Available Tabs |
71
+ | ------------------- | ------------------------------------------------------ |
72
+ | **Dev Server Mode** | Flags, Settings |
73
+ | **SDK Mode** | Overrides (if `flagOverridePlugin` provided), Settings |
138
74
 
139
- ### Console Information
75
+ ## Setup
140
76
 
141
- When the toolbar loads, you'll see helpful console output showing the available commands:
77
+ **Dev Server Mode**: Start your LaunchDarkly dev server with CORS enabled:
142
78
 
143
- ```
144
- 🔧 LaunchDarkly toolbar controls available:
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
79
+ ```bash
80
+ ldcli dev-server start --project your-project --cors-enabled true
149
81
  ```
150
82
 
151
- ### Persistent State
83
+ **SDK Mode**: No additional setup required.
152
84
 
153
- The toolbar's visibility state is automatically saved to localStorage and persists across browser sessions. The state is also synchronized across multiple tabs of the same application.
85
+ ## Visibility Control
154
86
 
155
- ### Usage Examples
87
+ The toolbar provides a global API for show/hide control:
156
88
 
157
89
  ```javascript
158
- // Hide the toolbar for focused development
159
- window.ldToolbar.disable();
160
- // Console: ✅ LaunchDarkly toolbar disabled.
90
+ // Toggle visibility
91
+ window.ldToolbar.toggle();
161
92
 
162
- // Show the toolbar when you need it
93
+ // Enable/disable explicitly
163
94
  window.ldToolbar.enable();
164
- // Console: ✅ LaunchDarkly toolbar enabled.
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
95
+ window.ldToolbar.disable();
170
96
 
171
- // Quick toggle
172
- window.ldToolbar.toggle();
97
+ // Check current status
98
+ window.ldToolbar.status(); // returns true/false
173
99
  ```
174
100
 
175
- ## Development Server Setup
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
- ```
101
+ Visibility preferences are automatically saved to localStorage.
182
102
 
183
103
  ## TypeScript
184
104
 
@@ -186,12 +106,8 @@ The package includes complete TypeScript definitions. No additional `@types` pac
186
106
 
187
107
  ```tsx
188
108
  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
109
  ```
196
110
 
111
+ ---
112
+
197
113
  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';