@gameslate/sdk 0.3.11 → 0.3.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/lib/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from './assets.js';
16
16
  export * from './plugins-api.js';
17
17
  export * from './signature.js';
18
18
  export * from './n64-address.js';
19
+ export * from './game-support.js';
package/lib/index.js CHANGED
@@ -16,3 +16,4 @@ export * from './assets.js';
16
16
  export * from './plugins-api.js';
17
17
  export * from './signature.js';
18
18
  export * from './n64-address.js';
19
+ export * from './game-support.js';
package/lib/pack.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare const PackDataSchema: z.ZodObject<{
16
16
  category: z.ZodOptional<z.ZodString>;
17
17
  short: z.ZodOptional<z.ZodString>;
18
18
  source: z.ZodOptional<z.ZodString>;
19
+ count: z.ZodOptional<z.ZodString>;
19
20
  }, "strict", z.ZodTypeAny, {
20
21
  label: string;
21
22
  id: string;
@@ -23,6 +24,7 @@ export declare const PackDataSchema: z.ZodObject<{
23
24
  source?: string | undefined;
24
25
  category?: string | undefined;
25
26
  short?: string | undefined;
27
+ count?: string | undefined;
26
28
  }, {
27
29
  label: string;
28
30
  id: string;
@@ -30,6 +32,7 @@ export declare const PackDataSchema: z.ZodObject<{
30
32
  source?: string | undefined;
31
33
  category?: string | undefined;
32
34
  short?: string | undefined;
35
+ count?: string | undefined;
33
36
  }>, "many">;
34
37
  counters: z.ZodArray<z.ZodObject<{
35
38
  id: z.ZodString;
@@ -38,13 +41,13 @@ export declare const PackDataSchema: z.ZodObject<{
38
41
  max: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
39
42
  display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
40
43
  role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
41
- format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
44
+ format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
42
45
  }, "strict", z.ZodTypeAny, {
43
46
  label: string;
44
47
  id: string;
45
48
  icon?: string | undefined;
46
49
  max?: string | number | undefined;
47
- format?: "number" | "percent" | undefined;
50
+ format?: "number" | "duration" | "percent" | undefined;
48
51
  display?: Record<string, string> | undefined;
49
52
  role?: "keys" | "health" | "magic" | "armor" | undefined;
50
53
  }, {
@@ -52,7 +55,7 @@ export declare const PackDataSchema: z.ZodObject<{
52
55
  id: string;
53
56
  icon?: string | undefined;
54
57
  max?: string | number | undefined;
55
- format?: "number" | "percent" | undefined;
58
+ format?: "number" | "duration" | "percent" | undefined;
56
59
  display?: Record<string, string> | undefined;
57
60
  role?: "keys" | "health" | "magic" | "armor" | undefined;
58
61
  }>, "many">;
@@ -80,16 +83,19 @@ export declare const PackDataSchema: z.ZodObject<{
80
83
  id: z.ZodString;
81
84
  title: z.ZodString;
82
85
  counters: z.ZodArray<z.ZodString, "many">;
86
+ hideMissing: z.ZodOptional<z.ZodBoolean>;
83
87
  }, "strict", z.ZodTypeAny, {
84
88
  id: string;
85
89
  title: string;
86
90
  counters: string[];
87
91
  kind: "counters";
92
+ hideMissing?: boolean | undefined;
88
93
  }, {
89
94
  id: string;
90
95
  title: string;
91
96
  counters: string[];
92
97
  kind: "counters";
98
+ hideMissing?: boolean | undefined;
93
99
  }>]>, "many">;
94
100
  missions: z.ZodArray<z.ZodObject<{
95
101
  id: z.ZodString;
@@ -459,7 +465,7 @@ export declare const PackDataSchema: z.ZodObject<{
459
465
  id: string;
460
466
  icon?: string | undefined;
461
467
  max?: string | number | undefined;
462
- format?: "number" | "percent" | undefined;
468
+ format?: "number" | "duration" | "percent" | undefined;
463
469
  display?: Record<string, string> | undefined;
464
470
  role?: "keys" | "health" | "magic" | "armor" | undefined;
465
471
  }[];
@@ -471,6 +477,7 @@ export declare const PackDataSchema: z.ZodObject<{
471
477
  source?: string | undefined;
472
478
  category?: string | undefined;
473
479
  short?: string | undefined;
480
+ count?: string | undefined;
474
481
  }[];
475
482
  chips: {
476
483
  label: string;
@@ -489,6 +496,7 @@ export declare const PackDataSchema: z.ZodObject<{
489
496
  title: string;
490
497
  counters: string[];
491
498
  kind: "counters";
499
+ hideMissing?: boolean | undefined;
492
500
  })[];
493
501
  missions: {
494
502
  id: string;
@@ -578,7 +586,7 @@ export declare const PackDataSchema: z.ZodObject<{
578
586
  id: string;
579
587
  icon?: string | undefined;
580
588
  max?: string | number | undefined;
581
- format?: "number" | "percent" | undefined;
589
+ format?: "number" | "duration" | "percent" | undefined;
582
590
  display?: Record<string, string> | undefined;
583
591
  role?: "keys" | "health" | "magic" | "armor" | undefined;
584
592
  }[];
@@ -590,6 +598,7 @@ export declare const PackDataSchema: z.ZodObject<{
590
598
  source?: string | undefined;
591
599
  category?: string | undefined;
592
600
  short?: string | undefined;
601
+ count?: string | undefined;
593
602
  }[];
594
603
  chips: {
595
604
  label: string;
@@ -608,6 +617,7 @@ export declare const PackDataSchema: z.ZodObject<{
608
617
  title: string;
609
618
  counters: string[];
610
619
  kind: "counters";
620
+ hideMissing?: boolean | undefined;
611
621
  })[];
612
622
  missions: {
613
623
  id: string;
@@ -704,6 +714,15 @@ export declare const PackDataSchema: z.ZodObject<{
704
714
  unitsPerMeter: number;
705
715
  northIsPositiveZ?: boolean | undefined;
706
716
  }>;
717
+ /** Panels the game leaves out because they wouldn't help its player. */
718
+ panels: z.ZodOptional<z.ZodObject<{
719
+ /** false: play has no space to map (a single-screen puzzle); the map panel isn't offered */
720
+ map: z.ZodOptional<z.ZodBoolean>;
721
+ }, "strip", z.ZodTypeAny, {
722
+ map?: boolean | undefined;
723
+ }, {
724
+ map?: boolean | undefined;
725
+ }>>;
707
726
  }, "strip", z.ZodTypeAny, {
708
727
  id: string;
709
728
  title: string;
@@ -717,7 +736,7 @@ export declare const PackDataSchema: z.ZodObject<{
717
736
  id: string;
718
737
  icon?: string | undefined;
719
738
  max?: string | number | undefined;
720
- format?: "number" | "percent" | undefined;
739
+ format?: "number" | "duration" | "percent" | undefined;
721
740
  display?: Record<string, string> | undefined;
722
741
  role?: "keys" | "health" | "magic" | "armor" | undefined;
723
742
  }[];
@@ -729,6 +748,7 @@ export declare const PackDataSchema: z.ZodObject<{
729
748
  source?: string | undefined;
730
749
  category?: string | undefined;
731
750
  short?: string | undefined;
751
+ count?: string | undefined;
732
752
  }[];
733
753
  chips: {
734
754
  label: string;
@@ -747,6 +767,7 @@ export declare const PackDataSchema: z.ZodObject<{
747
767
  title: string;
748
768
  counters: string[];
749
769
  kind: "counters";
770
+ hideMissing?: boolean | undefined;
750
771
  })[];
751
772
  missions: {
752
773
  id: string;
@@ -831,6 +852,9 @@ export declare const PackDataSchema: z.ZodObject<{
831
852
  shuffled?: boolean | undefined;
832
853
  }[] | undefined;
833
854
  };
855
+ panels?: {
856
+ map?: boolean | undefined;
857
+ } | undefined;
834
858
  }, {
835
859
  id: string;
836
860
  title: string;
@@ -844,7 +868,7 @@ export declare const PackDataSchema: z.ZodObject<{
844
868
  id: string;
845
869
  icon?: string | undefined;
846
870
  max?: string | number | undefined;
847
- format?: "number" | "percent" | undefined;
871
+ format?: "number" | "duration" | "percent" | undefined;
848
872
  display?: Record<string, string> | undefined;
849
873
  role?: "keys" | "health" | "magic" | "armor" | undefined;
850
874
  }[];
@@ -856,6 +880,7 @@ export declare const PackDataSchema: z.ZodObject<{
856
880
  source?: string | undefined;
857
881
  category?: string | undefined;
858
882
  short?: string | undefined;
883
+ count?: string | undefined;
859
884
  }[];
860
885
  chips: {
861
886
  label: string;
@@ -874,6 +899,7 @@ export declare const PackDataSchema: z.ZodObject<{
874
899
  title: string;
875
900
  counters: string[];
876
901
  kind: "counters";
902
+ hideMissing?: boolean | undefined;
877
903
  })[];
878
904
  missions: {
879
905
  id: string;
@@ -958,6 +984,9 @@ export declare const PackDataSchema: z.ZodObject<{
958
984
  shuffled?: boolean | undefined;
959
985
  }[] | undefined;
960
986
  };
987
+ panels?: {
988
+ map?: boolean | undefined;
989
+ } | undefined;
961
990
  }>;
962
991
  export type PackData = z.infer<typeof PackDataSchema>;
963
992
  /**
package/lib/pack.js CHANGED
@@ -14,10 +14,23 @@ export const PackDataSchema = z.object({
14
14
  /** true when +Z points north (Doom); otherwise +Z points south (the Zelda ports). */
15
15
  northIsPositiveZ: z.boolean().optional(),
16
16
  }),
17
+ /** Panels the game leaves out because they wouldn't help its player. */
18
+ panels: z
19
+ .object({
20
+ /** false: play has no space to map (a single-screen puzzle); the map panel isn't offered */
21
+ map: z.boolean().optional(),
22
+ })
23
+ .optional(),
17
24
  });
18
25
  /** The data part of a pack, without its code. */
19
26
  export function packToData(pack) {
20
- return { id: pack.id, title: pack.title, catalogue: pack.catalogue, world: pack.world };
27
+ return {
28
+ id: pack.id,
29
+ title: pack.title,
30
+ catalogue: pack.catalogue,
31
+ world: pack.world,
32
+ ...(pack.panels ? { panels: pack.panels } : {}),
33
+ };
21
34
  }
22
35
  /** Runs a pack's code over the live state. */
23
36
  export function packViewsFor(pack, state) {
@@ -21,6 +21,11 @@ export interface GameMemory {
21
21
  * Absent on cores before sdk 0.3.6 and for memory without an executable image (emulators).
22
22
  */
23
23
  scan?(signature: Signature): bigint | null;
24
+ /**
25
+ * Emits a diagnostic line to the core's plugin debug log (deduplicated per session and
26
+ * clamped to 500 characters; no-op on older cores).
27
+ */
28
+ log?(message: string): void;
24
29
  }
25
30
  /** A memory-read state source for one game. Packs export theirs from games/<id>/source.ts. */
26
31
  export interface GamePlugin {
@@ -18,6 +18,9 @@ function memoryFor(host, handle, info) {
18
18
  const at = host.scan(handle, JSON.stringify(signature));
19
19
  return at === null ? null : BigInt(at);
20
20
  },
21
+ log: message => {
22
+ host.log?.(handle, message);
23
+ },
21
24
  };
22
25
  }
23
26
  function describe(plugin) {
@@ -64,6 +64,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
64
64
  category: z.ZodOptional<z.ZodString>;
65
65
  short: z.ZodOptional<z.ZodString>;
66
66
  source: z.ZodOptional<z.ZodString>;
67
+ count: z.ZodOptional<z.ZodString>;
67
68
  }, "strict", z.ZodTypeAny, {
68
69
  label: string;
69
70
  id: string;
@@ -71,6 +72,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
71
72
  source?: string | undefined;
72
73
  category?: string | undefined;
73
74
  short?: string | undefined;
75
+ count?: string | undefined;
74
76
  }, {
75
77
  label: string;
76
78
  id: string;
@@ -78,6 +80,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
78
80
  source?: string | undefined;
79
81
  category?: string | undefined;
80
82
  short?: string | undefined;
83
+ count?: string | undefined;
81
84
  }>, "many">;
82
85
  counters: z.ZodArray<z.ZodObject<{
83
86
  id: z.ZodString;
@@ -86,13 +89,13 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
86
89
  max: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
87
90
  display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
88
91
  role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
89
- format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
92
+ format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
90
93
  }, "strict", z.ZodTypeAny, {
91
94
  label: string;
92
95
  id: string;
93
96
  icon?: string | undefined;
94
97
  max?: string | number | undefined;
95
- format?: "number" | "percent" | undefined;
98
+ format?: "number" | "duration" | "percent" | undefined;
96
99
  display?: Record<string, string> | undefined;
97
100
  role?: "keys" | "health" | "magic" | "armor" | undefined;
98
101
  }, {
@@ -100,7 +103,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
100
103
  id: string;
101
104
  icon?: string | undefined;
102
105
  max?: string | number | undefined;
103
- format?: "number" | "percent" | undefined;
106
+ format?: "number" | "duration" | "percent" | undefined;
104
107
  display?: Record<string, string> | undefined;
105
108
  role?: "keys" | "health" | "magic" | "armor" | undefined;
106
109
  }>, "many">;
@@ -128,16 +131,19 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
128
131
  id: z.ZodString;
129
132
  title: z.ZodString;
130
133
  counters: z.ZodArray<z.ZodString, "many">;
134
+ hideMissing: z.ZodOptional<z.ZodBoolean>;
131
135
  }, "strict", z.ZodTypeAny, {
132
136
  id: string;
133
137
  title: string;
134
138
  counters: string[];
135
139
  kind: "counters";
140
+ hideMissing?: boolean | undefined;
136
141
  }, {
137
142
  id: string;
138
143
  title: string;
139
144
  counters: string[];
140
145
  kind: "counters";
146
+ hideMissing?: boolean | undefined;
141
147
  }>]>, "many">;
