@launchdarkly/js-client-sdk 0.10.0 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0](https://github.com/launchdarkly/js-core/compare/js-client-sdk-v0.10.0...js-client-sdk-v0.11.0) (2025-12-18)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * align browser v4 intialization flow to specs ([#1040](https://github.com/launchdarkly/js-core/issues/1040))
9
+
10
+ ### Features
11
+
12
+ * adding support for debug override plugins ([#1033](https://github.com/launchdarkly/js-core/issues/1033)) ([17f5e7d](https://github.com/launchdarkly/js-core/commit/17f5e7d7d11d502d54a6ccf88aea6bec3e4b775c))
13
+ * allow clients to evaluate bootstrapped flags when not ready ([#1036](https://github.com/launchdarkly/js-core/issues/1036)) ([9b4542a](https://github.com/launchdarkly/js-core/commit/9b4542a722e5d19e123e860faef113d134dad47c))
14
+ * implement `waitForInitialization` for browser sdk 4.x ([#1028](https://github.com/launchdarkly/js-core/issues/1028)) ([156532a](https://github.com/launchdarkly/js-core/commit/156532aea3ec39635dab21dbab125c81fc31a3f5))
15
+
16
+
17
+ ### Code Refactoring
18
+
19
+ * align browser v4 intialization flow to specs ([#1040](https://github.com/launchdarkly/js-core/issues/1040)) ([eff6a55](https://github.com/launchdarkly/js-core/commit/eff6a55163508bee4f2dec574ad256f88ec513d6))
20
+
21
+
22
+ ### Dependencies
23
+
24
+ * The following workspace dependencies were updated
25
+ * dependencies
26
+ * @launchdarkly/js-client-sdk-common bumped from 1.15.2 to 1.16.0
27
+
3
28
  ## [0.10.0](https://github.com/launchdarkly/js-core/compare/js-client-sdk-v0.9.1...js-client-sdk-v0.10.0) (2025-12-09)
4
29
 
5
30
 
@@ -29,6 +29,68 @@ interface BrowserIdentifyOptions extends Omit<LDIdentifyOptions, 'waitForNetwork
29
29
  bootstrap?: unknown;
30
30
  }
31
31
 
32
+ /**
33
+ * @ignore
34
+ * Currently these options and the waitForInitialization method signiture will mirror the one
35
+ * that is defined in the server common. We will be consolidating this mehod so that it will
36
+ * be common to all sdks in the future.
37
+ */
38
+ /**
39
+ * Options for the waitForInitialization method.
40
+ */
41
+ interface LDWaitForInitializationOptions {
42
+ /**
43
+ * The timeout duration in seconds to wait for initialization before resolving the promise.
44
+ * If exceeded, the promise will resolve to a {@link LDWaitForInitializationTimeout} object.
45
+ *
46
+ * If no options are specified on the `waitForInitialization`, the default timeout of 5 seconds will be used.
47
+ *
48
+ * Using a high timeout, or no timeout, is not recommended because it could result in a long
49
+ * delay when conditions prevent successful initialization.
50
+ *
51
+ * A value of 0 will cause the promise to resolve without waiting. In that scenario it would be
52
+ * more effective to not call `waitForInitialization`.
53
+ *
54
+ * @default 5 seconds
55
+ */
56
+ timeout?: number;
57
+ }
58
+ /**
59
+ * The waitForInitialization operation failed.
60
+ */
61
+ interface LDWaitForInitializationFailed {
62
+ status: 'failed';
63
+ error: Error;
64
+ }
65
+ /**
66
+ * The waitForInitialization operation timed out.
67
+ */
68
+ interface LDWaitForInitializationTimeout {
69
+ status: 'timeout';
70
+ }
71
+ /**
72
+ * The waitForInitialization operation completed successfully.
73
+ */
74
+ interface LDWaitForInitializationComplete {
75
+ status: 'complete';
76
+ }
77
+ /**
78
+ * The result of the waitForInitialization operation.
79
+ */
80
+ type LDWaitForInitializationResult = LDWaitForInitializationFailed | LDWaitForInitializationTimeout | LDWaitForInitializationComplete;
81
+ interface LDStartOptions extends LDWaitForInitializationOptions {
82
+ /**
83
+ * Optional bootstrap data to use for the identify operation. If {@link LDIdentifyOptions.bootstrap} is provided, it will be ignored.
84
+ */
85
+ bootstrap?: unknown;
86
+ /**
87
+ * Optional identify options to use for the identify operation. See {@link LDIdentifyOptions} for more information.
88
+ *
89
+ * @remarks
90
+ * Since the first identify option should never be sheddable, we omit the sheddable option from the interface to avoid confusion.
91
+ */
92
+ identifyOptions?: Omit<BrowserIdentifyOptions, 'sheddable'>;
93
+ }
32
94
  /**
33
95
  *
34
96
  * The LaunchDarkly SDK client object.
@@ -81,6 +143,47 @@ type LDClient = Omit<LDClient$1, 'setConnectionMode' | 'getConnectionMode' | 'ge
81
143
  * @ignore Implementation Note: Browser implementation has different options.
82
144
  */
83
145
  identify(pristineContext: LDContext, identifyOptions?: BrowserIdentifyOptions): Promise<LDIdentifyResult>;
146
+ /**
147
+ * Returns a Promise that tracks the client's initialization state.
148
+ *
149
+ * The Promise will be resolved to a {@link LDWaitForInitializationResult} object containing the
150
+ * status of the waitForInitialization operation.
151
+ *
152
+ * @example
153
+ * This example shows use of async/await syntax for specifying handlers:
154
+ * ```
155
+ * const result = await client.waitForInitialization({ timeout: 5 });
156
+ *
157
+ * if (result.status === 'complete') {
158
+ * doSomethingWithSuccessfullyInitializedClient();
159
+ * } else if (result.status === 'failed') {
160
+ * doSomethingForFailedStartup(result.error);
161
+ * } else if (result.status === 'timeout') {
162
+ * doSomethingForTimedOutStartup();
163
+ * }
164
+ * ```
165
+ *
166
+ * @remarks
167
+ * You can also use event listeners ({@link on}) for the same purpose: the event `"initialized"`
168
+ * indicates success, and `"error"` indicates an error.
169
+ *
170
+ * @param options
171
+ * Optional configuration. Please see {@link LDWaitForInitializationOptions}.
172
+ *
173
+ * @returns
174
+ * A Promise that will be resolved to a {@link LDWaitForInitializationResult} object containing the
175
+ * status of the waitForInitialization operation.
176
+ */
177
+ waitForInitialization(options?: LDWaitForInitializationOptions): Promise<LDWaitForInitializationResult>;
178
+ /**
179
+ * Starts the client and returns a promise that resolves to the initialization result.
180
+ *
181
+ * The promise will resolve to a {@link LDWaitForInitializationResult} object containing the
182
+ * status of the waitForInitialization operation.
183
+ *
184
+ * @param options Optional configuration. Please see {@link LDStartOptions}.
185
+ */
186
+ start(options?: LDStartOptions): Promise<LDWaitForInitializationResult>;
84
187
  };
85
188
 
86
189
  /**
@@ -29,6 +29,68 @@ interface BrowserIdentifyOptions extends Omit<LDIdentifyOptions, 'waitForNetwork
29
29
  bootstrap?: unknown;
30
30
  }
31
31
 
32
+ /**
33
+ * @ignore
34
+ * Currently these options and the waitForInitialization method signiture will mirror the one
35
+ * that is defined in the server common. We will be consolidating this mehod so that it will
36
+ * be common to all sdks in the future.
37
+ */
38
+ /**
39
+ * Options for the waitForInitialization method.
40
+ */
41
+ interface LDWaitForInitializationOptions {
42
+ /**
43
+ * The timeout duration in seconds to wait for initialization before resolving the promise.
44
+ * If exceeded, the promise will resolve to a {@link LDWaitForInitializationTimeout} object.
45
+ *
46
+ * If no options are specified on the `waitForInitialization`, the default timeout of 5 seconds will be used.
47
+ *
48
+ * Using a high timeout, or no timeout, is not recommended because it could result in a long
49
+ * delay when conditions prevent successful initialization.
50
+ *
51
+ * A value of 0 will cause the promise to resolve without waiting. In that scenario it would be
52
+ * more effective to not call `waitForInitialization`.
53
+ *
54
+ * @default 5 seconds
55
+ */
56
+ timeout?: number;
57
+ }
58
+ /**
59
+ * The waitForInitialization operation failed.
60
+ */
61
+ interface LDWaitForInitializationFailed {
62
+ status: 'failed';
63
+ error: Error;
64
+ }
65
+ /**
66
+ * The waitForInitialization operation timed out.
67
+ */
68
+ interface LDWaitForInitializationTimeout {
69
+ status: 'timeout';
70
+ }
71
+ /**
72
+ * The waitForInitialization operation completed successfully.
73
+ */
74
+ interface LDWaitForInitializationComplete {
75
+ status: 'complete';
76
+ }
77
+ /**
78
+ * The result of the waitForInitialization operation.
79
+ */
80
+ type LDWaitForInitializationResult = LDWaitForInitializationFailed | LDWaitForInitializationTimeout | LDWaitForInitializationComplete;
81
+ interface LDStartOptions extends LDWaitForInitializationOptions {
82
+ /**
83
+ * Optional bootstrap data to use for the identify operation. If {@link LDIdentifyOptions.bootstrap} is provided, it will be ignored.
84
+ */
85
+ bootstrap?: unknown;
86
+ /**
87
+ * Optional identify options to use for the identify operation. See {@link LDIdentifyOptions} for more information.
88
+ *
89
+ * @remarks
90
+ * Since the first identify option should never be sheddable, we omit the sheddable option from the interface to avoid confusion.
91
+ */
92
+ identifyOptions?: Omit<BrowserIdentifyOptions, 'sheddable'>;
93
+ }
32
94
  /**
33
95
  *
34
96
  * The LaunchDarkly SDK client object.
@@ -81,6 +143,47 @@ type LDClient = Omit<LDClient$1, 'setConnectionMode' | 'getConnectionMode' | 'ge
81
143
  * @ignore Implementation Note: Browser implementation has different options.
82
144
  */
83
145
  identify(pristineContext: LDContext, identifyOptions?: BrowserIdentifyOptions): Promise<LDIdentifyResult>;
146
+ /**
147
+ * Returns a Promise that tracks the client's initialization state.
148
+ *
149
+ * The Promise will be resolved to a {@link LDWaitForInitializationResult} object containing the
150
+ * status of the waitForInitialization operation.
151
+ *
152
+ * @example
153
+ * This example shows use of async/await syntax for specifying handlers:
154
+ * ```
155
+ * const result = await client.waitForInitialization({ timeout: 5 });
156
+ *
157
+ * if (result.status === 'complete') {
158
+ * doSomethingWithSuccessfullyInitializedClient();
159
+ * } else if (result.status === 'failed') {
160
+ * doSomethingForFailedStartup(result.error);
161
+ * } else if (result.status === 'timeout') {
162
+ * doSomethingForTimedOutStartup();
163
+ * }
164
+ * ```
165
+ *
166
+ * @remarks
167
+ * You can also use event listeners ({@link on}) for the same purpose: the event `"initialized"`
168
+ * indicates success, and `"error"` indicates an error.
169
+ *
170
+ * @param options
171
+ * Optional configuration. Please see {@link LDWaitForInitializationOptions}.
172
+ *
173
+ * @returns
174
+ * A Promise that will be resolved to a {@link LDWaitForInitializationResult} object containing the
175
+ * status of the waitForInitialization operation.
176
+ */
177
+ waitForInitialization(options?: LDWaitForInitializationOptions): Promise<LDWaitForInitializationResult>;
178
+ /**
179
+ * Starts the client and returns a promise that resolves to the initialization result.
180
+ *
181
+ * The promise will resolve to a {@link LDWaitForInitializationResult} object containing the
182
+ * status of the waitForInitialization operation.
183
+ *
184
+ * @param options Optional configuration. Please see {@link LDStartOptions}.
185
+ */
186
+ start(options?: LDStartOptions): Promise<LDWaitForInitializationResult>;
84
187
  };
85
188
 
86
189
  /**