superprint 1.0.56 → 1.0.58
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 +3 -1
- package/cli.mjs +25 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npx superprint
|
|
|
14
14
|
|
|
15
15
|
**Windows PowerShell:** if script execution is disabled, use `npx.cmd superprint`.
|
|
16
16
|
|
|
17
|
-
On first launch, the launcher downloads the application (about 50 MB), installs its local dependencies and opens **http://
|
|
17
|
+
On first launch, the launcher downloads the application (about 50 MB), installs its local dependencies and opens **http://127.0.0.1:5173**. Later launches reuse the installed copy and automatically detect application updates. The server binds to the loopback interface by default, so it is not exposed to your local network or the Internet.
|
|
18
18
|
|
|
19
19
|
## What is included
|
|
20
20
|
|
|
@@ -46,6 +46,8 @@ You can pass Vite options to the launcher, for example:
|
|
|
46
46
|
npx superprint --host 127.0.0.1 --port 5173
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Network access is opt-in. Only use `--host 0.0.0.0` on a trusted network when you deliberately want another device to reach the application.
|
|
50
|
+
|
|
49
51
|
## Links
|
|
50
52
|
|
|
51
53
|
- [SuperPrint web application](https://superprint.cc)
|
package/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Works identically on Windows, macOS and Linux.
|
|
7
7
|
// ═══════════════════════════════════════════════════════════════
|
|
8
8
|
import { spawn, spawnSync } from 'node:child_process';
|
|
9
|
-
import { createWriteStream, existsSync, mkdirSync, readFileSync, statSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
9
|
+
import { createWriteStream, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
10
10
|
import { get as httpsGet } from 'node:https';
|
|
11
11
|
import { pipeline } from 'node:stream/promises';
|
|
12
12
|
import path from 'node:path';
|
|
@@ -142,6 +142,18 @@ function isInstalled() {
|
|
|
142
142
|
function installedVersion() {
|
|
143
143
|
try { return readFileSync(VERSION_FILE, 'utf8').trim(); } catch { return null; }
|
|
144
144
|
}
|
|
145
|
+
function dependenciesReady() {
|
|
146
|
+
return [
|
|
147
|
+
path.join(APP_DIR, 'node_modules', 'vite', 'bin', 'vite.js'),
|
|
148
|
+
path.join(APP_DIR, 'node_modules', '@mlc-ai', 'web-llm', 'package.json'),
|
|
149
|
+
path.join(APP_DIR, 'node_modules', '@e965', 'xlsx', 'package.json')
|
|
150
|
+
].every(existsSync);
|
|
151
|
+
}
|
|
152
|
+
function runNpmInstall() {
|
|
153
|
+
return spawnSync('npm', ['install', '--no-audit', '--no-fund'], {
|
|
154
|
+
stdio: 'inherit', cwd: APP_DIR, shell: true
|
|
155
|
+
});
|
|
156
|
+
}
|
|
145
157
|
|
|
146
158
|
// ── Main ──────────────────────────────────────────────────────
|
|
147
159
|
async function main() {
|
|
@@ -200,15 +212,18 @@ async function main() {
|
|
|
200
212
|
}
|
|
201
213
|
|
|
202
214
|
// ---- Step 4/4: npm install if needed ----
|
|
203
|
-
if (!
|
|
215
|
+
if (!dependenciesReady()) {
|
|
204
216
|
step(4, 'Installing dependencies (npm install)');
|
|
205
217
|
info('First install: a few minutes. Subsequent launches will be instant.');
|
|
206
218
|
// shell:true needed on Windows to launch npm (the .cmd wrappers
|
|
207
219
|
// fail with EINVAL via spawnSync without shell).
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
220
|
+
let install = runNpmInstall();
|
|
221
|
+
if (install.status !== 0) {
|
|
222
|
+
warn('The dependency folder is incomplete. Cleaning it and retrying once.');
|
|
223
|
+
try { rmSync(path.join(APP_DIR, 'node_modules'), { recursive: true, force: true }); } catch (_) {}
|
|
224
|
+
install = runNpmInstall();
|
|
225
|
+
}
|
|
226
|
+
if (install.status !== 0 || !dependenciesReady()) { fail('npm install failed.'); process.exit(1); }
|
|
212
227
|
// npm 12+ blocks install scripts (e.g. esbuild needs its postinstall
|
|
213
228
|
// to place its native binary). We approve all: this is our own
|
|
214
229
|
// trusted application.
|
|
@@ -228,11 +243,13 @@ async function main() {
|
|
|
228
243
|
// ---- Launch Vite ----
|
|
229
244
|
console.log(SEP);
|
|
230
245
|
console.log(C.green + C.bold + ' Starting SuperPrint…' + C.reset);
|
|
231
|
-
console.log(C.dim + ' Open your browser at: http://
|
|
246
|
+
console.log(C.dim + ' Open your browser at: http://127.0.0.1:5173' + C.reset);
|
|
232
247
|
console.log(SEP);
|
|
233
248
|
|
|
234
249
|
const viteBin = path.join(APP_DIR, 'node_modules', 'vite', 'bin', 'vite.js');
|
|
235
|
-
const
|
|
250
|
+
const userArgs = process.argv.slice(2);
|
|
251
|
+
const hasExplicitHost = userArgs.some(arg => arg === '--host' || arg.startsWith('--host='));
|
|
252
|
+
const args = hasExplicitHost ? userArgs : ['--host', '127.0.0.1', ...userArgs];
|
|
236
253
|
const child = spawn(process.execPath, [viteBin, ...args], {
|
|
237
254
|
stdio: 'inherit', cwd: APP_DIR
|
|
238
255
|
});
|