@vizel/react 1.0.0 → 1.1.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.
Files changed (49) hide show
  1. package/README.md +38 -14
  2. package/dist/index.d.ts +225 -1
  3. package/dist/index.js +59 -51
  4. package/dist/index10.js +42 -40
  5. package/dist/index13.js +1 -1
  6. package/dist/index14.js +4 -4
  7. package/dist/index16.js +1 -1
  8. package/dist/index19.js +1 -1
  9. package/dist/index2.js +1 -1
  10. package/dist/index20.js +152 -8
  11. package/dist/index21.js +8 -10
  12. package/dist/index22.js +10 -78
  13. package/dist/index23.js +75 -112
  14. package/dist/index24.js +112 -32
  15. package/dist/index25.js +35 -5
  16. package/dist/index26.js +5 -68
  17. package/dist/index27.js +65 -88
  18. package/dist/index28.js +91 -4
  19. package/dist/index29.js +4 -36
  20. package/dist/index30.js +34 -51
  21. package/dist/index31.js +52 -11
  22. package/dist/index32.js +11 -24
  23. package/dist/index33.js +24 -29
  24. package/dist/index34.js +30 -4
  25. package/dist/index35.js +4 -33
  26. package/dist/index36.js +31 -48
  27. package/dist/index37.js +50 -37
  28. package/dist/index38.js +48 -7
  29. package/dist/index39.js +69 -50
  30. package/dist/index40.js +45 -11
  31. package/dist/index41.js +8 -15
  32. package/dist/index42.js +53 -3
  33. package/dist/index43.js +11 -20
  34. package/dist/index44.js +54 -2
  35. package/dist/index45.js +15 -9742
  36. package/dist/index46.js +3 -17016
  37. package/dist/index47.js +21 -2
  38. package/dist/index48.js +2 -8
  39. package/dist/index49.js +9742 -2
  40. package/dist/index50.js +17016 -2
  41. package/dist/index51.js +2 -222
  42. package/dist/index52.js +7 -224
  43. package/dist/index53.js +2 -2
  44. package/dist/index54.js +2 -2
  45. package/dist/index55.js +224 -0
  46. package/dist/index56.js +227 -0
  47. package/dist/index57.js +4 -0
  48. package/dist/index58.js +4 -0
  49. package/package.json +12 -12
package/dist/index43.js CHANGED
@@ -1,23 +1,14 @@
1
- import { __module as e } from "./index44.js";
2
- import { __require as t } from "./index45.js";
3
- import { __require as i } from "./index46.js";
4
- var _;
5
- function O() {
6
- if (_) return e.exports;
7
- _ = 1;
8
- function r() {
9
- if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function")) {
10
- if (process.env.NODE_ENV !== "production")
11
- throw new Error("^_^");
12
- try {
13
- __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r);
14
- } catch (o) {
15
- console.error(o);
16
- }
17
- }
18
- }
19
- return process.env.NODE_ENV === "production" ? (r(), e.exports = t()) : e.exports = i(), e.exports;
1
+ import { useReducer as u, useRef as c, useEffect as f } from "react";
2
+ function s(n) {
3
+ const [o, r] = u((t) => t + 1, 0), e = c(null);
4
+ return f(() => {
5
+ const t = n() ?? null;
6
+ if (e.current && e.current !== t && e.current.off("transaction", r), e.current = t, !!t)
7
+ return t.on("transaction", r), () => {
8
+ t.off("transaction", r);
9
+ };
10
+ }), o;
20
11
  }
21
12
  export {
22
- O as __require
13
+ s as useVizelState
23
14
  };
package/dist/index44.js CHANGED
@@ -1,4 +1,56 @@
1
- var e = { exports: {} };
1
+ import { VIZEL_DEFAULT_VERSION_HISTORY_OPTIONS as c, createVizelVersionHistoryHandlers as k } from "@vizel/core";
2
+ import { useRef as S, useState as v, useCallback as o, useMemo as x, useEffect as E } from "react";
3
+ function O(n, r = {}) {
4
+ const t = S(r);
5
+ t.current = r;
6
+ const a = r.enabled ?? c.enabled, V = r.maxVersions ?? c.maxVersions, u = r.storage ?? c.storage, d = r.key ?? c.key, [i, R] = v({
7
+ snapshots: [],
8
+ isLoading: !1,
9
+ error: null
10
+ }), f = S(n);
11
+ f.current = n;
12
+ const m = o((e) => {
13
+ R((l) => ({ ...l, ...e }));
14
+ }, []), s = x(
15
+ () => k(
16
+ () => f.current(),
17
+ {
18
+ enabled: a,
19
+ maxVersions: V,
20
+ storage: u,
21
+ key: d,
22
+ onSave: (e) => t.current.onSave?.(e),
23
+ onError: (e) => t.current.onError?.(e),
24
+ onRestore: (e) => t.current.onRestore?.(e)
25
+ },
26
+ m
27
+ ),
28
+ [a, V, u, d, m]
29
+ );
30
+ E(() => {
31
+ n() && a && s.loadVersions();
32
+ }, [n, a, s]);
33
+ const h = o(
34
+ (e, l) => s.saveVersion(e, l),
35
+ [s]
36
+ ), g = o(
37
+ (e) => s.restoreVersion(e),
38
+ [s]
39
+ ), y = o(() => s.loadVersions(), [s]), L = o(
40
+ (e) => s.deleteVersion(e),
41
+ [s]
42
+ ), b = o(() => s.clearVersions(), [s]);
43
+ return {
44
+ snapshots: i.snapshots,
45
+ isLoading: i.isLoading,
46
+ error: i.error,
47
+ saveVersion: h,
48
+ restoreVersion: g,
49
+ loadVersions: y,
50
+ deleteVersion: L,
51
+ clearVersions: b
52
+ };
53
+ }
2
54
  export {
3
- e as __module
55
+ O as useVizelVersionHistory
4
56
  };