@tomorrowevening/theatre-dataverse 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +709 -0
- package/dist/Atom.d.ts +127 -0
- package/dist/Atom.d.ts.map +1 -0
- package/dist/PointerProxy.d.ts +33 -0
- package/dist/PointerProxy.d.ts.map +1 -0
- package/dist/Ticker.d.ts +105 -0
- package/dist/Ticker.d.ts.map +1 -0
- package/dist/atom.typeTest.d.ts +2 -0
- package/dist/atom.typeTest.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1555 -0
- package/dist/index.js.map +7 -0
- package/dist/pointer.d.ts +107 -0
- package/dist/pointer.d.ts.map +1 -0
- package/dist/pointer.typeTest.d.ts +2 -0
- package/dist/pointer.typeTest.d.ts.map +1 -0
- package/dist/pointerToPrism.d.ts +20 -0
- package/dist/pointerToPrism.d.ts.map +1 -0
- package/dist/prism/Interface.d.ts +33 -0
- package/dist/prism/Interface.d.ts.map +1 -0
- package/dist/prism/asyncIterateOver.d.ts +1 -0
- package/dist/prism/asyncIterateOver.d.ts.map +1 -0
- package/dist/prism/discoveryMechanism.d.ts +4 -0
- package/dist/prism/discoveryMechanism.d.ts.map +1 -0
- package/dist/prism/iterateAndCountTicks.d.ts +7 -0
- package/dist/prism/iterateAndCountTicks.d.ts.map +1 -0
- package/dist/prism/iterateOver.d.ts +4 -0
- package/dist/prism/iterateOver.d.ts.map +1 -0
- package/dist/prism/prism.d.ts +175 -0
- package/dist/prism/prism.d.ts.map +1 -0
- package/dist/setupTestEnv.d.ts +2 -0
- package/dist/setupTestEnv.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/Stack.d.ts +16 -0
- package/dist/utils/Stack.d.ts.map +1 -0
- package/dist/utils/typeTestUtils.d.ts +11 -0
- package/dist/utils/typeTestUtils.d.ts.map +1 -0
- package/dist/utils/updateDeep.d.ts +3 -0
- package/dist/utils/updateDeep.d.ts.map +1 -0
- package/dist/val.d.ts +14 -0
- package/dist/val.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../../../node_modules/lodash-es/isArray.js", "../../../node_modules/lodash-es/_freeGlobal.js", "../../../node_modules/lodash-es/_root.js", "../../../node_modules/lodash-es/_Symbol.js", "../../../node_modules/lodash-es/_getRawTag.js", "../../../node_modules/lodash-es/_objectToString.js", "../../../node_modules/lodash-es/_baseGetTag.js", "../../../node_modules/lodash-es/isObjectLike.js", "../../../node_modules/lodash-es/isSymbol.js", "../../../node_modules/lodash-es/_isKey.js", "../../../node_modules/lodash-es/isObject.js", "../../../node_modules/lodash-es/isFunction.js", "../../../node_modules/lodash-es/_coreJsData.js", "../../../node_modules/lodash-es/_isMasked.js", "../../../node_modules/lodash-es/_toSource.js", "../../../node_modules/lodash-es/_baseIsNative.js", "../../../node_modules/lodash-es/_getValue.js", "../../../node_modules/lodash-es/_getNative.js", "../../../node_modules/lodash-es/_nativeCreate.js", "../../../node_modules/lodash-es/_hashClear.js", "../../../node_modules/lodash-es/_hashDelete.js", "../../../node_modules/lodash-es/_hashGet.js", "../../../node_modules/lodash-es/_hashHas.js", "../../../node_modules/lodash-es/_hashSet.js", "../../../node_modules/lodash-es/_Hash.js", "../../../node_modules/lodash-es/_listCacheClear.js", "../../../node_modules/lodash-es/eq.js", "../../../node_modules/lodash-es/_assocIndexOf.js", "../../../node_modules/lodash-es/_listCacheDelete.js", "../../../node_modules/lodash-es/_listCacheGet.js", "../../../node_modules/lodash-es/_listCacheHas.js", "../../../node_modules/lodash-es/_listCacheSet.js", "../../../node_modules/lodash-es/_ListCache.js", "../../../node_modules/lodash-es/_Map.js", "../../../node_modules/lodash-es/_mapCacheClear.js", "../../../node_modules/lodash-es/_isKeyable.js", "../../../node_modules/lodash-es/_getMapData.js", "../../../node_modules/lodash-es/_mapCacheDelete.js", "../../../node_modules/lodash-es/_mapCacheGet.js", "../../../node_modules/lodash-es/_mapCacheHas.js", "../../../node_modules/lodash-es/_mapCacheSet.js", "../../../node_modules/lodash-es/_MapCache.js", "../../../node_modules/lodash-es/memoize.js", "../../../node_modules/lodash-es/_memoizeCapped.js", "../../../node_modules/lodash-es/_stringToPath.js", "../../../node_modules/lodash-es/_arrayMap.js", "../../../node_modules/lodash-es/_baseToString.js", "../../../node_modules/lodash-es/toString.js", "../../../node_modules/lodash-es/_castPath.js", "../../../node_modules/lodash-es/_toKey.js", "../../../node_modules/lodash-es/_baseGet.js", "../../../node_modules/lodash-es/get.js", "../../../node_modules/lodash-es/_overArg.js", "../../../node_modules/lodash-es/_getPrototype.js", "../../../node_modules/lodash-es/isPlainObject.js", "../../../node_modules/lodash-es/last.js", "../src/pointer.ts", "../src/utils/updateDeep.ts", "../src/utils/Stack.ts", "../src/prism/Interface.ts", "../src/prism/discoveryMechanism.ts", "../src/prism/prism.ts", "../src/Atom.ts", "../src/pointerToPrism.ts", "../src/val.ts", "../src/prism/iterateAndCountTicks.ts", "../src/Ticker.ts", "../src/prism/iterateOver.ts", "../src/PointerProxy.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * The animation-optimized FRP library powering the internals of Theatre.js.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport type {PointerToPrismProvider} from './pointerToPrism'\r\nexport {default as Atom} from './Atom'\r\nexport {val} from './val'\r\nexport {pointerToPrism} from './pointerToPrism'\r\nexport {isPrism} from './prism/Interface'\r\nexport type {Prism} from './prism/Interface'\r\nexport {default as iterateAndCountTicks} from './prism/iterateAndCountTicks'\r\nexport {default as iterateOver} from './prism/iterateOver'\r\nexport {default as prism} from './prism/prism'\r\nexport {default as pointer, getPointerParts, isPointer} from './pointer'\r\nexport type {Pointer, PointerType, PointerMeta} from './pointer'\r\nexport {default as Ticker} from './Ticker'\r\nexport {default as PointerProxy} from './PointerProxy'\r\n// export {default as asyncIterateOver} from './prism/asyncIterateOver'\r\n", "/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n", "/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n", "import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n", "import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n", "import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nexport default getRawTag;\n", "/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n", "import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nexport default baseGetTag;\n", "/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n", "import isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/;\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\nexport default isKey;\n", "/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n", "import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n", "import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n", "import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n", "/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nexport default toSource;\n", "import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n", "/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n", "import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n", "import getNative from './_getNative.js';\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nexport default nativeCreate;\n", "import nativeCreate from './_nativeCreate.js';\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nexport default hashClear;\n", "/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default hashDelete;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nexport default hashGet;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nexport default hashHas;\n", "import nativeCreate from './_nativeCreate.js';\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nexport default hashSet;\n", "import hashClear from './_hashClear.js';\nimport hashDelete from './_hashDelete.js';\nimport hashGet from './_hashGet.js';\nimport hashHas from './_hashHas.js';\nimport hashSet from './_hashSet.js';\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nexport default Hash;\n", "/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nexport default listCacheClear;\n", "/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nexport default eq;\n", "import eq from './eq.js';\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nexport default assocIndexOf;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nexport default listCacheDelete;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nexport default listCacheGet;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nexport default listCacheHas;\n", "import assocIndexOf from './_assocIndexOf.js';\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nexport default listCacheSet;\n", "import listCacheClear from './_listCacheClear.js';\nimport listCacheDelete from './_listCacheDelete.js';\nimport listCacheGet from './_listCacheGet.js';\nimport listCacheHas from './_listCacheHas.js';\nimport listCacheSet from './_listCacheSet.js';\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nexport default ListCache;\n", "import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n", "import Hash from './_Hash.js';\nimport ListCache from './_ListCache.js';\nimport Map from './_Map.js';\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nexport default mapCacheClear;\n", "/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nexport default isKeyable;\n", "import isKeyable from './_isKeyable.js';\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nexport default getMapData;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nexport default mapCacheDelete;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nexport default mapCacheGet;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nexport default mapCacheHas;\n", "import getMapData from './_getMapData.js';\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nexport default mapCacheSet;\n", "import mapCacheClear from './_mapCacheClear.js';\nimport mapCacheDelete from './_mapCacheDelete.js';\nimport mapCacheGet from './_mapCacheGet.js';\nimport mapCacheHas from './_mapCacheHas.js';\nimport mapCacheSet from './_mapCacheSet.js';\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nexport default MapCache;\n", "import MapCache from './_MapCache.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Expose `MapCache`.\nmemoize.Cache = MapCache;\n\nexport default memoize;\n", "import memoize from './memoize.js';\n\n/** Used as the maximum memoize cache size. */\nvar MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nfunction memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n}\n\nexport default memoizeCapped;\n", "import memoizeCapped from './_memoizeCapped.js';\n\n/** Used to match property names within property paths. */\nvar rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (string.charCodeAt(0) === 46 /* . */) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, subString) {\n result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\nexport default stringToPath;\n", "/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nexport default arrayMap;\n", "import Symbol from './_Symbol.js';\nimport arrayMap from './_arrayMap.js';\nimport isArray from './isArray.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default baseToString;\n", "import baseToString from './_baseToString.js';\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nexport default toString;\n", "import isArray from './isArray.js';\nimport isKey from './_isKey.js';\nimport stringToPath from './_stringToPath.js';\nimport toString from './toString.js';\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n}\n\nexport default castPath;\n", "import isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nexport default toKey;\n", "import castPath from './_castPath.js';\nimport toKey from './_toKey.js';\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = castPath(path, object);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\nexport default baseGet;\n", "import baseGet from './_baseGet.js';\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\nexport default get;\n", "/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nexport default overArg;\n", "import overArg from './_overArg.js';\n\n/** Built-in value references. */\nvar getPrototype = overArg(Object.getPrototypeOf, Object);\n\nexport default getPrototype;\n", "import baseGetTag from './_baseGetTag.js';\nimport getPrototype from './_getPrototype.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\nexport default isPlainObject;\n", "/**\n * Gets the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the last element of `array`.\n * @example\n *\n * _.last([1, 2, 3]);\n * // => 3\n */\nfunction last(array) {\n var length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n}\n\nexport default last;\n", "import type {$IntentionalAny} from './types'\r\n\r\ntype PathToProp = Array<string | number>\r\n\r\nexport type PointerMeta = {\r\n root: {}\r\n path: (string | number)[]\r\n}\r\n\r\n/** We are using an empty object as a WeakMap key for storing pointer meta data */\r\ntype WeakPointerKey = {}\r\n\r\nexport type UnindexableTypesForPointer =\r\n | number\r\n | string\r\n | boolean\r\n | null\r\n | void\r\n | undefined\r\n | Function // eslint-disable-line @typescript-eslint/ban-types\r\n\r\nexport type UnindexablePointer = {\r\n [K in $IntentionalAny]: Pointer<undefined>\r\n}\r\n\r\nconst pointerMetaWeakMap = new WeakMap<WeakPointerKey, PointerMeta>()\r\nconst cachedSubPathPointersWeakMap = new WeakMap<\r\n WeakPointerKey,\r\n Map<string | number, Pointer<unknown>>\r\n>()\r\n\r\n/**\r\n * A wrapper type for the type a `Pointer` points to.\r\n */\r\nexport type PointerType<O> = {\r\n /**\r\n * Only accessible via the type system.\r\n * This is a helper for getting the underlying pointer type\r\n * via the type space.\r\n */\r\n $$__pointer_type: O\r\n}\r\n\r\n/**\r\n * The type of {@link Atom} pointers. See {@link pointer|pointer()} for an\r\n * explanation of pointers.\r\n *\r\n * @see Atom\r\n *\r\n * @remarks\r\n * The Pointer type is quite tricky because it doesn't play well with `any` and other inexact types.\r\n * Here is an example that one would expect to work, but currently doesn't:\r\n * ```ts\r\n * declare function expectAnyPointer(pointer: Pointer<any>): void\r\n *\r\n * expectAnyPointer(null as Pointer<{}>) // this shows as a type error because Pointer<{}> is not assignable to Pointer<any>, even though it should\r\n * ```\r\n *\r\n * The current solution is to just avoid using `any` with pointer-related code (or type-test it well).\r\n * But if you enjoy solving typescript puzzles, consider fixing this :)\r\n * Potentially, [TypeScript variance annotations in 4.7+](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#optional-variance-annotations-for-type-parameters)\r\n * might be able to help us.\r\n */\r\nexport type Pointer<O> = PointerType<O> &\r\n // `Exclude<O, undefined>` will remove `undefined` from the first type\r\n // `undefined extends O ? undefined : never` will give us `undefined` if `O` is `... | undefined`\r\n PointerInner<Exclude<O, undefined>, undefined extends O ? undefined : never>\r\n\r\n// By separating the `O` (non-undefined) from the `undefined` or `never`, we\r\n// can properly use `O extends ...` to determine the kind of potential value\r\n// without actually discarding optionality information.\r\ntype PointerInner<O, Optional> = O extends UnindexableTypesForPointer\r\n ? UnindexablePointer\r\n : unknown extends O\r\n ? UnindexablePointer\r\n : O extends (infer T)[]\r\n ? Pointer<T>[]\r\n : O extends {}\r\n ? {\r\n [K in keyof O]-?: Pointer<O[K] | Optional>\r\n }\r\n : UnindexablePointer\r\n\r\nconst pointerMetaSymbol = Symbol('pointerMeta')\r\n\r\nconst proxyHandler = {\r\n get(\r\n pointerKey: WeakPointerKey,\r\n prop: string | typeof pointerMetaSymbol,\r\n ): $IntentionalAny {\r\n if (prop === pointerMetaSymbol) return pointerMetaWeakMap.get(pointerKey)!\r\n\r\n let subPathPointers = cachedSubPathPointersWeakMap.get(pointerKey)\r\n if (!subPathPointers) {\r\n subPathPointers = new Map()\r\n cachedSubPathPointersWeakMap.set(pointerKey, subPathPointers)\r\n }\r\n\r\n const existing = subPathPointers.get(prop)\r\n if (existing !== undefined) return existing\r\n\r\n const meta = pointerMetaWeakMap.get(pointerKey)!\r\n\r\n const subPointer = pointer({root: meta.root, path: [...meta.path, prop]})\r\n subPathPointers.set(prop, subPointer)\r\n return subPointer\r\n },\r\n}\r\n\r\n/**\r\n * Returns the metadata associated with the pointer. Usually the root object and\r\n * the path.\r\n *\r\n * @param p - The pointer.\r\n */\r\nexport const getPointerMeta = <_>(p: PointerType<_>): PointerMeta => {\r\n // @ts-ignore @todo\r\n const meta: PointerMeta = p[\r\n pointerMetaSymbol as unknown as $IntentionalAny\r\n ] as $IntentionalAny\r\n return meta\r\n}\r\n\r\n/**\r\n * Returns the root object and the path of the pointer.\r\n *\r\n * @example\r\n * ```ts\r\n * const {root, path} = getPointerParts(pointer)\r\n * ```\r\n *\r\n * @param p - The pointer.\r\n *\r\n * @returns An object with two properties: `root`-the root object or the pointer, and `path`-the path of the pointer. `path` is an array of the property-chain.\r\n */\r\nexport const getPointerParts = <_>(\r\n p: Pointer<_>,\r\n): {root: {}; path: PathToProp} => {\r\n const {root, path} = getPointerMeta(p)\r\n return {root, path}\r\n}\r\n\r\n/**\r\n * Creates a pointer to a (nested) property of an {@link Atom}.\r\n *\r\n * @remarks\r\n * Pointers are used to make prisms of properties or nested properties of\r\n * {@link Atom|Atoms}.\r\n *\r\n * Pointers also allow easy construction of new pointers pointing to nested members\r\n * of the root object, by simply using property chaining. E.g. `somePointer.a.b` will\r\n * create a new pointer that has `'a'` and `'b'` added to the path of `somePointer`.\r\n *\r\n * @example\r\n * ```ts\r\n * // Here, sum is a prism that updates whenever the a or b prop of someAtom does.\r\n * const sum = prism(() => {\r\n * return val(pointer({root: someAtom, path: ['a']})) + val(pointer({root: someAtom, path: ['b']}));\r\n * });\r\n *\r\n * // Note, atoms have a convenience Atom.pointer property that points to the root,\r\n * // which you would normally use in this situation.\r\n * const sum = prism(() => {\r\n * return val(someAtom.pointer.a) + val(someAtom.pointer.b);\r\n * });\r\n * ```\r\n *\r\n * @param args - The pointer parameters.\r\n *\r\n * @typeParam O - The type of the value being pointed to.\r\n */\r\nfunction pointer<O>(args: {root: {}; path?: Array<string | number>}) {\r\n const meta: PointerMeta = {\r\n root: args.root as $IntentionalAny,\r\n path: args.path ?? [],\r\n }\r\n const pointerKey: WeakPointerKey = {}\r\n pointerMetaWeakMap.set(pointerKey, meta)\r\n return new Proxy(pointerKey, proxyHandler) as Pointer<O>\r\n}\r\n\r\nexport default pointer\r\n\r\n/**\r\n * Returns whether `p` is a pointer.\r\n */\r\nexport const isPointer = (p: $IntentionalAny): p is Pointer<unknown> => {\r\n return p && !!getPointerMeta(p)\r\n}\r\n", "import type {$FixMe, $IntentionalAny} from '../types'\r\n\r\nexport default function updateDeep<S>(\r\n state: S,\r\n path: (string | number | undefined)[],\r\n reducer: (...args: $IntentionalAny[]) => $IntentionalAny,\r\n): S {\r\n if (path.length === 0) return reducer(state)\r\n return hoop(state, path as $IntentionalAny, reducer)\r\n}\r\n\r\nconst hoop = (\r\n s: $FixMe,\r\n path: (string | number)[],\r\n reducer: $FixMe,\r\n): $FixMe => {\r\n if (path.length === 0) {\r\n return reducer(s)\r\n }\r\n if (Array.isArray(s)) {\r\n let [index, ...restOfPath] = path\r\n index = parseInt(String(index), 10)\r\n if (isNaN(index)) index = 0\r\n const oldVal = s[index]\r\n const newVal = hoop(oldVal, restOfPath, reducer)\r\n if (oldVal === newVal) return s\r\n const newS = [...s]\r\n newS.splice(index, 1, newVal)\r\n return newS\r\n } else if (typeof s === 'object' && s !== null) {\r\n const [key, ...restOfPath] = path\r\n const oldVal = s[key]\r\n const newVal = hoop(oldVal, restOfPath, reducer)\r\n if (oldVal === newVal) return s\r\n const newS = {...s, [key]: newVal}\r\n return newS\r\n } else {\r\n const [key, ...restOfPath] = path\r\n\r\n return {[key]: hoop(undefined, restOfPath, reducer)}\r\n }\r\n}\r\n", "interface Node<Data> {\r\n next: undefined | Node<Data>\r\n data: Data\r\n}\r\n\r\n/**\r\n * Just a simple LinkedList\r\n */\r\nexport default class Stack<Data> {\r\n _head: undefined | Node<Data>\r\n\r\n constructor() {\r\n this._head = undefined\r\n }\r\n\r\n peek() {\r\n return this._head && this._head.data\r\n }\r\n\r\n pop() {\r\n const head = this._head\r\n if (!head) {\r\n return undefined\r\n }\r\n this._head = head.next\r\n return head.data\r\n }\r\n\r\n push(data: Data) {\r\n const node = {next: this._head, data}\r\n this._head = node\r\n }\r\n}\r\n", "import type Ticker from '../Ticker'\r\nimport type {$IntentionalAny, VoidFn} from '../types'\r\n\r\ntype IDependent = (msgComingFrom: Prism<$IntentionalAny>) => void\r\n\r\n/**\r\n * Common interface for prisms.\r\n */\r\nexport interface Prism<V> {\r\n /**\r\n * Whether the object is a prism.\r\n */\r\n isPrism: true\r\n\r\n /**\r\n * Whether the prism is hot.\r\n */\r\n isHot: boolean\r\n\r\n /**\r\n * Calls `listener` with a fresh value every time the prism _has_ a new value, throttled by Ticker.\r\n */\r\n onChange(\r\n ticker: Ticker,\r\n listener: (v: V) => void,\r\n immediate?: boolean,\r\n ): VoidFn\r\n\r\n onStale(cb: () => void): VoidFn\r\n\r\n /**\r\n * Keep the prism hot, even if there are no tappers (subscribers).\r\n */\r\n keepHot(): VoidFn\r\n\r\n /**\r\n * Add a prism as a dependent of this prism.\r\n *\r\n * @param d - The prism to be made a dependent of this prism.\r\n *\r\n * @see _removeDependent\r\n *\r\n * @internal\r\n */\r\n _addDependent(d: IDependent): void\r\n\r\n /**\r\n * Remove a prism as a dependent of this prism.\r\n *\r\n * @param d - The prism to be removed from as a dependent of this prism.\r\n *\r\n * @see _addDependent\r\n * @internal\r\n */\r\n _removeDependent(d: IDependent): void\r\n\r\n /**\r\n * Gets the current value of the prism. If the value is stale, it causes the prism to freshen.\r\n */\r\n getValue(): V\r\n}\r\n\r\n/**\r\n * Returns whether `d` is a prism.\r\n */\r\nexport function isPrism(d: any): d is Prism<unknown> {\r\n return !!(d && d.isPrism && d.isPrism === true)\r\n}\r\n", "import type {$IntentionalAny} from '../types'\r\nimport Stack from '../utils/Stack'\r\nimport type {Prism} from './Interface'\r\n\r\nfunction createMechanism() {\r\n const noop = () => {}\r\n\r\n const stack = new Stack<Collector>()\r\n const noopCollector: Collector = noop\r\n\r\n type Collector = (d: Prism<$IntentionalAny>) => void\r\n\r\n const pushCollector = (collector: Collector): void => {\r\n stack.push(collector)\r\n }\r\n\r\n const popCollector = (collector: Collector): void => {\r\n const existing = stack.peek()\r\n if (existing !== collector) {\r\n throw new Error(`Popped collector is not on top of the stack`)\r\n }\r\n stack.pop()\r\n }\r\n\r\n const startIgnoringDependencies = () => {\r\n stack.push(noopCollector)\r\n }\r\n\r\n const stopIgnoringDependencies = () => {\r\n if (stack.peek() !== noopCollector) {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.warn('This should never happen')\r\n }\r\n } else {\r\n stack.pop()\r\n }\r\n }\r\n\r\n const reportResolutionStart = (d: Prism<$IntentionalAny>) => {\r\n const possibleCollector = stack.peek()\r\n if (possibleCollector) {\r\n possibleCollector(d)\r\n }\r\n\r\n stack.push(noopCollector)\r\n }\r\n\r\n const reportResolutionEnd = (_d: Prism<$IntentionalAny>) => {\r\n stack.pop()\r\n }\r\n\r\n return {\r\n type: 'Dataverse_discoveryMechanism' as 'Dataverse_discoveryMechanism',\r\n startIgnoringDependencies,\r\n stopIgnoringDependencies,\r\n reportResolutionStart,\r\n reportResolutionEnd,\r\n pushCollector,\r\n popCollector,\r\n }\r\n}\r\n\r\nfunction getSharedMechanism(): ReturnType<typeof createMechanism> {\r\n const varName = '__dataverse_discoveryMechanism_sharedStack'\r\n const root =\r\n typeof window !== 'undefined'\r\n ? window\r\n : typeof global !== 'undefined'\r\n ? global\r\n : {}\r\n if (root) {\r\n const existingMechanism: ReturnType<typeof createMechanism> | undefined =\r\n // @ts-ignore ignore\r\n root[varName]\r\n if (\r\n existingMechanism &&\r\n typeof existingMechanism === 'object' &&\r\n existingMechanism.type === 'Dataverse_discoveryMechanism'\r\n ) {\r\n return existingMechanism\r\n } else {\r\n const mechanism = createMechanism()\r\n // @ts-ignore ignore\r\n root[varName] = mechanism\r\n return mechanism\r\n }\r\n } else {\r\n return createMechanism()\r\n }\r\n}\r\n\r\nexport const {\r\n startIgnoringDependencies,\r\n stopIgnoringDependencies,\r\n reportResolutionEnd,\r\n reportResolutionStart,\r\n pushCollector,\r\n popCollector,\r\n} = getSharedMechanism()\r\n", "import type Ticker from '../Ticker'\r\nimport type {$IntentionalAny, VoidFn} from '../types'\r\nimport Stack from '../utils/Stack'\r\nimport type {Prism} from './Interface'\r\nimport {isPrism} from './Interface'\r\nimport {\r\n startIgnoringDependencies,\r\n stopIgnoringDependencies,\r\n pushCollector,\r\n popCollector,\r\n reportResolutionStart,\r\n reportResolutionEnd,\r\n} from './discoveryMechanism'\r\n\r\ntype IDependent = (msgComingFrom: Prism<$IntentionalAny>) => void\r\n\r\nconst voidFn = () => {}\r\n\r\nclass HotHandle<V> {\r\n private _didMarkDependentsAsStale: boolean = false\r\n private _isFresh: boolean = false\r\n protected _cacheOfDendencyValues: Map<Prism<unknown>, unknown> = new Map()\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _dependents: Set<IDependent> = new Set()\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _dependencies: Set<Prism<$IntentionalAny>> = new Set()\r\n\r\n protected _possiblyStaleDeps = new Set<Prism<unknown>>()\r\n\r\n private _scope: HotScope = new HotScope(\r\n this as $IntentionalAny as HotHandle<unknown>,\r\n )\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _lastValue: undefined | V = undefined\r\n\r\n /**\r\n * If true, the prism is stale even though its dependencies aren't\r\n * marked as such. This is used by `prism.source()` and `prism.state()`\r\n * to mark the prism as stale.\r\n */\r\n private _forciblySetToStale: boolean = false\r\n\r\n constructor(\r\n private readonly _fn: () => V,\r\n private readonly _prismInstance: PrismInstance<V>,\r\n ) {\r\n for (const d of this._dependencies) {\r\n d._addDependent(this._reactToDependencyGoingStale)\r\n }\r\n\r\n startIgnoringDependencies()\r\n this.getValue()\r\n stopIgnoringDependencies()\r\n }\r\n\r\n get hasDependents(): boolean {\r\n return this._dependents.size > 0\r\n }\r\n removeDependent(d: IDependent) {\r\n this._dependents.delete(d)\r\n }\r\n addDependent(d: IDependent) {\r\n this._dependents.add(d)\r\n }\r\n\r\n destroy() {\r\n for (const d of this._dependencies) {\r\n d._removeDependent(this._reactToDependencyGoingStale)\r\n }\r\n cleanupScopeStack(this._scope)\r\n }\r\n\r\n getValue(): V {\r\n if (!this._isFresh) {\r\n const newValue = this._recalculate()\r\n this._lastValue = newValue\r\n this._isFresh = true\r\n this._didMarkDependentsAsStale = false\r\n this._forciblySetToStale = false\r\n }\r\n return this._lastValue!\r\n }\r\n\r\n _recalculate() {\r\n let value: V\r\n\r\n if (!this._forciblySetToStale) {\r\n if (this._possiblyStaleDeps.size > 0) {\r\n let anActuallyStaleDepWasFound = false\r\n startIgnoringDependencies()\r\n for (const dep of this._possiblyStaleDeps) {\r\n if (this._cacheOfDendencyValues.get(dep) !== dep.getValue()) {\r\n anActuallyStaleDepWasFound = true\r\n break\r\n }\r\n }\r\n stopIgnoringDependencies()\r\n this._possiblyStaleDeps.clear()\r\n if (!anActuallyStaleDepWasFound) {\r\n return this._lastValue!\r\n }\r\n }\r\n }\r\n\r\n const newDeps: Set<Prism<unknown>> = new Set()\r\n this._cacheOfDendencyValues.clear()\r\n\r\n const collector = (observedDep: Prism<unknown>): void => {\r\n newDeps.add(observedDep)\r\n this._addDependency(observedDep)\r\n }\r\n\r\n pushCollector(collector)\r\n\r\n hookScopeStack.push(this._scope)\r\n try {\r\n value = this._fn()\r\n } catch (error) {\r\n console.error(error)\r\n } finally {\r\n const topOfTheStack = hookScopeStack.pop()\r\n if (topOfTheStack !== this._scope) {\r\n console.warn(\r\n // @todo guide the user to report the bug in an issue\r\n `The Prism hook stack has slipped. This is a bug.`,\r\n )\r\n }\r\n }\r\n\r\n popCollector(collector)\r\n\r\n for (const dep of this._dependencies) {\r\n if (!newDeps.has(dep)) {\r\n this._removeDependency(dep)\r\n }\r\n }\r\n\r\n this._dependencies = newDeps\r\n\r\n startIgnoringDependencies()\r\n for (const dep of newDeps) {\r\n this._cacheOfDendencyValues.set(dep, dep.getValue())\r\n }\r\n stopIgnoringDependencies()\r\n\r\n return value!\r\n }\r\n\r\n forceStale() {\r\n this._forciblySetToStale = true\r\n this._markAsStale()\r\n }\r\n\r\n protected _reactToDependencyGoingStale = (which: Prism<$IntentionalAny>) => {\r\n this._possiblyStaleDeps.add(which)\r\n\r\n this._markAsStale()\r\n }\r\n\r\n private _markAsStale() {\r\n if (this._didMarkDependentsAsStale) return\r\n\r\n this._didMarkDependentsAsStale = true\r\n this._isFresh = false\r\n\r\n for (const dependent of this._dependents) {\r\n dependent(this._prismInstance)\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _addDependency(d: Prism<$IntentionalAny>) {\r\n if (this._dependencies.has(d)) return\r\n this._dependencies.add(d)\r\n d._addDependent(this._reactToDependencyGoingStale)\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected _removeDependency(d: Prism<$IntentionalAny>) {\r\n if (!this._dependencies.has(d)) return\r\n this._dependencies.delete(d)\r\n d._removeDependent(this._reactToDependencyGoingStale)\r\n }\r\n}\r\n\r\nconst emptyObject = {}\r\n\r\nclass PrismInstance<V> implements Prism<V> {\r\n /**\r\n * Whether the object is a prism.\r\n */\r\n readonly isPrism: true = true\r\n\r\n private _state:\r\n | {hot: false; handle: undefined}\r\n | {hot: true; handle: HotHandle<V>} = {\r\n hot: false,\r\n handle: undefined,\r\n }\r\n\r\n constructor(private readonly _fn: () => V) {}\r\n\r\n /**\r\n * Whether the prism is hot.\r\n */\r\n get isHot(): boolean {\r\n return this._state.hot\r\n }\r\n\r\n onChange(\r\n ticker: Ticker,\r\n listener: (v: V) => void,\r\n immediate: boolean = false,\r\n ): VoidFn {\r\n // the prism will call this function every time it goes from fresh to stale\r\n const dependent = () => {\r\n // schedule the listener to be called on the next tick, unless\r\n // we're already on a tick, in which case it'll be called on the current tick.\r\n ticker.onThisOrNextTick(refresh)\r\n }\r\n\r\n // let's cache the last value so we don't call the listener if the value hasn't changed\r\n let lastValue: V | typeof emptyObject =\r\n // use an empty object as the initial value so that the listener is called on the first tick.\r\n // if we were to use, say, undefined, and this.getValue() also returned undefined, the listener\r\n // would never be called.\r\n emptyObject\r\n\r\n // this function will be _scheduled_ to be called on the currently running, or next tick,\r\n // after the prism has gone from fresh to stale.\r\n const refresh = () => {\r\n const newValue = this.getValue()\r\n // if the value hasn't changed, don't call the listener\r\n if (newValue === lastValue) return\r\n\r\n // the value has changed - cache it\r\n lastValue = newValue\r\n\r\n // and let the listener know\r\n listener(newValue)\r\n }\r\n\r\n // add the dependent to the prism's list of dependents (which will make it go hot)\r\n this._addDependent(dependent)\r\n\r\n // if the caller wants the listener to be called immediately, call it now\r\n if (immediate) {\r\n lastValue = this.getValue()\r\n listener(lastValue as $IntentionalAny as V)\r\n }\r\n\r\n // the unsubscribe function\r\n const unsubscribe = () => {\r\n // remove the dependent from the prism's list of dependents (and if it was the last dependent, the prism will go cold)\r\n this._removeDependent(dependent)\r\n // in case we're scheduled for a tick, cancel that\r\n ticker.offThisOrNextTick(refresh)\r\n ticker.offNextTick(refresh)\r\n }\r\n\r\n return unsubscribe\r\n }\r\n\r\n /**\r\n * Calls `callback` every time the prism's state goes from `fresh-\\>stale.` Returns an `unsubscribe()` function.\r\n */\r\n onStale(callback: () => void): VoidFn {\r\n const untap = () => {\r\n this._removeDependent(onStaleCallback)\r\n }\r\n const onStaleCallback = () => callback()\r\n this._addDependent(onStaleCallback)\r\n return untap\r\n }\r\n\r\n /**\r\n * Keep the prism hot, even if there are no tappers (subscribers).\r\n */\r\n keepHot() {\r\n return this.onStale(() => {})\r\n }\r\n\r\n /**\r\n * Add a prism as a dependent of this prism.\r\n *\r\n * @param d - The prism to be made a dependent of this prism.\r\n *\r\n * @see _removeDependent\r\n */\r\n _addDependent(d: IDependent) {\r\n if (!this._state.hot) {\r\n this._goHot()\r\n }\r\n this._state.handle!.addDependent(d)\r\n }\r\n\r\n private _goHot() {\r\n const hotHandle = new HotHandle(this._fn, this)\r\n this._state = {\r\n hot: true,\r\n handle: hotHandle,\r\n }\r\n }\r\n\r\n /**\r\n * Remove a prism as a dependent of this prism.\r\n *\r\n * @param d - The prism to be removed from as a dependent of this prism.\r\n *\r\n * @see _addDependent\r\n */\r\n _removeDependent(d: IDependent) {\r\n const state = this._state\r\n if (!state.hot) {\r\n return\r\n }\r\n const handle = state.handle\r\n handle.removeDependent(d)\r\n if (!handle.hasDependents) {\r\n this._state = {hot: false, handle: undefined}\r\n handle.destroy()\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current value of the prism. If the value is stale, it causes the prism to freshen.\r\n */\r\n getValue(): V {\r\n /**\r\n * TODO We should prevent (or warn about) a common mistake users make, which is reading the value of\r\n * a prism in the body of a react component (e.g. `der.getValue()` (often via `val()`) instead of `useVal()`\r\n * or `uesPrism()`).\r\n *\r\n * Although that's the most common example of this mistake, you can also find it outside of react components.\r\n * Basically the user runs `der.getValue()` assuming the read is detected by a wrapping prism when it's not.\r\n *\r\n * Sometiems the prism isn't even hot when the user assumes it is.\r\n *\r\n * We can fix this type of mistake by:\r\n * 1. Warning the user when they call `getValue()` on a cold prism.\r\n * 2. Warning the user about calling `getValue()` on a hot-but-stale prism\r\n * if `getValue()` isn't called by a known mechanism like a `PrismEmitter`.\r\n *\r\n * Design constraints:\r\n * - This fix should not have a perf-penalty in production. Perhaps use a global flag + `process.env.NODE_ENV !== 'production'`\r\n * to enable it.\r\n * - In the case of `onStale()`, we don't control when the user calls\r\n * `getValue()` (as opposed to `onChange()` which calls `getValue()` directly).\r\n * Perhaps we can disable the check in that case.\r\n * - Probably the best place to add this check is right here in this method plus some changes to `reportResulutionStart()`,\r\n * which would have to be changed to let the caller know if there is an actual collector (a prism)\r\n * present in its stack.\r\n */\r\n reportResolutionStart(this)\r\n\r\n const state = this._state\r\n\r\n let val: V\r\n if (state.hot) {\r\n val = state.handle.getValue()\r\n } else {\r\n val = calculateColdPrism(this._fn)\r\n }\r\n\r\n reportResolutionEnd(this)\r\n return val\r\n }\r\n}\r\n\r\ninterface PrismScope {\r\n effect(key: string, cb: () => () => void, deps?: unknown[]): void\r\n memo<T>(\r\n key: string,\r\n fn: () => T,\r\n deps: undefined | $IntentionalAny[] | ReadonlyArray<$IntentionalAny>,\r\n ): T\r\n state<T>(key: string, initialValue: T): [T, (val: T) => void]\r\n ref<T>(key: string, initialValue: T): IRef<T>\r\n sub(key: string): PrismScope\r\n source<V>(subscribe: (fn: (val: V) => void) => VoidFn, getValue: () => V): V\r\n}\r\n\r\nclass HotScope implements PrismScope {\r\n constructor(private readonly _hotHandle: HotHandle<unknown>) {}\r\n\r\n protected readonly _refs: Map<string, IRef<unknown>> = new Map()\r\n ref<T>(key: string, initialValue: T): IRef<T> {\r\n let ref = this._refs.get(key)\r\n if (ref !== undefined) {\r\n return ref as $IntentionalAny as IRef<T>\r\n } else {\r\n const ref = {\r\n current: initialValue,\r\n }\r\n this._refs.set(key, ref)\r\n return ref\r\n }\r\n }\r\n isPrismScope = true\r\n\r\n // NOTE probably not a great idea to eager-allocate all of these objects/maps for every scope,\r\n // especially because most wouldn't get used in the majority of cases. However, back when these\r\n // were stored on weakmaps, they were uncomfortable to inspect in the debugger.\r\n readonly subs: Record<string, HotScope> = {}\r\n readonly effects: Map<string, IEffect> = new Map()\r\n\r\n effect(key: string, cb: () => () => void, deps?: unknown[]): void {\r\n let effect = this.effects.get(key)\r\n if (effect === undefined) {\r\n effect = {\r\n cleanup: voidFn,\r\n deps: undefined,\r\n }\r\n this.effects.set(key, effect)\r\n }\r\n\r\n if (depsHaveChanged(effect.deps, deps)) {\r\n effect.cleanup()\r\n\r\n startIgnoringDependencies()\r\n effect.cleanup = safelyRun(cb, voidFn).value\r\n stopIgnoringDependencies()\r\n effect.deps = deps\r\n }\r\n /**\r\n * TODO: we should cleanup dangling effects too.\r\n * Example:\r\n * ```ts\r\n * let i = 0\r\n * prism(() => {\r\n * if (i === 0) prism.effect(\"this effect will only run once\", () => {}, [])\r\n * i++\r\n * })\r\n * ```\r\n */\r\n }\r\n\r\n readonly memos: Map<string, IMemo> = new Map()\r\n\r\n memo<T>(\r\n key: string,\r\n fn: () => T,\r\n deps: undefined | $IntentionalAny[] | ReadonlyArray<$IntentionalAny>,\r\n ): T {\r\n let memo = this.memos.get(key)\r\n if (memo === undefined) {\r\n memo = {\r\n cachedValue: null,\r\n // undefined will always indicate \"deps have changed\", so we set its initial value as such\r\n deps: undefined,\r\n }\r\n this.memos.set(key, memo)\r\n }\r\n\r\n if (depsHaveChanged(memo.deps, deps)) {\r\n startIgnoringDependencies()\r\n\r\n memo.cachedValue = safelyRun(fn, undefined).value\r\n stopIgnoringDependencies()\r\n memo.deps = deps\r\n }\r\n\r\n return memo.cachedValue as $IntentionalAny as T\r\n }\r\n\r\n state<T>(key: string, initialValue: T): [T, (val: T) => void] {\r\n const {value, setValue} = this.memo(\r\n 'state/' + key,\r\n () => {\r\n const value = {current: initialValue}\r\n const setValue = (newValue: T) => {\r\n value.current = newValue\r\n this._hotHandle.forceStale()\r\n }\r\n return {value, setValue}\r\n },\r\n [],\r\n )\r\n\r\n return [value.current, setValue]\r\n }\r\n\r\n sub(key: string): HotScope {\r\n if (!this.subs[key]) {\r\n this.subs[key] = new HotScope(this._hotHandle)\r\n }\r\n return this.subs[key]\r\n }\r\n\r\n cleanupEffects() {\r\n for (const effect of this.effects.values()) {\r\n safelyRun(effect.cleanup, undefined)\r\n }\r\n this.effects.clear()\r\n }\r\n\r\n source<V>(subscribe: (fn: (val: V) => void) => VoidFn, getValue: () => V): V {\r\n const sourceKey = '$$source/blah'\r\n this.effect(\r\n sourceKey,\r\n () => {\r\n const unsub = subscribe(() => {\r\n this._hotHandle.forceStale()\r\n })\r\n return unsub\r\n },\r\n [subscribe],\r\n )\r\n return getValue()\r\n }\r\n}\r\n\r\nfunction cleanupScopeStack(scope: HotScope) {\r\n for (const sub of Object.values(scope.subs)) {\r\n cleanupScopeStack(sub)\r\n }\r\n scope.cleanupEffects()\r\n}\r\n\r\nfunction safelyRun<T, U>(\r\n fn: () => T,\r\n returnValueInCaseOfError: U,\r\n): {ok: true; value: T} | {ok: false; value: U} {\r\n try {\r\n return {value: fn(), ok: true}\r\n } catch (error) {\r\n // Naming this function can allow the error reporter additional context to the user on where this error came from\r\n setTimeout(function PrismReportThrow() {\r\n // ensure that the error gets reported, but does not crash the current execution scope\r\n throw error\r\n })\r\n return {value: returnValueInCaseOfError, ok: false}\r\n }\r\n}\r\n\r\nconst hookScopeStack = new Stack<PrismScope>()\r\n\r\ntype IRef<T> = {\r\n current: T\r\n}\r\n\r\ntype IEffect = {\r\n deps: undefined | unknown[]\r\n cleanup: VoidFn\r\n}\r\n\r\ntype IMemo = {\r\n deps: undefined | unknown[] | ReadonlyArray<unknown>\r\n cachedValue: unknown\r\n}\r\n\r\n/**\r\n * Just like React's `useRef()`, `prism.ref()` allows us to create a prism that holds a reference to some value.\r\n * The only difference is that `prism.ref()` requires a key to be passed into it, whlie `useRef()` doesn't.\r\n * This means that we can call `prism.ref()` in any order, and we can call it multiple times with the same key.\r\n * @param key - The key for the ref. Should be unique inside of the prism.\r\n * @param initialValue - The initial value for the ref.\r\n * @returns `{current: V}` - The ref object.\r\n *\r\n * Note that the ref object will always return its initial value if the prism is cold. It'll only record\r\n * its current value if the prism is hot (and will forget again if the prism goes cold again).\r\n *\r\n * @example\r\n * ```ts\r\n * const pr = prism(() => {\r\n * const ref1 = prism.ref(\"ref1\", 0)\r\n * console.log(ref1.current) // will print 0, and if the prism is hot, it'll print the current value\r\n * ref1.current++ // changing the current value of the ref\r\n * })\r\n * ```\r\n */\r\nfunction ref<T>(key: string, initialValue: T): IRef<T> {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`prism.ref() is called outside of a prism() call.`)\r\n }\r\n\r\n return scope.ref(key, initialValue)\r\n}\r\n\r\n/**\r\n * An effect hook, similar to React's `useEffect()`, but is not sensitive to call order by using `key`.\r\n *\r\n * @param key - the key for the effect. Should be uniqe inside of the prism.\r\n * @param cb - the callback function. Requires returning a cleanup function.\r\n * @param deps - the dependency array\r\n */\r\nfunction effect(key: string, cb: () => () => void, deps?: unknown[]): void {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`prism.effect() is called outside of a prism() call.`)\r\n }\r\n\r\n return scope.effect(key, cb, deps)\r\n}\r\n\r\nfunction depsHaveChanged(\r\n oldDeps: undefined | unknown[] | ReadonlyArray<unknown>,\r\n newDeps: undefined | unknown[] | ReadonlyArray<unknown>,\r\n): boolean {\r\n if (oldDeps === undefined || newDeps === undefined) {\r\n return true\r\n }\r\n\r\n const len = oldDeps.length\r\n if (len !== newDeps.length) return true\r\n\r\n for (let i = 0; i < len; i++) {\r\n if (oldDeps[i] !== newDeps[i]) return true\r\n }\r\n\r\n return false\r\n}\r\n\r\n/**\r\n * `prism.memo()` works just like React's `useMemo()` hook. It's a way to cache the result of a function call.\r\n * The only difference is that `prism.memo()` requires a key to be passed into it, whlie `useMemo()` doesn't.\r\n * This means that we can call `prism.memo()` in any order, and we can call it multiple times with the same key.\r\n *\r\n * @param key - The key for the memo. Should be unique inside of the prism\r\n * @param fn - The function to memoize\r\n * @param deps - The dependency array. Provide `[]` if you want to the value to be memoized only once and never re-calculated.\r\n * @returns The result of the function call\r\n *\r\n * @example\r\n * ```ts\r\n * const pr = prism(() => {\r\n * const memoizedReturnValueOfExpensiveFn = prism.memo(\"memo1\", expensiveFn, [])\r\n * })\r\n * ```\r\n */\r\nfunction memo<T>(\r\n key: string,\r\n fn: () => T,\r\n deps: undefined | $IntentionalAny[] | ReadonlyArray<$IntentionalAny>,\r\n): T {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`prism.memo() is called outside of a prism() call.`)\r\n }\r\n\r\n return scope.memo(key, fn, deps)\r\n}\r\n\r\n/**\r\n * A state hook, similar to react's `useState()`.\r\n *\r\n * @param key - the key for the state\r\n * @param initialValue - the initial value\r\n * @returns [currentState, setState]\r\n *\r\n * @example\r\n * ```ts\r\n * import {prism} from 'dataverse'\r\n *\r\n * // This prism holds the current mouse position and updates when the mouse moves\r\n * const mousePositionD = prism(() => {\r\n * const [pos, setPos] = prism.state<[x: number, y: number]>('pos', [0, 0])\r\n *\r\n * prism.effect(\r\n * 'setupListeners',\r\n * () => {\r\n * const handleMouseMove = (e: MouseEvent) => {\r\n * setPos([e.screenX, e.screenY])\r\n * }\r\n * document.addEventListener('mousemove', handleMouseMove)\r\n *\r\n * return () => {\r\n * document.removeEventListener('mousemove', handleMouseMove)\r\n * }\r\n * },\r\n * [],\r\n * )\r\n *\r\n * return pos\r\n * })\r\n * ```\r\n */\r\nfunction state<T>(key: string, initialValue: T): [T, (val: T) => void] {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`prism.state() is called outside of a prism() call.`)\r\n }\r\n\r\n return scope.state(key, initialValue)\r\n}\r\n\r\n/**\r\n * This is useful to make sure your code is running inside a `prism()` call.\r\n *\r\n * @example\r\n * ```ts\r\n * import {prism} from '@tomorrowevening/theatre-dataverse'\r\n *\r\n * function onlyUsefulInAPrism() {\r\n * prism.ensurePrism()\r\n * }\r\n *\r\n * prism(() => {\r\n * onlyUsefulInAPrism() // will run fine\r\n * })\r\n *\r\n * setTimeout(() => {\r\n * onlyUsefulInAPrism() // throws an error\r\n * console.log('This will never get logged')\r\n * }, 0)\r\n * ```\r\n */\r\nfunction ensurePrism(): void {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`The parent function is called outside of a prism() call.`)\r\n }\r\n}\r\n\r\nfunction scope<T>(key: string, fn: () => T): T {\r\n const parentScope = hookScopeStack.peek()\r\n if (!parentScope) {\r\n throw new Error(`prism.scope() is called outside of a prism() call.`)\r\n }\r\n const subScope = parentScope.sub(key)\r\n hookScopeStack.push(subScope)\r\n const ret = safelyRun(fn, undefined).value\r\n hookScopeStack.pop()\r\n return ret as $IntentionalAny as T\r\n}\r\n\r\n/**\r\n * Just an alias for `prism.memo(key, () => prism(fn), deps).getValue()`. It creates a new prism, memoizes it, and returns the value.\r\n * `prism.sub()` is useful when you want to divide your prism into smaller prisms, each of which\r\n * would _only_ recalculate when _certain_ dependencies change. In other words, it's an optimization tool.\r\n *\r\n * @param key - The key for the memo. Should be unique inside of the prism\r\n * @param fn - The function to run inside the prism\r\n * @param deps - The dependency array. Provide `[]` if you want to the value to be memoized only once and never re-calculated.\r\n * @returns The value of the inner prism\r\n */\r\nfunction sub<T>(\r\n key: string,\r\n fn: () => T,\r\n deps: undefined | $IntentionalAny[],\r\n): T {\r\n return memo(key, () => prism(fn), deps).getValue()\r\n}\r\n\r\n/**\r\n * @returns true if the current function is running inside a `prism()` call.\r\n */\r\nfunction inPrism(): boolean {\r\n return !!hookScopeStack.peek()\r\n}\r\n\r\nconst possiblePrismToValue = <P extends Prism<$IntentionalAny> | unknown>(\r\n input: P,\r\n): P extends Prism<infer T> ? T : P => {\r\n if (isPrism(input)) {\r\n return input.getValue() as $IntentionalAny\r\n } else {\r\n return input as $IntentionalAny\r\n }\r\n}\r\n\r\n/**\r\n * `prism.source()` allow a prism to react to changes in some external source (other than other prisms).\r\n * For example, `Atom.pointerToPrism()` uses `prism.source()` to create a prism that reacts to changes in the atom's value.\r\n \r\n * @param subscribe - The prism will call this function as soon as the prism goes hot. This function should return an unsubscribe function function which the prism will call when it goes cold.\r\n * @param getValue - A function that returns the current value of the external source.\r\n * @returns The current value of the source\r\n * \r\n * Example:\r\n * ```ts\r\n * function prismFromInputElement(input: HTMLInputElement): Prism<string> {\r\n * function listen(cb: (value: string) => void) {\r\n * const listener = () => {\r\n * cb(input.value)\r\n * }\r\n * input.addEventListener('input', listener)\r\n * return () => {\r\n * input.removeEventListener('input', listener)\r\n * }\r\n * }\r\n * \r\n * function get() {\r\n * return input.value\r\n * }\r\n * return prism(() => prism.source(listen, get))\r\n * }\r\n * ```\r\n */\r\nfunction source<V>(\r\n subscribe: (fn: (val: V) => void) => VoidFn,\r\n getValue: () => V,\r\n): V {\r\n const scope = hookScopeStack.peek()\r\n if (!scope) {\r\n throw new Error(`prism.source() is called outside of a prism() call.`)\r\n }\r\n\r\n return scope.source(subscribe, getValue)\r\n}\r\n\r\ntype IPrismFn = {\r\n <T>(fn: () => T): Prism<T>\r\n ref: typeof ref\r\n effect: typeof effect\r\n memo: typeof memo\r\n ensurePrism: typeof ensurePrism\r\n state: typeof state\r\n scope: typeof scope\r\n sub: typeof sub\r\n inPrism: typeof inPrism\r\n source: typeof source\r\n}\r\n\r\n/**\r\n * Creates a prism from the passed function that adds all prisms referenced\r\n * in it as dependencies, and reruns the function when these change.\r\n *\r\n * @param fn - The function to rerun when the prisms referenced in it change.\r\n */\r\nconst prism: IPrismFn = (fn) => {\r\n return new PrismInstance(fn)\r\n}\r\n\r\nclass ColdScope implements PrismScope {\r\n effect(key: string, cb: () => () => void, deps?: unknown[]): void {\r\n console.warn(`prism.effect() does not run in cold prisms`)\r\n }\r\n memo<T>(\r\n key: string,\r\n fn: () => T,\r\n deps: any[] | readonly any[] | undefined,\r\n ): T {\r\n return fn()\r\n }\r\n state<T>(key: string, initialValue: T): [T, (val: T) => void] {\r\n return [initialValue, () => {}]\r\n }\r\n ref<T>(key: string, initialValue: T): IRef<T> {\r\n return {current: initialValue}\r\n }\r\n sub(key: string): ColdScope {\r\n return new ColdScope()\r\n }\r\n source<V>(subscribe: (fn: (val: V) => void) => VoidFn, getValue: () => V): V {\r\n return getValue()\r\n }\r\n}\r\n\r\nfunction calculateColdPrism<V>(fn: () => V): V {\r\n const scope = new ColdScope()\r\n hookScopeStack.push(scope)\r\n let value: V\r\n try {\r\n value = fn()\r\n } catch (error) {\r\n console.error(error)\r\n } finally {\r\n const topOfTheStack = hookScopeStack.pop()\r\n if (topOfTheStack !== scope) {\r\n console.warn(\r\n // @todo guide the user to report the bug in an issue\r\n `The Prism hook stack has slipped. This is a bug.`,\r\n )\r\n }\r\n }\r\n return value!\r\n}\r\n\r\nprism.ref = ref\r\nprism.effect = effect\r\nprism.memo = memo\r\nprism.ensurePrism = ensurePrism\r\nprism.state = state\r\nprism.scope = scope\r\nprism.sub = sub\r\nprism.inPrism = inPrism\r\nprism.source = source\r\n\r\nexport default prism\r\n", "import get from 'lodash-es/get'\r\nimport isPlainObject from 'lodash-es/isPlainObject'\r\nimport last from 'lodash-es/last'\r\nimport type {Prism} from './prism/Interface'\r\nimport type {Pointer} from './pointer'\r\nimport {getPointerParts} from './pointer'\r\nimport {isPointer} from './pointer'\r\nimport pointer from './pointer'\r\nimport type {$FixMe, $IntentionalAny} from './types'\r\nimport updateDeep from './utils/updateDeep'\r\nimport prism from './prism/prism'\r\nimport type {PointerToPrismProvider} from './pointerToPrism'\r\n\r\ntype Listener = (newVal: unknown) => void\r\n\r\nenum ValueTypes {\r\n Dict,\r\n Array,\r\n Other,\r\n}\r\n\r\nconst getTypeOfValue = (v: unknown): ValueTypes => {\r\n if (Array.isArray(v)) return ValueTypes.Array\r\n if (isPlainObject(v)) return ValueTypes.Dict\r\n return ValueTypes.Other\r\n}\r\n\r\nconst getKeyOfValue = (\r\n v: unknown,\r\n key: string | number,\r\n vType: ValueTypes = getTypeOfValue(v),\r\n): unknown => {\r\n if (vType === ValueTypes.Dict && typeof key === 'string') {\r\n return (v as $IntentionalAny)[key]\r\n } else if (vType === ValueTypes.Array && isValidArrayIndex(key)) {\r\n return (v as $IntentionalAny)[key]\r\n } else {\r\n return undefined\r\n }\r\n}\r\n\r\nconst isValidArrayIndex = (key: string | number): boolean => {\r\n const inNumber = typeof key === 'number' ? key : parseInt(key, 10)\r\n return (\r\n !isNaN(inNumber) &&\r\n inNumber >= 0 &&\r\n inNumber < Infinity &&\r\n (inNumber | 0) === inNumber\r\n )\r\n}\r\n\r\nclass Scope {\r\n children: Map<string | number, Scope> = new Map()\r\n identityChangeListeners: Set<Listener> = new Set()\r\n constructor(\r\n readonly _parent: undefined | Scope,\r\n readonly _path: (string | number)[],\r\n ) {}\r\n\r\n addIdentityChangeListener(cb: Listener) {\r\n this.identityChangeListeners.add(cb)\r\n }\r\n\r\n removeIdentityChangeListener(cb: Listener) {\r\n this.identityChangeListeners.delete(cb)\r\n this._checkForGC()\r\n }\r\n\r\n removeChild(key: string | number) {\r\n this.children.delete(key)\r\n this._checkForGC()\r\n }\r\n\r\n getChild(key: string | number) {\r\n return this.children.get(key)\r\n }\r\n\r\n getOrCreateChild(key: string | number) {\r\n let child = this.children.get(key)\r\n if (!child) {\r\n child = child = new Scope(this, this._path.concat([key]))\r\n this.children.set(key, child)\r\n }\r\n return child\r\n }\r\n\r\n _checkForGC() {\r\n if (this.identityChangeListeners.size > 0) return\r\n if (this.children.size > 0) return\r\n\r\n if (this._parent) {\r\n this._parent.removeChild(last(this._path) as string | number)\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Wraps an object whose (sub)properties can be individually tracked.\r\n */\r\nexport default class Atom<State> implements PointerToPrismProvider {\r\n private _currentState: State\r\n /**\r\n * @internal\r\n */\r\n readonly $$isPointerToPrismProvider = true\r\n private readonly _rootScope: Scope\r\n /**\r\n * Convenience property that gives you a pointer to the root of the atom.\r\n *\r\n * @remarks\r\n * Equivalent to `pointer({ root: thisAtom, path: [] })`.\r\n */\r\n readonly pointer: Pointer<State> = pointer({root: this as $FixMe, path: []})\r\n\r\n readonly prism: Prism<State> = this.pointerToPrism(\r\n this.pointer,\r\n ) as $IntentionalAny\r\n\r\n constructor(initialState: State) {\r\n this._currentState = initialState\r\n this._rootScope = new Scope(undefined, [])\r\n }\r\n\r\n /**\r\n * Sets the state of the atom.\r\n *\r\n * @param newState - The new state of the atom.\r\n */\r\n set(newState: State) {\r\n const oldState = this._currentState\r\n this._currentState = newState\r\n\r\n this._checkUpdates(this._rootScope, oldState, newState)\r\n }\r\n\r\n /**\r\n * Returns the current state of the atom.\r\n */\r\n get(): State {\r\n return this._currentState\r\n }\r\n\r\n /**\r\n * Returns the value at the given pointer\r\n *\r\n * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer\r\n *\r\n * Example\r\n * ```ts\r\n * const atom = atom({ a: { b: 1 } })\r\n * atom.getByPointer(atom.pointer.a.b) // 1\r\n * atom.getByPointer((p) => p.a.b) // 1\r\n * ```\r\n */\r\n getByPointer<S>(\r\n pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>),\r\n ): S {\r\n const pointer = isPointer(pointerOrFn)\r\n ? pointerOrFn\r\n : (pointerOrFn as $IntentionalAny)(this.pointer)\r\n\r\n const path = getPointerParts(pointer).path\r\n return this._getIn(path) as S\r\n }\r\n\r\n /**\r\n * Gets the state of the atom at `path`.\r\n */\r\n private _getIn(path: (string | number)[]): unknown {\r\n return path.length === 0 ? this.get() : get(this.get(), path)\r\n }\r\n\r\n reduce(fn: (state: State) => State) {\r\n this.set(fn(this.get()))\r\n }\r\n\r\n /**\r\n * Reduces the value at the given pointer\r\n *\r\n * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer\r\n *\r\n * Example\r\n * ```ts\r\n * const atom = atom({ a: { b: 1 } })\r\n * atom.reduceByPointer(atom.pointer.a.b, (b) => b + 1) // atom.get().a.b === 2\r\n * atom.reduceByPointer((p) => p.a.b, (b) => b + 1) // atom.get().a.b === 2\r\n * ```\r\n */\r\n reduceByPointer<S>(\r\n pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>),\r\n reducer: (s: S) => S,\r\n ) {\r\n const pointer = isPointer(pointerOrFn)\r\n ? pointerOrFn\r\n : (pointerOrFn as $IntentionalAny)(this.pointer)\r\n\r\n const path = getPointerParts(pointer).path\r\n const newState = updateDeep(this.get(), path, reducer)\r\n this.set(newState)\r\n }\r\n\r\n /**\r\n * Sets the value at the given pointer\r\n *\r\n * @param pointerOrFn - A pointer to the desired path. Could also be a function returning a pointer\r\n *\r\n * Example\r\n * ```ts\r\n * const atom = atom({ a: { b: 1 } })\r\n * atom.setByPointer(atom.pointer.a.b, 2) // atom.get().a.b === 2\r\n * atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2\r\n * ```\r\n */\r\n setByPointer<S>(\r\n pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>),\r\n val: S,\r\n ) {\r\n this.reduceByPointer(pointerOrFn, () => val)\r\n }\r\n\r\n private _checkUpdates(scope: Scope, oldState: unknown, newState: unknown) {\r\n if (oldState === newState) return\r\n for (const cb of scope.identityChangeListeners) {\r\n cb(newState)\r\n }\r\n\r\n if (scope.children.size === 0) return\r\n\r\n // @todo we can probably skip checking value types\r\n const oldValueType = getTypeOfValue(oldState)\r\n const newValueType = getTypeOfValue(newState)\r\n\r\n if (oldValueType === ValueTypes.Other && oldValueType === newValueType)\r\n return\r\n\r\n for (const [childKey, childScope] of scope.children) {\r\n const oldChildVal = getKeyOfValue(oldState, childKey, oldValueType)\r\n const newChildVal = getKeyOfValue(newState, childKey, newValueType)\r\n this._checkUpdates(childScope, oldChildVal, newChildVal)\r\n }\r\n }\r\n\r\n private _getOrCreateScopeForPath(path: (string | number)[]): Scope {\r\n let curScope = this._rootScope\r\n for (const pathEl of path) {\r\n curScope = curScope.getOrCreateChild(pathEl)\r\n }\r\n return curScope\r\n }\r\n\r\n /**\r\n * Adds a listener that will be called whenever the value at the given pointer changes.\r\n * @param pointer - The pointer to listen to\r\n * @param cb - The callback to call when the value changes\r\n * @returns A function that can be called to unsubscribe from the listener\r\n *\r\n * **NOTE** Unlike {@link prism}s, `onChangeByPointer` and `onChange()` are traditional event listeners. They don't\r\n * provide any of the benefits of prisms. They don't compose, they can't be coordinated via a Ticker, their derivations\r\n * aren't cached, etc. You're almost always better off using a prism (which will internally use `onChangeByPointer`).\r\n *\r\n * ```ts\r\n * const a = atom({foo: 1})\r\n * const unsubscribe = a.onChangeByPointer(a.pointer.foo, (v) => {\r\n * console.log('foo changed to', v)\r\n * })\r\n * a.setByPointer(a.pointer.foo, 2) // logs 'foo changed to 2'\r\n * a.set({foo: 3}) // logs 'foo changed to 3'\r\n * unsubscribe()\r\n * ```\r\n */\r\n onChangeByPointer = <S>(\r\n pointerOrFn: Pointer<S> | ((p: Pointer<State>) => Pointer<S>),\r\n cb: (v: S) => void,\r\n ): (() => void) => {\r\n const pointer = isPointer(pointerOrFn)\r\n ? pointerOrFn\r\n : (pointerOrFn as $IntentionalAny)(this.pointer)\r\n const {path} = getPointerParts(pointer)\r\n const scope = this._getOrCreateScopeForPath(path)\r\n scope.identityChangeListeners.add(cb as $IntentionalAny)\r\n const unsubscribe = () => {\r\n scope.identityChangeListeners.delete(cb as $IntentionalAny)\r\n }\r\n return unsubscribe\r\n }\r\n\r\n /**\r\n * Adds a listener that will be called whenever the state of the atom changes.\r\n * @param cb - The callback to call when the value changes\r\n * @returns A function that can be called to unsubscribe from the listener\r\n *\r\n * **NOTE** Unlike {@link prism}s, `onChangeByPointer` and `onChange()` are traditional event listeners. They don't\r\n * provide any of the benefits of prisms. They don't compose, they can't be coordinated via a Ticker, their derivations\r\n * aren't cached, etc. You're almost always better off using a prism (which will internally use `onChangeByPointer`).\r\n *\r\n * ```ts\r\n * const a = atom({foo: 1})\r\n * const unsubscribe = a.onChange((v) => {\r\n * console.log('a changed to', v)\r\n * })\r\n * a.set({foo: 3}) // logs 'a changed to {foo: 3}'\r\n * unsubscribe()\r\n * ```\r\n */\r\n onChange(cb: (v: State) => void): () => void {\r\n return this.onChangeByPointer(this.pointer, cb)\r\n }\r\n\r\n /**\r\n * Returns a new prism of the value at the provided path.\r\n *\r\n * @param pointer - The path to create the prism at.\r\n *\r\n * ```ts\r\n * const pr = atom({ a: { b: 1 } }).pointerToPrism(atom.pointer.a.b)\r\n * pr.getValue() // 1\r\n * ```\r\n */\r\n pointerToPrism<P>(pointer: Pointer<P>): Prism<P> {\r\n const {path} = getPointerParts(pointer)\r\n const subscribe = (listener: (val: unknown) => void) =>\r\n this.onChangeByPointer(pointer, listener)\r\n\r\n const getValue = () => this._getIn(path)\r\n\r\n return prism(() => {\r\n return prism.source(subscribe, getValue)\r\n }) as Prism<P>\r\n }\r\n}\r\n", "import type {Prism} from './prism/Interface'\r\nimport type {Pointer, PointerType} from './pointer'\r\nimport {getPointerMeta} from './pointer'\r\nimport type {$IntentionalAny} from './types'\r\n\r\nconst identifyPrismWeakMap = new WeakMap<{}, Prism<unknown>>()\r\n\r\n/**\r\n * Interface for objects that can provide a prism at a certain path.\r\n */\r\nexport interface PointerToPrismProvider {\r\n /**\r\n * @internal\r\n * Future: We could consider using a `Symbol.for(\"dataverse/PointerToPrismProvider\")` as a key here, similar to\r\n * how {@link Iterable} works for `of`.\r\n */\r\n readonly $$isPointerToPrismProvider: true\r\n /**\r\n * Returns a prism of the value at the provided pointer.\r\n */\r\n pointerToPrism<P>(pointer: Pointer<P>): Prism<P>\r\n}\r\n\r\nexport function isPointerToPrismProvider(\r\n val: unknown,\r\n): val is PointerToPrismProvider {\r\n return (\r\n typeof val === 'object' &&\r\n val !== null &&\r\n (val as $IntentionalAny)['$$isPointerToPrismProvider'] === true\r\n )\r\n}\r\n\r\n/**\r\n * Returns a prism of the value at the provided pointer. Prisms are\r\n * cached per pointer.\r\n *\r\n * @param pointer - The pointer to return the prism at.\r\n */\r\n\r\nexport const pointerToPrism = <P extends PointerType<$IntentionalAny>>(\r\n pointer: P,\r\n): Prism<P extends PointerType<infer T> ? T : void> => {\r\n const meta = getPointerMeta(pointer)\r\n\r\n let prismInstance = identifyPrismWeakMap.get(meta)\r\n if (!prismInstance) {\r\n const root = meta.root\r\n if (!isPointerToPrismProvider(root)) {\r\n throw new Error(\r\n `Cannot run pointerToPrism() on a pointer whose root is not an PointerToPrismProvider`,\r\n )\r\n }\r\n prismInstance = root.pointerToPrism(pointer as $IntentionalAny)\r\n identifyPrismWeakMap.set(meta, prismInstance)\r\n }\r\n return prismInstance as $IntentionalAny\r\n}\r\n", "import type {Prism} from './prism/Interface'\r\nimport {isPrism} from './prism/Interface'\r\nimport type {PointerType} from './pointer'\r\nimport {isPointer} from './pointer'\r\nimport type {$IntentionalAny} from './types'\r\nimport {pointerToPrism} from './pointerToPrism'\r\n\r\n/**\r\n * Convenience function that returns a plain value from its argument, whether it\r\n * is a pointer, a prism or a plain value itself.\r\n *\r\n * @remarks\r\n * For pointers, the value is returned by first creating a prism, so it is\r\n * reactive e.g. when used in a `prism`.\r\n *\r\n * @param input - The argument to return a value from.\r\n */\r\n\r\nexport const val = <\r\n P extends\r\n | PointerType<$IntentionalAny>\r\n | Prism<$IntentionalAny>\r\n | undefined\r\n | null,\r\n>(\r\n input: P,\r\n): P extends PointerType<infer T>\r\n ? T\r\n : P extends Prism<infer T>\r\n ? T\r\n : P extends undefined | null\r\n ? P\r\n : unknown => {\r\n if (isPointer(input)) {\r\n return pointerToPrism(input).getValue() as $IntentionalAny\r\n } else if (isPrism(input)) {\r\n return input.getValue() as $IntentionalAny\r\n } else {\r\n return input as $IntentionalAny\r\n }\r\n}\r\n", "import {pointerToPrism} from '../pointerToPrism'\r\nimport type {Pointer} from '../pointer'\r\nimport {isPointer} from '../pointer'\r\nimport type {Prism} from './Interface'\r\nimport {isPrism} from './Interface'\r\n\r\nexport default function* iterateAndCountTicks<V>(\r\n pointerOrPrism: Prism<V> | Pointer<V>,\r\n): Generator<{value: V; ticks: number}, void, void> {\r\n let d\r\n if (isPointer(pointerOrPrism)) {\r\n d = pointerToPrism(pointerOrPrism) as Prism<V>\r\n } else if (isPrism(pointerOrPrism)) {\r\n d = pointerOrPrism\r\n } else {\r\n throw new Error(`Only pointers and prisms are supported`)\r\n }\r\n\r\n let ticksCountedSinceLastYield = 0\r\n const untap = d.onStale(() => {\r\n ticksCountedSinceLastYield++\r\n })\r\n\r\n try {\r\n while (true) {\r\n const ticks = ticksCountedSinceLastYield\r\n ticksCountedSinceLastYield = 0\r\n yield {value: d.getValue(), ticks}\r\n }\r\n } finally {\r\n untap()\r\n }\r\n}\r\n", "type ICallback = (t: number) => void\r\n\r\n/**\r\n * The number of ticks that can pass without any scheduled callbacks before the Ticker goes dormant. This is to prevent\r\n * the Ticker from staying active forever, even if there are no scheduled callbacks.\r\n *\r\n * Perhaps counting ticks vs. time is not the best way to do this. But it's a start.\r\n */\r\nexport const EMPTY_TICKS_BEFORE_GOING_DORMANT = 60 /*fps*/ * 3 /*seconds*/ // on a 60fps screen, 3 seconds should pass before the ticker goes dormant\r\n\r\n/**\r\n * The Ticker class helps schedule callbacks. Scheduled callbacks are executed per tick. Ticks can be triggered by an\r\n * external scheduling strategy, e.g. a raf.\r\n */\r\nexport default class Ticker {\r\n private _scheduledForThisOrNextTick: Set<ICallback>\r\n private _scheduledForNextTick: Set<ICallback>\r\n private _timeAtCurrentTick: number\r\n private _ticking: boolean = false\r\n\r\n /**\r\n * Whether the Ticker is dormant\r\n */\r\n private _dormant: boolean = true\r\n\r\n private _numberOfDormantTicks = 0\r\n\r\n /**\r\n * Whether the Ticker is dormant\r\n */\r\n get dormant(): boolean {\r\n return this._dormant\r\n }\r\n /**\r\n * Counts up for every tick executed.\r\n * Internally, this is used to measure ticks per second.\r\n *\r\n * This is \"public\" to TypeScript, because it's a tool for performance measurements.\r\n * Consider this as experimental, and do not rely on it always being here in future releases.\r\n */\r\n public __ticks = 0\r\n\r\n constructor(\r\n private _conf?: {\r\n /**\r\n * This is called when the Ticker goes dormant.\r\n */\r\n onDormant?: () => void\r\n /**\r\n * This is called when the Ticker goes active.\r\n */\r\n onActive?: () => void\r\n },\r\n ) {\r\n this._scheduledForThisOrNextTick = new Set()\r\n this._scheduledForNextTick = new Set()\r\n this._timeAtCurrentTick = 0\r\n }\r\n\r\n /**\r\n * Registers for fn to be called either on this tick or the next tick.\r\n *\r\n * If `onThisOrNextTick()` is called while `Ticker.tick()` is running, the\r\n * side effect _will_ be called within the running tick. If you don't want this\r\n * behavior, you can use `onNextTick()`.\r\n *\r\n * Note that `fn` will be added to a `Set()`. Which means, if you call `onThisOrNextTick(fn)`\r\n * with the same fn twice in a single tick, it'll only run once.\r\n *\r\n * @param fn - The function to be registered.\r\n *\r\n * @see offThisOrNextTick\r\n */\r\n onThisOrNextTick(fn: ICallback) {\r\n this._scheduledForThisOrNextTick.add(fn)\r\n if (this._dormant) {\r\n this._goActive()\r\n }\r\n }\r\n\r\n /**\r\n * Registers a side effect to be called on the next tick.\r\n *\r\n * @param fn - The function to be registered.\r\n *\r\n * @see onThisOrNextTick\r\n * @see offNextTick\r\n */\r\n onNextTick(fn: ICallback) {\r\n this._scheduledForNextTick.add(fn)\r\n if (this._dormant) {\r\n this._goActive()\r\n }\r\n }\r\n\r\n /**\r\n * De-registers a fn to be called either on this tick or the next tick.\r\n *\r\n * @param fn - The function to be de-registered.\r\n *\r\n * @see onThisOrNextTick\r\n */\r\n offThisOrNextTick(fn: ICallback) {\r\n this._scheduledForThisOrNextTick.delete(fn)\r\n }\r\n\r\n /**\r\n * De-registers a fn to be called on the next tick.\r\n *\r\n * @param fn - The function to be de-registered.\r\n *\r\n * @see onNextTick\r\n */\r\n offNextTick(fn: ICallback) {\r\n this._scheduledForNextTick.delete(fn)\r\n }\r\n\r\n /**\r\n * The time at the start of the current tick if there is a tick in progress, otherwise defaults to\r\n * `performance.now()`.\r\n */\r\n get time() {\r\n if (this._ticking) {\r\n return this._timeAtCurrentTick\r\n } else return performance.now()\r\n }\r\n\r\n private _goActive() {\r\n if (!this._dormant) return\r\n this._dormant = false\r\n this._conf?.onActive?.()\r\n }\r\n\r\n private _goDormant() {\r\n if (this._dormant) return\r\n this._dormant = true\r\n this._numberOfDormantTicks = 0\r\n this._conf?.onDormant?.()\r\n }\r\n\r\n /**\r\n * Triggers a tick which starts executing the callbacks scheduled for this tick.\r\n *\r\n * @param t - The time at the tick.\r\n *\r\n * @see onThisOrNextTick\r\n * @see onNextTick\r\n */\r\n tick(t: number = performance.now()) {\r\n if (process.env.NODE_ENV === 'development') {\r\n if (!(this instanceof Ticker)) {\r\n throw new Error(\r\n 'ticker.tick must be called while bound to the ticker. As in, \"ticker.tick(time)\" or \"requestAnimationFrame((t) => ticker.tick(t))\" for performance.',\r\n )\r\n }\r\n }\r\n\r\n this.__ticks++\r\n\r\n if (!this._dormant) {\r\n if (\r\n this._scheduledForNextTick.size === 0 &&\r\n this._scheduledForThisOrNextTick.size === 0\r\n ) {\r\n this._numberOfDormantTicks++\r\n if (this._numberOfDormantTicks >= EMPTY_TICKS_BEFORE_GOING_DORMANT) {\r\n this._goDormant()\r\n return\r\n }\r\n }\r\n }\r\n\r\n this._ticking = true\r\n this._timeAtCurrentTick = t\r\n for (const v of this._scheduledForNextTick) {\r\n this._scheduledForThisOrNextTick.add(v)\r\n }\r\n\r\n this._scheduledForNextTick.clear()\r\n this._tick(0)\r\n this._ticking = false\r\n }\r\n\r\n private _tick(iterationNumber: number): void {\r\n const time = this.time\r\n\r\n if (iterationNumber > 10) {\r\n console.warn('_tick() recursing for 10 times')\r\n }\r\n\r\n if (iterationNumber > 100) {\r\n throw new Error(`Maximum recursion limit for _tick()`)\r\n }\r\n\r\n const oldSet = this._scheduledForThisOrNextTick\r\n this._scheduledForThisOrNextTick = new Set()\r\n for (const fn of oldSet) {\r\n fn(time)\r\n }\r\n\r\n if (this._scheduledForThisOrNextTick.size > 0) {\r\n return this._tick(iterationNumber + 1)\r\n }\r\n }\r\n}\r\n", "import {pointerToPrism} from '../pointerToPrism'\r\nimport type {Pointer} from '../pointer'\r\nimport {isPointer} from '../pointer'\r\nimport Ticker from '../Ticker'\r\nimport type {Prism} from './Interface'\r\nimport {isPrism} from './Interface'\r\n\r\nexport default function* iterateOver<V>(\r\n pointerOrPrism: Prism<V> | Pointer<V>,\r\n): Generator<V, void, void> {\r\n let d\r\n if (isPointer(pointerOrPrism)) {\r\n d = pointerToPrism(pointerOrPrism) as Prism<V>\r\n } else if (isPrism(pointerOrPrism)) {\r\n d = pointerOrPrism\r\n } else {\r\n throw new Error(`Only pointers and prisms are supported`)\r\n }\r\n\r\n const ticker = new Ticker()\r\n\r\n const untap = d.onChange(ticker, (v) => {})\r\n\r\n try {\r\n while (true) {\r\n ticker.tick()\r\n\r\n yield d.getValue()\r\n }\r\n } finally {\r\n untap()\r\n }\r\n}\r\n", "import Atom from './Atom'\r\nimport {val} from './val'\r\nimport type {Pointer} from './pointer'\r\nimport {getPointerMeta} from './pointer'\r\nimport pointer from './pointer'\r\nimport type {$FixMe, $IntentionalAny} from './types'\r\nimport prism from './prism/prism'\r\nimport type {Prism} from './prism/Interface'\r\nimport type {PointerToPrismProvider} from './pointerToPrism'\r\n\r\n/**\r\n * Allows creating pointer-prisms where the pointer can be switched out.\r\n *\r\n * @remarks\r\n * This allows reacting not just to value changes at a certain pointer, but changes\r\n * to the proxied pointer too.\r\n */\r\nexport default class PointerProxy<O extends {}>\r\n implements PointerToPrismProvider\r\n{\r\n /**\r\n * @internal\r\n */\r\n readonly $$isPointerToPrismProvider = true\r\n private readonly _currentPointerBox: Atom<Pointer<O>>\r\n /**\r\n * Convenience pointer pointing to the root of this PointerProxy.\r\n *\r\n * @remarks\r\n * Allows convenient use of {@link pointerToPrism} and {@link val}.\r\n */\r\n readonly pointer: Pointer<O>\r\n\r\n constructor(currentPointer: Pointer<O>) {\r\n this._currentPointerBox = new Atom(currentPointer)\r\n this.pointer = pointer({root: this as $FixMe, path: []})\r\n }\r\n\r\n /**\r\n * Sets the underlying pointer.\r\n * @param p - The pointer to be proxied.\r\n */\r\n setPointer(p: Pointer<O>) {\r\n this._currentPointerBox.set(p)\r\n }\r\n\r\n /**\r\n * Returns a prism of the value at the provided sub-path of the proxied pointer.\r\n *\r\n * @param path - The path to create the prism at.\r\n */\r\n pointerToPrism<P>(pointer: Pointer<P>): Prism<P> {\r\n const {path} = getPointerMeta(pointer)\r\n return prism(() => {\r\n const currentPointer = this._currentPointerBox.prism.getValue()\r\n const subPointer = path.reduce(\r\n (pointerSoFar, pathItem) => (pointerSoFar as $IntentionalAny)[pathItem],\r\n currentPointer,\r\n )\r\n return val(subPointer) as P\r\n })\r\n }\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuBA,IAAI,UAAU,MAAM;AAEpB,IAAO,kBAAQ;;;ACxBf,IAAI,aAAa,OAAO,UAAU,YAAY,UAAU,OAAO,WAAW,UAAU;AAEpF,IAAO,qBAAQ;;;ACAf,IAAI,WAAW,OAAO,QAAQ,YAAY,QAAQ,KAAK,WAAW,UAAU;AAG5E,IAAI,OAAO,sBAAc,YAAY,SAAS;AAE9C,IAAO,eAAQ;;;ACLf,IAAI,UAAS,aAAK;AAElB,IAAO,iBAAQ;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AA,EAOtD,WAAW,GAAe;AACxB,SAAK,mBAAmB,IAAI;AAAA;AAAA,EAQ9B,eAAkB,UAA+B;AAC/C,UAAM,EAAC,SAAQ,eAAe;AAC9B,WAAO,cAAM,MAAM;AACjB,YAAM,iBAAiB,KAAK,mBAAmB,MAAM;AACrD,YAAM,aAAa,KAAK,OACtB,CAAC,cAAc,aAAc,aAAiC,WAC9D;AAEF,aAAO,IAAI;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { $IntentionalAny } from './types';
|
|
2
|
+
type PathToProp = Array<string | number>;
|
|
3
|
+
export type PointerMeta = {
|
|
4
|
+
root: {};
|
|
5
|
+
path: (string | number)[];
|
|
6
|
+
};
|
|
7
|
+
export type UnindexableTypesForPointer = number | string | boolean | null | void | undefined | Function;
|
|
8
|
+
export type UnindexablePointer = {
|
|
9
|
+
[K in $IntentionalAny]: Pointer<undefined>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A wrapper type for the type a `Pointer` points to.
|
|
13
|
+
*/
|
|
14
|
+
export type PointerType<O> = {
|
|
15
|
+
/**
|
|
16
|
+
* Only accessible via the type system.
|
|
17
|
+
* This is a helper for getting the underlying pointer type
|
|
18
|
+
* via the type space.
|
|
19
|
+
*/
|
|
20
|
+
$$__pointer_type: O;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The type of {@link Atom} pointers. See {@link pointer|pointer()} for an
|
|
24
|
+
* explanation of pointers.
|
|
25
|
+
*
|
|
26
|
+
* @see Atom
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The Pointer type is quite tricky because it doesn't play well with `any` and other inexact types.
|
|
30
|
+
* Here is an example that one would expect to work, but currently doesn't:
|
|
31
|
+
* ```ts
|
|
32
|
+
* declare function expectAnyPointer(pointer: Pointer<any>): void
|
|
33
|
+
*
|
|
34
|
+
* expectAnyPointer(null as Pointer<{}>) // this shows as a type error because Pointer<{}> is not assignable to Pointer<any>, even though it should
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The current solution is to just avoid using `any` with pointer-related code (or type-test it well).
|
|
38
|
+
* But if you enjoy solving typescript puzzles, consider fixing this :)
|
|
39
|
+
* Potentially, [TypeScript variance annotations in 4.7+](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#optional-variance-annotations-for-type-parameters)
|
|
40
|
+
* might be able to help us.
|
|
41
|
+
*/
|
|
42
|
+
export type Pointer<O> = PointerType<O> & PointerInner<Exclude<O, undefined>, undefined extends O ? undefined : never>;
|
|
43
|
+
type PointerInner<O, Optional> = O extends UnindexableTypesForPointer ? UnindexablePointer : unknown extends O ? UnindexablePointer : O extends (infer T)[] ? Pointer<T>[] : O extends {} ? {
|
|
44
|
+
[K in keyof O]-?: Pointer<O[K] | Optional>;
|
|
45
|
+
} : UnindexablePointer;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the metadata associated with the pointer. Usually the root object and
|
|
48
|
+
* the path.
|
|
49
|
+
*
|
|
50
|
+
* @param p - The pointer.
|
|
51
|
+
*/
|
|
52
|
+
export declare const getPointerMeta: <_>(p: PointerType<_>) => PointerMeta;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the root object and the path of the pointer.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const {root, path} = getPointerParts(pointer)
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param p - The pointer.
|
|
62
|
+
*
|
|
63
|
+
* @returns An object with two properties: `root`-the root object or the pointer, and `path`-the path of the pointer. `path` is an array of the property-chain.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getPointerParts: <_>(p: Pointer<_>) => {
|
|
66
|
+
root: {};
|
|
67
|
+
path: PathToProp;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Creates a pointer to a (nested) property of an {@link Atom}.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Pointers are used to make prisms of properties or nested properties of
|
|
74
|
+
* {@link Atom|Atoms}.
|
|
75
|
+
*
|
|
76
|
+
* Pointers also allow easy construction of new pointers pointing to nested members
|
|
77
|
+
* of the root object, by simply using property chaining. E.g. `somePointer.a.b` will
|
|
78
|
+
* create a new pointer that has `'a'` and `'b'` added to the path of `somePointer`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* // Here, sum is a prism that updates whenever the a or b prop of someAtom does.
|
|
83
|
+
* const sum = prism(() => {
|
|
84
|
+
* return val(pointer({root: someAtom, path: ['a']})) + val(pointer({root: someAtom, path: ['b']}));
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Note, atoms have a convenience Atom.pointer property that points to the root,
|
|
88
|
+
* // which you would normally use in this situation.
|
|
89
|
+
* const sum = prism(() => {
|
|
90
|
+
* return val(someAtom.pointer.a) + val(someAtom.pointer.b);
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param args - The pointer parameters.
|
|
95
|
+
*
|
|
96
|
+
* @typeParam O - The type of the value being pointed to.
|
|
97
|
+
*/
|
|
98
|
+
declare function pointer<O>(args: {
|
|
99
|
+
root: {};
|
|
100
|
+
path?: Array<string | number>;
|
|
101
|
+
}): Pointer<O>;
|
|
102
|
+
export default pointer;
|
|
103
|
+
/**
|
|
104
|
+
* Returns whether `p` is a pointer.
|
|
105
|
+
*/
|
|
106
|
+
export declare const isPointer: (p: $IntentionalAny) => p is Pointer<unknown>;
|
|
107
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../src/pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAE5C,KAAK,UAAU,GAAG,KAAK,CAAC,MA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;;;;;;;;;GA4BG;AACH,iBAAS,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE;IAAC,IAAI,EAAE,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;CAAC,cAQlE;AAED,eAAe,OAAO,CAAA;AAEtB;;GAEG;AACH,eAAO,MAAM,SAAS,MAAO,eAAe,0BAE3C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.typeTest.d.ts","sourceRoot":"","sources":["../src/pointer.typeTest.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Prism } from './prism/Interface';
|
|
2
|
+
import type { Pointer, PointerType } from './pointer';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for objects that can provide a prism at a certain path.
|
|
5
|
+
*/
|
|
6
|
+
export interface PointerToPrismProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a prism of the value at the provided pointer.
|
|
9
|
+
*/
|
|
10
|
+
pointerToPrism<P>(pointer: Pointer<P>): Prism<P>;
|
|
11
|
+
}
|
|
12
|
+
export declare function isPointerToPrismProvider(val: unknown): val is PointerToPrismProvider;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a prism of the value at the provided pointer. Prisms are
|
|
15
|
+
* cached per pointer.
|
|
16
|
+
*
|
|
17
|
+
* @param pointer - The pointer to return the prism at.
|
|
18
|
+
*/
|
|
19
|
+
export declare const pointerToPrism: <P extends PointerType<any>>(pointer: P) => Prism<P extends PointerType<infer T> ? T : void>;
|
|
20
|
+
//# sourceMappingURL=pointerToPrism.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerToPrism.d.ts","sourceRoot":"","sources":["../src/pointerToPrism.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,WAAW,CAAA;AAMnD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IAOrC;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;CACjD;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,sBAAsB,CAM/B;AAED;;;;;GAKG;AAEH,eAAO,MAAM,cAAc,8FAiB1B,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type Ticker from '../Ticker';
|
|
2
|
+
import type { VoidFn } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Common interface for prisms.
|
|
5
|
+
*/
|
|
6
|
+
export interface Prism<V> {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the object is a prism.
|
|
9
|
+
*/
|
|
10
|
+
isPrism: true;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the prism is hot.
|
|
13
|
+
*/
|
|
14
|
+
isHot: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Calls `listener` with a fresh value every time the prism _has_ a new value, throttled by Ticker.
|
|
17
|
+
*/
|
|
18
|
+
onChange(ticker: Ticker, listener: (v: V) => void, immediate?: boolean): VoidFn;
|
|
19
|
+
onStale(cb: () => void): VoidFn;
|
|
20
|
+
/**
|
|
21
|
+
* Keep the prism hot, even if there are no tappers (subscribers).
|
|
22
|
+
*/
|
|
23
|
+
keepHot(): VoidFn;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the current value of the prism. If the value is stale, it causes the prism to freshen.
|
|
26
|
+
*/
|
|
27
|
+
getValue(): V;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether `d` is a prism.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isPrism(d: any): d is Prism<unknown>;
|
|
33
|
+
//# sourceMappingURL=Interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../src/prism/Interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAkB,MAAM,EAAC,MAAM,UAAU,CAAA;AAIrD;;GAEG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB;;OAEG;IACH,OAAO,EAAE,IAAI,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;IAEd;;OAEG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EACxB,SAAS,CAAC,EAAE,OAAO,GAClB,MAAM,CAAA;IAET,OAAO,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,CAAA;IAE/B;;OAEG;IACH,OAAO,IAAI,MAAM,CAAA;IAuBjB;;OAEG;IACH,QAAQ,IAAI,CAAC,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAEnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=asyncIterateOver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncIterateOver.d.ts","sourceRoot":"","sources":["../../src/prism/asyncIterateOver.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { $IntentionalAny } from '../types';
|
|
2
|
+
import type { Prism } from './Interface';
|
|
3
|
+
export declare const startIgnoringDependencies: () => void, stopIgnoringDependencies: () => void, reportResolutionEnd: (_d: Prism<$IntentionalAny>) => void, reportResolutionStart: (d: Prism<$IntentionalAny>) => void, pushCollector: (collector: (d: Prism<$IntentionalAny>) => void) => void, popCollector: (collector: (d: Prism<$IntentionalAny>) => void) => void;
|
|
4
|
+
//# sourceMappingURL=discoveryMechanism.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoveryMechanism.d.ts","sourceRoot":"","sources":["../../src/prism/discoveryMechanism.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAE7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAyFtC,eAAO,MACL,yBAAyB,cACzB,wBAAwB,cACxB,mBAAmB,OA/Cc,MAAM,eAAe,CAAC,WAgDvD,qBAAqB,MAzDa,MAAM,eAAe,CAAC,WA0DxD,aAAa,kBAtFQ,MAAM,eAAe,CAAC,KAAK,IAAI,KAEN,IAAI,EAqFlD,YAAY,kBAvFS,MAAM,eAAe,CAAC,KAAK,IAAI,KAMP,IAkFvB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Pointer } from '../pointer';
|
|
2
|
+
import type { Prism } from './Interface';
|
|
3
|
+
export default function iterateAndCountTicks<V>(pointerOrPrism: Prism<V> | Pointer<V>): Generator<{
|
|
4
|
+
value: V;
|
|
5
|
+
ticks: number;
|
|
6
|
+
}, void, void>;
|
|
7
|
+
//# sourceMappingURL=iterateAndCountTicks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterateAndCountTicks.d.ts","sourceRoot":"","sources":["../../src/prism/iterateAndCountTicks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,YAAY,CAAA;AAEvC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAGtC,MAAM,CAAC,OAAO,UAAW,oBAAoB,CAAC,CAAC,EAC7C,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACpC,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAwBlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterateOver.d.ts","sourceRoot":"","sources":["../../src/prism/iterateOver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,YAAY,CAAA;AAGvC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAGtC,MAAM,CAAC,OAAO,UAAW,WAAW,CAAC,CAAC,EACpC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACpC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAuB1B"}
|