cross-state 1.8.5 → 1.9.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.
- package/dist/{diff-BZm7wZ6G.d.cts → diff-Bcr0h7-x.d.cts} +2 -1
- package/dist/{diff-DxjoO6qz.d.ts → diff-CwiTYAVK.d.ts} +2 -1
- package/dist/extendedJson-DA3RQ_ly.js +138 -0
- package/dist/extendedJson-DA3RQ_ly.js.map +1 -0
- package/dist/extendedJson-DzXMFE1P.cjs +167 -0
- package/dist/extendedJson-DzXMFE1P.cjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/{patchMethods-CxI_x-zv.d.ts → patchMethods-C21iQqML.d.ts} +2 -2
- package/dist/{patchMethods-BfyJt9me.cjs → patchMethods-CZje49Dk.cjs} +4 -117
- package/dist/patchMethods-CZje49Dk.cjs.map +1 -0
- package/dist/{patchMethods-D-Vmx93m.js → patchMethods-Cui462lc.js} +4 -111
- package/dist/patchMethods-Cui462lc.js.map +1 -0
- package/dist/{patchMethods-DjHq-wbw.d.cts → patchMethods-Cyb6MEOG.d.cts} +2 -2
- package/dist/patches/index.cjs +1 -1
- package/dist/patches/index.d.cts +1 -1
- package/dist/patches/index.d.ts +1 -1
- package/dist/patches/index.js +1 -1
- package/dist/patches/register.cjs +1 -1
- package/dist/patches/register.d.cts +1 -1
- package/dist/patches/register.d.ts +1 -1
- package/dist/patches/register.js +1 -1
- package/dist/persist/register.cjs +1 -1
- package/dist/persist/register.js +1 -1
- package/dist/{persist-CwKzFRM7.cjs → persist-CG1WHP6D.cjs} +3 -3
- package/dist/{persist-CwKzFRM7.cjs.map → persist-CG1WHP6D.cjs.map} +1 -1
- package/dist/{persist-CZhDrupc.js → persist-CNA2sYtB.js} +3 -3
- package/dist/{persist-CZhDrupc.js.map → persist-CNA2sYtB.js.map} +1 -1
- package/dist/react/index.cjs +41 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +9 -0
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.js +41 -3
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/extendedJson-B1OEqZtF.js +0 -29
- package/dist/extendedJson-B1OEqZtF.js.map +0 -1
- package/dist/extendedJson-BwYSvpOA.cjs +0 -53
- package/dist/extendedJson-BwYSvpOA.cjs.map +0 -1
- package/dist/patchMethods-BfyJt9me.cjs.map +0 -1
- package/dist/patchMethods-D-Vmx93m.js.map +0 -1
|
@@ -15,8 +15,9 @@ type Patch = {
|
|
|
15
15
|
};
|
|
16
16
|
interface DiffOptions {
|
|
17
17
|
stopAt?: number | ((path: KeyType[]) => boolean);
|
|
18
|
+
diffArrays?: boolean;
|
|
18
19
|
}
|
|
19
20
|
declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
|
|
20
21
|
//#endregion
|
|
21
22
|
export { Patch as n, diff as r, DiffOptions as t };
|
|
22
|
-
//# sourceMappingURL=diff-
|
|
23
|
+
//# sourceMappingURL=diff-Bcr0h7-x.d.cts.map
|
|
@@ -15,8 +15,9 @@ type Patch = {
|
|
|
15
15
|
};
|
|
16
16
|
interface DiffOptions {
|
|
17
17
|
stopAt?: number | ((path: KeyType[]) => boolean);
|
|
18
|
+
diffArrays?: boolean;
|
|
18
19
|
}
|
|
19
20
|
declare function diff(a: any, b: any, options?: DiffOptions): [patches: Patch[], reversePatches: Patch[]];
|
|
20
21
|
//#endregion
|
|
21
22
|
export { Patch as n, diff as r, DiffOptions as t };
|
|
22
|
-
//# sourceMappingURL=diff-
|
|
23
|
+
//# sourceMappingURL=diff-CwiTYAVK.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { c as deepEqual, o as isObject } from "./propAccess-BxCKNeOj.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/diff.ts
|
|
4
|
+
function diff(a, b, options = {}) {
|
|
5
|
+
const result = [..._diff(a, b, options)];
|
|
6
|
+
return [result.map(([patch]) => patch), result.map(([, reversePatch]) => reversePatch)];
|
|
7
|
+
}
|
|
8
|
+
function* _diff(a, b, options, prefix = []) {
|
|
9
|
+
if (a === b) return;
|
|
10
|
+
if (typeof options.stopAt === "number" && prefix.length >= options.stopAt || typeof options.stopAt === "function" && options.stopAt(prefix)) {
|
|
11
|
+
if (deepEqual(a, b)) return;
|
|
12
|
+
return yield [{
|
|
13
|
+
op: "replace",
|
|
14
|
+
path: prefix,
|
|
15
|
+
value: b
|
|
16
|
+
}, {
|
|
17
|
+
op: "replace",
|
|
18
|
+
path: prefix,
|
|
19
|
+
value: a
|
|
20
|
+
}];
|
|
21
|
+
}
|
|
22
|
+
if (a instanceof Date && b instanceof Date) {
|
|
23
|
+
if (a.getTime() === b.getTime()) return;
|
|
24
|
+
return yield [{
|
|
25
|
+
op: "replace",
|
|
26
|
+
path: prefix,
|
|
27
|
+
value: b
|
|
28
|
+
}, {
|
|
29
|
+
op: "replace",
|
|
30
|
+
path: prefix,
|
|
31
|
+
value: a
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
if (a instanceof Map && b instanceof Map) return yield* mapDiff(a, b, options, prefix);
|
|
35
|
+
if (a instanceof Set && b instanceof Set) {
|
|
36
|
+
if (deepEqual(a, b)) return;
|
|
37
|
+
return yield [{
|
|
38
|
+
op: "replace",
|
|
39
|
+
path: prefix,
|
|
40
|
+
value: b
|
|
41
|
+
}, {
|
|
42
|
+
op: "replace",
|
|
43
|
+
path: prefix,
|
|
44
|
+
value: a
|
|
45
|
+
}];
|
|
46
|
+
}
|
|
47
|
+
if (!options.diffArrays && Array.isArray(a) && Array.isArray(b)) {
|
|
48
|
+
if (deepEqual(a, b)) return;
|
|
49
|
+
return yield [{
|
|
50
|
+
op: "replace",
|
|
51
|
+
path: prefix,
|
|
52
|
+
value: b
|
|
53
|
+
}, {
|
|
54
|
+
op: "replace",
|
|
55
|
+
path: prefix,
|
|
56
|
+
value: a
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
if (isObject(a) && isObject(b) && (options.diffArrays || !Array.isArray(a) && !Array.isArray(b))) return yield* objectDiff(a, b, options, prefix);
|
|
60
|
+
yield [{
|
|
61
|
+
op: "replace",
|
|
62
|
+
path: prefix,
|
|
63
|
+
value: b
|
|
64
|
+
}, {
|
|
65
|
+
op: "replace",
|
|
66
|
+
path: prefix,
|
|
67
|
+
value: a
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
function* mapDiff(a, b, options, prefix) {
|
|
71
|
+
for (const [key, value] of a) if (!b.has(key)) yield [{
|
|
72
|
+
op: "remove",
|
|
73
|
+
path: [...prefix, key]
|
|
74
|
+
}, {
|
|
75
|
+
op: "add",
|
|
76
|
+
path: [...prefix, key],
|
|
77
|
+
value
|
|
78
|
+
}];
|
|
79
|
+
else yield* _diff(value, b.get(key), options, [...prefix, key]);
|
|
80
|
+
for (const [key, value] of b) if (!a.has(key)) yield [{
|
|
81
|
+
op: "add",
|
|
82
|
+
path: [...prefix, key],
|
|
83
|
+
value
|
|
84
|
+
}, {
|
|
85
|
+
op: "remove",
|
|
86
|
+
path: [...prefix, key]
|
|
87
|
+
}];
|
|
88
|
+
}
|
|
89
|
+
function* objectDiff(a, b, options, prefix) {
|
|
90
|
+
for (const [key, value] of Object.entries(a)) if (!(key in b)) yield [{
|
|
91
|
+
op: "remove",
|
|
92
|
+
path: [...prefix, key]
|
|
93
|
+
}, {
|
|
94
|
+
op: "add",
|
|
95
|
+
path: [...prefix, key],
|
|
96
|
+
value
|
|
97
|
+
}];
|
|
98
|
+
else yield* _diff(value, b[key], options, [...prefix, key]);
|
|
99
|
+
for (const [key, value] of Object.entries(b)) if (!(key in a)) yield [{
|
|
100
|
+
op: "add",
|
|
101
|
+
path: [...prefix, key],
|
|
102
|
+
value
|
|
103
|
+
}, {
|
|
104
|
+
op: "remove",
|
|
105
|
+
path: [...prefix, key]
|
|
106
|
+
}];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/lib/extendedJson.ts
|
|
111
|
+
function toExtendedJson(value) {
|
|
112
|
+
if (value instanceof Map) return { __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]) };
|
|
113
|
+
if (value instanceof Set) return { __set: [...value].map(toExtendedJson) };
|
|
114
|
+
if (value instanceof Date) return { __date: value.toISOString() };
|
|
115
|
+
if (typeof value === "bigint") return { __bigint: value.toString() };
|
|
116
|
+
if (Array.isArray(value)) return value.map(toExtendedJson);
|
|
117
|
+
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
function toExtendedJsonString(value, ...args) {
|
|
121
|
+
return JSON.stringify(toExtendedJson(value), ...args);
|
|
122
|
+
}
|
|
123
|
+
function fromExtendedJson(value) {
|
|
124
|
+
if (typeof value !== "object" || value === null) return value;
|
|
125
|
+
if ("__map" in value) return new Map(value.__map.map(([k, v]) => [fromExtendedJson(k), fromExtendedJson(v)]));
|
|
126
|
+
if ("__set" in value) return new Set(value.__set.map(fromExtendedJson));
|
|
127
|
+
if ("__date" in value) return new Date(value.__date);
|
|
128
|
+
if ("__bigint" in value) return BigInt(value.__bigint);
|
|
129
|
+
if (Array.isArray(value)) return value.map(fromExtendedJson);
|
|
130
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));
|
|
131
|
+
}
|
|
132
|
+
function fromExtendedJsonString(value, reviver) {
|
|
133
|
+
return fromExtendedJson(JSON.parse(value, reviver));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
export { diff as a, toExtendedJsonString as i, fromExtendedJsonString as n, toExtendedJson as r, fromExtendedJson as t };
|
|
138
|
+
//# sourceMappingURL=extendedJson-DA3RQ_ly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extendedJson-DA3RQ_ly.js","names":[],"sources":["../src/lib/diff.ts","../src/lib/extendedJson.ts"],"sourcesContent":["import { isObject } from '@lib/helpers';\nimport { deepEqual } from './equals';\nimport type { KeyType } from './path';\n\nexport type Patch =\n | { op: 'add'; path: KeyType[]; value: any }\n | { op: 'remove'; path: KeyType[] }\n | { op: 'replace'; path: KeyType[]; value: any };\n\nexport interface DiffOptions {\n stopAt?: number | ((path: KeyType[]) => boolean);\n diffArrays?: boolean;\n}\n\nexport function diff(\n a: any,\n b: any,\n options: DiffOptions = {},\n): [patches: Patch[], reversePatches: Patch[]] {\n const result = [..._diff(a, b, options)];\n const patches = result.map(([patch]) => patch);\n const reversePatches = result.map(([, reversePatch]) => reversePatch);\n\n return [patches, reversePatches];\n}\n\nfunction* _diff(\n a: any,\n b: any,\n options: DiffOptions,\n prefix: KeyType[] = [],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n if (a === b) {\n return;\n }\n\n if (\n (typeof options.stopAt === 'number' && prefix.length >= options.stopAt) ||\n (typeof options.stopAt === 'function' && options.stopAt(prefix))\n ) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (a instanceof Date && b instanceof Date) {\n if (a.getTime() === b.getTime()) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (a instanceof Map && b instanceof Map) {\n return yield* mapDiff(a, b, options, prefix);\n }\n\n if (a instanceof Set && b instanceof Set) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (!options.diffArrays && Array.isArray(a) && Array.isArray(b)) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (\n isObject(a) &&\n isObject(b) &&\n (options.diffArrays || (!Array.isArray(a) && !Array.isArray(b)))\n ) {\n return yield* objectDiff(a, b, options, prefix);\n }\n\n yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n}\n\nfunction* mapDiff(\n a: Map<any, any>,\n b: Map<any, any>,\n options: { stopAt?: number | ((path: KeyType[]) => boolean) },\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of a) {\n if (!b.has(key)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b.get(key), options, [...prefix, key]);\n }\n }\n\n for (const [key, value] of b) {\n if (!a.has(key)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n\nfunction* objectDiff(\n a: any,\n b: any,\n options: { stopAt?: number | ((path: KeyType[]) => boolean) },\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of Object.entries(a)) {\n if (!(key in b)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b[key], options, [...prefix, key]);\n }\n }\n\n for (const [key, value] of Object.entries(b)) {\n if (!(key in a)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n","export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";;;AAcA,SAAgB,KACd,GACA,GACA,UAAuB,EAAE,EACoB;CAC7C,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIxC,QAAO,CAHS,OAAO,KAAK,CAAC,WAAW,MAAM,EACvB,OAAO,KAAK,GAAG,kBAAkB,aAAa,CAErC;;AAGlC,UAAU,MACR,GACA,GACA,SACA,SAAoB,EAAE,EACyB;AAC/C,KAAI,MAAM,EACR;AAGF,KACG,OAAO,QAAQ,WAAW,YAAY,OAAO,UAAU,QAAQ,UAC/D,OAAO,QAAQ,WAAW,cAAc,QAAQ,OAAO,OAAO,EAC/D;AACA,MAAI,UAAU,GAAG,EAA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
|
+
const require_propAccess = require('./propAccess-udIdjqwY.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/lib/diff.ts
|
|
4
|
+
function diff(a, b, options = {}) {
|
|
5
|
+
const result = [..._diff(a, b, options)];
|
|
6
|
+
return [result.map(([patch]) => patch), result.map(([, reversePatch]) => reversePatch)];
|
|
7
|
+
}
|
|
8
|
+
function* _diff(a, b, options, prefix = []) {
|
|
9
|
+
if (a === b) return;
|
|
10
|
+
if (typeof options.stopAt === "number" && prefix.length >= options.stopAt || typeof options.stopAt === "function" && options.stopAt(prefix)) {
|
|
11
|
+
if (require_propAccess.deepEqual(a, b)) return;
|
|
12
|
+
return yield [{
|
|
13
|
+
op: "replace",
|
|
14
|
+
path: prefix,
|
|
15
|
+
value: b
|
|
16
|
+
}, {
|
|
17
|
+
op: "replace",
|
|
18
|
+
path: prefix,
|
|
19
|
+
value: a
|
|
20
|
+
}];
|
|
21
|
+
}
|
|
22
|
+
if (a instanceof Date && b instanceof Date) {
|
|
23
|
+
if (a.getTime() === b.getTime()) return;
|
|
24
|
+
return yield [{
|
|
25
|
+
op: "replace",
|
|
26
|
+
path: prefix,
|
|
27
|
+
value: b
|
|
28
|
+
}, {
|
|
29
|
+
op: "replace",
|
|
30
|
+
path: prefix,
|
|
31
|
+
value: a
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
if (a instanceof Map && b instanceof Map) return yield* mapDiff(a, b, options, prefix);
|
|
35
|
+
if (a instanceof Set && b instanceof Set) {
|
|
36
|
+
if (require_propAccess.deepEqual(a, b)) return;
|
|
37
|
+
return yield [{
|
|
38
|
+
op: "replace",
|
|
39
|
+
path: prefix,
|
|
40
|
+
value: b
|
|
41
|
+
}, {
|
|
42
|
+
op: "replace",
|
|
43
|
+
path: prefix,
|
|
44
|
+
value: a
|
|
45
|
+
}];
|
|
46
|
+
}
|
|
47
|
+
if (!options.diffArrays && Array.isArray(a) && Array.isArray(b)) {
|
|
48
|
+
if (require_propAccess.deepEqual(a, b)) return;
|
|
49
|
+
return yield [{
|
|
50
|
+
op: "replace",
|
|
51
|
+
path: prefix,
|
|
52
|
+
value: b
|
|
53
|
+
}, {
|
|
54
|
+
op: "replace",
|
|
55
|
+
path: prefix,
|
|
56
|
+
value: a
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
if (require_propAccess.isObject(a) && require_propAccess.isObject(b) && (options.diffArrays || !Array.isArray(a) && !Array.isArray(b))) return yield* objectDiff(a, b, options, prefix);
|
|
60
|
+
yield [{
|
|
61
|
+
op: "replace",
|
|
62
|
+
path: prefix,
|
|
63
|
+
value: b
|
|
64
|
+
}, {
|
|
65
|
+
op: "replace",
|
|
66
|
+
path: prefix,
|
|
67
|
+
value: a
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
function* mapDiff(a, b, options, prefix) {
|
|
71
|
+
for (const [key, value] of a) if (!b.has(key)) yield [{
|
|
72
|
+
op: "remove",
|
|
73
|
+
path: [...prefix, key]
|
|
74
|
+
}, {
|
|
75
|
+
op: "add",
|
|
76
|
+
path: [...prefix, key],
|
|
77
|
+
value
|
|
78
|
+
}];
|
|
79
|
+
else yield* _diff(value, b.get(key), options, [...prefix, key]);
|
|
80
|
+
for (const [key, value] of b) if (!a.has(key)) yield [{
|
|
81
|
+
op: "add",
|
|
82
|
+
path: [...prefix, key],
|
|
83
|
+
value
|
|
84
|
+
}, {
|
|
85
|
+
op: "remove",
|
|
86
|
+
path: [...prefix, key]
|
|
87
|
+
}];
|
|
88
|
+
}
|
|
89
|
+
function* objectDiff(a, b, options, prefix) {
|
|
90
|
+
for (const [key, value] of Object.entries(a)) if (!(key in b)) yield [{
|
|
91
|
+
op: "remove",
|
|
92
|
+
path: [...prefix, key]
|
|
93
|
+
}, {
|
|
94
|
+
op: "add",
|
|
95
|
+
path: [...prefix, key],
|
|
96
|
+
value
|
|
97
|
+
}];
|
|
98
|
+
else yield* _diff(value, b[key], options, [...prefix, key]);
|
|
99
|
+
for (const [key, value] of Object.entries(b)) if (!(key in a)) yield [{
|
|
100
|
+
op: "add",
|
|
101
|
+
path: [...prefix, key],
|
|
102
|
+
value
|
|
103
|
+
}, {
|
|
104
|
+
op: "remove",
|
|
105
|
+
path: [...prefix, key]
|
|
106
|
+
}];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/lib/extendedJson.ts
|
|
111
|
+
function toExtendedJson(value) {
|
|
112
|
+
if (value instanceof Map) return { __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]) };
|
|
113
|
+
if (value instanceof Set) return { __set: [...value].map(toExtendedJson) };
|
|
114
|
+
if (value instanceof Date) return { __date: value.toISOString() };
|
|
115
|
+
if (typeof value === "bigint") return { __bigint: value.toString() };
|
|
116
|
+
if (Array.isArray(value)) return value.map(toExtendedJson);
|
|
117
|
+
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
function toExtendedJsonString(value, ...args) {
|
|
121
|
+
return JSON.stringify(toExtendedJson(value), ...args);
|
|
122
|
+
}
|
|
123
|
+
function fromExtendedJson(value) {
|
|
124
|
+
if (typeof value !== "object" || value === null) return value;
|
|
125
|
+
if ("__map" in value) return new Map(value.__map.map(([k, v]) => [fromExtendedJson(k), fromExtendedJson(v)]));
|
|
126
|
+
if ("__set" in value) return new Set(value.__set.map(fromExtendedJson));
|
|
127
|
+
if ("__date" in value) return new Date(value.__date);
|
|
128
|
+
if ("__bigint" in value) return BigInt(value.__bigint);
|
|
129
|
+
if (Array.isArray(value)) return value.map(fromExtendedJson);
|
|
130
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));
|
|
131
|
+
}
|
|
132
|
+
function fromExtendedJsonString(value, reviver) {
|
|
133
|
+
return fromExtendedJson(JSON.parse(value, reviver));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
Object.defineProperty(exports, 'diff', {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return diff;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, 'fromExtendedJson', {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return fromExtendedJson;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, 'fromExtendedJsonString', {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return fromExtendedJsonString;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(exports, 'toExtendedJson', {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function () {
|
|
158
|
+
return toExtendedJson;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(exports, 'toExtendedJsonString', {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function () {
|
|
164
|
+
return toExtendedJsonString;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=extendedJson-DzXMFE1P.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extendedJson-DzXMFE1P.cjs","names":["deepEqual","isObject"],"sources":["../src/lib/diff.ts","../src/lib/extendedJson.ts"],"sourcesContent":["import { isObject } from '@lib/helpers';\nimport { deepEqual } from './equals';\nimport type { KeyType } from './path';\n\nexport type Patch =\n | { op: 'add'; path: KeyType[]; value: any }\n | { op: 'remove'; path: KeyType[] }\n | { op: 'replace'; path: KeyType[]; value: any };\n\nexport interface DiffOptions {\n stopAt?: number | ((path: KeyType[]) => boolean);\n diffArrays?: boolean;\n}\n\nexport function diff(\n a: any,\n b: any,\n options: DiffOptions = {},\n): [patches: Patch[], reversePatches: Patch[]] {\n const result = [..._diff(a, b, options)];\n const patches = result.map(([patch]) => patch);\n const reversePatches = result.map(([, reversePatch]) => reversePatch);\n\n return [patches, reversePatches];\n}\n\nfunction* _diff(\n a: any,\n b: any,\n options: DiffOptions,\n prefix: KeyType[] = [],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n if (a === b) {\n return;\n }\n\n if (\n (typeof options.stopAt === 'number' && prefix.length >= options.stopAt) ||\n (typeof options.stopAt === 'function' && options.stopAt(prefix))\n ) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (a instanceof Date && b instanceof Date) {\n if (a.getTime() === b.getTime()) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (a instanceof Map && b instanceof Map) {\n return yield* mapDiff(a, b, options, prefix);\n }\n\n if (a instanceof Set && b instanceof Set) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (!options.diffArrays && Array.isArray(a) && Array.isArray(b)) {\n if (deepEqual(a, b)) {\n return;\n }\n\n return yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n }\n\n if (\n isObject(a) &&\n isObject(b) &&\n (options.diffArrays || (!Array.isArray(a) && !Array.isArray(b)))\n ) {\n return yield* objectDiff(a, b, options, prefix);\n }\n\n yield [\n { op: 'replace', path: prefix, value: b },\n { op: 'replace', path: prefix, value: a },\n ];\n}\n\nfunction* mapDiff(\n a: Map<any, any>,\n b: Map<any, any>,\n options: { stopAt?: number | ((path: KeyType[]) => boolean) },\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of a) {\n if (!b.has(key)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b.get(key), options, [...prefix, key]);\n }\n }\n\n for (const [key, value] of b) {\n if (!a.has(key)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n\nfunction* objectDiff(\n a: any,\n b: any,\n options: { stopAt?: number | ((path: KeyType[]) => boolean) },\n prefix: KeyType[],\n): Iterable<[patch: Patch, reversePatch: Patch]> {\n for (const [key, value] of Object.entries(a)) {\n if (!(key in b)) {\n yield [\n { op: 'remove', path: [...prefix, key] },\n { op: 'add', path: [...prefix, key], value },\n ];\n } else {\n yield* _diff(value, b[key], options, [...prefix, key]);\n }\n }\n\n for (const [key, value] of Object.entries(b)) {\n if (!(key in a)) {\n yield [\n { op: 'add', path: [...prefix, key], value },\n { op: 'remove', path: [...prefix, key] },\n ];\n }\n }\n}\n","export function toExtendedJson(value: unknown): unknown {\n if (value instanceof Map) {\n return {\n __map: [...value].map(([k, v]) => [toExtendedJson(k), toExtendedJson(v)]),\n };\n }\n\n if (value instanceof Set) {\n return {\n __set: [...value].map(toExtendedJson),\n };\n }\n\n if (value instanceof Date) {\n return {\n __date: value.toISOString(),\n };\n }\n\n if (typeof value === 'bigint') {\n return {\n __bigint: value.toString(),\n };\n }\n\n if (Array.isArray(value)) {\n return value.map(toExtendedJson);\n }\n\n if (typeof value === 'object' && value !== null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toExtendedJson(v)]));\n }\n\n return value;\n}\n\nexport function toExtendedJsonString(\n value: any,\n replacer?: (this: any, key: string, value: any) => any,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(\n value: any,\n replacer?: (number | string)[] | null,\n space?: string | number,\n): string;\nexport function toExtendedJsonString(value: unknown, ...args: any[]): string {\n return JSON.stringify(toExtendedJson(value), ...args);\n}\n\nexport function fromExtendedJson(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n\n if ('__map' in value) {\n return new Map(\n (value.__map as [unknown, unknown][]).map(([k, v]) => [\n fromExtendedJson(k),\n fromExtendedJson(v),\n ]),\n );\n }\n\n if ('__set' in value) {\n return new Set((value.__set as unknown[]).map(fromExtendedJson));\n }\n\n if ('__date' in value) {\n return new Date(value.__date as string);\n }\n\n if ('__bigint' in value) {\n return BigInt(value.__bigint as string);\n }\n\n if (Array.isArray(value)) {\n return value.map(fromExtendedJson);\n }\n\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, fromExtendedJson(v)]));\n}\n\nexport function fromExtendedJsonString(\n value: string,\n reviver?: (this: any, key: string, value: any) => any,\n): unknown {\n return fromExtendedJson(JSON.parse(value, reviver));\n}\n"],"mappings":";;;AAcA,SAAgB,KACd,GACA,GACA,UAAuB,EAAE,EACoB;CAC7C,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,GAAG,QAAQ,CAAC;AAIxC,QAAO,CAHS,OAAO,KAAK,CAAC,WAAW,MAAM,EACvB,OAAO,KAAK,GAAG,kBAAkB,aAAa,CAErC;;AAGlC,UAAU,MACR,GACA,GACA,SACA,SAAoB,EAAE,EACyB;AAC/C,KAAI,MAAM,EACR;AAGF,KACG,OAAO,QAAQ,WAAW,YAAY,OAAO,UAAU,QAAQ,UAC/D,OAAO,QAAQ,WAAW,cAAc,QAAQ,OAAO,OAAO,EAC/D;AACA,MAAIA,6BAAU,GAAG,EAAE,CACjB;AAGF,SAAO,MAAM,CACX;GAAE,IAAI;GAAW,MAAM;GAAQ,OAAO;GAAG,EACzC;GAAE,IAAI;GAAW,MAAM;GAAQ,OAAO;GAAG,CAC1C;;AAGH,KAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,MAAI,EAAE,SAAS,KAAK,EAAE,SAAS,CAC7B;AAGF,SAAO,MAAM,CACX;GAAE,IAAI;GAAW,MAAM;GAAQ,OAAO;GAAG,EACzC;GAAE,IAAI;GAAW,MAAM;GAAQ,OAAO;GAAG,CAC1C;;AAGH,KAAI,aAAa,OAAO,aAAa,IACnC,QAAO,OAAO,QAAQ,GAAG,GAAG,SAAS,OAAO;AAG9C,KAAI,aAAa,OAAO,aAAa,K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AAgB,qBAAqB,OAAgB,GAAG,MAAqB;AAC3E,QAAO,KAAK,UAAU,eAAe,MAAM,EAAE,GAAG,KAAK;;AAGvD,SAAgB,iBAAiB,OAAyB;AACxD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;AAGT,KAAI,WAAW,MACb,QAAO,IAAI,IACR,MAAM,MAA+B,KAAK,CAAC,GAAG,OAAO,CACpD,iBAAiB,EAAE,EACnB,iBAAiB,EAAE,CACpB,CAAC,CACH;AAGH,KAAI,WAAW,MACb,QAAO,IAAI,IAAK,MAAM,MAAoB,IAAI,iBAAiB,CAAC;AAGlE,KAAI,YAAY,MACd,QAAO,IAAI,KAAK,MAAM,OAAiB;AAGzC,KAAI,cAAc,MAChB,QAAO,OAAO,MAAM,SAAmB;AAGzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,iBAAiB;AAGpC,QAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB,EAAE,CAAC,CAAC,CAAC;;AAG5F,SAAgB,uBACd,OACA,SACS;AACT,QAAO,iBAAiB,KAAK,MAAM,OAAO,QAAQ,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_store = require('./store-CPqOf4y5.cjs');
|
|
2
2
|
const require_propAccess = require('./propAccess-udIdjqwY.cjs');
|
|
3
3
|
const require_scope = require('./scope-DkX72a-2.cjs');
|
|
4
|
-
const require_patchMethods = require('./patchMethods-
|
|
5
|
-
const require_extendedJson = require('./extendedJson-
|
|
6
|
-
const require_persist = require('./persist-
|
|
4
|
+
const require_patchMethods = require('./patchMethods-CZje49Dk.cjs');
|
|
5
|
+
const require_extendedJson = require('./extendedJson-DzXMFE1P.cjs');
|
|
6
|
+
const require_persist = require('./persist-CG1WHP6D.cjs');
|
|
7
7
|
|
|
8
8
|
//#region src/core/pagedCache.ts
|
|
9
9
|
var PagedCache = class PagedCache extends require_scope.Cache {
|
|
@@ -100,7 +100,7 @@ exports.createResourceGroup = require_scope.createResourceGroup;
|
|
|
100
100
|
exports.createScope = require_scope.createScope;
|
|
101
101
|
exports.createStore = require_store.createStore;
|
|
102
102
|
exports.deepEqual = require_propAccess.deepEqual;
|
|
103
|
-
exports.diff =
|
|
103
|
+
exports.diff = require_extendedJson.diff;
|
|
104
104
|
exports.findOrDefault = findOrDefault;
|
|
105
105
|
exports.fromExtendedJson = require_extendedJson.fromExtendedJson;
|
|
106
106
|
exports.fromExtendedJsonString = require_extendedJson.fromExtendedJsonString;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-8uUaV6I8.cjs";
|
|
2
2
|
import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-21GsOOLS.cjs";
|
|
3
|
-
import { n as Patch, r as diff } from "./diff-
|
|
3
|
+
import { n as Patch, r as diff } from "./diff-Bcr0h7-x.cjs";
|
|
4
4
|
import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-CkZ7CzW8.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/core/pagedCache.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as ValueState, a as CacheFunction, c as CreateCacheResult, d as ResourceGroup, f as allResources, g as PendingState, h as ErrorState, i as CacheBundle, l as createCache, m as CacheState, n as createScope, o as CacheGetOptions, p as createResourceGroup, r as Cache, s as CacheOptions, t as Scope, u as Resource } from "./scope-qdOAlRWQ.js";
|
|
2
2
|
import { B as Value, C as Selector, D as UpdateFunction, E as UpdateFrom, F as PathAsString, I as SettablePath, K as Constrain, L as SettablePathAsArray, M as KeyType, N as Path, O as Use, P as PathAsArray, R as SettablePathAsString, S as Listener, T as Update, _ as Connection, a as StoreOptions, b as Duration, c as arrayMethods, d as setMethods, f as AsyncConnectionActions, g as Cancel, h as CalculationActions, i as StoreMethods, l as mapMethods, m as BaseConnectionActions, o as StoreOptionsWithMethods, p as AsyncUpdateFunction, r as Store, s as createStore, t as BoundStoreMethods, u as recordMethods, v as ConnectionActions, w as SubscribeOptions, x as Effect, y as DisposableCancel, z as SettableValue } from "./store-Cq1PqvEo.js";
|
|
3
|
-
import { n as Patch, r as diff } from "./diff-
|
|
3
|
+
import { n as Patch, r as diff } from "./diff-CwiTYAVK.js";
|
|
4
4
|
import { a as PersistStorageBase, c as PersistStorageWithListItems, i as PersistStorage, n as PersistOptions, o as PersistStorageWithKeys, r as persist, s as PersistStorageWithLength, t as Persist } from "./persist-3Nff6j1f.js";
|
|
5
5
|
|
|
6
6
|
//#region src/core/pagedCache.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as mapMethods, h as autobind, i as arrayMethods, m as calcDuration, n as createStore, o as recordMethods, s as setMethods, t as Store } from "./store-D4q5zD7q.js";
|
|
2
2
|
import { a as set, c as deepEqual, l as shallowEqual, n as get, u as strictEqual } from "./propAccess-BxCKNeOj.js";
|
|
3
3
|
import { a as defaultCacheOptions, c as allResources, d as hash, f as simpleHash, i as createCache, l as createResourceGroup, n as createScope, o as internalCreate, r as Cache, s as ResourceGroup, t as Scope, u as InstanceCache } from "./scope-CQE3HDNI.js";
|
|
4
|
-
import {
|
|
5
|
-
import { i as toExtendedJsonString, n as fromExtendedJsonString, r as toExtendedJson, t as fromExtendedJson } from "./extendedJson-
|
|
6
|
-
import { t as persist } from "./persist-
|
|
4
|
+
import { r as applyPatches } from "./patchMethods-Cui462lc.js";
|
|
5
|
+
import { a as diff, i as toExtendedJsonString, n as fromExtendedJsonString, r as toExtendedJson, t as fromExtendedJson } from "./extendedJson-DA3RQ_ly.js";
|
|
6
|
+
import { t as persist } from "./persist-CNA2sYtB.js";
|
|
7
7
|
|
|
8
8
|
//#region src/core/pagedCache.ts
|
|
9
9
|
var PagedCache = class PagedCache extends Cache {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as Cancel, r as Store, w as SubscribeOptions, y as DisposableCancel } from "./store-Cq1PqvEo.js";
|
|
2
|
-
import { n as Patch, t as DiffOptions } from "./diff-
|
|
2
|
+
import { n as Patch, t as DiffOptions } from "./diff-CwiTYAVK.js";
|
|
3
3
|
|
|
4
4
|
//#region src/patches/patchMethods.d.ts
|
|
5
5
|
interface SyncMessage {
|
|
@@ -45,4 +45,4 @@ declare const patchMethods: {
|
|
|
45
45
|
};
|
|
46
46
|
//#endregion
|
|
47
47
|
export { SyncMessage as n, patchMethods as r, SubscribePatchOptions as t };
|
|
48
|
-
//# sourceMappingURL=patchMethods-
|
|
48
|
+
//# sourceMappingURL=patchMethods-C21iQqML.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_propAccess = require('./propAccess-udIdjqwY.cjs');
|
|
2
|
-
const require_extendedJson = require('./extendedJson-
|
|
2
|
+
const require_extendedJson = require('./extendedJson-DzXMFE1P.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/lib/applyPatches.ts
|
|
5
5
|
function applySinglePatch(target, patch) {
|
|
@@ -11,113 +11,6 @@ function applyPatches(target, ...patches) {
|
|
|
11
11
|
return target;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/lib/diff.ts
|
|
16
|
-
function diff(a, b, options = {}) {
|
|
17
|
-
const result = [..._diff(a, b, options)];
|
|
18
|
-
return [result.map(([patch]) => patch), result.map(([, reversePatch]) => reversePatch)];
|
|
19
|
-
}
|
|
20
|
-
function* _diff(a, b, options, prefix = []) {
|
|
21
|
-
if (a === b) return;
|
|
22
|
-
if (typeof options.stopAt === "number" && prefix.length >= options.stopAt || typeof options.stopAt === "function" && options.stopAt(prefix)) {
|
|
23
|
-
if (require_propAccess.deepEqual(a, b)) return;
|
|
24
|
-
return yield [{
|
|
25
|
-
op: "replace",
|
|
26
|
-
path: prefix,
|
|
27
|
-
value: b
|
|
28
|
-
}, {
|
|
29
|
-
op: "replace",
|
|
30
|
-
path: prefix,
|
|
31
|
-
value: a
|
|
32
|
-
}];
|
|
33
|
-
}
|
|
34
|
-
if (a instanceof Date && b instanceof Date) {
|
|
35
|
-
if (a.getTime() === b.getTime()) return;
|
|
36
|
-
return yield [{
|
|
37
|
-
op: "replace",
|
|
38
|
-
path: prefix,
|
|
39
|
-
value: b
|
|
40
|
-
}, {
|
|
41
|
-
op: "replace",
|
|
42
|
-
path: prefix,
|
|
43
|
-
value: a
|
|
44
|
-
}];
|
|
45
|
-
}
|
|
46
|
-
if (a instanceof Map && b instanceof Map) return yield* mapDiff(a, b, options, prefix);
|
|
47
|
-
if (a instanceof Set && b instanceof Set) {
|
|
48
|
-
if (require_propAccess.deepEqual(a, b)) return;
|
|
49
|
-
return yield [{
|
|
50
|
-
op: "replace",
|
|
51
|
-
path: prefix,
|
|
52
|
-
value: b
|
|
53
|
-
}, {
|
|
54
|
-
op: "replace",
|
|
55
|
-
path: prefix,
|
|
56
|
-
value: a
|
|
57
|
-
}];
|
|
58
|
-
}
|
|
59
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
60
|
-
if (require_propAccess.deepEqual(a, b)) return;
|
|
61
|
-
return yield [{
|
|
62
|
-
op: "replace",
|
|
63
|
-
path: prefix,
|
|
64
|
-
value: b
|
|
65
|
-
}, {
|
|
66
|
-
op: "replace",
|
|
67
|
-
path: prefix,
|
|
68
|
-
value: a
|
|
69
|
-
}];
|
|
70
|
-
}
|
|
71
|
-
if (require_propAccess.isObject(a) && require_propAccess.isObject(b) && !Array.isArray(a) && !Array.isArray(b)) return yield* objectDiff(a, b, options, prefix);
|
|
72
|
-
yield [{
|
|
73
|
-
op: "replace",
|
|
74
|
-
path: prefix,
|
|
75
|
-
value: b
|
|
76
|
-
}, {
|
|
77
|
-
op: "replace",
|
|
78
|
-
path: prefix,
|
|
79
|
-
value: a
|
|
80
|
-
}];
|
|
81
|
-
}
|
|
82
|
-
function* mapDiff(a, b, options, prefix) {
|
|
83
|
-
for (const [key, value] of a) if (!b.has(key)) yield [{
|
|
84
|
-
op: "remove",
|
|
85
|
-
path: [...prefix, key]
|
|
86
|
-
}, {
|
|
87
|
-
op: "add",
|
|
88
|
-
path: [...prefix, key],
|
|
89
|
-
value
|
|
90
|
-
}];
|
|
91
|
-
else yield* _diff(value, b.get(key), options, [...prefix, key]);
|
|
92
|
-
for (const [key, value] of b) if (!a.has(key)) yield [{
|
|
93
|
-
op: "add",
|
|
94
|
-
path: [...prefix, key],
|
|
95
|
-
value
|
|
96
|
-
}, {
|
|
97
|
-
op: "remove",
|
|
98
|
-
path: [...prefix, key]
|
|
99
|
-
}];
|
|
100
|
-
}
|
|
101
|
-
function* objectDiff(a, b, options, prefix) {
|
|
102
|
-
for (const [key, value] of Object.entries(a)) if (!(key in b)) yield [{
|
|
103
|
-
op: "remove",
|
|
104
|
-
path: [...prefix, key]
|
|
105
|
-
}, {
|
|
106
|
-
op: "add",
|
|
107
|
-
path: [...prefix, key],
|
|
108
|
-
value
|
|
109
|
-
}];
|
|
110
|
-
else yield* _diff(value, b[key], options, [...prefix, key]);
|
|
111
|
-
for (const [key, value] of Object.entries(b)) if (!(key in a)) yield [{
|
|
112
|
-
op: "add",
|
|
113
|
-
path: [...prefix, key],
|
|
114
|
-
value
|
|
115
|
-
}, {
|
|
116
|
-
op: "remove",
|
|
117
|
-
path: [...prefix, key]
|
|
118
|
-
}];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
14
|
//#endregion
|
|
122
15
|
//#region src/lib/trie.ts
|
|
123
16
|
var TrieNode = class {
|
|
@@ -164,7 +57,7 @@ function subscribePatches(listener, options = {}) {
|
|
|
164
57
|
let cursor = options.startAt ?? (options.runNow ? void 0 : this.__patches.version);
|
|
165
58
|
return this.subscribe(function(value) {
|
|
166
59
|
if (patches.value !== value) {
|
|
167
|
-
const result = diff(patches.value, value, options);
|
|
60
|
+
const result = require_extendedJson.diff(patches.value, value, options);
|
|
168
61
|
patches.value = value;
|
|
169
62
|
if (result[0].length > 0) {
|
|
170
63
|
const newVersion = genId();
|
|
@@ -181,7 +74,7 @@ function subscribePatches(listener, options = {}) {
|
|
|
181
74
|
const index = patches.history.findIndex((h) => h.fromVersion === cursor);
|
|
182
75
|
let forward, backward, previousVersion;
|
|
183
76
|
if (index === -1) {
|
|
184
|
-
[forward, backward] = diff(void 0, value, options);
|
|
77
|
+
[forward, backward] = require_extendedJson.diff(void 0, value, options);
|
|
185
78
|
previousVersion = void 0;
|
|
186
79
|
} else {
|
|
187
80
|
forward = patches.history.slice(index).flatMap((h) => h.patches);
|
|
@@ -241,12 +134,6 @@ Object.defineProperty(exports, 'applyPatches', {
|
|
|
241
134
|
return applyPatches;
|
|
242
135
|
}
|
|
243
136
|
});
|
|
244
|
-
Object.defineProperty(exports, 'diff', {
|
|
245
|
-
enumerable: true,
|
|
246
|
-
get: function () {
|
|
247
|
-
return diff;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
137
|
Object.defineProperty(exports, 'patchMethods', {
|
|
251
138
|
enumerable: true,
|
|
252
139
|
get: function () {
|
|
@@ -259,4 +146,4 @@ Object.defineProperty(exports, 'subscribePatches', {
|
|
|
259
146
|
return subscribePatches;
|
|
260
147
|
}
|
|
261
148
|
});
|
|
262
|
-
//# sourceMappingURL=patchMethods-
|
|
149
|
+
//# sourceMappingURL=patchMethods-CZje49Dk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchMethods-CZje49Dk.cjs","names":["remove","set","diff","applyPatches","_applyPatches","toExtendedJson","fromExtendedJson","patchMethods: {\n subscribePatches: typeof subscribePatches;\n applyPatches: typeof applyPatches;\n sync: typeof sync;\n acceptSync: typeof acceptSync;\n}"],"sources":["../src/lib/applyPatches.ts","../src/lib/trie.ts","../src/patches/patchMethods.ts"],"sourcesContent":["import type { Patch } from './diff';\nimport { remove, set } from './propAccess';\n\nfunction applySinglePatch<T>(target: T, patch: Patch): T {\n if (patch.op === 'remove') {\n return remove(target, patch.path as any);\n }\n\n return set(target, patch.path as any, patch.value);\n}\n\nexport function applyPatches<T>(target: T, ...patches: Patch[]): T {\n for (const patch of patches) {\n target = applySinglePatch(target, patch);\n }\n\n return target;\n}\n","import type { KeyType } from '@lib/path';\n\nclass TrieNode {\n children: Map<KeyType, TrieNode> = new Map();\n isLeaf = false;\n}\n\nexport class Trie {\n root: TrieNode = new TrieNode();\n\n add(path: KeyType[]): void {\n let node = this.root;\n for (const key of path) {\n let next = node.children.get(key);\n if (!next) node.children.set(key, (next = new TrieNode()));\n node = next;\n }\n node.isLeaf = true;\n }\n\n hasSubPath(path: KeyType[]): boolean {\n let node = this.root;\n for (const key of path) {\n const next = node.children.get(key);\n if (!next) return false;\n node = next;\n }\n return node.isLeaf;\n }\n}\n","import type { Cancel, DisposableCancel, SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { applyPatches as _applyPatches } from '@lib/applyPatches';\nimport { diff, type DiffOptions, type Patch } from '@lib/diff';\nimport { fromExtendedJson, toExtendedJson } from '@lib/extendedJson';\nimport { Trie } from '@lib/trie';\n\nexport interface SyncMessage {\n fromVersion?: string;\n toVersion: string;\n patches: Patch[];\n}\n\nexport interface HistoryEntry extends SyncMessage {\n reversePatches: Patch[];\n}\n\ndeclare module '..' {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Store<T> {\n __patches?: {\n value: T;\n version: string;\n history: HistoryEntry[];\n };\n }\n}\n\nexport interface SubscribePatchOptions extends SubscribeOptions, DiffOptions {\n /** @default false */\n runNow?: boolean;\n /** try to start from a specific version and only receive patches after that.\n * If the id is not found, it will start from the beginning */\n startAt?: string;\n}\n\nexport type InteropPatch = Patch | { op: 'add' | 'replace' | 'remove'; value?: any };\n\nconst genId = () => Math.random().toString(36).slice(2);\n\nexport function subscribePatches<T>(\n this: Store<T>,\n listener: (\n this: { cancel: Cancel },\n patches: Patch[],\n reversePatches: Patch[],\n version: string,\n previousVersion: string | undefined,\n ) => void,\n options: SubscribePatchOptions = {},\n): DisposableCancel {\n const patches = (this.__patches ??= {\n value: this.get(),\n version: genId(),\n history: [],\n });\n\n options = { ...options };\n options.runNow ??= false;\n let cursor = options.startAt ?? (options.runNow ? undefined : this.__patches.version);\n\n return this.subscribe(function (value) {\n if (patches.value !== value) {\n const result = diff(patches.value, value, options);\n patches.value = value;\n\n if (result[0].length > 0) {\n const newVersion = genId();\n\n patches.history = patches.history\n .concat({\n fromVersion: patches.version,\n toVersion: newVersion,\n patches: result[0],\n reversePatches: result[1],\n })\n .slice(-1000);\n\n patches.version = newVersion;\n }\n }\n\n if (cursor === patches.version) return;\n const index = patches.history.findIndex((h) => h.fromVersion === cursor);\n let forward, backward, previousVersion;\n\n if (index === -1) {\n [forward, backward] = diff(undefined, value, options);\n previousVersion = undefined;\n } else {\n forward = patches.history.slice(index).flatMap((h) => h.patches);\n backward = patches.history.slice(index).flatMap((h) => h.reversePatches);\n previousVersion = cursor;\n }\n\n cursor = patches.version;\n listener.apply(this, [forward, backward, cursor, previousVersion]);\n }, options);\n}\n\nexport function applyPatches<T>(this: Store<T>, patches: InteropPatch[]): void;\nexport function applyPatches<T>(this: Store<T>, ...patches: InteropPatch[]): void;\nexport function applyPatches<T>(\n this: Store<T>,\n ...patches: (InteropPatch | InteropPatch[])[]\n): void {\n this.set((value) => _applyPatches(value, ...(patches.flat() as Patch[])));\n}\n\nexport function sync<T>(\n this: Store<T>,\n listener: (syncMessage: SyncMessage) => void,\n options?: Omit<SubscribePatchOptions, 'runNow'>,\n): DisposableCancel {\n const debounce =\n typeof options?.debounce === 'object' && 'wait' in options.debounce\n ? { ...options.debounce }\n : options?.debounce !== undefined\n ? { wait: options.debounce }\n : undefined;\n\n if (debounce) {\n debounce.waitOnRunNow ??= false;\n }\n\n return subscribePatches.apply<\n Store<T>,\n Parameters<typeof subscribePatches<T>>,\n ReturnType<typeof subscribePatches<T>>\n >(this, [\n (patches, _, version, previousVersion) => {\n const trie = new Trie();\n\n patches = [...patches]\n .reverse()\n .filter((patch) => {\n if (trie.hasSubPath(patch.path)) {\n return false;\n }\n\n trie.add(patch.path);\n return true;\n })\n .reverse();\n\n listener({\n fromVersion: previousVersion,\n toVersion: version,\n patches: toExtendedJson(patches) as Patch[],\n });\n },\n { ...options, debounce, runNow: true },\n ]);\n}\n\nexport function acceptSync<T>(this: Store<T>, message: SyncMessage): void {\n if (message.fromVersion && message.fromVersion !== this.version) {\n throw new Error(\n `version mismatch! version=${this.version}, fromVersion=${message.fromVersion}`,\n );\n }\n\n const patches = fromExtendedJson(message.patches) as Patch[];\n\n this.version = message.toVersion;\n applyPatches.apply<Store<T>, Patch[], void>(this, patches);\n}\n\nexport const patchMethods: {\n subscribePatches: typeof subscribePatches;\n applyPatches: typeof applyPatches;\n sync: typeof sync;\n acceptSync: typeof acceptSync;\n} = {\n subscribePatches,\n applyPatches,\n sync,\n acceptSync,\n};\n"],"mappings":";;;;AAGA,SAAS,iBAAoB,QAAW,OAAiB;AACvD,KAAI,MAAM,OAAO,SACf,QAAOA,0BAAO,QAAQ,MAAM,KAAY;A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