@cybermp-community/resource-builder 0.0.0-stage → 0.1.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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +303 -2
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +584 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +1040 -0
  7. package/dist/index.js +1 -0
  8. package/dist/run-CmhtmY2x.js +7018 -0
  9. package/dist/run-CmhtmY2x.js.map +1 -0
  10. package/package.json +64 -3
  11. package/schema/config.json +122 -0
  12. package/templates/project-default/Dockerfile +17 -0
  13. package/templates/project-default/README.md +57 -0
  14. package/templates/project-default/_dockerignore +26 -0
  15. package/templates/project-default/_gitignore +32 -0
  16. package/templates/project-default/addons/gamemode/browser/env.d.ts +1 -0
  17. package/templates/project-default/addons/gamemode/browser/index.html +12 -0
  18. package/templates/project-default/addons/gamemode/browser/package.json +21 -0
  19. package/templates/project-default/addons/gamemode/browser/src/App.vue +40 -0
  20. package/templates/project-default/addons/gamemode/browser/src/global.d.ts +7 -0
  21. package/templates/project-default/addons/gamemode/browser/src/main.ts +4 -0
  22. package/templates/project-default/addons/gamemode/browser/tsconfig.json +7 -0
  23. package/templates/project-default/addons/gamemode/browser/vite.config.ts +15 -0
  24. package/templates/project-default/addons/gamemode/client/src/global.d.ts +5 -0
  25. package/templates/project-default/addons/gamemode/client/src/index.ts +11 -0
  26. package/templates/project-default/addons/gamemode/client/tsconfig.json +4 -0
  27. package/templates/project-default/addons/gamemode/package.json +22 -0
  28. package/templates/project-default/addons/gamemode/resource.toml +12 -0
  29. package/templates/project-default/addons/gamemode/server/src/global.d.ts +5 -0
  30. package/templates/project-default/addons/gamemode/server/src/index.ts +13 -0
  31. package/templates/project-default/addons/gamemode/server/tsconfig.json +7 -0
  32. package/templates/project-default/addons/gamemode/shared/src/index.ts +2 -0
  33. package/templates/project-default/biome.json +43 -0
  34. package/templates/project-default/cybermp.config.json +6 -0
  35. package/templates/project-default/docker-compose.yml +19 -0
  36. package/templates/project-default/package.json +25 -0
  37. package/templates/project-default/pnpm-workspace.yaml +6 -0
  38. package/templates/project-default/server.toml +21 -0
  39. package/templates/project-default/tsconfig.json +7 -0
  40. package/templates/types.json +15 -0
  41. package/tsconfig.base.json +17 -0
