@hkdigital/lib-core 0.4.11 → 0.4.13
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/README.md +4 -1
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/errors.js +1 -1
- package/dist/auth/jwt/constants.d.ts +6 -0
- package/dist/auth/jwt/constants.js +13 -0
- package/dist/auth/jwt/core.d.ts +38 -0
- package/dist/auth/jwt/core.js +114 -0
- package/dist/auth/jwt/errors.d.ts +39 -0
- package/dist/auth/jwt/errors.js +74 -0
- package/dist/auth/jwt/generators.d.ts +29 -0
- package/dist/auth/jwt/generators.js +53 -0
- package/dist/auth/jwt/typedef.d.ts +159 -0
- package/dist/auth/jwt/typedef.js +72 -0
- package/dist/auth/jwt/util.d.ts +6 -0
- package/dist/auth/jwt/util.js +43 -0
- package/dist/auth/jwt.d.ts +4 -0
- package/dist/auth/jwt.js +12 -0
- package/dist/config/README.md +28 -0
- package/dist/design/README.md +12 -0
- package/dist/generic/data/classes/IterableTree.js +1 -1
- package/dist/generic/data/classes/Selector.js +1 -1
- package/dist/generic/promises/classes/HkPromise.js +1 -1
- package/dist/generic/streaming/classes/ServerEventsStore.js +1 -1
- package/dist/generic/typedef.d.ts +2 -0
- package/dist/generic/typedef.js +2 -0
- package/dist/logging/internal/adapters/console.js +3 -3
- package/dist/logging/internal/adapters/pino.js +17 -3
- package/dist/logging/internal/adapters/pino.js__ +260 -0
- package/dist/logging/internal/test-errors.js +3 -2
- package/dist/network/http/errors.js +10 -4
- package/dist/network/http/headers.js +1 -1
- package/dist/network/http/http-request.js +1 -1
- package/dist/network/http/json-request.js +1 -1
- package/dist/network/http/response.js +1 -1
- package/dist/network/loaders/audio/AudioScene.svelte.js +1 -1
- package/dist/network/loaders/image/ImageScene.svelte.js +1 -1
- package/dist/network/loaders/image/utils/index.js +1 -1
- package/dist/network/states/NetworkLoader.svelte.js +1 -1
- package/dist/network/typedef.d.ts +2 -0
- package/dist/network/typedef.js +3 -1
- package/dist/services/service-base/ServiceBase.js +1 -3
- package/dist/services/typedef.d.ts +2 -0
- package/dist/services/typedef.js +2 -0
- package/dist/state/typedef.d.ts +3 -0
- package/dist/state/typedef.js +3 -0
- package/dist/ui/components/drag-drop/drag-state.svelte.d.ts +3 -3
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/ui/components/presenter/util.js +1 -1
- package/dist/ui/components/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +3 -3
- package/dist/util/array/index.d.ts +0 -4
- package/dist/util/array/index.js +1 -5
- package/dist/util/array.d.ts +1 -0
- package/dist/util/array.js +9 -0
- package/dist/util/bases/base64.d.ts +8 -0
- package/dist/util/bases/base64.js +23 -0
- package/dist/util/bases/index.d.ts +0 -1
- package/dist/util/bases/index.js +0 -1
- package/dist/util/bases.d.ts +2 -0
- package/dist/util/bases.js +10 -0
- package/dist/util/compare.d.ts +1 -0
- package/dist/util/compare.js +9 -0
- package/dist/util/css/index.d.ts +0 -1
- package/dist/util/css/index.js +0 -1
- package/dist/util/css.d.ts +1 -0
- package/dist/util/css.js +8 -0
- package/dist/util/env.d.ts +1 -0
- package/dist/util/env.js +8 -0
- package/dist/util/exceptions.d.ts +1 -0
- package/dist/util/exceptions.js +8 -0
- package/dist/util/expect/arrays.js +2 -0
- package/dist/util/expect/compounds.d.ts +20 -0
- package/dist/util/expect/compounds.js +48 -0
- package/dist/util/expect/objects.d.ts +28 -0
- package/dist/util/expect/objects.js +70 -0
- package/dist/util/expect/primitives.d.ts +31 -1
- package/dist/util/expect/primitives.js +56 -0
- package/dist/util/expect/values.d.ts +26 -0
- package/dist/util/expect/values.js +48 -0
- package/dist/util/expect.d.ts +6 -0
- package/dist/util/expect.js +31 -0
- package/dist/util/function/index.js +1 -1
- package/dist/util/function.d.ts +1 -0
- package/dist/util/function.js +8 -0
- package/dist/util/geometry.d.ts +1 -0
- package/dist/util/geometry.js +9 -0
- package/dist/util/is.d.ts +1 -0
- package/dist/util/is.js +8 -0
- package/dist/util/iterate/index.js +1 -1
- package/dist/util/iterate.d.ts +1 -0
- package/dist/util/iterate.js +8 -0
- package/dist/util/object/index.js +2 -2
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +8 -0
- package/dist/util/random/bytes.d.ts +28 -0
- package/dist/util/random/bytes.js +72 -0
- package/dist/util/random.d.ts +1 -0
- package/dist/util/random.js +9 -0
- package/dist/util/singleton/index.js +1 -1
- package/dist/util/singleton.d.ts +1 -0
- package/dist/util/singleton.js +8 -0
- package/dist/util/ssr.d.ts +1 -0
- package/dist/util/ssr.js +8 -0
- package/dist/util/string/convert.js +1 -1
- package/dist/util/string/index.d.ts +0 -5
- package/dist/util/string/index.js +0 -5
- package/dist/util/string/interpolate.js +1 -1
- package/dist/util/string.d.ts +5 -0
- package/dist/util/string.js +12 -0
- package/dist/util/svelte/index.d.ts +0 -3
- package/dist/util/svelte/index.js +0 -4
- package/dist/util/svelte.d.ts +3 -0
- package/dist/util/svelte.js +11 -0
- package/dist/util/sveltekit/index.d.ts +0 -1
- package/dist/util/sveltekit/index.js +0 -1
- package/dist/util/sveltekit/route-folders/index.js +1 -1
- package/dist/util/sveltekit.d.ts +1 -0
- package/dist/util/sveltekit.js +8 -0
- package/dist/util/time/index.d.ts +7 -0
- package/dist/util/time/index.js +12 -1
- package/dist/util/time.d.ts +1 -0
- package/dist/util/time.js +1 -0
- package/dist/util/unique.d.ts +1 -0
- package/dist/util/unique.js +8 -0
- package/dist/valibot/{index.d.ts → valibot.d.ts} +1 -2
- package/dist/valibot/{index.js → valibot.js} +1 -6
- package/package.json +3 -1
- package/dist/auth/errors/jwt.d.ts +0 -8
- package/dist/auth/errors/jwt.js +0 -5
- package/dist/util/expect/index.d.ts +0 -103
- package/dist/util/expect/index.js +0 -259
- package/dist/util/index.d.ts +0 -10
- /package/dist/util/{geo → geometry}/index.d.ts +0 -0
- /package/dist/util/{geo → geometry}/index.js +0 -0
- /package/dist/util/{index.js → index.js__} +0 -0
package/dist/auth/jwt.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT utilities main export
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This module provides a clean API for JWT operations including signing,
|
|
6
|
+
* verifying tokens, and generating secret keys.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './jwt/core.js';
|
|
10
|
+
export * from './jwt/generators.js';
|
|
11
|
+
export * from './jwt/errors.js';
|
|
12
|
+
export * from './jwt/constants.js';
|
package/dist/config/README.md
CHANGED
|
@@ -56,6 +56,34 @@ export default defineConfig(
|
|
|
56
56
|
);
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
## PostCSS Configuration
|
|
60
|
+
|
|
61
|
+
HKdigital projects use a standardized PostCSS configuration that integrates with Tailwind CSS.
|
|
62
|
+
|
|
63
|
+
### Quick Start
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// postcss.config.js
|
|
67
|
+
export default {
|
|
68
|
+
plugins: {
|
|
69
|
+
'@tailwindcss/postcss': {}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Why this configuration:**
|
|
75
|
+
- Uses the modern `@tailwindcss/postcss` plugin for Tailwind 4+ compatibility
|
|
76
|
+
- Handles CSS processing for the design system and component styles
|
|
77
|
+
- Works seamlessly with SvelteKit and Vite build processes
|
|
78
|
+
|
|
79
|
+
### Integration
|
|
80
|
+
|
|
81
|
+
This PostCSS config works together with:
|
|
82
|
+
- `src/app.css` with `@import 'tailwindcss'` directive
|
|
83
|
+
- `tailwind.config.js` with design system extensions
|
|
84
|
+
- Vite configuration for CSS processing
|
|
85
|
+
|
|
86
|
+
For projects using the complete hkdigital setup, this PostCSS configuration is essential for proper CSS compilation and design system integration.
|
|
59
87
|
|
|
60
88
|
## Imagetools Configuration
|
|
61
89
|
|
package/dist/design/README.md
CHANGED
|
@@ -6,6 +6,15 @@ A comprehensive, responsive design system built for SvelteKit applications. This
|
|
|
6
6
|
|
|
7
7
|
### Basic Usage
|
|
8
8
|
|
|
9
|
+
**1. Import theme CSS in your app.css (REQUIRED for color classes):**
|
|
10
|
+
```css
|
|
11
|
+
/* src/app.css */
|
|
12
|
+
@import 'tailwindcss';
|
|
13
|
+
@import '../node_modules/@hkdigital/lib-core/dist/design/themes/hkdev/theme.css';
|
|
14
|
+
@import '../node_modules/@hkdigital/lib-core/dist/css/utilities.css';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**2. Configure Tailwind:**
|
|
9
18
|
```javascript
|
|
10
19
|
// tailwind.config.js
|
|
11
20
|
import {
|
|
@@ -35,6 +44,7 @@ export default {
|
|
|
35
44
|
};
|
|
36
45
|
```
|
|
37
46
|
|
|
47
|
+
**3. Add design tokens to your layout:**
|
|
38
48
|
```html
|
|
39
49
|
<!-- +layout.svelte -->
|
|
40
50
|
<script>
|
|
@@ -48,6 +58,8 @@ export default {
|
|
|
48
58
|
{@render children()}
|
|
49
59
|
```
|
|
50
60
|
|
|
61
|
+
**⚠️ Important:** Without the theme CSS import, color classes like `bg-surface-100`, `text-primary-500`, etc. will fail with "Cannot apply unknown utility class" errors during build.
|
|
62
|
+
|
|
51
63
|
## CSS Architecture & app.css
|
|
52
64
|
|
|
53
65
|
### Overview
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
/* ------------------------------------------------------------------ Imports */
|
|
30
30
|
|
|
31
|
-
import * as expect from '../../../util/expect
|
|
31
|
+
import * as expect from '../../../util/expect.js';
|
|
32
32
|
|
|
33
33
|
/* ------------------------------------------------------------------- Export */
|
|
34
34
|
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
/* ------------------------------------------------------------------ Imports */
|
|
36
36
|
|
|
37
|
-
import * as expect from '../../../util/expect
|
|
37
|
+
import * as expect from '../../../util/expect.js';
|
|
38
38
|
|
|
39
39
|
import { noop } from '../../../util/function/index.js';
|
|
40
40
|
|
|
@@ -2,7 +2,7 @@ import { writable } from 'svelte/store';
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line no-unused-vars
|
|
4
4
|
import * as v from 'valibot';
|
|
5
|
-
import { AbsOrRelUrl } from '../../../valibot/
|
|
5
|
+
import { AbsOrRelUrl } from '../../../valibot/parsers.js';
|
|
6
6
|
|
|
7
7
|
import { SubscribersCount } from '../../../state/classes.js';
|
|
8
8
|
|
package/dist/generic/typedef.js
CHANGED
|
@@ -3,9 +3,7 @@ import { LEVELS } from '../../constants.js';
|
|
|
3
3
|
import {
|
|
4
4
|
findRelevantFrameIndex,
|
|
5
5
|
detectErrorMeta,
|
|
6
|
-
formatErrorDisplay
|
|
7
|
-
isMeaningfulFunctionName,
|
|
8
|
-
parseFunctionName
|
|
6
|
+
formatErrorDisplay
|
|
9
7
|
} from './formatting.js';
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -362,6 +360,8 @@ export class ConsoleAdapter {
|
|
|
362
360
|
|
|
363
361
|
let cleaned = trimmed;
|
|
364
362
|
|
|
363
|
+
console.log(123, cleaned);
|
|
364
|
+
|
|
365
365
|
// Convert Chrome format to Firefox format for consistency
|
|
366
366
|
if (isChromeFormat) {
|
|
367
367
|
// "at functionName (url:line:col)" -> "functionName@url:line:col"
|
|
@@ -27,6 +27,14 @@ export class PinoAdapter {
|
|
|
27
27
|
this.#projectRoot = import.meta.env.VITE_PROJECT_ROOT || process.cwd();
|
|
28
28
|
const baseOptions = {
|
|
29
29
|
serializers: {
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Use 'errors' property to trigger Pino's error serializer
|
|
33
|
+
// The serializer traverses the error.cause chain and outputs an array
|
|
34
|
+
// of serialized error objects, which is why we use 'errors' (plural)
|
|
35
|
+
// instead of Pino's standard 'err' property (which expects a single
|
|
36
|
+
// error)
|
|
37
|
+
//
|
|
30
38
|
errors: (err) => {
|
|
31
39
|
|
|
32
40
|
/** @type {import('./typedef').ErrorSummary[]} */
|
|
@@ -194,13 +202,18 @@ export class PinoAdapter {
|
|
|
194
202
|
// Simplify pnpm paths: node_modules/.pnpm/package@version_deps/node_modules/package
|
|
195
203
|
// becomes: node_modules/package
|
|
196
204
|
const pnpmRegex =
|
|
197
|
-
/node_modules\/\.pnpm\/([
|
|
205
|
+
/node_modules\/\.pnpm\/([^@/]+)@[^/]+\/node_modules\/\1/g;
|
|
198
206
|
cleaned = cleaned.replace(pnpmRegex, 'node_modules/$1');
|
|
199
207
|
|
|
200
208
|
// Also handle cases where the package name might be different in the final path
|
|
201
|
-
const pnpmRegex2 = /node_modules\/\.pnpm\/[
|
|
209
|
+
const pnpmRegex2 = /node_modules\/\.pnpm\/[^/]+\/node_modules\/([^/]+)/g;
|
|
202
210
|
cleaned = cleaned.replace(pnpmRegex2, 'node_modules/$1');
|
|
203
211
|
|
|
212
|
+
// Filter out Node.js internal modules
|
|
213
|
+
const lines = cleaned.split('\n');
|
|
214
|
+
const filteredLines = lines.filter(line => !line.includes('node:internal'));
|
|
215
|
+
cleaned = filteredLines.join('\n');
|
|
216
|
+
|
|
204
217
|
return cleaned;
|
|
205
218
|
}
|
|
206
219
|
|
|
@@ -217,7 +230,8 @@ export class PinoAdapter {
|
|
|
217
230
|
timestamp
|
|
218
231
|
};
|
|
219
232
|
|
|
220
|
-
// Check if details contains an error and promote it to
|
|
233
|
+
// Check if details contains an error and promote it to error property for
|
|
234
|
+
// pino serializer
|
|
221
235
|
if (details) {
|
|
222
236
|
if (details instanceof Error) {
|
|
223
237
|
// details is directly an error
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pino adapter for server-side logging
|
|
3
|
+
*/
|
|
4
|
+
import pino from 'pino';
|
|
5
|
+
import { dev } from '$app/environment';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
detectErrorMeta,
|
|
9
|
+
findRelevantFrameIndex,
|
|
10
|
+
formatErrorDisplay
|
|
11
|
+
} from './formatting.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pino adapter that bridges Logger events to pino
|
|
15
|
+
*/
|
|
16
|
+
export class PinoAdapter {
|
|
17
|
+
#projectRoot = null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new PinoAdapter
|
|
21
|
+
*
|
|
22
|
+
* @param {Object} [options] - Pino configuration options
|
|
23
|
+
*/
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
// Determine project root once for stack trace cleaning
|
|
26
|
+
this.#projectRoot = import.meta.env.VITE_PROJECT_ROOT || process.cwd();
|
|
27
|
+
const baseOptions = {
|
|
28
|
+
serializers: {
|
|
29
|
+
errors: (err) => {
|
|
30
|
+
|
|
31
|
+
/** @type {import('./typedef').ErrorSummary[]} */
|
|
32
|
+
const chain = [];
|
|
33
|
+
let loggedAt = null;
|
|
34
|
+
|
|
35
|
+
let current = err;
|
|
36
|
+
let isFirst = true;
|
|
37
|
+
|
|
38
|
+
while (current && current instanceof Error) {
|
|
39
|
+
// Check if this is the first error and it's a LoggerError - extract logging context
|
|
40
|
+
if (isFirst && current.name === 'LoggerError') {
|
|
41
|
+
if (current.stack) {
|
|
42
|
+
const cleanedStackString = this.#cleanStackTrace(current.stack);
|
|
43
|
+
const cleanedStackArray = cleanedStackString
|
|
44
|
+
.split('\n')
|
|
45
|
+
.map((line) => line.trim())
|
|
46
|
+
.filter(
|
|
47
|
+
(line) =>
|
|
48
|
+
line && line !== current.name + ': ' + current.message
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// For LoggerError, we know it's a logger.error call, so find the relevant frame
|
|
52
|
+
const loggerErrorIndex = cleanedStackArray.findIndex(frame =>
|
|
53
|
+
(frame.includes('Logger.error') && frame.includes('logger/Logger.js')) ||
|
|
54
|
+
(frame.includes('error@') && frame.includes('logger/Logger.js'))
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (loggerErrorIndex >= 0 && loggerErrorIndex + 1 < cleanedStackArray.length) {
|
|
58
|
+
const relevantFrame = cleanedStackArray[loggerErrorIndex + 1];
|
|
59
|
+
|
|
60
|
+
// Extract function name from the relevant frame
|
|
61
|
+
// const functionName = parseFunctionName(relevantFrame);
|
|
62
|
+
|
|
63
|
+
// const errorType = functionName ? `logger.error in ${functionName}` : 'logger.error';
|
|
64
|
+
loggedAt = relevantFrame.slice(3); // remove "at "
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Skip the LoggerError and move to the actual error
|
|
69
|
+
current = current.cause;
|
|
70
|
+
isFirst = false;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
/** @type {import('./typedef').ErrorSummary} */
|
|
74
|
+
const serialized = {
|
|
75
|
+
name: current.name,
|
|
76
|
+
message: current.message
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Add error metadata for structured logging and terminal display
|
|
80
|
+
if (current.stack) {
|
|
81
|
+
// Convert cleaned stack string to array format expected by formatting functions
|
|
82
|
+
const cleanedStackString = this.#cleanStackTrace(current.stack);
|
|
83
|
+
const cleanedStackArray = cleanedStackString
|
|
84
|
+
.split('\n')
|
|
85
|
+
.map((line) => line.trim())
|
|
86
|
+
.filter(
|
|
87
|
+
(line) =>
|
|
88
|
+
line && line !== current.name + ': ' + current.message
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const errorMeta = detectErrorMeta(current, cleanedStackArray);
|
|
92
|
+
const relevantFrameIndex = findRelevantFrameIndex(
|
|
93
|
+
current,
|
|
94
|
+
cleanedStackArray
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
serialized.meta = errorMeta;
|
|
98
|
+
serialized.errorType = formatErrorDisplay(errorMeta);
|
|
99
|
+
|
|
100
|
+
// Include stack frames for terminal display
|
|
101
|
+
serialized.stackFrames = cleanedStackArray
|
|
102
|
+
.slice(0, 9)
|
|
103
|
+
.map((frame, index) => {
|
|
104
|
+
const marker = index === relevantFrameIndex ? '→' : ' ';
|
|
105
|
+
|
|
106
|
+
return `${marker} ${frame}`;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Include HttpError-specific properties
|
|
111
|
+
const httpError = /** @type {import('$lib/network/errors.js').HttpError} */ (current);
|
|
112
|
+
if (httpError.status !== undefined) {
|
|
113
|
+
serialized.status = httpError.status;
|
|
114
|
+
}
|
|
115
|
+
if (httpError.details !== undefined) {
|
|
116
|
+
serialized.details = httpError.details;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
chain.push(serialized);
|
|
120
|
+
current = current.cause;
|
|
121
|
+
isFirst = false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return loggedAt ? { chain, loggedAt } : chain;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Add error handling for missing pino-pretty in dev
|
|
130
|
+
if ( dev) {
|
|
131
|
+
const devOptions = {
|
|
132
|
+
level: 'debug',
|
|
133
|
+
transport: {
|
|
134
|
+
target: 'pino-pretty',
|
|
135
|
+
options: {
|
|
136
|
+
colorize: true,
|
|
137
|
+
ignore: 'hostname,pid'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
this.pino = pino({ ...baseOptions, ...devOptions, ...options });
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (
|
|
146
|
+
error.message.includes('Cannot find module') &&
|
|
147
|
+
error.message.includes('pino-pretty')
|
|
148
|
+
) {
|
|
149
|
+
const errorMessage = `
|
|
150
|
+
╭─────────────────────────────────────────────────────────────╮
|
|
151
|
+
│ Missing Dependency │
|
|
152
|
+
├─────────────────────────────────────────────────────────────┤
|
|
153
|
+
│ 'pino-pretty' is required for development logging │
|
|
154
|
+
│ Install it with: pnpm add -D pino-pretty │
|
|
155
|
+
╰─────────────────────────────────────────────────────────────╯`;
|
|
156
|
+
console.error(errorMessage);
|
|
157
|
+
throw new Error('pino-pretty is required for development mode');
|
|
158
|
+
}
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
this.pino = pino({ ...baseOptions, ...options });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Clean stack trace by removing project root path and simplifying node_modules
|
|
168
|
+
*
|
|
169
|
+
* @param {string} stack - Original stack trace
|
|
170
|
+
* @returns {string} Cleaned stack trace
|
|
171
|
+
*/
|
|
172
|
+
#cleanStackTrace(stack) {
|
|
173
|
+
if (!stack || !this.#projectRoot) {
|
|
174
|
+
return stack;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let cleaned = stack;
|
|
178
|
+
|
|
179
|
+
// Escape special regex characters in the project root path
|
|
180
|
+
const escapedRoot = this.#projectRoot.replace(
|
|
181
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
182
|
+
'\\$&'
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
// Replace project root path with relative path, handling file:// protocol
|
|
186
|
+
// Match both regular paths and file:// URLs
|
|
187
|
+
const rootRegex = new RegExp(
|
|
188
|
+
`(\\s+at\\s+.*\\()(file://)?${escapedRoot}[\\/\\\\]`,
|
|
189
|
+
'g'
|
|
190
|
+
);
|
|
191
|
+
cleaned = cleaned.replace(rootRegex, '$1');
|
|
192
|
+
|
|
193
|
+
// Simplify pnpm paths: node_modules/.pnpm/package@version_deps/node_modules/package
|
|
194
|
+
// becomes: node_modules/package
|
|
195
|
+
const pnpmRegex =
|
|
196
|
+
/node_modules\/\.pnpm\/([^@\/]+)@[^\/]+\/node_modules\/\1/g;
|
|
197
|
+
cleaned = cleaned.replace(pnpmRegex, 'node_modules/$1');
|
|
198
|
+
|
|
199
|
+
// Also handle cases where the package name might be different in the final path
|
|
200
|
+
const pnpmRegex2 = /node_modules\/\.pnpm\/[^\/]+\/node_modules\/([^\/]+)/g;
|
|
201
|
+
cleaned = cleaned.replace(pnpmRegex2, 'node_modules/$1');
|
|
202
|
+
|
|
203
|
+
return cleaned;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Handle log events from Logger
|
|
208
|
+
*
|
|
209
|
+
* @param {Object} logEvent - Log event from Logger
|
|
210
|
+
*/
|
|
211
|
+
handleLog(logEvent) {
|
|
212
|
+
const { level, message, details, source, timestamp } = logEvent;
|
|
213
|
+
|
|
214
|
+
const logData = {
|
|
215
|
+
source,
|
|
216
|
+
timestamp
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Check if details contains an error and promote it to err property for pino serializer
|
|
220
|
+
if (details) {
|
|
221
|
+
if (details instanceof Error) {
|
|
222
|
+
// details is directly an error
|
|
223
|
+
logData.err = details;
|
|
224
|
+
} else if (details.error instanceof Error) {
|
|
225
|
+
// details has an error property
|
|
226
|
+
logData.err = details.error;
|
|
227
|
+
// Include other details except the error
|
|
228
|
+
// eslint-disable-next-line no-unused-vars
|
|
229
|
+
const { error, ...otherDetails } = details;
|
|
230
|
+
if (Object.keys(otherDetails).length > 0) {
|
|
231
|
+
logData.details = otherDetails;
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
// No error found in details, include all details
|
|
235
|
+
logData.details = details;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Check if we have loggedAt info from the serializer
|
|
240
|
+
if (logData.err && typeof logData.err === 'object' && logData.err.loggedAt) {
|
|
241
|
+
logData.loggedAt = logData.err.loggedAt;
|
|
242
|
+
logData.err = logData.err.chain;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
this.pino[level](logData, message);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Create a child logger with additional context
|
|
250
|
+
*
|
|
251
|
+
* @param {Object} context - Additional context data
|
|
252
|
+
* @returns {PinoAdapter} New adapter instance with context
|
|
253
|
+
*/
|
|
254
|
+
child(context) {
|
|
255
|
+
const childPino = this.pino.child(context);
|
|
256
|
+
const adapter = new PinoAdapter();
|
|
257
|
+
adapter.pino = childPino;
|
|
258
|
+
return adapter;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as expect from '../../util/expect.js';
|
|
2
|
+
import { rethrow } from '../../util/exceptions.js';
|
|
2
3
|
import { HkPromise } from '../../generic/promises.js';
|
|
3
4
|
import { httpGet } from '../../network/http/index.js';
|
|
4
|
-
import { v } from '../../valibot/
|
|
5
|
+
import { v } from '../../valibot/valibot.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Test functions for generating various types of errors for logging demonstration
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as expect from '../../util/expect
|
|
1
|
+
import * as expect from '../../util/expect.js';
|
|
2
2
|
import { DetailedError } from '../../generic/errors.js';
|
|
3
3
|
|
|
4
4
|
import { CONTENT_TYPE } from '../../constants/http/index.js';
|
|
5
5
|
|
|
6
|
-
import { APPLICATION_JSON } from '../../constants/mime/index.js';
|
|
6
|
+
import { APPLICATION_JSON, TEXT_PLAIN } from '../../constants/mime/index.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Try to get error information from the server error response
|
|
@@ -77,8 +77,14 @@ export async function getErrorFromResponse(response) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!message && contentType === TEXT_PLAIN ) {
|
|
83
|
+
message = await response.text();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!message) {
|
|
87
|
+
// Final fallback to status text (avoid HTML pages)
|
|
82
88
|
message = response.statusText || `HTTP ${response.status}`;
|
|
83
89
|
}
|
|
84
90
|
// console.log( "message", message );
|
|
@@ -13,7 +13,7 @@ import { CONTENT_TYPE } from '../../constants/http/headers.js';
|
|
|
13
13
|
|
|
14
14
|
import { AbortError, TimeoutError } from '../errors/api.js';
|
|
15
15
|
|
|
16
|
-
import * as expect from '../../util/expect
|
|
16
|
+
import * as expect from '../../util/expect.js';
|
|
17
17
|
|
|
18
18
|
import { toURL } from './url.js';
|
|
19
19
|
import { setRequestHeaders } from './headers.js';
|
|
@@ -4,7 +4,7 @@ import { APPLICATION_JSON } from '../../constants/mime/application.js';
|
|
|
4
4
|
import { CONTENT_TYPE } from '../../constants/http/headers.js';
|
|
5
5
|
import { ResponseError } from '../errors.js';
|
|
6
6
|
|
|
7
|
-
import * as expect from '../../util/expect
|
|
7
|
+
import * as expect from '../../util/expect.js';
|
|
8
8
|
|
|
9
9
|
import { toURL } from './url.js';
|
|
10
10
|
import { httpRequest } from './http-request.js';
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
INITIAL
|
|
17
17
|
} from '../../state/classes/loading-state-machine/constants.js';
|
|
18
18
|
|
|
19
|
-
import * as expect from '../../util/expect
|
|
19
|
+
import * as expect from '../../util/expect.js';
|
|
20
20
|
|
|
21
21
|
import { httpGet, loadResponseBuffer } from '../http.js';
|
|
22
22
|
|
package/dist/network/typedef.js
CHANGED
|
@@ -446,9 +446,7 @@ export class ServiceBase extends EventEmitter {
|
|
|
446
446
|
* @param {Error} error - Error that occurred
|
|
447
447
|
*/
|
|
448
448
|
_setError(operation, error) {
|
|
449
|
-
const detailedError = new DetailedError(`${operation} failed`,
|
|
450
|
-
cause: error
|
|
451
|
-
});
|
|
449
|
+
const detailedError = new DetailedError(`${operation} failed`, null, error);
|
|
452
450
|
|
|
453
451
|
this.error = detailedError;
|
|
454
452
|
this._setState(ERROR_STATE);
|
package/dist/services/typedef.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const createOrGetDragState: (contextKey?: import("../../../state/
|
|
2
|
-
export const createDragState: (contextKey?: import("../../../state/
|
|
3
|
-
export const getDragState: (contextKey?: import("../../../state/
|
|
1
|
+
export const createOrGetDragState: (contextKey?: import("../../../state/typedef.js").ContextKey) => DragState;
|
|
2
|
+
export const createDragState: (contextKey?: import("../../../state/typedef.js").ContextKey) => DragState;
|
|
3
|
+
export const getDragState: (contextKey?: import("../../../state/typedef.js").ContextKey) => DragState;
|
|
4
4
|
export type SimulatedDragEvent = import("../../typedef.js").SimulatedDragEvent;
|
|
5
5
|
/** @typedef {import('../../typedef.js').SimulatedDragEvent} SimulatedDragEvent */
|
|
6
6
|
declare class DragState {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class AppLayoutState {
|
|
2
2
|
landscapeOnSmallScreen: boolean;
|
|
3
3
|
}
|
|
4
|
-
export const createOrGetState: (contextKey?: import("../../../state/
|
|
5
|
-
export const createState: (contextKey?: import("../../../state/
|
|
6
|
-
export const getState: (contextKey?: import("../../../state/
|
|
4
|
+
export const createOrGetState: (contextKey?: import("../../../state/typedef").ContextKey) => AppLayoutState;
|
|
5
|
+
export const createState: (contextKey?: import("../../../state/typedef").ContextKey) => AppLayoutState;
|
|
6
|
+
export const getState: (contextKey?: import("../../../state/typedef").ContextKey) => AppLayoutState;
|