@legendapp/state 0.15.0-next.9 → 0.15.2

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +8 -8
  3. package/babel.js +21 -599
  4. package/babel.js.map +1 -1
  5. package/index.d.ts +7 -2
  6. package/index.js +130 -119
  7. package/index.js.map +1 -1
  8. package/index.mjs +124 -119
  9. package/index.mjs.map +1 -1
  10. package/internal.d.ts +1 -1
  11. package/internal.js +4 -0
  12. package/internal.js.map +1 -1
  13. package/internal.mjs +1 -1
  14. package/package.json +15 -17
  15. package/react-components.d.ts +1 -0
  16. package/react-components.js +42 -0
  17. package/react-components.js.map +1 -0
  18. package/react-components.mjs +40 -0
  19. package/react-components.mjs.map +1 -0
  20. package/react-native-components.d.ts +1 -0
  21. package/react-native-components.js +38 -0
  22. package/react-native-components.js.map +1 -0
  23. package/react-native-components.mjs +36 -0
  24. package/react-native-components.mjs.map +1 -0
  25. package/react.d.ts +1 -0
  26. package/react.js +139 -137
  27. package/react.js.map +1 -1
  28. package/react.mjs +137 -140
  29. package/react.mjs.map +1 -1
  30. package/src/globals.d.ts +3 -1
  31. package/src/helpers.d.ts +3 -1
  32. package/src/observableInterfaces.d.ts +16 -14
  33. package/src/{effect.d.ts → observe.d.ts} +1 -1
  34. package/src/onChange.d.ts +1 -5
  35. package/src/react/flow.d.ts +31 -0
  36. package/src/react/useComputed.d.ts +6 -1
  37. package/src/react/useObserve.d.ts +1 -0
  38. package/src/{react/components.d.ts → react-components/react-components.d.ts} +4 -10
  39. package/src/{react-native/components.d.ts → react-native-components/rn-components.d.ts} +4 -8
  40. package/src/tracking.d.ts +1 -1
  41. package/src/when.d.ts +1 -5
  42. package/trace.js +4 -2
  43. package/trace.js.map +1 -1
  44. package/trace.mjs +5 -3
  45. package/trace.mjs.map +1 -1
  46. package/types.d.ts +15 -0
  47. package/react-native-types.d.ts +0 -39
  48. package/react-native.d.ts +0 -1
  49. package/react-native.js +0 -173
  50. package/react-native.js.map +0 -1
  51. package/react-native.mjs +0 -169
  52. package/react-native.mjs.map +0 -1
  53. package/react-types.d.ts +0 -8
  54. package/reactivity.d.ts +0 -2
  55. package/reactivity.js +0 -230
  56. package/reactivity.js.map +0 -1
  57. package/reactivity.mjs +0 -222
  58. package/reactivity.mjs.map +0 -1
  59. package/src/react/controlFlow.d.ts +0 -28
  60. package/state-types.d.ts +0 -24
