@wildshard/shard-format 0.25.0 → 0.27.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 (54) hide show
  1. package/package.json +4 -1
  2. package/src/format/actorMoves.ts +32 -0
  3. package/src/format/audio-mp4.ts +1 -1
  4. package/src/format/audioProfiles.ts +1 -1
  5. package/src/format/boot-memory-cost.ts +93 -2
  6. package/src/format/brains.ts +3 -3
  7. package/src/format/budget-tiers.ts +62 -0
  8. package/src/format/builtIndexes.ts +2 -2
  9. package/src/format/clientChannels.ts +3 -3
  10. package/src/format/clientScripts.ts +1 -1
  11. package/src/format/contentBounds.ts +1 -1
  12. package/src/format/contentCost.ts +2 -1
  13. package/src/format/creature-layers.ts +13 -1
  14. package/src/format/creature-ranks.ts +37 -0
  15. package/src/format/creature-sizes.ts +45 -4
  16. package/src/format/creature-volumes.ts +5 -4
  17. package/src/format/creatures.ts +20 -3
  18. package/src/format/crowds.ts +1 -1
  19. package/src/format/deviceMemoryCost.ts +2 -2
  20. package/src/format/directorStages.ts +3 -3
  21. package/src/format/flyers.ts +2 -2
  22. package/src/format/grazers.ts +2 -2
  23. package/src/format/items.ts +1 -1
  24. package/src/format/materialGraph.ts +7 -7
  25. package/src/format/materials.ts +10 -10
  26. package/src/format/memory-epoch.ts +1 -1
  27. package/src/format/memory-line.ts +48 -5
  28. package/src/format/memoryAdmission.ts +1 -1
  29. package/src/format/namedJsonContracts.ts +1 -1
  30. package/src/format/nativeGround.ts +3 -3
  31. package/src/format/navigation.ts +2 -2
  32. package/src/format/parsed-json.ts +91 -0
  33. package/src/format/placement-page-text.ts +281 -0
  34. package/src/format/questHost.ts +1 -1
  35. package/src/format/rows.ts +18 -5
  36. package/src/format/runtime-tier.ts +56 -0
  37. package/src/format/runtimeBinds.ts +6 -6
  38. package/src/format/runtimeCost.ts +1 -1
  39. package/src/format/runtimeSpawns.ts +2 -2
  40. package/src/format/scaledPostContract.ts +2 -2
  41. package/src/format/scriptAbi.ts +1 -1
  42. package/src/format/scriptWireV2.ts +1 -1
  43. package/src/format/shardSchema.ts +2 -2
  44. package/src/format/shardSections.ts +7 -1
  45. package/src/format/shardfile-assets.ts +9 -10
  46. package/src/format/shardfileValidation.ts +17 -11
  47. package/src/format/skin-file.ts +3 -0
  48. package/src/format/skinData.ts +39 -19
  49. package/src/format/skins.ts +21 -2
  50. package/src/format/sourceResidency.ts +1 -1
  51. package/src/format/standalone-catalogue.ts +1 -1
  52. package/src/format/terrain.ts +1 -1
  53. package/src/format/validationReceipt.ts +2 -2
  54. package/src/format/weaponProfiles.ts +2 -2
@@ -21,7 +21,10 @@ import { shardfileRecordings } from './shardfile-audio.ts';
21
21
  import type { RecordingMeasure } from './audio-measure.ts';
22
22
  import { issueError, withIssueCode as coded } from './issue-codes.ts';
23
23
  import { staleRuntimeIssues } from './memory-epoch.ts';
24
- import { offlineMemoryIssues } from './memory-line.ts';
24
+ import { memoryContext, offlineMemoryIssues } from './memory-line.ts';
25
+ import { runtimeTierIssues } from './runtime-tier.ts';
26
+ import type { MemoryContext } from './memory-line.ts';
27
+ import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
25
28
 
