@hkdigital/lib-core 0.3.13 → 0.3.15

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.
Files changed (45) hide show
  1. package/README.md +12 -3
  2. package/dist/config/README.md +4 -4
  3. package/dist/constants/regexp/url.js +0 -2
  4. package/dist/design/README.md +136 -66
  5. package/dist/design/config/{design-config.d.ts → design-tokens.d.ts} +23 -10
  6. package/dist/design/config/design-tokens.js +107 -0
  7. package/dist/design/generators/index.d.ts +51 -0
  8. package/dist/design/generators/index.js +89 -0
  9. package/dist/design/index.d.ts +3 -4
  10. package/dist/design/index.js +24 -41
  11. package/dist/design/plugins/skeleton.d.ts +4 -2
  12. package/dist/design/plugins/skeleton.js +3 -2
  13. package/dist/design/themes/hkdev/components/buttons/button-text.css +19 -25
  14. package/dist/design/utils/clamp.js +1 -1
  15. package/dist/design/utils/root-vars.d.ts +50 -39
  16. package/dist/design/utils/root-vars.js +127 -29
  17. package/dist/logging/index.d.ts +2 -3
  18. package/dist/logging/index.js +3 -4
  19. package/dist/logging/internal/adapters/console.js +3 -7
  20. package/dist/logging/internal/adapters/pino.js +21 -11
  21. package/dist/logging/internal/factories/client.js +1 -1
  22. package/dist/logging/internal/factories/server.js +1 -1
  23. package/dist/logging/internal/logger/Logger.d.ts +2 -2
  24. package/dist/logging/internal/logger/Logger.js +3 -3
  25. package/dist/services/index.d.ts +0 -2
  26. package/dist/services/index.js +0 -3
  27. package/dist/services/typedef.d.ts +2 -0
  28. package/dist/services/typedef.js +2 -0
  29. package/dist/typedef/index.d.ts +0 -1
  30. package/dist/typedef/index.js +0 -1
  31. package/dist/ui/components/game-box/GameBox.svelte +1 -1
  32. package/dist/ui/primitives/buttons/button-text/TextButton.svelte +1 -1
  33. package/dist/ui/primitives/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +7 -7
  34. package/dist/ui/primitives/index.d.ts +1 -0
  35. package/dist/ui/primitives/index.js +1 -2
  36. package/package.json +2 -2
  37. package/dist/design/config/design-config.js +0 -73
  38. package/dist/design/tailwind-theme-extend.d.ts +0 -23
  39. package/dist/design/tailwind-theme-extend.js +0 -158
  40. package/dist/logging/internal/factories/universal.d.ts +0 -9
  41. package/dist/logging/internal/factories/universal.js +0 -22
  42. /package/dist/logging/{internal/constants.d.ts → constants.d.ts} +0 -0
  43. /package/dist/logging/{internal/constants.js → constants.js} +0 -0
  44. /package/dist/logging/{internal/typedef.d.ts → typedef.d.ts} +0 -0
  45. /package/dist/logging/{internal/typedef.js → typedef.js} +0 -0
