UNPKG

6.22 kBJavaScriptView Raw
1"use strict";
2var ActionTypes = require("./ActionTypes");
3exports.CLEAR = 'DAG_HISTORY_CLEAR';
4exports.UNDO = 'DAG_HISTORY_UNDO';
5exports.REDO = 'DAG_HISTORY_REDO';
6exports.JUMP_TO_STATE = 'DAG_HISTORY_JUMP_TO_STATE';
7exports.JUMP_TO_BRANCH = 'DAG_HISTORY_JUMP_TO_BRANCH';
8exports.CREATE_BRANCH = 'DAG_HISTORY_CREATE_BRANCH';
9exports.SQUASH = 'DAG_HISTORY_SQUASH';
10var DEFAULT_ACTION_FILTER = function () { return true; };
11var Configuration = (function () {
12 function Configuration(rawConfig) {
13 this.rawConfig = rawConfig;
14 }
15 Object.defineProperty(Configuration.prototype, "stateEqualityPredicate", {
16 get: function () {
17 return this.rawConfig.stateEqualityPredicate;
18 },
19 enumerable: true,
20 configurable: true
21 });
22 Object.defineProperty(Configuration.prototype, "stateKeyGenerator", {
23 get: function () {
24 return this.rawConfig.stateKeyGenerator;
25 },
26 enumerable: true,
27 configurable: true
28 });
29 Configuration.prototype.actionName = function (state, id) {
30 if (this.rawConfig.actionName) {
31 return this.rawConfig.actionName(state, id);
32 }
33 else {
34 return "State " + id;
35 }
36 ;
37 };
38 Configuration.prototype.branchName = function (oldBranch, newBranch, actionName) {
39 if (this.rawConfig.branchName) {
40 return this.rawConfig.branchName(oldBranch, newBranch, actionName);
41 }
42 return newBranch + ": " + actionName;
43 };
44 Configuration.prototype.canHandleAction = function (action) {
45 return this.rawConfig.canHandleAction && this.rawConfig.canHandleAction(action);
46 };
47 Configuration.prototype.handleAction = function (action, history) {
48 return this.rawConfig.handleAction(action, history);
49 };
50 Object.defineProperty(Configuration.prototype, "debug", {
51 get: function () {
52 return this.rawConfig.debug || false;
53 },
54 enumerable: true,
55 configurable: true
56 });
57 Object.defineProperty(Configuration.prototype, "actionFilter", {
58 get: function () {
59 return this.rawConfig.actionFilter || DEFAULT_ACTION_FILTER;
60 },
61 enumerable: true,
62 configurable: true
63 });
64 Object.defineProperty(Configuration.prototype, "loadActionType", {
65 get: function () {
66 return this.rawConfig.loadActionType || ActionTypes.LOAD;
67 },
68 enumerable: true,
69 configurable: true
70 });
71 Object.defineProperty(Configuration.prototype, "clearActionType", {
72 get: function () {
73 return this.rawConfig.clearActionType || ActionTypes.CLEAR;
74 },
75 enumerable: true,
76 configurable: true
77 });
78 Object.defineProperty(Configuration.prototype, "undoActionType", {
79 get: function () {
80 return this.rawConfig.undoActionType || ActionTypes.UNDO;
81 },
82 enumerable: true,
83 configurable: true
84 });
85 Object.defineProperty(Configuration.prototype, "redoActionType", {
86 get: function () {
87 return this.rawConfig.redoActionType || ActionTypes.REDO;
88 },
89 enumerable: true,
90 configurable: true
91 });
92 Object.defineProperty(Configuration.prototype, "jumpToStateActionType", {
93 get: function () {
94 return this.rawConfig.jumpToStateActionType || ActionTypes.JUMP_TO_STATE;
95 },
96 enumerable: true,
97 configurable: true
98 });
99 Object.defineProperty(Configuration.prototype, "jumpToBranchActionType", {
100 get: function () {
101 return this.rawConfig.jumpToBranchActionType || ActionTypes.JUMP_TO_BRANCH;
102 },
103 enumerable: true,
104 configurable: true
105 });
106 Object.defineProperty(Configuration.prototype, "jumpToLatestOnBranchActionType", {
107 get: function () {
108 return this.rawConfig.jumpToLatestOnBranchActionType || ActionTypes.JUMP_TO_LATEST_ON_BRANCH;
109 },
110 enumerable: true,
111 configurable: true
112 });
113 Object.defineProperty(Configuration.prototype, "createBranchActionType", {
114 get: function () {
115 return this.rawConfig.createBranchActionType || ActionTypes.CREATE_BRANCH;
116 },
117 enumerable: true,
118 configurable: true
119 });
120 Object.defineProperty(Configuration.prototype, "renameBranchActionType", {
121 get: function () {
122 return this.rawConfig.renameBranchActionType || ActionTypes.RENAME_BRANCH;
123 },
124 enumerable: true,
125 configurable: true
126 });
127 Object.defineProperty(Configuration.prototype, "squashActionType", {
128 get: function () {
129 return this.rawConfig.squashActionType || ActionTypes.SQUASH;
130 },
131 enumerable: true,
132 configurable: true
133 });
134 Object.defineProperty(Configuration.prototype, "renameStateActionType", {
135 get: function () {
136 return this.rawConfig.renameStateActionType || ActionTypes.RENAME_STATE;
137 },
138 enumerable: true,
139 configurable: true
140 });
141 Object.defineProperty(Configuration.prototype, "skipToStartActionType", {
142 get: function () {
143 return this.rawConfig.skipToStartActionType || ActionTypes.SKIP_TO_START;
144 },
145 enumerable: true,
146 configurable: true
147 });
148 Object.defineProperty(Configuration.prototype, "skipToEndActionType", {
149 get: function () {
150 return this.rawConfig.skipToEndActionType || ActionTypes.SKIP_TO_END;
151 },
152 enumerable: true,
153 configurable: true
154 });
155 Object.defineProperty(Configuration.prototype, "initialBranchName", {
156 get: function () {
157 return this.rawConfig.initialBranchName || 'Branch 1';
158 },
159 enumerable: true,
160 configurable: true
161 });
162 Object.defineProperty(Configuration.prototype, "initialStateName", {
163 get: function () {
164 return this.rawConfig.initialStateName || 'Initial';
165 },
166 enumerable: true,
167 configurable: true
168 });
169 return Configuration;
170}());
171Object.defineProperty(exports, "__esModule", { value: true });
172exports.default = Configuration;