@unleash/proxy-client-vue 1.0.0 → 1.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 +38 -5
- package/dist/FlagProvider.vue.d.ts +2 -1
- package/dist/index.es.js +402 -394
- package/dist/index.umd.js +1 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/useFlag.d.ts +2 -2
- package/dist/useUnleashProvide.d.ts +5 -3
- package/dist/useVariant.d.ts +3 -3
- package/package.json +9 -3
package/dist/index.es.js
CHANGED
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
var
|
|
3
|
-
return
|
|
4
|
-
e.__proto__ =
|
|
5
|
-
} || function(e,
|
|
6
|
-
for (var
|
|
7
|
-
},
|
|
1
|
+
import { ref as D, reactive as yt, toRefs as bt, defineComponent as xt, provide as tt, onMounted as Tt, onUnmounted as z, renderSlot as Et, inject as F, toValue as O, watch as it } from "vue";
|
|
2
|
+
var Y = function(o, t) {
|
|
3
|
+
return Y = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
|
|
4
|
+
e.__proto__ = n;
|
|
5
|
+
} || function(e, n) {
|
|
6
|
+
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
|
|
7
|
+
}, Y(o, t);
|
|
8
8
|
};
|
|
9
|
-
function
|
|
9
|
+
function at(o, t) {
|
|
10
10
|
if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
11
11
|
function e() {
|
|
12
12
|
this.constructor = o;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
Y(o, t), o.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
|
|
15
15
|
}
|
|
16
16
|
var p = function() {
|
|
17
17
|
return p = Object.assign || function(o) {
|
|
18
|
-
for (var t, e = 1,
|
|
18
|
+
for (var t, e = 1, n = arguments.length; e < n; e++) for (var r in t = arguments[e]) Object.prototype.hasOwnProperty.call(t, r) && (o[r] = t[r]);
|
|
19
19
|
return o;
|
|
20
20
|
}, p.apply(this, arguments);
|
|
21
21
|
};
|
|
22
|
-
function g(o, t, e,
|
|
23
|
-
return new (e || (e = Promise))((function(
|
|
22
|
+
function g(o, t, e, n) {
|
|
23
|
+
return new (e || (e = Promise))((function(r, s) {
|
|
24
24
|
function i(c) {
|
|
25
25
|
try {
|
|
26
|
-
l(
|
|
27
|
-
} catch (
|
|
28
|
-
s(
|
|
26
|
+
l(n.next(c));
|
|
27
|
+
} catch (u) {
|
|
28
|
+
s(u);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function a(c) {
|
|
32
32
|
try {
|
|
33
|
-
l(
|
|
34
|
-
} catch (
|
|
35
|
-
s(
|
|
33
|
+
l(n.throw(c));
|
|
34
|
+
} catch (u) {
|
|
35
|
+
s(u);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function l(c) {
|
|
39
|
-
var
|
|
40
|
-
c.done ?
|
|
41
|
-
f(
|
|
42
|
-
}))).then(i,
|
|
39
|
+
var u;
|
|
40
|
+
c.done ? r(c.value) : (u = c.value, u instanceof e ? u : new e((function(f) {
|
|
41
|
+
f(u);
|
|
42
|
+
}))).then(i, a);
|
|
43
43
|
}
|
|
44
|
-
l((
|
|
44
|
+
l((n = n.apply(o, t || [])).next());
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
47
|
function y(o, t) {
|
|
48
|
-
var e,
|
|
49
|
-
if (1 &
|
|
50
|
-
return
|
|
48
|
+
var e, n, r, s = { label: 0, sent: function() {
|
|
49
|
+
if (1 & r[0]) throw r[1];
|
|
50
|
+
return r[1];
|
|
51
51
|
}, trys: [], ops: [] }, i = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
52
|
-
return i.next =
|
|
52
|
+
return i.next = a(0), i.throw = a(1), i.return = a(2), typeof Symbol == "function" && (i[Symbol.iterator] = function() {
|
|
53
53
|
return this;
|
|
54
54
|
}), i;
|
|
55
|
-
function
|
|
55
|
+
function a(l) {
|
|
56
56
|
return function(c) {
|
|
57
|
-
return (function(
|
|
57
|
+
return (function(u) {
|
|
58
58
|
if (e) throw new TypeError("Generator is already executing.");
|
|
59
|
-
for (; i && (i = 0,
|
|
60
|
-
if (e = 1,
|
|
61
|
-
switch (
|
|
59
|
+
for (; i && (i = 0, u[0] && (s = 0)), s; ) try {
|
|
60
|
+
if (e = 1, n && (r = 2 & u[0] ? n.return : u[0] ? n.throw || ((r = n.return) && r.call(n), 0) : n.next) && !(r = r.call(n, u[1])).done) return r;
|
|
61
|
+
switch (n = 0, r && (u = [2 & u[0], r.value]), u[0]) {
|
|
62
62
|
case 0:
|
|
63
63
|
case 1:
|
|
64
|
-
|
|
64
|
+
r = u;
|
|
65
65
|
break;
|
|
66
66
|
case 4:
|
|
67
|
-
return s.label++, { value:
|
|
67
|
+
return s.label++, { value: u[1], done: !1 };
|
|
68
68
|
case 5:
|
|
69
|
-
s.label++,
|
|
69
|
+
s.label++, n = u[1], u = [0];
|
|
70
70
|
continue;
|
|
71
71
|
case 7:
|
|
72
|
-
|
|
72
|
+
u = s.ops.pop(), s.trys.pop();
|
|
73
73
|
continue;
|
|
74
74
|
default:
|
|
75
|
-
if (
|
|
75
|
+
if (r = s.trys, !((r = r.length > 0 && r[r.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
|
|
76
76
|
s = 0;
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
|
-
if (
|
|
80
|
-
s.label =
|
|
79
|
+
if (u[0] === 3 && (!r || u[1] > r[0] && u[1] < r[3])) {
|
|
80
|
+
s.label = u[1];
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
s.label =
|
|
83
|
+
if (u[0] === 6 && s.label < r[1]) {
|
|
84
|
+
s.label = r[1], r = u;
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
88
|
-
s.label =
|
|
87
|
+
if (r && s.label < r[2]) {
|
|
88
|
+
s.label = r[2], s.ops.push(u);
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
r[2] && s.ops.pop(), s.trys.pop();
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
u = t.call(o, s);
|
|
95
95
|
} catch (f) {
|
|
96
|
-
|
|
96
|
+
u = [6, f], n = 0;
|
|
97
97
|
} finally {
|
|
98
|
-
e =
|
|
98
|
+
e = r = 0;
|
|
99
99
|
}
|
|
100
|
-
if (5 &
|
|
101
|
-
return { value:
|
|
100
|
+
if (5 & u[0]) throw u[1];
|
|
101
|
+
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
102
102
|
})([l, c]);
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
if (e || arguments.length === 2) for (var
|
|
108
|
-
return o.concat(
|
|
106
|
+
function j(o, t, e) {
|
|
107
|
+
if (e || arguments.length === 2) for (var n, r = 0, s = t.length; r < s; r++) !n && r in t || (n || (n = Array.prototype.slice.call(t, 0, r)), n[r] = t[r]);
|
|
108
|
+
return o.concat(n || Array.prototype.slice.call(t));
|
|
109
109
|
}
|
|
110
|
-
var
|
|
111
|
-
if (
|
|
110
|
+
var et, K = { exports: {} }, ut = (function() {
|
|
111
|
+
if (et) return K.exports;
|
|
112
112
|
function o() {
|
|
113
113
|
}
|
|
114
|
-
return
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
117
|
-
}, once: function(t, e,
|
|
118
|
-
var
|
|
114
|
+
return et = 1, o.prototype = { on: function(t, e, n) {
|
|
115
|
+
var r = this.e || (this.e = {});
|
|
116
|
+
return (r[t] || (r[t] = [])).push({ fn: e, ctx: n }), this;
|
|
117
|
+
}, once: function(t, e, n) {
|
|
118
|
+
var r = this;
|
|
119
119
|
function s() {
|
|
120
|
-
|
|
120
|
+
r.off(t, s), e.apply(n, arguments);
|
|
121
121
|
}
|
|
122
|
-
return s._ = e, this.on(t, s,
|
|
122
|
+
return s._ = e, this.on(t, s, n);
|
|
123
123
|
}, emit: function(t) {
|
|
124
|
-
for (var e = [].slice.call(arguments, 1),
|
|
124
|
+
for (var e = [].slice.call(arguments, 1), n = ((this.e || (this.e = {}))[t] || []).slice(), r = 0, s = n.length; r < s; r++) n[r].fn.apply(n[r].ctx, e);
|
|
125
125
|
return this;
|
|
126
126
|
}, off: function(t, e) {
|
|
127
|
-
var
|
|
128
|
-
if (
|
|
129
|
-
return s.length ?
|
|
130
|
-
} },
|
|
131
|
-
})(),
|
|
127
|
+
var n = this.e || (this.e = {}), r = n[t], s = [];
|
|
128
|
+
if (r && e) for (var i = 0, a = r.length; i < a; i++) r[i].fn !== e && r[i].fn._ !== e && s.push(r[i]);
|
|
129
|
+
return s.length ? n[t] = s : delete n[t], this;
|
|
130
|
+
} }, K.exports = o, K.exports.TinyEmitter = o, K.exports;
|
|
131
|
+
})(), J = function(o) {
|
|
132
132
|
var t = o[1];
|
|
133
133
|
return t != null;
|
|
134
|
-
},
|
|
135
|
-
var t = o.properties, e = t === void 0 ? {} : t,
|
|
136
|
-
var
|
|
137
|
-
for (var l in s) Object.prototype.hasOwnProperty.call(s, l) && i.indexOf(l) < 0 && (
|
|
134
|
+
}, Rt = function(o) {
|
|
135
|
+
var t = o.properties, e = t === void 0 ? {} : t, n = (function(s, i) {
|
|
136
|
+
var a = {};
|
|
137
|
+
for (var l in s) Object.prototype.hasOwnProperty.call(s, l) && i.indexOf(l) < 0 && (a[l] = s[l]);
|
|
138
138
|
if (s != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
139
139
|
var c = 0;
|
|
140
|
-
for (l = Object.getOwnPropertySymbols(s); c < l.length; c++) i.indexOf(l[c]) < 0 && Object.prototype.propertyIsEnumerable.call(s, l[c]) && (
|
|
140
|
+
for (l = Object.getOwnPropertySymbols(s); c < l.length; c++) i.indexOf(l[c]) < 0 && Object.prototype.propertyIsEnumerable.call(s, l[c]) && (a[l[c]] = s[l[c]]);
|
|
141
141
|
}
|
|
142
|
-
return
|
|
143
|
-
})(o, ["properties"]),
|
|
144
|
-
return Object.entries(s).sort((function(i,
|
|
145
|
-
var l = i[0], c =
|
|
142
|
+
return a;
|
|
143
|
+
})(o, ["properties"]), r = function(s) {
|
|
144
|
+
return Object.entries(s).sort((function(i, a) {
|
|
145
|
+
var l = i[0], c = a[0];
|
|
146
146
|
return l.localeCompare(c, void 0);
|
|
147
147
|
}));
|
|
148
148
|
};
|
|
149
|
-
return JSON.stringify([n
|
|
150
|
-
},
|
|
149
|
+
return JSON.stringify([r(n), r(e)]);
|
|
150
|
+
}, rt = function(o) {
|
|
151
151
|
return g(void 0, void 0, void 0, (function() {
|
|
152
152
|
var t;
|
|
153
153
|
return y(this, (function(e) {
|
|
154
154
|
switch (e.label) {
|
|
155
155
|
case 0:
|
|
156
|
-
t =
|
|
156
|
+
t = Rt(o), e.label = 1;
|
|
157
157
|
case 1:
|
|
158
|
-
return e.trys.push([1, 3, , 4]), [4, (
|
|
159
|
-
var
|
|
158
|
+
return e.trys.push([1, 3, , 4]), [4, (n = t, g(void 0, void 0, void 0, (function() {
|
|
159
|
+
var r, s, i, a, l;
|
|
160
160
|
return y(this, (function(c) {
|
|
161
161
|
switch (c.label) {
|
|
162
162
|
case 0:
|
|
163
|
-
if (
|
|
164
|
-
return s = new TextEncoder().encode(
|
|
163
|
+
if (r = typeof globalThis < "u" && (!((a = globalThis.crypto) === null || a === void 0) && a.subtle) ? (l = globalThis.crypto) === null || l === void 0 ? void 0 : l.subtle : void 0, typeof TextEncoder > "u" || !(r != null && r.digest) || typeof Uint8Array > "u") throw new Error("Hashing function not available");
|
|
164
|
+
return s = new TextEncoder().encode(n), [4, r.digest("SHA-256", s)];
|
|
165
165
|
case 1:
|
|
166
|
-
return i = c.sent(), [2, Array.from(new Uint8Array(i)).map((function(
|
|
167
|
-
return
|
|
166
|
+
return i = c.sent(), [2, Array.from(new Uint8Array(i)).map((function(u) {
|
|
167
|
+
return u.toString(16).padStart(2, "0");
|
|
168
168
|
})).join("")];
|
|
169
169
|
}
|
|
170
170
|
}));
|
|
@@ -176,25 +176,25 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
176
176
|
case 4:
|
|
177
177
|
return [2];
|
|
178
178
|
}
|
|
179
|
-
var
|
|
179
|
+
var n;
|
|
180
180
|
}));
|
|
181
181
|
}));
|
|
182
|
-
},
|
|
183
|
-
var t, e = o.clientKey,
|
|
184
|
-
return c && (
|
|
182
|
+
}, ct = function(o) {
|
|
183
|
+
var t, e = o.clientKey, n = o.appName, r = o.connectionId, s = o.customHeaders, i = o.headerName, a = i === void 0 ? "authorization" : i, l = o.etag, c = o.isPost, u = ((t = { accept: "application/json" })[a.toLocaleLowerCase()] = e, t["unleash-sdk"] = "unleash-js-sdk:3.8.3", t["unleash-appname"] = n, t);
|
|
184
|
+
return c && (u["content-type"] = "application/json"), l && (u["if-none-match"] = l), Object.entries(s || {}).filter(J).forEach((function(f) {
|
|
185
185
|
var x = f[0], T = f[1];
|
|
186
|
-
return
|
|
187
|
-
})),
|
|
188
|
-
},
|
|
186
|
+
return u[x.toLocaleLowerCase()] = T;
|
|
187
|
+
})), u["unleash-connection-id"] = r, u;
|
|
188
|
+
}, St = function() {
|
|
189
189
|
}, wt = (function() {
|
|
190
190
|
function o(t) {
|
|
191
|
-
var e = t.onError,
|
|
192
|
-
this.onError = e, this.onSent =
|
|
191
|
+
var e = t.onError, n = t.onSent, r = t.appName, s = t.metricsInterval, i = t.disableMetrics, a = i !== void 0 && i, l = t.url, c = t.clientKey, u = t.fetch, f = t.headerName, x = t.customHeaders, T = x === void 0 ? {} : x, b = t.metricsIntervalInitial, R = t.connectionId, S = t.metricRegistry;
|
|
192
|
+
this.onError = e, this.onSent = n || St, this.disabled = a, this.metricsInterval = 1e3 * s, this.metricsIntervalInitial = 1e3 * b, this.appName = r, this.url = l instanceof URL ? l : new URL(l), this.clientKey = c, this.bucket = this.createEmptyBucket(), this.fetch = u, this.headerName = f, this.customHeaders = T, this.connectionId = R, this.metricRegistry = S;
|
|
193
193
|
}
|
|
194
194
|
return o.prototype.start = function() {
|
|
195
195
|
var t = this;
|
|
196
|
-
if (this.disabled) return !1;
|
|
197
|
-
this.setupMetricsFlushOnPageUnload(), typeof this.metricsInterval == "number" && this.metricsInterval > 0 && (this.metricsIntervalInitial > 0 ? setTimeout((function() {
|
|
196
|
+
if (this.disabled || this.timer || this.flushMetricsOnPageUnload) return !1;
|
|
197
|
+
this.setupMetricsFlushOnPageUnload(), typeof this.metricsInterval == "number" && this.metricsInterval > 0 && (this.metricsIntervalInitial > 0 ? this.timer = setTimeout((function() {
|
|
198
198
|
t.startTimer(), t.sendMetrics();
|
|
199
199
|
}), this.metricsIntervalInitial) : this.startTimer());
|
|
200
200
|
}, o.prototype.stop = function() {
|
|
@@ -202,21 +202,21 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
202
202
|
}, o.prototype.createEmptyBucket = function() {
|
|
203
203
|
return { start: /* @__PURE__ */ new Date(), stop: null, toggles: {} };
|
|
204
204
|
}, o.prototype.getHeaders = function() {
|
|
205
|
-
return
|
|
205
|
+
return ct({ clientKey: this.clientKey, appName: this.appName, connectionId: this.connectionId, customHeaders: this.customHeaders, headerName: this.headerName, isPost: !0 });
|
|
206
206
|
}, o.prototype.sendMetrics = function() {
|
|
207
207
|
return g(this, arguments, void 0, (function(t) {
|
|
208
|
-
var e,
|
|
209
|
-
return y(this, (function(
|
|
210
|
-
switch (
|
|
208
|
+
var e, n, r, s = (t === void 0 ? {} : t).fireAndForget, i = s !== void 0 && s;
|
|
209
|
+
return y(this, (function(a) {
|
|
210
|
+
switch (a.label) {
|
|
211
211
|
case 0:
|
|
212
|
-
if (e = "".concat(this.url.toString().replace(/\/$/, ""), "/client/metrics"),
|
|
213
|
-
|
|
212
|
+
if (e = "".concat(this.url.toString().replace(/\/$/, ""), "/client/metrics"), n = this.getPayload(), this.bucketIsEmpty(n) && (!n.impactMetrics || n.impactMetrics.length === 0)) return [2];
|
|
213
|
+
a.label = 1;
|
|
214
214
|
case 1:
|
|
215
|
-
return
|
|
215
|
+
return a.trys.push([1, 3, , 4]), [4, this.fetch(e, { cache: "no-cache", method: "POST", headers: this.getHeaders(), body: JSON.stringify(n), keepalive: i })];
|
|
216
216
|
case 2:
|
|
217
|
-
return
|
|
217
|
+
return a.sent(), this.onSent(n), [3, 4];
|
|
218
218
|
case 3:
|
|
219
|
-
return
|
|
219
|
+
return r = a.sent(), console.error("Unleash: unable to send feature metrics", r), this.onError(r), [3, 4];
|
|
220
220
|
case 4:
|
|
221
221
|
return [2];
|
|
222
222
|
}
|
|
@@ -239,8 +239,8 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
239
239
|
}, o.prototype.getPayload = function() {
|
|
240
240
|
var t, e = p(p({}, this.bucket), { stop: /* @__PURE__ */ new Date() });
|
|
241
241
|
this.bucket = this.createEmptyBucket();
|
|
242
|
-
var
|
|
243
|
-
return
|
|
242
|
+
var n = { bucket: e, appName: this.appName, instanceId: "browser" }, r = ((t = this.metricRegistry) === null || t === void 0 ? void 0 : t.collect()) || [];
|
|
243
|
+
return n.impactMetrics = r, n;
|
|
244
244
|
}, o.prototype.setupMetricsFlushOnPageUnload = function() {
|
|
245
245
|
var t = this;
|
|
246
246
|
typeof document > "u" || typeof window > "u" || typeof document.addEventListener != "function" || document.addEventListener("visibilitychange", this.flushMetricsOnPageUnload = function() {
|
|
@@ -249,13 +249,13 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
249
249
|
}, o.prototype.removeMetricsFlushOnPageUnload = function() {
|
|
250
250
|
this.flushMetricsOnPageUnload && (document.removeEventListener("visibilitychange", this.flushMetricsOnPageUnload), this.flushMetricsOnPageUnload = void 0);
|
|
251
251
|
}, o;
|
|
252
|
-
})(),
|
|
252
|
+
})(), It = (function() {
|
|
253
253
|
function o() {
|
|
254
254
|
this.store = /* @__PURE__ */ new Map();
|
|
255
255
|
}
|
|
256
256
|
return o.prototype.save = function(t, e) {
|
|
257
257
|
return g(this, void 0, void 0, (function() {
|
|
258
|
-
return y(this, (function(
|
|
258
|
+
return y(this, (function(n) {
|
|
259
259
|
return this.store.set(t, e), [2];
|
|
260
260
|
}));
|
|
261
261
|
}));
|
|
@@ -266,17 +266,17 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
266
266
|
}));
|
|
267
267
|
}));
|
|
268
268
|
}, o;
|
|
269
|
-
})(),
|
|
269
|
+
})(), kt = (function() {
|
|
270
270
|
function o(t) {
|
|
271
271
|
t === void 0 && (t = "unleash:repository"), this.prefix = t;
|
|
272
272
|
}
|
|
273
273
|
return o.prototype.save = function(t, e) {
|
|
274
274
|
return g(this, void 0, void 0, (function() {
|
|
275
|
-
var
|
|
275
|
+
var n, r;
|
|
276
276
|
return y(this, (function(s) {
|
|
277
|
-
|
|
277
|
+
n = JSON.stringify(e), r = "".concat(this.prefix, ":").concat(t);
|
|
278
278
|
try {
|
|
279
|
-
window.localStorage.setItem(
|
|
279
|
+
window.localStorage.setItem(r, n);
|
|
280
280
|
} catch (i) {
|
|
281
281
|
console.error(i);
|
|
282
282
|
}
|
|
@@ -285,108 +285,108 @@ var Z, P = { exports: {} }, st = (function() {
|
|
|
285
285
|
}));
|
|
286
286
|
}, o.prototype.get = function(t) {
|
|
287
287
|
try {
|
|
288
|
-
var e = "".concat(this.prefix, ":").concat(t),
|
|
289
|
-
return
|
|
290
|
-
} catch (
|
|
291
|
-
console.error(
|
|
288
|
+
var e = "".concat(this.prefix, ":").concat(t), n = window.localStorage.getItem(e);
|
|
289
|
+
return n ? JSON.parse(n) : void 0;
|
|
290
|
+
} catch (r) {
|
|
291
|
+
console.error(r);
|
|
292
292
|
}
|
|
293
293
|
}, o;
|
|
294
|
-
})(),
|
|
294
|
+
})(), lt = function() {
|
|
295
295
|
var o;
|
|
296
296
|
return typeof globalThis < "u" && (!((o = globalThis.crypto) === null || o === void 0) && o.randomUUID) ? globalThis.crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (function(t) {
|
|
297
297
|
var e = 16 * Math.random() | 0;
|
|
298
298
|
return (t === "x" ? e : 3 & e | 8).toString(16);
|
|
299
299
|
}));
|
|
300
|
-
},
|
|
300
|
+
}, Ot = (function() {
|
|
301
301
|
function o() {
|
|
302
302
|
}
|
|
303
303
|
return o.prototype.generateEventId = function() {
|
|
304
|
-
return
|
|
305
|
-
}, o.prototype.createImpressionEvent = function(t, e,
|
|
306
|
-
var
|
|
307
|
-
return i ? p(p({},
|
|
308
|
-
}, o.prototype.createBaseEvent = function(t, e,
|
|
309
|
-
return { eventType:
|
|
304
|
+
return lt();
|
|
305
|
+
}, o.prototype.createImpressionEvent = function(t, e, n, r, s, i) {
|
|
306
|
+
var a = this.createBaseEvent(t, e, n, r, s);
|
|
307
|
+
return i ? p(p({}, a), { variant: i }) : a;
|
|
308
|
+
}, o.prototype.createBaseEvent = function(t, e, n, r, s) {
|
|
309
|
+
return { eventType: r, eventId: this.generateEventId(), context: t, enabled: e, featureName: n, impressionData: s };
|
|
310
310
|
}, o;
|
|
311
311
|
})();
|
|
312
|
-
function
|
|
312
|
+
function ht(o) {
|
|
313
313
|
return o !== void 0 && !Number.isFinite(o);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function W(o) {
|
|
316
316
|
return o ? Object.keys(o).sort().map((function(t) {
|
|
317
317
|
return "".concat(t, "=").concat(o[t]);
|
|
318
318
|
})).join(",") : "";
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function ft(o) {
|
|
321
321
|
var t = {};
|
|
322
322
|
if (!o) return t;
|
|
323
|
-
for (var e = 0,
|
|
324
|
-
var
|
|
323
|
+
for (var e = 0, n = o.split(","); e < n.length; e++) {
|
|
324
|
+
var r = n[e].split("="), s = r[0], i = r[1];
|
|
325
325
|
t[s] = i;
|
|
326
326
|
}
|
|
327
327
|
return t;
|
|
328
328
|
}
|
|
329
|
-
var
|
|
329
|
+
var Nt = function(o) {
|
|
330
330
|
return "value" in o;
|
|
331
|
-
},
|
|
331
|
+
}, nt = function(o) {
|
|
332
332
|
return "buckets" in o;
|
|
333
|
-
},
|
|
333
|
+
}, Ct = (function() {
|
|
334
334
|
function o(t) {
|
|
335
335
|
this.opts = t, this.values = /* @__PURE__ */ new Map();
|
|
336
336
|
}
|
|
337
337
|
return o.prototype.inc = function(t, e) {
|
|
338
|
-
var
|
|
339
|
-
if (!
|
|
340
|
-
var
|
|
341
|
-
if (!(
|
|
342
|
-
var s =
|
|
343
|
-
this.values.set(s, i +
|
|
338
|
+
var n;
|
|
339
|
+
if (!ht(t)) {
|
|
340
|
+
var r = t ?? 1;
|
|
341
|
+
if (!(r <= 0)) {
|
|
342
|
+
var s = W(e), i = (n = this.values.get(s)) !== null && n !== void 0 ? n : 0;
|
|
343
|
+
this.values.set(s, i + r);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}, o.prototype.collect = function() {
|
|
347
347
|
var t = Array.from(this.values.entries()).map((function(e) {
|
|
348
|
-
var
|
|
349
|
-
return { labels:
|
|
348
|
+
var n = e[0], r = e[1];
|
|
349
|
+
return { labels: ft(n), value: r };
|
|
350
350
|
}));
|
|
351
351
|
return this.values.clear(), t.length === 0 && t.push({ labels: {}, value: 0 }), { name: this.opts.name, help: this.opts.help, type: "counter", samples: t };
|
|
352
352
|
}, o;
|
|
353
|
-
})(),
|
|
353
|
+
})(), Ut = (function() {
|
|
354
354
|
function o(t) {
|
|
355
355
|
this.opts = t, this.values = /* @__PURE__ */ new Map();
|
|
356
|
-
var e = t.buckets && t.buckets.length > 0 ? t.buckets : [5e-3, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
357
|
-
return
|
|
358
|
-
})))).sort((function(
|
|
359
|
-
return
|
|
356
|
+
var e = t.buckets && t.buckets.length > 0 ? t.buckets : [5e-3, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10], n = Array.from(new Set(e.filter((function(r) {
|
|
357
|
+
return r !== 1 / 0;
|
|
358
|
+
})))).sort((function(r, s) {
|
|
359
|
+
return r - s;
|
|
360
360
|
}));
|
|
361
|
-
this.buckets =
|
|
361
|
+
this.buckets = j(j([], n, !0), [1 / 0], !1);
|
|
362
362
|
}
|
|
363
363
|
return o.prototype.restore = function(t) {
|
|
364
|
-
var e =
|
|
365
|
-
return [
|
|
364
|
+
var e = W(t.labels), n = { count: t.count, sum: t.sum, buckets: new Map(t.buckets.map((function(r) {
|
|
365
|
+
return [r.le === "+Inf" ? 1 / 0 : r.le, r.count];
|
|
366
366
|
}))) };
|
|
367
|
-
this.values.set(e,
|
|
367
|
+
this.values.set(e, n);
|
|
368
368
|
}, o.prototype.observe = function(t, e) {
|
|
369
|
-
var
|
|
370
|
-
if (!
|
|
371
|
-
var
|
|
369
|
+
var n;
|
|
370
|
+
if (!ht(t)) {
|
|
371
|
+
var r = W(e), s = this.values.get(r);
|
|
372
372
|
if (!s) {
|
|
373
|
-
for (var i = /* @__PURE__ */ new Map(),
|
|
374
|
-
var c = l[
|
|
373
|
+
for (var i = /* @__PURE__ */ new Map(), a = 0, l = this.buckets; a < l.length; a++) {
|
|
374
|
+
var c = l[a];
|
|
375
375
|
i.set(c, 0);
|
|
376
376
|
}
|
|
377
|
-
s = { count: 0, sum: 0, buckets: i }, this.values.set(
|
|
377
|
+
s = { count: 0, sum: 0, buckets: i }, this.values.set(r, s);
|
|
378
378
|
}
|
|
379
379
|
s.count++, s.sum += t;
|
|
380
|
-
for (var
|
|
381
|
-
if (t <= (c = f[
|
|
382
|
-
var x = (
|
|
380
|
+
for (var u = 0, f = this.buckets; u < f.length; u++)
|
|
381
|
+
if (t <= (c = f[u])) {
|
|
382
|
+
var x = (n = s.buckets.get(c)) !== null && n !== void 0 ? n : 0;
|
|
383
383
|
s.buckets.set(c, x + 1);
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
}, o.prototype.collect = function() {
|
|
387
387
|
var t = Array.from(this.values.entries()).map((function(e) {
|
|
388
|
-
var
|
|
389
|
-
return { labels:
|
|
388
|
+
var n = e[0], r = e[1];
|
|
389
|
+
return { labels: ft(n), count: r.count, sum: r.sum, buckets: Array.from(r.buckets.entries()).map((function(s) {
|
|
390
390
|
var i = s[0];
|
|
391
391
|
return { le: i === 1 / 0 ? "+Inf" : i, count: s[1] };
|
|
392
392
|
})) };
|
|
@@ -395,7 +395,7 @@ var kt = function(o) {
|
|
|
395
395
|
return { le: e === 1 / 0 ? "+Inf" : e, count: 0 };
|
|
396
396
|
})) }), { name: this.opts.name, help: this.opts.help, type: "histogram", samples: t };
|
|
397
397
|
}, o;
|
|
398
|
-
})(),
|
|
398
|
+
})(), At = (function() {
|
|
399
399
|
function o() {
|
|
400
400
|
this.counters = /* @__PURE__ */ new Map(), this.histograms = /* @__PURE__ */ new Map();
|
|
401
401
|
}
|
|
@@ -404,77 +404,77 @@ var kt = function(o) {
|
|
|
404
404
|
}, o.prototype.getHistogram = function(t) {
|
|
405
405
|
return this.histograms.get(t);
|
|
406
406
|
}, o.prototype.counter = function(t) {
|
|
407
|
-
var e = t.name,
|
|
408
|
-
return
|
|
407
|
+
var e = t.name, n = this.counters.get(e);
|
|
408
|
+
return n || (n = new Ct(t), this.counters.set(e, n)), n;
|
|
409
409
|
}, o.prototype.histogram = function(t) {
|
|
410
|
-
var e = t.name,
|
|
411
|
-
return
|
|
410
|
+
var e = t.name, n = this.histograms.get(e);
|
|
411
|
+
return n || (n = new Ut(t), this.histograms.set(e, n)), n;
|
|
412
412
|
}, o.prototype.collect = function() {
|
|
413
|
-
var t = Array.from(this.counters.values()).map((function(
|
|
414
|
-
return
|
|
415
|
-
})), e = Array.from(this.histograms.values()).map((function(
|
|
416
|
-
return
|
|
417
|
-
})),
|
|
418
|
-
return
|
|
413
|
+
var t = Array.from(this.counters.values()).map((function(r) {
|
|
414
|
+
return r.collect();
|
|
415
|
+
})), e = Array.from(this.histograms.values()).map((function(r) {
|
|
416
|
+
return r.collect();
|
|
417
|
+
})), n = j(j([], t, !0), e, !0).filter((function(r) {
|
|
418
|
+
return r.samples.length > 0;
|
|
419
419
|
}));
|
|
420
|
-
return
|
|
420
|
+
return n.length > 0 ? n : [];
|
|
421
421
|
}, o.prototype.restore = function(t) {
|
|
422
422
|
for (var e = function(i) {
|
|
423
423
|
switch (i.type) {
|
|
424
424
|
case "counter":
|
|
425
|
-
for (var
|
|
426
|
-
var
|
|
427
|
-
|
|
425
|
+
for (var a = n.counter({ name: i.name, help: i.help }), l = 0, c = i.samples; l < c.length; l++) {
|
|
426
|
+
var u = c[l];
|
|
427
|
+
Nt(u) && a.inc(u.value, u.labels);
|
|
428
428
|
}
|
|
429
429
|
break;
|
|
430
430
|
case "histogram":
|
|
431
|
-
var f = i.samples.find(
|
|
431
|
+
var f = i.samples.find(nt);
|
|
432
432
|
if (f) {
|
|
433
433
|
var x = f.buckets.map((function(b) {
|
|
434
434
|
return b.le === "+Inf" ? 1 / 0 : b.le;
|
|
435
|
-
})), T =
|
|
436
|
-
i.samples.filter(
|
|
435
|
+
})), T = n.histogram({ name: i.name, help: i.help, buckets: x });
|
|
436
|
+
i.samples.filter(nt).forEach((function(b) {
|
|
437
437
|
T.restore(b);
|
|
438
438
|
}));
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
},
|
|
442
|
-
e(s[
|
|
441
|
+
}, n = this, r = 0, s = t; r < s.length; r++)
|
|
442
|
+
e(s[r]);
|
|
443
443
|
}, o;
|
|
444
|
-
})(), m = { INIT: "initialized", ERROR: "error", READY: "ready", UPDATE: "update", IMPRESSION: "impression", SENT: "sent", RECOVERED: "recovered", WARN: "warn" },
|
|
445
|
-
function t(e,
|
|
444
|
+
})(), m = { INIT: "initialized", ERROR: "error", READY: "ready", UPDATE: "update", IMPRESSION: "impression", SENT: "sent", RECOVERED: "recovered", WARN: "warn" }, Pt = (function(o) {
|
|
445
|
+
function t(e, n, r) {
|
|
446
446
|
var s = o.call(this) || this;
|
|
447
|
-
return s.metricRegistry = e, s.appName =
|
|
447
|
+
return s.metricRegistry = e, s.appName = n, s.environment = r, s;
|
|
448
448
|
}
|
|
449
|
-
return
|
|
450
|
-
e &&
|
|
451
|
-
}, t.prototype.defineHistogram = function(e,
|
|
452
|
-
e &&
|
|
453
|
-
}, t.prototype.incrementCounter = function(e,
|
|
454
|
-
var
|
|
455
|
-
if (
|
|
449
|
+
return at(t, o), t.prototype.defineCounter = function(e, n) {
|
|
450
|
+
e && n ? this.metricRegistry.counter({ name: e, help: n, labelNames: ["featureName", "appName", "environment"] }) : this.emit(m.WARN, "Counter name or help cannot be empty: ".concat(e, ", ").concat(n, "."));
|
|
451
|
+
}, t.prototype.defineHistogram = function(e, n, r) {
|
|
452
|
+
e && n ? this.metricRegistry.histogram({ name: e, help: n, labelNames: ["featureName", "appName", "environment"], buckets: r }) : this.emit(m.WARN, "Histogram name or help cannot be empty: ".concat(e, ", ").concat(n, "."));
|
|
453
|
+
}, t.prototype.incrementCounter = function(e, n) {
|
|
454
|
+
var r = this.metricRegistry.getCounter(e);
|
|
455
|
+
if (r) {
|
|
456
456
|
var s = { appName: this.appName, environment: this.environment };
|
|
457
|
-
|
|
457
|
+
r.inc(n, s);
|
|
458
458
|
} else this.emit(m.WARN, "Counter ".concat(e, " not defined, this counter will not be incremented."));
|
|
459
|
-
}, t.prototype.observeHistogram = function(e,
|
|
460
|
-
var
|
|
461
|
-
if (
|
|
459
|
+
}, t.prototype.observeHistogram = function(e, n) {
|
|
460
|
+
var r = this.metricRegistry.getHistogram(e);
|
|
461
|
+
if (r) {
|
|
462
462
|
var s = { appName: this.appName, environment: this.environment };
|
|
463
|
-
|
|
463
|
+
r.observe(n, s);
|
|
464
464
|
} else this.emit(m.WARN, "Histogram ".concat(e, " not defined, this histogram will not be updated."));
|
|
465
465
|
}, t;
|
|
466
|
-
})(
|
|
467
|
-
return
|
|
468
|
-
},
|
|
466
|
+
})(ut.TinyEmitter), Mt = ["userId", "sessionId", "remoteAddress", "currentTime"], ot = function(o) {
|
|
467
|
+
return Mt.includes(o);
|
|
468
|
+
}, Lt = "isEnabled", Ht = "getVariant", Dt = { name: "disabled", enabled: !1, feature_enabled: !1 }, q = "repo", st = "repoLastUpdateTimestamp", jt = function() {
|
|
469
469
|
try {
|
|
470
470
|
if (typeof window < "u" && "fetch" in window) return fetch.bind(window);
|
|
471
471
|
if ("fetch" in globalThis) return fetch.bind(globalThis);
|
|
472
472
|
} catch (o) {
|
|
473
473
|
console.error('Unleash failed to resolve "fetch"', o);
|
|
474
474
|
}
|
|
475
|
-
},
|
|
475
|
+
}, Ft = (function(o) {
|
|
476
476
|
function t(e) {
|
|
477
|
-
var
|
|
477
|
+
var n, r = e.storageProvider, s = e.url, i = e.clientKey, a = e.disableRefresh, l = a !== void 0 && a, c = e.refreshInterval, u = c === void 0 ? 30 : c, f = e.metricsInterval, x = f === void 0 ? 30 : f, T = e.metricsIntervalInitial, b = T === void 0 ? 2 : T, R = e.disableMetrics, S = R !== void 0 && R, E = e.appName, w = e.environment, N = w === void 0 ? "default" : w, U = e.context, M = e.fetch, A = M === void 0 ? jt() : M, L = e.createAbortController, v = L === void 0 ? (function() {
|
|
478
478
|
try {
|
|
479
479
|
if (typeof window < "u" && "AbortController" in window) return function() {
|
|
480
480
|
return new window.AbortController();
|
|
@@ -482,65 +482,65 @@ var kt = function(o) {
|
|
|
482
482
|
if ("fetch" in globalThis) return function() {
|
|
483
483
|
return new globalThis.AbortController();
|
|
484
484
|
};
|
|
485
|
-
} catch (
|
|
486
|
-
console.error('Unleash failed to resolve "AbortController" factory',
|
|
485
|
+
} catch (P) {
|
|
486
|
+
console.error('Unleash failed to resolve "AbortController" factory', P);
|
|
487
487
|
}
|
|
488
|
-
})() :
|
|
489
|
-
if (h.toggles = [], h.etag = "", h.readyEventEmitted = !1, h.fetchedFromServer = !1, h.usePOSTrequests = !1, h.started = !1, !s) throw new Error("url is required");
|
|
488
|
+
})() : L, d = e.bootstrap, I = e.bootstrapOverride, B = I === void 0 || I, G = e.headerName, $ = G === void 0 ? "Authorization" : G, Q = e.customHeaders, X = Q === void 0 ? {} : Q, Z = e.impressionDataAll, vt = Z !== void 0 && Z, V = e.usePOSTrequests, mt = V !== void 0 && V, k = e.experimental, h = o.call(this) || this;
|
|
489
|
+
if (h.toggles = [], h.etag = "", h.readyEventEmitted = !1, h.fetchedFromServer = !1, h.usePOSTrequests = !1, h.started = !1, h.stopCount = 0, !s) throw new Error("url is required");
|
|
490
490
|
if (!i) throw new Error("clientKey is required");
|
|
491
491
|
if (!E) throw new Error("appName is required.");
|
|
492
|
-
h.eventsHandler = new
|
|
493
|
-
var
|
|
494
|
-
!
|
|
495
|
-
h.init().then(
|
|
496
|
-
console.error(
|
|
492
|
+
h.eventsHandler = new Ot(), h.impressionDataAll = vt, h.toggles = d && d.length > 0 ? d : [], h.url = s instanceof URL ? s : new URL(s), h.clientKey = i, h.headerName = $, h.customHeaders = X, h.storage = r || (typeof window < "u" ? new kt() : new It()), h.refreshInterval = l ? 0 : 1e3 * u, h.context = p({ appName: E, environment: N }, U), h.usePOSTrequests = mt, h.sdkState = "initializing";
|
|
493
|
+
var H = k == null ? void 0 : k.metricsUrl;
|
|
494
|
+
!H || H instanceof URL || (H = new URL(H)), h.experimental = p(p({}, k), { metricsUrl: H }), k != null && k.togglesStorageTTL && (k == null ? void 0 : k.togglesStorageTTL) > 0 && (h.experimental.togglesStorageTTL = 1e3 * k.togglesStorageTTL), h.lastRefreshTimestamp = 0, h.ready = new Promise((function(P) {
|
|
495
|
+
h.init().then(P).catch((function(_) {
|
|
496
|
+
console.error(_), h.sdkState = "error", h.emit(m.ERROR, _), h.lastError = _, P();
|
|
497
497
|
}));
|
|
498
|
-
})),
|
|
499
|
-
var
|
|
500
|
-
return h.impactMetrics = new
|
|
501
|
-
return h.emit(m.ERROR, { type: "metrics", error:
|
|
502
|
-
}, onSent: h.emit.bind(h, m.SENT), appName: E, metricsInterval: x, disableMetrics:
|
|
498
|
+
})), A || console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'), v || console.error('Unleash: You must either provide your own "AbortController" implementation or run in an environment where "AbortController" is available.'), h.fetch = A, h.createAbortController = v, h.bootstrap = d && d.length > 0 ? d : void 0, h.bootstrapOverride = B, h.connectionId = lt(), h.metricRegistry = new At();
|
|
499
|
+
var gt = h.resolveEnvironment(i, N);
|
|
500
|
+
return h.impactMetrics = new Pt(h.metricRegistry, E, gt), h.metrics = new wt({ onError: function(P) {
|
|
501
|
+
return h.emit(m.ERROR, { type: "metrics", error: P });
|
|
502
|
+
}, onSent: h.emit.bind(h, m.SENT), appName: E, metricsInterval: x, disableMetrics: S, url: ((n = h.experimental) === null || n === void 0 ? void 0 : n.metricsUrl) || h.url, clientKey: i, fetch: A, headerName: $, customHeaders: X, metricsIntervalInitial: b, connectionId: h.connectionId, metricRegistry: h.metricRegistry }), h;
|
|
503
503
|
}
|
|
504
|
-
return
|
|
505
|
-
return
|
|
504
|
+
return at(t, o), t.prototype.getAllToggles = function() {
|
|
505
|
+
return j([], this.toggles, !0);
|
|
506
506
|
}, t.prototype.isEnabled = function(e) {
|
|
507
|
-
var
|
|
508
|
-
return
|
|
509
|
-
})), s = !!
|
|
510
|
-
if (this.metrics.count(e, s), (
|
|
511
|
-
var i = this.eventsHandler.createImpressionEvent(this.context, s, e,
|
|
507
|
+
var n, r = this.toggles.find((function(a) {
|
|
508
|
+
return a.name === e;
|
|
509
|
+
})), s = !!r && r.enabled;
|
|
510
|
+
if (this.metrics.count(e, s), (r == null ? void 0 : r.impressionData) || this.impressionDataAll) {
|
|
511
|
+
var i = this.eventsHandler.createImpressionEvent(this.context, s, e, Lt, (n = r == null ? void 0 : r.impressionData) !== null && n !== void 0 ? n : void 0);
|
|
512
512
|
this.emit(m.IMPRESSION, i);
|
|
513
513
|
}
|
|
514
514
|
return s;
|
|
515
515
|
}, t.prototype.getVariant = function(e) {
|
|
516
|
-
var
|
|
516
|
+
var n, r = this.toggles.find((function(l) {
|
|
517
517
|
return l.name === e;
|
|
518
|
-
})), s = (
|
|
519
|
-
if (i.name && this.metrics.countVariant(e, i.name), this.metrics.count(e, s), (
|
|
520
|
-
var
|
|
521
|
-
this.emit(m.IMPRESSION,
|
|
518
|
+
})), s = (r == null ? void 0 : r.enabled) || !1, i = r ? r.variant : Dt;
|
|
519
|
+
if (i.name && this.metrics.countVariant(e, i.name), this.metrics.count(e, s), (r == null ? void 0 : r.impressionData) || this.impressionDataAll) {
|
|
520
|
+
var a = this.eventsHandler.createImpressionEvent(this.context, s, e, Ht, (n = r == null ? void 0 : r.impressionData) !== null && n !== void 0 ? n : void 0, i.name);
|
|
521
|
+
this.emit(m.IMPRESSION, a);
|
|
522
522
|
}
|
|
523
523
|
return p(p({}, i), { feature_enabled: s });
|
|
524
524
|
}, t.prototype.updateToggles = function() {
|
|
525
525
|
return g(this, void 0, void 0, (function() {
|
|
526
526
|
var e = this;
|
|
527
|
-
return y(this, (function(
|
|
528
|
-
switch (
|
|
527
|
+
return y(this, (function(n) {
|
|
528
|
+
switch (n.label) {
|
|
529
529
|
case 0:
|
|
530
530
|
return this.timerRef || this.fetchedFromServer ? [4, this.fetchToggles()] : [3, 2];
|
|
531
531
|
case 1:
|
|
532
|
-
return
|
|
532
|
+
return n.sent(), [3, 4];
|
|
533
533
|
case 2:
|
|
534
|
-
return this.started ? [4, new Promise((function(
|
|
534
|
+
return this.started ? [4, new Promise((function(r) {
|
|
535
535
|
var s = function() {
|
|
536
536
|
e.fetchToggles().then((function() {
|
|
537
|
-
e.off(m.READY, s),
|
|
537
|
+
e.off(m.READY, s), r();
|
|
538
538
|
}));
|
|
539
539
|
};
|
|
540
540
|
e.once(m.READY, s);
|
|
541
541
|
}))] : [3, 4];
|
|
542
542
|
case 3:
|
|
543
|
-
|
|
543
|
+
n.sent(), n.label = 4;
|
|
544
544
|
case 4:
|
|
545
545
|
return [2];
|
|
546
546
|
}
|
|
@@ -548,39 +548,39 @@ var kt = function(o) {
|
|
|
548
548
|
}));
|
|
549
549
|
}, t.prototype.updateContext = function(e) {
|
|
550
550
|
return g(this, void 0, void 0, (function() {
|
|
551
|
-
var
|
|
552
|
-
return y(this, (function(
|
|
553
|
-
switch (
|
|
551
|
+
var n;
|
|
552
|
+
return y(this, (function(r) {
|
|
553
|
+
switch (r.label) {
|
|
554
554
|
case 0:
|
|
555
|
-
return
|
|
555
|
+
return n = { environment: this.context.environment, appName: this.context.appName, sessionId: this.context.sessionId }, this.context = p(p({}, n), e), [4, this.updateToggles()];
|
|
556
556
|
case 1:
|
|
557
|
-
return
|
|
557
|
+
return r.sent(), [2];
|
|
558
558
|
}
|
|
559
559
|
}));
|
|
560
560
|
}));
|
|
561
561
|
}, t.prototype.getContext = function() {
|
|
562
562
|
return p({}, this.context);
|
|
563
|
-
}, t.prototype.setContextField = function(e,
|
|
563
|
+
}, t.prototype.setContextField = function(e, n) {
|
|
564
564
|
return g(this, void 0, void 0, (function() {
|
|
565
|
-
var
|
|
566
|
-
return y(this, (function(
|
|
567
|
-
switch (
|
|
565
|
+
var r, s, i;
|
|
566
|
+
return y(this, (function(a) {
|
|
567
|
+
switch (a.label) {
|
|
568
568
|
case 0:
|
|
569
|
-
return
|
|
569
|
+
return ot(e) ? this.context = p(p({}, this.context), ((s = {})[e] = n, s)) : (r = p(p({}, this.context.properties), ((i = {})[e] = n, i)), this.context = p(p({}, this.context), { properties: r })), [4, this.updateToggles()];
|
|
570
570
|
case 1:
|
|
571
|
-
return
|
|
571
|
+
return a.sent(), [2];
|
|
572
572
|
}
|
|
573
573
|
}));
|
|
574
574
|
}));
|
|
575
575
|
}, t.prototype.removeContextField = function(e) {
|
|
576
576
|
return g(this, void 0, void 0, (function() {
|
|
577
|
-
var
|
|
578
|
-
return y(this, (function(
|
|
579
|
-
switch (
|
|
577
|
+
var n;
|
|
578
|
+
return y(this, (function(r) {
|
|
579
|
+
switch (r.label) {
|
|
580
580
|
case 0:
|
|
581
|
-
return
|
|
581
|
+
return ot(e) ? this.context = p(p({}, this.context), ((n = {})[e] = void 0, n)) : typeof this.context.properties == "object" && delete this.context.properties[e], [4, this.updateToggles()];
|
|
582
582
|
case 1:
|
|
583
|
-
return
|
|
583
|
+
return r.sent(), [2];
|
|
584
584
|
}
|
|
585
585
|
}));
|
|
586
586
|
}));
|
|
@@ -588,23 +588,23 @@ var kt = function(o) {
|
|
|
588
588
|
this.readyEventEmitted = !0, this.emit(m.READY);
|
|
589
589
|
}, t.prototype.init = function() {
|
|
590
590
|
return g(this, void 0, void 0, (function() {
|
|
591
|
-
var e,
|
|
591
|
+
var e, n, r;
|
|
592
592
|
return y(this, (function(s) {
|
|
593
593
|
switch (s.label) {
|
|
594
594
|
case 0:
|
|
595
595
|
return [4, this.resolveSessionId()];
|
|
596
596
|
case 1:
|
|
597
|
-
return e = s.sent(), this.context = p({ sessionId: e }, this.context), [4, this.storage.get(
|
|
597
|
+
return e = s.sent(), this.context = p({ sessionId: e }, this.context), [4, this.storage.get(q)];
|
|
598
598
|
case 2:
|
|
599
|
-
return
|
|
599
|
+
return n = s.sent() || [], r = this, [4, this.getLastRefreshTimestamp()];
|
|
600
600
|
case 3:
|
|
601
|
-
return
|
|
601
|
+
return r.lastRefreshTimestamp = s.sent(), !this.bootstrap || !this.bootstrapOverride && n.length !== 0 ? [3, 6] : [4, this.storage.save(q, this.bootstrap)];
|
|
602
602
|
case 4:
|
|
603
603
|
return s.sent(), this.toggles = this.bootstrap, this.sdkState = "healthy", [4, this.storeLastRefreshTimestamp()];
|
|
604
604
|
case 5:
|
|
605
605
|
return s.sent(), this.setReady(), [3, 7];
|
|
606
606
|
case 6:
|
|
607
|
-
this.toggles =
|
|
607
|
+
this.toggles = n, s.label = 7;
|
|
608
608
|
case 7:
|
|
609
609
|
return this.sdkState = "healthy", this.emit(m.INIT), [2];
|
|
610
610
|
}
|
|
@@ -612,22 +612,22 @@ var kt = function(o) {
|
|
|
612
612
|
}));
|
|
613
613
|
}, t.prototype.start = function() {
|
|
614
614
|
return g(this, void 0, void 0, (function() {
|
|
615
|
-
var e, r = this;
|
|
616
|
-
return y(this, (function(
|
|
617
|
-
switch (
|
|
615
|
+
var e, n, r = this;
|
|
616
|
+
return y(this, (function(s) {
|
|
617
|
+
switch (s.label) {
|
|
618
618
|
case 0:
|
|
619
|
-
return this.started = !0, 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];
|
|
619
|
+
return this.started = !0, e = this.stopCount, 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];
|
|
620
620
|
case 1:
|
|
621
|
-
return
|
|
621
|
+
return s.sent(), this.stopCount === e && this.metrics.start(), n = this.refreshInterval, [4, this.initialFetchToggles()];
|
|
622
622
|
case 2:
|
|
623
|
-
return
|
|
623
|
+
return s.sent(), this.stopCount === e && n > 0 && !this.timerRef && (this.timerRef = setInterval((function() {
|
|
624
624
|
return r.fetchToggles();
|
|
625
|
-
}),
|
|
625
|
+
}), n)), [2];
|
|
626
626
|
}
|
|
627
627
|
}));
|
|
628
628
|
}));
|
|
629
629
|
}, t.prototype.stop = function() {
|
|
630
|
-
this.timerRef && (clearInterval(this.timerRef), this.timerRef = void 0), this.metrics.stop();
|
|
630
|
+
this.stopCount++, this.timerRef && (clearInterval(this.timerRef), this.timerRef = void 0), this.metrics.stop();
|
|
631
631
|
}, t.prototype.isReady = function() {
|
|
632
632
|
return this.readyEventEmitted;
|
|
633
633
|
}, t.prototype.getError = function() {
|
|
@@ -637,29 +637,29 @@ var kt = function(o) {
|
|
|
637
637
|
}, t.prototype.resolveSessionId = function() {
|
|
638
638
|
return g(this, void 0, void 0, (function() {
|
|
639
639
|
var e;
|
|
640
|
-
return y(this, (function(
|
|
641
|
-
switch (
|
|
640
|
+
return y(this, (function(n) {
|
|
641
|
+
switch (n.label) {
|
|
642
642
|
case 0:
|
|
643
643
|
return this.context.sessionId ? [2, this.context.sessionId] : [4, this.storage.get("sessionId")];
|
|
644
644
|
case 1:
|
|
645
|
-
return (e =
|
|
645
|
+
return (e = n.sent()) ? [3, 3] : (e = Math.floor(1e9 * Math.random()), [4, this.storage.save("sessionId", e.toString(10))]);
|
|
646
646
|
case 2:
|
|
647
|
-
|
|
647
|
+
n.sent(), n.label = 3;
|
|
648
648
|
case 3:
|
|
649
649
|
return [2, e.toString(10)];
|
|
650
650
|
}
|
|
651
651
|
}));
|
|
652
652
|
}));
|
|
653
653
|
}, t.prototype.getHeaders = function() {
|
|
654
|
-
return
|
|
654
|
+
return ct({ clientKey: this.clientKey, connectionId: this.connectionId, appName: this.context.appName, customHeaders: this.customHeaders, headerName: this.headerName, etag: this.etag, isPost: this.usePOSTrequests });
|
|
655
655
|
}, t.prototype.storeToggles = function(e) {
|
|
656
656
|
return g(this, void 0, void 0, (function() {
|
|
657
|
-
return y(this, (function(
|
|
658
|
-
switch (
|
|
657
|
+
return y(this, (function(n) {
|
|
658
|
+
switch (n.label) {
|
|
659
659
|
case 0:
|
|
660
|
-
return this.toggles = e, this.emit(m.UPDATE), [4, this.storage.save(
|
|
660
|
+
return this.toggles = e, this.emit(m.UPDATE), [4, this.storage.save(q, e)];
|
|
661
661
|
case 1:
|
|
662
|
-
return
|
|
662
|
+
return n.sent(), [2];
|
|
663
663
|
}
|
|
664
664
|
}));
|
|
665
665
|
}));
|
|
@@ -669,19 +669,19 @@ var kt = function(o) {
|
|
|
669
669
|
}, t.prototype.isUpToDate = function() {
|
|
670
670
|
var e;
|
|
671
671
|
if (!this.isTogglesStorageTTLEnabled()) return !1;
|
|
672
|
-
var
|
|
673
|
-
return this.lastRefreshTimestamp > 0 && this.lastRefreshTimestamp <=
|
|
672
|
+
var n = Date.now(), r = ((e = this.experimental) === null || e === void 0 ? void 0 : e.togglesStorageTTL) || 0;
|
|
673
|
+
return this.lastRefreshTimestamp > 0 && this.lastRefreshTimestamp <= n && n - this.lastRefreshTimestamp <= r;
|
|
674
674
|
}, t.prototype.getLastRefreshTimestamp = function() {
|
|
675
675
|
return g(this, void 0, void 0, (function() {
|
|
676
|
-
var e,
|
|
677
|
-
return y(this, (function(
|
|
678
|
-
switch (
|
|
676
|
+
var e, n;
|
|
677
|
+
return y(this, (function(r) {
|
|
678
|
+
switch (r.label) {
|
|
679
679
|
case 0:
|
|
680
|
-
return this.isTogglesStorageTTLEnabled() ? [4, this.storage.get(
|
|
680
|
+
return this.isTogglesStorageTTLEnabled() ? [4, this.storage.get(st)] : [3, 3];
|
|
681
681
|
case 1:
|
|
682
|
-
return e =
|
|
682
|
+
return e = r.sent(), [4, rt(this.context)];
|
|
683
683
|
case 2:
|
|
684
|
-
return
|
|
684
|
+
return n = r.sent(), [2, (e == null ? void 0 : e.key) === n ? e.timestamp : 0];
|
|
685
685
|
case 3:
|
|
686
686
|
return [2, 0];
|
|
687
687
|
}
|
|
@@ -689,15 +689,15 @@ var kt = function(o) {
|
|
|
689
689
|
}));
|
|
690
690
|
}, t.prototype.storeLastRefreshTimestamp = function() {
|
|
691
691
|
return g(this, void 0, void 0, (function() {
|
|
692
|
-
var e,
|
|
693
|
-
return y(this, (function(
|
|
694
|
-
switch (
|
|
692
|
+
var e, n;
|
|
693
|
+
return y(this, (function(r) {
|
|
694
|
+
switch (r.label) {
|
|
695
695
|
case 0:
|
|
696
|
-
return this.isTogglesStorageTTLEnabled() ? (this.lastRefreshTimestamp = Date.now(),
|
|
696
|
+
return this.isTogglesStorageTTLEnabled() ? (this.lastRefreshTimestamp = Date.now(), n = {}, [4, rt(this.context)]) : [3, 3];
|
|
697
697
|
case 1:
|
|
698
|
-
return
|
|
698
|
+
return n.key = r.sent(), n.timestamp = this.lastRefreshTimestamp, e = n, [4, this.storage.save(st, e)];
|
|
699
699
|
case 2:
|
|
700
|
-
|
|
700
|
+
r.sent(), r.label = 3;
|
|
701
701
|
case 3:
|
|
702
702
|
return [2];
|
|
703
703
|
}
|
|
@@ -708,31 +708,31 @@ var kt = function(o) {
|
|
|
708
708
|
this.fetchedFromServer || (this.fetchedFromServer = !0, this.setReady());
|
|
709
709
|
}, t.prototype.fetchToggles = function() {
|
|
710
710
|
return g(this, void 0, void 0, (function() {
|
|
711
|
-
var e,
|
|
711
|
+
var e, n, r, s, i, a, l, c, u;
|
|
712
712
|
return y(this, (function(f) {
|
|
713
713
|
switch (f.label) {
|
|
714
714
|
case 0:
|
|
715
715
|
if (!this.fetch) return [3, 9];
|
|
716
|
-
this.abortController && !this.abortController.signal.aborted && this.abortController.abort(), this.abortController = (
|
|
716
|
+
this.abortController && !this.abortController.signal.aborted && this.abortController.abort(), this.abortController = (u = this.createAbortController) === null || u === void 0 ? void 0 : u.call(this), e = this.abortController ? this.abortController.signal : void 0, f.label = 1;
|
|
717
717
|
case 1:
|
|
718
|
-
return f.trys.push([1, 7, 8, 9]),
|
|
718
|
+
return f.trys.push([1, 7, 8, 9]), n = this.usePOSTrequests, r = n ? this.url : (function(x, T) {
|
|
719
719
|
var b = new URL(x.toString());
|
|
720
|
-
return Object.entries(T).filter(
|
|
721
|
-
var
|
|
722
|
-
|
|
723
|
-
var
|
|
724
|
-
return b.searchParams.append("properties[".concat(
|
|
725
|
-
})) : b.searchParams.append(
|
|
720
|
+
return Object.entries(T).filter(J).forEach((function(R) {
|
|
721
|
+
var S = R[0], E = R[1];
|
|
722
|
+
S === "properties" && E ? Object.entries(E).filter(J).forEach((function(w) {
|
|
723
|
+
var N = w[0], U = w[1];
|
|
724
|
+
return b.searchParams.append("properties[".concat(N, "]"), U);
|
|
725
|
+
})) : b.searchParams.append(S, E);
|
|
726
726
|
})), b;
|
|
727
|
-
})(this.url, this.context), s =
|
|
727
|
+
})(this.url, this.context), s = n ? "POST" : "GET", i = n ? JSON.stringify({ context: this.context }) : void 0, [4, this.fetch(r.toString(), { method: s, cache: "no-cache", headers: this.getHeaders(), body: i, signal: e })];
|
|
728
728
|
case 2:
|
|
729
|
-
return
|
|
729
|
+
return a = f.sent(), this.sdkState === "error" && a.status < 400 && (this.sdkState = "healthy", this.emit(m.RECOVERED)), a.ok ? (this.etag = a.headers.get("ETag") || "", [4, a.json()]) : [3, 5];
|
|
730
730
|
case 3:
|
|
731
731
|
return l = f.sent(), [4, this.storeToggles(l.toggles)];
|
|
732
732
|
case 4:
|
|
733
733
|
return f.sent(), this.sdkState !== "healthy" && (this.sdkState = "healthy"), this.fetchedFromServer || (this.fetchedFromServer = !0, this.setReady()), this.storeLastRefreshTimestamp(), [3, 6];
|
|
734
734
|
case 5:
|
|
735
|
-
|
|
735
|
+
a.status === 304 ? this.storeLastRefreshTimestamp() : (console.error("Unleash: Fetching feature toggles did not have an ok response"), this.sdkState = "error", this.emit(m.ERROR, { type: "HttpError", code: a.status }), this.lastError = { type: "HttpError", code: a.status }), f.label = 6;
|
|
736
736
|
case 6:
|
|
737
737
|
return [3, 9];
|
|
738
738
|
case 7:
|
|
@@ -744,142 +744,150 @@ var kt = function(o) {
|
|
|
744
744
|
}
|
|
745
745
|
}));
|
|
746
746
|
}));
|
|
747
|
-
}, t.prototype.resolveEnvironment = function(e,
|
|
748
|
-
return (function(
|
|
749
|
-
var s =
|
|
747
|
+
}, t.prototype.resolveEnvironment = function(e, n) {
|
|
748
|
+
return (function(r) {
|
|
749
|
+
var s = r.indexOf(":");
|
|
750
750
|
if (s !== -1) {
|
|
751
|
-
var i =
|
|
752
|
-
if (
|
|
751
|
+
var i = r.slice(s + 1), a = i.lastIndexOf(".");
|
|
752
|
+
if (a !== -1) return i.slice(0, a);
|
|
753
753
|
}
|
|
754
|
-
})(e) ||
|
|
754
|
+
})(e) || n;
|
|
755
755
|
}, t;
|
|
756
|
-
})(
|
|
757
|
-
const
|
|
758
|
-
function
|
|
756
|
+
})(ut.TinyEmitter);
|
|
757
|
+
const C = Symbol("Context state identifier"), pt = Symbol("Context update identifier");
|
|
758
|
+
function dt({
|
|
759
759
|
config: o,
|
|
760
760
|
unleashClient: t,
|
|
761
|
-
startClient: e = !0
|
|
761
|
+
startClient: e = !0,
|
|
762
|
+
stopClient: n = !1
|
|
762
763
|
}) {
|
|
763
|
-
var
|
|
764
|
-
const r =
|
|
764
|
+
var w, N, U, M, A, L;
|
|
765
|
+
const r = D(
|
|
766
|
+
t ?? (o ? new Ft(o) : void 0)
|
|
767
|
+
), s = D(
|
|
768
|
+
!!((w = r.value) != null && w.isReady() || !t && ((N = o == null ? void 0 : o.bootstrap) != null && N.length) && o.bootstrapOverride !== !1)
|
|
769
|
+
), i = D(((U = r.value) == null ? void 0 : U.getError()) ?? null);
|
|
765
770
|
!o && !t && console.warn(
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
})
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
771
|
+
"You must provide either a config or an Unleash client to the flag provider."
|
|
772
|
+
);
|
|
773
|
+
const a = () => {
|
|
774
|
+
s.value = !0;
|
|
775
|
+
}, l = (v) => {
|
|
776
|
+
i.value = v;
|
|
777
|
+
}, c = () => {
|
|
778
|
+
i.value = null;
|
|
779
|
+
};
|
|
780
|
+
(M = r.value) == null || M.on("ready", a), (A = r.value) == null || A.on("error", l), (L = r.value) == null || L.on("recovered", c);
|
|
781
|
+
const b = yt({
|
|
782
|
+
on: (v, ...d) => {
|
|
783
|
+
var I;
|
|
784
|
+
return (I = r.value) == null ? void 0 : I.on(v, ...d);
|
|
777
785
|
},
|
|
778
|
-
updateContext: async (
|
|
779
|
-
var
|
|
780
|
-
await ((
|
|
786
|
+
updateContext: async (v) => {
|
|
787
|
+
var d;
|
|
788
|
+
await ((d = r.value) == null ? void 0 : d.updateContext(v));
|
|
781
789
|
},
|
|
782
|
-
isEnabled: (
|
|
783
|
-
var
|
|
784
|
-
return (
|
|
790
|
+
isEnabled: (v) => {
|
|
791
|
+
var d;
|
|
792
|
+
return (d = r.value) == null ? void 0 : d.isEnabled(v);
|
|
785
793
|
},
|
|
786
|
-
getVariant: (
|
|
787
|
-
var
|
|
788
|
-
return (
|
|
794
|
+
getVariant: (v) => {
|
|
795
|
+
var d;
|
|
796
|
+
return (d = r.value) == null ? void 0 : d.getVariant(v);
|
|
789
797
|
},
|
|
790
798
|
client: r,
|
|
791
|
-
flagsReady:
|
|
792
|
-
flagsError:
|
|
793
|
-
}),
|
|
794
|
-
|
|
795
|
-
},
|
|
796
|
-
var
|
|
797
|
-
(e || !t) && ((
|
|
799
|
+
flagsReady: s,
|
|
800
|
+
flagsError: i
|
|
801
|
+
}), R = (v, d) => {
|
|
802
|
+
b[v] = d;
|
|
803
|
+
}, S = () => {
|
|
804
|
+
var v;
|
|
805
|
+
(e || !t) && ((v = r.value) == null || v.start());
|
|
806
|
+
}, E = () => {
|
|
807
|
+
var v, d, I, B;
|
|
808
|
+
(v = r.value) == null || v.off("ready", a), (d = r.value) == null || d.off("error", l), (I = r.value) == null || I.off("recovered", c), n && ((B = r.value) == null || B.stop());
|
|
798
809
|
};
|
|
799
810
|
return {
|
|
800
|
-
context:
|
|
801
|
-
update:
|
|
802
|
-
start:
|
|
811
|
+
context: bt(b),
|
|
812
|
+
update: R,
|
|
813
|
+
start: S,
|
|
814
|
+
dispose: E
|
|
803
815
|
};
|
|
804
816
|
}
|
|
805
|
-
const _t = /* @__PURE__ */
|
|
817
|
+
const _t = /* @__PURE__ */ xt({
|
|
806
818
|
__name: "FlagProvider",
|
|
807
819
|
props: {
|
|
808
820
|
config: {},
|
|
809
821
|
unleashClient: {},
|
|
810
|
-
startClient: { type: Boolean, default: !0 }
|
|
822
|
+
startClient: { type: Boolean, default: !0 },
|
|
823
|
+
stopClient: { type: Boolean, default: !1 }
|
|
811
824
|
},
|
|
812
825
|
setup(o) {
|
|
813
|
-
const { context: t, start: e, update: r } =
|
|
826
|
+
const { context: t, start: e, update: n, dispose: r } = dt({
|
|
814
827
|
config: o.config,
|
|
815
828
|
unleashClient: o.unleashClient,
|
|
816
|
-
startClient: o.startClient
|
|
829
|
+
startClient: o.startClient,
|
|
830
|
+
stopClient: o.stopClient
|
|
817
831
|
});
|
|
818
|
-
return
|
|
819
|
-
e();
|
|
820
|
-
}), (n, s) => xt(n.$slots, "default");
|
|
832
|
+
return tt(C, t), tt(pt, n), Tt(e), z(r), (s, i) => Et(s.$slots, "default");
|
|
821
833
|
}
|
|
822
|
-
}),
|
|
823
|
-
const { isEnabled: t, client: e } =
|
|
824
|
-
function
|
|
825
|
-
const i = t == null ? void 0 : t.value(o);
|
|
826
|
-
i !==
|
|
834
|
+
}), qt = (o) => {
|
|
835
|
+
const { isEnabled: t, client: e } = F(C, {}), n = D(!!(t != null && t.value(O(o))));
|
|
836
|
+
function r() {
|
|
837
|
+
const i = t == null ? void 0 : t.value(O(o));
|
|
838
|
+
i !== n.value && (n.value = !!i);
|
|
827
839
|
}
|
|
828
840
|
function s() {
|
|
829
|
-
|
|
841
|
+
n.value = !!(t != null && t.value(O(o)));
|
|
830
842
|
}
|
|
831
|
-
return e == null || e.value.on("ready", s), e == null || e.value.on("update",
|
|
832
|
-
e == null || e.value.off("ready", s), e == null || e.value.off("update",
|
|
833
|
-
}),
|
|
834
|
-
},
|
|
835
|
-
const { flagsReady: o, flagsError: t } =
|
|
836
|
-
|
|
843
|
+
return e == null || e.value.on("ready", s), e == null || e.value.on("update", r), it(() => O(o), r), z(() => {
|
|
844
|
+
e == null || e.value.off("ready", s), e == null || e.value.off("update", r);
|
|
845
|
+
}), n;
|
|
846
|
+
}, Yt = () => {
|
|
847
|
+
const { flagsReady: o, flagsError: t } = F(
|
|
848
|
+
C,
|
|
837
849
|
{}
|
|
838
850
|
);
|
|
839
851
|
return { flagsReady: o, flagsError: t };
|
|
840
|
-
},
|
|
841
|
-
var
|
|
842
|
-
return !((o == null ? void 0 : o.name) === (t == null ? void 0 : t.name) && (o == null ? void 0 : o.enabled) === (t == null ? void 0 : t.enabled) && (o == null ? void 0 : o.feature_enabled) === (t == null ? void 0 : t.feature_enabled) && ((
|
|
843
|
-
},
|
|
844
|
-
const { getVariant: t, client: e } =
|
|
845
|
-
function
|
|
846
|
-
const i = t == null ? void 0 : t.value(o);
|
|
847
|
-
|
|
852
|
+
}, Bt = (o, t) => {
|
|
853
|
+
var n, r, s, i;
|
|
854
|
+
return !((o == null ? void 0 : o.name) === (t == null ? void 0 : t.name) && (o == null ? void 0 : o.enabled) === (t == null ? void 0 : t.enabled) && (o == null ? void 0 : o.feature_enabled) === (t == null ? void 0 : t.feature_enabled) && ((n = o == null ? void 0 : o.payload) == null ? void 0 : n.type) === ((r = t == null ? void 0 : t.payload) == null ? void 0 : r.type) && ((s = o == null ? void 0 : o.payload) == null ? void 0 : s.value) === ((i = t == null ? void 0 : t.payload) == null ? void 0 : i.value));
|
|
855
|
+
}, Jt = (o) => {
|
|
856
|
+
const { getVariant: t, client: e } = F(C, {}), n = D(t == null ? void 0 : t.value(O(o)));
|
|
857
|
+
function r() {
|
|
858
|
+
const i = t == null ? void 0 : t.value(O(o));
|
|
859
|
+
Bt(n == null ? void 0 : n.value, i) && (n.value = i);
|
|
848
860
|
}
|
|
849
861
|
function s() {
|
|
850
|
-
|
|
862
|
+
n.value = t == null ? void 0 : t.value(O(o));
|
|
851
863
|
}
|
|
852
|
-
return e == null || e.value.on("ready", s), e == null || e.value.on("update",
|
|
853
|
-
e == null || e.value.off("ready", s), e == null || e.value.off("update",
|
|
854
|
-
}),
|
|
855
|
-
}, Yt = () => {
|
|
856
|
-
const { updateContext: o } = A(S, {});
|
|
857
|
-
return o == null ? void 0 : o.value;
|
|
864
|
+
return e == null || e.value.on("ready", s), e == null || e.value.on("update", r), it(() => O(o), r), z(() => {
|
|
865
|
+
e == null || e.value.off("ready", s), e == null || e.value.off("update", r);
|
|
866
|
+
}), n || {};
|
|
858
867
|
}, Wt = () => {
|
|
859
|
-
const {
|
|
868
|
+
const { updateContext: o } = F(C, {});
|
|
860
869
|
return o == null ? void 0 : o.value;
|
|
861
|
-
}, zt = {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
o.provide(S, n), o.provide(lt, s), i();
|
|
870
|
+
}, zt = () => {
|
|
871
|
+
const { client: o } = F(C, {});
|
|
872
|
+
return o == null ? void 0 : o.value;
|
|
873
|
+
}, Gt = {
|
|
874
|
+
install(o, t) {
|
|
875
|
+
const { context: e, update: n, start: r, dispose: s } = dt(t);
|
|
876
|
+
o.provide(C, e), o.provide(pt, n), o.onUnmount(s), r();
|
|
869
877
|
}
|
|
870
878
|
};
|
|
871
879
|
export {
|
|
872
|
-
|
|
873
|
-
|
|
880
|
+
C as ContextStateSymbol,
|
|
881
|
+
pt as ContextUpdateSymbol,
|
|
874
882
|
_t as FlagProvider,
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
883
|
+
It as InMemoryStorageProvider,
|
|
884
|
+
kt as LocalStorageProvider,
|
|
885
|
+
Ft as UnleashClient,
|
|
878
886
|
_t as default,
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
887
|
+
Gt as plugin,
|
|
888
|
+
qt as useFlag,
|
|
889
|
+
Yt as useFlagsStatus,
|
|
890
|
+
zt as useUnleashClient,
|
|
891
|
+
Wt as useUnleashContext,
|
|
892
|
+
Jt as useVariant
|
|
885
893
|
};
|