@launchdarkly/react-native-client-sdk 0.1.0-alpha

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 (85) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/LICENSE +13 -0
  3. package/README.md +120 -0
  4. package/dist/package.json +77 -0
  5. package/dist/src/ReactNativeLDClient.d.ts +6 -0
  6. package/dist/src/ReactNativeLDClient.d.ts.map +1 -0
  7. package/dist/src/ReactNativeLDClient.js +21 -0
  8. package/dist/src/ReactNativeLDClient.js.map +1 -0
  9. package/dist/src/hooks/index.d.ts +4 -0
  10. package/dist/src/hooks/index.d.ts.map +1 -0
  11. package/dist/src/hooks/index.js +4 -0
  12. package/dist/src/hooks/index.js.map +1 -0
  13. package/dist/src/hooks/useLDClient.d.ts +3 -0
  14. package/dist/src/hooks/useLDClient.d.ts.map +1 -0
  15. package/dist/src/hooks/useLDClient.js +8 -0
  16. package/dist/src/hooks/useLDClient.js.map +1 -0
  17. package/dist/src/hooks/variation/index.d.ts +3 -0
  18. package/dist/src/hooks/variation/index.d.ts.map +1 -0
  19. package/dist/src/hooks/variation/index.js +3 -0
  20. package/dist/src/hooks/variation/index.js.map +1 -0
  21. package/dist/src/hooks/variation/useTypedVariation.d.ts +32 -0
  22. package/dist/src/hooks/variation/useTypedVariation.d.ts.map +1 -0
  23. package/dist/src/hooks/variation/useTypedVariation.js +62 -0
  24. package/dist/src/hooks/variation/useTypedVariation.js.map +1 -0
  25. package/dist/src/hooks/variation/useVariation.d.ts +131 -0
  26. package/dist/src/hooks/variation/useVariation.d.ts.map +1 -0
  27. package/dist/src/hooks/variation/useVariation.js +132 -0
  28. package/dist/src/hooks/variation/useVariation.js.map +1 -0
  29. package/dist/src/index.d.ts +6 -0
  30. package/dist/src/index.d.ts.map +1 -0
  31. package/dist/src/index.js +15 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/src/platform/ConditionalAsyncStorage.d.ts +20 -0
  34. package/dist/src/platform/ConditionalAsyncStorage.d.ts.map +1 -0
  35. package/dist/src/platform/ConditionalAsyncStorage.js +29 -0
  36. package/dist/src/platform/ConditionalAsyncStorage.js.map +1 -0
  37. package/dist/src/platform/index.d.ts +4 -0
  38. package/dist/src/platform/index.d.ts.map +1 -0
  39. package/dist/src/platform/index.js +81 -0
  40. package/dist/src/platform/index.js.map +1 -0
  41. package/dist/src/polyfills/CustomEvent.d.ts +17 -0
  42. package/dist/src/polyfills/CustomEvent.d.ts.map +1 -0
  43. package/dist/src/polyfills/CustomEvent.js +13 -0
  44. package/dist/src/polyfills/CustomEvent.js.map +1 -0
  45. package/dist/src/polyfills/btoa.d.ts +2 -0
  46. package/dist/src/polyfills/btoa.d.ts.map +1 -0
  47. package/dist/src/polyfills/btoa.js +12 -0
  48. package/dist/src/polyfills/btoa.js.map +1 -0
  49. package/dist/src/polyfills/index.d.ts +5 -0
  50. package/dist/src/polyfills/index.d.ts.map +1 -0
  51. package/dist/src/polyfills/index.js +12 -0
  52. package/dist/src/polyfills/index.js.map +1 -0
  53. package/dist/src/polyfills/uuid.d.ts +10 -0
  54. package/dist/src/polyfills/uuid.d.ts.map +1 -0
  55. package/dist/src/polyfills/uuid.js +17 -0
  56. package/dist/src/polyfills/uuid.js.map +1 -0
  57. package/dist/src/provider/LDProvider.d.ts +22 -0
  58. package/dist/src/provider/LDProvider.d.ts.map +1 -0
  59. package/dist/src/provider/LDProvider.js +29 -0
  60. package/dist/src/provider/LDProvider.js.map +1 -0
  61. package/dist/src/provider/index.d.ts +3 -0
  62. package/dist/src/provider/index.d.ts.map +1 -0
  63. package/dist/src/provider/index.js +4 -0
  64. package/dist/src/provider/index.js.map +1 -0
  65. package/dist/src/provider/reactContext.d.ts +8 -0
  66. package/dist/src/provider/reactContext.d.ts.map +1 -0
  67. package/dist/src/provider/reactContext.js +7 -0
  68. package/dist/src/provider/reactContext.js.map +1 -0
  69. package/dist/src/provider/setupListeners.d.ts +6 -0
  70. package/dist/src/provider/setupListeners.d.ts.map +1 -0
  71. package/dist/src/provider/setupListeners.js +7 -0
  72. package/dist/src/provider/setupListeners.js.map +1 -0
  73. package/dist/src/react-native-sse/EventSource.d.ts +47 -0
  74. package/dist/src/react-native-sse/EventSource.d.ts.map +1 -0
  75. package/dist/src/react-native-sse/EventSource.js +264 -0
  76. package/dist/src/react-native-sse/EventSource.js.map +1 -0
  77. package/dist/src/react-native-sse/index.d.ts +3 -0
  78. package/dist/src/react-native-sse/index.d.ts.map +1 -0
  79. package/dist/src/react-native-sse/index.js +3 -0
  80. package/dist/src/react-native-sse/index.js.map +1 -0
  81. package/dist/src/react-native-sse/types.d.ts +59 -0
  82. package/dist/src/react-native-sse/types.d.ts.map +1 -0
  83. package/dist/src/react-native-sse/types.js +2 -0
  84. package/dist/src/react-native-sse/types.js.map +1 -0
  85. package/package.json +77 -0
