@politie/sherlock-proxy 3.3.7 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@politie/sherlock-proxy",
3
- "version": "3.3.7",
3
+ "version": "3.4.0",
4
4
  "description": "A proxy extension to Sherlock.",
5
5
  "main": "sherlock-proxy.cjs.js",
6
6
  "module": "sherlock-proxy.esm.js",
@@ -38,6 +38,6 @@
38
38
  "tslib": "^2.2.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@politie/sherlock": "3.3.7"
41
+ "@politie/sherlock": "3.4.0"
42
42
  }
43
43
  }
package/proxy.d.ts CHANGED
@@ -105,7 +105,7 @@ export declare class ProxyDescriptor<V = any, T = V> {
105
105
  * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to
106
106
  * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.
107
107
  */
108
- $pluckableKeys(): (string | number | symbol)[];
108
+ $pluckableKeys(): (string | symbol)[];
109
109
  /**
110
110
  * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration
111
111
  * {@link #pluck} is called with indices up to but not including the result of `$length()`.
@@ -51,7 +51,7 @@ var ProxyDescriptor = /** @class */ (function () {
51
51
  }
52
52
  catch (e) {
53
53
  // istanbul ignore next: for debug purposes
54
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
54
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
55
55
  }
56
56
  },
57
57
  set: function (newValue) {
@@ -65,7 +65,7 @@ var ProxyDescriptor = /** @class */ (function () {
65
65
  atom.set(newValue);
66
66
  }
67
67
  catch (e) {
68
- throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
68
+ throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
69
69
  }
70
70
  },
71
71
  enumerable: false,
@@ -82,7 +82,7 @@ var ProxyDescriptor = /** @class */ (function () {
82
82
  }
83
83
  catch (e) {
84
84
  // istanbul ignore next: for debug purposes
85
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
85
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
86
86
  }
87
87
  },
88
88
  set: function (newValue) {
@@ -96,7 +96,7 @@ var ProxyDescriptor = /** @class */ (function () {
96
96
  atom.set(newValue);
97
97
  }
98
98
  catch (e) {
99
- throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
99
+ throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
100
100
  }
101
101
  },
102
102
  enumerable: false,
@@ -1 +1 @@
1
- {"version":3,"file":"sherlock-proxy.cjs.js","sources":["../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":["isSettableDerivable","utils","lens","isDerivable"],"mappings":";;;;;;;AAyCA,IAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;;SAKgB,gBAAgB,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;IAUA;QAwBY,gBAAW,GAAkB,SAAS,CAAC;KAmKlD;IAvKG,sBAAI,uCAAU;;;;aAAd;YACI,IAAM,EAAE,GAAG,IAAI,CA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AU,EAAE,IAAI;aACnB,CAAC;SACL;QACD,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,YAAC,MAAM;QACV,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;KAClC;CACJ,CAAC;AAEF,SAAS,mBAAmB,CAAC,MAAuB,EAAE,IAAiB;IACnE,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjH,CAAC;AAED;;;;;;;SAOgB,gBAAgB,CAAC,UAAe,EAAE,QAAyB;IAA1C,2BAAA,EAAA,eAAe;IAC5C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtE,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,CAAC;KACtC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,OAAO,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;KAC3F;IACD,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,UAAU,CAAC,IAAiC,EAAE,QAAyB;IAA5D,qBAAA,EAAA,SAAiC;IACxD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC;;;;;;;;"}
1
+ {"version":3,"file":"sherlock-proxy.cjs.js","sources":["../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":["_internal","isSettableDerivable","utils","lens","isDerivable"],"mappings":";;;;;;;AAyCA,IAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;;SAKgB,gBAAgB,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;IAUA;QAwBY,gBAAW,GAAkB,SAAS,CAAC;KAsKlD;IA1KG,sBAAI,uCAAU;;;;aAAd;YACI,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,OAAO,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC,WAAW,GAAG,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACnG;;;OAAA;IAOD,sBAAI,mCAAM;;;;;aAAV;YACI,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,IAAI;gBACA,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;;gBAER,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0BAAuB,EAAE,CAAC,WAAW,IAAI,QAAQ,YAAKA,kBAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;aAC/I;SACJ;aACD,UAAW,QAAQ;YACf,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,IAAM,IAAI,GAAG,EAAE,CAAC,UAAU,CAAC;YAC3B,IAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC;YAClC,IAAI,CAACC,4BAAmB,CAAC,IAAI,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G,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;KAC3F;IACD,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,UAAU,CAAC,IAAiC,EAAE,QAAyB;IAA5D,qBAAA,EAAA,SAAiC;IACxD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("@politie/sherlock"),e=Symbol("isDerivableProxy");function n(r){return!0===r[e]}var i=function(){function e(){this.$$derivable=void 0}return Object.defineProperty(e.prototype,"$derivable",{get:function(){var r=this.$proxyDescriptor;return r.$$derivable||(r.$$derivable=function(r,e){if(!e)return r;var n=e.get,i=e.set;return i&&t.isSettableDerivable(r)?t.lens({get:n,set:function(t,e){r.set(i.call(this,t,e))}},r).autoCache():r.derive(n).autoCache()}(r.$target,r.$lens&&r.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$value",{get:function(){var r=this.$proxyDescriptor;try{return r.$derivable.get()}catch(t){throw Object.assign(Error("error while getting "+(r.$expression||"$value")+": "+(t&&t.message)),{jse_cause:t})}},set:function(r){var e=this.$proxyDescriptor,n=e.$derivable,i=e.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$value")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$value")+": "+(r&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$targetValue",{get:function(){var r=this.$proxyDescriptor;try{return r.$target.get()}catch(t){throw Object.assign(Error("error while getting "+(r.$expression||"$targetValue")+": "+(t&&t.message)),{jse_cause:t})}},set:function(r){var e=this.$proxyDescriptor,n=e.$target,i=e.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$targetValue")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$targetValue")+": "+(r&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),e.prototype.$create=function(r,e,n){var i=t.utils.clone(this.$proxyDescriptor);return i.$target=r,Object.getOwnPropertyNames(i).filter((function(r){return r.startsWith("$$")})).forEach((function(r){return i[r]=void 0})),i.$expression=e,i.$path=n,new Proxy(i,o)},e.prototype.$pluck=function(r){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(r),s(t.$expression,r),a(t.$path,r))},e.prototype.$pluckableKeys=function(){var r=this.$proxyDescriptor.$value;return"object"==typeof r?Reflect.ownKeys(r):[]},e.prototype.$length=function(){var r=this.$proxyDescriptor.$targetValue;return Array.isArray(r)?r.length:void 0},e.prototype.$and=function(r){return this.$proxyDescriptor.$derivable.and(u(r))},e.prototype.$or=function(r){return this.$proxyDescriptor.$derivable.or(u(r))},e.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},e.prototype.$is=function(r){return this.$proxyDescriptor.$derivable.is(u(r))},e.prototype.$derive=function(){var r=this.$proxyDescriptor.$derivable;return r.derive.apply(r,arguments)},e.prototype.$react=function(r,t){return this.$proxyDescriptor.$derivable.react(r,t)},e.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var t,e,n,i;return r.__generator(this,(function(r){switch(r.label){case 0:if(t=this.$proxyDescriptor,void 0===(e=t.$length()))throw n=t.$expression,Object.assign(Error((n||"object")+" is not iterable"),{value:t.$value,expression:n});i=0,r.label=1;case 1:return i<e?[4,t.$pluck(i)]:[3,4];case 2:r.sent(),r.label=3;case 3:return i++,[3,1];case 4:return[2]}}))},Object.defineProperty(e.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),e}();function u(r){return n(r)?r.$derivable:r}i.prototype[e]=!0;var o={get:function(r,t,e){return"$proxyDescriptor"===t?r:c(r,t)?r.$pluck.call(e,t):Reflect.get(r,t,e)},set:function(r,e,i,u){if(c(r,e)){var o=r.$pluck.call(u,e);return i&&n(i)?o.$targetValue=i.$targetValue:o.$value=i&&t.isDerivable(i)?i.get():i,!0}return Reflect.set(r,e,i,u)},has:function(r,t){return t===Symbol.iterator?void 0!==r.$length():c(r,t)},getOwnPropertyDescriptor:function(r,t){if(c(r,t))return{get:function(){return this[t]},set:function(r){this[t]=r},configurable:!0,enumerable:!0}},ownKeys:function(r){return r.$pluckableKeys()}};function c(r,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(r,t)}function s(r,t){return void 0===r&&(r=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?r+"."+t:"string"==typeof t?r+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':r+"["+t+"]"}function a(r,t){return void 0===r&&(r=[]),r.concat(t)}exports.ProxyDescriptor=i,exports.extendExpression=s,exports.extendPath=a,exports.isDerivableProxy=n,exports.unwrapProxy=u;
1
+ Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("@politie/sherlock"),e=Symbol("isDerivableProxy");function n(r){return!0===r[e]}var i=function(){function e(){this.$$derivable=void 0}return Object.defineProperty(e.prototype,"$derivable",{get:function(){var r=this.$proxyDescriptor;return r.$$derivable||(r.$$derivable=function(r,e){if(!e)return r;var n=e.get,i=e.set;return i&&t.isSettableDerivable(r)?t.lens({get:n,set:function(t,e){r.set(i.call(this,t,e))}},r).autoCache():r.derive(n).autoCache()}(r.$target,r.$lens&&r.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$value",{get:function(){var r=this.$proxyDescriptor;try{return r.$derivable.get()}catch(e){throw Object.assign(Error("error while getting "+(r.$expression||"$value")+": "+(t._internal.isError(e)&&e.message)),{jse_cause:e})}},set:function(r){var e=this.$proxyDescriptor,n=e.$derivable,i=e.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$value")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$value")+": "+(t._internal.isError(r)&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$targetValue",{get:function(){var r=this.$proxyDescriptor;try{return r.$target.get()}catch(e){throw Object.assign(Error("error while getting "+(r.$expression||"$targetValue")+": "+(t._internal.isError(e)&&e.message)),{jse_cause:e})}},set:function(r){var e=this.$proxyDescriptor,n=e.$target,i=e.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$targetValue")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$targetValue")+": "+(t._internal.isError(r)&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),e.prototype.$create=function(r,e,n){var i=t.utils.clone(this.$proxyDescriptor);return i.$target=r,Object.getOwnPropertyNames(i).filter((function(r){return r.startsWith("$$")})).forEach((function(r){return i[r]=void 0})),i.$expression=e,i.$path=n,new Proxy(i,o)},e.prototype.$pluck=function(r){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(r),s(t.$expression,r),a(t.$path,r))},e.prototype.$pluckableKeys=function(){var r=this.$proxyDescriptor.$value;return"object"==typeof r?Reflect.ownKeys(r):[]},e.prototype.$length=function(){var r=this.$proxyDescriptor.$targetValue;return Array.isArray(r)?r.length:void 0},e.prototype.$and=function(r){return this.$proxyDescriptor.$derivable.and(u(r))},e.prototype.$or=function(r){return this.$proxyDescriptor.$derivable.or(u(r))},e.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},e.prototype.$is=function(r){return this.$proxyDescriptor.$derivable.is(u(r))},e.prototype.$derive=function(){var r=this.$proxyDescriptor.$derivable;return r.derive.apply(r,arguments)},e.prototype.$react=function(r,t){return this.$proxyDescriptor.$derivable.react(r,t)},e.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var t,e,n,i;return r.__generator(this,(function(r){switch(r.label){case 0:if(t=this.$proxyDescriptor,void 0===(e=t.$length()))throw n=t.$expression,Object.assign(Error((n||"object")+" is not iterable"),{value:t.$value,expression:n});i=0,r.label=1;case 1:return i<e?[4,t.$pluck(i)]:[3,4];case 2:r.sent(),r.label=3;case 3:return i++,[3,1];case 4:return[2]}}))},Object.defineProperty(e.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),e}();function u(r){return n(r)?r.$derivable:r}i.prototype[e]=!0;var o={get:function(r,t,e){return"$proxyDescriptor"===t?r:c(r,t)?r.$pluck.call(e,t):Reflect.get(r,t,e)},set:function(r,e,i,u){if(c(r,e)){var o=r.$pluck.call(u,e);return i&&n(i)?o.$targetValue=i.$targetValue:o.$value=i&&t.isDerivable(i)?i.get():i,!0}return Reflect.set(r,e,i,u)},has:function(r,t){return t===Symbol.iterator?void 0!==r.$length():c(r,t)},getOwnPropertyDescriptor:function(r,t){if(c(r,t))return{get:function(){return this[t]},set:function(r){this[t]=r},configurable:!0,enumerable:!0}},ownKeys:function(r){return r.$pluckableKeys()}};function c(r,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(r,t)}function s(r,t){return void 0===r&&(r=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?r+"."+t:"string"==typeof t?r+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':r+"["+t+"]"}function a(r,t){return void 0===r&&(r=[]),r.concat(t)}exports.ProxyDescriptor=i,exports.extendExpression=s,exports.extendPath=a,exports.isDerivableProxy=n,exports.unwrapProxy=u;
2
2
  //# sourceMappingURL=sherlock-proxy.cjs.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","i","_a","sent","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],"mappings":"6GAyCMA,EAAqBC,OAAO,6BAOlBC,EAAiBC,GAC7B,OAAmC,IAA5BA,EAAIH,oBAaf,SAAAI,IAwBYC,KAAAC,iBAA6BC,EAmKzC,OAvKIC,OAAAC,eAAIL,EAAAM,UAAA,aAAU,KAAd,WACI,IAAMC,EAAKN,KAAKO,iBAChB,OAAOD,EAAGL,cAAgBK,EAAGL,YAwKrC,SAA+BO,EAAsBC,GACjD,IAAKA,EACD,OAAOD,EAEH,IAAAE,EAAaD,EAASC,IAAjBC,EAAQF,EAASE,IAC9B,OAAKA,GAAQC,EAAAA,oBAAoBJ,GAG1BK,EAAAA,KAAK,CACRH,IAAGA,EACHC,IAAG,SAACG,EAAUC,GACVP,EAAOG,IAAIA,EAAIK,KAAKhB,KAAMc,EAAUC,MAEzCP,GAAQS,YAPAT,EAAOU,OAAOR,GAAKO,YA9KiBE,CAAgBb,EAAGc,QAASd,EAAGe,OAASf,EAAGe,2CAQ1FlB,OAAAC,eAAIL,EAAAM,UAAA,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,UAEX8B,EAAoB3E,EAAQ8B,IAEvCiD,yBAAwB,SAAC/E,EAAQ8B,GAC7B,GAAI6C,EAAoB3E,EAAQ8B,GAC5B,MAAO,CACH5B,IAAG,WAAK,OAAOV,KAAKsC,IACpB3B,IAAG,SAACG,GAAYd,KAAKsC,GAAQxB,GAC7B0E,cAAc,EACdC,YAAY,IAKxBrC,QAAO,SAAC5C,GACJ,OAAOA,EAAOwC,mBAItB,SAASmC,EAAoB3E,EAAyB8B,GAClD,MAAuB,iBAATA,GAAqC,iBAATA,GAAiC,MAAZA,EAAK,KAAea,QAAQmC,IAAI9E,EAAQ8B,YAU3FQ,EAAiBhB,EAAiB4D,GAC9C,YAD6B,IAAA5D,IAAAA,EAAA,IACL,iBAAb4D,GAAyB,sBAAsBC,KAAKD,GACpD5D,EAAa,IAAM4D,EAEN,iBAAbA,EACA5D,EAAa,KAAO4D,EAASE,QAAQ,MAAO,QAAQA,QAAQ,MAAO,OAAS,KAEhF9D,EAAa,IAAM4D,EAAW,aASzB3C,EAAWf,EAAmC0D,GAC1D,YADuB,IAAA1D,IAAAA,EAAA,IAChBA,EAAK6D,OAAOH","file":"sherlock-proxy.cjs.min.js","sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"]}
1
+ {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","_internal","isError","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","i","_a","sent","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],"mappings":"6GAyCMA,EAAqBC,OAAO,6BAOlBC,EAAiBC,GAC7B,OAAmC,IAA5BA,EAAIH,oBAaf,SAAAI,IAwBYC,KAAAC,iBAA6BC,EAsKzC,OA1KIC,OAAAC,eAAIL,EAAAM,UAAA,aAAU,KAAd,WACI,IAAMC,EAAKN,KAAKO,iBAChB,OAAOD,EAAGL,cAAgBK,EAAGL,YA2KrC,SAA+BO,EAAsBC,GACjD,IAAKA,EACD,OAAOD,EAEH,IAAAE,EAAaD,EAASC,IAAjBC,EAAQF,EAASE,IAC9B,OAAKA,GAAQC,EAAAA,oBAAoBJ,GAG1BK,EAAAA,KAAK,CACRH,IAAGA,EACHC,IAAG,SAACG,EAAUC,GACVP,EAAOG,IAAIA,EAAIK,KAAKhB,KAAMc,EAAUC,MAEzCP,GAAQS,YAPAT,EAAOU,OAAOR,GAAKO,YAjLiBE,CAAgBb,EAAGc,QAASd,EAAGe,OAASf,EAAGe,2CAQ1FlB,OAAAC,eAAIL,EAAAM,UAAA,SAAM,KAAV,WACI,IAAMC,EAAKN,KAAKO,iBAChB,IACI,OAAOD,EAAGgB,WAAWZ,MACvB,MAAOa,GAEL,MAAMpB,OAAOqB,OAAWC,MAAM,wBAAuBnB,EAAGoB,aAAe,UAAQ,MAAKC,EAAAA,UAAUC,QAAQL,IAAMA,EAAEM,UAAY,CAAEC,UAAWP,UAG/I,SAAWT,GACP,IAAMR,EAAKN,KAAKO,iBACVwB,EAAOzB,EAAGgB,WACVU,EAAa1B,EAAGoB,YACtB,IAAKd,EAAAA,oBAAoBmB,GACrB,MAAUN,OAASO,GAAc,UAAQ,gBA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D,MAAuB,iBAATA,GAAqC,iBAATA,GAAiC,MAAZA,EAAK,KAAea,QAAQmC,IAAIhF,EAAQgC,YAU3FQ,EAAiBhB,EAAiB4D,GAC9C,YAD6B,IAAA5D,IAAAA,EAAA,IACL,iBAAb4D,GAAyB,sBAAsBC,KAAKD,GACpD5D,EAAa,IAAM4D,EAEN,iBAAbA,EACA5D,EAAa,KAAO4D,EAASE,QAAQ,MAAO,QAAQA,QAAQ,MAAO,OAAS,KAEhF9D,EAAa,IAAM4D,EAAW,aASzB3C,EAAWf,EAAmC0D,GAC1D,YADuB,IAAA1D,IAAAA,EAAA,IAChBA,EAAK6D,OAAOH","file":"sherlock-proxy.cjs.min.js","sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { __generator } from 'tslib';
2
- import { isSettableDerivable, utils, lens, isDerivable } from '@politie/sherlock';
2
+ import { _internal, isSettableDerivable, utils, lens, isDerivable } from '@politie/sherlock';
3
3
 
4
4
  var IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');
5
5
  /**
@@ -47,7 +47,7 @@ var ProxyDescriptor = /** @class */ (function () {
47
47
  }
48
48
  catch (e) {
49
49
  // istanbul ignore next: for debug purposes
50
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
50
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (_internal.isError(e) && e.message)), { jse_cause: e });
51
51
  }
52
52
  },
53
53
  set: function (newValue) {
@@ -61,7 +61,7 @@ var ProxyDescriptor = /** @class */ (function () {
61
61
  atom.set(newValue);
62
62
  }
63
63
  catch (e) {
64
- throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
64
+ throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (_internal.isError(e) && e.message)), { jse_cause: e });
65
65
  }
66
66
  },
67
67
  enumerable: false,
@@ -78,7 +78,7 @@ var ProxyDescriptor = /** @class */ (function () {
78
78
  }
79
79
  catch (e) {
80
80
  // istanbul ignore next: for debug purposes
81
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
81
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (_internal.isError(e) && e.message)), { jse_cause: e });
82
82
  }
83
83
  },
84
84
  set: function (newValue) {
@@ -92,7 +92,7 @@ var ProxyDescriptor = /** @class */ (function () {
92
92
  atom.set(newValue);
93
93
  }
94
94
  catch (e) {
95
- throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
95
+ throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (_internal.isError(e) && e.message)), { jse_cause: e });
96
96
  }
97
97
  },
98
98
  enumerable: false,
@@ -1 +1 @@
1
- {"version":3,"file":"sherlock-proxy.esm.js","sources":["../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":[],"mappings":";;;AAyCA,IAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;;SAKgB,gBAAgB,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;IAUA;QAwBY,gBAAW,GAAkB,SAAS,CAAC;KAmKlD;IAvKG,sBAAI,uCAAU;;;;aAAd;YACI,IAAM,EAAE,GAAG,IAAI,CAAC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E,IAAI;aACnB,CAAC;SACL;QACD,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,YAAC,MAAM;QACV,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;KAClC;CACJ,CAAC;AAEF,SAAS,mBAAmB,CAAC,MAAuB,EAAE,IAAiB;IACnE,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjH,CAAC;AAED;;;;;;;SAOgB,gBAAgB,CAAC,UAAe,EAAE,QAAyB;IAA1C,2BAAA,EAAA,eAAe;IAC5C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtE,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,CAAC;KACtC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,OAAO,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;KAC3F;IACD,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,UAAU,CAAC,IAAiC,EAAE,QAAyB;IAA5D,qBAAA,EAAA,SAAiC;IACxD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC;;;;"}
1
+ {"version":3,"file":"sherlock-proxy.esm.js","sources":["../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":[],"mappings":";;;AAyCA,IAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;;SAKgB,gBAAgB,CAAC,GAAQ;IACrC,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;IAUA;QAwBY,gBAAW,GAAkB,SAAS,CAAC;KAsKlD;IA1KG,sBAAI,uCAAU;;;;aAAd;YACI,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,OAAO,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC,WAAW,GAAG,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACnG;;;OAAA;IAOD,sBAAI,mCAAM;;;;;aAAV;YACI,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,IAAI;gBACA,OAAO,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;;gBAER,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0BAAuB,EAAE,CAAC,WAAW,IAAI,QAAQ,YAAK,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;aAC/I;SACJ;aACD,UAAW,QAAQ;YACf,IAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACjC,IAAM,IAAI,GAAG,EAAE,CAAC,UAAU,CAAC;YAC3B,IAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC;YAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,CAAG,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,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;KAC3F;IACD,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,UAAU,CAAC,IAAiC,EAAE,QAAyB;IAA5D,qBAAA,EAAA,SAAiC;IACxD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC;;;;"}
@@ -1,2 +1,2 @@
1
- import{__generator as r}from"tslib";import{isSettableDerivable as t,utils as e,lens as n,isDerivable as i}from"@politie/sherlock";var u=Symbol("isDerivableProxy");function o(r){return!0===r[u]}var c=function(){function i(){this.$$derivable=void 0}return Object.defineProperty(i.prototype,"$derivable",{get:function(){var r=this.$proxyDescriptor;return r.$$derivable||(r.$$derivable=function(r,e){if(!e)return r;var i=e.get,u=e.set;return u&&t(r)?n({get:i,set:function(t,e){r.set(u.call(this,t,e))}},r).autoCache():r.derive(i).autoCache()}(r.$target,r.$lens&&r.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"$value",{get:function(){var r=this.$proxyDescriptor;try{return r.$derivable.get()}catch(t){throw Object.assign(Error("error while getting "+(r.$expression||"$value")+": "+(t&&t.message)),{jse_cause:t})}},set:function(r){var e=this.$proxyDescriptor,n=e.$derivable,i=e.$expression;if(!t(n))throw Error((i||"$value")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$value")+": "+(r&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"$targetValue",{get:function(){var r=this.$proxyDescriptor;try{return r.$target.get()}catch(t){throw Object.assign(Error("error while getting "+(r.$expression||"$targetValue")+": "+(t&&t.message)),{jse_cause:t})}},set:function(r){var e=this.$proxyDescriptor,n=e.$target,i=e.$expression;if(!t(n))throw Error((i||"$targetValue")+" is readonly");try{n.set(r)}catch(r){throw Object.assign(Error("error while setting "+(i||"$targetValue")+": "+(r&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),i.prototype.$create=function(r,t,n){var i=e.clone(this.$proxyDescriptor);return i.$target=r,Object.getOwnPropertyNames(i).filter((function(r){return r.startsWith("$$")})).forEach((function(r){return i[r]=void 0})),i.$expression=t,i.$path=n,new Proxy(i,f)},i.prototype.$pluck=function(r){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(r),l(t.$expression,r),h(t.$path,r))},i.prototype.$pluckableKeys=function(){var r=this.$proxyDescriptor.$value;return"object"==typeof r?Reflect.ownKeys(r):[]},i.prototype.$length=function(){var r=this.$proxyDescriptor.$targetValue;return Array.isArray(r)?r.length:void 0},i.prototype.$and=function(r){return this.$proxyDescriptor.$derivable.and(a(r))},i.prototype.$or=function(r){return this.$proxyDescriptor.$derivable.or(a(r))},i.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},i.prototype.$is=function(r){return this.$proxyDescriptor.$derivable.is(a(r))},i.prototype.$derive=function(){var r=this.$proxyDescriptor.$derivable;return r.derive.apply(r,arguments)},i.prototype.$react=function(r,t){return this.$proxyDescriptor.$derivable.react(r,t)},i.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(i.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),i.prototype[Symbol.iterator]=function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:if(t=this.$proxyDescriptor,void 0===(e=t.$length()))throw n=t.$expression,Object.assign(Error((n||"object")+" is not iterable"),{value:t.$value,expression:n});i=0,r.label=1;case 1:return i<e?[4,t.$pluck(i)]:[3,4];case 2:r.sent(),r.label=3;case 3:return i++,[3,1];case 4:return[2]}}))},Object.defineProperty(i.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),i}();function a(r){return o(r)?r.$derivable:r}c.prototype[u]=!0;var f={get:function(r,t,e){return"$proxyDescriptor"===t?r:s(r,t)?r.$pluck.call(e,t):Reflect.get(r,t,e)},set:function(r,t,e,n){if(s(r,t)){var u=r.$pluck.call(n,t);return e&&o(e)?u.$targetValue=e.$targetValue:u.$value=e&&i(e)?e.get():e,!0}return Reflect.set(r,t,e,n)},has:function(r,t){return t===Symbol.iterator?void 0!==r.$length():s(r,t)},getOwnPropertyDescriptor:function(r,t){if(s(r,t))return{get:function(){return this[t]},set:function(r){this[t]=r},configurable:!0,enumerable:!0}},ownKeys:function(r){return r.$pluckableKeys()}};function s(r,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(r,t)}function l(r,t){return void 0===r&&(r=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?r+"."+t:"string"==typeof t?r+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':r+"["+t+"]"}function h(r,t){return void 0===r&&(r=[]),r.concat(t)}export{c as ProxyDescriptor,l as extendExpression,h as extendPath,o as isDerivableProxy,a as unwrapProxy};
1
+ import{__generator as r}from"tslib";import{_internal as t,isSettableDerivable as e,utils as n,lens as i,isDerivable as u}from"@politie/sherlock";var o=Symbol("isDerivableProxy");function c(r){return!0===r[o]}var a=function(){function u(){this.$$derivable=void 0}return Object.defineProperty(u.prototype,"$derivable",{get:function(){var r=this.$proxyDescriptor;return r.$$derivable||(r.$$derivable=function(r,t){if(!t)return r;var n=t.get,u=t.set;return u&&e(r)?i({get:n,set:function(t,e){r.set(u.call(this,t,e))}},r).autoCache():r.derive(n).autoCache()}(r.$target,r.$lens&&r.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$value",{get:function(){var r=this.$proxyDescriptor;try{return r.$derivable.get()}catch(e){throw Object.assign(Error("error while getting "+(r.$expression||"$value")+": "+(t.isError(e)&&e.message)),{jse_cause:e})}},set:function(r){var n=this.$proxyDescriptor,i=n.$derivable,u=n.$expression;if(!e(i))throw Error((u||"$value")+" is readonly");try{i.set(r)}catch(r){throw Object.assign(Error("error while setting "+(u||"$value")+": "+(t.isError(r)&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$targetValue",{get:function(){var r=this.$proxyDescriptor;try{return r.$target.get()}catch(e){throw Object.assign(Error("error while getting "+(r.$expression||"$targetValue")+": "+(t.isError(e)&&e.message)),{jse_cause:e})}},set:function(r){var n=this.$proxyDescriptor,i=n.$target,u=n.$expression;if(!e(i))throw Error((u||"$targetValue")+" is readonly");try{i.set(r)}catch(r){throw Object.assign(Error("error while setting "+(u||"$targetValue")+": "+(t.isError(r)&&r.message)),{jse_cause:r})}},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),u.prototype.$create=function(r,t,e){var i=n.clone(this.$proxyDescriptor);return i.$target=r,Object.getOwnPropertyNames(i).filter((function(r){return r.startsWith("$$")})).forEach((function(r){return i[r]=void 0})),i.$expression=t,i.$path=e,new Proxy(i,s)},u.prototype.$pluck=function(r){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(r),h(t.$expression,r),b(t.$path,r))},u.prototype.$pluckableKeys=function(){var r=this.$proxyDescriptor.$value;return"object"==typeof r?Reflect.ownKeys(r):[]},u.prototype.$length=function(){var r=this.$proxyDescriptor.$targetValue;return Array.isArray(r)?r.length:void 0},u.prototype.$and=function(r){return this.$proxyDescriptor.$derivable.and(f(r))},u.prototype.$or=function(r){return this.$proxyDescriptor.$derivable.or(f(r))},u.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},u.prototype.$is=function(r){return this.$proxyDescriptor.$derivable.is(f(r))},u.prototype.$derive=function(){var r=this.$proxyDescriptor.$derivable;return r.derive.apply(r,arguments)},u.prototype.$react=function(r,t){return this.$proxyDescriptor.$derivable.react(r,t)},u.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(u.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),u.prototype[Symbol.iterator]=function(){var t,e,n,i;return r(this,(function(r){switch(r.label){case 0:if(t=this.$proxyDescriptor,void 0===(e=t.$length()))throw n=t.$expression,Object.assign(Error((n||"object")+" is not iterable"),{value:t.$value,expression:n});i=0,r.label=1;case 1:return i<e?[4,t.$pluck(i)]:[3,4];case 2:r.sent(),r.label=3;case 3:return i++,[3,1];case 4:return[2]}}))},Object.defineProperty(u.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),u}();function f(r){return c(r)?r.$derivable:r}a.prototype[o]=!0;var s={get:function(r,t,e){return"$proxyDescriptor"===t?r:l(r,t)?r.$pluck.call(e,t):Reflect.get(r,t,e)},set:function(r,t,e,n){if(l(r,t)){var i=r.$pluck.call(n,t);return e&&c(e)?i.$targetValue=e.$targetValue:i.$value=e&&u(e)?e.get():e,!0}return Reflect.set(r,t,e,n)},has:function(r,t){return t===Symbol.iterator?void 0!==r.$length():l(r,t)},getOwnPropertyDescriptor:function(r,t){if(l(r,t))return{get:function(){return this[t]},set:function(r){this[t]=r},configurable:!0,enumerable:!0}},ownKeys:function(r){return r.$pluckableKeys()}};function l(r,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(r,t)}function h(r,t){return void 0===r&&(r=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?r+"."+t:"string"==typeof t?r+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':r+"["+t+"]"}function b(r,t){return void 0===r&&(r=[]),r.concat(t)}export{a as ProxyDescriptor,h as extendExpression,b as extendPath,c as isDerivableProxy,f as unwrapProxy};
2
2
  //# sourceMappingURL=sherlock-proxy.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","i","_a","sent","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],"mappings":"kIAyCA,IAAMA,EAAqBC,OAAO,6BAOlBC,EAAiBC,GAC7B,OAAmC,IAA5BA,EAAIH,oBAaf,SAAAI,IAwBYC,KAAAC,iBAA6BC,EAmKzC,OAvKIC,OAAAC,eAAIL,EAAAM,UAAA,aAAU,KAAd,WACI,IAAMC,EAAKN,KAAKO,iBAChB,OAAOD,EAAGL,cAAgBK,EAAGL,YAwKrC,SAA+BO,EAAsBC,GACjD,IAAKA,EACD,OAAOD,EAEH,IAAAE,EAAaD,EAASC,IAAjBC,EAAQF,EAASE,IAC9B,OAAKA,GAAQC,EAAoBJ,GAG1BK,EAAK,CACRH,IAAGA,EACHC,IAAG,SAACG,EAAUC,GACVP,EAAOG,IAAIA,EAAIK,KAAKhB,KAAMc,EAAUC,MAEzCP,GAAQS,YAPAT,EAAOU,OAAOR,GAAKO,YA9KiBE,CAAgBb,EAAGc,QAASd,EAAGe,OAASf,EAAGe,2CAQ1FlB,OAAAC,eAAIL,EAAAM,UAAA,SAAM,KAAV,WACI,IAAMC,EAAKN,KAAKO,iBAChB,IACI,OAAOD,EAAGgB,WAAWZ,MACvB,MAAOa,GAEL,MAAMpB,OAAOqB,OAAWC,MAAM,wBAAuBnB,EAAGoB,aAAe,UAAQ,MAAKH,GAAKA,EAAEI,UAAY,CAAEC,UAAWL,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QAAO,SAAC5C,GACJ,OAAOA,EAAOwC,mBAItB,SAASmC,EAAoB3E,EAAyB8B,GAClD,MAAuB,iBAATA,GAAqC,iBAATA,GAAiC,MAAZA,EAAK,KAAea,QAAQmC,IAAI9E,EAAQ8B,YAU3FQ,EAAiBhB,EAAiB4D,GAC9C,YAD6B,IAAA5D,IAAAA,EAAA,IACL,iBAAb4D,GAAyB,sBAAsBC,KAAKD,GACpD5D,EAAa,IAAM4D,EAEN,iBAAbA,EACA5D,EAAa,KAAO4D,EAASE,QAAQ,MAAO,QAAQA,QAAQ,MAAO,OAAS,KAEhF9D,EAAa,IAAM4D,EAAW,aASzB3C,EAAWf,EAAmC0D,GAC1D,YADuB,IAAA1D,IAAAA,EAAA,IAChBA,EAAK6D,OAAOH","file":"sherlock-proxy.esm.min.js","sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"]}
1
+ {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","_internal","isError","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","i","_a","sent","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],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EAAa,IAAM4D,EAAW,aASzB3C,EAAWf,EAAmC0D,GAC1D,YADuB,IAAA1D,IAAAA,EAAA,IAChBA,EAAK6D,OAAOH","file":"sherlock-proxy.esm.min.js","sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@politie/sherlock')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', '@politie/sherlock'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SherlockProxy = {}, global.Sherlock));
5
- }(this, (function (exports, sherlock) { 'use strict';
5
+ })(this, (function (exports, sherlock) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -93,7 +93,7 @@
93
93
  }
94
94
  catch (e) {
95
95
  // istanbul ignore next: for debug purposes
96
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
96
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$value') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
97
97
  }
98
98
  },
99
99
  set: function (newValue) {
@@ -107,7 +107,7 @@
107
107
  atom.set(newValue);
108
108
  }
109
109
  catch (e) {
110
- throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (e && e.message)), { jse_cause: e });
110
+ throw Object.assign(new Error("error while setting " + (expression || '$value') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
111
111
  }
112
112
  },
113
113
  enumerable: false,
@@ -124,7 +124,7 @@
124
124
  }
125
125
  catch (e) {
126
126
  // istanbul ignore next: for debug purposes
127
- throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
127
+ throw Object.assign(new Error("error while getting " + (pd.$expression || '$targetValue') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
128
128
  }
129
129
  },
130
130
  set: function (newValue) {
@@ -138,7 +138,7 @@
138
138
  atom.set(newValue);
139
139
  }
140
140
  catch (e) {
141
- throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (e && e.message)), { jse_cause: e });
141
+ throw Object.assign(new Error("error while setting " + (expression || '$targetValue') + ": " + (sherlock._internal.isError(e) && e.message)), { jse_cause: e });
142
142
  }
143
143
  },
144
144
  enumerable: false,
@@ -366,5 +366,5 @@
366
366
 
367
367
  Object.defineProperty(exports, '__esModule', { value: true });
368
368
 
369
- })));
369
+ }));
370
370
  //# sourceMappingURL=sherlock-proxy.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sherlock-proxy.umd.js","sources":["../../node_modules/tslib/tslib.es6.js","../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":["isSettableDerivable","utils","lens","isDerivable"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AAiEA;IACO,SAAS,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE;IAC3C,IAAI,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrH,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7J,IAAI,SAAS,IAAI,CAAC,CAAC,EAAE,EAAE,OAAO,UAAU,CAAC,EAAE,EAAE,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;IACtE,IAAI,SAAS,IAAI,CAAC,EAAE,EAAE;IACtB,QAAQ,IAAI,CAAC,EAAE,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACt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MAAM,EAAE,IAAI,CAAC,CAAC;IACjH,CAAC;IAED;;;;;;;aAOgB,gBAAgB,CAAC,UAAe,EAAE,QAAyB;QAA1C,2BAAA,EAAA,eAAe;QAC5C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACtE,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,CAAC;SACtC;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC9B,OAAO,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;SAC3F;QACD,OAAO,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC;IAC7C,CAAC;IAED;;;;;;aAMgB,UAAU,CAAC,IAAiC,EAAE,QAAyB;QAA5D,qBAAA,EAAA,SAAiC;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"sherlock-proxy.umd.js","sources":["../../node_modules/tslib/tslib.es6.js","../../extensions/sherlock-proxy/proxy.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n"],"names":["_internal","isSettableDerivable","utils","lens","isDerivable"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AAiEA;IACO,SAAS,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE;IAC3C,IAAI,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrH,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAW,EAAE,OAAO,IAAI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R
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var r=Symbol("isDerivableProxy");function n(e){return!0===e[r]}var i=function(){function e(){this.$$derivable=void 0}return Object.defineProperty(e.prototype,"$derivable",{get:function(){var e=this.$proxyDescriptor;return e.$$derivable||(e.$$derivable=function(e,r){if(!r)return e;var n=r.get,i=r.set;return i&&t.isSettableDerivable(e)?t.lens({get:n,set:function(t,r){e.set(i.call(this,t,r))}},e).autoCache():e.derive(n).autoCache()}(e.$target,e.$lens&&e.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$value",{get:function(){var e=this.$proxyDescriptor;try{return e.$derivable.get()}catch(t){throw Object.assign(Error("error while getting "+(e.$expression||"$value")+": "+(t&&t.message)),{jse_cause:t})}},set:function(e){var r=this.$proxyDescriptor,n=r.$derivable,i=r.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$value")+" is readonly");try{n.set(e)}catch(e){throw Object.assign(Error("error while setting "+(i||"$value")+": "+(e&&e.message)),{jse_cause:e})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$targetValue",{get:function(){var e=this.$proxyDescriptor;try{return e.$target.get()}catch(t){throw Object.assign(Error("error while getting "+(e.$expression||"$targetValue")+": "+(t&&t.message)),{jse_cause:t})}},set:function(e){var r=this.$proxyDescriptor,n=r.$target,i=r.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$targetValue")+" is readonly");try{n.set(e)}catch(e){throw Object.assign(Error("error while setting "+(i||"$targetValue")+": "+(e&&e.message)),{jse_cause:e})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),e.prototype.$create=function(e,r,n){var i=t.utils.clone(this.$proxyDescriptor);return i.$target=e,Object.getOwnPropertyNames(i).filter((function(e){return e.startsWith("$$")})).forEach((function(e){return i[e]=void 0})),i.$expression=r,i.$path=n,new Proxy(i,u)},e.prototype.$pluck=function(e){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(e),f(t.$expression,e),a(t.$path,e))},e.prototype.$pluckableKeys=function(){var e=this.$proxyDescriptor.$value;return"object"==typeof e?Reflect.ownKeys(e):[]},e.prototype.$length=function(){var e=this.$proxyDescriptor.$targetValue;return Array.isArray(e)?e.length:void 0},e.prototype.$and=function(e){return this.$proxyDescriptor.$derivable.and(o(e))},e.prototype.$or=function(e){return this.$proxyDescriptor.$derivable.or(o(e))},e.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},e.prototype.$is=function(e){return this.$proxyDescriptor.$derivable.is(o(e))},e.prototype.$derive=function(){var e=this.$proxyDescriptor.$derivable;return e.derive.apply(e,arguments)},e.prototype.$react=function(e,t){return this.$proxyDescriptor.$derivable.react(e,t)},e.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var e,t,r,n;return function(e,t){var r,n,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!((i=(i=u.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}(this,(function(i){switch(i.label){case 0:if(e=this.$proxyDescriptor,void 0===(t=e.$length()))throw r=e.$expression,Object.assign(Error((r||"object")+" is not iterable"),{value:e.$value,expression:r});n=0,i.label=1;case 1:return n<t?[4,e.$pluck(n)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},Object.defineProperty(e.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),e}();function o(e){return n(e)?e.$derivable:e}i.prototype[r]=!0;var u={get:function(e,t,r){return"$proxyDescriptor"===t?e:c(e,t)?e.$pluck.call(r,t):Reflect.get(e,t,r)},set:function(e,r,i,o){if(c(e,r)){var u=e.$pluck.call(o,r);return i&&n(i)?u.$targetValue=i.$targetValue:u.$value=i&&t.isDerivable(i)?i.get():i,!0}return Reflect.set(e,r,i,o)},has:function(e,t){return t===Symbol.iterator?void 0!==e.$length():c(e,t)},getOwnPropertyDescriptor:function(e,t){if(c(e,t))return{get:function(){return this[t]},set:function(e){this[t]=e},configurable:!0,enumerable:!0}},ownKeys:function(e){return e.$pluckableKeys()}};function c(e,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(e,t)}function f(e,t){return void 0===e&&(e=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?e+"."+t:"string"==typeof t?e+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':e+"["+t+"]"}function a(e,t){return void 0===e&&(e=[]),e.concat(t)}e.ProxyDescriptor=i,e.extendExpression=f,e.extendPath=a,e.isDerivableProxy=n,e.unwrapProxy=o,Object.defineProperty(e,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */var r=Symbol("isDerivableProxy");function n(e){return!0===e[r]}var i=function(){function e(){this.$$derivable=void 0}return Object.defineProperty(e.prototype,"$derivable",{get:function(){var e=this.$proxyDescriptor;return e.$$derivable||(e.$$derivable=function(e,r){if(!r)return e;var n=r.get,i=r.set;return i&&t.isSettableDerivable(e)?t.lens({get:n,set:function(t,r){e.set(i.call(this,t,r))}},e).autoCache():e.derive(n).autoCache()}(e.$target,e.$lens&&e.$lens()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$value",{get:function(){var e=this.$proxyDescriptor;try{return e.$derivable.get()}catch(r){throw Object.assign(Error("error while getting "+(e.$expression||"$value")+": "+(t._internal.isError(r)&&r.message)),{jse_cause:r})}},set:function(e){var r=this.$proxyDescriptor,n=r.$derivable,i=r.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$value")+" is readonly");try{n.set(e)}catch(e){throw Object.assign(Error("error while setting "+(i||"$value")+": "+(t._internal.isError(e)&&e.message)),{jse_cause:e})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$targetValue",{get:function(){var e=this.$proxyDescriptor;try{return e.$target.get()}catch(r){throw Object.assign(Error("error while getting "+(e.$expression||"$targetValue")+": "+(t._internal.isError(r)&&r.message)),{jse_cause:r})}},set:function(e){var r=this.$proxyDescriptor,n=r.$target,i=r.$expression;if(!t.isSettableDerivable(n))throw Error((i||"$targetValue")+" is readonly");try{n.set(e)}catch(e){throw Object.assign(Error("error while setting "+(i||"$targetValue")+": "+(t._internal.isError(e)&&e.message)),{jse_cause:e})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"$proxyDescriptor",{get:function(){return this},enumerable:!1,configurable:!0}),e.prototype.$create=function(e,r,n){var i=t.utils.clone(this.$proxyDescriptor);return i.$target=e,Object.getOwnPropertyNames(i).filter((function(e){return e.startsWith("$$")})).forEach((function(e){return i[e]=void 0})),i.$expression=r,i.$path=n,new Proxy(i,u)},e.prototype.$pluck=function(e){var t=this.$proxyDescriptor;return t.$create(t.$derivable.pluck(e),f(t.$expression,e),a(t.$path,e))},e.prototype.$pluckableKeys=function(){var e=this.$proxyDescriptor.$value;return"object"==typeof e?Reflect.ownKeys(e):[]},e.prototype.$length=function(){var e=this.$proxyDescriptor.$targetValue;return Array.isArray(e)?e.length:void 0},e.prototype.$and=function(e){return this.$proxyDescriptor.$derivable.and(o(e))},e.prototype.$or=function(e){return this.$proxyDescriptor.$derivable.or(o(e))},e.prototype.$not=function(){return this.$proxyDescriptor.$derivable.not()},e.prototype.$is=function(e){return this.$proxyDescriptor.$derivable.is(o(e))},e.prototype.$derive=function(){var e=this.$proxyDescriptor.$derivable;return e.derive.apply(e,arguments)},e.prototype.$react=function(e,t){return this.$proxyDescriptor.$derivable.react(e,t)},e.prototype.toJSON=function(){return this.$proxyDescriptor.$value},Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"DerivableProxy"},enumerable:!1,configurable:!0}),e.prototype[Symbol.iterator]=function(){var e,t,r,n;return function(e,t){var r,n,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!((i=(i=u.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}(this,(function(i){switch(i.label){case 0:if(e=this.$proxyDescriptor,void 0===(t=e.$length()))throw r=e.$expression,Object.assign(Error((r||"object")+" is not iterable"),{value:e.$value,expression:r});n=0,i.label=1;case 1:return n<t?[4,e.$pluck(n)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},Object.defineProperty(e.prototype,"length",{get:function(){return this.$proxyDescriptor.$length()},enumerable:!1,configurable:!0}),e}();function o(e){return n(e)?e.$derivable:e}i.prototype[r]=!0;var u={get:function(e,t,r){return"$proxyDescriptor"===t?e:c(e,t)?e.$pluck.call(r,t):Reflect.get(e,t,r)},set:function(e,r,i,o){if(c(e,r)){var u=e.$pluck.call(o,r);return i&&n(i)?u.$targetValue=i.$targetValue:u.$value=i&&t.isDerivable(i)?i.get():i,!0}return Reflect.set(e,r,i,o)},has:function(e,t){return t===Symbol.iterator?void 0!==e.$length():c(e,t)},getOwnPropertyDescriptor:function(e,t){if(c(e,t))return{get:function(){return this[t]},set:function(e){this[t]=e},configurable:!0,enumerable:!0}},ownKeys:function(e){return e.$pluckableKeys()}};function c(e,t){return"number"==typeof t||"string"==typeof t&&"$"!==t[0]&&!Reflect.has(e,t)}function f(e,t){return void 0===e&&(e=""),"string"==typeof t&&/^[a-z_][a-z_0-9]*$/i.test(t)?e+"."+t:"string"==typeof t?e+'["'+t.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')+'"]':e+"["+t+"]"}function a(e,t){return void 0===e&&(e=[]),e.concat(t)}e.ProxyDescriptor=i,e.extendExpression=f,e.extendPath=a,e.isDerivableProxy=n,e.unwrapProxy=o,Object.defineProperty(e,"__esModule",{value:!0})}));
16
16
  //# sourceMappingURL=sherlock-proxy.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts","../../node_modules/tslib/tslib.es6.js"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","thisArg","body","f","y","t","g","_","label","sent","trys","ops","next","verb","throw","return","n","v","op","TypeError","done","pop","push","step","i","_a","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],"mappings":";;;;;;;;;;;;;;oFAyCA,IAAMA,EAAqBC,OAAO,6BAOlBC,EAAiBC,GAC7B,OAAmC,IAA5BA,EAAIH,oBAaf,SAAAI,IAwBYC,KAAAC,iBAA6BC,EAmKzC,OAvKIC,OAAAC,eAAIL,EAAAM,UAAA,aAAU,KAAd,WACI,IAAMC,EAAKN,KAAKO,iBAChB,OAAOD,EAAGL,cAAgBK,EAAGL,YAwKrC,SAA+BO,EAAsBC,GACjD,IAAKA,EACD,OAAOD,EAEH,IAAAE,EAAaD,EAASC,IAAjBC,EAAQF,EAASE,IAC9B,OAAKA,GAAQC,EAAAA,oBAAoBJ,GAG1BK,EAAAA,KAAK,CACRH,IAAGA,EACHC,IAAG,SAACG,EAAUC,GACVP,EAAOG,IAAIA,EAAIK,KAAKhB,KAAMc,EAAUC,MAEzCP,GAAQS,YAPAT,EAAOU,OAAOR,GAAKO,YA9KiBE,CAAgBb,EAAGc,QAASd,E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Q,MAAO,QAAQA,QAAQ,MAAO,OAAS,KAEhFpF,EAAa,IAAMkF,EAAW,aASzBjE,EAAWf,EAAmCgF,GAC1D,YADuB,IAAAhF,IAAAA,EAAA,IAChBA,EAAKmF,OAAOH","file":"sherlock-proxy.umd.min.js","sourcesContent":["import { Derivable, isDerivable, isSettableDerivable, lens, ReactorOptions, utils } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${e && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"]}
1
+ {"version":3,"sources":["../../extensions/sherlock-proxy/proxy.ts","../../node_modules/tslib/tslib.es6.js"],"names":["IS_DERIVABLE_PROXY","Symbol","isDerivableProxy","obj","ProxyDescriptor","this","$$derivable","undefined","Object","defineProperty","prototype","pd","$proxyDescriptor","target","proxyLens","get","set","isSettableDerivable","lens","newValue","targetValue","call","autoCache","derive","createDerivable","$target","$lens","$derivable","e","assign","Error","$expression","_internal","isError","message","jse_cause","atom","expression","$create","path","descriptor","utils","clone","getOwnPropertyNames","filter","prop","startsWith","forEach","$path","Proxy","proxyHandler","$pluck","pluck","extendExpression","extendPath","$pluckableKeys","value","$value","Reflect","ownKeys","$length","maybeArray","$targetValue","Array","isArray","length","$and","other","and","unwrapProxy","$or","or","$not","not","$is","is","$derive","apply","arguments","$react","reaction","options","react","toJSON","toStringTag","iterator","thisArg","body","f","y","t","g","_","label","sent","trys","ops","next","verb","throw","return","n","v","op","TypeError","done","pop","push","step","i","_a","receiver","isPluckableProperty","plucked","isDerivable","has","getOwnPropertyDescriptor","configurable","enumerable","property","test","replace","concat"],"mappings":";;;;;;;;;;;;;;oFAyCA,IAAMA,EAAqBC,OAAO,6BAOlBC,EAAiBC,GAC7B,OAAmC,IAA5BA,EAAIH,oBAaf,SAAAI,IAwBYC,KAAAC,iBAA6BC,EAsKzC,OA1KIC,OAAAC,eAAIL,EAAAM,UAAA,aAAU,KAAd,WACI,IAAMC,EAAKN,KAAKO,iBAChB,OAAOD,EAAGL,cAAgBK,EAAGL,YA2KrC,SAA+BO,EAAsBC,GACjD,IAAKA,EACD,OAAOD,EAEH,IAAAE,EAAaD,EAASC,IAAjBC,EAAQF,EAASE,IAC9B,OAAKA,GAAQC,EAAAA,oBAAoBJ,GAG1BK,EAAAA,KAAK,CACRH,IAAGA,EACHC,IAAG,SAACG,EAAUC,GACVP,EAAOG,IAAIA,EAAIK,KAAKhB,KAAMc,EAAUC,MAEzCP,GAAQS,YAPAT,EAAOU,OAAOR,GAAKO,YAjLiBE,CAAgBb,EAAGc,QAASd,EAAGe,OAASf,EAAGe,2CAQ1FlB,OAAAC,eAAIL,EAAAM,UAAA,SAAM,KAAV,WACI,IAAMC,EAAKN,KAAKO,iBAChB,IACI,OAAOD,EAAGgB,WAAWZ,MACvB,MAAOa,GAEL,MAAMpB,OAAOqB,OAAWC,MAAM,wBAAuBnB,EAAGoB,aAAe,UAAQ,MAAKC,EAAAA,UAAUC,QAAQL,IAAMA,EAAEM,UAAY,CAAEC,UAAWP,UAG/I,SAA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ptions, utils, _internal } from '@politie/sherlock';\n\n/**\n * The base interface for DerivableProxies. Defines only the $-properties and $-methods. Any property accessed with a number or\n * that doesn't start with a $-sign returns a new DerivableProxy.\n */\nexport interface DerivableProxy<V> {\n /** The current value that this Proxy represents. Can be expensive to calculate and is often writable. */\n $value: V;\n\n /** A string representation of this proxy's path from the root ProxyDescriptor. */\n $expression?: string;\n\n /**\n * An array representation of this proxy's path from the root ProxyDescriptor. Useful for programatically walking down the root\n * Descriptor's object tree to reacquire a target proxy.\n */\n $path?: Array<string | number>;\n\n /** {@see Derivable#and} */\n $and<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#or} */\n $or<W>(other: MaybePacked<W>): Derivable<V | W>;\n\n /** {@see Derivable#not} */\n $not(): Derivable<boolean>;\n\n /** {@see Derivable#is} */\n $is(other: MaybePacked<any>): Derivable<boolean>;\n\n /** {@see Derivable#derive} */\n $derive<R>(f: (v: V) => R): Derivable<R>;\n $derive<R, P1>(f: (v: V, p1: P1) => R, p1: MaybePacked<P1>): Derivable<R>;\n $derive<R, P1, P2>(f: (v: V, p1: P1, p2: P2) => R, p1: MaybePacked<P1>, p2: MaybePacked<P2>): Derivable<R>;\n $derive<R, P>(f: (v: V, ...ps: P[]) => R, ...ps: Array<MaybePacked<P>>): Derivable<R>;\n\n /** {@see Derivable#react} */\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<V>>): () => void;\n}\n\nconst IS_DERIVABLE_PROXY = Symbol('isDerivableProxy');\n\n/**\n * Returns whether obj is a DerivableProxy.\n *\n * @param obj the object to test\n */\nexport function isDerivableProxy(obj: any): obj is DerivableProxy<any> {\n return obj[IS_DERIVABLE_PROXY] === true;\n}\n\n/**\n * A ProxyDescriptor must be used to create DerivableProxies. It can be used in two ways, either create a new descriptor and\n * change any implementation details (if needed) or create a subclass to extend the behavior. Use the {@link #$create} method\n * to create a DerivableProxy.\n *\n * Note that `this` in methods points to the created proxy, so only methods and properties that start with a $-sign can be accessed\n * without trouble.\n *\n * Note also that properties that start with two $-signs are cleared on $create.\n */\nexport class ProxyDescriptor<V = any, T = V> {\n /**\n * The target derivable (the input to the proxy and the {@link #$create} method). The actual values that can be seen by methods\n * on the Proxy can be influenced by providing a {@link #$lens}.\n */\n $target!: Derivable<T>;\n\n /**\n * The expression that represents the path to the current Proxy.\n */\n $expression?: string;\n\n /**\n * The path to the current Proxy.\n */\n $path?: Array<string | number>;\n\n /**\n * The derivable that is the input to all default methods on the Proxy and the {@link #$value} property.\n */\n get $derivable(): Derivable<V> {\n const pd = this.$proxyDescriptor;\n return pd.$$derivable || (pd.$$derivable = createDerivable(pd.$target, pd.$lens && pd.$lens()));\n }\n private $$derivable?: Derivable<V> = undefined;\n\n /**\n * The current value of the DerivableProxy. Can be expensive to calculate. When the target is settable (is an Atom) then $value\n * is writable.\n */\n get $value() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$derivable.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(new Error(`error while getting ${pd.$expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n set $value(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$derivable;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$value'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$value'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * The current value of the target Derivable that was used to create the DerivableProxy.\n */\n get $targetValue() {\n const pd = this.$proxyDescriptor;\n try {\n return pd.$target.get();\n } catch (e) {\n // istanbul ignore next: for debug purposes\n throw Object.assign(\n new Error(`error while getting ${pd.$expression || '$targetValue'}: ${_internal.isError(e) && e.message}`),\n { jse_cause: e },\n );\n }\n }\n set $targetValue(newValue) {\n const pd = this.$proxyDescriptor;\n const atom = pd.$target;\n const expression = pd.$expression;\n if (!isSettableDerivable(atom)) {\n throw new Error(`${expression || '$targetValue'} is readonly`);\n }\n try {\n atom.set(newValue);\n } catch (e) {\n throw Object.assign(new Error(`error while setting ${expression || '$targetValue'}: ${_internal.isError(e) && e.message}`), { jse_cause: e });\n }\n }\n\n /**\n * In methods of a ProxyDescriptor, `this` is bound to the Proxy Object. Therefore, only $-properties and $-methods can be\n * accessed safely. Use $proxyDescriptor to get access to the ProxyDescriptor Object to prevent the ProxyHandler from messing\n * with your logic.\n */\n protected get $proxyDescriptor() { return this; }\n\n /**\n * An optional method that can return an optional lens to this proxy. Is used to transform the values before accessed by the\n * consumer of the Proxy (either through $value or one of the other methods).\n */\n $lens?(): DerivableProxyLens<T, V> | undefined;\n\n /**\n * Wrap a Derivable as DerivableProxy using this ProxyDescriptor.\n *\n * @param obj the object to wrap\n * @param expression the new expression to the created DerivableProxy\n * @param path the new path to the created DerivableProxy\n */\n $create(obj: Derivable<T>, expression?: string, path?: Array<string | number>): DerivableProxy<V> {\n const descriptor: ProxyDescriptor = utils.clone(this.$proxyDescriptor);\n descriptor.$target = obj;\n Object.getOwnPropertyNames(descriptor)\n .filter(prop => prop.startsWith('$$'))\n .forEach(prop => descriptor[prop] = undefined);\n descriptor.$expression = expression;\n descriptor.$path = path;\n return new Proxy(descriptor, proxyHandler) as any;\n }\n\n /**\n * The $pluck method is the implementation of the pluck mechanism of DerivableProxy. Replace this method to change the\n * pluck behavior. It should return a DerivableProxy.\n *\n * @param prop the property to pluck of the wrapped derivable\n */\n $pluck(prop: string | number): DerivableProxy<V> {\n const pd = this.$proxyDescriptor;\n return pd.$create(pd.$derivable.pluck(prop), extendExpression(pd.$expression, prop), extendPath(pd.$path, prop));\n }\n\n /**\n * The $pluckableKeys returns a list of properties that can be plucked from this object. Returned keys are guaranteed to\n * result in a usable DerivableProxy when used with $pluck. Is used for `for ... in` and `Object.keys(...)` logic.\n */\n $pluckableKeys() {\n const value = this.$proxyDescriptor.$value;\n return typeof value === 'object' ? Reflect.ownKeys(value as any) : [];\n }\n\n /**\n * Method that determines whether the current object is iterable and if so, how many elements it contains. During iteration\n * {@link #pluck} is called with indices up to but not including the result of `$length()`.\n */\n $length(): number | undefined {\n const maybeArray = this.$proxyDescriptor.$targetValue;\n return Array.isArray(maybeArray) ? maybeArray.length : undefined;\n }\n\n $and(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.and(unwrapProxy(other));\n }\n\n $or(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.or(unwrapProxy(other));\n }\n\n $not() {\n return this.$proxyDescriptor.$derivable.not();\n }\n\n $is(other: MaybePacked<any>) {\n return this.$proxyDescriptor.$derivable.is(unwrapProxy(other));\n }\n\n $derive() {\n const target = this.$proxyDescriptor.$derivable;\n return target.derive.apply(target, arguments as any);\n }\n\n $react(reaction: (value: V, stop: () => void) => void, options?: Partial<ReactorOptions<any>>): () => void {\n return this.$proxyDescriptor.$derivable.react(reaction, options);\n }\n\n toJSON() {\n return this.$proxyDescriptor.$value;\n }\n\n get [Symbol.toStringTag]() {\n return 'DerivableProxy';\n }\n\n *[Symbol.iterator](): IterableIterator<DerivableProxy<V>> {\n const pd = this.$proxyDescriptor;\n const length = pd.$length();\n if (length === undefined) {\n const expression = pd.$expression;\n throw Object.assign(new Error(`${expression || 'object'} is not iterable`), { value: pd.$value, expression });\n }\n for (let i = 0; i < length; i++) {\n yield pd.$pluck(i)!;\n }\n }\n\n get length() {\n return this.$proxyDescriptor.$length();\n }\n}\nProxyDescriptor.prototype[IS_DERIVABLE_PROXY] = true;\n\nfunction createDerivable<V, T>(target: Derivable<T>, proxyLens?: DerivableProxyLens<T, V>): Derivable<V> {\n if (!proxyLens) {\n return target as any;\n }\n const { get, set } = proxyLens;\n if (!set || !isSettableDerivable(target)) {\n return target.derive(get).autoCache();\n }\n return lens({\n get,\n set(newValue, targetValue) {\n target.set(set.call(this, newValue, targetValue));\n }\n }, target).autoCache();\n}\n\nexport interface DerivableProxyLens<T, V> {\n get: (targetValue: T) => V;\n set?: (newValue: V, targetValue: T | undefined) => T;\n}\n\nexport type MaybePacked<T> = T | Derivable<T> | DerivableProxy<T>;\n\nexport function unwrapProxy<W>(obj: MaybePacked<W>): W | Derivable<W> {\n if (isDerivableProxy(obj)) {\n return (obj as any).$derivable;\n }\n return obj;\n}\n\nconst proxyHandler: ProxyHandler<ProxyDescriptor> = {\n get(target, prop, receiver) {\n if (prop === '$proxyDescriptor') {\n return target;\n }\n if (isPluckableProperty(target, prop)) {\n return target.$pluck.call(receiver, prop as string | number);\n }\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop, newValue, receiver) {\n if (isPluckableProperty(target, prop)) {\n const plucked = target.$pluck.call(receiver, prop as string | number) as ProxyDescriptor;\n if (newValue && isDerivableProxy(newValue)) {\n plucked.$targetValue = (newValue as any).$targetValue;\n } else {\n plucked.$value = newValue && isDerivable(newValue) ? newValue.get() : newValue;\n }\n return true;\n }\n return Reflect.set(target, prop, newValue, receiver);\n },\n has(target, prop) {\n if (prop === Symbol.iterator) {\n return target.$length() !== undefined;\n }\n return isPluckableProperty(target, prop);\n },\n getOwnPropertyDescriptor(target, prop) {\n if (isPluckableProperty(target, prop)) {\n return {\n get() { return this[prop]; },\n set(newValue) { this[prop] = newValue; },\n configurable: true,\n enumerable: true,\n };\n }\n return undefined;\n },\n ownKeys(target) {\n return target.$pluckableKeys();\n },\n};\n\nfunction isPluckableProperty(target: ProxyDescriptor, prop: PropertyKey) {\n return typeof prop === 'number' || typeof prop === 'string' && prop[0] !== '$' && !Reflect.has(target, prop);\n}\n\n/**\n * Extends an expression with a property access. Automatically uses bracket notation where appropriate and escapes\n * strings in brackets to give a realistic combined expression.\n *\n * @param expression the (optional) expression to extend\n * @param property the property that should be appended to the expression\n */\nexport function extendExpression(expression = '', property: string | number) {\n if (typeof property === 'string' && /^[a-z_][a-z_0-9]*$/i.test(property)) {\n return expression + '.' + property;\n }\n if (typeof property === 'string') {\n return expression + '[\"' + property.replace(/\\\\/g, '\\\\\\\\').replace(/\\\"/g, '\\\\\"') + '\"]';\n }\n return expression + '[' + property + ']';\n}\n\n/**\n * Extends a path with a property access.\n *\n * @param path the (optional) path to extend\n * @param property the property that should be appended to the path\n */\nexport function extendPath(path: Array<string | number> = [], property: string | number) {\n return path.concat(property);\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"]}