@hkdigital/lib-core 0.5.11 → 0.5.12

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 (2) hide show
  1. package/README.md +148 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -32,6 +32,9 @@ pnpm add @skeletonlabs/skeleton
32
32
  # UI icons
33
33
  pnpm add @steeze-ui/heroicons
34
34
 
35
+ # CSS processing (Tailwind and PostCSS)
36
+ pnpm add tailwindcss @tailwindcss/postcss postcss autoprefixer
37
+
35
38
  # Logging
36
39
  pnpm add pino pino-pretty
37
40
 
@@ -42,13 +45,13 @@ pnpm add jsonwebtoken
42
45
  pnpm add @eslint/js eslint-plugin-import
43
46
 
44
47
  # Image processing
45
- pnpm add vite-imagetools
48
+ pnpm add -D vite-imagetools
46
49
  ```
47
50
 
48
51
  **For other libraries**, install as dev dependencies and declare as peer dependencies:
49
52
  ```bash
50
53
  # Install as dev dependencies and peer dependencies
51
- pnpm add -D --save-peer @sveltejs/kit svelte svelte-preprocess runed valibot @skeletonlabs/skeleton @steeze-ui/heroicons pino pino-pretty jsonwebtoken @eslint/js eslint-plugin-import vite-imagetools
54
+ pnpm add -D --save-peer @sveltejs/kit svelte svelte-preprocess runed valibot @skeletonlabs/skeleton @steeze-ui/heroicons tailwindcss @tailwindcss/postcss postcss autoprefixer pino pino-pretty jsonwebtoken @eslint/js eslint-plugin-import vite-imagetools
52
55
  ```
53
56
 
54
57
  ### Design System & Configuration
@@ -135,7 +138,8 @@ This library includes a complete design system with Tailwind CSS integration. Ba
135
138
  export default config;
136
139
  ```
137
140
 
138
- 5. **TypeScript support for imagetools** - Add image import definitions to `app.d.ts`:
141
+ 5. **Image import type definitions** - Add imagetools type support to
142
+ `app.d.ts`:
139
143
  ```typescript
140
144
  // src/app.d.ts
141
145
  import '@hkdigital/lib-core/config/imagetools.d.ts';
@@ -179,6 +183,59 @@ This library includes a complete design system with Tailwind CSS integration. Ba
179
183
  import heroResponsive from '$lib/assets/hero.jpg?preset=photo&responsive';
180
184
  ```
181
185
 
186
+ 6. **(meta) folder setup** - Copy and configure PWA/favicon generation:
187
+
188
+ The library includes a complete `(meta)` folder with PWA configuration,
189
+ favicon generation, manifest.json, sitemap.xml, and robots.txt endpoints.
190
+
191
+ **Copy the folder to your project:**
192
+ ```bash
193
+ cp -r node_modules/@hkdigital/lib-core/src/routes/\(meta\) src/routes/
194
+ ```
195
+
196
+ **Customize for your app:**
197
+ - Replace `src/routes/(meta)/favicon.png` with your 512×512px image
198
+ - Edit `src/routes/(meta)/config.js`:
199
+ ```javascript
200
+ export const name = 'Your App Name';
201
+ export const shortName = 'App';
202
+ export const description = 'Your app description';
203
+ export const backgroundAndThemeColor = '#082962';
204
+
205
+ // Add your site routes for sitemap
206
+ export const siteRoutes = ['/', '/about', '/contact'];
207
+
208
+ // Configure robots.txt (prevent test sites from being indexed)
209
+ export const robotsConfig = {
210
+ allowedHosts: ['mysite.com', 'www.mysite.com'],
211
+ disallowedPaths: ['/admin/*'],
212
+ includeSitemap: true
213
+ };
214
+ ```
215
+
216
+ **Integrate into root layout:**
217
+ ```svelte
218
+ <!-- src/routes/+layout.svelte -->
219
+ <script>
220
+ import { Favicons, PWA } from './(meta)/index.js';
221
+ </script>
222
+
223
+ <Favicons />
224
+ <PWA />
225
+
226
+ {@render children()}
227
+ ```
228
+
229
+ **What you get:**
230
+ - Automatic favicon generation (16, 32, 192, 512px)
231
+ - Apple touch icons (120, 152, 167, 180px)
232
+ - Dynamic `/manifest.json` endpoint
233
+ - Dynamic `/sitemap.xml` endpoint
234
+ - Dynamic `/robots.txt` with host filtering
235
+
236
+ See [src/routes/(meta)/README.md](./src/routes/(meta)/README.md) for
237
+ complete documentation.
238
+
182
239
  ### Logging System
183
240
 
184
241
  The library includes a comprehensive logging system that provides:
@@ -220,34 +277,112 @@ pnpm run upgrade:all # Update all packages
220
277
  pnpm run publish:npm # Version bump and publish to npm
