@unleash/proxy-client-vue 0.0.3 → 0.0.4

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/index.es.js CHANGED
@@ -182,11 +182,12 @@ var __generator$2 = commonjsGlobal && commonjsGlobal.__generator || function(thi
182
182
  Object.defineProperty(metrics, "__esModule", { value: true });
183
183
  var Metrics = function() {
184
184
  function Metrics2(_a) {
185
- var appName = _a.appName, metricsInterval = _a.metricsInterval, _b = _a.disableMetrics, disableMetrics = _b === void 0 ? false : _b, url = _a.url, clientKey = _a.clientKey, fetch2 = _a.fetch, headerName = _a.headerName;
185
+ var onError = _a.onError, appName = _a.appName, metricsInterval = _a.metricsInterval, _b = _a.disableMetrics, disableMetrics = _b === void 0 ? false : _b, url = _a.url, clientKey = _a.clientKey, fetch2 = _a.fetch, headerName = _a.headerName;
186
+ this.onError = onError;
186
187
  this.disabled = disableMetrics;
187
188
  this.metricsInterval = metricsInterval * 1e3;
188
189
  this.appName = appName;
189
- this.url = url;
190
+ this.url = url instanceof URL ? url : new URL(url);
190
191
  this.clientKey = clientKey;
191
192
  this.bucket = this.createEmptyBucket();
192
193
  this.fetch = fetch2;
@@ -219,7 +220,7 @@ var Metrics = function() {
219
220
  };
220
221
  Metrics2.prototype.sendMetrics = function() {
221
222
  return __awaiter$2(this, void 0, void 0, function() {
222
- var url, payload;
223
+ var url, payload, e_1;
223
224
  var _a;
224
225
  return __generator$2(this, function(_b) {
225
226
  switch (_b.label) {
@@ -229,14 +230,24 @@ var Metrics = function() {
229
230
  if (this.bucketIsEmpty(payload)) {
230
231
  return [2];
231
232
  }
233
+ _b.label = 1;
234
+ case 1:
235
+ _b.trys.push([1, 3, , 4]);
232
236
  return [4, this.fetch(url, {
233
237
  cache: "no-cache",
234
238
  method: "POST",
235
239
  headers: (_a = {}, _a[this.headerName] = this.clientKey, _a.Accept = "application/json", _a["Content-Type"] = "application/json", _a),
236
240
  body: JSON.stringify(payload)
237
241
  })];
238
- case 1:
242
+ case 2:
239
243
  _b.sent();
244
+ return [3, 4];
245
+ case 3:
246
+ e_1 = _b.sent();
247
+ console.error("Unleash: unable to send feature metrics", e_1);
248
+ this.onError(e_1);
249
+ return [3, 4];
250
+ case 4:
240
251
  return [2];
241
252
  }
242
253
  });
@@ -1194,7 +1205,7 @@ util.notNullOrUndefined = notNullOrUndefined;
1194
1205
  }
1195
1206
  _this.eventsHandler = new events_handler_1.default();
1196
1207
  _this.toggles = bootstrap && bootstrap.length > 0 ? bootstrap : [];
1197
- _this.url = new URL("".concat(url));
1208
+ _this.url = url instanceof URL ? url : new URL(url);
1198
1209
  _this.clientKey = clientKey;
1199
1210
  _this.headerName = headerName;
1200
1211
  _this.customHeaders = customHeaders;
@@ -1202,26 +1213,10 @@ util.notNullOrUndefined = notNullOrUndefined;
1202
1213
  _this.refreshInterval = disableRefresh ? 0 : refreshInterval * 1e3;
1203
1214
  _this.context = __assign2({ appName, environment }, context);
1204
1215
  _this.ready = new Promise(function(resolve) {
1205
- return __awaiter2(_this, void 0, void 0, function() {
1206
- var error_1;
1207
- return __generator2(this, function(_a2) {
1208
- switch (_a2.label) {
1209
- case 0:
1210
- _a2.trys.push([0, 2, , 3]);
1211
- return [4, this.init()];
1212
- case 1:
1213
- _a2.sent();
1214
- return [3, 3];
1215
- case 2:
1216
- error_1 = _a2.sent();
1217
- console.error(error_1);
1218
- this.emit(exports.EVENTS.ERROR, error_1);
1219
- return [3, 3];
1220
- case 3:
1221
- resolve();
1222
- return [2];
1223
- }
1224
- });
1216
+ _this.init().then(resolve).catch(function(error) {
1217
+ console.error(error);
1218
+ _this.emit(exports.EVENTS.ERROR, error);
1219
+ resolve();
1225
1220
  });
1226
1221
  });
1227
1222
  if (!fetch2) {
@@ -1231,10 +1226,11 @@ util.notNullOrUndefined = notNullOrUndefined;
1231
1226
  _this.bootstrap = bootstrap && bootstrap.length > 0 ? bootstrap : void 0;
1232
1227
  _this.bootstrapOverride = bootstrapOverride;
1233
1228
  _this.metrics = new metrics_1.default({
1229
+ onError: _this.emit.bind(_this, exports.EVENTS.ERROR),
1234
1230
  appName,
1235
1231
  metricsInterval,
1236
1232
  disableMetrics,
1237
- url,
1233
+ url: _this.url,
1238
1234
  clientKey,
1239
1235
  fetch: fetch2,
1240
1236
  headerName
@@ -1406,7 +1402,7 @@ util.notNullOrUndefined = notNullOrUndefined;
1406
1402
  };
1407
1403
  UnleashClient3.prototype.getHeaders = function() {
1408
1404
  var _a;
1409
- var headers = (_a = {}, _a[this.headerName] = this.clientKey, _a["Accept"] = "application/json", _a["Content-Type"] = "application/json", _a["If-None-Match"] = this.etag, _a);
1405
+ var headers = (_a = {}, _a[this.headerName] = this.clientKey, _a.Accept = "application/json", _a["Content-Type"] = "application/json", _a["If-None-Match"] = this.etag, _a);
1410
1406
  Object.entries(this.customHeaders).filter(util_1.notNullOrUndefined).forEach(function(_a2) {
1411
1407
  var name = _a2[0], value = _a2[1];
1412
1408
  return headers[name] = value;
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(T,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],b):(T=typeof globalThis!="undefined"?globalThis:T||self,b(T["proxy-client-vue"]={},T.Vue))})(this,function(T,b){"use strict";var m=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Oe(t){if(t.__esModule)return t;var i=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),i}var F={},Z={exports:{}};function W(){}W.prototype={on:function(t,i,e){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:i,ctx:e}),this},once:function(t,i,e){var n=this;function a(){n.off(t,a),i.apply(e,arguments)}return a._=i,this.on(t,a,e)},emit:function(t){var i=[].slice.call(arguments,1),e=((this.e||(this.e={}))[t]||[]).slice(),n=0,a=e.length;for(n;n<a;n++)e[n].fn.apply(e[n].ctx,i);return this},off:function(t,i){var e=this.e||(this.e={}),n=e[t],a=[];if(n&&i)for(var r=0,o=n.length;r<o;r++)n[r].fn!==i&&n[r].fn._!==i&&a.push(n[r]);return a.length?e[t]=a:delete e[t],this}},Z.exports=W,Z.exports.TinyEmitter=W;var ee={},$=m&&m.__assign||function(){return $=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},$.apply(this,arguments)},Ue=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},Re=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(ee,"__esModule",{value:!0});var Ce=function(){function t(i){var e=i.appName,n=i.metricsInterval,a=i.disableMetrics,r=a===void 0?!1:a,o=i.url,d=i.clientKey,v=i.fetch,s=i.headerName;this.disabled=r,this.metricsInterval=n*1e3,this.appName=e,this.url=o,this.clientKey=d,this.bucket=this.createEmptyBucket(),this.fetch=v,this.headerName=s}return t.prototype.start=function(){var i=this;if(this.disabled)return!1;typeof this.metricsInterval=="number"&&this.metricsInterval>0&&setTimeout(function(){i.startTimer(),i.sendMetrics()},2e3)},t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer)},t.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},t.prototype.sendMetrics=function(){return Ue(this,void 0,void 0,function(){var i,e,n;return Re(this,function(a){switch(a.label){case 0:return i="".concat(this.url,"/client/metrics"),e=this.getPayload(),this.bucketIsEmpty(e)?[2]:[4,this.fetch(i,{cache:"no-cache",method:"POST",headers:(n={},n[this.headerName]=this.clientKey,n.Accept="application/json",n["Content-Type"]="application/json",n),body:JSON.stringify(e)})];case 1:return a.sent(),[2]}})})},t.prototype.count=function(i,e){return this.disabled||!this.bucket?!1:(this.assertBucket(i),this.bucket.toggles[i][e?"yes":"no"]++,!0)},t.prototype.assertBucket=function(i){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[i]||(this.bucket.toggles[i]={yes:0,no:0})},t.prototype.startTimer=function(){var i=this;this.timer=setInterval(function(){i.sendMetrics()},this.metricsInterval)},t.prototype.bucketIsEmpty=function(i){return Object.keys(i.bucket.toggles).length===0},t.prototype.getPayload=function(){var i=$($({},this.bucket),{stop:new Date});return this.bucket=this.createEmptyBucket(),{bucket:i,appName:this.appName,instanceId:"browser"}},t}();ee.default=Ce;var te={},de=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},ve=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(te,"__esModule",{value:!0});var Me=function(){function t(){this.store=new Map}return t.prototype.save=function(i,e){return de(this,void 0,void 0,function(){return ve(this,function(n){return this.store.set(i,e),[2]})})},t.prototype.get=function(i){return de(this,void 0,void 0,function(){return ve(this,function(e){return[2,this.store.get(i)]})})},t}();te.default=Me;var re={},Ae=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},ke=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(re,"__esModule",{value:!0});var Pe=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(i,e){return Ae(this,void 0,void 0,function(){var n,a;return ke(this,function(r){n=JSON.stringify(e),a="".concat(this.prefix,":").concat(i);try{window.localStorage.setItem(a,n)}catch(o){console.error(o)}return[2]})})},t.prototype.get=function(i){try{var e="".concat(this.prefix,":").concat(i),n=window.localStorage.getItem(e);return n?JSON.parse(n):void 0}catch(a){console.error(a)}},t}();re.default=Pe;var ne={},q,je=new Uint8Array(16);function ye(){if(!q&&(q=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return q(je)}var Ve=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function G(t){return typeof t=="string"&&Ve.test(t)}for(var x=[],ae=0;ae<256;++ae)x.push((ae+256).toString(16).substr(1));function B(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(x[t[i+0]]+x[t[i+1]]+x[t[i+2]]+x[t[i+3]]+"-"+x[t[i+4]]+x[t[i+5]]+"-"+x[t[i+6]]+x[t[i+7]]+"-"+x[t[i+8]]+x[t[i+9]]+"-"+x[t[i+10]]+x[t[i+11]]+x[t[i+12]]+x[t[i+13]]+x[t[i+14]]+x[t[i+15]]).toLowerCase();if(!G(e))throw TypeError("Stringified UUID is invalid");return e}var pe,ie,oe=0,se=0;function De(t,i,e){var n=i&&e||0,a=i||new Array(16);t=t||{};var r=t.node||pe,o=t.clockseq!==void 0?t.clockseq:ie;if(r==null||o==null){var d=t.random||(t.rng||ye)();r==null&&(r=pe=[d[0]|1,d[1],d[2],d[3],d[4],d[5]]),o==null&&(o=ie=(d[6]<<8|d[7])&16383)}var v=t.msecs!==void 0?t.msecs:Date.now(),s=t.nsecs!==void 0?t.nsecs:se+1,h=v-oe+(s-se)/1e4;if(h<0&&t.clockseq===void 0&&(o=o+1&16383),(h<0||v>oe)&&t.nsecs===void 0&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");oe=v,se=s,ie=o,v+=122192928e5;var g=((v&268435455)*1e4+s)%4294967296;a[n++]=g>>>24&255,a[n++]=g>>>16&255,a[n++]=g>>>8&255,a[n++]=g&255;var M=v/4294967296*1e4&268435455;a[n++]=M>>>8&255,a[n++]=M&255,a[n++]=M>>>24&15|16,a[n++]=M>>>16&255,a[n++]=o>>>8|128,a[n++]=o&255;for(var k=0;k<6;++k)a[n+k]=r[k];return i||B(a)}function ge(t){if(!G(t))throw TypeError("Invalid UUID");var i,e=new Uint8Array(16);return e[0]=(i=parseInt(t.slice(0,8),16))>>>24,e[1]=i>>>16&255,e[2]=i>>>8&255,e[3]=i&255,e[4]=(i=parseInt(t.slice(9,13),16))>>>8,e[5]=i&255,e[6]=(i=parseInt(t.slice(14,18),16))>>>8,e[7]=i&255,e[8]=(i=parseInt(t.slice(19,23),16))>>>8,e[9]=i&255,e[10]=(i=parseInt(t.slice(24,36),16))/1099511627776&255,e[11]=i/4294967296&255,e[12]=i>>>24&255,e[13]=i>>>16&255,e[14]=i>>>8&255,e[15]=i&255,e}function Le(t){t=unescape(encodeURIComponent(t));for(var i=[],e=0;e<t.length;++e)i.push(t.charCodeAt(e));return i}var Ke="6ba7b810-9dad-11d1-80b4-00c04fd430c8",He="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function me(t,i,e){function n(a,r,o,d){if(typeof a=="string"&&(a=Le(a)),typeof r=="string"&&(r=ge(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var v=new Uint8Array(16+a.length);if(v.set(r),v.set(a,r.length),v=e(v),v[6]=v[6]&15|i,v[8]=v[8]&63|128,o){d=d||0;for(var s=0;s<16;++s)o[d+s]=v[s];return o}return B(v)}try{n.name=t}catch{}return n.DNS=Ke,n.URL=He,n}function Fe(t){if(typeof t=="string"){var i=unescape(encodeURIComponent(t));t=new Uint8Array(i.length);for(var e=0;e<i.length;++e)t[e]=i.charCodeAt(e)}return $e(qe(Ge(t),t.length*8))}function $e(t){for(var i=[],e=t.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var r=t[a>>5]>>>a%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);i.push(o)}return i}function be(t){return(t+64>>>9<<4)+14+1}function qe(t,i){t[i>>5]|=128<<i%32,t[be(i)-1]=i;for(var e=1732584193,n=-271733879,a=-1732584194,r=271733878,o=0;o<t.length;o+=16){var d=e,v=n,s=a,h=r;e=O(e,n,a,r,t[o],7,-680876936),r=O(r,e,n,a,t[o+1],12,-389564586),a=O(a,r,e,n,t[o+2],17,606105819),n=O(n,a,r,e,t[o+3],22,-1044525330),e=O(e,n,a,r,t[o+4],7,-176418897),r=O(r,e,n,a,t[o+5],12,1200080426),a=O(a,r,e,n,t[o+6],17,-1473231341),n=O(n,a,r,e,t[o+7],22,-45705983),e=O(e,n,a,r,t[o+8],7,1770035416),r=O(r,e,n,a,t[o+9],12,-1958414417),a=O(a,r,e,n,t[o+10],17,-42063),n=O(n,a,r,e,t[o+11],22,-1990404162),e=O(e,n,a,r,t[o+12],7,1804603682),r=O(r,e,n,a,t[o+13],12,-40341101),a=O(a,r,e,n,t[o+14],17,-1502002290),n=O(n,a,r,e,t[o+15],22,1236535329),e=U(e,n,a,r,t[o+1],5,-165796510),r=U(r,e,n,a,t[o+6],9,-1069501632),a=U(a,r,e,n,t[o+11],14,643717713),n=U(n,a,r,e,t[o],20,-373897302),e=U(e,n,a,r,t[o+5],5,-701558691),r=U(r,e,n,a,t[o+10],9,38016083),a=U(a,r,e,n,t[o+15],14,-660478335),n=U(n,a,r,e,t[o+4],20,-405537848),e=U(e,n,a,r,t[o+9],5,568446438),r=U(r,e,n,a,t[o+14],9,-1019803690),a=U(a,r,e,n,t[o+3],14,-187363961),n=U(n,a,r,e,t[o+8],20,1163531501),e=U(e,n,a,r,t[o+13],5,-1444681467),r=U(r,e,n,a,t[o+2],9,-51403784),a=U(a,r,e,n,t[o+7],14,1735328473),n=U(n,a,r,e,t[o+12],20,-1926607734),e=R(e,n,a,r,t[o+5],4,-378558),r=R(r,e,n,a,t[o+8],11,-2022574463),a=R(a,r,e,n,t[o+11],16,1839030562),n=R(n,a,r,e,t[o+14],23,-35309556),e=R(e,n,a,r,t[o+1],4,-1530992060),r=R(r,e,n,a,t[o+4],11,1272893353),a=R(a,r,e,n,t[o+7],16,-155497632),n=R(n,a,r,e,t[o+10],23,-1094730640),e=R(e,n,a,r,t[o+13],4,681279174),r=R(r,e,n,a,t[o],11,-358537222),a=R(a,r,e,n,t[o+3],16,-722521979),n=R(n,a,r,e,t[o+6],23,76029189),e=R(e,n,a,r,t[o+9],4,-640364487),r=R(r,e,n,a,t[o+12],11,-421815835),a=R(a,r,e,n,t[o+15],16,530742520),n=R(n,a,r,e,t[o+2],23,-995338651),e=C(e,n,a,r,t[o],6,-198630844),r=C(r,e,n,a,t[o+7],10,1126891415),a=C(a,r,e,n,t[o+14],15,-1416354905),n=C(n,a,r,e,t[o+5],21,-57434055),e=C(e,n,a,r,t[o+12],6,1700485571),r=C(r,e,n,a,t[o+3],10,-1894986606),a=C(a,r,e,n,t[o+10],15,-1051523),n=C(n,a,r,e,t[o+1],21,-2054922799),e=C(e,n,a,r,t[o+8],6,1873313359),r=C(r,e,n,a,t[o+15],10,-30611744),a=C(a,r,e,n,t[o+6],15,-1560198380),n=C(n,a,r,e,t[o+13],21,1309151649),e=C(e,n,a,r,t[o+4],6,-145523070),r=C(r,e,n,a,t[o+11],10,-1120210379),a=C(a,r,e,n,t[o+2],15,718787259),n=C(n,a,r,e,t[o+9],21,-343485551),e=D(e,d),n=D(n,v),a=D(a,s),r=D(r,h)}return[e,n,a,r]}function Ge(t){if(t.length===0)return[];for(var i=t.length*8,e=new Uint32Array(be(i)),n=0;n<i;n+=8)e[n>>5]|=(t[n/8]&255)<<n%32;return e}function D(t,i){var e=(t&65535)+(i&65535),n=(t>>16)+(i>>16)+(e>>16);return n<<16|e&65535}function Be(t,i){return t<<i|t>>>32-i}function Y(t,i,e,n,a,r){return D(Be(D(D(i,t),D(n,r)),a),e)}function O(t,i,e,n,a,r,o){return Y(i&e|~i&n,t,i,a,r,o)}function U(t,i,e,n,a,r,o){return Y(i&n|e&~n,t,i,a,r,o)}function R(t,i,e,n,a,r,o){return Y(i^e^n,t,i,a,r,o)}function C(t,i,e,n,a,r,o){return Y(e^(i|~n),t,i,a,r,o)}var Ye=me("v3",48,Fe),Je=Ye;function Qe(t,i,e){t=t||{};var n=t.random||(t.rng||ye)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,i){e=e||0;for(var a=0;a<16;++a)i[e+a]=n[a];return i}return B(n)}function Xe(t,i,e,n){switch(t){case 0:return i&e^~i&n;case 1:return i^e^n;case 2:return i&e^i&n^e&n;case 3:return i^e^n}}function ue(t,i){return t<<i|t>>>32-i}function ze(t){var i=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var n=unescape(encodeURIComponent(t));t=[];for(var a=0;a<n.length;++a)t.push(n.charCodeAt(a))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var r=t.length/4+2,o=Math.ceil(r/16),d=new Array(o),v=0;v<o;++v){for(var s=new Uint32Array(16),h=0;h<16;++h)s[h]=t[v*64+h*4]<<24|t[v*64+h*4+1]<<16|t[v*64+h*4+2]<<8|t[v*64+h*4+3];d[v]=s}d[o-1][14]=(t.length-1)*8/Math.pow(2,32),d[o-1][14]=Math.floor(d[o-1][14]),d[o-1][15]=(t.length-1)*8&4294967295;for(var g=0;g<o;++g){for(var M=new Uint32Array(80),k=0;k<16;++k)M[k]=d[g][k];for(var P=16;P<80;++P)M[P]=ue(M[P-3]^M[P-8]^M[P-14]^M[P-16],1);for(var w=e[0],E=e[1],j=e[2],I=e[3],y=e[4],u=0;u<80;++u){var f=Math.floor(u/20),c=ue(w,5)+Xe(f,E,j,I)+y+i[f]+M[u]>>>0;y=I,I=j,j=ue(E,30)>>>0,E=w,w=c}e[0]=e[0]+w>>>0,e[1]=e[1]+E>>>0,e[2]=e[2]+j>>>0,e[3]=e[3]+I>>>0,e[4]=e[4]+y>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Ze=me("v5",80,ze),We=Ze,et="00000000-0000-0000-0000-000000000000";function tt(t){if(!G(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}var rt=Object.freeze(Object.defineProperty({__proto__:null,v1:De,v3:Je,v4:Qe,v5:We,NIL:et,version:tt,validate:G,stringify:B,parse:ge},Symbol.toStringTag,{value:"Module"})),nt=Oe(rt),J=m&&m.__assign||function(){return J=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},J.apply(this,arguments)};Object.defineProperty(ne,"__esModule",{value:!0});var at=nt,it=function(){function t(){}return t.prototype.generateEventId=function(){return(0,at.v4)()},t.prototype.createImpressionEvent=function(i,e,n,a,r){var o=this.createBaseEvent(i,e,n,a);return r?J(J({},o),{variant:r}):o},t.prototype.createBaseEvent=function(i,e,n,a){return{eventType:a,eventId:this.generateEventId(),context:i,enabled:e,featureName:n}},t}();ne.default=it;var Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.notNullOrUndefined=void 0;var ot=function(t){var i=t[1];return i!=null};Q.notNullOrUndefined=ot,function(t){var i=m&&m.__extends||function(){var I=function(y,u){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,c){f.__proto__=c}||function(f,c){for(var l in c)Object.prototype.hasOwnProperty.call(c,l)&&(f[l]=c[l])},I(y,u)};return function(y,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");I(y,u);function f(){this.constructor=y}y.prototype=u===null?Object.create(u):(f.prototype=u.prototype,new f)}}(),e=m&&m.__assign||function(){return e=Object.assign||function(I){for(var y,u=1,f=arguments.length;u<f;u++){y=arguments[u];for(var c in y)Object.prototype.hasOwnProperty.call(y,c)&&(I[c]=y[c])}return I},e.apply(this,arguments)},n=m&&m.__awaiter||function(I,y,u,f){function c(l){return l instanceof u?l:new u(function(S){S(l)})}return new(u||(u=Promise))(function(l,S){function A(N){try{p(f.next(N))}catch(L){S(L)}}function V(N){try{p(f.throw(N))}catch(L){S(L)}}function p(N){N.done?l(N.value):c(N.value).then(A,V)}p((f=f.apply(I,y||[])).next())})},a=m&&m.__generator||function(I,y){var u={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},f,c,l,S;return S={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function A(p){return function(N){return V([p,N])}}function V(p){if(f)throw new TypeError("Generator is already executing.");for(;u;)try{if(f=1,c&&(l=p[0]&2?c.return:p[0]?c.throw||((l=c.return)&&l.call(c),0):c.next)&&!(l=l.call(c,p[1])).done)return l;switch(c=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return u.label++,{value:p[1],done:!1};case 5:u.label++,c=p[1],p=[0];continue;case 7:p=u.ops.pop(),u.trys.pop();continue;default:if(l=u.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){u=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){u.label=p[1];break}if(p[0]===6&&u.label<l[1]){u.label=l[1],l=p;break}if(l&&u.label<l[2]){u.label=l[2],u.ops.push(p);break}l[2]&&u.ops.pop(),u.trys.pop();continue}p=y.call(I,u)}catch(N){p=[6,N],c=0}finally{f=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},r=m&&m.__spreadArray||function(I,y,u){if(u||arguments.length===2)for(var f=0,c=y.length,l;f<c;f++)(l||!(f in y))&&(l||(l=Array.prototype.slice.call(y,0,f)),l[f]=y[f]);return I.concat(l||Array.prototype.slice.call(y))};Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorageProvider=t.LocalStorageProvider=t.UnleashClient=t.resolveFetch=t.EVENTS=void 0;var o=Z.exports,d=ee,v=te;t.InMemoryStorageProvider=v.default;var s=re;t.LocalStorageProvider=s.default;var h=ne,g=Q,M=["userId","sessionId","remoteAddress"];t.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression"};var k={IS_ENABLED:"isEnabled",GET_VARIANT:"getVariant"},P={name:"disabled",enabled:!1},w="repo",E=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(I){console.error('Unleash failed to resolve "fetch"',I)}};t.resolveFetch=E;var j=function(I){i(y,I);function y(u){var f=u.storageProvider,c=u.url,l=u.clientKey,S=u.disableRefresh,A=S===void 0?!1:S,V=u.refreshInterval,p=V===void 0?30:V,N=u.metricsInterval,L=N===void 0?30:N,X=u.disableMetrics,fe=X===void 0?!1:X,ce=u.appName,Ie=u.environment,ht=Ie===void 0?"default":Ie,dt=u.context,Se=u.fetch,le=Se===void 0?(0,t.resolveFetch)():Se,H=u.bootstrap,_e=u.bootstrapOverride,vt=_e===void 0?!0:_e,Te=u.headerName,Ne=Te===void 0?"Authorization":Te,xe=u.customHeaders,yt=xe===void 0?{}:xe,_=I.call(this)||this;if(_.toggles=[],_.etag="",_.readyEventEmitted=!1,!c)throw new Error("url is required");if(!l)throw new Error("clientKey is required");if(!ce)throw new Error("appName is required.");return _.eventsHandler=new h.default,_.toggles=H&&H.length>0?H:[],_.url=new URL("".concat(c)),_.clientKey=l,_.headerName=Ne,_.customHeaders=yt,_.storage=f||new s.default,_.refreshInterval=A?0:p*1e3,_.context=e({appName:ce,environment:ht},dt),_.ready=new Promise(function(pt){return n(_,void 0,void 0,function(){var he;return a(this,function(z){switch(z.label){case 0:return z.trys.push([0,2,,3]),[4,this.init()];case 1:return z.sent(),[3,3];case 2:return he=z.sent(),console.error(he),this.emit(t.EVENTS.ERROR,he),[3,3];case 3:return pt(),[2]}})})}),le||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),_.fetch=le,_.bootstrap=H&&H.length>0?H:void 0,_.bootstrapOverride=vt,_.metrics=new d.default({appName:ce,metricsInterval:L,disableMetrics:fe,url:c,clientKey:l,fetch:le,headerName:Ne}),_}return y.prototype.getAllToggles=function(){return r([],this.toggles,!0)},y.prototype.isEnabled=function(u){var f=this.toggles.find(function(S){return S.name===u}),c=f?f.enabled:!1;if(this.metrics.count(u,c),f!=null&&f.impressionData){var l=this.eventsHandler.createImpressionEvent(this.context,c,u,k.IS_ENABLED);this.emit(t.EVENTS.IMPRESSION,l)}return c},y.prototype.getVariant=function(u){var f=this.toggles.find(function(l){return l.name===u});if(f){if(this.metrics.count(u,!0),f.impressionData){var c=this.eventsHandler.createImpressionEvent(this.context,f.enabled,u,k.GET_VARIANT,f.variant.name);this.emit(t.EVENTS.IMPRESSION,c)}return f.variant}else return this.metrics.count(u,!1),P},y.prototype.updateContext=function(u){return n(this,void 0,void 0,function(){var f;return a(this,function(c){switch(c.label){case 0:return(u.appName||u.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext."),f={environment:this.context.environment,appName:this.context.appName},this.context=e(e({},f),u),this.timerRef?[4,this.fetchToggles()]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},y.prototype.getContext=function(){return e({},this.context)},y.prototype.setContextField=function(u,f){var c,l;if(M.includes(u))this.context=e(e({},this.context),(c={},c[u]=f,c));else{var S=e(e({},this.context.properties),(l={},l[u]=f,l));this.context=e(e({},this.context),{properties:S})}this.timerRef&&this.fetchToggles()},y.prototype.init=function(){return n(this,void 0,void 0,function(){var u,f;return a(this,function(c){switch(c.label){case 0:return[4,this.resolveSessionId()];case 1:return u=c.sent(),this.context=e({sessionId:u},this.context),f=this,[4,this.storage.get(w)];case 2:return f.toggles=c.sent()||[],this.bootstrap&&(this.bootstrapOverride||this.toggles.length===0)?[4,this.storage.save(w,this.bootstrap)]:[3,4];case 3:c.sent(),this.toggles=this.bootstrap,this.emit(t.EVENTS.READY),c.label=4;case 4:return this.emit(t.EVENTS.INIT),[2]}})})},y.prototype.start=function(){return n(this,void 0,void 0,function(){var u,f=this;return a(this,function(c){switch(c.label){case 0:return 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];case 1:return c.sent(),this.metrics.start(),u=this.refreshInterval,[4,this.fetchToggles()];case 2:return c.sent(),u>0&&(this.timerRef=setInterval(function(){return f.fetchToggles()},u)),[2]}})})},y.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},y.prototype.resolveSessionId=function(){return n(this,void 0,void 0,function(){var u;return a(this,function(f){switch(f.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return u=f.sent(),u?[3,4]:(u=Math.floor(Math.random()*1e9),[4,this.storage.save("sessionId",u)]);case 3:f.sent(),f.label=4;case 4:return[2,u]}})})},y.prototype.getHeaders=function(){var u,f=(u={},u[this.headerName]=this.clientKey,u.Accept="application/json",u["Content-Type"]="application/json",u["If-None-Match"]=this.etag,u);return Object.entries(this.customHeaders).filter(g.notNullOrUndefined).forEach(function(c){var l=c[0],S=c[1];return f[l]=S}),f},y.prototype.storeToggles=function(u){return n(this,void 0,void 0,function(){return a(this,function(f){switch(f.label){case 0:return this.toggles=u,this.emit(t.EVENTS.UPDATE),[4,this.storage.save(w,u)];case 1:return f.sent(),[2]}})})},y.prototype.fetchToggles=function(){return n(this,void 0,void 0,function(){var u,f,c,l,S;return a(this,function(A){switch(A.label){case 0:if(!this.fetch)return[3,7];A.label=1;case 1:return A.trys.push([1,6,,7]),u=this.context,f=new URL(this.url.toString()),Object.entries(u).filter(g.notNullOrUndefined).forEach(function(V){var p=V[0],N=V[1];p==="properties"&&N?Object.entries(N).filter(g.notNullOrUndefined).forEach(function(L){var X=L[0],fe=L[1];return f.searchParams.append("properties[".concat(X,"]"),fe)}):f.searchParams.append(p,N)}),[4,this.fetch(f.toString(),{cache:"no-cache",headers:this.getHeaders()})];case 2:return c=A.sent(),c.ok&&c.status!==304?(this.etag=c.headers.get("ETag")||"",[4,c.json()]):[3,5];case 3:return l=A.sent(),[4,this.storeToggles(l.toggles)];case 4:A.sent(),!this.bootstrap&&!this.readyEventEmitted&&(this.emit(t.EVENTS.READY),this.readyEventEmitted=!0),A.label=5;case 5:return[3,7];case 6:return S=A.sent(),console.error("Unleash: unable to fetch feature toggles",S),this.emit(t.EVENTS.ERROR,S),[3,7];case 7:return[2]}})})},y}(o.TinyEmitter);t.UnleashClient=j}(F);const K=Symbol("Context state identifier"),we=Symbol("Context update identifier"),Ee=b.defineComponent({props:{config:null,unleashClient:null,startClient:{type:Boolean}},setup(t){var k,P;const{config:i,unleashClient:e,startClient:n=!0}=t,a=b.ref(e),r=b.ref(!1),o=b.ref(null);!i&&!e&&console.warn(`You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
2
- checking if the client exists before rendering.`),!a.value&&i&&(a.value=new F.UnleashClient(i)),(k=a.value)==null||k.on("ready",()=>{r.value=!0}),(P=a.value)==null||P.on("error",w=>{o.value=w}),b.onMounted(()=>{var E;(n||!e)&&((E=a.value)==null||E.start())});const d=async w=>{var E;await((E=a.value)==null?void 0:E.updateContext(w))},v=w=>{var E;return(E=a.value)==null?void 0:E.isEnabled(w)},s=w=>{var E;return(E=a.value)==null?void 0:E.getVariant(w)},h=(w,...E)=>{var j;return(j=a.value)==null?void 0:j.on(w,...E)},g=b.reactive({on:h,updateContext:d,isEnabled:v,getVariant:s,client:a,flagsReady:r,flagsError:o});b.provide(K,b.toRefs(g));const M=(w,E)=>{g[w]=E};return b.provide(we,M),(w,E)=>b.renderSlot(w.$slots,"default")}}),st=t=>{const{isEnabled:i,client:e}=b.inject(K)||{},n=b.ref(!!i.value(t));function a(){const o=i.value(t);o!==n.value&&(n.value=!!o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),b.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n},ut=()=>{const{flagsReady:t,flagsError:i}=b.inject(K)||{};return{flagsReady:t,flagsError:i}},ft=t=>{const{getVariant:i,client:e}=b.inject(K)||{},n=b.ref(i.value(t));function a(){const o=i.value(t);(o.name!==n.value.name||o.enabled!==n.value.enabled)&&(n.value=o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),b.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n||{}},ct=()=>{const{updateContext:t}=b.inject(K)||{};return t.value},lt=()=>{const{client:t}=b.inject(K)||{};return t.value};T.ContextStateSymbol=K,T.ContextUpdateSymbol=we,T.FlagProvider=Ee,T.InMemoryStorageProvider=F.InMemoryStorageProvider,T.LocalStorageProvider=F.LocalStorageProvider,T.UnleashClient=F.UnleashClient,T.default=Ee,T.useFlag=st,T.useFlagsStatus=ut,T.useUnleashClient=lt,T.useUnleashContext=ct,T.useVariant=ft,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(T,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],b):(T=typeof globalThis!="undefined"?globalThis:T||self,b(T["proxy-client-vue"]={},T.Vue))})(this,function(T,b){"use strict";var m=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ue(t){if(t.__esModule)return t;var i=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),i}var F={},z={exports:{}};function Z(){}Z.prototype={on:function(t,i,e){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:i,ctx:e}),this},once:function(t,i,e){var n=this;function a(){n.off(t,a),i.apply(e,arguments)}return a._=i,this.on(t,a,e)},emit:function(t){var i=[].slice.call(arguments,1),e=((this.e||(this.e={}))[t]||[]).slice(),n=0,a=e.length;for(n;n<a;n++)e[n].fn.apply(e[n].ctx,i);return this},off:function(t,i){var e=this.e||(this.e={}),n=e[t],a=[];if(n&&i)for(var r=0,o=n.length;r<o;r++)n[r].fn!==i&&n[r].fn._!==i&&a.push(n[r]);return a.length?e[t]=a:delete e[t],this}},z.exports=Z,z.exports.TinyEmitter=Z;var W={},$=m&&m.__assign||function(){return $=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},$.apply(this,arguments)},xe=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},Re=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(W,"__esModule",{value:!0});var Ce=function(){function t(i){var e=i.onError,n=i.appName,a=i.metricsInterval,r=i.disableMetrics,o=r===void 0?!1:r,d=i.url,v=i.clientKey,s=i.fetch,h=i.headerName;this.onError=e,this.disabled=o,this.metricsInterval=a*1e3,this.appName=n,this.url=d instanceof URL?d:new URL(d),this.clientKey=v,this.bucket=this.createEmptyBucket(),this.fetch=s,this.headerName=h}return t.prototype.start=function(){var i=this;if(this.disabled)return!1;typeof this.metricsInterval=="number"&&this.metricsInterval>0&&setTimeout(function(){i.startTimer(),i.sendMetrics()},2e3)},t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer)},t.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},t.prototype.sendMetrics=function(){return xe(this,void 0,void 0,function(){var i,e,n,a;return Re(this,function(r){switch(r.label){case 0:if(i="".concat(this.url,"/client/metrics"),e=this.getPayload(),this.bucketIsEmpty(e))return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.fetch(i,{cache:"no-cache",method:"POST",headers:(a={},a[this.headerName]=this.clientKey,a.Accept="application/json",a["Content-Type"]="application/json",a),body:JSON.stringify(e)})];case 2:return r.sent(),[3,4];case 3:return n=r.sent(),console.error("Unleash: unable to send feature metrics",n),this.onError(n),[3,4];case 4:return[2]}})})},t.prototype.count=function(i,e){return this.disabled||!this.bucket?!1:(this.assertBucket(i),this.bucket.toggles[i][e?"yes":"no"]++,!0)},t.prototype.assertBucket=function(i){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[i]||(this.bucket.toggles[i]={yes:0,no:0})},t.prototype.startTimer=function(){var i=this;this.timer=setInterval(function(){i.sendMetrics()},this.metricsInterval)},t.prototype.bucketIsEmpty=function(i){return Object.keys(i.bucket.toggles).length===0},t.prototype.getPayload=function(){var i=$($({},this.bucket),{stop:new Date});return this.bucket=this.createEmptyBucket(),{bucket:i,appName:this.appName,instanceId:"browser"}},t}();W.default=Ce;var ee={},le=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},he=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(ee,"__esModule",{value:!0});var Me=function(){function t(){this.store=new Map}return t.prototype.save=function(i,e){return le(this,void 0,void 0,function(){return he(this,function(n){return this.store.set(i,e),[2]})})},t.prototype.get=function(i){return le(this,void 0,void 0,function(){return he(this,function(e){return[2,this.store.get(i)]})})},t}();ee.default=Me;var te={},Ae=m&&m.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function d(h){try{s(n.next(h))}catch(g){o(g)}}function v(h){try{s(n.throw(h))}catch(g){o(g)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,i||[])).next())})},ke=m&&m.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(te,"__esModule",{value:!0});var Pe=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(i,e){return Ae(this,void 0,void 0,function(){var n,a;return ke(this,function(r){n=JSON.stringify(e),a="".concat(this.prefix,":").concat(i);try{window.localStorage.setItem(a,n)}catch(o){console.error(o)}return[2]})})},t.prototype.get=function(i){try{var e="".concat(this.prefix,":").concat(i),n=window.localStorage.getItem(e);return n?JSON.parse(n):void 0}catch(a){console.error(a)}},t}();te.default=Pe;var re={},q,je=new Uint8Array(16);function de(){if(!q&&(q=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return q(je)}var Ve=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function G(t){return typeof t=="string"&&Ve.test(t)}for(var O=[],ne=0;ne<256;++ne)O.push((ne+256).toString(16).substr(1));function B(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(O[t[i+0]]+O[t[i+1]]+O[t[i+2]]+O[t[i+3]]+"-"+O[t[i+4]]+O[t[i+5]]+"-"+O[t[i+6]]+O[t[i+7]]+"-"+O[t[i+8]]+O[t[i+9]]+"-"+O[t[i+10]]+O[t[i+11]]+O[t[i+12]]+O[t[i+13]]+O[t[i+14]]+O[t[i+15]]).toLowerCase();if(!G(e))throw TypeError("Stringified UUID is invalid");return e}var ve,ae,ie=0,oe=0;function De(t,i,e){var n=i&&e||0,a=i||new Array(16);t=t||{};var r=t.node||ve,o=t.clockseq!==void 0?t.clockseq:ae;if(r==null||o==null){var d=t.random||(t.rng||de)();r==null&&(r=ve=[d[0]|1,d[1],d[2],d[3],d[4],d[5]]),o==null&&(o=ae=(d[6]<<8|d[7])&16383)}var v=t.msecs!==void 0?t.msecs:Date.now(),s=t.nsecs!==void 0?t.nsecs:oe+1,h=v-ie+(s-oe)/1e4;if(h<0&&t.clockseq===void 0&&(o=o+1&16383),(h<0||v>ie)&&t.nsecs===void 0&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ie=v,oe=s,ae=o,v+=122192928e5;var g=((v&268435455)*1e4+s)%4294967296;a[n++]=g>>>24&255,a[n++]=g>>>16&255,a[n++]=g>>>8&255,a[n++]=g&255;var M=v/4294967296*1e4&268435455;a[n++]=M>>>8&255,a[n++]=M&255,a[n++]=M>>>24&15|16,a[n++]=M>>>16&255,a[n++]=o>>>8|128,a[n++]=o&255;for(var k=0;k<6;++k)a[n+k]=r[k];return i||B(a)}function ye(t){if(!G(t))throw TypeError("Invalid UUID");var i,e=new Uint8Array(16);return e[0]=(i=parseInt(t.slice(0,8),16))>>>24,e[1]=i>>>16&255,e[2]=i>>>8&255,e[3]=i&255,e[4]=(i=parseInt(t.slice(9,13),16))>>>8,e[5]=i&255,e[6]=(i=parseInt(t.slice(14,18),16))>>>8,e[7]=i&255,e[8]=(i=parseInt(t.slice(19,23),16))>>>8,e[9]=i&255,e[10]=(i=parseInt(t.slice(24,36),16))/1099511627776&255,e[11]=i/4294967296&255,e[12]=i>>>24&255,e[13]=i>>>16&255,e[14]=i>>>8&255,e[15]=i&255,e}function Le(t){t=unescape(encodeURIComponent(t));for(var i=[],e=0;e<t.length;++e)i.push(t.charCodeAt(e));return i}var Ke="6ba7b810-9dad-11d1-80b4-00c04fd430c8",He="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function pe(t,i,e){function n(a,r,o,d){if(typeof a=="string"&&(a=Le(a)),typeof r=="string"&&(r=ye(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var v=new Uint8Array(16+a.length);if(v.set(r),v.set(a,r.length),v=e(v),v[6]=v[6]&15|i,v[8]=v[8]&63|128,o){d=d||0;for(var s=0;s<16;++s)o[d+s]=v[s];return o}return B(v)}try{n.name=t}catch{}return n.DNS=Ke,n.URL=He,n}function Fe(t){if(typeof t=="string"){var i=unescape(encodeURIComponent(t));t=new Uint8Array(i.length);for(var e=0;e<i.length;++e)t[e]=i.charCodeAt(e)}return $e(qe(Ge(t),t.length*8))}function $e(t){for(var i=[],e=t.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var r=t[a>>5]>>>a%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);i.push(o)}return i}function ge(t){return(t+64>>>9<<4)+14+1}function qe(t,i){t[i>>5]|=128<<i%32,t[ge(i)-1]=i;for(var e=1732584193,n=-271733879,a=-1732584194,r=271733878,o=0;o<t.length;o+=16){var d=e,v=n,s=a,h=r;e=U(e,n,a,r,t[o],7,-680876936),r=U(r,e,n,a,t[o+1],12,-389564586),a=U(a,r,e,n,t[o+2],17,606105819),n=U(n,a,r,e,t[o+3],22,-1044525330),e=U(e,n,a,r,t[o+4],7,-176418897),r=U(r,e,n,a,t[o+5],12,1200080426),a=U(a,r,e,n,t[o+6],17,-1473231341),n=U(n,a,r,e,t[o+7],22,-45705983),e=U(e,n,a,r,t[o+8],7,1770035416),r=U(r,e,n,a,t[o+9],12,-1958414417),a=U(a,r,e,n,t[o+10],17,-42063),n=U(n,a,r,e,t[o+11],22,-1990404162),e=U(e,n,a,r,t[o+12],7,1804603682),r=U(r,e,n,a,t[o+13],12,-40341101),a=U(a,r,e,n,t[o+14],17,-1502002290),n=U(n,a,r,e,t[o+15],22,1236535329),e=x(e,n,a,r,t[o+1],5,-165796510),r=x(r,e,n,a,t[o+6],9,-1069501632),a=x(a,r,e,n,t[o+11],14,643717713),n=x(n,a,r,e,t[o],20,-373897302),e=x(e,n,a,r,t[o+5],5,-701558691),r=x(r,e,n,a,t[o+10],9,38016083),a=x(a,r,e,n,t[o+15],14,-660478335),n=x(n,a,r,e,t[o+4],20,-405537848),e=x(e,n,a,r,t[o+9],5,568446438),r=x(r,e,n,a,t[o+14],9,-1019803690),a=x(a,r,e,n,t[o+3],14,-187363961),n=x(n,a,r,e,t[o+8],20,1163531501),e=x(e,n,a,r,t[o+13],5,-1444681467),r=x(r,e,n,a,t[o+2],9,-51403784),a=x(a,r,e,n,t[o+7],14,1735328473),n=x(n,a,r,e,t[o+12],20,-1926607734),e=R(e,n,a,r,t[o+5],4,-378558),r=R(r,e,n,a,t[o+8],11,-2022574463),a=R(a,r,e,n,t[o+11],16,1839030562),n=R(n,a,r,e,t[o+14],23,-35309556),e=R(e,n,a,r,t[o+1],4,-1530992060),r=R(r,e,n,a,t[o+4],11,1272893353),a=R(a,r,e,n,t[o+7],16,-155497632),n=R(n,a,r,e,t[o+10],23,-1094730640),e=R(e,n,a,r,t[o+13],4,681279174),r=R(r,e,n,a,t[o],11,-358537222),a=R(a,r,e,n,t[o+3],16,-722521979),n=R(n,a,r,e,t[o+6],23,76029189),e=R(e,n,a,r,t[o+9],4,-640364487),r=R(r,e,n,a,t[o+12],11,-421815835),a=R(a,r,e,n,t[o+15],16,530742520),n=R(n,a,r,e,t[o+2],23,-995338651),e=C(e,n,a,r,t[o],6,-198630844),r=C(r,e,n,a,t[o+7],10,1126891415),a=C(a,r,e,n,t[o+14],15,-1416354905),n=C(n,a,r,e,t[o+5],21,-57434055),e=C(e,n,a,r,t[o+12],6,1700485571),r=C(r,e,n,a,t[o+3],10,-1894986606),a=C(a,r,e,n,t[o+10],15,-1051523),n=C(n,a,r,e,t[o+1],21,-2054922799),e=C(e,n,a,r,t[o+8],6,1873313359),r=C(r,e,n,a,t[o+15],10,-30611744),a=C(a,r,e,n,t[o+6],15,-1560198380),n=C(n,a,r,e,t[o+13],21,1309151649),e=C(e,n,a,r,t[o+4],6,-145523070),r=C(r,e,n,a,t[o+11],10,-1120210379),a=C(a,r,e,n,t[o+2],15,718787259),n=C(n,a,r,e,t[o+9],21,-343485551),e=D(e,d),n=D(n,v),a=D(a,s),r=D(r,h)}return[e,n,a,r]}function Ge(t){if(t.length===0)return[];for(var i=t.length*8,e=new Uint32Array(ge(i)),n=0;n<i;n+=8)e[n>>5]|=(t[n/8]&255)<<n%32;return e}function D(t,i){var e=(t&65535)+(i&65535),n=(t>>16)+(i>>16)+(e>>16);return n<<16|e&65535}function Be(t,i){return t<<i|t>>>32-i}function Y(t,i,e,n,a,r){return D(Be(D(D(i,t),D(n,r)),a),e)}function U(t,i,e,n,a,r,o){return Y(i&e|~i&n,t,i,a,r,o)}function x(t,i,e,n,a,r,o){return Y(i&n|e&~n,t,i,a,r,o)}function R(t,i,e,n,a,r,o){return Y(i^e^n,t,i,a,r,o)}function C(t,i,e,n,a,r,o){return Y(e^(i|~n),t,i,a,r,o)}var Ye=pe("v3",48,Fe),Je=Ye;function Qe(t,i,e){t=t||{};var n=t.random||(t.rng||de)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,i){e=e||0;for(var a=0;a<16;++a)i[e+a]=n[a];return i}return B(n)}function Xe(t,i,e,n){switch(t){case 0:return i&e^~i&n;case 1:return i^e^n;case 2:return i&e^i&n^e&n;case 3:return i^e^n}}function se(t,i){return t<<i|t>>>32-i}function ze(t){var i=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var n=unescape(encodeURIComponent(t));t=[];for(var a=0;a<n.length;++a)t.push(n.charCodeAt(a))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var r=t.length/4+2,o=Math.ceil(r/16),d=new Array(o),v=0;v<o;++v){for(var s=new Uint32Array(16),h=0;h<16;++h)s[h]=t[v*64+h*4]<<24|t[v*64+h*4+1]<<16|t[v*64+h*4+2]<<8|t[v*64+h*4+3];d[v]=s}d[o-1][14]=(t.length-1)*8/Math.pow(2,32),d[o-1][14]=Math.floor(d[o-1][14]),d[o-1][15]=(t.length-1)*8&4294967295;for(var g=0;g<o;++g){for(var M=new Uint32Array(80),k=0;k<16;++k)M[k]=d[g][k];for(var P=16;P<80;++P)M[P]=se(M[P-3]^M[P-8]^M[P-14]^M[P-16],1);for(var w=e[0],E=e[1],j=e[2],S=e[3],y=e[4],u=0;u<80;++u){var f=Math.floor(u/20),c=se(w,5)+Xe(f,E,j,S)+y+i[f]+M[u]>>>0;y=S,S=j,j=se(E,30)>>>0,E=w,w=c}e[0]=e[0]+w>>>0,e[1]=e[1]+E>>>0,e[2]=e[2]+j>>>0,e[3]=e[3]+S>>>0,e[4]=e[4]+y>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Ze=pe("v5",80,ze),We=Ze,et="00000000-0000-0000-0000-000000000000";function tt(t){if(!G(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}var rt=Object.freeze(Object.defineProperty({__proto__:null,v1:De,v3:Je,v4:Qe,v5:We,NIL:et,version:tt,validate:G,stringify:B,parse:ye},Symbol.toStringTag,{value:"Module"})),nt=Ue(rt),J=m&&m.__assign||function(){return J=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},J.apply(this,arguments)};Object.defineProperty(re,"__esModule",{value:!0});var at=nt,it=function(){function t(){}return t.prototype.generateEventId=function(){return(0,at.v4)()},t.prototype.createImpressionEvent=function(i,e,n,a,r){var o=this.createBaseEvent(i,e,n,a);return r?J(J({},o),{variant:r}):o},t.prototype.createBaseEvent=function(i,e,n,a){return{eventType:a,eventId:this.generateEventId(),context:i,enabled:e,featureName:n}},t}();re.default=it;var Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.notNullOrUndefined=void 0;var ot=function(t){var i=t[1];return i!=null};Q.notNullOrUndefined=ot,function(t){var i=m&&m.__extends||function(){var S=function(y,u){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,c){f.__proto__=c}||function(f,c){for(var l in c)Object.prototype.hasOwnProperty.call(c,l)&&(f[l]=c[l])},S(y,u)};return function(y,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");S(y,u);function f(){this.constructor=y}y.prototype=u===null?Object.create(u):(f.prototype=u.prototype,new f)}}(),e=m&&m.__assign||function(){return e=Object.assign||function(S){for(var y,u=1,f=arguments.length;u<f;u++){y=arguments[u];for(var c in y)Object.prototype.hasOwnProperty.call(y,c)&&(S[c]=y[c])}return S},e.apply(this,arguments)},n=m&&m.__awaiter||function(S,y,u,f){function c(l){return l instanceof u?l:new u(function(_){_(l)})}return new(u||(u=Promise))(function(l,_){function A(N){try{p(f.next(N))}catch(L){_(L)}}function V(N){try{p(f.throw(N))}catch(L){_(L)}}function p(N){N.done?l(N.value):c(N.value).then(A,V)}p((f=f.apply(S,y||[])).next())})},a=m&&m.__generator||function(S,y){var u={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},f,c,l,_;return _={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function A(p){return function(N){return V([p,N])}}function V(p){if(f)throw new TypeError("Generator is already executing.");for(;u;)try{if(f=1,c&&(l=p[0]&2?c.return:p[0]?c.throw||((l=c.return)&&l.call(c),0):c.next)&&!(l=l.call(c,p[1])).done)return l;switch(c=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return u.label++,{value:p[1],done:!1};case 5:u.label++,c=p[1],p=[0];continue;case 7:p=u.ops.pop(),u.trys.pop();continue;default:if(l=u.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){u=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){u.label=p[1];break}if(p[0]===6&&u.label<l[1]){u.label=l[1],l=p;break}if(l&&u.label<l[2]){u.label=l[2],u.ops.push(p);break}l[2]&&u.ops.pop(),u.trys.pop();continue}p=y.call(S,u)}catch(N){p=[6,N],c=0}finally{f=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},r=m&&m.__spreadArray||function(S,y,u){if(u||arguments.length===2)for(var f=0,c=y.length,l;f<c;f++)(l||!(f in y))&&(l||(l=Array.prototype.slice.call(y,0,f)),l[f]=y[f]);return S.concat(l||Array.prototype.slice.call(y))};Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorageProvider=t.LocalStorageProvider=t.UnleashClient=t.resolveFetch=t.EVENTS=void 0;var o=z.exports,d=W,v=ee;t.InMemoryStorageProvider=v.default;var s=te;t.LocalStorageProvider=s.default;var h=re,g=Q,M=["userId","sessionId","remoteAddress"];t.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression"};var k={IS_ENABLED:"isEnabled",GET_VARIANT:"getVariant"},P={name:"disabled",enabled:!1},w="repo",E=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(S){console.error('Unleash failed to resolve "fetch"',S)}};t.resolveFetch=E;var j=function(S){i(y,S);function y(u){var f=u.storageProvider,c=u.url,l=u.clientKey,_=u.disableRefresh,A=_===void 0?!1:_,V=u.refreshInterval,p=V===void 0?30:V,N=u.metricsInterval,L=N===void 0?30:N,X=u.disableMetrics,ue=X===void 0?!1:X,fe=u.appName,we=u.environment,ht=we===void 0?"default":we,dt=u.context,Ee=u.fetch,ce=Ee===void 0?(0,t.resolveFetch)():Ee,H=u.bootstrap,Ie=u.bootstrapOverride,vt=Ie===void 0?!0:Ie,Se=u.headerName,_e=Se===void 0?"Authorization":Se,Te=u.customHeaders,yt=Te===void 0?{}:Te,I=S.call(this)||this;if(I.toggles=[],I.etag="",I.readyEventEmitted=!1,!c)throw new Error("url is required");if(!l)throw new Error("clientKey is required");if(!fe)throw new Error("appName is required.");return I.eventsHandler=new h.default,I.toggles=H&&H.length>0?H:[],I.url=c instanceof URL?c:new URL(c),I.clientKey=l,I.headerName=_e,I.customHeaders=yt,I.storage=f||new s.default,I.refreshInterval=A?0:p*1e3,I.context=e({appName:fe,environment:ht},dt),I.ready=new Promise(function(Ne){I.init().then(Ne).catch(function(Oe){console.error(Oe),I.emit(t.EVENTS.ERROR,Oe),Ne()})}),ce||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),I.fetch=ce,I.bootstrap=H&&H.length>0?H:void 0,I.bootstrapOverride=vt,I.metrics=new d.default({onError:I.emit.bind(I,t.EVENTS.ERROR),appName:fe,metricsInterval:L,disableMetrics:ue,url:I.url,clientKey:l,fetch:ce,headerName:_e}),I}return y.prototype.getAllToggles=function(){return r([],this.toggles,!0)},y.prototype.isEnabled=function(u){var f=this.toggles.find(function(_){return _.name===u}),c=f?f.enabled:!1;if(this.metrics.count(u,c),f!=null&&f.impressionData){var l=this.eventsHandler.createImpressionEvent(this.context,c,u,k.IS_ENABLED);this.emit(t.EVENTS.IMPRESSION,l)}return c},y.prototype.getVariant=function(u){var f=this.toggles.find(function(l){return l.name===u});if(f){if(this.metrics.count(u,!0),f.impressionData){var c=this.eventsHandler.createImpressionEvent(this.context,f.enabled,u,k.GET_VARIANT,f.variant.name);this.emit(t.EVENTS.IMPRESSION,c)}return f.variant}else return this.metrics.count(u,!1),P},y.prototype.updateContext=function(u){return n(this,void 0,void 0,function(){var f;return a(this,function(c){switch(c.label){case 0:return(u.appName||u.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext."),f={environment:this.context.environment,appName:this.context.appName},this.context=e(e({},f),u),this.timerRef?[4,this.fetchToggles()]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},y.prototype.getContext=function(){return e({},this.context)},y.prototype.setContextField=function(u,f){var c,l;if(M.includes(u))this.context=e(e({},this.context),(c={},c[u]=f,c));else{var _=e(e({},this.context.properties),(l={},l[u]=f,l));this.context=e(e({},this.context),{properties:_})}this.timerRef&&this.fetchToggles()},y.prototype.init=function(){return n(this,void 0,void 0,function(){var u,f;return a(this,function(c){switch(c.label){case 0:return[4,this.resolveSessionId()];case 1:return u=c.sent(),this.context=e({sessionId:u},this.context),f=this,[4,this.storage.get(w)];case 2:return f.toggles=c.sent()||[],this.bootstrap&&(this.bootstrapOverride||this.toggles.length===0)?[4,this.storage.save(w,this.bootstrap)]:[3,4];case 3:c.sent(),this.toggles=this.bootstrap,this.emit(t.EVENTS.READY),c.label=4;case 4:return this.emit(t.EVENTS.INIT),[2]}})})},y.prototype.start=function(){return n(this,void 0,void 0,function(){var u,f=this;return a(this,function(c){switch(c.label){case 0:return 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];case 1:return c.sent(),this.metrics.start(),u=this.refreshInterval,[4,this.fetchToggles()];case 2:return c.sent(),u>0&&(this.timerRef=setInterval(function(){return f.fetchToggles()},u)),[2]}})})},y.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},y.prototype.resolveSessionId=function(){return n(this,void 0,void 0,function(){var u;return a(this,function(f){switch(f.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return u=f.sent(),u?[3,4]:(u=Math.floor(Math.random()*1e9),[4,this.storage.save("sessionId",u)]);case 3:f.sent(),f.label=4;case 4:return[2,u]}})})},y.prototype.getHeaders=function(){var u,f=(u={},u[this.headerName]=this.clientKey,u.Accept="application/json",u["Content-Type"]="application/json",u["If-None-Match"]=this.etag,u);return Object.entries(this.customHeaders).filter(g.notNullOrUndefined).forEach(function(c){var l=c[0],_=c[1];return f[l]=_}),f},y.prototype.storeToggles=function(u){return n(this,void 0,void 0,function(){return a(this,function(f){switch(f.label){case 0:return this.toggles=u,this.emit(t.EVENTS.UPDATE),[4,this.storage.save(w,u)];case 1:return f.sent(),[2]}})})},y.prototype.fetchToggles=function(){return n(this,void 0,void 0,function(){var u,f,c,l,_;return a(this,function(A){switch(A.label){case 0:if(!this.fetch)return[3,7];A.label=1;case 1:return A.trys.push([1,6,,7]),u=this.context,f=new URL(this.url.toString()),Object.entries(u).filter(g.notNullOrUndefined).forEach(function(V){var p=V[0],N=V[1];p==="properties"&&N?Object.entries(N).filter(g.notNullOrUndefined).forEach(function(L){var X=L[0],ue=L[1];return f.searchParams.append("properties[".concat(X,"]"),ue)}):f.searchParams.append(p,N)}),[4,this.fetch(f.toString(),{cache:"no-cache",headers:this.getHeaders()})];case 2:return c=A.sent(),c.ok&&c.status!==304?(this.etag=c.headers.get("ETag")||"",[4,c.json()]):[3,5];case 3:return l=A.sent(),[4,this.storeToggles(l.toggles)];case 4:A.sent(),!this.bootstrap&&!this.readyEventEmitted&&(this.emit(t.EVENTS.READY),this.readyEventEmitted=!0),A.label=5;case 5:return[3,7];case 6:return _=A.sent(),console.error("Unleash: unable to fetch feature toggles",_),this.emit(t.EVENTS.ERROR,_),[3,7];case 7:return[2]}})})},y}(o.TinyEmitter);t.UnleashClient=j}(F);const K=Symbol("Context state identifier"),me=Symbol("Context update identifier"),be=b.defineComponent({props:{config:null,unleashClient:null,startClient:{type:Boolean}},setup(t){var k,P;const{config:i,unleashClient:e,startClient:n=!0}=t,a=b.ref(e),r=b.ref(!1),o=b.ref(null);!i&&!e&&console.warn(`You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
2
+ checking if the client exists before rendering.`),!a.value&&i&&(a.value=new F.UnleashClient(i)),(k=a.value)==null||k.on("ready",()=>{r.value=!0}),(P=a.value)==null||P.on("error",w=>{o.value=w}),b.onMounted(()=>{var E;(n||!e)&&((E=a.value)==null||E.start())});const d=async w=>{var E;await((E=a.value)==null?void 0:E.updateContext(w))},v=w=>{var E;return(E=a.value)==null?void 0:E.isEnabled(w)},s=w=>{var E;return(E=a.value)==null?void 0:E.getVariant(w)},h=(w,...E)=>{var j;return(j=a.value)==null?void 0:j.on(w,...E)},g=b.reactive({on:h,updateContext:d,isEnabled:v,getVariant:s,client:a,flagsReady:r,flagsError:o});b.provide(K,b.toRefs(g));const M=(w,E)=>{g[w]=E};return b.provide(me,M),(w,E)=>b.renderSlot(w.$slots,"default")}}),st=t=>{const{isEnabled:i,client:e}=b.inject(K)||{},n=b.ref(!!i.value(t));function a(){const o=i.value(t);o!==n.value&&(n.value=!!o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),b.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n},ut=()=>{const{flagsReady:t,flagsError:i}=b.inject(K)||{};return{flagsReady:t,flagsError:i}},ft=t=>{const{getVariant:i,client:e}=b.inject(K)||{},n=b.ref(i.value(t));function a(){const o=i.value(t);(o.name!==n.value.name||o.enabled!==n.value.enabled)&&(n.value=o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),b.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n||{}},ct=()=>{const{updateContext:t}=b.inject(K)||{};return t.value},lt=()=>{const{client:t}=b.inject(K)||{};return t.value};T.ContextStateSymbol=K,T.ContextUpdateSymbol=me,T.FlagProvider=be,T.InMemoryStorageProvider=F.InMemoryStorageProvider,T.LocalStorageProvider=F.LocalStorageProvider,T.UnleashClient=F.UnleashClient,T.default=be,T.useFlag=st,T.useFlagsStatus=ut,T.useUnleashClient=lt,T.useUnleashContext=ct,T.useVariant=ft,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unleash/proxy-client-vue",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Vue interface for working with Unleash",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -27,7 +27,7 @@
27
27
  "preview": "vite preview"
28
28
  },
29
29
  "dependencies": {
30
- "unleash-proxy-client": "^2.0.3",
30
+ "unleash-proxy-client": "^2.1.0",
31
31
  "vue": "^3.2.25"
32
32
  },
33
33
  "devDependencies": {