Skip to content

Commit

Permalink
Merge pull request #171 from cerebral/fixes6
Browse files Browse the repository at this point in the history
Fixes6
  • Loading branch information
christianalfoni authored Dec 22, 2018
2 parents c96e3de + 4c933e4 commit ca48e27
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 21 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"electron-json-storage": "4.1.0",
"express": "4.16.3",
"install": "0.12.1",
"is-plain-object": "2.0.4",
"is-plain-obj": "1.1.0",
"marksy": "6.1.0",
"npm": "6.3.0",
"page": "1.8.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/node_modules/overmind-devtools/src/app/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const state: State = {
newPortValue: '',
currentTab: Tab.State,
expandedStatePaths: [''],
expandAllActionDetails: false,
expandAllActionDetails: true,
expandedComponents: [],
currentApp: (state) => state.apps[state.currentAppName],
componentsMounted: (state) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const ActionOperator: SFC<Props> = ({
const { state, actions } = useOvermind()
const isExpanded = state.expandAllActionDetails || !operator.isCollapsed

console.log(operator.mutations)
return (
<div>
{value === undefined ? null : (
Expand Down
2 changes: 1 addition & 1 deletion packages/node_modules/overmind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"@types/node": "^10.5.1",
"is-plain-object": "^2.0.4",
"is-plain-obj": "^1.1.0",
"betsy": "next",
"proxy-state-tree": "next",
"tslib": "^1.9.3"
Expand Down
5 changes: 2 additions & 3 deletions packages/node_modules/overmind/src/Devtools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IS_PROXY } from 'proxy-state-tree'
// Needed due to Parcel + Webpack support
const isPlainObject = require('is-plain-object')
import * as isPlainObject from 'is-plain-obj'

export type Message = {
type: string
Expand All @@ -22,7 +21,7 @@ export function safeValue(value) {
aggr[key] = safeValue(value[key])

return aggr
}, value)
}, {})
: value
}

Expand Down
21 changes: 14 additions & 7 deletions packages/node_modules/overmind/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EventEmitter } from 'betsy'
import { IS_PROXY, ProxyStateTree, TTree } from 'proxy-state-tree'
import * as isPlainObject from 'is-plain-obj'
import { IS_PROXY, ProxyStateTree, TTree, IMutation } from 'proxy-state-tree'
import { Derived } from './derived'
import { Devtools, Message, safeValue } from './Devtools'
import { Devtools, Message, safeValue, safeValues } from './Devtools'
import {
Events,
EventType,
Expand Down Expand Up @@ -41,13 +42,16 @@ export type Derive<Parent extends TStateObject, Value> = TDerive<

export type OnInitialize = TOnInitialize<TheConfig>

const isPlainObject = require('is-plain-object')
const IS_PRODUCTION = process.env.NODE_ENV === 'production'
const IS_DEVELOPMENT = process.env.NODE_ENV === 'development'
const IS_OPERATOR = Symbol('operator')

export const log = (...objects: any[]) =>
console.log(...objects.map((obj) => JSON.parse(JSON.stringify(obj))))
export const makeStringifySafeMutations = (mutations: IMutation[]) => {
return mutations.map((mutation) => ({
...mutation,
args: safeValues(mutation.args),
}))
}

const hotReloadingCache = {}

Expand Down Expand Up @@ -123,6 +127,7 @@ export class Overmind<Config extends Configuration> implements Configuration {
data: {
...data,
...flushData,
mutations: makeStringifySafeMutations(flushData.mutations),
},
})
}
Expand All @@ -135,6 +140,7 @@ export class Overmind<Config extends Configuration> implements Configuration {
data: {
...data,
...flushData,
mutations: makeStringifySafeMutations(flushData.mutations),
},
})
}
Expand Down Expand Up @@ -247,7 +253,7 @@ export class Overmind<Config extends Configuration> implements Configuration {
mutationTree.onMutation((mutation) => {
this.eventHub.emit(EventType.MUTATIONS, {
...execution,
mutations: [mutation],
mutations: makeStringifySafeMutations([mutation]),
})
setTimeout(() => {
const flushData = this.proxyStateTree.flush(true)
Expand All @@ -257,6 +263,7 @@ export class Overmind<Config extends Configuration> implements Configuration {
data: {
...execution,
...flushData,
mutations: makeStringifySafeMutations(flushData.mutations),
},
})
}
Expand Down Expand Up @@ -749,7 +756,7 @@ export function mutate<Input, Config extends Configuration = TheConfig>(
context.execution.emit(EventType.MUTATIONS, {
...context.execution,
operatorId: context.execution.operatorId + 1,
mutations: [mutation],
mutations: makeStringifySafeMutations([mutation]),
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/node_modules/proxy-state-tree/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IS_PROXY, VALUE, PATH, Proxifier } from './Proxyfier'
import * as isPlainObject from 'is-plain-obj'
import {
IMutation,
ITrackMutationTree,
Expand All @@ -13,7 +14,6 @@ import {
} from './types'
import { TrackMutationTree } from './TrackMutationTree'
import { TrackStateTree } from './TrackStateTree'
const isPlainObject = require('is-plain-object')
const IS_PRODUCTION = process.env.NODE_ENV === 'production'

export {
Expand Down
2 changes: 1 addition & 1 deletion packages/overmind-website/src/app/onInitialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const onInitialize: OnInitialize = ({
css,
}) => {
state.typescript = storage.get('typescript') || false
state.theme = storage.get('theme') || 'components'
state.theme = storage.get('theme') || 'react'
css.changePrimary(state.theme)

router.route('/', app.actions.openHome)
Expand Down
3 changes: 0 additions & 3 deletions packages/overmind-website/src/app/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Demo,
SearchResult,
} from './types'
import { Derive } from 'overmind'

type State = {
page: Page
Expand All @@ -25,7 +24,6 @@ type State = {
isLoadingSearchResult: boolean
searchResult: SearchResult[]
showSearchResult: boolean
test: string
}

const state: State = {
Expand All @@ -44,7 +42,6 @@ const state: State = {
isLoadingSearchResult: false,
searchResult: [],
showSearchResult: false,
test: '',
}

export default state

0 comments on commit ca48e27

Please sign in to comment.