221
278
  ```
222
279
 
223
- ### Import JS, Svelte files and Typedefs
280
+ ### Import Patterns and Export Structure
224
281
 
225
- Main folders in lib have an index.js, but may also have a more specific export file e.g. http.js or cache.js (@see $lib/network).
282
+ **Public exports use domain-specific files matching folder names:**
226
283
 
227
- Main folders (should) have a typedef.js that can be used in JSdoc comments.
284
+ ```js
285
+ // Standard pattern: folder → matching .js export file
286
+ import { httpGet, httpPost } from '@hkdigital/lib-core/network/http.js';
287
+ import { CacheManager } from '@hkdigital/lib-core/network/cache.js';
288
+ import { LCHAR } from '@hkdigital/lib-core/constants/regexp.js';
289
+ import { Button } from '@hkdigital/lib-core/ui/primitives.js';
290
+ ```
291
+
292
+ **Pattern:**
293
+ - Folder `$lib/network/http/` → Export file `$lib/network/http.js`
294
+ - Folder `$lib/network/cache/` → Export file `$lib/network/cache.js`
295
+ - Folder `$lib/constants/regexp/` → Export file `$lib/constants/regexp.js`
296
+
297
+ **Rare exception - index.js for aggregated APIs:**
228
298
 
229
299
  ```js
230
- // Import Latin char constant for use in regular expressions
231
- import { LCHAR } from '@hkdigital/lib-core/constants/regexp/index.js';
300
+ // Only used for large subsystems with public-facing aggregated APIs
301
+ import { designTokens } from '@hkdigital/lib-core/design/index.js';
232
302
  ```
233
303
 
304
+ **TypeDefs for JSDoc:**
305
+
234
306
  ```js
235
307
  /**
236
- * @param {import('@hkdigital/lib-core/network/typedef.js').JsonGetOptions} JsonGetOptions
308
+ * @param {import('@hkdigital/lib-core/network/typedef.js').HttpGetOptions}
309
+ * options
237
310
  */
311
+ function fetchData(options) {
312
+ // ...
313
+ }
238
314
  ```
239
315
 
240
- ### Import CSS
316
+ ### CSS Architecture (app.css)
241
317
 
242
- Vite should include postcss-import, but the only solution to get it working for now is to use a relative path to the node_modules folder.
318
+ **CRITICAL**: Your `src/app.css` must include the complete design system
319
+ architecture. Incomplete imports will cause build failures.
243
320
 
244
- For example:
321
+ **Required structure:**
245
322
 
246
323
  ```css
247
324
  /* src/app.css */
248
- @import '../node_modules/@hkdigital/lib-core/dist/css/utilities.css';
325
+
326
+ /* 1. CSS Layers - Controls style precedence */
327
+ @layer theme, base, utilities, components;
328
+
329
+ /* 2. Tailwind CSS Core */
330
+ @import 'tailwindcss';
331
+
332
+ /* 3. HKdigital Design System Theme (ALL required for colors to work) */
333
+ @import '../node_modules/@hkdigital/lib-core/dist/design/themes/hkdev/theme.css' layer(theme);
334
+ @import '../node_modules/@hkdigital/lib-core/dist/design/themes/hkdev/globals.css';
335
+ @import '../node_modules/@hkdigital/lib-core/dist/design/themes/hkdev/components.css' layer(components);
336
+ @import '../node_modules/@hkdigital/lib-core/dist/design/themes/hkdev/responsive.css';
337
+
338
+ /* 4. Skeleton UI Framework */
339
+ @import '@skeletonlabs/skeleton' source('../node_modules/@skeletonlabs/skeleton-svelte/dist');
340
+ @import '@skeletonlabs/skeleton/optional/presets' source('../node_modules/@skeletonlabs/skeleton-svelte/dist');
341
+
342
+ /* 5. Tailwind Configuration Reference */
343
+ @config "../tailwind.config.js";
344
+
345
+ /* 6. Optional: Additional utilities */
346
+ /*@import '../node_modules/@hkdigital/lib-core/dist/css/utilities.css';*/
249
347
  ```
250
348
 
349
+ **Why all theme files are required:**
350
+ - Missing any theme file will cause "Cannot apply unknown utility class"
351
+ errors
352
+ - Classes like `bg-surface-100`, `text-primary-500` won't work without
353
+ complete theme
354
+ - All four theme files (theme.css, globals.css, components.css,
355
+ responsive.css) are needed
356
+
357
+ See [src/lib/design/README.md](./src/lib/design/README.md) for complete
358
+ CSS architecture documentation.
359
+
360
+ ### Critical: data-theme Attribute
361
+
362
+ **IMPORTANT**: Add `data-theme="hkdev"` to your `<body>` element in
363
+ `src/app.html`. Without this, theme colors will not work correctly.
364
+
365
+ ```html
366
+ <!-- src/app.html -->
367
+ <!doctype html>
368
+ <html lang="en">
369
+ <head>
370
+ <meta charset="utf-8" />
371
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
372
+ %sveltekit.head%
373
+ </head>
374
+ <body data-theme="hkdev" data-sveltekit-preload-data="hover">
375
+ <div>%sveltekit.body%</div>
376
+ </body>
377
+ </html>
378
+ ```
379
+
380
+ **Why this is required:**
381
+ - Theme CSS custom properties are scoped to `[data-theme='hkdev']`
382
+ - Without this attribute, colors fall back to browser defaults
383
+ - **Symptom**: Colors like `bg-primary-500` show grey instead of magenta
384
+ - **Solution**: Add `data-theme="hkdev"` to `<body>` element
385
+
251
386
  ## Building the library
252
387
 
253
388
  To build your library:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"