@digitalcanopy/assets 0.1.0 → 1.1.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 +55 -0
- package/dist/catalog/index.d.mts +94 -0
- package/dist/catalog/index.d.ts +94 -0
- package/dist/catalog/index.js +540 -0
- package/dist/catalog/index.mjs +30 -0
- package/dist/chunk-BUUV7WRE.mjs +502 -0
- package/dist/chunk-CIMJYYCP.mjs +3612 -0
- package/dist/chunk-FECYZWQ6.mjs +278 -0
- package/dist/chunk-MFWLT2XV.mjs +47 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4483 -0
- package/dist/index.mjs +74 -0
- package/dist/manifests/index.d.mts +79 -0
- package/dist/manifests/index.d.ts +79 -0
- package/dist/manifests/index.js +3647 -0
- package/dist/manifests/index.mjs +24 -0
- package/dist/registry/index.d.mts +98 -0
- package/dist/registry/index.d.ts +98 -0
- package/dist/registry/index.js +321 -0
- package/dist/registry/index.mjs +12 -0
- package/dist/resolvers/cdn.d.mts +16 -0
- package/dist/resolvers/cdn.d.ts +16 -0
- package/dist/resolvers/cdn.js +76 -0
- package/dist/resolvers/cdn.mjs +16 -0
- package/dist/types-Cy3PZIX4.d.mts +52 -0
- package/dist/types-_dmvJ9qx.d.ts +52 -0
- package/package.json +32 -11
- package/scripts/generate-manifests.mjs +0 -409
- package/src/__tests__/manifests.test.ts +0 -129
- package/src/__tests__/resolvers.test.ts +0 -55
- package/src/__tests__/sync-r2.test.ts +0 -82
- package/src/index.ts +0 -2
- package/src/manifests/index.ts +0 -81
- package/src/manifests/isometric-tiles.atlas.json +0 -592
- package/src/manifests/keys.ts +0 -160
- package/src/manifests/modular-characters.atlas.json +0 -856
- package/src/manifests/playing-cards.atlas.json +0 -1408
- package/src/manifests/ui-sprites.atlas.json +0 -568
- package/src/resolvers/index.ts +0 -62
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -20
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
playingCardsAtlas,
|
|
4
|
-
isometricTilesAtlas,
|
|
5
|
-
modularCharactersAtlas,
|
|
6
|
-
uiSpritesAtlas,
|
|
7
|
-
getFrameCoordinates,
|
|
8
|
-
toFlameSpriteData,
|
|
9
|
-
PLAYING_CARDS,
|
|
10
|
-
ISOMETRIC_TILES,
|
|
11
|
-
MODULAR_CHARACTERS,
|
|
12
|
-
UI_SPRITES,
|
|
13
|
-
} from '../manifests/index';
|
|
14
|
-
|
|
15
|
-
describe('@digitalcanopy/assets Atlas Manifests', () => {
|
|
16
|
-
describe('Playing Cards Atlas', () => {
|
|
17
|
-
it('has valid metadata and image path', () => {
|
|
18
|
-
expect(playingCardsAtlas.meta.pack).toBe('playing-cards');
|
|
19
|
-
expect(playingCardsAtlas.meta.image).toBe(
|
|
20
|
-
'https://cdn.sunshade.icu/assets/kenney/cards/playing-cards-atlas.png'
|
|
21
|
-
);
|
|
22
|
-
expect(playingCardsAtlas.meta.size.w).toBe(2048);
|
|
23
|
-
expect(playingCardsAtlas.meta.size.h).toBeGreaterThan(0);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('contains all cards defined in PLAYING_CARDS autocomplete keys', () => {
|
|
27
|
-
expect(Object.keys(playingCardsAtlas.frames).length).toBe(PLAYING_CARDS.length);
|
|
28
|
-
for (const cardKey of PLAYING_CARDS) {
|
|
29
|
-
const frame = playingCardsAtlas.frames[cardKey];
|
|
30
|
-
expect(frame).toBeDefined();
|
|
31
|
-
expect(frame.frame.w).toBe(140);
|
|
32
|
-
expect(frame.frame.h).toBe(190);
|
|
33
|
-
expect(frame.frame.x).toBeGreaterThanOrEqual(0);
|
|
34
|
-
expect(frame.frame.y).toBeGreaterThanOrEqual(0);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Isometric Tiles Atlas', () => {
|
|
40
|
-
it('has valid metadata and image path', () => {
|
|
41
|
-
expect(isometricTilesAtlas.meta.pack).toBe('isometric-tiles');
|
|
42
|
-
expect(isometricTilesAtlas.meta.image).toBe(
|
|
43
|
-
'https://cdn.sunshade.icu/assets/kenney/isometric-miniature-dungeon/isometric-tiles-atlas.png'
|
|
44
|
-
);
|
|
45
|
-
expect(isometricTilesAtlas.meta.size.w).toBe(2048);
|
|
46
|
-
expect(isometricTilesAtlas.meta.size.h).toBe(384);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('contains all isometric tiles defined in ISOMETRIC_TILES keys', () => {
|
|
50
|
-
expect(Object.keys(isometricTilesAtlas.frames).length).toBe(ISOMETRIC_TILES.length);
|
|
51
|
-
for (const tileKey of ISOMETRIC_TILES) {
|
|
52
|
-
const frame = isometricTilesAtlas.frames[tileKey];
|
|
53
|
-
expect(frame).toBeDefined();
|
|
54
|
-
expect(frame.frame.w).toBe(256);
|
|
55
|
-
expect(frame.frame.h).toBe(128);
|
|
56
|
-
expect(frame.anchor).toEqual({ ax: 0.5, ay: 0.75 });
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('Modular Characters Atlas', () => {
|
|
62
|
-
it('has valid metadata and image path', () => {
|
|
63
|
-
expect(modularCharactersAtlas.meta.pack).toBe('modular-characters');
|
|
64
|
-
expect(modularCharactersAtlas.meta.image).toBe(
|
|
65
|
-
'https://cdn.sunshade.icu/assets/kenney/modular-characters/modular-characters-atlas.png'
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('contains all character parts defined in MODULAR_CHARACTERS keys', () => {
|
|
70
|
-
expect(Object.keys(modularCharactersAtlas.frames).length).toBe(MODULAR_CHARACTERS.length);
|
|
71
|
-
for (const charKey of MODULAR_CHARACTERS) {
|
|
72
|
-
const frame = modularCharactersAtlas.frames[charKey];
|
|
73
|
-
expect(frame).toBeDefined();
|
|
74
|
-
expect(frame.frame.w).toBe(128);
|
|
75
|
-
expect(frame.frame.h).toBe(128);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('UI Sprites Atlas', () => {
|
|
81
|
-
it('has valid metadata and image path', () => {
|
|
82
|
-
expect(uiSpritesAtlas.meta.pack).toBe('ui-sprites');
|
|
83
|
-
expect(uiSpritesAtlas.meta.image).toBe(
|
|
84
|
-
'https://cdn.sunshade.icu/assets/kenney/ui-pack/ui-sprites-atlas.png'
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('contains all UI sprites defined in UI_SPRITES keys', () => {
|
|
89
|
-
expect(Object.keys(uiSpritesAtlas.frames).length).toBe(UI_SPRITES.length);
|
|
90
|
-
for (const uiKey of UI_SPRITES) {
|
|
91
|
-
const frame = uiSpritesAtlas.frames[uiKey];
|
|
92
|
-
expect(frame).toBeDefined();
|
|
93
|
-
expect(frame.frame.w).toBeGreaterThan(0);
|
|
94
|
-
expect(frame.frame.h).toBeGreaterThan(0);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('Helper Functions', () => {
|
|
100
|
-
it('getFrameCoordinates returns correct frame or undefined', () => {
|
|
101
|
-
const frame = getFrameCoordinates(playingCardsAtlas, 'card-spades-a');
|
|
102
|
-
expect(frame).toBeDefined();
|
|
103
|
-
expect(frame?.frame.x).toBe(0);
|
|
104
|
-
expect(frame?.frame.y).toBe(0);
|
|
105
|
-
|
|
106
|
-
const missing = getFrameCoordinates(playingCardsAtlas, 'non-existent-card');
|
|
107
|
-
expect(missing).toBeUndefined();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('toFlameSpriteData formats flame sprite component coordinates', () => {
|
|
111
|
-
const cardData = toFlameSpriteData(playingCardsAtlas, 'card-spades-a');
|
|
112
|
-
expect(cardData).toEqual({
|
|
113
|
-
srcPosition: [0, 0],
|
|
114
|
-
srcSize: [140, 190],
|
|
115
|
-
anchor: [0.5, 0.5],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const tileData = toFlameSpriteData(isometricTilesAtlas, 'tile-isometric-grass');
|
|
119
|
-
expect(tileData).toEqual({
|
|
120
|
-
srcPosition: [0, 0],
|
|
121
|
-
srcSize: [256, 128],
|
|
122
|
-
anchor: [0.5, 0.75],
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const nullData = toFlameSpriteData(playingCardsAtlas, 'non-existent');
|
|
126
|
-
expect(nullData).toBeNull();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
KENNEY_CDN_BASE,
|
|
4
|
-
getKenneyAssetUrl,
|
|
5
|
-
getKenneyAudioUrl,
|
|
6
|
-
getKenneyCardUrl,
|
|
7
|
-
getKenneyCharacterUrl,
|
|
8
|
-
} from '../resolvers/index';
|
|
9
|
-
|
|
10
|
-
describe('@digitalcanopy/assets CDN Resolvers', () => {
|
|
11
|
-
it('resolves base CDN URL correctly', () => {
|
|
12
|
-
expect(KENNEY_CDN_BASE).toBe('https://cdn.sunshade.icu/assets/kenney');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('resolves standard asset url with default extension', () => {
|
|
16
|
-
const url = getKenneyAssetUrl('modular-characters', 'base_01');
|
|
17
|
-
expect(url).toBe('https://cdn.sunshade.icu/assets/kenney/modular-characters/base_01.png');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('resolves asset url with explicit extension', () => {
|
|
21
|
-
const url = getKenneyAssetUrl('ui-pack', 'button-default', 'svg');
|
|
22
|
-
expect(url).toBe('https://cdn.sunshade.icu/assets/kenney/ui-pack/button-default.svg');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('handles extensions with leading dot cleanly', () => {
|
|
26
|
-
const url = getKenneyAssetUrl('ui-pack', 'button-default', '.svg');
|
|
27
|
-
expect(url).toBe('https://cdn.sunshade.icu/assets/kenney/ui-pack/button-default.svg');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('does not duplicate extension if key already contains it', () => {
|
|
31
|
-
const url1 = getKenneyAssetUrl('cards', 'card-spades-10.png');
|
|
32
|
-
expect(url1).toBe('https://cdn.sunshade.icu/assets/kenney/cards/card-spades-10.png');
|
|
33
|
-
|
|
34
|
-
const url2 = getKenneyAssetUrl('cards', 'card-spades-10.png', 'png');
|
|
35
|
-
expect(url2).toBe('https://cdn.sunshade.icu/assets/kenney/cards/card-spades-10.png');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('resolves audio sound effects correctly', () => {
|
|
39
|
-
const ogg = getKenneyAudioUrl('click-a');
|
|
40
|
-
expect(ogg).toBe('https://cdn.sunshade.icu/assets/kenney/ui-pack/sounds/click-a.ogg');
|
|
41
|
-
|
|
42
|
-
const wav = getKenneyAudioUrl('switch-b', 'wav');
|
|
43
|
-
expect(wav).toBe('https://cdn.sunshade.icu/assets/kenney/ui-pack/sounds/switch-b.wav');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('resolves playing card URLs correctly', () => {
|
|
47
|
-
const card = getKenneyCardUrl('card-spades-10');
|
|
48
|
-
expect(card).toBe('https://cdn.sunshade.icu/assets/kenney/cards/card-spades-10.png');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('resolves character avatar component URLs correctly', () => {
|
|
52
|
-
const face = getKenneyCharacterUrl('face', 'face-0');
|
|
53
|
-
expect(face).toBe('https://cdn.sunshade.icu/assets/kenney/modular-characters/face/face-0.png');
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
validateTaxonomyPath,
|
|
7
|
-
runSync,
|
|
8
|
-
verifyCdnEndpoint,
|
|
9
|
-
} from '../../../../scripts/sync-kenney-r2.mjs';
|
|
10
|
-
|
|
11
|
-
describe('Cloudflare R2 Taxonomy Validation', () => {
|
|
12
|
-
let tempFixtureDir: string;
|
|
13
|
-
|
|
14
|
-
beforeAll(() => {
|
|
15
|
-
tempFixtureDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kenney-test-fixtures-'));
|
|
16
|
-
const cardsPack = path.join(tempFixtureDir, 'kenney_cards');
|
|
17
|
-
const charPack = path.join(tempFixtureDir, 'kenney_modular-characters');
|
|
18
|
-
|
|
19
|
-
fs.mkdirSync(cardsPack, { recursive: true });
|
|
20
|
-
fs.mkdirSync(charPack, { recursive: true });
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(path.join(cardsPack, 'spades_10.png'), 'fake-png-data');
|
|
23
|
-
fs.writeFileSync(path.join(charPack, 'base_01.png'), 'fake-png-data');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterAll(() => {
|
|
27
|
-
if (tempFixtureDir && fs.existsSync(tempFixtureDir)) {
|
|
28
|
-
fs.rmSync(tempFixtureDir, { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('accepts valid modular character paths', () => {
|
|
33
|
-
const res = validateTaxonomyPath('assets/kenney/modular-characters/base_01.png');
|
|
34
|
-
expect(res.valid).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('accepts valid playing card paths', () => {
|
|
38
|
-
const res = validateTaxonomyPath('assets/kenney/cards/spades_10.png');
|
|
39
|
-
expect(res.valid).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('accepts valid UI audio paths', () => {
|
|
43
|
-
const res = validateTaxonomyPath('assets/kenney/ui-pack/sounds/click-a.ogg');
|
|
44
|
-
expect(res.valid).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('rejects keys without assets/kenney/ prefix', () => {
|
|
48
|
-
const res = validateTaxonomyPath('other/path/image.png');
|
|
49
|
-
expect(res.valid).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('handles dry-run mode without invoking remote uploader', async () => {
|
|
53
|
-
const mockUploader = vi.fn();
|
|
54
|
-
const res = await runSync({ dryRun: true, sourceDir: tempFixtureDir, uploader: mockUploader });
|
|
55
|
-
expect(mockUploader).not.toHaveBeenCalled();
|
|
56
|
-
expect(res.success).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('invokes uploader for each validated file in active mode', async () => {
|
|
60
|
-
const uploadedKeys: string[] = [];
|
|
61
|
-
const mockUploader = vi.fn((bucket, key) => {
|
|
62
|
-
uploadedKeys.push(key);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const res = await runSync({ dryRun: false, sourceDir: tempFixtureDir, uploader: mockUploader });
|
|
66
|
-
expect(res.success).toBe(true);
|
|
67
|
-
expect(mockUploader).toHaveBeenCalled();
|
|
68
|
-
expect(uploadedKeys.length).toBe(2);
|
|
69
|
-
expect(uploadedKeys).toContain('assets/kenney/cards/spades_10.png');
|
|
70
|
-
expect(uploadedKeys).toContain('assets/kenney/modular-characters/base_01.png');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('propagates errors and aborts when uploader fails', async () => {
|
|
74
|
-
const failingUploader = vi.fn(() => {
|
|
75
|
-
throw new Error('R2 write permission denied');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
await expect(
|
|
79
|
-
runSync({ dryRun: false, sourceDir: tempFixtureDir, uploader: failingUploader })
|
|
80
|
-
).rejects.toThrow('R2 write permission denied');
|
|
81
|
-
});
|
|
82
|
-
});
|
package/src/index.ts
DELETED
package/src/manifests/index.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import playingCardsAtlasJson from './playing-cards.atlas.json';
|
|
2
|
-
import isometricTilesAtlasJson from './isometric-tiles.atlas.json';
|
|
3
|
-
import modularCharactersAtlasJson from './modular-characters.atlas.json';
|
|
4
|
-
import uiSpritesAtlasJson from './ui-sprites.atlas.json';
|
|
5
|
-
|
|
6
|
-
export * from './keys';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Atlas and Sprite Sheet Coordinate Specifications
|
|
10
|
-
* Compatible with Flame (Flutter) and HTML5 Canvas / Pixi / WebGL
|
|
11
|
-
*/
|
|
12
|
-
export interface SpriteBounds {
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
w: number;
|
|
16
|
-
h: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface AnchorPoint {
|
|
20
|
-
ax: number;
|
|
21
|
-
ay: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface AtlasFrame {
|
|
25
|
-
frame: SpriteBounds;
|
|
26
|
-
rotated?: boolean;
|
|
27
|
-
trimmed?: boolean;
|
|
28
|
-
spriteSourceSize?: SpriteBounds;
|
|
29
|
-
sourceSize?: { w: number; h: number };
|
|
30
|
-
anchor?: AnchorPoint;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AtlasManifest {
|
|
34
|
-
meta: {
|
|
35
|
-
app: string;
|
|
36
|
-
version: string;
|
|
37
|
-
image: string;
|
|
38
|
-
format: string;
|
|
39
|
-
size: { w: number; h: number };
|
|
40
|
-
scale: string;
|
|
41
|
-
pack: string;
|
|
42
|
-
};
|
|
43
|
-
frames: Record<string, AtlasFrame>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface AssetManifestMetadata {
|
|
47
|
-
pack_id: string;
|
|
48
|
-
name: string;
|
|
49
|
-
category: string;
|
|
50
|
-
license: string;
|
|
51
|
-
total_assets: number;
|
|
52
|
-
cdn_base: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const playingCardsAtlas = playingCardsAtlasJson as AtlasManifest;
|
|
56
|
-
export const isometricTilesAtlas = isometricTilesAtlasJson as AtlasManifest;
|
|
57
|
-
export const modularCharactersAtlas = modularCharactersAtlasJson as AtlasManifest;
|
|
58
|
-
export const uiSpritesAtlas = uiSpritesAtlasJson as AtlasManifest;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves frame coordinate data from an atlas manifest.
|
|
62
|
-
*/
|
|
63
|
-
export function getFrameCoordinates(
|
|
64
|
-
manifest: AtlasManifest,
|
|
65
|
-
frameKey: string
|
|
66
|
-
): AtlasFrame | undefined {
|
|
67
|
-
return manifest.frames[frameKey];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Formats coordinates for Flame (Flutter) SpriteComponent.fromFrame data mapping.
|
|
72
|
-
*/
|
|
73
|
-
export function toFlameSpriteData(manifest: AtlasManifest, frameKey: string) {
|
|
74
|
-
const frameData = manifest.frames[frameKey];
|
|
75
|
-
if (!frameData) return null;
|
|
76
|
-
return {
|
|
77
|
-
srcPosition: [frameData.frame.x, frameData.frame.y] as [number, number],
|
|
78
|
-
srcSize: [frameData.frame.w, frameData.frame.h] as [number, number],
|
|
79
|
-
anchor: [frameData.anchor?.ax ?? 0.5, frameData.anchor?.ay ?? 0.5] as [number, number],
|
|
80
|
-
};
|
|
81
|
-
}
|