visaljs 0.0.8 → 0.0.9
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/README.md +6 -3
- package/THIRD_PARTY_LICENSES +1 -1
- package/cli.js +55 -4
- package/node/prelude/_http_agent.js +5 -0
- package/node/prelude/_http_server.js +7 -0
- package/node/prelude/dns.js +7 -1
- package/node/prelude/events.js +7 -3
- package/node/prelude/http.js +685 -279
- package/node/prelude/https.js +14 -3
- package/node/prelude/internal/events_extras.js +2 -5
- package/node/prelude/internal/features.js +17 -0
- package/node/prelude/internal/http_agent.js +88 -2
- package/node/prelude/internal/http_symbols.js +3 -0
- package/node/prelude/internal/net_bound.js +123 -0
- package/node/prelude/internal/net_onread.js +73 -0
- package/node/prelude/internal/net_tos.js +54 -0
- package/node/prelude/internal/perf_observe.js +7 -1
- package/node/prelude/internal/tls/wrap.js +2 -1
- package/node/prelude/module.js +42 -18
- package/node/prelude/net.js +195 -48
- package/node/prelude/perf_hooks.js +4 -0
- package/node/src/host_http.c +151 -21
- package/node/src/host_net.c +75 -9
- package/package.json +1 -1
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.h +4 -0
- package/runtime/include/js_web.h +3 -0
- package/runtime/include/jscontext.h +8 -0
- package/runtime/src/atoms.c +37 -3
- package/runtime/src/events.c +19 -0
- package/runtime/src/gc.c +4 -4
- package/runtime/src/internal.h +4 -4
- package/runtime/src/regexp.c +569 -12
- package/runtime/src/shape.c +68 -1
- package/runtime/src/weak.c +95 -24
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# visaljs
|
|
2
2
|
|
|
3
|
-
An ahead-of-time JavaScript to C compiler: `visaljs build` turns a JavaScript
|
|
4
|
-
CommonJS, `node_modules`) into a native binary.
|
|
3
|
+
An ahead-of-time JavaScript to C compiler: `visaljs build` turns a JavaScript or TypeScript program
|
|
4
|
+
(ES modules, CommonJS, `node_modules`) into a native binary.
|
|
5
5
|
|
|
6
6
|
```sh
|
|
7
7
|
npm install -g visaljs
|
|
@@ -63,7 +63,7 @@ takes a minute. `VISALJS_PREBUILT=0` builds them anyway.
|
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
```
|
|
66
|
-
usage: visaljs build [entry.js | project directory] [options]
|
|
66
|
+
usage: visaljs build [entry.js | entry.ts | project directory] [options]
|
|
67
67
|
visaljs licenses print the licenses to ship with a binary you distribute
|
|
68
68
|
|
|
69
69
|
A project (the current directory when none is given) builds its framework's production server: a
|
|
@@ -71,6 +71,9 @@ vinext app is built with its own `vite build` first, then its server is compiled
|
|
|
71
71
|
project builds the file its package.json starts: its one "bin" command, the file "scripts.start"
|
|
72
72
|
runs with node, or "main"; else index.js. The binary is named after the command or the project.
|
|
73
73
|
|
|
74
|
+
TypeScript (.ts, .mts, .cts, .tsx) is compiled too: its types are stripped, not checked (run tsc
|
|
75
|
+
for that), with the nearest tsconfig.json's settings (paths, decorators).
|
|
76
|
+
|
|
74
77
|
options:
|
|
75
78
|
-o <file> output binary
|
|
76
79
|
--emit-c <dir> stop after C emission
|
package/THIRD_PARTY_LICENSES
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
A program built by visaljs 0.0.
|
|
1
|
+
A program built by visaljs 0.0.9 holds visaljs's runtime and, of the third-party code
|
|
2
2
|
below, the parts the program uses. Their licenses require these notices to go with copies of the
|
|
3
3
|
code: ship this text with a binary you distribute, in its documentation or a file beside it.
|
|
4
4
|
|
package/cli.js
CHANGED
|
@@ -9917,6 +9917,8 @@ const modules = {
|
|
|
9917
9917
|
repl: join(preludeDir, "repl.js"),
|
|
9918
9918
|
sea: join(preludeDir, "sea.js"),
|
|
9919
9919
|
stream: join(preludeDir, "stream.js"),
|
|
9920
|
+
_http_agent: join(preludeDir, "_http_agent.js"),
|
|
9921
|
+
_http_server: join(preludeDir, "_http_server.js"),
|
|
9920
9922
|
_stream_duplex: join(preludeDir, "_stream_duplex.js"),
|
|
9921
9923
|
_stream_passthrough: join(preludeDir, "_stream_passthrough.js"),
|
|
9922
9924
|
_stream_readable: join(preludeDir, "_stream_readable.js"),
|
|
@@ -10038,6 +10040,18 @@ const implicitModules = [
|
|
|
10038
10040
|
file: join(preludeDir, "internal", "source_map.js"),
|
|
10039
10041
|
reached: (_code, program) => /\bSourceMap\b/.test(program)
|
|
10040
10042
|
},
|
|
10043
|
+
{
|
|
10044
|
+
file: join(preludeDir, "internal", "net_onread.js"),
|
|
10045
|
+
reached: (_code, program) => /\bonread\b/.test(program)
|
|
10046
|
+
},
|
|
10047
|
+
{
|
|
10048
|
+
file: join(preludeDir, "internal", "net_tos.js"),
|
|
10049
|
+
reached: (_code, program) => /TypeOfService|typeOfService/.test(program)
|
|
10050
|
+
},
|
|
10051
|
+
{
|
|
10052
|
+
file: join(preludeDir, "internal", "net_bound.js"),
|
|
10053
|
+
reached: (_code, program) => /\bBoundSocket\b/.test(program)
|
|
10054
|
+
},
|
|
10041
10055
|
{
|
|
10042
10056
|
file: join(preludeDir, "internal", "perf_observe.js"),
|
|
10043
10057
|
reached: (_code, program) => /\bPerformance(?:Observer|ObserverEntryList|ResourceTiming)\b/.test(program)
|
|
@@ -10481,6 +10495,10 @@ const primitives = {
|
|
|
10481
10495
|
c: "js_util_type_tag",
|
|
10482
10496
|
length: 1
|
|
10483
10497
|
},
|
|
10498
|
+
eventTargetListeners: {
|
|
10499
|
+
c: "js_event_target_listeners",
|
|
10500
|
+
length: 2
|
|
10501
|
+
},
|
|
10484
10502
|
cryptoHashNew: {
|
|
10485
10503
|
c: "js_crypto_hash_new",
|
|
10486
10504
|
length: 2
|
|
@@ -10735,7 +10753,7 @@ const primitives = {
|
|
|
10735
10753
|
},
|
|
10736
10754
|
httpParsers: {
|
|
10737
10755
|
c: "js_host_http_parsers",
|
|
10738
|
-
length:
|
|
10756
|
+
length: 6
|
|
10739
10757
|
},
|
|
10740
10758
|
httpAttach: {
|
|
10741
10759
|
c: "js_host_http_attach",
|
|
@@ -10743,6 +10761,22 @@ const primitives = {
|
|
|
10743
10761
|
},
|
|
10744
10762
|
httpDetach: {
|
|
10745
10763
|
c: "js_host_http_detach",
|
|
10764
|
+
length: 2
|
|
10765
|
+
},
|
|
10766
|
+
httpBusy: {
|
|
10767
|
+
c: "js_host_http_busy",
|
|
10768
|
+
length: 1
|
|
10769
|
+
},
|
|
10770
|
+
httpGuard: {
|
|
10771
|
+
c: "js_host_http_guard",
|
|
10772
|
+
length: 2
|
|
10773
|
+
},
|
|
10774
|
+
httpPending: {
|
|
10775
|
+
c: "js_host_http_pending",
|
|
10776
|
+
length: 1
|
|
10777
|
+
},
|
|
10778
|
+
httpWatchDrain: {
|
|
10779
|
+
c: "js_host_http_watch_drain",
|
|
10746
10780
|
length: 1
|
|
10747
10781
|
},
|
|
10748
10782
|
httpExpired: {
|
|
@@ -10751,7 +10785,7 @@ const primitives = {
|
|
|
10751
10785
|
},
|
|
10752
10786
|
httpWrite: {
|
|
10753
10787
|
c: "js_host_http_write",
|
|
10754
|
-
length:
|
|
10788
|
+
length: 3
|
|
10755
10789
|
},
|
|
10756
10790
|
httpFlush: {
|
|
10757
10791
|
c: "js_host_http_flush",
|
|
@@ -10837,6 +10871,10 @@ const primitives = {
|
|
|
10837
10871
|
c: "js_host_net_address",
|
|
10838
10872
|
length: 2
|
|
10839
10873
|
},
|
|
10874
|
+
netFd: {
|
|
10875
|
+
c: "js_host_net_fd",
|
|
10876
|
+
length: 1
|
|
10877
|
+
},
|
|
10840
10878
|
netNoDelay: {
|
|
10841
10879
|
c: "js_host_net_no_delay",
|
|
10842
10880
|
length: 2
|
|
@@ -10845,6 +10883,10 @@ const primitives = {
|
|
|
10845
10883
|
c: "js_host_net_keep_alive",
|
|
10846
10884
|
length: 3
|
|
10847
10885
|
},
|
|
10886
|
+
netTypeOfService: {
|
|
10887
|
+
c: "js_host_net_type_of_service",
|
|
10888
|
+
length: 2
|
|
10889
|
+
},
|
|
10848
10890
|
ttyOpen: {
|
|
10849
10891
|
c: "js_host_tty_open",
|
|
10850
10892
|
length: 2
|
|
@@ -12721,7 +12763,9 @@ function lineCount(text) {
|
|
|
12721
12763
|
const VERSION = "0.0.7";
|
|
12722
12764
|
/** A program's C splits into files of about this many IR instructions. */
|
|
12723
12765
|
const PART_SIZE = 2e4;
|
|
12724
|
-
|
|
12766
|
+
/** A TypeScript file, by its extension: the bundler strips its types. */
|
|
12767
|
+
const TYPESCRIPT = /\.(?:[cm]?ts|tsx)$/;
|
|
12768
|
+
const USAGE = `usage: visaljs build [entry.js | entry.ts | project directory] [options]
|
|
12725
12769
|
visaljs licenses print the licenses to ship with a binary you distribute
|
|
12726
12770
|
|
|
12727
12771
|
A project (the current directory when none is given) builds its framework's production server: a
|
|
@@ -12730,6 +12774,9 @@ vinext app with its own \`vite build\` first, then the server is compiled with t
|
|
|
12730
12774
|
project builds the file its package.json starts: its one "bin" command, the file "scripts.start"
|
|
12731
12775
|
runs with node, or "main"; else index.js. The binary is named after the command or the project.
|
|
12732
12776
|
|
|
12777
|
+
TypeScript (.ts, .mts, .cts, .tsx) is compiled too: its types are stripped, not checked (run tsc
|
|
12778
|
+
for that), with the nearest tsconfig.json's settings (paths, decorators).
|
|
12779
|
+
|
|
12733
12780
|
options:
|
|
12734
12781
|
-o <file> output binary
|
|
12735
12782
|
--emit-c <dir> stop after C emission
|
|
@@ -12860,6 +12907,10 @@ async function build(entry, options, io) {
|
|
|
12860
12907
|
io.stderr(`visaljs: cannot read ${entry}: ${e.message}\n`);
|
|
12861
12908
|
return 1;
|
|
12862
12909
|
}
|
|
12910
|
+
if ((options.script || options["no-bundle"]) && TYPESCRIPT.test(entry)) {
|
|
12911
|
+
io.stderr(`visaljs: ${entry} is TypeScript: it's compiled through the bundler, without ${options.script ? "--script" : "--no-bundle"}\n`);
|
|
12912
|
+
return 1;
|
|
12913
|
+
}
|
|
12863
12914
|
const dump = options["dump-ast"] === true || options["dump-ir"] === true;
|
|
12864
12915
|
const style = options.quiet || dump ? void 0 : io.report;
|
|
12865
12916
|
const report = new Report(io.stderr, style);
|
|
@@ -12959,7 +13010,7 @@ async function build(entry, options, io) {
|
|
|
12959
13010
|
report.finish("📂", (time) => `Wrote ${files.length > 1 ? `${files.length} files to ${displayPath(resolve(options["emit-c"]))}` : displayPath(resolve(options["emit-c"], "program.c"))} in ${time}`);
|
|
12960
13011
|
return 0;
|
|
12961
13012
|
}
|
|
12962
|
-
let output = options.output ?? (framework ? join(framework.root, basename(framework.root)) : project ? join(project.root, project.name) : basename(entry).replace(/\.[cm]?
|
|
13013
|
+
let output = options.output ?? (framework ? join(framework.root, basename(framework.root)) : project ? join(project.root, project.name) : basename(entry).replace(/\.(?:[cm]?[jt]s|[jt]sx)$/, ""));
|
|
12963
13014
|
if (process.platform === "win32" && !extname(output)) output += ".exe";
|
|
12964
13015
|
if (resolve(output) === resolve(entry) || statSync(output, { throwIfNoEntry: false })?.isDirectory()) {
|
|
12965
13016
|
io.stderr(`visaljs: the binary would be ${displayPath(resolve(output))}, which is ${resolve(output) === resolve(entry) ? "the entry file" : "a directory"}: give another with -o\n`);
|
|
@@ -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 };
|
package/node/prelude/dns.js
CHANGED
|
@@ -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) {
|
package/node/prelude/events.js
CHANGED
|
@@ -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
|
-
/**
|
|
359
|
-
export function listenerCount(
|
|
360
|
-
|
|
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;
|