@kameleoon/react-sdk 6.1.1 → 6.1.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.
Files changed (72) hide show
  1. package/dist/KameleoonContext.js +7 -3
  2. package/dist/KameleoonContext.js.map +1 -1
  3. package/dist/KameleoonError.js +16 -27
  4. package/dist/KameleoonError.js.map +1 -1
  5. package/dist/KameleoonProvider.js +18 -19
  6. package/dist/KameleoonProvider.js.map +1 -1
  7. package/dist/ProviderError.js +10 -25
  8. package/dist/ProviderError.js.map +1 -1
  9. package/dist/constants.js +6 -2
  10. package/dist/constants.js.map +1 -1
  11. package/dist/eventSource/browserEventSource.js +40 -30
  12. package/dist/eventSource/browserEventSource.js.map +1 -1
  13. package/dist/eventSource/index.js +18 -6
  14. package/dist/eventSource/index.js.map +1 -1
  15. package/dist/eventSource/nativeEventSource.js +42 -35
  16. package/dist/eventSource/nativeEventSource.js.map +1 -1
  17. package/dist/index.js +288 -51
  18. package/dist/index.js.map +1 -1
  19. package/dist/kameleoonClient.js +27 -22
  20. package/dist/kameleoonClient.js.map +1 -1
  21. package/dist/kameleoonUtils/browserUtils.js +45 -58
  22. package/dist/kameleoonUtils/browserUtils.js.map +1 -1
  23. package/dist/kameleoonUtils/nativeUtils.js +38 -54
  24. package/dist/kameleoonUtils/nativeUtils.js.map +1 -1
  25. package/dist/requester.d.ts +5 -0
  26. package/dist/requester.js +29 -0
  27. package/dist/requester.js.map +1 -0
  28. package/dist/storage/index.js +18 -6
  29. package/dist/storage/index.js.map +1 -1
  30. package/dist/storage/localStorage.js +37 -39
  31. package/dist/storage/localStorage.js.map +1 -1
  32. package/dist/storage/nativeStorage.js +36 -36
  33. package/dist/storage/nativeStorage.js.map +1 -1
  34. package/dist/useAddData.js +26 -49
  35. package/dist/useAddData.js.map +1 -1
  36. package/dist/useBrowserVisitorCode.js +13 -11
  37. package/dist/useBrowserVisitorCode.js.map +1 -1
  38. package/dist/useConfigurationUpdate.js +26 -20
  39. package/dist/useConfigurationUpdate.js.map +1 -1
  40. package/dist/useError.js +14 -12
  41. package/dist/useError.js.map +1 -1
  42. package/dist/useErrors.js +15 -38
  43. package/dist/useErrors.js.map +1 -1
  44. package/dist/useExperiments.js +27 -21
  45. package/dist/useExperiments.js.map +1 -1
  46. package/dist/useFeatureFlagActive.js +27 -21
  47. package/dist/useFeatureFlagActive.js.map +1 -1
  48. package/dist/useFeatureFlagVariationKey.js +27 -21
  49. package/dist/useFeatureFlagVariationKey.js.map +1 -1
  50. package/dist/useFeatureFlags.js +27 -21
  51. package/dist/useFeatureFlags.js.map +1 -1
  52. package/dist/useFeatureVariable.js +27 -21
  53. package/dist/useFeatureVariable.js.map +1 -1
  54. package/dist/useFlushData.js +16 -12
  55. package/dist/useFlushData.js.map +1 -1
  56. package/dist/useInitialize.js +27 -65
  57. package/dist/useInitialize.js.map +1 -1
  58. package/dist/useKameleoon.js +15 -13
  59. package/dist/useKameleoon.js.map +1 -1
  60. package/dist/useNativeVisitorCode.js +13 -11
  61. package/dist/useNativeVisitorCode.js.map +1 -1
  62. package/dist/useRemoteData.js +28 -67
  63. package/dist/useRemoteData.js.map +1 -1
  64. package/dist/useTrackConversion.js +26 -20
  65. package/dist/useTrackConversion.js.map +1 -1
  66. package/dist/useTriggerExperiment.js +28 -22
  67. package/dist/useTriggerExperiment.js.map +1 -1
  68. package/dist/useVisitorExperiments.js +27 -21
  69. package/dist/useVisitorExperiments.js.map +1 -1
  70. package/dist/useVisitorFeatureFlags.js +27 -21
  71. package/dist/useVisitorFeatureFlags.js.map +1 -1
  72. package/package.json +8 -5
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.KameleoonContext = void 0;
4
- var react_1 = require("react");
5
- exports.KameleoonContext = (0, react_1.createContext)(null);
7
+ var _react = require("react");
8
+ const KameleoonContext = /*#__PURE__*/(0, _react.createContext)(null);
9
+ exports.KameleoonContext = KameleoonContext;
6
10
  //# sourceMappingURL=KameleoonContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KameleoonContext.js","sourceRoot":"","sources":["../src/KameleoonContext.ts"],"names":[],"mappings":";;;AAAA,+BAAsC;AAGzB,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAuB,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"KameleoonContext.js","names":["_react","require","KameleoonContext","createContext","exports"],"sources":["../src/KameleoonContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\n\nexport const KameleoonContext = createContext<KameleoonCore | null>(null);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,gBAAG,IAAAC,oBAAa,EAAuB,IAAI,CAAC;AAACC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