26
29
  /**
27
30
  * P1-F3 format validation of a built shardfile product (format 2: `shard.json`, sections, blobs, packs): the schema,
@@ -108,18 +111,19 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
108
111
  }
109
112
 
110
113
  /** Refuse the declared targets a policy treats as refusals, before any byte is read or executed. */
111
- export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse', sections: ReadonlyMap<string, unknown> = new Map()): void {
112
- const issues = [...staleRuntimeIssues(source.runtime), ...offlineMemoryIssues(source, sections), ...performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal')];
114
+ export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse', context: MemoryContext = new Map()): void {
115
+ const issues = [...staleRuntimeIssues(source.runtime), ...offlineMemoryIssues(source, context), ...runtimeTierIssues(source), ...performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal')];
113
116
  if (issues.length === 0) return;
114
117
  throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
115
118
  }
116
119
 
117
120
  /** Admit a whole shardfile's declared costs and its actual immutable bytes through the defining contracts. */
118
121
  export function admitShardfileFolder(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
119
- policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = [], sections?: ReadonlyMap<string, unknown>): Shardfile {
122
+ policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = [], context?: MemoryContext): Shardfile {
123
+ const sections = context === undefined ? undefined : memoryContext(context).sections;
120
124
  const source = coded('shard-schema', (): Shardfile => parseShardfile(input, sections));
121
125
  coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy)); });
122
- coded('performance-targets', (): void => { assertShardfileTargets(source, policy, sections); });
126
+ coded('performance-targets', (): void => { assertShardfileTargets(source, policy, context); });
123
127
  return coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy), undefined, scripts, sections));
124
128
  }
125
129
 
@@ -185,17 +189,19 @@ function checkServerAndKtx2(index: OutputIndex, read: ReadListed, assets: Readon
185
189
 
186
190
  /** C0 (J137): the cook file; a mount passes the same hash and size checks as any listed file (`cook-invalid`). */
187
191
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
188
- function readCook(index: OutputIndex, read: ReadListed, hash: (bytes: Uint8Array) => string): ReturnType<typeof readCookData> | undefined {
189
- return coded('cook-invalid', (): ReturnType<typeof readCookData> | undefined => {
192
+ function readCook(index: OutputIndex, read: ReadListed, hash: (bytes: Uint8Array) => string): { cook: ReturnType<typeof readCookData> | undefined; mountedImages: number } {
193
+ return coded('cook-invalid', (): { cook: ReturnType<typeof readCookData> | undefined; mountedImages: number } => {
190
194
  const cook = index.cook === undefined ? undefined : readCookData(readCanonicalJson(read(index.cook)));
191
195
  requireCookPreparation(index, cook, hash);
196
+ let mountedImages = NO_BYTES;
192
197
  for (const mount of cook?.mounts ?? []) {
193
198
  if (!mountSharesBlob(mount, index.files)) {
194
199
  if (mount.path !== cookMountPath(mount.url)) { throw new Error(`Mount path differs from its URL: ${mount.url}`); }
195
- read(mount);
200
+ // MG6 epoch 3: the engine images a shard mounts decode at boot like its own (Far Reach's sky and textures).
201
+ mountedImages += mountedImageBytes(mount.path, read(mount));
196
202
  }
197
203
  }
198
- return cook;
204
+ return { cook, mountedImages };
199
205
  });
200
206
  }
201
207
 
@@ -225,13 +231,13 @@ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileV
225
231
  }
226
232
  checkServerAndKtx2(index, read, assets);
227
233
  coded('pack-invalid', (): void => { checkPacks(index, new Set(files.paths()), { readFile: files.read, readListed: read, verify, hash: ports.hash }); });
228
- const cook = readCook(index, read, ports.hash);
234
+ const { cook, mountedImages } = readCook(index, read, ports.hash);
229
235
  for (const entry of index.runtime?.files ?? []) {
230
236
  if (ports.runtimeImports === undefined) throw issueError('runtime-files', 'Copied runtime files need a runtime import checker');
231
237
  coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
232
238
  }
233
239
  for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
234
- const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, payloads);
240
+ const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages });
235
241
  checkWorldTargets(shard, payloads.get('world/targets'));
