@joplo-app/core 0.2.17 → 0.2.18

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/schema.d.ts CHANGED
@@ -68,8 +68,8 @@ export declare const Scene: z.ZodObject<{
68
68
  route: z.ZodString;
69
69
  name: z.ZodString;
70
70
  viewport: z.ZodDefault<z.ZodEnum<{
71
- desktop: "desktop";
72
71
  mobile: "mobile";
72
+ desktop: "desktop";
73
73
  }>>;
74
74
  root: z.ZodType<SceneNode, unknown, z.core.$ZodTypeInternals<SceneNode, unknown>>;
75
75
  layer: z.ZodOptional<z.ZodString>;
@@ -168,9 +168,9 @@ export declare const Fork: z.ZodObject<{
168
168
  export declare const Mark: z.ZodObject<{
169
169
  target: z.ZodString;
170
170
  kind: z.ZodEnum<{
171
+ box: "box";
171
172
  circle: "circle";
172
173
  underline: "underline";
173
- box: "box";
174
174
  arrow: "arrow";
175
175
  }>;
176
176
  note: z.ZodOptional<z.ZodString>;
@@ -194,8 +194,8 @@ export declare const Callout: z.ZodObject<{
194
194
  target: z.ZodString;
195
195
  text: z.ZodString;
196
196
  side: z.ZodOptional<z.ZodEnum<{
197
- top: "top";
198
197
  right: "right";
198
+ top: "top";
199
199
  bottom: "bottom";
200
200
  left: "left";
201
201
  }>>;
@@ -205,8 +205,8 @@ export declare const Step: z.ZodObject<{
205
205
  key: z.ZodOptional<z.ZodString>;
206
206
  kind: z.ZodEnum<{
207
207
  user: "user";
208
- system: "system";
209
208
  card: "card";
209
+ system: "system";
210
210
  }>;
211
211
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
212
212
  type: z.ZodLiteral<"click">;
@@ -242,11 +242,11 @@ export declare const Step: z.ZodObject<{
242
242
  captionAuto: z.ZodOptional<z.ZodObject<{
243
243
  kind: z.ZodEnum<{
244
244
  check: "check";
245
- click: "click";
246
245
  type: "type";
246
+ click: "click";
247
247
  select: "select";
248
- press: "press";
249
248
  back: "back";
249
+ press: "press";
250
250
  uncheck: "uncheck";
251
251
  switch_on: "switch_on";
252
252
  switch_off: "switch_off";
@@ -317,9 +317,9 @@ export declare const Step: z.ZodObject<{
317
317
  marks: z.ZodDefault<z.ZodArray<z.ZodObject<{
318
318
  target: z.ZodString;
319
319
  kind: z.ZodEnum<{
320
+ box: "box";
320
321
  circle: "circle";
321
322
  underline: "underline";
322
- box: "box";
323
323
  arrow: "arrow";
324
324
  }>;
325
325
  note: z.ZodOptional<z.ZodString>;
@@ -336,8 +336,8 @@ export declare const Step: z.ZodObject<{
336
336
  target: z.ZodString;
337
337
  text: z.ZodString;
338
338
  side: z.ZodOptional<z.ZodEnum<{
339
- top: "top";
340
339
  right: "right";
340
+ top: "top";
341
341
  bottom: "bottom";
342
342
  left: "left";
343
343
  }>>;
@@ -368,14 +368,15 @@ export declare const Scenario: z.ZodObject<{
368
368
  ui: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
369
369
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
370
370
  inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
371
+ layer: z.ZodOptional<z.ZodString>;
371
372
  }, z.core.$strict>;
372
373
  steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
373
374
  id: z.ZodString;
374
375
  key: z.ZodOptional<z.ZodString>;
375
376
  kind: z.ZodEnum<{
376
377
  user: "user";
377
- system: "system";
378
378
  card: "card";
379
+ system: "system";
379
380
  }>;
380
381
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
381
382
  type: z.ZodLiteral<"click">;
@@ -411,11 +412,11 @@ export declare const Scenario: z.ZodObject<{
411
412
  captionAuto: z.ZodOptional<z.ZodObject<{
412
413
  kind: z.ZodEnum<{
413
414
  check: "check";
414
- click: "click";
415
415
  type: "type";
416
+ click: "click";
416
417
  select: "select";
417
- press: "press";
418
418
  back: "back";
419
+ press: "press";
419
420
  uncheck: "uncheck";
420
421
  switch_on: "switch_on";
421
422
  switch_off: "switch_off";
@@ -486,9 +487,9 @@ export declare const Scenario: z.ZodObject<{
486
487
  marks: z.ZodDefault<z.ZodArray<z.ZodObject<{
487
488
  target: z.ZodString;
488
489
  kind: z.ZodEnum<{
490
+ box: "box";
489
491
  circle: "circle";
490
492
  underline: "underline";
491
- box: "box";
492
493
  arrow: "arrow";
493
494
  }>;
494
495
  note: z.ZodOptional<z.ZodString>;
@@ -505,8 +506,8 @@ export declare const Scenario: z.ZodObject<{
505
506
  target: z.ZodString;
506
507
  text: z.ZodString;
507
508
  side: z.ZodOptional<z.ZodEnum<{
508
- top: "top";
509
509
  right: "right";
510
+ top: "top";
510
511
  bottom: "bottom";
511
512
  left: "left";
512
513
  }>>;
@@ -554,10 +555,10 @@ export declare const Case: z.ZodObject<{
554
555
  title: z.ZodString;
555
556
  dimension: z.ZodEnum<{
556
557
  main: "main";
558
+ async: "async";
557
559
  input: "input";
558
560
  permission: "permission";
559
561
  lifecycle: "lifecycle";
560
- async: "async";
561
562
  interrupt: "interrupt";
562
563
  conflict: "conflict";
563
564
  consistency: "consistency";
@@ -573,11 +574,11 @@ export declare const Case: z.ZodObject<{
573
574
  export declare const COVERAGE_STATUSES: readonly ["expressed", "undecided", "missing", "not_applicable", "excluded"];
574
575
  export declare const Coverage: z.ZodObject<{
575
576
  status: z.ZodEnum<{
577
+ expressed: "expressed";
576
578
  undecided: "undecided";
577
579
  missing: "missing";
578
580
  not_applicable: "not_applicable";
579
581
  excluded: "excluded";
580
- expressed: "expressed";
581
582
  }>;
582
583
  scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
583
584
  reason: z.ZodOptional<z.ZodString>;
@@ -597,11 +598,11 @@ export declare const Option: z.ZodObject<{
597
598
  routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
598
599
  coverage: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
599
600
  status: z.ZodEnum<{
601
+ expressed: "expressed";
600
602
  undecided: "undecided";
601
603
  missing: "missing";
602
604
  not_applicable: "not_applicable";
603
605
  excluded: "excluded";
604
- expressed: "expressed";
605
606
  }>;
606
607
  scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
607
608
  reason: z.ZodOptional<z.ZodString>;
@@ -616,14 +617,14 @@ export declare const Option: z.ZodObject<{
616
617
  role: z.ZodOptional<z.ZodString>;
617
618
  icon: z.ZodOptional<z.ZodEnum<{
618
619
  terminal: "terminal";
619
- data: "data";
620
- desktop: "desktop";
621
- mobile: "mobile";
622
620
  window: "window";
623
621
  browser: "browser";
622
+ mobile: "mobile";
623
+ desktop: "desktop";
624
624
  chat: "chat";
625
625
  agent: "agent";
626
626
  server: "server";
627
+ data: "data";
627
628
  email: "email";
628
629
  doc: "doc";
629
630
  flow: "flow";
@@ -693,9 +694,11 @@ export declare const VoiceIndex: z.ZodObject<{
693
694
  narrator: z.ZodNullable<z.ZodString>;
694
695
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
695
696
  clips: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
697
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
696
698
  locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
697
699
  narrator: z.ZodNullable<z.ZodString>;
698
700
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
701
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
699
702
  }, z.core.$strict>>>;
700
703
  }, z.core.$strict>;
701
704
  export declare const Project: z.ZodObject<{
@@ -717,9 +720,11 @@ export declare const Project: z.ZodObject<{
717
720
  narrator: z.ZodNullable<z.ZodString>;
718
721
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
719
722
  clips: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
723
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
720
724
  locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
721
725
  narrator: z.ZodNullable<z.ZodString>;
722
726
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
727
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
723
728
  }, z.core.$strict>>>;
724
729
  }, z.core.$strict>>;
725
730
  i18n: z.ZodOptional<z.ZodObject<{
@@ -769,10 +774,10 @@ export declare const Project: z.ZodObject<{
769
774
  title: z.ZodString;
770
775
  dimension: z.ZodEnum<{
771
776
  main: "main";
777
+ async: "async";
772
778
  input: "input";
773
779
  permission: "permission";
774
780
  lifecycle: "lifecycle";
775
- async: "async";
776
781
  interrupt: "interrupt";
777
782
  conflict: "conflict";
778
783
  consistency: "consistency";
@@ -796,11 +801,11 @@ export declare const Project: z.ZodObject<{
796
801
  routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
797
802
  coverage: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
798
803
  status: z.ZodEnum<{
804
+ expressed: "expressed";
799
805
  undecided: "undecided";
800
806
  missing: "missing";
801
807
  not_applicable: "not_applicable";
802
808
  excluded: "excluded";
803
- expressed: "expressed";
804
809
  }>;
805
810
  scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
806
811
  reason: z.ZodOptional<z.ZodString>;
@@ -815,14 +820,14 @@ export declare const Project: z.ZodObject<{
815
820
  role: z.ZodOptional<z.ZodString>;
816
821
  icon: z.ZodOptional<z.ZodEnum<{
817
822
  terminal: "terminal";
818
- data: "data";
819
- desktop: "desktop";
820
- mobile: "mobile";
821
823
  window: "window";
822
824
  browser: "browser";
825
+ mobile: "mobile";
826
+ desktop: "desktop";
823
827
  chat: "chat";
824
828
  agent: "agent";
825
829
  server: "server";
830
+ data: "data";
826
831
  email: "email";
827
832
  doc: "doc";
828
833
  flow: "flow";
@@ -858,8 +863,8 @@ export declare const Project: z.ZodObject<{
858
863
  route: z.ZodString;
859
864
  name: z.ZodString;
860
865
  viewport: z.ZodDefault<z.ZodEnum<{
861
- desktop: "desktop";
862
866
  mobile: "mobile";
867
+ desktop: "desktop";
863
868
  }>>;
864
869
  root: z.ZodType<SceneNode, unknown, z.core.$ZodTypeInternals<SceneNode, unknown>>;
865
870
  layer: z.ZodOptional<z.ZodString>;
@@ -885,14 +890,15 @@ export declare const Project: z.ZodObject<{
885
890
  ui: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
886
891
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
887
892
  inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
893
+ layer: z.ZodOptional<z.ZodString>;
888
894
  }, z.core.$strict>;
889
895
  steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
890
896
  id: z.ZodString;
891
897
  key: z.ZodOptional<z.ZodString>;
892
898
  kind: z.ZodEnum<{
893
899
  user: "user";
894
- system: "system";
895
900
  card: "card";
901
+ system: "system";
896
902
  }>;
897
903
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
898
904
  type: z.ZodLiteral<"click">;
@@ -928,11 +934,11 @@ export declare const Project: z.ZodObject<{
928
934
  captionAuto: z.ZodOptional<z.ZodObject<{
929
935
  kind: z.ZodEnum<{
930
936
  check: "check";
931
- click: "click";
932
937
  type: "type";
938
+ click: "click";
933
939
  select: "select";
934
- press: "press";
935
940
  back: "back";
941
+ press: "press";
936
942
  uncheck: "uncheck";
937
943
  switch_on: "switch_on";
938
944
  switch_off: "switch_off";
@@ -1003,9 +1009,9 @@ export declare const Project: z.ZodObject<{
1003
1009
  marks: z.ZodDefault<z.ZodArray<z.ZodObject<{
1004
1010
  target: z.ZodString;
1005
1011
  kind: z.ZodEnum<{
1012
+ box: "box";
1006
1013
  circle: "circle";
1007
1014
  underline: "underline";
1008
- box: "box";
1009
1015
  arrow: "arrow";
1010
1016
  }>;
1011
1017
  note: z.ZodOptional<z.ZodString>;
@@ -1022,8 +1028,8 @@ export declare const Project: z.ZodObject<{
1022
1028
  target: z.ZodString;
1023
1029
  text: z.ZodString;
1024
1030
  side: z.ZodOptional<z.ZodEnum<{
1025
- top: "top";
1026
1031
  right: "right";
1032
+ top: "top";
1027
1033
  bottom: "bottom";
1028
1034
  left: "left";
1029
1035
  }>>;
package/dist/schema.js CHANGED
@@ -187,6 +187,8 @@ export const Scenario = z.strictObject({
187
187
  ui: z.record(z.string(), Json).default({}),
188
188
  data: z.record(z.string(), Json).default({}),
189
189
  inputs: z.record(z.string(), Json).default({}),
190
+ /** 起始导演层(flow({ layer }),或 flow({ from }) 接力时那个场景结尾的导演层);缺省为第一层。 */
191
+ layer: z.string().optional(),
190
192
  }),
191
193
  steps: z.array(Step).default([]),
192
194
  expected: z.string().default(''),
@@ -303,8 +305,10 @@ export const VoiceIndex = z.strictObject({
303
305
  narrator: z.string().min(1).nullable(),
304
306
  roles: z.record(z.string(), z.string().min(1)).default({}),
305
307
  clips: z.record(z.string(), z.string().min(1)).default({}),
308
+ /** 混合来源更新:clipKey(角色 id 或空串, 文字) → 实际声音指纹;音频键仍使用真实指纹。 */
309
+ overrides: z.record(z.string(), z.string().min(1)).optional(),
306
310
  /** 内容语言(D84)→ 这种语言的旁白与角色指纹;没有的语言用上面的默认声音。 */
307
- locales: z.record(z.string(), z.strictObject({ narrator: z.string().min(1).nullable(), roles: z.record(z.string(), z.string().min(1)).default({}) })).optional(),
311
+ locales: z.record(z.string(), z.strictObject({ narrator: z.string().min(1).nullable(), roles: z.record(z.string(), z.string().min(1)).default({}), overrides: z.record(z.string(), z.string().min(1)).optional() })).optional(),
308
312
  });
309
313
  export const Project = z.strictObject({
310
314
  schemaVersion: z.literal(SCHEMA_VERSION),
package/dist/voice.d.ts CHANGED
@@ -23,8 +23,14 @@ export declare function narrationText(step: Step, caption: string): string;
23
23
  export declare function speakerRoleAt(project: Project, scenarioId: string, index: number): string | null;
24
24
  /** 音频片段的键:声音指纹 + 规整后的朗读文字(空白合并)。 */
25
25
  export declare function clipKey(fingerprint: string, text: string): string;
26
- /** 某个角色(null = 旁白)用哪个声音指纹;角色没有单独的声音时用旁白的。 */
26
+ /** 某个角色(null = 旁白)的声音;传文字时优先该语言索引中的片段覆盖,再用角色 / 旁白指纹。 */
27
27
  export declare function voiceFingerprint(voices: {
28
28
  narrator: string | null;
29
29
  roles: Record<string, string>;
30
- }, roleId: string | null): string | null;
30
+ overrides?: Record<string, string>;
31
+ }, roleId: string | null, text?: string): string | null;
32
+ /**
33
+ * 托管朗读的计费字数(D85,与 Cloud 一致):规整空白后的朗读文字按 Array.from 计(一个 emoji、一个汉字都算 1 个字)。
34
+ * 看板的“约 X 字”、`joplo voice --dry-run` 的估算与服务端的扣费用同一个算法。
35
+ */
36
+ export declare function spokenChars(text: string): number;
package/dist/voice.js CHANGED
@@ -73,7 +73,19 @@ export function clipKey(fingerprint, text) {
73
73
  const s = `${fingerprint}\n${text.replace(/\s+/g, ' ').trim()}`;
74
74
  return `c${cyrb53(s, 1).toString(16).padStart(14, '0')}${cyrb53(s, 7).toString(16).padStart(14, '0')}`;
75
75
  }
76
- /** 某个角色(null = 旁白)用哪个声音指纹;角色没有单独的声音时用旁白的。 */
77
- export function voiceFingerprint(voices, roleId) {
76
+ /** 某个角色(null = 旁白)的声音;传文字时优先该语言索引中的片段覆盖,再用角色 / 旁白指纹。 */
77
+ export function voiceFingerprint(voices, roleId, text) {
78
+ if (text !== undefined) {
79
+ const override = voices.overrides?.[clipKey(roleId ?? '', text)];
80
+ if (override)
81
+ return override;
82
+ }
78
83
  return (roleId ? voices.roles[roleId] : undefined) ?? voices.narrator;
79
84
  }
85
+ /**
86
+ * 托管朗读的计费字数(D85,与 Cloud 一致):规整空白后的朗读文字按 Array.from 计(一个 emoji、一个汉字都算 1 个字)。
87
+ * 看板的“约 X 字”、`joplo voice --dry-run` 的估算与服务端的扣费用同一个算法。
88
+ */
89
+ export function spokenChars(text) {
90
+ return Array.from(text.replace(/\s+/g, ' ').trim()).length;
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joplo-app/core",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "Joplo 编译器、校验器与播放器(IR v2)",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@joplo-app/kit": "0.2.17",
22
+ "@joplo-app/kit": "0.2.18",
23
23
  "elkjs": "0.12.1",
24
24
  "zod": "4.6.7"
25
25
  },