@debuffjp/assets 0.0.0-stage → 0.2.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.
- package/README.md +38 -2
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @debuffjp/assets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runtime loader for the manifest that `debuff` generates from your project's `assets/` folder. No dependencies.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Assets } from "@debuffjp/assets";
|
|
7
|
+
import { Sprite } from "@debuffjp/core";
|
|
8
|
+
|
|
9
|
+
const assets = new Assets(await (await fetch("assets/manifest.json")).json());
|
|
10
|
+
await assets.load("default", ({ loaded, total }) => showProgress(loaded / total));
|
|
11
|
+
|
|
12
|
+
const hero = new Sprite({ frames: assets.frames("hero") }); // hero@16x24.png, sliced on its grid
|
|
13
|
+
draw.sprite(assets.frame("coin"), x, y); // any image, atlased or not
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Conventions (from the asset compiler)
|
|
17
|
+
|
|
18
|
+
| File | Asset id | Group |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| `assets/logo.png` | `logo` | `default` |
|
|
21
|
+
| `assets/level1/map.json` | `level1/map` | `level1` |
|
|
22
|
+
| `assets/hero@16x24.png` | `hero` (grid 16×24) | `default` |
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
- `load(groups?, onProgress?)`: preload one or more groups
|
|
27
|
+
- `fetch(id)`: lazy-load a single asset; concurrent calls share one request
|
|
28
|
+
- `frame(id)`: `{ image, x, y, w, h }` for `draw.sprite`; works for atlased and standalone images
|
|
29
|
+
- `frames(id)`: sprite-sheet frames from the `name@WxH` grid
|
|
30
|
+
- `image(id)` (standalone images only), `json(id)`, `audio(id)`, `text(id)`, `entry(id)`, `has(id)`
|
|
31
|
+
|
|
32
|
+
## Atlases
|
|
33
|
+
|
|
34
|
+
The CLI packs PNGs into atlases per preload group, in dev and in builds, so a level loads one texture instead of dozens. It's lossless, with padding that prevents edge bleeding. Images over half the atlas size stay standalone. Configure or disable it in `debuff.config.ts`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
export default defineConfig({ assets: { atlas: { maxSize: 2048, padding: 2, exclude: ["ui/"] } } }); // or atlas: false
|
|
38
|
+
```
|
|
39
|
+
- Errors are `AssetError` with the asset `id` and a suggested fix
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** Runtime asset manifest and loader. The build-time compiler (see `@debuffjp/cli`)
|
|
2
|
+
* produces the manifest; at runtime this only fetches and caches. */
|
|
3
|
+
export type AssetType = "image" | "json" | "audio" | "text";
|
|
4
|
+
export interface AssetEntry {
|
|
5
|
+
type: AssetType;
|
|
6
|
+
/** URL relative to the manifest's base. */
|
|
7
|
+
src: string;
|
|
8
|
+
/** Preload group; defaults to "default". */
|
|
9
|
+
group?: string;
|
|
10
|
+
/** Optional sprite-sheet grid for images. */
|
|
11
|
+
grid?: {
|
|
12
|
+
frameWidth: number;
|
|
13
|
+
frameHeight: number;
|
|
14
|
+
};
|
|
15
|
+
/** Region of `src` holding this image when it was packed into an atlas. */
|
|
16
|
+
rect?: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
w: number;
|
|
20
|
+
h: number;
|
|
21
|
+
};
|
|
22
|
+
bytes?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface AssetManifest {
|
|
25
|
+
version: 1;
|
|
26
|
+
assets: Record<string, AssetEntry>;
|
|
27
|
+
}
|
|
28
|
+
export interface LoadProgress {
|
|
29
|
+
loaded: number;
|
|
30
|
+
total: number;
|
|
31
|
+
}
|
|
32
|
+
/** An image region, structurally compatible with `@debuffjp/core`'s `Frame`. */
|
|
33
|
+
export interface ImageFrame {
|
|
34
|
+
image: HTMLImageElement;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
w: number;
|
|
38
|
+
h: number;
|
|
39
|
+
}
|
|
40
|
+
export declare class AssetError extends Error {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
constructor(id: string, message: string);
|
|
43
|
+
}
|
|
44
|
+
type Loaded = HTMLImageElement | ArrayBuffer | string | unknown;
|
|
45
|
+
export declare class Assets {
|
|
46
|
+
readonly manifest: AssetManifest;
|
|
47
|
+
private readonly base;
|
|
48
|
+
private readonly cache;
|
|
49
|
+
private readonly pending;
|
|
50
|
+
/** Loads by URL, so assets packed into one atlas share a single request and image. */
|
|
51
|
+
private readonly byUrl;
|
|
52
|
+
constructor(manifest: AssetManifest, base?: string);
|
|
53
|
+
/** Load every asset in the given groups (default: "default"). */
|
|
54
|
+
load(groups?: string | readonly string[], onProgress?: (p: LoadProgress) => void): Promise<void>;
|
|
55
|
+
has(id: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The whole image element. For images packed into an atlas this would be the atlas, so it throws;
|
|
58
|
+
* use `frame(id)` (works for both) with `draw.sprite`.
|
|
59
|
+
*/
|
|
60
|
+
image(id: string): HTMLImageElement;
|
|
61
|
+
/** The image region for an asset: `{ image, x, y, w, h }`, ready for `draw.sprite`. Works whether or not it was atlased. */
|
|
62
|
+
frame(id: string): ImageFrame;
|
|
63
|
+
/**
|
|
64
|
+
* Frames of a sprite sheet declared with the `name@WxH.png` convention, row-major, ready for
|
|
65
|
+
* `new Sprite({ frames })`. Works whether or not the sheet was atlased.
|
|
66
|
+
*/
|
|
67
|
+
frames(id: string): ImageFrame[];
|
|
68
|
+
json<T = unknown>(id: string): T;
|
|
69
|
+
/** Raw encoded audio; decode with `@debuffjp/audio`. */
|
|
70
|
+
audio(id: string): ArrayBuffer;
|
|
71
|
+
text(id: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* The asset's URL without downloading it, for streaming: `audio.stream(assets.url("music/theme"))`.
|
|
74
|
+
* Keep long tracks in a group you never `load()` (e.g. `assets/music/`) so they aren't fetched twice.
|
|
75
|
+
*/
|
|
76
|
+
url(id: string): string;
|
|
77
|
+
entry(id: string): AssetEntry;
|
|
78
|
+
/** Fetch a single asset (lazy loading). Concurrent calls share one request. */
|
|
79
|
+
fetch(id: string): Promise<Loaded>;
|
|
80
|
+
private get;
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;sEACsE;AACtE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,2EAA2E;IAC3E,IAAI,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gFAAgF;AAChF,MAAM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EAAE,MAAM,GAAG,WAAW,CAE7B;IAED,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEvB;IAED;;;OAGG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEtB;IAED,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAI5B;IAED,+EAA+E;IAC/E,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBjC;IAED,OAAO,CAAC,GAAG;CAQZ"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export class AssetError extends Error {
|
|
2
|
+
id;
|
|
3
|
+
constructor(id, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.id = id;
|
|
6
|
+
this.name = "AssetError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class Assets {
|
|
10
|
+
manifest;
|
|
11
|
+
base;
|
|
12
|
+
cache = new Map();
|
|
13
|
+
pending = new Map();
|
|
14
|
+
/** Loads by URL, so assets packed into one atlas share a single request and image. */
|
|
15
|
+
byUrl = new Map();
|
|
16
|
+
constructor(manifest, base = "") {
|
|
17
|
+
this.manifest = manifest;
|
|
18
|
+
this.base = base;
|
|
19
|
+
}
|
|
20
|
+
/** Load every asset in the given groups (default: "default"). */
|
|
21
|
+
async load(groups = "default", onProgress) {
|
|
22
|
+
const wanted = new Set(typeof groups === "string" ? [groups] : groups);
|
|
23
|
+
const ids = Object.entries(this.manifest.assets)
|
|
24
|
+
.filter(([, e]) => wanted.has(e.group ?? "default"))
|
|
25
|
+
.map(([id]) => id);
|
|
26
|
+
let loaded = 0;
|
|
27
|
+
onProgress?.({ loaded, total: ids.length });
|
|
28
|
+
await Promise.all(ids.map(async (id) => {
|
|
29
|
+
await this.fetch(id);
|
|
30
|
+
onProgress?.({ loaded: ++loaded, total: ids.length });
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
has(id) {
|
|
34
|
+
return this.cache.has(id);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The whole image element. For images packed into an atlas this would be the atlas, so it throws;
|
|
38
|
+
* use `frame(id)` (works for both) with `draw.sprite`.
|
|
39
|
+
*/
|
|
40
|
+
image(id) {
|
|
41
|
+
if (this.entry(id).rect) {
|
|
42
|
+
throw new AssetError(id, `Asset "${id}" is packed into an atlas. Use assets.frame("${id}") (or frames() for sprite sheets) with draw.sprite.`);
|
|
43
|
+
}
|
|
44
|
+
return this.get(id, "image");
|
|
45
|
+
}
|
|
46
|
+
/** The image region for an asset: `{ image, x, y, w, h }`, ready for `draw.sprite`. Works whether or not it was atlased. */
|
|
47
|
+
frame(id) {
|
|
48
|
+
const image = this.get(id, "image");
|
|
49
|
+
const rect = this.entry(id).rect;
|
|
50
|
+
return rect ? { image, ...rect } : { image, x: 0, y: 0, w: image.naturalWidth || image.width, h: image.naturalHeight || image.height };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Frames of a sprite sheet declared with the `name@WxH.png` convention, row-major, ready for
|
|
54
|
+
* `new Sprite({ frames })`. Works whether or not the sheet was atlased.
|
|
55
|
+
*/
|
|
56
|
+
frames(id) {
|
|
57
|
+
const whole = this.frame(id);
|
|
58
|
+
const grid = this.entry(id).grid;
|
|
59
|
+
if (!grid)
|
|
60
|
+
return [whole];
|
|
61
|
+
const out = [];
|
|
62
|
+
for (let y = 0; y + grid.frameHeight <= whole.h; y += grid.frameHeight) {
|
|
63
|
+
for (let x = 0; x + grid.frameWidth <= whole.w; x += grid.frameWidth) {
|
|
64
|
+
out.push({ image: whole.image, x: whole.x + x, y: whole.y + y, w: grid.frameWidth, h: grid.frameHeight });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
json(id) {
|
|
70
|
+
return this.get(id, "json");
|
|
71
|
+
}
|
|
72
|
+
/** Raw encoded audio; decode with `@debuffjp/audio`. */
|
|
73
|
+
audio(id) {
|
|
74
|
+
return this.get(id, "audio");
|
|
75
|
+
}
|
|
76
|
+
text(id) {
|
|
77
|
+
return this.get(id, "text");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The asset's URL without downloading it, for streaming: `audio.stream(assets.url("music/theme"))`.
|
|
81
|
+
* Keep long tracks in a group you never `load()` (e.g. `assets/music/`) so they aren't fetched twice.
|
|
82
|
+
*/
|
|
83
|
+
url(id) {
|
|
84
|
+
return this.base + this.entry(id).src;
|
|
85
|
+
}
|
|
86
|
+
entry(id) {
|
|
87
|
+
const e = this.manifest.assets[id];
|
|
88
|
+
if (!e)
|
|
89
|
+
throw new AssetError(id, `Unknown asset "${id}". ${suggest(id, Object.keys(this.manifest.assets))}`);
|
|
90
|
+
return e;
|
|
91
|
+
}
|
|
92
|
+
/** Fetch a single asset (lazy loading). Concurrent calls share one request. */
|
|
93
|
+
fetch(id) {
|
|
94
|
+
if (this.cache.has(id))
|
|
95
|
+
return Promise.resolve(this.cache.get(id));
|
|
96
|
+
const existing = this.pending.get(id);
|
|
97
|
+
if (existing)
|
|
98
|
+
return existing;
|
|
99
|
+
const entry = this.entry(id);
|
|
100
|
+
const url = this.base + entry.src;
|
|
101
|
+
let shared = this.byUrl.get(url);
|
|
102
|
+
if (!shared) {
|
|
103
|
+
shared = loadOne(entry.type, url);
|
|
104
|
+
this.byUrl.set(url, shared);
|
|
105
|
+
shared.catch(() => this.byUrl.delete(url));
|
|
106
|
+
}
|
|
107
|
+
const p = shared
|
|
108
|
+
.then((value) => {
|
|
109
|
+
this.cache.set(id, value);
|
|
110
|
+
this.pending.delete(id);
|
|
111
|
+
return value;
|
|
112
|
+
})
|
|
113
|
+
.catch((err) => {
|
|
114
|
+
this.pending.delete(id);
|
|
115
|
+
throw new AssetError(id, `Failed to load asset "${id}" from ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
116
|
+
});
|
|
117
|
+
this.pending.set(id, p);
|
|
118
|
+
return p;
|
|
119
|
+
}
|
|
120
|
+
get(id, type) {
|
|
121
|
+
const entry = this.entry(id);
|
|
122
|
+
if (entry.type !== type)
|
|
123
|
+
throw new AssetError(id, `Asset "${id}" is ${entry.type}, not ${type}`);
|
|
124
|
+
if (!this.cache.has(id)) {
|
|
125
|
+
throw new AssetError(id, `Asset "${id}" not loaded yet. Load its group "${entry.group ?? "default"}" first.`);
|
|
126
|
+
}
|
|
127
|
+
return this.cache.get(id);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function loadOne(type, url) {
|
|
131
|
+
if (type === "image") {
|
|
132
|
+
const img = new Image();
|
|
133
|
+
await new Promise((resolve, reject) => {
|
|
134
|
+
img.onload = () => resolve();
|
|
135
|
+
img.onerror = () => reject(new Error("image failed to load or decode"));
|
|
136
|
+
img.src = url;
|
|
137
|
+
});
|
|
138
|
+
// decode() avoids a hitch on first draw, but it can stall indefinitely in background tabs and
|
|
139
|
+
// throttled iframes. The load event already guarantees the image is usable, so it's only a hint.
|
|
140
|
+
img.decode().catch(() => { });
|
|
141
|
+
return img;
|
|
142
|
+
}
|
|
143
|
+
const res = await fetch(url);
|
|
144
|
+
if (!res.ok)
|
|
145
|
+
throw new Error(`HTTP ${res.status}`);
|
|
146
|
+
if (type === "json")
|
|
147
|
+
return res.json();
|
|
148
|
+
if (type === "text")
|
|
149
|
+
return res.text();
|
|
150
|
+
return res.arrayBuffer();
|
|
151
|
+
}
|
|
152
|
+
function suggest(id, known) {
|
|
153
|
+
const close = known.filter((k) => k.includes(id) || id.includes(k)).slice(0, 3);
|
|
154
|
+
return close.length ? `Did you mean: ${close.join(", ")}?` : `${known.length} assets in manifest.`;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAExB,EAAE;IADb,YACW,EAAU,EACnB,OAAe;QA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"0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Manifest-driven asset loader with preload groups for debuff",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"game",
|
|
7
|
+
"gamedev",
|
|
8
|
+
"game-engine",
|
|
9
|
+
"2d",
|
|
10
|
+
"html5-game",
|
|
11
|
+
"browser-game",
|
|
12
|
+
"debuff",
|
|
13
|
+
"assets",
|
|
14
|
+
"loader",
|
|
15
|
+
"preload",
|
|
16
|
+
"sprite-sheet"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://debuff.jp",
|
|
20
|
+
"bugs": "https://github.com/debuffjp/debuff/issues",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/debuffjp/debuff.git",
|
|
24
|
+
"directory": "packages/assets"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -b"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"provenance": false
|
|
46
|
+
}
|
|
47
|
+
}
|