@b9g/platform-cloudflare 0.1.0 → 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-cloudflare",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Cloudflare Workers platform adapter for Shovel - already ServiceWorker-based!",
5
5
  "keywords": [
6
6
  "shovel",
@@ -11,9 +11,9 @@
11
11
  "serviceworker"
12
12
  ],
13
13
  "dependencies": {
14
- "@b9g/platform": "workspace:*",
15
- "@b9g/cache": "workspace:*",
16
- "@b9g/assets": "workspace:*",
14
+ "@b9g/platform": "^0.1.1",
15
+ "@b9g/cache": "^0.1.1",
16
+ "@b9g/assets": "^0.1.1",
17
17
  "@cloudflare/workers-types": "^4.20241218.0"
18
18
  },
19
19
  "devDependencies": {
package/src/platform.d.ts CHANGED
@@ -23,12 +23,11 @@ export interface CloudflarePlatformOptions extends PlatformConfig {
23
23
  export declare class CloudflarePlatform extends BasePlatform {
24
24
  readonly name = "cloudflare";
25
25
  private options;
26
- private _dist?;
27
26
  constructor(options?: CloudflarePlatformOptions);
28
27
  /**
29
- * Build artifacts filesystem (not available in Workers runtime)
28
+ * Get filesystem directory handle (memory-only in Workers runtime)
30
29
  */
31
- get distDir(): FileSystemDirectoryHandle;
30
+ getDirectoryHandle(name: string): Promise<FileSystemDirectoryHandle>;
32
31
  /**
33
32
  * Get platform-specific default cache configuration for Cloudflare Workers
34
33
  */
package/src/platform.js CHANGED
@@ -11,11 +11,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
11
11
  import {
12
12
  BasePlatform
13
13
  } from "@b9g/platform";
14
- import { FileSystemRegistry, getFileSystemRoot, MemoryFileSystemAdapter } from "@b9g/filesystem";
14
+ import { FileSystemRegistry, getFileSystemRoot, MemoryBucket } from "@b9g/filesystem";
15
15
  var CloudflarePlatform = class extends BasePlatform {
16
16
  name = "cloudflare";
17
17
  options;
18
- _dist;
19
18
  constructor(options = {}) {
20
19
  super(options);
21
20
  this.options = {
@@ -26,7 +25,7 @@ var CloudflarePlatform = class extends BasePlatform {
26
25
  durableObjects: {},
27
26
  ...options
28
27
  };
29
- FileSystemRegistry.register("memory", new MemoryFileSystemAdapter());
28
+ FileSystemRegistry.register("memory", new MemoryBucket());
30
29
  if (this.options.r2Buckets?.default) {
31
30
  try {
32
31
  const { R2FileSystemAdapter } = __require("@b9g/filesystem-r2");
@@ -37,13 +36,11 @@ var CloudflarePlatform = class extends BasePlatform {
37
36
  }
38
37
  }
39
38
  /**
40
- * Build artifacts filesystem (not available in Workers runtime)
39
+ * Get filesystem directory handle (memory-only in Workers runtime)
41
40
  */
42
- get distDir() {
43
- if (!this._dist) {
44
- this._dist = new MemoryFileSystemAdapter().getFileSystemRoot("dist");
45
- }
46
- return this._dist;
41
+ async getDirectoryHandle(name) {
42
+ const adapter = new MemoryBucket();
43
+ return await adapter.getDirectoryHandle(name);
47
44
  }
48
45
  /**
49
46
  * Get platform-specific default cache configuration for Cloudflare Workers
@@ -69,15 +66,19 @@ var CloudflarePlatform = class extends BasePlatform {
69
66
  */
70
67
  createServer(handler, _options = {}) {
71
68
  return {
72
- listen: () => {
69
+ async listen() {
73
70
  console.info("[Cloudflare] Worker handler ready");
74
- return Promise.resolve();
75
71
  },
76
- close: () => {
72
+ async close() {
77
73
  console.info("[Cloudflare] Worker handler stopped");
78
- return Promise.resolve();
79
74
  },
80
- address: () => ({ port: 0, host: "cloudflare-workers" })
75
+ address: () => ({ port: 443, host: "cloudflare-workers" }),
76
+ get url() {
77
+ return "https://cloudflare-workers";
78
+ },
79
+ get ready() {
80
+ return true;
81
+ }
81
82
  };
82
83
  }
83
84
  /**