Fixed server getter
All checks were successful
Publish Library / Build NPM Project (push) Successful in 14s
Publish Library / Tag Version (push) Successful in 11s

This commit is contained in:
2026-08-24 21:18:24 -04:00
parent cab2571160
commit a2bde0b5cd
3 changed files with 8 additions and 7 deletions

View File

@@ -87,6 +87,7 @@ await server.stop(); // Kill server
```
#### List Local ZIMs
```js
const local = await server.list();
[

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/zim-utils",
"version": "0.3.1",
"version": "0.3.2",
"description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -10,7 +10,7 @@ import {zimCatalog, zimCatalogInfo, CATALOG_URL} from './catalog.js';
export class ZimManager {
#catalogUrl;
#dir;
server;
#server;
#ownsServer;
/** @param {{catalog?: string, server?: KiwixServer, port?: number, host?: string, binDir?: string, url?: string}} [opts]
@@ -21,15 +21,15 @@ export class ZimManager {
this.#catalogUrl = catalog;
this.#dir = dir;
this.#ownsServer = !server;
this.server = server ?? new KiwixServer(dir, {port, host, binDir, url});
this.#server = server ?? new KiwixServer(dir, {port, host, binDir, url});
}
/** The KiwixServer backing this manager - reuse it directly for content/search access, or pass into another ZimManager. */
get server() { return this.server; }
get server() { return this.#server; }
async #ensureServer() {
if (!this.server.running) await this.server.start();
return this.server;
if (!this.#server.running) await this.#server.start();
return this.#server;
}
async #download(url, destPath) {
@@ -74,7 +74,7 @@ export class ZimManager {
/** Stops the internally-owned KiwixServer, if this manager created its own (no-op if one was passed in). */
async close() {
if (this.#ownsServer) await this.server.stop();
if (this.#ownsServer) await this.#server.stop();
}
async delete(nameOrFile) {