diff --git a/index.js b/index.js index b8e5646..4abc6f3 100644 --- a/index.js +++ b/index.js @@ -9,12 +9,10 @@ module.exports = function Devtools () { if (typeof window.chrome === 'undefined') { return function () {} } return function init (module, controller) { - if (controller.addContextProvider) { - controller.addContextProvider(require('./providers/actionServicesCallsProvider')) - controller.addContextProvider(require('./providers/actionOutputProvider')) - controller.addContextProvider(require('./providers/actionInputProvider')) - controller.addContextProvider(require('./providers/signalOptionsProvider')) - } + controller.addContextProvider(require('./providers/actionServicesCallsProvider')) + controller.addContextProvider(require('./providers/actionOutputProvider')) + controller.addContextProvider(require('./providers/actionInputProvider')) + controller.addContextProvider(require('./providers/signalOptionsProvider')) module.addModules({ store: SignalStore() @@ -33,9 +31,8 @@ module.exports = function Devtools () { var isInitialized = false var hasInitialPayload = false var disableDebugger = false - var willKeepState = false var APP_ID = String(Date.now()) - var VERSION = 'v3' + var VERSION = 'v4' var isAwaitingFrame = false var nextSignalInLine = 0 @@ -116,7 +113,6 @@ module.exports = function Devtools () { return { initialModel: controller.get(), signals: signals, - willKeepState: willKeepState, disableDebugger: disableDebugger, isExecutingAsync: signalStore.isExecutingAsync() } @@ -145,62 +141,37 @@ module.exports = function Devtools () { var updateSettings = function () { update('settings', { - willKeepState: willKeepState, disableDebugger: disableDebugger }, true) } + window.addEventListener('cerebral.dev.components', function (event) { + update('components', event.detail, true) + }) + window.addEventListener('cerebral.dev.debuggerPing', function () { var signals = [] if (utils.hasLocalStorage()) { disableDebugger = JSON.parse(localStorage.getItem('cerebral_disable_debugger')) - signals = JSON.parse(localStorage.getItem('cerebral_signals')) || [] - willKeepState = JSON.parse(localStorage.getItem('cerebral_willKeepState')) } - // Might be an async signal running here - if (willKeepState && signalStore.isExecutingAsync()) { - controller.once('signalEnd', function () { - signalStore.setSignals(signals) - signalStore.remember(signalStore.getSignals().length - 1) - isInitialized = true - var event = new CustomEvent('cerebral.dev.cerebralPong', { - detail: JSON.stringify({ - type: 'init', - app: APP_ID, - version: VERSION, - data: getInit() - }) - }) - window.dispatchEvent(event) + signalStore.setSignals(signals) + signalStore.rememberInitial(signalStore.getSignals().length - 1) + isInitialized = true + var event = new CustomEvent('cerebral.dev.cerebralPong', { + detail: JSON.stringify({ + type: 'init', + app: APP_ID, + version: VERSION, + data: getInit() }) - } else { - signalStore.setSignals(signals) - signalStore.rememberInitial(signalStore.getSignals().length - 1) - isInitialized = true - var event = new CustomEvent('cerebral.dev.cerebralPong', { - detail: JSON.stringify({ - type: 'init', - app: APP_ID, - version: VERSION, - data: getInit() - }) - }) - window.dispatchEvent(event) - } - }) - - window.addEventListener('cerebral.dev.toggleKeepState', function () { - willKeepState = !willKeepState - updateSettings() + }) + window.dispatchEvent(event) }) window.addEventListener('cerebral.dev.toggleDisableDebugger', function () { disableDebugger = !disableDebugger - if (disableDebugger && willKeepState) { - willKeepState = !willKeepState - } updateSettings() }) @@ -239,8 +210,6 @@ module.exports = function Devtools () { signalStore.removeRunningSignals() if (utils.hasLocalStorage()) { - localStorage.setItem('cerebral_signals', isInitialized && willKeepState ? JSON.stringify(signalStore.getSignals()) : JSON.stringify([])) - localStorage.setItem('cerebral_willKeepState', isInitialized && JSON.stringify(willKeepState)) localStorage.setItem('cerebral_disable_debugger', isInitialized && JSON.stringify(disableDebugger)) } }) diff --git a/package.json b/package.json index 64d1201..0ea44ba 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "name": "cerebral-module-devtools", - "version": "0.0.0-semantically-released", + "version": "0.0.0-semantically-released", "description": "Module to enable Google Chrome debugger extension for Cerebral application", "main": "index.js", "scripts": { "pretest": "standard", - "test": "nodeunit tests && npm i cerebral@0.34.0-rc.4 && nodeunit tests", - "posttest": "npm i", + "test": "nodeunit tests", "coverage": "nyc --reporter=lcov --reporter=text npm test", "postcoverage": "cat ./coverage/lcov.info | coveralls", "semantic-release": "semantic-release pre && npm publish && semantic-release post" @@ -25,23 +24,24 @@ }, "homepage": "https://github.com/cerebral/cerebral-module-devtools#readme", "devDependencies": { - "cerebral": "^0.33.33", + "cerebral": "^0.35.0-0", "commitizen": "^2.5.0", "conventional-changelog": "0.0.17", "coveralls": "^2.11.6", "cz-customizable": "^2.7.0", "ghooks": "^1.0.3", - "nodeunit": "^0.9.1", "nyc": "^6.4.0", + "nodeunit": "^0.9.1", + "nyc": "^7.0.0", "semantic-release": "^4.3.5", - "standard": "^5.4.1", - "validate-commit-msg": "^1.1.1" + "standard": "^7.1.2", + "validate-commit-msg": "^2.6.1" }, "peerDependencies": { - "cerebral": "^0.33.8 || ^0.34.0-rc.4" + "cerebral": "^0.35.0-0" }, "dependencies": { - "cerebral-module-signal-store": "^0.1.8" + "cerebral-module-signal-store": "^0.2.0-0" }, "config": { "commitizen": { diff --git a/tests/index.js b/tests/index.js index 1fa08da..5f12e16 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,4 +1,4 @@ -var Controller = require('cerebral') +var Controller = require('cerebral').Controller var Devtools = require('../') var suite = {} var async = function (cb) {