@wildshard/shard-format 0.55.0 → 0.55.2
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.55.
|
|
3
|
+
"version": "0.55.2",
|
|
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": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { acceptsShardfileCost, textureLibrarySource } from './deviceMemoryCost.ts';
|
|
2
|
+
import { retainedActorIds } from './retained-actors.ts';
|
|
2
3
|
import { creaturePerchAdmissionRows } from './creature-perch.ts';
|
|
3
4
|
import { admitScriptContract, decisionModuleContracts, type ScriptAdmissionRows } from './scriptContract.ts';
|
|
4
5
|
import type { TextureTranscodeSupport } from './contentBounds.ts';
|
|
@@ -206,7 +207,12 @@ function admitAfterFiles(state: AssetAdmission, assets: ReadonlyMap<string, Uint
|
|
|
206
207
|
if (criticalWire > s.budgets.sim.compressed || s.sim.scripts.some((r) => !critical.has(r)) || [...critical].some((r) => library.has(r))) throw new Error('critical bundle cap, declared wire budget, render-library dependency or script omitted');
|
|
207
208
|
if(s.runtime?.binds?.includes('state')===true){
|
|
208
209
|
const spawns = s.runtime.spawns;
|
|
209
|
-
const
|
|
210
|
+
const runtimeIds=[...spawns?.bosses??[], ...spawns?.homes??[], ...spawns?.actors??[]].map(row=>row.id);
|
|
211
|
+
const bossIds: string[]=[];
|
|
212
|
+
const declaredIds: string[]=[];
|
|
213
|
+
for(const spawn of s.creatures.spawns){ declaredIds.push(spawn.id); }
|
|
214
|
+
for(const encounter of s.encounters){ if(encounter.kind==='boss'){ bossIds.push(encounter.entity); } }
|
|
215
|
+
const actors=retainedActorIds(runtimeIds, declaredIds, bossIds);
|
|
210
216
|
for(const field of s.state.shared.filter(candidate=>candidate.privacy==='public')) {
|
|
211
217
|
if(!scripts.some(row=>row.abi!==2&&Object.values(row.fields).includes(field.name)&&Object.values(row.actors).length>0
|
|
212
218
|
&&Object.values(row.actors).every(actor=>actors.has(actor))))throw new Error('Runtime actor field requires its actual declared sim guest');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The actors a runtime-bound public field may live on: the runtime's boss, home and actor spawns, and (ONE-FORMAT OF22c2)
|
|
3
|
+
* the declared spawn a `boss` encounter names, which is retained the same way.
|
|
4
|
+
*/
|
|
5
|
+
export function retainedActorIds(
|
|
6
|
+
runtimeIds: readonly string[],
|
|
7
|
+
declaredIds: readonly string[],
|
|
8
|
+
bossEntities: readonly string[],
|
|
9
|
+
): Set<string> {
|
|
10
|
+
const declared = new Set(declaredIds)
|
|
11
|
+
return new Set([
|
|
12
|
+
...runtimeIds,
|
|
13
|
+
...bossEntities.filter((entity: string): boolean => declared.has(entity)),
|
|
14
|
+
])
|
|
15
|
+
}
|
|
@@ -270,8 +270,13 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
errors.push(...stateRules(s.state));
|
|
273
|
+
// ONE-FORMAT OF22c2: a `boss` encounter on a declared spawn is a retained actor, as a runtime boss spawn is
|
|
274
|
+
const declaredIds = new Set<string>();
|
|
275
|
+
for (const spawn of s.creatures.spawns) { declaredIds.add(spawn.id); }
|
|
276
|
+
let retainedBoss = false;
|
|
277
|
+
for (const encounter of s.encounters) { if (encounter.kind === 'boss' && declaredIds.has(encounter.entity)) { retainedBoss = true; } }
|
|
273
278
|
if ((s.clientChannels?.length ?? 0) > 0 && !pageOwner && s.runtime?.binds?.includes('clientChannels') !== true) errors.push('native visual channels require their declared page or runtime owner');
|
|
274
|
-
if (s.runtime?.binds?.includes('state') === true && (s.state.player.length > 0 || s.state.shared.some((field) => field.privacy !== 'host' && !(field.privacy === 'public' && field.type !== 'string' && (s.runtime?.spawns?.bosses.length ?? 0) > 0)))) errors.push('runtime-bound state supports host fields and retained-actor numeric fields');
|
|
279
|
+
if (s.runtime?.binds?.includes('state') === true && (s.state.player.length > 0 || s.state.shared.some((field) => field.privacy !== 'host' && !(field.privacy === 'public' && field.type !== 'string' && ((s.runtime?.spawns?.bosses.length ?? 0) > 0 || retainedBoss))))) errors.push('runtime-bound state supports host fields and retained-actor numeric fields');
|
|
275
280
|
errors.push(...materialGraphRules(s), ...materialCurveRules(s), ...textureSamplerRules(s.look, s.files, skinLookTextureRefs(s)), ...postStackRules(s), ...lookSkyRules(s.look.sky?.graph, graphBindingSources(s)));
|
|
276
281
|
const materialRefs = materialTextureRefs(s.look.materials), libraryClosure = new Set<string>();
|
|
277
282
|
const libraryPending = [...s.library];
|