@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.
@@ -2117,12 +2117,25 @@ declare module "http" {
2117
2117
  options: ServerOptions,
2118
2118
  requestListener?: (req: IncomingMessage, res: ServerResponse) => void,
2119
2119
  ): Server;
2120
+ /* One signature with a UNION first parameter rather than Node's two
2121
+ * overloads: `const requestFn = tls ? https.request : http.request`
2122
+ * (the portless isProxyRunning shape) unions two function types, and
2123
+ * resolving a call on that union collapses each constituent to a
2124
+ * single signature — with an overload SET on both sides the options
2125
+ * literal ends up checked against URL, in either declaration order.
2126
+ * A union parameter has nothing to collapse. The lowering dispatches
2127
+ * on the argument's own type, so it reads the same either way.
2128
+ *
2129
+ * `target` is a URL string or URL object (the spelling a from-scratch
2130
+ * client reaches for first — dialed directly, with a non-http scheme
2131
+ * an ERR_INVALID_PROTOCOL at runtime rather than a type error), or
2132
+ * the options record. */
2120
2133
  export function request(
2121
- options: RequestOptions,
2134
+ target: RequestOptions | string | URL,
2122
2135
  callback?: (res: IncomingMessage) => void,
2123
2136
  ): ClientRequest;
2124
2137
  export function get(
2125
- options: RequestOptions,
2138
+ target: RequestOptions | string | URL,
2126
2139
  callback?: (res: IncomingMessage) => void,
2127
2140
  ): ClientRequest;
2128
2141
  }
@@ -2237,12 +2250,16 @@ declare module "https" {
2237
2250
  options: ServerOptions,
2238
2251
  requestListener: (req: IncomingMessage, res: ServerResponse) => void,
2239
2252
  ): Server;
2253
+ /* One signature with a union first parameter, for the request-fn
2254
+ * ternary's sake (see the http block). A URL target takes no options,
2255
+ * which means Node's defaults — the certificate is verified against
2256
+ * the default trust anchors. */
2240
2257
  export function request(
2241
- options: RequestOptions,
2258
+ target: RequestOptions | string | URL,
2242
2259
  callback?: (res: IncomingMessage) => void,
2243
2260
  ): ClientRequest;
2244
2261
  export function get(
2245
- options: RequestOptions,
2262
+ target: RequestOptions | string | URL,
2246
2263
  callback?: (res: IncomingMessage) => void,
2247
2264
  ): ClientRequest;
2248
2265
  }
@@ -3782,20 +3782,24 @@ export function emitExpr(E, e) {
3782
3782
  return finish(`scr_http_request_agent(${arg(0)}, ${arg(1)}, ${arg(2)}, ${arg(3)}, ${arg(4)}, ${arg(5)}, ${arg(6)}, ${arg(7)}, ${cbExpr}, ${adapter})`);
3783
3783
  }
3784
3784
  case "http.requestUrl":
3785
- case "http.requestUrlCb": {
3785
+ case "http.requestUrlCb":
3786
+ case "https.requestUrl":
3787
+ case "https.requestUrlCb": {
3786
3788
  E.usesTimers = true; // an in-flight request holds the loop open
3789
+ const tls = e.fn.startsWith("https.");
3787
3790
  let cbExpr = "NULL";
3788
3791
  let adapter = "NULL";
3789
- if (e.fn === "http.requestUrlCb") {
3792
+ if (e.fn.endsWith("Cb")) {
3790
3793
  const cbT = e.args[3].type;
3791
3794
  if (cbT.kind !== "func")
3792
- throw new Error("emitter bug: http.requestUrlCb callback not a func");
3795
+ throw new Error(`emitter bug: ${e.fn} callback not a func`);
3793
3796
  const cb = args[3];
3794
3797
  E.moveTemp(cb);
3795
3798
  cbExpr = cb.name;
3796
3799
  adapter = cbT.params.length === 0 ? "&scr_http_resp_thunk0" : "&scr_http_resp_thunk_res";
3797
3800
  }
3798
- return finish(`scr_http_request_url(${arg(0)}, ${arg(1)}, ${arg(2)}, ${cbExpr}, ${adapter})`);
3801
+ const entry = tls ? "scr_https_request_url" : "scr_http_request_url";
3802
+ return finish(`${entry}(${arg(0)}, ${arg(1)}, ${arg(2)}, ${cbExpr}, ${adapter})`);
3799
3803
  }
3800
3804
  case "http.requestConn":
3801
3805
  case "http.requestConnCb": {