@joplo-app/core 0.5.0 → 0.6.0

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.
Files changed (65) hide show
  1. package/dist/agent-skill.d.ts +7 -7
  2. package/dist/agent-skill.js +28 -25
  3. package/dist/authoring-works.d.ts +8 -0
  4. package/dist/authoring-works.js +46 -0
  5. package/dist/catalog.d.ts +2 -0
  6. package/dist/compile.d.ts +6 -3
  7. package/dist/compile.js +415 -340
  8. package/dist/content-i18n.js +9 -9
  9. package/dist/embed.d.ts +5 -5
  10. package/dist/embed.js +7 -7
  11. package/dist/entries.d.ts +63 -0
  12. package/dist/entries.js +78 -0
  13. package/dist/feature-diff.d.ts +7 -7
  14. package/dist/feature-diff.js +18 -17
  15. package/dist/features.d.ts +3 -3
  16. package/dist/features.js +3 -3
  17. package/dist/focus-check.js +2 -2
  18. package/dist/focus.d.ts +1 -5
  19. package/dist/focus.js +13 -35
  20. package/dist/guide.js +156 -66
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +2 -0
  23. package/dist/load.js +42 -11
  24. package/dist/local-review-files.js +17 -4
  25. package/dist/local-review.d.ts +8 -7
  26. package/dist/local-review.js +7 -6
  27. package/dist/outline.d.ts +21 -13
  28. package/dist/outline.js +27 -32
  29. package/dist/pace.d.ts +3 -4
  30. package/dist/pace.js +3 -4
  31. package/dist/playback.d.ts +57 -0
  32. package/dist/playback.js +317 -0
  33. package/dist/player.d.ts +9 -195
  34. package/dist/player.js +8 -633
  35. package/dist/playground.d.ts +1 -1
  36. package/dist/playground.js +4 -4
  37. package/dist/plugins/compiler.d.ts +16 -0
  38. package/dist/plugins/compiler.js +48 -9
  39. package/dist/presentation.d.ts +73 -0
  40. package/dist/presentation.js +163 -0
  41. package/dist/publication.d.ts +8 -0
  42. package/dist/publication.js +45 -0
  43. package/dist/result.d.ts +1 -1
  44. package/dist/review.d.ts +18 -10
  45. package/dist/review.js +62 -23
  46. package/dist/runtime.d.ts +2 -0
  47. package/dist/runtime.js +2 -0
  48. package/dist/scene-query.d.ts +77 -0
  49. package/dist/scene-query.js +246 -0
  50. package/dist/schema-issues.js +1 -1
  51. package/dist/schema.d.ts +108 -76
  52. package/dist/schema.js +48 -36
  53. package/dist/scope.d.ts +9 -9
  54. package/dist/scope.js +82 -49
  55. package/dist/selection.d.ts +1 -1
  56. package/dist/sequencing.d.ts +6 -0
  57. package/dist/sequencing.js +21 -0
  58. package/dist/step-plan.d.ts +55 -0
  59. package/dist/step-plan.js +90 -0
  60. package/dist/traits.d.ts +10 -0
  61. package/dist/traits.js +3 -0
  62. package/dist/validate.d.ts +1 -1
  63. package/dist/validate.js +75 -65
  64. package/dist/voice.js +2 -1
  65. package/package.json +15 -3
package/dist/schema.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ElementTraits } from '@joplo-app/kit/plugin';
2
2
  /**
3
- * Joplo IR(schemaVersion 2):由 TSX 源文件编译得到的中间表示,不是作者直接编辑的格式。
3
+ * Joplo IR(schemaVersion 3):由 TSX 源文件编译得到的中间表示,不是作者直接编辑的格式。
4
4
  * 权威源是项目文件夹里的 TSX/TS 文件(ADR-0002);渲染器、播放器、校验器、构建只消费这里的 IR。
5
5
  *
6
6
  * 带 `source` 的对象记录其来源 `相对路径:行:列`,用于选中元素、诊断定位,让 Agent 只读写那一处。
@@ -9,7 +9,7 @@ import { z } from 'zod';
9
9
  /** 层级标签的预设图标(标签压窄时靠它认出是哪一层)。不写时:手机视口 mobile,其余 window。 */