236
242
  if (ports.hash(validationSourceBytes(shard)) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
237
243
  return { index, shard, assets, sections: payloads, scripts, warnings, audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
@@ -35,6 +35,9 @@ function skinLookParameters(
35
35
  return {
36
36
  skin: look.output.skin,
37
37
  attackSpan: clips.output.attackSpan,
38
+ ...(row.animation.clipMap === undefined
39
+ ? {}
40
+ : { clipMap: row.animation.clipMap }),
38
41
  ...(look.output.variants === undefined
39
42
  ? {}
40
43
  : { variants: look.output.variants }),
@@ -2,52 +2,69 @@ import * as v from 'valibot';
2
2
  import { SkinPoseLayerSchema, validateSkinLayers } from './skinLayers.ts';
3
3
  import { SkinMaterialsSchema } from './skin-materials.ts';
4
4
  /** Animation clip identity; the native rig uses the same bounded family namespace. */
5
- export type SkinClipName = `${'idle' | 'walk' | 'run' | 'attack' | 'hit' | 'die' | 'turn' | 'swim' | 'fly'}${'' | `.${string}`}`;
5
+ type SkinClipName = `${'idle' | 'walk' | 'run' | 'attack' | 'hit' | 'die' | 'turn' | 'swim' | 'fly'}${'' | `.${string}`}`;
6
6
 
7
7
  const id = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u), v.maxLength(128));
8
8
  const hash = v.pipe(v.string(), v.regex(/^[0-9a-f]{64}$/u));
9
9
  /** Admitted clip family and optional lowercase action suffix; its transform is an identity type narrowing. */
10
- export const SkinClipNameSchema: v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows> & { readonly pipe: readonly [unknown, unknown, v.TransformAction<string, SkinClipName>] } = v.pipe(v.string(), v.regex(/^(idle|walk|run|attack|hit|die|turn|swim|fly)(\.[a-z][a-z0-9-]*)?$/u), v.transform((name) => name as SkinClipName));
10
+ const SkinClipNameSchema: v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows> & { readonly pipe: readonly [unknown, unknown, v.TransformAction<string, SkinClipName>] } = v.pipe(v.string(), v.regex(/^(idle|walk|run|attack|hit|die|turn|swim|fly)(\.[a-z][a-z0-9-]*)?$/u), v.transform((name) => name as SkinClipName));
11
+
12
+ declare const creatureClipName: unique symbol;
13
+ /** Exported skins can also use a validated name supplied by a creature author. */
14
+ type CreatureSkinClipName = SkinClipName | (string & { readonly [creatureClipName]: true });
15
+ const MAX_NAMED_CLIP_LENGTH = 64;
16
+ const namedClip = v.pipe(
17
+ v.string(),
18
+ v.maxLength(MAX_NAMED_CLIP_LENGTH),
19
+ v.regex(/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)?$/u),
20
+ v.transform((name): CreatureSkinClipName => name as CreatureSkinClipName),
21
+ );
22
+ const CreatureSkinClipNameSchema: v.GenericSchema<string, CreatureSkinClipName> =
23
+ v.union([SkinClipNameSchema, namedClip]);
11
24
  const joint = v.pipe(v.string(), v.regex(/^[A-Za-z][A-Za-z0-9_.-]*$/u), v.maxLength(64));
12
25
  const bytes = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(25_000_000));
13
26
 
14
27
  /** One exported skin: the GLB hash and rig. Clips may be empty for a poser-driven
15
28
  * rig; loop bindings must still name a declared clip. */
