@sudobility/di_web 0.1.118 → 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.
- package/README.md +60 -27
- 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
|
-
|
|
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 {
|
|
21
|
+
import { initializeWebApp } from '@sudobility/di_web';
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
await initializeWebApp({
|
|
24
|
+
firebaseConfig: { apiKey: '...', projectId: '...' },
|
|
25
|
+
registerServiceWorker: true,
|
|
26
|
+
});
|
|
18
27
|
```
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
### Info Banner (Toast Notifications)
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
// Render once in app root
|
|
40
|
+
function App() {
|
|
41
|
+
return (<><AppContent /><InfoBanner /></>);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
npm run build
|
|
45
|
+
### Service Worker (Vite Plugin)
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
44
|
-
npm test
|
|
70
|
+
## Development
|
|
45
71
|
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
85
|
+
BUSL-1.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/di_web",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
46
|
-
"@sudobility/di": "^1.5.
|
|
47
|
-
"@sudobility/types": "^1.9.
|
|
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.
|
|
66
|
-
"@sudobility/di": "^1.5.
|
|
67
|
-
"@sudobility/subscription_lib": "^0.0.
|
|
68
|
-
"@sudobility/types": "^1.9.
|
|
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",
|