@scml/types
Unified TypeScript type definitions for the SugarCube 2 Mod Loader ecosystem. This package does not fetch upstream source on its own; it aggregates .d.ts output from other packages in the monorepo and exposes a single entry point plus subpath exports.
Features
- Aggregated types: Copies each sub-package’s
type-dist/(e.g.sugarcube-2-ModLoader, Addons/Mods/Hooks) into this package’stype-dist/<package-name>/ - Global types: Generates a single
global.d.tsfrom each package’sglobal-data.js, extending global interfaces such asWindow - Subpath exports: Exposes each sub-package’s modules via separate export paths in
package.jsonexportsfor on-demand imports - Type alias replacement: At build time, applies
@scml/utils’stypeAliasReverceto all declaration files undertype-dist
Installation
Usage
Main entry (global types)
Import the main entry to get the extended global types (e.g. Window augmentations):
Subpath exports (per-module imports)
For specific module types, use the corresponding subpath:
All available subpaths are listed in package.json under exports. They follow patterns like:
@scml/types/sugarcube-2-ModLoader/<module-name>@scml/types/Addon_ConflictChecker/<module-name>@scml/types/Addon_ImageLoaderHook2BeautySelector/<module-name>- … and other Addon / Mod / Hook packages
Build
This package depends on other packages in the monorepo being built first (each producing its own type-dist/). From the repo root, run:
This package’s build (pnpm run build → tsx src/build.ts) does the following:
- Clears and recreates
type-dist/ - generateGlobal: Copies each sub-package’s
type-dist, reads each package’sglobal-data.js, and writestype-dist/global.d.ts - runReplace: Applies type-alias reverse replacement to
type-dist/**/*.d.ts - generateExports: Generates this package’s
package.jsonexportsfromconstant.ts’sallTypesand each sub-package’spackage.jsonexports
Scripts
Packages included in the bundle
The list in src/constant.ts (allTypes) controls which packages are aggregated. Currently:
- sugarcube-2-ModLoader (Mod Loader core)
- Addon_*: ConflictChecker, ImageLoaderHook2BeautySelector, ModdedClothes, ModdedFeats, ModdedHair, ModuleCssReplacer, TweeReplacerLinker
- AddonMod_*: BeautySelector, I18nScriptList, I18nTweeList, TweePrefixPostfix
- AddonModTimeWrapper
- GameOriginalImagePackMod
- Hook_*: ImgLoader, MacroRng
- Mod_*: CheckDoLCompressorDictionaries, CheckGameVersion, CoTCheckGameVersion, Diff3WayMerge, i18n, I18nTweeReplacer, LoaderGui, ReplacePatch, SubUiAngularJs, SweetAlert2, TweeReplacer
To add or remove a package, update allTypes in constant.ts and run pnpm run build again.
Publishing and files
- Published files:
filesincludes onlytype-distandREADME.md - Types entry:
typespoints to./type-dist/global.d.ts
