@wildshard/shard-format 0.79.3 → 0.81.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.
@@ -4,8 +4,6 @@ import { DeclaredBodyOpsSchema, type DeclaredBodyOpsRows } from './bodySlots.ts'
4
4
  import {StealthRowsSchema,type StealthRows} from './stealth.ts';
5
5
  import { PaintedLookSchema, type PaintedLookRow } from './paintedLook.ts';
6
6
  import { ColourFunctionBookSchema, type ColourFunctionBook } from './colourFunction.ts';
7
- import { RiggedHullBookSchema, type RiggedHullBook } from './riggedHulls.ts';
8
- import { HullLookBookSchema, type HullLookBookRows } from './speciesLooks.ts';
9
7
  import { ExplorerCatalogueSchema, type ExplorerCatalogue } from './explorerCatalogue.ts';
10
8
  import { ToonLookSchema, type ToonLookRow } from './toonLook.ts';
11
9
  import { KEYED_SKY, type KeyedSkyStyle } from './keyedSky.ts';
@@ -25,7 +23,6 @@ import { LoadoutSchema, type LoadoutRows } from './loadout.ts';
25
23
  import { HeldFinishesSchema, type HeldFinishesRows } from './heldFinishes.ts';
26
24
  import { HeldGearSchema, type HeldGearRows } from './heldGear.ts';
27
25
  import * as v from 'valibot';
28
- import { isJsonData } from './json.ts';
29
26
  import { HeldEquipmentSchema, type HeldEquipmentRows } from './heldEquipment.ts';
30
27
  import { HeldMeleeSchema } from './items.ts';
31
28
  import type { NativeSweptPolicyRows } from './items.ts';
@@ -45,17 +42,12 @@ import { WaterFieldSchema } from './water-field.ts';
45
42
  import type { WaterFieldRows } from './water-field.ts';
46
43
  import type { Vehicles } from './vehicles.ts';
47
44
 
48
- /** ONE-FORMAT OF30: a retired section an older product may still carry: plain JSON, read by nothing. */
49
- const RETIRED_SECTION: v.GenericSchema<unknown, unknown> = v.pipe(v.unknown(), v.check(isJsonData, 'A retired section must be plain JSON'));
50
-
51
45
  /** New plain-value sections supplement the unchanged v1 model assembled from the older section envelopes. */
