@launchdarkly/toolbar 0.26.0 → 1.0.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.
Files changed (148) hide show
  1. package/README.md +276 -161
  2. package/cdn/toolbar.min.js +24 -0
  3. package/cdn/toolbar.min.js.LICENSE.txt +59 -0
  4. package/dist/core/context/Providers.d.ts +9 -0
  5. package/dist/core/context/ReactMountContext.d.ts +2 -0
  6. package/dist/core/context/ShadowRootContext.d.ts +2 -0
  7. package/dist/core/context/defaultConfig.d.ts +3 -0
  8. package/dist/core/index.d.ts +8 -0
  9. package/dist/core/mount.d.ts +2 -0
  10. package/dist/{ui → core/ui}/Toolbar/LaunchDarklyToolbar.d.ts +3 -1
  11. package/dist/{ui → core/ui}/Toolbar/TabContent/EventsTabContent.d.ts +1 -1
  12. package/dist/{ui → core/ui}/Toolbar/TabContent/FlagSdkOverrideTabContent.d.ts +1 -1
  13. package/dist/{ui → core/ui}/Toolbar/components/ExpandedToolbarContent.d.ts +1 -1
  14. package/dist/{ui → core/ui}/Toolbar/components/TabContentRenderer.d.ts +1 -1
  15. package/dist/{ui → core/ui}/Toolbar/context/FlagSdkOverrideProvider.d.ts +1 -1
  16. package/dist/{ui → core/ui}/Toolbar/hooks/useEvents.d.ts +1 -2
  17. package/dist/{ui → core/ui}/Toolbar/hooks/useToolbarState.d.ts +1 -0
  18. package/dist/core/utils/hydrateConfig.d.ts +2 -0
  19. package/dist/{js/plugins/index.js → index.cjs} +278 -133
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.ts +9 -10
  22. package/dist/js/index.js +226 -7799
  23. package/dist/js/index.js.map +1 -0
  24. package/dist/react/lazyLoadToolbar.d.ts +2 -0
  25. package/dist/react/useLaunchDarklyToolbar.d.ts +20 -0
  26. package/dist/types/analytics.d.ts +1 -0
  27. package/dist/types/config.d.ts +54 -0
  28. package/dist/{hooks → types/hooks}/AfterEvaluationHook.d.ts +1 -1
  29. package/dist/{hooks → types/hooks}/AfterIdentifyHook.d.ts +1 -1
  30. package/dist/{hooks → types/hooks}/AfterTrackHook.d.ts +1 -1
  31. package/dist/{hooks → types/hooks}/EventStore.d.ts +1 -1
  32. package/dist/types/index.d.ts +5 -0
  33. package/dist/{plugins/EventInterceptionPlugin.d.ts → types/plugins/eventInterceptionPlugin.d.ts} +2 -2
  34. package/dist/{plugins/FlagOverridePlugin.d.ts → types/plugins/flagOverridePlugin.d.ts} +1 -1
  35. package/dist/types/plugins/index.d.ts +3 -0
  36. package/dist/types/{plugin.d.ts → plugins/plugins.d.ts} +1 -4
  37. package/dist/types/position.d.ts +2 -0
  38. package/package.json +55 -45
  39. package/LICENSE +0 -13
  40. package/dist/plugins/index.d.ts +0 -4
  41. package/dist/tests/DevServerProvider.test.d.ts +0 -1
  42. package/dist/tests/ExpandedToolbarContent.test.d.ts +0 -1
  43. package/dist/tests/FlagSdkOverrideProvider.test.d.ts +0 -1
  44. package/dist/tests/LaunchDarklyToolbar.test.d.ts +0 -1
  45. package/dist/tests/Tabs.test.d.ts +0 -1
  46. package/dist/tests/hooks/AfterEvaluationHook.test.d.ts +0 -1
  47. package/dist/tests/hooks/AfterIdentifyHook.test.d.ts +0 -1
  48. package/dist/tests/hooks/AfterTrackHook.test.d.ts +0 -1
  49. package/dist/tests/hooks/EventStore.test.d.ts +0 -1
  50. package/dist/tests/plugins/EventInterceptionPlugin.test.d.ts +0 -1
  51. package/dist/vendor/launchpad/Button.d.ts +0 -19
  52. package/dist/vendor/launchpad/Group.d.ts +0 -11
  53. package/dist/vendor/launchpad/Input.d.ts +0 -15
  54. package/dist/vendor/launchpad/ListBox.d.ts +0 -15
  55. package/dist/vendor/launchpad/Popover.d.ts +0 -13
  56. package/dist/vendor/launchpad/SearchField.d.ts +0 -10
  57. package/dist/vendor/launchpad/Select.d.ts +0 -16
  58. package/dist/vendor/launchpad/Switch.d.ts +0 -10
  59. package/dist/vendor/launchpad/TextField.d.ts +0 -10
  60. package/dist/vendor/launchpad/index.d.ts +0 -18
  61. package/dist/vendor/launchpad/utils.d.ts +0 -4
  62. /package/dist/{services → core/services}/DevServerClient.d.ts +0 -0
  63. /package/dist/{services → core/services}/FlagStateManager.d.ts +0 -0
  64. /package/dist/{tests → core/tests}/mocks/flags.d.ts +0 -0
  65. /package/dist/{types → core/types}/devServer.d.ts +0 -0
  66. /package/dist/{ui → core/ui}/List/List.css.d.ts +0 -0
  67. /package/dist/{ui → core/ui}/List/List.d.ts +0 -0
  68. /package/dist/{ui → core/ui}/List/ListItem.d.ts +0 -0
  69. /package/dist/{ui → core/ui}/Tabs/TabButton.d.ts +0 -0
  70. /package/dist/{ui → core/ui}/Tabs/Tabs.css.d.ts +0 -0
  71. /package/dist/{ui → core/ui}/Tabs/Tabs.d.ts +0 -0
  72. /package/dist/{ui → core/ui}/Tabs/useTabsContext.d.ts +0 -0
  73. /package/dist/{ui → core/ui}/Toolbar/Header/Header.css.d.ts +0 -0
  74. /package/dist/{ui → core/ui}/Toolbar/Header/Header.d.ts +0 -0
  75. /package/dist/{ui → core/ui}/Toolbar/Header/components/ActionButtons.d.ts +0 -0
  76. /package/dist/{ui → core/ui}/Toolbar/Header/components/EnvironmentLabel.d.ts +0 -0
  77. /package/dist/{ui → core/ui}/Toolbar/Header/components/LogoSection.d.ts +0 -0
  78. /package/dist/{ui → core/ui}/Toolbar/Header/components/SearchSection.d.ts +0 -0
  79. /package/dist/{ui → core/ui}/Toolbar/Header/components/index.d.ts +0 -0
  80. /package/dist/{ui → core/ui}/Toolbar/LaunchDarklyToolbar.css.d.ts +0 -0
  81. /package/dist/{ui → core/ui}/Toolbar/TabContent/EventsTabContent.css.d.ts +0 -0
  82. /package/dist/{ui → core/ui}/Toolbar/TabContent/FlagDevServerTabContent.css.d.ts +0 -0
  83. /package/dist/{ui → core/ui}/Toolbar/TabContent/FlagDevServerTabContent.d.ts +0 -0
  84. /package/dist/{ui → core/ui}/Toolbar/TabContent/SettingsTab.css.d.ts +0 -0
  85. /package/dist/{ui → core/ui}/Toolbar/TabContent/SettingsTabContent.d.ts +0 -0
  86. /package/dist/{ui → core/ui}/Toolbar/components/ActionButtonsContainer.css.d.ts +0 -0
  87. /package/dist/{ui → core/ui}/Toolbar/components/ActionButtonsContainer.d.ts +0 -0
  88. /package/dist/{ui → core/ui}/Toolbar/components/CircleLogo.d.ts +0 -0
  89. /package/dist/{ui → core/ui}/Toolbar/components/ConnectionStatus.css.d.ts +0 -0
  90. /package/dist/{ui → core/ui}/Toolbar/components/ConnectionStatus.d.ts +0 -0
  91. /package/dist/{ui → core/ui}/Toolbar/components/DoNotTrackWarning.css.d.ts +0 -0
  92. /package/dist/{ui → core/ui}/Toolbar/components/DoNotTrackWarning.d.ts +0 -0
  93. /package/dist/{ui → core/ui}/Toolbar/components/ErrorMessage.css.d.ts +0 -0
  94. /package/dist/{ui → core/ui}/Toolbar/components/ErrorMessage.d.ts +0 -0
  95. /package/dist/{ui → core/ui}/Toolbar/components/FlagControls.css.d.ts +0 -0
  96. /package/dist/{ui → core/ui}/Toolbar/components/FlagControls.d.ts +0 -0
  97. /package/dist/{ui → core/ui}/Toolbar/components/GenericHelpText.css.d.ts +0 -0
  98. /package/dist/{ui → core/ui}/Toolbar/components/GenericHelpText.d.ts +0 -0
  99. /package/dist/{ui → core/ui}/Toolbar/components/IconButton.css.d.ts +0 -0
  100. /package/dist/{ui → core/ui}/Toolbar/components/IconButton.d.ts +0 -0
  101. /package/dist/{ui → core/ui}/Toolbar/components/IconLinkButton.d.ts +0 -0
  102. /package/dist/{ui → core/ui}/Toolbar/components/LocalFlagControls.css.d.ts +0 -0
  103. /package/dist/{ui → core/ui}/Toolbar/components/LocalFlagControls.d.ts +0 -0
  104. /package/dist/{ui → core/ui}/Toolbar/components/OverrideIndicator.css.d.ts +0 -0
  105. /package/dist/{ui → core/ui}/Toolbar/components/OverrideIndicator.d.ts +0 -0
  106. /package/dist/{ui → core/ui}/Toolbar/components/Popover.css.d.ts +0 -0
  107. /package/dist/{ui → core/ui}/Toolbar/components/StatusDot.css.d.ts +0 -0
  108. /package/dist/{ui → core/ui}/Toolbar/components/StatusDot.d.ts +0 -0
  109. /package/dist/{ui → core/ui}/Toolbar/components/icons/AddIcon.d.ts +0 -0
  110. /package/dist/{ui → core/ui}/Toolbar/components/icons/ArrowUndoIcon.d.ts +0 -0
  111. /package/dist/{ui → core/ui}/Toolbar/components/icons/CancelCircleIcon.d.ts +0 -0
  112. /package/dist/{ui → core/ui}/Toolbar/components/icons/CheckIcon.d.ts +0 -0
  113. /package/dist/{ui → core/ui}/Toolbar/components/icons/ChevronDownIcon.d.ts +0 -0
  114. /package/dist/{ui → core/ui}/Toolbar/components/icons/ChevronUpIcon.d.ts +0 -0
  115. /package/dist/{ui → core/ui}/Toolbar/components/icons/DeleteIcon.d.ts +0 -0
  116. /package/dist/{ui → core/ui}/Toolbar/components/icons/EditIcon.d.ts +0 -0
  117. /package/dist/{ui → core/ui}/Toolbar/components/icons/GearIcon.d.ts +0 -0
  118. /package/dist/{ui → core/ui}/Toolbar/components/icons/Icon.css.d.ts +0 -0
  119. /package/dist/{ui → core/ui}/Toolbar/components/icons/LaunchDarklyIcon.d.ts +0 -0
  120. /package/dist/{ui → core/ui}/Toolbar/components/icons/LaunchDarklyLogo.d.ts +0 -0
  121. /package/dist/{ui → core/ui}/Toolbar/components/icons/SearchIcon.d.ts +0 -0
  122. /package/dist/{ui → core/ui}/Toolbar/components/icons/SyncIcon.d.ts +0 -0
  123. /package/dist/{ui → core/ui}/Toolbar/components/icons/ToggleOffIcon.d.ts +0 -0
  124. /package/dist/{ui → core/ui}/Toolbar/components/icons/XIcon.d.ts +0 -0
  125. /package/dist/{ui → core/ui}/Toolbar/components/icons/index.d.ts +0 -0
  126. /package/dist/{ui → core/ui}/Toolbar/components/index.d.ts +0 -0
  127. /package/dist/{ui → core/ui}/Toolbar/constants/animations.d.ts +0 -0
  128. /package/dist/{ui → core/ui}/Toolbar/constants/index.d.ts +0 -0
  129. /package/dist/{ui → core/ui}/Toolbar/constants/virtualization.d.ts +0 -0
  130. /package/dist/{ui → core/ui}/Toolbar/context/AnalyticsProvider.d.ts +0 -0
  131. /package/dist/{ui → core/ui}/Toolbar/context/DevServerProvider.d.ts +0 -0
  132. /package/dist/{ui → core/ui}/Toolbar/context/SearchProvider.d.ts +0 -0
  133. /package/dist/{ui → core/ui}/Toolbar/context/ToolbarUIProvider.d.ts +0 -0
  134. /package/dist/{ui → core/ui}/Toolbar/context/index.d.ts +0 -0
  135. /package/dist/{ui → core/ui}/Toolbar/hooks/index.d.ts +0 -0
  136. /package/dist/{ui → core/ui}/Toolbar/hooks/useCurrentDate.d.ts +0 -0
  137. /package/dist/{ui → core/ui}/Toolbar/hooks/useToolbarAnimations.d.ts +0 -0
  138. /package/dist/{ui → core/ui}/Toolbar/hooks/useToolbarDrag.d.ts +0 -0
  139. /package/dist/{ui → core/ui}/Toolbar/hooks/useToolbarVisibility.d.ts +0 -0
  140. /package/dist/{ui → core/ui}/Toolbar/types/index.d.ts +0 -0
  141. /package/dist/{ui → core/ui}/Toolbar/types/toolbar.d.ts +0 -0
  142. /package/dist/{ui → core/ui}/Toolbar/utils/localStorage.d.ts +0 -0
  143. /package/dist/{ui → core/ui}/constants/zIndex.d.ts +0 -0
  144. /package/dist/{utils → core/utils}/analytics.d.ts +0 -0
  145. /package/dist/{utils → core/utils}/browser.d.ts +0 -0
  146. /package/dist/{utils → core/utils}/deepEqual.d.ts +0 -0
  147. /package/dist/{utils → core/utils}/index.d.ts +0 -0
  148. /package/dist/{hooks → types/hooks}/index.d.ts +0 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license React