@@ -0,0 +1,1040 @@
1
+ /**
2
+ * `@cybermp-community/resource-builder` — project config, project resolution,
3
+ * builds and the `cybermp` CLI.
4
+ *
5
+ * The public surface is re-exported here so the CLI and library consumers share
6
+ * one module.
7
+ */
8
+ import { BrowserBuildConfig, Issue, ResourceManifest } from "@cybermp-community/addon";
9
+ /**
10
+ * The resolved form of an addon — one entry per addon the project loads,
11
+ * whatever its source.
12
+ *
13
+ * Discovery reads each source (a local directory now, npm packages and release
14
+ * archives later) and normalizes it to this shape, so ordering, materialization
15
+ * and building never need to know where an addon came from.
16
+ */
17
+ /** Where an addon was found. */
18
+ type AddonSource = 'local' | 'npm' | 'release' | 'builtin';
19
+ /**
20
+ * How an addon is installed: `source` addons are built from their sources,
21
+ * `prebuilt` addons are copied as they are.
22
+ */
23
+ type AddonKind = 'source' | 'prebuilt';
24
+ interface ResolvedAddon {
25
+ /**
26
+ * Resource name — the directory under the resources dir, and the name used by
27
+ * `addons.order`, `addons.disabled` and `requires`. It is deliberately not the
28
+ * npm package name: one npm package may ship a differently named resource.
29
+ */
30
+ name: string;
31
+ /**
32
+ * npm package name, for addons installed from npm. Undefined for local
33
+ * addons. The lock file records it so an entry can be updated or removed even
34
+ * when the package name and the resource name differ.
35
+ */
36
+ packageName?: string;
37
+ /** Absolute real path of the addon root (the directory holding `package.json`). */
38
+ dir: string;
39
+ /** Package version, or `0.0.0` when the package does not declare one. */
40
+ version: string;
41
+ /** Where the addon was found. */
42
+ source: AddonSource;
43
+ /** Resource names that must load before this addon. */
44
+ requires: string[];
45
+ /** `prebuilt` exactly when the addon's `cybermp.build` is `false`. */
46
+ kind: AddonKind;
47
+ /**
48
+ * `sha256-<hex>` digest of the archive the addon was installed from, for
49
+ * `release` addons — the same value `cybermp.lock.json` records. Undefined for
50
+ * every other source, whose identity comes from the package manager's
51
+ * lockfile or from the project tree itself.
52
+ */
53
+ integrity?: string;
54
+ /**
55
+ * The lock entry's `resolved` value for `release` addons: the release the
56
+ * project pinned. It is not `version` — a lock entry records the tag
57
+ * (`v1.2.0`), while `version` is the version the installed package declares
58
+ * (`1.2.0`).
59
+ */
60
+ resolved?: string;
61
+ }
62
+ /**
63
+ * Resolve every local addon matching `patterns`.
64
+ *
65
+ * Globs are expanded relative to `root`. Non-directory matches are skipped,
66
+ * duplicates (the same directory matched twice, directly or through a symlink)
67
+ * are returned once, and the result is sorted by real path for a deterministic
68
+ * order independent of the filesystem.
69
+ *
70
+ * Errors: glob expansion failures are `addons.glob`, stat/realpath failures are
71
+ * `addons.stat` / `addons.realpath`, a matched directory whose real path leaves
72
+ * the project root is `addons.outside-root`, and a matched directory that is not
73
+ * a valid addon rethrows the addon package's error (`package.missing`,
74
+ * `package.bad-json`, `package.missing-marker`, …) with the directory named in
75
+ * the message.
76
+ */
77
+ export declare function resolveLocalAddons(root: string, patterns: string[]): Promise<ResolvedAddon[]>;
78
+ /** Name of the lock file, relative to the project root. */
79
+ export declare const LOCK_FILENAME = "cybermp.lock.json";
80
+ /** The only lock format this version of the builder understands. */
81
+ export declare const LOCK_VERSION = 1;
82
+ /**
83
+ * Where a locked addon came from.
84
+ *
85
+ * The contract's entry shape admits `npm`, but npm addons are pinned by the
86
+ * package manager and are never recorded here: installers write only `release`
87
+ * and `path` entries, and nothing in this module resolves npm packages.
88
+ */
89
+ type LockSource = 'release' | 'path' | 'npm';
90
+ /**
91
+ * One locked addon, keyed by resource name — deliberately not by package name:
92
+ * one package may ship a differently named resource, and the lock follows the
93
+ * resource the project loads.
94
+ */
95
+ interface LockEntry {
96
+ /** How the addon was installed. */
97
+ source: LockSource;
98
+ /** Exact installed version. */
99
+ resolved: string;
100
+ /** `sha256-…` digest of the downloaded archive, for `release` entries. */
101
+ integrity?: string;
102
+ /** Archive URL the addon was downloaded from, for `release` entries. */
103
+ url?: string;
104
+ /** Project-relative path the addon was installed from, for `path` entries. */
105
+ path?: string;
106
+ /** Release tag requested at install time, when it was not a fixed version. */
107
+ tag?: string;
108
+ /** Whether the entry asked for a pinned tag instead of the latest release. */
109
+ pinned?: boolean;
110
+ }
111
+ /** The parsed contents of `cybermp.lock.json`. */
112
+ interface AddonLock {
113
+ version: typeof LOCK_VERSION;
114
+ addons: Record<string, LockEntry>;
115
+ }
116
+ /**
117
+ * Read `<root>/cybermp.lock.json`.
118
+ *
119
+ * A missing file is an empty lock (a project may have no non-npm addons).
120
+ * Malformed JSON or an entry of the wrong shape is `lock.parse`; both the root
121
+ * key set (`version`, `addons`) and the entry key set are closed, so a hand-edit
122
+ * typo is reported instead of being dropped on the next write — a misspelled
123
+ * `addons` must not read as an empty lock. Every `addons` key must be a
124
+ * non-reserved resource name (`lock.parse` otherwise): the key becomes a
125
+ * directory under the work dir and `ResolvedAddon.name`, so it is validated
126
+ * like one. A `version` other than `1` is
127
+ * `lock.unsupported-version`, so an older builder refuses a newer lock instead
128
+ * of silently reading it partially; the version is checked before the root keys
129
+ * so a future format reports its version, not its new fields.
130
+ */
131
+ export declare function readLock(root: string): AddonLock;
132
+ /**
133
+ * Write `<root>/cybermp.lock.json` deterministically.
134
+ *
135
+ * Entries are sorted by resource name and the file is replaced atomically, so a
136
+ * crashed write cannot leave a half-written lock behind for the next build to
137
+ * parse.
138
+ */
139
+ export declare function writeLock(root: string, lock: AddonLock): void;
140
+ /** The manifest every addon carries; always part of a materialized copy. */
141
+ export declare const MANIFEST_FILENAME = "resource.toml";
142
+ /** File name of the ownership registry, for `join(config.workDir, …)`. */
143
+ export declare const REGISTRY_FILENAME = "built.json";
144
+ /** Manifest fields a project may override on the materialized copy. */
145
+ type Overrides = Partial<Pick<ResourceManifest, 'cef_url' | 'hotreload' | 'use_game_natives'>>;
146
+ /**
147
+ * Materialize `addon` into `<outRoot>/<addon.name>` and return the copied
148
+ * paths, relative to the resource directory, with `resource.toml` first.
149
+ *
150
+ * The target directory is replaced when the registry already owns it, which is
151
+ * what makes a rebuild remove files the addon no longer ships. `overrides`
152
+ * rewrites the copied manifest only.
153
+ *
154
+ * `registryPath` is the ownership list (`<workDir>/built.json`) and is required:
155
+ * it is not derivable from `outRoot`, since the resources dir and the work dir
156
+ * are configured independently. Build it as
157
+ * `join(config.workDir, REGISTRY_FILENAME)` and pass the same path to
158
+ * {@link cleanOwnedDirs}; both read and write it.
159
+ *
160
+ * Precondition: resource names are already unique. Duplicate detection lives in
161
+ * `orderAddons`, which rejects two addons claiming one name; calling this twice
162
+ * for the same name overwrites the earlier copy instead of reporting a clash.
163
+ *
164
+ * Errors: a target directory the registry does not own is
165
+ * `materialize.not-owned`, a resource name that is not a single path segment is
166
+ * `materialize.bad-name`, an unreadable or malformed addon root is
167
+ * `materialize.addon-missing`, a missing manifest is `materialize.no-manifest`,
168
+ * a declared script or `cef_url` that does not exist is `materialize.missing`,
169
+ * a path that leaves the addon root is `materialize.path-outside`, an
170
+ * unreadable glob is `materialize.bad-pattern`, and a malformed registry is
171
+ * `materialize.registry`. A manifest that does not parse keeps the addon
172
+ * package's `manifest.*` code.
173
+ */
174
+ export declare function materializeAddon(addon: ResolvedAddon, outRoot: string, registryPath: string, overrides?: Overrides): Promise<string[]>;
175
+ /**
176
+ * Remove the resource directories named by the registry — and nothing else.
177
+ *
178
+ * A hand-managed resource next to the generated ones is never touched: it has
179
+ * no registry entry, so `materializeAddon` would have refused to take it over
180
+ * as well. A missing registry is a no-op.
181
+ *
182
+ * `names`, when given, limits the sweep to that subset of the registry. A
183
+ * filtered build (`--filter`) rebuilds only the named addons, so it must clean
184
+ * only their directories; an entry outside the subset is left in the registry
185
+ * and its directory is left in place, so a partial build never deletes the
186
+ * output of the addons it did not rebuild.
187
+ *
188
+ * An entry is pruned once its directory has been removed, so a directory the
189
+ * user creates later under that name is foreign: the next build refuses it with
190
+ * `materialize.not-owned` instead of silently deleting it. An entry whose
191
+ * directory is already gone — or whose removal failed — is kept, because the
192
+ * builder may still own that path and a half-finished build must not turn its
193
+ * leftovers into foreign directories. The registry is rewritten atomically, and
194
+ * only when an entry was actually pruned.
195
+ *
196
+ * Errors: a registry that cannot be read, parsed or rewritten is
197
+ * `materialize.registry`.
198
+ */
199
+ export declare function cleanOwnedDirs(registryPath: string, outRoot: string, names?: ReadonlySet<string>): void;
200
+ /**
201
+ * Return the addons in load order: a dependency precedes every addon that
202
+ * requires it, independent addons follow `order` and then their names, and
203
+ * disabled addons are removed.
204
+ *
205
+ * Errors: a resource name supplied by two addons is `addon.duplicate-name`
206
+ * (both sources are named), an `addons.order`, `addons.disabled` or
207
+ * `addons.overrides` entry that names no resolved addon is `order.unknown-name`,
208
+ * a requirement that no addon provides is `order.unknown-requires`, an enabled
209
+ * addon requiring a disabled one is `order.disabled-requires`, and a cycle is
210
+ * `order.cycle` with its members in edge order.
211
+ */
212
+ export declare function orderAddons(addons: ResolvedAddon[], order: string[], disabled: string[], overrides?: readonly string[]): ResolvedAddon[];
213
+ /** Release hosts the toolchain knows how to talk to. */
214
+ type ReleaseHost = 'github' | 'gitlab';
215
+ /** An npm package, optionally at a range; the package manager pins it. */
216
+ interface NpmAddonSpec {
217
+ kind: 'npm';
218
+ /** Package name, scoped or not: `@scope/pkg` or `pkg`. */
219
+ name: string;
220
+ /** Requested range or version, when the spec carried one. */
221
+ range?: string;
222
+ }
223
+ /** A release archive on GitHub or GitLab. */
224
+ interface ReleaseAddonSpec {
225
+ kind: 'release';
226
+ host: ReleaseHost;
227
+ /** `owner/repo`; a GitLab subgroup keeps its extra segments. */
228
+ repo: string;
229
+ /** Release tag, or omitted for the repository's latest release. */
230
+ tag?: string;
231
+ }
232
+ /** A direct link to a release archive. */
233
+ interface UrlAddonSpec {
234
+ kind: 'url';
235
+ url: string;
236
+ }
237
+ /** A directory in the project, or next to it. */
238
+ interface PathAddonSpec {
239
+ kind: 'path';
240
+ path: string;
241
+ }
242
+ /** One parsed addon spec. */
243
+ type AddonSpec = NpmAddonSpec | ReleaseAddonSpec | UrlAddonSpec | PathAddonSpec;
244
+ /** Options of {@link parseAddonSpec}. */
245
+ interface ParseAddonSpecOptions {
246
+ /** Project root a bare name is checked against; defaults to the process cwd. */
247
+ root?: string;
248
+ }
249
+ /**
250
+ * Parse an addon spec.
251
+ *
252
+ * Prefixes and URLs are recognized first, then a filesystem path (explicit `./`,
253
+ * `../`, an absolute path, or a name that exists as a directory), and anything
254
+ * else must be an npm package name. `options.root` is the project root the
255
+ * existence check resolves against; without it the process working directory is
256
+ * used, which is only correct for callers that have no project (the tests).
257
+ *
258
+ * Errors: `spec.empty`, `spec.release`, `spec.url`, `spec.npm`.
259
+ */
260
+ export declare function parseAddonSpec(input: string, options?: ParseAddonSpecOptions): AddonSpec;
261
+ /** Options for {@link installRelease}. */
262
+ interface ReleaseInstallOptions {
263
+ /** Project root; a relative `workDir` is resolved against it. */
264
+ root: string;
265
+ /** Build work directory — the addon is installed under `<workDir>/addons`. */
266
+ workDir: string;
267
+ /** Asset name or glob, required when a release ships several archives. */
268
+ asset?: string;
269
+ /** API root override, e.g. a local HTTP server in tests. */
270
+ apiBase?: string;
271
+ /**
272
+ * Run the full addon validator over the staged tree before replacing an
273
+ * existing installation. `add` and `update` set this so a rejected addon
274
+ * never destroys the version already installed; `install` leaves it off
275
+ * because it restores a lock entry whose integrity is verified against the
276
+ * archive.
277
+ */
278
+ validate?: boolean;
279
+ }
280
+ /** An installed release addon, with the archive integrity for the lock file. */
281
+ interface InstalledRelease extends ResolvedAddon {
282
+ /** `sha256-<hex>` digest of the downloaded archive. */
283
+ integrity: string;
284
+ /** URL the archive was downloaded from. */
285
+ url: string;
286
+ /** Release tag the host resolved (or the spec named); absent for a direct URL. */
287
+ tag?: string;
288
+ /** True when the spec named a tag instead of following the latest release. */
289
+ pinned?: boolean;
290
+ }
291
+ /**
292
+ * Install the addon described by `spec` and return it with its integrity.
293
+ *
294
+ * Only `release` and `url` specs are handled; npm packages belong to the
295
+ * package manager and paths are already in the project, so both are
296
+ * `release.unsupported-spec` here.
297
+ *
298
+ * The returned addon is `source: 'release'` and `kind: 'prebuilt'`: an archive
299
+ * ships the files to copy, so it is never built. `packageName` stays undefined
300
+ * — the archive's `package.json` name is not an npm dependency, exactly as for
301
+ * a local addon. `url`, `tag` and `pinned` carry what a lock entry needs, so
302
+ * the caller never has to re-resolve the release.
303
+ *
304
+ * Errors: `release.unsupported-spec`, `release.ambiguous-asset`,
305
+ * `release.no-asset`, `release.unsupported-archive`, `release.not-found`,
306
+ * `release.auth`, `release.rate-limit`, `release.http`, `release.network`,
307
+ * `release.bad-response`, `release.download`, `release.integrity`,
308
+ * `release.bad-archive`, `release.extract`, `release.not-an-addon`,
309
+ * `release.install`, `release.redirect`.
310
+ */
311
+ export declare function installRelease(spec: AddonSpec, opts: ReleaseInstallOptions): Promise<InstalledRelease>;
312
+ /**
313
+ * Produce `<resourceDir>/browser` from the `browser/` directory of `addonDir`.
314
+ *
315
+ * `resourceDir` is the addon's own output directory (`<out>/<name>`), not the
316
+ * resources directory. A missing `browser/` directory is not an error: the
317
+ * addon simply has no browser UI and `<resourceDir>/browser` is left untouched,
318
+ * since materialization never writes one for a source addon.
319
+ */
320
+ export declare function runBrowserBuild(addonDir: string, resourceDir: string, browser: BrowserBuildConfig | undefined): Promise<void>;
321
+ /** Name of the optional project configuration file, relative to the root. */
322
+ export declare const CONFIG_FILENAME = "cybermp.config.json";
323
+ /** Manifest fields a project may override on a materialized addon copy. */
324
+ type AddonOverride = Partial<Pick<ResourceManifest, 'cef_url' | 'hotreload' | 'use_game_natives'>>;
325
+ interface ProjectConfig {
326
+ /** Real path of the project root. */
327
+ root: string;
328
+ /**
329
+ * Directory passed to `-rdir`. Always absolute; defaults to
330
+ * `<root>/resources`.
331
+ */
332
+ resourcesDir: string;
333
+ /**
334
+ * Build state directory (compiler cache, unpacked release addons). Always
335
+ * absolute; defaults to `<root>/.cybermp`.
336
+ */
337
+ workDir: string;
338
+ addons: {
339
+ /**
340
+ * Directory globs, relative to `root`; absolute globs and `..` segments
341
+ * are rejected. Default `['addons/*']`.
342
+ */
343
+ local: string[];
344
+ /** Explicit load order; unlisted addons follow in graph order. */
345
+ order: string[];
346
+ /** Manifest edits applied to the materialized copy, keyed by addon name. */
347
+ overrides: Record<string, AddonOverride>;
348
+ /** Addons kept installed but neither built nor listed in `server.toml`. */
349
+ disabled: string[];
350
+ /** Hand-managed resources in `resourcesDir`, copied into `server.toml` as-is. */
351
+ extraResources: string[];
352
+ };
353
+ redscripts: {
354
+ /** Whether `final_redscripts` is built at all. Default `true`. */
355
+ enabled: boolean;
356
+ /** Pinned `redscript-cli` version. Default `'0.5.31'`. */
357
+ compilerVersion: string;
358
+ /**
359
+ * Optional platform whose compiler and core baseline are used. Consumers
360
+ * resolve the effective platform: this field, then `server.platforms[0]`,
361
+ * then the host platform.
362
+ */
363
+ platform?: 'win' | 'linux';
364
+ /**
365
+ * `'core'` (core baseline), `'none'` (compile with core sources; refused
366
+ * without `CYBERMP_REDSCRIPT_COMPILER` because the pinned compiler needs
367
+ * `-b`) or a path.
368
+ */
369
+ baseline: 'core' | 'none' | string;
370
+ /** Output resource name. Default `'final_redscripts'`. */
371
+ output: string;
372
+ };
373
+ server: {
374
+ /** Platform builds to keep downloaded. Default: the host platform. */
375
+ platforms: Array<'win' | 'linux'>;
376
+ /** Pinned server release tag; latest when absent. */
377
+ version?: string;
378
+ };
379
+ }
380
+ /**
381
+ * Read and validate `<root>/cybermp.config.json`, synchronously.
382
+ *
383
+ * Same contract as {@link loadConfig}. The addon commands write the config
384
+ * through {@link writeAddonConfig}, and a caller (or a test) that has just run
385
+ * one can read the result back without awaiting.
386
+ */
387
+ export declare function loadConfigSync(root: string): ProjectConfig;
388
+ /**
389
+ * Read and validate `<root>/cybermp.config.json`.
390
+ *
391
+ * A missing file yields the defaults; malformed JSON is `config.parse`, an
392
+ * unknown key (at any level) is `config.unknown-key`, and a value of the wrong
393
+ * shape is `config.bad-type`.
394
+ */
395
+ export declare function loadConfig(root: string): Promise<ProjectConfig>;
396
+ /**
397
+ * The `addons` fields the addon commands may rewrite in
398
+ * `cybermp.config.json`.
399
+ *
400
+ * The writer touches only these documented keys: every other key in the file
401
+ * (including `$schema`, `addons.overrides` and the build settings) is preserved
402
+ * exactly as written, so `cybermp add` never re-serializes a hand-tuned config
403
+ * from the defaults it resolves.
404
+ */
405
+ interface AddonConfigEdit {
406
+ /** Replace `addons.local` when given. */
407
+ local?: string[];
408
+ /** Replace `addons.order` when given. */
409
+ order?: string[];
410
+ /** Replace `addons.disabled` when given. */
411
+ disabled?: string[];
412
+ }
413
+ /**
414
+ * Rewrite the documented `addons` keys of `<root>/cybermp.config.json`.
415
+ *
416
+ * The file is re-read as raw JSON first, so keys this version of the builder
417
+ * does not understand yet survive the edit; only the given keys are replaced.
418
+ * The write is atomic (temporary file plus rename), and a failed write is
419
+ * `config.write`.
420
+ *
421
+ * Errors: `config.read`, `config.parse`, `config.bad-type` from reading the
422
+ * existing file, and `config.write` when it cannot be replaced.
423
+ */
424
+ export declare function writeAddonConfig(root: string, edit: AddonConfigEdit): void;
425
+ /** Flags accepted by `buildProject`; only `filter` and `noBrowser` act today. */
426
+ interface BuildOptions {
427
+ /** Build only the addon whose resource name matches exactly. */
428
+ filter?: string;
429
+ /** Skip the browser (CEF) build of local addons; an existing `browser/` is kept. */
430
+ noBrowser?: boolean;
431
+ /** Skip the redscripts stage — no compile, no `final_redscripts` in the list. */
432
+ noRedscripts?: boolean;
433
+ }
434
+ /** What one build did, for the CLI to print and for callers to inspect. */
435
+ interface BuildReport {
436
+ /** Real path of the project root. */
437
+ root: string;
438
+ /**
439
+ * Resource names in load order, exactly as written to `server.toml` — the
440
+ * full resolved list even on a filtered build.
441
+ */
442
+ resources: string[];
443
+ /** The addons this run built or materialized, in load order (a filtered build lists only the selected subset). */
444
+ addons: ResolvedAddon[];
445
+ }
446
+ /**
447
+ * Build `root` end to end (spec §9.3) and report what was written.
448
+ *
449
+ * Errors keep the stable `area.reason` codes of the modules they come from:
450
+ * resolution and ordering failures, `materialize.*`, `build.*`, `serverToml.*`
451
+ * and `redscripts.*` all surface unchanged, so a caller can match them the same
452
+ * way it matches any other builder error.
453
+ */
454
+ export declare function buildProject(root: string, options?: BuildOptions): Promise<BuildReport>;
455
+ /** Options for {@link buildLocalAddon}. */
456
+ interface BuildLocalOptions {
457
+ /** Skip only the browser (CEF) build; client and server still bundle. */
458
+ noBrowser?: boolean;
459
+ }
460
+ /**
461
+ * Build one local addon into `<outDir>/<addon.name>`.
462
+ *
463
+ * `outDir` is resolved against `config.root` when relative, so callers may pass
464
+ * either the configured resources directory or a path produced by joining it.
465
+ * The resource name is used as a single directory name; uniqueness is already
466
+ * enforced by ordering before the build runs.
467
+ */
468
+ export declare function buildLocalAddon(addon: ResolvedAddon, outDir: string, config: ProjectConfig, options?: BuildLocalOptions): Promise<void>;
469
+ /** The result of one project check. */
470
+ interface CheckResult {
471
+ /** True when no issue is at error level; warnings never fail the check. */
472
+ ok: boolean;
473
+ /** Every issue, in discovery order: server.toml first, then per addon. */
474
+ issues: Issue[];
475
+ }
476
+ /** Build flags that change what the next build would write. */
477
+ interface CheckOptions {
478
+ /** Expect the list `build --no-redscripts` writes: no generated resource. */
479
+ noRedscripts?: boolean;
480
+ }
481
+ /**
482
+ * Re-resolve `root` and compare it against the on-disk state.
483
+ *
484
+ * See the module comment for the two checks and the error contract.
485
+ */
486
+ export declare function checkProject(root: string, options?: CheckOptions): Promise<CheckResult>;
487
+ /** Package managers the builder knows how to drive. */
488
+ type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
489
+ /** Options of {@link addAddon}, mirroring the `add` flags. */
490
+ interface AddAddonOptions {
491
+ /** Insert the addon first in `addons.order`. */
492
+ first?: boolean;
493
+ /** Insert the addon directly before this `addons.order` name. */
494
+ before?: string;
495
+ /** Insert the addon directly after this `addons.order` name. */
496
+ after?: string;
497
+ /** Release asset name or glob, required when a release ships several archives. */
498
+ asset?: string;
499
+ /** Snapshot a local path into `<root>/addons/<resource>` instead of registering it. */
500
+ copy?: boolean;
501
+ /** Package manager override for npm specs. */
502
+ pm?: PackageManager;
503
+ /** Release API root override (a local server in tests). */
504
+ apiBase?: string;
505
+ }
506
+ /** A removed addon, for the CLI's one-line report. */
507
+ interface RemovedAddon {
508
+ name: string;
509
+ source: LockSource | 'npm' | 'local';
510
+ }
511
+ /** One row of {@link listAddons}. */
512
+ interface AddonListing {
513
+ name: string;
514
+ version: string;
515
+ source: AddonSource;
516
+ /** 1-based position in the resolved load order; absent for a disabled addon. */
517
+ order?: number;
518
+ }
519
+ /** Options of {@link installProject}. */
520
+ interface InstallOptions {
521
+ /** Package manager override. */
522
+ pm?: PackageManager;
523
+ }
524
+ /** What {@link installProject} did. */
525
+ interface InstallReport {
526
+ /** Package manager that would run (or ran) the dependency install. */
527
+ packageManager: PackageManager;
528
+ /** False when the project has no `package.json` and the package manager was skipped. */
529
+ ranPackageManager: boolean;
530
+ /** Release addons that were missing and restored from the lock. */
531
+ restored: string[];
532
+ }
533
+ /** Options of {@link updateAddon}. */
534
+ interface UpdateOptions {
535
+ /** Release API root override (a local server in tests). */
536
+ apiBase?: string;
537
+ }
538
+ /** What {@link updateAddon} did to one addon. */
539
+ interface UpdateResult {
540
+ name: string;
541
+ /** `resolved` before the update. */
542
+ from: string;
543
+ /** `resolved` after the update. */
544
+ to: string;
545
+ /** False when the entry was pinned or already at the resolved version. */
546
+ changed: boolean;
547
+ /** True when the lock entry now pins a tag. */
548
+ pinned: boolean;
549
+ }
550
+ /**
551
+ * Install one addon from any source and record it in the project.
552
+ *
553
+ * - a path is validated and registered in `addons.local` (or snapshotted with
554
+ * `copy`), and gets a `path` lock entry with the directory hash;
555
+ * - an npm package is installed with the project's package manager;
556
+ * - a release or direct URL goes through `installRelease`, is validated in
557
+ * place, and gets a `release` lock entry with its URL, integrity and tag.
558
+ *
559
+ * The resource name is appended to `addons.order` unless it is already there;
560
+ * `first`/`before`/`after` reposition it. Nothing is recorded until the addon
561
+ * has validated.
562
+ *
563
+ * Errors keep the source's own codes (`spec.*`, `add.*`, `pm.*`, `npm.*`,
564
+ * `release.*`) and validation failures keep the validator's code
565
+ * (`package.missing-marker`, `manifest.*`, `path.*`, …).
566
+ */
567
+ export declare function addAddon(root: string, spec: string, options?: AddAddonOptions): Promise<ResolvedAddon>;
568
+ /**
569
+ * Remove an addon by resource name or by npm package name.
570
+ *
571
+ * A lock entry (release or path) is deleted; an npm dependency is removed with
572
+ * the package manager; a local addon that `cybermp create addon` registered is
573
+ * dropped from `addons.local` and its directory deleted once no remaining glob
574
+ * matches it. The resource name is dropped from `addons.order` and
575
+ * `addons.disabled`, and a path entry that was registered in `addons.local` is
576
+ * dropped from it — a broad glob that still matches the directory is left
577
+ * alone, because it also covers other addons.
578
+ *
579
+ * Errors: `remove.not-found` when the lock, the project's `dependencies` and
580
+ * `addons.local` all lack the name; `remove.outside-root` when a matched local
581
+ * entry resolves outside the project; `pm.*` when the package manager fails.
582
+ */
583
+ export declare function removeAddon(root: string, nameOrPackage: string, options?: {
584
+ pm?: PackageManager;
585
+ }): Promise<RemovedAddon>;
586
+ /**
587
+ * Resolve every installed addon with its load-order position.
588
+ *
589
+ * Local and npm addons are resolved the way a build resolves them — through
590
+ * {@link resolveNpmAddonsChecked}, so a missing npm dependency fails with the
591
+ * same `cybermp install` hint here as it does from `build`; release addons come
592
+ * from the lock (their installed directory supplies the version and
593
+ * requirements when it is still present). A stale
594
+ * `addons.order`/`disabled`/`overrides` entry is ignored here instead of
595
+ * failing the listing — `cybermp check` is the command that reports it.
596
+ */
597
+ export declare function listAddons(root: string): Promise<AddonListing[]>;
598
+ /**
599
+ * Install the project's dependencies and restore missing release addons.
600
+ *
601
+ * `<pm> install` restores npm addons from the package manager lockfile (and is
602
+ * skipped when the project has no `package.json`). Every
603
+ * `release` lock entry whose installation under `<workDir>/addons/` is gone or
604
+ * no longer verifies — no install record, another archive, or files that changed
605
+ * after installation — is downloaded again from the URL the lock recorded and
606
+ * checked against the recorded integrity; a mismatch is `lock.integrity` and the
607
+ * downloaded addon is removed. A `path` entry whose directory no longer exists is
608
+ * `lock.path-missing` (re-add it, or remove it from the lock).
609
+ */
610
+ export declare function installProject(root: string, options?: InstallOptions): Promise<InstallReport>;
611
+ /**
612
+ * Re-resolve addons from their source and rewrite the lock.
613
+ *
614
+ * Releases follow their source: an unpinned entry re-resolves the latest
615
+ * release (or re-downloads a direct URL, whose content may move), `--to`
616
+ * installs and pins that tag, and a pinned entry stays put without `--to`.
617
+ * Path entries recompute their directory hash and version. With no name every
618
+ * lock entry is updated.
619
+ *
620
+ * Errors: `update.unknown-addon` for a name the lock does not hold,
621
+ * `update.unsupported` for `--to` on a source whose repository cannot be
622
+ * derived, `lock.incomplete`/`lock.path-missing` for a broken entry, and the
623
+ * release/validator codes for a failed install.
624
+ */
625
+ export declare function updateAddon(root: string, name?: string, to?: string, options?: UpdateOptions): Promise<UpdateResult[]>;
626
+ /** Realms that run against an `mp` global and therefore need a type package. */
627
+ export declare const TYPED_REALMS: readonly ['client', 'server', 'browser'];
628
+ /** One realm with an `mp` global (`shared` is plain TypeScript). */
629
+ type TypedRealm = (typeof TYPED_REALMS)[number];
630
+ /** One published set of type packages. */
631
+ type TypeSet = 'community' | 'official';
632
+ /**
633
+ * Which type packages to pin.
634
+ *
635
+ * `none` installs no package at all: the scaffold declares the `mp` global as
636
+ * `unknown` so an addon that does not need the API still typechecks.
637
+ */
638
+ type TypesMode = TypeSet | 'none';
639
+ /** Every mode `--types` accepts, in the order the CLI lists them. */
640
+ export declare const TYPES_MODES: readonly TypesMode[];
641
+ /** The parsed table: both sets plus the gate's blocker notes. */
642
+ interface TypeTable {
643
+ community: Readonly<Record<string, string>>;
644
+ official: Readonly<Record<string, string>>;
645
+ /** Community package suffix → why the gate could not accept it. */
646
+ blocked: Readonly<Record<string, string>>;
647
+ }
648
+ /** One resolved type package. */
649
+ interface TypePin {
650
+ realm: TypedRealm;
651
+ /** Package name, e.g. `@cybermp/client-types`. */
652
+ name: string;
653
+ /** Version without a range operator, e.g. `2.7.1`. */
654
+ version: string;
655
+ /** The set the pin came from. */
656
+ set: TypeSet;
657
+ }
658
+ /** Pins of the realms a caller asked for. */
659
+ type TypePins = ReadonlyMap<TypedRealm, TypePin>;
660
+ /**
661
+ * Resolve one pin per requested realm.
662
+ *
663
+ * `mode` selects a set; `none` pins nothing and returns an empty map. Without a
664
+ * mode every realm uses the official set — the community set is opt-in with
665
+ * `--types=community` until the gate accepts it for every realm.
666
+ *
667
+ * Errors: `types.file`, `types.missing`, `types.blocked`.
668
+ */
669
+ export declare function resolveTypePins(realms: readonly TypedRealm[], mode?: TypesMode): TypePins;
670
+ /** Options of {@link initProject}. */
671
+ interface InitOptions {
672
+ /** Project directory to create or fill; `.` is the current directory. */
673
+ dir: string;
674
+ /** Template directory name inside the package; defaults to `project-default`. */
675
+ template?: string;
676
+ /** Package manager override, as passed to `--pm`. */
677
+ pm?: string;
678
+ /** Run `<pm> install` after rendering. Defaults to `true`. */
679
+ install?: boolean;
680
+ /** Include the biome config and its dev dependency. Defaults to `true`. */
681
+ lint?: boolean;
682
+ /**
683
+ * Which type-package set to pin (`--types`). Absent pins the official set;
684
+ * `community` opts into the community packages, `none` into no package.
685
+ */
686
+ types?: TypesMode;
687
+ /** Render into a non-empty directory, overwriting the files the template names. */
688
+ force?: boolean;
689
+ }
690
+ /** What the install step did, for the CLI's next-steps output. */
691
+ interface InitReport {
692
+ /** Absolute path of the project root. */
693
+ dir: string;
694
+ /** Project name written into `package.json`. */
695
+ name: string;
696
+ /** Package manager the project was written for. */
697
+ packageManager: PackageManager;
698
+ /** Whether `<pm> install` ran. */
699
+ installed: boolean;
700
+ }
701
+ /**
702
+ * Scaffold a project into `options.dir`.
703
+ *
704
+ * See the module comment for the order of operations and the error contract.
705
+ */
706
+ export declare function initProject(options: InitOptions): Promise<InitReport>;
707
+ /**
708
+ * The package manager `init` writes into the project.
709
+ *
710
+ * An explicit `--pm` wins and must be one the builder drives. Otherwise the
711
+ * target's own manifest or lockfile decides, so `init --force` inside an
712
+ * existing project keeps that project's manager; a brand-new directory has
713
+ * nothing to detect and gets `pnpm`, which the shipped template's workspace
714
+ * layout and lockfile examples assume.
715
+ *
716
+ * Errors: `init.package-manager` for an unsupported name, `pm.unsupported` when
717
+ * the target's `packageManager` field names one.
718
+ */
719
+ export declare function initPackageManager(dir: string, explicit?: string): PackageManager;
720
+ /**
721
+ * The lines `cybermp init` prints after a successful scaffold: what was created
722
+ * and the three commands that take the project to a running server.
723
+ */
724
+ export declare function initNextSteps(report: InitReport): string;
725
+ /** Every build target an addon may ship. */
726
+ export declare const ADDON_REALMS: readonly ['client', 'server', 'shared', 'browser'];
727
+ /** One build target of an addon. */
728
+ type AddonRealm = (typeof ADDON_REALMS)[number];
729
+ /** Options of {@link createAddon}. */
730
+ interface CreateAddonOptions {
731
+ /** Resource name and directory name under `<project>/addons`. */
732
+ name: string;
733
+ /** Project root the addon is created in; defaults to the current directory. */
734
+ dir?: string;
735
+ /** Realms to scaffold; defaults to client and server. */
736
+ realms?: readonly AddonRealm[];
737
+ /** Include the shared realm without having to name it in `realms`. */
738
+ shared?: boolean;
739
+ /** Run `<pm> install` after writing. Defaults to `true`. */
740
+ install?: boolean;
741
+ /** Package manager override, as passed to `--pm`. */
742
+ pm?: PackageManager;
743
+ /**
744
+ * Which type-package set to pin (`--types`). Absent pins the official set;
745
+ * `community` opts into the community packages, `none` installs no type
746
+ * package and declares `mp` as `unknown`.
747
+ */
748
+ types?: TypesMode;
749
+ }
750
+ /**
751
+ * Scaffold `options.name` into `<project>/addons` and return the new addon
752
+ * directory.
753
+ *
754
+ * See the module comment for the order of operations and the error contract.
755
+ */
756
+ export declare function createAddon(options: CreateAddonOptions): Promise<string>;
757
+ /**
758
+ * The builder's error type.
759
+ *
760
+ * Same contract as `AddonError` in `@cybermp-community/addon`: a stable,
761
+ * machine-readable `code` of the shape `area.reason` (for example
762
+ * `config.unknown-key`) and a message formatted as `<code>: <human message>`,
763
+ * so callers can match codes with a regex and still print something readable.
764
+ */
765
+ export declare class BuilderError extends Error {
766
+ /** Stable code, e.g. `config.parse`. Never localized. */
767
+ readonly code: string;
768
+ constructor(code: string, message: string);
769
+ }
770
+ interface ResolvedProject {
771
+ /** Validated project configuration; every path is absolute. */
772
+ config: ProjectConfig;
773
+ /** Every resolved addon, disabled ones included, in discovery order. */
774
+ addons: ResolvedAddon[];
775
+ /**
776
+ * The enabled addons in load order — dependencies before their dependents,
777
+ * ties broken by `addons.order` then resource name. This is the order the
778
+ * `resources` array of `server.toml` must follow.
779
+ */
780
+ ordered: ResolvedAddon[];
781
+ }
782
+ /**
783
+ * Read `<root>/cybermp.config.json` and resolve every source of addons.
784
+ *
785
+ * The globs come from the config and are expanded relative to the real project
786
+ * root, so a project relocated on disk keeps working. Resolution also orders
787
+ * the addons: a duplicate resource name, an `addons.order` or `addons.disabled`
788
+ * entry that names nothing, an unknown or disabled requirement, or a `requires`
789
+ * cycle fails the whole project rather than being reported later by the build.
790
+ *
791
+ * Errors: `config.*` while the config is read, `addons.*` from local
792
+ * resolution, `npm.missing-dependency` (with an install hint) when a declared
793
+ * dependency is not installed, the release verifier's codes when a locked
794
+ * installation is missing, unverifiable or outside the work directory, and
795
+ * `addon.*` from ordering.
796
+ */
797
+ export declare function resolveProject(root: string): Promise<ResolvedProject>;
798
+ /** One `.reds` source: the addon that ships it and the absolute file path. */
799
+ interface RedscriptSource {
800
+ /** Resource name of the addon that owns the file. */
801
+ addon: string;
802
+ /** Absolute path of the `.reds` file. */
803
+ file: string;
804
+ }
805
+ /** Options for {@link buildRedscripts}. */
806
+ interface BuildRedscriptsOptions {
807
+ /** Sources collected by {@link collectRedscripts}; empty copies the baseline. */
808
+ sources: RedscriptSource[];
809
+ /**
810
+ * Compiled baseline (a `REDS` cache) the sources are compiled against.
811
+ *
812
+ * Omitted only for the `baseline: 'none'` project setting, where the core
813
+ * sources are compiled without a precompiled bundle. `redscript-cli` 0.5.31
814
+ * requires `-b`, so that mode needs a compiler that accepts a baseline-less
815
+ * compile; the pinned compiler reports the missing bundle itself.
816
+ */
817
+ baseline?: string;
818
+ /** Directory that receives `final.redscripts` and `resource.toml`. */
819
+ outputDir: string;
820
+ /**
821
+ * Path of the `redscript-cli` binary to run. Required as soon as `sources` is
822
+ * non-empty; a source-free run only copies the baseline, so the caller that
823
+ * skips compiler resolution passes nothing.
824
+ */
825
+ compiler?: string;
826
+ /** Build work directory; staging and the compile log live under `redscripts/`. */
827
+ workDir: string;
828
+ /** How long the compiler may run, in milliseconds; defaults to ten minutes. */
829
+ timeoutMs?: number;
830
+ }
831
+ /** File name of the compiled cache inside the resource directory. */
832
+ export declare const REDSCRIPTS_FILENAME = "final.redscripts";
833
+ /** Name of the compiler log, relative to {@link WORK_SUBDIR}. */
834
+ export declare const LOG_FILENAME = "compile.log";
835
+ /**
836
+ * Collect every `.reds` file the addons' manifests reference, in addon order.
837
+ *
838
+ * Patterns are expanded by {@link expandFilePattern}, so globs and literal
839
+ * paths behave exactly as they do during materialization, and a pattern or
840
+ * match that resolves outside the addon is `redscripts.path-outside`.
841
+ *
842
+ * A name shared by two different files — compared case-insensitively — is
843
+ * `redscripts.collision`; the compiler's flat staging directory would drop one
844
+ * of them otherwise.
845
+ *
846
+ * Errors: an unreadable manifest is `redscripts.no-manifest`; manifest syntax
847
+ * and shape errors keep the addon package's `manifest.*` codes; pattern and
848
+ * containment failures are `redscripts.path-outside`, `redscripts.bad-pattern`,
849
+ * `redscripts.addon-missing` and `redscripts.read`.
850
+ */
851
+ export declare function collectRedscripts(addons: ResolvedAddon[]): RedscriptSource[];
852
+ /**
853
+ * Compile `sources` against `baseline` into `outputDir`.
854
+ *
855
+ * Writes `<outputDir>/final.redscripts` and a `resource.toml` that lists it,
856
+ * with `hotreload = false` (the cache is a build artifact, not something the
857
+ * game reloads in place). The compile log is written under
858
+ * `<workDir>/redscripts/compile.log` whenever sources were compiled.
859
+ *
860
+ * Errors: `redscripts.compile-failed` (non-zero exit, timeout, spawn failure,
861
+ * or an explicit `error:` diagnostic) with the log path in the message,
862
+ * `redscripts.output` (missing or non-`REDS` output), `redscripts.missing`
863
+ * (a collected source that is no longer on disk), and `compiler.missing`
864
+ * (sources to compile but no `redscript-cli` path).
865
+ */
866
+ export declare function buildRedscripts(opts: BuildRedscriptsOptions): Promise<void>;
867
+ /**
868
+ * Pinned compiler artifacts — internal to the package.
869
+ *
870
+ * The digest pin is the security boundary for the downloaded binary, so this
871
+ * module is deliberately not re-exported from the package entry point:
872
+ * `resolveCompiler` is the only public way to reach it. Keeping the table in
873
+ * its own module also leaves exactly one seam for the tests, which point the
874
+ * entry at a binary they generate in-flight instead of committing one.
875
+ */
876
+ /** Platforms with a pinned compiler binary. Other values are an error. */
877
+ type CompilerPlatform = 'win' | 'linux';
878
+ /** Options for {@link resolveCompiler}. */
879
+ interface CompilerOptions {
880
+ /** Build work directory; the compiler caches under `<workDir>/redscript-cli`. */
881
+ workDir: string;
882
+ /** Pinned compiler version, e.g. `0.5.31`. */
883
+ version: string;
884
+ /** Platform the compiler runs on. */
885
+ platform: CompilerPlatform;
886
+ /** Release base URL override, e.g. a local HTTP server in tests. */
887
+ downloadBase?: string;
888
+ }
889
+ /**
890
+ * Return the path of the pinned compiler for `version`/`platform`, downloading
891
+ * and verifying it into the cache on first use.
892
+ *
893
+ * `CYBERMP_REDSCRIPT_COMPILER` wins over everything: it is returned verbatim
894
+ * without touching the filesystem or the network, which is also how a locally
895
+ * built compiler is used.
896
+ */
897
+ export declare function resolveCompiler(opts: CompilerOptions): Promise<string>;
898
+ /**
899
+ * `cybermp download` — fetch the CyberMP server binaries into the work
900
+ * directory.
901
+ *
902
+ * The server is distributed as platform zips on GitHub Releases
903
+ * (`Cyber-MP/CyberMP-Server-Releases`): `cybermp-server-win64-build-<tag>.zip`
904
+ * and `cybermp-server-linux-build-<tag>.zip`. One tag is used for every
905
+ * platform, so a run resolves `latest` once — through
906
+ * `api.github.com/repos/.../releases/latest` — and then downloads the same tag
907
+ * everywhere.
908
+ *
909
+ * The tag is `version`, else `CYBERMP_VERSION`, else `latest`. The platform is
910
+ * always the one requested, never the host: a Linux machine can fetch the
911
+ * Windows build, which is what `server.platforms` exists for.
912
+ *
913
+ * Layout: every build is unpacked into `<workDir>/mp/<win|linux>/` and marked
914
+ * with `<workDir>/mp/<platform>/.cybermp-version` holding the tag it came from.
915
+ * The Linux binary is made executable (`0o755`) because zip archives carry no
916
+ * usable permission bits for it.
917
+ *
918
+ * Integrity: CyberMP publishes no sha256 manifest, so a download is trusted
919
+ * only when (a) the bytes received match the `content-length` the host
920
+ * declared and (b) the archive unpacks. Both checks run before anything is
921
+ * moved into place. A host that declares no length (a chunked mirror) skips
922
+ * only check (a) — the unpack still has to succeed.
923
+ *
924
+ * Atomicity: each platform is unpacked into a temporary directory beside its
925
+ * target and moved in only after the archive arrived whole and unpacked. A
926
+ * failed download therefore leaves no half-unpacked tree — and never destroys
927
+ * the build already installed. Leftovers a crashed run left behind (a
928
+ * `.previous-*` tree or a `.<platform>-*` staging directory) are swept when the
929
+ * download starts, so they can neither accumulate nor hide a build.
930
+ *
931
+ * `base` (or `CYBERMP_DOWNLOAD_BASE`) replaces the download root for mirrors
932
+ * and offline caches; `apiBase` replaces the GitHub API root, so both can be
933
+ * pointed at a local server in tests.
934
+ *
935
+ * Errors: `server.platforms` (nothing requested), `server.version` (the latest
936
+ * release cannot be resolved), `server.download` (network, HTTP status, or the
937
+ * body could not be saved), `server.integrity` (truncated body), and
938
+ * `server.extract` (unreadable archive, or an entry that is not a plain file or
939
+ * directory inside the build — traversal, absolute path, empty name, symlink).
940
+ */
941
+ /** The build targets CyberMP ships binaries for. */
942
+ type ServerPlatform = 'win' | 'linux';
943
+ /** Marker file written into `<workDir>/mp/<platform>/`; holds the tag. */
944
+ export declare const VERSION_MARKER = ".cybermp-version";
945
+ /** Name of the Linux server binary inside an unpacked build. */
946
+ export declare const SERVER_BINARY = "cybermp-server";
947
+ /** Name of the Windows server binary inside an unpacked build. */
948
+ export declare const SERVER_BINARY_WIN = "cybermp-server.exe";
949
+ /** Options for {@link downloadServer}. */
950
+ interface DownloadOptions {
951
+ /** Build work directory; builds land under `<workDir>/mp/<platform>`. */
952
+ workDir: string;
953
+ /** Release tag to install; `version`, else `CYBERMP_VERSION`, else latest. */
954
+ version?: string;
955
+ /** Platforms to install; the caller decides, never the host. */
956
+ platforms: ServerPlatform[];
957
+ /** Download root override, e.g. a mirror or a local server in tests. */
958
+ base?: string;
959
+ /** GitHub API root override, used only to resolve `latest`. */
960
+ apiBase?: string;
961
+ }
962
+ /**
963
+ * Download the requested server builds into `<workDir>/mp/<platform>`.
964
+ *
965
+ * Platforms are fetched one after another; a failure stops the run and leaves
966
+ * the platforms already installed untouched. The tag is resolved once, so a
967
+ * multi-platform run installs one consistent version.
968
+ *
969
+ * Errors: `server.platforms`, `server.version`, `server.download`,
970
+ * `server.integrity`, `server.extract`.
971
+ */
972
+ export declare function downloadServer(opts: DownloadOptions): Promise<void>;
973
+ /** The directory one platform's build occupies. */
974
+ export declare function serverDir(workDir: string, platform: ServerPlatform): string;
975
+ /** The platform the host runs, matching the only two targets CyberMP ships. */
976
+ export declare function hostPlatform(): ServerPlatform;
977
+ /** Read the tag installed for `platform`, or `undefined` when there is none. */
978
+ export declare function readInstalledVersion(workDir: string, platform: ServerPlatform): Promise<string | undefined>;
979
+ /** Options for {@link runServer}. */
980
+ interface RunOptions {
981
+ /** Project root; the server's working directory. */
982
+ root: string;
983
+ /** Build work directory holding `mp/<platform>`. */
984
+ workDir: string;
985
+ /** Directory passed to `-rdir` (the project's `resourcesDir`). */
986
+ resourcesDir: string;
987
+ /** Run with `NODE_ENV=production` instead of `development`. */
988
+ prod?: boolean;
989
+ /** Build to start; defaults to the host platform. */
990
+ platform?: ServerPlatform;
991
+ }
992
+ /**
993
+ * Start the server for `platform` and resolve with its combined output once it
994
+ * exits.
995
+ *
996
+ * A non-zero exit is applied to `process.exitCode`, so the CLI exits with the
997
+ * child's code; a successful run leaves the exit code alone.
998
+ *
999
+ * Errors: `server.binary-missing`, `server.spawn`.
1000
+ */
1001
+ export declare function runServer(opts: RunOptions): Promise<string>;
1002
+ /**
1003
+ * Render `srcDir` into `destDir`, replacing `__NAME__` with `vars.NAME`.
1004
+ *
1005
+ * `vars` is keyed by the bare token name (`PROJECT_NAME` for
1006
+ * `__PROJECT_NAME__`); a token without a value is an error rather than a
1007
+ * literal left in the generated project, because a placeholder that reaches a
1008
+ * user is a broken scaffold.
1009
+ *
1010
+ * Files that already exist under `destDir` are overwritten — `init` refuses a
1011
+ * non-empty target on its own, and `--force` means "render over it".
1012
+ */
1013
+ export declare function renderTemplate(srcDir: string, destDir: string, vars: Record<string, string>): Promise<void>;
1014
+ /** A parsed `resources` list together with the span of its array in the text. */
1015
+ interface ResourceList {
1016
+ /** Resource names, in load order. */
1017
+ names: string[];
1018
+ /** Offset of the opening `[` of the array. */
1019
+ start: number;
1020
+ /** Offset just past the closing `]` of the array. */
1021
+ end: number;
1022
+ }
1023
+ /**
1024
+ * Read the top-level `resources` array of `server.toml`.
1025
+ *
1026
+ * Throws `serverToml.missing-resources` when the key is absent (or only
1027
+ * appears after the first table, where TOML would not read it as top-level),
1028
+ * `serverToml.invalid` when it is not an array of strings, and
1029
+ * `serverToml.parse` when the array itself is not valid TOML.
1030
+ */
1031
+ export declare function readResourceList(text: string): ResourceList;
1032
+ /**
1033
+ * Replace the top-level `resources` array with `names`.
1034
+ *
1035
+ * Only the array span changes; everything else in the file is returned
1036
+ * untouched. With no key, the list is inserted before the first table (or
1037
+ * appended when the file has none), using the file's own line ending.
1038
+ */
1039
+ export declare function writeResourceList(text: string, names: string[]): string;
1040
+ export type { AddAddonOptions, AddonConfigEdit, AddonKind, AddonListing, AddonLock, AddonOverride, AddonRealm, AddonSource, AddonSpec, BuildOptions, BuildRedscriptsOptions, BuildReport, CheckOptions, CheckResult, CompilerOptions, CompilerPlatform, CreateAddonOptions, DownloadOptions, InitOptions, InitReport, InstallOptions, InstallReport, InstalledRelease, LockEntry, LockSource, NpmAddonSpec, Overrides, ParseAddonSpecOptions, PathAddonSpec, ProjectConfig, RedscriptSource, ReleaseAddonSpec, ReleaseHost, ReleaseInstallOptions, RemovedAddon, ResolvedAddon, ResolvedProject, ResourceList, RunOptions, ServerPlatform, TypePin, TypePins, TypeTable, TypedRealm, TypesMode, UpdateOptions, UpdateResult, UrlAddonSpec };