52
46
  export interface PlatformDataSections {
53
47
  'collections/displays': CollectionDisplaysRows;
54
48
  'models/island-library': ResolvedIslandLibraryRows;
55
49
  'player/stealth':StealthRows;
56
50
  'explore/catalogue': ExplorerCatalogue;
57
- 'look/rigged-hulls': RiggedHullBook;
58
- 'look/hull-book': HullLookBookRows;
59
51
  'look/toon': ToonLookRow;
60
52
  'look/painted': PaintedLookRow;
61
53
  'look/colour-functions': ColourFunctionBook;
@@ -77,8 +69,6 @@ export interface PlatformDataSections {
77
69
  'held/melee': NativeSweptPolicyRows;
78
70
  'ui/completion': CompletionRows;
79
71
  'sim/runtime-plan': NativeRuntimePlanData;
80
- /** ONE-FORMAT OF30: retired. An older product still carrying it admits; nothing reads it. */
81
- 'actors/species-programs': unknown;
82
72
  'actors/moves': ActorMoves;
83
73
  'actors/spawn-scripts': SpawnScriptRows[];
84
74
  'actors/return-scripts': ReturnModuleRow[];
@@ -101,9 +91,6 @@ export const PLATFORM_DATA_SECTIONS: Readonly<{ [Name in keyof PlatformDataSecti
101
91
  'models/island-library': { schema: ResolvedIslandLibrarySchema },
102
92
  'player/stealth':{schema:StealthRowsSchema},
103
93
  'explore/catalogue': { schema: ExplorerCatalogueSchema },
104
- 'actors/species-programs': { schema: RETIRED_SECTION },
105
- 'look/rigged-hulls': { schema: RiggedHullBookSchema },
106
- 'look/hull-book': { schema: HullLookBookSchema },
107
94
  'look/toon': { schema: ToonLookSchema },
108
95
  'look/painted': { schema: PaintedLookSchema },
109
96
  'look/colour-functions': { schema: ColourFunctionBookSchema },
@@ -151,8 +138,6 @@ export function parsePlatformDataSection(name: 'collections/displays', value: un
151
138
  export function parsePlatformDataSection(name: 'models/island-library', value: unknown): ResolvedIslandLibraryRows;
152
139
  export function parsePlatformDataSection(name:'player/stealth',value:unknown):StealthRows;
153
140
  export function parsePlatformDataSection(name: 'explore/catalogue', value: unknown): ExplorerCatalogue;
154
- export function parsePlatformDataSection(name: 'look/rigged-hulls', value: unknown): RiggedHullBook;
155
- export function parsePlatformDataSection(name: 'look/hull-book', value: unknown): HullLookBookRows;
156
141
  export function parsePlatformDataSection(name: 'look/toon', value: unknown): ToonLookRow;
157
142
  export function parsePlatformDataSection(name: 'look/painted', value: unknown): PaintedLookRow;
158
143
  export function parsePlatformDataSection(name: 'look/colour-functions', value: unknown): ColourFunctionBook;
@@ -164,7 +149,6 @@ export function parsePlatformDataSection(name: 'held/loadout', value: unknown):
164
149
  export function parsePlatformDataSection(name: 'held/finishes', value: unknown): HeldFinishesRows;
165
150
  export function parsePlatformDataSection(name: 'held/gear', value: unknown): HeldGearRows;
166
151
  export function parsePlatformDataSection(name: 'held/equipment', value: unknown): HeldEquipmentRows;
167
- export function parsePlatformDataSection(name: 'actors/species-programs', value: unknown): unknown;
168
152
  export function parsePlatformDataSection(name: 'actors/moves', value: unknown): ActorMoves;
169
153
  export function parsePlatformDataSection(name: 'actors/strikes', value: unknown): CreatureStrikes;
170
154
  export function parsePlatformDataSection(name: 'actors/spawn-scripts', value: unknown): SpawnScriptRows[];
@@ -3,7 +3,7 @@
3
3
  * `platform.rig` names the `world/scenes` models library (`parameters.library`) whose rigs carry the body, and optionally
4
4
  * the rig body (`parameters.body`, else the species' kind). The rig brings its own skeleton, surfaces and clips, so the row
5
5
  * names no material and its animation is the rig's own (`platform.rig`, no parameters). This replaces a page's
6
- * `species.program` feature for drawing declared bodies (Sunscar Dunes' ray, strider and Matriarch).
6
+ * deleted species program for drawing declared bodies (Sunscar Dunes' ray, strider and Matriarch).
7
7
  */
8
8
  import {
9
9
  exactOptional,
@@ -139,7 +139,7 @@ function rigLookRules(
139
139
  }
140
140
 
141
141
  /** OF19d1: a page whose plan keeper stands no body (`keeper` is its actor ids), and whose every declared spawn's species
142
- * has a look row, draws its creatures as an ordinary upload does, so it needs no `species.program` feature. */
142
+ * has a look row, draws its creatures as an ordinary upload does. */
143
143
  function declaredLooksDraw(
144
144
  shard: Readonly<RigLookShard>,
145
145
  keeper: readonly string[],
@@ -156,22 +156,12 @@ function declaredLooksDraw(
156
156
  )
157
157
  }
158
158
 
159
- /** Whether a data page draws its declared bodies from their looks: it has no `species.program` feature, its runtime plan's
160
- * keeper (`plan`, the `sim/runtime-plan` section) stands no body, and every declared spawn's species has a look. */
159
+ /** Whether a data page draws its declared bodies from their looks: its runtime plan's keeper (`plan`, the
160
+ * `sim/runtime-plan` section) stands no body, and every declared spawn's species has a look. */
161
161
  function pageDrawsDeclaredLooks(
162
162
  shard: Readonly<RigLookShard>,
163
163
  plan: unknown,
164
- features: readonly Readonly<{ kind: string }>[],
165
164
  ): boolean {
166
- if (
167
- plan === undefined ||
168
- features.some(
169
- (row: Readonly<{ kind: string }>): boolean =>
170
- row.kind === 'species.program',
171
- )
172
- ) {
173
- return false
174
- }
175
165
  return declaredLooksDraw(shard, nativeRuntimeActorIds(plan))
176
166
  }
177
167
 
@@ -1,6 +1,3 @@
1
- import * as schema from 'valibot';
2
- import { isJsonData } from './json.ts';
3
-
4
1
  /** A generator flap: the back plane z(y) = z0 + (y - y0) · slope; every vertex above `yMin` behind it is pressed onto it,
5
2
  * keeping `keep` of its depth; `bulge` (m) rounds the pressed patch out into a dome (0 at its rim). */
6
3
  export interface RiggedHullFlap {
@@ -57,104 +54,11 @@ export interface RiggedHullUrls {
57
54
  readonly parts?: { readonly file: string; readonly nodes: Readonly<Record<string, string>> };
58
55
  }
59
56
 
60
- /** A generated tier book. Product references are logical blob names; coats keep
61
- * their original KTX2 cache keys and image URLs. */
57
+ /** A generated tier book, a shard generator's own data (its section and schema are deleted,
58
+ * FORMAT-PRUNE FP20). Product references are logical blob names; coats keep their original KTX2 cache keys and image
59
+ * URLs. */
62
60
  export interface RiggedHullBook {
63
61
  readonly family: RiggedHullFamilyRow;
64
62
  readonly tiers: Readonly<Record<'phone' | 'desktop', RiggedHullUrls>>;
65
63
  readonly productFiles: boolean;
66
64
  }
67
-
68
- const text = schema.pipe(schema.string(), schema.minLength(1), schema.maxLength(512)), num = schema.pipe(schema.number(), schema.finite());
69
- const rgbSchema = schema.tuple([num, num, num]);
70
- const resourcesSchema = schema.strictObject({
71
- files: schema.record(text, schema.union([text, schema.strictObject({ rig: text, base: text, normal: text })])),
72
- coats: schema.record(text, schema.strictObject({ key: text, image: text })),
73
- coatDecode: schema.exactOptional(schema.literal('bitmap')), vertexColours: schema.exactOptional(schema.boolean()),
74
- doubleSided: schema.exactOptional(schema.array(text)), parts: schema.exactOptional(schema.strictObject({ file: text, nodes: schema.record(text, text) })),
75
- });
76
- const bookSchema = schema.strictObject({ productFiles: schema.boolean(),
77
- family: schema.strictObject({ label: text, rigs: schema.pipe(schema.array(text), schema.maxLength(128)), hulls: schema.record(text, text),
78
- flaps: schema.exactOptional(schema.record(text, schema.strictObject({ yMin: num, y0: num, z0: num, slope: num, keep: num, bulge: num }))),
79
- fur: schema.exactOptional(schema.record(text, schema.record(text, schema.strictObject({ rim: rgbSchema, sheenColor: rgbSchema })))) }),
80
- tiers: schema.strictObject({ phone: resourcesSchema, desktop: resourcesSchema }),
81
- });
82
- /** Build-time and product admission share the same complete resource contract. */
83
- export const RiggedHullBookSchema: schema.GenericSchema<RiggedHullBookRowsInput, RiggedHullBookRows> = schema.pipe(bookSchema, schema.check(book => Object.values(book.tiers).every(source =>
84
- [...book.family.rigs, ...Object.values(book.family.hulls)].every(hull => source.files[hull] !== undefined)), 'Missing hull resource'));
85
- /** Admit a complete immutable book before any loader starts. */
86
- export function parseRiggedHullBook(input: unknown): RiggedHullBook {
87
- if (!isJsonData(input)) throw new Error('Rigged hull book requires plain data');
88
- const book = schema.parse(RiggedHullBookSchema, input);
89
- return book;
90
- }
91
-
92
- /** Admitted data contracts, independent of validator implementation metadata. */
93
- export type RiggedHullBookRowsInput = RiggedHullBookRows;
94
- interface RiggedHullBookRowsFields {
95
- productFiles: boolean;
96
- family: {
97
- label: string;
98
- rigs: (string)[];
99
- hulls: Record<string, string>;
100
- flaps?: Record<string, {
101
- yMin: number;
102
- y0: number;
103
- z0: number;
104
- slope: number;
105
- keep: number;
106
- bulge: number;
107
- }>;
108
- fur?: Record<string, Record<string, {
109
- rim: [
110
- number,
111
- number,
112
- number
113
- ];
114
- sheenColor: [
115
- number,
116
- number,
117
- number
118
- ];
119
- }>>;
120
- };
121
- tiers: {
122
- phone: {
123
- files: Record<string, (string) | ({
124
- rig: string;
125
- base: string;
126
- normal: string;
127
- })>;
128
- coats: Record<string, {
129
- key: string;
130
- image: string;
131
- }>;
132
- coatDecode?: 'bitmap';
133
- vertexColours?: boolean;
134
- doubleSided?: (string)[];
135
- parts?: {
136
- file: string;
137
- nodes: Record<string, string>;
138
- };
139
- };
140
- desktop: {
141
- files: Record<string, (string) | ({
142
- rig: string;
143
- base: string;
144
- normal: string;
145
- })>;
146
- coats: Record<string, {
147
- key: string;
148
- image: string;
149
- }>;
150
- coatDecode?: 'bitmap';
151
- vertexColours?: boolean;
152
- doubleSided?: (string)[];
153
- parts?: {
154
- file: string;
155
- nodes: Record<string, string>;
156
- };
157
- };
158
- };
159
- }
160
- export type RiggedHullBookRows = { [Key in keyof RiggedHullBookRowsFields]: RiggedHullBookRowsFields[Key] };
@@ -4,8 +4,6 @@ import type {StealthRows} from './stealth.ts';
4
4
  import type { ColourFunctionBook } from './colourFunction.ts';
5
5
  import type { PaintedLookRow } from './paintedLook.ts';
6
6
  import type { ExplorerCatalogue } from './explorerCatalogue.ts';
7
- import type { RiggedHullBook } from './riggedHulls.ts';
8
- import type { HullLookBookRows } from './speciesLooks.ts';
9
7
  import type { ToonLookRow } from './toonLook.ts';
10
8
  import type { KeyedSkyStyle } from './keyedSky.ts';
11
9
  import type { SpawnScriptRows } from './spawnScripts.ts';
@@ -58,8 +56,6 @@ export interface PlatformSections {
58
56
  'view/modules': ViewModuleRow[];
59
57
  /** Client-only ordered model references, ignored by simulation. */
60
58
  'explore/catalogue': ExplorerCatalogue;
61
- 'look/rigged-hulls': RiggedHullBook;
62
- 'look/hull-book': HullLookBookRows;
63
59
  'look/toon': ToonLookRow;
64
60
  'look/painted': PaintedLookRow;
65
61
  'look/colour-functions': ColourFunctionBook;
@@ -111,8 +107,6 @@ export interface PlatformSections {
111
107
  'look/look': Pick<Shardfile, 'look' | 'presentation'>;
112
108
  'look/map': Pick<Shardfile, 'map'>;
113
109
  'look/materials': { readonly rows: Pick<Rows, 'looks'> };
114
- /** ONE-FORMAT OF30: retired; an older product may carry it, nothing reads it. */
115
- 'actors/species-programs': unknown;
116
110
  /** new (KA5): sim-side steering mechanics, independently selected by decisions. */
117
111
  'actors/moves': ActorMoves;
118
112
  'actors/spawn-scripts': SpawnScriptRows[];
@@ -0,0 +1,18 @@
1
+ import { maxLength, pipe, regex, string } from 'valibot'
2
+
3
+ import type { GenericSchema } from 'valibot'
4
+
5
+ // SemVer without build metadata, reserved for the catalogue's migrated copies.
6
+ const number = String.raw`(?:0|[1-9]\d*)`
7
+ const identifier = String.raw`(?:${number}|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)`
8
+ const shardVersion = new RegExp(
9
+ String.raw`^${number}\.${number}\.${number}(?:-${identifier}(?:\.${identifier})*)?$`,
10
+ 'u',
11
+ )
12
+ const MAX_VERSION_LENGTH = 128
13
+
14
+ export const ShardVersionSchema: GenericSchema<string> = pipe(
15
+ string(),
16
+ maxLength(MAX_VERSION_LENGTH),
17
+ regex(shardVersion, 'Expected a shardVersion without build metadata'),
18
+ )
@@ -1,5 +1,4 @@
1
1
  import { creatureSizeRules, spawnCapacity } from './creature-sizes.ts';
2
- import { readSpeciesPrograms } from './speciesPrograms.ts';
3
2
  import type { StrikeDebrisPolicy } from './strike-debris.ts';
4
3
  import { strikeDebrisCatalogueRules } from './strike-debris.ts';
5
4
  import { harvestSpeciesRules } from './harvest-rows.ts';
@@ -332,10 +331,7 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
332
331
  const parsed = v.safeParse(VehiclesSchema, vehicles);
333
332
  errors.push(...parsed.success ? vehicleRules(parsed.output, s) : ['world/vehicles parses']);
334
333
  }
335
- const metadata = sections?.get('actors/species-programs');
336
- const roster = metadata === undefined ? undefined : readSpeciesPrograms(metadata);
337
- const targets = [...s.rows.species, ...roster?.page ?? [], ...roster?.native ?? [], ...roster?.program?.species ?? []];
338
- errors.push(...strikeDebrisCatalogueRules({ strikes: debrisStrikes, species: targets }));
334
+ errors.push(...strikeDebrisCatalogueRules({ strikes: debrisStrikes, species: s.rows.species }));
339
335
  const harvestItems = new Set((s.items.catalogue ?? []).map((row: Readonly<{ id: string }>): string => row.id));
340
336
  errors.push(...harvestSpeciesRules(s.rows.species, harvestItems));
341
337
  if (s.migrations.some(step => step.equipmentSlots?.some(rename => !s.items.rows.some(row => row.kind === 'weapon' && row.slot === rename.to)))) errors.push('migration equipment slots resolve declared weapons');