@openmrs/esm-state 4.0.0-pre.0 → 4.0.1-pre.206

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.
@@ -1,12 +1,12 @@
1
- @openmrs/esm-state:build: cache hit, replaying output 6f4588c86dd90fba
2
- @openmrs/esm-state:build: $ webpack --mode=production
3
- @openmrs/esm-state:build: asset openmrs-esm-state.js 2.93 KiB [emitted] [minimized] (name: main) 1 related asset
4
- @openmrs/esm-state:build: runtime modules 1.76 KiB 6 modules
5
- @openmrs/esm-state:build: orphan modules 2.79 KiB [orphan] 2 modules
6
- @openmrs/esm-state:build: cacheable modules 6.09 KiB
7
- @openmrs/esm-state:build:  modules by path ../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js 935 bytes
8
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
- @openmrs/esm-state:build:  ./src/index.ts + 2 modules 2.82 KiB [built] [code generated]
11
- @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
12
- @openmrs/esm-state:build: webpack 5.70.0 compiled successfully in 6850 ms
1
+ @openmrs/esm-state:build: cache hit, replaying output 52f237f0c1b1c4ce
2
+ @openmrs/esm-state:build: $ webpack --mode=production
3
+ @openmrs/esm-state:build: asset openmrs-esm-state.js 2.93 KiB [emitted] [minimized] (name: main) 1 related asset
4
+ @openmrs/esm-state:build: runtime modules 1.76 KiB 6 modules
5
+ @openmrs/esm-state:build: orphan modules 2.79 KiB [orphan] 2 modules
6
+ @openmrs/esm-state:build: cacheable modules 6.09 KiB
7
+ @openmrs/esm-state:build:  modules by path ../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js 935 bytes
8
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js 846 bytes [built] [code generated]
10
+ @openmrs/esm-state:build:  ./src/index.ts + 2 modules 2.82 KiB [built] [code generated]
11
+ @openmrs/esm-state:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
12
+ @openmrs/esm-state:build: webpack 5.74.0 compiled successfully in 12531 ms
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-esm-state.js","mappings":"yFAAA,MAAMA,EAAmB,SAEzBC,EAAQ,EAAiB,SAAwBC,GAY7C,GAXGA,IACHA,EAAe,IAUV,IAAmBC,OAAS,IAAmBA,KAAKC,IAEvD,MADAC,QAAQC,MAAM,qBAAsB,KAC9BC,MACJ,uHAIJ,IAA0BP,EACxB,IAAmBG,KAAKC,IACxBF,K,cCuDND,EAAQ,EAlCR,SAA0BO,EAAWC,GAKnC,IAAIC,EAAIC,SAASC,cAAc,KAC/BF,EAAEG,KAAOL,EAKT,IAHA,IAAIM,EAA6B,MAAlBJ,EAAEI,SAAS,GAAaJ,EAAEI,SAAW,IAAMJ,EAAEI,SACxDC,EAAmB,EACrBC,EAAQF,EAASG,OACZF,IAAqBN,GAAsBO,GAAS,GAE5C,MADFF,IAAWE,IAEpBD,IAIJ,GAAIA,IAAqBN,EACvB,MAAMF,MACJ,iDACEE,EACA,gDACAM,EACA,qBACAP,GAIN,IAAIU,EAAYJ,EAASK,MAAM,EAAGH,EAAQ,GAE1C,OAAON,EAAEU,SAAW,KAAOV,EAAEW,KAAOH,GAOpCI,OAAOC,YCjFLC,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa1B,QAGrB,IAAI4B,EAASL,EAAyBE,GAAY,CAGjDzB,QAAS,IAOV,OAHA6B,EAAoBJ,GAAUG,EAAQA,EAAO5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IAAML,EAAYJ,EAAgBE,GAElC,IAAKE,EAAW,CACd,IAAME,EAAQC,EAAYE,GAK1B,OAJAT,EAAgBE,GAAQ,CACtB3B,MAAO+B,EACPD,QAAQ,GAEHC,EAGT,OAAOF,EAAU7B,MAQZ,SAASmC,EAAeP,GAC7B,OAAOF,EAAkB,MAAOE,GAM3B,SAASQ,IACd,OAAOH,EAAyB,MAAO,IAGlC,SAASI,EACdN,EACAO,EACAC,GAEA,IAAIC,EAAWF,EAAOP,EAAMP,YAE5B,OAAOO,EAAMT,WAAU,SAACmB,GACtB,IAAMC,EAAUJ,EAAOG,GAEnBC,IAAYF,IACdA,EAAWE,EACXH,EAAOG,S","sources":["webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js","webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/public-path.js","webpack://@openmrs/esm-state/webpack/bootstrap","webpack://@openmrs/esm-state/webpack/runtime/__system_context__","webpack://@openmrs/esm-state/webpack/runtime/define property getters","webpack://@openmrs/esm-state/webpack/runtime/global","webpack://@openmrs/esm-state/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-state/webpack/runtime/make namespace object","webpack://@openmrs/esm-state/webpack/runtime/publicPath","webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js","webpack://@openmrs/esm-state/../../../node_modules/unistore/dist/unistore.es.js","webpack://@openmrs/esm-state/./src/state.ts"],"sourcesContent":["const resolveDirectory = require(\"../public-path\").resolveDirectory;\n\nexports.autoPublicPath = function autoPublicPath(rootDirLevel) {\n if (!rootDirLevel) {\n rootDirLevel = 1;\n }\n\n if (typeof __webpack_public_path__ !== \"undefined\") {\n if (typeof __system_context__ === \"undefined\") {\n throw Error(\n \"systemjs-webpack-interop requires webpack@>=5.0.0-beta.15 and output.libraryTarget set to 'system'\"\n );\n }\n\n if (!__system_context__.meta || !__system_context__.meta.url) {\n console.error(\"__system_context__\", __system_context__);\n throw Error(\n \"systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(\n __system_context__.meta.url,\n rootDirLevel\n );\n }\n};\n","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n isNaN(rootDirectoryLevel) ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n var moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n var a = document.createElement(\"a\");\n a.href = urlString;\n\n var pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n var numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n var char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n var finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nvar isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","// 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","__webpack_require__.y = __system_context__;","// 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__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\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};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) scriptUrl = scripts[scripts.length - 1].src\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","const autoPublicPath = require(\"./auto-public-path\").autoPublicPath;\n\nautoPublicPath(1);\n","function n(n,t){for(var r in t)n[r]=t[r];return n}export default function(t){var r=[];function u(n){for(var t=[],u=0;u<r.length;u++)r[u]===n?n=null:t.push(r[u]);r=t}function e(u,e,f){t=e?u:n(n({},t),u);for(var i=r,o=0;o<i.length;o++)i[o](t,f)}return t=t||{},{action:function(n){function r(t){e(t,!1,n)}return function(){for(var u=arguments,e=[t],f=0;f<arguments.length;f++)e.push(u[f]);var i=n.apply(this,e);if(null!=i)return i.then?i.then(r):r(i)}},setState:e,subscribe:function(n){return r.push(n),function(){u(n)}},unsubscribe:u,getState:function(){return t}}}\n//# sourceMappingURL=unistore.es.js.map\n","/** @module @category Store */\nimport createStore, { Store } from \"unistore\";\n\ninterface StoreEntity {\n value: Store<any>;\n active: boolean;\n}\n\nconst availableStores: Record<string, StoreEntity> = {};\n\n/**\n * Creates a Unistore [store](https://github.com/developit/unistore#store).\n *\n * @param name A name by which the store can be looked up later.\n * Must be unique across the entire application.\n * @param initialState An object which will be the initial state of the store.\n * @returns The newly created store.\n */\nexport function createGlobalStore<TState>(\n name: string,\n initialState: TState\n): Store<TState> {\n const available = availableStores[name];\n\n if (available) {\n if (available.active) {\n console.error(\n \"Cannot override an existing store. Make sure that stores are only created once.\"\n );\n } else {\n available.value.setState(initialState, true);\n }\n\n available.active = true;\n return available.value;\n } else {\n const store = createStore(initialState);\n\n availableStores[name] = {\n value: store,\n active: true,\n };\n\n return store;\n }\n}\n\n/**\n * Returns the existing [store](https://github.com/developit/unistore#store) named `name`,\n * or creates a new store named `name` if none exists.\n *\n * @param name The name of the store to look up.\n * @param fallbackState The initial value of the new store if no store named `name` exists.\n * @returns The found or newly created store.\n */\nexport function getGlobalStore<TState = any>(\n name: string,\n fallbackState?: TState\n): Store<TState> {\n const available = availableStores[name];\n\n if (!available) {\n const store = createStore(fallbackState);\n availableStores[name] = {\n value: store,\n active: false,\n };\n return store;\n }\n\n return available.value;\n}\n\nexport interface AppState {}\n\n/**\n * @internal\n */\nexport function createAppState(initialState: AppState) {\n return createGlobalStore(\"app\", initialState);\n}\n\n/**\n * @returns The [store](https://github.com/developit/unistore#store) named `app`.\n */\nexport function getAppState() {\n return getGlobalStore<AppState>(\"app\", {});\n}\n\nexport function subscribeTo<T, U>(\n store: Store<T>,\n select: (state: T) => U,\n handle: (subState: U) => void\n) {\n let previous = select(store.getState());\n\n return store.subscribe((state) => {\n const current = select(state);\n\n if (current !== previous) {\n previous = current;\n handle(current);\n }\n });\n}\n"],"names":["resolveDirectory","exports","rootDirLevel","meta","url","console","error","Error","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","finalPath","slice","protocol","host","Number","isInteger","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","module","__webpack_modules__","y","__system_context__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","currentScript","src","scripts","getElementsByTagName","replace","p","autoPublicPath","n","t","u","push","f","i","action","arguments","apply","then","setState","subscribe","unsubscribe","getState","availableStores","createGlobalStore","name","initialState","available","active","store","createStore","getGlobalStore","fallbackState","createAppState","getAppState","subscribeTo","select","handle","previous","state","current"],"sour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K,CAQZ,SAASmC,EAAeP,GAC7B,OAAOF,EAAkB,MAAOE,E,CAM3B,SAASQ,IACd,OAAOH,EAAyB,MAAO,CAAC,E,CAGnC,SAASI,EACdN,EACAO,EACAC,GAEA,IAAIC,EAAWF,EAAOP,EAAMP,YAE5B,OAAOO,EAAMT,WAAU,SAACmB,GACtB,IAAMC,EAAUJ,EAAOG,GAEnBC,IAAYF,IACdA,EAAWE,EACXH,EAAOG,G","sources":["webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js","webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/public-path.js","webpack://@openmrs/esm-state/webpack/bootstrap","webpack://@openmrs/esm-state/webpack/runtime/__system_context__","webpack://@openmrs/esm-state/webpack/runtime/define property getters","webpack://@openmrs/esm-state/webpack/runtime/global","webpack://@openmrs/esm-state/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-state/webpack/runtime/make namespace object","webpack://@openmrs/esm-state/webpack/runtime/publicPath","webpack://@openmrs/esm-state/../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js","webpack://@openmrs/esm-state/../../../node_modules/unistore/dist/unistore.es.js","webpack://@openmrs/esm-state/./src/state.ts"],"sourcesContent":["const resolveDirectory = require(\"../public-path\").resolveDirectory;\n\nexports.autoPublicPath = function autoPublicPath(rootDirLevel) {\n if (!rootDirLevel) {\n rootDirLevel = 1;\n }\n\n if (typeof __webpack_public_path__ !== \"undefined\") {\n if (typeof __system_context__ === \"undefined\") {\n throw Error(\n \"systemjs-webpack-interop requires webpack@>=5.0.0-beta.15 and output.libraryTarget set to 'system'\"\n );\n }\n\n if (!__system_context__.meta || !__system_context__.meta.url) {\n console.error(\"__system_context__\", __system_context__);\n throw Error(\n \"systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(\n __system_context__.meta.url,\n rootDirLevel\n );\n }\n};\n","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n isNaN(rootDirectoryLevel) ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n var moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n var a = document.createElement(\"a\");\n a.href = urlString;\n\n var pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n var numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n var char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n var finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nvar isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","// 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","__webpack_require__.y = __system_context__;","// 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__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\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};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) scriptUrl = scripts[scripts.length - 1].src\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","const autoPublicPath = require(\"./auto-public-path\").autoPublicPath;\n\nautoPublicPath(1);\n","function n(n,t){for(var r in t)n[r]=t[r];return n}export default function(t){var r=[];function u(n){for(var t=[],u=0;u<r.length;u++)r[u]===n?n=null:t.push(r[u]);r=t}function e(u,e,f){t=e?u:n(n({},t),u);for(var i=r,o=0;o<i.length;o++)i[o](t,f)}return t=t||{},{action:function(n){function r(t){e(t,!1,n)}return function(){for(var u=arguments,e=[t],f=0;f<arguments.length;f++)e.push(u[f]);var i=n.apply(this,e);if(null!=i)return i.then?i.then(r):r(i)}},setState:e,subscribe:function(n){return r.push(n),function(){u(n)}},unsubscribe:u,getState:function(){return t}}}\n//# sourceMappingURL=unistore.es.js.map\n","/** @module @category Store */\nimport createStore, { Store } from \"unistore\";\n\ninterface StoreEntity {\n value: Store<any>;\n active: boolean;\n}\n\nconst availableStores: Record<string, StoreEntity> = {};\n\n/**\n * Creates a Unistore [store](https://github.com/developit/unistore#store).\n *\n * @param name A name by which the store can be looked up later.\n * Must be unique across the entire application.\n * @param initialState An object which will be the initial state of the store.\n * @returns The newly created store.\n */\nexport function createGlobalStore<TState>(\n name: string,\n initialState: TState\n): Store<TState> {\n const available = availableStores[name];\n\n if (available) {\n if (available.active) {\n console.error(\n \"Cannot override an existing store. Make sure that stores are only created once.\"\n );\n } else {\n available.value.setState(initialState, true);\n }\n\n available.active = true;\n return available.value;\n } else {\n const store = createStore(initialState);\n\n availableStores[name] = {\n value: store,\n active: true,\n };\n\n return store;\n }\n}\n\n/**\n * Returns the existing [store](https://github.com/developit/unistore#store) named `name`,\n * or creates a new store named `name` if none exists.\n *\n * @param name The name of the store to look up.\n * @param fallbackState The initial value of the new store if no store named `name` exists.\n * @returns The found or newly created store.\n */\nexport function getGlobalStore<TState = any>(\n name: string,\n fallbackState?: TState\n): Store<TState> {\n const available = availableStores[name];\n\n if (!available) {\n const store = createStore(fallbackState);\n availableStores[name] = {\n value: store,\n active: false,\n };\n return store;\n }\n\n return available.value;\n}\n\nexport interface AppState {}\n\n/**\n * @internal\n */\nexport function createAppState(initialState: AppState) {\n return createGlobalStore(\"app\", initialState);\n}\n\n/**\n * @returns The [store](https://github.com/developit/unistore#store) named `app`.\n */\nexport function getAppState() {\n return getGlobalStore<AppState>(\"app\", {});\n}\n\nexport function subscribeTo<T, U>(\n store: Store<T>,\n select: (state: T) => U,\n handle: (subState: U) => void\n) {\n let previous = select(store.getState());\n\n return store.subscribe((state) => {\n const current = select(state);\n\n if (current !== previous) {\n previous = current;\n handle(current);\n }\n });\n}\n"],"names":["resolveDirectory","exports","rootDirLevel","meta","url","console","error","Error","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","finalPath","slice","protocol","host","Number","isInteger","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","module","__webpack_modules__","y","__system_context__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","currentScript","src","scripts","getElementsByTagName","replace","p","autoPublicPath","n","t","u","push","f","i","action","arguments","apply","then","setState","subscribe","unsubscribe","getState","availableStores","createGlobalStore","name","initialState","available","active","store","createStore","getGlobalStore","fallbackState","createAppState","getAppState","subscribeTo","select","handle","previous","state","current"],"sourceRoot":""}
package/jest.config.js CHANGED
@@ -3,4 +3,7 @@ module.exports = {
3
3
  "^.+\\.tsx?$": ["@swc/jest"],
4
4
  },
