From 8657b72c51a7c58f46974a1c5829ae9f0d589567 Mon Sep 17 00:00:00 2001 From: Mat Groves Date: Mon, 22 Apr 2024 14:14:01 +0100 Subject: [PATCH] feat(manifest): Add tags to Manifest (#10) * - 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 <24736175+Zyie@users.noreply.github.com> --- packages/manifest/src/pixiManifest.ts | 12 ++++- packages/manifest/test/Manifest.test.ts | 71 +++++++++++++++++-------- 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/packages/manifest/src/pixiManifest.ts b/packages/manifest/src/pixiManifest.ts index 5779f77..b3f6d5c 100644 --- a/packages/manifest/src/pixiManifest.ts +++ b/packages/manifest/src/pixiManifest.ts @@ -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.. @@ -68,6 +69,7 @@ export function pixiManifest(_options: PixiManifestOptions = {}): AssetPipe path.relative(outputPath, finalAsset.path)) - .sort((a, b) => b.localeCompare(a)) + .sort((a, b) => b.localeCompare(a)), + data: options.includeMetaData ? { + tags: asset.allMetaData + } : undefined }); }); } @@ -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 }); } } diff --git a/packages/manifest/test/Manifest.test.ts b/packages/manifest/test/Manifest.test.ts index 90f4111..f7cf8df 100644 --- a/packages/manifest/test/Manifest.test.ts +++ b/packages/manifest/test/Manifest.test.ts @@ -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'], @@ -159,11 +169,11 @@ describe('Manifest', () => 'bundle/sprite.webp', 'bundle/sprite.png', ], - // data: { - // tags: { - // m: true, - // }, - // }, + data: { + tags: { + m: true, + }, + }, }, { alias: ['bundle/tps-0'], @@ -171,12 +181,12 @@ describe('Manifest', () => 'bundle/tps-0@0.5x.json', 'bundle/tps-0.json', ], - // data: { - // tags: { - // tps: true, - // m: true, - // }, - // }, + data: { + tags: { + tps: true, + m: true, + }, + }, }, { alias: ['bundle/tps-1'], @@ -184,12 +194,12 @@ describe('Manifest', () => 'bundle/tps-1@0.5x.json', 'bundle/tps-1.json', ], - // data: { - // tags: { - // tps: true, - // m: true, - // }, - // }, + data: { + tags: { + tps: true, + m: true, + }, + }, }, ], }); @@ -199,14 +209,23 @@ 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'], @@ -214,11 +233,11 @@ describe('Manifest', () => 'spine/dragon@0.5x.atlas', 'spine/dragon.atlas', ], - // data: { - // tags: { - // spine: true, - // }, - // }, + data: { + tags: { + spine: true, + }, + }, }, ], }); @@ -319,6 +338,7 @@ describe('Manifest', () => pixiManifest({ createShortcuts: true, trimExtensions: true, + includeMetaData: false }), ], }); @@ -463,6 +483,7 @@ describe('Manifest', () => pixiManifest({ createShortcuts: true, trimExtensions: false, + includeMetaData: false }), ], }); @@ -585,6 +606,7 @@ describe('Manifest', () => pixiManifest({ createShortcuts: true, trimExtensions: false, + includeMetaData: false }), ], }); @@ -729,6 +751,7 @@ describe('Manifest', () => pixiManifest({ createShortcuts: false, trimExtensions: true, + includeMetaData: false }), ], }); @@ -894,7 +917,9 @@ describe('Manifest', () => output: outputDir, cache: false, pipes: [ - pixiManifest(), + pixiManifest({ + includeMetaData: false + }), ], });