launchdarkly-js-sdk-common 5.0.1 → 5.0.3

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to the `launchdarkly-js-sdk-common` package will be documented in this file. Changes that affect the dependent SDKs such as `launchdarkly-js-client-sdk` should also be logged in those projects, in the next release that uses the updated version of this package. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [5.0.2] - 2023-02-15
6
+ ### Changed:
7
+ - Removed usage of optional chaining (`?.`) to improve compatibility with projects which are using older transpilation tooling.
8
+
9
+ ## [5.0.1] - 2023-01-10
10
+ ### Changed:
11
+ - Updated all types in `typings.d.ts` to be exported. This is to ensure that those types are included in generated documentation of dependent SDKs.
12
+
5
13
  ## [5.0.0] - 2022-11-30
6
14
  This major version release of `js-sdk-common` corresponds to the upcoming releases of the `js-client-sdk` v3 and `react-client-sdk` v3, and cannot be used with earlier SDK versions.
7
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launchdarkly-js-sdk-common",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "LaunchDarkly SDK for JavaScript - common code",
5
5
  "author": "LaunchDarkly <team@launchdarkly.com>",
6
6
  "license": "Apache-2.0",
@@ -31,16 +31,17 @@ function InspectorManager(inspectors, logger) {
31
31
  [InspectorTypes.clientIdentityChanged]: [],
32
32
  };
33
33
 
34
- const safeInspectors = inspectors?.map(inspector => SafeInspector(inspector, logger));
34
+ const safeInspectors = inspectors && inspectors.map(inspector => SafeInspector(inspector, logger));
35
35
 
36
- safeInspectors.forEach(safeInspector => {
37
- // Only add inspectors of supported types.
38
- if (Object.prototype.hasOwnProperty.call(inspectorsByType, safeInspector.type)) {
39
- inspectorsByType[safeInspector.type].push(safeInspector);
40
- } else {
41
- logger.warn(messages.invalidInspector(safeInspector.type, safeInspector.name));
42
- }
43
- });
36
+ safeInspectors &&
37
+ safeInspectors.forEach(safeInspector => {
38
+ // Only add inspectors of supported types.
39
+ if (Object.prototype.hasOwnProperty.call(inspectorsByType, safeInspector.type)) {
40
+ inspectorsByType[safeInspector.type].push(safeInspector);
41
+ } else {
42
+ logger.warn(messages.invalidInspector(safeInspector.type, safeInspector.name));
43
+ }
44
+ });
44
45
 
45
46
  /**
46
47
  * Check if there is an inspector of a specific type registered.
@@ -48,7 +49,7 @@ function InspectorManager(inspectors, logger) {
48
49
  * @param {string} type The type of the inspector to check.
49
50
  * @returns True if there are any inspectors of that type registered.
50
51
  */
51
- manager.hasListeners = type => inspectorsByType[type]?.length;
52
+ manager.hasListeners = type => inspectorsByType[type] && inspectorsByType[type].length;
52
53
 
53
54
  /**
54
55
  * Notify registered inspectors of a flag being used.
@@ -45,7 +45,7 @@ const baseOptionDefs = {
45
45
  const allowedTagCharacters = /^(\w|\.|-)+$/;
46
46
 
47
47
  function canonicalizeUrl(url) {
48
- return url?.replace(/\/+$/, '');
48
+ return url && url.replace(/\/+$/, '');
49
49
  }
50
50
 
51
51
  /**
package/src/context.js CHANGED
@@ -107,7 +107,7 @@ function getContextKeys(context, logger = commonBasicLogger()) {
107
107
  Object.entries(context)
108
108
  .filter(([key]) => key !== 'kind')
109
109
  .forEach(([key, value]) => {
110
- if (value?.key) {
110
+ if (value && value.key) {
111
111
  keys[key] = value.key;
112
112
  }
113
113
  });
package/typings.d.ts CHANGED
@@ -345,8 +345,9 @@ declare module 'launchdarkly-js-sdk-common' {
345
345
 
346
346
  /**
347
347
  * A unique string identifying a context.
348
+ * This value must be set unless the context is anonymous.
348
349
  */
349
- key: string;
350
+ key?: string;
350
351
 
351
352
  /**
352
353
  * The context's name.