diff options
Diffstat (limited to 'src/javascript')
| -rw-r--r-- | src/javascript/jsc/api/router.zig | 4 | ||||
| -rw-r--r-- | src/javascript/jsc/bindings/DefaultGlobal.cpp | 46 | ||||
| -rw-r--r-- | src/javascript/jsc/bindings/DefaultGlobal.h | 101 | ||||
| -rw-r--r-- | src/javascript/jsc/bindings/ZigGlobalObject.cpp | 2 | ||||
| -rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 4 | ||||
| -rw-r--r-- | src/javascript/jsc/config.zig | 10 | ||||
| -rw-r--r-- | src/javascript/jsc/javascript.zig | 18 | ||||
| -rw-r--r-- | src/javascript/jsc/typescript.zig | 10 |
8 files changed, 96 insertions, 99 deletions
diff --git a/src/javascript/jsc/api/router.zig b/src/javascript/jsc/api/router.zig index 647dee2ea..143f8abb9 100644 --- a/src/javascript/jsc/api/router.zig +++ b/src/javascript/jsc/api/router.zig @@ -368,7 +368,7 @@ pub fn getScriptSrcString( // instead, we just store a boolean saying whether we should generate this whenever the script is requested // this is kind of bad. we should consider instead a way to inline the contents of the script. if (client_framework_enabled) { - JavaScript.Wundle.getPublicPath( + JavaScript.Bun.getPublicPath( Bundler.ClientEntryPoint.generateEntryPointPath( &entry_point_tempbuf, Fs.PathName.init(file_path), @@ -377,7 +377,7 @@ pub fn getScriptSrcString( writer, ); } else { - JavaScript.Wundle.getPublicPath(file_path, ScriptSrcStream.Writer, writer); + JavaScript.Bun.getPublicPath(file_path, ScriptSrcStream.Writer, writer); } } diff --git a/src/javascript/jsc/bindings/DefaultGlobal.cpp b/src/javascript/jsc/bindings/DefaultGlobal.cpp index 9ca83d267..d143835aa 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.cpp +++ b/src/javascript/jsc/bindings/DefaultGlobal.cpp @@ -1,6 +1,6 @@ -#include "root.h" #include "DefaultGlobal.h" +#include "root.h" #include <wtf/text/AtomStringImpl.h> @@ -25,26 +25,19 @@ #include "JSCInlines.h" - - class Script; namespace JSC { - class Identifier; - class JSObject; - class JSString; - -} - +class Identifier; +class JSObject; +class JSString; +} // namespace JSC +namespace Bun { - -namespace Wundle { - - - -// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(DefaultGlobal) }; -// const GlobalObjectMethodTable DefaultGlobal::s_globalObjectMethodTable = { +// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, +// CREATE_METHOD_TABLE(DefaultGlobal) }; const GlobalObjectMethodTable +// DefaultGlobal::s_globalObjectMethodTable = { // &supportsRichSourceInfo, // &shouldInterruptScript, // &javaScriptRuntimeFlags, @@ -64,13 +57,18 @@ namespace Wundle { // nullptr, // instantiateStreaming // }; - -// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* exception) {} -// JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { -// JSInternalPromise* DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* specifierValue, JSValue, const SourceOrigin& sourceOrigin) { -// JSInternalPromise* DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, JSValue, JSValue) { -// JSC::JSObject* DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { -// JSValue DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode) { +// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* +// exception) {} JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, +// JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { JSInternalPromise* +// DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* +// specifierValue, JSValue, const SourceOrigin& sourceOrigin) { JSInternalPromise* +// DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, +// JSValue, JSValue) { JSC::JSObject* +// DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, +// JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { JSValue +// DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, +// JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue +// resumeMode) { // using namespace JSC; -}; +}; // namespace Bun diff --git a/src/javascript/jsc/bindings/DefaultGlobal.h b/src/javascript/jsc/bindings/DefaultGlobal.h index 6bc5eb0c9..ae174e049 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.h +++ b/src/javascript/jsc/bindings/DefaultGlobal.h @@ -1,65 +1,64 @@ -#pragma once +#pragma once namespace JSC { - class Structure; - class Identifier; - -} +class Structure; +class Identifier; +} // namespace JSC + +#include "JSCInlines.h" #include "root.h" #include <JavaScriptCore/JSGlobalObject.h> -#include "JSCInlines.h" using namespace JSC; - -namespace Wundle { +namespace Bun { class Script; class DefaultGlobal final : public JSC::JSGlobalObject { -public: - using Base = JSC::JSGlobalObject; - - DECLARE_EXPORT_INFO; - static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; - - static constexpr bool needsDestruction = true; - template<typename CellType, SubspaceAccess mode> - static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return vm.apiGlobalObjectSpace<mode>(); - } - - static DefaultGlobal* create(JSC::VM& vm, JSC::Structure* structure) - { - auto* object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure); - object->finishCreation(vm); - return object; - } - - static Structure* createStructure(JSC::VM& vm, JSC::JSValue prototype) - { - auto* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); - result->setTransitionWatchpointIsLikelyToBeFired(true); - return result; - } - - static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, Exception*); - - static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSModuleLoader*, JSC::JSString* moduleNameValue, JSValue parameters, const SourceOrigin&); - static JSC::Identifier moduleLoaderResolve(JSGlobalObject*, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue); - static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue); - static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue); - static JSValue moduleLoaderEvaluate(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue, JSValue, JSValue); - - -private: - DefaultGlobal(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure, &s_globalObjectMethodTable) - { } + public: + using Base = JSC::JSGlobalObject; + + DECLARE_EXPORT_INFO; + static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; + + static constexpr bool needsDestruction = true; + template <typename CellType, SubspaceAccess mode> + static JSC::IsoSubspace *subspaceFor(JSC::VM &vm) { + return vm.apiGlobalObjectSpace<mode>(); + } + + static DefaultGlobal *create(JSC::VM &vm, JSC::Structure *structure) { + auto *object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure); + object->finishCreation(vm); + return object; + } + + static Structure *createStructure(JSC::VM &vm, JSC::JSValue prototype) { + auto *result = + Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); + result->setTransitionWatchpointIsLikelyToBeFired(true); + return result; + } + + static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, Exception *); + + static JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSModuleLoader *, + JSC::JSString *moduleNameValue, + JSValue parameters, const SourceOrigin &); + static JSC::Identifier moduleLoaderResolve(JSGlobalObject *, JSModuleLoader *, JSValue keyValue, + JSValue referrerValue, JSValue); + static JSInternalPromise *moduleLoaderFetch(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue, + JSValue); + static JSC::JSObject *moduleLoaderCreateImportMetaProperties(JSGlobalObject *, JSModuleLoader *, + JSValue, JSModuleRecord *, JSValue); + static JSValue moduleLoaderEvaluate(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue, JSValue, + JSValue, JSValue); + + private: + DefaultGlobal(JSC::VM &vm, JSC::Structure *structure) + : Base(vm, structure, &s_globalObjectMethodTable) {} }; - -} - +} // namespace Bun diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 45a68954e..762f8b5cc 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -340,7 +340,7 @@ JSC::JSObject *GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObje // metaProperties->putDirect(vm, Identifier::fromString(vm, "resolve"), // globalObject->globalThis() - // ->get(vm, Identifier::fromString("Wundle")) + // ->get(vm, Identifier::fromString("Bun")) // .getObject() // ->get(vm, Identifier::fromString("resolve"))); ); // RETURN_IF_EXCEPTION(scope, nullptr); diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 28e34717d..d1c76a6bb 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -937,10 +937,10 @@ fn _JSCellStub(comptime str: []const u8) type { } } -fn _Wundle(comptime str: []const u8) type { +fn _Bun(comptime str: []const u8) type { if (is_bindgen) { return opaque { - pub const name = "Wundle::" ++ str ++ ""; + pub const name = "Bun::" ++ str ++ ""; }; } else { return opaque {}; diff --git a/src/javascript/jsc/config.zig b/src/javascript/jsc/config.zig index affb1df68..2f91e433d 100644 --- a/src/javascript/jsc/config.zig +++ b/src/javascript/jsc/config.zig @@ -15,7 +15,7 @@ const http = @import("../../http.zig"); usingnamespace @import("./node_env_buf_map.zig"); -pub const DefaultSpeedyDefines = struct { +pub const DefaultBunDefines = struct { pub const Keys = struct { const window = "window"; }; @@ -24,18 +24,18 @@ pub const DefaultSpeedyDefines = struct { }; }; -pub fn configureTransformOptionsForSpeedyVM(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { +pub fn configureTransformOptionsForBunVM(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { var args = _args; // args.serve = false; args.write = false; args.resolve = Api.ResolveMode.lazy; args.generate_node_module_bundle = false; - return try configureTransformOptionsForSpeedy(allocator, args); + return try configureTransformOptionsForBun(allocator, args); } -pub fn configureTransformOptionsForSpeedy(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { +pub fn configureTransformOptionsForBun(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { var args = _args; - args.platform = Api.Platform.speedy; + args.platform = Api.Platform.bun; return args; } diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 29ede6112..a462515b7 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -32,10 +32,10 @@ pub const GlobalClasses = [_]type{ EventListenerMixin.addEventListener(VirtualMachine), BuildError.Class, ResolveError.Class, - Wundle.Class, + Bun.Class, }; -pub const Wundle = struct { +pub const Bun = struct { threadlocal var css_imports_list_strings: [512]ZigString = undefined; threadlocal var css_imports_list: [512]Api.StringPointer = undefined; threadlocal var css_imports_list_tail: u16 = 0; @@ -198,12 +198,12 @@ pub const Wundle = struct { pub const Class = NewClass( void, .{ - .name = "Wundle", + .name = "Bun", .read_only = true, .ts = .{ .module = .{ - .path = "speedy.js/router", - .tsdoc = "Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with Speedy.js.", + .path = "bun.js/router", + .tsdoc = "Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with Bun.js.", }, }, }, @@ -213,14 +213,14 @@ pub const Wundle = struct { .ts = Router.match_type_definition, }, .getImportedStyles = .{ - .rfn = Wundle.getImportedStyles, + .rfn = Bun.getImportedStyles, .ts = d.ts{ .name = "getImportedStyles", .@"return" = "string[]", }, }, .getRouteFiles = .{ - .rfn = Wundle.getRouteFiles, + .rfn = Bun.getRouteFiles, .ts = d.ts{ .name = "getRouteFiles", .@"return" = "string[]", @@ -302,7 +302,7 @@ pub const VirtualMachine = struct { const bundler = try Bundler.init( allocator, log, - try configureTransformOptionsForSpeedyVM(allocator, _args), + try configureTransformOptionsForBunVM(allocator, _args), existing_bundle, env_loader, ); @@ -322,7 +322,7 @@ pub const VirtualMachine = struct { try VirtualMachine.vm.bundler.configureFramework(false); if (_args.serve orelse false) { - VirtualMachine.vm.bundler.linker.onImportCSS = Wundle.onImportCSS; + VirtualMachine.vm.bundler.linker.onImportCSS = Bun.onImportCSS; } var global_classes: [GlobalClasses.len]js.JSClassRef = undefined; diff --git a/src/javascript/jsc/typescript.zig b/src/javascript/jsc/typescript.zig index e10df2b2f..b2273cfd9 100644 --- a/src/javascript/jsc/typescript.zig +++ b/src/javascript/jsc/typescript.zig @@ -43,14 +43,14 @@ pub fn main() anyerror!void { try index_file.writeAll( \\/// <reference no-default-lib="true" /> \\/// <reference lib="esnext" /> - \\/// <reference types="speedy.js/types/globals" /> - \\/// <reference types="speedy.js/types/modules" /> + \\/// <reference types="bun.js/types/globals" /> + \\/// <reference types="bun.js/types/modules" /> \\ ); var global_file = try dir.createFile("globals.d.ts", .{}); try global_file.writeAll( - \\// Speedy.js v + \\// Bun.js v \\ \\ ); @@ -58,7 +58,7 @@ pub fn main() anyerror!void { var module_file = try dir.createFile("modules.d.ts", .{}); try module_file.writeAll( - \\// Speedy.js v + \\// Bun.js v \\ \\ ); @@ -79,7 +79,7 @@ pub fn main() anyerror!void { inline for (modules) |decl| { comptime var module: d.ts.module = decl.module; - const basepath = comptime module.path["speedy.js/".len..]; + const basepath = comptime module.path["bun.js/".len..]; if (std.fs.path.dirname(basepath)) |dirname| { try dir.makePath(dirname); } |