10
10
  export declare const LAYER_ICONS: readonly ["window", "browser", "mobile", "desktop", "terminal", "chat", "agent", "server", "data", "email", "doc", "flow"];
11
11
  export type LayerIcon = (typeof LAYER_ICONS)[number];
12
- export declare const SCHEMA_VERSION: 2;
12
+ export declare const SCHEMA_VERSION: 3;
13
13
  /** 作者可写的 ID(对象键、元素 id)。 */
14
14
  export declare const Id: z.ZodString;
15
15
  /** 编译器生成的限定 ID,例如 `invite.happy`、`invite.a-modal@/members`。 */
@@ -69,7 +69,7 @@ export declare const SceneNode: z.ZodType<SceneNode>;
69
69
  /** 一个画面 = 某个方案上下文中的一个路径:布局 + 页面 + 堆叠进来的功能元素。 */
70
70
  export declare const Scene: z.ZodObject<{
71
71
  id: z.ZodString;
72
- optionId: z.ZodNullable<z.ZodString>;
72
+ workId: z.ZodNullable<z.ZodString>;
73
73
  route: z.ZodString;
74
74
  name: z.ZodString;
75
75
  viewport: z.ZodDefault<z.ZodEnum<{
@@ -429,7 +429,7 @@ export declare const Scenario: z.ZodObject<{
429
429
  }, z.core.$strict>>>;
430
430
  ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
431
431
  id: z.ZodString;
432
- optionId: z.ZodString;
432
+ workId: z.ZodString;
433
433
  name: z.ZodString;
434
434
  description: z.ZodDefault<z.ZodString>;
435
435
  caseIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -636,26 +636,6 @@ export declare const Route: z.ZodObject<{
636
636
  slots: z.ZodDefault<z.ZodArray<z.ZodString>>;
637
637
  source: z.ZodOptional<z.ZodString>;
638
638
  }, z.core.$strict>;
639
- export declare const Feature: z.ZodObject<{
640
- id: z.ZodString;
641
- name: z.ZodString;
642
- goal: z.ZodString;
643
- roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
644
- id: z.ZodOptional<z.ZodString>;
645
- name: z.ZodString;
646
- desc: z.ZodDefault<z.ZodString>;
647
- color: z.ZodString;
648
- }, z.core.$strict>>>;
649
- constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
650
- id: z.ZodString;
651
- text: z.ZodString;
652
- hard: z.ZodDefault<z.ZodBoolean>;
653
- }, z.core.$strict>>>;
654
- caseIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
655
- optionIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
656
- pick: z.ZodDefault<z.ZodNullable<z.ZodString>>;
657
- source: z.ZodOptional<z.ZodString>;
658
- }, z.core.$strict>;
659
639
  export declare const Case: z.ZodObject<{
660
640
  id: z.ZodString;
661
641
  featureId: z.ZodString;
@@ -694,6 +674,46 @@ export declare const Coverage: z.ZodObject<{
694
674
  declared: "declared";
695
675
  }>>;
696
676
  }, z.core.$strict>;
677
+ /** 功能是作品之上的评审层;评审信息按作品 id 存放。 */
678
+ export declare const Feature: z.ZodObject<{
679
+ id: z.ZodString;
680
+ name: z.ZodString;
681
+ goal: z.ZodString;
682
+ roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
683
+ id: z.ZodOptional<z.ZodString>;
684
+ name: z.ZodString;
685
+ desc: z.ZodDefault<z.ZodString>;
686
+ color: z.ZodString;
687
+ }, z.core.$strict>>>;
688
+ constraints: z.ZodDefault<z.ZodArray<z.ZodObject<{
689
+ id: z.ZodString;
690
+ text: z.ZodString;
691
+ hard: z.ZodDefault<z.ZodBoolean>;
692
+ }, z.core.$strict>>>;
693
+ caseIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
694
+ workIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
695
+ pick: z.ZodDefault<z.ZodNullable<z.ZodString>>;
696
+ alternatives: z.ZodRecord<z.ZodString, z.ZodObject<{
697
+ decisionFocus: z.ZodString;
698
+ tradeoffs: z.ZodArray<z.ZodString>;
699
+ coverage: z.ZodRecord<z.ZodString, z.ZodObject<{
700
+ status: z.ZodEnum<{
701
+ undecided: "undecided";
702
+ missing: "missing";
703
+ not_applicable: "not_applicable";
704
+ excluded: "excluded";
705
+ expressed: "expressed";
706
+ }>;
707
+ scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
708
+ reason: z.ZodOptional<z.ZodString>;
709
+ basis: z.ZodDefault<z.ZodEnum<{
710
+ derived: "derived";
711
+ declared: "declared";
712
+ }>>;
713
+ }, z.core.$strict>>;
714
+ }, z.core.$strict>>;
715
+ source: z.ZodOptional<z.ZodString>;
716
+ }, z.core.$strict>;
697
717
  export declare const FreeReaction: z.ZodObject<{
698
718
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
699
719
  type: z.ZodLiteral<"click">;
@@ -783,7 +803,8 @@ export declare const FreeReaction: z.ZodObject<{
783
803
  }, z.core.$strict>], "type">>>;
