aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/api/bun.zig65
-rw-r--r--src/bun.js/api/router.zig33
-rw-r--r--src/bun.js/javascript.zig11
-rw-r--r--src/bun.js/typescript.zig110
-rw-r--r--src/cli/run_command.zig1
-rw-r--r--src/typegen.zig5
6 files changed, 2 insertions, 223 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index ed3ad3710..f1719f00d 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -1013,143 +1013,87 @@ pub const Class = NewClass(
.{
.match = .{
.rfn = Router.match,
- .ts = Router.match_type_definition,
},
.sleepSync = .{
.rfn = sleepSync,
},
.fetch = .{
.rfn = Fetch.call,
- .ts = d.ts{},
},
.getImportedStyles = .{
.rfn = Bun.getImportedStyles,
- .ts = d.ts{
- .name = "getImportedStyles",
- .@"return" = "string[]",
- },
},
.inspect = .{
.rfn = Bun.inspect,
- .ts = d.ts{
- .name = "inspect",
- .@"return" = "string",
- },
},
.getRouteFiles = .{
.rfn = Bun.getRouteFiles,
- .ts = d.ts{
- .name = "getRouteFiles",
- .@"return" = "string[]",
- },
},
._Os = .{
.rfn = Bun.newOs,
- .ts = d.ts{},
},
._Path = .{
.rfn = Bun.newPath,
- .ts = d.ts{},
},
.getRouteNames = .{
.rfn = Bun.getRouteNames,
- .ts = d.ts{
- .name = "getRouteNames",
- .@"return" = "string[]",
- },
},
.readFile = .{
.rfn = Bun.readFileAsString,
- .ts = d.ts{
- .name = "readFile",
- .@"return" = "string",
- },
},
.resolveSync = .{
.rfn = Bun.resolveSync,
- .ts = d.ts{
- .name = "resolveSync",
- .@"return" = "string",
- },
},
.resolve = .{
.rfn = Bun.resolve,
- .ts = d.ts{
- .name = "resolve",
- .@"return" = "string",
- },
},
.readFileBytes = .{
.rfn = Bun.readFileAsBytes,
- .ts = d.ts{
- .name = "readFile",
- .@"return" = "Uint8Array",
- },
},
.getPublicPath = .{
.rfn = Bun.getPublicPathJS,
- .ts = d.ts{
- .name = "getPublicPath",
- .@"return" = "string",
- },
},
.registerMacro = .{
.rfn = Bun.registerMacro,
- .ts = d.ts{
- .name = "registerMacro",
- .@"return" = "undefined",
- },
.enumerable = false,
},
.fs = .{
.rfn = Bun.createNodeFS,
- .ts = d.ts{},
.enumerable = false,
},
.jest = .{
.rfn = @import("../test/jest.zig").Jest.call,
- .ts = d.ts{},
.enumerable = false,
},
.gc = .{
.rfn = Bun.runGC,
- .ts = d.ts{},
},
.allocUnsafe = .{
.rfn = Bun.allocUnsafe,
- .ts = .{},
},
.mmap = .{
.rfn = Bun.mmapFile,
- .ts = .{},
},
.generateHeapSnapshot = .{
.rfn = Bun.generateHeapSnapshot,
- .ts = d.ts{},
},
.shrink = .{
.rfn = Bun.shrink,
- .ts = d.ts{},
},
.openInEditor = .{
.rfn = Bun.openInEditor,
- .ts = d.ts{},
},
.readAllStdinSync = .{
.rfn = Bun.readAllStdinSync,
- .ts = d.ts{},
},
.serve = .{
.rfn = Bun.serve,
- .ts = d.ts{},
},
.file = .{
.rfn = JSC.WebCore.Blob.constructFile,
- .ts = d.ts{},
},
.write = .{
.rfn = JSC.WebCore.Blob.writeFile,
- .ts = d.ts{},
},
.sha = .{
.rfn = JSC.wrapWithHasContainer(Crypto.SHA512_256, "hash_", false, false, true),
@@ -1173,15 +1117,12 @@ pub const Class = NewClass(
.{
.main = .{
.get = getMain,
- .ts = d.ts{ .name = "main", .@"return" = "string" },
},
.cwd = .{
.get = getCWD,
- .ts = d.ts{ .name = "cwd", .@"return" = "string" },
},
.origin = .{
.get = getOrigin,
- .ts = d.ts{ .name = "origin", .@"return" = "string" },
},
.stdin = .{
.get = getStdin,
@@ -1194,15 +1135,12 @@ pub const Class = NewClass(
},
.routesDir = .{
.get = getRoutesDir,
- .ts = d.ts{ .name = "routesDir", .@"return" = "string" },
},
.assetPrefix = .{
.get = getAssetPrefix,
- .ts = d.ts{ .name = "assetPrefix", .@"return" = "string" },
},
.argv = .{
.get = getArgv,
- .ts = d.ts{ .name = "argv", .@"return" = "string[]" },
},
.env = .{
.get = EnvironmentVariables.getter,
@@ -1213,19 +1151,16 @@ pub const Class = NewClass(
},
.Transpiler = .{
.get = getTranspilerConstructor,
- .ts = d.ts{ .name = "Transpiler", .@"return" = "Transpiler.prototype" },
},
.hash = .{
.get = getHashObject,
},
.TOML = .{
.get = getTOMLObject,
- .ts = d.ts{ .name = "TOML", .@"return" = "TOML.prototype" },
},
.unsafe = .{
.get = getUnsafe,
},
-
.SHA1 = .{
.get = Crypto.SHA1.getter,
},
diff --git a/src/bun.js/api/router.zig b/src/bun.js/api/router.zig
index 318514d34..e23fb746c 100644
--- a/src/bun.js/api/router.zig
+++ b/src/bun.js/api/router.zig
@@ -178,39 +178,6 @@ fn createRouteObjectFromMatch(
return Instance.make(ctx, router);
}
-pub const match_type_definition = &[_]d.ts{
- .{
- .tsdoc = "Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent FetchEvent} to a `Route` from the local filesystem. Returns `null` if there is no match.",
- .args = &[_]d.ts.arg{
- .{
- .name = "event",
- .@"return" = "FetchEvent",
- },
- },
- .@"return" = "Route | null",
- },
- .{
- .tsdoc = "Match a `pathname` to a `Route` from the local filesystem. Returns `null` if there is no match.",
- .args = &[_]d.ts.arg{
- .{
- .name = "pathname",
- .@"return" = "string",
- },
- },
- .@"return" = "Route | null",
- },
- .{
- .tsdoc = "Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Request} to a `Route` from the local filesystem. Returns `null` if there is no match.",
- .args = &[_]d.ts.arg{
- .{
- .name = "request",
- .@"return" = "Request",
- },
- },
- .@"return" = "Route | null",
- },
-};
-
pub const Instance = NewClass(
Router,
.{
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index c8a336c5e..546ab36aa 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -2323,7 +2323,6 @@ pub const EventListenerMixin = struct {
.{
.@"callAsFunction" = .{
.rfn = Handler.addListener,
- .ts = d.ts{},
},
},
.{},
@@ -2413,7 +2412,6 @@ pub const ResolveError = struct {
.@"referrer" = .{
.@"get" = getReferrer,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
.@"code" = .{
.@"get" = getCode,
@@ -2422,27 +2420,22 @@ pub const ResolveError = struct {
.@"message" = .{
.@"get" = getMessage,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
.@"name" = .{
.@"get" = getName,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
.@"specifier" = .{
.@"get" = getSpecifier,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
.@"importKind" = .{
.@"get" = getImportKind,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
.@"position" = .{
.@"get" = getPosition,
.ro = true,
- .ts = d.ts{ .@"return" = "string" },
},
},
);
@@ -2897,9 +2890,9 @@ pub const HardcodedModule = enum {
.{ "node:path/win32", "node:path" },
.{ "node:perf_hooks", "node:perf_hooks" },
.{ "node:process", "node:process" },
+ .{ "node:stream", "node:stream" },
.{ "node:stream/consumer", "node:stream/consumer" },
.{ "node:stream/web", "node:stream/web" },
- .{ "node:stream", "node:stream" },
.{ "node:string_decoder", "node:string_decoder" },
.{ "node:timers", "node:timers" },
.{ "node:timers/promises", "node:timers/promises" },
@@ -2910,9 +2903,9 @@ pub const HardcodedModule = enum {
.{ "path/win32", "node:path" },
.{ "perf_hooks", "node:perf_hooks" },
.{ "process", "node:process" },
+ .{ "stream", "node:stream" },
.{ "stream/consumer", "node:stream/consumer" },
.{ "stream/web", "node:stream/web" },
- .{ "stream", "node:stream" },
.{ "string_decoder", "node:string_decoder" },
.{ "timers", "node:timers" },
.{ "timers/promises", "node:timers/promises" },
diff --git a/src/bun.js/typescript.zig b/src/bun.js/typescript.zig
deleted file mode 100644
index 725226781..000000000
--- a/src/bun.js/typescript.zig
+++ /dev/null
@@ -1,110 +0,0 @@
-const d = @import("./base.zig").d;
-const std = @import("std");
-const Router = @import("./api/router.zig");
-const builtin = @import("builtin");
-const io = std.io;
-const fs = std.fs;
-const process = std.process;
-const ChildProcess = std.ChildProcess;
-const Progress = std.Progress;
-const print = std.debug.print;
-const mem = std.mem;
-const testing = std.testing;
-const Allocator = std.mem.Allocator;
-const resolve_path = @import("../resolver/resolve_path.zig");
-const JSC = @import("../jsc.zig");
-const bun = @import("../global.zig");
-const string = bun.string;
-const strings = bun.strings;
-const default_allocator = bun.default_allocator;
-
-pub const bindgen = true;
-
-pub fn main() anyerror!void {
- const modules = comptime [_]d.ts.decl{
- JSC.Node.NodeFSBindings.typescriptDeclaration(),
- };
-
- const hidden_globals = comptime [_]d.ts.decl{
- JSC.WebCore.FetchEvent.Class.typescriptDeclaration(),
- };
-
- const globals = comptime [_]d.ts.decl{
- Router.Instance.typescriptDeclaration(),
- JSC.Bun.Class.typescriptDeclaration(),
- JSC.BuildError.Class.typescriptDeclaration(),
- JSC.ResolveError.Class.typescriptDeclaration(),
- JSC.WebCore.Response.Class.typescriptDeclaration(),
- JSC.WebCore.Headers.Class.typescriptDeclaration(),
- JSC.EventListenerMixin.addEventListener(JSC.VirtualMachine).typescriptDeclaration(),
- JSC.WebCore.Fetch.Class.typescriptDeclaration(),
- JSC.Performance.Class.typescriptDeclaration(),
- JSC.Crypto.Class.typescriptDeclaration(),
- JSC.API.Transpiler.Class.typescriptDeclaration(),
- };
-
- var allocator = default_allocator;
- var argv = std.mem.span(std.os.argv);
- var dest = [_]string{ std.mem.span(argv[argv.len - 2]), std.mem.span(argv[argv.len - 1]) };
- var stdout = std.io.getStdOut();
- var writer = stdout.writer();
- try writer.print("{s}/{s}\n", .{ dest[0], dest[1] });
- var dir_path = resolve_path.joinAbsString(try std.process.getCwdAlloc(allocator), &dest, .auto);
-
- std.debug.assert(dir_path.len > 0 and strings.eqlComptime(std.fs.path.basename(dir_path), "types"));
- std.fs.deleteTreeAbsolute(dir_path) catch {};
- try std.fs.makeDirAbsolute(dir_path);
- var dir = try std.fs.openDirAbsolute(dir_path, std.fs.Dir.OpenDirOptions{});
- var index_file = try dir.createFile("index.d.ts", .{});
- try index_file.writeAll(
- \\/// <reference no-default-lib="true" />
- \\/// <reference lib="esnext" />
- \\/// <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(
- \\// bun.js v
- \\
- \\
- );
- inline for (globals) |global| {
- try global_file.writeAll(comptime d.ts.class.Printer.printDecl(global, 0));
- }
-
- var module_file = try dir.createFile("modules.d.ts", .{});
- try module_file.writeAll(
- \\// bun.js v
- \\
- \\
- );
-
- try global_file.writeAll("\n");
-
- try global_file.writeAll("declare global {\n");
-
- inline for (hidden_globals) |module, i| {
- if (i > 0) {
- try global_file.writeAll("\n");
- }
- try global_file.writeAll(comptime d.ts.class.Printer.printDecl(module, 2));
- }
-
- try global_file.writeAll("}\n\n");
- try stdout.writeAll(" ✔️ index.d.ts\n");
-
- inline for (modules) |decl| {
- comptime var module: d.ts.module = decl.module;
- const basepath = comptime module.path;
- if (std.fs.path.dirname(basepath)) |dirname| {
- try dir.makePath(dirname);
- }
-
- try module_file.writeAll(comptime d.ts.class.Printer.printDecl(decl, 0));
- try stdout.writeAll(comptime " ✔️ " ++ basepath ++ " - modules.d.ts\n");
- }
-
- try global_file.writeAll("export {};\n");
-}
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index ab16cdfcc..c4653e853 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -397,7 +397,6 @@ pub const RunCommand = struct {
this_bundler.runEnvLoader() catch {};
if (root_dir_info.getEntries()) |dir| {
-
// Run .env again if it exists in a parent dir
if (this_bundler.options.production) {
this_bundler.env.load(&this_bundler.fs.fs, dir, false) catch {};
diff --git a/src/typegen.zig b/src/typegen.zig
deleted file mode 100644
index 4ddaca4a6..000000000
--- a/src/typegen.zig
+++ /dev/null
@@ -1,5 +0,0 @@
-pub const bindgen = true;
-
-pub fn main() anyerror!void {
- return try @import("bun.js/typescript.zig").main();
-}