@jbrowse/mobx-state-tree 5.6.2 → 5.6.3

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.
Files changed (126) hide show
  1. package/package.json +2 -2
  2. package/dist/core/action.d.ts +0 -87
  3. package/dist/core/action.js +0 -228
  4. package/dist/core/action.js.map +0 -1
  5. package/dist/core/actionContext.d.ts +0 -27
  6. package/dist/core/actionContext.js +0 -42
  7. package/dist/core/actionContext.js.map +0 -1
  8. package/dist/core/flow.d.ts +0 -69
  9. package/dist/core/flow.js +0 -180
  10. package/dist/core/flow.js.map +0 -1
  11. package/dist/core/json-patch.d.ts +0 -46
  12. package/dist/core/json-patch.js +0 -133
  13. package/dist/core/json-patch.js.map +0 -1
  14. package/dist/core/mst-operations.d.ts +0 -459
  15. package/dist/core/mst-operations.js +0 -885
  16. package/dist/core/mst-operations.js.map +0 -1
  17. package/dist/core/node/BaseNode.d.ts +0 -62
  18. package/dist/core/node/BaseNode.js +0 -152
  19. package/dist/core/node/BaseNode.js.map +0 -1
  20. package/dist/core/node/Hook.d.ts +0 -17
  21. package/dist/core/node/Hook.js +0 -15
  22. package/dist/core/node/Hook.js.map +0 -1
  23. package/dist/core/node/create-node.d.ts +0 -16
  24. package/dist/core/node/create-node.js +0 -41
  25. package/dist/core/node/create-node.js.map +0 -1
  26. package/dist/core/node/identifier-cache.d.ts +0 -19
  27. package/dist/core/node/identifier-cache.js +0 -115
  28. package/dist/core/node/identifier-cache.js.map +0 -1
  29. package/dist/core/node/livelinessChecking.d.ts +0 -37
  30. package/dist/core/node/livelinessChecking.js +0 -38
  31. package/dist/core/node/livelinessChecking.js.map +0 -1
  32. package/dist/core/node/node-utils.d.ts +0 -83
  33. package/dist/core/node/node-utils.js +0 -165
  34. package/dist/core/node/node-utils.js.map +0 -1
  35. package/dist/core/node/object-node.d.ts +0 -99
  36. package/dist/core/node/object-node.js +0 -545
  37. package/dist/core/node/object-node.js.map +0 -1
  38. package/dist/core/node/scalar-node.d.ts +0 -19
  39. package/dist/core/node/scalar-node.js +0 -89
  40. package/dist/core/node/scalar-node.js.map +0 -1
  41. package/dist/core/process.d.ts +0 -50
  42. package/dist/core/process.js +0 -39
  43. package/dist/core/process.js.map +0 -1
  44. package/dist/core/type/type-checker.d.ts +0 -69
  45. package/dist/core/type/type-checker.js +0 -154
  46. package/dist/core/type/type-checker.js.map +0 -1
  47. package/dist/core/type/type.d.ts +0 -317
  48. package/dist/core/type/type.js +0 -251
  49. package/dist/core/type/type.js.map +0 -1
  50. package/dist/index.d.ts +0 -2
  51. package/dist/index.js +0 -85
  52. package/dist/index.js.map +0 -1
  53. package/dist/internal.d.ts +0 -39
  54. package/dist/internal.js +0 -60
  55. package/dist/internal.js.map +0 -1
  56. package/dist/middlewares/create-action-tracking-middleware.d.ts +0 -24
  57. package/dist/middlewares/create-action-tracking-middleware.js +0 -81
  58. package/dist/middlewares/create-action-tracking-middleware.js.map +0 -1
  59. package/dist/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
  60. package/dist/middlewares/createActionTrackingMiddleware2.js +0 -133
  61. package/dist/middlewares/createActionTrackingMiddleware2.js.map +0 -1
  62. package/dist/middlewares/on-action.d.ts +0 -87
  63. package/dist/middlewares/on-action.js +0 -215
  64. package/dist/middlewares/on-action.js.map +0 -1
  65. package/dist/mobx-state-tree.js +0 -85
  66. package/dist/mobx-state-tree.module.js +0 -83
  67. package/dist/types/complex-types/array.d.ts +0 -80
  68. package/dist/types/complex-types/array.js +0 -352
  69. package/dist/types/complex-types/array.js.map +0 -1
  70. package/dist/types/complex-types/map.d.ts +0 -110
  71. package/dist/types/complex-types/map.js +0 -361
  72. package/dist/types/complex-types/map.js.map +0 -1
  73. package/dist/types/complex-types/model.d.ts +0 -192
  74. package/dist/types/complex-types/model.js +0 -477
  75. package/dist/types/complex-types/model.js.map +0 -1
  76. package/dist/types/index.d.ts +0 -33
  77. package/dist/types/index.js +0 -38
  78. package/dist/types/index.js.map +0 -1
  79. package/dist/types/primitives.d.ts +0 -124
  80. package/dist/types/primitives.js +0 -182
  81. package/dist/types/primitives.js.map +0 -1
  82. package/dist/types/utility-types/custom.d.ts +0 -74
  83. package/dist/types/utility-types/custom.js +0 -110
  84. package/dist/types/utility-types/custom.js.map +0 -1
  85. package/dist/types/utility-types/enumeration.d.ts +0 -5
  86. package/dist/types/utility-types/enumeration.js +0 -34
  87. package/dist/types/utility-types/enumeration.js.map +0 -1
  88. package/dist/types/utility-types/frozen.d.ts +0 -23
  89. package/dist/types/utility-types/frozen.js +0 -97
  90. package/dist/types/utility-types/frozen.js.map +0 -1
  91. package/dist/types/utility-types/identifier.d.ts +0 -86
  92. package/dist/types/utility-types/identifier.js +0 -129
  93. package/dist/types/utility-types/identifier.js.map +0 -1
  94. package/dist/types/utility-types/late.d.ts +0 -10
  95. package/dist/types/utility-types/late.js +0 -109
  96. package/dist/types/utility-types/late.js.map +0 -1
  97. package/dist/types/utility-types/lazy.d.ts +0 -22
  98. package/dist/types/utility-types/lazy.js +0 -76
  99. package/dist/types/utility-types/lazy.js.map +0 -1
  100. package/dist/types/utility-types/literal.d.ts +0 -37
  101. package/dist/types/utility-types/literal.js +0 -63
  102. package/dist/types/utility-types/literal.js.map +0 -1
  103. package/dist/types/utility-types/maybe.d.ts +0 -26
  104. package/dist/types/utility-types/maybe.js +0 -30
  105. package/dist/types/utility-types/maybe.js.map +0 -1
  106. package/dist/types/utility-types/optional.d.ts +0 -41
  107. package/dist/types/utility-types/optional.js +0 -140
  108. package/dist/types/utility-types/optional.js.map +0 -1
  109. package/dist/types/utility-types/reference.d.ts +0 -89
  110. package/dist/types/utility-types/reference.js +0 -392
  111. package/dist/types/utility-types/reference.js.map +0 -1
  112. package/dist/types/utility-types/refinement.d.ts +0 -10
  113. package/dist/types/utility-types/refinement.js +0 -85
  114. package/dist/types/utility-types/refinement.js.map +0 -1
  115. package/dist/types/utility-types/resilient.d.ts +0 -18
  116. package/dist/types/utility-types/resilient.js +0 -120
  117. package/dist/types/utility-types/resilient.js.map +0 -1
  118. package/dist/types/utility-types/snapshotProcessor.d.ts +0 -63
  119. package/dist/types/utility-types/snapshotProcessor.js +0 -161
  120. package/dist/types/utility-types/snapshotProcessor.js.map +0 -1
  121. package/dist/types/utility-types/union.d.ts +0 -77
  122. package/dist/types/utility-types/union.js +0 -245
  123. package/dist/types/utility-types/union.js.map +0 -1
  124. package/dist/utils.d.ts +0 -230
  125. package/dist/utils.js +0 -483
  126. package/dist/utils.js.map +0 -1
