@wildshard/shard-format 0.55.1 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -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');
|
|
@@ -18,11 +18,9 @@ const entry = v.strictObject({ id: key, kind: entryKind, tab: key, name: text, n
|
|
|
18
18
|
const stat = v.strictObject({ label: text, value: v.picklist(['seen', 'taken', 'best', 'rarity', 'status']),
|
|
19
19
|
fallback: v.exactOptional(text), suffix: v.exactOptional(text), words: v.exactOptional(v.record(key, text)) });
|
|
20
20
|
const stats = v.pipe(v.array(stat), v.maxLength(8));
|
|
21
|
-
const iconSelectors = { entryKind: v.exactOptional(entryKind), matchKind: v.exactOptional(key) };
|
|
22
|
-
const legacyIcon = v.strictObject({ ...iconSelectors, icon: v.picklist(['antlers', 'ghost', 'ironhide', 'deer', 'boar', 'elk', 'bear']) });
|
|
23
21
|
const iconImage = v.pipe(text, v.check(sketchReference, 'bounded inert SVG data or admitted image hash'));
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
const icon = v.strictObject({ entryKind: v.exactOptional(entryKind), matchKind: v.exactOptional(key),
|
|
23
|
+
image: iconImage, tint: v.exactOptional(v.literal('currentColor')) });
|
|
26
24
|
const cell = v.strictObject({ x: finite, y: finite, w: positive, h: positive });
|
|
27
25
|
const trophy = v.strictObject({ entry: key, outline: key, mount: v.exactOptional(v.strictObject({ kind: key, variant: key })), title: text });
|
|
28
26
|
const wall = v.strictObject({ cabin: natural, at: v.tuple([finite, finite, finite]), yaw: finite, width: positive,
|
|
@@ -51,14 +49,14 @@ export function journalRowRules(row: JournalRow): readonly string[] {
|
|
|
51
49
|
}
|
|
52
50
|
/** All raster images must be charged immutable library roots; logical URLs are resolved by the admitted product. */
|
|
53
51
|
export function journalImageRefs(row: JournalRow): readonly string[] {
|
|
54
|
-
const icons = row.icons.flatMap((value: Readonly<JournalIcon>): string[] =>
|
|
52
|
+
const icons = row.icons.flatMap((value: Readonly<JournalIcon>): string[] => value.image.startsWith('data:') ? [] : [value.image]);
|
|
55
53
|
return [...new Set([...row.entries.flatMap(value => [value.plate.sketch, ...value.plate.silhouette === undefined ? [] : [value.plate.silhouette]]),
|
|
56
54
|
...row.chalk === undefined ? [] : [row.chalk.atlas], ...icons])];
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
60
58
|
export type JournalRowInput = JournalRow;
|
|
61
|
-
|
|
59
|
+
interface JournalIcon { entryKind?: 'species' | 'variant' | 'elite' | 'boss' | 'place'; matchKind?: string; image: string; tint?: 'currentColor' }
|
|
62
60
|
interface JournalRowFields {
|
|
63
61
|
kind: 'journal';
|
|
64
62
|
id: string;
|
|
@@ -3,10 +3,10 @@ import { parseSketchSvg, sketchReference, type CompendiumSketch } from './sketch
|
|
|
3
3
|
import type { ShardRows } from './rows.ts';
|
|
4
4
|
|
|
5
5
|
const prefix = 'data:image/svg+xml,';
|
|
6
|
-
type SketchRow = Readonly<{ kind: 'journal'; icons: readonly Readonly<{ image
|
|
6
|
+
type SketchRow = Readonly<{ kind: 'journal'; icons: readonly Readonly<{ image: string }>[] }> | Readonly<{ kind?: never; entries: readonly Readonly<{ sketch: string }>[] }>;
|
|
7
7
|
function sketchRefs(row: SketchRow): string[] {
|
|
8
8
|
if (row.kind === 'journal') {
|
|
9
|
-
return row.icons.flatMap((value: Readonly<{ image
|
|
9
|
+
return row.icons.flatMap((value: Readonly<{ image: string }>): string[] => value.image.startsWith(prefix) ? [value.image] : []);
|
|
10
10
|
}
|
|
11
11
|
return row.entries.map((entry: Readonly<{ sketch: string }>): string => entry.sketch);
|
|
12
12
|
}
|
package/src/format/quests.ts
CHANGED
|
@@ -6,11 +6,32 @@ const text = v.pipe(v.string(), v.minLength(1), v.maxLength(512));
|
|
|
6
6
|
const finite = v.pipe(v.number(), v.finite());
|
|
7
7
|
const names = v.pipe(v.array(id), v.maxLength(128));
|
|
8
8
|
const condition = v.strictObject({ all: v.exactOptional(names), any: v.exactOptional(names), none: v.exactOptional(names) });
|
|
9
|
-
const
|
|
9
|
+
const worldAt = v.strictObject({ poi: v.literal('world'), x: finite, z: finite, y: v.exactOptional(finite) });
|
|
10
|
+
const marker = v.strictObject({ id, label: text, short: v.exactOptional(v.pipe(text, v.maxLength(18))), at: worldAt, hideWhen: v.exactOptional(condition) });
|
|
10
11
|
const markers = v.pipe(v.array(marker), v.maxLength(32));
|
|
11
12
|
const done = v.pipe(condition, v.check((c) => [...(c.all ?? []), ...(c.any ?? []), ...(c.none ?? [])].length > 0, 'nonempty done condition'));
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/** Meta MOSSGATE-ZONE MZ31 (QA 11-19 row 35, "nothing happens"): where a quest beat lands, and how. The engine flares the
|
|
14
|
+
* spot in `colour`, spreads its light over the ground for `radius` metres, pops a small reward there and sounds one of its own
|
|
15
|
+
* synth voices (`InteractSfx`, no recorded audio). */
|
|
16
|
+
const SPREAD_MIN = 1;
|
|
17
|
+
const SPREAD_MAX = 40;
|
|
18
|
+
const colour = v.pipe(v.string(), v.regex(/^#[0-9a-fA-F]{6}$/u));
|
|
19
|
+
const spread = v.pipe(finite, v.minValue(SPREAD_MIN), v.maxValue(SPREAD_MAX));
|
|
20
|
+
const voice = v.picklist(['chime', 'glyph', 'ignite', 'chest', 'lever', 'plate', 'door', 'grate']);
|
|
21
|
+
const landing = { at: v.omit(worldAt, ['poi']), colour: v.exactOptional(colour), radius: v.exactOptional(spread), sound: v.exactOptional(voice) };
|
|
22
|
+
/** A step's landing: shown where the step was done, the moment its `done` first holds. */
|
|
23
|
+
const feedback = v.strictObject(landing);
|
|
24
|
+
/** A quest's payoff: a bigger landing as it completes, the score's reward take (`music`, default `dawn`), then the next goal
|
|
25
|
+
* (`next`) on the tracker. The world change is `onComplete.scene`, the shard's own declared scene hook. */
|
|
26
|
+
const music = v.picklist(['dawn', 'none']);
|
|
27
|
+
const payoff = v.strictObject({ ...landing, music: v.exactOptional(music), next: v.exactOptional(text) });
|
|
28
|
+
const optionalPayoff = v.exactOptional(payoff);
|
|
29
|
+
/** MZ31: a quest beat's landing (a step's `feedback`, the base of a quest's `onComplete.payoff`). */
|
|
30
|
+
interface QuestFeedbackRows { at: Record<'x' | 'z', number> & Partial<Record<'y', number>>; colour?: string; radius?: number; sound?: 'chime' | 'glyph' | 'ignite' | 'chest' | 'lever' | 'plate' | 'door' | 'grate' }
|
|
31
|
+
/** MZ31: a quest's payoff as it completes. */
|
|
32
|
+
interface QuestPayoffRows extends QuestFeedbackRows { music?: 'dawn' | 'none'; next?: string }
|
|
33
|
+
const step = v.strictObject({ id, objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), done, count: v.exactOptional(names), markers: v.exactOptional(markers), feedback: v.exactOptional(feedback) });
|
|
34
|
+
const quest = v.strictObject({ id, title: text, track: v.exactOptional(v.boolean()), completeFlag: id, startWhen: v.exactOptional(condition), intro: v.exactOptional(v.strictObject({ objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), markers: v.exactOptional(markers) })), steps: v.pipe(v.array(step), v.minLength(1), v.maxLength(64)), onComplete: v.exactOptional(v.strictObject({ fact: v.exactOptional(id), scene: v.exactOptional(id), coins: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100))), payoff: optionalPayoff })) });
|
|
14
35
|
/** Complete presentation chapter after its native completion owner is omitted. */
|
|
15
36
|
export const QuestPresentationChapterSchema:v.GenericSchema<Omit<QuestDataInput['quests'][number],'onComplete'>,Omit<QuestData['quests'][number],'onComplete'>>=v.omit(quest,['onComplete']);
|
|
16
37
|
const trigger = v.variant('kind', [
|
|
@@ -133,6 +154,7 @@ interface QuestDataInputFields {
|
|
|
133
154
|
none?: (string)[];
|
|
134
155
|
};
|
|
135
156
|
count?: (string)[];
|
|
157
|
+
feedback?: QuestFeedbackRows;
|
|
136
158
|
markers?: ({
|
|
137
159
|
id: string;
|
|
138
160
|
label: string;
|
|
@@ -154,6 +176,7 @@ interface QuestDataInputFields {
|
|
|
154
176
|
fact?: string;
|
|
155
177
|
scene?: string;
|
|
156
178
|
coins?: number;
|
|
179
|
+
payoff?: QuestPayoffRows;
|
|
157
180
|
};
|
|
158
181
|
})[];
|
|
159
182
|
triggers: (({
|
|
@@ -276,6 +299,7 @@ interface QuestDataFields {
|
|
|
276
299
|
none?: (string)[];
|
|
277
300
|
};
|
|
278
301
|
count?: (string)[];
|
|
302
|
+
feedback?: QuestFeedbackRows;
|
|
279
303
|
markers?: ({
|
|
280
304
|
id: string;
|
|
281
305
|
label: string;
|
|
@@ -297,6 +321,7 @@ interface QuestDataFields {
|
|
|
297
321
|
fact?: string;
|
|
298
322
|
scene?: string;
|
|
299
323
|
coins?: number;
|
|
324
|
+
payoff?: QuestPayoffRows;
|
|
300
325
|
};
|
|
301
326
|
})[];
|
|
302
327
|
triggers: (({
|
|
@@ -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];
|