@wildshard/shard-format 0.69.2 → 0.71.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.
Files changed (73) hide show
  1. package/package.json +21 -3
  2. package/src/cli/corpus-candidate.ts +228 -0
  3. package/src/cli/corpus-command.ts +67 -0
  4. package/src/cli/corpus-pins.ts +73 -0
  5. package/src/cli/corpus-report.ts +36 -0
  6. package/src/cli/corpus-tar.ts +28 -0
  7. package/src/cli/corpus-usage.ts +106 -0
  8. package/src/cli/corpus.ts +50 -68
  9. package/src/cli/format-diff-data.ts +89 -0
  10. package/src/cli/format-diff-lock.ts +122 -0
  11. package/src/cli/format-diff-normal.ts +300 -0
  12. package/src/cli/format-diff-paths.ts +103 -0
  13. package/src/cli/format-diff-range.ts +112 -0
  14. package/src/cli/format-diff-report.ts +30 -0
  15. package/src/cli/format-diff-rules.ts +232 -0
  16. package/src/cli/format-diff.ts +226 -0
  17. package/src/cli/main.ts +81 -32
  18. package/src/cli/pack.ts +20 -3
  19. package/src/cli/validate.ts +1 -1
  20. package/src/format/clientOwnership.ts +1 -1
  21. package/src/format/clientTrails.ts +121 -46
  22. package/src/format/cook-data.ts +22 -3
  23. package/src/format/cook-deprecations.ts +53 -0
  24. package/src/format/cook-preparation.ts +105 -70
  25. package/src/format/creature-rest-rig.ts +248 -0
  26. package/src/format/creature-skin-bounds.ts +146 -0
  27. package/src/format/deprecations.ts +30 -21
  28. package/src/format/edge-observations.ts +67 -0
  29. package/src/format/empty-shardfile.ts +4 -2
  30. package/src/format/entry-read-set.ts +147 -0
  31. package/src/format/format-migrate-rebuild.ts +4 -1
  32. package/src/format/format-migrate.ts +10 -5
  33. package/src/format/format-migration-envelope.ts +40 -0
  34. package/src/format/format-migration-prune.ts +42 -1
  35. package/src/format/format-migrations.ts +10 -1
  36. package/src/format/format-window.ts +71 -0
  37. package/src/format/immutable.ts +4 -1
  38. package/src/format/json-schema.ts +1468 -0
  39. package/src/format/lootEconomy.ts +4 -1
  40. package/src/format/mat4.ts +225 -0
  41. package/src/format/memory-armed.json +1 -9
  42. package/src/format/memory-armed.ts +46 -17
  43. package/src/format/memory-epoch.ts +10 -3
  44. package/src/format/memory-line.ts +17 -6
  45. package/src/format/outputFields.ts +3 -2
  46. package/src/format/outputIndex.ts +41 -6
  47. package/src/format/platformDataSections.ts +5 -0
  48. package/src/format/platformFileFamilies.ts +3 -3
  49. package/src/format/play-area.ts +95 -0
  50. package/src/format/policy-verdict.ts +12 -2
  51. package/src/format/preparation-checks.ts +100 -0
  52. package/src/format/preparation-spec.ts +45 -0
  53. package/src/format/registeredJson.ts +2 -2
  54. package/src/format/runtime-tier.ts +14 -7
  55. package/src/format/save-revision.ts +105 -0
  56. package/src/format/schema-source.ts +70 -0
  57. package/src/format/sections.ts +4 -1
  58. package/src/format/server-plan.ts +42 -0
  59. package/src/format/server-reads.ts +23 -0
  60. package/src/format/shardSchema.ts +9 -4
  61. package/src/format/shardSections.ts +17 -7
  62. package/src/format/shardfile-assets.ts +5 -5
  63. package/src/format/shardfile-stream-admit.ts +19 -10
  64. package/src/format/shardfile-stream-facts.ts +2 -1
  65. package/src/format/shardfile-stream.ts +2 -3
  66. package/src/format/shardfileValidation.ts +16 -9
  67. package/src/format/species-deprecations.ts +79 -0
  68. package/src/format/stateLineage.ts +15 -7
  69. package/src/format/tread-boxes.ts +65 -0
  70. package/src/format/vehicle-hulls.ts +124 -0
  71. package/src/format/version.ts +96 -10
  72. package/src/format/whole-inputs.ts +51 -0
  73. package/src/tools/runtime-hosts.json +4 -0
@@ -0,0 +1,65 @@
1
+ /* oxlint-disable id-length, import/group-exports, max-statements, no-magic-numbers, no-plusplus -- a port of engine's treadBoxes kept term for term (SHARD-COMPAT PR6b), so the boxes match engine's byte for byte */
2
+ // SHARD-COMPAT PR6b (J487): a stair's `treads` collider as the solid boxes physics installs, one per tread from the
3
+ // stair's foot up to that tread's top, with format code only. Moved from engine
4
+ // `src/shared/engine/physics/pieces.ts` `treadBoxes`; the material (surface, friction, groups) rides on every box.
5
+
6
+ interface Point {
7
+ readonly x: number
8
+ readonly y: number
9
+ readonly z: number
10
+ }
11
+
12
+ /** A `treads` shape as props declare it, with whatever contact fields it carries. */
13
+ export interface TreadShape {
14
+ readonly from: Point
15
+ readonly to: Point
16
+ readonly width: number
17
+ readonly count: number
18
+ readonly surface?: string
19
+ readonly friction?: number
20
+ readonly groups?: number
21
+ }
22
+
23
+ /** One tread's solid block: centre, half extents and yaw, plus the stair's material. */
24
+ export interface TreadBox {
25
+ readonly kind: 'box'
26
+ readonly x: number
27
+ readonly y: number
28
+ readonly z: number
29
+ readonly hx: number
30
+ readonly hy: number
31
+ readonly hz: number
32
+ readonly yaw: number
33
+ readonly surface?: string
34
+ readonly friction?: number
35
+ readonly groups?: number
36
+ }
37
+
38
+ /** One tread of a stair: a solid block from the stair's foot up to this tread's top. */
39
+ export function treadBoxes(d: TreadShape): TreadBox[] {
40
+ const dx = d.to.x - d.from.x
41
+ const dz = d.to.z - d.from.z
42
+ const run = Math.hypot(dx, dz) / d.count
43
+ const rise = (d.to.y - d.from.y) / d.count
44
+ const yaw = Math.atan2(dx, dz)
45
+ const out: TreadBox[] = []
46
+ for (let i = 0; i < d.count; i++) {
47
+ const f = (i + 0.5) / d.count
48
+ const top = d.from.y + rise * (i + 1)
49
+ const hy = Math.max(0.01, (top - d.from.y) / 2)
50
+ out.push({
51
+ kind: 'box',
52
+ x: d.from.x + dx * f,
53
+ y: d.from.y + hy,
54
+ z: d.from.z + dz * f,
55
+ hx: d.width / 2,
56
+ hy,
57
+ hz: run / 2,
58
+ yaw,
59
+ ...(d.surface === undefined ? {} : { surface: d.surface }),
60
+ ...(d.friction === undefined ? {} : { friction: d.friction }),
61
+ ...(d.groups === undefined ? {} : { groups: d.groups }),
62
+ })
63
+ }
64
+ return out
65
+ }
@@ -0,0 +1,124 @@
1
+ /* oxlint-disable capitalized-comments, id-length, max-lines-per-function, no-continue, no-implicit-coercion, no-magic-numbers, oxc/erasing-op, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/prefer-modern-math-apis -- three.js 0.186's Quaternion and Vector3 steps ported term for term (SHARD-COMPAT PR6b), so the hulls match engine's byte for byte */
2
+ // SHARD-COMPAT PR6b (J487): each steer vehicle's hull as boxes in its own frame, from the shard's movers and prop
3
+ // colliders with format code only, so the MMO server builds vehicle bodies without engine code. Moved from engine
4
+ // `src/shared/game/shardfile/vehicleHulls.ts` (SHARD-SOURCE SS-GP5). The format keeps a carry `channel` row box-free,
5
+ // so a vehicle's solids are its panel's collider rows (`props.colliders` whose `panel` is the vehicle's id), written in
6
+ // the cell's frame at its rest; here they turn into the vehicle's frame (about its rest, YXZ). A tread shape is no
7
+ // hull; at most 128 boxes, as a mover holds.
8
+ import type { MoverBox } from './mover-pose.ts'
9
+ import type { Shardfile } from './shardSchema.ts'
10
+
11
+ const MAX_BOXES = 128
12
+
13
+ /** A quaternion as x, y, z, w. */
14
+ type Quat = readonly [number, number, number, number]
15
+
16
+ /** three's `setFromEuler` for order YXZ. */
17
+ function fromEulerYXZ(x: number, y: number, z: number): Quat {
18
+ const c1 = Math.cos(x / 2)
19
+ const c2 = Math.cos(y / 2)
20
+ const c3 = Math.cos(z / 2)
21
+ const s1 = Math.sin(x / 2)
22
+ const s2 = Math.sin(y / 2)
23
+ const s3 = Math.sin(z / 2)
24
+ return [
25
+ s1 * c2 * c3 + c1 * s2 * s3,
26
+ c1 * s2 * c3 - s1 * c2 * s3,
27
+ c1 * c2 * s3 - s1 * s2 * c3,
28
+ c1 * c2 * c3 + s1 * s2 * s3,
29
+ ]
30
+ }
31
+
32
+ /** three's `multiplyQuaternions(a, b)`. */
33
+ function multiply(a: Quat, b: Quat): Quat {
34
+ const [qax, qay, qaz, qaw] = a
35
+ const [qbx, qby, qbz, qbw] = b
36
+ return [
37
+ qax * qbw + qaw * qbx + qay * qbz - qaz * qby,
38
+ qay * qbw + qaw * qby + qaz * qbx - qax * qbz,
39
+ qaz * qbw + qaw * qbz + qax * qby - qay * qbx,
40
+ qaw * qbw - qax * qbx - qay * qby - qaz * qbz,
41
+ ]
42
+ }
43
+
44
+ /** three's `normalize`: a zero quaternion becomes the identity. */
45
+ function normalize(q: Quat): Quat {
46
+ const [x, y, z, w] = q
47
+ const length = Math.sqrt(x * x + y * y + z * z + w * w)
48
+ if (length === 0) {
49
+ return [0, 0, 0, 1]
50
+ }
51
+ const inverse = 1 / length
52
+ return [x * inverse, y * inverse, z * inverse, w * inverse]
53
+ }
54
+
55
+ /** three's `Vector3.applyQuaternion`. */
56
+ function rotate(
57
+ v: readonly [number, number, number],
58
+ q: Quat,
59
+ ): readonly [number, number, number] {
60
+ const [vx, vy, vz] = v
61
+ const [qx, qy, qz, qw] = q
62
+ const tx = 2 * (qy * vz - qz * vy)
63
+ const ty = 2 * (qz * vx - qx * vz)
64
+ const tz = 2 * (qx * vy - qy * vx)
65
+ return [
66
+ vx + qw * tx + qy * tz - qz * ty,
67
+ vy + qw * ty + qz * tx - qx * tz,
68
+ vz + qw * tz + qx * ty - qy * tx,
69
+ ]
70
+ }
71
+
72
+ /** Each steer vehicle's hull, as boxes in its own frame (about its rest, YXZ), by mover id. */
73
+ export function vehicleHulls(
74
+ source: Pick<Shardfile, 'movers'> & Partial<Pick<Shardfile, 'props'>>,
75
+ ): ReadonlyMap<string, readonly MoverBox[]> {
76
+ const hulls = new Map<string, readonly MoverBox[]>()
77
+ for (const row of source.movers) {
78
+ if (row.kind !== 'channel' || row.driver?.kind !== 'steer') {
79
+ continue
80
+ }
81
+ const [ex, ey, ez, ew] = fromEulerYXZ(row.euler.x, row.euler.y, row.euler.z)
82
+ // three's `invert` of a unit quaternion is its conjugate.
83
+ const back: Quat = [-ex, -ey, -ez, ew]
84
+ const boxes = (source.props?.colliders ?? [])
85
+ .filter(solid => solid.panel === row.id)
86
+ .flatMap(solid => solid.shapes)
87
+ .flatMap((shape): MoverBox[] => {
88
+ if (shape.kind !== 'box') {
89
+ return []
90
+ }
91
+ const [x, y, z] = rotate(
92
+ [shape.x - row.at.x, shape.y - row.at.y, shape.z - row.at.z],
93
+ back,
94
+ )
95
+ const half = (shape.yaw ?? 0) / 2
96
+ const turn: Quat =
97
+ shape.rot === undefined
98
+ ? [
99
+ 0 * Math.sin(half),
100
+ 1 * Math.sin(half),
101
+ 0 * Math.sin(half),
102
+ Math.cos(half),
103
+ ]
104
+ : [shape.rot.x, shape.rot.y, shape.rot.z, shape.rot.w]
105
+ const [rx, ry, rz, rw] = normalize(multiply(back, turn))
106
+ return [
107
+ {
108
+ x,
109
+ y,
110
+ z,
111
+ hx: shape.hx,
112
+ hy: shape.hy,
113
+ hz: shape.hz,
114
+ rot: { x: rx, y: ry, z: rz, w: rw },
115
+ },
116
+ ]
117
+ })
118
+ .slice(0, MAX_BOXES)
119
+ if (boxes.length > 0) {
120
+ hulls.set(row.id, boxes)
121
+ }
122
+ }
123
+ return hulls
124
+ }
@@ -1,9 +1,11 @@
1
- /** Canonical format revision, separate from the npm package and script ABI (J319).
1
+ import { LEGACY_PREPARATION_SPEC, PREPARED_SDK } from './preparation-spec.ts'
2
+
3
+ /** Canonical format version, separate from the npm package and script ABI (J319).
2
4
  * The fourth component adds fields; the third changes their meaning. */
3
5
  const ZERO = 0
4
6
  const ONE = 1
5
7
 
6
- const SHARDFILE_VERSION = '0.1.0.2'
8
+ const SHARDFILE_VERSION = '0.1.0.4'
7
9
  /** Formats whose `shard.json` names its version in `version`, beside the frozen layout marker `formatVersion: 2`.
8
10
  * Legacy 0.1 is the byte-preserving spelling of 0.1.0.0. */
9
11
  const LEGACY_INDEX_VERSIONS: readonly ['0.1', '0.1.0.0', '0.1.0.1'] = [
@@ -13,24 +15,38 @@ const LEGACY_INDEX_VERSIONS: readonly ['0.1', '0.1.0.0', '0.1.0.1'] = [
13
15
  ] as const
14
16
  /** Formats whose `shard.json` names its version in `formatVersion` (SHARD-COMPAT CP14, FORMAT-PRUNE FP25): the
15
17
  * layout marker and `version` are gone, so a reader tells the two envelopes apart by the field's type. */
16
- const INDEX_FORMAT_VERSIONS: readonly [typeof SHARDFILE_VERSION] = [
17
- SHARDFILE_VERSION,
18
- ] as const
18
+ const INDEX_FORMAT_VERSIONS: readonly [
19
+ '0.1.0.2',
20
+ '0.1.0.3',
21
+ typeof SHARDFILE_VERSION,
22
+ ] = ['0.1.0.2', '0.1.0.3', SHARDFILE_VERSION] as const
19
23
  const SHARDFILE_VERSIONS: readonly [
20
24
  ...typeof LEGACY_INDEX_VERSIONS,
21
25
  ...typeof INDEX_FORMAT_VERSIONS,
22
26
  ] = [...LEGACY_INDEX_VERSIONS, ...INDEX_FORMAT_VERSIONS] as const
23
- type ShardfileVersion = (typeof SHARDFILE_VERSIONS)[number]
27
+ /** A format version (J319): the four-part number naming a shard file's shape (SHARD-COMPAT §2's word). */
28
+ type FormatVersion = (typeof SHARDFILE_VERSIONS)[number]
29
+ /** @deprecated SHARD-COMPAT SP10: the retired word; use `FormatVersion`. Kept until no consumer imports it (ST19). */
30
+ type ShardfileVersion = FormatVersion
24
31
  type LegacyIndexVersion = (typeof LEGACY_INDEX_VERSIONS)[number]
25
32
  type IndexFormatVersion = (typeof INDEX_FORMAT_VERSIONS)[number]
26
33
  /** The frozen layout marker the legacy envelope carries in `formatVersion`. */
27
34
  const LEGACY_LAYOUT = 2
28
35
  /** The first format that writes its version in `formatVersion`. */
29
36
  const SHARDFILE_VERSION_INDEX_RENAME = '0.1.0.2'
30
- type ShardfileVersionParts = readonly [number, number, number, number]
37
+ /** The first format whose `shard.json` records the preparation spec version in `preparation` instead of the `sdk`
38
+ * marker (SHARD-COMPAT PR4, J487; FORMAT-PRUNE FP5 folded in). */
39
+ const SHARDFILE_VERSION_PREPARATION = '0.1.0.3'
40
+ /** The first format whose `shard.json` names the save lineage `identity.saveRevision` instead of `identity.revision`
41
+ * (FORMAT-PRUNE FP26, J493): the number keys saves and only ever rises; it is not the API's shard revision. */
42
+ const SHARDFILE_VERSION_SAVE_REVISION = '0.1.0.4'
43
+ /** A format version's four parts. */
44
+ type FormatVersionParts = readonly [number, number, number, number]
45
+ /** @deprecated SHARD-COMPAT SP10: use `FormatVersionParts`. */
46
+ type ShardfileVersionParts = FormatVersionParts
31
47
 
32
48
  /** Read canonical bounded decimal components; the legacy two-part spelling has zero counters. */
33
- function parseShardfileVersion(input: unknown): ShardfileVersionParts {
49
+ function parseShardfileVersion(input: unknown): FormatVersionParts {
34
50
  if (
35
51
  typeof input !== 'string' ||
36
52
  !/^(?:0|[1-9][0-9]{0,3})(?:\.(?:0|[1-9][0-9]{0,3}))(?:\.(?:0|[1-9][0-9]{0,3})\.(?:0|[1-9][0-9]{0,3}))?$/u.test(
@@ -85,7 +101,7 @@ function compatibleShardfileVersion(
85
101
 
86
102
  /** The format version a `shard.json` declares: `formatVersion` when it is a version string (0.1.0.2 on), else the
87
103
  * legacy `version` beside the layout marker `formatVersion: 2`. Throws when neither names a format. */
88
- function shardfileFormatOf(index: unknown): ShardfileVersion {
104
+ function shardfileFormatOf(index: unknown): FormatVersion {
89
105
  const declared: unknown =
90
106
  typeof index === 'object' && index !== null
91
107
  ? Reflect.get(index, 'formatVersion')
@@ -111,6 +127,60 @@ function writesIndexFormatVersion(version: string): boolean {
111
127
  )
112
128
  }
113
129
 
130
+ /** Whether a format version records `preparation` in place of the `sdk` marker (0.1.0.3 on, PR4). */
131
+ function writesPreparationMarker(version: string): boolean {
132
+ return (
133
+ compareShardfileVersions(version, SHARDFILE_VERSION_PREPARATION) >= ZERO
134
+ )
135
+ }
136
+
137
+ /** Whether a format version names the save lineage `identity.saveRevision` (0.1.0.4 on, FP26). */
138
+ function writesSaveRevision(version: string): boolean {
139
+ return (
140
+ compareShardfileVersions(version, SHARDFILE_VERSION_SAVE_REVISION) >= ZERO
141
+ )
142
+ }
143
+
144
+ /** FP26: a copy of an identity row with `revision` spelled `saveRevision`; anything else as it is. */
145
+ function withSaveRevision(identity: unknown): unknown {
146
+ if (
147
+ typeof identity !== 'object' ||
148
+ identity === null ||
149
+ Array.isArray(identity) ||
150
+ !Object.hasOwn(identity, 'revision')
151
+ ) {
152
+ return identity
153
+ }
154
+ const renamed = Object.entries(identity).map(
155
+ ([key, item]: readonly [string, unknown]): readonly [string, unknown] => [
156
+ key === 'revision' ? 'saveRevision' : key,
157
+ item,
158
+ ],
159
+ )
160
+ return Object.fromEntries(renamed)
161
+ }
162
+
163
+ /** The rows a version from 0.1.0.3 on changes in place: PR4's preparation marker, then FP26's save lineage. */
164
+ function laterEnvelopeRows(
165
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- it changes the writer's envelope in place
166
+ envelope: Record<string, unknown>,
167
+ version: string,
168
+ ): void {
169
+ // SHARD-COMPAT PR4: from 0.1.0.3 the `sdk` marker goes; a prepared writer's `'0.3'` becomes the spec version it
170
+ // meant, unless the writer already names one in `preparation`.
171
+ if (writesPreparationMarker(version)) {
172
+ const { sdk } = envelope
173
+ Reflect.deleteProperty(envelope, 'sdk')
174
+ if (sdk === PREPARED_SDK && envelope['preparation'] === undefined) {
175
+ envelope['preparation'] = LEGACY_PREPARATION_SPEC
176
+ }
177
+ }
178
+ // FORMAT-PRUNE FP26: from 0.1.0.4 the save lineage is `identity.saveRevision`.
179
+ if (writesSaveRevision(version)) {
180
+ envelope['identity'] = withSaveRevision(envelope['identity'])
181
+ }
182
+ }
183
+
114
184
  /** A copy of a JSON object without `keys`; anything else as it is. */
115
185
  function withoutKeys(value: unknown, keys: readonly string[]): unknown {
116
186
  if (typeof value !== 'object' || value === null || Array.isArray(value)) {
@@ -125,11 +195,16 @@ function withoutKeys(value: unknown, keys: readonly string[]): unknown {
125
195
 
126
196
  /** The rows `outputIndexEnvelope` returns: the writer's own rows, typed so it keeps reading them, with `version` and
127
197
  * `schemas` possibly gone and `formatVersion` possibly the version string. */
128
- type IndexEnvelope<Rows> = Omit<Rows, 'formatVersion' | 'schemas' | 'version'> &
198
+ type IndexEnvelope<Rows> = Omit<
199
+ Rows,
200
+ 'formatVersion' | 'schemas' | 'version' | 'sdk'
201
+ > &
129
202
  Readonly<{
130
203
  formatVersion: unknown
131
204
  version?: unknown
132
205
  schemas?: unknown
206
+ sdk?: unknown
207
+ preparation?: unknown
133
208
  }>
134
209
 
135
210
  /** SHARD-COMPAT CP14: writers build the legacy `shard.json` rows (`formatVersion: 2`, `version`, the always-empty lists)
@@ -149,6 +224,9 @@ function outputIndexEnvelope<Rows extends Readonly<Record<string, unknown>>>(
149
224
  formatVersion: version,
150
225
  runtime: withoutKeys(rest['runtime'], ['files', 'lines', 'trust']),
151
226
  }
227
+ if (typeof version === 'string') {
228
+ laterEnvelopeRows(envelope, version)
229
+ }
152
230
  // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the writer's own rows; only envelope fields change
153
231
  return envelope as IndexEnvelope<Rows>
154
232
  }
@@ -165,8 +243,16 @@ export {
165
243
  type IndexFormatVersion,
166
244
  shardfileFormatOf,
167
245
  writesIndexFormatVersion,
246
+ writesPreparationMarker,
247
+ writesSaveRevision,
248
+ SHARDFILE_VERSION_PREPARATION,
249
+ SHARDFILE_VERSION_SAVE_REVISION,
168
250
  SHARDFILE_FLOOR,
251
+ type FormatVersion,
252
+ type FormatVersionParts,
253
+ // oxlint-disable-next-line typescript/no-deprecated -- SP10: the old name stays exported as an alias until no consumer imports it (ST19).
169
254
  type ShardfileVersion,
255
+ // oxlint-disable-next-line typescript/no-deprecated -- SP10: as above.
170
256
  type ShardfileVersionParts,
171
257
  parseShardfileVersion,
172
258
  compareShardfileVersions,
@@ -0,0 +1,51 @@
1
+ import { splatTerrainOf, splatTextureRefs } from './splatTerrain.ts'
2
+
3
+ /* oxlint-disable curly, import/group-exports, no-magic-numbers, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/prefer-spread -- moved verbatim from engine (SHARD-COMPAT PR6e), so the cook's entry set stays the same set byte for byte */
4
+ // SHARD-COMPAT PR6e (J487): the whole-intake inputs and the other tier's splat files, a rule over the shard alone.
5
+ // Moved from engine `src/shared/game/shardfile/wholeInputs.ts`.
6
+ import type { Shardfile } from './shardSchema.ts'
7
+
8
+ /** Ordered native whole-intake inputs. A named assembly also reads its
9
+ * declared whole library; explicit-reference callers bypass this default. */
10
+ export function wholeGeometryInputs(
11
+ props: Shardfile['props'],
12
+ includeLibrary: boolean,
13
+ ): readonly string[] {
14
+ return [
15
+ ...(props?.tiles
16
+ .filter(row => row.lod === 0)
17
+ .flatMap(row => [row.file].concat(row.additionalFiles ?? [])) ?? []),
18
+ ...(includeLibrary ? (props?.wholeLibrary ?? []) : []),
19
+ ]
20
+ }
21
+
22
+ /** S4: a splat ground with a phone set draws one set per tier, and every L0 tile depends on both sets, so a dependency pins
23
+ * both through tier selection. The files only the other tier's set names are never read on this one. */
24
+ export function otherTierSplatFiles(
25
+ source: Pick<Shardfile, 'props'>,
26
+ tier: 'phone' | 'desktop' | (() => 'phone' | 'desktop'),
27
+ ): ReadonlySet<string> {
28
+ const splat = source.props === null ? undefined : splatTerrainOf(source.props)
29
+ if (splat?.phone === undefined) return new Set()
30
+ const drawn = new Set(
31
+ splatTextureRefs(splat, typeof tier === 'function' ? tier() : tier),
32
+ )
33
+ return new Set(splatTextureRefs(splat).filter(hash => !drawn.has(hash)))
34
+ }
35
+ /** S12f2b2: the phone layers a device drawing the phone set reads as the cook's own 6×6 file (`layer` names one), never as
36
+ * their blobs. None on a device drawing the desktop set, or without a cooked row (an older cook): the blob is read. */
37
+ export function cookedSplatLayers(
38
+ source: Pick<Shardfile, 'props'>,
39
+ tier: () => 'phone' | 'desktop',
40
+ layer: ((hash: string) => string | undefined) | undefined,
41
+ ): ReadonlySet<string> {
42
+ const splat =
43
+ source.props === null || layer === undefined
44
+ ? undefined
45
+ : splatTerrainOf(source.props)
46
+ if (splat?.phone === undefined || layer === undefined || tier() !== 'phone')
47
+ return new Set()
48
+ return new Set(
49
+ splatTextureRefs(splat, 'phone').filter(hash => layer(hash) !== undefined),
50
+ )
51
+ }
@@ -40,6 +40,10 @@
40
40
  "client/plan": {
41
41
  "hosts": ["page installClientPhase"]
42
42
  },
43
+ "server/plan": {
44
+ "hosts": ["server serverPlan"],
45
+ "note": "SHARD-COMPAT HS6b: the server's copy of the feature rows; engine's seam (`src/server/game/shardfile/serverPlan.ts`) reads it, falling back to `client/plan` for a file without one until the roll."
46
+ },
43
47
  "collections/displays": {
44
48
  "hosts": ["page CollectionCatalogue"]
45
49
  },