142
148
  missions: z.ZodArray<z.ZodObject<{
143
149
  id: z.ZodString;
@@ -507,7 +513,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
507
513
  id: string;
508
514
  icon?: string | undefined;
509
515
  max?: string | number | undefined;
510
- format?: "number" | "percent" | undefined;
516
+ format?: "number" | "duration" | "percent" | undefined;
511
517
  display?: Record<string, string> | undefined;
512
518
  role?: "keys" | "health" | "magic" | "armor" | undefined;
513
519
  }[];
@@ -519,6 +525,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
519
525
  source?: string | undefined;
520
526
  category?: string | undefined;
521
527
  short?: string | undefined;
528
+ count?: string | undefined;
522
529
  }[];
523
530
  chips: {
524
531
  label: string;
@@ -537,6 +544,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
537
544
  title: string;
538
545
  counters: string[];
539
546
  kind: "counters";
547
+ hideMissing?: boolean | undefined;
540
548
  })[];
541
549
  missions: {
542
550
  id: string;
@@ -626,7 +634,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
626
634
  id: string;
627
635
  icon?: string | undefined;
628
636
  max?: string | number | undefined;
629
- format?: "number" | "percent" | undefined;
637
+ format?: "number" | "duration" | "percent" | undefined;
630
638
  display?: Record<string, string> | undefined;
631
639
  role?: "keys" | "health" | "magic" | "armor" | undefined;
632
640
  }[];
