@nanoforge-dev/asset-manager
v1.0.1
Published
NanoForge Engine - Asset Manager
Downloads
153
Readme
About
@nanoforge-dev/asset-manager is a manager for loading assets to uniform work with between client and server.
Installation
Node.js 24.11.0 or newer is required.
npm install @nanoforge-dev/asset-manager
yarn add @nanoforge-dev/asset-manager
pnpm add @nanoforge-dev/asset-manager
bun add @nanoforge-dev/asset-managerExample usage
Initialize the library in your main file
import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager";
import { type IRunOptions } from "@nanoforge-dev/common";
import { NanoforgeFactory } from "@nanoforge-dev/core";
export async function main(options: IRunOptions) {
const app = NanoforgeFactory.createClient(); // Or NanoforgeFactory.createServer()
const assetManager = new AssetManagerLibrary();
app.useAssetManager(assetManager);
await app.init(options);
await app.run();
}Use to load assets
export async function mySystem(registry: Registry, ctx: Context) {
const assetManager = ctx.libs.getAssetManager<AssetManagerLibrary>();
const file = assetManager.getAsset("/path/to/file.txt");
const text = await file.text();
// Do something with file or text
}Links
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
documentation.
See the contribution guide if you'd like to submit a PR.
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in discussions.
