@dabble/patches 0.4.4 → 0.4.6
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/algorithms/client/applyCommittedChanges.d.ts +8 -2
- package/dist/algorithms/client/applyCommittedChanges.js +30 -38
- package/dist/algorithms/client/batching.d.ts +8 -2
- package/dist/algorithms/client/batching.js +38 -37
- package/dist/algorithms/client/breakChange.d.ts +8 -2
- package/dist/algorithms/client/breakChange.js +191 -240
- package/dist/algorithms/client/createStateFromSnapshot.d.ts +8 -2
- package/dist/algorithms/client/createStateFromSnapshot.js +7 -8
- package/dist/algorithms/client/getJSONByteSize.d.ts +3 -1
- package/dist/algorithms/client/getJSONByteSize.js +12 -11
- package/dist/algorithms/client/makeChange.d.ts +8 -2
- package/dist/algorithms/client/makeChange.js +28 -36
- package/dist/algorithms/server/commitChanges.d.ts +9 -3
- package/dist/algorithms/server/commitChanges.js +69 -78
- package/dist/algorithms/server/createVersion.d.ts +9 -3
- package/dist/algorithms/server/createVersion.js +21 -27
- package/dist/algorithms/server/getSnapshotAtRevision.d.ts +9 -3
- package/dist/algorithms/server/getSnapshotAtRevision.js +27 -28
- package/dist/algorithms/server/getStateAtRevision.d.ts +9 -3
- package/dist/algorithms/server/getStateAtRevision.js +13 -17
- package/dist/algorithms/server/handleOfflineSessionsAndBatches.d.ts +9 -3
- package/dist/algorithms/server/handleOfflineSessionsAndBatches.js +60 -77
- package/dist/algorithms/server/transformIncomingChanges.d.ts +8 -2
- package/dist/algorithms/server/transformIncomingChanges.js +27 -39
- package/dist/algorithms/shared/applyChanges.d.ts +8 -2
- package/dist/algorithms/shared/applyChanges.js +11 -16
- package/dist/algorithms/shared/rebaseChanges.d.ts +8 -2
- package/dist/algorithms/shared/rebaseChanges.js +30 -49
- package/dist/chunk-IZ2YBCUP.js +56 -0
- package/dist/client/InMemoryStore.d.ts +9 -3
- package/dist/client/InMemoryStore.js +92 -101
- package/dist/client/IndexedDBStore.d.ts +9 -3
- package/dist/client/IndexedDBStore.js +378 -491
- package/dist/client/Patches.d.ts +18 -13
- package/dist/client/Patches.js +152 -207
- package/dist/client/PatchesDoc.d.ts +14 -8
- package/dist/client/PatchesDoc.js +147 -154
- package/dist/client/PatchesHistoryClient.d.ts +12 -5
- package/dist/client/PatchesHistoryClient.js +110 -117
- package/dist/client/PatchesStore.d.ts +9 -3
- package/dist/client/PatchesStore.js +0 -1
- package/dist/client/index.d.ts +12 -6
- package/dist/client/index.js +5 -5
- package/dist/data/change.d.ts +9 -3
- package/dist/data/change.js +23 -15
- package/dist/data/version.d.ts +9 -3
- package/dist/data/version.js +11 -15
- package/dist/event-signal.d.ts +7 -6
- package/dist/event-signal.js +24 -39
- package/dist/index-CvQws3AB.d.ts +36 -0
- package/dist/index.d.ts +27 -5
- package/dist/index.js +10 -4
- package/dist/json-patch/JSONPatch.d.ts +9 -5
- package/dist/json-patch/JSONPatch.js +175 -183
- package/dist/json-patch/applyPatch.d.ts +5 -2
- package/dist/json-patch/applyPatch.js +27 -35
- package/dist/json-patch/composePatch.d.ts +5 -2
- package/dist/json-patch/composePatch.js +34 -34
- package/dist/json-patch/createJSONPatch.d.ts +7 -2
- package/dist/json-patch/createJSONPatch.js +11 -38
- package/dist/json-patch/index.d.ts +14 -6
- package/dist/json-patch/index.js +20 -9
- package/dist/json-patch/invertPatch.d.ts +5 -2
- package/dist/json-patch/invertPatch.js +31 -30
- package/dist/json-patch/ops/add.d.ts +5 -2
- package/dist/json-patch/ops/add.js +53 -51
- package/dist/json-patch/ops/bitmask.d.ts +8 -5
- package/dist/json-patch/ops/bitmask.js +41 -44
- package/dist/json-patch/ops/copy.d.ts +5 -2
- package/dist/json-patch/ops/copy.js +32 -33
- package/dist/json-patch/ops/increment.d.ts +5 -2
- package/dist/json-patch/ops/increment.js +21 -20
- package/dist/json-patch/ops/index.d.ts +10 -21
- package/dist/json-patch/ops/index.js +34 -24
- package/dist/json-patch/ops/move.d.ts +5 -2
- package/dist/json-patch/ops/move.js +132 -198
- package/dist/json-patch/ops/remove.d.ts +5 -2
- package/dist/json-patch/ops/remove.js +33 -30
- package/dist/json-patch/ops/replace.d.ts +5 -2
- package/dist/json-patch/ops/replace.js +45 -43
- package/dist/json-patch/ops/test.d.ts +5 -2
- package/dist/json-patch/ops/test.js +25 -21
- package/dist/json-patch/ops/text.d.ts +5 -2
- package/dist/json-patch/ops/text.js +54 -54
- package/dist/json-patch/pathProxy.d.ts +9 -3
- package/dist/json-patch/pathProxy.js +27 -48
- package/dist/json-patch/state.d.ts +5 -2
- package/dist/json-patch/state.js +11 -7
- package/dist/json-patch/transformPatch.d.ts +6 -2
- package/dist/json-patch/transformPatch.js +21 -24
- package/dist/json-patch/types.d.ts +9 -7
- package/dist/json-patch/types.js +0 -1
- package/dist/json-patch/utils/deepEqual.d.ts +3 -1
- package/dist/json-patch/utils/deepEqual.js +32 -28
- package/dist/json-patch/utils/exit.d.ts +5 -2
- package/dist/json-patch/utils/exit.js +7 -3
- package/dist/json-patch/utils/get.d.ts +5 -2
- package/dist/json-patch/utils/get.js +8 -4
- package/dist/json-patch/utils/getOpData.d.ts +5 -2
- package/dist/json-patch/utils/getOpData.js +12 -9
- package/dist/json-patch/utils/getType.d.ts +6 -3
- package/dist/json-patch/utils/getType.js +9 -4
- package/dist/json-patch/utils/index.d.ts +15 -14
- package/dist/json-patch/utils/index.js +14 -14
- package/dist/json-patch/utils/log.d.ts +4 -2
- package/dist/json-patch/utils/log.js +8 -3
- package/dist/json-patch/utils/ops.d.ts +8 -5
- package/dist/json-patch/utils/ops.js +83 -100
- package/dist/json-patch/utils/paths.d.ts +12 -9
- package/dist/json-patch/utils/paths.js +54 -51
- package/dist/json-patch/utils/pluck.d.ts +8 -5
- package/dist/json-patch/utils/pluck.js +32 -26
- package/dist/json-patch/utils/shallowCopy.d.ts +3 -1
- package/dist/json-patch/utils/shallowCopy.js +22 -18
- package/dist/json-patch/utils/softWrites.d.ts +6 -3
- package/dist/json-patch/utils/softWrites.js +17 -16
- package/dist/json-patch/utils/toArrayIndex.d.ts +3 -1
- package/dist/json-patch/utils/toArrayIndex.js +14 -10
- package/dist/json-patch/utils/toKeys.d.ts +3 -1
- package/dist/json-patch/utils/toKeys.js +15 -11
- package/dist/json-patch/utils/updateArrayIndexes.d.ts +5 -2
- package/dist/json-patch/utils/updateArrayIndexes.js +33 -37
- package/dist/json-patch/utils/updateArrayPath.d.ts +5 -2
- package/dist/json-patch/utils/updateArrayPath.js +29 -42
- package/dist/net/PatchesClient.d.ts +128 -0
- package/dist/net/PatchesClient.js +161 -0
- package/dist/net/PatchesSync.d.ts +19 -9
- package/dist/net/PatchesSync.js +291 -386
- package/dist/net/error.d.ts +3 -1
- package/dist/net/error.js +9 -6
- package/dist/net/http/FetchTransport.d.ts +21 -0
- package/dist/net/http/FetchTransport.js +34 -0
- package/dist/net/index.d.ts +26 -12
- package/dist/net/index.js +12 -10
- package/dist/net/protocol/JSONRPCClient.d.ts +11 -4
- package/dist/net/protocol/JSONRPCClient.js +95 -103
- package/dist/net/protocol/JSONRPCServer.d.ts +15 -8
- package/dist/net/protocol/JSONRPCServer.js +101 -123
- package/dist/net/protocol/types.d.ts +21 -15
- package/dist/net/protocol/types.js +0 -1
- package/dist/net/protocol/utils.d.ts +12 -0
- package/dist/net/protocol/utils.js +15 -0
- package/dist/net/types.d.ts +4 -2
- package/dist/net/types.js +0 -1
- package/dist/net/webrtc/WebRTCAwareness.d.ts +14 -4
- package/dist/net/webrtc/WebRTCAwareness.js +111 -120
- package/dist/net/webrtc/WebRTCTransport.d.ts +16 -8
- package/dist/net/webrtc/WebRTCTransport.js +149 -157
- package/dist/net/webrtc/index.d.ts +10 -2
- package/dist/net/webrtc/index.js +2 -2
- package/dist/net/websocket/AuthorizationProvider.d.ts +7 -5
- package/dist/net/websocket/AuthorizationProvider.js +12 -17
- package/dist/net/websocket/PatchesWebSocket.d.ts +14 -109
- package/dist/net/websocket/PatchesWebSocket.js +37 -184
- package/dist/net/websocket/RPCServer.d.ts +19 -10
- package/dist/net/websocket/RPCServer.js +190 -192
- package/dist/net/websocket/SignalingService.d.ts +12 -32
- package/dist/net/websocket/SignalingService.js +126 -133
- package/dist/net/websocket/WebSocketServer.d.ts +17 -4
- package/dist/net/websocket/WebSocketServer.js +64 -72
- package/dist/net/websocket/WebSocketTransport.d.ts +13 -5
- package/dist/net/websocket/WebSocketTransport.js +178 -207
- package/dist/net/websocket/onlineState.d.ts +6 -3
- package/dist/net/websocket/onlineState.js +25 -21
- package/dist/server/PatchesBranchManager.d.ts +12 -5
- package/dist/server/PatchesBranchManager.js +132 -142
- package/dist/server/PatchesHistoryManager.d.ts +11 -3
- package/dist/server/PatchesHistoryManager.js +81 -84
- package/dist/server/PatchesServer.d.ts +16 -10
- package/dist/server/PatchesServer.js +131 -137
- package/dist/server/index.d.ts +7 -2
- package/dist/server/index.js +9 -3
- package/dist/server/types.d.ts +9 -3
- package/dist/server/types.js +0 -1
- package/dist/types.d.ts +49 -19
- package/dist/types.js +1 -1
- package/dist/utils/concurrency.d.ts +7 -5
- package/dist/utils/concurrency.js +43 -53
- package/dist/utils/deferred.d.ts +4 -2
- package/dist/utils/deferred.js +25 -21
- package/package.json +5 -7
package/dist/json-patch/index.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export * from
|
|
1
|
+
import "../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { applyPatch } from "./applyPatch.js";
|
|
3
|
+
import { composePatch } from "./composePatch.js";
|
|
4
|
+
import { invertPatch } from "./invertPatch.js";
|
|
5
|
+
import { applyBitmask, bitmask, combineBitmasks } from "./ops/bitmask.js";
|
|
6
|
+
import * as defaultOps from "./ops/index.js";
|
|
7
|
+
export * from "./pathProxy.js";
|
|
8
|
+
import { transformPatch } from "./transformPatch.js";
|
|
9
|
+
export * from "./JSONPatch.js";
|
|
10
|
+
export * from "./ops/index.js";
|
|
11
|
+
export {
|
|
12
|
+
applyBitmask,
|
|
13
|
+
applyPatch,
|
|
14
|
+
bitmask,
|
|
15
|
+
combineBitmasks,
|
|
16
|
+
composePatch,
|
|
17
|
+
defaultOps,
|
|
18
|
+
invertPatch,
|
|
19
|
+
transformPatch
|
|
20
|
+
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { JSONPatchOp, JSONPatchOpHandlerMap } from './types.js';
|
|
2
|
+
|
|
3
|
+
declare function invertPatch(object: any, ops: JSONPatchOp[], custom?: JSONPatchOpHandlerMap): JSONPatchOp[];
|
|
4
|
+
|
|
5
|
+
export { invertPatch };
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.reverse();
|
|
30
|
-
});
|
|
1
|
+
import "../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { getTypes } from "./ops/index.js";
|
|
3
|
+
import { runWithObject } from "./state.js";
|
|
4
|
+
import { getType } from "./utils/getType.js";
|
|
5
|
+
function invertPatch(object, ops, custom = {}) {
|
|
6
|
+
const types = getTypes(custom);
|
|
7
|
+
return runWithObject({}, types, false, (state) => {
|
|
8
|
+
return ops.map((op) => {
|
|
9
|
+
const pathParts = op.path.split("/").slice(1);
|
|
10
|
+
let changedObj = object;
|
|
11
|
+
const prop = pathParts.pop();
|
|
12
|
+
let value, isIndex;
|
|
13
|
+
try {
|
|
14
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
15
|
+
changedObj = changedObj[pathParts[i]];
|
|
16
|
+
}
|
|
17
|
+
value = changedObj[prop];
|
|
18
|
+
isIndex = prop >= 0;
|
|
19
|
+
} catch (err) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Patch mismatch. This patch was not applied to the provided object and cannot be inverted. ${err.message || err}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const handler = getType(state, op)?.invert;
|
|
25
|
+
if (!handler) throw new Error("Unknown patch operation, cannot invert");
|
|
26
|
+
return handler(state, op, value, changedObj, isIndex);
|
|
27
|
+
}).filter((op) => !!op).reverse();
|
|
28
|
+
});
|
|
31
29
|
}
|
|
30
|
+
export {
|
|
31
|
+
invertPatch
|
|
32
|
+
};
|
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import "../../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { deepEqual } from "../utils/deepEqual.js";
|
|
3
|
+
import { getOpData } from "../utils/getOpData.js";
|
|
4
|
+
import {
|
|
5
|
+
isArrayPath,
|
|
6
|
+
isEmptyObject,
|
|
7
|
+
log,
|
|
8
|
+
updateArrayIndexes,
|
|
9
|
+
updateRemovedOps,
|
|
10
|
+
updateSoftWrites
|
|
11
|
+
} from "../utils/index.js";
|
|
12
|
+
import { pluckWithShallowCopy } from "../utils/pluck.js";
|
|
13
|
+
import { toArrayIndex } from "../utils/toArrayIndex.js";
|
|
14
|
+
const add = {
|
|
15
|
+
like: "add",
|
|
16
|
+
apply(state, path, value) {
|
|
17
|
+
if (typeof value === "undefined") {
|
|
18
|
+
return "[op:add] require value, but got undefined";
|
|
19
|
+
}
|
|
20
|
+
const [keys, lastKey, target] = getOpData(state, path, true);
|
|
21
|
+
if (target === null) {
|
|
22
|
+
return `[op:add] path not found: ${path}`;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(target)) {
|
|
25
|
+
const index = toArrayIndex(target, lastKey);
|
|
26
|
+
if (index < 0 || target.length < index) {
|
|
27
|
+
return `[op:add] invalid array index: ${path}`;
|
|
28
|
+
}
|
|
29
|
+
pluckWithShallowCopy(state, keys, true).splice(index, 0, value);
|
|
30
|
+
} else {
|
|
31
|
+
if (!deepEqual(target[lastKey], value)) {
|
|
32
|
+
pluckWithShallowCopy(state, keys, true)[lastKey] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
invert(_state, { path }, value, changedObj, isIndex) {
|
|
37
|
+
if (path.endsWith("/-")) return { op: "remove", path: path.replace("-", changedObj.length) };
|
|
38
|
+
else if (isIndex) return { op: "remove", path };
|
|
39
|
+
return value === void 0 ? { op: "remove", path } : { op: "replace", path, value };
|
|
40
|
+
},
|
|
41
|
+
transform(state, thisOp, otherOps) {
|
|
42
|
+
log("Transforming", otherOps, 'against "add"', thisOp);
|
|
43
|
+
if (isArrayPath(thisOp.path, state)) {
|
|
44
|
+
return updateArrayIndexes(state, thisOp.path, otherOps, 1);
|
|
45
|
+
} else if (isEmptyObject(thisOp.value)) {
|
|
46
|
+
return updateSoftWrites(thisOp.path, otherOps);
|
|
47
|
+
} else {
|
|
48
|
+
return updateRemovedOps(state, thisOp.path, otherOps);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
add
|
|
52
54
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSONPatchOpHandler } from '../types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Create and maintain up to 15 boolean values in a single positive number (a bitmask). This can reduce the size of your
|
|
4
5
|
* JSON document. Limiting the bits to 15 allows us to keep the number smaller (max of 9 characters), positive, and
|
|
5
6
|
* allows us to combine multiple operations into a single number.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
declare const bit: JSONPatchOpHandler;
|
|
8
9
|
/**
|
|
9
10
|
* A helper function to create a mask number for bitmask operations. The bottom 15 bits are used to turn bits on, and
|
|
10
11
|
* the top 15 bits are used to turn bits off.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
declare function bitmask(index: number, value: boolean): number;
|
|
14
|
+
declare function applyBitmask(num: number, mask: number): number;
|
|
15
|
+
declare function combineBitmasks(a: number, b: number): number;
|
|
16
|
+
|
|
17
|
+
export { applyBitmask, bit, bitmask, combineBitmasks };
|
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
compose(_state, value1, value2) {
|
|
21
|
-
return combineBitmasks(value1, value2);
|
|
22
|
-
},
|
|
1
|
+
import "../../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { get } from "../utils/get.js";
|
|
3
|
+
import { updateRemovedOps } from "../utils/ops.js";
|
|
4
|
+
import { replace } from "./replace.js";
|
|
5
|
+
const bit = {
|
|
6
|
+
like: "replace",
|
|
7
|
+
apply(state, path, value) {
|
|
8
|
+
return replace.apply(state, path, applyBitmask(get(state, path) || 0, value || 0));
|
|
9
|
+
},
|
|
10
|
+
transform(state, thisOp, otherOps) {
|
|
11
|
+
return updateRemovedOps(state, thisOp.path, otherOps, false, true);
|
|
12
|
+
},
|
|
13
|
+
invert(state, op, value, changedObj, isIndex) {
|
|
14
|
+
return replace.invert(state, op, value, changedObj, isIndex);
|
|
15
|
+
},
|
|
16
|
+
compose(_state, value1, value2) {
|
|
17
|
+
return combineBitmasks(value1, value2);
|
|
18
|
+
}
|
|
23
19
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
export function bitmask(index, value) {
|
|
29
|
-
if (index < 0 || index > 14)
|
|
30
|
-
throw new Error('Index must be between 0 and 14');
|
|
31
|
-
return value ? 1 << index : 1 << (index + 15);
|
|
20
|
+
function bitmask(index, value) {
|
|
21
|
+
if (index < 0 || index > 14) throw new Error("Index must be between 0 and 14");
|
|
22
|
+
return value ? 1 << index : 1 << index + 15;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
function applyBitmask(num, mask) {
|
|
25
|
+
const offMask = mask >> 15 & 32767;
|
|
26
|
+
const onMask = mask & 32767;
|
|
27
|
+
num &= ~offMask;
|
|
28
|
+
num |= onMask;
|
|
29
|
+
return num;
|
|
39
30
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
function combineBitmasks(a, b) {
|
|
32
|
+
const aOff = a >> 15 & 32767;
|
|
33
|
+
const aOn = a & 32767;
|
|
34
|
+
const bOff = b >> 15 & 32767;
|
|
35
|
+
const bOn = b & 32767;
|
|
36
|
+
const combinedOn = aOn & ~bOff | bOn;
|
|
37
|
+
const combinedOff = aOff & ~bOn | bOff;
|
|
38
|
+
return combinedOff << 15 | combinedOn;
|
|
48
39
|
}
|
|
40
|
+
export {
|
|
41
|
+
applyBitmask,
|
|
42
|
+
bit,
|
|
43
|
+
bitmask,
|
|
44
|
+
combineBitmasks
|
|
45
|
+
};
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
1
|
+
import "../../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { getOpData } from "../utils/getOpData.js";
|
|
3
|
+
import { log } from "../utils/log.js";
|
|
4
|
+
import { updateRemovedOps } from "../utils/ops.js";
|
|
5
|
+
import { isArrayPath } from "../utils/paths.js";
|
|
6
|
+
import { updateArrayIndexes } from "../utils/updateArrayIndexes.js";
|
|
7
|
+
import { add } from "./add.js";
|
|
8
|
+
const copy = {
|
|
9
|
+
like: "copy",
|
|
10
|
+
apply(state, path, from) {
|
|
11
|
+
const [, lastKey, target] = getOpData(state, from);
|
|
12
|
+
if (target === null) {
|
|
13
|
+
return `[op:copy] path not found: ${from}`;
|
|
14
|
+
}
|
|
15
|
+
return add.apply(state, path, target[lastKey]);
|
|
16
|
+
},
|
|
17
|
+
invert(_state, { path }, value, changedObj, isIndex) {
|
|
18
|
+
if (path.endsWith("/-")) return { op: "remove", path: path.replace("-", changedObj.length) };
|
|
19
|
+
else if (isIndex) return { op: "remove", path };
|
|
20
|
+
return value === void 0 ? { op: "remove", path } : { op: "replace", path, value };
|
|
21
|
+
},
|
|
22
|
+
transform(state, thisOp, otherOps) {
|
|
23
|
+
log("Transforming", otherOps, 'against "add"', thisOp);
|
|
24
|
+
if (isArrayPath(thisOp.path, state)) {
|
|
25
|
+
return updateArrayIndexes(state, thisOp.path, otherOps, 1);
|
|
26
|
+
} else {
|
|
27
|
+
return updateRemovedOps(state, thisOp.path, otherOps);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
copy
|
|
34
33
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSONPatchOpHandler } from '../types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Increment or decrement a number (using `+` or `-`).
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare const increment: JSONPatchOpHandler;
|
|
7
|
+
|
|
8
|
+
export { increment };
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import "../../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { get } from "../utils/get.js";
|
|
3
|
+
import { updateRemovedOps } from "../utils/ops.js";
|
|
4
|
+
import { replace } from "./replace.js";
|
|
5
|
+
const increment = {
|
|
6
|
+
like: "replace",
|
|
7
|
+
apply(state, path, value) {
|
|
8
|
+
return replace.apply(state, path, (get(state, path) || 0) + value);
|
|
9
|
+
},
|
|
10
|
+
transform(state, thisOp, otherOps) {
|
|
11
|
+
return updateRemovedOps(state, thisOp.path, otherOps, false, true);
|
|
12
|
+
},
|
|
13
|
+
invert(state, op, value, changedObj, isIndex) {
|
|
14
|
+
return replace.invert(state, op, value, changedObj, isIndex);
|
|
15
|
+
},
|
|
16
|
+
compose(_state, value1, value2) {
|
|
17
|
+
return value1 + value2;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
increment
|
|
21
22
|
};
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
export declare function getTypes(custom?: JSONPatchOpHandlerMap): {
|
|
12
|
-
test: import("../types.js").JSONPatchOpHandler;
|
|
13
|
-
add: import("../types.js").JSONPatchOpHandler;
|
|
14
|
-
remove: import("../types.js").JSONPatchOpHandler;
|
|
15
|
-
replace: import("../types.js").JSONPatchOpHandler;
|
|
16
|
-
copy: import("../types.js").JSONPatchOpHandler;
|
|
17
|
-
move: import("../types.js").JSONPatchOpHandler;
|
|
18
|
-
'@inc': import("../types.js").JSONPatchOpHandler;
|
|
19
|
-
'@bit': import("../types.js").JSONPatchOpHandler;
|
|
20
|
-
'@txt': import("../types.js").JSONPatchOpHandler;
|
|
21
|
-
};
|
|
1
|
+
import '../types.js';
|
|
2
|
+
export { add } from './add.js';
|
|
3
|
+
export { bit } from './bitmask.js';
|
|
4
|
+
export { copy } from './copy.js';
|
|
5
|
+
export { increment } from './increment.js';
|
|
6
|
+
export { move } from './move.js';
|
|
7
|
+
export { remove } from './remove.js';
|
|
8
|
+
export { replace } from './replace.js';
|
|
9
|
+
export { test } from './test.js';
|
|
10
|
+
export { g as getTypes } from '../../index-CvQws3AB.js';
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
1
|
+
import "../../chunk-IZ2YBCUP.js";
|
|
2
|
+
import { add } from "./add.js";
|
|
3
|
+
import { bit } from "./bitmask.js";
|
|
4
|
+
import { copy } from "./copy.js";
|
|
5
|
+
import { increment } from "./increment.js";
|
|
6
|
+
import { move } from "./move.js";
|
|
7
|
+
import { remove } from "./remove.js";
|
|
8
|
+
import { replace } from "./replace.js";
|
|
9
|
+
import { test } from "./test.js";
|
|
10
|
+
import { text } from "./text.js";
|
|
11
|
+
function getTypes(custom) {
|
|
12
|
+
return {
|
|
13
|
+
test,
|
|
14
|
+
add,
|
|
15
|
+
remove,
|
|
16
|
+
replace,
|
|
17
|
+
copy,
|
|
18
|
+
move,
|
|
19
|
+
"@inc": increment,
|
|
20
|
+
"@bit": bit,
|
|
21
|
+
"@txt": text,
|
|
22
|
+
...custom
|
|
23
|
+
};
|
|
25
24
|
}
|
|
25
|
+
export {
|
|
26
|
+
add,
|
|
27
|
+
bit,
|
|
28
|
+
copy,
|
|
29
|
+
getTypes,
|
|
30
|
+
increment,
|
|
31
|
+
move,
|
|
32
|
+
remove,
|
|
33
|
+
replace,
|
|
34
|
+
test
|
|
35
|
+
};
|