From 27b48ef96dc0f2c84e8e2c447db16f2c3511561a Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 1 May 2022 05:15:01 +0000 Subject: [PATCH] ressurect deepcopy --- packages/client/package.json | 1 + packages/client/src/pizzax.ts | 5 +++-- packages/client/yarn.lock | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index e533e1fb8..0a9473a54 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -31,6 +31,7 @@ "css-loader": "6.7.1", "cssnano": "5.1.7", "date-fns": "2.28.0", + "deepcopy": "2.1.0", "escape-regexp": "0.0.1", "eslint": "8.14.0", "eslint-plugin-vue": "8.7.1", diff --git a/packages/client/src/pizzax.ts b/packages/client/src/pizzax.ts index 338898005..389554247 100644 --- a/packages/client/src/pizzax.ts +++ b/packages/client/src/pizzax.ts @@ -1,10 +1,11 @@ -import { onUnmounted, Ref, ref, toRaw, watch } from 'vue'; +import { onUnmounted, Ref, ref, watch } from 'vue'; import { $i } from './account'; import { api } from './os'; import { get, set } from './scripts/idb-proxy'; import { defaultStore } from './store'; import { stream } from './stream'; import { BroadcastChannel } from 'broadcast-channel'; +import deepcopy from 'deepcopy'; type StateDef = Record { public set(key: K, value: T[K]['default']): Promise { // IndexedDBやBroadcastChannelで扱うために単純なオブジェクトにする // (JSON.parse(JSON.stringify(value))の代わり) - const rawValue = structuredClone(toRaw(value)); + const rawValue = deepcopy(value); if (_DEV_) console.log('set', key, rawValue, value); diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 05e175544..9b10508a5 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -1954,6 +1954,13 @@ deep-is@^0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= +deepcopy@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/deepcopy/-/deepcopy-2.1.0.tgz#2deb0dd52d079c2ecb7924b640a7c3abd4db1d6d" + integrity sha512-8cZeTb1ZKC3bdSCP6XOM1IsTczIO73fdqtwa2B0N15eAz7gmyhQo+mc5gnFuulsgN3vIQYmTgbmQVKalH1dKvQ== + dependencies: + type-detect "^4.0.8" + define-properties@^1.1.2, define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -5579,6 +5586,11 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" +type-detect@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + type-fest@^0.20.2: version "0.20.2" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"