@legendapp/state 2.2.0-next.71 → 2.2.0-next.73

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.
@@ -4,43 +4,45 @@ var state = require('@legendapp/state');
4
4
  var react$1 = require('@legendapp/state/react');
5
5
  var react = require('react');
6
6
 
7
- const ReactRenderContext = react.createContext(0);
8
- function needsSelector() {
9
- // If we're already tracking then we definitely don't need useSelector
10
- if (!state.tracking.current) {
11
- try {
12
- // If there's no dispatcher we're definitely not in React
13
- // This is an optimization to not need to run useContext. If in a future React version
14
- // this works differently we can change it or just remove it.
15
- const dispatcher = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;
16
- if (dispatcher) {
17
- // If there's a dispatcher then we may be inside of a hook.
18
- // Attempt a useContext hook, which will throw an error if outside of render.
19
- react.useContext(ReactRenderContext);
20
- return true;
21
- }
22
- }
23
- catch (_a) { } // eslint-disable-line no-empty
24
- }
25
- return false;
26
- }
27
7
  function enableReactTracking({ auto, warnUnobserved }) {
28
8
  const { get } = state.internal;
29
- state.configureLegendState({
30
- observableFunctions: {
31
- get: (node, options) => {
32
- if (needsSelector()) {
33
- if (auto) {
34
- return react$1.useSelector(() => get(node, options), state.isObject(options) ? options : undefined);
35
- }
36
- else if (process.env.NODE_ENV === 'development' && warnUnobserved) {
37
- console.warn('[legend-state] Detected a `get()` call in an unobserved component. You may want to wrap it in observer: https://legendapp.com/open-source/state/react-api/#observer-hoc');
9
+ if (auto || (process.env.NODE_ENV === 'development' && warnUnobserved)) {
10
+ const ReactRenderContext = react.createContext(0);
11
+ const needsSelector = () => {
12
+ // If we're already tracking then we definitely don't need useSelector
13
+ if (!state.tracking.current) {
14
+ try {
15
+ // If there's no dispatcher we're definitely not in React
16
+ // This is an optimization to not need to run useContext. If in a future React version
17
+ // this works differently we can change it or just remove it.
18
+ const dispatcher = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;
19
+ if (dispatcher) {
20
+ // If there's a dispatcher then we may be inside of a hook.
21
+ // Attempt a useContext hook, which will throw an error if outside of render.
22
+ react.useContext(ReactRenderContext);
23
+ return true;
38
24
  }
39
25
  }
40
- return get(node, options);
26
+ catch (_a) { } // eslint-disable-line no-empty
27
+ }
28
+ return false;
29
+ };
30
+ state.configureLegendState({
31
+ observableFunctions: {
32
+ get: (node, options) => {
33
+ if (needsSelector()) {
34
+ if (auto) {
35
+ return react$1.useSelector(() => get(node, options), state.isObject(options) ? options : undefined);
36
+ }
37
+ else if (process.env.NODE_ENV === 'development' && warnUnobserved) {
38
+ console.warn('[legend-state] Detected a `get()` call in an unobserved component. You may want to wrap it in observer: https://legendapp.com/open-source/state/react-api/#observer-hoc');
39
+ }
40
+ }
41
+ return get(node, options);
42
+ },
41
43
  },
42
- },
43
- });
44
+ });
45
+ }
44
46
  }
45
47
 
46
48
  exports.enableReactTracking = enableReactTracking;
@@ -1 +1 @@
1
- {"version":3,"file":"enableReactTracking.js","sources":["../src/config/enableReactTracking.ts"],"sourcesContent":[null],"names":["createContext","tracking","ReactInternals","useContext","internal","configureLegendState","useSelector","isObject"],"mappings":";;;;;;AAcA,MAAM,kBAAkB,GAAGA,mBAAa,CAAC,CAAC,CAAC,CAAC;AAE5C,SAAS,aAAa,GAAA;;AAElB,IAAA,IAAI,CAACC,cAAQ,CAAC,OAAO,EAAE;AACnB,QAAA,IAAI;;;;AAIA,YAAA,MAAM,UAAU,GAAGC,wDAAc,CAAC,sBAAsB,CAAC,OAAO,CAAC;YACjE,IAAI,UAAU,EAAE;;;gBAGZC,gBAAU,CAAC,kBAAkB,CAAC,CAAC;AAC/B,gBAAA,OAAO,IAAI,CAAC;aACf;SACJ;AAAC,QAAA,OAAA,EAAA,EAAM,GAAE;KACb;AACD,IAAA,OAAO,KAAK,CAAC;AACjB,CAAC;SAOe,mBAAmB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAwB,EAAA;AAC9E,IAAA,MAAM,EAAE,GAAG,EAAE,GAAGC,cAAQ,CAAC;AAEzB,IAAAC,0BAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA0D,KAAI;gBACjF,IAAI,aAAa,EAAE,EAAE;oBACjB,IAAI,IAAI,EAAE;wBACN,OAAOC,mBAAW,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAEC,cAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;qBACzF;yBAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,EAAE;AACjE,wBAAA,OAAO,CAAC,IAAI,CACR,yKAAyK,CAC5K,CAAC;qBACL;iBACJ;AACD,gBAAA,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;aAC7B;AACJ,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"enableReactTracking.js","sources":["../src/config/enableReactTracking.ts"],"sourcesContent":[null],"names":["internal","createContext","tracking","ReactInternals","useContext","configureLegendState","useSelector","isObject"],"mappings":";;;;;;SAmBgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAwB,EAAA;AAC9E,IAAA,MAAM,EAAE,GAAG,EAAE,GAAGA,cAAQ,CAAC;AAEzB,IAAA,IAAI,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,CAAC,EAAE;AACpE,QAAA,MAAM,kBAAkB,GAAGC,mBAAa,CAAC,CAAC,CAAC,CAAC;QAE5C,MAAM,aAAa,GAAG,MAAK;;AAEvB,YAAA,IAAI,CAACC,cAAQ,CAAC,OAAO,EAAE;AACnB,gBAAA,IAAI;;;;AAIA,oBAAA,MAAM,UAAU,GAAGC,wDAAc,CAAC,sBAAsB,CAAC,OAAO,CAAC;oBACjE,IAAI,UAAU,EAAE;;;wBAGZC,gBAAU,CAAC,kBAAkB,CAAC,CAAC;AAC/B,wBAAA,OAAO,IAAI,CAAC;qBACf;iBACJ;AAAC,gBAAA,OAAA,EAAA,EAAM,GAAE;aACb;AACD,YAAA,OAAO,KAAK,CAAC;AACjB,SAAC,CAAC;AAEF,QAAAC,0BAAoB,CAAC;AACjB,YAAA,mBAAmB,EAAE;AACjB,gBAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA0D,KAAI;oBACjF,IAAI,aAAa,EAAE,EAAE;wBACjB,IAAI,IAAI,EAAE;4BACN,OAAOC,mBAAW,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAEC,cAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;yBACzF;6BAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,EAAE;AACjE,4BAAA,OAAO,CAAC,IAAI,CACR,yKAAyK,CAC5K,CAAC;yBACL;qBACJ;AACD,oBAAA,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;iBAC7B;AACJ,aAAA;AACJ,SAAA,CAAC,CAAC;KACN;AACL;;;;"}
@@ -1,44 +1,46 @@
1
- import { configureLegendState, isObject, tracking, internal } from '@legendapp/state';
1
+ import { configureLegendState, isObject, internal, tracking } from '@legendapp/state';
2
2
  import { useSelector } from '@legendapp/state/react';
3
3
  import { createContext, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, useContext } from 'react';
4
4
 
5
- const ReactRenderContext = createContext(0);
6
- function needsSelector() {
7
- // If we're already tracking then we definitely don't need useSelector
8
- if (!tracking.current) {
9
- try {
10
- // If there's no dispatcher we're definitely not in React
11
- // This is an optimization to not need to run useContext. If in a future React version
12
- // this works differently we can change it or just remove it.
13
- const dispatcher = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;
14
- if (dispatcher) {
15
- // If there's a dispatcher then we may be inside of a hook.
16
- // Attempt a useContext hook, which will throw an error if outside of render.
17
- useContext(ReactRenderContext);
18
- return true;
19
- }
20
- }
21
- catch (_a) { } // eslint-disable-line no-empty
22
- }
23
- return false;
24
- }
25
5
  function enableReactTracking({ auto, warnUnobserved }) {
26
6
  const { get } = internal;
27
- configureLegendState({
28
- observableFunctions: {
29
- get: (node, options) => {
30
- if (needsSelector()) {
31
- if (auto) {
32
- return useSelector(() => get(node, options), isObject(options) ? options : undefined);
33
- }
34
- else if (process.env.NODE_ENV === 'development' && warnUnobserved) {
35
- console.warn('[legend-state] Detected a `get()` call in an unobserved component. You may want to wrap it in observer: https://legendapp.com/open-source/state/react-api/#observer-hoc');
7
+ if (auto || (process.env.NODE_ENV === 'development' && warnUnobserved)) {
8
+ const ReactRenderContext = createContext(0);
9
+ const needsSelector = () => {
10
+ // If we're already tracking then we definitely don't need useSelector
11
+ if (!tracking.current) {
12
+ try {
13
+ // If there's no dispatcher we're definitely not in React
14
+ // This is an optimization to not need to run useContext. If in a future React version
15
+ // this works differently we can change it or just remove it.
16
+ const dispatcher = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current;
17
+ if (dispatcher) {
18
+ // If there's a dispatcher then we may be inside of a hook.
19
+ // Attempt a useContext hook, which will throw an error if outside of render.
20
+ useContext(ReactRenderContext);
21
+ return true;
36
22
  }
37
23
  }
38
- return get(node, options);
24
+ catch (_a) { } // eslint-disable-line no-empty
25
+ }
26
+ return false;
27
+ };
28
+ configureLegendState({
29
+ observableFunctions: {
30
+ get: (node, options) => {
31
+ if (needsSelector()) {
32
+ if (auto) {
33
+ return useSelector(() => get(node, options), isObject(options) ? options : undefined);
34
+ }
35
+ else if (process.env.NODE_ENV === 'development' && warnUnobserved) {
36
+ console.warn('[legend-state] Detected a `get()` call in an unobserved component. You may want to wrap it in observer: https://legendapp.com/open-source/state/react-api/#observer-hoc');
37
+ }
38
+ }
39
+ return get(node, options);
40
+ },
39
41
  },
40
- },
41
- });
42
+ });
43
+ }
42
44
  }
43
45
 
44
46
  export { enableReactTracking };
@@ -1 +1 @@
1
- {"version":3,"file":"enableReactTracking.mjs","sources":["../src/config/enableReactTracking.ts"],"sourcesContent":[null],"names":["ReactInternals"],"mappings":";;;;AAcA,MAAM,kBAAkB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAE5C,SAAS,aAAa,GAAA;;AAElB,IAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACnB,QAAA,IAAI;;;;AAIA,YAAA,MAAM,UAAU,GAAGA,kDAAc,CAAC,sBAAsB,CAAC,OAAO,CAAC;YACjE,IAAI,UAAU,EAAE;;;gBAGZ,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAC/B,gBAAA,OAAO,IAAI,CAAC;aACf;SACJ;AAAC,QAAA,OAAA,EAAA,EAAM,GAAE;KACb;AACD,IAAA,OAAO,KAAK,CAAC;AACjB,CAAC;SAOe,mBAAmB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAwB,EAAA;AAC9E,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;AAEzB,IAAA,oBAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA0D,KAAI;gBACjF,IAAI,aAAa,EAAE,EAAE;oBACjB,IAAI,IAAI,EAAE;wBACN,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;qBACzF;yBAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,EAAE;AACjE,wBAAA,OAAO,CAAC,IAAI,CACR,yKAAyK,CAC5K,CAAC;qBACL;iBACJ;AACD,gBAAA,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;aAC7B;AACJ,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"enableReactTracking.mjs","sources":["../src/config/enableReactTracking.ts"],"sourcesContent":[null],"names":["ReactInternals"],"mappings":";;;;SAmBgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,cAAc,EAAwB,EAAA;AAC9E,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;AAEzB,IAAA,IAAI,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,CAAC,EAAE;AACpE,QAAA,MAAM,kBAAkB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAE5C,MAAM,aAAa,GAAG,MAAK;;AAEvB,YAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACnB,gBAAA,IAAI;;;;AAIA,oBAAA,MAAM,UAAU,GAAGA,kDAAc,CAAC,sBAAsB,CAAC,OAAO,CAAC;oBACjE,IAAI,UAAU,EAAE;;;wBAGZ,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAC/B,wBAAA,OAAO,IAAI,CAAC;qBACf;iBACJ;AAAC,gBAAA,OAAA,EAAA,EAAM,GAAE;aACb;AACD,YAAA,OAAO,KAAK,CAAC;AACjB,SAAC,CAAC;AAEF,QAAA,oBAAoB,CAAC;AACjB,YAAA,mBAAmB,EAAE;AACjB,gBAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA0D,KAAI;oBACjF,IAAI,aAAa,EAAE,EAAE;wBACjB,IAAI,IAAI,EAAE;4BACN,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;yBACzF;6BAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,cAAc,EAAE;AACjE,4BAAA,OAAO,CAAC,IAAI,CACR,yKAAyK,CAC5K,CAAC;yBACL;qBACJ;AACD,oBAAA,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;iBAC7B;AACJ,aAAA;AACJ,SAAA,CAAC,CAAC;KACN;AACL;;;;"}
@@ -3,11 +3,18 @@
3
3
  var state = require('@legendapp/state');
4
4
  var react = require('@legendapp/state/react');
5
5
 
6
- // TODO: Deprecate
6
+ // TODO: Deprecated, remove in v4
7
+ let didWarn = false;
7
8
  function enableReactUse() {
8
9
  state.configureLegendState({
9
10
  observableFunctions: {
10
- use: (node, options) => react.useSelector(state.internal.getProxy(node), options),
11
+ use: (node, options) => {
12
+ if (process.env.NODE_ENV === 'development' && !didWarn) {
13
+ didWarn = true;
14
+ console.warn('[legend-state] enableReactUse() is deprecated. Please switch to using get() with observer, which is safer and more efficient. See https://legendapp.com/open-source/state/v3/react/react-api/');
15
+ }
16
+ return react.useSelector(state.internal.getProxy(node), options);
17
+ },
11
18
  },
12
19
  });
13
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enableReactUse.js","sources":["../src/config/enableReactUse.ts"],"sourcesContent":[null],"names":["configureLegendState","useSelector","internal"],"mappings":";;;;;AAGA;SAEgB,cAAc,GAAA;AAC1B,IAAAA,0BAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA4B,KAAKC,iBAAW,CAACC,cAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;AACxG,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"enableReactUse.js","sources":["../src/config/enableReactUse.ts"],"sourcesContent":[null],"names":["configureLegendState","useSelector","internal"],"mappings":";;;;;AAGA;AACA,IAAI,OAAO,GAAG,KAAK,CAAC;SAEJ,cAAc,GAAA;AAC1B,IAAAA,0BAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA4B,KAAI;gBACnD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,CAAC,OAAO,EAAE;oBACpD,OAAO,GAAG,IAAI,CAAC;AACf,oBAAA,OAAO,CAAC,IAAI,CACR,+LAA+L,CAClM,CAAC;iBACL;gBACD,OAAOC,iBAAW,CAACC,cAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;aACxD;AACJ,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
@@ -1,11 +1,18 @@
1
1
  import { configureLegendState, internal } from '@legendapp/state';
2
2
  import { useSelector } from '@legendapp/state/react';
3
3
 
4
- // TODO: Deprecate
4
+ // TODO: Deprecated, remove in v4
5
+ let didWarn = false;
5
6
  function enableReactUse() {
6
7
  configureLegendState({
7
8
  observableFunctions: {
8
- use: (node, options) => useSelector(internal.getProxy(node), options),
9
+ use: (node, options) => {
10
+ if (process.env.NODE_ENV === 'development' && !didWarn) {
11
+ didWarn = true;
12
+ console.warn('[legend-state] enableReactUse() is deprecated. Please switch to using get() with observer, which is safer and more efficient. See https://legendapp.com/open-source/state/v3/react/react-api/');
13
+ }
14
+ return useSelector(internal.getProxy(node), options);
15
+ },
9
16
  },
10
17
  });
11
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enableReactUse.mjs","sources":["../src/config/enableReactUse.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;SAEgB,cAAc,GAAA;AAC1B,IAAA,oBAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA4B,KAAK,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;AACxG,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"enableReactUse.mjs","sources":["../src/config/enableReactUse.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;AACA,IAAI,OAAO,GAAG,KAAK,CAAC;SAEJ,cAAc,GAAA;AAC1B,IAAA,oBAAoB,CAAC;AACjB,QAAA,mBAAmB,EAAE;AACjB,YAAA,GAAG,EAAE,CAAC,IAAe,EAAE,OAA4B,KAAI;gBACnD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,CAAC,OAAO,EAAE;oBACpD,OAAO,GAAG,IAAI,CAAC;AACf,oBAAA,OAAO,CAAC,IAAI,CACR,+LAA+L,CAClM,CAAC;iBACL;gBACD,OAAO,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;aACxD;AACJ,SAAA;AACJ,KAAA,CAAC,CAAC;AACP;;;;"}
package/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export { when, whenReady } from './src/when';
18
18
  import { get, getProxy, peek, set } from './src/ObservableObject';
19
19
  import { createPreviousHandler } from './src/batching';
20
20
  import { clone, ensureNodeValue, findIDKey, getNode, getNodeValue, getPathType, safeParse, safeStringify, setNodeValue } from './src/globals';
21
- import { initializePathType, setAtPath } from './src/helpers';
21
+ import { getValueAtPath, initializePathType, setAtPath } from './src/helpers';
22
22
  import { runWithRetry } from './src/retry';
23
23
  export declare const internal: {
24
24
  createPreviousHandler: typeof createPreviousHandler;
@@ -30,6 +30,7 @@ export declare const internal: {
30
30
  getNodeValue: typeof getNodeValue;
31
31
  getPathType: typeof getPathType;
32
32
  getProxy: typeof getProxy;
33
+ getValueAtPath: typeof getValueAtPath;
33
34
  globalState: {
34
35
  isLoadingLocal: boolean;
35
36
  isMerging: boolean;
package/index.js CHANGED
@@ -147,7 +147,7 @@ function setNodeValue(node, newValue) {
147
147
  // Compute newValue if newValue is a function or an observable
148
148
  newValue = !parentNode.isAssigning && isFunc && !isFunction(prevValue) ? newValue(prevValue) : newValue;
149
149
  if (!globalState.isMerging ||
150
- prevValue === undefined ||
150
+ isNullOrUndefined(prevValue) ||
151
151
  isFunction(prevValue) ||
152
152
  !((_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.functions) === null || _c === void 0 ? void 0 : _c.get(key))) {
153
153
  try {
@@ -547,6 +547,14 @@ function opaqueObject(value) {
547
547
  }
548
548
  return value;
549
549
  }
550
+ function getValueAtPath$1(obj, path) {
551
+ let o = obj;
552
+ for (let i = 0; o && i < path.length; i++) {
553
+ const p = path[i];
554
+ o = o[p];
555
+ }
556
+ return o;
557
+ }
550
558
  function setAtPath(obj, path, pathTypes, value, mode, fullObj, restore) {
551
559
  let o = obj;
552
560
  let oFull = fullObj;
@@ -1414,6 +1422,7 @@ const proxyHandler = {
1414
1422
  updateTracking(node);
1415
1423
  return function (cbOrig, thisArg) {
1416
1424
  const isReduce = p === 'reduce';
1425
+ // Callbacks are given the Proxy rather than the underlying data
1417
1426
  const cbWrapped = isReduce
1418
1427
  ? (previousValue, currentValue, currentIndex, array) => {
1419
1428
  return cbOrig(previousValue, getProxy(node, currentIndex + '', currentValue), currentIndex, array);
@@ -1429,6 +1438,7 @@ const proxyHandler = {
1429
1438
  for (let i = 0; i < value.length; i++) {
1430
1439
  if (cbWrapped(value[i], i, value)) {
1431
1440
  const proxy = getProxy(node, i + '');
1441
+ // find returns the first match, otherwise it returns an array
1432
1442
  if (isFind) {
1433
1443
  return proxy;
1434
1444
  }
@@ -2228,6 +2238,7 @@ const internal = {
2228
2238
  getNodeValue,
2229
2239
  getPathType,
2230
2240
  getProxy,
2241
+ getValueAtPath: getValueAtPath$1,
2231
2242
  globalState,
2232
2243
  initializePathType,
2233
2244
  observableFns,