@joplo-app/kit 0.2.10 → 0.2.13

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.d.ts CHANGED
@@ -369,6 +369,8 @@ export type CardOpts = {
369
369
  role?: string;
370
370
  };
371
371
  export type StepDef = {
372
+ /** Stable identity within this scenario; independent of the playback position. */
373
+ key?: string;
372
374
  kind: 'user' | 'system' | 'card';
373
375
  action: {
374
376
  type: 'click';
@@ -422,6 +424,8 @@ export declare class Flow {
422
424
  readonly source: string | undefined;
423
425
  constructor(name: string, opts: FlowOpts);
424
426
  private add;
427
+ /** Give the preceding step a stable key. Keep it when editing or moving the same action. */
428
+ key(key: string): this;
425
429
  click(target: string, ...args: StepArg[]): this;
426
430
  type(target: string, value: string, ...args: StepArg[]): this;
427
431
  select(target: string, value: string, ...args: StepArg[]): this;
package/dist/index.js CHANGED
@@ -164,6 +164,16 @@ export class Flow {
164
164
  this.steps.push({ kind, action, ...(caption ? { caption } : {}), effects, source: callsite(4) });
165
165
  return this;
166
166
  }
167
+ /** Give the preceding step a stable key. Keep it when editing or moving the same action. */
168
+ key(key) {
169
+ const step = this.steps.at(-1);
170
+ if (!step)
171
+ throw new Error('flow.key() must follow a step');
172
+ if (step.key !== undefined)
173
+ throw new Error('This step already has a key');
174
+ step.key = key;
175
+ return this;
176
+ }
167
177
  click(target, ...args) {
168
178
  return this.add('user', { type: 'click', target }, args);
169
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joplo-app/kit",
3
- "version": "0.2.10",
3
+ "version": "0.2.13",
4
4
  "description": "Joplo 创作 SDK:组件、feature/option/flow 与 JSX 运行时(收集成数据,不作为 React 执行)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",