@@ -31,10 +31,9 @@ export class PinoAdapter {
31
31
  const serialized = {
32
32
  name: current.name,
33
33
  message: current.message,
34
- ...(isFirst &&
35
- this.pino.level === 'debug' && {
36
- stack: this.#cleanStackTrace(current.stack)
37
- })
34
+ ...(isFirst && {
35
+ stack: this.#cleanStackTrace(current.stack)
36
+ })
38
37
  };
39
38
 
40
39
  // Include HttpError-specific properties
@@ -89,7 +88,7 @@ export class PinoAdapter {
89
88
  }
90
89
 
91
90
  /**
92
- * Clean stack trace by removing project root path
91
+ * Clean stack trace by removing project root path and simplifying node_modules
93
92
  *
94
93
  * @param {string} stack - Original stack trace
95
94
  * @returns {string} Cleaned stack trace
@@ -99,15 +98,26 @@ export class PinoAdapter {
99
98
  return stack;
100
99
  }
101
100
 
101
+ let cleaned = stack;
102
+
102
103
  // Escape special regex characters in the project root path
103
104
  const escapedRoot = this.#projectRoot.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
104
105
 
105
- // Replace project root path with relative path, but only after "at " to avoid
106
- // accidental replacements in error messages or other parts of the stack
107
- // Match the project root followed by a path separator
108
- const regex = new RegExp(`(\\s+at\\s+.*\\()${escapedRoot}[\\/\\\\]`, 'g');
109
-
110
- return stack.replace(regex, '$1');
106
+ // Replace project root path with relative path, handling file:// protocol
107
+ // Match both regular paths and file:// URLs
108
+ const rootRegex = new RegExp(`(\\s+at\\s+.*\\()(file://)?${escapedRoot}[\\/\\\\]`, 'g');
109
+ cleaned = cleaned.replace(rootRegex, '$1');
110
+
111
+ // Simplify pnpm paths: node_modules/.pnpm/package@version_deps/node_modules/package
112
+ // becomes: node_modules/package
113
+ const pnpmRegex = /node_modules\/\.pnpm\/([^@\/]+)@[^\/]+\/node_modules\/\1/g;
114
+ cleaned = cleaned.replace(pnpmRegex, 'node_modules/$1');
115
+
116
+ // Also handle cases where the package name might be different in the final path
117
+ const pnpmRegex2 = /node_modules\/\.pnpm\/[^\/]+\/node_modules\/([^\/]+)/g;
118
+ cleaned = cleaned.replace(pnpmRegex2, 'node_modules/$1');
119
+
120
+ return cleaned;
111
121
  }
112
122
 
113
123
  /**
@@ -1,6 +1,6 @@
1
1
  import { Logger } from '../logger/index.js';
2
2
  import { ConsoleAdapter } from '../adapters/console.js';
3
- import { INFO } from '../constants.js';
3
+ import { INFO } from '../../constants.js';
4
4
 
5
5
  /**
6
6
  * Create a client-side logger with console adapter
@@ -1,7 +1,7 @@
1
1
  import { Logger } from '../logger/index.js';
2
2
 
3
3
  import { PinoAdapter } from '../adapters/pino.js';
4
- import { INFO } from '../constants.js';
4
+ import { INFO } from '../../constants.js';
5
5
 
6
6
  /**
7
7
  * Create a server-side logger with pino adapter
@@ -70,9 +70,9 @@ export default class Logger extends EventEmitter {
70
70
  * forwarded to this logger.
71
71
  *
72
72
  * @param {string} eventName
73
- * @param {import('../typedef.js').LogEventData} eventData
73
+ * @param {import('../../typedef.js').LogEventData} eventData
74
74
  */
75
- logFromEvent(eventName: string, eventData: import("../typedef.js").LogEventData): boolean;
75
+ logFromEvent(eventName: string, eventData: import("../../typedef.js").LogEventData): boolean;
76
76
  #private;
77
77
  }
78
78
  import { EventEmitter } from '../../../classes/event-emitter';
@@ -41,7 +41,7 @@ import {
41
41
  ERROR,
42
42
  LEVELS,
43
43
  LOG
44
- } from '../constants.js';
44
+ } from '../../constants.js';
45
45
 
46
46
  /**
47
47
  * Logger class for consistent logging
@@ -157,7 +157,7 @@ export default class Logger extends EventEmitter {
157
157
  * forwarded to this logger.
158
158
  *
159
159
  * @param {string} eventName
160
- * @param {import('../typedef.js').LogEventData} eventData
160
+ * @param {import('../../typedef.js').LogEventData} eventData
161
161
  */
