@wildshard/shard-format 0.62.0 → 0.64.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.62.0",
3
+ "version": "0.64.0",
4
4
  "description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -20,7 +20,7 @@ export type NativeAssemblyFeature =
20
20
  | { host: 'ammunition'; step: string; refill: string } | { host: 'boss.ground'; encounter: NativeAssemblyRead; binding: unknown }
21
21
  | { host: 'quest.composition'; rows: NativeAssemblyRead; spots: NativeAssemblyRead; counters: NativeAssemblyRead; document?: NativeAssemblyRead; table?: NativeAssemblyRead;
22
22
  contracts?: NativeAssemblyRead; props?: NativeAssemblyRead; readSpots?: boolean; nativeFeats?: boolean; barter?: boolean; director?: boolean; restoring?: boolean }
23
- | { host: 'quest.chapter'; id: string; rows: NativeAssemblyRead; wake: NativeAssemblyRead; reward: unknown; population: string }
23
+ | { host: 'quest.chapter'; id: string; rows: NativeAssemblyRead; wake: NativeAssemblyRead; reward: unknown; population?: string }
24
24
  | { host: 'quest.kill-steps'; rows: NativeAssemblyRead; counters: NativeAssemblyRead }
25
25
  | { host: 'weather.program'; program: NativeAssemblyRead } | { host: 'weather.native'; program: NativeAssemblyRead; shelters: NativeAssemblyRead; rows: NativeAssemblyRead }
26
26
  | { host: 'population.environment' | 'population.shelter' | 'population.roster' | 'riding.groups'; rows: NativeAssemblyRead }
