assistsx-js 0.2.1 → 0.2.3

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 CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  **[Assistsx源码](https://github.com/ven-coder/assistsx)**
17
17
 
18
+ **[更新日志](./CHANGELOG.md)**
19
+
18
20
  # 快速开始
19
21
 
20
22
  ## 方式一:HTML 直接引用(无需构建工具)
@@ -108,15 +110,61 @@ export default defineConfig({
108
110
 
109
111
  **[API开发文档](https://github.com/ven-coder/assistsx-js/blob/main/README-DEV.md)**
110
112
 
113
+ ## StepFlow(流程编排,`assistsx-js/step-flow`)
114
+
115
+ 在保留原有 `Step.run` / `StepImpl` 的前提下,提供基于**状态 + 事件 + on 转移表**的流程编排,适合非线性跳转、多流程共用同一步骤实现。
116
+
117
+ ```ts
118
+ import { Step } from "assistsx-js";
119
+ import {
120
+ StepFlow,
121
+ flowEvent,
122
+ flowRepeat,
123
+ flowEnd,
124
+ createFlowDispatcher,
125
+ buildFlowInitialData,
126
+ createLaunchState,
127
+ } from "assistsx-js/step-flow";
128
+
129
+ // 1. 定义流程(launch 可衔接 legacy finishMethod)
130
+ const config = {
131
+ id: "my.flow",
132
+ initial: "launch",
133
+ states: {} as Record<string, import("assistsx-js/step-flow").FlowStateDef>,
134
+ data: { appName: "抖音", packageName: "com.ss.android.ugc.aweme" },
135
+ };
136
+ const dispatcher = createFlowDispatcher(config);
137
+ config.states = {
138
+ launch: createLaunchState(dispatcher, appLaunch.launch, "mainPage"),
139
+ mainPage: {
140
+ run: async (step) => (isHome(step) ? flowEvent("home") : flowRepeat()),
141
+ on: { home: "next", retry: "mainPage" },
142
+ },
143
+ next: { run: async () => flowEnd(), on: {} },
144
+ };
145
+
146
+ await Step.run(dispatcher, { data: buildFlowInitialData(config) });
147
+ // 或使用:await StepFlow.run(config); // 需在 config.states 填充后再 run,见 createLaunchState 文档
148
+ ```
149
+
150
+ 要点:
151
+
152
+ - **步骤实现**(`FlowStepImpl`)只返回 `flowEvent` / `flowRepeat` / `flowEnd`,或 `legacy` 委托旧版 `StepImpl`。
153
+ - **跳转**由当前状态的 `on` 表决定;同一 `run` 可在不同 Flow 中配置不同的 `on`。
154
+ - **业务数据**建议放在 `step.data.payload`;`getFlowPayload` / `assignFlowPayload` 可读写。
155
+ - **与 legacy 共存**:`import { Step } from "assistsx-js"` 不变;StepFlow 从 `assistsx-js/step-flow` 单独导入。
156
+
157
+ 完整示例见 [ais-douyin-simple](https://github.com/ven-coder/assists-examples) 中 `src/v1/flows/check-unread.ts`。
158
+
111
159
  ## 示例
112
160
 
113
161
  示例源码及使用教程:[assistsx-js-simple](https://github.com/ven-coder/assists-examples/tree/main/assistsx-js-simple)
114
162
 
115
163
  ## 🙋有问题欢迎反馈交流
116
164
 
117
- | QQ交流群| 个人微信 |
165
+ | QQ交流群| 作者微信 |
118
166
  |:---------:|:-----------:|
119
- | <img src="https://github.com/user-attachments/assets/732c38a5-7473-44ca-be76-d1fabb27aa5d" width=200/> | <img src="https://github.com/user-attachments/assets/b805f5a0-223b-415d-a34b-7659aa0bdf0a" width=200/>
167
+ | <img src="https://github.com/user-attachments/assets/ec705332-5c07-47cb-aaa4-27199064ea1f" width=200/> | <img src="https://github.com/user-attachments/assets/b805f5a0-223b-415d-a34b-7659aa0bdf0a" width=200/>
120
168
 
121
169
  # 💝 支持开源
122
170