@joplo-app/core 0.2.16 → 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/pace.js CHANGED
@@ -59,3 +59,19 @@ export function stepDwell(o) {
59
59
  const streamed = longest ? longest + Math.max(MIN_DWELL / speed, read / 2) : 0;
60
60
  return Math.round(Math.max(read, cam, dots, streamed));
61
61
  }
62
+ /** 朗读估算(旁白 / 台词):中日韩约每秒 4.5 字、拉丁文字约每秒 13 个非空白字符(约 2.5 词),读完再留 0.45 秒换气。 */
63
+ export const VOICE_CJK_MS = 220;
64
+ export const VOICE_LATIN_MS = 75;
65
+ const VOICE_EST_BREATH_MS = 450;
66
+ /** 一段旁白大约读多久(毫秒,1×);没有文字时为 0。自动播放以真实读完为准,这个只用于封面、outline 与 check 的估算。 */
67
+ export function voiceMs(text, speed = 1) {
68
+ if (!text)
69
+ return 0;
70
+ let ms = 0;
71
+ for (const ch of text) {
72
+ if (/[\s\p{P}]/u.test(ch))
73
+ continue;
74
+ ms += (ch.codePointAt(0) ?? 0) > 0x2e80 ? VOICE_CJK_MS : VOICE_LATIN_MS;
75
+ }
76
+ return ms ? Math.round((ms + VOICE_EST_BREATH_MS) / (speed > 0 ? speed : 1)) : 0;
77
+ }
package/dist/player.js CHANGED
@@ -515,7 +515,8 @@ export function sceneOfTarget(project, scenario, state, target) {
515
515
  export function cameraAt(project, scenarioId, position) {
516
516
  const sc = project.scenarios[scenarioId];
517
517
  const perLayer = {};
518
- let directorLayer = layersOf(project, scenarioId)[0]?.id ?? PAGE_LAYER;
518
+ const layers = layersOf(project, scenarioId);
519
+ let directorLayer = (sc?.initial.layer && layers.some((l) => l.id === sc.initial.layer) ? sc.initial.layer : layers[0]?.id) ?? PAGE_LAYER;
519
520
  if (!sc)
520
521
  return { directorLayer, perLayer };
521
522
  const n = Math.max(0, Math.min(position, sc.steps.length));
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";
@@ -669,11 +670,21 @@ export declare const Issue: z.ZodObject<{
669
670
  refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
670
671
  source: z.ZodOptional<z.ZodString>;
671
672
  }, z.core.$strict>;
672
- /** 朗读配置(D74,来自 config({ voice })):只在 dev / review IR 里,发布站去掉。 */
673
+ /** 作者内容多语言(D84):default 是原文的语言,locales 第一个就是它。 */
674
+ export declare const ContentI18nSchema: z.ZodObject<{
675
+ default: z.ZodString;
676
+ locales: z.ZodArray<z.ZodString>;
677
+ messages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
678
+ stale: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
679
+ }, z.core.$strict>;
673
680
  export declare const VoiceConfig: z.ZodObject<{
674
681
  profile: z.ZodOptional<z.ZodString>;
675
682
  narrator: z.ZodOptional<z.ZodString>;
676
683
  roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
684
+ locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
685
+ narrator: z.ZodOptional<z.ZodString>;
686
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
687
+ }, z.core.$strict>>>;
677
688
  }, z.core.$strict>;
678
689
  /**
679
690
  * 发布站带上的朗读音频(D74,joplo build 写入):voices 是每个声音的指纹(旁白与各角色),
@@ -683,6 +694,12 @@ export declare const VoiceIndex: z.ZodObject<{
683
694
  narrator: z.ZodNullable<z.ZodString>;
684
695
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
685
696
  clips: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
697
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
698
+ locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
699
+ narrator: z.ZodNullable<z.ZodString>;
700
+ roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
701
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
702
+ }, z.core.$strict>>>;
686
703
  }, z.core.$strict>;
687
704
  export declare const Project: z.ZodObject<{
688
705
  schemaVersion: z.ZodLiteral<2>;
@@ -694,11 +711,27 @@ export declare const Project: z.ZodObject<{
694
711
  profile: z.ZodOptional<z.ZodString>;
695
712
  narrator: z.ZodOptional<z.ZodString>;
696
713
  roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
714
+ locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
715
+ narrator: z.ZodOptional<z.ZodString>;
716
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
717
+ }, z.core.$strict>>>;
697
718
  }, z.core.$strict>>;
698
719
  voiceIndex: z.ZodOptional<z.ZodObject<{
699
720
  narrator: z.ZodNullable<z.ZodString>;
700
721
  roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
701
722
  clips: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
723
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
724
+ locales: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
725
+ narrator: z.ZodNullable<z.ZodString>;
726
+ roles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
727
+ overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
728
+ }, z.core.$strict>>>;
729
+ }, z.core.$strict>>;
730
+ i18n: z.ZodOptional<z.ZodObject<{
731
+ default: z.ZodString;
732
+ locales: z.ZodArray<z.ZodString>;
733
+ messages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
734
+ stale: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
702
735
  }, z.core.$strict>>;
703
736
  themes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
704
737
  mode: z.ZodEnum<{
@@ -741,10 +774,10 @@ export declare const Project: z.ZodObject<{
741
774
  title: z.ZodString;
742
775
  dimension: z.ZodEnum<{
743
776
  main: "main";
777
+ async: "async";
744
778
  input: "input";
745
779
  permission: "permission";
746
780
  lifecycle: "lifecycle";
747
- async: "async";
748
781
  interrupt: "interrupt";
749
782
  conflict: "conflict";
750
783
  consistency: "consistency";
@@ -768,11 +801,11 @@ export declare const Project: z.ZodObject<{
768
801
  routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
769
802
  coverage: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
770
803
  status: z.ZodEnum<{
804
+ expressed: "expressed";
771
805
  undecided: "undecided";
772
806
  missing: "missing";
773
807
  not_applicable: "not_applicable";
774
808
  excluded: "excluded";
775
- expressed: "expressed";
776
809
  }>;
777
810
  scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
778
811
  reason: z.ZodOptional<z.ZodString>;
@@ -787,14 +820,14 @@ export declare const Project: z.ZodObject<{
787
820
  role: z.ZodOptional<z.ZodString>;
788
821
  icon: z.ZodOptional<z.ZodEnum<{
789
822
  terminal: "terminal";
790
- data: "data";
791
- desktop: "desktop";
792
- mobile: "mobile";
793
823
  window: "window";
794
824
  browser: "browser";
825
+ mobile: "mobile";
826
+ desktop: "desktop";
795
827
  chat: "chat";
796
828
  agent: "agent";
797
829
  server: "server";
830
+ data: "data";
798
831
  email: "email";
799
832
  doc: "doc";
800
833
  flow: "flow";
@@ -830,8 +863,8 @@ export declare const Project: z.ZodObject<{
830
863
  route: z.ZodString;
831
864
  name: z.ZodString;
832
865
  viewport: z.ZodDefault<z.ZodEnum<{
833
- desktop: "desktop";
834
866
  mobile: "mobile";
867
+ desktop: "desktop";
835
868
  }>>;
836
869
  root: z.ZodType<SceneNode, unknown, z.core.$ZodTypeInternals<SceneNode, unknown>>;
837
870
  layer: z.ZodOptional<z.ZodString>;
@@ -857,14 +890,15 @@ export declare const Project: z.ZodObject<{
857
890
  ui: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
858
891
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
859
892
  inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
893
+ layer: z.ZodOptional<z.ZodString>;
860
894
  }, z.core.$strict>;
861
895
  steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
862
896
  id: z.ZodString;
863
897
  key: z.ZodOptional<z.ZodString>;
864
898
  kind: z.ZodEnum<{
865
899
  user: "user";
866
- system: "system";
867
900
  card: "card";
901
+ system: "system";
868
902
  }>;
869
903
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
870
904
  type: z.ZodLiteral<"click">;
@@ -900,11 +934,11 @@ export declare const Project: z.ZodObject<{
900
934
  captionAuto: z.ZodOptional<z.ZodObject<{
901
935
  kind: z.ZodEnum<{
902
936
  check: "check";
903
- click: "click";
904
937
  type: "type";
938
+ click: "click";
905
939
  select: "select";
906
- press: "press";
907
940
  back: "back";
941
+ press: "press";
908
942
  uncheck: "uncheck";
909
943
  switch_on: "switch_on";
910
944
  switch_off: "switch_off";
@@ -975,9 +1009,9 @@ export declare const Project: z.ZodObject<{
975
1009
  marks: z.ZodDefault<z.ZodArray<z.ZodObject<{
976
1010
  target: z.ZodString;
977
1011
  kind: z.ZodEnum<{
1012
+ box: "box";
978
1013
  circle: "circle";
979
1014
  underline: "underline";
980
- box: "box";
981
1015
  arrow: "arrow";
982
1016
  }>;
983
1017
  note: z.ZodOptional<z.ZodString>;
@@ -994,8 +1028,8 @@ export declare const Project: z.ZodObject<{
994
1028
  target: z.ZodString;
995
1029
  text: z.ZodString;
996
1030
  side: z.ZodOptional<z.ZodEnum<{
997
- top: "top";
998
1031
  right: "right";
1032
+ top: "top";
999
1033
  bottom: "bottom";
1000
1034
  left: "left";
1001
1035
  }>>;
@@ -1043,3 +1077,4 @@ export type Cue = z.infer<typeof Cue>;
1043
1077
  export type Callout = z.infer<typeof Callout>;
1044
1078
  export type VoiceConfig = z.infer<typeof VoiceConfig>;
1045
1079
  export type VoiceIndex = z.infer<typeof VoiceIndex>;
1080
+ export type ContentI18nIR = z.infer<typeof ContentI18nSchema>;
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(''),
@@ -275,11 +277,25 @@ export const Issue = z.strictObject({
275
277
  refs: z.array(z.string()).default([]),
276
278
  source: Source,
277
279
  });
278
- /** 朗读配置(D74,来自 config({ voice })):只在 dev / review IR 里,发布站去掉。 */
280
+ /** 作者内容多语言(D84):default 是原文的语言,locales 第一个就是它。 */
281
+ export const ContentI18nSchema = z.strictObject({
282
+ default: z.string().min(1),
283
+ locales: z.array(z.string().min(1)).min(1),
284
+ /** 语言 → 原文 → 译文(不含空译文)。 */
285
+ messages: z.record(z.string(), z.record(z.string(), z.string().min(1))).default({}),
286
+ /** 每种语言里原文改过、旧译文还在的条数(看板菜单显示“过期”);只在 dev IR。 */
287
+ stale: z.record(z.string(), z.number().int().nonnegative()).optional(),
288
+ });
289
+ /** 朗读配置(D74,来自 config({ voice })):只在 dev / review IR 里,发布站去掉。locales(D84):按内容语言覆盖旁白与角色的音色。 */
290
+ const VoiceVoices = z.strictObject({
291
+ narrator: z.string().min(1).optional(),
292
+ roles: z.record(z.string(), z.string().min(1)).optional(),
293
+ });
279
294
  export const VoiceConfig = z.strictObject({
280
295
  profile: z.string().min(1).optional(),
281
296
  narrator: z.string().min(1).optional(),
282
297
  roles: z.record(z.string(), z.string().min(1)).optional(),
298
+ locales: z.record(z.string(), VoiceVoices).optional(),
283
299
  });
284
300
  /**
285
301
  * 发布站带上的朗读音频(D74,joplo build 写入):voices 是每个声音的指纹(旁白与各角色),
@@ -289,6 +305,10 @@ export const VoiceIndex = z.strictObject({
289
305
  narrator: z.string().min(1).nullable(),
290
306
  roles: z.record(z.string(), z.string().min(1)).default({}),
291
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(),
310
+ /** 内容语言(D84)→ 这种语言的旁白与角色指纹;没有的语言用上面的默认声音。 */
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(),
292
312
  });
