@wildshard/shard-format 0.80.0 → 0.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/cli/corpus-command.ts +16 -7
- package/src/cli/corpus-live.ts +6 -1
- package/src/cli/corpus-pins.ts +24 -4
- package/src/format/audio-measure.ts +4 -2
- package/src/format/audioProfiles.ts +1 -1
- package/src/format/carried-ktx2.ts +52 -0
- package/src/format/cook-data.ts +10 -0
- package/src/format/engine-art.ts +120 -0
- package/src/format/glbImages.ts +23 -5
- package/src/format/issue-codes.ts +2 -0
- package/src/format/materials.ts +1 -1
- package/src/format/outputIndex.ts +5 -0
- package/src/format/propMaterials.ts +1 -1
- package/src/format/props.ts +1 -1
- package/src/format/shard-version.ts +18 -0
- package/src/format/shardfile-stream-rows.ts +25 -1
- package/src/format/shardfile-stream.ts +1 -1
- package/src/format/shardfileValidation.ts +10 -1
- package/src/format/skin-variants.ts +3 -1
- package/src/format/skinAssets.ts +1 -1
- package/src/format/splatTerrain.ts +4 -2
- package/src/format/standalone-art.ts +110 -0
- package/src/scripts/.kit/wildshard-agent-requests.mjs +57 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1",
|
|
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": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"packages/wire/src/net-command.ts",
|
|
30
30
|
"src/cli/*.ts",
|
|
31
31
|
"src/cli/*.mjs",
|
|
32
|
+
"src/scripts/.kit/wildshard-agent-requests.mjs",
|
|
32
33
|
"!src/cli/*.test.ts",
|
|
33
34
|
"corpus/exports/**",
|
|
34
35
|
"src/format/meshopt-static.mjs",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markedFetch } from '../scripts/.kit/wildshard-agent-requests.mjs'
|
|
1
2
|
import { loadCandidate } from './corpus-candidate.ts'
|
|
2
3
|
import { corpusGate } from './corpus-gate.ts'
|
|
3
4
|
import {
|
|
@@ -24,8 +25,13 @@ interface CorpusArgs {
|
|
|
24
25
|
readonly only: string | undefined
|
|
25
26
|
/** ZS3: store drift blocks too (corpus.yml's nightly once ZS11 finalizes the retired and proof shards). */
|
|
26
27
|
readonly strictStore?: boolean
|
|
28
|
+
/** The network read under the Wildshard agent marker (QA 11-25 row 128); tests pass a stub. */
|
|
29
|
+
readonly fetch?: typeof fetch
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/** Every read the command makes, marked through the kit's shared helper: it reads production's store and release files. */
|
|
33
|
+
type MarkedArgs = Readonly<CorpusArgs> & Readonly<{ get: typeof fetch }>
|
|
34
|
+
|
|
29
35
|
const EXIT_OK = 0
|
|
30
36
|
const EXIT_INVALID = 3
|
|
31
37
|
const NONE = 0
|
|
@@ -43,20 +49,21 @@ interface LiveSet {
|
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/** ZS3 (J507): the API's list, engine's pins and every hash a signed release file or placement names. */
|
|
46
|
-
async function liveSet(args:
|
|
47
|
-
const pins = await readPins(args.pins ?? LIVE_PINS)
|
|
52
|
+
async function liveSet(args: MarkedArgs): Promise<LiveSet> {
|
|
53
|
+
const pins = await readPins(args.pins ?? LIVE_PINS, args.get)
|
|
48
54
|
const listed = await listKept({
|
|
49
55
|
api: args.api,
|
|
50
56
|
cache: args.cache,
|
|
51
57
|
validator: '',
|
|
58
|
+
fetch: args.get,
|
|
52
59
|
})
|
|
53
|
-
const live = await liveHashes({ packs: PACKS, listed, pins })
|
|
60
|
+
const live = await liveHashes({ packs: PACKS, listed, pins }, args.get)
|
|
54
61
|
return { pins, listed, live }
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
/** Every live original's row (ZS3, FE13). */
|
|
58
65
|
async function corpusRows(
|
|
59
|
-
args:
|
|
66
|
+
args: MarkedArgs,
|
|
60
67
|
set: Readonly<LiveSet>,
|
|
61
68
|
): Promise<Readonly<{ rows: CorpusRow[]; validator: string }>> {
|
|
62
69
|
const validator = await readVersion()
|
|
@@ -71,6 +78,7 @@ async function corpusRows(
|
|
|
71
78
|
validator,
|
|
72
79
|
pins: set.pins,
|
|
73
80
|
live: set.live,
|
|
81
|
+
fetch: args.get,
|
|
74
82
|
...candidate,
|
|
75
83
|
...only,
|
|
76
84
|
})
|
|
@@ -89,13 +97,13 @@ function gateBlocking(rows: readonly CorpusRow[]): number {
|
|
|
89
97
|
|
|
90
98
|
/** ZS3: the API's listed originals beyond the live ones; a drifted one blocks. */
|
|
91
99
|
async function storeDrift(
|
|
92
|
-
args:
|
|
100
|
+
args: MarkedArgs,
|
|
93
101
|
set: Readonly<LiveSet>,
|
|
94
102
|
): Promise<number> {
|
|
95
103
|
const kept = classifyKept(set.listed, {
|
|
96
104
|
live: set.live,
|
|
97
105
|
pins: set.pins,
|
|
98
|
-
pointed: await pointedHashes(args.api),
|
|
106
|
+
pointed: await pointedHashes(args.api, args.get),
|
|
99
107
|
})
|
|
100
108
|
process.stdout.write(`${keptLines(kept).join('\n')}\n`)
|
|
101
109
|
return kept.drift.length
|
|
@@ -103,7 +111,8 @@ async function storeDrift(
|
|
|
103
111
|
|
|
104
112
|
/** `shard-format corpus`: every live original, as stored (FE3, ZS3), gated by FE5's known failures and ZS3's store
|
|
105
113
|
* drift; `--usage` writes FE13's record over the live originals only. */
|
|
106
|
-
async function corpusCommand(
|
|
114
|
+
async function corpusCommand(input: Readonly<CorpusArgs>): Promise<number> {
|
|
115
|
+
const args: MarkedArgs = { ...input, get: markedFetch(input.fetch ?? fetch) }
|
|
107
116
|
const set = await liveSet(args)
|
|
108
117
|
const { rows, validator } = await corpusRows(args, set)
|
|
109
118
|
process.stdout.write(`${corpusReport(rows)}\n`)
|
package/src/cli/corpus-live.ts
CHANGED
|
@@ -22,6 +22,7 @@ const CatalogueSchema = object({ shards: array(HeadSchema) })
|
|
|
22
22
|
const SignedSchema = object({ body: string() })
|
|
23
23
|
const ReleaseShard = object({
|
|
24
24
|
slug: string(),
|
|
25
|
+
uploadNumber: optional(number()),
|
|
25
26
|
revision: optional(number()),
|
|
26
27
|
hash: optional(string()),
|
|
27
28
|
})
|
|
@@ -155,11 +156,15 @@ async function channelHashes(
|
|
|
155
156
|
(
|
|
156
157
|
shard: Readonly<{
|
|
157
158
|
slug: string
|
|
159
|
+
uploadNumber?: number | undefined
|
|
158
160
|
revision?: number | undefined
|
|
159
161
|
hash?: string | undefined
|
|
160
162
|
}>,
|
|
161
163
|
): string | undefined =>
|
|
162
|
-
shard.hash ??
|
|
164
|
+
shard.hash ??
|
|
165
|
+
byRevision.get(
|
|
166
|
+
`${shard.slug}@${String(shard.uploadNumber ?? shard.revision)}`,
|
|
167
|
+
),
|
|
163
168
|
)
|
|
164
169
|
const cells = placed.cells.map(
|
|
165
170
|
(cell: Readonly<{ hash?: string | undefined }>): string | undefined =>
|
package/src/cli/corpus-pins.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
array,
|
|
5
|
+
number,
|
|
6
|
+
object,
|
|
7
|
+
parse,
|
|
8
|
+
pipe,
|
|
9
|
+
regex,
|
|
10
|
+
string,
|
|
11
|
+
transform,
|
|
12
|
+
union,
|
|
13
|
+
} from 'valibot'
|
|
4
14
|
|
|
5
15
|
import type { StoredRecord } from './corpus.ts'
|
|
6
16
|
|
|
@@ -11,12 +21,22 @@ import type { StoredRecord } from './corpus.ts'
|
|
|
11
21
|
// the run, judged by hash like any other.
|
|
12
22
|
|
|
13
23
|
const HASH = pipe(string(), regex(/^[a-f0-9]{64}$/u))
|
|
14
|
-
const
|
|
24
|
+
const pinFields = {
|
|
15
25
|
slug: string(),
|
|
16
|
-
revision: number(),
|
|
17
26
|
hash: HASH,
|
|
18
27
|
bytes: number(),
|
|
19
|
-
}
|
|
28
|
+
}
|
|
29
|
+
const CurrentPin = object({ ...pinFields, uploadNumber: number() })
|
|
30
|
+
const PinSchema = union([
|
|
31
|
+
pipe(
|
|
32
|
+
CurrentPin,
|
|
33
|
+
transform(({ uploadNumber, ...pin }): Pin => ({
|
|
34
|
+
...pin,
|
|
35
|
+
revision: uploadNumber,
|
|
36
|
+
})),
|
|
37
|
+
),
|
|
38
|
+
object({ ...pinFields, revision: number() }),
|
|
39
|
+
])
|
|
20
40
|
const PinsSchema = object({ shards: array(PinSchema) })
|
|
21
41
|
|
|
22
42
|
/** One shard file engine pins. */
|
|
@@ -72,11 +72,13 @@ const MP3_SYNC_HIGH = 224
|
|
|
72
72
|
const UTF16_BOM_LOW = 254
|
|
73
73
|
const UNKNOWN_REASON = 'bytes in no audio container AU5 knows; they still count'
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// SF4: a zone's own audio sits under its slug, `/assets/<slug>/music/` or `/assets/<slug>/sfx/`
|
|
76
|
+
const ROLE_PATTERN =
|
|
77
|
+
/^\/assets\/(?:[a-z0-9]+(?:-[a-z0-9]+)*\/)?(?<role>music|sfx)\//u
|
|
76
78
|
const AUDIO_EXTENSION =
|
|
77
79
|
/\.(?:m4a|mp4|aac|wav|wave|flac|aif|aiff|aifc|caf|mp3|ogg|oga|opus|webm|weba)$/iu
|
|
78
80
|
|
|
79
|
-
/** Whether a public URL sits in an audio folder (`/assets/music/` or `/assets
|
|
81
|
+
/** Whether a public URL sits in an audio folder (`/assets/music/`, `/assets/sfx/` or a zone's `/assets/<slug>/music|sfx/`). */
|
|
80
82
|
function isAudioFolderUrl(url: string): boolean {
|
|
81
83
|
return ROLE_PATTERN.test(url)
|
|
82
84
|
}
|
|
@@ -62,7 +62,7 @@ export const AudioMusicSchema: v.GenericSchema<AudioMusic> = v.pipe(v.strictObje
|
|
|
62
62
|
setCatalogue:v.exactOptional(v.strictObject({inventory:v.picklist(['base','title']),priority:v.boolean(),bootSynth:v.boolean(),titleStings:v.boolean(),baseSamples:v.boolean(),cueOverlay:v.boolean()})),
|
|
63
63
|
lifecycle:v.exactOptional(v.strictObject({persistent:v.boolean(),dispose:v.boolean(),logChanges:v.boolean(),bossScene:v.exactOptional(id)})),
|
|
64
64
|
synthLead: v.picklist(['pluck', 'marimba']), minFade: v.pipe(finite, v.minValue(0), v.maxValue(60)),
|
|
65
|
-
source: v.nullable(v.strictObject({ dir: v.pipe(v.string(), v.regex(/^\/assets\/music\/[a-z0-9_-]+\/$/u)), manifestKey: id })),
|
|
65
|
+
source: v.nullable(v.strictObject({ dir: v.pipe(v.string(), v.regex(/^\/assets\/(?:[a-z0-9]+(?:-[a-z0-9]+)*\/)?music\/[a-z0-9_-]+\/$/u)), manifestKey: id })),
|
|
66
66
|
sets: v.record(id, id), selection: v.pipe(v.array(v.strictObject({ slots: list, when: conditions })), v.minLength(1), v.maxLength(64)),
|
|
67
67
|
selectMode: v.picklist(['first', 'all']),
|
|
68
68
|
catalogue: v.exactOptional(v.strictObject({ mode: v.picklist(['slots','bank']), extraStings: v.pipe(v.array(v.picklist(['pickup','death','chunk','dawn'])),v.maxLength(4)), stingSets: v.strictObject({ pickup:v.exactOptional(id),death:v.exactOptional(id),chunk:v.exactOptional(id),dawn:v.exactOptional(id) }) })),
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SF15 (J525, meta standalone shardfiles): the cook makes every KTX2 from a shardfile's own images, so a shardfile carries
|
|
2
|
+
// images only (JPG or PNG, and GLBs holding them): one way, never two. A new upload that carries its own KTX2 (a `ktx2` blob
|
|
3
|
+
// or a `.ktx2` file) is refused here. A stored shard file (an engine pin, a stored original, a cook: `judged: 'stored'`)
|
|
4
|
+
// is read as it was admitted, so the shards from before this rule still cook until their re-pack.
|
|
5
|
+
//
|
|
6
|
+
// A file that must stay an image (UI art, pixel art) says so on its cook mount row: `keepImage: true` (`cook-data.ts`).
|
|
7
|
+
import type { OutputIndex } from './outputIndex.ts'
|
|
8
|
+
import type { Judged } from './policy-verdict.ts'
|
|
9
|
+
|
|
10
|
+
const KTX2_PATH = /\.ktx2$/iu
|
|
11
|
+
|
|
12
|
+
/** The first KTX2 a shardfile carries, by its path in the product: a non-commons `ktx2` blob, or any `.ktx2` file. */
|
|
13
|
+
function carriedKtx2(
|
|
14
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
|
|
15
|
+
index: OutputIndex,
|
|
16
|
+
paths: Iterable<string>,
|
|
17
|
+
): string | undefined {
|
|
18
|
+
const commons = new Set<string>()
|
|
19
|
+
for (const row of index.files) {
|
|
20
|
+
if (row.commons === true) {
|
|
21
|
+
commons.add(row.path)
|
|
22
|
+
} else if (row.kind === 'ktx2') {
|
|
23
|
+
return row.path
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const path of paths) {
|
|
27
|
+
if (KTX2_PATH.test(path) && !commons.has(path)) {
|
|
28
|
+
return path
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Refuse a new upload that carries its own KTX2; a stored shard file passes. */
|
|
35
|
+
function refuseCarriedKtx2(
|
|
36
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
|
|
37
|
+
index: OutputIndex,
|
|
38
|
+
paths: Iterable<string>,
|
|
39
|
+
judged: Judged | undefined,
|
|
40
|
+
): void {
|
|
41
|
+
if ((judged ?? 'upload') !== 'upload') {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
const path = carriedKtx2(index, paths)
|
|
45
|
+
if (path !== undefined) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`A shardfile carries images only; the cook makes every KTX2 (J525): ${path}`,
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { carriedKtx2, refuseCarriedKtx2 }
|
package/src/format/cook-data.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
CookPreparationSchema,
|
|
18
18
|
CookSpecPreparationSchema,
|
|
19
19
|
} from './cook-preparation.ts'
|
|
20
|
+
import { ShardVersionSchema } from './shard-version.ts'
|
|
20
21
|
|
|
21
22
|
import type {
|
|
22
23
|
CookPreparation,
|
|
@@ -39,11 +40,14 @@ interface CookMount {
|
|
|
39
40
|
readonly path: string
|
|
40
41
|
readonly hash: string
|
|
41
42
|
readonly bytes: number
|
|
43
|
+
/** SF15 (J525): the cook leaves this image as it is and makes no KTX2 of it (UI art, pixel art). */
|
|
44
|
+
readonly keepImage?: true
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
interface LegacyCookData {
|
|
45
48
|
readonly version: typeof COOK_DATA_VERSION
|
|
46
49
|
readonly mounts: readonly CookMount[]
|
|
50
|
+
readonly shardVersion?: string
|
|
47
51
|
/** 'fence' packs what the boot reads before control; unset, the whole level. */
|
|
48
52
|
readonly packs?: 'fence'
|
|
49
53
|
/** The stable identities a recorded cold boot read before control. */
|
|
@@ -85,6 +89,7 @@ const mountRow: GenericSchema<unknown, CookMount> = strictObject({
|
|
|
85
89
|
path: mountPath,
|
|
86
90
|
hash: sha256Hex,
|
|
87
91
|
bytes: byteCount,
|
|
92
|
+
keepImage: exactOptional(literal(true)),
|
|
88
93
|
})
|
|
89
94
|
|
|
90
95
|
const mountRows: GenericSchema<unknown, CookMount[]> = pipe(
|
|
@@ -105,6 +110,7 @@ const identities: GenericSchema<unknown, string[]> = pipe(
|
|
|
105
110
|
const LegacyCookDataSchema = strictObject({
|
|
106
111
|
version: literal(COOK_DATA_VERSION),
|
|
107
112
|
mounts: mountRows,
|
|
113
|
+
shardVersion: exactOptional(ShardVersionSchema),
|
|
108
114
|
packs: exactOptional(literal('fence')),
|
|
109
115
|
fence: exactOptional(identities),
|
|
110
116
|
})
|
|
@@ -112,17 +118,21 @@ const LegacyCookDataSchema = strictObject({
|
|
|
112
118
|
const PreparedCookDataSchema = strictObject({
|
|
113
119
|
...CookPreparationSchema.entries,
|
|
114
120
|
mounts: mountRows,
|
|
121
|
+
shardVersion: exactOptional(ShardVersionSchema),
|
|
115
122
|
})
|
|
116
123
|
/** SHARD-COMPAT PR4: preparation spec 4, which names no engine. */
|
|
117
124
|
const SpecCookDataSchema = strictObject({
|
|
118
125
|
...CookSpecPreparationSchema.entries,
|
|
119
126
|
mounts: mountRows,
|
|
127
|
+
shardVersion: exactOptional(ShardVersionSchema),
|
|
120
128
|
})
|
|
121
129
|
interface PreparedCookData extends CookPreparation {
|
|
122
130
|
readonly mounts: readonly CookMount[]
|
|
131
|
+
readonly shardVersion?: string
|
|
123
132
|
}
|
|
124
133
|
interface SpecCookData extends CookSpecPreparation {
|
|
125
134
|
readonly mounts: readonly CookMount[]
|
|
135
|
+
readonly shardVersion?: string
|
|
126
136
|
}
|
|
127
137
|
type CookData = LegacyCookData | PreparedCookData | SpecCookData
|
|
128
138
|
const CookDataSchema: GenericSchema<unknown, CookData> = variant('version', [
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// SF1: engine 643b71dde, src/scripts/public-engine.json, filtered to /assets/.
|
|
2
|
+
export const ENGINE_ART: ReadonlySet<string> = new Set([
|
|
3
|
+
'/assets/baked/common/cloud-field.bin',
|
|
4
|
+
'/assets/baked/common/pickups/1fe194ff84e1bc6b9a4b384d34b4c6b4b7610b2c554aeb4e68cf476dd0e4a6a8.bin',
|
|
5
|
+
'/assets/baked/common/pickups/2de7bee2cfa38f6fb0c098894ce0d566eaef604b296445fba9bb21c55f219bb4.bin',
|
|
6
|
+
'/assets/baked/common/pickups/2f564a7ac57034940f5393f7af0401f978885104b49bf152628f11db64c41674.bin',
|
|
7
|
+
'/assets/baked/common/pickups/3452560ee7c55252cfeedb15711de356f0c6268cf0675976b318f7615a2a5e17.bin',
|
|
8
|
+
'/assets/baked/common/pickups/4bf85e3c3a0c2d0e0a235146ccfe16b1c98f214cd63800f4c7df554b9692d6e9.bin',
|
|
9
|
+
'/assets/baked/common/pickups/5c3385ceda17cb100afcf597bedf2d4c80369631055c74f4b33411adf84617dd.bin',
|
|
10
|
+
'/assets/baked/common/pickups/64f3f46016335eebc0875d1d3b75e7d3e1d1a054d7c097a5833f03c32fadf09c.bin',
|
|
11
|
+
'/assets/baked/common/pickups/6668b77b41bfa6e203dde8b28eb1a62da2bd49253ed0a4ba50c06f4b43a99b9e.bin',
|
|
12
|
+
'/assets/baked/common/pickups/6ef126f7661e05ea6ced8d6a821db45cde98c0c6867a7f80056176fcd78dd0ff.bin',
|
|
13
|
+
'/assets/baked/common/pickups/797122eeccd31b4004e2042c32385f17e903832426be0654b0dd60eb376460f0.bin',
|
|
14
|
+
'/assets/baked/common/pickups/91bdc8a37eb8437ab96f54331754cd5319a3307770870a69700d4d2380fcb30f.bin',
|
|
15
|
+
'/assets/baked/common/pickups/9e9951eb1076b35cc2708882cd14ff78276b61de234359bc24e2bfdd0bcd5c6b.bin',
|
|
16
|
+
'/assets/baked/common/pickups/ae21af3308fbecd359dd9e540b0317c0e60a77b8e31756816c2ebec329d8f063.bin',
|
|
17
|
+
'/assets/baked/common/pickups/b2afea11f95d0f420621460dfdea648f1db2efc74722c1bdf993945185c91f46.bin',
|
|
18
|
+
'/assets/baked/common/pickups/cae6a0c9056a243b2d3b4eef8f3411190dbb99611207c9297e84fafb006d268c.bin',
|
|
19
|
+
'/assets/baked/common/pickups/d22a098c92209d8b97226a0e0397d6cf6a5c45f8c5647e7328949c567ba7e850.bin',
|
|
20
|
+
'/assets/baked/common/pickups/d3abf3a9ce30e47f9a19e90cf5a83c95ae6f254aeb768191da56583353ce8e12.bin',
|
|
21
|
+
'/assets/baked/common/pickups/f3ce7d3e67bfae1075c398ac42593a106a187cb453206b2a691fd2306d0a5633.bin',
|
|
22
|
+
'/assets/baked/common/pickups/f49d22fffc4890880502d5308086ad225bb6cb6cd8fca8e8e58c1cb890dfbe96.bin',
|
|
23
|
+
'/assets/baked/common/pickups/f5a6071cc33cf87a3c498aac8062a0b3d87d29fb54a65f07cf3bfc3f523efc10.bin',
|
|
24
|
+
'/assets/baked/common/pickups/f7d3d060691377efa8aec3b4050b437fcfafc14a227b869d79fcbc91b226a5c6.bin',
|
|
25
|
+
'/assets/baked/common/pickups/fbd68e21b04e93fc938abbf14febe83df0992769eb173fa540249ed327bfcea2.bin',
|
|
26
|
+
'/assets/baked/common/pickups/fd513e136fcc7cc387fd5e351c9666b6418d6ed26a4569c83b1d9029b2d3f4e7.bin',
|
|
27
|
+
'/assets/baked/common/pickups/ff59e17a90dd32fbb6f5d403e79e81129f9750c8bf43f184af2f3b475981b14e.bin',
|
|
28
|
+
'/assets/baked/common/water-ripples.bin',
|
|
29
|
+
'/assets/grid-road/road-asphalt-phone.ktx2',
|
|
30
|
+
'/assets/grid-road/road-junction-phone.ktx2',
|
|
31
|
+
'/assets/grid-road/road-surfaces.json',
|
|
32
|
+
'/assets/models/hatchet/textures/hatchet_arm_1k.phone.webp',
|
|
33
|
+
'/assets/models/hatchet/textures/hatchet_diff_1k.phone.webp',
|
|
34
|
+
'/assets/models/hatchet/textures/hatchet_nor_gl_1k.phone.webp',
|
|
35
|
+
'/assets/music/ob7-listening.html',
|
|
36
|
+
'/assets/music/piano/music.json',
|
|
37
|
+
'/assets/music/piano/sting-chunk-1f540734.m4a',
|
|
38
|
+
'/assets/music/piano/sting-death-8ee9ff5d.m4a',
|
|
39
|
+
'/assets/music/piano/sting-pickup-5ba19a30.m4a',
|
|
40
|
+
'/assets/music/piano/title-7ce82663.m4a',
|
|
41
|
+
'/assets/practice/dummies/straw-cloth.glb',
|
|
42
|
+
'/assets/practice/dummies/unimate-motion.glb',
|
|
43
|
+
'/assets/practice/dummies/wood-steel.glb',
|
|
44
|
+
'/assets/practice/dummies/wood-wood.glb',
|
|
45
|
+
'/assets/sfx/best/bear_growl-3-cc7886e0.m4a',
|
|
46
|
+
'/assets/sfx/best/bear_hurt-1-f85f52c2.m4a',
|
|
47
|
+
'/assets/sfx/best/bear_hurt-3-55a83ba0.m4a',
|
|
48
|
+
'/assets/sfx/best/bear_roar-2-1cef350c.m4a',
|
|
49
|
+
'/assets/sfx/best/bear_roar-3-73630c1c.m4a',
|
|
50
|
+
'/assets/sfx/best/bed-underwater-3-e24ff222.m4a',
|
|
51
|
+
'/assets/sfx/best/boar_grunt-3-a64bbfdc.m4a',
|
|
52
|
+
'/assets/sfx/best/boar_squeal-1-92d61176.m4a',
|
|
53
|
+
'/assets/sfx/best/boltImpact-flesh-2-f674bf18.m4a',
|
|
54
|
+
'/assets/sfx/best/boltImpact-flesh-3-2338408b.m4a',
|
|
55
|
+
'/assets/sfx/best/boltImpact-ground-1-d23a3448.m4a',
|
|
56
|
+
'/assets/sfx/best/boltImpact-ground-2-129e0855.m4a',
|
|
57
|
+
'/assets/sfx/best/boltImpact-wood-2-6d2a1507.m4a',
|
|
58
|
+
'/assets/sfx/best/boltImpact-wood-3-6a4b8f28.m4a',
|
|
59
|
+
'/assets/sfx/best/crossbowFire-3-ea28c0a1.m4a',
|
|
60
|
+
'/assets/sfx/best/deer_call-1-b68edf22.m4a',
|
|
61
|
+
'/assets/sfx/best/deer_call-3-c8a420b0.m4a',
|
|
62
|
+
'/assets/sfx/best/dive-1-970397fa.m4a',
|
|
63
|
+
'/assets/sfx/best/dive-3-3ffe8999.m4a',
|
|
64
|
+
'/assets/sfx/best/dodge-2-f01c46d0.m4a',
|
|
65
|
+
'/assets/sfx/best/dodge-3-b4decd39.m4a',
|
|
66
|
+
'/assets/sfx/best/dryFire-2-fdc93561.m4a',
|
|
67
|
+
'/assets/sfx/best/dryFire-3-da2f2db5.m4a',
|
|
68
|
+
'/assets/sfx/best/elk_bugle-2-2ca5339a.m4a',
|
|
69
|
+
'/assets/sfx/best/elk_bugle-3-f9685682.m4a',
|
|
70
|
+
'/assets/sfx/best/footstep-litter-1-e4432f8f.m4a',
|
|
71
|
+
'/assets/sfx/best/footstep-litter-3-c0eef9be.m4a',
|
|
72
|
+
'/assets/sfx/best/footstep-mud-1-b66bbd49.m4a',
|
|
73
|
+
'/assets/sfx/best/footstep-mud-2-7d83fc7c.m4a',
|
|
74
|
+
'/assets/sfx/best/footstep-planks-2-b3d3f757.m4a',
|
|
75
|
+
'/assets/sfx/best/footstep-planks-3-07743ea3.m4a',
|
|
76
|
+
'/assets/sfx/best/footstep-rock-2-f5124e07.m4a',
|
|
77
|
+
'/assets/sfx/best/footstep-rock-3-8a0054f7.m4a',
|
|
78
|
+
'/assets/sfx/best/footstep-sand-1-20fe21fe.m4a',
|
|
79
|
+
'/assets/sfx/best/footstep-sand-2-5551248f.m4a',
|
|
80
|
+
'/assets/sfx/best/footstep-wet-1-9495bb0e.m4a',
|
|
81
|
+
'/assets/sfx/best/hitMarker-1-5c1e66a1.m4a',
|
|
82
|
+
'/assets/sfx/best/hoofsteps-1-04492a4d.m4a',
|
|
83
|
+
'/assets/sfx/best/hoofsteps-3-877c081a.m4a',
|
|
84
|
+
'/assets/sfx/best/hum-pickup-3-7fc62eae.m4a',
|
|
85
|
+
'/assets/sfx/best/kill-2-f4fb9a77.m4a',
|
|
86
|
+
'/assets/sfx/best/kill-3-f99b2126.m4a',
|
|
87
|
+
'/assets/sfx/best/land-2-33a6e4b7.m4a',
|
|
88
|
+
'/assets/sfx/best/land-3-6b542c4e.m4a',
|
|
89
|
+
'/assets/sfx/best/land-hard-1-33dd612d.m4a',
|
|
90
|
+
'/assets/sfx/best/land-hard-3-ea1ae9ba.m4a',
|
|
91
|
+
'/assets/sfx/best/lunge-3-8d441293.m4a',
|
|
92
|
+
'/assets/sfx/best/reload-1-3b1ae590.m4a',
|
|
93
|
+
'/assets/sfx/best/reload-3-e088b909.m4a',
|
|
94
|
+
'/assets/sfx/best/rifleFire-2-a0343e34.m4a',
|
|
95
|
+
'/assets/sfx/best/rifleFire-3-0504f7cc.m4a',
|
|
96
|
+
'/assets/sfx/best/rifleReload-2-e8696bed.m4a',
|
|
97
|
+
'/assets/sfx/best/rifleReload-3-bf8f116a.m4a',
|
|
98
|
+
'/assets/sfx/best/sfx.json',
|
|
99
|
+
'/assets/sfx/best/splash-2-42205790.m4a',
|
|
100
|
+
'/assets/sfx/best/splash-3-c8eb6dc8.m4a',
|
|
101
|
+
'/assets/sfx/best/surface-2-11564c13.m4a',
|
|
102
|
+
'/assets/sfx/best/surface-3-7fff73d1.m4a',
|
|
103
|
+
'/assets/sfx/best/swimStroke-2-21f83d52.m4a',
|
|
104
|
+
'/assets/sfx/best/swordHeavy-2-f396e760.m4a',
|
|
105
|
+
'/assets/sfx/best/swordHeavy-3-3138e14f.m4a',
|
|
106
|
+
'/assets/sfx/best/swordHit-flesh-1-bb37e93c.m4a',
|
|
107
|
+
'/assets/sfx/best/swordHit-flesh-2-feb9c7ca.m4a',
|
|
108
|
+
'/assets/sfx/best/swordHit-wood-2-e1d4dc58.m4a',
|
|
109
|
+
'/assets/sfx/best/swordHit-wood-3-22e728e1.m4a',
|
|
110
|
+
'/assets/sfx/best/swordSwing-1-22b97070.m4a',
|
|
111
|
+
'/assets/sfx/best/wadeStep-1-2743035d.m4a',
|
|
112
|
+
'/assets/sfx/best/wadeStep-2-06aa98c5.m4a',
|
|
113
|
+
'/assets/sfx/best/waterExit-1-990a61e9.m4a',
|
|
114
|
+
'/assets/sfx/best/weaponSwap-3-de475e16.m4a',
|
|
115
|
+
'/assets/title/launch-1206x2622-aa16bc3256f3.png',
|
|
116
|
+
'/assets/title/main-crossroads-landscape-first.jpg',
|
|
117
|
+
'/assets/title/main-crossroads-landscape.jpg',
|
|
118
|
+
'/assets/title/main-crossroads-square-first.jpg',
|
|
119
|
+
'/assets/title/main-crossroads-square.jpg',
|
|
120
|
+
])
|
package/src/format/glbImages.ts
CHANGED
|
@@ -25,14 +25,29 @@ function mipBytes(width: number, height: number): number {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const GLB_IMAGE_MIMES: ReadonlySet<string> = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/ktx2']);
|
|
29
|
+
const CORE_IMAGE_MIMES: ReadonlySet<string> = new Set(['image/png', 'image/jpeg']);
|
|
30
|
+
|
|
31
|
+
/** SF16 (J525): a texture with no extensions binds a core image by `source`. Its charge: a shardfile's GLB may carry PNG or JPEG images bound by `source`; the cook encodes them to KTX2. */
|
|
32
|
+
function coreTexture(texture: Readonly<Record<string, unknown>>, images: readonly { readonly mime: string; readonly gpu: number }[], samplers: number): { bytes: number; uses: number } {
|
|
33
|
+
const image = images[count(texture['source'])];
|
|
34
|
+
if (image === undefined || (texture['sampler'] !== undefined && count(texture['sampler']) >= samplers)) {
|
|
35
|
+
throw new Error('Missing GLB texture image or sampler');
|
|
36
|
+
}
|
|
37
|
+
if (!CORE_IMAGE_MIMES.has(image.mime)) {
|
|
38
|
+
throw new Error('GLB texture extension differs from image MIME');
|
|
39
|
+
}
|
|
40
|
+
return { bytes: image.gpu, uses: 0 };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Admit bounded embedded PNG or JPEG (core `source`, SF16) and WebP or Basis KTX2 through their matching texture extensions; external/data URIs
|
|
29
44
|
* and other bindings still refuse. Charge decoded images and conservative RGBA8 mips per texture/material use,
|
|
30
45
|
* conservatively covering loader clones for different material colour spaces. The GLB aggregate cap also applies. */
|
|
31
46
|
export function glbImageCost(doc: Record<string, unknown>, views: readonly Record<string, unknown>[], binary: Uint8Array): { decoded: number; gpu: number } {
|
|
32
47
|
let decoded = 0;
|
|
33
48
|
const images = list(doc['images'] ?? [], 16).map(value => {
|
|
34
49
|
const image = record(value); noExtensions(image);
|
|
35
|
-
if (image['uri'] !== undefined || (image['mimeType']
|
|
50
|
+
if (image['uri'] !== undefined || !GLB_IMAGE_MIMES.has(String(image['mimeType']))) throw new Error('GLB images require embedded PNG, JPEG, WebP or Basis KTX2 bytes');
|
|
36
51
|
const view = views[count(image['bufferView'])];
|
|
37
52
|
if (view === undefined || view['byteStride'] !== undefined || view['target'] !== undefined) throw new Error('Invalid GLB image view');
|
|
38
53
|
const offset = count(view['byteOffset'] ?? 0), length = count(view['byteLength']);
|
|
@@ -61,9 +76,8 @@ export function glbImageCost(doc: Record<string, unknown>, views: readonly Recor
|
|
|
61
76
|
|| ![33071, 33648, 10497].includes(count(sampler['wrapT'] ?? 10497))) throw new Error('Invalid GLB image sampler');
|
|
62
77
|
return sampler;
|
|
63
78
|
});
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const extension = extensions['EXT_texture_webp'] === undefined ? 'KHR_texture_basisu' : 'EXT_texture_webp';
|
|
79
|
+
const extensionTexture = (texture: Readonly<Record<string, unknown>>): { bytes: number; uses: number } => {
|
|
80
|
+
const extensions = record(texture['extensions']), extension = extensions['EXT_texture_webp'] === undefined ? 'KHR_texture_basisu' : 'EXT_texture_webp';
|
|
67
81
|
if (texture['source'] !== undefined || Object.keys(extensions).length !== 1 || extensions[extension] === undefined
|
|
68
82
|
|| !list(doc['extensionsUsed'] ?? [], 32).includes(extension)) throw new Error('GLB texture requires an unambiguous declared image extension');
|
|
69
83
|
const binding = record(extensions[extension]);
|
|
@@ -72,6 +86,10 @@ export function glbImageCost(doc: Record<string, unknown>, views: readonly Recor
|
|
|
72
86
|
if (image === undefined || (texture['sampler'] !== undefined && samplers[count(texture['sampler'])] === undefined)) throw new Error('Missing GLB texture image or sampler');
|
|
73
87
|
if (image.mime !== (extension === 'KHR_texture_basisu' ? 'image/ktx2' : 'image/webp')) throw new Error('GLB texture extension differs from image MIME');
|
|
74
88
|
return { bytes: image.gpu, uses: 0 };
|
|
89
|
+
};
|
|
90
|
+
const textures = list(doc['textures'] ?? [], 32).map(value => {
|
|
91
|
+
const texture = record(value);
|
|
92
|
+
return texture['extensions'] === undefined ? coreTexture(texture, images, samplers.length) : extensionTexture(texture);
|
|
75
93
|
});
|
|
76
94
|
if (images.length === 0 && textures.length === 0) return { decoded: 0, gpu: 0 };
|
|
77
95
|
const bind = (value: unknown): void => {
|
|
@@ -53,6 +53,8 @@ const VALIDATE_CODES = {
|
|
|
53
53
|
'world-targets':
|
|
54
54
|
'`world/targets` names an item or quest the shardfile does not declare.',
|
|
55
55
|
'source-hash': 'The sections differ from the declared `build.sourceHash`.',
|
|
56
|
+
'carried-ktx2':
|
|
57
|
+
'A new upload carries its own KTX2 (a `ktx2` blob or a `.ktx2` file): a shardfile carries images only and the cook makes every KTX2 (J525).',
|
|
56
58
|
} as const
|
|
57
59
|
|
|
58
60
|
// Stream: the streaming validator's own refusals, beside the validate codes it shares.
|
package/src/format/materials.ts
CHANGED
|
@@ -204,7 +204,7 @@ export function graphFileRules(source: Pick<Shardfile, 'look' | 'state' | 'files
|
|
|
204
204
|
const deps = new Set(files.get(material.file)?.dependencies);
|
|
205
205
|
for (const param of Object.values(checked.graph.params ?? {})) {
|
|
206
206
|
// a lent texture names no file: its runtime lends it (as an inline graph's)
|
|
207
|
-
if (param.type === 'texture' && param.role !== 'lent' && (typeof param.value !== 'string' || !deps.has(param.value) || files.get(param.value)?.kind
|
|
207
|
+
if (param.type === 'texture' && param.role !== 'lent' && (typeof param.value !== 'string' || !deps.has(param.value) || !['ktx2', 'image'].includes(files.get(param.value)?.kind ?? ''))) errors.push(`material ${materialId}: a graph file's texture is a KTX2 or image (SF16) dependency of its file row`);
|
|
208
208
|
}
|
|
209
209
|
errors.push(...bindingTypeErrors(materialId, checked.graph, dayChannels));
|
|
210
210
|
}
|
|
@@ -10,6 +10,7 @@ import type { AudioWaiver } from './audio-waiver.ts';
|
|
|
10
10
|
import { isOutputIndex, outputBlobPath } from './outputAddress.ts';
|
|
11
11
|
import { OUTPUT_SECTIONS, assembleOutputTransport, isPlatformDataSection, type OutputHostSectionName } from './outputFields.ts';
|
|
12
12
|
import * as v from 'valibot';
|
|
13
|
+
import { ShardVersionSchema } from './shard-version.ts';
|
|
13
14
|
import { assertFormatWindow } from './format-window.ts';
|
|
14
15
|
import { assertCellBounds } from './cellBounds.ts';
|
|
15
16
|
import { ShardfileFieldSchemas, parseShardfile, type Shardfile } from './shardSchema.ts';
|
|
@@ -45,6 +46,8 @@ const PreparationSpecNumberSchema = v.pipe(v.number(), v.integer(), v.minValue(L
|
|
|
45
46
|
/** Format 2 inventories every emitted byte except its index and validation receipt. */
|
|
46
47
|
export const OutputIndexSchema: v.GenericSchema<OutputIndexRowsInput, OutputIndexRows> & { readonly entries: { readonly [Key in keyof OutputIndexRows]-?: v.GenericSchema<OutputIndexRowsInput[Key], OutputIndexRows[Key]> } } = v.strictObject({
|
|
47
48
|
format: v.literal('wildshard.shardfile'),
|
|
49
|
+
/** Author-written package version. Earlier stored shardfiles omit it. */
|
|
50
|
+
shardVersion: v.exactOptional(ShardVersionSchema),
|
|
48
51
|
/** SHARD-COMPAT CP14 (FP25): the format version itself from 0.1.0.2; the legacy envelope carries the frozen layout marker
|
|
49
52
|
* `2` here and its version in `version`. `checkIndexEnvelope` holds each envelope to its own fields. */
|
|
50
53
|
formatVersion: IndexFormatVersionSchema, version: LegacyIndexVersionSchema,
|
|
@@ -242,6 +245,7 @@ export function assembleOutputShardfile(input: unknown, sections: ReadonlyMap<st
|
|
|
242
245
|
/** Exact admitted data, independent of validator implementation metadata. */
|
|
243
246
|
interface OutputIndexRowsInputFields {
|
|
244
247
|
format: "wildshard.shardfile";
|
|
248
|
+
shardVersion?: string;
|
|
245
249
|
formatVersion: typeof LEGACY_LAYOUT | IndexFormatVersion;
|
|
246
250
|
sdk?: "0.2" | "0.3";
|
|
247
251
|
/** A spec this package reads (3, 4), or a newer one kept unread (SP1b1a). */
|
|
@@ -342,6 +346,7 @@ interface OutputIndexRowsInputFields {
|
|
|
342
346
|
export type OutputIndexRowsInput = { [Key in keyof OutputIndexRowsInputFields]: OutputIndexRowsInputFields[Key] };
|
|
343
347
|
interface OutputIndexRowsFields {
|
|
344
348
|
format: "wildshard.shardfile";
|
|
349
|
+
shardVersion?: string;
|
|
345
350
|
formatVersion: typeof LEGACY_LAYOUT | IndexFormatVersion;
|
|
346
351
|
sdk?: "0.2" | "0.3";
|
|
347
352
|
/** A spec this package reads (3, 4), or a newer one kept unread (SP1b1a). */
|
|
@@ -112,7 +112,7 @@ export function validatePropMaterials(materials: PropMaterials, context: {
|
|
|
112
112
|
if (graph !== null && param?.type !== 'texture' && !(slotName === 'colour' && graph !== undefined && graphUsesMeshMap(graph))) throw new Error(`props material "${name}": graph ${row.id} has no texture param "${slotName}" for its ${slotName} slot`);
|
|
113
113
|
} else if (!(FAMILY_SLOTS[family] ?? []).includes(slotName)) throw new Error(`props material "${name}": the ${family} family draws no ${slotName} slot`);
|
|
114
114
|
const file = files.get(value.file);
|
|
115
|
-
if (file?.kind !== 'ktx2' || !declared.has(value.file)) throw new Error(`props material "${name}": its ${slotName} texture must be a KTX2 dependency of a declared props GLB`);
|
|
115
|
+
if ((file?.kind !== 'ktx2' && file?.kind !== 'image') || !declared.has(value.file)) throw new Error(`props material "${name}": its ${slotName} texture must be a KTX2 or image (SF16) dependency of a declared props GLB`);
|
|
116
116
|
if (catalogue.has(value.file)) throw new Error(`props material "${name}": its ${slotName} texture is also a look.materials texture (one sampler per file)`);
|
|
117
117
|
// a graph reads every texture param in the colour role (clientGraphs): its slots take that role
|
|
118
118
|
const role = family === 'graph' ? 'colour' : propSlotUse(slotName), seenRole = roles.get(value.file);
|
package/src/format/props.ts
CHANGED
|
@@ -142,7 +142,7 @@ export function validatePropsReferences(props: ShardProps, content: { files: rea
|
|
|
142
142
|
for (const entry of [...props.panels, ...props.models]) { model(entry.file); if (!content.library.includes(entry.file)) throw new Error('Prop panel/model must belong to the library'); }
|
|
143
143
|
if (props.far !== null) { model(props.far); if (!content.far?.files.includes(props.far)) throw new Error('Props far proxy disagrees with far files'); }
|
|
144
144
|
const refs = new Set([...props.tiles.flatMap((t) => [t.file, ...t.additionalFiles ?? []]), ...props.panels.map((p) => p.file), ...props.models.map((p) => p.file), ...(props.far === null ? [] : [props.far])]);
|
|
145
|
-
for (const texture of props.textures) if (!refs.has(texture.model) || files.get(texture.colour)?.kind
|
|
145
|
+
for (const texture of props.textures) if (!refs.has(texture.model) || !['ktx2', 'image'].includes(files.get(texture.colour)?.kind ?? '') || !files.get(texture.model)?.dependencies.includes(texture.colour)) throw new Error('Prop texture must be a declared KTX2 dependency');
|
|
146
146
|
if (props.materials !== undefined) validatePropMaterials(props.materials, { look: content.look?.materials ?? {}, models: [...refs], textures: props.textures, files: content.files });
|
|
147
147
|
if (props.splat !== undefined) {
|
|
148
148
|
if (props.materials !== undefined && Object.hasOwn(props.materials, props.splat.material)) throw new Error('Splat terrain material cannot also name a prop material');
|
|
@@ -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
|
+
)
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// The index and script rows are valibot's output types, which the replay only
|
|
7
7
|
// reads; their parameters say so in a disable comment rather than a deep type.
|
|
8
8
|
|
|
9
|
+
import { refuseCarriedKtx2 } from './carried-ktx2.ts'
|
|
9
10
|
import { cookMountPath, readCookData } from './cook-data.ts'
|
|
10
11
|
import { requireCookPreparation } from './cook-preparation.ts'
|
|
11
12
|
import { deprecationReport } from './deprecations.ts'
|
|
@@ -19,10 +20,16 @@ import { decisionModuleContracts } from './scriptContract.ts'
|
|
|
19
20
|
import { mountSharesBlob } from './shardfile-reads.ts'
|
|
20
21
|
import { inspectFacts, ktx2Text } from './shardfile-stream-facts.ts'
|
|
21
22
|
import { outputBlobKind, readCanonicalJson } from './shardfileValidation.ts'
|
|
23
|
+
import {
|
|
24
|
+
assertShardMountUrls,
|
|
25
|
+
assertStandaloneArt,
|
|
26
|
+
readDiscoveryArt,
|
|
27
|
+
} from './standalone-art.ts'
|
|
22
28
|
import { validationSourceBytes } from './validationReceipt.ts'
|
|
23
29
|
|
|
24
30
|
import type { DeprecationReport } from './deprecations.ts'
|
|
25
31
|
import type { OutputIndex } from './outputIndex.ts'
|
|
32
|
+
import type { Judged } from './policy-verdict.ts'
|
|
26
33
|
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
27
34
|
import type { FactsMember } from './shardfile-stream-facts.ts'
|
|
28
35
|
import type { StreamMember } from './shardfile-stream-tar.ts'
|
|
@@ -41,6 +48,8 @@ interface Replay {
|
|
|
41
48
|
readonly members: ReadonlyMap<string, KeptMember>
|
|
42
49
|
readonly listed: Set<string>
|
|
43
50
|
readonly hash: (bytes: Readonly<Uint8Array>) => string
|
|
51
|
+
/** SF15: how the upload is judged, for the carried-KTX2 refusal (`carried-ktx2.ts`). */
|
|
52
|
+
readonly judged?: Judged | undefined
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
const NONE = 0
|
|
@@ -244,6 +253,10 @@ function replayPacksToInventory(
|
|
|
244
253
|
}
|
|
245
254
|
replayCook(replay, index)
|
|
246
255
|
replayInventory(replay, index)
|
|
256
|
+
// SF15 (J525): a new upload carries images only; the folder validator checks it after its inventory too.
|
|
257
|
+
withIssueCode('carried-ktx2', (): void => {
|
|
258
|
+
refuseCarriedKtx2(index, replay.members.keys(), replay.judged)
|
|
259
|
+
})
|
|
247
260
|
}
|
|
248
261
|
|
|
249
262
|
/** The deprecation report, with `cook.json` as the folder validator passes it (FORMAT-PRUNE FP23's gate: without it
|
|
@@ -262,7 +275,18 @@ function streamedDeprecations(
|
|
|
262
275
|
listed === undefined
|
|
263
276
|
? undefined
|
|
264
277
|
: readCanonicalJson(listedBytes(replay, listed))
|
|
265
|
-
|
|
278
|
+
if (replay.judged !== 'stored' && shard.index.shardVersion !== undefined) {
|
|
279
|
+
const mounts = cook === undefined ? [] : readCookData(cook).mounts
|
|
280
|
+
const discovery = mounts
|
|
281
|
+
.filter((mount): boolean => isDiscoveryMount(mount.path))
|
|
282
|
+
.map((mount): unknown => readDiscoveryArt(listedBytes(replay, mount)))
|
|
283
|
+
assertStandaloneArt([...shard.sections.values(), ...discovery], mounts)
|
|
284
|
+
assertShardMountUrls(shard.index.identity.slug, mounts)
|
|
285
|
+
}
|
|
286
|
+
return deprecationReport(
|
|
287
|
+
{ index: shard.index, sections: shard.sections, cook },
|
|
288
|
+
warnings,
|
|
289
|
+
)
|
|
266
290
|
}
|
|
267
291
|
|
|
268
292
|
export type { KeptMember, Replay }
|
|
@@ -259,6 +259,7 @@ async function validateShardfileStream(
|
|
|
259
259
|
members: walked.members,
|
|
260
260
|
listed: new Set(['validation.json']),
|
|
261
261
|
hash: ports.hash,
|
|
262
|
+
judged: ports.judged,
|
|
262
263
|
}
|
|
263
264
|
const index = withIssueCode('index-invalid', (): OutputIndex =>
|
|
264
265
|
readIndex(replay),
|
|
@@ -294,7 +295,6 @@ async function validateShardfileStream(
|
|
|
294
295
|
reads: later.reads + NEXT,
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
|
-
|
|
298
298
|
export type { StoredSource } from './shardfile-stream-assets.ts'
|
|
299
299
|
export type { StreamValidationPorts, StreamedShardfile }
|
|
300
300
|
export { STREAM_BLOB_CAP, STREAM_KEPT_CAP, validateShardfileStream }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { assertShardMountUrls, assertStandaloneArt, readDiscoveryArt } from './standalone-art.ts';
|
|
1
2
|
import { cookMountPath, readCookData } from './cook-data.ts';
|
|
2
|
-
import { checkDiscoveryMount } from './manifest-deprecations.ts';
|
|
3
|
+
import { checkDiscoveryMount, isDiscoveryMount } from './manifest-deprecations.ts';
|
|
3
4
|
import { requireCookPreparation } from './cook-preparation.ts';
|
|
4
5
|
import { declaredSourceMatches, parseIncomingIndex, validateIncomingSection } from './incoming.ts';
|
|
5
6
|
import { assembleOutputShardfile, type OutputFile, type OutputIndex } from './outputIndex.ts';
|
|
@@ -31,6 +32,7 @@ import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
|
|
|
31
32
|
import { admittedVerdict, policyVerdict, recordVerdict } from './policy-verdict.ts';
|
|
32
33
|
import type { Judged, PolicyVerdict } from './policy-verdict.ts';
|
|
33
34
|
import { deprecationReport } from './deprecations.ts';
|
|
35
|
+
import { refuseCarriedKtx2 } from './carried-ktx2.ts';
|
|
34
36
|
import { currentSchemaSource } from './schema-source.ts';
|
|
35
37
|
import type { DeprecationReport } from './deprecations.ts';
|
|
36
38
|
|
|
@@ -253,11 +255,18 @@ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileV
|
|
|
253
255
|
checkServerAndKtx2(index, read, assets);
|
|
254
256
|
coded('pack-invalid', (): void => { checkPacks(index, new Set(files.paths()), { readFile: files.read, readListed: read, verify, hash: ports.hash }); });
|
|
255
257
|
const { cook, mountedImages } = readCook(index, read, ports);
|
|
258
|
+
if (ports.judged !== 'stored' && index.shardVersion !== undefined) {
|
|
259
|
+
const mounts = cook?.mounts ?? [];
|
|
260
|
+
const discovery = mounts.filter((mount): boolean => isDiscoveryMount(mount.path)).map((mount): unknown => readDiscoveryArt(read(mount)));
|
|
261
|
+
assertStandaloneArt([...payloads.values(), ...discovery], mounts);
|
|
262
|
+
assertShardMountUrls(index.identity.slug, mounts);
|
|
263
|
+
}
|
|
256
264
|
for (const entry of index.runtime?.files ?? []) {
|
|
257
265
|
if (ports.runtimeImports === undefined) throw issueError('runtime-files', 'Copied runtime files need a runtime import checker');
|
|
258
266
|
coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
|
|
259
267
|
}
|
|
260
268
|
for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
|
|
269
|
+
coded('carried-ktx2', (): void => { refuseCarriedKtx2(index, files.paths(), ports.judged); });
|
|
261
270
|
const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages, index, judged: ports.judged ?? 'upload', armed: ports.armed });
|
|
262
271
|
checkWorldTargets(shard, payloads.get('world/targets'));
|
|
263
272
|
if (!declaredSourceMatches(shard, index, ports.hash)) throw issueError('source-hash', 'Output sections differ from the declared source hash');
|
|
@@ -53,7 +53,9 @@ function readSkinFile(
|
|
|
53
53
|
const skin = { hash, ...parseSkinFile(bytes) }
|
|
54
54
|
const expected = skinFileDependencies(skin.row, skin.binding)
|
|
55
55
|
const texture = (ref: string): boolean =>
|
|
56
|
-
ref.startsWith('commons:') ||
|
|
56
|
+
ref.startsWith('commons:') ||
|
|
57
|
+
files.get(ref)?.kind === 'ktx2' ||
|
|
58
|
+
files.get(ref)?.kind === 'image'
|
|
57
59
|
if (
|
|
58
60
|
file.dependencies.length !== expected.length ||
|
|
59
61
|
file.dependencies.some((ref, index): boolean => ref !== expected[index]) ||
|
package/src/format/skinAssets.ts
CHANGED
|
@@ -39,7 +39,7 @@ function skinLookRules(source: Pick<Shardfile, 'rows' | 'files' | 'library'>): s
|
|
|
39
39
|
// OF27b: a skin file depends on its GLB, then its material's textures (KTX2 files or commons)
|
|
40
40
|
const textures = file?.dependencies.slice(1) ?? [];
|
|
41
41
|
if (file?.kind !== 'json' || glb?.kind !== 'glb' || !source.library.includes(skin)
|
|
42
|
-
|| textures.some((ref): boolean => !ref.startsWith('commons:') && files.get(ref)?.kind !== 'ktx2')) {errors.push('skin look file references');}
|
|
42
|
+
|| textures.some((ref): boolean => !ref.startsWith('commons:') && files.get(ref)?.kind !== 'ktx2' && files.get(ref)?.kind !== 'image')) {errors.push('skin look file references');}
|
|
43
43
|
if (!libraryJson(source.library, kinds, variants)) {errors.push('skin variant table references');}
|
|
44
44
|
if (!libraryJson(source.library, kinds, phone)) {errors.push('skin phone file references');}
|
|
45
45
|
if (!libraryJson(source.library, kinds, phoneVariants)) {errors.push('skin phone variant table references');}
|
|
@@ -74,7 +74,7 @@ export function splatTextureRefs(splat: SplatTerrain | undefined, tier?: 'phone'
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Check a splat terrain against the admitted files: every layer file is a KTX2 dependency of a declared props tile GLB, one
|
|
77
|
+
* Check a splat terrain against the admitted files: every layer file is a KTX2 or image (SF16) dependency of a declared props tile GLB, one
|
|
78
78
|
* file plays one role (a file may repeat within a role, never across colour and data), and none is also a `look.materials`
|
|
79
79
|
* or named prop material texture (the arrays own their files). `tiles` are the declared props tile GLBs. Throws the first refusal.
|
|
80
80
|
*/
|
|
@@ -86,7 +86,9 @@ export function validateSplatTerrain(splat: SplatTerrain, context: {
|
|
|
86
86
|
const declared = new Set(context.tiles.flatMap((tile) => files.get(tile)?.dependencies ?? []));
|
|
87
87
|
const elsewhere = new Set([...materialTextureRefs(context.look), ...context.propTextures]), roles = new Map<string, string>();
|
|
88
88
|
for (const set of [splat.layers, ...(splat.phone === undefined ? [] : [splat.phone])]) for (const role of Object.keys(SPLAT_ROLES) as SplatRole[]) for (const [layer, hash] of set[role].entries()) {
|
|
89
|
-
|
|
89
|
+
// SF16 (J525): a layer may be a PNG or JPEG image the cook encodes to its KTX2 `#layer` twin.
|
|
90
|
+
const kind = files.get(hash)?.kind;
|
|
91
|
+
if ((kind !== 'ktx2' && kind !== 'image') || !declared.has(hash)) throw new Error(`props.splat ${role} layer ${layer}: must be a KTX2 or image dependency of a declared props tile`);
|
|
90
92
|
if (elsewhere.has(hash)) throw new Error(`props.splat ${role} layer ${layer}: also bound by another material (the arrays own their files)`);
|
|
91
93
|
const use = SPLAT_ROLES[role], seen = roles.get(hash);
|
|
92
94
|
if (seen !== undefined && seen !== use) throw new Error(`props.splat ${role} layer ${layer}: one texture cannot mix colour and numeric data roles`);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ENGINE_ART } from './engine-art.ts'
|
|
2
|
+
import { issueError } from './issue-codes.ts'
|
|
3
|
+
|
|
4
|
+
import type { CookMount } from './cook-data.ts'
|
|
5
|
+
|
|
6
|
+
const START = 0
|
|
7
|
+
const PATH_ONLY = 1
|
|
8
|
+
|
|
9
|
+
/** Query and fragment suffixes identify the same published asset path. */
|
|
10
|
+
function assetPath(url: string): string {
|
|
11
|
+
return url.split(/[?#]/u, PATH_ONLY)[START] ?? ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function mentionedAssets(values: Iterable<unknown>): Set<string> {
|
|
15
|
+
const found = new Set<string>()
|
|
16
|
+
const pending = [...values]
|
|
17
|
+
while (pending.length > START) {
|
|
18
|
+
const value = pending.pop()
|
|
19
|
+
if (typeof value === 'string' && value.startsWith('/assets/')) {
|
|
20
|
+
found.add(assetPath(value))
|
|
21
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
22
|
+
for (const item of Object.values(value)) {
|
|
23
|
+
pending.push(item)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return found
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function supplied(url: string, mounts: ReadonlySet<string>): boolean {
|
|
31
|
+
return mounts.has(url) || ENGINE_ART.has(url)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The runtime loads the HDR source or the complete baked colour and gain pair. */
|
|
35
|
+
function skyCovered(stem: string, mounts: ReadonlySet<string>): boolean {
|
|
36
|
+
return (
|
|
37
|
+
supplied(`${stem}_2k.hdr`, mounts) ||
|
|
38
|
+
(supplied(`${stem}_2k.sky.jpg`, mounts) &&
|
|
39
|
+
supplied(`${stem}_2k.gain.png`, mounts))
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function covered(url: string, mounts: ReadonlySet<string>): boolean {
|
|
44
|
+
if (
|
|
45
|
+
supplied(url, mounts) ||
|
|
46
|
+
(url.includes('/hdri/') && skyCovered(url, mounts))
|
|
47
|
+
) {
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
const folder = url.endsWith('/') ? url : `${url}/`
|
|
51
|
+
for (const path of mounts) {
|
|
52
|
+
if (path.startsWith(folder)) {
|
|
53
|
+
return true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Both the folder packer and the streaming API validate the same mount table. */
|
|
60
|
+
function assertStandaloneArt(
|
|
61
|
+
values: Iterable<unknown>,
|
|
62
|
+
mounts: readonly Readonly<CookMount>[],
|
|
63
|
+
): void {
|
|
64
|
+
const paths = new Set(
|
|
65
|
+
mounts.map((row: Readonly<CookMount>): string => row.url),
|
|
66
|
+
)
|
|
67
|
+
for (const url of mentionedAssets(values)) {
|
|
68
|
+
if (!covered(url, paths)) {
|
|
69
|
+
throw issueError(
|
|
70
|
+
'cook-invalid',
|
|
71
|
+
`Missing shardfile asset ${url}: include it in the shardfile's mounts`,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Art and authored programs are scoped to the owning shard. Discovery is product metadata. */
|
|
78
|
+
function assertShardMountUrls(
|
|
79
|
+
slug: string,
|
|
80
|
+
mounts: readonly Readonly<CookMount>[],
|
|
81
|
+
): void {
|
|
82
|
+
const prefix = `/assets/${slug}/`
|
|
83
|
+
const program = `/programs/${slug}.json`
|
|
84
|
+
const discovery = `/shardfiles/${slug}/discovery.json`
|
|
85
|
+
const images = `/shardfiles/${slug}/blobs/image/`
|
|
86
|
+
for (const { url, hash } of mounts) {
|
|
87
|
+
const image =
|
|
88
|
+
url.startsWith(images) &&
|
|
89
|
+
['.jpg', '.png', '.webp'].some(
|
|
90
|
+
(suffix): boolean => url === `${images}${hash}${suffix}`,
|
|
91
|
+
)
|
|
92
|
+
if (
|
|
93
|
+
!url.startsWith(prefix) &&
|
|
94
|
+
url !== program &&
|
|
95
|
+
url !== discovery &&
|
|
96
|
+
!image
|
|
97
|
+
) {
|
|
98
|
+
throw issueError(
|
|
99
|
+
'cook-invalid',
|
|
100
|
+
`Shard ${slug} mount ${url} must use ${prefix} or ${program}`,
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function readDiscoveryArt(bytes: Readonly<Uint8Array>): unknown {
|
|
107
|
+
return JSON.parse(new TextDecoder().decode(bytes)) as unknown
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { assertShardMountUrls, assertStandaloneArt, readDiscoveryArt }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// MT3: the operator protocol shared with engine's actorMarkers.json.
|
|
2
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- These probes run in Node.
|
|
3
|
+
import { env } from 'node:process';
|
|
4
|
+
|
|
5
|
+
const AGENT_HEADER = 'x-wildshard-agent';
|
|
6
|
+
const TOKEN = 'WildshardAgent/1';
|
|
7
|
+
const LANE = /^[a-z0-9][a-z0-9._-]{0,63}$/iu;
|
|
8
|
+
|
|
9
|
+
function agentLane() {
|
|
10
|
+
/** @type {unknown} */
|
|
11
|
+
const environment = env;
|
|
12
|
+
const lane = typeof environment === 'object' && environment !== null && 'WS_LANE_NAME' in environment
|
|
13
|
+
? environment.WS_LANE_NAME
|
|
14
|
+
: undefined;
|
|
15
|
+
return typeof lane === 'string' && LANE.test(lane) ? lane : '1';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @param {string} base */
|
|
19
|
+
function agentUserAgent(base) {
|
|
20
|
+
if (base.split(/\s+/u).includes(TOKEN)) {
|
|
21
|
+
return base;
|
|
22
|
+
}
|
|
23
|
+
const lane = agentLane();
|
|
24
|
+
const marker = lane === '1' ? TOKEN : `${TOKEN} (${lane})`;
|
|
25
|
+
return `${base.trim()} ${marker}`.trim();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @param {string} input */
|
|
29
|
+
function gameAddress(input) {
|
|
30
|
+
if (!URL.canParse(input)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const host = new URL(input).hostname;
|
|
34
|
+
return host === 'wildshard.io' || host.endsWith('.wildshard.io') || host === 'localhost' || host === '127.0.0.1' || host === '[::1]';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @param {typeof fetch} read @returns {typeof fetch} */
|
|
38
|
+
function markedFetch(read) {
|
|
39
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- Preserve the platform Fetch signature.
|
|
40
|
+
return async (input, options) => {
|
|
41
|
+
const request = input instanceof Request ? input : undefined;
|
|
42
|
+
const address = request?.url ?? (input instanceof URL ? input.href : input);
|
|
43
|
+
if (typeof address !== 'string' || !gameAddress(address)) {
|
|
44
|
+
return await read(input, options);
|
|
45
|
+
}
|
|
46
|
+
const headers = new Headers(options?.headers ?? request?.headers);
|
|
47
|
+
headers.set(AGENT_HEADER, agentLane());
|
|
48
|
+
headers.set('user-agent', agentUserAgent(headers.get('user-agent') ?? 'node'));
|
|
49
|
+
return await read(input, { ...options, headers });
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @type {typeof fetch} */
|
|
54
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- Preserve the platform Fetch signature.
|
|
55
|
+
const agentFetch = async (input, options) => await markedFetch(globalThis.fetch)(input, options);
|
|
56
|
+
|
|
57
|
+
export { AGENT_HEADER, agentFetch, agentUserAgent, markedFetch };
|