@scriptc/runtime 0.0.21 → 0.0.23
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/scr_assert.c +23 -0
- package/src/scr_async.c +5 -2
- package/src/scr_bytes.c +7 -0
- package/src/scr_cycle.c +403 -62
- package/src/scr_dyn_invoke.c +58 -6
- package/src/scr_fetch.c +6200 -124
- package/src/scr_fetch_curl.c +21 -9
- package/src/scr_http.c +13 -0
- package/src/scr_inspect.c +6 -0
- package/src/scr_island.c +19 -0
- package/src/scr_json.c +413 -9
- package/src/scr_lib.c +277 -18
- package/src/scr_runtime.h +211 -27
- package/src/scr_tls.c +15 -11
- package/src/scr_tls_ca.c +35 -8
- package/src/scr_url.c +103 -15
- package/src/scr_web.c +77 -1
- package/vendor/README.md +4 -4
package/src/scr_fetch_curl.c
CHANGED
|
@@ -360,14 +360,17 @@ static JSValue fx_host_start(JSContext *ctx, JSValueConst this_val, int argc,
|
|
|
360
360
|
curl_easy_setopt(e, CURLOPT_ACCEPT_ENCODING, ""); /* gzip in, transparent out */
|
|
361
361
|
curl_easy_setopt(e, CURLOPT_PROTOCOLS_STR, "http,https");
|
|
362
362
|
curl_easy_setopt(e, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L);
|
|
363
|
-
/* Node
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const char *
|
|
370
|
-
|
|
363
|
+
/* Node's global opt-in and Vercel's request-local EnvProxyDispatcher both
|
|
364
|
+
* activate libcurl's environment proxy lookup. Otherwise explicitly turn
|
|
365
|
+
* it off, because libcurl enables proxy variables by default. */
|
|
366
|
+
JSValue envproxyv = JS_GetPropertyStr(ctx, req, "useEnvProxy");
|
|
367
|
+
bool use_env_proxy = JS_ToBool(ctx, envproxyv) > 0;
|
|
368
|
+
JS_FreeValue(ctx, envproxyv);
|
|
369
|
+
const char *global_env_proxy = getenv("NODE_USE_ENV_PROXY");
|
|
370
|
+
use_env_proxy = use_env_proxy ||
|
|
371
|
+
(global_env_proxy != NULL &&
|
|
372
|
+
strcmp(global_env_proxy, "1") == 0);
|
|
373
|
+
if (!use_env_proxy) {
|
|
371
374
|
curl_easy_setopt(e, CURLOPT_PROXY, "");
|
|
372
375
|
}
|
|
373
376
|
|
|
@@ -486,6 +489,15 @@ static const char fx_glue[] =
|
|
|
486
489
|
" url = String(input);\n"
|
|
487
490
|
" }\n"
|
|
488
491
|
" init = init === undefined || init === null ? {} : init;\n"
|
|
492
|
+
" let useEnvProxy = g.process?.env?.NODE_USE_ENV_PROXY === '1';\n"
|
|
493
|
+
" const initDispatcher = init.dispatcher;\n"
|
|
494
|
+
" if (initDispatcher !== undefined) {\n"
|
|
495
|
+
" const dispatcher = initDispatcher;\n"
|
|
496
|
+
" const methods = ['dispatch', 'close', 'destroy', 'agents', 'getAgent', 'shouldProxy', 'parseNoProxy'];\n"
|
|
497
|
+
" const known = dispatcher !== null && typeof dispatcher === 'object' && dispatcher.constructor?.name === 'EnvProxyDispatcher' && methods.every((member) => typeof dispatcher[member] === 'function');\n"
|
|
498
|
+
" if (!known) throw new TypeError('unsupported RequestInit option: dispatcher');\n"
|
|
499
|
+
" useEnvProxy = true;\n"
|
|
500
|
+
" }\n"
|
|
489
501
|
" // An explicit init.signal overrides the Request's, null included.\n"
|
|
490
502
|
" if (init.signal !== undefined) {\n"
|
|
491
503
|
" if (init.signal !== null && !(init.signal instanceof g.AbortSignal)) {\n"
|
|
@@ -546,7 +558,7 @@ static const char fx_glue[] =
|
|
|
546
558
|
" const flat = [];\n"
|
|
547
559
|
" for (const pair of headers) { flat.push(pair[0], pair[1]); }\n"
|
|
548
560
|
" id = host.start(\n"
|
|
549
|
-
" { url, method, headers: flat, body: body === null ? undefined : body },\n"
|
|
561
|
+
" { url, method, headers: flat, body: body === null ? undefined : body, useEnvProxy },\n"
|
|
550
562
|
" {\n"
|
|
551
563
|
" onResponse(status, statusText, raw, finalUrl, redirected) {\n"
|
|
552
564
|
" resolved = true;\n"
|
package/src/scr_http.c
CHANGED
|
@@ -2608,6 +2608,19 @@ static bool scr_http_client_parse_head(ScrHttpConn *conn, size_t head_len) {
|
|
|
2608
2608
|
return false;
|
|
2609
2609
|
}
|
|
2610
2610
|
|
|
2611
|
+
/*
|
|
2612
|
+
* Informational responses do not settle the request. Node emits an
|
|
2613
|
+
* `information` event for these and keeps parsing until the final
|
|
2614
|
+
* response; this runtime has no information listener surface yet, so
|
|
2615
|
+
* consume the head and continue. 101 is the upgrade case below.
|
|
2616
|
+
*/
|
|
2617
|
+
if (status >= 100 && status < 200 && status != 101) {
|
|
2618
|
+
memmove(conn->buf, conn->buf + head_len, conn->len - head_len);
|
|
2619
|
+
conn->len -= head_len;
|
|
2620
|
+
scr_http_req_release(res);
|
|
2621
|
+
return true;
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2611
2624
|
/* framing: HEAD requests and 204/304 responses have NO body; chunked
|
|
2612
2625
|
* wins over Content-Length; neither means EOF-delimited */
|
|
2613
2626
|
bool chunked = false;
|
package/src/scr_inspect.c
CHANGED
|
@@ -849,6 +849,12 @@ ScrStr *scr_insp_dyn(ScrDyn *d, double recurse, double depth) {
|
|
|
849
849
|
scr_throw_error(SCR_ERR_ERROR, ib_take(&out));
|
|
850
850
|
return scr_str_new("", 0);
|
|
851
851
|
}
|
|
852
|
+
case SCR_DYN_TYPED_REF: {
|
|
853
|
+
ScrDyn *materialized = scr_dyn_typed_ref_materialize(d);
|
|
854
|
+
ScrStr *out = scr_insp_dyn(materialized, recurse, depth);
|
|
855
|
+
scr_dyn_release(materialized);
|
|
856
|
+
return out;
|
|
857
|
+
}
|
|
852
858
|
case SCR_DYN_PROMISE: {
|
|
853
859
|
/* Node renders Promise { <pending> } / Promise { value } — the
|
|
854
860
|
* settled-value rendering pulls in the whole inspector; fence
|
package/src/scr_island.c
CHANGED
|
@@ -1635,6 +1635,25 @@ ScrJsval *scr_jsval_call(ScrJsval *f, int argc, ScrJsval **argv) {
|
|
|
1635
1635
|
return isl_cell_new(r);
|
|
1636
1636
|
}
|
|
1637
1637
|
|
|
1638
|
+
/* Call an already-resolved computed member with its original receiver. The
|
|
1639
|
+
* frontend performs GetValue before argument evaluation, then arrives here
|
|
1640
|
+
* after the arguments are ready; keeping callee and receiver separate avoids
|
|
1641
|
+
* a second getter read while preserving method `this`. */
|
|
1642
|
+
ScrJsval *scr_jsval_call_this(ScrJsval *f, ScrJsval *receiver, int argc,
|
|
1643
|
+
ScrJsval **argv) {
|
|
1644
|
+
isl_entry();
|
|
1645
|
+
JSValue stack_args[8];
|
|
1646
|
+
JSValue *args = argc <= 8 ? stack_args : malloc((size_t)argc * sizeof(JSValue));
|
|
1647
|
+
for (int i = 0; i < argc; i++) args[i] = argv[i]->v;
|
|
1648
|
+
JSValue r = JS_Call(isl_ctx, f->v, receiver->v, argc, args);
|
|
1649
|
+
if (args != stack_args) free(args);
|
|
1650
|
+
if (JS_IsException(r)) {
|
|
1651
|
+
isl_bridge_exception();
|
|
1652
|
+
return NULL;
|
|
1653
|
+
}
|
|
1654
|
+
return isl_cell_new(r);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1638
1657
|
/* Spread application on an island callee (jsOp callSpread) — the prelude
|
|
1639
1658
|
* helper's real `f(...pre, ...spread)`, so iterator protocols are the
|
|
1640
1659
|
* engine's own and the guards front-run V8's exact spread-call TypeError
|