@@ -1,31 +1,20 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
18
6
  exports.KameleoonError = void 0;
19
- var KameleoonError = /** @class */ (function (_super) {
20
- __extends(KameleoonError, _super);
21
- function KameleoonError(type) {
22
- var _this = _super.call(this, "Error: ".concat(type)) || this;
23
- _this.name = 'KameleoonError';
24
- _this.message = "".concat(_this.name, ".").concat(type);
25
- _this.type = type;
26
- return _this;
27
- }
28
- return KameleoonError;
29
- }(Error));
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
+ class KameleoonError extends Error {
11
+ constructor(type) {
12
+ super(`Error: ${type}`);
13
+ _defineProperty(this, "type", void 0);
14
+ this.name = 'KameleoonError';
15
+ this.message = `${this.name}.${type}`;
16
+ this.type = type;
17
+ }
18
+ }
30
19
  exports.KameleoonError = KameleoonError;
31
20
  //# sourceMappingURL=KameleoonError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KameleoonError.js","sourceRoot":"","sources":["../src/KameleoonError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA;IAAoC,kCAAK;IAGvC,wBAAY,IAAwB;QAApC,YACE,kBAAM,iBAAU,IAAI,CAAE,CAAC,SAIxB;QAHC,KAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,KAAI,CAAC,OAAO,GAAG,UAAG,KAAI,CAAC,IAAI,cAAI,IAAI,CAAE,CAAC;QACtC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,qBAAC;AAAD,CAAC,AATD,CAAoC,KAAK,GASxC;AATY,wCAAc"}
1
+ {"version":3,"file":"KameleoonError.js","names":["KameleoonError","Error","constructor","type","_defineProperty","name","message","exports"],"sources":["../src/KameleoonError.ts"],"sourcesContent":["import { KameleoonException } from '@kameleoon/javascript-sdk-core';\n\nexport class KameleoonError extends Error {\n type: KameleoonException;\n\n constructor(type: KameleoonException) {\n super(`Error: ${type}`);\n this.name = 'KameleoonError';\n this.message = `${this.name}.${type}`;\n this.type = type;\n }\n}\n"],"mappings":";;;;;;;;;AAEO,MAAMA,cAAc,SAASC,KAAK,CAAC;EAGxCC,WAAWA,CAACC,IAAwB,EAAE;IACpC,KAAK,CAAE,UAASA,IAAK,EAAC,CAAC;IAACC,eAAA;IACxB,IAAI,CAACC,IAAI,GAAG,gBAAgB;IAC5B,IAAI,CAACC,OAAO,GAAI,GAAE,IAAI,CAACD,IAAK,IAAGF,IAAK,EAAC;IACrC,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;AACF;AAACI,OAAA,CAAAP,cAAA,GAAAA,cAAA"}
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var jsx_runtime_1 = require("react/jsx-runtime");
15
- var react_1 = require("react");
16
- var KameleoonContext_1 = require("./KameleoonContext");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _KameleoonContext = require("./KameleoonContext");
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
11
  /**
18
12
  * A Provider that wraps the project and provides an access to SDK APIs
19
13
  */
