-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(providers): add devtools specific providers
- Loading branch information
1 parent
50b2d10
commit af6aacc
Showing
7 changed files
with
419 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function (context, execution) { | ||
execution.action.input = execution.payload | ||
return context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = function (context, execution) { | ||
var originalOutput = context.output | ||
var outputPaths = Object.keys(context.output) | ||
var output = function () { | ||
var path = typeof arguments[0] === 'string' ? arguments[0] : null | ||
var payload = path ? arguments[1] : arguments[0] | ||
execution.action.output = payload | ||
originalOutput.apply(null, arguments) | ||
} | ||
|
||
outputPaths.reduce(function (output, key) { | ||
output[key] = function () { | ||
execution.action.output = arguments[0] || {} | ||
originalOutput[key].apply(null, arguments) | ||
} | ||
return output | ||
}, output) | ||
|
||
context.output = output | ||
|
||
return context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var convertServices = function (action, path, modulesPaths, services) { | ||
return Object.keys(services).reduce(function (newservices, key) { | ||
path.push(key) | ||
if ( | ||
typeof services[key] === 'function' && | ||
services[key].constructor.name === 'Function' && | ||
!Object.keys(services[key]).length && | ||
(!services[key].prototype || !Object.keys(services[key].prototype).length) | ||
) { | ||
var servicePath = path.slice() | ||
var method = servicePath.pop() | ||
newservices[key] = function () { | ||
action.serviceCalls.push({ | ||
name: servicePath.join('.'), | ||
method: method, | ||
args: [].slice.call(arguments) | ||
}) | ||
return services[key].apply(this, arguments) | ||
} | ||
} else if ( | ||
typeof services[key] === 'object' && | ||
!Array.isArray(services[key]) && | ||
services[key] !== null && | ||
modulesPaths.indexOf(path.join('.')) >= 0 | ||
) { | ||
newservices[key] = convertServices(action, path, modulesPaths, services[key]) | ||
} else { | ||
newservices[key] = services[key] | ||
} | ||
path.pop(key) | ||
return newservices | ||
}, {}) | ||
} | ||
|
||
module.exports = function (context, execution, controller) { | ||
var action = execution.action | ||
var modules = controller.getModules() | ||
var services = controller.getServices() | ||
var path = [] | ||
action.serviceCalls = action.serviceCalls || [] | ||
context.services = convertServices(action, path, Object.keys(modules), services) | ||
|
||
return context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = function (context, execution) { | ||
execution.signal.isRecorded = execution.options.isRecorded | ||
execution.signal.isRouted = execution.options.isRouted | ||
return context | ||
} |
Oops, something went wrong.