@scriptc/compiler 0.0.13 → 0.0.14
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/ambient/scriptc-node-fallback.d.ts +21 -4
- package/dist/backend/emission/emit-exprs.js +8 -4
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/llvm/emitter.js +15 -5
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +27 -11
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/ir/nodes.d.ts +4 -0
- package/dist/ir/nodes.js +4 -0
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +5 -2
- package/dist/ir/validate.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
|
@@ -3090,8 +3090,8 @@ function lowerHttp2ModuleCall(L, expr, bi, loc) {
|
|
|
3090
3090
|
* object literal with string values, or any Record whose values are
|
|
3091
3091
|
* strings / `string | undefined` — the env.pairs shape). Every other key
|
|
3092
3092
|
* fences by name. The callback registers as once('response'); get() is
|
|
3093
|
-
* request() plus the eager end().
|
|
3094
|
-
*
|
|
3093
|
+
* request() plus the eager end(). A URL-STRING first argument takes the
|
|
3094
|
+
* requestUrl row instead (both schemes; see below). `secure` is the https
|
|
3095
3095
|
* spelling: port defaults to 443 and the rejectUnauthorized (boolean)
|
|
3096
3096
|
* and ca (PEM string/Buffer) options join the lowered set. A
|
|
3097
3097
|
* HttpClientFnBinding as `secure` is the requestFn-binding mode: whether
|
|
@@ -3120,22 +3120,38 @@ function lowerHttpClientCall(L, expr, member, loc, secure = false) {
|
|
|
3120
3120
|
const optsNode = args[0];
|
|
3121
3121
|
if (!ts.isObjectLiteralExpression(optsNode)) {
|
|
3122
3122
|
const t = L.mapTypeOf(L.typeOf(optsNode));
|
|
3123
|
-
if (t?.kind === "string" &&
|
|
3124
|
-
// The URL-string form — http.get(`http://127.0.0.1:${port}/x`[, cb])
|
|
3125
|
-
// the runtime parses through the WHATWG unit
|
|
3126
|
-
// inputs and
|
|
3127
|
-
|
|
3123
|
+
if ((t?.kind === "string" || t?.kind === "url") && binding === null) {
|
|
3124
|
+
// The URL-string form — http.get(`http://127.0.0.1:${port}/x`[, cb])
|
|
3125
|
+
// and its https spelling: the runtime parses through the WHATWG unit
|
|
3126
|
+
// and dials; unparsable inputs and a scheme that is not the calling
|
|
3127
|
+
// module's throw catchably (may-throw seed). No options means Node's
|
|
3128
|
+
// defaults, which for https is verification against the default
|
|
3129
|
+
// trust anchors. The requestFn binding has no URL row — whether the
|
|
3130
|
+
// dial is TLS is only known at runtime there, and the two schemes
|
|
3131
|
+
// reject each other's URLs.
|
|
3132
|
+
// A URL OBJECT is its href through the same parse — Node's own
|
|
3133
|
+
// reading of the argument, and the serialization round-trips.
|
|
3134
|
+
const url = t.kind === "url"
|
|
3135
|
+
? { kind: "libCall", fn: "url.href", args: [L.lowerExpr(optsNode)], type: STRING, loc }
|
|
3136
|
+
: L.lowerExprExpecting(optsNode, STRING);
|
|
3128
3137
|
const methodLit = { kind: "strLit", value: "GET", type: STRING, loc };
|
|
3129
3138
|
const autoEnd = boolLit(member === "get", loc);
|
|
3139
|
+
const isTls = secure === true;
|
|
3130
3140
|
if (args.length === 1) {
|
|
3131
|
-
|
|
3141
|
+
const fn = isTls ? "https.requestUrl" : "http.requestUrl";
|
|
3142
|
+
return { kind: "libCall", fn, args: [url, methodLit, autoEnd], type: HTTPCLIENTREQ_T, loc };
|
|
3132
3143
|
}
|
|
3133
3144
|
const { cb } = lowerCallbackArg(L, args[1], "response callbacks", 1, (p) => p.kind === "httpReq", "use (res) or ()", [HTTPREQ_T]);
|
|
3134
|
-
|
|
3145
|
+
const fn = isTls ? "https.requestUrlCb" : "http.requestUrlCb";
|
|
3146
|
+
return { kind: "libCall", fn, args: [url, methodLit, autoEnd, cb], type: HTTPCLIENTREQ_T, loc };
|
|
3135
3147
|
}
|
|
3136
3148
|
L.noLowering(t?.kind === "string"
|
|
3137
|
-
?
|
|
3138
|
-
: `${member} with a non-literal options argument`, optsNode,
|
|
3149
|
+
? `a URL-string first argument through a request-function binding`
|
|
3150
|
+
: `${member} with a non-literal options argument`, optsNode, t?.kind === "string"
|
|
3151
|
+
// Only the binding mode reaches here now: the scheme would have to
|
|
3152
|
+
// agree with a dial chosen at runtime.
|
|
3153
|
+
? "call http.request / https.request directly for the URL-string form, or pass the options as an object literal"
|
|
3154
|
+
: "pass the options as an object literal: { hostname, port, path, method, timeout?, headers? }");
|
|
3139
3155
|
}
|
|
3140
3156
|
let host = null;
|
|
3141
3157
|
let port = null;
|