Skip to content

Commit

Permalink
fix: remove structuredClone and use devalue
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Jan 30, 2023
1 parent 21ceb07 commit 8a6bb27
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"pinia": ">=2.0.14"
},
"dependencies": {
"@ungap/structured-clone": "^1.0.1",
"broadcast-channel": "^4.20.2",
"devalue": "^4.2.3",
"vue-demi": "^0.13.11"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { watch } from 'vue-demi';
import type { MethodType } from 'broadcast-channel';
import { BroadcastChannel as BroadcastChannelImpl } from 'broadcast-channel';
import type { PiniaPluginContext, Store } from 'pinia';
import structuredClone from '@ungap/structured-clone';
import * as devalue from 'devalue';

/**
* Share state across browser tabs.
Expand Down Expand Up @@ -43,7 +43,7 @@ export function share<T extends Store, K extends keyof T['$state']>(
timestamp = Date.now();
channel.postMessage({
timestamp,
state: structuredClone(state),
state: devalue.parse(devalue.stringify(state)),
});
}
externalUpdate = false;
Expand All @@ -55,7 +55,7 @@ export function share<T extends Store, K extends keyof T['$state']>(
if (evt === undefined) {
channel.postMessage({
timestamp,
state: structuredClone(store[key]),
state: devalue.parse(devalue.stringify(store[key])),
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"noEmit": true
},
"include": ["./src", "types.d.ts"]
"include": ["./src"]
}
5 changes: 0 additions & 5 deletions types.d.ts

This file was deleted.

0 comments on commit 8a6bb27

Please sign in to comment.