@storvia/sdk 0.5.20 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +171 -16
- package/dist/index.d.mts +35 -11
- package/dist/index.esm.js +171 -16
- package/dist/index.umd.js +171 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -691,15 +691,6 @@ declare class StorviaError extends Error {
|
|
|
691
691
|
constructor(code: StorviaErrorCode, message: string);
|
|
692
692
|
}
|
|
693
693
|
|
|
694
|
-
/**
|
|
695
|
-
* SDK 内置 Toast:参考主站 Toast.vue 样式
|
|
696
|
-
* 用于在 HTTP 层捕获错误后自动提示用户
|
|
697
|
-
*/
|
|
698
|
-
|
|
699
|
-
type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
700
|
-
declare function setToastEnabled(enabled: boolean): void;
|
|
701
|
-
declare function showToast(message: string, type?: ToastType, duration?: number): void;
|
|
702
|
-
|
|
703
694
|
/**
|
|
704
695
|
* 父子 iframe postMessage 协议类型
|
|
705
696
|
*
|
|
@@ -775,12 +766,19 @@ interface SdkErrorPayload {
|
|
|
775
766
|
message: string;
|
|
776
767
|
recoverable: boolean;
|
|
777
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* 子 → 父:请求宿主跳转。当前仅支持 'wallet'(充值/钱包页),
|
|
771
|
+
* Web 主站 router.push('/wallet'),App 端跳 App 内钱包路由。
|
|
772
|
+
*/
|
|
773
|
+
interface NavigatePayload {
|
|
774
|
+
target: 'wallet';
|
|
775
|
+
}
|
|
778
776
|
interface AckPayload {
|
|
779
777
|
ok: boolean;
|
|
780
778
|
error?: string;
|
|
781
779
|
}
|
|
782
780
|
type DownstreamMsg = ProtocolEnvelope<'init', InitPayload> | ProtocolEnvelope<'preview-init', PreviewInitPayload> | ProtocolEnvelope<'token-update', TokenUpdatePayload> | ProtocolEnvelope<'config-update', ConfigUpdatePayload> | ProtocolEnvelope<'set-model', SetModelPayload> | ProtocolEnvelope<'orientation', OrientationPayload> | ProtocolEnvelope<'ack', AckPayload>;
|
|
783
|
-
type UpstreamMsg = ProtocolEnvelope<'ready', ReadyPayload> | ProtocolEnvelope<'exit', Record<string, never>> | ProtocolEnvelope<'request-orientation', OrientationPayload> | ProtocolEnvelope<'error', SdkErrorPayload> | ProtocolEnvelope<'ack', AckPayload>;
|
|
781
|
+
type UpstreamMsg = ProtocolEnvelope<'ready', ReadyPayload> | ProtocolEnvelope<'exit', Record<string, never>> | ProtocolEnvelope<'request-orientation', OrientationPayload> | ProtocolEnvelope<'error', SdkErrorPayload> | ProtocolEnvelope<'navigate', NavigatePayload> | ProtocolEnvelope<'ack', AckPayload>;
|
|
784
782
|
declare function isProtocolEnvelope(data: unknown): data is ProtocolEnvelope<string, unknown>;
|
|
785
783
|
declare function envelope<T extends string, P>(type: T, payload: P, opts?: {
|
|
786
784
|
id?: string;
|
|
@@ -824,6 +822,11 @@ interface StorviaBusOptions<TIn extends AnyEnvelope> {
|
|
|
824
822
|
debug?: boolean;
|
|
825
823
|
/** transferable objects 的回调(用于 Phase 4 MessageChannel) */
|
|
826
824
|
transfer?: (msg: AnyEnvelope) => Transferable[] | undefined;
|
|
825
|
+
/**
|
|
826
|
+
* 自定义出站发送函数。一旦提供,`outgoing` 不会被调用,全部消息走这个函数。
|
|
827
|
+
* 用于 Flutter WebView 等没有 `window.parent` 的宿主环境(消息走 native channel)。
|
|
828
|
+
*/
|
|
829
|
+
customSend?: (envelope: AnyEnvelope) => void;
|
|
827
830
|
}
|
|
828
831
|
declare class StorviaBus<TIn extends AnyEnvelope, TOut extends AnyEnvelope> {
|
|
829
832
|
private incoming;
|
|
@@ -832,6 +835,7 @@ declare class StorviaBus<TIn extends AnyEnvelope, TOut extends AnyEnvelope> {
|
|
|
832
835
|
private validate;
|
|
833
836
|
private debug;
|
|
834
837
|
private getTransferables;
|
|
838
|
+
private customSend;
|
|
835
839
|
private handlers;
|
|
836
840
|
private pendingAcks;
|
|
837
841
|
private listener;
|
|
@@ -848,4 +852,24 @@ declare class StorviaBus<TIn extends AnyEnvelope, TOut extends AnyEnvelope> {
|
|
|
848
852
|
destroy(): void;
|
|
849
853
|
}
|
|
850
854
|
|
|
851
|
-
|
|
855
|
+
/**
|
|
856
|
+
* SDK 内置 Toast:参考主站 Toast.vue 样式
|
|
857
|
+
* 用于在 HTTP 层捕获错误后自动提示用户
|
|
858
|
+
*/
|
|
859
|
+
|
|
860
|
+
type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
861
|
+
declare function setToastEnabled(enabled: boolean): void;
|
|
862
|
+
interface ToastAction {
|
|
863
|
+
label: string;
|
|
864
|
+
onClick: () => void;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* 展示一条 toast。
|
|
868
|
+
* - duration > 0:duration ms 后自动消失
|
|
869
|
+
* - duration === 0:常驻,必须用户点关闭按钮(× 自动加上)或 action 按钮才会关闭
|
|
870
|
+
*/
|
|
871
|
+
declare function showToast(message: string, type?: ToastType, duration?: number, action?: ToastAction): void;
|
|
872
|
+
declare function setInsufficientCreditsSheetEnabled(enabled: boolean): void;
|
|
873
|
+
declare function showInsufficientCreditsSheet(fallbackMsg?: string): void;
|
|
874
|
+
|
|
875
|
+
export { type AISummary, type AckPayload, type AssetItem, type CharacterAddOptions, type CharacterDetail, type CharacterPersona, type CharacterUpdateOptions, type ChatGenerateOptions, type ChatMessage, type ChatMessageCursor, type ChatMessagesOptions, type ChatMessagesResponse, type ChatResponse, type ChatRetryOptions, type ChatSaveOptions, type ChatSendOptions, type ChatStateCallback, type ConfigUpdatePayload, type CurrentState, type DormantState, type DownstreamMsg, type FieldValue, type Gender, type InitPayload, type InventoryAddOptions, type InventoryMoveOptions, type InventoryRemoveGroupOptions, type InventoryRemoveOptions, type InventoryState, type InventoryUpdateOptions, type ItemData, type OrientationPayload, PROTOCOL_VERSION, type PlayerPersona, type PreviewConfig, type PreviewInitPayload, type ProtocolEnvelope, type ReadyPayload, type Relationship, type RichFieldValue, type SdkErrorPayload, type SetModelPayload, type State, type StateChanges, StorviaBus, type StorviaBusOptions, StorviaError, type StorviaErrorCode, StorviaSDK, type TokenUpdatePayload, type UpstreamMsg, createStorviaSDK, envelope, extractFieldValue, isProtocolEnvelope, isRichFieldValue, setInsufficientCreditsSheetEnabled, setToastEnabled, showInsufficientCreditsSheet, showToast };
|