@feedmepos/mf-brand-app-builder 0.5.43-dev.1 → 0.5.45-dev.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/dist/App-fxWMiswF.js +121 -0
- package/dist/{BrandkitView-CKCJs4dU.js → BrandkitView-CnsKm_nt.js} +2625 -2652
- package/dist/{BuilderView-Cdj86CAt.js → BuilderView-DlAFI1gC.js} +3 -3
- package/dist/{ImageUpload-czx5o-j6.js → ImageUpload-DxerDooG.js} +1 -1
- package/dist/{ListRepeater-DBkUbAFA.js → ListRepeater-DDEV4xLl.js} +1 -1
- package/dist/{ProjectView-DtxPapNI.js → ProjectView-DZ3qaw_E.js} +2 -2
- package/dist/{app-BlFm1Tkh.js → app-DqTMfqMo.js} +1135 -1156
- package/dist/app.js +1 -1
- package/dist/brand-core/src/brandkit.d.ts +34 -0
- package/dist/brand-core/src/entity.d.ts +0 -1
- package/dist/brandkit-Jwi77VnL.js +144 -0
- package/dist/client/merchant/src/app.d.ts +0 -28
- package/dist/client/merchant/src/composables/useBusinessFeatureFlag.d.ts +17 -0
- package/dist/client/merchant/src/main.d.ts +1 -0
- package/dist/client/merchant/src/stores/business/index.d.ts +0 -6
- package/dist/{dayjs.min-Bdy6lFTt.js → dayjs.min-B4vcU5Bc.js} +1 -1
- package/dist/{main-CozSePSS.js → main-DN4hx_tp.js} +2 -2
- package/dist/package.json +2 -1
- package/dist/style.css +1 -1
- package/dist/{useBusinessFeatureFlag-2_0Z_IYf.js → useBusinessFeatureFlag-BtLpiYy7.js} +281 -263
- package/package.json +2 -1
- package/dist/App-C1Sg6gD6.js +0 -114
- package/dist/brandkit-1Te5zV_c.js +0 -127
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var ue = Object.defineProperty;
|
|
2
|
-
var ce = (
|
|
3
|
-
var st = (
|
|
4
|
-
import { readonly as Pt, ref as $, watch as he } from "vue";
|
|
5
|
-
import { useCoreStore as
|
|
6
|
-
import { c as lt } from "./app-
|
|
2
|
+
var ce = (f, l, d) => l in f ? ue(f, l, { enumerable: !0, configurable: !0, writable: !0, value: d }) : f[l] = d;
|
|
3
|
+
var st = (f, l, d) => ce(f, typeof l != "symbol" ? l + "" : l, d);
|
|
4
|
+
import { readonly as Pt, ref as $, watch as he, computed as ve } from "vue";
|
|
5
|
+
import { useCoreStore as de } from "@feedmepos/mf-common";
|
|
6
|
+
import { c as lt } from "./app-DqTMfqMo.js";
|
|
7
7
|
var Ut = { exports: {} };
|
|
8
|
-
(function(
|
|
9
|
-
(function(
|
|
10
|
-
|
|
11
|
-
})(lt, function(
|
|
12
|
-
var
|
|
8
|
+
(function(f, l) {
|
|
9
|
+
(function(d, v) {
|
|
10
|
+
v(l);
|
|
11
|
+
})(lt, function(d) {
|
|
12
|
+
var v = { getItemSync: function(a) {
|
|
13
13
|
try {
|
|
14
14
|
return localStorage.getItem(a) || null;
|
|
15
15
|
} catch {
|
|
@@ -41,25 +41,25 @@ var Ut = { exports: {} };
|
|
|
41
41
|
};
|
|
42
42
|
function F(a, e, t, i) {
|
|
43
43
|
return new (t || (t = Promise))(function(n, r) {
|
|
44
|
-
function o(
|
|
44
|
+
function o(y) {
|
|
45
45
|
try {
|
|
46
|
-
h(i.next(
|
|
47
|
-
} catch (
|
|
48
|
-
r(
|
|
46
|
+
h(i.next(y));
|
|
47
|
+
} catch (u) {
|
|
48
|
+
r(u);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function c(y) {
|
|
52
52
|
try {
|
|
53
|
-
h(i.throw(
|
|
54
|
-
} catch (
|
|
55
|
-
r(
|
|
53
|
+
h(i.throw(y));
|
|
54
|
+
} catch (u) {
|
|
55
|
+
r(u);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function h(
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})).then(o,
|
|
58
|
+
function h(y) {
|
|
59
|
+
var u;
|
|
60
|
+
y.done ? n(y.value) : (u = y.value, u instanceof t ? u : new t(function(m) {
|
|
61
|
+
m(u);
|
|
62
|
+
})).then(o, c);
|
|
63
63
|
}
|
|
64
64
|
h((i = i.apply(a, [])).next());
|
|
65
65
|
});
|
|
@@ -69,57 +69,57 @@ var Ut = { exports: {} };
|
|
|
69
69
|
if (1 & n[0]) throw n[1];
|
|
70
70
|
return n[1];
|
|
71
71
|
}, trys: [], ops: [] };
|
|
72
|
-
return r = { next:
|
|
72
|
+
return r = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
|
|
73
73
|
return this;
|
|
74
74
|
}), r;
|
|
75
|
-
function
|
|
76
|
-
return function(
|
|
77
|
-
return function(
|
|
75
|
+
function c(h) {
|
|
76
|
+
return function(y) {
|
|
77
|
+
return function(u) {
|
|
78
78
|
if (t) throw new TypeError("Generator is already executing.");
|
|
79
79
|
for (; o; ) try {
|
|
80
|
-
if (t = 1, i && (n = 2 &
|
|
81
|
-
switch (i = 0, n && (
|
|
80
|
+
if (t = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n;
|
|
81
|
+
switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
|
|
82
82
|
case 0:
|
|
83
83
|
case 1:
|
|
84
|
-
n =
|
|
84
|
+
n = u;
|
|
85
85
|
break;
|
|
86
86
|
case 4:
|
|
87
|
-
return o.label++, { value:
|
|
87
|
+
return o.label++, { value: u[1], done: !1 };
|
|
88
88
|
case 5:
|
|
89
|
-
o.label++, i =
|
|
89
|
+
o.label++, i = u[1], u = [0];
|
|
90
90
|
continue;
|
|
91
91
|
case 7:
|
|
92
|
-
|
|
92
|
+
u = o.ops.pop(), o.trys.pop();
|
|
93
93
|
continue;
|
|
94
94
|
default:
|
|
95
|
-
if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) ||
|
|
95
|
+
if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
|
|
96
96
|
o = 0;
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
|
-
if (
|
|
100
|
-
o.label =
|
|
99
|
+
if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
|
|
100
|
+
o.label = u[1];
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
|
-
if (
|
|
104
|
-
o.label = n[1], n =
|
|
103
|
+
if (u[0] === 6 && o.label < n[1]) {
|
|
104
|
+
o.label = n[1], n = u;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
if (n && o.label < n[2]) {
|
|
108
|
-
o.label = n[2], o.ops.push(
|
|
108
|
+
o.label = n[2], o.ops.push(u);
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
n[2] && o.ops.pop(), o.trys.pop();
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
} catch (
|
|
116
|
-
|
|
114
|
+
u = e.call(a, o);
|
|
115
|
+
} catch (m) {
|
|
116
|
+
u = [6, m], i = 0;
|
|
117
117
|
} finally {
|
|
118
118
|
t = n = 0;
|
|
119
119
|
}
|
|
120
|
-
if (5 &
|
|
121
|
-
return { value:
|
|
122
|
-
}([h,
|
|
120
|
+
if (5 & u[0]) throw u[1];
|
|
121
|
+
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
122
|
+
}([h, y]);
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -150,7 +150,7 @@ var Ut = { exports: {} };
|
|
|
150
150
|
}
|
|
151
151
|
return e != e && t != t;
|
|
152
152
|
};
|
|
153
|
-
function
|
|
153
|
+
function b(a, e) {
|
|
154
154
|
var t = Object.keys(e || {}).filter(function(i) {
|
|
155
155
|
var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
|
|
156
156
|
return !k(n, r);
|
|
@@ -159,8 +159,8 @@ var Ut = { exports: {} };
|
|
|
159
159
|
Object.keys(e || {}).includes(i) || t.push(i);
|
|
160
160
|
}), Object.keys(t).length ? t : null;
|
|
161
161
|
}
|
|
162
|
-
var
|
|
163
|
-
function
|
|
162
|
+
var g, p;
|
|
163
|
+
function _(a, e, t) {
|
|
164
164
|
var i = "shortString", n = !0;
|
|
165
165
|
typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
|
|
166
166
|
}
|
|
@@ -178,61 +178,61 @@ var Ut = { exports: {} };
|
|
|
178
178
|
}
|
|
179
179
|
(function(a) {
|
|
180
180
|
a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
|
|
181
|
-
})(
|
|
182
|
-
var ht,
|
|
181
|
+
})(g || (g = {}));
|
|
182
|
+
var ht, w = null, ae = "FLAGSMITH_EVENT", rt = ae, Gt = "https://edge.api.flagsmith.com/api/v1/", Jt = "flagsmith_value_", Vt = "flagsmith_enabled_", zt = "flagsmith_trait_", re = function() {
|
|
183
183
|
function a(e) {
|
|
184
184
|
var t = this;
|
|
185
185
|
this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
|
|
186
186
|
var i = t, n = i.api, r = i.evaluationContext;
|
|
187
187
|
t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(s(s({}, t.loadingState), { isFetching: !0 }));
|
|
188
|
-
var o = "".concat(t.getContext().identity),
|
|
189
|
-
var
|
|
188
|
+
var o = "".concat(t.getContext().identity), c = function(h) {
|
|
189
|
+
var y, u, m, E;
|
|
190
190
|
if (h && o === "".concat(t.getContext().identity)) {
|
|
191
191
|
var U = h.flags, L = h.traits, P = h.identifier;
|
|
192
192
|
t.isLoading = !1;
|
|
193
193
|
var A = {}, j = {};
|
|
194
|
-
L = L || [], (U = U || []).forEach(function(
|
|
195
|
-
A[
|
|
196
|
-
}), L.forEach(function(
|
|
197
|
-
j[
|
|
194
|
+
L = L || [], (U = U || []).forEach(function(S) {
|
|
195
|
+
A[S.feature.name.toLowerCase().replace(/ /g, "_")] = { id: S.feature.id, enabled: S.enabled, value: S.feature_state_value };
|
|
196
|
+
}), L.forEach(function(S) {
|
|
197
|
+
j[S.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: S.transient, value: S.trait_value };
|
|
198
198
|
}), t.oldFlags = s({}, t.flags);
|
|
199
|
-
var K =
|
|
200
|
-
if ((P || Object.keys(j).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: j }), P && (t.evaluationContext.identity.identifier = P)), t.flags = A, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: K, traitsChanged: W }, t._loadedState(null,
|
|
199
|
+
var K = b(t.oldFlags, A), W = b((y = t.evaluationContext.identity) === null || y === void 0 ? void 0 : y.traits, j);
|
|
200
|
+
if ((P || Object.keys(j).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: j }), P && (t.evaluationContext.identity.identifier = P)), t.flags = A, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: K, traitsChanged: W }, t._loadedState(null, g.SERVER)), t.datadogRum) try {
|
|
201
201
|
if (t.datadogRum.trackTraits) {
|
|
202
202
|
var tt = {};
|
|
203
|
-
Object.keys(((
|
|
204
|
-
tt[
|
|
203
|
+
Object.keys(((u = t.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(S) {
|
|
204
|
+
tt[zt + S] = t.getTrait(S);
|
|
205
205
|
});
|
|
206
|
-
var q = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((
|
|
206
|
+
var q = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((m = t.evaluationContext.identity) === null || m === void 0 ? void 0 : m.identifier) }), tt);
|
|
207
207
|
t.log("Setting Datadog user", q), t.datadogRum.client.setUser(q);
|
|
208
208
|
}
|
|
209
|
-
} catch (
|
|
210
|
-
console.error(
|
|
209
|
+
} catch (S) {
|
|
210
|
+
console.error(S);
|
|
211
211
|
}
|
|
212
212
|
if (t.dtrum) try {
|
|
213
|
-
var
|
|
214
|
-
Object.keys(t.flags).map(function(
|
|
215
|
-
|
|
216
|
-
}), Object.keys(((
|
|
217
|
-
|
|
218
|
-
}), t.log("Sending javaLongOrObject traits to dynatrace",
|
|
219
|
-
} catch (
|
|
220
|
-
console.error(
|
|
213
|
+
var x = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
|
|
214
|
+
Object.keys(t.flags).map(function(S) {
|
|
215
|
+
_(x, Jt + S, t.getValue(S, { skipAnalytics: !0 })), _(x, Vt + S, t.hasFeature(S, { skipAnalytics: !0 }));
|
|
216
|
+
}), Object.keys(((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.traits) || {}).map(function(S) {
|
|
217
|
+
_(x, zt + S, t.getTrait(S));
|
|
218
|
+
}), t.log("Sending javaLongOrObject traits to dynatrace", x.javaLongOrObject), t.log("Sending date traits to dynatrace", x.date), t.log("Sending shortString traits to dynatrace", x.shortString), t.log("Sending javaDouble to dynatrace", x.javaDouble), t.dtrum.sendSessionProperties(x.javaLongOrObject, x.date, x.shortString, x.javaDouble);
|
|
219
|
+
} catch (S) {
|
|
220
|
+
console.error(S);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
return r.identity ? Promise.all([r.identity.traits && Object.keys(r.identity.traits).length || !r.identity.identifier ? t.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: r.identity.identifier, transient: r.identity.transient, traits: Object.entries(r.identity.traits).map(function(h) {
|
|
225
|
-
var
|
|
226
|
-
return { trait_key:
|
|
225
|
+
var y = h[0], u = h[1];
|
|
226
|
+
return { trait_key: y, trait_value: u == null ? void 0 : u.value, transient: u == null ? void 0 : u.transient };
|
|
227
227
|
}).filter(function(h) {
|
|
228
228
|
return h.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", h.trait_key), !1);
|
|
229
229
|
}) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(h) {
|
|
230
|
-
return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }),
|
|
230
|
+
return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }), c(h == null ? void 0 : h[0]);
|
|
231
231
|
}).catch(function(h) {
|
|
232
|
-
var
|
|
233
|
-
return Promise.reject(
|
|
232
|
+
var y = h.message, u = new Error(y);
|
|
233
|
+
return Promise.reject(u);
|
|
234
234
|
}) : t.getJSON(n + "flags/").then(function(h) {
|
|
235
|
-
return
|
|
235
|
+
return c({ flags: h, traits: void 0 });
|
|
236
236
|
});
|
|
237
237
|
}, this.analyticsFlags = function() {
|
|
238
238
|
var i = t.api;
|
|
@@ -244,15 +244,15 @@ var Ut = { exports: {} };
|
|
|
244
244
|
}).catch(function(n) {
|
|
245
245
|
t.log("Exception fetching evaluationEvent", n);
|
|
246
246
|
}) : void 0;
|
|
247
|
-
}, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source:
|
|
248
|
-
var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")],
|
|
249
|
-
if (o && (
|
|
247
|
+
}, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: g.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(i, n, r) {
|
|
248
|
+
var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = null;
|
|
249
|
+
if (o && (c = o.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), c === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
|
|
250
250
|
if (n != null && n.json) try {
|
|
251
|
-
return
|
|
251
|
+
return c === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(c);
|
|
252
252
|
} catch {
|
|
253
253
|
return n.fallback;
|
|
254
254
|
}
|
|
255
|
-
return
|
|
255
|
+
return c;
|
|
256
256
|
}, this.getTrait = function(i) {
|
|
257
257
|
var n, r;
|
|
258
258
|
return ((n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((r = t.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || r === void 0 ? void 0 : r.value);
|
|
@@ -275,26 +275,26 @@ var Ut = { exports: {} };
|
|
|
275
275
|
}, this.setTraits = function(i) {
|
|
276
276
|
var n;
|
|
277
277
|
if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
|
|
278
|
-
var o = r[0],
|
|
279
|
-
return [o, V(
|
|
278
|
+
var o = r[0], c = r[1];
|
|
279
|
+
return [o, V(c) ? c : { value: c }];
|
|
280
280
|
}))) }) }));
|
|
281
281
|
console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.");
|
|
282
282
|
}, this.hasFeature = function(i, n) {
|
|
283
|
-
var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")],
|
|
284
|
-
return !o && r && n.fallback !== void 0 ?
|
|
283
|
+
var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = !1;
|
|
284
|
+
return !o && r && n.fallback !== void 0 ? c = n == null ? void 0 : n.fallback : o && o.enabled && (c = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), c;
|
|
285
285
|
}, this.getStorageKey = function() {
|
|
286
286
|
var i, n;
|
|
287
287
|
return ((i = t.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = t.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
|
|
288
288
|
}, this.getJSON = function(i, n, r) {
|
|
289
|
-
var o,
|
|
290
|
-
|
|
291
|
-
var h =
|
|
292
|
-
t.evaluationContext.environment && (
|
|
293
|
-
var
|
|
294
|
-
return
|
|
295
|
-
var
|
|
296
|
-
if (
|
|
297
|
-
var P = (U =
|
|
289
|
+
var o, c = t;
|
|
290
|
+
c.evaluationContext;
|
|
291
|
+
var h = c.headers, y = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
|
|
292
|
+
t.evaluationContext.environment && (y.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (y.headers["Content-Type"] = "application/json; charset=utf-8"), h && Object.assign(y.headers, h), p || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
|
|
293
|
+
var u = "".concat((o = t.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
|
|
294
|
+
return p(i, y).then(function(m) {
|
|
295
|
+
var E, U, L = "".concat((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.identifier);
|
|
296
|
+
if (u === L) {
|
|
297
|
+
var P = (U = m.headers) === null || U === void 0 ? void 0 : U.get("x-flagsmith-document-updated-at");
|
|
298
298
|
if (P) try {
|
|
299
299
|
var A = parseFloat(P);
|
|
300
300
|
if (isNaN(A)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
|
|
@@ -302,114 +302,114 @@ var Ut = { exports: {} };
|
|
|
302
302
|
} catch (j) {
|
|
303
303
|
t.log(j, "Failed to parse x-flagsmith-document-updated-at", P);
|
|
304
304
|
}
|
|
305
|
-
return t.log("Fetch response: " +
|
|
305
|
+
return t.log("Fetch response: " + m.status + " " + (n || "GET") + 0 + i), m.text().then(function(j) {
|
|
306
306
|
var K = j;
|
|
307
307
|
try {
|
|
308
308
|
K = JSON.parse(j);
|
|
309
309
|
} catch {
|
|
310
310
|
}
|
|
311
|
-
return !K &&
|
|
311
|
+
return !K && m.status && (K = "API Response: ".concat(m.status)), m.status && m.status >= 200 && m.status < 300 ? K : Promise.reject(new Error(K));
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(
|
|
314
|
+
t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(L));
|
|
315
315
|
});
|
|
316
316
|
}, this.evaluateFlag = function(i, n) {
|
|
317
|
-
if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(
|
|
317
|
+
if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Jt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Vt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
|
|
318
318
|
if (!t.evaluationEvent || !t.evaluationContext.environment) return;
|
|
319
319
|
t.evaluationEvent[t.evaluationContext.environment.apiKey] || (t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] === void 0 && (t.evaluationEvent[t.evaluationContext.environment.apiKey][i] = 0), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] += 1;
|
|
320
320
|
}
|
|
321
321
|
t.updateEventStorage();
|
|
322
322
|
}, this._onChange = function(i, n, r) {
|
|
323
|
-
var o,
|
|
324
|
-
t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (
|
|
325
|
-
},
|
|
323
|
+
var o, c;
|
|
324
|
+
t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (c = t._trigger) === null || c === void 0 || c.call(t);
|
|
325
|
+
}, p = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : lt === null || lt === void 0 ? void 0 : lt.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (ht = e.eventSource), e.AsyncStorage && (w = e.AsyncStorage);
|
|
326
326
|
}
|
|
327
327
|
return a.prototype.init = function(e) {
|
|
328
328
|
var t, i, n;
|
|
329
329
|
return F(this, void 0, void 0, function() {
|
|
330
|
-
var r, o,
|
|
330
|
+
var r, o, c, h, y, u, m, E, U, L, P, A, j, K, W, tt, q, x, S, dt, et, Yt, X, gt, Zt, Qt, ft, Wt, pt, nt, Y, te, O = this;
|
|
331
331
|
return I(this, function(R) {
|
|
332
332
|
switch (R.label) {
|
|
333
333
|
case 0:
|
|
334
334
|
r = ct(e.evaluationContext || this.evaluationContext), R.label = 1;
|
|
335
335
|
case 1:
|
|
336
|
-
if (R.trys.push([1, 13, , 14]), o = e.environmentID,
|
|
336
|
+
if (R.trys.push([1, 13, , 14]), o = e.environmentID, c = e.api, h = c === void 0 ? Gt : c, y = e.headers, u = e.onChange, m = e.cacheFlags, E = e.datadogRum, U = e.onError, L = e.defaultFlags, P = e.fetch, A = e.preventFetch, j = e.enableLogs, K = e.enableDynatrace, W = e.enableAnalytics, tt = e.realtime, q = e.eventSourceUrl, x = q === void 0 ? "https://realtime.flagsmith.com/" : q, S = e.AsyncStorage, dt = e.identity, et = e.traits, Yt = e.state, X = e.cacheOptions, gt = e.angularHttpClient, Zt = e._trigger, Qt = e._triggerLoadingState, r.environment = o ? { apiKey: o } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
|
|
337
337
|
if (r.identity = dt || et ? { identifier: dt, traits: et ? Object.fromEntries(Object.entries(et).map(function(T) {
|
|
338
338
|
return [T[0], { value: T[1] }];
|
|
339
|
-
})) : {} } : r.identity, this.evaluationContext = r, this.api = h, this.headers =
|
|
340
|
-
|
|
341
|
-
}, this.enableLogs = j || !1, this.cacheOptions = X ? { skipAPI: !!X.skipAPI, ttl: X.ttl || 0, storageKey: X.storageKey, loadStale: !!X.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), P && (
|
|
339
|
+
})) : {} } : r.identity, this.evaluationContext = r, this.api = h, this.headers = y, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, ft = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Zt || this._trigger, this._triggerLoadingState = Qt || this._triggerLoadingState, this.onError = function(T) {
|
|
340
|
+
O.setLoadingState(s(s({}, O.loadingState), { isFetching: !1, isLoading: !1, error: T })), U == null || U(T);
|
|
341
|
+
}, this.enableLogs = j || !1, this.cacheOptions = X ? { skipAPI: !!X.skipAPI, ttl: X.ttl || 0, storageKey: X.storageKey, loadStale: !!X.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), P && (p = P), this.enableAnalytics = W || !1, this.flags = Object.assign({}, L) || {}, this.datadogRum = E || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = w !== void 0 && !!m, rt = "FLAGSMITH_EVENT_" + r.environment.apiKey, S && (w = S), tt && typeof window < "u" && this.setupRealtime(x, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Yt), this.log("Initialising with properties", e, this), K && (typeof dtrum > "u" ? console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed.") : this.dtrum = dtrum), gt && (p = /* @__PURE__ */ function(T) {
|
|
342
342
|
return function(D, G) {
|
|
343
|
-
var
|
|
344
|
-
return new Promise(function(
|
|
345
|
-
switch (
|
|
343
|
+
var M = G.headers, C = G.method, Z = G.body;
|
|
344
|
+
return new Promise(function(H) {
|
|
345
|
+
switch (C) {
|
|
346
346
|
case "GET":
|
|
347
|
-
return T.get(D, { headers:
|
|
348
|
-
|
|
349
|
-
return Promise.resolve(
|
|
347
|
+
return T.get(D, { headers: M }).subscribe(function(z) {
|
|
348
|
+
H({ ok: !0, text: function() {
|
|
349
|
+
return Promise.resolve(z);
|
|
350
350
|
} });
|
|
351
351
|
});
|
|
352
352
|
case "POST":
|
|
353
353
|
case "PUT":
|
|
354
|
-
return T.post(D, Z, { headers:
|
|
355
|
-
|
|
356
|
-
return Promise.resolve(
|
|
354
|
+
return T.post(D, Z, { headers: M }).subscribe(function(z) {
|
|
355
|
+
H({ ok: !0, text: function() {
|
|
356
|
+
return Promise.resolve(z);
|
|
357
357
|
} });
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
};
|
|
362
|
-
}(gt)),
|
|
362
|
+
}(gt)), w && this.canUseStorage && w.getItem(rt).then(function(T) {
|
|
363
363
|
try {
|
|
364
|
-
|
|
364
|
+
O.evaluationEvent = JSON.parse(T) || {};
|
|
365
365
|
} catch {
|
|
366
|
-
|
|
366
|
+
O.evaluationEvent = {};
|
|
367
367
|
}
|
|
368
|
-
|
|
369
|
-
}), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval),
|
|
370
|
-
if (D &&
|
|
368
|
+
O.analyticsInterval = setInterval(O.analyticsFlags, O.ticks);
|
|
369
|
+
}), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), w && this.canUseStorage && w.getItem(rt, function(T, D) {
|
|
370
|
+
if (D && O.evaluationContext.environment) {
|
|
371
371
|
var G = JSON.parse(D);
|
|
372
|
-
if (G[
|
|
373
|
-
var
|
|
374
|
-
|
|
372
|
+
if (G[O.evaluationContext.environment.apiKey]) {
|
|
373
|
+
var M = O.getState();
|
|
374
|
+
O.log("Retrieved events from cache", D), O.setState(s(s({}, M), { evaluationEvent: G[O.evaluationContext.environment.apiKey] }));
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
})), !
|
|
378
|
-
if (!
|
|
379
|
-
|
|
380
|
-
return F(
|
|
381
|
-
var G,
|
|
382
|
-
return I(this, function(
|
|
383
|
-
switch (
|
|
377
|
+
})), !m) return [3, 9];
|
|
378
|
+
if (!w || !this.canUseStorage) return [3, 8];
|
|
379
|
+
Wt = function(T, D) {
|
|
380
|
+
return F(O, void 0, void 0, function() {
|
|
381
|
+
var G, M, C, Z, H, z, yt, ee, mt, St, Ct, bt, _t, Ft, Et, xt, Ot, wt, It, Lt, At, jt, Tt, Nt, ne = this;
|
|
382
|
+
return I(this, function(B) {
|
|
383
|
+
switch (B.label) {
|
|
384
384
|
case 0:
|
|
385
385
|
if (!D) return [3, 7];
|
|
386
|
-
G = null,
|
|
386
|
+
G = null, M = null, B.label = 1;
|
|
387
387
|
case 1:
|
|
388
|
-
return
|
|
388
|
+
return B.trys.push([1, 5, , 6]), C = JSON.parse(D), Z = !1, H = !1, C && C.api === this.api && ((St = (mt = C.evaluationContext) === null || mt === void 0 ? void 0 : mt.environment) === null || St === void 0 ? void 0 : St.apiKey) === ((Ct = this.evaluationContext.environment) === null || Ct === void 0 ? void 0 : Ct.apiKey) && (z = !0, this.evaluationContext.identity && ((_t = (bt = C.evaluationContext) === null || bt === void 0 ? void 0 : bt.identity) === null || _t === void 0 ? void 0 : _t.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((Et = (Ft = C.evaluationContext) === null || Ft === void 0 ? void 0 : Ft.identity) === null || Et === void 0 ? void 0 : Et.identifier) + " to " + this.evaluationContext.identity.identifier), z = !1), this.cacheOptions.ttl && (!C.ts || (/* @__PURE__ */ new Date()).valueOf() - C.ts > this.cacheOptions.ttl) && (C.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), z = !1) : C.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), H = !0, z = !0)), z && (Z = !0, M = b((xt = this.evaluationContext.identity) === null || xt === void 0 ? void 0 : xt.traits, (wt = (Ot = C.evaluationContext) === null || Ot === void 0 ? void 0 : Ot.identity) === null || wt === void 0 ? void 0 : wt.traits), G = b(this.flags, C.flags), this.setState(s(s({}, C), { evaluationContext: ct(s(s({}, C.evaluationContext), { identity: !((It = C.evaluationContext) === null || It === void 0) && It.identity ? s(s({}, (Lt = C.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity), { traits: s(s({}, ((jt = (At = C.evaluationContext) === null || At === void 0 ? void 0 : At.identity) === null || jt === void 0 ? void 0 : jt.traits) || {}), et || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", C))), Z ? (yt = !A && (!this.cacheOptions.skipAPI || H), this._onChange(null, { isFromServer: !1, flagsChanged: G, traitsChanged: M }, this._loadedState(null, g.CACHE, yt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Z && !H && this.log("Skipping API, using cache"), yt && this.getFlags().catch(function(le) {
|
|
389
389
|
var kt;
|
|
390
|
-
(kt =
|
|
390
|
+
(kt = ne.onError) === null || kt === void 0 || kt.call(ne, le);
|
|
391
391
|
}), [3, 4]) : [3, 2];
|
|
392
392
|
case 2:
|
|
393
393
|
return A ? [3, 4] : [4, this.getFlags()];
|
|
394
394
|
case 3:
|
|
395
|
-
|
|
395
|
+
B.sent(), B.label = 4;
|
|
396
396
|
case 4:
|
|
397
397
|
return [3, 6];
|
|
398
398
|
case 5:
|
|
399
|
-
return
|
|
399
|
+
return ee = B.sent(), this.log("Exception fetching cached logs", ee), [3, 6];
|
|
400
400
|
case 6:
|
|
401
401
|
return [3, 10];
|
|
402
402
|
case 7:
|
|
403
403
|
return A ? [3, 9] : [4, this.getFlags()];
|
|
404
404
|
case 8:
|
|
405
|
-
return
|
|
405
|
+
return B.sent(), [3, 10];
|
|
406
406
|
case 9:
|
|
407
|
-
if (L) this._onChange(null, { isFromServer: !1, flagsChanged:
|
|
407
|
+
if (L) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (Tt = this.evaluationContext.identity) === null || Tt === void 0 ? void 0 : Tt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
|
|
408
408
|
else {
|
|
409
409
|
if (!this.flags) throw new Error(ft);
|
|
410
|
-
this._onChange(null, { isFromServer: !1, flagsChanged:
|
|
410
|
+
this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (Nt = this.evaluationContext.identity) === null || Nt === void 0 ? void 0 : Nt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
|
|
411
411
|
}
|
|
412
|
-
|
|
412
|
+
B.label = 10;
|
|
413
413
|
case 10:
|
|
414
414
|
return [2];
|
|
415
415
|
}
|
|
@@ -417,13 +417,13 @@ var Ut = { exports: {} };
|
|
|
417
417
|
});
|
|
418
418
|
}, R.label = 2;
|
|
419
419
|
case 2:
|
|
420
|
-
return R.trys.push([2, 7, , 8]),
|
|
420
|
+
return R.trys.push([2, 7, , 8]), w.getItemSync ? (pt = w.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
|
|
421
421
|
case 3:
|
|
422
|
-
return [4,
|
|
422
|
+
return [4, w.getItem(this.getStorageKey())];
|
|
423
423
|
case 4:
|
|
424
424
|
pt = R.sent(), R.label = 5;
|
|
425
425
|
case 5:
|
|
426
|
-
return [4,
|
|
426
|
+
return [4, Wt(null, pt)];
|
|
427
427
|
case 6:
|
|
428
428
|
case 7:
|
|
429
429
|
return R.sent(), [3, 8];
|
|
@@ -434,13 +434,13 @@ var Ut = { exports: {} };
|
|
|
434
434
|
case 10:
|
|
435
435
|
return R.sent(), [3, 12];
|
|
436
436
|
case 11:
|
|
437
|
-
if (L) this._onChange(null, { isFromServer: !1, flagsChanged:
|
|
438
|
-
else if (this.flags && (nt = null, Object.keys(this.flags).length === 0 && (nt = ft), this._onChange(null, { isFromServer: !1, flagsChanged:
|
|
437
|
+
if (L) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, L), traitsChanged: b({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
|
|
438
|
+
else if (this.flags && (nt = null, Object.keys(this.flags).length === 0 && (nt = ft), this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(nt, g.DEFAULT_FLAGS)), nt)) throw new Error(nt);
|
|
439
439
|
R.label = 12;
|
|
440
440
|
case 12:
|
|
441
441
|
return [3, 14];
|
|
442
442
|
case 13:
|
|
443
|
-
throw Y = R.sent(), this.log("Error during initialisation ", Y),
|
|
443
|
+
throw Y = R.sent(), this.log("Error during initialisation ", Y), te = Y instanceof Error ? Y : new Error("".concat(Y)), (n = this.onError) === null || n === void 0 || n.call(this, te), Y;
|
|
444
444
|
case 14:
|
|
445
445
|
return [2];
|
|
446
446
|
}
|
|
@@ -456,7 +456,7 @@ var Ut = { exports: {} };
|
|
|
456
456
|
}, a.prototype.getState = function() {
|
|
457
457
|
return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
|
|
458
458
|
}, a.prototype.setState = function(e) {
|
|
459
|
-
e && (this.initialised = !0, this.api = e.api || this.api ||
|
|
459
|
+
e && (this.initialised = !0, this.api = e.api || this.api || Gt, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
|
|
460
460
|
}, a.prototype.logout = function() {
|
|
461
461
|
return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
|
|
462
462
|
}, a.prototype.startListening = function(e) {
|
|
@@ -472,12 +472,12 @@ var Ut = { exports: {} };
|
|
|
472
472
|
if (this.cacheFlags) {
|
|
473
473
|
this.ts = (/* @__PURE__ */ new Date()).valueOf();
|
|
474
474
|
var e = JSON.stringify(this.getState());
|
|
475
|
-
this.log("Setting storage", e),
|
|
475
|
+
this.log("Setting storage", e), w.setItem(this.getStorageKey(), e);
|
|
476
476
|
}
|
|
477
477
|
}, a.prototype.updateEventStorage = function() {
|
|
478
478
|
if (this.enableAnalytics) {
|
|
479
479
|
var e = JSON.stringify(this.getState().evaluationEvent);
|
|
480
|
-
|
|
480
|
+
w.setItem(rt, e).catch(function(t) {
|
|
481
481
|
return console.error("Flagsmith: Error setting item in async storage", t);
|
|
482
482
|
});
|
|
483
483
|
}
|
|
@@ -490,8 +490,8 @@ var Ut = { exports: {} };
|
|
|
490
490
|
var o;
|
|
491
491
|
try {
|
|
492
492
|
o = JSON.parse(r.data).updated_at;
|
|
493
|
-
} catch (
|
|
494
|
-
i.log("Could not parse sse event",
|
|
493
|
+
} catch (c) {
|
|
494
|
+
i.log("Could not parse sse event", c);
|
|
495
495
|
}
|
|
496
496
|
o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", r.data, i.timestamp) : (i.log("updated_at is new, fetching flags", r.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", r.data, i.timestamp) : i.log("No updated_at received, fetching flags", r);
|
|
497
497
|
})) : this.log("Error, EventSource is undefined");
|
|
@@ -513,7 +513,7 @@ var Ut = { exports: {} };
|
|
|
513
513
|
this.constructor = a;
|
|
514
514
|
}
|
|
515
515
|
ot(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
516
|
-
}),
|
|
516
|
+
}), Bt = function(a) {
|
|
517
517
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
|
|
518
518
|
if (t) return t.call(a);
|
|
519
519
|
if (a && typeof a.length == "number") return { next: function() {
|
|
@@ -526,8 +526,8 @@ var Ut = { exports: {} };
|
|
|
526
526
|
var i, n, r = t.call(a), o = [];
|
|
527
527
|
try {
|
|
528
528
|
for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
|
|
529
|
-
} catch (
|
|
530
|
-
n = { error:
|
|
529
|
+
} catch (c) {
|
|
530
|
+
n = { error: c };
|
|
531
531
|
} finally {
|
|
532
532
|
try {
|
|
533
533
|
i && !i.done && (t = r.return) && t.call(r);
|
|
@@ -545,7 +545,7 @@ var Ut = { exports: {} };
|
|
|
545
545
|
Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
|
|
546
546
|
}
|
|
547
547
|
return oe(e, a), e;
|
|
548
|
-
}(Error),
|
|
548
|
+
}(Error), $t = function() {
|
|
549
549
|
function a(e, t) {
|
|
550
550
|
var i = this;
|
|
551
551
|
if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = t != null ? Object.assign({}, t) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = e.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new se();
|
|
@@ -565,9 +565,9 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
565
565
|
i.onmessage(h);
|
|
566
566
|
};
|
|
567
567
|
try {
|
|
568
|
-
for (var r =
|
|
569
|
-
var
|
|
570
|
-
this._eventSource.addEventListener(
|
|
568
|
+
for (var r = Bt(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
|
|
569
|
+
var c = o.value;
|
|
570
|
+
this._eventSource.addEventListener(c, this._onevent_wrapped);
|
|
571
571
|
}
|
|
572
572
|
} catch (h) {
|
|
573
573
|
e = { error: h };
|
|
@@ -594,10 +594,10 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
594
594
|
e && e.lastEventId && (this._lastEventId = e.lastEventId);
|
|
595
595
|
var n = this._listeners[e.type];
|
|
596
596
|
if (n != null) try {
|
|
597
|
-
for (var r =
|
|
597
|
+
for (var r = Bt(vt([], Ht(n), !1)), o = r.next(); !o.done; o = r.next())
|
|
598
598
|
o.value.call(this, e);
|
|
599
|
-
} catch (
|
|
600
|
-
t = { error:
|
|
599
|
+
} catch (c) {
|
|
600
|
+
t = { error: c };
|
|
601
601
|
} finally {
|
|
602
602
|
try {
|
|
603
603
|
o && !o.done && (i = r.return) && i.call(r);
|
|
@@ -623,9 +623,9 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
623
623
|
}, a;
|
|
624
624
|
}();
|
|
625
625
|
globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
|
|
626
|
-
var
|
|
626
|
+
var qt = function(a, e) {
|
|
627
627
|
return e = e || {}, new Promise(function(t, i) {
|
|
628
|
-
var n = new XMLHttpRequest(), r = [], o = [],
|
|
628
|
+
var n = new XMLHttpRequest(), r = [], o = [], c = {}, h = function() {
|
|
629
629
|
return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
|
|
630
630
|
return Promise.resolve(n.responseText);
|
|
631
631
|
}, json: function() {
|
|
@@ -636,28 +636,28 @@ Consider loading an EventSource polyfill and making it available globally as Eve
|
|
|
636
636
|
return r;
|
|
637
637
|
}, entries: function() {
|
|
638
638
|
return o;
|
|
639
|
-
}, get: function(
|
|
640
|
-
return u
|
|
641
|
-
}, has: function(
|
|
642
|
-
return
|
|
639
|
+
}, get: function(u) {
|
|
640
|
+
return c[u.toLowerCase()];
|
|
641
|
+
}, has: function(u) {
|
|
642
|
+
return u.toLowerCase() in c;
|
|
643
643
|
} } };
|
|
644
644
|
};
|
|
645
|
-
for (var
|
|
646
|
-
n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(
|
|
647
|
-
r.push(
|
|
645
|
+
for (var y in n.open(e.method || "get", a, !0), n.onload = function() {
|
|
646
|
+
n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(u, m, E) {
|
|
647
|
+
r.push(m = m.toLowerCase()), o.push([m, E]), c[m] = c[m] ? c[m] + "," + E : E;
|
|
648
648
|
}), t(h());
|
|
649
|
-
}, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(
|
|
649
|
+
}, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(y, e.headers[y]);
|
|
650
650
|
n.send(e.body || null);
|
|
651
651
|
});
|
|
652
|
-
},
|
|
653
|
-
typeof window < "u" && (window.flagsmith =
|
|
654
|
-
return Mt({ AsyncStorage:
|
|
655
|
-
},
|
|
652
|
+
}, Xt = Mt({ AsyncStorage: v, fetch: qt, eventSource: $t });
|
|
653
|
+
typeof window < "u" && (window.flagsmith = Xt), d.createFlagsmithInstance = function() {
|
|
654
|
+
return Mt({ AsyncStorage: v, fetch: qt, eventSource: $t });
|
|
655
|
+
}, d.default = Xt, Object.defineProperty(d, "__esModule", { value: !0 });
|
|
656
656
|
});
|
|
657
657
|
})(Ut, Ut.exports);
|
|
658
|
-
var
|
|
658
|
+
var ge = Ut.exports, fe = {
|
|
659
659
|
NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first."
|
|
660
|
-
},
|
|
660
|
+
}, ie = "business", J, pe = (J = class {
|
|
661
661
|
constructor() {
|
|
662
662
|
st(this, "flagsmithClient", null);
|
|
663
663
|
st(this, "userContext", null);
|
|
@@ -667,26 +667,26 @@ var de = Ut.exports, ge = {
|
|
|
667
667
|
}
|
|
668
668
|
ensureInitialized() {
|
|
669
669
|
if (!this.flagsmithClient)
|
|
670
|
-
throw new Error(
|
|
670
|
+
throw new Error(fe.NOT_INITIALIZED);
|
|
671
671
|
}
|
|
672
|
-
async init(
|
|
672
|
+
async init(l, d = []) {
|
|
673
673
|
if (!this.flagsmithClient)
|
|
674
674
|
try {
|
|
675
|
-
this.flagsmithClient =
|
|
676
|
-
const
|
|
675
|
+
this.flagsmithClient = ge.createFlagsmithInstance();
|
|
676
|
+
const v = d.reduce((s, F) => (s[F.feature.name] = F, s), {});
|
|
677
677
|
await this.flagsmithClient.init({
|
|
678
|
-
environmentID:
|
|
679
|
-
api: (
|
|
680
|
-
enableAnalytics: (
|
|
681
|
-
defaultFlags:
|
|
682
|
-
cacheFlags: (
|
|
678
|
+
environmentID: l.apiKey,
|
|
679
|
+
api: (l == null ? void 0 : l.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
|
|
680
|
+
enableAnalytics: (l == null ? void 0 : l.enableAnalytics) ?? !0,
|
|
681
|
+
defaultFlags: v,
|
|
682
|
+
cacheFlags: (l == null ? void 0 : l.cacheFlags) ?? !0
|
|
683
683
|
});
|
|
684
|
-
} catch (
|
|
685
|
-
throw console.error("Failed to initialize FeatureFlag:",
|
|
684
|
+
} catch (v) {
|
|
685
|
+
throw console.error("Failed to initialize FeatureFlag:", v), v;
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
|
-
async setUser(
|
|
689
|
-
this.ensureInitialized(), this.userContext = { identifier:
|
|
688
|
+
async setUser(l) {
|
|
689
|
+
this.ensureInitialized(), this.userContext = { identifier: l }, await this.updateContext();
|
|
690
690
|
}
|
|
691
691
|
async updateContext() {
|
|
692
692
|
try {
|
|
@@ -696,58 +696,58 @@ var de = Ut.exports, ge = {
|
|
|
696
696
|
identifier: this.userContext.identifier
|
|
697
697
|
}
|
|
698
698
|
});
|
|
699
|
-
} catch (
|
|
700
|
-
throw console.error("Failed to update user context:",
|
|
699
|
+
} catch (l) {
|
|
700
|
+
throw console.error("Failed to update user context:", l), l;
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
703
|
async getFlags() {
|
|
704
704
|
this.ensureInitialized();
|
|
705
|
-
const
|
|
706
|
-
return Object.entries(
|
|
705
|
+
const l = this.flagsmithClient.getAllFlags();
|
|
706
|
+
return Object.entries(l).map(([d, v]) => {
|
|
707
707
|
var s;
|
|
708
708
|
return {
|
|
709
709
|
feature: {
|
|
710
|
-
name:
|
|
711
|
-
id: (
|
|
710
|
+
name: d,
|
|
711
|
+
id: (v == null ? void 0 : v.id) ?? 0
|
|
712
712
|
},
|
|
713
|
-
enabled:
|
|
714
|
-
value: ((s =
|
|
713
|
+
enabled: v.enabled,
|
|
714
|
+
value: ((s = v.value) == null ? void 0 : s.toString()) ?? null
|
|
715
715
|
};
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
|
-
getFlagValue(
|
|
718
|
+
getFlagValue(l, d) {
|
|
719
719
|
this.ensureInitialized();
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
720
|
+
const v = this.flagsmithClient.getValue(l);
|
|
721
|
+
if (v == null)
|
|
722
722
|
return null;
|
|
723
723
|
try {
|
|
724
|
-
const s =
|
|
725
|
-
return
|
|
724
|
+
const s = v.toString();
|
|
725
|
+
return d ? d(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
|
|
726
726
|
} catch (s) {
|
|
727
727
|
return console.error("Error transforming flag value:", s), null;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
-
getFlag(
|
|
730
|
+
getFlag(l) {
|
|
731
731
|
this.ensureInitialized();
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
const
|
|
732
|
+
const d = this.flagsmithClient.getValue(l);
|
|
733
|
+
if (d == null) return null;
|
|
734
|
+
const v = this.flagsmithClient.hasFeature(l);
|
|
735
735
|
return {
|
|
736
736
|
feature: {
|
|
737
|
-
name:
|
|
737
|
+
name: l,
|
|
738
738
|
id: 0
|
|
739
739
|
},
|
|
740
|
-
enabled:
|
|
741
|
-
value:
|
|
740
|
+
enabled: v,
|
|
741
|
+
value: d.toString()
|
|
742
742
|
};
|
|
743
743
|
}
|
|
744
|
-
async getUserFlagValue(
|
|
744
|
+
async getUserFlagValue(l, d, v = null, s) {
|
|
745
745
|
var I;
|
|
746
746
|
const F = this.userContext;
|
|
747
747
|
try {
|
|
748
|
-
return await this.setUser(
|
|
748
|
+
return await this.setUser(l), this.getFlagValue(d, s) ?? v;
|
|
749
749
|
} catch (N) {
|
|
750
|
-
return console.error(`Error getting user flag value for ${
|
|
750
|
+
return console.error(`Error getting user flag value for ${d}:`, N), v;
|
|
751
751
|
} finally {
|
|
752
752
|
try {
|
|
753
753
|
await ((I = this.flagsmithClient) == null ? void 0 : I.logout()), this.userContext = null, F && await this.setUser(F.identifier);
|
|
@@ -759,51 +759,51 @@ var de = Ut.exports, ge = {
|
|
|
759
759
|
reset() {
|
|
760
760
|
this.flagsmithClient = null, this.userContext = null;
|
|
761
761
|
}
|
|
762
|
-
}, st(J, "instance"), J),
|
|
763
|
-
function
|
|
764
|
-
const
|
|
762
|
+
}, st(J, "instance"), J), ye = pe.getInstance(), it = $(!1), ut = $([]), Q = $(null);
|
|
763
|
+
function me(f = ye) {
|
|
764
|
+
const l = () => it.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), d = async (g, p = []) => {
|
|
765
765
|
if (it.value) {
|
|
766
766
|
console.warn("FeatureFlag is already initialized.");
|
|
767
767
|
return;
|
|
768
768
|
}
|
|
769
769
|
try {
|
|
770
|
-
await
|
|
771
|
-
} catch (
|
|
772
|
-
console.error("Failed to initialize feature flags:",
|
|
770
|
+
await f.init(g, p), ut.value = await f.getFlags(), it.value = !0, Q.value = null;
|
|
771
|
+
} catch (_) {
|
|
772
|
+
console.error("Failed to initialize feature flags:", _), Q.value = _;
|
|
773
773
|
}
|
|
774
|
-
},
|
|
775
|
-
if (
|
|
774
|
+
}, v = async (g) => {
|
|
775
|
+
if (l())
|
|
776
776
|
try {
|
|
777
|
-
await
|
|
778
|
-
} catch (
|
|
779
|
-
console.error("Failed to set user:",
|
|
777
|
+
await f.setUser(g), ut.value = await f.getFlags(), Q.value = null;
|
|
778
|
+
} catch (p) {
|
|
779
|
+
console.error("Failed to set user:", p), Q.value = p;
|
|
780
780
|
}
|
|
781
|
-
}, s = async (
|
|
782
|
-
if (!
|
|
781
|
+
}, s = async (g) => v(`${ie}-${g}`), F = (g, p, _ = null) => {
|
|
782
|
+
if (!l()) return _;
|
|
783
783
|
try {
|
|
784
|
-
return
|
|
784
|
+
return f.getFlagValue(g, p) ?? _;
|
|
785
785
|
} catch (V) {
|
|
786
|
-
return console.error(`Error getting flag value for ${
|
|
786
|
+
return console.error(`Error getting flag value for ${g}:`, V), _;
|
|
787
787
|
}
|
|
788
|
-
}, I = (
|
|
789
|
-
if (!
|
|
788
|
+
}, I = (g, p) => {
|
|
789
|
+
if (!l()) return p ?? null;
|
|
790
790
|
try {
|
|
791
|
-
return
|
|
792
|
-
} catch (
|
|
793
|
-
return console.error(`Error getting flag for ${
|
|
791
|
+
return f.getFlag(g) ?? p ?? null;
|
|
792
|
+
} catch (_) {
|
|
793
|
+
return console.error(`Error getting flag for ${g}:`, _), p ?? null;
|
|
794
794
|
}
|
|
795
|
-
}, N = async (
|
|
796
|
-
if (!
|
|
795
|
+
}, N = async (g, p, _ = null, V) => {
|
|
796
|
+
if (!l()) return _;
|
|
797
797
|
try {
|
|
798
|
-
return await
|
|
798
|
+
return await f.getUserFlagValue(g, p, _, V);
|
|
799
799
|
} catch (at) {
|
|
800
|
-
return console.error(`Error getting user flag value for ${
|
|
800
|
+
return console.error(`Error getting user flag value for ${p}:`, at), _;
|
|
801
801
|
}
|
|
802
|
-
}, k = async (
|
|
802
|
+
}, k = async (g, p, _ = null, V) => N(`${ie}-${g}`, p, _, V), b = () => {
|
|
803
803
|
try {
|
|
804
|
-
|
|
805
|
-
} catch (
|
|
806
|
-
console.error("Error resetting feature flags:",
|
|
804
|
+
f.reset();
|
|
805
|
+
} catch (g) {
|
|
806
|
+
console.error("Error resetting feature flags:", g);
|
|
807
807
|
} finally {
|
|
808
808
|
ut.value = [], it.value = !1, Q.value = null;
|
|
809
809
|
}
|
|
@@ -812,39 +812,55 @@ function ye(C = pe) {
|
|
|
812
812
|
flags: Pt(ut),
|
|
813
813
|
isInitialized: Pt(it),
|
|
814
814
|
error: Pt(Q),
|
|
815
|
-
init:
|
|
816
|
-
setUser:
|
|
815
|
+
init: d,
|
|
816
|
+
setUser: v,
|
|
817
817
|
setBusiness: s,
|
|
818
818
|
getFlagValue: F,
|
|
819
819
|
getFlag: I,
|
|
820
820
|
getUserFlagValue: N,
|
|
821
821
|
getBusinessFlagValue: k,
|
|
822
|
-
reset:
|
|
822
|
+
reset: b
|
|
823
823
|
};
|
|
824
824
|
}
|
|
825
|
-
var
|
|
825
|
+
var Dt = () => me();
|
|
826
826
|
const Kt = $(!1), Rt = $({});
|
|
827
|
-
async function
|
|
828
|
-
const { init:
|
|
829
|
-
await
|
|
827
|
+
async function Ee(f) {
|
|
828
|
+
const { init: l } = Dt();
|
|
829
|
+
await l({ apiKey: f === "prod" ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee" }), Kt.value = !0;
|
|
830
|
+
}
|
|
831
|
+
const Se = (f) => {
|
|
832
|
+
try {
|
|
833
|
+
const l = typeof f == "string" ? JSON.parse(f) : f;
|
|
834
|
+
return l === !0 || l === "true" || (l == null ? void 0 : l.enabled) === !0 || (l == null ? void 0 : l.enabled) === "true";
|
|
835
|
+
} catch {
|
|
836
|
+
return f === !0 || f === "true";
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
function xe(f) {
|
|
840
|
+
const { flags: l, isInitialized: d } = Dt();
|
|
841
|
+
return ve(() => {
|
|
842
|
+
if (!d.value) return !1;
|
|
843
|
+
const v = l.value.find((s) => s.feature.name === f);
|
|
844
|
+
return !!(v != null && v.enabled) && Se(v == null ? void 0 : v.value);
|
|
845
|
+
});
|
|
830
846
|
}
|
|
831
|
-
function
|
|
832
|
-
const
|
|
833
|
-
var
|
|
834
|
-
const k = (
|
|
847
|
+
function Oe(f, l, d) {
|
|
848
|
+
const v = de(), { getBusinessFlagValue: s } = Dt(), F = $(l), I = $(!0), N = async () => {
|
|
849
|
+
var g;
|
|
850
|
+
const k = (g = v.currentBusiness.value) == null ? void 0 : g._id;
|
|
835
851
|
if (!k || !Kt.value)
|
|
836
852
|
return;
|
|
837
|
-
const
|
|
838
|
-
if (
|
|
839
|
-
const
|
|
840
|
-
F.value =
|
|
853
|
+
const b = `${k}:${f}`;
|
|
854
|
+
if (b in Rt.value) {
|
|
855
|
+
const p = Rt.value[b];
|
|
856
|
+
F.value = d ? d(p) : p, I.value = !1;
|
|
841
857
|
return;
|
|
842
858
|
}
|
|
843
859
|
try {
|
|
844
|
-
const
|
|
845
|
-
Rt.value[
|
|
860
|
+
const p = await s(k, f, l);
|
|
861
|
+
Rt.value[b] = p, F.value = d ? d(p) : p;
|
|
846
862
|
} catch {
|
|
847
|
-
F.value =
|
|
863
|
+
F.value = l;
|
|
848
864
|
} finally {
|
|
849
865
|
I.value = !1;
|
|
850
866
|
}
|
|
@@ -852,7 +868,7 @@ function Fe(C, c, v) {
|
|
|
852
868
|
return he(
|
|
853
869
|
[() => {
|
|
854
870
|
var k;
|
|
855
|
-
return (k =
|
|
871
|
+
return (k = v.currentBusiness.value) == null ? void 0 : k._id;
|
|
856
872
|
}, Kt],
|
|
857
873
|
() => {
|
|
858
874
|
I.value = !0, N();
|
|
@@ -861,6 +877,8 @@ function Fe(C, c, v) {
|
|
|
861
877
|
), { value: F, loading: I };
|
|
862
878
|
}
|
|
863
879
|
export {
|
|
864
|
-
|
|
865
|
-
|
|
880
|
+
Oe as a,
|
|
881
|
+
Se as b,
|
|
882
|
+
Ee as i,
|
|
883
|
+
xe as u
|
|
866
884
|
};
|