@ops-ai/vue-feature-flags-toggly 1.0.4 → 1.0.5
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
CHANGED
|
@@ -47,16 +47,6 @@ app.use(toggly, {
|
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Or you can use the *$toggly* service to set/clear the identity at a later time.
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
this.$toggly.setIdentity('unique-user-identifier')
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```js
|
|
57
|
-
this.$toggly.clearIdentity()
|
|
58
|
-
```
|
|
59
|
-
|
|
60
50
|
Now you can start using the Feature component anywhere in your application.
|
|
61
51
|
|
|
62
52
|
```html
|
|
@@ -38,8 +38,6 @@ export declare class Toggly implements TogglyService {
|
|
|
38
38
|
evaluateFeatureGate: (featureKeys: string[], requirement?: string, negate?: boolean) => Promise<boolean>;
|
|
39
39
|
isFeatureOn: (featureKey: string) => Promise<boolean>;
|
|
40
40
|
isFeatureOff: (featureKey: string) => Promise<boolean>;
|
|
41
|
-
setIdentity: (identity: string) => void;
|
|
42
|
-
clearIdentity: () => void;
|
|
43
41
|
}
|
|
44
42
|
declare const toggly: Toggly;
|
|
45
43
|
export default toggly;
|
|
@@ -16,10 +16,10 @@ class f {
|
|
|
16
16
|
), this._config = Object.assign({}, this._config, e), this.shouldShowFeatureDuringEvaluation = this._config.showFeatureDuringEvaluation, this);
|
|
17
17
|
_loadFeatures = async () => {
|
|
18
18
|
if (this._loadingFeatures && await new Promise((a) => {
|
|
19
|
-
const
|
|
20
|
-
this._loadingFeatures ? setTimeout(
|
|
19
|
+
const i = () => {
|
|
20
|
+
this._loadingFeatures ? setTimeout(i, 100) : a();
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
i();
|
|
23
23
|
}), this._features !== null)
|
|
24
24
|
return this._features;
|
|
25
25
|
this._loadingFeatures = !0;
|
|
@@ -38,23 +38,17 @@ class f {
|
|
|
38
38
|
return this._features;
|
|
39
39
|
};
|
|
40
40
|
_featuresLoaded = async () => this._features ?? await this._loadFeatures();
|
|
41
|
-
_evaluateFeatureGate = async (e, a = "all",
|
|
41
|
+
_evaluateFeatureGate = async (e, a = "all", i = !1) => {
|
|
42
42
|
if (await this._featuresLoaded(), !this._features || Object.keys(this._features).length === 0)
|
|
43
43
|
return !0;
|
|
44
|
-
var
|
|
45
|
-
return a === "any" ?
|
|
44
|
+
var s;
|
|
45
|
+
return a === "any" ? s = e.reduce((n, r) => n || this._features[r] && this._features[r] === !0, !1) : s = e.reduce((n, r) => n && this._features[r] && this._features[r] === !0, !0), s = i ? !s : s, s;
|
|
46
46
|
};
|
|
47
|
-
evaluateFeatureGate = async (e, a = "all",
|
|
47
|
+
evaluateFeatureGate = async (e, a = "all", i = !1) => await this._evaluateFeatureGate(e, a, i);
|
|
48
48
|
isFeatureOn = async (e) => await this._evaluateFeatureGate([e]);
|
|
49
49
|
isFeatureOff = async (e) => await this._evaluateFeatureGate([e], "all", !0);
|
|
50
|
-
setIdentity = (e) => {
|
|
51
|
-
this._features = null, this._config.identity = e;
|
|
52
|
-
};
|
|
53
|
-
clearIdentity = () => {
|
|
54
|
-
this._features = null, this._config.identity = void 0;
|
|
55
|
-
};
|
|
56
50
|
}
|
|
57
|
-
const
|
|
51
|
+
const g = new f(), c = {
|
|
58
52
|
inject: ["$toggly"],
|
|
59
53
|
props: {
|
|
60
54
|
featureKey: {
|
|
@@ -90,19 +84,19 @@ const c = new f(), g = {
|
|
|
90
84
|
}
|
|
91
85
|
}, d = (t, e) => {
|
|
92
86
|
const a = t.__vccOpts || t;
|
|
93
|
-
for (const [
|
|
94
|
-
a[
|
|
87
|
+
for (const [i, s] of e)
|
|
88
|
+
a[i] = s;
|
|
95
89
|
return a;
|
|
96
90
|
}, _ = { key: 0 };
|
|
97
|
-
function y(t, e, a,
|
|
98
|
-
return
|
|
91
|
+
function y(t, e, a, i, s, n) {
|
|
92
|
+
return s.shouldShow ? (o(), u("div", _, [
|
|
99
93
|
l(t.$slots, "default")
|
|
100
94
|
])) : h("", !0);
|
|
101
95
|
}
|
|
102
|
-
const
|
|
96
|
+
const w = /* @__PURE__ */ d(c, [["render", y]]), p = {
|
|
103
97
|
install: (t, e) => {
|
|
104
|
-
const a =
|
|
105
|
-
t.provide("$toggly", a), t.component("Feature",
|
|
98
|
+
const a = g.init(e);
|
|
99
|
+
t.provide("$toggly", a), t.component("Feature", w);
|
|
106
100
|
}
|
|
107
101
|
};
|
|
108
102
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.VueFeatureFlagsToggly={},r.Vue))})(this,function(r,n){"use strict";class l{_config={baseURI:"https://client.toggly.io",showFeatureDuringEvaluation:!1};_features=null;_loadingFeatures=!1;shouldShowFeatureDuringEvaluation=!1;init=e=>(e.appKey?e.environment||(e.environment="Production",console.warn("Toggly --- Using Production environment as no environment provided when initializing the Toggly")):e.featureDefaults?(this._features=e.featureDefaults??{},console.warn("Toggly --- Using feature defaults as no application key provided when initializing the Toggly")):console.warn("Toggly --- A valid application key is required to connect to your Toggly.io application for evaluating your features."),this._config=Object.assign({},this._config,e),this.shouldShowFeatureDuringEvaluation=this._config.showFeatureDuringEvaluation,this);_loadFeatures=async()=>{if(this._loadingFeatures&&await new Promise(a=>{const s=()=>{this._loadingFeatures?setTimeout(s,100):a()};s()}),this._features!==null)return this._features;this._loadingFeatures=!0;try{var e=`${this._config.baseURI}/${this._config.appKey}-${this._config.environment}/defs`;this._config.identity&&(e+=`?u=${this._config.identity}`);const a=await fetch(e);this._features=await a.json()}catch{this._features=this._config.featureDefaults??{},console.warn("Toggly --- Using feature defaults as features could not be loaded from the Toggly API")}finally{this._loadingFeatures=!1}return this._features};_featuresLoaded=async()=>this._features??await this._loadFeatures();_evaluateFeatureGate=async(e,a="all",s=!1)=>{if(await this._featuresLoaded(),!this._features||Object.keys(this._features).length===0)return!0;var i;return a==="any"?i=e.reduce((u,o)=>u||this._features[o]&&this._features[o]===!0,!1):i=e.reduce((u,o)=>u&&this._features[o]&&this._features[o]===!0,!0),i=s?!i:i,i};evaluateFeatureGate=async(e,a="all",s=!1)=>await this._evaluateFeatureGate(e,a,s);isFeatureOn=async e=>await this._evaluateFeatureGate([e]);isFeatureOff=async e=>await this._evaluateFeatureGate([e],"all",!0)
|
|
1
|
+
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.VueFeatureFlagsToggly={},r.Vue))})(this,function(r,n){"use strict";class l{_config={baseURI:"https://client.toggly.io",showFeatureDuringEvaluation:!1};_features=null;_loadingFeatures=!1;shouldShowFeatureDuringEvaluation=!1;init=e=>(e.appKey?e.environment||(e.environment="Production",console.warn("Toggly --- Using Production environment as no environment provided when initializing the Toggly")):e.featureDefaults?(this._features=e.featureDefaults??{},console.warn("Toggly --- Using feature defaults as no application key provided when initializing the Toggly")):console.warn("Toggly --- A valid application key is required to connect to your Toggly.io application for evaluating your features."),this._config=Object.assign({},this._config,e),this.shouldShowFeatureDuringEvaluation=this._config.showFeatureDuringEvaluation,this);_loadFeatures=async()=>{if(this._loadingFeatures&&await new Promise(a=>{const s=()=>{this._loadingFeatures?setTimeout(s,100):a()};s()}),this._features!==null)return this._features;this._loadingFeatures=!0;try{var e=`${this._config.baseURI}/${this._config.appKey}-${this._config.environment}/defs`;this._config.identity&&(e+=`?u=${this._config.identity}`);const a=await fetch(e);this._features=await a.json()}catch{this._features=this._config.featureDefaults??{},console.warn("Toggly --- Using feature defaults as features could not be loaded from the Toggly API")}finally{this._loadingFeatures=!1}return this._features};_featuresLoaded=async()=>this._features??await this._loadFeatures();_evaluateFeatureGate=async(e,a="all",s=!1)=>{if(await this._featuresLoaded(),!this._features||Object.keys(this._features).length===0)return!0;var i;return a==="any"?i=e.reduce((u,o)=>u||this._features[o]&&this._features[o]===!0,!1):i=e.reduce((u,o)=>u&&this._features[o]&&this._features[o]===!0,!0),i=s?!i:i,i};evaluateFeatureGate=async(e,a="all",s=!1)=>await this._evaluateFeatureGate(e,a,s);isFeatureOn=async e=>await this._evaluateFeatureGate([e]);isFeatureOff=async e=>await this._evaluateFeatureGate([e],"all",!0)}const f=new l,h={inject:["$toggly"],props:{featureKey:{type:String},featureKeys:{type:Array},requirement:{type:String,default:"all"},negate:{type:Boolean,default:!1}},data(){return{shouldShow:!1,isLoading:!1}},mounted(){this.checkIfShouldShow()},methods:{async checkIfShouldShow(){this.isLoading=!0,this.shouldShow=this.$toggly.shouldShowFeatureDuringEvaluation;var t=[];this.featureKey&&t.push(this.featureKey),this.featureKeys&&(t=t.concat(this.featureKeys)),this.shouldShow=t.length>0?await this.$toggly.evaluateFeatureGate(t,this.requirement,this.negate):!0,this.isLoading=!1}}},g=(t,e)=>{const a=t.__vccOpts||t;for(const[s,i]of e)a[s]=i;return a},c={key:0};function d(t,e,a,s,i,u){return i.shouldShow?(n.openBlock(),n.createElementBlock("div",c,[n.renderSlot(t.$slots,"default")])):n.createCommentVNode("",!0)}const y=g(h,[["render",d]]),_={install:(t,e)=>{const a=f.init(e);t.provide("$toggly",a),t.component("Feature",y)}};r.toggly=_,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@ops-ai/vue-feature-flags-toggly",
|
|
3
|
-
"version": "1.0.4",
|
|
4
|
-
"description": "Provides feature flags support for Vue.js applications allowing you to enable and disable features easily. Can be used with or without Toggly.io.",
|
|
5
|
-
"type": "module",
|
|
6
2
|
"files": [
|
|
7
3
|
"dist"
|
|
8
4
|
],
|
|
@@ -17,7 +13,7 @@
|
|
|
17
13
|
"types": "./dist/types/index.d.ts",
|
|
18
14
|
"repository": {
|
|
19
15
|
"type": "git",
|
|
20
|
-
"url": "
|
|
16
|
+
"url": "https://github.com/ops-ai/Toggly.FeatureManagement"
|
|
21
17
|
},
|
|
22
18
|
"bugs": {
|
|
23
19
|
"url": "https://github.com/ops-ai/Toggly.FeatureManagement/issues"
|
|
@@ -37,6 +33,10 @@
|
|
|
37
33
|
"preview": "vite preview",
|
|
38
34
|
"test": "exit 0"
|
|
39
35
|
},
|
|
36
|
+
"name": "@ops-ai/vue-feature-flags-toggly",
|
|
37
|
+
"version": "1.0.5",
|
|
38
|
+
"description": "Provides feature flags support for Vue.js applications allowing you to enable and disable features easily. Can be used with or without Toggly.io.",
|
|
39
|
+
"type": "module",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"vue": "^3.2.45"
|
|
42
42
|
},
|