New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 0.6.3 to 0.7.0

lib/core/identifier-cache.d.ts

21

changelog.md

@@ -0,11 +1,22 @@

# 0.7.0
The type system and internal administration has been refactoring, making the internals both simpler and more flexible.
Things like references and identifiers are now first class types, making them much better composable.
* **BREAKING** References with a predefined lookup path are no longer supported. Instead of that, identifiers are now looked up in the entire tree. For that reasons identifiers now have to be unique in the entire tree, per type.
* **BREAKING** `resolve` is renamed to `resolvePath`
* Introduced `resolveIdentifier(type, tree, identifier)` to find objects by identifier
* **BREAKING** `types.reference` is by default non-nullable. For nullable identifiers, use `types.maybe(types.reference(X))`
* Many, many improvements. Related open issues will be updated.
# 0.6.3
Fixed issue with array/maps of union types @abruzzihraig
Make types.extend support computed attributes @cpunion
Fixed issue with map of primitive types and applySnapshot @pioh
Better type declarations for union, up to 10 supported types
* Fixed issue with array/maps of union types @abruzzihraig
* Make types.extend support computed attributes @cpunion
* Fixed issue with map of primitive types and applySnapshot @pioh
* Better type declarations for union, up to 10 supported types
# 0.6.2
Fixed issue where arrays where not properly serialized as action argument
* Fixed issue where arrays where not properly serialized as action argument

@@ -12,0 +23,0 @@ # 0.6.1

@@ -8,3 +8,3 @@ export declare type ISerializedActionCall = {

name: string;
object: any & IMSTNode;
object: any & IComplexValue;
args: any[];

@@ -24,5 +24,5 @@ };

*/
export declare function applyAction(target: IMSTNode, action: ISerializedActionCall): any;
export declare function onAction(target: IMSTNode, listener: (call: ISerializedActionCall) => void): IDisposer;
import { IMSTNode } from "./mst-node";
export declare function applyAction(target: IComplexValue, action: ISerializedActionCall): any;
export declare function onAction(target: IComplexValue, listener: (call: ISerializedActionCall) => void): IDisposer;
import { IComplexValue } from "./node";
import { IDisposer } from "../utils";

@@ -34,3 +34,3 @@ "use strict";

