9611 lines
235 KiB
JavaScript
9611 lines
235 KiB
JavaScript
(function () {
|
|
/**
|
|
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
|
|
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
|
|
*/
|
|
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
|
//be followed.
|
|
/*global setTimeout: false */
|
|
|
|
var requirejs, require, define;
|
|
(function (undef) {
|
|
var main, req, makeMap, handlers,
|
|
defined = {},
|
|
waiting = {},
|
|
config = {},
|
|
defining = {},
|
|
hasOwn = Object.prototype.hasOwnProperty,
|
|
aps = [].slice,
|
|
jsSuffixRegExp = /\.js$/;
|
|
|
|
function hasProp(obj, prop) {
|
|
return hasOwn.call(obj, prop);
|
|
}
|
|
|
|
/**
|
|
* Given a relative module name, like ./something, normalize it to
|
|
* a real name that can be mapped to a path.
|
|
* @param {String} name the relative name
|
|
* @param {String} baseName a real name that the name arg is relative
|
|
* to.
|
|
* @returns {String} normalized name
|
|
*/
|
|
function normalize(name, baseName) {
|
|
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
|
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
|
|
baseParts = baseName && baseName.split("/"),
|
|
map = config.map,
|
|
starMap = (map && map['*']) || {};
|
|
|
|
//Adjust any relative paths.
|
|
if (name) {
|
|
name = name.split('/');
|
|
lastIndex = name.length - 1;
|
|
|
|
// If wanting node ID compatibility, strip .js from end
|
|
// of IDs. Have to do this here, and not in nameToUrl
|
|
// because node allows either .js or non .js to map
|
|
// to same file.
|
|
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
|
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
|
}
|
|
|
|
// Starts with a '.' so need the baseName
|
|
if (name[0].charAt(0) === '.' && baseParts) {
|
|
//Convert baseName to array, and lop off the last part,
|
|
//so that . matches that 'directory' and not name of the baseName's
|
|
//module. For instance, baseName of 'one/two/three', maps to
|
|
//'one/two/three.js', but we want the directory, 'one/two' for
|
|
//this normalization.
|
|
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
|
name = normalizedBaseParts.concat(name);
|
|
}
|
|
|
|
//start trimDots
|
|
for (i = 0; i < name.length; i++) {
|
|
part = name[i];
|
|
if (part === '.') {
|
|
name.splice(i, 1);
|
|
i -= 1;
|
|
} else if (part === '..') {
|
|
// If at the start, or previous value is still ..,
|
|
// keep them so that when converted to a path it may
|
|
// still work when converted to a path, even though
|
|
// as an ID it is less than ideal. In larger point
|
|
// releases, may be better to just kick out an error.
|
|
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
|
|
continue;
|
|
} else if (i > 0) {
|
|
name.splice(i - 1, 2);
|
|
i -= 2;
|
|
}
|
|
}
|
|
}
|
|
//end trimDots
|
|
|
|
name = name.join('/');
|
|
}
|
|
|
|
//Apply map config if available.
|
|
if ((baseParts || starMap) && map) {
|
|
nameParts = name.split('/');
|
|
|
|
for (i = nameParts.length; i > 0; i -= 1) {
|
|
nameSegment = nameParts.slice(0, i).join("/");
|
|
|
|
if (baseParts) {
|
|
//Find the longest baseName segment match in the config.
|
|
//So, do joins on the biggest to smallest lengths of baseParts.
|
|
for (j = baseParts.length; j > 0; j -= 1) {
|
|
mapValue = map[baseParts.slice(0, j).join('/')];
|
|
|
|
//baseName segment has config, find if it has one for
|
|
//this name.
|
|
if (mapValue) {
|
|
mapValue = mapValue[nameSegment];
|
|
if (mapValue) {
|
|
//Match, update name to the new value.
|
|
foundMap = mapValue;
|
|
foundI = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (foundMap) {
|
|
break;
|
|
}
|
|
|
|
//Check for a star map match, but just hold on to it,
|
|
//if there is a shorter segment match later in a matching
|
|
//config, then favor over this star map.
|
|
if (!foundStarMap && starMap && starMap[nameSegment]) {
|
|
foundStarMap = starMap[nameSegment];
|
|
starI = i;
|
|
}
|
|
}
|
|
|
|
if (!foundMap && foundStarMap) {
|
|
foundMap = foundStarMap;
|
|
foundI = starI;
|
|
}
|
|
|
|
if (foundMap) {
|
|
nameParts.splice(0, foundI, foundMap);
|
|
name = nameParts.join('/');
|
|
}
|
|
}
|
|
|
|
return name;
|
|
}
|
|
|
|
function makeRequire(relName, forceSync) {
|
|
return function () {
|
|
//A version of a require function that passes a moduleName
|
|
//value for items that may need to
|
|
//look up paths relative to the moduleName
|
|
var args = aps.call(arguments, 0);
|
|
|
|
//If first arg is not require('string'), and there is only
|
|
//one arg, it is the array form without a callback. Insert
|
|
//a null so that the following concat is correct.
|
|
if (typeof args[0] !== 'string' && args.length === 1) {
|
|
args.push(null);
|
|
}
|
|
return req.apply(undef, args.concat([relName, forceSync]));
|
|
};
|
|
}
|
|
|
|
function makeNormalize(relName) {
|
|
return function (name) {
|
|
return normalize(name, relName);
|
|
};
|
|
}
|
|
|
|
function makeLoad(depName) {
|
|
return function (value) {
|
|
defined[depName] = value;
|
|
};
|
|
}
|
|
|
|
function callDep(name) {
|
|
if (hasProp(waiting, name)) {
|
|
var args = waiting[name];
|
|
delete waiting[name];
|
|
defining[name] = true;
|
|
main.apply(undef, args);
|
|
}
|
|
|
|
if (!hasProp(defined, name) && !hasProp(defining, name)) {
|
|
throw new Error('No ' + name);
|
|
}
|
|
return defined[name];
|
|
}
|
|
|
|
//Turns a plugin!resource to [plugin, resource]
|
|
//with the plugin being undefined if the name
|
|
//did not have a plugin prefix.
|
|
function splitPrefix(name) {
|
|
var prefix,
|
|
index = name ? name.indexOf('!') : -1;
|
|
if (index > -1) {
|
|
prefix = name.substring(0, index);
|
|
name = name.substring(index + 1, name.length);
|
|
}
|
|
return [prefix, name];
|
|
}
|
|
|
|
//Creates a parts array for a relName where first part is plugin ID,
|
|
//second part is resource ID. Assumes relName has already been normalized.
|
|
function makeRelParts(relName) {
|
|
return relName ? splitPrefix(relName) : [];
|
|
}
|
|
|
|
/**
|
|
* Makes a name map, normalizing the name, and using a plugin
|
|
* for normalization if necessary. Grabs a ref to plugin
|
|
* too, as an optimization.
|
|
*/
|
|
makeMap = function (name, relParts) {
|
|
var plugin,
|
|
parts = splitPrefix(name),
|
|
prefix = parts[0],
|
|
relResourceName = relParts[1];
|
|
|
|
name = parts[1];
|
|
|
|
if (prefix) {
|
|
prefix = normalize(prefix, relResourceName);
|
|
plugin = callDep(prefix);
|
|
}
|
|
|
|
//Normalize according
|
|
if (prefix) {
|
|
if (plugin && plugin.normalize) {
|
|
name = plugin.normalize(name, makeNormalize(relResourceName));
|
|
} else {
|
|
name = normalize(name, relResourceName);
|
|
}
|
|
} else {
|
|
name = normalize(name, relResourceName);
|
|
parts = splitPrefix(name);
|
|
prefix = parts[0];
|
|
name = parts[1];
|
|
if (prefix) {
|
|
plugin = callDep(prefix);
|
|
}
|
|
}
|
|
|
|
//Using ridiculous property names for space reasons
|
|
return {
|
|
f: prefix ? prefix + '!' + name : name, //fullName
|
|
n: name,
|
|
pr: prefix,
|
|
p: plugin
|
|
};
|
|
};
|
|
|
|
function makeConfig(name) {
|
|
return function () {
|
|
return (config && config.config && config.config[name]) || {};
|
|
};
|
|
}
|
|
|
|
handlers = {
|
|
require: function (name) {
|
|
return makeRequire(name);
|
|
},
|
|
exports: function (name) {
|
|
var e = defined[name];
|
|
if (typeof e !== 'undefined') {
|
|
return e;
|
|
} else {
|
|
return (defined[name] = {});
|
|
}
|
|
},
|
|
module: function (name) {
|
|
return {
|
|
id: name,
|
|
uri: '',
|
|
exports: defined[name],
|
|
config: makeConfig(name)
|
|
};
|
|
}
|
|
};
|
|
|
|
main = function (name, deps, callback, relName) {
|
|
var cjsModule, depName, ret, map, i, relParts,
|
|
args = [],
|
|
callbackType = typeof callback,
|
|
usingExports;
|
|
|
|
//Use name if no relName
|
|
relName = relName || name;
|
|
relParts = makeRelParts(relName);
|
|
|
|
//Call the callback to define the module, if necessary.
|
|
if (callbackType === 'undefined' || callbackType === 'function') {
|
|
//Pull out the defined dependencies and pass the ordered
|
|
//values to the callback.
|
|
//Default to [require, exports, module] if no deps
|
|
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
|
for (i = 0; i < deps.length; i += 1) {
|
|
map = makeMap(deps[i], relParts);
|
|
depName = map.f;
|
|
|
|
//Fast path CommonJS standard dependencies.
|
|
if (depName === "require") {
|
|
args[i] = handlers.require(name);
|
|
} else if (depName === "exports") {
|
|
//CommonJS module spec 1.1
|
|
args[i] = handlers.exports(name);
|
|
usingExports = true;
|
|
} else if (depName === "module") {
|
|
//CommonJS module spec 1.1
|
|
cjsModule = args[i] = handlers.module(name);
|
|
} else if (hasProp(defined, depName) ||
|
|
hasProp(waiting, depName) ||
|
|
hasProp(defining, depName)) {
|
|
args[i] = callDep(depName);
|
|
} else if (map.p) {
|
|
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
|
|
args[i] = defined[depName];
|
|
} else {
|
|
throw new Error(name + ' missing ' + depName);
|
|
}
|
|
}
|
|
|
|
ret = callback ? callback.apply(defined[name], args) : undefined;
|
|
|
|
if (name) {
|
|
//If setting exports via "module" is in play,
|
|
//favor that over return value and exports. After that,
|
|
//favor a non-undefined return value over exports use.
|
|
if (cjsModule && cjsModule.exports !== undef &&
|
|
cjsModule.exports !== defined[name]) {
|
|
defined[name] = cjsModule.exports;
|
|
} else if (ret !== undef || !usingExports) {
|
|
//Use the return value from the function.
|
|
defined[name] = ret;
|
|
}
|
|
}
|
|
} else if (name) {
|
|
//May just be an object definition for the module. Only
|
|
//worry about defining if have a module name.
|
|
defined[name] = callback;
|
|
}
|
|
};
|
|
|
|
requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
|
|
if (typeof deps === "string") {
|
|
if (handlers[deps]) {
|
|
//callback in this case is really relName
|
|
return handlers[deps](callback);
|
|
}
|
|
//Just return the module wanted. In this scenario, the
|
|
//deps arg is the module name, and second arg (if passed)
|
|
//is just the relName.
|
|
//Normalize module name, if it contains . or ..
|
|
return callDep(makeMap(deps, makeRelParts(callback)).f);
|
|
} else if (!deps.splice) {
|
|
//deps is a config object, not an array.
|
|
config = deps;
|
|
if (config.deps) {
|
|
req(config.deps, config.callback);
|
|
}
|
|
if (!callback) {
|
|
return;
|
|
}
|
|
|
|
if (callback.splice) {
|
|
//callback is an array, which means it is a dependency list.
|
|
//Adjust args if there are dependencies
|
|
deps = callback;
|
|
callback = relName;
|
|
relName = null;
|
|
} else {
|
|
deps = undef;
|
|
}
|
|
}
|
|
|
|
//Support require(['a'])
|
|
callback = callback || function () {};
|
|
|
|
//If relName is a function, it is an errback handler,
|
|
//so remove it.
|
|
if (typeof relName === 'function') {
|
|
relName = forceSync;
|
|
forceSync = alt;
|
|
}
|
|
|
|
//Simulate async callback;
|
|
if (forceSync) {
|
|
main(undef, deps, callback, relName);
|
|
} else {
|
|
//Using a non-zero value because of concern for what old browsers
|
|
//do, and latest browsers "upgrade" to 4 if lower value is used:
|
|
//http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
|
|
//If want a value immediately, use require('id') instead -- something
|
|
//that works in almond on the global level, but not guaranteed and
|
|
//unlikely to work in other AMD implementations.
|
|
setTimeout(function () {
|
|
main(undef, deps, callback, relName);
|
|
}, 4);
|
|
}
|
|
|
|
return req;
|
|
};
|
|
|
|
/**
|
|
* Just drops the config on the floor, but returns req in case
|
|
* the config return value is used.
|
|
*/
|
|
req.config = function (cfg) {
|
|
return req(cfg);
|
|
};
|
|
|
|
/**
|
|
* Expose module registry for debugging and tooling
|
|
*/
|
|
requirejs._defined = defined;
|
|
|
|
define = function (name, deps, callback) {
|
|
if (typeof name !== 'string') {
|
|
throw new Error('See almond README: incorrect module build, no module name');
|
|
}
|
|
|
|
//This module may not have dependencies
|
|
if (!deps.splice) {
|
|
//deps is not an array, so probably means
|
|
//an object literal or factory function for
|
|
//the value. Adjust args.
|
|
callback = deps;
|
|
deps = [];
|
|
}
|
|
|
|
if (!hasProp(defined, name) && !hasProp(waiting, name)) {
|
|
waiting[name] = [name, deps, callback];
|
|
}
|
|
};
|
|
|
|
define.amd = {
|
|
jQuery: true
|
|
};
|
|
}());
|
|
|
|
define("../node_modules/almond/almond", function(){});
|
|
|
|
define('core/EventObject',[],() => {
|
|
'use strict';
|
|
|
|
return class EventObject {
|
|
constructor() {
|
|
this.listeners = new Map();
|
|
this.forwards = new Set();
|
|
}
|
|
|
|
addEventListener(type, callback) {
|
|
const l = this.listeners.get(type);
|
|
if(l) {
|
|
l.push(callback);
|
|
} else {
|
|
this.listeners.set(type, [callback]);
|
|
}
|
|
}
|
|
|
|
removeEventListener(type, fn) {
|
|
const l = this.listeners.get(type);
|
|
if(!l) {
|
|
return;
|
|
}
|
|
const i = l.indexOf(fn);
|
|
if(i !== -1) {
|
|
l.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
countEventListeners(type) {
|
|
return (this.listeners.get(type) || []).length;
|
|
}
|
|
|
|
removeAllEventListeners(type) {
|
|
if(type) {
|
|
this.listeners.delete(type);
|
|
} else {
|
|
this.listeners.clear();
|
|
}
|
|
}
|
|
|
|
addEventForwarding(target) {
|
|
this.forwards.add(target);
|
|
}
|
|
|
|
removeEventForwarding(target) {
|
|
this.forwards.delete(target);
|
|
}
|
|
|
|
removeAllEventForwardings() {
|
|
this.forwards.clear();
|
|
}
|
|
|
|
trigger(type, params = []) {
|
|
(this.listeners.get(type) || []).forEach(
|
|
(listener) => listener.apply(null, params)
|
|
);
|
|
this.forwards.forEach((fwd) => fwd.trigger(type, params));
|
|
}
|
|
};
|
|
});
|
|
|
|
define('core/ArrayUtilities',[],() => {
|
|
'use strict';
|
|
|
|
function indexOf(list, element, equalityCheck = null) {
|
|
if(equalityCheck === null) {
|
|
return list.indexOf(element);
|
|
}
|
|
for(let i = 0; i < list.length; ++ i) {
|
|
if(equalityCheck(list[i], element)) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
function mergeSets(target, b = null, equalityCheck = null) {
|
|
if(!b) {
|
|
return;
|
|
}
|
|
for(let i = 0; i < b.length; ++ i) {
|
|
if(indexOf(target, b[i], equalityCheck) === -1) {
|
|
target.push(b[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
function hasIntersection(a, b, equalityCheck = null) {
|
|
for(let i = 0; i < b.length; ++ i) {
|
|
if(indexOf(a, b[i], equalityCheck) !== -1) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function removeAll(target, b = null, equalityCheck = null) {
|
|
if(!b) {
|
|
return;
|
|
}
|
|
for(let i = 0; i < b.length; ++ i) {
|
|
const p = indexOf(target, b[i], equalityCheck);
|
|
if(p !== -1) {
|
|
target.splice(p, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
function remove(list, item, equalityCheck = null) {
|
|
const p = indexOf(list, item, equalityCheck);
|
|
if(p !== -1) {
|
|
list.splice(p, 1);
|
|
}
|
|
}
|
|
|
|
function last(list) {
|
|
return list[list.length - 1];
|
|
}
|
|
|
|
function combineRecur(parts, position, current, target) {
|
|
if(position >= parts.length) {
|
|
target.push(current.slice());
|
|
return;
|
|
}
|
|
const choices = parts[position];
|
|
if(!Array.isArray(choices)) {
|
|
current.push(choices);
|
|
combineRecur(parts, position + 1, current, target);
|
|
current.pop();
|
|
return;
|
|
}
|
|
for(let i = 0; i < choices.length; ++ i) {
|
|
current.push(choices[i]);
|
|
combineRecur(parts, position + 1, current, target);
|
|
current.pop();
|
|
}
|
|
}
|
|
|
|
function combine(parts) {
|
|
const target = [];
|
|
combineRecur(parts, 0, [], target);
|
|
return target;
|
|
}
|
|
|
|
function flatMap(list, fn) {
|
|
const result = [];
|
|
list.forEach((item) => {
|
|
result.push(...fn(item));
|
|
});
|
|
return result;
|
|
}
|
|
|
|
return {
|
|
indexOf,
|
|
mergeSets,
|
|
hasIntersection,
|
|
removeAll,
|
|
remove,
|
|
last,
|
|
combine,
|
|
flatMap,
|
|
};
|
|
});
|
|
|
|
define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => {
|
|
'use strict';
|
|
|
|
const CM_ERROR = {type: 'error line-error', then: {'': 0}};
|
|
|
|
function suggestionsEqual(a, b) {
|
|
return (
|
|
(a.v === b.v) &&
|
|
(a.prefix === b.prefix) &&
|
|
(a.suffix === b.suffix) &&
|
|
(a.q === b.q)
|
|
);
|
|
}
|
|
|
|
const makeCommands = ((() => {
|
|
// The order of commands inside "then" blocks directly influences the
|
|
// order they are displayed to the user in autocomplete menus.
|
|
// This relies on the fact that common JS engines maintain insertion
|
|
// order in objects, though this is not guaranteed. It could be switched
|
|
// to use Map objects instead for strict compliance, at the cost of
|
|
// extra syntax.
|
|
|
|
const end = {type: '', suggest: '\n', then: {}};
|
|
const hiddenEnd = {type: '', then: {}};
|
|
|
|
function textTo(exit, suggest) {
|
|
return {
|
|
type: 'string',
|
|
suggest,
|
|
then: Object.assign({'': 0}, exit),
|
|
};
|
|
}
|
|
|
|
const textToEnd = textTo({'\n': end});
|
|
const aliasListToEnd = {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: {
|
|
'': 0,
|
|
'\n': end,
|
|
',': {type: 'operator', suggest: true, then: {'': 1}},
|
|
'as': {type: 'keyword', suggest: true, then: {
|
|
'': {type: 'variable', suggest: {known: 'Agent'}, then: {
|
|
'': 0,
|
|
',': {type: 'operator', suggest: true, then: {'': 3}},
|
|
'\n': end,
|
|
}},
|
|
}},
|
|
},
|
|
};
|
|
|
|
function agentListTo(exit) {
|
|
return {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: Object.assign({},
|
|
exit,
|
|
{
|
|
'': 0,
|
|
',': {type: 'operator', suggest: true, then: {'': 1}},
|
|
}
|
|
),
|
|
};
|
|
}
|
|
|
|
const colonTextToEnd = {
|
|
type: 'operator',
|
|
suggest: true,
|
|
then: {'': textToEnd, '\n': hiddenEnd},
|
|
};
|
|
const agentListToText = agentListTo({
|
|
':': colonTextToEnd,
|
|
});
|
|
const agentList2ToText = {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: {
|
|
'': 0,
|
|
',': {type: 'operator', suggest: true, then: {
|
|
'': agentListToText,
|
|
}},
|
|
':': CM_ERROR,
|
|
},
|
|
};
|
|
const singleAgentToText = {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: {
|
|
'': 0,
|
|
',': CM_ERROR,
|
|
':': colonTextToEnd,
|
|
},
|
|
};
|
|
const agentToOptText = {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: {
|
|
'': 0,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
'\n': hiddenEnd,
|
|
}},
|
|
'\n': end,
|
|
},
|
|
};
|
|
const referenceName = {
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textTo({
|
|
'as': {type: 'keyword', suggest: true, then: {
|
|
'': {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: {
|
|
'': 0,
|
|
'\n': end,
|
|
},
|
|
},
|
|
}},
|
|
}),
|
|
}},
|
|
};
|
|
const refDef = {type: 'keyword', suggest: true, then: Object.assign({
|
|
'over': {type: 'keyword', suggest: true, then: {
|
|
'': agentListTo(referenceName),
|
|
}},
|
|
}, referenceName)};
|
|
|
|
const divider = {
|
|
'\n': end,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
'\n': hiddenEnd,
|
|
}},
|
|
'with': {type: 'keyword', suggest: ['with height '], then: {
|
|
'height': {type: 'keyword', suggest: true, then: {
|
|
'': {type: 'number', suggest: ['6 ', '30 '], then: {
|
|
'\n': end,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
'\n': hiddenEnd,
|
|
}},
|
|
}},
|
|
}},
|
|
}},
|
|
};
|
|
|
|
function makeSideNote(side) {
|
|
return {
|
|
type: 'keyword',
|
|
suggest: [side + ' of ', side + ': '],
|
|
then: {
|
|
'of': {type: 'keyword', suggest: true, then: {
|
|
'': agentListToText,
|
|
}},
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
}},
|
|
'': agentListToText,
|
|
},
|
|
};
|
|
}
|
|
|
|
function makeOpBlock(exit, sourceExit) {
|
|
const op = {type: 'operator', suggest: true, then: {
|
|
'+': CM_ERROR,
|
|
'-': CM_ERROR,
|
|
'*': CM_ERROR,
|
|
'!': CM_ERROR,
|
|
'': exit,
|
|
}};
|
|
return {
|
|
'+': {type: 'operator', suggest: true, then: {
|
|
'+': CM_ERROR,
|
|
'-': CM_ERROR,
|
|
'*': op,
|
|
'!': CM_ERROR,
|
|
'': exit,
|
|
}},
|
|
'-': {type: 'operator', suggest: true, then: {
|
|
'+': CM_ERROR,
|
|
'-': CM_ERROR,
|
|
'*': op,
|
|
'!': {type: 'operator', then: {
|
|
'+': CM_ERROR,
|
|
'-': CM_ERROR,
|
|
'*': CM_ERROR,
|
|
'!': CM_ERROR,
|
|
'': exit,
|
|
}},
|
|
'': exit,
|
|
}},
|
|
'*': {type: 'operator', suggest: true, then: Object.assign({
|
|
'+': op,
|
|
'-': op,
|
|
'*': CM_ERROR,
|
|
'!': CM_ERROR,
|
|
'': exit,
|
|
}, sourceExit)},
|
|
'!': op,
|
|
'': exit,
|
|
};
|
|
}
|
|
|
|
function makeCMConnect(arrows) {
|
|
const connect = {
|
|
type: 'keyword',
|
|
suggest: true,
|
|
then: Object.assign({}, makeOpBlock(agentToOptText, {
|
|
':': colonTextToEnd,
|
|
'\n': hiddenEnd,
|
|
}), {
|
|
'...': {type: 'operator', suggest: true, then: {
|
|
'': {
|
|
type: 'variable',
|
|
suggest: {known: 'DelayedAgent'},
|
|
then: {
|
|
'': 0,
|
|
':': CM_ERROR,
|
|
'\n': end,
|
|
},
|
|
},
|
|
}},
|
|
}),
|
|
};
|
|
|
|
const connectors = {};
|
|
arrows.forEach((arrow) => (connectors[arrow] = connect));
|
|
|
|
const labelIndicator = {
|
|
type: 'operator',
|
|
suggest: true,
|
|
override: 'Label',
|
|
then: {},
|
|
};
|
|
|
|
const hiddenLabelIndicator = {
|
|
type: 'operator',
|
|
suggest: false,
|
|
override: 'Label',
|
|
then: {},
|
|
};
|
|
|
|
const firstAgent = {
|
|
type: 'variable',
|
|
suggest: {known: 'Agent'},
|
|
then: Object.assign({
|
|
'': 0,
|
|
':': labelIndicator,
|
|
}, connectors),
|
|
};
|
|
|
|
const firstAgentDelayed = {
|
|
type: 'variable',
|
|
suggest: {known: 'DelayedAgent'},
|
|
then: Object.assign({
|
|
'': 0,
|
|
':': hiddenLabelIndicator,
|
|
}, connectors),
|
|
};
|
|
|
|
return Object.assign({
|
|
'...': {type: 'operator', suggest: true, then: {
|
|
'': firstAgentDelayed,
|
|
}},
|
|
}, makeOpBlock(firstAgent, Object.assign({
|
|
'': firstAgent,
|
|
':': hiddenLabelIndicator,
|
|
}, connectors)));
|
|
}
|
|
|
|
const BASE_THEN = {
|
|
'title': {type: 'keyword', suggest: true, then: {
|
|
'': textToEnd,
|
|
}},
|
|
'theme': {type: 'keyword', suggest: true, then: {
|
|
'': {
|
|
type: 'string',
|
|
suggest: {
|
|
global: 'themes',
|
|
suffix: '\n',
|
|
},
|
|
then: {
|
|
'': 0,
|
|
'\n': end,
|
|
},
|
|
},
|
|
}},
|
|
'headers': {type: 'keyword', suggest: true, then: {
|
|
'none': {type: 'keyword', suggest: true, then: {}},
|
|
'cross': {type: 'keyword', suggest: true, then: {}},
|
|
'box': {type: 'keyword', suggest: true, then: {}},
|
|
'fade': {type: 'keyword', suggest: true, then: {}},
|
|
'bar': {type: 'keyword', suggest: true, then: {}},
|
|
}},
|
|
'terminators': {type: 'keyword', suggest: true, then: {
|
|
'none': {type: 'keyword', suggest: true, then: {}},
|
|
'cross': {type: 'keyword', suggest: true, then: {}},
|
|
'box': {type: 'keyword', suggest: true, then: {}},
|
|
'fade': {type: 'keyword', suggest: true, then: {}},
|
|
'bar': {type: 'keyword', suggest: true, then: {}},
|
|
}},
|
|
'divider': {type: 'keyword', suggest: true, then: Object.assign({
|
|
'line': {type: 'keyword', suggest: true, then: divider},
|
|
'space': {type: 'keyword', suggest: true, then: divider},
|
|
'delay': {type: 'keyword', suggest: true, then: divider},
|
|
'tear': {type: 'keyword', suggest: true, then: divider},
|
|
}, divider)},
|
|
'define': {type: 'keyword', suggest: true, then: {
|
|
'': aliasListToEnd,
|
|
'as': CM_ERROR,
|
|
}},
|
|
'begin': {type: 'keyword', suggest: true, then: {
|
|
'': aliasListToEnd,
|
|
'reference': refDef,
|
|
'as': CM_ERROR,
|
|
}},
|
|
'end': {type: 'keyword', suggest: true, then: {
|
|
'': aliasListToEnd,
|
|
'as': CM_ERROR,
|
|
'\n': end,
|
|
}},
|
|
'if': {type: 'keyword', suggest: true, then: {
|
|
'': textToEnd,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
}},
|
|
'\n': end,
|
|
}},
|
|
'else': {type: 'keyword', suggest: ['else\n', 'else if: '], then: {
|
|
'if': {type: 'keyword', suggest: 'if: ', then: {
|
|
'': textToEnd,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
}},
|
|
}},
|
|
'\n': end,
|
|
}},
|
|
'repeat': {type: 'keyword', suggest: true, then: {
|
|
'': textToEnd,
|
|
':': {type: 'operator', suggest: true, then: {
|
|
'': textToEnd,
|
|
}},
|
|
'\n': end,
|
|
}},
|
|
'note': {type: 'keyword', suggest: true, then: {
|
|
'over': {type: 'keyword', suggest: true, then: {
|
|
'': agentListToText,
|
|
}},
|
|
'left': makeSideNote('left'),
|
|
'right': makeSideNote('right'),
|
|
'between': {type: 'keyword', suggest: true, then: {
|
|
'': agentList2ToText,
|
|
}},
|
|
}},
|
|
'state': {type: 'keyword', suggest: 'state over ', then: {
|
|
'over': {type: 'keyword', suggest: true, then: {
|
|
'': singleAgentToText,
|
|
}},
|
|
}},
|
|
'text': {type: 'keyword', suggest: true, then: {
|
|
'left': makeSideNote('left'),
|
|
'right': makeSideNote('right'),
|
|
}},
|
|
'autolabel': {type: 'keyword', suggest: true, then: {
|
|
'off': {type: 'keyword', suggest: true, then: {}},
|
|
'': textTo({'\n': end}, [
|
|
{v: '<label>', suffix: '\n', q: true},
|
|
{v: '[<inc>] <label>', suffix: '\n', q: true},
|
|
{v: '[<inc 1,0.01>] <label>', suffix: '\n', q: true},
|
|
]),
|
|
}},
|
|
'simultaneously': {type: 'keyword', suggest: true, then: {
|
|
':': {type: 'operator', suggest: true, then: {}},
|
|
'with': {type: 'keyword', suggest: true, then: {
|
|
'': {type: 'variable', suggest: {known: 'Label'}, then: {
|
|
'': 0,
|
|
':': {type: 'operator', suggest: true, then: {}},
|
|
}},
|
|
}},
|
|
}},
|
|
};
|
|
|
|
return (arrows) => {
|
|
return {
|
|
type: 'error line-error',
|
|
then: Object.assign({}, BASE_THEN, makeCMConnect(arrows)),
|
|
};
|
|
};
|
|
})());
|
|
|
|
function cmCappedToken(token, current) {
|
|
if(Object.keys(current.then).length > 0) {
|
|
return {v: token, suffix: ' ', q: false};
|
|
} else {
|
|
return {v: token, suffix: '\n', q: false};
|
|
}
|
|
}
|
|
|
|
function cmGetSuggestions(state, token, current) {
|
|
let suggestions = current.suggest;
|
|
if(!Array.isArray(suggestions)) {
|
|
suggestions = [suggestions];
|
|
}
|
|
|
|
return array.flatMap(suggestions, (suggest) => {
|
|
if(suggest === true) {
|
|
return [cmCappedToken(token, current)];
|
|
} else if(typeof suggest === 'object') {
|
|
if(suggest.known) {
|
|
return state['known' + suggest.known] || [];
|
|
} else {
|
|
return [suggest];
|
|
}
|
|
} else if(typeof suggest === 'string' && suggest) {
|
|
return [{v: suggest, q: (token === '')}];
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
}
|
|
|
|
function cmMakeCompletions(state, path) {
|
|
const comp = [];
|
|
const current = array.last(path);
|
|
Object.keys(current.then).forEach((token) => {
|
|
let next = current.then[token];
|
|
if(typeof next === 'number') {
|
|
next = path[path.length - next - 1];
|
|
}
|
|
array.mergeSets(
|
|
comp,
|
|
cmGetSuggestions(state, token, next),
|
|
suggestionsEqual
|
|
);
|
|
});
|
|
return comp;
|
|
}
|
|
|
|
function updateSuggestion(state, locals, token, {suggest, override}) {
|
|
let known = null;
|
|
if(typeof suggest === 'object' && suggest.known) {
|
|
known = suggest.known;
|
|
}
|
|
if(locals.type && known !== locals.type) {
|
|
if(override) {
|
|
locals.type = override;
|
|
}
|
|
array.mergeSets(
|
|
state['known' + locals.type],
|
|
[{v: locals.value, suffix: ' ', q: true}],
|
|
suggestionsEqual
|
|
);
|
|
locals.type = '';
|
|
locals.value = '';
|
|
}
|
|
if(known) {
|
|
locals.type = known;
|
|
if(locals.value) {
|
|
locals.value += token.s;
|
|
}
|
|
locals.value += token.v;
|
|
}
|
|
}
|
|
|
|
function cmCheckToken(state, eol, commands) {
|
|
const suggestions = {
|
|
type: '',
|
|
value: '',
|
|
};
|
|
let current = commands;
|
|
const path = [current];
|
|
|
|
state.line.forEach((token, i) => {
|
|
if(i === state.line.length - 1) {
|
|
state.completions = cmMakeCompletions(state, path);
|
|
}
|
|
const keywordToken = token.q ? '' : token.v;
|
|
let found = current.then[keywordToken];
|
|
if(found === undefined) {
|
|
found = current.then[''];
|
|
state.isVar = true;
|
|
} else {
|
|
state.isVar = token.q;
|
|
}
|
|
if(typeof found === 'number') {
|
|
path.length -= found;
|
|
} else {
|
|
path.push(found || CM_ERROR);
|
|
}
|
|
current = array.last(path);
|
|
updateSuggestion(state, suggestions, token, current);
|
|
});
|
|
if(eol) {
|
|
updateSuggestion(state, suggestions, null, {});
|
|
}
|
|
state.nextCompletions = cmMakeCompletions(state, path);
|
|
state.valid = (
|
|
Boolean(current.then['\n']) ||
|
|
Object.keys(current.then).length === 0
|
|
);
|
|
return current.type;
|
|
}
|
|
|
|
function getInitialToken(block) {
|
|
const baseToken = (block.baseToken || {});
|
|
return {
|
|
value: baseToken.v || '',
|
|
quoted: baseToken.q || false,
|
|
};
|
|
}
|
|
|
|
return class Mode {
|
|
constructor(tokenDefinitions, arrows) {
|
|
this.tokenDefinitions = tokenDefinitions;
|
|
this.commands = makeCommands(arrows);
|
|
this.lineComment = '#';
|
|
}
|
|
|
|
startState() {
|
|
return {
|
|
currentType: -1,
|
|
current: '',
|
|
currentSpace: '',
|
|
currentQuoted: false,
|
|
knownAgent: [],
|
|
knownDelayedAgent: [],
|
|
knownLabel: [],
|
|
beginCompletions: cmMakeCompletions({}, [this.commands]),
|
|
completions: [],
|
|
nextCompletions: [],
|
|
valid: true,
|
|
isVar: true,
|
|
line: [],
|
|
indent: 0,
|
|
};
|
|
}
|
|
|
|
_matchPattern(stream, pattern, consume) {
|
|
if(!pattern) {
|
|
return null;
|
|
}
|
|
pattern.lastIndex = 0;
|
|
return stream.match(pattern, consume);
|
|
}
|
|
|
|
_tokenBegin(stream, state) {
|
|
state.currentSpace = '';
|
|
let lastChar = '';
|
|
while(true) {
|
|
if(stream.eol()) {
|
|
return false;
|
|
}
|
|
state.currentSpace += lastChar;
|
|
for(let i = 0; i < this.tokenDefinitions.length; ++ i) {
|
|
const block = this.tokenDefinitions[i];
|
|
if(this._matchPattern(stream, block.start, true)) {
|
|
state.currentType = i;
|
|
const {value, quoted} = getInitialToken(block);
|
|
state.current = value;
|
|
state.currentQuoted = quoted;
|
|
return true;
|
|
}
|
|
}
|
|
lastChar = stream.next();
|
|
}
|
|
}
|
|
|
|
_tokenCheckEscape(stream, state, block) {
|
|
const match = this._matchPattern(stream, block.escape, true);
|
|
if(match) {
|
|
state.current += block.escapeWith(match);
|
|
}
|
|
}
|
|
|
|
_addToken(state) {
|
|
state.line.push({
|
|
v: state.current,
|
|
s: state.currentSpace,
|
|
q: state.currentQuoted,
|
|
});
|
|
}
|
|
|
|
_tokenEndFound(stream, state, block, match) {
|
|
state.currentType = -1;
|
|
if(block.includeEnd) {
|
|
state.current += match[0];
|
|
}
|
|
if(block.omit) {
|
|
return 'comment';
|
|
}
|
|
this._addToken(state);
|
|
return cmCheckToken(state, stream.eol(), this.commands);
|
|
}
|
|
|
|
_tokenEOLFound(stream, state, block) {
|
|
state.current += '\n';
|
|
if(block.omit) {
|
|
return 'comment';
|
|
}
|
|
this._addToken(state);
|
|
const type = cmCheckToken(state, false, this.commands);
|
|
state.line.pop();
|
|
return type;
|
|
}
|
|
|
|
_tokenEnd(stream, state) {
|
|
while(true) {
|
|
const block = this.tokenDefinitions[state.currentType];
|
|
this._tokenCheckEscape(stream, state, block);
|
|
if(!block.end) {
|
|
return this._tokenEndFound(stream, state, block, null);
|
|
} else {
|
|
const match = this._matchPattern(stream, block.end, true);
|
|
if(match) {
|
|
return this._tokenEndFound(stream, state, block, match);
|
|
}
|
|
}
|
|
if(stream.eol()) {
|
|
return this._tokenEOLFound(stream, state, block);
|
|
}
|
|
state.current += stream.next();
|
|
}
|
|
}
|
|
|
|
token(stream, state) {
|
|
state.completions = state.nextCompletions;
|
|
state.isVar = true;
|
|
if(stream.sol() && state.currentType === -1) {
|
|
state.line.length = 0;
|
|
}
|
|
let type = '';
|
|
if(state.currentType !== -1 || this._tokenBegin(stream, state)) {
|
|
type = this._tokenEnd(stream, state);
|
|
}
|
|
if(state.currentType === -1 && stream.eol() && !state.valid) {
|
|
return 'line-error ' + type;
|
|
} else {
|
|
return type;
|
|
}
|
|
}
|
|
|
|
indent(state) {
|
|
return state.indent;
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/Tokeniser',['./CodeMirrorMode'], (CMMode) => {
|
|
'use strict';
|
|
|
|
function execAt(str, reg, i) {
|
|
reg.lastIndex = i;
|
|
return reg.exec(str);
|
|
}
|
|
|
|
function unescape(match) {
|
|
const c = match[1];
|
|
if(c === 'n') {
|
|
return '\n';
|
|
}
|
|
return match[1];
|
|
}
|
|
|
|
const TOKENS = [
|
|
{start: /#/y, end: /(?=\n)|$/y, omit: true},
|
|
{
|
|
start: /"/y,
|
|
end: /"/y,
|
|
escape: /\\(.)/y,
|
|
escapeWith: unescape,
|
|
baseToken: {q: true},
|
|
},
|
|
{start: /\.\.\./y, baseToken: {v: '...'}},
|
|
{start: /(?=[^ \t\r\n:+\-~*!<>,])/y, end: /(?=[ \t\r\n:+\-~*!<>,])|$/y},
|
|
{
|
|
start: /(?=[\-~<])/y,
|
|
end: /(?=[^\-~<>x])|[\-~]x|[<>](?=x)|$/y,
|
|
includeEnd: true,
|
|
},
|
|
{start: /,/y, baseToken: {v: ','}},
|
|
{start: /:/y, baseToken: {v: ':'}},
|
|
{start: /!/y, baseToken: {v: '!'}},
|
|
{start: /\+/y, baseToken: {v: '+'}},
|
|
{start: /\*/y, baseToken: {v: '*'}},
|
|
{start: /\n/y, baseToken: {v: '\n'}},
|
|
];
|
|
|
|
function tokFindBegin(src, i) {
|
|
for(let j = 0; j < TOKENS.length; ++ j) {
|
|
const block = TOKENS[j];
|
|
const match = execAt(src, block.start, i);
|
|
if(match) {
|
|
return {
|
|
newBlock: block,
|
|
end: !block.end,
|
|
appendSpace: '',
|
|
appendValue: '',
|
|
skip: match[0].length,
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
newBlock: null,
|
|
end: false,
|
|
appendSpace: src[i],
|
|
appendValue: '',
|
|
skip: 1,
|
|
};
|
|
}
|
|
|
|
function tokContinuePart(src, i, block) {
|
|
if(block.escape) {
|
|
const match = execAt(src, block.escape, i);
|
|
if(match) {
|
|
return {
|
|
newBlock: null,
|
|
end: false,
|
|
appendSpace: '',
|
|
appendValue: block.escapeWith(match),
|
|
skip: match[0].length,
|
|
};
|
|
}
|
|
}
|
|
const match = execAt(src, block.end, i);
|
|
if(match) {
|
|
return {
|
|
newBlock: null,
|
|
end: true,
|
|
appendSpace: '',
|
|
appendValue: block.includeEnd ? match[0] : '',
|
|
skip: match[0].length,
|
|
};
|
|
}
|
|
return {
|
|
newBlock: null,
|
|
end: false,
|
|
appendSpace: '',
|
|
appendValue: src[i],
|
|
skip: 1,
|
|
};
|
|
}
|
|
|
|
function tokAdvance(src, i, block) {
|
|
if(block) {
|
|
return tokContinuePart(src, i, block);
|
|
} else {
|
|
return tokFindBegin(src, i);
|
|
}
|
|
}
|
|
|
|
function copyPos(pos) {
|
|
return {i: pos.i, ln: pos.ln, ch: pos.ch};
|
|
}
|
|
|
|
function advancePos(pos, src, steps) {
|
|
for(let i = 0; i < steps; ++ i) {
|
|
++ pos.ch;
|
|
if(src[pos.i + i] === '\n') {
|
|
++ pos.ln;
|
|
pos.ch = 0;
|
|
}
|
|
}
|
|
pos.i += steps;
|
|
}
|
|
|
|
class TokenState {
|
|
constructor(src) {
|
|
this.src = src;
|
|
this.block = null;
|
|
this.token = null;
|
|
this.pos = {i: 0, ln: 0, ch: 0};
|
|
this.reset();
|
|
}
|
|
|
|
isOver() {
|
|
return this.pos.i > this.src.length;
|
|
}
|
|
|
|
reset() {
|
|
this.token = {s: '', v: '', q: false, b: null, e: null};
|
|
this.block = null;
|
|
}
|
|
|
|
beginToken(advance) {
|
|
this.block = advance.newBlock;
|
|
Object.assign(this.token, this.block.baseToken);
|
|
this.token.b = copyPos(this.pos);
|
|
}
|
|
|
|
endToken() {
|
|
let token = null;
|
|
if(!this.block.omit) {
|
|
this.token.e = copyPos(this.pos);
|
|
token = this.token;
|
|
}
|
|
this.reset();
|
|
return token;
|
|
}
|
|
|
|
advance() {
|
|
const advance = tokAdvance(this.src, this.pos.i, this.block);
|
|
|
|
if(advance.newBlock) {
|
|
this.beginToken(advance);
|
|
}
|
|
|
|
this.token.s += advance.appendSpace;
|
|
this.token.v += advance.appendValue;
|
|
advancePos(this.pos, this.src, advance.skip);
|
|
|
|
if(advance.end) {
|
|
return this.endToken();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
function posStr(pos) {
|
|
return 'line ' + (pos.ln + 1) + ', character ' + pos.ch;
|
|
}
|
|
|
|
return class Tokeniser {
|
|
tokenise(src) {
|
|
const tokens = [];
|
|
const state = new TokenState(src);
|
|
while(!state.isOver()) {
|
|
const token = state.advance();
|
|
if(token) {
|
|
tokens.push(token);
|
|
}
|
|
}
|
|
if(state.block) {
|
|
throw new Error(
|
|
'Unterminated literal (began at ' +
|
|
posStr(state.token.b) + ')'
|
|
);
|
|
}
|
|
return tokens;
|
|
}
|
|
|
|
getCodeMirrorMode(arrows) {
|
|
return new CMMode(TOKENS, arrows);
|
|
}
|
|
|
|
splitLines(tokens) {
|
|
const lines = [];
|
|
let line = [];
|
|
tokens.forEach((token) => {
|
|
if(!token.q && token.v === '\n') {
|
|
if(line.length > 0) {
|
|
lines.push(line);
|
|
line = [];
|
|
}
|
|
} else {
|
|
line.push(token);
|
|
}
|
|
});
|
|
if(line.length > 0) {
|
|
lines.push(line);
|
|
}
|
|
return lines;
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/MarkdownParser',[],() => {
|
|
'use strict';
|
|
|
|
const STYLES = [
|
|
{
|
|
begin: /[\s_~`]\*(?=\S)/g,
|
|
end: /\S\*(?=[\s_~`])/g,
|
|
attrs: {'font-style': 'italic'},
|
|
}, {
|
|
begin: /[\s*~`]_(?=\S)/g,
|
|
end: /\S_(?=[\s*~`])/g,
|
|
attrs: {'font-style': 'italic'},
|
|
}, {
|
|
begin: /[\s_~`]\*\*(?=\S)/g,
|
|
end: /\S\*\*(?=[\s_~`])/g,
|
|
attrs: {'font-weight': 'bolder'},
|
|
}, {
|
|
begin: /[\s*~`]__(?=\S)/g,
|
|
end: /\S__(?=[\s*~`])/g,
|
|
attrs: {'font-weight': 'bolder'},
|
|
}, {
|
|
begin: /[\s_*`]~(?=\S)/g,
|
|
end: /\S~(?=[\s_*`])/g,
|
|
attrs: {'text-decoration': 'line-through'},
|
|
}, {
|
|
begin: /[\s_*~.]`(?=\S)/g,
|
|
end: /\S`(?=[\s_*~.])/g,
|
|
attrs: {'font-family': 'monospace'},
|
|
},
|
|
];
|
|
|
|
function findNext(line, p, active) {
|
|
const virtLine = ' ' + line + ' ';
|
|
let styleIndex = -1;
|
|
let bestStart = virtLine.length;
|
|
let bestEnd = 0;
|
|
|
|
STYLES.forEach(({begin, end, attrs}, ind) => {
|
|
const search = active[ind] ? end : begin;
|
|
search.lastIndex = p;
|
|
const m = search.exec(virtLine);
|
|
if(m && (
|
|
m.index < bestStart ||
|
|
(m.index === bestStart && search.lastIndex > bestEnd)
|
|
)) {
|
|
styleIndex = ind;
|
|
bestStart = m.index;
|
|
bestEnd = search.lastIndex;
|
|
}
|
|
});
|
|
|
|
return {styleIndex, start: bestStart, end: bestEnd - 1};
|
|
}
|
|
|
|
function combineAttrs(activeCount, active) {
|
|
if(!activeCount) {
|
|
return null;
|
|
}
|
|
const attrs = {};
|
|
active.forEach((on, ind) => {
|
|
if(on) {
|
|
Object.assign(attrs, STYLES[ind].attrs);
|
|
}
|
|
});
|
|
return attrs;
|
|
}
|
|
|
|
function parseMarkdown(text) {
|
|
if(!text) {
|
|
return [];
|
|
}
|
|
|
|
const active = STYLES.map(() => false);
|
|
let activeCount = 0;
|
|
let attrs = null;
|
|
const lines = text.split('\n');
|
|
const result = [];
|
|
lines.forEach((line) => {
|
|
const parts = [];
|
|
let p = 0;
|
|
while(true) {
|
|
const {styleIndex, start, end} = findNext(line, p, active);
|
|
if(styleIndex === -1) {
|
|
break;
|
|
}
|
|
if(active[styleIndex]) {
|
|
active[styleIndex] = false;
|
|
-- activeCount;
|
|
} else {
|
|
active[styleIndex] = true;
|
|
++ activeCount;
|
|
}
|
|
if(start > p) {
|
|
parts.push({text: line.substring(p, start), attrs});
|
|
}
|
|
attrs = combineAttrs(activeCount, active);
|
|
p = end;
|
|
}
|
|
if(p < line.length) {
|
|
parts.push({text: line.substr(p), attrs});
|
|
}
|
|
result.push(parts);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
return parseMarkdown;
|
|
});
|
|
|
|
define('sequence/LabelPatternParser',[],() => {
|
|
'use strict';
|
|
|
|
const LABEL_PATTERN = /(.*?)<([^<>]*)>/g;
|
|
const DP_PATTERN = /\.([0-9]*)/;
|
|
|
|
function countDP(value) {
|
|
const match = DP_PATTERN.exec(value);
|
|
if(!match || !match[1]) {
|
|
return 0;
|
|
}
|
|
return match[1].length;
|
|
}
|
|
|
|
function parseCounter(args) {
|
|
let start = 1;
|
|
let inc = 1;
|
|
let dp = 0;
|
|
if(args[0]) {
|
|
start = Number(args[0]);
|
|
dp = Math.max(dp, countDP(args[0]));
|
|
}
|
|
if(args[1]) {
|
|
inc = Number(args[1]);
|
|
dp = Math.max(dp, countDP(args[1]));
|
|
}
|
|
return {start, inc, dp};
|
|
}
|
|
|
|
function parseToken(token) {
|
|
if(token === 'label') {
|
|
return {token: 'label'};
|
|
}
|
|
|
|
const p = token.indexOf(' ');
|
|
let type = null;
|
|
let args = null;
|
|
if(p === -1) {
|
|
type = token;
|
|
args = [];
|
|
} else {
|
|
type = token.substr(0, p);
|
|
args = token.substr(p + 1).split(',');
|
|
}
|
|
|
|
if(type === 'inc') {
|
|
return parseCounter(args);
|
|
}
|
|
|
|
return '<' + token + '>';
|
|
}
|
|
|
|
function parsePattern(raw) {
|
|
const pattern = [];
|
|
let match = null;
|
|
let end = 0;
|
|
LABEL_PATTERN.lastIndex = 0;
|
|
while((match = LABEL_PATTERN.exec(raw))) {
|
|
if(match[1]) {
|
|
pattern.push(match[1]);
|
|
}
|
|
if(match[2]) {
|
|
pattern.push(parseToken(match[2]));
|
|
}
|
|
end = LABEL_PATTERN.lastIndex;
|
|
}
|
|
const remainder = raw.substr(end);
|
|
if(remainder) {
|
|
pattern.push(remainder);
|
|
}
|
|
return pattern;
|
|
}
|
|
|
|
return parsePattern;
|
|
});
|
|
|
|
define('sequence/Parser',[
|
|
'core/ArrayUtilities',
|
|
'./Tokeniser',
|
|
'./MarkdownParser',
|
|
'./LabelPatternParser',
|
|
], (
|
|
array,
|
|
Tokeniser,
|
|
markdownParser,
|
|
labelPatternParser
|
|
) => {
|
|
'use strict';
|
|
|
|
const BLOCK_TYPES = {
|
|
'if': {
|
|
type: 'block begin',
|
|
blockType: 'if',
|
|
tag: 'if',
|
|
skip: [],
|
|
},
|
|
'else': {
|
|
type: 'block split',
|
|
blockType: 'else',
|
|
tag: 'else',
|
|
skip: ['if'],
|
|
},
|
|
'repeat': {
|
|
type: 'block begin',
|
|
blockType: 'repeat',
|
|
tag: 'repeat',
|
|
skip: [],
|
|
},
|
|
};
|
|
|
|
const CONNECT = {
|
|
types: ((() => {
|
|
const lTypes = [
|
|
{tok: '', type: 0},
|
|
{tok: '<', type: 1},
|
|
{tok: '<<', type: 2},
|
|
];
|
|
const mTypes = [
|
|
{tok: '-', type: 'solid'},
|
|
{tok: '--', type: 'dash'},
|
|
{tok: '~', type: 'wave'},
|
|
];
|
|
const rTypes = [
|
|
{tok: '', type: 0},
|
|
{tok: '>', type: 1},
|
|
{tok: '>>', type: 2},
|
|
{tok: 'x', type: 3},
|
|
];
|
|
const arrows = (array.combine([lTypes, mTypes, rTypes])
|
|
.filter((arrow) => (arrow[0].type !== 0 || arrow[2].type !== 0))
|
|
);
|
|
|
|
const types = new Map();
|
|
|
|
arrows.forEach((arrow) => {
|
|
types.set(arrow.map((part) => part.tok).join(''), {
|
|
line: arrow[1].type,
|
|
left: arrow[0].type,
|
|
right: arrow[2].type,
|
|
});
|
|
});
|
|
|
|
return types;
|
|
})()),
|
|
|
|
agentFlags: {
|
|
'*': {flag: 'begin', allowBlankName: true, blankNameFlag: 'source'},
|
|
'+': {flag: 'start'},
|
|
'-': {flag: 'stop'},
|
|
'!': {flag: 'end'},
|
|
},
|
|
};
|
|
|
|
const TERMINATOR_TYPES = [
|
|
'none',
|
|
'box',
|
|
'cross',
|
|
'fade',
|
|
'bar',
|
|
];
|
|
|
|
const NOTE_TYPES = {
|
|
'text': {
|
|
mode: 'text',
|
|
types: {
|
|
'left': {type: 'note left', skip: ['of'], min: 0, max: null},
|
|
'right': {type: 'note right', skip: ['of'], min: 0, max: null},
|
|
},
|
|
},
|
|
'note': {
|
|
mode: 'note',
|
|
types: {
|
|
'over': {type: 'note over', skip: [], min: 0, max: null},
|
|
'left': {type: 'note left', skip: ['of'], min: 0, max: null},
|
|
'right': {type: 'note right', skip: ['of'], min: 0, max: null},
|
|
'between': {type: 'note between', skip: [], min: 2, max: null},
|
|
},
|
|
},
|
|
'state': {
|
|
mode: 'state',
|
|
types: {
|
|
'over': {type: 'note over', skip: [], min: 1, max: 1},
|
|
},
|
|
},
|
|
};
|
|
|
|
const DIVIDER_TYPES = {
|
|
'line': {defaultHeight: 6},
|
|
'space': {defaultHeight: 6},
|
|
'delay': {defaultHeight: 30},
|
|
'tear': {defaultHeight: 6},
|
|
};
|
|
|
|
const AGENT_MANIPULATION_TYPES = {
|
|
'define': {type: 'agent define'},
|
|
'begin': {type: 'agent begin', mode: 'box'},
|
|
'end': {type: 'agent end', mode: 'cross'},
|
|
};
|
|
|
|
function makeError(message, token = null) {
|
|
let suffix = '';
|
|
if(token) {
|
|
suffix = (
|
|
' at line ' + (token.b.ln + 1) +
|
|
', character ' + token.b.ch
|
|
);
|
|
}
|
|
return new Error(message + suffix);
|
|
}
|
|
|
|
function joinLabel(line, begin = 0, end = null) {
|
|
if(end === null) {
|
|
end = line.length;
|
|
}
|
|
if(end <= begin) {
|
|
return '';
|
|
}
|
|
let result = line[begin].v;
|
|
for(let i = begin + 1; i < end; ++ i) {
|
|
result += line[i].s + line[i].v;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function readNumber(line, begin = 0, end = null, def = Number.NAN) {
|
|
const text = joinLabel(line, begin, end);
|
|
return Number(text || def);
|
|
}
|
|
|
|
function tokenKeyword(token) {
|
|
if(!token || token.q) {
|
|
return null;
|
|
}
|
|
return token.v;
|
|
}
|
|
|
|
function skipOver(line, start, skip, error = null) {
|
|
for(let i = 0; i < skip.length; ++ i) {
|
|
const expected = skip[i];
|
|
const token = line[start + i];
|
|
if(tokenKeyword(token) !== expected) {
|
|
if(error) {
|
|
throw makeError(
|
|
error + '; expected "' + expected + '"',
|
|
token
|
|
);
|
|
} else {
|
|
return start;
|
|
}
|
|
}
|
|
}
|
|
return start + skip.length;
|
|
}
|
|
|
|
function findToken(line, tokens, {
|
|
start = 0,
|
|
limit = null,
|
|
orEnd = false,
|
|
} = {}) {
|
|
if(limit === null) {
|
|
limit = line.length;
|
|
}
|
|
if(!Array.isArray(tokens)) {
|
|
tokens = [tokens];
|
|
}
|
|
for(let i = start; i <= limit - tokens.length; ++ i) {
|
|
if(skipOver(line, i, tokens) !== i) {
|
|
return i;
|
|
}
|
|
}
|
|
return orEnd ? limit : -1;
|
|
}
|
|
|
|
function findFirstToken(line, tokenMap, {start = 0, limit = null} = {}) {
|
|
if(limit === null) {
|
|
limit = line.length;
|
|
}
|
|
for(let pos = start; pos < limit; ++ pos) {
|
|
const value = tokenMap.get(tokenKeyword(line[pos]));
|
|
if(value) {
|
|
return {pos, value};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function readAgentAlias(line, start, end, {enableAlias, allowBlankName}) {
|
|
let aliasSep = -1;
|
|
if(enableAlias) {
|
|
aliasSep = findToken(line, 'as', {start});
|
|
}
|
|
if(aliasSep === -1 || aliasSep >= end) {
|
|
aliasSep = end;
|
|
}
|
|
if(start >= aliasSep && !allowBlankName) {
|
|
let errPosToken = line[start];
|
|
if(!errPosToken) {
|
|
errPosToken = {b: array.last(line).e};
|
|
}
|
|
throw makeError('Missing agent name', errPosToken);
|
|
}
|
|
return {
|
|
name: joinLabel(line, start, aliasSep),
|
|
alias: joinLabel(line, aliasSep + 1, end),
|
|
};
|
|
}
|
|
|
|
function readAgent(line, start, end, {
|
|
flagTypes = {},
|
|
aliases = false,
|
|
} = {}) {
|
|
const flags = [];
|
|
const blankNameFlags = [];
|
|
let p = start;
|
|
let allowBlankName = false;
|
|
for(; p < end; ++ p) {
|
|
const token = line[p];
|
|
const rawFlag = tokenKeyword(token);
|
|
const flag = flagTypes[rawFlag];
|
|
if(!flag) {
|
|
break;
|
|
}
|
|
if(flags.includes(flag.flag)) {
|
|
throw makeError('Duplicate agent flag: ' + rawFlag, token);
|
|
}
|
|
allowBlankName = allowBlankName || Boolean(flag.allowBlankName);
|
|
flags.push(flag.flag);
|
|
blankNameFlags.push(flag.blankNameFlag);
|
|
}
|
|
const {name, alias} = readAgentAlias(line, p, end, {
|
|
enableAlias: aliases,
|
|
allowBlankName,
|
|
});
|
|
return {
|
|
name,
|
|
alias,
|
|
flags: name ? flags : blankNameFlags,
|
|
};
|
|
}
|
|
|
|
function readAgentList(line, start, end, readAgentOpts) {
|
|
const list = [];
|
|
let currentStart = -1;
|
|
for(let i = start; i < end; ++ i) {
|
|
const token = line[i];
|
|
if(tokenKeyword(token) === ',') {
|
|
if(currentStart !== -1) {
|
|
list.push(readAgent(line, currentStart, i, readAgentOpts));
|
|
currentStart = -1;
|
|
}
|
|
} else if(currentStart === -1) {
|
|
currentStart = i;
|
|
}
|
|
}
|
|
if(currentStart !== -1) {
|
|
list.push(readAgent(line, currentStart, end, readAgentOpts));
|
|
}
|
|
return list;
|
|
}
|
|
|
|
const PARSERS = [
|
|
(line, meta) => { // title
|
|
if(tokenKeyword(line[0]) !== 'title') {
|
|
return null;
|
|
}
|
|
|
|
meta.title = joinLabel(line, 1);
|
|
return true;
|
|
},
|
|
|
|
(line, meta) => { // theme
|
|
if(tokenKeyword(line[0]) !== 'theme') {
|
|
return null;
|
|
}
|
|
|
|
meta.theme = joinLabel(line, 1);
|
|
return true;
|
|
},
|
|
|
|
(line, meta) => { // terminators
|
|
if(tokenKeyword(line[0]) !== 'terminators') {
|
|
return null;
|
|
}
|
|
|
|
const type = tokenKeyword(line[1]);
|
|
if(!type) {
|
|
throw makeError('Unspecified termination', line[0]);
|
|
}
|
|
if(TERMINATOR_TYPES.indexOf(type) === -1) {
|
|
throw makeError('Unknown termination "' + type + '"', line[1]);
|
|
}
|
|
meta.terminators = type;
|
|
return true;
|
|
},
|
|
|
|
(line, meta) => { // headers
|
|
if(tokenKeyword(line[0]) !== 'headers') {
|
|
return null;
|
|
}
|
|
|
|
const type = tokenKeyword(line[1]);
|
|
if(!type) {
|
|
throw makeError('Unspecified header', line[0]);
|
|
}
|
|
if(TERMINATOR_TYPES.indexOf(type) === -1) {
|
|
throw makeError('Unknown header "' + type + '"', line[1]);
|
|
}
|
|
meta.headers = type;
|
|
return true;
|
|
},
|
|
|
|
(line) => { // divider
|
|
if(tokenKeyword(line[0]) !== 'divider') {
|
|
return null;
|
|
}
|
|
|
|
const labelSep = findToken(line, ':', {orEnd: true});
|
|
const heightSep = findToken(line, ['with', 'height'], {
|
|
limit: labelSep,
|
|
orEnd: true,
|
|
});
|
|
|
|
const mode = joinLabel(line, 1, heightSep) || 'line';
|
|
if(!DIVIDER_TYPES[mode]) {
|
|
throw makeError('Unknown divider type', line[1]);
|
|
}
|
|
|
|
const height = readNumber(
|
|
line,
|
|
heightSep + 2,
|
|
labelSep,
|
|
DIVIDER_TYPES[mode].defaultHeight
|
|
);
|
|
if(Number.isNaN(height) || height < 0) {
|
|
throw makeError('Invalid divider height', line[heightSep+2]);
|
|
}
|
|
|
|
return {
|
|
type: 'divider',
|
|
mode,
|
|
height,
|
|
label: joinLabel(line, labelSep + 1),
|
|
};
|
|
},
|
|
|
|
(line) => { // autolabel
|
|
if(tokenKeyword(line[0]) !== 'autolabel') {
|
|
return null;
|
|
}
|
|
|
|
let raw = null;
|
|
if(tokenKeyword(line[1]) === 'off') {
|
|
raw = '<label>';
|
|
} else {
|
|
raw = joinLabel(line, 1);
|
|
}
|
|
return {
|
|
type: 'label pattern',
|
|
pattern: labelPatternParser(raw),
|
|
};
|
|
},
|
|
|
|
(line) => { // block
|
|
if(tokenKeyword(line[0]) === 'end' && line.length === 1) {
|
|
return {type: 'block end'};
|
|
}
|
|
|
|
const type = BLOCK_TYPES[tokenKeyword(line[0])];
|
|
if(!type) {
|
|
return null;
|
|
}
|
|
let skip = 1;
|
|
if(line.length > skip) {
|
|
skip = skipOver(line, skip, type.skip, 'Invalid block command');
|
|
}
|
|
skip = skipOver(line, skip, [':']);
|
|
return {
|
|
type: type.type,
|
|
blockType: type.blockType,
|
|
tag: type.tag,
|
|
label: joinLabel(line, skip),
|
|
};
|
|
},
|
|
|
|
(line) => { // begin reference
|
|
if(
|
|
tokenKeyword(line[0]) !== 'begin' ||
|
|
tokenKeyword(line[1]) !== 'reference'
|
|
) {
|
|
return null;
|
|
}
|
|
let agents = [];
|
|
const labelSep = findToken(line, ':');
|
|
if(tokenKeyword(line[2]) === 'over' && labelSep > 3) {
|
|
agents = readAgentList(line, 3, labelSep);
|
|
} else if(labelSep !== 2) {
|
|
throw makeError('Expected ":" or "over"', line[2]);
|
|
}
|
|
const def = readAgent(
|
|
line,
|
|
labelSep + 1,
|
|
line.length,
|
|
{aliases: true}
|
|
);
|
|
if(!def.alias) {
|
|
throw makeError('Reference must have an alias', line[labelSep]);
|
|
}
|
|
return {
|
|
type: 'group begin',
|
|
agents,
|
|
blockType: 'ref',
|
|
tag: 'ref',
|
|
label: def.name,
|
|
alias: def.alias,
|
|
};
|
|
},
|
|
|
|
(line) => { // agent
|
|
const type = AGENT_MANIPULATION_TYPES[tokenKeyword(line[0])];
|
|
if(!type || line.length <= 1) {
|
|
return null;
|
|
}
|
|
return Object.assign({
|
|
agents: readAgentList(line, 1, line.length, {aliases: true}),
|
|
}, type);
|
|
},
|
|
|
|
(line) => { // async
|
|
if(tokenKeyword(line[0]) !== 'simultaneously') {
|
|
return null;
|
|
}
|
|
if(tokenKeyword(array.last(line)) !== ':') {
|
|
return null;
|
|
}
|
|
let target = '';
|
|
if(line.length > 2) {
|
|
if(tokenKeyword(line[1]) !== 'with') {
|
|
return null;
|
|
}
|
|
target = joinLabel(line, 2, line.length - 1);
|
|
}
|
|
return {
|
|
type: 'async',
|
|
target,
|
|
};
|
|
},
|
|
|
|
(line) => { // note
|
|
const mode = NOTE_TYPES[tokenKeyword(line[0])];
|
|
const labelSep = findToken(line, ':');
|
|
if(!mode || labelSep === -1) {
|
|
return null;
|
|
}
|
|
const type = mode.types[tokenKeyword(line[1])];
|
|
if(!type) {
|
|
return null;
|
|
}
|
|
let skip = 2;
|
|
skip = skipOver(line, skip, type.skip);
|
|
const agents = readAgentList(line, skip, labelSep);
|
|
if(agents.length < type.min) {
|
|
throw makeError('Too few agents for ' + mode.mode, line[0]);
|
|
}
|
|
if(type.max !== null && agents.length > type.max) {
|
|
throw makeError('Too many agents for ' + mode.mode, line[0]);
|
|
}
|
|
return {
|
|
type: type.type,
|
|
agents,
|
|
mode: mode.mode,
|
|
label: joinLabel(line, labelSep + 1),
|
|
};
|
|
},
|
|
|
|
(line) => { // connect
|
|
const labelSep = findToken(line, ':', {orEnd: true});
|
|
const connectionToken = findFirstToken(
|
|
line,
|
|
CONNECT.types,
|
|
{start: 0, limit: labelSep - 1}
|
|
);
|
|
if(!connectionToken) {
|
|
return null;
|
|
}
|
|
|
|
const connectPos = connectionToken.pos;
|
|
|
|
const readOpts = {
|
|
flagTypes: CONNECT.agentFlags,
|
|
};
|
|
|
|
if(tokenKeyword(line[0]) === '...') {
|
|
return {
|
|
type: 'connect-delay-end',
|
|
tag: joinLabel(line, 1, connectPos),
|
|
agent: readAgent(line, connectPos + 1, labelSep, readOpts),
|
|
label: joinLabel(line, labelSep + 1),
|
|
options: connectionToken.value,
|
|
};
|
|
} else if(tokenKeyword(line[connectPos + 1]) === '...') {
|
|
if(labelSep !== line.length) {
|
|
throw makeError(
|
|
'Cannot label beginning of delayed connection',
|
|
line[labelSep]
|
|
);
|
|
}
|
|
return {
|
|
type: 'connect-delay-begin',
|
|
tag: joinLabel(line, connectPos + 2, labelSep),
|
|
agent: readAgent(line, 0, connectPos, readOpts),
|
|
options: connectionToken.value,
|
|
};
|
|
} else {
|
|
return {
|
|
type: 'connect',
|
|
agents: [
|
|
readAgent(line, 0, connectPos, readOpts),
|
|
readAgent(line, connectPos + 1, labelSep, readOpts),
|
|
],
|
|
label: joinLabel(line, labelSep + 1),
|
|
options: connectionToken.value,
|
|
};
|
|
}
|
|
},
|
|
|
|
(line) => { // marker
|
|
if(line.length < 2 || tokenKeyword(array.last(line)) !== ':') {
|
|
return null;
|
|
}
|
|
return {
|
|
type: 'mark',
|
|
name: joinLabel(line, 0, line.length - 1),
|
|
};
|
|
},
|
|
];
|
|
|
|
function parseLine(line, {meta, stages}) {
|
|
let stage = null;
|
|
for(let i = 0; i < PARSERS.length; ++ i) {
|
|
stage = PARSERS[i](line, meta);
|
|
if(stage) {
|
|
break;
|
|
}
|
|
}
|
|
if(!stage) {
|
|
throw makeError(
|
|
'Unrecognised command: ' + joinLabel(line),
|
|
line[0]
|
|
);
|
|
}
|
|
if(typeof stage === 'object') {
|
|
stage.ln = line[0].b.ln;
|
|
stages.push(stage);
|
|
}
|
|
}
|
|
|
|
const SHARED_TOKENISER = new Tokeniser();
|
|
|
|
return class Parser {
|
|
getCodeMirrorMode() {
|
|
return SHARED_TOKENISER.getCodeMirrorMode(
|
|
Array.from(CONNECT.types.keys())
|
|
);
|
|
}
|
|
|
|
parseLines(lines) {
|
|
const result = {
|
|
meta: {
|
|
title: '',
|
|
theme: '',
|
|
terminators: 'none',
|
|
headers: 'box',
|
|
textFormatter: markdownParser,
|
|
},
|
|
stages: [],
|
|
};
|
|
|
|
lines.forEach((line) => parseLine(line, result));
|
|
|
|
return result;
|
|
}
|
|
|
|
parse(src) {
|
|
const tokens = SHARED_TOKENISER.tokenise(src);
|
|
const lines = SHARED_TOKENISER.splitLines(tokens);
|
|
return this.parseLines(lines);
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/Generator',['core/ArrayUtilities'], (array) => {
|
|
'use strict';
|
|
|
|
class AgentState {
|
|
constructor({
|
|
visible = false,
|
|
locked = false,
|
|
blocked = false,
|
|
highlighted = false,
|
|
group = null,
|
|
covered = false,
|
|
} = {}) {
|
|
this.visible = visible;
|
|
this.locked = locked;
|
|
this.blocked = blocked;
|
|
this.highlighted = highlighted;
|
|
this.group = group;
|
|
this.covered = covered;
|
|
}
|
|
}
|
|
AgentState.LOCKED = new AgentState({locked: true});
|
|
AgentState.DEFAULT = new AgentState();
|
|
|
|
// Agent from Parser: {name, flags}
|
|
const PAgent = {
|
|
equals: (a, b) => {
|
|
return a.name === b.name;
|
|
},
|
|
hasFlag: (flag, has = true) => {
|
|
return (pAgent) => (pAgent.flags.includes(flag) === has);
|
|
},
|
|
};
|
|
|
|
// Agent from Generator: {id, formattedLabel, anchorRight}
|
|
const GAgent = {
|
|
equals: (a, b) => {
|
|
return a.id === b.id;
|
|
},
|
|
make: (id, {anchorRight = false, isVirtualSource = false} = {}) => {
|
|
return {id, anchorRight, isVirtualSource};
|
|
},
|
|
indexOf: (list, gAgent) => {
|
|
return array.indexOf(list, gAgent, GAgent.equals);
|
|
},
|
|
hasIntersection: (a, b) => {
|
|
return array.hasIntersection(a, b, GAgent.equals);
|
|
},
|
|
addNearby: (target, reference, item, offset) => {
|
|
const p = array.indexOf(target, reference, GAgent.equals);
|
|
if(p === -1) {
|
|
target.push(item);
|
|
} else {
|
|
target.splice(p + offset, 0, item);
|
|
}
|
|
},
|
|
};
|
|
|
|
const NOTE_DEFAULT_G_AGENTS = {
|
|
'note over': [GAgent.make('['), GAgent.make(']')],
|
|
'note left': [GAgent.make('[')],
|
|
'note right': [GAgent.make(']')],
|
|
};
|
|
|
|
const SPECIAL_AGENT_IDS = ['[', ']'];
|
|
|
|
const MERGABLE = {
|
|
'agent begin': {
|
|
check: ['mode'],
|
|
merge: ['agentIDs'],
|
|
siblings: new Set(['agent highlight']),
|
|
},
|
|
'agent end': {
|
|
check: ['mode'],
|
|
merge: ['agentIDs'],
|
|
siblings: new Set(['agent highlight']),
|
|
},
|
|
'agent highlight': {
|
|
check: ['highlighted'],
|
|
merge: ['agentIDs'],
|
|
siblings: new Set(['agent begin', 'agent end']),
|
|
},
|
|
};
|
|
|
|
function mergableParallel(target, copy) {
|
|
const info = MERGABLE[target.type];
|
|
if(!info || target.type !== copy.type) {
|
|
return false;
|
|
}
|
|
if(info.check.some((c) => target[c] !== copy[c])) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function performMerge(target, copy) {
|
|
const info = MERGABLE[target.type];
|
|
info.merge.forEach((m) => {
|
|
array.mergeSets(target[m], copy[m]);
|
|
});
|
|
}
|
|
|
|
function iterateRemoval(list, fn) {
|
|
for(let i = 0; i < list.length;) {
|
|
const remove = fn(list[i], i);
|
|
if(remove) {
|
|
list.splice(i, 1);
|
|
} else {
|
|
++ i;
|
|
}
|
|
}
|
|
}
|
|
|
|
function performParallelMergers(stages) {
|
|
iterateRemoval(stages, (stage, i) => {
|
|
for(let j = 0; j < i; ++ j) {
|
|
if(mergableParallel(stages[j], stage)) {
|
|
performMerge(stages[j], stage);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
|
|
function findViableSequentialMergers(stages) {
|
|
const mergers = new Set();
|
|
const types = stages.map(({type}) => type);
|
|
types.forEach((type) => {
|
|
const info = MERGABLE[type];
|
|
if(!info) {
|
|
return;
|
|
}
|
|
if(types.every((sType) =>
|
|
(type === sType || info.siblings.has(sType))
|
|
)) {
|
|
mergers.add(type);
|
|
}
|
|
});
|
|
return mergers;
|
|
}
|
|
|
|
function performSequentialMergers(lastViable, viable, lastStages, stages) {
|
|
iterateRemoval(stages, (stage) => {
|
|
if(!lastViable.has(stage.type) || !viable.has(stage.type)) {
|
|
return false;
|
|
}
|
|
for(let j = 0; j < lastStages.length; ++ j) {
|
|
if(mergableParallel(lastStages[j], stage)) {
|
|
performMerge(lastStages[j], stage);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
|
|
function optimiseStages(stages) {
|
|
let lastStages = [];
|
|
let lastViable = new Set();
|
|
for(let i = 0; i < stages.length;) {
|
|
const stage = stages[i];
|
|
let subStages = null;
|
|
if(stage.type === 'parallel') {
|
|
subStages = stage.stages;
|
|
} else {
|
|
subStages = [stage];
|
|
}
|
|
|
|
performParallelMergers(subStages);
|
|
const viable = findViableSequentialMergers(subStages);
|
|
performSequentialMergers(lastViable, viable, lastStages, subStages);
|
|
|
|
if(subStages.length === 0) {
|
|
stages.splice(i, 1);
|
|
} else {
|
|
if(stage.type === 'parallel' && subStages.length === 1) {
|
|
stages.splice(i, 1, subStages[0]);
|
|
}
|
|
lastViable = viable;
|
|
lastStages = subStages;
|
|
++ i;
|
|
}
|
|
}
|
|
}
|
|
|
|
function swapBegin(stage, mode) {
|
|
if(stage.type === 'agent begin') {
|
|
stage.mode = mode;
|
|
return true;
|
|
}
|
|
if(stage.type === 'parallel') {
|
|
let any = false;
|
|
stage.stages.forEach((subStage) => {
|
|
if(subStage.type === 'agent begin') {
|
|
subStage.mode = mode;
|
|
any = true;
|
|
}
|
|
});
|
|
return any;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function swapFirstBegin(stages, mode) {
|
|
for(let i = 0; i < stages.length; ++ i) {
|
|
if(swapBegin(stages[i], mode)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function addBounds(allGAgents, gAgentL, gAgentR, involvedGAgents = null) {
|
|
array.remove(allGAgents, gAgentL, GAgent.equals);
|
|
array.remove(allGAgents, gAgentR, GAgent.equals);
|
|
|
|
let indexL = 0;
|
|
let indexR = allGAgents.length;
|
|
if(involvedGAgents) {
|
|
const found = (involvedGAgents
|
|
.map((gAgent) => GAgent.indexOf(allGAgents, gAgent))
|
|
.filter((p) => (p !== -1))
|
|
);
|
|
indexL = found.reduce((a, b) => Math.min(a, b), allGAgents.length);
|
|
indexR = found.reduce((a, b) => Math.max(a, b), indexL) + 1;
|
|
}
|
|
|
|
allGAgents.splice(indexL, 0, gAgentL);
|
|
allGAgents.splice(indexR + 1, 0, gAgentR);
|
|
|
|
return {indexL, indexR: indexR + 1};
|
|
}
|
|
|
|
return class Generator {
|
|
constructor() {
|
|
this.agentStates = new Map();
|
|
this.agentAliases = new Map();
|
|
this.activeGroups = new Map();
|
|
this.gAgents = [];
|
|
this.labelPattern = null;
|
|
this.nextID = 0;
|
|
this.nesting = [];
|
|
this.markers = new Set();
|
|
this.currentSection = null;
|
|
this.currentNest = null;
|
|
|
|
this.stageHandlers = {
|
|
'block begin': this.handleBlockBegin.bind(this),
|
|
'block split': this.handleBlockSplit.bind(this),
|
|
'block end': this.handleBlockEnd.bind(this),
|
|
'group begin': this.handleGroupBegin.bind(this),
|
|
'mark': this.handleMark.bind(this),
|
|
'async': this.handleAsync.bind(this),
|
|
'agent define': this.handleAgentDefine.bind(this),
|
|
'agent begin': this.handleAgentBegin.bind(this),
|
|
'agent end': this.handleAgentEnd.bind(this),
|
|
'divider': this.handleDivider.bind(this),
|
|
'label pattern': this.handleLabelPattern.bind(this),
|
|
'connect': this.handleConnect.bind(this),
|
|
'connect-delay-begin': this.handleConnectDelayBegin.bind(this),
|
|
'connect-delay-end': this.handleConnectDelayEnd.bind(this),
|
|
'note over': this.handleNote.bind(this),
|
|
'note left': this.handleNote.bind(this),
|
|
'note right': this.handleNote.bind(this),
|
|
'note between': this.handleNote.bind(this),
|
|
};
|
|
this.expandGroupedGAgent = this.expandGroupedGAgent.bind(this);
|
|
this.handleStage = this.handleStage.bind(this);
|
|
this.toGAgent = this.toGAgent.bind(this);
|
|
this.endGroup = this.endGroup.bind(this);
|
|
}
|
|
|
|
toGAgent({name, alias, flags}) {
|
|
if(alias) {
|
|
if(this.agentAliases.has(name)) {
|
|
throw new Error(
|
|
'Cannot alias ' + name + '; it is already an alias'
|
|
);
|
|
}
|
|
const old = this.agentAliases.get(alias);
|
|
if(
|
|
(old && old !== alias) ||
|
|
this.gAgents.some((gAgent) => (gAgent.id === alias))
|
|
) {
|
|
throw new Error(
|
|
'Cannot use ' + alias +
|
|
' as an alias; it is already in use'
|
|
);
|
|
}
|
|
this.agentAliases.set(alias, name);
|
|
}
|
|
return GAgent.make(this.agentAliases.get(name) || name, {
|
|
isVirtualSource: flags.includes('source'),
|
|
});
|
|
}
|
|
|
|
addStage(stage, isVisible = true) {
|
|
if(!stage) {
|
|
return;
|
|
}
|
|
if(stage.ln === undefined) {
|
|
stage.ln = this.latestLine;
|
|
}
|
|
this.currentSection.stages.push(stage);
|
|
if(isVisible) {
|
|
this.currentNest.hasContent = true;
|
|
}
|
|
}
|
|
|
|
addParallelStages(stages) {
|
|
const viableStages = stages.filter((stage) => Boolean(stage));
|
|
if(viableStages.length === 0) {
|
|
return;
|
|
}
|
|
if(viableStages.length === 1) {
|
|
return this.addStage(viableStages[0]);
|
|
}
|
|
viableStages.forEach((stage) => {
|
|
if(stage.ln === undefined) {
|
|
stage.ln = this.latestLine;
|
|
}
|
|
});
|
|
return this.addStage({
|
|
type: 'parallel',
|
|
stages: viableStages,
|
|
});
|
|
}
|
|
|
|
defineGAgents(gAgents) {
|
|
array.mergeSets(
|
|
this.currentNest.gAgents,
|
|
gAgents.filter((gAgent) =>
|
|
!SPECIAL_AGENT_IDS.includes(gAgent.id)),
|
|
GAgent.equals
|
|
);
|
|
array.mergeSets(this.gAgents, gAgents, GAgent.equals);
|
|
}
|
|
|
|
getGAgentState(gAgent) {
|
|
return this.agentStates.get(gAgent.id) || AgentState.DEFAULT;
|
|
}
|
|
|
|
updateGAgentState(gAgent, change) {
|
|
const state = this.agentStates.get(gAgent.id);
|
|
if(state) {
|
|
Object.assign(state, change);
|
|
} else {
|
|
this.agentStates.set(gAgent.id, new AgentState(change));
|
|
}
|
|
}
|
|
|
|
replaceGAgentState(gAgent, state) {
|
|
this.agentStates.set(gAgent.id, state);
|
|
}
|
|
|
|
validateGAgents(gAgents, {
|
|
allowGrouped = false,
|
|
rejectGrouped = false,
|
|
allowVirtual = false,
|
|
} = {}) {
|
|
/* jshint -W074 */ // agent validity checking requires several steps
|
|
gAgents.forEach((gAgent) => {
|
|
const state = this.getGAgentState(gAgent);
|
|
if(state.covered) {
|
|
throw new Error(
|
|
'Agent ' + gAgent.id + ' is hidden behind group'
|
|
);
|
|
}
|
|
if(rejectGrouped && state.group !== null) {
|
|
throw new Error('Agent ' + gAgent.id + ' is in a group');
|
|
}
|
|
if(state.blocked && (!allowGrouped || state.group === null)) {
|
|
throw new Error('Duplicate agent name: ' + gAgent.id);
|
|
}
|
|
if(!allowVirtual && gAgent.isVirtualSource) {
|
|
throw new Error('cannot use message source here');
|
|
}
|
|
if(gAgent.id.startsWith('__')) {
|
|
throw new Error(gAgent.id + ' is a reserved name');
|
|
}
|
|
});
|
|
}
|
|
|
|
setGAgentVis(gAgents, visible, mode, checked = false) {
|
|
const seen = new Set();
|
|
const filteredGAgents = gAgents.filter((gAgent) => {
|
|
if(seen.has(gAgent.id)) {
|
|
return false;
|
|
}
|
|
seen.add(gAgent.id);
|
|
const state = this.getGAgentState(gAgent);
|
|
if(state.locked || state.blocked) {
|
|
if(checked) {
|
|
throw new Error('Cannot begin/end agent: ' + gAgent.id);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return state.visible !== visible;
|
|
});
|
|
if(filteredGAgents.length === 0) {
|
|
return null;
|
|
}
|
|
filteredGAgents.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {visible});
|
|
});
|
|
this.defineGAgents(filteredGAgents);
|
|
|
|
return {
|
|
type: (visible ? 'agent begin' : 'agent end'),
|
|
agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
|
|
mode,
|
|
};
|
|
}
|
|
|
|
setGAgentHighlight(gAgents, highlighted, checked = false) {
|
|
const filteredGAgents = gAgents.filter((gAgent) => {
|
|
const state = this.getGAgentState(gAgent);
|
|
if(state.locked || state.blocked) {
|
|
if(checked) {
|
|
throw new Error('Cannot highlight agent: ' + gAgent.id);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return state.visible && (state.highlighted !== highlighted);
|
|
});
|
|
if(filteredGAgents.length === 0) {
|
|
return null;
|
|
}
|
|
filteredGAgents.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {highlighted});
|
|
});
|
|
|
|
return {
|
|
type: 'agent highlight',
|
|
agentIDs: filteredGAgents.map((gAgent) => gAgent.id),
|
|
highlighted,
|
|
};
|
|
}
|
|
|
|
_makeSection(header, stages) {
|
|
return {
|
|
header,
|
|
delayedConnections: new Map(),
|
|
stages,
|
|
};
|
|
}
|
|
|
|
_checkSectionEnd() {
|
|
const dcs = this.currentSection.delayedConnections;
|
|
if(dcs.size > 0) {
|
|
const dc = dcs.values().next().value;
|
|
throw new Error(
|
|
'Unused delayed connection "' + dc.tag +
|
|
'" at line ' + (dc.ln + 1)
|
|
);
|
|
}
|
|
}
|
|
|
|
beginNested(blockType, {tag, label, name, ln}) {
|
|
const leftGAgent = GAgent.make(name + '[', {anchorRight: true});
|
|
const rightGAgent = GAgent.make(name + ']');
|
|
const gAgents = [leftGAgent, rightGAgent];
|
|
const stages = [];
|
|
this.currentSection = this._makeSection({
|
|
type: 'block begin',
|
|
blockType,
|
|
tag: this.textFormatter(tag),
|
|
label: this.textFormatter(label),
|
|
left: leftGAgent.id,
|
|
right: rightGAgent.id,
|
|
ln,
|
|
}, stages);
|
|
this.currentNest = {
|
|
blockType,
|
|
gAgents,
|
|
leftGAgent,
|
|
rightGAgent,
|
|
hasContent: false,
|
|
sections: [this.currentSection],
|
|
};
|
|
this.replaceGAgentState(leftGAgent, AgentState.LOCKED);
|
|
this.replaceGAgentState(rightGAgent, AgentState.LOCKED);
|
|
this.nesting.push(this.currentNest);
|
|
|
|
return {stages};
|
|
}
|
|
|
|
nextBlockName() {
|
|
const name = '__BLOCK' + this.nextID;
|
|
++ this.nextID;
|
|
return name;
|
|
}
|
|
|
|
nextVirtualAgentName() {
|
|
const name = '__' + this.nextID;
|
|
++ this.nextID;
|
|
return name;
|
|
}
|
|
|
|
handleBlockBegin({ln, blockType, tag, label}) {
|
|
this.beginNested(blockType, {
|
|
tag,
|
|
label,
|
|
name: this.nextBlockName(),
|
|
ln,
|
|
});
|
|
}
|
|
|
|
handleBlockSplit({ln, blockType, tag, label}) {
|
|
if(this.currentNest.blockType !== 'if') {
|
|
throw new Error(
|
|
'Invalid block nesting ("else" inside ' +
|
|
this.currentNest.blockType + ')'
|
|
);
|
|
}
|
|
this._checkSectionEnd();
|
|
this.currentSection = this._makeSection({
|
|
type: 'block split',
|
|
blockType,
|
|
tag: this.textFormatter(tag),
|
|
label: this.textFormatter(label),
|
|
left: this.currentNest.leftGAgent.id,
|
|
right: this.currentNest.rightGAgent.id,
|
|
ln,
|
|
}, []);
|
|
this.currentNest.sections.push(this.currentSection);
|
|
}
|
|
|
|
handleBlockEnd() {
|
|
if(this.nesting.length <= 1) {
|
|
throw new Error('Invalid block nesting (too many "end"s)');
|
|
}
|
|
this._checkSectionEnd();
|
|
const nested = this.nesting.pop();
|
|
this.currentNest = array.last(this.nesting);
|
|
this.currentSection = array.last(this.currentNest.sections);
|
|
|
|
if(nested.hasContent) {
|
|
this.defineGAgents(nested.gAgents);
|
|
addBounds(
|
|
this.gAgents,
|
|
nested.leftGAgent,
|
|
nested.rightGAgent,
|
|
nested.gAgents
|
|
);
|
|
nested.sections.forEach((section) => {
|
|
this.currentSection.stages.push(section.header);
|
|
this.currentSection.stages.push(...section.stages);
|
|
});
|
|
this.addStage({
|
|
type: 'block end',
|
|
left: nested.leftGAgent.id,
|
|
right: nested.rightGAgent.id,
|
|
});
|
|
} else {
|
|
throw new Error('Empty block');
|
|
}
|
|
}
|
|
|
|
makeGroupDetails(pAgents, alias) {
|
|
const gAgents = pAgents.map(this.toGAgent);
|
|
this.validateGAgents(gAgents, {rejectGrouped: true});
|
|
if(this.agentStates.has(alias)) {
|
|
throw new Error('Duplicate agent name: ' + alias);
|
|
}
|
|
const name = this.nextBlockName();
|
|
const leftGAgent = GAgent.make(name + '[', {anchorRight: true});
|
|
const rightGAgent = GAgent.make(name + ']');
|
|
this.replaceGAgentState(leftGAgent, AgentState.LOCKED);
|
|
this.replaceGAgentState(rightGAgent, AgentState.LOCKED);
|
|
this.updateGAgentState(
|
|
GAgent.make(alias),
|
|
{blocked: true, group: alias}
|
|
);
|
|
this.defineGAgents(gAgents);
|
|
const {indexL, indexR} = addBounds(
|
|
this.gAgents,
|
|
leftGAgent,
|
|
rightGAgent,
|
|
gAgents
|
|
);
|
|
|
|
const gAgentsCovered = [];
|
|
const gAgentsContained = gAgents.slice();
|
|
for(let i = indexL + 1; i < indexR; ++ i) {
|
|
gAgentsCovered.push(this.gAgents[i]);
|
|
}
|
|
array.removeAll(gAgentsCovered, gAgentsContained, GAgent.equals);
|
|
|
|
return {
|
|
gAgents,
|
|
leftGAgent,
|
|
rightGAgent,
|
|
gAgentsContained,
|
|
gAgentsCovered,
|
|
};
|
|
}
|
|
|
|
handleGroupBegin({agents, blockType, tag, label, alias}) {
|
|
const details = this.makeGroupDetails(agents, alias);
|
|
|
|
details.gAgentsContained.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {group: alias});
|
|
});
|
|
details.gAgentsCovered.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {covered: true});
|
|
});
|
|
this.activeGroups.set(alias, details);
|
|
this.addStage(this.setGAgentVis(details.gAgents, true, 'box'));
|
|
this.addStage({
|
|
type: 'block begin',
|
|
blockType,
|
|
tag: this.textFormatter(tag),
|
|
label: this.textFormatter(label),
|
|
left: details.leftGAgent.id,
|
|
right: details.rightGAgent.id,
|
|
});
|
|
}
|
|
|
|
endGroup({name}) {
|
|
const details = this.activeGroups.get(name);
|
|
if(!details) {
|
|
return null;
|
|
}
|
|
this.activeGroups.delete(name);
|
|
|
|
details.gAgentsContained.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {group: null});
|
|
});
|
|
details.gAgentsCovered.forEach((gAgent) => {
|
|
this.updateGAgentState(gAgent, {covered: false});
|
|
});
|
|
this.updateGAgentState(GAgent.make(name), {group: null});
|
|
|
|
return {
|
|
type: 'block end',
|
|
left: details.leftGAgent.id,
|
|
right: details.rightGAgent.id,
|
|
};
|
|
}
|
|
|
|
handleMark({name}) {
|
|
this.markers.add(name);
|
|
this.addStage({type: 'mark', name}, false);
|
|
}
|
|
|
|
handleDivider({mode, height, label}) {
|
|
this.addStage({
|
|
type: 'divider',
|
|
mode,
|
|
height,
|
|
formattedLabel: this.textFormatter(label),
|
|
}, false);
|
|
}
|
|
|
|
handleAsync({target}) {
|
|
if(target !== '' && !this.markers.has(target)) {
|
|
throw new Error('Unknown marker: ' + target);
|
|
}
|
|
this.addStage({type: 'async', target}, false);
|
|
}
|
|
|
|
handleLabelPattern({pattern}) {
|
|
this.labelPattern = pattern.slice();
|
|
for(let i = 0; i < this.labelPattern.length; ++ i) {
|
|
const part = this.labelPattern[i];
|
|
if(typeof part === 'object' && part.start !== undefined) {
|
|
this.labelPattern[i] = Object.assign({
|
|
current: part.start,
|
|
}, part);
|
|
}
|
|
}
|
|
}
|
|
|
|
applyLabelPattern(label) {
|
|
let result = '';
|
|
const tokens = {
|
|
'label': label,
|
|
};
|
|
this.labelPattern.forEach((part) => {
|
|
if(typeof part === 'string') {
|
|
result += part;
|
|
} else if(part.token !== undefined) {
|
|
result += tokens[part.token];
|
|
} else if(part.current !== undefined) {
|
|
result += part.current.toFixed(part.dp);
|
|
part.current += part.inc;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
expandGroupedGAgent(gAgent) {
|
|
const group = this.getGAgentState(gAgent).group;
|
|
if(!group) {
|
|
return [gAgent];
|
|
}
|
|
const details = this.activeGroups.get(group);
|
|
return [details.leftGAgent, details.rightGAgent];
|
|
}
|
|
|
|
expandGroupedGAgentConnection(gAgents) {
|
|
const gAgents1 = this.expandGroupedGAgent(gAgents[0]);
|
|
const gAgents2 = this.expandGroupedGAgent(gAgents[1]);
|
|
let ind1 = GAgent.indexOf(this.gAgents, gAgents1[0]);
|
|
let ind2 = GAgent.indexOf(this.gAgents, gAgents2[0]);
|
|
if(ind1 === -1) {
|
|
// Virtual sources written as '* -> Ref' will spawn to the left,
|
|
// not the right (as non-virtual agents would)
|
|
ind1 = gAgents1[0].isVirtualSource ? -1 : this.gAgents.length;
|
|
}
|
|
if(ind2 === -1) {
|
|
// Virtual and non-virtual agents written as 'Ref -> *' will
|
|
// spawn to the right
|
|
ind2 = this.gAgents.length;
|
|
}
|
|
if(ind1 === ind2) {
|
|
// Self-connection
|
|
return [array.last(gAgents1), array.last(gAgents2)];
|
|
} else if(ind1 < ind2) {
|
|
return [array.last(gAgents1), gAgents2[0]];
|
|
} else {
|
|
return [gAgents1[0], array.last(gAgents2)];
|
|
}
|
|
}
|
|
|
|
filterConnectFlags(pAgents) {
|
|
const beginGAgents = (pAgents
|
|
.filter(PAgent.hasFlag('begin'))
|
|
.map(this.toGAgent)
|
|
);
|
|
const endGAgents = (pAgents
|
|
.filter(PAgent.hasFlag('end'))
|
|
.map(this.toGAgent)
|
|
);
|
|
if(GAgent.hasIntersection(beginGAgents, endGAgents)) {
|
|
throw new Error('Cannot set agent visibility multiple times');
|
|
}
|
|
|
|
const startGAgents = (pAgents
|
|
.filter(PAgent.hasFlag('start'))
|
|
.map(this.toGAgent)
|
|
);
|
|
const stopGAgents = (pAgents
|
|
.filter(PAgent.hasFlag('stop'))
|
|
.map(this.toGAgent)
|
|
);
|
|
array.mergeSets(stopGAgents, endGAgents);
|
|
if(GAgent.hasIntersection(startGAgents, stopGAgents)) {
|
|
throw new Error('Cannot set agent highlighting multiple times');
|
|
}
|
|
|
|
this.validateGAgents(beginGAgents);
|
|
this.validateGAgents(endGAgents);
|
|
this.validateGAgents(startGAgents);
|
|
this.validateGAgents(stopGAgents);
|
|
|
|
return {beginGAgents, endGAgents, startGAgents, stopGAgents};
|
|
}
|
|
|
|
makeVirtualAgent(anchorRight) {
|
|
const virtualGAgent = GAgent.make(this.nextVirtualAgentName(), {
|
|
anchorRight,
|
|
isVirtualSource: true,
|
|
});
|
|
this.replaceGAgentState(virtualGAgent, AgentState.LOCKED);
|
|
return virtualGAgent;
|
|
}
|
|
|
|
addNearbyAgent(gAgentReference, gAgent, offset) {
|
|
GAgent.addNearby(
|
|
this.currentNest.gAgents,
|
|
gAgentReference,
|
|
gAgent,
|
|
offset
|
|
);
|
|
GAgent.addNearby(
|
|
this.gAgents,
|
|
gAgentReference,
|
|
gAgent,
|
|
offset
|
|
);
|
|
}
|
|
|
|
expandVirtualSourceAgents(gAgents) {
|
|
if(gAgents[0].isVirtualSource) {
|
|
if(gAgents[1].isVirtualSource) {
|
|
throw new Error('Cannot connect found messages');
|
|
}
|
|
if(SPECIAL_AGENT_IDS.includes(gAgents[1].id)) {
|
|
throw new Error(
|
|
'Cannot connect found messages to special agents'
|
|
);
|
|
}
|
|
const virtualGAgent = this.makeVirtualAgent(true);
|
|
this.addNearbyAgent(gAgents[1], virtualGAgent, 0);
|
|
return [virtualGAgent, gAgents[1]];
|
|
}
|
|
if(gAgents[1].isVirtualSource) {
|
|
if(SPECIAL_AGENT_IDS.includes(gAgents[0].id)) {
|
|
throw new Error(
|
|
'Cannot connect found messages to special agents'
|
|
);
|
|
}
|
|
const virtualGAgent = this.makeVirtualAgent(false);
|
|
this.addNearbyAgent(gAgents[0], virtualGAgent, 1);
|
|
return [gAgents[0], virtualGAgent];
|
|
}
|
|
return gAgents;
|
|
}
|
|
|
|
_handlePartialConnect(agents) {
|
|
const flags = this.filterConnectFlags(agents);
|
|
|
|
const gAgents = agents.map(this.toGAgent);
|
|
this.validateGAgents(gAgents, {
|
|
allowGrouped: true,
|
|
allowVirtual: true,
|
|
});
|
|
|
|
this.defineGAgents(array
|
|
.flatMap(gAgents, this.expandGroupedGAgent)
|
|
.filter((gAgent) => !gAgent.isVirtualSource)
|
|
);
|
|
|
|
const implicitBeginGAgents = (agents
|
|
.filter(PAgent.hasFlag('begin', false))
|
|
.map(this.toGAgent)
|
|
.filter((gAgent) => !gAgent.isVirtualSource)
|
|
);
|
|
this.addStage(this.setGAgentVis(implicitBeginGAgents, true, 'box'));
|
|
|
|
return {flags, gAgents};
|
|
}
|
|
|
|
_makeConnectParallelStages(flags, connectStage) {
|
|
return [
|
|
this.setGAgentVis(flags.beginGAgents, true, 'box', true),
|
|
this.setGAgentHighlight(flags.startGAgents, true, true),
|
|
connectStage,
|
|
this.setGAgentHighlight(flags.stopGAgents, false, true),
|
|
this.setGAgentVis(flags.endGAgents, false, 'cross', true),
|
|
];
|
|
}
|
|
|
|
_isSelfConnect(agents) {
|
|
const gAgents = agents.map(this.toGAgent);
|
|
const expandedGAgents = this.expandGroupedGAgentConnection(gAgents);
|
|
if(expandedGAgents[0].id !== expandedGAgents[1].id) {
|
|
return false;
|
|
}
|
|
if(expandedGAgents.some((gAgent) => gAgent.isVirtualSource)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
handleConnect({agents, label, options}) {
|
|
if(this._isSelfConnect(agents)) {
|
|
const tag = {};
|
|
this.handleConnectDelayBegin({
|
|
agent: agents[0],
|
|
tag,
|
|
options,
|
|
ln: 0,
|
|
});
|
|
this.handleConnectDelayEnd({
|
|
agent: agents[1],
|
|
tag,
|
|
label,
|
|
options,
|
|
});
|
|
return;
|
|
}
|
|
|
|
let {flags, gAgents} = this._handlePartialConnect(agents);
|
|
|
|
gAgents = this.expandGroupedGAgentConnection(gAgents);
|
|
gAgents = this.expandVirtualSourceAgents(gAgents);
|
|
|
|
const connectStage = {
|
|
type: 'connect',
|
|
agentIDs: gAgents.map((gAgent) => gAgent.id),
|
|
label: this.textFormatter(this.applyLabelPattern(label)),
|
|
options,
|
|
};
|
|
|
|
this.addParallelStages(this._makeConnectParallelStages(
|
|
flags,
|
|
connectStage
|
|
));
|
|
}
|
|
|
|
handleConnectDelayBegin({agent, tag, options, ln}) {
|
|
const dcs = this.currentSection.delayedConnections;
|
|
if(dcs.has(tag)) {
|
|
throw new Error('Duplicate delayed connection "' + tag + '"');
|
|
}
|
|
|
|
const {flags, gAgents} = this._handlePartialConnect([agent]);
|
|
const uniqueTag = this.nextVirtualAgentName();
|
|
|
|
const connectStage = {
|
|
type: 'connect-delay-begin',
|
|
tag: uniqueTag,
|
|
agentIDs: null,
|
|
label: null,
|
|
options,
|
|
};
|
|
|
|
dcs.set(tag, {tag, uniqueTag, ln, gAgents, connectStage});
|
|
|
|
this.addParallelStages(this._makeConnectParallelStages(
|
|
flags,
|
|
connectStage
|
|
));
|
|
}
|
|
|
|
handleConnectDelayEnd({agent, tag, label, options}) {
|
|
const dcs = this.currentSection.delayedConnections;
|
|
const dcInfo = dcs.get(tag);
|
|
if(!dcInfo) {
|
|
throw new Error('Unknown delayed connection "' + tag + '"');
|
|
}
|
|
|
|
let {flags, gAgents} = this._handlePartialConnect([agent]);
|
|
|
|
gAgents = this.expandGroupedGAgentConnection([
|
|
...dcInfo.gAgents,
|
|
...gAgents,
|
|
]);
|
|
gAgents = this.expandVirtualSourceAgents(gAgents);
|
|
|
|
let combinedOptions = dcInfo.connectStage.options;
|
|
if(combinedOptions.line !== options.line) {
|
|
throw new Error('Mismatched delayed connection arrows');
|
|
}
|
|
if(options.right) {
|
|
combinedOptions = Object.assign({}, combinedOptions, {
|
|
right: options.right,
|
|
});
|
|
}
|
|
|
|
Object.assign(dcInfo.connectStage, {
|
|
agentIDs: gAgents.map((gAgent) => gAgent.id),
|
|
label: this.textFormatter(this.applyLabelPattern(label)),
|
|
options: combinedOptions,
|
|
});
|
|
|
|
const connectEndStage = {
|
|
type: 'connect-delay-end',
|
|
tag: dcInfo.uniqueTag,
|
|
};
|
|
|
|
this.addParallelStages(this._makeConnectParallelStages(
|
|
flags,
|
|
connectEndStage
|
|
));
|
|
|
|
dcs.delete(tag);
|
|
}
|
|
|
|
handleNote({type, agents, mode, label}) {
|
|
let gAgents = null;
|
|
if(agents.length === 0) {
|
|
gAgents = NOTE_DEFAULT_G_AGENTS[type] || [];
|
|
} else {
|
|
gAgents = agents.map(this.toGAgent);
|
|
}
|
|
|
|
this.validateGAgents(gAgents, {allowGrouped: true});
|
|
gAgents = array.flatMap(gAgents, this.expandGroupedGAgent);
|
|
const agentIDs = gAgents.map((gAgent) => gAgent.id);
|
|
const uniqueAgents = new Set(agentIDs).size;
|
|
if(type === 'note between' && uniqueAgents < 2) {
|
|
throw new Error('note between requires at least 2 agents');
|
|
}
|
|
|
|
this.addStage(this.setGAgentVis(gAgents, true, 'box'));
|
|
this.defineGAgents(gAgents);
|
|
|
|
this.addStage({
|
|
type,
|
|
agentIDs,
|
|
mode,
|
|
label: this.textFormatter(label),
|
|
});
|
|
}
|
|
|
|
handleAgentDefine({agents}) {
|
|
const gAgents = agents.map(this.toGAgent);
|
|
this.validateGAgents(gAgents);
|
|
this.defineGAgents(gAgents);
|
|
}
|
|
|
|
handleAgentBegin({agents, mode}) {
|
|
const gAgents = agents.map(this.toGAgent);
|
|
this.validateGAgents(gAgents);
|
|
this.addStage(this.setGAgentVis(gAgents, true, mode, true));
|
|
}
|
|
|
|
handleAgentEnd({agents, mode}) {
|
|
const groupPAgents = (agents
|
|
.filter((pAgent) => this.activeGroups.has(pAgent.name))
|
|
);
|
|
const gAgents = (agents
|
|
.filter((pAgent) => !this.activeGroups.has(pAgent.name))
|
|
.map(this.toGAgent)
|
|
);
|
|
this.validateGAgents(gAgents);
|
|
this.addParallelStages([
|
|
this.setGAgentHighlight(gAgents, false),
|
|
this.setGAgentVis(gAgents, false, mode, true),
|
|
...groupPAgents.map(this.endGroup),
|
|
]);
|
|
}
|
|
|
|
handleStage(stage) {
|
|
this.latestLine = stage.ln;
|
|
try {
|
|
const handler = this.stageHandlers[stage.type];
|
|
if(!handler) {
|
|
throw new Error('Unknown command: ' + stage.type);
|
|
}
|
|
handler(stage);
|
|
} catch(e) {
|
|
if(typeof e === 'object' && e.message) {
|
|
e.message += ' at line ' + (stage.ln + 1);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
_reset() {
|
|
this.agentStates.clear();
|
|
this.markers.clear();
|
|
this.agentAliases.clear();
|
|
this.activeGroups.clear();
|
|
this.gAgents.length = 0;
|
|
this.nextID = 0;
|
|
this.nesting.length = 0;
|
|
this.labelPattern = [{token: 'label'}];
|
|
}
|
|
|
|
_finalise(globals) {
|
|
addBounds(
|
|
this.gAgents,
|
|
this.currentNest.leftGAgent,
|
|
this.currentNest.rightGAgent
|
|
);
|
|
optimiseStages(globals.stages);
|
|
|
|
this.gAgents.forEach((gAgent) => {
|
|
gAgent.formattedLabel = this.textFormatter(gAgent.id);
|
|
});
|
|
}
|
|
|
|
generate({stages, meta = {}}) {
|
|
this._reset();
|
|
|
|
this.textFormatter = meta.textFormatter;
|
|
const globals = this.beginNested('global', {
|
|
tag: '',
|
|
label: '',
|
|
name: '',
|
|
ln: 0,
|
|
});
|
|
|
|
stages.forEach(this.handleStage);
|
|
|
|
if(this.nesting.length !== 1) {
|
|
throw new Error(
|
|
'Unterminated section at line ' +
|
|
(this.currentSection.header.ln + 1)
|
|
);
|
|
}
|
|
if(this.activeGroups.size > 0) {
|
|
throw new Error('Unterminated group');
|
|
}
|
|
|
|
this._checkSectionEnd();
|
|
|
|
const terminators = meta.terminators || 'none';
|
|
this.addParallelStages([
|
|
this.setGAgentHighlight(this.gAgents, false),
|
|
this.setGAgentVis(this.gAgents, false, terminators),
|
|
]);
|
|
|
|
this._finalise(globals);
|
|
|
|
swapFirstBegin(globals.stages, meta.headers || 'box');
|
|
|
|
return {
|
|
meta: {
|
|
title: this.textFormatter(meta.title),
|
|
theme: meta.theme,
|
|
},
|
|
agents: this.gAgents.slice(),
|
|
stages: globals.stages,
|
|
};
|
|
}
|
|
};
|
|
});
|
|
|
|
define('svg/SVGUtilities',[],() => {
|
|
'use strict';
|
|
|
|
const NS = 'http://www.w3.org/2000/svg';
|
|
|
|
function makeText(text = '') {
|
|
return document.createTextNode(text);
|
|
}
|
|
|
|
function make(type, attrs = {}) {
|
|
const o = document.createElementNS(NS, type);
|
|
for(let k in attrs) {
|
|
if(attrs.hasOwnProperty(k)) {
|
|
o.setAttribute(k, attrs[k]);
|
|
}
|
|
}
|
|
return o;
|
|
}
|
|
|
|
function makeContainer(attrs = {}) {
|
|
return make('svg', Object.assign({
|
|
'xmlns': NS,
|
|
'version': '1.1',
|
|
}, attrs));
|
|
}
|
|
|
|
function empty(node) {
|
|
while(node.childNodes.length > 0) {
|
|
node.removeChild(node.lastChild);
|
|
}
|
|
}
|
|
|
|
return {
|
|
makeText,
|
|
make,
|
|
makeContainer,
|
|
empty,
|
|
};
|
|
});
|
|
|
|
define('svg/SVGTextBlock',['./SVGUtilities'], (svg) => {
|
|
'use strict';
|
|
|
|
// Thanks, https://stackoverflow.com/a/9851769/1180785
|
|
const firefox = (typeof window.InstallTrigger !== 'undefined');
|
|
|
|
function fontDetails(attrs) {
|
|
const size = Number(attrs['font-size']);
|
|
const lineHeight = size * (Number(attrs['line-height']) || 1);
|
|
return {
|
|
size,
|
|
lineHeight,
|
|
};
|
|
}
|
|
|
|
function merge(state, newState) {
|
|
for(let k in state) {
|
|
if(state.hasOwnProperty(k)) {
|
|
if(newState[k] !== null && newState[k] !== undefined) {
|
|
state[k] = newState[k];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function populateSvgTextLine(node, formattedLine) {
|
|
if(!Array.isArray(formattedLine)) {
|
|
throw new Error('Invalid formatted text line: ' + formattedLine);
|
|
}
|
|
formattedLine.forEach(({text, attrs}) => {
|
|
const textNode = svg.makeText(text);
|
|
if(attrs) {
|
|
const span = svg.make('tspan', attrs);
|
|
span.appendChild(textNode);
|
|
node.appendChild(span);
|
|
} else {
|
|
node.appendChild(textNode);
|
|
}
|
|
});
|
|
}
|
|
|
|
const EMPTY = [];
|
|
|
|
class SVGTextBlock {
|
|
constructor(container, initialState = {}) {
|
|
this.container = container;
|
|
this.state = {
|
|
attrs: {},
|
|
formatted: EMPTY,
|
|
x: 0,
|
|
y: 0,
|
|
};
|
|
this.width = 0;
|
|
this.height = 0;
|
|
this.lines = [];
|
|
this.set(initialState);
|
|
}
|
|
|
|
_rebuildLines(count) {
|
|
if(count > this.lines.length) {
|
|
const attrs = Object.assign({
|
|
'x': this.state.x,
|
|
}, this.state.attrs);
|
|
|
|
while(this.lines.length < count) {
|
|
const node = svg.make('text', attrs);
|
|
this.container.appendChild(node);
|
|
this.lines.push({node, latest: ''});
|
|
}
|
|
} else {
|
|
while(this.lines.length > count) {
|
|
const {node} = this.lines.pop();
|
|
this.container.removeChild(node);
|
|
}
|
|
}
|
|
}
|
|
|
|
_reset() {
|
|
this._rebuildLines(0);
|
|
this.width = 0;
|
|
this.height = 0;
|
|
}
|
|
|
|
_renderText() {
|
|
const {formatted} = this.state;
|
|
|
|
if(!formatted || !formatted.length) {
|
|
this._reset();
|
|
return;
|
|
}
|
|
if(!Array.isArray(formatted)) {
|
|
throw new Error('Invalid formatted text: ' + formatted);
|
|
}
|
|
|
|
this._rebuildLines(formatted.length);
|
|
|
|
let maxWidth = 0;
|
|
this.lines.forEach((ln, i) => {
|
|
const id = JSON.stringify(formatted[i]);
|
|
if(id !== ln.latest) {
|
|
svg.empty(ln.node);
|
|
populateSvgTextLine(ln.node, formatted[i]);
|
|
ln.latest = id;
|
|
}
|
|
maxWidth = Math.max(maxWidth, ln.node.getComputedTextLength());
|
|
});
|
|
this.width = maxWidth;
|
|
}
|
|
|
|
_updateX() {
|
|
this.lines.forEach(({node}) => {
|
|
node.setAttribute('x', this.state.x);
|
|
});
|
|
}
|
|
|
|
_updateY() {
|
|
const {size, lineHeight} = fontDetails(this.state.attrs);
|
|
this.lines.forEach(({node}, i) => {
|
|
node.setAttribute('y', this.state.y + i * lineHeight + size);
|
|
});
|
|
this.height = lineHeight * this.lines.length;
|
|
}
|
|
|
|
firstLine() {
|
|
if(this.lines.length > 0) {
|
|
return this.lines[0].node;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
set(newState) {
|
|
const oldState = Object.assign({}, this.state);
|
|
merge(this.state, newState);
|
|
|
|
if(this.state.attrs !== oldState.attrs) {
|
|
this._reset();
|
|
oldState.formatted = EMPTY;
|
|
}
|
|
|
|
const oldLines = this.lines.length;
|
|
|
|
if(this.state.formatted !== oldState.formatted) {
|
|
this._renderText();
|
|
}
|
|
|
|
if(this.state.x !== oldState.x) {
|
|
this._updateX();
|
|
}
|
|
|
|
if(this.state.y !== oldState.y || this.lines.length !== oldLines) {
|
|
this._updateY();
|
|
}
|
|
}
|
|
}
|
|
|
|
class SizeTester {
|
|
constructor(container) {
|
|
this.testers = svg.make('g', {
|
|
// Firefox fails to measure non-displayed text
|
|
'display': firefox ? 'block' : 'none',
|
|
'visibility': 'hidden',
|
|
});
|
|
this.container = container;
|
|
this.cache = new Map();
|
|
}
|
|
|
|
measure(attrs, formatted) {
|
|
if(!formatted || !formatted.length) {
|
|
return {width: 0, height: 0};
|
|
}
|
|
if(!Array.isArray(formatted)) {
|
|
throw new Error('Invalid formatted text: ' + formatted);
|
|
}
|
|
|
|
let tester = this.cache.get(attrs);
|
|
if(!tester) {
|
|
tester = svg.make('text', attrs);
|
|
this.testers.appendChild(tester);
|
|
this.cache.set(attrs, tester);
|
|
}
|
|
|
|
if(!this.testers.parentNode) {
|
|
this.container.appendChild(this.testers);
|
|
}
|
|
|
|
let width = 0;
|
|
formatted.forEach((line) => {
|
|
svg.empty(tester);
|
|
populateSvgTextLine(tester, line);
|
|
width = Math.max(width, tester.getComputedTextLength());
|
|
});
|
|
|
|
return {
|
|
width,
|
|
height: formatted.length * fontDetails(attrs).lineHeight,
|
|
};
|
|
}
|
|
|
|
measureHeight(attrs, formatted) {
|
|
if(!formatted) {
|
|
return 0;
|
|
}
|
|
if(!Array.isArray(formatted)) {
|
|
throw new Error('Invalid formatted text: ' + formatted);
|
|
}
|
|
|
|
return formatted.length * fontDetails(attrs).lineHeight;
|
|
}
|
|
|
|
resetCache() {
|
|
svg.empty(this.testers);
|
|
this.cache.clear();
|
|
}
|
|
|
|
detach() {
|
|
if(this.testers.parentNode) {
|
|
this.container.removeChild(this.testers);
|
|
}
|
|
}
|
|
}
|
|
|
|
SVGTextBlock.SizeTester = SizeTester;
|
|
|
|
return SVGTextBlock;
|
|
});
|
|
|
|
define('svg/PatternedLine',[],() => {
|
|
'use strict';
|
|
|
|
return class PatternedLine {
|
|
constructor(pattern = null, phase = 0) {
|
|
this.pattern = pattern;
|
|
this.dw = pattern && pattern.partWidth;
|
|
this.points = [];
|
|
this.phase = phase;
|
|
this.x = null;
|
|
this.y = null;
|
|
this.disconnect = 0;
|
|
}
|
|
|
|
_nextDelta() {
|
|
return this.pattern.getDelta(this.phase ++);
|
|
}
|
|
|
|
_link() {
|
|
if(this.disconnect === 2) {
|
|
this.points.push(this.x + ' ' + this.y);
|
|
this.disconnect = 0;
|
|
}
|
|
}
|
|
|
|
cap() {
|
|
if(this.disconnect > 0) {
|
|
this.points.push(this.x + ' ' + this.y);
|
|
this.disconnect = 0;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
move(x, y) {
|
|
this.cap();
|
|
this.x = x;
|
|
this.y = y;
|
|
this.disconnect = 2;
|
|
return this;
|
|
}
|
|
|
|
line(x, y, {patterned = true} = {}) {
|
|
if(this.pattern && patterned) {
|
|
const len = Math.sqrt(
|
|
(x - this.x) * (x - this.x) +
|
|
(y - this.y) * (y - this.y)
|
|
);
|
|
const dx1 = (x - this.x) / len;
|
|
const dy1 = (y - this.y) / len;
|
|
const dx2 = -dy1;
|
|
const dy2 = dx1;
|
|
|
|
for(let pos = 0; pos + this.dw <= len; pos += this.dw) {
|
|
const delta = this._nextDelta();
|
|
this.points.push(
|
|
(this.x + pos * dx1 + delta * dx2) + ' ' +
|
|
(this.y + pos * dy1 + delta * dy2)
|
|
);
|
|
}
|
|
this.disconnect = 1;
|
|
} else {
|
|
this._link();
|
|
this.disconnect = 2;
|
|
}
|
|
|
|
this.x = x;
|
|
this.y = y;
|
|
return this;
|
|
}
|
|
|
|
arc(cx, cy, theta) {
|
|
const radius = Math.sqrt(
|
|
(cx - this.x) * (cx - this.x) +
|
|
(cy - this.y) * (cy - this.y)
|
|
);
|
|
const theta1 = Math.atan2(this.x - cx, cy - this.y);
|
|
const nextX = cx + Math.sin(theta1 + theta) * radius;
|
|
const nextY = cy - Math.cos(theta1 + theta) * radius;
|
|
|
|
if(this.pattern) {
|
|
const dir = (theta < 0 ? 1 : -1);
|
|
const dt = this.dw / radius;
|
|
|
|
for(let t = theta1; t + dt <= theta1 + theta; t += dt) {
|
|
const delta = this._nextDelta() * dir;
|
|
this.points.push(
|
|
(cx + Math.sin(t) * (radius + delta)) + ' ' +
|
|
(cy - Math.cos(t) * (radius + delta))
|
|
);
|
|
}
|
|
this.disconnect = 1;
|
|
} else {
|
|
this.points.push(
|
|
this.x + ' ' + this.y +
|
|
'A' + radius + ' ' + radius + ' 0 ' +
|
|
((Math.abs(theta) >= Math.PI) ? '1 ' : '0 ') +
|
|
((theta < 0) ? '0 ' : '1 ') +
|
|
nextX + ' ' + nextY
|
|
);
|
|
this.disconnect = 0;
|
|
}
|
|
|
|
this.x = nextX;
|
|
this.y = nextY;
|
|
|
|
return this;
|
|
}
|
|
|
|
asPath() {
|
|
this._link();
|
|
return 'M' + this.points.join('L');
|
|
}
|
|
};
|
|
});
|
|
|
|
define('svg/SVGShapes',[
|
|
'./SVGUtilities',
|
|
'./SVGTextBlock',
|
|
'./PatternedLine',
|
|
], (
|
|
svg,
|
|
SVGTextBlock,
|
|
PatternedLine
|
|
) => {
|
|
'use strict';
|
|
|
|
function renderBox(attrs, position) {
|
|
return svg.make('rect', Object.assign({}, position, attrs));
|
|
}
|
|
|
|
function renderLine(attrs, position) {
|
|
return svg.make('line', Object.assign({}, position, attrs));
|
|
}
|
|
|
|
function renderNote(attrs, flickAttrs, position) {
|
|
const g = svg.make('g');
|
|
const x0 = position.x;
|
|
const x1 = position.x + position.width;
|
|
const y0 = position.y;
|
|
const y1 = position.y + position.height;
|
|
const flick = 7;
|
|
|
|
g.appendChild(svg.make('polygon', Object.assign({
|
|
'points': (
|
|
x0 + ' ' + y0 + ' ' +
|
|
(x1 - flick) + ' ' + y0 + ' ' +
|
|
x1 + ' ' + (y0 + flick) + ' ' +
|
|
x1 + ' ' + y1 + ' ' +
|
|
x0 + ' ' + y1
|
|
),
|
|
}, attrs)));
|
|
|
|
g.appendChild(svg.make('polyline', Object.assign({
|
|
'points': (
|
|
(x1 - flick) + ' ' + y0 + ' ' +
|
|
(x1 - flick) + ' ' + (y0 + flick) + ' ' +
|
|
x1 + ' ' + (y0 + flick)
|
|
),
|
|
}, flickAttrs)));
|
|
|
|
return g;
|
|
}
|
|
|
|
function calculateAnchor(x, attrs, padding) {
|
|
let shift = 0;
|
|
let anchorX = x;
|
|
switch(attrs['text-anchor']) {
|
|
case 'middle':
|
|
shift = 0.5;
|
|
anchorX += (padding.left - padding.right) / 2;
|
|
break;
|
|
case 'end':
|
|
shift = 1;
|
|
anchorX -= padding.right;
|
|
break;
|
|
default:
|
|
shift = 0;
|
|
anchorX += padding.left;
|
|
break;
|
|
}
|
|
return {shift, anchorX};
|
|
}
|
|
|
|
function renderBoxedText(formatted, {
|
|
x,
|
|
y,
|
|
padding,
|
|
boxAttrs,
|
|
labelAttrs,
|
|
boxLayer,
|
|
labelLayer,
|
|
boxRenderer = null,
|
|
SVGTextBlockClass = SVGTextBlock,
|
|
}) {
|
|
if(!formatted || !formatted.length) {
|
|
return {width: 0, height: 0, label: null, box: null};
|
|
}
|
|
|
|
const {shift, anchorX} = calculateAnchor(x, labelAttrs, padding);
|
|
|
|
const label = new SVGTextBlockClass(labelLayer, {
|
|
attrs: labelAttrs,
|
|
formatted,
|
|
x: anchorX,
|
|
y: y + padding.top,
|
|
});
|
|
|
|
const width = (label.width + padding.left + padding.right);
|
|
const height = (label.height + padding.top + padding.bottom);
|
|
|
|
let box = null;
|
|
if(boxRenderer) {
|
|
box = boxRenderer({
|
|
'x': anchorX - label.width * shift - padding.left,
|
|
'y': y,
|
|
'width': width,
|
|
'height': height,
|
|
});
|
|
} else {
|
|
box = renderBox(boxAttrs, {
|
|
'x': anchorX - label.width * shift - padding.left,
|
|
'y': y,
|
|
'width': width,
|
|
'height': height,
|
|
});
|
|
}
|
|
|
|
if(boxLayer === labelLayer) {
|
|
boxLayer.insertBefore(box, label.firstLine());
|
|
} else {
|
|
boxLayer.appendChild(box);
|
|
}
|
|
|
|
return {width, height, label, box};
|
|
}
|
|
|
|
return {
|
|
renderBox,
|
|
renderLine,
|
|
renderNote,
|
|
renderBoxedText,
|
|
TextBlock: SVGTextBlock,
|
|
PatternedLine,
|
|
};
|
|
});
|
|
|
|
define('sequence/components/BaseComponent',[],() => {
|
|
'use strict';
|
|
|
|
class BaseComponent {
|
|
makeState(/*state*/) {
|
|
}
|
|
|
|
resetState(state) {
|
|
this.makeState(state);
|
|
}
|
|
|
|
separationPre(/*stage, {
|
|
theme,
|
|
agentInfos,
|
|
visibleAgentIDs,
|
|
momentaryAgentIDs,
|
|
textSizer,
|
|
addSpacing,
|
|
addSeparation,
|
|
state,
|
|
components,
|
|
}*/) {
|
|
}
|
|
|
|
separation(/*stage, {
|
|
theme,
|
|
agentInfos,
|
|
visibleAgentIDs,
|
|
momentaryAgentIDs,
|
|
textSizer,
|
|
addSpacing,
|
|
addSeparation,
|
|
state,
|
|
components,
|
|
}*/) {
|
|
}
|
|
|
|
renderPre(/*stage, {
|
|
theme,
|
|
agentInfos,
|
|
textSizer,
|
|
state,
|
|
components,
|
|
}*/) {
|
|
// return {topShift, agentIDs, asynchronousY}
|
|
}
|
|
|
|
render(/*stage, {
|
|
topY,
|
|
primaryY,
|
|
blockLayer,
|
|
shapeLayer,
|
|
labelLayer,
|
|
theme,
|
|
agentInfos,
|
|
textSizer,
|
|
SVGTextBlockClass,
|
|
addDef,
|
|
makeRegion,
|
|
state,
|
|
components,
|
|
}*/) {
|
|
// return bottom Y coordinate
|
|
}
|
|
}
|
|
|
|
BaseComponent.cleanRenderPreResult = ({
|
|
agentIDs = [],
|
|
topShift = 0,
|
|
y = null,
|
|
asynchronousY = null,
|
|
} = {}, currentY = null) => {
|
|
if(y !== null && currentY !== null) {
|
|
topShift = Math.max(topShift, y - currentY);
|
|
}
|
|
return {
|
|
agentIDs,
|
|
topShift,
|
|
y,
|
|
asynchronousY: (asynchronousY !== null) ? asynchronousY : currentY,
|
|
};
|
|
};
|
|
|
|
const components = new Map();
|
|
|
|
BaseComponent.register = (name, component) => {
|
|
components.set(name, component);
|
|
};
|
|
|
|
BaseComponent.getComponents = () => {
|
|
return components;
|
|
};
|
|
|
|
return BaseComponent;
|
|
});
|
|
|
|
define('sequence/components/Block',[
|
|
'./BaseComponent',
|
|
'core/ArrayUtilities',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseComponent,
|
|
array,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
class BlockSplit extends BaseComponent {
|
|
separation({left, right, tag, label}, env) {
|
|
const blockInfo = env.state.blocks.get(left);
|
|
const config = env.theme.getBlock(blockInfo.type).section;
|
|
const width = (
|
|
env.textSizer.measure(config.tag.labelAttrs, tag).width +
|
|
config.tag.padding.left +
|
|
config.tag.padding.right +
|
|
env.textSizer.measure(config.label.labelAttrs, label).width +
|
|
config.label.padding.left +
|
|
config.label.padding.right
|
|
);
|
|
env.addSeparation(left, right, width);
|
|
}
|
|
|
|
renderPre({left, right}) {
|
|
return {
|
|
agentIDs: [left, right],
|
|
};
|
|
}
|
|
|
|
render({left, right, tag, label}, env, first = false) {
|
|
const blockInfo = env.state.blocks.get(left);
|
|
const config = env.theme.getBlock(blockInfo.type);
|
|
const agentInfoL = env.agentInfos.get(left);
|
|
const agentInfoR = env.agentInfos.get(right);
|
|
|
|
let y = env.primaryY;
|
|
|
|
if(!first) {
|
|
y += config.section.padding.bottom;
|
|
}
|
|
|
|
const clickable = env.makeRegion();
|
|
|
|
const tagRender = SVGShapes.renderBoxedText(tag, {
|
|
x: agentInfoL.x,
|
|
y,
|
|
padding: config.section.tag.padding,
|
|
boxAttrs: config.section.tag.boxAttrs,
|
|
boxRenderer: config.section.tag.boxRenderer,
|
|
labelAttrs: config.section.tag.labelAttrs,
|
|
boxLayer: blockInfo.hold,
|
|
labelLayer: clickable,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
|
|
const labelRender = SVGShapes.renderBoxedText(label, {
|
|
x: agentInfoL.x + tagRender.width,
|
|
y,
|
|
padding: config.section.label.padding,
|
|
boxAttrs: {'fill': '#000000'},
|
|
labelAttrs: config.section.label.labelAttrs,
|
|
boxLayer: env.maskLayer,
|
|
labelLayer: clickable,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
|
|
const labelHeight = Math.max(tagRender.height, labelRender.height);
|
|
|
|
clickable.insertBefore(svg.make('rect', {
|
|
'x': agentInfoL.x,
|
|
'y': y,
|
|
'width': agentInfoR.x - agentInfoL.x,
|
|
'height': labelHeight,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}), clickable.firstChild);
|
|
|
|
if(!first) {
|
|
blockInfo.hold.appendChild(config.sepRenderer({
|
|
'x1': agentInfoL.x,
|
|
'y1': y,
|
|
'x2': agentInfoR.x,
|
|
'y2': y,
|
|
}));
|
|
}
|
|
|
|
return y + labelHeight + config.section.padding.top;
|
|
}
|
|
}
|
|
|
|
class BlockBegin extends BlockSplit {
|
|
makeState(state) {
|
|
state.blocks = new Map();
|
|
}
|
|
|
|
resetState(state) {
|
|
state.blocks.clear();
|
|
}
|
|
|
|
storeBlockInfo(stage, env) {
|
|
const blockInfo = {
|
|
type: stage.blockType,
|
|
hold: null,
|
|
startY: null,
|
|
};
|
|
env.state.blocks.set(stage.left, blockInfo);
|
|
return blockInfo;
|
|
}
|
|
|
|
separationPre(stage, env) {
|
|
this.storeBlockInfo(stage, env);
|
|
}
|
|
|
|
separation(stage, env) {
|
|
array.mergeSets(env.visibleAgentIDs, [stage.left, stage.right]);
|
|
super.separation(stage, env);
|
|
}
|
|
|
|
renderPre(stage, env) {
|
|
const blockInfo = this.storeBlockInfo(stage, env);
|
|
|
|
const config = env.theme.getBlock(blockInfo.type);
|
|
|
|
return {
|
|
agentIDs: [stage.left, stage.right],
|
|
topShift: config.margin.top,
|
|
};
|
|
}
|
|
|
|
render(stage, env) {
|
|
const hold = svg.make('g');
|
|
env.blockLayer.appendChild(hold);
|
|
|
|
const blockInfo = env.state.blocks.get(stage.left);
|
|
blockInfo.hold = hold;
|
|
blockInfo.startY = env.primaryY;
|
|
|
|
return super.render(stage, env, true);
|
|
}
|
|
}
|
|
|
|
class BlockEnd extends BaseComponent {
|
|
separation({left, right}, env) {
|
|
array.removeAll(env.visibleAgentIDs, [left, right]);
|
|
}
|
|
|
|
renderPre({left, right}, env) {
|
|
const blockInfo = env.state.blocks.get(left);
|
|
const config = env.theme.getBlock(blockInfo.type);
|
|
|
|
return {
|
|
agentIDs: [left, right],
|
|
topShift: config.section.padding.bottom,
|
|
};
|
|
}
|
|
|
|
render({left, right}, env) {
|
|
const blockInfo = env.state.blocks.get(left);
|
|
const config = env.theme.getBlock(blockInfo.type);
|
|
const agentInfoL = env.agentInfos.get(left);
|
|
const agentInfoR = env.agentInfos.get(right);
|
|
|
|
blockInfo.hold.appendChild(config.boxRenderer({
|
|
x: agentInfoL.x,
|
|
y: blockInfo.startY,
|
|
width: agentInfoR.x - agentInfoL.x,
|
|
height: env.primaryY - blockInfo.startY,
|
|
}));
|
|
|
|
return env.primaryY + config.margin.bottom + env.theme.actionMargin;
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('block begin', new BlockBegin());
|
|
BaseComponent.register('block split', new BlockSplit());
|
|
BaseComponent.register('block end', new BlockEnd());
|
|
|
|
return {
|
|
BlockBegin,
|
|
BlockSplit,
|
|
BlockEnd,
|
|
};
|
|
});
|
|
|
|
define('sequence/components/Parallel',[
|
|
'./BaseComponent',
|
|
'core/ArrayUtilities',
|
|
], (
|
|
BaseComponent,
|
|
array
|
|
) => {
|
|
'use strict';
|
|
|
|
function nullableMax(a = null, b = null) {
|
|
if(a === null) {
|
|
return b;
|
|
}
|
|
if(b === null) {
|
|
return a;
|
|
}
|
|
return Math.max(a, b);
|
|
}
|
|
|
|
function mergeResults(a, b) {
|
|
array.mergeSets(a.agentIDs, b.agentIDs);
|
|
return {
|
|
agentIDs: a.agentIDs,
|
|
topShift: Math.max(a.topShift, b.topShift),
|
|
y: nullableMax(a.y, b.y),
|
|
asynchronousY: nullableMax(a.asynchronousY, b.asynchronousY),
|
|
};
|
|
}
|
|
|
|
class Parallel extends BaseComponent {
|
|
separationPre(stage, env) {
|
|
stage.stages.forEach((subStage) => {
|
|
env.components.get(subStage.type).separationPre(subStage, env);
|
|
});
|
|
}
|
|
|
|
separation(stage, env) {
|
|
stage.stages.forEach((subStage) => {
|
|
env.components.get(subStage.type).separation(subStage, env);
|
|
});
|
|
}
|
|
|
|
renderPre(stage, env) {
|
|
const baseResults = {
|
|
topShift: 0,
|
|
agentIDs: [],
|
|
asynchronousY: null,
|
|
};
|
|
|
|
return stage.stages.map((subStage) => {
|
|
const component = env.components.get(subStage.type);
|
|
const subResult = component.renderPre(subStage, env);
|
|
return BaseComponent.cleanRenderPreResult(subResult);
|
|
}).reduce(mergeResults, baseResults);
|
|
}
|
|
|
|
render(stage, env) {
|
|
const originalMakeRegion = env.makeRegion;
|
|
let bottomY = 0;
|
|
stage.stages.forEach((subStage) => {
|
|
env.makeRegion = (o, stageOverride = null) => {
|
|
return originalMakeRegion(o, stageOverride || subStage);
|
|
};
|
|
|
|
const component = env.components.get(subStage.type);
|
|
const baseY = component.render(subStage, env) || 0;
|
|
bottomY = Math.max(bottomY, baseY);
|
|
});
|
|
env.makeRegion = originalMakeRegion;
|
|
return bottomY;
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('parallel', new Parallel());
|
|
|
|
return Parallel;
|
|
});
|
|
|
|
define('sequence/components/Marker',['./BaseComponent'], (BaseComponent) => {
|
|
'use strict';
|
|
|
|
class Mark extends BaseComponent {
|
|
makeState(state) {
|
|
state.marks = new Map();
|
|
}
|
|
|
|
resetState(state) {
|
|
state.marks.clear();
|
|
}
|
|
|
|
render({name}, {topY, state}) {
|
|
state.marks.set(name, topY);
|
|
}
|
|
}
|
|
|
|
class Async extends BaseComponent {
|
|
renderPre({target}, {state}) {
|
|
let y = 0;
|
|
if(target && state.marks) {
|
|
y = state.marks.get(target) || 0;
|
|
}
|
|
return {
|
|
asynchronousY: y,
|
|
};
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('mark', new Mark());
|
|
BaseComponent.register('async', new Async());
|
|
|
|
return {
|
|
Mark,
|
|
Async,
|
|
};
|
|
});
|
|
|
|
define('sequence/components/AgentCap',[
|
|
'./BaseComponent',
|
|
'core/ArrayUtilities',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseComponent,
|
|
array,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
class CapBox {
|
|
separation({formattedLabel}, env) {
|
|
const config = env.theme.agentCap.box;
|
|
const width = (
|
|
env.textSizer.measure(config.labelAttrs, formattedLabel).width +
|
|
config.padding.left +
|
|
config.padding.right
|
|
);
|
|
|
|
return {
|
|
left: width / 2,
|
|
right: width / 2,
|
|
radius: width / 2,
|
|
};
|
|
}
|
|
|
|
topShift({formattedLabel}, env) {
|
|
const config = env.theme.agentCap.box;
|
|
const height = (
|
|
env.textSizer.measureHeight(config.labelAttrs, formattedLabel) +
|
|
config.padding.top +
|
|
config.padding.bottom
|
|
);
|
|
return Math.max(0, height - config.arrowBottom);
|
|
}
|
|
|
|
render(y, {x, formattedLabel}, env) {
|
|
const config = env.theme.agentCap.box;
|
|
const clickable = env.makeRegion();
|
|
const {width, height} = SVGShapes.renderBoxedText(formattedLabel, {
|
|
x,
|
|
y,
|
|
padding: config.padding,
|
|
boxAttrs: config.boxAttrs,
|
|
boxRenderer: config.boxRenderer,
|
|
labelAttrs: config.labelAttrs,
|
|
boxLayer: env.shapeLayer,
|
|
labelLayer: clickable,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
clickable.insertBefore(svg.make('rect', {
|
|
'x': x - width / 2,
|
|
'y': y,
|
|
'width': width,
|
|
'height': height,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}), clickable.firstChild);
|
|
|
|
return {
|
|
lineTop: 0,
|
|
lineBottom: height,
|
|
height,
|
|
};
|
|
}
|
|
}
|
|
|
|
class CapCross {
|
|
separation(agentInfo, env) {
|
|
const config = env.theme.agentCap.cross;
|
|
return {
|
|
left: config.size / 2,
|
|
right: config.size / 2,
|
|
radius: 0,
|
|
};
|
|
}
|
|
|
|
topShift(agentInfo, env) {
|
|
const config = env.theme.agentCap.cross;
|
|
return config.size / 2;
|
|
}
|
|
|
|
render(y, {x}, env) {
|
|
const config = env.theme.agentCap.cross;
|
|
const d = config.size / 2;
|
|
|
|
env.shapeLayer.appendChild(config.render({x, y: y + d, radius: d}));
|
|
|
|
env.makeRegion().appendChild(svg.make('rect', {
|
|
'x': x - d,
|
|
'y': y,
|
|
'width': d * 2,
|
|
'height': d * 2,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}));
|
|
|
|
return {
|
|
lineTop: d,
|
|
lineBottom: d,
|
|
height: d * 2,
|
|
};
|
|
}
|
|
}
|
|
|
|
class CapBar {
|
|
separation({formattedLabel}, env) {
|
|
const config = env.theme.agentCap.box;
|
|
const width = (
|
|
env.textSizer.measure(config.labelAttrs, formattedLabel).width +
|
|
config.padding.left +
|
|
config.padding.right
|
|
);
|
|
|
|
return {
|
|
left: width / 2,
|
|
right: width / 2,
|
|
radius: width / 2,
|
|
};
|
|
}
|
|
|
|
topShift(agentInfo, env) {
|
|
const config = env.theme.agentCap.bar;
|
|
return config.height / 2;
|
|
}
|
|
|
|
render(y, {x, formattedLabel}, env) {
|
|
const boxCfg = env.theme.agentCap.box;
|
|
const barCfg = env.theme.agentCap.bar;
|
|
const width = (
|
|
env.textSizer.measure(boxCfg.labelAttrs, formattedLabel).width +
|
|
boxCfg.padding.left +
|
|
boxCfg.padding.right
|
|
);
|
|
const height = barCfg.height;
|
|
|
|
env.shapeLayer.appendChild(barCfg.render({
|
|
x: x - width / 2,
|
|
y,
|
|
width,
|
|
height,
|
|
}));
|
|
|
|
env.makeRegion().appendChild(svg.make('rect', {
|
|
'x': x - width / 2,
|
|
'y': y,
|
|
'width': width,
|
|
'height': height,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}));
|
|
|
|
return {
|
|
lineTop: 0,
|
|
lineBottom: height,
|
|
height: height,
|
|
};
|
|
}
|
|
}
|
|
|
|
class CapFade {
|
|
separation({currentRad}) {
|
|
return {
|
|
left: currentRad,
|
|
right: currentRad,
|
|
radius: currentRad,
|
|
};
|
|
}
|
|
|
|
topShift(agentInfo, env, isBegin) {
|
|
const config = env.theme.agentCap.fade;
|
|
return isBegin ? config.height : 0;
|
|
}
|
|
|
|
render(y, {x}, env, isBegin) {
|
|
const config = env.theme.agentCap.fade;
|
|
const ratio = config.height / (config.height + config.extend);
|
|
|
|
const gradID = env.addDef(isBegin ? 'FadeIn' : 'FadeOut', () => {
|
|
const grad = svg.make('linearGradient', {
|
|
'x1': '0%',
|
|
'y1': isBegin ? '100%' : '0%',
|
|
'x2': '0%',
|
|
'y2': isBegin ? '0%' : '100%',
|
|
});
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': '0%',
|
|
'stop-color': '#FFFFFF',
|
|
}));
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': (100 * ratio).toFixed(3) + '%',
|
|
'stop-color': '#000000',
|
|
}));
|
|
return grad;
|
|
});
|
|
|
|
env.maskLayer.appendChild(svg.make('rect', {
|
|
'x': x - config.width / 2,
|
|
'y': y - (isBegin ? config.extend : 0),
|
|
'width': config.width,
|
|
'height': config.height + config.extend,
|
|
'fill': 'url(#' + gradID + ')',
|
|
}));
|
|
|
|
env.makeRegion().appendChild(svg.make('rect', {
|
|
'x': x - config.width / 2,
|
|
'y': y,
|
|
'width': config.width,
|
|
'height': config.height,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}));
|
|
|
|
return {
|
|
lineTop: config.height,
|
|
lineBottom: 0,
|
|
height: config.height,
|
|
};
|
|
}
|
|
}
|
|
|
|
class CapNone {
|
|
separation({currentRad}) {
|
|
return {
|
|
left: currentRad,
|
|
right: currentRad,
|
|
radius: currentRad,
|
|
};
|
|
}
|
|
|
|
topShift(agentInfo, env) {
|
|
const config = env.theme.agentCap.none;
|
|
return config.height;
|
|
}
|
|
|
|
render(y, {x}, env) {
|
|
const config = env.theme.agentCap.none;
|
|
|
|
const w = 10;
|
|
env.makeRegion().appendChild(svg.make('rect', {
|
|
'x': x - w / 2,
|
|
'y': y,
|
|
'width': w,
|
|
'height': config.height,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}));
|
|
|
|
return {
|
|
lineTop: config.height,
|
|
lineBottom: 0,
|
|
height: config.height,
|
|
};
|
|
}
|
|
}
|
|
|
|
const AGENT_CAPS = {
|
|
'box': new CapBox(),
|
|
'cross': new CapCross(),
|
|
'bar': new CapBar(),
|
|
'fade': new CapFade(),
|
|
'none': new CapNone(),
|
|
};
|
|
|
|
class AgentCap extends BaseComponent {
|
|
constructor(begin) {
|
|
super();
|
|
this.begin = begin;
|
|
}
|
|
|
|
separationPre({mode, agentIDs}, env) {
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
const cap = AGENT_CAPS[mode];
|
|
const sep = cap.separation(agentInfo, env, this.begin);
|
|
env.addSpacing(id, sep);
|
|
agentInfo.currentMaxRad = Math.max(
|
|
agentInfo.currentMaxRad,
|
|
sep.radius
|
|
);
|
|
});
|
|
}
|
|
|
|
separation({mode, agentIDs}, env) {
|
|
if(this.begin) {
|
|
array.mergeSets(env.visibleAgentIDs, agentIDs);
|
|
} else {
|
|
array.removeAll(env.visibleAgentIDs, agentIDs);
|
|
}
|
|
}
|
|
|
|
renderPre({mode, agentIDs}, env) {
|
|
let maxTopShift = 0;
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
const cap = AGENT_CAPS[mode];
|
|
const topShift = cap.topShift(agentInfo, env, this.begin);
|
|
maxTopShift = Math.max(maxTopShift, topShift);
|
|
|
|
const r = cap.separation(agentInfo, env, this.begin).radius;
|
|
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
|
});
|
|
return {
|
|
agentIDs,
|
|
topShift: maxTopShift,
|
|
};
|
|
}
|
|
|
|
render({mode, agentIDs}, env) {
|
|
let maxEnd = 0;
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
const cap = AGENT_CAPS[mode];
|
|
const topShift = cap.topShift(agentInfo, env, this.begin);
|
|
const y0 = env.primaryY - topShift;
|
|
const shifts = cap.render(
|
|
y0,
|
|
agentInfo,
|
|
env,
|
|
this.begin
|
|
);
|
|
maxEnd = Math.max(maxEnd, y0 + shifts.height);
|
|
if(this.begin) {
|
|
env.drawAgentLine(id, y0 + shifts.lineBottom);
|
|
} else {
|
|
env.drawAgentLine(id, y0 + shifts.lineTop, true);
|
|
}
|
|
});
|
|
return maxEnd + env.theme.actionMargin;
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('agent begin', new AgentCap(true));
|
|
BaseComponent.register('agent end', new AgentCap(false));
|
|
|
|
return AgentCap;
|
|
});
|
|
|
|
define('sequence/components/AgentHighlight',['./BaseComponent'], (BaseComponent) => {
|
|
'use strict';
|
|
|
|
class AgentHighlight extends BaseComponent {
|
|
radius(highlighted, env) {
|
|
return highlighted ? env.theme.agentLineHighlightRadius : 0;
|
|
}
|
|
|
|
separationPre({agentIDs, highlighted}, env) {
|
|
const r = this.radius(highlighted, env);
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
agentInfo.currentRad = r;
|
|
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
|
});
|
|
}
|
|
|
|
renderPre({agentIDs, highlighted}, env) {
|
|
const r = this.radius(highlighted, env);
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
|
});
|
|
}
|
|
|
|
render({agentIDs, highlighted}, env) {
|
|
const r = this.radius(highlighted, env);
|
|
agentIDs.forEach((id) => {
|
|
env.drawAgentLine(id, env.primaryY);
|
|
env.agentInfos.get(id).currentRad = r;
|
|
});
|
|
return env.primaryY + env.theme.actionMargin;
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('agent highlight', new AgentHighlight());
|
|
|
|
return AgentHighlight;
|
|
});
|
|
|
|
define('sequence/components/Connect',[
|
|
'core/ArrayUtilities',
|
|
'./BaseComponent',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
array,
|
|
BaseComponent,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
class Arrowhead {
|
|
constructor(propName) {
|
|
this.propName = propName;
|
|
}
|
|
|
|
getConfig(theme) {
|
|
return theme.connect.arrow[this.propName];
|
|
}
|
|
|
|
short(theme) {
|
|
const arrow = this.getConfig(theme);
|
|
const join = arrow.attrs['stroke-linejoin'] || 'miter';
|
|
const t = arrow.attrs['stroke-width'] * 0.5;
|
|
const lineStroke = theme.agentLineAttrs['stroke-width'] * 0.5;
|
|
if(join === 'round') {
|
|
return lineStroke + t;
|
|
} else {
|
|
const h = arrow.height / 2;
|
|
const w = arrow.width;
|
|
const arrowDistance = t * Math.sqrt((w * w) / (h * h) + 1);
|
|
return lineStroke + arrowDistance;
|
|
}
|
|
}
|
|
|
|
render(layer, theme, pt, dir) {
|
|
const config = this.getConfig(theme);
|
|
const short = this.short(theme);
|
|
layer.appendChild(config.render(config.attrs, {
|
|
x: pt.x + short * dir.dx,
|
|
y: pt.y + short * dir.dy,
|
|
width: config.width,
|
|
height: config.height,
|
|
dir,
|
|
}));
|
|
}
|
|
|
|
width(theme) {
|
|
return this.short(theme) + this.getConfig(theme).width;
|
|
}
|
|
|
|
height(theme) {
|
|
return this.getConfig(theme).height;
|
|
}
|
|
|
|
lineGap(theme, lineAttrs) {
|
|
const arrow = this.getConfig(theme);
|
|
const short = this.short(theme);
|
|
if(arrow.attrs.fill === 'none') {
|
|
const h = arrow.height / 2;
|
|
const w = arrow.width;
|
|
const safe = short + (lineAttrs['stroke-width'] / 2) * (w / h);
|
|
return (short + safe) / 2;
|
|
} else {
|
|
return short + arrow.width / 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
class Arrowcross {
|
|
getConfig(theme) {
|
|
return theme.connect.arrow.cross;
|
|
}
|
|
|
|
render(layer, theme, pt, dir) {
|
|
const config = this.getConfig(theme);
|
|
layer.appendChild(config.render({
|
|
x: pt.x + config.short * dir.dx,
|
|
y: pt.y + config.short * dir.dy,
|
|
radius: config.radius,
|
|
}));
|
|
}
|
|
|
|
width(theme) {
|
|
const config = this.getConfig(theme);
|
|
return config.short + config.radius;
|
|
}
|
|
|
|
height(theme) {
|
|
return this.getConfig(theme).radius * 2;
|
|
}
|
|
|
|
lineGap(theme) {
|
|
return this.getConfig(theme).short;
|
|
}
|
|
}
|
|
|
|
const ARROWHEADS = [
|
|
{
|
|
render: () => {},
|
|
width: () => 0,
|
|
height: () => 0,
|
|
lineGap: () => 0,
|
|
},
|
|
new Arrowhead('single'),
|
|
new Arrowhead('double'),
|
|
new Arrowcross(),
|
|
];
|
|
|
|
class Connect extends BaseComponent {
|
|
separationPre({agentIDs}, env) {
|
|
const r = env.theme.connect.source.radius;
|
|
agentIDs.forEach((id) => {
|
|
const agentInfo = env.agentInfos.get(id);
|
|
if(!agentInfo.isVirtualSource) {
|
|
return;
|
|
}
|
|
agentInfo.currentRad = r;
|
|
agentInfo.currentMaxRad = Math.max(agentInfo.currentMaxRad, r);
|
|
});
|
|
}
|
|
|
|
separation({label, agentIDs, options}, env) {
|
|
const config = env.theme.connect;
|
|
|
|
const lArrow = ARROWHEADS[options.left];
|
|
const rArrow = ARROWHEADS[options.right];
|
|
|
|
let labelWidth = (
|
|
env.textSizer.measure(config.label.attrs, label).width
|
|
);
|
|
if(labelWidth > 0) {
|
|
labelWidth += config.label.padding * 2;
|
|
}
|
|
|
|
const info1 = env.agentInfos.get(agentIDs[0]);
|
|
if(agentIDs[0] === agentIDs[1]) {
|
|
env.addSpacing(agentIDs[0], {
|
|
left: 0,
|
|
right: (
|
|
info1.currentMaxRad +
|
|
Math.max(
|
|
labelWidth + lArrow.width(env.theme),
|
|
rArrow.width(env.theme)
|
|
) +
|
|
config.loopbackRadius
|
|
),
|
|
});
|
|
} else {
|
|
const info2 = env.agentInfos.get(agentIDs[1]);
|
|
env.addSeparation(
|
|
agentIDs[0],
|
|
agentIDs[1],
|
|
|
|
info1.currentMaxRad +
|
|
info2.currentMaxRad +
|
|
labelWidth +
|
|
Math.max(
|
|
lArrow.width(env.theme),
|
|
rArrow.width(env.theme)
|
|
) * 2
|
|
);
|
|
}
|
|
|
|
array.mergeSets(env.momentaryAgentIDs, agentIDs);
|
|
}
|
|
|
|
renderRevArrowLine({x1, y1, x2, y2, xR}, options, env) {
|
|
const config = env.theme.connect;
|
|
const line = config.line[options.line];
|
|
const lArrow = ARROWHEADS[options.left];
|
|
const rArrow = ARROWHEADS[options.right];
|
|
|
|
const dx1 = lArrow.lineGap(env.theme, line.attrs);
|
|
const dx2 = rArrow.lineGap(env.theme, line.attrs);
|
|
const rendered = line.renderRev(line.attrs, {
|
|
x1: x1 + dx1,
|
|
y1,
|
|
x2: x2 + dx2,
|
|
y2,
|
|
xR,
|
|
rad: config.loopbackRadius,
|
|
});
|
|
env.shapeLayer.appendChild(rendered.shape);
|
|
|
|
lArrow.render(env.shapeLayer, env.theme, {
|
|
x: rendered.p1.x - dx1,
|
|
y: rendered.p1.y,
|
|
}, {dx: 1, dy: 0});
|
|
|
|
rArrow.render(env.shapeLayer, env.theme, {
|
|
x: rendered.p2.x - dx2,
|
|
y: rendered.p2.y,
|
|
}, {dx: 1, dy: 0});
|
|
}
|
|
|
|
renderSelfConnect({label, agentIDs, options}, env, from, yBegin) {
|
|
const config = env.theme.connect;
|
|
|
|
const lArrow = ARROWHEADS[options.left];
|
|
const rArrow = ARROWHEADS[options.right];
|
|
|
|
const to = env.agentInfos.get(agentIDs[1]);
|
|
|
|
const height = label ? (
|
|
env.textSizer.measureHeight(config.label.attrs, label) +
|
|
config.label.margin.top +
|
|
config.label.margin.bottom
|
|
) : 0;
|
|
|
|
const xL = (
|
|
from.x + from.currentMaxRad +
|
|
lArrow.width(env.theme) +
|
|
(label ? config.label.padding : 0)
|
|
);
|
|
|
|
const clickable = env.makeRegion();
|
|
|
|
const renderedText = SVGShapes.renderBoxedText(label, {
|
|
x: xL - config.mask.padding.left,
|
|
y: yBegin - height + config.label.margin.top,
|
|
padding: config.mask.padding,
|
|
boxAttrs: {'fill': '#000000'},
|
|
labelAttrs: config.label.loopbackAttrs,
|
|
boxLayer: env.maskLayer,
|
|
labelLayer: clickable,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
const labelW = (label ? (
|
|
renderedText.width +
|
|
config.label.padding -
|
|
config.mask.padding.left -
|
|
config.mask.padding.right
|
|
) : 0);
|
|
|
|
const xR = Math.max(
|
|
to.x + to.currentMaxRad + rArrow.width(env.theme),
|
|
xL + labelW
|
|
);
|
|
|
|
this.renderRevArrowLine({
|
|
x1: from.x + from.currentMaxRad,
|
|
y1: yBegin,
|
|
x2: to.x + to.currentMaxRad,
|
|
y2: env.primaryY,
|
|
xR,
|
|
}, options, env);
|
|
|
|
const raise = Math.max(height, lArrow.height(env.theme) / 2);
|
|
const arrowDip = rArrow.height(env.theme) / 2;
|
|
|
|
clickable.insertBefore(svg.make('rect', {
|
|
'x': from.x,
|
|
'y': yBegin - raise,
|
|
'width': xR + config.loopbackRadius - from.x,
|
|
'height': raise + env.primaryY - yBegin + arrowDip,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}), clickable.firstChild);
|
|
|
|
return (
|
|
env.primaryY +
|
|
Math.max(arrowDip, 0) +
|
|
env.theme.actionMargin
|
|
);
|
|
}
|
|
|
|
renderArrowLine({x1, y1, x2, y2}, options, env) {
|
|
const config = env.theme.connect;
|
|
const line = config.line[options.line];
|
|
const lArrow = ARROWHEADS[options.left];
|
|
const rArrow = ARROWHEADS[options.right];
|
|
|
|
const len = Math.sqrt(
|
|
(x2 - x1) * (x2 - x1) +
|
|
(y2 - y1) * (y2 - y1)
|
|
);
|
|
const d1 = lArrow.lineGap(env.theme, line.attrs);
|
|
const d2 = rArrow.lineGap(env.theme, line.attrs);
|
|
const dx = (x2 - x1) / len;
|
|
const dy = (y2 - y1) / len;
|
|
|
|
const rendered = line.renderFlat(line.attrs, {
|
|
x1: x1 + d1 * dx,
|
|
y1: y1 + d1 * dy,
|
|
x2: x2 - d2 * dx,
|
|
y2: y2 - d2 * dy,
|
|
});
|
|
env.shapeLayer.appendChild(rendered.shape);
|
|
|
|
const p1 = {x: rendered.p1.x - d1 * dx, y: rendered.p1.y - d1 * dy};
|
|
const p2 = {x: rendered.p2.x + d2 * dx, y: rendered.p2.y + d2 * dy};
|
|
|
|
lArrow.render(env.shapeLayer, env.theme, p1, {dx, dy});
|
|
rArrow.render(env.shapeLayer, env.theme, p2, {dx: -dx, dy: -dy});
|
|
|
|
return {
|
|
p1,
|
|
p2,
|
|
lArrow,
|
|
rArrow,
|
|
};
|
|
}
|
|
|
|
renderVirtualSources(from, to, renderedLine, env) {
|
|
const config = env.theme.connect.source;
|
|
|
|
if(from.isVirtualSource) {
|
|
env.shapeLayer.appendChild(config.render({
|
|
x: renderedLine.p1.x - config.radius,
|
|
y: renderedLine.p1.y,
|
|
radius: config.radius,
|
|
}));
|
|
}
|
|
if(to.isVirtualSource) {
|
|
env.shapeLayer.appendChild(config.render({
|
|
x: renderedLine.p2.x + config.radius,
|
|
y: renderedLine.p2.y,
|
|
radius: config.radius,
|
|
}));
|
|
}
|
|
}
|
|
|
|
renderSimpleLabel(label, {layer, x1, x2, y1, y2, height}, env) {
|
|
const config = env.theme.connect;
|
|
|
|
const midX = (x1 + x2) / 2;
|
|
const midY = (y1 + y2) / 2;
|
|
|
|
let labelLayer = layer;
|
|
const boxAttrs = {'fill': '#000000'};
|
|
if(y1 !== y2) {
|
|
const angle = Math.atan((y2 - y1) / (x2 - x1));
|
|
const transform = (
|
|
'rotate(' +
|
|
(angle * 180 / Math.PI) +
|
|
' ' + midX + ',' + midY +
|
|
')'
|
|
);
|
|
boxAttrs.transform = transform;
|
|
labelLayer = svg.make('g', {'transform': transform});
|
|
layer.appendChild(labelLayer);
|
|
}
|
|
|
|
SVGShapes.renderBoxedText(label, {
|
|
x: midX,
|
|
y: midY + config.label.margin.top - height,
|
|
padding: config.mask.padding,
|
|
boxAttrs,
|
|
labelAttrs: config.label.attrs,
|
|
boxLayer: env.maskLayer,
|
|
labelLayer,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
}
|
|
|
|
renderSimpleConnect({label, agentIDs, options}, env, from, yBegin) {
|
|
const config = env.theme.connect;
|
|
const to = env.agentInfos.get(agentIDs[1]);
|
|
|
|
const dir = (from.x < to.x) ? 1 : -1;
|
|
|
|
const height = (
|
|
env.textSizer.measureHeight(config.label.attrs, label) +
|
|
config.label.margin.top +
|
|
config.label.margin.bottom
|
|
);
|
|
|
|
const x1 = from.x + from.currentMaxRad * dir;
|
|
const x2 = to.x - to.currentMaxRad * dir;
|
|
|
|
const clickable = env.makeRegion();
|
|
|
|
const rendered = this.renderArrowLine({
|
|
x1,
|
|
y1: yBegin,
|
|
x2,
|
|
y2: env.primaryY,
|
|
}, options, env);
|
|
|
|
const arrowSpread = Math.max(
|
|
rendered.lArrow.height(env.theme),
|
|
rendered.rArrow.height(env.theme)
|
|
) / 2;
|
|
|
|
const lift = Math.max(height, arrowSpread);
|
|
|
|
this.renderVirtualSources(from, to, rendered, env);
|
|
|
|
clickable.appendChild(svg.make('path', {
|
|
'd': (
|
|
'M' + x1 + ',' + (yBegin - lift) +
|
|
'L' + x2 + ',' + (env.primaryY - lift) +
|
|
'L' + x2 + ',' + (env.primaryY + arrowSpread) +
|
|
'L' + x1 + ',' + (yBegin + arrowSpread) +
|
|
'Z'
|
|
),
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}));
|
|
|
|
this.renderSimpleLabel(label, {
|
|
layer: clickable,
|
|
x1,
|
|
y1: yBegin,
|
|
x2,
|
|
y2: env.primaryY,
|
|
height,
|
|
}, env);
|
|
|
|
return env.primaryY + Math.max(
|
|
arrowSpread + env.theme.minActionMargin,
|
|
env.theme.actionMargin
|
|
);
|
|
}
|
|
|
|
renderPre({label, agentIDs, options}, env) {
|
|
const config = env.theme.connect;
|
|
|
|
const lArrow = ARROWHEADS[options.left];
|
|
const rArrow = ARROWHEADS[options.right];
|
|
|
|
const height = (
|
|
env.textSizer.measureHeight(config.label.attrs, label) +
|
|
config.label.margin.top +
|
|
config.label.margin.bottom
|
|
);
|
|
|
|
let arrowH = lArrow.height(env.theme);
|
|
if(agentIDs[0] !== agentIDs[1]) {
|
|
arrowH = Math.max(arrowH, rArrow.height(env.theme));
|
|
}
|
|
|
|
return {
|
|
agentIDs,
|
|
topShift: Math.max(arrowH / 2, height),
|
|
};
|
|
}
|
|
|
|
render(stage, env, from = null, yBegin = null) {
|
|
if(from === null) {
|
|
from = env.agentInfos.get(stage.agentIDs[0]);
|
|
yBegin = env.primaryY;
|
|
}
|
|
if(stage.agentIDs[0] === stage.agentIDs[1]) {
|
|
return this.renderSelfConnect(stage, env, from, yBegin);
|
|
} else {
|
|
return this.renderSimpleConnect(stage, env, from, yBegin);
|
|
}
|
|
}
|
|
}
|
|
|
|
class ConnectDelayBegin extends Connect {
|
|
makeState(state) {
|
|
state.delayedConnections = new Map();
|
|
}
|
|
|
|
resetState(state) {
|
|
state.delayedConnections.clear();
|
|
}
|
|
|
|
separation(stage, env) {
|
|
super.separation(stage, env);
|
|
array.mergeSets(env.momentaryAgentIDs, [stage.agentIDs[0]]);
|
|
}
|
|
|
|
renderPre(stage, env) {
|
|
return Object.assign(super.renderPre(stage, env), {
|
|
agentIDs: [stage.agentIDs[0]],
|
|
});
|
|
}
|
|
|
|
render(stage, env) {
|
|
const dc = env.state.delayedConnections;
|
|
dc.set(stage.tag, {
|
|
stage,
|
|
from: Object.assign({}, env.agentInfos.get(stage.agentIDs[0])),
|
|
y: env.primaryY,
|
|
});
|
|
return env.primaryY + env.theme.actionMargin;
|
|
}
|
|
}
|
|
|
|
class ConnectDelayEnd extends Connect {
|
|
separationPre() {}
|
|
|
|
separation() {}
|
|
|
|
renderPre({tag}, env) {
|
|
const config = env.theme.connect;
|
|
|
|
const dc = env.state.delayedConnections;
|
|
const begin = dc.get(tag);
|
|
const beginStage = begin.stage;
|
|
const agentIDs = [beginStage.agentIDs[1]];
|
|
|
|
if(beginStage.agentIDs[0] === beginStage.agentIDs[1]) {
|
|
return {
|
|
agentIDs,
|
|
y: begin.y + config.loopbackRadius * 2,
|
|
};
|
|
}
|
|
|
|
return Object.assign(super.renderPre(beginStage, env), {agentIDs});
|
|
}
|
|
|
|
render({tag}, env) {
|
|
const dc = env.state.delayedConnections;
|
|
const begin = dc.get(tag);
|
|
return super.render(begin.stage, env, begin.from, begin.y);
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('connect', new Connect());
|
|
BaseComponent.register('connect-delay-begin', new ConnectDelayBegin());
|
|
BaseComponent.register('connect-delay-end', new ConnectDelayEnd());
|
|
|
|
return {
|
|
Connect,
|
|
ConnectDelayBegin,
|
|
ConnectDelayEnd,
|
|
};
|
|
});
|
|
|
|
define('sequence/components/Note',['./BaseComponent', 'svg/SVGUtilities'], (BaseComponent, svg) => {
|
|
'use strict';
|
|
|
|
function findExtremes(agentInfos, agentIDs) {
|
|
let min = null;
|
|
let max = null;
|
|
agentIDs.forEach((id) => {
|
|
const info = agentInfos.get(id);
|
|
if(min === null || info.index < min.index) {
|
|
min = info;
|
|
}
|
|
if(max === null || info.index > max.index) {
|
|
max = info;
|
|
}
|
|
});
|
|
return {
|
|
left: min.id,
|
|
right: max.id,
|
|
};
|
|
}
|
|
|
|
class NoteComponent extends BaseComponent {
|
|
renderPre({agentIDs}) {
|
|
return {agentIDs};
|
|
}
|
|
|
|
renderNote({
|
|
xMid = null,
|
|
x0 = null,
|
|
x1 = null,
|
|
anchor,
|
|
mode,
|
|
label,
|
|
}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
|
|
const clickable = env.makeRegion();
|
|
|
|
const y = env.topY + config.margin.top + config.padding.top;
|
|
const labelNode = new env.SVGTextBlockClass(clickable, {
|
|
attrs: config.labelAttrs,
|
|
formatted: label,
|
|
y,
|
|
});
|
|
|
|
const fullW = (
|
|
labelNode.width +
|
|
config.padding.left +
|
|
config.padding.right
|
|
);
|
|
const fullH = (
|
|
config.padding.top +
|
|
labelNode.height +
|
|
config.padding.bottom
|
|
);
|
|
if(x0 === null && xMid !== null) {
|
|
x0 = xMid - fullW / 2;
|
|
}
|
|
if(x1 === null && x0 !== null) {
|
|
x1 = x0 + fullW;
|
|
} else if(x0 === null) {
|
|
x0 = x1 - fullW;
|
|
}
|
|
switch(config.labelAttrs['text-anchor']) {
|
|
case 'middle':
|
|
labelNode.set({
|
|
x: (
|
|
x0 + config.padding.left +
|
|
x1 - config.padding.right
|
|
) / 2,
|
|
y,
|
|
});
|
|
break;
|
|
case 'end':
|
|
labelNode.set({x: x1 - config.padding.right, y});
|
|
break;
|
|
default:
|
|
labelNode.set({x: x0 + config.padding.left, y});
|
|
break;
|
|
}
|
|
|
|
env.shapeLayer.appendChild(config.boxRenderer({
|
|
x: x0,
|
|
y: env.topY + config.margin.top,
|
|
width: x1 - x0,
|
|
height: fullH,
|
|
}));
|
|
|
|
clickable.insertBefore(svg.make('rect', {
|
|
'x': x0,
|
|
'y': env.topY + config.margin.top,
|
|
'width': x1 - x0,
|
|
'height': fullH,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}), clickable.firstChild);
|
|
|
|
return (
|
|
env.topY +
|
|
config.margin.top +
|
|
fullH +
|
|
config.margin.bottom +
|
|
env.theme.actionMargin
|
|
);
|
|
}
|
|
}
|
|
|
|
class NoteOver extends NoteComponent {
|
|
separation({agentIDs, mode, label}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
const width = (
|
|
env.textSizer.measure(config.labelAttrs, label).width +
|
|
config.padding.left +
|
|
config.padding.right
|
|
);
|
|
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
const infoL = env.agentInfos.get(left);
|
|
const infoR = env.agentInfos.get(right);
|
|
if(infoL !== infoR) {
|
|
const hangL = infoL.currentMaxRad + config.overlap.left;
|
|
const hangR = infoR.currentMaxRad + config.overlap.right;
|
|
|
|
env.addSeparation(left, right, width - hangL - hangR);
|
|
|
|
env.addSpacing(left, {left: hangL, right: 0});
|
|
env.addSpacing(right, {left: 0, right: hangR});
|
|
} else {
|
|
env.addSpacing(left, {
|
|
left: width / 2,
|
|
right: width / 2,
|
|
});
|
|
}
|
|
}
|
|
|
|
render({agentIDs, mode, label}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
const infoL = env.agentInfos.get(left);
|
|
const infoR = env.agentInfos.get(right);
|
|
if(infoL !== infoR) {
|
|
return this.renderNote({
|
|
x0: infoL.x - infoL.currentMaxRad - config.overlap.left,
|
|
x1: infoR.x + infoR.currentMaxRad + config.overlap.right,
|
|
anchor: 'middle',
|
|
mode,
|
|
label,
|
|
}, env);
|
|
} else {
|
|
const xMid = infoL.x;
|
|
return this.renderNote({
|
|
xMid,
|
|
anchor: 'middle',
|
|
mode,
|
|
label,
|
|
}, env);
|
|
}
|
|
}
|
|
}
|
|
|
|
class NoteSide extends NoteComponent {
|
|
constructor(isRight) {
|
|
super();
|
|
this.isRight = isRight;
|
|
}
|
|
|
|
separation({agentIDs, mode, label}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
const width = (
|
|
env.textSizer.measure(config.labelAttrs, label).width +
|
|
config.padding.left +
|
|
config.padding.right +
|
|
config.margin.left +
|
|
config.margin.right
|
|
);
|
|
|
|
if(this.isRight) {
|
|
const info = env.agentInfos.get(right);
|
|
env.addSpacing(right, {
|
|
left: 0,
|
|
right: width + info.currentMaxRad,
|
|
});
|
|
} else {
|
|
const info = env.agentInfos.get(left);
|
|
env.addSpacing(left, {
|
|
left: width + info.currentMaxRad,
|
|
right: 0,
|
|
});
|
|
}
|
|
}
|
|
|
|
render({agentIDs, mode, label}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
if(this.isRight) {
|
|
const info = env.agentInfos.get(right);
|
|
const x0 = info.x + info.currentMaxRad + config.margin.left;
|
|
return this.renderNote({
|
|
x0,
|
|
anchor: 'start',
|
|
mode,
|
|
label,
|
|
}, env);
|
|
} else {
|
|
const info = env.agentInfos.get(left);
|
|
const x1 = info.x - info.currentMaxRad - config.margin.right;
|
|
return this.renderNote({
|
|
x1,
|
|
anchor: 'end',
|
|
mode,
|
|
label,
|
|
}, env);
|
|
}
|
|
}
|
|
}
|
|
|
|
class NoteBetween extends NoteComponent {
|
|
separation({agentIDs, mode, label}, env) {
|
|
const config = env.theme.getNote(mode);
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
const infoL = env.agentInfos.get(left);
|
|
const infoR = env.agentInfos.get(right);
|
|
|
|
env.addSeparation(
|
|
left,
|
|
right,
|
|
|
|
env.textSizer.measure(config.labelAttrs, label).width +
|
|
config.padding.left +
|
|
config.padding.right +
|
|
config.margin.left +
|
|
config.margin.right +
|
|
infoL.currentMaxRad +
|
|
infoR.currentMaxRad
|
|
);
|
|
}
|
|
|
|
render({agentIDs, mode, label}, env) {
|
|
const {left, right} = findExtremes(env.agentInfos, agentIDs);
|
|
const infoL = env.agentInfos.get(left);
|
|
const infoR = env.agentInfos.get(right);
|
|
const xMid = (
|
|
infoL.x + infoL.currentMaxRad +
|
|
infoR.x - infoR.currentMaxRad
|
|
) / 2;
|
|
|
|
return this.renderNote({
|
|
xMid,
|
|
anchor: 'middle',
|
|
mode,
|
|
label,
|
|
}, env);
|
|
}
|
|
}
|
|
|
|
NoteComponent.NoteOver = NoteOver;
|
|
NoteComponent.NoteSide = NoteSide;
|
|
NoteComponent.NoteBetween = NoteBetween;
|
|
|
|
BaseComponent.register('note over', new NoteOver());
|
|
BaseComponent.register('note left', new NoteSide(false));
|
|
BaseComponent.register('note right', new NoteSide(true));
|
|
BaseComponent.register('note between', new NoteBetween());
|
|
|
|
return NoteComponent;
|
|
});
|
|
|
|
define('sequence/components/Divider',[
|
|
'./BaseComponent',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseComponent,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
class Divider extends BaseComponent {
|
|
separation({mode, formattedLabel}, env) {
|
|
const config = env.theme.getDivider(mode);
|
|
|
|
const width = (
|
|
env.textSizer.measure(config.labelAttrs, formattedLabel).width +
|
|
config.padding.left +
|
|
config.padding.right
|
|
);
|
|
|
|
env.addSeparation('[', ']', width);
|
|
env.addSpacing('[', {left: config.extend, right: 0});
|
|
env.addSpacing(']', {left: 0, right: config.extend});
|
|
}
|
|
|
|
render({mode, height, formattedLabel}, env) {
|
|
const config = env.theme.getDivider(mode);
|
|
|
|
const left = env.agentInfos.get('[');
|
|
const right = env.agentInfos.get(']');
|
|
|
|
const clickable = env.makeRegion();
|
|
|
|
let labelWidth = 0;
|
|
let labelHeight = 0;
|
|
if(formattedLabel) {
|
|
labelHeight = env.textSizer.measureHeight(
|
|
config.labelAttrs,
|
|
formattedLabel
|
|
);
|
|
}
|
|
|
|
const fullHeight = Math.max(height, labelHeight) + config.margin;
|
|
|
|
if(formattedLabel) {
|
|
const boxed = SVGShapes.renderBoxedText(formattedLabel, {
|
|
x: (left.x + right.x) / 2,
|
|
y: (
|
|
env.primaryY +
|
|
(fullHeight - labelHeight) / 2 -
|
|
config.padding.top
|
|
),
|
|
padding: config.padding,
|
|
boxAttrs: {'fill': '#000000'},
|
|
labelAttrs: config.labelAttrs,
|
|
boxLayer: env.maskLayer,
|
|
labelLayer: clickable,
|
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
|
});
|
|
labelWidth = boxed.width;
|
|
}
|
|
|
|
const {shape, mask} = config.render({
|
|
x: left.x - config.extend,
|
|
y: env.primaryY + (fullHeight - height) / 2,
|
|
labelWidth,
|
|
labelHeight,
|
|
width: right.x - left.x + config.extend * 2,
|
|
height,
|
|
env,
|
|
});
|
|
if(shape) {
|
|
clickable.insertBefore(shape, clickable.firstChild);
|
|
}
|
|
if(mask) {
|
|
env.maskLayer.appendChild(mask);
|
|
}
|
|
clickable.insertBefore(svg.make('rect', {
|
|
'x': left.x - config.extend,
|
|
'y': env.primaryY,
|
|
'width': right.x - left.x + config.extend * 2,
|
|
'height': fullHeight,
|
|
'fill': 'transparent',
|
|
'class': 'outline',
|
|
}), clickable.firstChild);
|
|
|
|
return env.primaryY + fullHeight + env.theme.actionMargin;
|
|
}
|
|
}
|
|
|
|
BaseComponent.register('divider', new Divider());
|
|
|
|
return Divider;
|
|
});
|
|
|
|
/* jshint -W072 */ // Allow several required modules
|
|
define('sequence/Renderer',[
|
|
'core/ArrayUtilities',
|
|
'core/EventObject',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
'./components/BaseComponent',
|
|
'./components/Block',
|
|
'./components/Parallel',
|
|
'./components/Marker',
|
|
'./components/AgentCap',
|
|
'./components/AgentHighlight',
|
|
'./components/Connect',
|
|
'./components/Note',
|
|
'./components/Divider',
|
|
], (
|
|
array,
|
|
EventObject,
|
|
svg,
|
|
SVGShapes,
|
|
BaseComponent
|
|
) => {
|
|
/* jshint +W072 */
|
|
'use strict';
|
|
|
|
function findExtremes(agentInfos, agentIDs) {
|
|
let min = null;
|
|
let max = null;
|
|
agentIDs.forEach((id) => {
|
|
const info = agentInfos.get(id);
|
|
if(min === null || info.index < min.index) {
|
|
min = info;
|
|
}
|
|
if(max === null || info.index > max.index) {
|
|
max = info;
|
|
}
|
|
});
|
|
return {
|
|
left: min.id,
|
|
right: max.id,
|
|
};
|
|
}
|
|
|
|
function makeThemes(themes) {
|
|
if(themes.length === 0) {
|
|
throw new Error('Cannot render without a theme');
|
|
}
|
|
const themeMap = new Map();
|
|
themes.forEach((theme) => {
|
|
themeMap.set(theme.name, theme);
|
|
});
|
|
themeMap.set('', themes[0]);
|
|
return themeMap;
|
|
}
|
|
|
|
let globalNamespace = 0;
|
|
|
|
function parseNamespace(namespace) {
|
|
if(namespace === null) {
|
|
namespace = 'R' + globalNamespace;
|
|
++ globalNamespace;
|
|
}
|
|
return namespace;
|
|
}
|
|
|
|
return class Renderer extends EventObject {
|
|
constructor({
|
|
themes = [],
|
|
namespace = null,
|
|
components = null,
|
|
SVGTextBlockClass = SVGShapes.TextBlock,
|
|
} = {}) {
|
|
super();
|
|
|
|
if(components === null) {
|
|
components = BaseComponent.getComponents();
|
|
}
|
|
|
|
this._bindMethods();
|
|
|
|
this.state = {};
|
|
this.width = 0;
|
|
this.height = 0;
|
|
this.themes = makeThemes(themes);
|
|
this.theme = null;
|
|
this.namespace = parseNamespace(namespace);
|
|
this.components = components;
|
|
this.SVGTextBlockClass = SVGTextBlockClass;
|
|
this.knownThemeDefs = new Set();
|
|
this.knownDefs = new Set();
|
|
this.highlights = new Map();
|
|
this.currentHighlight = -1;
|
|
this.buildStaticElements();
|
|
this.components.forEach((component) => {
|
|
component.makeState(this.state);
|
|
});
|
|
}
|
|
|
|
_bindMethods() {
|
|
this.separationStage = this.separationStage.bind(this);
|
|
this.renderStage = this.renderStage.bind(this);
|
|
this.addSeparation = this.addSeparation.bind(this);
|
|
this.addThemeDef = this.addThemeDef.bind(this);
|
|
this.addDef = this.addDef.bind(this);
|
|
}
|
|
|
|
addTheme(theme) {
|
|
this.themes.set(theme.name, theme);
|
|
}
|
|
|
|
buildStaticElements() {
|
|
this.base = svg.makeContainer();
|
|
|
|
this.themeDefs = svg.make('defs');
|
|
this.defs = svg.make('defs');
|
|
this.mask = svg.make('mask', {
|
|
'id': this.namespace + 'LineMask',
|
|
'maskUnits': 'userSpaceOnUse',
|
|
});
|
|
this.maskReveal = svg.make('rect', {'fill': '#FFFFFF'});
|
|
this.agentLines = svg.make('g', {
|
|
'mask': 'url(#' + this.namespace + 'LineMask)',
|
|
});
|
|
this.blocks = svg.make('g');
|
|
this.actionShapes = svg.make('g');
|
|
this.actionLabels = svg.make('g');
|
|
this.base.appendChild(this.themeDefs);
|
|
this.base.appendChild(this.defs);
|
|
this.base.appendChild(this.agentLines);
|
|
this.base.appendChild(this.blocks);
|
|
this.base.appendChild(this.actionShapes);
|
|
this.base.appendChild(this.actionLabels);
|
|
this.title = new this.SVGTextBlockClass(this.base);
|
|
|
|
this.sizer = new this.SVGTextBlockClass.SizeTester(this.base);
|
|
}
|
|
|
|
addThemeDef(name, generator) {
|
|
const namespacedName = this.namespace + name;
|
|
if(this.knownThemeDefs.has(name)) {
|
|
return namespacedName;
|
|
}
|
|
this.knownThemeDefs.add(name);
|
|
const def = generator();
|
|
def.setAttribute('id', namespacedName);
|
|
this.themeDefs.appendChild(def);
|
|
return namespacedName;
|
|
}
|
|
|
|
addDef(name, generator) {
|
|
if(typeof generator !== 'function') {
|
|
const o = name;
|
|
name = 'P' + this.knownDefs.size;
|
|
generator = () => o;
|
|
}
|
|
|
|
const namespacedName = this.namespace + name;
|
|
if(this.knownDefs.has(name)) {
|
|
return namespacedName;
|
|
}
|
|
this.knownDefs.add(name);
|
|
const def = generator();
|
|
def.setAttribute('id', namespacedName);
|
|
this.defs.appendChild(def);
|
|
return namespacedName;
|
|
}
|
|
|
|
addSeparation(agentID1, agentID2, dist) {
|
|
const info1 = this.agentInfos.get(agentID1);
|
|
const info2 = this.agentInfos.get(agentID2);
|
|
|
|
const d1 = info1.separations.get(agentID2) || 0;
|
|
info1.separations.set(agentID2, Math.max(d1, dist));
|
|
|
|
const d2 = info2.separations.get(agentID1) || 0;
|
|
info2.separations.set(agentID1, Math.max(d2, dist));
|
|
}
|
|
|
|
separationStage(stage) {
|
|
const agentSpaces = new Map();
|
|
const agentIDs = this.visibleAgentIDs.slice();
|
|
|
|
const addSpacing = (agentID, {left, right}) => {
|
|
const current = agentSpaces.get(agentID);
|
|
current.left = Math.max(current.left, left);
|
|
current.right = Math.max(current.right, right);
|
|
};
|
|
|
|
this.agentInfos.forEach((agentInfo) => {
|
|
const rad = agentInfo.currentRad;
|
|
agentInfo.currentMaxRad = rad;
|
|
agentSpaces.set(agentInfo.id, {left: rad, right: rad});
|
|
});
|
|
const env = {
|
|
theme: this.theme,
|
|
agentInfos: this.agentInfos,
|
|
visibleAgentIDs: this.visibleAgentIDs,
|
|
momentaryAgentIDs: agentIDs,
|
|
textSizer: this.sizer,
|
|
addSpacing,
|
|
addSeparation: this.addSeparation,
|
|
state: this.state,
|
|
components: this.components,
|
|
};
|
|
const component = this.components.get(stage.type);
|
|
if(!component) {
|
|
throw new Error('Unknown component: ' + stage.type);
|
|
}
|
|
component.separationPre(stage, env);
|
|
component.separation(stage, env);
|
|
array.mergeSets(agentIDs, this.visibleAgentIDs);
|
|
|
|
agentIDs.forEach((agentIDR) => {
|
|
const infoR = this.agentInfos.get(agentIDR);
|
|
const sepR = agentSpaces.get(agentIDR);
|
|
infoR.maxRPad = Math.max(infoR.maxRPad, sepR.right);
|
|
infoR.maxLPad = Math.max(infoR.maxLPad, sepR.left);
|
|
agentIDs.forEach((agentIDL) => {
|
|
const infoL = this.agentInfos.get(agentIDL);
|
|
if(infoL.index >= infoR.index) {
|
|
return;
|
|
}
|
|
const sepL = agentSpaces.get(agentIDL);
|
|
this.addSeparation(
|
|
agentIDR,
|
|
agentIDL,
|
|
sepR.left + sepL.right + this.theme.agentMargin
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
checkAgentRange(agentIDs, topY = 0) {
|
|
if(agentIDs.length === 0) {
|
|
return topY;
|
|
}
|
|
const {left, right} = findExtremes(this.agentInfos, agentIDs);
|
|
const leftX = this.agentInfos.get(left).x;
|
|
const rightX = this.agentInfos.get(right).x;
|
|
let baseY = topY;
|
|
this.agentInfos.forEach((agentInfo) => {
|
|
if(agentInfo.x >= leftX && agentInfo.x <= rightX) {
|
|
baseY = Math.max(baseY, agentInfo.latestY);
|
|
}
|
|
});
|
|
return baseY;
|
|
}
|
|
|
|
markAgentRange(agentIDs, y) {
|
|
if(agentIDs.length === 0) {
|
|
return;
|
|
}
|
|
const {left, right} = findExtremes(this.agentInfos, agentIDs);
|
|
const leftX = this.agentInfos.get(left).x;
|
|
const rightX = this.agentInfos.get(right).x;
|
|
this.agentInfos.forEach((agentInfo) => {
|
|
if(agentInfo.x >= leftX && agentInfo.x <= rightX) {
|
|
agentInfo.latestY = y;
|
|
}
|
|
});
|
|
}
|
|
|
|
drawAgentLine(agentInfo, toY) {
|
|
if(
|
|
agentInfo.latestYStart === null ||
|
|
toY <= agentInfo.latestYStart
|
|
) {
|
|
return;
|
|
}
|
|
|
|
this.agentLines.appendChild(this.theme.renderAgentLine({
|
|
x: agentInfo.x,
|
|
y0: agentInfo.latestYStart,
|
|
y1: toY,
|
|
width: agentInfo.currentRad * 2,
|
|
className: 'agent-' + agentInfo.index + '-line',
|
|
}));
|
|
}
|
|
|
|
addHighlightObject(line, o) {
|
|
let list = this.highlights.get(line);
|
|
if(!list) {
|
|
list = [];
|
|
this.highlights.set(line, list);
|
|
}
|
|
list.push(o);
|
|
}
|
|
|
|
renderStage(stage) {
|
|
this.agentInfos.forEach((agentInfo) => {
|
|
const rad = agentInfo.currentRad;
|
|
agentInfo.currentMaxRad = rad;
|
|
});
|
|
|
|
const envPre = {
|
|
theme: this.theme,
|
|
agentInfos: this.agentInfos,
|
|
textSizer: this.sizer,
|
|
state: this.state,
|
|
components: this.components,
|
|
};
|
|
const component = this.components.get(stage.type);
|
|
const result = component.renderPre(stage, envPre);
|
|
const {agentIDs, topShift, asynchronousY} =
|
|
BaseComponent.cleanRenderPreResult(result, this.currentY);
|
|
|
|
const topY = this.checkAgentRange(agentIDs, asynchronousY);
|
|
|
|
const eventOut = () => {
|
|
this.trigger('mouseout');
|
|
};
|
|
|
|
const makeRegion = (o, stageOverride = null) => {
|
|
if(!o) {
|
|
o = svg.make('g');
|
|
}
|
|
const targetStage = (stageOverride || stage);
|
|
this.addHighlightObject(targetStage.ln, o);
|
|
o.setAttribute('class', 'region');
|
|
o.addEventListener('mouseenter', () => {
|
|
this.trigger('mouseover', [targetStage]);
|
|
});
|
|
o.addEventListener('mouseleave', eventOut);
|
|
o.addEventListener('click', () => {
|
|
this.trigger('click', [targetStage]);
|
|
});
|
|
this.actionLabels.appendChild(o);
|
|
return o;
|
|
};
|
|
|
|
const env = {
|
|
topY,
|
|
primaryY: topY + topShift,
|
|
blockLayer: this.blocks,
|
|
shapeLayer: this.actionShapes,
|
|
labelLayer: this.actionLabels,
|
|
maskLayer: this.mask,
|
|
theme: this.theme,
|
|
agentInfos: this.agentInfos,
|
|
textSizer: this.sizer,
|
|
SVGTextBlockClass: this.SVGTextBlockClass,
|
|
state: this.state,
|
|
drawAgentLine: (agentID, toY, andStop = false) => {
|
|
const agentInfo = this.agentInfos.get(agentID);
|
|
this.drawAgentLine(agentInfo, toY);
|
|
agentInfo.latestYStart = andStop ? null : toY;
|
|
},
|
|
addDef: this.addDef,
|
|
makeRegion,
|
|
components: this.components,
|
|
};
|
|
|
|
const bottomY = Math.max(topY, component.render(stage, env) || 0);
|
|
this.markAgentRange(agentIDs, bottomY);
|
|
|
|
this.currentY = bottomY;
|
|
}
|
|
|
|
positionAgents() {
|
|
// Map guarantees insertion-order iteration
|
|
const orderedInfos = [];
|
|
this.agentInfos.forEach((agentInfo) => {
|
|
let currentX = 0;
|
|
agentInfo.separations.forEach((dist, otherAgent) => {
|
|
const otherAgentInfo = this.agentInfos.get(otherAgent);
|
|
if(otherAgentInfo.index < agentInfo.index) {
|
|
currentX = Math.max(currentX, otherAgentInfo.x + dist);
|
|
}
|
|
});
|
|
agentInfo.x = currentX;
|
|
orderedInfos.push(agentInfo);
|
|
});
|
|
|
|
let previousInfo = {x: 0};
|
|
orderedInfos.reverse().forEach((agentInfo) => {
|
|
let currentX = previousInfo.x;
|
|
previousInfo = agentInfo;
|
|
if(!agentInfo.anchorRight) {
|
|
return;
|
|
}
|
|
agentInfo.separations.forEach((dist, otherAgent) => {
|
|
const otherAgentInfo = this.agentInfos.get(otherAgent);
|
|
if(otherAgentInfo.index > agentInfo.index) {
|
|
currentX = Math.min(currentX, otherAgentInfo.x - dist);
|
|
}
|
|
});
|
|
agentInfo.x = currentX;
|
|
});
|
|
|
|
this.agentInfos.forEach(({x, maxRPad, maxLPad}) => {
|
|
this.minX = Math.min(this.minX, x - maxLPad);
|
|
this.maxX = Math.max(this.maxX, x + maxRPad);
|
|
});
|
|
}
|
|
|
|
buildAgentInfos(agents, stages) {
|
|
this.agentInfos = new Map();
|
|
agents.forEach((agent, index) => {
|
|
this.agentInfos.set(agent.id, {
|
|
id: agent.id,
|
|
formattedLabel: agent.formattedLabel,
|
|
anchorRight: agent.anchorRight,
|
|
isVirtualSource: agent.isVirtualSource,
|
|
index,
|
|
x: null,
|
|
latestYStart: null,
|
|
currentRad: 0,
|
|
currentMaxRad: 0,
|
|
latestY: 0,
|
|
maxRPad: 0,
|
|
maxLPad: 0,
|
|
separations: new Map(),
|
|
});
|
|
});
|
|
|
|
this.visibleAgentIDs = ['[', ']'];
|
|
stages.forEach(this.separationStage);
|
|
|
|
this.positionAgents();
|
|
}
|
|
|
|
updateBounds(stagesHeight) {
|
|
const cx = (this.minX + this.maxX) / 2;
|
|
const titleY = ((this.title.height > 0) ?
|
|
(-this.theme.titleMargin - this.title.height) : 0
|
|
);
|
|
this.title.set({x: cx, y: titleY});
|
|
|
|
const halfTitleWidth = this.title.width / 2;
|
|
const margin = this.theme.outerMargin;
|
|
const x0 = Math.min(this.minX, cx - halfTitleWidth) - margin;
|
|
const x1 = Math.max(this.maxX, cx + halfTitleWidth) + margin;
|
|
const y0 = titleY - margin;
|
|
const y1 = stagesHeight + margin;
|
|
|
|
this.maskReveal.setAttribute('x', x0);
|
|
this.maskReveal.setAttribute('y', y0);
|
|
this.maskReveal.setAttribute('width', x1 - x0);
|
|
this.maskReveal.setAttribute('height', y1 - y0);
|
|
|
|
this.base.setAttribute('viewBox', (
|
|
x0 + ' ' + y0 + ' ' +
|
|
(x1 - x0) + ' ' + (y1 - y0)
|
|
));
|
|
this.width = (x1 - x0);
|
|
this.height = (y1 - y0);
|
|
}
|
|
|
|
_resetState() {
|
|
this.components.forEach((component) => {
|
|
component.resetState(this.state);
|
|
});
|
|
this.currentY = 0;
|
|
}
|
|
|
|
_reset(theme) {
|
|
if(theme) {
|
|
this.knownThemeDefs.clear();
|
|
svg.empty(this.themeDefs);
|
|
}
|
|
|
|
this.knownDefs.clear();
|
|
this.highlights.clear();
|
|
this.currentHighlight = -1;
|
|
svg.empty(this.defs);
|
|
svg.empty(this.mask);
|
|
svg.empty(this.agentLines);
|
|
svg.empty(this.blocks);
|
|
svg.empty(this.actionShapes);
|
|
svg.empty(this.actionLabels);
|
|
this.mask.appendChild(this.maskReveal);
|
|
this.defs.appendChild(this.mask);
|
|
this._resetState();
|
|
}
|
|
|
|
setHighlight(line = null) {
|
|
if(line === null || !this.highlights.has(line)) {
|
|
line = -1;
|
|
}
|
|
if(this.currentHighlight === line) {
|
|
return;
|
|
}
|
|
if(this.currentHighlight !== -1) {
|
|
this.highlights.get(this.currentHighlight).forEach((o) => {
|
|
o.setAttribute('class', 'region');
|
|
});
|
|
}
|
|
if(line !== -1) {
|
|
this.highlights.get(line).forEach((o) => {
|
|
o.setAttribute('class', 'region focus');
|
|
});
|
|
}
|
|
this.currentHighlight = line;
|
|
}
|
|
|
|
render(sequence) {
|
|
const prevHighlight = this.currentHighlight;
|
|
const oldTheme = this.theme;
|
|
|
|
this.theme = this.getThemeNamed(sequence.meta.theme);
|
|
|
|
const themeChanged = (this.theme !== oldTheme);
|
|
this._reset(themeChanged);
|
|
|
|
this.theme.reset();
|
|
this.theme.addDefs(this.addThemeDef);
|
|
|
|
this.title.set({
|
|
attrs: this.theme.titleAttrs,
|
|
formatted: sequence.meta.title,
|
|
});
|
|
|
|
this.minX = 0;
|
|
this.maxX = 0;
|
|
this.buildAgentInfos(sequence.agents, sequence.stages);
|
|
|
|
this._resetState();
|
|
sequence.stages.forEach(this.renderStage);
|
|
const bottomY = this.checkAgentRange(['[', ']'], this.currentY);
|
|
|
|
const stagesHeight = Math.max(bottomY - this.theme.actionMargin, 0);
|
|
this.updateBounds(stagesHeight);
|
|
|
|
this.sizer.resetCache();
|
|
this.sizer.detach();
|
|
this.setHighlight(prevHighlight);
|
|
}
|
|
|
|
getThemeNames() {
|
|
return (Array.from(this.themes.keys())
|
|
.filter((name) => (name !== ''))
|
|
);
|
|
}
|
|
|
|
getThemes() {
|
|
return this.getThemeNames().map((name) => this.themes.get(name));
|
|
}
|
|
|
|
getThemeNamed(themeName) {
|
|
const theme = this.themes.get(themeName);
|
|
if(theme) {
|
|
return theme;
|
|
}
|
|
return this.themes.get('');
|
|
}
|
|
|
|
getAgentX(id) {
|
|
return this.agentInfos.get(id).x;
|
|
}
|
|
|
|
svg() {
|
|
return this.base;
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/Exporter',[],() => {
|
|
'use strict';
|
|
|
|
// Thanks, https://stackoverflow.com/a/23522755/1180785
|
|
const safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
|
|
// Thanks, https://stackoverflow.com/a/9851769/1180785
|
|
const firefox = (typeof window.InstallTrigger !== 'undefined');
|
|
|
|
return class Exporter {
|
|
constructor() {
|
|
this.latestSVG = null;
|
|
this.latestInternalSVG = null;
|
|
this.canvas = null;
|
|
this.context = null;
|
|
this.indexPNG = 0;
|
|
this.latestPNGIndex = 0;
|
|
this.latestPNG = null;
|
|
}
|
|
|
|
getSVGContent(renderer, size = null) {
|
|
let code = renderer.svg().outerHTML;
|
|
if(firefox && size) {
|
|
// Firefox fails to render SVGs unless they have size
|
|
// attributes on the <svg> tag
|
|
code = code.replace(
|
|
/^<svg/,
|
|
'<svg width="' + size.width +
|
|
'" height="' + size.height + '" '
|
|
);
|
|
}
|
|
return code;
|
|
}
|
|
|
|
getSVGBlob(renderer, size = null) {
|
|
return new Blob(
|
|
[this.getSVGContent(renderer, size)],
|
|
{type: 'image/svg+xml'}
|
|
);
|
|
}
|
|
|
|
getSVGURL(renderer, size = null) {
|
|
const blob = this.getSVGBlob(renderer, size);
|
|
if(size) {
|
|
if(this.latestInternalSVG) {
|
|
URL.revokeObjectURL(this.latestInternalSVG);
|
|
}
|
|
this.latestInternalSVG = URL.createObjectURL(blob);
|
|
return this.latestInternalSVG;
|
|
} else {
|
|
if(this.latestSVG) {
|
|
URL.revokeObjectURL(this.latestSVG);
|
|
}
|
|
this.latestSVG = URL.createObjectURL(blob);
|
|
return this.latestSVG;
|
|
}
|
|
}
|
|
|
|
getPNGBlob(renderer, resolution, callback) {
|
|
if(!this.canvas) {
|
|
window.devicePixelRatio = 1;
|
|
this.canvas = document.createElement('canvas');
|
|
this.context = this.canvas.getContext('2d');
|
|
}
|
|
|
|
const width = renderer.width * resolution;
|
|
const height = renderer.height * resolution;
|
|
const img = new Image(width, height);
|
|
let safariHackaround = null;
|
|
if(safari) {
|
|
// Safari fails to resize SVG images unless they are displayed
|
|
// on the page somewhere, so we must add it before drawing the
|
|
// image. For some reason, doing this inside the load listener
|
|
// is too late, so we do it here and do our best to ensure it
|
|
// doesn't change the page rendering (display:none fails too)
|
|
safariHackaround = document.createElement('div');
|
|
safariHackaround.style.position = 'absolute';
|
|
safariHackaround.style.visibility = 'hidden';
|
|
safariHackaround.appendChild(img);
|
|
document.body.appendChild(safariHackaround);
|
|
}
|
|
|
|
const render = () => {
|
|
this.canvas.width = width;
|
|
this.canvas.height = height;
|
|
this.context.drawImage(img, 0, 0);
|
|
if(safariHackaround) {
|
|
document.body.removeChild(safariHackaround);
|
|
}
|
|
this.canvas.toBlob(callback, 'image/png');
|
|
};
|
|
|
|
img.addEventListener('load', () => {
|
|
if(safariHackaround) {
|
|
// Wait for custom fonts to load (Safari takes a moment)
|
|
setTimeout(render, 50);
|
|
} else {
|
|
render();
|
|
}
|
|
}, {once: true});
|
|
|
|
img.src = this.getSVGURL(renderer, {width, height});
|
|
}
|
|
|
|
getPNGURL(renderer, resolution, callback) {
|
|
++ this.indexPNG;
|
|
const index = this.indexPNG;
|
|
|
|
this.getPNGBlob(renderer, resolution, (blob) => {
|
|
const url = URL.createObjectURL(blob);
|
|
const isLatest = index >= this.latestPNGIndex;
|
|
if(isLatest) {
|
|
if(this.latestPNG) {
|
|
URL.revokeObjectURL(this.latestPNG);
|
|
}
|
|
this.latestPNG = url;
|
|
this.latestPNGIndex = index;
|
|
callback(url, true);
|
|
} else {
|
|
callback(url, false);
|
|
URL.revokeObjectURL(url);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => {
|
|
'use strict';
|
|
|
|
const TRIMMER = /^([ \t]*)(.*)$/;
|
|
const SQUASH = {
|
|
start: /^[ \t\r\n:,]/,
|
|
end: /[ \t\r\n]$/,
|
|
after: '.!+', // cannot squash after * or - in all cases
|
|
};
|
|
const ONGOING_QUOTE = /^"(\\.|[^"])*$/;
|
|
const REQUIRED_QUOTED = /[\r\n:,"<>\-~]/;
|
|
const QUOTE_ESCAPE = /["\\]/g;
|
|
|
|
function suggestionsEqual(a, b) {
|
|
return (
|
|
(a.v === b.v) &&
|
|
(a.prefix === b.prefix) &&
|
|
(a.suffix === b.suffix) &&
|
|
(a.q === b.q)
|
|
);
|
|
}
|
|
|
|
function makeRangeFrom(cm, line, chFrom) {
|
|
const ln = cm.getLine(line);
|
|
const ranges = {
|
|
word: {line: line, ch: chFrom},
|
|
squash: {line: line, ch: chFrom},
|
|
};
|
|
if(chFrom > 0 && ln[chFrom - 1] === ' ') {
|
|
if(SQUASH.after.includes(ln[chFrom - 2])) {
|
|
ranges.word.ch --;
|
|
}
|
|
ranges.squash.ch --;
|
|
}
|
|
return ranges;
|
|
}
|
|
|
|
function makeRangeTo(cm, line, chTo) {
|
|
const ln = cm.getLine(line);
|
|
const ranges = {
|
|
word: {line: line, ch: chTo},
|
|
squash: {line: line, ch: chTo},
|
|
};
|
|
if(ln[chTo] === ' ') {
|
|
ranges.squash.ch ++;
|
|
}
|
|
return ranges;
|
|
}
|
|
|
|
function wrapQuote(entry, quote) {
|
|
if(!quote && REQUIRED_QUOTED.test(entry.v)) {
|
|
quote = '"';
|
|
}
|
|
let inner = entry.v;
|
|
if(quote && entry.q) {
|
|
inner = quote + inner.replace(QUOTE_ESCAPE, '\\$&') + quote;
|
|
}
|
|
return (entry.prefix || '') + inner + (entry.suffix || '');
|
|
}
|
|
|
|
function makeHintItem(entry, ranges, quote) {
|
|
const quoted = wrapQuote(entry, quote);
|
|
const from = entry.q ? ranges.fromVar : ranges.fromKey;
|
|
if(quoted === '\n') {
|
|
return {
|
|
text: '\n',
|
|
displayText: '<END>',
|
|
className: 'pick-virtual',
|
|
from: from.squash,
|
|
to: ranges.to.squash,
|
|
displayFrom: null,
|
|
};
|
|
} else {
|
|
return {
|
|
text: quoted,
|
|
displayText: quoted.trim(),
|
|
className: null,
|
|
from: SQUASH.start.test(quoted) ? from.squash : from.word,
|
|
to: SQUASH.end.test(quoted) ? ranges.to.squash : ranges.to.word,
|
|
displayFrom: from.word,
|
|
};
|
|
}
|
|
}
|
|
|
|
function getGlobals({global, prefix = '', suffix = ''}, globals) {
|
|
const identified = globals[global];
|
|
if(!identified) {
|
|
return [];
|
|
}
|
|
return identified.map((item) => ({v: item, prefix, suffix, q: true}));
|
|
}
|
|
|
|
function populateGlobals(suggestions, globals = {}) {
|
|
for(let i = 0; i < suggestions.length;) {
|
|
if(suggestions[i].global) {
|
|
const identified = getGlobals(suggestions[i], globals);
|
|
array.mergeSets(suggestions, identified, suggestionsEqual);
|
|
suggestions.splice(i, 1);
|
|
} else {
|
|
++ i;
|
|
}
|
|
}
|
|
}
|
|
|
|
function getTokensUpTo(cm, pos) {
|
|
const tokens = cm.getLineTokens(pos.line);
|
|
for(let p = 0; p < tokens.length; ++ p) {
|
|
if(tokens[p].end >= pos.ch) {
|
|
tokens.length = p + 1;
|
|
break;
|
|
}
|
|
}
|
|
return tokens;
|
|
}
|
|
|
|
function getVariablePartial(tokens, pos) {
|
|
let lastVariable = 0;
|
|
let partial = '';
|
|
let start = 0;
|
|
let end = 0;
|
|
tokens.forEach((token, p) => {
|
|
if(token.state.isVar) {
|
|
partial += token.string;
|
|
end = token.end;
|
|
} else {
|
|
lastVariable = p + 1;
|
|
partial = '';
|
|
start = token.end;
|
|
}
|
|
});
|
|
if(end > pos.ch) {
|
|
partial = partial.substr(0, pos.ch - start);
|
|
}
|
|
const parts = TRIMMER.exec(partial);
|
|
partial = parts[2];
|
|
let quote = '';
|
|
if(ONGOING_QUOTE.test(partial)) {
|
|
quote = partial[0];
|
|
partial = partial.substr(1);
|
|
}
|
|
return {
|
|
partial,
|
|
quote,
|
|
from: start + parts[1].length,
|
|
valid: end >= start,
|
|
};
|
|
}
|
|
|
|
function getKeywordPartial(token, pos) {
|
|
let partial = token.string;
|
|
if(token.end > pos.ch) {
|
|
partial = partial.substr(0, pos.ch - token.start);
|
|
}
|
|
const parts = TRIMMER.exec(partial);
|
|
return {
|
|
partial: parts[2],
|
|
from: token.start + parts[1].length,
|
|
valid: true,
|
|
};
|
|
}
|
|
|
|
function suggestDropdownLocation(list, fromKey) {
|
|
let p = null;
|
|
list.forEach(({displayFrom}) => {
|
|
if(displayFrom) {
|
|
if(
|
|
!p ||
|
|
displayFrom.line > p.line ||
|
|
(displayFrom.line === p.line && displayFrom.ch > p.ch)
|
|
) {
|
|
p = displayFrom;
|
|
}
|
|
}
|
|
});
|
|
return p || fromKey.word;
|
|
}
|
|
|
|
function partialMatch(v, p) {
|
|
return p.valid && v.startsWith(p.partial);
|
|
}
|
|
|
|
function getHints(cm, options) {
|
|
const cur = cm.getCursor();
|
|
const tokens = getTokensUpTo(cm, cur);
|
|
const token = array.last(tokens) || cm.getTokenAt(cur);
|
|
const pVar = getVariablePartial(tokens, cur);
|
|
const pKey = getKeywordPartial(token, cur);
|
|
|
|
const continuation = (cur.ch > 0 && token.state.line.length > 0);
|
|
let comp = (continuation ?
|
|
token.state.completions :
|
|
token.state.beginCompletions
|
|
);
|
|
if(!continuation) {
|
|
comp = comp.concat(token.state.knownAgent);
|
|
}
|
|
|
|
populateGlobals(comp, cm.options.globals);
|
|
|
|
const ranges = {
|
|
fromVar: makeRangeFrom(cm, cur.line, pVar.from),
|
|
fromKey: makeRangeFrom(cm, cur.line, pKey.from),
|
|
to: makeRangeTo(cm, cur.line, token.end),
|
|
};
|
|
let selfValid = null;
|
|
const list = (comp
|
|
.filter((o) => (
|
|
(o.q || !pVar.quote) &&
|
|
partialMatch(o.v, o.q ? pVar : pKey)
|
|
))
|
|
.map((o) => {
|
|
if(!options.completeSingle) {
|
|
if(o.v === (o.q ? pVar : pKey).partial) {
|
|
selfValid = o;
|
|
return null;
|
|
}
|
|
}
|
|
return makeHintItem(o, ranges, pVar.quote);
|
|
})
|
|
.filter((opt) => (opt !== null))
|
|
);
|
|
if(selfValid && list.length > 0) {
|
|
list.unshift(makeHintItem(selfValid, ranges, pVar.quote));
|
|
}
|
|
|
|
return {
|
|
list,
|
|
from: suggestDropdownLocation(list, ranges.fromKey),
|
|
to: ranges.to.word,
|
|
};
|
|
}
|
|
|
|
return {
|
|
getHints,
|
|
};
|
|
});
|
|
|
|
define('sequence/themes/BaseTheme',[
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
function deepCopy(o) {
|
|
if(typeof o !== 'object' || !o) {
|
|
return o;
|
|
}
|
|
const r = {};
|
|
for(let k in o) {
|
|
if(o.hasOwnProperty(k)) {
|
|
r[k] = deepCopy(o[k]);
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
|
|
class BaseTheme {
|
|
constructor({name, settings, blocks, notes, dividers}) {
|
|
this.name = name;
|
|
this.blocks = deepCopy(blocks);
|
|
this.notes = deepCopy(notes);
|
|
this.dividers = deepCopy(dividers);
|
|
Object.assign(this, deepCopy(settings));
|
|
}
|
|
|
|
reset() {
|
|
}
|
|
|
|
addDefs() {
|
|
}
|
|
|
|
getBlock(type) {
|
|
return this.blocks[type] || this.blocks[''];
|
|
}
|
|
|
|
getNote(type) {
|
|
return this.notes[type] || this.notes[''];
|
|
}
|
|
|
|
getDivider(type) {
|
|
return this.dividers[type] || this.dividers[''];
|
|
}
|
|
|
|
renderAgentLine({x, y0, y1, width, className}) {
|
|
if(width > 0) {
|
|
return svg.make('rect', Object.assign({
|
|
'x': x - width / 2,
|
|
'y': y0,
|
|
'width': width,
|
|
'height': y1 - y0,
|
|
'class': className,
|
|
}, this.agentLineAttrs));
|
|
} else {
|
|
return svg.make('line', Object.assign({
|
|
'x1': x,
|
|
'y1': y0,
|
|
'x2': x,
|
|
'y2': y1,
|
|
'class': className,
|
|
}, this.agentLineAttrs));
|
|
}
|
|
}
|
|
}
|
|
|
|
BaseTheme.renderArrowHead = (attrs, {x, y, width, height, dir}) => {
|
|
const wx = width * dir.dx;
|
|
const wy = width * dir.dy;
|
|
const hy = height * 0.5 * dir.dx;
|
|
const hx = -height * 0.5 * dir.dy;
|
|
return svg.make(
|
|
attrs.fill === 'none' ? 'polyline' : 'polygon',
|
|
Object.assign({
|
|
'points': (
|
|
(x + wx - hx) + ' ' + (y + wy - hy) + ' ' +
|
|
x + ' ' + y + ' ' +
|
|
(x + wx + hx) + ' ' + (y + wy + hy)
|
|
),
|
|
}, attrs)
|
|
);
|
|
};
|
|
|
|
BaseTheme.renderTag = (attrs, {x, y, width, height}) => {
|
|
const {rx, ry} = attrs;
|
|
const x2 = x + width;
|
|
const y2 = y + height;
|
|
|
|
const line = (
|
|
'M' + x2 + ' ' + y +
|
|
'L' + x2 + ' ' + (y2 - ry) +
|
|
'L' + (x2 - rx) + ' ' + y2 +
|
|
'L' + x + ' ' + y2
|
|
);
|
|
|
|
const g = svg.make('g');
|
|
if(attrs.fill !== 'none') {
|
|
g.appendChild(svg.make('path', Object.assign({
|
|
'd': line + 'L' + x + ' ' + y,
|
|
}, attrs, {'stroke': 'none'})));
|
|
}
|
|
|
|
if(attrs.stroke !== 'none') {
|
|
g.appendChild(svg.make('path', Object.assign({
|
|
'd': line,
|
|
}, attrs, {'fill': 'none'})));
|
|
}
|
|
|
|
return g;
|
|
};
|
|
|
|
BaseTheme.renderCross = (attrs, {x, y, radius}) => {
|
|
return svg.make('path', Object.assign({
|
|
'd': (
|
|
'M' + (x - radius) + ' ' + (y - radius) +
|
|
'l' + (radius * 2) + ' ' + (radius * 2) +
|
|
'm0 ' + (-radius * 2) +
|
|
'l' + (-radius * 2) + ' ' + (radius * 2)
|
|
),
|
|
}, attrs));
|
|
};
|
|
|
|
BaseTheme.WavePattern = class WavePattern {
|
|
constructor(width, height) {
|
|
if(Array.isArray(height)) {
|
|
this.deltas = height;
|
|
} else {
|
|
this.deltas = [
|
|
0,
|
|
-height * 2 / 3,
|
|
-height,
|
|
-height * 2 / 3,
|
|
0,
|
|
height * 2 / 3,
|
|
height,
|
|
height * 2 / 3,
|
|
];
|
|
}
|
|
this.partWidth = width / this.deltas.length;
|
|
}
|
|
|
|
getDelta(p) {
|
|
return this.deltas[p % this.deltas.length];
|
|
}
|
|
};
|
|
|
|
BaseTheme.renderFlatConnector = (
|
|
pattern,
|
|
attrs,
|
|
{x1, y1, x2, y2}
|
|
) => {
|
|
return {
|
|
shape: svg.make('path', Object.assign({
|
|
d: new SVGShapes.PatternedLine(pattern)
|
|
.move(x1, y1)
|
|
.line(x2, y2)
|
|
.cap()
|
|
.asPath(),
|
|
}, attrs)),
|
|
p1: {x: x1, y: y1},
|
|
p2: {x: x2, y: y2},
|
|
};
|
|
};
|
|
|
|
BaseTheme.renderRevConnector = (
|
|
pattern,
|
|
attrs,
|
|
{x1, y1, x2, y2, xR, rad}
|
|
) => {
|
|
const maxRad = (y2 - y1) / 2;
|
|
const line = new SVGShapes.PatternedLine(pattern)
|
|
.move(x1, y1)
|
|
.line(xR, y1);
|
|
if(rad < maxRad) {
|
|
line
|
|
.arc(xR, y1 + rad, Math.PI / 2)
|
|
.line(xR + rad, y2 - rad)
|
|
.arc(xR, y2 - rad, Math.PI / 2);
|
|
} else {
|
|
line.arc(xR, (y1 + y2) / 2, Math.PI);
|
|
}
|
|
return {
|
|
shape: svg.make('path', Object.assign({
|
|
d: line
|
|
.line(x2, y2)
|
|
.cap()
|
|
.asPath(),
|
|
}, attrs)),
|
|
p1: {x: x1, y: y1},
|
|
p2: {x: x2, y: y2},
|
|
};
|
|
};
|
|
|
|
BaseTheme.renderLineDivider = (
|
|
{lineAttrs},
|
|
{x, y, labelWidth, width, height}
|
|
) => {
|
|
let shape = null;
|
|
const yPos = y + height / 2;
|
|
if(labelWidth > 0) {
|
|
shape = svg.make('g');
|
|
shape.appendChild(svg.make('line', Object.assign({
|
|
'x1': x,
|
|
'y1': yPos,
|
|
'x2': x + (width - labelWidth) / 2,
|
|
'y2': yPos,
|
|
'fill': 'none',
|
|
}, lineAttrs)));
|
|
shape.appendChild(svg.make('line', Object.assign({
|
|
'x1': x + (width + labelWidth) / 2,
|
|
'y1': yPos,
|
|
'x2': x + width,
|
|
'y2': yPos,
|
|
'fill': 'none',
|
|
}, lineAttrs)));
|
|
} else {
|
|
shape = svg.make('line', Object.assign({
|
|
'x1': x,
|
|
'y1': yPos,
|
|
'x2': x + width,
|
|
'y2': yPos,
|
|
'fill': 'none',
|
|
}, lineAttrs));
|
|
}
|
|
return {shape};
|
|
};
|
|
|
|
BaseTheme.renderDelayDivider = (
|
|
{dotSize, gapSize},
|
|
{x, y, width, height}
|
|
) => {
|
|
const mask = svg.make('g');
|
|
for(let i = 0; i + gapSize <= height; i += dotSize + gapSize) {
|
|
mask.appendChild(svg.make('rect', {
|
|
'x': x,
|
|
'y': y + i,
|
|
'width': width,
|
|
'height': gapSize,
|
|
'fill': '#000000',
|
|
}));
|
|
}
|
|
return {mask};
|
|
};
|
|
|
|
BaseTheme.renderTearDivider = (
|
|
{fadeBegin, fadeSize, pattern, zigWidth, zigHeight, lineAttrs},
|
|
{x, y, labelWidth, labelHeight, width, height, env}
|
|
) => {
|
|
const maskGradID = env.addDef('tear-grad', () => {
|
|
const px = 100 / width;
|
|
const grad = svg.make('linearGradient');
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': (fadeBegin * px) + '%',
|
|
'stop-color': '#000000',
|
|
}));
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': ((fadeBegin + fadeSize) * px) + '%',
|
|
'stop-color': '#FFFFFF',
|
|
}));
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': (100 - (fadeBegin + fadeSize) * px) + '%',
|
|
'stop-color': '#FFFFFF',
|
|
}));
|
|
grad.appendChild(svg.make('stop', {
|
|
'offset': (100 - fadeBegin * px) + '%',
|
|
'stop-color': '#000000',
|
|
}));
|
|
return grad;
|
|
});
|
|
const shapeMask = svg.make('mask', {
|
|
'maskUnits': 'userSpaceOnUse',
|
|
});
|
|
const shapeMaskID = env.addDef(shapeMask);
|
|
const shape = svg.make('g', {
|
|
'mask': 'url(#' + shapeMaskID + ')',
|
|
});
|
|
|
|
shapeMask.appendChild(svg.make('rect', {
|
|
'x': x,
|
|
'y': y - 5,
|
|
'width': width,
|
|
'height': height + 10,
|
|
'fill': 'url(#' + maskGradID + ')',
|
|
}));
|
|
if(labelWidth > 0) {
|
|
shapeMask.appendChild(svg.make('rect', {
|
|
'x': x + (width - labelWidth) / 2,
|
|
'y': y + (height - labelHeight) / 2 - 1,
|
|
'width': labelWidth,
|
|
'height': labelHeight + 2,
|
|
'rx': 2,
|
|
'ry': 2,
|
|
'fill': '#000000',
|
|
}));
|
|
}
|
|
|
|
if(!pattern) {
|
|
pattern = new BaseTheme.WavePattern(
|
|
zigWidth,
|
|
[zigHeight, -zigHeight]
|
|
);
|
|
}
|
|
let mask = null;
|
|
|
|
const pathTop = new SVGShapes.PatternedLine(pattern)
|
|
.move(x, y)
|
|
.line(x + width, y);
|
|
shape.appendChild(svg.make('path', Object.assign({
|
|
'd': pathTop.asPath(),
|
|
'fill': 'none',
|
|
}, lineAttrs)));
|
|
|
|
if(height > 0) {
|
|
const pathBase = new SVGShapes.PatternedLine(pattern)
|
|
.move(x, y + height)
|
|
.line(x + width, y + height);
|
|
shape.appendChild(svg.make('path', Object.assign({
|
|
'd': pathBase.asPath(),
|
|
'fill': 'none',
|
|
}, lineAttrs)));
|
|
pathTop
|
|
.line(pathBase.x, pathBase.y, {patterned: false})
|
|
.cap();
|
|
pathTop.points.push(...pathBase.points.reverse());
|
|
mask = svg.make('path', {
|
|
'd': pathTop.asPath(),
|
|
'fill': '#000000',
|
|
});
|
|
}
|
|
return {shape, mask};
|
|
};
|
|
|
|
return BaseTheme;
|
|
});
|
|
|
|
define('sequence/themes/Basic',[
|
|
'./BaseTheme',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseTheme,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
const FONT = 'sans-serif';
|
|
const LINE_HEIGHT = 1.3;
|
|
|
|
const WAVE = new BaseTheme.WavePattern(6, 0.5);
|
|
|
|
const SETTINGS = {
|
|
titleMargin: 10,
|
|
outerMargin: 5,
|
|
agentMargin: 10,
|
|
actionMargin: 10,
|
|
minActionMargin: 3,
|
|
agentLineHighlightRadius: 4,
|
|
|
|
agentCap: {
|
|
box: {
|
|
padding: {
|
|
top: 5,
|
|
left: 10,
|
|
right: 10,
|
|
bottom: 5,
|
|
},
|
|
arrowBottom: 5 + 12 * 1.3 / 2,
|
|
boxAttrs: {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 12,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
},
|
|
cross: {
|
|
size: 20,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
bar: {
|
|
height: 4,
|
|
render: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
fade: {
|
|
width: 5,
|
|
height: 6,
|
|
extend: 1,
|
|
},
|
|
none: {
|
|
height: 10,
|
|
},
|
|
},
|
|
|
|
connect: {
|
|
loopbackRadius: 6,
|
|
line: {
|
|
'solid': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'dash': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'stroke-dasharray': '4, 2',
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'wave': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, WAVE),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, WAVE),
|
|
},
|
|
},
|
|
arrow: {
|
|
'single': {
|
|
width: 5,
|
|
height: 10,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': '#000000',
|
|
'stroke-width': 0,
|
|
'stroke-linejoin': 'miter',
|
|
},
|
|
},
|
|
'double': {
|
|
width: 4,
|
|
height: 6,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'stroke-linejoin': 'miter',
|
|
},
|
|
},
|
|
'cross': {
|
|
short: 7,
|
|
radius: 3,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
},
|
|
label: {
|
|
padding: 6,
|
|
margin: {top: 2, bottom: 1},
|
|
attrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
loopbackAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
},
|
|
},
|
|
source: {
|
|
radius: 2,
|
|
render: ({x, y, radius}) => {
|
|
return svg.make('circle', {
|
|
'cx': x,
|
|
'cy': y,
|
|
'r': radius,
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
});
|
|
},
|
|
},
|
|
mask: {
|
|
padding: {
|
|
top: 0,
|
|
left: 3,
|
|
right: 3,
|
|
bottom: 1,
|
|
},
|
|
},
|
|
},
|
|
|
|
titleAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 20,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
'class': 'title',
|
|
},
|
|
|
|
agentLineAttrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
};
|
|
|
|
const SHARED_BLOCK_SECTION = {
|
|
padding: {
|
|
top: 3,
|
|
bottom: 2,
|
|
},
|
|
tag: {
|
|
padding: {
|
|
top: 1,
|
|
left: 3,
|
|
right: 3,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: BaseTheme.renderTag.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'rx': 2,
|
|
'ry': 2,
|
|
}),
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-weight': 'bold',
|
|
'font-size': 9,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
label: {
|
|
padding: {
|
|
top: 1,
|
|
left: 5,
|
|
right: 3,
|
|
bottom: 0,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
};
|
|
|
|
const BLOCKS = {
|
|
'ref': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1.5,
|
|
'rx': 2,
|
|
'ry': 2,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
},
|
|
'': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1.5,
|
|
'rx': 2,
|
|
'ry': 2,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
sepRenderer: SVGShapes.renderLine.bind(null, {
|
|
'stroke': '#000000',
|
|
'stroke-width': 1.5,
|
|
'stroke-dasharray': '4, 2',
|
|
}),
|
|
},
|
|
};
|
|
|
|
const NOTE_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
};
|
|
|
|
const NOTES = {
|
|
'text': {
|
|
margin: {top: 0, left: 2, right: 2, bottom: 0},
|
|
padding: {top: 2, left: 2, right: 2, bottom: 2},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'note': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 5, left: 5, right: 10, bottom: 5},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderNote.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'state': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 7, left: 7, right: 7, bottom: 7},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'rx': 10,
|
|
'ry': 10,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
};
|
|
|
|
const DIVIDER_LABEL_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
};
|
|
|
|
const DIVIDERS = {
|
|
'': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: () => ({}),
|
|
},
|
|
'line': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 0,
|
|
render: BaseTheme.renderLineDivider.bind(null, {
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
},
|
|
}),
|
|
},
|
|
'delay': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: BaseTheme.renderDelayDivider.bind(null, {
|
|
dotSize: 1,
|
|
gapSize: 2,
|
|
}),
|
|
},
|
|
'tear': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 10,
|
|
render: BaseTheme.renderTearDivider.bind(null, {
|
|
fadeBegin: 5,
|
|
fadeSize: 10,
|
|
zigWidth: 6,
|
|
zigHeight: 1,
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
},
|
|
}),
|
|
},
|
|
};
|
|
|
|
return class BasicTheme extends BaseTheme {
|
|
constructor() {
|
|
super({
|
|
name: 'basic',
|
|
settings: SETTINGS,
|
|
blocks: BLOCKS,
|
|
notes: NOTES,
|
|
dividers: DIVIDERS,
|
|
});
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/themes/Monospace',[
|
|
'./BaseTheme',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseTheme,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
const FONT = 'monospace';
|
|
const LINE_HEIGHT = 1.3;
|
|
|
|
const WAVE = new BaseTheme.WavePattern(6, [
|
|
+0,
|
|
-0.25,
|
|
-0.5,
|
|
-0.25,
|
|
+0,
|
|
+0.25,
|
|
+0.5,
|
|
+0.25,
|
|
]);
|
|
|
|
const SETTINGS = {
|
|
titleMargin: 8,
|
|
outerMargin: 4,
|
|
agentMargin: 12,
|
|
actionMargin: 12,
|
|
minActionMargin: 4,
|
|
agentLineHighlightRadius: 4,
|
|
|
|
agentCap: {
|
|
box: {
|
|
padding: {
|
|
top: 4,
|
|
left: 8,
|
|
right: 8,
|
|
bottom: 4,
|
|
},
|
|
arrowBottom: 12,
|
|
boxAttrs: {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 12,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
},
|
|
cross: {
|
|
size: 16,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
bar: {
|
|
height: 4,
|
|
render: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
fade: {
|
|
width: 5,
|
|
height: 8,
|
|
extend: 1,
|
|
},
|
|
none: {
|
|
height: 8,
|
|
},
|
|
},
|
|
|
|
connect: {
|
|
loopbackRadius: 4,
|
|
line: {
|
|
'solid': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'dash': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'stroke-dasharray': '4, 4',
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'wave': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, WAVE),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, WAVE),
|
|
},
|
|
},
|
|
arrow: {
|
|
'single': {
|
|
width: 4,
|
|
height: 8,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': '#000000',
|
|
'stroke-width': 0,
|
|
'stroke-linejoin': 'miter',
|
|
},
|
|
},
|
|
'double': {
|
|
width: 3,
|
|
height: 6,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'stroke-linejoin': 'miter',
|
|
},
|
|
},
|
|
'cross': {
|
|
short: 8,
|
|
radius: 4,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
},
|
|
},
|
|
label: {
|
|
padding: 4,
|
|
margin: {top: 2, bottom: 1},
|
|
attrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
loopbackAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
},
|
|
},
|
|
source: {
|
|
radius: 2,
|
|
render: ({x, y, radius}) => {
|
|
return svg.make('circle', {
|
|
'cx': x,
|
|
'cy': y,
|
|
'r': radius,
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
});
|
|
},
|
|
},
|
|
mask: {
|
|
padding: {
|
|
top: 0,
|
|
left: 3,
|
|
right: 3,
|
|
bottom: 1,
|
|
},
|
|
},
|
|
},
|
|
|
|
titleAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 20,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
'class': 'title',
|
|
},
|
|
|
|
agentLineAttrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
};
|
|
|
|
const SHARED_BLOCK_SECTION = {
|
|
padding: {
|
|
top: 3,
|
|
bottom: 2,
|
|
},
|
|
tag: {
|
|
padding: {
|
|
top: 2,
|
|
left: 4,
|
|
right: 4,
|
|
bottom: 2,
|
|
},
|
|
boxRenderer: BaseTheme.renderTag.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'rx': 3,
|
|
'ry': 3,
|
|
}),
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-weight': 'bold',
|
|
'font-size': 9,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
label: {
|
|
padding: {
|
|
top: 2,
|
|
left: 8,
|
|
right: 8,
|
|
bottom: 2,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
};
|
|
|
|
const BLOCKS = {
|
|
'ref': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
},
|
|
'': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
sepRenderer: SVGShapes.renderLine.bind(null, {
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'stroke-dasharray': '8, 4',
|
|
}),
|
|
},
|
|
};
|
|
|
|
const NOTE_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
};
|
|
|
|
const NOTES = {
|
|
'text': {
|
|
margin: {top: 0, left: 8, right: 8, bottom: 0},
|
|
padding: {top: 4, left: 4, right: 4, bottom: 4},
|
|
overlap: {left: 8, right: 8},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'note': {
|
|
margin: {top: 0, left: 8, right: 8, bottom: 0},
|
|
padding: {top: 8, left: 8, right: 8, bottom: 8},
|
|
overlap: {left: 8, right: 8},
|
|
boxRenderer: SVGShapes.renderNote.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'state': {
|
|
margin: {top: 0, left: 8, right: 8, bottom: 0},
|
|
padding: {top: 8, left: 8, right: 8, bottom: 8},
|
|
overlap: {left: 8, right: 8},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
'rx': 8,
|
|
'ry': 8,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
};
|
|
|
|
const DIVIDER_LABEL_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
};
|
|
|
|
const DIVIDERS = {
|
|
'': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: () => ({}),
|
|
},
|
|
'line': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 8,
|
|
margin: 0,
|
|
render: BaseTheme.renderLineDivider.bind(null, {
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
},
|
|
}),
|
|
},
|
|
'delay': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: BaseTheme.renderDelayDivider.bind(null, {
|
|
dotSize: 2,
|
|
gapSize: 2,
|
|
}),
|
|
},
|
|
'tear': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 8,
|
|
margin: 8,
|
|
render: BaseTheme.renderTearDivider.bind(null, {
|
|
fadeBegin: 4,
|
|
fadeSize: 4,
|
|
zigWidth: 4,
|
|
zigHeight: 1,
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
},
|
|
}),
|
|
},
|
|
};
|
|
|
|
return class MonospaceTheme extends BaseTheme {
|
|
constructor() {
|
|
super({
|
|
name: 'monospace',
|
|
settings: SETTINGS,
|
|
blocks: BLOCKS,
|
|
notes: NOTES,
|
|
dividers: DIVIDERS,
|
|
});
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/themes/Chunky',[
|
|
'./BaseTheme',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
], (
|
|
BaseTheme,
|
|
svg,
|
|
SVGShapes
|
|
) => {
|
|
'use strict';
|
|
|
|
const FONT = 'sans-serif';
|
|
const LINE_HEIGHT = 1.3;
|
|
|
|
const WAVE = new BaseTheme.WavePattern(10, 1);
|
|
|
|
const SETTINGS = {
|
|
titleMargin: 12,
|
|
outerMargin: 5,
|
|
agentMargin: 8,
|
|
actionMargin: 5,
|
|
minActionMargin: 5,
|
|
agentLineHighlightRadius: 4,
|
|
|
|
agentCap: {
|
|
box: {
|
|
padding: {
|
|
top: 1,
|
|
left: 3,
|
|
right: 3,
|
|
bottom: 1,
|
|
},
|
|
arrowBottom: 2 + 14 * 1.3 / 2,
|
|
boxAttrs: {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'rx': 4,
|
|
'ry': 4,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-weight': 'bold',
|
|
'font-size': 14,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
},
|
|
cross: {
|
|
size: 20,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-linecap': 'round',
|
|
}),
|
|
},
|
|
bar: {
|
|
height: 4,
|
|
render: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'rx': 2,
|
|
'ry': 2,
|
|
}),
|
|
},
|
|
fade: {
|
|
width: 5,
|
|
height: 10,
|
|
extend: 1,
|
|
},
|
|
none: {
|
|
height: 10,
|
|
},
|
|
},
|
|
|
|
connect: {
|
|
loopbackRadius: 8,
|
|
line: {
|
|
'solid': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'dash': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-dasharray': '10, 4',
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, null),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, null),
|
|
},
|
|
'wave': {
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
},
|
|
renderFlat: BaseTheme.renderFlatConnector.bind(null, WAVE),
|
|
renderRev: BaseTheme.renderRevConnector.bind(null, WAVE),
|
|
},
|
|
},
|
|
arrow: {
|
|
'single': {
|
|
width: 10,
|
|
height: 12,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-linejoin': 'round',
|
|
},
|
|
},
|
|
'double': {
|
|
width: 10,
|
|
height: 12,
|
|
render: BaseTheme.renderArrowHead,
|
|
attrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
},
|
|
},
|
|
'cross': {
|
|
short: 10,
|
|
radius: 5,
|
|
render: BaseTheme.renderCross.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
}),
|
|
},
|
|
},
|
|
label: {
|
|
padding: 7,
|
|
margin: {top: 2, bottom: 3},
|
|
attrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
loopbackAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
},
|
|
},
|
|
source: {
|
|
radius: 5,
|
|
render: ({x, y, radius}) => {
|
|
return svg.make('circle', {
|
|
'cx': x,
|
|
'cy': y,
|
|
'r': radius,
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
});
|
|
},
|
|
},
|
|
mask: {
|
|
padding: {
|
|
top: 1,
|
|
left: 5,
|
|
right: 5,
|
|
bottom: 3,
|
|
},
|
|
},
|
|
},
|
|
|
|
titleAttrs: {
|
|
'font-family': FONT,
|
|
'font-weight': 'bolder',
|
|
'font-size': 20,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
'class': 'title',
|
|
},
|
|
|
|
agentLineAttrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
},
|
|
};
|
|
|
|
const SHARED_BLOCK_SECTION = {
|
|
padding: {
|
|
top: 3,
|
|
bottom: 4,
|
|
},
|
|
tag: {
|
|
padding: {
|
|
top: 2,
|
|
left: 5,
|
|
right: 5,
|
|
bottom: 1,
|
|
},
|
|
boxRenderer: BaseTheme.renderTag.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'rx': 3,
|
|
'ry': 3,
|
|
}),
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-weight': 'bold',
|
|
'font-size': 9,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
label: {
|
|
padding: {
|
|
top: 2,
|
|
left: 5,
|
|
right: 3,
|
|
bottom: 0,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
};
|
|
|
|
const BLOCKS = {
|
|
'ref': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 4,
|
|
'rx': 5,
|
|
'ry': 5,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
},
|
|
'': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 4,
|
|
'rx': 5,
|
|
'ry': 5,
|
|
}),
|
|
section: SHARED_BLOCK_SECTION,
|
|
sepRenderer: SVGShapes.renderLine.bind(null, {
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'stroke-dasharray': '5, 3',
|
|
}),
|
|
},
|
|
};
|
|
|
|
const NOTE_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
};
|
|
|
|
const NOTES = {
|
|
'text': {
|
|
margin: {top: 0, left: 2, right: 2, bottom: 0},
|
|
padding: {top: 2, left: 2, right: 2, bottom: 2},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'note': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 3, left: 3, right: 10, bottom: 3},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderNote.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'stroke-linejoin': 'round',
|
|
}, {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'state': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 5, left: 7, right: 7, bottom: 5},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
'stroke': '#000000',
|
|
'stroke-width': 3,
|
|
'rx': 10,
|
|
'ry': 10,
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
};
|
|
|
|
const DIVIDER_LABEL_ATTRS = {
|
|
'font-family': FONT,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
};
|
|
|
|
const DIVIDERS = {
|
|
'': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: () => ({}),
|
|
},
|
|
'line': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 0,
|
|
render: BaseTheme.renderLineDivider.bind(null, {
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'stroke-linecap': 'round',
|
|
},
|
|
}),
|
|
},
|
|
'delay': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: BaseTheme.renderDelayDivider.bind(null, {
|
|
dotSize: 3,
|
|
gapSize: 3,
|
|
}),
|
|
},
|
|
'tear': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 10,
|
|
render: BaseTheme.renderTearDivider.bind(null, {
|
|
fadeBegin: 5,
|
|
fadeSize: 10,
|
|
zigWidth: 6,
|
|
zigHeight: 1,
|
|
lineAttrs: {
|
|
'stroke': '#000000',
|
|
'stroke-width': 2,
|
|
'stroke-linejoin': 'round',
|
|
},
|
|
}),
|
|
},
|
|
};
|
|
|
|
return class ChunkyTheme extends BaseTheme {
|
|
constructor() {
|
|
super({
|
|
name: 'chunky',
|
|
settings: SETTINGS,
|
|
blocks: BLOCKS,
|
|
notes: NOTES,
|
|
dividers: DIVIDERS,
|
|
});
|
|
}
|
|
};
|
|
});
|
|
|
|
define('sequence/themes/HandleeFontData',[],() => {
|
|
'use strict';
|
|
|
|
// Handlee font, by Joe Prince
|
|
// Downloaded from Google Fonts and converted to Base64 for embedding in
|
|
// generated SVGs
|
|
// https://fonts.google.com/specimen/Handlee
|
|
|
|
/* License
|
|
|
|
SIL OPEN FONT LICENSE
|
|
Version 1.1 - 26 February 2007
|
|
|
|
PREAMBLE
|
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
development of collaborative font projects, to support the font creation
|
|
efforts of academic and linguistic communities, and to provide a free and
|
|
open framework in which fonts may be shared and improved in partnership
|
|
with others.
|
|
|
|
The OFL allows the licensed fonts to be used, studied, modified and
|
|
redistributed freely as long as they are not sold by themselves. The
|
|
fonts, including any derivative works, can be bundled, embedded,
|
|
redistributed and/or sold with any software provided that any reserved
|
|
names are not used by derivative works. The fonts and derivatives,
|
|
however, cannot be released under any other type of license. The
|
|
requirement for fonts to remain under this license does not apply
|
|
to any document created using the fonts or their derivatives.
|
|
|
|
DEFINITIONS
|
|
"Font Software" refers to the set of files released by the Copyright
|
|
Holder(s) under this license and clearly marked as such. This may
|
|
include source files, build scripts and documentation.
|
|
|
|
"Reserved Font Name" refers to any names specified as such after the
|
|
copyright statement(s).
|
|
|
|
"Original Version" refers to the collection of Font Software components as
|
|
distributed by the Copyright Holder(s).
|
|
|
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
or substituting — in part or in whole — any of the components of the
|
|
Original Version, by changing formats or by porting the Font Software to a
|
|
new environment.
|
|
|
|
"Author" refers to any designer, engineer, programmer, technical
|
|
writer or other person who contributed to the Font Software.
|
|
|
|
PERMISSION & CONDITIONS
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
redistribute, and sell modified and unmodified copies of the Font
|
|
Software, subject to the following conditions:
|
|
|
|
1) Neither the Font Software nor any of its individual components,
|
|
in Original or Modified Versions, may be sold by itself.
|
|
|
|
2) Original or Modified Versions of the Font Software may be bundled,
|
|
redistributed and/or sold with any software, provided that each copy
|
|
contains the above copyright notice and this license. These can be
|
|
included either as stand-alone text files, human-readable headers or
|
|
in the appropriate machine-readable metadata fields within text or
|
|
binary files as long as those fields can be easily viewed by the user.
|
|
|
|
3) No Modified Version of the Font Software may use the Reserved Font
|
|
Name(s) unless explicit written permission is granted by the corresponding
|
|
Copyright Holder. This restriction only applies to the primary font name as
|
|
presented to the users.
|
|
|
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
Software shall not be used to promote, endorse or advertise any
|
|
Modified Version, except to acknowledge the contribution(s) of the
|
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
permission.
|
|
|
|
5) The Font Software, modified or unmodified, in part or in whole,
|
|
must be distributed entirely under this license, and must not be
|
|
distributed under any other license. The requirement for fonts to
|
|
remain under this license does not apply to any document created
|
|
using the Font Software.
|
|
|
|
TERMINATION
|
|
This license becomes null and void if any of the above conditions are
|
|
not met.
|
|
|
|
DISCLAIMER
|
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
|
|
*/
|
|
|
|
return {
|
|
name: 'Handlee',
|
|
woff2: (
|
|
'd09GMgABAAAAAD3EAA4AAAAAi4QAAD1qAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
|
|
'GhYbxV4cKgZgAIF8EQgKgbpIgZNlC4MGAAE2AiQDhggEIAWEDgeDKxuhdSXsmCEe' +
|
|
'ByC2jBgVNYuS+mQUpZq0k+z/vyY3BgzxIa3ugqhFRlV1T4WqHliFgkLvX+Fguaf/' +
|
|
'tXTReCMU5hvZIfpErawhdoJhvGi60udSmcpUmZV+33txIHLMbEhRhomyZs7N2ods' +
|
|
'iOl7OmXseNPFL9fnzsBxPmouBP/3/Wbmvt+Om/2FCihaDcM063gCEX9NLAt4u0Mw' +
|
|
't27RRQwYMGqMWgUxxtioahM7sANfMfL9svpDv1r7QwmKw9y7bx3k5w1Kx2CplAiG' +
|
|
'qIJEAx6gUICjf39+y0xK/qS6vwbT8sAy+yrlEHe3vNdJ+jauiqvOOWRpffhe8mec' +
|
|
'SXiGF4IGTtgLKLV2M6lzDvAXO0QkRtk8v62KREEBwaihHQPHQUZ7YfchZmHtcm8+' +
|
|
'Z6+az/v4cS/auKr51LlyEhygfzOnr94kmRQnbJcIXjvUGdVV1xbM/AtMwQWbE4Nk' +
|
|
'WTgj7VNM7tsSphi6w7Xer64GAF9ZWaEQhamQGZvYSbJ32eOle7QPGCaZ8v8BQACc' +
|
|
'a4LR5sPtg6JABnLj1wL8AT7Ig0UXwD88/7/XfvbvhPOLI9BloMsIxZsiDEJjTHLf' +
|
|
'vMw6c9alqsNd71f1JrRMfmuZUDJl+RESNELxW1Gh1Kq+QyiUQwiLBqH532XN5lbd' +
|
|
'0eXiwCGbNyn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5Am864ZdqJRxa5GO9PHpglZjqn0ZulqqamNlzDq6nWqV1sqQ5uW' +
|
|
'ZG99lRlTP3z4/iVw968DnxaQhFS/xRpWdHxXGG53OF1uj9fnPydIimZYLnARDIUj' +
|
|
'fPRyp3+9Qly8TiRT6Uw2l38kyXqD0WS2WG12hzM5JTXNle7O8GR6fVnZObl5+QWF' +
|
|
'RcVbxsZRWmHCAvOst8tco5aatNJsFy++s9uUfT5Z/09J6SJln916dWt/Z3fvttsH' +
|
|
'h/9Tudi9k8Ydc9RU19bXNWzS2NzU0tre1tHZ1dPd2993wmaDA0OGnXR/wCEPzjtD' +
|
|
'jjhu2qURx1x+3R5nnI2W/z0OAAA='
|
|
),
|
|
};
|
|
});
|
|
|
|
define('sequence/themes/Sketch',[
|
|
'./BaseTheme',
|
|
'svg/SVGUtilities',
|
|
'svg/SVGShapes',
|
|
'./HandleeFontData',
|
|
], (
|
|
BaseTheme,
|
|
svg,
|
|
SVGShapes,
|
|
Handlee
|
|
) => {
|
|
'use strict';
|
|
|
|
const FONT = Handlee.name;
|
|
const FONT_FAMILY = '\'' + FONT + '\',cursive';
|
|
const LINE_HEIGHT = 1.5;
|
|
const MAX_CHAOS = 5;
|
|
|
|
const PENCIL = {
|
|
normal: {
|
|
'stroke': 'rgba(0,0,0,0.7)',
|
|
'stroke-width': 0.8,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
},
|
|
thick: {
|
|
'stroke': 'rgba(0,0,0,0.8)',
|
|
'stroke-width': 1.2,
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
},
|
|
};
|
|
|
|
const SETTINGS = {
|
|
titleMargin: 10,
|
|
outerMargin: 5,
|
|
agentMargin: 10,
|
|
actionMargin: 10,
|
|
minActionMargin: 3,
|
|
agentLineHighlightRadius: 4,
|
|
|
|
agentCap: {
|
|
box: {
|
|
padding: {
|
|
top: 5,
|
|
left: 10,
|
|
right: 10,
|
|
bottom: 5,
|
|
},
|
|
arrowBottom: 5 + 12 * 1.3 / 2,
|
|
labelAttrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 12,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
boxRenderer: null,
|
|
},
|
|
cross: {
|
|
size: 15,
|
|
render: null,
|
|
},
|
|
bar: {
|
|
height: 6,
|
|
render: null,
|
|
},
|
|
fade: {
|
|
width: Math.ceil(MAX_CHAOS * 2 + 2),
|
|
height: 6,
|
|
extend: Math.ceil(MAX_CHAOS * 0.3 + 1),
|
|
},
|
|
none: {
|
|
height: 10,
|
|
},
|
|
},
|
|
|
|
connect: {
|
|
loopbackRadius: 6,
|
|
line: {
|
|
'solid': {
|
|
attrs: Object.assign({
|
|
'fill': 'none',
|
|
}, PENCIL.normal),
|
|
renderFlat: null,
|
|
renderRev: null,
|
|
},
|
|
'dash': {
|
|
attrs: Object.assign({
|
|
'fill': 'none',
|
|
'stroke-dasharray': '4, 2',
|
|
}, PENCIL.normal),
|
|
renderFlat: null,
|
|
renderRev: null,
|
|
},
|
|
'wave': {
|
|
attrs: Object.assign({
|
|
'fill': 'none',
|
|
'stroke-linejoin': 'round',
|
|
'stroke-linecap': 'round',
|
|
}, PENCIL.normal),
|
|
renderFlat: null,
|
|
renderRev: null,
|
|
},
|
|
},
|
|
arrow: {
|
|
'single': {
|
|
width: 5,
|
|
height: 6,
|
|
attrs: Object.assign({
|
|
'fill': 'rgba(0,0,0,0.9)',
|
|
}, PENCIL.normal),
|
|
render: null,
|
|
},
|
|
'double': {
|
|
width: 4,
|
|
height: 8,
|
|
attrs: Object.assign({
|
|
'fill': 'none',
|
|
}, PENCIL.normal),
|
|
render: null,
|
|
},
|
|
'cross': {
|
|
short: 5,
|
|
radius: 3,
|
|
render: null,
|
|
},
|
|
},
|
|
label: {
|
|
padding: 6,
|
|
margin: {top: 2, bottom: 1},
|
|
attrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
},
|
|
loopbackAttrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
},
|
|
},
|
|
source: {
|
|
radius: 1,
|
|
render: ({x, y, radius}) => {
|
|
return svg.make('circle', {
|
|
'cx': x,
|
|
'cy': y,
|
|
'r': radius,
|
|
'fill': '#000000',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
});
|
|
},
|
|
},
|
|
mask: {
|
|
padding: {
|
|
top: 0,
|
|
left: 3,
|
|
right: 3,
|
|
bottom: 1,
|
|
},
|
|
},
|
|
},
|
|
|
|
titleAttrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 20,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
'class': 'title',
|
|
},
|
|
|
|
agentLineAttrs: {
|
|
'fill': 'none',
|
|
'stroke': '#000000',
|
|
'stroke-width': 1,
|
|
},
|
|
};
|
|
|
|
const SHARED_BLOCK_SECTION = {
|
|
padding: {
|
|
top: 3,
|
|
bottom: 2,
|
|
},
|
|
tag: {
|
|
padding: {
|
|
top: 2,
|
|
left: 3,
|
|
right: 5,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: null,
|
|
labelAttrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-weight': 'bold',
|
|
'font-size': 9,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
label: {
|
|
padding: {
|
|
top: 2,
|
|
left: 5,
|
|
right: 3,
|
|
bottom: 0,
|
|
},
|
|
labelAttrs: {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'left',
|
|
},
|
|
},
|
|
};
|
|
|
|
const BLOCKS = {
|
|
'ref': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: null,
|
|
section: SHARED_BLOCK_SECTION,
|
|
},
|
|
'': {
|
|
margin: {
|
|
top: 0,
|
|
bottom: 0,
|
|
},
|
|
boxRenderer: null,
|
|
section: SHARED_BLOCK_SECTION,
|
|
sepRenderer: null,
|
|
},
|
|
};
|
|
|
|
const NOTE_ATTRS = {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
};
|
|
|
|
const NOTES = {
|
|
'text': {
|
|
margin: {top: 0, left: 6, right: 6, bottom: 0},
|
|
padding: {top: 2, left: 2, right: 2, bottom: 2},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: SVGShapes.renderBox.bind(null, {
|
|
'fill': '#FFFFFF',
|
|
}),
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'note': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 5, left: 5, right: 10, bottom: 5},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: null,
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
'state': {
|
|
margin: {top: 0, left: 5, right: 5, bottom: 0},
|
|
padding: {top: 7, left: 7, right: 7, bottom: 7},
|
|
overlap: {left: 10, right: 10},
|
|
boxRenderer: null,
|
|
labelAttrs: NOTE_ATTRS,
|
|
},
|
|
};
|
|
|
|
const DIVIDER_LABEL_ATTRS = {
|
|
'font-family': FONT_FAMILY,
|
|
'font-size': 8,
|
|
'line-height': LINE_HEIGHT,
|
|
'text-anchor': 'middle',
|
|
};
|
|
|
|
const DIVIDERS = {
|
|
'': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: () => ({}),
|
|
},
|
|
'line': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 0,
|
|
render: null,
|
|
},
|
|
'delay': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 0,
|
|
margin: 0,
|
|
render: BaseTheme.renderDelayDivider.bind(null, {
|
|
dotSize: 1,
|
|
gapSize: 2,
|
|
}),
|
|
},
|
|
'tear': {
|
|
labelAttrs: DIVIDER_LABEL_ATTRS,
|
|
padding: {top: 2, left: 5, right: 5, bottom: 2},
|
|
extend: 10,
|
|
margin: 10,
|
|
render: null,
|
|
},
|
|
};
|
|
|
|
class Random {
|
|
// xorshift+ 64-bit random generator
|
|
// https://en.wikipedia.org/wiki/Xorshift
|
|
|
|
constructor() {
|
|
this.s = new Uint32Array(4);
|
|
}
|
|
|
|
reset() {
|
|
// Arbitrary random seed with roughly balanced 1s / 0s
|
|
// (taken from running Math.random a few times)
|
|
this.s[0] = 0x177E9C74;
|
|
this.s[1] = 0xAE6FFDCE;
|
|
this.s[2] = 0x3CF4F32B;
|
|
this.s[3] = 0x46449F88;
|
|
}
|
|
|
|
nextFloat() {
|
|
/* jshint -W016 */ // bit-operations are part of the algorithm
|
|
const range = 0x100000000;
|
|
let x0 = this.s[0];
|
|
let x1 = this.s[1];
|
|
const y0 = this.s[2];
|
|
const y1 = this.s[3];
|
|
this.s[0] = y0;
|
|
this.s[1] = y1;
|
|
x0 ^= (x0 << 23) | (x1 >>> 9);
|
|
x1 ^= (x1 << 23);
|
|
this.s[2] = x0 ^ y0 ^ (x0 >>> 17) ^ (y0 >>> 26);
|
|
this.s[3] = (
|
|
x1 ^ y1 ^
|
|
(x0 << 15 | x1 >>> 17) ^
|
|
(y0 << 6 | y1 >>> 26)
|
|
);
|
|
return (((this.s[3] + y1) >>> 0) % range) / range;
|
|
}
|
|
}
|
|
|
|
const RIGHT = {};
|
|
const LEFT = {};
|
|
|
|
class SketchWavePattern extends BaseTheme.WavePattern {
|
|
constructor(width, handedness) {
|
|
const heights = [
|
|
+0.0,
|
|
-0.3,
|
|
-0.6,
|
|
-0.75,
|
|
-0.45,
|
|
+0.0,
|
|
+0.45,
|
|
+0.75,
|
|
+0.6,
|
|
+0.3,
|
|
];
|
|
if(handedness !== RIGHT) {
|
|
heights.reverse();
|
|
}
|
|
super(6, heights);
|
|
}
|
|
|
|
getDelta(p) {
|
|
return super.getDelta(p) + Math.sin(p * 0.03) * 0.5;
|
|
}
|
|
}
|
|
|
|
class SketchTheme extends BaseTheme {
|
|
constructor(handedness = RIGHT) {
|
|
super({
|
|
name: '',
|
|
settings: SETTINGS,
|
|
blocks: BLOCKS,
|
|
notes: NOTES,
|
|
dividers: DIVIDERS,
|
|
});
|
|
|
|
if(handedness === RIGHT) {
|
|
this.name = 'sketch';
|
|
this.handedness = 1;
|
|
} else {
|
|
this.name = 'sketch left handed';
|
|
this.handedness = -1;
|
|
}
|
|
this.random = new Random();
|
|
this.wave = new SketchWavePattern(4, handedness);
|
|
|
|
this._assignCapFunctions();
|
|
this._assignConnectFunctions();
|
|
this._assignNoteFunctions();
|
|
this._assignBlockFunctions();
|
|
this._assignDividerFunctions();
|
|
}
|
|
|
|
_assignCapFunctions() {
|
|
this.renderBar = this.renderBar.bind(this);
|
|
this.renderBox = this.renderBox.bind(this);
|
|
|
|
this.agentCap.cross.render = this.renderCross.bind(this);
|
|
this.agentCap.bar.render = this.renderBar;
|
|
this.agentCap.box.boxRenderer = this.renderBox;
|
|
}
|
|
|
|
_assignConnectFunctions() {
|
|
this.renderArrowHead = this.renderArrowHead.bind(this);
|
|
this.renderFlatConnector = this.renderFlatConnector.bind(this);
|
|
this.renderRevConnector = this.renderRevConnector.bind(this);
|
|
|
|
this.connect.arrow.single.render = this.renderArrowHead;
|
|
this.connect.arrow.double.render = this.renderArrowHead;
|
|
this.connect.arrow.cross.render = this.renderCross.bind(this);
|
|
|
|
this.connect.line.solid.renderFlat = this.renderFlatConnector;
|
|
this.connect.line.solid.renderRev = this.renderRevConnector;
|
|
this.connect.line.dash.renderFlat = this.renderFlatConnector;
|
|
this.connect.line.dash.renderRev = this.renderRevConnector;
|
|
this.connect.line.wave.renderFlat =
|
|
this.renderFlatConnectorWave.bind(this);
|
|
this.connect.line.wave.renderRev =
|
|
this.renderRevConnectorWave.bind(this);
|
|
}
|
|
|
|
_assignNoteFunctions() {
|
|
this.notes.note.boxRenderer = this.renderNote.bind(this);
|
|
this.notes.state.boxRenderer = this.renderState.bind(this);
|
|
}
|
|
|
|
_assignBlockFunctions() {
|
|
this.renderTag = this.renderTag.bind(this);
|
|
|
|
this.blocks.ref.boxRenderer = this.renderRefBlock.bind(this);
|
|
this.blocks[''].boxRenderer = this.renderBlock.bind(this);
|
|
this.blocks.ref.section.tag.boxRenderer = this.renderTag;
|
|
this.blocks[''].section.tag.boxRenderer = this.renderTag;
|
|
this.blocks[''].sepRenderer = this.renderSeparator.bind(this);
|
|
}
|
|
|
|
_assignDividerFunctions() {
|
|
this.dividers.line.render = this.renderLineDivider.bind(this);
|
|
this.dividers.tear.render = BaseTheme.renderTearDivider.bind(null, {
|
|
fadeBegin: 5,
|
|
fadeSize: 10,
|
|
pattern: this.wave,
|
|
lineAttrs: PENCIL.normal,
|
|
});
|
|
}
|
|
|
|
reset() {
|
|
this.random.reset();
|
|
}
|
|
|
|
addDefs(builder) {
|
|
builder('sketch_font', () => {
|
|
const style = document.createElement('style');
|
|
// For some uses, it is fine to load this font externally,
|
|
// but this fails when exporting as SVG / PNG (svg tags must
|
|
// have no external dependencies).
|
|
// const url = 'https://fonts.googleapis.com/css?family=' + FONT;
|
|
// style.innerText = '@import url("' + url + '")';
|
|
style.innerText = (
|
|
'@font-face{' +
|
|
'font-family:"' + Handlee.name + '";' +
|
|
'src:url("data:font/woff2;base64,' + Handlee.woff2 + '");' +
|
|
'}'
|
|
);
|
|
return style;
|
|
});
|
|
}
|
|
|
|
vary(range, centre = 0) {
|
|
if(!range) {
|
|
return centre;
|
|
}
|
|
// cosine distribution [-pi/2 pi/2] scaled to [-range range]
|
|
// int(cos(x))dx = sin(x)
|
|
// from -pi/2: sin(x) - sin(-pi/2) = sin(x) + 1
|
|
// total: sin(pi/2) + 1 = 2
|
|
// normalise to area 1: /2
|
|
// (sin(x) + 1) / 2
|
|
// inverse: p = (sin(x) + 1) / 2
|
|
// asin(2p - 1) = x
|
|
// normalise range
|
|
// x = asin(2p - 1) * range / (pi/2)
|
|
const rand = this.random.nextFloat(); // [0 1)
|
|
return centre + Math.asin(rand * 2 - 1) * 2 * range / Math.PI;
|
|
}
|
|
|
|
lineNodes(p1, p2, {
|
|
var1 = 1,
|
|
var2 = 1,
|
|
varX = 1,
|
|
varY = 1,
|
|
move = true,
|
|
}) {
|
|
const length = Math.sqrt(
|
|
(p2.x - p1.x) * (p2.x - p1.x) +
|
|
(p2.y - p1.y) * (p2.y - p1.y)
|
|
);
|
|
const rough = Math.min(Math.sqrt(length) * 0.2, MAX_CHAOS);
|
|
const x1 = this.vary(var1 * varX * rough, p1.x);
|
|
const y1 = this.vary(var1 * varY * rough, p1.y);
|
|
const x2 = this.vary(var2 * varX * rough, p2.x);
|
|
const y2 = this.vary(var2 * varY * rough, p2.y);
|
|
|
|
// -1 = p1 higher, 1 = p2 higher
|
|
const upper = Math.max(-1, Math.min(1,
|
|
(y1 - y2) / (Math.abs(x1 - x2) + 0.001)
|
|
));
|
|
const frac = upper / 6 + 0.5;
|
|
|
|
// Line curve is to top / left (simulates right-handed drawing)
|
|
// or top / right (left-handed)
|
|
const curveX = this.vary(0.5, 0.5) * rough;
|
|
const curveY = this.vary(0.5, 0.5) * rough;
|
|
const xc = x1 * (1 - frac) + x2 * frac - curveX * this.handedness;
|
|
const yc = y1 * (1 - frac) + y2 * frac - curveY;
|
|
const nodes = (
|
|
(move ? ('M' + x1 + ' ' + y1) : '') +
|
|
'C' + xc + ' ' + yc +
|
|
',' + x2 + ' ' + y2 +
|
|
',' + x2 + ' ' + y2
|
|
);
|
|
return {
|
|
nodes,
|
|
p1: {x: x1, y: y1},
|
|
p2: {x: x2, y: y2},
|
|
};
|
|
}
|
|
|
|
renderLine(p1, p2, lineOptions) {
|
|
const line = this.lineNodes(p1, p2, lineOptions);
|
|
const shape = svg.make('path', Object.assign({
|
|
'd': line.nodes,
|
|
'fill': 'none',
|
|
'stroke-dasharray': lineOptions.dash ? '6, 5' : 'none',
|
|
}, lineOptions.thick ? PENCIL.thick : PENCIL.normal));
|
|
return shape;
|
|
}
|
|
|
|
renderBox({x, y, width, height}, {fill = null, thick = false} = {}) {
|
|
const lT = this.lineNodes(
|
|
{x, y},
|
|
{x: x + width, y},
|
|
{}
|
|
);
|
|
const lB = this.lineNodes(
|
|
{x: x + width, y: y + height},
|
|
{x, y: y + height},
|
|
{move: false}
|
|
);
|
|
const lR = this.lineNodes(
|
|
lT.p2,
|
|
lB.p1,
|
|
{var1: 0, var2: 0, move: false}
|
|
);
|
|
const lL = this.lineNodes(
|
|
lB.p2,
|
|
lT.p1,
|
|
{var1: 0, var2: 0.3, move: false}
|
|
);
|
|
|
|
const shape = svg.make('path', Object.assign({
|
|
'd': lT.nodes + lR.nodes + lB.nodes + lL.nodes,
|
|
'fill': fill || '#FFFFFF',
|
|
}, thick ? PENCIL.thick : PENCIL.normal));
|
|
|
|
return shape;
|
|
}
|
|
|
|
renderNote({x, y, width, height}) {
|
|
const flickSize = 5;
|
|
const lT = this.lineNodes(
|
|
{x, y},
|
|
{x: x + width - flickSize, y},
|
|
{}
|
|
);
|
|
const lF = this.lineNodes(
|
|
lT.p2,
|
|
{x: x + width, y: y + flickSize},
|
|
{move: false, var1: 0}
|
|
);
|
|
const lB = this.lineNodes(
|
|
{x: x + width, y: y + height},
|
|
{x, y: y + height},
|
|
{move: false}
|
|
);
|
|
const lR = this.lineNodes(
|
|
lF.p2,
|
|
lB.p1,
|
|
{var1: 0, var2: 0, move: false}
|
|
);
|
|
const lL = this.lineNodes(
|
|
lB.p2,
|
|
lT.p1,
|
|
{var1: 0, var2: 0.3, move: false}
|
|
);
|
|
const lF1 = this.lineNodes(
|
|
lF.p1,
|
|
{x: x + width - flickSize, y: y + flickSize},
|
|
{var1: 0.3}
|
|
);
|
|
const lF2 = this.lineNodes(
|
|
lF1.p2,
|
|
lF.p2,
|
|
{var1: 0, move: false}
|
|
);
|
|
|
|
const g = svg.make('g');
|
|
g.appendChild(svg.make('path', Object.assign({
|
|
'd': (
|
|
lT.nodes +
|
|
lF.nodes +
|
|
lR.nodes +
|
|
lB.nodes +
|
|
lL.nodes
|
|
),
|
|
'fill': '#FFFFFF',
|
|
}, PENCIL.normal)));
|
|
g.appendChild(svg.make('path', Object.assign({
|
|
'd': lF1.nodes + lF2.nodes,
|
|
'fill': 'none',
|
|
}, PENCIL.normal)));
|
|
|
|
return g;
|
|
}
|
|
|
|
renderLineDivider({x, y, labelWidth, width, height}) {
|
|
let shape = null;
|
|
const yPos = y + height / 2;
|
|
if(labelWidth > 0) {
|
|
shape = svg.make('g');
|
|
shape.appendChild(this.renderLine(
|
|
{x, y: yPos},
|
|
{x: x + (width - labelWidth) / 2, y: yPos},
|
|
{}
|
|
));
|
|
shape.appendChild(this.renderLine(
|
|
{x: x + (width + labelWidth) / 2, y: yPos},
|
|
{x: x + width, y: yPos},
|
|
{}
|
|
));
|
|
} else {
|
|
shape = this.renderLine(
|
|
{x, y: yPos},
|
|
{x: x + width, y: yPos},
|
|
{}
|
|
);
|
|
}
|
|
return {shape};
|
|
}
|
|
|
|
renderFlatConnector(attrs, {x1, y1, x2, y2}) {
|
|
const ln = this.lineNodes(
|
|
{x: x1, y: y1},
|
|
{x: x2, y: y2},
|
|
{varX: 0.3}
|
|
);
|
|
return {
|
|
shape: svg.make('path', Object.assign({'d': ln.nodes}, attrs)),
|
|
p1: ln.p1,
|
|
p2: ln.p2,
|
|
};
|
|
}
|
|
|
|
renderRevConnector(attrs, {x1, y1, x2, y2, xR}) {
|
|
const variance = Math.min((xR - x1) * 0.06, 3);
|
|
const overshoot = Math.min((xR - x1) * 0.5, 6);
|
|
const p1x = x1 + this.vary(variance, -1);
|
|
const p1y = y1 + this.vary(variance, -1);
|
|
const b1x = xR - overshoot * this.vary(0.2, 1);
|
|
const b1y = y1 - this.vary(1, 2);
|
|
const p2x = xR;
|
|
const p2y = y1 + this.vary(1, 1);
|
|
const b2x = xR;
|
|
const b2y = y2 + this.vary(2);
|
|
const p3x = x2 + this.vary(variance, -1);
|
|
const p3y = y2 + this.vary(variance, -1);
|
|
|
|
return {
|
|
shape: svg.make('path', Object.assign({
|
|
d: (
|
|
'M' + p1x + ' ' + p1y +
|
|
'C' + p1x + ' ' + p1y +
|
|
',' + b1x + ' ' + b1y +
|
|
',' + p2x + ' ' + p2y +
|
|
'S' + b2x + ' ' + b2y +
|
|
',' + p3x + ' ' + p3y
|
|
),
|
|
}, attrs)),
|
|
p1: {x: p1x, y: p1y},
|
|
p2: {x: p3x, y: p3y},
|
|
};
|
|
}
|
|
|
|
renderFlatConnectorWave(attrs, {x1, y1, x2, y2}) {
|
|
const x1v = x1 + this.vary(0.3);
|
|
const x2v = x2 + this.vary(0.3);
|
|
const y1v = y1 + this.vary(1);
|
|
const y2v = y2 + this.vary(1);
|
|
return {
|
|
shape: svg.make('path', Object.assign({
|
|
d: new SVGShapes.PatternedLine(this.wave)
|
|
.move(x1v, y1v)
|
|
.line(x2v, y2v)
|
|
.cap()
|
|
.asPath(),
|
|
}, attrs)),
|
|
p1: {x: x1v, y: y1v},
|
|
p2: {x: x2v, y: y2v},
|
|
};
|
|
}
|
|
|
|
renderRevConnectorWave(attrs, {x1, y1, x2, y2, xR}) {
|
|
const x1v = x1 + this.vary(0.3);
|
|
const x2v = x2 + this.vary(0.3);
|
|
const y1v = y1 + this.vary(1);
|
|
const y2v = y2 + this.vary(1);
|
|
return {
|
|
shape: svg.make('path', Object.assign({
|
|
d: new SVGShapes.PatternedLine(this.wave)
|
|
.move(x1v, y1v)
|
|
.line(xR, y1)
|
|
.arc(xR, (y1 + y2) / 2, Math.PI)
|
|
.line(x2v, y2v)
|
|
.cap()
|
|
.asPath(),
|
|
}, attrs)),
|
|
p1: {x: x1v, y: y1v},
|
|
p2: {x: x2v, y: y2v},
|
|
};
|
|
}
|
|
|
|
renderArrowHead(attrs, {x, y, width, height, dir}) {
|
|
const w = width * this.vary(0.2, 1);
|
|
const h = height * this.vary(0.3, 1);
|
|
const wx = w * dir.dx;
|
|
const wy = w * dir.dy;
|
|
const hy = h * 0.5 * dir.dx;
|
|
const hx = -h * 0.5 * dir.dy;
|
|
const l1 = this.lineNodes(
|
|
{x: x + wx - hx, y: y + wy - hy},
|
|
{x, y},
|
|
{var1: 2.0, var2: 0.2}
|
|
);
|
|
const l2 = this.lineNodes(
|
|
l1.p2,
|
|
{x: x + wx + hx, y: y + wy + hy},
|
|
{var1: 0, var2: 2.0, move: false}
|
|
);
|
|
const l3 = (attrs.fill === 'none') ? {nodes: ''} : this.lineNodes(
|
|
l2.p2,
|
|
l1.p1,
|
|
{var1: 0, var2: 0, move: false}
|
|
);
|
|
return svg.make('path', Object.assign({
|
|
'd': l1.nodes + l2.nodes + l3.nodes,
|
|
}, attrs));
|
|
}
|
|
|
|
renderState({x, y, width, height}) {
|
|
const dx = Math.min(width * 0.06, 3);
|
|
const dy = Math.min(height * 0.06, 3);
|
|
const tlX = x + dx * this.vary(0.6, 1);
|
|
const tlY = y + dy * this.vary(0.6, 1);
|
|
const trX = x + width - dx * this.vary(0.6, 1);
|
|
const trY = y + dy * this.vary(0.6, 1);
|
|
const blX = x + dx * this.vary(0.6, 1);
|
|
const blY = y + height - dy * this.vary(0.6, 1);
|
|
const brX = x + width - dx * this.vary(0.6, 1);
|
|
const brY = y + height - dy * this.vary(0.6, 1);
|
|
const mX = x + width / 2;
|
|
const mY = y + height / 2;
|
|
const cx = dx * this.vary(0.2, 1.2);
|
|
const cy = dy * this.vary(0.2, 1.2);
|
|
const bentT = y - Math.min(width * 0.005, 1);
|
|
const bentB = y + height - Math.min(width * 0.01, 2);
|
|
const bentL = x - Math.min(height * 0.01, 2) * this.handedness;
|
|
const bentR = bentL + width;
|
|
|
|
return svg.make('path', Object.assign({
|
|
'd': (
|
|
'M' + tlX + ' ' + tlY +
|
|
'C' + (tlX + cx) + ' ' + (tlY - cy) +
|
|
',' + (mX - width * this.vary(0.03, 0.3)) + ' ' + bentT +
|
|
',' + mX + ' ' + bentT +
|
|
'S' + (trX - cx) + ' ' + (trY - cy) +
|
|
',' + trX + ' ' + trY +
|
|
'S' + bentR + ' ' + (mY - height * this.vary(0.03, 0.3)) +
|
|
',' + bentR + ' ' + mY +
|
|
'S' + (brX + cx) + ' ' + (brY - cy) +
|
|
',' + brX + ' ' + brY +
|
|
'S' + (mX + width * this.vary(0.03, 0.3)) + ' ' + bentB +
|
|
',' + mX + ' ' + bentB +
|
|
'S' + (blX + cx) + ' ' + (blY + cy) +
|
|
',' + blX + ' ' + blY +
|
|
'S' + bentL + ' ' + (mY + height * this.vary(0.03, 0.3)) +
|
|
',' + bentL + ' ' + mY +
|
|
'S' + (tlX - cx) + ' ' + (tlY + cy) +
|
|
',' + tlX + ' ' + tlY +
|
|
'Z'
|
|
),
|
|
'fill': '#FFFFFF',
|
|
}, PENCIL.normal));
|
|
}
|
|
|
|
renderRefBlock({x, y, width, height}) {
|
|
return this.renderBox(
|
|
{x, y, width, height},
|
|
{fill: '#FFFFFF', thick: true}
|
|
);
|
|
}
|
|
|
|
renderBlock({x, y, width, height}) {
|
|
return this.renderBox(
|
|
{x, y, width, height},
|
|
{fill: 'none', thick: true}
|
|
);
|
|
}
|
|
|
|
renderTag({x, y, width, height}) {
|
|
const x2 = x + width;
|
|
const y2 = y + height;
|
|
|
|
const l1 = this.lineNodes(
|
|
{x: x2 + 3, y},
|
|
{x: x2 - 2, y: y2},
|
|
{}
|
|
);
|
|
const l2 = this.lineNodes(
|
|
l1.p2,
|
|
{x, y: y2 + 1},
|
|
{var1: 0, move: false}
|
|
);
|
|
|
|
const line = l1.nodes + l2.nodes;
|
|
|
|
const g = svg.make('g');
|
|
|
|
g.appendChild(svg.make('path', {
|
|
'd': line + 'L' + x + ' ' + y,
|
|
'fill': '#FFFFFF',
|
|
}));
|
|
|
|
g.appendChild(svg.make('path', Object.assign({
|
|
'd': line,
|
|
'fill': '#FFFFFF',
|
|
}, PENCIL.normal)));
|
|
|
|
return g;
|
|
}
|
|
|
|
renderSeparator({x1, y1, x2, y2}) {
|
|
return this.renderLine(
|
|
{x: x1, y: y1},
|
|
{x: x2, y: y2},
|
|
{thick: true, dash: true}
|
|
);
|
|
}
|
|
|
|
renderBar({x, y, width, height}) {
|
|
return this.renderBox({x, y, width, height}, {fill: '#000000'});
|
|
}
|
|
|
|
renderCross({x, y, radius}) {
|
|
const r1 = this.vary(0.2, 1) * radius;
|
|
const l1 = this.lineNodes(
|
|
{x: x - r1, y: y - r1},
|
|
{x: x + r1, y: y + r1},
|
|
{}
|
|
);
|
|
const r2 = this.vary(0.2, 1) * radius;
|
|
const l2 = this.lineNodes(
|
|
{x: x + r2, y: y - r2},
|
|
{x: x - r2, y: y + r2},
|
|
{}
|
|
);
|
|
|
|
return svg.make('path', Object.assign({
|
|
'd': l1.nodes + l2.nodes,
|
|
'fill': 'none',
|
|
}, PENCIL.normal));
|
|
}
|
|
|
|
renderAgentLine({x, y0, y1, width, className}) {
|
|
if(width > 0) {
|
|
const shape = this.renderBox({
|
|
x: x - width / 2,
|
|
y: y0,
|
|
width,
|
|
height: y1 - y0,
|
|
}, {fill: 'none'});
|
|
shape.setAttribute('class', className);
|
|
return shape;
|
|
} else {
|
|
const shape = this.renderLine(
|
|
{x, y: y0},
|
|
{x, y: y1},
|
|
{varY: 0.3}
|
|
);
|
|
shape.setAttribute('class', className);
|
|
return shape;
|
|
}
|
|
}
|
|
}
|
|
|
|
SketchTheme.RIGHT = RIGHT;
|
|
SketchTheme.LEFT = LEFT;
|
|
|
|
return SketchTheme;
|
|
});
|
|
|
|
/* jshint -W072 */ // Allow several required modules
|
|
define('sequence/SequenceDiagram',[
|
|
'core/EventObject',
|
|
'./Parser',
|
|
'./Generator',
|
|
'./Renderer',
|
|
'./Exporter',
|
|
'./CodeMirrorHints',
|
|
'./themes/BaseTheme',
|
|
'./themes/Basic',
|
|
'./themes/Monospace',
|
|
'./themes/Chunky',
|
|
'./themes/Sketch',
|
|
], (
|
|
EventObject,
|
|
Parser,
|
|
Generator,
|
|
Renderer,
|
|
Exporter,
|
|
CMHints,
|
|
BaseTheme,
|
|
BasicTheme,
|
|
MonospaceTheme,
|
|
ChunkyTheme,
|
|
SketchTheme
|
|
) => {
|
|
/* jshint +W072 */
|
|
'use strict';
|
|
|
|
const themes = [
|
|
new BasicTheme(),
|
|
new MonospaceTheme(),
|
|
new ChunkyTheme(),
|
|
new SketchTheme(SketchTheme.RIGHT),
|
|
new SketchTheme(SketchTheme.LEFT),
|
|
];
|
|
|
|
const SharedParser = new Parser();
|
|
const SharedGenerator = new Generator();
|
|
const CMMode = SharedParser.getCodeMirrorMode();
|
|
|
|
function registerCodeMirrorMode(CodeMirror, modeName = 'sequence') {
|
|
if(!CodeMirror) {
|
|
CodeMirror = window.CodeMirror;
|
|
}
|
|
CodeMirror.defineMode(modeName, () => CMMode);
|
|
CodeMirror.registerHelper('hint', modeName, CMHints.getHints);
|
|
}
|
|
|
|
function addTheme(theme) {
|
|
themes.push(theme);
|
|
}
|
|
|
|
class SequenceDiagram extends EventObject {
|
|
constructor(code = null, options = {}) {
|
|
super();
|
|
|
|
if(code && typeof code === 'object') {
|
|
options = code;
|
|
code = options.code;
|
|
}
|
|
|
|
this.registerCodeMirrorMode = registerCodeMirrorMode;
|
|
|
|
this.code = code;
|
|
this.parser = SharedParser;
|
|
this.generator = SharedGenerator;
|
|
this.renderer = new Renderer(Object.assign({themes}, options));
|
|
this.exporter = new Exporter();
|
|
this.renderer.addEventForwarding(this);
|
|
if(options.container) {
|
|
options.container.appendChild(this.dom());
|
|
}
|
|
if(typeof this.code === 'string') {
|
|
this.render();
|
|
}
|
|
}
|
|
|
|
clone(options = {}) {
|
|
return new SequenceDiagram(Object.assign({
|
|
code: this.code,
|
|
container: null,
|
|
themes: this.renderer.getThemes(),
|
|
namespace: null,
|
|
components: this.renderer.components,
|
|
SVGTextBlockClass: this.renderer.SVGTextBlockClass,
|
|
}, options));
|
|
}
|
|
|
|
set(code = '') {
|
|
if(this.code === code) {
|
|
return;
|
|
}
|
|
|
|
this.code = code;
|
|
this.render();
|
|
}
|
|
|
|
process(code) {
|
|
const parsed = this.parser.parse(code);
|
|
return this.generator.generate(parsed);
|
|
}
|
|
|
|
addTheme(theme) {
|
|
this.renderer.addTheme(theme);
|
|
}
|
|
|
|
setHighlight(line = null) {
|
|
this.renderer.setHighlight(line);
|
|
}
|
|
|
|
getThemeNames() {
|
|
return this.renderer.getThemeNames();
|
|
}
|
|
|
|
getThemes() {
|
|
return this.renderer.getThemes();
|
|
}
|
|
|
|
getSVGSynchronous() {
|
|
return this.exporter.getSVGURL(this.renderer);
|
|
}
|
|
|
|
getSVG() {
|
|
return Promise.resolve({
|
|
url: this.getSVGSynchronous(),
|
|
latest: true,
|
|
});
|
|
}
|
|
|
|
getPNG({resolution = 1, size = null} = {}) {
|
|
if(size) {
|
|
this.renderer.width = size.width;
|
|
this.renderer.height = size.height;
|
|
}
|
|
return new Promise((resolve) => {
|
|
this.exporter.getPNGURL(
|
|
this.renderer,
|
|
resolution,
|
|
(url, latest) => {
|
|
resolve({url, latest});
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
getSize() {
|
|
return {
|
|
width: this.renderer.width,
|
|
height: this.renderer.height,
|
|
};
|
|
}
|
|
|
|
render(processed = null) {
|
|
const dom = this.renderer.svg();
|
|
const originalParent = dom.parentNode;
|
|
if(!document.body.contains(dom)) {
|
|
if(originalParent) {
|
|
originalParent.removeChild(dom);
|
|
}
|
|
document.body.appendChild(dom);
|
|
}
|
|
try {
|
|
if(!processed) {
|
|
processed = this.process(this.code);
|
|
}
|
|
this.renderer.render(processed);
|
|
} finally {
|
|
if(dom.parentNode !== originalParent) {
|
|
document.body.removeChild(dom);
|
|
if(originalParent) {
|
|
originalParent.appendChild(dom);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
setContainer(node = null) {
|
|
const dom = this.dom();
|
|
if(dom.parentNode) {
|
|
dom.parentNode.removeChild(dom);
|
|
}
|
|
if(node) {
|
|
node.appendChild(dom);
|
|
}
|
|
}
|
|
|
|
dom() {
|
|
return this.renderer.svg();
|
|
}
|
|
}
|
|
|
|
function convert(element, code = null, options = {}) {
|
|
if(element.tagName === 'svg') {
|
|
return null;
|
|
}
|
|
|
|
if(code === null) {
|
|
code = element.innerText;
|
|
} else if(typeof code === 'object') {
|
|
options = code;
|
|
code = options.code;
|
|
}
|
|
const diagram = new SequenceDiagram(code, options);
|
|
const newElement = diagram.dom();
|
|
element.parentNode.insertBefore(newElement, element);
|
|
element.parentNode.removeChild(element);
|
|
const attrs = element.attributes;
|
|
for(let i = 0; i < attrs.length; ++ i) {
|
|
newElement.setAttribute(
|
|
attrs[i].nodeName,
|
|
attrs[i].nodeValue
|
|
);
|
|
}
|
|
return diagram;
|
|
}
|
|
|
|
function convertAll(root = null, className = 'sequence-diagram') {
|
|
if(typeof root === 'string') {
|
|
className = root;
|
|
root = null;
|
|
}
|
|
let elements = null;
|
|
if(root && root.length !== undefined) {
|
|
elements = root;
|
|
} else {
|
|
elements = (root || document).getElementsByClassName(className);
|
|
}
|
|
// Convert from "live" collection to static to avoid infinite loops:
|
|
const els = [];
|
|
for(let i = 0; i < elements.length; ++ i) {
|
|
els.push(elements[i]);
|
|
}
|
|
// Convert elements
|
|
els.forEach((el) => convert(el));
|
|
}
|
|
|
|
return Object.assign(SequenceDiagram, {
|
|
Parser,
|
|
Generator,
|
|
Renderer,
|
|
Exporter,
|
|
BaseTheme,
|
|
themes,
|
|
addTheme,
|
|
registerCodeMirrorMode,
|
|
convert,
|
|
convertAll,
|
|
});
|
|
});
|
|
|
|
requirejs(['sequence/SequenceDiagram'], (SequenceDiagram) => {
|
|
'use strict';
|
|
|
|
const def = window.define;
|
|
if(def && def.amd) {
|
|
def(() => {
|
|
return SequenceDiagram;
|
|
});
|
|
return;
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
SequenceDiagram.convertAll();
|
|
}, {once: true});
|
|
|
|
if(window.CodeMirror) {
|
|
SequenceDiagram.registerCodeMirrorMode(window.CodeMirror);
|
|
}
|
|
|
|
window.SequenceDiagram = SequenceDiagram;
|
|
}, null, true);
|
|
|
|
define("standalone", function(){});
|
|
|
|
}()); |