@@ -1,477 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModelType = void 0;
4
- exports.model = model;
5
- exports.compose = compose;
6
- exports.isModelType = isModelType;
7
- const mobx_1 = require("mobx");
8
- const internal_ts_1 = require("../../internal.js");
9
- const PRE_PROCESS_SNAPSHOT = "preProcessSnapshot";
10
- const POST_PROCESS_SNAPSHOT = "postProcessSnapshot";
11
- function objectTypeToString() {
12
- return (0, internal_ts_1.getStateTreeNode)(this).toString();
13
- }
14
- const defaultObjectOptions = {
15
- name: "AnonymousModel",
16
- properties: {},
17
- initializers: internal_ts_1.EMPTY_ARRAY
18
- };
19
- function toPropertiesObject(declaredProps) {
20
- const keysList = Object.keys(declaredProps);
21
- const alreadySeenKeys = new Set();
22
- keysList.forEach(key => {
23
- if (alreadySeenKeys.has(key)) {
24
- throw (0, internal_ts_1.fail)(`${key} is declared twice in the model. Model should not contain the same keys`);
25
- }
26
- alreadySeenKeys.add(key);
27
- });
28
- // loop through properties and ensures that all items are types
29
- return keysList.reduce((props, key) => {
30
- // warn if user intended a HOOK
31
- if (key in internal_ts_1.Hook) {
32
- throw (0, internal_ts_1.fail)(`Hook '${key}' was defined as property. Hooks should be defined as part of the actions`);
33
- }
34
- // the user intended to use a view
35
- const descriptor = Object.getOwnPropertyDescriptor(declaredProps, key);
36
- if ("get" in descriptor) {
37
- throw (0, internal_ts_1.fail)("Getters are not supported as properties. Please use views instead");
38
- }
39
- // undefined and null are not valid
40
- const value = descriptor.value;
41
- if (value === null || value === undefined) {
42
- throw (0, internal_ts_1.fail)("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");
43
- }
44
- // its a primitive, convert to its type
45
- else if ((0, internal_ts_1.isPrimitive)(value)) {
46
- props[key] = (0, internal_ts_1.optional)((0, internal_ts_1.getPrimitiveFactoryFromValue)(value), value);
47
- }
48
- // map defaults to empty object automatically for models
49
- else if (value instanceof internal_ts_1.MapType) {
50
- props[key] = (0, internal_ts_1.optional)(value, {});
51
- }
52
- else if (value instanceof internal_ts_1.ArrayType) {
53
- props[key] = (0, internal_ts_1.optional)(value, []);
54
- }
55
- // its already a type
56
- else if ((0, internal_ts_1.isType)(value)) {
57
- // do nothing, it's already a type
58
- }
59
- // its a function, maybe the user wanted a view?
60
- else if ((0, internal_ts_1.devMode)() && typeof value === "function") {
61
- throw (0, internal_ts_1.fail)(`Invalid type definition for property '${key}', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?`);
62
- }
63
- // no other complex values
64
- else if ((0, internal_ts_1.devMode)() && typeof value === "object") {
65
- throw (0, internal_ts_1.fail)(`Invalid type definition for property '${key}', it looks like you passed an object. Try passing another model type or a types.frozen.`);
66
- }
67
- else {
68
- throw (0, internal_ts_1.fail)(`Invalid type definition for property '${key}', cannot infer a type from a value like '${value}' (${typeof value})`);
69
- }
70
- return props;
71
- }, { ...declaredProps });
72
- }
73
- /**
74
- * @internal
75
- * @hidden
76
- */
77
- class ModelType extends internal_ts_1.ComplexType {
78
- flags = internal_ts_1.TypeFlags.Object;
79
- /*
80
- * The original object definition
81
- */
82
- initializers;
83
- properties;
84
- preProcessor;
85
- postProcessor;
86
- propertyNames;
87
- constructor(opts) {
88
- super(opts.name || defaultObjectOptions.name);
89
- Object.assign(this, defaultObjectOptions, opts);
90
- // ensures that any default value gets converted to its related type
91
- this.properties = toPropertiesObject(this.properties);
92
- (0, internal_ts_1.freeze)(this.properties); // make sure nobody messes with it
93
- this.propertyNames = Object.keys(this.properties);
94
- this.identifierAttribute = this._getIdentifierAttribute();
95
- }
96
- _getIdentifierAttribute() {
97
- let identifierAttribute = undefined;
98
- this.forAllProps((propName, propType) => {
99
- if (propType.flags & internal_ts_1.TypeFlags.Identifier) {
100
- if (identifierAttribute) {
101
- throw (0, internal_ts_1.fail)(`Cannot define property '${propName}' as object identifier, property '${identifierAttribute}' is already defined as identifier property`);
102
- }
103
- identifierAttribute = propName;
104
- }
105
- });
106
- return identifierAttribute;
107
- }
108
- cloneAndEnhance(opts) {
109
- return new ModelType({
110
- name: opts.name || this.name,
111
- properties: Object.assign({}, this.properties, opts.properties),
112
- initializers: this.initializers.concat(opts.initializers || []),
113
- preProcessor: opts.preProcessor || this.preProcessor,
114
- postProcessor: opts.postProcessor || this.postProcessor
115
- });
116
- }
117
- actions(fn) {
118
- const actionInitializer = (self) => {
119
- this.instantiateActions(self, fn(self));
120
- return self;
121
- };
122
- return this.cloneAndEnhance({ initializers: [actionInitializer] });
123
- }
124
- instantiateActions(self, actions) {
125
- // check if return is correct
126
- if (!(0, internal_ts_1.isPlainObject)(actions)) {
127
- throw (0, internal_ts_1.fail)(`actions initializer should return a plain object containing actions`);
128
- }
129
- // bind actions to the object created
130
- Object.keys(actions).forEach(name => {
131
- // warn if preprocessor was given
132
- if (name === PRE_PROCESS_SNAPSHOT) {
133
- throw (0, internal_ts_1.fail)(`Cannot define action '${PRE_PROCESS_SNAPSHOT}', it should be defined using 'type.preProcessSnapshot(fn)' instead`);
134
- }
135
- // warn if postprocessor was given
136
- if (name === POST_PROCESS_SNAPSHOT) {
137
- throw (0, internal_ts_1.fail)(`Cannot define action '${POST_PROCESS_SNAPSHOT}', it should be defined using 'type.postProcessSnapshot(fn)' instead`);
138
- }
139
- let action2 = actions[name];
140
- // apply hook composition
141
- const baseAction = self[name];
142
- if (name in internal_ts_1.Hook && baseAction) {
143
- const specializedAction = action2;
144
- action2 = function (...args) {
145
- baseAction(...args);
146
- specializedAction(...args);
147
- };
148
- }
149
- // the goal of this is to make sure actions using "this" can call themselves,
150
- // while still allowing the middlewares to register them
151
- const middlewares = action2.$mst_middleware; // make sure middlewares are not lost
152
- const boundAction = action2.bind(actions);
153
- boundAction._isFlowAction =
154
- action2._isFlowAction || false;
155
- boundAction.$mst_middleware = middlewares;
156
- const actionInvoker = (0, internal_ts_1.createActionInvoker)(self, name, boundAction);
157
- actions[name] = actionInvoker;
158
- (!(0, internal_ts_1.devMode)() ? internal_ts_1.addHiddenFinalProp : internal_ts_1.addHiddenWritableProp)(self, name, actionInvoker);
159
- });
160
- }
161
- named = name => {
162
- return this.cloneAndEnhance({ name });
163
- };
164
- props = properties => {
165
- return this.cloneAndEnhance({ properties });
166
- };
167
- volatile(fn) {
168
- if (typeof fn !== "function") {
169
- throw (0, internal_ts_1.fail)(`You passed an ${typeof fn} to volatile state as an argument, when function is expected`);
170
- }
171
- const stateInitializer = (self) => {
172
- this.instantiateVolatileState(self, fn(self));
173
- return self;
174
- };
175
- return this.cloneAndEnhance({ initializers: [stateInitializer] });
176
- }
177
- instantiateVolatileState(self, state) {
178
- // check views return
179
- if (!(0, internal_ts_1.isPlainObject)(state)) {
180
- throw (0, internal_ts_1.fail)(`volatile state initializer should return a plain object containing state`);
181
- }
182
- (0, mobx_1.set)(self, state);
183
- }
184
- extend(fn) {
185
- const initializer = (self) => {
186
- const { actions, views, state, ...rest } = fn(self);
187
- for (const key in rest) {
188
- throw (0, internal_ts_1.fail)(`The \`extend\` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '${key}'`);
189
- }
190
- if (state) {
191
- this.instantiateVolatileState(self, state);
192
- }
193
- if (views) {
194
- this.instantiateViews(self, views);
195
- }
196
- if (actions) {
197
- this.instantiateActions(self, actions);
198
- }
199
- return self;
200
- };
201
- return this.cloneAndEnhance({ initializers: [initializer] });
202
- }
203
- views(fn) {
204
- const viewInitializer = (self) => {
205
- this.instantiateViews(self, fn(self));
206
- return self;
207
- };
208
- return this.cloneAndEnhance({ initializers: [viewInitializer] });
209
- }
210
- instantiateViews(self, views) {
211
- // check views return
212
- if (!(0, internal_ts_1.isPlainObject)(views)) {
213
- throw (0, internal_ts_1.fail)(`views initializer should return a plain object containing views`);
214
- }
215
- Object.getOwnPropertyNames(views).forEach(key => {
216
- // is this a computed property?
217
- const descriptor = Object.getOwnPropertyDescriptor(views, key);
218
- if ("get" in descriptor) {
219
- (0, mobx_1.defineProperty)(self, key, descriptor);
220
- (0, mobx_1.makeObservable)(self, { [key]: mobx_1.computed });
221
- }
222
- else if (typeof descriptor.value === "function") {
223
- // this is a view function, merge as is!
224
- // See #646, allow models to be mocked
225
- ;
226
- (!(0, internal_ts_1.devMode)() ? internal_ts_1.addHiddenFinalProp : internal_ts_1.addHiddenWritableProp)(self, key, descriptor.value);
227
- }
228
- else {
229
- throw (0, internal_ts_1.fail)(`A view member should either be a function or getter based property`);
230
- }
231
- });
232
- }
233
- preProcessSnapshot = preProcessor => {
234
- const currentPreprocessor = this.preProcessor;
235
- if (!currentPreprocessor) {
236
- return this.cloneAndEnhance({ preProcessor });
237
- }
238
- else {
239
- return this.cloneAndEnhance({
240
- preProcessor: snapshot => currentPreprocessor(preProcessor(snapshot))
241
- });
242
- }
243
- };
244
- postProcessSnapshot = postProcessor => {
245
- const currentPostprocessor = this.postProcessor;
246
- if (!currentPostprocessor) {
247
- return this.cloneAndEnhance({ postProcessor });
248
- }
249
- else {
250
- return this.cloneAndEnhance({
251
- postProcessor: snapshot => postProcessor(currentPostprocessor(snapshot))
252
- });
253
- }
254
- };
255
- instantiate(parent, subpath, environment, initialValue) {
256
- const value = (0, internal_ts_1.isStateTreeNode)(initialValue)
257
- ? initialValue
258
- : this.applySnapshotPreProcessor(initialValue);
259
- return (0, internal_ts_1.createObjectNode)(this, parent, subpath, environment, value);
260
- // Optimization: record all prop- view- and action names after first construction, and generate an optimal base class
261
- // that pre-reserves all these fields for fast object-member lookups
262
- }
263
- initializeChildNodes(objNode, initialSnapshot = {}) {
264
- const type = objNode.type;
265
- const result = {};
266
- type.forAllProps((name, childType) => {
267
- result[name] = childType.instantiate(objNode, name, undefined, initialSnapshot[name]);
268
- });
269
- return result;
270
- }
271
- createNewInstance(childNodes) {
272
- const options = { ...internal_ts_1.mobxShallow, name: this.name };
273
- return mobx_1.observable.object(childNodes, internal_ts_1.EMPTY_OBJECT, options);
274
- }
275
- finalizeNewInstance(node, instance) {
276
- (0, internal_ts_1.addHiddenFinalProp)(instance, "toString", objectTypeToString);
277
- this.forAllProps(name => {
278
- (0, mobx_1._interceptReads)(instance, name, node.unbox);
279
- });
280
- this.initializers.reduce((self, fn) => fn(self), instance);
281
- (0, mobx_1.intercept)(instance, this.willChange);
282
- (0, mobx_1.observe)(instance, this.didChange);
283
- }
284
- willChange(chg) {
285
- // TODO: mobx typings don't seem to take into account that newValue can be set even when removing a prop
286
- const change = chg;
287
- const node = (0, internal_ts_1.getStateTreeNode)(change.object);
288
- const subpath = change.name;
289
- node.assertWritable({ subpath });
290
- const childType = node.type.properties[subpath];
291
- // only properties are typed, state are stored as-is references
292
- if (childType) {
293
- (0, internal_ts_1.typecheckInternal)(childType, change.newValue);
294
- change.newValue = childType.reconcile(node.getChildNode(subpath), change.newValue, node, subpath);
295
- }
296
- return change;
297
- }
298
- didChange(chg) {
299
- // TODO: mobx typings don't seem to take into account that newValue can be set even when removing a prop
300
- const change = chg;
301
- const childNode = (0, internal_ts_1.getStateTreeNode)(change.object);
302
- const childType = childNode.type.properties[change.name];
303
- if (!childType) {
304
- // don't emit patches for volatile state
305
- return;
306
- }
307
- const oldChildValue = change.oldValue ? change.oldValue.snapshot : undefined;
308
- childNode.emitPatch({
309
- op: "replace",
310
- path: (0, internal_ts_1.escapeJsonPath)(change.name),
311
- value: change.newValue.snapshot,
312
- oldValue: oldChildValue
313
- }, childNode);
314
- }
315
- getChildren(node) {
316
- const res = [];
317
- this.forAllProps(name => {
318
- res.push(this.getChildNode(node, name));
319
- });
320
- return res;
321
- }
322
- getChildNode(node, key) {
323
- if (!(key in this.properties)) {
324
- throw (0, internal_ts_1.fail)("Not a value property: " + key);
325
- }
326
- const adm = (0, mobx_1._getAdministration)(node.storedValue, key);
327
- const childNode = adm.raw?.();
328
- if (!childNode) {
329
- throw (0, internal_ts_1.fail)("Node not available for property " + key);
330
- }
331
- return childNode;
332
- }
333
- getSnapshot(node, applyPostProcess = true) {
334
- const res = {};
335
- this.forAllProps((name, _type) => {
336
- try {
337
- // TODO: FIXME, make sure the observable ref is used!
338
- const atom = (0, mobx_1.getAtom)(node.storedValue, name);
339
- atom.reportObserved();
340
- }
341
- catch (_e) {
342
- throw (0, internal_ts_1.fail)(`${name} property is declared twice`);
343
- }
344
- res[name] = this.getChildNode(node, name).snapshot;
345
- });
346
- if (applyPostProcess) {
347
- return this.applySnapshotPostProcessor(res);
348
- }
349
- return res;
350
- }
351
- processInitialSnapshot(childNodes) {
352
- const processed = {};
353
- Object.keys(childNodes).forEach(key => {
354
- processed[key] = childNodes[key].getSnapshot();
355
- });
356
- return this.applySnapshotPostProcessor(processed);
357
- }
358
- applyPatchLocally(node, subpath, patch) {
359
- if (!(patch.op === "replace" || patch.op === "add")) {
360
- throw (0, internal_ts_1.fail)(`object does not support operation ${patch.op}`);
361
- }
362
- ;
363
- node.storedValue[subpath] = patch.value;
364
- }
365
- applySnapshot(node, snapshot) {
366
- (0, internal_ts_1.typecheckInternal)(this, snapshot);
367
- const preProcessedSnapshot = this.applySnapshotPreProcessor(snapshot);
368
- this.forAllProps(name => {
369
- ;
370
- node.storedValue[name] = preProcessedSnapshot[name];
371
- });
372
- }
373
- applySnapshotPreProcessor(snapshot) {
374
- const processor = this.preProcessor;
375
- return processor ? processor.call(null, snapshot) : snapshot;
376
- }
377
- applySnapshotPostProcessor(snapshot) {
378
- const postProcessor = this.postProcessor;
379
- if (postProcessor) {
380
- return postProcessor.call(null, snapshot);
381
- }
382
- return snapshot;
383
- }
384
- getChildType(propertyName) {
385
- (0, internal_ts_1.assertIsString)(propertyName, 1);
386
- return this.properties[propertyName];
387
- }
388
- isValidSnapshot(value, context) {
389
- const snapshot = this.applySnapshotPreProcessor(value);
390
- if (!(0, internal_ts_1.isPlainObject)(snapshot)) {
391
- return (0, internal_ts_1.typeCheckFailure)(context, snapshot, "Value is not a plain object");
392
- }
393
- for (const key of this.propertyNames) {
394
- const propType = this.properties[key];
395
- (0, internal_ts_1.getContextForPath)(context, key, propType);
396
- const errors = propType.validate(snapshot[key], context);
397
- (0, internal_ts_1.popContext)(context);
398
- if (errors.length > 0) {
399
- return errors;
400
- }
401
- }
402
- return (0, internal_ts_1.typeCheckSuccess)();
403
- }
404
- forAllProps(fn) {
405
- this.propertyNames.forEach(key => fn(key, this.properties[key]));
406
- }
407
- describe() {
408
- // optimization: cache
409
- return ("{ " +
410
- this.propertyNames
411
- .map(key => key + ": " + this.properties[key].describe())
412
- .join("; ") +
413
- " }");
414
- }
415
- getDefaultSnapshot() {
416
- return internal_ts_1.EMPTY_OBJECT;
417
- }
418
- removeChild(node, subpath) {
419
- ;
420
- node.storedValue[subpath] = undefined;
421
- }
422
- }
423
- exports.ModelType = ModelType;
424
- ModelType.prototype.applySnapshot = (0, mobx_1.action)(ModelType.prototype.applySnapshot);
425
- /**
426
- * `types.model` - Creates a new model type by providing a name, properties, volatile state and actions.
427
- *
428
- * See the [model type](/concepts/trees#creating-models) description or the [getting started](intro/getting-started.md#getting-started-1) tutorial.
429
- */
430
- function model(...args) {
431
- if ((0, internal_ts_1.devMode)() && typeof args[0] !== "string" && args[1]) {
432
- throw (0, internal_ts_1.fail)("Model creation failed. First argument must be a string when two arguments are provided");
433
- }
434
- const name = typeof args[0] === "string" ? args.shift() : "AnonymousModel";
435
- const properties = args.shift() || {};
436
- return new ModelType({ name, properties });
437
- }
438
- /**
439
- * `types.compose` - Composes a new model from one or more existing model types.
440
- * This method can be invoked in two forms:
441
- * Given 2 or more model types, the types are composed into a new Type.
442
- * Given first parameter as a string and 2 or more model types,
443
- * the types are composed into a new Type with the given name
444
- */
445
- function compose(...args) {
446
- // TODO: just join the base type names if no name is provided
447
- const hasTypename = typeof args[0] === "string";
448
- const typeName = hasTypename ? args[0] : "AnonymousModel";
449
- if (hasTypename) {
450
- args.shift();
451
- }
452
- // check all parameters
453
- if ((0, internal_ts_1.devMode)()) {
454
- args.forEach((type, i) => {
455
- (0, internal_ts_1.assertArg)(type, isModelType, "mobx-state-tree model type", hasTypename ? i + 2 : i + 1);
456
- });
457
- }
458
- return args
459
- .reduce((prev, cur) => prev.cloneAndEnhance({
460
- name: prev.name + "_" + cur.name,
461
- properties: cur.properties,
462
- initializers: cur.initializers,
463
- preProcessor: (snapshot) => cur.applySnapshotPreProcessor(prev.applySnapshotPreProcessor(snapshot)),
464
- postProcessor: (snapshot) => cur.applySnapshotPostProcessor(prev.applySnapshotPostProcessor(snapshot))
465
- }))
466
- .named(typeName);
467
- }
468
- /**
469
- * Returns if a given value represents a model type.
470
- *
471
- * @param type
472
- * @returns
473
- */
474
- function isModelType(type) {
475
- return (0, internal_ts_1.isType)(type) && (type.flags & internal_ts_1.TypeFlags.Object) > 0;
476
- }
477
- //# sourceMappingURL=model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/types/complex-types/model.ts"],"names":[],"mappings":";;;AAu0BA,sBAUC;AA0DD,0BAqCC;AAQD,kCAIC;AA57BD,+BAca;AAEb,mDA4C0B;AAE1B,MAAM,oBAAoB,GAAG,oBAAoB,CAAA;AACjD,MAAM,qBAAqB,GAAG,qBAAqB,CAAA;AAwMnD,SAAS,kBAAkB;IACzB,OAAO,IAAA,8BAAgB,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC1C,CAAC;AAcD,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,gBAAgB;IACtB,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,yBAAW;CAC1B,CAAA;AAED,SAAS,kBAAkB,CACzB,aAAyC;IAEzC,MAAM,QAAQ,GAAG,MAA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e, maybeNull, model, optional, reference, refinement, safeReference, resilient, snapshotProcessor, union } from "../internal.ts";
2
- export declare const types: {
3
- enumeration: typeof enumeration;
4
- model: typeof model;
5
- compose: typeof compose;
6
- custom: typeof custom;
7
- reference: typeof reference;
8
- safeReference: typeof safeReference;
9
- union: typeof union;
10
- optional: typeof optional;
11
- literal: typeof literal;
12
- maybe: typeof maybe;
13
- maybeNull: typeof maybeNull;
14
- refinement: typeof refinement;
15
- string: import("../internal.ts").ISimpleType<string>;
16
- boolean: import("../internal.ts").ISimpleType<boolean>;
17
- number: import("../internal.ts").ISimpleType<number>;
18
- integer: import("../internal.ts").ISimpleType<number>;
19
- float: import("../internal.ts").ISimpleType<number>;
20
- finite: import("../internal.ts").ISimpleType<number>;
21
- Date: import("../internal.ts").IType<number | Date, number, Date>;
22
- map: typeof map;
23
- array: typeof array;
24
- frozen: typeof frozen;
25
- identifier: import("../internal.ts").ISimpleType<string>;
26
- identifierNumber: import("../internal.ts").ISimpleType<number>;
27
- late: typeof late;
28
- lazy: typeof lazy;
29
- undefined: import("../internal.ts").ISimpleType<undefined>;
30
- null: import("../internal.ts").ISimpleType<null>;
31
- snapshotProcessor: typeof snapshotProcessor;
32
- resilient: typeof resilient;
33
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.types = void 0;
4
- // we import the types to re-export them inside types.
5
- const internal_ts_1 = require("../internal.js");
6
- exports.types = {
7
- enumeration: internal_ts_1.enumeration,
8
- model: internal_ts_1.model,
9
- compose: internal_ts_1.compose,
10
- custom: internal_ts_1.custom,
11
- reference: internal_ts_1.reference,
12
- safeReference: internal_ts_1.safeReference,
13
- union: internal_ts_1.union,
14
- optional: internal_ts_1.optional,
15
- literal: internal_ts_1.literal,
16
- maybe: internal_ts_1.maybe,
17
- maybeNull: internal_ts_1.maybeNull,
18
- refinement: internal_ts_1.refinement,
19
- string: internal_ts_1.string,
20
- boolean: internal_ts_1.boolean,
21
- number: internal_ts_1.number,
22
- integer: internal_ts_1.integer,
23
- float: internal_ts_1.float,
24
- finite: internal_ts_1.finite,
25
- Date: internal_ts_1.DatePrimitive,
26
- map: internal_ts_1.map,
27
- array: internal_ts_1.array,
28
- frozen: internal_ts_1.frozen,
29
- identifier: internal_ts_1.identifier,
30
- identifierNumber: internal_ts_1.identifierNumber,
31
- late: internal_ts_1.late,
32
- lazy: internal_ts_1.lazy,
33
- undefined: internal_ts_1.undefinedType,
34
- null: internal_ts_1.nullType,
35
- snapshotProcessor: internal_ts_1.snapshotProcessor,
36
- resilient: internal_ts_1.resilient
37
- };
38
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,gDA+BuB;AAEV,QAAA,KAAK,GAAG;IACnB,WAAW,EAAX,yBAAW;IACX,KAAK,EAAL,mBAAK;IACL,OAAO,EAAP,qBAAO;IACP,MAAM,EAAN,oBAAM;IACN,SAAS,EAAT,uBAAS;IACT,aAAa,EAAb,2BAAa;IACb,KAAK,EAAL,mBAAK;IACL,QAAQ,EAAR,sBAAQ;IACR,OAAO,EAAP,qBAAO;IACP,KAAK,EAAL,mBAAK;IACL,SAAS,EAAT,uBAAS;IACT,UAAU,EAAV,wBAAU;IACV,MAAM,EAAN,oBAAM;IACN,OAAO,EAAP,qBAAO;IACP,MAAM,EAAN,oBAAM;IACN,OAAO,EAAP,qBAAO;IACP,KAAK,EAAL,mBAAK;IACL,MAAM,EAAN,oBAAM;IACN,IAAI,EAAE,2BAAa;IACnB,GAAG,EAAH,iBAAG;IACH,KAAK,EAAL,mBAAK;IACL,MAAM,EAAN,oBAAM;IACN,UAAU,EAAV,wBAAU;IACV,gBAAgB,EAAhB,8BAAgB;IAChB,IAAI,EAAJ,kBAAI;IACJ,IAAI,EAAJ,kBAAI;IACJ,SAAS,EAAE,2BAAa;IACxB,IAAI,EAAE,sBAAQ;IACd,iBAAiB,EAAjB,+BAAiB;IACjB,SAAS,EAAT,uBAAS;CACV,CAAA"}