🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@mkrause/lifecycle-loader

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mkrause/lifecycle-loader - npm Package Compare versions

Comparing version
0.3.0
to
0.3.1
+5
-1
lib-cjs/index.js

@@ -28,4 +28,7 @@ "use strict";

item: LoadableDefs.itemKey,
// Prevent widening to `symbol`
status: LoadableDefs.statusKey,
// Prevent widening to `symbol`
construct: LoadableDefs.constructKey,
// Prevent widening to `symbol`
isStatus: LoadableDefs.isStatus,

@@ -50,3 +53,4 @@ isLoadable: LoadableDefs.isLoadable,

exports.Loadable = Loadable;
const status = LoadableDefs.statusKey;
const status = LoadableDefs.statusKey; // Prevent widening to `symbol`
exports.status = status;

@@ -53,0 +57,0 @@ const isStatus = LoadableDefs.isStatus;

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"names":["Loadable","Object","assign","item","status","LoadableDefs","LoadableProxy","itemKey","statusKey","construct","constructKey","isStatus","isLoadable","Record","LoadableRecord","Proxy","getItem","resource","getStatus","update","updateItem","updateStatus","asPending","asLoading","asReady","asFailed","Loader","LoaderDefs","resourceKey","fromPromise"],"mappings":";;;;;;;;;;;;;AAEA;;AAEA;;AACA;;;;;;AAQA;AACO,MAAMA,QAAQ,GAAGC,MAAM,CAACC,MAAP,CACpB,CAAsBC,IAAtB,EAA6CC,MAAqC,GAAG,EAArF,KACIC,YAAY,CAACC,aAAb,CAA2BH,IAA3B,EAAiCC,MAAjC,CAFgB,EAGpB;AACI;AACAD,EAAAA,IAAI,EAAEE,YAAY,CAACE,OAFvB;AAGIH,EAAAA,MAAM,EAAEC,YAAY,CAACG,SAHzB;AAIIC,EAAAA,SAAS,EAAEJ,YAAY,CAACK,YAJ5B;AAMIC,EAAAA,QAAQ,EAAEN,YAAY,CAACM,QAN3B;AAOIC,EAAAA,UAAU,EAAEP,YAAY,CAACO,UAP7B;AASI;AACAC,EAAAA,MAAM,EAAER,YAAY,CAACS,cAVzB;AAWIC,EAAAA,KAAK,EAAEV,YAAY,CAACC,aAXxB;AAaI;AACAU,EAAAA,OAAO,EAAMC,QAAJ,IAA+BA,QAAQ,CAACZ,YAAY,CAACE,OAAd,CAdpD;AAeIW,EAAAA,SAAS,EAAMD,QAAJ,IAA+BA,QAAQ,CAACZ,YAAY,CAACG,SAAd,CAftD;AAiBI;AACAW,EAAAA,MAAM,EAAEd,YAAY,CAACc,MAlBzB;AAmBIC,EAAAA,UAAU,EAAEf,YAAY,CAACe,UAnB7B;AAoBIC,EAAAA,YAAY,EAAEhB,YAAY,CAACgB,YApB/B;AAqBIC,EAAAA,SAAS,EAAEjB,YAAY,CAACiB,SArB5B;AAsBIC,EAAAA,SAAS,EAAElB,YAAY,CAACkB,SAtB5B;AAuBIC,EAAAA,OAAO,EAAEnB,YAAY,CAACmB,OAvB1B;AAwBIC,EAAAA,QAAQ,EAAEpB,YAAY,CAACoB;AAxB3B,CAHoB,CAAjB,C,CA+BP;;;AACO,MAAMrB,MAAM,GAAGC,YAAY,CAACG,SAA5B;;AACA,MAAMG,QAAQ,GAAGN,YAAY,CAACM,QAA9B;;AACA,MAAMC,UAAU,GAAGP,YAAY,CAACO,UAAhC,C,CAEP;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMc,MAAM,GAAG;AAClBT,EAAAA,QAAQ,EAAEU,UAAU,CAACC,WADH;AAElBC,EAAAA,WAAW,EAAEF,UAAU,CAACE;AAFN,CAAf;;eAOQ7B,Q","sourcesContent":["\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\nimport { isProxyable } from 'proxy-extend';\n\nimport * as LoadableDefs from './interfaces/Loadable.js';\nimport * as LoaderDefs from './interfaces/Loader.js';\n\n\nexport type Status = LoadableDefs.Status;\nexport type Loadable<T> = LoadableDefs.Loadable<T>;\nexport type { Proxyable };\nexport type LoadableProxy<T extends Proxyable> = LoadableDefs.LoadableProxyT<T>;\n\n// Wrap up the definitions in a single `Loadable` object, which can also be invocated as a function (uses Proxy)\nexport const Loadable = Object.assign(\n <T extends Proxyable>(item ?: undefined | T, status : Partial<LoadableDefs.Status> = {}) =>\n LoadableDefs.LoadableProxy(item, status),\n {\n // Keys\n item: LoadableDefs.itemKey,\n status: LoadableDefs.statusKey,\n construct: LoadableDefs.constructKey,\n \n isStatus: LoadableDefs.isStatus,\n isLoadable: LoadableDefs.isLoadable,\n \n // Constructors\n Record: LoadableDefs.LoadableRecord,\n Proxy: LoadableDefs.LoadableProxy,\n \n // Accessor functions\n getItem: <T>(resource : Loadable<T>) => resource[LoadableDefs.itemKey],\n getStatus: <T>(resource : Loadable<T>) => resource[LoadableDefs.statusKey],\n \n // Updater functions\n update: LoadableDefs.update,\n updateItem: LoadableDefs.updateItem,\n updateStatus: LoadableDefs.updateStatus,\n asPending: LoadableDefs.asPending,\n asLoading: LoadableDefs.asLoading,\n asReady: LoadableDefs.asReady,\n asFailed: LoadableDefs.asFailed,\n },\n);\n\n// Shorthand exports\nexport const status = LoadableDefs.statusKey;\nexport const isStatus = LoadableDefs.isStatus;\nexport const isLoadable = LoadableDefs.isLoadable;\n\n// Utilities\nexport { isProxyable };\n\n\n/*\nexport {\n LoadError,\n LoadablePromise,\n};\n\nexport const loader = <T>(\n item : Loadable<T>,\n executor : (resolve : (item : Loadable<T>) => void, reject : (item : Loadable<T>) => void) => void,\n ) =>\n new LoadablePromise(executor, item);\n*/\n\nexport const Loader = {\n resource: LoaderDefs.resourceKey,\n fromPromise: LoaderDefs.fromPromise,\n};\n\nexport type PromiseWithResource<T> = LoaderDefs.PromiseWithResource<T>;\n\nexport default Loadable;\n"],"file":"index.js"}
{"version":3,"sources":["../src/index.ts"],"names":["Loadable","Object","assign","item","status","LoadableDefs","LoadableProxy","itemKey","statusKey","construct","constructKey","isStatus","isLoadable","Record","LoadableRecord","Proxy","getItem","resource","getStatus","update","updateItem","updateStatus","asPending","asLoading","asReady","asFailed","Loader","LoaderDefs","resourceKey","fromPromise"],"mappings":";;;;;;;;;;;;;AAEA;;AAEA;;AACA;;;;;;AAQA;AACO,MAAMA,QAAQ,GAAGC,MAAM,CAACC,MAAP,CACpB,CAAsBC,IAAtB,EAA6CC,MAAqC,GAAG,EAArF,KACIC,YAAY,CAACC,aAAb,CAA2BH,IAA3B,EAAiCC,MAAjC,CAFgB,EAGpB;AACI;AACAD,EAAAA,IAAI,EAAEE,YAAY,CAACE,OAFvB;AAEgE;AAC5DH,EAAAA,MAAM,EAAEC,YAAY,CAACG,SAHzB;AAGsE;AAClEC,EAAAA,SAAS,EAAEJ,YAAY,CAACK,YAJ5B;AAI+E;AAE3EC,EAAAA,QAAQ,EAAEN,YAAY,CAACM,QAN3B;AAOIC,EAAAA,UAAU,EAAEP,YAAY,CAACO,UAP7B;AASI;AACAC,EAAAA,MAAM,EAAER,YAAY,CAACS,cAVzB;AAWIC,EAAAA,KAAK,EAAEV,YAAY,CAACC,aAXxB;AAaI;AACAU,EAAAA,OAAO,EAAMC,QAAJ,IAA+BA,QAAQ,CAACZ,YAAY,CAACE,OAAd,CAdpD;AAeIW,EAAAA,SAAS,EAAMD,QAAJ,IAA+BA,QAAQ,CAACZ,YAAY,CAACG,SAAd,CAftD;AAiBI;AACAW,EAAAA,MAAM,EAAEd,YAAY,CAACc,MAlBzB;AAmBIC,EAAAA,UAAU,EAAEf,YAAY,CAACe,UAnB7B;AAoBIC,EAAAA,YAAY,EAAEhB,YAAY,CAACgB,YApB/B;AAqBIC,EAAAA,SAAS,EAAEjB,YAAY,CAACiB,SArB5B;AAsBIC,EAAAA,SAAS,EAAElB,YAAY,CAACkB,SAtB5B;AAuBIC,EAAAA,OAAO,EAAEnB,YAAY,CAACmB,OAvB1B;AAwBIC,EAAAA,QAAQ,EAAEpB,YAAY,CAACoB;AAxB3B,CAHoB,CAAjB,C,CA+BP;;;AACO,MAAMrB,MAAqC,GAAGC,YAAY,CAACG,SAA3D,C,CAAsE;;;AACtE,MAAMG,QAAQ,GAAGN,YAAY,CAACM,QAA9B;;AACA,MAAMC,UAAU,GAAGP,YAAY,CAACO,UAAhC,C,CAEP;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMc,MAAM,GAAG;AAClBT,EAAAA,QAAQ,EAAEU,UAAU,CAACC,WADH;AAElBC,EAAAA,WAAW,EAAEF,UAAU,CAACE;AAFN,CAAf;;eAOQ7B,Q","sourcesContent":["\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\nimport { isProxyable } from 'proxy-extend';\n\nimport * as LoadableDefs from './interfaces/Loadable.js';\nimport * as LoaderDefs from './interfaces/Loader.js';\n\n\nexport type Status = LoadableDefs.Status;\nexport type Loadable<T> = LoadableDefs.Loadable<T>;\nexport type { Proxyable };\nexport type LoadableProxy<T extends Proxyable> = LoadableDefs.LoadableProxyT<T>;\n\n// Wrap up the definitions in a single `Loadable` object, which can also be invocated as a function (uses Proxy)\nexport const Loadable = Object.assign(\n <T extends Proxyable>(item ?: undefined | T, status : Partial<LoadableDefs.Status> = {}) =>\n LoadableDefs.LoadableProxy(item, status),\n {\n // Keys\n item: LoadableDefs.itemKey as typeof LoadableDefs.itemKey, // Prevent widening to `symbol`\n status: LoadableDefs.statusKey as typeof LoadableDefs.statusKey, // Prevent widening to `symbol`\n construct: LoadableDefs.constructKey as typeof LoadableDefs.constructKey, // Prevent widening to `symbol`\n \n isStatus: LoadableDefs.isStatus,\n isLoadable: LoadableDefs.isLoadable,\n \n // Constructors\n Record: LoadableDefs.LoadableRecord,\n Proxy: LoadableDefs.LoadableProxy,\n \n // Accessor functions\n getItem: <T>(resource : Loadable<T>) => resource[LoadableDefs.itemKey],\n getStatus: <T>(resource : Loadable<T>) => resource[LoadableDefs.statusKey],\n \n // Updater functions\n update: LoadableDefs.update,\n updateItem: LoadableDefs.updateItem,\n updateStatus: LoadableDefs.updateStatus,\n asPending: LoadableDefs.asPending,\n asLoading: LoadableDefs.asLoading,\n asReady: LoadableDefs.asReady,\n asFailed: LoadableDefs.asFailed,\n },\n);\n\n// Shorthand exports\nexport const status: typeof LoadableDefs.statusKey = LoadableDefs.statusKey; // Prevent widening to `symbol`\nexport const isStatus = LoadableDefs.isStatus;\nexport const isLoadable = LoadableDefs.isLoadable;\n\n// Utilities\nexport { isProxyable };\n\n\n/*\nexport {\n LoadError,\n LoadablePromise,\n};\n\nexport const loader = <T>(\n item : Loadable<T>,\n executor : (resolve : (item : Loadable<T>) => void, reject : (item : Loadable<T>) => void) => void,\n ) =>\n new LoadablePromise(executor, item);\n*/\n\nexport const Loader = {\n resource: LoaderDefs.resourceKey,\n fromPromise: LoaderDefs.fromPromise,\n};\n\nexport type PromiseWithResource<T> = LoaderDefs.PromiseWithResource<T>;\n\nexport default Loadable;\n"],"file":"index.js"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/interfaces/Loadable.ts"],"names":["defaultStatus","ready","loading","error","itemKey","Symbol","for","statusKey","constructKey","isStatus","value","Error","isLoadable","LoadableRecord","item","status","TypeError","statusWithDefaults","loadable","LoadableProxy","extend","is","itemProxyable","update","resource","updateItem","updateStatus","asPending","undefined","asLoading","asReady","asFailed","reason"],"mappings":";;;;;;;AACA;;AACA;;;;;;;;AAiCA,MAAMA,aAAsB,GAAG;AAAEC,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,OAAO,EAAE,KAAzB;AAAgCC,EAAAA,KAAK,EAAE;AAAvC,CAA/B,C,CAGA;;AACO,MAAMC,OAAO,GAAGC,MAAM,CAACC,GAAP,CAAW,yBAAX,CAAhB;;AACA,MAAMC,SAAS,GAAGF,MAAM,CAACC,GAAP,CAAW,2BAAX,CAAlB;;AACA,MAAME,YAAY,GAAGH,MAAM,CAACC,GAAP,CAAW,8BAAX,CAArB,C,CAEP;;;;AASO,MAAMG,QAAQ,GAAIC,KAAD,IAAuC;AAC3D,MAA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CADT","sourcesContent":["\nimport $msg from 'message-tag';\nimport extend, { isProxyable } from 'proxy-extend';\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\n\n\n// An *item* is the data part of a resource (can be anything).\nexport type Item = unknown;\n\n/*\nA *status* is an object that describes the current loading state of some resource.\n\nStatus flags:\n - ready: indicates whether this resource can be used or not (whether the data can be read safely)\n - loading: indicates whether we are currently in the process of loading this resource\n - error: indicates that the last load attempt resulted in an error\n\nNote that each of the flags is independent, rather than being a linear transition (e.g. loading -> ready).\nThis is so that we can, for example, start loading new data while keeping information such as an error\nstate, for UI purposes. All the possible combinations listed below.\n\n- !ready + !loading + !error \"pending\", nothing done yet, not even attempted to load\n- !ready + loading + !error \"loading\", for the first time, no older data available\n- ready + !loading + !error \"ready\" (or \"idle\"), can use the data as needed\n- ready + loading + !error \"ready\" (or \"reloading\"), ready but also loading an updated version\n- !ready + !loading + error \"failed\", and not yet any attempt to retry (no older data available)\n- !ready + loading + error \"failed\", but we're currently retrying (no older data available)\n- ready + !loading + error \"failed\", and not yet any attempt to retry (there is older data available)\n- ready + loading + error \"failed\", but we're currently retrying (there is older data available)\n*/\nexport type Status = {\n ready : boolean,\n loading : boolean,\n error : null | Error,\n};\nconst defaultStatus : Status = { ready: false, loading: false, error: null };\n\n\n// Property key symbols\nexport const itemKey = Symbol.for('lifecycle.loadable.item');\nexport const statusKey = Symbol.for('lifecycle.loadable.status');\nexport const constructKey = Symbol.for('lifecycle.loadable.construct');\n\n// A *resource* (or \"Loadable\") is an object that has both an item and a status.\nexport type Loadable<T> = {\n [itemKey] : undefined | T, // May be `undefined` when status is not ready (if ready *must not* be `undefined`)\n [statusKey] : Status,\n \n // Construct a new resource from this one, using the given item and status\n [constructKey] : (item : undefined | T, status : Status) => Loadable<T>,\n};\n\nexport const isStatus = (value : unknown) : value is Status => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n \n return 'ready' in value && typeof (value as Status).ready === 'boolean'\n && 'loading' in value && typeof (value as Status).loading === 'boolean'\n && 'error' in value && ((value as Status).error === null || (value as Status).error instanceof Error);\n};\n\nexport const isLoadable = (value : unknown) : value is Loadable<unknown> => {\n if (!(typeof value === 'object' && value !== null)) {\n return false;\n }\n \n return itemKey in value\n && statusKey in value && typeof (value as { [statusKey] : unknown })[statusKey] === 'object'\n && constructKey in value && typeof (value as { [constructKey] : unknown })[constructKey] === 'function';\n};\n\n\n/*\nLoadableRecord: simple resource implementation that just stores the item and status in a plain object. Also\nexposes these as regular (non-symbol) properties (so you can access them simply as `res.item` and `res.status`).\n*/\nexport type LoadableRecordT<T> = Loadable<T> & { item : undefined | T, status : Status };\nexport const LoadableRecord = <T>(item ?: undefined | T, status : Partial<Status> = {}) : LoadableRecordT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n const loadable : LoadableRecordT<T> = {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableRecord,\n \n // Also expose as regular (non-symbol) keys\n item,\n status: statusWithDefaults,\n };\n \n return loadable;\n};\n\n\n/*\nLoadableProxy: resource implementation that uses a Proxy, in order to expose an interface that appears the same\nas the item itself (status is \"hidden\" using a symbol key).\n*/\nexport type LoadableProxyT<T extends Proxyable> = Loadable<T>\n & (T extends undefined ? ProxyableExternal<null> : ProxyableExternal<T>);\nexport const LoadableProxy = <T extends Proxyable>(\n item ?: undefined | T,\n status : Partial<Status> = {}\n ) : LoadableProxyT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n // Prevent proxying multiple times (to prevent bugs where an object is repeatedly proxied over and over)\n if (extend.is(item)) {\n throw new TypeError($msg`Cannot create a LoadableProxy from an item which is already a LoadableProxy`);\n \n // TODO: maybe just unwrap the given proxy and override the status?\n //const { extension: { [itemKey]: _item, [statusKey]: _status } } = extend.unwrap(item);\n }\n \n // If the item itself is a loadable resource, return it as is?\n // (Alternatively, unwrap it and convert to a LoadableProxy instead)\n //if (isLoadable(item)) {\n // return item;\n //}\n \n const itemProxyable = typeof item === 'undefined' ? null : item;\n \n if (!isProxyable(itemProxyable)) {\n throw new TypeError(`Cannot proxy the given value: ${itemProxyable}`);\n }\n \n return extend(itemProxyable, {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableProxy,\n }) as unknown as LoadableProxyT<T>;\n };\n\n\n// Updater methods\n\nexport const update = <T>(resource : Loadable<T>, item : undefined | T, status : Partial<Status> = {}) =>\n resource[constructKey](item, { ...resource[statusKey], ...status });\nexport const updateItem = <T>(resource : Loadable<T>, item : undefined | T) =>\n resource[constructKey](item, resource[statusKey]);\nexport const updateStatus = <T>(resource : Loadable<T>, status : Partial<Status> = {}) =>\n resource[constructKey](resource[itemKey], { ...resource[statusKey], ...status });\n\nexport const asPending = <T>(resource : Loadable<T>) =>\n update(resource, undefined, { ready: false, loading: false, error: null })\nexport const asLoading = <T>(resource : Loadable<T>) =>\n updateStatus(resource, { loading: true }); // TODO: should we also clear any error here?\nexport const asReady = <T>(resource : Loadable<T>, item ?: T) => update(resource,\n typeof item === 'undefined' ? resource[itemKey] : item, // `item` is optional, if not present use existing\n { ready: true, loading: false, error: null }\n);\nexport const asFailed = <T>(resource : Loadable<T>, reason : Error) =>\n updateStatus(resource, { loading: false, error: reason });\n"],"file":"Loadable.js"}
{"version":3,"sources":["../../src/interfaces/Loadable.ts"],"names":["defaultStatus","ready","loading","error","itemKey","Symbol","for","statusKey","constructKey","isStatus","value","Error","isLoadable","LoadableRecord","item","status","TypeError","statusWithDefaults","loadable","LoadableProxy","extend","is","itemProxyable","update","resource","updateItem","updateStatus","asPending","undefined","asLoading","asReady","asFailed","reason"],"mappings":";;;;;;;AACA;;AACA;;;;;;;;AAiCA,MAAMA,aAAsB,GAAG;AAAEC,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,OAAO,EAAE,KAAzB;AAAgCC,EAAAA,KAAK,EAAE;AAAvC,CAA/B,C,CAGA;;AACO,MAAMC,OAAsB,GAAGC,MAAM,CAACC,GAAP,CAAW,yBAAX,CAA/B;;AACA,MAAMC,SAAwB,GAAGF,MAAM,CAACC,GAAP,CAAW,2BAAX,CAAjC;;AACA,MAAME,YAA2B,GAAGH,MAAM,CAACC,GAAP,CAAW,8BAAX,CAApC,C,CAEP;;;;AASO,MAAMG,QAAQ,GAAIC,KAAD,IAAuC;AAC3D,MAAI,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,KAAK,IAA3C,EAAiD;AAC7C,WAAO,KAAP;AACH;;AAED,SAAO,WAAWA,KAAX,IAAoB,OAAQA,KAAD,CAAkBT,KAAzB,KAAmC,SAAvD,IACA,aAAaS,KADb,IACsB,OAAQA,KAAD,CAAkBR,OAAzB,KAAqC,SAD3D,IAEA,WAAWQ,KAFX,KAEsBA,KAAD,CAAkBP,KAAlB,KAA4B,IAA5B,IAAqCO,KAAD,CAAkBP,KAAlB,YAAmCQ,KAF5F,CAAP;AAGH,CARM;;;;AAUA,MAAMC,UAAU,GAAIF,KAAD,IAAkD;AACxE,MAAI,EAAE,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,KAAK,IAAzC,CAAJ,EAAoD;AAChD,WAAO,KAAP;AACH;;AAED,SAAON,OAAO,IAAIM,KAAX,IACAH,SAAS,IAAIG,KADb,IACsB,OAAQA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AAE,KAAzB;AAAgCC,EAAAA,KAAK,EAAE;AAAvC,CAAtB,CADH;;;;AAEA,MAAM0B,SAAS,GAAOL,QAAJ,IACrBE,YAAY,CAACF,QAAD,EAAW;AAAEtB,EAAAA,OAAO,EAAE;AAAX,CAAX,CADT,C,CACwC;;;;;AACxC,MAAM4B,OAAO,GAAG,CAAIN,QAAJ,EAA4BV,IAA5B,KAA0CS,MAAM,CAACC,QAAD,EACnE,OAAOV,IAAP,KAAgB,WAAhB,GAA8BU,QAAQ,CAACpB,OAAD,CAAtC,GAAkDU,IADiB,EACX;AACxD;AAAEb,EAAAA,KAAK,EAAE,IAAT;AAAeC,EAAAA,OAAO,EAAE,KAAxB;AAA+BC,EAAAA,KAAK,EAAE;AAAtC,CAFmE,CAAhE;;;;AAIA,MAAM4B,QAAQ,GAAG,CAAIP,QAAJ,EAA4BQ,MAA5B,KACpBN,YAAY,CAACF,QAAD,EAAW;AAAEtB,EAAAA,OAAO,EAAE,KAAX;AAAkBC,EAAAA,KAAK,EAAE6B;AAAzB,CAAX,CADT","sourcesContent":["\nimport $msg from 'message-tag';\nimport extend, { isProxyable } from 'proxy-extend';\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\n\n\n// An *item* is the data part of a resource (can be anything).\nexport type Item = unknown;\n\n/*\nA *status* is an object that describes the current loading state of some resource.\n\nStatus flags:\n - ready: indicates whether this resource can be used or not (whether the data can be read safely)\n - loading: indicates whether we are currently in the process of loading this resource\n - error: indicates that the last load attempt resulted in an error\n\nNote that each of the flags is independent, rather than being a linear transition (e.g. loading -> ready).\nThis is so that we can, for example, start loading new data while keeping information such as an error\nstate, for UI purposes. All the possible combinations listed below.\n\n- !ready + !loading + !error \"pending\", nothing done yet, not even attempted to load\n- !ready + loading + !error \"loading\", for the first time, no older data available\n- ready + !loading + !error \"ready\" (or \"idle\"), can use the data as needed\n- ready + loading + !error \"ready\" (or \"reloading\"), ready but also loading an updated version\n- !ready + !loading + error \"failed\", and not yet any attempt to retry (no older data available)\n- !ready + loading + error \"failed\", but we're currently retrying (no older data available)\n- ready + !loading + error \"failed\", and not yet any attempt to retry (there is older data available)\n- ready + loading + error \"failed\", but we're currently retrying (there is older data available)\n*/\nexport type Status = {\n ready : boolean,\n loading : boolean,\n error : null | Error,\n};\nconst defaultStatus : Status = { ready: false, loading: false, error: null };\n\n\n// Property key symbols\nexport const itemKey: unique symbol = Symbol.for('lifecycle.loadable.item');\nexport const statusKey: unique symbol = Symbol.for('lifecycle.loadable.status');\nexport const constructKey: unique symbol = Symbol.for('lifecycle.loadable.construct');\n\n// A *resource* (or \"Loadable\") is an object that has both an item and a status.\nexport type Loadable<T> = {\n [itemKey] : undefined | T, // May be `undefined` when status is not ready (if ready *must not* be `undefined`)\n [statusKey] : Status,\n \n // Construct a new resource from this one, using the given item and status\n [constructKey] : (item : undefined | T, status : Status) => Loadable<T>,\n};\n\nexport const isStatus = (value : unknown) : value is Status => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n \n return 'ready' in value && typeof (value as Status).ready === 'boolean'\n && 'loading' in value && typeof (value as Status).loading === 'boolean'\n && 'error' in value && ((value as Status).error === null || (value as Status).error instanceof Error);\n};\n\nexport const isLoadable = (value : unknown) : value is Loadable<unknown> => {\n if (!(typeof value === 'object' && value !== null)) {\n return false;\n }\n \n return itemKey in value\n && statusKey in value && typeof (value as { [statusKey] : unknown })[statusKey] === 'object'\n && constructKey in value && typeof (value as { [constructKey] : unknown })[constructKey] === 'function';\n};\n\n\n/*\nLoadableRecord: simple resource implementation that just stores the item and status in a plain object. Also\nexposes these as regular (non-symbol) properties (so you can access them simply as `res.item` and `res.status`).\n*/\nexport type LoadableRecordT<T> = Loadable<T> & { item : undefined | T, status : Status };\nexport const LoadableRecord = <T>(item ?: undefined | T, status : Partial<Status> = {}) : LoadableRecordT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n const loadable : LoadableRecordT<T> = {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableRecord,\n \n // Also expose as regular (non-symbol) keys\n item,\n status: statusWithDefaults,\n };\n \n return loadable;\n};\n\n\n/*\nLoadableProxy: resource implementation that uses a Proxy, in order to expose an interface that appears the same\nas the item itself (status is \"hidden\" using a symbol key).\n*/\nexport type LoadableProxyT<T extends Proxyable> = Loadable<T>\n & (T extends undefined ? ProxyableExternal<null> : ProxyableExternal<T>);\nexport const LoadableProxy = <T extends Proxyable>(\n item ?: undefined | T,\n status : Partial<Status> = {}\n ) : LoadableProxyT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n // Prevent proxying multiple times (to prevent bugs where an object is repeatedly proxied over and over)\n if (extend.is(item)) {\n throw new TypeError($msg`Cannot create a LoadableProxy from an item which is already a LoadableProxy`);\n \n // TODO: maybe just unwrap the given proxy and override the status?\n //const { extension: { [itemKey]: _item, [statusKey]: _status } } = extend.unwrap(item);\n }\n \n // If the item itself is a loadable resource, return it as is?\n // (Alternatively, unwrap it and convert to a LoadableProxy instead)\n //if (isLoadable(item)) {\n // return item;\n //}\n \n const itemProxyable = typeof item === 'undefined' ? null : item;\n \n if (!isProxyable(itemProxyable)) {\n throw new TypeError(`Cannot proxy the given value: ${itemProxyable}`);\n }\n \n return extend(itemProxyable, {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableProxy,\n }) as unknown as LoadableProxyT<T>;\n };\n\n\n// Updater methods\n\nexport const update = <T>(resource : Loadable<T>, item : undefined | T, status : Partial<Status> = {}) =>\n resource[constructKey](item, { ...resource[statusKey], ...status });\nexport const updateItem = <T>(resource : Loadable<T>, item : undefined | T) =>\n resource[constructKey](item, resource[statusKey]);\nexport const updateStatus = <T>(resource : Loadable<T>, status : Partial<Status> = {}) =>\n resource[constructKey](resource[itemKey], { ...resource[statusKey], ...status });\n\nexport const asPending = <T>(resource : Loadable<T>) =>\n update(resource, undefined, { ready: false, loading: false, error: null })\nexport const asLoading = <T>(resource : Loadable<T>) =>\n updateStatus(resource, { loading: true }); // TODO: should we also clear any error here?\nexport const asReady = <T>(resource : Loadable<T>, item ?: T) => update(resource,\n typeof item === 'undefined' ? resource[itemKey] : item, // `item` is optional, if not present use existing\n { ready: true, loading: false, error: null }\n);\nexport const asFailed = <T>(resource : Loadable<T>, reason : Error) =>\n updateStatus(resource, { loading: false, error: reason });\n"],"file":"Loadable.js"}

@@ -8,4 +8,7 @@ import { isProxyable } from 'proxy-extend';

item: LoadableDefs.itemKey,
// Prevent widening to `symbol`
status: LoadableDefs.statusKey,
// Prevent widening to `symbol`
construct: LoadableDefs.constructKey,
// Prevent widening to `symbol`
isStatus: LoadableDefs.isStatus,

@@ -29,3 +32,4 @@ isLoadable: LoadableDefs.isLoadable,

export const status = LoadableDefs.statusKey;
export const status = LoadableDefs.statusKey; // Prevent widening to `symbol`
export const isStatus = LoadableDefs.isStatus;

@@ -32,0 +36,0 @@ export const isLoadable = LoadableDefs.isLoadable; // Utilities

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"names":["isProxyable","LoadableDefs","LoaderDefs","Loadable","Object","assign","item","status","LoadableProxy","itemKey","statusKey","construct","constructKey","isStatus","isLoadable","Record","LoadableRecord","Proxy","getItem","resource","getStatus","update","updateItem","updateStatus","asPending","asLoading","asReady","asF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AO,MAAMpB,MAAM,GAAGN,YAAY,CAACS,SAA5B;AACP,OAAO,MAAMG,QAAQ,GAAGZ,YAAY,CAACY,QAA9B;AACP,OAAO,MAAMC,UAAU,GAAGb,YAAY,CAACa,UAAhC,C,CAEP;;AACA,SAASd,WAAT;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAM4B,MAAM,GAAG;AAClBT,EAAAA,QAAQ,EAAEjB,UAAU,CAAC2B,WADH;AAElBC,EAAAA,WAAW,EAAE5B,UAAU,CAAC4B;AAFN,CAAf;AAOP,eAAe3B,QAAf","sourcesContent":["\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\nimport { isProxyable } from 'proxy-extend';\n\nimport * as LoadableDefs from './interfaces/Loadable.js';\nimport * as LoaderDefs from './interfaces/Loader.js';\n\n\nexport type Status = LoadableDefs.Status;\nexport type Loadable<T> = LoadableDefs.Loadable<T>;\nexport type { Proxyable };\nexport type LoadableProxy<T extends Proxyable> = LoadableDefs.LoadableProxyT<T>;\n\n// Wrap up the definitions in a single `Loadable` object, which can also be invocated as a function (uses Proxy)\nexport const Loadable = Object.assign(\n <T extends Proxyable>(item ?: undefined | T, status : Partial<LoadableDefs.Status> = {}) =>\n LoadableDefs.LoadableProxy(item, status),\n {\n // Keys\n item: LoadableDefs.itemKey,\n status: LoadableDefs.statusKey,\n construct: LoadableDefs.constructKey,\n \n isStatus: LoadableDefs.isStatus,\n isLoadable: LoadableDefs.isLoadable,\n \n // Constructors\n Record: LoadableDefs.LoadableRecord,\n Proxy: LoadableDefs.LoadableProxy,\n \n // Accessor functions\n getItem: <T>(resource : Loadable<T>) => resource[LoadableDefs.itemKey],\n getStatus: <T>(resource : Loadable<T>) => resource[LoadableDefs.statusKey],\n \n // Updater functions\n update: LoadableDefs.update,\n updateItem: LoadableDefs.updateItem,\n updateStatus: LoadableDefs.updateStatus,\n asPending: LoadableDefs.asPending,\n asLoading: LoadableDefs.asLoading,\n asReady: LoadableDefs.asReady,\n asFailed: LoadableDefs.asFailed,\n },\n);\n\n// Shorthand exports\nexport const status = LoadableDefs.statusKey;\nexport const isStatus = LoadableDefs.isStatus;\nexport const isLoadable = LoadableDefs.isLoadable;\n\n// Utilities\nexport { isProxyable };\n\n\n/*\nexport {\n LoadError,\n LoadablePromise,\n};\n\nexport const loader = <T>(\n item : Loadable<T>,\n executor : (resolve : (item : Loadable<T>) => void, reject : (item : Loadable<T>) => void) => void,\n ) =>\n new LoadablePromise(executor, item);\n*/\n\nexport const Loader = {\n resource: LoaderDefs.resourceKey,\n fromPromise: LoaderDefs.fromPromise,\n};\n\nexport type PromiseWithResource<T> = LoaderDefs.PromiseWithResource<T>;\n\nexport default Loadable;\n"],"file":"index.js"}
{"version":3,"sources":["../src/index.ts"],"names":["isProxyable","LoadableDefs","LoaderDefs","Loadable","Object","assign","item","status","LoadableProxy","itemKey","statusKey","construct","constructKey","isStatus","isLoadable","Record","LoadableRecord","Proxy","getItem","resource","getStatus","update","updateItem","updateStatus","asPending","asLoading","asReady","asFailed","Loader","resourceKey","fromPromise"],"mappings":"AAEA,SAASA,WAAT,QAA4B,cAA5B;AAEA,OAAO,KAAKC,YAAZ,MAA8B,0BAA9B;AACA,OAAO,KAAKC,UAAZ,MAA4B,wBAA5B;AAQA;AACA,OAAO,MAAMC,QAAQ,GAAGC,MAAM,CAACC,MAAP,CACpB,CAAsBC,IAAtB,EAA6CC,MAAqC,GAAG,EAArF,KACIN,YAAY,CAACO,aAAb,CAA2BF,IAA3B,EAAiCC,MAAjC,CAFgB,EAGpB;AACI;AACAD,EAAAA,IAAI,EAAEL,YAAY,CAACQ,OAFvB;AAEgE;AAC5DF,EAAAA,MAAM,EAAEN,YAAY,CAACS,SAHzB;AAGsE;AAClEC,EAAAA,SAAS,EAAEV,YAAY,CAACW,YAJ5B;AAI+E;AAE3EC,EAAAA,QAAQ,EAAEZ,YAAY,CAACY,QAN3B;AAOIC,EAAAA,UAAU,EAAEb,YAAY,CAACa,UAP7B;AASI;AACAC,EAAAA,MAAM,EAAEd,YAAY,CAACe,cAVzB;AAWIC,EAAAA,KAAK,EAAEhB,YAAY,CAACO,aAXxB;AAaI;AACAU,EAAAA,OAAO,EAAMC,QAAJ,IAA+BA,QAAQ,CAAClB,YAAY,CAACQ,OAAd,CAdpD;AAeIW,EAAAA,SAAS,EAAMD,QAAJ,IAA+BA,QAAQ,CAAClB,YAAY,CAACS,SAAd,CAftD;AAiBI;AACAW,EAAAA,MAAM,EAAEpB,YAAY,CAACoB,MAlBzB;AAmBIC,EAAAA,UAAU,EAAErB,YAAY,CAACqB,UAnB7B;AAoBIC,EAAAA,YAAY,EAAEtB,YAAY,CAACsB,YApB/B;AAqBIC,EAAAA,SAAS,EAAEvB,YAAY,CAACuB,SArB5B;AAsBIC,EAAAA,SAAS,EAAExB,YAAY,CAACwB,SAtB5B;AAuBIC,EAAAA,OAAO,EAAEzB,YAAY,CAACyB,OAvB1B;AAwBIC,EAAAA,QAAQ,EAAE1B,YAAY,CAAC0B;AAxB3B,CAHoB,CAAjB,C,CA+BP;;AACA,OAAO,MAAMpB,MAAqC,GAAGN,YAAY,CAACS,SAA3D,C,CAAsE;;AAC7E,OAAO,MAAMG,QAAQ,GAAGZ,YAAY,CAACY,QAA9B;AACP,OAAO,MAAMC,UAAU,GAAGb,YAAY,CAACa,UAAhC,C,CAEP;;AACA,SAASd,WAAT;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAM4B,MAAM,GAAG;AAClBT,EAAAA,QAAQ,EAAEjB,UAAU,CAAC2B,WADH;AAElBC,EAAAA,WAAW,EAAE5B,UAAU,CAAC4B;AAFN,CAAf;AAOP,eAAe3B,QAAf","sourcesContent":["\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\nimport { isProxyable } from 'proxy-extend';\n\nimport * as LoadableDefs from './interfaces/Loadable.js';\nimport * as LoaderDefs from './interfaces/Loader.js';\n\n\nexport type Status = LoadableDefs.Status;\nexport type Loadable<T> = LoadableDefs.Loadable<T>;\nexport type { Proxyable };\nexport type LoadableProxy<T extends Proxyable> = LoadableDefs.LoadableProxyT<T>;\n\n// Wrap up the definitions in a single `Loadable` object, which can also be invocated as a function (uses Proxy)\nexport const Loadable = Object.assign(\n <T extends Proxyable>(item ?: undefined | T, status : Partial<LoadableDefs.Status> = {}) =>\n LoadableDefs.LoadableProxy(item, status),\n {\n // Keys\n item: LoadableDefs.itemKey as typeof LoadableDefs.itemKey, // Prevent widening to `symbol`\n status: LoadableDefs.statusKey as typeof LoadableDefs.statusKey, // Prevent widening to `symbol`\n construct: LoadableDefs.constructKey as typeof LoadableDefs.constructKey, // Prevent widening to `symbol`\n \n isStatus: LoadableDefs.isStatus,\n isLoadable: LoadableDefs.isLoadable,\n \n // Constructors\n Record: LoadableDefs.LoadableRecord,\n Proxy: LoadableDefs.LoadableProxy,\n \n // Accessor functions\n getItem: <T>(resource : Loadable<T>) => resource[LoadableDefs.itemKey],\n getStatus: <T>(resource : Loadable<T>) => resource[LoadableDefs.statusKey],\n \n // Updater functions\n update: LoadableDefs.update,\n updateItem: LoadableDefs.updateItem,\n updateStatus: LoadableDefs.updateStatus,\n asPending: LoadableDefs.asPending,\n asLoading: LoadableDefs.asLoading,\n asReady: LoadableDefs.asReady,\n asFailed: LoadableDefs.asFailed,\n },\n);\n\n// Shorthand exports\nexport const status: typeof LoadableDefs.statusKey = LoadableDefs.statusKey; // Prevent widening to `symbol`\nexport const isStatus = LoadableDefs.isStatus;\nexport const isLoadable = LoadableDefs.isLoadable;\n\n// Utilities\nexport { isProxyable };\n\n\n/*\nexport {\n LoadError,\n LoadablePromise,\n};\n\nexport const loader = <T>(\n item : Loadable<T>,\n executor : (resolve : (item : Loadable<T>) => void, reject : (item : Loadable<T>) => void) => void,\n ) =>\n new LoadablePromise(executor, item);\n*/\n\nexport const Loader = {\n resource: LoaderDefs.resourceKey,\n fromPromise: LoaderDefs.fromPromise,\n};\n\nexport type PromiseWithResource<T> = LoaderDefs.PromiseWithResource<T>;\n\nexport default Loadable;\n"],"file":"index.js"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/interfaces/Loadable.ts"],"names":["$msg","extend","isProxyable","defaultStatus","ready","loading","error","itemKey","Symbol","for","statusKey","constructKey","isStatus","value","Error","isLoadable","LoadableRecord","item","status","TypeError","statusWithDefaults","loadable","LoadableProxy","is","itemProxyable","update","resource","updateItem","updateStatus","asPending","undefined","asLoading","asReady","asFailed","reason"],"mappings":"AACA,OAAOA,IAAP,MAAiB,aAAjB;AACA,OAAOC,MAAP,IAAiBC,WAAjB,QAAoC,cAApC;AAiCA,MAAMC,aAAsB,GAAG;AAAEC,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,OAAO,EAAE,KAAzB;AAAgCC,EAAAA,KAAK,EAAE;AAAvC,CAA/B,C,CAGA;;AACA,OAAO,MAAMC,OAAO,GAAGC,MAAM,CAACC,GAAP,CAAW,yBAAX,CAAhB;AACP,OAAO,MAAMC,SAAS,GAAGF,MAAM,CAACC,GAAP,CAAW,2BAAX,CAAlB;AACP,OAAO,MAAME,YAAY,GAAGH,MAAM,CAACC,GAAP,CAAW,8BAAX,CAArB,C,CAEP;;AASA,OAAO,MAAMG,QAAQ,GAAIC,KAAD,IAAuC;AAC3D,MAAI,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,KAAK,IAA3C,EAAiD;AAC7C,WAAO,KAAP;AACH;;AAED,SAAO,WAAWA,KAAX,IAAoB,OAAQA,KAAD,CAAkBT,KAAzB,KAAmC,SAAvD,IACA,aAAaS,KADb,IACsB,OAAQA,KAAD,CAAkBR,OAAzB,KAAqC,SAD3D,IAEA,WAAWQ,KAFX,KAEsBA,KAAD,CAAkBP,KAAlB,KAA4B,IAA5B,IAAqCO,KAAD,CAAkBP,KAAlB,YAAmCQ,KAF5F,CAAP;AAGH,CARM;AAUP,OAAO,MAAMC,UAAU,GAAIF,KAAD,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AAE,GAAGmB,QAAQ,CAAChB,SAAD,CAAb;AAA0B,KAAGQ;AAA7B,CAA1C,CADG;AAGP,OAAO,MAAMW,SAAS,GAAOH,QAAJ,IACrBD,MAAM,CAACC,QAAD,EAAWI,SAAX,EAAsB;AAAE1B,EAAAA,KAAK,EAAE,KAAT;AAAgBC,EAAAA,OAAO,EAAE,KAAzB;AAAgCC,EAAAA,KAAK,EAAE;AAAvC,CAAtB,CADH;AAEP,OAAO,MAAMyB,SAAS,GAAOL,QAAJ,IACrBE,YAAY,CAACF,QAAD,EAAW;AAAErB,EAAAA,OAAO,EAAE;AAAX,CAAX,CADT,C,CACwC;;AAC/C,OAAO,MAAM2B,OAAO,GAAG,CAAIN,QAAJ,EAA4BT,IAA5B,KAA0CQ,MAAM,CAACC,QAAD,EACnE,OAAOT,IAAP,KAAgB,WAAhB,GAA8BS,QAAQ,CAACnB,OAAD,CAAtC,GAAkDU,IADiB,EACX;AACxD;AAAEb,EAAAA,KAAK,EAAE,IAAT;AAAeC,EAAAA,OAAO,EAAE,KAAxB;AAA+BC,EAAAA,KAAK,EAAE;AAAtC,CAFmE,CAAhE;AAIP,OAAO,MAAM2B,QAAQ,GAAG,CAAIP,QAAJ,EAA4BQ,MAA5B,KACpBN,YAAY,CAACF,QAAD,EAAW;AAAErB,EAAAA,OAAO,EAAE,KAAX;AAAkBC,EAAAA,KAAK,EAAE4B;AAAzB,CAAX,CADT","sourcesContent":["\nimport $msg from 'message-tag';\nimport extend, { isProxyable } from 'proxy-extend';\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\n\n\n// An *item* is the data part of a resource (can be anything).\nexport type Item = unknown;\n\n/*\nA *status* is an object that describes the current loading state of some resource.\n\nStatus flags:\n - ready: indicates whether this resource can be used or not (whether the data can be read safely)\n - loading: indicates whether we are currently in the process of loading this resource\n - error: indicates that the last load attempt resulted in an error\n\nNote that each of the flags is independent, rather than being a linear transition (e.g. loading -> ready).\nThis is so that we can, for example, start loading new data while keeping information such as an error\nstate, for UI purposes. All the possible combinations listed below.\n\n- !ready + !loading + !error \"pending\", nothing done yet, not even attempted to load\n- !ready + loading + !error \"loading\", for the first time, no older data available\n- ready + !loading + !error \"ready\" (or \"idle\"), can use the data as needed\n- ready + loading + !error \"ready\" (or \"reloading\"), ready but also loading an updated version\n- !ready + !loading + error \"failed\", and not yet any attempt to retry (no older data available)\n- !ready + loading + error \"failed\", but we're currently retrying (no older data available)\n- ready + !loading + error \"failed\", and not yet any attempt to retry (there is older data available)\n- ready + loading + error \"failed\", but we're currently retrying (there is older data available)\n*/\nexport type Status = {\n ready : boolean,\n loading : boolean,\n error : null | Error,\n};\nconst defaultStatus : Status = { ready: false, loading: false, error: null };\n\n\n// Property key symbols\nexport const itemKey = Symbol.for('lifecycle.loadable.item');\nexport const statusKey = Symbol.for('lifecycle.loadable.status');\nexport const constructKey = Symbol.for('lifecycle.loadable.construct');\n\n// A *resource* (or \"Loadable\") is an object that has both an item and a status.\nexport type Loadable<T> = {\n [itemKey] : undefined | T, // May be `undefined` when status is not ready (if ready *must not* be `undefined`)\n [statusKey] : Status,\n \n // Construct a new resource from this one, using the given item and status\n [constructKey] : (item : undefined | T, status : Status) => Loadable<T>,\n};\n\nexport const isStatus = (value : unknown) : value is Status => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n \n return 'ready' in value && typeof (value as Status).ready === 'boolean'\n && 'loading' in value && typeof (value as Status).loading === 'boolean'\n && 'error' in value && ((value as Status).error === null || (value as Status).error instanceof Error);\n};\n\nexport const isLoadable = (value : unknown) : value is Loadable<unknown> => {\n if (!(typeof value === 'object' && value !== null)) {\n return false;\n }\n \n return itemKey in value\n && statusKey in value && typeof (value as { [statusKey] : unknown })[statusKey] === 'object'\n && constructKey in value && typeof (value as { [constructKey] : unknown })[constructKey] === 'function';\n};\n\n\n/*\nLoadableRecord: simple resource implementation that just stores the item and status in a plain object. Also\nexposes these as regular (non-symbol) properties (so you can access them simply as `res.item` and `res.status`).\n*/\nexport type LoadableRecordT<T> = Loadable<T> & { item : undefined | T, status : Status };\nexport const LoadableRecord = <T>(item ?: undefined | T, status : Partial<Status> = {}) : LoadableRecordT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n const loadable : LoadableRecordT<T> = {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableRecord,\n \n // Also expose as regular (non-symbol) keys\n item,\n status: statusWithDefaults,\n };\n \n return loadable;\n};\n\n\n/*\nLoadableProxy: resource implementation that uses a Proxy, in order to expose an interface that appears the same\nas the item itself (status is \"hidden\" using a symbol key).\n*/\nexport type LoadableProxyT<T extends Proxyable> = Loadable<T>\n & (T extends undefined ? ProxyableExternal<null> : ProxyableExternal<T>);\nexport const LoadableProxy = <T extends Proxyable>(\n item ?: undefined | T,\n status : Partial<Status> = {}\n ) : LoadableProxyT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n // Prevent proxying multiple times (to prevent bugs where an object is repeatedly proxied over and over)\n if (extend.is(item)) {\n throw new TypeError($msg`Cannot create a LoadableProxy from an item which is already a LoadableProxy`);\n \n // TODO: maybe just unwrap the given proxy and override the status?\n //const { extension: { [itemKey]: _item, [statusKey]: _status } } = extend.unwrap(item);\n }\n \n // If the item itself is a loadable resource, return it as is?\n // (Alternatively, unwrap it and convert to a LoadableProxy instead)\n //if (isLoadable(item)) {\n // return item;\n //}\n \n const itemProxyable = typeof item === 'undefined' ? null : item;\n \n if (!isProxyable(itemProxyable)) {\n throw new TypeError(`Cannot proxy the given value: ${itemProxyable}`);\n }\n \n return extend(itemProxyable, {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableProxy,\n }) as unknown as LoadableProxyT<T>;\n };\n\n\n// Updater methods\n\nexport const update = <T>(resource : Loadable<T>, item : undefined | T, status : Partial<Status> = {}) =>\n resource[constructKey](item, { ...resource[statusKey], ...status });\nexport const updateItem = <T>(resource : Loadable<T>, item : undefined | T) =>\n resource[constructKey](item, resource[statusKey]);\nexport const updateStatus = <T>(resource : Loadable<T>, status : Partial<Status> = {}) =>\n resource[constructKey](resource[itemKey], { ...resource[statusKey], ...status });\n\nexport const asPending = <T>(resource : Loadable<T>) =>\n update(resource, undefined, { ready: false, loading: false, error: null })\nexport const asLoading = <T>(resource : Loadable<T>) =>\n updateStatus(resource, { loading: true }); // TODO: should we also clear any error here?\nexport const asReady = <T>(resource : Loadable<T>, item ?: T) => update(resource,\n typeof item === 'undefined' ? resource[itemKey] : item, // `item` is optional, if not present use existing\n { ready: true, loading: false, error: null }\n);\nexport const asFailed = <T>(resource : Loadable<T>, reason : Error) =>\n updateStatus(resource, { loading: false, error: reason });\n"],"file":"Loadable.js"}
{"version":3,"sources":["../../src/interfaces/Loadable.ts"],"names":["$msg","extend","isProxyable","defaultStatus","ready","loading","error","itemKey","Symbol","for","statusKey","constructKey","isStatus","value","Error","isLoadable","LoadableRecord","item","status","TypeError","statusWithDefaults","loadable","LoadableProxy","is","itemProxyable","update","resource","updateItem","updateStatus","asPending","undefined","asLoading","asReady","asFailed","reason"],"mappings":"AACA,OAAOA,IAAP,MAAiB,aAAjB;AACA,OAAOC,MAAP,IAAiBC,WAAjB,QAAoC,cAApC;AAiCA,MAAMC,aAAsB,GAAG;AAAEC,EAAAA,KAA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,IAA5B,KAA0CQ,MAAM,CAACC,QAAD,EACnE,OAAOT,IAAP,KAAgB,WAAhB,GAA8BS,QAAQ,CAACnB,OAAD,CAAtC,GAAkDU,IADiB,EACX;AACxD;AAAEb,EAAAA,KAAK,EAAE,IAAT;AAAeC,EAAAA,OAAO,EAAE,KAAxB;AAA+BC,EAAAA,KAAK,EAAE;AAAtC,CAFmE,CAAhE;AAIP,OAAO,MAAM2B,QAAQ,GAAG,CAAIP,QAAJ,EAA4BQ,MAA5B,KACpBN,YAAY,CAACF,QAAD,EAAW;AAAErB,EAAAA,OAAO,EAAE,KAAX;AAAkBC,EAAAA,KAAK,EAAE4B;AAAzB,CAAX,CADT","sourcesContent":["\nimport $msg from 'message-tag';\nimport extend, { isProxyable } from 'proxy-extend';\nimport type { Proxyable, ProxyableExternal } from 'proxy-extend';\n\n\n// An *item* is the data part of a resource (can be anything).\nexport type Item = unknown;\n\n/*\nA *status* is an object that describes the current loading state of some resource.\n\nStatus flags:\n - ready: indicates whether this resource can be used or not (whether the data can be read safely)\n - loading: indicates whether we are currently in the process of loading this resource\n - error: indicates that the last load attempt resulted in an error\n\nNote that each of the flags is independent, rather than being a linear transition (e.g. loading -> ready).\nThis is so that we can, for example, start loading new data while keeping information such as an error\nstate, for UI purposes. All the possible combinations listed below.\n\n- !ready + !loading + !error \"pending\", nothing done yet, not even attempted to load\n- !ready + loading + !error \"loading\", for the first time, no older data available\n- ready + !loading + !error \"ready\" (or \"idle\"), can use the data as needed\n- ready + loading + !error \"ready\" (or \"reloading\"), ready but also loading an updated version\n- !ready + !loading + error \"failed\", and not yet any attempt to retry (no older data available)\n- !ready + loading + error \"failed\", but we're currently retrying (no older data available)\n- ready + !loading + error \"failed\", and not yet any attempt to retry (there is older data available)\n- ready + loading + error \"failed\", but we're currently retrying (there is older data available)\n*/\nexport type Status = {\n ready : boolean,\n loading : boolean,\n error : null | Error,\n};\nconst defaultStatus : Status = { ready: false, loading: false, error: null };\n\n\n// Property key symbols\nexport const itemKey: unique symbol = Symbol.for('lifecycle.loadable.item');\nexport const statusKey: unique symbol = Symbol.for('lifecycle.loadable.status');\nexport const constructKey: unique symbol = Symbol.for('lifecycle.loadable.construct');\n\n// A *resource* (or \"Loadable\") is an object that has both an item and a status.\nexport type Loadable<T> = {\n [itemKey] : undefined | T, // May be `undefined` when status is not ready (if ready *must not* be `undefined`)\n [statusKey] : Status,\n \n // Construct a new resource from this one, using the given item and status\n [constructKey] : (item : undefined | T, status : Status) => Loadable<T>,\n};\n\nexport const isStatus = (value : unknown) : value is Status => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n \n return 'ready' in value && typeof (value as Status).ready === 'boolean'\n && 'loading' in value && typeof (value as Status).loading === 'boolean'\n && 'error' in value && ((value as Status).error === null || (value as Status).error instanceof Error);\n};\n\nexport const isLoadable = (value : unknown) : value is Loadable<unknown> => {\n if (!(typeof value === 'object' && value !== null)) {\n return false;\n }\n \n return itemKey in value\n && statusKey in value && typeof (value as { [statusKey] : unknown })[statusKey] === 'object'\n && constructKey in value && typeof (value as { [constructKey] : unknown })[constructKey] === 'function';\n};\n\n\n/*\nLoadableRecord: simple resource implementation that just stores the item and status in a plain object. Also\nexposes these as regular (non-symbol) properties (so you can access them simply as `res.item` and `res.status`).\n*/\nexport type LoadableRecordT<T> = Loadable<T> & { item : undefined | T, status : Status };\nexport const LoadableRecord = <T>(item ?: undefined | T, status : Partial<Status> = {}) : LoadableRecordT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n const loadable : LoadableRecordT<T> = {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableRecord,\n \n // Also expose as regular (non-symbol) keys\n item,\n status: statusWithDefaults,\n };\n \n return loadable;\n};\n\n\n/*\nLoadableProxy: resource implementation that uses a Proxy, in order to expose an interface that appears the same\nas the item itself (status is \"hidden\" using a symbol key).\n*/\nexport type LoadableProxyT<T extends Proxyable> = Loadable<T>\n & (T extends undefined ? ProxyableExternal<null> : ProxyableExternal<T>);\nexport const LoadableProxy = <T extends Proxyable>(\n item ?: undefined | T,\n status : Partial<Status> = {}\n ) : LoadableProxyT<T> => {\n // If the status is ready, then `item` cannot be `undefined`\n if (status.ready === true && typeof item === 'undefined') {\n throw new TypeError('Expected an item, but given `undefined`');\n }\n \n // If the status is not ready, then `item` must be `undefined`\n //if (status.ready === false && typeof item !== 'undefined') {\n // throw new TypeError($msg`Expected \\`undefined\\`, but given ${item}`);\n //}\n \n const statusWithDefaults = {\n ...defaultStatus,\n ready: typeof item !== 'undefined',\n ...status,\n };\n \n // Prevent proxying multiple times (to prevent bugs where an object is repeatedly proxied over and over)\n if (extend.is(item)) {\n throw new TypeError($msg`Cannot create a LoadableProxy from an item which is already a LoadableProxy`);\n \n // TODO: maybe just unwrap the given proxy and override the status?\n //const { extension: { [itemKey]: _item, [statusKey]: _status } } = extend.unwrap(item);\n }\n \n // If the item itself is a loadable resource, return it as is?\n // (Alternatively, unwrap it and convert to a LoadableProxy instead)\n //if (isLoadable(item)) {\n // return item;\n //}\n \n const itemProxyable = typeof item === 'undefined' ? null : item;\n \n if (!isProxyable(itemProxyable)) {\n throw new TypeError(`Cannot proxy the given value: ${itemProxyable}`);\n }\n \n return extend(itemProxyable, {\n [itemKey]: item,\n [statusKey]: statusWithDefaults,\n [constructKey]: LoadableProxy,\n }) as unknown as LoadableProxyT<T>;\n };\n\n\n// Updater methods\n\nexport const update = <T>(resource : Loadable<T>, item : undefined | T, status : Partial<Status> = {}) =>\n resource[constructKey](item, { ...resource[statusKey], ...status });\nexport const updateItem = <T>(resource : Loadable<T>, item : undefined | T) =>\n resource[constructKey](item, resource[statusKey]);\nexport const updateStatus = <T>(resource : Loadable<T>, status : Partial<Status> = {}) =>\n resource[constructKey](resource[itemKey], { ...resource[statusKey], ...status });\n\nexport const asPending = <T>(resource : Loadable<T>) =>\n update(resource, undefined, { ready: false, loading: false, error: null })\nexport const asLoading = <T>(resource : Loadable<T>) =>\n updateStatus(resource, { loading: true }); // TODO: should we also clear any error here?\nexport const asReady = <T>(resource : Loadable<T>, item ?: T) => update(resource,\n typeof item === 'undefined' ? resource[itemKey] : item, // `item` is optional, if not present use existing\n { ready: true, loading: false, error: null }\n);\nexport const asFailed = <T>(resource : Loadable<T>, reason : Error) =>\n updateStatus(resource, { loading: false, error: reason });\n"],"file":"Loadable.js"}
{
"name": "@mkrause/lifecycle-loader",
"version": "0.3.0",
"version": "0.3.1",
"author": "mkrause",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -20,5 +20,5 @@

// Keys
item: LoadableDefs.itemKey,
status: LoadableDefs.statusKey,
construct: LoadableDefs.constructKey,
item: LoadableDefs.itemKey as typeof LoadableDefs.itemKey, // Prevent widening to `symbol`
status: LoadableDefs.statusKey as typeof LoadableDefs.statusKey, // Prevent widening to `symbol`
construct: LoadableDefs.constructKey as typeof LoadableDefs.constructKey, // Prevent widening to `symbol`

@@ -48,3 +48,3 @@ isStatus: LoadableDefs.isStatus,

// Shorthand exports
export const status = LoadableDefs.statusKey;
export const status: typeof LoadableDefs.statusKey = LoadableDefs.statusKey; // Prevent widening to `symbol`
export const isStatus = LoadableDefs.isStatus;

@@ -51,0 +51,0 @@ export const isLoadable = LoadableDefs.isLoadable;

@@ -40,5 +40,5 @@

// Property key symbols
export const itemKey = Symbol.for('lifecycle.loadable.item');
export const statusKey = Symbol.for('lifecycle.loadable.status');
export const constructKey = Symbol.for('lifecycle.loadable.construct');
export const itemKey: unique symbol = Symbol.for('lifecycle.loadable.item');
export const statusKey: unique symbol = Symbol.for('lifecycle.loadable.status');
export const constructKey: unique symbol = Symbol.for('lifecycle.loadable.construct');

@@ -45,0 +45,0 @@ // A *resource* (or "Loadable") is an object that has both an item and a status.

@@ -10,5 +10,5 @@ import type { Proxyable } from 'proxy-extend';

export declare const Loadable: (<T extends Proxyable>(item?: T | undefined, status?: Partial<LoadableDefs.Status>) => LoadableDefs.LoadableProxyT<T>) & {
item: symbol;
status: symbol;
construct: symbol;
item: typeof LoadableDefs.itemKey;
status: typeof LoadableDefs.statusKey;
construct: typeof LoadableDefs.constructKey;
isStatus: (value: unknown) => value is LoadableDefs.Status;

@@ -28,3 +28,3 @@ isLoadable: (value: unknown) => value is LoadableDefs.Loadable<unknown>;

};
export declare const status: symbol;
export declare const status: typeof LoadableDefs.statusKey;
export declare const isStatus: (value: unknown) => value is LoadableDefs.Status;

@@ -31,0 +31,0 @@ export declare const isLoadable: (value: unknown) => value is LoadableDefs.Loadable<unknown>;

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAGrD,oBAAY,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;AACzC,oBAAY,QAAQ,CAAC,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,CAAC;AAC1B,oBAAY,aAAa,CAAC,CAAC,SAAS,SAAS,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAGhF,eAAO,MAAM,QAAQ,wDACqC,QAAQ,mBAAmB,CAAC;;;;;;;;;;;;;;;;;CA4BrF,CAAC;AAGF,eAAO,MAAM,MAAM,QAAyB,CAAC;AAC7C,eAAO,MAAM,QAAQ,kDAAwB,CAAC;AAC9C,eAA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