html360-gen 2.5.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 html360
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # html360-gen
2
+
3
+ **Standalone, zero-dependency binaries** for the original [Pannellum](https://github.com/mpetroff/pannellum/blob/a5e2f25d960270b6cdd6136d2c18c21f745bba0e/utils/multires/generate.py) multiresolution generator.
4
+
5
+ ## Overview
6
+
7
+ The original Pannellum processing script `generate.py` is powerful but requires a Python environment with `Pillow` and depends on `nona` (from Hugin).
8
+
9
+ This project provides a **pre-compiled, portable version** of that script. It includes all necessary C++ dependencies (`nona`, `zlib`, etc.) inside a single executable for **Windows**, **Linux**, and **macOS**.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install html360-gen
15
+ ```
16
+
17
+ ## Usage
18
+ ### Node.js
19
+ ```javascript
20
+ import { html360Gen } from 'html360-gen';
21
+ import { execFile } from 'child_process';
22
+
23
+ const genPath = html360Gen.getBinaryPath();
24
+
25
+ // Example: Slice a 360° panorama into tiles
26
+ const args = ['input.jpg', '--output', './tiles_output'];
27
+
28
+ execFile(genPath, args, (error, stdout, stderr) => {
29
+ if (error) {
30
+ console.error(`Error: ${error.message}`);
31
+ return;
32
+ }
33
+ console.log('✅ Success! Tiles generated.');
34
+ });
35
+ ```
36
+
37
+ ### Command Line Interface (CLI)
38
+ If installed locally, run via npx:
39
+
40
+ ```
41
+ npx html360-gen input.jpg
42
+ ```
43
+ If installed globally, run directly:
44
+ ```
45
+ html360-gen input.jpg
46
+ ```
47
+ ### Note
48
+ The binary supports all original Pannellum flags like --bin, --levels, etc. Run with --help to see all options.
49
+
50
+ ## Technical Details
51
+ - **Core**: Fork of the official Pannellum generate.py.
52
+ - **Engine**: Bundled nona utility for mathematically accurate cube projection.
53
+ - **Packaging**: Compiled using PyInstaller with custom library path patching for macOS portability.
54
+
55
+ ### Versioning Policy
56
+ This project follows a **mirror versioning** strategy relative to the official [Pannellum](https://www.npmjs.com/package/pannellum) releases:
57
+ - The **Major** and **Minor** versions match the corresponding Pannellum version (e.g., `2.5.x`).
58
+ - The **Patch** version reflects updates, bug fixes, or binary improvements specific to this generator project.
59
+
60
+
61
+ ## Credits
62
+ - **Pannellum** — the core 360° viewer engine by Matthew Petroff.
63
+ - **Hugin** — for the nona stitching engine.
64
+ - **Google Gemini** — for co-authoring the entire project architecture and CI/CD pipelines.
package/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { execFileSync } from 'child_process';
3
+ import { html360Gen } from './index.js';
4
+
5
+ try {
6
+ const bin = html360Gen.getBinaryPath();
7
+ execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
8
+ } catch (err) {
9
+ // Если ошибка пришла от самого бинарника (у него есть код выхода status)
10
+ if (err.status) {
11
+ process.exit(err.status);
12
+ }
13
+
14
+ // Если это системная ошибка Node.js (например, файл не найден или ОС не та)
15
+ console.error(err);
16
+ process.exit(1);
17
+ }
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import path from 'path';
2
+ import fs from 'node:fs';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ function getBinaryPath() {
9
+ const platform = process.platform;
10
+
11
+ let binaryName;
12
+ if (platform === 'win32') binaryName = 'html360-gen.exe';
13
+ if (platform === 'darwin') binaryName = 'html360-gen';
14
+ if (platform === "linux") binaryName = 'html360-gen';
15
+ if (!binaryName){
16
+ throw new Error(`[html360-gen] Platform ${process.platform} is not supported.`);
17
+ }
18
+
19
+ const result = path.join(__dirname, 'bin', binaryName);
20
+
21
+ if (!fs.existsSync(result)) {
22
+ throw new Error(
23
+ `[html360-gen] Binary not found! Try reinstalling the package.`,
24
+ );
25
+ }
26
+
27
+ return result;
28
+ }
29
+
30
+ export const html360Gen = {
31
+ getBinaryPath
32
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "html360-gen",
3
+ "version": "2.5.0",
4
+ "description": "Standalone, zero-dependency binaries for the original Pannellum `generate.py` script.",
5
+ "keywords": [
6
+ "pannellum",
7
+ "generate.py",
8
+ "multiresolution",
9
+ "tiles-generator",
10
+ "binaries",
11
+ "panorama",
12
+ "html360",
13
+ "360"
14
+ ],
15
+ "homepage": "https://github.com/html360/html360-gen",
16
+ "bugs": {
17
+ "url": "https://github.com/html360/html360-gen/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/html360/html360-gen.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": "d_hand",
25
+ "type": "module",
26
+ "main": "index.js",
27
+ "bin": {
28
+ "html360-gen": "cli.js"
29
+ },
30
+ "files": [
31
+ "postinstall.cjs",
32
+ "index.js",
33
+ "cli.js",
34
+ "README.md"
35
+ ],
36
+ "scripts": {
37
+ "postinstall": "node postinstall.cjs"
38
+ },
39
+ "engines": {
40
+ "node": ">=20.10.0"
41
+ }
42
+ }
@@ -0,0 +1,70 @@
1
+ const os = require("os");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const https = require("https");
5
+ const pkg = require("./package.json");
6
+
7
+ const platform = os.platform();
8
+
9
+ let binaryName;
10
+ if (platform === "win32") binaryName = "html360-gen-win.exe";
11
+ if (platform === "linux") binaryName = "html360-gen-linux";
12
+ if (platform === "darwin") binaryName = "html360-gen-macos";
13
+
14
+ if (!binaryName) {
15
+ console.error("❌ Error: Your operating system is not supported.");
16
+ process.exit(0); // Завершаем без ошибки, чтобы не ломать npm install (сломает установку html360)
17
+ }
18
+
19
+ const binDir = path.join(__dirname, "bin");
20
+ const dest = path.join(
21
+ binDir,
22
+ platform === "win32" ? "html360-gen.exe" : "html360-gen",
23
+ );
24
+
25
+ if (!fs.existsSync(binDir)) {
26
+ fs.mkdirSync(binDir, { recursive: true });
27
+ }
28
+
29
+ const url = `https://github.com/html360/html360-gen/releases/download/v${pkg.version}/${binaryName}`;
30
+
31
+ function download(fileUrl) {
32
+ console.log(`Downloading binary for ${platform}...`);
33
+
34
+ https
35
+ .get(fileUrl, (res) => {
36
+ // Handle GitHub Redirects (301 or 302)
37
+ if (res.statusCode === 301 || res.statusCode === 302) {
38
+ return download(res.headers.location);
39
+ }
40
+
41
+ if (res.statusCode !== 200) {
42
+ console.error(`❌ Download failed: Server returned ${res.statusCode}`);
43
+ process.exit(1);
44
+ }
45
+
46
+ const file = fs.createWriteStream(dest);
47
+ res.pipe(file);
48
+
49
+ file.on("finish", () => {
50
+ file.close();
51
+ // Grant execution permissions for Linux/Mac
52
+ if (platform !== "win32") {
53
+ fs.chmodSync(dest, 0o755);
54
+ }
55
+ console.log("✅ Binary downloaded and ready to use!");
56
+ process.exit(0);
57
+ });
58
+ file.on("error", () => {
59
+ console.error("❌ Write file error:", err.message);
60
+ if (fs.existsSync(dest)) fs.unlinkSync(dest);
61
+ process.exit(1);
62
+ });
63
+ })
64
+ .on("error", (err) => {
65
+ console.error("❌ Network error:", err.message);
66
+ process.exit(1);
67
+ });
68
+ }
69
+
70
+ download(url);