@measured/puck 0.10.0-canary.3fe6284 → 0.10.0-canary.a7d9a28

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 (2) hide show
  1. package/dist/index.js +16 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3582,11 +3582,20 @@ function useActionHistory() {
3582
3582
  var import_react_hotkeys_hook = require("react-hotkeys-hook");
3583
3583
  var import_event_emitter = __toESM(require("event-emitter"));
3584
3584
  var import_use_debounce2 = require("use-debounce");
3585
- var import_deep_diff = require("deep-diff");
3586
3585
  var DEBOUNCE_TIME = 250;
3587
3586
  var RECORD_DIFF = "RECORD_DIFF";
3588
3587
  var historyEmitter = (0, import_event_emitter.default)();
3589
3588
  var recordDiff = (newAppData) => historyEmitter.emit(RECORD_DIFF, newAppData);
3589
+ var _recordHistory = ({ snapshot, newSnapshot, record, dispatch }) => {
3590
+ record({
3591
+ forward: () => {
3592
+ dispatch({ type: "set", appData: newSnapshot });
3593
+ },
3594
+ rewind: () => {
3595
+ dispatch({ type: "set", appData: snapshot });
3596
+ }
3597
+ });
3598
+ };
3590
3599
  function usePuckHistory({
3591
3600
  appData,
3592
3601
  dispatch
@@ -3597,27 +3606,11 @@ function usePuckHistory({
3597
3606
  (0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
3598
3607
  const [snapshot] = (0, import_use_debounce2.useDebounce)(appData, DEBOUNCE_TIME);
3599
3608
  const handleRecordDiff = (0, import_use_debounce2.useDebouncedCallback)((newAppData) => {
3600
- const _diff = (0, import_deep_diff.diff)(snapshot, newAppData);
3601
- if (!_diff) {
3602
- return;
3603
- }
3604
- record({
3605
- forward: () => {
3606
- const target = structuredClone(appData);
3607
- _diff.reduce((target2, change) => {
3608
- (0, import_deep_diff.applyChange)(target2, true, change);
3609
- return target2;
3610
- }, target);
3611
- dispatch({ type: "set", appData: target });
3612
- },
3613
- rewind: () => {
3614
- const target = structuredClone(appData);
3615
- _diff.reduce((target2, change) => {
3616
- (0, import_deep_diff.revertChange)(target2, true, change);
3617
- return target2;
3618
- }, target);
3619
- dispatch({ type: "set", appData: target });
3620
- }
3609
+ return _recordHistory({
3610
+ snapshot,
3611
+ newSnapshot: newAppData,
3612
+ record,
3613
+ dispatch
3621
3614
  });
3622
3615
  }, DEBOUNCE_TIME);
3623
3616
  (0, import_react26.useEffect)(() => {
@@ -3630,8 +3623,7 @@ function usePuckHistory({
3630
3623
  canForward,
3631
3624
  canRewind,
3632
3625
  rewind,
3633
- forward,
3634
- record
3626
+ forward
3635
3627
  };
3636
3628
  }
3637
3629
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.10.0-canary.3fe6284",
3
+ "version": "0.10.0-canary.a7d9a28",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",