@scml/types
v1.0.7
Published
Unified TypeScript type definitions for the SugarCube 2 Mod Loader ecosystem
Maintainers
Readme
@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.
Documentation
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
pnpm add @scml/types
# or
npm i @scml/typesUsage
Main entry (global types)
Import the main entry to get the extended global types (e.g. Window augmentations):
import "@scml/types";
// You then get the Window and other global types declared in each package’s global-dataSubpath exports (per-module imports)
For specific module types, use the corresponding subpath:
import type { ModLoader } from "@scml/types/sugarcube-2-ModLoader/ModLoader";
import type { AddonPlugin } from "@scml/types/sugarcube-2-ModLoader/AddonPlugin";
import type { ConflictChecker } from "@scml/types/Addon_ConflictChecker/ConflictChecker";
import type { TweeReplacer } from "@scml/types/Mod_TweeReplacer/TweeReplacer";
// See package.json "exports" for all available pathsAll 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:
pnpm buildThis 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
| Command | Description |
| -------------------- | ------------------------------------------------------- |
| pnpm run build | Generate type-dist/ and update package.json exports |
| pnpm run typecheck | tsc --noEmit |
| pnpm run publint | Run publint |
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
License
MIT
