@scriptc/compiler 0.0.13 → 0.0.15

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.
Files changed (40) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +21 -4
  2. package/dist/backend/cc.d.ts +15 -0
  3. package/dist/backend/cc.js +32 -7
  4. package/dist/backend/cc.js.map +1 -1
  5. package/dist/backend/emission/emit-exprs.js +55 -4
  6. package/dist/backend/emission/emit-exprs.js.map +1 -1
  7. package/dist/backend/emission/emitter.d.ts +3 -1
  8. package/dist/backend/emission/emitter.js +32 -0
  9. package/dist/backend/emission/emitter.js.map +1 -1
  10. package/dist/backend/llvm/emitter.js +119 -5
  11. package/dist/backend/llvm/emitter.js.map +1 -1
  12. package/dist/diagnostics/diagnostic.d.ts +13 -0
  13. package/dist/diagnostics/diagnostic.js +44 -0
  14. package/dist/diagnostics/diagnostic.js.map +1 -1
  15. package/dist/ffi/profile.d.ts +29 -0
  16. package/dist/ffi/profile.js +191 -0
  17. package/dist/ffi/profile.js.map +1 -0
  18. package/dist/frontend/lowering/lower-calls.d.ts +17 -0
  19. package/dist/frontend/lowering/lower-calls.js +191 -2
  20. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  21. package/dist/frontend/lowering/lower-server.js +27 -11
  22. package/dist/frontend/lowering/lower-server.js.map +1 -1
  23. package/dist/frontend/lowering/lowerer.d.ts +16 -1
  24. package/dist/frontend/lowering/lowerer.js +44 -5
  25. package/dist/frontend/lowering/lowerer.js.map +1 -1
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.js +141 -80
  28. package/dist/index.js.map +1 -1
  29. package/dist/ir/nodes.d.ts +36 -1
  30. package/dist/ir/nodes.js +4 -0
  31. package/dist/ir/nodes.js.map +1 -1
  32. package/dist/ir/serialize.d.ts +1 -1
  33. package/dist/ir/serialize.js +1 -1
  34. package/dist/ir/validate.js +59 -4
  35. package/dist/ir/validate.js.map +1 -1
  36. package/dist/library/int-infer.js +1 -0
  37. package/dist/library/int-infer.js.map +1 -1
  38. package/dist/library/int-infer.test.js +1 -1
  39. package/package.json +2 -2
  40. 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(). The url-string first argument has no
3094
- * lowering (build the options object instead). `secure` is the https
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" && !secureish) {
3124
- // The URL-string form — http.get(`http://127.0.0.1:${port}/x`[, cb]):
3125
- // the runtime parses through the WHATWG unit and dials; unparsable
3126
- // inputs and non-http schemes throw catchably (may-throw seed).
3127
- const url = L.lowerExprExpecting(optsNode, STRING);
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
- return { kind: "libCall", fn: "http.requestUrl", args: [url, methodLit, autoEnd], type: HTTPCLIENTREQ_T, loc };
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
- return { kind: "libCall", fn: "http.requestUrlCb", args: [url, methodLit, autoEnd, cb], type: HTTPCLIENTREQ_T, loc };
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
- ? `${member} with a URL-string first argument`
3138
- : `${member} with a non-literal options argument`, optsNode, "pass the options as an object literal: { hostname, port, path, method, timeout?, headers? }");
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;