@equinor/cpl-feature-flag-react 2.0.0 → 2.0.2

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.
Files changed (3) hide show
  1. package/dist/index.js +10 -25
  2. package/dist/index.mjs +10 -28
  3. package/package.json +22 -15
package/dist/index.js CHANGED
@@ -1,27 +1,10 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
6
  var __getProtoOf = Object.getPrototypeOf;
10
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
8
  var __export = (target, all) => {
26
9
  for (var name in all)
27
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -97,7 +80,7 @@ function getFeatureFlagConfigFromSessionStorage(storage, storageKey) {
97
80
  result[featureFlagKey] = value;
98
81
  }
99
82
  return result;
100
- } catch (e) {
83
+ } catch {
101
84
  removeStorageItemSafe(storage, storageKey);
102
85
  return void 0;
103
86
  }
@@ -107,7 +90,7 @@ function setFeatureFlagValueInSessionStorage(storage, storageKey, featureFlagKey
107
90
  return;
108
91
  }
109
92
  const featueFlagConfig = getFeatureFlagConfigFromSessionStorage(storage, storageKey);
110
- storage.setItem(storageKey, JSON.stringify(__spreadProps(__spreadValues({}, featueFlagConfig), { [featureFlagKey]: value })));
93
+ storage.setItem(storageKey, JSON.stringify({ ...featueFlagConfig, [featureFlagKey]: value }));
111
94
  }
112
95
 
113
96
  // src/buildFeatureFlagContext.tsx
@@ -115,8 +98,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
115
98
  function buildFeatureFlagContext(storage, sessionStorageKey, config) {
116
99
  const FeatureFlagContext = (0, import_react.createContext)(config);
117
100
  const useFeatureFlagConfig = () => (0, import_react.useContext)(FeatureFlagContext);
118
- const FeatureFlagDispatchContext = (0, import_react.createContext)(() => {
119
- });
101
+ const FeatureFlagDispatchContext = (0, import_react.createContext)((() => {
102
+ }));
120
103
  const useFeatureFlagDispatch = () => (0, import_react.useContext)(FeatureFlagDispatchContext);
121
104
  const reducer = buildReducer(storage, sessionStorageKey);
122
105
  const FeatureFlagProvider = ({ children }) => {
@@ -139,11 +122,13 @@ function buildReducer(storage, storageKey) {
139
122
  action.featureFlagKey,
140
123
  action.value
141
124
  );
142
- return __spreadProps(__spreadValues({}, state), {
143
- [action.featureFlagKey]: __spreadProps(__spreadValues({}, state[action.featureFlagKey]), {
125
+ return {
126
+ ...state,
127
+ [action.featureFlagKey]: {
128
+ ...state[action.featureFlagKey],
144
129
  [action.env]: action.value
145
- })
146
- });
130
+ }
131
+ };
147
132
  }
148
133
  default: {
149
134
  return state;
package/dist/index.mjs CHANGED
@@ -1,23 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
-
21
1
  // src/buildFeatureFlagContext.tsx
22
2
  import { createContext, useContext, useReducer } from "react";
23
3
 
@@ -64,7 +44,7 @@ function getFeatureFlagConfigFromSessionStorage(storage, storageKey) {
64
44
  result[featureFlagKey] = value;
65
45
  }
66
46
  return result;
67
- } catch (e) {
47
+ } catch {
68
48
  removeStorageItemSafe(storage, storageKey);
69
49
  return void 0;
70
50
  }
@@ -74,7 +54,7 @@ function setFeatureFlagValueInSessionStorage(storage, storageKey, featureFlagKey
74
54
  return;
75
55
  }
76
56
  const featueFlagConfig = getFeatureFlagConfigFromSessionStorage(storage, storageKey);
77
- storage.setItem(storageKey, JSON.stringify(__spreadProps(__spreadValues({}, featueFlagConfig), { [featureFlagKey]: value })));
57
+ storage.setItem(storageKey, JSON.stringify({ ...featueFlagConfig, [featureFlagKey]: value }));
78
58
  }
79
59
 
80
60
  // src/buildFeatureFlagContext.tsx
@@ -82,8 +62,8 @@ import { jsx } from "react/jsx-runtime";
82
62
  function buildFeatureFlagContext(storage, sessionStorageKey, config) {
83
63
  const FeatureFlagContext = createContext(config);
84
64
  const useFeatureFlagConfig = () => useContext(FeatureFlagContext);
85
- const FeatureFlagDispatchContext = createContext(() => {
86
- });
65
+ const FeatureFlagDispatchContext = createContext((() => {
66
+ }));
87
67
  const useFeatureFlagDispatch = () => useContext(FeatureFlagDispatchContext);
88
68
  const reducer = buildReducer(storage, sessionStorageKey);
89
69
  const FeatureFlagProvider = ({ children }) => {
@@ -106,11 +86,13 @@ function buildReducer(storage, storageKey) {
106
86
  action.featureFlagKey,
107
87
  action.value
108
88
  );
109
- return __spreadProps(__spreadValues({}, state), {
110
- [action.featureFlagKey]: __spreadProps(__spreadValues({}, state[action.featureFlagKey]), {
89
+ return {
90
+ ...state,
91
+ [action.featureFlagKey]: {
92
+ ...state[action.featureFlagKey],
111
93
  [action.env]: action.value
112
- })
113
- });
94
+ }
95
+ };
114
96
  }
115
97
  default: {
116
98
  return state;
package/package.json CHANGED
@@ -1,26 +1,33 @@
1
1
  {
2
2
  "name": "@equinor/cpl-feature-flag-react",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
8
15
  "files": [
9
16
  "dist/**"
10
17
  ],
11
18
  "devDependencies": {
12
- "@equinor/eds-core-react": "^2.2.0",
13
- "@storybook/react": "^9.1.1",
14
- "@types/react": "^18.3.18",
15
- "@types/react-dom": "^18.3.5",
16
- "@types/styled-components": "^5.1.34",
17
- "eslint": "^9.21.0",
18
- "react": "^18.2.0",
19
- "react-dom": "^18.2.0",
20
- "styled-components": "^6.1.14",
21
- "tsup": "^8.3.6",
22
- "@equinor/cpl-eslint-config": "1.0.0",
23
- "@equinor/cpl-typescript-config": "0.0.2"
19
+ "@equinor/eds-core-react": "2.3.4",
20
+ "@storybook/react-vite": "10.2.8",
21
+ "@types/react": "19.2.13",
22
+ "@types/react-dom": "19.2.3",
23
+ "@types/styled-components": "5.1.36",
24
+ "eslint": "10.0.0",
25
+ "react": "19.2.4",
26
+ "react-dom": "19.2.4",
27
+ "styled-components": "6.3.9",
28
+ "tsup": "8.5.1",
29
+ "@equinor/cpl-eslint-config": "1.0.1",
30
+ "@equinor/cpl-typescript-config": "0.0.3"
24
31
  },
25
32
  "peerDependencies": {
26
33
  "@equinor/eds-core-react": ">=2.2.0",
@@ -32,8 +39,8 @@
32
39
  "access": "public"
33
40
  },
34
41
  "dependencies": {
35
- "@equinor/eds-icons": "^0.21.0",
36
- "@equinor/eds-tokens": "^0.9.2"
42
+ "@equinor/eds-icons": "1.2.1",
43
+ "@equinor/eds-tokens": "2.1.1"
37
44
  },
38
45
  "scripts": {
39
46
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",