var actionInvoker = function () {
var adm = mst_node_1.getMSTAdministration(this);
var adm = node_1.getStateTreeNode(this);
adm.assertAlive();

@@ -45,3 +45,3 @@ if (adm.isRunningAction()) {

name: name,
object: adm.target,
object: adm.storedValue,
args: utils_1.argsToArray(arguments)

@@ -64,11 +64,11 @@ };

exports.createActionInvoker = createActionInvoker;
function serializeArgument(adm, actionName, index, arg) {
function serializeArgument(node, actionName, index, arg) {
if (utils_1.isPrimitive(arg))
return arg;
if (mst_node_1.isMST(arg)) {
var targetNode = mst_node_1.getMSTAdministration(arg);
if (adm.root !== targetNode.root)
if (node_1.isStateTreeNode(arg)) {
var targetNode = node_1.getStateTreeNode(arg);
if (node.root !== targetNode.root)
throw new Error("Argument " + index + " that was passed to action '" + actionName + "' is a model that is not part of the same state tree. Consider passing a snapshot or some representative ID instead");
return ({
$ref: mst_node_1.getRelativePathForNodes(adm, mst_node_1.getMSTAdministration(arg))
$ref: node.getRelativePathTo(node_1.getStateTreeNode(arg))
});

@@ -96,3 +96,3 @@ }

if (keys.length === 1 && keys[0] === "$ref")
return mst_operations_1.resolve(adm.target, value.$ref);
return mst_operations_1.resolvePath(adm.storedValue, value.$ref);
}

@@ -115,3 +115,3 @@ return value;

return utils_1.fail("Invalid action path: " + (action.path || ""));
var node = mst_node_1.getMSTAdministration(resolvedTarget);
var node = node_1.getStateTreeNode(resolvedTarget);
if (!(typeof resolvedTarget[action.name] === "function"))

@@ -124,6 +124,6 @@ utils_1.fail("Action '" + action.name + "' does not exist in '" + node.path + "'");

return mst_operations_1.addMiddleware(target, function (rawCall, next) {
var sourceNode = mst_node_1.getMSTAdministration(rawCall.object);
var sourceNode = node_1.getStateTreeNode(rawCall.object);
listener({
name: rawCall.name,
path: mst_node_1.getRelativePathForNodes(mst_node_1.getMSTAdministration(target), sourceNode),
path: node_1.getStateTreeNode(target).getRelativePathTo(sourceNode),
args: rawCall.args.map(function (arg, index) { return serializeArgument(sourceNode, rawCall.name, index, arg); })

@@ -135,5 +135,5 @@ });

exports.onAction = onAction;
var mst_node_1 = require("./mst-node");
var node_1 = require("./node");
var mst_operations_1 = require("./mst-operations");
var utils_1 = require("../utils");
//# sourceMappingURL=action.js.map

@@ -1,5 +0,4 @@

export * from "./mst-node";
export * from "./mst-node-administration";
export * from "./node";
export * from "./action";
export * from "./json-patch";
export * from "./mst-operations";

@@ -6,4 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./mst-node"));
__export(require("./mst-node-administration"));
__export(require("./node"));
__export(require("./action"));

@@ -10,0 +9,0 @@ __export(require("./json-patch"));

@@ -0,0 +0,0 @@ export declare type IJsonPatch = {

@@ -0,0 +0,0 @@ "use strict";

import { IRawActionCall, ISerializedActionCall } from "./action";
import { IObservableArray, ObservableMap } from "mobx";
import { IMSTNode } from "./mst-node";
import { IComplexValue } from "./node";
import { IJsonPatch } from "./json-patch";
import { IDisposer } from "../utils";
import { ISnapshottable, IType } from "../types/type";
export declare function getType<S, T>(object: IComplexValue): IType<S, T>;
export declare function getChildType(object: IComplexValue, child: string): IType<any, any>;
/**

@@ -49,3 +51,3 @@ * TODO: update docs

*/
export declare function addMiddleware(target: IMSTNode, middleware: (action: IRawActionCall, next: (call: IRawActionCall) => any) => any): IDisposer;
export declare function addMiddleware(target: IComplexValue, middleware: (action: IRawActionCall, next: (call: IRawActionCall) => any) => any): IDisposer;
/**

@@ -61,3 +63,3 @@ * Registers a function that will be invoked for each that as made to the provided model instance, or any of it's children.

*/
export declare function onPatch(target: IMSTNode, callback: (patch: IJsonPatch) => void): IDisposer;
export declare function onPatch(target: IComplexValue, callback: (patch: IJsonPatch) => void): IDisposer;
/**

@@ -85,3 +87,3 @@ * Registeres a function that is invoked whenever a new snapshot for the given model instance is available.

*/
export declare function applyPatch(target: IMSTNode, patch: IJsonPatch): void;
export declare function applyPatch(target: IComplexValue, patch: IJsonPatch): void;
/**

@@ -94,9 +96,9 @@ * Applies a number of JSON patches in a single MobX transaction

*/
export declare function applyPatches(target: IMSTNode, patches: IJsonPatch[]): void;
export declare function applyPatches(target: IComplexValue, patches: IJsonPatch[]): void;
export interface IPatchRecorder {
patches: IJsonPatch[];
stop(): any;
replay(target: IMSTNode): any;
replay(target: IComplexValue): any;
}
export declare function recordPatches(subject: IMSTNode): IPatchRecorder;
export declare function recordPatches(subject: IComplexValue): IPatchRecorder;
/**

@@ -113,9 +115,9 @@ * Applies a series of actions in a single MobX transaction.

*/
export declare function applyActions(target: IMSTNode, actions: ISerializedActionCall[]): void;
export declare function applyActions(target: IComplexValue, actions: ISerializedActionCall[]): void;
export interface IActionRecorder {
actions: ISerializedActionCall[];
stop(): any;
replay(target: IMSTNode): any;
replay(target: IComplexValue): any;
}
export declare function recordActions(subject: IMSTNode): IActionRecorder;
export declare function recordActions(subject: IComplexValue): IActionRecorder;
/**

@@ -141,8 +143,8 @@ * By default it is allowed to both directly modify a model or through an action.

*/
export declare function protect(target: IMSTNode): void;
export declare function unprotect(target: IMSTNode): void;
export declare function protect(target: IComplexValue): void;
export declare function unprotect(target: IComplexValue): void;
/**
* Returns true if the object is in protected mode, @see protect
*/
export declare function isProtected(target: IMSTNode): boolean;
export declare function isProtected(target: IComplexValue): boolean;
/**

@@ -156,3 +158,3 @@ * Applies a snapshot to a given model instances. Patch and snapshot listeners will be invoked as usual.

*/
export declare function applySnapshot<S, T>(target: IMSTNode, snapshot: S): void;
export declare function applySnapshot<S, T>(target: IComplexValue, snapshot: S): void;
/**

@@ -179,3 +181,3 @@ * Calculates a snapshot from the given model instance. The snapshot will always reflect the latest state but use

*/
export declare function hasParent(target: IMSTNode, depth?: number): boolean;
export declare function hasParent(target: IComplexValue, depth?: number): boolean;
/**

@@ -192,4 +194,4 @@ * Returns the immediate parent of this object, or null.

*/
export declare function getParent(target: IMSTNode, depth?: number): (any & IMSTNode);
export declare function getParent<T>(target: IMSTNode, depth?: number): (T & IMSTNode);
export declare function getParent(target: IComplexValue, depth?: number): (any & IComplexValue);
export declare function getParent<T>(target: IComplexValue, depth?: number): (T & IComplexValue);
/**

@@ -202,4 +204,4 @@ * Given an object in a model tree, returns the root object of that tree

*/
export declare function getRoot(target: IMSTNode): any & IMSTNode;
export declare function getRoot<T>(target: IMSTNode): T & IMSTNode;
export declare function getRoot(target: IComplexValue): any & IComplexValue;
export declare function getRoot<T>(target: IComplexValue): T & IComplexValue;
/**

@@ -212,3 +214,3 @@ * Returns the path of the given object in the model tree

*/
export declare function getPath(target: IMSTNode): string;
export declare function getPath(target: IComplexValue): string;
/**

@@ -221,3 +223,3 @@ * Returns the path of the given object as unescaped string array

*/
export declare function getPathParts(target: IMSTNode): string[];
export declare function getPathParts(target: IComplexValue): string[];
/**

@@ -230,3 +232,3 @@ * Returns true if the given object is the root of a model tree

*/
export declare function isRoot(target: IMSTNode): boolean;
export declare function isRoot(target: IComplexValue): boolean;
/**

@@ -240,3 +242,4 @@ * Resolves a path relatively to a given object.

*/
export declare function resolve(target: IMSTNode, path: string): IMSTNode | any;
export declare function resolvePath(target: IComplexValue, path: string): IComplexValue | any;
export declare function resolveIdentifier(type: IType<any, any>, target: IComplexValue, identifier: string | number): any;
/**

@@ -250,4 +253,4 @@ *

*/
export declare function tryResolve(target: IMSTNode, path: string): IMSTNode | any;
export declare function getRelativePath(base: IMSTNode, target: IMSTNode): string;
export declare function tryResolve(target: IComplexValue, path: string): IComplexValue | any;
export declare function getRelativePath(base: IComplexValue, target: IComplexValue): string;
/**

@@ -261,18 +264,17 @@ *

*/
export declare function clone<T extends IMSTNode>(source: T, keepEnvironment?: boolean | any): T;
export declare function clone<T extends IComplexValue>(source: T, keepEnvironment?: boolean | any): T;
/**
* Removes a model element from the state tree, and let it live on as a new state tree
*/
export declare function detach<T extends IMSTNode>(thing: T): T;
export declare function detach<T extends IComplexValue>(thing: T): T;
/**
* Removes a model element from the state tree, and mark it as end-of-life; the element should not be used anymore
*/
export declare function destroy(thing: IMSTNode): void;
export declare function isAlive(thing: IMSTNode): boolean;
export declare function addDisposer(thing: IMSTNode, disposer: () => void): void;
export declare function getEnv(thing: IMSTNode): any;
export declare function destroy(thing: IComplexValue): void;
export declare function isAlive(thing: IComplexValue): boolean;
export declare function addDisposer(thing: IComplexValue, disposer: () => void): void;
export declare function getEnv(thing: IComplexValue): any;
/**
* Performs a depth first walk through a tree
*/
export declare function walk(thing: IMSTNode, processor: (item: IMSTNode) => void): void;
export declare function testActions<S, T>(factory: IType<S, IMSTNode>, initialState: S, ...actions: ISerializedActionCall[]): S;
export declare function walk(thing: IComplexValue, processor: (item: IComplexValue) => void): void;

@@ -5,5 +5,14 @@ "use strict";

var mobx_1 = require("mobx");
var mst_node_1 = require("./mst-node");
var node_1 = require("./node");
var json_patch_1 = require("./json-patch");
var utils_1 = require("../utils");
var type_1 = require("../types/type");
function getType(object) {
return node_1.getStateTreeNode(object).type;
}
exports.getType = getType;
function getChildType(object, child) {
return node_1.getStateTreeNode(object).getChildType(child);
}
exports.getChildType = getChildType;
/**

@@ -52,3 +61,3 @@ * TODO: update docs

function addMiddleware(target, middleware) {
var node = mst_node_1.getMSTAdministration(target);
var node = node_1.getStateTreeNode(target);
if (!node.isProtectionEnabled)

@@ -70,7 +79,7 @@ console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`");

function onPatch(target, callback) {
return mst_node_1.getMSTAdministration(target).onPatch(callback);
return node_1.getStateTreeNode(target).onPatch(callback);
}
exports.onPatch = onPatch;
function onSnapshot(target, callback) {
return mst_node_1.getMSTAdministration(target).onSnapshot(callback);
return node_1.getStateTreeNode(target).onSnapshot(callback);
}

@@ -87,3 +96,3 @@ exports.onSnapshot = onSnapshot;

function applyPatch(target, patch) {
return mst_node_1.getMSTAdministration(target).applyPatch(patch);
return node_1.getStateTreeNode(target).applyPatch(patch);
}

@@ -99,3 +108,3 @@ exports.applyPatch = applyPatch;

function applyPatches(target, patches) {
var node = mst_node_1.getMSTAdministration(target);
var node = node_1.getStateTreeNode(target);
mobx_1.runInAction(function () {

@@ -171,3 +180,3 @@ patches.forEach(function (p) { return node.applyPatch(p); });

// TODO: verify that no parent is unprotectd, as that would be a noop
mst_node_1.getMSTAdministration(target).isProtectionEnabled = true;
node_1.getStateTreeNode(target).isProtectionEnabled = true;
}

@@ -177,3 +186,3 @@ exports.protect = protect;

// TODO: verify that any node in the given tree is unprotected
mst_node_1.getMSTAdministration(target).isProtectionEnabled = false;
node_1.getStateTreeNode(target).isProtectionEnabled = false;
}

@@ -185,3 +194,3 @@ exports.unprotect = unprotect;

function isProtected(target) {
return mst_node_1.getMSTAdministration(target).isProtectionEnabled;
return node_1.getStateTreeNode(target).isProtectionEnabled;
}

@@ -198,7 +207,7 @@ exports.isProtected = isProtected;

function applySnapshot(target, snapshot) {
return mst_node_1.getMSTAdministration(target).applySnapshot(snapshot);
return node_1.getStateTreeNode(target).applySnapshot(snapshot);
}
exports.applySnapshot = applySnapshot;
function getSnapshot(target) {
return mst_node_1.getMSTAdministration(target).snapshot;
return node_1.getStateTreeNode(target).snapshot;
}

@@ -218,3 +227,3 @@ exports.getSnapshot = getSnapshot;

utils_1.fail("Invalid depth: " + depth + ", should be >= 1");
var parent = mst_node_1.getMSTAdministration(target).parent;
var parent = node_1.getStateTreeNode(target).parent;
while (parent) {

@@ -233,13 +242,13 @@ if (--depth === 0)

var d = depth;
var parent = mst_node_1.getMSTAdministration(target).parent;
var parent = node_1.getStateTreeNode(target).parent;
while (parent) {
if (--d === 0)
return parent.target;
return parent.storedValue;
parent = parent.parent;
}
return utils_1.fail("Failed to find the parent of " + mst_node_1.getMSTAdministration(target) + " at depth " + depth);
return utils_1.fail("Failed to find the parent of " + node_1.getStateTreeNode(target) + " at depth " + depth);
}
exports.getParent = getParent;
function getRoot(target) {
return mst_node_1.getMSTAdministration(target).root.target;
return node_1.getStateTreeNode(target).root.storedValue;
}

@@ -255,3 +264,3 @@ exports.getRoot = getRoot;

function getPath(target) {
return mst_node_1.getMSTAdministration(target).path;
return node_1.getStateTreeNode(target).path;
}

@@ -267,3 +276,3 @@ exports.getPath = getPath;

function getPathParts(target) {
return json_patch_1.splitJsonPath(mst_node_1.getMSTAdministration(target).path);
return json_patch_1.splitJsonPath(node_1.getStateTreeNode(target).path);
}

@@ -279,3 +288,3 @@ exports.getPathParts = getPathParts;

function isRoot(target) {
return mst_node_1.getMSTAdministration(target).isRoot;
return node_1.getStateTreeNode(target).isRoot;
}

@@ -291,9 +300,16 @@ exports.isRoot = isRoot;

*/
function resolve(target, path) {
function resolvePath(target, path) {
// TODO: give better error messages!
// TODO: also accept path parts
var node = mst_node_1.getMSTAdministration(target).resolve(path);
return node ? node.target : undefined;
var node = node_1.getStateTreeNode(target).resolve(path);
return node ? node.getValue() : undefined;
}
exports.resolve = resolve;
exports.resolvePath = resolvePath;
function resolveIdentifier(type, target, identifier) {
if (!type_1.isType(type))
utils_1.fail("Expected a type as first argument");
var node = node_1.getStateTreeNode(target).root.identifierCache.resolve(type, "" + identifier);
return node ? node.getValue() : undefined;
}
exports.resolveIdentifier = resolveIdentifier;
/**

@@ -308,10 +324,10 @@ *

function tryResolve(target, path) {
var node = mst_node_1.getMSTAdministration(target).resolve(path, false);
var node = node_1.getStateTreeNode(target).resolve(path, false);
if (node === undefined)
return undefined;
return node ? node.target : undefined;
return node ? node.getValue() : undefined;
}
exports.tryResolve = tryResolve;
function getRelativePath(base, target) {
return mst_node_1.getRelativePathForNodes(mst_node_1.getMSTAdministration(base), mst_node_1.getMSTAdministration(target));
return node_1.getStateTreeNode(base).getRelativePathTo(node_1.getStateTreeNode(target));
}

@@ -329,3 +345,3 @@ exports.getRelativePath = getRelativePath;

if (keepEnvironment === void 0) { keepEnvironment = true; }
var node = mst_node_1.getMSTAdministration(source);
var node = node_1.getStateTreeNode(source);
return node.type.create(node.snapshot, keepEnvironment === true

@@ -344,3 +360,3 @@ ? node.root._environment

// TODO: should throw if it cannot be removed from the parent? e.g. parent type wouldn't allow that
mst_node_1.getMSTAdministration(thing).detach();
node_1.getStateTreeNode(thing).detach();
return thing;

@@ -353,3 +369,3 @@ }

function destroy(thing) {
var node = mst_node_1.getMSTAdministration(thing);
var node = node_1.getStateTreeNode(thing);
// TODO: should throw if it cannot be removed from the parent? e.g. parent type wouldn't allow that

@@ -363,11 +379,11 @@ if (node.isRoot)

function isAlive(thing) {
return mst_node_1.getMSTAdministration(thing).isAlive;
return node_1.getStateTreeNode(thing).isAlive;
}
exports.isAlive = isAlive;
function addDisposer(thing, disposer) {
mst_node_1.getMSTAdministration(thing).addDisposer(disposer);
node_1.getStateTreeNode(thing).addDisposer(disposer);
}
exports.addDisposer = addDisposer;
function getEnv(thing) {
var node = mst_node_1.getMSTAdministration(thing);
var node = node_1.getStateTreeNode(thing);
var env = node.root._environment;

@@ -383,22 +399,11 @@ if (!(!!env))

function walk(thing, processor) {
var node = mst_node_1.getMSTAdministration(thing);
var node = node_1.getStateTreeNode(thing);
// tslint:disable-next-line:no_unused-variable
node.getChildMSTs().forEach(function (_a) {
var _ = _a[0], childNode = _a[1];
walk(childNode.target, processor);
node.getChildren().forEach(function (child) {
if (node_1.isStateTreeNode(child.storedValue))
walk(child.storedValue, processor);
});
processor(node.target);
processor(node.storedValue);
}
exports.walk = walk;
// TODO: remove
function testActions(factory, initialState) {
var actions = [];
for (var _i = 2; _i < arguments.length; _i++) {
actions[_i - 2] = arguments[_i];
}
var testInstance = factory.create(initialState);
applyActions(testInstance, actions);
return getSnapshot(testInstance);
}
exports.testActions = testActions;
//# sourceMappingURL=mst-operations.js.map

@@ -0,7 +1,7 @@

import "./core/node";
import "./types/type";
import "./types/complex-types/complex-type";
export { types, IType } from "./types";
export * from "./core/mst-operations";
export * from "./core/json-patch";
export { isMST, getType, getChildType, onAction, applyAction } from "./core";
export { isStateTreeNode, getType, getChildType, onAction, applyAction } from "./core";
export { asReduxStore, IReduxStore, connectReduxDevtools } from "./interop/redux";

@@ -7,4 +7,4 @@ "use strict";

// Fix some circular deps:
require("./core/node");
require("./types/type");
require("./types/complex-types/complex-type");
// TODO: things that should not be exposed (?)

@@ -19,3 +19,3 @@ // TODO: add test to verify exposed api

var core_1 = require("./core");
exports.isMST = core_1.isMST;
exports.isStateTreeNode = core_1.isStateTreeNode;
exports.getType = core_1.getType;

@@ -22,0 +22,0 @@ exports.getChildType = core_1.getChildType;

@@ -0,0 +0,0 @@ import { IRawActionCall } from "../core";

@@ -12,3 +12,3 @@ "use strict";

}
if (!core_1.isMST(model))
if (!core_1.isStateTreeNode(model))
utils_1.fail("Expected model object");

@@ -15,0 +15,0 @@ var store = {

import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx";
import { IJsonPatch, MSTAdministration } from "../../core";
import { IType, IComplexType, TypeFlags } from "../type";
import { IJsonPatch, Node } from "../../core";
import { IType, IComplexType, TypeFlags, ComplexType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";
export declare function arrayToString(this: IObservableArray<any>): string;
export declare class ArrayType<S, T> extends ComplexType<S[], IObservableArray<T>> {
isArrayFactory: boolean;
shouldAttachNode: boolean;
subType: IType<any, any>;

@@ -13,18 +12,19 @@ readonly flags: TypeFlags;

describe(): string;
createNewInstance(): IObservableArray<{}>;
finalizeNewInstance(instance: IObservableArray<any>, snapshot: any): void;
getChildMSTs(node: MSTAdministration): [string, MSTAdministration][];
getChildMST(node: MSTAdministration, key: string): MSTAdministration | null;
createNewInstance: () => IObservableArray<{}>;
finalizeNewInstance: (node: Node, snapshot: any) => void;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: S): Node;
getChildren(node: Node): Node[];
getChildNode(node: Node, key: string): Node;
willChange(change: IArrayWillChange<any> | IArrayWillSplice<any>): Object | null;
serialize(node: MSTAdministration): any;
getValue(node: Node): any;
getSnapshot(node: Node): any;
didChange(this: {}, change: IArrayChange<any> | IArraySplice<any>): void;
applyPatchLocally(node: MSTAdministration, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: MSTAdministration, snapshot: any[]): void;
applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: Node, snapshot: any[]): void;
getChildType(key: string): IType<any, any>;
isValidSnapshot(value: any, context: IContext): IValidationResult;
getDefaultSnapshot(): never[];
removeChild(node: MSTAdministration, subpath: string): void;
readonly identifierAttribute: null;
removeChild(node: Node, subpath: string): void;
}
export declare function array<S, T>(subtype: IType<S, T>): IComplexType<S[], IObservableArray<T>>;
export declare function isArrayFactory<S, T>(type: any): type is IComplexType<S[], IObservableArray<T>>;

@@ -24,5 +24,4 @@ "use strict";

var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");
function arrayToString() {
return core_1.getMSTAdministration(this) + "(" + this.length + " items)";
return core_1.getStateTreeNode(this) + "(" + this.length + " items)";
}

@@ -34,4 +33,16 @@ exports.arrayToString = arrayToString;

var _this = _super.call(this, name) || this;
_this.isArrayFactory = true;
_this.shouldAttachNode = true;
_this.flags = type_1.TypeFlags.Array;
_this.createNewInstance = function () {
var array = mobx_1.observable.shallowArray();
utils_1.addHiddenFinalProp(array, "toString", arrayToString);
return array;
};
_this.finalizeNewInstance = function (node, snapshot) {
var instance = node.storedValue;
mobx_1.extras.getAdministration(instance).dehancer = node.unbox;
mobx_1.intercept(instance, function (change) { return _this.willChange(change); });
mobx_1.observe(instance, _this.didChange);
node.applySnapshot(snapshot);
};
_this.subType = subType;

@@ -43,31 +54,18 @@ return _this;

};
ArrayType.prototype.createNewInstance = function () {
var array = mobx_1.observable.shallowArray();
utils_1.addHiddenFinalProp(array, "toString", arrayToString);
return array;
ArrayType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return core_1.createNode(this, parent, subpath, environment, snapshot, this.createNewInstance, this.finalizeNewInstance);
};
ArrayType.prototype.finalizeNewInstance = function (instance, snapshot) {
var _this = this;
mobx_1.intercept(instance, function (change) { return _this.willChange(change); });
mobx_1.observe(instance, this.didChange);
core_1.getMSTAdministration(instance).applySnapshot(snapshot);
ArrayType.prototype.getChildren = function (node) {
return node.storedValue.peek();
};
ArrayType.prototype.getChildMSTs = function (node) {
var target = node.target;
var res = [];
target.forEach(function (value, index) {
core_1.maybeMST(value, function (childNode) { res.push(["" + index, childNode]); });
});
return res;
};
ArrayType.prototype.getChildMST = function (node, key) {
var target = node.target;
ArrayType.prototype.getChildNode = function (node, key) {
var index = parseInt(key, 10);
if (index < target.length)
return core_1.maybeMST(target[index], utils_1.identity, utils_1.nothing);
return null;
if (index < node.storedValue.length)
return node.storedValue[index];
return utils_1.fail("Not a child: " + key);
};
ArrayType.prototype.willChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
node.assertWritable();
var childNodes = node.getChildren();
switch (change.type) {

@@ -77,15 +75,10 @@ case "update":

return null;
change.newValue = node.reconcileChildren(this.subType, [change.object[change.index]], [change.newValue], [change.index])[0];
change.newValue = node.reconcileChildren(node, this.subType, [childNodes[change.index]], [change.newValue], [change.index])[0];
break;
case "splice":
var index_1 = change.index, removedCount_1 = change.removedCount, added_1 = change.added, object = change.object;
change.added = node.reconcileChildren(this.subType, object.slice(index_1, index_1 + removedCount_1), added_1, added_1.map(function (_, i) { return index_1 + i; }));
var _loop_1 = function (i) {
core_1.maybeMST(object[i], function (child) {
child.setParent(node, "" + (i + added_1.length - removedCount_1));
});
};
var index_1 = change.index, removedCount = change.removedCount, added = change.added;
change.added = node.reconcileChildren(node, this.subType, childNodes.slice(index_1, index_1 + removedCount), added, added.map(function (_, i) { return index_1 + i; }));
// update paths of remaining items
for (var i = index_1 + removedCount_1; i < object.length; i++) {
_loop_1(i);
for (var i = index_1 + removedCount; i < childNodes.length; i++) {
childNodes[i].setParent(node, "" + (i + added.length - removedCount));
}

@@ -96,8 +89,10 @@ break;

};
ArrayType.prototype.serialize = function (node) {
var target = node.target;
return target.map(core_1.valueToSnapshot);
ArrayType.prototype.getValue = function (node) {
return node.storedValue;
};
ArrayType.prototype.getSnapshot = function (node) {
return node.getChildren().map(function (childNode) { return childNode.snapshot; });
};
ArrayType.prototype.didChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
switch (change.type) {

@@ -108,3 +103,3 @@ case "update":

path: "" + change.index,
value: core_1.valueToSnapshot(change.newValue)
value: node.getChildNode("" + change.index).snapshot
}, node);

@@ -121,3 +116,3 @@ case "splice":

path: "" + (change.index + i),
value: core_1.valueToSnapshot(change.added[i])
value: node.getChildNode("" + (change.index + i)).snapshot
}, node);

@@ -128,3 +123,3 @@ return;

ArrayType.prototype.applyPatchLocally = function (node, subpath, patch) {
var target = node.target;
var target = node.storedValue;
var index = subpath === "-" ? target.length : parseInt(subpath);

@@ -145,3 +140,3 @@ switch (patch.op) {

node.pseudoAction(function () {
var target = node.target;
var target = node.storedValue;
target.replace(snapshot);

@@ -164,13 +159,6 @@ });

ArrayType.prototype.removeChild = function (node, subpath) {
node.target.splice(parseInt(subpath, 10), 1);
node.storedValue.splice(parseInt(subpath, 10), 1);
};
Object.defineProperty(ArrayType.prototype, "identifierAttribute", {
get: function () {
return null;
},
enumerable: true,
configurable: true
});
return ArrayType;
}(complex_type_1.ComplexType));
}(type_1.ComplexType));
__decorate([

@@ -177,0 +165,0 @@ mobx_1.action

import { ObservableMap, IMapChange, IMapWillChange } from "mobx";
import { MSTAdministration, IJsonPatch } from "../../core";
import { IType, IComplexType, TypeFlags } from "../type";
import { IJsonPatch, Node } from "../../core";
import { IType, IComplexType, TypeFlags, ComplexType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";
export interface IExtendedObservableMap<T> extends ObservableMap<T> {

@@ -13,21 +12,25 @@ put(value: T | any): this;

}, IExtendedObservableMap<T>> {
isMapFactory: boolean;
shouldAttachNode: boolean;
subType: IType<any, any>;
readonly flags: TypeFlags;
constructor(name: string, subType: IType<any, any>);
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: S): Node;
describe(): string;
createNewInstance(): ObservableMap<{}>;
finalizeNewInstance(instance: ObservableMap<any>, snapshot: any): void;
getChildMSTs(node: MSTAdministration): [string, MSTAdministration][];
getChildMST(node: MSTAdministration, key: string): MSTAdministration | null;
createNewInstance: () => ObservableMap<{}>;
finalizeNewInstance: (node: Node, snapshot: any) => void;
getChildren(node: Node): Node[];
getChildNode(node: Node, key: string): Node;
willChange(change: IMapWillChange<any>): IMapWillChange<any> | null;
serialize(node: MSTAdministration): Object;
private verifyIdentifier(expected, node);
getValue(node: Node): any;
getSnapshot(node: Node): {
[key: string]: any;
};
didChange(change: IMapChange<any>): void;
applyPatchLocally(node: MSTAdministration, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: MSTAdministration, snapshot: any): void;
applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: Node, snapshot: any): void;
getChildType(key: string): IType<any, any>;
isValidSnapshot(value: any, context: IContext): IValidationResult;
getDefaultSnapshot(): {};
removeChild(node: MSTAdministration, subpath: string): void;
readonly identifierAttribute: null;
removeChild(node: Node, subpath: string): void;
}

@@ -34,0 +37,0 @@ export declare function map<S, T>(subtype: IType<S, T>): IComplexType<{

@@ -19,3 +19,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var object_1 = require("./object");
var mobx_1 = require("mobx");

@@ -26,14 +25,23 @@ var core_1 = require("../../core");

var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");
function mapToString() {
return core_1.getMSTAdministration(this) + "(" + this.size + " items)";
return core_1.getStateTreeNode(this) + "(" + this.size + " items)";
}
exports.mapToString = mapToString;
function put(value) {
var identifierAttr = object_1.getIdentifierAttribute(core_1.getMSTAdministration(this).type.subType);
if (!(!!identifierAttr))
utils_1.fail("Map.put is only supported if the subtype has an idenfier attribute");
if (!(!!value))
utils_1.fail("Map.put cannot be used to set empty values");
this.set(value[identifierAttr], value);
var node;
if (core_1.isStateTreeNode(value)) {
node = core_1.getStateTreeNode(value);
}
else if (utils_1.isMutable(value)) {
var targetType = core_1.getStateTreeNode(this).type.subType;
node = core_1.getStateTreeNode(targetType.create(value));
}
else {
return utils_1.fail("Map.put can only be used to store complex values");
}
if (!node.identifierAttribute)
utils_1.fail("Map.put can only be used to store complex values that have an identifier type attribute");
this.set(node.identifier, node.getValue());
return this;

@@ -45,43 +53,39 @@ }

var _this = _super.call(this, name) || this;
_this.isMapFactory = true;
_this.shouldAttachNode = true;
_this.flags = type_1.TypeFlags.Map;
_this.createNewInstance = function () {
// const identifierAttr = getIdentifierAttribute(this.subType)
var map = mobx_1.observable.shallowMap();
utils_1.addHiddenFinalProp(map, "put", put);
utils_1.addHiddenFinalProp(map, "toString", mapToString);
return map;
};
_this.finalizeNewInstance = function (node, snapshot) {
var instance = node.storedValue;
mobx_1.extras.interceptReads(instance, node.unbox);
mobx_1.intercept(instance, function (c) { return _this.willChange(c); });
mobx_1.observe(instance, _this.didChange);
node.applySnapshot(snapshot);
};
_this.subType = subType;
return _this;
}
MapType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return core_1.createNode(this, parent, subpath, environment, snapshot, this.createNewInstance, this.finalizeNewInstance);
};
MapType.prototype.describe = function () {
return "Map<string, " + this.subType.describe() + ">";
};
MapType.prototype.createNewInstance = function () {
// const identifierAttr = getIdentifierAttribute(this.subType)
var map = mobx_1.observable.shallowMap();
utils_1.addHiddenFinalProp(map, "put", put);
utils_1.addHiddenFinalProp(map, "toString", mapToString);
return map;
MapType.prototype.getChildren = function (node) {
return node.storedValue.values();
};
MapType.prototype.finalizeNewInstance = function (instance, snapshot) {
var _this = this;
mobx_1.intercept(instance, function (c) { return _this.willChange(c); });
mobx_1.observe(instance, this.didChange);
core_1.getMSTAdministration(instance).applySnapshot(snapshot);
MapType.prototype.getChildNode = function (node, key) {
var childNode = node.storedValue.get(key);
if (!childNode)
utils_1.fail("Not a child" + key);
return childNode;
};
MapType.prototype.getChildMSTs = function (node) {
var res = [];
node.target.forEach(function (value, key) {
core_1.maybeMST(value, function (childNode) { res.push([key, childNode]); });
});
return res;
};
MapType.prototype.getChildMST = function (node, key) {
var target = node.target;
if (target.has(key))
return core_1.maybeMST(target.get(key), utils_1.identity, utils_1.nothing);
return null;
};
MapType.prototype.willChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
node.assertWritable();
// Q: how to create a map that is not keyed by identifier, but contains objects with identifiers? Is that a use case? A: No, that is were reference maps should come into play...
var identifierAttr = object_1.getIdentifierAttribute(node.type);
if (identifierAttr && change.newValue && typeof change.newValue === "object" && change.newValue[identifierAttr] !== change.name)
utils_1.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + change.name + "', but expected: '" + change.newValue[identifierAttr] + "'");
switch (change.type) {

@@ -94,3 +98,4 @@ case "update":

return null;
change.newValue = node.reconcileChildren(this.subType, [oldValue], [newValue], [change.name])[0];
change.newValue = this.subType.reconcile(node.getChildNode(change.name), change.newValue);
this.verifyIdentifier(change.name, change.newValue);
}

@@ -100,4 +105,4 @@ break;

{
var newValue = change.newValue;
change.newValue = node.reconcileChildren(this.subType, [], [newValue], [change.name])[0];
change.newValue = this.subType.instantiate(node, change.name, undefined, change.newValue);
this.verifyIdentifier(change.name, change.newValue);
}

@@ -107,4 +112,3 @@ break;

{
var oldValue = change.object.get(change.name);
node.reconcileChildren(this.subType, [oldValue], [], []);
node.getChildNode(change.name).die();
}

@@ -115,7 +119,14 @@ break;

};
MapType.prototype.serialize = function (node) {
var target = node.target;
MapType.prototype.verifyIdentifier = function (expected, node) {
var identifier = node.identifier;
if (identifier !== null && identifier !== expected)
utils_1.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + identifier + "', but expected: '" + expected + "'");
};
MapType.prototype.getValue = function (node) {
return node.storedValue;
};
MapType.prototype.getSnapshot = function (node) {
var res = {};
target.forEach(function (value, key) {
res[key] = core_1.valueToSnapshot(value);
node.getChildren().forEach(function (childNode) {
res[childNode.subpath] = childNode.snapshot;
});

@@ -125,3 +136,3 @@ return res;

MapType.prototype.didChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
switch (change.type) {

@@ -133,3 +144,3 @@ case "update":

path: core_1.escapeJsonPath(change.name),
value: core_1.valueToSnapshot(change.newValue)
value: node.getChildNode(change.name).snapshot
}, node);

@@ -144,3 +155,3 @@ case "delete":

MapType.prototype.applyPatchLocally = function (node, subpath, patch) {
var target = node.target;
var target = node.storedValue;
switch (patch.op) {

@@ -157,25 +168,9 @@ case "add":

MapType.prototype.applySnapshot = function (node, snapshot) {
var _this = this;
node.pseudoAction(function () {
var target = node.target;
var identifierAttr = object_1.getIdentifierAttribute(_this.subType);
// Try to update snapshot smartly, by reusing instances under the same key as much as possible
var target = node.storedValue;
var currentKeys = {};
target.keys().forEach(function (key) { currentKeys[key] = false; });
// Don't use target.replace, as it will throw all existing items first
Object.keys(snapshot).forEach(function (key) {
var item = snapshot[key];
if (identifierAttr && item && typeof item === "object" && key !== item[identifierAttr])
utils_1.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + key + "', but expected: '" + item[identifierAttr] + "'");
// if snapshot[key] is non-primitive, and this.get(key) has a Node, update it, instead of replace
if (key in currentKeys && !utils_1.isPrimitive(item)) {
core_1.maybeMST(target.get(key), function (propertyNode) {
// update existing instance
propertyNode.applySnapshot(item);
}, function () {
target.set(key, item);
});
}
else {
target.set(key, item);
}
target.set(key, snapshot[key]);
currentKeys[key] = true;

@@ -203,13 +198,6 @@ });

MapType.prototype.removeChild = function (node, subpath) {
node.target.delete(subpath);
node.storedValue.delete(subpath);
};
Object.defineProperty(MapType.prototype, "identifierAttribute", {
get: function () {
return null;
},
enumerable: true,
configurable: true
});
return MapType;
}(complex_type_1.ComplexType));
}(type_1.ComplexType));
__decorate([

@@ -216,0 +204,0 @@ mobx_1.action

import { IObjectChange, IObjectWillChange } from "mobx";
import { MSTAdministration, IMSTNode, IJsonPatch } from "../../core";
import { IType, IComplexType, TypeFlags } from "../type";
import { IType, IComplexType, TypeFlags, ComplexType } from "../type";
import { IJsonPatch, Node } from "../../core";
import { IContext, IValidationResult } from "../type-checker";
import { ComplexType } from "./complex-type";
export declare class ObjectType extends ComplexType<any, any> {
isObjectFactory: boolean;
shouldAttachNode: boolean;
readonly flags: TypeFlags;

@@ -19,14 +18,15 @@ /**

private props;
identifierAttribute: string | null;
constructor(name: string, baseModel: Object, baseActions: Object);
createNewInstance(): Object;
finalizeNewInstance(instance: IMSTNode, snapshot: any): void;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: any): Node;
createNewInstance: () => Object;
finalizeNewInstance: (node: Node, snapshot: any) => void;
willChange(change: IObjectWillChange): IObjectWillChange | null;
didChange: (change: IObjectChange) => void;
parseModelProps(): void;
getChildMSTs(node: MSTAdministration): [string, MSTAdministration][];
getChildMST(node: MSTAdministration, key: string): MSTAdministration | null;
serialize(node: MSTAdministration): any;
applyPatchLocally(node: MSTAdministration, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: MSTAdministration, snapshot: any): void;
getChildren(node: Node): Node[];
getChildNode(node: Node, key: string): Node;
getValue(node: Node): any;
getSnapshot(node: Node): any;
applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
applySnapshot(node: Node, snapshot: any): void;
getChildType(key: string): IType<any, any>;

@@ -37,3 +37,3 @@ isValidSnapshot(value: any, context: IContext): IValidationResult;

getDefaultSnapshot(): any;
removeChild(node: MSTAdministration, subpath: string): void;
removeChild(node: Node, subpath: string): void;
}

@@ -57,2 +57,1 @@ export declare type IModelProperties<T> = {

export declare function isObjectFactory(type: any): boolean;
export declare function getIdentifierAttribute(type: IType<any, any>): string | null;

@@ -21,12 +21,9 @@ "use strict";

var utils_1 = require("../../utils");
var type_1 = require("../type");
var core_1 = require("../../core");
var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var complex_type_1 = require("./complex-type");
var primitives_1 = require("../primitives");
var identifier_1 = require("../utility-types/identifier");
var optional_1 = require("../utility-types/optional");
var reference_1 = require("../utility-types/reference");
var identifier_1 = require("../utility-types/identifier");
var identifier_property_1 = require("../property-types/identifier-property");
var reference_property_1 = require("../property-types/reference-property");
var computed_property_1 = require("../property-types/computed-property");

@@ -37,3 +34,3 @@ var value_property_1 = require("../property-types/value-property");

function objectTypeToString() {
return core_1.getMSTAdministration(this).toString();
return core_1.getStateTreeNode(this).toString();
}

@@ -44,3 +41,3 @@ var ObjectType = (function (_super) {

var _this = _super.call(this, name) || this;
_this.isObjectFactory = true;
_this.shouldAttachNode = true;
_this.flags = type_1.TypeFlags.Object;

@@ -51,3 +48,13 @@ /**

_this.props = {};
_this.identifierAttribute = null;
_this.createNewInstance = function () {
var instance = new _this.modelConstructor();
mobx_1.extendShallowObservable(instance, {});
return instance;
};
_this.finalizeNewInstance = function (node, snapshot) {
var instance = node.storedValue;
_this.forAllProps(function (prop) { return prop.initialize(instance, snapshot); });
mobx_1.intercept(instance, function (change) { return _this.willChange(change); } /* wait for typing fix in mobx */);
mobx_1.observe(instance, _this.didChange);
};
_this.didChange = function (change) {

@@ -68,15 +75,7 @@ _this.props[change.name].didChange(change);

}
ObjectType.prototype.createNewInstance = function () {
var instance = new this.modelConstructor();
mobx_1.extendShallowObservable(instance, {});
return instance;
ObjectType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return core_1.createNode(this, parent, subpath, environment, snapshot, this.createNewInstance, this.finalizeNewInstance);
};
ObjectType.prototype.finalizeNewInstance = function (instance, snapshot) {
var _this = this;
mobx_1.intercept(instance, function (change) { return _this.willChange(change); } /* wait for typing fix in mobx */);
mobx_1.observe(instance, this.didChange);
this.forAllProps(function (prop) { return prop.initialize(instance, snapshot); });
};
ObjectType.prototype.willChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
node.assertWritable();

@@ -88,2 +87,3 @@ // TODO: assigning a new snapshot / MST to a property should result in a nice patch in itself

var _a = this, baseModel = _a.baseModel, baseActions = _a.baseActions;
var alreadySeenIdentifierAttribute = null;
for (var key in baseModel)

@@ -101,8 +101,2 @@ if (utils_1.hasOwnProperty(baseModel, key)) {

}
else if (identifier_1.isIdentifierFactory(value)) {
if (this.identifierAttribute)
utils_1.fail("Cannot define property '" + key + "' as object identifier, property '" + this.identifierAttribute + "' is already defined as identifier property");
this.identifierAttribute = key;
this.props[key] = new identifier_property_1.IdentifierProperty(key, value.primitiveType);
}
else if (utils_1.isPrimitive(value)) {

@@ -112,8 +106,11 @@ var baseType = primitives_1.getPrimitiveFactoryFromValue(value);

}
else if (identifier_1.isIdentifierType(value)) {
if (alreadySeenIdentifierAttribute !== null)
utils_1.fail("Cannot define property '" + key + "' as object identifier, property '" + alreadySeenIdentifierAttribute + "' is already defined as identifier property");
alreadySeenIdentifierAttribute = key;
this.props[key] = new identifier_property_1.IdentifierProperty(key, value);
}
else if (type_1.isType(value)) {
this.props[key] = new value_property_1.ValueProperty(key, value);
}
else if (reference_1.isReferenceFactory(value)) {
this.props[key] = new reference_property_1.ReferenceProperty(key, value.targetType, value.basePath);
}
else if (typeof value === "function") {

@@ -151,16 +148,21 @@ this.props[key] = new view_property_1.ViewProperty(key, value);

};
ObjectType.prototype.getChildMSTs = function (node) {
ObjectType.prototype.getChildren = function (node) {
var res = [];
this.forAllProps(function (prop) {
if (prop instanceof value_property_1.ValueProperty)
core_1.maybeMST(node.target[prop.name], function (propertyNode) { return res.push([prop.name, propertyNode]); });
res.push(prop.getValueNode(node.storedValue));
});
return res;
};
ObjectType.prototype.getChildMST = function (node, key) {
return core_1.maybeMST(node.target[key], utils_1.identity, utils_1.nothing);
ObjectType.prototype.getChildNode = function (node, key) {
if (!(this.props[key] instanceof value_property_1.ValueProperty))
return utils_1.fail("Not a value property: " + key);
return this.props[key].getValueNode(node.storedValue);
};
ObjectType.prototype.serialize = function (node) {
ObjectType.prototype.getValue = function (node) {
return node.storedValue;
};
ObjectType.prototype.getSnapshot = function (node) {
var res = {};
this.forAllProps(function (prop) { return prop.serialize(node.target, res); });
this.forAllProps(function (prop) { return prop.serialize(node.storedValue, res); });
return res;

@@ -171,3 +173,3 @@ };

utils_1.fail("object does not support operation " + patch.op);
node.target[subpath] = patch.value;
node.storedValue[subpath] = patch.value;
};

@@ -179,3 +181,3 @@ ObjectType.prototype.applySnapshot = function (node, snapshot) {

for (var key in _this.props)
_this.props[key].deserialize(node.target, snapshot);
_this.props[key].deserialize(node.storedValue, snapshot);
});

@@ -215,6 +217,6 @@ };

ObjectType.prototype.removeChild = function (node, subpath) {
node.target[subpath] = null;
node.storedValue[subpath] = null;
};
return ObjectType;
}(complex_type_1.ComplexType));
}(type_1.ComplexType));
__decorate([

@@ -256,8 +258,2 @@ mobx_1.action

exports.isObjectFactory = isObjectFactory;
function getIdentifierAttribute(type) {
if (isObjectFactory(type))
return type.identifierAttribute;
return null;
}
exports.getIdentifierAttribute = getIdentifierAttribute;
//# sourceMappingURL=object.js.map

@@ -27,8 +27,3 @@ import { IObservableArray } from "mobx";

};
reference: {
<T>(factory: IType<any, T>): IType<{
$ref: string;
}, T | null>;
<T>(factory: IType<any, T>, basePath: string): IType<string, T | null>;
};
reference: <T>(factory: IType<any, T>) => IType<string | number, T>;
union: {

@@ -79,3 +74,3 @@ <SA, SB, TA, TB>(dispatch: (snapshot: any) => IType<any, any>, A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>;

<T>(baseType: IType<T, T>): T;
(): string;
<T>(): T;
};

@@ -82,0 +77,0 @@ late: {

@@ -0,0 +0,0 @@ "use strict";

import { ISimpleType, TypeFlags, Type } from "./type";
import { IContext, IValidationResult } from "./type-checker";
import { Node } from "../core";
export declare class CoreType<T> extends Type<T, T> {

@@ -8,5 +9,4 @@ readonly checker: (value: any) => boolean;

describe(): string;
create(value: any): any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: T): Node;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}

@@ -13,0 +13,0 @@ export declare const string: ISimpleType<string>;

@@ -16,2 +16,3 @@ "use strict";

var utils_1 = require("../utils");
var core_1 = require("../core");
var CoreType = (function (_super) {

@@ -28,10 +29,6 @@ __extends(CoreType, _super);

};
CoreType.prototype.create = function (value) {
if (!utils_1.isPrimitive(value))
utils_1.fail("Not a primitive: '" + value + "'");
if (!this.checker(value))
utils_1.fail("Value is not assignable to '" + this.name + "'");
return value;
CoreType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return core_1.createNode(this, parent, subpath, environment, snapshot);
};
CoreType.prototype.validate = function (value, context) {
CoreType.prototype.isValidSnapshot = function (value, context) {
if (utils_1.isPrimitive(value) && this.checker(value)) {

@@ -42,9 +39,2 @@ return type_checker_1.typeCheckSuccess();

};
Object.defineProperty(CoreType.prototype, "identifierAttribute", {
get: function () {
return null;
},
enumerable: true,
configurable: true
});
return CoreType;

@@ -61,2 +51,6 @@ }(type_1.Type));

exports.DatePrimitive = new CoreType("Date", type_1.TypeFlags.Date, function (v) { return v instanceof Date; });
exports.DatePrimitive.getSnapshot = function (node) {
return node.storedValue.getTime();
};
// TODO: move null and undefined primitive to here (from maybe)
function getPrimitiveFactoryFromValue(value) {

@@ -63,0 +57,0 @@ switch (typeof value) {

@@ -0,0 +0,0 @@ import { Property } from "./property";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Property } from "./property";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,14 +0,8 @@

import { IObjectWillChange } from "mobx";
import { Property } from "./property";
import { ValueProperty } from "./value-property";
import { IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export declare class IdentifierProperty extends Property {
export declare class IdentifierProperty extends ValueProperty {
subtype: IType<any, any>;
constructor(propertyName: string, subtype: IType<any, any>);
initialize(target: any, snapshot: any): void;
willChange(change: IObjectWillChange): IObjectWillChange | null;
serialize(instance: any, snapshot: any): void;
deserialize(instance: any, snapshot: any): void;
validate(snapshot: any, context: IContext): IValidationResult;
initialize(targetInstance: any, snapshot: any): void;
isValidIdentifier(identifier: any): boolean;
}

@@ -14,5 +14,3 @@ "use strict";

var core_1 = require("../../core");
var mobx_1 = require("mobx");
var property_1 = require("./property");
var utils_1 = require("../../utils");
var value_property_1 = require("./value-property");
var type_checker_1 = require("../type-checker");

@@ -22,51 +20,19 @@ var IdentifierProperty = (function (_super) {

function IdentifierProperty(propertyName, subtype) {
var _this = _super.call(this, propertyName) || this;
var _this = _super.call(this, propertyName, subtype) || this;
_this.subtype = subtype;
return _this;
}
IdentifierProperty.prototype.initialize = function (target, snapshot) {
mobx_1.extendObservable(target, (_a = {},
_a[this.name] = mobx_1.observable.ref(snapshot[this.name]),
_a));
var _a;
};
IdentifierProperty.prototype.willChange = function (change) {
var identifier = change.newValue;
if (typeof identifier !== "number" && !utils_1.isValidIdentifier(identifier))
utils_1.fail("Not a valid identifier: '" + identifier);
IdentifierProperty.prototype.initialize = function (targetInstance, snapshot) {
_super.prototype.initialize.call(this, targetInstance, snapshot);
var node = core_1.getStateTreeNode(targetInstance);
var identifier = snapshot[this.name];
type_checker_1.typecheck(this.subtype, identifier);
var node = core_1.getMSTAdministration(change.object);
node.assertWritable();
var oldValue = change.object[this.name];
if (oldValue !== undefined && oldValue !== identifier)
utils_1.fail("It is not allowed to change the identifier of an object, got: '" + identifier + "' but expected: '" + oldValue + "'");
return change;
node.identifierAttribute = this.name;
};
IdentifierProperty.prototype.serialize = function (instance, snapshot) {
var identifier = instance[this.name];
if (!this.isValidIdentifier(identifier))
utils_1.fail("Object does not have a valid identifier yet: '" + identifier + "'");
snapshot[this.name] = identifier;
};
IdentifierProperty.prototype.deserialize = function (instance, snapshot) {
instance[this.name] = snapshot[this.name];
};
IdentifierProperty.prototype.validate = function (snapshot, context) {
if (!this.isValidIdentifier(snapshot[this.name])) {
return type_checker_1.typeCheckFailure(type_checker_1.getContextForPath(context, this.name, this.subtype), snapshot[this.name], "The provided identifier is not valid");
}
return type_checker_1.typeCheckSuccess();
};
IdentifierProperty.prototype.isValidIdentifier = function (identifier) {
// TODO: MWE, I don't think this isValidIdentifier things makes sense.
// Who are we to decide? Maybe just rule out empty string
// Making types.identifier(types.refinement(types.string, (v) => coolCheck(v))) work would be great!
// On the other hand, this avoids problems with json paths, so maybe we should support all identifiers that don't require further escaping?
if (typeof identifier !== "number" && !utils_1.isValidIdentifier(identifier))
return false;
return this.subtype.is(identifier);
};
return IdentifierProperty;
}(property_1.Property));
}(value_property_1.ValueProperty));
exports.IdentifierProperty = IdentifierProperty;
//# sourceMappingURL=identifier-property.js.map

@@ -1,2 +0,2 @@

import { IMSTNode } from "../../core/";
import { IComplexValue } from "../../core/";
import { IContext, IValidationResult } from "../type-checker";

@@ -8,8 +8,8 @@ import { IObjectChange, IObjectWillChange } from "mobx";

initializePrototype(prototype: any): void;
initialize(targetInstance: IMSTNode, snapshot: any): void;
initialize(targetInstance: IComplexValue, snapshot: any): void;
willChange(change: IObjectWillChange): IObjectWillChange | null;
didChange(change: IObjectChange): void;
serialize(instance: IMSTNode, snapshot: any): void;
deserialize(instance: IMSTNode, snapshot: any): void;
serialize(instance: IComplexValue, snapshot: any): void;
deserialize(instance: IComplexValue, snapshot: any): void;
abstract validate(snapshot: any, context: IContext): IValidationResult;
}

@@ -0,0 +0,0 @@ "use strict";

import { IObjectWillChange, IObjectChange } from "mobx";
import { Property } from "./property";
import { Node } from "../../core";
import { IType } from "../type";

@@ -9,3 +10,4 @@ import { IContext, IValidationResult } from "../type-checker";

initializePrototype(proto: any): void;
initialize(targetInstance: any, snapshot: any): void;
initialize(instance: any, snapshot: any): void;
getValueNode(targetInstance: any): Node;
willChange(change: IObjectWillChange): IObjectWillChange | null;

@@ -12,0 +14,0 @@ didChange(change: IObjectChange): void;

@@ -17,2 +17,5 @@ "use strict";

var type_checker_1 = require("../type-checker");
var utils_1 = require("../../utils");
var literal_1 = require("../utility-types/literal");
var undefinedType = literal_1.literal(undefined);
var ValueProperty = (function (_super) {

@@ -26,26 +29,37 @@ __extends(ValueProperty, _super);

ValueProperty.prototype.initializePrototype = function (proto) {
mobx_1.observable.ref(proto, this.name, { value: undefined });
mobx_1.observable.ref(proto, this.name, { value: undefinedType.instantiate(null, "", null, undefined) }); // TODO: undefined type should not be needed
};
ValueProperty.prototype.initialize = function (targetInstance, snapshot) {
targetInstance[this.name] = this.type.create(snapshot[this.name]);
ValueProperty.prototype.initialize = function (instance, snapshot) {
var node = core_1.getStateTreeNode(instance);
instance[this.name] = this.type.instantiate(node, this.name, node._environment, snapshot[this.name]);
mobx_1.extras.interceptReads(instance, this.name, node.unbox);
};
ValueProperty.prototype.getValueNode = function (targetInstance) {
var node = targetInstance.$mobx.values[this.name].value; // TODO: blegh!
if (!node)
return utils_1.fail("Node not available for property " + this.name);
return node;
};
ValueProperty.prototype.willChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
change.newValue = node.reconcileChildren(this.type, [change.object[change.name]], [change.newValue], [change.name])[0];
var node = core_1.getStateTreeNode(change.object); // TODO: pass node in from object property
type_checker_1.typecheck(this.type, change.newValue);
change.newValue = this.type.reconcile(node.getChildNode(change.name), change.newValue);
return change;
};
ValueProperty.prototype.didChange = function (change) {
var node = core_1.getMSTAdministration(change.object);
var node = core_1.getStateTreeNode(change.object);
node.emitPatch({
op: "replace",
path: core_1.escapeJsonPath(this.name),
value: core_1.valueToSnapshot(change.newValue)
value: this.getValueNode(change.object).snapshot
}, node);
};
ValueProperty.prototype.serialize = function (instance, snapshot) {
snapshot[this.name] = core_1.valueToSnapshot(instance[this.name]);
// TODO: FIXME, make sure the observable ref is used!
mobx_1.extras.getAtom(instance, this.name).reportObserved();
snapshot[this.name] = this.getValueNode(instance).snapshot;
};
ValueProperty.prototype.deserialize = function (instance, snapshot) {
var _this = this;
core_1.maybeMST(instance[this.name], function (propertyNode) { propertyNode.applySnapshot(snapshot[_this.name]); }, function () { instance[_this.name] = snapshot[_this.name]; });
// TODO: was a maybeMST here first...
instance[this.name] = snapshot[this.name];
};

@@ -52,0 +66,0 @@ ValueProperty.prototype.validate = function (snapshot, context) {

@@ -0,0 +0,0 @@ import { Property } from "./property";

@@ -41,3 +41,3 @@ "use strict";

var args = arguments;
var adm = core_1.getMSTAdministration(this);
var adm = core_1.getStateTreeNode(this);
adm.assertAlive();

@@ -44,0 +44,0 @@ return mobx_1.extras.allowStateChanges(false, function () { return fn.apply(_this, args); });

@@ -1,2 +0,1 @@

import { IType } from "./type";
export interface IContextEntry {

@@ -13,2 +12,3 @@ path: string;

export declare type IValidationResult = IValidationError[];
export declare function prettyPrintValue(value: any): string;
export declare function getDefaultContext(type: IType<any, any>): IContext;

@@ -20,1 +20,2 @@ export declare function getContextForPath(context: IContext, path: string, type?: IType<any, any>): IContext;

export declare function typecheck(type: IType<any, any>, value: any): void;
import { IType } from "./type";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var mst_node_1 = require("../core/mst-node");
var primitives_1 = require("./primitives");
var optional_1 = require("./utility-types/optional");
var prettyPrintValue = function (value) {
return mst_node_1.isMST(value) ?
"<" + value + ">" :
"`" + JSON.stringify(value) + "`";
};
function prettyPrintValue(value) {
return typeof value === "function"
? "<function" + (value.name ? " " + value.name : "") + ">"
: core_1.isStateTreeNode(value)
? "<" + value + ">"
: "`" + JSON.stringify(value) + "`";
}
exports.prettyPrintValue = prettyPrintValue;
function toErrorString(error) {

@@ -20,4 +19,6 @@ var value = error.value;

var pathPrefix = fullPath.length > 0 ? "at path \"/" + fullPath + "\" " : "";
var currentTypename = mst_node_1.maybeMST(value, function (node) { return "value of type " + node.type.name + ":"; }, function () { return utils_1.isPrimitive(value) ? "value" : "snapshot"; });
var isSnapshotCompatible = type && mst_node_1.isMST(value) && type.is(mst_node_1.getMSTAdministration(value).snapshot);
var currentTypename = core_1.isStateTreeNode(value)
? "value of type " + core_1.getStateTreeNode(value).type.name + ":"
: utils_1.isPrimitive(value) ? "value" : "snapshot";
var isSnapshotCompatible = type && core_1.isStateTreeNode(value) && type.is(core_1.getStateTreeNode(value).snapshot);
return "" + pathPrefix + currentTypename + " " + prettyPrintValue(value) + " is not assignable " + (type ? "to type: `" + type.name + "`" : "") +

@@ -51,2 +52,3 @@ (error.message ? " (" + error.message + ")" : "") +

exports.flattenTypeErrors = flattenTypeErrors;
// TODO; typecheck should be invoked from: type.create and array / map / value.property will change
function typecheck(type, value) {

@@ -60,2 +62,6 @@ var errors = type.validate(value, [{ path: "", type: type }]);

exports.typecheck = typecheck;
var utils_1 = require("../utils");
var core_1 = require("../core");
var primitives_1 = require("./primitives");
var optional_1 = require("./utility-types/optional");
//# sourceMappingURL=type-checker.js.map

@@ -14,2 +14,4 @@ export interface ISnapshottable<S> {

Optional = 512,
Reference = 1024,
Identifier = 2048,
}

@@ -26,23 +28,62 @@ export interface IType<S, T> {

SnapshotType: S;
identifierAttribute: string | null;
instantiate(parent: Node | null, subpath: string, environment: any, initialValue?: any): Node;
reconcile(current: Node, newValue: any): Node;
getValue(node: Node): T;
getSnapshot(node: Node): S;
applySnapshot(node: Node, snapshot: S): void;
applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
getChildren(node: Node): Node[];
getChildNode(node: Node, key: string): Node;
getChildType(key: string): IType<any, any>;
removeChild(node: Node, subpath: string): void;
isAssignableFrom(type: IType<any, any>): boolean;
}
export interface ISimpleType<T> extends IType<T, T> {
}
export interface IComplexType<S, T> extends IType<S, T & ISnapshottable<S> & IMSTNode> {
export interface IComplexType<S, T> extends IType<S, T & ISnapshottable<S> & IComplexValue> {
}
export declare function isType(value: any): value is IType<any, any>;
export declare abstract class Type<S, T> implements IType<S, T> {
name: string;
isType: boolean;
/**
* A complex type produces a MST node (Node in the state tree)
*/
export declare abstract class ComplexType<S, T> implements IType<S, T> {
readonly isType: boolean;
readonly name: string;
constructor(name: string);
create(snapshot?: S, environment?: any): T;
abstract instantiate(parent: Node | null, subpath: string, environment: any, initialValue: any): Node;
abstract flags: TypeFlags;
abstract create(snapshot: any): any;
abstract validate(thing: any, context: IContext): IValidationResult;
abstract describe(): string;
abstract applySnapshot(node: Node, snapshot: any): void;
abstract getDefaultSnapshot(): any;
abstract getChildren(node: Node): Node[];
abstract getChildNode(node: Node, key: string): Node;
abstract getValue(node: Node): T;
abstract getSnapshot(node: Node): any;
abstract applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
abstract getChildType(key: string): IType<any, any>;
abstract removeChild(node: Node, subpath: string): void;
abstract isValidSnapshot(value: any, context: IContext): IValidationResult;
isAssignableFrom(type: IType<any, any>): boolean;
validate(value: any, context: IContext): IValidationResult;
is(value: any): value is S | T;
reconcile(current: Node, newValue: any): Node;
readonly Type: T;
readonly SnapshotType: S;
readonly abstract identifierAttribute: string | null;
}
import { IMSTNode } from "../core/mst-node";
export declare abstract class Type<S, T> extends ComplexType<S, T> implements IType<S, T> {
constructor(name: string);
abstract instantiate(parent: Node | null, subpath: string, environment: any, initialValue: any): Node;
getValue(node: Node): any;
getSnapshot(node: Node): any;
getDefaultSnapshot(): undefined;
applySnapshot(node: Node, snapshot: S): void;
applyPatchLocally(node: Node, subpath: string, patch: IJsonPatch): void;
getChildren(node: Node): Node[];
getChildNode(node: Node, key: string): Node;
getChildType(key: string): IType<any, any>;
reconcile(current: Node, newValue: any): Node;
removeChild(node: Node, subpath: string): void;
}
import { IContext, IValidationResult } from "./type-checker";
import { Node, IComplexValue, IJsonPatch } from "../core";
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var TypeFlags;

@@ -15,2 +32,4 @@ (function (TypeFlags) {

TypeFlags[TypeFlags["Optional"] = 512] = "Optional";
TypeFlags[TypeFlags["Reference"] = 1024] = "Reference";
TypeFlags[TypeFlags["Identifier"] = 2048] = "Identifier";
})(TypeFlags = exports.TypeFlags || (exports.TypeFlags = {}));

@@ -21,11 +40,56 @@ function isType(value) {

exports.isType = isType;
var Type = (function () {
function Type(name) {
/**
* A complex type produces a MST node (Node in the state tree)
*/
var ComplexType = (function () {
function ComplexType(name) {
this.isType = true;
this.name = name;
}
Type.prototype.is = function (value) {
ComplexType.prototype.create = function (snapshot, environment) {
if (snapshot === void 0) { snapshot = this.getDefaultSnapshot(); }
type_checker_1.typecheck(this, snapshot);
return this.instantiate(null, "", environment, snapshot).getValue();
};
ComplexType.prototype.isAssignableFrom = function (type) {
return type === this;
};
ComplexType.prototype.validate = function (value, context) {
if (node_1.isStateTreeNode(value)) {
return mst_operations_1.getType(value) === this || this.isAssignableFrom(mst_operations_1.getType(value)) ? type_checker_1.typeCheckSuccess() : type_checker_1.typeCheckFailure(context, value);
// it is tempting to compare snapshots, but in that case we should always clone on assignments...
}
return this.isValidSnapshot(value, context);
};
ComplexType.prototype.is = function (value) {
return this.validate(value, [{ path: "", type: this }]).length === 0;
};
Object.defineProperty(Type.prototype, "Type", {
ComplexType.prototype.reconcile = function (current, newValue) {
// TODO: this.is... for all prepareNewVaues?
if (node_1.isStateTreeNode(newValue) && node_1.getStateTreeNode(newValue) === current)
// the current node is the same as the new one
return current;
if (current.type === this &&
utils_1.isMutable(newValue) &&
!node_1.isStateTreeNode(newValue) &&
(!current.identifierAttribute ||
current.identifier === newValue[current.identifierAttribute])) {
// the newValue has no node, so can be treated like a snapshot
// we can reconcile
current.applySnapshot(newValue);
return current;
}
// current node cannot be recycled in any way
current.die();
// attempt to reuse the new one
if (node_1.isStateTreeNode(newValue) && this.isAssignableFrom(mst_operations_1.getType(newValue))) {
// newValue is a Node as well, move it here..
var newNode = node_1.getStateTreeNode(newValue);
newNode.setParent(current.parent, current.path);
return newNode;
}
// nothing to do, we have to create a new node
return this.instantiate(current.parent, current.path, current._environment, newValue);
};
Object.defineProperty(ComplexType.prototype, "Type", {
get: function () {

@@ -37,3 +101,3 @@ return utils_1.fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");

});
Object.defineProperty(Type.prototype, "SnapshotType", {
Object.defineProperty(ComplexType.prototype, "SnapshotType", {
get: function () {

@@ -45,6 +109,55 @@ return utils_1.fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");

});
return ComplexType;
}());
__decorate([
mobx_1.action
], ComplexType.prototype, "create", null);
exports.ComplexType = ComplexType;
var Type = (function (_super) {
__extends(Type, _super);
function Type(name) {
return _super.call(this, name) || this;
}
Type.prototype.getValue = function (node) {
return node.storedValue;
};
Type.prototype.getSnapshot = function (node) {
return node.storedValue;
};
Type.prototype.getDefaultSnapshot = function () {
return undefined;
};
Type.prototype.applySnapshot = function (node, snapshot) {
utils_1.fail("Immutable types do not support applying snapshots");
};
Type.prototype.applyPatchLocally = function (node, subpath, patch) {
utils_1.fail("Immutable types do not support applying patches");
};
Type.prototype.getChildren = function (node) {
return utils_1.EMPTY_ARRAY;
};
Type.prototype.getChildNode = function (node, key) {
return utils_1.fail("No child '" + key + "' available in type: " + this.name);
};
Type.prototype.getChildType = function (key) {
return utils_1.fail("No child '" + key + "' available in type: " + this.name);
};
Type.prototype.reconcile = function (current, newValue) {
// reconcile only if type and value are still the same
if (current.type === this && current.storedValue === newValue)
return current;
var res = this.instantiate(current.parent, current.subpath, current._environment, newValue);
current.die();
return res;
};
Type.prototype.removeChild = function (node, subpath) {
return utils_1.fail("No child '" + subpath + "' available in type: " + this.name);
};
return Type;
}());
}(ComplexType));
exports.Type = Type;
var utils_1 = require("../utils");
var node_1 = require("../core/node");
var type_checker_1 = require("./type-checker");
var mst_operations_1 = require("../core/mst-operations");
//# sourceMappingURL=type.js.map
import { ISimpleType, TypeFlags, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { Node } from '../../core';
export declare class Frozen<T> extends Type<T, T> {

@@ -7,6 +8,5 @@ flags: TypeFlags;

describe(): string;
create(value: any): any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;
instantiate(parent: Node | null, subpath: string, environment: any, value: any): Node;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare const frozen: ISimpleType<any>;

@@ -16,2 +16,3 @@ "use strict";

var utils_1 = require("../../utils");
var core_1 = require("../../core");
function freeze(value) {

@@ -38,9 +39,7 @@ Object.freeze(value);

};
Frozen.prototype.create = function (value) {
if (!utils_1.isSerializable(value))
utils_1.fail("Given value should be serializable");
Frozen.prototype.instantiate = function (parent, subpath, environment, value) {
// deep freeze the object/array
return utils_1.isMutable(value) ? freeze(value) : value;
return core_1.createNode(this, parent, subpath, environment, utils_1.isMutable(value) ? freeze(value) : value);
};
Frozen.prototype.validate = function (value, context) {
Frozen.prototype.isValidSnapshot = function (value, context) {
if (!utils_1.isSerializable(value)) {

@@ -51,9 +50,2 @@ return type_checker_1.typeCheckFailure(context, value);

};
Object.defineProperty(Frozen.prototype, "identifierAttribute", {
get: function () {
return null;
},
enumerable: true,
configurable: true
});
return Frozen;

@@ -60,0 +52,0 @@ }(type_1.Type));

@@ -1,8 +0,15 @@

import { IType } from "../type";
export interface IIdentifierDescriptor<T> {
isIdentifier: true;
primitiveType: IType<T, T>;
import { TypeFlags, Type, IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { Node } from "../../core";
export declare class IdentifierType<T> extends Type<T, T> {
readonly identifierType: IType<T, T>;
readonly flags: TypeFlags;
constructor(identifierType: IType<T, T>);
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: T): Node;
reconcile(current: Node, newValue: any): Node;
describe(): string;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function identifier<T>(baseType: IType<T, T>): T;
export declare function identifier(): string;
export declare function isIdentifierFactory(thing: any): thing is IIdentifierDescriptor<any>;
export declare function identifier<T>(): T;
export declare function isIdentifierType(type: any): type is IdentifierType<any>;
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var utils_1 = require("../../utils");
var core_1 = require("../../core");
var primitives_1 = require("../primitives");
var utils_1 = require("../../utils");
var late_1 = require("./late");
var Identifier = (function () {
function Identifier(identifier) {
this.identifier = identifier;
}
Identifier.prototype.toString = function () {
return "identifier(" + this.identifier + ")";
};
return Identifier;
}());
var IdentifierType = (function (_super) {
__extends(IdentifierType, _super);
function IdentifierType(identifierType) {
var _this = _super.call(this, "identifier(" + identifierType.name + ")") || this;
_this.identifierType = identifierType;
_this.flags = type_1.TypeFlags.Identifier;
return _this;
}
IdentifierType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
type_checker_1.typecheck(this.identifierType, snapshot);
if (parent && !core_1.isStateTreeNode(parent.storedValue))
utils_1.fail("Identifier types can only be instantiated as direct child of a model type");
return core_1.createNode(this, parent, subpath, environment, snapshot);
};
IdentifierType.prototype.reconcile = function (current, newValue) {
if (current.storedValue !== newValue)
return utils_1.fail("Tried to change identifier from '" + current.storedValue + "' to '" + newValue + "'. Changing identifiers is not allowed.");
return current;
};
IdentifierType.prototype.describe = function () {
return "identifier(" + this.identifierType.describe() + ")";
};
IdentifierType.prototype.isValidSnapshot = function (value, context) {
if (this.identifierType.is(value)) {
return type_checker_1.typeCheckSuccess();
}
return type_checker_1.typeCheckFailure(context, value);
};
return IdentifierType;
}(type_1.Type));
exports.IdentifierType = IdentifierType;
function identifier(baseType) {

@@ -10,12 +64,10 @@ if (baseType === void 0) { baseType = primitives_1.string; }

utils_1.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers");
return {
isIdentifier: true,
primitiveType: baseType
};
return new IdentifierType(baseType);
}
exports.identifier = identifier;
function isIdentifierFactory(thing) {
return typeof thing === "object" && thing && thing.isIdentifier === true;
function isIdentifierType(type) {
return (!(type instanceof late_1.Late)) &&
(type.flags & (type_1.TypeFlags.Identifier)) > 0;
}
exports.isIdentifierFactory = isIdentifierFactory;
exports.isIdentifierType = isIdentifierType;
//# sourceMappingURL=identifier.js.map
import { Type, IType, TypeFlags } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { Node } from "../../core";
export declare class Late<S, T> extends Type<S, T> {

@@ -9,6 +10,7 @@ readonly definition: () => IType<S, T>;

constructor(name: string, definition: () => IType<S, T>);
create(snapshot?: any, environment?: any): T;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: any): Node;
reconcile(current: Node, newValue: any): Node;
describe(): string;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;
isValidSnapshot(value: any, context: IContext): IValidationResult;
isAssignableFrom(type: IType<any, any>): boolean;
}

@@ -15,0 +17,0 @@ export declare type ILateType<S, T> = () => IType<S, T>;

@@ -42,18 +42,17 @@ "use strict";

});
Late.prototype.create = function (snapshot, environment) {
return this.subType.create(snapshot, environment);
Late.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return this.subType.instantiate(parent, subpath, environment, snapshot);
};
Late.prototype.reconcile = function (current, newValue) {
return this.subType.reconcile(current, newValue);
};
Late.prototype.describe = function () {
return this.subType.name;
};
Late.prototype.validate = function (value, context) {
Late.prototype.isValidSnapshot = function (value, context) {
return this.subType.validate(value, context);
};
Object.defineProperty(Late.prototype, "identifierAttribute", {
get: function () {
return this.subType.identifierAttribute;
},
enumerable: true,
configurable: true
});
Late.prototype.isAssignableFrom = function (type) {
return this.subType.isAssignableFrom(type);
};
return Late;

@@ -60,0 +59,0 @@ }(type_1.Type));

import { ISimpleType, TypeFlags, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { Node } from "../../core";
export declare class Literal<T> extends Type<T, T> {

@@ -7,7 +8,6 @@ readonly value: any;

constructor(value: any);
create(snapshot: any): any;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: T): Node;
describe(): string;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: null;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function literal<S>(value: S): ISimpleType<S>;

@@ -16,2 +16,3 @@ "use strict";

var type_checker_1 = require("../type-checker");
var core_1 = require("../../core");
var Literal = (function (_super) {

@@ -25,5 +26,4 @@ __extends(Literal, _super);

}
Literal.prototype.create = function (snapshot) {
type_checker_1.typecheck(this, snapshot);
return this.value;
Literal.prototype.instantiate = function (parent, subpath, environment, snapshot) {
return core_1.createNode(this, parent, subpath, environment, snapshot);
};

@@ -33,3 +33,3 @@ Literal.prototype.describe = function () {

};
Literal.prototype.validate = function (value, context) {
Literal.prototype.isValidSnapshot = function (value, context) {
if (utils_1.isPrimitive(value) && value === this.value) {

@@ -40,9 +40,2 @@ return type_checker_1.typeCheckSuccess();

};
Object.defineProperty(Literal.prototype, "identifierAttribute", {
get: function () {
return null;
},
enumerable: true,
configurable: true
});
return Literal;

@@ -49,0 +42,0 @@ }(type_1.Type));

import { IType } from "../type";
export declare function maybe<S, T>(type: IType<S, T>): IType<S | null | undefined, T | null>;

@@ -0,0 +0,0 @@ "use strict";

import { Type, IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { Node } from "../../core";
export declare type IFunctionReturn<T> = () => T;

@@ -11,5 +12,6 @@ export declare type IOptionalValue<S, T> = S | T | IFunctionReturn<S> | IFunctionReturn<T>;

describe(): string;
create(value: any): T;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;
instantiate(parent: Node, subpath: string, environment: any, value: S): Node;
reconcile(current: Node, newValue: any): Node;
private getDefaultValue();
isValidSnapshot(value: any, context: IContext): IValidationResult;
}

@@ -16,0 +18,0 @@ export declare function optional<S, T>(type: IType<S, T>, defaultValueOrFunction: S): IType<S, T>;

@@ -15,2 +15,3 @@ "use strict";

var type_checker_1 = require("../type-checker");
var core_1 = require("../../core");
var OptionalValue = (function (_super) {

@@ -32,15 +33,22 @@ __extends(OptionalValue, _super);

OptionalValue.prototype.describe = function () {
// return "(" + this.type.type.describe() + " = " + JSON.stringify(this.defaultValue) + ")"
// MWE: discuss a default value is not part of the type description? (unlike a literal)
return this.type.describe() + "?";
};
OptionalValue.prototype.create = function (value) {
OptionalValue.prototype.instantiate = function (parent, subpath, environment, value) {
if (typeof value === "undefined") {
var defaultValue = typeof this.defaultValue === "function" ? this.defaultValue() : this.defaultValue;
var defaultSnapshot = mst_node_1.isMST(defaultValue) ? mst_node_1.getMSTAdministration(defaultValue).snapshot : defaultValue;
return this.type.create(defaultSnapshot);
var defaultValue = this.getDefaultValue();
var defaultSnapshot = core_1.isStateTreeNode(defaultValue) ? core_1.getStateTreeNode(defaultValue).snapshot : defaultValue;
return this.type.instantiate(parent, subpath, environment, defaultSnapshot);
}
return this.type.create(value);
return this.type.instantiate(parent, subpath, environment, value);
};
OptionalValue.prototype.validate = function (value, context) {
OptionalValue.prototype.reconcile = function (current, newValue) {
return this.type.reconcile(current, this.type.is(newValue) ? newValue : this.getDefaultValue());
};
OptionalValue.prototype.getDefaultValue = function () {
var defaultValue = typeof this.defaultValue === "function" ? this.defaultValue() : this.defaultValue;
if (typeof this.defaultValue === "function")
type_checker_1.typecheck(this, defaultValue);
return defaultValue;
};
OptionalValue.prototype.isValidSnapshot = function (value, context) {
// defaulted values can be skipped

@@ -52,9 +60,2 @@ if (value === undefined || this.type.is(value)) {

};
Object.defineProperty(OptionalValue.prototype, "identifierAttribute", {
get: function () {
return this.type.identifierAttribute;
},
enumerable: true,
configurable: true
});
return OptionalValue;

@@ -65,3 +66,3 @@ }(type_1.Type));

var defaultValue = typeof defaultValueOrFunction === "function" ? defaultValueOrFunction() : defaultValueOrFunction;
var defaultSnapshot = mst_node_1.isMST(defaultValue) ? mst_node_1.getMSTAdministration(defaultValue).snapshot : defaultValue;
var defaultSnapshot = core_1.isStateTreeNode(defaultValue) ? core_1.getStateTreeNode(defaultValue).snapshot : defaultValue;
type_checker_1.typecheck(type, defaultSnapshot);

@@ -71,3 +72,2 @@ return new OptionalValue(type, defaultValueOrFunction);

exports.optional = optional;
var mst_node_1 = require("../../core/mst-node");
//# sourceMappingURL=optional.js.map

@@ -1,11 +0,21 @@

import { IType } from "../type";
export interface IReferenceDescription {
targetType: IType<any, any>;
basePath: string;
isReference: true;
import { Node } from "../../core";
import { TypeFlags, Type, IType } from "../type";
import { IContext, IValidationResult } from "../type-checker";
export interface IReference {
$ref: string;
}
export declare function reference<T>(factory: IType<any, T>): IType<{
$ref: string;
}, T | null>;
export declare function reference<T>(factory: IType<any, T>, basePath: string): IType<string, T | null>;
export declare function isReferenceFactory(thing: any): thing is IReferenceDescription;
export declare type ReferenceSnapshot = string | null | IReference;
export declare class ReferenceType<T> extends Type<ReferenceSnapshot, T> {
private readonly targetType;
readonly flags: TypeFlags;
constructor(targetType: IType<any, T>);
describe(): string;
getValue(node: Node): any;
getSnapshot(node: Node): any;
instantiate(parent: Node | null, subpath: string, environment: any, snapshot: any): Node;
reconcile(current: Node, newValue: any): Node;
isAssignableFrom(type: IType<any, any>): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function reference<T>(factory: IType<any, T>): IType<string | number, T>;
export declare function isReferenceType(type: any): type is ReferenceType<any>;
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
function reference(factory, basePath) {
if (basePath === void 0) { basePath = ""; }
// FIXME: IType return type is inconsistent with what is actually returned, however, results in the best type-inference results for objects...
return {
targetType: factory,
basePath: basePath,
isReference: true
var core_1 = require("../../core");
var type_1 = require("../type");
var type_checker_1 = require("../type-checker");
var utils_1 = require("../../utils");
var StoredReference = (function () {
function StoredReference(mode, value) {
this.mode = mode;
this.value = value;
if (mode === "object") {
if (!core_1.isStateTreeNode(value))
return utils_1.fail("Can only store references to tree nodes, got: '" + value + "'");
var targetNode = core_1.getStateTreeNode(value);
if (!targetNode.identifierAttribute)
return utils_1.fail("Can only store references with a defined identifier attribute.");
}
}
return StoredReference;
}());
var ReferenceType = (function (_super) {
__extends(ReferenceType, _super);
function ReferenceType(targetType) {
var _this =
// TODO: check if targetType is object type? Or does that break late types? Do it in instantiate
_super.call(this, "reference(" + targetType.name + ")") || this;
_this.targetType = targetType;
_this.flags = type_1.TypeFlags.Reference;
return _this;
}
ReferenceType.prototype.describe = function () {
return this.name;
};
ReferenceType.prototype.getValue = function (node) {
var ref = node.storedValue;
if (ref.mode === "object")
return ref.value;
// reference was initialized with the identifier of the target
var target = node.root.identifierCache.resolve(this.targetType, ref.value);
if (!target)
return utils_1.fail("Failed to resolve reference of type " + this.targetType.name + ": '" + ref.value + "' (in: " + node.path + ")");
return target.getValue();
};
ReferenceType.prototype.getSnapshot = function (node) {
var ref = node.storedValue;
switch (ref.mode) {
case "identifier":
return ref.value;
case "object":
return core_1.getStateTreeNode(ref.value).identifier;
}
};
ReferenceType.prototype.instantiate = function (parent, subpath, environment, snapshot) {
var isComplex = core_1.isStateTreeNode(snapshot);
return core_1.createNode(this, parent, subpath, environment, new StoredReference(isComplex ? "object" : "identifier", snapshot));
};
ReferenceType.prototype.reconcile = function (current, newValue) {
var targetMode = core_1.isStateTreeNode(newValue) ? "object" : "identifier";
if (isReferenceType(current.type)) {
var ref = current.storedValue;
if (targetMode === ref.mode && ref.value === newValue)
return current;
}
var newNode = this.instantiate(current.parent, current.subpath, current._environment, newValue);
current.die();
return newNode;
};
ReferenceType.prototype.isAssignableFrom = function (type) {
return this.targetType.isAssignableFrom(type);
};
ReferenceType.prototype.isValidSnapshot = function (value, context) {
return (typeof value === "string" || typeof value === "number")
? type_checker_1.typeCheckSuccess()
: type_checker_1.typeCheckFailure(context, value, "Value '" + type_checker_1.prettyPrintValue(value) + "' is not a valid reference. Expected a string or number.");
};
return ReferenceType;
}(type_1.Type));
exports.ReferenceType = ReferenceType;
function reference(factory) {
if (arguments.length === 2 && typeof arguments[1] === "string")
utils_1.fail("References with base path are no longer supported. Please remove the base path.");
return new ReferenceType(factory);
}
exports.reference = reference;
function isReferenceFactory(thing) {
return thing.isReference === true;
function isReferenceType(type) {
return (type.flags & (type_1.TypeFlags.Reference)) > 0;
}
exports.isReferenceFactory = isReferenceFactory;
exports.isReferenceType = isReferenceType;
//# sourceMappingURL=reference.js.map

@@ -1,2 +0,3 @@

import { IType, TypeFlags, Type } from "../type";
import { IType, Type, TypeFlags } from "../type";
import { Node } from "../../core";
import { IContext, IValidationResult } from "../type-checker";

@@ -9,7 +10,7 @@ export declare class Refinement extends Type<any, any> {

describe(): string;
create(value: any): any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;
instantiate(parent: Node, subpath: string, environment: any, value: any): Node;
isAssignableFrom(type: IType<any, any>): boolean;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}
export declare function refinement<T>(name: string, type: IType<T, T>, predicate: (snapshot: T) => boolean): IType<T, T>;
export declare function refinement<S, T extends S, U extends S>(name: string, type: IType<S, T>, predicate: (snapshot: S) => snapshot is U): IType<S, U>;

@@ -35,24 +35,19 @@ "use strict";

};
Refinement.prototype.create = function (value) {
Refinement.prototype.instantiate = function (parent, subpath, environment, value) {
// create the child type
var inst = this.type.create(value);
var snapshot = core_1.isMST(inst) ? core_1.getMSTAdministration(inst).snapshot : inst;
// check if pass the predicate
if (!this.is(snapshot))
utils_1.fail("Value " + JSON.stringify(snapshot) + " is not assignable to type " + this.name);
var inst = this.type.instantiate(parent, subpath, environment, value);
return inst;
};
Refinement.prototype.validate = function (value, context) {
if (this.type.is(value) && this.predicate(value)) {
return type_checker_1.typeCheckSuccess();
Refinement.prototype.isAssignableFrom = function (type) {
return this.type.isAssignableFrom(type);
};
Refinement.prototype.isValidSnapshot = function (value, context) {
if (this.type.is(value)) {
var snapshot = core_1.isStateTreeNode(value) ? core_1.getStateTreeNode(value).snapshot : value;
if (this.predicate(snapshot)) {
return type_checker_1.typeCheckSuccess();
}
}
return type_checker_1.typeCheckFailure(context, value);
};
Object.defineProperty(Refinement.prototype, "identifierAttribute", {
get: function () {
return this.type.identifierAttribute;
},
enumerable: true,
configurable: true
});
return Refinement;

@@ -64,3 +59,3 @@ }(type_1.Type));

var inst = type.create();
if (!predicate(core_1.isMST(inst) ? core_1.getMSTAdministration(inst).snapshot : inst))
if (!predicate(core_1.isStateTreeNode(inst) ? core_1.getStateTreeNode(inst).snapshot : inst))
utils_1.fail("Default value for refinement type " + name + " does not pass the predicate.");

@@ -67,0 +62,0 @@ return new Refinement(name, type, predicate);

import { IType, TypeFlags, Type } from "../type";
import { IContext, IValidationResult } from "../type-checker";
import { MSTAdministration } from "../../core/mst-node-administration";
import { Node } from "../../core";
export declare type ITypeDispatcher = (snapshot: any) => IType<any, any>;

@@ -10,6 +10,8 @@ export declare class Union extends Type<any, any> {

constructor(name: string, types: IType<any, any>[], dispatcher: ITypeDispatcher | null);
isAssignableFrom(type: IType<any, any>): boolean;
describe(): string;
create(value: any, environment?: any, parent?: MSTAdministration | null, subpath?: string): any;
validate(value: any, context: IContext): IValidationResult;
readonly identifierAttribute: string | null;
instantiate(parent: Node, subpath: string, environment: any, value: any): Node;
reconcile(current: Node, newValue: any): Node;
determineType(value: any): IType<any, any>;
isValidSnapshot(value: any, context: IContext): IValidationResult;
}

@@ -16,0 +18,0 @@ export declare function union<SA, SB, TA, TB>(dispatch: ITypeDispatcher, A: IType<SA, TA>, B: IType<SB, TB>): IType<SA | SB, TA | TB>;

@@ -36,13 +36,18 @@ "use strict";

});
Union.prototype.isAssignableFrom = function (type) {
return this.types.some(function (subType) { return subType.isAssignableFrom(type); });
};
Union.prototype.describe = function () {
return "(" + this.types.map(function (factory) { return factory.describe(); }).join(" | ") + ")";
};
Union.prototype.create = function (value, environment, parent, subpath) {
if (environment === void 0) { environment = undefined; }
if (parent === void 0) { parent = null; }
if (subpath === void 0) { subpath = ""; }
type_checker_1.typecheck(this, value);
Union.prototype.instantiate = function (parent, subpath, environment, value) {
return this.determineType(value).instantiate(parent, subpath, environment, value);
};
Union.prototype.reconcile = function (current, newValue) {
return this.determineType(newValue).reconcile(current, newValue);
};
Union.prototype.determineType = function (value) {
// try the dispatcher, if defined
if (this.dispatcher !== null) {
return this.dispatcher(value).create(value, environment, parent, subpath);
return this.dispatcher(value);
}

@@ -53,5 +58,5 @@ // find the most accomodating type

return utils_1.fail("Ambiguos snapshot " + JSON.stringify(value) + " for union " + this.name + ". Please provide a dispatch in the union declaration.");
return applicableTypes[0].create(value, environment, parent, subpath);
return applicableTypes[0];
};
Union.prototype.validate = function (value, context) {
Union.prototype.isValidSnapshot = function (value, context) {
if (this.dispatcher !== null) {

@@ -71,12 +76,2 @@ return this.dispatcher(value).validate(value, context);

};
Object.defineProperty(Union.prototype, "identifierAttribute", {
get: function () {
var identifier0 = this.types[0].identifierAttribute;
if (identifier0 && this.types.every(function (type) { return type.identifierAttribute === identifier0; }))
return identifier0;
return null;
},
enumerable: true,
configurable: true
});
return Union;

@@ -83,0 +78,0 @@ }(type_1.Type));

@@ -6,2 +6,3 @@ export declare const EMPTY_ARRAY: ReadonlyArray<never>;

export declare function nothing(): null;
export declare function noop(): void;
export declare function extend<A, B>(a: A, b: B): A & B;

@@ -26,2 +27,1 @@ export declare function extend<A, B, C>(a: A, b: B, c: C): A & B & C;

export declare function createNamedFunction(name: string, fn: Function): any;
export declare function isValidIdentifier(identifier: any): boolean;

@@ -17,2 +17,4 @@ "use strict";

exports.nothing = nothing;
function noop() { }
exports.noop = noop;
function extend(a) {

@@ -125,8 +127,2 @@ var b = [];

exports.createNamedFunction = createNamedFunction;
function isValidIdentifier(identifier) {
if (typeof identifier !== "string")
return false;
return /^[a-z0-9_-]+$/i.test(identifier);
}
exports.isValidIdentifier = isValidIdentifier;
//# sourceMappingURL=utils.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],e):"object"==typeof exports?exports.mobxStateTree=e(require("mobx")):t.mobxStateTree=e(t.mobx)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),n(3),n(10);var i=n(24);e.types=i.types,r(n(7)),r(n(9));var o=n(5);e.isMST=o.isMST,e.getType=o.getType,e.getChildType=o.getChildType,e.onAction=o.onAction,e.applyAction=o.applyAction;var a=n(21);e.asReduxStore=a.asReduxStore,e.connectReduxDevtools=a.connectReduxDevtools},function(t,e){"use strict";function n(t){throw void 0===t&&(t="Illegal state"),new Error("[mobx-state-tree] "+t)}function r(t){return t}function i(){return null}function o(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i)t[o]=i[o]}return t}function a(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++){var i=e[r];for(var o in i){var a=Object.getOwnPropertyDescriptor(i,o);"get"in a?Object.defineProperty(t,o,a):t[o]=i[o]}}return t}function s(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function u(t){return!(null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp)}function c(t){return null===t||void 0===t||"string"==typeof t||"number"==typeof t||"boolean"==typeof t||t instanceof Date}function p(t){return"function"!=typeof t}function f(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!1,configurable:!0,value:n})}function l(t,e,n){Object.defineProperty(t,e,{enumerable:!1,writable:!0,configurable:!0,value:n})}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!0,writable:!1,configurable:!0,value:n})}function d(t,e){return t.push(e),function(){var n=t.indexOf(e);n!==-1&&t.splice(n,1)}}function y(t,e){return m.call(t,e)}function v(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e}function b(t,e){return new Function("f","return function "+t+"() { return f.apply(this, arguments)}")(e)}function g(t){return"string"==typeof t&&/^[a-z0-9_-]+$/i.test(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.EMPTY_ARRAY=Object.freeze([]),e.fail=n,e.identity=r,e.nothing=i,e.extend=o,e.extendKeepGetter=a,e.isPlainObject=s,e.isMutable=u,e.isPrimitive=c,e.isSerializable=p,e.addHiddenFinalProp=f,e.addHiddenWritableProp=l,e.addReadOnlyProp=h,e.registerEventHandler=d;var m=Object.prototype.hasOwnProperty;e.hasOwnProperty=y,e.argsToArray=v,e.createNamedFunction=b,e.isValidIdentifier=g},function(t,e,n){"use strict";function r(t){var e=t.value,n=t.context[t.context.length-1].type,r=t.context.map(function(t){var e=t.path;return e}).filter(function(t){return t.length>0}).join("/"),i=r.length>0?'at path "/'+r+'" ':"",o=f.maybeMST(e,function(t){return"value of type "+t.type.name+":"},function(){return p.isPrimitive(e)?"value":"snapshot"}),a=n&&f.isMST(e)&&n.is(f.getMSTAdministration(e).snapshot);return""+i+o+" "+d(e)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(t.message?" ("+t.message+")":"")+(n?l.isPrimitiveType(n)||n instanceof h.OptionalValue&&l.isPrimitiveType(n.type)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function i(t){return[{type:t,path:""}]}function o(t,e,n){return t.concat([{path:e,type:n}])}function a(){return p.EMPTY_ARRAY}function s(t,e,n){return[{context:t,value:e,message:n}]}function u(t){return t.reduce(function(t,e){return t.concat(e)},[])}function c(t,e){var n=t.validate(e,[{path:"",type:t}]);n.length>0&&p.fail("Error while converting "+d(e)+" to `"+t.name+"`:\n"+n.map(r).join("\n"))}Object.defineProperty(e,"__esModule",{value:!0});var p=n(1),f=n(6),l=n(12),h=n(13),d=function(t){return f.isMST(t)?"<"+t+">":"`"+JSON.stringify(t)+"`"};e.getDefaultContext=i,e.getContextForPath=o,e.typeCheckSuccess=a,e.typeCheckFailure=s,e.flattenTypeErrors=u,e.typecheck=c},function(t,e,n){"use strict";function r(t){return"object"==typeof t&&t&&t.isType===!0}Object.defineProperty(e,"__esModule",{value:!0});var i;!function(t){t[t.String=1]="String",t[t.Number=2]="Number",t[t.Boolean=4]="Boolean",t[t.Date=8]="Date",t[t.Literal=16]="Literal",t[t.Array=32]="Array",t[t.Map=64]="Map",t[t.Object=128]="Object",t[t.Frozen=256]="Frozen",t[t.Optional=512]="Optional"}(i=e.TypeFlags||(e.TypeFlags={})),e.isType=r;var o=function(){function t(t){this.isType=!0,this.name=t}return t.prototype.is=function(t){return 0===this.validate(t,[{path:"",type:this}]).length},Object.defineProperty(t.prototype,"Type",{get:function(){return a.fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"SnapshotType",{get:function(){return a.fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),t}();e.Type=o;var a=n(1)},function(e,n){e.exports=t},function(t,e,n){"use strict";function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(6)),r(n(15)),r(n(14)),r(n(9)),r(n(7))},function(t,e,n){"use strict";function r(t){return a(t).type}function i(t,e){return a(t).getChildType(e)}function o(t){return t&&t.$treenode}function a(t){return o(t)?t.$treenode:f.fail("element has no Node")}function s(t,e,n){if(f.isMutable(t)&&o(t)){var r=a(t);return e(r,r.target)}return n?n(t):t}function u(t){return t instanceof Date?{$treetype:"Date",time:t.toJSON()}:o(t)?a(t).snapshot:f.isSerializable(t)?t:void f.fail("Unable to convert value to snapshot.")}function c(t,e){t.root!==e.root&&f.fail("Cannot calculate relative path: objects '"+t+"' and '"+e+"' are not part of the same object tree");for(var n=p.splitJsonPath(t.path),r=p.splitJsonPath(e.path),i=0;i<n.length&&n[i]===r[i];i++);return n.slice(i).map(function(t){return".."}).join("/")+p.joinJsonPath(r.slice(i))}Object.defineProperty(e,"__esModule",{value:!0});var p=n(9);e.getType=r,e.getChildType=i,e.isMST=o,e.getMSTAdministration=a,e.maybeMST=s,e.valueToSnapshot=u,e.getRelativePathForNodes=c;var f=n(1)},function(t,e,n){"use strict";function r(t,e){var n=z.getMSTAdministration(t);return n.isProtectionEnabled||console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`"),n.addMiddleWare(e)}function i(t,e){return z.getMSTAdministration(t).onPatch(e)}function o(t,e){return z.getMSTAdministration(t).onSnapshot(e)}function a(t,e){return z.getMSTAdministration(t).applyPatch(e)}function s(t,e){var n=z.getMSTAdministration(t);I.runInAction(function(){e.forEach(function(t){return n.applyPatch(t)})})}function u(t){var e={patches:[],stop:function(){return n()},replay:function(t){s(t,e.patches)}},n=i(t,function(t){e.patches.push(t)});return e}function c(t,e){I.runInAction(function(){e.forEach(function(e){return R.applyAction(t,e)})})}function p(t){var e={actions:[],stop:function(){return n()},replay:function(t){c(t,e.actions)}},n=R.onAction(t,e.actions.push.bind(e.actions));return e}function f(t){z.getMSTAdministration(t).isProtectionEnabled=!0}function l(t){z.getMSTAdministration(t).isProtectionEnabled=!1}function h(t){return z.getMSTAdministration(t).isProtectionEnabled}function d(t,e){return z.getMSTAdministration(t).applySnapshot(e)}function y(t){return z.getMSTAdministration(t).snapshot}function v(t,e){void 0===e&&(e=1),e<0&&E.fail("Invalid depth: "+e+", should be >= 1");for(var n=z.getMSTAdministration(t).parent;n;){if(0===--e)return!0;n=n.parent}return!1}function b(t,e){void 0===e&&(e=1),e<0&&E.fail("Invalid depth: "+e+", should be >= 1");for(var n=e,r=z.getMSTAdministration(t).parent;r;){if(0===--n)return r.target;r=r.parent}return E.fail("Failed to find the parent of "+z.getMSTAdministration(t)+" at depth "+e)}function g(t){return z.getMSTAdministration(t).root.target}function m(t){return z.getMSTAdministration(t).path}function _(t){return V.splitJsonPath(z.getMSTAdministration(t).path)}function P(t){return z.getMSTAdministration(t).isRoot}function T(t,e){var n=z.getMSTAdministration(t).resolve(e);return n?n.target:void 0}function A(t,e){var n=z.getMSTAdministration(t).resolve(e,!1);if(void 0!==n)return n?n.target:void 0}function j(t,e){return z.getRelativePathForNodes(z.getMSTAdministration(t),z.getMSTAdministration(e))}function O(t,e){void 0===e&&(e=!0);var n=z.getMSTAdministration(t);return n.type.create(n.snapshot,e===!0?n.root._environment:e===!1?void 0:e)}function S(t){return z.getMSTAdministration(t).detach(),t}function w(t){var e=z.getMSTAdministration(t);e.isRoot?e.die():e.parent.removeChild(e.subpath)}function M(t){return z.getMSTAdministration(t).isAlive}function C(t,e){z.getMSTAdministration(t).addDisposer(e)}function x(t){var e=z.getMSTAdministration(t),n=e.root._environment;return n||E.fail("Node '"+e+"' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()"),n}function F(t,e){var n=z.getMSTAdministration(t);n.getChildMSTs().forEach(function(t){var n=(t[0],t[1]);F(n.target,e)}),e(n.target)}function k(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=t.create(e);return c(i,n),y(i)}Object.defineProperty(e,"__esModule",{value:!0});var R=n(14),I=n(4),z=n(6),V=n(9),E=n(1);e.addMiddleware=r,e.onPatch=i,e.onSnapshot=o,e.applyPatch=a,e.applyPatches=s,e.recordPatches=u,e.applyActions=c,e.recordActions=p,e.protect=f,e.unprotect=l,e.isProtected=h,e.applySnapshot=d,e.getSnapshot=y,e.hasParent=v,e.getParent=b,e.getRoot=g,e.getPath=m,e.getPathParts=_,e.isRoot=P,e.resolve=T,e.tryResolve=A,e.getRelativePath=j,e.clone=O,e.detach=S,e.destroy=w,e.isAlive=M,e.addDisposer=C,e.getEnv=x,e.walk=F,e.testActions=k},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.name=t}return t.prototype.initializePrototype=function(t){},t.prototype.initialize=function(t,e){},t.prototype.willChange=function(t){return null},t.prototype.didChange=function(t){},t.prototype.serialize=function(t,e){},t.prototype.deserialize=function(t,e){},t}();e.Property=n},function(t,e){"use strict";function n(t){return t.replace(/~/g,"~1").replace(/\//g,"~0")}function r(t){return t.replace(/~0/g,"\\").replace(/~1/g,"~")}function i(t){return 0===t.length?"":"/"+t.map(n).join("/")}function o(t){var e=t.split("/").map(r);return""===e[0]?e.slice(1):e}Object.defineProperty(e,"__esModule",{value:!0}),e.escapeJsonPath=n,e.unescapeJsonPath=r,e.joinJsonPath=i,e.splitJsonPath=o},function(t,e,n){"use strict";function r(){return p.getMSTAdministration(this).snapshot}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),a=n(3),s=n(1),u=n(2),c=function(t){function e(e){var n=t.call(this,e)||this;return n.create=o.action(n.name,n.create),n}return i(e,t),e.prototype.create=function(t,e,n,i){var o=this;void 0===t&&(t=this.getDefaultSnapshot()),void 0===e&&(e=void 0),void 0===n&&(n=null),void 0===i&&(i=""),u.typecheck(this,t);var a=this.createNewInstance(),c=new f.MSTAdministration(n,i,a,this,e),p=!0;try{return c.pseudoAction(function(){o.finalizeNewInstance(a,t)}),s.addReadOnlyProp(a,"toJSON",r),c.fireHook("afterCreate"),n&&c.fireHook("afterAttach"),p=!1,a}finally{p&&(c._isAlive=!1)}},e.prototype.validate=function(t,e){return t&&"object"==typeof t?p.isMST(t)?p.getType(t)===this?u.typeCheckSuccess():u.typeCheckFailure(e,t):this.isValidSnapshot(t,e):u.typeCheckFailure(e,t)},e}(a.Type);e.ComplexType=c;var p=n(6),f=n(15)},function(t,e,n){"use strict";function r(){return d.getMSTAdministration(this).toString()}function i(t,e,n){var r="string"==typeof t?t:"AnonymousModel",i="string"==typeof t?e:t,o="string"==typeof t?n:e;return new M(r,i,o||{})}function o(t){var e=y.isType(t)?t:d.getType(t);return u(e)?e.baseModel:{}}function a(t){var e=y.isType(t)?t:d.getType(t);return u(e)?e.baseActions:{}}function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];console.warn("[mobx-state-tree] `extend` is an experimental feature and it's behavior will probably change in the future");var n="string"==typeof t[0]?t.slice(1):t,r="string"==typeof t[0]?t[0]:n.map(function(t){return t.name}).join("_"),s=h.extendKeepGetter.apply(null,[{}].concat(n.map(o))),u=h.extend.apply(null,[{}].concat(n.map(a)));return i(r,s,u)}function u(t){return y.isType(t)&&(t.flags&y.TypeFlags.Object)>0}function c(t){return u(t)?t.identifierAttribute:null}var p=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),f=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var l=n(4),h=n(1),d=n(5),y=n(3),v=n(2),b=n(10),g=n(12),m=n(13),_=n(18),P=n(16),T=n(27),A=n(28),j=n(26),O=n(29),S=n(25),w=n(30),M=function(t){function e(e,n,i){var o=t.call(this,e)||this;return o.isObjectFactory=!0,o.flags=y.TypeFlags.Object,o.props={},o.identifierAttribute=null,o.didChange=function(t){o.props[t.name].didChange(t)},Object.freeze(n),Object.freeze(i),o.baseModel=n,o.baseActions=i,/^\w[\w\d_]*$/.test(e)||h.fail("Typename should be a valid identifier: "+e),o.modelConstructor=new Function("return function "+e+" (){}")(),o.modelConstructor.prototype.toString=r,o.parseModelProps(),o.forAllProps(function(t){return t.initializePrototype(o.modelConstructor.prototype)}),o}return p(e,t),e.prototype.createNewInstance=function(){var t=new this.modelConstructor;return l.extendShallowObservable(t,{}),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;l.intercept(t,function(t){return n.willChange(t)}),l.observe(t,this.didChange),this.forAllProps(function(n){return n.initialize(t,e)})},e.prototype.willChange=function(t){var e=d.getMSTAdministration(t.object);return e.assertWritable(),this.props[t.name].willChange(t)},e.prototype.parseModelProps=function(){var t=this,e=t.baseModel,n=t.baseActions;for(var r in e)if(h.hasOwnProperty(e,r)){var i=Object.getOwnPropertyDescriptor(e,r);if("get"in i){this.props[r]=new j.ComputedProperty(r,i.get,i.set);continue}var o=i.value;if(null===o)h.fail("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else if(P.isIdentifierFactory(o))this.identifierAttribute&&h.fail("Cannot define property '"+r+"' as object identifier, property '"+this.identifierAttribute+"' is already defined as identifier property"),this.identifierAttribute=r,this.props[r]=new T.IdentifierProperty(r,o.primitiveType);else if(h.isPrimitive(o)){var a=g.getPrimitiveFactoryFromValue(o);this.props[r]=new O.ValueProperty(r,m.optional(a,o))}else y.isType(o)?this.props[r]=new O.ValueProperty(r,o):_.isReferenceFactory(o)?this.props[r]=new A.ReferenceProperty(r,o.targetType,o.basePath):"function"==typeof o?this.props[r]=new w.ViewProperty(r,o):"object"==typeof o?h.fail("In property '"+r+"': base model's should not contain complex values: '"+o+"'"):h.fail("Unexpected value for property '"+r+"'")}for(var r in n)if(h.hasOwnProperty(n,r)){var o=n[r];r in this.baseModel&&h.fail("Property '"+r+"' was also defined as action. Actions and properties should not collide"),"function"==typeof o?this.props[r]=new S.ActionProperty(r,o):h.fail("Unexpected value for action '"+r+"'. Expected function, got "+typeof o)}},e.prototype.getChildMSTs=function(t){var e=[];return this.forAllProps(function(n){n instanceof O.ValueProperty&&d.maybeMST(t.target[n.name],function(t){return e.push([n.name,t])})}),e},e.prototype.getChildMST=function(t,e){return d.maybeMST(t.target[e],h.identity,h.nothing)},e.prototype.serialize=function(t){var e={};return this.forAllProps(function(n){return n.serialize(t.target,e)}),e},e.prototype.applyPatchLocally=function(t,e,n){"replace"!==n.op&&"add"!==n.op&&h.fail("object does not support operation "+n.op),t.target[e]=n.value},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){for(var r in n.props)n.props[r].deserialize(t.target,e)})},e.prototype.getChildType=function(t){return this.props[t].type},e.prototype.isValidSnapshot=function(t,e){var n=this;return h.isPlainObject(t)?v.flattenTypeErrors(Object.keys(this.props).map(function(r){return n.props[r].validate(t,e)})):v.typeCheckFailure(e,t)},e.prototype.forAllProps=function(t){var e=this;Object.keys(this.props).forEach(function(n){return t(e.props[n])})},e.prototype.describe=function(){var t=this;return"{ "+Object.keys(this.props).map(function(e){var n=t.props[e];return n instanceof O.ValueProperty?e+": "+n.type.describe():n instanceof T.IdentifierProperty?e+": identifier":""}).filter(Boolean).join("; ")+" }"},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target[e]=null},e}(b.ComplexType);f([l.action],M.prototype,"applySnapshot",null),e.ObjectType=M,e.model=i,e.extend=s,e.isObjectFactory=u,e.getIdentifierAttribute=c},function(t,e,n){"use strict";function r(t){switch(typeof t){case"string":return e.string;case"number":return e.number;case"boolean":return e.boolean;case"object":if(t instanceof Date)return e.DatePrimitive}return u.fail("Cannot determine primtive type from value "+t)}function i(t){return(t.flags&(a.TypeFlags.String|a.TypeFlags.Number|a.TypeFlags.Boolean|a.TypeFlags.Date))>0}var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var a=n(3),s=n(2),u=n(1),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.flags=n,i.checker=r,i}return o(e,t),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){return u.isPrimitive(t)||u.fail("Not a primitive: '"+t+"'"),this.checker(t)||u.fail("Value is not assignable to '"+this.name+"'"),t},e.prototype.validate=function(t,e){return u.isPrimitive(t)&&this.checker(t)?s.typeCheckSuccess():s.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(a.Type);e.CoreType=c,e.string=new c("string",a.TypeFlags.String,function(t){return"string"==typeof t}),e.number=new c("number",a.TypeFlags.Number,function(t){return"number"==typeof t}),e.boolean=new c("boolean",a.TypeFlags.Boolean,function(t){return"boolean"==typeof t}),e.DatePrimitive=new c("Date",a.TypeFlags.Date,function(t){return t instanceof Date}),e.getPrimitiveFactoryFromValue=r,e.isPrimitiveType=i},function(t,e,n){"use strict";function r(t,e){var n="function"==typeof e?e():e,r=u.isMST(n)?u.getMSTAdministration(n).snapshot:n;return a.typecheck(t,r),new s(t,e)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=function(t){function e(e,n){var r=t.call(this,e.name)||this;return r.type=e,r.defaultValue=n,r}return i(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags|o.TypeFlags.Optional},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.type.describe()+"?"},e.prototype.create=function(t){if("undefined"==typeof t){var e="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue,n=u.isMST(e)?u.getMSTAdministration(e).snapshot:e;return this.type.create(n)}return this.type.create(t)},e.prototype.validate=function(t,e){return void 0===t||this.type.is(t)?a.typeCheckSuccess():a.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.OptionalValue=s,e.optional=r;var u=n(6)},function(t,e,n){"use strict";function r(t){return t.object[t.name].apply(t.object,t.args)}function i(t){for(var e=t.middlewares.slice(),n=t;n.parent;)n=n.parent,e=e.concat(n.middlewares);return e}function o(t,e){function n(t){var e=o.shift();return e?e(t,n):r(t)}var o=i(t);return o.length?n(e):r(e)}function a(t,e){var n=f.action(t,e),r=function(){var e=l.getMSTAdministration(this);if(e.assertAlive(),e.isRunningAction())return n.apply(this,arguments);var r={name:t,object:e.target,args:d.argsToArray(arguments)},i=e.root;i._isRunningAction=!0;try{return o(e,r)}finally{i._isRunningAction=!1}};return d.createNamedFunction(t,r)}function s(t,e,n,r){if(d.isPrimitive(r))return r;if(l.isMST(r)){var i=l.getMSTAdministration(r);if(t.root!==i.root)throw new Error("Argument "+n+" that was passed to action '"+e+"' is a model that is not part of the same state tree. Consider passing a snapshot or some representative ID instead");return{$ref:l.getRelativePathForNodes(t,l.getMSTAdministration(r))}}if("function"==typeof r)throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a function");if("object"==typeof r&&!d.isPlainObject(r)&&!Array.isArray(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received a "+(r&&r.constructor?r.constructor.name:"Complex Object"));if(f.isObservable(r))throw new Error("Argument "+n+" that was passed to action '"+e+"' should be a primitive, model object or plain object, received an mobx observable.");try{return JSON.stringify(r),r}catch(t){throw new Error("Argument "+n+" that was passed to action '"+e+"' is not serializable.")}}function u(t,e){if("object"==typeof e){var n=Object.keys(e);if(1===n.length&&"$ref"===n[0])return h.resolve(t.target,e.$ref)}return e}function c(t,e){var n=h.tryResolve(t,e.path||"");if(!n)return d.fail("Invalid action path: "+(e.path||""));var r=l.getMSTAdministration(n);return"function"!=typeof n[e.name]&&d.fail("Action '"+e.name+"' does not exist in '"+r.path+"'"),n[e.name].apply(n,e.args?e.args.map(function(t){return u(r,t)}):[])}function p(t,e){return h.addMiddleware(t,function(n,r){var i=l.getMSTAdministration(n.object);return e({name:n.name,path:l.getRelativePathForNodes(l.getMSTAdministration(t),i),args:n.args.map(function(t,e){return s(i,n.name,e,t)})}),r(n)})}Object.defineProperty(e,"__esModule",{value:!0});var f=n(4);e.createActionInvoker=a,e.applyAction=c,e.onAction=p;var l=n(6),h=n(7),d=n(1)},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(2),a=n(6),s=n(1),u=n(9),c=n(11),p=n(10),f=1,l=function(){function t(t,e,n,r,o){var a=this;this.nodeId=++f,this._parent=null,this.subpath="",this.isProtectionEnabled=!0,this._environment=void 0,this._isRunningAction=!1,this._isAlive=!0,this._isDetaching=!1,this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.disposers=[],r instanceof p.ComplexType||s.fail("Uh oh"),s.addHiddenFinalProp(n,"$treenode",this),this._parent=t,this.subpath=e,this.type=r,this.target=n,this._environment=o;var u=i.reaction(function(){return a.snapshot},function(t){a.snapshotSubscribers.forEach(function(e){return e(t)})});u.onError(function(t){throw t}),this.addDisposer(u)}return Object.defineProperty(t.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+u.escapeJsonPath(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return null===this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){for(var t,e=this;t=e.parent;)e=t;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAlive",{get:function(){return this._isAlive},enumerable:!0,configurable:!0}),t.prototype.die=function(){this._isDetaching||(h.walk(this.target,function(t){return a.getMSTAdministration(t).aboutToDie()}),h.walk(this.target,function(t){return a.getMSTAdministration(t).finalizeDeath()}))},t.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(t){return t()}),this.fireHook("beforeDestroy")},t.prototype.finalizeDeath=function(){var t=this,e=this.path;s.addReadOnlyProp(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this._isAlive=!1,this._parent=null,this.subpath="",Object.defineProperty(this.target,"$mobx",{get:function(){s.fail("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+t.type.name+"') used to live at '"+e+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},t.prototype.assertAlive=function(){this._isAlive||s.fail(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},Object.defineProperty(t.prototype,"snapshot",{get:function(){if(this._isAlive)return Object.freeze(this.type.serialize(this))},enumerable:!0,configurable:!0}),t.prototype.onSnapshot=function(t){return s.registerEventHandler(this.snapshotSubscribers,t)},t.prototype.applySnapshot=function(t){return o.typecheck(this.type,t),this.type.applySnapshot(this,t)},t.prototype.applyPatch=function(t){var e=u.splitJsonPath(t.path),n=this.resolvePath(e.slice(0,-1));n.pseudoAction(function(){n.applyPatchLocally(e[e.length-1],t)})},t.prototype.applyPatchLocally=function(t,e){this.assertWritable(),this.type.applyPatchLocally(this,t,e)},t.prototype.onPatch=function(t){return s.registerEventHandler(this.patchSubscribers,t)},t.prototype.emitPatch=function(t,e){if(this.patchSubscribers.length){var n=s.extend({},t,{path:e.path.substr(this.path.length)+"/"+t.path});this.patchSubscribers.forEach(function(t){return t(n)})}this.parent&&this.parent.emitPatch(t,e)},t.prototype.setParent=function(t,e){void 0===e&&(e=null),this.parent===t&&this.subpath===e||(this._parent&&t&&t!==this._parent&&s.fail("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+t.path+"/"+e+"'."),!this._parent&&t&&t.root===this&&s.fail("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+t.path+"/"+e+"'"),!this._parent&&this._environment&&s.fail("A state tree that has been initialized with an environment cannot be made part of another state tree."),this.parent&&!t?this.die():(this._parent=t,this.subpath=e||"",this.fireHook("afterAttach")))},t.prototype.addDisposer=function(t){this.disposers.unshift(t)},t.prototype.reconcileChildren=function(t,e,n,r){var i=this,u=new Array(n.length),p={},f={},l=c.getIdentifierAttribute(t);e.forEach(function(t){if(t){if(l){var e=t[l];e&&(f[e]=t)}a.isMST(t)&&(p[a.getMSTAdministration(t).nodeId]=t)}}),n.forEach(function(e,n){var c=""+r[n];if(a.isMST(e)){var h=a.getMSTAdministration(e);if(h.assertAlive(),h.parent&&(h.parent!==i||!p[h.nodeId]))return s.fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+i.path+"/"+c+"', but it lives already at '"+h.path+"'");p[h.nodeId]=void 0,h.setParent(i,c),u[n]=e}else if(l&&s.isMutable(e)){o.typecheck(t,e);var d=e[l],y=f[d],h=y&&a.getMSTAdministration(y);y&&h.type.is(e)?(p[h.nodeId]=void 0,h.setParent(i,c),h.applySnapshot(e),u[n]=y):u[n]=t.create(e,void 0,i,c)}else o.typecheck(t,e),u[n]=t.create(e,void 0,i,c)});for(var h in p)p[h]&&a.getMSTAdministration(p[h]).die();return u},t.prototype.resolve=function(t,e){return void 0===e&&(e=!0),this.resolvePath(u.splitJsonPath(t),e)},t.prototype.resolvePath=function(t,e){void 0===e&&(e=!0),this.assertAlive();for(var n=this,r=0;r<t.length;r++){if(""===t[r])n=n.root;else if(".."===t[r])n=n.parent;else{if("."===t[r]||""===t[r])continue;n=n.getChildMST(t[r])}if(null===n)return e?s.fail("Could not resolve '"+t[r]+"' in '"+u.joinJsonPath(t.slice(0,r-1))+"', path of the patch does not resolve"):void 0}return n},t.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},t.prototype.addMiddleWare=function(t){return s.registerEventHandler(this.middlewares,t)},t.prototype.getChildMST=function(t){return this.assertAlive(),this.type.getChildMST(this,t)},t.prototype.getChildMSTs=function(){return this.type.getChildMSTs(this)},t.prototype.getChildType=function(t){return this.type.getChildType(t)},Object.defineProperty(t.prototype,"isProtected",{get:function(){for(var t=this;t;){if(t.isProtectionEnabled===!1)return!1;t=t.parent}return!0},enumerable:!0,configurable:!0}),t.prototype.pseudoAction=function(t){var e=this._isRunningAction;this._isRunningAction=!0,t(),this._isRunningAction=e},t.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&s.fail("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},t.prototype.removeChild=function(t){this.type.removeChild(this,t)},t.prototype.detach=function(){this._isAlive||s.fail("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this._isDetaching=!0,this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this._isDetaching=!1)},t.prototype.fireHook=function(t){var e=this.target[t];"function"==typeof e&&e.apply(this.target)},t.prototype.toString=function(){var t=c.getIdentifierAttribute(this.type),e=t?"("+t+": "+this.target[t]+")":"";return this.type.name+"@"+(this.path||"<root>")+e+(this.isAlive?"":"[dead]")},t}();r([i.observable],l.prototype,"_parent",void 0),r([i.observable],l.prototype,"subpath",void 0),r([i.computed],l.prototype,"path",null),r([i.computed],l.prototype,"snapshot",null),r([i.action],l.prototype,"applyPatch",null),e.MSTAdministration=l;var h=n(7)},function(t,e,n){"use strict";function r(t){return void 0===t&&(t=o.string),
t!==o.string&&t!==o.number&&a.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers"),{isIdentifier:!0,primitiveType:t}}function i(t){return"object"==typeof t&&t&&t.isIdentifier===!0}Object.defineProperty(e,"__esModule",{value:!0});var o=n(12),a=n(1);e.identifier=r,e.isIdentifierFactory=i},function(t,e,n){"use strict";function r(t){return a.isPrimitive(t)||a.fail("Literal types can be built only on top of primitives"),new u(t)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(1),s=n(2),u=function(t){function e(e){var n=t.call(this,""+e)||this;return n.flags=o.TypeFlags.Literal,n.value=e,n}return i(e,t),e.prototype.create=function(t){return s.typecheck(this,t),this.value},e.prototype.describe=function(){return JSON.stringify(this.value)},e.prototype.validate=function(t,e){return a.isPrimitive(t)&&t===this.value?s.typeCheckSuccess():s.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Literal=u,e.literal=r},function(t,e){"use strict";function n(t,e){return void 0===e&&(e=""),{targetType:t,basePath:e,isReference:!0}}function r(t){return t.isReference===!0}Object.defineProperty(e,"__esModule",{value:!0}),e.reference=n,e.isReferenceFactory=r},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=o.isType(t)?null:t,i=o.isType(t)?e.concat(t):e,a=i.map(function(t){return t.name}).join(" | ");return new u(a,i,r)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=n(1),u=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dispatcher=null,i.dispatcher=r,i.types=n,i}return i(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){var t=0;return this.types.forEach(function(e){t|=e.flags}),t},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return"("+this.types.map(function(t){return t.describe()}).join(" | ")+")"},e.prototype.create=function(t,e,n,r){if(void 0===e&&(e=void 0),void 0===n&&(n=null),void 0===r&&(r=""),a.typecheck(this,t),null!==this.dispatcher)return this.dispatcher(t).create(t,e,n,r);var i=this.types.filter(function(e){return e.is(t)});return i.length>1?s.fail("Ambiguos snapshot "+JSON.stringify(t)+" for union "+this.name+". Please provide a dispatch in the union declaration."):i[0].create(t,e,n,r)},e.prototype.validate=function(t,e){if(null!==this.dispatcher)return this.dispatcher(t).validate(t,e);var n=this.types.map(function(n){return n.validate(t,e)}),r=n.filter(function(t){return 0===t.length});return r.length>1?a.typeCheckFailure(e,t,"Multiple types are applicable and no dispatch method is defined for the union"):r.length<1?a.typeCheckFailure(e,t,"No type is applicable and no dispatch method is defined for the union").concat(a.flattenTypeErrors(n)):a.typeCheckSuccess()},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){var t=this.types[0].identifierAttribute;return t&&this.types.every(function(e){return e.identifierAttribute===t})?t:null},enumerable:!0,configurable:!0}),e}(o.Type);e.Union=u,e.union=r},function(t,e,n){"use strict";var r=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(6),a=n(1),s=n(11),u=n(2),c=n(7),p=function(){function t(t,e,n,r){return this.owner=t,this.type=e,this.basePath=n,this.identifier=null,n&&(this.targetIdAttribute=s.getIdentifierAttribute(e)||"",!this.targetIdAttribute)?a.fail("Cannot create reference to path '"+n+"'; the targeted type, "+e.describe()+", does not specify an identifier property"):void this.setNewValue(r)}return Object.defineProperty(t.prototype,"get",{get:function(){var t=this,e=t.targetIdAttribute,n=t.identifier;if(null===n)return null;if(this.basePath){var r=c.resolve(this.owner,this.basePath);if(i.isObservableArray(r))return r.find(function(t){return t&&t[e]===n});if(i.isObservableMap(r)){var o=r.get(n);return o&&o[e]!==n&&a.fail("Inconsistent collection, the map entry under key '"+n+"' should have property '"+e+"' set to value '"+n),o}return a.fail("References with base paths should point to either an `array` or `map` collection")}return c.resolve(this.owner,n)},enumerable:!0,configurable:!0}),t.prototype.setNewValue=function(t){if(t)if(o.isMST(t)){u.typecheck(this.type,t);var e=o.getMSTAdministration(this.owner),n=o.getMSTAdministration(t);this.targetIdAttribute?this.identifier=t[this.targetIdAttribute]:(e.root!==n.root&&a.fail("Failed to assign a value to a reference; the value should already be part of the same model tree"),this.identifier=o.getRelativePathForNodes(e,n))}else this.targetIdAttribute?("string"!=typeof t&&a.fail("Expected an identifier, got: "+t),this.identifier=t):("object"==typeof t&&"string"==typeof t.$ref||a.fail("Expected a reference in the format `{ $ref: ... }`, got: "+t),this.identifier=t.$ref);else this.identifier=null},t.prototype.serialize=function(){return this.basePath?this.identifier:this.identifier?{$ref:this.identifier}:null},t}();r([i.observable],p.prototype,"identifier",void 0),r([i.computed],p.prototype,"get",null),e.Reference=p},function(t,e,n){"use strict";function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.isMST(t)||p.fail("Expected model object");var r={getState:function(){return u.getSnapshot(t)},dispatch:function(e){o(e,a.slice(),function(e){return c.applyAction(t,i(e))})},subscribe:function(e){return u.onSnapshot(t,e)}},a=e.map(function(t){return t(r)});return r}function i(t){var e=p.extend({},t);return delete e.type,{name:t.type,args:[e]}}function o(t,e,n){function r(t){var i=e.shift();i?i(r)(t):n(t)}r(t)}function a(t,e){var n=t.connectViaExtension(),r=!1;n.subscribe(function(n){var i=t.extractState(n);i&&(r=!0,u.applySnapshot(e,i),r=!1)}),c.onAction(e,function(t){if(!r){var i={};i.type=t.name,t.args&&t.args.forEach(function(t,e){return i[e]=t}),n.send(i,u.getSnapshot(e))}})}Object.defineProperty(e,"__esModule",{value:!0});var s=n(5),u=n(7),c=n(14),p=n(1);e.asReduxStore=r,e.connectReduxDevtools=a},function(t,e,n){"use strict";function r(){return c.getMSTAdministration(this)+"("+this.length+" items)"}function i(t){return new d(t.name+"[]",t)}function o(t){return f.isType(t)&&(t.flags&f.TypeFlags.Array)>0}var a=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),s=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var u=n(4),c=n(5),p=n(1),f=n(3),l=n(2),h=n(10);e.arrayToString=r;var d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isArrayFactory=!0,r.flags=f.TypeFlags.Array,r.subType=n,r}return a(e,t),e.prototype.describe=function(){return this.subType.describe()+"[]"},e.prototype.createNewInstance=function(){var t=u.observable.shallowArray();return p.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;u.intercept(t,function(t){return n.willChange(t)}),u.observe(t,this.didChange),c.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=t.target,n=[];return e.forEach(function(t,e){c.maybeMST(t,function(t){n.push([""+e,t])})}),n},e.prototype.getChildMST=function(t,e){var n=t.target,r=parseInt(e,10);return r<n.length?c.maybeMST(n[r],p.identity,p.nothing):null},e.prototype.willChange=function(t){var e=c.getMSTAdministration(t.object);switch(e.assertWritable(),t.type){case"update":if(t.newValue===t.object[t.index])return null;t.newValue=e.reconcileChildren(this.subType,[t.object[t.index]],[t.newValue],[t.index])[0];break;case"splice":var n=t.index,r=t.removedCount,i=t.added,o=t.object;t.added=e.reconcileChildren(this.subType,o.slice(n,n+r),i,i.map(function(t,e){return n+e}));for(var a=function(t){c.maybeMST(o[t],function(n){n.setParent(e,""+(t+i.length-r))})},s=n+r;s<o.length;s++)a(s)}return t},e.prototype.serialize=function(t){var e=t.target;return e.map(c.valueToSnapshot)},e.prototype.didChange=function(t){var e=c.getMSTAdministration(t.object);switch(t.type){case"update":return void e.emitPatch({op:"replace",path:""+t.index,value:c.valueToSnapshot(t.newValue)},e);case"splice":for(var n=t.index+t.removedCount-1;n>=t.index;n--)e.emitPatch({op:"remove",path:""+n},e);for(var n=0;n<t.addedCount;n++)e.emitPatch({op:"add",path:""+(t.index+n),value:c.valueToSnapshot(t.added[n])},e);return}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target,i="-"===e?r.length:parseInt(e);switch(n.op){case"replace":r[i]=n.value;break;case"add":r.splice(i,0,n.value);break;case"remove":r.splice(i,1)}},e.prototype.applySnapshot=function(t,e){t.pseudoAction(function(){var n=t.target;n.replace(e)})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return Array.isArray(t)?l.flattenTypeErrors(t.map(function(t,r){return n.subType.validate(t,l.getContextForPath(e,""+r,n.subType))})):l.typeCheckFailure(e,t)},e.prototype.getDefaultSnapshot=function(){return[]},e.prototype.removeChild=function(t,e){t.target.splice(parseInt(e,10),1)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(h.ComplexType);s([u.action],d.prototype,"applySnapshot",null),e.ArrayType=d,e.array=i,e.isArrayFactory=o},function(t,e,n){"use strict";function r(){return f.getMSTAdministration(this)+"("+this.size+" items)"}function i(t){var e=c.getIdentifierAttribute(f.getMSTAdministration(this).type.subType);return e||l.fail("Map.put is only supported if the subtype has an idenfier attribute"),t||l.fail("Map.put cannot be used to set empty values"),this.set(t[e],t),this}function o(t){return new v("map<string, "+t.name+">",t)}function a(t){return h.isType(t)&&(t.flags&h.TypeFlags.Map)>0}var s=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=this&&this.__decorate||function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var c=n(11),p=n(4),f=n(5),l=n(1),h=n(3),d=n(2),y=n(10);e.mapToString=r;var v=function(t){function e(e,n){var r=t.call(this,e)||this;return r.isMapFactory=!0,r.flags=h.TypeFlags.Map,r.subType=n,r}return s(e,t),e.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},e.prototype.createNewInstance=function(){var t=p.observable.shallowMap();return l.addHiddenFinalProp(t,"put",i),l.addHiddenFinalProp(t,"toString",r),t},e.prototype.finalizeNewInstance=function(t,e){var n=this;p.intercept(t,function(t){return n.willChange(t)}),p.observe(t,this.didChange),f.getMSTAdministration(t).applySnapshot(e)},e.prototype.getChildMSTs=function(t){var e=[];return t.target.forEach(function(t,n){f.maybeMST(t,function(t){e.push([n,t])})}),e},e.prototype.getChildMST=function(t,e){var n=t.target;return n.has(e)?f.maybeMST(n.get(e),l.identity,l.nothing):null},e.prototype.willChange=function(t){var e=f.getMSTAdministration(t.object);e.assertWritable();var n=c.getIdentifierAttribute(e.type);switch(n&&t.newValue&&"object"==typeof t.newValue&&t.newValue[n]!==t.name&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t.name+"', but expected: '"+t.newValue[n]+"'"),t.type){case"update":var r=t.newValue,i=t.object.get(t.name);if(r===i)return null;t.newValue=e.reconcileChildren(this.subType,[i],[r],[t.name])[0];break;case"add":var r=t.newValue;t.newValue=e.reconcileChildren(this.subType,[],[r],[t.name])[0];break;case"delete":var i=t.object.get(t.name);e.reconcileChildren(this.subType,[i],[],[])}return t},e.prototype.serialize=function(t){var e=t.target,n={};return e.forEach(function(t,e){n[e]=f.valueToSnapshot(t)}),n},e.prototype.didChange=function(t){var e=f.getMSTAdministration(t.object);switch(t.type){case"update":case"add":return void e.emitPatch({op:"add"===t.type?"add":"replace",path:f.escapeJsonPath(t.name),value:f.valueToSnapshot(t.newValue)},e);case"delete":return void e.emitPatch({op:"remove",path:f.escapeJsonPath(t.name)},e)}},e.prototype.applyPatchLocally=function(t,e,n){var r=t.target;switch(n.op){case"add":case"replace":r.set(e,n.value);break;case"remove":r.delete(e)}},e.prototype.applySnapshot=function(t,e){var n=this;t.pseudoAction(function(){var r=t.target,i=c.getIdentifierAttribute(n.subType),o={};r.keys().forEach(function(t){o[t]=!1}),Object.keys(e).forEach(function(t){var n=e[t];i&&n&&"object"==typeof n&&t!==n[i]&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+t+"', but expected: '"+n[i]+"'"),t in o&&!l.isPrimitive(n)?f.maybeMST(r.get(t),function(t){t.applySnapshot(n)},function(){r.set(t,n)}):r.set(t,n),o[t]=!0}),Object.keys(o).forEach(function(t){o[t]===!1&&r.delete(t)})})},e.prototype.getChildType=function(t){return this.subType},e.prototype.isValidSnapshot=function(t,e){var n=this;return l.isPlainObject(t)?d.flattenTypeErrors(Object.keys(t).map(function(r){return n.subType.validate(t[r],d.getContextForPath(e,r,n.subType))})):d.typeCheckFailure(e,t)},e.prototype.getDefaultSnapshot=function(){return{}},e.prototype.removeChild=function(t,e){t.target.delete(e)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(y.ComplexType);u([p.action],v.prototype,"applySnapshot",null),e.MapType=v,e.map=o,e.isMapFactory=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(23),i=n(22),o=n(16),a=n(11),s=n(18),u=n(19),c=n(13),p=n(17),f=n(33),l=n(34),h=n(31),d=n(12),y=n(32);e.types={model:a.model,extend:a.extend,reference:s.reference,union:u.union,optional:c.optional,literal:p.literal,maybe:f.maybe,refinement:l.refinement,string:d.string,boolean:d.boolean,number:d.number,Date:d.DatePrimitive,map:r.map,array:i.array,frozen:h.frozen,identifier:o.identifier,late:y.late}},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),o=n(5),a=n(8),s=n(2),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.invokeAction=o.createActionInvoker(e,n),r}return r(e,t),e.prototype.initialize=function(t){i.addHiddenFinalProp(t,this.name,this.invokeAction.bind(t))},e.prototype.validate=function(t,e){return this.name in t?s.typeCheckFailure(s.getContextForPath(e,this.name),t[this.name],"Action properties should not be provided in the snapshot"):s.typeCheckSuccess()},e}(a.Property);e.ActionProperty=u},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(8),a=n(2),s=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.getter=n,i.setter=r,i}return r(e,t),e.prototype.initializePrototype=function(t){Object.defineProperty(t,this.name,i.computed(t,this.name,{get:this.getter,set:this.setter,configurable:!0,enumerable:!1}))},e.prototype.validate=function(t,e){return this.name in t?a.typeCheckFailure(a.getContextForPath(e,this.name),t[this.name],"Computed properties should not be provided in the snapshot"):a.typeCheckSuccess()},e}(o.Property);e.ComputedProperty=s},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(5),o=n(4),a=n(8),s=n(1),u=n(2),c=function(t){function e(e,n){var r=t.call(this,e)||this;return r.subtype=n,r}return r(e,t),e.prototype.initialize=function(t,e){o.extendObservable(t,(n={},n[this.name]=o.observable.ref(e[this.name]),n));var n},e.prototype.willChange=function(t){var e=t.newValue;"number"==typeof e||s.isValidIdentifier(e)||s.fail("Not a valid identifier: '"+e),u.typecheck(this.subtype,e);var n=i.getMSTAdministration(t.object);n.assertWritable();var r=t.object[this.name];return void 0!==r&&r!==e&&s.fail("It is not allowed to change the identifier of an object, got: '"+e+"' but expected: '"+r+"'"),t},e.prototype.serialize=function(t,e){var n=t[this.name];this.isValidIdentifier(n)||s.fail("Object does not have a valid identifier yet: '"+n+"'"),e[this.name]=n},e.prototype.deserialize=function(t,e){t[this.name]=e[this.name]},e.prototype.validate=function(t,e){return this.isValidIdentifier(t[this.name])?u.typeCheckSuccess():u.typeCheckFailure(u.getContextForPath(e,this.name,this.subtype),t[this.name],"The provided identifier is not valid")},e.prototype.isValidIdentifier=function(t){return!("number"!=typeof t&&!s.isValidIdentifier(t))&&this.subtype.is(t)},e}(a.Property);e.IdentifierProperty=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(8),o=n(1),a=n(5),s=n(20),u=n(2),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.basePath=r,i}return r(e,t),e.prototype.initialize=function(t,e){var n=new s.Reference(t,this.type,this.basePath,e[this.name]);o.addHiddenFinalProp(t,this.name+"$value",n);var r=this;Object.defineProperty(t,this.name,{get:function(){return a.getMSTAdministration(this).assertAlive(),n.get},set:function(t){var e=a.getMSTAdministration(this);e.assertWritable();var i=n.identifier;n.setNewValue(t),n.identifier!==i&&e.emitPatch({op:"replace",path:a.escapeJsonPath(r.name),value:n.serialize},e)}}),t[this.name]=e[this.name]},e.prototype.serialize=function(t,e){e[this.name]=t[this.name+"$value"].serialize()},e.prototype.deserialize=function(t,e){t[this.name+"$value"].setNewValue(e[this.name])},e.prototype.validate=function(t,e){return this.name in t?u.typeCheckSuccess():u.typeCheckFailure(u.getContextForPath(e,this.name,this.type),void 0,"Reference is required.")},e}(i.Property);e.ReferenceProperty=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=n(8),a=n(5),s=n(2),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.type=n,r}return r(e,t),e.prototype.initializePrototype=function(t){i.observable.ref(t,this.name,{value:void 0})},e.prototype.initialize=function(t,e){t[this.name]=this.type.create(e[this.name])},e.prototype.willChange=function(t){var e=a.getMSTAdministration(t.object);return t.newValue=e.reconcileChildren(this.type,[t.object[t.name]],[t.newValue],[t.name])[0],t},e.prototype.didChange=function(t){var e=a.getMSTAdministration(t.object);e.emitPatch({op:"replace",path:a.escapeJsonPath(this.name),value:a.valueToSnapshot(t.newValue)},e)},e.prototype.serialize=function(t,e){e[this.name]=a.valueToSnapshot(t[this.name])},e.prototype.deserialize=function(t,e){var n=this;a.maybeMST(t[this.name],function(t){t.applySnapshot(e[n.name])},function(){t[n.name]=e[n.name]})},e.prototype.validate=function(t,e){return this.type.validate(t[this.name],s.getContextForPath(e,this.name,this.type))},e}(o.Property);e.ValueProperty=u},function(t,e,n){"use strict";function r(t,e){var n=function(){var t=this,n=arguments,r=s.getMSTAdministration(this);return r.assertAlive(),o.extras.allowStateChanges(!1,function(){return e.apply(t,n)})};return a.createNamedFunction(t,n)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),a=n(1),s=n(5),u=n(8),c=n(2),p=function(t){function e(e,n){var i=t.call(this,e)||this;return i.invokeView=r(e,n),i}return i(e,t),e.prototype.initialize=function(t){a.addHiddenFinalProp(t,this.name,this.invokeView.bind(t))},e.prototype.validate=function(t,e){return this.name in t?c.typeCheckFailure(c.getContextForPath(e,this.name),t[this.name],"View properties should not be provided in the snapshot"):c.typeCheckSuccess()},e}(u.Property);e.ViewProperty=p,e.createViewInvoker=r},function(t,e,n){"use strict";function r(t){return Object.freeze(t),s.isPlainObject(t)&&Object.keys(t).forEach(function(e){Object.isFrozen(t[e])||r(t[e])}),t}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(2),s=n(1),u=function(t){function e(){var e=t.call(this,"frozen")||this;return e.flags=o.TypeFlags.Frozen,e}return i(e,t),e.prototype.describe=function(){return"<any immutable value>"},e.prototype.create=function(t){return s.isSerializable(t)||s.fail("Given value should be serializable"),s.isMutable(t)?r(t):t},e.prototype.validate=function(t,e){return s.isSerializable(t)?a.typeCheckSuccess():a.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return null},enumerable:!0,configurable:!0}),e}(o.Type);e.Frozen=u,e.frozen=new u},function(t,e,n){"use strict";function r(t,e){var n="string"==typeof t?t:"<late>",r="string"==typeof t?e:t;return new s(n,r)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),a=n(3),s=function(t){function e(e,n){var r=t.call(this,e)||this;return r._subType=null,"function"==typeof n&&0===n.length||o.fail("Invalid late type, expected a function with zero arguments that returns a type, got: "+n),r.definition=n,r}return i(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.subType.flags},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),e.prototype.create=function(t,e){return this.subType.create(t,e)},e.prototype.describe=function(){return this.subType.name},e.prototype.validate=function(t,e){return this.subType.validate(t,e)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.subType.identifierAttribute},enumerable:!0,configurable:!0}),e}(a.Type);e.Late=s,e.late=r},function(t,e,n){"use strict";function r(t){return i.union(s,t)}Object.defineProperty(e,"__esModule",{value:!0});var i=n(19),o=n(17),a=n(13),s=a.optional(o.literal(null),null);e.maybe=r},function(t,e,n){"use strict";function r(t,e,n){var r=e.create();return n(s.isMST(r)?s.getMSTAdministration(r).snapshot:r)||a.fail("Default value for refinement type "+t+" does not pass the predicate."),new c(t,e,n)}var i=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(1),s=n(5),u=n(2),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.type=n,i.predicate=r,i}return i(e,t),Object.defineProperty(e.prototype,"flags",{get:function(){return this.type.flags},enumerable:!0,configurable:!0}),e.prototype.describe=function(){return this.name},e.prototype.create=function(t){var e=this.type.create(t),n=s.isMST(e)?s.getMSTAdministration(e).snapshot:e;return this.is(n)||a.fail("Value "+JSON.stringify(n)+" is not assignable to type "+this.name),e},e.prototype.validate=function(t,e){return this.type.is(t)&&this.predicate(t)?u.typeCheckSuccess():u.typeCheckFailure(e,t)},Object.defineProperty(e.prototype,"identifierAttribute",{get:function(){return this.type.identifierAttribute},enumerable:!0,configurable:!0}),e}(o.Type);e.Refinement=c,e.refinement=r}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("mobx")):"function"==typeof define&&define.amd?define(["mobx"],t):"object"==typeof exports?exports.mobxStateTree=t(require("mobx")):e.mobxStateTree=t(e.mobx)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),n(7),n(4);var o=n(23);t.types=o.types,r(n(6)),r(n(8));var i=n(3);t.isStateTreeNode=i.isStateTreeNode,t.getType=i.getType,t.getChildType=i.getChildType,t.onAction=i.onAction,t.applyAction=i.applyAction;var a=n(19);t.asReduxStore=a.asReduxStore,t.connectReduxDevtools=a.connectReduxDevtools},function(e,t){"use strict";function n(e){throw void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function r(e){return e}function o(){return null}function i(){}function a(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var o=t[r];for(var i in o)e[i]=o[i]}return e}function s(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var o=t[r];for(var i in o){var a=Object.getOwnPropertyDescriptor(o,i);"get"in a?Object.defineProperty(e,i,a):e[i]=o[i]}}return e}function u(e){if(null===e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function p(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function c(e){return null===e||void 0===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e instanceof Date}function l(e){return"function"!=typeof e}function f(e,t,n){Object.defineProperty(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function h(e,t,n){Object.defineProperty(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function d(e,t,n){Object.defineProperty(e,t,{enumerable:!0,writable:!1,configurable:!0,value:n})}function y(e,t){return e.push(t),function(){var n=e.indexOf(t);n!==-1&&e.splice(n,1)}}function v(e,t){return m.call(e,t)}function b(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function g(e,t){return new Function("f","return function "+e+"() { return f.apply(this, arguments)}")(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.EMPTY_ARRAY=Object.freeze([]),t.fail=n,t.identity=r,t.nothing=o,t.noop=i,t.extend=a,t.extendKeepGetter=s,t.isPlainObject=u,t.isMutable=p,t.isPrimitive=c,t.isSerializable=l,t.addHiddenFinalProp=f,t.addHiddenWritableProp=h,t.addReadOnlyProp=d,t.registerEventHandler=y;var m=Object.prototype.hasOwnProperty;t.hasOwnProperty=v,t.argsToArray=b,t.createNamedFunction=g},function(e,t,n){"use strict";function r(e){return"function"==typeof e?"<function"+(e.name?" "+e.name:"")+">":f.isStateTreeNode(e)?"<"+e+">":"`"+JSON.stringify(e)+"`"}function o(e){var t=e.value,n=e.context[e.context.length-1].type,o=e.context.map(function(e){var t=e.path;return t}).filter(function(e){return e.length>0}).join("/"),i=o.length>0?'at path "/'+o+'" ':"",a=f.isStateTreeNode(t)?"value of type "+f.getStateTreeNode(t).type.name+":":l.isPrimitive(t)?"value":"snapshot",s=n&&f.isStateTreeNode(t)&&n.is(f.getStateTreeNode(t).snapshot);return""+i+a+" "+r(t)+" is not assignable "+(n?"to type: `"+n.name+"`":"")+(e.message?" ("+e.message+")":"")+(n?h.isPrimitiveType(n)||n instanceof d.OptionalValue&&h.isPrimitiveType(n.type)?".":", expected an instance of `"+n.name+"` or a snapshot like `"+n.describe()+"` instead."+(s?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function i(e){return[{type:e,path:""}]}function a(e,t,n){return e.concat([{path:t,type:n}])}function s(){return l.EMPTY_ARRAY}function u(e,t,n){return[{context:e,value:t,message:n}]}function p(e){return e.reduce(function(e,t){return e.concat(t)},[])}function c(e,t){var n=e.validate(t,[{path:"",type:e}]);n.length>0&&l.fail("Error while converting "+r(t)+" to `"+e.name+"`:\n"+n.map(o).join("\n"))}Object.defineProperty(t,"__esModule",{value:!0}),t.prettyPrintValue=r,t.getDefaultContext=i,t.getContextForPath=a,t.typeCheckSuccess=s,t.typeCheckFailure=u,t.flattenTypeErrors=p,t.typecheck=c;var l=n(1),f=n(3),h=n(9),d=n(11)},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(7)),r(n(12)),r(n(8)),r(n(6))},function(e,t,n){"use strict";function r(e){return"object"==typeof e&&e&&e.isType===!0}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),i=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var a,s=n(5);!function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier"}(a=t.TypeFlags||(t.TypeFlags={})),t.isType=r;var u=function(){function e(e){this.isType=!0,this.name=e}return e.prototype.create=function(e,t){return void 0===e&&(e=this.getDefaultSnapshot()),f.typecheck(this,e),this.instantiate(null,"",t,e).getValue()},e.prototype.isAssignableFrom=function(e){return e===this},e.prototype.validate=function(e,t){return l.isStateTreeNode(e)?h.getType(e)===this||this.isAssignableFrom(h.getType(e))?f.typeCheckSuccess():f.typeCheckFailure(t,e):this.isValidSnapshot(e,t)},e.prototype.is=function(e){return 0===this.validate(e,[{path:"",type:this}]).length},e.prototype.reconcile=function(e,t){if(l.isStateTreeNode(t)&&l.getStateTreeNode(t)===e)return e;if(e.type===this&&c.isMutable(t)&&!l.isStateTreeNode(t)&&(!e.identifierAttribute||e.identifier===t[e.identifierAttribute]))return e.applySnapshot(t),e;if(e.die(),l.isStateTreeNode(t)&&this.isAssignableFrom(h.getType(t))){var n=l.getStateTreeNode(t);return n.setParent(e.parent,e.path),n}return this.instantiate(e.parent,e.path,e._environment,t)},Object.defineProperty(e.prototype,"Type",{get:function(){return c.fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){return c.fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!0,configurable:!0}),e}();i([s.action],u.prototype,"create",null),t.ComplexType=u;var p=function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.getValue=function(e){return e.storedValue},t.prototype.getSnapshot=function(e){return e.storedValue},t.prototype.getDefaultSnapshot=function(){},t.prototype.applySnapshot=function(e,t){c.fail("Immutable types do not support applying snapshots")},t.prototype.applyPatchLocally=function(e,t,n){c.fail("Immutable types do not support applying patches")},t.prototype.getChildren=function(e){return c.EMPTY_ARRAY},t.prototype.getChildNode=function(e,t){return c.fail("No child '"+t+"' available in type: "+this.name)},t.prototype.getChildType=function(e){return c.fail("No child '"+e+"' available in type: "+this.name)},t.prototype.reconcile=function(e,t){if(e.type===this&&e.storedValue===t)return e;var n=this.instantiate(e.parent,e.subpath,e._environment,t);return e.die(),n},t.prototype.removeChild=function(e,t){return c.fail("No child '"+t+"' available in type: "+this.name)},t}(u);t.Type=p;var c=n(1),l=n(7),f=n(2),h=n(6)},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return E.getStateTreeNode(e).type}function o(e,t){return E.getStateTreeNode(e).getChildType(t)}function i(e,t){var n=E.getStateTreeNode(e);return n.isProtectionEnabled||console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`"),n.addMiddleWare(t)}function a(e,t){return E.getStateTreeNode(e).onPatch(t)}function s(e,t){return E.getStateTreeNode(e).onSnapshot(t)}function u(e,t){return E.getStateTreeNode(e).applyPatch(t)}function p(e,t){var n=E.getStateTreeNode(e);I.runInAction(function(){t.forEach(function(e){return n.applyPatch(e)})})}function c(e){var t={patches:[],stop:function(){return n()},replay:function(e){p(e,t.patches)}},n=a(e,function(e){t.patches.push(e)});return t}function l(e,t){I.runInAction(function(){t.forEach(function(t){return M.applyAction(e,t)})})}function f(e){var t={actions:[],stop:function(){return n()},replay:function(e){l(e,t.actions)}},n=M.onAction(e,t.actions.push.bind(t.actions));return t}function h(e){E.getStateTreeNode(e).isProtectionEnabled=!0}function d(e){E.getStateTreeNode(e).isProtectionEnabled=!1}function y(e){return E.getStateTreeNode(e).isProtectionEnabled}function v(e,t){return E.getStateTreeNode(e).applySnapshot(t)}function b(e){return E.getStateTreeNode(e).snapshot}function g(e,t){void 0===t&&(t=1),t<0&&z.fail("Invalid depth: "+t+", should be >= 1");for(var n=E.getStateTreeNode(e).parent;n;){if(0===--t)return!0;n=n.parent}return!1}function m(e,t){void 0===t&&(t=1),t<0&&z.fail("Invalid depth: "+t+", should be >= 1");for(var n=t,r=E.getStateTreeNode(e).parent;r;){if(0===--n)return r.storedValue;r=r.parent}return z.fail("Failed to find the parent of "+E.getStateTreeNode(e)+" at depth "+t)}function _(e){return E.getStateTreeNode(e).root.storedValue}function P(e){return E.getStateTreeNode(e).path}function T(e){return D.splitJsonPath(E.getStateTreeNode(e).path)}function j(e){return E.getStateTreeNode(e).isRoot}function O(e,t){var n=E.getStateTreeNode(e).resolve(t);return n?n.getValue():void 0}function w(e,t,n){J.isType(e)||z.fail("Expected a type as first argument");var r=E.getStateTreeNode(t).root.identifierCache.resolve(e,""+n);return r?r.getValue():void 0}function S(e,t){var n=E.getStateTreeNode(e).resolve(t,!1);if(void 0!==n)return n?n.getValue():void 0}function N(e,t){return E.getStateTreeNode(e).getRelativePathTo(E.getStateTreeNode(t))}function C(e,t){void 0===t&&(t=!0);var n=E.getStateTreeNode(e);return n.type.create(n.snapshot,t===!0?n.root._environment:t===!1?void 0:t)}function A(e){return E.getStateTreeNode(e).detach(),e}function V(e){var t=E.getStateTreeNode(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function x(e){return E.getStateTreeNode(e).isAlive}function F(e,t){E.getStateTreeNode(e).addDisposer(t)}function k(e){var t=E.getStateTreeNode(e),n=t.root._environment;return n||z.fail("Node '"+t+"' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()"),n}function R(e,t){var n=E.getStateTreeNode(e);n.getChildren().forEach(function(e){E.isStateTreeNode(e.storedValue)&&R(e.storedValue,t)}),t(n.storedValue)}Object.defineProperty(t,"__esModule",{value:!0});var M=n(12),I=n(5),E=n(7),D=n(8),z=n(1),J=n(4);t.getType=r,t.getChildType=o,t.addMiddleware=i,t.onPatch=a,t.onSnapshot=s,t.applyPatch=u,t.applyPatches=p,t.recordPatches=c,t.applyActions=l,t.recordActions=f,t.protect=h,t.unprotect=d,t.isProtected=y,t.applySnapshot=v,t.getSnapshot=b,t.hasParent=g,t.getParent=m,t.getRoot=_,t.getPath=P,t.getPathParts=T,t.isRoot=j,t.resolvePath=O,t.resolveIdentifier=w,t.tryResolve=S,t.getRelativePath=N,t.clone=C,t.detach=A,t.destroy=V,t.isAlive=x,t.addDisposer=F,t.getEnv=k,t.walk=R},function(e,t,n){"use strict";function r(e){return!(!e||!e.$treenode)}function o(e){return r(e)?e.$treenode:y.fail("element has no Node")}function i(e){return e&&"object"==typeof e&&!r(e)&&!Object.isFrozen(e)}function a(){return o(this).snapshot}function s(e,t,n,s,u,p,c){if(void 0===p&&(p=y.identity),void 0===c&&(c=y.noop),r(u)){var f=o(u);return f.isRoot||y.fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(t?t.path:"")+"/"+n+"', but it lives already at '"+f.path+"'"),f.setParent(t,n),f}var h=p(u),d=i(h),b=new l(e,t,n,s,h);t||(b.identifierCache=new v.IdentifierCache),d&&y.addHiddenFinalProp(h,"$treenode",b);var g=!0;try{return d&&y.addReadOnlyProp(h,"toJSON",a),b.pseudoAction(function(){c(b,u)}),t?t.root.identifierCache.addNodeToCache(b):b.identifierCache.addNodeToCache(b),b.fireHook("afterCreate"),t&&b.fireHook("afterAttach"),g=!1,b}finally{g&&(b._isAlive=!1)}}var u=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var p=n(5),c=1,l=function(){function e(e,t,n,r,o){var i=this;this.nodeId=++c,this._parent=null,this.subpath="",this.isProtectionEnabled=!0,this.identifierAttribute=void 0,this._environment=void 0,this._isRunningAction=!1,this._autoUnbox=!0,this._isAlive=!0,this._isDetaching=!1,this.middlewares=[],this.snapshotSubscribers=[],this.patchSubscribers=[],this.disposers=[],this.type=e,this._parent=t,this.subpath=n,this.storedValue=o,this._environment=r,this.unbox=this.unbox.bind(this);var a=p.reaction(function(){return i.snapshot},function(e){i.emitSnapshot(e)});a.onError(function(e){throw e}),this.addDisposer(a)}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this.identifierAttribute?this.storedValue[this.identifierAttribute]:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.parent?this.parent.path+"/"+f.escapeJsonPath(this.subpath):""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){for(var e,t=this;e=t.parent;)t=e;return t},enumerable:!0,configurable:!0}),e.prototype.getRelativePathTo=function(e){this.root!==e.root&&y.fail("Cannot calculate relative path: objects '"+this+"' and '"+e+"' are not part of the same object tree");for(var t=f.splitJsonPath(this.path),n=f.splitJsonPath(e.path),r=0;r<t.length&&t[r]===n[r];r++);return t.slice(r).map(function(e){return".."}).join("/")+f.joinJsonPath(n.slice(r))},e.prototype.resolve=function(e,t){return void 0===t&&(t=!0),this.resolvePath(f.splitJsonPath(e),t)},e.prototype.resolvePath=function(e,t){void 0===t&&(t=!0);for(var n=this,r=0;r<e.length;r++){if(""===e[r])n=n.root;else if(".."===e[r])n=n.parent;else{if("."===e[r]||""===e[r])continue;if(n){n=n.getChildNode(e[r]);continue}}if(!n)return t?y.fail("Could not resolve '"+e[r]+"' in '"+f.joinJsonPath(e.slice(0,r-1))+"', path of the patch does not resolve"):void 0}return n},e.prototype.getValue=function(){return this.type.getValue(this)},Object.defineProperty(e.prototype,"isAlive",{get:function(){return this._isAlive},enumerable:!0,configurable:!0}),e.prototype.die=function(){this._isDetaching||r(this.storedValue)&&(d.walk(this.storedValue,function(e){return o(e).aboutToDie()}),d.walk(this.storedValue,function(e){return o(e).finalizeDeath()}))},e.prototype.aboutToDie=function(){this.disposers.splice(0).forEach(function(e){return e()}),this.fireHook("beforeDestroy")},e.prototype.finalizeDeath=function(){this.root.identifierCache.notifyDied(this);var e=this,t=this.path;y.addReadOnlyProp(this,"snapshot",this.snapshot),this.patchSubscribers.splice(0),this.snapshotSubscribers.splice(0),this.patchSubscribers.splice(0),this._isAlive=!1,this._parent=null,this.subpath="",Object.defineProperty(this.storedValue,"$mobx",{get:function(){y.fail("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '"+e.type.name+"') used to live at '"+t+"'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.")}})},e.prototype.assertAlive=function(){this._isAlive||y.fail(this+" cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value")},Object.defineProperty(e.prototype,"snapshot",{get:function(){if(this._isAlive)return Object.freeze(this.type.getSnapshot(this))},enumerable:!0,configurable:!0}),e.prototype.onSnapshot=function(e){return y.registerEventHandler(this.snapshotSubscribers,e)},e.prototype.applySnapshot=function(e){return h.typecheck(this.type,e),this.type.applySnapshot(this,e)},e.prototype.emitSnapshot=function(e){this.snapshotSubscribers.forEach(function(t){return t(e)})},e.prototype.applyPatch=function(e){var t=f.splitJsonPath(e.path),n=this.resolvePath(t.slice(0,-1));n.pseudoAction(function(){n.applyPatchLocally(t[t.length-1],e)})},e.prototype.applyPatchLocally=function(e,t){this.assertWritable(),this.type.applyPatchLocally(this,e,t)},e.prototype.onPatch=function(e){return y.registerEventHandler(this.patchSubscribers,e)},e.prototype.emitPatch=function(e,t){if(this.patchSubscribers.length){var n=y.extend({},e,{path:t.path.substr(this.path.length)+"/"+e.path});this.patchSubscribers.forEach(function(e){return e(n)})}this.parent&&this.parent.emitPatch(e,t)},e.prototype.setParent=function(e,t){void 0===t&&(t=null),this.parent===e&&this.subpath===t||(this._parent&&e&&e!==this._parent&&y.fail("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+e.path+"/"+t+"'."),!this._parent&&e&&e.root===this&&y.fail("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+e.path+"/"+t+"'"),!this._parent&&this._environment&&y.fail("A state tree that has been initialized with an environment cannot be made part of another state tree."),this.parent&&!e?this.die():(this.subpath=t||"",e&&e!==this._parent&&(e.root.identifierCache.mergeCache(this),this._parent=e,this.fireHook("afterAttach"))))},e.prototype.addDisposer=function(e){this.disposers.unshift(e)},e.prototype.reconcileChildren=function(e,t,n,i,a){function s(e){for(var t in l){var n=e[t];if(("string"==typeof n||"number"==typeof n)&&l[t][n])return l[t][n]}return null}var u=this,p=new Array(i.length),c={},l={};n.forEach(function(e){e.identifierAttribute&&((l[e.identifierAttribute]||(l[e.identifierAttribute]={}))[e.identifier]=e),c[e.nodeId]=e}),i.forEach(function(n,i){var l=""+a[i];if(r(n)){var f=o(n);f.assertAlive(),f.parent===e?(c[f.nodeId]||y.fail("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+l+"', but it lives already at '"+f.path+"'"),c[f.nodeId]=void 0,f.setParent(e,l),p[i]=f):p[i]=t.instantiate(u,l,void 0,n)}else if(y.isMutable(n)){var h=s(n);if(h){var f=t.reconcile(h,n);c[h.nodeId]=void 0,f.setParent(u,l),p[i]=f}else p[i]=t.instantiate(u,l,void 0,n)}else p[i]=t.instantiate(u,l,void 0,n)});for(var f in c)void 0!==c[f]&&c[f].die();return p},e.prototype.isRunningAction=function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()},e.prototype.addMiddleWare=function(e){return y.registerEventHandler(this.middlewares,e)},e.prototype.getChildNode=function(e){this.assertAlive(),this._autoUnbox=!1;var t=this.type.getChildNode(this,e);return this._autoUnbox=!0,t},e.prototype.getChildren=function(){this.assertAlive(),this._autoUnbox=!1;var e=this.type.getChildren(this);return this._autoUnbox=!0,e},e.prototype.getChildType=function(e){return this.type.getChildType(e)},Object.defineProperty(e.prototype,"isProtected",{get:function(){for(var e=this;e;){if(e.isProtectionEnabled===!1)return!1;e=e.parent}return!0},enumerable:!0,configurable:!0}),e.prototype.pseudoAction=function(e){var t=this._isRunningAction;this._isRunningAction=!0,e(),this._isRunningAction=t},e.prototype.assertWritable=function(){this.assertAlive(),!this.isRunningAction()&&this.isProtected&&y.fail("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")},e.prototype.removeChild=function(e){this.type.removeChild(this,e)},e.prototype.detach=function(){this._isAlive||y.fail("Error while detaching, node is not alive."),this.isRoot||(this.fireHook("beforeDetach"),this._environment=this.root._environment,this._isDetaching=!0,this.identifierCache=this.root.identifierCache.splitCache(this),this.parent.removeChild(this.subpath),this._parent=null,this.subpath="",this._isDetaching=!1)},e.prototype.unbox=function(e){return this._autoUnbox===!0?e.getValue():e},e.prototype.fireHook=function(e){var t=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof t&&t.apply(this.storedValue)},e.prototype.toString=function(){var e=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+(this.path||"<root>")+e+(this.isAlive?"":"[dead]")},e}();u([p.observable],l.prototype,"_parent",void 0),u([p.observable],l.prototype,"subpath",void 0),u([p.computed],l.prototype,"path",null),u([p.computed],l.prototype,"snapshot",null),u([p.action],l.prototype,"applyPatch",null),t.Node=l,t.isStateTreeNode=r,t.getStateTreeNode=o,t.createNode=s;var f=n(8),h=n(2),d=n(6),y=n(1),v=n(18)},function(e,t){"use strict";function n(e){return e.replace(/~/g,"~1").replace(/\//g,"~0")}function r(e){return e.replace(/~0/g,"\\").replace(/~1/g,"~")}function o(e){return 0===e.length?"":"/"+e.map(n).join("/")}function i(e){var t=e.split("/").map(r);return""===t[0]?t.slice(1):t}Object.defineProperty(t,"__esModule",{value:!0}),t.escapeJsonPath=n,t.unescapeJsonPath=r,t.joinJsonPath=o,t.splitJsonPath=i},function(e,t,n){"use strict";function r(e){switch(typeof e){case"string":return t.string;case"number":return t.number;case"boolean":return t.boolean;case"object":if(e instanceof Date)return t.DatePrimitive}return u.fail("Cannot determine primtive type from value "+e)}function o(e){return(e.flags&(a.TypeFlags.String|a.TypeFlags.Number|a.TypeFlags.Boolean|a.TypeFlags.Date))>0}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var a=n(4),s=n(2),u=n(1),p=n(3),c=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.flags=n,o.checker=r,o}return i(t,e),t.prototype.describe=function(){return this.name},t.prototype.instantiate=function(e,t,n,r){return p.createNode(this,e,t,n,r)},t.prototype.isValidSnapshot=function(e,t){return u.isPrimitive(e)&&this.checker(e)?s.typeCheckSuccess():s.typeCheckFailure(t,e)},t}(a.Type);t.CoreType=c,t.string=new c("string",a.TypeFlags.String,function(e){return"string"==typeof e}),t.number=new c("number",a.TypeFlags.Number,function(e){return"number"==typeof e}),t.boolean=new c("boolean",a.TypeFlags.Boolean,function(e){return"boolean"==typeof e}),t.DatePrimitive=new c("Date",a.TypeFlags.Date,function(e){return e instanceof Date}),t.DatePrimitive.getSnapshot=function(e){return e.storedValue.getTime()},t.getPrimitiveFactoryFromValue=r,t.isPrimitiveType=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.name=e}return e.prototype.initializePrototype=function(e){},e.prototype.initialize=function(e,t){},e.prototype.willChange=function(e){return null},e.prototype.didChange=function(e){},e.prototype.serialize=function(e,t){},e.prototype.deserialize=function(e,t){},e}();t.Property=n},function(e,t,n){"use strict";function r(e,t){var n="function"==typeof t?t():t,r=s.isStateTreeNode(n)?s.getStateTreeNode(n).snapshot:n;return a.typecheck(e,r),new u(e,t)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),a=n(2),s=n(3),u=function(e){function t(t,n){var r=e.call(this,t.name)||this;return r.type=t,r.defaultValue=n,r}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this.type.flags|i.TypeFlags.Optional},enumerable:!0,configurable:!0}),t.prototype.describe=function(){return this.type.describe()+"?"},t.prototype.instantiate=function(e,t,n,r){if("undefined"==typeof r){var o=this.getDefaultValue(),i=s.isStateTreeNode(o)?s.getStateTreeNode(o).snapshot:o;return this.type.instantiate(e,t,n,i)}return this.type.instantiate(e,t,n,r)},t.prototype.reconcile=function(e,t){return this.type.reconcile(e,this.type.is(t)?t:this.getDefaultValue())},t.prototype.getDefaultValue=function(){var e="function"==typeof this.defaultValue?this.defaultValue():this.defaultValue;return"function"==typeof this.defaultValue&&a.typecheck(this,e),e},t.prototype.isValidSnapshot=function(e,t){return void 0===e||this.type.is(e)?a.typeCheckSuccess():a.typeCheckFailure(t,e)},t}(i.Type);t.OptionalValue=u,t.optional=r},function(e,t,n){"use strict";function r(e){return e.object[e.name].apply(e.object,e.args)}function o(e){for(var t=e.middlewares.slice(),n=e;n.parent;)n=n.parent,t=t.concat(n.middlewares);return t}function i(e,t){function n(e){var t=i.shift();return t?t(e,n):r(e)}var i=o(e);return i.length?n(t):r(t)}function a(e,t){var n=l.action(e,t),r=function(){var t=f.getStateTreeNode(this);if(t.assertAlive(),t.isRunningAction())return n.apply(this,arguments);var r={name:e,object:t.storedValue,args:d.argsToArray(arguments)},o=t.root;o._isRunningAction=!0;try{return i(t,r)}finally{o._isRunningAction=!1}};return d.createNamedFunction(e,r)}function s(e,t,n,r){if(d.isPrimitive(r))return r;if(f.isStateTreeNode(r)){var o=f.getStateTreeNode(r);if(e.root!==o.root)throw new Error("Argument "+n+" that was passed to action '"+t+"' is a model that is not part of the same state tree. Consider passing a snapshot or some representative ID instead");return{$ref:e.getRelativePathTo(f.getStateTreeNode(r))}}if("function"==typeof r)throw new Error("Argument "+n+" that was passed to action '"+t+"' should be a primitive, model object or plain object, received a function");if("object"==typeof r&&!d.isPlainObject(r)&&!Array.isArray(r))throw new Error("Argument "+n+" that was passed to action '"+t+"' should be a primitive, model object or plain object, received a "+(r&&r.constructor?r.constructor.name:"Complex Object"));if(l.isObservable(r))throw new Error("Argument "+n+" that was passed to action '"+t+"' should be a primitive, model object or plain object, received an mobx observable.");try{return JSON.stringify(r),r}catch(e){throw new Error("Argument "+n+" that was passed to action '"+t+"' is not serializable.")}}function u(e,t){if("object"==typeof t){var n=Object.keys(t);if(1===n.length&&"$ref"===n[0])return h.resolvePath(e.storedValue,t.$ref)}return t}function p(e,t){var n=h.tryResolve(e,t.path||"");if(!n)return d.fail("Invalid action path: "+(t.path||""));var r=f.getStateTreeNode(n);return"function"!=typeof n[t.name]&&d.fail("Action '"+t.name+"' does not exist in '"+r.path+"'"),n[t.name].apply(n,t.args?t.args.map(function(e){return u(r,e)}):[])}function c(e,t){return h.addMiddleware(e,function(n,r){var o=f.getStateTreeNode(n.object);return t({name:n.name,path:f.getStateTreeNode(e).getRelativePathTo(o),args:n.args.map(function(e,t){return s(o,n.name,t,e)})}),r(n)})}Object.defineProperty(t,"__esModule",{value:!0});var l=n(5);t.createActionInvoker=a,t.applyAction=p,t.onAction=c;var f=n(7),h=n(6),d=n(1)},function(e,t,n){"use strict";function r(e){return a.isPrimitive(e)||a.fail("Literal types can be built only on top of primitives"),new p(e)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),a=n(1),s=n(2),u=n(3),p=function(e){function t(t){var n=e.call(this,""+t)||this;return n.flags=i.TypeFlags.Literal,n.value=t,n}return o(t,e),t.prototype.instantiate=function(e,t,n,r){return u.createNode(this,e,t,n,r)},t.prototype.describe=function(){return JSON.stringify(this.value)},t.prototype.isValidSnapshot=function(e,t){return a.isPrimitive(e)&&e===this.value?s.typeCheckSuccess():s.typeCheckFailure(t,e)},t}(i.Type);t.Literal=p,t.literal=r},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),i=n(10),a=n(3),s=n(2),u=n(1),p=n(13),c=p.literal(void 0),l=function(e){function t(t,n){var r=e.call(this,t)||this;return r.type=n,r}return r(t,e),t.prototype.initializePrototype=function(e){o.observable.ref(e,this.name,{value:c.instantiate(null,"",null,void 0)})},t.prototype.initialize=function(e,t){var n=a.getStateTreeNode(e);e[this.name]=this.type.instantiate(n,this.name,n._environment,t[this.name]),o.extras.interceptReads(e,this.name,n.unbox)},t.prototype.getValueNode=function(e){var t=e.$mobx.values[this.name].value;return t?t:u.fail("Node not available for property "+this.name)},t.prototype.willChange=function(e){var t=a.getStateTreeNode(e.object);return s.typecheck(this.type,e.newValue),e.newValue=this.type.reconcile(t.getChildNode(e.name),e.newValue),e},t.prototype.didChange=function(e){var t=a.getStateTreeNode(e.object);t.emitPatch({op:"replace",path:a.escapeJsonPath(this.name),value:this.getValueNode(e.object).snapshot},t)},t.prototype.serialize=function(e,t){o.extras.getAtom(e,this.name).reportObserved(),t[this.name]=this.getValueNode(e).snapshot},t.prototype.deserialize=function(e,t){e[this.name]=t[this.name]},t.prototype.validate=function(e,t){return this.type.validate(e[this.name],s.getContextForPath(t,this.name,this.type))},t}(i.Property);t.ValueProperty=l},function(e,t,n){"use strict";function r(e){return void 0===e&&(e=c.string),e!==c.string&&e!==c.number&&u.fail("Only 'types.number' and 'types.string' are acceptable as type specification for identifiers"),new f(e)}function o(e){return!(e instanceof l.Late)&&(e.flags&a.TypeFlags.Identifier)>0}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0
});var a=n(4),s=n(2),u=n(1),p=n(3),c=n(9),l=n(16),f=(function(){function e(e){this.identifier=e}return e.prototype.toString=function(){return"identifier("+this.identifier+")"},e}(),function(e){function t(t){var n=e.call(this,"identifier("+t.name+")")||this;return n.identifierType=t,n.flags=a.TypeFlags.Identifier,n}return i(t,e),t.prototype.instantiate=function(e,t,n,r){return s.typecheck(this.identifierType,r),e&&!p.isStateTreeNode(e.storedValue)&&u.fail("Identifier types can only be instantiated as direct child of a model type"),p.createNode(this,e,t,n,r)},t.prototype.reconcile=function(e,t){return e.storedValue!==t?u.fail("Tried to change identifier from '"+e.storedValue+"' to '"+t+"'. Changing identifiers is not allowed."):e},t.prototype.describe=function(){return"identifier("+this.identifierType.describe()+")"},t.prototype.isValidSnapshot=function(e,t){return this.identifierType.is(e)?s.typeCheckSuccess():s.typeCheckFailure(t,e)},t}(a.Type));t.IdentifierType=f,t.identifier=r,t.isIdentifierType=o},function(e,t,n){"use strict";function r(e,t){var n="string"==typeof e?e:"<late>",r="string"==typeof e?t:e;return new s(n,r)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),a=n(4),s=function(e){function t(t,n){var r=e.call(this,t)||this;return r._subType=null,"function"==typeof n&&0===n.length||i.fail("Invalid late type, expected a function with zero arguments that returns a type, got: "+n),r.definition=n,r}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this.subType.flags},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subType",{get:function(){return null===this._subType&&(this._subType=this.definition()),this._subType},enumerable:!0,configurable:!0}),t.prototype.instantiate=function(e,t,n,r){return this.subType.instantiate(e,t,n,r)},t.prototype.reconcile=function(e,t){return this.subType.reconcile(e,t)},t.prototype.describe=function(){return this.subType.name},t.prototype.isValidSnapshot=function(e,t){return this.subType.validate(e,t)},t.prototype.isAssignableFrom=function(e){return this.subType.isAssignableFrom(e)},t}(a.Type);t.Late=s,t.late=r},function(e,t,n){"use strict";function r(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=i.isType(e)?null:e,o=i.isType(e)?t.concat(e):t,a=o.map(function(e){return e.name}).join(" | ");return new u(a,o,r)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),a=n(2),s=n(1),u=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.dispatcher=null,o.dispatcher=r,o.types=n,o}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=0;return this.types.forEach(function(t){e|=t.flags}),e},enumerable:!0,configurable:!0}),t.prototype.isAssignableFrom=function(e){return this.types.some(function(t){return t.isAssignableFrom(e)})},t.prototype.describe=function(){return"("+this.types.map(function(e){return e.describe()}).join(" | ")+")"},t.prototype.instantiate=function(e,t,n,r){return this.determineType(r).instantiate(e,t,n,r)},t.prototype.reconcile=function(e,t){return this.determineType(t).reconcile(e,t)},t.prototype.determineType=function(e){if(null!==this.dispatcher)return this.dispatcher(e);var t=this.types.filter(function(t){return t.is(e)});return t.length>1?s.fail("Ambiguos snapshot "+JSON.stringify(e)+" for union "+this.name+". Please provide a dispatch in the union declaration."):t[0]},t.prototype.isValidSnapshot=function(e,t){if(null!==this.dispatcher)return this.dispatcher(e).validate(e,t);var n=this.types.map(function(n){return n.validate(e,t)}),r=n.filter(function(e){return 0===e.length});return r.length>1?a.typeCheckFailure(t,e,"Multiple types are applicable and no dispatch method is defined for the union"):r.length<1?a.typeCheckFailure(t,e,"No type is applicable and no dispatch method is defined for the union").concat(a.flattenTypeErrors(n)):a.typeCheckSuccess()},t}(i.Type);t.Union=u,t.union=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=n(5),i=function(){function e(){this.cache=o.observable.map()}return e.prototype.addNodeToCache=function(e){if(e.identifierAttribute){var t=e.identifier;this.cache.has(t)||this.cache.set(t,o.observable.shallowArray());var n=this.cache.get(t);n.indexOf(e)!==-1&&r.fail("Already registered"),n.push(e)}return this},e.prototype.mergeCache=function(e){var t=this;e.identifierCache.cache.values().forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})},e.prototype.notifyDied=function(e){if(e.identifierAttribute){var t=this.cache.get(e.identifier);t&&t.remove(e)}},e.prototype.splitCache=function(t){var n=new e,r=t.path;return this.cache.values().forEach(function(e){for(var t=e.length-1;t>=0;t--)0===e[t].path.indexOf(r)&&(n.addNodeToCache(e[t]),e.splice(t,1))}),n},e.prototype.resolve=function(e,t){var n=this.cache.get(t);if(!n)return null;var o=n.filter(function(t){return e.isAssignableFrom(t.type)});switch(o.length){case 0:return null;case 1:return o[0];default:return r.fail("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+o.map(function(e){return e.path}).join(", "))}},e}();t.IdentifierCache=i},function(e,t,n){"use strict";function r(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.isStateTreeNode(e)||c.fail("Expected model object");var r={getState:function(){return u.getSnapshot(e)},dispatch:function(t){i(t,a.slice(),function(t){return p.applyAction(e,o(t))})},subscribe:function(t){return u.onSnapshot(e,t)}},a=t.map(function(e){return e(r)});return r}function o(e){var t=c.extend({},e);return delete t.type,{name:e.type,args:[t]}}function i(e,t,n){function r(e){var o=t.shift();o?o(r)(e):n(e)}r(e)}function a(e,t){var n=e.connectViaExtension(),r=!1;n.subscribe(function(n){var o=e.extractState(n);o&&(r=!0,u.applySnapshot(t,o),r=!1)}),p.onAction(t,function(e){if(!r){var o={};o.type=e.name,e.args&&e.args.forEach(function(e,t){return o[t]=e}),n.send(o,u.getSnapshot(t))}})}Object.defineProperty(t,"__esModule",{value:!0});var s=n(3),u=n(6),p=n(12),c=n(1);t.asReduxStore=r,t.connectReduxDevtools=a},function(e,t,n){"use strict";function r(){return p.getStateTreeNode(this)+"("+this.length+" items)"}function o(e){return new h(e.name+"[]",e)}function i(e){return l.isType(e)&&(e.flags&l.TypeFlags.Array)>0}var a=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),s=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var u=n(5),p=n(3),c=n(1),l=n(4),f=n(2);t.arrayToString=r;var h=function(e){function t(t,n){var o=e.call(this,t)||this;return o.shouldAttachNode=!0,o.flags=l.TypeFlags.Array,o.createNewInstance=function(){var e=u.observable.shallowArray();return c.addHiddenFinalProp(e,"toString",r),e},o.finalizeNewInstance=function(e,t){var n=e.storedValue;u.extras.getAdministration(n).dehancer=e.unbox,u.intercept(n,function(e){return o.willChange(e)}),u.observe(n,o.didChange),e.applySnapshot(t)},o.subType=n,o}return a(t,e),t.prototype.describe=function(){return this.subType.describe()+"[]"},t.prototype.instantiate=function(e,t,n,r){return p.createNode(this,e,t,n,r,this.createNewInstance,this.finalizeNewInstance)},t.prototype.getChildren=function(e){return e.storedValue.peek()},t.prototype.getChildNode=function(e,t){var n=parseInt(t,10);return n<e.storedValue.length?e.storedValue[n]:c.fail("Not a child: "+t)},t.prototype.willChange=function(e){var t=p.getStateTreeNode(e.object);t.assertWritable();var n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;e.newValue=t.reconcileChildren(t,this.subType,[n[e.index]],[e.newValue],[e.index])[0];break;case"splice":var r=e.index,o=e.removedCount,i=e.added;e.added=t.reconcileChildren(t,this.subType,n.slice(r,r+o),i,i.map(function(e,t){return r+t}));for(var a=r+o;a<n.length;a++)n[a].setParent(t,""+(a+i.length-o))}return e},t.prototype.getValue=function(e){return e.storedValue},t.prototype.getSnapshot=function(e){return e.getChildren().map(function(e){return e.snapshot})},t.prototype.didChange=function(e){var t=p.getStateTreeNode(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:t.getChildNode(""+e.index).snapshot},t);case"splice":for(var n=e.index+e.removedCount-1;n>=e.index;n--)t.emitPatch({op:"remove",path:""+n},t);for(var n=0;n<e.addedCount;n++)t.emitPatch({op:"add",path:""+(e.index+n),value:t.getChildNode(""+(e.index+n)).snapshot},t);return}},t.prototype.applyPatchLocally=function(e,t,n){var r=e.storedValue,o="-"===t?r.length:parseInt(t);switch(n.op){case"replace":r[o]=n.value;break;case"add":r.splice(o,0,n.value);break;case"remove":r.splice(o,1)}},t.prototype.applySnapshot=function(e,t){e.pseudoAction(function(){var n=e.storedValue;n.replace(t)})},t.prototype.getChildType=function(e){return this.subType},t.prototype.isValidSnapshot=function(e,t){var n=this;return Array.isArray(e)?f.flattenTypeErrors(e.map(function(e,r){return n.subType.validate(e,f.getContextForPath(t,""+r,n.subType))})):f.typeCheckFailure(t,e)},t.prototype.getDefaultSnapshot=function(){return[]},t.prototype.removeChild=function(e,t){e.storedValue.splice(parseInt(t,10),1)},t}(l.ComplexType);s([u.action],h.prototype,"applySnapshot",null),t.ArrayType=h,t.array=o,t.isArrayFactory=i},function(e,t,n){"use strict";function r(){return c.getStateTreeNode(this)+"("+this.size+" items)"}function o(e){e||l.fail("Map.put cannot be used to set empty values");var t;if(c.isStateTreeNode(e))t=c.getStateTreeNode(e);else{if(!l.isMutable(e))return l.fail("Map.put can only be used to store complex values");var n=c.getStateTreeNode(this).type.subType;t=c.getStateTreeNode(n.create(e))}return t.identifierAttribute||l.fail("Map.put can only be used to store complex values that have an identifier type attribute"),this.set(t.identifier,t.getValue()),this}function i(e){return new d("map<string, "+e.name+">",e)}function a(e){return f.isType(e)&&(e.flags&f.TypeFlags.Map)>0}var s=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),u=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var p=n(5),c=n(3),l=n(1),f=n(4),h=n(2);t.mapToString=r;var d=function(e){function t(t,n){var i=e.call(this,t)||this;return i.shouldAttachNode=!0,i.flags=f.TypeFlags.Map,i.createNewInstance=function(){var e=p.observable.shallowMap();return l.addHiddenFinalProp(e,"put",o),l.addHiddenFinalProp(e,"toString",r),e},i.finalizeNewInstance=function(e,t){var n=e.storedValue;p.extras.interceptReads(n,e.unbox),p.intercept(n,function(e){return i.willChange(e)}),p.observe(n,i.didChange),e.applySnapshot(t)},i.subType=n,i}return s(t,e),t.prototype.instantiate=function(e,t,n,r){return c.createNode(this,e,t,n,r,this.createNewInstance,this.finalizeNewInstance)},t.prototype.describe=function(){return"Map<string, "+this.subType.describe()+">"},t.prototype.getChildren=function(e){return e.storedValue.values()},t.prototype.getChildNode=function(e,t){var n=e.storedValue.get(t);return n||l.fail("Not a child"+t),n},t.prototype.willChange=function(e){var t=c.getStateTreeNode(e.object);switch(t.assertWritable(),e.type){case"update":var n=e.newValue,r=e.object.get(e.name);if(n===r)return null;e.newValue=this.subType.reconcile(t.getChildNode(e.name),e.newValue),this.verifyIdentifier(e.name,e.newValue);break;case"add":e.newValue=this.subType.instantiate(t,e.name,void 0,e.newValue),this.verifyIdentifier(e.name,e.newValue);break;case"delete":t.getChildNode(e.name).die()}return e},t.prototype.verifyIdentifier=function(e,t){var n=t.identifier;null!==n&&n!==e&&l.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+n+"', but expected: '"+e+"'")},t.prototype.getValue=function(e){return e.storedValue},t.prototype.getSnapshot=function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t},t.prototype.didChange=function(e){var t=c.getStateTreeNode(e.object);switch(e.type){case"update":case"add":return void t.emitPatch({op:"add"===e.type?"add":"replace",path:c.escapeJsonPath(e.name),value:t.getChildNode(e.name).snapshot},t);case"delete":return void t.emitPatch({op:"remove",path:c.escapeJsonPath(e.name)},t)}},t.prototype.applyPatchLocally=function(e,t,n){var r=e.storedValue;switch(n.op){case"add":case"replace":r.set(t,n.value);break;case"remove":r.delete(t)}},t.prototype.applySnapshot=function(e,t){e.pseudoAction(function(){var n=e.storedValue,r={};n.keys().forEach(function(e){r[e]=!1}),Object.keys(t).forEach(function(e){n.set(e,t[e]),r[e]=!0}),Object.keys(r).forEach(function(e){r[e]===!1&&n.delete(e)})})},t.prototype.getChildType=function(e){return this.subType},t.prototype.isValidSnapshot=function(e,t){var n=this;return l.isPlainObject(e)?h.flattenTypeErrors(Object.keys(e).map(function(r){return n.subType.validate(e[r],h.getContextForPath(t,r,n.subType))})):h.typeCheckFailure(t,e)},t.prototype.getDefaultSnapshot=function(){return{}},t.prototype.removeChild=function(e,t){e.storedValue.delete(t)},t}(f.ComplexType);u([p.action],d.prototype,"applySnapshot",null),t.MapType=d,t.map=i,t.isMapFactory=a},function(e,t,n){"use strict";function r(){return d.getStateTreeNode(this).toString()}function o(e,t,n){var r="string"==typeof e?e:"AnonymousModel",o="string"==typeof e?t:e,i="string"==typeof e?n:t;return new O(r,o,i||{})}function i(e){var t=h.isType(e)?e:d.getType(e);return u(t)?t.baseModel:{}}function a(e){var t=h.isType(e)?e:d.getType(e);return u(t)?t.baseActions:{}}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn("[mobx-state-tree] `extend` is an experimental feature and it's behavior will probably change in the future");var n="string"==typeof e[0]?e.slice(1):e,r="string"==typeof e[0]?e[0]:n.map(function(e){return e.name}).join("_"),s=f.extendKeepGetter.apply(null,[{}].concat(n.map(i))),u=f.extend.apply(null,[{}].concat(n.map(a)));return o(r,s,u)}function u(e){return h.isType(e)&&(e.flags&h.TypeFlags.Object)>0}var p=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),c=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var l=n(5),f=n(1),h=n(4),d=n(3),y=n(2),v=n(9),b=n(15),g=n(11),m=n(26),_=n(25),P=n(14),T=n(24),j=n(27),O=function(e){function t(t,n,o){var i=e.call(this,t)||this;return i.shouldAttachNode=!0,i.flags=h.TypeFlags.Object,i.props={},i.createNewInstance=function(){var e=new i.modelConstructor;return l.extendShallowObservable(e,{}),e},i.finalizeNewInstance=function(e,t){var n=e.storedValue;i.forAllProps(function(e){return e.initialize(n,t)}),l.intercept(n,function(e){return i.willChange(e)}),l.observe(n,i.didChange)},i.didChange=function(e){i.props[e.name].didChange(e)},Object.freeze(n),Object.freeze(o),i.baseModel=n,i.baseActions=o,/^\w[\w\d_]*$/.test(t)||f.fail("Typename should be a valid identifier: "+t),i.modelConstructor=new Function("return function "+t+" (){}")(),i.modelConstructor.prototype.toString=r,i.parseModelProps(),i.forAllProps(function(e){return e.initializePrototype(i.modelConstructor.prototype)}),i}return p(t,e),t.prototype.instantiate=function(e,t,n,r){return d.createNode(this,e,t,n,r,this.createNewInstance,this.finalizeNewInstance)},t.prototype.willChange=function(e){var t=d.getStateTreeNode(e.object);return t.assertWritable(),this.props[e.name].willChange(e)},t.prototype.parseModelProps=function(){var e=this,t=e.baseModel,n=e.baseActions,r=null;for(var o in t)if(f.hasOwnProperty(t,o)){var i=Object.getOwnPropertyDescriptor(t,o);if("get"in i){this.props[o]=new _.ComputedProperty(o,i.get,i.set);continue}var a=i.value;if(null===a)f.fail("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");else if(f.isPrimitive(a)){var s=v.getPrimitiveFactoryFromValue(a);this.props[o]=new P.ValueProperty(o,g.optional(s,a))}else b.isIdentifierType(a)?(null!==r&&f.fail("Cannot define property '"+o+"' as object identifier, property '"+r+"' is already defined as identifier property"),r=o,this.props[o]=new m.IdentifierProperty(o,a)):h.isType(a)?this.props[o]=new P.ValueProperty(o,a):"function"==typeof a?this.props[o]=new j.ViewProperty(o,a):"object"==typeof a?f.fail("In property '"+o+"': base model's should not contain complex values: '"+a+"'"):f.fail("Unexpected value for property '"+o+"'")}for(var o in n)if(f.hasOwnProperty(n,o)){var a=n[o];o in this.baseModel&&f.fail("Property '"+o+"' was also defined as action. Actions and properties should not collide"),"function"==typeof a?this.props[o]=new T.ActionProperty(o,a):f.fail("Unexpected value for action '"+o+"'. Expected function, got "+typeof a)}},t.prototype.getChildren=function(e){var t=[];return this.forAllProps(function(n){n instanceof P.ValueProperty&&t.push(n.getValueNode(e.storedValue))}),t},t.prototype.getChildNode=function(e,t){return this.props[t]instanceof P.ValueProperty?this.props[t].getValueNode(e.storedValue):f.fail("Not a value property: "+t)},t.prototype.getValue=function(e){return e.storedValue},t.prototype.getSnapshot=function(e){var t={};return this.forAllProps(function(n){return n.serialize(e.storedValue,t)}),t},t.prototype.applyPatchLocally=function(e,t,n){"replace"!==n.op&&"add"!==n.op&&f.fail("object does not support operation "+n.op),e.storedValue[t]=n.value},t.prototype.applySnapshot=function(e,t){var n=this;e.pseudoAction(function(){for(var r in n.props)n.props[r].deserialize(e.storedValue,t)})},t.prototype.getChildType=function(e){return this.props[e].type},t.prototype.isValidSnapshot=function(e,t){var n=this;return f.isPlainObject(e)?y.flattenTypeErrors(Object.keys(this.props).map(function(r){return n.props[r].validate(e,t)})):y.typeCheckFailure(t,e)},t.prototype.forAllProps=function(e){var t=this;Object.keys(this.props).forEach(function(n){return e(t.props[n])})},t.prototype.describe=function(){var e=this;return"{ "+Object.keys(this.props).map(function(t){var n=e.props[t];return n instanceof P.ValueProperty?t+": "+n.type.describe():n instanceof m.IdentifierProperty?t+": identifier":""}).filter(Boolean).join("; ")+" }"},t.prototype.getDefaultSnapshot=function(){return{}},t.prototype.removeChild=function(e,t){e.storedValue[t]=null},t}(h.ComplexType);c([l.action],O.prototype,"applySnapshot",null),t.ObjectType=O,t.model=o,t.extend=s,t.isObjectFactory=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(21),o=n(20),i=n(15),a=n(22),s=n(30),u=n(17),p=n(11),c=n(13),l=n(29),f=n(31),h=n(28),d=n(9),y=n(16);t.types={model:a.model,extend:a.extend,reference:s.reference,union:u.union,optional:p.optional,literal:c.literal,maybe:l.maybe,refinement:f.refinement,string:d.string,boolean:d.boolean,number:d.number,Date:d.DatePrimitive,map:r.map,array:o.array,frozen:h.frozen,identifier:i.identifier,late:y.late}},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(3),a=n(10),s=n(2),u=function(e){function t(t,n){var r=e.call(this,t)||this;return r.invokeAction=i.createActionInvoker(t,n),r}return r(t,e),t.prototype.initialize=function(e){o.addHiddenFinalProp(e,this.name,this.invokeAction.bind(e))},t.prototype.validate=function(e,t){return this.name in e?s.typeCheckFailure(s.getContextForPath(t,this.name),e[this.name],"Action properties should not be provided in the snapshot"):s.typeCheckSuccess()},t}(a.Property);t.ActionProperty=u},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(5),i=n(10),a=n(2),s=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.getter=n,o.setter=r,o}return r(t,e),t.prototype.initializePrototype=function(e){Object.defineProperty(e,this.name,o.computed(e,this.name,{get:this.getter,set:this.setter,configurable:!0,enumerable:!1}))},t.prototype.validate=function(e,t){return this.name in e?a.typeCheckFailure(a.getContextForPath(t,this.name),e[this.name],"Computed properties should not be provided in the snapshot"):a.typeCheckSuccess()},t}(i.Property);t.ComputedProperty=s},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(3),i=n(14),a=n(2),s=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.subtype=n,r}return r(t,e),t.prototype.initialize=function(t,n){e.prototype.initialize.call(this,t,n);var r=o.getStateTreeNode(t),i=n[this.name];a.typecheck(this.subtype,i),r.identifierAttribute=this.name},t.prototype.isValidIdentifier=function(e){return this.subtype.is(e)},t}(i.ValueProperty);t.IdentifierProperty=s},function(e,t,n){"use strict";function r(e,t){var n=function(){var e=this,n=arguments,r=s.getStateTreeNode(this);return r.assertAlive(),i.extras.allowStateChanges(!1,function(){return t.apply(e,n)})};return a.createNamedFunction(e,n)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(5),a=n(1),s=n(3),u=n(10),p=n(2),c=function(e){function t(t,n){var o=e.call(this,t)||this;return o.invokeView=r(t,n),o}return o(t,e),t.prototype.initialize=function(e){a.addHiddenFinalProp(e,this.name,this.invokeView.bind(e))},t.prototype.validate=function(e,t){return this.name in e?p.typeCheckFailure(p.getContextForPath(t,this.name),e[this.name],"View properties should not be provided in the snapshot"):p.typeCheckSuccess()},t}(u.Property);t.ViewProperty=c,t.createViewInvoker=r},function(e,t,n){"use strict";function r(e){return Object.freeze(e),s.isPlainObject(e)&&Object.keys(e).forEach(function(t){Object.isFrozen(e[t])||r(e[t])}),e}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),a=n(2),s=n(1),u=n(3),p=function(e){function t(){var t=e.call(this,"frozen")||this;return t.flags=i.TypeFlags.Frozen,t}return o(t,e),t.prototype.describe=function(){return"<any immutable value>"},t.prototype.instantiate=function(e,t,n,o){return u.createNode(this,e,t,n,s.isMutable(o)?r(o):o)},t.prototype.isValidSnapshot=function(e,t){return s.isSerializable(e)?a.typeCheckSuccess():a.typeCheckFailure(t,e)},t}(i.Type);t.Frozen=p,t.frozen=new p},function(e,t,n){"use strict";function r(e){return o.union(s,e)}Object.defineProperty(t,"__esModule",{value:!0});var o=n(17),i=n(13),a=n(11),s=a.optional(i.literal(null),null);t.maybe=r},function(e,t,n){"use strict";function r(e){return 2===arguments.length&&"string"==typeof arguments[1]&&p.fail("References with base path are no longer supported. Please remove the base path."),new l(e)}function o(e){return(e.flags&s.TypeFlags.Reference)>0}var i=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var a=n(3),s=n(4),u=n(2),p=n(1),c=function(){function e(e,t){if(this.mode=e,this.value=t,"object"===e){if(!a.isStateTreeNode(t))return p.fail("Can only store references to tree nodes, got: '"+t+"'");var n=a.getStateTreeNode(t);if(!n.identifierAttribute)return p.fail("Can only store references with a defined identifier attribute.")}}return e}(),l=function(e){function t(t){var n=e.call(this,"reference("+t.name+")")||this;return n.targetType=t,n.flags=s.TypeFlags.Reference,n}return i(t,e),t.prototype.describe=function(){return this.name},t.prototype.getValue=function(e){var t=e.storedValue;if("object"===t.mode)return t.value;var n=e.root.identifierCache.resolve(this.targetType,t.value);return n?n.getValue():p.fail("Failed to resolve reference of type "+this.targetType.name+": '"+t.value+"' (in: "+e.path+")")},t.prototype.getSnapshot=function(e){var t=e.storedValue;switch(t.mode){case"identifier":return t.value;case"object":return a.getStateTreeNode(t.value).identifier}},t.prototype.instantiate=function(e,t,n,r){var o=a.isStateTreeNode(r);return a.createNode(this,e,t,n,new c(o?"object":"identifier",r))},t.prototype.reconcile=function(e,t){var n=a.isStateTreeNode(t)?"object":"identifier";if(o(e.type)){var r=e.storedValue;if(n===r.mode&&r.value===t)return e}var i=this.instantiate(e.parent,e.subpath,e._environment,t);return e.die(),i},t.prototype.isAssignableFrom=function(e){return this.targetType.isAssignableFrom(e)},t.prototype.isValidSnapshot=function(e,t){return"string"==typeof e||"number"==typeof e?u.typeCheckSuccess():u.typeCheckFailure(t,e,"Value '"+u.prettyPrintValue(e)+"' is not a valid reference. Expected a string or number.")},t}(s.Type);t.ReferenceType=l,t.reference=r,t.isReferenceType=o},function(e,t,n){"use strict";function r(e,t,n){var r=t.create();return n(s.isStateTreeNode(r)?s.getStateTreeNode(r).snapshot:r)||a.fail("Default value for refinement type "+e+" does not pass the predicate."),new p(e,t,n)}var o=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var i=n(4),a=n(1),s=n(3),u=n(2),p=function(e){function t(t,n,r){var o=e.call(this,t)||this;return o.type=n,o.predicate=r,o}return o(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this.type.flags},enumerable:!0,configurable:!0}),t.prototype.describe=function(){return this.name},t.prototype.instantiate=function(e,t,n,r){var o=this.type.instantiate(e,t,n,r);return o},t.prototype.isAssignableFrom=function(e){return this.type.isAssignableFrom(e)},t.prototype.isValidSnapshot=function(e,t){if(this.type.is(e)){var n=s.isStateTreeNode(e)?s.getStateTreeNode(e).snapshot:e;if(this.predicate(n))return u.typeCheckSuccess()}return u.typeCheckFailure(t,e)},t}(i.Type);t.Refinement=p,t.refinement=r}])});
{
"name": "mobx-state-tree",
"version": "0.6.3",
"version": "0.7.0",
"description": "Opinionated, transactional, MobX powered state container",

@@ -38,3 +38,3 @@ "main": "lib/index.js",

"documentation": "^4.0.0-beta9",
"mobx": "^3.1.9",
"mobx": "^3.1.12",
"nyc": "^10.0.0",

@@ -49,3 +49,3 @@ "tape": "^4.6.0",

"peerDependencies": {
"mobx": "^3.1.9"
"mobx": "^3.1.12"
},

@@ -52,0 +52,0 @@ "keywords": [

<p align="center">
<img src="docs/logo.png" height="100">
<h3 align="center">mobx-state-tree</h3>
<p align="center">_Opinionated, transactional, MobX powered state container combining the best features of the immutable and mutable world for an optimal DX_<p>
<p align="center"><i>Opinionated, transactional, MobX powered state container combining the best features of the immutable and mutable world for an optimal DX</i><p>
</p>

@@ -141,3 +141,3 @@

Despite all that, you will see that the [API](api.md) is pretty straight forward!
Despite all that, you will see that the [API](API.md) is pretty straight forward!

@@ -198,3 +198,3 @@ ---

todos: types.array(Todo), // 4
selectedTodo: types.reference(Todo, "todos"), // 5
selectedTodo: types.reference(Todo), // 5
get completedTodos() { // 6

@@ -374,3 +374,3 @@ return this.todos.filter(t => t.done)

todos: types.array(Todo),
selectedTodo: types.reference(Todo, "todos")
selectedTodo: types.reference(Todo)
})

@@ -396,20 +396,12 @@

- The identifier property of an object cannot be modified after initialization
- Identifiers should be unique within their parent collection (`array` or `map`)
- Each identifiers / type combination should be unique within the entire tree
- Identifiers are used to reconcile items inside arrays and maps wherever possible when applying snapshots
- The `map.put()` method can be used to simplify adding objects to maps that have identifiers
- The `map.put()` method can be used to simplify adding objects that have identifiers to maps
- The primary goal of identifiers is not validation, but reconciliation and reference resolving. For this reason identifiers cannot be defined or updated after creation. If you want to check if some value just looks as an identifier, without providing the above semantics; use something like: `types.refinement(types.string, v => v.match(/someregex/))`
#### References
References can be defined in two ways, generic or namespaces.
References are defined by mentioning the type they should resolve to. The targetted type should have exactly one attribute of the type `identifier()`.
References are looked up through the entire tree, but per type. So identifiers need to be unique in the entire tree.
Namespaced references can only put to elements of the correct type, at a predefined location (namespace). Namespaced references always use the `identifier()` property of the targeted object.
The above example: `selectedTodo: types.reference(Todo, "todos")` is namespaced, and resolves it's target in the collection on the relative path `"todos"`. (`"../todos"` can be used to identify a namespace one level higher in the tree etc.)
Generic references can point to any element of the correct type in the current tree, and are stored behind the scenes as JSON path. The above example could also have been configured as `selectedTodo: types.reference(Todo)` to create a generic reference.
_Tip: It is recommended to use namespaced references; as those are more stable, since they always use immutable references and a preconfigured namespace._
**Note: The exact semantics of references are still under investigation, and might change before MST 1.0. One of the two forms might be dropped_**
### Listening to observables, snapshots, patches or actions

@@ -511,3 +503,3 @@

* `types.identifier(subType?)` Only one such member can exist in a `types.model` and should uniquely identify the object. See [identifiers](#identifiers) for more details. `subType` should be either `types.string` or `types.number`, defaulting to the first if not specified.
* `types.reference(targetType, basePath?)` creates a property that is a reference to another item of the given `targetType` somewhere in the same tree. See [references](#references) for more details.
* `types.reference(targetType)` creates a property that is a reference to another item of the given `targetType` somewhere in the same tree. See [references](#references) for more details.

@@ -642,4 +634,16 @@ ## LifeCycle hooks for `types.model`

### Storing non-serializable data with models
TODO `types.localState`
# FAQ
### How does reconcilation work?
* When applying snapshots, MST will always try to reuse existing object instances for snapshots with the same identifier (see `types.identifier()`).
* If no identifier is specified, but the type of the snapshot is correct, MST will reconcile objects as well if they are stored in a specific model property or under the same map key.
* In arrays, items without identifier are never reconciled
If an object is reconciled, the consequence is that localState is preserved and `postCreate` / `attach` life-cycle hooks are not fired because applying a snapshot results just in an existing tree node being updated.
### Creating async processes

@@ -646,0 +650,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc