@ttoss/react-feature-flags 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +24 -22
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
2
7
|
|
|
3
8
|
// src/FeatureFlag.tsx
|
|
9
|
+
import * as React3 from "react";
|
|
4
10
|
import { ErrorBoundary } from "react-error-boundary";
|
|
5
11
|
|
|
6
12
|
// src/useFeatureFlag.ts
|
|
@@ -8,12 +14,11 @@ import * as React2 from "react";
|
|
|
8
14
|
|
|
9
15
|
// src/FeatureFlagsProvider.tsx
|
|
10
16
|
import * as React from "react";
|
|
11
|
-
|
|
12
|
-
var FeatureFlagsContext = React.createContext({
|
|
17
|
+
var FeatureFlagsContext = /* @__PURE__ */React.createContext({
|
|
13
18
|
features: [],
|
|
14
|
-
setFeatures: () => {}
|
|
19
|
+
setFeatures: /* @__PURE__ */__name(() => {}, "setFeatures")
|
|
15
20
|
});
|
|
16
|
-
var FeatureFlagsProvider = ({
|
|
21
|
+
var FeatureFlagsProvider = /* @__PURE__ */__name(({
|
|
17
22
|
children,
|
|
18
23
|
loadFeatures
|
|
19
24
|
}) => {
|
|
@@ -23,26 +28,24 @@ var FeatureFlagsProvider = ({
|
|
|
23
28
|
return setFeatures(features2);
|
|
24
29
|
});
|
|
25
30
|
}, [loadFeatures]);
|
|
26
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */React.createElement(FeatureFlagsContext.Provider, {
|
|
27
32
|
value: {
|
|
28
33
|
features,
|
|
29
34
|
setFeatures
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
35
|
+
}
|
|
36
|
+
}, children);
|
|
37
|
+
}, "FeatureFlagsProvider");
|
|
34
38
|
|
|
35
39
|
// src/useFeatureFlag.ts
|
|
36
|
-
var useFeatureFlag = name => {
|
|
40
|
+
var useFeatureFlag = /* @__PURE__ */__name(name => {
|
|
37
41
|
const {
|
|
38
42
|
features
|
|
39
43
|
} = React2.useContext(FeatureFlagsContext);
|
|
40
44
|
return features.includes(name);
|
|
41
|
-
};
|
|
45
|
+
}, "useFeatureFlag");
|
|
42
46
|
|
|
43
47
|
// src/FeatureFlag.tsx
|
|
44
|
-
|
|
45
|
-
var FeatureFlag = ({
|
|
48
|
+
var FeatureFlag = /* @__PURE__ */__name(({
|
|
46
49
|
name,
|
|
47
50
|
children,
|
|
48
51
|
fallback = null,
|
|
@@ -52,20 +55,19 @@ var FeatureFlag = ({
|
|
|
52
55
|
if (!isEnabled) {
|
|
53
56
|
return fallback;
|
|
54
57
|
}
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
fallback: errorFallback
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
58
|
+
return /* @__PURE__ */React3.createElement(ErrorBoundary, {
|
|
59
|
+
fallback: errorFallback
|
|
60
|
+
}, children);
|
|
61
|
+
}, "FeatureFlag");
|
|
60
62
|
|
|
61
63
|
// src/useUpdateFeatures.ts
|
|
62
|
-
import * as
|
|
63
|
-
var useUpdateFeatures = () => {
|
|
64
|
+
import * as React4 from "react";
|
|
65
|
+
var useUpdateFeatures = /* @__PURE__ */__name(() => {
|
|
64
66
|
const {
|
|
65
67
|
setFeatures
|
|
66
|
-
} =
|
|
68
|
+
} = React4.useContext(FeatureFlagsContext);
|
|
67
69
|
return {
|
|
68
70
|
updateFeatures: setFeatures
|
|
69
71
|
};
|
|
70
|
-
};
|
|
72
|
+
}, "useUpdateFeatures");
|
|
71
73
|
export { FeatureFlag, FeatureFlagsProvider, useFeatureFlag, useUpdateFeatures };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-feature-flags",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "React Feature Flags",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"jest": "^30.0.4",
|
|
34
34
|
"react": "^19.1.0",
|
|
35
35
|
"tsup": "^8.5.0",
|
|
36
|
-
"@ttoss/config": "^1.35.
|
|
37
|
-
"@ttoss/test-utils": "^2.1.
|
|
36
|
+
"@ttoss/config": "^1.35.7",
|
|
37
|
+
"@ttoss/test-utils": "^2.1.27"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"feature-flags",
|