16
- export const SkinRowSchema: v.GenericSchema<SkinRowInput, SkinRow> = v.object({
29
+ const SkinRowSchema: v.GenericSchema<SkinRowInput, SkinRow> = v.object({
17
30
  id, file: hash, family: v.picklist(['toon', 'pbr']),
18
- rig: v.strictObject({ skeleton: v.pipe(v.string(), v.regex(/^[a-z][A-Za-z0-9.]*$/u), v.maxLength(128)), joints: v.pipe(v.array(v.pipe(v.array(joint), v.minLength(1), v.maxLength(128))), v.length(1)), clips: v.pipe(v.array(SkinClipNameSchema), v.maxLength(32)), sockets: v.pipe(v.array(joint), v.maxLength(32)) }),
31
+ rig: v.strictObject({ skeleton: v.pipe(v.string(), v.regex(/^[a-z][A-Za-z0-9.]*$/u), v.maxLength(128)), joints: v.pipe(v.array(v.pipe(v.array(joint), v.minLength(1), v.maxLength(128))), v.length(1)), clips: v.pipe(v.array(CreatureSkinClipNameSchema), v.maxLength(32)), sockets: v.pipe(v.array(joint), v.maxLength(32)) }),
19
32
  cost: v.strictObject({ decoded: bytes, gpu: bytes, triangles: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(400_000)), draws: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(512)) }),
20
33
  });
21
34
  /** A validated exported skin row. */
22
35
 
23
36
  /** How a skin plays and draws: the family material entry (SF10a, validated by the family registry) the clips that loop and independent numeric pose clocks; `materials` (TE-ENG10) maps GLB material names to look materials (`./skin-materials`). */
24
- export const SkinBindingSchema: v.GenericSchema<SkinBindingInput, SkinBinding> = v.strictObject({ skin: id, material: v.record(v.string(), v.unknown()), materials: v.exactOptional(SkinMaterialsSchema), loops: v.pipe(v.array(SkinClipNameSchema), v.maxLength(32)), poseLayers: v.exactOptional(v.record(SkinClipNameSchema, v.pipe(v.array(SkinPoseLayerSchema), v.maxLength(32)))) });
37
+ const SkinBindingSchema: v.GenericSchema<SkinBindingInput, SkinBinding> = v.strictObject({ skin: id, material: v.record(v.string(), v.unknown()), materials: v.exactOptional(SkinMaterialsSchema), loops: v.pipe(v.array(CreatureSkinClipNameSchema), v.maxLength(32)), poseLayers: v.exactOptional(v.record(CreatureSkinClipNameSchema, v.pipe(v.array(SkinPoseLayerSchema), v.maxLength(32)))) });
25
38
  /** A validated skin binding. */
26
39
 
27
40
 
28
41
  /** Every creature kind, including flying/custom rigs, exposes body and head for collision and view binding. */
