@ibyar/platform 3.0.0 → 4.0.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/LICENSE +1 -1
- package/package.json +5 -4
- package/patch/diff.d.ts +12 -15
- package/patch/diff.d.ts.map +1 -1
- package/patch/diff.js +33 -60
- package/patch/diff.js.map +1 -1
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibyar/platform",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Ibyar Platform, A utility package for Aurora",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ibyar/aurora/tree/dev/packages/platform",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"contributors": [
|
|
17
17
|
{
|
|
18
18
|
"name": "Muhammad Salem",
|
|
19
|
-
"email": "salem.ebo@gmail.com"
|
|
19
|
+
"email": "salem.ebo@gmail.com",
|
|
20
|
+
"url": "https://github.com/muhammad-salem"
|
|
20
21
|
}
|
|
21
22
|
],
|
|
22
23
|
"main": "./index.js",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"tslib": "^2.8.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"typescript": "^5.
|
|
40
|
+
"typescript": "^5.8.3"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "tsc --build --verbose",
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"platform",
|
|
49
50
|
"front-end"
|
|
50
51
|
],
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "6671356b7c827061a32d138db5cad660ad0053c5"
|
|
52
53
|
}
|
package/patch/diff.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export type TrackBy<T, R = T> = (index: number, item: T) => R;
|
|
|
2
2
|
export type DiffOptions<T, R = T> = {
|
|
3
3
|
trackBy?: TrackBy<T, R>;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* in memory patch operations
|
|
7
|
+
*/
|
|
5
8
|
export declare enum PatchOperation {
|
|
6
9
|
ADD = "add",
|
|
7
10
|
REMOVE = "remove",
|
|
8
|
-
|
|
9
|
-
MOVE = "move",
|
|
10
|
-
KEEP = "keep"
|
|
11
|
+
MOVE = "move"
|
|
11
12
|
}
|
|
12
13
|
export type PatchArray<T> = {
|
|
13
14
|
currentIndex: number;
|
|
@@ -19,19 +20,15 @@ export type PatchObject = {
|
|
|
19
20
|
key: string;
|
|
20
21
|
op: PatchOperation;
|
|
21
22
|
};
|
|
22
|
-
export declare const PatchRoot: {
|
|
23
|
-
op: PatchOperation;
|
|
24
|
-
root: boolean;
|
|
25
|
-
};
|
|
26
23
|
export type DiffPatch<T> = PatchArray<T> | PatchObject;
|
|
27
24
|
export declare class JSONPatch {
|
|
28
|
-
protected diffArray<T, R = T>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[]
|
|
29
|
-
protected diffObject<T = any>(input: T, output: T): PatchObject[]
|
|
30
|
-
diff<T = any>(input: T, output: T): PatchObject[]
|
|
31
|
-
diff<T>(input: T[], output: T[]): PatchArray<T>[]
|
|
32
|
-
diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[]
|
|
25
|
+
protected diffArray<T, R = T>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[];
|
|
26
|
+
protected diffObject<T = any>(input: T, output: T): PatchObject[];
|
|
27
|
+
diff<T = any>(input: T, output: T): PatchObject[];
|
|
28
|
+
diff<T>(input: T[], output: T[]): PatchArray<T>[];
|
|
29
|
+
diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[];
|
|
33
30
|
}
|
|
34
|
-
export declare function diff<T = any>(input: T, output: T): PatchObject[]
|
|
35
|
-
export declare function diff<T>(input: T[], output: T[]): PatchArray<T>[]
|
|
36
|
-
export declare function diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[]
|
|
31
|
+
export declare function diff<T = any>(input: T, output: T): PatchObject[];
|
|
32
|
+
export declare function diff<T>(input: T[], output: T[]): PatchArray<T>[];
|
|
33
|
+
export declare function diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[];
|
|
37
34
|
//# sourceMappingURL=diff.d.ts.map
|
package/patch/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/platform/patch/diff.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9D,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/platform/patch/diff.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9D,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAAE,CAAC;AAGhE;;GAEG;AACH,oBAAY,cAAc;IACzB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;CACb;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAA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C,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC"}
|
package/patch/diff.js
CHANGED
|
@@ -1,78 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* in memory patch operations
|
|
3
|
+
*/
|
|
1
4
|
export var PatchOperation;
|
|
2
5
|
(function (PatchOperation) {
|
|
3
6
|
PatchOperation["ADD"] = "add";
|
|
4
7
|
PatchOperation["REMOVE"] = "remove";
|
|
5
|
-
PatchOperation["REPLACE"] = "replace";
|
|
6
8
|
PatchOperation["MOVE"] = "move";
|
|
7
|
-
PatchOperation["KEEP"] = "keep";
|
|
8
9
|
})(PatchOperation || (PatchOperation = {}));
|
|
9
10
|
;
|
|
10
|
-
export const PatchRoot = { op: PatchOperation.REPLACE, root: true };
|
|
11
11
|
export class JSONPatch {
|
|
12
12
|
diffArray(input, output, options) {
|
|
13
13
|
const trackBy = options?.trackBy;
|
|
14
|
-
const identityInput = (trackBy && input.map((item, index) => trackBy(index, item))) ?? input;
|
|
15
|
-
const identityOutput = (trackBy && output.map((item, index) => trackBy(index, item))) ?? output;
|
|
16
|
-
const
|
|
17
|
-
identityInput.
|
|
14
|
+
const identityInput = (trackBy && input.map((item, index) => trackBy(index, item))) ?? input.slice();
|
|
15
|
+
const identityOutput = (trackBy && output.map((item, index) => trackBy(index, item))) ?? output.slice();
|
|
16
|
+
const diff = [];
|
|
17
|
+
for (let currentIndex = identityInput.length - 1; currentIndex >= 0; currentIndex--) {
|
|
18
|
+
const item = identityInput[currentIndex];
|
|
18
19
|
const nextIndex = identityOutput.indexOf(item);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: index == nextIndex
|
|
22
|
-
? PatchOperation.KEEP
|
|
23
|
-
: PatchOperation.MOVE;
|
|
24
|
-
diffArray.push({
|
|
25
|
-
currentIndex: index,
|
|
26
|
-
nextIndex: nextIndex,
|
|
27
|
-
op: op,
|
|
28
|
-
item: output[nextIndex]
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
identityOutput.forEach((item, index) => {
|
|
32
|
-
const oldIndex = identityInput.indexOf(item);
|
|
33
|
-
if (oldIndex == -1) {
|
|
34
|
-
diffArray.push({
|
|
35
|
-
currentIndex: -1,
|
|
36
|
-
nextIndex: index,
|
|
37
|
-
op: PatchOperation.ADD,
|
|
38
|
-
item: output[index]
|
|
39
|
-
});
|
|
20
|
+
if (nextIndex !== -1) {
|
|
21
|
+
continue;
|
|
40
22
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
diff.push({
|
|
24
|
+
nextIndex,
|
|
25
|
+
currentIndex,
|
|
26
|
+
op: PatchOperation.REMOVE,
|
|
27
|
+
item: input[currentIndex]
|
|
28
|
+
});
|
|
29
|
+
identityInput.splice(currentIndex, 1);
|
|
30
|
+
}
|
|
31
|
+
identityOutput.forEach((item, nextIndex) => {
|
|
32
|
+
const currentIndex = identityInput.indexOf(item);
|
|
33
|
+
if (currentIndex === nextIndex) {
|
|
46
34
|
return;
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
replacedItem.ignore = true;
|
|
58
|
-
patch = {
|
|
59
|
-
currentIndex: item.currentIndex,
|
|
60
|
-
nextIndex: replacedItem.nextIndex,
|
|
61
|
-
op: PatchOperation.REPLACE,
|
|
62
|
-
item: replacedItem.item
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
36
|
+
const op = currentIndex === -1 ? PatchOperation.ADD : PatchOperation.MOVE;
|
|
37
|
+
diff.push({
|
|
38
|
+
op,
|
|
39
|
+
nextIndex,
|
|
40
|
+
currentIndex,
|
|
41
|
+
item: output[nextIndex]
|
|
42
|
+
});
|
|
43
|
+
if (op === PatchOperation.MOVE) {
|
|
44
|
+
identityInput.splice(currentIndex, 1);
|
|
66
45
|
}
|
|
67
|
-
|
|
46
|
+
identityInput.splice(nextIndex, 0, item);
|
|
68
47
|
});
|
|
69
|
-
|
|
70
|
-
.filter(item => !item.ignore && PatchOperation.REMOVE == item.op)
|
|
71
|
-
.sort((a, b) => b.currentIndex - a.currentIndex);
|
|
72
|
-
const apply = patchArray
|
|
73
|
-
.filter(item => !item.ignore && PatchOperation.REMOVE != item.op)
|
|
74
|
-
.sort((a, b) => a.nextIndex - b.nextIndex);
|
|
75
|
-
return removed.concat(apply);
|
|
48
|
+
return diff;
|
|
76
49
|
}
|
|
77
50
|
diffObject(input, output) {
|
|
78
51
|
return [];
|
|
@@ -84,7 +57,7 @@ export class JSONPatch {
|
|
|
84
57
|
else if (typeof input == 'object' && typeof output == 'object') {
|
|
85
58
|
return this.diffObject(input, output);
|
|
86
59
|
}
|
|
87
|
-
|
|
60
|
+
throw new Error('Not supported operation');
|
|
88
61
|
}
|
|
89
62
|
}
|
|
90
63
|
const jsonPatch = new JSONPatch();
|
package/patch/diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/platform/patch/diff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/platform/patch/diff.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACzB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IACjB,+BAAa,CAAA;AACd,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAAA,CAAC;AAMF,MAAM,OAAO,SAAS;IAEX,SAAS,CAAW,KAAU,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AAC;AAC/C,CAAC","sourcesContent":["export type TrackBy<T, R = T> = (index: number, item: T) => R;\nexport type DiffOptions<T, R = T> = { trackBy?: TrackBy<T, R> };\n\n\n/**\n * in memory patch operations\n */\nexport enum PatchOperation {\n\tADD = 'add',\n\tREMOVE = 'remove',\n\tMOVE = 'move',\n};\n\nexport type PatchArray<T> = { currentIndex: number, nextIndex: number, op: PatchOperation, item: T };\nexport type PatchObject = { key: string, op: PatchOperation };\nexport type DiffPatch<T> = PatchArray<T> | PatchObject;\n\nexport class JSONPatch {\n\n\tprotected diffArray<T, R = T>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[] {\n\t\tconst trackBy = options?.trackBy;\n\t\tconst identityInput = (trackBy && input.map((item, index) => trackBy(index, item))) ?? input.slice() as unknown as R[];\n\t\tconst identityOutput = (trackBy && output.map((item, index) => trackBy(index, item))) ?? output.slice() as unknown as R[];\n\t\tconst diff: PatchArray<T>[] = [];\n\t\tfor (let currentIndex = identityInput.length - 1; currentIndex >= 0; currentIndex--) {\n\t\t\tconst item = identityInput[currentIndex];\n\t\t\tconst nextIndex = identityOutput.indexOf(item);\n\t\t\tif (nextIndex !== -1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tdiff.push({\n\t\t\t\tnextIndex,\n\t\t\t\tcurrentIndex,\n\t\t\t\top: PatchOperation.REMOVE,\n\t\t\t\titem: input[currentIndex]\n\t\t\t});\n\t\t\tidentityInput.splice(currentIndex, 1);\n\t\t}\n\t\tidentityOutput.forEach((item, nextIndex) => {\n\t\t\tconst currentIndex = identityInput.indexOf(item);\n\t\t\tif (currentIndex === nextIndex) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst op = currentIndex === -1 ? PatchOperation.ADD : PatchOperation.MOVE;\n\t\t\tdiff.push({\n\t\t\t\top,\n\t\t\t\tnextIndex,\n\t\t\t\tcurrentIndex,\n\t\t\t\titem: output[nextIndex]\n\t\t\t});\n\t\t\tif (op === PatchOperation.MOVE) {\n\t\t\t\tidentityInput.splice(currentIndex, 1);\n\t\t\t}\n\t\t\tidentityInput.splice(nextIndex, 0, item);\n\t\t});\n\t\treturn diff;\n\t}\n\n\tprotected diffObject<T = any>(input: T, output: T): PatchObject[] {\n\t\treturn [];\n\t}\n\n\tdiff<T = any>(input: T, output: T): PatchObject[];\n\tdiff<T>(input: T[], output: T[]): PatchArray<T>[];\n\tdiff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[];\n\tdiff(input: any, output: any, options?: DiffOptions<any, any>): DiffPatch<any>[] {\n\t\tif (Array.isArray(input) && Array.isArray(output)) {\n\t\t\treturn this.diffArray(input, output, options);\n\t\t} else if (typeof input == 'object' && typeof output == 'object') {\n\t\t\treturn this.diffObject(input, output);\n\t\t}\n\t\tthrow new Error('Not supported operation');\n\t}\n}\n\nconst jsonPatch = new JSONPatch();\n\nexport function diff<T = any>(input: T, output: T): PatchObject[];\nexport function diff<T>(input: T[], output: T[]): PatchArray<T>[];\nexport function diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[];\nexport function diff(input: any, output: any, options?: DiffOptions<any, any>): DiffPatch<any>[] {\n\treturn jsonPatch.diff(input, output, options);\n}\n"]}
|