From af1eec38627e0b3d2eac6cdf1793719b3881ea1f Mon Sep 17 00:00:00 2001 From: Andrey Konstantinov Date: Tue, 21 Sep 2021 11:11:17 +1200 Subject: [PATCH] build dist --- dist/index.es.js | 6 +++++- dist/index.es.js.map | 2 +- dist/index.js | 6 +++++- dist/index.js.map | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dist/index.es.js b/dist/index.es.js index 23a59500..ea901983 100644 --- a/dist/index.es.js +++ b/dist/index.es.js @@ -99,7 +99,11 @@ function useHookstate(source) { // Global state mount or destroyed link // eslint-disable-next-line react-hooks/rules-of-hooks var _b = React.useState({ state: parentMethods.state }), value_1 = _b[0], setValue_2 = _b[1]; - return useSubscribedStateMethods(value_1.state, parentMethods.path, function () { return setValue_2({ state: value_1.state }); }, value_1.state).self; + var state = useSubscribedStateMethods(value_1.state, RootPath, function () { return setValue_2({ state: value_1.state }); }, value_1.state).self; + for (var ind = 0; ind < parentMethods.path.length; ind += 1) { + state = state.nested(parentMethods.path[ind]); + } + return state; } } else { diff --git a/dist/index.es.js.map b/dist/index.es.js.map index bb0ea1df..ed3fd0a7 100644 --- a/dist/index.es.js.map +++ b/dist/index.es.js.map @@ -1 +1 @@ -{"version":3,"file":"index.es.js","sources":["../node_modules/tslib/tslib.es6.js","../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import React from 'react';\n\n///\n/// EXPORTED SYMBOLS (LIBRARY INTERFACE)\n///\n\n/**\n * 'JSON path' from root of a state object to a nested property.\n * Return type of [StateMethod.path](#readonly-path).\n *\n * For example, an object `{ a: [{ b: 1 }, { 1000: 'value' }, '3rd'] }`,\n * has got the following paths pointing to existing properties:\n *\n * - `[]`\n * - `['a']`\n * - `['a', 0]`\n * - `['a', 0, 'b']`\n * - `['a', 1]`\n * - `['a', 1, 1000]`\n * - `['a', 2]`\n */\nexport type Path = ReadonlyArray;\n\n/**\n * Type of an argument of [StateMethods.set](#set).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetStateAction = (S | Promise) | ((prevState: S) => (S | Promise));\n\n/**\n * Type of an argument of [StateMethods.merge](#merge).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetPartialStateAction =\n S extends ReadonlyArray<(infer U)> ?\n ReadonlyArray | Record | ((prevValue: S) => (ReadonlyArray | Record)) :\n S extends object | string ? Partial | ((prevValue: S) => Partial) :\n React.SetStateAction;\n\n/**\n * Type of an argument of [createState](#createstate) and [useState](#usestate).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetInitialStateAction = S | Promise | (() => S | Promise)\n\n/**\n * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function.\n * \n * [Learn more...](https://hookstate.js.org/docs/asynchronous-state#executing-an-action-when-state-is-loaded)\n */\nexport const postpone = Symbol('postpone')\n\n/**\n * Special symbol which might be used to delete properties\n * from an object calling [StateMethods.set](#set) or [StateMethods.merge](#merge).\n * \n * [Learn more...](https://hookstate.js.org/docs/nested-state#deleting-existing-element)\n */\nexport const none = Symbol('none') as StateValueAtPath;\n\n/**\n * Return type of [StateMethods.keys](#readonly-keys).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateKeysType =\n S extends ReadonlyArray ? ReadonlyArray :\n S extends null ? undefined :\n S extends object ? ReadonlyArray :\n undefined;\n\n/**\n * Return type of [StateMethods.map()](#map).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateOrnullType =\n S extends undefined ? undefined :\n S extends null ? null : State;\n\n/**\n * For plugin developers only.\n * An instance to manipulate the state in more controlled way.\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginStateControl {\n /**\n * Get state value, but do not leave the traces of reading it.\n */\n getUntracked(): S;\n /**\n * Set new state value, but do not trigger rerender.\n * \n * @param newValue new value to set to a state.\n */\n setUntracked(newValue: SetStateAction): Path[];\n /**\n * Merge new state value, but do not trigger rerender.\n * \n * @param mergeValue new partial value to merge with the current state value and set.\n */\n mergeUntracked(mergeValue: SetPartialStateAction): Path[];\n /**\n * Trigger rerender for hooked states, where values at the specified paths are used.\n * \n * @param paths paths of the state variables to search for being used by components and rerender\n */\n rerender(paths: Path[]): void;\n}\n\n/**\n * An interface to manage a state in Hookstate.\n * \n * @typeparam S Type of a value of a state\n */\nexport interface StateMethods {\n /**\n * 'Javascript' object 'path' to an element relative to the root object\n * in the state. For example:\n *\n * ```tsx\n * const state = useState([{ name: 'First Task' }])\n * state.path IS []\n * state[0].path IS [0]\n * state.[0].name.path IS [0, 'name']\n * ```\n */\n readonly path: Path;\n\n /**\n * Return the keys of nested states.\n * For a given state of [State](#state) type,\n * `state.keys` will be structurally equal to Object.keys(state),\n * with two minor difference:\n * 1. if `state.value` is an array, the returned result will be\n * an array of numbers, not strings like with `Object.keys`.\n * 2. if `state.value` is not an object, the returned result will be undefined.\n */\n readonly keys: InferredStateKeysType;\n\n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.get](#get) method.\n *\n * This property is more useful than [get](#get) method for the cases,\n * when a value may hold null or undefined values.\n * Typescript compiler does not handle elimination of undefined with get(),\n * like in the following examples, but value does:\n *\n * ```tsx\n * const state = useState(0)\n * const myvalue: number = state.value\n * ? state.value + 1\n * : 0; // <-- compiles\n * const myvalue: number = state.get()\n * ? state.get() + 1\n * : 0; // <-- does not compile\n * ```\n */\n readonly value: S;\n\n /**\n * True if state value is not yet available (eg. equal to a promise)\n */\n readonly promised: boolean;\n \n /**\n * If a state was set to a promise and the promise was rejected,\n * this property will return the error captured from the promise rejection\n */\n readonly error: StateErrorAtRoot | undefined;\n \n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.value](#readonly-value) method.\n */\n get(): S;\n \n /**\n * Sets new value for a state.\n * If `this.path === []`,\n * it is similar to the `setState` variable returned by `React.useState` hook.\n * If `this.path !== []`, it sets only the segment of the state value, pointed out by the path.\n * Unlike [merge](#merge) method, this method will not accept partial updates.\n * Partial updates can be also done by walking the nested states and setting those.\n *\n * @param newValue new value to set to a state.\n * It can be a value, a promise resolving to a value\n * (only if [this.path](#readonly-path) is `[]`),\n * or a function returning one of these.\n * The function receives the current state value as an argument.\n */\n set(newValue: SetStateAction): void;\n \n /**\n * Similarly to [set](#set) method updates state value.\n *\n * - If current state value is an object, it does partial update for the object.\n * - If state value is an array and the argument is an array too,\n * it concatenates the current value with the value of the argument and sets it to the state.\n * - If state value is an array and the `merge` argument is an object,\n * it does partial update for the current array value.\n * - If current state value is a string, it concatenates the current state\n * value with the argument converted to string and sets the result to the state.\n */\n merge(newValue: SetPartialStateAction): void;\n \n /**\n * Returns nested state by key.\n * `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`,\n * but also works for properties, which names collide with names of state methods.\n * \n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n * \n * @param key child property name or index\n */\n nested(key: K): State;\n \n /**\n * Runs the provided action callback with optimised re-rendering.\n * Updating state within a batch action does not trigger immediate rerendering.\n * Instead, all required rerendering is done once the batch is finished.\n * \n * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates\n * \n * @param action callback function to execute in a batch\n * \n * @param context custom user's value, which is passed to plugins\n */\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R;\n\n /**\n * If state value is null or undefined, returns state value.\n * Otherwise, it returns this state instance but\n * with null and undefined removed from the type parameter.\n * \n * [Learn more...](https://hookstate.js.org/docs/nullable-state)\n */\n ornull: InferredStateOrnullType;\n\n /**\n * Adds plugin to the state.\n * \n * [Learn more...](https://hookstate.js.org/docs/extensions-overview)\n */\n attach(plugin: () => Plugin): State\n \n /**\n * For plugin developers only.\n * It is a method to get the instance of the previously attached plugin.\n * If a plugin has not been attached to a state,\n * it returns an Error as the first element.\n * A plugin may trhow an error to indicate that plugin has not been attached.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n}\n\n/**\n * Mixin for the [StateMethods](#interfacesstatemethodsmd) for a [State](#state),\n * which can be destroyed by a client.\n */\nexport interface StateMethodsDestroy {\n /**\n * Destroys an instance of a state, so\n * it can clear the allocated native resources (if any)\n * and can not be used anymore after it has been destroyed.\n */\n destroy(): void;\n}\n\n/**\n * Type of a result of [createState](#createstate) and [useState](#usestate) functions\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more about global states...](https://hookstate.js.org/docs/global-state)\n * [Learn more about local states...](https://hookstate.js.org/docs/local-state)\n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n */\nexport type State = StateMethods & (\n S extends ReadonlyArray<(infer U)> ? ReadonlyArray> :\n S extends object ? Omit<\n { readonly [K in keyof Required]: State; },\n keyof StateMethods | keyof StateMethodsDestroy\n > : {}\n);\n\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with root state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with nested state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtPath = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with state error.\n *\n * @hidden\n * @ignore\n */\nexport type StateErrorAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with context value.\n *\n * @hidden\n * @ignore\n */\nexport type AnyContext = any; //tslint:disable-line: no-any\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onSet argument type.\n */\nexport interface PluginCallbacksOnSetArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n /**\n * **A note about previous values and merging:**\n * State values are muteable in Hookstate for performance reasons. This causes a side effect in the merge operation.\n * While merging, the previous state object is mutated as the desired changes are applied. This means the value of\n * `previous` will reflect the merged changes as well, matching the new `state` value rather than the previous\n * state value. As a result, the `previous` property is unreliable when merge is used. The\n * [merged](#optional-readonly-merged) property can be used to detect which values were merged in but it will not\n * inform you whether those values are different from the previous state.\n *\n * As a workaround, you can [batch state updates](https://hookstate.js.org/docs/performance-batched-updates) or\n * replace merge calls with the immutable-style set operation like so:\n *\n * ```\n * state.set(p => {\n * let copy = p.clone(); /// here it is up to you to define how to clone the current state\n * copy.field = 'new value for field';\n * delete copy.fieldToDelete;\n * return copy;\n * })\n * ```\n */\n readonly previous?: StateValueAtPath,\n readonly value?: StateValueAtPath,\n readonly merged?: StateValueAtPath,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onDestroy argument type.\n */\nexport interface PluginCallbacksOnDestroyArgument {\n readonly state?: StateValueAtRoot,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onBatchStart/Finish argument type.\n */\nexport interface PluginCallbacksOnBatchArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n readonly context?: AnyContext,\n}\n\n/**\n * For plugin developers only.\n * Set of callbacks, a plugin may subscribe to.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginCallbacks {\n readonly onSet?: (arg: PluginCallbacksOnSetArgument) => void,\n readonly onDestroy?: (arg: PluginCallbacksOnDestroyArgument) => void,\n readonly onBatchStart?: (arg: PluginCallbacksOnBatchArgument) => void,\n readonly onBatchFinish?: (arg: PluginCallbacksOnBatchArgument) => void,\n};\n\n/**\n * For plugin developers only.\n * Hookstate plugin specification and factory method.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface Plugin {\n /**\n * Unique identifier of a plugin.\n */\n readonly id: symbol;\n /**\n * Initializer for a plugin when it is attached for the first time.\n */\n readonly init?: (state: State) => PluginCallbacks;\n}\n\n/**\n * Creates new state and returns it.\n *\n * You can create as many global states as you need.\n *\n * When you the state is not needed anymore,\n * it should be destroyed by calling\n * `destroy()` method of the returned instance.\n * This is necessary for some plugins,\n * which allocate native resources,\n * like subscription to databases, broadcast channels, etc.\n * In most cases, a global state is used during\n * whole life time of an application and would not require\n * destruction. However, if you have got, for example,\n * a catalog of dynamically created and destroyed global states,\n * the states should be destroyed as advised above.\n *\n * @param initial Initial value of the state.\n * It can be a value OR a promise,\n * which asynchronously resolves to a value,\n * OR a function returning a value or a promise.\n *\n * @typeparam S Type of a value of the state\n *\n * @returns [State](#state) instance,\n * which can be used directly to get and set state value\n * outside of React components.\n * When you need to use the state in a functional `React` component,\n * pass the created state to [useState](#usestate) function and\n * use the returned result in the component's logic.\n */\nexport function createState(\n initial: SetInitialStateAction\n): State & StateMethodsDestroy {\n const methods = createStore(initial).toMethods();\n const devtools = createState[DevToolsID]\n if (devtools) {\n methods.attach(devtools)\n }\n return methods.self as State & StateMethodsDestroy;\n}\n\n/**\n * Enables a functional React component to use a state,\n * either created by [createState](#createstate) (*global* state) or\n * derived from another call to [useState](#usestate) (*scoped* state).\n *\n * The `useState` forces a component to rerender every time, when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * For example, if the state value is `{ a: 1, b: 2 }` and\n * a component uses only `a` property of the state, it will rerender\n * only when the whole state object is updated or when `a` property is updated.\n * Setting the state value/property to the same value is also considered as an update.\n *\n * A component can use one or many states,\n * i.e. you may call `useState` multiple times for multiple states.\n *\n * The same state can be used by multiple different components.\n *\n * @param source a reference to the state to hook into\n *\n * The `useState` is a hook and should follow React's rules of hooks.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: State\n): State;\n/**\n * This function enables a functional React component to use a state,\n * created per component by [useState](#usestate) (*local* state).\n * In this case `useState` behaves similarly to `React.useState`,\n * but the returned instance of [State](#state)\n * has got more features.\n *\n * When a state is used by only one component, and maybe it's children,\n * it is recommended to use *local* state instead of *global*,\n * which is created by [createState](#createstate).\n *\n * *Local* (per component) state is created when a component is mounted\n * and automatically destroyed when a component is unmounted.\n *\n * The same as with the usage of a *global* state,\n * `useState` forces a component to rerender when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * You can use as many local states within the same component as you need.\n *\n * @param source An initial value state.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: SetInitialStateAction\n): State;\nexport function useState(\n source: SetInitialStateAction | State\n): State {\n return useHookstate(source as State);\n}\n\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: State\n): State;\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: SetInitialStateAction\n): State;\nexport function useHookstate(\n source: SetInitialStateAction | State\n): State {\n const parentMethods = typeof source === 'object' && source !== null ?\n source[self] as StateMethodsImpl | undefined :\n undefined;\n if (parentMethods) {\n if (parentMethods.isMounted) {\n // Scoped state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [, setValue] = React.useState({});\n return useSubscribedStateMethods(\n parentMethods.state,\n parentMethods.path,\n () => setValue({}),\n parentMethods).self;\n } else {\n // Global state mount or destroyed link\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState({ state: parentMethods.state });\n return useSubscribedStateMethods(\n value.state,\n parentMethods.path,\n () => setValue({ state: value.state }),\n value.state).self;\n }\n } else {\n // Local state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState(() => ({ state: createStore(source) }));\n const result = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state);\n\n if (isDevelopmentMode) {\n // This is a workaround for the issue:\n // https://github.com/avkonst/hookstate/issues/109\n // See technical notes on React behavior here:\n // https://github.com/apollographql/apollo-client/issues/5870#issuecomment-689098185\n const isEffectExecutedAfterRender = React.useRef(false);\n isEffectExecutedAfterRender.current = false; // not yet...\n \n React.useEffect(() => {\n isEffectExecutedAfterRender.current = true; // ... and now, yes!\n // The state is not destroyed intentionally\n // under hot reload case.\n return () => { isEffectExecutedAfterRender.current && value.state.destroy() }\n });\n } else {\n React.useEffect(() => () => value.state.destroy(), []);\n }\n const devtools = useState[DevToolsID]\n if (devtools) {\n result.attach(devtools)\n }\n return result.self;\n }\n}\n\n/**\n * Allows to use a state without defining a functional react component.\n * It can be also used in class-based React components. It is also\n * particularly useful for creating *scoped* states.\n *\n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: State,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\n/**\n * Allows to use a state without defining a functional react component.\n * See more at [StateFragment](#statefragment)\n * \n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\nexport function StateFragment(\n props: {\n state: State | SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement {\n const scoped = useState(props.state as State);\n return props.children(scoped);\n}\n\n/**\n * A plugin which allows to opt-out from usage of Javascript proxies for\n * state usage tracking. It is useful for performance tuning.\n * \n * [Learn more...](https://hookstate.js.org/docs/performance-managed-rendering#downgraded-plugin)\n */\nexport function Downgraded(): Plugin { // tslint:disable-line: function-name\n return {\n id: DowngradedID\n }\n}\n\n/**\n * For plugin developers only.\n * Reserved plugin ID for developers tools extension.\n *\n * @hidden\n * @ignore\n */\nexport const DevToolsID = Symbol('DevTools');\n\n/**\n * Return type of [DevTools](#devtools).\n */\nexport interface DevToolsExtensions {\n /**\n * Assigns custom label to identify the state in the development tools\n * @param name label for development tools\n */\n label(name: string): void;\n /**\n * Logs to the development tools\n */\n log(str: string, data?: any): void; // tslint:disable-line: no-any\n}\n\n/**\n * Returns access to the development tools for a given state.\n * Development tools are delivered as optional plugins.\n * You can activate development tools from `@hookstate/devtools`package,\n * for example. If no development tools are activated,\n * it returns an instance of dummy tools, which do nothing, when called.\n * \n * [Learn more...](https://hookstate.js.org/docs/devtools)\n * \n * @param state A state to relate to the extension.\n * \n * @returns Interface to interact with the development tools for a given state.\n * \n * @typeparam S Type of a value of a state\n */\nexport function DevTools(state: State): DevToolsExtensions {\n const plugin = state.attach(DevToolsID);\n if (plugin[0] instanceof Error) {\n return EmptyDevToolsExtensions;\n }\n return plugin[0] as DevToolsExtensions;\n}\n\n///\n/// INTERNAL SYMBOLS (LIBRARY IMPLEMENTATION)\n///\n\nconst isDevelopmentMode = typeof process === 'object' && \n typeof process.env === 'object' &&\n process.env.NODE_ENV === 'development'\n\nconst self = Symbol('self')\n\nconst EmptyDevToolsExtensions: DevToolsExtensions = {\n label() { /* */ },\n log() { /* */ }\n}\n\nenum ErrorId {\n InitStateToValueFromState = 101,\n SetStateToValueFromState = 102,\n GetStateWhenPromised = 103,\n SetStateWhenPromised = 104,\n SetStateNestedToPromised = 105,\n SetStateWhenDestroyed = 106,\n ToJson_Value = 108,\n ToJson_State = 109,\n GetUnknownPlugin = 120,\n\n SetProperty_State = 201,\n SetProperty_Value = 202,\n SetPrototypeOf_State = 203,\n SetPrototypeOf_Value = 204,\n PreventExtensions_State = 205,\n PreventExtensions_Value = 206,\n DefineProperty_State = 207,\n DefineProperty_Value = 208,\n DeleteProperty_State = 209,\n DeleteProperty_Value = 210,\n Construct_State = 211,\n Construct_Value = 212,\n Apply_State = 213,\n Apply_Value = 214,\n}\n\nclass StateInvalidUsageError extends Error {\n constructor(path: Path, id: ErrorId, details?: string) {\n super(`Error: HOOKSTATE-${id} [path: /${path.join('/')}${details ? `, details: ${details}` : ''}]. ` +\n `See https://hookstate.js.org/docs/exceptions#hookstate-${id}`)\n }\n}\n\ninterface Subscriber {\n onSet(paths: Path[], actions: (() => void)[]): void;\n}\n\ninterface Subscribable {\n subscribe(l: Subscriber): void;\n unsubscribe(l: Subscriber): void;\n}\n\nfunction isNoProxyInitializer() {\n try {\n const used = new Proxy({}, {});\n return false;\n } catch (e) {\n return true;\n }\n};\nconst IsNoProxy = isNoProxyInitializer()\n\nconst DowngradedID = Symbol('Downgraded');\nconst SelfMethodsID = Symbol('ProxyMarker');\n\nconst RootPath: Path = [];\nconst DestroyedEdition = -1\n\ntype Writeable = { -readonly [P in keyof T]: T[P] };\n\nclass Store implements Subscribable {\n private _edition = 0;\n\n private _subscribers: Set = new Set();\n private _setSubscribers: Set['onSet']> = new Set();\n private _destroySubscribers: Set['onDestroy']> = new Set();\n private _batchStartSubscribers: Set['onBatchStart']> = new Set();\n private _batchFinishSubscribers: Set['onBatchFinish']> = new Set();\n\n private _plugins: Map = new Map();\n\n private _promised?: Promised;\n\n private _batches = 0;\n private _batchesPendingPaths?: Path[];\n private _batchesPendingActions?: (() => void)[];\n\n constructor(private _value: StateValueAtRoot) {\n if (typeof _value === 'object' &&\n Promise.resolve(_value) === _value) {\n this._promised = this.createPromised(_value)\n this._value = none\n } else if (_value === none) {\n this._promised = this.createPromised(undefined)\n }\n }\n\n createPromised(newValue: StateValueAtPath | undefined) {\n const promised = new Promised(\n newValue ? Promise.resolve(newValue) : undefined,\n (r: StateValueAtPath) => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._promised = undefined\n this.set(RootPath, r, undefined)\n this.update([RootPath])\n }\n },\n () => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._edition += 1\n this.update([RootPath])\n }\n },\n () => {\n if (this._batchesPendingActions &&\n this._value !== none &&\n this.edition !== DestroyedEdition) {\n const actions = this._batchesPendingActions\n this._batchesPendingActions = undefined\n actions.forEach(a => a())\n }\n }\n );\n return promised;\n }\n\n get edition() {\n return this._edition;\n }\n\n get promised() {\n return this._promised;\n }\n\n get(path: Path) {\n let result = this._value;\n if (result === none) {\n return result;\n }\n path.forEach(p => {\n result = result[p];\n });\n return result;\n }\n\n set(path: Path, value: StateValueAtPath, mergeValue: Partial | undefined): Path {\n if (this._edition < 0) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenDestroyed)\n }\n\n if (path.length === 0) {\n // Root value UPDATE case,\n\n const onSetArg: Writeable = {\n path: path,\n state: value,\n value: value,\n previous: this._value,\n merged: mergeValue\n }\n if (value === none) {\n this._promised = this.createPromised(undefined)\n delete onSetArg.value\n delete onSetArg.state\n } else if (typeof value === 'object' && Promise.resolve(value) === value) {\n this._promised = this.createPromised(value)\n value = none\n delete onSetArg.value\n delete onSetArg.state\n } else if (this._promised && (!this._promised.resolver && !this._promised.fullfilled)) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenPromised)\n }\n\n let prevValue = this._value;\n if (prevValue === none) {\n delete onSetArg.previous\n }\n this._value = value;\n this.afterSet(onSetArg)\n\n if (prevValue === none && this._value !== none &&\n this.promised && this.promised.resolver) {\n this.promised.resolver(this._value)\n }\n\n return path;\n }\n\n if (typeof value === 'object' && Promise.resolve(value) === value) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateNestedToPromised)\n }\n\n let target = this._value;\n for (let i = 0; i < path.length - 1; i += 1) {\n target = target[path[i]];\n }\n\n const p = path[path.length - 1]\n if (p in target) {\n if (value !== none) {\n // Property UPDATE case\n let prevValue = target[p]\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n previous: prevValue,\n merged: mergeValue\n })\n\n return path;\n } else {\n // Property DELETE case\n let prevValue = target[p]\n if (Array.isArray(target) && typeof p === 'number') {\n target.splice(p, 1)\n } else {\n delete target[p]\n }\n this.afterSet({\n path: path,\n state: this._value,\n previous: prevValue,\n merged: mergeValue\n })\n\n // if an array of objects is about to loose existing property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n }\n\n if (value !== none) {\n // Property INSERT case\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n merged: mergeValue\n })\n\n // if an array of objects is about to be extended by new property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n\n // Non-existing property DELETE case\n // no-op\n return path;\n }\n\n update(paths: Path[]) {\n if (this._batches) {\n this._batchesPendingPaths = this._batchesPendingPaths || []\n this._batchesPendingPaths = this._batchesPendingPaths.concat(paths)\n return;\n }\n\n const actions: (() => void)[] = [];\n this._subscribers.forEach(s => s.onSet(paths, actions));\n actions.forEach(a => a());\n }\n\n afterSet(params: PluginCallbacksOnSetArgument) {\n if (this._edition !== DestroyedEdition) {\n this._edition += 1;\n this._setSubscribers.forEach(cb => cb(params))\n }\n }\n\n startBatch(path: Path, options?: { context?: AnyContext }): void {\n this._batches += 1\n\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchStartSubscribers.forEach(cb => cb(cbArgument))\n }\n\n finishBatch(path: Path, options?: { context?: AnyContext }): void {\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchFinishSubscribers.forEach(cb => cb(cbArgument))\n\n this._batches -= 1\n if (this._batches === 0) {\n if (this._batchesPendingPaths) {\n const paths = this._batchesPendingPaths\n this._batchesPendingPaths = undefined\n this.update(paths)\n }\n }\n }\n\n postponeBatch(action: () => void): void {\n this._batchesPendingActions = this._batchesPendingActions || []\n this._batchesPendingActions.push(action)\n }\n\n getPlugin(pluginId: symbol) {\n return this._plugins.get(pluginId)\n }\n\n register(plugin: Plugin) {\n const existingInstance = this._plugins.get(plugin.id)\n if (existingInstance) {\n return;\n }\n\n const pluginCallbacks = plugin.init ? plugin.init(this.toMethods().self) : {};\n this._plugins.set(plugin.id, pluginCallbacks);\n if (pluginCallbacks.onSet) {\n this._setSubscribers.add((p) => pluginCallbacks.onSet!(p))\n }\n if (pluginCallbacks.onDestroy) {\n this._destroySubscribers.add((p) => pluginCallbacks.onDestroy!(p))\n }\n if (pluginCallbacks.onBatchStart) {\n this._batchStartSubscribers.add((p) => pluginCallbacks.onBatchStart!(p))\n }\n if (pluginCallbacks.onBatchFinish) {\n this._batchFinishSubscribers.add((p) => pluginCallbacks.onBatchFinish!(p))\n }\n }\n\n toMethods() {\n return new StateMethodsImpl(\n this,\n RootPath,\n this.get(RootPath),\n this.edition,\n OnSetUsedNoAction\n )\n }\n\n subscribe(l: Subscriber) {\n this._subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this._subscribers.delete(l);\n }\n\n destroy() {\n this._destroySubscribers.forEach(cb => cb(this._value !== none ? { state: this._value } : {}))\n this._edition = DestroyedEdition\n }\n\n toJSON() {\n throw new StateInvalidUsageError(RootPath, ErrorId.ToJson_Value);\n }\n}\n\nclass Promised {\n public fullfilled?: true;\n public error?: StateErrorAtRoot;\n public resolver?: (_: StateValueAtRoot) => void;\n\n constructor(public promise: Promise | undefined,\n onResolve: (r: StateValueAtPath) => void,\n onReject: () => void,\n onPostResolve: () => void) {\n if (!promise) {\n promise = new Promise(resolve => {\n this.resolver = resolve;\n })\n }\n this.promise = promise\n .then(r => {\n this.fullfilled = true\n if (!this.resolver) {\n onResolve(r)\n }\n })\n .catch(err => {\n this.fullfilled = true\n this.error = err\n onReject()\n })\n .then(() => onPostResolve())\n }\n}\n\n// use symbol property to allow for easier reference finding\nconst ValueUnusedMarker = Symbol('ValueUnusedMarker');\n\nfunction OnSetUsedNoAction() { /** no action callback */ }\n\n// use symbol to mark that a function has no effect anymore\nconst UnmountedMarker = Symbol('UnmountedMarker');\nOnSetUsedNoAction[UnmountedMarker] = true\n\nclass StateMethodsImpl implements StateMethods, StateMethodsDestroy, Subscribable, Subscriber {\n private subscribers: Set | undefined;\n\n private isDowngraded: boolean | undefined;\n private childrenCache: Record> | undefined;\n private selfCache: State | undefined;\n private valueCache: StateValueAtPath = ValueUnusedMarker;\n \n constructor(\n public readonly state: Store,\n public readonly path: Path,\n private valueSource: S,\n private valueEdition: number,\n private readonly onSetUsed: () => void\n ) { }\n\n getUntracked(allowPromised?: boolean) {\n if (this.valueEdition !== this.state.edition) {\n this.valueSource = this.state.get(this.path)\n this.valueEdition = this.state.edition\n\n if (this.isMounted) {\n // this link is still mounted to a component\n // populate cache again to ensure correct tracking of usage\n // when React scans which states to rerender on update\n if (this.valueCache !== ValueUnusedMarker) {\n this.valueCache = ValueUnusedMarker\n this.get(true) // renew cache to keep it marked used\n }\n } else {\n // This link is not mounted to a component\n // for example, it might be global link or\n // a link which has been discarded after rerender\n // but still captured by some callback or an effect.\n // If we are here and if it was mounted before,\n // it means it has not been garbage collected\n // when a component unmounted.\n // We take this opportunity to clean up caches\n // to avoid memory leaks via stale children states cache.\n this.valueCache = ValueUnusedMarker\n delete this.childrenCache\n delete this.selfCache\n }\n }\n if (this.valueSource === none && !allowPromised) {\n if (this.state.promised && this.state.promised.error) {\n throw this.state.promised.error;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.GetStateWhenPromised)\n }\n return this.valueSource;\n }\n\n get(allowPromised?: boolean) {\n const currentValue = this.getUntracked(allowPromised)\n if (this.valueCache === ValueUnusedMarker) {\n if (this.isDowngraded) {\n this.valueCache = currentValue;\n } else if (Array.isArray(currentValue)) {\n this.valueCache = this.valueArrayImpl(currentValue as unknown as StateValueAtPath[]);\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n this.valueCache = this.valueObjectImpl(currentValue as unknown as object);\n } else {\n this.valueCache = currentValue;\n }\n }\n return this.valueCache as S;\n }\n\n get value(): S {\n return this.get()\n }\n\n setUntracked(newValue: SetStateAction, mergeValue?: Partial): [Path] {\n if (typeof newValue === 'function') {\n newValue = (newValue as ((prevValue: S) => S))(this.getUntracked());\n }\n if (typeof newValue === 'object' && newValue !== null && newValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(this.path, ErrorId.SetStateToValueFromState)\n }\n return [this.state.set(this.path, newValue, mergeValue)];\n }\n\n set(newValue: SetStateAction) {\n this.state.update(this.setUntracked(newValue));\n }\n\n mergeUntracked(sourceValue: SetPartialStateAction): Path[] {\n const currentValue = this.getUntracked()\n if (typeof sourceValue === 'function') {\n sourceValue = (sourceValue as Function)(currentValue);\n }\n\n let updatedPaths: [Path];\n let deletedOrInsertedProps = false\n\n if (Array.isArray(currentValue)) {\n if (Array.isArray(sourceValue)) {\n return this.setUntracked(currentValue.concat(sourceValue) as unknown as S, sourceValue)\n } else {\n const deletedIndexes: number[] = []\n Object.keys(sourceValue).sort().forEach(i => {\n const index = Number(i);\n const newPropValue = sourceValue[index]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n deletedIndexes.push(index)\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(index in currentValue);\n (currentValue as StateValueAtPath[])[index] = newPropValue\n }\n });\n // indexes are ascending sorted as per above\n // so, delete one by one from the end\n // this way index positions do not change\n deletedIndexes.reverse().forEach(p => {\n (currentValue as unknown as []).splice(p, 1)\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n }\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n Object.keys(sourceValue).forEach(key => {\n const newPropValue = sourceValue[key]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n delete currentValue[key]\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(key in currentValue)\n currentValue[key] = newPropValue\n }\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n } else if (typeof currentValue === 'string') {\n return this.setUntracked((currentValue + String(sourceValue)) as unknown as S, sourceValue)\n } else {\n return this.setUntracked(sourceValue as S)\n }\n\n if (updatedPaths.length !== 1 || updatedPaths[0] !== this.path || deletedOrInsertedProps) {\n return updatedPaths\n }\n const updatedPath = updatedPaths[0]\n return Object.keys(sourceValue).map(p => updatedPath.slice().concat(p))\n }\n\n merge(sourceValue: SetPartialStateAction) {\n this.state.update(this.mergeUntracked(sourceValue));\n }\n\n nested(key: K): State {\n return this.child(key as string | number).self as State\n }\n \n rerender(paths: Path[]) {\n this.state.update(paths)\n }\n\n destroy(): void {\n this.state.destroy()\n }\n\n subscribe(l: Subscriber) {\n if (this.subscribers === undefined) {\n this.subscribers = new Set();\n }\n this.subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this.subscribers!.delete(l);\n }\n \n get isMounted(): boolean {\n return !this.onSetUsed[UnmountedMarker]\n }\n\n onUnmount() {\n this.onSetUsed[UnmountedMarker] = true\n }\n\n onSet(paths: Path[], actions: (() => void)[]): boolean {\n const update = () => {\n if (this.isDowngraded && this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n for (let path of paths) {\n const firstChildKey = path[this.path.length];\n if (firstChildKey === undefined) {\n if (this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n } else {\n const firstChildValue = this.childrenCache && this.childrenCache[firstChildKey];\n if (firstChildValue && firstChildValue.onSet(paths, actions)) {\n return true;\n }\n }\n }\n return false;\n }\n\n const updated = update();\n if (!updated && this.subscribers !== undefined) {\n this.subscribers.forEach(s => {\n s.onSet(paths, actions)\n })\n }\n return updated;\n }\n\n get keys(): InferredStateKeysType {\n const value = this.get()\n if (Array.isArray(value)) {\n return Object.keys(value).map(i => Number(i)).filter(i => Number.isInteger(i)) as\n unknown as InferredStateKeysType;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value) as unknown as InferredStateKeysType;\n }\n return undefined as InferredStateKeysType;\n }\n\n child(key: number | string) {\n // if this state is not mounted to a hook,\n // we do not cache children to avoid unnecessary memory leaks\n if (this.isMounted) {\n this.childrenCache = this.childrenCache || {};\n const cachehit = this.childrenCache[key];\n if (cachehit) {\n return cachehit;\n }\n }\n const r = new StateMethodsImpl(\n this.state,\n this.path.slice().concat(key),\n this.valueSource[key],\n this.valueEdition,\n this.onSetUsed,\n )\n if (this.isDowngraded) {\n r.isDowngraded = true;\n }\n if (this.childrenCache) {\n this.childrenCache[key] = r;\n }\n return r;\n }\n \n private valueArrayImpl(currentValue: StateValueAtPath[]): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === 'length') {\n return (target as []).length;\n }\n if (key in Array.prototype) {\n return Array.prototype[key];\n }\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n const index = Number(key);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.child(index).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n private valueObjectImpl(currentValue: object): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n return this.child(key).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n get self(): State {\n if (this.selfCache) {\n return this.selfCache\n }\n \n const getter = (_: object, key: PropertyKey) => {\n if (key === self) {\n return this\n }\n if (typeof key === 'symbol') {\n return undefined\n }\n if (key === 'toJSON') {\n throw new StateInvalidUsageError(this.path, ErrorId.ToJson_State);\n }\n \n let nestedGetter = (prop: PropertyKey) => {\n const currentDowngraded = this.isDowngraded; // relevant for IE11 only\n const currentValue = this.get(); // IE11 marks this as downgraded\n this.isDowngraded = currentDowngraded; // relevant for IE11 only\n if (// if currentValue is primitive type\n (typeof currentValue !== 'object' || currentValue === null) &&\n // if promised, it will be none\n currentValue !== none) {\n // This was an error case, but various tools like webpack bundler\n // and react dev tools attempt to get props out of non-null object,\n // so this was changed to return just undefined for any property request\n // as there is no way to fix 3rd party tools.\n // Logging a warning to console is also not an option\n // as it pollutes console for legitimate apps on app start app.\n // Ref: https://github.com/avkonst/hookstate/issues/125\n return undefined\n }\n\n if (Array.isArray(currentValue)) {\n if (prop === 'length') {\n return currentValue.length;\n }\n if (prop in Array.prototype) {\n return Array.prototype[prop];\n }\n const index = Number(prop);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.nested(index as keyof S)\n }\n return this.nested(prop.toString() as keyof S)\n }\n\n switch (key) {\n case 'path':\n return this.path\n case 'keys':\n return this.keys\n case 'value':\n return this.value\n case 'ornull':\n return this.ornull\n case 'promised':\n return this.promised\n case 'error':\n return this.error\n case 'get':\n return () => this.get()\n case 'set':\n return (p: SetStateAction) => this.set(p)\n case 'merge':\n return (p: SetPartialStateAction) => this.merge(p)\n case 'nested':\n return (p: keyof S) => nestedGetter(p)\n case 'batch':\n // tslint:disable-next-line: no-any\n return (action: () => R, context: Exclude) => this.batch(action, context)\n case 'attach':\n return (p: symbol) => this.attach(p)\n case 'destroy':\n return () => this.destroy()\n default:\n return nestedGetter(key)\n }\n }\n \n if (IsNoProxy) {\n // minimal support for IE11\n const result = (Array.isArray(this.valueSource) ? [] : {}) as State;\n [self, 'toJSON', 'path', 'keys', 'value', 'ornull',\n 'promised', 'error', 'get', 'set', 'merge',\n 'nested', 'batch', 'attach', 'destroy']\n .forEach(key => {\n Object.defineProperty(result, key, {\n get: () => getter(result, key)\n })\n })\n if (typeof this.valueSource === 'object' && this.valueSource !== null) {\n Object.keys(this.valueSource).forEach(key => {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => getter(result, key)\n })\n })\n }\n this.selfCache = result;\n return this.selfCache\n }\n \n this.selfCache = proxyWrap(this.path, this.valueSource,\n () => {\n this.get() // get latest & mark used\n return this.valueSource\n },\n getter,\n (_, key, value) => {\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_State)\n },\n false) as unknown as State;\n return this.selfCache\n }\n \n get promised(): boolean {\n const currentValue = this.get(true) // marks used\n if (currentValue === none && this.state.promised && !this.state.promised.fullfilled) {\n return true;\n }\n return false;\n }\n\n get error(): StateErrorAtRoot | undefined {\n const currentValue = this.get(true) // marks used\n if (currentValue === none) {\n if (this.state.promised && this.state.promised.fullfilled) {\n return this.state.promised.error;\n }\n this.get() // will throw 'read while promised' exception\n }\n return undefined;\n }\n\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R {\n const opts = { context: context }\n try {\n this.state.startBatch(this.path, opts)\n const result = action(this.self) as R\n if (result as unknown as Symbol === postpone) {\n this.state.postponeBatch(() => this.batch(action, context))\n }\n return result\n } finally {\n this.state.finishBatch(this.path, opts)\n }\n }\n\n get ornull(): InferredStateOrnullType {\n const value = this.get()\n if (value === null || value === undefined) {\n return value as unknown as InferredStateOrnullType;\n }\n return this.self as InferredStateOrnullType;\n }\n\n attach(plugin: () => Plugin): State\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n attach(p: (() => Plugin) | symbol):\n State | [PluginCallbacks | Error, PluginStateControl] {\n if (typeof p === 'function') {\n const pluginMeta = p();\n if (pluginMeta.id === DowngradedID) {\n this.isDowngraded = true;\n if (this.valueCache !== ValueUnusedMarker) {\n const currentValue = this.getUntracked(true);\n this.valueCache = currentValue;\n }\n return this.self;\n }\n this.state.register(pluginMeta);\n return this.self;\n } else {\n return [\n this.state.getPlugin(p) ||\n (new StateInvalidUsageError(this.path, ErrorId.GetUnknownPlugin, p.toString())), \n this\n ];\n }\n }\n}\n\nfunction proxyWrap(\n path: Path,\n // tslint:disable-next-line: no-any\n targetBootstrap: any,\n // tslint:disable-next-line: no-any\n targetGetter: () => any,\n // tslint:disable-next-line: no-any\n propertyGetter: (unused: any, key: PropertyKey) => any,\n // tslint:disable-next-line: no-any\n propertySetter: (unused: any, p: PropertyKey, value: any, receiver: any) => boolean,\n isValueProxy: boolean\n) {\n const onInvalidUsage = (op: ErrorId) => {\n throw new StateInvalidUsageError(path, op)\n }\n if (typeof targetBootstrap !== 'object' || targetBootstrap === null) {\n targetBootstrap = {}\n }\n return new Proxy(targetBootstrap, {\n getPrototypeOf: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf#Invariants\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return null;\n }\n return Object.getPrototypeOf(targetReal);\n },\n setPrototypeOf: (target, v) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.SetPrototypeOf_State :\n ErrorId.SetPrototypeOf_Value)\n },\n isExtensible: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible#Invariants\n return true; // required to satisfy the invariants of the getPrototypeOf\n // return Object.isExtensible(target);\n },\n preventExtensions: (target) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.PreventExtensions_State :\n ErrorId.PreventExtensions_Value)\n },\n getOwnPropertyDescriptor: (target, p) => {\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return undefined;\n }\n const origin = Object.getOwnPropertyDescriptor(targetReal, p);\n if (origin && Array.isArray(targetReal) && p in Array.prototype) {\n return origin;\n }\n return origin && {\n configurable: true, // JSON.stringify() does not work for an object without it\n enumerable: origin.enumerable,\n get: () => propertyGetter(targetReal, p),\n set: undefined\n };\n },\n has: (target, p) => {\n if (typeof p === 'symbol') {\n return false;\n }\n const targetReal = targetGetter()\n if (typeof targetReal === 'object' && targetReal !== null) {\n return p in targetReal;\n }\n return false;\n },\n get: propertyGetter,\n set: propertySetter,\n deleteProperty: (target, p) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DeleteProperty_State :\n ErrorId.DeleteProperty_Value)\n },\n defineProperty: (target, p, attributes) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DefineProperty_State :\n ErrorId.DefineProperty_Value)\n },\n ownKeys: (target) => {\n const targetReal = targetGetter()\n if (Array.isArray(targetReal)) {\n return Object.keys(targetReal).concat('length');\n }\n if (targetReal === undefined || targetReal === null) {\n return [];\n }\n return Object.keys(targetReal);\n },\n apply: (target, thisArg, argArray?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Apply_State:\n ErrorId.Apply_Value)\n },\n construct: (target, argArray, newTarget?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Construct_State :\n ErrorId.Construct_Value)\n }\n });\n}\n\nfunction createStore(initial: SetInitialStateAction): Store {\n let initialValue: S | Promise = initial as (S | Promise);\n if (typeof initial === 'function') {\n initialValue = (initial as (() => S | Promise))();\n }\n if (typeof initialValue === 'object' && initialValue !== null && initialValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(RootPath, ErrorId.InitStateToValueFromState)\n }\n return new Store(initialValue);\n}\n\nfunction useSubscribedStateMethods(\n state: Store,\n path: Path,\n update: () => void,\n subscribeTarget: Subscribable\n) {\n const link = new StateMethodsImpl(\n state,\n path,\n state.get(path),\n state.edition,\n update,\n );\n // useLayoutEffect here instead of useEffect because of this issue:\n // https://github.com/avkonst/hookstate/issues/165#issuecomment-824670930\n // and very likely this issue:\n // https://github.com/avkonst/hookstate/issues/186\n // and probably this issue:\n // https://github.com/avkonst/hookstate/issues/145\n React.useLayoutEffect(() => {\n subscribeTarget.subscribe(link);\n return () => {\n link.onUnmount()\n subscribeTarget.unsubscribe(link);\n }\n });\n return link;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AACF;AACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,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,SAAS,WAAW,CAAI,OAAiC;IACrD,IAAI,YAAY,GAAmB,OAA2B,CAAC;IAC/D,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;QAC/B,YAAY,GAAI,OAAkC,EAAE,CAAC;KACxD;IACD,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,aAAa,CAAC,EAAE;QAC1F,MAAM,IAAI,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;KAChF;IACD,OAAO,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,yBAAyB,CAC9B,KAAY,EACZ,IAAU,EACV,MAAkB,EAClB,eAA6B;IAE7B,IAAM,IAAI,GAAG,IAAI,gBAAgB,CAC7B,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EACf,KAAK,CAAC,OAAO,EACb,MAAM,CACT,CAAC;;;;;;;IAOF,KAAK,CAAC,eAAe,CAAC;QAClB,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO;YACH,IAAI,CAAC,SAAS,EAAE,CAAA;YAChB,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACrC,CAAA;KACJ,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AAChB;;;;"} \ No newline at end of file +{"version":3,"file":"index.es.js","sources":["../node_modules/tslib/tslib.es6.js","../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import React from 'react';\n\n///\n/// EXPORTED SYMBOLS (LIBRARY INTERFACE)\n///\n\n/**\n * 'JSON path' from root of a state object to a nested property.\n * Return type of [StateMethod.path](#readonly-path).\n *\n * For example, an object `{ a: [{ b: 1 }, { 1000: 'value' }, '3rd'] }`,\n * has got the following paths pointing to existing properties:\n *\n * - `[]`\n * - `['a']`\n * - `['a', 0]`\n * - `['a', 0, 'b']`\n * - `['a', 1]`\n * - `['a', 1, 1000]`\n * - `['a', 2]`\n */\nexport type Path = ReadonlyArray;\n\n/**\n * Type of an argument of [StateMethods.set](#set).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetStateAction = (S | Promise) | ((prevState: S) => (S | Promise));\n\n/**\n * Type of an argument of [StateMethods.merge](#merge).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetPartialStateAction =\n S extends ReadonlyArray<(infer U)> ?\n ReadonlyArray | Record | ((prevValue: S) => (ReadonlyArray | Record)) :\n S extends object | string ? Partial | ((prevValue: S) => Partial) :\n React.SetStateAction;\n\n/**\n * Type of an argument of [createState](#createstate) and [useState](#usestate).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetInitialStateAction = S | Promise | (() => S | Promise)\n\n/**\n * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function.\n * \n * [Learn more...](https://hookstate.js.org/docs/asynchronous-state#executing-an-action-when-state-is-loaded)\n */\nexport const postpone = Symbol('postpone')\n\n/**\n * Special symbol which might be used to delete properties\n * from an object calling [StateMethods.set](#set) or [StateMethods.merge](#merge).\n * \n * [Learn more...](https://hookstate.js.org/docs/nested-state#deleting-existing-element)\n */\nexport const none = Symbol('none') as StateValueAtPath;\n\n/**\n * Return type of [StateMethods.keys](#readonly-keys).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateKeysType =\n S extends ReadonlyArray ? ReadonlyArray :\n S extends null ? undefined :\n S extends object ? ReadonlyArray :\n undefined;\n\n/**\n * Return type of [StateMethods.map()](#map).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateOrnullType =\n S extends undefined ? undefined :\n S extends null ? null : State;\n\n/**\n * For plugin developers only.\n * An instance to manipulate the state in more controlled way.\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginStateControl {\n /**\n * Get state value, but do not leave the traces of reading it.\n */\n getUntracked(): S;\n /**\n * Set new state value, but do not trigger rerender.\n * \n * @param newValue new value to set to a state.\n */\n setUntracked(newValue: SetStateAction): Path[];\n /**\n * Merge new state value, but do not trigger rerender.\n * \n * @param mergeValue new partial value to merge with the current state value and set.\n */\n mergeUntracked(mergeValue: SetPartialStateAction): Path[];\n /**\n * Trigger rerender for hooked states, where values at the specified paths are used.\n * \n * @param paths paths of the state variables to search for being used by components and rerender\n */\n rerender(paths: Path[]): void;\n}\n\n/**\n * An interface to manage a state in Hookstate.\n * \n * @typeparam S Type of a value of a state\n */\nexport interface StateMethods {\n /**\n * 'Javascript' object 'path' to an element relative to the root object\n * in the state. For example:\n *\n * ```tsx\n * const state = useState([{ name: 'First Task' }])\n * state.path IS []\n * state[0].path IS [0]\n * state.[0].name.path IS [0, 'name']\n * ```\n */\n readonly path: Path;\n\n /**\n * Return the keys of nested states.\n * For a given state of [State](#state) type,\n * `state.keys` will be structurally equal to Object.keys(state),\n * with two minor difference:\n * 1. if `state.value` is an array, the returned result will be\n * an array of numbers, not strings like with `Object.keys`.\n * 2. if `state.value` is not an object, the returned result will be undefined.\n */\n readonly keys: InferredStateKeysType;\n\n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.get](#get) method.\n *\n * This property is more useful than [get](#get) method for the cases,\n * when a value may hold null or undefined values.\n * Typescript compiler does not handle elimination of undefined with get(),\n * like in the following examples, but value does:\n *\n * ```tsx\n * const state = useState(0)\n * const myvalue: number = state.value\n * ? state.value + 1\n * : 0; // <-- compiles\n * const myvalue: number = state.get()\n * ? state.get() + 1\n * : 0; // <-- does not compile\n * ```\n */\n readonly value: S;\n\n /**\n * True if state value is not yet available (eg. equal to a promise)\n */\n readonly promised: boolean;\n \n /**\n * If a state was set to a promise and the promise was rejected,\n * this property will return the error captured from the promise rejection\n */\n readonly error: StateErrorAtRoot | undefined;\n \n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.value](#readonly-value) method.\n */\n get(): S;\n \n /**\n * Sets new value for a state.\n * If `this.path === []`,\n * it is similar to the `setState` variable returned by `React.useState` hook.\n * If `this.path !== []`, it sets only the segment of the state value, pointed out by the path.\n * Unlike [merge](#merge) method, this method will not accept partial updates.\n * Partial updates can be also done by walking the nested states and setting those.\n *\n * @param newValue new value to set to a state.\n * It can be a value, a promise resolving to a value\n * (only if [this.path](#readonly-path) is `[]`),\n * or a function returning one of these.\n * The function receives the current state value as an argument.\n */\n set(newValue: SetStateAction): void;\n \n /**\n * Similarly to [set](#set) method updates state value.\n *\n * - If current state value is an object, it does partial update for the object.\n * - If state value is an array and the argument is an array too,\n * it concatenates the current value with the value of the argument and sets it to the state.\n * - If state value is an array and the `merge` argument is an object,\n * it does partial update for the current array value.\n * - If current state value is a string, it concatenates the current state\n * value with the argument converted to string and sets the result to the state.\n */\n merge(newValue: SetPartialStateAction): void;\n \n /**\n * Returns nested state by key.\n * `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`,\n * but also works for properties, which names collide with names of state methods.\n * \n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n * \n * @param key child property name or index\n */\n nested(key: K): State;\n \n /**\n * Runs the provided action callback with optimised re-rendering.\n * Updating state within a batch action does not trigger immediate rerendering.\n * Instead, all required rerendering is done once the batch is finished.\n * \n * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates\n * \n * @param action callback function to execute in a batch\n * \n * @param context custom user's value, which is passed to plugins\n */\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R;\n\n /**\n * If state value is null or undefined, returns state value.\n * Otherwise, it returns this state instance but\n * with null and undefined removed from the type parameter.\n * \n * [Learn more...](https://hookstate.js.org/docs/nullable-state)\n */\n ornull: InferredStateOrnullType;\n\n /**\n * Adds plugin to the state.\n * \n * [Learn more...](https://hookstate.js.org/docs/extensions-overview)\n */\n attach(plugin: () => Plugin): State\n \n /**\n * For plugin developers only.\n * It is a method to get the instance of the previously attached plugin.\n * If a plugin has not been attached to a state,\n * it returns an Error as the first element.\n * A plugin may trhow an error to indicate that plugin has not been attached.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n}\n\n/**\n * Mixin for the [StateMethods](#interfacesstatemethodsmd) for a [State](#state),\n * which can be destroyed by a client.\n */\nexport interface StateMethodsDestroy {\n /**\n * Destroys an instance of a state, so\n * it can clear the allocated native resources (if any)\n * and can not be used anymore after it has been destroyed.\n */\n destroy(): void;\n}\n\n/**\n * Type of a result of [createState](#createstate) and [useState](#usestate) functions\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more about global states...](https://hookstate.js.org/docs/global-state)\n * [Learn more about local states...](https://hookstate.js.org/docs/local-state)\n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n */\nexport type State = StateMethods & (\n S extends ReadonlyArray<(infer U)> ? ReadonlyArray> :\n S extends object ? Omit<\n { readonly [K in keyof Required]: State; },\n keyof StateMethods | keyof StateMethodsDestroy\n > : {}\n);\n\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with root state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with nested state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtPath = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with state error.\n *\n * @hidden\n * @ignore\n */\nexport type StateErrorAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with context value.\n *\n * @hidden\n * @ignore\n */\nexport type AnyContext = any; //tslint:disable-line: no-any\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onSet argument type.\n */\nexport interface PluginCallbacksOnSetArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n /**\n * **A note about previous values and merging:**\n * State values are muteable in Hookstate for performance reasons. This causes a side effect in the merge operation.\n * While merging, the previous state object is mutated as the desired changes are applied. This means the value of\n * `previous` will reflect the merged changes as well, matching the new `state` value rather than the previous\n * state value. As a result, the `previous` property is unreliable when merge is used. The\n * [merged](#optional-readonly-merged) property can be used to detect which values were merged in but it will not\n * inform you whether those values are different from the previous state.\n *\n * As a workaround, you can [batch state updates](https://hookstate.js.org/docs/performance-batched-updates) or\n * replace merge calls with the immutable-style set operation like so:\n *\n * ```\n * state.set(p => {\n * let copy = p.clone(); /// here it is up to you to define how to clone the current state\n * copy.field = 'new value for field';\n * delete copy.fieldToDelete;\n * return copy;\n * })\n * ```\n */\n readonly previous?: StateValueAtPath,\n readonly value?: StateValueAtPath,\n readonly merged?: StateValueAtPath,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onDestroy argument type.\n */\nexport interface PluginCallbacksOnDestroyArgument {\n readonly state?: StateValueAtRoot,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onBatchStart/Finish argument type.\n */\nexport interface PluginCallbacksOnBatchArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n readonly context?: AnyContext,\n}\n\n/**\n * For plugin developers only.\n * Set of callbacks, a plugin may subscribe to.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginCallbacks {\n readonly onSet?: (arg: PluginCallbacksOnSetArgument) => void,\n readonly onDestroy?: (arg: PluginCallbacksOnDestroyArgument) => void,\n readonly onBatchStart?: (arg: PluginCallbacksOnBatchArgument) => void,\n readonly onBatchFinish?: (arg: PluginCallbacksOnBatchArgument) => void,\n};\n\n/**\n * For plugin developers only.\n * Hookstate plugin specification and factory method.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface Plugin {\n /**\n * Unique identifier of a plugin.\n */\n readonly id: symbol;\n /**\n * Initializer for a plugin when it is attached for the first time.\n */\n readonly init?: (state: State) => PluginCallbacks;\n}\n\n/**\n * Creates new state and returns it.\n *\n * You can create as many global states as you need.\n *\n * When you the state is not needed anymore,\n * it should be destroyed by calling\n * `destroy()` method of the returned instance.\n * This is necessary for some plugins,\n * which allocate native resources,\n * like subscription to databases, broadcast channels, etc.\n * In most cases, a global state is used during\n * whole life time of an application and would not require\n * destruction. However, if you have got, for example,\n * a catalog of dynamically created and destroyed global states,\n * the states should be destroyed as advised above.\n *\n * @param initial Initial value of the state.\n * It can be a value OR a promise,\n * which asynchronously resolves to a value,\n * OR a function returning a value or a promise.\n *\n * @typeparam S Type of a value of the state\n *\n * @returns [State](#state) instance,\n * which can be used directly to get and set state value\n * outside of React components.\n * When you need to use the state in a functional `React` component,\n * pass the created state to [useState](#usestate) function and\n * use the returned result in the component's logic.\n */\nexport function createState(\n initial: SetInitialStateAction\n): State & StateMethodsDestroy {\n const methods = createStore(initial).toMethods();\n const devtools = createState[DevToolsID]\n if (devtools) {\n methods.attach(devtools)\n }\n return methods.self as State & StateMethodsDestroy;\n}\n\n/**\n * Enables a functional React component to use a state,\n * either created by [createState](#createstate) (*global* state) or\n * derived from another call to [useState](#usestate) (*scoped* state).\n *\n * The `useState` forces a component to rerender every time, when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * For example, if the state value is `{ a: 1, b: 2 }` and\n * a component uses only `a` property of the state, it will rerender\n * only when the whole state object is updated or when `a` property is updated.\n * Setting the state value/property to the same value is also considered as an update.\n *\n * A component can use one or many states,\n * i.e. you may call `useState` multiple times for multiple states.\n *\n * The same state can be used by multiple different components.\n *\n * @param source a reference to the state to hook into\n *\n * The `useState` is a hook and should follow React's rules of hooks.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: State\n): State;\n/**\n * This function enables a functional React component to use a state,\n * created per component by [useState](#usestate) (*local* state).\n * In this case `useState` behaves similarly to `React.useState`,\n * but the returned instance of [State](#state)\n * has got more features.\n *\n * When a state is used by only one component, and maybe it's children,\n * it is recommended to use *local* state instead of *global*,\n * which is created by [createState](#createstate).\n *\n * *Local* (per component) state is created when a component is mounted\n * and automatically destroyed when a component is unmounted.\n *\n * The same as with the usage of a *global* state,\n * `useState` forces a component to rerender when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * You can use as many local states within the same component as you need.\n *\n * @param source An initial value state.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: SetInitialStateAction\n): State;\nexport function useState(\n source: SetInitialStateAction | State\n): State {\n return useHookstate(source as State);\n}\n\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: State\n): State;\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: SetInitialStateAction\n): State;\nexport function useHookstate(\n source: SetInitialStateAction | State\n): State {\n const parentMethods = typeof source === 'object' && source !== null ?\n source[self] as StateMethodsImpl | undefined :\n undefined;\n if (parentMethods) {\n if (parentMethods.isMounted) {\n // Scoped state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [, setValue] = React.useState({});\n return useSubscribedStateMethods(\n parentMethods.state,\n parentMethods.path,\n () => setValue({}),\n parentMethods).self;\n } else {\n // Global state mount or destroyed link\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState({ state: parentMethods.state });\n let state = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state).self;\n for (let ind = 0; ind < parentMethods.path.length; ind += 1) {\n state = state.nested(parentMethods.path[ind]);\n }\n return state as State;\n }\n } else {\n // Local state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState(() => ({ state: createStore(source) }));\n const result = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state);\n\n if (isDevelopmentMode) {\n // This is a workaround for the issue:\n // https://github.com/avkonst/hookstate/issues/109\n // See technical notes on React behavior here:\n // https://github.com/apollographql/apollo-client/issues/5870#issuecomment-689098185\n const isEffectExecutedAfterRender = React.useRef(false);\n isEffectExecutedAfterRender.current = false; // not yet...\n \n React.useEffect(() => {\n isEffectExecutedAfterRender.current = true; // ... and now, yes!\n // The state is not destroyed intentionally\n // under hot reload case.\n return () => { isEffectExecutedAfterRender.current && value.state.destroy() }\n });\n } else {\n React.useEffect(() => () => value.state.destroy(), []);\n }\n const devtools = useState[DevToolsID]\n if (devtools) {\n result.attach(devtools)\n }\n return result.self;\n }\n}\n\n/**\n * Allows to use a state without defining a functional react component.\n * It can be also used in class-based React components. It is also\n * particularly useful for creating *scoped* states.\n *\n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: State,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\n/**\n * Allows to use a state without defining a functional react component.\n * See more at [StateFragment](#statefragment)\n * \n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\nexport function StateFragment(\n props: {\n state: State | SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement {\n const scoped = useState(props.state as State);\n return props.children(scoped);\n}\n\n/**\n * A plugin which allows to opt-out from usage of Javascript proxies for\n * state usage tracking. It is useful for performance tuning.\n * \n * [Learn more...](https://hookstate.js.org/docs/performance-managed-rendering#downgraded-plugin)\n */\nexport function Downgraded(): Plugin { // tslint:disable-line: function-name\n return {\n id: DowngradedID\n }\n}\n\n/**\n * For plugin developers only.\n * Reserved plugin ID for developers tools extension.\n *\n * @hidden\n * @ignore\n */\nexport const DevToolsID = Symbol('DevTools');\n\n/**\n * Return type of [DevTools](#devtools).\n */\nexport interface DevToolsExtensions {\n /**\n * Assigns custom label to identify the state in the development tools\n * @param name label for development tools\n */\n label(name: string): void;\n /**\n * Logs to the development tools\n */\n log(str: string, data?: any): void; // tslint:disable-line: no-any\n}\n\n/**\n * Returns access to the development tools for a given state.\n * Development tools are delivered as optional plugins.\n * You can activate development tools from `@hookstate/devtools`package,\n * for example. If no development tools are activated,\n * it returns an instance of dummy tools, which do nothing, when called.\n * \n * [Learn more...](https://hookstate.js.org/docs/devtools)\n * \n * @param state A state to relate to the extension.\n * \n * @returns Interface to interact with the development tools for a given state.\n * \n * @typeparam S Type of a value of a state\n */\nexport function DevTools(state: State): DevToolsExtensions {\n const plugin = state.attach(DevToolsID);\n if (plugin[0] instanceof Error) {\n return EmptyDevToolsExtensions;\n }\n return plugin[0] as DevToolsExtensions;\n}\n\n///\n/// INTERNAL SYMBOLS (LIBRARY IMPLEMENTATION)\n///\n\nconst isDevelopmentMode = typeof process === 'object' && \n typeof process.env === 'object' &&\n process.env.NODE_ENV === 'development'\n\nconst self = Symbol('self')\n\nconst EmptyDevToolsExtensions: DevToolsExtensions = {\n label() { /* */ },\n log() { /* */ }\n}\n\nenum ErrorId {\n InitStateToValueFromState = 101,\n SetStateToValueFromState = 102,\n GetStateWhenPromised = 103,\n SetStateWhenPromised = 104,\n SetStateNestedToPromised = 105,\n SetStateWhenDestroyed = 106,\n ToJson_Value = 108,\n ToJson_State = 109,\n GetUnknownPlugin = 120,\n\n SetProperty_State = 201,\n SetProperty_Value = 202,\n SetPrototypeOf_State = 203,\n SetPrototypeOf_Value = 204,\n PreventExtensions_State = 205,\n PreventExtensions_Value = 206,\n DefineProperty_State = 207,\n DefineProperty_Value = 208,\n DeleteProperty_State = 209,\n DeleteProperty_Value = 210,\n Construct_State = 211,\n Construct_Value = 212,\n Apply_State = 213,\n Apply_Value = 214,\n}\n\nclass StateInvalidUsageError extends Error {\n constructor(path: Path, id: ErrorId, details?: string) {\n super(`Error: HOOKSTATE-${id} [path: /${path.join('/')}${details ? `, details: ${details}` : ''}]. ` +\n `See https://hookstate.js.org/docs/exceptions#hookstate-${id}`)\n }\n}\n\ninterface Subscriber {\n onSet(paths: Path[], actions: (() => void)[]): void;\n}\n\ninterface Subscribable {\n subscribe(l: Subscriber): void;\n unsubscribe(l: Subscriber): void;\n}\n\nfunction isNoProxyInitializer() {\n try {\n const used = new Proxy({}, {});\n return false;\n } catch (e) {\n return true;\n }\n};\nconst IsNoProxy = isNoProxyInitializer()\n\nconst DowngradedID = Symbol('Downgraded');\nconst SelfMethodsID = Symbol('ProxyMarker');\n\nconst RootPath: Path = [];\nconst DestroyedEdition = -1\n\ntype Writeable = { -readonly [P in keyof T]: T[P] };\n\nclass Store implements Subscribable {\n private _edition = 0;\n\n private _subscribers: Set = new Set();\n private _setSubscribers: Set['onSet']> = new Set();\n private _destroySubscribers: Set['onDestroy']> = new Set();\n private _batchStartSubscribers: Set['onBatchStart']> = new Set();\n private _batchFinishSubscribers: Set['onBatchFinish']> = new Set();\n\n private _plugins: Map = new Map();\n\n private _promised?: Promised;\n\n private _batches = 0;\n private _batchesPendingPaths?: Path[];\n private _batchesPendingActions?: (() => void)[];\n\n constructor(private _value: StateValueAtRoot) {\n if (typeof _value === 'object' &&\n Promise.resolve(_value) === _value) {\n this._promised = this.createPromised(_value)\n this._value = none\n } else if (_value === none) {\n this._promised = this.createPromised(undefined)\n }\n }\n\n createPromised(newValue: StateValueAtPath | undefined) {\n const promised = new Promised(\n newValue ? Promise.resolve(newValue) : undefined,\n (r: StateValueAtPath) => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._promised = undefined\n this.set(RootPath, r, undefined)\n this.update([RootPath])\n }\n },\n () => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._edition += 1\n this.update([RootPath])\n }\n },\n () => {\n if (this._batchesPendingActions &&\n this._value !== none &&\n this.edition !== DestroyedEdition) {\n const actions = this._batchesPendingActions\n this._batchesPendingActions = undefined\n actions.forEach(a => a())\n }\n }\n );\n return promised;\n }\n\n get edition() {\n return this._edition;\n }\n\n get promised() {\n return this._promised;\n }\n\n get(path: Path) {\n let result = this._value;\n if (result === none) {\n return result;\n }\n path.forEach(p => {\n result = result[p];\n });\n return result;\n }\n\n set(path: Path, value: StateValueAtPath, mergeValue: Partial | undefined): Path {\n if (this._edition < 0) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenDestroyed)\n }\n\n if (path.length === 0) {\n // Root value UPDATE case,\n\n const onSetArg: Writeable = {\n path: path,\n state: value,\n value: value,\n previous: this._value,\n merged: mergeValue\n }\n if (value === none) {\n this._promised = this.createPromised(undefined)\n delete onSetArg.value\n delete onSetArg.state\n } else if (typeof value === 'object' && Promise.resolve(value) === value) {\n this._promised = this.createPromised(value)\n value = none\n delete onSetArg.value\n delete onSetArg.state\n } else if (this._promised && (!this._promised.resolver && !this._promised.fullfilled)) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenPromised)\n }\n\n let prevValue = this._value;\n if (prevValue === none) {\n delete onSetArg.previous\n }\n this._value = value;\n this.afterSet(onSetArg)\n\n if (prevValue === none && this._value !== none &&\n this.promised && this.promised.resolver) {\n this.promised.resolver(this._value)\n }\n\n return path;\n }\n\n if (typeof value === 'object' && Promise.resolve(value) === value) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateNestedToPromised)\n }\n\n let target = this._value;\n for (let i = 0; i < path.length - 1; i += 1) {\n target = target[path[i]];\n }\n\n const p = path[path.length - 1]\n if (p in target) {\n if (value !== none) {\n // Property UPDATE case\n let prevValue = target[p]\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n previous: prevValue,\n merged: mergeValue\n })\n\n return path;\n } else {\n // Property DELETE case\n let prevValue = target[p]\n if (Array.isArray(target) && typeof p === 'number') {\n target.splice(p, 1)\n } else {\n delete target[p]\n }\n this.afterSet({\n path: path,\n state: this._value,\n previous: prevValue,\n merged: mergeValue\n })\n\n // if an array of objects is about to loose existing property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n }\n\n if (value !== none) {\n // Property INSERT case\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n merged: mergeValue\n })\n\n // if an array of objects is about to be extended by new property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n\n // Non-existing property DELETE case\n // no-op\n return path;\n }\n\n update(paths: Path[]) {\n if (this._batches) {\n this._batchesPendingPaths = this._batchesPendingPaths || []\n this._batchesPendingPaths = this._batchesPendingPaths.concat(paths)\n return;\n }\n\n const actions: (() => void)[] = [];\n this._subscribers.forEach(s => s.onSet(paths, actions));\n actions.forEach(a => a());\n }\n\n afterSet(params: PluginCallbacksOnSetArgument) {\n if (this._edition !== DestroyedEdition) {\n this._edition += 1;\n this._setSubscribers.forEach(cb => cb(params))\n }\n }\n\n startBatch(path: Path, options?: { context?: AnyContext }): void {\n this._batches += 1\n\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchStartSubscribers.forEach(cb => cb(cbArgument))\n }\n\n finishBatch(path: Path, options?: { context?: AnyContext }): void {\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchFinishSubscribers.forEach(cb => cb(cbArgument))\n\n this._batches -= 1\n if (this._batches === 0) {\n if (this._batchesPendingPaths) {\n const paths = this._batchesPendingPaths\n this._batchesPendingPaths = undefined\n this.update(paths)\n }\n }\n }\n\n postponeBatch(action: () => void): void {\n this._batchesPendingActions = this._batchesPendingActions || []\n this._batchesPendingActions.push(action)\n }\n\n getPlugin(pluginId: symbol) {\n return this._plugins.get(pluginId)\n }\n\n register(plugin: Plugin) {\n const existingInstance = this._plugins.get(plugin.id)\n if (existingInstance) {\n return;\n }\n\n const pluginCallbacks = plugin.init ? plugin.init(this.toMethods().self) : {};\n this._plugins.set(plugin.id, pluginCallbacks);\n if (pluginCallbacks.onSet) {\n this._setSubscribers.add((p) => pluginCallbacks.onSet!(p))\n }\n if (pluginCallbacks.onDestroy) {\n this._destroySubscribers.add((p) => pluginCallbacks.onDestroy!(p))\n }\n if (pluginCallbacks.onBatchStart) {\n this._batchStartSubscribers.add((p) => pluginCallbacks.onBatchStart!(p))\n }\n if (pluginCallbacks.onBatchFinish) {\n this._batchFinishSubscribers.add((p) => pluginCallbacks.onBatchFinish!(p))\n }\n }\n\n toMethods() {\n return new StateMethodsImpl(\n this,\n RootPath,\n this.get(RootPath),\n this.edition,\n OnSetUsedNoAction\n )\n }\n\n subscribe(l: Subscriber) {\n this._subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this._subscribers.delete(l);\n }\n\n destroy() {\n this._destroySubscribers.forEach(cb => cb(this._value !== none ? { state: this._value } : {}))\n this._edition = DestroyedEdition\n }\n\n toJSON() {\n throw new StateInvalidUsageError(RootPath, ErrorId.ToJson_Value);\n }\n}\n\nclass Promised {\n public fullfilled?: true;\n public error?: StateErrorAtRoot;\n public resolver?: (_: StateValueAtRoot) => void;\n\n constructor(public promise: Promise | undefined,\n onResolve: (r: StateValueAtPath) => void,\n onReject: () => void,\n onPostResolve: () => void) {\n if (!promise) {\n promise = new Promise(resolve => {\n this.resolver = resolve;\n })\n }\n this.promise = promise\n .then(r => {\n this.fullfilled = true\n if (!this.resolver) {\n onResolve(r)\n }\n })\n .catch(err => {\n this.fullfilled = true\n this.error = err\n onReject()\n })\n .then(() => onPostResolve())\n }\n}\n\n// use symbol property to allow for easier reference finding\nconst ValueUnusedMarker = Symbol('ValueUnusedMarker');\n\nfunction OnSetUsedNoAction() { /** no action callback */ }\n\n// use symbol to mark that a function has no effect anymore\nconst UnmountedMarker = Symbol('UnmountedMarker');\nOnSetUsedNoAction[UnmountedMarker] = true\n\nclass StateMethodsImpl implements StateMethods, StateMethodsDestroy, Subscribable, Subscriber {\n private subscribers: Set | undefined;\n\n private isDowngraded: boolean | undefined;\n private childrenCache: Record> | undefined;\n private selfCache: State | undefined;\n private valueCache: StateValueAtPath = ValueUnusedMarker;\n \n constructor(\n public readonly state: Store,\n public readonly path: Path,\n private valueSource: S,\n private valueEdition: number,\n private readonly onSetUsed: () => void\n ) { }\n\n getUntracked(allowPromised?: boolean) {\n if (this.valueEdition !== this.state.edition) {\n this.valueSource = this.state.get(this.path)\n this.valueEdition = this.state.edition\n\n if (this.isMounted) {\n // this link is still mounted to a component\n // populate cache again to ensure correct tracking of usage\n // when React scans which states to rerender on update\n if (this.valueCache !== ValueUnusedMarker) {\n this.valueCache = ValueUnusedMarker\n this.get(true) // renew cache to keep it marked used\n }\n } else {\n // This link is not mounted to a component\n // for example, it might be global link or\n // a link which has been discarded after rerender\n // but still captured by some callback or an effect.\n // If we are here and if it was mounted before,\n // it means it has not been garbage collected\n // when a component unmounted.\n // We take this opportunity to clean up caches\n // to avoid memory leaks via stale children states cache.\n this.valueCache = ValueUnusedMarker\n delete this.childrenCache\n delete this.selfCache\n }\n }\n if (this.valueSource === none && !allowPromised) {\n if (this.state.promised && this.state.promised.error) {\n throw this.state.promised.error;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.GetStateWhenPromised)\n }\n return this.valueSource;\n }\n\n get(allowPromised?: boolean) {\n const currentValue = this.getUntracked(allowPromised)\n if (this.valueCache === ValueUnusedMarker) {\n if (this.isDowngraded) {\n this.valueCache = currentValue;\n } else if (Array.isArray(currentValue)) {\n this.valueCache = this.valueArrayImpl(currentValue as unknown as StateValueAtPath[]);\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n this.valueCache = this.valueObjectImpl(currentValue as unknown as object);\n } else {\n this.valueCache = currentValue;\n }\n }\n return this.valueCache as S;\n }\n\n get value(): S {\n return this.get()\n }\n\n setUntracked(newValue: SetStateAction, mergeValue?: Partial): [Path] {\n if (typeof newValue === 'function') {\n newValue = (newValue as ((prevValue: S) => S))(this.getUntracked());\n }\n if (typeof newValue === 'object' && newValue !== null && newValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(this.path, ErrorId.SetStateToValueFromState)\n }\n return [this.state.set(this.path, newValue, mergeValue)];\n }\n\n set(newValue: SetStateAction) {\n this.state.update(this.setUntracked(newValue));\n }\n\n mergeUntracked(sourceValue: SetPartialStateAction): Path[] {\n const currentValue = this.getUntracked()\n if (typeof sourceValue === 'function') {\n sourceValue = (sourceValue as Function)(currentValue);\n }\n\n let updatedPaths: [Path];\n let deletedOrInsertedProps = false\n\n if (Array.isArray(currentValue)) {\n if (Array.isArray(sourceValue)) {\n return this.setUntracked(currentValue.concat(sourceValue) as unknown as S, sourceValue)\n } else {\n const deletedIndexes: number[] = []\n Object.keys(sourceValue).sort().forEach(i => {\n const index = Number(i);\n const newPropValue = sourceValue[index]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n deletedIndexes.push(index)\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(index in currentValue);\n (currentValue as StateValueAtPath[])[index] = newPropValue\n }\n });\n // indexes are ascending sorted as per above\n // so, delete one by one from the end\n // this way index positions do not change\n deletedIndexes.reverse().forEach(p => {\n (currentValue as unknown as []).splice(p, 1)\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n }\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n Object.keys(sourceValue).forEach(key => {\n const newPropValue = sourceValue[key]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n delete currentValue[key]\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(key in currentValue)\n currentValue[key] = newPropValue\n }\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n } else if (typeof currentValue === 'string') {\n return this.setUntracked((currentValue + String(sourceValue)) as unknown as S, sourceValue)\n } else {\n return this.setUntracked(sourceValue as S)\n }\n\n if (updatedPaths.length !== 1 || updatedPaths[0] !== this.path || deletedOrInsertedProps) {\n return updatedPaths\n }\n const updatedPath = updatedPaths[0]\n return Object.keys(sourceValue).map(p => updatedPath.slice().concat(p))\n }\n\n merge(sourceValue: SetPartialStateAction) {\n this.state.update(this.mergeUntracked(sourceValue));\n }\n\n nested(key: K): State {\n return this.child(key as string | number).self as State\n }\n \n rerender(paths: Path[]) {\n this.state.update(paths)\n }\n\n destroy(): void {\n this.state.destroy()\n }\n\n subscribe(l: Subscriber) {\n if (this.subscribers === undefined) {\n this.subscribers = new Set();\n }\n this.subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this.subscribers!.delete(l);\n }\n \n get isMounted(): boolean {\n return !this.onSetUsed[UnmountedMarker]\n }\n\n onUnmount() {\n this.onSetUsed[UnmountedMarker] = true\n }\n\n onSet(paths: Path[], actions: (() => void)[]): boolean {\n const update = () => {\n if (this.isDowngraded && this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n for (let path of paths) {\n const firstChildKey = path[this.path.length];\n if (firstChildKey === undefined) {\n if (this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n } else {\n const firstChildValue = this.childrenCache && this.childrenCache[firstChildKey];\n if (firstChildValue && firstChildValue.onSet(paths, actions)) {\n return true;\n }\n }\n }\n return false;\n }\n\n const updated = update();\n if (!updated && this.subscribers !== undefined) {\n this.subscribers.forEach(s => {\n s.onSet(paths, actions)\n })\n }\n return updated;\n }\n\n get keys(): InferredStateKeysType {\n const value = this.get()\n if (Array.isArray(value)) {\n return Object.keys(value).map(i => Number(i)).filter(i => Number.isInteger(i)) as\n unknown as InferredStateKeysType;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value) as unknown as InferredStateKeysType;\n }\n return undefined as InferredStateKeysType;\n }\n\n child(key: number | string) {\n // if this state is not mounted to a hook,\n // we do not cache children to avoid unnecessary memory leaks\n if (this.isMounted) {\n this.childrenCache = this.childrenCache || {};\n const cachehit = this.childrenCache[key];\n if (cachehit) {\n return cachehit;\n }\n }\n const r = new StateMethodsImpl(\n this.state,\n this.path.slice().concat(key),\n this.valueSource[key],\n this.valueEdition,\n this.onSetUsed,\n )\n if (this.isDowngraded) {\n r.isDowngraded = true;\n }\n if (this.childrenCache) {\n this.childrenCache[key] = r;\n }\n return r;\n }\n \n private valueArrayImpl(currentValue: StateValueAtPath[]): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === 'length') {\n return (target as []).length;\n }\n if (key in Array.prototype) {\n return Array.prototype[key];\n }\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n const index = Number(key);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.child(index).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n private valueObjectImpl(currentValue: object): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n return this.child(key).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n get self(): State {\n if (this.selfCache) {\n return this.selfCache\n }\n \n const getter = (_: object, key: PropertyKey) => {\n if (key === self) {\n return this\n }\n if (typeof key === 'symbol') {\n return undefined\n }\n if (key === 'toJSON') {\n throw new StateInvalidUsageError(this.path, ErrorId.ToJson_State);\n }\n \n let nestedGetter = (prop: PropertyKey) => {\n const currentDowngraded = this.isDowngraded; // relevant for IE11 only\n const currentValue = this.get(); // IE11 marks this as downgraded\n this.isDowngraded = currentDowngraded; // relevant for IE11 only\n if (// if currentValue is primitive type\n (typeof currentValue !== 'object' || currentValue === null) &&\n // if promised, it will be none\n currentValue !== none) {\n // This was an error case, but various tools like webpack bundler\n // and react dev tools attempt to get props out of non-null object,\n // so this was changed to return just undefined for any property request\n // as there is no way to fix 3rd party tools.\n // Logging a warning to console is also not an option\n // as it pollutes console for legitimate apps on app start app.\n // Ref: https://github.com/avkonst/hookstate/issues/125\n return undefined\n }\n\n if (Array.isArray(currentValue)) {\n if (prop === 'length') {\n return currentValue.length;\n }\n if (prop in Array.prototype) {\n return Array.prototype[prop];\n }\n const index = Number(prop);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.nested(index as keyof S)\n }\n return this.nested(prop.toString() as keyof S)\n }\n\n switch (key) {\n case 'path':\n return this.path\n case 'keys':\n return this.keys\n case 'value':\n return this.value\n case 'ornull':\n return this.ornull\n case 'promised':\n return this.promised\n case 'error':\n return this.error\n case 'get':\n return () => this.get()\n case 'set':\n return (p: SetStateAction) => this.set(p)\n case 'merge':\n return (p: SetPartialStateAction) => this.merge(p)\n case 'nested':\n return (p: keyof S) => nestedGetter(p)\n case 'batch':\n // tslint:disable-next-line: no-any\n return (action: () => R, context: Exclude) => this.batch(action, context)\n case 'attach':\n return (p: symbol) => this.attach(p)\n case 'destroy':\n return () => this.destroy()\n default:\n return nestedGetter(key)\n }\n }\n \n if (IsNoProxy) {\n // minimal support for IE11\n const result = (Array.isArray(this.valueSource) ? [] : {}) as State;\n [self, 'toJSON', 'path', 'keys', 'value', 'ornull',\n 'promised', 'error', 'get', 'set', 'merge',\n 'nested', 'batch', 'attach', 'destroy']\n .forEach(key => {\n Object.defineProperty(result, key, {\n get: () => getter(result, key)\n })\n })\n if (typeof this.valueSource === 'object' && this.valueSource !== null) {\n Object.keys(this.valueSource).forEach(key => {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => getter(result, key)\n })\n })\n }\n this.selfCache = result;\n return this.selfCache\n }\n \n this.selfCache = proxyWrap(this.path, this.valueSource,\n () => {\n this.get() // get latest & mark used\n return this.valueSource\n },\n getter,\n (_, key, value) => {\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_State)\n },\n false) as unknown as State;\n return this.selfCache\n }\n \n get promised(): boolean {\n const currentValue = this.get(true) // marks used\n if (currentValue === none && this.state.promised && !this.state.promised.fullfilled) {\n return true;\n }\n return false;\n }\n\n get error(): StateErrorAtRoot | undefined {\n const currentValue = this.get(true) // marks used\n if (currentValue === none) {\n if (this.state.promised && this.state.promised.fullfilled) {\n return this.state.promised.error;\n }\n this.get() // will throw 'read while promised' exception\n }\n return undefined;\n }\n\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R {\n const opts = { context: context }\n try {\n this.state.startBatch(this.path, opts)\n const result = action(this.self) as R\n if (result as unknown as Symbol === postpone) {\n this.state.postponeBatch(() => this.batch(action, context))\n }\n return result\n } finally {\n this.state.finishBatch(this.path, opts)\n }\n }\n\n get ornull(): InferredStateOrnullType {\n const value = this.get()\n if (value === null || value === undefined) {\n return value as unknown as InferredStateOrnullType;\n }\n return this.self as InferredStateOrnullType;\n }\n\n attach(plugin: () => Plugin): State\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n attach(p: (() => Plugin) | symbol):\n State | [PluginCallbacks | Error, PluginStateControl] {\n if (typeof p === 'function') {\n const pluginMeta = p();\n if (pluginMeta.id === DowngradedID) {\n this.isDowngraded = true;\n if (this.valueCache !== ValueUnusedMarker) {\n const currentValue = this.getUntracked(true);\n this.valueCache = currentValue;\n }\n return this.self;\n }\n this.state.register(pluginMeta);\n return this.self;\n } else {\n return [\n this.state.getPlugin(p) ||\n (new StateInvalidUsageError(this.path, ErrorId.GetUnknownPlugin, p.toString())), \n this\n ];\n }\n }\n}\n\nfunction proxyWrap(\n path: Path,\n // tslint:disable-next-line: no-any\n targetBootstrap: any,\n // tslint:disable-next-line: no-any\n targetGetter: () => any,\n // tslint:disable-next-line: no-any\n propertyGetter: (unused: any, key: PropertyKey) => any,\n // tslint:disable-next-line: no-any\n propertySetter: (unused: any, p: PropertyKey, value: any, receiver: any) => boolean,\n isValueProxy: boolean\n) {\n const onInvalidUsage = (op: ErrorId) => {\n throw new StateInvalidUsageError(path, op)\n }\n if (typeof targetBootstrap !== 'object' || targetBootstrap === null) {\n targetBootstrap = {}\n }\n return new Proxy(targetBootstrap, {\n getPrototypeOf: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf#Invariants\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return null;\n }\n return Object.getPrototypeOf(targetReal);\n },\n setPrototypeOf: (target, v) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.SetPrototypeOf_State :\n ErrorId.SetPrototypeOf_Value)\n },\n isExtensible: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible#Invariants\n return true; // required to satisfy the invariants of the getPrototypeOf\n // return Object.isExtensible(target);\n },\n preventExtensions: (target) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.PreventExtensions_State :\n ErrorId.PreventExtensions_Value)\n },\n getOwnPropertyDescriptor: (target, p) => {\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return undefined;\n }\n const origin = Object.getOwnPropertyDescriptor(targetReal, p);\n if (origin && Array.isArray(targetReal) && p in Array.prototype) {\n return origin;\n }\n return origin && {\n configurable: true, // JSON.stringify() does not work for an object without it\n enumerable: origin.enumerable,\n get: () => propertyGetter(targetReal, p),\n set: undefined\n };\n },\n has: (target, p) => {\n if (typeof p === 'symbol') {\n return false;\n }\n const targetReal = targetGetter()\n if (typeof targetReal === 'object' && targetReal !== null) {\n return p in targetReal;\n }\n return false;\n },\n get: propertyGetter,\n set: propertySetter,\n deleteProperty: (target, p) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DeleteProperty_State :\n ErrorId.DeleteProperty_Value)\n },\n defineProperty: (target, p, attributes) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DefineProperty_State :\n ErrorId.DefineProperty_Value)\n },\n ownKeys: (target) => {\n const targetReal = targetGetter()\n if (Array.isArray(targetReal)) {\n return Object.keys(targetReal).concat('length');\n }\n if (targetReal === undefined || targetReal === null) {\n return [];\n }\n return Object.keys(targetReal);\n },\n apply: (target, thisArg, argArray?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Apply_State:\n ErrorId.Apply_Value)\n },\n construct: (target, argArray, newTarget?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Construct_State :\n ErrorId.Construct_Value)\n }\n });\n}\n\nfunction createStore(initial: SetInitialStateAction): Store {\n let initialValue: S | Promise = initial as (S | Promise);\n if (typeof initial === 'function') {\n initialValue = (initial as (() => S | Promise))();\n }\n if (typeof initialValue === 'object' && initialValue !== null && initialValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(RootPath, ErrorId.InitStateToValueFromState)\n }\n return new Store(initialValue);\n}\n\nfunction useSubscribedStateMethods(\n state: Store,\n path: Path,\n update: () => void,\n subscribeTarget: Subscribable\n) {\n const link = new StateMethodsImpl(\n state,\n path,\n state.get(path),\n state.edition,\n update,\n );\n // useLayoutEffect here instead of useEffect because of this issue:\n // https://github.com/avkonst/hookstate/issues/165#issuecomment-824670930\n // and very likely this issue:\n // https://github.com/avkonst/hookstate/issues/186\n // and probably this issue:\n // https://github.com/avkonst/hookstate/issues/145\n React.useLayoutEffect(() => {\n subscribeTarget.subscribe(link);\n return () => {\n link.onUnmount()\n subscribeTarget.unsubscribe(link);\n }\n });\n return link;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CA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AAA;KACJ,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AAChB;;;;"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 85599bc1..590e9d34 100644 --- a/dist/index.js +++ b/dist/index.js @@ -105,7 +105,11 @@ function useHookstate(source) { // Global state mount or destroyed link // eslint-disable-next-line react-hooks/rules-of-hooks var _b = React.useState({ state: parentMethods.state }), value_1 = _b[0], setValue_2 = _b[1]; - return useSubscribedStateMethods(value_1.state, parentMethods.path, function () { return setValue_2({ state: value_1.state }); }, value_1.state).self; + var state = useSubscribedStateMethods(value_1.state, RootPath, function () { return setValue_2({ state: value_1.state }); }, value_1.state).self; + for (var ind = 0; ind < parentMethods.path.length; ind += 1) { + state = state.nested(parentMethods.path[ind]); + } + return state; } } else { diff --git a/dist/index.js.map b/dist/index.js.map index 919c0035..3e1bb5cc 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../node_modules/tslib/tslib.es6.js","../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import React from 'react';\n\n///\n/// EXPORTED SYMBOLS (LIBRARY INTERFACE)\n///\n\n/**\n * 'JSON path' from root of a state object to a nested property.\n * Return type of [StateMethod.path](#readonly-path).\n *\n * For example, an object `{ a: [{ b: 1 }, { 1000: 'value' }, '3rd'] }`,\n * has got the following paths pointing to existing properties:\n *\n * - `[]`\n * - `['a']`\n * - `['a', 0]`\n * - `['a', 0, 'b']`\n * - `['a', 1]`\n * - `['a', 1, 1000]`\n * - `['a', 2]`\n */\nexport type Path = ReadonlyArray;\n\n/**\n * Type of an argument of [StateMethods.set](#set).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetStateAction = (S | Promise) | ((prevState: S) => (S | Promise));\n\n/**\n * Type of an argument of [StateMethods.merge](#merge).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetPartialStateAction =\n S extends ReadonlyArray<(infer U)> ?\n ReadonlyArray | Record | ((prevValue: S) => (ReadonlyArray | Record)) :\n S extends object | string ? Partial | ((prevValue: S) => Partial) :\n React.SetStateAction;\n\n/**\n * Type of an argument of [createState](#createstate) and [useState](#usestate).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetInitialStateAction = S | Promise | (() => S | Promise)\n\n/**\n * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function.\n * \n * [Learn more...](https://hookstate.js.org/docs/asynchronous-state#executing-an-action-when-state-is-loaded)\n */\nexport const postpone = Symbol('postpone')\n\n/**\n * Special symbol which might be used to delete properties\n * from an object calling [StateMethods.set](#set) or [StateMethods.merge](#merge).\n * \n * [Learn more...](https://hookstate.js.org/docs/nested-state#deleting-existing-element)\n */\nexport const none = Symbol('none') as StateValueAtPath;\n\n/**\n * Return type of [StateMethods.keys](#readonly-keys).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateKeysType =\n S extends ReadonlyArray ? ReadonlyArray :\n S extends null ? undefined :\n S extends object ? ReadonlyArray :\n undefined;\n\n/**\n * Return type of [StateMethods.map()](#map).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateOrnullType =\n S extends undefined ? undefined :\n S extends null ? null : State;\n\n/**\n * For plugin developers only.\n * An instance to manipulate the state in more controlled way.\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginStateControl {\n /**\n * Get state value, but do not leave the traces of reading it.\n */\n getUntracked(): S;\n /**\n * Set new state value, but do not trigger rerender.\n * \n * @param newValue new value to set to a state.\n */\n setUntracked(newValue: SetStateAction): Path[];\n /**\n * Merge new state value, but do not trigger rerender.\n * \n * @param mergeValue new partial value to merge with the current state value and set.\n */\n mergeUntracked(mergeValue: SetPartialStateAction): Path[];\n /**\n * Trigger rerender for hooked states, where values at the specified paths are used.\n * \n * @param paths paths of the state variables to search for being used by components and rerender\n */\n rerender(paths: Path[]): void;\n}\n\n/**\n * An interface to manage a state in Hookstate.\n * \n * @typeparam S Type of a value of a state\n */\nexport interface StateMethods {\n /**\n * 'Javascript' object 'path' to an element relative to the root object\n * in the state. For example:\n *\n * ```tsx\n * const state = useState([{ name: 'First Task' }])\n * state.path IS []\n * state[0].path IS [0]\n * state.[0].name.path IS [0, 'name']\n * ```\n */\n readonly path: Path;\n\n /**\n * Return the keys of nested states.\n * For a given state of [State](#state) type,\n * `state.keys` will be structurally equal to Object.keys(state),\n * with two minor difference:\n * 1. if `state.value` is an array, the returned result will be\n * an array of numbers, not strings like with `Object.keys`.\n * 2. if `state.value` is not an object, the returned result will be undefined.\n */\n readonly keys: InferredStateKeysType;\n\n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.get](#get) method.\n *\n * This property is more useful than [get](#get) method for the cases,\n * when a value may hold null or undefined values.\n * Typescript compiler does not handle elimination of undefined with get(),\n * like in the following examples, but value does:\n *\n * ```tsx\n * const state = useState(0)\n * const myvalue: number = state.value\n * ? state.value + 1\n * : 0; // <-- compiles\n * const myvalue: number = state.get()\n * ? state.get() + 1\n * : 0; // <-- does not compile\n * ```\n */\n readonly value: S;\n\n /**\n * True if state value is not yet available (eg. equal to a promise)\n */\n readonly promised: boolean;\n \n /**\n * If a state was set to a promise and the promise was rejected,\n * this property will return the error captured from the promise rejection\n */\n readonly error: StateErrorAtRoot | undefined;\n \n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.value](#readonly-value) method.\n */\n get(): S;\n \n /**\n * Sets new value for a state.\n * If `this.path === []`,\n * it is similar to the `setState` variable returned by `React.useState` hook.\n * If `this.path !== []`, it sets only the segment of the state value, pointed out by the path.\n * Unlike [merge](#merge) method, this method will not accept partial updates.\n * Partial updates can be also done by walking the nested states and setting those.\n *\n * @param newValue new value to set to a state.\n * It can be a value, a promise resolving to a value\n * (only if [this.path](#readonly-path) is `[]`),\n * or a function returning one of these.\n * The function receives the current state value as an argument.\n */\n set(newValue: SetStateAction): void;\n \n /**\n * Similarly to [set](#set) method updates state value.\n *\n * - If current state value is an object, it does partial update for the object.\n * - If state value is an array and the argument is an array too,\n * it concatenates the current value with the value of the argument and sets it to the state.\n * - If state value is an array and the `merge` argument is an object,\n * it does partial update for the current array value.\n * - If current state value is a string, it concatenates the current state\n * value with the argument converted to string and sets the result to the state.\n */\n merge(newValue: SetPartialStateAction): void;\n \n /**\n * Returns nested state by key.\n * `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`,\n * but also works for properties, which names collide with names of state methods.\n * \n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n * \n * @param key child property name or index\n */\n nested(key: K): State;\n \n /**\n * Runs the provided action callback with optimised re-rendering.\n * Updating state within a batch action does not trigger immediate rerendering.\n * Instead, all required rerendering is done once the batch is finished.\n * \n * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates\n * \n * @param action callback function to execute in a batch\n * \n * @param context custom user's value, which is passed to plugins\n */\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R;\n\n /**\n * If state value is null or undefined, returns state value.\n * Otherwise, it returns this state instance but\n * with null and undefined removed from the type parameter.\n * \n * [Learn more...](https://hookstate.js.org/docs/nullable-state)\n */\n ornull: InferredStateOrnullType;\n\n /**\n * Adds plugin to the state.\n * \n * [Learn more...](https://hookstate.js.org/docs/extensions-overview)\n */\n attach(plugin: () => Plugin): State\n \n /**\n * For plugin developers only.\n * It is a method to get the instance of the previously attached plugin.\n * If a plugin has not been attached to a state,\n * it returns an Error as the first element.\n * A plugin may trhow an error to indicate that plugin has not been attached.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n}\n\n/**\n * Mixin for the [StateMethods](#interfacesstatemethodsmd) for a [State](#state),\n * which can be destroyed by a client.\n */\nexport interface StateMethodsDestroy {\n /**\n * Destroys an instance of a state, so\n * it can clear the allocated native resources (if any)\n * and can not be used anymore after it has been destroyed.\n */\n destroy(): void;\n}\n\n/**\n * Type of a result of [createState](#createstate) and [useState](#usestate) functions\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more about global states...](https://hookstate.js.org/docs/global-state)\n * [Learn more about local states...](https://hookstate.js.org/docs/local-state)\n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n */\nexport type State = StateMethods & (\n S extends ReadonlyArray<(infer U)> ? ReadonlyArray> :\n S extends object ? Omit<\n { readonly [K in keyof Required]: State; },\n keyof StateMethods | keyof StateMethodsDestroy\n > : {}\n);\n\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with root state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with nested state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtPath = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with state error.\n *\n * @hidden\n * @ignore\n */\nexport type StateErrorAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with context value.\n *\n * @hidden\n * @ignore\n */\nexport type AnyContext = any; //tslint:disable-line: no-any\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onSet argument type.\n */\nexport interface PluginCallbacksOnSetArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n /**\n * **A note about previous values and merging:**\n * State values are muteable in Hookstate for performance reasons. This causes a side effect in the merge operation.\n * While merging, the previous state object is mutated as the desired changes are applied. This means the value of\n * `previous` will reflect the merged changes as well, matching the new `state` value rather than the previous\n * state value. As a result, the `previous` property is unreliable when merge is used. The\n * [merged](#optional-readonly-merged) property can be used to detect which values were merged in but it will not\n * inform you whether those values are different from the previous state.\n *\n * As a workaround, you can [batch state updates](https://hookstate.js.org/docs/performance-batched-updates) or\n * replace merge calls with the immutable-style set operation like so:\n *\n * ```\n * state.set(p => {\n * let copy = p.clone(); /// here it is up to you to define how to clone the current state\n * copy.field = 'new value for field';\n * delete copy.fieldToDelete;\n * return copy;\n * })\n * ```\n */\n readonly previous?: StateValueAtPath,\n readonly value?: StateValueAtPath,\n readonly merged?: StateValueAtPath,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onDestroy argument type.\n */\nexport interface PluginCallbacksOnDestroyArgument {\n readonly state?: StateValueAtRoot,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onBatchStart/Finish argument type.\n */\nexport interface PluginCallbacksOnBatchArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n readonly context?: AnyContext,\n}\n\n/**\n * For plugin developers only.\n * Set of callbacks, a plugin may subscribe to.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginCallbacks {\n readonly onSet?: (arg: PluginCallbacksOnSetArgument) => void,\n readonly onDestroy?: (arg: PluginCallbacksOnDestroyArgument) => void,\n readonly onBatchStart?: (arg: PluginCallbacksOnBatchArgument) => void,\n readonly onBatchFinish?: (arg: PluginCallbacksOnBatchArgument) => void,\n};\n\n/**\n * For plugin developers only.\n * Hookstate plugin specification and factory method.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface Plugin {\n /**\n * Unique identifier of a plugin.\n */\n readonly id: symbol;\n /**\n * Initializer for a plugin when it is attached for the first time.\n */\n readonly init?: (state: State) => PluginCallbacks;\n}\n\n/**\n * Creates new state and returns it.\n *\n * You can create as many global states as you need.\n *\n * When you the state is not needed anymore,\n * it should be destroyed by calling\n * `destroy()` method of the returned instance.\n * This is necessary for some plugins,\n * which allocate native resources,\n * like subscription to databases, broadcast channels, etc.\n * In most cases, a global state is used during\n * whole life time of an application and would not require\n * destruction. However, if you have got, for example,\n * a catalog of dynamically created and destroyed global states,\n * the states should be destroyed as advised above.\n *\n * @param initial Initial value of the state.\n * It can be a value OR a promise,\n * which asynchronously resolves to a value,\n * OR a function returning a value or a promise.\n *\n * @typeparam S Type of a value of the state\n *\n * @returns [State](#state) instance,\n * which can be used directly to get and set state value\n * outside of React components.\n * When you need to use the state in a functional `React` component,\n * pass the created state to [useState](#usestate) function and\n * use the returned result in the component's logic.\n */\nexport function createState(\n initial: SetInitialStateAction\n): State & StateMethodsDestroy {\n const methods = createStore(initial).toMethods();\n const devtools = createState[DevToolsID]\n if (devtools) {\n methods.attach(devtools)\n }\n return methods.self as State & StateMethodsDestroy;\n}\n\n/**\n * Enables a functional React component to use a state,\n * either created by [createState](#createstate) (*global* state) or\n * derived from another call to [useState](#usestate) (*scoped* state).\n *\n * The `useState` forces a component to rerender every time, when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * For example, if the state value is `{ a: 1, b: 2 }` and\n * a component uses only `a` property of the state, it will rerender\n * only when the whole state object is updated or when `a` property is updated.\n * Setting the state value/property to the same value is also considered as an update.\n *\n * A component can use one or many states,\n * i.e. you may call `useState` multiple times for multiple states.\n *\n * The same state can be used by multiple different components.\n *\n * @param source a reference to the state to hook into\n *\n * The `useState` is a hook and should follow React's rules of hooks.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: State\n): State;\n/**\n * This function enables a functional React component to use a state,\n * created per component by [useState](#usestate) (*local* state).\n * In this case `useState` behaves similarly to `React.useState`,\n * but the returned instance of [State](#state)\n * has got more features.\n *\n * When a state is used by only one component, and maybe it's children,\n * it is recommended to use *local* state instead of *global*,\n * which is created by [createState](#createstate).\n *\n * *Local* (per component) state is created when a component is mounted\n * and automatically destroyed when a component is unmounted.\n *\n * The same as with the usage of a *global* state,\n * `useState` forces a component to rerender when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * You can use as many local states within the same component as you need.\n *\n * @param source An initial value state.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: SetInitialStateAction\n): State;\nexport function useState(\n source: SetInitialStateAction | State\n): State {\n return useHookstate(source as State);\n}\n\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: State\n): State;\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: SetInitialStateAction\n): State;\nexport function useHookstate(\n source: SetInitialStateAction | State\n): State {\n const parentMethods = typeof source === 'object' && source !== null ?\n source[self] as StateMethodsImpl | undefined :\n undefined;\n if (parentMethods) {\n if (parentMethods.isMounted) {\n // Scoped state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [, setValue] = React.useState({});\n return useSubscribedStateMethods(\n parentMethods.state,\n parentMethods.path,\n () => setValue({}),\n parentMethods).self;\n } else {\n // Global state mount or destroyed link\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState({ state: parentMethods.state });\n return useSubscribedStateMethods(\n value.state,\n parentMethods.path,\n () => setValue({ state: value.state }),\n value.state).self;\n }\n } else {\n // Local state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState(() => ({ state: createStore(source) }));\n const result = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state);\n\n if (isDevelopmentMode) {\n // This is a workaround for the issue:\n // https://github.com/avkonst/hookstate/issues/109\n // See technical notes on React behavior here:\n // https://github.com/apollographql/apollo-client/issues/5870#issuecomment-689098185\n const isEffectExecutedAfterRender = React.useRef(false);\n isEffectExecutedAfterRender.current = false; // not yet...\n \n React.useEffect(() => {\n isEffectExecutedAfterRender.current = true; // ... and now, yes!\n // The state is not destroyed intentionally\n // under hot reload case.\n return () => { isEffectExecutedAfterRender.current && value.state.destroy() }\n });\n } else {\n React.useEffect(() => () => value.state.destroy(), []);\n }\n const devtools = useState[DevToolsID]\n if (devtools) {\n result.attach(devtools)\n }\n return result.self;\n }\n}\n\n/**\n * Allows to use a state without defining a functional react component.\n * It can be also used in class-based React components. It is also\n * particularly useful for creating *scoped* states.\n *\n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: State,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\n/**\n * Allows to use a state without defining a functional react component.\n * See more at [StateFragment](#statefragment)\n * \n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\nexport function StateFragment(\n props: {\n state: State | SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement {\n const scoped = useState(props.state as State);\n return props.children(scoped);\n}\n\n/**\n * A plugin which allows to opt-out from usage of Javascript proxies for\n * state usage tracking. It is useful for performance tuning.\n * \n * [Learn more...](https://hookstate.js.org/docs/performance-managed-rendering#downgraded-plugin)\n */\nexport function Downgraded(): Plugin { // tslint:disable-line: function-name\n return {\n id: DowngradedID\n }\n}\n\n/**\n * For plugin developers only.\n * Reserved plugin ID for developers tools extension.\n *\n * @hidden\n * @ignore\n */\nexport const DevToolsID = Symbol('DevTools');\n\n/**\n * Return type of [DevTools](#devtools).\n */\nexport interface DevToolsExtensions {\n /**\n * Assigns custom label to identify the state in the development tools\n * @param name label for development tools\n */\n label(name: string): void;\n /**\n * Logs to the development tools\n */\n log(str: string, data?: any): void; // tslint:disable-line: no-any\n}\n\n/**\n * Returns access to the development tools for a given state.\n * Development tools are delivered as optional plugins.\n * You can activate development tools from `@hookstate/devtools`package,\n * for example. If no development tools are activated,\n * it returns an instance of dummy tools, which do nothing, when called.\n * \n * [Learn more...](https://hookstate.js.org/docs/devtools)\n * \n * @param state A state to relate to the extension.\n * \n * @returns Interface to interact with the development tools for a given state.\n * \n * @typeparam S Type of a value of a state\n */\nexport function DevTools(state: State): DevToolsExtensions {\n const plugin = state.attach(DevToolsID);\n if (plugin[0] instanceof Error) {\n return EmptyDevToolsExtensions;\n }\n return plugin[0] as DevToolsExtensions;\n}\n\n///\n/// INTERNAL SYMBOLS (LIBRARY IMPLEMENTATION)\n///\n\nconst isDevelopmentMode = typeof process === 'object' && \n typeof process.env === 'object' &&\n process.env.NODE_ENV === 'development'\n\nconst self = Symbol('self')\n\nconst EmptyDevToolsExtensions: DevToolsExtensions = {\n label() { /* */ },\n log() { /* */ }\n}\n\nenum ErrorId {\n InitStateToValueFromState = 101,\n SetStateToValueFromState = 102,\n GetStateWhenPromised = 103,\n SetStateWhenPromised = 104,\n SetStateNestedToPromised = 105,\n SetStateWhenDestroyed = 106,\n ToJson_Value = 108,\n ToJson_State = 109,\n GetUnknownPlugin = 120,\n\n SetProperty_State = 201,\n SetProperty_Value = 202,\n SetPrototypeOf_State = 203,\n SetPrototypeOf_Value = 204,\n PreventExtensions_State = 205,\n PreventExtensions_Value = 206,\n DefineProperty_State = 207,\n DefineProperty_Value = 208,\n DeleteProperty_State = 209,\n DeleteProperty_Value = 210,\n Construct_State = 211,\n Construct_Value = 212,\n Apply_State = 213,\n Apply_Value = 214,\n}\n\nclass StateInvalidUsageError extends Error {\n constructor(path: Path, id: ErrorId, details?: string) {\n super(`Error: HOOKSTATE-${id} [path: /${path.join('/')}${details ? `, details: ${details}` : ''}]. ` +\n `See https://hookstate.js.org/docs/exceptions#hookstate-${id}`)\n }\n}\n\ninterface Subscriber {\n onSet(paths: Path[], actions: (() => void)[]): void;\n}\n\ninterface Subscribable {\n subscribe(l: Subscriber): void;\n unsubscribe(l: Subscriber): void;\n}\n\nfunction isNoProxyInitializer() {\n try {\n const used = new Proxy({}, {});\n return false;\n } catch (e) {\n return true;\n }\n};\nconst IsNoProxy = isNoProxyInitializer()\n\nconst DowngradedID = Symbol('Downgraded');\nconst SelfMethodsID = Symbol('ProxyMarker');\n\nconst RootPath: Path = [];\nconst DestroyedEdition = -1\n\ntype Writeable = { -readonly [P in keyof T]: T[P] };\n\nclass Store implements Subscribable {\n private _edition = 0;\n\n private _subscribers: Set = new Set();\n private _setSubscribers: Set['onSet']> = new Set();\n private _destroySubscribers: Set['onDestroy']> = new Set();\n private _batchStartSubscribers: Set['onBatchStart']> = new Set();\n private _batchFinishSubscribers: Set['onBatchFinish']> = new Set();\n\n private _plugins: Map = new Map();\n\n private _promised?: Promised;\n\n private _batches = 0;\n private _batchesPendingPaths?: Path[];\n private _batchesPendingActions?: (() => void)[];\n\n constructor(private _value: StateValueAtRoot) {\n if (typeof _value === 'object' &&\n Promise.resolve(_value) === _value) {\n this._promised = this.createPromised(_value)\n this._value = none\n } else if (_value === none) {\n this._promised = this.createPromised(undefined)\n }\n }\n\n createPromised(newValue: StateValueAtPath | undefined) {\n const promised = new Promised(\n newValue ? Promise.resolve(newValue) : undefined,\n (r: StateValueAtPath) => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._promised = undefined\n this.set(RootPath, r, undefined)\n this.update([RootPath])\n }\n },\n () => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._edition += 1\n this.update([RootPath])\n }\n },\n () => {\n if (this._batchesPendingActions &&\n this._value !== none &&\n this.edition !== DestroyedEdition) {\n const actions = this._batchesPendingActions\n this._batchesPendingActions = undefined\n actions.forEach(a => a())\n }\n }\n );\n return promised;\n }\n\n get edition() {\n return this._edition;\n }\n\n get promised() {\n return this._promised;\n }\n\n get(path: Path) {\n let result = this._value;\n if (result === none) {\n return result;\n }\n path.forEach(p => {\n result = result[p];\n });\n return result;\n }\n\n set(path: Path, value: StateValueAtPath, mergeValue: Partial | undefined): Path {\n if (this._edition < 0) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenDestroyed)\n }\n\n if (path.length === 0) {\n // Root value UPDATE case,\n\n const onSetArg: Writeable = {\n path: path,\n state: value,\n value: value,\n previous: this._value,\n merged: mergeValue\n }\n if (value === none) {\n this._promised = this.createPromised(undefined)\n delete onSetArg.value\n delete onSetArg.state\n } else if (typeof value === 'object' && Promise.resolve(value) === value) {\n this._promised = this.createPromised(value)\n value = none\n delete onSetArg.value\n delete onSetArg.state\n } else if (this._promised && (!this._promised.resolver && !this._promised.fullfilled)) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenPromised)\n }\n\n let prevValue = this._value;\n if (prevValue === none) {\n delete onSetArg.previous\n }\n this._value = value;\n this.afterSet(onSetArg)\n\n if (prevValue === none && this._value !== none &&\n this.promised && this.promised.resolver) {\n this.promised.resolver(this._value)\n }\n\n return path;\n }\n\n if (typeof value === 'object' && Promise.resolve(value) === value) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateNestedToPromised)\n }\n\n let target = this._value;\n for (let i = 0; i < path.length - 1; i += 1) {\n target = target[path[i]];\n }\n\n const p = path[path.length - 1]\n if (p in target) {\n if (value !== none) {\n // Property UPDATE case\n let prevValue = target[p]\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n previous: prevValue,\n merged: mergeValue\n })\n\n return path;\n } else {\n // Property DELETE case\n let prevValue = target[p]\n if (Array.isArray(target) && typeof p === 'number') {\n target.splice(p, 1)\n } else {\n delete target[p]\n }\n this.afterSet({\n path: path,\n state: this._value,\n previous: prevValue,\n merged: mergeValue\n })\n\n // if an array of objects is about to loose existing property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n }\n\n if (value !== none) {\n // Property INSERT case\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n merged: mergeValue\n })\n\n // if an array of objects is about to be extended by new property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n\n // Non-existing property DELETE case\n // no-op\n return path;\n }\n\n update(paths: Path[]) {\n if (this._batches) {\n this._batchesPendingPaths = this._batchesPendingPaths || []\n this._batchesPendingPaths = this._batchesPendingPaths.concat(paths)\n return;\n }\n\n const actions: (() => void)[] = [];\n this._subscribers.forEach(s => s.onSet(paths, actions));\n actions.forEach(a => a());\n }\n\n afterSet(params: PluginCallbacksOnSetArgument) {\n if (this._edition !== DestroyedEdition) {\n this._edition += 1;\n this._setSubscribers.forEach(cb => cb(params))\n }\n }\n\n startBatch(path: Path, options?: { context?: AnyContext }): void {\n this._batches += 1\n\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchStartSubscribers.forEach(cb => cb(cbArgument))\n }\n\n finishBatch(path: Path, options?: { context?: AnyContext }): void {\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchFinishSubscribers.forEach(cb => cb(cbArgument))\n\n this._batches -= 1\n if (this._batches === 0) {\n if (this._batchesPendingPaths) {\n const paths = this._batchesPendingPaths\n this._batchesPendingPaths = undefined\n this.update(paths)\n }\n }\n }\n\n postponeBatch(action: () => void): void {\n this._batchesPendingActions = this._batchesPendingActions || []\n this._batchesPendingActions.push(action)\n }\n\n getPlugin(pluginId: symbol) {\n return this._plugins.get(pluginId)\n }\n\n register(plugin: Plugin) {\n const existingInstance = this._plugins.get(plugin.id)\n if (existingInstance) {\n return;\n }\n\n const pluginCallbacks = plugin.init ? plugin.init(this.toMethods().self) : {};\n this._plugins.set(plugin.id, pluginCallbacks);\n if (pluginCallbacks.onSet) {\n this._setSubscribers.add((p) => pluginCallbacks.onSet!(p))\n }\n if (pluginCallbacks.onDestroy) {\n this._destroySubscribers.add((p) => pluginCallbacks.onDestroy!(p))\n }\n if (pluginCallbacks.onBatchStart) {\n this._batchStartSubscribers.add((p) => pluginCallbacks.onBatchStart!(p))\n }\n if (pluginCallbacks.onBatchFinish) {\n this._batchFinishSubscribers.add((p) => pluginCallbacks.onBatchFinish!(p))\n }\n }\n\n toMethods() {\n return new StateMethodsImpl(\n this,\n RootPath,\n this.get(RootPath),\n this.edition,\n OnSetUsedNoAction\n )\n }\n\n subscribe(l: Subscriber) {\n this._subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this._subscribers.delete(l);\n }\n\n destroy() {\n this._destroySubscribers.forEach(cb => cb(this._value !== none ? { state: this._value } : {}))\n this._edition = DestroyedEdition\n }\n\n toJSON() {\n throw new StateInvalidUsageError(RootPath, ErrorId.ToJson_Value);\n }\n}\n\nclass Promised {\n public fullfilled?: true;\n public error?: StateErrorAtRoot;\n public resolver?: (_: StateValueAtRoot) => void;\n\n constructor(public promise: Promise | undefined,\n onResolve: (r: StateValueAtPath) => void,\n onReject: () => void,\n onPostResolve: () => void) {\n if (!promise) {\n promise = new Promise(resolve => {\n this.resolver = resolve;\n })\n }\n this.promise = promise\n .then(r => {\n this.fullfilled = true\n if (!this.resolver) {\n onResolve(r)\n }\n })\n .catch(err => {\n this.fullfilled = true\n this.error = err\n onReject()\n })\n .then(() => onPostResolve())\n }\n}\n\n// use symbol property to allow for easier reference finding\nconst ValueUnusedMarker = Symbol('ValueUnusedMarker');\n\nfunction OnSetUsedNoAction() { /** no action callback */ }\n\n// use symbol to mark that a function has no effect anymore\nconst UnmountedMarker = Symbol('UnmountedMarker');\nOnSetUsedNoAction[UnmountedMarker] = true\n\nclass StateMethodsImpl implements StateMethods, StateMethodsDestroy, Subscribable, Subscriber {\n private subscribers: Set | undefined;\n\n private isDowngraded: boolean | undefined;\n private childrenCache: Record> | undefined;\n private selfCache: State | undefined;\n private valueCache: StateValueAtPath = ValueUnusedMarker;\n \n constructor(\n public readonly state: Store,\n public readonly path: Path,\n private valueSource: S,\n private valueEdition: number,\n private readonly onSetUsed: () => void\n ) { }\n\n getUntracked(allowPromised?: boolean) {\n if (this.valueEdition !== this.state.edition) {\n this.valueSource = this.state.get(this.path)\n this.valueEdition = this.state.edition\n\n if (this.isMounted) {\n // this link is still mounted to a component\n // populate cache again to ensure correct tracking of usage\n // when React scans which states to rerender on update\n if (this.valueCache !== ValueUnusedMarker) {\n this.valueCache = ValueUnusedMarker\n this.get(true) // renew cache to keep it marked used\n }\n } else {\n // This link is not mounted to a component\n // for example, it might be global link or\n // a link which has been discarded after rerender\n // but still captured by some callback or an effect.\n // If we are here and if it was mounted before,\n // it means it has not been garbage collected\n // when a component unmounted.\n // We take this opportunity to clean up caches\n // to avoid memory leaks via stale children states cache.\n this.valueCache = ValueUnusedMarker\n delete this.childrenCache\n delete this.selfCache\n }\n }\n if (this.valueSource === none && !allowPromised) {\n if (this.state.promised && this.state.promised.error) {\n throw this.state.promised.error;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.GetStateWhenPromised)\n }\n return this.valueSource;\n }\n\n get(allowPromised?: boolean) {\n const currentValue = this.getUntracked(allowPromised)\n if (this.valueCache === ValueUnusedMarker) {\n if (this.isDowngraded) {\n this.valueCache = currentValue;\n } else if (Array.isArray(currentValue)) {\n this.valueCache = this.valueArrayImpl(currentValue as unknown as StateValueAtPath[]);\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n this.valueCache = this.valueObjectImpl(currentValue as unknown as object);\n } else {\n this.valueCache = currentValue;\n }\n }\n return this.valueCache as S;\n }\n\n get value(): S {\n return this.get()\n }\n\n setUntracked(newValue: SetStateAction, mergeValue?: Partial): [Path] {\n if (typeof newValue === 'function') {\n newValue = (newValue as ((prevValue: S) => S))(this.getUntracked());\n }\n if (typeof newValue === 'object' && newValue !== null && newValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(this.path, ErrorId.SetStateToValueFromState)\n }\n return [this.state.set(this.path, newValue, mergeValue)];\n }\n\n set(newValue: SetStateAction) {\n this.state.update(this.setUntracked(newValue));\n }\n\n mergeUntracked(sourceValue: SetPartialStateAction): Path[] {\n const currentValue = this.getUntracked()\n if (typeof sourceValue === 'function') {\n sourceValue = (sourceValue as Function)(currentValue);\n }\n\n let updatedPaths: [Path];\n let deletedOrInsertedProps = false\n\n if (Array.isArray(currentValue)) {\n if (Array.isArray(sourceValue)) {\n return this.setUntracked(currentValue.concat(sourceValue) as unknown as S, sourceValue)\n } else {\n const deletedIndexes: number[] = []\n Object.keys(sourceValue).sort().forEach(i => {\n const index = Number(i);\n const newPropValue = sourceValue[index]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n deletedIndexes.push(index)\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(index in currentValue);\n (currentValue as StateValueAtPath[])[index] = newPropValue\n }\n });\n // indexes are ascending sorted as per above\n // so, delete one by one from the end\n // this way index positions do not change\n deletedIndexes.reverse().forEach(p => {\n (currentValue as unknown as []).splice(p, 1)\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n }\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n Object.keys(sourceValue).forEach(key => {\n const newPropValue = sourceValue[key]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n delete currentValue[key]\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(key in currentValue)\n currentValue[key] = newPropValue\n }\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n } else if (typeof currentValue === 'string') {\n return this.setUntracked((currentValue + String(sourceValue)) as unknown as S, sourceValue)\n } else {\n return this.setUntracked(sourceValue as S)\n }\n\n if (updatedPaths.length !== 1 || updatedPaths[0] !== this.path || deletedOrInsertedProps) {\n return updatedPaths\n }\n const updatedPath = updatedPaths[0]\n return Object.keys(sourceValue).map(p => updatedPath.slice().concat(p))\n }\n\n merge(sourceValue: SetPartialStateAction) {\n this.state.update(this.mergeUntracked(sourceValue));\n }\n\n nested(key: K): State {\n return this.child(key as string | number).self as State\n }\n \n rerender(paths: Path[]) {\n this.state.update(paths)\n }\n\n destroy(): void {\n this.state.destroy()\n }\n\n subscribe(l: Subscriber) {\n if (this.subscribers === undefined) {\n this.subscribers = new Set();\n }\n this.subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this.subscribers!.delete(l);\n }\n \n get isMounted(): boolean {\n return !this.onSetUsed[UnmountedMarker]\n }\n\n onUnmount() {\n this.onSetUsed[UnmountedMarker] = true\n }\n\n onSet(paths: Path[], actions: (() => void)[]): boolean {\n const update = () => {\n if (this.isDowngraded && this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n for (let path of paths) {\n const firstChildKey = path[this.path.length];\n if (firstChildKey === undefined) {\n if (this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n } else {\n const firstChildValue = this.childrenCache && this.childrenCache[firstChildKey];\n if (firstChildValue && firstChildValue.onSet(paths, actions)) {\n return true;\n }\n }\n }\n return false;\n }\n\n const updated = update();\n if (!updated && this.subscribers !== undefined) {\n this.subscribers.forEach(s => {\n s.onSet(paths, actions)\n })\n }\n return updated;\n }\n\n get keys(): InferredStateKeysType {\n const value = this.get()\n if (Array.isArray(value)) {\n return Object.keys(value).map(i => Number(i)).filter(i => Number.isInteger(i)) as\n unknown as InferredStateKeysType;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value) as unknown as InferredStateKeysType;\n }\n return undefined as InferredStateKeysType;\n }\n\n child(key: number | string) {\n // if this state is not mounted to a hook,\n // we do not cache children to avoid unnecessary memory leaks\n if (this.isMounted) {\n this.childrenCache = this.childrenCache || {};\n const cachehit = this.childrenCache[key];\n if (cachehit) {\n return cachehit;\n }\n }\n const r = new StateMethodsImpl(\n this.state,\n this.path.slice().concat(key),\n this.valueSource[key],\n this.valueEdition,\n this.onSetUsed,\n )\n if (this.isDowngraded) {\n r.isDowngraded = true;\n }\n if (this.childrenCache) {\n this.childrenCache[key] = r;\n }\n return r;\n }\n \n private valueArrayImpl(currentValue: StateValueAtPath[]): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === 'length') {\n return (target as []).length;\n }\n if (key in Array.prototype) {\n return Array.prototype[key];\n }\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n const index = Number(key);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.child(index).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n private valueObjectImpl(currentValue: object): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n return this.child(key).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n get self(): State {\n if (this.selfCache) {\n return this.selfCache\n }\n \n const getter = (_: object, key: PropertyKey) => {\n if (key === self) {\n return this\n }\n if (typeof key === 'symbol') {\n return undefined\n }\n if (key === 'toJSON') {\n throw new StateInvalidUsageError(this.path, ErrorId.ToJson_State);\n }\n \n let nestedGetter = (prop: PropertyKey) => {\n const currentDowngraded = this.isDowngraded; // relevant for IE11 only\n const currentValue = this.get(); // IE11 marks this as downgraded\n this.isDowngraded = currentDowngraded; // relevant for IE11 only\n if (// if currentValue is primitive type\n (typeof currentValue !== 'object' || currentValue === null) &&\n // if promised, it will be none\n currentValue !== none) {\n // This was an error case, but various tools like webpack bundler\n // and react dev tools attempt to get props out of non-null object,\n // so this was changed to return just undefined for any property request\n // as there is no way to fix 3rd party tools.\n // Logging a warning to console is also not an option\n // as it pollutes console for legitimate apps on app start app.\n // Ref: https://github.com/avkonst/hookstate/issues/125\n return undefined\n }\n\n if (Array.isArray(currentValue)) {\n if (prop === 'length') {\n return currentValue.length;\n }\n if (prop in Array.prototype) {\n return Array.prototype[prop];\n }\n const index = Number(prop);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.nested(index as keyof S)\n }\n return this.nested(prop.toString() as keyof S)\n }\n\n switch (key) {\n case 'path':\n return this.path\n case 'keys':\n return this.keys\n case 'value':\n return this.value\n case 'ornull':\n return this.ornull\n case 'promised':\n return this.promised\n case 'error':\n return this.error\n case 'get':\n return () => this.get()\n case 'set':\n return (p: SetStateAction) => this.set(p)\n case 'merge':\n return (p: SetPartialStateAction) => this.merge(p)\n case 'nested':\n return (p: keyof S) => nestedGetter(p)\n case 'batch':\n // tslint:disable-next-line: no-any\n return (action: () => R, context: Exclude) => this.batch(action, context)\n case 'attach':\n return (p: symbol) => this.attach(p)\n case 'destroy':\n return () => this.destroy()\n default:\n return nestedGetter(key)\n }\n }\n \n if (IsNoProxy) {\n // minimal support for IE11\n const result = (Array.isArray(this.valueSource) ? [] : {}) as State;\n [self, 'toJSON', 'path', 'keys', 'value', 'ornull',\n 'promised', 'error', 'get', 'set', 'merge',\n 'nested', 'batch', 'attach', 'destroy']\n .forEach(key => {\n Object.defineProperty(result, key, {\n get: () => getter(result, key)\n })\n })\n if (typeof this.valueSource === 'object' && this.valueSource !== null) {\n Object.keys(this.valueSource).forEach(key => {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => getter(result, key)\n })\n })\n }\n this.selfCache = result;\n return this.selfCache\n }\n \n this.selfCache = proxyWrap(this.path, this.valueSource,\n () => {\n this.get() // get latest & mark used\n return this.valueSource\n },\n getter,\n (_, key, value) => {\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_State)\n },\n false) as unknown as State;\n return this.selfCache\n }\n \n get promised(): boolean {\n const currentValue = this.get(true) // marks used\n if (currentValue === none && this.state.promised && !this.state.promised.fullfilled) {\n return true;\n }\n return false;\n }\n\n get error(): StateErrorAtRoot | undefined {\n const currentValue = this.get(true) // marks used\n if (currentValue === none) {\n if (this.state.promised && this.state.promised.fullfilled) {\n return this.state.promised.error;\n }\n this.get() // will throw 'read while promised' exception\n }\n return undefined;\n }\n\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R {\n const opts = { context: context }\n try {\n this.state.startBatch(this.path, opts)\n const result = action(this.self) as R\n if (result as unknown as Symbol === postpone) {\n this.state.postponeBatch(() => this.batch(action, context))\n }\n return result\n } finally {\n this.state.finishBatch(this.path, opts)\n }\n }\n\n get ornull(): InferredStateOrnullType {\n const value = this.get()\n if (value === null || value === undefined) {\n return value as unknown as InferredStateOrnullType;\n }\n return this.self as InferredStateOrnullType;\n }\n\n attach(plugin: () => Plugin): State\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n attach(p: (() => Plugin) | symbol):\n State | [PluginCallbacks | Error, PluginStateControl] {\n if (typeof p === 'function') {\n const pluginMeta = p();\n if (pluginMeta.id === DowngradedID) {\n this.isDowngraded = true;\n if (this.valueCache !== ValueUnusedMarker) {\n const currentValue = this.getUntracked(true);\n this.valueCache = currentValue;\n }\n return this.self;\n }\n this.state.register(pluginMeta);\n return this.self;\n } else {\n return [\n this.state.getPlugin(p) ||\n (new StateInvalidUsageError(this.path, ErrorId.GetUnknownPlugin, p.toString())), \n this\n ];\n }\n }\n}\n\nfunction proxyWrap(\n path: Path,\n // tslint:disable-next-line: no-any\n targetBootstrap: any,\n // tslint:disable-next-line: no-any\n targetGetter: () => any,\n // tslint:disable-next-line: no-any\n propertyGetter: (unused: any, key: PropertyKey) => any,\n // tslint:disable-next-line: no-any\n propertySetter: (unused: any, p: PropertyKey, value: any, receiver: any) => boolean,\n isValueProxy: boolean\n) {\n const onInvalidUsage = (op: ErrorId) => {\n throw new StateInvalidUsageError(path, op)\n }\n if (typeof targetBootstrap !== 'object' || targetBootstrap === null) {\n targetBootstrap = {}\n }\n return new Proxy(targetBootstrap, {\n getPrototypeOf: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf#Invariants\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return null;\n }\n return Object.getPrototypeOf(targetReal);\n },\n setPrototypeOf: (target, v) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.SetPrototypeOf_State :\n ErrorId.SetPrototypeOf_Value)\n },\n isExtensible: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible#Invariants\n return true; // required to satisfy the invariants of the getPrototypeOf\n // return Object.isExtensible(target);\n },\n preventExtensions: (target) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.PreventExtensions_State :\n ErrorId.PreventExtensions_Value)\n },\n getOwnPropertyDescriptor: (target, p) => {\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return undefined;\n }\n const origin = Object.getOwnPropertyDescriptor(targetReal, p);\n if (origin && Array.isArray(targetReal) && p in Array.prototype) {\n return origin;\n }\n return origin && {\n configurable: true, // JSON.stringify() does not work for an object without it\n enumerable: origin.enumerable,\n get: () => propertyGetter(targetReal, p),\n set: undefined\n };\n },\n has: (target, p) => {\n if (typeof p === 'symbol') {\n return false;\n }\n const targetReal = targetGetter()\n if (typeof targetReal === 'object' && targetReal !== null) {\n return p in targetReal;\n }\n return false;\n },\n get: propertyGetter,\n set: propertySetter,\n deleteProperty: (target, p) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DeleteProperty_State :\n ErrorId.DeleteProperty_Value)\n },\n defineProperty: (target, p, attributes) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DefineProperty_State :\n ErrorId.DefineProperty_Value)\n },\n ownKeys: (target) => {\n const targetReal = targetGetter()\n if (Array.isArray(targetReal)) {\n return Object.keys(targetReal).concat('length');\n }\n if (targetReal === undefined || targetReal === null) {\n return [];\n }\n return Object.keys(targetReal);\n },\n apply: (target, thisArg, argArray?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Apply_State:\n ErrorId.Apply_Value)\n },\n construct: (target, argArray, newTarget?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Construct_State :\n ErrorId.Construct_Value)\n }\n });\n}\n\nfunction createStore(initial: SetInitialStateAction): Store {\n let initialValue: S | Promise = initial as (S | Promise);\n if (typeof initial === 'function') {\n initialValue = (initial as (() => S | Promise))();\n }\n if (typeof initialValue === 'object' && initialValue !== null && initialValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(RootPath, ErrorId.InitStateToValueFromState)\n }\n return new Store(initialValue);\n}\n\nfunction useSubscribedStateMethods(\n state: Store,\n path: Path,\n update: () => void,\n subscribeTarget: Subscribable\n) {\n const link = new StateMethodsImpl(\n state,\n path,\n state.get(path),\n state.edition,\n update,\n );\n // useLayoutEffect here instead of useEffect because of this issue:\n // https://github.com/avkonst/hookstate/issues/165#issuecomment-824670930\n // and very likely this issue:\n // https://github.com/avkonst/hookstate/issues/186\n // and probably this issue:\n // https://github.com/avkonst/hookstate/issues/145\n React.useLayoutEffect(() => {\n subscribeTarget.subscribe(link);\n return () => {\n link.onUnmount()\n subscribeTarget.unsubscribe(link);\n }\n });\n return link;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AACF;AACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;AAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;AAC3C,IAAI,CAAC,CAAC,SAAS,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YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,aAAa,CAAC,EAAE;QAC1F,MAAM,IAAI,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;KAChF;IACD,OAAO,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,yBAAyB,CAC9B,KAAY,EACZ,IAAU,EACV,MAAkB,EAClB,eAA6B;IAE7B,IAAM,IAAI,GAAG,IAAI,gBAAgB,CAC7B,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EACf,KAAK,CAAC,OAAO,EACb,MAAM,CACT,CAAC;;;;;;;IAOF,KAAK,CAAC,eAAe,CAAC;QAClB,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO;YACH,IAAI,CAAC,SAAS,EAAE,CAAA;YAChB,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACrC,CAAA;KACJ,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AAChB;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../node_modules/tslib/tslib.es6.js","../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import React from 'react';\n\n///\n/// EXPORTED SYMBOLS (LIBRARY INTERFACE)\n///\n\n/**\n * 'JSON path' from root of a state object to a nested property.\n * Return type of [StateMethod.path](#readonly-path).\n *\n * For example, an object `{ a: [{ b: 1 }, { 1000: 'value' }, '3rd'] }`,\n * has got the following paths pointing to existing properties:\n *\n * - `[]`\n * - `['a']`\n * - `['a', 0]`\n * - `['a', 0, 'b']`\n * - `['a', 1]`\n * - `['a', 1, 1000]`\n * - `['a', 2]`\n */\nexport type Path = ReadonlyArray;\n\n/**\n * Type of an argument of [StateMethods.set](#set).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetStateAction = (S | Promise) | ((prevState: S) => (S | Promise));\n\n/**\n * Type of an argument of [StateMethods.merge](#merge).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetPartialStateAction =\n S extends ReadonlyArray<(infer U)> ?\n ReadonlyArray | Record | ((prevValue: S) => (ReadonlyArray | Record)) :\n S extends object | string ? Partial | ((prevValue: S) => Partial) :\n React.SetStateAction;\n\n/**\n * Type of an argument of [createState](#createstate) and [useState](#usestate).\n * \n * @typeparam S Type of a value of a state\n */\nexport type SetInitialStateAction = S | Promise | (() => S | Promise)\n\n/**\n * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function.\n * \n * [Learn more...](https://hookstate.js.org/docs/asynchronous-state#executing-an-action-when-state-is-loaded)\n */\nexport const postpone = Symbol('postpone')\n\n/**\n * Special symbol which might be used to delete properties\n * from an object calling [StateMethods.set](#set) or [StateMethods.merge](#merge).\n * \n * [Learn more...](https://hookstate.js.org/docs/nested-state#deleting-existing-element)\n */\nexport const none = Symbol('none') as StateValueAtPath;\n\n/**\n * Return type of [StateMethods.keys](#readonly-keys).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateKeysType =\n S extends ReadonlyArray ? ReadonlyArray :\n S extends null ? undefined :\n S extends object ? ReadonlyArray :\n undefined;\n\n/**\n * Return type of [StateMethods.map()](#map).\n * \n * @typeparam S Type of a value of a state\n */\nexport type InferredStateOrnullType =\n S extends undefined ? undefined :\n S extends null ? null : State;\n\n/**\n * For plugin developers only.\n * An instance to manipulate the state in more controlled way.\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginStateControl {\n /**\n * Get state value, but do not leave the traces of reading it.\n */\n getUntracked(): S;\n /**\n * Set new state value, but do not trigger rerender.\n * \n * @param newValue new value to set to a state.\n */\n setUntracked(newValue: SetStateAction): Path[];\n /**\n * Merge new state value, but do not trigger rerender.\n * \n * @param mergeValue new partial value to merge with the current state value and set.\n */\n mergeUntracked(mergeValue: SetPartialStateAction): Path[];\n /**\n * Trigger rerender for hooked states, where values at the specified paths are used.\n * \n * @param paths paths of the state variables to search for being used by components and rerender\n */\n rerender(paths: Path[]): void;\n}\n\n/**\n * An interface to manage a state in Hookstate.\n * \n * @typeparam S Type of a value of a state\n */\nexport interface StateMethods {\n /**\n * 'Javascript' object 'path' to an element relative to the root object\n * in the state. For example:\n *\n * ```tsx\n * const state = useState([{ name: 'First Task' }])\n * state.path IS []\n * state[0].path IS [0]\n * state.[0].name.path IS [0, 'name']\n * ```\n */\n readonly path: Path;\n\n /**\n * Return the keys of nested states.\n * For a given state of [State](#state) type,\n * `state.keys` will be structurally equal to Object.keys(state),\n * with two minor difference:\n * 1. if `state.value` is an array, the returned result will be\n * an array of numbers, not strings like with `Object.keys`.\n * 2. if `state.value` is not an object, the returned result will be undefined.\n */\n readonly keys: InferredStateKeysType;\n\n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.get](#get) method.\n *\n * This property is more useful than [get](#get) method for the cases,\n * when a value may hold null or undefined values.\n * Typescript compiler does not handle elimination of undefined with get(),\n * like in the following examples, but value does:\n *\n * ```tsx\n * const state = useState(0)\n * const myvalue: number = state.value\n * ? state.value + 1\n * : 0; // <-- compiles\n * const myvalue: number = state.get()\n * ? state.get() + 1\n * : 0; // <-- does not compile\n * ```\n */\n readonly value: S;\n\n /**\n * True if state value is not yet available (eg. equal to a promise)\n */\n readonly promised: boolean;\n \n /**\n * If a state was set to a promise and the promise was rejected,\n * this property will return the error captured from the promise rejection\n */\n readonly error: StateErrorAtRoot | undefined;\n \n /**\n * Unwraps and returns the underlying state value referred by\n * [path](#readonly-path) of this state instance.\n *\n * It returns the same result as [StateMethods.value](#readonly-value) method.\n */\n get(): S;\n \n /**\n * Sets new value for a state.\n * If `this.path === []`,\n * it is similar to the `setState` variable returned by `React.useState` hook.\n * If `this.path !== []`, it sets only the segment of the state value, pointed out by the path.\n * Unlike [merge](#merge) method, this method will not accept partial updates.\n * Partial updates can be also done by walking the nested states and setting those.\n *\n * @param newValue new value to set to a state.\n * It can be a value, a promise resolving to a value\n * (only if [this.path](#readonly-path) is `[]`),\n * or a function returning one of these.\n * The function receives the current state value as an argument.\n */\n set(newValue: SetStateAction): void;\n \n /**\n * Similarly to [set](#set) method updates state value.\n *\n * - If current state value is an object, it does partial update for the object.\n * - If state value is an array and the argument is an array too,\n * it concatenates the current value with the value of the argument and sets it to the state.\n * - If state value is an array and the `merge` argument is an object,\n * it does partial update for the current array value.\n * - If current state value is a string, it concatenates the current state\n * value with the argument converted to string and sets the result to the state.\n */\n merge(newValue: SetPartialStateAction): void;\n \n /**\n * Returns nested state by key.\n * `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`,\n * but also works for properties, which names collide with names of state methods.\n * \n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n * \n * @param key child property name or index\n */\n nested(key: K): State;\n \n /**\n * Runs the provided action callback with optimised re-rendering.\n * Updating state within a batch action does not trigger immediate rerendering.\n * Instead, all required rerendering is done once the batch is finished.\n * \n * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates\n * \n * @param action callback function to execute in a batch\n * \n * @param context custom user's value, which is passed to plugins\n */\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R;\n\n /**\n * If state value is null or undefined, returns state value.\n * Otherwise, it returns this state instance but\n * with null and undefined removed from the type parameter.\n * \n * [Learn more...](https://hookstate.js.org/docs/nullable-state)\n */\n ornull: InferredStateOrnullType;\n\n /**\n * Adds plugin to the state.\n * \n * [Learn more...](https://hookstate.js.org/docs/extensions-overview)\n */\n attach(plugin: () => Plugin): State\n \n /**\n * For plugin developers only.\n * It is a method to get the instance of the previously attached plugin.\n * If a plugin has not been attached to a state,\n * it returns an Error as the first element.\n * A plugin may trhow an error to indicate that plugin has not been attached.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n}\n\n/**\n * Mixin for the [StateMethods](#interfacesstatemethodsmd) for a [State](#state),\n * which can be destroyed by a client.\n */\nexport interface StateMethodsDestroy {\n /**\n * Destroys an instance of a state, so\n * it can clear the allocated native resources (if any)\n * and can not be used anymore after it has been destroyed.\n */\n destroy(): void;\n}\n\n/**\n * Type of a result of [createState](#createstate) and [useState](#usestate) functions\n * \n * @typeparam S Type of a value of a state\n * \n * [Learn more about global states...](https://hookstate.js.org/docs/global-state)\n * [Learn more about local states...](https://hookstate.js.org/docs/local-state)\n * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)\n */\nexport type State = StateMethods & (\n S extends ReadonlyArray<(infer U)> ? ReadonlyArray> :\n S extends object ? Omit<\n { readonly [K in keyof Required]: State; },\n keyof StateMethods | keyof StateMethodsDestroy\n > : {}\n);\n\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with root state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with nested state value.\n *\n * @hidden\n * @ignore\n */\nexport type StateValueAtPath = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with state error.\n *\n * @hidden\n * @ignore\n */\nexport type StateErrorAtRoot = any; //tslint:disable-line: no-any\n/**\n * For plugin developers only.\n * Type alias to highlight the places where we are dealing with context value.\n *\n * @hidden\n * @ignore\n */\nexport type AnyContext = any; //tslint:disable-line: no-any\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onSet argument type.\n */\nexport interface PluginCallbacksOnSetArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n /**\n * **A note about previous values and merging:**\n * State values are muteable in Hookstate for performance reasons. This causes a side effect in the merge operation.\n * While merging, the previous state object is mutated as the desired changes are applied. This means the value of\n * `previous` will reflect the merged changes as well, matching the new `state` value rather than the previous\n * state value. As a result, the `previous` property is unreliable when merge is used. The\n * [merged](#optional-readonly-merged) property can be used to detect which values were merged in but it will not\n * inform you whether those values are different from the previous state.\n *\n * As a workaround, you can [batch state updates](https://hookstate.js.org/docs/performance-batched-updates) or\n * replace merge calls with the immutable-style set operation like so:\n *\n * ```\n * state.set(p => {\n * let copy = p.clone(); /// here it is up to you to define how to clone the current state\n * copy.field = 'new value for field';\n * delete copy.fieldToDelete;\n * return copy;\n * })\n * ```\n */\n readonly previous?: StateValueAtPath,\n readonly value?: StateValueAtPath,\n readonly merged?: StateValueAtPath,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onDestroy argument type.\n */\nexport interface PluginCallbacksOnDestroyArgument {\n readonly state?: StateValueAtRoot,\n}\n\n/**\n * For plugin developers only.\n * PluginCallbacks.onBatchStart/Finish argument type.\n */\nexport interface PluginCallbacksOnBatchArgument {\n readonly path: Path,\n readonly state?: StateValueAtRoot,\n readonly context?: AnyContext,\n}\n\n/**\n * For plugin developers only.\n * Set of callbacks, a plugin may subscribe to.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface PluginCallbacks {\n readonly onSet?: (arg: PluginCallbacksOnSetArgument) => void,\n readonly onDestroy?: (arg: PluginCallbacksOnDestroyArgument) => void,\n readonly onBatchStart?: (arg: PluginCallbacksOnBatchArgument) => void,\n readonly onBatchFinish?: (arg: PluginCallbacksOnBatchArgument) => void,\n};\n\n/**\n * For plugin developers only.\n * Hookstate plugin specification and factory method.\n * \n * [Learn more...](https://hookstate.js.org/docs/writing-plugin)\n */\nexport interface Plugin {\n /**\n * Unique identifier of a plugin.\n */\n readonly id: symbol;\n /**\n * Initializer for a plugin when it is attached for the first time.\n */\n readonly init?: (state: State) => PluginCallbacks;\n}\n\n/**\n * Creates new state and returns it.\n *\n * You can create as many global states as you need.\n *\n * When you the state is not needed anymore,\n * it should be destroyed by calling\n * `destroy()` method of the returned instance.\n * This is necessary for some plugins,\n * which allocate native resources,\n * like subscription to databases, broadcast channels, etc.\n * In most cases, a global state is used during\n * whole life time of an application and would not require\n * destruction. However, if you have got, for example,\n * a catalog of dynamically created and destroyed global states,\n * the states should be destroyed as advised above.\n *\n * @param initial Initial value of the state.\n * It can be a value OR a promise,\n * which asynchronously resolves to a value,\n * OR a function returning a value or a promise.\n *\n * @typeparam S Type of a value of the state\n *\n * @returns [State](#state) instance,\n * which can be used directly to get and set state value\n * outside of React components.\n * When you need to use the state in a functional `React` component,\n * pass the created state to [useState](#usestate) function and\n * use the returned result in the component's logic.\n */\nexport function createState(\n initial: SetInitialStateAction\n): State & StateMethodsDestroy {\n const methods = createStore(initial).toMethods();\n const devtools = createState[DevToolsID]\n if (devtools) {\n methods.attach(devtools)\n }\n return methods.self as State & StateMethodsDestroy;\n}\n\n/**\n * Enables a functional React component to use a state,\n * either created by [createState](#createstate) (*global* state) or\n * derived from another call to [useState](#usestate) (*scoped* state).\n *\n * The `useState` forces a component to rerender every time, when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * For example, if the state value is `{ a: 1, b: 2 }` and\n * a component uses only `a` property of the state, it will rerender\n * only when the whole state object is updated or when `a` property is updated.\n * Setting the state value/property to the same value is also considered as an update.\n *\n * A component can use one or many states,\n * i.e. you may call `useState` multiple times for multiple states.\n *\n * The same state can be used by multiple different components.\n *\n * @param source a reference to the state to hook into\n *\n * The `useState` is a hook and should follow React's rules of hooks.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: State\n): State;\n/**\n * This function enables a functional React component to use a state,\n * created per component by [useState](#usestate) (*local* state).\n * In this case `useState` behaves similarly to `React.useState`,\n * but the returned instance of [State](#state)\n * has got more features.\n *\n * When a state is used by only one component, and maybe it's children,\n * it is recommended to use *local* state instead of *global*,\n * which is created by [createState](#createstate).\n *\n * *Local* (per component) state is created when a component is mounted\n * and automatically destroyed when a component is unmounted.\n *\n * The same as with the usage of a *global* state,\n * `useState` forces a component to rerender when:\n * - a segment/part of the state data is updated *AND only if*\n * - this segment was **used** by the component during or after the latest rendering.\n *\n * You can use as many local states within the same component as you need.\n *\n * @param source An initial value state.\n *\n * @returns an instance of [State](#state),\n * which **must be** used within the component (during rendering\n * or in effects) or it's children.\n */\nexport function useState(\n source: SetInitialStateAction\n): State;\nexport function useState(\n source: SetInitialStateAction | State\n): State {\n return useHookstate(source as State);\n}\n\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: State\n): State;\n/**\n * Alias to [useState](#usestate) which provides a workaround\n * for [React 20613 bug](https://github.com/facebook/react/issues/20613)\n */\nexport function useHookstate(\n source: SetInitialStateAction\n): State;\nexport function useHookstate(\n source: SetInitialStateAction | State\n): State {\n const parentMethods = typeof source === 'object' && source !== null ?\n source[self] as StateMethodsImpl | undefined :\n undefined;\n if (parentMethods) {\n if (parentMethods.isMounted) {\n // Scoped state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [, setValue] = React.useState({});\n return useSubscribedStateMethods(\n parentMethods.state,\n parentMethods.path,\n () => setValue({}),\n parentMethods).self;\n } else {\n // Global state mount or destroyed link\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState({ state: parentMethods.state });\n let state = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state).self;\n for (let ind = 0; ind < parentMethods.path.length; ind += 1) {\n state = state.nested(parentMethods.path[ind]);\n }\n return state as State;\n }\n } else {\n // Local state mount\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [value, setValue] = React.useState(() => ({ state: createStore(source) }));\n const result = useSubscribedStateMethods(\n value.state,\n RootPath,\n () => setValue({ state: value.state }),\n value.state);\n\n if (isDevelopmentMode) {\n // This is a workaround for the issue:\n // https://github.com/avkonst/hookstate/issues/109\n // See technical notes on React behavior here:\n // https://github.com/apollographql/apollo-client/issues/5870#issuecomment-689098185\n const isEffectExecutedAfterRender = React.useRef(false);\n isEffectExecutedAfterRender.current = false; // not yet...\n \n React.useEffect(() => {\n isEffectExecutedAfterRender.current = true; // ... and now, yes!\n // The state is not destroyed intentionally\n // under hot reload case.\n return () => { isEffectExecutedAfterRender.current && value.state.destroy() }\n });\n } else {\n React.useEffect(() => () => value.state.destroy(), []);\n }\n const devtools = useState[DevToolsID]\n if (devtools) {\n result.attach(devtools)\n }\n return result.self;\n }\n}\n\n/**\n * Allows to use a state without defining a functional react component.\n * It can be also used in class-based React components. It is also\n * particularly useful for creating *scoped* states.\n *\n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: State,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\n/**\n * Allows to use a state without defining a functional react component.\n * See more at [StateFragment](#statefragment)\n * \n * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)\n * \n * @typeparam S Type of a value of a state\n */\nexport function StateFragment(\n props: {\n state: SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement;\nexport function StateFragment(\n props: {\n state: State | SetInitialStateAction,\n children: (state: State) => React.ReactElement,\n }\n): React.ReactElement {\n const scoped = useState(props.state as State);\n return props.children(scoped);\n}\n\n/**\n * A plugin which allows to opt-out from usage of Javascript proxies for\n * state usage tracking. It is useful for performance tuning.\n * \n * [Learn more...](https://hookstate.js.org/docs/performance-managed-rendering#downgraded-plugin)\n */\nexport function Downgraded(): Plugin { // tslint:disable-line: function-name\n return {\n id: DowngradedID\n }\n}\n\n/**\n * For plugin developers only.\n * Reserved plugin ID for developers tools extension.\n *\n * @hidden\n * @ignore\n */\nexport const DevToolsID = Symbol('DevTools');\n\n/**\n * Return type of [DevTools](#devtools).\n */\nexport interface DevToolsExtensions {\n /**\n * Assigns custom label to identify the state in the development tools\n * @param name label for development tools\n */\n label(name: string): void;\n /**\n * Logs to the development tools\n */\n log(str: string, data?: any): void; // tslint:disable-line: no-any\n}\n\n/**\n * Returns access to the development tools for a given state.\n * Development tools are delivered as optional plugins.\n * You can activate development tools from `@hookstate/devtools`package,\n * for example. If no development tools are activated,\n * it returns an instance of dummy tools, which do nothing, when called.\n * \n * [Learn more...](https://hookstate.js.org/docs/devtools)\n * \n * @param state A state to relate to the extension.\n * \n * @returns Interface to interact with the development tools for a given state.\n * \n * @typeparam S Type of a value of a state\n */\nexport function DevTools(state: State): DevToolsExtensions {\n const plugin = state.attach(DevToolsID);\n if (plugin[0] instanceof Error) {\n return EmptyDevToolsExtensions;\n }\n return plugin[0] as DevToolsExtensions;\n}\n\n///\n/// INTERNAL SYMBOLS (LIBRARY IMPLEMENTATION)\n///\n\nconst isDevelopmentMode = typeof process === 'object' && \n typeof process.env === 'object' &&\n process.env.NODE_ENV === 'development'\n\nconst self = Symbol('self')\n\nconst EmptyDevToolsExtensions: DevToolsExtensions = {\n label() { /* */ },\n log() { /* */ }\n}\n\nenum ErrorId {\n InitStateToValueFromState = 101,\n SetStateToValueFromState = 102,\n GetStateWhenPromised = 103,\n SetStateWhenPromised = 104,\n SetStateNestedToPromised = 105,\n SetStateWhenDestroyed = 106,\n ToJson_Value = 108,\n ToJson_State = 109,\n GetUnknownPlugin = 120,\n\n SetProperty_State = 201,\n SetProperty_Value = 202,\n SetPrototypeOf_State = 203,\n SetPrototypeOf_Value = 204,\n PreventExtensions_State = 205,\n PreventExtensions_Value = 206,\n DefineProperty_State = 207,\n DefineProperty_Value = 208,\n DeleteProperty_State = 209,\n DeleteProperty_Value = 210,\n Construct_State = 211,\n Construct_Value = 212,\n Apply_State = 213,\n Apply_Value = 214,\n}\n\nclass StateInvalidUsageError extends Error {\n constructor(path: Path, id: ErrorId, details?: string) {\n super(`Error: HOOKSTATE-${id} [path: /${path.join('/')}${details ? `, details: ${details}` : ''}]. ` +\n `See https://hookstate.js.org/docs/exceptions#hookstate-${id}`)\n }\n}\n\ninterface Subscriber {\n onSet(paths: Path[], actions: (() => void)[]): void;\n}\n\ninterface Subscribable {\n subscribe(l: Subscriber): void;\n unsubscribe(l: Subscriber): void;\n}\n\nfunction isNoProxyInitializer() {\n try {\n const used = new Proxy({}, {});\n return false;\n } catch (e) {\n return true;\n }\n};\nconst IsNoProxy = isNoProxyInitializer()\n\nconst DowngradedID = Symbol('Downgraded');\nconst SelfMethodsID = Symbol('ProxyMarker');\n\nconst RootPath: Path = [];\nconst DestroyedEdition = -1\n\ntype Writeable = { -readonly [P in keyof T]: T[P] };\n\nclass Store implements Subscribable {\n private _edition = 0;\n\n private _subscribers: Set = new Set();\n private _setSubscribers: Set['onSet']> = new Set();\n private _destroySubscribers: Set['onDestroy']> = new Set();\n private _batchStartSubscribers: Set['onBatchStart']> = new Set();\n private _batchFinishSubscribers: Set['onBatchFinish']> = new Set();\n\n private _plugins: Map = new Map();\n\n private _promised?: Promised;\n\n private _batches = 0;\n private _batchesPendingPaths?: Path[];\n private _batchesPendingActions?: (() => void)[];\n\n constructor(private _value: StateValueAtRoot) {\n if (typeof _value === 'object' &&\n Promise.resolve(_value) === _value) {\n this._promised = this.createPromised(_value)\n this._value = none\n } else if (_value === none) {\n this._promised = this.createPromised(undefined)\n }\n }\n\n createPromised(newValue: StateValueAtPath | undefined) {\n const promised = new Promised(\n newValue ? Promise.resolve(newValue) : undefined,\n (r: StateValueAtPath) => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._promised = undefined\n this.set(RootPath, r, undefined)\n this.update([RootPath])\n }\n },\n () => {\n if (this.promised === promised && this.edition !== DestroyedEdition) {\n this._edition += 1\n this.update([RootPath])\n }\n },\n () => {\n if (this._batchesPendingActions &&\n this._value !== none &&\n this.edition !== DestroyedEdition) {\n const actions = this._batchesPendingActions\n this._batchesPendingActions = undefined\n actions.forEach(a => a())\n }\n }\n );\n return promised;\n }\n\n get edition() {\n return this._edition;\n }\n\n get promised() {\n return this._promised;\n }\n\n get(path: Path) {\n let result = this._value;\n if (result === none) {\n return result;\n }\n path.forEach(p => {\n result = result[p];\n });\n return result;\n }\n\n set(path: Path, value: StateValueAtPath, mergeValue: Partial | undefined): Path {\n if (this._edition < 0) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenDestroyed)\n }\n\n if (path.length === 0) {\n // Root value UPDATE case,\n\n const onSetArg: Writeable = {\n path: path,\n state: value,\n value: value,\n previous: this._value,\n merged: mergeValue\n }\n if (value === none) {\n this._promised = this.createPromised(undefined)\n delete onSetArg.value\n delete onSetArg.state\n } else if (typeof value === 'object' && Promise.resolve(value) === value) {\n this._promised = this.createPromised(value)\n value = none\n delete onSetArg.value\n delete onSetArg.state\n } else if (this._promised && (!this._promised.resolver && !this._promised.fullfilled)) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateWhenPromised)\n }\n\n let prevValue = this._value;\n if (prevValue === none) {\n delete onSetArg.previous\n }\n this._value = value;\n this.afterSet(onSetArg)\n\n if (prevValue === none && this._value !== none &&\n this.promised && this.promised.resolver) {\n this.promised.resolver(this._value)\n }\n\n return path;\n }\n\n if (typeof value === 'object' && Promise.resolve(value) === value) {\n throw new StateInvalidUsageError(path, ErrorId.SetStateNestedToPromised)\n }\n\n let target = this._value;\n for (let i = 0; i < path.length - 1; i += 1) {\n target = target[path[i]];\n }\n\n const p = path[path.length - 1]\n if (p in target) {\n if (value !== none) {\n // Property UPDATE case\n let prevValue = target[p]\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n previous: prevValue,\n merged: mergeValue\n })\n\n return path;\n } else {\n // Property DELETE case\n let prevValue = target[p]\n if (Array.isArray(target) && typeof p === 'number') {\n target.splice(p, 1)\n } else {\n delete target[p]\n }\n this.afterSet({\n path: path,\n state: this._value,\n previous: prevValue,\n merged: mergeValue\n })\n\n // if an array of objects is about to loose existing property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n }\n\n if (value !== none) {\n // Property INSERT case\n target[p] = value;\n this.afterSet({\n path: path,\n state: this._value,\n value: value,\n merged: mergeValue\n })\n\n // if an array of objects is about to be extended by new property\n // we consider it is the whole object is changed\n // which is identified by upper path\n return path.slice(0, -1)\n }\n\n // Non-existing property DELETE case\n // no-op\n return path;\n }\n\n update(paths: Path[]) {\n if (this._batches) {\n this._batchesPendingPaths = this._batchesPendingPaths || []\n this._batchesPendingPaths = this._batchesPendingPaths.concat(paths)\n return;\n }\n\n const actions: (() => void)[] = [];\n this._subscribers.forEach(s => s.onSet(paths, actions));\n actions.forEach(a => a());\n }\n\n afterSet(params: PluginCallbacksOnSetArgument) {\n if (this._edition !== DestroyedEdition) {\n this._edition += 1;\n this._setSubscribers.forEach(cb => cb(params))\n }\n }\n\n startBatch(path: Path, options?: { context?: AnyContext }): void {\n this._batches += 1\n\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchStartSubscribers.forEach(cb => cb(cbArgument))\n }\n\n finishBatch(path: Path, options?: { context?: AnyContext }): void {\n const cbArgument: Writeable = {\n path: path\n }\n if (options && 'context' in options) {\n cbArgument.context = options.context\n }\n if (this._value !== none) {\n cbArgument.state = this._value\n }\n this._batchFinishSubscribers.forEach(cb => cb(cbArgument))\n\n this._batches -= 1\n if (this._batches === 0) {\n if (this._batchesPendingPaths) {\n const paths = this._batchesPendingPaths\n this._batchesPendingPaths = undefined\n this.update(paths)\n }\n }\n }\n\n postponeBatch(action: () => void): void {\n this._batchesPendingActions = this._batchesPendingActions || []\n this._batchesPendingActions.push(action)\n }\n\n getPlugin(pluginId: symbol) {\n return this._plugins.get(pluginId)\n }\n\n register(plugin: Plugin) {\n const existingInstance = this._plugins.get(plugin.id)\n if (existingInstance) {\n return;\n }\n\n const pluginCallbacks = plugin.init ? plugin.init(this.toMethods().self) : {};\n this._plugins.set(plugin.id, pluginCallbacks);\n if (pluginCallbacks.onSet) {\n this._setSubscribers.add((p) => pluginCallbacks.onSet!(p))\n }\n if (pluginCallbacks.onDestroy) {\n this._destroySubscribers.add((p) => pluginCallbacks.onDestroy!(p))\n }\n if (pluginCallbacks.onBatchStart) {\n this._batchStartSubscribers.add((p) => pluginCallbacks.onBatchStart!(p))\n }\n if (pluginCallbacks.onBatchFinish) {\n this._batchFinishSubscribers.add((p) => pluginCallbacks.onBatchFinish!(p))\n }\n }\n\n toMethods() {\n return new StateMethodsImpl(\n this,\n RootPath,\n this.get(RootPath),\n this.edition,\n OnSetUsedNoAction\n )\n }\n\n subscribe(l: Subscriber) {\n this._subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this._subscribers.delete(l);\n }\n\n destroy() {\n this._destroySubscribers.forEach(cb => cb(this._value !== none ? { state: this._value } : {}))\n this._edition = DestroyedEdition\n }\n\n toJSON() {\n throw new StateInvalidUsageError(RootPath, ErrorId.ToJson_Value);\n }\n}\n\nclass Promised {\n public fullfilled?: true;\n public error?: StateErrorAtRoot;\n public resolver?: (_: StateValueAtRoot) => void;\n\n constructor(public promise: Promise | undefined,\n onResolve: (r: StateValueAtPath) => void,\n onReject: () => void,\n onPostResolve: () => void) {\n if (!promise) {\n promise = new Promise(resolve => {\n this.resolver = resolve;\n })\n }\n this.promise = promise\n .then(r => {\n this.fullfilled = true\n if (!this.resolver) {\n onResolve(r)\n }\n })\n .catch(err => {\n this.fullfilled = true\n this.error = err\n onReject()\n })\n .then(() => onPostResolve())\n }\n}\n\n// use symbol property to allow for easier reference finding\nconst ValueUnusedMarker = Symbol('ValueUnusedMarker');\n\nfunction OnSetUsedNoAction() { /** no action callback */ }\n\n// use symbol to mark that a function has no effect anymore\nconst UnmountedMarker = Symbol('UnmountedMarker');\nOnSetUsedNoAction[UnmountedMarker] = true\n\nclass StateMethodsImpl implements StateMethods, StateMethodsDestroy, Subscribable, Subscriber {\n private subscribers: Set | undefined;\n\n private isDowngraded: boolean | undefined;\n private childrenCache: Record> | undefined;\n private selfCache: State | undefined;\n private valueCache: StateValueAtPath = ValueUnusedMarker;\n \n constructor(\n public readonly state: Store,\n public readonly path: Path,\n private valueSource: S,\n private valueEdition: number,\n private readonly onSetUsed: () => void\n ) { }\n\n getUntracked(allowPromised?: boolean) {\n if (this.valueEdition !== this.state.edition) {\n this.valueSource = this.state.get(this.path)\n this.valueEdition = this.state.edition\n\n if (this.isMounted) {\n // this link is still mounted to a component\n // populate cache again to ensure correct tracking of usage\n // when React scans which states to rerender on update\n if (this.valueCache !== ValueUnusedMarker) {\n this.valueCache = ValueUnusedMarker\n this.get(true) // renew cache to keep it marked used\n }\n } else {\n // This link is not mounted to a component\n // for example, it might be global link or\n // a link which has been discarded after rerender\n // but still captured by some callback or an effect.\n // If we are here and if it was mounted before,\n // it means it has not been garbage collected\n // when a component unmounted.\n // We take this opportunity to clean up caches\n // to avoid memory leaks via stale children states cache.\n this.valueCache = ValueUnusedMarker\n delete this.childrenCache\n delete this.selfCache\n }\n }\n if (this.valueSource === none && !allowPromised) {\n if (this.state.promised && this.state.promised.error) {\n throw this.state.promised.error;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.GetStateWhenPromised)\n }\n return this.valueSource;\n }\n\n get(allowPromised?: boolean) {\n const currentValue = this.getUntracked(allowPromised)\n if (this.valueCache === ValueUnusedMarker) {\n if (this.isDowngraded) {\n this.valueCache = currentValue;\n } else if (Array.isArray(currentValue)) {\n this.valueCache = this.valueArrayImpl(currentValue as unknown as StateValueAtPath[]);\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n this.valueCache = this.valueObjectImpl(currentValue as unknown as object);\n } else {\n this.valueCache = currentValue;\n }\n }\n return this.valueCache as S;\n }\n\n get value(): S {\n return this.get()\n }\n\n setUntracked(newValue: SetStateAction, mergeValue?: Partial): [Path] {\n if (typeof newValue === 'function') {\n newValue = (newValue as ((prevValue: S) => S))(this.getUntracked());\n }\n if (typeof newValue === 'object' && newValue !== null && newValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(this.path, ErrorId.SetStateToValueFromState)\n }\n return [this.state.set(this.path, newValue, mergeValue)];\n }\n\n set(newValue: SetStateAction) {\n this.state.update(this.setUntracked(newValue));\n }\n\n mergeUntracked(sourceValue: SetPartialStateAction): Path[] {\n const currentValue = this.getUntracked()\n if (typeof sourceValue === 'function') {\n sourceValue = (sourceValue as Function)(currentValue);\n }\n\n let updatedPaths: [Path];\n let deletedOrInsertedProps = false\n\n if (Array.isArray(currentValue)) {\n if (Array.isArray(sourceValue)) {\n return this.setUntracked(currentValue.concat(sourceValue) as unknown as S, sourceValue)\n } else {\n const deletedIndexes: number[] = []\n Object.keys(sourceValue).sort().forEach(i => {\n const index = Number(i);\n const newPropValue = sourceValue[index]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n deletedIndexes.push(index)\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(index in currentValue);\n (currentValue as StateValueAtPath[])[index] = newPropValue\n }\n });\n // indexes are ascending sorted as per above\n // so, delete one by one from the end\n // this way index positions do not change\n deletedIndexes.reverse().forEach(p => {\n (currentValue as unknown as []).splice(p, 1)\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n }\n } else if (typeof currentValue === 'object' && currentValue !== null) {\n Object.keys(sourceValue).forEach(key => {\n const newPropValue = sourceValue[key]\n if (newPropValue === none) {\n deletedOrInsertedProps = true\n delete currentValue[key]\n } else {\n deletedOrInsertedProps = deletedOrInsertedProps || !(key in currentValue)\n currentValue[key] = newPropValue\n }\n })\n updatedPaths = this.setUntracked(currentValue, sourceValue)\n } else if (typeof currentValue === 'string') {\n return this.setUntracked((currentValue + String(sourceValue)) as unknown as S, sourceValue)\n } else {\n return this.setUntracked(sourceValue as S)\n }\n\n if (updatedPaths.length !== 1 || updatedPaths[0] !== this.path || deletedOrInsertedProps) {\n return updatedPaths\n }\n const updatedPath = updatedPaths[0]\n return Object.keys(sourceValue).map(p => updatedPath.slice().concat(p))\n }\n\n merge(sourceValue: SetPartialStateAction) {\n this.state.update(this.mergeUntracked(sourceValue));\n }\n\n nested(key: K): State {\n return this.child(key as string | number).self as State\n }\n \n rerender(paths: Path[]) {\n this.state.update(paths)\n }\n\n destroy(): void {\n this.state.destroy()\n }\n\n subscribe(l: Subscriber) {\n if (this.subscribers === undefined) {\n this.subscribers = new Set();\n }\n this.subscribers.add(l);\n }\n\n unsubscribe(l: Subscriber) {\n this.subscribers!.delete(l);\n }\n \n get isMounted(): boolean {\n return !this.onSetUsed[UnmountedMarker]\n }\n\n onUnmount() {\n this.onSetUsed[UnmountedMarker] = true\n }\n\n onSet(paths: Path[], actions: (() => void)[]): boolean {\n const update = () => {\n if (this.isDowngraded && this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n for (let path of paths) {\n const firstChildKey = path[this.path.length];\n if (firstChildKey === undefined) {\n if (this.valueCache !== ValueUnusedMarker) {\n actions.push(this.onSetUsed);\n return true;\n }\n } else {\n const firstChildValue = this.childrenCache && this.childrenCache[firstChildKey];\n if (firstChildValue && firstChildValue.onSet(paths, actions)) {\n return true;\n }\n }\n }\n return false;\n }\n\n const updated = update();\n if (!updated && this.subscribers !== undefined) {\n this.subscribers.forEach(s => {\n s.onSet(paths, actions)\n })\n }\n return updated;\n }\n\n get keys(): InferredStateKeysType {\n const value = this.get()\n if (Array.isArray(value)) {\n return Object.keys(value).map(i => Number(i)).filter(i => Number.isInteger(i)) as\n unknown as InferredStateKeysType;\n }\n if (typeof value === 'object' && value !== null) {\n return Object.keys(value) as unknown as InferredStateKeysType;\n }\n return undefined as InferredStateKeysType;\n }\n\n child(key: number | string) {\n // if this state is not mounted to a hook,\n // we do not cache children to avoid unnecessary memory leaks\n if (this.isMounted) {\n this.childrenCache = this.childrenCache || {};\n const cachehit = this.childrenCache[key];\n if (cachehit) {\n return cachehit;\n }\n }\n const r = new StateMethodsImpl(\n this.state,\n this.path.slice().concat(key),\n this.valueSource[key],\n this.valueEdition,\n this.onSetUsed,\n )\n if (this.isDowngraded) {\n r.isDowngraded = true;\n }\n if (this.childrenCache) {\n this.childrenCache[key] = r;\n }\n return r;\n }\n \n private valueArrayImpl(currentValue: StateValueAtPath[]): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === 'length') {\n return (target as []).length;\n }\n if (key in Array.prototype) {\n return Array.prototype[key];\n }\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n const index = Number(key);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.child(index).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n private valueObjectImpl(currentValue: object): S {\n if (IsNoProxy) {\n this.isDowngraded = true\n return currentValue as unknown as S;\n }\n return proxyWrap(this.path, currentValue,\n () => currentValue,\n (target: object, key: PropertyKey) => {\n if (key === SelfMethodsID) {\n return this;\n }\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n return target[key];\n }\n return this.child(key).get();\n },\n (target: object, key: PropertyKey, value: StateValueAtPath) => {\n if (typeof key === 'symbol') {\n // allow clients to associate hidden cache with state values\n target[key] = value;\n return true;\n }\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_Value)\n },\n true\n ) as unknown as S;\n }\n\n get self(): State {\n if (this.selfCache) {\n return this.selfCache\n }\n \n const getter = (_: object, key: PropertyKey) => {\n if (key === self) {\n return this\n }\n if (typeof key === 'symbol') {\n return undefined\n }\n if (key === 'toJSON') {\n throw new StateInvalidUsageError(this.path, ErrorId.ToJson_State);\n }\n \n let nestedGetter = (prop: PropertyKey) => {\n const currentDowngraded = this.isDowngraded; // relevant for IE11 only\n const currentValue = this.get(); // IE11 marks this as downgraded\n this.isDowngraded = currentDowngraded; // relevant for IE11 only\n if (// if currentValue is primitive type\n (typeof currentValue !== 'object' || currentValue === null) &&\n // if promised, it will be none\n currentValue !== none) {\n // This was an error case, but various tools like webpack bundler\n // and react dev tools attempt to get props out of non-null object,\n // so this was changed to return just undefined for any property request\n // as there is no way to fix 3rd party tools.\n // Logging a warning to console is also not an option\n // as it pollutes console for legitimate apps on app start app.\n // Ref: https://github.com/avkonst/hookstate/issues/125\n return undefined\n }\n\n if (Array.isArray(currentValue)) {\n if (prop === 'length') {\n return currentValue.length;\n }\n if (prop in Array.prototype) {\n return Array.prototype[prop];\n }\n const index = Number(prop);\n if (!Number.isInteger(index)) {\n return undefined;\n }\n return this.nested(index as keyof S)\n }\n return this.nested(prop.toString() as keyof S)\n }\n\n switch (key) {\n case 'path':\n return this.path\n case 'keys':\n return this.keys\n case 'value':\n return this.value\n case 'ornull':\n return this.ornull\n case 'promised':\n return this.promised\n case 'error':\n return this.error\n case 'get':\n return () => this.get()\n case 'set':\n return (p: SetStateAction) => this.set(p)\n case 'merge':\n return (p: SetPartialStateAction) => this.merge(p)\n case 'nested':\n return (p: keyof S) => nestedGetter(p)\n case 'batch':\n // tslint:disable-next-line: no-any\n return (action: () => R, context: Exclude) => this.batch(action, context)\n case 'attach':\n return (p: symbol) => this.attach(p)\n case 'destroy':\n return () => this.destroy()\n default:\n return nestedGetter(key)\n }\n }\n \n if (IsNoProxy) {\n // minimal support for IE11\n const result = (Array.isArray(this.valueSource) ? [] : {}) as State;\n [self, 'toJSON', 'path', 'keys', 'value', 'ornull',\n 'promised', 'error', 'get', 'set', 'merge',\n 'nested', 'batch', 'attach', 'destroy']\n .forEach(key => {\n Object.defineProperty(result, key, {\n get: () => getter(result, key)\n })\n })\n if (typeof this.valueSource === 'object' && this.valueSource !== null) {\n Object.keys(this.valueSource).forEach(key => {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => getter(result, key)\n })\n })\n }\n this.selfCache = result;\n return this.selfCache\n }\n \n this.selfCache = proxyWrap(this.path, this.valueSource,\n () => {\n this.get() // get latest & mark used\n return this.valueSource\n },\n getter,\n (_, key, value) => {\n throw new StateInvalidUsageError(this.path, ErrorId.SetProperty_State)\n },\n false) as unknown as State;\n return this.selfCache\n }\n \n get promised(): boolean {\n const currentValue = this.get(true) // marks used\n if (currentValue === none && this.state.promised && !this.state.promised.fullfilled) {\n return true;\n }\n return false;\n }\n\n get error(): StateErrorAtRoot | undefined {\n const currentValue = this.get(true) // marks used\n if (currentValue === none) {\n if (this.state.promised && this.state.promised.fullfilled) {\n return this.state.promised.error;\n }\n this.get() // will throw 'read while promised' exception\n }\n return undefined;\n }\n\n batch(\n action: (s: State) => R,\n context?: Exclude\n ): R {\n const opts = { context: context }\n try {\n this.state.startBatch(this.path, opts)\n const result = action(this.self) as R\n if (result as unknown as Symbol === postpone) {\n this.state.postponeBatch(() => this.batch(action, context))\n }\n return result\n } finally {\n this.state.finishBatch(this.path, opts)\n }\n }\n\n get ornull(): InferredStateOrnullType {\n const value = this.get()\n if (value === null || value === undefined) {\n return value as unknown as InferredStateOrnullType;\n }\n return this.self as InferredStateOrnullType;\n }\n\n attach(plugin: () => Plugin): State\n attach(pluginId: symbol): [PluginCallbacks | Error, PluginStateControl]\n attach(p: (() => Plugin) | symbol):\n State | [PluginCallbacks | Error, PluginStateControl] {\n if (typeof p === 'function') {\n const pluginMeta = p();\n if (pluginMeta.id === DowngradedID) {\n this.isDowngraded = true;\n if (this.valueCache !== ValueUnusedMarker) {\n const currentValue = this.getUntracked(true);\n this.valueCache = currentValue;\n }\n return this.self;\n }\n this.state.register(pluginMeta);\n return this.self;\n } else {\n return [\n this.state.getPlugin(p) ||\n (new StateInvalidUsageError(this.path, ErrorId.GetUnknownPlugin, p.toString())), \n this\n ];\n }\n }\n}\n\nfunction proxyWrap(\n path: Path,\n // tslint:disable-next-line: no-any\n targetBootstrap: any,\n // tslint:disable-next-line: no-any\n targetGetter: () => any,\n // tslint:disable-next-line: no-any\n propertyGetter: (unused: any, key: PropertyKey) => any,\n // tslint:disable-next-line: no-any\n propertySetter: (unused: any, p: PropertyKey, value: any, receiver: any) => boolean,\n isValueProxy: boolean\n) {\n const onInvalidUsage = (op: ErrorId) => {\n throw new StateInvalidUsageError(path, op)\n }\n if (typeof targetBootstrap !== 'object' || targetBootstrap === null) {\n targetBootstrap = {}\n }\n return new Proxy(targetBootstrap, {\n getPrototypeOf: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getPrototypeOf#Invariants\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return null;\n }\n return Object.getPrototypeOf(targetReal);\n },\n setPrototypeOf: (target, v) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.SetPrototypeOf_State :\n ErrorId.SetPrototypeOf_Value)\n },\n isExtensible: (target) => {\n // should satisfy the invariants:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/isExtensible#Invariants\n return true; // required to satisfy the invariants of the getPrototypeOf\n // return Object.isExtensible(target);\n },\n preventExtensions: (target) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.PreventExtensions_State :\n ErrorId.PreventExtensions_Value)\n },\n getOwnPropertyDescriptor: (target, p) => {\n const targetReal = targetGetter()\n if (targetReal === undefined || targetReal === null) {\n return undefined;\n }\n const origin = Object.getOwnPropertyDescriptor(targetReal, p);\n if (origin && Array.isArray(targetReal) && p in Array.prototype) {\n return origin;\n }\n return origin && {\n configurable: true, // JSON.stringify() does not work for an object without it\n enumerable: origin.enumerable,\n get: () => propertyGetter(targetReal, p),\n set: undefined\n };\n },\n has: (target, p) => {\n if (typeof p === 'symbol') {\n return false;\n }\n const targetReal = targetGetter()\n if (typeof targetReal === 'object' && targetReal !== null) {\n return p in targetReal;\n }\n return false;\n },\n get: propertyGetter,\n set: propertySetter,\n deleteProperty: (target, p) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DeleteProperty_State :\n ErrorId.DeleteProperty_Value)\n },\n defineProperty: (target, p, attributes) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.DefineProperty_State :\n ErrorId.DefineProperty_Value)\n },\n ownKeys: (target) => {\n const targetReal = targetGetter()\n if (Array.isArray(targetReal)) {\n return Object.keys(targetReal).concat('length');\n }\n if (targetReal === undefined || targetReal === null) {\n return [];\n }\n return Object.keys(targetReal);\n },\n apply: (target, thisArg, argArray?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Apply_State:\n ErrorId.Apply_Value)\n },\n construct: (target, argArray, newTarget?) => {\n return onInvalidUsage(isValueProxy ?\n ErrorId.Construct_State :\n ErrorId.Construct_Value)\n }\n });\n}\n\nfunction createStore(initial: SetInitialStateAction): Store {\n let initialValue: S | Promise = initial as (S | Promise);\n if (typeof initial === 'function') {\n initialValue = (initial as (() => S | Promise))();\n }\n if (typeof initialValue === 'object' && initialValue !== null && initialValue[SelfMethodsID]) {\n throw new StateInvalidUsageError(RootPath, ErrorId.InitStateToValueFromState)\n }\n return new Store(initialValue);\n}\n\nfunction useSubscribedStateMethods(\n state: Store,\n path: Path,\n update: () => void,\n subscribeTarget: Subscribable\n) {\n const link = new StateMethodsImpl(\n state,\n path,\n state.get(path),\n state.edition,\n update,\n );\n // useLayoutEffect here instead of useEffect because of this issue:\n // https://github.com/avkonst/hookstate/issues/165#issuecomment-824670930\n // and very likely this issue:\n // https://github.com/avkonst/hookstate/issues/186\n // and probably this issue:\n // https://github.com/avkonst/hookstate/issues/145\n React.useLayoutEffect(() => {\n subscribeTarget.subscribe(link);\n return () => {\n link.onUnmount()\n subscribeTarget.unsubscribe(link);\n }\n });\n return link;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;AACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;AACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;AACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC;AACF;A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