-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathBunObject.cpp
More file actions
1188 lines (1019 loc) · 61.1 KB
/
BunObject.cpp
File metadata and controls
1188 lines (1019 loc) · 61.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "root.h"
#include "JavaScriptCore/HeapProfiler.h"
#include <JavaScriptCore/HeapSnapshotBuilder.h>
#include "ZigGlobalObject.h"
#include "JavaScriptCore/ArgList.h"
#include "JSDOMURL.h"
#include "helpers.h"
#include "IDLTypes.h"
#include "DOMURL.h"
#include <JavaScriptCore/JSPromise.h>
#include <JavaScriptCore/JSBase.h>
#include <JavaScriptCore/BuiltinNames.h>
#include "ScriptExecutionContext.h"
#include "WebCoreJSClientData.h"
#include <JavaScriptCore/JSFunction.h>
#include <JavaScriptCore/InternalFunction.h>
#include <JavaScriptCore/LazyClassStructure.h>
#include <JavaScriptCore/LazyClassStructureInlines.h>
#include <JavaScriptCore/FunctionPrototype.h>
#include <JavaScriptCore/DateInstance.h>
#include <JavaScriptCore/JSONObject.h>
#include "wtf/SIMDUTF.h"
#include <JavaScriptCore/ObjectConstructor.h>
#include "headers.h"
#include "BunObject.h"
#include "WebCoreJSBuiltins.h"
#include <JavaScriptCore/JSObject.h>
#include "DOMJITIDLConvert.h"
#include "DOMJITIDLType.h"
#include "DOMJITIDLTypeFilter.h"
#include "Exception.h"
#include "JSDOMException.h"
#include "JSDOMConvert.h"
#include "wtf/Compiler.h"
#include "PathInlines.h"
#include "wtf/text/ASCIILiteral.h"
#include "BunObject+exports.h"
#include "ErrorCode.h"
#include "GeneratedBunObject.h"
#include "JavaScriptCore/BunV8HeapSnapshotBuilder.h"
#include "BunObjectModule.h"
#include "JSCookie.h"
#include "JSCookieMap.h"
#include "Secrets.h"
#ifdef WIN32
#include <ws2def.h>
#else
#include <netdb.h>
#endif
extern "C" size_t Bun__Feature__heap_snapshot;
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__lookup);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolve);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveSrv);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveTxt);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveSoa);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveNaptr);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveMx);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveCaa);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveNs);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolvePtr);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveCname);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__resolveAny);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__getServers);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__setServers);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__reverse);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__lookupService);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__prefetch);
BUN_DECLARE_HOST_FUNCTION(Bun__DNS__getCacheStats);
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__new);
BUN_DECLARE_HOST_FUNCTION(Bun__DNSResolver__cancel);
BUN_DECLARE_HOST_FUNCTION(Bun__fetch);
BUN_DECLARE_HOST_FUNCTION(Bun__fetchPreconnect);
BUN_DECLARE_HOST_FUNCTION(Bun__randomUUIDv7);
BUN_DECLARE_HOST_FUNCTION(Bun__randomUUIDv5);
namespace Bun {
JSC_DECLARE_HOST_FUNCTION(jsFunctionBunStripANSI);
JSC_DECLARE_HOST_FUNCTION(jsFunctionBunWrapAnsi);
}
using namespace JSC;
using namespace WebCore;
namespace Bun {
extern "C" bool has_bun_garbage_collector_flag_enabled;
static JSValue BunObject_lazyPropCb_wrap_ArrayBufferSink(VM& vm, JSObject* bunObject)
{
return jsCast<Zig::GlobalObject*>(bunObject->globalObject())->ArrayBufferSink();
}
static JSValue constructCookieObject(VM& vm, JSObject* bunObject);
static JSValue constructCookieMapObject(VM& vm, JSObject* bunObject);
static JSValue constructSecretsObject(VM& vm, JSObject* bunObject);
static JSValue constructEnvObject(VM& vm, JSObject* object)
{
return jsCast<Zig::GlobalObject*>(object->globalObject())->processEnvObject();
}
static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBufferOrUint8Array(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue, size_t maxLength, bool asUint8Array)
{
auto& vm = JSC::getVM(lexicalGlobalObject);
if (arrayValue.isUndefinedOrNull() || !arrayValue) {
return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1)));
}
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto array = JSC::jsDynamicCast<JSC::JSArray*>(arrayValue);
if (!array) [[unlikely]] {
throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s);
return {};
}
size_t arrayLength = array->length();
const auto returnEmptyArrayBufferView = [&]() -> EncodedJSValue {
if (asUint8Array) {
RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->m_typedArrayUint8.get(lexicalGlobalObject), 0)));
}
RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
};
RETURN_IF_EXCEPTION(throwScope, {});
if (arrayLength < 1) {
return returnEmptyArrayBufferView();
}
size_t byteLength = 0;
bool any_buffer = false;
bool any_typed = false;
// Use an argument buffer to avoid calling `getIndex` more than once per element.
// This is a small optimization
MarkedArgumentBuffer args;
args.ensureCapacity(arrayLength);
if (args.hasOverflowed()) [[unlikely]] {
throwOutOfMemoryError(lexicalGlobalObject, throwScope);
return {};
}
for (size_t i = 0; i < arrayLength; i++) {
auto element = array->getIndex(lexicalGlobalObject, i);
RETURN_IF_EXCEPTION(throwScope, {});
if (auto* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(element)) {
if (typedArray->isDetached()) [[unlikely]] {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, "Cannot validate on a detached buffer"_s);
}
size_t current = typedArray->byteLength();
any_typed = true;
byteLength += current;
if (current > 0) {
args.append(typedArray);
}
} else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
auto* impl = arrayBuffer->impl();
if (!impl) [[unlikely]] {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject, "Cannot validate on a detached buffer"_s);
}
size_t current = impl->byteLength();
any_buffer = true;
if (current > 0) {
args.append(arrayBuffer);
}
byteLength += current;
} else {
throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s);
return {};
}
}
byteLength = std::min(byteLength, maxLength);
if (byteLength == 0) {
return returnEmptyArrayBufferView();
}
auto buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1);
if (!buffer) [[unlikely]] {
throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s);
return {};
}
size_t remain = byteLength;
auto* head = reinterpret_cast<char*>(buffer->data());
if (!any_buffer) {
for (size_t i = 0; i < args.size(); i++) {
auto element = args.at(i);
RETURN_IF_EXCEPTION(throwScope, {});
auto* view = JSC::jsCast<JSC::JSArrayBufferView*>(element);
size_t length = std::min(remain, view->byteLength());
memcpy(head, view->vector(), length);
remain -= length;
head += length;
}
} else if (!any_typed) {
for (size_t i = 0; i < args.size(); i++) {
auto element = args.at(i);
RETURN_IF_EXCEPTION(throwScope, {});
auto* view = JSC::jsCast<JSC::JSArrayBuffer*>(element);
size_t length = std::min(remain, view->impl()->byteLength());
memcpy(head, view->impl()->data(), length);
remain -= length;
head += length;
}
} else {
for (size_t i = 0; i < args.size(); i++) {
auto element = args.at(i);
RETURN_IF_EXCEPTION(throwScope, {});
size_t length = 0;
if (auto* view = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
length = std::min(remain, view->impl()->byteLength());
memcpy(head, view->impl()->data(), length);
} else {
auto* typedArray = JSC::jsCast<JSC::JSArrayBufferView*>(element);
length = std::min(remain, typedArray->byteLength());
memcpy(head, typedArray->vector(), length);
}
remain -= length;
head += length;
}
}
if (asUint8Array) {
auto uint8array = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->m_typedArrayUint8.get(lexicalGlobalObject), WTF::move(buffer), 0, byteLength);
RETURN_IF_EXCEPTION(throwScope, {});
return JSValue::encode(uint8array);
}
RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), WTF::move(buffer))));
}
JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto& vm = JSC::getVM(globalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
if (callFrame->argumentCount() < 1) [[unlikely]] {
throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
return {};
}
auto arrayValue = callFrame->uncheckedArgument(0);
size_t maxLength = std::numeric_limits<size_t>::max();
auto arg1 = callFrame->argument(1);
if (!arg1.isUndefined() && arg1.isNumber()) {
double number = arg1.toNumber(globalObject);
if (std::isnan(number) || number < 0) {
throwRangeError(globalObject, throwScope, "Maximum length must be >= 0"_s);
return {};
}
if (!std::isinf(number)) {
maxLength = arg1.toUInt32(globalObject);
}
}
bool asUint8Array = false;
auto arg2 = callFrame->argument(2);
if (!arg2.isUndefined()) {
asUint8Array = arg2.toBoolean(globalObject);
}
RELEASE_AND_RETURN(throwScope, flattenArrayOfBuffersIntoArrayBufferOrUint8Array(globalObject, arrayValue, maxLength, asUint8Array));
}
JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArrays);
static JSValue constructBunVersion(VM& vm, JSObject*)
{
return JSC::jsString(vm, makeString(ASCIILiteral::fromLiteralUnsafe(Bun__version + 1)));
}
static JSValue constructBunRevision(VM& vm, JSObject*)
{
return JSC::jsString(vm, makeString(ASCIILiteral::fromLiteralUnsafe(Bun__version_sha)));
}
static JSValue constructBunVersionWithSha(VM& vm, JSObject*)
{
return JSC::jsString(vm, makeString(ASCIILiteral::fromLiteralUnsafe(Bun__version_with_sha)));
}
static JSValue constructIsMainThread(VM&, JSObject* object)
{
return jsBoolean(jsCast<Zig::GlobalObject*>(object->globalObject())->scriptExecutionContext()->isMainThread());
}
static JSValue constructPluginObject(VM& vm, JSObject* bunObject)
{
auto* globalObject = bunObject->globalObject();
JSFunction* pluginFunction = JSFunction::create(vm, globalObject, 1, String("plugin"_s), jsFunctionBunPlugin, ImplementationVisibility::Public, NoIntrinsic);
pluginFunction->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "clearAll"_s), 1, jsFunctionBunPluginClear, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
return pluginFunction;
}
static JSValue defaultBunSQLObject(VM& vm, JSObject* bunObject)
{
auto scope = DECLARE_THROW_SCOPE(vm);
auto* globalObject = defaultGlobalObject(bunObject->globalObject());
JSValue sqlValue = globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::BunSql);
#if BUN_DEBUG
if (scope.exception()) globalObject->reportUncaughtExceptionAtEventLoop(globalObject, scope.exception());
#endif
RETURN_IF_EXCEPTION(scope, {});
RELEASE_AND_RETURN(scope, sqlValue.getObject()->get(globalObject, vm.propertyNames->defaultKeyword));
}
static JSValue constructBunSQLObject(VM& vm, JSObject* bunObject)
{
auto scope = DECLARE_THROW_SCOPE(vm);
auto* globalObject = defaultGlobalObject(bunObject->globalObject());
JSValue sqlValue = globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::BunSql);
#if BUN_DEBUG
if (scope.exception()) globalObject->reportUncaughtExceptionAtEventLoop(globalObject, scope.exception());
#endif
RETURN_IF_EXCEPTION(scope, {});
auto clientData = WebCore::clientData(vm);
RELEASE_AND_RETURN(scope, sqlValue.getObject()->get(globalObject, clientData->builtinNames().SQLPublicName()));
}
extern "C" JSC::EncodedJSValue JSPasswordObject__create(JSGlobalObject*);
static JSValue constructPasswordObject(VM& vm, JSObject* bunObject)
{
return JSValue::decode(JSPasswordObject__create(bunObject->globalObject()));
}
JSValue constructBunFetchObject(VM& vm, JSObject* bunObject)
{
JSFunction* fetchFn = JSFunction::create(vm, bunObject->globalObject(), 1, "fetch"_s, Bun__fetch, ImplementationVisibility::Public, NoIntrinsic);
auto* globalObject = jsCast<Zig::GlobalObject*>(bunObject->globalObject());
fetchFn->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "preconnect"_s), 1, Bun__fetchPreconnect, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
return fetchFn;
}
static JSValue constructBunShell(VM& vm, JSObject* bunObject)
{
auto* globalObject = jsCast<Zig::GlobalObject*>(bunObject->globalObject());
JSFunction* createParsedShellScript = JSFunction::create(vm, bunObject->globalObject(), 2, "createParsedShellScript"_s, BunObject_callback_createParsedShellScript, ImplementationVisibility::Private, NoIntrinsic);
JSFunction* createShellInterpreterFunction = JSFunction::create(vm, bunObject->globalObject(), 1, "createShellInterpreter"_s, BunObject_callback_createShellInterpreter, ImplementationVisibility::Private, NoIntrinsic);
JSC::JSFunction* createShellFn = JSC::JSFunction::create(vm, globalObject, shellCreateBunShellTemplateFunctionCodeGenerator(vm), globalObject);
auto scope = DECLARE_THROW_SCOPE(vm);
auto args = JSC::MarkedArgumentBuffer();
args.append(createShellInterpreterFunction);
args.append(createParsedShellScript);
JSC::JSValue shell = JSC::call(globalObject, createShellFn, args, "BunShell"_s);
RETURN_IF_EXCEPTION(scope, {});
if (!shell.isObject()) [[unlikely]] {
throwTypeError(globalObject, scope, "Internal error: BunShell constructor did not return an object"_s);
return {};
}
auto* bunShell = shell.getObject();
auto ShellError = bunShell->get(globalObject, JSC::Identifier::fromString(vm, "ShellError"_s));
RETURN_IF_EXCEPTION(scope, {});
if (!ShellError.isObject()) [[unlikely]] {
throwTypeError(globalObject, scope, "Internal error: BunShell.ShellError is not an object"_s);
return {};
}
bunShell->putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "braces"_s), 1, Generated::BunObject::jsBraces, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
bunShell->putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "escape"_s), 1, BunObject_callback_shellEscape, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
bunShell->putDirect(vm, JSC::Identifier::fromString(vm, "ShellError"_s), ShellError.getObject(), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | 0);
return bunShell;
}
static JSValue constructDNSObject(VM& vm, JSObject* bunObject)
{
JSGlobalObject* globalObject = bunObject->globalObject();
JSC::JSObject* dnsObject = JSC::constructEmptyObject(globalObject);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookup"_s), 2, Bun__DNS__lookup, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, vm.propertyNames->resolve, 2, Bun__DNS__resolve, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSrv"_s), 2, Bun__DNS__resolveSrv, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveTxt"_s), 2, Bun__DNS__resolveTxt, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveSoa"_s), 2, Bun__DNS__resolveSoa, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNaptr"_s), 2, Bun__DNS__resolveNaptr, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveMx"_s), 2, Bun__DNS__resolveMx, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCaa"_s), 2, Bun__DNS__resolveCaa, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveNs"_s), 2, Bun__DNS__resolveNs, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolvePtr"_s), 2, Bun__DNS__resolvePtr, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveCname"_s), 2, Bun__DNS__resolveCname, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "resolveAny"_s), 2, Bun__DNS__resolveAny, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getServers"_s), 2, Bun__DNS__getServers, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "setServers"_s), 2, Bun__DNS__setServers, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reverse"_s), 2, Bun__DNS__reverse, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "lookupService"_s), 2, Bun__DNS__lookupService, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "prefetch"_s), 2, Bun__DNS__prefetch, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getCacheStats"_s), 0, Bun__DNS__getCacheStats, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirect(vm, JSC::Identifier::fromString(vm, "ADDRCONFIG"_s), jsNumber(AI_ADDRCONFIG),
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirect(vm, JSC::Identifier::fromString(vm, "ALL"_s), jsNumber(AI_ALL),
JSC::PropertyAttribute::DontDelete | 0);
dnsObject->putDirect(vm, JSC::Identifier::fromString(vm, "V4MAPPED"_s), jsNumber(AI_V4MAPPED),
JSC::PropertyAttribute::DontDelete | 0);
return dnsObject;
}
JSC_DECLARE_HOST_FUNCTION(jsFunctionJSONLParse);
JSC_DECLARE_HOST_FUNCTION(jsFunctionJSONLParseChunk);
JSC_DEFINE_HOST_FUNCTION(jsFunctionJSONLParse, (JSGlobalObject * globalObject, CallFrame* callFrame))
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue arg = callFrame->argument(0);
if (arg.isUndefinedOrNull()) {
throwTypeError(globalObject, scope, "JSONL.parse requires a string argument"_s);
return {};
}
MarkedArgumentBuffer values;
JSC::StreamingJSONParseResult result;
if (arg.isCell() && isTypedArrayType(arg.asCell()->type())) {
auto* view = jsCast<JSC::JSArrayBufferView*>(arg.asCell());
if (view->isDetached()) {
throwTypeError(globalObject, scope, "ArrayBuffer is detached"_s);
return {};
}
auto* data = static_cast<const uint8_t*>(view->vector());
size_t length = view->byteLength();
// Skip UTF-8 BOM if present
if (length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) {
data += 3;
length -= 3;
}
if (length <= String::MaxLength && simdutf::validate_ascii(reinterpret_cast<const char*>(data), length)) {
auto chars = std::span { reinterpret_cast<const char8_t*>(data), length };
result = JSC::streamingJSONParse(globalObject, StringView(chars), values);
} else {
size_t u16Length = simdutf::utf16_length_from_utf8(reinterpret_cast<const char*>(data), length);
if (u16Length > String::MaxLength) {
throwOutOfMemoryError(globalObject, scope);
return {};
}
auto str = WTF::String::fromUTF8ReplacingInvalidSequences(std::span { reinterpret_cast<const char8_t*>(data), length });
if (str.isNull()) {
throwOutOfMemoryError(globalObject, scope);
return {};
}
result = JSC::streamingJSONParse(globalObject, str, values);
}
} else {
auto* inputString = arg.toString(globalObject);
RETURN_IF_EXCEPTION(scope, {});
auto view = inputString->view(globalObject);
RETURN_IF_EXCEPTION(scope, {});
result = JSC::streamingJSONParse(globalObject, view, values);
}
RETURN_IF_EXCEPTION(scope, {});
if (result.status == JSC::StreamingJSONParseResult::Status::Error && values.isEmpty()) {
throwSyntaxError(globalObject, scope, "Failed to parse JSONL"_s);
return {};
}
RELEASE_AND_RETURN(scope, JSValue::encode(constructArray(globalObject, static_cast<ArrayAllocationProfile*>(nullptr), values)));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionJSONLParseChunk, (JSGlobalObject * globalObject, CallFrame* callFrame))
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue arg = callFrame->argument(0);
if (arg.isUndefinedOrNull()) {
throwTypeError(globalObject, scope, "JSONL.parseChunk requires a string argument"_s);
return {};
}
MarkedArgumentBuffer values;
JSC::StreamingJSONParseResult result;
size_t readBytes = 0;
bool isTypedArray = arg.isCell() && isTypedArrayType(arg.asCell()->type());
if (isTypedArray) {
auto* view = jsCast<JSC::JSArrayBufferView*>(arg.asCell());
if (view->isDetached()) {
throwTypeError(globalObject, scope, "ArrayBuffer is detached"_s);
return {};
}
auto* data = static_cast<const uint8_t*>(view->vector());
size_t length = view->byteLength();
// Apply optional start/end offsets (byte offsets for typed arrays)
size_t start = 0;
size_t end = length;
JSValue startArg = callFrame->argument(1);
if (startArg.isNumber()) {
double s = startArg.asNumber();
if (s > 0)
start = static_cast<size_t>(std::min(s, static_cast<double>(length)));
}
JSValue endArg = callFrame->argument(2);
if (endArg.isNumber()) {
double e = endArg.asNumber();
if (e >= 0)
end = static_cast<size_t>(std::min(e, static_cast<double>(length)));
}
if (start > end)
start = end;
const uint8_t* sliceData = data + start;
size_t sliceLen = end - start;
// Skip UTF-8 BOM if present at the start of the slice
size_t bomOffset = 0;
if (start == 0 && sliceLen >= 3 && sliceData[0] == 0xEF && sliceData[1] == 0xBB && sliceData[2] == 0xBF) {
sliceData += 3;
sliceLen -= 3;
bomOffset = 3;
}
if (sliceLen <= String::MaxLength && simdutf::validate_ascii(reinterpret_cast<const char*>(sliceData), sliceLen)) {
auto chars = std::span { reinterpret_cast<const char8_t*>(sliceData), sliceLen };
result = JSC::streamingJSONParse(globalObject, StringView(chars), values);
// For ASCII, byte offset = character offset
readBytes = start + bomOffset + result.charactersConsumed;
} else {
size_t u16Length = simdutf::utf16_length_from_utf8(reinterpret_cast<const char*>(sliceData), sliceLen);
if (u16Length > String::MaxLength) {
throwOutOfMemoryError(globalObject, scope);
return {};
}
auto str = WTF::String::fromUTF8ReplacingInvalidSequences(std::span { reinterpret_cast<const char8_t*>(sliceData), sliceLen });
if (str.isNull()) {
throwOutOfMemoryError(globalObject, scope);
return {};
}
result = JSC::streamingJSONParse(globalObject, str, values);
// Convert character offset back to UTF-8 byte offset
if (str.is8Bit()) {
readBytes = start + bomOffset + simdutf::utf8_length_from_latin1(reinterpret_cast<const char*>(str.span8().data()), result.charactersConsumed);
} else {
readBytes = start + bomOffset + simdutf::utf8_length_from_utf16le(reinterpret_cast<const char16_t*>(str.span16().data()), result.charactersConsumed);
}
}
} else {
auto* inputString = arg.toString(globalObject);
RETURN_IF_EXCEPTION(scope, {});
auto view = inputString->view(globalObject);
RETURN_IF_EXCEPTION(scope, {});
result = JSC::streamingJSONParse(globalObject, view, values);
readBytes = result.charactersConsumed;
}
RETURN_IF_EXCEPTION(scope, {});
JSArray* array = constructArray(globalObject, static_cast<ArrayAllocationProfile*>(nullptr), values);
RETURN_IF_EXCEPTION(scope, {});
JSValue errorValue = jsNull();
if (result.status == JSC::StreamingJSONParseResult::Status::Error) {
errorValue = createSyntaxError(globalObject, "Failed to parse JSONL"_s);
}
auto* zigGlobalObject = jsCast<Zig::GlobalObject*>(globalObject);
JSObject* resultObj = constructEmptyObject(vm, zigGlobalObject->jsonlParseResultStructure());
resultObj->putDirectOffset(vm, 0, array);
resultObj->putDirectOffset(vm, 1, jsNumber(readBytes));
resultObj->putDirectOffset(vm, 2, jsBoolean(result.status == JSC::StreamingJSONParseResult::Status::Complete));
resultObj->putDirectOffset(vm, 3, errorValue);
return JSValue::encode(resultObj);
}
static JSValue constructJSONLObject(VM& vm, JSObject* bunObject)
{
JSGlobalObject* globalObject = bunObject->globalObject();
JSC::JSObject* jsonlObject = JSC::constructEmptyObject(globalObject);
jsonlObject->putDirectNativeFunction(vm, globalObject, vm.propertyNames->parse, 1, jsFunctionJSONLParse, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
jsonlObject->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "parseChunk"_s), 1, jsFunctionJSONLParseChunk, ImplementationVisibility::Public, NoIntrinsic,
JSC::PropertyAttribute::DontDelete | 0);
jsonlObject->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsNontrivialString(vm, "JSONL"_s),
JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly);
return jsonlObject;
}
static JSValue constructBunPeekObject(VM& vm, JSObject* bunObject)
{
JSGlobalObject* globalObject = bunObject->globalObject();
JSC::Identifier identifier = JSC::Identifier::fromString(vm, "peek"_s);
JSFunction* peekFunction = JSFunction::create(vm, globalObject, peekPeekCodeGenerator(vm), globalObject->globalScope());
JSFunction* peekStatus = JSFunction::create(vm, globalObject, peekPeekStatusCodeGenerator(vm), globalObject->globalScope());
peekFunction->putDirect(vm, PropertyName(JSC::Identifier::fromString(vm, "status"_s)), peekStatus, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
return peekFunction;
}
extern "C" uint64_t Bun__readOriginTimer(void*);
extern "C" double Bun__readOriginTimerStart(void*);
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionBunEscapeHTMLWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSObject*, JSString*));
JSC_DEFINE_HOST_FUNCTION(functionBunSleep,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto& vm = JSC::getVM(globalObject);
JSC::JSValue millisecondsValue = callFrame->argument(0);
if (millisecondsValue.inherits<JSC::DateInstance>()) {
auto now = MonotonicTime::now();
double milliseconds = jsCast<JSC::DateInstance*>(millisecondsValue)->internalNumber() - now.approximateWallTime().secondsSinceEpoch().milliseconds();
millisecondsValue = JSC::jsNumber(milliseconds > 0 ? std::ceil(milliseconds) : 0);
}
if (!millisecondsValue.isNumber()) {
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
JSC::throwTypeError(globalObject, scope, "sleep expects a number (milliseconds)"_s);
return {};
}
JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure());
Bun__Timer__sleep(globalObject, JSValue::encode(promise), JSC::JSValue::encode(millisecondsValue));
return JSC::JSValue::encode(promise);
}
extern "C" JSC::EncodedJSValue Bun__escapeHTML8(JSGlobalObject* globalObject, JSC::EncodedJSValue input, const Latin1Character* ptr, size_t length);
extern "C" JSC::EncodedJSValue Bun__escapeHTML16(JSGlobalObject* globalObject, JSC::EncodedJSValue input, const char16_t* ptr, size_t length);
JSC_DEFINE_HOST_FUNCTION(functionBunEscapeHTML, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
auto& vm = JSC::getVM(lexicalGlobalObject);
JSC::JSValue argument = callFrame->argument(0);
if (argument.isEmpty())
return JSValue::encode(jsEmptyString(vm));
if (argument.isNumber() || argument.isBoolean() || argument.isUndefined() || argument.isNull())
return JSValue::encode(argument.toString(lexicalGlobalObject));
auto scope = DECLARE_THROW_SCOPE(vm);
auto string = argument.toString(lexicalGlobalObject);
RETURN_IF_EXCEPTION(scope, {});
if (string->length() == 0)
RELEASE_AND_RETURN(scope, JSValue::encode(string));
auto resolvedString = string->view(lexicalGlobalObject);
RETURN_IF_EXCEPTION(scope, {});
JSC::EncodedJSValue encodedInput = JSValue::encode(string);
if (!resolvedString->is8Bit()) {
const auto span = resolvedString->span16();
RELEASE_AND_RETURN(scope, Bun__escapeHTML16(lexicalGlobalObject, encodedInput, span.data(), span.size()));
} else {
const auto span = resolvedString->span8();
RELEASE_AND_RETURN(scope, Bun__escapeHTML8(lexicalGlobalObject, encodedInput, span.data(), span.size()));
}
}
JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto* global = reinterpret_cast<GlobalObject*>(globalObject);
auto& vm = JSC::getVM(global);
auto scope = DECLARE_THROW_SCOPE(vm);
if (callFrame->argumentCount() < 2) {
auto throwScope = DECLARE_THROW_SCOPE(vm);
throwTypeError(globalObject, throwScope, "Expected 2 values to compare"_s);
return {};
}
JSC::JSValue arg1 = callFrame->uncheckedArgument(0);
JSC::JSValue arg2 = callFrame->uncheckedArgument(1);
JSC::JSValue strict = callFrame->argument(2);
Vector<std::pair<JSValue, JSValue>, 16> stack;
MarkedArgumentBuffer gcBuffer;
if (strict.isBoolean() && strict.asBoolean()) {
bool isEqual = Bun__deepEquals<true, false>(globalObject, arg1, arg2, gcBuffer, stack, scope, true);
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(jsBoolean(isEqual));
} else {
bool isEqual = Bun__deepEquals<false, false>(globalObject, arg1, arg2, gcBuffer, stack, scope, true);
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(jsBoolean(isEqual));
}
}
JSC_DEFINE_HOST_FUNCTION(functionBunDeepMatch, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto* global = reinterpret_cast<GlobalObject*>(globalObject);
auto& vm = JSC::getVM(global);
auto scope = DECLARE_THROW_SCOPE(vm);
if (callFrame->argumentCount() < 2) {
throwTypeError(globalObject, scope, "Expected 2 values to compare"_s);
return {};
}
JSC::JSValue subset = callFrame->uncheckedArgument(0);
JSC::JSValue object = callFrame->uncheckedArgument(1);
if (!subset.isObject() || !object.isObject()) {
throwTypeError(globalObject, scope, "Expected 2 objects to match"_s);
return {};
}
std::set<EncodedJSValue> objVisited;
std::set<EncodedJSValue> subsetVisited;
MarkedArgumentBuffer gcBuffer;
bool match = Bun__deepMatch</* enableAsymmetricMatchers */ false>(object, &objVisited, subset, &subsetVisited, globalObject, scope, &gcBuffer, false, false);
RETURN_IF_EXCEPTION(scope, {});
return JSValue::encode(jsBoolean(match));
}
JSC_DEFINE_HOST_FUNCTION(functionBunNanoseconds, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
uint64_t time = Bun__readOriginTimer(bunVM(globalObject));
return JSValue::encode(jsNumber(time));
}
JSC_DEFINE_HOST_FUNCTION(functionPathToFileURL, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame))
{
auto& globalObject = *defaultGlobalObject(lexicalGlobalObject);
auto& vm = globalObject.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto pathValue = callFrame->argument(0);
JSValue jsValue;
{
WTF::String pathString = pathValue.toWTFString(lexicalGlobalObject);
RETURN_IF_EXCEPTION(throwScope, {});
pathString = pathResolveWTFString(lexicalGlobalObject, pathString);
auto fileURL = WTF::URL::fileURLWithFileSystemPath(pathString);
auto object = WebCore::DOMURL::create(fileURL.string(), String());
jsValue = WebCore::toJSNewlyCreated<IDLInterface<DOMURL>>(*lexicalGlobalObject, globalObject, throwScope, WTF::move(object));
}
auto* jsDOMURL = jsCast<JSDOMURL*>(jsValue.asCell());
vm.heap.reportExtraMemoryAllocated(jsDOMURL, jsDOMURL->wrapped().memoryCostForGC());
RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(jsValue));
}
JSC_DEFINE_HOST_FUNCTION(functionGenerateHeapSnapshot, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto& vm = JSC::getVM(globalObject);
vm.ensureHeapProfiler();
auto& heapProfiler = *vm.heapProfiler();
heapProfiler.clearSnapshots();
Bun__Feature__heap_snapshot += 1;
JSValue arg0 = callFrame->argument(0);
auto throwScope = DECLARE_THROW_SCOPE(vm);
bool useV8 = false;
if (!arg0.isUndefined()) {
if (arg0.isString()) {
auto str = arg0.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
if (str == "v8"_s) {
useV8 = true;
} else if (str == "jsc"_s) {
// do nothing
} else {
throwTypeError(globalObject, throwScope, "Expected 'v8' or 'jsc' or undefined"_s);
return {};
}
}
}
if (useV8) {
JSC::BunV8HeapSnapshotBuilder builder(heapProfiler);
return JSC::JSValue::encode(jsString(vm, builder.json()));
}
JSC::HeapSnapshotBuilder builder(heapProfiler);
builder.buildSnapshot();
auto json = builder.json();
// Returning an object was a bad idea but it's a breaking change
// so we'll just keep it for now.
JSC::JSValue jsonValue = JSONParseWithException(globalObject, json);
RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(jsonValue));
}
JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto& vm = JSC::getVM(globalObject);
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue arg0 = callFrame->argument(0);
WTF::URL url;
auto path = JSC::JSValue::encode(arg0);
auto* domURL = WebCoreCast<WebCore::JSDOMURL, WebCore::DOMURL>(path);
if (!domURL) {
if (arg0.isString()) {
url = WTF::URL(arg0.toWTFString(globalObject));
RETURN_IF_EXCEPTION(scope, {});
} else {
Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, "url"_s, "string"_s, arg0);
return {};
}
} else {
url = domURL->href();
}
/// cannot turn non-`file://` URLs into file paths
if (!url.protocolIsFile()) [[unlikely]] {
Bun::ERR::INVALID_URL_SCHEME(scope, globalObject, "file"_s);
return {};
}
// NOTE: On Windows, WTF::URL::fileSystemPath will handle UNC paths
// (`file:\\server\share\etc` -> `\\server\share\etc`), so hostname check only
// needs to happen on posix systems
#if !OS(WINDOWS)
// file://host/path is illegal if `host` is not `localhost`.
// Should be `file:///` instead
if (url.host().length() > 0 && url.host() != "localhost"_s) [[unlikely]] {
#if OS(DARWIN)
Bun::ERR::INVALID_FILE_URL_HOST(scope, globalObject, "darwin"_s);
return {};
#else
Bun::ERR::INVALID_FILE_URL_HOST(scope, globalObject, "linux"_s);
return {};
#endif
}
#endif
// ban url-encoded slashes. '/' on posix, '/' and '\' on windows.
const StringView p = url.path();
if (p.contains('%')) {
#if OS(WINDOWS)
if (p.contains("%2f"_s) || p.contains("%5c"_s) || p.contains("%2F"_s) || p.contains("%5C"_s)) {
Bun::ERR::INVALID_FILE_URL_PATH(scope, globalObject, "must not include encoded \\ or / characters"_s);
return {};
}
#else
if (p.contains("%2f"_s) || p.contains("%2F"_s)) {
Bun::ERR::INVALID_FILE_URL_PATH(scope, globalObject, "must not include encoded / characters"_s);
return {};
}
#endif
}
auto fileSystemPath = url.fileSystemPath();
#if OS(WINDOWS)
if (!isAbsolutePath(fileSystemPath)) {
Bun::ERR::INVALID_FILE_URL_PATH(scope, globalObject, "must be an absolute path"_s);
return {};
}
#endif
return JSC::JSValue::encode(JSC::jsString(vm, fileSystemPath));
}
/* Source for BunObject.lut.h
@begin bunObjectTable
$ constructBunShell DontDelete|PropertyCallback
Archive BunObject_lazyPropCb_wrap_Archive DontDelete|PropertyCallback
ArrayBufferSink BunObject_lazyPropCb_wrap_ArrayBufferSink DontDelete|PropertyCallback
Cookie constructCookieObject DontDelete|ReadOnly|PropertyCallback
CookieMap constructCookieMapObject DontDelete|ReadOnly|PropertyCallback
CryptoHasher BunObject_lazyPropCb_wrap_CryptoHasher DontDelete|PropertyCallback
FFI BunObject_lazyPropCb_wrap_FFI DontDelete|PropertyCallback
FileSystemRouter BunObject_lazyPropCb_wrap_FileSystemRouter DontDelete|PropertyCallback
Glob BunObject_lazyPropCb_wrap_Glob DontDelete|PropertyCallback
MD4 BunObject_lazyPropCb_wrap_MD4 DontDelete|PropertyCallback
MD5 BunObject_lazyPropCb_wrap_MD5 DontDelete|PropertyCallback
SHA1 BunObject_lazyPropCb_wrap_SHA1 DontDelete|PropertyCallback
SHA224 BunObject_lazyPropCb_wrap_SHA224 DontDelete|PropertyCallback
SHA256 BunObject_lazyPropCb_wrap_SHA256 DontDelete|PropertyCallback
SHA384 BunObject_lazyPropCb_wrap_SHA384 DontDelete|PropertyCallback
SHA512 BunObject_lazyPropCb_wrap_SHA512 DontDelete|PropertyCallback
SHA512_256 BunObject_lazyPropCb_wrap_SHA512_256 DontDelete|PropertyCallback
JSONC BunObject_lazyPropCb_wrap_JSONC DontDelete|PropertyCallback
JSON5 BunObject_lazyPropCb_wrap_JSON5 DontDelete|PropertyCallback
JSONL constructJSONLObject ReadOnly|DontDelete|PropertyCallback
markdown BunObject_lazyPropCb_wrap_markdown DontDelete|PropertyCallback
mdx BunObject_lazyPropCb_wrap_mdx DontDelete|PropertyCallback
TOML BunObject_lazyPropCb_wrap_TOML DontDelete|PropertyCallback
YAML BunObject_lazyPropCb_wrap_YAML DontDelete|PropertyCallback
Transpiler BunObject_lazyPropCb_wrap_Transpiler DontDelete|PropertyCallback
embeddedFiles BunObject_lazyPropCb_wrap_embeddedFiles DontDelete|PropertyCallback
S3Client BunObject_lazyPropCb_wrap_S3Client DontDelete|PropertyCallback
s3 BunObject_lazyPropCb_wrap_s3 DontDelete|PropertyCallback
CSRF BunObject_lazyPropCb_wrap_CSRF DontDelete|PropertyCallback
allocUnsafe BunObject_callback_allocUnsafe DontDelete|Function 1
argv BunObject_lazyPropCb_wrap_argv DontDelete|PropertyCallback
build BunObject_callback_build DontDelete|Function 1
concatArrayBuffers functionConcatTypedArrays DontDelete|Function 3
connect BunObject_callback_connect DontDelete|Function 1
cwd BunObject_lazyPropCb_wrap_cwd DontEnum|DontDelete|PropertyCallback
color BunObject_callback_color DontDelete|Function 2
deepEquals functionBunDeepEquals DontDelete|Function 2
deepMatch functionBunDeepMatch DontDelete|Function 2
deflateSync BunObject_callback_deflateSync DontDelete|Function 1
dns constructDNSObject ReadOnly|DontDelete|PropertyCallback
enableANSIColors BunObject_lazyPropCb_wrap_enableANSIColors DontDelete|PropertyCallback
env constructEnvObject ReadOnly|DontDelete|PropertyCallback
escapeHTML functionBunEscapeHTML DontDelete|Function 2
fetch constructBunFetchObject ReadOnly|DontDelete|PropertyCallback
file BunObject_callback_file DontDelete|Function 1
fileURLToPath functionFileURLToPath DontDelete|Function 1
gc Generated::BunObject::jsGc DontDelete|Function 1
generateHeapSnapshot functionGenerateHeapSnapshot DontDelete|Function 1
gunzipSync BunObject_callback_gunzipSync DontDelete|Function 1
gzipSync BunObject_callback_gzipSync DontDelete|Function 1
hash BunObject_lazyPropCb_wrap_hash DontDelete|PropertyCallback
indexOfLine BunObject_callback_indexOfLine DontDelete|Function 1
inflateSync BunObject_callback_inflateSync DontDelete|Function 1
inspect BunObject_lazyPropCb_wrap_inspect DontDelete|PropertyCallback
isMainThread constructIsMainThread ReadOnly|DontDelete|PropertyCallback
jest BunObject_callback_jest DontEnum|DontDelete|Function 1
listen BunObject_callback_listen DontDelete|Function 1
udpSocket BunObject_callback_udpSocket DontDelete|Function 1
main bunObjectMain DontDelete|CustomAccessor
mmap BunObject_callback_mmap DontDelete|Function 1
nanoseconds functionBunNanoseconds DontDelete|Function 0
openInEditor BunObject_callback_openInEditor DontDelete|Function 1
origin BunObject_lazyPropCb_wrap_origin DontEnum|ReadOnly|DontDelete|PropertyCallback
version_with_sha constructBunVersionWithSha DontEnum|ReadOnly|DontDelete|PropertyCallback
password constructPasswordObject DontDelete|PropertyCallback
pathToFileURL functionPathToFileURL DontDelete|Function 1
peek constructBunPeekObject DontDelete|PropertyCallback
plugin constructPluginObject ReadOnly|DontDelete|PropertyCallback
randomUUIDv7 Bun__randomUUIDv7 DontDelete|Function 2
randomUUIDv5 Bun__randomUUIDv5 DontDelete|Function 3
readableStreamToArray JSBuiltin Builtin|Function 1
readableStreamToArrayBuffer JSBuiltin Builtin|Function 1
readableStreamToBytes JSBuiltin Builtin|Function 1
readableStreamToBlob JSBuiltin Builtin|Function 1
readableStreamToFormData JSBuiltin Builtin|Function 1
readableStreamToJSON JSBuiltin Builtin|Function 1
readableStreamToText JSBuiltin Builtin|Function 1
registerMacro BunObject_callback_registerMacro DontEnum|DontDelete|Function 1
resolve BunObject_callback_resolve DontDelete|Function 1
resolveSync BunObject_callback_resolveSync DontDelete|Function 1
revision constructBunRevision ReadOnly|DontDelete|PropertyCallback
semver BunObject_lazyPropCb_wrap_semver ReadOnly|DontDelete|PropertyCallback
sql defaultBunSQLObject DontDelete|PropertyCallback
postgres defaultBunSQLObject DontDelete|PropertyCallback
SQL constructBunSQLObject DontDelete|PropertyCallback
serve BunObject_callback_serve DontDelete|Function 1
sha BunObject_callback_sha DontDelete|Function 1
shrink BunObject_callback_shrink DontDelete|Function 1
sleep functionBunSleep DontDelete|Function 1
sleepSync BunObject_callback_sleepSync DontDelete|Function 1
spawn BunObject_callback_spawn DontDelete|Function 1
spawnSync BunObject_callback_spawnSync DontDelete|Function 1
stderr BunObject_lazyPropCb_wrap_stderr DontDelete|PropertyCallback
stdin BunObject_lazyPropCb_wrap_stdin DontDelete|PropertyCallback
stdout BunObject_lazyPropCb_wrap_stdout DontDelete|PropertyCallback
stringWidth Generated::BunObject::jsStringWidth DontDelete|Function 2
stripANSI jsFunctionBunStripANSI DontDelete|Function 1