784
804
  source: z.ZodOptional<z.ZodString>;
785
805
  }, z.core.$strict>;
786
- export declare const Option: z.ZodObject<{
806
+ export declare const Work: z.ZodObject<{
807
+ sequencing: z.ZodOptional<z.ZodLiteral<"linear">>;
787
808
  free: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
788
809
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
789
810
  type: z.ZodLiteral<"click">;
@@ -874,28 +895,19 @@ export declare const Option: z.ZodObject<{
874
895
  source: z.ZodOptional<z.ZodString>;
875
896
  }, z.core.$strict>>>;
876
897
  id: z.ZodString;
877
- featureId: z.ZodString;
898
+ featureId: z.ZodOptional<z.ZodString>;
878
899
  key: z.ZodString;
879
- name: z.ZodString;
880
- idea: z.ZodString;
881
- decisionFocus: z.ZodDefault<z.ZodString>;
882
- tradeoffs: z.ZodDefault<z.ZodArray<z.ZodString>>;
883
- routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
884
- coverage: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
885
- status: z.ZodEnum<{
886
- undecided: "undecided";
887
- missing: "missing";
888
- not_applicable: "not_applicable";
889
- excluded: "excluded";
890
- expressed: "expressed";
891
- }>;
892
- scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
893
- reason: z.ZodOptional<z.ZodString>;
894
- basis: z.ZodDefault<z.ZodEnum<{
895
- derived: "derived";
896
- declared: "declared";
897
- }>>;
900
+ title: z.ZodString;
901
+ summary: z.ZodString;
902
+ audience: z.ZodOptional<z.ZodString>;
903
+ roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
904
+ id: z.ZodOptional<z.ZodString>;
905
+ name: z.ZodString;
906
+ desc: z.ZodDefault<z.ZodString>;
907
+ color: z.ZodString;
898
908
  }, z.core.$strict>>>;
909
+ draft: z.ZodOptional<z.ZodLiteral<true>>;
910
+ routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
899
911
  layers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
900
912
  title: z.ZodString;
901
913
  sceneId: z.ZodString;
@@ -922,7 +934,7 @@ export declare const RULE_CONFIRMATIONS: readonly ["pending", "confirmed", "conf
922
934
  export declare const Rule: z.ZodObject<{
923
935
  id: z.ZodString;
924
936
  featureId: z.ZodString;
925
- optionId: z.ZodOptional<z.ZodString>;
937
+ workId: z.ZodOptional<z.ZodString>;
926
938
  text: z.ZodString;
927
939
  origin: z.ZodEnum<{
928
940
  user: "user";
@@ -945,7 +957,7 @@ export declare const Rule: z.ZodObject<{
945
957
  export declare const Issue: z.ZodObject<{
946
958
  id: z.ZodString;
947
959
  featureId: z.ZodString;
948
- optionId: z.ZodOptional<z.ZodString>;
960
+ workId: z.ZodOptional<z.ZodString>;
949
961
  text: z.ZodString;
950
962
  severity: z.ZodDefault<z.ZodEnum<{
951
963
  blocker: "blocker";
@@ -998,7 +1010,7 @@ export declare const AudioRegionSchema: z.ZodObject<{
998
1010
  channels: z.ZodNumber;
999
1011
  }, z.core.$strict>;
1000
1012
  export declare const Project: z.ZodObject<{
1001
- schemaVersion: z.ZodLiteral<2>;
1013
+ schemaVersion: z.ZodLiteral<3>;
1002
1014
  name: z.ZodString;
1003
1015
  description: z.ZodDefault<z.ZodString>;
1004
1016
  theme: z.ZodDefault<z.ZodString>;
@@ -1084,6 +1096,15 @@ export declare const Project: z.ZodObject<{
1084
1096
  title: z.ZodString;
1085
1097
  version: z.ZodOptional<z.ZodString>;
1086
1098
  components: z.ZodRecord<z.ZodString, z.ZodObject<{
1099
+ label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
1100
+ inspect: z.ZodOptional<z.ZodArray<z.ZodObject<{
1101
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
1102
+ props: z.ZodArray<z.ZodString>;
1103
+ join: z.ZodOptional<z.ZodString>;
1104
+ values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>;
1105
+ flags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>;
1106
+ fallback: z.ZodOptional<z.ZodString>;
1107
+ }, z.core.$strict>>>;
1087
1108
  interactive: z.ZodOptional<z.ZodBoolean>;
1088
1109
  parent: z.ZodOptional<z.ZodString>;
1089
1110
  needsId: z.ZodOptional<z.ZodBoolean>;
@@ -1121,11 +1142,30 @@ export declare const Project: z.ZodObject<{
1121
1142
  hard: z.ZodDefault<z.ZodBoolean>;
1122
1143
  }, z.core.$strict>>>;
1123
1144
  caseIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1124
- optionIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1145
+ workIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1125
1146
  pick: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1147
+ alternatives: z.ZodRecord<z.ZodString, z.ZodObject<{
1148
+ decisionFocus: z.ZodString;
1149
+ tradeoffs: z.ZodArray<z.ZodString>;
1150
+ coverage: z.ZodRecord<z.ZodString, z.ZodObject<{
1151
+ status: z.ZodEnum<{
1152
+ undecided: "undecided";
1153
+ missing: "missing";
1154
+ not_applicable: "not_applicable";
1155
+ excluded: "excluded";
1156
+ expressed: "expressed";
1157
+ }>;
1158
+ scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1159
+ reason: z.ZodOptional<z.ZodString>;
1160
+ basis: z.ZodDefault<z.ZodEnum<{
1161
+ derived: "derived";
1162
+ declared: "declared";
1163
+ }>>;
1164
+ }, z.core.$strict>>;
1165
+ }, z.core.$strict>>;
1126
1166
  source: z.ZodOptional<z.ZodString>;
1127
1167
  }, z.core.$strict>>>;
1128
- featureIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
1168
+ entryIds: z.ZodArray<z.ZodString>;
1129
1169
  cases: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1130
1170
  id: z.ZodString;
1131
1171
  featureId: z.ZodString;
@@ -1148,7 +1188,8 @@ export declare const Project: z.ZodObject<{
1148
1188
  }>>;
1149
1189
  source: z.ZodOptional<z.ZodString>;
1150
1190
  }, z.core.$strict>>>;
1151
- options: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1191
+ works: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1192
+ sequencing: z.ZodOptional<z.ZodLiteral<"linear">>;
1152
1193
  free: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1153
1194
  action: z.ZodDiscriminatedUnion<[z.ZodObject<{
1154
1195
  type: z.ZodLiteral<"click">;
@@ -1239,28 +1280,19 @@ export declare const Project: z.ZodObject<{
1239
1280
  source: z.ZodOptional<z.ZodString>;
1240
1281
  }, z.core.$strict>>>;
1241
1282
  id: z.ZodString;
1242
- featureId: z.ZodString;
1283
+ featureId: z.ZodOptional<z.ZodString>;
1243
1284
  key: z.ZodString;
1244
- name: z.ZodString;
1245
- idea: z.ZodString;
1246
- decisionFocus: z.ZodDefault<z.ZodString>;
1247
- tradeoffs: z.ZodDefault<z.ZodArray<z.ZodString>>;
1248
- routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
1249
- coverage: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1250
- status: z.ZodEnum<{
1251
- undecided: "undecided";
1252
- missing: "missing";
1253
- not_applicable: "not_applicable";
1254
- excluded: "excluded";
1255
- expressed: "expressed";
1256
- }>;
1257
- scenarioIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1258
- reason: z.ZodOptional<z.ZodString>;
1259
- basis: z.ZodDefault<z.ZodEnum<{
1260
- derived: "derived";
1261
- declared: "declared";
1262
- }>>;
1285
+ title: z.ZodString;
1286
+ summary: z.ZodString;
1287
+ audience: z.ZodOptional<z.ZodString>;
1288
+ roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
1289
+ id: z.ZodOptional<z.ZodString>;
1290
+ name: z.ZodString;
1291
+ desc: z.ZodDefault<z.ZodString>;
1292
+ color: z.ZodString;
1263
1293
  }, z.core.$strict>>>;
1294
+ draft: z.ZodOptional<z.ZodLiteral<true>>;
1295
+ routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
1264
1296
  layers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1265
1297
  title: z.ZodString;
1266
1298
  sceneId: z.ZodString;
@@ -1285,7 +1317,7 @@ export declare const Project: z.ZodObject<{
1285
1317
  rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1286
1318
  id: z.ZodString;
1287
1319
  featureId: z.ZodString;
1288
- optionId: z.ZodOptional<z.ZodString>;
1320
+ workId: z.ZodOptional<z.ZodString>;
1289
1321
  text: z.ZodString;
1290
1322
  origin: z.ZodEnum<{
1291
1323
  user: "user";
@@ -1306,7 +1338,7 @@ export declare const Project: z.ZodObject<{
1306
1338
  }, z.core.$strict>>>;
1307
1339
  scenes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1308
1340
  id: z.ZodString;
1309
- optionId: z.ZodNullable<z.ZodString>;
1341
+ workId: z.ZodNullable<z.ZodString>;
1310
1342
  route: z.ZodString;
1311
1343
  name: z.ZodString;
1312
1344
  viewport: z.ZodDefault<z.ZodEnum<{
@@ -1335,7 +1367,7 @@ export declare const Project: z.ZodObject<{
1335
1367
  }, z.core.$strict>>>;
1336
1368
  ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
1337
1369
  id: z.ZodString;
1338
- optionId: z.ZodString;
1370
+ workId: z.ZodString;
1339
1371
  name: z.ZodString;
1340
1372
  description: z.ZodDefault<z.ZodString>;
1341
1373
  caseIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -1536,7 +1568,7 @@ export declare const Project: z.ZodObject<{
1536
1568
  issues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
1537
1569
  id: z.ZodString;
1538
1570
  featureId: z.ZodString;
1539
- optionId: z.ZodOptional<z.ZodString>;
1571
+ workId: z.ZodOptional<z.ZodString>;
1540
1572
  text: z.ZodString;
1541
1573
  severity: z.ZodDefault<z.ZodEnum<{
1542
1574
  blocker: "blocker";
@@ -1551,7 +1583,7 @@ export type Project = z.infer<typeof Project>;
1551
1583
  export type Route = z.infer<typeof Route>;
1552
1584
  export type Feature = z.infer<typeof Feature>;
1553
1585
  export type Case = z.infer<typeof Case>;
1554
- export type Option = z.infer<typeof Option>;
1586
+ export type Work = z.infer<typeof Work>;
1555
1587
  export type Coverage = z.infer<typeof Coverage>;
1556
1588
  export type Rule = z.infer<typeof Rule>;
1557
1589
  export type Issue = z.infer<typeof Issue>;
package/dist/schema.js CHANGED
@@ -1,6 +1,6 @@
1
- import { ElementTraitsSchema } from "./traits.js";
1
+ import { ElementTraitsSchema, PluginInspectFieldSchema, PluginTextSchema } from "./traits.js";
2
2
  /**
3
- * Joplo IR(schemaVersion 2):由 TSX 源文件编译得到的中间表示,不是作者直接编辑的格式。
3
+ * Joplo IR(schemaVersion 3):由 TSX 源文件编译得到的中间表示,不是作者直接编辑的格式。
4
4
  * 权威源是项目文件夹里的 TSX/TS 文件(ADR-0002);渲染器、播放器、校验器、构建只消费这里的 IR。
5
5
  *
6
6
  * 带 `source` 的对象记录其来源 `相对路径:行:列`,用于选中元素、诊断定位,让 Agent 只读写那一处。
@@ -16,7 +16,7 @@ const ScopeRule = z.lazy(() => z.strictObject({
16
16
  }));
17
17
  const SlotSpec = z.strictObject({ text: z.array(DataPath).optional(), scope: z.union([z.literal('global'), z.array(ScopeRule)]).optional() });
18
18
  const DataSpec = z.strictObject({ node: SlotSpec.optional(), step: SlotSpec.optional() });
19
- export const SCHEMA_VERSION = 2;
19
+ export const SCHEMA_VERSION = 3;
20
20
  /** 作者可写的 ID(对象键、元素 id)。 */
21
21
  export const Id = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, 'ID must start with a letter and contain only letters, digits, underscores, and hyphens');
22
22
  /** 编译器生成的限定 ID,例如 `invite.happy`、`invite.a-modal@/members`。 */
@@ -58,7 +58,7 @@ export const SceneNode = z.lazy(() => z.strictObject({
58
58
  export const Scene = z.strictObject({
59
59
  id: Qid,
60
60
  /** 方案上下文;`null` 表示发布视图(所有功能都取选定方案)。 */
61
- optionId: Qid.nullable(),
61
+ workId: Qid.nullable(),
62
62
  route: z.string().regex(/^\/[^\s]*$/),
63
63
  name: z.string().min(1),
64
64
  viewport: z.enum(['desktop', 'mobile']).default('desktop'),
@@ -173,7 +173,7 @@ export const Scenario = z.strictObject({
173
173
  media: MediaSnapshot.optional(),
174
174
  ext: z.record(z.string(), Json).optional(),
175
175
  id: Qid,
176
- optionId: Qid,
176
+ workId: Qid,
177
177
  name: z.string().min(1),
178
178
  description: z.string().default(''),
179
179
  caseIds: z.array(Qid).default([]),
@@ -202,19 +202,6 @@ export const Route = z.strictObject({
202
202
  slots: z.array(z.string()).default([]),
203
203
  source: Source,
204
204
  });
205
- export const Feature = z.strictObject({
206
- id: Id,
207
- name: z.string().min(1),
208
- goal: z.string().min(1),
209
- /** 角色(D56):id 来自 { 键: role('名字') } 写法,可被层级和过渡卡引用;旧的名字数组没有 id。color 已按顺序补齐。 */
210
- roles: z.array(z.strictObject({ id: Id.optional(), name: z.string().min(1), desc: z.string().default(''), color: z.string().min(1) })).default([]),
211
- constraints: z.array(z.strictObject({ id: Id, text: z.string().min(1), hard: z.boolean().default(false) })).default([]),
212
- caseIds: z.array(Qid).default([]),
213
- optionIds: z.array(Qid).default([]),
214
- /** 选定的方案;build 只发布它。 */
215
- pick: Qid.nullable().default(null),
216
- source: Source,
217
- });
218
205
  export const Case = z.strictObject({
219
206
  id: Qid,
220
207
  featureId: Id,
@@ -232,20 +219,46 @@ export const Coverage = z.strictObject({
232
219
  /** derived = 编译器根据场景推导;declared = 作者在源文件中声明。 */
233
220
  basis: z.enum(['derived', 'declared']).default('declared'),
234
221
  });
222
+ /** 功能是作品之上的评审层;评审信息按作品 id 存放。 */
223
+ export const Feature = z.strictObject({
224
+ id: Id,
225
+ name: z.string().min(1),
226
+ goal: z.string().min(1),
227
+ /** 角色(D56):id 来自 { 键: role('名字') } 写法,可被层级和过渡卡引用;旧的名字数组没有 id。color 已按顺序补齐。 */
228
+ roles: z.array(z.strictObject({ id: Id.optional(), name: z.string().min(1), desc: z.string().default(''), color: z.string().min(1) })).default([]),
229
+ constraints: z.array(z.strictObject({ id: Id, text: z.string().min(1), hard: z.boolean().default(false) })).default([]),
230
+ caseIds: z.array(Qid).default([]),
231
+ workIds: z.array(Qid).default([]),
232
+ /** 选定的方案;build 只发布它。 */
233
+ pick: Qid.nullable().default(null),
234
+ alternatives: z.record(Qid, z.strictObject({
235
+ decisionFocus: z.string(),
236
+ tradeoffs: z.array(z.string()),
237
+ coverage: z.record(Qid, Coverage),
238
+ })),
239
+ source: Source,
240
+ }).superRefine((f, ctx) => {
241
+ const keys = Object.keys(f.alternatives);
242
+ if (new Set(f.workIds).size !== f.workIds.length || keys.length !== f.workIds.length || keys.some(id => !f.workIds.includes(id)))
243
+ ctx.addIssue({ code: 'custom', path: ['alternatives'], message: 'alternatives must list every workId exactly once' });
244
+ });
235
245
  export const FreeReaction = z.strictObject({ action: Action, effects: z.array(Effect).default([]), source: Source });
236
- export const Option = z.strictObject({
246
+ export const Work = z.strictObject({
247
+ /** 共享切片解析器在全部切片使用 chapter() 时写入;Entry.sequencing 消费,公开保留;缺省 independent。 */
248
+ sequencing: z.literal('linear').optional(),
237
249
  free: z.record(Id, FreeReaction).optional(),
238
250
  id: Qid,
239
- featureId: Id,
251
+ featureId: Id.optional(),
240
252
  /** 文件名,例如 `a-modal`。 */
241
253
  key: Id,
242
- name: z.string().min(1),
243
- idea: z.string().min(1),
244
- decisionFocus: z.string().default(''),
245
- tradeoffs: z.array(z.string()).default([]),
254
+ title: z.string().min(1),
255
+ summary: z.string().min(1),
256
+ audience: z.string().min(1).optional(),
257
+ /** 独立作品声明角色;功能下面的作品保持为空,通过 rolesOf 继承功能角色。 */
258
+ roles: Feature.shape.roles,
259
+ draft: z.literal(true).optional(),
246
260
  /** 该方案触及的路径(堆叠或新增)。 */
247
261
  routes: z.array(z.string()).default([]),
248
- coverage: z.record(Qid, Coverage).default({}),
249
262
  /** 层级(视角):键 → 标题与这一层自己的画面(完全独立的页面)。演示信息,发布站保留。 */
250
263
  /** icon:作者显式选的预设图标(层级标签用);不写时由 layersOf 按视口补默认。 */
251
264
  layers: z.record(Id, z.strictObject({ title: z.string().min(1), sceneId: Qid, role: Id.optional(), icon: z.enum(LAYER_ICONS).optional() })).default({}),
@@ -256,7 +269,7 @@ export const RULE_CONFIRMATIONS = ['pending', 'confirmed', 'conflict', 'out_of_s
256
269
  export const Rule = z.strictObject({
257
270
  id: Qid,
258
271
  featureId: Id,
259
- optionId: Qid.optional(),
272
+ workId: Qid.optional(),
260
273
  text: z.string().min(1),
261
274
  origin: z.enum(RULE_ORIGINS),
262
275
  confirmation: z.enum(RULE_CONFIRMATIONS).default('pending'),
@@ -269,7 +282,7 @@ export const Rule = z.strictObject({
269
282
  export const Issue = z.strictObject({
270
283
  id: Qid,
271
284
  featureId: Id,
272
- optionId: Qid.optional(),
285
+ workId: Qid.optional(),
273
286
  text: z.string().min(1),
274
287
  severity: z.enum(['blocker', 'major', 'minor']).default('major'),
275
288
  refs: z.array(z.string()).default([]),
@@ -333,7 +346,7 @@ export const Project = z.strictObject({
333
346
  id: z.string().min(1),
334
347
  title: z.string(),
335
348
  version: z.string().optional(),
336
- components: z.record(z.string(), z.strictObject({ interactive: z.boolean().optional(), parent: z.string().optional(), needsId: z.boolean().optional(), selfEvident: z.boolean().optional(), traits: ElementTraitsSchema.optional() })),
349
+ components: z.record(z.string(), z.strictObject({ label: PluginTextSchema.optional(), inspect: z.array(PluginInspectFieldSchema).optional(), interactive: z.boolean().optional(), parent: z.string().optional(), needsId: z.boolean().optional(), selfEvident: z.boolean().optional(), traits: ElementTraitsSchema.optional() })),
337
350
  })).optional(),
338
351
  /** 作者主题(D51):主题名 → CSS 原文(themes/<name>.css);渲染时自动限定在舞台范围内。发布站同样打包。 */
339
352
  themes: z.record(z.string(), z.string()).default({}),
@@ -341,18 +354,17 @@ export const Project = z.strictObject({
341
354
  mode: z.enum(['dev', 'publish', 'review']),
342
355
  routes: z.record(z.string(), Route).default({}),
343
356
  features: z.record(Id, Feature).default({}),
344
- /** 编译器决定的演示顺序,发布时保留。旧 IR 可省略,读取时沿用其已有顺序。 */
345
- featureIds: z.array(Id).optional(),
357
+ /** 编译器决定的条目顺序,发布时保留;每个条目恰好一次。 */
358
+ entryIds: z.array(Id),
346
359
  cases: z.record(Qid, Case).default({}),
347
- options: z.record(Qid, Option).default({}),
360
+ works: z.record(Qid, Work).default({}),
348
361
  rules: z.record(Qid, Rule).default({}),
349
362
  scenes: z.record(Qid, Scene).default({}),
350
363
  scenarios: z.record(Qid, Scenario).default({}),
351
364
  issues: z.record(Qid, Issue).default({}),
352
365
  }).superRefine((p, ctx) => {
353
- if (!p.featureIds)
354
- return;
355
- const ids = new Set(p.featureIds);
356
- if (ids.size !== p.featureIds.length || ids.size !== Object.keys(p.features).length || p.featureIds.some(id => !p.features[id]))
357
- ctx.addIssue({ code: 'custom', path: ['featureIds'], message: 'featureIds must list every feature exactly once' });
366
+ const entries = [...Object.keys(p.features), ...Object.values(p.works).filter(w => !w.featureId).map(w => w.id)];
367
+ const ids = new Set(p.entryIds);
368
+ if (ids.size !== p.entryIds.length || ids.size !== entries.length || entries.some(id => !ids.has(id)))
369
+ ctx.addIssue({ code: 'custom', path: ['entryIds'], message: 'entryIds must list every entry exactly once' });
358
370
  });
package/dist/scope.d.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  import type { Project, Step } from './schema.js';
2
- /** 作者要分享的范围:场景 id 与功能 id(功能 = 这个功能选定方案的全部场景;评审版是全部方案的场景)。 */
2
+ /** 作者要分享的范围:场景 id 与首页条目 id(功能取选定作品;评审版取全部作品;独立作品取自身)。 */
3
3
  export type ScopeRequest = {
4
4
  scenarios?: readonly string[];
5
- features?: readonly string[];
5
+ entryIds?: readonly string[];
6
6
  };
7
7
  /** publish = 只发布选定方案;review = 评审版(全部方案)。 */
8
8
  export type ScopeMode = 'publish' | 'review';
9
9
  /** 因为被范围内步骤引用而带上的别的功能的内容(只给作者看:终端输出、看板浮层,不进分享)。 */
10
10
  export type ScopeBorrowed = {
11
11
  kind: 'element';
12
- featureId: string;
13
- featureName: string;
14
- optionId: string;
12
+ entryId: string;
13
+ entryTitle: string;
14
+ workId: string;
15
15
  elementId: string;
16
16
  route: string;
17
17
  refs: string[];
18
18
  scenarios: string[];
19
19
  } | {
20
20
  kind: 'page';
21
- featureId: string;
22
- featureName: string;
23
- optionId: string;
21
+ entryId: string;
22
+ entryTitle: string;
23
+ workId: string;
24
24
  route: string;
25
25
  scenarios: string[];
26
26
  };
@@ -28,7 +28,7 @@ export type ScopeInfo = {
28
28
  /** `.joplo/cloud.json` 里这个范围的键:排序后的场景 id,用逗号连接;评审版前缀 `review:`。 */
29
29
  key: string;
30
30
  scenarios: string[];
31
- features: string[];
31
+ entryIds: string[];
32
32
  borrowed: ScopeBorrowed[];
33
33
  };
34
34
  export declare const hasScope: (r: ScopeRequest | undefined) => r is ScopeRequest;