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.
- package/README.md +6 -3
- package/THIRD_PARTY_LICENSES +1 -1
- package/cli.js +2782 -770
- package/node/include/js_node.h +1 -0
- 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 +693 -285
- 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_chars.ts +22 -0
- 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 +212 -61
- 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/node/src/host_sys.c +9 -0
- 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_buffer.h +185 -0
- package/runtime/include/js_builtins.h +53 -0
- package/runtime/include/js_exception.h +3 -0
- package/runtime/include/js_function.h +1 -1
- package/runtime/include/js_object.h +21 -3
- package/runtime/include/js_ops.h +27 -0
- package/runtime/include/js_runtime.h +1 -0
- package/runtime/include/js_web.h +3 -3
- package/runtime/include/jscontext.h +15 -0
- package/runtime/src/atoms.c +37 -3
- package/runtime/src/builtins.c +17 -4
- package/runtime/src/events.c +19 -0
- package/runtime/src/function.c +37 -10
- package/runtime/src/gc.c +7 -5
- package/runtime/src/internal.h +4 -4
- package/runtime/src/iterator.c +5 -1
- package/runtime/src/object.c +42 -6
- package/runtime/src/regexp.c +569 -12
- package/runtime/src/shape.c +68 -1
- package/runtime/src/typedarray.c +23 -0
- package/runtime/src/weak.c +95 -24
package/node/prelude/module.js
CHANGED
|
@@ -53,6 +53,9 @@ for (const ext of [".js", ".json", ".node"]) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/* Module._cache: every require's cache, as Node's */
|
|
57
|
+
const cache = { __proto__: null };
|
|
58
|
+
|
|
56
59
|
export function createRequire(filename) {
|
|
57
60
|
if (typeof filename !== "string" && !(typeof URL === "function" && filename instanceof URL)) {
|
|
58
61
|
throw withCode(new TypeError("The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received " +
|
|
@@ -62,38 +65,55 @@ export function createRequire(filename) {
|
|
|
62
65
|
const require = (id) => {
|
|
63
66
|
const load = globalThis[REQUIRE_TABLE]?.get(id);
|
|
64
67
|
if (load !== undefined) return load();
|
|
65
|
-
if (typeof id === "string" && id.endsWith(".json") &&
|
|
68
|
+
if (typeof id === "string" && id.endsWith(".json") && (isRelative(id) || isAbsolute(id))) return requireJSON(require.cache, id, base);
|
|
66
69
|
throw notFound(id);
|
|
67
70
|
};
|
|
68
71
|
require.resolve = (id) => {
|
|
69
72
|
throw notFound(id);
|
|
70
73
|
};
|
|
71
74
|
require.resolve.paths = () => null;
|
|
72
|
-
require.cache =
|
|
75
|
+
require.cache = cache;
|
|
73
76
|
require.main = undefined;
|
|
74
77
|
require.extensions = extensions;
|
|
75
78
|
return require;
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
/* paths as node:path's default (which this module can't import) has them: on Windows, a root of
|
|
82
|
+
* a drive (C:), a share (\\server\share) or none, and either separator */
|
|
83
|
+
const onWindows = () => globalThis.process.platform === "win32";
|
|
84
|
+
const isAbsolute = (path) => path.startsWith("/") || (onWindows() && /^(?:\\|[A-Za-z]:[\\/])/.test(path));
|
|
85
|
+
const isRelative = (path) => /^\.\.?\//.test(path) || (onWindows() && /^\.\.?\\/.test(path));
|
|
86
|
+
const endsWithSep = (path) => path.endsWith("/") || (onWindows() && path.endsWith("\\"));
|
|
87
|
+
|
|
78
88
|
function pathOf(filename) {
|
|
79
89
|
const s = typeof filename === "string" ? filename : filename.href;
|
|
80
|
-
|
|
90
|
+
if (!s.startsWith("file:")) return s;
|
|
91
|
+
const url = new URL(s);
|
|
92
|
+
const path = decodeURIComponent(url.pathname);
|
|
93
|
+
if (!onWindows()) return path;
|
|
94
|
+
const local = path.replace(/^\/([A-Za-z]:)/, "$1").replaceAll("/", "\\");
|
|
95
|
+
return url.hostname ? `\\\\${url.hostname}${local}` : local;
|
|
81
96
|
}
|
|
82
97
|
|
|
83
|
-
/* an absolute path without its . and .. segments (node:path's normalize
|
|
98
|
+
/* an absolute path without its . and .. segments (node:path's normalize); a root's parent is itself.
|
|
99
|
+
* On Windows, \path is on the working directory's drive. */
|
|
100
|
+
const windowsRoot = (path) => /^(?:[A-Za-z]:|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.exec(path)?.[0];
|
|
84
101
|
function normalize(path) {
|
|
102
|
+
const windows = onWindows();
|
|
103
|
+
const given = windows ? windowsRoot(path) ?? "" : "";
|
|
104
|
+
const root = windows && !given ? windowsRoot(globalThis.process.cwd()) ?? "" : given;
|
|
85
105
|
const out = [];
|
|
86
|
-
for (const part of path.split("/")) {
|
|
106
|
+
for (const part of path.slice(given.length).split(windows ? /[\\/]/ : "/")) {
|
|
87
107
|
if (part === "..") out.pop();
|
|
88
108
|
else if (part !== "." && part !== "") out.push(part);
|
|
89
109
|
}
|
|
90
|
-
return "/" + out.join("/");
|
|
110
|
+
return windows ? `${root.replaceAll("/", "\\")}\\${out.join("\\")}` : "/" + out.join("/");
|
|
91
111
|
}
|
|
92
112
|
|
|
93
113
|
/** A JSON file, by a path absolute or relative to the requiring file's directory: parsed once,
|
|
94
114
|
* then from require.cache, as Node's loader does. */
|
|
95
115
|
function requireJSON(cache, id, from) {
|
|
96
|
-
const path = normalize(id
|
|
116
|
+
const path = normalize(isAbsolute(id) ? id : `${from}/../${id}`);
|
|
97
117
|
if (path in cache) return cache[path].exports;
|
|
98
118
|
const text = fsReadFile(path, false);
|
|
99
119
|
if (typeof text !== "string") throw notFound(id);
|
|
@@ -182,6 +202,9 @@ const isDir = (path) => {
|
|
|
182
202
|
};
|
|
183
203
|
const exists = (path) => typeof fsStat(path, true) !== "number";
|
|
184
204
|
const dirOf = (path) => path.slice(0, Math.max(path.lastIndexOf("/"), 0)) || "/";
|
|
205
|
+
const parentOf = (path) => normalize(`${path}/..`);
|
|
206
|
+
/* on Windows, Node gives the closest package.json as a namespaced path: \\?\C:\… or \\?\UNC\server\… */
|
|
207
|
+
const namespaced = (path) => !onWindows() ? path : path.startsWith("\\\\") ? `\\\\?\\UNC\\${path.slice(2)}` : `\\\\?\\${path}`;
|
|
185
208
|
|
|
186
209
|
/** findPackageJSON(specifier[, base]): the package.json closest to what the specifier resolves to
|
|
187
210
|
* (a path or file: URL, relative to base; or a package, from base's node_modules), or undefined. */
|
|
@@ -192,26 +215,27 @@ export function findPackageJSON(specifier, base) {
|
|
|
192
215
|
"Invalid relative URL or base scheme is not hierarchical."), "ERR_UNSUPPORTED_RESOLVE_REQUEST");
|
|
193
216
|
const basePath = baseText === undefined ? undefined : baseText.startsWith("file:") ? pathOf(baseText) : baseText;
|
|
194
217
|
let target;
|
|
195
|
-
if (spec.startsWith("file:")) target = pathOf(spec);
|
|
218
|
+
if (spec.startsWith("file:")) target = normalize(pathOf(spec));
|
|
219
|
+
/* a specifier is a URL: C:\… has the scheme c: */
|
|
220
|
+
else if (onWindows() && isAbsolute(spec)) throw withCode(new TypeError("The URL must be of scheme file"), "ERR_INVALID_URL_SCHEME");
|
|
196
221
|
else if (spec.startsWith("/")) target = normalize(spec);
|
|
197
222
|
else if (spec.startsWith("./") || spec.startsWith("../")) {
|
|
198
223
|
if (basePath === undefined) throw unresolved();
|
|
199
|
-
|
|
200
|
-
target = normalize(`${from}/${spec}`);
|
|
224
|
+
target = normalize(endsWithSep(baseText) ? `${basePath}/${spec}` : `${basePath}/../${spec}`);
|
|
201
225
|
} else {
|
|
202
226
|
/* a package: its directory under the closest node_modules that has it */
|
|
203
227
|
if (basePath === undefined) throw unresolved();
|
|
204
228
|
const name = spec.startsWith("@") ? spec.split("/").slice(0, 2).join("/") : spec.split("/")[0];
|
|
205
|
-
for (let dir = baseText
|
|
206
|
-
const candidate = `${dir
|
|
229
|
+
for (let dir = endsWithSep(baseText) ? normalize(basePath) : parentOf(basePath); ; dir = parentOf(dir)) {
|
|
230
|
+
const candidate = normalize(`${dir}/node_modules/${name}/package.json`);
|
|
207
231
|
if (exists(candidate)) return candidate;
|
|
208
|
-
if (dir ===
|
|
232
|
+
if (parentOf(dir) === dir) throw withCode(new Error(`Cannot find package '${name}' imported from ${basePath}`), "ERR_MODULE_NOT_FOUND");
|
|
209
233
|
}
|
|
210
234
|
}
|
|
211
|
-
for (let dir = isDir(target) ? target :
|
|
212
|
-
const candidate = `${dir
|
|
213
|
-
if (exists(candidate)) return candidate;
|
|
214
|
-
if (dir ===
|
|
235
|
+
for (let dir = isDir(target) ? target : parentOf(target); ; dir = parentOf(dir)) {
|
|
236
|
+
const candidate = normalize(`${dir}/package.json`);
|
|
237
|
+
if (exists(candidate)) return namespaced(candidate);
|
|
238
|
+
if (parentOf(dir) === dir) return undefined;
|
|
215
239
|
}
|
|
216
240
|
}
|
|
217
241
|
|
|
@@ -239,7 +263,7 @@ const ModuleWithHelpers = /* @__PURE__ */ Object.assign(Module, {
|
|
|
239
263
|
enableCompileCache, getCompileCacheDir, flushCompileCache, getSourceMapsSupport, setSourceMapsSupport, findSourceMap, SourceMap,
|
|
240
264
|
findPackageJSON, globalPaths, Module, wrapper,
|
|
241
265
|
wrap: (script) => wrapper[0] + script + wrapper[1],
|
|
242
|
-
_cache:
|
|
266
|
+
_cache: cache,
|
|
243
267
|
_extensions: extensions,
|
|
244
268
|
/* a built-in resolves to itself; a compiled program has no files to resolve to */
|
|
245
269
|
_resolveFilename(request) {
|