@bscotch/stitch
Version:
Stitch: The GameMaker Studio 2 Asset Pipeline Development Kit.
282 lines • 13.1 kB
TypeScript
import { Pathy } from '@bscotch/pathy';
import { RequiredBy } from '@bscotch/utility';
import { Yyp } from '@bscotch/yy';
import { Gms2ProjectComponents } from '../types/Gms2ProjectComponents.js';
import { FileDifference } from '../utility/files.js';
import { AudioAsset, DeletedAsset } from './assetSource/assetSource.js';
import { Gms2AudioGroup } from './components/Gms2AudioGroup.js';
import { Gms2ComponentArray } from './components/Gms2ComponentArray.js';
import { Gms2Config } from './components/Gms2Config.js';
import { Gms2IncludedFile } from './components/Gms2IncludedFile.js';
import { Gms2IncludedFileArray } from './components/Gms2IncludedFileArray.js';
import { Gms2ResourceArray } from './components/Gms2ResourceArray.js';
import { Gms2RoomOrder } from './components/Gms2RoomOrder.js';
import { Gms2TextureGroup } from './components/Gms2TextureGroup.js';
import { GameMakerEngine } from './GameMakerEngine.js';
import { GameMakerBuildOptions, GameMakerRunOptions } from './GameMakerEngine.types.js';
import { GameMakerIssue } from './GameMakerIssue.js';
import { Gms2FolderArray } from './Gms2FolderArray.js';
import { Linter, LinterOptions, LinterReportFormat } from './Linter.js';
import { GmlTokenSummary } from './parser/GmlTokenSummary.js';
import { Gms2Platform, StitchProjectStatic } from './StitchProject.static.js';
import type { FindGlobalFunctionReferencesOptions, GameMakerProjectCloneOptions, SpriteImportOptions, StitchProjectComms, StitchProjectOptions, StitchProjectPlugin } from './StitchProject.types.js';
import { StitchProjectConfig } from './StitchProjectConfig.js';
import { Gms2MergerGitHubOptions, StitchMergerOptions } from './StitchProjectMerger.js';
import { StitchStorage } from './StitchStorage.js';
export * from './StitchProject.static.js';
export * from './StitchProject.types.js';
/**
* Convert a GameMaker Studio 2.3+ project
* into an internal representation that can
* be manipulated programmatically.
*/
export declare class StitchProject extends StitchProjectStatic {
/**
* The content of the YYP file, mirroring the data structure
* in the file but with components replaced by model instances.
*/
protected components: Gms2ProjectComponents;
readonly config: StitchProjectConfig;
protected plugins: StitchProjectPlugin[];
readonly storage: StitchStorage;
yypRaw: Yyp;
/**
* A representation of an "Issue" for submission
* to GameMaker. Its methods can be used to create
* an issue form, fetch log info, and compile a
* report.
*/
readonly issue: GameMakerIssue;
static load(options?: StitchProjectOptions): Promise<StitchProject>;
static readonly from: typeof StitchProject.load;
protected constructor(options: RequiredBy<StitchProjectOptions, 'projectPath'>);
/**
* Compile the project using Igor.
* @alpha
*/
build(options?: GameMakerBuildOptions): Promise<import("./GameMakerEngine.types.js").GameMakerExecutionResults>;
/**
* Run the project using Igor.
* @alpha
*/
run(options?: GameMakerRunOptions): Promise<import("./GameMakerEngine.types.js").GameMakerExecutionResults>;
/**
* Change the name of the project stored in its
* YYP file.
*
* (Not the name of the file itself.)
*/
get name(): string;
set name(newProjectName: string);
get resourceVersion(): unknown;
get io(): StitchProjectComms;
get yypPathAbsolute(): string;
get yypDirAbsolute(): string;
get folders(): Gms2FolderArray;
get resources(): Gms2ResourceArray;
get textureGroups(): Gms2ComponentArray<import("zod").objectOutputType<{
ConfigValues: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>;
name: import("zod").ZodString;
groupParent: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodObject<{
name: import("zod").ZodString;
path: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
path: string;
name: string;
}, {
path: string;
name: string;
}>>>;
isScaled: import("zod").ZodDefault<import("zod").ZodBoolean>;
customOptions: import("zod").ZodOptional<import("zod").ZodString>;
compressFormat: import("zod").ZodOptional<import("zod").ZodString>;
autocrop: import("zod").ZodDefault<import("zod").ZodBoolean>;
border: import("zod").ZodDefault<import("zod").ZodNumber>;
mipsToGenerate: import("zod").ZodDefault<import("zod").ZodNumber>;
targets: import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodBigInt]>, bigint, number | bigint>>;
loadType: import("zod").ZodOptional<import("zod").ZodEnum<["default", "dynamicpages"]>>;
directory: import("zod").ZodOptional<import("zod").ZodString>;
resourceType: import("zod").ZodDefault<import("zod").ZodLiteral<"GMTextureGroup">>;
resourceVersion: import("zod").ZodDefault<import("zod").ZodString>;
}, import("zod").ZodTypeAny, "passthrough">, typeof Gms2TextureGroup>;
get audioGroups(): Gms2ComponentArray<{
name: string;
resourceType: "GMAudioGroup";
resourceVersion: string;
targets: bigint;
ConfigValues?: Record<string, Record<string, string>> | undefined;
}, typeof Gms2AudioGroup>;
get includedFiles(): Gms2IncludedFileArray;
get rooms(): import("./components/resources/Gms2Room.js").Gms2Room[];
get roomOrder(): Gms2ComponentArray<{
roomId: {
path: string;
name: string;
};
}, typeof Gms2RoomOrder>;
get configs(): Gms2Config;
get ideVersion(): string;
/**
* For GameMaker versions starting in 2022,
* returns `true` if the version indicates
* that the IDE in use is a beta IDE.
*
* For versions before that, always returns `undefined`.
*/
get ideVersionIsBeta(): boolean | undefined;
/**
* The local path where the GameMaker engine stores
* runtimes, IDE configs, and other information.
*
* Uses the project's IDE Version and the current
* OS to determine this directory.
*
* (Only works on Windows.)
*/
engine(): GameMakerEngine;
listScriptGmlFiles(): string[];
listObjectGmlFiles(): string[];
getGlobalFunctions(): import("./parser/GmlToken.js").GmlToken[];
/**
* Set the project version in all options files.
* (Note that the Switch options files do not include the version
* -- that must be set outside of GameMaker in the *.nmeta file).
* Can use one of:
* + "0.0.0.0" syntax (exactly as GameMaker stores versions)
* + "0.0.0" syntax (semver without prereleases -- the 4th value will always be 0)
* + "0.0.0-rc.0" syntax (the 4th number will be the RC number)
* The four numbers will appear in all cases as the string "major.minor.patch.candidate"
*/
set version(versionString: string);
versionOnPlatform(platform: Gms2Platform): string;
/**
* Bundle the project into a single zip file with the `.yyz` extension.
*/
exportYyz(options?: {
outputDirectory?: string;
}): Promise<{
filePath: string;
}>;
mergeFromUrl(url: string, options?: StitchMergerOptions, headers?: {
[]: any;
}): Promise<StitchProject>;
mergeFromGithub(options: Gms2MergerGitHubOptions): Promise<StitchProject>;
/**
* Import modules from one GMS2 project into this one.
* @param fromProject A directory containing a single .yyp file somwhere,
* or the path directly to a .yyp file.
*/
merge(fromProjectPath: string, options?: StitchMergerOptions): Promise<this>;
/**
* Get all references to global functions.
*
* @alpha
*/
findGlobalFunctionReferences(options?: FindGlobalFunctionReferencesOptions): GmlTokenSummary<import("./parser/GmlToken.js").GmlToken>[];
/** Lint this project, resulting in a report of potential issues. */
lint(options?: LinterOptions & {
format?: LinterReportFormat;
}): Linter;
/** Ensure that a texture group exists in the project. */
addTextureGroup(textureGroupName: string): this;
/** Add a texture group assignment if it doesn't already exist. */
addTextureGroupAssignment(folder: string, textureGroupName: string): Promise<StitchProject>;
/** Ensure an audio group exists in the project */
addAudioGroup(audioGroupName: string): this;
/** Add a texture group assignment if it doesn't already exist. */
addAudioGroupAssignment(folder: string, audioGroupName: string): Promise<StitchProject>;
addRoom(name: string, options?: {
first?: boolean;
}): Promise<import("./components/resources/Gms2Room.js").Gms2Room>;
/**
* Ensure that a folder path exists, so that assets can be assigned to it.
*/
addFolder(path: string, tags?: string[]): this;
/** Does not save the project. */
private addSoundByFile;
/**
* Diff an audio source against the project's current audio resources.
*/
checkSoundSource(sourceConfigPath: string | Pathy, sourceId?: string): Promise<(FileDifference & {
source: AudioAsset | DeletedAsset;
})[]>;
/**
* Add or update audio files from a file or a directory.
* The name is taken from
* the source. If there already exists a sound asset
* with this name, its file will be replaced. Otherwise
* the asset will be created and placed into folder "/NEW".
* Support the following extensions:
* 1. mp3
* 2. ogg
* 3. wav
* 4. wma
*
* If the file is a `stitch.src.json` file, its importable audio source(s)
* will be used.
*/
addSounds(source: string, options?: {
/**
* Optionally provide a target sourceId if using a Stitch Asset Source
* (otherwise uses all audio sources)
*/
sourceId?: string;
/**
* Optionally limit allowed extensions when discovering sound files
*/
extensions?: string[];
}): Promise<this>;
/**
* Add or update a script resource. Unless you're trying to make
* global variables, your code should be wrapped in a function!
*/
addScript(name: string, code: string): Promise<this>;
/**
* Given a source folder that is either a sprite or a
* a folder containing sprites (where a 'sprite' is a folder
* containing one or more immediate child PNGs that are
* all the same size -- nesting is allowed), add or update
* the game project sprites using those images. This completely
* replaces the existing images for that sprite. The folder
* name is used directly as the sprite name (parent folders
* are ignored for this.)
*/
addSprites(sourceFolder: string, options?: SpriteImportOptions): Promise<StitchProject>;
addObject(name: string): Promise<import("./components/resources/Gms2Object.js").Gms2Object>;
deleteResourceByName(name: string): this;
deleteIncludedFileByName(baseName: string): this;
/**
* Import a new IncludedFile based on an external file.
* By default will appear in "datafiles/NEW" folder, but you can specificy
* a subdirectory path. If an included file with this name already exists
* in **ANY** subdirectory it will be overwritten. (Names must be unique due to
* an iOS bug wherein all included files are effectively in a flat heirarchy.
* {@see https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/sprites/sprite_add.html}
* @param path Direct filepath or a directory from which all files (recursively) should be loaded
* @param content If set, will create a new file instead of copying content from an existing one.
* If the content is a string or buffer it will be written as-is. All other cases are
* JSON stringified. Must not be null or undefined in order to take effect.
* @param subdirectory Subdirectory inside the Datafiles folder in which to place this resource.
*/
addIncludedFiles(path: string, options?: {
content?: any;
subdirectory?: string;
allowedExtensions?: string[];
}): Gms2IncludedFile[];
addConfig(name: string): this;
/** Write *any* changes to disk. (Does nothing if readonly is true.) */
save(): this;
ensureResourceGroupAssignments(): Promise<StitchProject>;
/**
* Recreate in-memory representations of the GameMaker Project
* using its files.
*/
protected reload(): Promise<void>;
/**
* A deep copy of the project's YYP content with everything as plain primitives (no custom class instances).
* Perfect for writing to JSON.
*/
toJSON(): Yyp;
static cloneProject(options: GameMakerProjectCloneOptions): Promise<StitchProject>;
}
//# sourceMappingURL=StitchProject.d.ts.map