@wildshard/shard-format 0.82.2 → 0.82.3
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.82.
|
|
3
|
+
"version": "0.82.3",
|
|
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": {
|
|
@@ -203,6 +203,24 @@ function mountedImageBytes(path: string, bytes: Readonly<Uint8Array>): number {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
/** The phone loader substitutes a known `.phone.webp` mount for its desktop
|
|
207
|
+
* image. A direct read in the prepared phone fence still counts. */
|
|
208
|
+
function mountedImageOnPhone(
|
|
209
|
+
mount: Readonly<{ url: string; hash: string; keepImage?: boolean }>,
|
|
210
|
+
urls: ReadonlySet<string>,
|
|
211
|
+
phoneFence?: ReadonlySet<string>,
|
|
212
|
+
): boolean {
|
|
213
|
+
if (
|
|
214
|
+
phoneFence === undefined ||
|
|
215
|
+
phoneFence.has(mount.hash) ||
|
|
216
|
+
mount.keepImage === true
|
|
217
|
+
) {
|
|
218
|
+
return true
|
|
219
|
+
}
|
|
220
|
+
const phone = mount.url.replace(/\.(?:png|jpg|webp)$/u, '.phone.webp')
|
|
221
|
+
return phone === mount.url || !urls.has(phone)
|
|
222
|
+
}
|
|
223
|
+
|
|
206
224
|
/** MG6 epoch 4: the phone's playing (settled) and loading-peak estimates of a product's terms. */
|
|
207
225
|
function bootPhoneBytes(
|
|
208
226
|
terms: Readonly<PhoneTerms>,
|
|
@@ -261,6 +279,7 @@ export {
|
|
|
261
279
|
bootMemoryCosts,
|
|
262
280
|
bootPhoneBytes,
|
|
263
281
|
mountedImageBytes,
|
|
282
|
+
mountedImageOnPhone,
|
|
264
283
|
NO_BYTES,
|
|
265
284
|
type PhoneTerms,
|
|
266
285
|
phoneTerms,
|
package/src/format/engine-art.ts
CHANGED
|
@@ -38,6 +38,9 @@ export const ENGINE_ART: ReadonlySet<string> = new Set([
|
|
|
38
38
|
'/assets/music/piano/sting-death-8ee9ff5d.m4a',
|
|
39
39
|
'/assets/music/piano/sting-pickup-5ba19a30.m4a',
|
|
40
40
|
'/assets/music/piano/title-7ce82663.m4a',
|
|
41
|
+
// The engine's build copies the physics binary here (engine vite/rapier.ts); it is gitignored, so not in SF1's list.
|
|
42
|
+
// A shard's boot rows name it through the SDK's sharedBootPhysics (opus-pine, Pine Hollow's shardVersion build).
|
|
43
|
+
'/assets/physics/rapier.wasm',
|
|
41
44
|
'/assets/practice/dummies/straw-cloth.glb',
|
|
42
45
|
'/assets/practice/dummies/unimate-motion.glb',
|
|
43
46
|
'/assets/practice/dummies/wood-steel.glb',
|
|
@@ -8,6 +8,7 @@ const names: v.GenericSchema<string[], string[]> & { readonly pipe: readonly [un
|
|
|
8
8
|
v.check(rows => new Set(rows).size === rows.length));
|
|
9
9
|
const count = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(4096));
|
|
10
10
|
const bounded = <T extends v.GenericSchema>(schema: T, max: number) => v.pipe(v.array(schema), v.maxLength(max));
|
|
11
|
+
const imageExtension = v.exactOptional(v.picklist(['webp', 'png']));
|
|
11
12
|
/** G475 held arms drawn in graph looks: a skinned rig played by the shared arm player (its blade row is the hit sweep's
|
|
12
13
|
* and the swing trail's), its meshes dressed from rows, the trail sampled along the blade during each swing, and the
|
|
13
14
|
* per-frame look writes as named sources. Client-only presentation; ids only, no callbacks. */
|
|
@@ -23,8 +24,8 @@ export const GraphArmsSchema: v.StrictObjectSchema<{ readonly rig: v.GenericSche
|
|
|
23
24
|
/** every look's params, by look id; a frame source with no look writes each look that declares its param */
|
|
24
25
|
params: v.record(name, bounded(name, 128)),
|
|
25
26
|
meshes: bounded(v.strictObject({ name, channels: v.record(name, name), look: name, maps: v.exactOptional(name), hull: v.boolean(), doubleSide: v.boolean() }), 64),
|
|
26
|
-
/**
|
|
27
|
-
maps: v.strictObject({ base: name, names, kinds: v.strictObject({ maps: name, nrm: name }), anisotropy: finite }),
|
|
27
|
+
/** Per-mesh map pairs at `<base><name>-<kind>.<imageExtension>`, WebP for existing rows. */
|
|
28
|
+
maps: v.strictObject({ base: name, names, kinds: v.strictObject({ maps: name, nrm: name }), anisotropy: finite, imageExtension }),
|
|
28
29
|
/** an R8 repeating weave and per-tier lossless decal images, all named product files */
|
|
29
30
|
weave: v.strictObject({ file: name, size: count, param: name }),
|
|
30
31
|
decal: v.strictObject({ files: v.strictObject({ phone: name, desktop: name }), param: name }),
|
|
@@ -89,6 +90,7 @@ interface GraphArmsRowInputFields {
|
|
|
89
90
|
nrm: string;
|
|
90
91
|
};
|
|
91
92
|
anisotropy: number;
|
|
93
|
+
imageExtension?: 'webp' | 'png';
|
|
92
94
|
};
|
|
93
95
|
weave: {
|
|
94
96
|
file: string;
|
|
@@ -168,6 +170,7 @@ interface GraphArmsRowFields {
|
|
|
168
170
|
nrm: string;
|
|
169
171
|
};
|
|
170
172
|
anisotropy: number;
|
|
173
|
+
imageExtension?: 'webp' | 'png';
|
|
171
174
|
};
|
|
172
175
|
weave: {
|
|
173
176
|
file: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assertShardMountUrls, assertStandaloneArt, readDiscoveryArt } from './standalone-art.ts';
|
|
2
2
|
import { cookMountPath, readCookData } from './cook-data.ts';
|
|
3
|
+
import type { CookData, CookMount } from './cook-data.ts';
|
|
3
4
|
import { checkDiscoveryMount, isDiscoveryMount } from './manifest-deprecations.ts';
|
|
4
|
-
import { requireCookPreparation } from './cook-preparation.ts';
|
|
5
|
+
import { isPreparedCook, requireCookPreparation } from './cook-preparation.ts';
|
|
5
6
|
import { declaredSourceMatches, parseIncomingIndex, validateIncomingSection } from './incoming.ts';
|
|
6
7
|
import { assembleOutputShardfile, type OutputFile, type OutputIndex } from './outputIndex.ts';
|
|
7
8
|
import { decisionModuleContracts, scriptAdmissionRows, type ScriptAdmissionRows, type ScriptContract } from './scriptContract.ts';
|
|
@@ -28,7 +29,7 @@ import { memoryContext, offlineMemoryIssues } from './memory-line.ts';
|
|
|
28
29
|
import { armedZone } from './memory-armed.ts';
|
|
29
30
|
import { runtimeTierIssues } from './runtime-tier.ts';
|
|
30
31
|
import type { MemoryContext } from './memory-line.ts';
|
|
31
|
-
import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
|
|
32
|
+
import { mountedImageBytes, mountedImageOnPhone, NO_BYTES } from './boot-memory-cost.ts';
|
|
32
33
|
import { admittedVerdict, policyVerdict, recordVerdict } from './policy-verdict.ts';
|
|
33
34
|
import type { Judged, PolicyVerdict } from './policy-verdict.ts';
|
|
34
35
|
import { deprecationReport } from './deprecations.ts';
|
|
@@ -210,21 +211,34 @@ function checkServerAndKtx2(index: OutputIndex, read: ReadListed, assets: Readon
|
|
|
210
211
|
});
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
type MountInventory = Readonly<{ formatVersion: OutputIndex['formatVersion']; files: readonly Readonly<Pick<OutputFile, 'hash' | 'path' | 'compressed'>>[] }>;
|
|
215
|
+
|
|
216
|
+
/** C0 (J137): verify every cook mount, even a desktop image the phone never requests. */
|
|
217
|
+
function checkedMountImageBytes(index: MountInventory, mount: Readonly<CookMount>, options: Readonly<{ read: ReadListed; onPhone: boolean }>): number {
|
|
218
|
+
if (mountSharesBlob(mount, index.files)) { return NO_BYTES; }
|
|
219
|
+
if (mount.path !== cookMountPath(mount.url)) { throw new Error(`Mount path differs from its URL: ${mount.url}`); }
|
|
220
|
+
const bytes = checkDiscoveryMount(index.formatVersion, mount.path, options.read(mount));
|
|
221
|
+
return options.onPhone ? mountedImageBytes(mount.path, bytes) : NO_BYTES;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function checkedMountImages(index: MountInventory, read: ReadListed, cook: CookData | undefined): number {
|
|
225
|
+
const mounts = cook?.mounts ?? [];
|
|
226
|
+
const urls = new Set(mounts.map((mount): string => mount.url));
|
|
227
|
+
const phoneFence = isPreparedCook(cook) && cook?.fence !== undefined ? new Set(cook.fence) : undefined;
|
|
228
|
+
let mountedImages = NO_BYTES;
|
|
229
|
+
for (const mount of mounts) {
|
|
230
|
+
mountedImages += checkedMountImageBytes(index, mount, { read, onPhone: mountedImageOnPhone(mount, urls, phoneFence) });
|
|
231
|
+
}
|
|
232
|
+
return mountedImages;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The cook file and the mounted engine images measured alongside its own images. */
|
|
214
236
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
|
|
215
237
|
function readCook(index: OutputIndex, read: ReadListed, ports: Pick<ShardfileValidationPorts, 'hash' | 'preparation'>): { cook: ReturnType<typeof readCookData> | undefined; mountedImages: number } {
|
|
216
238
|
return coded('cook-invalid', (): { cook: ReturnType<typeof readCookData> | undefined; mountedImages: number } => {
|
|
217
239
|
const cook = index.cook === undefined ? undefined : readCookData(readCanonicalJson(read(index.cook)));
|
|
218
240
|
if (ports.preparation !== 'migrated') { coded('preparation-invalid', (): void => { requireCookPreparation(index, cook, ports.hash); }); }
|
|
219
|
-
|
|
220
|
-
for (const mount of cook?.mounts ?? []) {
|
|
221
|
-
if (!mountSharesBlob(mount, index.files)) {
|
|
222
|
-
if (mount.path !== cookMountPath(mount.url)) { throw new Error(`Mount path differs from its URL: ${mount.url}`); }
|
|
223
|
-
// MG6 epoch 3: the engine images a shard mounts decode at boot like its own (Far Reach's sky and textures).
|
|
224
|
-
mountedImages += mountedImageBytes(mount.path, checkDiscoveryMount(index.formatVersion, mount.path, read(mount)));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return { cook, mountedImages };
|
|
241
|
+
return { cook, mountedImages: checkedMountImages(index, read, cook) };
|
|
228
242
|
});
|
|
229
243
|
}
|
|
230
244
|
|
|
@@ -40,7 +40,29 @@ function skyCovered(stem: string, mounts: ReadonlySet<string>): boolean {
|
|
|
40
40
|
)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/** A URL template (`/assets/z/hdri/{id}_2k.key.jpg`, a keyed sky's files) names at least one supplied file. */
|
|
44
|
+
function templateCovered(url: string, mounts: ReadonlySet<string>): boolean {
|
|
45
|
+
const pattern = new RegExp(
|
|
46
|
+
`^${url
|
|
47
|
+
.split(/\{[a-z][a-zA-Z0-9]*\}/u)
|
|
48
|
+
.map((part: string): string =>
|
|
49
|
+
part.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`),
|
|
50
|
+
)
|
|
51
|
+
.join('[^/]+')}$`,
|
|
52
|
+
'u',
|
|
53
|
+
)
|
|
54
|
+
for (const path of [...mounts, ...ENGINE_ART]) {
|
|
55
|
+
if (pattern.test(path)) {
|
|
56
|
+
return true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
function covered(url: string, mounts: ReadonlySet<string>): boolean {
|
|
63
|
+
if (/\{[a-z][a-zA-Z0-9]*\}/u.test(url)) {
|
|
64
|
+
return templateCovered(url, mounts)
|
|
65
|
+
}
|
|
44
66
|
if (
|
|
45
67
|
supplied(url, mounts) ||
|
|
46
68
|
(url.includes('/hdri/') && skyCovered(url, mounts))
|