@sudobility/di_web 0.1.117 → 0.1.119

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 +60 -27
  2. package/package.json +8 -8
package/README.md CHANGED
@@ -1,52 +1,85 @@
1
1
  # @sudobility/di_web
2
2
 
3
- Web implementations of dependency injection services for Sudobility.
3
+ Web-specific implementations of dependency injection services for Sudobility applications. Implements interfaces from `@sudobility/di` using browser APIs and React, plus a shared service worker with a Vite plugin.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @sudobility/di_web @sudobility/di @sudobility/types
8
+ bun install @sudobility/di_web @sudobility/di @sudobility/types @sudobility/components
9
+ ```
10
+
11
+ Optional peer dependency for service worker plugin:
12
+ ```bash
13
+ bun install vite # Vite 5, 6, or 7
9
14
  ```
10
15
 
11
16
  ## Usage
12
17
 
18
+ ### App Initialization
19
+
13
20
  ```typescript
14
- import { webNetworkClient, webStorageService, webAnalyticsService } from '@sudobility/di_web';
21
+ import { initializeWebApp } from '@sudobility/di_web';
15
22
 
16
- // Use the pre-configured singleton instances
17
- const response = await webNetworkClient.get('https://api.example.com/data');
23
+ await initializeWebApp({
24
+ firebaseConfig: { apiKey: '...', projectId: '...' },
25
+ registerServiceWorker: true,
26
+ });
18
27
  ```
19
28
 
20
- ## Services
29
+ ### Info Banner (Toast Notifications)
21
30
 
22
- - **Network Client**: Axios-based HTTP client with retry logic
23
- - **Storage Service**: LocalStorage-based persistence
24
- - **Analytics Service**: Web analytics tracking
25
- - **Notification Service**: Browser notification support
26
- - **Navigation Service**: Web navigation helpers
27
- - **Theme Service**: Dark/light theme management
28
- - **Persistence Service**: IndexedDB-based storage
29
- - **Firebase Service**: Firebase initialization for web
31
+ ```typescript
32
+ import { getInfoService, InfoBanner } from '@sudobility/di_web';
33
+ import { InfoType } from '@sudobility/types';
30
34
 
31
- ## Development
35
+ // Show notifications from anywhere
36
+ getInfoService().show('Saved', 'Changes saved successfully', InfoType.SUCCESS);
37
+ getInfoService().show('Error', 'Something went wrong', InfoType.ERROR, 10000);
32
38
 
33
- ```bash
34
- # Install dependencies
35
- npm install
39
+ // Render once in app root
40
+ function App() {
41
+ return (<><AppContent /><InfoBanner /></>);
42
+ }
43
+ ```
36
44
 
37
- # Build
38
- npm run build
45
+ ### Service Worker (Vite Plugin)
39
46
 
40
- # Watch mode
41
- npm run dev
47
+ ```typescript
48
+ // vite.config.ts
49
+ import { serviceWorkerPlugin } from '@sudobility/di_web/vite';
50
+
51
+ export default {
52
+ plugins: [
53
+ serviceWorkerPlugin({ includeFirebaseMessaging: true }),
54
+ ],
55
+ };
56
+ ```
57
+
58
+ Caching strategies: Cache First (static assets, images), Network First (HTML), Stale While Revalidate (locale files).
59
+
60
+ ## Services
61
+
62
+ | Service | Purpose |
63
+ |---------|---------|
64
+ | `WebInfoService` | Observable banner/toast notifications with auto-dismiss |
65
+ | `InfoBanner` | Drop-in React component for rendering toasts |
66
+ | `initializeWebApp` | Orchestrator for all DI service initialization |
67
+ | `serviceWorkerPlugin` | Vite plugin for service worker build and dev |
68
+ | `registerServiceWorker` | Production service worker registration |
42
69
 
43
- # Run tests
44
- npm test
70
+ ## Development
45
71
 
46
- # Lint
47
- npm run lint
72
+ ```bash
73
+ bun install
74
+ bun run build # Compile (tsc + copy SW files)
75
+ bun run build:watch # Watch mode
76
+ bun run typecheck # TypeScript check
77
+ bun run test # Run tests (Vitest, jsdom)
78
+ bun run test:coverage # With coverage report
79
+ bun run lint # ESLint
80
+ bun run format # Prettier
48
81
  ```
49
82
 
50
83
  ## License
51
84
 
52
- MIT
85
+ BUSL-1.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/di_web",
3
- "version": "0.1.117",
3
+ "version": "0.1.119",
4
4
  "description": "Web implementations of dependency injection services for Sudobility",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,9 +42,9 @@
42
42
  "author": "Sudobility Inc",
43
43
  "license": "BUSL-1.1",
44
44
  "peerDependencies": {
45
- "@sudobility/components": "^5.0.17",
46
- "@sudobility/di": "^1.5.43",
47
- "@sudobility/types": "^1.9.55",
45
+ "@sudobility/components": "^5.0.20",
46
+ "@sudobility/di": "^1.5.45",
47
+ "@sudobility/types": "^1.9.57",
48
48
  "react": "^18.0.0 || ^19.0.0",
49
49
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
50
50
  },
@@ -62,10 +62,10 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@eslint/js": "^9.38.0",
65
- "@sudobility/components": "^5.0.17",
66
- "@sudobility/di": "^1.5.43",
67
- "@sudobility/subscription_lib": "^0.0.19",
68
- "@sudobility/types": "^1.9.55",
65
+ "@sudobility/components": "^5.0.20",
66
+ "@sudobility/di": "^1.5.45",
67
+ "@sudobility/subscription_lib": "^0.0.20",
68
+ "@sudobility/types": "^1.9.57",
69
69
  "@types/node": "^24.10.1",
70
70
  "@types/react": "^19.1.8",
71
71
  "@typescript-eslint/eslint-plugin": "^8.46.2",