@@ -0,0 +1,132 @@
1
+ import { useTypedVariation, useTypedVariationDetail } from './useTypedVariation';
2
+ /**
3
+ * Determines the boolean variation of a feature flag.
4
+ *
5
+ * If the flag variation does not have a boolean value, defaultValue is returned.
6
+ *
7
+ * @param key The unique key of the feature flag.
8
+ * @param defaultValue The default value of the flag, to be used if the value is not available
9
+ * from LaunchDarkly.
10
+ * @returns
11
+ * The boolean value.
12
+ */
13
+ export const useBoolVariation = (key, defaultValue) => useTypedVariation(key, defaultValue);
14
+ /**
15
+ * Determines the boolean variation of a feature flag for a context, along with information about
16
+ * how it was calculated.
17
+ *
18
+ * The `reason` property of the result will also be included in analytics events, if you are
19
+ * capturing detailed event data for this flag.
20
+ *
21
+ * If the flag variation does not have a boolean value, defaultValue is returned. The reason will
22
+ * indicate an error of the type `WRONG_KIND` in this case.
23
+ *
24
+ * For more information, see the [SDK reference
25
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
26
+ *
27
+ * @param key The unique key of the feature flag.
28
+ * @param defaultValue The default value of the flag, to be used if the value is not available
29
+ * from LaunchDarkly.
30
+ * @returns
31
+ * The result (as an {@link LDEvaluationDetailTyped<boolean>}).
32
+ */
33
+ export const useBoolVariationDetail = (key, defaultValue) => useTypedVariationDetail(key, defaultValue);
34
+ /**
35
+ * Determines the numeric variation of a feature flag.
36
+ *
37
+ * If the flag variation does not have a numeric value, defaultValue is returned.
38
+ *
39
+ * @param key The unique key of the feature flag.
40
+ * @param defaultValue The default value of the flag, to be used if the value is not available
41
+ * from LaunchDarkly.
42
+ * @returns
43
+ * The numeric value.
44
+ */
45
+ export const useNumberVariation = (key, defaultValue) => useTypedVariation(key, defaultValue);
46
+ /**
47
+ * Determines the numeric variation of a feature flag for a context, along with information about
48
+ * how it was calculated.
49
+ *
50
+ * The `reason` property of the result will also be included in analytics events, if you are
51
+ * capturing detailed event data for this flag.
52
+ *
53
+ * If the flag variation does not have a numeric value, defaultValue is returned. The reason will
54
+ * indicate an error of the type `WRONG_KIND` in this case.
55
+ *
56
+ * For more information, see the [SDK reference
57
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
58
+ *
59
+ * @param key The unique key of the feature flag.
60
+ * @param defaultValue The default value of the flag, to be used if the value is not available
61
+ * from LaunchDarkly.
62
+ * @returns
63
+ * The result (as an {@link LDEvaluationDetailTyped<number>}).
64
+ */
65
+ export const useNumberVariationDetail = (key, defaultValue) => useTypedVariationDetail(key, defaultValue);
66
+ /**
67
+ * Determines the string variation of a feature flag.
68
+ *
69
+ * If the flag variation does not have a string value, defaultValue is returned.
70
+ *
71
+ * @param key The unique key of the feature flag.
72
+ * @param defaultValue The default value of the flag, to be used if the value is not available
73
+ * from LaunchDarkly.
74
+ * @returns
75
+ * The string value.
76
+ */
77
+ export const useStringVariation = (key, defaultValue) => useTypedVariation(key, defaultValue);
78
+ /**
79
+ * Determines the string variation of a feature flag for a context, along with information about
80
+ * how it was calculated.
81
+ *
82
+ * The `reason` property of the result will also be included in analytics events, if you are
83
+ * capturing detailed event data for this flag.
84
+ *
85
+ * If the flag variation does not have a string value, defaultValue is returned. The reason will
86
+ * indicate an error of the type `WRONG_KIND` in this case.
87
+ *
88
+ * For more information, see the [SDK reference
89
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
90
+ *
91
+ * @param key The unique key of the feature flag.
92
+ * @param defaultValue The default value of the flag, to be used if the value is not available
93
+ * from LaunchDarkly.
94
+ * @returns
95
+ * The result (as an {@link LDEvaluationDetailTyped<string>}).
96
+ */
97
+ export const useStringVariationDetail = (key, defaultValue) => useTypedVariationDetail(key, defaultValue);
98
+ /**
99
+ * Determines the json variation of a feature flag.
100
+ *
101
+ * This version may be favored in TypeScript versus `variation` because it returns
102
+ * an `unknown` type instead of `any`. `unknown` will require a cast before usage.
103
+ *
104
+ * @param key The unique key of the feature flag.
105
+ * @param defaultValue The default value of the flag, to be used if the value is not available
106
+ * from LaunchDarkly.
107
+ * @returns
108
+ * The json value.
109
+ */
110
+ export const useJsonVariation = (key, defaultValue) => useTypedVariation(key, defaultValue);
111
+ /**
112
+ * Determines the json variation of a feature flag for a context, along with information about how it
113
+ * was calculated.
114
+ *
115
+ * The `reason` property of the result will also be included in analytics events, if you are
116
+ * capturing detailed event data for this flag.
117
+ *
118
+ * This version may be favored in TypeScript versus `variation` because it returns
119
+ * an `unknown` type instead of `any`. `unknown` will require a cast before usage.
120
+ *
121
+ * For more information, see the [SDK reference
122
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
123
+ *
124
+ * @param key The unique key of the feature flag.
125
+ * @param defaultValue The default value of the flag, to be used if the value is not available
126
+ * from LaunchDarkly.
127
+ * @returns
128
+ * If you provided a callback, then nothing. Otherwise, a Promise which will be resolved with
129
+ * the result (as an{@link LDEvaluationDetailTyped<unknown>}).
130
+ */
131
+ export const useJsonVariationDetail = (key, defaultValue) => useTypedVariationDetail(key, defaultValue);
132
+ //# sourceMappingURL=useVariation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariation.js","sourceRoot":"","sources":["../../../../src/hooks/variation/useVariation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,YAAqB,EAAE,EAAE,CACrE,iBAAiB,CAAU,GAAG,EAAE,YAAY,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAE,YAAqB,EAAE,EAAE,CAC3E,uBAAuB,CAAU,GAAG,EAAE,YAAY,CAAC,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,CACtE,iBAAiB,CAAS,GAAG,EAAE,YAAY,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,CAC5E,uBAAuB,CAAS,GAAG,EAAE,YAAY,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,CACtE,iBAAiB,CAAS,GAAG,EAAE,YAAY,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,CAC5E,uBAAuB,CAAS,GAAG,EAAE,YAAY,CAAC,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,YAAqB,EAAE,EAAE,CACrE,iBAAiB,CAAU,GAAG,EAAE,YAAY,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAE,YAAqB,EAAE,EAAE,CAC3E,uBAAuB,CAAU,GAAG,EAAE,YAAY,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import ReactNativeLDClient from './ReactNativeLDClient';
2
+ export * from '@launchdarkly/js-client-sdk-common';
3
+ export * from './hooks';
4
+ export * from './provider';
5
+ export { ReactNativeLDClient };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAIxD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This is the API reference for the React Native LaunchDarkly SDK.
3
+ *
4
+ * For more information, see the SDK reference guide.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import { setupPolyfill } from './polyfills';
9
+ import ReactNativeLDClient from './ReactNativeLDClient';
10
+ setupPolyfill();
11
+ export * from '@launchdarkly/js-client-sdk-common';
12
+ export * from './hooks';
13
+ export * from './provider';
14
+ export { ReactNativeLDClient };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,aAAa,EAAE,CAAC;AAEhB,cAAc,oCAAoC,CAAC;AAEnD,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * For react-native version >= 0.71, the LaunchDarkly React-Native SDK uses
3
+ * @react-native-async-storage/async-storage for bootstrapping. This is a native
4
+ * dependency.
5
+ *
6
+ * If you are using expo, then adding the LaunchDarkly React Native
7
+ * SDK from npm and re-running pod install should suffice.
8
+ *
9
+ * If you are not using expo, you will need to explicitly add
10
+ * @react-native-async-storage/async-storage as a dependency to your project
11
+ * and re-run pod install for auto-linking to work. This is because auto-link
12
+ * does not work with transitive dependencies:
13
+ * https://github.com/react-native-community/cli/issues/1347
14
+ *
15
+ * For react-native version < 0.71, the built-in react-native AsyncStorage
16
+ * module is used.
17
+ */
18
+ declare let ConditionalAsyncStorage: any;
19
+ export default ConditionalAsyncStorage;
20
+ //# sourceMappingURL=ConditionalAsyncStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionalAsyncStorage.d.ts","sourceRoot":"","sources":["../../../src/platform/ConditionalAsyncStorage.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,IAAI,uBAAuB,EAAE,GAAG,CAAC;AAUjC,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /* eslint-disable import/no-mutable-exports,global-require */
2
+ /**
3
+ * For react-native version >= 0.71, the LaunchDarkly React-Native SDK uses
4
+ * @react-native-async-storage/async-storage for bootstrapping. This is a native
5
+ * dependency.
6
+ *
7
+ * If you are using expo, then adding the LaunchDarkly React Native
8
+ * SDK from npm and re-running pod install should suffice.
9
+ *
10
+ * If you are not using expo, you will need to explicitly add
11
+ * @react-native-async-storage/async-storage as a dependency to your project
12
+ * and re-run pod install for auto-linking to work. This is because auto-link
13
+ * does not work with transitive dependencies:
14
+ * https://github.com/react-native-community/cli/issues/1347
15
+ *
16
+ * For react-native version < 0.71, the built-in react-native AsyncStorage
17
+ * module is used.
18
+ */
19
+ let ConditionalAsyncStorage;
20
+ try {
21
+ // react-native version < 0.71
22
+ ConditionalAsyncStorage = require('react-native').AsyncStorage;
23
+ }
24
+ catch (e) {
25
+ // react-native version >= 0.71
26
+ ConditionalAsyncStorage = require('@react-native-async-storage/async-storage').default;
27
+ }
28
+ export default ConditionalAsyncStorage;
29
+ //# sourceMappingURL=ConditionalAsyncStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionalAsyncStorage.js","sourceRoot":"","sources":["../../../src/platform/ConditionalAsyncStorage.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,IAAI,uBAA4B,CAAC;AAEjC,IAAI;IACF,8BAA8B;IAC9B,uBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC;CAChE;AAAC,OAAO,CAAC,EAAE;IACV,+BAA+B;IAC/B,uBAAuB,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC,OAAO,CAAC;CACxF;AAED,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { LDLogger, Platform } from '@launchdarkly/js-client-sdk-common';
2
+ declare const createPlatform: (logger: LDLogger) => Platform;
3
+ export default createPlatform;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EASV,QAAQ,EAER,QAAQ,EAMT,MAAM,oCAAoC,CAAC;AAiF5C,QAAA,MAAM,cAAc,WAAY,QAAQ,KAAG,QAMzC,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { name, version } from '../../package.json';
2
+ import { btoa, uuidv4 } from '../polyfills';
3
+ import RNEventSource from '../react-native-sse';
4
+ import AsyncStorage from './ConditionalAsyncStorage';
5
+ class PlatformRequests {
6
+ createEventSource(url, eventSourceInitDict) {
7
+ return new RNEventSource(url, {
8
+ headers: eventSourceInitDict.headers,
9
+ retryAndHandleError: eventSourceInitDict.errorFilter,
10
+ });
11
+ }
12
+ fetch(url, options) {
13
+ // @ts-ignore
14
+ return fetch(url, options);
15
+ }
16
+ }
17
+ class PlatformEncoding {
18
+ btoa(data) {
19
+ return btoa(data);
20
+ }
21
+ }
22
+ class PlatformInfo {
23
+ platformData() {
24
+ return {
25
+ name: 'React Native',
26
+ };
27
+ }
28
+ sdkData() {
29
+ return {
30
+ name,
31
+ version,
32
+ userAgentBase: 'ReactNativeClient',
33
+ };
34
+ }
35
+ }
36
+ class PlatformCrypto {
37
+ createHash(_algorithm) {
38
+ throw new Error('not implemented');
39
+ }
40
+ createHmac(_algorithm, _key) {
41
+ throw new Error('not implemented');
42
+ }
43
+ randomUUID() {
44
+ return uuidv4();
45
+ }
46
+ }
47
+ class PlatformStorage {
48
+ constructor(logger) {
49
+ this.logger = logger;
50
+ }
51
+ async clear(key) {
52
+ await AsyncStorage.removeItem(key);
53
+ }
54
+ async get(key) {
55
+ try {
56
+ const value = await AsyncStorage.getItem(key);
57
+ return value !== null && value !== void 0 ? value : null;
58
+ }
59
+ catch (error) {
60
+ this.logger.debug(`Error getting AsyncStorage key: ${key}, error: ${error}`);
61
+ return null;
62
+ }
63
+ }
64
+ async set(key, value) {
65
+ try {
66
+ await AsyncStorage.setItem(key, value);
67
+ }
68
+ catch (error) {
69
+ this.logger.debug(`Error saving AsyncStorage key: ${key}, value: ${value}, error: ${error}`);
70
+ }
71
+ }
72
+ }
73
+ const createPlatform = (logger) => ({
74
+ crypto: new PlatformCrypto(),
75
+ info: new PlatformInfo(),
76
+ requests: new PlatformRequests(),
77
+ encoding: new PlatformEncoding(),
78
+ storage: new PlatformStorage(logger),
79
+ });
80
+ export default createPlatform;
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,MAAM,gBAAgB;IACpB,iBAAiB,CAAC,GAAW,EAAE,mBAAwC;QACrE,OAAO,IAAI,aAAa,CAAY,GAAG,EAAE;YACvC,OAAO,EAAE,mBAAmB,CAAC,OAAO;YACpC,mBAAmB,EAAE,mBAAmB,CAAC,WAAW;SACrD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAiB;QAClC,aAAa;QACb,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;CACF;AACD,MAAM,gBAAgB;IACpB,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACF;AAED,MAAM,YAAY;IAChB,YAAY;QACV,OAAO;YACL,IAAI,EAAE,cAAc;SACrB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO;YACL,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,mBAAmB;SACnC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,cAAc;IAClB,UAAU,CAAC,UAAkB;QAC3B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAY;QACzC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,UAAU;QACR,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;CACF;AAED,MAAM,eAAe;IACnB,YAA6B,MAAgB;QAAhB,WAAM,GAAN,MAAM,CAAU;IAAG,CAAC;IACjD,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,GAAG,YAAY,KAAK,EAAE,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAClC,IAAI;YACF,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACxC;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,GAAG,YAAY,KAAK,YAAY,KAAK,EAAE,CAAC,CAAC;SAC9F;IACH,CAAC;CACF;AAED,MAAM,cAAc,GAAG,CAAC,MAAgB,EAAY,EAAE,CAAC,CAAC;IACtD,MAAM,EAAE,IAAI,cAAc,EAAE;IAC5B,IAAI,EAAE,IAAI,YAAY,EAAE;IACxB,QAAQ,EAAE,IAAI,gBAAgB,EAAE;IAChC,QAAQ,EAAE,IAAI,gBAAgB,EAAE;IAChC,OAAO,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;CACrC,CAAC,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Ripped from:
3
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Events/CustomEvent.js#L21
4
+ */
5
+ import { Event } from 'event-target-shim';
6
+ type CustomEventOptions = {
7
+ bubbles?: boolean;
8
+ cancelable?: boolean;
9
+ composed?: boolean;
10
+ detail?: any;
11
+ };
12
+ export default class CustomEvent extends Event {
13
+ detail: any;
14
+ constructor(typeArg: string, options: CustomEventOptions);
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=CustomEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomEvent.d.ts","sourceRoot":"","sources":["../../../src/polyfills/CustomEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK;IAC5C,MAAM,EAAE,GAAG,CAAC;gBAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB;CAMzD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Ripped from:
3
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Events/CustomEvent.js#L21
4
+ */
5
+ import { Event } from 'event-target-shim';
6
+ export default class CustomEvent extends Event {
7
+ constructor(typeArg, options) {
8
+ const { bubbles, cancelable, composed, detail } = options;
9
+ super(typeArg, { bubbles, cancelable, composed });
10
+ this.detail = detail; // this would correspond to `NativeEvent` in SyntheticEvent
11
+ }
12
+ }
13
+ //# sourceMappingURL=CustomEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomEvent.js","sourceRoot":"","sources":["../../../src/polyfills/CustomEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS1C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK;IAG5C,YAAY,OAAe,EAAE,OAA2B;QACtD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC1D,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAElD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,2DAA2D;IACnF,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export default function btoa(s: string): string;
2
+ //# sourceMappingURL=btoa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btoa.d.ts","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAE,MAAM,UAErC"}
@@ -0,0 +1,12 @@
1
+ import { fromByteArray } from 'base64-js';
2
+ function convertToByteArray(s) {
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
+ }
9
+ export default function btoa(s) {
10
+ return fromByteArray(convertToByteArray(s));
11
+ }
12
+ //# sourceMappingURL=btoa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btoa.js","sourceRoot":"","sources":["../../../src/polyfills/btoa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,SAAS,kBAAkB,CAAC,CAAS;IACnC,MAAM,CAAC,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACpC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACzB;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAS;IACpC,OAAO,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import btoa from './btoa';
2
+ import uuidv4 from './uuid';
3
+ declare function setupPolyfill(): void;
4
+ export { btoa, setupPolyfill, uuidv4 };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/polyfills/index.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,iBAAS,aAAa,SAKrB;AACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import EventTarget from 'event-target-shim';
2
+ import btoa from './btoa';
3
+ import CustomEvent from './CustomEvent';
4
+ import uuidv4 from './uuid';
5
+ function setupPolyfill() {
6
+ Object.assign(global, {
7
+ EventTarget,
8
+ CustomEvent,
9
+ });
10
+ }
11
+ export { btoa, setupPolyfill, uuidv4 };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,SAAS,aAAa;IACpB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QACpB,WAAW;QACX,WAAW;KACZ,CAAC,CAAC;AACL,CAAC;AACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * To avoid dependencies on uuid, this is good enough for now.
3
+ * Ripped from the react-native repo:
4
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/BlobManager.js#L27
5
+ *
6
+ * Based on the rfc4122-compliant solution posted at
7
+ * http://stackoverflow.com/questions/105034
8
+ */
9
+ export default function uuidv4(): string;
10
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../src/polyfills/uuid.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,MAAM,CAMvC"}
@@ -0,0 +1,17 @@
1
+ /* eslint-disable no-bitwise */
2
+ /**
3
+ * To avoid dependencies on uuid, this is good enough for now.
4
+ * Ripped from the react-native repo:
5
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Blob/BlobManager.js#L27
6
+ *
7
+ * Based on the rfc4122-compliant solution posted at
8
+ * http://stackoverflow.com/questions/105034
9
+ */
10
+ export default function uuidv4() {
11
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
12
+ const r = (Math.random() * 16) | 0;
13
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
14
+ return v.toString(16);
15
+ });
16
+ }
17
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/polyfills/uuid.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM;IAC5B,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { type LDContext } from '@launchdarkly/js-client-sdk-common';
3
+ import ReactNativeLDClient from '../ReactNativeLDClient';
4
+ type LDProps = {
5
+ client: ReactNativeLDClient;
6
+ context?: LDContext;
7
+ };
8
+ /**
9
+ * This is the LaunchDarkly Provider which uses the React context api to store
10
+ * and pass data to child components through hooks.
11
+ *
12
+ * @param client The ReactNativeLDClient object. Initialize this object separately
13
+ * and then set this prop when declaring the LDProvider.
14
+ * @param context Optional. The LDContext object. If set, the LDProvider will
15
+ * `identify` this context on application mount. If not set, default flag values
16
+ * will be returned. You can run `identify` at a later time.
17
+ * @param children
18
+ * @constructor
19
+ */
20
+ declare const LDProvider: ({ client, context, children }: PropsWithChildren<LDProps>) => import("react").JSX.Element;
21
+ export default LDProvider;
22
+ //# sourceMappingURL=LDProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/LDProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAIzD,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,mBAAmB,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,UAAU,kCAAmC,kBAAkB,OAAO,CAAC,gCAgB5E,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Provider } from './reactContext';
3
+ import setupListeners from './setupListeners';
4
+ /**
5
+ * This is the LaunchDarkly Provider which uses the React context api to store
6
+ * and pass data to child components through hooks.
7
+ *
8
+ * @param client The ReactNativeLDClient object. Initialize this object separately
9
+ * and then set this prop when declaring the LDProvider.
10
+ * @param context Optional. The LDContext object. If set, the LDProvider will
11
+ * `identify` this context on application mount. If not set, default flag values
12
+ * will be returned. You can run `identify` at a later time.
13
+ * @param children
14
+ * @constructor
15
+ */
16
+ const LDProvider = ({ client, context, children }) => {
17
+ const [state, setState] = useState({ client });
18
+ useEffect(() => {
19
+ setupListeners(client, setState);
20
+ if (context) {
21
+ client
22
+ .identify(context)
23
+ .catch((e) => client.logger.debug(`LaunchDarkly React Native Sdk identify error: ${e}`));
24
+ }
25
+ }, []);
26
+ return <Provider value={state}>{children}</Provider>;
27
+ };
28
+ export default LDProvider;
29
+ //# sourceMappingURL=LDProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDProvider.js","sourceRoot":"","sources":["../../../src/provider/LDProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAK/D,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAO9C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAA8B,EAAE,EAAE;IAC/E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEjC,IAAI,OAAO,EAAE;YACX,MAAM;iBACH,QAAQ,CAAC,OAAO,CAAC;iBACjB,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAChB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,EAAE,CAAC,CAC1E,CAAC;SACL;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import LDProvider from './LDProvider';
2
+ export { LDProvider };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import LDProvider from './LDProvider';
2
+ // eslint-disable-next-line import/prefer-default-export
3
+ export { LDProvider };
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,wDAAwD;AACxD,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { LDClient } from '@launchdarkly/js-client-sdk-common';
2
+ export type ReactContext = {
3
+ client: LDClient;
4
+ };
5
+ export declare const context: import("react").Context<ReactContext>;
6
+ declare const Provider: import("react").Provider<ReactContext>, Consumer: import("react").Consumer<ReactContext>;
7
+ export { Provider, Consumer };
8
+ //# sourceMappingURL=reactContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactContext.d.ts","sourceRoot":"","sources":["../../../src/provider/reactContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,OAAO,uCAElB,CAAC;AAEH,QAAA,MAAQ,QAAQ,0CAAE,QAAQ,wCAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { createContext } from 'react';
2
+ export const context = createContext({
3
+ client: {},
4
+ });
5
+ const { Provider, Consumer } = context;
6
+ export { Provider, Consumer };
7
+ //# sourceMappingURL=reactContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactContext.js","sourceRoot":"","sources":["../../../src/provider/reactContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAe;IACjD,MAAM,EAAE,EAAS;CAClB,CAAC,CAAC;AAEH,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import ReactNativeLDClient from '../ReactNativeLDClient';
3
+ import { ReactContext } from './reactContext';
4
+ declare const setupListeners: (client: ReactNativeLDClient, setState: Dispatch<SetStateAction<ReactContext>>) => void;
5
+ export default setupListeners;
6
+ //# sourceMappingURL=setupListeners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupListeners.d.ts","sourceRoot":"","sources":["../../../src/provider/setupListeners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,QAAA,MAAM,cAAc,WACV,mBAAmB,YACjB,SAAS,eAAe,YAAY,CAAC,CAAC,SAKjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ const setupListeners = (client, setState) => {
2
+ client.on('change', () => {
3
+ setState({ client });
4
+ });
5
+ };
6
+ export default setupListeners;
7
+ //# sourceMappingURL=setupListeners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupListeners.js","sourceRoot":"","sources":["../../../src/provider/setupListeners.ts"],"names":[],"mappings":"AAKA,MAAM,cAAc,GAAG,CACrB,MAA2B,EAC3B,QAAgD,EAChD,EAAE;IACF,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Ripped from https://github.com/binaryminds/react-native-sse
3
+ * These changes are made from the above repo at fork-time:
4
+ * 1. converted to ts and fix ts related errors.
5
+ * 2. added onopen, onclose, onerror, onretrying functions.
6
+ * 3. modified dispatch to work with functions added in 2.
7
+ * 4. replaced all for of loops with foreach
8
+ */
9
+ import type { EventSourceEvent, EventSourceListener, EventSourceOptions, EventType } from './types';
10
+ export default class EventSource<E extends string = never> {
11
+ ERROR: number;
12
+ CONNECTING: number;
13
+ OPEN: number;
14
+ CLOSED: number;
15
+ private lastEventId;
16
+ private lastIndexProcessed;
17
+ private eventType;
18
+ private status;
19
+ private eventHandlers;
20
+ private method;
21
+ private timeout;
22
+ private timeoutBeforeConnection;
23
+ private withCredentials;
24
+ private headers;
25
+ private body;
26
+ private debug;
27
+ private url;
28
+ private xhr;
29
+ private pollTimer;
30
+ private pollingInterval;
31
+ private retryAndHandleError?;
32
+ constructor(url: string, options?: EventSourceOptions);
33
+ private pollAgain;
34
+ open(): void;
35
+ private logDebug;
36
+ private handleEvent;
37
+ addEventListener<T extends EventType<E>>(type: T, listener: EventSourceListener<E, T>): void;
38
+ removeEventListener<T extends EventType<E>>(type: T, listener: EventSourceListener<E, T>): void;
39
+ removeAllEventListeners<T extends EventType<E>>(type?: T): void;
40
+ dispatch<T extends EventType<E>>(type: T, data: EventSourceEvent<T>): void;
41
+ close(): void;
42
+ onopen(): void;
43
+ onclose(): void;
44
+ onerror(_err: any): void;
45
+ onretrying(_e: any): void;
46
+ }
47
+ //# sourceMappingURL=EventSource.d.ts.map