@launchdarkly/react-native-client-sdk 10.6.1 → 10.8.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 +37 -0
- package/dist/package.json +3 -6
- package/dist/src/MobileDataManager.d.ts +15 -0
- package/dist/src/MobileDataManager.d.ts.map +1 -0
- package/dist/src/MobileDataManager.js +89 -0
- package/dist/src/MobileDataManager.js.map +1 -0
- package/dist/src/RNOptions.d.ts +10 -1
- package/dist/src/RNOptions.d.ts.map +1 -1
- package/dist/src/ReactNativeLDClient.d.ts +6 -5
- package/dist/src/ReactNativeLDClient.d.ts.map +1 -1
- package/dist/src/ReactNativeLDClient.js +32 -16
- package/dist/src/ReactNativeLDClient.js.map +1 -1
- package/dist/src/options.d.ts +2 -1
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/options.js +11 -0
- package/dist/src/options.js.map +1 -1
- package/dist/src/platform/PlatformRequests.d.ts +2 -1
- package/dist/src/platform/PlatformRequests.d.ts.map +1 -1
- package/dist/src/platform/PlatformRequests.js +10 -0
- package/dist/src/platform/PlatformRequests.js.map +1 -1
- package/dist/src/polyfills/btoa.d.ts.map +1 -1
- package/dist/src/polyfills/btoa.js +3 -8
- package/dist/src/polyfills/btoa.js.map +1 -1
- package/dist/src/polyfills/toUtf8Array.d.ts +2 -0
- package/dist/src/polyfills/toUtf8Array.d.ts.map +1 -0
- package/dist/src/polyfills/toUtf8Array.js +48 -0
- package/dist/src/polyfills/toUtf8Array.js.map +1 -0
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [10.8.0](https://github.com/launchdarkly/js-core/compare/react-native-client-sdk-v10.7.0...react-native-client-sdk-v10.8.0) (2024-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Add support for hooks. ([#605](https://github.com/launchdarkly/js-core/issues/605)) ([04d347b](https://github.com/launchdarkly/js-core/commit/04d347b25e01015134a2545be22bfd8b1d1e85cc))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Ensure client logger is always wrapped in a safe logger. ([#599](https://github.com/launchdarkly/js-core/issues/599)) ([980e4da](https://github.com/launchdarkly/js-core/commit/980e4daaf32864e18f14b1e5e28e308dff0ae94f))
|
|
14
|
+
* Fix base64 encoding of unicode characters. ([#613](https://github.com/launchdarkly/js-core/issues/613)) ([35ec8d1](https://github.com/launchdarkly/js-core/commit/35ec8d1ecc07ddb68f4d02b19e1f238f7ff14df7))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
* The following workspace dependencies were updated
|
|
20
|
+
* dependencies
|
|
21
|
+
* @launchdarkly/js-client-sdk-common bumped from 1.8.0 to 1.9.0
|
|
22
|
+
|
|
23
|
+
## [10.7.0](https://github.com/launchdarkly/js-core/compare/react-native-client-sdk-v10.6.1...react-native-client-sdk-v10.7.0) (2024-09-26)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* Add support for conditional event source capabilities. ([#577](https://github.com/launchdarkly/js-core/issues/577)) ([fe82500](https://github.com/launchdarkly/js-core/commit/fe82500f28cf8d8311502098aa6cc2e73932064e))
|
|
29
|
+
* Add support for js-client-sdk style initialization. ([53f5bb8](https://github.com/launchdarkly/js-core/commit/53f5bb89754ff05405d481a959e75742fbd0d0a9))
|
|
30
|
+
* Adds support for REPORT. ([#575](https://github.com/launchdarkly/js-core/issues/575)) ([916b724](https://github.com/launchdarkly/js-core/commit/916b72409b63abdf350e70cca41331c4204b6e95))
|
|
31
|
+
* Refactor data source connection handling. ([53f5bb8](https://github.com/launchdarkly/js-core/commit/53f5bb89754ff05405d481a959e75742fbd0d0a9))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
|
|
36
|
+
* The following workspace dependencies were updated
|
|
37
|
+
* dependencies
|
|
38
|
+
* @launchdarkly/js-client-sdk-common bumped from 1.7.0 to 1.8.0
|
|
39
|
+
|
|
3
40
|
## [10.6.1](https://github.com/launchdarkly/js-core/compare/react-native-client-sdk-v10.6.0...react-native-client-sdk-v10.6.1) (2024-09-03)
|
|
4
41
|
|
|
5
42
|
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/react-native-client-sdk",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.8.0",
|
|
4
4
|
"description": "React Native LaunchDarkly SDK",
|
|
5
5
|
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native",
|
|
6
6
|
"repository": {
|
|
@@ -34,21 +34,18 @@
|
|
|
34
34
|
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
|
|
35
35
|
"test": "jest",
|
|
36
36
|
"coverage": "yarn test --coverage",
|
|
37
|
-
"check": "yarn prettier && yarn lint && yarn build && yarn test"
|
|
38
|
-
"android": "yarn && yarn ./example && yarn build && (cd example/ && yarn android-release)",
|
|
39
|
-
"ios": "yarn && yarn ./example && yarn build && (cd example/ && yarn ios-go)"
|
|
37
|
+
"check": "yarn prettier && yarn lint && yarn build && yarn test"
|
|
40
38
|
},
|
|
41
39
|
"peerDependencies": {
|
|
42
40
|
"react": "*",
|
|
43
41
|
"react-native": "*"
|
|
44
42
|
},
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@launchdarkly/js-client-sdk-common": "1.
|
|
44
|
+
"@launchdarkly/js-client-sdk-common": "1.9.0",
|
|
47
45
|
"@react-native-async-storage/async-storage": "^1.21.0",
|
|
48
46
|
"base64-js": "^1.5.1"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@launchdarkly/private-js-mocks": "0.0.1",
|
|
52
49
|
"@testing-library/react": "^14.1.2",
|
|
53
50
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
54
51
|
"@types/jest": "^29.5.11",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseDataManager, Configuration, ConnectionMode, Context, DataSourcePaths, FlagManager, internal, LDEmitter, LDHeaders, LDIdentifyOptions, Platform } from '@launchdarkly/js-client-sdk-common';
|
|
2
|
+
import { ValidatedOptions } from './options';
|
|
3
|
+
export default class MobileDataManager extends BaseDataManager {
|
|
4
|
+
private readonly rnConfig;
|
|
5
|
+
protected networkAvailable: boolean;
|
|
6
|
+
protected connectionMode: ConnectionMode;
|
|
7
|
+
constructor(platform: Platform, flagManager: FlagManager, credential: string, config: Configuration, rnConfig: ValidatedOptions, getPollingPaths: () => DataSourcePaths, getStreamingPaths: () => DataSourcePaths, baseHeaders: LDHeaders, emitter: LDEmitter, diagnosticsManager?: internal.DiagnosticsManager);
|
|
8
|
+
private debugLog;
|
|
9
|
+
identify(identifyResolve: () => void, identifyReject: (err: Error) => void, context: Context, identifyOptions?: LDIdentifyOptions): Promise<void>;
|
|
10
|
+
private setupConnection;
|
|
11
|
+
setNetworkAvailability(available: boolean): void;
|
|
12
|
+
setConnectionMode(mode: ConnectionMode): Promise<void>;
|
|
13
|
+
getConnectionMode(): ConnectionMode;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=MobileDataManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileDataManager.d.ts","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,EACP,eAAe,EACf,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,eAAe;IAU1D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAR3B,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAQ;IAC3C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAe;gBAGrD,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACJ,QAAQ,EAAE,gBAAgB,EAC3C,eAAe,EAAE,MAAM,eAAe,EACtC,iBAAiB,EAAE,MAAM,eAAe,EACxC,WAAW,EAAE,SAAS,EACtB,OAAO,EAAE,SAAS,EAClB,kBAAkB,CAAC,EAAE,QAAQ,CAAC,kBAAkB;IAgBlD,OAAO,CAAC,QAAQ;IAID,QAAQ,CACrB,eAAe,EAAE,MAAM,IAAI,EAC3B,cAAc,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,EACpC,OAAO,EAAE,OAAO,EAChB,eAAe,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,IAAI,CAAC;IAgChB,OAAO,CAAC,eAAe;IAqBvB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAI1C,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B5D,iBAAiB,IAAI,cAAc;CAGpC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BaseDataManager, Context, } from '@launchdarkly/js-client-sdk-common';
|
|
2
|
+
const logTag = '[MobileDataManager]';
|
|
3
|
+
export default class MobileDataManager extends BaseDataManager {
|
|
4
|
+
constructor(platform, flagManager, credential, config, rnConfig, getPollingPaths, getStreamingPaths, baseHeaders, emitter, diagnosticsManager) {
|
|
5
|
+
super(platform, flagManager, credential, config, getPollingPaths, getStreamingPaths, baseHeaders, emitter, diagnosticsManager);
|
|
6
|
+
this.rnConfig = rnConfig;
|
|
7
|
+
// Not implemented yet.
|
|
8
|
+
this.networkAvailable = true;
|
|
9
|
+
this.connectionMode = 'streaming';
|
|
10
|
+
this.connectionMode = rnConfig.initialConnectionMode;
|
|
11
|
+
}
|
|
12
|
+
debugLog(message, ...args) {
|
|
13
|
+
this.logger.debug(`${logTag} ${message}`, ...args);
|
|
14
|
+
}
|
|
15
|
+
async identify(identifyResolve, identifyReject, context, identifyOptions) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
const offline = this.connectionMode === 'offline';
|
|
18
|
+
// In offline mode we do not support waiting for results.
|
|
19
|
+
const waitForNetworkResults = !!(identifyOptions === null || identifyOptions === void 0 ? void 0 : identifyOptions.waitForNetworkResults) && !offline;
|
|
20
|
+
const loadedFromCache = await this.flagManager.loadCached(context);
|
|
21
|
+
if (loadedFromCache && !waitForNetworkResults) {
|
|
22
|
+
this.debugLog('Identify completing with cached flags');
|
|
23
|
+
identifyResolve();
|
|
24
|
+
}
|
|
25
|
+
if (loadedFromCache && waitForNetworkResults) {
|
|
26
|
+
this.debugLog('Identify - Flags loaded from cache, but identify was requested with "waitForNetworkResults"');
|
|
27
|
+
}
|
|
28
|
+
if (this.connectionMode === 'offline') {
|
|
29
|
+
if (loadedFromCache) {
|
|
30
|
+
this.debugLog('Offline identify - using cached flags.');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.debugLog('Offline identify - no cached flags, using defaults or already loaded flags.');
|
|
34
|
+
identifyResolve();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Context has been validated in LDClientImpl.identify
|
|
39
|
+
this.setupConnection(context, identifyResolve, identifyReject);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
setupConnection(context, identifyResolve, identifyReject) {
|
|
43
|
+
var _a;
|
|
44
|
+
const rawContext = Context.toLDContext(context);
|
|
45
|
+
(_a = this.updateProcessor) === null || _a === void 0 ? void 0 : _a.close();
|
|
46
|
+
switch (this.connectionMode) {
|
|
47
|
+
case 'streaming':
|
|
48
|
+
this.createStreamingProcessor(rawContext, context, identifyResolve, identifyReject);
|
|
49
|
+
break;
|
|
50
|
+
case 'polling':
|
|
51
|
+
this.createPollingProcessor(rawContext, context, identifyResolve, identifyReject);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
this.updateProcessor.start();
|
|
57
|
+
}
|
|
58
|
+
setNetworkAvailability(available) {
|
|
59
|
+
this.networkAvailable = available;
|
|
60
|
+
}
|
|
61
|
+
async setConnectionMode(mode) {
|
|
62
|
+
var _a;
|
|
63
|
+
if (this.connectionMode === mode) {
|
|
64
|
+
this.debugLog(`setConnectionMode ignored. Mode is already '${mode}'.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.connectionMode = mode;
|
|
68
|
+
this.debugLog(`setConnectionMode ${mode}.`);
|
|
69
|
+
switch (mode) {
|
|
70
|
+
case 'offline':
|
|
71
|
+
(_a = this.updateProcessor) === null || _a === void 0 ? void 0 : _a.close();
|
|
72
|
+
break;
|
|
73
|
+
case 'polling':
|
|
74
|
+
case 'streaming':
|
|
75
|
+
if (this.context) {
|
|
76
|
+
// identify will start the update processor
|
|
77
|
+
this.setupConnection(this.context);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
this.logger.warn(`Unknown ConnectionMode: ${mode}. Only 'offline', 'streaming', and 'polling' are supported.`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
getConnectionMode() {
|
|
86
|
+
return this.connectionMode;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=MobileDataManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileDataManager.js","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGf,OAAO,GAQR,MAAM,oCAAoC,CAAC;AAI5C,MAAM,MAAM,GAAG,qBA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C;QAC3B,IAAI,CAAC,QAAQ,CAAC,qBAAqB,IAAI,GAAG,CAAC,CAAC;QAE5C,QAAQ,IAAI,EAAE;YACZ,KAAK,SAAS;gBACZ,MAAA,IAAI,CAAC,eAAe,0CAAE,KAAK,EAAE,CAAC;gBAC9B,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,WAAW;gBACd,IAAI,IAAI,CAAC,OAAO,EAAE;oBAChB,2CAA2C;oBAC3C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACpC;gBAED,MAAM;YACR;gBACE,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,2BAA2B,IAAI,6DAA6D,CAC7F,CAAC;gBACF,MAAM;SACT;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/src/RNOptions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LDOptions } from '@launchdarkly/js-client-sdk-common';
|
|
1
|
+
import { ConnectionMode, LDOptions } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for providing custom storage implementations for react Native.
|
|
4
4
|
*
|
|
@@ -87,6 +87,15 @@ export interface RNSpecificOptions {
|
|
|
87
87
|
* Defaults to @react-native-async-storage/async-storage.
|
|
88
88
|
*/
|
|
89
89
|
readonly storage?: RNStorage;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the mode to use for connections when the SDK is initialized.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Possible values are offline, streaming, or polling. See {@link ConnectionMode} for more information.
|
|
95
|
+
*
|
|
96
|
+
* @defaultValue streaming.
|
|
97
|
+
*/
|
|
98
|
+
initialConnectionMode?: ConnectionMode;
|
|
90
99
|
}
|
|
91
100
|
export default interface RNOptions extends LDOptions, RNSpecificOptions {
|
|
92
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNOptions.d.ts","sourceRoot":"","sources":["../../src/RNOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/
|
|
1
|
+
{"version":3,"file":"RNOptions.d.ts","sourceRoot":"","sources":["../../src/RNOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;OAKG;IAEH;;;;;;OAMG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE7C;;;;;;OAMG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;;;;;;;OAQG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IAEnC;;;;;;OAMG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAE5C;;;;;OAKG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAE/C;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAE7B;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,cAAc,CAAC;CACxC;AAED,MAAM,CAAC,OAAO,WAAW,SAAU,SAAQ,SAAS,EAAE,iBAAiB;CAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutoEnvAttributes, ConnectionMode, LDClientImpl
|
|
1
|
+
import { AutoEnvAttributes, ConnectionMode, LDClientImpl } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
import LDOptions from './RNOptions';
|
|
3
3
|
/**
|
|
4
4
|
* The React Native LaunchDarkly client. Instantiate this class to create an
|
|
@@ -26,10 +26,11 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
26
26
|
* @param options {@link LDOptions} to initialize the client with.
|
|
27
27
|
*/
|
|
28
28
|
constructor(sdkKey: string, autoEnvAttributes: AutoEnvAttributes, options?: LDOptions);
|
|
29
|
-
private baseSetConnectionMode;
|
|
30
|
-
private encodeContext;
|
|
31
|
-
createStreamUriPath(context: LDContext): string;
|
|
32
|
-
createPollUriPath(context: LDContext): string;
|
|
33
29
|
setConnectionMode(mode: ConnectionMode): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the SDK connection mode.
|
|
32
|
+
*/
|
|
33
|
+
getConnectionMode(): ConnectionMode;
|
|
34
|
+
isOffline(): boolean;
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=ReactNativeLDClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAIjB,cAAc,EAId,YAAY,EAGb,MAAM,oCAAoC,CAAC;AAM5C,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D,OAAO,CAAC,iBAAiB,CAAoB;IAC7C;;;;;;;;;OASG;gBACS,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,GAAE,SAAc;IA2FnF,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAKnC,SAAS;CAIV"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-classes-per-file */
|
|
2
2
|
import { base64UrlEncode, BasicLogger, LDClientImpl, } from '@launchdarkly/js-client-sdk-common';
|
|
3
|
+
import MobileDataManager from './MobileDataManager';
|
|
3
4
|
import validateOptions, { filterToBaseOptions } from './options';
|
|
4
5
|
import createPlatform from './platform';
|
|
5
6
|
import { ConnectionManager } from './platform/ConnectionManager';
|
|
@@ -42,10 +43,27 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
42
43
|
highTimeoutThreshold: 15,
|
|
43
44
|
};
|
|
44
45
|
const validatedRnOptions = validateOptions(options, logger);
|
|
45
|
-
|
|
46
|
+
const platform = createPlatform(logger, validatedRnOptions.storage);
|
|
47
|
+
super(sdkKey, autoEnvAttributes, platform, Object.assign(Object.assign({}, filterToBaseOptions(options)), { logger }), (flagManager, configuration, baseHeaders, emitter, diagnosticsManager) => new MobileDataManager(platform, flagManager, sdkKey, configuration, validatedRnOptions, () => ({
|
|
48
|
+
pathGet(encoding, _plainContextString) {
|
|
49
|
+
return `/msdk/evalx/contexts/${base64UrlEncode(_plainContextString, encoding)}`;
|
|
50
|
+
},
|
|
51
|
+
pathReport(_encoding, _plainContextString) {
|
|
52
|
+
return `/msdk/evalx/context`;
|
|
53
|
+
},
|
|
54
|
+
}), () => ({
|
|
55
|
+
pathGet(encoding, _plainContextString) {
|
|
56
|
+
return `/meval/${base64UrlEncode(_plainContextString, encoding)}`;
|
|
57
|
+
},
|
|
58
|
+
pathReport(_encoding, _plainContextString) {
|
|
59
|
+
return `/meval`;
|
|
60
|
+
},
|
|
61
|
+
}), baseHeaders, emitter, diagnosticsManager), internalOptions);
|
|
62
|
+
this.setEventSendingEnabled(!this.isOffline(), false);
|
|
63
|
+
const dataManager = this.dataManager;
|
|
46
64
|
const destination = {
|
|
47
65
|
setNetworkAvailability: (available) => {
|
|
48
|
-
|
|
66
|
+
dataManager.setNetworkAvailability(available);
|
|
49
67
|
},
|
|
50
68
|
setEventSendingEnabled: (enabled, flush) => {
|
|
51
69
|
this.setEventSendingEnabled(enabled, flush);
|
|
@@ -53,7 +71,7 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
53
71
|
setConnectionMode: async (mode) => {
|
|
54
72
|
// Pass the connection mode to the base implementation.
|
|
55
73
|
// The RN implementation will pass the connection mode through the connection manager.
|
|
56
|
-
|
|
74
|
+
dataManager.setConnectionMode(mode);
|
|
57
75
|
},
|
|
58
76
|
};
|
|
59
77
|
const initialConnectionMode = (_a = options.initialConnectionMode) !== null && _a !== void 0 ? _a : 'streaming';
|
|
@@ -64,19 +82,6 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
64
82
|
runInBackground: validatedRnOptions.runInBackground,
|
|
65
83
|
}, destination, new RNStateDetector());
|
|
66
84
|
}
|
|
67
|
-
baseSetConnectionMode(mode) {
|
|
68
|
-
// Jest had problems with calls to super from nested arrow functions, so this method proxies the call.
|
|
69
|
-
super.setConnectionMode(mode);
|
|
70
|
-
}
|
|
71
|
-
encodeContext(context) {
|
|
72
|
-
return base64UrlEncode(JSON.stringify(context), this.platform.encoding);
|
|
73
|
-
}
|
|
74
|
-
createStreamUriPath(context) {
|
|
75
|
-
return `/meval/${this.encodeContext(context)}`;
|
|
76
|
-
}
|
|
77
|
-
createPollUriPath(context) {
|
|
78
|
-
return `/msdk/evalx/contexts/${this.encodeContext(context)}`;
|
|
79
|
-
}
|
|
80
85
|
async setConnectionMode(mode) {
|
|
81
86
|
// Set the connection mode before setting offline, in case there is any mode transition work
|
|
82
87
|
// such as flushing on entering the background.
|
|
@@ -84,5 +89,16 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
84
89
|
// For now the data source connection and the event processing state are connected.
|
|
85
90
|
this.connectionManager.setOffline(mode === 'offline');
|
|
86
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets the SDK connection mode.
|
|
94
|
+
*/
|
|
95
|
+
getConnectionMode() {
|
|
96
|
+
const dataManager = this.dataManager;
|
|
97
|
+
return dataManager.getConnectionMode();
|
|
98
|
+
}
|
|
99
|
+
isOffline() {
|
|
100
|
+
const dataManager = this.dataManager;
|
|
101
|
+
return dataManager.getConnectionMode() === 'offline';
|
|
102
|
+
}
|
|
87
103
|
}
|
|
88
104
|
//# sourceMappingURL=ReactNativeLDClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeLDClient.js","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAEL,eAAe,EACf,WAAW,
|
|
1
|
+
{"version":3,"file":"ReactNativeLDClient.js","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAEL,eAAe,EACf,WAAW,EAMX,YAAY,GAGb,MAAM,oCAAoC,CAAC;AAE5C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,EAAE,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,cAAc,MAAM,YAAY,CAAC;AACxC,OAAO,EAAyB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAE3D;;;;;;;;;OASG;IACH,YAAY,MAAc,EAAE,iBAAoC,EAAE,UAAqB,EAAE;;QACvF,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAChD,MAAM,MAAM,GACV,YAAY,aAAZ,YAAY,cAAZ,YAAY,GACZ,IAAI,WAAW,CAAC;YACd,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,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QACP,MAAM,WAAW,GAAG,IAAI,CAAC,WAAgC,CAAC;QAC1D,OAAO,WAAW,CAAC,iBAAiB,EAAE,KAAK,SAAS,CAAC;IACvD,CAAC;CACF"}
|
package/dist/src/options.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { LDLogger, LDOptions } from '@launchdarkly/js-client-sdk-common';
|
|
1
|
+
import { ConnectionMode, LDLogger, LDOptions } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
import RNOptions, { RNStorage } from './RNOptions';
|
|
3
3
|
export interface ValidatedOptions {
|
|
4
4
|
runInBackground: boolean;
|
|
5
5
|
automaticNetworkHandling: boolean;
|
|
6
6
|
automaticBackgroundHandling: boolean;
|
|
7
7
|
storage?: RNStorage;
|
|
8
|
+
initialConnectionMode: ConnectionMode;
|
|
8
9
|
}
|
|
9
10
|
export declare function filterToBaseOptions(opts: RNOptions): LDOptions;
|
|
10
11
|
export default function validateOptions(opts: RNOptions, logger: LDLogger): ValidatedOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,SAAS,EAIV,MAAM,oCAAoC,CAAC;AAE5C,OAAO,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,EACR,SAAS,EAIV,MAAM,oCAAoC,CAAC;AAE5C,OAAO,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAWnD,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,wBAAwB,EAAE,OAAO,CAAC;IAClC,2BAA2B,EAAE,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,qBAAqB,EAAE,cAAc,CAAC;CACvC;AAkBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAS9D;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,gBAAgB,CAiB3F"}
|
package/dist/src/options.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { OptionMessages, TypeValidators, } from '@launchdarkly/js-client-sdk-common';
|
|
2
|
+
class ConnectionModeValidator {
|
|
3
|
+
is(u) {
|
|
4
|
+
return u === 'offline' || u === 'streaming' || u === 'polling';
|
|
5
|
+
}
|
|
6
|
+
getType() {
|
|
7
|
+
return 'ConnectionMode (offline | streaming | polling)';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
2
10
|
const optDefaults = {
|
|
3
11
|
runInBackground: false,
|
|
4
12
|
automaticNetworkHandling: true,
|
|
5
13
|
automaticBackgroundHandling: true,
|
|
6
14
|
storage: undefined,
|
|
15
|
+
initialConnectionMode: 'streaming',
|
|
7
16
|
};
|
|
8
17
|
const validators = {
|
|
9
18
|
runInBackground: TypeValidators.Boolean,
|
|
10
19
|
automaticNetworkHandling: TypeValidators.Boolean,
|
|
11
20
|
automaticBackgroundHandling: TypeValidators.Boolean,
|
|
12
21
|
storage: TypeValidators.Object,
|
|
22
|
+
initialConnectionMode: new ConnectionModeValidator(),
|
|
13
23
|
};
|
|
14
24
|
export function filterToBaseOptions(opts) {
|
|
15
25
|
const baseOptions = Object.assign({}, opts);
|
|
@@ -27,6 +37,7 @@ export default function validateOptions(opts, logger) {
|
|
|
27
37
|
const value = opts[key];
|
|
28
38
|
if (value !== undefined) {
|
|
29
39
|
if (validator.is(value)) {
|
|
40
|
+
// @ts-ignore The type inference has some problems here.
|
|
30
41
|
output[key] = value;
|
|
31
42
|
}
|
|
32
43
|
else {
|
package/dist/src/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,cAAc,EAEd,cAAc,GACf,MAAM,oCAAoC,CAAC;AAI5C,MAAM,uBAAuB;IAC3B,EAAE,CAAC,CAAU;QACX,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,SAAS,CAAC;IACjE,CAAC;IACD,OAAO;QACL,OAAO,gDAAgD,CAAC;IAC1D,CAAC;CACF;AAUD,MAAM,WAAW,GAAqB;IACpC,eAAe,EAAE,KAAK;IACtB,wBAAwB,EAAE,IAAI;IAC9B,2BAA2B,EAAE,IAAI;IACjC,OAAO,EAAE,SAAS;IAClB,qBAAqB,EAAE,WAAW;CACnC,CAAC;AAEF,MAAM,UAAU,GAAiE;IAC/E,eAAe,EAAE,cAAc,CAAC,OAAO;IACvC,wBAAwB,EAAE,cAAc,CAAC,OAAO;IAChD,2BAA2B,EAAE,cAAc,CAAC,OAAO;IACnD,OAAO,EAAE,cAAc,CAAC,MAAM;IAC9B,qBAAqB,EAAE,IAAI,uBAAuB,EAAE;CACrD,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,IAAe;IACjD,MAAM,WAAW,qBAAmB,IAAI,CAAE,CAAC;IAE3C,0EAA0E;IAC1E,qDAAqD;IACrD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACvC,OAAQ,WAAmB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,IAAe,EAAE,MAAgB;IACvE,MAAM,MAAM,qBAA0B,WAAW,CAAE,CAAC;IAEpD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3C,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,KAAyC,CAAC;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,IAAI,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;gBACvB,wDAAwD;gBACxD,MAAM,CAAC,GAA6B,CAAC,GAAG,KAAY,CAAC;aACtD;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC;aACrF;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { EventSource, EventSourceInitDict, LDLogger, Options, Requests, Response } from '@launchdarkly/js-client-sdk-common';
|
|
1
|
+
import type { EventSource, EventSourceCapabilities, EventSourceInitDict, LDLogger, Options, Requests, Response } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformRequests implements Requests {
|
|
3
3
|
private readonly logger;
|
|
4
4
|
constructor(logger: LDLogger);
|
|
5
5
|
createEventSource(url: string, eventSourceInitDict: EventSourceInitDict): EventSource;
|
|
6
|
+
getEventSourceCapabilities(): EventSourceCapabilities;
|
|
6
7
|
fetch(url: string, options?: Options): Promise<Response>;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=PlatformRequests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,QAAQ;IAE7C,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,GAAG,WAAW;
|
|
1
|
+
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,QAAQ;IAE7C,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,GAAG,WAAW;IAUrF,0BAA0B,IAAI,uBAAuB;IAQrD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAIzD"}
|
|
@@ -4,12 +4,22 @@ export default class PlatformRequests {
|
|
|
4
4
|
this.logger = logger;
|
|
5
5
|
}
|
|
6
6
|
createEventSource(url, eventSourceInitDict) {
|
|
7
|
+
var _a;
|
|
7
8
|
return new RNEventSource(url, {
|
|
9
|
+
method: (_a = eventSourceInitDict.method) !== null && _a !== void 0 ? _a : 'GET',
|
|
8
10
|
headers: eventSourceInitDict.headers,
|
|
11
|
+
body: eventSourceInitDict.body,
|
|
9
12
|
retryAndHandleError: eventSourceInitDict.errorFilter,
|
|
10
13
|
logger: this.logger,
|
|
11
14
|
});
|
|
12
15
|
}
|
|
16
|
+
getEventSourceCapabilities() {
|
|
17
|
+
return {
|
|
18
|
+
readTimeout: false,
|
|
19
|
+
headers: true,
|
|
20
|
+
customMethod: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
13
23
|
fetch(url, options) {
|
|
14
24
|
// @ts-ignore
|
|
15
25
|
return fetch(url, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequests.js","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformRequests.js","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAWA,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,YAA6B,MAAgB;QAAhB,WAAM,GAAN,MAAM,CAAU;IAAG,CAAC;IAEjD,iBAAiB,CAAC,GAAW,EAAE,mBAAwC;;QACrE,OAAO,IAAI,aAAa,CAAY,GAAG,EAAE;YACvC,MAAM,EAAE,MAAA,mBAAmB,CAAC,MAAM,mCAAI,KAAK;YAC3C,OAAO,EAAE,mBAAmB,CAAC,OAAO;YACpC,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,mBAAmB,EAAE,mBAAmB,CAAC,WAAW;YACpD,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAED,0BAA0B;QACxB,OAAO;YACL,WAAW,EAAE,KAAK;YAClB,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,IAAI;SACnB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAiB;QAClC,aAAa;QACb,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"btoa.d.ts","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"btoa.d.ts","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"AAKA,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,UAE7B;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,UAAU,UAEhD"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
+
/* eslint-disable no-bitwise */
|
|
1
2
|
import { fromByteArray } from 'base64-js';
|
|
2
|
-
|
|
3
|
-
const b = [];
|
|
4
|
-
for (let i = 0; i < s.length; i += 1) {
|
|
5
|
-
b.push(s.charCodeAt(i));
|
|
6
|
-
}
|
|
7
|
-
return Uint8Array.from(b);
|
|
8
|
-
}
|
|
3
|
+
import toUtf8Array from './toUtf8Array';
|
|
9
4
|
export function btoa(s) {
|
|
10
|
-
return fromByteArray(
|
|
5
|
+
return fromByteArray(toUtf8Array(s));
|
|
11
6
|
}
|
|
12
7
|
export function base64FromByteArray(a) {
|
|
13
8
|
return fromByteArray(a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"btoa.js","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"btoa.js","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAa;IAC/C,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUtf8Array.d.ts","sourceRoot":"","sources":["../../../src/polyfills/toUtf8Array.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA4B3D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable no-plusplus */
|
|
2
|
+
/* eslint-disable no-bitwise */
|
|
3
|
+
// Originally from: https://github.com/google/closure-library/blob/a1f5a029c1b32eb4793a2d920aa52abc085e1bf7/closure/goog/crypt/crypt.js
|
|
4
|
+
// Once React Native versions uniformly support TextEncoder this code can be removed.
|
|
5
|
+
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
|
|
6
|
+
//
|
|
7
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
// you may not use this file except in compliance with the License.
|
|
9
|
+
// You may obtain a copy of the License at
|
|
10
|
+
//
|
|
11
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
//
|
|
13
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
// distributed under the License is distributed on an "AS-IS" BASIS,
|
|
15
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
// See the License for the specific language governing permissions and
|
|
17
|
+
// limitations under the License.
|
|
18
|
+
export default function toUtf8Array(str) {
|
|
19
|
+
const out = [];
|
|
20
|
+
let p = 0;
|
|
21
|
+
for (let i = 0; i < str.length; i += 1) {
|
|
22
|
+
let c = str.charCodeAt(i);
|
|
23
|
+
if (c < 128) {
|
|
24
|
+
out[p++] = c;
|
|
25
|
+
}
|
|
26
|
+
else if (c < 2048) {
|
|
27
|
+
out[p++] = (c >> 6) | 192;
|
|
28
|
+
out[p++] = (c & 63) | 128;
|
|
29
|
+
}
|
|
30
|
+
else if ((c & 0xfc00) === 0xd800 &&
|
|
31
|
+
i + 1 < str.length &&
|
|
32
|
+
(str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
33
|
+
// Surrogate Pair
|
|
34
|
+
c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff);
|
|
35
|
+
out[p++] = (c >> 18) | 240;
|
|
36
|
+
out[p++] = ((c >> 12) & 63) | 128;
|
|
37
|
+
out[p++] = ((c >> 6) & 63) | 128;
|
|
38
|
+
out[p++] = (c & 63) | 128;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
out[p++] = (c >> 12) | 224;
|
|
42
|
+
out[p++] = ((c >> 6) & 63) | 128;
|
|
43
|
+
out[p++] = (c & 63) | 128;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return Uint8Array.from(out);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=toUtf8Array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUtf8Array.js","sourceRoot":"","sources":["../../../src/polyfills/toUtf8Array.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,+BAA+B;AAE/B,uIAAuI;AAEvI,qFAAqF;AAErF,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAW;IAC7C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACtC,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,EAAE;YACX,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;SACd;aAAM,IAAI,CAAC,GAAG,IAAI,EAAE;YACnB,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,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CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/react-native-client-sdk",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.8.0",
|
|
4
4
|
"description": "React Native LaunchDarkly SDK",
|
|
5
5
|
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native",
|
|
6
6
|
"repository": {
|
|
@@ -34,21 +34,18 @@
|
|
|
34
34
|
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
|
|
35
35
|
"test": "jest",
|
|
36
36
|
"coverage": "yarn test --coverage",
|
|
37
|
-
"check": "yarn prettier && yarn lint && yarn build && yarn test"
|
|
38
|
-
"android": "yarn && yarn ./example && yarn build && (cd example/ && yarn android-release)",
|
|
39
|
-
"ios": "yarn && yarn ./example && yarn build && (cd example/ && yarn ios-go)"
|
|
37
|
+
"check": "yarn prettier && yarn lint && yarn build && yarn test"
|
|
40
38
|
},
|
|
41
39
|
"peerDependencies": {
|
|
42
40
|
"react": "*",
|
|
43
41
|
"react-native": "*"
|
|
44
42
|
},
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@launchdarkly/js-client-sdk-common": "1.
|
|
44
|
+
"@launchdarkly/js-client-sdk-common": "1.9.0",
|
|
47
45
|
"@react-native-async-storage/async-storage": "^1.21.0",
|
|
48
46
|
"base64-js": "^1.5.1"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@launchdarkly/private-js-mocks": "0.0.1",
|
|
52
49
|
"@testing-library/react": "^14.1.2",
|
|
53
50
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
|
54
51
|
"@types/jest": "^29.5.11",
|