@hkdigital/lib-core 0.5.28 → 0.5.30
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/dist/config/generators/imagetools.js +15 -0
- package/dist/config/generators/vite.js +29 -29
- package/dist/network/cache/IndexedDbCache.d.ts +1 -1
- package/dist/network/cache/IndexedDbCache.js +1 -1
- package/dist/network/http/http-request.js +1 -1
- package/package.json +2 -2
- /package/{CLAUDE.md → claude.md} +0 -0
|
@@ -75,6 +75,9 @@ const DEFAULT_PRESETS = {
|
|
|
75
75
|
* ) => (Record<string, string | string[]>[])}
|
|
76
76
|
*/
|
|
77
77
|
export function generateResponseConfigs(options) {
|
|
78
|
+
|
|
79
|
+
// console.log("generateResponseConfigs");
|
|
80
|
+
|
|
78
81
|
//
|
|
79
82
|
// @see https://github.com/JonasKruckenberg/imagetools
|
|
80
83
|
// /blob/main/docs/core/src/functions/resolveConfigs.md
|
|
@@ -93,6 +96,8 @@ export function generateResponseConfigs(options) {
|
|
|
93
96
|
configPairs[key] = value;
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
// console.log('configPairs', configPairs);
|
|
100
|
+
|
|
96
101
|
// console.log('entries', entries);
|
|
97
102
|
// e.g.
|
|
98
103
|
// entries [
|
|
@@ -116,6 +121,10 @@ export function generateResponseConfigs(options) {
|
|
|
116
121
|
const faviconSizes = options?.faviconSizes ?? FAVICON_SIZES;
|
|
117
122
|
const appleTouchSizes = options?.appleTouchSizes ?? APPLE_TOUCH_SIZES;
|
|
118
123
|
|
|
124
|
+
delete configPairs.responsive;
|
|
125
|
+
delete configPairs.favicons;
|
|
126
|
+
delete configPairs['apple-touch-icons'];
|
|
127
|
+
|
|
119
128
|
// Always include the main image(s) and a thumbnail version
|
|
120
129
|
const thumbnailConfig = {
|
|
121
130
|
...configPairs,
|
|
@@ -188,6 +197,8 @@ export function generateDefaultDirectives(options) {
|
|
|
188
197
|
* @param {URL} url
|
|
189
198
|
*/
|
|
190
199
|
return function defaultDirectives(url) {
|
|
200
|
+
|
|
201
|
+
|
|
191
202
|
// Check the directive in the URL to determine which preset to use
|
|
192
203
|
const params = url.searchParams;
|
|
193
204
|
|
|
@@ -198,6 +209,8 @@ export function generateDefaultDirectives(options) {
|
|
|
198
209
|
// @see https://github.com/JonasKruckenberg/
|
|
199
210
|
// imagetools/blob/main/docs/directives.md#metadata
|
|
200
211
|
|
|
212
|
+
// as=metadata already set in generateResponseConfigs
|
|
213
|
+
|
|
201
214
|
if (params.has('responsive')) {
|
|
202
215
|
params.set('as', 'metadata');
|
|
203
216
|
}
|
|
@@ -237,6 +250,8 @@ export function generateDefaultDirectives(options) {
|
|
|
237
250
|
params.set(key, preset[key]);
|
|
238
251
|
}
|
|
239
252
|
|
|
253
|
+
// console.log("generateDefaultDirectives", { href: url.href, params });
|
|
254
|
+
|
|
240
255
|
// TODO: process directive 'w''
|
|
241
256
|
// - generate only allowed widths
|
|
242
257
|
// - support width presets such as 'hd'
|
|
@@ -66,19 +66,19 @@ export async function generateViteConfig(options = {}) {
|
|
|
66
66
|
const { generateDefaultDirectives, generateResponseConfigs } =
|
|
67
67
|
await import('./imagetools.js');
|
|
68
68
|
|
|
69
|
-
const sharp = (await import('sharp')).default;
|
|
69
|
+
// const sharp = (await import('sharp')).default;
|
|
70
70
|
|
|
71
71
|
plugins.push(
|
|
72
72
|
imagetools({
|
|
73
73
|
defaultDirectives: generateDefaultDirectives(imagetoolsOptions),
|
|
74
74
|
resolveConfigs: generateResponseConfigs(imagetoolsOptions),
|
|
75
|
-
cache: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
75
|
+
// cache: {
|
|
76
|
+
// // @note disable caching to test custom transforms
|
|
77
|
+
// enabled: false,
|
|
78
|
+
// // enabled: true,
|
|
79
|
+
// dir: './node_modules/.cache/imagetools',
|
|
80
|
+
// retention: 60 * 60 * 24 * 10 // 10 days
|
|
81
|
+
// },
|
|
82
82
|
// @see https://www.npmjs.com/package/vite-imagetools?activeTab=readme
|
|
83
83
|
// extendOutputFormats(builtins) {
|
|
84
84
|
// return {
|
|
@@ -89,27 +89,27 @@ export async function generateViteConfig(options = {}) {
|
|
|
89
89
|
// })
|
|
90
90
|
// };
|
|
91
91
|
// },
|
|
92
|
-
extendTransforms(builtins) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
92
|
+
// extendTransforms(builtins) {
|
|
93
|
+
// const ensureAlphaTransform = (config, ctx) => {
|
|
94
|
+
// // Check if 'ensureAlpha' directive is in the URL
|
|
95
|
+
// if (!('ensureAlpha' in config)) {
|
|
96
|
+
// return undefined; // This transform doesn't apply
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// // Mark the parameter as used
|
|
100
|
+
// ctx.useParam('ensureAlpha');
|
|
101
|
+
|
|
102
|
+
// // Return the actual transformation function
|
|
103
|
+
// return (image) => {
|
|
104
|
+
// return image
|
|
105
|
+
// .ensureAlpha()
|
|
106
|
+
// .withMetadata({ xmp: '' });
|
|
107
|
+
// };
|
|
108
|
+
// };
|
|
109
|
+
|
|
110
|
+
// // Return an ARRAY with builtins + your custom transform
|
|
111
|
+
// return [...builtins, ensureAlphaTransform];
|
|
112
|
+
// }
|
|
113
113
|
})
|
|
114
114
|
);
|
|
115
115
|
|
|
@@ -392,7 +392,7 @@ export async function httpRequest(options) {
|
|
|
392
392
|
|
|
393
393
|
if (!isTestEnv) {
|
|
394
394
|
if (cachedResponse) {
|
|
395
|
-
|
|
395
|
+
console.debug(`http:cache-hit [${url.pathname}]`);
|
|
396
396
|
// console.debug(`cached-response has body: ${!!cachedResponse.body}`);
|
|
397
397
|
// console.debug(`cached-response content-length: ${cachedResponse.headers.get('content-length')}`);
|
|
398
398
|
return cachedResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hkdigital/lib-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.30",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "HKdigital",
|
|
6
6
|
"url": "https://hkdigital.nl"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"check:run": "svelte-check --tsconfig ./jsconfig.json",
|
|
39
39
|
"check:watch-run": "svelte-check --tsconfig ./jsconfig.json --watch",
|
|
40
40
|
"git:push": "git push",
|
|
41
|
-
"
|
|
41
|
+
"cache:clear": "rm -rf node_modules/.cache/imagetools",
|
|
42
42
|
"lint:prettier": "prettier --check .",
|
|
43
43
|
"lint:eslint": "eslint .",
|
|
44
44
|
"test:unit": "vitest",
|
/package/{CLAUDE.md → claude.md}
RENAMED
|
File without changes
|