@b9g/platform-node 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b9g/platform-node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Node.js platform adapter for Shovel with hot reloading and ESBuild integration",
5
5
  "keywords": [
6
6
  "shovel",
package/src/platform.d.ts CHANGED
@@ -25,12 +25,11 @@ export declare class NodePlatform extends BasePlatform {
25
25
  private options;
26
26
  private workerManager?;
27
27
  private cacheStorage?;
28
- private _dist?;
29
28
  constructor(options?: NodePlatformOptions);
30
29
  /**
31
- * Build artifacts filesystem (install-time only)
30
+ * Get filesystem directory handle
32
31
  */
33
- get distDir(): FileSystemDirectoryHandle;
32
+ getDirectoryHandle(name: string): Promise<FileSystemDirectoryHandle>;
34
33
  /**
35
34
  * THE MAIN JOB - Load and run a ServiceWorker-style entrypoint in Node.js
36
35
  * Uses Worker threads with coordinated cache storage for isolation and standards compliance
package/src/platform.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  BasePlatform
5
5
  } from "@b9g/platform";
6
6
  import { CustomCacheStorage, MemoryCacheManager, PostMessageCache } from "@b9g/cache";
7
- import { FileSystemRegistry, getFileSystemRoot, NodeFileSystemAdapter, NodeFileSystemDirectoryHandle } from "@b9g/filesystem";
7
+ import { FileSystemRegistry, getFileSystemRoot, NodeFileSystemAdapter } from "@b9g/filesystem";
8
8
  import * as Http from "http";
9
9
  import * as Path from "path";
10
10
  import { Worker } from "worker_threads";
@@ -155,7 +155,6 @@ var NodePlatform = class extends BasePlatform {
155
155
  options;
156
156
  workerManager;
157
157
  cacheStorage;
158
- _dist;
159
158
  constructor(options = {}) {
160
159
  super(options);
161
160
  this.options = {
@@ -170,14 +169,12 @@ var NodePlatform = class extends BasePlatform {
170
169
  }));
171
170
  }
172
171
  /**
173
- * Build artifacts filesystem (install-time only)
172
+ * Get filesystem directory handle
174
173
  */
175
- get distDir() {
176
- if (!this._dist) {
177
- const distPath = Path.resolve(this.options.cwd, "dist");
178
- this._dist = new NodeFileSystemDirectoryHandle(distPath);
179
- }
180
- return this._dist;
174
+ async getDirectoryHandle(name) {
175
+ const distPath = Path.resolve(this.options.cwd, "dist");
176
+ const adapter = new NodeFileSystemAdapter({ rootPath: distPath });
177
+ return await adapter.getDirectoryHandle(name);
181
178
  }
182
179
  /**
183
180
  * THE MAIN JOB - Load and run a ServiceWorker-style entrypoint in Node.js
@@ -308,19 +305,32 @@ var NodePlatform = class extends BasePlatform {
308
305
  res.end("Internal Server Error");
309
306
  }
310
307
  });
308
+ let isListening = false;
311
309
  return {
312
- listen: () => {
310
+ async listen() {
313
311
  return new Promise((resolve2) => {
314
312
  httpServer.listen(port, host, () => {
315
313
  console.info(`\u{1F680} Server running at http://${host}:${port}`);
314
+ isListening = true;
316
315
  resolve2();
317
316
  });
318
317
  });
319
318
  },
320
- close: () => new Promise((resolve2) => {
321
- httpServer.close(() => resolve2());
322
- }),
323
- address: () => ({ port, host })
319
+ async close() {
320
+ return new Promise((resolve2) => {
321
+ httpServer.close(() => {
322
+ isListening = false;
323
+ resolve2();
324
+ });
325
+ });
326
+ },
327
+ address: () => ({ port, host }),
328
+ get url() {
329
+ return `http://${host}:${port}`;
330
+ },
331
+ get ready() {
332
+ return isListening;
333
+ }
324
334
  };
325
335
  }
326
336
  /**