29
- export function validateCreatureBones(species: string, names: readonly string[]): void {
42
+ function validateCreatureBones(species: string, names: readonly string[]): void {
30
43
  for (const bone of ['body', 'head']) {
31
44
  if (!names.includes(bone)) throw new Error(`species '${species}': rig missing required bone '${bone}'`);
32
45
  }
33
46
  }
34
47
 
35
48
  /** Validate the export half's rows; unknown fields (its notes and motion receipt) are ignored. */
36
- export function parseSkinRows(input: unknown): SkinRow[] {
49
+ function parseSkinRows(input: unknown): SkinRow[] {
37
50
  const r = v.safeParse(v.pipe(v.array(SkinRowSchema), v.maxLength(256)), input);
38
51
  if (!r.success) throw new Error(`skins: ${r.issues.map((i) => `${v.getDotPath(i) ?? '(root)'}: ${i.message}`).join('; ')}`);
39
52
  if (new Set(r.output.map((row) => row.id)).size !== r.output.length) throw new Error('skins: unique ids');
40
53
  return r.output;
41
54
  }
42
55
  /** Validate skin bindings against their rows: one per skin, loops only over the row's clips, with bounded periodic layer tables. */
43
- export function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): SkinBinding[] {
56
+ function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): SkinBinding[] {
44
57
  const r = v.safeParse(v.pipe(v.array(SkinBindingSchema), v.maxLength(256)), input);
45
58
  if (!r.success) throw new Error(`skin bindings: ${r.issues.map((i) => `${v.getDotPath(i) ?? '(root)'}: ${i.message}`).join('; ')}`);
46
59
  for (const binding of r.output) {
47
60
  const row = rows.find((candidate) => candidate.id === binding.skin);
48
61
  if (row === undefined) throw new Error(`skin bindings: no skin ${binding.skin}`);
49
62
  if (binding.loops.some((name) => !row.rig.clips.includes(name))) throw new Error(`skin bindings: ${binding.skin} loops an unknown clip`);
50
- for (const [name, layers] of Object.entries(binding.poseLayers ?? {})) { if (layers === undefined) continue; if (!binding.loops.includes(name as SkinClipName)) throw new Error('skin layers require a looping base'); validateSkinLayers(layers, row.rig.joints[0] ?? []); }
63
+ for (const [name, layers] of Object.entries(binding.poseLayers ?? {})) {
64
+ if (layers === undefined) continue;
65
+ if (!binding.loops.some((loop): boolean => loop === name)) throw new Error('skin layers require a looping base');
66
+ validateSkinLayers(layers, row.rig.joints[0] ?? []);
67
+ }
51
68
  }
52
69
  if (new Set(r.output.map((binding) => binding.skin)).size !== r.output.length) throw new Error('skin bindings: one per skin');
53
70
  return r.output;
@@ -55,8 +72,8 @@ export function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): Ski
55
72
 
56
73
 
57
74
  /** Admitted data contracts, independent of validator implementation metadata. */
58
- export type SkinClipNameRowsInput = string;
59
- export type SkinClipNameRows = SkinClipName;
75
+ type SkinClipNameRowsInput = string;
76
+ type SkinClipNameRows = SkinClipName;
60
77
  interface SkinRowInputFields {
61
78
  id: string;
62
79
  file: string;
@@ -74,7 +91,7 @@ interface SkinRowInputFields {
74
91
  draws: number;
75
92
  };
76
93
  }
77
- export type SkinRowInput = { [Key in keyof SkinRowInputFields]: SkinRowInputFields[Key] };
94
+ type SkinRowInput = { [Key in keyof SkinRowInputFields]: SkinRowInputFields[Key] };
78
95
  interface SkinRowFields {
79
96
  id: string;
80
97
  file: string;
@@ -82,7 +99,7 @@ interface SkinRowFields {
82
99
  rig: {
83
100
  skeleton: string;
84
101
  joints: ((string)[])[];
85
- clips: (SkinClipNameRows)[];
102
+ clips: CreatureSkinClipName[];
86
103
  sockets: (string)[];
87
104
  };
88
105
  cost: {
@@ -92,20 +109,23 @@ interface SkinRowFields {
92
109
  draws: number;
93
110
  };
94
111
  }
95
- export type SkinRow = { [Key in keyof SkinRowFields]: SkinRowFields[Key] };
112
+ type SkinRow = { [Key in keyof SkinRowFields]: SkinRowFields[Key] };
96
113
  interface SkinBindingInputFields {
97
114
  skin: string;
98
115
  material: Record<string, unknown>;
99
116
  materials?: Record<string, string>;
100
117
  loops: (SkinClipNameRowsInput)[];
101
- poseLayers?: v.InferInput<v.RecordSchema<v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
118
+ poseLayers?: v.InferInput<v.RecordSchema<v.GenericSchema<string, CreatureSkinClipName>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
102
119
  }
103
- export type SkinBindingInput = { [Key in keyof SkinBindingInputFields]: SkinBindingInputFields[Key] };
120
+ type SkinBindingInput = { [Key in keyof SkinBindingInputFields]: SkinBindingInputFields[Key] };
104
121
  interface SkinBindingFields {
105
122
  skin: string;
106
123
  material: Record<string, unknown>;
107
124
  materials?: Record<string, string>;
108
- loops: (SkinClipNameRows)[];
109
- poseLayers?: v.InferOutput<v.RecordSchema<v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
125
+ loops: CreatureSkinClipName[];
126
+ poseLayers?: v.InferOutput<v.RecordSchema<v.GenericSchema<string, CreatureSkinClipName>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
110
127
  }
111
- export type SkinBinding = { [Key in keyof SkinBindingFields]: SkinBindingFields[Key] };
128
+ type SkinBinding = { [Key in keyof SkinBindingFields]: SkinBindingFields[Key] };
129
+
130
+ export { SkinClipNameSchema, CreatureSkinClipNameSchema, SkinRowSchema, SkinBindingSchema, validateCreatureBones, parseSkinRows, parseSkinBindings };
131
+ export type { SkinClipName, CreatureSkinClipName, SkinClipNameRowsInput, SkinClipNameRows, SkinRowInput, SkinRow, SkinBindingInput, SkinBinding };
@@ -1,4 +1,6 @@
1
1
  import * as v from 'valibot';
2
+ import { CreatureSkinClipNameSchema } from './skinData.ts';
3
+ import type { CreatureSkinClipName } from './skinData.ts';
2
4
 
3
5
  /** The look recipe for an exported skin, and its animation recipe. */
4
6
  const SKIN_LOOK_RECIPE = 'platform.skin';
@@ -18,13 +20,30 @@ interface SkinVariantsFields { version: typeof VARIANTS_VERSION; skins: Record<s
18
20
  type SkinVariants = { [Key in keyof SkinVariantsFields]: SkinVariantsFields[Key] };
19
21
  const SkinVariantsSchema: v.GenericSchema<SkinVariants> = v.strictObject({ version: v.literal(VARIANTS_VERSION),
20
22
  skins: variantSkins });
23
+ type SkinClipState = 'idle' | 'idle.graze' | 'walk' | 'attack' | 'hit' | 'die';
24
+ interface SkinClipMap<Name extends string = CreatureSkinClipName> {
25
+ states?: Partial<Record<SkinClipState, Name>>;
26
+ abilities?: Record<string, Name>;
27
+ }
28
+ const MAX_ABILITY_ID = 128;
29
+ const MAX_ABILITY_CLIPS = 32;
30
+ const clipSlot = v.exactOptional(CreatureSkinClipNameSchema);
31
+ const abilityName = v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9.:-]*$/u), v.maxLength(MAX_ABILITY_ID));
32
+ const stateClips = v.strictObject({
33
+ idle: clipSlot, 'idle.graze': clipSlot, walk: clipSlot, attack: clipSlot, hit: clipSlot, die: clipSlot,
34
+ });
35
+ const abilityClips = v.pipe(v.record(abilityName, CreatureSkinClipNameSchema), v.maxEntries(MAX_ABILITY_CLIPS));
36
+ const SkinClipMapSchema: v.GenericSchema<SkinClipMap<string>, SkinClipMap> = v.strictObject({
37
+ states: v.exactOptional(stateClips),
38
+ abilities: v.exactOptional(abilityClips),
39
+ });
21
40
  /** The animation recipe's parameters. */
22
41
  const SkinClipParametersSchema: v.GenericSchema<SkinClipParametersRowsInput, SkinClipParametersRows> = v.strictObject({ attackSpan: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0.05), v.maxValue(10)), 1) });