5
5
  testEnvironment: "jsdom",
6
+ testEnvironmentOptions: {
7
+ url: "http://localhost/",
8
+ },
6
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-state",
3
- "version": "4.0.0-pre.0",
3
+ "version": "4.0.1-pre.206",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Frontend stores & state management for OpenMRS",
6
6
  "browser": "dist/openmrs-esm-state.js",
@@ -38,5 +38,5 @@
38
38
  "dependencies": {
39
39
  "unistore": "^3.5.2"
40
40
  },
41
- "gitHead": "254a7226212aac82df4434639b2584e24ac240e4"
41
+ "gitHead": "7ac6e01b41238739cdf5d20efdff50062f46f500"
42
42
  }
package/src/public.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export {
2
- AppState,
2
+ type AppState,
3
3
  createGlobalStore,
4
4
  getGlobalStore,
5
5
  getAppState,
@@ -1,2 +0,0 @@
1
- @openmrs/esm-state:lint: cache hit, replaying output ff3db7423bfec95f
2
- @openmrs/esm-state:lint: $ eslint src --ext ts,tsx
@@ -1,3 +0,0 @@
1
- @openmrs/esm-state:test: cache hit, replaying output e18f52fd775a5b53
2
- @openmrs/esm-state:test: $ jest --config jest.config.js --passWithNoTests
3
- @openmrs/esm-state:test: No tests found, exiting with code 0
@@ -1,2 +0,0 @@
1
- @openmrs/esm-state:typescript: cache hit, replaying output bc146951720a7d02
2
- @openmrs/esm-state:typescript: $ tsc
@@ -1,50 +0,0 @@
1
- import { Store } from "unistore";
2
- import get from "lodash-es/get";
3
- import isEqual from "lodash-es/isEqual";
4
-
5
- /**
6
- * Convenience method to update a store's state with respect to its previous state.
7
- *
8
- * #### Examples
9
- *
10
- * ```js
11
- * myStore.setState({ foo: 0, bar: 10 });
12
- * myStore.subscribe(s => { console.log(s); });
13
- * updateStore(myStore, s => ({ ...s, foo: 1 }));
14
- * // console: { foo: 1, bar: 10 }
15
- *
16
- * updateStore(myStore, s => ({ ...s, foo: 2 }), ['bar']);
17
- * // => { foo: 1, bar: 10 }
18
- * ```
19
- *
20
- * @param store A Unistore store obtained with [[createGlobalStore]] or [[getGlobalStore]]
21
- * @param updater A function operating on the store's state
22
- * @param checkDeepEqualAtPath If undefined, the store is updated as long as the new
23
- * state object does not referentially equal the old state object. If provided,
24
- * it should be a path for accessing the value of the state that should be compared
25
- * for deep equality before setting the state.
26
- */
27
- export function updateStore<T>(
28
- store: Store<T>,
29
- updater: (state: T) => T,
30
- checkDeepEqualAtPath?: Array<string>
31
- ) {
32
- const state = store.getState();
33
- const newState = updater(state);
34
- if (checkDeepEqualAtPath) {
35
- let oldValue = get(state, checkDeepEqualAtPath);
36
- let newValue = get(state, checkDeepEqualAtPath);
37
- // return the whole object if checkDeepEqualAtPath, unlike what get() does
38
- if (checkDeepEqualAtPath.length == 0) {
39
- oldValue = state;
40
- newValue = newState;
41
- }
42
- if (!isEqual(oldValue, newValue)) {
43
- store.setState(newState);
44
- }
45
- } else {
46
- if (newState !== state) {
47
- store.setState(newState);
48
- }
49
- }
50
- }