@@ -638,6 +646,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
638
646
  source?: string | undefined;
639
647
  category?: string | undefined;
640
648
  short?: string | undefined;
649
+ count?: string | undefined;
641
650
  }[];
642
651
  chips: {
643
652
  label: string;
@@ -656,6 +665,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
656
665
  title: string;
657
666
  counters: string[];
658
667
  kind: "counters";
668
+ hideMissing?: boolean | undefined;
659
669
  })[];
660
670
  missions: {
661
671
  id: string;
@@ -750,6 +760,13 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
750
760
  unitsPerMeter: number;
751
761
  northIsPositiveZ?: boolean | undefined;
752
762
  }>;
763
+ panels: z.ZodOptional<z.ZodObject<{
764
+ map: z.ZodOptional<z.ZodBoolean>;
765
+ }, "strip", z.ZodTypeAny, {
766
+ map?: boolean | undefined;
767
+ }, {
768
+ map?: boolean | undefined;
769
+ }>>;
753
770
  }, "strip", z.ZodTypeAny, {
754
771
  id: string;
755
772
  title: string;
@@ -763,7 +780,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
763
780
  id: string;
764
781
  icon?: string | undefined;
765
782
  max?: string | number | undefined;
766
- format?: "number" | "percent" | undefined;
783
+ format?: "number" | "duration" | "percent" | undefined;
767
784
  display?: Record<string, string> | undefined;
768
785
  role?: "keys" | "health" | "magic" | "armor" | undefined;
769
786
  }[];
@@ -775,6 +792,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
775
792
  source?: string | undefined;
776
793
  category?: string | undefined;
777
794
  short?: string | undefined;
795
+ count?: string | undefined;
778
796
  }[];
779
797
  chips: {
780
798
  label: string;
@@ -793,6 +811,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
793
811
  title: string;
794
812
  counters: string[];
795
813
  kind: "counters";
814
+ hideMissing?: boolean | undefined;
796
815
  })[];
797
816
  missions: {
798
817
  id: string;
@@ -877,6 +896,9 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
877
896
  shuffled?: boolean | undefined;
878
897
  }[] | undefined;
879
898
  };
899
+ panels?: {
900
+ map?: boolean | undefined;
901
+ } | undefined;
880
902
  }, {
881
903
  id: string;
882
904
  title: string;
@@ -890,7 +912,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
890
912
  id: string;
891
913
  icon?: string | undefined;
892
914
  max?: string | number | undefined;
893
- format?: "number" | "percent" | undefined;
915
+ format?: "number" | "duration" | "percent" | undefined;
894
916
  display?: Record<string, string> | undefined;
895
917
  role?: "keys" | "health" | "magic" | "armor" | undefined;
896
918
  }[];
@@ -902,6 +924,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
902
924
  source?: string | undefined;
903
925
  category?: string | undefined;
904
926
  short?: string | undefined;
927
+ count?: string | undefined;
905
928
  }[];
906
929
  chips: {
907
930
  label: string;
@@ -920,6 +943,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
920
943
  title: string;
921
944
  counters: string[];
922
945
  kind: "counters";
946
+ hideMissing?: boolean | undefined;
923
947
  })[];
924
948
  missions: {
925
949
  id: string;
@@ -1004,6 +1028,9 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1004
1028
  shuffled?: boolean | undefined;
1005
1029
  }[] | undefined;
1006
1030
  };
1031
+ panels?: {
1032
+ map?: boolean | undefined;
1033
+ } | undefined;
1007
1034
  }>, "many">;
1008
1035
  sources: z.ZodArray<z.ZodObject<{
1009
1036
  gameId: z.ZodString;
@@ -1070,7 +1097,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1070
1097
  id: string;
1071
1098
  icon?: string | undefined;
1072
1099
  max?: string | number | undefined;
1073
- format?: "number" | "percent" | undefined;
1100
+ format?: "number" | "duration" | "percent" | undefined;
1074
1101
  display?: Record<string, string> | undefined;
1075
1102
  role?: "keys" | "health" | "magic" | "armor" | undefined;
1076
1103
  }[];
@@ -1082,6 +1109,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1082
1109
  source?: string | undefined;
1083
1110
  category?: string | undefined;
1084
1111
  short?: string | undefined;
1112
+ count?: string | undefined;
1085
1113
  }[];
1086
1114
  chips: {
1087
1115
  label: string;
@@ -1100,6 +1128,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1100
1128
  title: string;
1101
1129
  counters: string[];
1102
1130
  kind: "counters";
1131
+ hideMissing?: boolean | undefined;
1103
1132
  })[];
1104
1133
  missions: {
1105
1134
  id: string;
@@ -1184,6 +1213,9 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1184
1213
  shuffled?: boolean | undefined;
1185
1214
  }[] | undefined;
1186
1215
  };
1216
+ panels?: {
1217
+ map?: boolean | undefined;
1218
+ } | undefined;
1187
1219
  }[];
1188
1220
  sources: {
1189
1221
  gameId: string;
@@ -1214,7 +1246,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1214
1246
  id: string;
1215
1247
  icon?: string | undefined;
1216
1248
  max?: string | number | undefined;
1217
- format?: "number" | "percent" | undefined;
1249
+ format?: "number" | "duration" | "percent" | undefined;
1218
1250
  display?: Record<string, string> | undefined;
1219
1251
  role?: "keys" | "health" | "magic" | "armor" | undefined;
1220
1252
  }[];
@@ -1226,6 +1258,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1226
1258
  source?: string | undefined;
1227
1259
  category?: string | undefined;
1228
1260
  short?: string | undefined;
1261
+ count?: string | undefined;
1229
1262
  }[];
1230
1263
  chips: {
1231
1264
  label: string;
@@ -1244,6 +1277,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1244
1277
  title: string;
1245
1278
  counters: string[];
1246
1279
  kind: "counters";
1280
+ hideMissing?: boolean | undefined;
1247
1281
  })[];
1248
1282
  missions: {
1249
1283
  id: string;
@@ -1328,6 +1362,9 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1328
1362
  shuffled?: boolean | undefined;
1329
1363
  }[] | undefined;
1330
1364
  };
1365
+ panels?: {
1366
+ map?: boolean | undefined;
1367
+ } | undefined;
1331
1368
  }[];
1332
1369
  sources: {
1333
1370
  gameId: string;
@@ -1380,6 +1417,8 @@ export interface SandboxHostApi {
1380
1417
  refreshMappings(handle: number): void;
1381
1418
  /** a signature scan (JSON of a Signature); the address as a decimal string, or null */
1382
1419
  scan(handle: number, signature: string): string | null;
1420
+ /** a diagnostic line from the guest; consecutive duplicates per session are suppressed */
1421
+ log?(handle: number, message: string): void;
1383
1422
  }
1384
1423
  /** A player's file as the asset guest sees it: a handle for `inputRead`, its name and size. */
1385
1424
  export declare const SandboxInputFileSchema: z.ZodObject<{
package/lib/status.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Catalogue, CatalogueCounter, CounterRole, CatalogueMission, CollectibleEntry, ReferenceEntry } from './catalogue.js';
1
+ import type { Catalogue, CatalogueCounter, CatalogueItem, CatalogueLayout, CounterRole, CatalogueMission, CollectibleEntry, ReferenceEntry } from './catalogue.js';
2
2
  import type { EvaluationContext } from './condition.js';
3
3
  import type { GameState } from './types.js';
4
4
  /** Context whose `{ mission }` conditions resolve against this catalogue (cycles → unknown). */
@@ -22,6 +22,14 @@ export interface CounterView {
22
22
  }
23
23
  /** Counter value + display text; null when the counter isn't streamed (unknown, not zero). */
24
24
  export declare function getCounterView(counter: CatalogueCounter, state: GameState): CounterView | null;
25
+ /** Milliseconds as a race time: 83456 → 1'23"456. */
26
+ export declare function formatDuration(ms: number): string;
27
+ /** The counters a `counters` layout shows now: all of them, or with `hideMissing` those the state has. */
28
+ export declare function layoutCounterIds(layout: Extract<CatalogueLayout, {
29
+ kind: 'counters';
30
+ }>, state: GameState): string[];
31
+ /** How many of an item the player holds, when the pack counts it and the state has the count. */
32
+ export declare function findItemCount(item: CatalogueItem, state: GameState): number | undefined;
25
33
  /** The pack's counter with this role and its value now, or undefined (no such counter, or unread). */
26
34
  export declare function counterByRole(catalogue: Catalogue | undefined, state: GameState, role: CounterRole): (CounterView & {
27
35
  counter: CatalogueCounter;
package/lib/status.js CHANGED
@@ -69,6 +69,11 @@ export function getCounterView(counter, state) {
69
69
  : counter.max
70
70
  ? (readCounter(state, counter.max) ?? null)
71
71
  : null;
72
+ if (counter.format === 'duration') {
73
+ /* a value that isn't whole milliseconds can't be shown as a time: unknown, not a crash
74
+ * mid-render (plugin state isn't schema-checked at the daemon, boundaries.ts) */
75
+ return isDuration(value) ? { value, text: formatDuration(value), max } : null;
76
+ }
72
77
  if (counter.format === 'percent') {
73
78
  /* no max declared: the value is already a 0..1 share. A declared max that's unread or
74
79
  * not positive leaves the share unknown, so the counter isn't shown. */
@@ -81,6 +86,27 @@ export function getCounterView(counter, state) {
81
86
  const text = mapped ?? (max !== null ? `${value}/${max}` : String(value));
82
87
  return { value, text, max };
83
88
  }
89
+ const MS_PER_MINUTE = 60_000;
90
+ const MS_PER_SECOND = 1000;
91
+ const isDuration = (ms) => Number.isInteger(ms) && ms >= 0;
92
+ /** Milliseconds as a race time: 83456 → 1'23"456. */
93
+ export function formatDuration(ms) {
94
+ if (!Number.isInteger(ms) || ms < 0)
95
+ throw new Error(`${ms} isn't a duration in whole milliseconds`);
96
+ const minutes = Math.floor(ms / MS_PER_MINUTE);
97
+ const seconds = Math.floor((ms % MS_PER_MINUTE) / MS_PER_SECOND);
98
+ return `${minutes}'${String(seconds).padStart(2, '0')}"${String(ms % MS_PER_SECOND).padStart(3, '0')}`;
99
+ }
100
+ /** The counters a `counters` layout shows now: all of them, or with `hideMissing` those the state has. */
101
+ export function layoutCounterIds(layout, state) {
102
+ if (!layout.hideMissing)
103
+ return layout.counters;
104
+ return layout.counters.filter(id => readCounter(state, id) !== undefined);
105
+ }
106
+ /** How many of an item the player holds, when the pack counts it and the state has the count. */
107
+ export function findItemCount(item, state) {
108
+ return item.count === undefined ? undefined : readCounter(state, item.count);
109
+ }
84
110
  /** The pack's counter with this role and its value now, or undefined (no such counter, or unread). */
85
111
  export function counterByRole(catalogue, state, role) {
86
112
  const counter = catalogue?.counters.find(c => c.role === role);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gameslate/sdk",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
5
5
  "license": "MIT",
6
6
  "type": "module",