@arcadia-eternity/content-sdk 4.10.0 → 4.11.1

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.
@@ -69,6 +69,31 @@ declare const compositionSchema: z.ZodObject<{
69
69
  max: z.ZodNumber;
70
70
  }, z.core.$strict>>;
71
71
  allowFaintSwitch: z.ZodOptional<z.ZodBoolean>;
72
+ timer: z.ZodOptional<z.ZodObject<{
73
+ enabled: z.ZodBoolean;
74
+ turnTimeLimit: z.ZodOptional<z.ZodNumber>;
75
+ totalTimeLimit: z.ZodOptional<z.ZodNumber>;
76
+ animationPauseEnabled: z.ZodOptional<z.ZodBoolean>;
77
+ maxAnimationDuration: z.ZodOptional<z.ZodNumber>;
78
+ }, z.core.$strict>>;
79
+ teamSelection: z.ZodOptional<z.ZodObject<{
80
+ enabled: z.ZodBoolean;
81
+ mode: z.ZodOptional<z.ZodEnum<{
82
+ FULL_TEAM: "FULL_TEAM";
83
+ TEAM_SELECTION: "TEAM_SELECTION";
84
+ VIEW_ONLY: "VIEW_ONLY";
85
+ }>>;
86
+ minTeamSize: z.ZodOptional<z.ZodNumber>;
87
+ maxTeamSize: z.ZodOptional<z.ZodNumber>;
88
+ allowStarterSelection: z.ZodOptional<z.ZodBoolean>;
89
+ showOpponentTeam: z.ZodOptional<z.ZodBoolean>;
90
+ teamInfoVisibility: z.ZodOptional<z.ZodEnum<{
91
+ BASIC: "BASIC";
92
+ FULL: "FULL";
93
+ HIDDEN: "HIDDEN";
94
+ }>>;
95
+ timeLimit: z.ZodOptional<z.ZodNumber>;
96
+ }, z.core.$strict>>;
72
97
  inheritance: z.ZodOptional<z.ZodObject<{
73
98
  eligible: z.ZodUnion<readonly [z.ZodEnum<{
74
99
  all: "all";
@@ -172,6 +197,31 @@ declare const compositionSchema: z.ZodObject<{
172
197
  max: z.ZodNumber;
173
198
  }, z.core.$strict>>;
174
199
  allowFaintSwitch: z.ZodOptional<z.ZodBoolean>;
200
+ timer: z.ZodOptional<z.ZodObject<{
201
+ enabled: z.ZodBoolean;
202
+ turnTimeLimit: z.ZodOptional<z.ZodNumber>;
203
+ totalTimeLimit: z.ZodOptional<z.ZodNumber>;
204
+ animationPauseEnabled: z.ZodOptional<z.ZodBoolean>;
205
+ maxAnimationDuration: z.ZodOptional<z.ZodNumber>;
206
+ }, z.core.$strict>>;
207
+ teamSelection: z.ZodOptional<z.ZodObject<{
208
+ enabled: z.ZodBoolean;
209
+ mode: z.ZodOptional<z.ZodEnum<{
210
+ FULL_TEAM: "FULL_TEAM";
211
+ TEAM_SELECTION: "TEAM_SELECTION";
212
+ VIEW_ONLY: "VIEW_ONLY";
213
+ }>>;
214
+ minTeamSize: z.ZodOptional<z.ZodNumber>;
215
+ maxTeamSize: z.ZodOptional<z.ZodNumber>;
216
+ allowStarterSelection: z.ZodOptional<z.ZodBoolean>;
217
+ showOpponentTeam: z.ZodOptional<z.ZodBoolean>;
218
+ teamInfoVisibility: z.ZodOptional<z.ZodEnum<{
219
+ BASIC: "BASIC";
220
+ FULL: "FULL";
221
+ HIDDEN: "HIDDEN";
222
+ }>>;
223
+ timeLimit: z.ZodOptional<z.ZodNumber>;
224
+ }, z.core.$strict>>;
175
225
  inheritance: z.ZodOptional<z.ZodObject<{
176
226
  eligible: z.ZodUnion<readonly [z.ZodEnum<{
177
227
  all: "all";
@@ -579,6 +629,7 @@ export interface ContentWorkspace {
579
629
  cleanupStaging(): Promise<string[]>;
580
630
  }
581
631
  export interface OwnedContentWorkspace extends ContentWorkspace {
632
+ refreshBuiltinRules(documents: readonly EnvironmentDocument[]): Promise<void>;
582
633
  registerBuiltinEnvironments(keys: string[], adopted: Record<string, string>): Promise<Readonly<Record<string, string>>>;
583
634
  }
584
635
  export interface ContentWorkspaceConstructor {
@@ -635,6 +686,23 @@ export declare function readShippedEnvironments(file: string | URL, bundledVersi
635
686
  max: number;
636
687
  } | undefined;
637
688
  allowFaintSwitch?: boolean | undefined;
689
+ timer?: {
690
+ enabled: boolean;
691
+ turnTimeLimit?: number | undefined;
692
+ totalTimeLimit?: number | undefined;
693
+ animationPauseEnabled?: boolean | undefined;
694
+ maxAnimationDuration?: number | undefined;
695
+ } | undefined;
696
+ teamSelection?: {
697
+ enabled: boolean;
698
+ mode?: "FULL_TEAM" | "TEAM_SELECTION" | "VIEW_ONLY" | undefined;
699
+ minTeamSize?: number | undefined;
700
+ maxTeamSize?: number | undefined;
701
+ allowStarterSelection?: boolean | undefined;
702
+ showOpponentTeam?: boolean | undefined;
703
+ teamInfoVisibility?: "BASIC" | "FULL" | "HIDDEN" | undefined;
704
+ timeLimit?: number | undefined;
705
+ } | undefined;
638
706
  inheritance?: {
639
707
  eligible: "all" | "off" | "species" | string[];
640
708
  pool?: {
@@ -726,48 +794,6 @@ export declare function readShippedEnvironments(file: string | URL, bundledVersi
726
794
  kind: "mark" | "skill" | "species";
727
795
  ids: string[];
728
796
  }[] | undefined;
729
- include?: string[] | undefined;
730
- constraintEdits?: {
731
- remove?: string[] | undefined;
732
- replace?: ({
733
- id: string;
734
- allOf: {
735
- kind: "mark" | "skill" | "species";
736
- ids: string[];
737
- fromCollections?: string[] | undefined;
738
- }[];
739
- kind: "ban";
740
- scope: "pet" | "team";
741
- exceptWhen?: {
742
- kind: "mark" | "skill" | "species";
743
- ids: string[];
744
- fromCollections?: string[] | undefined;
745
- }[] | undefined;
746
- exceptAny?: {
747
- kind: "mark" | "skill" | "species";
748
- ids: string[];
749
- fromCollections?: string[] | undefined;
750
- }[][] | undefined;
751
- } | {
752
- id: string;
753
- allOf: {
754
- kind: "mark" | "skill" | "species";
755
- ids: string[];
756
- fromCollections?: string[] | undefined;
757
- }[];
758
- kind: "memberLimit";
759
- max: number;
760
- })[] | undefined;
761
- clearExceptions?: string[] | undefined;
762
- exceptions?: {
763
- target: string;
764
- allOf: {
765
- kind: "mark" | "skill" | "species";
766
- ids: string[];
767
- fromCollections?: string[] | undefined;
768
- }[];
769
- }[] | undefined;
770
- } | undefined;
771
797
  };
772
798
  requires: {
773
799
  engine?: string | undefined;
@@ -217,6 +217,34 @@ class ContentWorkspaceImplementation {
217
217
  throw error;
218
218
  }
219
219
  }
220
+ /** Registered builtins use the declarations shipped with the app, including on the first startup after an update. */
221
+ refreshBuiltinRules(documents) {
222
+ return this.#exclusive(async () => {
223
+ for (const document of documents) {
224
+ if (this.builtinEnvironmentIds[document.id] !== document.id)
225
+ continue;
226
+ const directory = this.#directory(document.id);
227
+ const resolved = await realpath(directory).catch(error => {
228
+ if (errorCode(error) !== 'ENOENT')
229
+ throw error;
230
+ return undefined;
231
+ });
232
+ if (!resolved)
233
+ continue;
234
+ if (resolved !== directory)
235
+ throw contentError('WORKSPACE_PATH_INVALID');
236
+ const file = join(directory, 'package.json');
237
+ const manifest = await readJson(file);
238
+ const declaration = manifest.arcadiaEnvironment;
239
+ if (!isRecord(declaration) || declaration.id !== document.id)
240
+ throw contentError('ENVIRONMENT_ID_MISMATCH');
241
+ if (isDeepStrictEqual(declaration.rules, document.rules))
242
+ continue;
243
+ declaration.rules = document.rules;
244
+ await writeFileAtomic(file, json(manifest));
245
+ }
246
+ }, true);
247
+ }
220
248
  registerBuiltinEnvironments(keys, adopted) {
221
249
  return this.#exclusive(async () => {
222
250
  const ids = readBuiltinEnvironmentIds({ builtinEnvironmentIds: Object.fromEntries(keys.map(key => [key, key])) });
@@ -20,6 +20,31 @@ export declare const EnvironmentDocumentV2Schema: z.ZodObject<{
20
20
  max: z.ZodNumber;
21
21
  }, z.core.$strict>>;
22
22
  allowFaintSwitch: z.ZodOptional<z.ZodBoolean>;
23
+ timer: z.ZodOptional<z.ZodObject<{
24
+ enabled: z.ZodBoolean;
25
+ turnTimeLimit: z.ZodOptional<z.ZodNumber>;
26
+ totalTimeLimit: z.ZodOptional<z.ZodNumber>;
27
+ animationPauseEnabled: z.ZodOptional<z.ZodBoolean>;
28
+ maxAnimationDuration: z.ZodOptional<z.ZodNumber>;
29
+ }, z.core.$strict>>;
30
+ teamSelection: z.ZodOptional<z.ZodObject<{
31
+ enabled: z.ZodBoolean;
32
+ mode: z.ZodOptional<z.ZodEnum<{
33
+ FULL_TEAM: "FULL_TEAM";
34
+ TEAM_SELECTION: "TEAM_SELECTION";
35
+ VIEW_ONLY: "VIEW_ONLY";
36
+ }>>;
37
+ minTeamSize: z.ZodOptional<z.ZodNumber>;
38
+ maxTeamSize: z.ZodOptional<z.ZodNumber>;
39
+ allowStarterSelection: z.ZodOptional<z.ZodBoolean>;
40
+ showOpponentTeam: z.ZodOptional<z.ZodBoolean>;
41
+ teamInfoVisibility: z.ZodOptional<z.ZodEnum<{
42
+ BASIC: "BASIC";
43
+ FULL: "FULL";
44
+ HIDDEN: "HIDDEN";
45
+ }>>;
46
+ timeLimit: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strict>>;
23
48
  inheritance: z.ZodOptional<z.ZodObject<{
24
49
  eligible: z.ZodUnion<readonly [z.ZodEnum<{
25
50
  all: "all";
@@ -156,71 +181,6 @@ export declare const EnvironmentDocumentV2Schema: z.ZodObject<{
156
181
  }>;
157
182
  ids: z.ZodArray<z.ZodString>;
158
183
  }, z.core.$strict>>>;
159
- include: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
- constraintEdits: z.ZodOptional<z.ZodObject<{
161
- remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
162
- replace: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
163
- id: z.ZodString;
164
- allOf: z.ZodArray<z.ZodObject<{
165
- kind: z.ZodEnum<{
166
- mark: "mark";
167
- skill: "skill";
168
- species: "species";
169
- }>;
170
- ids: z.ZodArray<z.ZodString>;
171
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
172
- }, z.core.$strict>>;
173
- kind: z.ZodLiteral<"ban">;
174
- scope: z.ZodEnum<{
175
- pet: "pet";
176
- team: "team";
177
- }>;
178
- exceptWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
- kind: z.ZodEnum<{
180
- mark: "mark";
181
- skill: "skill";
182
- species: "species";
183
- }>;
184
- ids: z.ZodArray<z.ZodString>;
185
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
186
- }, z.core.$strict>>>;
187
- exceptAny: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodObject<{
188
- kind: z.ZodEnum<{
189
- mark: "mark";
190
- skill: "skill";
191
- species: "species";
192
- }>;
193
- ids: z.ZodArray<z.ZodString>;
194
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
- }, z.core.$strict>>>>;
196
- }, z.core.$strict>, z.ZodObject<{
197
- id: z.ZodString;
198
- allOf: z.ZodArray<z.ZodObject<{
199
- kind: z.ZodEnum<{
200
- mark: "mark";
201
- skill: "skill";
202
- species: "species";
203
- }>;
204
- ids: z.ZodArray<z.ZodString>;
205
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
206
- }, z.core.$strict>>;
207
- kind: z.ZodLiteral<"memberLimit">;
208
- max: z.ZodNumber;
209
- }, z.core.$strict>], "kind">>>;
210
- clearExceptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
211
- exceptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
212
- target: z.ZodString;
213
- allOf: z.ZodArray<z.ZodObject<{
214
- kind: z.ZodEnum<{
215
- mark: "mark";
216
- skill: "skill";
217
- species: "species";
218
- }>;
219
- ids: z.ZodArray<z.ZodString>;
220
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
221
- }, z.core.$strict>>;
222
- }, z.core.$strict>>>;
223
- }, z.core.$strict>>;
224
184
  }, z.core.$strict>;
225
185
  requires: z.ZodObject<{
226
186
  engine: z.ZodOptional<z.ZodString>;
@@ -253,6 +213,31 @@ export declare const EnvironmentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodOb
253
213
  max: z.ZodNumber;
254
214
  }, z.core.$strict>>;
255
215
  allowFaintSwitch: z.ZodOptional<z.ZodBoolean>;
216
+ timer: z.ZodOptional<z.ZodObject<{
217
+ enabled: z.ZodBoolean;
218
+ turnTimeLimit: z.ZodOptional<z.ZodNumber>;
219
+ totalTimeLimit: z.ZodOptional<z.ZodNumber>;
220
+ animationPauseEnabled: z.ZodOptional<z.ZodBoolean>;
221
+ maxAnimationDuration: z.ZodOptional<z.ZodNumber>;
222
+ }, z.core.$strict>>;
223
+ teamSelection: z.ZodOptional<z.ZodObject<{
224
+ enabled: z.ZodBoolean;
225
+ mode: z.ZodOptional<z.ZodEnum<{
226
+ FULL_TEAM: "FULL_TEAM";
227
+ TEAM_SELECTION: "TEAM_SELECTION";
228
+ VIEW_ONLY: "VIEW_ONLY";
229
+ }>>;
230
+ minTeamSize: z.ZodOptional<z.ZodNumber>;
231
+ maxTeamSize: z.ZodOptional<z.ZodNumber>;
232
+ allowStarterSelection: z.ZodOptional<z.ZodBoolean>;
233
+ showOpponentTeam: z.ZodOptional<z.ZodBoolean>;
234
+ teamInfoVisibility: z.ZodOptional<z.ZodEnum<{
235
+ BASIC: "BASIC";
236
+ FULL: "FULL";
237
+ HIDDEN: "HIDDEN";
238
+ }>>;
239
+ timeLimit: z.ZodOptional<z.ZodNumber>;
240
+ }, z.core.$strict>>;
256
241
  inheritance: z.ZodOptional<z.ZodObject<{
257
242
  eligible: z.ZodUnion<readonly [z.ZodEnum<{
258
243
  all: "all";
@@ -389,71 +374,6 @@ export declare const EnvironmentDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodOb
389
374
  }>;
390
375
  ids: z.ZodArray<z.ZodString>;
391
376
  }, z.core.$strict>>>;
392
- include: z.ZodOptional<z.ZodArray<z.ZodString>>;
393
- constraintEdits: z.ZodOptional<z.ZodObject<{
394
- remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
395
- replace: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
396
- id: z.ZodString;
397
- allOf: z.ZodArray<z.ZodObject<{
398
- kind: z.ZodEnum<{
399
- mark: "mark";
400
- skill: "skill";
401
- species: "species";
402
- }>;
403
- ids: z.ZodArray<z.ZodString>;
404
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
405
- }, z.core.$strict>>;
406
- kind: z.ZodLiteral<"ban">;
407
- scope: z.ZodEnum<{
408
- pet: "pet";
409
- team: "team";
410
- }>;
411
- exceptWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
412
- kind: z.ZodEnum<{
413
- mark: "mark";
414
- skill: "skill";
415
- species: "species";
416
- }>;
417
- ids: z.ZodArray<z.ZodString>;
418
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
419
- }, z.core.$strict>>>;
420
- exceptAny: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodObject<{
421
- kind: z.ZodEnum<{
422
- mark: "mark";
423
- skill: "skill";
424
- species: "species";
425
- }>;
426
- ids: z.ZodArray<z.ZodString>;
427
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
428
- }, z.core.$strict>>>>;
429
- }, z.core.$strict>, z.ZodObject<{
430
- id: z.ZodString;
431
- allOf: z.ZodArray<z.ZodObject<{
432
- kind: z.ZodEnum<{
433
- mark: "mark";
434
- skill: "skill";
435
- species: "species";
436
- }>;
437
- ids: z.ZodArray<z.ZodString>;
438
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
439
- }, z.core.$strict>>;
440
- kind: z.ZodLiteral<"memberLimit">;
441
- max: z.ZodNumber;
442
- }, z.core.$strict>], "kind">>>;
443
- clearExceptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
444
- exceptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
445
- target: z.ZodString;
446
- allOf: z.ZodArray<z.ZodObject<{
447
- kind: z.ZodEnum<{
448
- mark: "mark";
449
- skill: "skill";
450
- species: "species";
451
- }>;
452
- ids: z.ZodArray<z.ZodString>;
453
- fromCollections: z.ZodOptional<z.ZodArray<z.ZodString>>;
454
- }, z.core.$strict>>;
455
- }, z.core.$strict>>>;
456
- }, z.core.$strict>>;
457
377
  }, z.core.$strict>;
458
378
  requires: z.ZodObject<{
459
379
  engine: z.ZodOptional<z.ZodString>;
@@ -1,4 +1,4 @@
1
- import { EnvironmentRuleDeclarationSchema, EnvironmentRequirementsSchema } from '@arcadia-eternity/const';
1
+ import { IndependentEnvironmentRulesSchema, EnvironmentRequirementsSchema } from '@arcadia-eternity/const';
2
2
  export { EnvironmentRuleDeclarationSchema, EnvironmentRulesSchema, } from '@arcadia-eternity/const';
3
3
  import { WorkspaceError } from './workspace.js';
4
4
  import { z } from 'zod';
@@ -33,7 +33,7 @@ export const EnvironmentDocumentV2Schema = z
33
33
  .object({
34
34
  schemaVersion: z.literal(2),
35
35
  ...sharedFields,
36
- rules: EnvironmentRuleDeclarationSchema,
36
+ rules: IndependentEnvironmentRulesSchema,
37
37
  requires: EnvironmentRequirementsSchema,
38
38
  })
39
39
  .strict();
@@ -33,6 +33,23 @@ export declare function environmentShareMaterials(files: Material[], document: E
33
33
  max: number;
34
34
  } | undefined;
35
35
  allowFaintSwitch?: boolean | undefined;
36
+ timer?: {
37
+ enabled: boolean;
38
+ turnTimeLimit?: number | undefined;
39
+ totalTimeLimit?: number | undefined;
40
+ animationPauseEnabled?: boolean | undefined;
41
+ maxAnimationDuration?: number | undefined;
42
+ } | undefined;
43
+ teamSelection?: {
44
+ enabled: boolean;
45
+ mode?: "FULL_TEAM" | "TEAM_SELECTION" | "VIEW_ONLY" | undefined;
46
+ minTeamSize?: number | undefined;
47
+ maxTeamSize?: number | undefined;
48
+ allowStarterSelection?: boolean | undefined;
49
+ showOpponentTeam?: boolean | undefined;
50
+ teamInfoVisibility?: "BASIC" | "FULL" | "HIDDEN" | undefined;
51
+ timeLimit?: number | undefined;
52
+ } | undefined;
36
53
  inheritance?: {
37
54
  eligible: "all" | "off" | "species" | string[];
38
55
  pool?: {
@@ -124,48 +141,6 @@ export declare function environmentShareMaterials(files: Material[], document: E
124
141
  kind: "mark" | "skill" | "species";
125
142
  ids: string[];
126
143
  }[] | undefined;
127
- include?: string[] | undefined;
128
- constraintEdits?: {
129
- remove?: string[] | undefined;
130
- replace?: ({
131
- id: string;
132
- allOf: {
133
- kind: "mark" | "skill" | "species";
134
- ids: string[];
135
- fromCollections?: string[] | undefined;
136
- }[];
137
- kind: "ban";
138
- scope: "pet" | "team";
139
- exceptWhen?: {
140
- kind: "mark" | "skill" | "species";
141
- ids: string[];
142
- fromCollections?: string[] | undefined;
143
- }[] | undefined;
144
- exceptAny?: {
145
- kind: "mark" | "skill" | "species";
146
- ids: string[];
147
- fromCollections?: string[] | undefined;
148
- }[][] | undefined;
149
- } | {
150
- id: string;
151
- allOf: {
152
- kind: "mark" | "skill" | "species";
153
- ids: string[];
154
- fromCollections?: string[] | undefined;
155
- }[];
156
- kind: "memberLimit";
157
- max: number;
158
- })[] | undefined;
159
- clearExceptions?: string[] | undefined;
160
- exceptions?: {
161
- target: string;
162
- allOf: {
163
- kind: "mark" | "skill" | "species";
164
- ids: string[];
165
- fromCollections?: string[] | undefined;
166
- }[];
167
- }[] | undefined;
168
- } | undefined;
169
144
  };
170
145
  requires: {
171
146
  engine?: string | undefined;