23
42
  /** The content-addressed skin file: one export row and its binding (validated together by the SF9c parsers). */
24
43
  const ShardSkinFileSchema: v.GenericSchema<ShardSkinFileRowsInput, ShardSkinFileRows> = v.strictObject({ row: v.unknown(), binding: v.unknown() });
25
44
 
26
45
  /** A parsed skin look: the file it names and the attack span its clip was sampled with. */
27
- interface SkinLookParameters { skin: string; variants?: string; attackSpan: number }
46
+ interface SkinLookParameters { skin: string; variants?: string; attackSpan: number; clipMap?: SkinClipMap }
28
47
 
29
48
  /** Admitted data contracts, independent of validator implementation metadata. */
30
49
  type SkinLookParametersRowsInput = SkinLookParametersRows;
@@ -48,4 +67,4 @@ interface ShardSkinFileRowsFields {
48
67
  }
49
68
  type ShardSkinFileRows = { [Key in keyof ShardSkinFileRowsFields]: ShardSkinFileRowsFields[Key] };
50
69
 
51
- export { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE, SkinLookParametersSchema, type SkinVariants, SkinVariantsSchema, SkinClipParametersSchema, ShardSkinFileSchema, type SkinLookParameters, type SkinLookParametersRowsInput, type SkinLookParametersRows, type SkinClipParametersRowsInput, type SkinClipParametersRows, type ShardSkinFileRowsInput, type ShardSkinFileRows };
70
+ export { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE, SkinLookParametersSchema, type SkinVariants, SkinVariantsSchema, SkinClipParametersSchema, SkinClipMapSchema, ShardSkinFileSchema, type SkinClipMap, type SkinClipState, type SkinLookParameters, type SkinLookParametersRowsInput, type SkinLookParametersRows, type SkinClipParametersRowsInput, type SkinClipParametersRows, type ShardSkinFileRowsInput, type ShardSkinFileRows };
@@ -8,7 +8,7 @@ function shardfileWireBytes(source:Wire):number{
8
8
  return source.files.reduce((sum,file)=>sum+file.compressed,0)
9
9
  +source.requires.commons.reduce((sum,hash)=>sum+(source.requires.commonsWire[hash]??0),0);
10
10
  }
