Other
CallCommand
Call
Command
<Vars, Params, Return, Yield>: { goto
?: string; key
: string; script
: ScriptLibrary<unknown, unknown, Params, Return, Yield>; setVars
?: CallReturnSetter<Vars, Return>; type
: "call"; withParams
?: CallParamsGetter<Vars, Params> }Type parameters
CallParamsFn
Call
Params
Fn
<Vars, Params>: (circs
: ScriptCircs<Vars>) => Params | Promise<Params>Type parameters
Type declaration
Parameters
Returns Params | Promise<Params>
CallParamsGetter
Type parameters
CallReturnSetFn
Call
Return
Set
Fn
<Vars, Return>: (circs
: ScriptCircs<Vars>, returnValue
: Return) => Vars | Promise<Vars>Type parameters
Type declaration
- (circs: ScriptCircs<Vars>, returnValue: Return): Vars | Promise<Vars>
Parameters
Returns Vars | Promise<Vars>
CallReturnSetter
Type parameters
CallStatus
Call
Status
<Vars>: { script
: ScriptLibrary<Vars, unknown, unknown, unknown, unknown>; stopAt
: undefined | string; vars
: Vars }Type parameters
Type declaration
script: ScriptLibrary<Vars, unknown, unknown, unknown, unknown>
stopAt: undefined | string
vars: Vars
ConditionMatchFn
Condition
Match
Fn
<Vars>: (circs
: ScriptCircs<Vars>) => boolean | Promise<boolean>Type parameters
Type declaration
Parameters
Returns boolean | Promise<boolean>
ConditionMatcher
Type parameters
ConditionsSegment
Conditions
Segment
<Vars>: { branches
: { body
: ScriptSegment<Vars, unknown, unknown, unknown>[]; condition
: ConditionMatcher<Vars> }[]; fallbackBody
: null | ScriptSegment<Vars, unknown, unknown, unknown>[]; type
: "conditions" }Type parameters
ContentCommand
Content
Command
<Vars>: { getContent
: ContentNode<Vars>; type
: "content" }Type parameters
ContentNode
Type parameters
EffectCommand
Type parameters
EffectSetFn
Effect
Set
Fn
<Vars>: (circs
: ScriptCircs<Vars>) => Vars | Promise<Vars>Type parameters
Type declaration
Parameters
Returns Vars | Promise<Vars>
EffectSetter
Type parameters
EffectYieldFn
Effect
Yield
Fn
<Vars, Yield>: (circs
: ScriptCircs<Vars>, prevValue
: undefined | Yield) => Yield | Promise<Yield>Type parameters
Type declaration
- (circs: ScriptCircs<Vars>, prevValue: undefined | Yield): Yield | Promise<Yield>
Parameters
prevValue: undefined | Yield
Returns Yield | Promise<Yield>
EffectYielder
Type parameters
InputOfScript
Input
Of
Script
<Script>: Script extends ScriptLibrary<unknown, infer Input
, unknown, unknown, unknown> ? Input : neverType parameters
JumpCommand
JumpCommand: { offset: number; type: "jump" }
Type declaration
offset: number
type: "jump"
JumpCondCommand
Jump
Cond
Command
<Vars>: { condition
: ConditionMatcher<Vars>; isNot
: boolean; offset
: number; type
: "jump_cond" }Type parameters
Type declaration
isNot: boolean
offset: number
type: "jump_cond"
LabelSegment
LabelSegment: { key: string; type: "label" }
ParamsOfScript
Params
Of
Script
<Script>: Script extends ScriptLibrary<unknown, unknown, infer Params
, unknown, unknown> ? Params : neverType parameters
PromptCommand
Prompt
Command
<Vars, Input>: { key
: string; setVars
?: PromptSetter<Vars, Input>; type
: "prompt" }Type parameters
Type declaration
key: string
Optional setVars?: PromptSetter<Vars, Input>
type: "prompt"
PromptSetFn
Prompt
Set
Fn
<Vars, Input>: (circs
: ScriptCircs<Vars>, input
: Input) => Vars | Promise<Vars>Type parameters
Type declaration
- (circs: ScriptCircs<Vars>, input: Input): Vars | Promise<Vars>
Parameters
Returns Vars | Promise<Vars>
PromptSetter
Type parameters
ReturnCommand
Return
Command
<Vars, Return>: { getValue
?: ReturnValueGetter<Vars, Return>; type
: "return" }Type parameters
ReturnOfScript
Return
Of
Script
<Script>: Script extends ScriptLibrary<unknown, unknown, unknown, infer Return
, unknown> ? Return : neverType parameters
ReturnValueFn
Return
Value
Fn
<Vars, Return>: (circs
: ScriptCircs<Vars>) => Return | Promise<Return>Type parameters
Type declaration
Parameters
Returns Return | Promise<Return>
ReturnValueGetter
Type parameters
ScriptCircs
Script
Circs
<Vars>: { channel
: SociablyChannel; platform
: string; vars
: Vars }Type parameters
Type declaration
platform: string
vars: Vars
ScriptCommand
Type parameters
ScriptElement
Script
Element
<Vars, Input, Return, Yield>: IfElement<Vars, Input, Return, Yield> | WhileElement<Vars, Input, Return, Yield> | PromptElement<Vars, Input> | LabelElement | CallElement<Vars, AnyScriptLibrary> | ReturnElement<Vars, Return>Type parameters
ScriptLibrary
Script
Library
<Vars, Input, Params, Return, Yield>: { $$typeof
: typeof SOCIABLY_SCRIPT_TYPE; Start
: ContainerComponent<StartScriptProps<Params>>; commands
: ScriptCommand<Vars, Input, Return, Yield>[]; name
: string; stopPointIndex
: Map<string, number>; initVars
: any }Type parameters
Vars
Input
Params
Return
Yield
Type declaration
$$typeof: typeof SOCIABLY_SCRIPT_TYPE
commands: ScriptCommand<Vars, Input, Return, Yield>[]
name: string
stopPointIndex: Map<string, number>
initVars:function
- initVars(params: Params): Vars
ScriptNode
Script
Node
<Vars, Input, Return, Yield>: SociablyEmpty | ContentNode<Vars> | ScriptElement<Vars, Input, Return, Yield> | ScriptNode<Vars, Input, Return, Yield>[] | SociablyElement<{ children
: ScriptNode<Vars, Input, Return, Yield> }, typeof Fragment>Type parameters
ScriptProcessState
Type declaration
timestamp: number
version: "0"
ScriptSegment
Type parameters
SerializedCallStatus
SerializedCallStatus<Vars>: { name: string; stopAt: string; vars: Vars }
Type parameters
Type declaration
name: string
stopAt: string
vars: Vars
VarsOfScript
Vars
Of
Script
<Script>: Script extends ScriptLibrary<infer Vars
, unknown, unknown, unknown, unknown> ? Vars : neverType parameters
WhileSegment
Type parameters
Type declaration
body: ScriptSegment<Vars, unknown, unknown, unknown>[]
type: "while"
YieldOfScript
Yield
Of
Script
<Script>: Script extends ScriptLibrary<unknown, unknown, unknown, unknown, infer Yield
> ? Yield : neverType parameters
Const build
- build<Vars, Input, Params, Return, Yield>(options: ScriptBuildOtions<Params, Vars>, src: SociablyElement<unknown, unknown>): ScriptLibrary<Vars, Input, Params, Return, Yield>
Type parameters
Vars: {}
Params = {}
Return = void
Yield = void
Parameters
options: ScriptBuildOtions<Params, Vars>
Returns ScriptLibrary<Vars, Input, Params, Return, Yield>
Script Module
Control conversation flow with programming language styled script.
Install
Docs
Check the Dialog Script document and the package reference.
Setup
Register the built script like this: