@openmrs/esm-state 4.3.2-pre.680 → 4.4.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.
- package/.turbo/turbo-build.log +14 -14
- package/dist/openmrs-esm-state.js +1 -1
- package/dist/openmrs-esm-state.js.map +1 -1
- package/package.json +3 -3
- package/src/state.ts +15 -15
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
1
|
+
[34m@openmrs/esm-state:build[0m: cache hit, replaying output [2m7443d7285a9a6064[0m
|
|
2
|
+
[34m@openmrs/esm-state:build: [0mBrowserslist: caniuse-lite is outdated. Please run:
|
|
3
|
+
[34m@openmrs/esm-state:build: [0m npx update-browserslist-db@latest
|
|
4
|
+
[34m@openmrs/esm-state:build: [0m Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
5
|
+
[34m@openmrs/esm-state:build: [0masset [1m[32mopenmrs-esm-state.js[39m[22m 2.98 KiB [1m[32m[emitted][39m[22m [1m[32m[minimized][39m[22m (name: main) 1 related asset
|
|
6
|
+
[34m@openmrs/esm-state:build: [0mruntime modules 1.76 KiB 6 modules
|
|
7
|
+
[34m@openmrs/esm-state:build: [0morphan modules 3.8 KiB [1m[33m[orphan][39m[22m 2 modules
|
|
8
|
+
[34m@openmrs/esm-state:build: [0mcacheable modules 7.09 KiB
|
|
9
|
+
[34m@openmrs/esm-state:build: [0m modules by path [1m../../../node_modules/systemjs-webpack-interop/auto-public-path/*.js[39m[22m 935 bytes
|
|
10
|
+
[34m@openmrs/esm-state:build: [0m [1m../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js[39m[22m 89 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
11
|
+
[34m@openmrs/esm-state:build: [0m [1m../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js[39m[22m 846 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
12
|
+
[34m@openmrs/esm-state:build: [0m [1m./src/index.ts + 2 modules[39m[22m 3.82 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
13
|
+
[34m@openmrs/esm-state:build: [0m [1m../../../node_modules/systemjs-webpack-interop/public-path.js[39m[22m 2.36 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
14
|
+
[34m@openmrs/esm-state:build: [0mwebpack 5.77.0 compiled [1m[32msuccessfully[39m[22m in 15945 ms
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register([],(function(e,t){return{execute:function(){e((()=>{var e={968:(e,t,r)=>{const n=r(577).R;t.s=function(e){if(e||(e=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,e)}},577:(e,t,r)=>{t.R=function(e,t){var r=document.createElement("a");r.href=e;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,o=0,a=n.length;o!==t&&a>=0;)"/"===n[--a]&&o++;if(o!==t)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+t+") is greater than the number of directories ("+o+") in the URL path "+e);var i=n.slice(0,a+1);return r.protocol+"//"+r.host+i};Number.isInteger}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.y=t,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})();var o={};return(0,n(968).s)(1),(()=>{"use strict";
|
|
1
|
+
System.register([],(function(e,t){return{execute:function(){e((()=>{var e={968:(e,t,r)=>{const n=r(577).R;t.s=function(e){if(e||(e=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,e)}},577:(e,t,r)=>{t.R=function(e,t){var r=document.createElement("a");r.href=e;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,o=0,a=n.length;o!==t&&a>=0;)"/"===n[--a]&&o++;if(o!==t)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+t+") is greater than the number of directories ("+o+") in the URL path "+e);var i=n.slice(0,a+1);return r.protocol+"//"+r.host+i};Number.isInteger}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.y=t,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})();var o={};return(0,n(968).s)(1),(()=>{"use strict";n.r(o),n.d(o,{createAppState:()=>c,createGlobalStore:()=>a,getAppState:()=>u,getGlobalStore:()=>i,subscribeTo:()=>s});const e=e=>{let t;const r=new Set,n=(e,n)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=n?n:"object"!=typeof o)?o:Object.assign({},t,o),r.forEach((r=>r(t,e)))}},o=()=>t,a={setState:n,getState:o,subscribe:e=>(r.add(e),()=>r.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return t=e(n,o,a),a},t=t=>t?e(t):e;var r={};function a(e,n){var o=r[e];if(o)return o.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):o.value.setState(n,!0),o.active=!0,o.value;var a=t()((function(){return n}));return r[e]={value:a,active:!0},a}function i(e,n){var o=r[e];if(!o){var a=t()((function(){return null!=n?n:{}}));return r[e]={value:a,active:!1},a}return o.value}function c(e){return a("app",e)}function u(){return i("app",{})}function s(e,t,r){var n=t(e.getState());return e.subscribe((function(e){var o=t(e);o!==n&&(n=o,r(o))}))}})(),o})())}}}));
|
|
2
2
|
//# sourceMappingURL=openmrs-esm-state.js.map
|
|
@@ -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,I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AWF,EAAOP,EAAMP,YAE5B,OAAOO,EAAMT,WAAU,SAACmB,GACtB,IAAMC,EAAUJ,EAAOG,GAEnBC,IAAYF,IACdA,EAAWE,EACXH,EAAOG,GAEX,GACF,C","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":""}
|
|
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,EAGN,C,gBCoDAD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AAgBC,GAAeD,EAClF,ICrBMsB,EAA+C,CAAC,EAU/C,SAASC,EACdC,EACAC,GAEA,IAAMC,EAAYJ,EAAgBE,GAElC,GAAIE,EAUF,OATIA,EAAUC,OACZxF,QAAQC,MACN,mFAGFsF,EAAUrC,MAAMgB,SAASoB,GAAc,GAGzCC,EAAUC,QAAS,EACZD,EAAUrC,MAEjB,IAAMuC,EAAQP,KAAiB,W,OAAMI,C,IAOrC,OALAH,EAAgBE,GAAQ,CACtBnC,MAAOuC,EACPD,QAAQ,GAGHC,CAEX,CAUO,SAASC,EACdL,EACAM,GAEA,IAAMJ,EAAYJ,EAAgBE,GAElC,IAAKE,EAAW,CACd,IAAME,EAAQP,KAAiB,W,OAAMS,QAAAA,EAAkB,CAAC,C,IAKxD,OAJAR,EAAgBE,GAAQ,CACtBnC,MAAOuC,EACPD,QAAQ,GAEHC,CACT,CAEA,OAAOF,EAAUrC,KACnB,CAOO,SAAS0C,EAAeN,GAC7B,OAAOF,EAAkB,MAAOE,EAClC,CAKO,SAASO,IACd,OAAOH,EAAyB,MAAO,CAAC,EAC1C,CAEO,SAASI,EACdL,EACAM,EACAC,GAEA,IAAIC,EAAWF,EAAON,EAAMf,YAE5B,OAAOe,EAAMb,WAAU,SAACb,GACtB,IAAMmC,EAAUH,EAAOhC,GAEnBmC,IAAYD,IACdA,EAAWC,EACXF,EAAOE,GAEX,GACF,C","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/zustand/esm/vanilla.mjs","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","const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\") ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const destroy = () => {\n if ((import.meta.env && import.meta.env.MODE) !== \"production\") {\n console.warn(\n \"[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected.\"\n );\n }\n listeners.clear();\n };\n const api = { setState, getState, subscribe, destroy };\n state = createState(setState, getState, api);\n return api;\n};\nconst createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;\nvar vanilla = (createState) => {\n if ((import.meta.env && import.meta.env.MODE) !== \"production\") {\n console.warn(\n \"[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'.\"\n );\n }\n return createStore(createState);\n};\n\nexport { createStore, vanilla as default };\n","/** @module @category Store */\nimport { createStore, StoreApi } from \"zustand/vanilla\";\n\ninterface StoreEntity {\n value: StoreApi<unknown>;\n active: boolean;\n}\n\nconst availableStores: Record<string, StoreEntity> = {};\n\n/**\n * Creates a Zustand 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<T>(\n name: string,\n initialState: T\n): StoreApi<T> {\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 as StoreApi<T>;\n } else {\n const store = createStore<T>()(() => 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 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<T>(\n name: string,\n fallbackState?: T\n): StoreApi<T> {\n const available = availableStores[name];\n\n if (!available) {\n const store = createStore<T>()(() => fallbackState ?? ({} as unknown as T));\n availableStores[name] = {\n value: store,\n active: false,\n };\n return store;\n }\n\n return available.value as StoreApi<T>;\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: StoreApi<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","createStoreImpl","createState","state","listeners","Set","setState","partial","nextState","is","previousState","assign","forEach","listener","getState","api","subscribe","add","delete","destroy","warn","clear","createStore","availableStores","createGlobalStore","name","initialState","available","active","store","getGlobalStore","fallbackState","createAppState","getAppState","subscribeTo","select","handle","previous","current"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-state",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Frontend stores & state management for OpenMRS",
|
|
6
6
|
"browser": "dist/openmrs-esm-state.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
39
|
+
"zustand": "^4.3.6"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fdaefeded76bee4ec6503ca6590737e89ebe4b26"
|
|
42
42
|
}
|
package/src/state.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/** @module @category Store */
|
|
2
|
-
import createStore,
|
|
2
|
+
import { createStore, StoreApi } from "zustand/vanilla";
|
|
3
3
|
|
|
4
4
|
interface StoreEntity {
|
|
5
|
-
value:
|
|
5
|
+
value: StoreApi<unknown>;
|
|
6
6
|
active: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const availableStores: Record<string, StoreEntity> = {};
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Creates a
|
|
12
|
+
* Creates a Zustand store.
|
|
13
13
|
*
|
|
14
14
|
* @param name A name by which the store can be looked up later.
|
|
15
15
|
* Must be unique across the entire application.
|
|
16
16
|
* @param initialState An object which will be the initial state of the store.
|
|
17
17
|
* @returns The newly created store.
|
|
18
18
|
*/
|
|
19
|
-
export function createGlobalStore<
|
|
19
|
+
export function createGlobalStore<T>(
|
|
20
20
|
name: string,
|
|
21
|
-
initialState:
|
|
22
|
-
):
|
|
21
|
+
initialState: T
|
|
22
|
+
): StoreApi<T> {
|
|
23
23
|
const available = availableStores[name];
|
|
24
24
|
|
|
25
25
|
if (available) {
|
|
@@ -32,9 +32,9 @@ export function createGlobalStore<TState>(
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
available.active = true;
|
|
35
|
-
return available.value
|
|
35
|
+
return available.value as StoreApi<T>;
|
|
36
36
|
} else {
|
|
37
|
-
const store = createStore(initialState);
|
|
37
|
+
const store = createStore<T>()(() => initialState);
|
|
38
38
|
|
|
39
39
|
availableStores[name] = {
|
|
40
40
|
value: store,
|
|
@@ -46,21 +46,21 @@ export function createGlobalStore<TState>(
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Returns the existing
|
|
49
|
+
* Returns the existing store named `name`,
|
|
50
50
|
* or creates a new store named `name` if none exists.
|
|
51
51
|
*
|
|
52
52
|
* @param name The name of the store to look up.
|
|
53
53
|
* @param fallbackState The initial value of the new store if no store named `name` exists.
|
|
54
54
|
* @returns The found or newly created store.
|
|
55
55
|
*/
|
|
56
|
-
export function getGlobalStore<
|
|
56
|
+
export function getGlobalStore<T>(
|
|
57
57
|
name: string,
|
|
58
|
-
fallbackState?:
|
|
59
|
-
):
|
|
58
|
+
fallbackState?: T
|
|
59
|
+
): StoreApi<T> {
|
|
60
60
|
const available = availableStores[name];
|
|
61
61
|
|
|
62
62
|
if (!available) {
|
|
63
|
-
const store = createStore(fallbackState);
|
|
63
|
+
const store = createStore<T>()(() => fallbackState ?? ({} as unknown as T));
|
|
64
64
|
availableStores[name] = {
|
|
65
65
|
value: store,
|
|
66
66
|
active: false,
|
|
@@ -68,7 +68,7 @@ export function getGlobalStore<TState = any>(
|
|
|
68
68
|
return store;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
return available.value
|
|
71
|
+
return available.value as StoreApi<T>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface AppState {}
|
|
@@ -88,7 +88,7 @@ export function getAppState() {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export function subscribeTo<T, U>(
|
|
91
|
-
store:
|
|
91
|
+
store: StoreApi<T>,
|
|
92
92
|
select: (state: T) => U,
|
|
93
93
|
handle: (subState: U) => void
|
|
94
94
|
) {
|