@unleash/proxy-client-vue 0.0.7 → 0.1.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 +18 -20
- package/dist/index.es.js +429 -1439
- package/dist/index.umd.js +2 -2
- package/dist/useVariant.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,1490 +1,479 @@
|
|
|
1
1
|
import { toRefs, ref, reactive, defineComponent, provide, onMounted, renderSlot, inject, onUnmounted } from "vue";
|
|
2
|
-
var
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return n[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
return a;
|
|
17
|
-
}
|
|
18
|
-
var build = {};
|
|
19
|
-
var tinyEmitter = { exports: {} };
|
|
20
|
-
function E() {
|
|
21
|
-
}
|
|
22
|
-
E.prototype = {
|
|
23
|
-
on: function(name, callback, ctx) {
|
|
24
|
-
var e = this.e || (this.e = {});
|
|
25
|
-
(e[name] || (e[name] = [])).push({
|
|
26
|
-
fn: callback,
|
|
27
|
-
ctx
|
|
28
|
-
});
|
|
29
|
-
return this;
|
|
30
|
-
},
|
|
31
|
-
once: function(name, callback, ctx) {
|
|
32
|
-
var self2 = this;
|
|
33
|
-
function listener() {
|
|
34
|
-
self2.off(name, listener);
|
|
35
|
-
callback.apply(ctx, arguments);
|
|
36
|
-
}
|
|
37
|
-
listener._ = callback;
|
|
38
|
-
return this.on(name, listener, ctx);
|
|
39
|
-
},
|
|
40
|
-
emit: function(name) {
|
|
41
|
-
var data = [].slice.call(arguments, 1);
|
|
42
|
-
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
|
43
|
-
var i = 0;
|
|
44
|
-
var len = evtArr.length;
|
|
45
|
-
for (i; i < len; i++) {
|
|
46
|
-
evtArr[i].fn.apply(evtArr[i].ctx, data);
|
|
47
|
-
}
|
|
48
|
-
return this;
|
|
49
|
-
},
|
|
50
|
-
off: function(name, callback) {
|
|
51
|
-
var e = this.e || (this.e = {});
|
|
52
|
-
var evts = e[name];
|
|
53
|
-
var liveEvents = [];
|
|
54
|
-
if (evts && callback) {
|
|
55
|
-
for (var i = 0, len = evts.length; i < len; i++) {
|
|
56
|
-
if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
|
57
|
-
liveEvents.push(evts[i]);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
liveEvents.length ? e[name] = liveEvents : delete e[name];
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
2
|
+
var t = function(e2, n2) {
|
|
3
|
+
return t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t2, e3) {
|
|
4
|
+
t2.__proto__ = e3;
|
|
5
|
+
} || function(t2, e3) {
|
|
6
|
+
for (var n3 in e3)
|
|
7
|
+
Object.prototype.hasOwnProperty.call(e3, n3) && (t2[n3] = e3[n3]);
|
|
8
|
+
}, t(e2, n2);
|
|
63
9
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (var p in s)
|
|
72
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
73
|
-
t[p] = s[p];
|
|
74
|
-
}
|
|
75
|
-
return t;
|
|
76
|
-
};
|
|
77
|
-
return __assign$1.apply(this, arguments);
|
|
10
|
+
var e = function() {
|
|
11
|
+
return e = Object.assign || function(t2) {
|
|
12
|
+
for (var e2, n2 = 1, r2 = arguments.length; n2 < r2; n2++)
|
|
13
|
+
for (var i2 in e2 = arguments[n2])
|
|
14
|
+
Object.prototype.hasOwnProperty.call(e2, i2) && (t2[i2] = e2[i2]);
|
|
15
|
+
return t2;
|
|
16
|
+
}, e.apply(this, arguments);
|
|
78
17
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
resolve(value);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
86
|
-
function fulfilled(value) {
|
|
18
|
+
function n(t2, e2, n2, r2) {
|
|
19
|
+
return new (n2 || (n2 = Promise))(function(i2, o2) {
|
|
20
|
+
function s2(t3) {
|
|
87
21
|
try {
|
|
88
|
-
|
|
89
|
-
} catch (
|
|
90
|
-
|
|
22
|
+
c2(r2.next(t3));
|
|
23
|
+
} catch (t4) {
|
|
24
|
+
o2(t4);
|
|
91
25
|
}
|
|
92
26
|
}
|
|
93
|
-
function
|
|
27
|
+
function a2(t3) {
|
|
94
28
|
try {
|
|
95
|
-
|
|
96
|
-
} catch (
|
|
97
|
-
|
|
29
|
+
c2(r2.throw(t3));
|
|
30
|
+
} catch (t4) {
|
|
31
|
+
o2(t4);
|
|
98
32
|
}
|
|
99
33
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
34
|
+
function c2(t3) {
|
|
35
|
+
var e3;
|
|
36
|
+
t3.done ? i2(t3.value) : (e3 = t3.value, e3 instanceof n2 ? e3 : new n2(function(t4) {
|
|
37
|
+
t4(e3);
|
|
38
|
+
})).then(s2, a2);
|
|
102
39
|
}
|
|
103
|
-
|
|
40
|
+
c2((r2 = r2.apply(t2, e2 || [])).next());
|
|
104
41
|
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
if (
|
|
109
|
-
throw
|
|
110
|
-
return
|
|
111
|
-
}, trys: [], ops: [] }
|
|
112
|
-
return
|
|
42
|
+
}
|
|
43
|
+
function r(t2, e2) {
|
|
44
|
+
var n2, r2, i2, o2, s2 = { label: 0, sent: function() {
|
|
45
|
+
if (1 & i2[0])
|
|
46
|
+
throw i2[1];
|
|
47
|
+
return i2[1];
|
|
48
|
+
}, trys: [], ops: [] };
|
|
49
|
+
return o2 = { next: a2(0), throw: a2(1), return: a2(2) }, typeof Symbol == "function" && (o2[Symbol.iterator] = function() {
|
|
113
50
|
return this;
|
|
114
|
-
}),
|
|
115
|
-
function
|
|
116
|
-
return function(
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
_.label = t[1];
|
|
157
|
-
t = op;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
if (t && _.label < t[2]) {
|
|
161
|
-
_.label = t[2];
|
|
162
|
-
_.ops.push(op);
|
|
163
|
-
break;
|
|
51
|
+
}), o2;
|
|
52
|
+
function a2(a3) {
|
|
53
|
+
return function(c2) {
|
|
54
|
+
return function(a4) {
|
|
55
|
+
if (n2)
|
|
56
|
+
throw new TypeError("Generator is already executing.");
|
|
57
|
+
for (; o2 && (o2 = 0, a4[0] && (s2 = 0)), s2; )
|
|
58
|
+
try {
|
|
59
|
+
if (n2 = 1, r2 && (i2 = 2 & a4[0] ? r2.return : a4[0] ? r2.throw || ((i2 = r2.return) && i2.call(r2), 0) : r2.next) && !(i2 = i2.call(r2, a4[1])).done)
|
|
60
|
+
return i2;
|
|
61
|
+
switch (r2 = 0, i2 && (a4 = [2 & a4[0], i2.value]), a4[0]) {
|
|
62
|
+
case 0:
|
|
63
|
+
case 1:
|
|
64
|
+
i2 = a4;
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
return s2.label++, { value: a4[1], done: false };
|
|
68
|
+
case 5:
|
|
69
|
+
s2.label++, r2 = a4[1], a4 = [0];
|
|
70
|
+
continue;
|
|
71
|
+
case 7:
|
|
72
|
+
a4 = s2.ops.pop(), s2.trys.pop();
|
|
73
|
+
continue;
|
|
74
|
+
default:
|
|
75
|
+
if (!(i2 = s2.trys, (i2 = i2.length > 0 && i2[i2.length - 1]) || a4[0] !== 6 && a4[0] !== 2)) {
|
|
76
|
+
s2 = 0;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (a4[0] === 3 && (!i2 || a4[1] > i2[0] && a4[1] < i2[3])) {
|
|
80
|
+
s2.label = a4[1];
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (a4[0] === 6 && s2.label < i2[1]) {
|
|
84
|
+
s2.label = i2[1], i2 = a4;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (i2 && s2.label < i2[2]) {
|
|
88
|
+
s2.label = i2[2], s2.ops.push(a4);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
i2[2] && s2.ops.pop(), s2.trys.pop();
|
|
92
|
+
continue;
|
|
164
93
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
if (op[0] & 5)
|
|
178
|
-
throw op[1];
|
|
179
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
Object.defineProperty(metrics, "__esModule", { value: true });
|
|
183
|
-
var Metrics = function() {
|
|
184
|
-
function Metrics2(_a) {
|
|
185
|
-
var onError = _a.onError, appName = _a.appName, metricsInterval = _a.metricsInterval, _b = _a.disableMetrics, disableMetrics = _b === void 0 ? false : _b, url = _a.url, clientKey = _a.clientKey, fetch2 = _a.fetch, headerName = _a.headerName;
|
|
186
|
-
this.onError = onError;
|
|
187
|
-
this.disabled = disableMetrics;
|
|
188
|
-
this.metricsInterval = metricsInterval * 1e3;
|
|
189
|
-
this.appName = appName;
|
|
190
|
-
this.url = url instanceof URL ? url : new URL(url);
|
|
191
|
-
this.clientKey = clientKey;
|
|
192
|
-
this.bucket = this.createEmptyBucket();
|
|
193
|
-
this.fetch = fetch2;
|
|
194
|
-
this.headerName = headerName;
|
|
94
|
+
a4 = e2.call(t2, s2);
|
|
95
|
+
} catch (t3) {
|
|
96
|
+
a4 = [6, t3], r2 = 0;
|
|
97
|
+
} finally {
|
|
98
|
+
n2 = i2 = 0;
|
|
99
|
+
}
|
|
100
|
+
if (5 & a4[0])
|
|
101
|
+
throw a4[1];
|
|
102
|
+
return { value: a4[0] ? a4[1] : void 0, done: true };
|
|
103
|
+
}([a3, c2]);
|
|
104
|
+
};
|
|
195
105
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
106
|
+
}
|
|
107
|
+
typeof SuppressedError == "function" && SuppressedError;
|
|
108
|
+
var i = { exports: {} };
|
|
109
|
+
function o() {
|
|
110
|
+
}
|
|
111
|
+
o.prototype = { on: function(t2, e2, n2) {
|
|
112
|
+
var r2 = this.e || (this.e = {});
|
|
113
|
+
return (r2[t2] || (r2[t2] = [])).push({ fn: e2, ctx: n2 }), this;
|
|
114
|
+
}, once: function(t2, e2, n2) {
|
|
115
|
+
var r2 = this;
|
|
116
|
+
function i2() {
|
|
117
|
+
r2.off(t2, i2), e2.apply(n2, arguments);
|
|
118
|
+
}
|
|
119
|
+
return i2._ = e2, this.on(t2, i2, n2);
|
|
120
|
+
}, emit: function(t2) {
|
|
121
|
+
for (var e2 = [].slice.call(arguments, 1), n2 = ((this.e || (this.e = {}))[t2] || []).slice(), r2 = 0, i2 = n2.length; r2 < i2; r2++)
|
|
122
|
+
n2[r2].fn.apply(n2[r2].ctx, e2);
|
|
123
|
+
return this;
|
|
124
|
+
}, off: function(t2, e2) {
|
|
125
|
+
var n2 = this.e || (this.e = {}), r2 = n2[t2], i2 = [];
|
|
126
|
+
if (r2 && e2)
|
|
127
|
+
for (var o2 = 0, s2 = r2.length; o2 < s2; o2++)
|
|
128
|
+
r2[o2].fn !== e2 && r2[o2].fn._ !== e2 && i2.push(r2[o2]);
|
|
129
|
+
return i2.length ? n2[t2] = i2 : delete n2[t2], this;
|
|
130
|
+
} }, i.exports = o;
|
|
131
|
+
var s = i.exports.TinyEmitter = o, a = function(t2) {
|
|
132
|
+
var e2 = t2[1];
|
|
133
|
+
return e2 != null;
|
|
134
|
+
}, c = function() {
|
|
135
|
+
}, u = function() {
|
|
136
|
+
function t2(t3) {
|
|
137
|
+
var e2 = t3.onError, n2 = t3.onSent, r2 = t3.appName, i2 = t3.metricsInterval, o2 = t3.disableMetrics, s2 = o2 !== void 0 && o2, a2 = t3.url, u2 = t3.clientKey, h2 = t3.fetch, l2 = t3.headerName, p2 = t3.customHeaders, f2 = p2 === void 0 ? {} : p2;
|
|
138
|
+
this.onError = e2, this.onSent = n2 || c, this.disabled = s2, this.metricsInterval = 1e3 * i2, this.appName = r2, this.url = a2 instanceof URL ? a2 : new URL(a2), this.clientKey = u2, this.bucket = this.createEmptyBucket(), this.fetch = h2, this.headerName = l2, this.customHeaders = f2;
|
|
139
|
+
}
|
|
140
|
+
return t2.prototype.start = function() {
|
|
141
|
+
var t3 = this;
|
|
142
|
+
if (this.disabled)
|
|
199
143
|
return false;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
toggles: {}
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
Metrics2.prototype.sendMetrics = function() {
|
|
222
|
-
return __awaiter$2(this, void 0, void 0, function() {
|
|
223
|
-
var url, payload, e_1;
|
|
224
|
-
var _a;
|
|
225
|
-
return __generator$2(this, function(_b) {
|
|
226
|
-
switch (_b.label) {
|
|
144
|
+
typeof this.metricsInterval == "number" && this.metricsInterval > 0 && setTimeout(function() {
|
|
145
|
+
t3.startTimer(), t3.sendMetrics();
|
|
146
|
+
}, 2e3);
|
|
147
|
+
}, t2.prototype.stop = function() {
|
|
148
|
+
this.timer && (clearTimeout(this.timer), delete this.timer);
|
|
149
|
+
}, t2.prototype.createEmptyBucket = function() {
|
|
150
|
+
return { start: new Date(), stop: null, toggles: {} };
|
|
151
|
+
}, t2.prototype.getHeaders = function() {
|
|
152
|
+
var t3, e2 = ((t3 = {})[this.headerName] = this.clientKey, t3.Accept = "application/json", t3["Content-Type"] = "application/json", t3);
|
|
153
|
+
return Object.entries(this.customHeaders).filter(a).forEach(function(t4) {
|
|
154
|
+
var n2 = t4[0], r2 = t4[1];
|
|
155
|
+
return e2[n2] = r2;
|
|
156
|
+
}), e2;
|
|
157
|
+
}, t2.prototype.sendMetrics = function() {
|
|
158
|
+
return n(this, void 0, void 0, function() {
|
|
159
|
+
var t3, e2, n2;
|
|
160
|
+
return r(this, function(r2) {
|
|
161
|
+
switch (r2.label) {
|
|
227
162
|
case 0:
|
|
228
|
-
|
|
229
|
-
payload = this.getPayload();
|
|
230
|
-
if (this.bucketIsEmpty(payload)) {
|
|
163
|
+
if (t3 = "".concat(this.url, "/client/metrics"), e2 = this.getPayload(), this.bucketIsEmpty(e2))
|
|
231
164
|
return [2];
|
|
232
|
-
|
|
233
|
-
_b.label = 1;
|
|
165
|
+
r2.label = 1;
|
|
234
166
|
case 1:
|
|
235
|
-
|
|
236
|
-
return [4, this.fetch(url, {
|
|
237
|
-
cache: "no-cache",
|
|
238
|
-
method: "POST",
|
|
239
|
-
headers: (_a = {}, _a[this.headerName] = this.clientKey, _a.Accept = "application/json", _a["Content-Type"] = "application/json", _a),
|
|
240
|
-
body: JSON.stringify(payload)
|
|
241
|
-
})];
|
|
167
|
+
return r2.trys.push([1, 3, , 4]), [4, this.fetch(t3, { cache: "no-cache", method: "POST", headers: this.getHeaders(), body: JSON.stringify(e2) })];
|
|
242
168
|
case 2:
|
|
243
|
-
|
|
244
|
-
return [3, 4];
|
|
169
|
+
return r2.sent(), this.onSent(e2), [3, 4];
|
|
245
170
|
case 3:
|
|
246
|
-
|
|
247
|
-
console.error("Unleash: unable to send feature metrics", e_1);
|
|
248
|
-
this.onError(e_1);
|
|
249
|
-
return [3, 4];
|
|
171
|
+
return n2 = r2.sent(), console.error("Unleash: unable to send feature metrics", n2), this.onError(n2), [3, 4];
|
|
250
172
|
case 4:
|
|
251
173
|
return [2];
|
|
252
174
|
}
|
|
253
175
|
});
|
|
254
176
|
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this.
|
|
261
|
-
this.bucket.toggles[name][enabled ? "yes" : "no"]++;
|
|
262
|
-
return true;
|
|
263
|
-
};
|
|
264
|
-
Metrics2.prototype.assertBucket = function(name) {
|
|
265
|
-
if (this.disabled || !this.bucket) {
|
|
177
|
+
}, t2.prototype.count = function(t3, e2) {
|
|
178
|
+
return !(this.disabled || !this.bucket) && (this.assertBucket(t3), this.bucket.toggles[t3][e2 ? "yes" : "no"]++, true);
|
|
179
|
+
}, t2.prototype.countVariant = function(t3, e2) {
|
|
180
|
+
return !(this.disabled || !this.bucket) && (this.assertBucket(t3), this.bucket.toggles[t3].variants[e2] ? this.bucket.toggles[t3].variants[e2] += 1 : this.bucket.toggles[t3].variants[e2] = 1, true);
|
|
181
|
+
}, t2.prototype.assertBucket = function(t3) {
|
|
182
|
+
if (this.disabled || !this.bucket)
|
|
266
183
|
return false;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
yes: 0,
|
|
271
|
-
no: 0
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
Metrics2.prototype.startTimer = function() {
|
|
276
|
-
var _this = this;
|
|
184
|
+
this.bucket.toggles[t3] || (this.bucket.toggles[t3] = { yes: 0, no: 0, variants: {} });
|
|
185
|
+
}, t2.prototype.startTimer = function() {
|
|
186
|
+
var t3 = this;
|
|
277
187
|
this.timer = setInterval(function() {
|
|
278
|
-
|
|
188
|
+
t3.sendMetrics();
|
|
279
189
|
}, this.metricsInterval);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
bucket,
|
|
289
|
-
appName: this.appName,
|
|
290
|
-
instanceId: "browser"
|
|
291
|
-
};
|
|
292
|
-
};
|
|
293
|
-
return Metrics2;
|
|
294
|
-
}();
|
|
295
|
-
metrics.default = Metrics;
|
|
296
|
-
var storageProviderInmemory = {};
|
|
297
|
-
var __awaiter$1 = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
298
|
-
function adopt(value) {
|
|
299
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
300
|
-
resolve(value);
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
304
|
-
function fulfilled(value) {
|
|
305
|
-
try {
|
|
306
|
-
step(generator.next(value));
|
|
307
|
-
} catch (e) {
|
|
308
|
-
reject(e);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function rejected(value) {
|
|
312
|
-
try {
|
|
313
|
-
step(generator["throw"](value));
|
|
314
|
-
} catch (e) {
|
|
315
|
-
reject(e);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
function step(result) {
|
|
319
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
320
|
-
}
|
|
321
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
var __generator$1 = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) {
|
|
325
|
-
var _ = { label: 0, sent: function() {
|
|
326
|
-
if (t[0] & 1)
|
|
327
|
-
throw t[1];
|
|
328
|
-
return t[1];
|
|
329
|
-
}, trys: [], ops: [] }, f2, y, t, g;
|
|
330
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
331
|
-
return this;
|
|
332
|
-
}), g;
|
|
333
|
-
function verb(n) {
|
|
334
|
-
return function(v) {
|
|
335
|
-
return step([n, v]);
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
function step(op) {
|
|
339
|
-
if (f2)
|
|
340
|
-
throw new TypeError("Generator is already executing.");
|
|
341
|
-
while (_)
|
|
342
|
-
try {
|
|
343
|
-
if (f2 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
344
|
-
return t;
|
|
345
|
-
if (y = 0, t)
|
|
346
|
-
op = [op[0] & 2, t.value];
|
|
347
|
-
switch (op[0]) {
|
|
348
|
-
case 0:
|
|
349
|
-
case 1:
|
|
350
|
-
t = op;
|
|
351
|
-
break;
|
|
352
|
-
case 4:
|
|
353
|
-
_.label++;
|
|
354
|
-
return { value: op[1], done: false };
|
|
355
|
-
case 5:
|
|
356
|
-
_.label++;
|
|
357
|
-
y = op[1];
|
|
358
|
-
op = [0];
|
|
359
|
-
continue;
|
|
360
|
-
case 7:
|
|
361
|
-
op = _.ops.pop();
|
|
362
|
-
_.trys.pop();
|
|
363
|
-
continue;
|
|
364
|
-
default:
|
|
365
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
366
|
-
_ = 0;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
370
|
-
_.label = op[1];
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
374
|
-
_.label = t[1];
|
|
375
|
-
t = op;
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
if (t && _.label < t[2]) {
|
|
379
|
-
_.label = t[2];
|
|
380
|
-
_.ops.push(op);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
if (t[2])
|
|
384
|
-
_.ops.pop();
|
|
385
|
-
_.trys.pop();
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
op = body.call(thisArg, _);
|
|
389
|
-
} catch (e) {
|
|
390
|
-
op = [6, e];
|
|
391
|
-
y = 0;
|
|
392
|
-
} finally {
|
|
393
|
-
f2 = t = 0;
|
|
394
|
-
}
|
|
395
|
-
if (op[0] & 5)
|
|
396
|
-
throw op[1];
|
|
397
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
Object.defineProperty(storageProviderInmemory, "__esModule", { value: true });
|
|
401
|
-
var ImMemoryStorageProvider = function() {
|
|
402
|
-
function ImMemoryStorageProvider2() {
|
|
190
|
+
}, t2.prototype.bucketIsEmpty = function(t3) {
|
|
191
|
+
return Object.keys(t3.bucket.toggles).length === 0;
|
|
192
|
+
}, t2.prototype.getPayload = function() {
|
|
193
|
+
var t3 = e(e({}, this.bucket), { stop: new Date() });
|
|
194
|
+
return this.bucket = this.createEmptyBucket(), { bucket: t3, appName: this.appName, instanceId: "browser" };
|
|
195
|
+
}, t2;
|
|
196
|
+
}(), h = function() {
|
|
197
|
+
function t2() {
|
|
403
198
|
this.store = /* @__PURE__ */ new Map();
|
|
404
199
|
}
|
|
405
|
-
|
|
406
|
-
return
|
|
407
|
-
return
|
|
408
|
-
this.store.set(
|
|
409
|
-
return [2];
|
|
200
|
+
return t2.prototype.save = function(t3, e2) {
|
|
201
|
+
return n(this, void 0, void 0, function() {
|
|
202
|
+
return r(this, function(n2) {
|
|
203
|
+
return this.store.set(t3, e2), [2];
|
|
410
204
|
});
|
|
411
205
|
});
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return [2, this.store.get(name)];
|
|
206
|
+
}, t2.prototype.get = function(t3) {
|
|
207
|
+
return n(this, void 0, void 0, function() {
|
|
208
|
+
return r(this, function(e2) {
|
|
209
|
+
return [2, this.store.get(t3)];
|
|
417
210
|
});
|
|
418
211
|
});
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
storageProviderInmemory.default = ImMemoryStorageProvider;
|
|
423
|
-
var storageProviderLocal = {};
|
|
424
|
-
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
425
|
-
function adopt(value) {
|
|
426
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
427
|
-
resolve(value);
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
431
|
-
function fulfilled(value) {
|
|
432
|
-
try {
|
|
433
|
-
step(generator.next(value));
|
|
434
|
-
} catch (e) {
|
|
435
|
-
reject(e);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
function rejected(value) {
|
|
439
|
-
try {
|
|
440
|
-
step(generator["throw"](value));
|
|
441
|
-
} catch (e) {
|
|
442
|
-
reject(e);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function step(result) {
|
|
446
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
447
|
-
}
|
|
448
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
449
|
-
});
|
|
450
|
-
};
|
|
451
|
-
var __generator = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) {
|
|
452
|
-
var _ = { label: 0, sent: function() {
|
|
453
|
-
if (t[0] & 1)
|
|
454
|
-
throw t[1];
|
|
455
|
-
return t[1];
|
|
456
|
-
}, trys: [], ops: [] }, f2, y, t, g;
|
|
457
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
458
|
-
return this;
|
|
459
|
-
}), g;
|
|
460
|
-
function verb(n) {
|
|
461
|
-
return function(v) {
|
|
462
|
-
return step([n, v]);
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
function step(op) {
|
|
466
|
-
if (f2)
|
|
467
|
-
throw new TypeError("Generator is already executing.");
|
|
468
|
-
while (_)
|
|
469
|
-
try {
|
|
470
|
-
if (f2 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
471
|
-
return t;
|
|
472
|
-
if (y = 0, t)
|
|
473
|
-
op = [op[0] & 2, t.value];
|
|
474
|
-
switch (op[0]) {
|
|
475
|
-
case 0:
|
|
476
|
-
case 1:
|
|
477
|
-
t = op;
|
|
478
|
-
break;
|
|
479
|
-
case 4:
|
|
480
|
-
_.label++;
|
|
481
|
-
return { value: op[1], done: false };
|
|
482
|
-
case 5:
|
|
483
|
-
_.label++;
|
|
484
|
-
y = op[1];
|
|
485
|
-
op = [0];
|
|
486
|
-
continue;
|
|
487
|
-
case 7:
|
|
488
|
-
op = _.ops.pop();
|
|
489
|
-
_.trys.pop();
|
|
490
|
-
continue;
|
|
491
|
-
default:
|
|
492
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
493
|
-
_ = 0;
|
|
494
|
-
continue;
|
|
495
|
-
}
|
|
496
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
497
|
-
_.label = op[1];
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
501
|
-
_.label = t[1];
|
|
502
|
-
t = op;
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
if (t && _.label < t[2]) {
|
|
506
|
-
_.label = t[2];
|
|
507
|
-
_.ops.push(op);
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
if (t[2])
|
|
511
|
-
_.ops.pop();
|
|
512
|
-
_.trys.pop();
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
op = body.call(thisArg, _);
|
|
516
|
-
} catch (e) {
|
|
517
|
-
op = [6, e];
|
|
518
|
-
y = 0;
|
|
519
|
-
} finally {
|
|
520
|
-
f2 = t = 0;
|
|
521
|
-
}
|
|
522
|
-
if (op[0] & 5)
|
|
523
|
-
throw op[1];
|
|
524
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
Object.defineProperty(storageProviderLocal, "__esModule", { value: true });
|
|
528
|
-
var LocalStorageProvider = function() {
|
|
529
|
-
function LocalStorageProvider2() {
|
|
212
|
+
}, t2;
|
|
213
|
+
}(), l = function() {
|
|
214
|
+
function t2() {
|
|
530
215
|
this.prefix = "unleash:repository";
|
|
531
216
|
}
|
|
532
|
-
|
|
533
|
-
return
|
|
534
|
-
var
|
|
535
|
-
return
|
|
536
|
-
|
|
537
|
-
key = "".concat(this.prefix, ":").concat(name);
|
|
217
|
+
return t2.prototype.save = function(t3, e2) {
|
|
218
|
+
return n(this, void 0, void 0, function() {
|
|
219
|
+
var n2, i2;
|
|
220
|
+
return r(this, function(r2) {
|
|
221
|
+
n2 = JSON.stringify(e2), i2 = "".concat(this.prefix, ":").concat(t3);
|
|
538
222
|
try {
|
|
539
|
-
window.localStorage.setItem(
|
|
540
|
-
} catch (
|
|
541
|
-
console.error(
|
|
223
|
+
window.localStorage.setItem(i2, n2);
|
|
224
|
+
} catch (t4) {
|
|
225
|
+
console.error(t4);
|
|
542
226
|
}
|
|
543
227
|
return [2];
|
|
544
228
|
});
|
|
545
229
|
});
|
|
546
|
-
}
|
|
547
|
-
LocalStorageProvider2.prototype.get = function(name) {
|
|
230
|
+
}, t2.prototype.get = function(t3) {
|
|
548
231
|
try {
|
|
549
|
-
var
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
console.error(e);
|
|
232
|
+
var e2 = "".concat(this.prefix, ":").concat(t3), n2 = window.localStorage.getItem(e2);
|
|
233
|
+
return n2 ? JSON.parse(n2) : void 0;
|
|
234
|
+
} catch (t4) {
|
|
235
|
+
console.error(t4);
|
|
554
236
|
}
|
|
555
|
-
};
|
|
556
|
-
return LocalStorageProvider2;
|
|
237
|
+
}, t2;
|
|
557
238
|
}();
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
|
|
565
|
-
if (!getRandomValues) {
|
|
566
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return getRandomValues(rnds8);
|
|
570
|
-
}
|
|
571
|
-
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
572
|
-
function validate(uuid) {
|
|
573
|
-
return typeof uuid === "string" && REGEX.test(uuid);
|
|
239
|
+
let p;
|
|
240
|
+
const f = new Uint8Array(16);
|
|
241
|
+
function d() {
|
|
242
|
+
if (!p && (p = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !p))
|
|
243
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
244
|
+
return p(f);
|
|
574
245
|
}
|
|
575
|
-
|
|
576
|
-
for (
|
|
577
|
-
|
|
246
|
+
const v = [];
|
|
247
|
+
for (let t2 = 0; t2 < 256; ++t2)
|
|
248
|
+
v.push((t2 + 256).toString(16).slice(1));
|
|
249
|
+
var m = { randomUUID: typeof crypto != "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
250
|
+
function y(t2, e2, n2) {
|
|
251
|
+
if (m.randomUUID && !e2 && !t2)
|
|
252
|
+
return m.randomUUID();
|
|
253
|
+
const r2 = (t2 = t2 || {}).random || (t2.rng || d)();
|
|
254
|
+
if (r2[6] = 15 & r2[6] | 64, r2[8] = 63 & r2[8] | 128, e2) {
|
|
255
|
+
n2 = n2 || 0;
|
|
256
|
+
for (let t3 = 0; t3 < 16; ++t3)
|
|
257
|
+
e2[n2 + t3] = r2[t3];
|
|
258
|
+
return e2;
|
|
259
|
+
}
|
|
260
|
+
return function(t3, e3 = 0) {
|
|
261
|
+
return v[t3[e3 + 0]] + v[t3[e3 + 1]] + v[t3[e3 + 2]] + v[t3[e3 + 3]] + "-" + v[t3[e3 + 4]] + v[t3[e3 + 5]] + "-" + v[t3[e3 + 6]] + v[t3[e3 + 7]] + "-" + v[t3[e3 + 8]] + v[t3[e3 + 9]] + "-" + v[t3[e3 + 10]] + v[t3[e3 + 11]] + v[t3[e3 + 12]] + v[t3[e3 + 13]] + v[t3[e3 + 14]] + v[t3[e3 + 15]];
|
|
262
|
+
}(r2);
|
|
578
263
|
}
|
|
579
|
-
function
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
function v1(options, buf, offset) {
|
|
592
|
-
var i = buf && offset || 0;
|
|
593
|
-
var b = buf || new Array(16);
|
|
594
|
-
options = options || {};
|
|
595
|
-
var node = options.node || _nodeId;
|
|
596
|
-
var clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
|
|
597
|
-
if (node == null || clockseq == null) {
|
|
598
|
-
var seedBytes = options.random || (options.rng || rng)();
|
|
599
|
-
if (node == null) {
|
|
600
|
-
node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
|
601
|
-
}
|
|
602
|
-
if (clockseq == null) {
|
|
603
|
-
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
var msecs = options.msecs !== void 0 ? options.msecs : Date.now();
|
|
607
|
-
var nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
|
|
608
|
-
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
|
|
609
|
-
if (dt < 0 && options.clockseq === void 0) {
|
|
610
|
-
clockseq = clockseq + 1 & 16383;
|
|
611
|
-
}
|
|
612
|
-
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) {
|
|
613
|
-
nsecs = 0;
|
|
614
|
-
}
|
|
615
|
-
if (nsecs >= 1e4) {
|
|
616
|
-
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
617
|
-
}
|
|
618
|
-
_lastMSecs = msecs;
|
|
619
|
-
_lastNSecs = nsecs;
|
|
620
|
-
_clockseq = clockseq;
|
|
621
|
-
msecs += 122192928e5;
|
|
622
|
-
var tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
|
|
623
|
-
b[i++] = tl >>> 24 & 255;
|
|
624
|
-
b[i++] = tl >>> 16 & 255;
|
|
625
|
-
b[i++] = tl >>> 8 & 255;
|
|
626
|
-
b[i++] = tl & 255;
|
|
627
|
-
var tmh = msecs / 4294967296 * 1e4 & 268435455;
|
|
628
|
-
b[i++] = tmh >>> 8 & 255;
|
|
629
|
-
b[i++] = tmh & 255;
|
|
630
|
-
b[i++] = tmh >>> 24 & 15 | 16;
|
|
631
|
-
b[i++] = tmh >>> 16 & 255;
|
|
632
|
-
b[i++] = clockseq >>> 8 | 128;
|
|
633
|
-
b[i++] = clockseq & 255;
|
|
634
|
-
for (var n = 0; n < 6; ++n) {
|
|
635
|
-
b[i + n] = node[n];
|
|
636
|
-
}
|
|
637
|
-
return buf || stringify(b);
|
|
638
|
-
}
|
|
639
|
-
function parse(uuid) {
|
|
640
|
-
if (!validate(uuid)) {
|
|
641
|
-
throw TypeError("Invalid UUID");
|
|
642
|
-
}
|
|
643
|
-
var v;
|
|
644
|
-
var arr = new Uint8Array(16);
|
|
645
|
-
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
646
|
-
arr[1] = v >>> 16 & 255;
|
|
647
|
-
arr[2] = v >>> 8 & 255;
|
|
648
|
-
arr[3] = v & 255;
|
|
649
|
-
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
650
|
-
arr[5] = v & 255;
|
|
651
|
-
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
652
|
-
arr[7] = v & 255;
|
|
653
|
-
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
654
|
-
arr[9] = v & 255;
|
|
655
|
-
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
|
|
656
|
-
arr[11] = v / 4294967296 & 255;
|
|
657
|
-
arr[12] = v >>> 24 & 255;
|
|
658
|
-
arr[13] = v >>> 16 & 255;
|
|
659
|
-
arr[14] = v >>> 8 & 255;
|
|
660
|
-
arr[15] = v & 255;
|
|
661
|
-
return arr;
|
|
662
|
-
}
|
|
663
|
-
function stringToBytes(str) {
|
|
664
|
-
str = unescape(encodeURIComponent(str));
|
|
665
|
-
var bytes = [];
|
|
666
|
-
for (var i = 0; i < str.length; ++i) {
|
|
667
|
-
bytes.push(str.charCodeAt(i));
|
|
668
|
-
}
|
|
669
|
-
return bytes;
|
|
670
|
-
}
|
|
671
|
-
var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
672
|
-
var URL$1 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
673
|
-
function v35(name, version2, hashfunc) {
|
|
674
|
-
function generateUUID(value, namespace, buf, offset) {
|
|
675
|
-
if (typeof value === "string") {
|
|
676
|
-
value = stringToBytes(value);
|
|
677
|
-
}
|
|
678
|
-
if (typeof namespace === "string") {
|
|
679
|
-
namespace = parse(namespace);
|
|
680
|
-
}
|
|
681
|
-
if (namespace.length !== 16) {
|
|
682
|
-
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
683
|
-
}
|
|
684
|
-
var bytes = new Uint8Array(16 + value.length);
|
|
685
|
-
bytes.set(namespace);
|
|
686
|
-
bytes.set(value, namespace.length);
|
|
687
|
-
bytes = hashfunc(bytes);
|
|
688
|
-
bytes[6] = bytes[6] & 15 | version2;
|
|
689
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
690
|
-
if (buf) {
|
|
691
|
-
offset = offset || 0;
|
|
692
|
-
for (var i = 0; i < 16; ++i) {
|
|
693
|
-
buf[offset + i] = bytes[i];
|
|
694
|
-
}
|
|
695
|
-
return buf;
|
|
696
|
-
}
|
|
697
|
-
return stringify(bytes);
|
|
698
|
-
}
|
|
264
|
+
var g = function() {
|
|
265
|
+
function t2() {
|
|
266
|
+
}
|
|
267
|
+
return t2.prototype.generateEventId = function() {
|
|
268
|
+
return y();
|
|
269
|
+
}, t2.prototype.createImpressionEvent = function(t3, n2, r2, i2, o2, s2) {
|
|
270
|
+
var a2 = this.createBaseEvent(t3, n2, r2, i2, o2);
|
|
271
|
+
return s2 ? e(e({}, a2), { variant: s2 }) : a2;
|
|
272
|
+
}, t2.prototype.createBaseEvent = function(t3, e2, n2, r2, i2) {
|
|
273
|
+
return { eventType: r2, eventId: this.generateEventId(), context: t3, enabled: e2, featureName: n2, impressionData: i2 };
|
|
274
|
+
}, t2;
|
|
275
|
+
}(), b = ["userId", "sessionId", "remoteAddress"], w = { INIT: "initialized", ERROR: "error", READY: "ready", UPDATE: "update", IMPRESSION: "impression", SENT: "sent" }, E = "isEnabled", I = "getVariant", x = { name: "disabled", enabled: false, feature_enabled: false }, R = "repo", S = function() {
|
|
699
276
|
try {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
function
|
|
708
|
-
|
|
709
|
-
var
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
var length32 = input.length * 32;
|
|
720
|
-
var hexTab = "0123456789abcdef";
|
|
721
|
-
for (var i = 0; i < length32; i += 8) {
|
|
722
|
-
var x = input[i >> 5] >>> i % 32 & 255;
|
|
723
|
-
var hex = parseInt(hexTab.charAt(x >>> 4 & 15) + hexTab.charAt(x & 15), 16);
|
|
724
|
-
output.push(hex);
|
|
725
|
-
}
|
|
726
|
-
return output;
|
|
727
|
-
}
|
|
728
|
-
function getOutputLength(inputLength8) {
|
|
729
|
-
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
|
|
730
|
-
}
|
|
731
|
-
function wordsToMd5(x, len) {
|
|
732
|
-
x[len >> 5] |= 128 << len % 32;
|
|
733
|
-
x[getOutputLength(len) - 1] = len;
|
|
734
|
-
var a = 1732584193;
|
|
735
|
-
var b = -271733879;
|
|
736
|
-
var c = -1732584194;
|
|
737
|
-
var d = 271733878;
|
|
738
|
-
for (var i = 0; i < x.length; i += 16) {
|
|
739
|
-
var olda = a;
|
|
740
|
-
var oldb = b;
|
|
741
|
-
var oldc = c;
|
|
742
|
-
var oldd = d;
|
|
743
|
-
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
|
744
|
-
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
745
|
-
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
746
|
-
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
747
|
-
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
748
|
-
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
749
|
-
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
750
|
-
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
751
|
-
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
752
|
-
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
753
|
-
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
754
|
-
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
755
|
-
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
756
|
-
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
757
|
-
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
758
|
-
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
759
|
-
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
760
|
-
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
761
|
-
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
762
|
-
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
|
763
|
-
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
764
|
-
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
765
|
-
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
766
|
-
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
767
|
-
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
768
|
-
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
769
|
-
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
770
|
-
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
771
|
-
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
772
|
-
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
773
|
-
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
774
|
-
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
775
|
-
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
776
|
-
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
777
|
-
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
778
|
-
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
779
|
-
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
780
|
-
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
781
|
-
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
782
|
-
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
783
|
-
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
784
|
-
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
|
785
|
-
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
786
|
-
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
787
|
-
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
788
|
-
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
789
|
-
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
790
|
-
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
791
|
-
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
|
792
|
-
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
793
|
-
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
794
|
-
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
795
|
-
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
796
|
-
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
797
|
-
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
798
|
-
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
799
|
-
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
800
|
-
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
801
|
-
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
802
|
-
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
803
|
-
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
804
|
-
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
805
|
-
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
806
|
-
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
807
|
-
a = safeAdd(a, olda);
|
|
808
|
-
b = safeAdd(b, oldb);
|
|
809
|
-
c = safeAdd(c, oldc);
|
|
810
|
-
d = safeAdd(d, oldd);
|
|
811
|
-
}
|
|
812
|
-
return [a, b, c, d];
|
|
813
|
-
}
|
|
814
|
-
function bytesToWords(input) {
|
|
815
|
-
if (input.length === 0) {
|
|
816
|
-
return [];
|
|
817
|
-
}
|
|
818
|
-
var length8 = input.length * 8;
|
|
819
|
-
var output = new Uint32Array(getOutputLength(length8));
|
|
820
|
-
for (var i = 0; i < length8; i += 8) {
|
|
821
|
-
output[i >> 5] |= (input[i / 8] & 255) << i % 32;
|
|
822
|
-
}
|
|
823
|
-
return output;
|
|
824
|
-
}
|
|
825
|
-
function safeAdd(x, y) {
|
|
826
|
-
var lsw = (x & 65535) + (y & 65535);
|
|
827
|
-
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
828
|
-
return msw << 16 | lsw & 65535;
|
|
829
|
-
}
|
|
830
|
-
function bitRotateLeft(num, cnt) {
|
|
831
|
-
return num << cnt | num >>> 32 - cnt;
|
|
832
|
-
}
|
|
833
|
-
function md5cmn(q, a, b, x, s, t) {
|
|
834
|
-
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
|
835
|
-
}
|
|
836
|
-
function md5ff(a, b, c, d, x, s, t) {
|
|
837
|
-
return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
|
838
|
-
}
|
|
839
|
-
function md5gg(a, b, c, d, x, s, t) {
|
|
840
|
-
return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
|
841
|
-
}
|
|
842
|
-
function md5hh(a, b, c, d, x, s, t) {
|
|
843
|
-
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
|
844
|
-
}
|
|
845
|
-
function md5ii(a, b, c, d, x, s, t) {
|
|
846
|
-
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
847
|
-
}
|
|
848
|
-
var v3 = v35("v3", 48, md5);
|
|
849
|
-
var v3$1 = v3;
|
|
850
|
-
function v4(options, buf, offset) {
|
|
851
|
-
options = options || {};
|
|
852
|
-
var rnds = options.random || (options.rng || rng)();
|
|
853
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
854
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
855
|
-
if (buf) {
|
|
856
|
-
offset = offset || 0;
|
|
857
|
-
for (var i = 0; i < 16; ++i) {
|
|
858
|
-
buf[offset + i] = rnds[i];
|
|
859
|
-
}
|
|
860
|
-
return buf;
|
|
861
|
-
}
|
|
862
|
-
return stringify(rnds);
|
|
863
|
-
}
|
|
864
|
-
function f(s, x, y, z) {
|
|
865
|
-
switch (s) {
|
|
866
|
-
case 0:
|
|
867
|
-
return x & y ^ ~x & z;
|
|
868
|
-
case 1:
|
|
869
|
-
return x ^ y ^ z;
|
|
870
|
-
case 2:
|
|
871
|
-
return x & y ^ x & z ^ y & z;
|
|
872
|
-
case 3:
|
|
873
|
-
return x ^ y ^ z;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
function ROTL(x, n) {
|
|
877
|
-
return x << n | x >>> 32 - n;
|
|
878
|
-
}
|
|
879
|
-
function sha1(bytes) {
|
|
880
|
-
var K = [1518500249, 1859775393, 2400959708, 3395469782];
|
|
881
|
-
var H = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
882
|
-
if (typeof bytes === "string") {
|
|
883
|
-
var msg = unescape(encodeURIComponent(bytes));
|
|
884
|
-
bytes = [];
|
|
885
|
-
for (var i = 0; i < msg.length; ++i) {
|
|
886
|
-
bytes.push(msg.charCodeAt(i));
|
|
887
|
-
}
|
|
888
|
-
} else if (!Array.isArray(bytes)) {
|
|
889
|
-
bytes = Array.prototype.slice.call(bytes);
|
|
890
|
-
}
|
|
891
|
-
bytes.push(128);
|
|
892
|
-
var l = bytes.length / 4 + 2;
|
|
893
|
-
var N = Math.ceil(l / 16);
|
|
894
|
-
var M = new Array(N);
|
|
895
|
-
for (var _i = 0; _i < N; ++_i) {
|
|
896
|
-
var arr = new Uint32Array(16);
|
|
897
|
-
for (var j = 0; j < 16; ++j) {
|
|
898
|
-
arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
|
|
899
|
-
}
|
|
900
|
-
M[_i] = arr;
|
|
901
|
-
}
|
|
902
|
-
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
|
|
903
|
-
M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
904
|
-
M[N - 1][15] = (bytes.length - 1) * 8 & 4294967295;
|
|
905
|
-
for (var _i2 = 0; _i2 < N; ++_i2) {
|
|
906
|
-
var W = new Uint32Array(80);
|
|
907
|
-
for (var t = 0; t < 16; ++t) {
|
|
908
|
-
W[t] = M[_i2][t];
|
|
909
|
-
}
|
|
910
|
-
for (var _t = 16; _t < 80; ++_t) {
|
|
911
|
-
W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
|
|
912
|
-
}
|
|
913
|
-
var a = H[0];
|
|
914
|
-
var b = H[1];
|
|
915
|
-
var c = H[2];
|
|
916
|
-
var d = H[3];
|
|
917
|
-
var e = H[4];
|
|
918
|
-
for (var _t2 = 0; _t2 < 80; ++_t2) {
|
|
919
|
-
var s = Math.floor(_t2 / 20);
|
|
920
|
-
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
|
|
921
|
-
e = d;
|
|
922
|
-
d = c;
|
|
923
|
-
c = ROTL(b, 30) >>> 0;
|
|
924
|
-
b = a;
|
|
925
|
-
a = T;
|
|
926
|
-
}
|
|
927
|
-
H[0] = H[0] + a >>> 0;
|
|
928
|
-
H[1] = H[1] + b >>> 0;
|
|
929
|
-
H[2] = H[2] + c >>> 0;
|
|
930
|
-
H[3] = H[3] + d >>> 0;
|
|
931
|
-
H[4] = H[4] + e >>> 0;
|
|
932
|
-
}
|
|
933
|
-
return [H[0] >> 24 & 255, H[0] >> 16 & 255, H[0] >> 8 & 255, H[0] & 255, H[1] >> 24 & 255, H[1] >> 16 & 255, H[1] >> 8 & 255, H[1] & 255, H[2] >> 24 & 255, H[2] >> 16 & 255, H[2] >> 8 & 255, H[2] & 255, H[3] >> 24 & 255, H[3] >> 16 & 255, H[3] >> 8 & 255, H[3] & 255, H[4] >> 24 & 255, H[4] >> 16 & 255, H[4] >> 8 & 255, H[4] & 255];
|
|
934
|
-
}
|
|
935
|
-
var v5 = v35("v5", 80, sha1);
|
|
936
|
-
var v5$1 = v5;
|
|
937
|
-
var nil = "00000000-0000-0000-0000-000000000000";
|
|
938
|
-
function version(uuid) {
|
|
939
|
-
if (!validate(uuid)) {
|
|
940
|
-
throw TypeError("Invalid UUID");
|
|
941
|
-
}
|
|
942
|
-
return parseInt(uuid.substr(14, 1), 16);
|
|
943
|
-
}
|
|
944
|
-
var esmBrowser = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
945
|
-
__proto__: null,
|
|
946
|
-
v1,
|
|
947
|
-
v3: v3$1,
|
|
948
|
-
v4,
|
|
949
|
-
v5: v5$1,
|
|
950
|
-
NIL: nil,
|
|
951
|
-
version,
|
|
952
|
-
validate,
|
|
953
|
-
stringify,
|
|
954
|
-
parse
|
|
955
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
956
|
-
var require$$0 = /* @__PURE__ */ getAugmentedNamespace(esmBrowser);
|
|
957
|
-
var __assign = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
958
|
-
__assign = Object.assign || function(t) {
|
|
959
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
960
|
-
s = arguments[i];
|
|
961
|
-
for (var p in s)
|
|
962
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
963
|
-
t[p] = s[p];
|
|
964
|
-
}
|
|
965
|
-
return t;
|
|
966
|
-
};
|
|
967
|
-
return __assign.apply(this, arguments);
|
|
968
|
-
};
|
|
969
|
-
Object.defineProperty(eventsHandler, "__esModule", { value: true });
|
|
970
|
-
var uuid_1 = require$$0;
|
|
971
|
-
var EventsHandler = function() {
|
|
972
|
-
function EventsHandler2() {
|
|
973
|
-
}
|
|
974
|
-
EventsHandler2.prototype.generateEventId = function() {
|
|
975
|
-
return (0, uuid_1.v4)();
|
|
976
|
-
};
|
|
977
|
-
EventsHandler2.prototype.createImpressionEvent = function(context, enabled, featureName, eventType, variant) {
|
|
978
|
-
var baseEvent = this.createBaseEvent(context, enabled, featureName, eventType);
|
|
979
|
-
if (variant) {
|
|
980
|
-
return __assign(__assign({}, baseEvent), { variant });
|
|
981
|
-
}
|
|
982
|
-
return baseEvent;
|
|
983
|
-
};
|
|
984
|
-
EventsHandler2.prototype.createBaseEvent = function(context, enabled, featureName, eventType) {
|
|
985
|
-
return {
|
|
986
|
-
eventType,
|
|
987
|
-
eventId: this.generateEventId(),
|
|
988
|
-
context,
|
|
989
|
-
enabled,
|
|
990
|
-
featureName
|
|
991
|
-
};
|
|
992
|
-
};
|
|
993
|
-
return EventsHandler2;
|
|
994
|
-
}();
|
|
995
|
-
eventsHandler.default = EventsHandler;
|
|
996
|
-
var util = {};
|
|
997
|
-
Object.defineProperty(util, "__esModule", { value: true });
|
|
998
|
-
util.notNullOrUndefined = void 0;
|
|
999
|
-
var notNullOrUndefined = function(_a) {
|
|
1000
|
-
var value = _a[1];
|
|
1001
|
-
return value !== void 0 && value !== null;
|
|
1002
|
-
};
|
|
1003
|
-
util.notNullOrUndefined = notNullOrUndefined;
|
|
1004
|
-
(function(exports) {
|
|
1005
|
-
var __extends = commonjsGlobal && commonjsGlobal.__extends || function() {
|
|
1006
|
-
var extendStatics = function(d, b) {
|
|
1007
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
1008
|
-
d2.__proto__ = b2;
|
|
1009
|
-
} || function(d2, b2) {
|
|
1010
|
-
for (var p in b2)
|
|
1011
|
-
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
1012
|
-
d2[p] = b2[p];
|
|
1013
|
-
};
|
|
1014
|
-
return extendStatics(d, b);
|
|
1015
|
-
};
|
|
1016
|
-
return function(d, b) {
|
|
1017
|
-
if (typeof b !== "function" && b !== null)
|
|
1018
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1019
|
-
extendStatics(d, b);
|
|
1020
|
-
function __() {
|
|
1021
|
-
this.constructor = d;
|
|
1022
|
-
}
|
|
1023
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1024
|
-
};
|
|
1025
|
-
}();
|
|
1026
|
-
var __assign2 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
1027
|
-
__assign2 = Object.assign || function(t) {
|
|
1028
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1029
|
-
s = arguments[i];
|
|
1030
|
-
for (var p in s)
|
|
1031
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1032
|
-
t[p] = s[p];
|
|
1033
|
-
}
|
|
1034
|
-
return t;
|
|
1035
|
-
};
|
|
1036
|
-
return __assign2.apply(this, arguments);
|
|
1037
|
-
};
|
|
1038
|
-
var __awaiter2 = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1039
|
-
function adopt(value) {
|
|
1040
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1041
|
-
resolve(value);
|
|
277
|
+
if (typeof window != "undefined" && "fetch" in window)
|
|
278
|
+
return fetch.bind(window);
|
|
279
|
+
if ("fetch" in globalThis)
|
|
280
|
+
return fetch.bind(globalThis);
|
|
281
|
+
} catch (t2) {
|
|
282
|
+
console.error('Unleash failed to resolve "fetch"', t2);
|
|
283
|
+
}
|
|
284
|
+
}, T = function(i2) {
|
|
285
|
+
function o2(t2) {
|
|
286
|
+
var n2 = t2.storageProvider, r2 = t2.url, o3 = t2.clientKey, s2 = t2.disableRefresh, a2 = s2 !== void 0 && s2, c2 = t2.refreshInterval, p2 = c2 === void 0 ? 30 : c2, f2 = t2.metricsInterval, d2 = f2 === void 0 ? 30 : f2, v2 = t2.disableMetrics, m2 = v2 !== void 0 && v2, y2 = t2.appName, b2 = t2.environment, E2 = b2 === void 0 ? "default" : b2, I2 = t2.context, x2 = t2.fetch, R2 = x2 === void 0 ? S() : x2, T2 = t2.bootstrap, O = t2.bootstrapOverride, N = O === void 0 || O, k = t2.headerName, D = k === void 0 ? "Authorization" : k, U = t2.customHeaders, P = U === void 0 ? {} : U, A = t2.impressionDataAll, j = A !== void 0 && A, H = t2.usePOSTrequests, M = H !== void 0 && H, _ = i2.call(this) || this;
|
|
287
|
+
if (_.toggles = [], _.etag = "", _.readyEventEmitted = false, _.usePOSTrequests = false, _.started = false, !r2)
|
|
288
|
+
throw new Error("url is required");
|
|
289
|
+
if (!o3)
|
|
290
|
+
throw new Error("clientKey is required");
|
|
291
|
+
if (!y2)
|
|
292
|
+
throw new Error("appName is required.");
|
|
293
|
+
return _.eventsHandler = new g(), _.impressionDataAll = j, _.toggles = T2 && T2.length > 0 ? T2 : [], _.url = r2 instanceof URL ? r2 : new URL(r2), _.clientKey = o3, _.headerName = D, _.customHeaders = P, _.storage = n2 || (typeof window != "undefined" ? new l() : new h()), _.refreshInterval = a2 ? 0 : 1e3 * p2, _.context = e({ appName: y2, environment: E2 }, I2), _.usePOSTrequests = M, _.ready = new Promise(function(t3) {
|
|
294
|
+
_.init().then(t3).catch(function(e2) {
|
|
295
|
+
console.error(e2), _.emit(w.ERROR, e2), t3();
|
|
1042
296
|
});
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
297
|
+
}), R2 || console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'), _.fetch = R2, _.bootstrap = T2 && T2.length > 0 ? T2 : void 0, _.bootstrapOverride = N, _.metrics = new u({ onError: _.emit.bind(_, w.ERROR), onSent: _.emit.bind(_, w.SENT), appName: y2, metricsInterval: d2, disableMetrics: m2, url: _.url, clientKey: o3, fetch: R2, headerName: D, customHeaders: P }), _;
|
|
298
|
+
}
|
|
299
|
+
return function(e2, n2) {
|
|
300
|
+
if (typeof n2 != "function" && n2 !== null)
|
|
301
|
+
throw new TypeError("Class extends value " + String(n2) + " is not a constructor or null");
|
|
302
|
+
function r2() {
|
|
303
|
+
this.constructor = e2;
|
|
304
|
+
}
|
|
305
|
+
t(e2, n2), e2.prototype = n2 === null ? Object.create(n2) : (r2.prototype = n2.prototype, new r2());
|
|
306
|
+
}(o2, i2), o2.prototype.getAllToggles = function() {
|
|
307
|
+
return function(t2, e2, n2) {
|
|
308
|
+
if (n2 || arguments.length === 2)
|
|
309
|
+
for (var r2, i3 = 0, o3 = e2.length; i3 < o3; i3++)
|
|
310
|
+
!r2 && i3 in e2 || (r2 || (r2 = Array.prototype.slice.call(e2, 0, i3)), r2[i3] = e2[i3]);
|
|
311
|
+
return t2.concat(r2 || Array.prototype.slice.call(e2));
|
|
312
|
+
}([], this.toggles, true);
|
|
313
|
+
}, o2.prototype.isEnabled = function(t2) {
|
|
314
|
+
var e2, n2 = this.toggles.find(function(e3) {
|
|
315
|
+
return e3.name === t2;
|
|
316
|
+
}), r2 = !!n2 && n2.enabled;
|
|
317
|
+
if (this.metrics.count(t2, r2), (n2 == null ? void 0 : n2.impressionData) || this.impressionDataAll) {
|
|
318
|
+
var i3 = this.eventsHandler.createImpressionEvent(this.context, r2, t2, E, (e2 = n2 == null ? void 0 : n2.impressionData) !== null && e2 !== void 0 ? e2 : void 0);
|
|
319
|
+
this.emit(w.IMPRESSION, i3);
|
|
320
|
+
}
|
|
321
|
+
return r2;
|
|
322
|
+
}, o2.prototype.getVariant = function(t2) {
|
|
323
|
+
var n2, r2 = this.toggles.find(function(e2) {
|
|
324
|
+
return e2.name === t2;
|
|
325
|
+
}), i3 = (r2 == null ? void 0 : r2.enabled) || false, o3 = r2 ? r2.variant : x;
|
|
326
|
+
if (o3.name && this.metrics.countVariant(t2, o3.name), this.metrics.count(t2, i3), (r2 == null ? void 0 : r2.impressionData) || this.impressionDataAll) {
|
|
327
|
+
var s2 = this.eventsHandler.createImpressionEvent(this.context, i3, t2, I, (n2 = r2 == null ? void 0 : r2.impressionData) !== null && n2 !== void 0 ? n2 : void 0, o3.name);
|
|
328
|
+
this.emit(w.IMPRESSION, s2);
|
|
329
|
+
}
|
|
330
|
+
return e(e({}, o3), { feature_enabled: i3 });
|
|
331
|
+
}, o2.prototype.updateContext = function(t2) {
|
|
332
|
+
return n(this, void 0, void 0, function() {
|
|
333
|
+
var n2, i3 = this;
|
|
334
|
+
return r(this, function(r2) {
|
|
335
|
+
switch (r2.label) {
|
|
336
|
+
case 0:
|
|
337
|
+
return (t2.appName || t2.environment) && console.warn("appName and environment are static. They can't be updated with updateContext."), n2 = { environment: this.context.environment, appName: this.context.appName, sessionId: this.context.sessionId }, this.context = e(e({}, n2), t2), this.timerRef || this.readyEventEmitted ? [4, this.fetchToggles()] : [3, 2];
|
|
338
|
+
case 1:
|
|
339
|
+
return r2.sent(), [3, 4];
|
|
340
|
+
case 2:
|
|
341
|
+
return this.started ? [4, new Promise(function(t3) {
|
|
342
|
+
var e2 = function() {
|
|
343
|
+
i3.fetchToggles().then(function() {
|
|
344
|
+
i3.off(w.READY, e2), t3();
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
i3.once(w.READY, e2);
|
|
348
|
+
})] : [3, 4];
|
|
349
|
+
case 3:
|
|
350
|
+
r2.sent(), r2.label = 4;
|
|
351
|
+
case 4:
|
|
352
|
+
return [2];
|
|
1057
353
|
}
|
|
1058
|
-
}
|
|
1059
|
-
function step(result) {
|
|
1060
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1061
|
-
}
|
|
1062
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
354
|
+
});
|
|
1063
355
|
});
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
case 1:
|
|
1091
|
-
t = op;
|
|
1092
|
-
break;
|
|
1093
|
-
case 4:
|
|
1094
|
-
_.label++;
|
|
1095
|
-
return { value: op[1], done: false };
|
|
1096
|
-
case 5:
|
|
1097
|
-
_.label++;
|
|
1098
|
-
y = op[1];
|
|
1099
|
-
op = [0];
|
|
1100
|
-
continue;
|
|
1101
|
-
case 7:
|
|
1102
|
-
op = _.ops.pop();
|
|
1103
|
-
_.trys.pop();
|
|
1104
|
-
continue;
|
|
1105
|
-
default:
|
|
1106
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1107
|
-
_ = 0;
|
|
1108
|
-
continue;
|
|
1109
|
-
}
|
|
1110
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1111
|
-
_.label = op[1];
|
|
1112
|
-
break;
|
|
1113
|
-
}
|
|
1114
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1115
|
-
_.label = t[1];
|
|
1116
|
-
t = op;
|
|
1117
|
-
break;
|
|
1118
|
-
}
|
|
1119
|
-
if (t && _.label < t[2]) {
|
|
1120
|
-
_.label = t[2];
|
|
1121
|
-
_.ops.push(op);
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
if (t[2])
|
|
1125
|
-
_.ops.pop();
|
|
1126
|
-
_.trys.pop();
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
op = body.call(thisArg, _);
|
|
1130
|
-
} catch (e) {
|
|
1131
|
-
op = [6, e];
|
|
1132
|
-
y = 0;
|
|
1133
|
-
} finally {
|
|
1134
|
-
f2 = t = 0;
|
|
1135
|
-
}
|
|
1136
|
-
if (op[0] & 5)
|
|
1137
|
-
throw op[1];
|
|
1138
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function(to, from, pack) {
|
|
1142
|
-
if (pack || arguments.length === 2)
|
|
1143
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1144
|
-
if (ar || !(i in from)) {
|
|
1145
|
-
if (!ar)
|
|
1146
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
1147
|
-
ar[i] = from[i];
|
|
356
|
+
}, o2.prototype.getContext = function() {
|
|
357
|
+
return e({}, this.context);
|
|
358
|
+
}, o2.prototype.setContextField = function(t2, n2) {
|
|
359
|
+
var r2, i3;
|
|
360
|
+
if (b.includes(t2))
|
|
361
|
+
this.context = e(e({}, this.context), ((r2 = {})[t2] = n2, r2));
|
|
362
|
+
else {
|
|
363
|
+
var o3 = e(e({}, this.context.properties), ((i3 = {})[t2] = n2, i3));
|
|
364
|
+
this.context = e(e({}, this.context), { properties: o3 });
|
|
365
|
+
}
|
|
366
|
+
this.timerRef && this.fetchToggles();
|
|
367
|
+
}, o2.prototype.init = function() {
|
|
368
|
+
return n(this, void 0, void 0, function() {
|
|
369
|
+
var t2, n2;
|
|
370
|
+
return r(this, function(r2) {
|
|
371
|
+
switch (r2.label) {
|
|
372
|
+
case 0:
|
|
373
|
+
return [4, this.resolveSessionId()];
|
|
374
|
+
case 1:
|
|
375
|
+
return t2 = r2.sent(), this.context = e({ sessionId: t2 }, this.context), n2 = this, [4, this.storage.get(R)];
|
|
376
|
+
case 2:
|
|
377
|
+
return n2.toggles = r2.sent() || [], !this.bootstrap || !this.bootstrapOverride && this.toggles.length !== 0 ? [3, 4] : [4, this.storage.save(R, this.bootstrap)];
|
|
378
|
+
case 3:
|
|
379
|
+
r2.sent(), this.toggles = this.bootstrap, this.emit(w.READY), r2.label = 4;
|
|
380
|
+
case 4:
|
|
381
|
+
return this.emit(w.INIT), [2];
|
|
1148
382
|
}
|
|
1149
|
-
}
|
|
1150
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1151
|
-
};
|
|
1152
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1153
|
-
exports.InMemoryStorageProvider = exports.LocalStorageProvider = exports.UnleashClient = exports.resolveFetch = exports.EVENTS = void 0;
|
|
1154
|
-
var tiny_emitter_1 = tinyEmitter.exports;
|
|
1155
|
-
var metrics_1 = metrics;
|
|
1156
|
-
var storage_provider_inmemory_1 = storageProviderInmemory;
|
|
1157
|
-
exports.InMemoryStorageProvider = storage_provider_inmemory_1.default;
|
|
1158
|
-
var storage_provider_local_1 = storageProviderLocal;
|
|
1159
|
-
exports.LocalStorageProvider = storage_provider_local_1.default;
|
|
1160
|
-
var events_handler_1 = eventsHandler;
|
|
1161
|
-
var util_1 = util;
|
|
1162
|
-
var DEFINED_FIELDS = ["userId", "sessionId", "remoteAddress"];
|
|
1163
|
-
exports.EVENTS = {
|
|
1164
|
-
INIT: "initialized",
|
|
1165
|
-
ERROR: "error",
|
|
1166
|
-
READY: "ready",
|
|
1167
|
-
UPDATE: "update",
|
|
1168
|
-
IMPRESSION: "impression"
|
|
1169
|
-
};
|
|
1170
|
-
var IMPRESSION_EVENTS = {
|
|
1171
|
-
IS_ENABLED: "isEnabled",
|
|
1172
|
-
GET_VARIANT: "getVariant"
|
|
1173
|
-
};
|
|
1174
|
-
var defaultVariant = { name: "disabled", enabled: false };
|
|
1175
|
-
var storeKey = "repo";
|
|
1176
|
-
var resolveFetch = function() {
|
|
1177
|
-
try {
|
|
1178
|
-
if ("fetch" in window) {
|
|
1179
|
-
return fetch.bind(window);
|
|
1180
|
-
} else if ("fetch" in globalThis) {
|
|
1181
|
-
return fetch.bind(globalThis);
|
|
1182
|
-
}
|
|
1183
|
-
} catch (e) {
|
|
1184
|
-
console.error('Unleash failed to resolve "fetch"', e);
|
|
1185
|
-
}
|
|
1186
|
-
return void 0;
|
|
1187
|
-
};
|
|
1188
|
-
exports.resolveFetch = resolveFetch;
|
|
1189
|
-
var UnleashClient2 = function(_super) {
|
|
1190
|
-
__extends(UnleashClient3, _super);
|
|
1191
|
-
function UnleashClient3(_a) {
|
|
1192
|
-
var storageProvider = _a.storageProvider, url = _a.url, clientKey = _a.clientKey, _b = _a.disableRefresh, disableRefresh = _b === void 0 ? false : _b, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 30 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 30 : _d, _e = _a.disableMetrics, disableMetrics = _e === void 0 ? false : _e, appName = _a.appName, _f = _a.environment, environment = _f === void 0 ? "default" : _f, context = _a.context, _g = _a.fetch, fetch2 = _g === void 0 ? (0, exports.resolveFetch)() : _g, bootstrap = _a.bootstrap, _h = _a.bootstrapOverride, bootstrapOverride = _h === void 0 ? true : _h, _j = _a.headerName, headerName = _j === void 0 ? "Authorization" : _j, _k = _a.customHeaders, customHeaders = _k === void 0 ? {} : _k;
|
|
1193
|
-
var _this = _super.call(this) || this;
|
|
1194
|
-
_this.toggles = [];
|
|
1195
|
-
_this.etag = "";
|
|
1196
|
-
_this.readyEventEmitted = false;
|
|
1197
|
-
if (!url) {
|
|
1198
|
-
throw new Error("url is required");
|
|
1199
|
-
}
|
|
1200
|
-
if (!clientKey) {
|
|
1201
|
-
throw new Error("clientKey is required");
|
|
1202
|
-
}
|
|
1203
|
-
if (!appName) {
|
|
1204
|
-
throw new Error("appName is required.");
|
|
1205
|
-
}
|
|
1206
|
-
_this.eventsHandler = new events_handler_1.default();
|
|
1207
|
-
_this.toggles = bootstrap && bootstrap.length > 0 ? bootstrap : [];
|
|
1208
|
-
_this.url = url instanceof URL ? url : new URL(url);
|
|
1209
|
-
_this.clientKey = clientKey;
|
|
1210
|
-
_this.headerName = headerName;
|
|
1211
|
-
_this.customHeaders = customHeaders;
|
|
1212
|
-
_this.storage = storageProvider || new storage_provider_local_1.default();
|
|
1213
|
-
_this.refreshInterval = disableRefresh ? 0 : refreshInterval * 1e3;
|
|
1214
|
-
_this.context = __assign2({ appName, environment }, context);
|
|
1215
|
-
_this.ready = new Promise(function(resolve) {
|
|
1216
|
-
_this.init().then(resolve).catch(function(error) {
|
|
1217
|
-
console.error(error);
|
|
1218
|
-
_this.emit(exports.EVENTS.ERROR, error);
|
|
1219
|
-
resolve();
|
|
1220
|
-
});
|
|
1221
|
-
});
|
|
1222
|
-
if (!fetch2) {
|
|
1223
|
-
console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.');
|
|
1224
|
-
}
|
|
1225
|
-
_this.fetch = fetch2;
|
|
1226
|
-
_this.bootstrap = bootstrap && bootstrap.length > 0 ? bootstrap : void 0;
|
|
1227
|
-
_this.bootstrapOverride = bootstrapOverride;
|
|
1228
|
-
_this.metrics = new metrics_1.default({
|
|
1229
|
-
onError: _this.emit.bind(_this, exports.EVENTS.ERROR),
|
|
1230
|
-
appName,
|
|
1231
|
-
metricsInterval,
|
|
1232
|
-
disableMetrics,
|
|
1233
|
-
url: _this.url,
|
|
1234
|
-
clientKey,
|
|
1235
|
-
fetch: fetch2,
|
|
1236
|
-
headerName
|
|
1237
|
-
});
|
|
1238
|
-
return _this;
|
|
1239
|
-
}
|
|
1240
|
-
UnleashClient3.prototype.getAllToggles = function() {
|
|
1241
|
-
return __spreadArray([], this.toggles, true);
|
|
1242
|
-
};
|
|
1243
|
-
UnleashClient3.prototype.isEnabled = function(toggleName) {
|
|
1244
|
-
var toggle = this.toggles.find(function(t) {
|
|
1245
|
-
return t.name === toggleName;
|
|
1246
|
-
});
|
|
1247
|
-
var enabled = toggle ? toggle.enabled : false;
|
|
1248
|
-
this.metrics.count(toggleName, enabled);
|
|
1249
|
-
if (toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) {
|
|
1250
|
-
var event_1 = this.eventsHandler.createImpressionEvent(this.context, enabled, toggleName, IMPRESSION_EVENTS.IS_ENABLED);
|
|
1251
|
-
this.emit(exports.EVENTS.IMPRESSION, event_1);
|
|
1252
|
-
}
|
|
1253
|
-
return enabled;
|
|
1254
|
-
};
|
|
1255
|
-
UnleashClient3.prototype.getVariant = function(toggleName) {
|
|
1256
|
-
var toggle = this.toggles.find(function(t) {
|
|
1257
|
-
return t.name === toggleName;
|
|
1258
383
|
});
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
384
|
+
});
|
|
385
|
+
}, o2.prototype.start = function() {
|
|
386
|
+
return n(this, void 0, void 0, function() {
|
|
387
|
+
var t2, e2 = this;
|
|
388
|
+
return r(this, function(n2) {
|
|
389
|
+
switch (n2.label) {
|
|
390
|
+
case 0:
|
|
391
|
+
return this.started = true, this.timerRef ? (console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again."), [2]) : [4, this.ready];
|
|
392
|
+
case 1:
|
|
393
|
+
return n2.sent(), this.metrics.start(), t2 = this.refreshInterval, [4, this.fetchToggles()];
|
|
394
|
+
case 2:
|
|
395
|
+
return n2.sent(), t2 > 0 && (this.timerRef = setInterval(function() {
|
|
396
|
+
return e2.fetchToggles();
|
|
397
|
+
}, t2)), [2];
|
|
1264
398
|
}
|
|
1265
|
-
return toggle.variant;
|
|
1266
|
-
} else {
|
|
1267
|
-
this.metrics.count(toggleName, false);
|
|
1268
|
-
return defaultVariant;
|
|
1269
|
-
}
|
|
1270
|
-
};
|
|
1271
|
-
UnleashClient3.prototype.updateContext = function(context) {
|
|
1272
|
-
return __awaiter2(this, void 0, void 0, function() {
|
|
1273
|
-
var staticContext;
|
|
1274
|
-
return __generator2(this, function(_a) {
|
|
1275
|
-
switch (_a.label) {
|
|
1276
|
-
case 0:
|
|
1277
|
-
if (context.appName || context.environment) {
|
|
1278
|
-
console.warn("appName and environment are static. They can't be updated with updateContext.");
|
|
1279
|
-
}
|
|
1280
|
-
staticContext = {
|
|
1281
|
-
environment: this.context.environment,
|
|
1282
|
-
appName: this.context.appName
|
|
1283
|
-
};
|
|
1284
|
-
this.context = __assign2(__assign2({}, staticContext), context);
|
|
1285
|
-
if (!this.timerRef)
|
|
1286
|
-
return [3, 2];
|
|
1287
|
-
return [4, this.fetchToggles()];
|
|
1288
|
-
case 1:
|
|
1289
|
-
_a.sent();
|
|
1290
|
-
_a.label = 2;
|
|
1291
|
-
case 2:
|
|
1292
|
-
return [2];
|
|
1293
|
-
}
|
|
1294
|
-
});
|
|
1295
399
|
});
|
|
1296
|
-
};
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
var
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
return __generator2(this, function(_b) {
|
|
1316
|
-
switch (_b.label) {
|
|
1317
|
-
case 0:
|
|
1318
|
-
return [4, this.resolveSessionId()];
|
|
1319
|
-
case 1:
|
|
1320
|
-
sessionId = _b.sent();
|
|
1321
|
-
this.context = __assign2({ sessionId }, this.context);
|
|
1322
|
-
_a = this;
|
|
1323
|
-
return [4, this.storage.get(storeKey)];
|
|
1324
|
-
case 2:
|
|
1325
|
-
_a.toggles = _b.sent() || [];
|
|
1326
|
-
if (!(this.bootstrap && (this.bootstrapOverride || this.toggles.length === 0)))
|
|
1327
|
-
return [3, 4];
|
|
1328
|
-
return [4, this.storage.save(storeKey, this.bootstrap)];
|
|
1329
|
-
case 3:
|
|
1330
|
-
_b.sent();
|
|
1331
|
-
this.toggles = this.bootstrap;
|
|
1332
|
-
this.emit(exports.EVENTS.READY);
|
|
1333
|
-
_b.label = 4;
|
|
1334
|
-
case 4:
|
|
1335
|
-
this.emit(exports.EVENTS.INIT);
|
|
1336
|
-
return [2];
|
|
1337
|
-
}
|
|
1338
|
-
});
|
|
1339
|
-
});
|
|
1340
|
-
};
|
|
1341
|
-
UnleashClient3.prototype.start = function() {
|
|
1342
|
-
return __awaiter2(this, void 0, void 0, function() {
|
|
1343
|
-
var interval;
|
|
1344
|
-
var _this = this;
|
|
1345
|
-
return __generator2(this, function(_a) {
|
|
1346
|
-
switch (_a.label) {
|
|
1347
|
-
case 0:
|
|
1348
|
-
if (this.timerRef) {
|
|
1349
|
-
console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again.");
|
|
1350
|
-
return [2];
|
|
1351
|
-
}
|
|
1352
|
-
return [4, this.ready];
|
|
1353
|
-
case 1:
|
|
1354
|
-
_a.sent();
|
|
1355
|
-
this.metrics.start();
|
|
1356
|
-
interval = this.refreshInterval;
|
|
1357
|
-
return [4, this.fetchToggles()];
|
|
1358
|
-
case 2:
|
|
1359
|
-
_a.sent();
|
|
1360
|
-
if (interval > 0) {
|
|
1361
|
-
this.timerRef = setInterval(function() {
|
|
1362
|
-
return _this.fetchToggles();
|
|
1363
|
-
}, interval);
|
|
1364
|
-
}
|
|
1365
|
-
return [2];
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1368
|
-
});
|
|
1369
|
-
};
|
|
1370
|
-
UnleashClient3.prototype.stop = function() {
|
|
1371
|
-
if (this.timerRef) {
|
|
1372
|
-
clearInterval(this.timerRef);
|
|
1373
|
-
this.timerRef = void 0;
|
|
1374
|
-
}
|
|
1375
|
-
this.metrics.stop();
|
|
1376
|
-
};
|
|
1377
|
-
UnleashClient3.prototype.resolveSessionId = function() {
|
|
1378
|
-
return __awaiter2(this, void 0, void 0, function() {
|
|
1379
|
-
var sessionId;
|
|
1380
|
-
return __generator2(this, function(_a) {
|
|
1381
|
-
switch (_a.label) {
|
|
1382
|
-
case 0:
|
|
1383
|
-
if (!this.context.sessionId)
|
|
1384
|
-
return [3, 1];
|
|
1385
|
-
return [2, this.context.sessionId];
|
|
1386
|
-
case 1:
|
|
1387
|
-
return [4, this.storage.get("sessionId")];
|
|
1388
|
-
case 2:
|
|
1389
|
-
sessionId = _a.sent();
|
|
1390
|
-
if (!!sessionId)
|
|
1391
|
-
return [3, 4];
|
|
1392
|
-
sessionId = Math.floor(Math.random() * 1e9);
|
|
1393
|
-
return [4, this.storage.save("sessionId", sessionId)];
|
|
1394
|
-
case 3:
|
|
1395
|
-
_a.sent();
|
|
1396
|
-
_a.label = 4;
|
|
1397
|
-
case 4:
|
|
1398
|
-
return [2, sessionId];
|
|
1399
|
-
}
|
|
1400
|
-
});
|
|
1401
|
-
});
|
|
1402
|
-
};
|
|
1403
|
-
UnleashClient3.prototype.getHeaders = function() {
|
|
1404
|
-
var _a;
|
|
1405
|
-
var headers = (_a = {}, _a[this.headerName] = this.clientKey, _a.Accept = "application/json", _a["Content-Type"] = "application/json", _a["If-None-Match"] = this.etag, _a);
|
|
1406
|
-
Object.entries(this.customHeaders).filter(util_1.notNullOrUndefined).forEach(function(_a2) {
|
|
1407
|
-
var name = _a2[0], value = _a2[1];
|
|
1408
|
-
return headers[name] = value;
|
|
400
|
+
});
|
|
401
|
+
}, o2.prototype.stop = function() {
|
|
402
|
+
this.timerRef && (clearInterval(this.timerRef), this.timerRef = void 0), this.metrics.stop();
|
|
403
|
+
}, o2.prototype.resolveSessionId = function() {
|
|
404
|
+
return n(this, void 0, void 0, function() {
|
|
405
|
+
var t2;
|
|
406
|
+
return r(this, function(e2) {
|
|
407
|
+
switch (e2.label) {
|
|
408
|
+
case 0:
|
|
409
|
+
return this.context.sessionId ? [2, this.context.sessionId] : [3, 1];
|
|
410
|
+
case 1:
|
|
411
|
+
return [4, this.storage.get("sessionId")];
|
|
412
|
+
case 2:
|
|
413
|
+
return (t2 = e2.sent()) ? [3, 4] : (t2 = Math.floor(1e9 * Math.random()), [4, this.storage.save("sessionId", t2)]);
|
|
414
|
+
case 3:
|
|
415
|
+
e2.sent(), e2.label = 4;
|
|
416
|
+
case 4:
|
|
417
|
+
return [2, t2];
|
|
418
|
+
}
|
|
1409
419
|
});
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
420
|
+
});
|
|
421
|
+
}, o2.prototype.getHeaders = function() {
|
|
422
|
+
var t2, e2 = ((t2 = {})[this.headerName] = this.clientKey, t2.Accept = "application/json", t2["Content-Type"] = "application/json", t2["If-None-Match"] = this.etag, t2);
|
|
423
|
+
return Object.entries(this.customHeaders).filter(a).forEach(function(t3) {
|
|
424
|
+
var n2 = t3[0], r2 = t3[1];
|
|
425
|
+
return e2[n2] = r2;
|
|
426
|
+
}), e2;
|
|
427
|
+
}, o2.prototype.storeToggles = function(t2) {
|
|
428
|
+
return n(this, void 0, void 0, function() {
|
|
429
|
+
return r(this, function(e2) {
|
|
430
|
+
switch (e2.label) {
|
|
431
|
+
case 0:
|
|
432
|
+
return this.toggles = t2, this.emit(w.UPDATE), [4, this.storage.save(R, t2)];
|
|
433
|
+
case 1:
|
|
434
|
+
return e2.sent(), [2];
|
|
435
|
+
}
|
|
1425
436
|
});
|
|
1426
|
-
};
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
data = _a.sent();
|
|
1463
|
-
return [4, this.storeToggles(data.toggles)];
|
|
1464
|
-
case 4:
|
|
1465
|
-
_a.sent();
|
|
1466
|
-
if (!this.bootstrap && !this.readyEventEmitted) {
|
|
1467
|
-
this.emit(exports.EVENTS.READY);
|
|
1468
|
-
this.readyEventEmitted = true;
|
|
1469
|
-
}
|
|
1470
|
-
_a.label = 5;
|
|
1471
|
-
case 5:
|
|
1472
|
-
return [3, 7];
|
|
1473
|
-
case 6:
|
|
1474
|
-
e_1 = _a.sent();
|
|
1475
|
-
console.error("Unleash: unable to fetch feature toggles", e_1);
|
|
1476
|
-
this.emit(exports.EVENTS.ERROR, e_1);
|
|
1477
|
-
return [3, 7];
|
|
1478
|
-
case 7:
|
|
1479
|
-
return [2];
|
|
1480
|
-
}
|
|
1481
|
-
});
|
|
437
|
+
});
|
|
438
|
+
}, o2.prototype.fetchToggles = function() {
|
|
439
|
+
return n(this, void 0, void 0, function() {
|
|
440
|
+
var t2, e2, n2, i3, o3, s2, c2;
|
|
441
|
+
return r(this, function(r2) {
|
|
442
|
+
switch (r2.label) {
|
|
443
|
+
case 0:
|
|
444
|
+
if (!this.fetch)
|
|
445
|
+
return [3, 8];
|
|
446
|
+
r2.label = 1;
|
|
447
|
+
case 1:
|
|
448
|
+
return r2.trys.push([1, 7, , 8]), t2 = this.usePOSTrequests, e2 = t2 ? this.url : function(t3, e3) {
|
|
449
|
+
var n3 = new URL(t3.toString());
|
|
450
|
+
return Object.entries(e3).filter(a).forEach(function(t4) {
|
|
451
|
+
var e4 = t4[0], r3 = t4[1];
|
|
452
|
+
e4 === "properties" && r3 ? Object.entries(r3).filter(a).forEach(function(t5) {
|
|
453
|
+
var e5 = t5[0], r4 = t5[1];
|
|
454
|
+
return n3.searchParams.append("properties[".concat(e5, "]"), r4);
|
|
455
|
+
}) : n3.searchParams.append(e4, r3);
|
|
456
|
+
}), n3;
|
|
457
|
+
}(this.url, this.context), n2 = t2 ? "POST" : "GET", i3 = t2 ? JSON.stringify({ context: this.context }) : void 0, [4, this.fetch(e2.toString(), { method: n2, cache: "no-cache", headers: this.getHeaders(), body: i3 })];
|
|
458
|
+
case 2:
|
|
459
|
+
return (o3 = r2.sent()).ok && o3.status !== 304 ? (this.etag = o3.headers.get("ETag") || "", [4, o3.json()]) : [3, 5];
|
|
460
|
+
case 3:
|
|
461
|
+
return s2 = r2.sent(), [4, this.storeToggles(s2.toggles)];
|
|
462
|
+
case 4:
|
|
463
|
+
return r2.sent(), this.bootstrap || this.readyEventEmitted || (this.emit(w.READY), this.readyEventEmitted = true), [3, 6];
|
|
464
|
+
case 5:
|
|
465
|
+
o3.ok || o3.status === 304 || (console.error("Unleash: Fetching feature toggles did not have an ok response"), this.emit(w.ERROR, { type: "HttpError", code: o3.status })), r2.label = 6;
|
|
466
|
+
case 6:
|
|
467
|
+
return [3, 8];
|
|
468
|
+
case 7:
|
|
469
|
+
return c2 = r2.sent(), console.error("Unleash: unable to fetch feature toggles", c2), this.emit(w.ERROR, c2), [3, 8];
|
|
470
|
+
case 8:
|
|
471
|
+
return [2];
|
|
472
|
+
}
|
|
1482
473
|
});
|
|
1483
|
-
};
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
exports.UnleashClient = UnleashClient2;
|
|
1487
|
-
})(build);
|
|
474
|
+
});
|
|
475
|
+
}, o2;
|
|
476
|
+
}(s);
|
|
1488
477
|
const ContextStateSymbol = Symbol("Context state identifier");
|
|
1489
478
|
const ContextUpdateSymbol = Symbol("Context update identifier");
|
|
1490
479
|
function useUnleashProvide({
|
|
@@ -1501,13 +490,13 @@ function useUnleashProvide({
|
|
|
1501
490
|
checking if the client exists before rendering.`);
|
|
1502
491
|
}
|
|
1503
492
|
if (!client.value && config) {
|
|
1504
|
-
client.value = new
|
|
493
|
+
client.value = new T(config);
|
|
1505
494
|
}
|
|
1506
495
|
(_a = client.value) == null ? void 0 : _a.on("ready", () => {
|
|
1507
496
|
flagsReady.value = true;
|
|
1508
497
|
});
|
|
1509
|
-
(_b = client.value) == null ? void 0 : _b.on("error", (
|
|
1510
|
-
flagsError.value =
|
|
498
|
+
(_b = client.value) == null ? void 0 : _b.on("error", (e2) => {
|
|
499
|
+
flagsError.value = e2;
|
|
1511
500
|
});
|
|
1512
501
|
const updateContext = async (context2) => {
|
|
1513
502
|
var _a2;
|
|
@@ -1601,13 +590,17 @@ const useFlagsStatus = () => {
|
|
|
1601
590
|
const { flagsReady, flagsError } = inject(ContextStateSymbol, {});
|
|
1602
591
|
return { flagsReady, flagsError };
|
|
1603
592
|
};
|
|
593
|
+
const variantHasChanged = (oldVariant, newVariant) => {
|
|
594
|
+
var _a, _b, _c, _d;
|
|
595
|
+
const variantsAreEqual = (oldVariant == null ? void 0 : oldVariant.name) === (newVariant == null ? void 0 : newVariant.name) && (oldVariant == null ? void 0 : oldVariant.enabled) === (newVariant == null ? void 0 : newVariant.enabled) && (oldVariant == null ? void 0 : oldVariant.feature_enabled) === (newVariant == null ? void 0 : newVariant.feature_enabled) && ((_a = oldVariant == null ? void 0 : oldVariant.payload) == null ? void 0 : _a.type) === ((_b = newVariant == null ? void 0 : newVariant.payload) == null ? void 0 : _b.type) && ((_c = oldVariant == null ? void 0 : oldVariant.payload) == null ? void 0 : _c.value) === ((_d = newVariant == null ? void 0 : newVariant.payload) == null ? void 0 : _d.value);
|
|
596
|
+
return !variantsAreEqual;
|
|
597
|
+
};
|
|
1604
598
|
const useVariant = (name) => {
|
|
1605
599
|
const { getVariant, client } = inject(ContextStateSymbol, {});
|
|
1606
600
|
const variant = ref(getVariant == null ? void 0 : getVariant.value(name));
|
|
1607
601
|
function onUpdate() {
|
|
1608
|
-
var _a, _b;
|
|
1609
602
|
const newVariant = getVariant == null ? void 0 : getVariant.value(name);
|
|
1610
|
-
if ((
|
|
603
|
+
if (variantHasChanged(variant == null ? void 0 : variant.value, newVariant)) {
|
|
1611
604
|
variant.value = newVariant;
|
|
1612
605
|
}
|
|
1613
606
|
}
|
|
@@ -1642,7 +635,4 @@ const plugin = {
|
|
|
1642
635
|
start();
|
|
1643
636
|
}
|
|
1644
637
|
};
|
|
1645
|
-
|
|
1646
|
-
var LocalStorageProvider$1 = build.LocalStorageProvider;
|
|
1647
|
-
var UnleashClient = build.UnleashClient;
|
|
1648
|
-
export { ContextStateSymbol, ContextUpdateSymbol, _sfc_main as FlagProvider, InMemoryStorageProvider, LocalStorageProvider$1 as LocalStorageProvider, UnleashClient, _sfc_main as default, plugin, useFlag, useFlagsStatus, useUnleashClient, useUnleashContext, useVariant };
|
|
638
|
+
export { ContextStateSymbol, ContextUpdateSymbol, _sfc_main as FlagProvider, h as InMemoryStorageProvider, l as LocalStorageProvider, T as UnleashClient, _sfc_main as default, plugin, useFlag, useFlagsStatus, useUnleashClient, useUnleashContext, useVariant };
|