162
162
  logFromEvent(eventName, eventData) {
163
163
  const level = eventData.level;
@@ -205,7 +205,7 @@ export default class Logger extends EventEmitter {
205
205
  /**
206
206
  * Internal event loggin method
207
207
  *
208
- * @param {import('../typedef.js').LogEvent} logEvent
208
+ * @param {import('../../typedef.js').LogEvent} logEvent
209
209
  */
210
210
  #logEvent(logEvent) {
211
211
  // Emit as both specific level event and generic 'log' event
@@ -2,5 +2,3 @@ export { default as ServiceBase } from "./service-base/ServiceBase.js";
2
2
  export { default as ServiceManager } from "./service-manager/ServiceManager.js";
3
3
  export * from "./service-base/constants.js";
4
4
  export * from "./service-manager/constants.js";
5
- export * from "./service-base/typedef.js";
6
- export * from "./service-manager/typedef.js";
@@ -3,6 +3,3 @@ export { default as ServiceManager } from './service-manager/ServiceManager.js';
3
3
 
4
4
  export * from './service-base/constants.js';
5
5
  export * from './service-manager/constants.js';
6
-
7
- export * from './service-base/typedef.js';
8
- export * from './service-manager/typedef.js';
@@ -0,0 +1,2 @@
1
+ export * from "./service-base/typedef.js";
2
+ export * from "./service-manager/typedef.js";
@@ -0,0 +1,2 @@
1
+ export * from './service-base/typedef.js';
2
+ export * from './service-manager/typedef.js';
@@ -1,4 +1,3 @@
1
1
  export * from "./context.js";
2
2
  export * from "./drag.js";
3
3
  export * from "./drop.js";
4
- export * from "../network/typedef.js";
@@ -1,4 +1,3 @@
1
1
  export * from './context.js';
2
2
  export * from './drag.js';
3
3
  export * from './drop.js';
4
- export * from '../network/typedef.js';
@@ -7,7 +7,7 @@
7
7
  } from './gamebox.util.js';
8
8
 
9
9
  import { enableContainerScaling } from '../../../design/index.js';
10
- // import { enableContainerScaling } from '@hkdigital/lib-sveltekit/util/design-system/index.js';
10
+ // import { enableContainerScaling } from '@hkdigital/lib-core/design/index.js';
11
11
 
12
12
  /**
13
13
  * @typedef {{
@@ -16,6 +16,6 @@
16
16
  } = $props();
17
17
  </script>
18
18
 
19
- <Button type="text" {...attrs}>
19
+ <Button type="text" data-type="text" {...attrs}>
20
20
  {@render children()}
21
21
  </Button>
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  import { onMount } from 'svelte';
3
- import { DESIGN, CLAMPING } from '../../../../design/config/design-config.js';
4
3
  import {
4
+ designTokens,
5
5
  enableScalingUI,
6
6
  getAllRootScalingVars
7
7
  } from '../../../../design/index.js';
@@ -44,7 +44,7 @@
44
44
  onMount(() => {
45
45
  // Initialize the design scaling system
46
46
  //const cleanup = () => {};
47
- const cleanup = enableScalingUI(DESIGN, CLAMPING);
47
+ const cleanup = enableScalingUI(designTokens.DESIGN, designTokens.CLAMPING);
48
48
 
49
49
  // Update debug values initially
50
50
  updateDebugValues();
@@ -92,10 +92,10 @@
92
92
  </div>
93
93
  <div class="grid grid-cols-2 gap-x-2 gap-y-0.5">
94
94
  <div class="text-gray-400">Design Width:</div>
95
- <div>{DESIGN.width}px</div>
95
+ <div>{designTokens.DESIGN.width}px</div>
96
96
 
97
97
  <div class="text-gray-400">Design Height:</div>
98
- <div>{DESIGN.height}px</div>
98
+ <div>{designTokens.DESIGN.height}px</div>
99
99
 
100
100
  <div class="text-gray-400">Window:</div>
101
101
  <div id="window-size">...</div>
@@ -125,12 +125,12 @@
125
125
  <div class="mt-1 pt-1 border-t border-gray-600 text-gray-400">
126
126
  <div>Clamping:</div>
127
127
  <div class="grid grid-cols-3 text-2xs">
128
- <div>UI: {CLAMPING.ui.min} - {CLAMPING.ui.max}</div>
128
+ <div>UI: {designTokens.CLAMPING.ui.min} - {designTokens.CLAMPING.ui.max}</div>
129
129
  <div>
130
- Content: {CLAMPING.textBase.min} - {CLAMPING.textBase.max}
130
+ Content: {designTokens.CLAMPING.textBase.min} - {designTokens.CLAMPING.textBase.max}
131
131
  </div>
132
132
  <div>
133
- Heading: {CLAMPING.textHeading.min} - {CLAMPING.textHeading.max}
133
+ Heading: {designTokens.CLAMPING.textHeading.min} - {designTokens.CLAMPING.textHeading.max}
134
134
  </div>
135
135
  </div>
136
136
  </div>
@@ -0,0 +1 @@
1
+ export * from "./buttons/index.js";
@@ -1,2 +1 @@
1
- // export * as area from "./area/index.js";
2
- // export * as icon from "./icon/index.js";
1
+ export * from './buttons/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
@@ -8,7 +8,7 @@
8
8
  "license": "ISC",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/HKdigital/hkdigital--lib-sveltekit.git"
11
+ "url": "git+https://github.com/HKdigital/hkdigital--lib-core.git"
12
12
  },
13
13
  "keywords": [
14
14
  "component-library",
@@ -1,73 +0,0 @@
1
- /* == Design dimensions == */
2
-
3
- export const DESIGN = {
4
- width: 1024,
5
- height: 768
6
- };
7
-
8
- /* == Scaling-clamping behaviour == */
9
-
10
- export const CLAMPING = {
11
- ui: { min: 0.3, max: 2 },
12
- textBase: { min: 0.75, max: 1.5 },
13
- textHeading: { min: 0.75, max: 2.25 },
14
- textUi: { min: 0.5, max: 1.25 }
15
- };
16
-
17
- /* == Text == */
18
-
19
- export const TEXT_POINT_SIZES = [
20
- 1, 2, 4, 6, 8, 10, 11, 12, 16, 20, 24, 28, 32, 36, 50
21
- ];
22
-
23
- export const VIEWPORT_POINT_SIZES = [
24
- 1, 2, 4, 5, 6, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180,
25
- 200
26
- ];
27
-
28
- export const TEXT_BASE_SIZES = {
29
- sm: { size: 14, lineHeight: 1.25 },
30
- md: { size: 16, lineHeight: 1.25 },
31
- lg: { size: 18, lineHeight: 1.25 }
32
- };
33
-
34
- export const TEXT_HEADING_SIZES = {
35
- h1: { size: 32, lineHeight: 1.25 },
36
- h2: { size: 28, lineHeight: 1.25 },
37
- h3: { size: 24, lineHeight: 1.25 },
38
- h4: { size: 20, lineHeight: 1.25 },
39
- h5: { size: 16, lineHeight: 1.25 }
40
- };
41
-
42
- export const TEXT_UI_SIZES = {
43
- sm: { size: 14, lineHeight: 1 },
44
- md: { size: 16, lineHeight: 1 },
45
- lg: { size: 18, lineHeight: 1 }
46
- };
47
-
48
- /* == Border radius == */
49
-
50
- export const RADIUS_SIZES = {
51
- none: '0px',
52
- xs: { size: 5 },
53
- sm: { size: 10 },
54
- md: { size: 25 },
55
- lg: { size: 35 },
56
- full: '9999px'
57
- };
58
-
59
- /* == Border width == */
60
-
61
- export const BORDER_WIDTH_SIZES = {
62
- thin: { size: 1 },
63
- normal: { size: 2 },
64
- thick: { size: 4 }
65
- };
66
-
67
- /* == Stroke width == */
68
-
69
- export const STROKE_WIDTH_SIZES = {
70
- thin: { size: 1 },
71
- normal: { size: 2 },
72
- thick: { size: 4 }
73
- };
@@ -1,23 +0,0 @@
1
- export const spacing: {
2
- [x: string]: string;
3
- };
4
- export const fontSize: {
5
- [x: string]: string | [string, {
6
- lineHeight: number;
7
- }];
8
- };
9
- export const borderRadius: {
10
- [x: string]: string;
11
- };
12
- export const borderWidth: {
13
- [key: string]: string;
14
- };
15
- export const strokeWidth: {
16
- [key: string]: string;
17
- };
18
- export const outlineWidth: {
19
- [key: string]: string;
20
- };
21
- export const outlineOffset: {
22
- [key: string]: string;
23
- };
@@ -1,158 +0,0 @@
1
- /**
2
- * Design System Configuration
3
- * Using CSS Custom Properties (variables) for consistent scaling
4
- *
5
- * @note
6
- * The tailwind theme extensions require CSS custom
7
- * properties (variables) to be set at the root level
8
- * of your application to function properly.
9
- *
10
- * @example Implementation in SvelteKit +layout.svelte
11
- * <script>
12
- * import { onMount } from 'svelte';
13
- *
14
- * import '../app.css';
15
- *
16
- * let { children } = $props();
17
- *
18
- * import { DESIGN, CLAMPING }
19
- * from './config/design-config.js';
20
- *
21
- * import { rootDesignVarsHTML }
22
- * from '@hkdigital/lib-core/design/utils/root-vars.js';
23
- * </script>
24
- *
25
- * <svelte:head>
26
- * {@html rootDesignVarsHTML(DESIGN, CLAMPING)}
27
- * </svelte:head>
28
- *
29
- * Base units:
30
- * --scale-w: 0.052vw (Viewport Width Point)
31
- * --scale-h: 0.09259vh (Viewport Height Point)
32
- * --scale-viewport: min(var(--scale-w), var(--scale-h)) (Viewport Point)
33
- * --scale-ui: clamp(0.3, var(--scale-viewport), 2) (UI Point)
34
- * --scale-text-base: clamp(0.75, var(--scale-viewport), 1.5) (Base Text)
35
- * --scale-text-heading: clamp(0.75, var(--scale-viewport), 2.25) (Heading Text)
36
- * --scale-text-ui: clamp(0.5, var(--scale-viewport), 1.25) (UI Text)
37
- *
38
- * --
39
- *
40
- * UI Points (up) - Clamped scaling values
41
- * Based on viewport scaling with minimum and maximum bounds
42
- * to ensure usability across all screen sizes
43
- *
44
- * > PREFERRED METHOD FOR UI ELEMENT SCALING
45
- *
46
- * Examples:
47
- * 5up = 5px at design size (clamps between 1.5px and 10px)
48
- * 10up = 10px at design size (clamps between 3px and 20px)
49
- * 20up = 20px at design size (clamps between 6px and 40px)
50
- *
51
- * Used for:
52
- * - Component padding and margins
53
- * - Interface element sizing
54
- * - Any UI element that needs responsive scaling with guardrails
55
- *
56
- * --
57
- *
58
- * Text-Based Spacing Units (ut, bt, ht)
59
- * Scaled by their respective text scaling variables
60
- *
61
- * > PREFERRED METHOD FOR TEXT-RELATED SPACING
62
- *
63
- * Examples:
64
- * 4ut = calc(4px * var(--scale-text-ui)) // UI text spacing
65
- * 4bt = calc(4px * var(--scale-text-base)) // Base text spacing
66
- * 4ht = calc(4px * var(--scale-text-heading)) // Heading text spacing
67
- *
68
- * Used for:
69
- * - ut: Button padding, form spacing, UI component margins
70
- * - bt: Paragraph margins, list spacing, base gaps
71
- * - ht: Heading margins, title spacing
72
- *
73
- * --
74
- *
75
- * Viewport Points (wp, hp) - Responsive scaling values
76
- * wp: Uses width-based scaling (1920px reference)
77
- * hp: Uses height-based scaling (1080px reference)
78
- *
79
- * > ALTERNATIVE SCALING METHODS
80
- *
81
- * Examples:
82
- * 10wp = calc(10px * var(--scale-w))
83
- * 10hp = calc(10px * var(--scale-h))
84
- *
85
- * Used for:
86
- * - Interface scaling that needs to fit both width and height
87
- * - Maintaining aspect ratio of design
88
- * - Preventing overflow in either direction
89
- */
90
- import {
91
- generateTextBasedSpacing,
92
- generateViewportBasedSpacing,
93
- generateTextStyles,
94
- generateBorderRadiusStyles,
95
- generateWidthStyles
96
- } from './generators/index.js';
97
-
98
- import {
99
- TEXT_POINT_SIZES,
100
- VIEWPORT_POINT_SIZES,
101
- TEXT_BASE_SIZES,
102
- TEXT_HEADING_SIZES,
103
- TEXT_UI_SIZES,
104
- RADIUS_SIZES,
105
- BORDER_WIDTH_SIZES,
106
- STROKE_WIDTH_SIZES
107
- } from './config/design-config.js';
108
-
109
- /* == Internals */
110
-
111
- const TEXT_BASED_SPACING = generateTextBasedSpacing(TEXT_POINT_SIZES);
112
- const VIEWPORT_BASED_SPACING =
113
- generateViewportBasedSpacing(VIEWPORT_POINT_SIZES);
114
-
115
- /* == Exports */
116
-
117
- export const spacing = {
118
- ...VIEWPORT_BASED_SPACING,
119
- ...TEXT_BASED_SPACING
120
- };
121
-
122
- export const fontSize = {
123
- ...TEXT_BASED_SPACING,
124
-
125
- // Named styles
126
- ...generateTextStyles(TEXT_BASE_SIZES, 'base'),
127
- ...generateTextStyles(TEXT_HEADING_SIZES, 'heading'),
128
- ...generateTextStyles(TEXT_UI_SIZES, 'ui')
129
- };
130
-
131
- export const borderRadius = {
132
- // Named styles
133
- ...generateBorderRadiusStyles(RADIUS_SIZES)
134
- };
135
-
136
- export const borderWidth = {
137
- // Named styles
138
- ...generateWidthStyles(BORDER_WIDTH_SIZES, 'width')
139
- };
140
-
141
- export const strokeWidth = {
142
- // Named styles
143
- ...generateWidthStyles(STROKE_WIDTH_SIZES, 'width')
144
- };
145
-
146
- export const outlineWidth = {
147
- // Named styles
148
- ...generateWidthStyles(STROKE_WIDTH_SIZES, '')
149
- };
150
-
151
- export const outlineOffset = {
152
- // Named styles
153
- ...generateWidthStyles(STROKE_WIDTH_SIZES, '')
154
- };
155
-
156
- // console.log('borderWidth', borderWidth);
157
- // console.log('outlineWidth', outlineWidth);
158
- // console.log('outlineOffset', outlineOffset);
@@ -1,9 +0,0 @@
1
- /**
2
- * Create a logger that works in both server and client environments
3
- *
4
- * @param {string} serviceName - Name of the service
5
- * @param {string} [level] - Initial log level
6
- * @param {Object} [options] - Additional options
7
- * @returns {import('../logger').Logger} Configured logger instance
8
- */
9
- export function createLogger(serviceName: string, level?: string, options?: any): import("../logger").Logger;
@@ -1,22 +0,0 @@
1
- /**
2
- * Universal logger factory that auto-detects environment
3
- */
4
- import { browser } from '$app/environment';
5
- import { createServerLogger } from './server.js';
6
- import { createClientLogger } from './client.js';
7
-
8
- /**
9
- * Create a logger that works in both server and client environments
10
- *
11
- * @param {string} serviceName - Name of the service
12
- * @param {string} [level] - Initial log level
13
- * @param {Object} [options] - Additional options
14
- * @returns {import('../logger').Logger} Configured logger instance
15
- */
16
- export function createLogger(serviceName, level, options = {}) {
17
- if (browser) {
18
- return createClientLogger(serviceName, level, options);
19
- } else {
20
- return createServerLogger(serviceName, level, options);
21
- }
22
- }