@hkdigital/lib-core 0.5.25 → 0.5.26

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.
@@ -68,25 +68,13 @@ export async function generateViteConfig(options = {}) {
68
68
  generateResponseConfigs
69
69
  } = await import('./imagetools.js');
70
70
 
71
- // Custom transform to ensure alpha channel based on directive
71
+ // Custom transform to ensure alpha channel for all PNGs
72
72
  const ensureAlphaTransform = (config) => {
73
- // Only apply if ensureAlpha directive is present
74
- if (!config.ensureAlpha) return undefined;
75
-
76
- return async (image) => {
77
- // Force RGBA output by making one pixel slightly transparent
78
- // This prevents Sharp from optimizing back to RGB palette
79
- const metadata = await image.metadata();
80
-
81
- return image
82
- .ensureAlpha()
83
- .composite([{
84
- input: Buffer.from([0, 0, 0, 254]), // RGBA: black with 254 alpha (nearly opaque)
85
- raw: { width: 1, height: 1, channels: 4 },
86
- top: 0,
87
- left: 0,
88
- blend: 'over'
89
- }]);
73
+ // Apply to all PNG images (harmless no-op if alpha exists)
74
+ if (config.format !== 'png') return undefined;
75
+
76
+ return (image) => {
77
+ return image.ensureAlpha();
90
78
  };
91
79
  };
92
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.5.25",
3
+ "version": "0.5.26",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"