{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["// symbols\nconst TRACK_MEMO_SYMBOL = Symbol();\nconst GET_ORIGINAL_SYMBOL = Symbol();\n\n// properties\nconst AFFECTED_PROPERTY = 'a';\nconst IS_TARGET_COPIED_PROPERTY = 'f';\nconst PROXY_PROPERTY = 'p';\nconst PROXY_CACHE_PROPERTY = 'c';\nconst TARGET_CACHE_PROPERTY = 't';\nconst NEXT_OBJECT_PROPERTY = 'n';\nconst CHANGED_PROPERTY = 'g';\nconst HAS_KEY_PROPERTY = 'h';\nconst ALL_OWN_KEYS_PROPERTY = 'w';\nconst HAS_OWN_KEY_PROPERTY = 'o';\nconst KEYS_PROPERTY = 'k';\n\n// function to create a new bare proxy\nlet newProxy = (\n target: T,\n handler: ProxyHandler,\n) => new Proxy(target, handler);\n\n// get object prototype\nconst getProto = Object.getPrototypeOf;\n\nconst objectsToTrack = new WeakMap();\n\n// check if obj is a plain object or an array\nconst isObjectToTrack = (obj: T): obj is T extends object ? T : never => (\n obj && (objectsToTrack.has(obj as unknown as object)\n ? objectsToTrack.get(obj as unknown as object) as boolean\n : (getProto(obj) === Object.prototype || getProto(obj) === Array.prototype)\n )\n);\n\n// check if it is object\nconst isObject = (x: unknown): x is object => (\n typeof x === 'object' && x !== null\n);\n\n// Properties that are both non-configurable and non-writable will break\n// the proxy get trap when we try to return a recursive/child compare proxy\n// from them. We can avoid this by making a copy of the target object with\n// all descriptors marked as configurable, see `copyTargetObject`.\n// See: https://github.com/dai-shi/proxy-compare/pull/8\nconst needsToCopyTargetObject = (obj: object) => (\n Object.values(Object.getOwnPropertyDescriptors(obj)).some(\n (descriptor) => !descriptor.configurable && !descriptor.writable,\n )\n);\n\n// Make a copy with all descriptors marked as configurable.\nconst copyTargetObject = (obj: T): T => {\n if (Array.isArray(obj)) {\n // Arrays need a special way to copy\n return Array.from(obj) as T;\n }\n // For non-array objects, we create a new object keeping the prototype\n // with changing all configurable options (otherwise, proxies will complain)\n const descriptors = Object.getOwnPropertyDescriptors(obj);\n Object.values(descriptors).forEach((desc) => { desc.configurable = true; });\n return Object.create(getProto(obj), descriptors);\n};\n\ntype HasKeySet = Set\ntype HasOwnKeySet = Set\ntype KeysSet = Set\ntype Used = {\n [HAS_KEY_PROPERTY]?: HasKeySet;\n [ALL_OWN_KEYS_PROPERTY]?: true;\n [HAS_OWN_KEY_PROPERTY]?: HasOwnKeySet;\n [KEYS_PROPERTY]?: KeysSet;\n};\ntype Affected = WeakMap;\ntype ProxyHandlerState = {\n readonly [IS_TARGET_COPIED_PROPERTY]: boolean;\n [PROXY_PROPERTY]?: T;\n [PROXY_CACHE_PROPERTY]?: ProxyCache | undefined;\n [TARGET_CACHE_PROPERTY]?: TargetCache | undefined;\n [AFFECTED_PROPERTY]?: Affected;\n}\ntype ProxyCache = WeakMap<\n object,\n readonly [ProxyHandler, ProxyHandlerState]\n>;\ntype TargetCache = WeakMap<\n object,\n readonly [target: T, copiedTarget?: T]\n>;\n\nconst createProxyHandler = (origObj: T, isTargetCopied: boolean) => {\n const state: ProxyHandlerState = {\n [IS_TARGET_COPIED_PROPERTY]: isTargetCopied,\n };\n let trackObject = false; // for trackMemo\n const recordUsage = (\n type:\n | typeof HAS_KEY_PROPERTY\n | typeof ALL_OWN_KEYS_PROPERTY\n | typeof HAS_OWN_KEY_PROPERTY\n | typeof KEYS_PROPERTY,\n key?: string | symbol,\n ) => {\n if (!trackObject) {\n let used = (state[AFFECTED_PROPERTY] as Affected).get(origObj);\n if (!used) {\n used = {};\n (state[AFFECTED_PROPERTY] as Affected).set(origObj, used);\n }\n if (type === ALL_OWN_KEYS_PROPERTY) {\n used[ALL_OWN_KEYS_PROPERTY] = true;\n } else {\n let set = used[type];\n if (!set) {\n set = new Set();\n used[type] = set;\n }\n set.add(key as string | symbol);\n }\n }\n };\n const recordObjectAsUsed = () => {\n trackObject = true;\n (state[AFFECTED_PROPERTY] as Affected).delete(origObj);\n };\n const handler: ProxyHandler = {\n get(target, key) {\n if (key === GET_ORIGINAL_SYMBOL) {\n return origObj;\n }\n recordUsage(KEYS_PROPERTY, key);\n return createProxy(\n Reflect.get(target, key),\n (state[AFFECTED_PROPERTY] as Affected),\n state[PROXY_CACHE_PROPERTY],\n state[TARGET_CACHE_PROPERTY],\n );\n },\n has(target, key) {\n if (key === TRACK_MEMO_SYMBOL) {\n recordObjectAsUsed();\n return true;\n }\n recordUsage(HAS_KEY_PROPERTY, key);\n return Reflect.has(target, key);\n },\n getOwnPropertyDescriptor(target, key) {\n recordUsage(HAS_OWN_KEY_PROPERTY, key);\n return Reflect.getOwnPropertyDescriptor(target, key);\n },\n ownKeys(target) {\n recordUsage(ALL_OWN_KEYS_PROPERTY);\n return Reflect.ownKeys(target);\n },\n };\n if (isTargetCopied) {\n handler.set = handler.deleteProperty = () => false;\n }\n return [handler, state] as const;\n};\n\nconst getOriginalObject = (obj: T) => (\n // unwrap proxy\n (obj as { [GET_ORIGINAL_SYMBOL]?: typeof obj })[GET_ORIGINAL_SYMBOL]\n // otherwise\n || obj\n);\n\n/**\n * Create a proxy.\n *\n * This function will create a proxy at top level and proxy nested objects as you access them,\n * in order to keep track of which properties were accessed via get/has proxy handlers:\n *\n * NOTE: Printing of WeakMap is hard to inspect and not very readable\n * for this purpose you can use the `affectedToPathList` helper.\n *\n * @param {object} obj - Object that will be wrapped on the proxy.\n * @param {WeakMap} affected -\n * WeakMap that will hold the tracking of which properties in the proxied object were accessed.\n * @param {WeakMap} [proxyCache] -\n * WeakMap that will help keep referential identity for proxies.\n * @returns {Proxy} - Object wrapped in a proxy.\n *\n * @example\n * import { createProxy } from 'proxy-compare';\n *\n * const original = { a: \"1\", c: \"2\", d: { e: \"3\" } };\n * const affected = new WeakMap();\n * const proxy = createProxy(original, affected);\n *\n * proxy.a // Will mark as used and track its value.\n * // This will update the affected WeakMap with original as key\n * // and a Set with \"a\"\n *\n * proxy.d // Will mark \"d\" as accessed to track and proxy itself ({ e: \"3\" }).\n * // This will update the affected WeakMap with original as key\n * // and a Set with \"d\"\n */\nexport const createProxy = (\n obj: T,\n affected: WeakMap,\n proxyCache?: WeakMap,\n targetCache?: WeakMap,\n): T => {\n if (!isObjectToTrack(obj)) return obj;\n let targetAndCopied = (\n targetCache && (targetCache as TargetCache).get(obj)\n );\n if (!targetAndCopied) {\n const target = getOriginalObject(obj);\n if (needsToCopyTargetObject(target)) {\n targetAndCopied = [target, copyTargetObject(target)];\n } else {\n targetAndCopied = [target];\n }\n targetCache?.set(obj, targetAndCopied);\n }\n const [target, copiedTarget] = targetAndCopied;\n let handlerAndState = (\n proxyCache && (proxyCache as ProxyCache).get(target)\n );\n if (\n !handlerAndState\n || handlerAndState[1][IS_TARGET_COPIED_PROPERTY] !== !!copiedTarget\n ) {\n handlerAndState = createProxyHandler(target, !!copiedTarget);\n handlerAndState[1][PROXY_PROPERTY] = newProxy(\n copiedTarget || target,\n handlerAndState[0],\n );\n if (proxyCache) {\n proxyCache.set(target, handlerAndState);\n }\n }\n handlerAndState[1][AFFECTED_PROPERTY] = affected as Affected;\n handlerAndState[1][PROXY_CACHE_PROPERTY] = proxyCache as ProxyCache | undefined;\n handlerAndState[1][TARGET_CACHE_PROPERTY] = targetCache as TargetCache | undefined;\n return handlerAndState[1][PROXY_PROPERTY] as typeof target;\n};\n\nconst isAllOwnKeysChanged = (prevObj: object, nextObj: object) => {\n const prevKeys = Reflect.ownKeys(prevObj);\n const nextKeys = Reflect.ownKeys(nextObj);\n return prevKeys.length !== nextKeys.length\n || prevKeys.some((k, i) => k !== nextKeys[i]);\n};\n\ntype ChangedCache = WeakMap;\n\n/**\n * Compare changes on objects.\n *\n * This will compare the affected properties on tracked objects inside the proxy\n * to check if there were any changes made to it,\n * by default if no property was accessed on the proxy it will attempt to do a\n * reference equality check for the objects provided (Object.is(a, b)). If you access a property\n * on the proxy, then isChanged will only compare the affected properties.\n *\n * @param {object} prevObj - The previous object to compare.\n * @param {object} nextObj - Object to compare with the previous one.\n * @param {WeakMap} affected -\n * WeakMap that holds the tracking of which properties in the proxied object were accessed.\n * @param {WeakMap} [cache] -\n * WeakMap that holds a cache of the comparisons for better performance with repetitive comparisons,\n * and to avoid infinite loop with circular structures.\n * @returns {boolean} - Boolean indicating if the affected property on the object has changed.\n *\n * @example\n * import { createProxy, isChanged } from 'proxy-compare';\n *\n * const obj = { a: \"1\", c: \"2\", d: { e: \"3\" } };\n * const affected = new WeakMap();\n *\n * const proxy = createProxy(obj, affected);\n *\n * proxy.a\n *\n * isChanged(obj, { a: \"1\" }, affected) // false\n *\n * proxy.a = \"2\"\n *\n * isChanged(obj, { a: \"1\" }, affected) // true\n */\n\nexport const isChanged = (\n prevObj: unknown,\n nextObj: unknown,\n affected: WeakMap,\n cache?: WeakMap,\n): boolean => {\n if (Object.is(prevObj, nextObj)) {\n return false;\n }\n if (!isObject(prevObj) || !isObject(nextObj)) return true;\n const used = (affected as Affected).get(getOriginalObject(prevObj));\n if (!used) return true;\n if (cache) {\n const hit = (cache as ChangedCache).get(prevObj);\n if (hit && hit[NEXT_OBJECT_PROPERTY] === nextObj) {\n return hit[CHANGED_PROPERTY];\n }\n // for object with cycles\n (cache as ChangedCache).set(prevObj, {\n [NEXT_OBJECT_PROPERTY]: nextObj,\n [CHANGED_PROPERTY]: false,\n });\n }\n let changed: boolean | null = null;\n try {\n for (const key of used[HAS_KEY_PROPERTY] || []) {\n changed = Reflect.has(prevObj, key) !== Reflect.has(nextObj, key);\n if (changed) return changed;\n }\n if (used[ALL_OWN_KEYS_PROPERTY] === true) {\n changed = isAllOwnKeysChanged(prevObj, nextObj);\n if (changed) return changed;\n } else {\n for (const key of used[HAS_OWN_KEY_PROPERTY] || []) {\n const hasPrev = !!Reflect.getOwnPropertyDescriptor(prevObj, key);\n const hasNext = !!Reflect.getOwnPropertyDescriptor(nextObj, key);\n changed = hasPrev !== hasNext;\n if (changed) return changed;\n }\n }\n for (const key of used[KEYS_PROPERTY] || []) {\n changed = isChanged(\n (prevObj as any)[key],\n (nextObj as any)[key],\n affected,\n cache,\n );\n if (changed) return changed;\n }\n if (changed === null) changed = true;\n return changed;\n } finally {\n if (cache) {\n cache.set(prevObj, {\n [NEXT_OBJECT_PROPERTY]: nextObj,\n [CHANGED_PROPERTY]: changed,\n });\n }\n }\n};\n\n// explicitly track object with memo\nexport const trackMemo = (obj: unknown) => {\n if (isObjectToTrack(obj)) {\n return TRACK_MEMO_SYMBOL in obj;\n }\n return false;\n};\n\n/**\n * Unwrap proxy to get the original object.\n *\n * Used to retrieve the original object used to create the proxy instance with `createProxy`.\n *\n * @param {Proxy} obj - The proxy wrapper of the originial object.\n * @returns {object | null} - Return either the unwrapped object if exists.\n *\n * @example\n * import { createProxy, getUntracked } from 'proxy-compare';\n *\n * const original = { a: \"1\", c: \"2\", d: { e: \"3\" } };\n * const affected = new WeakMap();\n *\n * const proxy = createProxy(original, affected);\n * const originalFromProxy = getUntracked(proxy)\n *\n * Object.is(original, originalFromProxy) // true\n * isChanged(original, originalFromProxy, affected) // false\n */\nexport const getUntracked = (obj: T): T | null => {\n if (isObjectToTrack(obj)) {\n return (obj as { [GET_ORIGINAL_SYMBOL]?: T })[GET_ORIGINAL_SYMBOL] || null;\n }\n return null;\n};\n\n/**\n * Mark object to be tracked.\n *\n * This function marks an object that will be passed into `createProxy`\n * as marked to track or not. By default only Array and Object are marked to track,\n * so this is useful for example to mark a class instance to track or to mark a object\n * to be untracked when creating your proxy.\n *\n * @param obj - Object to mark as tracked or not.\n * @param mark - Boolean indicating whether you want to track this object or not.\n * @returns - No return.\n *\n * @example\n * import { createProxy, markToTrack, isChanged } from 'proxy-compare';\n *\n * const nested = { e: \"3\" }\n *\n * markToTrack(nested, false)\n *\n * const original = { a: \"1\", c: \"2\", d: nested };\n * const affected = new WeakMap();\n *\n * const proxy = createProxy(original, affected);\n *\n * proxy.d.e\n *\n * isChanged(original, { d: { e: \"3\" } }, affected) // true\n */\nexport const markToTrack = (obj: object, mark = true) => {\n objectsToTrack.set(obj, mark);\n};\n\n/**\n * Convert `affected` to path list\n *\n * `affected` is a weak map which is not printable.\n * This function is can convert it to printable path list.\n * It's for debugging purpose.\n *\n * @param obj - An object that is used with `createProxy`.\n * @param affected - A weak map that is used with `createProxy`.\n * @param onlyWithValues - An optional boolean to exclude object getters.\n * @returns - An array of paths.\n */\nexport const affectedToPathList = (\n obj: unknown,\n affected: WeakMap,\n onlyWithValues?: boolean,\n) => {\n const list: (string | symbol)[][] = [];\n const seen = new WeakSet();\n const walk = (x: unknown, path?: (string | symbol)[]) => {\n if (seen.has(x as object)) {\n // for object with cycles\n return;\n }\n if (isObject(x)) {\n seen.add(x);\n }\n const used = isObject(x) && (affected as Affected).get(getOriginalObject(x));\n if (used) {\n used[HAS_KEY_PROPERTY]?.forEach((key) => {\n const segment = `:has(${String(key)})`;\n list.push(path ? [...path, segment] : [segment]);\n });\n if (used[ALL_OWN_KEYS_PROPERTY] === true) {\n const segment = ':ownKeys';\n list.push(path ? [...path, segment] : [segment]);\n } else {\n used[HAS_OWN_KEY_PROPERTY]?.forEach((key) => {\n const segment = `:hasOwn(${String(key)})`;\n list.push(path ? [...path, segment] : [segment]);\n });\n }\n used[KEYS_PROPERTY]?.forEach((key) => {\n if (!onlyWithValues || 'value' in (Object.getOwnPropertyDescriptor(x, key) || {})) {\n walk((x as any)[key], path ? [...path, key] : [key]);\n }\n });\n } else if (path) {\n list.push(path);\n }\n };\n walk(obj);\n return list;\n};\n\n/**\n * replace newProxy function.\n *\n * This can be used if you want to use proxy-polyfill.\n * Note that proxy-polyfill can't polyfill everything.\n * Use it at your own risk.\n */\nexport const replaceNewProxy = (fn: typeof newProxy) => {\n newProxy = fn;\n};\n"],"names":["TRACK_MEMO_SYMBOL","Symbol","GET_ORIGINAL_SYMBOL","AFFECTED_PROPERTY","ALL_OWN_KEYS_PROPERTY","newProxy","target","handler","Proxy","getProto","Object","getPrototypeOf","objectsToTrack","WeakMap","isObjectToTrack","obj","has","get","prototype","Array","isObject","x","copyTargetObject","isArray","from","descriptors","getOwnPropertyDescriptors","values","forEach","desc","configurable","create","getOriginalObject","createProxy","affected","proxyCache","targetCache","targetAndCopied","some","descriptor","writable","needsToCopyTargetObject","set","origObj","isTargetCopied","_state","state","trackObject","recordUsage","copiedTarget","handlerAndState","type","key","used","Set","add","Reflect","getOwnPropertyDescriptor","ownKeys","deleteProperty","onlyWithValues","list","seen","WeakSet","walk","path","_used$HAS_KEY_PROPERT","_used$KEYS_PROPERTY","segment","String","push","concat","_used$HAS_OWN_KEY_PRO","isChanged","prevObj","nextObj","cache","is","_cache$set","hit","changed","_step","_iterator","_createForOfIteratorHelperLoose","done","value","prevKeys","nextKeys","length","k","i","isAllOwnKeysChanged","_iterator2","_step2","_step3","_iterator3","_cache$set2","mark","fn"],"mappings":"4hCACA,IAAMA,EAAoBC,SACpBC,EAAsBD,SAGtBE,EAAoB,IAQpBC,EAAwB,IAK1BC,EAAW,SACbC,EACAC,GAAwB,OACjB,IAAAC,MAAMF,EAAQC,EAAQ,EAGzBE,EAAWC,OAAOC,eAElBC,EAAiB,IAAIC,QAGrBC,EAAkB,SAAIC,GAC1B,OAAAA,IAAQH,EAAeI,IAAID,GACvBH,EAAeK,IAAIF,GAClBN,EAASM,KAASL,OAAOQ,WAAaT,EAASM,KAASI,MAAMD,UAClE,EAIGE,EAAW,SAACC,GAChB,MAAa,iBAANA,GAAwB,OAANA,CAAU,EAe/BC,EAAmB,SAAmBP,GAC1C,GAAII,MAAMI,QAAQR,GAEhB,OAAOI,MAAMK,KAAKT,GAIpB,IAAMU,EAAcf,OAAOgB,0BAA0BX,GAErD,OADAL,OAAOiB,OAAOF,GAAaG,QAAQ,SAACC,GAAWA,EAAKC,cAAe,CAAM,GAClEpB,OAAOqB,OAAOtB,EAASM,GAAMU,EACtC,EAmGMO,EAAoB,SAAmBjB,GAE1C,OAAAA,EAA+Cb,IAE7Ca,CAAG,EAkCKkB,EAAc,SACzBlB,EACAmB,EACAC,EACAC,GAEA,IAAKtB,EAAgBC,GAAM,OAAOA,EAClC,IAAIsB,E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