@b9g/platform-cloudflare 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 +1 -1
- package/src/platform.d.ts +2 -3
- package/src/platform.js +15 -14
package/package.json
CHANGED
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
|
-
*
|
|
28
|
+
* Get filesystem directory handle (memory-only in Workers runtime)
|
|
30
29
|
*/
|
|
31
|
-
|
|
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,
|
|
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
|
|
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
|
-
*
|
|
39
|
+
* Get filesystem directory handle (memory-only in Workers runtime)
|
|
41
40
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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:
|
|
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
|
/**
|