@unleash/proxy-client-vue 1.0.0 → 1.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -5
- package/dist/FlagProvider.vue.d.ts +2 -1
- package/dist/index.es.js +402 -394
- package/dist/index.umd.js +1 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/useFlag.d.ts +2 -2
- package/dist/useUnleashProvide.d.ts +5 -3
- package/dist/useVariant.d.ts +3 -3
- package/package.json +9 -3
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(function(m,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m["proxy-client-vue"]={},m.Vue))})(this,(function(m,p){"use strict";var M=function(o,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])},M(o,t)};function q(o,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=o}M(o,t),o.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var d=function(){return d=Object.assign||function(o){for(var t,e=1,r=arguments.length;e<r;e++)for(var n in t=arguments[e])Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o},d.apply(this,arguments)};function b(o,t,e,r){return new(e||(e=Promise))((function(n,s){function i(u){try{l(r.next(u))}catch(a){s(a)}}function c(u){try{l(r.throw(u))}catch(a){s(a)}}function l(u){var a;u.done?n(u.value):(a=u.value,a instanceof e?a:new e((function(f){f(a)}))).then(i,c)}l((r=r.apply(o,t||[])).next())}))}function x(o,t){var e,r,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function c(l){return function(u){return(function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(e=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(n=s.trys,!((n=n.length>0&&n[n.length-1])||a[0]!==6&&a[0]!==2)){s=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(a[0]===6&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(o,s)}catch(f){a=[6,f],r=0}finally{e=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}})([l,u])}}}function N(o,t,e){if(e||arguments.length===2)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return o.concat(r||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var B,A={exports:{}},Y=(function(){if(B)return A.exports;function o(){}return B=1,o.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 s(){n.off(t,s),e.apply(r,arguments)}return s._=e,this.on(t,s,r)},emit:function(t){for(var e=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),n=0,s=r.length;n<s;n++)r[n].fn.apply(r[n].ctx,e);return this},off:function(t,e){var r=this.e||(this.e={}),n=r[t],s=[];if(n&&e)for(var i=0,c=n.length;i<c;i++)n[i].fn!==e&&n[i].fn._!==e&&s.push(n[i]);return s.length?r[t]=s:delete r[t],this}},A.exports=o,A.exports.TinyEmitter=o,A.exports})(),L=function(o){var t=o[1];return t!=null},dt=function(o){var t=o.properties,e=t===void 0?{}:t,r=(function(s,i){var c={};for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&i.indexOf(l)<0&&(c[l]=s[l]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function"){var u=0;for(l=Object.getOwnPropertySymbols(s);u<l.length;u++)i.indexOf(l[u])<0&&Object.prototype.propertyIsEnumerable.call(s,l[u])&&(c[l[u]]=s[l[u]])}return c})(o,["properties"]),n=function(s){return Object.entries(s).sort((function(i,c){var l=i[0],u=c[0];return l.localeCompare(u,void 0)}))};return JSON.stringify([n(r),n(e)])},W=function(o){return b(void 0,void 0,void 0,(function(){var t;return x(this,(function(e){switch(e.label){case 0:t=dt(o),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,(r=t,b(void 0,void 0,void 0,(function(){var n,s,i,c,l;return x(this,(function(u){switch(u.label){case 0:if(n=typeof globalThis<"u"&&(!((c=globalThis.crypto)===null||c===void 0)&&c.subtle)?(l=globalThis.crypto)===null||l===void 0?void 0:l.subtle:void 0,typeof TextEncoder>"u"||!(n!=null&&n.digest)||typeof Uint8Array>"u")throw new Error("Hashing function not available");return s=new TextEncoder().encode(r),[4,n.digest("SHA-256",s)];case 1:return i=u.sent(),[2,Array.from(new Uint8Array(i)).map((function(a){return a.toString(16).padStart(2,"0")})).join("")]}}))})))];case 2:return[2,e.sent()];case 3:return e.sent(),[2,t];case 4:return[2]}var r}))}))},z=function(o){var t,e=o.clientKey,r=o.appName,n=o.connectionId,s=o.customHeaders,i=o.headerName,c=i===void 0?"authorization":i,l=o.etag,u=o.isPost,a=((t={accept:"application/json"})[c.toLocaleLowerCase()]=e,t["unleash-sdk"]="unleash-js-sdk:3.8.2",t["unleash-appname"]=r,t);return u&&(a["content-type"]="application/json"),l&&(a["if-none-match"]=l),Object.entries(s||{}).filter(L).forEach((function(f){var S=f[0],E=f[1];return a[S.toLocaleLowerCase()]=E})),a["unleash-connection-id"]=n,a},vt=function(){},mt=(function(){function o(t){var e=t.onError,r=t.onSent,n=t.appName,s=t.metricsInterval,i=t.disableMetrics,c=i!==void 0&&i,l=t.url,u=t.clientKey,a=t.fetch,f=t.headerName,S=t.customHeaders,E=S===void 0?{}:S,T=t.metricsIntervalInitial,v=t.connectionId,g=t.metricRegistry;this.onError=e,this.onSent=r||vt,this.disabled=c,this.metricsInterval=1e3*s,this.metricsIntervalInitial=1e3*T,this.appName=n,this.url=l instanceof URL?l:new URL(l),this.clientKey=u,this.bucket=this.createEmptyBucket(),this.fetch=a,this.headerName=f,this.customHeaders=E,this.connectionId=v,this.metricRegistry=g}return o.prototype.start=function(){var t=this;if(this.disabled)return!1;this.setupMetricsFlushOnPageUnload(),typeof this.metricsInterval=="number"&&this.metricsInterval>0&&(this.metricsIntervalInitial>0?setTimeout((function(){t.startTimer(),t.sendMetrics()}),this.metricsIntervalInitial):this.startTimer())},o.prototype.stop=function(){this.timer&&(clearInterval(this.timer),delete this.timer),this.removeMetricsFlushOnPageUnload()},o.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},o.prototype.getHeaders=function(){return z({clientKey:this.clientKey,appName:this.appName,connectionId:this.connectionId,customHeaders:this.customHeaders,headerName:this.headerName,isPost:!0})},o.prototype.sendMetrics=function(){return b(this,arguments,void 0,(function(t){var e,r,n,s=(t===void 0?{}:t).fireAndForget,i=s!==void 0&&s;return x(this,(function(c){switch(c.label){case 0:if(e="".concat(this.url.toString().replace(/\/$/,""),"/client/metrics"),r=this.getPayload(),this.bucketIsEmpty(r)&&(!r.impactMetrics||r.impactMetrics.length===0))return[2];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.fetch(e,{cache:"no-cache",method:"POST",headers:this.getHeaders(),body:JSON.stringify(r),keepalive:i})];case 2:return c.sent(),this.onSent(r),[3,4];case 3:return n=c.sent(),console.error("Unleash: unable to send feature metrics",n),this.onError(n),[3,4];case 4:return[2]}}))}))},o.prototype.count=function(t,e){return!(this.disabled||!this.bucket)&&(this.assertBucket(t),this.bucket.toggles[t][e?"yes":"no"]++,!0)},o.prototype.countVariant=function(t,e){return!(this.disabled||!this.bucket)&&(this.assertBucket(t),this.bucket.toggles[t].variants[e]?this.bucket.toggles[t].variants[e]+=1:this.bucket.toggles[t].variants[e]=1,!0)},o.prototype.assertBucket=function(t){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[t]||(this.bucket.toggles[t]={yes:0,no:0,variants:{}})},o.prototype.startTimer=function(){var t=this;this.timer=setInterval((function(){t.sendMetrics()}),this.metricsInterval)},o.prototype.bucketIsEmpty=function(t){return Object.keys(t.bucket.toggles).length===0},o.prototype.getPayload=function(){var t,e=d(d({},this.bucket),{stop:new Date});this.bucket=this.createEmptyBucket();var r={bucket:e,appName:this.appName,instanceId:"browser"},n=((t=this.metricRegistry)===null||t===void 0?void 0:t.collect())||[];return r.impactMetrics=n,r},o.prototype.setupMetricsFlushOnPageUnload=function(){var t=this;typeof document>"u"||typeof window>"u"||typeof document.addEventListener!="function"||document.addEventListener("visibilitychange",this.flushMetricsOnPageUnload=function(){document.visibilityState==="hidden"&&t.sendMetrics({fireAndForget:!0})})},o.prototype.removeMetricsFlushOnPageUnload=function(){this.flushMetricsOnPageUnload&&(document.removeEventListener("visibilitychange",this.flushMetricsOnPageUnload),this.flushMetricsOnPageUnload=void 0)},o})(),J=(function(){function o(){this.store=new Map}return o.prototype.save=function(t,e){return b(this,void 0,void 0,(function(){return x(this,(function(r){return this.store.set(t,e),[2]}))}))},o.prototype.get=function(t){return b(this,void 0,void 0,(function(){return x(this,(function(e){return[2,this.store.get(t)]}))}))},o})(),G=(function(){function o(t){t===void 0&&(t="unleash:repository"),this.prefix=t}return o.prototype.save=function(t,e){return b(this,void 0,void 0,(function(){var r,n;return x(this,(function(s){r=JSON.stringify(e),n="".concat(this.prefix,":").concat(t);try{window.localStorage.setItem(n,r)}catch(i){console.error(i)}return[2]}))}))},o.prototype.get=function(t){try{var e="".concat(this.prefix,":").concat(t),r=window.localStorage.getItem(e);return r?JSON.parse(r):void 0}catch(n){console.error(n)}},o})(),$=function(){var o;return typeof globalThis<"u"&&(!((o=globalThis.crypto)===null||o===void 0)&&o.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)}))},gt=(function(){function o(){}return o.prototype.generateEventId=function(){return $()},o.prototype.createImpressionEvent=function(t,e,r,n,s,i){var c=this.createBaseEvent(t,e,r,n,s);return i?d(d({},c),{variant:i}):c},o.prototype.createBaseEvent=function(t,e,r,n,s){return{eventType:n,eventId:this.generateEventId(),context:t,enabled:e,featureName:r,impressionData:s}},o})();function Q(o){return o!==void 0&&!Number.isFinite(o)}function j(o){return o?Object.keys(o).sort().map((function(t){return"".concat(t,"=").concat(o[t])})).join(","):""}function X(o){var t={};if(!o)return t;for(var e=0,r=o.split(",");e<r.length;e++){var n=r[e].split("="),s=n[0],i=n[1];t[s]=i}return t}var yt=function(o){return"value"in o},Z=function(o){return"buckets"in o},bt=(function(){function o(t){this.opts=t,this.values=new Map}return o.prototype.inc=function(t,e){var r;if(!Q(t)){var n=t??1;if(!(n<=0)){var s=j(e),i=(r=this.values.get(s))!==null&&r!==void 0?r:0;this.values.set(s,i+n)}}},o.prototype.collect=function(){var t=Array.from(this.values.entries()).map((function(e){var r=e[0],n=e[1];return{labels:X(r),value:n}}));return this.values.clear(),t.length===0&&t.push({labels:{},value:0}),{name:this.opts.name,help:this.opts.help,type:"counter",samples:t}},o})(),xt=(function(){function o(t){this.opts=t,this.values=new Map;var e=t.buckets&&t.buckets.length>0?t.buckets:[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],r=Array.from(new Set(e.filter((function(n){return n!==1/0})))).sort((function(n,s){return n-s}));this.buckets=N(N([],r,!0),[1/0],!1)}return o.prototype.restore=function(t){var e=j(t.labels),r={count:t.count,sum:t.sum,buckets:new Map(t.buckets.map((function(n){return[n.le==="+Inf"?1/0:n.le,n.count]})))};this.values.set(e,r)},o.prototype.observe=function(t,e){var r;if(!Q(t)){var n=j(e),s=this.values.get(n);if(!s){for(var i=new Map,c=0,l=this.buckets;c<l.length;c++){var u=l[c];i.set(u,0)}s={count:0,sum:0,buckets:i},this.values.set(n,s)}s.count++,s.sum+=t;for(var a=0,f=this.buckets;a<f.length;a++)if(t<=(u=f[a])){var S=(r=s.buckets.get(u))!==null&&r!==void 0?r:0;s.buckets.set(u,S+1)}}},o.prototype.collect=function(){var t=Array.from(this.values.entries()).map((function(e){var r=e[0],n=e[1];return{labels:X(r),count:n.count,sum:n.sum,buckets:Array.from(n.buckets.entries()).map((function(s){var i=s[0];return{le:i===1/0?"+Inf":i,count:s[1]}}))}}));return this.values.clear(),t.length===0&&t.push({labels:{},count:0,sum:0,buckets:this.buckets.map((function(e){return{le:e===1/0?"+Inf":e,count:0}}))}),{name:this.opts.name,help:this.opts.help,type:"histogram",samples:t}},o})(),Tt=(function(){function o(){this.counters=new Map,this.histograms=new Map}return o.prototype.getCounter=function(t){return this.counters.get(t)},o.prototype.getHistogram=function(t){return this.histograms.get(t)},o.prototype.counter=function(t){var e=t.name,r=this.counters.get(e);return r||(r=new bt(t),this.counters.set(e,r)),r},o.prototype.histogram=function(t){var e=t.name,r=this.histograms.get(e);return r||(r=new xt(t),this.histograms.set(e,r)),r},o.prototype.collect=function(){var t=Array.from(this.counters.values()).map((function(n){return n.collect()})),e=Array.from(this.histograms.values()).map((function(n){return n.collect()})),r=N(N([],t,!0),e,!0).filter((function(n){return n.samples.length>0}));return r.length>0?r:[]},o.prototype.restore=function(t){for(var e=function(i){switch(i.type){case"counter":for(var c=r.counter({name:i.name,help:i.help}),l=0,u=i.samples;l<u.length;l++){var a=u[l];yt(a)&&c.inc(a.value,a.labels)}break;case"histogram":var f=i.samples.find(Z);if(f){var S=f.buckets.map((function(T){return T.le==="+Inf"?1/0:T.le})),E=r.histogram({name:i.name,help:i.help,buckets:S});i.samples.filter(Z).forEach((function(T){E.restore(T)}))}}},r=this,n=0,s=t;n<s.length;n++)e(s[n])},o})(),y={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression",SENT:"sent",RECOVERED:"recovered",WARN:"warn"},St=(function(o){function t(e,r,n){var s=o.call(this)||this;return s.metricRegistry=e,s.appName=r,s.environment=n,s}return q(t,o),t.prototype.defineCounter=function(e,r){e&&r?this.metricRegistry.counter({name:e,help:r,labelNames:["featureName","appName","environment"]}):this.emit(y.WARN,"Counter name or help cannot be empty: ".concat(e,", ").concat(r,"."))},t.prototype.defineHistogram=function(e,r,n){e&&r?this.metricRegistry.histogram({name:e,help:r,labelNames:["featureName","appName","environment"],buckets:n}):this.emit(y.WARN,"Histogram name or help cannot be empty: ".concat(e,", ").concat(r,"."))},t.prototype.incrementCounter=function(e,r){var n=this.metricRegistry.getCounter(e);if(n){var s={appName:this.appName,environment:this.environment};n.inc(r,s)}else this.emit(y.WARN,"Counter ".concat(e," not defined, this counter will not be incremented."))},t.prototype.observeHistogram=function(e,r){var n=this.metricRegistry.getHistogram(e);if(n){var s={appName:this.appName,environment:this.environment};n.observe(r,s)}else this.emit(y.WARN,"Histogram ".concat(e," not defined, this histogram will not be updated."))},t})(Y.TinyEmitter),Et=["userId","sessionId","remoteAddress","currentTime"],V=function(o){return Et.includes(o)},wt="isEnabled",Rt="getVariant",It={name:"disabled",enabled:!1,feature_enabled:!1},H="repo",tt="repoLastUpdateTimestamp",kt=function(){try{if(typeof window<"u"&&"fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(o){console.error('Unleash failed to resolve "fetch"',o)}},et=(function(o){function t(e){var r,n=e.storageProvider,s=e.url,i=e.clientKey,c=e.disableRefresh,l=c!==void 0&&c,u=e.refreshInterval,a=u===void 0?30:u,f=e.metricsInterval,S=f===void 0?30:f,E=e.metricsIntervalInitial,T=E===void 0?2:E,v=e.disableMetrics,g=v!==void 0&&v,w=e.appName,C=e.environment,P=C===void 0?"default":C,F=e.context,ot=e.fetch,_=ot===void 0?kt():ot,st=e.createAbortController,it=st===void 0?(function(){try{if(typeof window<"u"&&"AbortController"in window)return function(){return new window.AbortController};if("fetch"in globalThis)return function(){return new globalThis.AbortController}}catch(O){console.error('Unleash failed to resolve "AbortController" factory',O)}})():st,k=e.bootstrap,at=e.bootstrapOverride,Lt=at===void 0||at,ct=e.headerName,ut=ct===void 0?"Authorization":ct,lt=e.customHeaders,ht=lt===void 0?{}:lt,ft=e.impressionDataAll,jt=ft!==void 0&&ft,pt=e.usePOSTrequests,Ht=pt!==void 0&&pt,I=e.experimental,h=o.call(this)||this;if(h.toggles=[],h.etag="",h.readyEventEmitted=!1,h.fetchedFromServer=!1,h.usePOSTrequests=!1,h.started=!1,!s)throw new Error("url is required");if(!i)throw new Error("clientKey is required");if(!w)throw new Error("appName is required.");h.eventsHandler=new gt,h.impressionDataAll=jt,h.toggles=k&&k.length>0?k:[],h.url=s instanceof URL?s:new URL(s),h.clientKey=i,h.headerName=ut,h.customHeaders=ht,h.storage=n||(typeof window<"u"?new G:new J),h.refreshInterval=l?0:1e3*a,h.context=d({appName:w,environment:P},F),h.usePOSTrequests=Ht,h.sdkState="initializing";var U=I==null?void 0:I.metricsUrl;!U||U instanceof URL||(U=new URL(U)),h.experimental=d(d({},I),{metricsUrl:U}),I!=null&&I.togglesStorageTTL&&(I==null?void 0:I.togglesStorageTTL)>0&&(h.experimental.togglesStorageTTL=1e3*I.togglesStorageTTL),h.lastRefreshTimestamp=0,h.ready=new Promise((function(O){h.init().then(O).catch((function(K){console.error(K),h.sdkState="error",h.emit(y.ERROR,K),h.lastError=K,O()}))})),_||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),it||console.error('Unleash: You must either provide your own "AbortController" implementation or run in an environment where "AbortController" is available.'),h.fetch=_,h.createAbortController=it,h.bootstrap=k&&k.length>0?k:void 0,h.bootstrapOverride=Lt,h.connectionId=$(),h.metricRegistry=new Tt;var Dt=h.resolveEnvironment(i,P);return h.impactMetrics=new St(h.metricRegistry,w,Dt),h.metrics=new mt({onError:function(O){return h.emit(y.ERROR,{type:"metrics",error:O})},onSent:h.emit.bind(h,y.SENT),appName:w,metricsInterval:S,disableMetrics:g,url:((r=h.experimental)===null||r===void 0?void 0:r.metricsUrl)||h.url,clientKey:i,fetch:_,headerName:ut,customHeaders:ht,metricsIntervalInitial:T,connectionId:h.connectionId,metricRegistry:h.metricRegistry}),h}return q(t,o),t.prototype.getAllToggles=function(){return N([],this.toggles,!0)},t.prototype.isEnabled=function(e){var r,n=this.toggles.find((function(c){return c.name===e})),s=!!n&&n.enabled;if(this.metrics.count(e,s),(n==null?void 0:n.impressionData)||this.impressionDataAll){var i=this.eventsHandler.createImpressionEvent(this.context,s,e,wt,(r=n==null?void 0:n.impressionData)!==null&&r!==void 0?r:void 0);this.emit(y.IMPRESSION,i)}return s},t.prototype.getVariant=function(e){var r,n=this.toggles.find((function(l){return l.name===e})),s=(n==null?void 0:n.enabled)||!1,i=n?n.variant:It;if(i.name&&this.metrics.countVariant(e,i.name),this.metrics.count(e,s),(n==null?void 0:n.impressionData)||this.impressionDataAll){var c=this.eventsHandler.createImpressionEvent(this.context,s,e,Rt,(r=n==null?void 0:n.impressionData)!==null&&r!==void 0?r:void 0,i.name);this.emit(y.IMPRESSION,c)}return d(d({},i),{feature_enabled:s})},t.prototype.updateToggles=function(){return b(this,void 0,void 0,(function(){var e=this;return x(this,(function(r){switch(r.label){case 0:return this.timerRef||this.fetchedFromServer?[4,this.fetchToggles()]:[3,2];case 1:return r.sent(),[3,4];case 2:return this.started?[4,new Promise((function(n){var s=function(){e.fetchToggles().then((function(){e.off(y.READY,s),n()}))};e.once(y.READY,s)}))]:[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))},t.prototype.updateContext=function(e){return b(this,void 0,void 0,(function(){var r;return x(this,(function(n){switch(n.label){case 0:return(e.appName||e.environment)&&this.emit(y.WARN,"appName and environment are static. They can't be updated with updateContext."),r={environment:this.context.environment,appName:this.context.appName,sessionId:this.context.sessionId},this.context=d(d({},r),e),[4,this.updateToggles()];case 1:return n.sent(),[2]}}))}))},t.prototype.getContext=function(){return d({},this.context)},t.prototype.setContextField=function(e,r){return b(this,void 0,void 0,(function(){var n,s,i;return x(this,(function(c){switch(c.label){case 0:return V(e)?this.context=d(d({},this.context),((s={})[e]=r,s)):(n=d(d({},this.context.properties),((i={})[e]=r,i)),this.context=d(d({},this.context),{properties:n})),[4,this.updateToggles()];case 1:return c.sent(),[2]}}))}))},t.prototype.removeContextField=function(e){return b(this,void 0,void 0,(function(){var r;return x(this,(function(n){switch(n.label){case 0:return V(e)?this.context=d(d({},this.context),((r={})[e]=void 0,r)):typeof this.context.properties=="object"&&delete this.context.properties[e],[4,this.updateToggles()];case 1:return n.sent(),[2]}}))}))},t.prototype.setReady=function(){this.readyEventEmitted=!0,this.emit(y.READY)},t.prototype.init=function(){return b(this,void 0,void 0,(function(){var e,r,n;return x(this,(function(s){switch(s.label){case 0:return[4,this.resolveSessionId()];case 1:return e=s.sent(),this.context=d({sessionId:e},this.context),[4,this.storage.get(H)];case 2:return r=s.sent()||[],n=this,[4,this.getLastRefreshTimestamp()];case 3:return n.lastRefreshTimestamp=s.sent(),!this.bootstrap||!this.bootstrapOverride&&r.length!==0?[3,6]:[4,this.storage.save(H,this.bootstrap)];case 4:return s.sent(),this.toggles=this.bootstrap,this.sdkState="healthy",[4,this.storeLastRefreshTimestamp()];case 5:return s.sent(),this.setReady(),[3,7];case 6:this.toggles=r,s.label=7;case 7:return this.sdkState="healthy",this.emit(y.INIT),[2]}}))}))},t.prototype.start=function(){return b(this,void 0,void 0,(function(){var e,r=this;return x(this,(function(n){switch(n.label){case 0:return this.started=!0,this.timerRef?(console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again."),[2]):[4,this.ready];case 1:return n.sent(),this.metrics.start(),e=this.refreshInterval,[4,this.initialFetchToggles()];case 2:return n.sent(),e>0&&(this.timerRef=setInterval((function(){return r.fetchToggles()}),e)),[2]}}))}))},t.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},t.prototype.isReady=function(){return this.readyEventEmitted},t.prototype.getError=function(){return this.sdkState==="error"?this.lastError:void 0},t.prototype.sendMetrics=function(){return this.metrics.sendMetrics()},t.prototype.resolveSessionId=function(){return b(this,void 0,void 0,(function(){var e;return x(this,(function(r){switch(r.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[4,this.storage.get("sessionId")];case 1:return(e=r.sent())?[3,3]:(e=Math.floor(1e9*Math.random()),[4,this.storage.save("sessionId",e.toString(10))]);case 2:r.sent(),r.label=3;case 3:return[2,e.toString(10)]}}))}))},t.prototype.getHeaders=function(){return z({clientKey:this.clientKey,connectionId:this.connectionId,appName:this.context.appName,customHeaders:this.customHeaders,headerName:this.headerName,etag:this.etag,isPost:this.usePOSTrequests})},t.prototype.storeToggles=function(e){return b(this,void 0,void 0,(function(){return x(this,(function(r){switch(r.label){case 0:return this.toggles=e,this.emit(y.UPDATE),[4,this.storage.save(H,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.isTogglesStorageTTLEnabled=function(){var e;return!!(!((e=this.experimental)===null||e===void 0)&&e.togglesStorageTTL&&this.experimental.togglesStorageTTL>0)},t.prototype.isUpToDate=function(){var e;if(!this.isTogglesStorageTTLEnabled())return!1;var r=Date.now(),n=((e=this.experimental)===null||e===void 0?void 0:e.togglesStorageTTL)||0;return this.lastRefreshTimestamp>0&&this.lastRefreshTimestamp<=r&&r-this.lastRefreshTimestamp<=n},t.prototype.getLastRefreshTimestamp=function(){return b(this,void 0,void 0,(function(){var e,r;return x(this,(function(n){switch(n.label){case 0:return this.isTogglesStorageTTLEnabled()?[4,this.storage.get(tt)]:[3,3];case 1:return e=n.sent(),[4,W(this.context)];case 2:return r=n.sent(),[2,(e==null?void 0:e.key)===r?e.timestamp:0];case 3:return[2,0]}}))}))},t.prototype.storeLastRefreshTimestamp=function(){return b(this,void 0,void 0,(function(){var e,r;return x(this,(function(n){switch(n.label){case 0:return this.isTogglesStorageTTLEnabled()?(this.lastRefreshTimestamp=Date.now(),r={},[4,W(this.context)]):[3,3];case 1:return r.key=n.sent(),r.timestamp=this.lastRefreshTimestamp,e=r,[4,this.storage.save(tt,e)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},t.prototype.initialFetchToggles=function(){if(!this.isUpToDate())return this.fetchToggles();this.fetchedFromServer||(this.fetchedFromServer=!0,this.setReady())},t.prototype.fetchToggles=function(){return b(this,void 0,void 0,(function(){var e,r,n,s,i,c,l,u,a;return x(this,(function(f){switch(f.label){case 0:if(!this.fetch)return[3,9];this.abortController&&!this.abortController.signal.aborted&&this.abortController.abort(),this.abortController=(a=this.createAbortController)===null||a===void 0?void 0:a.call(this),e=this.abortController?this.abortController.signal:void 0,f.label=1;case 1:return f.trys.push([1,7,8,9]),r=this.usePOSTrequests,n=r?this.url:(function(S,E){var T=new URL(S.toString());return Object.entries(E).filter(L).forEach((function(v){var g=v[0],w=v[1];g==="properties"&&w?Object.entries(w).filter(L).forEach((function(C){var P=C[0],F=C[1];return T.searchParams.append("properties[".concat(P,"]"),F)})):T.searchParams.append(g,w)})),T})(this.url,this.context),s=r?"POST":"GET",i=r?JSON.stringify({context:this.context}):void 0,[4,this.fetch(n.toString(),{method:s,cache:"no-cache",headers:this.getHeaders(),body:i,signal:e})];case 2:return c=f.sent(),this.sdkState==="error"&&c.status<400&&(this.sdkState="healthy",this.emit(y.RECOVERED)),c.ok?(this.etag=c.headers.get("ETag")||"",[4,c.json()]):[3,5];case 3:return l=f.sent(),[4,this.storeToggles(l.toggles)];case 4:return f.sent(),this.sdkState!=="healthy"&&(this.sdkState="healthy"),this.fetchedFromServer||(this.fetchedFromServer=!0,this.setReady()),this.storeLastRefreshTimestamp(),[3,6];case 5:c.status===304?this.storeLastRefreshTimestamp():(console.error("Unleash: Fetching feature toggles did not have an ok response"),this.sdkState="error",this.emit(y.ERROR,{type:"HttpError",code:c.status}),this.lastError={type:"HttpError",code:c.status}),f.label=6;case 6:return[3,9];case 7:return typeof(u=f.sent())=="object"&&u!==null&&"name"in u&&u.name==="AbortError"||(console.error("Unleash: unable to fetch feature toggles",u),this.sdkState="error",this.emit(y.ERROR,{type:"fetch-toggles",error:u}),this.lastError=u),[3,9];case 8:return this.abortController=null,[7];case 9:return[2]}}))}))},t.prototype.resolveEnvironment=function(e,r){return(function(n){var s=n.indexOf(":");if(s!==-1){var i=n.slice(s+1),c=i.lastIndexOf(".");if(c!==-1)return i.slice(0,c)}})(e)||r},t})(Y.TinyEmitter);const R=Symbol("Context state identifier"),D=Symbol("Context update identifier");function rt({config:o,unleashClient:t,startClient:e=!0}){var E,T;const r=p.ref(t),n=p.ref(!1),s=p.ref(null);!o&&!t&&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.`),!r.value&&o&&(r.value=new et(o)),(E=r.value)==null||E.on("ready",()=>{n.value=!0}),(T=r.value)==null||T.on("error",v=>{s.value=v});const i=async v=>{var g;await((g=r.value)==null?void 0:g.updateContext(v))},c=v=>{var g;return(g=r.value)==null?void 0:g.isEnabled(v)},l=v=>{var g;return(g=r.value)==null?void 0:g.getVariant(v)},u=(v,...g)=>{var w;return(w=r.value)==null?void 0:w.on(v,...g)},a=p.reactive({on:u,updateContext:i,isEnabled:c,getVariant:l,client:r,flagsReady:n,flagsError:s}),f=(v,g)=>{a[v]=g},S=()=>{var v;(e||!t)&&((v=r==null?void 0:r.value)==null||v.start())};return{context:p.toRefs(a),update:f,start:S}}const nt=p.defineComponent({__name:"FlagProvider",props:{config:{},unleashClient:{},startClient:{type:Boolean,default:!0}},setup(o){const{context:t,start:e,update:r}=rt({config:o.config,unleashClient:o.unleashClient,startClient:o.startClient});return p.provide(R,t),p.provide(D,r),p.onMounted(()=>{e()}),(n,s)=>p.renderSlot(n.$slots,"default")}}),Ot=o=>{const{isEnabled:t,client:e}=p.inject(R,{}),r=p.ref(!!(t!=null&&t.value(o)));function n(){const i=t==null?void 0:t.value(o);i!==r.value&&(r.value=!!i)}function s(){r.value=!!(t!=null&&t.value(o))}return e==null||e.value.on("ready",s),e==null||e.value.on("update",n),p.onUnmounted(()=>{e==null||e.value.off("ready",s),e==null||e.value.off("update",n)}),r},Nt=()=>{const{flagsReady:o,flagsError:t}=p.inject(R,{});return{flagsReady:o,flagsError:t}},Ct=(o,t)=>{var r,n,s,i;return!((o==null?void 0:o.name)===(t==null?void 0:t.name)&&(o==null?void 0:o.enabled)===(t==null?void 0:t.enabled)&&(o==null?void 0:o.feature_enabled)===(t==null?void 0:t.feature_enabled)&&((r=o==null?void 0:o.payload)==null?void 0:r.type)===((n=t==null?void 0:t.payload)==null?void 0:n.type)&&((s=o==null?void 0:o.payload)==null?void 0:s.value)===((i=t==null?void 0:t.payload)==null?void 0:i.value))},Ut=o=>{const{getVariant:t,client:e}=p.inject(R,{}),r=p.ref(t==null?void 0:t.value(o));function n(){const i=t==null?void 0:t.value(o);Ct(r==null?void 0:r.value,i)&&(r.value=i)}function s(){r.value=t==null?void 0:t.value(o)}return e==null||e.value.on("ready",s),e==null||e.value.on("update",n),p.onUnmounted(()=>{e==null||e.value.off("ready",s),e==null||e.value.off("update",n)}),r||{}},At=()=>{const{updateContext:o}=p.inject(R,{});return o==null?void 0:o.value},Pt=()=>{const{client:o}=p.inject(R,{});return o==null?void 0:o.value},Mt={install(o,{config:t,unleashClient:e,startClient:r}){const{context:n,update:s,start:i}=rt({config:t,unleashClient:e,startClient:r});o.provide(R,n),o.provide(D,s),i()}};m.ContextStateSymbol=R,m.ContextUpdateSymbol=D,m.FlagProvider=nt,m.InMemoryStorageProvider=J,m.LocalStorageProvider=G,m.UnleashClient=et,m.default=nt,m.plugin=Mt,m.useFlag=Ot,m.useFlagsStatus=Nt,m.useUnleashClient=Pt,m.useUnleashContext=At,m.useVariant=Ut,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(g,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(g=typeof globalThis<"u"?globalThis:g||self,f(g["proxy-client-vue"]={},g.Vue))})(this,(function(g,f){"use strict";var B=function(o,t){return B=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},B(o,t)};function z(o,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=o}B(o,t),o.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var d=function(){return d=Object.assign||function(o){for(var t,e=1,n=arguments.length;e<n;e++)for(var r in t=arguments[e])Object.prototype.hasOwnProperty.call(t,r)&&(o[r]=t[r]);return o},d.apply(this,arguments)};function y(o,t,e,n){return new(e||(e=Promise))((function(r,s){function i(c){try{l(n.next(c))}catch(a){s(a)}}function u(c){try{l(n.throw(c))}catch(a){s(a)}}function l(c){var a;c.done?r(c.value):(a=c.value,a instanceof e?a:new e((function(p){p(a)}))).then(i,u)}l((n=n.apply(o,t||[])).next())}))}function b(o,t){var e,n,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(l){return function(c){return(function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(e=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(r=s.trys,!((r=r.length>0&&r[r.length-1])||a[0]!==6&&a[0]!==2)){s=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(a[0]===6&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(o,s)}catch(p){a=[6,p],n=0}finally{e=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}})([l,c])}}}function L(o,t,e){if(e||arguments.length===2)for(var n,r=0,s=t.length;r<s;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return o.concat(n||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var G,F={exports:{}},$=(function(){if(G)return F.exports;function o(){}return G=1,o.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 s(){r.off(t,s),e.apply(n,arguments)}return s._=e,this.on(t,s,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,s=n.length;r<s;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],s=[];if(r&&e)for(var i=0,u=r.length;i<u;i++)r[i].fn!==e&&r[i].fn._!==e&&s.push(r[i]);return s.length?n[t]=s:delete n[t],this}},F.exports=o,F.exports.TinyEmitter=o,F.exports})(),K=function(o){var t=o[1];return t!=null},vt=function(o){var t=o.properties,e=t===void 0?{}:t,n=(function(s,i){var u={};for(var l in s)Object.prototype.hasOwnProperty.call(s,l)&&i.indexOf(l)<0&&(u[l]=s[l]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function"){var c=0;for(l=Object.getOwnPropertySymbols(s);c<l.length;c++)i.indexOf(l[c])<0&&Object.prototype.propertyIsEnumerable.call(s,l[c])&&(u[l[c]]=s[l[c]])}return u})(o,["properties"]),r=function(s){return Object.entries(s).sort((function(i,u){var l=i[0],c=u[0];return l.localeCompare(c,void 0)}))};return JSON.stringify([r(n),r(e)])},Q=function(o){return y(void 0,void 0,void 0,(function(){var t;return b(this,(function(e){switch(e.label){case 0:t=vt(o),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,(n=t,y(void 0,void 0,void 0,(function(){var r,s,i,u,l;return b(this,(function(c){switch(c.label){case 0:if(r=typeof globalThis<"u"&&(!((u=globalThis.crypto)===null||u===void 0)&&u.subtle)?(l=globalThis.crypto)===null||l===void 0?void 0:l.subtle:void 0,typeof TextEncoder>"u"||!(r!=null&&r.digest)||typeof Uint8Array>"u")throw new Error("Hashing function not available");return s=new TextEncoder().encode(n),[4,r.digest("SHA-256",s)];case 1:return i=c.sent(),[2,Array.from(new Uint8Array(i)).map((function(a){return a.toString(16).padStart(2,"0")})).join("")]}}))})))];case 2:return[2,e.sent()];case 3:return e.sent(),[2,t];case 4:return[2]}var n}))}))},X=function(o){var t,e=o.clientKey,n=o.appName,r=o.connectionId,s=o.customHeaders,i=o.headerName,u=i===void 0?"authorization":i,l=o.etag,c=o.isPost,a=((t={accept:"application/json"})[u.toLocaleLowerCase()]=e,t["unleash-sdk"]="unleash-js-sdk:3.8.3",t["unleash-appname"]=n,t);return c&&(a["content-type"]="application/json"),l&&(a["if-none-match"]=l),Object.entries(s||{}).filter(K).forEach((function(p){var S=p[0],E=p[1];return a[S.toLocaleLowerCase()]=E})),a["unleash-connection-id"]=r,a},mt=function(){},gt=(function(){function o(t){var e=t.onError,n=t.onSent,r=t.appName,s=t.metricsInterval,i=t.disableMetrics,u=i!==void 0&&i,l=t.url,c=t.clientKey,a=t.fetch,p=t.headerName,S=t.customHeaders,E=S===void 0?{}:S,T=t.metricsIntervalInitial,R=t.connectionId,k=t.metricRegistry;this.onError=e,this.onSent=n||mt,this.disabled=u,this.metricsInterval=1e3*s,this.metricsIntervalInitial=1e3*T,this.appName=r,this.url=l instanceof URL?l:new URL(l),this.clientKey=c,this.bucket=this.createEmptyBucket(),this.fetch=a,this.headerName=p,this.customHeaders=E,this.connectionId=R,this.metricRegistry=k}return o.prototype.start=function(){var t=this;if(this.disabled||this.timer||this.flushMetricsOnPageUnload)return!1;this.setupMetricsFlushOnPageUnload(),typeof this.metricsInterval=="number"&&this.metricsInterval>0&&(this.metricsIntervalInitial>0?this.timer=setTimeout((function(){t.startTimer(),t.sendMetrics()}),this.metricsIntervalInitial):this.startTimer())},o.prototype.stop=function(){this.timer&&(clearInterval(this.timer),delete this.timer),this.removeMetricsFlushOnPageUnload()},o.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},o.prototype.getHeaders=function(){return X({clientKey:this.clientKey,appName:this.appName,connectionId:this.connectionId,customHeaders:this.customHeaders,headerName:this.headerName,isPost:!0})},o.prototype.sendMetrics=function(){return y(this,arguments,void 0,(function(t){var e,n,r,s=(t===void 0?{}:t).fireAndForget,i=s!==void 0&&s;return b(this,(function(u){switch(u.label){case 0:if(e="".concat(this.url.toString().replace(/\/$/,""),"/client/metrics"),n=this.getPayload(),this.bucketIsEmpty(n)&&(!n.impactMetrics||n.impactMetrics.length===0))return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.fetch(e,{cache:"no-cache",method:"POST",headers:this.getHeaders(),body:JSON.stringify(n),keepalive:i})];case 2:return u.sent(),this.onSent(n),[3,4];case 3:return r=u.sent(),console.error("Unleash: unable to send feature metrics",r),this.onError(r),[3,4];case 4:return[2]}}))}))},o.prototype.count=function(t,e){return!(this.disabled||!this.bucket)&&(this.assertBucket(t),this.bucket.toggles[t][e?"yes":"no"]++,!0)},o.prototype.countVariant=function(t,e){return!(this.disabled||!this.bucket)&&(this.assertBucket(t),this.bucket.toggles[t].variants[e]?this.bucket.toggles[t].variants[e]+=1:this.bucket.toggles[t].variants[e]=1,!0)},o.prototype.assertBucket=function(t){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[t]||(this.bucket.toggles[t]={yes:0,no:0,variants:{}})},o.prototype.startTimer=function(){var t=this;this.timer=setInterval((function(){t.sendMetrics()}),this.metricsInterval)},o.prototype.bucketIsEmpty=function(t){return Object.keys(t.bucket.toggles).length===0},o.prototype.getPayload=function(){var t,e=d(d({},this.bucket),{stop:new Date});this.bucket=this.createEmptyBucket();var n={bucket:e,appName:this.appName,instanceId:"browser"},r=((t=this.metricRegistry)===null||t===void 0?void 0:t.collect())||[];return n.impactMetrics=r,n},o.prototype.setupMetricsFlushOnPageUnload=function(){var t=this;typeof document>"u"||typeof window>"u"||typeof document.addEventListener!="function"||document.addEventListener("visibilitychange",this.flushMetricsOnPageUnload=function(){document.visibilityState==="hidden"&&t.sendMetrics({fireAndForget:!0})})},o.prototype.removeMetricsFlushOnPageUnload=function(){this.flushMetricsOnPageUnload&&(document.removeEventListener("visibilitychange",this.flushMetricsOnPageUnload),this.flushMetricsOnPageUnload=void 0)},o})(),Z=(function(){function o(){this.store=new Map}return o.prototype.save=function(t,e){return y(this,void 0,void 0,(function(){return b(this,(function(n){return this.store.set(t,e),[2]}))}))},o.prototype.get=function(t){return y(this,void 0,void 0,(function(){return b(this,(function(e){return[2,this.store.get(t)]}))}))},o})(),V=(function(){function o(t){t===void 0&&(t="unleash:repository"),this.prefix=t}return o.prototype.save=function(t,e){return y(this,void 0,void 0,(function(){var n,r;return b(this,(function(s){n=JSON.stringify(e),r="".concat(this.prefix,":").concat(t);try{window.localStorage.setItem(r,n)}catch(i){console.error(i)}return[2]}))}))},o.prototype.get=function(t){try{var e="".concat(this.prefix,":").concat(t),n=window.localStorage.getItem(e);return n?JSON.parse(n):void 0}catch(r){console.error(r)}},o})(),tt=function(){var o;return typeof globalThis<"u"&&(!((o=globalThis.crypto)===null||o===void 0)&&o.randomUUID)?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return(t==="x"?e:3&e|8).toString(16)}))},yt=(function(){function o(){}return o.prototype.generateEventId=function(){return tt()},o.prototype.createImpressionEvent=function(t,e,n,r,s,i){var u=this.createBaseEvent(t,e,n,r,s);return i?d(d({},u),{variant:i}):u},o.prototype.createBaseEvent=function(t,e,n,r,s){return{eventType:r,eventId:this.generateEventId(),context:t,enabled:e,featureName:n,impressionData:s}},o})();function et(o){return o!==void 0&&!Number.isFinite(o)}function q(o){return o?Object.keys(o).sort().map((function(t){return"".concat(t,"=").concat(o[t])})).join(","):""}function rt(o){var t={};if(!o)return t;for(var e=0,n=o.split(",");e<n.length;e++){var r=n[e].split("="),s=r[0],i=r[1];t[s]=i}return t}var bt=function(o){return"value"in o},nt=function(o){return"buckets"in o},xt=(function(){function o(t){this.opts=t,this.values=new Map}return o.prototype.inc=function(t,e){var n;if(!et(t)){var r=t??1;if(!(r<=0)){var s=q(e),i=(n=this.values.get(s))!==null&&n!==void 0?n:0;this.values.set(s,i+r)}}},o.prototype.collect=function(){var t=Array.from(this.values.entries()).map((function(e){var n=e[0],r=e[1];return{labels:rt(n),value:r}}));return this.values.clear(),t.length===0&&t.push({labels:{},value:0}),{name:this.opts.name,help:this.opts.help,type:"counter",samples:t}},o})(),Tt=(function(){function o(t){this.opts=t,this.values=new Map;var e=t.buckets&&t.buckets.length>0?t.buckets:[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],n=Array.from(new Set(e.filter((function(r){return r!==1/0})))).sort((function(r,s){return r-s}));this.buckets=L(L([],n,!0),[1/0],!1)}return o.prototype.restore=function(t){var e=q(t.labels),n={count:t.count,sum:t.sum,buckets:new Map(t.buckets.map((function(r){return[r.le==="+Inf"?1/0:r.le,r.count]})))};this.values.set(e,n)},o.prototype.observe=function(t,e){var n;if(!et(t)){var r=q(e),s=this.values.get(r);if(!s){for(var i=new Map,u=0,l=this.buckets;u<l.length;u++){var c=l[u];i.set(c,0)}s={count:0,sum:0,buckets:i},this.values.set(r,s)}s.count++,s.sum+=t;for(var a=0,p=this.buckets;a<p.length;a++)if(t<=(c=p[a])){var S=(n=s.buckets.get(c))!==null&&n!==void 0?n:0;s.buckets.set(c,S+1)}}},o.prototype.collect=function(){var t=Array.from(this.values.entries()).map((function(e){var n=e[0],r=e[1];return{labels:rt(n),count:r.count,sum:r.sum,buckets:Array.from(r.buckets.entries()).map((function(s){var i=s[0];return{le:i===1/0?"+Inf":i,count:s[1]}}))}}));return this.values.clear(),t.length===0&&t.push({labels:{},count:0,sum:0,buckets:this.buckets.map((function(e){return{le:e===1/0?"+Inf":e,count:0}}))}),{name:this.opts.name,help:this.opts.help,type:"histogram",samples:t}},o})(),St=(function(){function o(){this.counters=new Map,this.histograms=new Map}return o.prototype.getCounter=function(t){return this.counters.get(t)},o.prototype.getHistogram=function(t){return this.histograms.get(t)},o.prototype.counter=function(t){var e=t.name,n=this.counters.get(e);return n||(n=new xt(t),this.counters.set(e,n)),n},o.prototype.histogram=function(t){var e=t.name,n=this.histograms.get(e);return n||(n=new Tt(t),this.histograms.set(e,n)),n},o.prototype.collect=function(){var t=Array.from(this.counters.values()).map((function(r){return r.collect()})),e=Array.from(this.histograms.values()).map((function(r){return r.collect()})),n=L(L([],t,!0),e,!0).filter((function(r){return r.samples.length>0}));return n.length>0?n:[]},o.prototype.restore=function(t){for(var e=function(i){switch(i.type){case"counter":for(var u=n.counter({name:i.name,help:i.help}),l=0,c=i.samples;l<c.length;l++){var a=c[l];bt(a)&&u.inc(a.value,a.labels)}break;case"histogram":var p=i.samples.find(nt);if(p){var S=p.buckets.map((function(T){return T.le==="+Inf"?1/0:T.le})),E=n.histogram({name:i.name,help:i.help,buckets:S});i.samples.filter(nt).forEach((function(T){E.restore(T)}))}}},n=this,r=0,s=t;r<s.length;r++)e(s[r])},o})(),x={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression",SENT:"sent",RECOVERED:"recovered",WARN:"warn"},Et=(function(o){function t(e,n,r){var s=o.call(this)||this;return s.metricRegistry=e,s.appName=n,s.environment=r,s}return z(t,o),t.prototype.defineCounter=function(e,n){e&&n?this.metricRegistry.counter({name:e,help:n,labelNames:["featureName","appName","environment"]}):this.emit(x.WARN,"Counter name or help cannot be empty: ".concat(e,", ").concat(n,"."))},t.prototype.defineHistogram=function(e,n,r){e&&n?this.metricRegistry.histogram({name:e,help:n,labelNames:["featureName","appName","environment"],buckets:r}):this.emit(x.WARN,"Histogram name or help cannot be empty: ".concat(e,", ").concat(n,"."))},t.prototype.incrementCounter=function(e,n){var r=this.metricRegistry.getCounter(e);if(r){var s={appName:this.appName,environment:this.environment};r.inc(n,s)}else this.emit(x.WARN,"Counter ".concat(e," not defined, this counter will not be incremented."))},t.prototype.observeHistogram=function(e,n){var r=this.metricRegistry.getHistogram(e);if(r){var s={appName:this.appName,environment:this.environment};r.observe(n,s)}else this.emit(x.WARN,"Histogram ".concat(e," not defined, this histogram will not be updated."))},t})($.TinyEmitter),wt=["userId","sessionId","remoteAddress","currentTime"],ot=function(o){return wt.includes(o)},Rt="isEnabled",It="getVariant",kt={name:"disabled",enabled:!1,feature_enabled:!1},Y="repo",st="repoLastUpdateTimestamp",Ot=function(){try{if(typeof window<"u"&&"fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(o){console.error('Unleash failed to resolve "fetch"',o)}},it=(function(o){function t(e){var n,r=e.storageProvider,s=e.url,i=e.clientKey,u=e.disableRefresh,l=u!==void 0&&u,c=e.refreshInterval,a=c===void 0?30:c,p=e.metricsInterval,S=p===void 0?30:p,E=e.metricsIntervalInitial,T=E===void 0?2:E,R=e.disableMetrics,k=R!==void 0&&R,w=e.appName,O=e.environment,U=O===void 0?"default":O,A=e.context,j=e.fetch,P=j===void 0?Ot():j,H=e.createAbortController,m=H===void 0?(function(){try{if(typeof window<"u"&&"AbortController"in window)return function(){return new window.AbortController};if("fetch"in globalThis)return function(){return new globalThis.AbortController}}catch(M){console.error('Unleash failed to resolve "AbortController" factory',M)}})():H,v=e.bootstrap,C=e.bootstrapOverride,_=C===void 0||C,ct=e.headerName,lt=ct===void 0?"Authorization":ct,ht=e.customHeaders,ft=ht===void 0?{}:ht,pt=e.impressionDataAll,jt=pt!==void 0&&pt,dt=e.usePOSTrequests,Ht=dt!==void 0&&dt,N=e.experimental,h=o.call(this)||this;if(h.toggles=[],h.etag="",h.readyEventEmitted=!1,h.fetchedFromServer=!1,h.usePOSTrequests=!1,h.started=!1,h.stopCount=0,!s)throw new Error("url is required");if(!i)throw new Error("clientKey is required");if(!w)throw new Error("appName is required.");h.eventsHandler=new yt,h.impressionDataAll=jt,h.toggles=v&&v.length>0?v:[],h.url=s instanceof URL?s:new URL(s),h.clientKey=i,h.headerName=lt,h.customHeaders=ft,h.storage=r||(typeof window<"u"?new V:new Z),h.refreshInterval=l?0:1e3*a,h.context=d({appName:w,environment:U},A),h.usePOSTrequests=Ht,h.sdkState="initializing";var D=N==null?void 0:N.metricsUrl;!D||D instanceof URL||(D=new URL(D)),h.experimental=d(d({},N),{metricsUrl:D}),N!=null&&N.togglesStorageTTL&&(N==null?void 0:N.togglesStorageTTL)>0&&(h.experimental.togglesStorageTTL=1e3*N.togglesStorageTTL),h.lastRefreshTimestamp=0,h.ready=new Promise((function(M){h.init().then(M).catch((function(W){console.error(W),h.sdkState="error",h.emit(x.ERROR,W),h.lastError=W,M()}))})),P||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),m||console.error('Unleash: You must either provide your own "AbortController" implementation or run in an environment where "AbortController" is available.'),h.fetch=P,h.createAbortController=m,h.bootstrap=v&&v.length>0?v:void 0,h.bootstrapOverride=_,h.connectionId=tt(),h.metricRegistry=new St;var Dt=h.resolveEnvironment(i,U);return h.impactMetrics=new Et(h.metricRegistry,w,Dt),h.metrics=new gt({onError:function(M){return h.emit(x.ERROR,{type:"metrics",error:M})},onSent:h.emit.bind(h,x.SENT),appName:w,metricsInterval:S,disableMetrics:k,url:((n=h.experimental)===null||n===void 0?void 0:n.metricsUrl)||h.url,clientKey:i,fetch:P,headerName:lt,customHeaders:ft,metricsIntervalInitial:T,connectionId:h.connectionId,metricRegistry:h.metricRegistry}),h}return z(t,o),t.prototype.getAllToggles=function(){return L([],this.toggles,!0)},t.prototype.isEnabled=function(e){var n,r=this.toggles.find((function(u){return u.name===e})),s=!!r&&r.enabled;if(this.metrics.count(e,s),(r==null?void 0:r.impressionData)||this.impressionDataAll){var i=this.eventsHandler.createImpressionEvent(this.context,s,e,Rt,(n=r==null?void 0:r.impressionData)!==null&&n!==void 0?n:void 0);this.emit(x.IMPRESSION,i)}return s},t.prototype.getVariant=function(e){var n,r=this.toggles.find((function(l){return l.name===e})),s=(r==null?void 0:r.enabled)||!1,i=r?r.variant:kt;if(i.name&&this.metrics.countVariant(e,i.name),this.metrics.count(e,s),(r==null?void 0:r.impressionData)||this.impressionDataAll){var u=this.eventsHandler.createImpressionEvent(this.context,s,e,It,(n=r==null?void 0:r.impressionData)!==null&&n!==void 0?n:void 0,i.name);this.emit(x.IMPRESSION,u)}return d(d({},i),{feature_enabled:s})},t.prototype.updateToggles=function(){return y(this,void 0,void 0,(function(){var e=this;return b(this,(function(n){switch(n.label){case 0:return this.timerRef||this.fetchedFromServer?[4,this.fetchToggles()]:[3,2];case 1:return n.sent(),[3,4];case 2:return this.started?[4,new Promise((function(r){var s=function(){e.fetchToggles().then((function(){e.off(x.READY,s),r()}))};e.once(x.READY,s)}))]:[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},t.prototype.updateContext=function(e){return y(this,void 0,void 0,(function(){var n;return b(this,(function(r){switch(r.label){case 0:return n={environment:this.context.environment,appName:this.context.appName,sessionId:this.context.sessionId},this.context=d(d({},n),e),[4,this.updateToggles()];case 1:return r.sent(),[2]}}))}))},t.prototype.getContext=function(){return d({},this.context)},t.prototype.setContextField=function(e,n){return y(this,void 0,void 0,(function(){var r,s,i;return b(this,(function(u){switch(u.label){case 0:return ot(e)?this.context=d(d({},this.context),((s={})[e]=n,s)):(r=d(d({},this.context.properties),((i={})[e]=n,i)),this.context=d(d({},this.context),{properties:r})),[4,this.updateToggles()];case 1:return u.sent(),[2]}}))}))},t.prototype.removeContextField=function(e){return y(this,void 0,void 0,(function(){var n;return b(this,(function(r){switch(r.label){case 0:return ot(e)?this.context=d(d({},this.context),((n={})[e]=void 0,n)):typeof this.context.properties=="object"&&delete this.context.properties[e],[4,this.updateToggles()];case 1:return r.sent(),[2]}}))}))},t.prototype.setReady=function(){this.readyEventEmitted=!0,this.emit(x.READY)},t.prototype.init=function(){return y(this,void 0,void 0,(function(){var e,n,r;return b(this,(function(s){switch(s.label){case 0:return[4,this.resolveSessionId()];case 1:return e=s.sent(),this.context=d({sessionId:e},this.context),[4,this.storage.get(Y)];case 2:return n=s.sent()||[],r=this,[4,this.getLastRefreshTimestamp()];case 3:return r.lastRefreshTimestamp=s.sent(),!this.bootstrap||!this.bootstrapOverride&&n.length!==0?[3,6]:[4,this.storage.save(Y,this.bootstrap)];case 4:return s.sent(),this.toggles=this.bootstrap,this.sdkState="healthy",[4,this.storeLastRefreshTimestamp()];case 5:return s.sent(),this.setReady(),[3,7];case 6:this.toggles=n,s.label=7;case 7:return this.sdkState="healthy",this.emit(x.INIT),[2]}}))}))},t.prototype.start=function(){return y(this,void 0,void 0,(function(){var e,n,r=this;return b(this,(function(s){switch(s.label){case 0:return this.started=!0,e=this.stopCount,this.timerRef?(console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again."),[2]):[4,this.ready];case 1:return s.sent(),this.stopCount===e&&this.metrics.start(),n=this.refreshInterval,[4,this.initialFetchToggles()];case 2:return s.sent(),this.stopCount===e&&n>0&&!this.timerRef&&(this.timerRef=setInterval((function(){return r.fetchToggles()}),n)),[2]}}))}))},t.prototype.stop=function(){this.stopCount++,this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},t.prototype.isReady=function(){return this.readyEventEmitted},t.prototype.getError=function(){return this.sdkState==="error"?this.lastError:void 0},t.prototype.sendMetrics=function(){return this.metrics.sendMetrics()},t.prototype.resolveSessionId=function(){return y(this,void 0,void 0,(function(){var e;return b(this,(function(n){switch(n.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[4,this.storage.get("sessionId")];case 1:return(e=n.sent())?[3,3]:(e=Math.floor(1e9*Math.random()),[4,this.storage.save("sessionId",e.toString(10))]);case 2:n.sent(),n.label=3;case 3:return[2,e.toString(10)]}}))}))},t.prototype.getHeaders=function(){return X({clientKey:this.clientKey,connectionId:this.connectionId,appName:this.context.appName,customHeaders:this.customHeaders,headerName:this.headerName,etag:this.etag,isPost:this.usePOSTrequests})},t.prototype.storeToggles=function(e){return y(this,void 0,void 0,(function(){return b(this,(function(n){switch(n.label){case 0:return this.toggles=e,this.emit(x.UPDATE),[4,this.storage.save(Y,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.isTogglesStorageTTLEnabled=function(){var e;return!!(!((e=this.experimental)===null||e===void 0)&&e.togglesStorageTTL&&this.experimental.togglesStorageTTL>0)},t.prototype.isUpToDate=function(){var e;if(!this.isTogglesStorageTTLEnabled())return!1;var n=Date.now(),r=((e=this.experimental)===null||e===void 0?void 0:e.togglesStorageTTL)||0;return this.lastRefreshTimestamp>0&&this.lastRefreshTimestamp<=n&&n-this.lastRefreshTimestamp<=r},t.prototype.getLastRefreshTimestamp=function(){return y(this,void 0,void 0,(function(){var e,n;return b(this,(function(r){switch(r.label){case 0:return this.isTogglesStorageTTLEnabled()?[4,this.storage.get(st)]:[3,3];case 1:return e=r.sent(),[4,Q(this.context)];case 2:return n=r.sent(),[2,(e==null?void 0:e.key)===n?e.timestamp:0];case 3:return[2,0]}}))}))},t.prototype.storeLastRefreshTimestamp=function(){return y(this,void 0,void 0,(function(){var e,n;return b(this,(function(r){switch(r.label){case 0:return this.isTogglesStorageTTLEnabled()?(this.lastRefreshTimestamp=Date.now(),n={},[4,Q(this.context)]):[3,3];case 1:return n.key=r.sent(),n.timestamp=this.lastRefreshTimestamp,e=n,[4,this.storage.save(st,e)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.initialFetchToggles=function(){if(!this.isUpToDate())return this.fetchToggles();this.fetchedFromServer||(this.fetchedFromServer=!0,this.setReady())},t.prototype.fetchToggles=function(){return y(this,void 0,void 0,(function(){var e,n,r,s,i,u,l,c,a;return b(this,(function(p){switch(p.label){case 0:if(!this.fetch)return[3,9];this.abortController&&!this.abortController.signal.aborted&&this.abortController.abort(),this.abortController=(a=this.createAbortController)===null||a===void 0?void 0:a.call(this),e=this.abortController?this.abortController.signal:void 0,p.label=1;case 1:return p.trys.push([1,7,8,9]),n=this.usePOSTrequests,r=n?this.url:(function(S,E){var T=new URL(S.toString());return Object.entries(E).filter(K).forEach((function(R){var k=R[0],w=R[1];k==="properties"&&w?Object.entries(w).filter(K).forEach((function(O){var U=O[0],A=O[1];return T.searchParams.append("properties[".concat(U,"]"),A)})):T.searchParams.append(k,w)})),T})(this.url,this.context),s=n?"POST":"GET",i=n?JSON.stringify({context:this.context}):void 0,[4,this.fetch(r.toString(),{method:s,cache:"no-cache",headers:this.getHeaders(),body:i,signal:e})];case 2:return u=p.sent(),this.sdkState==="error"&&u.status<400&&(this.sdkState="healthy",this.emit(x.RECOVERED)),u.ok?(this.etag=u.headers.get("ETag")||"",[4,u.json()]):[3,5];case 3:return l=p.sent(),[4,this.storeToggles(l.toggles)];case 4:return p.sent(),this.sdkState!=="healthy"&&(this.sdkState="healthy"),this.fetchedFromServer||(this.fetchedFromServer=!0,this.setReady()),this.storeLastRefreshTimestamp(),[3,6];case 5:u.status===304?this.storeLastRefreshTimestamp():(console.error("Unleash: Fetching feature toggles did not have an ok response"),this.sdkState="error",this.emit(x.ERROR,{type:"HttpError",code:u.status}),this.lastError={type:"HttpError",code:u.status}),p.label=6;case 6:return[3,9];case 7:return typeof(c=p.sent())=="object"&&c!==null&&"name"in c&&c.name==="AbortError"||(console.error("Unleash: unable to fetch feature toggles",c),this.sdkState="error",this.emit(x.ERROR,{type:"fetch-toggles",error:c}),this.lastError=c),[3,9];case 8:return this.abortController=null,[7];case 9:return[2]}}))}))},t.prototype.resolveEnvironment=function(e,n){return(function(r){var s=r.indexOf(":");if(s!==-1){var i=r.slice(s+1),u=i.lastIndexOf(".");if(u!==-1)return i.slice(0,u)}})(e)||n},t})($.TinyEmitter);const I=Symbol("Context state identifier"),J=Symbol("Context update identifier");function at({config:o,unleashClient:t,startClient:e=!0,stopClient:n=!1}){var O,U,A,j,P,H;const r=f.ref(t??(o?new it(o):void 0)),s=f.ref(!!((O=r.value)!=null&&O.isReady()||!t&&((U=o==null?void 0:o.bootstrap)!=null&&U.length)&&o.bootstrapOverride!==!1)),i=f.ref(((A=r.value)==null?void 0:A.getError())??null);!o&&!t&&console.warn("You must provide either a config or an Unleash client to the flag provider.");const u=()=>{s.value=!0},l=m=>{i.value=m},c=()=>{i.value=null};(j=r.value)==null||j.on("ready",u),(P=r.value)==null||P.on("error",l),(H=r.value)==null||H.on("recovered",c);const a=async m=>{var v;await((v=r.value)==null?void 0:v.updateContext(m))},p=m=>{var v;return(v=r.value)==null?void 0:v.isEnabled(m)},S=m=>{var v;return(v=r.value)==null?void 0:v.getVariant(m)},E=(m,...v)=>{var C;return(C=r.value)==null?void 0:C.on(m,...v)},T=f.reactive({on:E,updateContext:a,isEnabled:p,getVariant:S,client:r,flagsReady:s,flagsError:i}),R=(m,v)=>{T[m]=v},k=()=>{var m;(e||!t)&&((m=r.value)==null||m.start())},w=()=>{var m,v,C,_;(m=r.value)==null||m.off("ready",u),(v=r.value)==null||v.off("error",l),(C=r.value)==null||C.off("recovered",c),n&&((_=r.value)==null||_.stop())};return{context:f.toRefs(T),update:R,start:k,dispose:w}}const ut=f.defineComponent({__name:"FlagProvider",props:{config:{},unleashClient:{},startClient:{type:Boolean,default:!0},stopClient:{type:Boolean,default:!1}},setup(o){const{context:t,start:e,update:n,dispose:r}=at({config:o.config,unleashClient:o.unleashClient,startClient:o.startClient,stopClient:o.stopClient});return f.provide(I,t),f.provide(J,n),f.onMounted(e),f.onUnmounted(r),(s,i)=>f.renderSlot(s.$slots,"default")}}),Ct=o=>{const{isEnabled:t,client:e}=f.inject(I,{}),n=f.ref(!!(t!=null&&t.value(f.toValue(o))));function r(){const i=t==null?void 0:t.value(f.toValue(o));i!==n.value&&(n.value=!!i)}function s(){n.value=!!(t!=null&&t.value(f.toValue(o)))}return e==null||e.value.on("ready",s),e==null||e.value.on("update",r),f.watch(()=>f.toValue(o),r),f.onUnmounted(()=>{e==null||e.value.off("ready",s),e==null||e.value.off("update",r)}),n},Nt=()=>{const{flagsReady:o,flagsError:t}=f.inject(I,{});return{flagsReady:o,flagsError:t}},Ut=(o,t)=>{var n,r,s,i;return!((o==null?void 0:o.name)===(t==null?void 0:t.name)&&(o==null?void 0:o.enabled)===(t==null?void 0:t.enabled)&&(o==null?void 0:o.feature_enabled)===(t==null?void 0:t.feature_enabled)&&((n=o==null?void 0:o.payload)==null?void 0:n.type)===((r=t==null?void 0:t.payload)==null?void 0:r.type)&&((s=o==null?void 0:o.payload)==null?void 0:s.value)===((i=t==null?void 0:t.payload)==null?void 0:i.value))},At=o=>{const{getVariant:t,client:e}=f.inject(I,{}),n=f.ref(t==null?void 0:t.value(f.toValue(o)));function r(){const i=t==null?void 0:t.value(f.toValue(o));Ut(n==null?void 0:n.value,i)&&(n.value=i)}function s(){n.value=t==null?void 0:t.value(f.toValue(o))}return e==null||e.value.on("ready",s),e==null||e.value.on("update",r),f.watch(()=>f.toValue(o),r),f.onUnmounted(()=>{e==null||e.value.off("ready",s),e==null||e.value.off("update",r)}),n||{}},Pt=()=>{const{updateContext:o}=f.inject(I,{});return o==null?void 0:o.value},Mt=()=>{const{client:o}=f.inject(I,{});return o==null?void 0:o.value},Lt={install(o,t){const{context:e,update:n,start:r,dispose:s}=at(t);o.provide(I,e),o.provide(J,n),o.onUnmount(s),r()}};g.ContextStateSymbol=I,g.ContextUpdateSymbol=J,g.FlagProvider=ut,g.InMemoryStorageProvider=Z,g.LocalStorageProvider=V,g.UnleashClient=it,g.default=ut,g.plugin=Lt,g.useFlag=Ct,g.useFlagsStatus=Nt,g.useUnleashClient=Mt,g.useUnleashContext=Pt,g.useVariant=At,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/plugin.d.ts
CHANGED
package/dist/useFlag.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
declare const useFlag: (name: string) => Ref<boolean, boolean>;
|
|
1
|
+
import { type Ref, type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
declare const useFlag: (name: MaybeRefOrGetter<string>) => Ref<boolean, boolean>;
|
|
3
3
|
export default useFlag;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { UnleashClient, IConfig, IMutableContext } from 'unleash-proxy-client';
|
|
1
|
+
import { UnleashClient, type IConfig, type IMutableContext } from 'unleash-proxy-client';
|
|
2
2
|
export interface IProvideOptions {
|
|
3
3
|
config?: IConfig;
|
|
4
4
|
unleashClient?: UnleashClient;
|
|
5
5
|
startClient?: boolean;
|
|
6
|
+
stopClient?: boolean;
|
|
6
7
|
}
|
|
7
|
-
declare function useUnleashProvide({ config, unleashClient, startClient }: IProvideOptions): {
|
|
8
|
+
declare function useUnleashProvide({ config, unleashClient, startClient, stopClient }: IProvideOptions): {
|
|
8
9
|
context: import("vue").ToRefs<{
|
|
9
10
|
on: (event: string, args_0: Function, args_1: any) => UnleashClient | undefined;
|
|
10
11
|
updateContext: (context: IMutableContext) => Promise<void>;
|
|
@@ -50,9 +51,10 @@ declare function useUnleashProvide({ config, unleashClient, startClient }: IProv
|
|
|
50
51
|
off: (event: string, callback?: Function) => UnleashClient;
|
|
51
52
|
} | undefined;
|
|
52
53
|
flagsReady: boolean;
|
|
53
|
-
flagsError:
|
|
54
|
+
flagsError: unknown;
|
|
54
55
|
}>;
|
|
55
56
|
update: (property: string, value: any) => void;
|
|
56
57
|
start: () => void;
|
|
58
|
+
dispose: () => void;
|
|
57
59
|
};
|
|
58
60
|
export default useUnleashProvide;
|
package/dist/useVariant.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IVariant } from 'unleash-proxy-client';
|
|
2
|
-
import { Ref } from 'vue';
|
|
3
|
-
declare const useVariant: (name: string) => Ref<{
|
|
1
|
+
import type { IVariant } from 'unleash-proxy-client';
|
|
2
|
+
import { type Ref, type MaybeRefOrGetter } from 'vue';
|
|
3
|
+
declare const useVariant: (name: MaybeRefOrGetter<string>) => Ref<{
|
|
4
4
|
name: string;
|
|
5
5
|
enabled: boolean;
|
|
6
6
|
feature_enabled?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unleash/proxy-client-vue",
|
|
3
|
-
"version": "1.0.0",
|
|
3
|
+
"version": "1.1.0-beta.0",
|
|
4
4
|
"description": "Vue interface for working with Unleash",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -28,21 +28,27 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "vite",
|
|
31
|
-
"build": "vite build && vue-tsc --emitDeclarationOnly",
|
|
31
|
+
"build": "vite build && vue-tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
32
|
+
"check": "vue-tsc --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:package": "pnpm build && node scripts/test-package.mjs",
|
|
32
35
|
"prepare": "npm run build",
|
|
33
36
|
"preview": "vite preview"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"unleash-proxy-client": "^3.8.
|
|
39
|
+
"unleash-proxy-client": "^3.8.3"
|
|
37
40
|
},
|
|
41
|
+
"packageManager": "pnpm@12.23.0",
|
|
38
42
|
"peerDependencies": {
|
|
39
43
|
"vue": "^3.5.46"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "^22.0.0",
|
|
43
47
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
48
|
+
"happy-dom": "^21.0.4",
|
|
44
49
|
"typescript": "^5.9.3",
|
|
45
50
|
"vite": "^6.4.5",
|
|
51
|
+
"vitest": "^5.1.1",
|
|
46
52
|
"vue": "^3.5.46",
|
|
47
53
|
"vue-tsc": "^3.3.14"
|
|
48
54
|
}
|