@wildshard/shard-format 0.75.0 → 0.77.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 +2 -1
- package/src/format/deprecations.ts +7 -1
- package/src/format/engine-floor.ts +68 -0
- package/src/format/format-migration-manifest.ts +183 -0
- package/src/format/format-migration-prune.ts +1 -1
- package/src/format/format-migrations.ts +8 -0
- package/src/format/heldFinishes.ts +5 -3
- package/src/format/items.ts +1 -1
- package/src/format/json-schema.ts +9 -0
- package/src/format/loadout.ts +7 -5
- package/src/format/manifest-deprecations.ts +174 -6
- package/src/format/memory-armed.json +1 -203
- package/src/format/memory-armed.ts +4 -25
- package/src/format/memory-epoch.ts +1 -1
- package/src/format/memory-line.ts +12 -3
- package/src/format/outputIndex.ts +12 -2
- package/src/format/policy-verdict.ts +1 -1
- package/src/format/shardSections.ts +35 -3
- package/src/format/shardfile-stream-rows.ts +13 -1
- package/src/format/shardfile-stream.ts +3 -2
- package/src/format/shardfileValidation.ts +3 -2
- package/src/format/version.ts +24 -6
- package/src/format/weapon-slot.ts +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.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": {
|
|
@@ -124,6 +124,7 @@
|
|
|
124
124
|
"./fur-strands": "./src/format/fur-strands.ts",
|
|
125
125
|
"./scene-render": "./src/format/scene-render.ts",
|
|
126
126
|
"./look-level": "./src/format/look-level.ts",
|
|
127
|
+
"./engine-floor": "./src/format/engine-floor.ts",
|
|
127
128
|
"./level-start": "./src/format/level-start.ts",
|
|
128
129
|
"./level-start-rows": "./src/format/level-start-rows.ts",
|
|
129
130
|
"./look-sky": "./src/format/look-sky.ts",
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* both validators warn on it and the corpus counts its kept users (`shard-format corpus`). A path with a migration is
|
|
4
4
|
* mended by the chain; one without is deleted once no kept file uses it. */
|
|
5
5
|
import { COOK_DEPRECATIONS } from './cook-deprecations.ts'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
LEVEL_DEPRECATIONS,
|
|
8
|
+
MANIFEST_MOVED_DEPRECATIONS,
|
|
9
|
+
MAP_IMAGE_DEPRECATION,
|
|
10
|
+
} from './manifest-deprecations.ts'
|
|
7
11
|
import { SAVE_REVISION_DEPRECATION } from './save-revision.ts'
|
|
8
12
|
import { SCHEMA_SOURCE_DEPRECATION } from './schema-source.ts'
|
|
9
13
|
import {
|
|
@@ -157,6 +161,8 @@ const RULES: readonly DeprecationRule[] = [
|
|
|
157
161
|
) !== undefined,
|
|
158
162
|
},
|
|
159
163
|
...MANIFEST_MOVED_DEPRECATIONS,
|
|
164
|
+
...LEVEL_DEPRECATIONS,
|
|
165
|
+
MAP_IMAGE_DEPRECATION,
|
|
160
166
|
{
|
|
161
167
|
id: 'runtime.trust',
|
|
162
168
|
path: 'shard.json runtime.trust',
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { maxLength, pipe, regex, string } from 'valibot'
|
|
2
|
+
|
|
3
|
+
import type { GenericSchema } from 'valibot'
|
|
4
|
+
|
|
5
|
+
// FORMAT-PRUNE FP47b (coordinator, 2026-11-24, J505): a product names the lowest engine release that can draw it
|
|
6
|
+
// (`requires.engine`, from format 0.1.0.6). The SDK stamps the engine release it builds against; the cook, a pin and a
|
|
7
|
+
// grid's admission refuse a product whose floor is above the engine they run, so a product built for a newer engine
|
|
8
|
+
// never lands on an older grid. An older engine's format has no such word and refuses the product outright.
|
|
9
|
+
|
|
10
|
+
const RELEASE = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u
|
|
11
|
+
/** A running engine's version: a release, or a release's prerelease or build (`0.1.83-next.839c8ba0`). */
|
|
12
|
+
const RUNNING =
|
|
13
|
+
/^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:[-+][0-9A-Za-z.-]+)?$/u
|
|
14
|
+
const MAX_RELEASE = 32
|
|
15
|
+
const SAME = 0
|
|
16
|
+
|
|
17
|
+
/** An engine release, `X.Y.Z`. */
|
|
18
|
+
const EngineReleaseSchema: GenericSchema<string, string> = pipe(
|
|
19
|
+
string(),
|
|
20
|
+
maxLength(MAX_RELEASE),
|
|
21
|
+
regex(RELEASE),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
/** A version's release numbers; a prerelease of `X.Y.Z` (an engine `next` build) counts as `X.Y.Z`. */
|
|
25
|
+
function releaseParts(version: string): readonly number[] | undefined {
|
|
26
|
+
const groups = RUNNING.exec(version)?.groups
|
|
27
|
+
return groups === undefined
|
|
28
|
+
? undefined
|
|
29
|
+
: [groups['major'], groups['minor'], groups['patch']].map(Number)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Positive when `left` is the newer release. */
|
|
33
|
+
function compareReleases(
|
|
34
|
+
left: readonly number[],
|
|
35
|
+
right: readonly number[],
|
|
36
|
+
): number {
|
|
37
|
+
const differs = left.findIndex(
|
|
38
|
+
(part: number, index: number): boolean => part !== right[index],
|
|
39
|
+
)
|
|
40
|
+
return differs < SAME
|
|
41
|
+
? SAME
|
|
42
|
+
: (left[differs] ?? SAME) - (right[differs] ?? SAME)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Why an engine running `running` refuses a product whose floor is `required`, or undefined when it may draw it (no
|
|
47
|
+
* floor, or a floor at or below it). An unreadable running version refuses any floor.
|
|
48
|
+
*/
|
|
49
|
+
function engineFloorRefusal(
|
|
50
|
+
required: string | undefined,
|
|
51
|
+
running: string,
|
|
52
|
+
): string | undefined {
|
|
53
|
+
if (required === undefined) {
|
|
54
|
+
return undefined
|
|
55
|
+
}
|
|
56
|
+
const need = releaseParts(required)
|
|
57
|
+
const have = releaseParts(running)
|
|
58
|
+
if (
|
|
59
|
+
need !== undefined &&
|
|
60
|
+
have !== undefined &&
|
|
61
|
+
compareReleases(have, need) >= SAME
|
|
62
|
+
) {
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
return `This shard needs engine ${required} or newer; this engine is ${running} (requires.engine)`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { EngineReleaseSchema, engineFloorRefusal }
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// oxlint-disable typescript/prefer-readonly-parameter-types -- a step edits the shard it is handed, in place
|
|
2
|
+
/** FORMAT-PRUNE FP34 (J486; ONE-FORMAT OF9b5a): format 0.1.0.6 takes the moved words out of the level manifest. The
|
|
3
|
+
* page-start words move into their sections as `liftLevelStart` moves them at the door (a section's own value wins):
|
|
4
|
+
* `spawn` into `world/spawn` when the shard never set one, `loadout` into `combat/items`' `loadout.level`, `audio` into
|
|
5
|
+
* `audio/audio`'s `level`. `weapon` has no reader (`combat/items` arms the player) and leaves. The herd fields
|
|
6
|
+
* (`species`, `spawns`, `faunaTuning`) became declared rows in the build (OF9b4), which a copy of the file can't redo, so
|
|
7
|
+
* they leave too: a file that still needs them is rebuilt on SDK 0.4.25 or later. */
|
|
8
|
+
import { DEFAULT_SPAWN } from './level-start.ts'
|
|
9
|
+
import {
|
|
10
|
+
LEVEL_WORDS,
|
|
11
|
+
NO_LEVEL_WORDS,
|
|
12
|
+
isDiscoveryMount,
|
|
13
|
+
} from './manifest-deprecations.ts'
|
|
14
|
+
|
|
15
|
+
import type { FormatMigration, MigratingShard } from './format-migrations.ts'
|
|
16
|
+
|
|
17
|
+
type JsonRecord = Record<string, unknown>
|
|
18
|
+
|
|
19
|
+
const MANIFEST_WORDS_GONE = '0.1.0.6'
|
|
20
|
+
const MOVED_WORDS: readonly string[] = [
|
|
21
|
+
'spawn',
|
|
22
|
+
'loadout',
|
|
23
|
+
'audio',
|
|
24
|
+
'weapon',
|
|
25
|
+
'species',
|
|
26
|
+
'spawns',
|
|
27
|
+
'faunaTuning',
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
function isRecord(value: unknown): value is JsonRecord {
|
|
31
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `field` of section `name`, when both are objects. */
|
|
35
|
+
function sectionField(
|
|
36
|
+
shard: Readonly<MigratingShard>,
|
|
37
|
+
name: string,
|
|
38
|
+
field: string,
|
|
39
|
+
): JsonRecord | undefined {
|
|
40
|
+
const section = shard.sections.get(name)
|
|
41
|
+
const value = isRecord(section) ? section[field] : undefined
|
|
42
|
+
return isRecord(value) ? value : undefined
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Whether a world spawn is the default one, a shard that never set `world/spawn`. */
|
|
46
|
+
function defaultSpawn(spawn: Readonly<JsonRecord>): boolean {
|
|
47
|
+
return (
|
|
48
|
+
spawn['x'] === DEFAULT_SPAWN.x &&
|
|
49
|
+
spawn['y'] === DEFAULT_SPAWN.y &&
|
|
50
|
+
spawn['z'] === DEFAULT_SPAWN.z &&
|
|
51
|
+
spawn['yaw'] === DEFAULT_SPAWN.yaw
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The manifest's spawn stands the world spawn, keeping the section's height when it has none (a page on terrain). */
|
|
56
|
+
function liftSpawn(
|
|
57
|
+
shard: MigratingShard,
|
|
58
|
+
manifest: Readonly<JsonRecord>,
|
|
59
|
+
): void {
|
|
60
|
+
const spawn = sectionField(shard, 'world/spawn', 'spawn')
|
|
61
|
+
const from = manifest['spawn']
|
|
62
|
+
if (spawn === undefined || !isRecord(from) || !defaultSpawn(spawn)) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
// oxlint-disable-next-line eslint/id-length -- world/spawn names its height y
|
|
66
|
+
Object.assign(spawn, { ...from, y: from['y'] ?? spawn['y'] })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The manifest's loadout and audio fill their sections' empty `level`. */
|
|
70
|
+
function liftLevels(
|
|
71
|
+
shard: MigratingShard,
|
|
72
|
+
manifest: Readonly<JsonRecord>,
|
|
73
|
+
): void {
|
|
74
|
+
const items = sectionField(shard, 'combat/items', 'items')
|
|
75
|
+
const loadout = isRecord(items) ? items['loadout'] : undefined
|
|
76
|
+
if (
|
|
77
|
+
isRecord(loadout) &&
|
|
78
|
+
loadout['level'] === undefined &&
|
|
79
|
+
manifest['loadout'] !== undefined
|
|
80
|
+
) {
|
|
81
|
+
loadout['level'] = manifest['loadout']
|
|
82
|
+
}
|
|
83
|
+
const audio = sectionField(shard, 'audio/audio', 'audio')
|
|
84
|
+
if (
|
|
85
|
+
audio !== undefined &&
|
|
86
|
+
audio['level'] === undefined &&
|
|
87
|
+
manifest['audio'] !== undefined
|
|
88
|
+
) {
|
|
89
|
+
audio['level'] = manifest['audio']
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Lift a manifest-shaped object's start words into their sections, then drop every moved word and the old pointer. */
|
|
94
|
+
function liftAndDrop(shard: MigratingShard, manifest: JsonRecord): void {
|
|
95
|
+
liftSpawn(shard, manifest)
|
|
96
|
+
liftLevels(shard, manifest)
|
|
97
|
+
for (const word of [...MOVED_WORDS, 'gridShardfile']) {
|
|
98
|
+
Reflect.deleteProperty(manifest, word)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** FORMAT-PRUNE FP34: the level manifest carries none of the moved words. */
|
|
103
|
+
const manifestMovedWords: FormatMigration = {
|
|
104
|
+
id: 'fp34-manifest-moved-words',
|
|
105
|
+
to: MANIFEST_WORDS_GONE,
|
|
106
|
+
touches: 'data',
|
|
107
|
+
affects: [],
|
|
108
|
+
apply: (shard: MigratingShard): void => {
|
|
109
|
+
const manifest = sectionField(shard, 'ui/level', 'manifest')
|
|
110
|
+
if (manifest === undefined) {
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
liftAndDrop(shard, manifest)
|
|
114
|
+
// FORMAT-PRUNE FP47c: the map image leaves too, as `liftLevelStart` drops it at the door (look/map draws the map)
|
|
115
|
+
const map = manifest['minimap']
|
|
116
|
+
if (isRecord(map)) {
|
|
117
|
+
Reflect.deleteProperty(map, 'image')
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** FORMAT-PRUNE FP36: the discovery mount's `data` repeats the level manifest; it carries none of the moved words either.
|
|
123
|
+
* Runs after FP34's step, so a section the level manifest already filled keeps its value. */
|
|
124
|
+
const discoveryMovedWords: FormatMigration = {
|
|
125
|
+
id: 'fp36-discovery-moved-words',
|
|
126
|
+
to: MANIFEST_WORDS_GONE,
|
|
127
|
+
touches: 'data',
|
|
128
|
+
affects: [],
|
|
129
|
+
apply: (shard: MigratingShard): void => {
|
|
130
|
+
for (const [path, mount] of shard.mounts) {
|
|
131
|
+
const data = isRecord(mount) ? mount['data'] : undefined
|
|
132
|
+
if (isDiscoveryMount(path) && isRecord(data)) {
|
|
133
|
+
liftAndDrop(shard, data)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** FORMAT-PRUNE FP47b: a manifest-shaped object's level look (sky, atmosphere and grade, and a horizon when it paints
|
|
140
|
+
* one) fills `look/look`'s empty `level`, as `liftLevelLook` does at the door; the look's own wins. Then the four words
|
|
141
|
+
* leave the object. A partial look (no sky, atmosphere or grade) has no level to give and only leaves. */
|
|
142
|
+
function liftLevelWords(shard: MigratingShard, manifest: JsonRecord): void {
|
|
143
|
+
const look = sectionField(shard, 'look/look', 'look')
|
|
144
|
+
const { sky, atmosphere, grade, horizon } = manifest
|
|
145
|
+
if (
|
|
146
|
+
look !== undefined &&
|
|
147
|
+
look['level'] === undefined &&
|
|
148
|
+
sky !== undefined &&
|
|
149
|
+
atmosphere !== undefined &&
|
|
150
|
+
grade !== undefined
|
|
151
|
+
) {
|
|
152
|
+
look['level'] =
|
|
153
|
+
horizon === undefined
|
|
154
|
+
? { sky, atmosphere, grade }
|
|
155
|
+
: { sky, atmosphere, grade, horizon }
|
|
156
|
+
}
|
|
157
|
+
for (const word of LEVEL_WORDS) {
|
|
158
|
+
Reflect.deleteProperty(manifest, word)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** FORMAT-PRUNE FP47b: format 0.1.0.6 takes the level look out of the level manifest and the discovery mount; it lives
|
|
163
|
+
* in `look/look`'s `level` (ONE-FORMAT OF9b2). The level manifest gives first, then each discovery mount. */
|
|
164
|
+
const levelLook: FormatMigration = {
|
|
165
|
+
id: 'fp47b-level-look',
|
|
166
|
+
to: NO_LEVEL_WORDS,
|
|
167
|
+
touches: 'data',
|
|
168
|
+
affects: [],
|
|
169
|
+
apply: (shard: MigratingShard): void => {
|
|
170
|
+
const manifest = sectionField(shard, 'ui/level', 'manifest')
|
|
171
|
+
if (manifest !== undefined) {
|
|
172
|
+
liftLevelWords(shard, manifest)
|
|
173
|
+
}
|
|
174
|
+
for (const [path, mount] of shard.mounts) {
|
|
175
|
+
const data = isRecord(mount) ? mount['data'] : undefined
|
|
176
|
+
if (isDiscoveryMount(path) && isRecord(data)) {
|
|
177
|
+
liftLevelWords(shard, data)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { MOVED_WORDS, discoveryMovedWords, levelLook, manifestMovedWords }
|
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
} from './format-migration-envelope.ts'
|
|
13
13
|
import { homesToMembers } from './format-migration-homes.ts'
|
|
14
14
|
import { journalGlyphImages } from './format-migration-journal.ts'
|
|
15
|
+
import {
|
|
16
|
+
discoveryMovedWords,
|
|
17
|
+
levelLook,
|
|
18
|
+
manifestMovedWords,
|
|
19
|
+
} from './format-migration-manifest.ts'
|
|
15
20
|
import {
|
|
16
21
|
dropRuntimeTrust,
|
|
17
22
|
schemaSource,
|
|
@@ -86,6 +91,9 @@ const FORMAT_MIGRATIONS: readonly FormatMigration[] = [
|
|
|
86
91
|
dropRequiresCapabilities,
|
|
87
92
|
dropRequiresSdk,
|
|
88
93
|
homesToMembers,
|
|
94
|
+
manifestMovedWords,
|
|
95
|
+
discoveryMovedWords,
|
|
96
|
+
levelLook,
|
|
89
97
|
]
|
|
90
98
|
|
|
91
99
|
/** Whether a file at `version` still needs a step that writes `to`. The legacy two-part spelling sits just below its
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { WeaponSlotSchema } from './weapon-slot.ts';
|
|
3
|
+
import type { WeaponSlot } from './weapon-slot.ts';
|
|
2
4
|
import { CatalogueIconSchema } from './items.ts';
|
|
3
5
|
import { PackedGeometryRowsSchema } from './geometryPack.ts';
|
|
4
6
|
|
|
5
7
|
const text = v.pipe(v.string(), v.minLength(1), v.maxLength(512));
|
|
6
8
|
const finite = v.pipe(v.number(), v.finite());
|
|
7
9
|
const natural = v.pipe(finite, v.integer(), v.minValue(0));
|
|
8
|
-
const weapon =
|
|
10
|
+
const weapon = WeaponSlotSchema;
|
|
9
11
|
const override = v.strictObject({ color: v.exactOptional(finite), emissive: v.exactOptional(finite), emissiveIntensity: v.exactOptional(finite),
|
|
10
12
|
roughness: v.exactOptional(finite), metalness: v.exactOptional(finite), envMapIntensity: v.exactOptional(finite), plain: v.exactOptional(v.boolean()) });
|
|
11
13
|
/** Pre-admission locker and Explorer card identities, in the authored order. */
|
|
@@ -354,7 +356,7 @@ interface HeldFinishesRowsInputFields {
|
|
|
354
356
|
order: (string)[];
|
|
355
357
|
rows: Record<string, {
|
|
356
358
|
id: string;
|
|
357
|
-
weapon:
|
|
359
|
+
weapon: WeaponSlot;
|
|
358
360
|
name: string;
|
|
359
361
|
blurb: string;
|
|
360
362
|
dropsFrom?: {
|
|
@@ -388,7 +390,7 @@ interface HeldFinishesRowsFields {
|
|
|
388
390
|
order: (string)[];
|
|
389
391
|
rows: Record<string, {
|
|
390
392
|
id: string;
|
|
391
|
-
weapon:
|
|
393
|
+
weapon: WeaponSlot;
|
|
392
394
|
name: string;
|
|
393
395
|
blurb: string;
|
|
394
396
|
dropsFrom?: {
|
package/src/format/items.ts
CHANGED
|
@@ -181,7 +181,7 @@ export function itemRules(items: ShardItems, modules?: readonly string[]): strin
|
|
|
181
181
|
const ids = items.rows.map((r) => r.id), weapons = items.rows.filter((r) => r.kind === 'weapon');
|
|
182
182
|
const runtimeContexts = items.runtimeContexts ?? [];
|
|
183
183
|
if (items.loadout.effects?.weapons.some(binding => new Set(binding.items).size !== binding.items.length
|
|
184
|
-
|| binding.items.some(id => !weapons.some(entry => entry.id === id && entry.equipment
|
|
184
|
+
|| binding.items.some(id => !weapons.some(entry => entry.id === id && entry.equipment !== undefined))) === true)
|
|
185
185
|
errors.push('item effect targets need unique native equipment ids');
|
|
186
186
|
if (weapons.some(row => row.profile !== undefined && !row.family.includes('.') && row.family !== row.profile.family && !(row.family === 'swept' && row.profile.family === 'melee'))) errors.push('weapon profile matches declared family');
|
|
187
187
|
if (weapons.some(row => row.profile?.family === 'cone' && (row.light.range !== row.heavy.range
|
|
@@ -356,6 +356,11 @@ import { UiSchema } from './ui.ts'
|
|
|
356
356
|
import { uniformIdentityTransforms } from './uniformRows.ts'
|
|
357
357
|
import { WaterSchema } from './water.ts'
|
|
358
358
|
import { WaterWorldSchema } from './waterWorld.ts'
|
|
359
|
+
import {
|
|
360
|
+
DECLARED_LIMIT,
|
|
361
|
+
DECLARED_PATTERN,
|
|
362
|
+
DeclaredWeaponSchema,
|
|
363
|
+
} from './weapon-slot.ts'
|
|
359
364
|
import {
|
|
360
365
|
WeaponProfileSchema,
|
|
361
366
|
MeleeWeaponProfileSchema,
|
|
@@ -402,6 +407,10 @@ const input = plumbing.entries.input.pipe[0].item
|
|
|
402
407
|
const debug = plumbing.entries.debug.pipe[0].item
|
|
403
408
|
// These identities are the defining schemas, not message-based permissions for arbitrary author code.
|
|
404
409
|
const customSchemas = new Map<object, FormatJsonSchema>([
|
|
410
|
+
[
|
|
411
|
+
DeclaredWeaponSchema,
|
|
412
|
+
{ type: 'string', maxLength: DECLARED_LIMIT, pattern: DECLARED_PATTERN },
|
|
413
|
+
],
|
|
405
414
|
[
|
|
406
415
|
WeatherHitTagSchema,
|
|
407
416
|
{ type: 'string', pattern: '^[a-z][a-zA-Z0-9.-]*\\.[a-zA-Z0-9.*-]+$' },
|
package/src/format/loadout.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { isJsonData } from './json.ts';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
import { WeaponSlotSchema } from './weapon-slot.ts';
|
|
4
|
+
import type { WeaponSlot } from './weapon-slot.ts';
|
|
3
5
|
|
|
4
6
|
const text = v.pipe(v.string(), v.minLength(1), v.maxLength(1024));
|
|
5
7
|
const finite = v.pipe(v.number(), v.finite());
|
|
6
8
|
const natural = v.pipe(finite, v.integer(), v.minValue(0));
|
|
7
9
|
const names = v.pipe(v.array(text), v.minLength(1), v.maxLength(64), v.check(rows => new Set(rows).size === rows.length));
|
|
8
|
-
const slot =
|
|
10
|
+
const slot = WeaponSlotSchema;
|
|
9
11
|
const action = v.custom<`${string}.${string}`>(value => typeof value === 'string' && /^[^.]+\..+$/.test(value));
|
|
10
12
|
const cue = v.custom<`cue.${string}`>(value => typeof value === 'string' && value.startsWith('cue.') && value.length > 4);
|
|
11
13
|
/** A held loadout's ammunition, ownership, save ABI, input and cues. Native weapon clocks remain in combat/items. */
|
|
@@ -58,15 +60,15 @@ interface LoadoutRowsFields {
|
|
|
58
60
|
};
|
|
59
61
|
launcher: {
|
|
60
62
|
item: string;
|
|
61
|
-
slot:
|
|
63
|
+
slot: WeaponSlot;
|
|
62
64
|
};
|
|
63
65
|
firearm: {
|
|
64
|
-
slot:
|
|
66
|
+
slot: WeaponSlot;
|
|
65
67
|
owned: string;
|
|
66
68
|
ammo: string;
|
|
67
69
|
};
|
|
68
70
|
bow: {
|
|
69
|
-
slot:
|
|
71
|
+
slot: WeaponSlot;
|
|
70
72
|
owned: string;
|
|
71
73
|
legacyItem: string;
|
|
72
74
|
ammo: string;
|
|
@@ -140,7 +142,7 @@ interface MountedLoadoutRowsFields {
|
|
|
140
142
|
item: `weapon.${string}`;
|
|
141
143
|
muzzleLight: boolean;
|
|
142
144
|
};
|
|
143
|
-
order:
|
|
145
|
+
order: WeaponSlot[];
|
|
144
146
|
};
|
|
145
147
|
variants: {
|
|
146
148
|
bow: {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** ONE-FORMAT OF9b5 under J486: the level manifest's moved words. SDK 0.4.25 builds write none of them (OF9b3b moved
|
|
2
2
|
* the page-start words to their sections, OF9b4 the herd fields to declared rows), but every product built before it
|
|
3
|
-
* still carries some in `ui/level`. FE7 counts each one's kept users
|
|
4
|
-
* `ManifestMetadataSchema` at
|
|
5
|
-
*
|
|
3
|
+
* still carries some in `ui/level`. FE7 counts each one's kept users. FORMAT-PRUNE FP34 deletes them from
|
|
4
|
+
* `ManifestMetadataSchema` at format 0.1.0.6, and its chain step (`fp34-manifest-moved-words`) lifts the start words into
|
|
5
|
+
* their sections and drops the rest: the herd fields became declared rows in the build, which a copy can't redo. */
|
|
6
|
+
|
|
7
|
+
import { OLD_POINTER } from './format-migration-prune.ts'
|
|
8
|
+
import { compareShardfileVersions } from './version.ts'
|
|
6
9
|
|
|
7
10
|
/** The registry's row shape (`deprecations.ts`). */
|
|
8
11
|
interface ManifestDeprecation {
|
|
@@ -10,7 +13,7 @@ interface ManifestDeprecation {
|
|
|
10
13
|
readonly path: string
|
|
11
14
|
readonly since: string
|
|
12
15
|
readonly replacement: string
|
|
13
|
-
readonly migration:
|
|
16
|
+
readonly migration: string
|
|
14
17
|
readonly uses: (
|
|
15
18
|
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
16
19
|
) => boolean
|
|
@@ -40,7 +43,7 @@ const MANIFEST_MOVED_DEPRECATIONS: readonly ManifestDeprecation[] = MOVED.map(
|
|
|
40
43
|
path: `sections/ui/level manifest.${word} (ONE-FORMAT OF9b5)`,
|
|
41
44
|
since: '0.1.0.4',
|
|
42
45
|
replacement,
|
|
43
|
-
migration:
|
|
46
|
+
migration: 'fp34-manifest-moved-words',
|
|
44
47
|
uses: (
|
|
45
48
|
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
46
49
|
): boolean => {
|
|
@@ -54,4 +57,169 @@ const MANIFEST_MOVED_DEPRECATIONS: readonly ManifestDeprecation[] = MOVED.map(
|
|
|
54
57
|
}),
|
|
55
58
|
)
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
/** FORMAT-PRUNE FP47b: each level look word the manifest carried before OF9b2, and the chain step that lifts it. */
|
|
61
|
+
const LEVEL_DEPRECATIONS: readonly ManifestDeprecation[] = [
|
|
62
|
+
'sky',
|
|
63
|
+
'atmosphere',
|
|
64
|
+
'grade',
|
|
65
|
+
'horizon',
|
|
66
|
+
].map((word: string): ManifestDeprecation => ({
|
|
67
|
+
id: `manifest.${word}`,
|
|
68
|
+
path: `sections/ui/level manifest.${word} (and the discovery mount; ONE-FORMAT OF9b2)`,
|
|
69
|
+
since: '0.1.0.4',
|
|
70
|
+
replacement: `look/look's level.${word} (OF9b2)`,
|
|
71
|
+
migration: 'fp47b-level-look',
|
|
72
|
+
uses: (
|
|
73
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
74
|
+
): boolean => {
|
|
75
|
+
const manifest = manifestOf(shard.sections)
|
|
76
|
+
return (
|
|
77
|
+
typeof manifest === 'object' &&
|
|
78
|
+
manifest !== null &&
|
|
79
|
+
Object.hasOwn(manifest, word)
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
}))
|
|
83
|
+
/** FORMAT-PRUNE FP34: the first format whose level manifest carries none of the moved words, nor the old pointer. */
|
|
84
|
+
// 0.75.0 shipped format 0.1.0.5 without FP34 and FP36, so they ride 0.1.0.6 with FP47b.
|
|
85
|
+
const NO_MOVED_WORDS = '0.1.0.6'
|
|
86
|
+
const NONE = 0
|
|
87
|
+
// The old pointer's spelling is FP8's chain step's (format's one-way `format.grid-pointer-references` counts each one).
|
|
88
|
+
const GONE_WORDS: readonly string[] = [
|
|
89
|
+
OLD_POINTER,
|
|
90
|
+
...MOVED.map(([word]: readonly [string, string]): string => word),
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
/** FORMAT-PRUNE FP47b: the first format whose level manifest and discovery data carry no level look (OF9b2 moved it
|
|
94
|
+
* to `look/look`'s `level`), and the four words. */
|
|
95
|
+
const NO_LEVEL_WORDS = '0.1.0.6'
|
|
96
|
+
const LEVEL_WORDS: readonly string[] = ['sky', 'atmosphere', 'grade', 'horizon']
|
|
97
|
+
/** FORMAT-PRUNE FP36: the discovery mount, which repeats the level manifest as its `data`. */
|
|
98
|
+
const DISCOVERY_MOUNT =
|
|
99
|
+
/^mounts\/shardfiles\/(?:_[a-z]+|[a-z][a-z0-9-]*)\/discovery\.json$/u
|
|
100
|
+
|
|
101
|
+
/** Whether a format version is one that carries none of the gone words. */
|
|
102
|
+
function gated(version: unknown): version is string {
|
|
103
|
+
return (
|
|
104
|
+
typeof version === 'string' &&
|
|
105
|
+
compareShardfileVersions(version, NO_MOVED_WORDS) >= NONE
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The gone words a manifest-shaped object still carries at `version`: the moved words and the level look's
|
|
110
|
+
* from 0.1.0.6 (FP47b). */
|
|
111
|
+
function keptWords(version: string, manifest: unknown): readonly string[] {
|
|
112
|
+
if (typeof manifest !== 'object' || manifest === null) {
|
|
113
|
+
return []
|
|
114
|
+
}
|
|
115
|
+
const gone =
|
|
116
|
+
compareShardfileVersions(version, NO_LEVEL_WORDS) >= NONE
|
|
117
|
+
? [...GONE_WORDS, ...LEVEL_WORDS]
|
|
118
|
+
: GONE_WORDS
|
|
119
|
+
return gone.filter((word: string): boolean => Object.hasOwn(manifest, word))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** FORMAT-PRUNE FP47c: a level manifest's map image, which `look/map` replaced (OF9b3); gone with the moved words. */
|
|
123
|
+
function keptMapImage(manifest: unknown): readonly string[] {
|
|
124
|
+
const map: unknown =
|
|
125
|
+
typeof manifest === 'object' && manifest !== null
|
|
126
|
+
? Reflect.get(manifest, 'minimap')
|
|
127
|
+
: undefined
|
|
128
|
+
return typeof map === 'object' && map !== null && Object.hasOwn(map, 'image')
|
|
129
|
+
? ['minimap.image']
|
|
130
|
+
: []
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** FORMAT-PRUNE FP47c: the level manifest's map image (OF9b3 moved the map to `look/map`); FP34's step drops it. */
|
|
134
|
+
const MAP_IMAGE_DEPRECATION: ManifestDeprecation = {
|
|
135
|
+
id: 'manifest.minimap.image',
|
|
136
|
+
path: 'sections/ui/level manifest.minimap.image (ONE-FORMAT OF9b3)',
|
|
137
|
+
since: '0.1.0.4',
|
|
138
|
+
replacement: 'look/map (OF9b3)',
|
|
139
|
+
migration: 'fp34-manifest-moved-words',
|
|
140
|
+
uses: (
|
|
141
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
142
|
+
): boolean => keptMapImage(manifestOf(shard.sections)).length > NONE,
|
|
143
|
+
}
|
|
144
|
+
/** The row that refuses the kept words: FP47b when they are all the level look's, else the moved words' row. */
|
|
145
|
+
function prune(kept: readonly string[], moved = 'FP36'): string {
|
|
146
|
+
return kept.every((word: string): boolean => LEVEL_WORDS.includes(word))
|
|
147
|
+
? 'FP47b'
|
|
148
|
+
: moved
|
|
149
|
+
}
|
|
150
|
+
/** Parsed JSON, or nothing for bytes that are none (another check's refusal). */
|
|
151
|
+
function jsonOf(bytes: Readonly<Uint8Array>): unknown {
|
|
152
|
+
try {
|
|
153
|
+
return JSON.parse(new TextDecoder().decode(bytes))
|
|
154
|
+
} catch {
|
|
155
|
+
return undefined
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Whether a product path is a shard's discovery mount. */
|
|
160
|
+
function isDiscoveryMount(path: string): boolean {
|
|
161
|
+
return DISCOVERY_MOUNT.test(path)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A mount or pack the stream validator checks as it passes and does not hold; the discovery mount it holds (FP36). */
|
|
165
|
+
function unheldMount(path: string): boolean {
|
|
166
|
+
return (
|
|
167
|
+
path.startsWith('packs/') ||
|
|
168
|
+
(path.startsWith('mounts/') && !isDiscoveryMount(path))
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** FORMAT-PRUNE FP36 (the FP33 pattern): format 0.1.0.6 on refuses a discovery mount whose `data` carries a moved word or
|
|
173
|
+
* the old pointer; an older file keeps them as written, and the chain step (`fp36-discovery-moved-words`) lifts them.
|
|
174
|
+
* Bytes that are no JSON object are another check's refusal. Answers the bytes it checked. */
|
|
175
|
+
function checkDiscoveryMount(
|
|
176
|
+
version: unknown,
|
|
177
|
+
path: string,
|
|
178
|
+
bytes: Readonly<Uint8Array>,
|
|
179
|
+
): Readonly<Uint8Array> {
|
|
180
|
+
if (!isDiscoveryMount(path) || !gated(version)) {
|
|
181
|
+
return bytes
|
|
182
|
+
}
|
|
183
|
+
const parsed = jsonOf(bytes)
|
|
184
|
+
const data: unknown =
|
|
185
|
+
typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
186
|
+
? Reflect.get(parsed, 'data')
|
|
187
|
+
: undefined
|
|
188
|
+
const kept = keptWords(version, data)
|
|
189
|
+
if (kept.length > NONE) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Format ${version} carries no ${kept.map((word: string): string => `data.${word}`).join(', ')} (${path}; FORMAT-PRUNE ${prune(kept)})`,
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
return bytes
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** FORMAT-PRUNE FP34 (the FP33 pattern): format 0.1.0.6 on refuses a level manifest carrying a moved word or the old
|
|
198
|
+
* pointer; an older file keeps them as written, so its source hash still matches, and the chain step
|
|
199
|
+
* (`fp34-manifest-moved-words`) lifts them. */
|
|
200
|
+
function checkNoMovedWords(version: unknown, level: unknown): void {
|
|
201
|
+
if (!gated(version)) {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
const manifest = manifestOf(new Map([['ui/level', level]]))
|
|
205
|
+
const kept = [...keptWords(version, manifest), ...keptMapImage(manifest)]
|
|
206
|
+
if (kept.length > NONE) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`Format ${version} carries no ${kept.map((word: string): string => `manifest.${word}`).join(', ')} (sections/ui/level; FORMAT-PRUNE ${prune(kept, 'FP34')})`,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export {
|
|
214
|
+
GONE_WORDS,
|
|
215
|
+
LEVEL_DEPRECATIONS,
|
|
216
|
+
LEVEL_WORDS,
|
|
217
|
+
MANIFEST_MOVED_DEPRECATIONS,
|
|
218
|
+
MAP_IMAGE_DEPRECATION,
|
|
219
|
+
NO_LEVEL_WORDS,
|
|
220
|
+
NO_MOVED_WORDS,
|
|
221
|
+
checkDiscoveryMount,
|
|
222
|
+
checkNoMovedWords,
|
|
223
|
+
isDiscoveryMount,
|
|
224
|
+
unheldMount,
|
|
225
|
+
}
|