@jbrowse/mobx-state-tree 5.6.0 → 5.6.2
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/README.md +18 -0
- package/dist/core/action.d.ts +1 -1
- package/dist/core/action.js +228 -0
- package/dist/core/action.js.map +1 -1
- package/dist/core/actionContext.js +42 -0
- package/dist/core/actionContext.js.map +1 -1
- package/dist/core/flow.d.ts +1 -1
- package/dist/core/flow.js +180 -0
- package/dist/core/flow.js.map +1 -1
- package/dist/core/json-patch.js +133 -0
- package/dist/core/json-patch.js.map +1 -1
- package/dist/core/mst-operations.js +885 -0
- package/dist/core/mst-operations.js.map +1 -1
- package/dist/core/node/BaseNode.js +152 -0
- package/dist/core/node/BaseNode.js.map +1 -1
- package/dist/core/node/Hook.js +15 -0
- package/dist/core/node/Hook.js.map +1 -1
- package/dist/core/node/create-node.js +41 -0
- package/dist/core/node/create-node.js.map +1 -1
- package/dist/core/node/identifier-cache.js +115 -0
- package/dist/core/node/identifier-cache.js.map +1 -1
- package/dist/core/node/livelinessChecking.js +38 -0
- package/dist/core/node/livelinessChecking.js.map +1 -1
- package/dist/core/node/node-utils.js +165 -0
- package/dist/core/node/node-utils.js.map +1 -1
- package/dist/core/node/object-node.js +545 -0
- package/dist/core/node/object-node.js.map +1 -1
- package/dist/core/node/scalar-node.js +89 -0
- package/dist/core/node/scalar-node.js.map +1 -1
- package/dist/core/process.d.ts +1 -1
- package/dist/core/process.js +39 -0
- package/dist/core/process.js.map +1 -1
- package/dist/core/type/type-checker.js +154 -0
- package/dist/core/type/type-checker.js.map +1 -1
- package/dist/core/type/type.d.ts +1 -1
- package/dist/core/type/type.js +251 -0
- package/dist/core/type/type.js.map +1 -1
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.js +60 -0
- package/dist/internal.js.map +1 -1
- package/dist/middlewares/create-action-tracking-middleware.js +81 -0
- package/dist/middlewares/create-action-tracking-middleware.js.map +1 -1
- package/dist/middlewares/createActionTrackingMiddleware2.js +133 -0
- package/dist/middlewares/createActionTrackingMiddleware2.js.map +1 -1
- package/dist/middlewares/on-action.js +215 -0
- package/dist/middlewares/on-action.js.map +1 -1
- package/dist/mobx-state-tree.js +83 -6867
- package/dist/mobx-state-tree.module.js +83 -6789
- package/dist/types/complex-types/array.d.ts +1 -1
- package/dist/types/complex-types/array.js +352 -0
- package/dist/types/complex-types/array.js.map +1 -1
- package/dist/types/complex-types/map.d.ts +1 -1
- package/dist/types/complex-types/map.js +361 -0
- package/dist/types/complex-types/map.js.map +1 -1
- package/dist/types/complex-types/model.js +477 -0
- package/dist/types/complex-types/model.js.map +1 -1
- package/dist/types/index.js +38 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/primitives.js +182 -0
- package/dist/types/primitives.js.map +1 -1
- package/dist/types/utility-types/custom.js +110 -0
- package/dist/types/utility-types/custom.js.map +1 -1
- package/dist/types/utility-types/enumeration.js +34 -0
- package/dist/types/utility-types/enumeration.js.map +1 -1
- package/dist/types/utility-types/frozen.js +97 -0
- package/dist/types/utility-types/frozen.js.map +1 -1
- package/dist/types/utility-types/identifier.js +129 -0
- package/dist/types/utility-types/identifier.js.map +1 -1
- package/dist/types/utility-types/late.js +109 -0
- package/dist/types/utility-types/late.js.map +1 -1
- package/dist/types/utility-types/lazy.js +76 -0
- package/dist/types/utility-types/lazy.js.map +1 -1
- package/dist/types/utility-types/literal.js +63 -0
- package/dist/types/utility-types/literal.js.map +1 -1
- package/dist/types/utility-types/maybe.js +30 -0
- package/dist/types/utility-types/maybe.js.map +1 -1
- package/dist/types/utility-types/optional.js +140 -0
- package/dist/types/utility-types/optional.js.map +1 -1
- package/dist/types/utility-types/reference.d.ts +2 -2
- package/dist/types/utility-types/reference.js +392 -0
- package/dist/types/utility-types/reference.js.map +1 -1
- package/dist/types/utility-types/refinement.js +85 -0
- package/dist/types/utility-types/refinement.js.map +1 -1
- package/dist/types/utility-types/resilient.js +120 -0
- package/dist/types/utility-types/resilient.js.map +1 -1
- package/dist/types/utility-types/snapshotProcessor.js +161 -0
- package/dist/types/utility-types/snapshotProcessor.js.map +1 -1
- package/dist/types/utility-types/union.d.ts +1 -0
- package/dist/types/utility-types/union.js +245 -0
- package/dist/types/utility-types/union.js.map +1 -1
- package/dist/utils.js +483 -0
- package/dist/utils.js.map +1 -1
- package/package.json +25 -24
- package/changelog.md +0 -677
- package/dist/mobx-state-tree.umd.js +0 -6873
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitPatch = splitPatch;
|
|
4
|
+
exports.stripPatch = stripPatch;
|
|
5
|
+
exports.escapeJsonPath = escapeJsonPath;
|
|
6
|
+
exports.unescapeJsonPath = unescapeJsonPath;
|
|
7
|
+
exports.joinJsonPath = joinJsonPath;
|
|
8
|
+
exports.splitJsonPath = splitJsonPath;
|
|
9
|
+
const internal_ts_1 = require("../internal.js");
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
function splitPatch(patch) {
|
|
15
|
+
if (!("oldValue" in patch)) {
|
|
16
|
+
throw (0, internal_ts_1.fail)(`Patches without \`oldValue\` field cannot be inversed`);
|
|
17
|
+
}
|
|
18
|
+
return [stripPatch(patch), invertPatch(patch)];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
function stripPatch(patch) {
|
|
25
|
+
// strips `oldvalue` information from the patch, so that it becomes a patch conform the json-patch spec
|
|
26
|
+
// this removes the ability to undo the patch
|
|
27
|
+
switch (patch.op) {
|
|
28
|
+
case "add":
|
|
29
|
+
return { op: "add", path: patch.path, value: patch.value };
|
|
30
|
+
case "remove":
|
|
31
|
+
return { op: "remove", path: patch.path };
|
|
32
|
+
case "replace":
|
|
33
|
+
return { op: "replace", path: patch.path, value: patch.value };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function invertPatch(patch) {
|
|
37
|
+
switch (patch.op) {
|
|
38
|
+
case "add":
|
|
39
|
+
return {
|
|
40
|
+
op: "remove",
|
|
41
|
+
path: patch.path
|
|
42
|
+
};
|
|
43
|
+
case "remove":
|
|
44
|
+
return {
|
|
45
|
+
op: "add",
|
|
46
|
+
path: patch.path,
|
|
47
|
+
value: patch.oldValue
|
|
48
|
+
};
|
|
49
|
+
case "replace":
|
|
50
|
+
return {
|
|
51
|
+
op: "replace",
|
|
52
|
+
path: patch.path,
|
|
53
|
+
value: patch.oldValue
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Simple simple check to check it is a number.
|
|
59
|
+
*/
|
|
60
|
+
function isNumber(x) {
|
|
61
|
+
return typeof x === "number";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Escape slashes and backslashes.
|
|
65
|
+
*
|
|
66
|
+
* http://tools.ietf.org/html/rfc6901
|
|
67
|
+
*/
|
|
68
|
+
function escapeJsonPath(path) {
|
|
69
|
+
if (isNumber(path) === true) {
|
|
70
|
+
return "" + path;
|
|
71
|
+
}
|
|
72
|
+
if (path.indexOf("/") === -1 && path.indexOf("~") === -1) {
|
|
73
|
+
return path;
|
|
74
|
+
}
|
|
75
|
+
return path.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Unescape slashes and backslashes.
|
|
79
|
+
*/
|
|
80
|
+
function unescapeJsonPath(path) {
|
|
81
|
+
return path.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Generates a json-path compliant json path from path parts.
|
|
85
|
+
*
|
|
86
|
+
* @param path
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
function joinJsonPath(path) {
|
|
90
|
+
// `/` refers to property with an empty name, while `` refers to root itself!
|
|
91
|
+
if (path.length === 0) {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
const getPathStr = (p) => p.map(escapeJsonPath).join("/");
|
|
95
|
+
if (path[0] === "." || path[0] === "..") {
|
|
96
|
+
// relative
|
|
97
|
+
return getPathStr(path);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// absolute
|
|
101
|
+
return "/" + getPathStr(path);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Splits and decodes a json path into several parts.
|
|
106
|
+
*
|
|
107
|
+
* @param path
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
function splitJsonPath(path) {
|
|
111
|
+
// `/` refers to property with an empty name, while `` refers to root itself!
|
|
112
|
+
const parts = path.split("/").map(unescapeJsonPath);
|
|
113
|
+
const valid = path === "" ||
|
|
114
|
+
path === "." ||
|
|
115
|
+
path === ".." ||
|
|
116
|
+
(0, internal_ts_1.stringStartsWith)(path, "/") ||
|
|
117
|
+
(0, internal_ts_1.stringStartsWith)(path, "./") ||
|
|
118
|
+
(0, internal_ts_1.stringStartsWith)(path, "../");
|
|
119
|
+
if (!valid) {
|
|
120
|
+
throw (0, internal_ts_1.fail)(`a json path must be either rooted, empty or relative, but got '${path}'`);
|
|
121
|
+
}
|
|
122
|
+
// '/a/b/c' -> ["a", "b", "c"]
|
|
123
|
+
// '../../b/c' -> ["..", "..", "b", "c"]
|
|
124
|
+
// '' -> []
|
|
125
|
+
// '/' -> ['']
|
|
126
|
+
// './a' -> [".", "a"]
|
|
127
|
+
// /./a' -> [".", "a"] equivalent to './a'
|
|
128
|
+
if (parts[0] === "") {
|
|
129
|
+
parts.shift();
|
|
130
|
+
}
|
|
131
|
+
return parts;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=json-patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-patch.js","sourceRoot":"","sources":["../../src/core/json-patch.ts"],"names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