@ph-itdev/fleet-tracker 0.2026.628

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 ADDED
@@ -0,0 +1,26 @@
1
+ # @ph-itdev/fleet-tracker
2
+
3
+ Track fleet vehicles with GPS coordinates, speed, heading, and geofencing for transportation logistics management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ph-itdev/fleet-tracker
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ const { } = require('@ph-itdev/fleet-tracker');
15
+ ```
16
+
17
+ ## API
18
+
19
+ See source code for full API documentation.
20
+
21
+ ## License
22
+
23
+ MIT
24
+
25
+ ---
26
+ *Auto-generated by logistics-npm pipeline — 2026-06-28*
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Type definitions for @ph-itdev/fleet-tracker
2
+ export * from './index.js';
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ // Fleet GPS Tracker
2
+ // Track fleet vehicles with GPS coordinates, speed, heading, and geofencing for transportation logistics management.
3
+ // Auto-generated by @ph-itdev/logistics-pipeline
4
+
5
+
6
+ class FleetTracker {
7
+ constructor() { this.vehicles = new Map(); this.geofences = new Map(); this.alerts = []; }
8
+ registerVehicle(id, name, metadata = {}) { this.vehicles.set(id, { id, name, ...metadata, position: null, speed: 0, heading: 0, history: [] }); }
9
+ updatePosition(id, { lat, lon, speed = 0, heading = 0 }) {
10
+ const v = this.vehicles.get(id);
11
+ if (!v) throw new Error('Vehicle not found');
12
+ v.position = { lat, lon, timestamp: Date.now() };
13
+ v.speed = speed;
14
+ v.heading = heading;
15
+ v.history.push({ ...v.position, speed, heading });
16
+ this._checkGeofences(id, lat, lon);
17
+ return v;
18
+ }
19
+ addGeofence(id, name, { centerLat, centerLon, radiusKm }) {
20
+ this.geofences.set(id, { id, name, centerLat, centerLon, radiusKm });
21
+ }
22
+ _checkGeofences(vehicleId, lat, lon) {
23
+ for (const gf of this.geofences.values()) {
24
+ const R = 6371;
25
+ const dLat = (lat - gf.centerLat) * Math.PI / 180;
26
+ const dLon = (lon - gf.centerLon) * Math.PI / 180;
27
+ const a = Math.sin(dLat/2)**2 + Math.cos(gf.centerLat*Math.PI/180)*Math.cos(lat*Math.PI/180)*Math.sin(dLon/2)**2;
28
+ const dist = R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
29
+ const inside = dist <= gf.radiusKm;
30
+ const v = this.vehicles.get(vehicleId);
31
+ const wasInside = v._geofences?.[gf.id] ?? false;
32
+ if (wasInside && !inside) this.alerts.push({ vehicleId, geofence: gf.name, event: 'EXIT', ts: Date.now() });
33
+ if (!wasInside && inside) this.alerts.push({ vehicleId, geofence: gf.name, event: 'ENTER', ts: Date.now() });
34
+ if (!v._geofences) v._geofences = {};
35
+ v._geofences[gf.id] = inside;
36
+ }
37
+ }
38
+ getVehicle(id) { return this.vehicles.get(id) || null; }
39
+ getAllVehicles() { return [...this.vehicles.values()].map(v => ({ id: v.id, name: v.name, position: v.position, speed: v.speed })); }
40
+ getAlerts(filter = {}) { return this.alerts.filter(a => filter.vehicleId ? a.vehicleId === filter.vehicleId : true); }
41
+ }
42
+
43
+
44
+ module.exports = { FleetTracker };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@ph-itdev/fleet-tracker",
3
+ "version": "0.2026.0628",
4
+ "description": "Track fleet vehicles with GPS coordinates, speed, heading, and geofencing for transportation logistics management.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "commonjs",
8
+ "scripts": {
9
+ "test": "node test.js",
10
+ "lint": "echo 'lint ok'"
11
+ },
12
+ "keywords": [
13
+ "logistics",
14
+ "automation",
15
+ "shipping",
16
+ "supply-chain",
17
+ "fleet"
18
+ ],
19
+ "author": "@ph-itdev",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/nilskie06/fleet-tracker.git"
24
+ },
25
+ "homepage": "https://github.com/nilskie06/fleet-tracker#readme",
26
+ "bugs": {
27
+ "url": "https://github.com/nilskie06/fleet-tracker/issues"
28
+ },
29
+ "engines": {
30
+ "node": ">=14.0.0"
31
+ }
32
+ }