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