Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | var __assign = this && this.__assign || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import { ActionTypes, SpecialTargets } from './types'; import * as actionTypes from './actionTypes'; import { getEventType } from './utils'; export { actionTypes }; export function toEventObject(event // id?: TEvents['type'] ) { if (typeof event === 'string' || typeof event === 'number') { var eventObject = { type: event }; // if (id !== undefined) { // eventObject.id = id; // } return eventObject; } return event; } function getActionFunction(actionType, actionFunctionMap) { if (!actionFunctionMap) { return undefined; } var actionReference = actionFunctionMap[actionType]; if (!actionReference) { return undefined; } if (typeof actionReference === 'function') { return actionReference; } return actionReference.exec; } export var toActionObject = function (action, actionFunctionMap) { var actionObject; if (typeof action === 'string' || typeof action === 'number') { actionObject = { type: action, exec: getActionFunction(action, actionFunctionMap) }; } else if (typeof action === 'function') { actionObject = { type: action.name, exec: action }; } else { var exec = getActionFunction(action.type, actionFunctionMap); return exec ? __assign({}, action, { exec: exec }) : action; } Object.defineProperty(actionObject, 'toString', { value: function () { return actionObject.type; }, enumerable: false }); return actionObject; }; export function toActivityDefinition(action) { var actionObject = toActionObject(action); return __assign({ id: typeof action === 'string' ? action : actionObject.id }, actionObject, { type: actionObject.type }); } export var toActionObjects = function (action, actionFunctionMap) { if (!action) { return []; } var actions = Array.isArray(action) ? action : [action]; return actions.map(function (subAction) { return toActionObject(subAction, actionFunctionMap); }); }; export function raise(eventType) { return { type: actionTypes.raise, event: eventType }; } export function send(event, options) { return { target: options ? options.target : undefined, type: actionTypes.send, event: toEventObject(event), delay: options ? options.delay : undefined, id: options && options.id !== undefined ? options.id : getEventType(event) }; } export function sendParent(event, options) { return send(event, __assign({}, options, { target: SpecialTargets.Parent })); } export function log(expr, label) { return { type: actionTypes.log, label: label, expr: expr }; } export var cancel = function (sendId) { return { type: actionTypes.cancel, sendId: sendId }; }; export function start(activity) { var activityDef = toActivityDefinition(activity); return { type: ActionTypes.Start, activity: activityDef, exec: undefined }; } export function stop(activity) { var activityDef = toActivityDefinition(activity); return { type: ActionTypes.Stop, activity: activityDef, exec: undefined }; } export var assign = function (assignment) { return { type: actionTypes.assign, assignment: assignment }; }; export function isActionObject(action) { return typeof action === 'object' && 'type' in action; } export function after(delay, id) { var idSuffix = id ? "#" + id : ''; return ActionTypes.After + "(" + delay + ")" + idSuffix; } export function done(id) { return ActionTypes.DoneState + "." + id; } export function invoke(invokeConfig, options) { if (typeof invokeConfig === 'string') { return __assign({ id: invokeConfig, src: invokeConfig, type: ActionTypes.Invoke }, options); } return invokeConfig; } |