@scion-scxml/core
Version:
StateCharts Interpretation and Optimization eNgine (SCION) CORE is an implementation of Statecharts in JavaScript.
658 lines (644 loc) • 44.2 kB
HTML
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>typescript</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">typescript</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="globals.html">Globals</a>
</li>
</ul>
<h1> typescript</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<h1 id="overview">Overview</h1>
<p>scion-core is a small implementation of Statecharts in JavaScript. scion-core
lets you program with Statecharts using a simple JavaScript/JSON API. </p>
<h1 id="installation">Installation</h1>
<h2 id="browser-vanillajs-">Browser (VanillaJS)</h2>
<p>scion-core is available on unpkg. Simply add the script tag to your page:</p>
<pre><code><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/@scion-scxml/core@2.6.22/dist/core.min.js"</span>></span><span class="undefined"></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre><p>scion-core is then available as the global variable <code>scion.core</code>.</p>
<h2 id="node-js">Node.js</h2>
<p>Install scion-core via npm:</p>
<pre><code><span class="hljs-selector-tag">npm</span> <span class="hljs-selector-tag">install</span> @<span class="hljs-keyword">scion</span>-<span class="hljs-keyword">scxml</span>/<span class="hljs-keyword">core</span></code></pre><h1 id="backwards-compatibility-semantics-">Backwards-compatibility (semantics)</h1>
<p>There are many different semantics for Statecharts family of languages (for a
good overview of various Statechart semantics, see <a href="https://cs.uwaterloo.ca/~nday/pdf/techreps/2009-05-EsDa-tr.pdf">"Big-Step Semantics"</a> by
Shahram Esmaeilsabzali, Nancy A. Day, Joanne M. Atlee, and Jianwei Niu).
scion-core implements the semantics described in <a href="https://www.w3.org/TR/scxml/">Appendix D of the SCXML specification</a>.</p>
<p>Versions of <a href="mailto:scion-core@1.x">scion-core@1.x</a> implements a slightly different semantics,
described
<a href="https://github.com/jbeard4/SCION/wiki/SCION-vs.-SCXML-Comparison">here</a>,
<a href="https://github.com/jbeard4/SCION/wiki/Scion-Semantics">here</a>, and
<a href="http://digitool.library.mcgill.ca/R/-?func=dbin-jump-full&object_id=116899&silo_library=GEN01">here</a>.
The semantics of <a href="mailto:scion-core@1.x">scion-core@1.x</a> have been deprecated in <a href="mailto:scion-core@2.x">scion-core@2.x</a> in favor
of the SCXML semantics described in Appendix D of the specification. </p>
<p>If you are upgrading an existing application, and you require support for
<a href="mailto:scion-core@1.x">scion-core@1.x</a> semantics, the
<a href="https://github.com/jbeard4/scion-core-legac://github.com/jbeard4/scion-core-legacy">scion-core-legacy</a>
module provides a backwards-compatible, drop-in replacement module for
<a href="mailto:scion-core@1.5.5">scion-core@1.5.5</a>. </p>
<h1 id="api">API</h1>
<p>See generated API docs <a href="http://jbeard4.github.io/SCION-CORE/classes/_workspace_scion_scxml_platform_projects_scion_core_tsd_scion_core_d_.statechart.html">here</a>.</p>
<h1 id="statecharts-model-schema">Statecharts Model Schema</h1>
<p>scion-core is designed to allow you to specify the Statecharts model declaratively as a single JavaScript object literal, or as JSON. This section is intended to describe the schema of the Statecharts object model accepted by scion-core. </p>
<p>As of version 2, scion-core implements the semantics defined in Appendix D of the SCXML specification, <a href="https://www.w3.org/TR/scxml/#AlgorithmforSCXMLInterpretation">"Algorithm for SCXML Interpretation"</a>.</p>
<h2 id="states">States</h2>
<p>A scion-core model is made up of states. States can have id's, which are optional. Here is a scion-core model which is a single state:</p>
<pre><code>{
<span class="hljs-attribute">id </span>: <span class="hljs-string">'foo'</span>
}</code></pre><p>States can contain other states hierarchically:</p>
<pre><code class="language-javascript">{
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>
states : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>
}
]
}</code></pre>
<p>By default, a parent state will be an "OR" state, which means it defines an XOR relationship between its children (if the state machine is in 'foo', then the state machine will either be in state 'bar' or 'bat', but will never be in both 'bar' and 'bat' simultaneously). </p>
<p>By default, when entering a parent state, the first state in the parent's state array will be entered. So, for example, when the state machine is started with the above model, its <strong>configuration</strong> (the set of states the state machine is currently in) will be <code>['foo','bar']</code>;</p>
<p>There are other types of states, however, including "parallel" states, which defines an "AND" relationship between substates.</p>
<pre><code class="language-javascript">{
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>
$type : <span class="hljs-string">'parallel'</span>
states : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>
}
]
}</code></pre>
<p>In this example, if the state machine is in state 'foo', then the state machine will also be in state 'bar' and state 'bat' simultaneously. So when the state machine is started with the above model, its configuration will be <code>['foo','bar','bat']</code>.</p>
<h2 id="transitions">Transitions</h2>
<p>States are associated with <strong>transitions</strong>, which target other states. Transitions are optionally associated with an <strong>event name</strong>. A scion-core event is an object with "name" and "data" properties. When an event is sent to the state machine, the interpreter will inspect the current configuration, and select the set of transitions that matches event name.</p>
<pre><code class="language-javascript">{
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>
states : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>,
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">target</span> : <span class="hljs-string">'bat'</span>,
<span class="hljs-attr">event</span> : <span class="hljs-string">'t'</span>
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>
}
]
}</code></pre>
<p>In this case, the state machine would start in configuration <code>['foo','bar']</code>. When event <code>{ name : 't' }</code> is sent to the state machine, then the state machine would transition to state 'bat', and the resulting configuration would be <code>['foo','bat']</code>.</p>
<p>If the transition does not have an event property, then it is known as a "default transition", and it will be selected regardless of the event's "name" property.</p>
<p>A transition can also be associated with a <strong>condition</strong>, which is an arbitrary JavaScript function that accepts an event as input, and returns a boolean value as output. Boolean true means the transition can be selected, while boolean false means the transition will not be selected.</p>
<pre><code class="language-javascript">{
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>
states : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>,
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">target</span> : <span class="hljs-string">'bat'</span>,
<span class="hljs-attr">event</span> : <span class="hljs-string">'t'</span>,
<span class="hljs-attr">cond</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
<span class="hljs-keyword">return</span> event.data % <span class="hljs-number">2</span>;
}
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>
}
]
}</code></pre>
<p>For example, the above model will only transition from 'bar' to 'bat', when <code>event.data</code> contains an odd number.</p>
<h2 id="entry-exit-and-transition-actions">Entry, Exit, and Transition Actions</h2>
<p>States can be associated with <strong>entry</strong> and <strong>exit</strong> actions. These are JavaScript functions which are executed when the state is entered or exited.</p>
<p>Transitions can also be associated with actions.</p>
<p>Actions are executed in the following order: </p>
<ul>
<li>State exit actions, ordered first by hierarchy (inner states first), and then by the order in which they appear in the document.</li>
<li>Transition actions, based on document order.</li>
<li>State entry actions, ordered first by hierarchy (outer states first), and then by the order in which they appear in the document.</li>
</ul>
<pre><code class="language-javascript"><span class="hljs-keyword">var</span> buffer;
<span class="hljs-keyword">var</span> model = {
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>
onEntry : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
buffer = []; <span class="hljs-comment">//initialize array</span>
},
<span class="hljs-attr">states</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
buffer.push(<span class="hljs-number">1</span>);
},
<span class="hljs-attr">onExit</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
buffer.push(<span class="hljs-number">2</span>);
},
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">target</span> : <span class="hljs-string">'bat'</span>,
<span class="hljs-attr">event</span> : <span class="hljs-string">'t'</span>,
<span class="hljs-attr">onTransition</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
buffer.push(<span class="hljs-number">3</span>);
}
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
buffer.push(event.data);
}
}
]
};
<span class="hljs-keyword">var</span> sc = <span class="hljs-keyword">new</span> scion.SCInterpreter(model);
sc.start(); <span class="hljs-comment">//buffer now contains [1]</span>
sc.gen(<span class="hljs-string">'t'</span>,<span class="hljs-string">'x'</span>); <span class="hljs-comment">//buffer now contains [1,2,3,'x']</span></code></pre>
<p>For the above model, when the state machine is started, 'foo' would be entered, thus initializing variable <code>buffer</code> with a new array; and then state 'bar' would be entered, pushing <code>1</code> to the buffer. After the invocation to <code>sc.start</code>, the buffer would then container <code>[1]</code>.</p>
<p>During the call to <code>sc.gen</code>, the exit action of state 'bar' would be executed, pushing <code>2</code> to the buffer, followed by transition action, pushing <code>3</code> to the buffer, followed by the entry action of <code>bat</code>, pushing the event data, string <code>"x"</code>, to the buffer. After the call to <code>sc.gen</code> completes, the buffer would contain [1,2,3,'x'].</p>
<h2 id="history">History</h2>
<p>A <strong>history</strong> state is a special pseudo-state that allows the state machine to "remember" what substate it was in last time it was in a particular parent state. There are two types of history states: "deep" and "shallow".</p>
<p>The syntax for specifying history states is as follows:</p>
<pre><code class="language-javascript">{
<span class="hljs-attr">states</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'foo'</span>,
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'t2'</span>
target : <span class="hljs-string">'bif'</span>
}
],
<span class="hljs-attr">states</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'h'</span>,
<span class="hljs-attr">$type</span> : <span class="hljs-string">'history'</span>,
<span class="hljs-attr">isDeep</span> : <span class="hljs-literal">true</span>
transitions : [
{
<span class="hljs-attr">target</span> : <span class="hljs-string">'bar'</span>
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bar'</span>,
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'t1'</span>
target : <span class="hljs-string">'bat2'</span>
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat'</span>,
<span class="hljs-attr">substates</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat1'</span>
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bat2'</span>
}
]
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'bif'</span>,
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">target</span> : <span class="hljs-string">'h'</span>,
<span class="hljs-attr">event</span> : <span class="hljs-string">'t3'</span>
}
]
}
]
}</code></pre>
<p>The first time the state machine enters 'h', it it will transition to state 'bar'. After the call to sc.start(), the state machine will reside in ['foo','bar'].</p>
<p>After the state machine sends event <code>t1</code>, the state machine will transition to 'bat2', and will reside in configuration <code>['foo','bat','bat2']</code>.</p>
<p>After the state machine sends event <code>t2</code>, the state machine will transition to 'bif', and will reside in configuration <code>['bif']</code>.</p>
<p>Finally, after the state machine sends event <code>t3</code>, the state machine will transition to back to the history state 'h', which will "remember", the configuration the state machine was in last time it was in 'foo', and the state machine will complete in configuration <code>['foo','bat','bat2']</code>.</p>
<p>If property <code>isDeep</code> had not been set on the history state, then the state machine would only have remembered the child substates of <code>foo</code>, and the state machine would have completed in configuration <code>['foo','bat','bat1']</code>.</p>
<h2 id="communications">Communications</h2>
<p>The context object ("<code>this</code>") of onEntry, onExit, and onTransition functions contains the following methods:</p>
<ul>
<li><code>send(event)</code>, which adds an event to the interpreter's outer queue</li>
<li><code>raise(event)</code>, which adds an event to the interpreter's inner queue </li>
</ul>
<h1 id="quickstart-and-simple-use-case">Quickstart and Simple Use Case</h1>
<p>Let's start with the simple example of drag-and-drop behaviour in the browser. You can run this demo live on jsfiddle <a href="http://jsfiddle.net/jbeard4/MDkLe/11/">here</a>.</p>
<p>An entity that can be dragged has two states: idle and dragging. If the entity is in an idle state, and it receives a mousedown event, then it starts dragging. While dragging, if it receives a mousemove event, then it changes its position. Also while dragging, when it receives a mouseup event, it returns to the idle state.</p>
<p>This natural-language description of behaviour can be described using the following simple state machine:</p>
<p><img src="http://jbeard4.github.com/SCION/img/drag_and_drop.png" alt="Drag and Drop"></p>
<p>This state machine could be written in scion-core's JSON syntax as follows:</p>
<pre><code class="language-javascript">{
<span class="hljs-string">"states"</span> : [
{
<span class="hljs-string">"id"</span> : <span class="hljs-string">"idle"</span>,
<span class="hljs-string">"transitions"</span> : [
{
<span class="hljs-string">"event"</span> : <span class="hljs-string">"mousedown"</span>,
<span class="hljs-string">"target"</span> : <span class="hljs-string">"dragging"</span>,
}
]
},
{
<span class="hljs-string">"id"</span> : <span class="hljs-string">"dragging"</span>,
<span class="hljs-string">"transitions"</span> : [
{
<span class="hljs-string">"event"</span> : <span class="hljs-string">"mouseup"</span>,
<span class="hljs-string">"target"</span> : <span class="hljs-string">"idle"</span>,
},
{
<span class="hljs-string">"event"</span> : <span class="hljs-string">"mousemove"</span>,
<span class="hljs-string">"target"</span> : <span class="hljs-string">"dragging"</span>
}
]
}
]
}</code></pre>
<p>One can add action code in order to script an HTML DOM element, so as to change its position on mousemove events:</p>
<pre><code class="language-javascript"><span class="hljs-comment">//declare the your statechart model, same as before</span>
<span class="hljs-keyword">var</span> firstEvent,
eventStamp,
rectNode = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'rect'</span>),
rectX = <span class="hljs-number">0</span>,
rectY = <span class="hljs-number">0</span>;
<span class="hljs-keyword">var</span> statechartModel = {
<span class="hljs-attr">states</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'idle'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
rectNode.textContent=<span class="hljs-string">'idle'</span>;
},
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mousedown'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onTransition</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
eventStamp = firstEvent = event.data;
}
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
rectNode.textContent=<span class="hljs-string">'dragging'</span>;
},
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mouseup'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'idle'</span>
},
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mousemove'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onTransition</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
<span class="hljs-keyword">var</span> dx = eventStamp.clientX - event.data.clientX;
<span class="hljs-keyword">var</span> dy = eventStamp.clientY - event.data.clientY;
rectNode.style.left = (rectX -= dx) + <span class="hljs-string">'px'</span>;
rectNode.style.top = (rectY -= dy) + <span class="hljs-string">'px'</span>;
eventStamp = event.data;
}
}
]
}
]
};</code></pre>
<p>You can then perform the following steps to script web content:</p>
<ol>
<li>Use the statecharts model object to instantiate the SCXML interpreter.</li>
<li>Connect relevant event listeners to the SCXML interpreter.</li>
<li>Call the <code>start</code> method on the SCXML interpreter to start execution of the statechart.</li>
</ol>
<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/@scion-scxml/core@2.6.21/dist/core.min.js"</span>></span><span class="undefined"></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
<span class="hljs-tag"></<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">body</span>></span>
<span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"rect"</span>/></span>
<span class="hljs-tag"><<span class="hljs-name">script</span>></span><span class="javascript">
<span class="hljs-comment">//declare the your statechart model, same as before</span>
<span class="hljs-keyword">var</span> firstEvent,
eventStamp,
rectNode = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'rect'</span>),
rectX = <span class="hljs-number">0</span>,
rectY = <span class="hljs-number">0</span>;
<span class="hljs-keyword">var</span> statechartModel = {
<span class="hljs-attr">states</span> : [
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'idle'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
rectNode.textContent=<span class="hljs-string">'idle'</span>;
},
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mousedown'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onTransition</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
eventStamp = firstEvent = event.data;
}
}
]
},
{
<span class="hljs-attr">id</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onEntry</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
rectNode.textContent=<span class="hljs-string">'dragging'</span>;
},
<span class="hljs-attr">transitions</span> : [
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mouseup'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'idle'</span>
},
{
<span class="hljs-attr">event</span> : <span class="hljs-string">'mousemove'</span>,
<span class="hljs-attr">target</span> : <span class="hljs-string">'dragging'</span>,
<span class="hljs-attr">onTransition</span> : <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
<span class="hljs-keyword">var</span> dx = eventStamp.clientX - event.data.clientX;
<span class="hljs-keyword">var</span> dy = eventStamp.clientY - event.data.clientY;
rectNode.style.left = (rectX -= dx) + <span class="hljs-string">'px'</span>;
rectNode.style.top = (rectY -= dy) + <span class="hljs-string">'px'</span>;
eventStamp = event.data;
}
}
]
}
]
};
<span class="hljs-comment">//instantiate the interpreter</span>
<span class="hljs-keyword">var</span> interpreter = <span class="hljs-keyword">new</span> scion.core.Statechart(statechartModel);
<span class="hljs-comment">//start the interpreter</span>
interpreter.start();
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleEvent</span>(<span class="hljs-params">e</span>)</span>{
e.preventDefault();
interpreter.gen({<span class="hljs-attr">name</span> : e.type,<span class="hljs-attr">data</span>: e});
}
<span class="hljs-comment">//connect all relevant event listeners</span>
rectNode.addEventListener(<span class="hljs-string">'mousedown'</span>,handleEvent,<span class="hljs-literal">true</span>);
<span class="hljs-built_in">document</span>.documentElement.addEventListener(<span class="hljs-string">'mouseup'</span>,handleEvent,<span class="hljs-literal">true</span>);
<span class="hljs-built_in">document</span>.documentElement.addEventListener(<span class="hljs-string">'mousemove'</span>,handleEvent,<span class="hljs-literal">true</span>);
</span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
<span class="hljs-tag"></<span class="hljs-name">body</span>></span>
<span class="hljs-tag"></<span class="hljs-name">html</span>></span></code></pre>
<h1 id="build-status">Build Status</h1>
<p><a href="https://gitlab.com/scion-scxml/core"><img src="https://gitlab.com/scion-scxml/core/badges/master/build.svg" alt="Build status"></a></p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="globals.html"><em>Globals</em></a>
</li>
<li class="label tsd-is-external">
<span>Internals</span>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_tsd_scion_core_d_.html">"tsd/scion-<wbr>core.d"</a>
</li>
<li class="label tsd-is-external">
<span>Externals</span>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__scion_scxml_core_base_tsd_scion_core_base_d_.html">"node_<wbr>modules/@scion-<wbr>scxml/core-<wbr>base/tsd/scion-<wbr>core-<wbr>base.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_events_index_d_.html">"node_<wbr>modules/@types/events/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_fs_extra_index_d_.html">"node_<wbr>modules/@types/fs-<wbr>extra/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_glob_index_d_.html">"node_<wbr>modules/@types/glob/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_handlebars_index_d_.html">"node_<wbr>modules/@types/handlebars/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_highlight_js_index_d_.html">"node_<wbr>modules/@types/highlight.js/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_array_d_.html">"node_<wbr>modules/@types/lodash/common/array.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_collection_d_.html">"node_<wbr>modules/@types/lodash/common/collection.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_common_d_.html">"node_<wbr>modules/@types/lodash/common/common.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_date_d_.html">"node_<wbr>modules/@types/lodash/common/date.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_function_d_.html">"node_<wbr>modules/@types/lodash/common/function.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_lang_d_.html">"node_<wbr>modules/@types/lodash/common/lang.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_math_d_.html">"node_<wbr>modules/@types/lodash/common/math.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_number_d_.html">"node_<wbr>modules/@types/lodash/common/number.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_object_d_.html">"node_<wbr>modules/@types/lodash/common/object.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_seq_d_.html">"node_<wbr>modules/@types/lodash/common/seq.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_string_d_.html">"node_<wbr>modules/@types/lodash/common/string.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_common_util_d_.html">"node_<wbr>modules/@types/lodash/common/util.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_lodash_index_d_.html">"node_<wbr>modules/@types/lodash/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_marked_index_d_.html">"node_<wbr>modules/@types/marked/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_minimatch_index_d_.html">"node_<wbr>modules/@types/minimatch/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_node_index_d_.html">"node_<wbr>modules/@types/node/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_node_inspector_d_.html">"node_<wbr>modules/@types/node/inspector.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules__types_shelljs_index_d_.html">"node_<wbr>modules/@types/shelljs/index.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_collection_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.collection.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_core_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.core.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_generator_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.generator.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_iterable_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.iterable.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_promise_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.promise.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_proxy_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.proxy.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_reflect_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.reflect.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_symbol_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.symbol.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es2015_symbol_wellknown_d_.html">"node_<wbr>modules/typescript/lib/lib.es2015.symbol.wellknown.d"</a>
</li>
<li class=" tsd-kind-external-module tsd-is-external">
<a href="modules/_node_modules_typescript_lib_lib_es5_d_.html">"node_<wbr>modules/typescript/lib/lib.es5.d"</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>