@scriptc/cli-darwin-x64 0.2.2 → 0.2.3
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/dist/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +99 -27
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url_params.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util_compare.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_util_style.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/runtime-pack.json +351 -225
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +5 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +26 -0
- package/dist/lib/runtime-sources/src/scr_async.c +44 -0
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +305 -48
- package/dist/lib/runtime-sources/src/scr_events.c +9 -0
- package/dist/lib/runtime-sources/src/scr_exception.c +1 -0
- package/dist/lib/runtime-sources/src/scr_file_handle.c +11 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1001 -417
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -7
- package/dist/lib/runtime-sources/src/scr_json.c +135 -2
- package/dist/lib/runtime-sources/src/scr_lib.c +379 -12
- package/dist/lib/runtime-sources/src/scr_map.c +8 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +78 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +65 -0
- package/dist/lib/runtime-sources/src/scr_runtime.h +69 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_system_errors.h +573 -0
- package/dist/lib/runtime-sources/src/scr_url.c +515 -59
- package/dist/lib/runtime-sources/src/scr_url_internal.h +6 -0
- package/dist/lib/runtime-sources/src/scr_url_params.c +10 -0
- package/dist/lib/runtime-sources/src/scr_util_compare.c +222 -0
- package/dist/lib/runtime-sources/src/scr_util_style.c +337 -0
- package/dist/lib/runtime-sources/src/scr_web.c +720 -238
- package/package.json +1 -1
|
@@ -135,6 +135,11 @@ static const ScrIslandModule *isl_mods = NULL;
|
|
|
135
135
|
static size_t isl_nmods = 0;
|
|
136
136
|
static const ScrIslandEdge *isl_edges = NULL;
|
|
137
137
|
static size_t isl_nedges = 0;
|
|
138
|
+
static const char *isl_main_module = NULL;
|
|
139
|
+
|
|
140
|
+
void scr_island_entry_module(const char *filename) {
|
|
141
|
+
isl_main_module = filename;
|
|
142
|
+
}
|
|
138
143
|
|
|
139
144
|
/* Compressed embedded module text (src_raw/esm_raw > 0: raw DEFLATE, the
|
|
140
145
|
* emitter's size lever) inflates LAZILY at a module's first load and the
|
|
@@ -222,6 +227,7 @@ static const char *isl_edge_find(const char *from, const char *spec, int want) {
|
|
|
222
227
|
|
|
223
228
|
/* Defined with the module system below; called from isl_init. */
|
|
224
229
|
static void isl_install_module_loader(void);
|
|
230
|
+
static void isl_init_type_brands(void);
|
|
225
231
|
/* Defined with the host-function machinery below; called from isl_init. */
|
|
226
232
|
static void isl_register_hostfn_class(void);
|
|
227
233
|
/* Defined with the island → static promise bridge below; called from the
|
|
@@ -536,6 +542,7 @@ static void isl_init(void) {
|
|
|
536
542
|
fprintf(stderr, "scriptc: island engine context allocation failed\n");
|
|
537
543
|
abort();
|
|
538
544
|
}
|
|
545
|
+
isl_init_type_brands();
|
|
539
546
|
JSValue arr = JS_Eval(isl_ctx, isl_prelude, sizeof isl_prelude - 1,
|
|
540
547
|
"<scr-prelude>", JS_EVAL_TYPE_GLOBAL);
|
|
541
548
|
if (JS_IsException(arr)) {
|
|
@@ -1154,6 +1161,103 @@ static bool isl_dynjs_strict_eq(ScrJsval *a, ScrJsval *b) {
|
|
|
1154
1161
|
static bool isl_dynjs_is_array(ScrJsval *cell) { return JS_IsArray(cell->v); }
|
|
1155
1162
|
static bool isl_dynjs_is_error(ScrJsval *cell) { return JS_IsError(cell->v); }
|
|
1156
1163
|
|
|
1164
|
+
/* Cache engine class IDs from pristine builtins before user code runs.
|
|
1165
|
+
* Class comparisons never inspect public properties or execute traps. */
|
|
1166
|
+
static SCR_TL JSClassID isl_module_namespace_class;
|
|
1167
|
+
static const char *const isl_brand_names[] = { "SharedArrayBuffer", "GeneratorFunction", "AsyncGeneratorFunction", "Generator", "AsyncGenerator",
|
|
1168
|
+
"Arguments", "Arguments", "Map Iterator", "Set Iterator", "Number", "String", "Boolean", "Symbol", "BigInt" };
|
|
1169
|
+
static SCR_TL JSClassID isl_brand_classes[sizeof isl_brand_names / sizeof isl_brand_names[0]];
|
|
1170
|
+
static void isl_init_type_brands(void) {
|
|
1171
|
+
static const char brand_source[] =
|
|
1172
|
+
"[new SharedArrayBuffer(0), function*(){}, async function*(){}, (function*(){})(), (async function*(){})(),"
|
|
1173
|
+
"(function(){'use strict';return arguments})(1), Function('a','return arguments')(1),"
|
|
1174
|
+
"new Map().entries(), new Set().values(), Object(0), Object(''), Object(false), Object(Symbol()), Object(0n)]";
|
|
1175
|
+
JSValue brands = JS_Eval(isl_ctx, brand_source, sizeof brand_source - 1, "<scr-type-brands>", JS_EVAL_TYPE_GLOBAL);
|
|
1176
|
+
if (JS_IsException(brands)) {
|
|
1177
|
+
fprintf(stderr, "scriptc: island type brands failed to initialize\n");
|
|
1178
|
+
abort();
|
|
1179
|
+
}
|
|
1180
|
+
for (size_t i = 0; i < sizeof isl_brand_classes / sizeof isl_brand_classes[0]; i++) {
|
|
1181
|
+
JSValue value = JS_GetPropertyUint32(isl_ctx, brands, (uint32_t)i);
|
|
1182
|
+
isl_brand_classes[i] = JS_GetClassID(value);
|
|
1183
|
+
JS_FreeValue(isl_ctx, value);
|
|
1184
|
+
}
|
|
1185
|
+
JS_FreeValue(isl_ctx, brands);
|
|
1186
|
+
static const char namespace_source[] = "export {};";
|
|
1187
|
+
JSValue module = JS_Eval(isl_ctx, namespace_source, sizeof namespace_source - 1,
|
|
1188
|
+
"<scr-type-brands>", JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
|
|
1189
|
+
JSValue evaluated = JS_IsException(module) ? JS_EXCEPTION : JS_EvalFunction(isl_ctx, JS_DupValue(isl_ctx, module));
|
|
1190
|
+
JSValue namespace = JS_IsException(evaluated) ? JS_EXCEPTION : JS_GetModuleNamespace(isl_ctx, JS_VALUE_GET_PTR(module));
|
|
1191
|
+
if (JS_IsException(namespace)) {
|
|
1192
|
+
fprintf(stderr, "scriptc: island type brands failed to initialize\n");
|
|
1193
|
+
abort();
|
|
1194
|
+
}
|
|
1195
|
+
isl_module_namespace_class = JS_GetClassID(namespace);
|
|
1196
|
+
JS_FreeValue(isl_ctx, namespace);
|
|
1197
|
+
JS_FreeValue(isl_ctx, evaluated);
|
|
1198
|
+
JS_FreeValue(isl_ctx, module);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
static bool isl_class_named(JSValueConst value, const char *name) {
|
|
1202
|
+
JSClassID id = JS_GetClassID(value);
|
|
1203
|
+
if (!id) return false;
|
|
1204
|
+
for (size_t i = 0; i < sizeof isl_brand_names / sizeof isl_brand_names[0]; i++)
|
|
1205
|
+
if (id == isl_brand_classes[i] && strcmp(isl_brand_names[i], name) == 0) return true;
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
static bool isl_type_probe(JSValueConst value, const char *probe, size_t len) {
|
|
1210
|
+
#define PROBE(name) (len == sizeof(name) - 1 && memcmp(probe, name, sizeof(name) - 1) == 0)
|
|
1211
|
+
int typed = JS_GetTypedArrayType(value);
|
|
1212
|
+
if (PROBE("isTypedArray")) return typed >= 0;
|
|
1213
|
+
if (PROBE("isArrayBufferView")) return typed >= 0 || JS_IsDataView(value);
|
|
1214
|
+
if (PROBE("isUint8Array")) return typed == JS_TYPED_ARRAY_UINT8;
|
|
1215
|
+
if (PROBE("isUint8ClampedArray")) return typed == JS_TYPED_ARRAY_UINT8C;
|
|
1216
|
+
if (PROBE("isUint16Array")) return typed == JS_TYPED_ARRAY_UINT16;
|
|
1217
|
+
if (PROBE("isUint32Array")) return typed == JS_TYPED_ARRAY_UINT32;
|
|
1218
|
+
if (PROBE("isInt8Array")) return typed == JS_TYPED_ARRAY_INT8;
|
|
1219
|
+
if (PROBE("isInt16Array")) return typed == JS_TYPED_ARRAY_INT16;
|
|
1220
|
+
if (PROBE("isInt32Array")) return typed == JS_TYPED_ARRAY_INT32;
|
|
1221
|
+
if (PROBE("isFloat16Array")) return typed == JS_TYPED_ARRAY_FLOAT16;
|
|
1222
|
+
if (PROBE("isFloat32Array")) return typed == JS_TYPED_ARRAY_FLOAT32;
|
|
1223
|
+
if (PROBE("isFloat64Array")) return typed == JS_TYPED_ARRAY_FLOAT64;
|
|
1224
|
+
if (PROBE("isBigInt64Array")) return typed == JS_TYPED_ARRAY_BIG_INT64;
|
|
1225
|
+
if (PROBE("isBigUint64Array")) return typed == JS_TYPED_ARRAY_BIG_UINT64;
|
|
1226
|
+
if (PROBE("isArrayBuffer")) return JS_IsArrayBuffer(value);
|
|
1227
|
+
if (PROBE("isDataView")) return JS_IsDataView(value);
|
|
1228
|
+
if (PROBE("isDate")) return JS_IsDate(value);
|
|
1229
|
+
if (PROBE("isMap")) return JS_IsMap(value);
|
|
1230
|
+
if (PROBE("isSet")) return JS_IsSet(value);
|
|
1231
|
+
if (PROBE("isWeakMap")) return JS_IsWeakMap(value);
|
|
1232
|
+
if (PROBE("isWeakSet")) return JS_IsWeakSet(value);
|
|
1233
|
+
if (PROBE("isRegExp")) return JS_IsRegExp(value);
|
|
1234
|
+
if (PROBE("isPromise")) return JS_IsPromise(value);
|
|
1235
|
+
if (PROBE("isProxy")) return JS_IsProxy(value);
|
|
1236
|
+
if (PROBE("isNativeError")) return JS_IsError(value);
|
|
1237
|
+
if (PROBE("isAnyArrayBuffer")) return JS_IsArrayBuffer(value) || isl_class_named(value, "SharedArrayBuffer");
|
|
1238
|
+
if (PROBE("isSharedArrayBuffer")) return isl_class_named(value, "SharedArrayBuffer");
|
|
1239
|
+
if (PROBE("isAsyncFunction")) return JS_IsAsyncFunction(value) || isl_class_named(value, "AsyncGeneratorFunction");
|
|
1240
|
+
if (PROBE("isGeneratorFunction")) return isl_class_named(value, "GeneratorFunction") || isl_class_named(value, "AsyncGeneratorFunction");
|
|
1241
|
+
if (PROBE("isGeneratorObject")) return isl_class_named(value, "Generator") || isl_class_named(value, "AsyncGenerator");
|
|
1242
|
+
if (PROBE("isArgumentsObject")) return isl_class_named(value, "Arguments");
|
|
1243
|
+
if (PROBE("isMapIterator")) return isl_class_named(value, "Map Iterator");
|
|
1244
|
+
if (PROBE("isSetIterator")) return isl_class_named(value, "Set Iterator");
|
|
1245
|
+
if (PROBE("isModuleNamespaceObject")) return isl_module_namespace_class && JS_GetClassID(value) == isl_module_namespace_class;
|
|
1246
|
+
if (PROBE("isNumberObject")) return isl_class_named(value, "Number");
|
|
1247
|
+
if (PROBE("isStringObject")) return isl_class_named(value, "String");
|
|
1248
|
+
if (PROBE("isBooleanObject")) return isl_class_named(value, "Boolean");
|
|
1249
|
+
if (PROBE("isSymbolObject")) return isl_class_named(value, "Symbol");
|
|
1250
|
+
if (PROBE("isBigIntObject")) return isl_class_named(value, "BigInt");
|
|
1251
|
+
if (PROBE("isBoxedPrimitive")) return isl_class_named(value, "Number") || isl_class_named(value, "String") ||
|
|
1252
|
+
isl_class_named(value, "Boolean") || isl_class_named(value, "Symbol") || isl_class_named(value, "BigInt");
|
|
1253
|
+
#undef PROBE
|
|
1254
|
+
return false;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
static bool isl_dynjs_type_probe(ScrJsval *cell, const ScrStr *probe) {
|
|
1258
|
+
return isl_type_probe(cell->v, probe->data, probe->len);
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1157
1261
|
static const ScrDynJsvalOps isl_dynjs_ops;
|
|
1158
1262
|
|
|
1159
1263
|
/* The jsval→dyn wrap over a RAW engine value (BORROWED) — the scalar
|
|
@@ -1442,6 +1546,7 @@ static const ScrDynJsvalOps isl_dynjs_ops = {
|
|
|
1442
1546
|
isl_dynjs_iter_drain,
|
|
1443
1547
|
isl_dynjs_iterator,
|
|
1444
1548
|
isl_dynjs_iter_n,
|
|
1549
|
+
isl_dynjs_type_probe,
|
|
1445
1550
|
};
|
|
1446
1551
|
|
|
1447
1552
|
ScrDyn *scr_dyn_from_jsval(ScrJsval *cell) {
|
|
@@ -2552,32 +2657,49 @@ static JSModuleDef *isl_module_load(JSContext *ctx, const char *name, void *opaq
|
|
|
2552
2657
|
free(heap);
|
|
2553
2658
|
if (JS_IsException(v)) return NULL;
|
|
2554
2659
|
JSModuleDef *def = JS_VALUE_GET_PTR(v);
|
|
2555
|
-
/*
|
|
2556
|
-
* are
|
|
2557
|
-
*
|
|
2660
|
+
/* File-backed metadata uses the same converters as node:url. Embedded
|
|
2661
|
+
* keys are resolved paths, including spaces, percent signs and Unicode;
|
|
2662
|
+
* concatenating file:// would reinterpret those as URL syntax. */
|
|
2558
2663
|
JSValue meta = JS_GetImportMeta(ctx, def);
|
|
2559
2664
|
if (!JS_IsException(meta)) {
|
|
2560
2665
|
JSValue url;
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2666
|
+
bool file_backed = name[0] == '/' ||
|
|
2667
|
+
(name[0] && name[1] == ':' && (name[2] == '/' || name[2] == '\\')) ||
|
|
2668
|
+
(name[0] == '\\' && name[1] == '\\');
|
|
2669
|
+
if (file_backed) {
|
|
2670
|
+
ScrStr *path = scr_str_new(name, strlen(name));
|
|
2671
|
+
ScrUrl *parsed = scr_url_from_path(path);
|
|
2672
|
+
ScrStr *href = parsed ? scr_url_href(parsed) : NULL;
|
|
2673
|
+
ScrStr *dir = scr_path_dirname(path);
|
|
2674
|
+
if (!href || !dir) {
|
|
2675
|
+
if (href) scr_str_release(href);
|
|
2676
|
+
if (dir) scr_str_release(dir);
|
|
2677
|
+
if (parsed) scr_url_release(parsed);
|
|
2678
|
+
scr_str_release(path);
|
|
2679
|
+
isl_throw_pending(ctx);
|
|
2680
|
+
JS_FreeValue(ctx, meta);
|
|
2681
|
+
JS_FreeValue(ctx, v);
|
|
2682
|
+
return NULL;
|
|
2570
2683
|
}
|
|
2684
|
+
JS_SetPropertyStr(ctx, meta, "dirname", JS_NewStringLen(ctx, dir->data, dir->len));
|
|
2685
|
+
JS_SetPropertyStr(ctx, meta, "filename", JS_NewStringLen(ctx, path->data, path->len));
|
|
2686
|
+
url = JS_NewStringLen(ctx, href->data, href->len);
|
|
2687
|
+
scr_str_release(href);
|
|
2688
|
+
scr_str_release(dir);
|
|
2689
|
+
scr_url_release(parsed);
|
|
2690
|
+
scr_str_release(path);
|
|
2571
2691
|
} else {
|
|
2572
2692
|
url = JS_NewString(ctx, name);
|
|
2573
2693
|
}
|
|
2574
|
-
JS_SetPropertyStr(ctx, meta, "
|
|
2694
|
+
JS_SetPropertyStr(ctx, meta, "main", JS_NewBool(ctx, isl_main_module && strcmp(isl_main_module, name) == 0));
|
|
2575
2695
|
JSValue key = JS_NewString(ctx, name);
|
|
2576
2696
|
JSValueConst data[1] = {key};
|
|
2577
2697
|
JSValue resolve_fn = JS_NewCFunctionData(ctx, isl_import_meta_resolve, 1,
|
|
2578
2698
|
0, 1, data);
|
|
2579
2699
|
JS_FreeValue(ctx, key); /* resolve_fn's func_data retains it */
|
|
2700
|
+
JS_DefinePropertyValueStr(ctx, resolve_fn, "name", JS_NewString(ctx, "resolve"), JS_PROP_CONFIGURABLE);
|
|
2580
2701
|
JS_SetPropertyStr(ctx, meta, "resolve", resolve_fn); /* consumed */
|
|
2702
|
+
JS_SetPropertyStr(ctx, meta, "url", url); /* consumed */
|
|
2581
2703
|
JS_FreeValue(ctx, meta);
|
|
2582
2704
|
}
|
|
2583
2705
|
JS_FreeValue(ctx, v);
|
|
@@ -2903,6 +3025,29 @@ static JSValue isl_host_env_delete(JSContext *ctx, JSValueConst this_val, int ar
|
|
|
2903
3025
|
return JS_TRUE;
|
|
2904
3026
|
}
|
|
2905
3027
|
|
|
3028
|
+
static JSValue isl_host_system_error_entries(JSContext *ctx, JSValueConst this_val, int argc,
|
|
3029
|
+
JSValueConst *argv) {
|
|
3030
|
+
(void)ctx; (void)this_val; (void)argc; (void)argv;
|
|
3031
|
+
ScrDyn *entries = scr_util_system_error_entries();
|
|
3032
|
+
JSValue result = isl_from_dyn(entries);
|
|
3033
|
+
scr_dyn_release(entries);
|
|
3034
|
+
return result;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
static JSValue isl_host_system_error_info(JSContext *ctx, JSValueConst this_val, int argc,
|
|
3038
|
+
JSValueConst *argv) {
|
|
3039
|
+
(void)this_val;
|
|
3040
|
+
if (argc != 2) return JS_ThrowTypeError(ctx, "invalid system error bridge arity");
|
|
3041
|
+
double number;
|
|
3042
|
+
if (JS_ToFloat64(ctx, &number, argv[0]) < 0) return JS_EXCEPTION;
|
|
3043
|
+
ScrDyn value = {0}; value.kind = SCR_DYN_NUM; value.v.num = number;
|
|
3044
|
+
ScrStr *text = JS_ToBool(ctx, argv[1]) ? scr_util_system_error_message(&value) : scr_util_system_error_name(&value);
|
|
3045
|
+
if (!text) return isl_throw_pending(ctx);
|
|
3046
|
+
JSValue result = JS_NewStringLen(ctx, text->data, text->len);
|
|
3047
|
+
scr_str_release(text);
|
|
3048
|
+
return result;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
2906
3051
|
static JSValue isl_host_parse_env(JSContext *ctx, JSValueConst this_val, int argc,
|
|
2907
3052
|
JSValueConst *argv) {
|
|
2908
3053
|
(void)this_val; (void)argc;
|
|
@@ -3311,41 +3456,44 @@ static JSValue isl_host_zlib(JSContext *ctx, JSValueConst this_val, int argc,
|
|
|
3311
3456
|
static JSValue isl_host_url_to_path(JSContext *ctx, JSValueConst this_val, int argc,
|
|
3312
3457
|
JSValueConst *argv) {
|
|
3313
3458
|
(void)this_val;
|
|
3314
|
-
(
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3459
|
+
ScrDyn *input = isl_dyn_from_value(argc ? argv[0] : JS_UNDEFINED);
|
|
3460
|
+
if (!input) return JS_EXCEPTION;
|
|
3461
|
+
ScrDyn *options = isl_dyn_from_value(argc > 1 ? argv[1] : JS_UNDEFINED);
|
|
3462
|
+
ScrStr *path = scr_url_checked_to_path_options(input, options);
|
|
3463
|
+
scr_dyn_release(input); scr_dyn_release(options);
|
|
3464
|
+
if (!path) return isl_throw_pending(ctx);
|
|
3465
|
+
JSValue result = JS_NewStringLen(ctx, path->data, path->len);
|
|
3466
|
+
scr_str_release(path);
|
|
3467
|
+
return result;
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
static JSValue isl_host_url_to_path_buffer(JSContext *ctx, JSValueConst this_val, int argc,
|
|
3471
|
+
JSValueConst *argv) {
|
|
3472
|
+
(void)this_val;
|
|
3473
|
+
ScrDyn *input = isl_dyn_from_value(argc ? argv[0] : JS_UNDEFINED);
|
|
3474
|
+
if (!input) return JS_EXCEPTION;
|
|
3475
|
+
ScrDyn *options = isl_dyn_from_value(argc > 1 ? argv[1] : JS_UNDEFINED);
|
|
3476
|
+
ScrBytes *path = scr_url_checked_to_path_buffer(input, options);
|
|
3477
|
+
scr_dyn_release(input); scr_dyn_release(options);
|
|
3478
|
+
if (!path) return isl_throw_pending(ctx);
|
|
3479
|
+
JSValue result = JS_NewUint8ArrayCopy(ctx, path->data, path->len);
|
|
3480
|
+
scr_bytes_release(path);
|
|
3481
|
+
return result;
|
|
3329
3482
|
}
|
|
3330
3483
|
|
|
3331
3484
|
static JSValue isl_host_url_from_path(JSContext *ctx, JSValueConst this_val, int argc,
|
|
3332
3485
|
JSValueConst *argv) {
|
|
3333
3486
|
(void)this_val;
|
|
3334
|
-
(
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
scr_str_release(s);
|
|
3343
|
-
if (!u) return isl_throw_pending(ctx);
|
|
3344
|
-
ScrStr *href = scr_url_href(u);
|
|
3345
|
-
scr_url_release(u);
|
|
3346
|
-
JSValue out = JS_NewStringLen(ctx, href->data, href->len);
|
|
3487
|
+
ScrDyn *input = isl_dyn_from_value(argc ? argv[0] : JS_UNDEFINED);
|
|
3488
|
+
ScrDyn *options = isl_dyn_from_value(argc > 1 ? argv[1] : JS_UNDEFINED);
|
|
3489
|
+
ScrUrl *url = scr_url_checked_from_path(input, options);
|
|
3490
|
+
scr_dyn_release(input); scr_dyn_release(options);
|
|
3491
|
+
if (!url) return isl_throw_pending(ctx);
|
|
3492
|
+
ScrStr *href = scr_url_href(url);
|
|
3493
|
+
scr_url_release(url);
|
|
3494
|
+
JSValue result = JS_NewStringLen(ctx, href->data, href->len);
|
|
3347
3495
|
scr_str_release(href);
|
|
3348
|
-
return
|
|
3496
|
+
return result;
|
|
3349
3497
|
}
|
|
3350
3498
|
|
|
3351
3499
|
/* fs.constants (and the legacy `constants` module's fs half): the REAL
|
|
@@ -3686,6 +3834,18 @@ static JSValue isl_host_hostname(JSContext *ctx, JSValueConst this_val, int argc
|
|
|
3686
3834
|
return JS_NewString(ctx, buf);
|
|
3687
3835
|
}
|
|
3688
3836
|
|
|
3837
|
+
static JSValue isl_host_type_probe(JSContext *ctx, JSValueConst this_val,
|
|
3838
|
+
int argc, JSValueConst *argv) {
|
|
3839
|
+
(void)this_val;
|
|
3840
|
+
if (argc < 2) return JS_FALSE;
|
|
3841
|
+
size_t len;
|
|
3842
|
+
const char *probe = JS_ToCStringLen(ctx, &len, argv[0]);
|
|
3843
|
+
if (!probe) return JS_EXCEPTION;
|
|
3844
|
+
bool result = isl_type_probe(argv[1], probe, len);
|
|
3845
|
+
JS_FreeCString(ctx, probe);
|
|
3846
|
+
return JS_NewBool(ctx, result);
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3689
3849
|
/* The bootstrap: the CommonJS require shim over the embedded map, the
|
|
3690
3850
|
* builtin shims, and the real process bridge. Evaluated once (module boot);
|
|
3691
3851
|
* returns the CJS import helper the boundary below pins. Everything JS
|
|
@@ -3756,16 +3916,15 @@ static const char isl_modules_bootstrap[] =
|
|
|
3756
3916
|
" const cache = Object.create(null);\n"
|
|
3757
3917
|
" const builtins = Object.create(null);\n"
|
|
3758
3918
|
" const builtinModules = ['assert','assert/strict','async_hooks','buffer','child_process','cluster','console','constants','crypto','dgram','diagnostics_channel','dns','dns/promises','domain','events','fs','fs/promises','http','http2','https','inspector','inspector/promises','module','net','os','path','path/posix','path/win32','perf_hooks','process','punycode','querystring','readline','readline/promises','repl','stream','stream/consumers','stream/promises','stream/web','string_decoder','sys','timers','timers/promises','tls','trace_events','tty','url','util','util/types','v8','vm','wasi','worker_threads','zlib'];\n"
|
|
3759
|
-
/* Node's require stack
|
|
3760
|
-
*
|
|
3761
|
-
*
|
|
3762
|
-
* resolution reports the requiring module plus its parent chain.
|
|
3919
|
+
/* Node's require stack follows module records, including parents
|
|
3920
|
+
* whose evaluation failed or whose cache entry was deleted. A failing
|
|
3921
|
+
* resolution reports the requiring module plus its first-parent chain.
|
|
3763
3922
|
* Entry modules loaded from the compiled (ESM-like) world have no
|
|
3764
3923
|
* parent, exactly like Node's ESM→CJS boundary. */
|
|
3765
|
-
" const
|
|
3766
|
-
" const requireStackOf = (
|
|
3924
|
+
" const moduleParents = new WeakMap();\n"
|
|
3925
|
+
" const requireStackOf = (parent) => {\n"
|
|
3767
3926
|
" const stack = [];\n"
|
|
3768
|
-
" for (let m =
|
|
3927
|
+
" for (let m = parent; m; m = moduleParents.get(m)) stack.push(m.filename || m.id);\n"
|
|
3769
3928
|
" return stack;\n"
|
|
3770
3929
|
" };\n"
|
|
3771
3930
|
/* Node resolves core modules unconditionally, before node_modules
|
|
@@ -3778,12 +3937,13 @@ static const char isl_modules_bootstrap[] =
|
|
|
3778
3937
|
* properties. (Unshimmed BUILTINS reached by build-time-visible lazy
|
|
3779
3938
|
* edges resolve through the edge table to their node: keys and take
|
|
3780
3939
|
* requireKey's does-not-provide throw below instead.) */
|
|
3781
|
-
" const resolveFrom = (
|
|
3940
|
+
" const resolveFrom = (parent, spec) => {\n"
|
|
3941
|
+
" const from = parent.filename;\n"
|
|
3782
3942
|
" const to = host.resolve(from, spec);\n"
|
|
3783
3943
|
" if (to === undefined) {\n"
|
|
3784
3944
|
" const name = spec.startsWith('node:') ? spec.slice(5) : spec;\n"
|
|
3785
3945
|
" if (builtins[name]) return 'node:' + name;\n"
|
|
3786
|
-
" const stack = requireStackOf(
|
|
3946
|
+
" const stack = requireStackOf(parent);\n"
|
|
3787
3947
|
" const err = new Error(\"Cannot find module '\" + spec + \"'\" +\n"
|
|
3788
3948
|
" (stack.length ? '\\nRequire stack:\\n- ' + stack.join('\\n- ') : ''));\n"
|
|
3789
3949
|
" err.code = 'MODULE_NOT_FOUND';\n"
|
|
@@ -3813,12 +3973,52 @@ static const char isl_modules_bootstrap[] =
|
|
|
3813
3973
|
" }\n"
|
|
3814
3974
|
" return out;\n"
|
|
3815
3975
|
" };\n"
|
|
3816
|
-
"
|
|
3976
|
+
" // CommonJS module records retain identity across cache hits and circular loads.\n"
|
|
3977
|
+
" const modulePathsFrom = (directory) => {\n"
|
|
3978
|
+
" const paths = [];\n"
|
|
3979
|
+
" const path = builtins.path();\n"
|
|
3980
|
+
" for (let dir = directory;;) {\n"
|
|
3981
|
+
" if (path.basename(dir) !== 'node_modules') paths.push(path.join(dir, 'node_modules'));\n"
|
|
3982
|
+
" const parent = path.dirname(dir);\n"
|
|
3983
|
+
" if (parent === dir) break;\n"
|
|
3984
|
+
" dir = parent;\n"
|
|
3985
|
+
" }\n"
|
|
3986
|
+
" return paths;\n"
|
|
3987
|
+
" };\n"
|
|
3988
|
+
" const updateChildren = (parent, child) => {\n"
|
|
3989
|
+
" if (parent && parent.children && !parent.children.includes(child)) parent.children.push(child);\n"
|
|
3990
|
+
" };\n"
|
|
3991
|
+
" function Module(id = '', parent) {\n"
|
|
3992
|
+
" this.id = id;\n"
|
|
3993
|
+
" this.path = builtins.path().dirname(id);\n"
|
|
3994
|
+
" this.exports = {};\n"
|
|
3995
|
+
" moduleParents.set(this, parent);\n"
|
|
3996
|
+
" updateChildren(parent, this);\n"
|
|
3997
|
+
" this.filename = null;\n"
|
|
3998
|
+
" this.loaded = false;\n"
|
|
3999
|
+
" this.children = [];\n"
|
|
4000
|
+
" }\n"
|
|
4001
|
+
" Object.defineProperty(Module.prototype, 'parent', {\n"
|
|
4002
|
+
" get() { return moduleParents.get(this); },\n"
|
|
4003
|
+
" set(parent) { moduleParents.set(this, parent); },\n"
|
|
4004
|
+
" });\n"
|
|
4005
|
+
" Object.defineProperty(Module.prototype, 'isPreloading', { get() { return false; } });\n"
|
|
4006
|
+
" Module.prototype.require = function(id) {\n"
|
|
4007
|
+
" if (typeof id !== 'string') envArgumentError('id', 'of type string', id);\n"
|
|
4008
|
+
" if (id.length === 0) {\n"
|
|
4009
|
+
" const error = new TypeError(\"The argument 'id' must be a non-empty string. Received ''\");\n"
|
|
4010
|
+
" error.code = 'ERR_INVALID_ARG_VALUE';\n"
|
|
4011
|
+
" throw error;\n"
|
|
4012
|
+
" }\n"
|
|
4013
|
+
" return requireKey(resolveFrom(this, id), this);\n"
|
|
4014
|
+
" };\n"
|
|
4015
|
+
" const decorateRequire = (req, parent) => {\n"
|
|
4016
|
+
" const from = parent.filename;\n"
|
|
3817
4017
|
" const resolve = (spec) => {\n"
|
|
3818
4018
|
" if (typeof spec !== 'string') return requirePathsFrom(from, spec);\n"
|
|
3819
4019
|
" const bare = spec.startsWith('node:') ? spec.slice(5) : spec;\n"
|
|
3820
4020
|
" if (builtinModules.includes(bare) && (spec.startsWith('node:') || bare !== 'test')) return spec;\n"
|
|
3821
|
-
" return resolveFrom(
|
|
4021
|
+
" return resolveFrom(parent, spec);\n"
|
|
3822
4022
|
" };\n"
|
|
3823
4023
|
" resolve.paths = (spec) => requirePathsFrom(from, spec);\n"
|
|
3824
4024
|
" req.resolve = resolve;\n"
|
|
@@ -3832,26 +4032,32 @@ static const char isl_modules_bootstrap[] =
|
|
|
3832
4032
|
" return b();\n"
|
|
3833
4033
|
" }\n"
|
|
3834
4034
|
" const hit = cache[key];\n"
|
|
3835
|
-
" if (hit) return hit.exports
|
|
4035
|
+
" if (hit) { updateChildren(parent, hit); return hit.exports; }\n"
|
|
3836
4036
|
" const info = host.source(key);\n"
|
|
3837
4037
|
" if (info === undefined) throw new Error(\"module '\" + key + \"' is not embedded\");\n"
|
|
3838
4038
|
" const src = info[0], format = info[1];\n"
|
|
3839
|
-
" const mod =
|
|
4039
|
+
" const mod = new Module(key, parent);\n"
|
|
4040
|
+
" mod.filename = key;\n"
|
|
4041
|
+
" mod.paths = modulePathsFrom(mod.path);\n"
|
|
3840
4042
|
" cache[key] = mod;\n"
|
|
3841
|
-
"
|
|
3842
|
-
" if (format === 2) { mod.exports = JSON.parse(src); return mod.exports; }\n"
|
|
3843
|
-
" if (format === 0) { delete cache[key]; throw new Error('require() of ES module ' + key); }\n"
|
|
3844
|
-
" const fn = new Function('exports', 'require', 'module', '__filename', '__dirname', src);\n"
|
|
3845
|
-
" const req = decorateRequire((spec) => requireKey(resolveFrom(key, spec), key), key);\n"
|
|
3846
|
-
" const dir = key.slice(0, key.lastIndexOf('/')) || '/';\n"
|
|
4043
|
+
" const req = decorateRequire((spec) => mod.require(spec), mod);\n"
|
|
3847
4044
|
/* A module whose evaluation THROWS leaves no cache entry — Node
|
|
3848
4045
|
* deletes it so a later require re-evaluates (and a lazy require
|
|
3849
4046
|
* trap throws EVERY time instead of answering {} on the retry). */
|
|
3850
4047
|
" try {\n"
|
|
3851
|
-
"
|
|
4048
|
+
" if (format === 2) mod.exports = JSON.parse(src);\n"
|
|
4049
|
+
" else {\n"
|
|
4050
|
+
" if (format === 0) throw new Error('require() of ES module ' + key);\n"
|
|
4051
|
+
" const fn = new Function('exports', 'require', 'module', '__filename', '__dirname', src);\n"
|
|
4052
|
+
" fn.call(mod.exports, mod.exports, req, mod, key, mod.path);\n"
|
|
4053
|
+
" }\n"
|
|
4054
|
+
" mod.loaded = true;\n"
|
|
3852
4055
|
" } catch (e) {\n"
|
|
3853
4056
|
" delete cache[key];\n"
|
|
3854
|
-
"
|
|
4057
|
+
" if (parent && Array.isArray(parent.children)) {\n"
|
|
4058
|
+
" const index = parent.children.indexOf(mod);\n"
|
|
4059
|
+
" if (index !== -1) parent.children.splice(index, 1);\n"
|
|
4060
|
+
" }\n"
|
|
3855
4061
|
" throw e;\n"
|
|
3856
4062
|
" }\n"
|
|
3857
4063
|
" return mod.exports;\n"
|
|
@@ -4895,44 +5101,161 @@ static const char isl_modules_bootstrap[] =
|
|
|
4895
5101
|
" return tty;\n"
|
|
4896
5102
|
" });\n"
|
|
4897
5103
|
" builtins.diagnostics_channel = memo(() => {\n"
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
"
|
|
5104
|
+
" // Store bindings count as active even when there are no message subscribers.\n"
|
|
5105
|
+
" // Store propagation follows the island's synchronous AsyncLocalStorage model.\n"
|
|
5106
|
+
" const channels = new Map();\n"
|
|
5107
|
+
" const deferError = (error) => { queueMicrotask(() => { throw error; }); };\n"
|
|
5108
|
+
" const deactivate = (channel) => {\n"
|
|
5109
|
+
" if (!channel._subscribers.length && !channel._stores.size) {\n"
|
|
5110
|
+
" channel._subscribers = undefined;\n"
|
|
5111
|
+
" channel._stores = undefined;\n"
|
|
5112
|
+
" }\n"
|
|
5113
|
+
" };\n"
|
|
4905
5114
|
" class Channel {\n"
|
|
4906
|
-
" constructor(name) {
|
|
4907
|
-
"
|
|
4908
|
-
"
|
|
4909
|
-
"
|
|
4910
|
-
"
|
|
4911
|
-
"
|
|
4912
|
-
"
|
|
5115
|
+
" constructor(name) {\n"
|
|
5116
|
+
" this._subscribers = undefined;\n"
|
|
5117
|
+
" this._stores = undefined;\n"
|
|
5118
|
+
" this.name = name;\n"
|
|
5119
|
+
" channels.set(name, this);\n"
|
|
5120
|
+
" }\n"
|
|
5121
|
+
" static [Symbol.hasInstance](value) {\n"
|
|
5122
|
+
" if (value == null) throw new TypeError('Cannot convert undefined or null to object');\n"
|
|
5123
|
+
" return Object.getPrototypeOf(value) === Channel.prototype;\n"
|
|
5124
|
+
" }\n"
|
|
5125
|
+
" _activate() {\n"
|
|
5126
|
+
" if (this._subscribers === undefined) {\n"
|
|
5127
|
+
" this._subscribers = [];\n"
|
|
5128
|
+
" this._stores = new Map();\n"
|
|
5129
|
+
" }\n"
|
|
5130
|
+
" }\n"
|
|
5131
|
+
" get hasSubscribers() { return this._subscribers !== undefined; }\n"
|
|
5132
|
+
" subscribe(subscription) {\n"
|
|
5133
|
+
" this._activate();\n"
|
|
5134
|
+
" if (typeof subscription !== 'function') envArgumentError('subscription', 'of type function', subscription);\n"
|
|
5135
|
+
" this._subscribers = [...this._subscribers, subscription];\n"
|
|
5136
|
+
" }\n"
|
|
5137
|
+
" unsubscribe(subscription) {\n"
|
|
5138
|
+
" const index = this._subscribers?.indexOf(subscription) ?? -1;\n"
|
|
5139
|
+
" if (index === -1) return false;\n"
|
|
5140
|
+
" this._subscribers = [...this._subscribers.slice(0, index), ...this._subscribers.slice(index + 1)];\n"
|
|
5141
|
+
" deactivate(this);\n"
|
|
4913
5142
|
" return true;\n"
|
|
4914
5143
|
" }\n"
|
|
4915
|
-
" publish(
|
|
5144
|
+
" publish(data) {\n"
|
|
5145
|
+
" const subscribers = this._subscribers;\n"
|
|
5146
|
+
" for (const subscriber of subscribers ?? []) {\n"
|
|
5147
|
+
" try { subscriber(data, this.name); }\n"
|
|
5148
|
+
" catch (error) { deferError(error); }\n"
|
|
5149
|
+
" }\n"
|
|
5150
|
+
" }\n"
|
|
5151
|
+
" bindStore(store, transform) { this._activate(); this._stores.set(store, transform); }\n"
|
|
5152
|
+
" unbindStore(store) {\n"
|
|
5153
|
+
" if (!this._stores?.delete(store)) return false;\n"
|
|
5154
|
+
" deactivate(this);\n"
|
|
5155
|
+
" return true;\n"
|
|
5156
|
+
" }\n"
|
|
5157
|
+
" runStores(data, fn, thisArg, ...args) {\n"
|
|
5158
|
+
" let run = () => { this.publish(data); return Reflect.apply(fn, thisArg, args); };\n"
|
|
5159
|
+
" for (const [store, transform = (data) => data] of this._stores ?? []) {\n"
|
|
5160
|
+
" const next = run;\n"
|
|
5161
|
+
" run = () => {\n"
|
|
5162
|
+
" let context;\n"
|
|
5163
|
+
" try { context = transform(data); }\n"
|
|
5164
|
+
" catch (error) { deferError(error); return next(); }\n"
|
|
5165
|
+
" return store.run(context, next);\n"
|
|
5166
|
+
" };\n"
|
|
5167
|
+
" }\n"
|
|
5168
|
+
" return run();\n"
|
|
5169
|
+
" }\n"
|
|
4916
5170
|
" }\n"
|
|
4917
|
-
" const channel = (name) =>
|
|
4918
|
-
"
|
|
4919
|
-
"
|
|
4920
|
-
"
|
|
4921
|
-
"
|
|
4922
|
-
"
|
|
5171
|
+
" const channel = (name) => {\n"
|
|
5172
|
+
" const existing = channels.get(name);\n"
|
|
5173
|
+
" if (existing) return existing;\n"
|
|
5174
|
+
" if (typeof name !== 'string' && typeof name !== 'symbol') envArgumentError('channel', 'one of type string or symbol', name);\n"
|
|
5175
|
+
" return new Channel(name);\n"
|
|
5176
|
+
" };\n"
|
|
5177
|
+
" const traceEvents = ['start', 'end', 'asyncStart', 'asyncEnd', 'error'];\n"
|
|
5178
|
+
" class TracingChannel {\n"
|
|
5179
|
+
" constructor(nameOrChannels) {\n"
|
|
5180
|
+
" for (const name of traceEvents) {\n"
|
|
5181
|
+
" let event;\n"
|
|
5182
|
+
" if (typeof nameOrChannels === 'string') event = channel('tracing:' + nameOrChannels + ':' + name);\n"
|
|
5183
|
+
" else if (nameOrChannels !== null && typeof nameOrChannels === 'object') {\n"
|
|
5184
|
+
" event = nameOrChannels[name];\n"
|
|
5185
|
+
" if (!(event instanceof Channel)) envArgumentError('nameOrChannels.' + name, 'an instance of Channel', event);\n"
|
|
5186
|
+
" } else envArgumentError('nameOrChannels', 'of type string or an instance of TracingChannel or Object', nameOrChannels);\n"
|
|
5187
|
+
" Object.defineProperty(this, name, { value: event });\n"
|
|
4923
5188
|
" }\n"
|
|
4924
|
-
"
|
|
4925
|
-
" }
|
|
4926
|
-
"
|
|
4927
|
-
"
|
|
4928
|
-
"
|
|
4929
|
-
"
|
|
5189
|
+
" }\n"
|
|
5190
|
+
" get hasSubscribers() { return traceEvents.some((name) => this[name]?.hasSubscribers); }\n"
|
|
5191
|
+
" subscribe(handlers) {\n"
|
|
5192
|
+
" for (const name of traceEvents) if (handlers[name]) this[name]?.subscribe(handlers[name]);\n"
|
|
5193
|
+
" }\n"
|
|
5194
|
+
" unsubscribe(handlers) {\n"
|
|
5195
|
+
" let done = true;\n"
|
|
5196
|
+
" for (const name of traceEvents) if (handlers[name] && !this[name]?.unsubscribe(handlers[name])) done = false;\n"
|
|
5197
|
+
" return done;\n"
|
|
5198
|
+
" }\n"
|
|
5199
|
+
" traceSync(fn, context = {}, thisArg, ...args) {\n"
|
|
5200
|
+
" if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);\n"
|
|
5201
|
+
" return this.start.runStores(context, () => {\n"
|
|
5202
|
+
" try { const result = Reflect.apply(fn, thisArg, args); context.result = result; return result; }\n"
|
|
5203
|
+
" catch (error) { context.error = error; this.error.publish(context); throw error; }\n"
|
|
5204
|
+
" finally { this.end.publish(context); }\n"
|
|
5205
|
+
" });\n"
|
|
5206
|
+
" }\n"
|
|
5207
|
+
" tracePromise(fn, context = {}, thisArg, ...args) {\n"
|
|
5208
|
+
" if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);\n"
|
|
5209
|
+
" const resolve = (result) => {\n"
|
|
5210
|
+
" context.result = result;\n"
|
|
5211
|
+
" this.asyncStart.publish(context);\n"
|
|
5212
|
+
" this.asyncEnd.publish(context);\n"
|
|
5213
|
+
" return result;\n"
|
|
5214
|
+
" };\n"
|
|
5215
|
+
" const reject = (error) => {\n"
|
|
5216
|
+
" context.error = error;\n"
|
|
5217
|
+
" this.error.publish(context);\n"
|
|
5218
|
+
" this.asyncStart.publish(context);\n"
|
|
5219
|
+
" this.asyncEnd.publish(context);\n"
|
|
5220
|
+
" return Promise.reject(error);\n"
|
|
5221
|
+
" };\n"
|
|
5222
|
+
" return this.start.runStores(context, () => {\n"
|
|
5223
|
+
" try {\n"
|
|
5224
|
+
" let promise = Reflect.apply(fn, thisArg, args);\n"
|
|
5225
|
+
" if (!(promise instanceof Promise)) promise = Promise.resolve(promise);\n"
|
|
5226
|
+
" return Promise.prototype.then.call(promise, resolve, reject);\n"
|
|
5227
|
+
" } catch (error) { context.error = error; this.error.publish(context); throw error; }\n"
|
|
5228
|
+
" finally { this.end.publish(context); }\n"
|
|
5229
|
+
" });\n"
|
|
5230
|
+
" }\n"
|
|
5231
|
+
" traceCallback(fn, position = -1, context = {}, thisArg, ...args) {\n"
|
|
5232
|
+
" if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);\n"
|
|
5233
|
+
" const { start, end, asyncStart, asyncEnd, error } = this;\n"
|
|
5234
|
+
" const callback = args.at(position);\n"
|
|
5235
|
+
" if (typeof callback !== 'function') envArgumentError('callback', 'of type function', callback);\n"
|
|
5236
|
+
" function wrappedCallback(err, result) {\n"
|
|
5237
|
+
" if (err) { context.error = err; error.publish(context); }\n"
|
|
5238
|
+
" else context.result = result;\n"
|
|
5239
|
+
" asyncStart.runStores(context, () => {\n"
|
|
5240
|
+
" try { return Reflect.apply(callback, this, arguments); }\n"
|
|
5241
|
+
" finally { asyncEnd.publish(context); }\n"
|
|
5242
|
+
" });\n"
|
|
5243
|
+
" }\n"
|
|
5244
|
+
" args.splice(position, 1, wrappedCallback);\n"
|
|
5245
|
+
" return start.runStores(context, () => {\n"
|
|
5246
|
+
" try { return Reflect.apply(fn, thisArg, args); }\n"
|
|
5247
|
+
" catch (err) { context.error = err; error.publish(context); throw err; }\n"
|
|
5248
|
+
" finally { end.publish(context); }\n"
|
|
5249
|
+
" });\n"
|
|
5250
|
+
" }\n"
|
|
5251
|
+
" }\n"
|
|
4930
5252
|
" const dc = {\n"
|
|
4931
5253
|
" channel,\n"
|
|
4932
|
-
" subscribe: (name,
|
|
4933
|
-
" unsubscribe: (name,
|
|
4934
|
-
" hasSubscribers: (name) =>
|
|
4935
|
-
" tracingChannel,\n"
|
|
5254
|
+
" subscribe: (name, subscription) => channel(name).subscribe(subscription),\n"
|
|
5255
|
+
" unsubscribe: (name, subscription) => channel(name).unsubscribe(subscription),\n"
|
|
5256
|
+
" hasSubscribers: (name) => channels.get(name)?.hasSubscribers ?? false,\n"
|
|
5257
|
+
" tracingChannel: (nameOrChannels) => new TracingChannel(nameOrChannels),\n"
|
|
5258
|
+
" Channel,\n"
|
|
4936
5259
|
" };\n"
|
|
4937
5260
|
" dc.default = dc;\n"
|
|
4938
5261
|
" return dc;\n"
|
|
@@ -4950,7 +5273,10 @@ static const char isl_modules_bootstrap[] =
|
|
|
4950
5273
|
" if (key.startsWith('file://')) key = decodeURIComponent(key.slice(7));\n"
|
|
4951
5274
|
/* The base file is the created require's parent, like Node: modules
|
|
4952
5275
|
* it loads report it in their require stacks. */
|
|
4953
|
-
"
|
|
5276
|
+
" const parent = new Module(key);\n"
|
|
5277
|
+
" parent.filename = key;\n"
|
|
5278
|
+
" parent.paths = modulePathsFrom(parent.path);\n"
|
|
5279
|
+
" return decorateRequire((spec) => parent.require(spec), parent);\n"
|
|
4954
5280
|
" };\n"
|
|
4955
5281
|
/* builtinModules/isBuiltin answer Node's QUESTION ("is this name a
|
|
4956
5282
|
* Node builtin?") with Node's full list — resolution of unshimmed
|
|
@@ -4978,11 +5304,11 @@ static const char isl_modules_bootstrap[] =
|
|
|
4978
5304
|
* converters riding the static scr_url.c implementations (Node's
|
|
4979
5305
|
* exact rules), and the legacy parse/format/resolve trio over the
|
|
4980
5306
|
* WHATWG parser. */
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
"
|
|
4984
|
-
" };\n"
|
|
4985
|
-
" const pathToFileURL = (p) => new globalThis.URL(host.urlFromPath(
|
|
5307
|
+
/* Read user option getters in their engine so thrown values preserve
|
|
5308
|
+
* identity. The path-to-URL public wrapper validates its path first. */
|
|
5309
|
+
" const fileURLToPath = (u, options) => host.urlToPath(u, { windows: options?.windows });\n"
|
|
5310
|
+
" const fileURLToPathBuffer = (u, options) => builtins.buffer().Buffer.from(host.urlToPathBuffer(u, { windows: options?.windows }));\n"
|
|
5311
|
+
" const pathToFileURL = (p, options) => new globalThis.URL(host.urlFromPath(p, typeof p === 'string' ? { windows: options?.windows } : undefined));\n"
|
|
4986
5312
|
" const parse = (input, parseQuery) => {\n"
|
|
4987
5313
|
" const out = { protocol: null, slashes: null, auth: null, host: null, port: null,\n"
|
|
4988
5314
|
" hostname: null, hash: null, search: null, query: null, pathname: null, path: null, href: String(input) };\n"
|
|
@@ -5044,7 +5370,7 @@ static const char isl_modules_bootstrap[] =
|
|
|
5044
5370
|
" const u = {\n"
|
|
5045
5371
|
" URL: globalThis.URL,\n"
|
|
5046
5372
|
" URLSearchParams: globalThis.URLSearchParams,\n"
|
|
5047
|
-
" fileURLToPath, pathToFileURL, parse, format, resolve,\n"
|
|
5373
|
+
" fileURLToPath, fileURLToPathBuffer, pathToFileURL, parse, format, resolve,\n"
|
|
5048
5374
|
/* IDNA is not carried: ASCII hostnames pass through lowercased
|
|
5049
5375
|
* (documented divergence for internationalized domains). */
|
|
5050
5376
|
" domainToASCII: (d) => String(d).toLowerCase(),\n"
|
|
@@ -7210,7 +7536,12 @@ static const char isl_modules_bootstrap[] =
|
|
|
7210
7536
|
" const g = globalThis;\n"
|
|
7211
7537
|
" const w = {\n"
|
|
7212
7538
|
" ReadableStream: g.ReadableStream, TransformStream: g.TransformStream,\n"
|
|
7213
|
-
"
|
|
7539
|
+
" ReadableStreamDefaultReader: g.ReadableStreamDefaultReader, ReadableStreamDefaultController: g.ReadableStreamDefaultController,\n"
|
|
7540
|
+
" TextDecoderStream: g.TextDecoderStream, TextEncoderStream: g.TextEncoderStream,\n"
|
|
7541
|
+
" TransformStreamDefaultController: g.TransformStreamDefaultController,\n"
|
|
7542
|
+
" WritableStream: g.WritableStream, WritableStreamDefaultWriter: g.WritableStreamDefaultWriter,\n"
|
|
7543
|
+
" WritableStreamDefaultController: g.WritableStreamDefaultController,\n"
|
|
7544
|
+
" CountQueuingStrategy: g.CountQueuingStrategy, ByteLengthQueuingStrategy: g.ByteLengthQueuingStrategy,\n"
|
|
7214
7545
|
" };\n"
|
|
7215
7546
|
" w.default = w;\n"
|
|
7216
7547
|
" return w;\n"
|
|
@@ -7395,6 +7726,44 @@ static const char isl_modules_bootstrap[] =
|
|
|
7395
7726
|
" generatedMessage: true,\n"
|
|
7396
7727
|
" });\n"
|
|
7397
7728
|
" };\n"
|
|
7729
|
+
" const noErrorRegexExec = RegExp.prototype.exec;\n"
|
|
7730
|
+
" const noErrorMatches = (actual, expected) => {\n"
|
|
7731
|
+
" if (typeof expected === 'function') {\n"
|
|
7732
|
+
" if (expected.prototype !== undefined && actual instanceof expected) return true;\n"
|
|
7733
|
+
" if (Object.prototype.isPrototypeOf.call(Error, expected)) return false;\n"
|
|
7734
|
+
" if (expected === Error && typeof actual === 'symbol') throw new TypeError('Cannot convert a Symbol value to a string');\n"
|
|
7735
|
+
" return Reflect.apply(expected, {}, [actual]) === true;\n"
|
|
7736
|
+
" }\n"
|
|
7737
|
+
" if (expected instanceof RegExp) return Reflect.apply(noErrorRegexExec, expected, [String(actual)]) !== null;\n"
|
|
7738
|
+
" envArgumentError('expected', 'of type function or an instance of RegExp', expected);\n"
|
|
7739
|
+
" };\n"
|
|
7740
|
+
" const noErrorFailure = (actual, expected, message, operator) => {\n"
|
|
7741
|
+
" if (typeof expected === 'string') { message = expected; expected = undefined; }\n"
|
|
7742
|
+
" if (!expected || noErrorMatches(actual, expected)) {\n"
|
|
7743
|
+
" const kind = operator === 'doesNotReject' ? 'rejection' : 'exception';\n"
|
|
7744
|
+
" throw new AssertionError({ actual, expected, operator,\n"
|
|
7745
|
+
" message: 'Got unwanted ' + kind + (message ? ': ' + message : '.') + '\\nActual message: \"' + actual?.message + '\"',\n"
|
|
7746
|
+
" });\n"
|
|
7747
|
+
" }\n"
|
|
7748
|
+
" throw actual;\n"
|
|
7749
|
+
" };\n"
|
|
7750
|
+
" const waitForNoError = async (input) => {\n"
|
|
7751
|
+
" const isPromise = (p) => env.isPromise(p) || (p !== null && typeof p === 'object' && typeof p.then === 'function' && typeof p.catch === 'function');\n"
|
|
7752
|
+
" let result;\n"
|
|
7753
|
+
" if (typeof input !== 'function') {\n"
|
|
7754
|
+
" if (!isPromise(input)) envArgumentError('promiseFn', 'of type function or an instance of Promise', input);\n"
|
|
7755
|
+
" result = input;\n"
|
|
7756
|
+
" } else {\n"
|
|
7757
|
+
" result = input();\n"
|
|
7758
|
+
" if (!isPromise(result)) {\n"
|
|
7759
|
+
" const error = new TypeError('Expected instance of Promise to be returned from the \\\"promiseFn\\\" function but got ' + envReceivedType(result) + '.');\n"
|
|
7760
|
+
" error.code = 'ERR_INVALID_RETURN_VALUE';\n"
|
|
7761
|
+
" throw error;\n"
|
|
7762
|
+
" }\n"
|
|
7763
|
+
" }\n"
|
|
7764
|
+
" try { await result; } catch (actual) { return { didFail: true, actual }; }\n"
|
|
7765
|
+
" return { didFail: false };\n"
|
|
7766
|
+
" };\n"
|
|
7398
7767
|
" const assert = Object.assign(ok, {\n"
|
|
7399
7768
|
" AssertionError,\n"
|
|
7400
7769
|
" ok,\n"
|
|
@@ -7463,20 +7832,11 @@ static const char isl_modules_bootstrap[] =
|
|
|
7463
7832
|
" }\n"
|
|
7464
7833
|
" },\n"
|
|
7465
7834
|
" doesNotThrow(fn, expected, message) {\n"
|
|
7466
|
-
" if (typeof
|
|
7467
|
-
" message = expected;\n"
|
|
7468
|
-
" expected = undefined;\n"
|
|
7469
|
-
" }\n"
|
|
7835
|
+
" if (typeof fn !== 'function') envArgumentError('fn', 'of type function', fn);\n"
|
|
7470
7836
|
" try {\n"
|
|
7471
7837
|
" fn();\n"
|
|
7472
7838
|
" } catch (e) {\n"
|
|
7473
|
-
"
|
|
7474
|
-
" throw new AssertionError({\n"
|
|
7475
|
-
" message: \"Got unwanted exception\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n"
|
|
7476
|
-
" operator: \"doesNotThrow\",\n"
|
|
7477
|
-
" });\n"
|
|
7478
|
-
" }\n"
|
|
7479
|
-
" throw e;\n"
|
|
7839
|
+
" noErrorFailure(e, expected, message, 'doesNotThrow');\n"
|
|
7480
7840
|
" }\n"
|
|
7481
7841
|
" },\n"
|
|
7482
7842
|
" async rejects(promiseOrFn, expected, message) {\n"
|
|
@@ -7503,21 +7863,8 @@ static const char isl_modules_bootstrap[] =
|
|
|
7503
7863
|
" }\n"
|
|
7504
7864
|
" },\n"
|
|
7505
7865
|
" async doesNotReject(promiseOrFn, expected, message) {\n"
|
|
7506
|
-
"
|
|
7507
|
-
"
|
|
7508
|
-
" expected = undefined;\n"
|
|
7509
|
-
" }\n"
|
|
7510
|
-
" try {\n"
|
|
7511
|
-
" await (typeof promiseOrFn === \"function\" ? promiseOrFn() : promiseOrFn);\n"
|
|
7512
|
-
" } catch (e) {\n"
|
|
7513
|
-
" if (expected === undefined || checkExpected(e, expected, message, \"doesNotReject\")) {\n"
|
|
7514
|
-
" throw new AssertionError({\n"
|
|
7515
|
-
" message: \"Got unwanted rejection\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n"
|
|
7516
|
-
" operator: \"doesNotReject\",\n"
|
|
7517
|
-
" });\n"
|
|
7518
|
-
" }\n"
|
|
7519
|
-
" throw e;\n"
|
|
7520
|
-
" }\n"
|
|
7866
|
+
" const result = await waitForNoError(promiseOrFn);\n"
|
|
7867
|
+
" if (result.didFail) noErrorFailure(result.actual, expected, message, 'doesNotReject');\n"
|
|
7521
7868
|
" },\n"
|
|
7522
7869
|
" match(string, regexp, message) {\n"
|
|
7523
7870
|
" if (!(regexp instanceof RegExp)) {\n"
|
|
@@ -7584,7 +7931,7 @@ static const char isl_modules_bootstrap[] =
|
|
|
7584
7931
|
" return assert;\n"
|
|
7585
7932
|
"}\n"
|
|
7586
7933
|
" const u = builtins.util();\n"
|
|
7587
|
-
" const a = makeAssert({ isDeepStrictEqual: u.isDeepStrictEqual, inspect: u.inspect });\n"
|
|
7934
|
+
" const a = makeAssert({ isDeepStrictEqual: u.isDeepStrictEqual, inspect: u.inspect, isPromise: u.types.isPromise });\n"
|
|
7588
7935
|
" a.default = a;\n"
|
|
7589
7936
|
" return a;\n"
|
|
7590
7937
|
" });\n"
|
|
@@ -7599,13 +7946,17 @@ static const char isl_modules_bootstrap[] =
|
|
|
7599
7946
|
* isDeepStrictEqual, stripVTControlCharacters, styleText,
|
|
7600
7947
|
* parseArgs, toUSVString). The host supplies what JS cannot see:
|
|
7601
7948
|
* promise state (JS_PromiseState), the pid, and fd writes. */
|
|
7602
|
-
" const
|
|
7949
|
+
" const envReceivedType = (value) => {\n"
|
|
7603
7950
|
" const type = typeof value;\n"
|
|
7604
7951
|
" let received;\n"
|
|
7605
7952
|
" if (value === null || value === undefined) received = String(value);\n"
|
|
7606
7953
|
" else if (type === 'function') received = 'function ' + value.name;\n"
|
|
7607
7954
|
" else if (type === 'object' && value.constructor && value.constructor.name) received = 'an instance of ' + value.constructor.name;\n"
|
|
7608
7955
|
" else received = type === 'object' ? builtins.util().inspect(value, { depth: -1 }) : 'type ' + type + ' (' + builtins.util().inspect(value) + ')';\n"
|
|
7956
|
+
" return received;\n"
|
|
7957
|
+
" };\n"
|
|
7958
|
+
" const envArgumentError = (name, expected, value) => {\n"
|
|
7959
|
+
" const received = envReceivedType(value);\n"
|
|
7609
7960
|
" const error = new TypeError('The \"' + name + '\" ' + (name.includes('.') ? 'property' : 'argument') + ' must be ' + expected + '. Received ' + received);\n"
|
|
7610
7961
|
" error.code = 'ERR_INVALID_ARG_TYPE';\n"
|
|
7611
7962
|
" throw error;\n"
|
|
@@ -8315,230 +8666,283 @@ static const char isl_modules_bootstrap[] =
|
|
|
8315
8666
|
" return fn;\n"
|
|
8316
8667
|
" };\n"
|
|
8317
8668
|
" const tagOf = (v) => Object.prototype.toString.call(v).slice(8, -1);\n"
|
|
8318
|
-
" const taggedTest = (tag) => (v) => tagOf(v) === tag && typeof v === \"object\";\n"
|
|
8319
8669
|
" const taTagGetter = Object.getOwnPropertyDescriptor(\n"
|
|
8320
8670
|
" Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array(0))), Symbol.toStringTag).get;\n"
|
|
8321
|
-
" const brandTA = (v) => {\n"
|
|
8322
|
-
" try {\n"
|
|
8323
|
-
" return taTagGetter.call(v) !== undefined;\n"
|
|
8324
|
-
" } catch (e) {\n"
|
|
8325
|
-
" return false;\n"
|
|
8326
|
-
" }\n"
|
|
8327
|
-
" };\n"
|
|
8328
8671
|
" const types = {\n"
|
|
8329
|
-
" isAnyArrayBuffer: (v) =>
|
|
8330
|
-
" isArrayBufferView: (v) =>
|
|
8331
|
-
" isArgumentsObject:
|
|
8332
|
-
" isArrayBuffer: (v) =>
|
|
8333
|
-
"
|
|
8334
|
-
"
|
|
8335
|
-
"
|
|
8336
|
-
"
|
|
8337
|
-
"
|
|
8338
|
-
"
|
|
8339
|
-
"
|
|
8340
|
-
"
|
|
8341
|
-
"
|
|
8342
|
-
"
|
|
8343
|
-
"
|
|
8344
|
-
"
|
|
8345
|
-
"
|
|
8346
|
-
"
|
|
8347
|
-
"
|
|
8348
|
-
"
|
|
8349
|
-
"
|
|
8350
|
-
"
|
|
8351
|
-
"
|
|
8352
|
-
"
|
|
8353
|
-
"
|
|
8354
|
-
"
|
|
8355
|
-
"
|
|
8356
|
-
"
|
|
8357
|
-
"
|
|
8358
|
-
"
|
|
8359
|
-
"
|
|
8360
|
-
"
|
|
8361
|
-
"
|
|
8362
|
-
"
|
|
8363
|
-
"
|
|
8364
|
-
"
|
|
8365
|
-
"
|
|
8366
|
-
"
|
|
8367
|
-
"
|
|
8368
|
-
"
|
|
8369
|
-
"
|
|
8370
|
-
"
|
|
8371
|
-
"
|
|
8372
|
-
"
|
|
8373
|
-
"
|
|
8374
|
-
"
|
|
8375
|
-
"
|
|
8376
|
-
"
|
|
8377
|
-
"
|
|
8378
|
-
"
|
|
8379
|
-
"
|
|
8380
|
-
"
|
|
8381
|
-
"
|
|
8382
|
-
"
|
|
8383
|
-
"
|
|
8384
|
-
"
|
|
8385
|
-
"
|
|
8386
|
-
"
|
|
8387
|
-
"
|
|
8388
|
-
"
|
|
8389
|
-
" isSetIterator: (v) => tagOf(v) === \"Set Iterator\",\n"
|
|
8390
|
-
" isSharedArrayBuffer: (v) => tagOf(v) === \"SharedArrayBuffer\",\n"
|
|
8391
|
-
" isStringObject: (v) => {\n"
|
|
8392
|
-
" try { String.prototype.valueOf.call(v); return typeof v === \"object\"; }\n"
|
|
8393
|
-
" catch (e) { return false; }\n"
|
|
8394
|
-
" },\n"
|
|
8395
|
-
" isSymbolObject: (v) => {\n"
|
|
8396
|
-
" try { Symbol.prototype.valueOf.call(v); return typeof v === \"object\"; }\n"
|
|
8397
|
-
" catch (e) { return false; }\n"
|
|
8398
|
-
" },\n"
|
|
8399
|
-
" isTypedArray: brandTA,\n"
|
|
8400
|
-
" isUint8Array: (v) => tagOf(v) === \"Uint8Array\",\n"
|
|
8401
|
-
" isUint8ClampedArray: (v) => tagOf(v) === \"Uint8ClampedArray\",\n"
|
|
8402
|
-
" isUint16Array: (v) => tagOf(v) === \"Uint16Array\",\n"
|
|
8403
|
-
" isUint32Array: (v) => tagOf(v) === \"Uint32Array\",\n"
|
|
8404
|
-
" isWeakMap: (v) => {\n"
|
|
8405
|
-
" try { WeakMap.prototype.has.call(v, {}); return true; }\n"
|
|
8406
|
-
" catch (e) { return false; }\n"
|
|
8407
|
-
" },\n"
|
|
8408
|
-
" isWeakSet: (v) => {\n"
|
|
8409
|
-
" try { WeakSet.prototype.has.call(v, {}); return true; }\n"
|
|
8410
|
-
" catch (e) { return false; }\n"
|
|
8411
|
-
" },\n"
|
|
8412
|
-
" };\n"
|
|
8413
|
-
" const deepEquals = (a, b, memos) => {\n"
|
|
8672
|
+
" isAnyArrayBuffer: (v) => env.typeProbe(\"isAnyArrayBuffer\", v),\n"
|
|
8673
|
+
" isArrayBufferView: (v) => env.typeProbe(\"isArrayBufferView\", v),\n"
|
|
8674
|
+
" isArgumentsObject: (v) => env.typeProbe(\"isArgumentsObject\", v),\n"
|
|
8675
|
+
" isArrayBuffer: (v) => env.typeProbe(\"isArrayBuffer\", v),\n"
|
|
8676
|
+
" isAsyncFunction: (v) => env.typeProbe(\"isAsyncFunction\", v),\n"
|
|
8677
|
+
" isBigInt64Array: (v) => env.typeProbe(\"isBigInt64Array\", v),\n"
|
|
8678
|
+
" isBigUint64Array: (v) => env.typeProbe(\"isBigUint64Array\", v),\n"
|
|
8679
|
+
" isBooleanObject: (v) => env.typeProbe(\"isBooleanObject\", v),\n"
|
|
8680
|
+
" isBoxedPrimitive: (v) => env.typeProbe(\"isBoxedPrimitive\", v),\n"
|
|
8681
|
+
" isBigIntObject: (v) => env.typeProbe(\"isBigIntObject\", v),\n"
|
|
8682
|
+
" isCryptoKey: (v) => env.typeProbe(\"isCryptoKey\", v),\n"
|
|
8683
|
+
" isDataView: (v) => env.typeProbe(\"isDataView\", v),\n"
|
|
8684
|
+
" isDate: (v) => env.typeProbe(\"isDate\", v),\n"
|
|
8685
|
+
" isExternal: (v) => env.typeProbe(\"isExternal\", v),\n"
|
|
8686
|
+
" isFloat16Array: (v) => env.typeProbe(\"isFloat16Array\", v),\n"
|
|
8687
|
+
" isFloat32Array: (v) => env.typeProbe(\"isFloat32Array\", v),\n"
|
|
8688
|
+
" isFloat64Array: (v) => env.typeProbe(\"isFloat64Array\", v),\n"
|
|
8689
|
+
" isGeneratorFunction: (v) => env.typeProbe(\"isGeneratorFunction\", v),\n"
|
|
8690
|
+
" isGeneratorObject: (v) => env.typeProbe(\"isGeneratorObject\", v),\n"
|
|
8691
|
+
" isInt8Array: (v) => env.typeProbe(\"isInt8Array\", v),\n"
|
|
8692
|
+
" isInt16Array: (v) => env.typeProbe(\"isInt16Array\", v),\n"
|
|
8693
|
+
" isInt32Array: (v) => env.typeProbe(\"isInt32Array\", v),\n"
|
|
8694
|
+
" isKeyObject: (v) => env.typeProbe(\"isKeyObject\", v),\n"
|
|
8695
|
+
" isMap: (v) => env.typeProbe(\"isMap\", v),\n"
|
|
8696
|
+
" isMapIterator: (v) => env.typeProbe(\"isMapIterator\", v),\n"
|
|
8697
|
+
" isModuleNamespaceObject: (v) => env.typeProbe(\"isModuleNamespaceObject\", v),\n"
|
|
8698
|
+
" isNativeError: (v) => env.typeProbe(\"isNativeError\", v),\n"
|
|
8699
|
+
" isNumberObject: (v) => env.typeProbe(\"isNumberObject\", v),\n"
|
|
8700
|
+
" isPromise: (v) => env.typeProbe(\"isPromise\", v),\n"
|
|
8701
|
+
" isProxy: (v) => env.typeProbe(\"isProxy\", v),\n"
|
|
8702
|
+
" isRegExp: (v) => env.typeProbe(\"isRegExp\", v),\n"
|
|
8703
|
+
" isSet: (v) => env.typeProbe(\"isSet\", v),\n"
|
|
8704
|
+
" isSetIterator: (v) => env.typeProbe(\"isSetIterator\", v),\n"
|
|
8705
|
+
" isSharedArrayBuffer: (v) => env.typeProbe(\"isSharedArrayBuffer\", v),\n"
|
|
8706
|
+
" isStringObject: (v) => env.typeProbe(\"isStringObject\", v),\n"
|
|
8707
|
+
" isSymbolObject: (v) => env.typeProbe(\"isSymbolObject\", v),\n"
|
|
8708
|
+
" isTypedArray: (v) => env.typeProbe(\"isTypedArray\", v),\n"
|
|
8709
|
+
" isUint8Array: (v) => env.typeProbe(\"isUint8Array\", v),\n"
|
|
8710
|
+
" isUint8ClampedArray: (v) => env.typeProbe(\"isUint8ClampedArray\", v),\n"
|
|
8711
|
+
" isUint16Array: (v) => env.typeProbe(\"isUint16Array\", v),\n"
|
|
8712
|
+
" isUint32Array: (v) => env.typeProbe(\"isUint32Array\", v),\n"
|
|
8713
|
+
" isWeakMap: (v) => env.typeProbe(\"isWeakMap\", v),\n"
|
|
8714
|
+
" isWeakSet: (v) => env.typeProbe(\"isWeakSet\", v),\n"
|
|
8715
|
+
" };\n"
|
|
8716
|
+
" for (const [name, probe] of Object.entries(types)) {\n"
|
|
8717
|
+
" const wrapper = name === \"isTypedArray\" || /Array$/.test(name) && name !== \"isAnyArrayBuffer\" && name !== \"isArrayBuffer\";\n"
|
|
8718
|
+
" if (!wrapper && name !== \"isArrayBufferView\" && name !== \"isCryptoKey\" && name !== \"isKeyObject\") {\n"
|
|
8719
|
+
" Object.defineProperty(probe, \"name\", { value: \"\", configurable: true });\n"
|
|
8720
|
+
" Object.defineProperty(probe, \"length\", { value: 0, configurable: true });\n"
|
|
8721
|
+
" }\n"
|
|
8722
|
+
" }\n"
|
|
8723
|
+
" types.isArrayBufferView = ArrayBuffer.isView;\n"
|
|
8724
|
+
" Object.defineProperty(types.isCryptoKey, \"name\", { value: \"value\", configurable: true });\n"
|
|
8725
|
+
" Object.defineProperty(types.isKeyObject, \"name\", { value: \"value\", configurable: true });\n"
|
|
8726
|
+
" const deepConstructors = new Set([Array, ArrayBuffer, BigInt, Boolean, DataView, Date, Error, Function,\n"
|
|
8727
|
+
" Map, Number, Object, Promise, RegExp, Set, String, Symbol, WeakMap, WeakSet, Uint8Array,\n"
|
|
8728
|
+
" Uint8ClampedArray, Uint16Array, Uint32Array, Int8Array, Int16Array, Int32Array, Float32Array,\n"
|
|
8729
|
+
" Float64Array, BigInt64Array, BigUint64Array, Buffer]);\n"
|
|
8730
|
+
" if (typeof Float16Array !== \"undefined\") deepConstructors.add(Float16Array);\n"
|
|
8731
|
+
" const deepEquals = (a, b, skipPrototype, memos) => {\n"
|
|
8414
8732
|
" if (Object.is(a, b)) return true;\n"
|
|
8415
|
-
"
|
|
8416
|
-
"
|
|
8417
|
-
"
|
|
8418
|
-
"
|
|
8419
|
-
"
|
|
8420
|
-
"
|
|
8421
|
-
"
|
|
8422
|
-
"
|
|
8423
|
-
"
|
|
8424
|
-
"
|
|
8425
|
-
"
|
|
8426
|
-
"
|
|
8427
|
-
"
|
|
8428
|
-
"
|
|
8429
|
-
"
|
|
8430
|
-
"
|
|
8431
|
-
"
|
|
8432
|
-
"
|
|
8433
|
-
"
|
|
8434
|
-
"
|
|
8733
|
+
" if (typeof a !== \"object\" || a === null || typeof b !== \"object\" || b === null) return false;\n"
|
|
8734
|
+
" if (!skipPrototype) {\n"
|
|
8735
|
+
" if (deepConstructors.has(a.constructor) ||\n"
|
|
8736
|
+
" (a.constructor !== undefined && !Object.prototype.hasOwnProperty.call(a, \"constructor\"))) {\n"
|
|
8737
|
+
" if (a.constructor !== b.constructor) return false;\n"
|
|
8738
|
+
" } else if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n"
|
|
8739
|
+
" }\n"
|
|
8740
|
+
" const array = Array.isArray(a);\n"
|
|
8741
|
+
" const view = ArrayBuffer.isView(a);\n"
|
|
8742
|
+
" const map = types.isMap(a);\n"
|
|
8743
|
+
" const set = types.isSet(a);\n"
|
|
8744
|
+
" const date = types.isDate(a);\n"
|
|
8745
|
+
" const regexp = types.isRegExp(a);\n"
|
|
8746
|
+
" const buffer = types.isAnyArrayBuffer(a);\n"
|
|
8747
|
+
" if (array !== Array.isArray(b) || view !== ArrayBuffer.isView(b) ||\n"
|
|
8748
|
+
" map !== types.isMap(b) || set !== types.isSet(b) || date !== types.isDate(b) ||\n"
|
|
8749
|
+
" regexp !== types.isRegExp(b) || buffer !== types.isAnyArrayBuffer(b)) return false;\n"
|
|
8750
|
+
" if (!view && tagOf(a) !== tagOf(b)) return false;\n"
|
|
8751
|
+
" if (array && a.length !== b.length) return false;\n"
|
|
8752
|
+
" if (view) {\n"
|
|
8753
|
+
" if (taTagGetter.call(a) !== taTagGetter.call(b) || a.byteLength !== b.byteLength) return false;\n"
|
|
8754
|
+
" const ua = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);\n"
|
|
8755
|
+
" const ub = new Uint8Array(b.buffer, b.byteOffset, b.byteLength);\n"
|
|
8756
|
+
" for (let i = 0; i < ua.length; i++) if (ua[i] !== ub[i]) return false;\n"
|
|
8435
8757
|
" }\n"
|
|
8436
|
-
" if (
|
|
8758
|
+
" if (buffer) {\n"
|
|
8759
|
+
" if (a.byteLength !== b.byteLength) return false;\n"
|
|
8437
8760
|
" const ua = new Uint8Array(a);\n"
|
|
8438
8761
|
" const ub = new Uint8Array(b);\n"
|
|
8439
|
-
" if (ua.length !== ub.length) return false;\n"
|
|
8440
8762
|
" for (let i = 0; i < ua.length; i++) if (ua[i] !== ub[i]) return false;\n"
|
|
8441
|
-
" return true;\n"
|
|
8442
8763
|
" }\n"
|
|
8443
|
-
" if (
|
|
8444
|
-
" if (
|
|
8445
|
-
"
|
|
8446
|
-
" (
|
|
8447
|
-
"
|
|
8448
|
-
"
|
|
8449
|
-
"
|
|
8450
|
-
"
|
|
8451
|
-
"
|
|
8452
|
-
"
|
|
8453
|
-
"
|
|
8454
|
-
"
|
|
8455
|
-
"
|
|
8456
|
-
"
|
|
8457
|
-
"
|
|
8458
|
-
"
|
|
8459
|
-
"
|
|
8460
|
-
"
|
|
8461
|
-
"
|
|
8764
|
+
" if (date && !Object.is(Date.prototype.getTime.call(a), Date.prototype.getTime.call(b))) return false;\n"
|
|
8765
|
+
" if (regexp && (a.source !== b.source || a.flags !== b.flags || a.lastIndex !== b.lastIndex)) return false;\n"
|
|
8766
|
+
" if (types.isPromise(a) || types.isPromise(b) || types.isWeakMap(a) || types.isWeakMap(b) ||\n"
|
|
8767
|
+
" types.isWeakSet(a) || types.isWeakSet(b)) return false;\n"
|
|
8768
|
+
" const boxed = types.isBoxedPrimitive(a);\n"
|
|
8769
|
+
" if (boxed !== types.isBoxedPrimitive(b)) return false;\n"
|
|
8770
|
+
" if (boxed) {\n"
|
|
8771
|
+
" const unbox = (v) => (types.isStringObject(v) ? String.prototype.valueOf :\n"
|
|
8772
|
+
" types.isNumberObject(v) ? Number.prototype.valueOf : types.isBooleanObject(v) ? Boolean.prototype.valueOf :\n"
|
|
8773
|
+
" types.isBigIntObject(v) ? BigInt.prototype.valueOf : Symbol.prototype.valueOf).call(v);\n"
|
|
8774
|
+
" if (!Object.is(unbox(a), unbox(b))) return false;\n"
|
|
8775
|
+
" }\n"
|
|
8776
|
+
" const error = a instanceof Error;\n"
|
|
8777
|
+
" if (error !== (b instanceof Error)) return false;\n"
|
|
8778
|
+
" if (typeof URL !== \"undefined\" && (a instanceof URL || b instanceof URL)) {\n"
|
|
8779
|
+
" if (!(a instanceof URL && b instanceof URL) || a.href !== b.href) return false;\n"
|
|
8780
|
+
" }\n"
|
|
8781
|
+
" const enumerable = (v, k) => Object.prototype.propertyIsEnumerable.call(v, k);\n"
|
|
8782
|
+
" // Typed view elements were compared by bytes. Object.is on float elements\n"
|
|
8783
|
+
" // would erase distinct NaN payloads that Node's strict comparison preserves.\n"
|
|
8784
|
+
" const keys = (v) => Reflect.ownKeys(v).filter((k) => enumerable(v, k) &&\n"
|
|
8785
|
+
" !((array || view) && typeof k === \"string\" && String(k >>> 0) === k && k !== \"4294967295\"));\n"
|
|
8786
|
+
" const keysA = keys(a);\n"
|
|
8787
|
+
" const keysB = keys(b);\n"
|
|
8788
|
+
" if (keysA.length !== keysB.length || keysA.some((k) => !enumerable(b, k))) return false;\n"
|
|
8789
|
+
" if (map || set) {\n"
|
|
8790
|
+
" if (a.size !== b.size) return false;\n"
|
|
8791
|
+
" }\n"
|
|
8792
|
+
" // Node 24's pair fast path for the first ancestor, then ancestor-set\n"
|
|
8793
|
+
" // matching at greater depth. Keep this state local to each traversal path.\n"
|
|
8794
|
+
" memos = memos || [];\n"
|
|
8795
|
+
" if (memos.length === 1) {\n"
|
|
8796
|
+
" if (memos[0][0] === a) return memos[0][1] === b;\n"
|
|
8797
|
+
" if (memos[0][1] === b) return false;\n"
|
|
8798
|
+
" } else if (memos.length > 1) {\n"
|
|
8799
|
+
" const seenA = memos.some((p) => p[0] === a || p[1] === a);\n"
|
|
8800
|
+
" const seenB = memos.some((p) => p[0] === b || p[1] === b);\n"
|
|
8801
|
+
" if (seenA || seenB) return seenA && seenB;\n"
|
|
8802
|
+
" }\n"
|
|
8803
|
+
" memos.push([a, b]);\n"
|
|
8462
8804
|
" try {\n"
|
|
8463
|
-
" if (
|
|
8464
|
-
"
|
|
8465
|
-
"
|
|
8466
|
-
" if (b.has(k)) {\n"
|
|
8467
|
-
" if (deepEquals(v, b.get(k), memos)) continue;\n"
|
|
8468
|
-
" }\n"
|
|
8469
|
-
" for (const [k2, v2] of b) {\n"
|
|
8470
|
-
" if (deepEquals(k, k2, memos) && deepEquals(v, v2, memos)) continue outer;\n"
|
|
8471
|
-
" }\n"
|
|
8472
|
-
" return false;\n"
|
|
8805
|
+
" if (error) {\n"
|
|
8806
|
+
" for (const k of [\"name\", \"message\", \"cause\", \"errors\"]) {\n"
|
|
8807
|
+
" if (!enumerable(b, k) && !deepEquals(a[k], b[k], skipPrototype, memos)) return false;\n"
|
|
8473
8808
|
" }\n"
|
|
8474
|
-
" return
|
|
8475
|
-
" }\n"
|
|
8476
|
-
"
|
|
8477
|
-
"
|
|
8478
|
-
"
|
|
8479
|
-
"
|
|
8480
|
-
"
|
|
8481
|
-
"
|
|
8482
|
-
"
|
|
8483
|
-
"
|
|
8809
|
+
" if (Object.prototype.hasOwnProperty.call(a, \"cause\") !== Object.prototype.hasOwnProperty.call(b, \"cause\")) return false;\n"
|
|
8810
|
+
" }\n"
|
|
8811
|
+
" let ordered = true;\n"
|
|
8812
|
+
" for (let i = 0; i < keysB.length; i++) {\n"
|
|
8813
|
+
" const k = keysB[i];\n"
|
|
8814
|
+
" ordered = ordered && keysA[i] === k;\n"
|
|
8815
|
+
" const descriptor = !ordered ? Object.getOwnPropertyDescriptor(a, k) : undefined;\n"
|
|
8816
|
+
" if (!ordered && (!descriptor || !descriptor.enumerable)) return false;\n"
|
|
8817
|
+
" const value = descriptor && descriptor.writable !== undefined ? descriptor.value : a[k];\n"
|
|
8818
|
+
" if (!deepEquals(value, b[k], skipPrototype, memos)) return false;\n"
|
|
8819
|
+
" }\n"
|
|
8820
|
+
" if (array) {\n"
|
|
8821
|
+
" for (let i = 0; i < a.length; i++) {\n"
|
|
8822
|
+
" if (b[i] === undefined) {\n"
|
|
8823
|
+
" if (!Object.prototype.hasOwnProperty.call(b, i)) {\n"
|
|
8824
|
+
" const indicesA = Object.keys(a);\n"
|
|
8825
|
+
" const indicesB = Object.keys(b);\n"
|
|
8826
|
+
" if (indicesA.length !== indicesB.length) return false;\n"
|
|
8827
|
+
" for (; i < indicesB.length; i++) {\n"
|
|
8828
|
+
" const k = indicesB[i];\n"
|
|
8829
|
+
" if ((a[k] === undefined && !Object.prototype.hasOwnProperty.call(a, k)) ||\n"
|
|
8830
|
+
" !deepEquals(a[k], b[k], skipPrototype, memos)) return false;\n"
|
|
8831
|
+
" }\n"
|
|
8832
|
+
" return true;\n"
|
|
8833
|
+
" }\n"
|
|
8834
|
+
" if (a[i] !== undefined || !Object.prototype.hasOwnProperty.call(a, i)) return false;\n"
|
|
8835
|
+
" } else if (a[i] === undefined || !deepEquals(a[i], b[i], skipPrototype, memos)) return false;\n"
|
|
8484
8836
|
" }\n"
|
|
8485
|
-
" return true;\n"
|
|
8486
|
-
" }\n"
|
|
8487
|
-
" const keysA = Object.keys(a);\n"
|
|
8488
|
-
" const keysB = Object.keys(b);\n"
|
|
8489
|
-
" if (keysA.length !== keysB.length) return false;\n"
|
|
8490
|
-
" for (const k of keysA) {\n"
|
|
8491
|
-
" if (!Object.prototype.propertyIsEnumerable.call(b, k)) return false;\n"
|
|
8492
|
-
" if (!deepEquals(a[k], b[k], memos)) return false;\n"
|
|
8493
8837
|
" }\n"
|
|
8494
|
-
"
|
|
8495
|
-
"
|
|
8496
|
-
"
|
|
8497
|
-
"
|
|
8498
|
-
"
|
|
8499
|
-
"
|
|
8838
|
+
" if (map || set) {\n"
|
|
8839
|
+
" const remaining = map ? Array.from(b.entries()) : Array.from(b.values());\n"
|
|
8840
|
+
" for (const item of a) {\n"
|
|
8841
|
+
" const index = remaining.findIndex((other) => map\n"
|
|
8842
|
+
" ? deepEquals(item[0], other[0], skipPrototype, memos) && deepEquals(item[1], other[1], skipPrototype, memos)\n"
|
|
8843
|
+
" : deepEquals(item, other, skipPrototype, memos));\n"
|
|
8844
|
+
" if (index === -1) return false;\n"
|
|
8845
|
+
" remaining.splice(index, 1);\n"
|
|
8846
|
+
" }\n"
|
|
8500
8847
|
" }\n"
|
|
8501
8848
|
" return true;\n"
|
|
8502
8849
|
" } finally {\n"
|
|
8503
|
-
" memos.
|
|
8504
|
-
" memos.b.delete(b);\n"
|
|
8850
|
+
" memos.pop();\n"
|
|
8505
8851
|
" }\n"
|
|
8506
8852
|
" };\n"
|
|
8507
|
-
" const isDeepStrictEqual = (a, b) => deepEquals(a, b, undefined);\n"
|
|
8508
|
-
" const ansiRe = /[\\
|
|
8853
|
+
" const isDeepStrictEqual = (a, b, skipPrototype) => deepEquals(a, b, !!skipPrototype, undefined);\n"
|
|
8854
|
+
" const ansiRe = /[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))/g;\n"
|
|
8509
8855
|
" const stripVTControlCharacters = (str) => {\n"
|
|
8510
|
-
" if (typeof str !== \"string\")
|
|
8511
|
-
" const e = new TypeError('The \"str\" argument must be of type string. Received ' + (str === null ? \"null\" : typeof str === \"object\" ? \"an instance of Object\" : typeof str === \"undefined\" ? \"undefined\" : \"type \" + typeof str));\n"
|
|
8512
|
-
" e.code = \"ERR_INVALID_ARG_TYPE\";\n"
|
|
8513
|
-
" throw e;\n"
|
|
8514
|
-
" }\n"
|
|
8856
|
+
" if (typeof str !== \"string\") envArgumentError(\"str\", \"of type string\", str);\n"
|
|
8515
8857
|
" return str.replace(ansiRe, \"\");\n"
|
|
8516
8858
|
" };\n"
|
|
8517
|
-
" const
|
|
8518
|
-
"
|
|
8519
|
-
"
|
|
8520
|
-
"
|
|
8521
|
-
"
|
|
8522
|
-
"
|
|
8523
|
-
"
|
|
8524
|
-
"
|
|
8525
|
-
"
|
|
8526
|
-
"
|
|
8527
|
-
"
|
|
8528
|
-
"
|
|
8529
|
-
"
|
|
8530
|
-
"
|
|
8531
|
-
"
|
|
8532
|
-
"
|
|
8533
|
-
"
|
|
8534
|
-
"
|
|
8535
|
-
"
|
|
8536
|
-
"
|
|
8859
|
+
" const styleAliases = { grey: 'gray', blackBright: 'gray', bgGrey: 'bgGray', bgBlackBright: 'bgGray', faint: 'dim', crossedout: 'strikethrough', strikeThrough: 'strikethrough', crossedOut: 'strikethrough', conceal: 'hidden', swapColors: 'inverse', swapcolors: 'inverse', doubleUnderline: 'doubleunderline' };\n"
|
|
8860
|
+
" for (const [name, target] of Object.entries(styleAliases)) Object.defineProperty(inspect.colors, name, {\n"
|
|
8861
|
+
" configurable: true, get: () => inspect.colors[target], set: (value) => { inspect.colors[target] = value; },\n"
|
|
8862
|
+
" });\n"
|
|
8863
|
+
" let styleCache;\n"
|
|
8864
|
+
" const getStyleCache = () => {\n"
|
|
8865
|
+
" if (styleCache === undefined) {\n"
|
|
8866
|
+
" styleCache = Object.create(null);\n"
|
|
8867
|
+
" for (const key of Object.getOwnPropertyNames(inspect.colors)) {\n"
|
|
8868
|
+
" const pair = inspect.colors[key];\n"
|
|
8869
|
+
" if (!pair) continue;\n"
|
|
8870
|
+
" styleCache[key] = { open: '\\u001b[' + pair[0] + 'm', close: '\\u001b[' + pair[1] + 'm', keepClose: pair[0] === 1 || pair[0] === 2 };\n"
|
|
8871
|
+
" }\n"
|
|
8872
|
+
" }\n"
|
|
8873
|
+
" return styleCache;\n"
|
|
8874
|
+
" };\n"
|
|
8875
|
+
" const replaceCloseCode = (text, style) => {\n"
|
|
8876
|
+
" let at = 0, index = text.indexOf(style.close), result = '';\n"
|
|
8877
|
+
" while (index !== -1 && index + style.close.length < text.length) {\n"
|
|
8878
|
+
" result += text.slice(at, index) + (style.keepClose ? style.close : '') + style.open;\n"
|
|
8879
|
+
" at = index + style.close.length;\n"
|
|
8880
|
+
" index = text.indexOf(style.close, at);\n"
|
|
8881
|
+
" }\n"
|
|
8882
|
+
" return result + text.slice(at);\n"
|
|
8883
|
+
" };\n"
|
|
8884
|
+
" let warnedColors = false;\n"
|
|
8885
|
+
" const terminalColors = () => {\n"
|
|
8886
|
+
" const e = env.env, force = e.FORCE_COLOR;\n"
|
|
8887
|
+
" if (force !== undefined) {\n"
|
|
8888
|
+
" const enabled = ['', '1', '2', '3', 'true'].includes(force);\n"
|
|
8889
|
+
" const disabled = e.NO_COLOR ? 'NO_COLOR' : e.NODE_DISABLE_COLORS ? 'NODE_DISABLE_COLORS' : undefined;\n"
|
|
8890
|
+
" if (enabled && disabled && !warnedColors) {\n"
|
|
8891
|
+
" env.emitWarning(\"The '\" + disabled + \"' env is ignored due to the 'FORCE_COLOR' env being set.\", 'Warning');\n"
|
|
8892
|
+
" warnedColors = true;\n"
|
|
8893
|
+
" }\n"
|
|
8894
|
+
" return enabled;\n"
|
|
8895
|
+
" }\n"
|
|
8896
|
+
" if (e.NO_COLOR || e.NODE_DISABLE_COLORS || e.TERM === 'dumb') return false;\n"
|
|
8897
|
+
" if (env.platform === 'win32' || e.TMUX || e.TF_BUILD !== undefined && e.AGENT_NAME !== undefined) return true;\n"
|
|
8898
|
+
" if (e.CI !== undefined) return ['APPVEYOR', 'BUILDKITE', 'CIRCLECI', 'DRONE', 'GITEA_ACTIONS', 'GITHUB_ACTIONS', 'GITLAB_CI', 'TRAVIS'].some((name) => e[name] !== undefined) || e.CI_NAME === 'codeship';\n"
|
|
8899
|
+
" if (e.TEAMCITY_VERSION !== undefined) return /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(e.TEAMCITY_VERSION);\n"
|
|
8900
|
+
" if (['iTerm.app', 'HyperTerm', 'MacTerm', 'Apple_Terminal'].includes(e.TERM_PROGRAM)) return true;\n"
|
|
8901
|
+
" if (e.COLORTERM === 'truecolor' || e.COLORTERM === '24bit') return true;\n"
|
|
8902
|
+
" if (e.TERM) {\n"
|
|
8903
|
+
" if (e.TERM.includes('truecolor') || e.TERM.startsWith('xterm-256')) return true;\n"
|
|
8904
|
+
" const term = e.TERM.toLowerCase();\n"
|
|
8905
|
+
" if (['eterm', 'cons25', 'console', 'cygwin', 'dtterm', 'gnome', 'hurd', 'jfbterm', 'konsole', 'kterm', 'mlterm', 'mosh', 'putty', 'st', 'rxvt-unicode-24bit', 'terminator', 'xterm-kitty'].includes(term) || /ansi|color|linux|direct|^con[0-9]*x[0-9]|^rxvt|^screen|^xterm|^vt100|^vt220/.test(term)) return true;\n"
|
|
8906
|
+
" }\n"
|
|
8907
|
+
" return !!e.COLORTERM;\n"
|
|
8908
|
+
" };\n"
|
|
8909
|
+
" const styleText = (format, text, options) => {\n"
|
|
8910
|
+
" const validateStream = options?.validateStream ?? true;\n"
|
|
8911
|
+
" const cache = getStyleCache();\n"
|
|
8912
|
+
" if (!validateStream && typeof format === 'string' && typeof text === 'string') {\n"
|
|
8913
|
+
" if (format === 'none') return text;\n"
|
|
8914
|
+
" const style = cache[format];\n"
|
|
8915
|
+
" if (style !== undefined) return style.open + replaceCloseCode(text, style) + style.close;\n"
|
|
8916
|
+
" }\n"
|
|
8917
|
+
" if (typeof text !== 'string') envArgumentError('text', 'of type string', text);\n"
|
|
8918
|
+
" if (options !== undefined && (options === null || typeof options !== 'object' || Array.isArray(options))) envArgumentError('options', 'of type object', options);\n"
|
|
8919
|
+
" if (typeof validateStream !== 'boolean') envArgumentError('options.validateStream', 'of type boolean', validateStream);\n"
|
|
8920
|
+
" let skipColorize = false;\n"
|
|
8921
|
+
" if (validateStream) {\n"
|
|
8922
|
+
" const stream = options?.stream ?? env.stdout;\n"
|
|
8923
|
+
" const node = stream && (stream._readableState || stream._writableState || typeof stream.write === 'function' && typeof stream.on === 'function' || typeof stream.pipe === 'function' && typeof stream.on === 'function');\n"
|
|
8924
|
+
" const readable = stream && !node && typeof stream.pipeThrough === 'function' && typeof stream.getReader === 'function' && typeof stream.cancel === 'function';\n"
|
|
8925
|
+
" const writable = stream && !node && typeof stream.getWriter === 'function' && typeof stream.abort === 'function';\n"
|
|
8926
|
+
" if (!node && !readable && !writable) envArgumentError('stream', 'an instance of ReadableStream, WritableStream, or Stream', stream);\n"
|
|
8927
|
+
" let colorize;\n"
|
|
8928
|
+
" if (env.env.FORCE_COLOR !== undefined) colorize = terminalColors();\n"
|
|
8929
|
+
" else colorize = stream?.isTTY && (typeof stream.getColorDepth === 'function' ? stream.getColorDepth() > 2 : stream === env.stdout || stream === env.stderr || stream === env.stdin ? terminalColors() : true);\n"
|
|
8930
|
+
" skipColorize = !colorize;\n"
|
|
8931
|
+
" }\n"
|
|
8932
|
+
" const formats = Array.isArray(format) ? format : [format];\n"
|
|
8933
|
+
" let open = '', close = '', processed = text;\n"
|
|
8934
|
+
" for (const key of formats) {\n"
|
|
8935
|
+
" if (key === 'none') continue;\n"
|
|
8936
|
+
" const style = cache[key];\n"
|
|
8937
|
+
" if (style === undefined && !Object.getOwnPropertyNames(inspect.colors).includes(key)) {\n"
|
|
8938
|
+
" const error = new TypeError(\"The argument 'format' must be one of: \" + Object.getOwnPropertyNames(inspect.colors).map((name) => \"'\" + name + \"'\").join(', ') + '. Received ' + inspect(key));\n"
|
|
8939
|
+
" error.code = 'ERR_INVALID_ARG_VALUE';\n"
|
|
8940
|
+
" throw error;\n"
|
|
8537
8941
|
" }\n"
|
|
8538
|
-
"
|
|
8539
|
-
"
|
|
8942
|
+
" open += style.open; close = style.close + close;\n"
|
|
8943
|
+
" processed = replaceCloseCode(processed, style);\n"
|
|
8540
8944
|
" }\n"
|
|
8541
|
-
" return
|
|
8945
|
+
" return skipColorize ? text : open + processed + close;\n"
|
|
8542
8946
|
" };\n"
|
|
8543
8947
|
" const parseArgs = (config = {}) => {\n"
|
|
8544
8948
|
" if (config === null) throw new TypeError(\"Cannot convert undefined or null to object\");\n"
|
|
@@ -8674,16 +9078,190 @@ static const char isl_modules_bootstrap[] =
|
|
|
8674
9078
|
" }\n"
|
|
8675
9079
|
" return result;\n"
|
|
8676
9080
|
" };\n"
|
|
8677
|
-
" const toUSVString = (s) =>
|
|
9081
|
+
" const toUSVString = (s) => {\n"
|
|
9082
|
+
" let primitive = s;\n"
|
|
9083
|
+
" const isObject = (v) => v !== null && (typeof v === 'object' || typeof v === 'function');\n"
|
|
9084
|
+
" if (isObject(s)) {\n"
|
|
9085
|
+
" const exotic = s[Symbol.toPrimitive];\n"
|
|
9086
|
+
" if (exotic !== undefined && exotic !== null) {\n"
|
|
9087
|
+
" if (typeof exotic !== 'function') {\n"
|
|
9088
|
+
" const kind = typeof exotic;\n"
|
|
9089
|
+
" const label = ['object', 'symbol', 'bigint'].includes(kind) ? kind : kind + ' ' + (kind === 'string' ? '\"' + exotic + '\"' : String(exotic));\n"
|
|
9090
|
+
" throw new TypeError(label + ' is not a function');\n"
|
|
9091
|
+
" }\n"
|
|
9092
|
+
" primitive = Reflect.apply(exotic, s, ['string']);\n"
|
|
9093
|
+
" if (isObject(primitive)) throw new TypeError('Cannot convert object to primitive value');\n"
|
|
9094
|
+
" } else {\n"
|
|
9095
|
+
" let converted = false;\n"
|
|
9096
|
+
" for (const name of ['toString', 'valueOf']) {\n"
|
|
9097
|
+
" const method = s[name];\n"
|
|
9098
|
+
" if (typeof method !== 'function') continue;\n"
|
|
9099
|
+
" primitive = Reflect.apply(method, s, []);\n"
|
|
9100
|
+
" if (!isObject(primitive)) { converted = true; break; }\n"
|
|
9101
|
+
" }\n"
|
|
9102
|
+
" if (!converted) throw new TypeError('Cannot convert object to primitive value');\n"
|
|
9103
|
+
" }\n"
|
|
9104
|
+
" }\n"
|
|
9105
|
+
" if (typeof primitive === 'symbol') throw new TypeError('Cannot convert a Symbol value to a string');\n"
|
|
9106
|
+
" return `${primitive}`.replace(/[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g, \"�\");\n"
|
|
9107
|
+
" };\n"
|
|
8678
9108
|
" const _extend = (target, source) => {\n"
|
|
8679
9109
|
" if (source === null || typeof source !== \"object\") return target;\n"
|
|
8680
9110
|
" for (const k of Object.keys(source)) target[k] = source[k];\n"
|
|
8681
9111
|
" return target;\n"
|
|
8682
9112
|
" };\n"
|
|
9113
|
+
" // Node 24's MIME API uses HTTP whitespace and token grammar, not Unicode trimming.\n"
|
|
9114
|
+
" const mimeInvalidToken = /[^!#$%&'*+\\-.^_`|~A-Za-z0-9]/;\n"
|
|
9115
|
+
" const mimeInvalidValue = /[^\\t\\u0020-\\u007e\\u0080-\\u00ff]/;\n"
|
|
9116
|
+
" const mimeLeadingWhitespace = /^[\\r\\n\\t ]*/;\n"
|
|
9117
|
+
" const mimeTrailingWhitespace = /[\\r\\n\\t ]*$/;\n"
|
|
9118
|
+
" const mimeLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase());\n"
|
|
9119
|
+
" const mimeError = (production, input, index) => {\n"
|
|
9120
|
+
" const error = new TypeError('The MIME syntax for a ' + production + ' in \"' + input + '\" is invalid' + (index === -1 ? '' : ' at ' + index));\n"
|
|
9121
|
+
" error.code = 'ERR_INVALID_MIME_SYNTAX';\n"
|
|
9122
|
+
" throw error;\n"
|
|
9123
|
+
" };\n"
|
|
9124
|
+
" const mimeValidateToken = (value, production, input = value) => {\n"
|
|
9125
|
+
" const index = value.search(mimeInvalidToken);\n"
|
|
9126
|
+
" if (!value.length || index !== -1) mimeError(production, input, index);\n"
|
|
9127
|
+
" };\n"
|
|
9128
|
+
" const mimeEncode = (value) => {\n"
|
|
9129
|
+
" if (value.length && value.search(mimeInvalidToken) === -1) return value;\n"
|
|
9130
|
+
" return '\"' + value.replace(/[\"\\\\]/g, (c) => '\\\\' + c) + '\"';\n"
|
|
9131
|
+
" };\n"
|
|
9132
|
+
" let mimeParamsFromSource;\n"
|
|
9133
|
+
" class MIMEParams {\n"
|
|
9134
|
+
" #data = new Map();\n"
|
|
9135
|
+
" #source = null;\n"
|
|
9136
|
+
" static {\n"
|
|
9137
|
+
" mimeParamsFromSource = (source) => {\n"
|
|
9138
|
+
" const params = new MIMEParams();\n"
|
|
9139
|
+
" params.#source = source;\n"
|
|
9140
|
+
" return params;\n"
|
|
9141
|
+
" };\n"
|
|
9142
|
+
" }\n"
|
|
9143
|
+
" #parse() {\n"
|
|
9144
|
+
" if (this.#source === null) return;\n"
|
|
9145
|
+
" const source = this.#source;\n"
|
|
9146
|
+
" const end = source.search(mimeTrailingWhitespace);\n"
|
|
9147
|
+
" let pos = 0;\n"
|
|
9148
|
+
" while (pos < end) {\n"
|
|
9149
|
+
" pos += source.slice(pos).match(mimeLeadingWhitespace)[0].length;\n"
|
|
9150
|
+
" const start = pos;\n"
|
|
9151
|
+
" while (pos < source.length && source[pos] !== ';' && source[pos] !== '=') pos++;\n"
|
|
9152
|
+
" const name = mimeLower(source.slice(start, pos));\n"
|
|
9153
|
+
" if (pos < end && source[pos++] === ';') continue;\n"
|
|
9154
|
+
" if (pos >= end) break;\n"
|
|
9155
|
+
" let value = '';\n"
|
|
9156
|
+
" if (source[pos] === '\"') {\n"
|
|
9157
|
+
" pos++;\n"
|
|
9158
|
+
" // Quoted values accept escaped characters and a missing closing quote.\n"
|
|
9159
|
+
" while (pos < source.length) {\n"
|
|
9160
|
+
" const char = source[pos++];\n"
|
|
9161
|
+
" if (char === '\"') break;\n"
|
|
9162
|
+
" value += char === '\\\\' && pos < source.length ? source[pos++] : char;\n"
|
|
9163
|
+
" }\n"
|
|
9164
|
+
" } else {\n"
|
|
9165
|
+
" const startValue = pos;\n"
|
|
9166
|
+
" while (pos < source.length && source[pos] !== ';') pos++;\n"
|
|
9167
|
+
" value = source.slice(startValue, pos).replace(mimeTrailingWhitespace, '');\n"
|
|
9168
|
+
" if (!value.length) continue;\n"
|
|
9169
|
+
" }\n"
|
|
9170
|
+
" // Parsing ignores invalid parameters and keeps the first duplicate.\n"
|
|
9171
|
+
" if (name.length && name.search(mimeInvalidToken) === -1 &&\n"
|
|
9172
|
+
" value.search(mimeInvalidValue) === -1 && !this.#data.has(name)) {\n"
|
|
9173
|
+
" this.#data.set(name, value);\n"
|
|
9174
|
+
" }\n"
|
|
9175
|
+
" pos++;\n"
|
|
9176
|
+
" }\n"
|
|
9177
|
+
" this.#source = null;\n"
|
|
9178
|
+
" }\n"
|
|
9179
|
+
" delete(name) { this.#parse(); this.#data.delete(name); }\n"
|
|
9180
|
+
" get(name) { this.#parse(); return this.#data.has(name) ? this.#data.get(name) : null; }\n"
|
|
9181
|
+
" has(name) { this.#parse(); return this.#data.has(name); }\n"
|
|
9182
|
+
" set(name, value) {\n"
|
|
9183
|
+
" this.#parse();\n"
|
|
9184
|
+
" name = `${name}`;\n"
|
|
9185
|
+
" value = `${value}`;\n"
|
|
9186
|
+
" mimeValidateToken(name, 'parameter name');\n"
|
|
9187
|
+
" const index = value.search(mimeInvalidValue);\n"
|
|
9188
|
+
" if (index !== -1) mimeError('parameter value', value, index);\n"
|
|
9189
|
+
" this.#data.set(name, value);\n"
|
|
9190
|
+
" }\n"
|
|
9191
|
+
" *entries() { this.#parse(); yield* this.#data.entries(); }\n"
|
|
9192
|
+
" *keys() { this.#parse(); yield* this.#data.keys(); }\n"
|
|
9193
|
+
" *values() { this.#parse(); yield* this.#data.values(); }\n"
|
|
9194
|
+
" toString() {\n"
|
|
9195
|
+
" this.#parse();\n"
|
|
9196
|
+
" let result = '';\n"
|
|
9197
|
+
" for (const [name, value] of this.#data) {\n"
|
|
9198
|
+
" if (result.length) result += ';';\n"
|
|
9199
|
+
" result += name + '=' + mimeEncode(value);\n"
|
|
9200
|
+
" }\n"
|
|
9201
|
+
" return result;\n"
|
|
9202
|
+
" }\n"
|
|
9203
|
+
" }\n"
|
|
9204
|
+
" const mimeParamsStringify = MIMEParams.prototype.toString;\n"
|
|
9205
|
+
" Object.defineProperty(MIMEParams.prototype, Symbol.iterator, {\n"
|
|
9206
|
+
" value: MIMEParams.prototype.entries, writable: true, configurable: true,\n"
|
|
9207
|
+
" });\n"
|
|
9208
|
+
" Object.defineProperty(MIMEParams.prototype, 'toJSON', {\n"
|
|
9209
|
+
" value: mimeParamsStringify, writable: true, configurable: true,\n"
|
|
9210
|
+
" });\n"
|
|
9211
|
+
" class MIMEType {\n"
|
|
9212
|
+
" #type;\n"
|
|
9213
|
+
" #subtype;\n"
|
|
9214
|
+
" #params;\n"
|
|
9215
|
+
" constructor(input) {\n"
|
|
9216
|
+
" input = `${input}`;\n"
|
|
9217
|
+
" const start = input.match(mimeLeadingWhitespace)[0].length;\n"
|
|
9218
|
+
" const slash = input.indexOf('/', start);\n"
|
|
9219
|
+
" const type = input.slice(start, slash === -1 ? input.length : slash);\n"
|
|
9220
|
+
" mimeValidateToken(type, 'type', input);\n"
|
|
9221
|
+
" if (slash === -1) mimeError('type', input, -1);\n"
|
|
9222
|
+
" const semicolon = input.indexOf(';', slash + 1);\n"
|
|
9223
|
+
" const subtype = input.slice(slash + 1, semicolon === -1 ? input.length : semicolon).replace(mimeTrailingWhitespace, '');\n"
|
|
9224
|
+
" mimeValidateToken(subtype, 'subtype', input);\n"
|
|
9225
|
+
" this.#type = mimeLower(type);\n"
|
|
9226
|
+
" this.#subtype = mimeLower(subtype);\n"
|
|
9227
|
+
" this.#params = mimeParamsFromSource(semicolon === -1 ? '' : input.slice(semicolon + 1));\n"
|
|
9228
|
+
" }\n"
|
|
9229
|
+
" get type() { return this.#type; }\n"
|
|
9230
|
+
" set type(value) {\n"
|
|
9231
|
+
" value = `${value}`;\n"
|
|
9232
|
+
" mimeValidateToken(value, 'type');\n"
|
|
9233
|
+
" this.#type = mimeLower(value);\n"
|
|
9234
|
+
" }\n"
|
|
9235
|
+
" get subtype() { return this.#subtype; }\n"
|
|
9236
|
+
" set subtype(value) {\n"
|
|
9237
|
+
" value = `${value}`;\n"
|
|
9238
|
+
" mimeValidateToken(value, 'subtype');\n"
|
|
9239
|
+
" this.#subtype = mimeLower(value);\n"
|
|
9240
|
+
" }\n"
|
|
9241
|
+
" get essence() { return this.#type + '/' + this.#subtype; }\n"
|
|
9242
|
+
" get params() { return this.#params; }\n"
|
|
9243
|
+
" toString() {\n"
|
|
9244
|
+
" // Capture the serializer so user overrides cannot change MIME serialization.\n"
|
|
9245
|
+
" const params = mimeParamsStringify.call(this.#params);\n"
|
|
9246
|
+
" return this.#type + '/' + this.#subtype + (params.length ? ';' + params : '');\n"
|
|
9247
|
+
" }\n"
|
|
9248
|
+
" }\n"
|
|
9249
|
+
" Object.defineProperty(MIMEType.prototype, 'toJSON', {\n"
|
|
9250
|
+
" value: MIMEType.prototype.toString, writable: true, configurable: true,\n"
|
|
9251
|
+
" });\n"
|
|
8683
9252
|
" const util = {\n"
|
|
9253
|
+
" getSystemErrorMap: () => new Map(host.systemErrorEntries()),\n"
|
|
9254
|
+
" getSystemErrorName: (err) => {\n"
|
|
9255
|
+
" if (typeof err !== 'number') envArgumentError('err', 'of type number', err);\n"
|
|
9256
|
+
" return host.systemErrorInfo(err, false);\n"
|
|
9257
|
+
" },\n"
|
|
9258
|
+
" getSystemErrorMessage: (err) => {\n"
|
|
9259
|
+
" if (typeof err !== 'number') envArgumentError('err', 'of type number', err);\n"
|
|
9260
|
+
" return host.systemErrorInfo(err, true);\n"
|
|
9261
|
+
" },\n"
|
|
8684
9262
|
" format, formatWithOptions, inspect, inherits, promisify, callbackify,\n"
|
|
8685
9263
|
" deprecate, debuglog, debug: debuglog, types, isDeepStrictEqual,\n"
|
|
8686
|
-
" stripVTControlCharacters, styleText, parseArgs, toUSVString, _extend,\n"
|
|
9264
|
+
" stripVTControlCharacters, styleText, parseArgs, toUSVString, _extend, MIMEType, MIMEParams,\n"
|
|
8687
9265
|
" parseEnv: (content) => {\n"
|
|
8688
9266
|
" if (typeof content !== 'string') envArgumentError('content', 'of type string', content);\n"
|
|
8689
9267
|
" return host.parseEnv(toUSVString(content));\n"
|
|
@@ -8694,6 +9272,7 @@ static const char isl_modules_bootstrap[] =
|
|
|
8694
9272
|
" return util;\n"
|
|
8695
9273
|
"}\n"
|
|
8696
9274
|
" const util = makeUtil({\n"
|
|
9275
|
+
" typeProbe: host.typeProbe,\n"
|
|
8697
9276
|
" promiseState: (p) => host.promiseState(p),\n"
|
|
8698
9277
|
" writeErr: (s) => host.write(2, s),\n"
|
|
8699
9278
|
" env: builtins.process().env,\n"
|
|
@@ -8708,7 +9287,6 @@ static const char isl_modules_bootstrap[] =
|
|
|
8708
9287
|
* same object; require('util/types') === require('util').types). */
|
|
8709
9288
|
" builtins['util/types'] = memo(() => {\n"
|
|
8710
9289
|
" const t = builtins.util().types;\n"
|
|
8711
|
-
" t.default = t;\n"
|
|
8712
9290
|
" return t;\n"
|
|
8713
9291
|
" });\n"
|
|
8714
9292
|
" builtins.child_process = memo(() => {\n"
|
|
@@ -10133,7 +10711,8 @@ static const char isl_modules_bootstrap[] =
|
|
|
10133
10711
|
" const spec = String(raw);\n"
|
|
10134
10712
|
" const bare = spec.startsWith('node:') ? spec.slice(5) : spec;\n"
|
|
10135
10713
|
" if (builtinModules.includes(bare) && (spec.startsWith('node:') || bare !== 'test')) return 'node:' + bare;\n"
|
|
10136
|
-
" const
|
|
10714
|
+
" const filePath = (s) => s.startsWith('/') || /^[A-Za-z]:[\\\\/]/.test(s) || s.startsWith('\\\\\\\\');\n"
|
|
10715
|
+
" const base = filePath(from) ? host.urlFromPath(from) : from;\n"
|
|
10137
10716
|
" if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(spec) || spec.startsWith('./') || spec.startsWith('../') || spec.startsWith('/')) {\n"
|
|
10138
10717
|
" return new URL(spec, base).href;\n"
|
|
10139
10718
|
" }\n"
|
|
@@ -10143,7 +10722,7 @@ static const char isl_modules_bootstrap[] =
|
|
|
10143
10722
|
" err.code = 'ERR_MODULE_NOT_FOUND';\n"
|
|
10144
10723
|
" throw err;\n"
|
|
10145
10724
|
" }\n"
|
|
10146
|
-
" return to
|
|
10725
|
+
" return filePath(to) ? host.urlFromPath(to) : to;\n"
|
|
10147
10726
|
" };\n"
|
|
10148
10727
|
" return (key, name) => {\n"
|
|
10149
10728
|
" const exports = requireKey(key);\n"
|
|
@@ -10175,6 +10754,7 @@ static void isl_modules_boot(void) {
|
|
|
10175
10754
|
abort();
|
|
10176
10755
|
}
|
|
10177
10756
|
JSValue host = JS_NewObject(isl_ctx);
|
|
10757
|
+
JS_SetPropertyStr(isl_ctx, host, "typeProbe", JS_NewCFunction(isl_ctx, isl_host_type_probe, "typeProbe", 2));
|
|
10178
10758
|
/* JS_SetPropertyStr consumes the function values. */
|
|
10179
10759
|
JS_SetPropertyStr(isl_ctx, host, "source", JS_NewCFunction(isl_ctx, isl_host_source, "source", 1));
|
|
10180
10760
|
JS_SetPropertyStr(isl_ctx, host, "resolve", JS_NewCFunction(isl_ctx, isl_host_resolve, "resolve", 2));
|
|
@@ -10185,6 +10765,8 @@ static void isl_modules_boot(void) {
|
|
|
10185
10765
|
JS_SetPropertyStr(isl_ctx, host, "envSet", JS_NewCFunction(isl_ctx, isl_host_env_set, "envSet", 2));
|
|
10186
10766
|
JS_SetPropertyStr(isl_ctx, host, "envDelete", JS_NewCFunction(isl_ctx, isl_host_env_delete, "envDelete", 1));
|
|
10187
10767
|
JS_SetPropertyStr(isl_ctx, host, "parseEnv", JS_NewCFunction(isl_ctx, isl_host_parse_env, "parseEnv", 1));
|
|
10768
|
+
JS_SetPropertyStr(isl_ctx, host, "systemErrorEntries", JS_NewCFunction(isl_ctx, isl_host_system_error_entries, "systemErrorEntries", 0));
|
|
10769
|
+
JS_SetPropertyStr(isl_ctx, host, "systemErrorInfo", JS_NewCFunction(isl_ctx, isl_host_system_error_info, "systemErrorInfo", 2));
|
|
10188
10770
|
JS_SetPropertyStr(isl_ctx, host, "transcode", JS_NewCFunction(isl_ctx, isl_host_transcode, "transcode", 3));
|
|
10189
10771
|
JS_SetPropertyStr(isl_ctx, host, "loadEnvFile", JS_NewCFunction(isl_ctx, isl_host_load_env_file, "loadEnvFile", 2));
|
|
10190
10772
|
JS_SetPropertyStr(isl_ctx, host, "write", JS_NewCFunction(isl_ctx, isl_host_write, "write", 2));
|
|
@@ -10209,8 +10791,9 @@ static void isl_modules_boot(void) {
|
|
|
10209
10791
|
JS_SetPropertyStr(isl_ctx, host, "fs", JS_NewCFunction(isl_ctx, isl_host_fs, "fs", 4));
|
|
10210
10792
|
JS_SetPropertyStr(isl_ctx, host, "fsConstants", JS_NewCFunction(isl_ctx, isl_host_fs_constants, "fsConstants", 0));
|
|
10211
10793
|
JS_SetPropertyStr(isl_ctx, host, "path", JS_NewCFunction(isl_ctx, isl_host_path, "path", 4));
|
|
10212
|
-
JS_SetPropertyStr(isl_ctx, host, "urlToPath", JS_NewCFunction(isl_ctx, isl_host_url_to_path, "urlToPath",
|
|
10213
|
-
JS_SetPropertyStr(isl_ctx, host, "
|
|
10794
|
+
JS_SetPropertyStr(isl_ctx, host, "urlToPath", JS_NewCFunction(isl_ctx, isl_host_url_to_path, "urlToPath", 2));
|
|
10795
|
+
JS_SetPropertyStr(isl_ctx, host, "urlToPathBuffer", JS_NewCFunction(isl_ctx, isl_host_url_to_path_buffer, "urlToPathBuffer", 2));
|
|
10796
|
+
JS_SetPropertyStr(isl_ctx, host, "urlFromPath", JS_NewCFunction(isl_ctx, isl_host_url_from_path, "urlFromPath", 2));
|
|
10214
10797
|
JS_SetPropertyStr(isl_ctx, host, "hrtime", JS_NewCFunction(isl_ctx, isl_host_hrtime, "hrtime", 0));
|
|
10215
10798
|
JS_SetPropertyStr(isl_ctx, host, "versions", JS_NewCFunction(isl_ctx, isl_host_versions, "versions", 0));
|
|
10216
10799
|
JS_SetPropertyStr(isl_ctx, host, "ids", JS_NewCFunction(isl_ctx, isl_host_ids, "ids", 0));
|
|
@@ -10587,33 +11170,11 @@ ScrJsval *scr_jsval_from_bytes(const ScrBytes *b) {
|
|
|
10587
11170
|
* installs a minimal class: construction re-parses through the SAME
|
|
10588
11171
|
* WHATWG parser the static URL uses (scr_url.c, via a host function), so
|
|
10589
11172
|
* a marshaled URL and `new URL(href)` in embedded code agree exactly.
|
|
10590
|
-
*
|
|
10591
|
-
*
|
|
10592
|
-
* TypeError instead of silently diverging from the live re-serializing
|
|
10593
|
-
* accessors a real URL has (SEMANTICS.md). If a URL global already exists
|
|
11173
|
+
* Component reads and writes share the native parser and setter
|
|
11174
|
+
* state overrides. If a URL global already exists
|
|
10594
11175
|
* (a future web-prelude one, or embedded code's own), it wins — the
|
|
10595
11176
|
* marshal constructs through whatever globalThis.URL is. */
|
|
10596
|
-
static JSValue
|
|
10597
|
-
int argc, JSValueConst *argv) {
|
|
10598
|
-
(void)this_val;
|
|
10599
|
-
if (argc < 1) return JS_ThrowTypeError(ctx, "Invalid URL");
|
|
10600
|
-
ScrStr *in = isl_arg_str(ctx, argv[0]);
|
|
10601
|
-
if (!in) return JS_EXCEPTION;
|
|
10602
|
-
ScrStr *base = argc > 1 && !JS_IsUndefined(argv[1]) ? isl_arg_str(ctx, argv[1]) : NULL;
|
|
10603
|
-
if (argc > 1 && !JS_IsUndefined(argv[1]) && !base) {
|
|
10604
|
-
scr_str_release(in);
|
|
10605
|
-
return JS_EXCEPTION;
|
|
10606
|
-
}
|
|
10607
|
-
ScrUrl *u = base ? scr_url_new_base(in, base) : scr_url_new(in);
|
|
10608
|
-
scr_str_release(in);
|
|
10609
|
-
scr_str_release(base);
|
|
10610
|
-
if (!u) {
|
|
10611
|
-
if (argc > 2 && JS_ToBool(ctx, argv[2])) {
|
|
10612
|
-
scr_exc_clear();
|
|
10613
|
-
return JS_NULL;
|
|
10614
|
-
}
|
|
10615
|
-
return isl_throw_pending(ctx);
|
|
10616
|
-
}
|
|
11177
|
+
static JSValue isl_url_components(JSContext *ctx, ScrUrl *u) {
|
|
10617
11178
|
ScrStr *href = scr_url_href(u);
|
|
10618
11179
|
ScrStr *protocol = scr_url_protocol(u);
|
|
10619
11180
|
ScrStr *pathname = scr_url_pathname(u);
|
|
@@ -10652,14 +11213,61 @@ static JSValue isl_url_parse_host(JSContext *ctx, JSValueConst this_val,
|
|
|
10652
11213
|
return arr;
|
|
10653
11214
|
}
|
|
10654
11215
|
|
|
11216
|
+
static JSValue isl_url_parse_host(JSContext *ctx, JSValueConst this_val,
|
|
11217
|
+
int argc, JSValueConst *argv) {
|
|
11218
|
+
(void)this_val;
|
|
11219
|
+
if (argc < 1) return JS_ThrowTypeError(ctx, "Invalid URL");
|
|
11220
|
+
ScrStr *in = isl_arg_str(ctx, argv[0]);
|
|
11221
|
+
if (!in) return JS_EXCEPTION;
|
|
11222
|
+
ScrStr *base = argc > 1 && !JS_IsUndefined(argv[1]) ? isl_arg_str(ctx, argv[1]) : NULL;
|
|
11223
|
+
if (argc > 1 && !JS_IsUndefined(argv[1]) && !base) {
|
|
11224
|
+
scr_str_release(in);
|
|
11225
|
+
return JS_EXCEPTION;
|
|
11226
|
+
}
|
|
11227
|
+
ScrUrl *u = base ? scr_url_new_base(in, base) : scr_url_new(in);
|
|
11228
|
+
scr_str_release(in);
|
|
11229
|
+
scr_str_release(base);
|
|
11230
|
+
if (!u) {
|
|
11231
|
+
if (argc > 2 && JS_ToBool(ctx, argv[2])) {
|
|
11232
|
+
scr_exc_clear();
|
|
11233
|
+
return JS_NULL;
|
|
11234
|
+
}
|
|
11235
|
+
return isl_throw_pending(ctx);
|
|
11236
|
+
}
|
|
11237
|
+
return isl_url_components(ctx, u);
|
|
11238
|
+
}
|
|
11239
|
+
|
|
11240
|
+
static JSValue isl_url_set_host(JSContext *ctx, JSValueConst this_val,
|
|
11241
|
+
int argc, JSValueConst *argv) {
|
|
11242
|
+
(void)this_val;
|
|
11243
|
+
if (argc < 3) return JS_ThrowTypeError(ctx, "Invalid URL");
|
|
11244
|
+
ScrStr *href = isl_arg_str(ctx, argv[0]);
|
|
11245
|
+
if (!href) return JS_EXCEPTION;
|
|
11246
|
+
ScrStr *field = isl_arg_str(ctx, argv[1]);
|
|
11247
|
+
if (!field) { scr_str_release(href); return JS_EXCEPTION; }
|
|
11248
|
+
ScrStr *value = isl_arg_str(ctx, argv[2]);
|
|
11249
|
+
if (!value) { scr_str_release(href); scr_str_release(field); return JS_EXCEPTION; }
|
|
11250
|
+
ScrUrl *u = scr_url_new(href);
|
|
11251
|
+
scr_str_release(href);
|
|
11252
|
+
bool applied = u && scr_url_set_component(u, field, value);
|
|
11253
|
+
scr_str_release(field);
|
|
11254
|
+
scr_str_release(value);
|
|
11255
|
+
if (!u || scr_exc_pending()) {
|
|
11256
|
+
scr_url_release(u);
|
|
11257
|
+
return isl_throw_pending(ctx);
|
|
11258
|
+
}
|
|
11259
|
+
if (!applied) { scr_url_release(u); return JS_NULL; }
|
|
11260
|
+
return isl_url_components(ctx, u);
|
|
11261
|
+
}
|
|
11262
|
+
|
|
10655
11263
|
static const char isl_url_src[] =
|
|
10656
|
-
"(function (parse) {\n"
|
|
11264
|
+
"(function (parse, mutate) {\n"
|
|
10657
11265
|
" 'use strict';\n"
|
|
10658
|
-
" const def = (o, n, v) => Object.defineProperty(o, n, { value: v, enumerable: true });\n"
|
|
10659
11266
|
" const text = (v) => {\n"
|
|
10660
11267
|
" if (typeof v === 'symbol') throw new TypeError('Cannot convert a Symbol value to a string');\n"
|
|
10661
11268
|
" return `${v}`;\n"
|
|
10662
11269
|
" };\n"
|
|
11270
|
+
" const fields = ['href', 'protocol', 'pathname', 'host', 'hostname', 'search', 'origin', 'username', 'password', 'hash', 'port'];\n"
|
|
10663
11271
|
" class URL {\n"
|
|
10664
11272
|
" constructor(input, base) {\n"
|
|
10665
11273
|
" if (arguments.length === 0) throw URL._missing();\n"
|
|
@@ -10673,70 +11281,43 @@ static const char isl_url_src[] =
|
|
|
10673
11281
|
" return error;\n"
|
|
10674
11282
|
" }\n"
|
|
10675
11283
|
" _init(c) {\n"
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
"
|
|
10683
|
-
"
|
|
10684
|
-
"
|
|
10685
|
-
"
|
|
10686
|
-
"
|
|
10687
|
-
"
|
|
10688
|
-
"
|
|
10689
|
-
"
|
|
10690
|
-
"
|
|
10691
|
-
"
|
|
10692
|
-
"
|
|
10693
|
-
"
|
|
10694
|
-
"
|
|
10695
|
-
"
|
|
10696
|
-
"
|
|
10697
|
-
" def(this, 'protocol', c[1]);\n"
|
|
10698
|
-
" def(this, 'pathname', c[2]);\n"
|
|
10699
|
-
" def(this, 'host', c[3]);\n"
|
|
10700
|
-
" def(this, 'hostname', c[4]);\n"
|
|
10701
|
-
" def(this, 'origin', c[6]);\n"
|
|
10702
|
-
" def(this, 'username', c[7]);\n"
|
|
10703
|
-
" def(this, 'password', c[8]);\n"
|
|
10704
|
-
" def(this, 'hash', c[9]);\n"
|
|
10705
|
-
" def(this, 'port', c[10]);\n"
|
|
10706
|
-
" }\n"
|
|
10707
|
-
/* The search half of the live coupling: normalize the assigned
|
|
10708
|
-
* query, splice it into href between the pre-query part and the
|
|
10709
|
-
* fragment. */
|
|
10710
|
-
" _applySearch(v) {\n"
|
|
10711
|
-
" let s = String(v);\n"
|
|
10712
|
-
" if (s !== '' && !s.startsWith('?')) s = '?' + s;\n"
|
|
10713
|
-
" if (s === '?') s = '';\n"
|
|
10714
|
-
" const base = this._href.split('#')[0].split('?')[0];\n"
|
|
10715
|
-
" this._search = s;\n"
|
|
10716
|
-
" this._href = base + s + this.hash;\n"
|
|
10717
|
-
" }\n"
|
|
10718
|
-
/* searchParams: ONE URLSearchParams per URL (identity stable, like
|
|
10719
|
-
* the spec) whose mutators — append/set/delete/sort — write the
|
|
10720
|
-
* serialized list back into search/href. Reads AND writes agree with
|
|
10721
|
-
* Node for the query component; the other components stay parse-time
|
|
10722
|
-
* snapshots. */
|
|
11284
|
+
" Object.defineProperty(this, '_components', { value: c, writable: true });\n"
|
|
11285
|
+
" for (let i = 0; i < fields.length; i++) {\n"
|
|
11286
|
+
" const name = fields[i];\n"
|
|
11287
|
+
" const descriptor = { enumerable: true, get: () => this._components[i] };\n"
|
|
11288
|
+
" if (name !== 'origin') descriptor.set = (v) => this._set(name, v);\n"
|
|
11289
|
+
" Object.defineProperty(this, name, descriptor);\n"
|
|
11290
|
+
" }\n"
|
|
11291
|
+
" }\n"
|
|
11292
|
+
" _set(name, value) {\n"
|
|
11293
|
+
" const href = this.href;\n"
|
|
11294
|
+
" const ignored = name === 'pathname' && !href.slice(this.protocol.length).startsWith('/');\n"
|
|
11295
|
+
" const converted = text(value);\n"
|
|
11296
|
+
" if (ignored) return;\n"
|
|
11297
|
+
" const components = mutate(name === 'href' ? this.href : href, name, converted);\n"
|
|
11298
|
+
" if (components === null) return;\n"
|
|
11299
|
+
" this._components = components;\n"
|
|
11300
|
+
" if ((name === 'search' || name === 'href') && this._sp !== undefined) {\n"
|
|
11301
|
+
" this._sp._pairs.length = 0;\n"
|
|
11302
|
+
" for (const [k, v] of new globalThis.URLSearchParams(this.search)) this._sp._pairs.push([k, v]);\n"
|
|
11303
|
+
" }\n"
|
|
11304
|
+
" }\n"
|
|
10723
11305
|
" get searchParams() {\n"
|
|
10724
11306
|
" if (this._sp === undefined) {\n"
|
|
10725
11307
|
" const sp = new globalThis.URLSearchParams(this.search);\n"
|
|
10726
11308
|
" const sync = () => {\n"
|
|
10727
11309
|
" const q = sp.toString();\n"
|
|
10728
|
-
" this.
|
|
11310
|
+
" this._set('search', q === '' ? '' : '?' + q);\n"
|
|
10729
11311
|
" };\n"
|
|
10730
11312
|
" for (const m of ['append', 'set', 'delete', 'sort']) {\n"
|
|
10731
11313
|
" const orig = sp[m].bind(sp);\n"
|
|
10732
|
-
" Object.defineProperty(sp, m, {
|
|
10733
|
-
" value: (...args) => { const r = orig(...args); sync(); return r; },\n"
|
|
10734
|
-
" });\n"
|
|
11314
|
+
" Object.defineProperty(sp, m, { value: (...args) => { const r = orig(...args); sync(); return r; } });\n"
|
|
10735
11315
|
" }\n"
|
|
10736
11316
|
" Object.defineProperty(this, '_sp', { value: sp });\n"
|
|
10737
11317
|
" }\n"
|
|
10738
11318
|
" return this._sp;\n"
|
|
10739
11319
|
" }\n"
|
|
11320
|
+
" get href() { throw new TypeError('Receiver must be an instance of class URL'); }\n"
|
|
10740
11321
|
" toString() { return this.href; }\n"
|
|
10741
11322
|
" toJSON() { return this.href; }\n"
|
|
10742
11323
|
" static canParse(input, base) {\n"
|
|
@@ -10773,7 +11354,10 @@ static void isl_install_url_class(void) {
|
|
|
10773
11354
|
abort(); /* fixed source; failing to parse is a build defect */
|
|
10774
11355
|
}
|
|
10775
11356
|
JSValue parse = JS_NewCFunction(isl_ctx, isl_url_parse_host, "__scr_url_parse", 3);
|
|
10776
|
-
JSValue
|
|
11357
|
+
JSValue mutate = JS_NewCFunction(isl_ctx, isl_url_set_host, "__scr_url_set", 3);
|
|
11358
|
+
JSValue args[2] = {parse, mutate};
|
|
11359
|
+
JSValue r = JS_Call(isl_ctx, installer, JS_UNDEFINED, 2, args);
|
|
11360
|
+
JS_FreeValue(isl_ctx, mutate);
|
|
10777
11361
|
JS_FreeValue(isl_ctx, parse);
|
|
10778
11362
|
JS_FreeValue(isl_ctx, installer);
|
|
10779
11363
|
if (JS_IsException(r)) {
|