@quan-erp/shared-frontend-core 1.0.0
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 +92 -0
- package/dist/index.js +2921 -0
- package/dist/types/core/accelerometer.d.ts +47 -0
- package/dist/types/core/assets.d.ts +13 -0
- package/dist/types/core/backend-api.d.ts +2 -0
- package/dist/types/core/background-location.d.ts +1 -0
- package/dist/types/core/battery.d.ts +40 -0
- package/dist/types/core/bluetooth.d.ts +77 -0
- package/dist/types/core/camera.d.ts +83 -0
- package/dist/types/core/clipboard.d.ts +56 -0
- package/dist/types/core/database.d.ts +13 -0
- package/dist/types/core/device-class-tier.d.ts +19 -0
- package/dist/types/core/device-fingerprint.d.ts +29 -0
- package/dist/types/core/device.d.ts +33 -0
- package/dist/types/core/filesystem.d.ts +85 -0
- package/dist/types/core/firebase.d.ts +5 -0
- package/dist/types/core/gyroscope.d.ts +52 -0
- package/dist/types/core/index.d.ts +32 -0
- package/dist/types/core/location.d.ts +87 -0
- package/dist/types/core/microphone.d.ts +54 -0
- package/dist/types/core/morientation.d.ts +14 -0
- package/dist/types/core/motion-orientation.d.ts +25 -0
- package/dist/types/core/network.d.ts +15 -0
- package/dist/types/core/notification.d.ts +113 -0
- package/dist/types/core/number-formatter.d.ts +20 -0
- package/dist/types/core/orientation.d.ts +49 -0
- package/dist/types/core/permissions.d.ts +6 -0
- package/dist/types/core/platform.d.ts +27 -0
- package/dist/types/core/plugin-api.d.ts +33 -0
- package/dist/types/core/printer.d.ts +54 -0
- package/dist/types/core/safearea.d.ts +30 -0
- package/dist/types/core/shared-preferences.d.ts +61 -0
- package/dist/types/core/sqlite.d.ts +18 -0
- package/dist/types/core/system-locale.d.ts +24 -0
- package/dist/types/core/system.d.ts +109 -0
- package/dist/types/core/user-behavior.d.ts +24 -0
- package/dist/types/core/user-hand-behavior.d.ts +90 -0
- package/dist/types/core/vibration.d.ts +78 -0
- package/dist/types/dto/dto.d.ts +9 -0
- package/dist/types/dto/index.d.ts +2 -0
- package/dist/types/dto/pagination.dto.d.ts +29 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/security/websecurity.d.ts +4 -0
- package/dist/types/utilities/index.d.ts +1 -0
- package/dist/types/utilities/plugin-expose.d.ts +5 -0
- package/dist/types/utilities/version.util.d.ts +53 -0
- package/external-global-rollup-config.json +61 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Quan ERP Frontend Core Framework
|
|
2
|
+
|
|
3
|
+
The Hardware Abstraction Layer (HAL) and System Bridge for the Quan ERP frontend ecosystem. This library provides a unified, secure, and performant API for accessing native device features and system resources across multiple platforms.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏗️ Platform Abstraction Layer (PAL)
|
|
8
|
+
|
|
9
|
+
The framework is designed to satisfy the "Write Once, Run Anywhere" philosophy by abstracting the differences between Web, Native Mobile (via Capacitor), and Desktop (via Electron).
|
|
10
|
+
|
|
11
|
+
### Environment Detection
|
|
12
|
+
The `Platforms` class provides static methods to identify the runtime environment:
|
|
13
|
+
- **Mobile**: Detects Capacitor native platforms (iOS/Android).
|
|
14
|
+
- **Desktop**: Detects Electron renderer processes.
|
|
15
|
+
- **Web**: Fallback for standard browser environments.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🛡️ Kernel-Level Security
|
|
20
|
+
|
|
21
|
+
To ensure system integrity and prevent unauthorized access to sensitive device information, the library implements a **Global Injection Protection** strategy.
|
|
22
|
+
|
|
23
|
+
### Object Freezing
|
|
24
|
+
In `websecurity.ts`, critical browser globals are intercepted and locked:
|
|
25
|
+
- `window.navigator`: Managed to prevent fingerprinting and uncontrolled hardware access.
|
|
26
|
+
- `window.localStorage`: Restricted to encourage the use of the library's managed storage bridges.
|
|
27
|
+
- `window.sessionStorage`: Similarly restricted for security compliance.
|
|
28
|
+
|
|
29
|
+
> [!CAUTION]
|
|
30
|
+
> Direct access to these globals will trigger console warnings. Developers are expected to use the provided `System` and `SystemLocale` APIs instead.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🔌 Hardware & Device Bridges
|
|
35
|
+
|
|
36
|
+
The core provides a comprehensive suite of "Bridges" that wrap native capabilities in standardized, promise-based TypeScript APIs.
|
|
37
|
+
|
|
38
|
+
### Available Bridges
|
|
39
|
+
- **Vision & Audio**: `Camera`, `Microphone`.
|
|
40
|
+
- **Connectivity**: `Bluetooth`, `Network`, `Firebase` (Push Notifications).
|
|
41
|
+
- **Storage**: `Filesystem`, `SQLite`, `Database` (Scoped).
|
|
42
|
+
- **Sensing**: `Location` (GPS), `Accelerometer`, `Gyroscope`, `MotionOrientation`.
|
|
43
|
+
- **Utility**: `Clipboard`, `Battery`, `Printer`, `Vibration`, `Orientation`.
|
|
44
|
+
|
|
45
|
+
### Usage Pattern
|
|
46
|
+
```typescript
|
|
47
|
+
import { Camera, Location } from '@quan-erp/shared-frontend-core';
|
|
48
|
+
|
|
49
|
+
// Snapshot capability
|
|
50
|
+
const photo = await Camera.takePhoto();
|
|
51
|
+
|
|
52
|
+
// Precise location
|
|
53
|
+
const coords = await Location.getCurrentPosition();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🧠 System Intelligence
|
|
59
|
+
|
|
60
|
+
The `System` class acts as a central hub for resource monitoring and environment diagnostics.
|
|
61
|
+
|
|
62
|
+
| Feature | Description |
|
|
63
|
+
| :--- | :--- |
|
|
64
|
+
| **CPU Monitoring** | Real-time tracking of CPU usage and core count. |
|
|
65
|
+
| **Memory Diagnostics** | Tracks used vs. total JS heap and device RAM (Platform dependent). |
|
|
66
|
+
| **Network State** | Detects network type (WiFi, Cellular, 4G/5G) and connection quality. |
|
|
67
|
+
| **Identity** | Retrieves detailed device information (OS version, Browser engine, etc.). |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ⚙️ Application Integration
|
|
72
|
+
|
|
73
|
+
### Backend Connectivity
|
|
74
|
+
Use `setBackendAPI(url)` to configure the global endpoint for all core-related network requests.
|
|
75
|
+
|
|
76
|
+
### Globalization
|
|
77
|
+
- **`SystemLocale`**: Detects system-level language and region settings.
|
|
78
|
+
- **`NumberFormatter`**: Provides consistent currency and decimal formatting across all ERP modules.
|
|
79
|
+
|
|
80
|
+
### User Behavior
|
|
81
|
+
The `UserHandBehavior` utility tracks and predicts hand orientation (Left vs. Right) to optimize UI layouts for one-handed use on mobile devices.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🔌 Plugin API
|
|
86
|
+
|
|
87
|
+
For dynamic frontend plugins, the library exposes a `PluginAPI` that bridges the gap between third-party modules and the core's native capability layer. This ensures that even dynamically loaded code adheres to the kernel's security and abstraction standards.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
> [!IMPORTANT]
|
|
92
|
+
> This library is a peer dependency for all `@quan-erp-plugins/*-frontend` packages. Always verify compatibility with the core version before upgrading native plugins.
|