🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@dlymon-core/preferences

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dlymon-core/preferences - npm Package Compare versions

Comparing version
8.2.6
to
8.2.7
+3
-6
dist/preferences.cjs

@@ -27,13 +27,10 @@ 'use strict';

__publicField(this, "state");
console.log("PreferenceManager constructor start");
this.cache = new cache.StorageManager();
console.log("Cache initialized:", this.cache);
const loadedPreferences = this.loadPreferences();
console.log("Loaded preferences:", loadedPreferences);
try {
this.state = vue.reactive(loadedPreferences);
console.log("Reactive state created:", this.state);
const preferencesCopy = JSON.parse(JSON.stringify(loadedPreferences));
this.state = vue.reactive(preferencesCopy);
} catch (error) {
console.error("Failed to create reactive state, using plain object:", error);
this.state = { ...loadedPreferences };
this.state = { ...config.defaultPreferences };
}

@@ -40,0 +37,0 @@ this.savePreferences = core.useDebounceFn(

@@ -25,13 +25,10 @@ import { reactive, readonly, markRaw, watch } from 'vue';

__publicField(this, "state");
console.log("PreferenceManager constructor start");
this.cache = new StorageManager();
console.log("Cache initialized:", this.cache);
const loadedPreferences = this.loadPreferences();
console.log("Loaded preferences:", loadedPreferences);
try {
this.state = reactive(loadedPreferences);
console.log("Reactive state created:", this.state);
const preferencesCopy = JSON.parse(JSON.stringify(loadedPreferences));
this.state = reactive(preferencesCopy);
} catch (error) {
console.error("Failed to create reactive state, using plain object:", error);
this.state = { ...loadedPreferences };
this.state = { ...defaultPreferences };
}

@@ -38,0 +35,0 @@ this.savePreferences = useDebounceFn(

{
"name": "@dlymon-core/preferences",
"version": "8.2.6",
"version": "8.2.7",
"license": "MIT",

@@ -85,4 +85,4 @@ "type": "module",

"vue": "^3.5.22",
"@dlymon-core/shared": "5.1.6",
"@dlymon-core/typings": "5.0.6"
"@dlymon-core/shared": "5.1.7",
"@dlymon-core/typings": "5.0.7"
},

@@ -89,0 +89,0 @@ "scripts": {

@@ -32,19 +32,17 @@ import type { DeepPartial } from '@dlymon-core/typings';

constructor() {
console.log('PreferenceManager constructor start');
// 1. 先初始化 cache
this.cache = new StorageManager();
console.log('Cache initialized:', this.cache);
// 2. 同步加载 preferences(确保有回退)
const loadedPreferences = this.loadPreferences();
console.log('Loaded preferences:', loadedPreferences);
// 3. 安全地初始化响应式状态
// 3. 安全地初始化响应式状态 - 增加深拷贝避免数据引用问题
try {
this.state = reactive<Preferences>(loadedPreferences);
console.log('Reactive state created:', this.state);
// 先深拷贝以确保没有循环引用或不可序列化的对象
const preferencesCopy = JSON.parse(JSON.stringify(loadedPreferences));
this.state = reactive<Preferences>(preferencesCopy);
} catch (error) {
console.error('Failed to create reactive state, using plain object:', error);
this.state = { ...loadedPreferences };
// 如果发生错误,使用默认配置而不是可能损坏的数据
this.state = { ...defaultPreferences };
}

@@ -51,0 +49,0 @@