New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unleash/proxy-client-react

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unleash/proxy-client-react - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2-alpha.0

2

dist/index.js

@@ -1,1 +0,1 @@

(()=>{var t={60:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>c,useAsyncStorage:()=>a});const r=n(942).bind({concatArrays:!0,ignoreUndefined:!0}),o=(t,e)=>new Promise(((n,r)=>{try{const r=t();e&&e(null,r),n(r)}catch(t){e&&e(t),r(t)}})),i=(t,e,n)=>Promise.all(t).then((t=>{const r=n?n(t):null;return e&&e(null,r),Promise.resolve(r)}),(t=>(e&&e(t),Promise.reject(t))));class s{static getItem(t,e){return o((()=>window.localStorage.getItem(t)),e)}static setItem(t,e,n){return o((()=>{window.localStorage.setItem(t,e)}),n)}static removeItem(t,e){return o((()=>window.localStorage.removeItem(t)),e)}static mergeItem(t,e,n){return o((()=>{((t,e)=>{const n=window.localStorage.getItem(t),o=JSON.parse(n),i=JSON.parse(e),s=JSON.stringify(r(o,i));window.localStorage.setItem(t,s)})(t,e)}),n)}static clear(t){return o((()=>{window.localStorage.clear()}),t)}static getAllKeys(t){return o((()=>{const t=window.localStorage.length,e=[];for(let n=0;n<t;n+=1){const t=window.localStorage.key(n);e.push(t)}return e}),t)}static flushGetRequests(){}static multiGet(t,e){const n=t.map((t=>s.getItem(t)));return i(n,e,(e=>e.map(((e,n)=>[t[n],e]))))}static multiSet(t,e){const n=t.map((t=>s.setItem(t[0],t[1])));return i(n,e)}static multiRemove(t,e){const n=t.map((t=>s.removeItem(t)));return i(n,e)}static multiMerge(t,e){const n=t.map((t=>s.mergeItem(t[0],t[1])));return i(n,e)}}function a(t){return{getItem:(...e)=>s.getItem(t,...e),setItem:(...e)=>s.setItem(t,...e),mergeItem:(...e)=>s.mergeItem(t,...e),removeItem:(...e)=>s.removeItem(t,...e)}}const c=s},310:t=>{"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},942:function(t,e,n){"use strict";const r=n(310),{hasOwnProperty:o}=Object.prototype,{propertyIsEnumerable:i}=Object,s=(t,e,n)=>Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=t=>{const e=[];for(const n in t)o.call(t,n)&&e.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(t);for(const r of n)i.call(t,r)&&e.push(r)}return e};function l(t){return Array.isArray(t)?function(t){const e=t.slice(0,0);return u(t).forEach((n=>{s(e,n,l(t[n]))})),e}(t):r(t)?function(t){const e=null===Object.getPrototypeOf(t)?Object.create(null):{};return u(t).forEach((n=>{s(e,n,l(t[n]))})),e}(t):t}const f=(t,e,n,r)=>(n.forEach((n=>{void 0===e[n]&&r.ignoreUndefined||(n in t&&t[n]!==Object.getPrototypeOf(t)?s(t,n,h(t[n],e[n],r)):s(t,n,l(e[n])))})),t);function h(t,e,n){return n.concatArrays&&Array.isArray(t)&&Array.isArray(e)?((t,e,n)=>{let r=t.slice(0,0),i=0;return[t,e].forEach((e=>{const a=[];for(let n=0;n<e.length;n++)o.call(e,n)&&(a.push(String(n)),s(r,i++,e===t?e[n]:l(e[n])));r=f(r,e,u(e).filter((t=>!a.includes(t))),n)})),r})(t,e,n):r(e)&&r(t)?f(t,e,u(e),n):l(e)}t.exports=function(...t){const e=h(l(c),this!==a&&this||{},c);let n={_:{}};for(const o of t)if(void 0!==o){if(!r(o))throw new TypeError("`"+o+"` is not an Option Object");n=h(n,{_:o},e)}return n._}},279:t=>{function e(){}e.prototype={on:function(t,e,n){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var r=this;function o(){r.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],o=[];if(r&&e)for(var i=0,s=r.length;i<s;i++)r[i].fn!==e&&r[i].fn._!==e&&o.push(r[i]);return o.length?n[t]=o:delete n[t],this}},t.exports=e,t.exports.TinyEmitter=e},9:function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},c=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.InMemoryStorageProvider=e.LocalStorageProvider=e.UnleashClient=e.EVENTS=void 0;var u=n(279),l=n(524),f=n(432);e.LocalStorageProvider=f.default;var h=n(475);e.InMemoryStorageProvider=h.default;var p=["userId","sessionId","remoteAddress"];e.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update"};var d={name:"disabled"},y="repo",v=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(t){console.error('Unleash failed to resolve "fetch"',t)}},b=function(t){function n(n){var r=n.storageProvider,o=n.url,c=n.clientKey,u=n.refreshInterval,h=void 0===u?30:u,p=n.metricsInterval,d=void 0===p?30:p,y=n.disableMetrics,b=void 0!==y&&y,g=n.appName,m=n.environment,w=void 0===m?"default":m,x=n.context,E=n.fetch,S=void 0===E?v():E,I=n.bootstrap,O=n.bootstrapOverride,_=void 0===O||O,k=t.call(this)||this;if(k.toggles=[],k.etag="",!o)throw new Error("url is required");if(!c)throw new Error("clientKey is required");if(!g)throw new Error("appName is required.");return k.url=new URL(""+o),k.clientKey=c,k.storage=r||new f.default,k.refreshInterval=1e3*h,k.context=i({appName:g,environment:w},x),k.ready=new Promise((function(t){return s(k,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.init()];case 1:return r.sent(),[3,3];case 2:return n=r.sent(),console.error(n),this.emit(e.EVENTS.ERROR,n),[3,3];case 3:return t(),[2]}}))}))})),S||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),k.fetch=S,k.bootstrap=I&&I.length>0?I:void 0,k.bootstrapOverride=_,k.metrics=new l.default({appName:g,metricsInterval:d,disableMetrics:b,url:o,clientKey:c,fetch:S}),k}return o(n,t),n.prototype.getAllToggles=function(){return c([],this.toggles,!0)},n.prototype.isEnabled=function(t){var e=this.toggles.find((function(e){return e.name===t})),n=!!e&&e.enabled;return this.metrics.count(t,n),n},n.prototype.getVariant=function(t){var e=this.toggles.find((function(e){return e.name===t}));return e?(this.metrics.count(t,!0),e.variant):(this.metrics.count(t,!1),d)},n.prototype.updateContext=function(t){(t.appName||t.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext.");var e={environment:this.context.environment,appName:this.context.appName};this.context=i(i({},e),t),this.timerRef&&this.fetchToggles()},n.prototype.getContext=function(){return i({},this.context)},n.prototype.setContextField=function(t,e){var n,r;if(p.includes(t))this.context=i(i({},this.context),((n={})[t]=e,n));else{var o=i(i({},this.context.properties),((r={})[t]=e,r));this.context=i(i({},this.context),{properties:o})}this.timerRef&&this.fetchToggles()},n.prototype.init=function(){return s(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return[4,this.resolveSessionId()];case 1:return t=r.sent(),this.context=i({sessionId:t},this.context),n=this,[4,this.storage.get(y)];case 2:return n.toggles=r.sent()||[],!this.bootstrap||!this.bootstrapOverride&&0!==this.toggles.length?[3,4]:[4,this.storage.save(y,this.bootstrap)];case 3:r.sent(),this.toggles=this.bootstrap,r.label=4;case 4:return this.emit(e.EVENTS.INIT),[2]}}))}))},n.prototype.start=function(){return s(this,void 0,void 0,(function(){var t,n=this;return a(this,(function(r){switch(r.label){case 0:return[4,this.ready];case 1:return r.sent(),this.stop(),t=this.refreshInterval,[4,this.fetchToggles()];case 2:return r.sent(),this.emit(e.EVENTS.READY),this.timerRef=setInterval((function(){return n.fetchToggles()}),t),[2]}}))}))},n.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0)},n.prototype.resolveSessionId=function(){return s(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return(t=e.sent())?[3,4]:(t=Math.floor(1e9*Math.random()),[4,this.storage.save("sessionId",t)]);case 3:e.sent(),e.label=4;case 4:return[2,t]}}))}))},n.prototype.storeToggles=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return this.toggles=t,this.emit(e.EVENTS.UPDATE),[4,this.storage.save(y,t)];case 1:return n.sent(),[2]}}))}))},n.prototype.fetchToggles=function(){return s(this,void 0,void 0,(function(){var t,n,r,o,i;return a(this,(function(s){switch(s.label){case 0:if(!this.fetch)return[3,7];s.label=1;case 1:return s.trys.push([1,6,,7]),t=this.context,n=new URL(this.url.toString()),Object.entries(t).forEach((function(t){var e=t[0],r=t[1];"properties"===e&&r?Object.entries(r).forEach((function(t){var e=t[0],r=t[1];return n.searchParams.append("properties["+e+"]",r)})):n.searchParams.append(e,r)})),[4,this.fetch(n.toString(),{cache:"no-cache",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json","If-None-Match":this.etag}})];case 2:return(r=s.sent()).ok&&304!==r.status?(this.etag=r.headers.get("ETag")||"",[4,r.json()]):[3,5];case 3:return o=s.sent(),[4,this.storeToggles(o.toggles)];case 4:s.sent(),s.label=5;case 5:return[3,7];case 6:return i=s.sent(),console.error("Unleash: unable to fetch feature toggles",i),this.emit(e.EVENTS.ERROR,i),[3,7];case 7:return[2]}}))}))},n}(u.TinyEmitter);e.UnleashClient=b},524:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t){var e=t.appName,n=t.metricsInterval,r=t.disableMetrics,o=void 0!==r&&r,i=t.url,s=t.clientKey,a=t.fetch;this.disabled=o,this.metricsInterval=1e3*n,this.appName=e,this.url=i,this.started=new Date,this.clientKey=s,this.resetBucket(),this.fetch=a,"number"==typeof this.metricsInterval&&this.metricsInterval>0&&this.startTimer(2e3)}return t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer),this.disabled=!0},t.prototype.sendMetrics=function(){return n(this,void 0,void 0,(function(){var t,e;return r(this,(function(n){switch(n.label){case 0:return this.disabled?[2,!1]:this.bucketIsEmpty()?(this.resetBucket(),this.startTimer(),[2,!0]):(t=this.url+"/client/metrics",e=this.getPayload(),[4,this.fetch(t,{cache:"no-cache",method:"POST",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)})]);case 1:return n.sent(),[2,!0]}}))}))},t.prototype.count=function(t,e){return!(this.disabled||!this.bucket||(this.assertBucket(t),this.bucket.toggles[t][e?"yes":"no"]++,0))},t.prototype.assertBucket=function(t){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[t]||(this.bucket.toggles[t]={yes:0,no:0})},t.prototype.startTimer=function(t){var e=this;return!this.disabled&&(this.timer=setTimeout((function(){e.sendMetrics()}),t||this.metricsInterval),!0)},t.prototype.bucketIsEmpty=function(){return!!this.bucket&&0===Object.keys(this.bucket.toggles).length},t.prototype.resetBucket=function(){var t={start:new Date,stop:null,toggles:{}};this.bucket=t},t.prototype.closeBucket=function(){this.bucket&&(this.bucket.stop=new Date)},t.prototype.getPayload=function(){this.closeBucket();var t=this.getMetricsData();return this.resetBucket(),t},t.prototype.getMetricsData=function(){return{appName:this.appName,instanceId:"browser",bucket:this.bucket}},t}();e.default=o},475:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(){this.store=new Map}return t.prototype.save=function(t,e){return n(this,void 0,void 0,(function(){return r(this,(function(n){return this.store.set(t,e),[2]}))}))},t.prototype.get=function(t){return n(this,void 0,void 0,(function(){return r(this,(function(e){return[2,this.store.get(t)]}))}))},t}();e.default=o},432:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(60),s=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(t,e){return r(this,void 0,void 0,(function(){var n,r,s;return o(this,(function(o){switch(o.label){case 0:n=JSON.stringify(e),r=this.prefix+":"+t,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.default.setItem(r,n)];case 2:return o.sent(),[3,4];case 3:return s=o.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e,n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.prefix+":"+t,[4,i.default.getItem(e)];case 1:return[2,(n=o.sent())?JSON.parse(n):void 0];case 2:return r=o.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},t}();e.default=s}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{FlagProvider:()=>c,default:()=>p,useFlag:()=>u,useFlagsStatus:()=>l,useUnleashContext:()=>h,useVariant:()=>f});const t=require("react"),e=n.n(t)().createContext(null);var o=n(9),i=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},a=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};const c=function(n){var r=n.config,c=n.children,u=t.useState(null),l=u[0],f=u[1],h=t.useRef();h.current=[],t.useEffect((function(){var t=new o.UnleashClient(r);h.current.forEach((function(e){e(t)}),[]),h.current=[],f(t),t.start()}),[]);var p=function(t){h.current.push(t)},d={on:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l)return l.on.apply(l,a([t],e,!1));p((function(n){return n.on.apply(n,a([t],e,!1))}))},updateContext:function(t){return i(void 0,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return l?[4,l.updateContext(t)]:(p((function(e){return i(void 0,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.updateContext(t)];case 1:return[2,n.sent()]}}))}))})),[2]);case 1:return e.sent(),[2]}}))}))},isEnabled:function(t){if(l)return l.isEnabled(t);p((function(e){return e.isEnabled(t)}))},getVariant:function(t){return l?l.getVariant(t):(p((function(e){return e.getVariant(t)})),{})},client:l};return t.createElement(e.Provider,{value:d},c)},u=function(n){var r=(0,t.useContext)(e),o=r.isEnabled,i=r.client,s=(0,t.useState)(!!o(n)),a=s[0],c=s[1],u=(0,t.useRef)();return u.current=a,(0,t.useEffect)((function(){i&&(i.on("update",(function(){var t=o(n);t!==u.current&&(u.current=t,c(!!t))})),i.on("ready",(function(){var t=o(n);c(t)})))}),[i]),a},l=function(){var n=(0,t.useContext)(e).on,r=(0,t.useState)(!1),i=r[0],s=r[1],a=(0,t.useState)(null),c=a[0],u=a[1];return(0,t.useEffect)((function(){n(o.EVENTS.READY,(function(){s(!0)})),n(o.EVENTS.ERROR,(function(t){u(t)}))}),[]),{flagsReady:i,flagsError:c}},f=function(n){var r=(0,t.useContext)(e),o=r.getVariant,i=r.client,s=(0,t.useState)(o(n)),a=s[0],c=s[1],u=(0,t.useRef)();return u.current=a,(0,t.useEffect)((function(){i&&(i.on("update",(function(){var t=o(n);u.current.name===t.name&&u.current.enabled===t.enabled||(c(t),u.current=t)})),i.on("ready",(function(){var t=o(n);c(t)})))}),[i]),a||{}},h=function(){return(0,t.useContext)(e).updateContext},p=c})(),module.exports=r})();
(()=>{var t={474:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},c=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.InMemoryStorageProvider=e.LocalStorageProvider=e.UnleashClient=e.EVENTS=void 0;var u=r(584),l=r(531),f=r(336);e.LocalStorageProvider=f.default;var h=r(489);e.InMemoryStorageProvider=h.default;var p=["userId","sessionId","remoteAddress"];e.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update"};var d={name:"disabled"},v="repo",y=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(t){console.error('Unleash failed to resolve "fetch"',t)}},b=function(t){function r(r){var n=r.storageProvider,o=r.url,c=r.clientKey,u=r.disableRefresh,h=void 0!==u&&u,p=r.refreshInterval,d=void 0===p?30:p,v=r.metricsInterval,b=void 0===v?30:v,g=r.disableMetrics,m=void 0!==g&&g,w=r.appName,x=r.environment,S=void 0===x?"default":x,E=r.context,I=r.fetch,O=void 0===I?y():I,_=r.bootstrap,P=r.bootstrapOverride,k=void 0===P||P,T=t.call(this)||this;if(T.toggles=[],T.etag="",!o)throw new Error("url is required");if(!c)throw new Error("clientKey is required");if(!w)throw new Error("appName is required.");return T.toggles=_&&_.length>0?_:[],T.url=new URL(""+o),T.clientKey=c,T.storage=n||new f.default,T.refreshInterval=h?0:1e3*d,T.context=i({appName:w,environment:S},E),T.ready=new Promise((function(t){return s(T,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.init()];case 1:return n.sent(),[3,3];case 2:return r=n.sent(),console.error(r),this.emit(e.EVENTS.ERROR,r),[3,3];case 3:return t(),[2]}}))}))})),O||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),T.fetch=O,T.bootstrap=_&&_.length>0?_:void 0,T.bootstrapOverride=k,T.metrics=new l.default({appName:w,metricsInterval:b,disableMetrics:m,url:o,clientKey:c,fetch:O}),T}return o(r,t),r.prototype.getAllToggles=function(){return c([],this.toggles,!0)},r.prototype.isEnabled=function(t){var e=this.toggles.find((function(e){return e.name===t})),r=!!e&&e.enabled;return this.metrics.count(t,r),r},r.prototype.getVariant=function(t){var e=this.toggles.find((function(e){return e.name===t}));return e?(this.metrics.count(t,!0),e.variant):(this.metrics.count(t,!1),d)},r.prototype.updateContext=function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(r){switch(r.label){case 0:return(t.appName||t.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext."),e={environment:this.context.environment,appName:this.context.appName},this.context=i(i({},e),t),this.timerRef?[4,this.fetchToggles()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},r.prototype.getContext=function(){return i({},this.context)},r.prototype.setContextField=function(t,e){var r,n;if(p.includes(t))this.context=i(i({},this.context),((r={})[t]=e,r));else{var o=i(i({},this.context.properties),((n={})[t]=e,n));this.context=i(i({},this.context),{properties:o})}this.timerRef&&this.fetchToggles()},r.prototype.init=function(){return s(this,void 0,void 0,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:return[4,this.resolveSessionId()];case 1:return t=n.sent(),this.context=i({sessionId:t},this.context),r=this,[4,this.storage.get(v)];case 2:return r.toggles=n.sent()||[],!this.bootstrap||!this.bootstrapOverride&&0!==this.toggles.length?[3,4]:[4,this.storage.save(v,this.bootstrap)];case 3:n.sent(),this.toggles=this.bootstrap,n.label=4;case 4:return this.emit(e.EVENTS.INIT),[2]}}))}))},r.prototype.start=function(){return s(this,void 0,void 0,(function(){var t,r=this;return a(this,(function(n){switch(n.label){case 0:return[4,this.ready];case 1:return n.sent(),this.stop(),t=this.refreshInterval,[4,this.fetchToggles()];case 2:return n.sent(),this.emit(e.EVENTS.READY),t>0&&(this.timerRef=setInterval((function(){return r.fetchToggles()}),t)),[2]}}))}))},r.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0)},r.prototype.resolveSessionId=function(){return s(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return(t=e.sent())?[3,4]:(t=Math.floor(1e9*Math.random()),[4,this.storage.save("sessionId",t)]);case 3:e.sent(),e.label=4;case 4:return[2,t]}}))}))},r.prototype.storeToggles=function(t){return s(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return this.toggles=t,this.emit(e.EVENTS.UPDATE),[4,this.storage.save(v,t)];case 1:return r.sent(),[2]}}))}))},r.prototype.fetchToggles=function(){return s(this,void 0,void 0,(function(){var t,r,n,o,i;return a(this,(function(s){switch(s.label){case 0:if(!this.fetch)return[3,7];s.label=1;case 1:return s.trys.push([1,6,,7]),t=this.context,r=new URL(this.url.toString()),Object.entries(t).forEach((function(t){var e=t[0],n=t[1];"properties"===e&&n?Object.entries(n).forEach((function(t){var e=t[0],n=t[1];return r.searchParams.append("properties["+e+"]",n)})):r.searchParams.append(e,n)})),[4,this.fetch(r.toString(),{cache:"no-cache",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json","If-None-Match":this.etag}})];case 2:return(n=s.sent()).ok&&304!==n.status?(this.etag=n.headers.get("ETag")||"",[4,n.json()]):[3,5];case 3:return o=s.sent(),[4,this.storeToggles(o.toggles)];case 4:s.sent(),s.label=5;case 5:return[3,7];case 6:return i=s.sent(),console.error("Unleash: unable to fetch feature toggles",i),this.emit(e.EVENTS.ERROR,i),[3,7];case 7:return[2]}}))}))},r}(u.TinyEmitter);e.UnleashClient=b},531:function(t,e){"use strict";var r=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},n=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t){var e=t.appName,r=t.metricsInterval,n=t.disableMetrics,o=void 0!==n&&n,i=t.url,s=t.clientKey,a=t.fetch;this.disabled=o,this.metricsInterval=1e3*r,this.appName=e,this.url=i,this.started=new Date,this.clientKey=s,this.resetBucket(),this.fetch=a,"number"==typeof this.metricsInterval&&this.metricsInterval>0&&this.startTimer(2e3)}return t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer),this.disabled=!0},t.prototype.sendMetrics=function(){return r(this,void 0,void 0,(function(){var t,e;return n(this,(function(r){switch(r.label){case 0:return this.disabled?[2,!1]:this.bucketIsEmpty()?(this.resetBucket(),this.startTimer(),[2,!0]):(t=this.url+"/client/metrics",e=this.getPayload(),[4,this.fetch(t,{cache:"no-cache",method:"POST",headers:{Authorization:this.clientKey,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)})]);case 1:return r.sent(),[2,!0]}}))}))},t.prototype.count=function(t,e){return!(this.disabled||!this.bucket||(this.assertBucket(t),this.bucket.toggles[t][e?"yes":"no"]++,0))},t.prototype.assertBucket=function(t){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[t]||(this.bucket.toggles[t]={yes:0,no:0})},t.prototype.startTimer=function(t){var e=this;return!this.disabled&&(this.timer=setTimeout((function(){e.sendMetrics()}),t||this.metricsInterval),!0)},t.prototype.bucketIsEmpty=function(){return!!this.bucket&&0===Object.keys(this.bucket.toggles).length},t.prototype.resetBucket=function(){var t={start:new Date,stop:null,toggles:{}};this.bucket=t},t.prototype.closeBucket=function(){this.bucket&&(this.bucket.stop=new Date)},t.prototype.getPayload=function(){this.closeBucket();var t=this.getMetricsData();return this.resetBucket(),t},t.prototype.getMetricsData=function(){return{appName:this.appName,instanceId:"browser",bucket:this.bucket}},t}();e.default=o},489:function(t,e){"use strict";var r=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},n=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(){this.store=new Map}return t.prototype.save=function(t,e){return r(this,void 0,void 0,(function(){return n(this,(function(r){return this.store.set(t,e),[2]}))}))},t.prototype.get=function(t){return r(this,void 0,void 0,(function(){return n(this,(function(e){return[2,this.store.get(t)]}))}))},t}();e.default=o},336:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(933),s=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(t,e){return n(this,void 0,void 0,(function(){var r,n,s;return o(this,(function(o){switch(o.label){case 0:r=JSON.stringify(e),n=this.prefix+":"+t,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.default.setItem(n,r)];case 2:return o.sent(),[3,4];case 3:return s=o.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t){return n(this,void 0,void 0,(function(){var e,r,n;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=this.prefix+":"+t,[4,i.default.getItem(e)];case 1:return[2,(r=o.sent())?JSON.parse(r):void 0];case 2:return n=o.sent(),console.error(n),[3,3];case 3:return[2]}}))}))},t}();e.default=s},933:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>c,useAsyncStorage:()=>a});const n=r(825).bind({concatArrays:!0,ignoreUndefined:!0}),o=(t,e)=>new Promise(((r,n)=>{try{const n=t();e&&e(null,n),r(n)}catch(t){e&&e(t),n(t)}})),i=(t,e,r)=>Promise.all(t).then((t=>{const n=r?r(t):null;return e&&e(null,n),Promise.resolve(n)}),(t=>(e&&e(t),Promise.reject(t))));class s{static getItem(t,e){return o((()=>window.localStorage.getItem(t)),e)}static setItem(t,e,r){return o((()=>{window.localStorage.setItem(t,e)}),r)}static removeItem(t,e){return o((()=>window.localStorage.removeItem(t)),e)}static mergeItem(t,e,r){return o((()=>{((t,e)=>{const r=window.localStorage.getItem(t),o=JSON.parse(r),i=JSON.parse(e),s=JSON.stringify(n(o,i));window.localStorage.setItem(t,s)})(t,e)}),r)}static clear(t){return o((()=>{window.localStorage.clear()}),t)}static getAllKeys(t){return o((()=>{const t=window.localStorage.length,e=[];for(let r=0;r<t;r+=1){const t=window.localStorage.key(r);e.push(t)}return e}),t)}static flushGetRequests(){}static multiGet(t,e){const r=t.map((t=>s.getItem(t)));return i(r,e,(e=>e.map(((e,r)=>[t[r],e]))))}static multiSet(t,e){const r=t.map((t=>s.setItem(t[0],t[1])));return i(r,e)}static multiRemove(t,e){const r=t.map((t=>s.removeItem(t)));return i(r,e)}static multiMerge(t,e){const r=t.map((t=>s.mergeItem(t[0],t[1])));return i(r,e)}}function a(t){return{getItem:(...e)=>s.getItem(t,...e),setItem:(...e)=>s.setItem(t,...e),mergeItem:(...e)=>s.mergeItem(t,...e),removeItem:(...e)=>s.removeItem(t,...e)}}const c=s},897:t=>{"use strict";t.exports=t=>{if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}},825:function(t,e,r){"use strict";const n=r(897),{hasOwnProperty:o}=Object.prototype,{propertyIsEnumerable:i}=Object,s=(t,e,r)=>Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=t=>{const e=[];for(const r in t)o.call(t,r)&&e.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(t);for(const n of r)i.call(t,n)&&e.push(n)}return e};function l(t){return Array.isArray(t)?function(t){const e=t.slice(0,0);return u(t).forEach((r=>{s(e,r,l(t[r]))})),e}(t):n(t)?function(t){const e=null===Object.getPrototypeOf(t)?Object.create(null):{};return u(t).forEach((r=>{s(e,r,l(t[r]))})),e}(t):t}const f=(t,e,r,n)=>(r.forEach((r=>{void 0===e[r]&&n.ignoreUndefined||(r in t&&t[r]!==Object.getPrototypeOf(t)?s(t,r,h(t[r],e[r],n)):s(t,r,l(e[r])))})),t);function h(t,e,r){return r.concatArrays&&Array.isArray(t)&&Array.isArray(e)?((t,e,r)=>{let n=t.slice(0,0),i=0;return[t,e].forEach((e=>{const a=[];for(let r=0;r<e.length;r++)o.call(e,r)&&(a.push(String(r)),s(n,i++,e===t?e[r]:l(e[r])));n=f(n,e,u(e).filter((t=>!a.includes(t))),r)})),n})(t,e,r):n(e)&&n(t)?f(t,e,u(e),r):l(e)}t.exports=function(...t){const e=h(l(c),this!==a&&this||{},c);let r={_:{}};for(const o of t)if(void 0!==o){if(!n(o))throw new TypeError("`"+o+"` is not an Option Object");r=h(r,{_:o},e)}return r._}},584:t=>{function e(){}e.prototype={on:function(t,e,r){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:e,ctx:r}),this},once:function(t,e,r){var n=this;function o(){n.off(t,o),e.apply(r,arguments)}return o._=e,this.on(t,o,r)},emit:function(t){for(var e=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),n=0,o=r.length;n<o;n++)r[n].fn.apply(r[n].ctx,e);return this},off:function(t,e){var r=this.e||(this.e={}),n=r[t],o=[];if(n&&e)for(var i=0,s=n.length;i<s;i++)n[i].fn!==e&&n[i].fn._!==e&&o.push(n[i]);return o.length?r[t]=o:delete r[t],this}},t.exports=e,t.exports.TinyEmitter=e}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{FlagProvider:()=>s,InMemoryStorageProvider:()=>t.InMemoryStorageProvider,LocalStorageProvider:()=>t.LocalStorageProvider,UnleashClient:()=>t.UnleashClient,default:()=>f,useFlag:()=>a,useFlagsStatus:()=>c,useUnleashContext:()=>l,useVariant:()=>u});var t=r(474);const e=require("react"),o=r.n(e)().createContext(null);var i=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};const s=function(r){var n=r.config,s=r.children,a=r.unleashClient,c=e.useRef(a);if(!n&&!a)throw new Error("You must provide either a config or an unleash client to the flag provider");c.current||(c.current=new t.UnleashClient(n)),e.useEffect((function(){c.current.start()}),[]);var u={on:function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return(e=c.current).on.apply(e,i([t],r,!1))},updateContext:function(t){return e=void 0,r=void 0,o=function(){return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(e){switch(e.label){case 0:return[4,c.current.updateContext(t)];case 1:return e.sent(),[2]}}))},new((n=void 0)||(n=Promise))((function(t,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,a)}c((o=o.apply(e,r||[])).next())}));var e,r,n,o},isEnabled:function(t){return c.current.isEnabled(t)},getVariant:function(t){return c.current.getVariant(t)},client:c.current};return e.createElement(o.Provider,{value:u},s)},a=function(t){var r=(0,e.useContext)(o),n=r.isEnabled,i=r.client,s=(0,e.useState)(!!n(t)),a=s[0],c=s[1],u=(0,e.useRef)();return u.current=a,(0,e.useEffect)((function(){i&&(i.on("update",(function(){var e=n(t);e!==u.current&&(u.current=e,c(!!e))})),i.on("ready",(function(){var e=n(t);c(e)})))}),[i]),a},c=function(){var r=(0,e.useContext)(o).on,n=(0,e.useState)(!1),i=n[0],s=n[1],a=(0,e.useState)(null),c=a[0],u=a[1];return(0,e.useEffect)((function(){r(t.EVENTS.READY,(function(){s(!0)})),r(t.EVENTS.ERROR,(function(t){u(t)}))}),[]),{flagsReady:i,flagsError:c}},u=function(t){var r=(0,e.useContext)(o),n=r.getVariant,i=r.client,s=(0,e.useState)(n(t)),a=s[0],c=s[1],u=(0,e.useRef)();return u.current=a,(0,e.useEffect)((function(){i&&(i.on("update",(function(){var e=n(t);u.current.name===e.name&&u.current.enabled===e.enabled||(c(e),u.current=e)})),i.on("ready",(function(){var e=n(t);c(e)})))}),[i]),a||{}},l=function(){return(0,e.useContext)(o).updateContext},f=s})(),module.exports=n})();

@@ -0,7 +1,9 @@

/** @format */
import * as React from 'react';
import { IConfig } from 'unleash-proxy-client';
import { UnleashClient, IConfig } from 'unleash-proxy-client';
interface IFlagProvider {
config: IConfig;
config?: IConfig;
unleashClient?: UnleashClient;
}
declare const FlagProvider: React.FC<IFlagProvider>;
export default FlagProvider;

@@ -0,1 +1,5 @@

/**
* @format
* @jest-environment jsdom
*/
import '@testing-library/jest-dom';

@@ -1,2 +0,4 @@

export type { IConfig } from 'unleash-proxy-client';
/** @format */
export type { IConfig, IContext, IMutableContext, IVariant, IToggle, } from 'unleash-proxy-client';
export { UnleashClient, IStorageProvider, LocalStorageProvider, InMemoryStorageProvider, } from 'unleash-proxy-client';
import FlagProvider from './FlagProvider';

@@ -7,3 +9,3 @@ import useFlag from './useFlag';

import useUnleashContext from './useUnleashContext';
export { FlagProvider, useFlag, useFlagsStatus, useVariant, useUnleashContext };
export { FlagProvider, useFlag, useFlagsStatus, useVariant, useUnleashContext, };
export default FlagProvider;
{
"name": "@unleash/proxy-client-react",
"version": "1.0.1",
"version": "1.0.2-alpha.0",
"description": "React interface for working with unleash",

@@ -43,3 +43,3 @@ "main": "./dist/index.js",

"typescript": "^4.4.3",
"unleash-proxy-client": "^1.7.0",
"unleash-proxy-client": "Unleash/unleash-proxy-client-js#master",
"webpack": "^5.35.1",

@@ -46,0 +46,0 @@ "webpack-cli": "^4.6.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc