@wildshard/sdk 0.2.4 → 0.2.6
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/GUIDE.md +77 -11
- package/codemods/0.2.5.mjs +12 -0
- package/lint/ratchet.json +1 -9
- package/lint/sdk-plugin.mjs +24 -2
- package/package.json +4 -3
- package/scripts/build-shardfiles.mjs +1 -1
- package/scripts/gen-format-schema.mjs +1 -1
- package/scripts/shard-build-pool.mjs +1 -1
- package/scripts/wildshard.mjs +11 -3
- package/skills/wildshard-upgrade/SKILL.md +22 -23
- package/src/cli/help.ts +6 -3
- package/src/sharddev/agentFiles.ts +4 -3
- package/src/sharddev/author.ts +16 -3
- package/src/sharddev/bake/authoredWorld.ts +1 -1
- package/src/sharddev/bake/specimenCatalogue.ts +1 -1
- package/src/sharddev/bake/staticMaterials.ts +1 -1
- package/src/sharddev/checkProject.ts +1 -1
- package/src/sharddev/cli.ts +11 -7
- package/src/sharddev/formatJsonSchema.ts +1117 -3
- package/src/sharddev/kit/bakedGeometry.ts +58 -12
- package/src/sharddev/nativePopulationRows.ts +1 -1
- package/src/sharddev/performancePolicy.ts +1 -1
- package/src/sharddev/phasedBoss.ts +212 -34
- package/src/sharddev/project.ts +1 -1
- package/src/sharddev/projectEntryProof.ts +1 -1
- package/src/sharddev/projectGeneration.ts +1 -1
- package/src/sharddev/projectOutput.ts +1 -1
- package/src/sharddev/projectSections.ts +1 -1
- package/src/sharddev/refusals.ts +9 -5
- package/src/sharddev/reportCard.ts +1 -1
- package/src/sharddev/sections.ts +1 -1
- package/src/sharddev/species/clips.ts +64 -24
- package/src/sharddev/speciesBrains.ts +98 -15
- package/src/sharddev/updatePins.ts +358 -0
- package/src/sharddev/weapons/bowProfile.ts +3 -3
- package/src/sharddev/weapons/meleeProfile.ts +48 -4
- package/src/sharddev/worldScenes.ts +1 -1
- package/tsconfig.author.json +1 -0
|
@@ -1,19 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
// A species row and its declared brain, as the SDK defines them (SHARD-AUTHORING SA12). The row is gameplay data and the
|
|
2
|
+
// brain one platform archetype with its shard-format data; `test/sdk-engine-types.test.ts` keeps both equal to the engine's
|
|
3
|
+
// (game/plugin/brain), so a drift in either fails the test. The engine admits them (game/plugin/brain
|
|
4
|
+
// `admitSpeciesProgram`; SA26 took that runtime call off the SDK).
|
|
5
|
+
import type * as v from 'valibot';
|
|
6
|
+
import type { BorrowedDecision } from '@wildshard/format/decisionScripts';
|
|
7
|
+
import type { ScriptSpeciesSchema } from '@wildshard/format/speciesScripts';
|
|
8
|
+
import type { CreatureBodyRecipe } from '@wildshard/format/creatures';
|
|
9
|
+
import type { GrazerSchema, ChallengeGrazerSchema } from '@wildshard/format/grazers';
|
|
10
|
+
import type { DiverSchema, PatrolDiverSchema } from '@wildshard/format/flyers';
|
|
11
|
+
import type { StalkerSchema, GuardianPatternsSchema, SkirmisherSchema, GuardianSchema, PerchHunterSchema } from '@wildshard/format/brains';
|
|
2
12
|
|
|
3
|
-
import type { StrikeData } from './species';
|
|
4
|
-
|
|
5
|
-
/** A species row's declared brain (SHARD-PLATFORM SF27): `{ archetype, data }`, one platform archetype and its data. */
|
|
6
|
-
export type SpeciesBrain = PlatformSpeciesBrain;
|
|
7
|
-
/** Species gameplay data with an optional `brain`; a row without one keeps its runtime's own policy. */
|
|
8
|
-
export type BrainedSpecies = PlatformBrainedSpecies;
|
|
9
|
-
/** A catalogue's admitted brains: browser callbacks (`bind`), the live witness and the headless home policies. */
|
|
10
|
-
export type SpeciesBrains = PlatformSpeciesBrains;
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
* ScriptHost.
|
|
14
|
+
* A species row's declared brain (SHARD-PLATFORM SF27): `{ archetype, data }`, one platform archetype and its data. A
|
|
15
|
+
* challenge grazer's circling phase is the actor seed's slot in `[0, phaseSlots)`, so a pack spreads round its home. A
|
|
16
|
+
* `decision` brain lends its body to an admitted guest while the existing encounter owns its memory marks.
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
18
|
+
export type SpeciesBrain =
|
|
19
|
+
| { readonly archetype: 'grazer'; readonly data: Extract<v.InferInput<typeof GrazerSchema>, { pattern: 'wander-ram' }> }
|
|
20
|
+
| { readonly archetype: 'grazer'; readonly data: Extract<v.InferInput<typeof GrazerSchema>, { pattern: 'circle-challenge' }>; readonly phaseSlots: number }
|
|
21
|
+
| { readonly archetype: 'diver'; readonly data: v.InferInput<typeof DiverSchema> }
|
|
22
|
+
| { readonly archetype: 'decision'; readonly data: BorrowedDecision }
|
|
23
|
+
| { readonly archetype: 'challenge-grazer'; readonly data: v.InferInput<typeof ChallengeGrazerSchema>; readonly phaseSlots: number }
|
|
24
|
+
| { readonly archetype: 'patrol-diver'; readonly data: v.InferInput<typeof PatrolDiverSchema> }
|
|
25
|
+
| { readonly archetype: 'script'; readonly data: v.InferInput<typeof ScriptSpeciesSchema> }
|
|
26
|
+
| { readonly archetype: 'stalker'; readonly data: v.InferInput<typeof StalkerSchema> }
|
|
27
|
+
| { readonly archetype: 'skirmisher'; readonly data: v.InferInput<typeof SkirmisherSchema> }
|
|
28
|
+
| { readonly archetype: 'guardian'; readonly data: v.InferInput<typeof GuardianSchema> | v.InferInput<typeof GuardianPatternsSchema> }
|
|
29
|
+
| { readonly archetype: 'perch-hunter'; readonly data: v.InferInput<typeof PerchHunterSchema> };
|
|
30
|
+
|
|
31
|
+
/** A variant's rarity. */
|
|
32
|
+
export type Rarity = 'common' | 'uncommon' | 'rare' | 'legendary';
|
|
33
|
+
|
|
34
|
+
/** Per-variant gameplay multipliers, applied at spawn on top of the species' hunt tuning. */
|
|
35
|
+
export interface VariantMods {
|
|
36
|
+
/** × runSpeed / trotSpeed / charge speed (1 = species baseline) */
|
|
37
|
+
speed: number;
|
|
38
|
+
/** × panicDist (the charge trigger) and the "turns on you when hit" distance */
|
|
39
|
+
chargeDist: number;
|
|
40
|
+
/** × damage taken by BODY hits (headshots always land in full) */
|
|
41
|
+
damageTaken: number;
|
|
42
|
+
/** damage dealt to the player by one charge contact (species default 25) */
|
|
43
|
+
chargeDamage: number;
|
|
44
|
+
/** charges last 3× longer, cool down in 1/3 the time, and a hit always provokes one */
|
|
45
|
+
relentless: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** One variant of a species: gameplay data only, never a builder, palette or hull. */
|
|
49
|
+
export interface SpeciesVariant {
|
|
50
|
+
id: string; label: string; weight: number; rarity: Rarity; scale: [number, number];
|
|
51
|
+
hp?: number; mods?: Partial<VariantMods>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** One animal kind's hunting-loop numbers (m, s, rad, awareness/s). Player speeds: crouch 2.2, walk 4.3, sprint 7.2 m/s. */
|
|
55
|
+
export interface HuntTuning {
|
|
56
|
+
hp: number;
|
|
57
|
+
sightRange: number; sightRangeGraze: number; sightCone: number;
|
|
58
|
+
hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number;
|
|
59
|
+
noticeRate: number; forgetRate: number; alertAt: number; boltAt: number;
|
|
60
|
+
freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number;
|
|
61
|
+
runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number;
|
|
62
|
+
lookBack: number; waryTime: number; waryBoost: number;
|
|
63
|
+
herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number;
|
|
64
|
+
impactSpook: number; impactAlert: number;
|
|
65
|
+
/** Hunters: the alert turns into a pursuit ('stalk') instead of a bolt. */
|
|
66
|
+
stalk?: {
|
|
67
|
+
detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number;
|
|
68
|
+
/** sound played at the start of a charge */
|
|
69
|
+
roar: string;
|
|
70
|
+
fleeBelowHp: number; fleeChance: number;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A flying species' altitude and climb, dive and bank limits. */
|
|
75
|
+
export interface SpeciesFlight {
|
|
76
|
+
altitude: number;
|
|
77
|
+
/** Ground-relative by default; a missing/distant floor falls back to world altitude. */
|
|
78
|
+
above?: 'ground' | 'world';
|
|
79
|
+
climbRate: number; diveRate: number;
|
|
80
|
+
/** Lock acquire distance in metres (eye → body edge); default 24 m, release at 1.5×. */
|
|
81
|
+
lockRange?: number;
|
|
82
|
+
/** The largest roll into a turn, radians (0 < bank < π/2); omitted, the body flies level. */
|
|
83
|
+
bank?: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Species gameplay data with an optional `brain`; a row without one keeps its runtime's own policy. */
|
|
87
|
+
export interface BrainedSpecies {
|
|
88
|
+
id: string; kind: string; label: string;
|
|
89
|
+
variants: SpeciesVariant[]; spawnOnly?: SpeciesVariant[];
|
|
90
|
+
aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number;
|
|
91
|
+
/** s / m / m: the charge's wind-up, the ring a charger circles on, the grass track it flattens */
|
|
92
|
+
chargeWindup?: number; ringRadius?: number; trampleRadius?: number;
|
|
93
|
+
tuning?: HuntTuning;
|
|
94
|
+
sounds?: { call: string; hurt: string; callVariants?: string[]; callEvery?: [number, number] };
|
|
95
|
+
tick?: 'ai' | 'always';
|
|
96
|
+
corpseFade?: number; blood?: boolean;
|
|
97
|
+
flight?: SpeciesFlight;
|
|
98
|
+
/** LOCK / target taps: omitted ground species are not lockable; omitted flight species are. */
|
|
99
|
+
lockable?: boolean;
|
|
100
|
+
readonly brain?: SpeciesBrain;
|
|
101
|
+
readonly body?: CreatureBodyRecipe;
|
|
19
102
|
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- `update --pins` asks pnpm for a release, installs it and runs its CLI.
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- It edits the shard repo's package.json and reads the installed sdk.
|
|
4
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
5
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Resolve files beneath the shard repo and the installed sdk.
|
|
6
|
+
import { basename, resolve } from 'node:path';
|
|
7
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- A codemod is a module the installed sdk ships; it loads by file URL.
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The new sdk's CLI runs under this same Node.
|
|
10
|
+
import process from 'node:process';
|
|
11
|
+
import { assertShardRepo, updateShardRepo } from './agentFiles';
|
|
12
|
+
|
|
13
|
+
// SHARD-AUTHORING SA18 (J314 Q7, Q27; J317 Q16): `wildshard update --pins[=<version>] [dir]`. Move the repo's pins to one
|
|
14
|
+
// sdk release (the sdk, and the shard-format, engine and three specs that release pins), install with pnpm, apply the
|
|
15
|
+
// release's codemods, rewrite GUIDE.md and the skills with the new sdk's own `update` (SA28), then run its `check`. It
|
|
16
|
+
// starts only from a committed git tree (assertCommitted), so the author can tell its edits from their own.
|
|
17
|
+
|
|
18
|
+
/** The names a shard repo lists the sdk under. `new` writes `@wildshard/sdk`; the org's shard repos list it as
|
|
19
|
+
* `@wildshard/sharddev`, which their source imports, as a GitHub pin or NPM-PUBLISH NP8's `npm:@wildshard/sdk@<v>`
|
|
20
|
+
* alias. The move keeps the name the repo has. */
|
|
21
|
+
export const SDK_NAMES = ['@wildshard/sdk', '@wildshard/sharddev'] as const;
|
|
22
|
+
/** The pins a shard repo may list; each moves to what the release names. The sdk moves to the release itself. */
|
|
23
|
+
export const PINNED = ['@wildshard/sdk', '@wildshard/sharddev', '@wildshard/engine', '@wildshard/format', 'three'] as const;
|
|
24
|
+
const isSdkName = (name: string): boolean => (SDK_NAMES as readonly string[]).includes(name);
|
|
25
|
+
const isPinned = (name: string): boolean => (PINNED as readonly string[]).includes(name);
|
|
26
|
+
const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies'] as const;
|
|
27
|
+
|
|
28
|
+
/** One sdk release, as the registry describes it: its version, the exact specs it pins (dependencies win over peers)
|
|
29
|
+
* and the Node it needs (`engines.node`, which `new` copies into a repo). */
|
|
30
|
+
export interface SdkRelease { readonly version: string; readonly pins: Readonly<Record<string, string>>; readonly node?: string }
|
|
31
|
+
|
|
32
|
+
/** How `update --pins` reaches the world, so a test can stand in for pnpm and the network. */
|
|
33
|
+
export interface PinsRunner {
|
|
34
|
+
/** The release `@wildshard/sdk@<spec>` names (`latest`, or a version). */
|
|
35
|
+
readonly view: (spec: string, cwd: string) => SdkRelease;
|
|
36
|
+
/** The tags of the GitHub repo `owner/name`, each to the commit it names (`git ls-remote --tags`). */
|
|
37
|
+
readonly tags: (repo: string, cwd: string) => ReadonlyMap<string, string>;
|
|
38
|
+
/** Run a command in `cwd` with its output shown; throw when it exits non-zero. */
|
|
39
|
+
readonly run: (command: string, args: readonly string[], cwd: string) => void;
|
|
40
|
+
readonly log: (line: string) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u;
|
|
44
|
+
/** Compare two versions `x.y.z[-pre]`: negative, zero or positive. A prerelease sorts before its release. */
|
|
45
|
+
export function compareVersions(a: string, b: string): number {
|
|
46
|
+
const left = SEMVER.exec(a), right = SEMVER.exec(b);
|
|
47
|
+
if (left === null || right === null) throw new Error(`update --pins: ${left === null ? a : b} is not a version`);
|
|
48
|
+
for (let part = 1; part <= 3; part += 1) {
|
|
49
|
+
const difference = Number(left[part]) - Number(right[part]);
|
|
50
|
+
if (difference !== 0) return difference;
|
|
51
|
+
}
|
|
52
|
+
const [preLeft, preRight] = [left[4], right[4]];
|
|
53
|
+
if (preLeft === preRight) return 0;
|
|
54
|
+
if (preLeft === undefined) return 1;
|
|
55
|
+
if (preRight === undefined) return -1;
|
|
56
|
+
// semver: dot-separated identifiers, numbers numerically and below words; fewer identifiers sort first.
|
|
57
|
+
const [partsLeft, partsRight] = [preLeft.split('.'), preRight.split('.')];
|
|
58
|
+
for (let index = 0; index < Math.min(partsLeft.length, partsRight.length); index += 1) {
|
|
59
|
+
const [l, r] = [partsLeft[index] ?? '', partsRight[index] ?? ''];
|
|
60
|
+
if (l === r) continue;
|
|
61
|
+
const [ln, rn] = [/^\d+$/u.test(l), /^\d+$/u.test(r)];
|
|
62
|
+
if (ln && rn) return Number(l) - Number(r);
|
|
63
|
+
if (ln !== rn) return ln ? -1 : 1;
|
|
64
|
+
return l < r ? -1 : 1;
|
|
65
|
+
}
|
|
66
|
+
return partsLeft.length - partsRight.length;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type Json = Record<string, unknown>;
|
|
70
|
+
const isRecord = (value: unknown): value is Json => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
71
|
+
const readJson = (file: string): Json => {
|
|
72
|
+
const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));
|
|
73
|
+
if (!isRecord(parsed)) throw new Error(`update --pins: ${file} is not a JSON object`);
|
|
74
|
+
return parsed;
|
|
75
|
+
};
|
|
76
|
+
const stringAt = (record: Json, key: string): string | undefined => typeof record[key] === 'string' ? record[key] : undefined;
|
|
77
|
+
|
|
78
|
+
/** One pin `movePins` changed (or left: the release no longer pins a package the repo lists). An override's name is
|
|
79
|
+
* its key in `pnpm.overrides`. */
|
|
80
|
+
export interface PinMove { readonly name: string; readonly field: string; readonly from: string; readonly to: string | undefined }
|
|
81
|
+
|
|
82
|
+
const SDK_ALIAS = /^npm:@wildshard\/sdk@(.+)$/u;
|
|
83
|
+
const GITHUB_PIN = /^github:([\w.-]+\/[\w.-]+)#(.+)$/u;
|
|
84
|
+
/** The package a `pnpm.overrides` key overrides: the last `parent>` step, without its `@<range>` selector (which may
|
|
85
|
+
* hold a `>` of its own, as in `three@>=0.180`). */
|
|
86
|
+
const overriddenPackage = (key: string): string => (key.split(/>(?=[@A-Za-z])/u).at(-1) ?? key).replace(/(?<=.)@[^@/]*$/u, '');
|
|
87
|
+
|
|
88
|
+
/** The repo's package.json text with every listed pin moved to `release`; each pin keeps its field (a blender repo's
|
|
89
|
+
* sdk stays a dev dependency) and the sdk keeps its name and form: an exact version moves to the release, an
|
|
90
|
+
* `npm:@wildshard/sdk@<v>` alias to the release's alias, and a GitHub pin to `sdkSpec`, which `updatePins` resolves
|
|
91
|
+
* (the release tag's commit); any other form (`link:`, a `$` reference, a GitHub pin with no `sdkSpec`) is left, and
|
|
92
|
+
* reported as a move to nothing. `pnpm.overrides` of a moved package move with it, whatever their key's form, since an
|
|
93
|
+
* override wins over the pin. `engines.node` moves too, when the repo lists it, since `new` writes it and `.npmrc` makes
|
|
94
|
+
* it strict. Nothing else in the file changes, and its indent is kept. */
|
|
95
|
+
export function movePins(text: string, release: SdkRelease, sdkSpec?: string): { readonly text: string; readonly moves: readonly PinMove[] } {
|
|
96
|
+
const parsed: unknown = JSON.parse(text);
|
|
97
|
+
if (!isRecord(parsed)) throw new Error('update --pins: package.json is not a JSON object');
|
|
98
|
+
const moves: PinMove[] = [];
|
|
99
|
+
const target = (name: string, from: string): string | undefined => {
|
|
100
|
+
if (!isSdkName(name)) return release.pins[name];
|
|
101
|
+
if (SDK_ALIAS.test(from)) return `npm:@wildshard/sdk@${release.version}`;
|
|
102
|
+
if (GITHUB_PIN.test(from)) return sdkSpec;
|
|
103
|
+
return SEMVER.test(from) ? release.version : undefined;
|
|
104
|
+
};
|
|
105
|
+
const move = (record: Json, key: string, name: string, field: string): void => {
|
|
106
|
+
const from = stringAt(record, key);
|
|
107
|
+
if (from === undefined) return;
|
|
108
|
+
const to = target(name, from);
|
|
109
|
+
if (to === from) return;
|
|
110
|
+
moves.push({ name: key, field, from, to });
|
|
111
|
+
if (to !== undefined) record[key] = to;
|
|
112
|
+
};
|
|
113
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
114
|
+
const listed = parsed[field];
|
|
115
|
+
if (isRecord(listed)) for (const name of PINNED) move(listed, name, name, field);
|
|
116
|
+
}
|
|
117
|
+
const pnpm = parsed['pnpm'], overrides = isRecord(pnpm) ? pnpm['overrides'] : undefined;
|
|
118
|
+
if (isRecord(overrides)) for (const key of Object.keys(overrides)) {
|
|
119
|
+
const name = overriddenPackage(key);
|
|
120
|
+
if (isPinned(name)) move(overrides, key, name, 'pnpm.overrides');
|
|
121
|
+
}
|
|
122
|
+
const engines = parsed['engines'], node = isRecord(engines) ? stringAt(engines, 'node') : undefined;
|
|
123
|
+
if (isRecord(engines) && node !== undefined && release.node !== undefined && node !== release.node) {
|
|
124
|
+
moves.push({ name: 'engines.node', field: 'engines', from: node, to: release.node });
|
|
125
|
+
engines['node'] = release.node;
|
|
126
|
+
}
|
|
127
|
+
const indent = /^\{\r?\n([ \t]+)"/u.exec(text)?.[1] ?? 2;
|
|
128
|
+
return { text: moves.some(moved => moved.to !== undefined) ? `${JSON.stringify(parsed, null, indent)}\n` : text, moves };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Whether package.json lists `three` itself (a `--template sdk` repo does; a blender one does not). */
|
|
132
|
+
const listsThree = (listed: Json): boolean => DEPENDENCY_FIELDS.some(field => { const pins = listed[field]; return isRecord(pins) && stringAt(pins, 'three') !== undefined; });
|
|
133
|
+
|
|
134
|
+
/** The version of the package installed at `<project>/node_modules/<name>`, if any. */
|
|
135
|
+
function installedVersion(project: string, name: string): string | undefined {
|
|
136
|
+
const file = resolve(project, 'node_modules', name, 'package.json');
|
|
137
|
+
return existsSync(file) ? stringAt(readJson(file), 'version') : undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The sdk dependency a repo lists: its name, its spec, and the GitHub repo and ref when it is a GitHub pin. */
|
|
141
|
+
interface SdkPin { readonly name: string; readonly spec: string; readonly github?: { readonly repo: string; readonly ref: string } }
|
|
142
|
+
|
|
143
|
+
/** The repo's sdk pin: an exact version, an `npm:@wildshard/sdk@<version>` alias, or a GitHub pin (`github:<owner>/<repo>#<ref>`,
|
|
144
|
+
* at a commit or a tag), under either name. Anything else (`link:`, a range) names no one release. */
|
|
145
|
+
function sdkPin(project: string, listed: Json): SdkPin {
|
|
146
|
+
for (const field of DEPENDENCY_FIELDS) for (const name of SDK_NAMES) {
|
|
147
|
+
const pins = listed[field], spec = isRecord(pins) ? stringAt(pins, name) : undefined;
|
|
148
|
+
if (spec === undefined) continue;
|
|
149
|
+
const alias = SDK_ALIAS.exec(spec)?.[1], github = GITHUB_PIN.exec(spec);
|
|
150
|
+
if (SEMVER.test(spec) || (alias !== undefined && SEMVER.test(alias))) return { name, spec };
|
|
151
|
+
if (github !== null) return { name, spec, github: { repo: github[1] ?? '', ref: github[2] ?? '' } };
|
|
152
|
+
throw new Error(`update --pins: cannot tell which sdk ${project} is on: pin ${name} to a version, an npm:@wildshard/sdk@<version> alias or a github: commit (not ${spec})`);
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`update --pins: cannot tell which sdk ${project} is on: its package.json lists no ${SDK_NAMES.join(' or ')}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The release a `v<version>` tag names, newest first when one commit has several. */
|
|
158
|
+
function taggedVersion(tags: ReadonlyMap<string, string>, ref: string): string | undefined {
|
|
159
|
+
if (/^v\d/u.test(ref)) return SEMVER.test(ref.slice(1)) ? ref.slice(1) : undefined;
|
|
160
|
+
if (!/^[0-9a-f]{7,40}$/u.test(ref)) return undefined;
|
|
161
|
+
return [...tags].filter(([tag, commit]) => commit.startsWith(ref) && /^v\d/u.test(tag) && SEMVER.test(tag.slice(1)))
|
|
162
|
+
.map(([tag]) => tag.slice(1)).sort(compareVersions).at(-1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The sdk version the repo is on now. A version or alias pin says it, and must match what is installed; a GitHub pin
|
|
166
|
+
* says it by its tag, or by the release tag at its commit; a commit no release tag names is whatever is installed. */
|
|
167
|
+
function currentSdk(project: string, pin: SdkPin, tags: () => ReadonlyMap<string, string>): string {
|
|
168
|
+
const pinned = pin.github === undefined ? SDK_ALIAS.exec(pin.spec)?.[1] ?? pin.spec : taggedVersion(tags(), pin.github.ref);
|
|
169
|
+
const installed = installedVersion(project, pin.name);
|
|
170
|
+
if (pinned !== undefined && installed !== undefined && installed !== pinned) throw new Error(`update --pins: ${project} pins ${pin.name} ${pinned} but has ${installed} installed: run pnpm install, then wildshard check ., then update --pins again`);
|
|
171
|
+
const from = pinned ?? installed;
|
|
172
|
+
if (from === undefined) throw new Error(`update --pins: cannot tell which sdk ${project} is on: ${pin.name} ${pin.spec} is no release tag's commit and no sdk is installed: run pnpm install, then update --pins again`);
|
|
173
|
+
return from;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Where a GitHub sdk pin moves for `version`: a tag pin to that release's tag, a commit pin to the commit the release's
|
|
177
|
+
* `v<version>` tag names, so the repo's pin style stays as it was. */
|
|
178
|
+
function githubTarget(pin: SdkPin & { readonly github: NonNullable<SdkPin['github']> }, version: string, tags: ReadonlyMap<string, string>): { readonly spec: string; readonly why: string } {
|
|
179
|
+
const tag = `v${version}`, commit = tags.get(tag);
|
|
180
|
+
if (commit === undefined) throw new Error(`update --pins: ${pin.github.repo} has no tag ${tag}, so ${pin.name} ${pin.spec} has no release commit to move to; pin ${pin.name} to npm:@wildshard/sdk@${version} instead`);
|
|
181
|
+
if (/^v\d/u.test(pin.github.ref)) return { spec: `github:${pin.github.repo}#${tag}`, why: `kept as a GitHub tag pin: ${tag}` };
|
|
182
|
+
return { spec: `github:${pin.github.repo}#${commit}`, why: `kept as a GitHub commit pin: the ${tag} tag's commit` };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A release's codemods: `codemods/<version>.mjs` in the installed sdk, each default-exporting
|
|
186
|
+
* `({ project, from, to }) => void | string[] | Promise<…>` that edits the shard repo for that release. */
|
|
187
|
+
export const CODEMODS_FOLDER = 'codemods';
|
|
188
|
+
|
|
189
|
+
/** The codemods for a move `from` → `to`: every `<v>.mjs` with from < v <= to, oldest first. */
|
|
190
|
+
export function codemodsBetween(sdkRoot: string, from: string, to: string): string[] {
|
|
191
|
+
const folder = resolve(sdkRoot, CODEMODS_FOLDER);
|
|
192
|
+
if (!existsSync(folder)) return [];
|
|
193
|
+
return readdirSync(folder)
|
|
194
|
+
.map(file => /^(.+)\.mjs$/u.exec(file)?.[1])
|
|
195
|
+
.filter((version): version is string => version !== undefined && SEMVER.test(version)
|
|
196
|
+
&& compareVersions(version, from) > 0 && compareVersions(version, to) <= 0)
|
|
197
|
+
.sort(compareVersions)
|
|
198
|
+
.map(version => resolve(folder, `${version}.mjs`));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Apply each codemod from `codemodsBetween` to `project`, in order; returns what each says it changed. */
|
|
202
|
+
export async function applyCodemods(project: string, sdkRoot: string, from: string, to: string): Promise<string[]> {
|
|
203
|
+
const lines: string[] = [];
|
|
204
|
+
for (const file of codemodsBetween(sdkRoot, from, to)) {
|
|
205
|
+
const name = basename(file);
|
|
206
|
+
let said: unknown;
|
|
207
|
+
try {
|
|
208
|
+
const loaded: unknown = await import(pathToFileURL(file).href);
|
|
209
|
+
const codemod: unknown = isRecord(loaded) ? loaded['default'] : undefined;
|
|
210
|
+
if (typeof codemod !== 'function') throw new Error('it has no default export function');
|
|
211
|
+
said = await Reflect.apply(codemod, undefined, [{ project, from, to }]);
|
|
212
|
+
} catch (error) { throw new Error(`update --pins: codemod ${name} failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error }); }
|
|
213
|
+
lines.push(` codemod ${name}`);
|
|
214
|
+
if (Array.isArray(said)) for (const line of said) if (typeof line === 'string') lines.push(` ${line}`);
|
|
215
|
+
}
|
|
216
|
+
return lines;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** `update --pins` edits package.json, the lock file and (by its codemods) the shard source, so it needs a repo whose
|
|
220
|
+
* every change is committed: then `git diff` shows only what the move made. It refuses a repo git does not track
|
|
221
|
+
* (no repo, or package.json not committed, as in a folder another repo ignores) and one with uncommitted or untracked
|
|
222
|
+
* changes. Ignored files (node_modules, build output) are not dirt. There is no flag to skip this. */
|
|
223
|
+
export function assertCommitted(project: string): void {
|
|
224
|
+
const git = (args: readonly string[]): string | undefined => {
|
|
225
|
+
try { return execFileSync('git', [...args], { cwd: project, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }); }
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (isRecord(error) && error['code'] === 'ENOENT') throw new Error('update --pins: git not found: install git, then run update --pins again', { cause: error });
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
// Untracked files count whatever the author's status.showUntrackedFiles says.
|
|
232
|
+
const status = git(['ls-files', '--error-unmatch', '--', 'package.json']) === undefined ? undefined : git(['status', '--porcelain', '--untracked-files=normal', '--', '.']);
|
|
233
|
+
if (status === undefined) throw new Error(`update --pins: ${project} is not in a git repo with its package.json committed; update --pins edits your files, and git diff is how you see what it changed`);
|
|
234
|
+
const changed = status.split('\n').filter(line => line.trim() !== '');
|
|
235
|
+
if (changed.length > 0) {
|
|
236
|
+
const shown = changed.slice(0, 3).map(line => line.slice(3)).join(', ') + (changed.length > 3 ? ` and ${String(changed.length - 3)} more` : '');
|
|
237
|
+
throw new Error(`update --pins: ${project} has uncommitted changes (${shown}); commit or stash them first, so git diff shows only what update --pins changes`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** git ls-remote: a GitHub repo's tags, each to its commit (an annotated tag's peeled `^{}` line wins). */
|
|
242
|
+
function gitTags(repo: string, cwd: string): ReadonlyMap<string, string> {
|
|
243
|
+
let out: string;
|
|
244
|
+
// GIT_TERMINAL_PROMPT=0: a private or misspelt repo fails instead of asking for a username on the terminal.
|
|
245
|
+
try { out = execFileSync('git', ['ls-remote', '--tags', `https://github.com/${repo}.git`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } }); }
|
|
246
|
+
catch (error) { throw new Error(`update --pins: git ls-remote --tags on github.com/${repo} failed: ${error instanceof Error ? error.message.split('\n')[0] ?? '' : String(error)}`, { cause: error }); }
|
|
247
|
+
const tags = new Map<string, string>();
|
|
248
|
+
for (const [commit, ref] of out.split('\n').map(line => line.split('\t'))) {
|
|
249
|
+
const tag = ref?.replace(/^refs\/tags\//u, '');
|
|
250
|
+
if (commit === undefined || tag === undefined || tag === ref) continue;
|
|
251
|
+
if (tag.endsWith('^{}')) tags.set(tag.slice(0, -3), commit);
|
|
252
|
+
else if (!tags.has(tag)) tags.set(tag, commit);
|
|
253
|
+
}
|
|
254
|
+
return tags;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The newest sdk whose `wildshard update` refuses a repo that lists it as `@wildshard/sharddev`. */
|
|
258
|
+
const LAST_UPDATE_WITHOUT_SHARDDEV = '0.2.5';
|
|
259
|
+
|
|
260
|
+
/** pnpm view: the release a spec names, with the specs it pins. */
|
|
261
|
+
function pnpmView(spec: string, cwd: string): SdkRelease {
|
|
262
|
+
let out: string;
|
|
263
|
+
try { out = execFileSync('pnpm', ['view', `@wildshard/sdk@${spec}`, 'version', 'dependencies', 'peerDependencies', 'engines', '--json'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }); }
|
|
264
|
+
catch (error) { throw new Error(`update --pins: pnpm view @wildshard/sdk@${spec} failed: ${error instanceof Error ? error.message.split('\n')[0] ?? '' : String(error)}`, { cause: error }); }
|
|
265
|
+
if (out.trim() === '') throw new Error(`update --pins: npm has no @wildshard/sdk@${spec}`);
|
|
266
|
+
const parsed: unknown = JSON.parse(out);
|
|
267
|
+
// A range matching several versions lists each; take the newest.
|
|
268
|
+
const found: unknown = Array.isArray(parsed) ? parsed.at(-1) : parsed;
|
|
269
|
+
const record = isRecord(found) ? found : {}, version = stringAt(record, 'version');
|
|
270
|
+
if (version === undefined || !SEMVER.test(version)) throw new Error(`update --pins: npm gave no version for @wildshard/sdk@${spec}`);
|
|
271
|
+
const pins: Record<string, string> = {};
|
|
272
|
+
for (const key of ['peerDependencies', 'dependencies']) {
|
|
273
|
+
const listed = record[key];
|
|
274
|
+
if (isRecord(listed)) for (const [name, value] of Object.entries(listed)) if (typeof value === 'string') pins[name] = value;
|
|
275
|
+
}
|
|
276
|
+
const engines = record['engines'], node = isRecord(engines) ? stringAt(engines, 'node') : undefined;
|
|
277
|
+
return { version, pins, ...(node === undefined ? {} : { node }) };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function runInherited(command: string, args: readonly string[], cwd: string): void {
|
|
281
|
+
execFileSync(command, args, { cwd, stdio: 'inherit' });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export const PNPM_RUNNER: PinsRunner = { view: pnpmView, tags: gitTags, run: runInherited, log: line => { console.info(line); } };
|
|
285
|
+
|
|
286
|
+
/** `wildshard update --pins[=<version>] [dir]`: move the repo at `project` to the sdk release `spec` names. */
|
|
287
|
+
export async function updatePins(project: string, spec = 'latest', runner: PinsRunner = PNPM_RUNNER): Promise<void> {
|
|
288
|
+
assertShardRepo(project);
|
|
289
|
+
const packageFile = resolve(project, 'package.json'), listed = readJson(packageFile);
|
|
290
|
+
const manager = stringAt(listed, 'packageManager');
|
|
291
|
+
if (manager !== undefined && !manager.startsWith('pnpm@')) throw new Error(`update --pins: ${project} names ${manager} as its package manager; update --pins installs with pnpm`);
|
|
292
|
+
const pin = sdkPin(project, listed);
|
|
293
|
+
assertCommitted(project);
|
|
294
|
+
let tagsRead: ReadonlyMap<string, string> | undefined;
|
|
295
|
+
const tags = (): ReadonlyMap<string, string> => {
|
|
296
|
+
tagsRead ??= runner.tags(pin.github?.repo ?? '', project);
|
|
297
|
+
return tagsRead;
|
|
298
|
+
};
|
|
299
|
+
const from = currentSdk(project, pin, tags);
|
|
300
|
+
const release = runner.view(spec, project);
|
|
301
|
+
if (compareVersions(release.version, from) < 0) throw new Error(`update --pins: ${project} is on ${pin.name} ${from}, newer than ${release.version}; update --pins moves forward only`);
|
|
302
|
+
const github = pin.github === undefined || release.version === from ? undefined : githubTarget({ ...pin, github: pin.github }, release.version, tags());
|
|
303
|
+
// A GitHub pin that is not moving stays as it is, and so does an sdk-named GitHub override.
|
|
304
|
+
const sdkSpec = github?.spec ?? (pin.github === undefined ? undefined : pin.spec);
|
|
305
|
+
runner.log(`wildshard update --pins: ${pin.name} ${from} -> ${release.version}`);
|
|
306
|
+
|
|
307
|
+
// 1. Move the pins. Until the codemods are done, a failure puts package.json and the lock file back and installs the
|
|
308
|
+
// old sdk again, so a second run starts from the same sdk and applies every codemod.
|
|
309
|
+
const lockFile = resolve(project, 'pnpm-lock.yaml'), oldText = readFileSync(packageFile, 'utf8');
|
|
310
|
+
const oldLock = existsSync(lockFile) ? readFileSync(lockFile) : undefined;
|
|
311
|
+
const moved = movePins(oldText, release, sdkSpec);
|
|
312
|
+
for (const move of moved.moves) {
|
|
313
|
+
const what = move.field === 'pnpm.overrides' ? `pnpm.overrides ${move.name}` : move.name;
|
|
314
|
+
const left = isSdkName(move.field === 'pnpm.overrides' ? overriddenPackage(move.name) : move.name)
|
|
315
|
+
? 'update --pins cannot move this form of the sdk pin; move it by hand' : `sdk ${release.version} no longer pins it`;
|
|
316
|
+
runner.log(move.to === undefined ? ` left ${what} ${move.from}: ${left}` : ` ${what} ${move.from} -> ${move.to}`);
|
|
317
|
+
if (move.name === pin.name && move.field !== 'pnpm.overrides' && github !== undefined) runner.log(` ${github.why}`);
|
|
318
|
+
}
|
|
319
|
+
if (moved.moves.length === 0) runner.log(' pins already match');
|
|
320
|
+
writeFileSync(packageFile, moved.text);
|
|
321
|
+
let sdkRoot: string;
|
|
322
|
+
try {
|
|
323
|
+
// 2. Install, then confirm pnpm installed what the pins say.
|
|
324
|
+
try { runner.run('pnpm', ['install'], project); }
|
|
325
|
+
catch (error) { throw new Error(`update --pins: pnpm install failed on @wildshard/sdk ${release.version}`, { cause: error }); }
|
|
326
|
+
const installed = installedVersion(project, pin.name);
|
|
327
|
+
if (installed !== release.version) throw new Error(`update --pins: pnpm installed ${pin.name} ${installed ?? 'nothing'}, not ${release.version}`);
|
|
328
|
+
// A repo that lists three (not a blender one) must get the exact three the release pins.
|
|
329
|
+
const threePin = release.pins['three'], three = installedVersion(project, 'three');
|
|
330
|
+
if (threePin !== undefined && SEMVER.test(threePin) && listsThree(listed) && three !== threePin) throw new Error(`update --pins: sdk ${release.version} pins three ${threePin}, but ${three ?? 'none'} is installed`);
|
|
331
|
+
sdkRoot = realpathSync(resolve(project, 'node_modules', pin.name));
|
|
332
|
+
// 3. The release's codemods, read from the installed sdk.
|
|
333
|
+
const codemods = await applyCodemods(project, sdkRoot, from, release.version);
|
|
334
|
+
runner.log(codemods.length === 0 ? ` no codemods between ${from} and ${release.version}` : codemods.join('\n'));
|
|
335
|
+
} catch (error) {
|
|
336
|
+
writeFileSync(packageFile, oldText);
|
|
337
|
+
if (oldLock !== undefined) writeFileSync(lockFile, oldLock);
|
|
338
|
+
let back = `package.json and pnpm-lock.yaml are back on ${pin.name} ${from}`;
|
|
339
|
+
try { runner.run('pnpm', ['install'], project); } catch { back += ', but pnpm install failed: run it again'; }
|
|
340
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
341
|
+
throw new Error(`${message}\n ${back}; a codemod may have edited src/ before it failed: git diff shows it`, { cause: error });
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// 4. GUIDE.md and the skills, by the new sdk's own `update` (SA28); 5. its `check`. An sdk up to 0.2.5 has an `update`
|
|
345
|
+
// that refuses a repo listing it as @wildshard/sharddev, so for those this CLI syncs that sdk's guide and skills itself.
|
|
346
|
+
const cli = resolve(sdkRoot, 'bin/wildshard.mjs');
|
|
347
|
+
if (pin.name === '@wildshard/sdk' || compareVersions(release.version, LAST_UPDATE_WITHOUT_SHARDDEV) > 0) {
|
|
348
|
+
try { runner.run(process.execPath, [cli, 'update', project], project); }
|
|
349
|
+
catch (error) { throw new Error(`update --pins: the pins moved to @wildshard/sdk ${release.version}, but its wildshard update failed: run pnpm exec wildshard update`, { cause: error }); }
|
|
350
|
+
} else {
|
|
351
|
+
runner.log(` sdk ${release.version}'s own update does not know ${pin.name}, so this CLI writes its GUIDE.md and skills`);
|
|
352
|
+
try { for (const line of updateShardRepo(project, sdkRoot)) runner.log(line); }
|
|
353
|
+
catch (error) { throw new Error(`update --pins: the pins moved to @wildshard/sdk ${release.version}, but writing its GUIDE.md and skills failed (${error instanceof Error ? error.message : String(error)}): run pnpm --package=@wildshard/sdk@latest dlx wildshard update`, { cause: error }); }
|
|
354
|
+
}
|
|
355
|
+
try { runner.run(process.execPath, [cli, 'check', '.'], project); }
|
|
356
|
+
catch (error) { throw new Error(`update --pins: the pins moved to @wildshard/sdk ${release.version}, but check failed: fix each refusal above, then run wildshard check .`, { cause: error }); }
|
|
357
|
+
runner.log(`wildshard update --pins: on @wildshard/sdk ${release.version}, check pass`);
|
|
358
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parse, type InferOutput } from 'valibot';
|
|
2
2
|
import { BowWeaponProfileSchema, HeldBowFileSchema, type HeldBowFileRows } from '@wildshard/format/weaponProfiles';
|
|
3
3
|
import STARTER_BOW from '@wildshard/engine/game/weapons/starterBow.json' with { type: 'json' };
|
|
4
|
-
import type { BowStyle as PlatformBowStyle } from '@wildshard/engine/combat/view/bowProfile';
|
|
5
4
|
|
|
6
|
-
/** Named transitional bow view strategy styles.
|
|
7
|
-
|
|
5
|
+
/** Named transitional bow view strategy styles: any name the shard's bow view repaints by (`test/sdk-engine-types.test.ts`
|
|
6
|
+
* keeps it equal to the engine's `combat/view/bowProfile` `BowStyle`). */
|
|
7
|
+
export type BowStyle = string;
|
|
8
8
|
|
|
9
9
|
/** Admit a complete authored bow file before its pool or display strategy is borrowed. */
|
|
10
10
|
export function parseHeldBowFile(input: unknown): HeldBowFileRows { return parse(HeldBowFileSchema, input); }
|
|
@@ -1,13 +1,57 @@
|
|
|
1
1
|
import { SWORD_WOOD } from '@wildshard/engine/game/weapons/starterMeleeProfile';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EquipmentIcon, EquipmentTouchMap, WeaponId } from '@wildshard/engine/combat/Equipment';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { parse } from 'valibot';
|
|
5
5
|
import { MeleeWeaponProfileSchema, type MeleeWeaponProfileRows } from '@wildshard/format/weaponProfiles';
|
|
6
6
|
|
|
7
|
-
/** Authored swept combo and view parameters; ordered contact rows are defined by the format's weaponProfiles module. */
|
|
8
|
-
export type MeleeProfile = PlatformMeleeProfile;
|
|
9
7
|
/** Numeric camera lag, bob and sway parameters, independent of a particular weapon model. */
|
|
10
|
-
export
|
|
8
|
+
export interface ViewmodelFeel {
|
|
9
|
+
lag: { gain: number; clampYaw: number; clampPitch: number; k: number; c: number; posYaw: number; posPitch: number };
|
|
10
|
+
bob: { x: number; y: number; rz: number; rx: number };
|
|
11
|
+
sway: { ax: number; fx: number; ay: number; fy: number };
|
|
12
|
+
fovHip: number; portraitFov?: number;
|
|
13
|
+
}
|
|
14
|
+
/** How the held melee model sits in the view: shrink, offset, tilt and yaw. */
|
|
15
|
+
export interface MeleeFraming { shrink: number; dx: number; dy: number; tilt: number; yaw: number }
|
|
16
|
+
/** A held item's menu and HUD presentation. `icon`, `touch` and the slot are the host's declared vocabularies (the engine's
|
|
17
|
+
* `EquipmentIconMap`, `EquipmentTouchMap` and `EquipmentSlotMap`, filled by declaration merging). */
|
|
18
|
+
export interface EquipmentUi {
|
|
19
|
+
name: string; icon: EquipmentIcon;
|
|
20
|
+
/** Magazine readouts offer touch reload; quivers keep their passive ammo chip. */
|
|
21
|
+
ammo?: { label: string; segments: number; magazine?: boolean; bagLabel?: string; bagLabelFor?: string };
|
|
22
|
+
inputContext?: string;
|
|
23
|
+
touch: keyof EquipmentTouchMap;
|
|
24
|
+
lockOn: boolean; melee: boolean; tracers: boolean;
|
|
25
|
+
/** The existing 24px swap glyph and short label; menu icons use the shared 64px icon library. */
|
|
26
|
+
swapIcon: string; swapName?: string;
|
|
27
|
+
huntersEye?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Authored swept combo and view parameters; ordered contact rows are defined by the format's weaponProfiles module.
|
|
31
|
+
* These are the authored fields of the engine's `combat/meleeProfile` `MeleeProfile`; its `pickup` factory is lent by
|
|
32
|
+
* the runtime host and is not author data. `test/sdk-engine-types.test.ts` keeps the two assignable both ways.
|
|
33
|
+
*/
|
|
34
|
+
export interface MeleeProfile {
|
|
35
|
+
id: `weapon.${string}` | `tool.${string}`; legacySlot?: WeaponId;
|
|
36
|
+
ui: EquipmentUi; meta: { name: string; icon: EquipmentIcon; blurb: string; category: string };
|
|
37
|
+
/** Sound cues: fire, reload, impact, and the optional dry, hit, heavy and charge cues. */
|
|
38
|
+
cues?: { fire: `cue.${string}`; reload: `cue.${string}`; impact: `cue.${string}`; dry?: `cue.${string}`; hit?: `cue.${string}`; heavy?: `cue.${string}`; charge?: Readonly<Record<string, `cue.${string}`>> };
|
|
39
|
+
rangedFeel?: {
|
|
40
|
+
kick: { body: number; head: number; kill: number; side: number; killSide: number };
|
|
41
|
+
trauma: { kill: number; head: number; killKinds: readonly string[]; headKinds: readonly string[] };
|
|
42
|
+
};
|
|
43
|
+
hitStop?: { body: number; head: number; kill: number };
|
|
44
|
+
tags?: readonly `${string}.${string}`[];
|
|
45
|
+
family: 'melee'; parent?: string;
|
|
46
|
+
damage: number; reach: number; swingScale: number;
|
|
47
|
+
portraitPullX: number; framing: MeleeFraming; feel: ViewmodelFeel;
|
|
48
|
+
moves?: MeleeMoveSet;
|
|
49
|
+
cooldown: number; comboGap: number; chainLag: number; heavyCharge: number; chargeBlend: number;
|
|
50
|
+
lunge: { range: number; heavyRange: number; cone: number; stop: number; speed: number; minTime: number; maxTime: number };
|
|
51
|
+
sweep: { rays: number; extensions: readonly number[]; step: number; maxSamples: number; maxHits: number };
|
|
52
|
+
trail: { samples: number; subdivisions: number };
|
|
53
|
+
dodgeKick: { kick: number; k: number; c: number }; armFollow: number;
|
|
54
|
+
}
|
|
11
55
|
|
|
12
56
|
/** An authored hand pose, independent of a live weapon controller. */
|
|
13
57
|
export interface MeleeKey { t: number; pos: THREE.Vector3; q: THREE.Quaternion }
|
|
@@ -2,7 +2,7 @@ import { parseWorldScenePage } from '@wildshard/format/worldScenePages';
|
|
|
2
2
|
import { SceneModelSourceSchema, SceneBakeSourceSchema } from '@wildshard/format/sceneSources';
|
|
3
3
|
import type { BakedPlacementPlan } from '@wildshard/format/bakedTiles';
|
|
4
4
|
import { isJsonData } from '@wildshard/format/json';
|
|
5
|
-
import { namedJsonSchema, registeredJsonSchema } from '
|
|
5
|
+
import { namedJsonSchema, registeredJsonSchema } from './formatJsonSchema';
|
|
6
6
|
import type { RegisteredScenePageJsonName, RegisteredPlacementPageJsonName } from '@wildshard/format/registeredJson';
|
|
7
7
|
import { parseWorldScene, parseWorldSceneBindings, parsePrivateScene, type WorldSceneRecipe } from '@wildshard/format/clientChannels';
|
|
8
8
|
import { CaveInteriorSchema, type CaveInteriorRows } from '@wildshard/format/caveInterior';
|
package/tsconfig.author.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"src/sharddev/**/*.mts",
|
|
13
13
|
"src/commons/**/*.ts",
|
|
14
14
|
"test/graph-scene-author-types.test.ts",
|
|
15
|
+
"test/sdk-engine-types.test.ts",
|
|
15
16
|
"node_modules/@wildshard/engine/src/*/engine/**/*.d.ts",
|
|
16
17
|
"node_modules/@wildshard/engine/src/*/game/**/*.merge.d.ts"
|
|
17
18
|
],
|