Skip to content

Commit

Permalink
feat: support only cerebral@^0.35.0-0
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Dropped support for previous cerebral versions
  • Loading branch information
christianalfoni authored and Guria committed Jul 13, 2016
1 parent a9f1619 commit add6ca8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 61 deletions.
71 changes: 20 additions & 51 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand Down Expand Up @@ -116,7 +113,6 @@ module.exports = function Devtools () {
return {
initialModel: controller.get(),
signals: signals,
willKeepState: willKeepState,
disableDebugger: disableDebugger,
isExecutingAsync: signalStore.isExecutingAsync()
}
Expand Down Expand Up @@ -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()
})

Expand Down Expand Up @@ -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))
}
})
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 [email protected] && 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"
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Controller = require('cerebral')
var Controller = require('cerebral').Controller
var Devtools = require('../')
var suite = {}
var async = function (cb) {
Expand Down

0 comments on commit add6ca8

Please sign in to comment.