From f4907afb103dd3db68d6229f6f774d2128323f47 Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:55:31 +0100 Subject: [PATCH 1/4] fix: ensure allMetaData is up to date (#81) --- packages/assetpack/src/core/Asset.ts | 8 +++++--- packages/assetpack/src/webfont/webfont.ts | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/assetpack/src/core/Asset.ts b/packages/assetpack/src/core/Asset.ts index 9c5888e..52aa791 100644 --- a/packages/assetpack/src/core/Asset.ts +++ b/packages/assetpack/src/core/Asset.ts @@ -30,7 +30,6 @@ export class Asset metaData: Record = {}; inheritedMetaData: Record = {}; - allMetaData: Record = {}; transformData: Record = {}; settings?: Record; @@ -63,7 +62,6 @@ export class Asset asset.parent = this; asset.inheritedMetaData = { ...this.inheritedMetaData, ...this.metaData }; - asset.allMetaData = { ...asset.inheritedMetaData, ...asset.metaData }; asset.transformData = { ...this.transformData, ...asset.transformData }; } @@ -87,12 +85,16 @@ export class Asset asset.transformParent = this; asset.inheritedMetaData = { ...this.inheritedMetaData, ...this.metaData }; - asset.allMetaData = { ...asset.inheritedMetaData, ...asset.metaData }; asset.transformData = { ...this.transformData, ...asset.transformData }; asset.settings = this.settings; } + get allMetaData() + { + return { ...this.inheritedMetaData, ...this.metaData }; + } + get state() { return this._state; diff --git a/packages/assetpack/src/webfont/webfont.ts b/packages/assetpack/src/webfont/webfont.ts index 9ec7481..3f56165 100644 --- a/packages/assetpack/src/webfont/webfont.ts +++ b/packages/assetpack/src/webfont/webfont.ts @@ -34,8 +34,7 @@ export function webfont(): AssetPipe buffer = fonts.svg.to.woff2(asset.path); break; default: - throw new Error(`{Assetpack] Unsupported font type: ${ext}`); - break; + throw new Error(`{AssetPack] Unsupported font type: ${ext}`); } const newFileName = asset.filename.replace(/\.(otf|ttf|svg)$/i, '.woff2'); From 718b55cfc4a262a07ffdae505ec18616f5fb9572 Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:55:41 +0100 Subject: [PATCH 2/4] fix: compress plugin not outputting original image (#75) --- packages/assetpack/src/image/compress.ts | 6 ++++++ packages/assetpack/test/image/Compress.test.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/assetpack/src/image/compress.ts b/packages/assetpack/src/image/compress.ts index 92ba323..277ed0b 100644 --- a/packages/assetpack/src/image/compress.ts +++ b/packages/assetpack/src/image/compress.ts @@ -98,6 +98,12 @@ export function compress(options: CompressOptions = {}): AssetPipe image.sharpImage.toBuffer().then((buffer) => { newAssets[i].buffer = buffer; diff --git a/packages/assetpack/test/image/Compress.test.ts b/packages/assetpack/test/image/Compress.test.ts index d9c830b..f68a954 100644 --- a/packages/assetpack/test/image/Compress.test.ts +++ b/packages/assetpack/test/image/Compress.test.ts @@ -84,9 +84,9 @@ describe('Compress', () => cache: false, pipes: [ compress({ - png: true, + png: false, webp: true, - jpg: true, + jpg: false, avif: true, }), ], From 7de5e2087c550b03fed6caa691862f65275bef63 Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:55:49 +0100 Subject: [PATCH 3/4] fix: relative names when using removeFileExtension (#77) --- packages/assetpack/src/texture-packer/packer/createJsons.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/assetpack/src/texture-packer/packer/createJsons.ts b/packages/assetpack/src/texture-packer/packer/createJsons.ts index 8c8144c..b4ccbb5 100644 --- a/packages/assetpack/src/texture-packer/packer/createJsons.ts +++ b/packages/assetpack/src/texture-packer/packer/createJsons.ts @@ -7,7 +7,7 @@ function convertName(pth: string, nameStyle: 'short' | 'relative', removeFileExt { const name = nameStyle === 'short' ? path.basename(pth) : pth; - return removeFileExtension ? path.parse(name).name : name; + return removeFileExtension ? path.trimExt(name) : name; } export function createJsons( From 972ce84a46485d09836e9a5e50fc5e8e84f772f8 Mon Sep 17 00:00:00 2001 From: Richard Fu <44884321+furic@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:55:59 +1000 Subject: [PATCH 4/4] Update texture-packer.mdx (#80) --- packages/docs/docs/guide/pipes/texture-packer.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/docs/guide/pipes/texture-packer.mdx b/packages/docs/docs/guide/pipes/texture-packer.mdx index d256bdc..b93578e 100644 --- a/packages/docs/docs/guide/pipes/texture-packer.mdx +++ b/packages/docs/docs/guide/pipes/texture-packer.mdx @@ -88,7 +88,7 @@ To compress the texture atlases you can use the `texturePackerCompress` plugin. ```js import { compress } from "@assetpack/core/image"; -import { compress } from "@assetpack/core/texture-packer"; +import { texturePackerCompress } from "@assetpack/core/texture-packer"; // these options are the default values, all options shown here are optional const options = {