20
- function KameleoonProvider(_a) {
21
- var client = _a.client, children = _a.children;
22
- return ((0, jsx_runtime_1.jsx)(KameleoonContext_1.KameleoonContext.Provider, __assign({ value: client }, { children: children })));
14
+ function KameleoonProvider({
15
+ client,
16
+ children
17
+ }) {
18
+ return /*#__PURE__*/_react.default.createElement(_KameleoonContext.KameleoonContext.Provider, {
19
+ value: client
20
+ }, children);
23
21
  }
24
- exports.default = (0, react_1.memo)(KameleoonProvider);
22
+ var _default = /*#__PURE__*/(0, _react.memo)(KameleoonProvider);
23
+ exports.default = _default;
25
24
  //# sourceMappingURL=KameleoonProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KameleoonProvider.js","sourceRoot":"","sources":["../src/KameleoonProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA+C;AAE/C,uDAAsD;AAStD;;GAEG;AACH,SAAS,iBAAiB,CAAC,EAGD;QAFxB,MAAM,YAAA,EACN,QAAQ,cAAA;IAER,OAAO,CACL,uBAAC,mCAAgB,CAAC,QAAQ,aAAC,KAAK,EAAE,MAAM,gBACrC,QAAQ,IACiB,CAC7B,CAAC;AACJ,CAAC;AAED,kBAAe,IAAA,YAAI,EAAC,iBAAiB,CAAC,CAAC"}
1
+ {"version":3,"file":"KameleoonProvider.js","names":["_react","_interopRequireWildcard","require","_KameleoonContext","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","KameleoonProvider","client","children","createElement","KameleoonContext","Provider","value","_default","memo","exports"],"sources":["../src/KameleoonProvider.tsx"],"sourcesContent":["import React, { memo, ReactNode } from 'react';\nimport { KameleoonCore } from '@kameleoon/javascript-sdk-core';\nimport { KameleoonContext } from './KameleoonContext';\n\nexport interface IKameleoonProviderProps {\n /** Child elements of the provider. */\n children: ReactNode;\n /** An instance of KameleoonClient. */\n client: KameleoonCore;\n}\n\n/**\n * A Provider that wraps the project and provides an access to SDK APIs\n */\nfunction KameleoonProvider({\n client,\n children,\n}: IKameleoonProviderProps): JSX.Element {\n return (\n <KameleoonContext.Provider value={client}>\n {children}\n </KameleoonContext.Provider>\n );\n}\n\nexport default memo(KameleoonProvider);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAAsD,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAStD;AACA;AACA;AACA,SAASW,iBAAiBA,CAAC;EACzBC,MAAM;EACNC;AACuB,CAAC,EAAe;EACvC,oBACE5B,MAAA,CAAAW,OAAA,CAAAkB,aAAA,CAAC1B,iBAAA,CAAA2B,gBAAgB,CAACC,QAAQ;IAACC,KAAK,EAAEL;EAAO,GACtCC,QAAQ,CACiB;AAEhC;AAAC,IAAAK,QAAA,gBAEc,IAAAC,WAAI,EAACR,iBAAiB,CAAC;AAAAS,OAAA,CAAAxB,OAAA,GAAAsB,QAAA"}
@@ -1,29 +1,14 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
18
6
  exports.ProviderError = void 0;
19
- var ProviderError = /** @class */ (function (_super) {
20
- __extends(ProviderError, _super);
21
- function ProviderError(method) {
22
- var _this = _super.call(this, "".concat(method, " must be used within a KameleoonProvider")) || this;
23
- _this.name = 'ProviderError';
24
- return _this;
25
- }
26
- return ProviderError;
27
- }(Error));
7
+ class ProviderError extends Error {
8
+ constructor(method) {
9
+ super(`${method} must be used within a KameleoonProvider`);
10
+ this.name = 'ProviderError';
11
+ }
12
+ }
28
13
  exports.ProviderError = ProviderError;
29
14
  //# sourceMappingURL=ProviderError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderError.js","sourceRoot":"","sources":["../src/ProviderError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;IAAmC,iCAAK;IACtC,uBAAY,MAAc;QAA1B,YACE,kBAAM,UAAG,MAAM,6CAA0C,CAAC,SAE3D;QADC,KAAI,CAAC,IAAI,GAAG,eAAe,CAAC;;IAC9B,CAAC;IACH,oBAAC;AAAD,CAAC,AALD,CAAmC,KAAK,GAKvC;AALY,sCAAa"}
1
+ {"version":3,"file":"ProviderError.js","names":["ProviderError","Error","constructor","method","name","exports"],"sources":["../src/ProviderError.ts"],"sourcesContent":["export class ProviderError extends Error {\n constructor(method: string) {\n super(`${method} must be used within a KameleoonProvider`);\n this.name = 'ProviderError';\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,aAAa,SAASC,KAAK,CAAC;EACvCC,WAAWA,CAACC,MAAc,EAAE;IAC1B,KAAK,CAAE,GAAEA,MAAO,0CAAyC,CAAC;IAC1D,IAAI,CAACC,IAAI,GAAG,eAAe;EAC7B;AACF;AAACC,OAAA,CAAAL,aAAA,GAAAA,aAAA"}
package/dist/constants.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.DEFAULT_VARIATION_ID = void 0;
4
- exports.DEFAULT_VARIATION_ID = 0;
7
+ const DEFAULT_VARIATION_ID = 0;
8
+ exports.DEFAULT_VARIATION_ID = DEFAULT_VARIATION_ID;
5
9
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["DEFAULT_VARIATION_ID","exports"],"sources":["../src/constants.ts"],"sourcesContent":["export const DEFAULT_VARIATION_ID = 0;\n"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAG,CAAC;AAACC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA"}
@@ -1,38 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.BrowserEventSourceConstructor = void 0;
4
- var BrowserEventSourceConstructor = /** @class */ (function () {
5
- function BrowserEventSourceConstructor() {
6
- }
7
- BrowserEventSourceConstructor.prototype.initialize = function (url) {
8
- return new ExternalEventSource(url);
9
- };
10
- return BrowserEventSourceConstructor;
11
- }());
12
- exports.BrowserEventSourceConstructor = BrowserEventSourceConstructor;
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
+ class BrowserEventSourceConstructor {
11
+ initialize(url) {
12
+ return new ExternalEventSource(url);
13
+ }
14
+ }
15
+
13
16
  // --- Note ---
14
17
  // - `EventSource` has no dedicated tests because same browser instance
15
18
  // is tested thoroughly inside core and would just duplicate tests
16
19
  // - Moreover we would have to import some unexposed details like constructed url
17
20
  // or the `eventType` from the core
18
- var ExternalEventSource = /** @class */ (function () {
19
- function ExternalEventSource(url) {
20
- var eventSource = new EventSource(url);
21
- this.eventSource = eventSource;
22
- }
23
- ExternalEventSource.prototype.open = function (_a) {
24
- var siteCode = _a.siteCode, eventType = _a.eventType, onEvent = _a.onEvent;
25
- this.eventSource.addEventListener(eventType, function (message) {
26
- var event = JSON.parse(message.data);
27
- var eventSiteCode = event.siteCode, ts = event.ts;
28
- if (siteCode === eventSiteCode) {
29
- onEvent(ts);
30
- }
31
- });
32
- };
33
- ExternalEventSource.prototype.close = function () {
34
- this.eventSource.close();
35
- };
36
- return ExternalEventSource;
37
- }());
21
+ exports.BrowserEventSourceConstructor = BrowserEventSourceConstructor;
22
+ class ExternalEventSource {
23
+ constructor(url) {
24
+ _defineProperty(this, "eventSource", void 0);
25
+ const eventSource = new EventSource(url);
26
+ this.eventSource = eventSource;
27
+ }
28
+ open({
29
+ siteCode,
30
+ eventType,
31
+ onEvent
32
+ }) {
33
+ this.eventSource.addEventListener(eventType, message => {
34
+ const event = JSON.parse(message.data);
35
+ const {
36
+ siteCode: eventSiteCode,
37
+ ts
38
+ } = event;
39
+ if (siteCode === eventSiteCode) {
40
+ onEvent(ts);
41
+ }
42
+ });
43
+ }
44
+ close() {
45
+ this.eventSource.close();
46
+ }
47
+ }
38
48
  //# sourceMappingURL=browserEventSource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browserEventSource.js","sourceRoot":"","sources":["../../src/eventSource/browserEventSource.ts"],"names":[],"mappings":";;;AAOA;IAAA;IAMA,CAAC;IAHQ,kDAAU,GAAjB,UAAkB,GAAW;QAC3B,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IACH,oCAAC;AAAD,CAAC,AAND,IAMC;AANY,sEAA6B;AAQ1C,eAAe;AACf,uEAAuE;AACvE,kEAAkE;AAClE,iFAAiF;AACjF,mCAAmC;AACnC;IAGE,6BAAY,GAAW;QACrB,IAAM,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,kCAAI,GAAX,UAAY,EAIoB;YAH9B,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,OAAO,aAAA;QAEP,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAC,OAAO;YACnD,IAAM,KAAK,GAAsB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClD,IAAU,aAAa,GAAS,KAAK,SAAd,EAAE,EAAE,GAAK,KAAK,GAAV,CAAW;YAE9C,IAAI,QAAQ,KAAK,aAAa,EAAE;gBAC9B,OAAO,CAAC,EAAE,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,mCAAK,GAAZ;QACE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IACH,0BAAC;AAAD,CAAC,AA3BD,IA2BC"}
1
+ {"version":3,"file":"browserEventSource.js","names":["BrowserEventSourceConstructor","initialize","url","ExternalEventSource","exports","constructor","_defineProperty","eventSource","EventSource","open","siteCode","eventType","onEvent","addEventListener","message","event","JSON","parse","data","eventSiteCode","ts","close"],"sources":["../../src/eventSource/browserEventSource.ts"],"sourcesContent":["import {\n RealTimeEventType,\n IExternalEventSource,\n EventSourceOpenParametersType,\n IExternalEventSourceConstructor,\n} from '@kameleoon/javascript-sdk-core';\n\nexport class BrowserEventSourceConstructor\n implements IExternalEventSourceConstructor\n{\n public initialize(url: string): IExternalEventSource {\n return new ExternalEventSource(url);\n }\n}\n\n// --- Note ---\n// - `EventSource` has no dedicated tests because same browser instance\n// is tested thoroughly inside core and would just duplicate tests\n// - Moreover we would have to import some unexposed details like constructed url\n// or the `eventType` from the core\nclass ExternalEventSource implements IExternalEventSource {\n private eventSource: EventSource;\n\n constructor(url: string) {\n const eventSource = new EventSource(url);\n\n this.eventSource = eventSource;\n }\n\n public open({\n siteCode,\n eventType,\n onEvent,\n }: EventSourceOpenParametersType): void {\n this.eventSource.addEventListener(eventType, (message) => {\n const event: RealTimeEventType = JSON.parse(message.data);\n const { siteCode: eventSiteCode, ts } = event;\n\n if (siteCode === eventSiteCode) {\n onEvent(ts);\n }\n });\n }\n\n public close() {\n this.eventSource.close();\n }\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,6BAA6B,CAE1C;EACSC,UAAUA,CAACC,GAAW,EAAwB;IACnD,OAAO,IAAIC,mBAAmB,CAACD,GAAG,CAAC;EACrC;AACF;;AAEA;AACA;AACA;AACA;AACA;AAAAE,OAAA,CAAAJ,6BAAA,GAAAA,6BAAA;AACA,MAAMG,mBAAmB,CAAiC;EAGxDE,WAAWA,CAACH,GAAW,EAAE;IAAAI,eAAA;IACvB,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAACN,GAAG,CAAC;IAExC,IAAI,CAACK,WAAW,GAAGA,WAAW;EAChC;EAEOE,IAAIA,CAAC;IACVC,QAAQ;IACRC,SAAS;IACTC;EAC6B,CAAC,EAAQ;IACtC,IAAI,CAACL,WAAW,CAACM,gBAAgB,CAACF,SAAS,EAAGG,OAAO,IAAK;MACxD,MAAMC,KAAwB,GAAGC,IAAI,CAACC,KAAK,CAACH,OAAO,CAACI,IAAI,CAAC;MACzD,MAAM;QAAER,QAAQ,EAAES,aAAa;QAAEC;MAAG,CAAC,GAAGL,KAAK;MAE7C,IAAIL,QAAQ,KAAKS,aAAa,EAAE;QAC9BP,OAAO,CAACQ,EAAE,CAAC;MACb;IACF,CAAC,CAAC;EACJ;EAEOC,KAAKA,CAAA,EAAG;IACb,IAAI,CAACd,WAAW,CAACc,KAAK,EAAE;EAC1B;AACF"}
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NativeEventSourceConstructor = exports.BrowserEventSourceConstructor = void 0;
4
- var browserEventSource_1 = require("./browserEventSource");
5
- Object.defineProperty(exports, "BrowserEventSourceConstructor", { enumerable: true, get: function () { return browserEventSource_1.BrowserEventSourceConstructor; } });
6
- var nativeEventSource_1 = require("./nativeEventSource");
7
- Object.defineProperty(exports, "NativeEventSourceConstructor", { enumerable: true, get: function () { return nativeEventSource_1.NativeEventSourceConstructor; } });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BrowserEventSourceConstructor", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _browserEventSource.BrowserEventSourceConstructor;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "NativeEventSourceConstructor", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _nativeEventSource.NativeEventSourceConstructor;
16
+ }
17
+ });
18
+ var _browserEventSource = require("./browserEventSource");
19
+ var _nativeEventSource = require("./nativeEventSource");
8
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eventSource/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqE;AAA5D,mIAAA,6BAA6B,OAAA;AACtC,yDAAmE;AAA1D,iIAAA,4BAA4B,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_browserEventSource","require","_nativeEventSource"],"sources":["../../src/eventSource/index.ts"],"sourcesContent":["export { BrowserEventSourceConstructor } from './browserEventSource';\nexport { NativeEventSourceConstructor } from './nativeEventSource';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA"}
@@ -1,39 +1,46 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
6
  exports.NativeEventSourceConstructor = void 0;
7
- var react_native_event_source_1 = __importDefault(require("react-native-event-source"));
8
- var NativeEventSourceConstructor = /** @class */ (function () {
9
- function NativeEventSourceConstructor() {
10
- }
11
- NativeEventSourceConstructor.prototype.initialize = function (url) {
12
- return new ExternalEventSource(url);
13
- };
14
- return NativeEventSourceConstructor;
15
- }());
7
+ var _reactNativeEventSource = _interopRequireDefault(require("react-native-event-source"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ class NativeEventSourceConstructor {
13
+ initialize(url) {
14
+ return new ExternalEventSource(url);
15
+ }
16
+ }
16
17
  exports.NativeEventSourceConstructor = NativeEventSourceConstructor;
17
- var ExternalEventSource = /** @class */ (function () {
18
- function ExternalEventSource(url) {
19
- var eventSource = new react_native_event_source_1.default(url);
20
- this.eventSource = eventSource;
21
- }
22
- ExternalEventSource.prototype.open = function (_a) {
23
- var siteCode = _a.siteCode, eventType = _a.eventType, onEvent = _a.onEvent;
24
- this.eventSource.addEventListener(eventType, function (message) {
25
- if (message.data) {
26
- var event_1 = JSON.parse(message.data);
27
- var eventSiteCode = event_1.siteCode, ts = event_1.ts;
28
- if (siteCode === eventSiteCode) {
29
- onEvent(ts);
30
- }
31
- }
32
- });
33
- };
34
- ExternalEventSource.prototype.close = function () {
35
- this.eventSource.close();
36
- };
37
- return ExternalEventSource;
38
- }());
18
+ class ExternalEventSource {
19
+ constructor(url) {
20
+ _defineProperty(this, "eventSource", void 0);
21
+ const eventSource = new _reactNativeEventSource.default(url);
22
+ this.eventSource = eventSource;
23
+ }
24
+ open({
25
+ siteCode,
26
+ eventType,
27
+ onEvent
28
+ }) {
29
+ this.eventSource.addEventListener(eventType, message => {
30
+ if (message.data) {
31
+ const event = JSON.parse(message.data);
32
+ const {
33
+ siteCode: eventSiteCode,
34
+ ts
35
+ } = event;
36
+ if (siteCode === eventSiteCode) {
37
+ onEvent(ts);
38
+ }
39
+ }
40
+ });
41
+ }
42
+ close() {
43
+ this.eventSource.close();
44
+ }
45
+ }
39
46
  //# sourceMappingURL=nativeEventSource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeEventSource.js","sourceRoot":"","sources":["../../src/eventSource/nativeEventSource.ts"],"names":[],"mappings":";;;;;;AAAA,wFAAoD;AAQpD;IAAA;IAMA,CAAC;IAHQ,iDAAU,GAAjB,UAAkB,GAAW;QAC3B,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IACH,mCAAC;AAAD,CAAC,AAND,IAMC;AANY,oEAA4B;AAQzC;IAGE,6BAAY,GAAW;QACrB,IAAM,WAAW,GAAG,IAAI,mCAAW,CAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,kCAAI,GAAX,UAAY,EAIoB;YAH9B,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,OAAO,aAAA;QAEP,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAC,OAAqB;YACjE,IAAI,OAAO,CAAC,IAAI,EAAE;gBAChB,IAAM,OAAK,GAAsB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAClD,IAAU,aAAa,GAAS,OAAK,SAAd,EAAE,EAAE,GAAK,OAAK,GAAV,CAAW;gBAE9C,IAAI,QAAQ,KAAK,aAAa,EAAE;oBAC9B,OAAO,CAAC,EAAE,CAAC,CAAC;iBACb;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,mCAAK,GAAZ;QACE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IACH,0BAAC;AAAD,CAAC,AA7BD,IA6BC"}
1
+ {"version":3,"file":"nativeEventSource.js","names":["_reactNativeEventSource","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","NativeEventSourceConstructor","initialize","url","ExternalEventSource","exports","constructor","eventSource","EventSource","open","siteCode","eventType","onEvent","addEventListener","message","data","event","JSON","parse","eventSiteCode","ts","close"],"sources":["../../src/eventSource/nativeEventSource.ts"],"sourcesContent":["import EventSource from 'react-native-event-source';\nimport {\n RealTimeEventType,\n IExternalEventSource,\n EventSourceOpenParametersType,\n IExternalEventSourceConstructor,\n} from '@kameleoon/javascript-sdk-core';\n\nexport class NativeEventSourceConstructor\n implements IExternalEventSourceConstructor\n{\n public initialize(url: string): IExternalEventSource {\n return new ExternalEventSource(url);\n }\n}\n\nclass ExternalEventSource implements IExternalEventSource {\n private eventSource: EventSource;\n\n constructor(url: string) {\n const eventSource = new EventSource(url);\n\n this.eventSource = eventSource;\n }\n\n public open({\n siteCode,\n eventType,\n onEvent,\n }: EventSourceOpenParametersType): void {\n this.eventSource.addEventListener(eventType, (message: MessageEvent) => {\n if (message.data) {\n const event: RealTimeEventType = JSON.parse(message.data);\n const { siteCode: eventSiteCode, ts } = event;\n\n if (siteCode === eventSiteCode) {\n onEvent(ts);\n }\n }\n });\n }\n\n public close() {\n this.eventSource.close();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAQ7C,MAAMU,4BAA4B,CAEzC;EACSC,UAAUA,CAACC,GAAW,EAAwB;IACnD,OAAO,IAAIC,mBAAmB,CAACD,GAAG,CAAC;EACrC;AACF;AAACE,OAAA,CAAAJ,4BAAA,GAAAA,4BAAA;AAED,MAAMG,mBAAmB,CAAiC;EAGxDE,WAAWA,CAACH,GAAW,EAAE;IAAAxB,eAAA;IACvB,MAAM4B,WAAW,GAAG,IAAIC,+BAAW,CAACL,GAAG,CAAC;IAExC,IAAI,CAACI,WAAW,GAAGA,WAAW;EAChC;EAEOE,IAAIA,CAAC;IACVC,QAAQ;IACRC,SAAS;IACTC;EAC6B,CAAC,EAAQ;IACtC,IAAI,CAACL,WAAW,CAACM,gBAAgB,CAACF,SAAS,EAAGG,OAAqB,IAAK;MACtE,IAAIA,OAAO,CAACC,IAAI,EAAE;QAChB,MAAMC,KAAwB,GAAGC,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACC,IAAI,CAAC;QACzD,MAAM;UAAEL,QAAQ,EAAES,aAAa;UAAEC;QAAG,CAAC,GAAGJ,KAAK;QAE7C,IAAIN,QAAQ,KAAKS,aAAa,EAAE;UAC9BP,OAAO,CAACQ,EAAE,CAAC;QACb;MACF;IACF,CAAC,CAAC;EACJ;EAEOC,KAAKA,CAAA,EAAG;IACb,IAAI,CAACd,WAAW,CAACc,KAAK,EAAE;EAC1B;AACF"}