next-flow-interface 0.24.8 → 0.24.9
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/README.md +1 -1
- package/index.d.ts +163 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# next-flow-interface
|
|
1
|
+
# next-flow-interface
|
package/index.d.ts
CHANGED
|
@@ -4895,19 +4895,180 @@ declare function stopPropagationListener(e: ReactEvent): void
|
|
|
4895
4895
|
export declare type SupportAnimationTarget = Node_2 | Scene | Material | NodeMaterialBlock | ShadowGenerator
|
|
4896
4896
|
|
|
4897
4897
|
/**
|
|
4898
|
-
*
|
|
4898
|
+
* 同步服务 - 管理多人协同数据的核心服务
|
|
4899
|
+
*
|
|
4900
|
+
* @description
|
|
4901
|
+
* SyncService 是管理 Next Flow 所有协同数据的基础服务。
|
|
4902
|
+
* 它负责初始化和协调 RhineVar 同步系统,管理客户端连接,
|
|
4903
|
+
* 并编排所有子服务,包括文件、资源、模型、场景和插件等。
|
|
4904
|
+
*
|
|
4905
|
+
* 该服务采用单例模式,首次访问时自动初始化。
|
|
4906
|
+
* 所有协同状态存储在 `state` 属性中,这是一个 RhineVar 代理对象,
|
|
4907
|
+
* 会实时同步到所有连接的客户端。
|
|
4908
|
+
*
|
|
4909
|
+
* @example
|
|
4910
|
+
* ```typescript
|
|
4911
|
+
* // 获取同步服务实例
|
|
4912
|
+
* const syncService = SyncService.instance
|
|
4913
|
+
*
|
|
4914
|
+
* // 为新实体生成唯一 ID
|
|
4915
|
+
* const newId = syncService.generateId('model')
|
|
4916
|
+
*
|
|
4917
|
+
* // 访问协同状态
|
|
4918
|
+
* const steps = syncService.state.steps
|
|
4919
|
+
* ```
|
|
4899
4920
|
*
|
|
4900
4921
|
* @public
|
|
4901
4922
|
*/
|
|
4902
4923
|
export declare class SyncService {
|
|
4924
|
+
/**
|
|
4925
|
+
* RhineVar 同步覆写模式标志
|
|
4926
|
+
*
|
|
4927
|
+
* @description
|
|
4928
|
+
* 启用时,允许本地状态在初始化时覆盖远程状态。
|
|
4929
|
+
* 通常仅用于开发或调试目的。
|
|
4930
|
+
*
|
|
4931
|
+
* @defaultValue false
|
|
4932
|
+
* @public
|
|
4933
|
+
*/
|
|
4903
4934
|
OVERWRITE_MODE: boolean
|
|
4935
|
+
/**
|
|
4936
|
+
* 启用 RhineVar 内部日志
|
|
4937
|
+
*
|
|
4938
|
+
* @description
|
|
4939
|
+
* 启用时,打开 RhineVar 操作的详细日志。
|
|
4940
|
+
* 用于调试同步问题。
|
|
4941
|
+
*
|
|
4942
|
+
* @defaultValue false
|
|
4943
|
+
* @public
|
|
4944
|
+
*/
|
|
4904
4945
|
ENABLE_RHINE_VAR_LOG: boolean
|
|
4946
|
+
/**
|
|
4947
|
+
* 获取 SyncService 的单例实例
|
|
4948
|
+
*
|
|
4949
|
+
* @description
|
|
4950
|
+
* 返回 SyncService 的单例实例。如果不存在则创建新实例。
|
|
4951
|
+
* 服务在首次访问时自动开始初始化。
|
|
4952
|
+
*
|
|
4953
|
+
* @returns SyncService 单例实例
|
|
4954
|
+
*
|
|
4955
|
+
* @example
|
|
4956
|
+
* ```typescript
|
|
4957
|
+
* const syncService = SyncService.instance
|
|
4958
|
+
* ```
|
|
4959
|
+
*
|
|
4960
|
+
* @public
|
|
4961
|
+
*/
|
|
4905
4962
|
static get instance(): SyncService
|
|
4906
|
-
|
|
4963
|
+
/**
|
|
4964
|
+
* RhineVar 同步服务器的 WebSocket 地址
|
|
4965
|
+
*
|
|
4966
|
+
* @description
|
|
4967
|
+
* 用于连接 RhineVar 同步服务器的 URL。
|
|
4968
|
+
* 使用当前页面的项目 ID 构造而成。
|
|
4969
|
+
*
|
|
4970
|
+
* @public
|
|
4971
|
+
*/
|
|
4907
4972
|
url: string
|
|
4973
|
+
/**
|
|
4974
|
+
* RhineVar 协同状态对象
|
|
4975
|
+
*
|
|
4976
|
+
* @description
|
|
4977
|
+
* 在所有客户端之间同步的根协同状态对象。
|
|
4978
|
+
* 该对象包含所有项目数据,包括场景步骤、文件、资源、模型、场景节点等。
|
|
4979
|
+
* 对此状态的任何修改都会自动同步到所有连接的客户端。
|
|
4980
|
+
*
|
|
4981
|
+
* 配置选项:
|
|
4982
|
+
* - 覆写模式(如果启用)
|
|
4983
|
+
* - 撤销管理器用于历史记录跟踪
|
|
4984
|
+
* - 协作感知用于跟踪其他用户
|
|
4985
|
+
*
|
|
4986
|
+
* @see {@link RvBase} 查看完整的状态结构
|
|
4987
|
+
*
|
|
4988
|
+
* @example
|
|
4989
|
+
* ```typescript
|
|
4990
|
+
* // 访问场景步骤
|
|
4991
|
+
* const steps = SyncService.instance.state.steps
|
|
4992
|
+
*
|
|
4993
|
+
* // 访问文件
|
|
4994
|
+
* const files = SyncService.instance.state.files
|
|
4995
|
+
*
|
|
4996
|
+
* // 等待同步完成
|
|
4997
|
+
* await SyncService.instance.state.waitSynced()
|
|
4998
|
+
* ```
|
|
4999
|
+
*
|
|
5000
|
+
* @public
|
|
5001
|
+
*/
|
|
4908
5002
|
state: RecursiveObject<RvBase>
|
|
5003
|
+
/**
|
|
5004
|
+
* 客户端唯一标识符
|
|
5005
|
+
*
|
|
5006
|
+
* @description
|
|
5007
|
+
* RhineVar 同步系统分配给此客户端的唯一数字 ID。
|
|
5008
|
+
* 用于在所有连接的客户端中识别此客户端,并生成唯一的实体 ID。
|
|
5009
|
+
*
|
|
5010
|
+
* @public
|
|
5011
|
+
*/
|
|
4909
5012
|
clientId: number
|
|
5013
|
+
/**
|
|
5014
|
+
* 使用指定前缀生成唯一 ID
|
|
5015
|
+
*
|
|
5016
|
+
* @description
|
|
5017
|
+
* 通过组合以下内容生成唯一标识符:
|
|
5018
|
+
* - 提供的前缀
|
|
5019
|
+
* - 该前缀的自增计数器
|
|
5020
|
+
* - 当前客户端 ID
|
|
5021
|
+
*
|
|
5022
|
+
* 这确保了 ID 在所有客户端和实体类型之间都是唯一的。
|
|
5023
|
+
*
|
|
5024
|
+
* @param prefix - 用于 ID 的前缀(例如:'model'、'step'、'file')
|
|
5025
|
+
* @returns 格式为 `{prefix}{counter}-{clientId}` 的唯一 ID 字符串
|
|
5026
|
+
*
|
|
5027
|
+
* @example
|
|
5028
|
+
* ```typescript
|
|
5029
|
+
* // 生成唯一的模型 ID
|
|
5030
|
+
* const modelId = SyncService.instance.generateId('model')
|
|
5031
|
+
* // 返回: "model0-12345" (其中 12345 是客户端 ID)
|
|
5032
|
+
*
|
|
5033
|
+
* // 再次生成模型 ID
|
|
5034
|
+
* const modelId2 = SyncService.instance.generateId('model')
|
|
5035
|
+
* // 返回: "model1-12345"
|
|
5036
|
+
*
|
|
5037
|
+
* // 生成场景步骤 ID
|
|
5038
|
+
* const stepId = SyncService.instance.generateId('step')
|
|
5039
|
+
* // 返回: "step0-12345"
|
|
5040
|
+
* ```
|
|
5041
|
+
*
|
|
5042
|
+
* @public
|
|
5043
|
+
*/
|
|
4910
5044
|
generateId(prefix: string): string
|
|
5045
|
+
/**
|
|
5046
|
+
* 重置所有协同数据
|
|
5047
|
+
*
|
|
5048
|
+
* @description
|
|
5049
|
+
* **⚠️ 危险操作:这是一个破坏性操作!**
|
|
5050
|
+
*
|
|
5051
|
+
* 通过删除底层 RhineVar YMap 中的状态,完全清除所有协同数据。
|
|
5052
|
+
* 这将影响所有连接的客户端,并且无法撤销。
|
|
5053
|
+
*
|
|
5054
|
+
* 请极其谨慎使用,通常仅用于:
|
|
5055
|
+
* - 开发/测试目的
|
|
5056
|
+
* - 从损坏的状态中恢复
|
|
5057
|
+
* - 经过用户确认的有意项目重置
|
|
5058
|
+
*
|
|
5059
|
+
* @returns 如果重置成功返回 `true`,如果未找到基础映射表返回 `false`
|
|
5060
|
+
*
|
|
5061
|
+
* @example
|
|
5062
|
+
* ```typescript
|
|
5063
|
+
* // 重置所有数据(请谨慎使用!)
|
|
5064
|
+
* const success = SyncService.instance.reset()
|
|
5065
|
+
* if (success) {
|
|
5066
|
+
* console.log('All collaborative data has been cleared')
|
|
5067
|
+
* }
|
|
5068
|
+
* ```
|
|
5069
|
+
*
|
|
5070
|
+
* @public
|
|
5071
|
+
*/
|
|
4911
5072
|
reset(): boolean
|
|
4912
5073
|
}
|
|
4913
5074
|
|