@statelyai/sky-react
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,8 +0,5 @@ | ||
import { SkyConfigFile } from '@statelyai/sky'; | ||
import { SkyConfigFile, actorFromStately } from '@statelyai/sky'; | ||
import { Actor, AnyStateMachine } from 'xstate'; | ||
export declare function useStatelyActor<T extends AnyStateMachine>({ apiKey, url, sessionId, runOnSky, }: { | ||
apiKey?: string; | ||
url: string; | ||
sessionId: string; | ||
runOnSky?: boolean; | ||
}, skyConfig?: SkyConfigFile<T>): readonly [import("xstate").SnapshotFrom<T>, ((event: import("xstate").EventFromLogic<T>) => void) | undefined, Actor<T> | undefined]; | ||
export declare function useStatelyActor<T extends AnyStateMachine>(options: Parameters<typeof actorFromStately>[0], skyConfig?: SkyConfigFile<T>): readonly [import("xstate").SnapshotFrom<T>, ((event: import("xstate").EventFromLogic<T>) => void) | undefined, Actor<T> | undefined, { | ||
isConnecting: boolean; | ||
}]; |
@@ -10,10 +10,5 @@ 'use strict'; | ||
function useStatelyActor({ | ||
apiKey, | ||
url, | ||
sessionId, | ||
runOnSky = true | ||
}, skyConfig) { | ||
function useStatelyActor(options, skyConfig) { | ||
if (!skyConfig) { | ||
throw new Error(`You need to run xstate sky "src/**/*.ts?(x)" before you can use the Stately Sky actor with url ${url}`); | ||
throw new Error(`You need to run xstate sky "src/**/*.ts?(x)" before you can use the Stately Sky actor with url ${options.url}`); | ||
} | ||
@@ -23,8 +18,3 @@ const [maybeActor, setMaybeActor] = react.useState(); | ||
react.useEffect(() => { | ||
const subscription = xstate.createActor(xstate.fromPromise(() => sky.actorFromStately({ | ||
url, | ||
apiKey, | ||
sessionId, | ||
runOnSky | ||
}, skyConfig))).start().subscribe(s => { | ||
const subscription = xstate.createActor(xstate.fromPromise(() => sky.actorFromStately(options, skyConfig))).start().subscribe(s => { | ||
s.output?.start(); | ||
@@ -34,6 +24,11 @@ return setMaybeActor(s.output); | ||
return () => subscription.unsubscribe(); | ||
}, [apiKey, runOnSky, sessionId, skyConfig, url]); | ||
return [state, maybeActor?.send, maybeActor]; | ||
}, [options.url, options.sessionId, skyConfig]); | ||
const send = maybeActor?.send; | ||
const isConnecting = send === undefined; | ||
const sky$1 = { | ||
isConnecting | ||
}; | ||
return [state, send, maybeActor, sky$1]; | ||
} | ||
exports.useStatelyActor = useStatelyActor; |
@@ -6,10 +6,5 @@ import { actorFromStately } from '@statelyai/sky'; | ||
function useStatelyActor({ | ||
apiKey, | ||
url, | ||
sessionId, | ||
runOnSky = true | ||
}, skyConfig) { | ||
function useStatelyActor(options, skyConfig) { | ||
if (!skyConfig) { | ||
throw new Error(`You need to run xstate sky "src/**/*.ts?(x)" before you can use the Stately Sky actor with url ${url}`); | ||
throw new Error(`You need to run xstate sky "src/**/*.ts?(x)" before you can use the Stately Sky actor with url ${options.url}`); | ||
} | ||
@@ -19,8 +14,3 @@ const [maybeActor, setMaybeActor] = useState(); | ||
useEffect(() => { | ||
const subscription = createActor(fromPromise(() => actorFromStately({ | ||
url, | ||
apiKey, | ||
sessionId, | ||
runOnSky | ||
}, skyConfig))).start().subscribe(s => { | ||
const subscription = createActor(fromPromise(() => actorFromStately(options, skyConfig))).start().subscribe(s => { | ||
s.output?.start(); | ||
@@ -30,6 +20,11 @@ return setMaybeActor(s.output); | ||
return () => subscription.unsubscribe(); | ||
}, [apiKey, runOnSky, sessionId, skyConfig, url]); | ||
return [state, maybeActor?.send, maybeActor]; | ||
}, [options.url, options.sessionId, skyConfig]); | ||
const send = maybeActor?.send; | ||
const isConnecting = send === undefined; | ||
const sky = { | ||
isConnecting | ||
}; | ||
return [state, send, maybeActor, sky]; | ||
} | ||
export { useStatelyActor }; |
{ | ||
"name": "@statelyai/sky-react", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -33,5 +33,5 @@ "main": "dist/statelyai-sky-react.cjs.js", | ||
"dependencies": { | ||
"@statelyai/sky": "0.0.4", | ||
"@statelyai/sky": "0.0.5", | ||
"@xstate/react": "4.0.0-beta.10", | ||
"xstate": "5.0.0-beta.33" | ||
"xstate": "5.0.0-beta.37" | ||
}, | ||
@@ -38,0 +38,0 @@ "devDependencies": { |
4377
64
+ Added@statelyai/sky@0.0.5(transitive)
+ Addedpartysocket@0.0.12(transitive)
+ Addedxstate@5.0.0-beta.37(transitive)
- Removed@statelyai/sky@0.0.4(transitive)
- Removedpartysocket@0.0.9(transitive)
- Removedxstate@5.0.0-beta.33(transitive)
Updated@statelyai/sky@0.0.5
Updatedxstate@5.0.0-beta.37