Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-lippert committed Oct 30, 2023
1 parent 6341cc1 commit baa365e
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 114 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"format": "prettier --write '**/*.{js,css,json,md}'"
},
"dependencies": {
"xstate": "^4.38.2"
"xstate": "^4.38.3"
},
"devDependencies": {
"ava": "^5.3.1",
"eslint": "^8.50.0",
"eslint": "^8.52.0",
"prettier": "^3.0.3",
"wrangler": "^3.10.1"
"wrangler": "^3.15.0"
}
}
19 changes: 6 additions & 13 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export class State {
this.state = state
this.env = env
state.blockConcurrencyWhile(async () => {
;[this.machineDefinition, this.machineState] = await Promise.all([
this.state.storage.get('machineDefinition'),
this.state.storage.get('machineState'),
])
;[this.machineDefinition, this.machineState] = await Promise.all([this.state.storage.get('machineDefinition'), this.state.storage.get('machineState')])
if (this.machineDefinition) {
this.startMachine(this.machineState)
}
Expand Down Expand Up @@ -113,29 +110,25 @@ export class State {
},
instance,
}
const stateMap = () => {
retval.state = this.machineState
if (this.serviceState?.nextEvents && this.serviceState.nextEvents.length)
retval.events = this.serviceState.nextEvents.map((e) => `${origin}/${instance}/${encodeURIComponent(e)}`)
}
if (search === '?reset') {
await this.reset()
stateMap()
} else if (search.startsWith('?import=')) {
const machine = await fetch(decodeURIComponent(search.substring('?import='.length))).then((res) => res.json())
await this.update(machine)
stateMap()
} else if (search === '?machine') {
if (this.machineDefinition) retval.machine = this.machineDefinition
retval.user = user
return new Response(JSON.stringify(retval, null, 2), { headers: { 'content-type': 'application/json; charset=utf-8' } })
} else if ((search && (!this.machineDefinition || isSearchBasedUpdate)) || (method === 'POST' && !Array.isArray(json))) {
await this.update((search && JSON.parse(decodeURIComponent(search.substring(isSearchBasedUpdate ? update.length : 1)))) || json)
stateMap()
} else {
if (json) console.log(json)
if (stateEvent) this.service?.send(stateEvent, json)
else if (json) this.service?.send(json)
stateMap()
}
retval.state = this.machineState
if (this.serviceState?.nextEvents && this.serviceState.nextEvents.length)
retval.events = this.serviceState.nextEvents.map((e) => `${origin}/${instance}/${encodeURIComponent(e)}`)
retval.user = user
return new Response(JSON.stringify(retval, null, 2), { headers: { 'content-type': 'application/json; charset=utf-8' } })
}
Expand Down
Loading

0 comments on commit baa365e

Please sign in to comment.