@b9g/platform-cloudflare 0.1.9 → 0.1.11

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.
@@ -1,106 +0,0 @@
1
- /// <reference types="./filesystem-assets.d.ts" />
2
- // src/filesystem-assets.ts
3
- var CFAssetsDirectoryHandle = class _CFAssetsDirectoryHandle {
4
- kind;
5
- name;
6
- #assets;
7
- #basePath;
8
- constructor(assets, basePath = "/") {
9
- this.kind = "directory";
10
- this.#assets = assets;
11
- this.#basePath = basePath.endsWith("/") ? basePath : basePath + "/";
12
- this.name = basePath.split("/").filter(Boolean).pop() || "assets";
13
- }
14
- async getFileHandle(name, _options) {
15
- const path = this.#basePath + name;
16
- const response = await this.#assets.fetch(
17
- new Request("https://assets" + path)
18
- );
19
- if (!response.ok) {
20
- throw new DOMException(
21
- `A requested file or directory could not be found: ${name}`,
22
- "NotFoundError"
23
- );
24
- }
25
- return new CFAssetsFileHandle(this.#assets, path, name);
26
- }
27
- async getDirectoryHandle(name, _options) {
28
- return new _CFAssetsDirectoryHandle(this.#assets, this.#basePath + name);
29
- }
30
- async removeEntry(_name, _options) {
31
- throw new DOMException("Assets directory is read-only", "NotAllowedError");
32
- }
33
- async resolve(_possibleDescendant) {
34
- return null;
35
- }
36
- // eslint-disable-next-line require-yield
37
- async *entries() {
38
- throw new DOMException(
39
- "Directory listing not supported for ASSETS binding. Use an asset manifest for enumeration.",
40
- "NotSupportedError"
41
- );
42
- }
43
- // eslint-disable-next-line require-yield
44
- async *keys() {
45
- throw new DOMException(
46
- "Directory listing not supported for ASSETS binding",
47
- "NotSupportedError"
48
- );
49
- }
50
- // eslint-disable-next-line require-yield
51
- async *values() {
52
- throw new DOMException(
53
- "Directory listing not supported for ASSETS binding",
54
- "NotSupportedError"
55
- );
56
- }
57
- [Symbol.asyncIterator]() {
58
- return this.entries();
59
- }
60
- isSameEntry(other) {
61
- return Promise.resolve(
62
- other instanceof _CFAssetsDirectoryHandle && other.#basePath === this.#basePath
63
- );
64
- }
65
- };
66
- var CFAssetsFileHandle = class _CFAssetsFileHandle {
67
- kind;
68
- name;
69
- #assets;
70
- #path;
71
- constructor(assets, path, name) {
72
- this.kind = "file";
73
- this.#assets = assets;
74
- this.#path = path;
75
- this.name = name;
76
- }
77
- async getFile() {
78
- const response = await this.#assets.fetch(
79
- new Request("https://assets" + this.#path)
80
- );
81
- if (!response.ok) {
82
- throw new DOMException(
83
- `A requested file or directory could not be found: ${this.name}`,
84
- "NotFoundError"
85
- );
86
- }
87
- const blob = await response.blob();
88
- const contentType = response.headers.get("content-type") || "application/octet-stream";
89
- return new File([blob], this.name, { type: contentType });
90
- }
91
- async createWritable(_options) {
92
- throw new DOMException("Assets are read-only", "NotAllowedError");
93
- }
94
- async createSyncAccessHandle() {
95
- throw new DOMException("Sync access not supported", "NotSupportedError");
96
- }
97
- isSameEntry(other) {
98
- return Promise.resolve(
99
- other instanceof _CFAssetsFileHandle && other.#path === this.#path
100
- );
101
- }
102
- };
103
- export {
104
- CFAssetsDirectoryHandle,
105
- CFAssetsFileHandle
106
- };