electron-pinia-sync 1.0.0 → 1.2.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.
@@ -1,6 +1,48 @@
1
- import diff from 'microdiff';
2
-
3
- // src/renderer/index.ts
1
+ // node_modules/microdiff/dist/index.js
2
+ var richTypes = { Date: true, RegExp: true, String: true, Number: true };
3
+ function diff(obj, newObj, options = { cyclesFix: true }, _stack = []) {
4
+ let diffs = [];
5
+ const isObjArray = Array.isArray(obj);
6
+ for (const key in obj) {
7
+ const objKey = obj[key];
8
+ const path = isObjArray ? +key : key;
9
+ if (!(key in newObj)) {
10
+ diffs.push({
11
+ type: "REMOVE",
12
+ path: [path],
13
+ oldValue: obj[key]
14
+ });
15
+ continue;
16
+ }
17
+ const newObjKey = newObj[key];
18
+ const areCompatibleObjects = typeof objKey === "object" && typeof newObjKey === "object" && Array.isArray(objKey) === Array.isArray(newObjKey);
19
+ if (objKey && newObjKey && areCompatibleObjects && !richTypes[Object.getPrototypeOf(objKey)?.constructor?.name] && (!options.cyclesFix || !_stack.includes(objKey))) {
20
+ diffs.push.apply(diffs, diff(objKey, newObjKey, options, options.cyclesFix ? _stack.concat([objKey]) : []).map((difference) => {
21
+ difference.path.unshift(path);
22
+ return difference;
23
+ }));
24
+ } else if (objKey !== newObjKey && // treat NaN values as equivalent
25
+ !(Number.isNaN(objKey) && Number.isNaN(newObjKey)) && !(areCompatibleObjects && (isNaN(objKey) ? objKey + "" === newObjKey + "" : +objKey === +newObjKey))) {
26
+ diffs.push({
27
+ path: [path],
28
+ type: "CHANGE",
29
+ value: newObjKey,
30
+ oldValue: objKey
31
+ });
32
+ }
33
+ }
34
+ const isNewObjArray = Array.isArray(newObj);
35
+ for (const key in newObj) {
36
+ if (!(key in obj)) {
37
+ diffs.push({
38
+ type: "CREATE",
39
+ path: [isNewObjArray ? +key : key],
40
+ value: newObj[key]
41
+ });
42
+ }
43
+ }
44
+ return diffs;
45
+ }
4
46
 
5
47
  // src/debug.ts
6
48
  function createDebugLogger(namespace, debugLevel = false, customLogger) {
@@ -195,5 +237,9 @@ function createRendererSync(options = {}) {
195
237
  };
196
238
  };
197
239
  }
198
-
199
- export { createDebugLogger, createRendererSync, formatPatchForDebug, formatStateForDebug };
240
+ export {
241
+ createDebugLogger,
242
+ createRendererSync,
243
+ formatPatchForDebug,
244
+ formatStateForDebug
245
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-pinia-sync",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A comprehensive Pinia plugin for Electron that synchronizes store states across multiple windows via IPC and provides seamless persistence through electron-store.",
5
5
  "license": "MIT",
6
6
  "author": "simpli.fyi",
@@ -16,24 +16,27 @@
16
16
  ],
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/simpli-fyi/electron-pinia-sync.git"
19
+ "url": "git+https://github.com/simpli-fyi/electron-pinia-sync.git"
20
20
  },
21
21
  "type": "module",
22
22
  "packageManager": "npm@10.9.0",
23
23
  "engines": {
24
- "node": ">=20.0.0"
24
+ "node": ">=22.14.0"
25
25
  },
26
26
  "exports": {
27
27
  "./main": {
28
28
  "types": "./dist/main/index.d.ts",
29
+ "require": "./dist/main/index.cjs",
29
30
  "import": "./dist/main/index.js"
30
31
  },
31
32
  "./preload": {
32
33
  "types": "./dist/preload/index.d.ts",
34
+ "require": "./dist/preload/index.cjs",
33
35
  "import": "./dist/preload/index.js"
34
36
  },
35
37
  "./renderer": {
36
38
  "types": "./dist/renderer/index.d.ts",
39
+ "require": "./dist/renderer/index.cjs",
37
40
  "import": "./dist/renderer/index.js"
38
41
  }
39
42
  },
@@ -44,12 +47,9 @@
44
47
  "CONTRIBUTING.md"
45
48
  ],
46
49
  "scripts": {
47
- "build": "npm run clean && npm run build:main && npm run build:renderer && npm run build:preload",
48
- "build:main": "tsup src/main/index.ts --format esm --dts --outDir dist/main",
49
- "build:preload": "tsup src/preload/index.ts --format esm --dts --outDir dist/preload",
50
- "build:renderer": "tsup src/renderer/index.ts --format esm --dts --outDir dist/renderer",
50
+ "build": "npm run clean && tsup",
51
+ "dev": "tsup --watch",
51
52
  "clean": "rm -rf dist",
52
- "dev": "npm run build --watch",
53
53
  "test": "vitest run",
54
54
  "test:watch": "vitest",
55
55
  "test:coverage": "vitest run --coverage",
@@ -70,12 +70,16 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@playwright/test": "^1.58.0",
73
+ "@semantic-release/changelog": "^6.0.3",
74
+ "@semantic-release/git": "^10.0.1",
75
+ "@semantic-release/npm": "^13.1.3",
73
76
  "@types/node": "^25.1.0",
74
77
  "@vitest/coverage-v8": "^4.0.0",
75
78
  "electron": "^40.1.0",
76
79
  "eslint": "^9.39.0",
77
80
  "pinia": "^3.0.0",
78
81
  "playwright": "^1.58.0",
82
+ "semantic-release": "^25.0.3",
79
83
  "tsup": "^8.5.0",
80
84
  "tsx": "^4.21.0",
81
85
  "typescript": "^5.7.0",