@flagship.io/react-sdk 3.0.7 → 3.0.10-alpha.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/README.md +27 -27
- package/dist/FlagshipContext.js +15 -22
- package/dist/index.node.js +1 -1531
- package/dist/index.node.js.map +1 -1
- package/package.json +101 -100
- package/dist/index.browser.js +0 -8673
- package/dist/index.browser.js.map +0 -1
package/dist/index.node.js
CHANGED
|
@@ -1,1532 +1,2 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
/******/ var __webpack_modules__ = ({
|
|
4
|
-
|
|
5
|
-
/***/ "./src/Flag.ts":
|
|
6
|
-
/*!*********************!*\
|
|
7
|
-
!*** ./src/Flag.ts ***!
|
|
8
|
-
\*********************/
|
|
9
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
10
|
-
|
|
11
|
-
__webpack_require__.r(__webpack_exports__);
|
|
12
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
-
/* harmony export */ "Flag": () => (/* binding */ Flag)
|
|
14
|
-
/* harmony export */ });
|
|
15
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "core-js/modules/es.object.to-string.js");
|
|
16
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
17
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.promise.js */ "core-js/modules/es.promise.js");
|
|
18
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
19
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @flagship.io/js-sdk */ "@flagship.io/js-sdk");
|
|
20
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2__);
|
|
21
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
22
|
-
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ "./src/utils.tsx");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
-
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
-
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
31
|
-
|
|
32
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var Flag = /*#__PURE__*/function () {
|
|
38
|
-
function Flag(defaultValue, key, flagsData) {
|
|
39
|
-
_classCallCheck(this, Flag);
|
|
40
|
-
|
|
41
|
-
_defineProperty(this, "defaultValue", void 0);
|
|
42
|
-
|
|
43
|
-
_defineProperty(this, "flagsData", void 0);
|
|
44
|
-
|
|
45
|
-
_defineProperty(this, "key", void 0);
|
|
46
|
-
|
|
47
|
-
_defineProperty(this, "flag", void 0);
|
|
48
|
-
|
|
49
|
-
if (!flagsData) {
|
|
50
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logWarn)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), _constants__WEBPACK_IMPORTED_MODULE_3__.noVisitorMessage, 'GetFlag');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.defaultValue = defaultValue;
|
|
54
|
-
this.key = key;
|
|
55
|
-
this.flag = flagsData === null || flagsData === void 0 ? void 0 : flagsData.get(key);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_createClass(Flag, [{
|
|
59
|
-
key: "NotSameType",
|
|
60
|
-
value: function NotSameType() {
|
|
61
|
-
var _this$flag;
|
|
62
|
-
|
|
63
|
-
return this.defaultValue !== null && this.defaultValue !== undefined && !(0,_utils__WEBPACK_IMPORTED_MODULE_4__.hasSameType)((_this$flag = this.flag) === null || _this$flag === void 0 ? void 0 : _this$flag.value, this.defaultValue);
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "getValue",
|
|
67
|
-
value: function getValue() {
|
|
68
|
-
if (!this.flag) {
|
|
69
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logWarn)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), _constants__WEBPACK_IMPORTED_MODULE_3__.noVisitorMessage, 'getValue');
|
|
70
|
-
return this.defaultValue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (this.NotSameType()) {
|
|
74
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logInfo)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), (0,_utils__WEBPACK_IMPORTED_MODULE_4__.sprintf)(_constants__WEBPACK_IMPORTED_MODULE_3__.GET_FLAG_CAST_ERROR, this.key), 'getValue');
|
|
75
|
-
return this.defaultValue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return this.flag.value;
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "exists",
|
|
82
|
-
value: function exists() {
|
|
83
|
-
if (!this.flag) {
|
|
84
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logWarn)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), _constants__WEBPACK_IMPORTED_MODULE_3__.noVisitorMessage, 'exists');
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return !!(this.flag.campaignId && this.flag.variationId && this.flag.variationGroupId);
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "userExposed",
|
|
92
|
-
value: function userExposed() {
|
|
93
|
-
if (!this.flag) {
|
|
94
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logWarn)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), _constants__WEBPACK_IMPORTED_MODULE_3__.noVisitorMessage, 'userExposed');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return Promise.resolve();
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "metadata",
|
|
101
|
-
get: function get() {
|
|
102
|
-
var functionName = 'metadata';
|
|
103
|
-
|
|
104
|
-
if (!this.flag) {
|
|
105
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logWarn)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), _constants__WEBPACK_IMPORTED_MODULE_3__.noVisitorMessage, functionName);
|
|
106
|
-
return _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2__.FlagMetadata.Empty();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (this.NotSameType()) {
|
|
110
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_4__.logInfo)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2___default().getConfig(), (0,_utils__WEBPACK_IMPORTED_MODULE_4__.sprintf)(_constants__WEBPACK_IMPORTED_MODULE_3__.GET_METADATA_CAST_ERROR, this.key), functionName);
|
|
111
|
-
return _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2__.FlagMetadata.Empty();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return new _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_2__.FlagMetadata({
|
|
115
|
-
campaignId: this.flag.campaignId,
|
|
116
|
-
variationGroupId: this.flag.variationGroupId,
|
|
117
|
-
variationId: this.flag.variationId,
|
|
118
|
-
isReference: !!this.flag.isReference,
|
|
119
|
-
campaignType: this.flag.campaignType,
|
|
120
|
-
slug: this.flag.slug
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}]);
|
|
124
|
-
|
|
125
|
-
return Flag;
|
|
126
|
-
}();
|
|
127
|
-
|
|
128
|
-
/***/ }),
|
|
129
|
-
|
|
130
|
-
/***/ "./src/FlagshipContext.tsx":
|
|
131
|
-
/*!*********************************!*\
|
|
132
|
-
!*** ./src/FlagshipContext.tsx ***!
|
|
133
|
-
\*********************************/
|
|
134
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
135
|
-
|
|
136
|
-
__webpack_require__.r(__webpack_exports__);
|
|
137
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
138
|
-
/* harmony export */ "FlagshipContext": () => (/* binding */ FlagshipContext),
|
|
139
|
-
/* harmony export */ "FlagshipProvider": () => (/* binding */ FlagshipProvider)
|
|
140
|
-
/* harmony export */ });
|
|
141
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "core-js/modules/es.array.iterator.js");
|
|
142
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
143
|
-
/* harmony import */ var core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.map.js */ "core-js/modules/es.map.js");
|
|
144
|
-
/* harmony import */ var core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
145
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "core-js/modules/es.object.to-string.js");
|
|
146
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
147
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "core-js/modules/es.string.iterator.js");
|
|
148
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
149
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "core-js/modules/web.dom-collections.iterator.js");
|
|
150
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4__);
|
|
151
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "core-js/modules/web.dom-collections.for-each.js");
|
|
152
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
153
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ "core-js/modules/es.object.keys.js");
|
|
154
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6__);
|
|
155
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "core-js/modules/es.symbol.js");
|
|
156
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_7__);
|
|
157
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.array.filter.js */ "core-js/modules/es.array.filter.js");
|
|
158
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_8__);
|
|
159
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ "core-js/modules/es.object.get-own-property-descriptor.js");
|
|
160
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_9__);
|
|
161
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptors.js */ "core-js/modules/es.object.get-own-property-descriptors.js");
|
|
162
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_10__);
|
|
163
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "core-js/modules/es.symbol.description.js");
|
|
164
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11__);
|
|
165
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "core-js/modules/es.symbol.iterator.js");
|
|
166
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12__);
|
|
167
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "core-js/modules/es.array.slice.js");
|
|
168
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_13__);
|
|
169
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "core-js/modules/es.function.name.js");
|
|
170
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_14__);
|
|
171
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "core-js/modules/es.array.from.js");
|
|
172
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_15__);
|
|
173
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! react */ "react");
|
|
174
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_16__);
|
|
175
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @flagship.io/js-sdk */ "@flagship.io/js-sdk");
|
|
176
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__);
|
|
177
|
-
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./utils */ "./src/utils.tsx");
|
|
178
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
179
|
-
|
|
180
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
181
|
-
|
|
182
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
183
|
-
|
|
184
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
185
|
-
|
|
186
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
187
|
-
|
|
188
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
208
|
-
|
|
209
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
210
|
-
|
|
211
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
212
|
-
|
|
213
|
-
// eslint-disable-next-line no-use-before-define
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
var initStat = {
|
|
218
|
-
status: {
|
|
219
|
-
isLoading: true,
|
|
220
|
-
isSdkReady: false
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
var FlagshipContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_16__.createContext)({
|
|
224
|
-
state: _objectSpread({}, initStat)
|
|
225
|
-
});
|
|
226
|
-
var FlagshipProvider = function FlagshipProvider(_ref) {
|
|
227
|
-
var children = _ref.children,
|
|
228
|
-
fetchNow = _ref.fetchNow,
|
|
229
|
-
envId = _ref.envId,
|
|
230
|
-
apiKey = _ref.apiKey,
|
|
231
|
-
decisionMode = _ref.decisionMode,
|
|
232
|
-
decisionApiUrl = _ref.decisionApiUrl,
|
|
233
|
-
timeout = _ref.timeout,
|
|
234
|
-
logLevel = _ref.logLevel,
|
|
235
|
-
statusChangedCallback = _ref.statusChangedCallback,
|
|
236
|
-
logManager = _ref.logManager,
|
|
237
|
-
pollingInterval = _ref.pollingInterval,
|
|
238
|
-
visitorData = _ref.visitorData,
|
|
239
|
-
onInitStart = _ref.onInitStart,
|
|
240
|
-
onInitDone = _ref.onInitDone,
|
|
241
|
-
onBucketingSuccess = _ref.onBucketingSuccess,
|
|
242
|
-
onBucketingFail = _ref.onBucketingFail,
|
|
243
|
-
loadingComponent = _ref.loadingComponent,
|
|
244
|
-
onBucketingUpdated = _ref.onBucketingUpdated,
|
|
245
|
-
onUpdate = _ref.onUpdate,
|
|
246
|
-
enableClientCache = _ref.enableClientCache,
|
|
247
|
-
initialBucketing = _ref.initialBucketing,
|
|
248
|
-
initialCampaigns = _ref.initialCampaigns,
|
|
249
|
-
initialModifications = _ref.initialModifications,
|
|
250
|
-
initialFlagsData = _ref.initialFlagsData,
|
|
251
|
-
fetchFlagsOnBucketingUpdated = _ref.fetchFlagsOnBucketingUpdated,
|
|
252
|
-
activateDeduplicationTime = _ref.activateDeduplicationTime,
|
|
253
|
-
hitDeduplicationTime = _ref.hitDeduplicationTime,
|
|
254
|
-
visitorCacheImplementation = _ref.visitorCacheImplementation,
|
|
255
|
-
hitCacheImplementation = _ref.hitCacheImplementation,
|
|
256
|
-
disableCache = _ref.disableCache,
|
|
257
|
-
language = _ref.language;
|
|
258
|
-
var modifications = new Map();
|
|
259
|
-
|
|
260
|
-
if (initialFlagsData && initialFlagsData.forEach) {
|
|
261
|
-
initialFlagsData.forEach(function (flag) {
|
|
262
|
-
modifications.set(flag.key, flag);
|
|
263
|
-
});
|
|
264
|
-
} else if (initialModifications && initialModifications.forEach) {
|
|
265
|
-
initialModifications.forEach(function (modification) {
|
|
266
|
-
modifications.set(modification.key, modification);
|
|
267
|
-
});
|
|
268
|
-
} else if (initialCampaigns) {
|
|
269
|
-
modifications = (0,_utils__WEBPACK_IMPORTED_MODULE_18__.getModificationsFromCampaigns)(initialCampaigns);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_16__.useState)(_objectSpread(_objectSpread({}, initStat), {}, {
|
|
273
|
-
modifications: modifications
|
|
274
|
-
})),
|
|
275
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
276
|
-
state = _useState2[0],
|
|
277
|
-
setState = _useState2[1];
|
|
278
|
-
|
|
279
|
-
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_16__.useState)(),
|
|
280
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
281
|
-
lastModified = _useState4[0],
|
|
282
|
-
setLastModified = _useState4[1];
|
|
283
|
-
|
|
284
|
-
var stateRef = (0,react__WEBPACK_IMPORTED_MODULE_16__.useRef)();
|
|
285
|
-
stateRef.current = state;
|
|
286
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_18__.useNonInitialEffect)(function () {
|
|
287
|
-
if (fetchFlagsOnBucketingUpdated) {
|
|
288
|
-
var _state$visitor;
|
|
289
|
-
|
|
290
|
-
(_state$visitor = state.visitor) === null || _state$visitor === void 0 ? void 0 : _state$visitor.fetchFlags();
|
|
291
|
-
}
|
|
292
|
-
}, [lastModified]);
|
|
293
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_18__.useNonInitialEffect)(function () {
|
|
294
|
-
createVisitor(true);
|
|
295
|
-
}, [JSON.stringify(visitorData)]);
|
|
296
|
-
(0,react__WEBPACK_IMPORTED_MODULE_16__.useEffect)(function () {
|
|
297
|
-
initSdk();
|
|
298
|
-
}, [envId, apiKey, decisionMode]);
|
|
299
|
-
|
|
300
|
-
function initializeState(param) {
|
|
301
|
-
var newStatus = {
|
|
302
|
-
isSdkReady: param.isSdkReady,
|
|
303
|
-
isLoading: param.isLoading,
|
|
304
|
-
isVisitorDefined: !!param.fsVisitor,
|
|
305
|
-
lastRefresh: new Date().toISOString()
|
|
306
|
-
};
|
|
307
|
-
setState(function (currentState) {
|
|
308
|
-
if (!currentState.status.firstInitSuccess) {
|
|
309
|
-
newStatus.firstInitSuccess = new Date().toISOString();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return _objectSpread(_objectSpread({}, currentState), {}, {
|
|
313
|
-
visitor: param.fsVisitor,
|
|
314
|
-
modifications: param.fsVisitor.modifications,
|
|
315
|
-
config: _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.getConfig(),
|
|
316
|
-
status: _objectSpread(_objectSpread({}, currentState.status), newStatus)
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
return newStatus;
|
|
320
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var onVisitorReady = function onVisitorReady(fsVisitor, error) {
|
|
324
|
-
if (error) {
|
|
325
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_18__.logError)(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.getConfig(), error.message || error, 'onReady');
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
var newStatus = initializeState({
|
|
330
|
-
fsVisitor: fsVisitor,
|
|
331
|
-
isSdkReady: true,
|
|
332
|
-
isLoading: false
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
if (onUpdate) {
|
|
336
|
-
onUpdate({
|
|
337
|
-
fsModifications: fsVisitor.modifications,
|
|
338
|
-
config: _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.getConfig(),
|
|
339
|
-
status: newStatus
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
var createVisitor = function createVisitor() {
|
|
345
|
-
var fetchFlags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
346
|
-
|
|
347
|
-
if (!visitorData) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
var fsVisitor = _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.newVisitor({
|
|
352
|
-
visitorId: visitorData.id,
|
|
353
|
-
context: visitorData.context,
|
|
354
|
-
isAuthenticated: visitorData.isAuthenticated,
|
|
355
|
-
hasConsented: visitorData.hasConsented,
|
|
356
|
-
initialCampaigns: initialCampaigns,
|
|
357
|
-
initialModifications: initialModifications,
|
|
358
|
-
initialFlagsData: initialFlagsData
|
|
359
|
-
});
|
|
360
|
-
fsVisitor === null || fsVisitor === void 0 ? void 0 : fsVisitor.on('ready', function (error) {
|
|
361
|
-
onVisitorReady(fsVisitor, error);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
if (!fetchNow && fsVisitor && !fetchFlags) {
|
|
365
|
-
initializeState({
|
|
366
|
-
fsVisitor: fsVisitor,
|
|
367
|
-
isSdkReady: true,
|
|
368
|
-
isLoading: false
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (fetchFlags && !fetchNow) {
|
|
373
|
-
fsVisitor === null || fsVisitor === void 0 ? void 0 : fsVisitor.fetchFlags();
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
var statusChanged = function statusChanged(status) {
|
|
378
|
-
if (statusChangedCallback) {
|
|
379
|
-
statusChangedCallback(status);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
switch (status) {
|
|
383
|
-
case _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.FlagshipStatus.STARTING:
|
|
384
|
-
if (status === _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.FlagshipStatus.STARTING && onInitStart) {
|
|
385
|
-
onInitStart();
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
break;
|
|
389
|
-
|
|
390
|
-
case _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.FlagshipStatus.READY_PANIC_ON:
|
|
391
|
-
case _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.FlagshipStatus.READY:
|
|
392
|
-
if (onInitDone) {
|
|
393
|
-
onInitDone();
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
createVisitor();
|
|
397
|
-
break;
|
|
398
|
-
|
|
399
|
-
case _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.FlagshipStatus.NOT_INITIALIZED:
|
|
400
|
-
setState(function (prev) {
|
|
401
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
402
|
-
config: _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.getConfig()
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
var onBucketingLastModified = function onBucketingLastModified(lastUpdate) {
|
|
410
|
-
if (onBucketingUpdated) {
|
|
411
|
-
onBucketingUpdated(lastUpdate);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
setLastModified(lastUpdate);
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
var initSdk = function initSdk() {
|
|
418
|
-
_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_17__.Flagship.start(envId, apiKey, {
|
|
419
|
-
decisionMode: decisionMode,
|
|
420
|
-
fetchNow: fetchNow,
|
|
421
|
-
timeout: timeout,
|
|
422
|
-
logLevel: logLevel,
|
|
423
|
-
statusChangedCallback: statusChanged,
|
|
424
|
-
logManager: logManager,
|
|
425
|
-
pollingInterval: pollingInterval,
|
|
426
|
-
onBucketingFail: onBucketingFail,
|
|
427
|
-
onBucketingSuccess: onBucketingSuccess,
|
|
428
|
-
enableClientCache: enableClientCache,
|
|
429
|
-
decisionApiUrl: decisionApiUrl,
|
|
430
|
-
onBucketingUpdated: onBucketingLastModified,
|
|
431
|
-
initialBucketing: initialBucketing,
|
|
432
|
-
activateDeduplicationTime: activateDeduplicationTime,
|
|
433
|
-
hitDeduplicationTime: hitDeduplicationTime,
|
|
434
|
-
visitorCacheImplementation: visitorCacheImplementation,
|
|
435
|
-
hitCacheImplementation: hitCacheImplementation,
|
|
436
|
-
disableCache: disableCache,
|
|
437
|
-
language: language
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
var handleDisplay = function handleDisplay() {
|
|
442
|
-
var isFirstInit = !state.visitor;
|
|
443
|
-
|
|
444
|
-
if (state.status.isLoading && loadingComponent && isFirstInit && fetchNow) {
|
|
445
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_16___default().createElement((react__WEBPACK_IMPORTED_MODULE_16___default().Fragment), null, loadingComponent);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_16___default().createElement((react__WEBPACK_IMPORTED_MODULE_16___default().Fragment), null, children);
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_16___default().createElement(FlagshipContext.Provider, {
|
|
452
|
-
value: {
|
|
453
|
-
state: state,
|
|
454
|
-
setState: setState
|
|
455
|
-
}
|
|
456
|
-
}, handleDisplay());
|
|
457
|
-
};
|
|
458
|
-
FlagshipProvider.defaultProps = {
|
|
459
|
-
activateDeduplicationTime: 2,
|
|
460
|
-
hitDeduplicationTime: 2,
|
|
461
|
-
fetchNow: true,
|
|
462
|
-
language: 1
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
/***/ }),
|
|
466
|
-
|
|
467
|
-
/***/ "./src/FlagshipHooks.tsx":
|
|
468
|
-
/*!*******************************!*\
|
|
469
|
-
!*** ./src/FlagshipHooks.tsx ***!
|
|
470
|
-
\*******************************/
|
|
471
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
472
|
-
|
|
473
|
-
__webpack_require__.r(__webpack_exports__);
|
|
474
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
475
|
-
/* harmony export */ "useFsModifications": () => (/* binding */ useFsModifications),
|
|
476
|
-
/* harmony export */ "useFsModification": () => (/* binding */ useFsModification),
|
|
477
|
-
/* harmony export */ "useFsModificationInfo": () => (/* binding */ useFsModificationInfo),
|
|
478
|
-
/* harmony export */ "useFsFlag": () => (/* binding */ useFsFlag),
|
|
479
|
-
/* harmony export */ "useFsActivate": () => (/* binding */ useFsActivate),
|
|
480
|
-
/* harmony export */ "useFlagship": () => (/* binding */ useFlagship)
|
|
481
|
-
/* harmony export */ });
|
|
482
|
-
/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! regenerator-runtime/runtime.js */ "regenerator-runtime/runtime.js");
|
|
483
|
-
/* harmony import */ var regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(regenerator_runtime_runtime_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
484
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "core-js/modules/web.dom-collections.for-each.js");
|
|
485
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
486
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "core-js/modules/es.object.to-string.js");
|
|
487
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
488
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.promise.js */ "core-js/modules/es.promise.js");
|
|
489
|
-
/* harmony import */ var core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_promise_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
490
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "core-js/modules/es.array.from.js");
|
|
491
|
-
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_4__);
|
|
492
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "core-js/modules/es.string.iterator.js");
|
|
493
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
494
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "core-js/modules/es.symbol.js");
|
|
495
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_6__);
|
|
496
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "core-js/modules/es.symbol.description.js");
|
|
497
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_7__);
|
|
498
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "core-js/modules/es.symbol.iterator.js");
|
|
499
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_8__);
|
|
500
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "core-js/modules/es.array.iterator.js");
|
|
501
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_9__);
|
|
502
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "core-js/modules/web.dom-collections.iterator.js");
|
|
503
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_10__);
|
|
504
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "core-js/modules/es.array.slice.js");
|
|
505
|
-
/* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_11__);
|
|
506
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "core-js/modules/es.function.name.js");
|
|
507
|
-
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_12__);
|
|
508
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ "core-js/modules/es.object.keys.js");
|
|
509
|
-
/* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_13__);
|
|
510
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.array.filter.js */ "core-js/modules/es.array.filter.js");
|
|
511
|
-
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_14__);
|
|
512
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ "core-js/modules/es.object.get-own-property-descriptor.js");
|
|
513
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_15__);
|
|
514
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptors.js */ "core-js/modules/es.object.get-own-property-descriptors.js");
|
|
515
|
-
/* harmony import */ var core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptors_js__WEBPACK_IMPORTED_MODULE_16__);
|
|
516
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! react */ "react");
|
|
517
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_17__);
|
|
518
|
-
/* harmony import */ var _FlagshipContext__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./FlagshipContext */ "./src/FlagshipContext.tsx");
|
|
519
|
-
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./utils */ "./src/utils.tsx");
|
|
520
|
-
/* harmony import */ var _Flag__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Flag */ "./src/Flag.ts");
|
|
521
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
522
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
523
|
-
|
|
524
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
525
|
-
|
|
526
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
527
|
-
|
|
528
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
529
|
-
|
|
530
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
531
|
-
|
|
532
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
533
|
-
|
|
534
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
535
|
-
|
|
536
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
537
|
-
|
|
538
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
543
|
-
|
|
544
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
var checkType = function checkType(value, defaultValue) {
|
|
572
|
-
return _typeof(value) === 'object' && _typeof(defaultValue) === 'object' && Array.isArray(value) === Array.isArray(defaultValue) || _typeof(value) === _typeof(defaultValue);
|
|
573
|
-
};
|
|
574
|
-
|
|
575
|
-
var fsModificationsSync = function fsModificationsSync(args) {
|
|
576
|
-
var visitor = args.visitor,
|
|
577
|
-
params = args.params,
|
|
578
|
-
activateAll = args.activateAll,
|
|
579
|
-
state = args.state,
|
|
580
|
-
functionName = args.functionName,
|
|
581
|
-
config = args.config;
|
|
582
|
-
|
|
583
|
-
if (visitor) {
|
|
584
|
-
return visitor.getModificationsSync(params, activateAll);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
var check = !state.status.isSdkReady && !!state.modifications && state.modifications.size > 0;
|
|
588
|
-
var flags = {};
|
|
589
|
-
|
|
590
|
-
if (check) {
|
|
591
|
-
params.forEach(function (item) {
|
|
592
|
-
var _state$modifications;
|
|
593
|
-
|
|
594
|
-
var modification = (_state$modifications = state.modifications) === null || _state$modifications === void 0 ? void 0 : _state$modifications.get(item.key);
|
|
595
|
-
|
|
596
|
-
if (modification && checkType(modification === null || modification === void 0 ? void 0 : modification.value, item.defaultValue)) {
|
|
597
|
-
flags[item.key] = modification.value;
|
|
598
|
-
} else {
|
|
599
|
-
flags[item.key] = item.defaultValue;
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
return flags;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorDefault, functionName);
|
|
606
|
-
params.forEach(function (item) {
|
|
607
|
-
flags[item.key] = item.defaultValue;
|
|
608
|
-
});
|
|
609
|
-
return flags;
|
|
610
|
-
};
|
|
611
|
-
/**
|
|
612
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
613
|
-
* @deprecated use useFsFlag instead
|
|
614
|
-
*/
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
var useFsModifications = function useFsModifications(params, activateAll) {
|
|
618
|
-
var _useContext = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext),
|
|
619
|
-
state = _useContext.state;
|
|
620
|
-
|
|
621
|
-
var visitor = state.visitor,
|
|
622
|
-
config = state.config;
|
|
623
|
-
var functionName = 'useFsModifications';
|
|
624
|
-
return fsModificationsSync({
|
|
625
|
-
functionName: functionName,
|
|
626
|
-
state: state,
|
|
627
|
-
visitor: visitor,
|
|
628
|
-
config: config,
|
|
629
|
-
params: params,
|
|
630
|
-
activateAll: activateAll
|
|
631
|
-
});
|
|
632
|
-
};
|
|
633
|
-
/**
|
|
634
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
635
|
-
* @deprecated use useFsFlag instead
|
|
636
|
-
*/
|
|
637
|
-
|
|
638
|
-
var useFsModification = function useFsModification(params) {
|
|
639
|
-
var _state$modifications2;
|
|
640
|
-
|
|
641
|
-
var _useContext2 = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext),
|
|
642
|
-
state = _useContext2.state;
|
|
643
|
-
|
|
644
|
-
var visitor = state.visitor,
|
|
645
|
-
config = state.config;
|
|
646
|
-
var functionName = 'useFsModifications';
|
|
647
|
-
|
|
648
|
-
if (visitor) {
|
|
649
|
-
return visitor.getModificationSync(params);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
var modification = (_state$modifications2 = state.modifications) === null || _state$modifications2 === void 0 ? void 0 : _state$modifications2.get(params.key);
|
|
653
|
-
|
|
654
|
-
if (!state.status.isSdkReady && modification && checkType(modification === null || modification === void 0 ? void 0 : modification.value, params.defaultValue)) {
|
|
655
|
-
return modification.value;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorDefault, functionName);
|
|
659
|
-
return params.defaultValue;
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
var fsModificationInfoSync = function fsModificationInfoSync(args) {
|
|
663
|
-
var _state$modifications3;
|
|
664
|
-
|
|
665
|
-
var key = args.key,
|
|
666
|
-
visitor = args.visitor,
|
|
667
|
-
state = args.state;
|
|
668
|
-
|
|
669
|
-
if (visitor) {
|
|
670
|
-
return visitor.getModificationInfoSync(key);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
var modification = (_state$modifications3 = state.modifications) === null || _state$modifications3 === void 0 ? void 0 : _state$modifications3.get(key);
|
|
674
|
-
|
|
675
|
-
if (!state.status.isSdkReady && modification) {
|
|
676
|
-
return modification;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
return null;
|
|
680
|
-
};
|
|
681
|
-
/**
|
|
682
|
-
* Get the campaign modification information value matching the given key.
|
|
683
|
-
* @param {string} key key which identify the modification.
|
|
684
|
-
* @deprecated use useFsFlag instead
|
|
685
|
-
*/
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
var useFsModificationInfo = function useFsModificationInfo(key) {
|
|
689
|
-
var _useContext3 = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext),
|
|
690
|
-
state = _useContext3.state;
|
|
691
|
-
|
|
692
|
-
var visitor = state.visitor;
|
|
693
|
-
return fsModificationInfoSync({
|
|
694
|
-
key: key,
|
|
695
|
-
state: state,
|
|
696
|
-
visitor: visitor
|
|
697
|
-
});
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
var fsActivate = /*#__PURE__*/function () {
|
|
701
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(params, functionName, visitor, config) {
|
|
702
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
703
|
-
while (1) {
|
|
704
|
-
switch (_context.prev = _context.next) {
|
|
705
|
-
case 0:
|
|
706
|
-
_context.prev = 0;
|
|
707
|
-
|
|
708
|
-
if (visitor) {
|
|
709
|
-
_context.next = 4;
|
|
710
|
-
break;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
714
|
-
return _context.abrupt("return");
|
|
715
|
-
|
|
716
|
-
case 4:
|
|
717
|
-
_context.next = 6;
|
|
718
|
-
return visitor.activateModifications(params);
|
|
719
|
-
|
|
720
|
-
case 6:
|
|
721
|
-
_context.next = 11;
|
|
722
|
-
break;
|
|
723
|
-
|
|
724
|
-
case 8:
|
|
725
|
-
_context.prev = 8;
|
|
726
|
-
_context.t0 = _context["catch"](0);
|
|
727
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _context.t0.message || _context.t0, functionName);
|
|
728
|
-
|
|
729
|
-
case 11:
|
|
730
|
-
case "end":
|
|
731
|
-
return _context.stop();
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
}, _callee, null, [[0, 8]]);
|
|
735
|
-
}));
|
|
736
|
-
|
|
737
|
-
return function fsActivate(_x, _x2, _x3, _x4) {
|
|
738
|
-
return _ref.apply(this, arguments);
|
|
739
|
-
};
|
|
740
|
-
}();
|
|
741
|
-
/**
|
|
742
|
-
* This hook returns a flag object by its key. If no flag match the given key an empty flag will be returned.
|
|
743
|
-
* @param key
|
|
744
|
-
* @param defaultValue
|
|
745
|
-
* @returns
|
|
746
|
-
*/
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
var useFsFlag = function useFsFlag(key, defaultValue) {
|
|
750
|
-
var _useContext4 = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext),
|
|
751
|
-
state = _useContext4.state;
|
|
752
|
-
|
|
753
|
-
var visitor = state.visitor;
|
|
754
|
-
|
|
755
|
-
if (!visitor) {
|
|
756
|
-
return new _Flag__WEBPACK_IMPORTED_MODULE_20__.Flag(defaultValue, key, state.modifications);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
return visitor.getFlag(key, defaultValue);
|
|
760
|
-
};
|
|
761
|
-
/**
|
|
762
|
-
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
763
|
-
* @param params
|
|
764
|
-
* @deprecated use useFsFlag instead
|
|
765
|
-
* @returns
|
|
766
|
-
*/
|
|
767
|
-
|
|
768
|
-
var useFsActivate = /*#__PURE__*/function () {
|
|
769
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(params) {
|
|
770
|
-
var _useContext5, state, visitor, config, functionName;
|
|
771
|
-
|
|
772
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
773
|
-
while (1) {
|
|
774
|
-
switch (_context2.prev = _context2.next) {
|
|
775
|
-
case 0:
|
|
776
|
-
_useContext5 = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext), state = _useContext5.state;
|
|
777
|
-
visitor = state.visitor, config = state.config;
|
|
778
|
-
functionName = 'useFsModifications';
|
|
779
|
-
_context2.next = 5;
|
|
780
|
-
return fsActivate(params, functionName, visitor, config);
|
|
781
|
-
|
|
782
|
-
case 5:
|
|
783
|
-
case "end":
|
|
784
|
-
return _context2.stop();
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}, _callee2);
|
|
788
|
-
}));
|
|
789
|
-
|
|
790
|
-
return function useFsActivate(_x5) {
|
|
791
|
-
return _ref2.apply(this, arguments);
|
|
792
|
-
};
|
|
793
|
-
}();
|
|
794
|
-
var useFlagship = function useFlagship() {
|
|
795
|
-
var _useContext6 = (0,react__WEBPACK_IMPORTED_MODULE_17__.useContext)(_FlagshipContext__WEBPACK_IMPORTED_MODULE_18__.FlagshipContext),
|
|
796
|
-
state = _useContext6.state;
|
|
797
|
-
|
|
798
|
-
var visitor = state.visitor,
|
|
799
|
-
config = state.config;
|
|
800
|
-
|
|
801
|
-
var fsUpdateContext = function fsUpdateContext(context) {
|
|
802
|
-
var functionName = 'updateContext';
|
|
803
|
-
|
|
804
|
-
if (!visitor) {
|
|
805
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
visitor.clearContext();
|
|
810
|
-
visitor.updateContext(context);
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
var fsClearContext = function fsClearContext() {
|
|
814
|
-
var functionName = 'cleanContext';
|
|
815
|
-
|
|
816
|
-
if (!visitor) {
|
|
817
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
visitor.clearContext();
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
var fsAuthenticate = function fsAuthenticate(visitorId) {
|
|
825
|
-
var functionName = 'authenticate';
|
|
826
|
-
|
|
827
|
-
if (!visitor) {
|
|
828
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
visitor.authenticate(visitorId);
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
var fsUnauthenticate = function fsUnauthenticate() {
|
|
836
|
-
var functionName = 'unauthenticate';
|
|
837
|
-
|
|
838
|
-
if (!visitor) {
|
|
839
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
visitor.unauthenticate();
|
|
844
|
-
};
|
|
845
|
-
/**
|
|
846
|
-
* Send a Hit to Flagship servers for reporting.
|
|
847
|
-
*/
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
var fsSendHit = function fsSendHit(hit) {
|
|
851
|
-
var functionName = 'sendHit';
|
|
852
|
-
|
|
853
|
-
if (!visitor) {
|
|
854
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
855
|
-
return Promise.resolve();
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
return visitor.sendHit(hit);
|
|
859
|
-
};
|
|
860
|
-
/**
|
|
861
|
-
* Send a Hit to Flagship servers for reporting.
|
|
862
|
-
*/
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
var fsSendHits = function fsSendHits(hit) {
|
|
866
|
-
var functionName = 'sendHits';
|
|
867
|
-
|
|
868
|
-
if (!visitor) {
|
|
869
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logError)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, functionName);
|
|
870
|
-
return Promise.resolve();
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
return visitor.sendHits(hit);
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
var modifications = visitor === null || visitor === void 0 ? void 0 : visitor.getModificationsArray();
|
|
877
|
-
|
|
878
|
-
if (!state.status.isSdkReady && state.modifications) {
|
|
879
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
880
|
-
modifications = Array.from(state.modifications, function (_ref3) {
|
|
881
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
882
|
-
_key = _ref4[0],
|
|
883
|
-
item = _ref4[1];
|
|
884
|
-
|
|
885
|
-
return item;
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
var activateModification = /*#__PURE__*/function () {
|
|
890
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(params) {
|
|
891
|
-
var functionName;
|
|
892
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
893
|
-
while (1) {
|
|
894
|
-
switch (_context3.prev = _context3.next) {
|
|
895
|
-
case 0:
|
|
896
|
-
functionName = 'activateModification';
|
|
897
|
-
_context3.next = 3;
|
|
898
|
-
return fsActivate(params, functionName, visitor, config);
|
|
899
|
-
|
|
900
|
-
case 3:
|
|
901
|
-
case "end":
|
|
902
|
-
return _context3.stop();
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}, _callee3);
|
|
906
|
-
}));
|
|
907
|
-
|
|
908
|
-
return function activateModification(_x6) {
|
|
909
|
-
return _ref5.apply(this, arguments);
|
|
910
|
-
};
|
|
911
|
-
}();
|
|
912
|
-
|
|
913
|
-
var synchronizeModifications = /*#__PURE__*/function () {
|
|
914
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
915
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
916
|
-
while (1) {
|
|
917
|
-
switch (_context4.prev = _context4.next) {
|
|
918
|
-
case 0:
|
|
919
|
-
if (visitor) {
|
|
920
|
-
_context4.next = 3;
|
|
921
|
-
break;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, 'synchronizeModifications');
|
|
925
|
-
return _context4.abrupt("return");
|
|
926
|
-
|
|
927
|
-
case 3:
|
|
928
|
-
_context4.next = 5;
|
|
929
|
-
return visitor.synchronizeModifications();
|
|
930
|
-
|
|
931
|
-
case 5:
|
|
932
|
-
case "end":
|
|
933
|
-
return _context4.stop();
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
}, _callee4);
|
|
937
|
-
}));
|
|
938
|
-
|
|
939
|
-
return function synchronizeModifications() {
|
|
940
|
-
return _ref6.apply(this, arguments);
|
|
941
|
-
};
|
|
942
|
-
}();
|
|
943
|
-
|
|
944
|
-
var getModifications = function getModifications(params, activateAll) {
|
|
945
|
-
var functionName = 'getModifications';
|
|
946
|
-
return fsModificationsSync({
|
|
947
|
-
functionName: functionName,
|
|
948
|
-
state: state,
|
|
949
|
-
visitor: visitor,
|
|
950
|
-
config: config,
|
|
951
|
-
params: params,
|
|
952
|
-
activateAll: activateAll
|
|
953
|
-
});
|
|
954
|
-
};
|
|
955
|
-
|
|
956
|
-
var getModificationInfo = function getModificationInfo(key) {
|
|
957
|
-
return fsModificationInfoSync({
|
|
958
|
-
key: key,
|
|
959
|
-
state: state,
|
|
960
|
-
visitor: visitor
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
function getFlag(key, defaultValue) {
|
|
965
|
-
if (!visitor) {
|
|
966
|
-
return new _Flag__WEBPACK_IMPORTED_MODULE_20__.Flag(defaultValue, key, state.modifications);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
return visitor.getFlag(key, defaultValue);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
function fetchFlags() {
|
|
973
|
-
if (!visitor) {
|
|
974
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, 'fetchFlags');
|
|
975
|
-
return Promise.resolve();
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
return visitor.fetchFlags();
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
function setConsent(hasConsented) {
|
|
982
|
-
if (!visitor) {
|
|
983
|
-
(0,_utils__WEBPACK_IMPORTED_MODULE_19__.logWarn)(config, _constants__WEBPACK_IMPORTED_MODULE_21__.noVisitorMessage, 'setConsent');
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
visitor.setConsent(hasConsented);
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
return {
|
|
991
|
-
visitorId: visitor === null || visitor === void 0 ? void 0 : visitor.visitorId,
|
|
992
|
-
anonymousId: visitor === null || visitor === void 0 ? void 0 : visitor.anonymousId,
|
|
993
|
-
context: _objectSpread({}, visitor === null || visitor === void 0 ? void 0 : visitor.context),
|
|
994
|
-
hasConsented: visitor === null || visitor === void 0 ? void 0 : visitor.hasConsented,
|
|
995
|
-
setConsent: setConsent,
|
|
996
|
-
updateContext: fsUpdateContext,
|
|
997
|
-
clearContext: fsClearContext,
|
|
998
|
-
authenticate: fsAuthenticate,
|
|
999
|
-
unauthenticate: fsUnauthenticate,
|
|
1000
|
-
status: state.status,
|
|
1001
|
-
activateModification: activateModification,
|
|
1002
|
-
synchronizeModifications: synchronizeModifications,
|
|
1003
|
-
getModifications: getModifications,
|
|
1004
|
-
modifications: modifications || [],
|
|
1005
|
-
flagsData: (visitor === null || visitor === void 0 ? void 0 : visitor.getFlagsDataArray()) || [],
|
|
1006
|
-
getModificationInfo: getModificationInfo,
|
|
1007
|
-
hit: {
|
|
1008
|
-
send: fsSendHit,
|
|
1009
|
-
sendMultiple: fsSendHits
|
|
1010
|
-
},
|
|
1011
|
-
getFlag: getFlag,
|
|
1012
|
-
fetchFlags: fetchFlags
|
|
1013
|
-
};
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
/***/ }),
|
|
1017
|
-
|
|
1018
|
-
/***/ "./src/constants.ts":
|
|
1019
|
-
/*!**************************!*\
|
|
1020
|
-
!*** ./src/constants.ts ***!
|
|
1021
|
-
\**************************/
|
|
1022
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1023
|
-
|
|
1024
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1025
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1026
|
-
/* harmony export */ "noVisitorMessage": () => (/* binding */ noVisitorMessage),
|
|
1027
|
-
/* harmony export */ "noVisitorDefault": () => (/* binding */ noVisitorDefault),
|
|
1028
|
-
/* harmony export */ "GET_FLAG_CAST_ERROR": () => (/* binding */ GET_FLAG_CAST_ERROR),
|
|
1029
|
-
/* harmony export */ "GET_METADATA_CAST_ERROR": () => (/* binding */ GET_METADATA_CAST_ERROR)
|
|
1030
|
-
/* harmony export */ });
|
|
1031
|
-
var noVisitorMessage = 'flagship Visitor not initialized.';
|
|
1032
|
-
var noVisitorDefault = 'fsVisitor not initialized, returns default value';
|
|
1033
|
-
var GET_FLAG_CAST_ERROR = 'Flag for key {0} has a different type. Default value is returned.';
|
|
1034
|
-
var GET_METADATA_CAST_ERROR = 'Flag for key {0} has a different type with defaultValue, an empty metadata object is returned';
|
|
1035
|
-
|
|
1036
|
-
/***/ }),
|
|
1037
|
-
|
|
1038
|
-
/***/ "./src/utils.tsx":
|
|
1039
|
-
/*!***********************!*\
|
|
1040
|
-
!*** ./src/utils.tsx ***!
|
|
1041
|
-
\***********************/
|
|
1042
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1043
|
-
|
|
1044
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1045
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1046
|
-
/* harmony export */ "logError": () => (/* binding */ logError),
|
|
1047
|
-
/* harmony export */ "logInfo": () => (/* binding */ logInfo),
|
|
1048
|
-
/* harmony export */ "logWarn": () => (/* binding */ logWarn),
|
|
1049
|
-
/* harmony export */ "getModificationsFromCampaigns": () => (/* binding */ getModificationsFromCampaigns),
|
|
1050
|
-
/* harmony export */ "uuidV4": () => (/* binding */ uuidV4),
|
|
1051
|
-
/* harmony export */ "useNonInitialEffect": () => (/* binding */ useNonInitialEffect),
|
|
1052
|
-
/* harmony export */ "hasSameType": () => (/* binding */ hasSameType),
|
|
1053
|
-
/* harmony export */ "sprintf": () => (/* binding */ sprintf)
|
|
1054
|
-
/* harmony export */ });
|
|
1055
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "core-js/modules/es.array.iterator.js");
|
|
1056
|
-
/* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
1057
|
-
/* harmony import */ var core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.map.js */ "core-js/modules/es.map.js");
|
|
1058
|
-
/* harmony import */ var core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_map_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
1059
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "core-js/modules/es.object.to-string.js");
|
|
1060
|
-
/* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
1061
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "core-js/modules/es.string.iterator.js");
|
|
1062
|
-
/* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
1063
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "core-js/modules/web.dom-collections.iterator.js");
|
|
1064
|
-
/* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_4__);
|
|
1065
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "core-js/modules/web.dom-collections.for-each.js");
|
|
1066
|
-
/* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
1067
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "core-js/modules/es.regexp.exec.js");
|
|
1068
|
-
/* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_6__);
|
|
1069
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.string.replace.js */ "core-js/modules/es.string.replace.js");
|
|
1070
|
-
/* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_7__);
|
|
1071
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ "core-js/modules/es.regexp.to-string.js");
|
|
1072
|
-
/* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_8__);
|
|
1073
|
-
/* harmony import */ var core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.regexp.constructor.js */ "core-js/modules/es.regexp.constructor.js");
|
|
1074
|
-
/* harmony import */ var core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_constructor_js__WEBPACK_IMPORTED_MODULE_9__);
|
|
1075
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "core-js/modules/es.symbol.js");
|
|
1076
|
-
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_10__);
|
|
1077
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "core-js/modules/es.symbol.description.js");
|
|
1078
|
-
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_11__);
|
|
1079
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "core-js/modules/es.symbol.iterator.js");
|
|
1080
|
-
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_12__);
|
|
1081
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @flagship.io/js-sdk */ "@flagship.io/js-sdk");
|
|
1082
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13__);
|
|
1083
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! react */ "react");
|
|
1084
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_14__);
|
|
1085
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
function logError(config, message, tag) {
|
|
1103
|
-
if (!config || !config.logManager || typeof config.logManager.error !== 'function' || !config.logLevel || config.logLevel < _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13__.LogLevel.ERROR) {
|
|
1104
|
-
return;
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
config.logManager.error(message, tag);
|
|
1108
|
-
}
|
|
1109
|
-
function logInfo(config, message, tag) {
|
|
1110
|
-
if (!config || !config.logManager || typeof config.logManager.info !== 'function' || !config.logLevel || config.logLevel < _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13__.LogLevel.INFO) {
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
config.logManager.info(message, tag);
|
|
1115
|
-
}
|
|
1116
|
-
function logWarn(config, message, tag) {
|
|
1117
|
-
if (!config || !config.logManager || typeof config.logManager.warning !== 'function' || !config.logLevel || config.logLevel < _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_13__.LogLevel.WARNING) {
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
config.logManager.warning(message, tag);
|
|
1122
|
-
}
|
|
1123
|
-
var getModificationsFromCampaigns = function getModificationsFromCampaigns(campaigns) {
|
|
1124
|
-
var modifications = new Map();
|
|
1125
|
-
|
|
1126
|
-
if (!campaigns || !Array.isArray(campaigns)) {
|
|
1127
|
-
return modifications;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
campaigns.forEach(function (campaign) {
|
|
1131
|
-
var object = campaign.variation.modifications.value;
|
|
1132
|
-
|
|
1133
|
-
for (var key in object) {
|
|
1134
|
-
var value = object[key];
|
|
1135
|
-
modifications.set(key, {
|
|
1136
|
-
key: key,
|
|
1137
|
-
campaignId: campaign.id,
|
|
1138
|
-
variationGroupId: campaign.variationGroupId,
|
|
1139
|
-
variationId: campaign.variation.id,
|
|
1140
|
-
isReference: campaign.variation.reference,
|
|
1141
|
-
value: value
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1145
|
-
return modifications;
|
|
1146
|
-
};
|
|
1147
|
-
function uuidV4() {
|
|
1148
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
|
|
1149
|
-
var rand = Math.random() * 16 | 0;
|
|
1150
|
-
var value = char === 'x' ? rand : rand & 0x3 | 0x8;
|
|
1151
|
-
return value.toString(16);
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
function useNonInitialEffect(effect, deps) {
|
|
1155
|
-
var initialRender = (0,react__WEBPACK_IMPORTED_MODULE_14__.useRef)(true);
|
|
1156
|
-
(0,react__WEBPACK_IMPORTED_MODULE_14__.useEffect)(function () {
|
|
1157
|
-
if (initialRender.current) {
|
|
1158
|
-
initialRender.current = false;
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
if (typeof effect === 'function') {
|
|
1163
|
-
return effect();
|
|
1164
|
-
}
|
|
1165
|
-
}, deps);
|
|
1166
|
-
}
|
|
1167
|
-
function hasSameType(flagValue, defaultValue) {
|
|
1168
|
-
if (_typeof(flagValue) !== _typeof(defaultValue)) {
|
|
1169
|
-
return false;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
if (_typeof(flagValue) === 'object' && _typeof(defaultValue) === 'object' && Array.isArray(flagValue) !== Array.isArray(defaultValue)) {
|
|
1173
|
-
return false;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
return true;
|
|
1177
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1178
|
-
|
|
1179
|
-
function sprintf(format) {
|
|
1180
|
-
var formatted = format;
|
|
1181
|
-
|
|
1182
|
-
for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
|
1183
|
-
var element = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
|
1184
|
-
formatted = formatted.replace(new RegExp("\\{".concat(i, "\\}"), 'g'), element);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
return formatted;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
/***/ }),
|
|
1191
|
-
|
|
1192
|
-
/***/ "@flagship.io/js-sdk":
|
|
1193
|
-
/*!**************************************!*\
|
|
1194
|
-
!*** external "@flagship.io/js-sdk" ***!
|
|
1195
|
-
\**************************************/
|
|
1196
|
-
/***/ ((module) => {
|
|
1197
|
-
|
|
1198
|
-
module.exports = require("@flagship.io/js-sdk");
|
|
1199
|
-
|
|
1200
|
-
/***/ }),
|
|
1201
|
-
|
|
1202
|
-
/***/ "core-js/modules/es.array.filter.js":
|
|
1203
|
-
/*!*****************************************************!*\
|
|
1204
|
-
!*** external "core-js/modules/es.array.filter.js" ***!
|
|
1205
|
-
\*****************************************************/
|
|
1206
|
-
/***/ ((module) => {
|
|
1207
|
-
|
|
1208
|
-
module.exports = require("core-js/modules/es.array.filter.js");
|
|
1209
|
-
|
|
1210
|
-
/***/ }),
|
|
1211
|
-
|
|
1212
|
-
/***/ "core-js/modules/es.array.from.js":
|
|
1213
|
-
/*!***************************************************!*\
|
|
1214
|
-
!*** external "core-js/modules/es.array.from.js" ***!
|
|
1215
|
-
\***************************************************/
|
|
1216
|
-
/***/ ((module) => {
|
|
1217
|
-
|
|
1218
|
-
module.exports = require("core-js/modules/es.array.from.js");
|
|
1219
|
-
|
|
1220
|
-
/***/ }),
|
|
1221
|
-
|
|
1222
|
-
/***/ "core-js/modules/es.array.iterator.js":
|
|
1223
|
-
/*!*******************************************************!*\
|
|
1224
|
-
!*** external "core-js/modules/es.array.iterator.js" ***!
|
|
1225
|
-
\*******************************************************/
|
|
1226
|
-
/***/ ((module) => {
|
|
1227
|
-
|
|
1228
|
-
module.exports = require("core-js/modules/es.array.iterator.js");
|
|
1229
|
-
|
|
1230
|
-
/***/ }),
|
|
1231
|
-
|
|
1232
|
-
/***/ "core-js/modules/es.array.slice.js":
|
|
1233
|
-
/*!****************************************************!*\
|
|
1234
|
-
!*** external "core-js/modules/es.array.slice.js" ***!
|
|
1235
|
-
\****************************************************/
|
|
1236
|
-
/***/ ((module) => {
|
|
1237
|
-
|
|
1238
|
-
module.exports = require("core-js/modules/es.array.slice.js");
|
|
1239
|
-
|
|
1240
|
-
/***/ }),
|
|
1241
|
-
|
|
1242
|
-
/***/ "core-js/modules/es.function.name.js":
|
|
1243
|
-
/*!******************************************************!*\
|
|
1244
|
-
!*** external "core-js/modules/es.function.name.js" ***!
|
|
1245
|
-
\******************************************************/
|
|
1246
|
-
/***/ ((module) => {
|
|
1247
|
-
|
|
1248
|
-
module.exports = require("core-js/modules/es.function.name.js");
|
|
1249
|
-
|
|
1250
|
-
/***/ }),
|
|
1251
|
-
|
|
1252
|
-
/***/ "core-js/modules/es.map.js":
|
|
1253
|
-
/*!********************************************!*\
|
|
1254
|
-
!*** external "core-js/modules/es.map.js" ***!
|
|
1255
|
-
\********************************************/
|
|
1256
|
-
/***/ ((module) => {
|
|
1257
|
-
|
|
1258
|
-
module.exports = require("core-js/modules/es.map.js");
|
|
1259
|
-
|
|
1260
|
-
/***/ }),
|
|
1261
|
-
|
|
1262
|
-
/***/ "core-js/modules/es.object.get-own-property-descriptor.js":
|
|
1263
|
-
/*!***************************************************************************!*\
|
|
1264
|
-
!*** external "core-js/modules/es.object.get-own-property-descriptor.js" ***!
|
|
1265
|
-
\***************************************************************************/
|
|
1266
|
-
/***/ ((module) => {
|
|
1267
|
-
|
|
1268
|
-
module.exports = require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
1269
|
-
|
|
1270
|
-
/***/ }),
|
|
1271
|
-
|
|
1272
|
-
/***/ "core-js/modules/es.object.get-own-property-descriptors.js":
|
|
1273
|
-
/*!****************************************************************************!*\
|
|
1274
|
-
!*** external "core-js/modules/es.object.get-own-property-descriptors.js" ***!
|
|
1275
|
-
\****************************************************************************/
|
|
1276
|
-
/***/ ((module) => {
|
|
1277
|
-
|
|
1278
|
-
module.exports = require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
1279
|
-
|
|
1280
|
-
/***/ }),
|
|
1281
|
-
|
|
1282
|
-
/***/ "core-js/modules/es.object.keys.js":
|
|
1283
|
-
/*!****************************************************!*\
|
|
1284
|
-
!*** external "core-js/modules/es.object.keys.js" ***!
|
|
1285
|
-
\****************************************************/
|
|
1286
|
-
/***/ ((module) => {
|
|
1287
|
-
|
|
1288
|
-
module.exports = require("core-js/modules/es.object.keys.js");
|
|
1289
|
-
|
|
1290
|
-
/***/ }),
|
|
1291
|
-
|
|
1292
|
-
/***/ "core-js/modules/es.object.to-string.js":
|
|
1293
|
-
/*!*********************************************************!*\
|
|
1294
|
-
!*** external "core-js/modules/es.object.to-string.js" ***!
|
|
1295
|
-
\*********************************************************/
|
|
1296
|
-
/***/ ((module) => {
|
|
1297
|
-
|
|
1298
|
-
module.exports = require("core-js/modules/es.object.to-string.js");
|
|
1299
|
-
|
|
1300
|
-
/***/ }),
|
|
1301
|
-
|
|
1302
|
-
/***/ "core-js/modules/es.promise.js":
|
|
1303
|
-
/*!************************************************!*\
|
|
1304
|
-
!*** external "core-js/modules/es.promise.js" ***!
|
|
1305
|
-
\************************************************/
|
|
1306
|
-
/***/ ((module) => {
|
|
1307
|
-
|
|
1308
|
-
module.exports = require("core-js/modules/es.promise.js");
|
|
1309
|
-
|
|
1310
|
-
/***/ }),
|
|
1311
|
-
|
|
1312
|
-
/***/ "core-js/modules/es.regexp.constructor.js":
|
|
1313
|
-
/*!***********************************************************!*\
|
|
1314
|
-
!*** external "core-js/modules/es.regexp.constructor.js" ***!
|
|
1315
|
-
\***********************************************************/
|
|
1316
|
-
/***/ ((module) => {
|
|
1317
|
-
|
|
1318
|
-
module.exports = require("core-js/modules/es.regexp.constructor.js");
|
|
1319
|
-
|
|
1320
|
-
/***/ }),
|
|
1321
|
-
|
|
1322
|
-
/***/ "core-js/modules/es.regexp.exec.js":
|
|
1323
|
-
/*!****************************************************!*\
|
|
1324
|
-
!*** external "core-js/modules/es.regexp.exec.js" ***!
|
|
1325
|
-
\****************************************************/
|
|
1326
|
-
/***/ ((module) => {
|
|
1327
|
-
|
|
1328
|
-
module.exports = require("core-js/modules/es.regexp.exec.js");
|
|
1329
|
-
|
|
1330
|
-
/***/ }),
|
|
1331
|
-
|
|
1332
|
-
/***/ "core-js/modules/es.regexp.to-string.js":
|
|
1333
|
-
/*!*********************************************************!*\
|
|
1334
|
-
!*** external "core-js/modules/es.regexp.to-string.js" ***!
|
|
1335
|
-
\*********************************************************/
|
|
1336
|
-
/***/ ((module) => {
|
|
1337
|
-
|
|
1338
|
-
module.exports = require("core-js/modules/es.regexp.to-string.js");
|
|
1339
|
-
|
|
1340
|
-
/***/ }),
|
|
1341
|
-
|
|
1342
|
-
/***/ "core-js/modules/es.string.iterator.js":
|
|
1343
|
-
/*!********************************************************!*\
|
|
1344
|
-
!*** external "core-js/modules/es.string.iterator.js" ***!
|
|
1345
|
-
\********************************************************/
|
|
1346
|
-
/***/ ((module) => {
|
|
1347
|
-
|
|
1348
|
-
module.exports = require("core-js/modules/es.string.iterator.js");
|
|
1349
|
-
|
|
1350
|
-
/***/ }),
|
|
1351
|
-
|
|
1352
|
-
/***/ "core-js/modules/es.string.replace.js":
|
|
1353
|
-
/*!*******************************************************!*\
|
|
1354
|
-
!*** external "core-js/modules/es.string.replace.js" ***!
|
|
1355
|
-
\*******************************************************/
|
|
1356
|
-
/***/ ((module) => {
|
|
1357
|
-
|
|
1358
|
-
module.exports = require("core-js/modules/es.string.replace.js");
|
|
1359
|
-
|
|
1360
|
-
/***/ }),
|
|
1361
|
-
|
|
1362
|
-
/***/ "core-js/modules/es.symbol.description.js":
|
|
1363
|
-
/*!***********************************************************!*\
|
|
1364
|
-
!*** external "core-js/modules/es.symbol.description.js" ***!
|
|
1365
|
-
\***********************************************************/
|
|
1366
|
-
/***/ ((module) => {
|
|
1367
|
-
|
|
1368
|
-
module.exports = require("core-js/modules/es.symbol.description.js");
|
|
1369
|
-
|
|
1370
|
-
/***/ }),
|
|
1371
|
-
|
|
1372
|
-
/***/ "core-js/modules/es.symbol.iterator.js":
|
|
1373
|
-
/*!********************************************************!*\
|
|
1374
|
-
!*** external "core-js/modules/es.symbol.iterator.js" ***!
|
|
1375
|
-
\********************************************************/
|
|
1376
|
-
/***/ ((module) => {
|
|
1377
|
-
|
|
1378
|
-
module.exports = require("core-js/modules/es.symbol.iterator.js");
|
|
1379
|
-
|
|
1380
|
-
/***/ }),
|
|
1381
|
-
|
|
1382
|
-
/***/ "core-js/modules/es.symbol.js":
|
|
1383
|
-
/*!***********************************************!*\
|
|
1384
|
-
!*** external "core-js/modules/es.symbol.js" ***!
|
|
1385
|
-
\***********************************************/
|
|
1386
|
-
/***/ ((module) => {
|
|
1387
|
-
|
|
1388
|
-
module.exports = require("core-js/modules/es.symbol.js");
|
|
1389
|
-
|
|
1390
|
-
/***/ }),
|
|
1391
|
-
|
|
1392
|
-
/***/ "core-js/modules/web.dom-collections.for-each.js":
|
|
1393
|
-
/*!******************************************************************!*\
|
|
1394
|
-
!*** external "core-js/modules/web.dom-collections.for-each.js" ***!
|
|
1395
|
-
\******************************************************************/
|
|
1396
|
-
/***/ ((module) => {
|
|
1397
|
-
|
|
1398
|
-
module.exports = require("core-js/modules/web.dom-collections.for-each.js");
|
|
1399
|
-
|
|
1400
|
-
/***/ }),
|
|
1401
|
-
|
|
1402
|
-
/***/ "core-js/modules/web.dom-collections.iterator.js":
|
|
1403
|
-
/*!******************************************************************!*\
|
|
1404
|
-
!*** external "core-js/modules/web.dom-collections.iterator.js" ***!
|
|
1405
|
-
\******************************************************************/
|
|
1406
|
-
/***/ ((module) => {
|
|
1407
|
-
|
|
1408
|
-
module.exports = require("core-js/modules/web.dom-collections.iterator.js");
|
|
1409
|
-
|
|
1410
|
-
/***/ }),
|
|
1411
|
-
|
|
1412
|
-
/***/ "react":
|
|
1413
|
-
/*!************************!*\
|
|
1414
|
-
!*** external "react" ***!
|
|
1415
|
-
\************************/
|
|
1416
|
-
/***/ ((module) => {
|
|
1417
|
-
|
|
1418
|
-
module.exports = require("react");
|
|
1419
|
-
|
|
1420
|
-
/***/ }),
|
|
1421
|
-
|
|
1422
|
-
/***/ "regenerator-runtime/runtime.js":
|
|
1423
|
-
/*!*************************************************!*\
|
|
1424
|
-
!*** external "regenerator-runtime/runtime.js" ***!
|
|
1425
|
-
\*************************************************/
|
|
1426
|
-
/***/ ((module) => {
|
|
1427
|
-
|
|
1428
|
-
module.exports = require("regenerator-runtime/runtime.js");
|
|
1429
|
-
|
|
1430
|
-
/***/ })
|
|
1431
|
-
|
|
1432
|
-
/******/ });
|
|
1433
|
-
/************************************************************************/
|
|
1434
|
-
/******/ // The module cache
|
|
1435
|
-
/******/ var __webpack_module_cache__ = {};
|
|
1436
|
-
/******/
|
|
1437
|
-
/******/ // The require function
|
|
1438
|
-
/******/ function __webpack_require__(moduleId) {
|
|
1439
|
-
/******/ // Check if module is in cache
|
|
1440
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
1441
|
-
/******/ if (cachedModule !== undefined) {
|
|
1442
|
-
/******/ return cachedModule.exports;
|
|
1443
|
-
/******/ }
|
|
1444
|
-
/******/ // Create a new module (and put it into the cache)
|
|
1445
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
1446
|
-
/******/ // no module.id needed
|
|
1447
|
-
/******/ // no module.loaded needed
|
|
1448
|
-
/******/ exports: {}
|
|
1449
|
-
/******/ };
|
|
1450
|
-
/******/
|
|
1451
|
-
/******/ // Execute the module function
|
|
1452
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
1453
|
-
/******/
|
|
1454
|
-
/******/ // Return the exports of the module
|
|
1455
|
-
/******/ return module.exports;
|
|
1456
|
-
/******/ }
|
|
1457
|
-
/******/
|
|
1458
|
-
/************************************************************************/
|
|
1459
|
-
/******/ /* webpack/runtime/compat get default export */
|
|
1460
|
-
/******/ (() => {
|
|
1461
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
1462
|
-
/******/ __webpack_require__.n = (module) => {
|
|
1463
|
-
/******/ var getter = module && module.__esModule ?
|
|
1464
|
-
/******/ () => (module['default']) :
|
|
1465
|
-
/******/ () => (module);
|
|
1466
|
-
/******/ __webpack_require__.d(getter, { a: getter });
|
|
1467
|
-
/******/ return getter;
|
|
1468
|
-
/******/ };
|
|
1469
|
-
/******/ })();
|
|
1470
|
-
/******/
|
|
1471
|
-
/******/ /* webpack/runtime/define property getters */
|
|
1472
|
-
/******/ (() => {
|
|
1473
|
-
/******/ // define getter functions for harmony exports
|
|
1474
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
1475
|
-
/******/ for(var key in definition) {
|
|
1476
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
1477
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
1478
|
-
/******/ }
|
|
1479
|
-
/******/ }
|
|
1480
|
-
/******/ };
|
|
1481
|
-
/******/ })();
|
|
1482
|
-
/******/
|
|
1483
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
1484
|
-
/******/ (() => {
|
|
1485
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
1486
|
-
/******/ })();
|
|
1487
|
-
/******/
|
|
1488
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
1489
|
-
/******/ (() => {
|
|
1490
|
-
/******/ // define __esModule on exports
|
|
1491
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
1492
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
1493
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1494
|
-
/******/ }
|
|
1495
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
1496
|
-
/******/ };
|
|
1497
|
-
/******/ })();
|
|
1498
|
-
/******/
|
|
1499
|
-
/************************************************************************/
|
|
1500
|
-
var __webpack_exports__ = {};
|
|
1501
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
1502
|
-
(() => {
|
|
1503
|
-
/*!***********************!*\
|
|
1504
|
-
!*** ./src/index.tsx ***!
|
|
1505
|
-
\***********************/
|
|
1506
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1507
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1508
|
-
/* harmony export */ "FlagshipContext": () => (/* reexport safe */ _FlagshipContext__WEBPACK_IMPORTED_MODULE_0__.FlagshipContext),
|
|
1509
|
-
/* harmony export */ "FlagshipProvider": () => (/* reexport safe */ _FlagshipContext__WEBPACK_IMPORTED_MODULE_0__.FlagshipProvider),
|
|
1510
|
-
/* harmony export */ "useFlagship": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFlagship),
|
|
1511
|
-
/* harmony export */ "useFsActivate": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFsActivate),
|
|
1512
|
-
/* harmony export */ "useFsFlag": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFsFlag),
|
|
1513
|
-
/* harmony export */ "useFsModification": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFsModification),
|
|
1514
|
-
/* harmony export */ "useFsModificationInfo": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFsModificationInfo),
|
|
1515
|
-
/* harmony export */ "useFsModifications": () => (/* reexport safe */ _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__.useFsModifications)
|
|
1516
|
-
/* harmony export */ });
|
|
1517
|
-
/* harmony import */ var _FlagshipContext__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FlagshipContext */ "./src/FlagshipContext.tsx");
|
|
1518
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @flagship.io/js-sdk */ "@flagship.io/js-sdk");
|
|
1519
|
-
/* harmony import */ var _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_1__);
|
|
1520
|
-
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
1521
|
-
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_1__) if(["default","FlagshipContext","FlagshipProvider"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _flagship_io_js_sdk__WEBPACK_IMPORTED_MODULE_1__[__WEBPACK_IMPORT_KEY__]
|
|
1522
|
-
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
1523
|
-
/* harmony import */ var _FlagshipHooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FlagshipHooks */ "./src/FlagshipHooks.tsx");
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
})();
|
|
1528
|
-
|
|
1529
|
-
module.exports = __webpack_exports__;
|
|
1530
|
-
/******/ })()
|
|
1531
|
-
;
|
|
1
|
+
(()=>{"use strict";var t={161:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Flag=void 0,i(117);var a=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var i=s(e);if(i&&i.has(t))return i.get(t);var a={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in t)if("default"!==n&&Object.prototype.hasOwnProperty.call(t,n)){var r=o?Object.getOwnPropertyDescriptor(t,n):null;r&&(r.get||r.set)?Object.defineProperty(a,n,r):a[n]=t[n]}return a.default=t,i&&i.set(t,a),a}(i(4)),o=i(147),n=i(370);function s(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(s=function(t){return t?i:e})(t)}function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}e.Flag=class{constructor(t,e,i){r(this,"defaultValue",void 0),r(this,"flagsData",void 0),r(this,"key",void 0),r(this,"flag",void 0),i||(0,n.logWarn)(a.default.getConfig(),o.noVisitorMessage,"GetFlag"),this.defaultValue=t,this.key=e,this.flag=null==i?void 0:i.get(e)}NotSameType(){var t;return null!==this.defaultValue&&void 0!==this.defaultValue&&!(0,n.hasSameType)(null===(t=this.flag)||void 0===t?void 0:t.value,this.defaultValue)}getValue(){return this.flag?this.NotSameType()?((0,n.logInfo)(a.default.getConfig(),(0,n.sprintf)(o.GET_FLAG_CAST_ERROR,this.key),"getValue"),this.defaultValue):this.flag.value:((0,n.logWarn)(a.default.getConfig(),o.noVisitorMessage,"getValue"),this.defaultValue)}exists(){return this.flag?!!(this.flag.campaignId&&this.flag.variationId&&this.flag.variationGroupId):((0,n.logWarn)(a.default.getConfig(),o.noVisitorMessage,"exists"),!1)}userExposed(){return this.flag||(0,n.logWarn)(a.default.getConfig(),o.noVisitorMessage,"userExposed"),Promise.resolve()}get metadata(){const t="metadata";return this.flag?this.NotSameType()?((0,n.logInfo)(a.default.getConfig(),(0,n.sprintf)(o.GET_METADATA_CAST_ERROR,this.key),t),a.FlagMetadata.Empty()):new a.FlagMetadata({campaignId:this.flag.campaignId,variationGroupId:this.flag.variationGroupId,variationId:this.flag.variationId,isReference:!!this.flag.isReference,campaignType:this.flag.campaignType,slug:this.flag.slug}):((0,n.logWarn)(a.default.getConfig(),o.noVisitorMessage,t),a.FlagMetadata.Empty())}}},821:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FlagshipProvider=e.FlagshipContext=void 0;var a=function(t,e){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var i=s(e);if(i&&i.has(t))return i.get(t);var a={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in t)if("default"!==n&&Object.prototype.hasOwnProperty.call(t,n)){var r=o?Object.getOwnPropertyDescriptor(t,n):null;r&&(r.get||r.set)?Object.defineProperty(a,n,r):a[n]=t[n]}return a.default=t,i&&i.set(t,a),a}(i(689)),o=i(4),n=i(370);function s(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(s=function(t){return t?i:e})(t)}const r={status:{isLoading:!0,isSdkReady:!1}},l=(0,a.createContext)({state:{...r}});e.FlagshipContext=l;const u=({children:t,fetchNow:e,envId:i,apiKey:s,decisionMode:u,visitorData:f,onInitStart:c,onInitDone:g,loadingComponent:d,statusChangedCallback:p,onBucketingUpdated:v,onUpdate:y,initialCampaigns:h,initialModifications:M,initialFlagsData:m,fetchFlagsOnBucketingUpdated:x,...F})=>{let C=new Map;m&&m.forEach?m.forEach((t=>{C.set(t.key,t)})):M&&M.forEach?M.forEach((t=>{C.set(t.key,t)})):h&&(C=(0,n.getModificationsFromCampaigns)(h));const[E,V]=(0,a.useState)({...r,modifications:C}),[A,I]=(0,a.useState)();function k(t){const e={isSdkReady:t.isSdkReady,isLoading:t.isLoading,isVisitorDefined:!!t.fsVisitor,lastRefresh:(new Date).toISOString()};return V((i=>(i.status.firstInitSuccess||(e.firstInitSuccess=(new Date).toISOString()),{...i,visitor:t.fsVisitor,modifications:t.fsVisitor.modifications,config:o.Flagship.getConfig(),status:{...i.status,...e}}))),e}(0,a.useRef)().current=E,(0,n.useNonInitialEffect)((()=>{var t;x&&(null===(t=E.visitor)||void 0===t||t.fetchFlags())}),[A]),(0,n.useNonInitialEffect)((()=>{O(!0)}),[JSON.stringify(f)]),(0,a.useEffect)((()=>{S()}),[i,s,u]);const O=(t=!1)=>{if(!f)return;const i=o.Flagship.newVisitor({visitorId:f.id,context:f.context,isAuthenticated:f.isAuthenticated,hasConsented:f.hasConsented,initialCampaigns:h,initialModifications:M,initialFlagsData:m});null==i||i.on("ready",(t=>{((t,e)=>{if(e)return void(0,n.logError)(o.Flagship.getConfig(),e.message||e,"onReady");const i=k({fsVisitor:t,isSdkReady:!0,isLoading:!1});y&&y({fsModifications:t.modifications,config:o.Flagship.getConfig(),status:i})})(i,t)})),e||!i||t||k({fsVisitor:i,isSdkReady:!0,isLoading:!1}),t&&!e&&(null==i||i.fetchFlags())},R=t=>{switch(p&&p(t),t){case o.FlagshipStatus.STARTING:t===o.FlagshipStatus.STARTING&&c&&c();break;case o.FlagshipStatus.READY_PANIC_ON:case o.FlagshipStatus.READY:g&&g(),O();break;case o.FlagshipStatus.NOT_INITIALIZED:V((t=>({...t,config:o.Flagship.getConfig()})))}},_=t=>{v&&v(t),I(t)},S=()=>{o.Flagship.start(i,s,{decisionMode:u,fetchNow:e,statusChangedCallback:R,onBucketingUpdated:_,...F})};return a.default.createElement(l.Provider,{value:{state:E,setState:V}},(()=>{const i=!E.visitor;return E.status.isLoading&&d&&i&&e?a.default.createElement(a.default.Fragment,null,d):a.default.createElement(a.default.Fragment,null,t)})())};e.FlagshipProvider=u,u.defaultProps={activateDeduplicationTime:2,hitDeduplicationTime:2,fetchNow:!0,language:1}},460:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.useFlagship=e.useFsActivate=e.useFsFlag=e.useFsModificationInfo=e.useFsModification=e.useFsModifications=void 0,i(117);var a=i(689),o=i(821),n=i(370),s=i(161),r=i(147);const l=(t,e)=>"object"==typeof t&&"object"==typeof e&&Array.isArray(t)===Array.isArray(e)||typeof t==typeof e,u=t=>{const{visitor:e,params:i,activateAll:a,state:o,functionName:s,config:u}=t;if(e)return e.getModificationsSync(i,a);const f=!o.status.isSdkReady&&!!o.modifications&&o.modifications.size>0,c={};return f?(i.forEach((t=>{var e;const i=null===(e=o.modifications)||void 0===e?void 0:e.get(t.key);i&&l(null==i?void 0:i.value,t.defaultValue)?c[t.key]=i.value:c[t.key]=t.defaultValue})),c):((0,n.logWarn)(u,r.noVisitorDefault,s),i.forEach((t=>{c[t.key]=t.defaultValue})),c)};e.useFsModifications=(t,e)=>{const{state:i}=(0,a.useContext)(o.FlagshipContext),{visitor:n,config:s}=i;return u({functionName:"useFsModifications",state:i,visitor:n,config:s,params:t,activateAll:e})},e.useFsModification=t=>{var e;const{state:i}=(0,a.useContext)(o.FlagshipContext),{visitor:s,config:u}=i;if(s)return s.getModificationSync(t);const f=null===(e=i.modifications)||void 0===e?void 0:e.get(t.key);return!i.status.isSdkReady&&f&&l(null==f?void 0:f.value,t.defaultValue)?f.value:((0,n.logWarn)(u,r.noVisitorDefault,"useFsModifications"),t.defaultValue)};const f=t=>{var e;const{key:i,visitor:a,state:o}=t;if(a)return a.getModificationInfoSync(i);const n=null===(e=o.modifications)||void 0===e?void 0:e.get(i);return!o.status.isSdkReady&&n?n:null};e.useFsModificationInfo=t=>{const{state:e}=(0,a.useContext)(o.FlagshipContext),{visitor:i}=e;return f({key:t,state:e,visitor:i})};const c=async(t,e,i,a)=>{try{if(!i)return void(0,n.logWarn)(a,r.noVisitorMessage,e);await i.activateModifications(t)}catch(t){(0,n.logWarn)(a,t.message||t,e)}};e.useFsFlag=(t,e)=>{const{state:i}=(0,a.useContext)(o.FlagshipContext),{visitor:n}=i;return n?n.getFlag(t,e):new s.Flag(e,t,i.modifications)},e.useFsActivate=async t=>{const{state:e}=(0,a.useContext)(o.FlagshipContext),{visitor:i,config:n}=e;await c(t,"useFsModifications",i,n)},e.useFlagship=()=>{const{state:t}=(0,a.useContext)(o.FlagshipContext),{visitor:e,config:i}=t;let l=null==e?void 0:e.getModificationsArray();return!t.status.isSdkReady&&t.modifications&&(l=Array.from(t.modifications,(([t,e])=>e))),{visitorId:null==e?void 0:e.visitorId,anonymousId:null==e?void 0:e.anonymousId,context:{...null==e?void 0:e.context},hasConsented:null==e?void 0:e.hasConsented,setConsent:function(t){e?e.setConsent(t):(0,n.logWarn)(i,r.noVisitorMessage,"setConsent")},updateContext:t=>{e?(e.clearContext(),e.updateContext(t)):(0,n.logError)(i,r.noVisitorMessage,"updateContext")},clearContext:()=>{e?e.clearContext():(0,n.logError)(i,r.noVisitorMessage,"cleanContext")},authenticate:t=>{e?e.authenticate(t):(0,n.logError)(i,r.noVisitorMessage,"authenticate")},unauthenticate:()=>{e?e.unauthenticate():(0,n.logError)(i,r.noVisitorMessage,"unauthenticate")},status:t.status,activateModification:async t=>{await c(t,"activateModification",e,i)},synchronizeModifications:async()=>{e?await e.synchronizeModifications():(0,n.logWarn)(i,r.noVisitorMessage,"synchronizeModifications")},getModifications:(a,o)=>u({functionName:"getModifications",state:t,visitor:e,config:i,params:a,activateAll:o}),modifications:l||[],flagsData:(null==e?void 0:e.getFlagsDataArray())||[],getModificationInfo:i=>f({key:i,state:t,visitor:e}),hit:{send:t=>e?e.sendHit(t):((0,n.logError)(i,r.noVisitorMessage,"sendHit"),Promise.resolve()),sendMultiple:t=>e?e.sendHits(t):((0,n.logError)(i,r.noVisitorMessage,"sendHits"),Promise.resolve())},getFlag:function(i,a){return e?e.getFlag(i,a):new s.Flag(a,i,t.modifications)},fetchFlags:function(){return e?e.fetchFlags():((0,n.logWarn)(i,r.noVisitorMessage,"fetchFlags"),Promise.resolve())}}}},147:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GET_METADATA_CAST_ERROR=e.GET_FLAG_CAST_ERROR=e.noVisitorDefault=e.noVisitorMessage=void 0,e.noVisitorMessage="flagship Visitor not initialized.",e.noVisitorDefault="fsVisitor not initialized, returns default value",e.GET_FLAG_CAST_ERROR="Flag for key {0} has a different type. Default value is returned.",e.GET_METADATA_CAST_ERROR="Flag for key {0} has a different type with defaultValue, an empty metadata object is returned"},231:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});var a=i(821);Object.keys(a).forEach((function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===a[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}}))}));var o=i(4);Object.keys(o).forEach((function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===o[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}}))}));var n=i(460);Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&(t in e&&e[t]===n[t]||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}}))}))},370:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.logError=function(t,e,i){t&&t.logManager&&"function"==typeof t.logManager.error&&t.logLevel&&!(t.logLevel<a.LogLevel.ERROR)&&t.logManager.error(e,i)},e.logInfo=function(t,e,i){t&&t.logManager&&"function"==typeof t.logManager.info&&t.logLevel&&!(t.logLevel<a.LogLevel.INFO)&&t.logManager.info(e,i)},e.logWarn=function(t,e,i){t&&t.logManager&&"function"==typeof t.logManager.warning&&t.logLevel&&!(t.logLevel<a.LogLevel.WARNING)&&t.logManager.warning(e,i)},e.uuidV4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},e.useNonInitialEffect=function(t,e){const i=(0,o.useRef)(!0);(0,o.useEffect)((()=>{if(!i.current)return"function"==typeof t?t():void 0;i.current=!1}),e)},e.hasSameType=function(t,e){return typeof t==typeof e&&("object"!=typeof t||"object"!=typeof e||Array.isArray(t)===Array.isArray(e))},e.sprintf=function(t,...e){let i=t;for(let t=0;t<e.length;t++){const a=e[t];i=i.replace(new RegExp(`\\{${t}\\}`,"g"),a)}return i},e.getModificationsFromCampaigns=void 0;var a=i(4),o=i(689);e.getModificationsFromCampaigns=t=>{const e=new Map;return t&&Array.isArray(t)?(t.forEach((t=>{const i=t.variation.modifications.value;for(const a in i){const o=i[a];e.set(a,{key:a,campaignId:t.id,variationGroupId:t.variationGroupId,variationId:t.variation.id,isReference:t.variation.reference,value:o})}})),e):e}},4:t=>{t.exports=require("@flagship.io/js-sdk")},117:t=>{t.exports=require("core-js/modules/es.promise.js")},689:t=>{t.exports=require("react")}},e={},i=function i(a){var o=e[a];if(void 0!==o)return o.exports;var n=e[a]={exports:{}};return t[a](n,n.exports,i),n.exports}(231);module.exports=i})();
|
|
1532
2
|
//# sourceMappingURL=index.node.js.map
|