Skip to content

Commit

Permalink
feat(manifest): Add tags to Manifest (#10)
Browse files Browse the repository at this point in the history
* - add skip property and skipChildren
- fixed json and test
- fixed texture packer still creating individual images
- ensure output is removed if the cache key changes

* -test tweak
- fix compressed pngs not working

* fix rotation on texture packer

* - modify cache-buster to use hash
- remove spineAtlasMipmap from mipmap-compress
- fix png compression
- add spine package

* pr feedback

* fix install

* fix tests

* fix test

* note

* feedback

* fix fs

* fix up metadata

* remove dup code

---------

Co-authored-by: Zyie <[email protected]>
  • Loading branch information
GoodBoyDigital and Zyie authored Apr 22, 2024
1 parent afccd34 commit 8657b72
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
12 changes: 10 additions & 2 deletions packages/manifest/src/pixiManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface PixiManifestOptions
output?: string;
createShortcuts?: boolean;
trimExtensions?: boolean;
includeMetaData?: boolean;
}

// TODO EXPORT this out! But don't want to create a dependency on the atlas plugin just yet..
Expand Down Expand Up @@ -68,6 +69,7 @@ export function pixiManifest(_options: PixiManifestOptions = {}): AssetPipe<Pixi
output: 'manifest.json',
createShortcuts: false,
trimExtensions: false,
includeMetaData: true,
..._options
};

Expand Down Expand Up @@ -135,7 +137,10 @@ function collectAssets(
alias: getShortNames(stripTags(path.relative(entryPath, `${asset.path}-${pageIndex}`)), options),
src: pages
.map((finalAsset) => path.relative(outputPath, finalAsset.path))
.sort((a, b) => b.localeCompare(a))
.sort((a, b) => b.localeCompare(a)),
data: options.includeMetaData ? {
tags: asset.allMetaData
} : undefined
});
});
}
Expand All @@ -145,7 +150,10 @@ function collectAssets(
alias: getShortNames(stripTags(path.relative(entryPath, asset.path)), options),
src: finalAssets
.map((finalAsset) => path.relative(outputPath, finalAsset.path))
.sort((a, b) => b.localeCompare(a))
.sort((a, b) => b.localeCompare(a)),
data: options.includeMetaData ? {
tags: asset.allMetaData
} : undefined
});
}
}
Expand Down
71 changes: 48 additions & 23 deletions packages/manifest/test/Manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,20 @@ describe('Manifest', () =>
{
alias: ['bundle/json.json'],
src: ['bundle/json.json'],
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/json.json5'],
src: ['bundle/json.json5'],
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/sprite.png'],
Expand All @@ -159,37 +169,37 @@ describe('Manifest', () =>
'bundle/sprite.webp',
'bundle/sprite.png',
],
// data: {
// tags: {
// m: true,
// },
// },
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/tps-0'],
src: [
'bundle/[email protected]',
'bundle/tps-0.json',
],
// data: {
// tags: {
// tps: true,
// m: true,
// },
// },
data: {
tags: {
tps: true,
m: true,
},
},
},
{
alias: ['bundle/tps-1'],
src: [
'bundle/[email protected]',
'bundle/tps-1.json',
],
// data: {
// tags: {
// tps: true,
// m: true,
// },
// },
data: {
tags: {
tps: true,
m: true,
},
},
},
],
});
Expand All @@ -199,26 +209,35 @@ describe('Manifest', () =>
{
alias: ['defaultFolder/1.mp3'],
src: ['defaultFolder/1.ogg', 'defaultFolder/1.mp3'],
data: {
tags: {},
},
},
{
alias: ['defaultFolder/3.wav'],
src: ['defaultFolder/3.ogg', 'defaultFolder/3.mp3'],
data: {
tags: {},
},
},
{
alias: ['spine/dragon.json'],
src: ['spine/dragon.json'],
data: {
tags: {}
},
},
{
alias: ['spine/dragon.atlas'],
src: [
'spine/[email protected]',
'spine/dragon.atlas',
],
// data: {
// tags: {
// spine: true,
// },
// },
data: {
tags: {
spine: true,
},
},
},
],
});
Expand Down Expand Up @@ -319,6 +338,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: true,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -463,6 +483,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: false,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -585,6 +606,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: false,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -729,6 +751,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: false,
trimExtensions: true,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -894,7 +917,9 @@ describe('Manifest', () =>
output: outputDir,
cache: false,
pipes: [
pixiManifest(),
pixiManifest({
includeMetaData: false
}),
],
});

Expand Down

0 comments on commit 8657b72

Please sign in to comment.