@@ -96,7 +96,9 @@ const feature = v.variant('host', [
96
96
  v.strictObject({ host: v.literal('ammunition'), step: key, refill: key }), v.strictObject({ host: v.literal('boss.ground'), encounter: read, binding: v.unknown() }),
97
97
  v.strictObject({ host: v.literal('quest.composition'), rows: read, spots: read, counters: read, document: v.exactOptional(read), table: v.exactOptional(read), contracts: v.exactOptional(read), props: v.exactOptional(read),
98
98
  readSpots: flag, nativeFeats: flag, barter: flag, director: flag, restoring: flag }),
99
- v.strictObject({ host: v.literal('quest.chapter'), id: key, rows: read, wake: read, reward: v.unknown(), population: key }),
99
+ // ONE-FORMAT OF22c3: a chapter's wake names a declared boss fight; `population` named the retired mixed population and
100
+ // stays optional only for writers that still send it
101
+ v.strictObject({ host: v.literal('quest.chapter'), id: key, rows: read, wake: read, reward: v.unknown(), population: v.exactOptional(key) }),
100
102
  v.strictObject({ host: v.literal('quest.kill-steps'), rows: read, counters: read }),
101
103
  v.strictObject({ host: v.literal('weather.program'), program: read }), v.strictObject({ host: v.literal('weather.native'), program: read, shelters: read, rows: read }),
102
104
  v.strictObject({ host: v.picklist(['population.environment', 'population.shelter', 'population.roster', 'riding.groups']), rows: read }),
@@ -47,14 +47,22 @@ const strike: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.Ge
47
47
  const numbers = v.strictObject({ overcast: unit, rain: unit, wet: unit, wind: unit, fog: unit });
48
48
  const weather = v.strictObject({ id, states: v.pipe(v.array(v.strictObject({ id, next: id, length: ordered, numbers })), v.minLength(1), v.maxLength(64)), initial: numbers, soak: unit, dry: unit,
49
49
  modes: v.pipe(v.array(v.strictObject({ id, hold: v.nullable(id), at: unit, dry: v.boolean() })), v.maxLength(64)) });
50
+ /** OF23e3: a weather row may name its program instead of a plain chain: a product file the server parses as a
51
+ * `WeatherProgram` and runs (the rows a native assembly's `weather.program` host read; Pine's `world/weather.json`). */
52
+ const programFile = v.pipe(text, v.nonEmpty());
53
+ const programWeather = v.strictObject({ id, program: programFile });
54
+ const weatherRow = v.union([weather, programWeather]);
50
55
  const hour = v.pipe(finite, v.minValue(0), v.maxValue(24));
51
56
  const day = v.strictObject({ id, units: v.literal('hour'), start: hour,
52
57
  schedule: v.pipe(v.array(v.strictObject({ phase: v.picklist(['dawn', 'day', 'golden', 'dusk', 'night']), from: hour, to: hour, minutes: duration })), v.minLength(1), v.maxLength(64)),
53
58
  sun: v.strictObject({ maxElevation: v.pipe(finite, v.minValue(0), v.maxValue(90)), azimuthOffset: v.pipe(finite, v.minValue(-180), v.maxValue(180)) }),
54
59
  fixed: v.strictObject({ midday: hour, golden: hour, sunset: hour, night: hour }), presets: v.strictObject({ dawn: hour, noon: hour, dusk: hour, night: hour }) });
55
60
  const mods = v.strictObject({ speed: positive, chargeDist: positive, damageTaken: positive, chargeDamage: nonnegative, relentless: v.boolean() });
56
- const dims = v.strictObject({ bodyY: dimension, bodyHalfLen: dimension, bodyRadius: dimension, headRadius: dimension, legLen: legs,
57
- feet: v.pipe(v.array(v.tuple([finite, finite])), v.maxLength(16)), halfWidth: dimension });
61
+ // Body Y names the rig pivot. A flying hull can place it at zero.
62
+ const GROUND_PIVOT = 0;
63
+ const bodyPivot = v.union([v.literal(GROUND_PIVOT), dimension]);
64
+ const dims = v.strictObject({ bodyY: bodyPivot, bodyHalfLen: dimension, bodyRadius: dimension, headRadius: dimension, legLen: legs,
65
+ feet: v.pipe(v.array(v.tuple([finite, finite])), v.maxLength(16)), halfWidth: dimension, capsuleAxis: v.exactOptional(v.picklist(['y', 'z'])) });
58
66
  const variant = v.strictObject({ id, label: text, rarity: v.picklist(['common', 'uncommon', 'rare', 'legendary']), weight: nonnegative, scale: ordered, hp: positive, mods });
59
67
  const flight = v.strictObject({ altitude: v.pipe(finite, v.minValue(-250), v.maxValue(250)),
60
68
  above: v.exactOptional(v.picklist(['ground', 'world'])), climbRate: v.pipe(positive, v.maxValue(30)), diveRate: v.pipe(positive, v.maxValue(30)),
@@ -81,7 +89,7 @@ const loot = v.union([
81
89
  v.strictObject({ id, gear: v.literal('purse.coins'), finds: v.null(), marks: v.null(), charted: v.boolean(), chime: id, economy: v.exactOptional(LootEconomySchema) }),
82
90
  v.strictObject({ id, economy: BarterEconomySchema }),
83
91
  ]);
84
- const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v.ArraySchema<typeof strike, undefined>, v.MaxLengthAction<ShardRows['strikes'], 256, undefined>]>; readonly weather: v.GenericSchema<ShardRowsInput['weather'], ShardRows['weather']>; readonly days: v.GenericSchema<ShardRowsInput['days'], ShardRows['days']>; readonly species: v.GenericSchema<ShardRowsInput['species'], ShardRows['species']>; readonly looks: v.GenericSchema<ShardRowsInput['looks'], ShardRows['looks']>; readonly compendiums: v.GenericSchema<ShardRowsInput['compendiums'], ShardRows['compendiums']>; readonly loot: v.GenericSchema<ShardRowsInput['loot'], ShardRows['loot']>; }, undefined> = v.strictObject({ strikes: v.pipe(v.array(strike), v.maxLength(256)), weather: v.pipe(v.array(weather), v.maxLength(16)), days: v.pipe(v.array(day), v.maxLength(16)),
92
+ const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v.ArraySchema<typeof strike, undefined>, v.MaxLengthAction<ShardRows['strikes'], 256, undefined>]>; readonly weather: v.GenericSchema<ShardRowsInput['weather'], ShardRows['weather']>; readonly days: v.GenericSchema<ShardRowsInput['days'], ShardRows['days']>; readonly species: v.GenericSchema<ShardRowsInput['species'], ShardRows['species']>; readonly looks: v.GenericSchema<ShardRowsInput['looks'], ShardRows['looks']>; readonly compendiums: v.GenericSchema<ShardRowsInput['compendiums'], ShardRows['compendiums']>; readonly loot: v.GenericSchema<ShardRowsInput['loot'], ShardRows['loot']>; }, undefined> = v.strictObject({ strikes: v.pipe(v.array(strike), v.maxLength(256)), weather: v.pipe(v.array(weatherRow), v.maxLength(16)), days: v.pipe(v.array(day), v.maxLength(16)),
85
93
  species: v.pipe(v.array(species), v.maxLength(256)), looks: v.pipe(v.array(look), v.maxLength(256)), compendiums: v.pipe(v.array(v.union([basicCompendium, JournalRowSchema])), v.maxLength(16)), loot: v.pipe(v.array(loot), v.maxLength(16)) });
86
94
  /** Pure author rows: numeric weights, state output tables, clocks and registered view/presentation recipes. */
87
95
 
@@ -90,9 +98,12 @@ function rowRules(rows: ShardRows): string[] {
90
98
  const errors: string[] = harvestSpeciesRules(rows.species);
91
99
  for (const list of Object.values(rows)) if (new Set(list.map((r) => r.id)).size !== list.length) errors.push('unique row ids');
92
100
  for (const row of rows.loot) if (row.economy !== undefined && !('kind' in row.economy)) errors.push(...lootEconomyRules(row.economy));
101
+ // OF23e3: a row that names its program has no chain to check
93
102
  for (const w of rows.weather) {
94
- const states = new Set(w.states.map((s) => s.id));
95
- if (states.size !== w.states.length || w.states.some((s) => !states.has(s.next)) || w.modes.some((m) => m.hold !== null && !states.has(m.hold)) || new Set(w.modes.map((m) => m.id)).size !== w.modes.length) errors.push('weather states and transitions');
103
+ if (!('program' in w)) {
104
+ const states = new Set(w.states.map((s) => s.id));
105
+ if (states.size !== w.states.length || w.states.some((s) => !states.has(s.next)) || w.modes.some((m) => m.hold !== null && !states.has(m.hold)) || new Set(w.modes.map((m) => m.id)).size !== w.modes.length) errors.push('weather states and transitions');
106
+ }
96
107
  }
97
108
  for (const d of rows.days) if (d.schedule[0]?.from !== 0 || d.schedule.at(-1)?.to !== 24 || d.schedule.some((s, i) => s.from >= s.to || (i > 0 && d.schedule[i - 1]?.to !== s.from))) errors.push('complete ordered day schedule');
98
109
  const speciesIds = new Set(rows.species.map((s) => s.id));
@@ -135,14 +146,14 @@ function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input
135
146
  /** Admitted author data independent of validator implementation metadata. */
136
147
  type StrikeRowsInput = StrikeRows;
137
148
  interface StrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; overshoot?: number; units?: StrikeUnits; }
138
- interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRowInput[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap<string>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
149
+ interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: (({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; }) | ({ id: string; program: string; }))[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRowInput[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap<string>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
139
150
  // oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
140
- type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
151
+ type ShardRows = { strikes: (StrikeRows)[]; weather: (({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; }) | ({ id: string; program: string; }))[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
141
152
 
142
153
  type SpeciesRowInput = Omit<SpeciesRow, "abilities"> & { abilities?: CreatureAbilityInput[] };
143
154
 
144
155
  /** A species keeps its old fields, with optional explicit creature layers. */
145
- interface SpeciesRow extends CreatureLayers { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
156
+ interface SpeciesRow extends CreatureLayers { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; capsuleAxis?: 'y' | 'z'; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
146
157
 
147
158
  export { rowRules, RowsSchema, parseRows };
148
159
  export type { StrikeRowsInput, StrikeRows, ShardRowsInput, ShardRows, SpeciesRow };