Documentation ¶
Index ¶
- Constants
- type CompBaseOperationRegister
- type CompDecoder
- type CompEncoder
- type CompFrameworkSteper
- type CompNonBaseOperationRegister
- type CompNonStdOperationRegister
- type CompOperationRegister
- type CompStdOperationRegister
- type CompStdStructuredPtrCreator
- type Component
- type ComponentData
- type ComponentEvent
- type ComponentOperations
- type ComponentOptions
- type ComponentProps
- type ComponentProtocol
- type ComponentProtocolDebugOptions
- type ComponentProtocolParams
- type ComponentProtocolRequest
- type ComponentState
- type ContinueRender
- type Extra
- type ExtraMap
- type GlobalInnerCtxKey
- type GlobalStateData
- type Hierarchy
- type IComponent
- type IDefaultComponent
- type IOperation
- type IStdStructuredPtr
- type InParams
- type InvokeRenderWsEventPayload
- type LegacyOperation
- type OpClientData
- type OpServerData
- type Operation
- type OperationFunc
- type OperationKey
- type ProtocolOptions
- type RendingItem
- type RendingState
- type SDK
- type Scenario
- type UIRenderWsEventPayload
- type WebSocketEventType
Constants ¶
const ( // DefaultRenderingKey . DefaultRenderingKey = "__DefaultRendering__" // InParamsStateBindingKey . InParamsStateBindingKey = "__InParams__" )
DefaultRenderingKey .
const (
// DefaultComponentNamespace contains all common components.
DefaultComponentNamespace = "__DefaultComponentNamespace__"
)
DefaultComponentNamespace .
const (
// FieldImplForInject used to inject `Impl` field by framework.
FieldImplForInject = "Impl"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompBaseOperationRegister ¶
type CompBaseOperationRegister interface { RegisterInitializeOp() (opFunc OperationFunc) RegisterRenderingOp() (opFunc OperationFunc) }
CompBaseOperationRegister includes Initialize & Rendering Op.
type CompDecoder ¶
type CompDecoder interface { DecodeData(srcRawPtr ComponentData, dstStdStructPtr interface{}) DecodeState(srcRawPtr ComponentState, dstStdStructPtr interface{}) DecodeInParams(srcRawPtr InParams, dstStdStructPtr interface{}) }
CompDecoder is a protocol-level interface, convert raw-cp-result to structured-struct. decode raw-ptr to std-struct-ptr.
type CompEncoder ¶
type CompEncoder interface { EncodeData(srcStdStructPtr interface{}, dstRawPtr *ComponentData) EncodeState(srcStdStructPtr interface{}, dstRawPtr *ComponentState) EncodeInParams(srcStdStructPtr interface{}, dstRawPtr *InParams) }
CompEncoder is a protocol-level interface, convert structured-struct to raw-cp-result. encode std-struct-ptr to raw-ptr.
type CompFrameworkSteper ¶
type CompFrameworkSteper interface { Initialize(sdk *SDK) Finalize(sdk *SDK) SkipOp(sdk *SDK) bool Visible(sdk *SDK) bool BeforeHandleOp(sdk *SDK) AfterHandleOp(sdk *SDK) }
CompFrameworkSteper represents all component steps played in framework.
type CompNonBaseOperationRegister ¶
type CompNonBaseOperationRegister interface { CompStdOperationRegister CompNonStdOperationRegister }
CompNonBaseOperationRegister includes a component's all non-base operations.
type CompNonStdOperationRegister ¶
type CompNonStdOperationRegister interface {
RegisterCompNonStdOps() (opFuncs map[OperationKey]OperationFunc)
}
CompNonStdOperationRegister register a component's all non-standard operations to standard cptype.OperationFunc, and then used by framework.
type CompOperationRegister ¶
type CompOperationRegister interface { CompBaseOperationRegister CompNonBaseOperationRegister }
CompOperationRegister includes a component's all operations.
type CompStdOperationRegister ¶
type CompStdOperationRegister interface {
RegisterCompStdOps() (opFuncs map[OperationKey]OperationFunc)
}
CompStdOperationRegister register a component's all standard operations to standard cptype.OperationFunc, and then used by framework.
type CompStdStructuredPtrCreator ¶
type CompStdStructuredPtrCreator interface {
StdStructuredPtrCreator() func() IStdStructuredPtr
}
CompStdStructuredPtrCreator return creator of StdStructuredPtr.
type Component ¶
type Component struct { Version string `json:"version,omitempty" yaml:"version,omitempty"` // 组件类型 Type string `json:"type,omitempty" yaml:"type,omitempty"` // 组件名字 Name string `json:"name,omitempty" yaml:"name,omitempty"` // table 动态字段 Props ComponentProps `json:"props,omitempty" yaml:"props,omitempty"` // 组件业务数据 Data ComponentData `json:"data,omitempty" yaml:"data,omitempty"` // 前端组件状态 State ComponentState `json:"state,omitempty" yaml:"state,omitempty"` // 组件相关操作(前端定义) Operations ComponentOperations `json:"operations,omitempty" yaml:"operations,omitempty"` // Component Options Options *ComponentOptions `json:"options,omitempty" yaml:"options,omitempty"` }
Component defines a component.
type ComponentEvent ¶
type ComponentEvent struct { Component string `json:"component"` Operation OperationKey `json:"operation"` OperationData map[string]interface{} `json:"operationData"` }
ComponentEvent .
type ComponentOptions ¶
type ComponentOptions struct { Visible bool `json:"visible,omitempty" yaml:"visible,omitempty"` AsyncAtInit bool `json:"asyncAtInit,omitempty" yaml:"asyncAtInit,omitempty"` // enable continueRender if not nil ContinueRender *ContinueRender `json:"continueRender,omitempty" yaml:"continueRender,omitempty"` // extra related FlatExtra bool `json:"flatExtra,omitempty" yaml:"flatExtra,omitempty"` RemoveExtraAfterFlat bool `json:"removeExtraAfterFlat,omitempty" yaml:"removeExtraAfterFlat,omitempty"` // url query URLQuery string `json:"urlQuery,omitempty" yaml:"urlQuery,omitempty"` }
ComponentOptions .
type ComponentProtocol ¶
type ComponentProtocol struct { Version string `json:"version" yaml:"version"` Scenario string `json:"scenario" yaml:"scenario"` GlobalState *GlobalStateData `json:"state" yaml:"state"` Hierarchy Hierarchy `json:"hierarchy" yaml:"hierarchy"` Components map[string]*Component `json:"components" yaml:"components"` Rendering map[string][]RendingItem `json:"rendering" yaml:"rendering"` Options *ProtocolOptions `json:"options" yaml:"options"` }
ComponentProtocol is protocol definition.
type ComponentProtocolDebugOptions ¶
type ComponentProtocolDebugOptions struct {
ComponentKey string `json:"componentKey"`
}
ComponentProtocolDebugOptions .
type ComponentProtocolRequest ¶
type ComponentProtocolRequest struct { Scenario Scenario `json:"scenario"` Event ComponentEvent `json:"event"` InParams InParams `json:"inParams"` // 初次请求为空,事件出发后,把包含状态的protocol传到后端 Protocol *ComponentProtocol `json:"protocol"` // DebugOptions debug 选项 DebugOptions *ComponentProtocolDebugOptions `json:"debugOptions,omitempty"` }
ComponentProtocolRequest .
type ContinueRender ¶
type ContinueRender struct {
OpKey string `json:"opKey,omitempty"`
}
ContinueRender .
type Extra ¶
type Extra struct {
Extra ExtraMap `json:"extra,omitempty"`
}
Extra is a magic fields, and will be flat if specified in protocol.
type GlobalInnerCtxKey ¶
type GlobalInnerCtxKey string
GlobalInnerCtxKey .
const ( // GlobalInnerKeyCtxSDK . GlobalInnerKeyCtxSDK GlobalInnerCtxKey = "_sdk_" // GlobalInnerKeyUserIDs . GlobalInnerKeyUserIDs GlobalInnerCtxKey = "_userIDs_" // GlobalInnerKeyIdentity . GlobalInnerKeyIdentity GlobalInnerCtxKey = "_identity_" // GlobalInnerKeyError . GlobalInnerKeyError GlobalInnerCtxKey = "_error_" // GlobalInnerKeyStateTemp . GlobalInnerKeyStateTemp GlobalInnerCtxKey = "_state_temp_" )
GlobalInnerKeyCtxSDK .
type Hierarchy ¶
type Hierarchy struct { Version string `json:"version" yaml:"version"` Root string `json:"root" yaml:"root"` // structure的结构可能是list、map Structure map[string]interface{} `json:"structure" yaml:"structure"` // Parallel Parallel map[string][]string `json:"parallel,omitempty"` }
Hierarchy represents components' hierarchy.
type IComponent ¶
type IComponent interface { IDefaultComponent CompBaseOperationRegister }
IComponent combines IDefaultComponent and BaseOperationRegister.
type IDefaultComponent ¶
type IDefaultComponent interface { CompStdStructuredPtrCreator CompNonBaseOperationRegister CompFrameworkSteper CompEncoder CompDecoder }
IDefaultComponent std component's default impl should implement this interface.
type IStdStructuredPtr ¶
type IStdStructuredPtr interface { DataPtr() interface{} StatePtr() interface{} InParamsPtr() interface{} }
IStdStructuredPtr represents std structured pointer type.
type InvokeRenderWsEventPayload ¶
type InvokeRenderWsEventPayload struct {
RenderEvent ComponentEvent `json:"event,omitempty"`
}
InvokeRenderWsEventPayload .
type LegacyOperation ¶
type LegacyOperation struct { Key string `json:"key,omitempty"` Text string `json:"text,omitempty"` Confirm string `json:"confirm,omitempty"` Disabled bool `json:"disabled,omitempty"` DisabledTip string `json:"disabledTip,omitempty"` Reload bool `json:"reload,omitempty"` }
LegacyOperation .
type OpClientData ¶
OpClientData .
type Operation ¶
type Operation struct { Text string `json:"text,omitempty"` Tip string `json:"tip,omitempty"` Confirm string `json:"confirm,omitempty"` Disabled bool `json:"disabled,omitempty"` SkipRender bool `json:"skipRender,omitempty"` // skipRender means this op is just a frontend op, won't invoke backend to render. Async bool `json:"async,omitempty"` // ServerData generated at server-side. ServerData *OpServerData `json:"serverData,omitempty"` // ClientData generated at client-side. ClientData *OpClientData `json:"clientData,omitempty"` }
Operation .
type OperationFunc ¶
type OperationFunc func(sdk *SDK) IStdStructuredPtr
OperationFunc return std structured response.
type OperationKey ¶
type OperationKey string
OperationKey .
const ( // 协议定义的操作 // 用户通过URL初次访问 InitializeOperation OperationKey = "__Initialize__" // 用于替换掉DefaultOperation,前端触发某组件,在协议Rending中定义了关联渲染组件,传递的事件是RendingOperation RenderingOperation OperationKey = "__Rendering__" SyncOperation OperationKey = "__Sync__" AsyncAtInitOperation OperationKey = "__AsyncAtInit__" )
InitializeOperation .
type ProtocolOptions ¶
type ProtocolOptions struct { // SyncIntervalSecond can be float64, such as 10, 1, 0.5 . SyncIntervalSecond float64 `json:"syncIntervalSecond" yaml:"syncIntervalSecond"` // ParallelContinueRenders contains all component-level continue-render. ParallelContinueRenders map[string]ContinueRender `json:"parallelContinueRenders,omitempty" yaml:"parallelContinueRenders,omitempty"` // EnableWebSocket enable WebSocket for current scenario. EnableWebSocket bool `json:"enableWebSocket,omitempty" yaml:"enableWebSocket,omitempty"` // Only return rendering components if disabled ReturnAllComponents bool `json:"returnAllComponents" yaml:"returnAllComponents"` }
ProtocolOptions .
type RendingItem ¶
type RendingItem struct { Name string `json:"name" yaml:"name"` State []RendingState `json:"state" yaml:"state"` }
RendingItem .
type RendingState ¶
type RendingState struct { Name string `json:"name" yaml:"name"` Value string `json:"value" yaml:"value"` }
RendingState .
type SDK ¶
type SDK struct { Ctx context.Context Scenario string Tran i18n.Translator Identity *pb.IdentityInfo InParams InParams Lang i18n.LanguageCodes GlobalState *GlobalStateData // ONLY FOR STD COMPONENT USE Event ComponentEvent CompOpFuncs map[OperationKey]OperationFunc Comp *Component // for parallel use, it's request level StdStructuredPtr IStdStructuredPtr // contains filtered or unexported fields }
SDK .
func (*SDK) MergeClonedGlobalState ¶
func (sdk *SDK) MergeClonedGlobalState()
MergeClonedGlobalState merge cloned global state to origin unified global state.
func (*SDK) RegisterOperation ¶
func (sdk *SDK) RegisterOperation(opKey OperationKey, opFunc OperationFunc)
RegisterOperation .
type Scenario ¶
type Scenario struct { // 场景类型, 没有则为空 ScenarioType string `json:"scenarioType" query:"scenarioType"` // 场景Key ScenarioKey string `json:"scenarioKey" query:"scenarioKey"` }
Scenario .
type UIRenderWsEventPayload ¶
type UIRenderWsEventPayload struct {
Components map[string]*Component `json:"components,omitempty"`
}
UIRenderWsEventPayload .
type WebSocketEventType ¶
type WebSocketEventType string
WebSocketEventType .
var ( // WebSocketEventTypeInvokeRender means frontend need invoke operation render to backend. WebSocketEventTypeInvokeRender WebSocketEventType = "InvokeRender" // WebSocketEventTypeUIRender means just UI re-render, no need invoke backend. WebSocketEventTypeUIRender WebSocketEventType = "UIRender" )