@openmrs/esm-feature-flags 5.7.2 → 5.7.3-pre.2113

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.
@@ -7,4 +7,4 @@ orphan modules 8.16 KiB [orphan] 1 module
7
7
  built modules 8.23 KiB [built]
8
8
  ./src/index.ts + 1 modules 8.19 KiB [built] [code generated]
9
9
  external "@openmrs/esm-state" 42 bytes [built] [code generated]
10
- webpack 5.88.0 compiled successfully in 15373 ms
10
+ webpack 5.88.0 compiled successfully in 9148 ms
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-esm-feature-flags.js","mappings":"sLAAAA,EAAOC,QAAUC,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaL,QAGrB,IAAID,EAASG,EAAyBE,GAAY,CAGjDJ,QAAS,CAAC,GAOX,OAHAO,EAAoBH,GAAUL,EAAQA,EAAOC,QAASG,GAG/CJ,EAAOC,OACf,CCrBAG,EAAoBK,EAAI,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEX,EAASU,IAC5EE,OAAOC,eAAeb,EAASU,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAKrB,IACH,oBAAXsB,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAeb,EAASsB,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAeb,EAAS,aAAc,CAAEwB,OAAO,GAAO,E,2KCL1B,iB,04BAapC,IAAMC,EAAsB,CAAEC,MAe9B,WACE,IAAMA,EAAQ,CAAC,EACV,mB,IAAL,QAAK,IAAad,OAAOe,KAAKC,c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,wBAAiC,OAATvB,GAAYsB,EAAKhB,QAAQkB,YACtE1B,aAAayB,QACX,6BAAsC,OAATvB,GAC7BG,KAAKsB,UAAU,CAAEd,MAAOW,EAAKX,MAAOC,YAAaU,EAAKV,cAE1D,C,UANK,Q,aAAA,6B,YAAA,E,MAAA,C,EAOP,G","sources":["webpack://@openmrs/esm-feature-flags/external system \"@openmrs/esm-state\"","webpack://@openmrs/esm-feature-flags/webpack/bootstrap","webpack://@openmrs/esm-feature-flags/webpack/runtime/define property getters","webpack://@openmrs/esm-feature-flags/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-feature-flags/webpack/runtime/make namespace object","webpack://@openmrs/esm-feature-flags/./src/feature-flags.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","// 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](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/** @module @category Feature Flags */\nimport { getGlobalStore } from '@openmrs/esm-state';\n\nexport interface FeatureFlagsStore {\n flags: { [flagName: string]: FeatureFlag };\n}\n\nexport interface FeatureFlag {\n enabled: boolean;\n label: string;\n description: string;\n}\n\nconst initialFeatureFlags = { flags: getFeatureFlagsFromLocalStorage() };\n\n/** @internal */\nexport const featureFlagsStore = getGlobalStore<FeatureFlagsStore>('feature-flags', initialFeatureFlags);\n\nfeatureFlagsStore.subscribe((state) => {\n for (const [flagName, flag] of Object.entries(state.flags)) {\n localStorage.setItem(`openmrs:feature-flag:${flagName}`, flag.enabled.toString());\n localStorage.setItem(\n `openmrs:feature-flag-meta:${flagName}`,\n JSON.stringify({ label: flag.label, description: flag.description }),\n );\n }\n});\n\nfunction getFeatureFlagsFromLocalStorage() {\n const flags = {};\n for (const key of Object.keys(localStorage)) {\n if (key.startsWith('openmrs:feature-flag:')) {\n const flagName = key.replace('openmrs:feature-flag:', '');\n const meta = JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || '{}');\n flags[flagName] = {\n enabled: localStorage.getItem(key) === 'true',\n ...meta,\n };\n }\n }\n return flags;\n}\n\n/**\n * This function creates a feature flag. Call it in top-level code anywhere. It will\n * not reset whether the flag is enabled or not, so it's safe to call it multiple times.\n * Once a feature flag is created, it will appear with a toggle in the Implementer Tools.\n * It can then be used to turn on or off features in the code.\n *\n * @param flagName A code-friendly name for the flag, which will be used to reference it in code\n * @param label A human-friendly name which will be displayed in the Implementer Tools\n * @param description An explanation of what the flag does, which will be displayed in the Implementer Tools\n */\nexport function registerFeatureFlag(flagName: string, label: string, description: string) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: {\n enabled: state.flags[flagName]?.enabled ?? false,\n label,\n description,\n },\n },\n }));\n}\n\n/** Use this function to access the current value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function getFeatureFlag(flagName: string) {\n return featureFlagsStore.getState().flags[flagName].enabled;\n}\n\n/** Use this function to subscribe to the value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function subscribeToFeatureFlag(flagName: string, callback: (value: boolean) => void) {\n featureFlagsStore.subscribe((state) => {\n callback(state.flags[flagName].enabled);\n });\n}\n\n/** @internal for Implementer Tools */\nexport function setFeatureFlag(flagName: string, value: boolean) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: { ...state.flags[flagName], enabled: value },\n },\n }));\n}\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__685__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","initialFeatureFlags","flags","keys","localStorage","startsWith","flagName","replace","meta","JSON","parse","getItem","enabled","getFeatureFlagsFromLocalStorage","featureFlagsStore","getGlobalStore","registerFeatureFlag","label","description","state","setState","getFeatureFlag","getState","subscribeToFeatureFlag","callback","subscribe","setFeatureFlag","entries","flag","setItem","toString","stringify"],"sourceRoot":""}
1
+ {"version":3,"file":"openmrs-esm-feature-flags.js","mappings":"sLAAAA,EAAOC,QAAUC,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaL,QAGrB,IAAID,EAASG,EAAyBE,GAAY,CAGjDJ,QAAS,CAAC,GAOX,OAHAO,EAAoBH,GAAUL,EAAQA,EAAOC,QAASG,GAG/CJ,EAAOC,OACf,CCrBAG,EAAoBK,EAAI,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEX,EAASU,IAC5EE,OAAOC,eAAeb,EAASU,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EA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Cc,EAAkBM,UAAS,SAACD,G,MAAW,CACrCjB,MAAO,OACFiB,EAAMjB,OACT,KAACI,EAAW,OAAKa,EAAMjB,MAAMI,IAAS,CAAEM,QAASZ,M,GAGvD,CA1EAc,EAAkBW,WAAU,SAACN,G,QACtB,mB,IAAL,QAAK,IAA0B/B,OAAOuC,QAAQR,EAAMjB,OAAK,qBAApD,0BAAuD,CAAvD,O,EAAA,Q,EAAA,E,+zBAAOI,EAAAA,EAAAA,GAAUsB,EAAAA,EAAAA,GACpBxB,aAAayB,QAAQ,wBAAiC,OAATvB,GAAYsB,EAAKhB,QAAQkB,YACtE1B,aAAayB,QACX,6BAAsC,OAATvB,GAC7BG,KAAKsB,UAAU,CAAEd,MAAOW,EAAKX,MAAOC,YAAaU,EAAKV,cAE1D,C,UANK,Q,aAAA,6B,YAAA,E,MAAA,C,EAOP,G","sources":["webpack://@openmrs/esm-feature-flags/external system \"@openmrs/esm-state\"","webpack://@openmrs/esm-feature-flags/webpack/bootstrap","webpack://@openmrs/esm-feature-flags/webpack/runtime/define property getters","webpack://@openmrs/esm-feature-flags/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-feature-flags/webpack/runtime/make namespace object","webpack://@openmrs/esm-feature-flags/./src/feature-flags.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","// 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](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/** @module @category Feature Flags */\nimport { getGlobalStore } from '@openmrs/esm-state';\n\nexport interface FeatureFlagsStore {\n flags: { [flagName: string]: FeatureFlag };\n}\n\nexport interface FeatureFlag {\n enabled: boolean;\n label: string;\n description: string;\n}\n\nconst initialFeatureFlags = { flags: getFeatureFlagsFromLocalStorage() };\n\n/** @internal */\nexport const featureFlagsStore = getGlobalStore<FeatureFlagsStore>('feature-flags', initialFeatureFlags);\n\nfeatureFlagsStore.subscribe((state) => {\n for (const [flagName, flag] of Object.entries(state.flags)) {\n localStorage.setItem(`openmrs:feature-flag:${flagName}`, flag.enabled.toString());\n localStorage.setItem(\n `openmrs:feature-flag-meta:${flagName}`,\n JSON.stringify({ label: flag.label, description: flag.description }),\n );\n }\n});\n\nfunction getFeatureFlagsFromLocalStorage() {\n const flags: FeatureFlagsStore['flags'] = {};\n for (const key of Object.keys(localStorage)) {\n if (key.startsWith('openmrs:feature-flag:')) {\n const flagName = key.replace('openmrs:feature-flag:', '');\n const meta = JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || '{}');\n flags[flagName] = {\n enabled: localStorage.getItem(key) === 'true',\n ...meta,\n };\n }\n }\n return flags;\n}\n\n/**\n * This function creates a feature flag. Call it in top-level code anywhere. It will\n * not reset whether the flag is enabled or not, so it's safe to call it multiple times.\n * Once a feature flag is created, it will appear with a toggle in the Implementer Tools.\n * It can then be used to turn on or off features in the code.\n *\n * @param flagName A code-friendly name for the flag, which will be used to reference it in code\n * @param label A human-friendly name which will be displayed in the Implementer Tools\n * @param description An explanation of what the flag does, which will be displayed in the Implementer Tools\n */\nexport function registerFeatureFlag(flagName: string, label: string, description: string) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: {\n enabled: state.flags[flagName]?.enabled ?? false,\n label,\n description,\n },\n },\n }));\n}\n\n/** Use this function to access the current value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function getFeatureFlag(flagName: string) {\n return featureFlagsStore.getState().flags[flagName].enabled;\n}\n\n/** Use this function to subscribe to the value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function subscribeToFeatureFlag(flagName: string, callback: (value: boolean) => void) {\n featureFlagsStore.subscribe((state) => {\n callback(state.flags[flagName].enabled);\n });\n}\n\n/** @internal for Implementer Tools */\nexport function setFeatureFlag(flagName: string, value: boolean) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: { ...state.flags[flagName], enabled: value },\n },\n }));\n}\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__685__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","initialFeatureFlags","flags","keys","localStorage","startsWith","flagName","replace","meta","JSON","parse","getItem","enabled","getFeatureFlagsFromLocalStorage","featureFlagsStore","getGlobalStore","registerFeatureFlag","label","description","state","setState","getFeatureFlag","getState","subscribeToFeatureFlag","callback","subscribe","setFeatureFlag","entries","flag","setItem","toString","stringify"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-feature-flags",
3
- "version": "5.7.2",
3
+ "version": "5.7.3-pre.2113",
4
4
  "license": "MPL-2.0",
5
5
  "description": "A feature flag system for the OpenMRS Single-Spa framework.",
6
6
  "browser": "dist/openmrs-esm-feature-flags.js",
@@ -46,8 +46,9 @@
46
46
  "single-spa": "5.x"
47
47
  },
48
48
  "devDependencies": {
49
- "@openmrs/esm-globals": "5.7.2",
50
- "@openmrs/esm-state": "5.7.2",
49
+ "@openmrs/esm-globals": "5.7.3-pre.2113",
50
+ "@openmrs/esm-state": "5.7.3-pre.2113",
51
51
  "single-spa": "^6.0.1"
52
- }
52
+ },
53
+ "stableVersion": "5.7.2"
53
54
  }
@@ -27,7 +27,7 @@ featureFlagsStore.subscribe((state) => {
27
27
  });
28
28
 
29
29
  function getFeatureFlagsFromLocalStorage() {
30
- const flags = {};
30
+ const flags: FeatureFlagsStore['flags'] = {};
31
31
  for (const key of Object.keys(localStorage)) {
32
32
  if (key.startsWith('openmrs:feature-flag:')) {
33
33
  const flagName = key.replace('openmrs:feature-flag:', '');