@jbrowse/mobx-state-tree 5.6.3 → 5.6.9
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/core/action.d.ts +87 -0
- package/dist/core/action.js +228 -0
- package/dist/core/action.js.map +1 -0
- package/dist/core/actionContext.d.ts +27 -0
- package/dist/core/actionContext.js +42 -0
- package/dist/core/actionContext.js.map +1 -0
- package/dist/core/flow.d.ts +69 -0
- package/dist/core/flow.js +180 -0
- package/dist/core/flow.js.map +1 -0
- package/dist/core/json-patch.d.ts +46 -0
- package/dist/core/json-patch.js +133 -0
- package/dist/core/json-patch.js.map +1 -0
- package/dist/core/mst-operations.d.ts +459 -0
- package/dist/core/mst-operations.js +885 -0
- package/dist/core/mst-operations.js.map +1 -0
- package/dist/core/node/BaseNode.d.ts +62 -0
- package/dist/core/node/BaseNode.js +152 -0
- package/dist/core/node/BaseNode.js.map +1 -0
- package/dist/core/node/Hook.d.ts +17 -0
- package/dist/core/node/Hook.js +15 -0
- package/dist/core/node/Hook.js.map +1 -0
- package/dist/core/node/create-node.d.ts +16 -0
- package/dist/core/node/create-node.js +41 -0
- package/dist/core/node/create-node.js.map +1 -0
- package/dist/core/node/identifier-cache.d.ts +19 -0
- package/dist/core/node/identifier-cache.js +115 -0
- package/dist/core/node/identifier-cache.js.map +1 -0
- package/dist/core/node/livelinessChecking.d.ts +37 -0
- package/dist/core/node/livelinessChecking.js +38 -0
- package/dist/core/node/livelinessChecking.js.map +1 -0
- package/dist/core/node/node-utils.d.ts +83 -0
- package/dist/core/node/node-utils.js +165 -0
- package/dist/core/node/node-utils.js.map +1 -0
- package/dist/core/node/object-node.d.ts +99 -0
- package/dist/core/node/object-node.js +545 -0
- package/dist/core/node/object-node.js.map +1 -0
- package/dist/core/node/scalar-node.d.ts +19 -0
- package/dist/core/node/scalar-node.js +89 -0
- package/dist/core/node/scalar-node.js.map +1 -0
- package/dist/core/process.d.ts +50 -0
- package/dist/core/process.js +39 -0
- package/dist/core/process.js.map +1 -0
- package/dist/core/type/type-checker.d.ts +69 -0
- package/dist/core/type/type-checker.js +154 -0
- package/dist/core/type/type-checker.js.map +1 -0
- package/dist/core/type/type.d.ts +317 -0
- package/dist/core/type/type.js +251 -0
- package/dist/core/type/type.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +39 -0
- package/dist/internal.js +60 -0
- package/dist/internal.js.map +1 -0
- package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -0
- package/dist/middlewares/create-action-tracking-middleware.js +81 -0
- package/dist/middlewares/create-action-tracking-middleware.js.map +1 -0
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -0
- package/dist/middlewares/createActionTrackingMiddleware2.js +133 -0
- package/dist/middlewares/createActionTrackingMiddleware2.js.map +1 -0
- package/dist/middlewares/on-action.d.ts +87 -0
- package/dist/middlewares/on-action.js +215 -0
- package/dist/middlewares/on-action.js.map +1 -0
- package/dist/mobx-state-tree.js +85 -0
- package/dist/mobx-state-tree.module.js +83 -0
- package/dist/types/complex-types/array.d.ts +80 -0
- package/dist/types/complex-types/array.js +352 -0
- package/dist/types/complex-types/array.js.map +1 -0
- package/dist/types/complex-types/map.d.ts +110 -0
- package/dist/types/complex-types/map.js +361 -0
- package/dist/types/complex-types/map.js.map +1 -0
- package/dist/types/complex-types/model.d.ts +192 -0
- package/dist/types/complex-types/model.js +477 -0
- package/dist/types/complex-types/model.js.map +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.js +38 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/primitives.d.ts +124 -0
- package/dist/types/primitives.js +182 -0
- package/dist/types/primitives.js.map +1 -0
- package/dist/types/utility-types/custom.d.ts +74 -0
- package/dist/types/utility-types/custom.js +110 -0
- package/dist/types/utility-types/custom.js.map +1 -0
- package/dist/types/utility-types/enumeration.d.ts +5 -0
- package/dist/types/utility-types/enumeration.js +34 -0
- package/dist/types/utility-types/enumeration.js.map +1 -0
- package/dist/types/utility-types/frozen.d.ts +23 -0
- package/dist/types/utility-types/frozen.js +97 -0
- package/dist/types/utility-types/frozen.js.map +1 -0
- package/dist/types/utility-types/identifier.d.ts +86 -0
- package/dist/types/utility-types/identifier.js +129 -0
- package/dist/types/utility-types/identifier.js.map +1 -0
- package/dist/types/utility-types/late.d.ts +10 -0
- package/dist/types/utility-types/late.js +109 -0
- package/dist/types/utility-types/late.js.map +1 -0
- package/dist/types/utility-types/lazy.d.ts +22 -0
- package/dist/types/utility-types/lazy.js +76 -0
- package/dist/types/utility-types/lazy.js.map +1 -0
- package/dist/types/utility-types/literal.d.ts +37 -0
- package/dist/types/utility-types/literal.js +63 -0
- package/dist/types/utility-types/literal.js.map +1 -0
- package/dist/types/utility-types/maybe.d.ts +26 -0
- package/dist/types/utility-types/maybe.js +30 -0
- package/dist/types/utility-types/maybe.js.map +1 -0
- package/dist/types/utility-types/optional.d.ts +41 -0
- package/dist/types/utility-types/optional.js +140 -0
- package/dist/types/utility-types/optional.js.map +1 -0
- package/dist/types/utility-types/reference.d.ts +89 -0
- package/dist/types/utility-types/reference.js +392 -0
- package/dist/types/utility-types/reference.js.map +1 -0
- package/dist/types/utility-types/refinement.d.ts +10 -0
- package/dist/types/utility-types/refinement.js +85 -0
- package/dist/types/utility-types/refinement.js.map +1 -0
- package/dist/types/utility-types/resilient.d.ts +18 -0
- package/dist/types/utility-types/resilient.js +120 -0
- package/dist/types/utility-types/resilient.js.map +1 -0
- package/dist/types/utility-types/snapshotProcessor.d.ts +63 -0
- package/dist/types/utility-types/snapshotProcessor.js +161 -0
- package/dist/types/utility-types/snapshotProcessor.js.map +1 -0
- package/dist/types/utility-types/union.d.ts +77 -0
- package/dist/types/utility-types/union.js +245 -0
- package/dist/types/utility-types/union.js.map +1 -0
- package/dist/utils.d.ts +230 -0
- package/dist/utils.js +483 -0
- package/dist/utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { AnyNode, AnyObjectNode, IAnyComplexType, IAnyType, IChildNodesMap, IType, Instance, STNValue } from "../../internal.ts";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export declare enum NodeLifeCycle {
|
|
7
|
+
INITIALIZING = 0,// setting up
|
|
8
|
+
CREATED = 1,// afterCreate has run
|
|
9
|
+
FINALIZED = 2,// afterAttach has run
|
|
10
|
+
DETACHING = 3,// being detached from the tree
|
|
11
|
+
DEAD = 4
|
|
12
|
+
}
|
|
13
|
+
/** @hidden */
|
|
14
|
+
declare const $stateTreeNodeType: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* Common interface that represents a node instance.
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
export interface IStateTreeNode<IT extends IAnyType = IAnyType> {
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
readonly $treenode?: any;
|
|
24
|
+
readonly [$stateTreeNodeType]?: [IT] | [any];
|
|
25
|
+
}
|
|
26
|
+
/** @hidden */
|
|
27
|
+
export type TypeOfValue<T extends IAnyStateTreeNode> = T extends IStateTreeNode<infer IT> ? IT : never;
|
|
28
|
+
/**
|
|
29
|
+
* Represents any state tree node instance.
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
export interface IAnyStateTreeNode extends STNValue<any, IAnyType> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if the given value is a node in a state tree.
|
|
36
|
+
* More precisely, that is, if the value is an instance of a
|
|
37
|
+
* `types.model`, `types.array` or `types.map`.
|
|
38
|
+
*
|
|
39
|
+
* @param value
|
|
40
|
+
* @returns true if the value is a state tree node.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isStateTreeNode<IT extends IAnyComplexType = IAnyComplexType>(value: any): value is STNValue<Instance<IT>, IT>;
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
export declare function assertIsStateTreeNode(value: IAnyStateTreeNode, argNumber: number | number[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
52
|
+
export declare function getStateTreeNode(value: IAnyStateTreeNode): AnyObjectNode;
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
* @hidden
|
|
56
|
+
*/
|
|
57
|
+
export declare function getStateTreeNodeSafe(value: IAnyStateTreeNode): AnyObjectNode | null;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
export declare function toJSON<S>(this: IStateTreeNode<IType<any, S, any>>): S;
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
67
|
+
export declare function getRelativePathBetweenNodes(base: AnyObjectNode, target: AnyObjectNode): string;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveNodeByPath(base: AnyObjectNode, path: string, failIfResolveFails?: boolean): AnyNode | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* @internal
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveNodeByPathParts(base: AnyObjectNode, pathParts: string[], failIfResolveFails?: boolean): AnyNode | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
* @hidden
|
|
81
|
+
*/
|
|
82
|
+
export declare function convertChildNodesToArray(childNodes: IChildNodesMap | null): AnyNode[];
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeLifeCycle = void 0;
|
|
4
|
+
exports.isStateTreeNode = isStateTreeNode;
|
|
5
|
+
exports.assertIsStateTreeNode = assertIsStateTreeNode;
|
|
6
|
+
exports.getStateTreeNode = getStateTreeNode;
|
|
7
|
+
exports.getStateTreeNodeSafe = getStateTreeNodeSafe;
|
|
8
|
+
exports.toJSON = toJSON;
|
|
9
|
+
exports.getRelativePathBetweenNodes = getRelativePathBetweenNodes;
|
|
10
|
+
exports.resolveNodeByPath = resolveNodeByPath;
|
|
11
|
+
exports.resolveNodeByPathParts = resolveNodeByPathParts;
|
|
12
|
+
exports.convertChildNodesToArray = convertChildNodesToArray;
|
|
13
|
+
const internal_ts_1 = require("../../internal.js");
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
var NodeLifeCycle;
|
|
19
|
+
(function (NodeLifeCycle) {
|
|
20
|
+
NodeLifeCycle[NodeLifeCycle["INITIALIZING"] = 0] = "INITIALIZING";
|
|
21
|
+
NodeLifeCycle[NodeLifeCycle["CREATED"] = 1] = "CREATED";
|
|
22
|
+
NodeLifeCycle[NodeLifeCycle["FINALIZED"] = 2] = "FINALIZED";
|
|
23
|
+
NodeLifeCycle[NodeLifeCycle["DETACHING"] = 3] = "DETACHING";
|
|
24
|
+
NodeLifeCycle[NodeLifeCycle["DEAD"] = 4] = "DEAD"; // no coming back from this one
|
|
25
|
+
})(NodeLifeCycle || (exports.NodeLifeCycle = NodeLifeCycle = {}));
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if the given value is a node in a state tree.
|
|
28
|
+
* More precisely, that is, if the value is an instance of a
|
|
29
|
+
* `types.model`, `types.array` or `types.map`.
|
|
30
|
+
*
|
|
31
|
+
* @param value
|
|
32
|
+
* @returns true if the value is a state tree node.
|
|
33
|
+
*/
|
|
34
|
+
function isStateTreeNode(value) {
|
|
35
|
+
return !!(value && value.$treenode);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
function assertIsStateTreeNode(value, argNumber) {
|
|
42
|
+
(0, internal_ts_1.assertArg)(value, isStateTreeNode, "mobx-state-tree node", argNumber);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
48
|
+
function getStateTreeNode(value) {
|
|
49
|
+
if (!isStateTreeNode(value)) {
|
|
50
|
+
// istanbul ignore next
|
|
51
|
+
throw (0, internal_ts_1.fail)(`Value ${value} is no MST Node`);
|
|
52
|
+
}
|
|
53
|
+
return value.$treenode;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
function getStateTreeNodeSafe(value) {
|
|
60
|
+
return (value && value.$treenode) || null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
function toJSON() {
|
|
67
|
+
return getStateTreeNode(this).snapshot;
|
|
68
|
+
}
|
|
69
|
+
const doubleDot = (_) => "..";
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
function getRelativePathBetweenNodes(base, target) {
|
|
75
|
+
// PRE condition target is (a child of) base!
|
|
76
|
+
if (base.root !== target.root) {
|
|
77
|
+
throw (0, internal_ts_1.fail)(`Cannot calculate relative path: objects '${base}' and '${target}' are not part of the same object tree`);
|
|
78
|
+
}
|
|
79
|
+
const baseParts = (0, internal_ts_1.splitJsonPath)(base.path);
|
|
80
|
+
const targetParts = (0, internal_ts_1.splitJsonPath)(target.path);
|
|
81
|
+
let common = 0;
|
|
82
|
+
for (; common < baseParts.length; common++) {
|
|
83
|
+
if (baseParts[common] !== targetParts[common]) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// TODO: assert that no targetParts paths are "..", "." or ""!
|
|
88
|
+
return (baseParts.slice(common).map(doubleDot).join("/") +
|
|
89
|
+
(0, internal_ts_1.joinJsonPath)(targetParts.slice(common)));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
* @hidden
|
|
94
|
+
*/
|
|
95
|
+
function resolveNodeByPath(base, path, failIfResolveFails = true) {
|
|
96
|
+
return resolveNodeByPathParts(base, (0, internal_ts_1.splitJsonPath)(path), failIfResolveFails);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
* @hidden
|
|
101
|
+
*/
|
|
102
|
+
function resolveNodeByPathParts(base, pathParts, failIfResolveFails = true) {
|
|
103
|
+
let current = base;
|
|
104
|
+
try {
|
|
105
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
106
|
+
const part = pathParts[i];
|
|
107
|
+
if (part === "..") {
|
|
108
|
+
current = current.parent;
|
|
109
|
+
if (current) {
|
|
110
|
+
continue;
|
|
111
|
+
} // not everything has a parent
|
|
112
|
+
}
|
|
113
|
+
else if (part === ".") {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
else if (current) {
|
|
117
|
+
if (current instanceof internal_ts_1.ScalarNode) {
|
|
118
|
+
// check if the value of a scalar resolves to a state tree node (e.g. references)
|
|
119
|
+
// then we can continue resolving...
|
|
120
|
+
const value = current.value;
|
|
121
|
+
if (isStateTreeNode(value)) {
|
|
122
|
+
current = getStateTreeNode(value);
|
|
123
|
+
// fall through
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (current instanceof internal_ts_1.ObjectNode) {
|
|
127
|
+
const subType = current.getChildType(part);
|
|
128
|
+
if (subType) {
|
|
129
|
+
current = current.getChildNode(part);
|
|
130
|
+
if (current) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
throw (0, internal_ts_1.fail)(`Could not resolve '${part}' in path '${(0, internal_ts_1.joinJsonPath)(pathParts.slice(0, i)) || "/"}' while resolving '${(0, internal_ts_1.joinJsonPath)(pathParts)}'`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
if (!failIfResolveFails) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
throw e;
|
|
144
|
+
}
|
|
145
|
+
return current;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
function convertChildNodesToArray(childNodes) {
|
|
152
|
+
if (!childNodes) {
|
|
153
|
+
return internal_ts_1.EMPTY_ARRAY;
|
|
154
|
+
}
|
|
155
|
+
const keys = Object.keys(childNodes);
|
|
156
|
+
if (!keys.length) {
|
|
157
|
+
return internal_ts_1.EMPTY_ARRAY;
|
|
158
|
+
}
|
|
159
|
+
const result = new Array(keys.length);
|
|
160
|
+
keys.forEach((key, index) => {
|
|
161
|
+
result[index] = childNodes[key];
|
|
162
|
+
});
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=node-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-utils.js","sourceRoot":"","sources":["../../../src/core/node/node-utils.ts"],"names":[],"mappings":";;;AAqEA,0CAIC;AAMD,sDAKC;AAMD,4CAMC;AAMD,oDAIC;AAMD,wBAEC;AAQD,kEAwBC;AAMD,8CAMC;AAMD,wDAiDC;AAMD,4DAiBC;AA5OD,mDAQ0B;AAa1B;;;GAGG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,iEAAY,CAAA;IACZ,uDAAO,CAAA;IACP,2DAAS,CAAA;IACT,2DAAS,CAAA;IACT,iDAAI,CAAA,CAAC,+BAA+B;AACtC,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB;AA8BD;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,KAAU;IAEV,OAAO,CAAC,CAAC,CAAC,KAAK,I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KAAK,CAAC,GAAG,UAAW,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BaseNode, ComplexType, Hook, IdentifierCache } from "../../internal.ts";
|
|
2
|
+
import type { AnyNode, IAnyType, IDisposer, IJsonPatch, IMiddleware, IMiddlewareEvent, IMiddlewareHandler, IReversibleJsonPatch, IStateTreeNode, IType, ReferenceIdentifier } from "../../internal.ts";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export interface IChildNodesMap {
|
|
8
|
+
[key: string]: AnyNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export declare class ObjectNode<C, S, T> extends BaseNode<C, S, T> {
|
|
15
|
+
readonly type: ComplexType<C, S, T>;
|
|
16
|
+
storedValue: T & IStateTreeNode<IType<C, S, T>>;
|
|
17
|
+
readonly nodeId: number;
|
|
18
|
+
readonly identifierAttribute?: string;
|
|
19
|
+
readonly identifier: string | null;
|
|
20
|
+
readonly unnormalizedIdentifier: ReferenceIdentifier | null;
|
|
21
|
+
identifierCache?: IdentifierCache;
|
|
22
|
+
isProtectionEnabled: boolean;
|
|
23
|
+
middlewares?: IMiddleware[];
|
|
24
|
+
hasSnapshotPostProcessor: boolean;
|
|
25
|
+
private _applyPatches?;
|
|
26
|
+
applyPatches(patches: IJsonPatch[]): void;
|
|
27
|
+
private _applySnapshot?;
|
|
28
|
+
applySnapshot(snapshot: C): void;
|
|
29
|
+
private _autoUnbox;
|
|
30
|
+
_isRunningAction: boolean;
|
|
31
|
+
private _hasSnapshotReaction;
|
|
32
|
+
private _observableInstanceState;
|
|
33
|
+
private _childNodes;
|
|
34
|
+
private _initialSnapshot;
|
|
35
|
+
private _cachedInitialSnapshot?;
|
|
36
|
+
private _cachedInitialSnapshotCreated;
|
|
37
|
+
private _snapshotComputed;
|
|
38
|
+
constructor(complexType: ComplexType<C, S, T>, parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C);
|
|
39
|
+
createObservableInstanceIfNeeded(fireHooks?: boolean): void;
|
|
40
|
+
createObservableInstance(fireHooks?: boolean): void;
|
|
41
|
+
get root(): AnyObjectNode;
|
|
42
|
+
clearParent(): void;
|
|
43
|
+
setParent(newParent: AnyObjectNode, subpath: string): void;
|
|
44
|
+
protected fireHook(name: Hook): void;
|
|
45
|
+
private _snapshotUponDeath?;
|
|
46
|
+
get snapshot(): S;
|
|
47
|
+
getSnapshot(): S;
|
|
48
|
+
private _getActualSnapshot;
|
|
49
|
+
private _getCachedInitialSnapshot;
|
|
50
|
+
private isRunningAction;
|
|
51
|
+
assertAlive(context: AssertAliveContext): void;
|
|
52
|
+
private _getAssertAliveError;
|
|
53
|
+
getChildNode(subpath: string): AnyNode;
|
|
54
|
+
getChildren(): ReadonlyArray<AnyNode>;
|
|
55
|
+
getChildType(propertyName?: string): IAnyType;
|
|
56
|
+
get isProtected(): boolean;
|
|
57
|
+
assertWritable(context: AssertAliveContext): void;
|
|
58
|
+
removeChild(subpath: string): void;
|
|
59
|
+
unbox(childNode: AnyNode | undefined): AnyNode | undefined;
|
|
60
|
+
toString(): string;
|
|
61
|
+
finalizeCreation(): void;
|
|
62
|
+
detach(): void;
|
|
63
|
+
private preboot;
|
|
64
|
+
die(): void;
|
|
65
|
+
aboutToDie(): void;
|
|
66
|
+
finalizeDeath(): void;
|
|
67
|
+
onSnapshot(onChange: (snapshot: S) => void): IDisposer;
|
|
68
|
+
protected emitSnapshot(snapshot: S): void;
|
|
69
|
+
onPatch(handler: (patch: IJsonPatch, reversePatch: IJsonPatch) => void): IDisposer;
|
|
70
|
+
emitPatch(basePatch: IReversibleJsonPatch, source: AnyNode): void;
|
|
71
|
+
hasDisposer(disposer: () => void): boolean;
|
|
72
|
+
addDisposer(disposer: () => void): void;
|
|
73
|
+
removeDisposer(disposer: () => void): void;
|
|
74
|
+
private removeMiddleware;
|
|
75
|
+
addMiddleWare(handler: IMiddlewareHandler, includeHooks?: boolean): IDisposer;
|
|
76
|
+
applyPatchLocally(subpath: string, patch: IJsonPatch): void;
|
|
77
|
+
private _addSnapshotReaction;
|
|
78
|
+
private _internalEvents?;
|
|
79
|
+
private _internalEventsHasSubscribers;
|
|
80
|
+
private _internalEventsRegister;
|
|
81
|
+
private _internalEventsHas;
|
|
82
|
+
private _internalEventsUnregister;
|
|
83
|
+
private _internalEventsEmit;
|
|
84
|
+
private _internalEventsClear;
|
|
85
|
+
private _internalEventsClearAll;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
* @hidden
|
|
90
|
+
*/
|
|
91
|
+
export type AnyObjectNode = ObjectNode<any, any, any>;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
96
|
+
export interface AssertAliveContext {
|
|
97
|
+
subpath?: string;
|
|
98
|
+
actionContext?: IMiddlewareEvent;
|
|
99
|
+
}
|