scion-core
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -54,4 +54,2 @@ // Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors | ||
var eventProcessorTypes = Object.keys(ioProcessorTypes).map(function(k){return ioProcessorTypes[k].location}); | ||
function initializeModel(rootState){ | ||
@@ -1124,3 +1122,3 @@ var transitions = [], idToStateMap = {}, documentOrder = 0; | ||
function InterpreterScriptingContext(interpreter){ | ||
function InterpreterScriptingContext(interpreter) { | ||
this._interpreter = interpreter; | ||
@@ -1130,2 +1128,7 @@ this._timeoutMap = {}; | ||
//Regex from: | ||
// http://daringfireball.net/2010/07/improved_regex_for_matching_urls | ||
// http://stackoverflow.com/a/6927878 | ||
var validateUriRegex = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i; | ||
//TODO: consider whether this is the API we would like to expose | ||
@@ -1137,19 +1140,42 @@ InterpreterScriptingContext.prototype = { | ||
send : function(event, options){ | ||
if(eventProcessorTypes.indexOf(event.type) === -1) { | ||
this.raise({ name : "error.execution", data: 'Unsupported event processor type', sendid: options.sendid }); | ||
//TODO: move these out | ||
function validateSend(event, options, sendAction){ | ||
if(event.target){ | ||
var targetIsValidUri = validateUriRegex.test(event.target) | ||
if(!targetIsValidUri){ | ||
return this.raise({ name : "error.execution", data: 'Target is not valid URI', sendid: options.sendid }); | ||
} | ||
} | ||
var eventProcessorTypes = Object.keys(ioProcessorTypes).map(function(k){return ioProcessorTypes[k].location}); | ||
if(eventProcessorTypes.indexOf(event.type) === -1) { | ||
return this.raise({ name : "error.execution", data: 'Unsupported event processor type', sendid: options.sendid }); | ||
} | ||
sendAction.call(this, event, options); | ||
} | ||
if(options.delay === undefined){ | ||
this.gen(event); | ||
}else{ | ||
if( typeof setTimeout === 'undefined' ) throw new Error('Default implementation of Statechart.prototype.send will not work unless setTimeout is defined globally.'); | ||
function defaultSendAction (event, options) { | ||
if (printTrace) this._interpreter.opts.console.log("sending event", event.name, "with content", event.data, "after delay", options.delay); | ||
if( typeof setTimeout === 'undefined' ) throw new Error('Default implementation of Statechart.prototype.send will not work unless setTimeout is defined globally.'); | ||
var timeoutId = setTimeout(this._interpreter.gen.bind(this._interpreter,event), options.delay || 0); | ||
var timeoutId = setTimeout(this._interpreter.gen.bind(this._interpreter, event), options.delay || 0); | ||
if (options.sendid) this._timeoutMap[options.sendid] = timeoutId; | ||
if (options.sendid) this._timeoutMap[options.sendid] = timeoutId; | ||
} | ||
event.type = event.type || ioProcessorTypes.scxml.location; | ||
var sendFn = this._interpreter.opts.customSend || defaultSendAction; | ||
options=options || {}; | ||
if (printTrace) this._interpreter.opts.console.log("sending event", event.name, "with content", event.data, "after delay", options.delay); | ||
validateSend.call(this, event, options, sendFn); | ||
}, | ||
cancel : function(sendid){ | ||
if(this._interpreter.opts.customCancel) { | ||
return this._interpreter.opts.customCancel.apply(this, [sendid]); | ||
} | ||
@@ -1163,3 +1189,2 @@ if( typeof clearTimeout === 'undefined' ) throw new Error('Default implementation of Statechart.prototype.cancel will not work unless setTimeout is defined globally.'); | ||
} | ||
}; | ||
@@ -1179,4 +1204,6 @@ | ||
/** @expose */ | ||
InterpreterScriptingContext : InterpreterScriptingContext | ||
InterpreterScriptingContext : InterpreterScriptingContext, | ||
/** @expose */ | ||
ioProcessorTypes : ioProcessorTypes | ||
}; | ||
})); |
{ | ||
"name": "scion-core", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "StateCharts Interpretation and Optimization eNgine (SCION) CORE is an implementation of Statecharts in JavaScript.", | ||
@@ -28,8 +28,6 @@ "keywords": [ | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/jbeard4/SCION-ng.git" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jbeard4/SCION-ng.git" | ||
}, | ||
"devDependencies": { | ||
@@ -36,0 +34,0 @@ "async": "0.2.5", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
769233
21494
8
1