11
- /** Exact existing source/wire claim, computed once by the publisher for first-party clients. */
11
+ /** Exact existing source/wire claim, computed once by the publisher for built-in clients. */
12
12
  function publishedSourceResidency(source:Shardfile):number{
13
13
  const accounting={heapBytes:0};preflightShardfile(source,accounting);
14
14
  return shardfileWireBytes(source)+accounting.heapBytes*2+(source.files.length+source.requires.commons.length)*128+1024;
@@ -33,7 +33,7 @@ import type { GenericSchema } from 'valibot'
33
33
  // `placements` are `src/game/shared/grid/singleplayer.json` today, field for
34
34
  // field. A cell's `slug` keeps the authored spelling, so `_template` stays
35
35
  // `_template` although its product's `identity.slug` cannot start with an
36
- // underscore: `shardSlugOf` is the one mapping, as `firstPartyInstance` does.
36
+ // underscore: `shardSlugOf` is the one mapping, as `catalogueInstance` does.
37
37
 
38
38
  const FORMAT_VERSION = 0
39
39
  const MIN_SIZE = 1
@@ -43,7 +43,7 @@ const metre = v.pipe(v.number(), v.finite(), v.minValue(-1000), v.maxValue(1000)
43
43
  const groundPoint = v.tuple([metre, metre]);
44
44
  const seed = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(0xffffffff));
45
45
  /**
46
- * A hybrid shard's declared ground (G4): its baked terrain by key and seed, the trails, pads and pond its terrain metadata
46
+ * A runtime shard's declared ground (G4): its baked terrain by key and seed, the trails, pads and pond its terrain metadata
47
47
  * reads (grading masks, grass and forest clearings), its rest water level and render datum. Ordinary bodies use the
48
48
  * shardfile's water grammar; a ground-only basin borrows this field's mask and live water level. The game builds the
49
49
  * manifest ground from these rows (`declaredGround`); no shard code. Generated from the shard's own layout.
@@ -119,7 +119,7 @@ export async function validationSourceBytesPaced(source: unknown, pause: () => P
119
119
  }
120
120
  /** The build hashes the engine/game validator sources; unbundled clients always validate in full. */
121
121
  export function validationRevision(): string | null { return typeof __SHARDFILE_VALIDATOR__ === 'string' ? __SHARDFILE_VALIDATOR__ : null; }
122
- /** Cache metadata is trusted local storage, but stale or malformed verdicts are never accepted. */
122
+ /** Cache metadata is host-owned local storage, but stale or malformed verdicts are never accepted. */
123
123
  export function readValidationReceipt(input: unknown, sourceHash: string): ValidationReceipt | null {
124
124
  if (typeof input !== 'object' || input === null || !('revision' in input) || typeof input.revision !== 'string' || input.revision !== validationRevision() || !('sourceHash' in input) || input.sourceHash !== sourceHash || !('worst' in input)) return null;
125
125
  const indexHash: unknown = 'indexHash' in input ? input.indexHash : undefined;
@@ -133,7 +133,7 @@ export function readValidationReceipt(input: unknown, sourceHash: string): Valid
133
133
  if (typeof cost.playing !== 'number' || typeof cost.loading !== 'number' || typeof cost.accounted !== 'number' || typeof cost.location[0] !== 'number' || typeof cost.location[1] !== 'number') return null;
134
134
  return { revision: input.revision, sourceHash, ...(typeof indexHash === 'string' ? { indexHash } : {}),...(typeof residentBytes==='number'?{residentBytes}:{}), worst: { playing: cost.playing, loading: cost.loading, accounted: cost.accounted, location: [cost.location[0], cost.location[1]] } };
135
135
  }
136
- /** Only the client build's own validated first-party catalogue can skip a first asset-header validation. */
136
+ /** Only the client build's own validated built-in catalogue can skip a first asset-header validation. */
137
137
  export function builtValidationReceipt(sourceHash: string, indexHash?: string): ValidationReceipt | null {
138
138
  const rows: unknown = typeof __SHARDFILE_VERDICTS__ === 'object' ? __SHARDFILE_VERDICTS__ : null;
139
139
  if (!Array.isArray(rows)) return null;
@@ -75,7 +75,7 @@ export const ThrownWeaponProfileSchema: v.SchemaWithPipe<readonly [v.StrictObjec
75
75
  }), v.check(row => row.carried <= row.pool, 'Carried thrown weapons fit the native pool'));
