@ph-itdev/load-optimizer 0.2026.703

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/load-optimizer
2
+
3
+ Optimize truck load and pallet configurations using bin-packing heuristics to maximize space utilization for freight logistics.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ph-itdev/load-optimizer
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ const { } = require('@ph-itdev/load-optimizer');
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-07-03*
package/bin/cli.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ // @ph-itdev/load-optimizer CLI
4
+ // Usage: npx @ph-itdev/load-optimizer playground
5
+
6
+ const http = require('http');
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { exec } = require('child_process');
10
+
11
+ const args = process.argv.slice(2);
12
+ const command = args[0];
13
+
14
+ if (command === 'playground' || command === 'demo' || command === 'play') {
15
+ startPlayground();
16
+ } else if (command === 'help' || !command) {
17
+ console.log(`
18
+ 📦 @ph-itdev/load-optimizer
19
+
20
+ Commands:
21
+ npx @ph-itdev/load-optimizer playground Open interactive playground in browser
22
+ npx @ph-itdev/load-optimizer demo Same as playground
23
+ npx @ph-itdev/load-optimizer help Show this help
24
+ `);
25
+ } else {
26
+ console.log(`Unknown command: ${command}. Run with "help" for usage.`);
27
+ }
28
+
29
+ function startPlayground() {
30
+ const examplePath = path.join(__dirname, '..', 'example', 'index.html');
31
+
32
+ if (!fs.existsSync(examplePath)) {
33
+ console.error('❌ Example file not found. Try: npm install @ph-itdev/load-optimizer');
34
+ process.exit(1);
35
+ }
36
+
37
+ const html = fs.readFileSync(examplePath, 'utf-8');
38
+
39
+ const server = http.createServer((req, res) => {
40
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
41
+ res.end(html);
42
+ });
43
+
44
+ const PORT = 3456;
45
+
46
+ server.listen(PORT, '127.0.0.1', () => {
47
+ const url = `http://localhost:${PORT}`;
48
+ console.log(`
49
+ 📦 @ph-itdev/load-optimizer — Playground running!
50
+
51
+ 🌐 Open: ${url}
52
+
53
+ Press Ctrl+C to stop.
54
+ `);
55
+ const platform = process.platform;
56
+ if (platform === 'darwin') exec(`open ${url}`);
57
+ else if (platform === 'win32') exec(`start ${url}`);
58
+ else exec(`xdg-open ${url} 2>/dev/null || echo "Open ${url} in your browser"`);
59
+ });
60
+
61
+ server.on('error', (err) => {
62
+ if (err.code === 'EADDRINUSE') {
63
+ console.log(`⚠️ Port ${PORT} in use. Opening http://localhost:${PORT} instead.`);
64
+ const platform = process.platform;
65
+ if (platform === 'darwin') exec(`open http://localhost:${PORT}`);
66
+ else if (platform === 'win32') exec(`start http://localhost:${PORT}`);
67
+ else exec(`xdg-open http://localhost:${PORT} 2>/dev/null`);
68
+ } else {
69
+ console.error('Server error:', err);
70
+ }
71
+ });
72
+ }
@@ -0,0 +1,88 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>@ph-itdev/load-optimizer — Live Playground</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body { font-family: 'JetBrains Mono','Fira Code',monospace; background: #0a0e1a; color: #e0e6f0; min-height: 100vh; }
10
+ .header { background: linear-gradient(135deg, #0c1430 0%, #1a0a2e 100%); border-bottom: 1px solid rgba(0,229,255,0.15); padding: 24px 32px; text-align: center; }
11
+ .header h1 { font-size: 28px; color: #00e5ff; margin-bottom: 6px; letter-spacing: 2px; }
12
+ .header p { color: #7eb8c9; font-size: 13px; opacity: 0.7; }
13
+ .header .badge { display: inline-block; background: rgba(0,229,255,0.1); border: 1px solid rgba(0,229,255,0.3); color: #00e5ff; padding: 4px 12px; border-radius: 4px; font-size: 12px; margin-top: 10px; }
14
+ .container { max-width: 1100px; margin: 0 auto; padding: 24px; }
15
+ .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
16
+ @media (max-width: 768px) { .grid { grid-template-columns: 1fr; } }
17
+ .panel { background: rgba(12,20,48,0.8); border: 1px solid rgba(0,229,255,0.1); border-radius: 10px; padding: 18px; }
18
+ .panel h2 { font-size: 14px; color: #00e5ff; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px dashed rgba(0,229,255,0.15); }
19
+ label { display: block; font-size: 11px; color: #7eb8c9; margin-bottom: 4px; letter-spacing: 1px; }
20
+ input, select { width: 100%; background: rgba(0,229,255,0.04); border: 1px solid rgba(0,229,255,0.15); color: #e0e6f0; padding: 8px 12px; border-radius: 6px; font-family: inherit; font-size: 13px; margin-bottom: 10px; outline: none; }
21
+ input:focus, select:focus { border-color: rgba(0,229,255,0.5); }
22
+ select option { background: #0c1430; }
23
+ .row { display: flex; gap: 10px; } .row > * { flex: 1; }
24
+ button { background: linear-gradient(135deg, rgba(0,229,255,0.15), rgba(0,229,255,0.05)); border: 1px solid rgba(0,229,255,0.35); color: #00e5ff; padding: 10px 18px; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 13px; letter-spacing: 1px; transition: all 0.2s; margin-top: 4px; }
25
+ button:hover { background: rgba(0,229,255,0.2); box-shadow: 0 0 12px rgba(0,229,255,0.2); }
26
+ button.danger { border-color: rgba(255,100,100,0.4); color: #ff6464; }
27
+ button.danger:hover { background: rgba(255,100,100,0.15); }
28
+ .output { background: #060a14; border: 1px solid rgba(0,229,255,0.08); border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.6; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
29
+ .output .log { color: #7eb8c9; } .output .success { color: #28c840; } .output .error { color: #ff6464; } .output .info { color: #00e5ff; } .output .warn { color: #ffb352; }
30
+ .full-width { grid-column: 1 / -1; }
31
+ ::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); border-radius: 3px; }
32
+ </style>
33
+ </head>
34
+ <body>
35
+ <div class="header">
36
+ <h1>📦 load-optimizer</h1>
37
+ <p>Optimize truck load and pallet configurations using bin-packing heuristics to maximize space utilization for freight logistics.</p>
38
+ <span class="badge">npm install @ph-itdev/load-optimizer</span>
39
+ </div>
40
+ <div class="container">
41
+ <div class="grid">
42
+ <div class="panel">
43
+ <h2>🚀 Try It</h2>
44
+ <p style="font-size:12px;color:#7eb8c9;margin-bottom:12px;">Run in your terminal:</p>
45
+ <div class="output" style="max-height:none;">
46
+ <div class="info"># Install</div>
47
+ <div class="success">npm install @ph-itdev/load-optimizer</div>
48
+ <br>
49
+ <div class="info"># Open playground</div>
50
+ <div class="success">npx load-optimizer playground</div>
51
+ <br>
52
+ <div class="info"># Use in code</div>
53
+ <div class="log">const pkg = require('@ph-itdev/load-optimizer');</div>
54
+ <div class="log">console.log(Object.keys(pkg));</div>
55
+ </div>
56
+ </div>
57
+ <div class="panel">
58
+ <h2>📦 Package Info</h2>
59
+ <div class="output" style="max-height:none;">
60
+ <div class="log">Name: @ph-itdev/load-optimizer</div>
61
+ <div class="log">Version: 1.0.0</div>
62
+ <div class="log">License: MIT</div>
63
+ <div class="log">Author: @ph-itdev</div>
64
+ <div class="log">Registry: npmjs.com</div>
65
+ <div class="log">Repo: github.com/nilskie06/load-optimizer</div>
66
+ </div>
67
+ </div>
68
+ <div class="panel full-width">
69
+ <h2>💻 Console</h2>
70
+ <div id="console" class="output"></div>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ <script>
75
+ function log(msg, cls='log') {
76
+ const el = document.getElementById('console');
77
+ const line = document.createElement('div');
78
+ line.className = cls;
79
+ line.textContent = '[' + new Date().toLocaleTimeString() + '] ' + msg;
80
+ el.appendChild(line);
81
+ el.scrollTop = el.scrollHeight;
82
+ }
83
+ log('🚀 Welcome! This is the interactive playground for @ph-itdev/load-optimizer', 'info');
84
+ log(' Install: npm install @ph-itdev/load-optimizer', 'info');
85
+ log(' CLI: npx load-optimizer playground', 'info');
86
+ </script>
87
+ </body>
88
+ </html>
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Type definitions for @ph-itdev/load-optimizer
2
+ export * from './index.js';
package/index.js ADDED
@@ -0,0 +1,53 @@
1
+ // Load & Pallet Optimizer
2
+ // Optimize truck load and pallet configurations using bin-packing heuristics to maximize space utilization for freight logistics.
3
+ // Auto-generated by @ph-itdev/logistics-pipeline
4
+
5
+
6
+ function firstFitDecreasing(items, containerCapacity) {
7
+ const sorted = [...items].sort((a, b) => b.weight - a.weight);
8
+ const containers = [];
9
+ for (const item of sorted) {
10
+ let placed = false;
11
+ for (const c of containers) {
12
+ if (c.used + item.weight <= containerCapacity) { c.items.push(item); c.used += item.weight; placed = true; break; }
13
+ }
14
+ if (!placed) containers.push({ items: [item], used: item.weight, capacity: containerCapacity });
15
+ }
16
+ return containers;
17
+ }
18
+
19
+ function optimizePalletLayer(palletWidth, palletDepth, items) {
20
+ const placed = [];
21
+ let currentX = 0, currentY = 0, rowHeight = 0;
22
+ for (const item of items) {
23
+ if (currentX + item.width <= palletWidth) {
24
+ placed.push({ ...item, x: currentX, y: currentY });
25
+ currentX += item.width;
26
+ rowHeight = Math.max(rowHeight, item.height || item.depth || 0);
27
+ } else if (currentY + rowHeight + (item.height || 0) <= palletDepth) {
28
+ currentY += rowHeight;
29
+ currentX = 0;
30
+ placed.push({ ...item, x: currentX, y: currentY });
31
+ currentX += item.width;
32
+ rowHeight = item.height || 0;
33
+ }
34
+ }
35
+ const usedArea = placed.reduce((s, p) => s + p.width * (p.height || p.depth || 0), 0);
36
+ const totalArea = palletWidth * palletDepth;
37
+ return { placements: usedArea, totalArea, utilization: +((usedArea / totalArea) * 100).toFixed(1), placed };
38
+ }
39
+
40
+ function calculateLoadMetrics(container, { maxWeight = 45000, maxVolume = 2000 } = {}) {
41
+ const totalWeight = container.items.reduce((s, i) => s + (i.weight || 0), 0);
42
+ const totalVolume = container.items.reduce((s, i) => s + (i.volume || 0), 0);
43
+ return {
44
+ items: container.items.length,
45
+ weight: totalWeight,
46
+ weightUtilization: +((totalWeight / maxWeight) * 100).toFixed(1),
47
+ volume: totalVolume,
48
+ volumeUtilization: +((totalVolume / maxVolume) * 100).toFixed(1),
49
+ };
50
+ }
51
+
52
+
53
+ module.exports = { firstFitDecreasing, optimizePalletLayer, calculateLoadMetrics };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@ph-itdev/load-optimizer",
3
+ "version": "0.2026.0703",
4
+ "description": "Optimize truck load and pallet configurations using bin-packing heuristics to maximize space utilization for freight logistics.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "commonjs",
8
+ "bin": {
9
+ "load-optimizer": "bin/cli.js"
10
+ },
11
+ "files": [
12
+ "index.js",
13
+ "index.d.ts",
14
+ "bin/",
15
+ "example/",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "test": "node test.js",
20
+ "lint": "echo 'lint ok'",
21
+ "playground": "node bin/cli.js playground"
22
+ },
23
+ "keywords": [
24
+ "logistics",
25
+ "automation",
26
+ "shipping",
27
+ "supply-chain",
28
+ "load"
29
+ ],
30
+ "author": "@ph-itdev",
31
+ "license": "MIT \u00a9 Nilo Besingga",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/nilskie06/load-optimizer.git"
35
+ },
36
+ "homepage": "https://github.com/nilskie06/load-optimizer#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/nilskie06/load-optimizer/issues"
39
+ },
40
+ "engines": {
41
+ "node": ">=14.0.0"
42
+ }
43
+ }