package/CHANGELOG.md ADDED
@@ -0,0 +1,85 @@
1
+ ## 0.15.0
2
+
3
+ This is a big one with many breaking (but good) changes, so see https://legendapp.com/dev/state/migrating for more details. We're making a lot of breaking changes all once so that we can start to stabilize towards a 1.0.
4
+
5
+ - Breaking: There are now three levels of safety: Unsafe, Default, Safe. "Default" is new and allows direct assignment to primitives but prevents directly assigning to everything else. The previous default behavior was "Unsafe" so you may see errors if you were directly assigning to objects/arrays/etc... Replace those with `.set(...)` or pass in `false` as the second parameter to `observable` to go back to "Unsafe" mode.
6
+ - Breaking: Renamed `ref()` to `obs()`
7
+ - Breaking: The array optimizations are now opt-in, because they can potentially have some unexpected behavior if modifying the DOM externally. You can enable them by using the `For` component with the `optimized` prop.
8
+ - Breaking: Replaced `shallow` with a `Tracking` namespace, to add Optimized tracking. Change `shallow` to `Tracking.shallow` to get the previous behavior, or `Tracking.optimized` on an array to get the optimized behavior.
9
+ - Breaking: Changed `observableBatcher` to export the batching functions directly instead of as a namespace
10
+ - Breaking: Removed `onChangeShallow`, `onTrue`, `onEquals`, and `onHasValue` in favor of the new `effect` and `when` which automatically track any accessed observables.
11
+ - Breaking: Renamed primitive observables' wrapping value from `current` to `value`.
12
+ - Breaking: Renamed `observableComputed` to `computed` and `observableEvent` to `event`.
13
+ - Breaking: Renamed the bindable components from `LS` to `Bindable` and they now export from '@legendapp/state/react-components' or '@legendapp/state/react-native-components'
14
+ - Feat: Observable primitives can be rendered directly in React
15
+ - Feat: Added `observe`, which can run arbitrary code while tracking all accessed observables.
16
+ - Feat: Added `when`, which can run functions when the predicate returns a truthy value.
17
+ - Feat: Added `Switch` component
18
+ - Feat: Support creating an observable with a Promise as a value, which will update itself when the promise resolves.
19
+ - Feat: A `lockObservable` function to prevent writes
20
+ - Fix: Observables with arrays at the root were not notifying listeners properly
21
+ - Fix: Accessing `current` (now `value`) on a primitive observable was not tracking as expected
22
+ - Fix: Improve types of Memo/Computed/Show components so that they require functions by default, and are expanded to not need functions when referencing the babel types.
23
+
24
+ ## 0.14.5
25
+ - Feat: Allow passing observables directly to Show
26
+ - Fix: Usage of old observe() when if prop is an observable
27
+
28
+ ## 0.14.4
29
+ - Fix: Some issues in remote persistence plugins (not yet released)
30
+
31
+ ## 0.14.3
32
+ - Fix: Some issues in remote persistence plugins (not yet released)
33
+
34
+ ## 0.14.2
35
+ - Fix: Old versions of React Native were crashing because of using `React.` without importing it
36
+
37
+ ## 0.14.1
38
+ - Fix: `For` component with children re-renders with the latest children correctly
39
+
40
+ ## 0.14.0
41
+ - Feature: A `For` component for easy rendering with array optimizations
42
+ - Fix: Improve performance of observer
43
+ - Fix: Support `_id` or `__id` field names for array optimizations
44
+ - Fix: Mixing shallow and non-shallow listeners in a component could have not mixed correctly
45
+
46
+ ## 0.13.2
47
+ - Types: Renamed exported types for improved clarity
48
+
49
+ ## 0.13.1
50
+ - Fix: Exported components were losing className/style when not using bind prop
51
+
52
+ ## 0.13.0
53
+ - Breaking Change: Removed observe() and prop(), favoring get() and ref(). get() tracks by default and ref() does not.
54
+ - Feat: Support ref to a path on an undefined value
55
+ - Fix: A crash when calling get() on an observable with undefined parents
56
+ - Types: Enforce bind prop to not be a primitive
57
+
58
+ ## 0.12.1
59
+ - Types: Improved types of exported components
60
+
61
+ ## 0.12.0
62
+ - Feat: Allow direct assignment, with warnings to catch accidental errors, and an optional "safe" mode
63
+ - Feat: input components with `bind` prop that automatically binds an observable to value and onChange
64
+ - Feat: Support keyed ref: `obs.ref('key')`
65
+ - Feat: `onChange` has a `runImmediately` option
66
+ - Fix: `.ref()` and `.get()` inside an `observer` do reference counting so they don't untrack too aggressively
67
+ - Fix: `delete()` was notifying listeners with the value undefined, but the key not yet deleted
68
+ - Fix: `observer` was sometimes missing updates occurring between render and mount
69
+
70
+ ## 0.11.0-beta.7
71
+ - Fix: New set option with function parameter was breaking persistence
72
+ - Fix: Component useEffect was getting called before observer could listen for changes
73
+
74
+ ## 0.11.0-beta.6
75
+ - Fix: Babel plugin adds imports only once, only if not already imported
76
+
77
+ ## 0.11.0-beta.5
78
+ - Feat: `set()` can take a function to easily compute it relative to the previous value
79
+
80
+ ## 0.11.0-beta.4
81
+ - Feat: Added `traceListeners` and `traceUpdates` functions (exported from @legendapp/state/trace). Call them within an observer. `traceListeners` logs the path of all tracked observables, while `traceUpdates` logs details of each observable change that causes a render.
82
+
83
+ ## 0.11.0-beta.3
84
+ - Fix: observer was not working the first time in StrictMode
85
+ - Fix: observer was not cleaning up old listeners when the the tracked observables changed
package/README.md CHANGED
@@ -72,14 +72,14 @@ const Component = observer(function Component() {
72
72
 
73
73
  ## Highlights
74
74
 
75
- - ✨ Super easy to use - observables are normal objects
76
- - ✨ No boilerplate
77
- - ✨ Safe from 🔫 footguns
78
- - ✨ Designed for maximum performance and scalability
79
- - ✨ React components re-render only on changes
80
- - ✨ Very strongly typed with TypeScript
81
- - ✨ Persistence plugins for automatically saving/loading from storage
82
- - ✨ State can be global or within components
75
+ - ✨ Super easy to use - observables are normal objects
76
+ - ✨ No boilerplate
77
+ - ✨ Safe from 🔫 footguns
78
+ - ✨ Designed for maximum performance and scalability
79
+ - ✨ React components re-render only on changes
80
+ - ✨ Very strongly typed with TypeScript
81
+ - ✨ Persistence plugins for automatically saving/loading from storage
82
+ - ✨ State can be global or within components
83
83
 
84
84
  [Read more](https://www.legendapp.com/dev/state/why/) about why Legend-State might be right for you.
85
85