76
76
 
77
77
  /** Native timed lash contacts: bounded unroll/double-crack clocks, pull/stagger reactions and named pipeline moves.
78
- * The profile supplies values only; the trusted family retains its contact ordering and continuation. */
78
+ * The profile supplies values only; the native family retains its contact ordering and continuation. */
79
79
  export const LashWeaponProfileSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly family: v.GenericSchema<LashWeaponProfileRowsInput['family'], LashWeaponProfileRows['family']>; readonly contact: v.ExactOptionalSchema<v.GenericSchema<Exclude<LashWeaponProfileRowsInput['contact'], undefined>, Exclude<LashWeaponProfileRows['contact'], undefined>>, undefined>; readonly timing: v.GenericSchema<LashWeaponProfileRowsInput['timing'], LashWeaponProfileRows['timing']>; readonly moves: v.GenericSchema<LashWeaponProfileRowsInput['moves'], LashWeaponProfileRows['moves']>; }, undefined>, v.CheckAction<{ [K in keyof LashWeaponProfileRows]: LashWeaponProfileRows[K] }, 'Ordered native lash contacts'>]> = v.pipe(v.strictObject({
80
80
  family: v.literal('lash'),
81
81
  contact: v.exactOptional(v.strictObject({ chestHeight: scalar, bodyAllowance: scalar })),
@@ -93,7 +93,7 @@ const reaction = v.variant('kind', [
93
93
  v.strictObject({ when: v.picklist(['before', 'survived']), kind: v.literal('stagger'),
94
94
  strength: scalar, aboveHealth: v.exactOptional(scalar) }),
95
95
  ]);
96
- /** Ordered cone/lane contacts, with authority supplied by the trusted owner rather than JSON. */
96
+ /** Ordered cone/lane contacts, with authority supplied by the native owner rather than JSON. */
97
97
  export const MeleeContactRowSchema: v.GenericSchema<MeleeContactDataInput, MeleeContactData> = v.pipe(v.strictObject({
98
98
  lane: v.picklist(['primary', 'secondary']), heavy: v.boolean(), cooldown: seconds,
99
99
  shape: v.picklist(['cone', 'lane']), reach: v.pipe(positive, v.maxValue(20)),