@hkdigital/lib-core 0.5.29 → 0.5.31

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.
@@ -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'
@@ -72,13 +72,13 @@ export async function generateViteConfig(options = {}) {
72
72
  imagetools({
73
73
  defaultDirectives: generateDefaultDirectives(imagetoolsOptions),
74
74
  resolveConfigs: generateResponseConfigs(imagetoolsOptions),
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
- },
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
- 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
- }
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
 
@@ -40,7 +40,7 @@ export default class IndexedDbCache {
40
40
  SCHEMA_VERSION: number;
41
41
  /**
42
42
  * Database connection promise
43
- * @type {Promise<IDBDatabase>}
43
+ * @type {Promise<IDBDatabase>|null}
44
44
  * @private
45
45
  */
46
46
  private dbPromise;
@@ -91,7 +91,7 @@ export default class IndexedDbCache {
91
91
 
92
92
  /**
93
93
  * Database connection promise
94
- * @type {Promise<IDBDatabase>}
94
+ * @type {Promise<IDBDatabase>|null}
95
95
  * @private
96
96
  */
97
97
  this.dbPromise = null;
@@ -53,6 +53,7 @@
53
53
  * snippetPortrait?: GameBoxSnippet,
54
54
  * snippetRequireFullscreen?: GameBoxSnippet,
55
55
  * snippetInstallOnHomeScreen?: GameBoxSnippet,
56
+ * debug?: boolean,
56
57
  * [attr: string]: any
57
58
  * }}
58
59
  */
@@ -84,7 +85,9 @@
84
85
  snippetLandscape,
85
86
  snippetPortrait,
86
87
  snippetRequireFullscreen,
87
- snippetInstallOnHomeScreen
88
+ snippetInstallOnHomeScreen,
89
+
90
+ debug = false
88
91
  } = $props();
89
92
 
90
93
  // > Game dimensions and state
@@ -149,9 +152,15 @@
149
152
  isLandscape = !isPortraitMedia;
150
153
  });
151
154
 
152
- // $inspect('isLandscape', isLandscape);
153
- // $inspect('windowWidth/Height', windowWidth, windowHeight);
154
- // $inspect('iosWindowWidth/Height', iosWindowWidth, iosWindowHeight);
155
+ // Use $effect for conditional debugging instead of $inspect
156
+ $effect(() => {
157
+ if (debug) {
158
+ console.log('[GameBox] isLandscape:', isLandscape);
159
+ console.log('[GameBox] windowWidth/Height:', windowWidth, windowHeight);
160
+ console.log('[GameBox] iosWindowWidth/Height:',
161
+ iosWindowWidth, iosWindowHeight);
162
+ }
163
+ });
155
164
 
156
165
  // Update game dimensions based on window size and orientation
157
166
  $effect(() => {
@@ -163,12 +172,15 @@
163
172
  const availWidth = width - marginLeft - marginRight;
164
173
  const availHeight = height - marginTop - marginBottom;
165
174
 
166
- // console.debug('GameBox margins:', {
167
- // marginLeft,
168
- // marginRight,
169
- // marginTop,
170
- // marginBottom
171
- // });
175
+ if( debug )
176
+ {
177
+ console.debug('GameBox margins:', {
178
+ marginLeft,
179
+ marginRight,
180
+ marginTop,
181
+ marginBottom
182
+ });
183
+ }
172
184
 
173
185
  if (availWidth > availHeight) {
174
186
  gameWidthOnLandscape = getGameWidthOnLandscape({
@@ -231,13 +243,17 @@
231
243
  iosWindowWidth = window.innerWidth;
232
244
  iosWindowHeight = window.innerHeight;
233
245
  }
234
- // console.debug('updateIosWidthHeight', {
235
- // angle,
236
- // 'window.innerWidth': window.innerWidth,
237
- // 'window.innerHeight': window.innerHeight,
238
- // iosWindowWidth,
239
- // iosWindowHeight
240
- // });
246
+
247
+ if( debug )
248
+ {
249
+ console.debug('updateIosWidthHeight', {
250
+ angle,
251
+ 'window.innerWidth': window.innerWidth,
252
+ 'window.innerHeight': window.innerHeight,
253
+ iosWindowWidth,
254
+ iosWindowHeight
255
+ });
256
+ }
241
257
  }
242
258
  }
243
259
 
@@ -271,21 +287,24 @@
271
287
  // App visibility detection for iOS debugging
272
288
  const handleVisibilityChange = () => {
273
289
  if (document.visibilityState === 'visible') {
274
- // console.log('App became visible:', {
275
- // 'window.innerWidth': window.innerWidth,
276
- // 'window.innerHeight': window.innerHeight,
277
- // 'screen.width': screen.width,
278
- // 'screen.height': screen.height,
279
- // 'screen.orientation.angle': screen.orientation.angle,
280
- // 'screen.orientation.type': screen.orientation.type,
281
- // 'matchMedia portrait':
282
- // window.matchMedia('(orientation: portrait)').matches,
283
- // 'isLandscape': isLandscape,
284
- // 'gameWidth': gameWidth,
285
- // 'gameHeight': gameHeight,
286
- // 'iosWindowWidth': iosWindowWidth,
287
- // 'iosWindowHeight': iosWindowHeight
288
- // });
290
+
291
+ if( debug ) {
292
+ console.log('App became visible:', {
293
+ 'window.innerWidth': window.innerWidth,
294
+ 'window.innerHeight': window.innerHeight,
295
+ 'screen.width': screen.width,
296
+ 'screen.height': screen.height,
297
+ 'screen.orientation.angle': screen.orientation.angle,
298
+ 'screen.orientation.type': screen.orientation.type,
299
+ 'matchMedia portrait':
300
+ window.matchMedia('(orientation: portrait)').matches,
301
+ 'isLandscape': isLandscape,
302
+ 'gameWidth': gameWidth,
303
+ 'gameHeight': gameHeight,
304
+ 'iosWindowWidth': iosWindowWidth,
305
+ 'iosWindowHeight': iosWindowHeight
306
+ });
307
+ }
289
308
 
290
309
  // Force iOS dimension update when app becomes visible
291
310
  if (isPwa && isAppleMobile) {
@@ -45,6 +45,7 @@ type GameBox = {
45
45
  snippetPortrait?: Snippet<[SnippetParams]> | undefined;
46
46
  snippetRequireFullscreen?: Snippet<[SnippetParams]> | undefined;
47
47
  snippetInstallOnHomeScreen?: Snippet<[SnippetParams]> | undefined;
48
+ debug?: boolean | undefined;
48
49
  }>): void;
49
50
  };
50
51
  declare const GameBox: import("svelte").Component<{
@@ -91,4 +92,5 @@ declare const GameBox: import("svelte").Component<{
91
92
  snippetPortrait?: import("svelte").Snippet<[import("./typedef.js").SnippetParams]>;
92
93
  snippetRequireFullscreen?: import("svelte").Snippet<[import("./typedef.js").SnippetParams]>;
93
94
  snippetInstallOnHomeScreen?: import("svelte").Snippet<[import("./typedef.js").SnippetParams]>;
95
+ debug?: boolean;
94
96
  }, {}, "">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.5.29",
3
+ "version": "0.5.31",
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
- "imagetools:clean": "rm -rf node_modules/.cache/imagetools",
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",