visaljs 0.0.8 → 0.0.10

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 (54) hide show
  1. package/README.md +6 -3
  2. package/THIRD_PARTY_LICENSES +1 -1
  3. package/cli.js +2782 -770
  4. package/node/include/js_node.h +1 -0
  5. package/node/prelude/_http_agent.js +5 -0
  6. package/node/prelude/_http_server.js +7 -0
  7. package/node/prelude/dns.js +7 -1
  8. package/node/prelude/events.js +7 -3
  9. package/node/prelude/http.js +693 -285
  10. package/node/prelude/https.js +14 -3
  11. package/node/prelude/internal/events_extras.js +2 -5
  12. package/node/prelude/internal/features.js +17 -0
  13. package/node/prelude/internal/http_agent.js +88 -2
  14. package/node/prelude/internal/http_chars.ts +22 -0
  15. package/node/prelude/internal/http_symbols.js +3 -0
  16. package/node/prelude/internal/net_bound.js +123 -0
  17. package/node/prelude/internal/net_onread.js +73 -0
  18. package/node/prelude/internal/net_tos.js +54 -0
  19. package/node/prelude/internal/perf_observe.js +7 -1
  20. package/node/prelude/internal/tls/wrap.js +2 -1
  21. package/node/prelude/module.js +42 -18
  22. package/node/prelude/net.js +212 -61
  23. package/node/prelude/perf_hooks.js +4 -0
  24. package/node/src/host_http.c +151 -21
  25. package/node/src/host_net.c +75 -9
  26. package/node/src/host_sys.c +9 -0
  27. package/package.json +1 -1
  28. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  29. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  30. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  31. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  32. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  33. package/runtime/include/js_atoms.h +4 -0
  34. package/runtime/include/js_buffer.h +185 -0
  35. package/runtime/include/js_builtins.h +53 -0
  36. package/runtime/include/js_exception.h +3 -0
  37. package/runtime/include/js_function.h +1 -1
  38. package/runtime/include/js_object.h +21 -3
  39. package/runtime/include/js_ops.h +27 -0
  40. package/runtime/include/js_runtime.h +1 -0
  41. package/runtime/include/js_web.h +3 -3
  42. package/runtime/include/jscontext.h +15 -0
  43. package/runtime/src/atoms.c +37 -3
  44. package/runtime/src/builtins.c +17 -4
  45. package/runtime/src/events.c +19 -0
  46. package/runtime/src/function.c +37 -10
  47. package/runtime/src/gc.c +7 -5
  48. package/runtime/src/internal.h +4 -4
  49. package/runtime/src/iterator.c +5 -1
  50. package/runtime/src/object.c +42 -6
  51. package/runtime/src/regexp.c +569 -12
  52. package/runtime/src/shape.c +68 -1
  53. package/runtime/src/typedarray.c +23 -0
  54. package/runtime/src/weak.c +95 -24
@@ -31,6 +31,7 @@ JSValue js_host_fs_read(JSContext *ctx, JSValue callee, JSValue this_val, uint32
31
31
  int js_node_uv_error(int e);
32
32
  JSValue js_host_errno_name(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
33
33
  JSValue js_host_timer_unref(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
34
+ JSValue js_host_loop_now(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
34
35
  JSValue js_host_timer_start(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
35
36
  JSValue js_host_timer_ref(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
36
37
  JSValue js_host_async_context_get(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
@@ -0,0 +1,5 @@
1
+ // node:_http_agent: Node's module behind node:http's Agent, as its tests reach it.
2
+ import { Agent, globalAgent } from "./internal/http_agent.js";
3
+
4
+ export { Agent, globalAgent };
5
+ export default { Agent, globalAgent };
@@ -0,0 +1,7 @@
1
+ // node:_http_server: Node's module behind node:http's server, as its tests reach it: the server's
2
+ // classes and kConnectionsCheckingInterval (lib/_http_server.js' exports that have ours).
3
+ import { Server, ServerResponse, STATUS_CODES } from "./http.js";
4
+ import { kConnectionsCheckingInterval } from "./internal/http_symbols.js";
5
+
6
+ export { kConnectionsCheckingInterval, Server, ServerResponse, STATUS_CODES };
7
+ export default { kConnectionsCheckingInterval, Server, ServerResponse, STATUS_CODES };
@@ -3,7 +3,7 @@
3
3
  // (c-ares) and Resolver.
4
4
  import { dnsLookup, errnoName } from "visaljs:host";
5
5
  import { bindContext } from "./internal/async_context.js";
6
- import { codeError, invalidArgType } from "./internal/errors.js";
6
+ import { codeError, invalidArgType, invalidArgValue } from "./internal/errors.js";
7
7
  import { isIP } from "./internal/net.js";
8
8
 
9
9
  /* getaddrinfo hints, and the error codes of the resolver */
@@ -66,6 +66,12 @@ export function lookup(hostname, options, callback) {
66
66
  } else if (options !== undefined && options !== null) {
67
67
  family = familyOf(options.family);
68
68
  all = options.all === true;
69
+ /* hints are checked, as Node's; getaddrinfo isn't given them */
70
+ if (options.hints != null) {
71
+ if (typeof options.hints !== "number") throw invalidArgType("options.hints", "of type number", options.hints);
72
+ const hints = options.hints >>> 0;
73
+ if ((hints & ~(ADDRCONFIG | ALL | V4MAPPED)) !== 0) throw invalidArgValue("hints", "is invalid", hints);
74
+ }
69
75
  }
70
76
  if (typeof callback !== "function") throw invalidArgType("callback", "of type function", callback);
71
77
  if (!hostname) {
@@ -4,6 +4,7 @@
4
4
  // warning, and captureRejections. The functions on emitters and EventTargets: once and on (as
5
5
  // promises and an async iterator, with an AbortSignal), getEventListeners, the max-listener
6
6
  // counts, and addAbortListener.
7
+ import { eventTargetListeners } from "visaljs:host";
7
8
  import { lazyClass, lazyFunction } from "./internal/features.js";
8
9
 
9
10
  const kCapture = Symbol("kCapture");
@@ -355,9 +356,12 @@ EventEmitter.on = on;
355
356
  export const getEventListeners = lazyFunction("getEventListeners", 2);
356
357
  export const getMaxListeners = lazyFunction("getMaxListeners", 1);
357
358
  export const setMaxListeners = lazyFunction("setMaxListeners");
358
- /** Deprecated: emitter.listenerCount(type). */
359
- export function listenerCount(emitter, type) {
360
- return typeof emitter.listenerCount === "function" ? emitter.listenerCount(type) : 0;
359
+ /** emitter.listenerCount(type), or an EventTarget's listeners for the type, as Node's. */
360
+ export function listenerCount(emitterOrTarget, type) {
361
+ if (typeof emitterOrTarget?.listenerCount === "function") return emitterOrTarget.listenerCount(type);
362
+ const listeners = eventTargetListeners(emitterOrTarget, type);
363
+ if (listeners !== undefined) return listeners.length;
364
+ throw invalidArgType("emitter", "an instance of EventEmitter or EventTarget", emitterOrTarget);
361
365
  }
362
366
  export const addAbortListener = lazyFunction("addAbortListener", 2);
363
367
  export const usingDomains = false;