293
313
  export const Project = z.strictObject({
294
314
  schemaVersion: z.literal(SCHEMA_VERSION),
@@ -300,6 +320,8 @@ export const Project = z.strictObject({
300
320
  autoFocus: z.boolean().optional(),
301
321
  voiceConfig: VoiceConfig.optional(),
302
322
  voiceIndex: VoiceIndex.optional(),
323
+ /** 作者内容多语言(D84):只有 config 写了 locales 才有。messages 只含非默认语言、这份 IR 用得到的译文;stale 只在 dev IR。 */
324
+ i18n: ContentI18nSchema.optional(),
303
325
  /** 作者主题(D51):主题名 → CSS 原文(themes/<name>.css);渲染时自动限定在舞台范围内。发布站同样打包。 */
304
326
  themes: z.record(z.string(), z.string()).default({}),
305
327
  /** dev = 含全部方案(本地看板);publish = 只含选定方案,且去掉创作侧信息(D33);review = 评审版:全部方案,同样去掉创作侧信息(D63)。 */
package/dist/scope.js CHANGED
@@ -8,6 +8,7 @@
8
8
  * - 范围外的分叉去掉;规则、情况、问题只留范围内功能(规则、问题再按方案过滤);项目说明去掉(常常概述所有功能),项目名保留。
9
9
  * dev、publish、review 三种 IR 都能裁剪:share 用它裁剪发布 IR(上传的文件)和 dev IR(评审清单、预览图)。
10
10
  */
11
+ import { pruneMessages } from "./content-i18n.js";
11
12
  import { orderedFeatures } from "./features.js";
12
13
  import { JoploError } from "./result.js";
13
14
  export const hasScope = (r) => !!r && ((r.scenarios?.length ?? 0) > 0 || (r.features?.length ?? 0) > 0);
@@ -210,7 +211,14 @@ export function scopeProject(project, scenarioIds, mode = project.mode === 'revi
210
211
  const featureIds = project.featureIds?.filter((id) => F.has(id));
211
212
  const inF = (x) => F.has(x.featureId) && (x.optionId === undefined || O.has(x.optionId));
212
213
  const roleIds = new Set(Object.values(features).flatMap((f) => f.roles.map((r) => r.id).filter((r) => !!r)));
213
- const keepRoles = (v) => v && v.roles ? { ...v, roles: Object.fromEntries(Object.entries(v.roles).filter(([k]) => roleIds.has(k))) } : v;
214
+ const onlyRoles = (r) => Object.fromEntries(Object.entries(r).filter(([k]) => roleIds.has(k)));
215
+ const keepRoles = (v) => v && (v.roles || v.locales)
216
+ ? {
217
+ ...v,
218
+ ...(v.roles ? { roles: onlyRoles(v.roles) } : {}),
219
+ ...(v.locales ? { locales: Object.fromEntries(Object.entries(v.locales).map(([l, x]) => [l, x.roles ? { ...x, roles: onlyRoles(x.roles) } : x])) } : {}),
220
+ }
221
+ : v;
214
222
  const out = {
215
223
  ...project,
216
224
  // 项目说明常常概述所有功能:范围分享里不带;项目名保留(分享标题与页面标题要用,作者自己决定怎么起)
@@ -228,7 +236,8 @@ export function scopeProject(project, scenarioIds, mode = project.mode === 'revi
228
236
  ...(project.voiceIndex ? { voiceIndex: keepRoles(project.voiceIndex) } : {}),
229
237
  };
230
238
  const ids = Object.keys(scenarios);
231
- return { project: out, info: { key: scopeKey(ids, mode), scenarios: ids, features: Object.keys(features), borrowed: merged } };
239
+ // 译文只留范围内用得到的(D84):别的功能的文字不随范围分享出去
240
+ return { project: pruneMessages(out), info: { key: scopeKey(ids, mode), scenarios: ids, features: Object.keys(features), borrowed: merged } };
232
241
  }
233
242
  /** 一条借用的说明(英文,CLI 与看板共用)。 */
234
243
  export function borrowedLine(b) {
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.16",
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.16",
22
+ "@joplo-app/kit": "0.2.18",
23
23
  "elkjs": "0.12.1",
24
24
  "zod": "4.6.7"
25
25
  },