3
+ * react-dom-client.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react-dom.production.js
14
+ *
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * react-jsx-runtime.production.js
24
+ *
25
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+
31
+ /**
32
+ * @license React
33
+ * react.production.js
34
+ *
35
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
40
+
41
+ /**
42
+ * @license React
43
+ * scheduler.production.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */
50
+
51
+ /**
52
+ * @license React
53
+ * use-sync-external-store-shim.production.js
54
+ *
55
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE file in the root directory of this source tree.
59
+ */
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ interface Props {
3
+ children: ReactNode;
4
+ portalMount: HTMLElement;
5
+ reactMount: HTMLElement;
6
+ shadowRoot: ShadowRoot;
7
+ }
8
+ export default function Providers(props: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const ReactMountContext: import("react").Context<HTMLElement>;
2
+ export default ReactMountContext;
@@ -0,0 +1,2 @@
1
+ declare const ShadowRootContext: import("react").Context<ShadowRoot>;
2
+ export default ShadowRootContext;
@@ -0,0 +1,3 @@
1
+ import { InitializationConfig } from '../../types';
2
+ declare const defaultConfig: InitializationConfig;
3
+ export default defaultConfig;
@@ -0,0 +1,8 @@
1
+ import { InitializationConfig } from '../types';
2
+ import './globals.css';
3
+ export type Cleanup = () => void;
4
+ export declare function init(config: InitializationConfig): Cleanup;
5
+ declare const LaunchDarklyToolbar: {
6
+ init: typeof init;
7
+ };
8
+ export default LaunchDarklyToolbar;
@@ -0,0 +1,2 @@
1
+ import { InitializationConfig } from '../types';
2
+ export default function mount(rootNode: HTMLElement, config: InitializationConfig): () => void;
@@ -1,10 +1,11 @@
1
1
  import { ToolbarMode, ToolbarPosition } from './types/toolbar';
2
- import type { IEventInterceptionPlugin, IFlagOverridePlugin } from '../../types/plugin';
2
+ import { IEventInterceptionPlugin, IFlagOverridePlugin } from '../../../types';
3
3
  export interface LdToolbarProps {
4
4
  mode: ToolbarMode;
5
5
  baseUrl: string;
6
6
  flagOverridePlugin?: IFlagOverridePlugin;
7
7
  eventInterceptionPlugin?: IEventInterceptionPlugin;
8
+ domId: string;
8
9
  }
9
10
  export declare function LdToolbar(props: LdToolbarProps): import("react/jsx-runtime").JSX.Element;
10
11
  export interface LaunchDarklyToolbarProps {
@@ -15,5 +16,6 @@ export interface LaunchDarklyToolbarProps {
15
16
  eventInterceptionPlugin?: IEventInterceptionPlugin;
16
17
  pollIntervalInMs?: number;
17
18
  position?: ToolbarPosition;
19
+ domId: string;
18
20
  }
19
21
  export declare function LaunchDarklyToolbar(props: LaunchDarklyToolbarProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,4 +1,4 @@
1
- import type { IEventInterceptionPlugin } from '../../../types/plugin';
1
+ import { IEventInterceptionPlugin } from '../../../../types';
2
2
  interface EventsTabContentProps {
3
3
  baseUrl: string;
4
4
  eventInterceptionPlugin?: IEventInterceptionPlugin;
@@ -1,4 +1,4 @@
1
- import type { IFlagOverridePlugin } from '../../../types/plugin';
1
+ import { IFlagOverridePlugin } from '../../../../types';
2
2
  interface FlagSdkOverrideTabContentProps {
3
3
  flagOverridePlugin?: IFlagOverridePlugin;
4
4
  reloadOnFlagChangeIsEnabled: boolean;
@@ -1,6 +1,6 @@
1
1
  import React, { Dispatch, SetStateAction } from 'react';
2
2
  import { ActiveTabId, ToolbarMode } from '../types';
3
- import type { IFlagOverridePlugin, IEventInterceptionPlugin } from '../../../types/plugin';
3
+ import { IEventInterceptionPlugin, IFlagOverridePlugin } from '../../../../types';
4
4
  interface ExpandedToolbarContentProps {
5
5
  activeTab: ActiveTabId;
6
6
  slideDirection: number;
@@ -1,5 +1,5 @@
1
1
  import { TabId, ToolbarMode } from '../types';
2
- import type { IFlagOverridePlugin, IEventInterceptionPlugin } from '../../../types/plugin';
2
+ import { IEventInterceptionPlugin, IFlagOverridePlugin } from '../../../../types';
3
3
  interface TabContentRendererProps {
4
4
  activeTab: TabId;
5
5
  baseUrl: string;
@@ -1,4 +1,4 @@
1
- import type { IFlagOverridePlugin } from '../../../types/plugin';
1
+ import { IFlagOverridePlugin } from '../../../../types';
2
2
  interface LocalFlag {
3
3
  key: string;
4
4
  name: string;
@@ -1,5 +1,4 @@
1
- import type { ProcessedEvent } from '../../../types/events';
2
- import { IEventInterceptionPlugin } from '../../../types/plugin';
1
+ import { IEventInterceptionPlugin, ProcessedEvent } from '../../../../types';
3
2
  interface EventStats {
4
3
  totalEvents: number;
5
4
  eventsByKind: Record<string, number>;
@@ -2,6 +2,7 @@ import { Dispatch, SetStateAction } from 'react';
2
2
  import { ActiveTabId } from '../types';
3
3
  export interface UseToolbarStateProps {
4
4
  defaultActiveTab: ActiveTabId;
5
+ domId: string;
5
6
  }
6
7
  export interface UseToolbarStateReturn {
7
8
  isExpanded: boolean;
@@ -0,0 +1,2 @@
1
+ import { InitializationConfig } from '../../types';
2
+ export default function hydrateProps(config: InitializationConfig): InitializationConfig;
@@ -1,135 +1,64 @@
1
- const DEFAULT_STORAGE_NAMESPACE = 'ld-flag-override';
2
- class FlagOverridePlugin {
3
- debugOverride;
4
- config;
5
- ldClient = null;
6
- constructor(config = {}){
7
- this.config = {
8
- storageNamespace: config.storageNamespace ?? DEFAULT_STORAGE_NAMESPACE
9
- };
10
- }
11
- getMetadata() {
12
- return {
13
- name: 'FlagOverridePlugin'
14
- };
15
- }
16
- getHooks(_metadata) {
17
- return [];
18
- }
19
- register(ldClient) {
20
- this.ldClient = ldClient;
21
- }
22
- registerDebug(debugOverride) {
23
- this.debugOverride = debugOverride;
24
- this.loadExistingOverrides();
25
- }
26
- loadExistingOverrides() {
27
- if (!this.debugOverride) return;
28
- const storage = this.getStorage();
29
- if (!storage) return;
30
- try {
31
- for(let i = 0; i < storage.length; i++){
32
- const key = storage.key(i);
33
- if (!key?.startsWith(this.config.storageNamespace + ':')) continue;
34
- const storedValue = storage.getItem(key);
35
- if (storedValue) try {
36
- const value = JSON.parse(storedValue);
37
- const flagKey = key.replace(this.config.storageNamespace + ':', '');
38
- this.debugOverride.setOverride(flagKey, value);
39
- } catch {
40
- console.warn('flagOverridePlugin: Invalid stored value for', key);
41
- storage.removeItem(key);
42
- }
43
- }
44
- } catch (error) {
45
- console.error('flagOverridePlugin: Error loading existing overrides:', error);
46
- }
47
- }
48
- setOverride(flagKey, value) {
49
- if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
50
- if (!flagKey || 'string' != typeof flagKey) return void console.error('flagOverridePlugin: Invalid flag key:', flagKey);
51
- if (void 0 === value) return void console.error('flagOverridePlugin: Cannot set undefined value for flag override');
52
- try {
53
- this.persistOverride(flagKey, value);
54
- this.debugOverride.setOverride(flagKey, value);
55
- } catch (error) {
56
- console.error('flagOverridePlugin: Failed to set override:', error);
57
- }
58
- }
59
- removeOverride(flagKey) {
60
- if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
61
- if (!flagKey || 'string' != typeof flagKey) return void console.error('flagOverridePlugin: Invalid flag key:', flagKey);
62
- try {
63
- this.removePersistedOverride(flagKey);
64
- this.debugOverride.removeOverride(flagKey);
65
- } catch (error) {
66
- console.error('flagOverridePlugin: Failed to remove override:', error);
67
- }
68
- }
69
- clearAllOverrides() {
70
- if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
71
- try {
72
- this.clearPersistedOverrides();
73
- this.debugOverride.clearAllOverrides();
74
- } catch (error) {
75
- console.error('flagOverridePlugin: Failed to clear overrides:', error);
76
- }
77
- }
78
- getAllOverrides() {
79
- if (!this.debugOverride) {
80
- console.warn('flagOverridePlugin: Debug interface not available');
81
- return {};
82
- }
83
- try {
84
- return this.debugOverride.getAllOverrides();
85
- } catch (error) {
86
- console.error('flagOverridePlugin: Failed to get overrides:', error);
87
- return {};
88
- }
89
- }
90
- getClient() {
91
- return this.ldClient;
92
- }
93
- getStorage() {
94
- if ('undefined' == typeof window) return null;
95
- return window.localStorage;
96
- }
97
- persistOverride(flagKey, value) {
98
- const storage = this.getStorage();
99
- if (!storage) return;
100
- try {
101
- const storageKey = `${this.config.storageNamespace}:${flagKey}`;
102
- storage.setItem(storageKey, JSON.stringify(value));
103
- } catch (error) {
104
- console.error('flagOverridePlugin: Failed to persist override:', error);
105
- }
106
- }
107
- removePersistedOverride(flagKey) {
108
- const storage = this.getStorage();
109
- if (!storage) return;
110
- try {
111
- const storageKey = `${this.config.storageNamespace}:${flagKey}`;
112
- storage.removeItem(storageKey);
113
- } catch (error) {
114
- console.error('flagOverridePlugin: Failed to remove persisted override:', error);
115
- }
116
- }
117
- clearPersistedOverrides() {
118
- const storage = this.getStorage();
119
- if (!storage) return;
120
- try {
121
- const keysToRemove = [];
122
- const prefix = this.config.storageNamespace + ':';
123
- for(let i = 0; i < storage.length; i++){
124
- const key = storage.key(i);
125
- if (key?.startsWith(prefix)) keysToRemove.push(key);
126
- }
127
- keysToRemove.forEach((key)=>storage.removeItem(key));
128
- } catch (error) {
129
- console.error('flagOverridePlugin: Failed to clear persisted overrides:', error);
130
- }
131
- }
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ isValidEventKind: ()=>isValidEventKind,
28
+ ANALYTICS_EVENT_PREFIX: ()=>ANALYTICS_EVENT_PREFIX,
29
+ EventInterceptionPlugin: ()=>EventInterceptionPlugin,
30
+ FlagOverridePlugin: ()=>FlagOverridePlugin,
31
+ TOOLBAR_POSITIONS: ()=>TOOLBAR_POSITIONS,
32
+ useLaunchDarklyToolbar: ()=>useLaunchDarklyToolbar,
33
+ isValidEventCategory: ()=>isValidEventCategory
34
+ });
35
+ const ANALYTICS_EVENT_PREFIX = 'ld.toolbar';
36
+ const VALID_EVENT_KINDS = [
37
+ 'identify',
38
+ 'feature',
39
+ 'custom',
40
+ 'debug',
41
+ 'summary',
42
+ 'diagnostic'
43
+ ];
44
+ const VALID_EVENT_CATEGORIES = [
45
+ 'flag',
46
+ 'custom',
47
+ 'identify',
48
+ 'debug'
49
+ ];
50
+ function isValidEventKind(kind) {
51
+ return VALID_EVENT_KINDS.includes(kind);
52
+ }
53
+ function isValidEventCategory(category) {
54
+ return VALID_EVENT_CATEGORIES.includes(category);
132
55
  }
56
+ const TOOLBAR_POSITIONS = [
57
+ 'top-left',
58
+ 'top-right',
59
+ 'bottom-left',
60
+ 'bottom-right'
61
+ ];
133
62
  const DEFAULT_MAX_EVENTS = 100;
134
63
  class EventStore {
135
64
  events = [];
@@ -366,7 +295,6 @@ class AfterEvaluationHook {
366
295
  };
367
296
  }
368
297
  }
369
- const ANALYTICS_EVENT_PREFIX = 'ld.toolbar';
370
298
  class EventInterceptionPlugin {
371
299
  afterTrackHook;
372
300
  afterIdentifyHook;
@@ -441,4 +369,221 @@ class EventInterceptionPlugin {
441
369
  this.eventStore.destroy();
442
370
  }
443
371
  }
444
- export { EventInterceptionPlugin, FlagOverridePlugin };
372
+ const DEFAULT_STORAGE_NAMESPACE = 'ld-flag-override';
373
+ class FlagOverridePlugin {
374
+ debugOverride;
375
+ config;
376
+ ldClient = null;
377
+ constructor(config = {}){
378
+ this.config = {
379
+ storageNamespace: config.storageNamespace ?? DEFAULT_STORAGE_NAMESPACE
380
+ };
381
+ }
382
+ getMetadata() {
383
+ return {
384
+ name: 'FlagOverridePlugin'
385
+ };
386
+ }
387
+ getHooks(_metadata) {
388
+ return [];
389
+ }
390
+ register(ldClient) {
391
+ this.ldClient = ldClient;
392
+ }
393
+ registerDebug(debugOverride) {
394
+ this.debugOverride = debugOverride;
395
+ this.loadExistingOverrides();
396
+ }
397
+ loadExistingOverrides() {
398
+ if (!this.debugOverride) return;
399
+ const storage = this.getStorage();
400
+ if (!storage) return;
401
+ try {
402
+ for(let i = 0; i < storage.length; i++){
403
+ const key = storage.key(i);
404
+ if (!key?.startsWith(this.config.storageNamespace + ':')) continue;
405
+ const storedValue = storage.getItem(key);
406
+ if (storedValue) try {
407
+ const value = JSON.parse(storedValue);
408
+ const flagKey = key.replace(this.config.storageNamespace + ':', '');
409
+ this.debugOverride.setOverride(flagKey, value);
410
+ } catch {
411
+ console.warn('flagOverridePlugin: Invalid stored value for', key);
412
+ storage.removeItem(key);
413
+ }
414
+ }
415
+ } catch (error) {
416
+ console.error('flagOverridePlugin: Error loading existing overrides:', error);
417
+ }
418
+ }
419
+ setOverride(flagKey, value) {
420
+ if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
421
+ if (!flagKey || 'string' != typeof flagKey) return void console.error('flagOverridePlugin: Invalid flag key:', flagKey);
422
+ if (void 0 === value) return void console.error('flagOverridePlugin: Cannot set undefined value for flag override');
423
+ try {
424
+ this.persistOverride(flagKey, value);
425
+ this.debugOverride.setOverride(flagKey, value);
426
+ } catch (error) {
427
+ console.error('flagOverridePlugin: Failed to set override:', error);
428
+ }
429
+ }
430
+ removeOverride(flagKey) {
431
+ if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
432
+ if (!flagKey || 'string' != typeof flagKey) return void console.error('flagOverridePlugin: Invalid flag key:', flagKey);
433
+ try {
434
+ this.removePersistedOverride(flagKey);
435
+ this.debugOverride.removeOverride(flagKey);
436
+ } catch (error) {
437
+ console.error('flagOverridePlugin: Failed to remove override:', error);
438
+ }
439
+ }
440
+ clearAllOverrides() {
441
+ if (!this.debugOverride) return void console.warn('flagOverridePlugin: Debug interface not available');
442
+ try {
443
+ this.clearPersistedOverrides();
444
+ this.debugOverride.clearAllOverrides();
445
+ } catch (error) {
446
+ console.error('flagOverridePlugin: Failed to clear overrides:', error);
447
+ }
448
+ }
449
+ getAllOverrides() {
450
+ if (!this.debugOverride) {
451
+ console.warn('flagOverridePlugin: Debug interface not available');
452
+ return {};
453
+ }
454
+ try {
455
+ return this.debugOverride.getAllOverrides();
456
+ } catch (error) {
457
+ console.error('flagOverridePlugin: Failed to get overrides:', error);
458
+ return {};
459
+ }
460
+ }
461
+ getClient() {
462
+ return this.ldClient;
463
+ }
464
+ getStorage() {
465
+ if ('undefined' == typeof window) return null;
466
+ return window.localStorage;
467
+ }
468
+ persistOverride(flagKey, value) {
469
+ const storage = this.getStorage();
470
+ if (!storage) return;
471
+ try {
472
+ const storageKey = `${this.config.storageNamespace}:${flagKey}`;
473
+ storage.setItem(storageKey, JSON.stringify(value));
474
+ } catch (error) {
475
+ console.error('flagOverridePlugin: Failed to persist override:', error);
476
+ }
477
+ }
478
+ removePersistedOverride(flagKey) {
479
+ const storage = this.getStorage();
480
+ if (!storage) return;
481
+ try {
482
+ const storageKey = `${this.config.storageNamespace}:${flagKey}`;
483
+ storage.removeItem(storageKey);
484
+ } catch (error) {
485
+ console.error('flagOverridePlugin: Failed to remove persisted override:', error);
486
+ }
487
+ }
488
+ clearPersistedOverrides() {
489
+ const storage = this.getStorage();
490
+ if (!storage) return;
491
+ try {
492
+ const keysToRemove = [];
493
+ const prefix = this.config.storageNamespace + ':';
494
+ for(let i = 0; i < storage.length; i++){
495
+ const key = storage.key(i);
496
+ if (key?.startsWith(prefix)) keysToRemove.push(key);
497
+ }
498
+ keysToRemove.forEach((key)=>storage.removeItem(key));
499
+ } catch (error) {
500
+ console.error('flagOverridePlugin: Failed to clear persisted overrides:', error);
501
+ }
502
+ }
503
+ }
504
+ const external_react_namespaceObject = require("react");
505
+ function getWindow() {
506
+ return window;
507
+ }
508
+ async function lazyLoadToolbar(signal, url) {
509
+ const existing = getWindow().LaunchDarklyToolbar;
510
+ if (existing) return Promise.resolve(existing);
511
+ await lazyLoad(signal, url);
512
+ const toolbarModule = getWindow().LaunchDarklyToolbar;
513
+ if (!toolbarModule) throw new Error(`Unable to detect LaunchDarklyToolbar global from ${url}`);
514
+ return toolbarModule;
515
+ }
516
+ async function lazyLoad(signal, url) {
517
+ const script = document.createElement("script");
518
+ script.src = url;
519
+ script.crossOrigin = 'anonymous';
520
+ script.referrerPolicy = 'origin';
521
+ const waitForLoad = new Promise((resolve, reject)=>{
522
+ script.addEventListener('load', ()=>{
523
+ if (!signal.aborted) resolve();
524
+ });
525
+ script.addEventListener('error', (error)=>{
526
+ if (!signal.aborted) reject(error);
527
+ });
528
+ });
529
+ document.body.appendChild(script);
530
+ try {
531
+ await waitForLoad;
532
+ } catch (error) {
533
+ console.log(error);
534
+ throw new Error(`Could not load LaunchDarkly developer toolbar bundle from ${url}`);
535
+ }
536
+ }
537
+ var package_namespaceObject = JSON.parse('{"rE":"1.0.1-beta.1"}');
538
+ function useLaunchDarklyToolbar(args) {
539
+ const { toolbarBundleUrl, enabled, ...initConfig } = args;
540
+ const configRef = (0, external_react_namespaceObject.useRef)(null);
541
+ const url = toolbarBundleUrl ?? versionToCdn(package_namespaceObject.rE);
542
+ (0, external_react_namespaceObject.useEffect)(()=>{
543
+ if (false === enabled) return;
544
+ if (null === configRef.current) configRef.current = initConfig;
545
+ }, [
546
+ enabled,
547
+ initConfig
548
+ ]);
549
+ (0, external_react_namespaceObject.useEffect)(()=>{
550
+ if (false === enabled || null === configRef.current) return;
551
+ const controller = new AbortController();
552
+ let cleanup = ()=>{};
553
+ lazyLoadToolbar(controller.signal, url).then((importedToolbar)=>{
554
+ if (null === configRef.current) return;
555
+ cleanup = importedToolbar.init(configRef.current);
556
+ });
557
+ return ()=>{
558
+ controller.abort();
559
+ cleanup();
560
+ };
561
+ }, [
562
+ enabled,
563
+ url
564
+ ]);
565
+ }
566
+ function versionToCdn(version = 'latest') {
567
+ return `https://unpkg.com/@launchdarkly/toolbar@${version}/cdn/toolbar.min.js`;
568
+ }
569
+ exports.ANALYTICS_EVENT_PREFIX = __webpack_exports__.ANALYTICS_EVENT_PREFIX;
570
+ exports.EventInterceptionPlugin = __webpack_exports__.EventInterceptionPlugin;
571
+ exports.FlagOverridePlugin = __webpack_exports__.FlagOverridePlugin;
572
+ exports.TOOLBAR_POSITIONS = __webpack_exports__.TOOLBAR_POSITIONS;
573
+ exports.isValidEventCategory = __webpack_exports__.isValidEventCategory;
574
+ exports.isValidEventKind = __webpack_exports__.isValidEventKind;
575
+ exports.useLaunchDarklyToolbar = __webpack_exports__.useLaunchDarklyToolbar;
576
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
577
+ "ANALYTICS_EVENT_PREFIX",
578
+ "EventInterceptionPlugin",
579
+ "FlagOverridePlugin",
580
+ "TOOLBAR_POSITIONS",
581
+ "isValidEventCategory",
582
+ "isValidEventKind",
583
+ "useLaunchDarklyToolbar"
584
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
585
+ Object.defineProperty(exports, '__esModule', {
586
+ value: true
587
+ });
588
+
589
+ //# sourceMappingURL=index.cjs.map