@featurevisor/react 0.14.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +84 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.gz +0 -0
  6. package/dist/index.js.map +1 -0
  7. package/jest.config.js +8 -0
  8. package/jest.setup.js +4 -0
  9. package/lib/FeaturevisorContext.d.ts +3 -0
  10. package/lib/FeaturevisorContext.js +3 -0
  11. package/lib/FeaturevisorContext.js.map +1 -0
  12. package/lib/FeaturevisorProvider.d.ts +7 -0
  13. package/lib/FeaturevisorProvider.js +6 -0
  14. package/lib/FeaturevisorProvider.js.map +1 -0
  15. package/lib/activateFeature.d.ts +2 -0
  16. package/lib/activateFeature.js +7 -0
  17. package/lib/activateFeature.js.map +1 -0
  18. package/lib/activateFeature.spec.d.ts +1 -0
  19. package/lib/index.d.ts +7 -0
  20. package/lib/index.js +11 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib/useSdk.d.ts +2 -0
  23. package/lib/useSdk.js +7 -0
  24. package/lib/useSdk.js.map +1 -0
  25. package/lib/useSdk.spec.d.ts +1 -0
  26. package/lib/useStatus.d.ts +4 -0
  27. package/lib/useStatus.js +21 -0
  28. package/lib/useStatus.js.map +1 -0
  29. package/lib/useStatus.spec.d.ts +1 -0
  30. package/lib/useVariable.d.ts +2 -0
  31. package/lib/useVariable.js +7 -0
  32. package/lib/useVariable.js.map +1 -0
  33. package/lib/useVariable.spec.d.ts +1 -0
  34. package/lib/useVariation.d.ts +2 -0
  35. package/lib/useVariation.js +7 -0
  36. package/lib/useVariation.js.map +1 -0
  37. package/lib/useVariation.spec.d.ts +1 -0
  38. package/package.json +55 -0
  39. package/src/FeaturevisorContext.ts +4 -0
  40. package/src/FeaturevisorProvider.tsx +15 -0
  41. package/src/activateFeature.spec.tsx +64 -0
  42. package/src/activateFeature.ts +12 -0
  43. package/src/index.ts +12 -0
  44. package/src/useSdk.spec.tsx +66 -0
  45. package/src/useSdk.ts +10 -0
  46. package/src/useStatus.spec.tsx +64 -0
  47. package/src/useStatus.ts +32 -0
  48. package/src/useVariable.spec.tsx +81 -0
  49. package/src/useVariable.ts +13 -0
  50. package/src/useVariation.spec.tsx +64 -0
  51. package/src/useVariation.ts +12 -0
  52. package/tsconfig.cjs.json +7 -0
  53. package/tsconfig.esm.json +7 -0
  54. package/tsconfig.json +7 -0
  55. package/webpack.config.js +21 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [0.14.0](https://github.com/fahad19/featurevisor/compare/v0.13.1...v0.14.0) (2023-04-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * React integration package ([#56](https://github.com/fahad19/featurevisor/issues/56)) ([d0f6ad8](https://github.com/fahad19/featurevisor/commit/d0f6ad8a7e40fa06a741706a5322c08486e84ea9))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Fahad Heylaal (https://fahad19.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @featurevisor/react
2
+
3
+ React components and hooks for Featurevisor.
4
+
5
+ Visit [https://featurevisor.com](https://featurevisor.com) for more information.
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ $ npm install --save @featurevisor/react
11
+ ```
12
+
13
+ ## API
14
+
15
+ ### FeaturevisorProvider
16
+
17
+ React Provider component for setting SDK instance:
18
+
19
+ ```js
20
+ import React from "react";
21
+ import { createInstance } from "@featurevisor/sdk";
22
+ import { FeaturevisorProvider } from "@featurevisor/react";
23
+
24
+ const sdk = createInstance({
25
+ // ...
26
+ });
27
+
28
+ function Root() {
29
+ return (
30
+ <FeaturevisorProvider sdk={sdk}>
31
+ <App />
32
+ </FeaturevisorProvider>
33
+ );
34
+ }
35
+ ```
36
+
37
+ ### activateFeature
38
+
39
+ > activateFeature(featureName, attributes = {}): VariationValue | undefined
40
+
41
+ Hook for activate feature.
42
+
43
+ ### useSdk
44
+
45
+ > useSdk(): FeaturevisorInstance
46
+
47
+ Hook for getting Featurevisor SDK instance.
48
+
49
+ ### useStatus
50
+
51
+ > useStatus(): { isReady: boolean }
52
+
53
+ Hook for checking if Featurevisor SDK is ready.
54
+
55
+ ```js
56
+ import React from "react";
57
+ import { useStatus } from "@featurevisor/react";
58
+
59
+ function App() {
60
+ const { isReady } = useStatus();
61
+
62
+ if (!isReady) {
63
+ return <div>Loading...</div>;
64
+ }
65
+
66
+ return <div>Ready!</div>;
67
+ }
68
+ ```
69
+
70
+ ### useVariation
71
+
72
+ > useVariation(featureKey, attributes = {}): VariationValue | undefined
73
+
74
+ Hook for getting variation value.
75
+
76
+ ### useVariable
77
+
78
+ > useVariable(featureKey, variableKey, attributes = {}): VariableValue | undefined
79
+
80
+ Hook for getting variable value.
81
+
82
+ ## License
83
+
84
+ MIT © [Fahad Heylaal](https://fahad19.com)
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.FeaturevisorReact=t(require("react")):e.FeaturevisorReact=t(e.React)}(this,(e=>(()=>{"use strict";var t={67:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorContext=void 0;var o=r(359);t.FeaturevisorContext=o.createContext(void 0)},673:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorProvider=void 0;var o=r(359),i=r(67);t.FeaturevisorProvider=function(e){return o.createElement(i.FeaturevisorContext.Provider,{value:e.sdk},e.children)}},289:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.activateFeature=void 0;var o=r(901);t.activateFeature=function(e,t){return void 0===t&&(t={}),(0,o.useSdk)().activate(e,t)}},97:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(67),t),i(r(673),t),i(r(289),t),i(r(901),t),i(r(9),t),i(r(26),t),i(r(613),t)},901:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useSdk=void 0;var o=r(359),i=r(67);t.useSdk=function(){return o.useContext(i.FeaturevisorContext)}},9:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useStatus=void 0;var o=r(359),i=r(901);t.useStatus=function(){var e=(0,i.useSdk)(),t=e.isReady(),r=o.useState(t),u=r[0],a=r[1];return u||o.useEffect((function(){function t(){a(!0)}return e.on("ready",t),function(){e.off("ready",t)}}),[]),{isReady:u}}},26:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useVariable=void 0;var o=r(901);t.useVariable=function(e,t,r){return void 0===r&&(r={}),(0,o.useSdk)().getVariable(e,t,r)}},613:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useVariation=void 0;var o=r(901);t.useVariation=function(e,t){return void 0===t&&(t={}),(0,o.useSdk)().getVariation(e,t)}},359:t=>{t.exports=e}},r={};return function e(o){var i=r[o];if(void 0!==i)return i.exports;var u=r[o]={exports:{}};return t[o].call(u.exports,u,u.exports,e),u.exports}(97)})()));
2
+ //# sourceMappingURL=index.js.map
Binary file
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,UACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,SAAUJ,GACQ,iBAAZC,QACdA,QAA2B,kBAAID,EAAQG,QAAQ,UAE/CJ,EAAwB,kBAAIC,EAAQD,EAAY,MACjD,CATD,CASGO,MAAOC,G,qHCTV,aAGa,EAAAC,oBAAsBC,EAAMC,mBAAgDC,E,+FCHzF,aAGA,QAOA,gCAAqCC,GACnC,OACE,gBAAC,EAAAJ,oBAAoBK,SAAQ,CAACC,MAAOF,EAAMG,KAAMH,EAAMI,SAE3D,C,0FCZA,aAEA,2BACEC,EACAC,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDC,SAASH,EAAYC,EAClC,C,0fCVA,WAGA,YAGA,YACA,YACA,UACA,WACA,W,iFCXA,aAGA,QAEA,oBAGE,OAFYT,EAAMY,WAAW,EAAAb,oBAG/B,C,kFCTA,aAEA,SAMA,uBACE,IAAMO,GAAM,IAAAI,UACNG,EAAgBP,EAAIQ,UAEpB,EAAwBd,EAAMe,SAASF,GAAtCC,EAAO,KAAEE,EAAU,KAE1B,OAAIF,GAIJd,EAAMiB,WAAU,WACd,SAASC,IACPF,GAAW,EACb,CAIA,OAFAV,EAAIa,GAAG,QAASD,GAET,WACLZ,EAAIc,IAAI,QAASF,EACnB,CACF,GAAG,IAbM,CAAEJ,QAAO,EAgBpB,C,qFC7BA,aAEA,uBACEN,EACAa,EACAZ,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDY,YAAYd,EAAYa,EAAaZ,EAClD,C,uFCVA,aAEA,wBACED,EACAC,GAIA,YAJA,IAAAA,IAAAA,EAAA,KAEY,IAAAC,UAEDa,aAAaf,EAAYC,EACtC,C,UCXAhB,EAAOD,QAAUM,C,GCCb0B,EAA2B,CAAC,E,OAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBxB,IAAjByB,EACH,OAAOA,EAAanC,QAGrB,IAAIC,EAAS+B,EAAyBE,GAAY,CAGjDlC,QAAS,CAAC,GAOX,OAHAoC,EAAoBF,GAAUG,KAAKpC,EAAOD,QAASC,EAAQA,EAAOD,QAASiC,GAGpEhC,EAAOD,OACf,CCnB0BiC,CAAoB,G","sources":["webpack://FeaturevisorReact/webpack/universalModuleDefinition","webpack://FeaturevisorReact/./src/FeaturevisorContext.ts","webpack://FeaturevisorReact/./src/FeaturevisorProvider.tsx","webpack://FeaturevisorReact/./src/activateFeature.ts","webpack://FeaturevisorReact/./src/index.ts","webpack://FeaturevisorReact/./src/useSdk.ts","webpack://FeaturevisorReact/./src/useStatus.ts","webpack://FeaturevisorReact/./src/useVariable.ts","webpack://FeaturevisorReact/./src/useVariation.ts","webpack://FeaturevisorReact/external umd {\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\",\"root\":\"React\"}","webpack://FeaturevisorReact/webpack/bootstrap","webpack://FeaturevisorReact/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FeaturevisorReact\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"FeaturevisorReact\"] = factory(root[\"React\"]);\n})(this, (__WEBPACK_EXTERNAL_MODULE__359__) => {\nreturn ","import * as React from \"react\";\nimport { FeaturevisorInstance } from \"@featurevisor/sdk\";\n\nexport const FeaturevisorContext = React.createContext<FeaturevisorInstance | undefined>(undefined);\n","import * as React from \"react\";\nimport { FeaturevisorInstance } from \"@featurevisor/sdk\";\n\nimport { FeaturevisorContext } from \"./FeaturevisorContext\";\n\nexport interface FeaturevisorProviderProps {\n sdk: FeaturevisorInstance;\n children: React.ReactNode;\n}\n\nexport function FeaturevisorProvider(props: FeaturevisorProviderProps) {\n return (\n <FeaturevisorContext.Provider value={props.sdk}>{props.children}</FeaturevisorContext.Provider>\n );\n}\n","import { Attributes, FeatureKey, VariationValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function activateFeature(\n featureKey: FeatureKey,\n attributes: Attributes = {},\n): VariationValue | undefined {\n const sdk = useSdk();\n\n return sdk.activate(featureKey, attributes);\n}\n","// contexts\nexport * from \"./FeaturevisorContext\";\n\n// components\nexport * from \"./FeaturevisorProvider\";\n\n// hooks\nexport * from \"./activateFeature\";\nexport * from \"./useSdk\";\nexport * from \"./useStatus\";\nexport * from \"./useVariable\";\nexport * from \"./useVariation\";\n","import * as React from \"react\";\nimport { FeaturevisorInstance } from \"@featurevisor/sdk\";\n\nimport { FeaturevisorContext } from \"./FeaturevisorContext\";\n\nexport function useSdk(): FeaturevisorInstance {\n const sdk = React.useContext(FeaturevisorContext);\n\n return sdk as FeaturevisorInstance;\n}\n","import * as React from \"react\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport interface Status {\n isReady: boolean;\n}\n\nexport function useStatus(): Status {\n const sdk = useSdk();\n const initialStatus = sdk.isReady();\n\n const [isReady, setIsReady] = React.useState(initialStatus);\n\n if (isReady) {\n return { isReady };\n }\n\n React.useEffect(function () {\n function handleReady() {\n setIsReady(true);\n }\n\n sdk.on(\"ready\", handleReady);\n\n return function () {\n sdk.off(\"ready\", handleReady);\n };\n }, []);\n\n return { isReady };\n}\n","import { Attributes, FeatureKey, VariableKey, VariableValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function useVariable(\n featureKey: FeatureKey,\n variableKey: VariableKey,\n attributes: Attributes = {},\n): VariableValue | undefined {\n const sdk = useSdk();\n\n return sdk.getVariable(featureKey, variableKey, attributes);\n}\n","import { Attributes, FeatureKey, VariationValue } from \"@featurevisor/types\";\n\nimport { useSdk } from \"./useSdk\";\n\nexport function useVariation(\n featureKey: FeatureKey,\n attributes: Attributes = {},\n): VariationValue | undefined {\n const sdk = useSdk();\n\n return sdk.getVariation(featureKey, attributes);\n}\n","module.exports = __WEBPACK_EXTERNAL_MODULE__359__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(97);\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__359__","FeaturevisorContext","React","createContext","undefined","props","Provider","value","sdk","children","featureKey","attributes","useSdk","activate","useContext","initialStatus","isReady","useState","setIsReady","useEffect","handleReady","on","off","variableKey","getVariable","getVariation","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ bail: true,
4
+
5
+ // for react testing library
6
+ testEnvironment: "jsdom",
7
+ setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect", "./jest.setup.js"],
8
+ };
package/jest.setup.js ADDED
@@ -0,0 +1,4 @@
1
+ const { TextEncoder, TextDecoder } = require("util");
2
+
3
+ global.TextEncoder = TextEncoder;
4
+ global.TextDecoder = TextDecoder;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
3
+ export declare const FeaturevisorContext: React.Context<FeaturevisorInstance>;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ export var FeaturevisorContext = React.createContext(undefined);
3
+ //# sourceMappingURL=FeaturevisorContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeaturevisorContext.js","sourceRoot":"","sources":["../src/FeaturevisorContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,IAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAmC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
3
+ export interface FeaturevisorProviderProps {
4
+ sdk: FeaturevisorInstance;
5
+ children: React.ReactNode;
6
+ }
7
+ export declare function FeaturevisorProvider(props: FeaturevisorProviderProps): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorContext } from "./FeaturevisorContext";
3
+ export function FeaturevisorProvider(props) {
4
+ return (React.createElement(FeaturevisorContext.Provider, { value: props.sdk }, props.children));
5
+ }
6
+ //# sourceMappingURL=FeaturevisorProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeaturevisorProvider.js","sourceRoot":"","sources":["../src/FeaturevisorProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,OAAO,CACL,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAG,KAAK,CAAC,QAAQ,CAAgC,CAChG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Attributes, FeatureKey, VariationValue } from "@featurevisor/types";
2
+ export declare function activateFeature(featureKey: FeatureKey, attributes?: Attributes): VariationValue | undefined;
@@ -0,0 +1,7 @@
1
+ import { useSdk } from "./useSdk";
2
+ export function activateFeature(featureKey, attributes) {
3
+ if (attributes === void 0) { attributes = {}; }
4
+ var sdk = useSdk();
5
+ return sdk.activate(featureKey, attributes);
6
+ }
7
+ //# sourceMappingURL=activateFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activateFeature.js","sourceRoot":"","sources":["../src/activateFeature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./FeaturevisorContext";
2
+ export * from "./FeaturevisorProvider";
3
+ export * from "./activateFeature";
4
+ export * from "./useSdk";
5
+ export * from "./useStatus";
6
+ export * from "./useVariable";
7
+ export * from "./useVariation";
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // contexts
2
+ export * from "./FeaturevisorContext";
3
+ // components
4
+ export * from "./FeaturevisorProvider";
5
+ // hooks
6
+ export * from "./activateFeature";
7
+ export * from "./useSdk";
8
+ export * from "./useStatus";
9
+ export * from "./useVariable";
10
+ export * from "./useVariation";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,uBAAuB,CAAC;AAEtC,aAAa;AACb,cAAc,wBAAwB,CAAC;AAEvC,QAAQ;AACR,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
2
+ export declare function useSdk(): FeaturevisorInstance;
package/lib/useSdk.js ADDED
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorContext } from "./FeaturevisorContext";
3
+ export function useSdk() {
4
+ var sdk = React.useContext(FeaturevisorContext);
5
+ return sdk;
6
+ }
7
+ //# sourceMappingURL=useSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSdk.js","sourceRoot":"","sources":["../src/useSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,UAAU,MAAM;IACpB,IAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAElD,OAAO,GAA2B,CAAC;AACrC,CAAC"}
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,4 @@
1
+ export interface Status {
2
+ isReady: boolean;
3
+ }
4
+ export declare function useStatus(): Status;
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import { useSdk } from "./useSdk";
3
+ export function useStatus() {
4
+ var sdk = useSdk();
5
+ var initialStatus = sdk.isReady();
6
+ var _a = React.useState(initialStatus), isReady = _a[0], setIsReady = _a[1];
7
+ if (isReady) {
8
+ return { isReady: isReady };
9
+ }
10
+ React.useEffect(function () {
11
+ function handleReady() {
12
+ setIsReady(true);
13
+ }
14
+ sdk.on("ready", handleReady);
15
+ return function () {
16
+ sdk.off("ready", handleReady);
17
+ };
18
+ }, []);
19
+ return { isReady: isReady };
20
+ }
21
+ //# sourceMappingURL=useStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStatus.js","sourceRoot":"","sources":["../src/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC,MAAM,UAAU,SAAS;IACvB,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,IAAM,aAAa,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAE9B,IAAA,KAAwB,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAApD,OAAO,QAAA,EAAE,UAAU,QAAiC,CAAC;IAE5D,IAAI,OAAO,EAAE;QACX,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;KACpB;IAED,KAAK,CAAC,SAAS,CAAC;QACd,SAAS,WAAW;YAClB,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAE7B,OAAO;YACL,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,OAAO,SAAA,EAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,2 @@
1
+ import { Attributes, FeatureKey, VariableKey, VariableValue } from "@featurevisor/types";
2
+ export declare function useVariable(featureKey: FeatureKey, variableKey: VariableKey, attributes?: Attributes): VariableValue | undefined;
@@ -0,0 +1,7 @@
1
+ import { useSdk } from "./useSdk";
2
+ export function useVariable(featureKey, variableKey, attributes) {
3
+ if (attributes === void 0) { attributes = {}; }
4
+ var sdk = useSdk();
5
+ return sdk.getVariable(featureKey, variableKey, attributes);
6
+ }
7
+ //# sourceMappingURL=useVariable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariable.js","sourceRoot":"","sources":["../src/useVariable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,WAAW,CACzB,UAAsB,EACtB,WAAwB,EACxB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,2 @@
1
+ import { Attributes, FeatureKey, VariationValue } from "@featurevisor/types";
2
+ export declare function useVariation(featureKey: FeatureKey, attributes?: Attributes): VariationValue | undefined;
@@ -0,0 +1,7 @@
1
+ import { useSdk } from "./useSdk";
2
+ export function useVariation(featureKey, attributes) {
3
+ if (attributes === void 0) { attributes = {}; }
4
+ var sdk = useSdk();
5
+ return sdk.getVariation(featureKey, attributes);
6
+ }
7
+ //# sourceMappingURL=useVariation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariation.js","sourceRoot":"","sources":["../src/useVariation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,YAAY,CAC1B,UAAsB,EACtB,UAA2B;IAA3B,2BAAA,EAAA,eAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IAErB,OAAO,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@featurevisor/react",
3
+ "version": "0.14.0",
4
+ "description": "React package for Featurevisor",
5
+ "main": "dist/index.js",
6
+ "module": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "scripts": {
9
+ "lint": "echo 'not linting in this package yet'",
10
+ "transpile": "rimraf lib && tsc --project tsconfig.esm.json",
11
+ "dist": "webpack --config ./webpack.config.js",
12
+ "build": "npm run transpile && npm run dist",
13
+ "test": "jest --config jest.config.js --verbose"
14
+ },
15
+ "author": {
16
+ "name": "Fahad Heylaal",
17
+ "url": "https://fahad19.com"
18
+ },
19
+ "homepage": "https://featurevisor.com",
20
+ "keywords": [
21
+ "featurevisor",
22
+ "feature",
23
+ "features",
24
+ "flags",
25
+ "feature flags",
26
+ "feature toggles",
27
+ "feature management",
28
+ "experimentation",
29
+ "experiment",
30
+ "experiments",
31
+ "react"
32
+ ],
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/fahad19/featurevisor.git"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/fahad19/featurevisor/issues"
43
+ },
44
+ "dependencies": {
45
+ "@featurevisor/sdk": "^0.14.0",
46
+ "@featurevisor/types": "^0.14.0"
47
+ },
48
+ "license": "MIT",
49
+ "devDependencies": {
50
+ "@testing-library/jest-dom": "^5.16.5",
51
+ "@testing-library/react": "^14.0.0",
52
+ "jest-environment-jsdom": "^29.5.0"
53
+ },
54
+ "gitHead": "eb0599df92747f40e6ece174e4de37ac4c098c4c"
55
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
3
+
4
+ export const FeaturevisorContext = React.createContext<FeaturevisorInstance | undefined>(undefined);
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
3
+
4
+ import { FeaturevisorContext } from "./FeaturevisorContext";
5
+
6
+ export interface FeaturevisorProviderProps {
7
+ sdk: FeaturevisorInstance;
8
+ children: React.ReactNode;
9
+ }
10
+
11
+ export function FeaturevisorProvider(props: FeaturevisorProviderProps) {
12
+ return (
13
+ <FeaturevisorContext.Provider value={props.sdk}>{props.children}</FeaturevisorContext.Provider>
14
+ );
15
+ }
@@ -0,0 +1,64 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+
5
+ import { FeaturevisorProvider } from "./FeaturevisorProvider";
6
+ import { activateFeature } from "./activateFeature";
7
+ import { createInstance } from "@featurevisor/sdk";
8
+
9
+ function getNewInstance() {
10
+ const sdk = createInstance({
11
+ datafile: {
12
+ schemaVersion: "1",
13
+ revision: "1.0",
14
+ features: [
15
+ {
16
+ key: "test",
17
+ defaultVariation: false,
18
+ bucketBy: "userId",
19
+ variations: [
20
+ { type: "boolean", value: true },
21
+ { type: "boolean", value: false },
22
+ ],
23
+ traffic: [
24
+ {
25
+ key: "1",
26
+ segments: "*",
27
+ percentage: 100000,
28
+ allocation: [
29
+ { variation: true, percentage: 100000 },
30
+ { variation: false, percentage: 0 },
31
+ ],
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ attributes: [],
37
+ segments: [],
38
+ },
39
+ });
40
+
41
+ return sdk;
42
+ }
43
+
44
+ describe("react: activateFeature", function() {
45
+ test("should be a function", function() {
46
+ expect(activateFeature).toBeInstanceOf(Function);
47
+ });
48
+
49
+ test("should return the variation", function() {
50
+ function TestComponent() {
51
+ const variation = activateFeature("test", { userId: "1" });
52
+
53
+ return variation === true ? <p>True</p> : <p>False</p>;
54
+ }
55
+
56
+ render(
57
+ <FeaturevisorProvider sdk={getNewInstance()}>
58
+ <TestComponent />
59
+ </FeaturevisorProvider>,
60
+ );
61
+
62
+ expect(screen.getByText("True")).toBeInTheDocument();
63
+ });
64
+ });
@@ -0,0 +1,12 @@
1
+ import { Attributes, FeatureKey, VariationValue } from "@featurevisor/types";
2
+
3
+ import { useSdk } from "./useSdk";
4
+
5
+ export function activateFeature(
6
+ featureKey: FeatureKey,
7
+ attributes: Attributes = {},
8
+ ): VariationValue | undefined {
9
+ const sdk = useSdk();
10
+
11
+ return sdk.activate(featureKey, attributes);
12
+ }
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ // contexts
2
+ export * from "./FeaturevisorContext";
3
+
4
+ // components
5
+ export * from "./FeaturevisorProvider";
6
+
7
+ // hooks
8
+ export * from "./activateFeature";
9
+ export * from "./useSdk";
10
+ export * from "./useStatus";
11
+ export * from "./useVariable";
12
+ export * from "./useVariation";
@@ -0,0 +1,66 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+
5
+ import { FeaturevisorProvider } from "./FeaturevisorProvider";
6
+ import { useSdk } from "./useSdk";
7
+ import { createInstance } from "@featurevisor/sdk";
8
+
9
+ function getNewInstance() {
10
+ const sdk = createInstance({
11
+ datafile: {
12
+ schemaVersion: "1",
13
+ revision: "1.0",
14
+ features: [
15
+ {
16
+ key: "test",
17
+ defaultVariation: false,
18
+ bucketBy: "userId",
19
+ variations: [
20
+ { type: "boolean", value: true },
21
+ { type: "boolean", value: false },
22
+ ],
23
+ traffic: [
24
+ {
25
+ key: "1",
26
+ segments: "*",
27
+ percentage: 100000,
28
+ allocation: [
29
+ { variation: true, percentage: 100000 },
30
+ { variation: false, percentage: 0 },
31
+ ],
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ attributes: [],
37
+ segments: [],
38
+ },
39
+ });
40
+
41
+ return sdk;
42
+ }
43
+
44
+ describe("react: useSdk", function () {
45
+ test("should be a function", function () {
46
+ expect(useSdk).toBeInstanceOf(Function);
47
+ });
48
+
49
+ test("should return the sdk", function () {
50
+ function TestComponent() {
51
+ const sdk = useSdk();
52
+
53
+ expect(typeof sdk.isReady).toEqual("function");
54
+
55
+ return <p>Test</p>;
56
+ }
57
+
58
+ render(
59
+ <FeaturevisorProvider sdk={getNewInstance()}>
60
+ <TestComponent />
61
+ </FeaturevisorProvider>,
62
+ );
63
+
64
+ expect(screen.getByText("Test")).toBeInTheDocument();
65
+ });
66
+ });
package/src/useSdk.ts ADDED
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { FeaturevisorInstance } from "@featurevisor/sdk";
3
+
4
+ import { FeaturevisorContext } from "./FeaturevisorContext";
5
+
6
+ export function useSdk(): FeaturevisorInstance {
7
+ const sdk = React.useContext(FeaturevisorContext);
8
+
9
+ return sdk as FeaturevisorInstance;
10
+ }
@@ -0,0 +1,64 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+
5
+ import { FeaturevisorProvider } from "./FeaturevisorProvider";
6
+ import { useStatus } from "./useStatus";
7
+ import { createInstance } from "@featurevisor/sdk";
8
+
9
+ function getNewInstance() {
10
+ const sdk = createInstance({
11
+ datafile: {
12
+ schemaVersion: "1",
13
+ revision: "1.0",
14
+ features: [
15
+ {
16
+ key: "test",
17
+ defaultVariation: false,
18
+ bucketBy: "userId",
19
+ variations: [
20
+ { type: "boolean", value: true },
21
+ { type: "boolean", value: false },
22
+ ],
23
+ traffic: [
24
+ {
25
+ key: "1",
26
+ segments: "*",
27
+ percentage: 100000,
28
+ allocation: [
29
+ { variation: true, percentage: 100000 },
30
+ { variation: false, percentage: 0 },
31
+ ],
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ attributes: [],
37
+ segments: [],
38
+ },
39
+ });
40
+
41
+ return sdk;
42
+ }
43
+
44
+ describe("react: useStatus", function () {
45
+ test("should be a function", function () {
46
+ expect(useStatus).toBeInstanceOf(Function);
47
+ });
48
+
49
+ test("should return the variation", function () {
50
+ function TestComponent() {
51
+ const { isReady } = useStatus();
52
+
53
+ return isReady ? <p>Ready</p> : <p>Loading...</p>;
54
+ }
55
+
56
+ render(
57
+ <FeaturevisorProvider sdk={getNewInstance()}>
58
+ <TestComponent />
59
+ </FeaturevisorProvider>,
60
+ );
61
+
62
+ expect(screen.getByText("Ready")).toBeInTheDocument();
63
+ });
64
+ });
@@ -0,0 +1,32 @@
1
+ import * as React from "react";
2
+
3
+ import { useSdk } from "./useSdk";
4
+
5
+ export interface Status {
6
+ isReady: boolean;
7
+ }
8
+
9
+ export function useStatus(): Status {
10
+ const sdk = useSdk();
11
+ const initialStatus = sdk.isReady();
12
+
13
+ const [isReady, setIsReady] = React.useState(initialStatus);
14
+
15
+ if (isReady) {
16
+ return { isReady };
17
+ }
18
+
19
+ React.useEffect(function () {
20
+ function handleReady() {
21
+ setIsReady(true);
22
+ }
23
+
24
+ sdk.on("ready", handleReady);
25
+
26
+ return function () {
27
+ sdk.off("ready", handleReady);
28
+ };
29
+ }, []);
30
+
31
+ return { isReady };
32
+ }
@@ -0,0 +1,81 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+
5
+ import { FeaturevisorProvider } from "./FeaturevisorProvider";
6
+ import { useVariable } from "./useVariable";
7
+ import { createInstance } from "@featurevisor/sdk";
8
+
9
+ function getNewInstance() {
10
+ const sdk = createInstance({
11
+ datafile: {
12
+ schemaVersion: "1",
13
+ revision: "1.0",
14
+ features: [
15
+ {
16
+ key: "test",
17
+ defaultVariation: "control",
18
+ bucketBy: "userId",
19
+ variations: [
20
+ { type: "string", value: "control" },
21
+ {
22
+ type: "string",
23
+ value: "b",
24
+ },
25
+ { type: "string", value: "c" },
26
+ ],
27
+ traffic: [
28
+ {
29
+ key: "1",
30
+ segments: "*",
31
+ percentage: 100000,
32
+ allocation: [
33
+ { variation: "control", percentage: 33000 },
34
+ { variation: "b", percentage: 33000 },
35
+ { variation: "c", percentage: 34000 },
36
+ ],
37
+ },
38
+ ],
39
+ variablesSchema: [
40
+ { key: "color", type: "string", defaultValue: "red" },
41
+ {
42
+ key: "hero",
43
+ type: "object",
44
+ defaultValue: {
45
+ title: "Hero Title",
46
+ subtitle: "Hero Subtitle",
47
+ alignment: "center",
48
+ },
49
+ },
50
+ ],
51
+ },
52
+ ],
53
+ attributes: [],
54
+ segments: [],
55
+ },
56
+ });
57
+
58
+ return sdk;
59
+ }
60
+
61
+ describe("react: useVariable", function () {
62
+ test("should be a function", function () {
63
+ expect(useVariable).toBeInstanceOf(Function);
64
+ });
65
+
66
+ test("should return the variable", function () {
67
+ function TestComponent() {
68
+ const variable = useVariable("test", "color", { userId: "1" });
69
+
70
+ return variable === "red" ? <p>Red</p> : <p>Transparent</p>;
71
+ }
72
+
73
+ render(
74
+ <FeaturevisorProvider sdk={getNewInstance()}>
75
+ <TestComponent />
76
+ </FeaturevisorProvider>,
77
+ );
78
+
79
+ expect(screen.getByText("Red")).toBeInTheDocument();
80
+ });
81
+ });
@@ -0,0 +1,13 @@
1
+ import { Attributes, FeatureKey, VariableKey, VariableValue } from "@featurevisor/types";
2
+
3
+ import { useSdk } from "./useSdk";
4
+
5
+ export function useVariable(
6
+ featureKey: FeatureKey,
7
+ variableKey: VariableKey,
8
+ attributes: Attributes = {},
9
+ ): VariableValue | undefined {
10
+ const sdk = useSdk();
11
+
12
+ return sdk.getVariable(featureKey, variableKey, attributes);
13
+ }
@@ -0,0 +1,64 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import "@testing-library/jest-dom";
4
+
5
+ import { FeaturevisorProvider } from "./FeaturevisorProvider";
6
+ import { useVariation } from "./useVariation";
7
+ import { createInstance } from "@featurevisor/sdk";
8
+
9
+ function getNewInstance() {
10
+ const sdk = createInstance({
11
+ datafile: {
12
+ schemaVersion: "1",
13
+ revision: "1.0",
14
+ features: [
15
+ {
16
+ key: "test",
17
+ defaultVariation: false,
18
+ bucketBy: "userId",
19
+ variations: [
20
+ { type: "boolean", value: true },
21
+ { type: "boolean", value: false },
22
+ ],
23
+ traffic: [
24
+ {
25
+ key: "1",
26
+ segments: "*",
27
+ percentage: 100000,
28
+ allocation: [
29
+ { variation: true, percentage: 100000 },
30
+ { variation: false, percentage: 0 },
31
+ ],
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ attributes: [],
37
+ segments: [],
38
+ },
39
+ });
40
+
41
+ return sdk;
42
+ }
43
+
44
+ describe("react: useVariation", function () {
45
+ test("should be a function", function () {
46
+ expect(useVariation).toBeInstanceOf(Function);
47
+ });
48
+
49
+ test("should return the variation", function () {
50
+ function TestComponent() {
51
+ const variation = useVariation("test", { userId: "1" });
52
+
53
+ return variation === true ? <p>True</p> : <p>False</p>;
54
+ }
55
+
56
+ render(
57
+ <FeaturevisorProvider sdk={getNewInstance()}>
58
+ <TestComponent />
59
+ </FeaturevisorProvider>,
60
+ );
61
+
62
+ expect(screen.getByText("True")).toBeInTheDocument();
63
+ });
64
+ });
@@ -0,0 +1,12 @@
1
+ import { Attributes, FeatureKey, VariationValue } from "@featurevisor/types";
2
+
3
+ import { useSdk } from "./useSdk";
4
+
5
+ export function useVariation(
6
+ featureKey: FeatureKey,
7
+ attributes: Attributes = {},
8
+ ): VariationValue | undefined {
9
+ const sdk = useSdk();
10
+
11
+ return sdk.getVariation(featureKey, attributes);
12
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.cjs.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib"
5
+ },
6
+ "include": ["./src/**/*.ts", "./src/**/*.tsx"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib"
5
+ },
6
+ "include": ["./src/**/*.ts", "./src/**/*.tsx"]
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib"
5
+ },
6
+ "include": ["./src/**/*.ts", "./src/**/*.tsx"]
7
+ }
@@ -0,0 +1,21 @@
1
+ const path = require("path");
2
+
3
+ const getWebpackConfig = require("../../tools/getWebpackConfig");
4
+
5
+ const wepbackConfig = getWebpackConfig({
6
+ entryFilePath: path.join(__dirname, "src", "index.ts"),
7
+ entryKey: "index",
8
+ outputDirectoryPath: path.join(__dirname, "dist"),
9
+ outputLibrary: "FeaturevisorReact",
10
+ tsConfigFilePath: path.join(__dirname, "tsconfig.cjs.json"),
11
+ externals: {
12
+ react: {
13
+ commonjs: "react",
14
+ commonjs2: "react",
15
+ amd: "react",
16
+ root: "React",
17
+ },
18
+ },
19
+ });
20
+
21
+ module.exports = wepbackConfig;