Comparing version 0.15.0 to 0.15.1
@@ -30,2 +30,4 @@ 'use strict'; | ||
var _processor2 = _interopRequireDefault(_processor); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -48,3 +50,3 @@ | ||
if ((0, _utils.isItAnElement)(element)) { | ||
(0, _processor.createProcessor)(function (error, result) { | ||
new _processor2.default(function (error, result) { | ||
return error ? reject(error) : done(result); | ||
@@ -51,0 +53,0 @@ }).add(element, (0, _createRootElement2.default)(context)); |
@@ -9,4 +9,2 @@ 'use strict'; | ||
exports.createProcessor = createProcessor; | ||
var _utils = require('../utils'); | ||
@@ -34,5 +32,5 @@ | ||
var _processChildren = require('./processChildren'); | ||
var _attemptToProcessChildren = require('./attemptToProcessChildren'); | ||
var _processChildren2 = _interopRequireDefault(_processChildren); | ||
var _attemptToProcessChildren2 = _interopRequireDefault(_attemptToProcessChildren); | ||
@@ -88,3 +86,3 @@ var _defineChildrenProp = require('./defineChildrenProp'); | ||
key: 'elementProcessed', | ||
value: function elementProcessed(task, executionContext) { | ||
value: function elementProcessed(task) { | ||
var id = task.id; | ||
@@ -102,3 +100,3 @@ | ||
if (task.done) { | ||
task.done(executionContext.result); | ||
task.done(task.result); | ||
} | ||
@@ -108,40 +106,11 @@ | ||
if (Object.keys(this.queue).length === 0) { | ||
this.exit(null, executionContext.result); | ||
this.exit(null, task.result); | ||
} | ||
} | ||
}, { | ||
key: 'createTask', | ||
value: function createTask(element, parent, done) { | ||
return { element: element, parent: parent, id: this.ids++, done: done }; | ||
} | ||
}, { | ||
key: 'processElement', | ||
value: function processElement(task) { | ||
key: 'createProcessorErrorHandler', | ||
value: function createProcessorErrorHandler(element) { | ||
var _this = this; | ||
this.queue[task.id] = task; | ||
var element = task.element, | ||
parent = task.parent; | ||
var executionContext = { | ||
element: element.initialize(parent), | ||
result: undefined, | ||
processor: this | ||
}; | ||
this.debug('->', element); | ||
(0, _utils.flow)([_beforeHook2.default, _normalizeProps2.default, _defineChildrenProp2.default, _execute2.default, _resolveExports2.default, function atemptToProcessChildren(execContext, done, addNewWorker) { | ||
if (!execContext.childrenProp) { | ||
addNewWorker(_processChildren2.default); | ||
} | ||
done(); | ||
}, _afterHook2.default], executionContext, function (error) { | ||
if (error) { | ||
_this.exit(error); | ||
} else { | ||
_this.elementProcessed(task, executionContext); | ||
} | ||
}, function (error, continueFlow, stopFlow) { | ||
return function (error, continueFlow, stopFlow) { | ||
_this.debug('!', element, error.message); | ||
@@ -156,3 +125,3 @@ | ||
} | ||
}); | ||
}; | ||
} | ||
@@ -162,3 +131,20 @@ }, { | ||
value: function add(element, parent, done) { | ||
this.processElement(this.createTask(element, parent, done)); | ||
var _this2 = this; | ||
var task = { | ||
id: this.ids++, | ||
element: element.initialize(parent), | ||
parent: parent, | ||
done: done, | ||
result: undefined, | ||
processor: this | ||
}; | ||
var onProcessingFinished = function onProcessingFinished(error) { | ||
return error ? _this2.exit(error) : _this2.elementProcessed(task, task); | ||
}; | ||
this.queue[task.id] = task; | ||
this.debug('->', element); | ||
(0, _utils.flow)([_beforeHook2.default, _normalizeProps2.default, _defineChildrenProp2.default, _execute2.default, _resolveExports2.default, _attemptToProcessChildren2.default, _afterHook2.default], task, onProcessingFinished, this.createProcessorErrorHandler(element)); | ||
} | ||
@@ -170,4 +156,2 @@ }]); | ||
function createProcessor(done) { | ||
return new Processor(done); | ||
} | ||
exports.default = Processor; |
{ | ||
"name": "actml", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"description": "Like jsx but for your business logic", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
411968
29
708