@ricsam/quickjs-fetch 0.0.1 → 0.2.1
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/README.md +109 -43
- package/dist/cjs/abort-controller.cjs +212 -0
- package/dist/cjs/abort-controller.cjs.map +10 -0
- package/dist/cjs/fetch.cjs +199 -0
- package/dist/cjs/fetch.cjs.map +10 -0
- package/dist/cjs/form-data.cjs +289 -0
- package/dist/cjs/form-data.cjs.map +10 -0
- package/dist/cjs/handle.cjs +248 -0
- package/dist/cjs/handle.cjs.map +10 -0
- package/dist/cjs/headers.cjs +196 -0
- package/dist/cjs/headers.cjs.map +10 -0
- package/dist/cjs/index.cjs +47 -0
- package/dist/cjs/index.cjs.map +10 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/request.cjs +315 -0
- package/dist/cjs/request.cjs.map +10 -0
- package/dist/cjs/response.cjs +315 -0
- package/dist/cjs/response.cjs.map +10 -0
- package/dist/cjs/serve.cjs +182 -0
- package/dist/cjs/serve.cjs.map +10 -0
- package/dist/cjs/setup.cjs +119 -0
- package/dist/cjs/setup.cjs.map +10 -0
- package/dist/cjs/types.cjs +26 -0
- package/dist/cjs/types.cjs.map +9 -0
- package/dist/mjs/abort-controller.mjs +181 -0
- package/dist/mjs/abort-controller.mjs.map +10 -0
- package/dist/mjs/fetch.mjs +168 -0
- package/dist/mjs/fetch.mjs.map +10 -0
- package/dist/mjs/form-data.mjs +258 -0
- package/dist/mjs/form-data.mjs.map +10 -0
- package/dist/mjs/handle.mjs +217 -0
- package/dist/mjs/handle.mjs.map +10 -0
- package/dist/mjs/headers.mjs +165 -0
- package/dist/mjs/headers.mjs.map +10 -0
- package/dist/mjs/index.mjs +22 -0
- package/dist/mjs/index.mjs.map +10 -0
- package/dist/mjs/package.json +5 -0
- package/dist/mjs/request.mjs +284 -0
- package/dist/mjs/request.mjs.map +10 -0
- package/dist/mjs/response.mjs +284 -0
- package/dist/mjs/response.mjs.map +10 -0
- package/dist/mjs/serve.mjs +151 -0
- package/dist/mjs/serve.mjs.map +10 -0
- package/dist/mjs/setup.mjs +92 -0
- package/dist/mjs/setup.mjs.map +10 -0
- package/dist/mjs/types.mjs +3 -0
- package/dist/mjs/types.mjs.map +9 -0
- package/dist/types/globals/abort-controller.d.ts +9 -0
- package/dist/types/globals/fetch.d.ts +5 -0
- package/dist/types/globals/form-data.d.ts +37 -0
- package/dist/types/globals/headers.d.ts +36 -0
- package/dist/types/globals/request.d.ts +16 -0
- package/dist/types/globals/response.d.ts +25 -0
- package/dist/types/globals/serve.d.ts +16 -0
- package/dist/types/handle.d.ts +6 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/setup.d.ts +48 -0
- package/dist/types/types.d.ts +175 -0
- package/package.json +51 -6
package/README.md
CHANGED
|
@@ -1,45 +1,111 @@
|
|
|
1
1
|
# @ricsam/quickjs-fetch
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
3
|
+
Fetch API and HTTP server handler.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { setupFetch } from "@ricsam/quickjs-fetch";
|
|
7
|
+
|
|
8
|
+
const handle = setupFetch(context, {
|
|
9
|
+
onFetch: async (request) => {
|
|
10
|
+
// Handle outbound fetch() calls from QuickJS
|
|
11
|
+
console.log(`Fetching: ${request.url}`);
|
|
12
|
+
return fetch(request);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Injected Globals:**
|
|
18
|
+
- `fetch`, `Request`, `Response`, `Headers`
|
|
19
|
+
- `FormData`, `AbortController`, `AbortSignal`
|
|
20
|
+
- `serve` (HTTP server handler)
|
|
21
|
+
|
|
22
|
+
**Usage in QuickJS:**
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
// Outbound fetch
|
|
26
|
+
const response = await fetch("https://api.example.com/data");
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
|
|
29
|
+
// Request/Response
|
|
30
|
+
const request = new Request("https://example.com", {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "Content-Type": "application/json" },
|
|
33
|
+
body: JSON.stringify({ name: "test" }),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const response = new Response(JSON.stringify({ ok: true }), {
|
|
37
|
+
status: 200,
|
|
38
|
+
headers: { "Content-Type": "application/json" },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Static methods
|
|
42
|
+
Response.json({ message: "hello" });
|
|
43
|
+
Response.redirect("https://example.com", 302);
|
|
44
|
+
|
|
45
|
+
// AbortController
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
setTimeout(() => controller.abort(), 5000);
|
|
48
|
+
await fetch(url, { signal: controller.signal });
|
|
49
|
+
|
|
50
|
+
// FormData
|
|
51
|
+
const formData = new FormData();
|
|
52
|
+
formData.append("name", "John");
|
|
53
|
+
formData.append("file", new File(["content"], "file.txt"));
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### HTTP Server
|
|
57
|
+
|
|
58
|
+
Register a server handler in QuickJS and dispatch requests from the host:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// In QuickJS
|
|
62
|
+
context.evalCode(`
|
|
63
|
+
serve({
|
|
64
|
+
fetch(request, server) {
|
|
65
|
+
const url = new URL(request.url);
|
|
66
|
+
|
|
67
|
+
if (url.pathname === "/ws") {
|
|
68
|
+
if (server.upgrade(request, { data: { userId: "123" } })) {
|
|
69
|
+
return new Response(null, { status: 101 });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return Response.json({ path: url.pathname });
|
|
74
|
+
},
|
|
75
|
+
websocket: {
|
|
76
|
+
open(ws) {
|
|
77
|
+
console.log("Connected:", ws.data.userId);
|
|
78
|
+
},
|
|
79
|
+
message(ws, message) {
|
|
80
|
+
ws.send("Echo: " + message);
|
|
81
|
+
},
|
|
82
|
+
close(ws, code, reason) {
|
|
83
|
+
console.log("Closed:", code, reason);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
`);
|
|
88
|
+
|
|
89
|
+
// From host - dispatch HTTP request
|
|
90
|
+
const response = await handle.dispatchRequest(
|
|
91
|
+
new Request("http://localhost/api/users")
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// Check for WebSocket upgrade
|
|
95
|
+
const upgrade = handle.getUpgradeRequest();
|
|
96
|
+
if (upgrade?.requested) {
|
|
97
|
+
// Handle WebSocket connection
|
|
98
|
+
const connectionId = crypto.randomUUID();
|
|
99
|
+
handle.dispatchWebSocketOpen(connectionId, upgrade.data);
|
|
100
|
+
|
|
101
|
+
// Listen for outgoing messages
|
|
102
|
+
handle.onWebSocketCommand((command) => {
|
|
103
|
+
if (command.type === "message") {
|
|
104
|
+
// Send to actual WebSocket client
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Forward incoming messages
|
|
109
|
+
handle.dispatchWebSocketMessage(connectionId, "Hello from client");
|
|
110
|
+
}
|
|
111
|
+
```
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// @bun @bun-cjs
|
|
2
|
+
(function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// packages/fetch/src/globals/abort-controller.ts
|
|
31
|
+
var exports_abort_controller = {};
|
|
32
|
+
__export(exports_abort_controller, {
|
|
33
|
+
setupAbortControllerAndSignal: () => setupAbortControllerAndSignal
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(exports_abort_controller);
|
|
36
|
+
function setupAbortControllerAndSignal(context) {
|
|
37
|
+
const pendingTimeouts = new Map;
|
|
38
|
+
let nextTimeoutId = 1;
|
|
39
|
+
const scheduleTimeoutFn = context.newFunction("__scheduleTimeout__", (msHandle) => {
|
|
40
|
+
const ms = context.getNumber(msHandle);
|
|
41
|
+
const timeoutId = nextTimeoutId++;
|
|
42
|
+
const hostTimeoutId = setTimeout(() => {
|
|
43
|
+
pendingTimeouts.delete(timeoutId);
|
|
44
|
+
}, ms);
|
|
45
|
+
pendingTimeouts.set(timeoutId, hostTimeoutId);
|
|
46
|
+
return context.newNumber(timeoutId);
|
|
47
|
+
});
|
|
48
|
+
const checkTimeoutFn = context.newFunction("__checkTimeout__", (timeoutIdHandle) => {
|
|
49
|
+
const timeoutId = context.getNumber(timeoutIdHandle);
|
|
50
|
+
const isElapsed = !pendingTimeouts.has(timeoutId);
|
|
51
|
+
return isElapsed ? context.true : context.false;
|
|
52
|
+
});
|
|
53
|
+
context.setProp(context.global, "__scheduleTimeout__", scheduleTimeoutFn);
|
|
54
|
+
context.setProp(context.global, "__checkTimeout__", checkTimeoutFn);
|
|
55
|
+
scheduleTimeoutFn.dispose();
|
|
56
|
+
checkTimeoutFn.dispose();
|
|
57
|
+
const result = context.evalCode(`
|
|
58
|
+
(function() {
|
|
59
|
+
const signalState = new WeakMap();
|
|
60
|
+
|
|
61
|
+
class AbortSignal {
|
|
62
|
+
constructor() {
|
|
63
|
+
signalState.set(this, {
|
|
64
|
+
aborted: false,
|
|
65
|
+
reason: undefined,
|
|
66
|
+
listeners: []
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get aborted() {
|
|
71
|
+
return signalState.get(this).aborted;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get reason() {
|
|
75
|
+
return signalState.get(this).reason;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
throwIfAborted() {
|
|
79
|
+
const state = signalState.get(this);
|
|
80
|
+
if (state.aborted) {
|
|
81
|
+
throw state.reason ?? new DOMException("signal is aborted", "AbortError");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
addEventListener(type, callback) {
|
|
86
|
+
if (type === "abort" && typeof callback === "function") {
|
|
87
|
+
signalState.get(this).listeners.push(callback);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
removeEventListener(type, callback) {
|
|
92
|
+
if (type === "abort") {
|
|
93
|
+
const state = signalState.get(this);
|
|
94
|
+
const idx = state.listeners.indexOf(callback);
|
|
95
|
+
if (idx >= 0) state.listeners.splice(idx, 1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static abort(reason) {
|
|
100
|
+
const signal = new AbortSignal();
|
|
101
|
+
const state = signalState.get(signal);
|
|
102
|
+
state.aborted = true;
|
|
103
|
+
state.reason = reason ?? new DOMException("signal is aborted", "AbortError");
|
|
104
|
+
return signal;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static timeout(ms) {
|
|
108
|
+
const signal = new AbortSignal();
|
|
109
|
+
const state = signalState.get(signal);
|
|
110
|
+
const timeoutId = __scheduleTimeout__(Number(ms));
|
|
111
|
+
|
|
112
|
+
// Store timeout info for later checking
|
|
113
|
+
state.timeoutId = timeoutId;
|
|
114
|
+
state.timeoutReason = new DOMException("signal timed out", "TimeoutError");
|
|
115
|
+
|
|
116
|
+
return signal;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Internal method to check and trigger timeout
|
|
120
|
+
__checkAndTriggerTimeout__() {
|
|
121
|
+
const state = signalState.get(this);
|
|
122
|
+
if (state.aborted || state.timeoutId === undefined) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (__checkTimeout__(state.timeoutId)) {
|
|
127
|
+
state.aborted = true;
|
|
128
|
+
state.reason = state.timeoutReason;
|
|
129
|
+
delete state.timeoutId;
|
|
130
|
+
delete state.timeoutReason;
|
|
131
|
+
|
|
132
|
+
for (const cb of state.listeners) {
|
|
133
|
+
try { cb(); } catch {}
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static any(signals) {
|
|
141
|
+
const signal = new AbortSignal();
|
|
142
|
+
const state = signalState.get(signal);
|
|
143
|
+
|
|
144
|
+
if (!Array.isArray(signals)) return signal;
|
|
145
|
+
|
|
146
|
+
for (const s of signals) {
|
|
147
|
+
if (s && typeof s === "object" && "aborted" in s) {
|
|
148
|
+
// Check timeout signals
|
|
149
|
+
if (s.__checkAndTriggerTimeout__) {
|
|
150
|
+
s.__checkAndTriggerTimeout__();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (s.aborted) {
|
|
154
|
+
state.aborted = true;
|
|
155
|
+
state.reason = s.reason;
|
|
156
|
+
return signal;
|
|
157
|
+
}
|
|
158
|
+
s.addEventListener("abort", () => {
|
|
159
|
+
if (!state.aborted) {
|
|
160
|
+
state.aborted = true;
|
|
161
|
+
state.reason = s.reason;
|
|
162
|
+
for (const cb of state.listeners) {
|
|
163
|
+
try { cb(); } catch {}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return signal;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const controllerState = new WeakMap();
|
|
174
|
+
|
|
175
|
+
class AbortController {
|
|
176
|
+
constructor() {
|
|
177
|
+
const signal = new AbortSignal();
|
|
178
|
+
controllerState.set(this, { signal });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get signal() {
|
|
182
|
+
return controllerState.get(this).signal;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
abort(reason) {
|
|
186
|
+
const signal = controllerState.get(this).signal;
|
|
187
|
+
const state = signalState.get(signal);
|
|
188
|
+
if (state.aborted) return;
|
|
189
|
+
|
|
190
|
+
state.aborted = true;
|
|
191
|
+
state.reason = reason ?? new DOMException("signal is aborted", "AbortError");
|
|
192
|
+
|
|
193
|
+
for (const cb of state.listeners) {
|
|
194
|
+
try { cb(); } catch {}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
globalThis.AbortSignal = AbortSignal;
|
|
200
|
+
globalThis.AbortController = AbortController;
|
|
201
|
+
})();
|
|
202
|
+
`);
|
|
203
|
+
if (result.error) {
|
|
204
|
+
const error = context.dump(result.error);
|
|
205
|
+
result.error.dispose();
|
|
206
|
+
throw new Error(`Failed to setup AbortController: ${JSON.stringify(error)}`);
|
|
207
|
+
}
|
|
208
|
+
result.value.dispose();
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
//# debugId=76B7F4BCB13124D864756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/globals/abort-controller.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { QuickJSContext } from \"quickjs-emscripten\";\n\n/**\n * Setup AbortController and AbortSignal classes in QuickJS.\n * Uses pure QuickJS implementation so that:\n * - controller.signal returns an actual AbortSignal instance\n * - Event listeners work correctly\n * - All prototype methods are accessible\n */\nexport function setupAbortControllerAndSignal(context: QuickJSContext): void {\n // Track signals for timeout feature - we need to call back into QuickJS after a delay\n const pendingTimeouts = new Map<number, ReturnType<typeof setTimeout>>();\n let nextTimeoutId = 1;\n\n // Create a host function that schedules a timeout and returns an ID\n const scheduleTimeoutFn = context.newFunction(\"__scheduleTimeout__\", (msHandle) => {\n const ms = context.getNumber(msHandle);\n const timeoutId = nextTimeoutId++;\n\n // Schedule the timeout - we'll call back into QuickJS using a polling mechanism\n const hostTimeoutId = setTimeout(() => {\n pendingTimeouts.delete(timeoutId);\n }, ms);\n\n pendingTimeouts.set(timeoutId, hostTimeoutId);\n return context.newNumber(timeoutId);\n });\n\n // Create a host function to check if a timeout has elapsed\n const checkTimeoutFn = context.newFunction(\"__checkTimeout__\", (timeoutIdHandle) => {\n const timeoutId = context.getNumber(timeoutIdHandle);\n // If the timeout is no longer in pendingTimeouts, it has elapsed\n const isElapsed = !pendingTimeouts.has(timeoutId);\n return isElapsed ? context.true : context.false;\n });\n\n context.setProp(context.global, \"__scheduleTimeout__\", scheduleTimeoutFn);\n context.setProp(context.global, \"__checkTimeout__\", checkTimeoutFn);\n scheduleTimeoutFn.dispose();\n checkTimeoutFn.dispose();\n\n // Use WeakMap for private state (more compatible than private fields)\n // Note: AbortSignal.timeout() uses a polling approach since we can't easily\n // call back into QuickJS from a host setTimeout callback\n const result = context.evalCode(`\n (function() {\n const signalState = new WeakMap();\n\n class AbortSignal {\n constructor() {\n signalState.set(this, {\n aborted: false,\n reason: undefined,\n listeners: []\n });\n }\n\n get aborted() {\n return signalState.get(this).aborted;\n }\n\n get reason() {\n return signalState.get(this).reason;\n }\n\n throwIfAborted() {\n const state = signalState.get(this);\n if (state.aborted) {\n throw state.reason ?? new DOMException(\"signal is aborted\", \"AbortError\");\n }\n }\n\n addEventListener(type, callback) {\n if (type === \"abort\" && typeof callback === \"function\") {\n signalState.get(this).listeners.push(callback);\n }\n }\n\n removeEventListener(type, callback) {\n if (type === \"abort\") {\n const state = signalState.get(this);\n const idx = state.listeners.indexOf(callback);\n if (idx >= 0) state.listeners.splice(idx, 1);\n }\n }\n\n static abort(reason) {\n const signal = new AbortSignal();\n const state = signalState.get(signal);\n state.aborted = true;\n state.reason = reason ?? new DOMException(\"signal is aborted\", \"AbortError\");\n return signal;\n }\n\n static timeout(ms) {\n const signal = new AbortSignal();\n const state = signalState.get(signal);\n const timeoutId = __scheduleTimeout__(Number(ms));\n\n // Store timeout info for later checking\n state.timeoutId = timeoutId;\n state.timeoutReason = new DOMException(\"signal timed out\", \"TimeoutError\");\n\n return signal;\n }\n\n // Internal method to check and trigger timeout\n __checkAndTriggerTimeout__() {\n const state = signalState.get(this);\n if (state.aborted || state.timeoutId === undefined) {\n return false;\n }\n\n if (__checkTimeout__(state.timeoutId)) {\n state.aborted = true;\n state.reason = state.timeoutReason;\n delete state.timeoutId;\n delete state.timeoutReason;\n\n for (const cb of state.listeners) {\n try { cb(); } catch {}\n }\n return true;\n }\n return false;\n }\n\n static any(signals) {\n const signal = new AbortSignal();\n const state = signalState.get(signal);\n\n if (!Array.isArray(signals)) return signal;\n\n for (const s of signals) {\n if (s && typeof s === \"object\" && \"aborted\" in s) {\n // Check timeout signals\n if (s.__checkAndTriggerTimeout__) {\n s.__checkAndTriggerTimeout__();\n }\n\n if (s.aborted) {\n state.aborted = true;\n state.reason = s.reason;\n return signal;\n }\n s.addEventListener(\"abort\", () => {\n if (!state.aborted) {\n state.aborted = true;\n state.reason = s.reason;\n for (const cb of state.listeners) {\n try { cb(); } catch {}\n }\n }\n });\n }\n }\n return signal;\n }\n }\n\n const controllerState = new WeakMap();\n\n class AbortController {\n constructor() {\n const signal = new AbortSignal();\n controllerState.set(this, { signal });\n }\n\n get signal() {\n return controllerState.get(this).signal;\n }\n\n abort(reason) {\n const signal = controllerState.get(this).signal;\n const state = signalState.get(signal);\n if (state.aborted) return;\n\n state.aborted = true;\n state.reason = reason ?? new DOMException(\"signal is aborted\", \"AbortError\");\n\n for (const cb of state.listeners) {\n try { cb(); } catch {}\n }\n }\n }\n\n globalThis.AbortSignal = AbortSignal;\n globalThis.AbortController = AbortController;\n })();\n `);\n\n if (result.error) {\n const error = context.dump(result.error);\n result.error.dispose();\n throw new Error(`Failed to setup AbortController: ${JSON.stringify(error)}`);\n }\n result.value.dispose();\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAAS,6BAA6B,CAAC,SAA+B;AAAA,EAE3E,MAAM,kBAAkB,IAAI;AAAA,EAC5B,IAAI,gBAAgB;AAAA,EAGpB,MAAM,oBAAoB,QAAQ,YAAY,uBAAuB,CAAC,aAAa;AAAA,IACjF,MAAM,KAAK,QAAQ,UAAU,QAAQ;AAAA,IACrC,MAAM,YAAY;AAAA,IAGlB,MAAM,gBAAgB,WAAW,MAAM;AAAA,MACrC,gBAAgB,OAAO,SAAS;AAAA,OAC/B,EAAE;AAAA,IAEL,gBAAgB,IAAI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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAiJ/B;AAAA,EAED,IAAI,OAAO,OAAO;AAAA,IAChB,MAAM,QAAQ,QAAQ,KAAK,OAAO,KAAK;AAAA,IACvC,OAAO,MAAM,QAAQ;AAAA,IACrB,MAAM,IAAI,MAAM,oCAAoC,KAAK,UAAU,KAAK,GAAG;AAAA,EAC7E;AAAA,EACA,OAAO,MAAM,QAAQ;AAAA;",
|
|
8
|
+
"debugId": "76B7F4BCB13124D864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// @bun @bun-cjs
|
|
2
|
+
(function(exports, require, module, __filename, __dirname) {var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// packages/fetch/src/globals/fetch.ts
|
|
31
|
+
var exports_fetch = {};
|
|
32
|
+
__export(exports_fetch, {
|
|
33
|
+
createFetchFunction: () => createFetchFunction
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(exports_fetch);
|
|
36
|
+
var import_quickjs_core = require("@ricsam/quickjs-core");
|
|
37
|
+
var import_headers = require("./headers.ts");
|
|
38
|
+
var import_response = require("./response.ts");
|
|
39
|
+
function createFetchFunction(context, onFetch) {
|
|
40
|
+
return context.newFunction("fetch", (...argHandles) => {
|
|
41
|
+
const deferred = context.newPromise();
|
|
42
|
+
const inputHandle = argHandles[0];
|
|
43
|
+
const initHandle = argHandles[1];
|
|
44
|
+
let signalHandle = null;
|
|
45
|
+
if (initHandle !== undefined) {
|
|
46
|
+
const initType = context.typeof(initHandle);
|
|
47
|
+
if (initType === "object") {
|
|
48
|
+
const tempSignal = context.getProp(initHandle, "signal");
|
|
49
|
+
const signalType = context.typeof(tempSignal);
|
|
50
|
+
if (signalType !== "undefined" && signalType !== "null") {
|
|
51
|
+
signalHandle = tempSignal;
|
|
52
|
+
} else {
|
|
53
|
+
tempSignal.dispose();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let isPreAborted = false;
|
|
58
|
+
let abortReason;
|
|
59
|
+
if (signalHandle) {
|
|
60
|
+
const abortedHandle = context.getProp(signalHandle, "aborted");
|
|
61
|
+
isPreAborted = Boolean(context.dump(abortedHandle));
|
|
62
|
+
abortedHandle.dispose();
|
|
63
|
+
if (isPreAborted) {
|
|
64
|
+
const reasonHandle = context.getProp(signalHandle, "reason");
|
|
65
|
+
abortReason = context.dump(reasonHandle);
|
|
66
|
+
reasonHandle.dispose();
|
|
67
|
+
signalHandle.dispose();
|
|
68
|
+
signalHandle = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (isPreAborted) {
|
|
72
|
+
Promise.resolve().then(() => {
|
|
73
|
+
const errorMessage = abortReason?.message || "signal is aborted without reason";
|
|
74
|
+
const safeMessage = errorMessage.replace(/"/g, "\\\"");
|
|
75
|
+
const errorResult = context.evalCode(`new DOMException("${safeMessage}", "AbortError")`);
|
|
76
|
+
if ("value" in errorResult) {
|
|
77
|
+
deferred.reject(errorResult.value);
|
|
78
|
+
errorResult.value.dispose();
|
|
79
|
+
} else {
|
|
80
|
+
const fallbackError = import_quickjs_core.marshal(context, { name: "AbortError", message: errorMessage });
|
|
81
|
+
deferred.reject(fallbackError);
|
|
82
|
+
fallbackError.dispose();
|
|
83
|
+
errorResult.error.dispose();
|
|
84
|
+
}
|
|
85
|
+
context.runtime.executePendingJobs();
|
|
86
|
+
});
|
|
87
|
+
return deferred.handle;
|
|
88
|
+
}
|
|
89
|
+
const nativeController = new AbortController;
|
|
90
|
+
if (signalHandle) {
|
|
91
|
+
const abortCallback = context.newFunction("__fetchAbortCallback__", () => {
|
|
92
|
+
nativeController.abort();
|
|
93
|
+
return context.undefined;
|
|
94
|
+
});
|
|
95
|
+
const addEventListenerHandle = context.getProp(signalHandle, "addEventListener");
|
|
96
|
+
const typeHandle = context.newString("abort");
|
|
97
|
+
context.callFunction(addEventListenerHandle, signalHandle, typeHandle, abortCallback);
|
|
98
|
+
typeHandle.dispose();
|
|
99
|
+
addEventListenerHandle.dispose();
|
|
100
|
+
abortCallback.dispose();
|
|
101
|
+
signalHandle.dispose();
|
|
102
|
+
}
|
|
103
|
+
const input = inputHandle ? import_quickjs_core.unmarshal(context, inputHandle) : undefined;
|
|
104
|
+
const init = initHandle ? import_quickjs_core.unmarshal(context, initHandle) : undefined;
|
|
105
|
+
let url = "";
|
|
106
|
+
let method = "GET";
|
|
107
|
+
let headers = new Headers;
|
|
108
|
+
let body = null;
|
|
109
|
+
if (typeof input === "string") {
|
|
110
|
+
url = input;
|
|
111
|
+
} else if (input && typeof input === "object" && "url" in input) {
|
|
112
|
+
const reqState = input;
|
|
113
|
+
url = reqState.url;
|
|
114
|
+
method = reqState.method;
|
|
115
|
+
headers = import_headers.headersStateToNative(reqState.headersState);
|
|
116
|
+
if (reqState.body) {
|
|
117
|
+
body = reqState.body;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (init) {
|
|
121
|
+
if (init.method) {
|
|
122
|
+
method = init.method;
|
|
123
|
+
}
|
|
124
|
+
if (init.headers) {
|
|
125
|
+
if (init.headers && typeof init.headers === "object" && "headers" in init.headers) {
|
|
126
|
+
headers = import_headers.headersStateToNative(init.headers);
|
|
127
|
+
} else {
|
|
128
|
+
headers = new Headers;
|
|
129
|
+
for (const [key, value] of Object.entries(init.headers)) {
|
|
130
|
+
headers.set(key, String(value));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (init.body !== undefined) {
|
|
135
|
+
if (typeof init.body === "string") {
|
|
136
|
+
body = init.body;
|
|
137
|
+
} else if (init.body instanceof ArrayBuffer) {
|
|
138
|
+
body = init.body;
|
|
139
|
+
} else if (init.body instanceof Uint8Array) {
|
|
140
|
+
body = init.body;
|
|
141
|
+
} else if (init.body && typeof init.body === "object" && "parts" in init.body) {
|
|
142
|
+
const parts = init.body.parts;
|
|
143
|
+
const totalLength = parts.reduce((sum, p) => sum + p.length, 0);
|
|
144
|
+
const combined = new Uint8Array(totalLength);
|
|
145
|
+
let offset = 0;
|
|
146
|
+
for (const part of parts) {
|
|
147
|
+
combined.set(part, offset);
|
|
148
|
+
offset += part.length;
|
|
149
|
+
}
|
|
150
|
+
body = combined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
Promise.resolve().then(async () => {
|
|
155
|
+
try {
|
|
156
|
+
if (!onFetch) {
|
|
157
|
+
throw new Error("fetch is not configured - no onFetch handler provided to setupFetch");
|
|
158
|
+
}
|
|
159
|
+
const nativeRequest = new Request(url, {
|
|
160
|
+
method,
|
|
161
|
+
headers,
|
|
162
|
+
body: method !== "GET" && method !== "HEAD" ? body : undefined,
|
|
163
|
+
signal: nativeController.signal
|
|
164
|
+
});
|
|
165
|
+
const nativeResponse = await onFetch(nativeRequest);
|
|
166
|
+
const responseState = await import_response.createResponseStateFromNative(nativeResponse);
|
|
167
|
+
const resultHandle = import_quickjs_core.marshal(context, responseState);
|
|
168
|
+
deferred.resolve(resultHandle);
|
|
169
|
+
resultHandle.dispose();
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
172
|
+
const safeMessage = error.message.replace(/"/g, "\\\"");
|
|
173
|
+
const errorResult = context.evalCode(`new DOMException("${safeMessage}", "AbortError")`);
|
|
174
|
+
if ("value" in errorResult) {
|
|
175
|
+
deferred.reject(errorResult.value);
|
|
176
|
+
errorResult.value.dispose();
|
|
177
|
+
} else {
|
|
178
|
+
const fallbackError = import_quickjs_core.marshal(context, { name: "AbortError", message: error.message });
|
|
179
|
+
deferred.reject(fallbackError);
|
|
180
|
+
fallbackError.dispose();
|
|
181
|
+
errorResult.error.dispose();
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
const errorHandle = import_quickjs_core.marshal(context, {
|
|
185
|
+
name: error instanceof Error ? error.name : "Error",
|
|
186
|
+
message: error instanceof Error ? error.message : String(error)
|
|
187
|
+
});
|
|
188
|
+
deferred.reject(errorHandle);
|
|
189
|
+
errorHandle.dispose();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
context.runtime.executePendingJobs();
|
|
193
|
+
});
|
|
194
|
+
return deferred.handle;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
//# debugId=7E802FD0338F66EB64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/globals/fetch.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { QuickJSContext, QuickJSHandle } from \"quickjs-emscripten\";\nimport { unmarshal, marshal } from \"@ricsam/quickjs-core\";\nimport type { RequestState, HeadersState } from \"../types.ts\";\nimport { headersStateToNative } from \"./headers.ts\";\nimport { createResponseStateFromNative } from \"./response.ts\";\n\n/**\n * Create the fetch function for QuickJS\n */\nexport function createFetchFunction(\n context: QuickJSContext,\n onFetch?: (request: Request) => Promise<Response>\n): QuickJSHandle {\n return context.newFunction(\"fetch\", (...argHandles) => {\n // Create promise first\n const deferred = context.newPromise();\n\n const inputHandle = argHandles[0];\n const initHandle = argHandles[1];\n\n // Extract signal BEFORE unmarshalling (keep as handle)\n let signalHandle: QuickJSHandle | null = null;\n // Check if initHandle exists and is a valid QuickJS handle (not JS undefined)\n if (initHandle !== undefined) {\n const initType = context.typeof(initHandle);\n if (initType === \"object\") {\n const tempSignal = context.getProp(initHandle, \"signal\");\n const signalType = context.typeof(tempSignal);\n if (signalType !== \"undefined\" && signalType !== \"null\") {\n signalHandle = tempSignal;\n } else {\n tempSignal.dispose();\n }\n }\n }\n\n // Check if signal is pre-aborted\n let isPreAborted = false;\n let abortReason: { message?: string } | undefined;\n if (signalHandle) {\n const abortedHandle = context.getProp(signalHandle, \"aborted\");\n isPreAborted = Boolean(context.dump(abortedHandle));\n abortedHandle.dispose();\n\n if (isPreAborted) {\n const reasonHandle = context.getProp(signalHandle, \"reason\");\n abortReason = context.dump(reasonHandle) as { message?: string } | undefined;\n reasonHandle.dispose();\n signalHandle.dispose();\n signalHandle = null;\n }\n }\n\n // If pre-aborted, reject immediately in a microtask\n if (isPreAborted) {\n Promise.resolve().then(() => {\n // Create DOMException and reject\n const errorMessage = abortReason?.message || \"signal is aborted without reason\";\n // Escape quotes in the message for safety\n const safeMessage = errorMessage.replace(/\"/g, '\\\\\"');\n const errorResult = context.evalCode(\n `new DOMException(\"${safeMessage}\", \"AbortError\")`\n );\n if (\"value\" in errorResult) {\n deferred.reject(errorResult.value);\n errorResult.value.dispose();\n } else {\n // If evalCode failed, create a plain error\n const fallbackError = marshal(context, { name: \"AbortError\", message: errorMessage });\n deferred.reject(fallbackError);\n fallbackError.dispose();\n errorResult.error.dispose();\n }\n context.runtime.executePendingJobs();\n });\n return deferred.handle;\n }\n\n // Create native AbortController\n const nativeController = new AbortController();\n\n // Wire QuickJS signal to native controller\n if (signalHandle) {\n // Create callback that aborts native controller when QuickJS signal aborts\n const abortCallback = context.newFunction(\"__fetchAbortCallback__\", () => {\n nativeController.abort();\n return context.undefined;\n });\n\n // Call addEventListener on the QuickJS signal\n const addEventListenerHandle = context.getProp(signalHandle, \"addEventListener\");\n const typeHandle = context.newString(\"abort\");\n\n context.callFunction(addEventListenerHandle, signalHandle, typeHandle, abortCallback);\n\n typeHandle.dispose();\n addEventListenerHandle.dispose();\n abortCallback.dispose();\n signalHandle.dispose();\n }\n\n // Unmarshal arguments\n const input = inputHandle ? unmarshal(context, inputHandle) : undefined;\n const init = initHandle ? unmarshal(context, initHandle) as {\n method?: string;\n headers?: object;\n body?: unknown;\n } | undefined : undefined;\n\n // Build the request\n let url = \"\";\n let method = \"GET\";\n let headers = new Headers();\n let body: BodyInit | null = null;\n\n if (typeof input === \"string\") {\n url = input;\n } else if (input && typeof input === \"object\" && \"url\" in input) {\n // Request-like object from QuickJS\n const reqState = input as RequestState;\n url = reqState.url;\n method = reqState.method;\n headers = headersStateToNative(reqState.headersState);\n if (reqState.body) {\n body = reqState.body as BodyInit;\n }\n }\n\n // Apply init overrides\n if (init) {\n if (init.method) {\n method = init.method;\n }\n if (init.headers) {\n if (\n init.headers &&\n typeof init.headers === \"object\" &&\n \"headers\" in init.headers\n ) {\n headers = headersStateToNative(init.headers as HeadersState);\n } else {\n headers = new Headers();\n for (const [key, value] of Object.entries(init.headers)) {\n headers.set(key, String(value));\n }\n }\n }\n if (init.body !== undefined) {\n if (typeof init.body === \"string\") {\n body = init.body;\n } else if (init.body instanceof ArrayBuffer) {\n body = init.body;\n } else if (init.body instanceof Uint8Array) {\n body = init.body as BodyInit;\n } else if (\n init.body &&\n typeof init.body === \"object\" &&\n \"parts\" in init.body\n ) {\n // Blob-like\n const parts = (init.body as { parts: Uint8Array[] }).parts;\n const totalLength = parts.reduce((sum, p) => sum + p.length, 0);\n const combined = new Uint8Array(totalLength);\n let offset = 0;\n for (const part of parts) {\n combined.set(part, offset);\n offset += part.length;\n }\n body = combined as BodyInit;\n }\n }\n }\n\n // Run the async fetch operation in a microtask to ensure proper promise settling\n Promise.resolve().then(async () => {\n try {\n if (!onFetch) {\n throw new Error(\n \"fetch is not configured - no onFetch handler provided to setupFetch\"\n );\n }\n\n // Create native Request with signal\n const nativeRequest = new Request(url, {\n method,\n headers,\n body: method !== \"GET\" && method !== \"HEAD\" ? body : undefined,\n signal: nativeController.signal,\n });\n\n // Call the host fetch handler\n const nativeResponse = await onFetch(nativeRequest);\n\n // Convert to ResponseState for QuickJS\n const responseState = await createResponseStateFromNative(nativeResponse);\n const resultHandle = marshal(context, responseState);\n deferred.resolve(resultHandle);\n resultHandle.dispose();\n } catch (error) {\n // Handle abort errors specially\n if (error instanceof DOMException && error.name === \"AbortError\") {\n const safeMessage = error.message.replace(/\"/g, '\\\\\"');\n const errorResult = context.evalCode(\n `new DOMException(\"${safeMessage}\", \"AbortError\")`\n );\n if (\"value\" in errorResult) {\n deferred.reject(errorResult.value);\n errorResult.value.dispose();\n } else {\n const fallbackError = marshal(context, { name: \"AbortError\", message: error.message });\n deferred.reject(fallbackError);\n fallbackError.dispose();\n errorResult.error.dispose();\n }\n } else {\n const errorHandle = marshal(context, {\n name: error instanceof Error ? error.name : \"Error\",\n message: error instanceof Error ? error.message : String(error),\n });\n deferred.reject(errorHandle);\n errorHandle.dispose();\n }\n }\n context.runtime.executePendingJobs();\n });\n\n return deferred.handle;\n });\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACmC,IAAnC;AAEqC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