@hkdigital/lib-core 0.4.70 → 0.4.72

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.
@@ -465,7 +465,7 @@ export function parseFunctionName(frame) {
465
465
  }
466
466
 
467
467
  // Strip Firefox function naming artifacts like "</timeoutId<"
468
- functionName = functionName.replace(/<\/[^<>]*</g, '');
468
+ functionName = functionName.replace(/<\/[^<>]*</, '');
469
469
 
470
470
  return functionName;
471
471
  }
@@ -403,6 +403,19 @@ export default class IndexedDbCache {
403
403
  try {
404
404
  let responseHeaders = new Headers(entry.headers);
405
405
 
406
+ // Calculate actual content length from the body and fix Content-Length header
407
+ const bodySize = responseBody instanceof ArrayBuffer ?
408
+ responseBody.byteLength :
409
+ responseBody instanceof Blob ?
410
+ responseBody.size :
411
+ responseBody.length || 0;
412
+
413
+ console.debug(`cache-retrieval: fixing content-length from ${responseHeaders.get('content-length')} to ${bodySize}`);
414
+ console.debug(`cache-retrieval: body type=${typeof responseBody}, constructor=${responseBody?.constructor?.name}, byteLength=${responseBody?.byteLength}`);
415
+
416
+ // Add/fix Content-Length header with actual size
417
+ responseHeaders.set('content-length', bodySize.toString());
418
+
406
419
  // Create Response safely
407
420
  let response;
408
421
  try {
@@ -69,8 +69,34 @@ export default class MemoryResponseCache {
69
69
  // Update last accessed time
70
70
  entry.lastAccessed = Date.now();
71
71
 
72
+ // Get body data safely (works with both real Response and mocks)
73
+ let responseBody;
74
+ try {
75
+ responseBody = await entry.response.arrayBuffer();
76
+ } catch (err) {
77
+ // Fallback for test mocks or consumed responses
78
+ responseBody = entry.response.body || new ArrayBuffer(0);
79
+ }
80
+
81
+ // Calculate size from body data
82
+ const bodySize = responseBody instanceof ArrayBuffer ?
83
+ responseBody.byteLength :
84
+ responseBody instanceof Blob ?
85
+ responseBody.size :
86
+ responseBody.length || 0;
87
+
88
+ // Create new response with corrected Content-Length header
89
+ const fixedHeaders = new Headers(entry.response.headers);
90
+ fixedHeaders.set('content-length', bodySize.toString());
91
+
92
+ const enhancedResponse = new Response(responseBody, {
93
+ status: entry.response.status,
94
+ statusText: entry.response.statusText,
95
+ headers: fixedHeaders
96
+ });
97
+
72
98
  return {
73
- response: entry.response.clone(),
99
+ response: enhancedResponse,
74
100
  metadata: entry.metadata,
75
101
  url: entry.url,
76
102
  timestamp: entry.timestamp,
@@ -387,6 +387,8 @@ export async function httpRequest(options) {
387
387
  if (!isTestEnv) {
388
388
  if (cachedResponse) {
389
389
  console.debug(`http:cache-hit [${url.pathname}]`);
390
+ console.debug(`cached-response has body: ${!!cachedResponse.body}`);
391
+ console.debug(`cached-response content-length: ${cachedResponse.headers.get('content-length')}`);
390
392
  return cachedResponse;
391
393
  } else {
392
394
  console.debug(`http:cache-miss [${url.pathname}]`);
@@ -5,7 +5,7 @@
5
5
  // AbortError,
6
6
  // TimeoutError,
7
7
  // TypeOrValueError
8
- // } from '$lib/errors/index.js';
8
+ // } from '../../errors/index.js';
9
9
 
10
10
  // import { setRequestHeaders } from './headers.js';
11
11
  // import { getErrorFromResponse } from './errors.js';
@@ -245,6 +245,7 @@ export function loadResponseBuffer(response, onProgress) {
245
245
  let bytesLoaded = 0;
246
246
 
247
247
  if (onProgress /*&& size*/) {
248
+ console.debug(`loadResponseBuffer:initial-progress size=${size}`);
248
249
  onProgress({ bytesLoaded, size });
249
250
  }
250
251
 
@@ -274,6 +275,7 @@ export function loadResponseBuffer(response, onProgress) {
274
275
  chunks.push(value);
275
276
 
276
277
  if (onProgress /*&& size*/) {
278
+ console.debug(`loadResponseBuffer:chunk-progress ${bytesLoaded}/${size}`);
277
279
  onProgress({ bytesLoaded, size });
278
280
  }
279
281
  }
@@ -19,6 +19,8 @@ import {
19
19
  import { waitForState } from '../../../util/svelte.js';
20
20
  import { TimeoutError } from '../../../generic/errors.js';
21
21
 
22
+ const MAX_TIMEOUT_MS = 120000;
23
+
22
24
  /** @typedef {import('./typedef.js').SceneLoadingProgress} SceneLoadingProgress */
23
25
 
24
26
  /**
@@ -223,9 +225,6 @@ export default class SceneBase {
223
225
  * Object with promise that resolves when loaded and abort function
224
226
  */
225
227
  preload({ timeoutMs = 10000, onProgress } = {}) {
226
- /** @type {number|NodeJS.Timeout|null} */
227
- let timeoutId = null;
228
-
229
228
  /** @type {number|NodeJS.Timeout|null} */
230
229
  let progressIntervalId = null;
231
230
 
@@ -281,8 +280,8 @@ export default class SceneBase {
281
280
  this.load();
282
281
 
283
282
  // Wait for completion with timeout
284
- // 0 means no timeout, but we still need a reasonable value for waitForState
285
- const waitTimeout = timeoutMs > 0 ? timeoutMs : 120000;
283
+ // 0 means no timeout, but actually we use max timeout
284
+ const waitTimeout = timeoutMs > 0 ? timeoutMs : MAX_TIMEOUT_MS;
286
285
 
287
286
  waitForState(() => {
288
287
  return (
@@ -307,6 +307,7 @@ export default class NetworkLoader {
307
307
  const { bufferPromise, abort: abortLoadBody } = loadResponseBuffer(
308
308
  response,
309
309
  ({ bytesLoaded, size }) => {
310
+ console.debug(`loader:progress [${this._url}] ${bytesLoaded}/${size} bytes`);
310
311
  this._bytesLoaded = bytesLoaded;
311
312
  this._size = size;
312
313
  }
@@ -57,7 +57,7 @@ export type ServiceManagerConfig = {
57
57
  * Result of health check for all services
58
58
  */
59
59
  export type HealthCheckResult = {
60
- [x: string]: import("../service-base/typedef.js").HealthStatus;
60
+ [x: string]: import("../typedef.js").HealthStatus;
61
61
  };
62
62
  /**
63
63
  * Service class constructor type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.4.70",
3
+ "version": "0.4.72",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
@@ -93,46 +93,46 @@
93
93
  "vite-imagetools": "^8.0.0"
94
94
  },
95
95
  "devDependencies": {
96
- "@eslint/js": "^9.33.0",
97
- "@playwright/test": "^1.54.2",
96
+ "@eslint/js": "^9.37.0",
97
+ "@playwright/test": "^1.56.0",
98
98
  "@skeletonlabs/skeleton": "3.1.7",
99
99
  "@skeletonlabs/skeleton-svelte": "1.3.1",
100
100
  "@steeze-ui/heroicons": "^2.4.2",
101
- "@sveltejs/adapter-auto": "^6.1.0",
102
- "@sveltejs/package": "^2.4.1",
103
- "@sveltejs/vite-plugin-svelte": "^6.1.1",
104
- "@tailwindcss/typography": "^0.5.16",
101
+ "@sveltejs/adapter-auto": "^6.1.1",
102
+ "@sveltejs/package": "^2.5.4",
103
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
104
+ "@tailwindcss/postcss": "^4.1.14",
105
+ "@tailwindcss/typography": "^0.5.19",
105
106
  "@testing-library/svelte": "^5.2.8",
106
107
  "@testing-library/user-event": "^14.6.1",
107
- "@tailwindcss/postcss": "^4.1.11",
108
108
  "@types/eslint": "^9.6.1",
109
- "@types/node": "^24.2.1",
109
+ "@types/node": "^24.7.2",
110
110
  "autoprefixer": "^10.4.21",
111
- "eslint": "^9.33.0",
111
+ "eslint": "^9.37.0",
112
112
  "eslint-config-prettier": "^10.1.8",
113
113
  "eslint-plugin-import": "^2.32.0",
114
- "eslint-plugin-svelte": "^3.11.0",
115
- "fake-indexeddb": "^6.1.0",
116
- "globals": "^16.3.0",
114
+ "eslint-plugin-svelte": "^3.12.4",
115
+ "fake-indexeddb": "^6.2.3",
116
+ "globals": "^16.4.0",
117
117
  "jsdom": "^26.1.0",
118
- "jsonwebtoken": "^9.0.0",
119
- "npm-check-updates": "^18.0.2",
118
+ "jsonwebtoken": "^9.0.2",
119
+ "npm-check-updates": "^18.3.1",
120
120
  "npm-run-all": "^4.1.5",
121
- "pino": "^9.8.0",
122
- "pino-pretty": "^13.1.1",
121
+ "pino": "^9.13.1",
122
+ "pino-pretty": "^13.1.2",
123
123
  "postcss": "^8.5.6",
124
124
  "postcss-mixins": "^12.1.2",
125
125
  "prettier": "^3.6.2",
126
126
  "prettier-plugin-svelte": "^3.4.0",
127
127
  "prettier-plugin-tailwindcss": "^0.6.14",
128
- "publint": "^0.3.12",
128
+ "publint": "^0.3.14",
129
129
  "standardized-audio-context-mock": "^9.7.24",
130
- "svelte": "^5.38.1",
131
- "svelte-check": "^4.3.1",
130
+ "svelte": "^5.39.11",
131
+ "svelte-check": "^4.3.3",
132
132
  "svelte-preprocess": "^6.0.3",
133
- "tailwindcss": "^4.1.11",
134
- "typescript": "^5.9.2",
135
- "vite": "^7.1.2",
133
+ "tailwindcss": "^4.1.14",
134
+ "typescript": "^5.9.3",
135
+ "vite": "^7.1.9",
136
136
  "vite-imagetools": "^8.0.0",
137
137
  "vitest": "^3.2.4"
138
138
  }